This build was committed by a bot.

This commit is contained in:
github-actions
2025-08-26 05:05:12 +00:00
parent 76a2376b61
commit bdb1392f58
2 changed files with 3 additions and 3 deletions

View File

@@ -245,8 +245,8 @@ const lastAssistantId=()=>{const a=[...el.messages.querySelectorAll('.msg-bubble
const getBubbleById=id=>el.messages.querySelector(`.msg-bubble[data-mid="${CSS.escape(id)}"]`)
async function syncTranscript(){const id=lastAssistantId();if(!id)return false;const bubble=getBubbleById(id);if(!bubble)return false;const j=await fetchTranscript(id).catch(()=>null);if(!j||j.rid!==id){if(j&&j.error){setBtnSend();state.busy=false;const t=(bubble.textContent||'')+'\n\n'+j.error;renderMarkdown(bubble,t,{enhance:false});enhanceCodeBlocks(bubble,true);const i=state.messages.findIndex(m=>m.id===id);if(i>=0)state.messages[i].content=[{type:'text',text:t}];else state.messages.push({id,role:'assistant',content:[{type:'text',text:t}]});persistThread()}return false}const t=j.text||'';renderMarkdown(bubble,t,{enhance:false});if(j.error||j.done||j.phase==='done'){setBtnSend();state.busy=false;enhanceCodeBlocks(bubble,true);const i=state.messages.findIndex(m=>m.id===id);if(i>=0)state.messages[i].content=[{type:'text',text:t}];else state.messages.push({id,role:'assistant',content:[{type:'text',text:t}]});persistThread();return false}return true}
let syncLoopRunning=false
const syncKick=r=>{if(document.visibilityState!=='hidden')setTimeout(()=>syncLoop(r),0)}
async function syncLoop(){if(syncLoopRunning)return;const id=lastAssistantId();if(!id)return;syncLoopRunning=true;try{for(;;){const cont=await syncTranscript().catch(()=>false);if(!cont)break;await new Promise(r=>setTimeout(r,1200))}}finally{syncLoopRunning=false}}
const syncKick=r=>{if(!state.busy||document.visibilityState==='hidden')return;setTimeout(()=>syncLoop(r),0)}
async function syncLoop(){if(!state.busy||syncLoopRunning)return;const id=lastAssistantId();if(!id)return;syncLoopRunning=true;try{for(;;){if(!state.busy)break;const cont=await syncTranscript().catch(()=>false);if(!cont)break;await new Promise(r=>setTimeout(r,1200))}}finally{syncLoopRunning=false}}
;['focus','pageshow'].forEach(ev=>window.addEventListener(ev,()=>syncKick(ev)))
document.addEventListener('visibilitychange',()=>{if(document.visibilityState==='visible')syncKick('visible')})
el.copySystemPrompt.addEventListener('click',async()=>{try{await navigator.clipboard.writeText(el.set_system_prompt.value||'')}catch{}})