Skip to content

feat(web): surface remaining context-window utilization - #4

Merged
saucam merged 1 commit into
mainfrom
feat/web-context-window
May 5, 2026
Merged

feat(web): surface remaining context-window utilization#4
saucam merged 1 commit into
mainfrom
feat/web-context-window

Conversation

@saucam

@saucam saucam commented May 5, 2026

Copy link
Copy Markdown
Collaborator

Two daemon-fed surfaces: status bar pill + UsageStrip tile with progress bar. Numbers from SessionUsage.lastTurnInputTokens against Session.CONTEXT_WINDOW = 1_000_000.

Two surfaces, both fed from SessionUsage.lastTurnInputTokens against
the daemon's Session.CONTEXT_WINDOW constant (1_000_000 today):

  - StatusBar: compact `ctx N%` pill, color-cued green/warn/danger.
    Hover shows the raw `tokens / window (xx.x%)`.
  - SessionHeader UsageStrip: a dedicated "Context" tile leading the
    row, with a thin progress bar showing headroom at a glance. Grid
    grows from 7 to 8 columns so the existing tiles stay readable.

If the daemon ever emits per-session context_window on the wire (today
it's a hardcoded constant), swap the client constant for that field —
no other code change needed. Bundle / tests unchanged.
@saucam
saucam merged commit 5f197d1 into main May 5, 2026
saucam added a commit that referenced this pull request Jun 14, 2026
…scaling) (#12)

Adversarially-verified high-severity findings from a full-codebase audit.
(The scarier "stuck-status" race claims were refuted on verification and are
not touched here.)

#1 Dropped message after interrupt-then-fast-send (session.ts). The consumer
   `finally` nulled #inputQueue/#consumerTask without the identity guard it
   already used for #query/#abortController, so an un-awaited interrupt() + a
   fast send() let the stale loop clobber the new loop's queue/task and the
   next push was silently dropped. Capture a loop-local queue/task snapshot
   and guard the nulls by identity.

#2 Token never re-verified after handshake (auth.ts/server.ts/types.ts). An
   open socket honored an expired/revoked token forever. Carry `exp` into
   AuthContext, reject missing/expired exp in verifyToken (60s skew), and
   close 4003 on a per-message expiry check. (Instant revocation of a still
   -valid token still needs a periodic re-verify — tracked separately.)

#3 Web reconnect replayed the dead JWT forever (ws.ts/connection.ts). Add a
   getToken() supplier called on every (re)connect open that re-exchanges the
   stored zid_sk_ key for a fresh JWT; fall back to the last token if none.
   +2 tests.

#4 Vector recall had no cache despite the comment (memory/store.ts). Every
   recall re-read + re-decoded all embeddings and brute-forced cosine.
   Memoize the decoded matrix per workspace; invalidate on insert-with
   -embedding / setEmbedding.

#5 Memory init was all-or-nothing (engine.ts). An embedder download hiccup
   nulled the whole engine, also killing FTS recall + usage persistence. Wrap
   embedder.init() in try/catch and run FTS-only (vector signal off) on
   failure; recall and the embed pump guard on the ready flag.

#6 Unbounded session resume blocked startup (session-manager.ts, issue #6).
   Sort newest-first, cap to RESUME_MAX_SESSIONS, time-box to
   RESUME_DEADLINE_MS, and log what was left on disk.

Typecheck clean; 554 daemon tests + 95 web tests pass; build OK; live smoke
(auth+exp accepted, session.list) verified against the dev daemon.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
saucam added a commit that referenced this pull request Jul 16, 2026
…abel (#188)

Settings follow-ups (originally scoped as #2 + #4 + #5):

- #4 web: `/settings` (aliases `/config`, `/prefs`) opens the settings drawer,
  mirroring `/agents` etc. Wired through @codeoid/core slash → PromptBox
  showSettings → openSettings; added to the HelpModal catalog + slash tests.
- #5 telegram: a read-only `/settings` command that summarizes the current
  NON-default configuration (secret VALUES never shown — only which are set)
  plus the config.json/.env paths for editing. Reads the store in-process.
- #2: on inspection, the "hot" env knobs (context-strategy, seed-budget, codex
  approval/sandbox) already hot-apply to new sessions/turns via live process.env,
  so promoting them into config.json would make them restart-only — a regression.
  Kept env-backed; fixed the one real bug: the codex approval/sandbox policies
  were mislabeled `restart` in the manifest when they hot-apply → `next-session`.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant