The browser's category lists were capped at the newest 200 nodes, so a
long session showed token sums with no item rows for everything older.
Projection pushes ship the whole value but only fire on surface-moving
events (a few per step, ~150B per node), and auto-compaction keeps the
live surface far below 2000 in healthy sessions — so the new default
effectively lists every live node, with the bound kept (and the honest
'outside the served window' note) as a backstop for pathological cases.
The turn strip's per-turn palette was positionally identical to the six
category colors (turn 1 indigo = system, turn 2 amber = tools, ...).
Sitting 4px under the bars, the strip read as a detached full-width
bottom segment that never aligned with the bars above — the bars looked
broken, especially in multi-turn sessions.
The strip now uses a neutral two-tone zebra (adjacent turns still read
as separate ranges) with secondary-label text; the in-turn bar tint goes
neutral too. Verified against the live GUI: every composition bar's
segments measure pixel-aligned; the strip now clearly reads as an axis.
Add docs/context-browser.png to the browser section, plus the two
behaviors that shipped with it: trend-chart hover linkage and honest
coverage (archive reconstruction notes, auto-loading older history,
always-listed live injections). The History section mentions the hover
linkage too.
Hovering a history bar now transiently previews that step in the Context
browser — picker, meta line, composition bar and category lists all
follow the pointer, with a 'preview' marker in the meta row. Leaving
the chart returns the browser to its own picker selection; a seq trimmed
out of retention is ignored. Accordion state survives the hover, so one
open category can be scrubbed across steps for comparison.
Injections land on the surface first, so in a long session the plain
maxNodes tail window dropped their identity while their tokens kept
counting (sums cover the full surface) — the browser's inject section
showed a gray '0 items' row with a real token sum and no way to see
what was inside.
The served slice is now the newest maxNodes tail PLUS every live inject
node older than the tail (they are few; the concatenation stays
seq-ordered). droppedNodes and surfaceFloor count only the unserved
non-inject overflow, so the 'N earlier messages' note no longer
double-counts pinned injects, and per-step reconstruction sees them too.
Overview + trend stack in the left column and the context browser takes
the right column, reusing the shared lc-cols flex (wraps to one column
on narrow widths).
Section spacing moves from per-card margins to the row container:
.lc-cols owns the 14px gap to the next section, cards that ARE columns
drop their own bottom margin, and the last card inside a wrapper column
drops its own — fixing the head row sitting flush against the overview
card and making every section boundary exactly 14px however the flex
wraps.
Expanding a Context browser element whose seq is outside the loaded
conversation window now pages older history in automatically (one page
in flight, up to 20 pages) until the join hits, instead of leaving the
reader with the 80-char preview plus a static note.
The pagination verb reaches the card through the harness's
sessions.provide channel: the plugin contributes a loadOlderHistory
standard prop resolved to session.loadOlder(), so every session-scope
slot component receives it. Hosts without the channel (or a duplicate
refusal) fail soft to the previous preview-plus-hint degradation.
The client entry's `module.exports = { name, inject, apply }` is the
closure-factory contract every dsh.client package's `./client` export
must use — the harness's __ModuleLoader__ wraps the bundled CJS in a
factory that provides `var module = { exports: {} }` as a closure local
(see scripts/build.mjs:73-86), so the reference is legitimate. esbuild's
parser nonetheless flags it because the .ts source lives in a
"type": "module" package.
`logOverride: { 'commonjs-variable-in-esm': 'silent' }` suppresses that
one specific warning without touching any other esbuild signal — a future
maintainer adding a real CJS leak (e.g. require() inside the entry) would
still see a different warning. No source, test, or runtime behavior
changes; the bundled client.js still ends with the documented factory
shape that the harness's loader consumes.
dsh-session exports deriveEventMessage(event) as the canonical per-event
message projection:
user/message -> event.data
assistant/message -> event.data.message (or null when content is empty)
tool/result -> event.data.message
other -> null
The fold's three surface-event cases now call this one function instead of
hand-rolling casts and picks.
Behavior is identical: empty assistant/message projects to no message
(usage-only), so applySurface receives null in that case and the existing
emptyIsZero short-circuit prices 0 tokens (without the +ROLE_OVERHEAD that
a non-empty message would pay).
MessageLike is kept as the plugin's narrow structural type; deriveEventMessage's
return type (Message from dsh-llm) is structurally compatible with MessageLike
(modulo the optional error field, which is harmless).
applySurface's message parameter widens to MessageLike | null | undefined
to accept deriveEventMessage's null return directly.
The harness's global scrollbar skin (ui-theme/src/styles/scrollbar.css)
supplies the styled scrollbar via scrollbar-width: thin; declaring both
scrollbar-width and ::-webkit-scrollbar on the same element is mutually
exclusive across engines (see harness's own note at scrollbar.css:26-43),
so the local webkit rules were silently ignored on Chromium/Safari
anyway. Drop them; the chart scroll uses the harness's skin.
The events card header now carries four pill buttons (注入/压缩/剪枝/切换)
instead of a select: all picked by default, clicking an unpicked kind adds
it (A -> A+B -> ...), clicking a picked one removes it, and removing the
last one resets to all. Each kind gets a distinct hue shared between the
pills and the row chips (绿/红/紫/蓝); the hint subtitle and the filter
dropdown are gone.
Each event row now carries a kind chip (注入/压缩/剪枝/切换) colored by
impact direction (+ adds, - frees, ⇄ neutral), the events card header
gains a one-line hint about the block's meaning, and the native title
tooltip attaches only while the label actually truncates (measured after
every render and on resize) instead of always.
Side-by-side head row (3:2 flex, wraps when tight): plugin name, version,
and GitHub repo as whole-cell links (name/version -> GitHub/npm), with the
version/repo baked in from package.json via esbuild define. A once-per-page
npm registry check adds an 'Update!' badge + update-command tooltip on the
version cell whenever the registry release differs; failures stay silent.
Bilingual strings, cell-hover underline + brand border affordance.
Drop recycled/switches/est/actual-prompt/output cells and split the
single recycled counter into two — compactions and prunes — so the
counts are distinguishable in the board. Bold the cell labels and
center the values for a cleaner scan.
token-meter is a core service that owns estimation and replay (its docs:
'the singleton ctx.tokenMeter directly owns estimation and replay'), and the
published package registers three projections on the shared
SessionProjectionMap — tokenUsage / contextPressure / contextBreakdown.
The host was duplicating the contextPressure fold (pressureTokens +
sampledSurfaceTokens + occupancyWindow, sampleUsage on assistant/message and
usage chunks) and the client was rendering from that mirror.
Host: the occupancy mirror leaves the fold entirely (assistant/chunk is now
structurally ignored — same reference, no change feed). stateVersion 1 -> 2
so cached rows from the old fold are discarded. The strict wire schema no
longer accepts occupancy; the shared type keeps it optional as legacy for
downstream consumers.
Client: the headline reads the official token-meter contextPressure
projection via the useProjection seat (the same key the chat's context ring
reads); absent key/value degrades to the existing derived fallback (last
request prompt + surface movement), so the UI renders identically in every
deployment. UI functionality is unchanged — same headline, same percentages,
same composition anchoring.
diff-fold.mjs is repurposed: the plugin no longer has an occupancy fold to
compare, but its heuristic composition (current.system/tools + surface total)
must stay equal to the official contextBreakdown projection — verified
MATCH on three real session logs.
Tests: host asserts occupancy is absent + chunk reference stability; client
feeds the official projection through the stub and asserts the same UI text.
Verified against the harness source before locking in:
- agent-loop appends request/header (reason 'change' when the envelope
differs) BEFORE request/context per request, so a model switch is always a
header change — firing the model event only there equals the durable
record, and route/capacity metadata can never double-fire it.
- dsh-llm TokenUsage buckets are disjoint: billed prompt-side =
inputTokens + cacheReadTokens + cacheWriteTokens, outputTokens already
contains reasoningTokens — the fold's prompt/output mapping was already
correct; comments now cite the official semantics.
No behavior change; new assertions cover the switch event (exactly one, from
model-a to model-b), provider-only changes (route update, not a switch), and
the usage mapping (1000 = 800+150+50; output 30).
The docs' plugin contract expects an exported Config (Standard Schema) so
invalid entry config fails the load loudly, and the harness config principle
is 'anything two deployments may want to set differently is a configuration
field'. The fold previously hardcoded MAX_REQUEST_STEPS / MAX_KEPT_TURNS /
MAX_EVENTS / MAX_NODES in fold.ts.
- config.ts: exported Config (zod, implements Standard Schema v1 — the same
validator cordis uses via Config['~standard'].validate) with strict,
defaulted fields; resolveBounds() turns entry config into FoldBounds.
- fold.ts/timeline.ts: bounds thread through applyTimeline/trimState/
buildTimelineView; the projection unit is now created per instance by
createContextTimelineDefinition(config), so cordis config edits hot-reload
(HMR) like any other entry config.
- index.ts: apply(ctx, config) registers the config-bound unit; Config is
re-exported for patchers and the config catalog.
- Defaults equal the previous constants, so behavior is unchanged; persisted
state shape is untouched (no stateVersion bump — bounds are retention only).
- tests: host test drives a bounded instance (maxNodes/maxKeptTurns).
The module-level inject: ['sessionProjections'] already gates apply and
auto-restarts when the registry provider is replaced; wrapping the same
registration in ctx.inject(...) created a redundant dependent fiber
(cordis-api/registry.md documents ctx.inject as shorthand for
ctx.plugin({ inject, apply })). Registering in apply keeps one gate.
- Tagline now leads with the two surfaces ("Context Tab and /context
command.") and keeps the made-of / evolves framing.
- Title all white; six-category legend fits one line; wider left column;
right app shot enlarged in place; dropped the 中文/EN chip.
- Hero image is now a real capture of the /context centered dialog
(docs/context-command.png).
- Intro rewritten around the two surfaces: the Context tab and the
client-owned /context command (no model traffic, no message history).
- New "Use it" section documenting the command's invocation, closing
interactions, and the deferred composer-token consumption.
- package.json description updated to match.
Typing /context in the composer opens a centered dialog with the current
composition (provider-anchored headline, stacked bar, legend) and the
last-10-turn trend chart — the same pushed contextTimeline projection the
tab renders, no RPC, no polling.
The command is the plugin's own '/' trigger source, fully client-side:
no host descriptor, no session log records, nothing model-visible. The
composer token is consumed only when the modal closes (deferred
slash/input-consume-token with span / bare-token guards, fail-soft if the
draft changed meanwhile). Esc, backdrop click, and the close button all
close it and restore composer focus.
Also extracts the provider-anchored headline derivation shared by the tab
and the modal (headline.ts).
Composition-bar hover now recedes everything except the hovered part: the
container gets a lc-stacked-dim modifier whose unselected segments and the
free track drop to 35% opacity while the hovered segment/chip/free-track stays
at 100% (with the existing brightness boost). The occupied-region reference
frame is also stronger: 2px dashed label-primary at full opacity (plus a hair
inner ring) so it reads as an obvious dark frame against the colored
segments. Pure CSS + one container class — sheet and tests unchanged in
behavior (box/dim are hover-gated like before).