Skip to content
Back

Context treemap

A treemap of everything in an agent's context: each prompt, tool list, memory, file, chat turn and tool result is a tile sized by tokens, tiles slide as the window fills, unused room stays hatched, and compaction folds old turns into one summary tile.

oxyn add context-treemap
MCP

Context

40.4k / 200k20%
System prompt6.1k · System prompt
Tool definitions14.8k · Tools
Project memory9.2k · Memory
CHANGELOG.md1.2k · File
release.ts3.1k · File
Chat900 · Chat
vercel.json600 · File
notes.md4.5k · File
Free160k

No compaction so far – the before and after will show here when it runs.

Dioxus
rsx! {
    ContextTreemap {
        blocks: Some(session.context_blocks()),
        limit: 200_000,
        compaction: session.last_compaction(),
        now: clock.now(),
        on_select: move |id| inspect(id),
    }
}

Rendered from Rust at build time · goes live when visible

When to use

  • A treemap of everything in an agent's context: each prompt, tool list, memory, file, chat turn and tool result is a tile sized by tokens; tiles slide as the window fills, unused room stays hatched, and compaction folds old turns into one summary tile.

When not to use

  • An agent asks before it acts: use Approval Card instead.
  • Several open requests in one card: use Approval pager instead.
  • An agent's question in its own card above the composer: use Decision Card instead.

Installation

Context treemap is free and MIT. The oxyn CLI copies its code, and the components it needs, into src/oxyn/ of your Dioxus or GPUI project, so it is yours to change.

Terminal
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add context-treemap
Rust
use crate::oxyn::{ContextTreemap, STATUS_INDICATOR_CSS};

Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{ContextTreemap, STATUS_INDICATOR_CSS};

Usage

Dioxus · rust
rsx! {
    ContextTreemap {
        blocks: Some(session.context_blocks()),
        limit: 200_000,
        compaction: session.last_compaction(),
        now: clock.now(),
        on_select: move |id| inspect(id),
    }
}

Examples

Live

The session grows tile by tile, hits the limit, compacts – old turns squeeze into a summary – and Before | After appears.

Context

40.4k / 200k20%
System prompt6.1k · System prompt
Tool definitions14.8k · Tools
Project memory9.2k · Memory
CHANGELOG.md1.2k · File
release.ts3.1k · File
Chat900 · Chat
vercel.json600 · File
notes.md4.5k · File
Free160k

No compaction so far – the before and after will show here when it runs.

Code
rsx! {
    ContextTreemap {
        blocks: Some(session.context_blocks()),
        limit: 200_000,
        compaction: session.last_compaction(),
        now: clock.now(),
        on_select: move |id| inspect(id),
    }
}

Fresh

A fresh session: small tiles, the dashed free space, no compaction so far.

Context

56.3k / 200k28%
System prompt6.1k · System prompt
Tool definitions14.8k · Tools
Project memory9.2k · Memory
CHANGELOG.md2k · File
release.ts4.8k · File
Chat6.1k · Chat
CI run · 14×2.6k · Tool result
vercel.json1.8k · File
Issue search1.9k · Tool result
notes.md6.9k · File
Free144k

No compaction so far – the before and after will show here when it runs.

Code
rsx! {
    ContextTreemap {
        blocks: Some(session.context_blocks()),
        limit: 200_000,
        compaction: session.last_compaction(),
        now: clock.now(),
        on_select: move |id| inspect(id),
    }
}

Nearly full

Nearly full: the percent turns amber and the free space is a sliver.

Context

173k / 200k86%
System prompt6.1k · System prompt
Tool definitions14.8k · Tools
Project memory9.2k · Memory
CHANGELOG.md7.9k · File
release.ts16.9k · File
Chat44.6k · Chat
CI run · 14×21.7k · Tool result
vercel.json10.4k · File
Issue search16.2k · Tool result
notes.md24.8k · File
Free27.4k

No compaction so far – the before and after will show here when it runs.

Code
rsx! {
    ContextTreemap {
        blocks: Some(session.context_blocks()),
        limit: 200_000,
        compaction: session.last_compaction(),
        now: clock.now(),
        on_select: move |id| inspect(id),
    }
}

After compaction

After a compaction: kept parts, a green summary, and the line of what was kept, summarized and dropped.

Context

73.7k / 200k37%
System prompt6.1k · System prompt
Tool definitions14.8k · Tools
Project memory9.2k · Memory
CHANGELOG.md7.9k · File
release.ts16.9k · File
vercel.json10.4k · File
Summary8.4k · Summary
Free126k

173k → 73.7k6 kept · 65.3k3 summarized · 91.1k into 8.4k1 dropped · 16.2k

Code
rsx! {
    ContextTreemap {
        blocks: Some(session.context_blocks()),
        limit: 200_000,
        compaction: session.last_compaction(),
        now: clock.now(),
        on_select: move |id| inspect(id),
    }
}

Before compaction

Before: the parts that were summarized or dropped come back, dashed and tagged.

Context

173k / 200k86%
System prompt6.1k · kept
Tool definitions14.8k · kept
Project memory9.2k · kept
CHANGELOG.md7.9k · kept
release.ts16.9k · kept
Chat44.6k · summarized
CI run · 14×21.7k · summarized
vercel.json10.4k · kept
Issue search16.2k · dropped
notes.md24.8k · summarized
Free27.4k

173k → 73.7k6 kept · 65.3k3 summarized · 91.1k into 8.4k1 dropped · 16.2k

Code
rsx! {
    ContextTreemap {
        blocks: Some(session.context_blocks()),
        limit: 200_000,
        compaction: session.last_compaction(),
        now: clock.now(),
        on_select: move |id| inspect(id),
    }
}

