This commit is contained in:
从何开始123
2026-01-08 11:56:00 +08:00
parent 54e9bf5906
commit 1561c054b7
24 changed files with 1105 additions and 449 deletions

View File

@@ -1,4 +1,4 @@
import React, { useRef, useLayoutEffect, useState } from 'react';
import React, { useRef, useLayoutEffect, useState, useEffect } from 'react';
import { ArrowUp, Square } from 'lucide-react';
import { AppState } from '../types';
@@ -34,6 +34,13 @@ const InputSection = ({ query, setQuery, onRun, onStop, appState }: InputSection
}
};
// Focus input on mount and when app becomes idle (e.g. after "New Chat" or completion)
useEffect(() => {
if (appState === 'idle' && textareaRef.current) {
textareaRef.current.focus();
}
}, [appState]);
// useLayoutEffect prevents visual flickering by adjusting height before paint
useLayoutEffect(() => {
adjustHeight();
@@ -70,6 +77,7 @@ const InputSection = ({ query, setQuery, onRun, onStop, appState }: InputSection
onCompositionEnd={() => setIsComposing(false)}
placeholder="Ask a complex question..."
rows={1}
autoFocus
className="flex-1 max-h-[200px] py-3 pl-4 pr-2 bg-transparent border-none focus:ring-0 resize-none outline-none text-slate-800 placeholder:text-slate-400 leading-relaxed custom-scrollbar text-base"
style={{ minHeight: '48px' }}
/>