Repository navigation
fix(ui): collapse verbose tool failure details behind a disclosure (#741) - #753
Merged
Merged
Conversation
) 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 theToolErrorBannersummary. 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
ToolErrorDetailsCollapsible (closed by default, keyboard-reachable<button>trigger) owns the shared-panel raw result (quietJson.body/ non-ownedToolResultPreview) whenerrored.!erroredso it no longer renders alongside the banner.ToolErrorBanner, copy action,redactSecrets, the 240px truncation, and result-preview size caps are unchanged.Verification
renderToStaticMarkupcontract (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 useserroredto mount the panel for SSR and still sees itsdata-kindpreviews).@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-contractusesstatus: '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