The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 09:30 UTC
fix(web): composer notices no longer flicker next to a floating preview (#22974)
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Rodrigo Brechard committed
Oct 31, 2026 at 09:41 UTC
1c8ada502333da46f1eec59b5f5103ac9e50e68d
2 files changed
+49
-15
apps/web/src/components/chat/ComposerBannerStack.browser.test.tsx
+15
@@ -97,6 +97,12 @@ it("shows the details button while text or nested text is cut, until it fits aga
97
const details = screen.getByRole("button", { name: "Show details" });
98
await expect.element(details).toBeInTheDocument();
99
100
+ await screen.rerender(noticeRow("4rem", "Ready"));
101
+ await expect.element(details).not.toBeInTheDocument();
102
+
103
+ await screen.rerender(noticeRow("4rem", "Waiting on a subagent with a long name"));
104
+ await expect.element(details).toBeInTheDocument();
105
+
106
screen.getByTestId("row").element().style.width = "40rem";
107
await expect.element(details).not.toBeInTheDocument();
108
@@ -107,4 +113,13 @@ it("shows the details button while text or nested text is cut, until it fits aga
113
),
114
);
115
await expect.element(details).toBeInTheDocument();
116
+
117
+ await screen.rerender(
118
+ <ComposerBanner.Root>
119
+ {noticeRow("4rem", "Waiting on a subagent with a long name")}
120
+ </ComposerBanner.Root>,
121
+ );
122
+ await expect.element(details).toBeInTheDocument();
123
+ await screen.rerender(<ComposerBanner.Root>{noticeRow("4rem", "Ready")}</ComposerBanner.Root>);
124
+ await expect.element(details).not.toBeInTheDocument();
125
});
apps/web/src/components/chat/ComposerBannerStack.tsx
+34
-15
@@ -72,36 +72,55 @@ export function NoticeText({
72
}) {
73
const textRef = useRef<HTMLSpanElement>(null);
74
const detailsRef = useRef<HTMLButtonElement>(null);
75
- const [showDetails, setShowDetails] = useState(false);
75
+ const [detailsAtWidth, setDetailsAtWidth] = useState<number | null>(null);
76
+ const showDetails = detailsAtWidth !== null;
77
78
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- measures text overflow in the DOM via ResizeObserver and MutationObserver to show the details button
79
useLayoutEffect(() => {
80
const text = textRef.current;
81
if (!text) return;
82
+ const banner = text.closest("[data-slot=composer-banner]");
83
const range = document.createRange();
84
const measure = () => {
85
// Ignore the space taken by the details button itself so it cannot
86
// sustain its own overflow after the text would otherwise fit.
87
const recoveredWidth = detailsRef.current ? detailsRef.current.offsetWidth + 4 : 0;
88
const hidden = getComputedStyle(text).position === "absolute";
87
- setShowDetails(
89
+ const overflowing =
90
hidden ||
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
- }),
91
+ [text, ...text.querySelectorAll("*")].some((element) => {
92
+ // A range spans laid-out content only; scrollWidth also counts positioned layers
93
+ // such as a link's touch hit area, which overflow without cutting any text.
94
+ // The two rects can disagree by float rounding (~0.00001px on phones); real
95
+ // overflow is at least one layout unit, 1/64 of a device pixel.
96
+ range.selectNodeContents(element);
97
+ return (
98
+ range.getBoundingClientRect().width >
99
+ element.getBoundingClientRect().width + recoveredWidth + SUBPIXEL_ROUNDING
100
+ );
101
+ });
102
+ // The button's width can wrap the banner's actions onto a second row, which gives
103
+ // the text room and removes the button, which unwraps the row again. Once shown,
104
+ // the button stays until the banner itself gets wider than where it appeared.
105
+ const width = banner?.clientWidth ?? text.clientWidth;
106
+ setDetailsAtWidth((shownAt) =>
107
+ overflowing
108
+ ? (shownAt ?? width)
109
+ : banner && shownAt !== null && width <= shownAt
110
+ ? shownAt
111
+ : null,
112
);
113
};
114
measure();
103
- const stopObserving = observeResize(text, measure);
104
- const mutations = new MutationObserver(measure);
115
+ const stopObserving = observeResize([text, banner ?? text], measure);
116
+ let content = text.textContent;
117
+ const mutations = new MutationObserver(() => {
118
+ if (text.textContent !== content) {
119
+ content = text.textContent;
120
+ setDetailsAtWidth(null);
121
+ }
122
+ measure();
123
+ });
124
mutations.observe(text, { childList: true, subtree: true, characterData: true });
125
return () => {
126
stopObserving();