opencode
opencode copied to clipboard
feat(tui): add context preview dialog
Summary
- Add context preview dialog accessible via command palette
- Shows breakdown of context being sent to LLM before submission
- Displays system prompt, instruction files, environment context, and conversation history with token estimates
Motivation
Users currently see total token count but cannot inspect what comprises the context. This makes it difficult to:
- Identify unnecessary context consumption
- Understand why token counts are high
- Optimize context before sending
Changes
dialog-context.tsx: New dialog component showing context breakdown by typeapp.tsx: Register "Preview context" command in command palette
Usage
- Open command palette
- Select "Preview context"
- View breakdown of context items with token estimates
It would probably be cool if this could be bound to a key (although it should probably be bound to "none" by default and left for the user to bind themselves if they choose to as the team hasn't been a fan of new default keybindings recently).