From 69655416908768c4805ad20de8a3fdd8b2ed8291 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Sun, 28 Jun 2026 00:11:55 +0900 Subject: feat(step-context-update): update context window usage at end of each step --- src/features/chat/ui/Composer.svelte | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/features/chat/ui') diff --git a/src/features/chat/ui/Composer.svelte b/src/features/chat/ui/Composer.svelte index afe1e3c..04c28cd 100644 --- a/src/features/chat/ui/Composer.svelte +++ b/src/features/chat/ui/Composer.svelte @@ -39,8 +39,10 @@ onQueue?: (text: string) => void; /** Stop the in-flight generation (`POST /conversations/:id/stop`). */ onStop?: () => void; - // Current context occupancy (latest turn's contextSize), or `undefined` - // when unknown — the status bar then shows "— tokens", never 0%. + // Current context occupancy — updated progressively during a turn (the + // latest step's input+output) and finalized to the turn's `contextSize` on + // seal, or `undefined` when unknown — the status bar then shows + // "— tokens", never 0%. contextSize?: number | undefined; /** Per-model context window (max tokens) from `GET /models` modelInfo. */ contextWindow?: number | undefined; @@ -66,7 +68,6 @@ const canSend = $derived(hasText || hasImages); const effectiveMax = $derived(contextWindow ?? FALLBACK_CONTEXT_WINDOW); const usage = $derived(computeContextUsage(contextSize, effectiveMax)); - const hasUsage = $derived(contextSize !== undefined); // One button, three modes: // - idle → "Send" (starts a turn via chat.send) @@ -395,7 +396,7 @@ {/if} - {#if hasUsage} + {#if usage.current !== null} {formatCompactTokens(usage.current)}{#if usage.max !== null} -- cgit v1.2.3