@devries-cameron20 / t3code Mirror · read-only / commits / cc93cc564b
Fork 0

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, 15:45 UTC

revert(web): composer body ref goes back to the #25079 ref callback (#25412)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 26, 2026 at 01:50 UTC cc93cc564b052a9dcf73323783e7b60506cda5e0
2 files changed +18 -9
apps/web/src/components/chat/ChatComposer.tsx
+9 -2
@@ -1096,7 +1096,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
1096 null,
1097 );
1098 const [composerMenuAnchor, setComposerMenuAnchor] = useState<HTMLDivElement | null>(null);
1099 - const hasWrappedPrompt = useComposerMultilinePrompt(composerMenuAnchor);
1099 + const [hasWrappedPrompt, observeWrappedPrompt] = useComposerMultilinePrompt();
1100 const hasMultilinePrompt = prompt.includes("\n") || hasWrappedPrompt;
1101 const [isTasksDrawerOpen, setIsTasksDrawerOpen] = useState(false);
1102 // A pending question stays expanded: its card moves into the banner dock,
@@ -3652,7 +3652,14 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
3652 ) : null}
3653
3654 <div
3655 - ref={setComposerMenuAnchor}
3655 + ref={(node) => {
3656 + setComposerMenuAnchor(node);
3657 + const stopObserving = observeWrappedPrompt(node);
3658 + return () => {
3659 + setComposerMenuAnchor(null);
3660 + stopObserving?.();
3661 + };
3662 + }}
3663 data-chat-composer-body="true"
3664 className={cn(
3665 "relative px-3 pb-2 sm:px-4",
apps/web/src/components/chat/useComposerMultilinePrompt.ts
+9 -7
@@ -1,4 +1,4 @@
1 -import { useLayoutEffect, useState } from "react";
1 +import { useState } from "react";
2 import { observeResize } from "../../lib/observeResize";
3
4 function measureComposerMultilinePrompt(body: HTMLElement): boolean | null {
@@ -19,10 +19,13 @@ function measureComposerMultilinePrompt(body: HTMLElement): boolean | null {
19 return bounds.height > lineHeight + 1 || bounds.width > expandedWidth + 1;
20 }
21
22 -export function useComposerMultilinePrompt(body: HTMLElement | null): boolean {
22 +/** Whether the prompt wraps, and the ref callback that measures it on the composer body. */
23 +export function useComposerMultilinePrompt(): readonly [
24 + boolean,
25 + (body: HTMLElement | null) => (() => void) | undefined,
26 +] {
27 const [isMultiline, setIsMultiline] = useState(false);
24 -
25 - useLayoutEffect(() => {
28 + const observeBody = (body: HTMLElement | null) => {
29 if (!body) return;
30 const measure = () => {
31 const next = measureComposerMultilinePrompt(body);
@@ -37,7 +40,6 @@ export function useComposerMultilinePrompt(body: HTMLElement | null): boolean {
40 stopObserving();
41 mutationObserver.disconnect();
42 };
40 - }, [body]);
41 -
42 - return isMultiline;
43 + };
44 + return [isMultiline, observeBody] as const;
45 }