Clarify usage report evidence and context structure
Traceability
- Spec ID: inspector-usage-report-information-hierarchy
- Status: Implemented
- Related: Inspect session usage and context evidence
Intent
Make the Usage report easier to scan by keeping provenance close to the owning Session header, removing redundant lead hierarchy, and turning bounded context- layer counts into a visual structure summary. The report must preserve the distinction between observed item counts and token-weighted context composition.
Acceptance Scenarios
- AC-1: The Session title bar and selected Usage mode own the visible view identity. The report body does not repeat
Usage and Context Reportor anEvidence detailssubheader. It begins with a compact, always-visible four-group evidence band followed by six responsive KPI tiles for latest context, input reuse, baseline context, net context growth, Session processed tokens, and model calls. Evidence is grouped by Observability, Runtime, Accounting, and Provenance instead of presented as one undifferentiated field grid. Coverage is evidence quality and appears as an Observability fact, rather than occupying a standalone heading row or pill. The band omits redundant explanatory copy, uses one row through compact layouts, and keeps KPI tiles dense enough that downstream analysis begins in the first viewport. Current context includes a compact occupancy/composition bar and a separately sourced reported-compaction or observed-reset badge. Input reuse includes its compact cached/uncached bar and exact retained totals. Those two summaries do not repeat as full-width report sections. When Session processed tokens are unavailable, the sixth KPI shows the observed peak context instead of an unavailable placeholder. Net context is labelled as a comparison with baseline rather than lifetime consumption. - AC-2: Context structure renders each observed layer as a categorical, count-weighted segment plus a matching labelled row with its exact item count. The visualization is explicitly labelled as item counts, never tokens. It does not show percentages or synthesized
Kvalues when per-layer token sizes were not retained, and saystoken sizes unavailable. Compactions move to the Current context KPI rather than remaining a duplicate structure fact. - AC-3: A Session without retained context layers shows an honest unavailable state and does not render an empty or invented distribution.
- AC-4: Standalone Inspector and native Studio use the same information order, copy, values, categorical mapping, disclosure semantics, and responsive behavior at 1440x900, 1024x768, and 390x844.
- AC-5: The Evidence band and Context structure introduce no raw context text; prompt previews remain limited to already-retained, Turn-linked evidence owned by the linked Usage explorer. The report has no document-level horizontal overflow and introduces no browser console or page errors.
- AC-6: Overview is the sole prompt-event index for Context progression. It retains one subtle tick at the first linked response for every observed user prompt. The selected tick exposes one compact
Tnanchor; hovering a tick or moving to it with Overview keyboard navigation replaces that anchor with an immediate prompt-first tooltip containing the retained prompt preview plusTn, response, time, and context metadata. Clicking the tick selects that response and centres the Focus window. Overview is one composite keyboard stop: Left/Right move between prompt events and reveal the same tooltip, with no per-prompt tab stops. Focus renders only the context series, response selection crosshair, and context/model boundaries; it does not duplicate the prompt-event rug or its labels. Selected Response details own the complete retained prompt preview and repeat the sameTnbeside its prompt heading; the response table does not add a separate Turn-number column. The default Focus window starts at the latest observed context reset or model boundary when at least the minimum window remains, and its y-scale is derived from that visible window. Copy saysLinked promptbecause the marker position is the first linked model response rather than an observed prompt timestamp.
Non-goals
- Estimating layer token sizes from item counts, raw text length, a tokenizer, or model-name lookup tables.
- Changing provider adapters, context manifests, token accounting, or compaction detection.
- Redesigning the rest of Session Detail or changing the report route.
Plan and Tasks
- Add shared presentation helpers for evidence facts and observed context-layer counts without changing the portable report model.
- Let the Session title bar and selected Usage mode own view identity. Remove the repeated report title, Evidence details subheader, eyebrow, explanatory subtitle, and Coverage pill. Begin with a compact evidence band, group Coverage with Observability, and keep the six-tile KPI overview below it.
- Fold the Current context composition and Input reuse bars into their KPI tiles, surface reported compactions beside Current context, and remove the now-redundant full-width sections. Use peak context as the fallback KPI when Session processed evidence is unavailable.
- Replace the Context structure definition list with a count-weighted segmented bar and exact item-count rows; remove percentages and explicitly mark missing per-layer token sizes instead of estimating them.
- Keep the standalone string renderer and Studio React renderer aligned while sharing the existing Inspector stylesheet and semantic color tokens.
- Make Overview the single linked-prompt event rug, keep one selected
Tnanchor backed by a prompt-first hover/focus tooltip, and let click or composite keyboard navigation centre Focus. Remove the duplicate Focus prompt lane and Turn table column while repeating the selectedTnbeside the complete prompt in Response details. - Add focused rendering assertions, regenerate linked documentation artifacts, and run standalone/native visual checks at all three layout widths.
Test and Review Evidence
- AC-1/AC-2/AC-3: focused behavioral rendering assertions in
test/reporting/harness-inspector.test.mjsand Studio component/browser tests assert the absence of repeated visible headings, always-visible facts, exact counts, unavailable state, and absence of misleading token claims. - AC-4/AC-5:
node scripts/harness-inspector/visual-contract-check.mjsplus the focused Studio Inspector Playwright scenario cover wide, compact, and narrow layouts, header reflow, overflow, page/console errors, and screenshots. - Documentation integrity: regenerate
docs/better-harness-doc-links.mmdand runnpx vitest run test/skills-docs/doc-link-graph.test.mjs. - Privacy risk: the UI continues to render only bounded layer kinds/counts and enumerated evidence facts; no raw context or prompt text enters the report.
- Interpretation risk: the chart aria-label, header copy, and legend say
items; the current-context composition remains the only token-weighted category visualization.
Validation
npx vitest run test/reporting/harness-inspector.test.mjspassed 38 focused reporting tests.npm run typecheckandnpm run buildpassed inpackages/harness-studio.- The focused Studio Playwright Inspector scenario passed and asserts six KPI tiles, no repeated report or Evidence headings, Coverage ownership inside Observability, exact context structure counts, and the synchronized Overview prompt tooltip / Focus / Response details selection model.
- The standalone visual contract passed all 15 surfaces at 1440x900, 1024x768, and 390x844 for both the demo and a regenerated real report, with zero document overflow, clipped text, sub-12px meaningful text, console errors, or page errors.
- The requested Session
01a04647-16fa-7123-87d6-b216f77cdf1ebegins directly with the four-group evidence band and KPI row. The repeated report title, Evidence details heading, eyebrow, explanatory subtitle, and Coverage pill are absent; Coverage remains visible as an Observability fact. - The compact-density pass keeps four Evidence groups in one row at 1024px and brings downstream analysis into the first wide viewport without dropping evidence facts.
npx vitest run test/skills-docs/doc-link-graph.test.mjspassed all 8 document integrity tests after regeneratingdocs/better-harness-doc-links.mmd.- Three independent read-only reviewers covered visualization density, interaction/accessibility, and evidence semantics. Their common P2 finding was the duplicated permanent Turn-chip layer; AC-6 supersedes that layer with a single prompt-first Overview event rug.
- The real 60-response / 11-Turn Session
01a04772-042c-7451-b637-b9f07e612a1cdefaults Focus to the latest observed context cycle (responses 43–60), uses a local 32.3K–41K Focus scale, retains the full 08:18:00–08:54:48 Overview range, and has zero wide or narrow overflow and browser errors. Its Usage lead contains no visible report-title repeat, Evidence details heading, or Coverage pill. Overview retains one selectedT11; hovering it immediately shows the retained prompt followed byTurn 11 · Response 59metadata, while Focus contains no duplicate prompt markers and Response details saysLinked user prompt · T11. - The real 899-response Session
01a04647-16fa-7123-87d6-b216f77cdf1erenders 17 Overview prompt ticks and one selectedT18. Hover shows提交然后 push 吧withTurn 18 · Response 894metadata; Focus contains zero prompt markers and the page has zero horizontal overflow, console errors, or page errors. Prompt ticks and the range handles use separate upper/lower hit areas, including at the first and last response positions.