#4788 [GUI] Add a context gauge and conversation summaries to browser chat
open · @orangeswim · 0 comments · View on GitHub
Setup & installServer & APIModels & quantsWindows
Description
[GUI] Add a context gauge and conversation summaries to browser chat ## Problem and result The browser chat has no context-usage display or command to summarize older messages. This adds a gauge beside the message box and a manual compaction button. The gauge updates from API-reported token usage after replies, independently of compaction. It warns at 70% and 90% of the context limit. After compaction, it displays an estimate until the next reply supplies a measured count. Local edits do not request a new count. Compaction asks the model to summarize older messages. They remain visible, while subsequent requests use their summary. Recent messages kept outside the summary retain files, images and tool results. The latest summary card can undo that compaction. Repeated compaction uses the previous summary and newer messages. With **Edit and rewind messages** enabled, **Edit summary** changes the summary text without removing other messages or changing which earlier messages it replaces. The edit sends no request and supports Undo. A long user message (over ten lines or 800 characters) is clamped to about ten lines with a fade; **Show all N lines** expands it in place, **Show less** collapses it again. ## Related discussion Split out of #1507 per the tracker reset for 0.2.0-beta: https://github.com/Niko1221/Strata/pull/1507#issuecomment-6444549518. This PR keeps the two related items together — the summary marker's context reading exists to feed the gauge, and the fold's effect is only visible through it. The third item, per-request timings, is filed separately. ## Approach The gauge reads `usage.prompt_tokens + completion_tokens` from the latest reply (or a fresh marker's post-fold estimate), formats with the existing `kfmt`/`ctxfmt` helpers, and sends nothing anywhere. Compaction is one hidden request: `compact-prompt.js` holds the summary prompt, and `compaction.js` owns the fold rules (pure, unit-tested) — the cut never crosses an earlier marker, so repeated compactions chain instead of orphaning older context, and the marker records its boundary. The kept window is budgeted on converted API messages, so attachments count, and an oversized paste cannot hijack it — it stays in the summarized part. Compaction, unfold and summary editing follow the existing history-lock rules, and messages queued during a compaction follow the normal `settlePending` rules. Editing a summary nulls the token counts that described the generated text rather than leaving them stale. <img width="936" height="288" alt="image" src="https://github.com/user-attachments/assets/886fdff2-8cc1-49d1-83ae-84884f4ff280" /> ## Validation Windows, Python 3.12.1, Node.js 22.15.0, headless Chrome. Tested code revision: `d76e90f2`. Browser tests used an external `puppeteer-core` installation through `WEBTEST_MODULES`; Python tests used isolated Jinja2 and regex dependencies. **Passed:** - `node serve/web/test_compaction.mjs` — 15 checks. - `node tools/webtest/browser_test.mjs` — 41 browser tests against the local mock server, including summary editing, Undo and reload. - `python -B -m unittest discover -s serve -p 'test_web*.py'` — 52 tests, 2 optional browser checks skipped. **Failed:** none in these final runs. **Not run:** real-model/GPU compaction and summary-recall validation. ## Limits The recent-message budget and context count after compaction are client estimates. Summaries can omit details.
Related on this site
Quick links to related pages.