Skip to content

feat(site): show a divider for token-budget context windows - #316

Merged
ibetitsmike merged 6 commits into
mainfrom
mike/issue-283-token-budget-ui
Nov 14, 2026
Merged

ibetitsmike merged 6 commits into
mainfrom
mike/issue-283-token-budget-ui

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Coder Agents opened this PR on behalf of @ibetitsmike.

Closes #283

This is the last part of #283. A token-budget rollover now shows as a divider line in the conversation instead of the "Summarized" card.

Backend

  • New coderd/x/chatd/chatloop/fork_context_window.go: ContextWindowBoundary{id, trigger} and the triggers new_context and context_limit.
  • chatloop/compaction.go: one line, the ContextWindow field of CompactionResult.
  • fork_token_budget.go: contextWindowRollover sets the field. The trigger is new_context when that call succeeded in the prompt window, else context_limit. withContextWindowResult adds it as context_window to the streamed chat_summarized result.
  • message_conversion.go: one hook line adds the same field to the stored result.
  • With the experiment off, or for a manual compaction or a summary turn, the field is absent and the result is as on main.

UI

  • New ForkContextWindowDivider.tsx: withForkContextWindow wraps the upstream chat_summarized renderer. With fork-token-budget on and a result that holds context_window, it renders "Context window w:2 started at the agent's request" or "... at the context limit" between two separators. Otherwise, or on an error, it renders the upstream card.
  • Tool.tsx: one import line and one changed line in the renderer map.

Docs

  • docs/fork/pstack-adapter.md: the Context windows section names the divider, and the evidence lines list the new files and the updated line numbers.
  • coderd/x/chatd/ARCHITECTURE.md: the Context windows bullet describes the field.

Tests

  • flock ~/.fork-go.lock go test -count=1 ./coderd/x/chatd/...: pass. TestTokenBudgetWindows checks the stored result: {w:2,new_context} for the cooperative path, {w:2,context_limit} for the forced rollover, and no field with the experiment off. Without the message_conversion.go hook line the first two fail. PlanModeSummarizes checks that a summary has no field. TestContextWindowRolloverStreamsWindow checks the streamed result and fails without the wrapper on the streamed part. TestWithContextWindowResult covers the nil, null, non-object and replace paths.
  • flock ~/.fork-go.lock go build ./coderd/..., the new-code golangci-lint (0 issues), make lint/emdash lint/markdown lint/architecture lint/agents: pass.
  • pnpm test src/pages/AgentsPage/components/ChatElements/tools/: 24 files, 328 tests pass, including ForkContextWindowDivider.test.ts.
  • vitest --project=storybook ForkContextWindowDivider.stories.tsx: 6 stories pass (NewContext, ContextLimit, UnknownTrigger, NarrowPane, ExperimentOff, ErrorResult).
  • pnpm check, pnpm format, lint:types, lint:circular-deps, lint:compiler: pass. knip reports nothing for these files. lint:oxlint and lint:design-system fail on main already, in ForkWaitForEventsTool.tsx and useForkWorkflowsTab.test.tsx, which this PR does not touch.
  • The frontend-review and frontend-deep-review checks found no blocking issue. The should-fix (JSDoc on an export) and the test and story nits are fixed. A read-only Opus review found three older Tool.tsx line references in pstack-adapter.md that the new import line shifted. They are fixed, and its test nits are addressed.

Not verified

  • A live rollover in a running server and a real browser. The divider was checked through the stories and the unit tests only.
  • The context usage indicator right after a rollover. It reads estimated_context_tokens, which this PR does not change.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T09:15:01.313691Z 19d7020 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 39b68d779c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dafc986c7a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 240adc690d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/x/chatd/chatloop/compaction.go Resolved
Comment thread coderd/x/chatd/fork_token_budget.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 19d702012b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike merged commit 5d0cc97 into main Nov 14, 2026
10 checks passed
@ibetitsmike
ibetitsmike deleted the mike/issue-283-token-budget-ui branch November 14, 2026 09:24
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged as 5d0cc97 (squash) at 09:24Z. Before the merge, the server was confirmed on the previous deploy, b79366f.

Gates on head 19d7020:

  1. The head matched the SHA I verified, and main was b79366f at merge time.
  2. All check runs passed. fork-ci run 43579291695 passed on this exact head.
  3. Codex receipt: issuecomment-6875057469, "Didn't find any major issues", reviewed commit 19d7020. Of 11 earlier P2s, 9 were fixed and 2 dropped with replies: a doc comment that the type doc already covers, and a non-regression re-read.
  4. 0 of 11 threads unresolved.
  5. The branch was 0 commits behind main. The diff against main was 13 files, +401 -18.
  6. My tests on the exact head, run under flock:
    • go test -count=1 -v -run '(TestTokenBudget|TestContextWindow|TestWithContextWindowResult|TestNewContextTool|TestChatNotesTool|TestChatHistoryTool)' ./coderd/x/chatd/ ./coderd/x/chatd/chatloop/: 13 top-level tests passed, including TestContextWindowRolloverStreamsWindow and TestWithContextWindowResult.
    • go test -count=1 ./coderd/x/chatd/chatloop/: passed.
    • I also reviewed the hooks. There is one line each in chatloop/compaction.go, message_conversion.go and Tool.tsx. The renderer falls back to the upstream Summarized card when fork-token-budget is off, on an error, or without context_window.
    • I did not rerun the site tests locally. The child ran pnpm check, the ChatElements/tools vitest suite (328 tests) and the 6 stories, and the fork-ci site job passed.
  7. The independent read-only Opus 5.5 review gave READY. It checked the doc line refs and agreed with both dropped P2s.

Not exercised: a live rollover on a running server in a real browser, and visual snapshots of the stories.

This closes #283. fork-token-budget is off by default. Enabling it on the daily server is an ops step.

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.

chatd: token-budget context windows instead of summary compaction

1 participant