fix: the knowledge-context slider lives in the stats bar's left slot — the session-data spot — with a "tok" readout

The original vision, restored (owner, 2026-09-15): pre-chat the session-
data side of the under-composer stats bar is free real estate ("—" only),
so the budget slider mounts exactly where session data will sit once a
session exists — via a new StatsBar leftSlot — vertically centered with
the model + thinking pills by the row's own geometry. Short 96px slider
instead of a full-width one; readout abbreviates "1k tok" so >1k budgets
stay on one line ("4.1k tokens" wrapped). Home and /chat/new both.
This commit is contained in:
amosblomqvist
2026-09-15 08:00:04 +03:00
parent 1d45d77303
commit 4c7ad48c73
5 changed files with 69 additions and 43 deletions
+17 -16
View File
@@ -11,15 +11,19 @@ import { formatTokens } from "@/components/usage-format";
/**
* The knowledge-context budget control (vision-context-injection.md) — the
* "session data" section's one input, shown where sessions START: the home
* (graph) view's new-session dock and the /chat/new draft. Input before
* output: the panel that will later show what the session contributed to
* the graph asks first what the graph will contribute to the session.
* (graph) view's new-session dock and the /chat/new draft. It renders in
* the StatsBar's LEFT slot — the very place session data (context/cost)
* lives once a session exists, which pre-chat is free real estate (just
* "—"). Input before output: the panel that will later show what the
* session contributed to the graph asks first what the graph will
* contribute to the session.
*
* One quiet slider row: the token budget for the prior-knowledge block the
* injection steers in at session start. 0 = off; absent settings show the
* DEFAULT (1024 — on). The value rides ChatSettings (the same lifted
* settings the model picker uses), so it persists pre-chat via the same
* deferred PUT. Sessions never show this control — the injection is
* One quiet compact row sized to sit in the stats band beside the model +
* thinking pills: short slider, "tok" readout (abbreviated — "4.1k tok"
* stays on one line where "4.1k tokens" wrapped). 0 = off; absent settings
* show the DEFAULT (1024 — on). The value rides ChatSettings (the same
* lifted settings the model picker uses), so it persists pre-chat via the
* same deferred PUT. Sessions never show this control — the injection is
* one-shot at session start, so mid-session there is nothing to decide.
*/
export function GraphContextControl({
@@ -32,12 +36,9 @@ export function GraphContextControl({
testId?: string;
}) {
return (
<div
data-testid={testId}
className="flex items-center gap-2 px-1 text-xxs text-muted-foreground"
>
<div data-testid={testId} className="flex items-center gap-2 text-xs text-muted-foreground">
<BookOpenIcon className="size-3 shrink-0" />
<span className="shrink-0 uppercase tracking-widest">Knowledge context</span>
<span className="shrink-0">Knowledge context</span>
<input
type="range"
min={0}
@@ -46,14 +47,14 @@ export function GraphContextControl({
value={value}
onChange={(e) => onChange(Number(e.target.value))}
aria-label="Prior-knowledge token budget"
className="h-1 flex-1 accent-primary"
className="h-1 w-24 shrink-0 accent-primary"
data-testid="graph-context-slider"
/>
<span
className="w-16 shrink-0 text-right tabular-nums"
className="w-14 shrink-0 text-right tabular-nums"
data-testid="graph-context-value"
>
{value === 0 ? "off" : `${formatTokens(value)} tokens`}
{value === 0 ? "off" : `${formatTokens(value)} tok`}
</span>
</div>
);