Fix HUD context percentage to match /context across window sizes#49
Closed
StephenJoshii wants to merge 1 commit intojarrodwatts:mainfrom
Closed
Fix HUD context percentage to match /context across window sizes#49StephenJoshii wants to merge 1 commit intojarrodwatts:mainfrom
StephenJoshii wants to merge 1 commit intojarrodwatts:mainfrom
Conversation
Author
|
simply changed the hardcoded 45000 buffer to a dynamic: windowSize * 0.225. |
Owner
|
Thanks @StephenJoshii - but what claude models have context windows that are not 200k? saw this issue raised once before but wasn't sure how people run into it |
Author
|
Larger enterprise/ preview models, or any setup where the context size is set differently. In those cases the hardcoded value stops matching the intended behavior. |
jarrodwatts
added a commit
that referenced
this pull request
Jan 9, 2026
- Change hardcoded 45k buffer to 22.5% of context window
- Scales correctly for enterprise windows (>200k)
- Add `display.autocompactBuffer` config option ('enabled' | 'disabled')
- Default 'enabled' preserves current behavior (buffered %)
- 'disabled' shows raw % for users with autocompact off
Fixes #48, #16
Related: #4, #30, #43, #49
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
4 tasks
jarrodwatts
added a commit
that referenced
this pull request
Jan 9, 2026
- Change hardcoded 45k buffer to 22.5% of context window
- Scales correctly for enterprise windows (>200k)
- Add `display.autocompactBuffer` config option ('enabled' | 'disabled')
- Default 'enabled' preserves current behavior (buffered %)
- 'disabled' shows raw % for users with autocompact off
Fixes #48, #16
Related: #4, #30, #43, #49
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
jarrodwatts
added a commit
that referenced
this pull request
Jan 9, 2026
* fix: use percentage-based autocompact buffer with config toggle
- Change hardcoded 45k buffer to 22.5% of context window
- Scales correctly for enterprise windows (>200k)
- Add `display.autocompactBuffer` config option ('enabled' | 'disabled')
- Default 'enabled' preserves current behavior (buffered %)
- 'disabled' shows raw % for users with autocompact off
Fixes #48, #16
Related: #4, #30, #43, #49
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* test: add autocompactBuffer tests for renderSessionLine
Address review feedback:
- Add tests verifying autocompactBuffer: 'enabled' uses buffered %
- Add tests verifying autocompactBuffer: 'disabled' uses raw %
- Add autocompactBuffer check to loadConfig test
- Update baseContext() to include autocompactBuffer
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: add clickable GitHub URLs to CHANGELOG credits
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add debug log for autocompactBuffer mode
When DEBUG=claude-hud is set and autocompactBuffer='disabled',
logs both raw and buffered percentages to help troubleshoot mismatches.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Owner
|
Thank you for the percentage-based approach! This was incorporated into #55 - the buffer is now 22.5% of context window size instead of hardcoded 45k, so it scales correctly for enterprise windows. Credit: Your idea of using a percentage instead of fixed tokens was key to the solution. 🙏 |
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.
Summary
Fixes #48
Fix context percentage mismatch between HUD and /context command for context windows larger than 200k tokens.
The autocompact buffer was hardcoded as 45000 tokens, which only worked correctly for 200k windows (45k = 22.5% of 200k). For larger windows (500k, 1M), the HUD showed significantly lower percentages than /context.
Changed the buffer from a fixed value to a dynamic 22.5% of the context window size:
// Before
export const AUTOCOMPACT_BUFFER = 45000;
// After
export const AUTOCOMPACT_BUFFER_PERCENT = 0.225;
const autocompactBuffer = size * AUTOCOMPACT_BUFFER_PERCENT;
Window | Before | After | /context
200k | 45% | 45% | 45%
500k | 23% | 36% | 36%
1M | 9% | 27% | 27%
Testing
npm testnpm run test:coverageChecklist