Skip to content

feat(tui): add /context command with a categorized context-window breakdown #3432

Description

@aheritier

Summary

Add a /context slash command that opens a dialog (consistent with the existing /cost dialog) showing the current context-window composition, broken down by category.

Motivation

Competitors (Claude Code's /context grid) let users see exactly what is consuming their context window. docker-agent today shows only a single aggregate "Context: N%" in the sidebar and a cost-centric /cost dialog — there is no window-centric breakdown.

Proposed behavior

Show estimated tokens and % of the resolved context limit for each category:

  • system prompt
  • tool definitions
  • prompt files (AGENTS.md / add_prompt_files)
  • conversation messages
  • tool results
  • compaction summary

Render as a dialog with a bar/grid. Numbers are estimates (len/4 heuristic via compaction.EstimateMessageTokens) — label them as such.

Implementation notes (starting points)

  • New command in pkg/tui/commands/commands.go
  • New message type in pkg/tui/messages/session.go
  • New dialog pkg/tui/dialog/context.go
  • Breakdown computed in pkg/runtime from Session.GetMessages output; consider a ContextBreakdownEvent
  • Reuse pkg/tui/components/toolcommon/tokencount.go

Complexity: M. Command name decided as /context (not /status).

Background: shared plan context-management-gap-analysis (Phase 1, item 1).

Dependencies / Relationships

Metadata

Metadata

Assignees

Labels

area/runtimeRuntime engine, agent loop execution, tool dispatch, loop detectionarea/tuiFor features/issues/fixes related to the TUIkind/featPR adds a new feature (maps to feat:). Use on PRs only.

Fields

No fields configured for Enhancement.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions