diff options
| author | Adam Malczewski <[email protected]> | 2026-06-28 15:26:40 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-28 15:26:40 +0900 |
| commit | ed3425cb8ed57862f954505831be38a2588729bd (patch) | |
| tree | 518e613106fbe1c4dd1a0bbf786be4bae3cc1227 /src/features | |
| parent | 061f44e0efecb9cf9fa817875517390d09655104 (diff) | |
| parent | 9f2710f7686b0521c2503446437b3a45d42f6d66 (diff) | |
| download | dispatch-web-ed3425cb8ed57862f954505831be38a2588729bd.tar.gz dispatch-web-ed3425cb8ed57862f954505831be38a2588729bd.zip | |
Merge branch 'feature/step-context-update' into predev
Diffstat (limited to 'src/features')
| -rw-r--r-- | src/features/chat/store.svelte.ts | 9 | ||||
| -rw-r--r-- | src/features/chat/ui/Composer.svelte | 9 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/features/chat/store.svelte.ts b/src/features/chat/store.svelte.ts index 5278737..9911438 100644 --- a/src/features/chat/store.svelte.ts +++ b/src/features/chat/store.svelte.ts @@ -74,9 +74,12 @@ export interface ChatStore { readonly chunks: readonly RenderedChunk[]; readonly turnMetrics: readonly TurnMetricsEntry[]; /** - * The conversation's current context size (tokens occupied) — the latest - * finalized turn's `contextSize`, or `undefined` ("unknown") when none is - * known yet. Never `0` for the unknown case. + * The conversation's current context size (tokens occupied) — updated + * PROGRESSIVELY: during an in-flight turn, the most recent step's + * `inputTokens + outputTokens` (each step's input already includes all prior + * context); once the turn seals, its authoritative `contextSize`. `undefined` + * ("unknown") when no step has reported usage yet. Never `0` for the unknown + * case. */ readonly currentContextSize: number | undefined; /** 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} <span class="shrink-0 whitespace-nowrap font-mono"> - {#if hasUsage} + {#if usage.current !== null} {formatCompactTokens(usage.current)}{#if usage.max !== null}<span class="text-base-content/40" > |
