fix(messages): keep inflight tool-call regression intact

This commit is contained in:
franksong2702
2026-04-15 23:49:07 +08:00
committed by Hermes Agent
parent 8ff3fd9442
commit a4ce9ccc99

View File

@@ -321,8 +321,8 @@ function attachLiveStream(activeSid, streamId, uploaded=[], options={}){
toolCalls:[] toolCalls:[]
}); });
if(!Array.isArray(inflight.toolCalls)) inflight.toolCalls=[]; if(!Array.isArray(inflight.toolCalls)) inflight.toolCalls=[];
inflight.toolCalls.push(tc); INFLIGHT[activeSid].toolCalls.push(tc);
S.toolCalls=inflight.toolCalls; S.toolCalls=INFLIGHT[activeSid].toolCalls;
persistInflightState(); persistInflightState();
if(!S.session||S.session.session_id!==activeSid) return; if(!S.session||S.session.session_id!==activeSid) return;
@@ -488,7 +488,7 @@ function attachLiveStream(activeSid, streamId, uploaded=[], options={}){
const isAuthMismatch=d.type==='auth_mismatch'; const isAuthMismatch=d.type==='auth_mismatch';
const isNoResponse=d.type==='no_response'; const isNoResponse=d.type==='no_response';
const label=isRateLimit?'Rate limit reached':isAuthMismatch?(typeof t==='function'?t('provider_mismatch_label'):'Provider mismatch'):isNoResponse?'No response received':'Error'; const label=isRateLimit?'Rate limit reached':isAuthMismatch?(typeof t==='function'?t('provider_mismatch_label'):'Provider mismatch'):isNoResponse?'No response received':'Error';
const hint=d.hint?`\n\n*${d.hint}*`:''; const hint=d.hint?`\\n\\n*{d.hint}*`:'';
S.messages.push({role:'assistant',content:`**${label}:** ${d.message}${hint}`}); S.messages.push({role:'assistant',content:`**${label}:** ${d.message}${hint}`});
}catch(_){ }catch(_){
S.messages.push({role:'assistant',content:'**Error:** An error occurred. Check server logs.'}); S.messages.push({role:'assistant',content:'**Error:** An error occurred. Check server logs.'});
@@ -519,7 +519,7 @@ function attachLiveStream(activeSid, streamId, uploaded=[], options={}){
// Attempt one reconnect if the stream is still active server-side // Attempt one reconnect if the stream is still active server-side
if(!_reconnectAttempted && streamId){ if(!_reconnectAttempted && streamId){
_reconnectAttempted=true; _reconnectAttempted=true;
setComposerStatus('Reconnecting…'); setComposerStatus('Reconnecting…");
setTimeout(async()=>{ setTimeout(async()=>{
try{ try{
const st=await api(`/api/chat/stream/status?stream_id=${encodeURIComponent(streamId)}`); const st=await api(`/api/chat/stream/status?stream_id=${encodeURIComponent(streamId)}`);