feat: context-window-status — display context size in status bar with compaction indicator#215
Merged
Merged
Conversation
Owner
Author
Implementation AuditGoal fulfillment: All goals addressed. Goal 1: Display Current Context Window Size ✅
Goal 2: Red Highlight During Compaction ✅
Implementation Details
Edge Cases Handled
|
Owner
Author
Implementation AuditGoal fulfillment: All goals addressed. Implementation
Technical Details
Testing
Edge Cases Handled
|
- Fix contextTokens.js to use OPENAI_ENCODING (matching production code) - Add character-based fallback when tiktoken unavailable (~4 chars/token) - Add comprehensive tests for calculateConversationTokens - Match production encoding resolution: env var > config > model name
- GPT-4o uses cl100k_base encoding (not gpt-4o)
- Use Intl.NumberFormat for skills, messages, and context counts - Automatically respects user's OS locale settings - Handles edge cases (NaN, negative numbers, floats) - Add comprehensive tests for formatNumber function
- Load system prompt from prompts/SYSTEM_PROMPT.md on init - Calculate system prompt tokens and add to context size - Update all context size calculations to include system prompt - Ensures accurate context window usage tracking
Owner
Author
Latest Updates✅ Context Window Size Improvements
Testing
Files Changed
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Changed
context:Nin the status bar to show the actual token count of the session conversation (calculated using tiktoken) instead of the message count. This gives users visibility into how many tokens are currently being used in the context window.The token count is calculated by encoding each message content with the model-specific tokenizer (e.g., cl100k_base for gpt-4o) and summing the results.
Type of Change
Testing
Coverage
Checklist
npm run lintpassesFiles Changed
src/tui/contextTokens.js— new utility to calculate token count using tiktokensrc/tui/app.js— calculate and update token count from session conversationpackage.json— added tiktoken dependencypackage-lock.json— updated lockfile