Skip to content

Add Claude context usage hint via hooks in status bar#41

Open
0dragosh wants to merge 2 commits intomainfrom
codex/add-context-usage-hints-to-zellij/tmux
Open

Add Claude context usage hint via hooks in status bar#41
0dragosh wants to merge 2 commits intomainfrom
codex/add-context-usage-hints-to-zellij/tmux

Conversation

@0dragosh
Copy link
Copy Markdown
Owner

Motivation

  • Surface Claude/Context usage to the user as a bottom legend/hint so TUI sessions in zellij/tmux can show how much conversation context is used and where /context hooks can be leveraged.
  • Accept and persist context usage reported by Claude hook payloads (or parsed from notification messages) per worktree so the UI can display it immediately and across refreshes.

Description

  • Add context_usage_percent: Option<u8> to the Worktree model to persist hook-derived context percentages (file: src/worktree/model.rs).
  • Extend HookEvent::SessionNotification to accept an optional context_usage_percent field and add context_usage_percent() plus parse_context_percent_from_message to extract a percent either from the explicit field or from message text (file: src/hooks/event.rs).
  • Update generated Claude hook scripts in src/hooks/install.rs to forward message and a best-effort context_usage_percent value (explicit payload field or % parsed from message) over the cwt Unix socket.
  • Wire hook handling in App::handle_hook_event to update and persist context_usage_percent on session notification events (file: src/app.rs).
  • Extend the status bar API and rendering to accept an optional context percentage and show a compact hint Claude ctx:<n>% (/context via hooks) in the bottom legend, including tests for rendering (file: src/ui/status_bar.rs).

Testing

  • Ran cargo check and it completed successfully.
  • Ran cargo clippy --all-targets -- -D warnings with no warnings (success).
  • Ran cargo test and all tests passed (unit + integration), including the new parsing and status bar rendering tests.

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant