[PR #1507] [CLOSED] # Chat: a context gauge, per-request timings, and conversation compaction #3498

Closed
opened 2026-11-07 14:41:53 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1507
Author: @orangeswim
Created: 10/8/2026
Status: ❌ Closed

Base: main ← Head: context-and-compaction-v2


📝 Commits (3)

  • d93c2ba Chat: a context gauge by the input
  • bf06bdb Chat + Monitor: per-request timings, and PP t/s in the requests table
  • c4d6cdb Chat: conversation compaction

📊 Changes

8 files changed (+486 additions, -21 deletions)

View changed files

📝 docs/DETAILS.md (+4 -1)
➕ serve/test_compaction.py (+30 -0)
📝 serve/web/app.css (+39 -0)
📝 serve/web/app.js (+233 -18)
➕ serve/web/compact-prompt.js (+20 -0)
➕ serve/web/compaction.js (+42 -0)
📝 serve/web/index.html (+11 -2)
➕ serve/web/test_compaction.mjs (+107 -0)

📄 Description

Chat: a context gauge, per-request timings, and conversation compaction

Re-opening of #350, which GitHub closed when main's history was cleaned up (not a rejection, per the heads-up there). Same change, rebuilt on the new main as three commits, one per feature. No server change.

What it adds:

  • A context gauge — a small pill in the composer bar (fill bar + token count, e.g. 2.4k/200K) showing how much of the context window the conversation uses. Amber at 70% of the window, red at 90%. Updates after each reply; passive.
  • Per-request timings, and a PP t/s column — a chevron on each reply opens one line with that request's numbers: tokens read and their speed, cache reuse, time to first token, drafts accepted (kept with the message). The Monitor's requests table gains a prompt-processing tokens/s column beside decode, computed in the UI from fields the server already returns (the reused cache share excluded; a fully cache-served request shows a dash). Also: the streaming cursor now shows from the moment a message is sent, while the prompt is still being read, not only once tokens arrive.
  • Conversation compaction — a button that asks the model itself to summarize the older turns: the newest turns stay verbatim up to a ~5k-token budget, the summary carries them as an exact client-built transcript, and from then on the API receives the summary plus the newer messages instead of everything. The page keeps every message (the summarized ones are dimmed above the divider, and only the newest summary can be put back — older ones are already contained in the one after them). Long user messages clamp with a Show-all toggle; display only. The payload rules live in web/compaction.js, tested by web/test_compaction.mjs (run through serve/test_compaction.py so unittest discover picks them up).

Notes for this rebase:

  • The one conflict (apiMessages) was resolved by folding #1392's "the answer being asked for now is not history yet" rule into the new callback form.
  • The compaction rules were aligned with #1392's error-turn policy: compaction.js no longer drops error turns itself — it only decides which messages the summary replaces; the converter decides how a turn is sent (so a turn with no answer text still goes back as an empty assistant turn, as on main).
image image image

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/1507 **Author:** [@orangeswim](https://github.com/orangeswim) **Created:** 10/8/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `context-and-compaction-v2` --- ### 📝 Commits (3) - [`d93c2ba`](https://github.com/Niko1221/Strata/commit/d93c2ba5c79fc7f3a5c7a34262a97b4f13d0a774) Chat: a context gauge by the input - [`bf06bdb`](https://github.com/Niko1221/Strata/commit/bf06bdbabeed7760c19a4cbe62d1429aee941601) Chat + Monitor: per-request timings, and PP t/s in the requests table - [`c4d6cdb`](https://github.com/Niko1221/Strata/commit/c4d6cdb85861cdd3b8afb7fed138a3ab516bea40) Chat: conversation compaction ### 📊 Changes **8 files changed** (+486 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+4 -1) ➕ `serve/test_compaction.py` (+30 -0) 📝 `serve/web/app.css` (+39 -0) 📝 `serve/web/app.js` (+233 -18) ➕ `serve/web/compact-prompt.js` (+20 -0) ➕ `serve/web/compaction.js` (+42 -0) 📝 `serve/web/index.html` (+11 -2) ➕ `serve/web/test_compaction.mjs` (+107 -0) </details> ### 📄 Description # Chat: a context gauge, per-request timings, and conversation compaction Re-opening of #350, which GitHub closed when main's history was cleaned up (not a rejection, per the heads-up there). Same change, rebuilt on the new main as three commits, one per feature. No server change. What it adds: - **A context gauge** — a small pill in the composer bar (fill bar + token count, e.g. `2.4k/200K`) showing how much of the context window the conversation uses. Amber at 70% of the window, red at 90%. Updates after each reply; passive. - **Per-request timings, and a PP t/s column** — a chevron on each reply opens one line with that request's numbers: tokens read and their speed, cache reuse, time to first token, drafts accepted (kept with the message). The Monitor's requests table gains a prompt-processing tokens/s column beside decode, computed in the UI from fields the server already returns (the reused cache share excluded; a fully cache-served request shows a dash). Also: the streaming cursor now shows from the moment a message is sent, while the prompt is still being read, not only once tokens arrive. - **Conversation compaction** — a button that asks the model itself to summarize the older turns: the newest turns stay verbatim up to a ~5k-token budget, the summary carries them as an exact client-built transcript, and from then on the API receives the summary plus the newer messages instead of everything. The page keeps every message (the summarized ones are dimmed above the divider, and only the newest summary can be put back — older ones are already contained in the one after them). Long user messages clamp with a Show-all toggle; display only. The payload rules live in `web/compaction.js`, tested by `web/test_compaction.mjs` (run through `serve/test_compaction.py` so `unittest discover` picks them up). Notes for this rebase: - The one conflict (`apiMessages`) was resolved by folding #1392's "the answer being asked for now is not history yet" rule into the new callback form. - The compaction rules were aligned with #1392's error-turn policy: `compaction.js` no longer drops error turns itself — it only decides which messages the summary replaces; the converter decides how a turn is sent (so a turn with no answer text still goes back as an empty assistant turn, as on main). <img width="875" height="819" alt="image" src="https://github.com/user-attachments/assets/93d871e5-4e90-49bc-9d87-3bec3eec91e9" /> <img width="862" height="233" alt="image" src="https://github.com/user-attachments/assets/dacda2a5-b2bd-42a9-a13a-c7f90b979ac7" /> <img width="1109" height="290" alt="image" src="https://github.com/user-attachments/assets/14fc1843-3d6c-4f47-b0dc-c5cb516fdf0c" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 14:41:53 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3498
No description provided.