fix(FN-4201): complete Step 1 — sync composer autosize on messageInput changes

Fusion-Task-Id: FN-4201
Fusion-Task-Lineage: 6bfc2e72-8c11-4e63-b3c7-9245965d2380
This commit is contained in:
Fusion
2026-05-13 03:17:15 -07:00
committed by gsxdsm
parent 65b0f7917b
commit 600d634a09

View File

@@ -1444,6 +1444,20 @@ export function ChatView({ projectId, addToast, experimentalFeatures }: ChatView
[createSession, addToast, isMobile],
);
const resizeComposer = useCallback((textarea?: HTMLTextAreaElement | null) => {
const composer = textarea ?? inputRef.current;
if (!composer) {
return;
}
composer.style.height = "auto";
composer.style.height = `${clampChatInputHeight(composer.scrollHeight)}px`;
}, []);
useLayoutEffect(() => {
resizeComposer();
}, [messageInput, resizeComposer]);
const clearComposerState = useCallback(() => {
setMessageInput("");
if (activeDraftKey) {
@@ -1546,8 +1560,7 @@ export function ChatView({ projectId, addToast, experimentalFeatures }: ChatView
window.requestAnimationFrame(() => {
if (!inputRef.current) return;
inputRef.current.style.height = "auto";
inputRef.current.style.height = `${clampChatInputHeight(inputRef.current.scrollHeight)}px`;
resizeComposer(inputRef.current);
inputRef.current.focus();
});
@@ -1558,7 +1571,7 @@ export function ChatView({ projectId, addToast, experimentalFeatures }: ChatView
setSkillFilter("");
setHighlightedSkillIndex(0);
},
[],
[resizeComposer],
);
const handleMentionSelect = useCallback(
@@ -1585,13 +1598,12 @@ export function ChatView({ projectId, addToast, experimentalFeatures }: ChatView
window.requestAnimationFrame(() => {
if (!inputRef.current) return;
inputRef.current.style.height = "auto";
inputRef.current.style.height = `${clampChatInputHeight(inputRef.current.scrollHeight)}px`;
resizeComposer(inputRef.current);
inputRef.current.focus();
inputRef.current.setSelectionRange(nextCursorPos, nextCursorPos);
});
},
[mentionStartPos, messageInput],
[mentionStartPos, messageInput, resizeComposer],
);
@@ -1745,9 +1757,8 @@ export function ChatView({ projectId, addToast, experimentalFeatures }: ChatView
updateFileMentionPosition(textarea);
}
textarea.style.height = "auto";
textarea.style.height = `${clampChatInputHeight(textarea.scrollHeight)}px`;
}, [updateMentionState]);
resizeComposer(textarea);
}, [updateMentionState, resizeComposer]);
const handleInputSelectionChange = useCallback(
(e: React.SyntheticEvent<HTMLTextAreaElement>) => {