{"record":{"id":"fb9bef7708a55cc7","repo":"BigPizzaV3/CodexPlusPlus","slug":"codex-canvas-panel","errorCode":null,"errorMessage":"Codex++ 会话接口尚未连接，请稍后点击刷新","messagePattern":"Codex\\+\\+ 会话接口尚未连接，请稍后点击刷新","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"tools/conversation-canvas/src/canvas-panel.js","lineNumber":256,"sourceCode":"      const needle=normalize(message.text).slice(0,100);\n      if(needle.length>=15){\n        const candidates=[...document.querySelectorAll('p,pre,[data-message-id],article')].filter(e=>!host.contains(e)&&normalize(e.textContent).includes(needle));\n        const leaves=candidates.filter(e=>!candidates.some(other=>other!==e&&e.contains(other)));\n        if(leaves.length===1)target=leaves[0];\n      }\n    }\n    if(!target){$('jump-status').textContent=({revealed:'已展开所属轮次，但该消息仍被折叠或未显示。可先查看对应原文。',unavailable:'当前页面的历史定位尚未就绪。可先查看对应原文。','missing-turn':'该来源缺少轮次信息。可先查看对应原文。',failed:'原聊天轮次展开失败。可先查看对应原文。'})[navigationState];return;}\n    closePanel();\n    target.scrollIntoView({behavior:'smooth',block:'center'});\n    target.animate([{outline:'2px solid #888',backgroundColor:'#8882'},{outline:'2px solid transparent',backgroundColor:'transparent'}],{duration:2000});\n    $('jump-status').textContent='正在定位原聊天消息…';\n    setTimeout(()=>{if(disposed||currentId()!==threadId)return;const r=target.getBoundingClientRect();$('jump-status').textContent=target.isConnected&&r.height>0&&r.bottom>0&&r.top<innerHeight?'已定位并高亮原聊天消息。':'消息已找到，滚动尚未完成。';},700);\n  }\n  async function readCanvasSource(id,signal,progress){\n    if(!nativeReadTasks.has(id)){\n      let result;\n      try{\n        if(typeof window.__codexSessionDeleteBridge!=='function')throw Error('Codex++ 会话接口尚未连接，请稍后点击刷新');\n        let timer;\n        try{result=await Promise.race([window.__codexSessionDeleteBridge('/session/export',{session_id:id}),new Promise((_,reject)=>{timer=setTimeout(()=>reject(Error('会话读取超时，请重试')),15000);})]);}\n        finally{clearTimeout(timer);}\n      }catch(error){if(!isExportSizeError(error.message))throw error;result={message:error.message};}\n      if(result?.status==='ok')return result;\n      if(!isExportSizeError(result?.message))throw Error(result?.message||'Codex++ 会话读取失败');\n      nativeReadTasks.add(id);\n    }\n    signal.throwIfAborted();progress('会话较大，正在改用原生分页读取…');\n    const {manager}=await nativeContext(id);\n    const messages=await readNativeHistory((method,params)=>manager.sendRequest(method,params,{priority:'background',timeoutMs:15000}),id,historyCache,progress,signal);\n    const signature=[];for(const message of messages){signal.throwIfAborted();signature.push(message.id+':'+await messageDigest(message));}\n    return {status:'ok',kind:'canvas-messages',session_id:id,messages,content:signature.join('|')};\n  }\n  async function sync(force=false){\n    const id=currentId();\n    if(!id){historyAbort?.abort();requestSequence++;active='';pending=null;data=null;revision='';taskCanvas.context('');$('pending-tray').replaceChildren();$('transcript').replaceChildren();$('details').hidden=true;status('请打开具体任务。');return;}\n    if(id!==active){","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/tools/conversation-canvas/src/canvas-panel.js#L238-L274","documentation":"Identical guard to error 610 but in the panel bundle (src/canvas-panel.js): readCanvasSource throws when the Codex++ bridge function window.__codexSessionDeleteBridge is not available at the moment of the export attempt.","triggerScenarios":"readCanvasSource invoked from the panel while window.__codexSessionDeleteBridge is undefined/not a function — bridge not yet injected or injection failed.","commonSituations":"Panel opened immediately after page load before extension injection; extension update or Codex redesign broke bridge injection; extension disabled in this browser profile.","solutions":["Click refresh in the panel after a short delay to retry","Reload the Codex page so the extension injects the bridge","Re-enable/reinstall the Codex++ extension","Check the browser console for extension content-script errors"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if(typeof window.__codexSessionDeleteBridge!=='function')return queueRetry(readCanvasSource);","typeGuard":"const bridgeAvailable=()=>typeof window.__codexSessionDeleteBridge==='function';","tryCatchPattern":"try{await readCanvasSource(id,signal,progress);}catch(e){if(/尚未连接/.test(e.message)){setTimeout(()=>refresh(),2000);}else throw e;}","preventionTips":["Gate panel actions on a bridge-ready event from the extension","Show a 'bridge connecting' state instead of allowing immediate refresh spam","Reload the page after installing/updating the extension"],"tags":["userscript","bridge","session-export"],"backgroundTag":"missing-dependency","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}