Skip to content

fix(ui): collapse verbose tool failure details behind a disclosure (#741) - #753

Merged
Astro-Han merged 4 commits into
mainfrom
fix/ui-collapse-tool-failure
Jul 12, 2026
Merged

Astro-Han merged 4 commits into
mainfrom
fix/ui-collapse-tool-failure

Conversation

@Astro-Han

Copy link
Copy Markdown
Contributor

Summary

Collapse an errored tool's raw diagnostic payload behind a closed disclosure (ToolErrorDetails, trigger "显示原始诊断"), and remove the raw result from the shared output panel so it no longer duplicates the ToolErrorBanner summary. The banner already truncates errorText to 240px + offers a copy action; this adds the collapsed raw behind it.

Why

A real tool validation failure rendered a human-readable error card followed by a large raw payload (repeated messages + schema details), growing one turn to ~2631px and repeating the same failure several times. Closes #741.

Scope

  • New ToolErrorDetails Collapsible (closed by default, keyboard-reachable <button> trigger) owns the shared-panel raw result (quietJson.body / non-owned ToolResultPreview) when errored.
  • The shared-panel raw is gated on !errored so it no longer renders alongside the banner.
  • Owned structured previews (automation / terminal / web_search / connector — already bounded cards) stay rendered; only the verbose shared raw folds.
  • ToolErrorBanner, copy action, redactSecrets, the 240px truncation, and result-preview size caps are unchanged.

Verification

  • RED renderToStaticMarkup contract (tool-error-collapse-contract) → GREEN: banner shows the first 240px, a long error's tail is not rendered alongside it, the disclosure trigger is present, and a short error still appears in the banner.
  • npm run -w @maka/desktop test — 2324/2324 pass (incl. automation-result-preview-contract, which intentionally uses errored to mount the panel for SSR and still sees its data-kind previews).
  • @maka/ui build + typecheck + test:checks — pass.

Impact

Errored tools with a shared-panel raw show one concise summary + a collapsed raw disclosure; owned structured previews and non-errored tools are unchanged. No behavior, API, or migration change.

Reviewer notes

Owned previews are intentionally not folded — they are already bounded structured cards, and automation-result-preview-contract uses status: 'errored' purely to make Base UI mount the panel in static markup (it exercises the result parser, not disclosure defaults). Folding them would break that contract and hide useful structured cards.

Ready for review

  • Verification complete and current
  • Impact/compatibility/migration/docs/release-note needs addressed
  • Visual evidence included (renderToStaticMarkup contract)

)

An errored tool rendered a human-readable failure banner followed by the
full raw payload (repeated messages + schema details), so one failed turn
could grow to ~2631px and repeat the same failure several times. The
ToolErrorBanner already truncates errorText to 240px and offers a copy
action, but the shared output panel still rendered the full raw result
alongside it.

Add a ToolErrorDetails Collapsible (closed by default, keyboard-reachable
trigger "显示原始诊断") that owns the shared-panel raw result
(quietJson.body / non-owned ToolResultPreview) when errored, and gate the
shared-panel raw on !errored so it no longer duplicates the banner summary.
Owned structured previews (automation / terminal / web_search / connector —
already bounded cards) stay rendered; only the verbose shared raw folds.

Secret redaction and size caps stay enforced upstream (redactSecrets, the
banner's 240px truncation, and the result preview's own caps). A
renderToStaticMarkup contract pins the collapse: the banner shows the
first 240px, the tail of a long error is not rendered alongside it, and
the disclosure trigger is present.

Refs #741
Two follow-ups from the #741 codex review:

- P2: args:{} + errored + non-owned used to render an empty destructive
  tool-output box (the raw moved to the disclosure, but showResult kept the
  shared panel open with nothing in it). Gate hasSharedPanelContent's
  showResult on !errored so the shared panel only opens when it has content.
  Added a DOM regression for the args:{} validation-failure shape.
- P3: ToolErrorDetails gets a controlled `open` prop (internal useState
  fallback when omitted) and is exported, so the contract can render the
  expanded state in static markup and prove the raw payload actually mounts
  when open — not just that it is hidden by default. disclosure-collapsible-
  contract still passes (controlled open, not defaultOpen).

No production behavior change beyond the empty-panel fix; owned structured
previews and non-errored tools are unchanged.
Two follow-ups from the #741 fresh-eye codex review:

- P2: the banner's `errorText.slice(0, 240)` kept newlines, so a multi-line
  validation error (180 lines, 269 chars) still rendered ~161 lines (~2656px)
  — the exact ~2631px the issue tracked. Add summarizeErrorText() capping both
  characters (240) and logical lines (4), whichever trips first, with an
  ellipsis. The full redacted text still lives in the disclosure for copy.
  Added a multi-line SSR regression.
- P3: ToolErrorDetails' `onOpenChange ?? setInternalOpen` left internalOpen
  stuck closed when a caller passed onOpenChange without open (callback ran
  but state never updated). setOpen now always updates internalOpen then calls
  the optional callback, so the half-controlled shape is consistent with the
  "self-managed when open omitted" contract.
The CollapsibleTrigger inherited the primitive's default w-full, so the
'显示原始诊断' trigger occupied the whole row — clicking empty space to the
right of the label would expand the disclosure, and the focus ring spanned
the full width. Add w-fit so the trigger is only as wide as its content.
@Astro-Han
Astro-Han merged commit c9e2ff8 into main Jul 12, 2026
3 checks passed
@Astro-Han
Astro-Han deleted the fix/ui-collapse-tool-failure branch July 14, 2026 05:05
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.

fix(ui): collapse verbose tool failure details

1 participant