Skip to content

fix(web): show the error disclosure only when text is hidden - #32461

Closed
juliusmarminge wants to merge 4 commits into
mainfrom
fix/issue-32428
Closed

juliusmarminge wants to merge 4 commits into
mainfrom
fix/issue-32428

Conversation

@juliusmarminge

Copy link
Copy Markdown
Member

Problem

The thread error banner (and the Diagnostics and provider-settings error cells) offered "Show full error" even when the whole error was already visible; clicking it only changed the label to "Show less". ExpandableText guessed with text.length > 180 || text.includes("\n") instead of checking rendered overflow.

Reproduced on main (83a3674) in the web app at 1280×800: in a thread on a plain local checkout (no worktree), run one turn, then "Edit from here" → "Revert files too". The 212-character "File restore requires an isolated worktree…" error renders in three lines (clientHeight 60 = scrollHeight 60 under line-clamp-3), yet "Show full error" is shown and expanding reveals nothing. At 390px wide the same text is clipped (scrollHeight 120 > 60), and there the control is needed.

Change

ExpandableText now measures the clamped element instead of guessing. The collapsed text always carries collapsedClassName. The control shows when scrollHeight exceeds clientHeight, when collapsedText differs from text (the banner's readable summary vs. raw diagnostics), or while expanded. The measurement uses the shared observeResize helper and re-runs on document.fonts loadingdone, the same pattern as ChatHeader and BranchToolbar. A new collapsed text remounts the measured element. Nothing is measured while expanded, so "Show less" and its keyboard focus stay put until the user collapses.

Short messages that wrap past the clamp now clamp too and get the control. Before, they were shown in full because they were under 180 characters. This shows up in Diagnostics → Span Logs and the failure tables (F5, F7 below).

Scope and approval

Fixes #32428

Verification

Focused tests, apps/web/src/components/settings/ExpandableText.browser.test.tsx (vp test run --project browser src/components/settings/ExpandableText.browser.test.tsx from apps/web):

  • shows no disclosure when a long error fits within the clamp: fails on main (the button is found), passes here.
  • offers the disclosure when the error is clipped by the clamp: passes on both; guards against hiding the control everywhere.
  • keeps the disclosure while expanded and follows container resizes: expands with a click and collapses with Enter, asserting focus stays on the button, then widens the container and asserts the control disappears. Fails on main and on a version that measures while expanded (focus drops to <body>).

vp run check:changed passes (format, lint, knip, typecheck, tests, React compiler).

Evidence: real web app built from each revision (before 83a3674, after 9421f43; the head only adds a merge of main, which does not touch these files). Captured with Playwright / Chromium 148, headless Linux, DPR 1, 100% zoom, reduced motion, frozen clock; wide = 1280×800, narrow = 390×800. Each sheet is Before | After | Diff0 (any change, amplified) | DiffT (>16/255), with the SHA under each column. Data is synthetic: a Replay/dev turn for the banner, a synthetic trace-file seed for Diagnostics. F3 and F8 are labelled harnesses that render the real ThreadErrorBanner / ProviderSettingsPanel with stubbed environment state, because those branches cannot be reached deterministically from a route.

F1, banner fits (1280, light and dark). The control and its 24px row are gone, uncovering the unchanged reply under the floating banner. There are no other changed pixels.

F1 wide light: Before | After | Diff0 | DiffT

F1 wide dark: Before | After | Diff0 | DiffT

F2, clipped banner lifecycle (390 ↔ 1280, dark), before left, after right. Each step is a 2-second hold:

Time Step
0–2s Narrow, clipped
2–4s Pointer expands
4–6s Enter collapses
6–8s Space expands
8–10s Widened while expanded; Show less stays focused
10–12s Collapsed wide; the after control disappears
12–14s Narrow again; the control returns
14–16s Shift+Tab reaches the control
16–18s Wide
18–20s Dismiss

Only the wide collapsed states differ.

F2 dark lifecycle: before left, after right

F3, summary differs from the raw error (HARNESS, 1280, light). The control stays, and expanding reveals the full JSON on both revisions. The collapsed pair is pixel-identical.

F3 HARNESS: Before | After | Diff0 | DiffT
F3 HARNESS before
F3 HARNESS after

F4, two-line failure causes that fit (Diagnostics, Latest and Most Common Failures, 1280, light). The unnecessary controls are removed.

F4: Before | After | Diff0 | DiffT

F5, a 161-character cause that wraps to four lines (1280, dark). Before shows it in full with no control. After clamps it to three lines with Show full error / Show less.

F5: Before | After | Diff0 | DiffT
F5 before
F5 after

F6, two-line Span Log that fits (line-clamp-2, "Show full message", 1280, dark). The control is removed.

F6: Before | After | Diff0 | DiffT

F7, a short Span Log that wraps to nine lines (390, light, horizontally scrolled table). After clamps it to two lines with Show full message. The different focus rings are the table container on base, where there is no button, and the button on after.

F7: Before | After | Diff0 | DiffT
F7 lifecycle: before left, after right

F8, provider connection error (HARNESS, mono, 1280, dark). A text replacement inside the same clamped box (three → four lines) gains the control. A real FontFace load that rewraps three lines into four without resizing the box also gains it. Show less survives a second font load while expanded.

F8 HARNESS fitting: Before | After | Diff0 | DiffT
F8 HARNESS after first font load: Before | After | Diff0 | DiffT
F8 HARNESS before
F8 HARNESS after

What else changed:

  • Removing a fitting control shortens its banner or row, which moves the content below it.
  • Newly clamped short messages (F5, F7) change table row heights.
  • Before/after keyboard focus outlines differ where the base has a control and the head does not.

Not checked:

  • The Electron shell (it renders the same web code).
  • Safari and Firefox.
  • The seeding and capture scripts are not attached to this PR.

AI-assisted; verified with the tests and tools listed above.

ExpandableText offers "Show full error" for any text over 180 characters,
even when the rendered text fits inside its line clamp. The first test
renders a 212-character single-line error in a 960px container and fails
on main; the second keeps the control when a 200px container clips it.
ExpandableText guessed whether its text was clipped from its length and
newlines, so a long single-line error that fit inside the clamp still
offered "Show full error" and expanding revealed nothing.

Always clamp the collapsed text and measure the clamped element with the
shared observeResize helper, so the control follows the rendered layout
and container resizes. A distinct collapsedText still keeps the control,
and it stays while expanded so the text can be collapsed again.
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 7, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 99e5087

Macroscope's review found this PR approvable — The error disclosure now appears when text is actually hidden, rather than based on length or newlines. The change is limited to presentation in chat and settings, without altering stored data or product defaults.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

ExpandableText now measures rendered clipping to decide whether to show its disclosure control. It updates the measurement after size changes and font loading. Browser tests cover wide and narrow layouts, expansion, keyboard focus, and resizing.

Changes: ExpandableText disclosure

Layer / File(s) Summary
Measure clipping and validate disclosure behavior
apps/web/src/components/settings/ExpandableText.tsx, apps/web/src/components/settings/ExpandableText.browser.test.tsx
The component uses measured clipping, expansion state, and differing collapsedText and text values to determine whether to show the disclosure control. It observes size changes and font loading. Browser tests check disclosure visibility at different widths and keyboard interaction.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • pingdotgg/t3code#32445: Also addresses issue #32428 by replacing the length and newline heuristic with rendered overflow measurement.

Suggested labels: bugfix

Suggested reviewers: macroscopeapp

Merge Risk: Minimal · up to 99e50

No actionable merge-blocking risk was established for the disclosure change.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly describes the main change to error disclosure.
Description check Passed The description is mostly complete. It includes reproduction steps, the fix, an issue reference, test results, and visual evidence. It does not identify the agent model and harness or confirm that the…
Linked Issues check Passed [#32428] ExpandableText measures rendered overflow instead of using the length and newline heuristic. It keeps the control when a different full error is available or when expanded. Browser tests co…
Out of Scope Changes check Passed [#32428] The component change and browser tests support the error disclosure fix. Clamping short text that overflows also follows the rendered-overflow behavior.
Full details: Description check

Explanation

The description is mostly complete. It includes reproduction steps, the fix, an issue reference, test results, and visual evidence. It does not identify the agent model and harness or confirm that the linked issue is triaged. The evidence is not hosted on GitHub as the template requests.

Full details: Linked Issues check

Explanation

[#32428] ExpandableText measures rendered overflow instead of using the length and newline heuristic. It keeps the control when a different full error is available or when expanded. Browser tests cover fitting and clipped errors, focus, and resizing.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4c3a9d5 and 99e5087.

Files selected for processing: 2

  • apps/web/src/components/settings/ExpandableText.browser.test.tsx
  • apps/web/src/components/settings/ExpandableText.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Copy link
Copy Markdown
Member Author

This overlaps #32445, opened earlier for the same issue with the same approach (measure the clamped element instead of the length/newline heuristic). Differences here: browser tests for fit, clip, keyboard focus through Show less, and resize; a re-measure after web fonts load; before/after captures for every caller. Only one of the two should land.

Copy link
Copy Markdown
Member Author

Thanks for this. https://git.cafe/pingdotgg/t3code/pulls/32445 makes the same change and is the one being kept.

Keep #32445 instead. Both address open issue #32428 in the same component, but that PR additionally remeasures on interface/code font setting changes and resets expansion when an error is replaced. Its current head has 40 successful checks, no pending or failing checks, and a current conflict check confirms it merges cleanly against main. Paging all 3,643 open PRs found these two matching candidates. Main still uses the heuristic; distinctive-line history searches found no equivalent implementation, and no merges since this PR’s base touch either changed file. This was a read-only assessment; no application code or tests were run.

Closing as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error disclosure appears when the entire message is visible

1 participant