Repository navigation
fix(web): show the error disclosure only when text is hidden - #32461
juliusmarminge wants to merge 4 commits into
Conversation
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.
ApprovabilityVerdict: Approved at 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. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
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. |
|
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. |
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".
ExpandableTextguessed withtext.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 (
clientHeight60 =scrollHeight60 underline-clamp-3), yet "Show full error" is shown and expanding reveals nothing. At 390px wide the same text is clipped (scrollHeight120 > 60), and there the control is needed.Change
ExpandableTextnow measures the clamped element instead of guessing. The collapsed text always carriescollapsedClassName. The control shows whenscrollHeightexceedsclientHeight, whencollapsedTextdiffers fromtext(the banner's readable summary vs. raw diagnostics), or while expanded. The measurement uses the sharedobserveResizehelper and re-runs ondocument.fontsloadingdone, the same pattern asChatHeaderandBranchToolbar. 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.tsxfromapps/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:changedpasses (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/ProviderSettingsPanelwith 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.
F2, clipped banner lifecycle (390 ↔ 1280, dark), before left, after right. Each step is a 2-second hold:
Only the wide collapsed states differ.
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.
F4, two-line failure causes that fit (Diagnostics, Latest and Most Common Failures, 1280, light). The unnecessary controls are removed.
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.
F6, two-line Span Log that fits (
line-clamp-2, "Show full message", 1280, dark). The control is removed.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.
F8, provider connection error (HARNESS, mono, 1280, dark). A text replacement inside the same clamped box (three → four lines) gains the control. A real
FontFaceload that rewraps three lines into four without resizing the box also gains it. Show less survives a second font load while expanded.What else changed:
Not checked:
AI-assisted; verified with the tests and tools listed above.