Skip to content

feat(tui) display context window limit in token usage counter and sidebar - #42927

Open
Haltarys wants to merge 2 commits into
anomalyco:devfrom
Haltarys:feat/tui-context-limit
Open

feat(tui) display context window limit in token usage counter and sidebar#42927
Haltarys wants to merge 2 commits into
anomalyco:devfrom
Haltarys:feat/tui-context-limit

Conversation

@Haltarys

@Haltarys Haltarys commented Aug 16, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #42929

Could also fulfill #13003 as well up to you.

Type of change

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

What does this PR do?

The TUI input bar showed context usage as 30.0K (15%), but the percentage had no visible reference for what it was relative to. This PR adds the model's context window limit to both places that counter is rendered, so the input bar reads 30.0K / 200K (15%) and the sidebar context panel reads 30,000 / 200,000 tokens.

The limit comes from the model's limit.context (models.dev or provider config). packages/tui/src/component/prompt/index.tsx hoists it into a contextLimit variable and renders tokens together with the limit and percentage when a limit is known. packages/tui/src/feature-plugins/sidebar/context.tsx does the same for the sidebar panel. Models without a known limit behave as before.

How did you verify your code works?

  • bun run --cwd packages/tui typecheck (tsgo --noEmit) passes, as does the full turbo typecheck run by the pre-push hook.
  • Built the binary with bun run script/build.ts --single; the built-in --version smoke test passes.
  • Installed the built binary and used it in a real session — the input bar shows 30.0K / 200K (15%) and the sidebar shows 30,000 / 200,000 tokens.

Screenshots / recordings

Before:

30.0K (15%)

After:

30.0K / 200K (15%)

Can add a terminal screenshot if needed.

Checklist

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

@github-actions

Copy link
Copy Markdown
Contributor

Hey! Your PR title [FEATURE] Display context window limit in token usage counter and sidebar doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 16, 2026
@Haltarys Haltarys changed the title [FEATURE] Display context window limit in token usage counter and sidebar feat(tui) display context window limit in token usage counter and sidebar Aug 16, 2026
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Show the model's context window limit in the TUI (footer and sidebar)

1 participant