Open a part

A tile pointed at: its card with tokens, share and what it holds.

Context

107k / 200k53%
System prompt6.1k · System prompt
Tool definitions14.8k · Tools
Project memory9.2k · Memory
CHANGELOG.md4.6k · File
release.ts10k · File
Chat22.8k · Chat
CI run · 14×10.9k · Tool result
vercel.json5.5k · File
Issue search8.1k · Tool result
notes.md14.6k · File
Free93.5k

No compaction so far – the before and after will show here when it runs.

Code
rsx! {
    ContextTreemap {
        blocks: Some(session.context_blocks()),
        limit: 200_000,
        compaction: session.last_compaction(),
        now: clock.now(),
        on_select: move |id| inspect(id),
    }
}

Agent menu

The agent menu: each agent with its model and window size.

Context

  • Release helperOpus 5.5200k
  • Repo mapperGemini Pro500k
  • Inbox triageGPT-5128k
56.3k / 200k28%
System prompt6.1k · System prompt
Tool definitions14.8k · Tools
Project memory9.2k · Memory
CHANGELOG.md2k · File
release.ts4.8k · File
Chat6.1k · Chat
CI run · 14×2.6k · Tool result
vercel.json1.8k · File
Issue search1.9k · Tool result
notes.md6.9k · File
Free144k

No compaction so far – the before and after will show here when it runs.

Code
rsx! {
    ContextTreemap {
        blocks: Some(session.context_blocks()),
        limit: 200_000,
        compaction: session.last_compaction(),
        now: clock.now(),
        on_select: move |id| inspect(id),
    }
}

Narrow

Under 480 px the map is shorter and the numbers take a line of their own.

Context

73.7k / 200k37%
System prompt6.1k · System prompt
Tool definitions14.8k · Tools
Project memory9.2k · Memory
CHANGELOG.md7.9k · File
release.ts16.9k · File
vercel.json10.4k · File
Summary8.4k · Summary
Free126k

173k → 73.7k6 kept · 65.3k3 summarized · 91.1k into 8.4k1 dropped · 16.2k

Code
rsx! {
    ContextTreemap {
        blocks: Some(session.context_blocks()),
        limit: 200_000,
        compaction: session.last_compaction(),
        now: clock.now(),
        on_select: move |id| inspect(id),
    }
}

Classic

Classic style: a grey band, more saturated tiles with a solid edge, a white percent.

Context

73.7k / 200k37%
System prompt6.1k · System prompt
Tool definitions14.8k · Tools
Project memory9.2k · Memory
CHANGELOG.md7.9k · File
release.ts16.9k · File
vercel.json10.4k · File
Summary8.4k · Summary
Free126k

173k → 73.7k6 kept · 65.3k3 summarized · 91.1k into 8.4k1 dropped · 16.2k

Code
rsx! {
    ContextTreemap {
        blocks: Some(session.context_blocks()),
        limit: 200_000,
        compaction: session.last_compaction(),
        now: clock.now(),
        on_select: move |id| inspect(id),
    }
}

API reference

ContextTreemap

PropTypeDefaultDescription
blocksOption<Vec<CtxBlock>>Default::default()Every part of the context, in tile order (the demo's when `None`).
limitu32Default::default()The window's size in tokens (the current agent's when 0).
agentsOption<Vec<CtxAgent>>Default::default()Agents to switch between (the demo's when `None`).
agentStringDefault::default()The agent shown first (id; the first when empty).
compactionOption<CtxCompaction>Default::default()The last compaction (adds Before | After and the line under the map).
compactedboolDefault::default()Demo only: show the demo's compaction.
viewString"after"Which side of the compaction shows first (`before` / `after`).
growf320.35Demo only: grow the session (0–1) when `live` is off.
liveboolDefault::default()Demo only: the session grows, compacts and settles on its own.
statusStringDefault::default()A short status in the bar ("Compacting").
pointStringDefault::default()A tile pointed at from the start (its card shows).
menu_openboolDefault::default()The agent menu open from the start.
titleString"Context"Heading.
nowrequiredClockMs—The clock.
styleStringDefault::default()`clean`, `classic`, or empty to follow `data-cstyle`.
on_selectEventHandler<String>—A tile was clicked (block id; empty for the free space).
on_agent_changeEventHandler<String>—Another agent was picked.
on_view_changeEventHandler<String>—Before | After was switched.

Read from the Rust signature and doc comments.

Keyboard interactions

KeyAction
TabThrough the agent menu, Before | After and the tiles
EnterorSpacePins the focused tile's card, or lets it go
EscapeLets go of the pinned card and closes the menu

Accessibility

  • The map is a list named by its title; every tile is an item with its name, kind and tokens.
  • The fill level is text in the bar – its colour is extra, not the only signal.
  • Before | After is a radio group; the agent menu is a listbox.

Responsive behaviour

  • 680 px up to its container; the map keeps its height and tiles too small for a label show only their colour.
  • Under 480 px the map is 220 px tall and the numbers move to a line of their own.
Edge cases (spec)

680 px up to its container; the map keeps its height and the layout stretches. Under 480 px the map is 220 px and the numbers take a line of their own.

Notes for AI

  • Import ContextTreemap from oxyn_dioxus and include STATUS_INDICATOR_CSS plus the token stylesheet once.
  • A GPUI version exists: ContextTreemapEl in oxyn_gpui.
  • Props to set first: now.
  • It reads a clock (now) for live timers; pass one clock for the whole page rather than one per component.
  • Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.

Guides

Oxyn · 74 free components · 264 Pro components · 96 screens · 20 blocks · Dioxus and GPUI