diff --git a/src/renderer/src/hooks/useTextareaResize.ts b/src/renderer/src/hooks/useTextareaResize.ts index 8688cb186f..c29d6134cd 100644 --- a/src/renderer/src/hooks/useTextareaResize.ts +++ b/src/renderer/src/hooks/useTextareaResize.ts @@ -51,7 +51,7 @@ export function useTextareaResize(options: UseTextareaResizeOptions = {}): UseTe const { maxHeight = 400, minHeight = 30, autoResize = true } = options const textareaRef = useRef(null) - const [customHeight, setCustomHeight] = useState() + const [customHeight, setCustomHeight] = useState(undefined) const [isExpanded, setIsExpanded] = useState(false) const resize = useCallback( diff --git a/src/renderer/src/pages/home/Inputbar/AgentSessionInputbar.tsx b/src/renderer/src/pages/home/Inputbar/AgentSessionInputbar.tsx index 2dbcd04067..850be7f727 100644 --- a/src/renderer/src/pages/home/Inputbar/AgentSessionInputbar.tsx +++ b/src/renderer/src/pages/home/Inputbar/AgentSessionInputbar.tsx @@ -177,8 +177,10 @@ const AgentSessionInputbarInner: FC = ({ assistant, agentId, session resize: resizeTextArea, focus: focusTextarea, setExpanded, - isExpanded: textareaIsExpanded - } = useTextareaResize({ maxHeight: 400, minHeight: 30 }) + isExpanded: textareaIsExpanded, + customHeight, + setCustomHeight + } = useTextareaResize({ maxHeight: 500, minHeight: 30 }) const { sendMessageShortcut, apiServer } = useSettings() const { t } = useTranslation() @@ -474,6 +476,8 @@ const AgentSessionInputbarInner: FC = ({ assistant, agentId, session text={text} onTextChange={setText} textareaRef={textareaRef} + height={customHeight} + onHeightChange={setCustomHeight} resizeTextArea={resizeTextArea} focusTextarea={focusTextarea} placeholder={placeholderText} diff --git a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx index 0985023ead..fc95082e50 100644 --- a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx +++ b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx @@ -143,9 +143,11 @@ const InputbarInner: FC = ({ assistant: initialAssistant, se resize: resizeTextArea, focus: focusTextarea, setExpanded, - isExpanded: textareaIsExpanded + isExpanded: textareaIsExpanded, + customHeight, + setCustomHeight } = useTextareaResize({ - maxHeight: 400, + maxHeight: 500, minHeight: 30 }) @@ -257,7 +259,7 @@ const InputbarInner: FC = ({ assistant: initialAssistant, se setText('') setFiles([]) setTimeoutTimer('sendMessage_1', () => setText(''), 500) - setTimeoutTimer('sendMessage_2', () => resizeTextArea(true), 0) + setTimeoutTimer('sendMessage_2', () => resizeTextArea(), 0) } catch (error) { logger.warn('Failed to send message:', error as Error) parent?.recordException(error as Error) @@ -478,6 +480,8 @@ const InputbarInner: FC = ({ assistant: initialAssistant, se text={text} onTextChange={setText} textareaRef={textareaRef} + height={customHeight} + onHeightChange={setCustomHeight} resizeTextArea={resizeTextArea} focusTextarea={focusTextarea} isLoading={loading} diff --git a/src/renderer/src/pages/home/Inputbar/components/InputbarCore.tsx b/src/renderer/src/pages/home/Inputbar/components/InputbarCore.tsx index e1ae6d1bae..b55ca93cd3 100644 --- a/src/renderer/src/pages/home/Inputbar/components/InputbarCore.tsx +++ b/src/renderer/src/pages/home/Inputbar/components/InputbarCore.tsx @@ -50,6 +50,9 @@ export interface InputbarCoreProps { resizeTextArea: (force?: boolean) => void focusTextarea: () => void + height: number | undefined + onHeightChange: (height: number) => void + supportedExts: string[] isLoading: boolean @@ -104,6 +107,8 @@ export const InputbarCore: FC = ({ textareaRef, resizeTextArea, focusTextarea, + height, + onHeightChange, supportedExts, isLoading, onPause, @@ -131,8 +136,6 @@ export const InputbarCore: FC = ({ } = useSettings() const quickPanelTriggersEnabled = forceEnableQuickPanelTriggers ?? enableQuickPanelTriggers - const [textareaHeight, setTextareaHeight] = useState() - const { t } = useTranslation() const [isTranslating, setIsTranslating] = useState(false) const { getLanguageByLangcode } = useTranslate() @@ -538,8 +541,8 @@ export const InputbarCore: FC = ({ const handleMouseMove = (e: MouseEvent) => { const deltaY = startDragY.current - e.clientY - const newHeight = Math.max(40, Math.min(400, startHeight.current + deltaY)) - setTextareaHeight(newHeight) + const newHeight = Math.max(40, Math.min(500, startHeight.current + deltaY)) + onHeightChange(newHeight) } const handleMouseUp = () => { @@ -550,7 +553,7 @@ export const InputbarCore: FC = ({ document.addEventListener('mousemove', handleMouseMove) document.addEventListener('mouseup', handleMouseUp) }, - [config.enableDragDrop, setTextareaHeight, textareaRef] + [config.enableDragDrop, onHeightChange, textareaRef] ) const onQuote = useCallback( @@ -667,11 +670,11 @@ export const InputbarCore: FC = ({ variant="borderless" spellCheck={enableSpellCheck} rows={2} - autoSize={textareaHeight ? false : { minRows: 2, maxRows: 20 }} + autoSize={height ? false : { minRows: 2, maxRows: 20 }} styles={{ textarea: TextareaStyle }} style={{ fontSize, - height: textareaHeight, + height: height, minHeight: '30px' }} disabled={isTranslating || searching}