diff --git a/app/components/AiSidebar.js b/app/components/AiSidebar.js index eac151a..509ca16 100644 --- a/app/components/AiSidebar.js +++ b/app/components/AiSidebar.js @@ -240,20 +240,22 @@ export default function AiSidebar({ onInsertText }) { const onRegenerate = useCallback(async (aiMsgId) => { if (chatStreaming) return; + console.log('[Regenerate] Starting for msg:', aiMsgId); const msgs = chatHistory; const aiIdx = msgs.findIndex(m => m.id === aiMsgId); - if (aiIdx < 0) return; + if (aiIdx < 0) { console.log('[Regenerate] AI msg not found'); return; } let userMsgIdx = -1; for (let i = aiIdx - 1; i >= 0; i--) { if (msgs[i].role === 'user') { userMsgIdx = i; break; } } - if (userMsgIdx < 0) return; + if (userMsgIdx < 0) { console.log('[Regenerate] User msg not found'); return; } const userMsg = msgs[userMsgIdx]; const priorHistory = msgs.slice(0, userMsgIdx); setChatStreaming(true); + console.log('[Regenerate] User msg:', userMsg.content.slice(0, 50)); try { const { apiConfig } = getProjectSettings(); @@ -273,6 +275,7 @@ export default function AiSidebar({ onInsertText }) { ...s, messages: s.messages.map(m => { if (m.id !== aiMsgId) return m; const variants = m.variants || [{ content: m.content, thinking: m.thinking || '', timestamp: m.timestamp }]; + console.log('[Regenerate] Initialized variants:', variants.length); return { ...m, variants, content: '', thinking: '' }; }), }; @@ -289,8 +292,10 @@ export default function AiSidebar({ onInsertText }) { })); }, (finalText, finalThinking) => { + console.log('[Regenerate] Stream done, adding variant. Final text length:', finalText?.length); setSessionStore(prev => { const newStore = addVariant(prev, aiMsgId, { content: finalText || '(AI 未返回内容)', thinking: finalThinking, timestamp: Date.now() }); + console.log('[Regenerate] After addVariant, checking msg:', newStore.sessions.find(s => s.id === newStore.activeSessionId)?.messages.find(m => m.id === aiMsgId)?.variants?.length, 'variants'); saveSessionStore(newStore); return newStore; }); diff --git a/app/locales/en.json b/app/locales/en.json index 3e3b022..7f02f30 100644 --- a/app/locales/en.json +++ b/app/locales/en.json @@ -172,7 +172,7 @@ "roleAi": "AI", "edited": "Edited", "btnEdit": "✏️", - "btnResend": "🔄", + "btnResend": "↩️", "btnRegenerate": "🔄", "btnBranch": "🔀", "thinkingChain": "💡 Chain of Thought", diff --git a/app/locales/ru.json b/app/locales/ru.json index 179c989..8137c73 100644 --- a/app/locales/ru.json +++ b/app/locales/ru.json @@ -172,7 +172,7 @@ "roleAi": "ИИ", "edited": "Изменено", "btnEdit": "✏️", - "btnResend": "🔄", + "btnResend": "↩️", "btnRegenerate": "🔄", "btnBranch": "🔀", "thinkingChain": "💡 Цепь рассуждений", diff --git a/app/locales/zh.json b/app/locales/zh.json index 5ef127a..92bd152 100644 --- a/app/locales/zh.json +++ b/app/locales/zh.json @@ -172,7 +172,7 @@ "roleAi": "AI", "edited": "已编辑", "btnEdit": "✏️", - "btnResend": "🔄", + "btnResend": "↩️", "btnRegenerate": "🔄", "btnBranch": "🔀", "thinkingChain": "💡 思维链",