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). 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