Add Claude context usage hint via hooks in status bar#41
Open
Add Claude context usage hint via hooks in status bar#41
Conversation
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.
Motivation
zellij/tmuxcan show how much conversation context is used and where/contexthooks can be leveraged.Description
context_usage_percent: Option<u8>to theWorktreemodel to persist hook-derived context percentages (file:src/worktree/model.rs).HookEvent::SessionNotificationto accept an optionalcontext_usage_percentfield and addcontext_usage_percent()plusparse_context_percent_from_messageto extract a percent either from the explicit field or from message text (file:src/hooks/event.rs).src/hooks/install.rsto forwardmessageand a best-effortcontext_usage_percentvalue (explicit payload field or%parsed from message) over the cwt Unix socket.App::handle_hook_eventto update and persistcontext_usage_percenton session notification events (file:src/app.rs).Claude ctx:<n>% (/context via hooks)in the bottom legend, including tests for rendering (file:src/ui/status_bar.rs).Testing
cargo checkand it completed successfully.cargo clippy --all-targets -- -D warningswith no warnings (success).cargo testand all tests passed (unit + integration), including the new parsing and status bar rendering tests.Codex Task