@@ -38,13 +38,25 @@ export default function ApiConfigAssistant({ onClose, currentSettings, onApply }
3838 } , [ messages ] ) ;
3939
4040 // Auto-fill from existing configs
41+ const autoConfigured = useRef ( false ) ;
4142 useEffect ( ( ) => {
43+ if ( autoConfigured . current ) return ;
4244 const mainConfig = currentSettings . configs ?. find ( ( c ) => c . id === currentSettings . activeConfigId ) ;
43- if ( mainConfig ?. baseUrl && mainConfig ?. apiKey && ! configReady ) {
45+ if ( mainConfig ?. baseUrl && mainConfig ?. apiKey ) {
4446 setAssistantBaseUrl ( mainConfig . baseUrl . replace ( / \/ + $ / , '' ) ) ;
4547 setAssistantApiKey ( mainConfig . apiKey ) ;
4648 setAssistantModel ( mainConfig . model || '' ) ;
47- // Don't auto-close panel — let user verify
49+ setConfigReady ( true ) ;
50+ setShowConfigPanel ( false ) ;
51+ autoConfigured . current = true ;
52+ // Post a system message to inform user
53+ setMessages ( ( prev ) => [
54+ ...prev ,
55+ {
56+ role : 'assistant' ,
57+ content : `已自动使用当前配置:${ mainConfig . 名称 || '未命名' } (${ mainConfig . baseUrl . replace ( / \/ + $ / , '' ) } )\n如需更换助手后端,请点击右上角齿轮图标。` ,
58+ } ,
59+ ] ) ;
4860 }
4961 } , [ currentSettings ] ) ;
5062
@@ -117,8 +129,8 @@ export default function ApiConfigAssistant({ onClose, currentSettings, onApply }
117129 } ;
118130
119131 return (
120- < div className = "fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm" >
121- < div className = "relative w-full max-w-2xl max-h-[85vh] flex flex-col bg-gray-900/95 border border-wuxia-gold/30 rounded-xl shadow-2xl" >
132+ < div className = "fixed inset-0 z-[300] flex items-center justify-center bg-black/60 backdrop-blur-sm" >
133+ < div className = "relative w-full max-w-2xl max-h-[85vh] sm:max-h-[85vh] h-[100dvh] sm:h-auto flex flex-col bg-gray-900/95 border border-wuxia-gold/30 rounded-none sm:rounded- xl shadow-2xl mx-2 sm:mx-4 " >
122134 { /* Header */ }
123135 < div className = "flex items-center justify-between px-4 py-3 border-b border-wuxia-gold/20" >
124136 < h2 className = "text-lg font-bold font-serif text-wuxia-gold" > AI 配置助手</ h2 >
@@ -258,32 +270,32 @@ function AssistantConfigPanel({
258270 </ div >
259271 ) }
260272
261- < div className = "flex gap-2" >
273+ < div className = "flex flex-wrap gap-2" >
262274 < input
263275 type = "text"
264276 value = { baseUrl }
265277 onChange = { ( e ) => onBaseUrlChange ( e . target . value ) }
266278 placeholder = "https://example.com/v1"
267- className = "flex-1 bg-gray-700 border border-gray-600 rounded px-2 py-1.5 text-xs text-white placeholder-gray-500 focus:border-wuxia-gold focus:outline-none"
279+ className = "min-w-0 flex-1 sm: flex-1 bg-gray-700 border border-gray-600 rounded px-2 py-1.5 text-xs text-white placeholder-gray-500 focus:border-wuxia-gold focus:outline-none"
268280 />
269281 < input
270282 type = "password"
271283 value = { apiKey }
272284 onChange = { ( e ) => onApiKeyChange ( e . target . value ) }
273285 placeholder = "sk-..."
274- className = "flex-1 bg-gray-700 border border-gray-600 rounded px-2 py-1.5 text-xs text-white placeholder-gray-500 focus:border-wuxia-gold focus:outline-none"
286+ className = "min-w-0 flex-1 sm: flex-1 bg-gray-700 border border-gray-600 rounded px-2 py-1.5 text-xs text-white placeholder-gray-500 focus:border-wuxia-gold focus:outline-none"
275287 />
276288 < input
277289 type = "text"
278290 value = { model }
279291 onChange = { ( e ) => onModelChange ( e . target . value ) }
280292 placeholder = "模型名 (可选)"
281- className = "w-32 bg-gray-700 border border-gray-600 rounded px-2 py-1.5 text-xs text-white placeholder-gray-500 focus:border-wuxia-gold focus:outline-none"
293+ className = "w-24 sm:w- 32 bg-gray-700 border border-gray-600 rounded px-2 py-1.5 text-xs text-white placeholder-gray-500 focus:border-wuxia-gold focus:outline-none"
282294 />
283295 < button
284296 onClick = { onConfirm }
285297 disabled = { ! baseUrl . trim ( ) || ! apiKey . trim ( ) }
286- className = { `px-3 py-1.5 rounded text-xs font-bold transition-colors ${
298+ className = { `w-full sm:w-auto px-3 py-1.5 rounded text-xs font-bold transition-colors ${
287299 isReady
288300 ? 'bg-green-600/30 text-green-400 border border-green-500/30'
289301 : 'bg-wuxia-gold/20 text-wuxia-gold disabled:opacity-40'
@@ -303,7 +315,7 @@ function MessageBubble({ message }: { message: AssistantMessage }) {
303315 return (
304316 < div className = { `flex ${ isUser ? 'justify-end' : 'justify-start' } ` } >
305317 < div
306- className = { `max-w-[85%] rounded-lg px-3 py-2 text-sm whitespace-pre-wrap ${
318+ className = { `max-w-[85%] rounded-lg px-3 py-2 text-sm whitespace-pre-wrap break-words ${
307319 isError
308320 ? 'bg-red-900/40 text-red-300 border border-red-500/30'
309321 : isUser
0 commit comments