@@ -69,6 +69,7 @@ const AgentChatPanel = forwardRef<
6969 const [ showHeader , setShowHeader ] = useState ( true ) ;
7070 const streamControllerRef = useRef < AbortController | null > ( null ) ;
7171 const autoSummaryHistoryRef = useRef < Record < number , string | null > > ( { } ) ;
72+ const savedConversationRef = useRef < boolean > ( false ) ;
7273
7374 // 暴露 setInputText 方法给父组件
7475 useImperativeHandle ( ref , ( ) => ( {
@@ -117,6 +118,7 @@ const AgentChatPanel = forwardRef<
117118 timestamp : new Date ( msg . created_at ) ,
118119 } ) ) ;
119120 setMessages ( historyMessages ) ;
121+ savedConversationRef . current = true ;
120122 }
121123 } catch ( error ) {
122124 console . error ( "加载对话历史失败:" , error ) ;
@@ -135,6 +137,7 @@ const AgentChatPanel = forwardRef<
135137 timestamp : new Date ( ) ,
136138 } ,
137139 ] ) ;
140+ savedConversationRef . current = false ;
138141 }
139142 // 其他错误不影响新对话
140143 } finally {
@@ -150,6 +153,7 @@ const AgentChatPanel = forwardRef<
150153 const convId = parseInt ( savedConvId , 10 ) ;
151154 setConversationId ( convId ) ;
152155 loadConversationHistory ( convId ) ;
156+ savedConversationRef . current = true ;
153157 } else {
154158 // 没有保存的对话,显示欢迎消息
155159 setMessages ( [
@@ -162,6 +166,7 @@ const AgentChatPanel = forwardRef<
162166 ] ) ;
163167 setConversationId ( null ) ;
164168 setQuotedText ( null ) ;
169+ savedConversationRef . current = false ;
165170 }
166171 } else if ( ! mineruResult ) {
167172 // 重置为初始状态
@@ -175,6 +180,7 @@ const AgentChatPanel = forwardRef<
175180 ] ) ;
176181 setConversationId ( null ) ;
177182 setQuotedText ( null ) ;
183+ savedConversationRef . current = false ;
178184 }
179185 } , [ paperId , mineruResult , loadConversationHistory ] ) ;
180186
@@ -302,6 +308,9 @@ const AgentChatPanel = forwardRef<
302308 if ( ! paperId || ! mineruResult ) {
303309 return ;
304310 }
311+ if ( conversationId || savedConversationRef . current ) {
312+ return ;
313+ }
305314
306315 const summaryIntro : AgentMessage = {
307316 id : createId ( ) ,
0 commit comments