The best way to control Claude Code, Codex and more from any computer or phone
fix(web): stop timeline details icon flickering on touch devices (#26793)
Co-authored-by: PR Batch Tester <agent@local.test> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
shivam committed
Oct 31, 2026 at 02:50 UTC
35231d78676725811aa5f4d6b24a8888be6662d5
2 files changed
+91
-5
apps/web/src/components/chat/ComposerBannerStack.browser.test.tsx
+77
-2
@@ -1,11 +1,16 @@
1
import { InfoIcon } from "lucide-react";
2
-import { expect, it } from "vite-plus/test";
2
+import type { ReactNode } from "react";
3
+import { expect, it, vi } from "vite-plus/test";
4
5
import "~/index.css";
6
7
import { render } from "../../../test/render";
8
import { ComposerBanner } from "./ComposerBanner";
8
-import { ComposerBannerStack, type ComposerBannerStackItem } from "./ComposerBannerStack";
9
+import {
10
+ ComposerBannerStack,
11
+ NoticeText,
12
+ type ComposerBannerStackItem,
13
+} from "./ComposerBannerStack";
14
15
function notice(title: string, group?: ComposerBannerStackItem["group"]): ComposerBannerStackItem {
16
return { id: title, variant: "default", icon: <InfoIcon />, title, ...(group ? { group } : {}) };
@@ -33,3 +38,73 @@ it("leaves the next attachment its own top edge when there are no notices", asyn
38
expect(surface.borderTopWidth).toBe("1px");
39
expect(surface.borderTopLeftRadius).not.toBe("0px");
40
});
41
+
42
+function noticeRow(width: string, children: ReactNode) {
43
+ return (
44
+ <div data-testid="row" className="flex items-center gap-1.5" style={{ width }}>
45
+ <NoticeText detailsLabel="Show details" className="min-w-0 truncate">
46
+ {children}
47
+ </NoticeText>
48
+ </div>
49
+ );
50
+}
51
+
52
+it("leaves out the details button when only a link's hit area reaches past the text", async () => {
53
+ // Phones lay out in device pixels, so a range can measure one float32 step (2^-17 px at
54
+ // this size) wider than its element. Headless Chromium's rects agree exactly.
55
+ const rangeRect = Range.prototype.getBoundingClientRect;
56
+ using _rangeRect = vi
57
+ .spyOn(Range.prototype, "getBoundingClientRect")
58
+ .mockImplementation(function (this: Range) {
59
+ const rect = rangeRect.call(this);
60
+ return new DOMRect(rect.x, rect.y, rect.width + 2 ** -17, rect.height);
61
+ });
62
+ // The flicker is a details button that mounts and then unmounts, so record every insertion.
63
+ const inserted: Node[] = [];
64
+ using observing = new DisposableStack();
65
+ const mutations = new MutationObserver((records) =>
66
+ inserted.push(...records.flatMap((record) => [...record.addedNodes])),
67
+ );
68
+ mutations.observe(document.body, { childList: true, subtree: true });
69
+ observing.defer(() => mutations.disconnect());
70
+ await using screen = await render(
71
+ noticeRow(
72
+ "20rem",
73
+ <>
74
+ Needs input{" "}
75
+ <button type="button" className="relative after:absolute after:-inset-x-10 after:inset-y-0">
76
+ Review
77
+ </button>
78
+ </>,
79
+ ),
80
+ );
81
+
82
+ await expect.element(screen.getByText("Review")).toBeVisible();
83
+ const details = [
84
+ ...inserted,
85
+ ...mutations.takeRecords().flatMap((record) => [...record.addedNodes]),
86
+ ].filter(
87
+ (node) =>
88
+ node instanceof Element &&
89
+ (node.matches('[aria-label="Show details"]') ||
90
+ node.querySelector('[aria-label="Show details"]')),
91
+ );
92
+ expect(details).toEqual([]);
93
+});
94
+
95
+it("shows the details button while text or nested text is cut, until it fits again", async () => {
96
+ await using screen = await render(noticeRow("4rem", "Waiting on a subagent with a long name"));
97
+ const details = screen.getByRole("button", { name: "Show details" });
98
+ await expect.element(details).toBeInTheDocument();
99
+
100
+ screen.getByTestId("row").element().style.width = "40rem";
101
+ await expect.element(details).not.toBeInTheDocument();
102
+
103
+ await screen.rerender(
104
+ noticeRow(
105
+ "40rem",
106
+ <span className="inline-block max-w-16 truncate align-bottom">A long nested name</span>,
107
+ ),
108
+ );
109
+ await expect.element(details).toBeInTheDocument();
110
+});
apps/web/src/components/chat/ComposerBannerStack.tsx
+14
-3
@@ -59,6 +59,8 @@ export function ComposerBannerStack({
59
));
60
}
61
62
+const SUBPIXEL_ROUNDING = 0.001;
63
+
64
export function NoticeText({
65
children,
66
className,
@@ -76,6 +78,7 @@ export function NoticeText({
78
useLayoutEffect(() => {
79
const text = textRef.current;
80
if (!text) return;
81
+ const range = document.createRange();
82
const measure = () => {
83
// Ignore the space taken by the details button itself so it cannot
84
// sustain its own overflow after the text would otherwise fit.
@@ -83,9 +86,17 @@ export function NoticeText({
86
const hidden = getComputedStyle(text).position === "absolute";
87
setShowDetails(
88
hidden ||
86
- [text, ...text.querySelectorAll("*")].some(
87
- (element) => element.scrollWidth > element.clientWidth + recoveredWidth,
88
- ),
89
+ [text, ...text.querySelectorAll("*")].some((element) => {
90
+ // A range spans laid-out content only; scrollWidth also counts positioned layers
91
+ // such as a link's touch hit area, which overflow without cutting any text.
92
+ // The two rects can disagree by float rounding (~0.00001px on phones); real
93
+ // overflow is at least one layout unit, 1/64 of a device pixel.
94
+ range.selectNodeContents(element);
95
+ return (
96
+ range.getBoundingClientRect().width >
97
+ element.getBoundingClientRect().width + recoveredWidth + SUBPIXEL_ROUNDING
98
+ );
99
+ }),
100
);
101
};
102
measure();