Skip to content

feat(chat): the context left, in the chat's status line - #71

Merged
devswha merged 3 commits into
mainfrom
feat/context-left
Sep 26, 2026
Merged

devswha merged 3 commits into
mainfrom
feat/context-left

Conversation

@devswha

@devswha devswha commented Sep 26, 2026

Copy link
Copy Markdown
Owner

Stacked on #70 (quick replies). Merge #70 first; this PR then shows only its own commit. It was rebased onto #70 because both add to the same CHANGELOG and translation lines.

What

The chat's status line shows how much context is left, kept as short as possible:

Case Shows Hover
Codex (window recorded) 74% left 68k of 258k tokens
Claude past 200k (so the 1M window) 57% left 435k of 1M tokens
omp/omo/gjc, Claude below 200k (window not recorded) 68k used tokens used

It turns red at 20% left or less, when a compaction is near.

Where the numbers come from (server/conversation-metadata.ts)

  • Codex: event_msg token_count → info.last_token_usage.total_tokens against info.model_context_window.
  • Claude Code: the last assistant message.usage, input + cache_creation + cache_read. Sidechain (subagent) entries and synthetic messages are skipped.
  • omp/omo/gjc: assistant message.usage, input + cacheRead + cacheWrite.
  • Window rule: a percentage is shown only when the window is certain. Codex records it. A Claude request past 200k can only have run in the 1M window, and that is kept through a later compaction. Otherwise the line shows tokens used, never a guessed percentage.

Checked against real transcripts on this PC: Claude 435k/1M, Codex 67.7k/258.4k, omo 167k/unknown.

Also fixed

PaneTerminal's metadata dedupe compared only model and effort, so a context change would never have reached the composer. It now compares the context too.

Tests

  • bun run typecheck; bun test 410/410; test:ui 9/9.
    • One earlier test:ui run on the unrebased branch stopped after 4 scenarios; the next three runs passed.
  • New parser tests: Codex, Claude (1M inference, sidechain skip, compaction keeps the window, synthetic skip), omp shape. New formatting tests for formatTokens and contextLeftPercent.
  • Screenshotted the status line at 390 px with mocked metadata (Korean 74% 남음 and 15% 남음 in red, English 167k used): no overflow.

Remote PCs

The numbers are computed on the server that reads the transcript. Remote panes show them once their bridge runs a bundle with this change (next remote-vN). Until then the field is absent and nothing is shown.

🤖 Generated with Claude Code

devswha and others added 3 commits September 27, 2026 00:23
One-tap messages (continue, yes, no, commit and push, retry to start with),
as collie's Quick dock has. A reply goes through the composer's own send
path, so it is queued while the agent works and taken as the answer when a
question card is open; a draft in the box is left alone.

The list lives in each device's settings: quick replies are a phone thing
(a PC has a keyboard), so nothing is stored on the server. Settings ->
Quick replies edits it (up to 12, 200 characters each; blank rows are kept
while being typed and never shown), and a button beside the paperclip
hides or shows the row, remembered per device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The row takes a line above the message box on every pane; it now waits for
the ⚡ button, and the choice is remembered per device as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Transcripts already record what each request filled:
- Codex: token_count events with last_token_usage and model_context_window
- Claude Code: assistant usage, input + cache creation + cache read,
  subagent (sidechain) entries skipped
- omp/omo/gjc: message usage, input + cacheRead + cacheWrite

ConversationMetadata gains an optional `context { used, window }`. The
window is only what the transcript leaves no doubt about: Codex states it,
and a Claude request past 200k can only have run in the 1M window (kept
through a compaction). Otherwise the line shows the tokens used, never a
guessed percentage.

The composer shows `74% left` or `68k used`, red at 20% or less, with the
counts on hover. PaneTerminal's metadata dedupe compared only model and
effort, so it now compares the context too, or the number would never move.

Co-Authored-By: Claude Opus 5.5 <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