Skip to content

feat(trace): cap row excerpts and count the fold head by tool (#1604) - #1605

Merged
tutunannan merged 2 commits into
developfrom
feature/1604-trace-fold-density
Nov 18, 2026
Merged

tutunannan merged 2 commits into
developfrom
feature/1604-trace-fold-density

Conversation

@tutunannan

@tutunannan tutunannan commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Issue #1604 — trace row density closeout. A success row's result_excerpt no longer renders under the row: it folds into the TraceSummaryFold expand block as a second column beside the argument summary, both under the existing max-h-48 scroll cap, so the row stays one line. The failure excerpt keeps its place under the row (the cross-turn retrospection anchor, ADR-0078) and gains the same cap, so a multi-KB error can no longer push the whole screen out of view. The round step fold's head switches from a bare call total to per-tool call counts in first-appearance order (explore ×3 · describe ×1) — an earlier cut counted by operation category, but on a single-category round the category word collapses to an undifferentiated 读 ×N, so the tool name (untranslated data, order stable across re-renders and locale switches) carries the head while the category stays on the row's OperationBadge. ADR-0078's folding discipline is untouched.

Changes

  • Row excerpt gate (TraceRow.tsx): the excerpt render splits on success — success rows pass the excerpt into the summary fold (undefined when empty), failure rows keep the under-row span and add max-h-48 overflow-y-auto (the thinking fold's cap face).
  • Summary fold columns (TraceSummaryFold.tsx): a new optional resultExcerpt prop renders the argument summary and the result excerpt as two columns of one capped block, divided by a hairline; absent keeps the single-column block, so the approval card and the running row are unaffected.
  • Fold-head label (TraceRow.tsx): the step fold counts calls per tool name in first-appearance order — the trace is append-only within a round, so the order never reshuffles; a single tool keeps the count form; zero-call rounds still mount nothing.
  • Catalog (zh-CN.json, en-US.json): the dead thread.trace.toggle key drops (the i18n guard rejects dead keys) and a thread.trace.toolCount count template ({tool} ×{count}) replaces it — the only new key.
  • Test surface (TraceView.test.tsx, TraceSummaryFold.test.tsx, TurnCard.test.tsx, Thread.test.tsx, DelegationSubTraceBody.test.tsx): the excerpt-gate tests rework to the new faces (success folds into the block, failure stays capped, clean stays bare), the fold-label describe covers first-appearance order / single tool / zero-call, and the zh-catalog assertions pin the exact count strings.

Files Changed

  • src/components/thread/TraceRow.tsx -- modified (excerpt gate split by success + per-tool fold-head label)
  • src/components/thread/TraceSummaryFold.tsx -- modified (optional resultExcerpt column in the expand block)
  • src/components/thread/DelegationSubTraceBody.tsx -- modified (comment wording rides the label rename)
  • src/locales/zh-CN.json -- modified (-thread.trace.toggle, +thread.trace.toolCount)
  • src/locales/en-US.json -- modified (same)
  • src/components/thread/__tests__/TraceView.test.tsx -- modified (excerpt-gate rework + fold-label describe)
  • src/components/thread/__tests__/TraceSummaryFold.test.tsx -- modified (+resultExcerpt column coverage)
  • src/components/thread/__tests__/TurnCard.test.tsx -- modified (count-label assertions + tool-order pin)
  • src/components/thread/__tests__/Thread.test.tsx -- modified (count-label assertions)
  • src/components/thread/__tests__/DelegationSubTraceBody.test.tsx -- modified (count-label assertion)

Testing

  • Frontend: full suite green 2896/2896 across 182 files — the excerpt-gate rework and the fold-label describe carry the new coverage (first-appearance order, single tool, zero-call, success fold, failure cap, clean row). tsc --noEmit, ESLint, and i18n:check (863 ids: source == en-US == zh-CN) clean; design:lint passes.

Related Issues

Closes #1604.

Follow-up (deferred):

  • A leading label word on the fold head (工具调用 · explore ×3) is parked until the live process-grouping ticket lands — its verb-prefix vocabulary is the same design space.

- fold a success row's result excerpt into the summary expand block as
  a second column beside the argument summary, both under the existing
  max-h-48 scroll cap, so the row stays one line
- keep the failure excerpt un-folded under the row (the cross-turn
  retrospection anchor) and add the same scroll cap, so a multi-KB
  error can no longer push the whole screen out of view
- relabel the round step fold from a bare call total to per-tool call
  counts in first-appearance order ("explore ×3 · describe ×1") --
  the category word alone reads as an undifferentiated 读 ×N on a
  single-category round; the category stays on the row's
  OperationBadge; tool names are untranslated data, so the head order
  is stable across re-renders and locale switches
- swap the catalog key for a count template and drop the dead toggle
  key in both locales
@tutunannan

Copy link
Copy Markdown
Contributor Author

Review: 6-agent pass

Six passes over commit d4f70ab (10 files, +209/−62 — issue #1604, ticket A of the trace-flow plan: a success row's result excerpt folds into the summary fold's expand block as a second capped column beside the argument summary, the failure excerpt keeps its under-row retrospection anchor and gains the thinking fold's scroll cap, and the round step fold's head switches from a bare call total to per-tool call counts in first-appearance order): code-reviewer, comment-analyzer, pr-test-analyzer, silent-failure-hunter, type-design-analyzer, and code-simplifier — all six delivered; the implementing session's dual-axis review (standards and spec, no Critical, no Important) had already folded its rulings into the pushed commit, and the axes below checked the pushed tree without re-litigating the recorded rulings — the on-device recalibration to tool-name counting, the relaxed test anchors (the trace-toggle class selector plus exact label strings), the OPERATION_ORDER dual enumeration dissolving with the live-grouping ticket, the describe placement dispersion, and the leading label word parked for that same ticket. Verification feeding this pass: silent-failure-hunter walked the excerpt gate's success/failure matrix and every fallback chain with concrete inputs and found no swallowed error outside the cap finding; pr-test-analyzer ran ten gate mutants plus a dead-key probe over the five touched suites — seven killed outright, the gate and column-structure survivors feed Importants 2 and 3, and the en-US template survivor is the repo's defaultMessage-pinning convention rather than a defect; comment-analyzer fact-checked every touched comment claim against source and caught the two the rework itself had rotted; type-design-analyzer ruled the excerpt prop's undefined-as-absent seam correct and found zero casts across the touched test factories; code-simplifier audited both directions and found one dead structure; code-reviewer ran the thread suite directory-wide (741/741) and audited all three consumer faces; the main session re-verified all five Importants at source — the four cap precedents grepped attribute by attribute against the bare new span, both stale comments read at HEAD, and both surviving mutants' inference chains re-derived. CI at review time: Frontend and Rust green on ubuntu, windows, and macos.

Verdict: no Critical, 5 Important, 1 Advisory. The density core is sound on every axis — the excerpt gate's success/failure matrix, the three consumer faces staying single-column, the first-appearance counting with untranslated tool names, and the exact i18n parity all survived adversarial reading, and the type axis ruled the excerpt prop's seam placement correct. Important 1 is an accessibility backstop the four existing cap regions already carry — three attributes and one catalog id away; Importants 2 and 3 are small test pins closing the two surviving mutants; Importants 4 and 5 are one-line comment fixes in files this PR itself touched. Advisory A is a net-three-line deletion the simplifier verified green by mutation; per the maintainer's take-all ruling every finding lands in this PR rather than follow-up.

Important

1. The failure excerpt's new scroll cap is the trace's first pointer-only scroll region (silent-failure-hunter, precedents re-verified at source; src/components/thread/TraceRow.tsx:221). All four pre-existing max-h-48 regions carry the #1363 keyboard-reachability triple — src/components/common/TechnicalDetailsFold.tsx:50, src/components/thread/DelegationSubTraceBody.tsx:87, src/components/thread/ThinkingFold.tsx:55, src/components/thread/TraceSummaryFold.tsx:97 — while the new span ships as a bare class-only element. A multi-KB error clips at the 192px cap; a keyboard-only user can never focus the region, arrow keys scroll the page instead, and the error tail is unreachable without a pointer. Pre-PR the excerpt was uncapped and page scroll reached all of it, so this PR introduces the regression; the cap-class pin at src/components/thread/__tests__/TraceView.test.tsx:217 does not see the region role. The fix is the same triple plus one aria-label id on the span.

2. The success gate has no behavioral pin (pr-test-analyzer, mutation-verified; src/components/thread/TraceRow.tsx:177). Dropping the entry.success && arm from the resultExcerpt gate ran green across all four consumer suites — 188 tests — so a future gate refactor renders a failed call's excerpt twice, under the row anchor and again as the muted block's right column, with nothing red. The clean-row test already expands the fold, so the failure test is two lines away from the same posture: expand, assert the block's text does not carry the error excerpt.

3. The two-column layout and its divider are unpinned (pr-test-analyzer, two mutants survived; src/components/thread/TraceSummaryFold.tsx:105). Retargeting the discriminant to an empty-string compare — every excerpt-less expand, the running rows, the approval cards, and most trace rows, renders an empty right column with a stray hairline divider — and stripping the flex columns and border-l entirely, collapsing the PR's core visual deliverable to stacked text, both ran green in both touched suites; the textContent assertions cannot see structure. A shape assertion closes both: the excerpt branch carries the border-l child span, the absent branch has none.

4. The sub-trace header comment still counts per kind (comment-analyzer; src/components/thread/DelegationSubTraceBody.tsx:13). The comment this PR itself rewrote says the panel stacks each round's per-kind count step fold, but the head now counts per tool — the category word is exactly what this ticket retired from the head, and the same PR's foldLabel comment records that retirement. One word: per-tool.

5. A test comment still quotes the retired head label (comment-analyzer; src/components/thread/__tests__/DelegationSubTraceBody.test.tsx:126). The comment says the "Trace · 0 calls" head must not appear; the string exists nowhere in src now and a zero-call round mounts no head at all, while the behavioral assertion below it, the trace-toggle count, stays exact. The PR that killed the label should not leave it quoted; one clause rewrite.

Advisory

A. foldLabel carries a dead order array and a dead fallback (code-simplifier, rewrite verified green by mutation; src/components/thread/TraceRow.tsx:92). A JS Map iterates in insertion order, so the order array duplicates counts.keys(), and every name it holds was counted at least once in the same loop pass, so the ?? 0 at format time is unreachable. Array.from(counts, ...) nets three lines and drops one data structure with all four consumer suites green on the rewrite; the type axis independently read the same lines and ruled the explicit array the plainer statement of first-appearance intent — both readings stand, and the deletion rides this PR under the take-all ruling.

Confirmed clean

  • Excerpt gate matrix and consumer faces (code-reviewer + silent-failure-hunter, cross-verified). All four success/failure by empty/non-empty arms render the designed face; RunningRow and ApprovalCard pass no resultExcerpt and stay single-column, and no spread path can smuggle an empty string onto the two-column face — the boundary conversion is the sole passer.
  • Fold-label behavior (pr-test-analyzer, mutants killed). The alphabetical-sort and forced-count mutants die in the TraceView suite alongside the single-tool and zero-call pins, and the zh catalog template is pinned by seven exact-string assertions across Thread and TurnCard.
  • i18n parity and dead-key enforcement (code-reviewer + pr-test-analyzer + silent-failure-hunter). 863 ids aligned across source and both catalogs, the new key lands symmetrically mid-block in both, the retired key has zero references repo-wide, and the guard empirically rejects re-adding it.
  • Type seam and test factories (type-design-analyzer). The undefined-as-absent discriminant was ruled the correct seam against the domain's empty-string convention, is exhaustive over its declared domain, and the touched test factories carry zero casts.
  • Nothing else to cut (code-simplifier). The border-l divider idiom has three inline precedents and no shared primitive to reuse, the new tests ride the existing toggle and block helpers, and no test duplicates another's arm.

- give the failure excerpt's scroll cap the #1363 region posture the
  other three height-capped regions hold (tabIndex, role, a new
  thread.trace.excerptAria id), so a multi-KB error's tail stays
  reachable by keyboard, and pin the three attributes in the failure
  test
- pin the success gate: the failure test now expands the fold and
  asserts the block carries the summary alone -- dropping the
  entry.success arm had rendered the failure twice with 188 tests
  green
- pin the two-column face: the excerpt test asserts the divider
  column carries the excerpt and the no-excerpt test asserts none --
  both the discriminant flip and the divider strip had run green
- count foldLabel through the Map's insertion order (the append-only
  trace makes it the first-appearance order), dropping the parallel
  order array and the unreachable ?? 0 fallback
- reword the sub-trace header's per-kind to per-tool and drop the
  retired "Trace · 0 calls" quote from the zero-call test comment
@tutunannan

Copy link
Copy Markdown
Contributor Author

Review follow-up

Landed in 89af974: Importants 1 through 5 and Advisory A.

Important — fixed

  • 1. The failure excerpt's cap carries the 会话 thread: 子轨迹任务块与思考折叠块的滚动容器键盘不可达 #1363 region posture -- tabIndex, role, and the new thread.trace.excerptAria id (TraceRow.tsx:221) -- and the failure test pins all three attributes (TraceView.test.tsx:221). Mutation-verified: dropping the tabindex reddens exactly the failure test, restored and green.
  • 2. The failure test now expands the fold and asserts the block carries the summary alone, not a second copy of the error (TraceView.test.tsx:229). Mutation-verified: dropping the entry.success arm reddens three excerpt-gate tests, restored and green.
  • 3. The excerpt test asserts the divider column carries the excerpt and the no-excerpt test asserts no divider column (TraceSummaryFold.test.tsx:69, 86). Mutation-verified: the flipped discriminant and the stripped divider each redden exactly their test, restored and green.
  • 4. The sub-trace header now reads per-tool count (DelegationSubTraceBody.tsx:13).
  • 5. The zero-call test comment no longer quotes the retired label (DelegationSubTraceBody.test.tsx:126).

Advisory — fixed

  • A. foldLabel counts through the Map's insertion order -- the append-only trace makes it the first-appearance order -- with the parallel order array and the unreachable ?? 0 fallback dropped (TraceRow.tsx:91).

Local verification: full suite 2896/2896, tsc clean, eslint and design:lint clean, i18n:check aligned at 864 ids; all four mutants (the dropped gate, the bare cap, the flipped discriminant, the stripped divider) each reddened their pin and restored green.

@tutunannan
tutunannan merged commit 3a90a01 into develop Nov 18, 2026
4 checks passed
@tutunannan
tutunannan deleted the feature/1604-trace-fold-density branch November 18, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

会话 thread: 过程折叠行降噪 — 结果摘要收进行内展开块、折叠标签类别计数化

1 participant