Context Info
Why. Replaces piβs default footer with a rich dashboard: git branch, model name, token usage with color thresholds, TPS during streaming, cache hit rate, session name, trust status, thinking level, live timer, and tool call counter.
How it works. Creates FooterState on session start, reads config from .pi/settings.json (top-level settings: quietStartup, contextStatusBar.showTps). Detects git worktree name, captures session name and trust status. Installs custom footer via ctx.ui.setFooter() (TUI only). Secondary text (labels, timer, cache stats) is appearance-aware: it reads the themeβs reported appearance once at install and uses muted on light backgrounds, dim otherwise. Updates reactively on model_select, thinking_level_select, turn_end, message_end (token+cache stats), message_update (TPS sampling through deduplicated key extraction), tool_execution_end. Timer updates session duration display every second. Session_shutdown stops timer.
Registers three /explain-* commands for listing discovery:
/explain-extensionsβ Lists all active extensions with descriptions/explain-promptsβ Lists all available prompt templates/explain-skillsβ Lists all available skills
Also provides setSupervisorIssueData / clearSupervisorIssueData exported API for the supervisor pipeline to display current issue number/title/repo in the TUI footer.
Location: .pi/extensions/context-info/
Details
Architecture
Reactive footer system with event-driven updates and timer:
βββ index.ts # Entry: event hooks, state management, /explain-* commands
βββ footer.ts # installFooter: builds TUI footer component tree
βββ footer-state.ts # FooterState: mutable state container with render triggers
βββ config.ts # Load config from .pi/settings.json (quietStartup, contextStatusBar)
βββ types.ts # ThresholdEntry, TpsSample, FooterConfig interfaces
βββ git-helpers.ts # Worktree name detection from git rev-parse
βββ telemetry.ts # tryEmit: lightweight telemetry emission
βββ extensions.ts # List active extensions from .pi/extensions/
βββ prompts.ts # List available prompt templates
βββ skills.ts # List available skills
βββ explain.ts # createExplainCommand: /explain-* command factory with word-wrap
βββ cheasee-pi-info.ts # /cheasee-pi-info command with repo version display
βββ test/ # Unit tests
Footer State Machine
flowchart TD
A[session_start] --> B[FooterState.resetProperties]
B --> C[loadConfig]
C --> D{config null?}
D -- yes --> E[clear UI: setFooter undefined, setStatus undefined, stopTimer]
D -- no --> F[set worktreeName, sessionName, trustStatus]
F --> G[installFooter: build TUI component]
G --> H[startTimer: 1s interval]
H --> I{Event received}
I -- model_select --> J[update model name, contextWindow, cacheHitRate]
I -- thinking_level_select --> K[update thinkingLevel]
I -- turn_end --> L[re-render footer]
I -- message_end --> M[update token usage, cache stats]
I -- message_update --> N[sample TPS]
I -- tool_execution_end --> O[increment toolCallCount]
I -- session_shutdown --> P[stopTimer, dispose]
Footer Component Tree
The TUI footer renders a single-line status bar with adaptive segments:
[Git branch] [Model name] [Thinking level] [β± timer] [Tokens used/max] [TPS] [Cache hit rate] [Session name] [Trust status] [Tool calls]
Each segment is implemented as a reactive Widget that updates when its backing Reactive value changes. The FooterState object holds all reactive values and calls installFooter() (mutating FooterConfig) which triggers ctx.ui.setFooter() re-render.
Key Design Decisions
- FooterState lifecycle β Created on
session_start, disposed onsession_shutdown. Previous state is disposed before creating new one to prevent stalectxclosures after reload/newSession/fork/switchSession. - Working indicator β Custom dot pulse (
Β·ββ’ββββ’) instead of standard spinner. Set insession_startfor TUI mode. - TPS sampling β On
message_updateevent, samples streaming output tokens. Uses deduplicated key extraction to prevent double-counting. Sampled every ~200ms during streaming. - Cache hit rate β Computed from
cacheRead / (cacheRead + cacheWrite)on eachmessage_end. Rounded to integer percentage. Reset on model change (provider/model-specific cache keys). - Quiet startup β When
quietStartup: truein config, startup hint and working indicator are suppressed. - Explain commands β
/explain-extensions,/explain-prompts,/explain-skillsrender inline lists. Widgets auto-cleared on firstinput/before_agent_start/user_bashevent. - Supervisor integration β Exported
setSupervisorIssueData/clearSupervisorIssueDataallow supervisor pipeline to display current issue number/title/repo in the TUI footer. Uses function reference (stateRef) set on session_start. - Timer β
startTimer()sets asetIntervalat 1s.stopTimer()clears it. Timer updatesFooterConfig.timervalue and triggers re-render.
Event β Footer Update Map
| Event | Fields Updated |
|---|---|
session_start |
worktreeName, sessionName, trustStatus, sessionId, contextWindow |
model_select |
modelName, contextWindow, cacheHitRate, sessionName |
thinking_level_select |
thinkingLevel |
turn_end |
sessionName (re-read) |
message_end |
tokensUsed, tokensMax, cacheRead, cacheWrite, cacheHitRate |
message_update |
TPS samples |
tool_execution_end |
toolCallCount |
session_shutdown |
Timer stopped, state disposed |
Testing
Tests cover:
- Footer state: all reactive values, mutations, reset
- Event handlers: each event β correct field update
- Timer: start/stop/interval behavior
- TPS sampling: deduplication, accumulation, average computation
- Explain commands: extension/prompt/skill listing, error handling
- Config loading: all settings paths, missing file, invalid JSON
- Supervisor integration: set/clear issue data functions