Skip to content

Commit 2e2b64d

Browse files
jarrodwattsclaude
andcommitted
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>
1 parent e372132 commit 2e2b64d

22 files changed

+177
-51
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
All notable changes to Claude HUD will be documented in this file.
44

5+
## [Unreleased]
6+
7+
### Changed
8+
- Context percentage now uses percentage-based buffer (22.5%) instead of hardcoded 45k tokens
9+
- Scales correctly for enterprise context windows (>200k)
10+
- Add `display.autocompactBuffer` config option (`'enabled'` | `'disabled'`, default: `'enabled'`)
11+
- `'enabled'`: Shows buffered % (matches `/context` when autocompact ON) - **default**
12+
- `'disabled'`: Shows raw % (matches `/context` when autocompact OFF)
13+
14+
### Credits
15+
- Ideas from PRs #30 (@r-firpo), #43 (@yansircc), #49 (@StephenJoshii) informed the final solution
16+
17+
---
18+
519
## [0.0.4] - 2026-01-07
620

721
### Added

dist/config.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export type LayoutType = 'default' | 'separators';
2+
export type AutocompactBufferMode = 'enabled' | 'disabled';
23
export interface HudConfig {
34
layout: LayoutType;
45
pathLevels: 1 | 2 | 3;
@@ -17,6 +18,7 @@ export interface HudConfig {
1718
showTools: boolean;
1819
showAgents: boolean;
1920
showTodos: boolean;
21+
autocompactBuffer: AutocompactBufferMode;
2022
};
2123
}
2224
export declare const DEFAULT_CONFIG: HudConfig;

dist/config.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/config.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/config.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/constants.d.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/**
2-
* Autocompact buffer: reserved space that /context includes in its calculation.
3-
* This is fixed at 45k tokens (22.5% of 200k) - must be added to match /context output.
2+
* Autocompact buffer percentage.
3+
*
4+
* NOTE: This value (22.5% = 45k/200k) is empirically derived from community
5+
* observations of Claude Code's autocompact behavior. It is NOT officially
6+
* documented by Anthropic and may change in future Claude Code versions.
7+
* If users report mismatches, this value may need adjustment.
48
*/
5-
export declare const AUTOCOMPACT_BUFFER = 45000;
9+
export declare const AUTOCOMPACT_BUFFER_PERCENT = 0.225;
610
//# sourceMappingURL=constants.d.ts.map

dist/constants.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/constants.js

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/constants.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/render/session-line.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)