Skip to content

feat(tui): select Copilot context independently of reasoning - #53553

Closed
anxkhn wants to merge 4 commits into
anomalyco:devfrom
anxkhn:copilot-context
Closed

anxkhn wants to merge 4 commits into
anomalyco:devfrom
anxkhn:copilot-context

Conversation

@anxkhn

@anxkhn anxkhn commented Oct 6, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #53521. Related to #38164 and #52089.

Draft for core-team design review. #53521 renews the earlier request that the inactivity bot closed.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Keep one base Copilot model in /models. Add Switch context window to the TUI command palette and /context-window, with Default and Long choices independent of reasoning. Changing reasoning preserves the context choice, and the footer shows the selected tier.

Read account-specific boundaries and cache prices from Copilot's authenticated /models endpoint. Apply the selected budget to execution and compaction. Display Copilot-only session costs in AI credits, with 1 credit = $0.01; mixed or partially loaded histories retain USD. Actual prompt size determines the price tier, and reported GitHub charges still override estimates.

Preserve existing OAuth and configured Enterprise routing, fast-mode prices, and configured reasoning overrides. Context metadata stays local and is removed from inference options. This implements the legacy/TUI path, not the v2 app. It does not change authentication or add a new inference API parameter.

How did you verify your code works?

  • 134 passing Copilot/provider/request tests, including OAuth and Enterprise discovery, context budgets, config merging, custom reasoning, and metadata stripping.
  • 55 passing compaction tests, 1 skipped.
  • 199 passing TUI tests, 1 skipped, including credit conversion and context selection parsing. Re-ran after the prompt footer fix and upstream sync.
  • Both package typechecks and the pre-push repository typecheck passed, 30 tasks.
  • Prettier passed and new discovery/dialog/accounting source passed oxlint.
  • Built the darwin-arm64 CLI and passed its smoke test. Live OAuth discovery and TUI selection confirmed medium/default → medium/long → high/long without sending a model prompt. Enterprise support is fixture-tested, not tested with live Enterprise credentials.

Follow-up verification: the main prompt bottom bar now uses the response context tier and AI-credit formatter, matching the sidebar and subagent footer. Reopening an existing Default-context session showed 31.6K tokens at 8% in both locations, replacing the incorrect 3% bottom-bar reading. The pre-push repository typecheck also passed after syncing with current upstream dev, 30 tasks.

Screenshots / recordings

Terminal capture from the built TUI:

Select context window
Default context, 272K input tokens   200 / 1000 AI credits per 1M input / output
Long context, 922K input tokens      400 / 1500 AI credits per 1M input / output

Build · GPT-6.1 Sol GitHub Copilot · medium · long context
Build · GPT-6.1 Sol GitHub Copilot · high · long context

Labels have since been shortened to fit the dialog. No image screenshot is attached; presentation is part of the requested design review.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@anxkhn
anxkhn marked this pull request as ready for review October 6, 2026 16:10
@anxkhn

anxkhn commented Oct 6, 2026

Copy link
Copy Markdown
Author

Fixed a missed accounting path in d879f26. The main prompt bottom bar still divided token usage by the model maximum and formatted Copilot costs in USD, while the sidebar and subagent footer already used the selected context tier and AI credits.

The bottom bar now uses the same contextLimit(model, last.variant) and formatSessionCost helpers. Verified in the built macOS TUI by reopening an existing Default-context session without sending another model request. Its 31,595 tokens now show 8% in both the bottom bar and sidebar, rather than 3% in the bottom bar. The provider reports 272,000 Default input tokens plus 128,000 output tokens, giving a 400,000-token effective context window; Long uses 1,050,000.

Checks after syncing with current upstream dev: 199 TUI tests passed, 1 skipped; TUI typecheck and Prettier passed. Native darwin-arm64 build and version smoke test passed before the upstream sync.

The local install now identifies itself as 1.18.34-copilot-context.1 rather than the automatic 0.0.0 preview version. This is a local build setting, with the existing channel retained to preserve session database access; no repository version bump is included.

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

@anxkhn

anxkhn commented Oct 12, 2026

Copy link
Copy Markdown
Author

@thdxr this is now ported to v2 and rebased onto dev. i addressed the review feedback, and the tests and typechecks pass. the replacement pr is ready for review: #54782

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.

[FEATURE]: Independent Copilot context-window selection and AI-credit usage

2 participants