What fills an agent's context, as a map: the system prompt, tools, memory, every file, every turn and tool result is a tile sized by its tokens, with free room as a dashed tile. Tiles glide as the session grows, and a compaction squeezes the old turns into their summary.
Examples
Near the limit
Installation
Installation is part of Pro
Pro components install from a licensed registry. The live preview stays open to everyone.
Props
- segments
ContextSegment[]- The same shape as Context Window: { id, label, tokens, kind?, reserve?, parts?, detail?, summaryOf? }. Each part (a file, a turn, a tool result) gets its own tile inside its segment. tokens: 0 sums the parts.
- limit / model / limits
number / string / Record<string, number>- Window size, or a lookup in your own table. Free room is the dashed tile; over the limit there is none and the numbers turn red.
- warnAt / fullAt
number- Default
0.8 / 0.95 - Thresholds for the state line: "60k free", "Filling up", "Almost full".
- onCompact / compacting / compactLabel
() => void / boolean / string- Default
- / - / "Compact" - The Compact button. While compacting the conversation tiles pulse. Replace the old turns with a part whose summaryOf lists their ids: they fly into it.
- before
ContextSegment[]- The window before a compaction: a Before / After switch glides between the two, and the line says how much it freed.
- onOpen
(tile) => void- Click or Enter on a tile. The tile has segmentId, partId, label, tokens and detail.
- height / title / freeLabel / formatTokens
number / ReactNode / string / (n) => string- Default
300 / "Context" / "Free" / 124k - Map height in px, heading, the free tile's name and the token format.
- a11y
role=meter, focusable tiles- The header is a meter with the share in words. Every tile is focusable (a button with onOpen) and named like "session.ts, Files: 11.8k tokens, 6%"; focus shows the same line as hover. Motion stops under reduced motion.
| Prop | Type | Default | Description |
|---|---|---|---|
| segments | ContextSegment[] | - | The same shape as Context Window: { id, label, tokens, kind?, reserve?, parts?, detail?, summaryOf? }. Each part (a file, a turn, a tool result) gets its own tile inside its segment. tokens: 0 sums the parts. |
| limit / model / limits | number / string / Record<string, number> | - | Window size, or a lookup in your own table. Free room is the dashed tile; over the limit there is none and the numbers turn red. |
| warnAt / fullAt | number | 0.8 / 0.95 | Thresholds for the state line: "60k free", "Filling up", "Almost full". |
| onCompact / compacting / compactLabel | () => void / boolean / string | - / - / "Compact" | The Compact button. While compacting the conversation tiles pulse. Replace the old turns with a part whose summaryOf lists their ids: they fly into it. |
| before | ContextSegment[] | - | The window before a compaction: a Before / After switch glides between the two, and the line says how much it freed. |
| onOpen | (tile) => void | - | Click or Enter on a tile. The tile has segmentId, partId, label, tokens and detail. |
| height / title / freeLabel / formatTokens | number / ReactNode / string / (n) => string | 300 / "Context" / "Free" / 124k | Map height in px, heading, the free tile's name and the token format. |
| a11y | role=meter, focusable tiles | - | The header is a meter with the share in words. Every tile is focusable (a button with onOpen) and named like "session.ts, Files: 11.8k tokens, 6%"; focus shows the same line as hover. Motion stops under reduced motion. |
When to use
When to use
- Showing what fills an agent's context file by file and turn by turn, so people see what to drop.
- Making a compaction visible: the old turns squeeze into their summary, with a before and after.
- A debug or inspector panel next to a run, where clicking a tile opens that file or turn.
When not to use
- A small how-full indicator in a header or composer: use Context Window.
- Billing, credits or spend against a plan: use Usage Meter.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Context Treemap to my app and wire it to my own data.
- I need showing what fills an agent's context file by file and turn by turn, so people see what to drop. Set that up with the Knowns UI Context Treemap.
- Which Context Treemap props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "context-treemap" }) and search_docs({ query: "context treemap" }). Pro props, full examples and source come back once your license key is in the MCP config.