@pi-chamber/web 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/bin/cli.test.js +6 -8
  2. package/bin/lib/cli-tunnel-capabilities.js +0 -2
  3. package/dist/assets/{CommitSection-BQBmpPVE.js → CommitSection-BpbMC0et.js} +1 -1
  4. package/dist/assets/{DiagramEditor-Cp22TGpq.js → DiagramEditor-dFTMKHuO.js} +1 -1
  5. package/dist/assets/{DiagramView-E4HJ4ZPU.js → DiagramView-DVw_8Px1.js} +1 -1
  6. package/dist/assets/{DiffView-d23o9CKP.js → DiffView-CkoY1oAM.js} +2 -2
  7. package/dist/assets/FilesView-C0hyg2pa.js +14 -0
  8. package/dist/assets/{GitView-CkUONO1-.js → GitView-D36hpDsb.js} +4 -4
  9. package/dist/assets/{JsonTreeView-By2oGMNK.js → JsonTreeView-BF8S-bPN.js} +1 -1
  10. package/dist/assets/{MarkdownRendererImpl-DUghE55t.js → MarkdownRendererImpl-BVNChdig.js} +2 -2
  11. package/dist/assets/{PatchDiff-BjN6zMtK.js → PatchDiff-B--OaNB1.js} +1 -1
  12. package/dist/assets/{PierreDiffViewer-B38_7NnU.js → PierreDiffViewer-0Qkp9ICt.js} +2 -2
  13. package/dist/assets/{SessionSwitcherDropdown-NbVfnqQQ.js → SessionSwitcherDropdown-cFWgy1td.js} +101 -102
  14. package/dist/assets/SettingsView-D3ZZyjU3.js +4 -0
  15. package/dist/assets/SettingsWindow-BuJCvYoR.js +1 -0
  16. package/dist/assets/{ToolOutputDialog-DVesARmI.js → ToolOutputDialog-Bi9BoEe7.js} +5 -5
  17. package/dist/assets/{ToolPartDiffPreview-C2N_oIO-.js → ToolPartDiffPreview-DGX7N4zr.js} +1 -1
  18. package/dist/assets/{VirtualizedFileDiff-B7eVR6Pt.js → VirtualizedFileDiff-CxraYoDZ.js} +1 -1
  19. package/dist/assets/{collapsible-CPkWB1VR.js → collapsible-d4-HChej.js} +1 -1
  20. package/dist/assets/{computeVirtualFileMetrics-BsZulefS.js → computeVirtualFileMetrics-BuD14qFL.js} +2 -2
  21. package/dist/assets/{contextFileOpenGuard-BmmlK5E3.js → contextFileOpenGuard-DirV-hCs.js} +1 -1
  22. package/dist/assets/{index-C84KrQoy.js → index-BWmmf5yJ.js} +1 -1
  23. package/dist/assets/{index-BhXma4dv.js → index-DEYblXCW.js} +7 -7
  24. package/dist/assets/index-DLKBsLKY.css +1 -0
  25. package/dist/assets/{isDiffPlainText-DsuyxFXo.js → isDiffPlainText-LoMmNzmX.js} +1 -1
  26. package/dist/assets/{isFilePlainText-CCYoe7us.js → isFilePlainText-3Hj9i02t.js} +1 -1
  27. package/dist/assets/{main-ClYgYVm1.js → main-BsszlAdQ.js} +2 -2
  28. package/dist/assets/main-CUvZIN16.js +133 -0
  29. package/dist/assets/{markdownCore-D2uqals1.js → markdownCore-sGxk8jrc.js} +2 -2
  30. package/dist/assets/{miniChat-DmX9SjxM.js → miniChat-C6SDQL4G.js} +2 -2
  31. package/dist/assets/{mobile-C-PCxN62.js → mobile-DBW3XDmZ.js} +2 -2
  32. package/dist/assets/renderElectronMiniChatApp-B1_fTdN-.js +1 -0
  33. package/dist/assets/renderMobileApp-CFxZc_1a.js +14 -0
  34. package/dist/assets/{runtimeSurface-CouGjZ3A.js → runtimeSurface-9aJdtQbh.js} +1 -1
  35. package/dist/assets/{useInlineCommentController-buNJ3xB4.js → useInlineCommentController-Cl--s6vE.js} +2 -2
  36. package/dist/assets/usePanelSlide-D5ffPTGM.js +56 -0
  37. package/dist/assets/{useWindowTitle-CnF4pKz0.js → useWindowTitle-C-AZD713.js} +3 -3
  38. package/dist/assets/{vendor-base-ui-DwfTg5wD.js → vendor-base-ui-DL8r2fgQ.js} +1 -1
  39. package/dist/assets/{vendor-codemirror-autocomplete-3xMyV7a2.js → vendor-codemirror-autocomplete-BS2SpSAZ.js} +1 -1
  40. package/dist/assets/{vendor-codemirror-commands-Bzf12ODH.js → vendor-codemirror-commands-RrgJ8H_6.js} +1 -1
  41. package/dist/assets/{vendor-codemirror-lang-angular-0K6s6cvb.js → vendor-codemirror-lang-angular-ADhO_TUK.js} +1 -1
  42. package/dist/assets/{vendor-codemirror-lang-cpp-B0aL03z-.js → vendor-codemirror-lang-cpp-BGCWj7Om.js} +1 -1
  43. package/dist/assets/{vendor-codemirror-lang-css-C4jEScp7.js → vendor-codemirror-lang-css-Ba8JZ6fp.js} +1 -1
  44. package/dist/assets/{vendor-codemirror-lang-go-CgrfVBPr.js → vendor-codemirror-lang-go-DyTiHXo4.js} +1 -1
  45. package/dist/assets/{vendor-codemirror-lang-html-C1Svvdey.js → vendor-codemirror-lang-html-DK27qQri.js} +1 -1
  46. package/dist/assets/{vendor-codemirror-lang-java-DNPz7_Bx.js → vendor-codemirror-lang-java-CvFfnhPQ.js} +1 -1
  47. package/dist/assets/{vendor-codemirror-lang-javascript-CrbeaEAU.js → vendor-codemirror-lang-javascript-BUlYhQ3o.js} +1 -1
  48. package/dist/assets/{vendor-codemirror-lang-jinja-DL8BR_RG.js → vendor-codemirror-lang-jinja-wBMtAEvT.js} +1 -1
  49. package/dist/assets/{vendor-codemirror-lang-json-BTvAjwkJ.js → vendor-codemirror-lang-json-CqayksDf.js} +1 -1
  50. package/dist/assets/{vendor-codemirror-lang-less-CPABt6NZ.js → vendor-codemirror-lang-less-Ct3-H1PB.js} +1 -1
  51. package/dist/assets/{vendor-codemirror-lang-liquid-BLOLOBMg.js → vendor-codemirror-lang-liquid-XspREksq.js} +1 -1
  52. package/dist/assets/{vendor-codemirror-lang-markdown-BloD9GN-.js → vendor-codemirror-lang-markdown-CvO36Y1p.js} +1 -1
  53. package/dist/assets/{vendor-codemirror-lang-php-FIZMTuWM.js → vendor-codemirror-lang-php-BlUF9cCe.js} +1 -1
  54. package/dist/assets/{vendor-codemirror-lang-python-CR2g6ukK.js → vendor-codemirror-lang-python-_2bIYTiJ.js} +1 -1
  55. package/dist/assets/{vendor-codemirror-lang-rust-lsPqn4k4.js → vendor-codemirror-lang-rust-BdTYih_U.js} +1 -1
  56. package/dist/assets/{vendor-codemirror-lang-sass-CtECMwzH.js → vendor-codemirror-lang-sass-E6MhfOFk.js} +1 -1
  57. package/dist/assets/{vendor-codemirror-lang-sql-BtmZrrZH.js → vendor-codemirror-lang-sql-B1BRhQSF.js} +1 -1
  58. package/dist/assets/{vendor-codemirror-lang-vue-Br6DrntY.js → vendor-codemirror-lang-vue-BYQJRa1Q.js} +1 -1
  59. package/dist/assets/{vendor-codemirror-lang-wast-DT7IlCnb.js → vendor-codemirror-lang-wast-D706yuyC.js} +1 -1
  60. package/dist/assets/{vendor-codemirror-lang-xml-wNr-LZOf.js → vendor-codemirror-lang-xml--MfWU6Dj.js} +1 -1
  61. package/dist/assets/{vendor-codemirror-lang-yaml-BTKFwfc2.js → vendor-codemirror-lang-yaml-CRUFIbRX.js} +1 -1
  62. package/dist/assets/{vendor-codemirror-language-BuDklWi8.js → vendor-codemirror-language-E2vgV9K3.js} +1 -1
  63. package/dist/assets/{vendor-codemirror-language-data-qBLdzwMc.js → vendor-codemirror-language-data-HC9JT4I3.js} +2 -2
  64. package/dist/assets/{vendor-codemirror-search-BzyfPoRb.js → vendor-codemirror-search-8kyQdB3f.js} +1 -1
  65. package/dist/assets/{vendor-codemirror-state-Wdz6Qsow.js → vendor-codemirror-state-CNWM3Q8V.js} +1 -1
  66. package/dist/assets/{vendor-codemirror-view-pXtfpqbT.js → vendor-codemirror-view-DSzLbZiS.js} +1 -1
  67. package/dist/assets/{vendor-replit-codemirror-vim-BUqe2Slv.js → vendor-replit-codemirror-vim-BJY5fGLS.js} +1 -1
  68. package/dist/assets/{web-components-BhO08KaW.js → web-components-skJ_VpnT.js} +4 -4
  69. package/dist/index.html +4 -4
  70. package/dist/mini-chat.html +3 -3
  71. package/dist/mobile.html +3 -3
  72. package/package.json +1 -1
  73. package/server/lib/package-manager.js +0 -34
  74. package/server/lib/pi/routes.js +32 -2
  75. package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -1
  76. package/server/lib/pi/session-daemon/runtime-registry.js +3 -0
  77. package/server/lib/pi/session-daemon/session-daemon.js +150 -10
  78. package/server/lib/pi/session-daemon/session-daemon.test.js +22 -0
  79. package/server/lib/tunnels/DOCUMENTATION.md +6 -7
  80. package/server/lib/tunnels/executable-search.test.js +4 -4
  81. package/server/lib/tunnels/install-help.js +0 -10
  82. package/server/lib/tunnels/install-help.test.js +0 -9
  83. package/server/lib/tunnels/types.js +0 -1
  84. package/dist/assets/FilesView-DIDB-xK7.js +0 -14
  85. package/dist/assets/SettingsView-C2dCv0r7.js +0 -3
  86. package/dist/assets/SettingsWindow-DsMhdX5H.js +0 -1
  87. package/dist/assets/index-BZXqJcua.css +0 -1
  88. package/dist/assets/main-CmrF_CaW.js +0 -133
  89. package/dist/assets/renderElectronMiniChatApp-BhXZtZlU.js +0 -1
  90. package/dist/assets/renderMobileApp-DUSTAPWw.js +0 -23
  91. package/dist/assets/usePanelSlide-BRwyEEzi.js +0 -47
  92. package/server/lib/ngrok-tunnel.js +0 -343
  93. package/server/lib/ngrok-tunnel.test.js +0 -50
  94. package/server/lib/tunnels/providers/ngrok.js +0 -32
@@ -1,10 +1,10 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-capacitor-core-B4EWRrHz.js"])))=>i.map(i=>d[i]);
2
- import{m as E,d7 as T,d8 as j,az as se,d9 as ne,cV as ie,da as re,ae as k,b as Z,db as ae,dc as le,dd as P,de as ce,df as de}from"./SessionSwitcherDropdown-NbVfnqQQ.js";import{an as ue,l as B,r as U,o as ee,u as d,U as te,ao as ge,a as G,ap as fe,L as oe,i as x,b as me,K as $,R as pe,e as ye,aq as V,ak as he,ar as Se,al as we}from"./index-BhXma4dv.js";import{_ as be}from"./vendor-vite-runtime-DD1OZmLC.js";import{R as A}from"./vendor-react-DYyjh7Q0.js";const Me=[];function K(){return[...Me].reverse()}const De={getLastAssistantMessage(){if(!E.getState().currentSessionId)return console.log("[ERROR] No active session"),null;const t=P();if(!t||t.length===0)return console.log("[ERROR] No messages in current session"),null;for(let s=t.length-1;s>=0;s--){const n=t[s];if(n.role==="assistant"){const a=(T(n.id)||[]).map(u=>{const m={id:u.id,type:u.type};return u.type==="text"?(m.text=u.text,m.textLength=u.text?.length||0):u.type==="tool"?(m.tool=u.tool,m.state=u.state?.status):(u.type==="step-start"||u.type==="step-finish")&&(m.isStepMarker=!0),m}),g=a.some(u=>u.type==="text"&&u.text&&u.text.trim().length>0),r=a.some(u=>u.type==="tool"),l=a.some(u=>u.type==="step-start"||u.type==="step-finish"),h=a.length===0,p=!g&&!r&&(!h||l),f={messageId:n.id,role:n.role,timestamp:n.time?.created||0,partsCount:a.length,parts:a,isEmpty:h,isEmptyResponse:p,raw:n};return console.log("[INSPECT] Last Assistant Message:",f),console.log("[SUMMARY] Summary:",{messageId:f.messageId,partsCount:f.partsCount,isEmpty:f.isEmpty,isEmptyResponse:f.isEmptyResponse,hasText:g,hasTools:r,hasStepMarkers:l,onlyStepMarkers:l&&!g&&!r}),f.isEmpty&&console.warn("[WARNING] Message has NO parts!"),f.isEmptyResponse&&(console.warn("[WARNING] Message has parts but NO meaningful content (empty text, no tools)!"),l&&!g&&!r&&(console.warn("[CRITICAL] CLAUDE EMPTY RESPONSE BUG: Only step-start/step-finish markers, no actual content!"),console.log("This is a known issue with Claude models (anthropic provider)"),console.log("Recommendation: Send a follow-up message or try a different model"))),f}}return console.log("[ERROR] No assistant messages found in current session"),null},truncateString(e,o=80){return!e||typeof e!="string"||e.length<=o?e:e.substring(0,o)+"…"},truncateMessages(e){return e.map(o=>({...o,parts:(T(o.id)||[]).map(t=>{const s={...t};return"text"in t&&(s.text=this.truncateString(t.text)),"textPreview"in t&&(s.textPreview=this.truncateString(t.textPreview)),t.state&&(s.state={...t.state},"output"in t.state&&(s.state.output=this.truncateString(t.state.output)),"error"in t.state&&(s.state.error=this.truncateString(t.state.error)),t.state.metadata&&"preview"in t.state.metadata&&(s.state.metadata={...t.state.metadata,preview:this.truncateString(t.state.metadata.preview)})),s})}))},getAllMessages(e=!1){if(!E.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const s=P();return console.log(`[MESSAGES] Total messages in session: ${s.length}`),s.forEach((n,c)=>{const a=T(n.id)||[];console.log(`[${c}] ${n.role} - ${n.id} - ${a.length} parts`)}),e?this.truncateMessages(s):s},async getAppStatus(){const e=B.getState(),o=E.getState(),t=Z.getState(),s=e.currentDirectory||null,n=k.getDirectory()??null,c=ae(),a=new Set,g={};c.forEach(i=>{const y=i.directory;typeof y=="string"&&y.trim().length>0?(a.add(y),g[y]=(g[y]??0)+1):g["(none)"]=(g["(none)"]??0)+1});const r=(()=>{if(typeof window>"u")return{available:!1};try{return{available:!0,lastDirectory:window.localStorage.getItem("lastDirectory"),homeDirectory:window.localStorage.getItem("homeDirectory")}}catch(i){return{available:!1,error:i instanceof Error?i.message:String(i)}}})(),l=ee(),h=typeof window<"u"&&!!window.__PICHAMBER_ELECTRON__,p=async i=>{try{return await i.json()}catch{return null}},f=async i=>{try{return await i.text()}catch{return null}},u=async i=>{try{const y=await U(i);return y.ok?await p(y):{status:y.status}}catch(y){return{error:y instanceof Error?y.message:String(y)}}};let m=null,D=null,I=null,w=null;try{const i=await k.getSdkClient().path.get(s?{directory:s}:void 0);m=i.error?{error:i.error}:i.data}catch(i){m={error:i instanceof Error?i.message:String(i)}}try{const i=await k.getSdkClient().project.current(s?{directory:s}:void 0);D=i.error?{error:i.error}:i.data}catch(i){D={error:i instanceof Error?i.message:String(i)}}I=await u("/api/pi/ui-settings");try{const i=await U("/api/health"),y=i.headers.get("content-type")||"",L=await f(i),O=y.toLowerCase().includes("application/json");let M=null;if(O&&L)try{const R=JSON.parse(L);R&&typeof R=="object"&&!Array.isArray(R)&&(M=R)}catch{M=null}w={status:i.status,ok:i.ok,contentType:y,type:O?"json":"html",openCodePort:M?.openCodePort??null,openCodeRunning:M?.openCodeRunning??null,openCodeSecureConnection:M?.openCodeSecureConnection??null,openCodeAuthSource:M?.openCodeAuthSource??null,isOpenCodeReady:M?.isOpenCodeReady??null,lastOpenCodeError:M?.lastOpenCodeError??null,preview:L?L.slice(0,120):null}}catch(i){w={error:i instanceof Error?i.message:String(i)}}let b={isGitRepo:null};if(s)try{b.isGitRepo=await le(s)}catch(i){b={isGitRepo:null,error:i instanceof Error?i.message:String(i)}}const C=t.projects.map(i=>({id:i.id,path:i.path,label:i.label})),v={runtime:{platform:l?.runtime?.platform??null,isDesktop:h,hasRuntimeApis:!!l,desktopServerOrigin:null},location:typeof window<"u"?{href:window.location?.href??null,origin:window.location?.origin??null}:null,directories:{currentDirectory:s,opencodeDirectory:m?.directory||m?.worktree||n,homeDirectory:e.homeDirectory||null,isHomeReady:e.isHomeReady,hasPersistedDirectory:e.hasPersistedDirectory,isSwitchingDirectory:e.isSwitchingDirectory},projects:{total:t.projects.length,activeProjectId:t.activeProjectId,samples:C},sessions:{total:c.length,currentSessionId:o.currentSessionId,lastLoadedDirectory:o.lastLoadedDirectory,uniqueDirectories:a.size,directorySamples:Array.from(a).slice(0,5),directoryCounts:g},git:b,localStorage:r,opencode:{pathInfo:m,projectInfo:D,health:w},pichamber:{settingsInfo:I},recentSendFailures:K(),currentSessionDirectoryResolution:o.currentSessionId?this.diagnoseSessionDirectory(o.currentSessionId):null};return console.log("[DEBUG] App status snapshot:",v),v},getRecentSendFailures(){const e=K();return e.length===0?console.log("[OK] No prompt sends were rejected in this session."):(console.warn(`[ALERT] ${e.length} rejected prompt send(s):`),console.table(e)),e},diagnoseSessionDirectory(e){const o=E.getState(),t=e??o.currentSessionId;if(!t)return console.log("[ERROR] No session selected and no session id passed"),null;const s=ne(t),n=ie().find(p=>p.id===t),c=n?.directory??null,a=t===o.currentSessionId?o.currentSessionDirectory:null,r=re({session:n??null,currentDirectory:a}),l=o.getDirectoryForSession(t),h={sessionId:t,isCurrentSession:t===o.currentSessionId,routedDirectory:l,resolvedFrom:r.source,conflict:r.conflict,sources:ce(),details:{owningChildStore:s,sessionRecordDirectory:c,sessionIndexed:!!n,currentSessionDirectory:o.currentSessionDirectory,rememberedForRuntime:remembered.runtime,persistedAcrossRestarts:remembered.persisted,activeDirectory:B.getState().currentDirectory??null,opencodeClientDirectory:k.getDirectory()??null}};return console.log("[DEBUG] Session directory resolution:",h),r.conflict?console.warn(`[ALERT] Directory sources disagree: using "${r.directory}" (${r.source}) while "${r.conflict.directory}" came from ${r.conflict.source}.`):l?console.log("[OK] All known sources agree on the session directory."):console.warn("[ALERT] No directory resolved for this session — sends fall back to the active directory."),h},async buildDiagnosticsReport(){const e=await this.getAppStatus();return JSON.stringify(e,null,2)},async copyTextToClipboard(e){return se(e)},async copyDiagnosticsReport(){const e=await this.buildDiagnosticsReport();return{...await this.copyTextToClipboard(e),report:e}},checkLastMessage(){const e=this.getLastAssistantMessage();if(!e)return!1;const o=e.isEmpty||e.isEmptyResponse;return o?(console.error("[ALERT] PROBLEMATIC MESSAGE DETECTED!"),console.log("Details:",{messageId:e.messageId,isEmpty:e.isEmpty,isEmptyResponse:e.isEmptyResponse,partsCount:e.partsCount}),e.parts.length>0&&console.log("Parts:",e.parts)):console.log("[OK] Last message looks good!"),o},getStreamingState(){const e=E.getState(),o=j.getState(),t=e.currentSessionId?o.streamingMessageIds.get(e.currentSessionId)??null:null;return console.log("[STREAM] Streaming State:",{streamingMessageId:t,streamingMessageIds:Array.from(o.streamingMessageIds.entries()),messageStreamStates:Array.from(o.messageStreamStates.entries())}),{streamingMessageId:t,streamingMessageIds:o.streamingMessageIds,streamStates:o.messageStreamStates}},findEmptyMessages(){if(!E.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const s=P().filter(n=>n.role==="assistant").filter(n=>{const c=T(n.id)||[],a=c.some(r=>r.type==="text"&&r.text&&r.text.trim().length>0),g=c.some(r=>r.type==="tool");return c.length===0||!a&&!g});return console.log(`[INSPECT] Found ${s.length} empty assistant messages`),s.forEach((n,c)=>{const a=T(n.id)||[];console.log(`[${c}] Empty message:`,{messageId:n.id,partsCount:a.length,provider:n.providerID,model:n.modelID,timestamp:n.time?.created})}),s},showRetryHelp(){console.log(`[DEBUG] How to handle empty Claude responses:
2
+ import{h as E,d6 as T,d7 as j,av as se,d8 as ne,cU as ie,d9 as re,aa as k,b as Z,da as ae,db as le,dc as P,dd as ce,de}from"./SessionSwitcherDropdown-cFWgy1td.js";import{aq as ue,m as B,r as U,q as ee,u as d,W as te,a3 as ge,a as G,ar as fe,N as oe,i as x,b as me,M as $,T as pe,e as ye,as as V,an as he,at as Se,ao as we}from"./index-DEYblXCW.js";import{_ as be}from"./vendor-vite-runtime-DD1OZmLC.js";import{R as A}from"./vendor-react-DYyjh7Q0.js";const Me=[];function H(){return[...Me].reverse()}const De={getLastAssistantMessage(){if(!E.getState().currentSessionId)return console.log("[ERROR] No active session"),null;const t=P();if(!t||t.length===0)return console.log("[ERROR] No messages in current session"),null;for(let s=t.length-1;s>=0;s--){const n=t[s];if(n.role==="assistant"){const a=(T(n.id)||[]).map(u=>{const m={id:u.id,type:u.type};return u.type==="text"?(m.text=u.text,m.textLength=u.text?.length||0):u.type==="tool"?(m.tool=u.tool,m.state=u.state?.status):(u.type==="step-start"||u.type==="step-finish")&&(m.isStepMarker=!0),m}),g=a.some(u=>u.type==="text"&&u.text&&u.text.trim().length>0),r=a.some(u=>u.type==="tool"),l=a.some(u=>u.type==="step-start"||u.type==="step-finish"),h=a.length===0,p=!g&&!r&&(!h||l),f={messageId:n.id,role:n.role,timestamp:n.time?.created||0,partsCount:a.length,parts:a,isEmpty:h,isEmptyResponse:p,raw:n};return console.log("[INSPECT] Last Assistant Message:",f),console.log("[SUMMARY] Summary:",{messageId:f.messageId,partsCount:f.partsCount,isEmpty:f.isEmpty,isEmptyResponse:f.isEmptyResponse,hasText:g,hasTools:r,hasStepMarkers:l,onlyStepMarkers:l&&!g&&!r}),f.isEmpty&&console.warn("[WARNING] Message has NO parts!"),f.isEmptyResponse&&(console.warn("[WARNING] Message has parts but NO meaningful content (empty text, no tools)!"),l&&!g&&!r&&(console.warn("[CRITICAL] CLAUDE EMPTY RESPONSE BUG: Only step-start/step-finish markers, no actual content!"),console.log("This is a known issue with Claude models (anthropic provider)"),console.log("Recommendation: Send a follow-up message or try a different model"))),f}}return console.log("[ERROR] No assistant messages found in current session"),null},truncateString(e,o=80){return!e||typeof e!="string"||e.length<=o?e:e.substring(0,o)+"…"},truncateMessages(e){return e.map(o=>({...o,parts:(T(o.id)||[]).map(t=>{const s={...t};return"text"in t&&(s.text=this.truncateString(t.text)),"textPreview"in t&&(s.textPreview=this.truncateString(t.textPreview)),t.state&&(s.state={...t.state},"output"in t.state&&(s.state.output=this.truncateString(t.state.output)),"error"in t.state&&(s.state.error=this.truncateString(t.state.error)),t.state.metadata&&"preview"in t.state.metadata&&(s.state.metadata={...t.state.metadata,preview:this.truncateString(t.state.metadata.preview)})),s})}))},getAllMessages(e=!1){if(!E.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const s=P();return console.log(`[MESSAGES] Total messages in session: ${s.length}`),s.forEach((n,c)=>{const a=T(n.id)||[];console.log(`[${c}] ${n.role} - ${n.id} - ${a.length} parts`)}),e?this.truncateMessages(s):s},async getAppStatus(){const e=B.getState(),o=E.getState(),t=Z.getState(),s=e.currentDirectory||null,n=k.getDirectory()??null,c=ae(),a=new Set,g={};c.forEach(i=>{const y=i.directory;typeof y=="string"&&y.trim().length>0?(a.add(y),g[y]=(g[y]??0)+1):g["(none)"]=(g["(none)"]??0)+1});const r=(()=>{if(typeof window>"u")return{available:!1};try{return{available:!0,lastDirectory:window.localStorage.getItem("lastDirectory"),homeDirectory:window.localStorage.getItem("homeDirectory")}}catch(i){return{available:!1,error:i instanceof Error?i.message:String(i)}}})(),l=ee(),h=typeof window<"u"&&!!window.__PICHAMBER_ELECTRON__,p=async i=>{try{return await i.json()}catch{return null}},f=async i=>{try{return await i.text()}catch{return null}},u=async i=>{try{const y=await U(i);return y.ok?await p(y):{status:y.status}}catch(y){return{error:y instanceof Error?y.message:String(y)}}};let m=null,D=null,I=null,w=null;try{const i=await k.getSdkClient().path.get(s?{directory:s}:void 0);m=i.error?{error:i.error}:i.data}catch(i){m={error:i instanceof Error?i.message:String(i)}}try{const i=await k.getSdkClient().project.current(s?{directory:s}:void 0);D=i.error?{error:i.error}:i.data}catch(i){D={error:i instanceof Error?i.message:String(i)}}I=await u("/api/pi/ui-settings");try{const i=await U("/api/health"),y=i.headers.get("content-type")||"",L=await f(i),O=y.toLowerCase().includes("application/json");let M=null;if(O&&L)try{const R=JSON.parse(L);R&&typeof R=="object"&&!Array.isArray(R)&&(M=R)}catch{M=null}w={status:i.status,ok:i.ok,contentType:y,type:O?"json":"html",openCodePort:M?.openCodePort??null,openCodeRunning:M?.openCodeRunning??null,openCodeSecureConnection:M?.openCodeSecureConnection??null,openCodeAuthSource:M?.openCodeAuthSource??null,isOpenCodeReady:M?.isOpenCodeReady??null,lastOpenCodeError:M?.lastOpenCodeError??null,preview:L?L.slice(0,120):null}}catch(i){w={error:i instanceof Error?i.message:String(i)}}let b={isGitRepo:null};if(s)try{b.isGitRepo=await le(s)}catch(i){b={isGitRepo:null,error:i instanceof Error?i.message:String(i)}}const C=t.projects.map(i=>({id:i.id,path:i.path,label:i.label})),v={runtime:{platform:l?.runtime?.platform??null,isDesktop:h,hasRuntimeApis:!!l,desktopServerOrigin:null},location:typeof window<"u"?{href:window.location?.href??null,origin:window.location?.origin??null}:null,directories:{currentDirectory:s,opencodeDirectory:m?.directory||m?.worktree||n,homeDirectory:e.homeDirectory||null,isHomeReady:e.isHomeReady,hasPersistedDirectory:e.hasPersistedDirectory,isSwitchingDirectory:e.isSwitchingDirectory},projects:{total:t.projects.length,activeProjectId:t.activeProjectId,samples:C},sessions:{total:c.length,currentSessionId:o.currentSessionId,lastLoadedDirectory:o.lastLoadedDirectory,uniqueDirectories:a.size,directorySamples:Array.from(a).slice(0,5),directoryCounts:g},git:b,localStorage:r,opencode:{pathInfo:m,projectInfo:D,health:w},pichamber:{settingsInfo:I},recentSendFailures:H(),currentSessionDirectoryResolution:o.currentSessionId?this.diagnoseSessionDirectory(o.currentSessionId):null};return console.log("[DEBUG] App status snapshot:",v),v},getRecentSendFailures(){const e=H();return e.length===0?console.log("[OK] No prompt sends were rejected in this session."):(console.warn(`[ALERT] ${e.length} rejected prompt send(s):`),console.table(e)),e},diagnoseSessionDirectory(e){const o=E.getState(),t=e??o.currentSessionId;if(!t)return console.log("[ERROR] No session selected and no session id passed"),null;const s=ne(t),n=ie().find(p=>p.id===t),c=n?.directory??null,a=t===o.currentSessionId?o.currentSessionDirectory:null,r=re({session:n??null,currentDirectory:a}),l=o.getDirectoryForSession(t),h={sessionId:t,isCurrentSession:t===o.currentSessionId,routedDirectory:l,resolvedFrom:r.source,conflict:r.conflict,sources:ce(),details:{owningChildStore:s,sessionRecordDirectory:c,sessionIndexed:!!n,currentSessionDirectory:o.currentSessionDirectory,rememberedForRuntime:remembered.runtime,persistedAcrossRestarts:remembered.persisted,activeDirectory:B.getState().currentDirectory??null,opencodeClientDirectory:k.getDirectory()??null}};return console.log("[DEBUG] Session directory resolution:",h),r.conflict?console.warn(`[ALERT] Directory sources disagree: using "${r.directory}" (${r.source}) while "${r.conflict.directory}" came from ${r.conflict.source}.`):l?console.log("[OK] All known sources agree on the session directory."):console.warn("[ALERT] No directory resolved for this session — sends fall back to the active directory."),h},async buildDiagnosticsReport(){const e=await this.getAppStatus();return JSON.stringify(e,null,2)},async copyTextToClipboard(e){return se(e)},async copyDiagnosticsReport(){const e=await this.buildDiagnosticsReport();return{...await this.copyTextToClipboard(e),report:e}},checkLastMessage(){const e=this.getLastAssistantMessage();if(!e)return!1;const o=e.isEmpty||e.isEmptyResponse;return o?(console.error("[ALERT] PROBLEMATIC MESSAGE DETECTED!"),console.log("Details:",{messageId:e.messageId,isEmpty:e.isEmpty,isEmptyResponse:e.isEmptyResponse,partsCount:e.partsCount}),e.parts.length>0&&console.log("Parts:",e.parts)):console.log("[OK] Last message looks good!"),o},getStreamingState(){const e=E.getState(),o=j.getState(),t=e.currentSessionId?o.streamingMessageIds.get(e.currentSessionId)??null:null;return console.log("[STREAM] Streaming State:",{streamingMessageId:t,streamingMessageIds:Array.from(o.streamingMessageIds.entries()),messageStreamStates:Array.from(o.messageStreamStates.entries())}),{streamingMessageId:t,streamingMessageIds:o.streamingMessageIds,streamStates:o.messageStreamStates}},findEmptyMessages(){if(!E.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const s=P().filter(n=>n.role==="assistant").filter(n=>{const c=T(n.id)||[],a=c.some(r=>r.type==="text"&&r.text&&r.text.trim().length>0),g=c.some(r=>r.type==="tool");return c.length===0||!a&&!g});return console.log(`[INSPECT] Found ${s.length} empty assistant messages`),s.forEach((n,c)=>{const a=T(n.id)||[];console.log(`[${c}] Empty message:`,{messageId:n.id,partsCount:a.length,provider:n.providerID,model:n.modelID,timestamp:n.time?.created})}),s},showRetryHelp(){console.log(`[DEBUG] How to handle empty Claude responses:
3
3
  `),console.log("1. Check the last message:"),console.log(` __opencodeDebug.getLastAssistantMessage()
4
4
  `),console.log("2. Find all empty messages in session:"),console.log(` __opencodeDebug.findEmptyMessages()
5
5
  `),console.log("3. To retry, you can:"),console.log(" - Edit your last user message and resend"),console.log(' - Send a follow-up message like "Please provide the response"'),console.log(` - Try a different model (OpenAI models tend to be more reliable)
6
- `),console.log("[TIP] Empty responses are usually due to:"),console.log(" - Model rate limits"),console.log(" - Context length issues"),console.log(" - Model refusing to respond to certain prompts"),console.log(" - API errors from provider")},analyzeMessageCompletionConsistency(e={}){const{includeNonAssistant:o=!1,verbose:t=!0,maxTableRows:s=25}=e;if(!E.getState().currentSessionId)return console.log("[ERROR] No active session"),{summary:null,rows:[]};const a=P(),g=o?a:a.filter(f=>f.role==="assistant"),r={totalMessages:a.length,analyzedMessages:g.length,completedMissing:0,completedBeforeTool:0,completedBeforeReasoning:0,runningToolsWhenCompleted:0,reasoningOpenWhenCompleted:0,withTools:0,withReasoning:0},l=f=>typeof f=="number"&&Number.isFinite(f)?f:null,h=f=>{const u=f.filter(m=>typeof m=="number");return u.length>0?Math.max(...u):null},p=g.map((f,u)=>{const m=f,D=T(f.id)||[],I=m.time??{},w=l(I.completed),b=w!==null,C=D.filter(S=>S.type==="tool"),v=D.filter(S=>S.type==="reasoning"),i=h(C.map(S=>l(S.state?.time?.end??S.state?.time?.start))),y=h(v.map(S=>l(S.time?.end??S.time?.start))),L=h([i,y].filter(S=>S!==null)),O=C.some(S=>["pending","running","started"].includes(S.state?.status)),M=v.some(S=>typeof S.time?.end!="number");C.length>0&&(r.withTools+=1),v.length>0&&(r.withReasoning+=1),b||(r.completedMissing+=1);const R=!!(b&&typeof i=="number"&&w<i);R&&(r.completedBeforeTool+=1);const N=!!(b&&typeof y=="number"&&w<y);return N&&(r.completedBeforeReasoning+=1),b&&O&&(r.runningToolsWhenCompleted+=1),b&&M&&(r.reasoningOpenWhenCompleted+=1),{index:u,messageId:m.id,role:m.role,completedAt:w,latestToolTimestamp:i,latestReasoningTimestamp:y,latestPartTimestamp:L,completed_missing:!b,completed_before_tool:R,completed_before_reasoning:N,running_tools_when_completed:!!(b&&O),reasoning_open_when_completed:!!(b&&M),has_tools:C.length>0,has_reasoning:v.length>0}});return t&&(console.table(p.slice(0,s)),p.length>s&&console.log(`Displayed first ${s} rows out of ${p.length}.`),console.log("[SUMMARY] Message completion timing:",r)),{summary:r,rows:p}},checkCompletionStatus(){if(!E.getState().currentSessionId)return console.log("[ERROR] No active session"),null;const s=P().filter(w=>w.role==="assistant");if(s.length===0)return console.log("[ERROR] No assistant messages"),null;const n=s[s.length-1],a=(T(n.id)||[]).filter(w=>w.type==="step-finish"),g=n.finish==="stop",l=n.time?.completed,h=n.status,p=typeof l=="number"&&l>0||h==="completed",f=!!(p&&g),u=j.getState(),m=n.sessionID?u.streamingMessageIds.get(n.sessionID)??null:null,D=u.messageStreamStates.get(n.id),I=n.id===m;return console.log("[SUMMARY] Completion Status:"),console.log("Message ID:",n.id),console.log("time.completed:",l,"(type:",typeof l,")"),console.log("status:",h),console.log("hasCompletedFlag:",p),console.log("hasStopReason:",g),console.log("messageIsComplete:",f),console.log("lifecycle phase:",D?.phase),console.log("isStreamingCandidate:",I),console.log("streamingMessageId:",m),console.log("Step-finish parts:",a),{messageId:n.id,completed:l,status:h,hasCompletedFlag:p,hasStopReason:g,messageIsComplete:f,stepFinishParts:a,raw:n}}};typeof window<"u"&&(window.__opencodeDebug=De,ue()&&(console.log("[DEBUG] OpenCode Debug Utils loaded! Use window.__opencodeDebug in console"),console.log("Available commands:"),console.log(" __opencodeDebug.getLastAssistantMessage() - Get last assistant message details"),console.log(" __opencodeDebug.getAllMessages(truncate?) - List all messages (truncate=true for short preview)"),console.log(" __opencodeDebug.truncateMessages(messages) - Truncate long fields in messages array"),console.log(" __opencodeDebug.getAppStatus() - Show app status snapshot"),console.log(" __opencodeDebug.diagnoseSessionDirectory(sessionId?) - Show how the session directory is resolved"),console.log(" __opencodeDebug.getRecentSendFailures() - List prompt sends that were rejected and rolled back"),console.log(" __opencodeDebug.checkLastMessage() - Check if last message is problematic"),console.log(" __opencodeDebug.findEmptyMessages() - Find all empty assistant messages"),console.log(" __opencodeDebug.showRetryHelp() - Show instructions for handling empty responses"),console.log(" __opencodeDebug.getStreamingState() - Get streaming state info"),console.log(" __opencodeDebug.analyzeMessageCompletionConsistency(opts?) - Compare time.completed vs part timings"),console.log(" __opencodeDebug.checkCompletionStatus() - Check completion status of last message")),window.addEventListener("error",e=>{try{const o=e.message||"",t=e.filename||"";typeof o=="string"&&o.includes("this._renderer.value.dimensions")&&/xterm/i.test(String(t))&&e.preventDefault()}catch{}}));let H=!1;const ke=()=>{if(H||typeof window>"u")return;H=!0;let e={showReasoningTraces:d.getState().showReasoningTraces,collapsibleThinkingBlocks:d.getState().collapsibleThinkingBlocks,collapseThinkingByDefault:d.getState().collapseThinkingByDefault,showDeletionDialog:d.getState().showDeletionDialog,nativeNotificationsEnabled:d.getState().nativeNotificationsEnabled,notificationMode:d.getState().notificationMode,notifyOnSubtasks:d.getState().notifyOnSubtasks,notifyOnCompletion:d.getState().notifyOnCompletion,notifyOnError:d.getState().notifyOnError,notifyOnQuestion:d.getState().notifyOnQuestion,notificationTemplates:d.getState().notificationTemplates,summarizeLastMessage:d.getState().summarizeLastMessage,summaryThreshold:d.getState().summaryThreshold,summaryLength:d.getState().summaryLength,maxLastMessageLength:d.getState().maxLastMessageLength,autoDeleteEnabled:d.getState().autoDeleteEnabled,autoSaveEnabled:d.getState().autoSaveEnabled,autoDeleteAfterDays:d.getState().autoDeleteAfterDays,sessionRetentionAction:d.getState().sessionRetentionAction,fontSize:d.getState().fontSize,terminalFontSize:d.getState().terminalFontSize,terminalShell:d.getState().terminalShell,terminalLoginShells:d.getState().terminalLoginShells,editorFontSize:d.getState().editorFontSize,uiFont:d.getState().uiFont,monoFont:d.getState().monoFont,padding:d.getState().padding,cornerRadius:d.getState().cornerRadius,inputBarOffset:d.getState().inputBarOffset,mobileKeyboardMode:d.getState().mobileKeyboardMode,diffLayoutPreference:d.getState().diffLayoutPreference,gitChangesViewMode:d.getState().gitChangesViewMode};d.subscribe(o=>{const t={showReasoningTraces:o.showReasoningTraces,collapsibleThinkingBlocks:o.collapsibleThinkingBlocks,collapseThinkingByDefault:o.collapseThinkingByDefault,showDeletionDialog:o.showDeletionDialog,nativeNotificationsEnabled:o.nativeNotificationsEnabled,notificationMode:o.notificationMode,notifyOnSubtasks:o.notifyOnSubtasks,notifyOnCompletion:o.notifyOnCompletion,notifyOnError:o.notifyOnError,notifyOnQuestion:o.notifyOnQuestion,notificationTemplates:o.notificationTemplates,summarizeLastMessage:o.summarizeLastMessage,summaryThreshold:o.summaryThreshold,summaryLength:o.summaryLength,maxLastMessageLength:o.maxLastMessageLength,autoDeleteEnabled:o.autoDeleteEnabled,autoSaveEnabled:o.autoSaveEnabled,autoDeleteAfterDays:o.autoDeleteAfterDays,sessionRetentionAction:o.sessionRetentionAction,fontSize:o.fontSize,terminalFontSize:o.terminalFontSize,terminalShell:o.terminalShell,terminalLoginShells:o.terminalLoginShells,editorFontSize:o.editorFontSize,uiFont:o.uiFont,monoFont:o.monoFont,padding:o.padding,cornerRadius:o.cornerRadius,inputBarOffset:o.inputBarOffset,mobileKeyboardMode:o.mobileKeyboardMode,diffLayoutPreference:o.diffLayoutPreference,gitChangesViewMode:o.gitChangesViewMode},s={};t.showReasoningTraces!==e.showReasoningTraces&&(s.showReasoningTraces=t.showReasoningTraces),t.collapsibleThinkingBlocks!==e.collapsibleThinkingBlocks&&(s.collapsibleThinkingBlocks=t.collapsibleThinkingBlocks),t.collapseThinkingByDefault!==e.collapseThinkingByDefault&&(s.collapseThinkingByDefault=t.collapseThinkingByDefault),t.showDeletionDialog!==e.showDeletionDialog&&(s.showDeletionDialog=t.showDeletionDialog),t.nativeNotificationsEnabled!==e.nativeNotificationsEnabled&&(s.nativeNotificationsEnabled=t.nativeNotificationsEnabled),t.notificationMode!==e.notificationMode&&(s.notificationMode=t.notificationMode),t.notifyOnSubtasks!==e.notifyOnSubtasks&&(s.notifyOnSubtasks=t.notifyOnSubtasks),t.notifyOnCompletion!==e.notifyOnCompletion&&(s.notifyOnCompletion=t.notifyOnCompletion),t.notifyOnError!==e.notifyOnError&&(s.notifyOnError=t.notifyOnError),t.notifyOnQuestion!==e.notifyOnQuestion&&(s.notifyOnQuestion=t.notifyOnQuestion),JSON.stringify(t.notificationTemplates)!==JSON.stringify(e.notificationTemplates)&&(s.notificationTemplates=t.notificationTemplates),t.summarizeLastMessage!==e.summarizeLastMessage&&(s.summarizeLastMessage=t.summarizeLastMessage),t.summaryThreshold!==e.summaryThreshold&&(s.summaryThreshold=t.summaryThreshold),t.summaryLength!==e.summaryLength&&(s.summaryLength=t.summaryLength),t.maxLastMessageLength!==e.maxLastMessageLength&&(s.maxLastMessageLength=t.maxLastMessageLength),t.autoDeleteEnabled!==e.autoDeleteEnabled&&(s.autoDeleteEnabled=t.autoDeleteEnabled),t.autoSaveEnabled!==e.autoSaveEnabled&&(s.autoSaveEnabled=t.autoSaveEnabled),t.autoDeleteAfterDays!==e.autoDeleteAfterDays&&(s.autoDeleteAfterDays=t.autoDeleteAfterDays),t.sessionRetentionAction!==e.sessionRetentionAction&&(s.sessionRetentionAction=t.sessionRetentionAction),t.fontSize!==e.fontSize&&(s.fontSize=t.fontSize),t.terminalFontSize!==e.terminalFontSize&&(s.terminalFontSize=t.terminalFontSize),t.terminalShell!==e.terminalShell&&(s.terminalShell=t.terminalShell),t.terminalLoginShells!==e.terminalLoginShells&&(s.terminalLoginShells=t.terminalLoginShells),t.editorFontSize!==e.editorFontSize&&(s.editorFontSize=t.editorFontSize),t.uiFont!==e.uiFont&&(s.uiFont=t.uiFont),t.monoFont!==e.monoFont&&(s.monoFont=t.monoFont),t.padding!==e.padding&&(s.padding=t.padding),t.cornerRadius!==e.cornerRadius&&(s.cornerRadius=t.cornerRadius),t.inputBarOffset!==e.inputBarOffset&&(s.inputBarOffset=t.inputBarOffset),t.mobileKeyboardMode!==e.mobileKeyboardMode&&(s.mobileKeyboardMode=t.mobileKeyboardMode),t.diffLayoutPreference!==e.diffLayoutPreference&&(s.diffLayoutPreference=t.diffLayoutPreference),t.gitChangesViewMode!==e.gitChangesViewMode&&(s.gitChangesViewMode=t.gitChangesViewMode),e=t,Object.keys(s).length>0&&te(s)})},Fe=async()=>{if(typeof window>"u")return;let e=null;try{e=window.localStorage.getItem("lastDirectory")}catch(o){console.warn("Failed to read saved directory preferences:",o)}e&&B.getState().setDirectory(e,{showOverlay:!1})},F=(e,o)=>{if(e===o)return!0;if(e.length!==o.length)return!1;for(let t=0;t<e.length;t+=1)if(e[t]?.providerID!==o[t]?.providerID||e[t]?.modelID!==o[t]?.modelID)return!1;return!0},z=(e,o)=>{if(e===o)return!0;if(e.length!==o.length)return!1;for(let t=0;t<e.length;t+=1)if(e[t]!==o[t])return!1;return!0},Ee=(e,o)=>{if(e===o)return!0;const t=Object.keys(e);return t.length!==Object.keys(o).length?!1:t.every(s=>Array.isArray(o[s])&&z(e[s],o[s]))},ve=()=>{const e=d.getState();return{favoriteModels:e.favoriteModels,hiddenModels:e.hiddenModels,collapsedModelProviders:e.collapsedModelProviders,recentModels:e.recentModels,recentAgents:e.recentAgents,recentEfforts:e.recentEfforts}},W=(e,o)=>F(e.favoriteModels,o.favoriteModels)&&F(e.hiddenModels,o.hiddenModels)&&z(e.collapsedModelProviders,o.collapsedModelProviders)&&F(e.recentModels,o.recentModels)&&z(e.recentAgents,o.recentAgents)&&Ee(e.recentEfforts,o.recentEfforts),Re=e=>({favoriteModels:e.favoriteModels.slice(),hiddenModels:e.hiddenModels.slice(),collapsedModelProviders:e.collapsedModelProviders.slice(),recentModels:e.recentModels.slice(),recentAgents:e.recentAgents.slice(),recentEfforts:Object.fromEntries(Object.entries(e.recentEfforts).map(([o,t])=>[o,t.slice()]))}),Be=()=>{if(typeof window>"u")return()=>{};let e=null,o=null,t=!1,s=null;const n=()=>{e=null;const r=s;if(s=null,!r||r!==G())return;const l=ve();o&&W(o,l)||(o=Re(l),te(l).catch(()=>{}))},c=()=>{if(!t){t=!0;return}e!==null&&window.clearTimeout(e),s=G(),e=window.setTimeout(n,1200)},a=ge(()=>{e!==null&&window.clearTimeout(e),e=null,s=null,o=null}),g=d.subscribe((r,l)=>{const h={favoriteModels:r.favoriteModels,hiddenModels:r.hiddenModels,collapsedModelProviders:r.collapsedModelProviders,recentModels:r.recentModels,recentAgents:r.recentAgents,recentEfforts:r.recentEfforts},p={favoriteModels:l.favoriteModels,hiddenModels:l.hiddenModels,collapsedModelProviders:l.collapsedModelProviders,recentModels:l.recentModels,recentAgents:l.recentAgents,recentEfforts:l.recentEfforts};W(h,p)||c()});return()=>{g(),a(),e!==null&&window.clearTimeout(e)}};let Y=!1;const Q="pichamber-typography-base",Te=()=>{if(typeof document>"u")return;const o=`:root {
6
+ `),console.log("[TIP] Empty responses are usually due to:"),console.log(" - Model rate limits"),console.log(" - Context length issues"),console.log(" - Model refusing to respond to certain prompts"),console.log(" - API errors from provider")},analyzeMessageCompletionConsistency(e={}){const{includeNonAssistant:o=!1,verbose:t=!0,maxTableRows:s=25}=e;if(!E.getState().currentSessionId)return console.log("[ERROR] No active session"),{summary:null,rows:[]};const a=P(),g=o?a:a.filter(f=>f.role==="assistant"),r={totalMessages:a.length,analyzedMessages:g.length,completedMissing:0,completedBeforeTool:0,completedBeforeReasoning:0,runningToolsWhenCompleted:0,reasoningOpenWhenCompleted:0,withTools:0,withReasoning:0},l=f=>typeof f=="number"&&Number.isFinite(f)?f:null,h=f=>{const u=f.filter(m=>typeof m=="number");return u.length>0?Math.max(...u):null},p=g.map((f,u)=>{const m=f,D=T(f.id)||[],I=m.time??{},w=l(I.completed),b=w!==null,C=D.filter(S=>S.type==="tool"),v=D.filter(S=>S.type==="reasoning"),i=h(C.map(S=>l(S.state?.time?.end??S.state?.time?.start))),y=h(v.map(S=>l(S.time?.end??S.time?.start))),L=h([i,y].filter(S=>S!==null)),O=C.some(S=>["pending","running","started"].includes(S.state?.status)),M=v.some(S=>typeof S.time?.end!="number");C.length>0&&(r.withTools+=1),v.length>0&&(r.withReasoning+=1),b||(r.completedMissing+=1);const R=!!(b&&typeof i=="number"&&w<i);R&&(r.completedBeforeTool+=1);const z=!!(b&&typeof y=="number"&&w<y);return z&&(r.completedBeforeReasoning+=1),b&&O&&(r.runningToolsWhenCompleted+=1),b&&M&&(r.reasoningOpenWhenCompleted+=1),{index:u,messageId:m.id,role:m.role,completedAt:w,latestToolTimestamp:i,latestReasoningTimestamp:y,latestPartTimestamp:L,completed_missing:!b,completed_before_tool:R,completed_before_reasoning:z,running_tools_when_completed:!!(b&&O),reasoning_open_when_completed:!!(b&&M),has_tools:C.length>0,has_reasoning:v.length>0}});return t&&(console.table(p.slice(0,s)),p.length>s&&console.log(`Displayed first ${s} rows out of ${p.length}.`),console.log("[SUMMARY] Message completion timing:",r)),{summary:r,rows:p}},checkCompletionStatus(){if(!E.getState().currentSessionId)return console.log("[ERROR] No active session"),null;const s=P().filter(w=>w.role==="assistant");if(s.length===0)return console.log("[ERROR] No assistant messages"),null;const n=s[s.length-1],a=(T(n.id)||[]).filter(w=>w.type==="step-finish"),g=n.finish==="stop",l=n.time?.completed,h=n.status,p=typeof l=="number"&&l>0||h==="completed",f=!!(p&&g),u=j.getState(),m=n.sessionID?u.streamingMessageIds.get(n.sessionID)??null:null,D=u.messageStreamStates.get(n.id),I=n.id===m;return console.log("[SUMMARY] Completion Status:"),console.log("Message ID:",n.id),console.log("time.completed:",l,"(type:",typeof l,")"),console.log("status:",h),console.log("hasCompletedFlag:",p),console.log("hasStopReason:",g),console.log("messageIsComplete:",f),console.log("lifecycle phase:",D?.phase),console.log("isStreamingCandidate:",I),console.log("streamingMessageId:",m),console.log("Step-finish parts:",a),{messageId:n.id,completed:l,status:h,hasCompletedFlag:p,hasStopReason:g,messageIsComplete:f,stepFinishParts:a,raw:n}}};typeof window<"u"&&(window.__opencodeDebug=De,ue()&&(console.log("[DEBUG] OpenCode Debug Utils loaded! Use window.__opencodeDebug in console"),console.log("Available commands:"),console.log(" __opencodeDebug.getLastAssistantMessage() - Get last assistant message details"),console.log(" __opencodeDebug.getAllMessages(truncate?) - List all messages (truncate=true for short preview)"),console.log(" __opencodeDebug.truncateMessages(messages) - Truncate long fields in messages array"),console.log(" __opencodeDebug.getAppStatus() - Show app status snapshot"),console.log(" __opencodeDebug.diagnoseSessionDirectory(sessionId?) - Show how the session directory is resolved"),console.log(" __opencodeDebug.getRecentSendFailures() - List prompt sends that were rejected and rolled back"),console.log(" __opencodeDebug.checkLastMessage() - Check if last message is problematic"),console.log(" __opencodeDebug.findEmptyMessages() - Find all empty assistant messages"),console.log(" __opencodeDebug.showRetryHelp() - Show instructions for handling empty responses"),console.log(" __opencodeDebug.getStreamingState() - Get streaming state info"),console.log(" __opencodeDebug.analyzeMessageCompletionConsistency(opts?) - Compare time.completed vs part timings"),console.log(" __opencodeDebug.checkCompletionStatus() - Check completion status of last message")),window.addEventListener("error",e=>{try{const o=e.message||"",t=e.filename||"";typeof o=="string"&&o.includes("this._renderer.value.dimensions")&&/xterm/i.test(String(t))&&e.preventDefault()}catch{}}));let K=!1;const ke=()=>{if(K||typeof window>"u")return;K=!0;let e={showReasoningTraces:d.getState().showReasoningTraces,collapsibleThinkingBlocks:d.getState().collapsibleThinkingBlocks,collapseThinkingByDefault:d.getState().collapseThinkingByDefault,showDeletionDialog:d.getState().showDeletionDialog,nativeNotificationsEnabled:d.getState().nativeNotificationsEnabled,notificationMode:d.getState().notificationMode,notifyOnSubtasks:d.getState().notifyOnSubtasks,notifyOnCompletion:d.getState().notifyOnCompletion,notifyOnError:d.getState().notifyOnError,notifyOnQuestion:d.getState().notifyOnQuestion,notificationTemplates:d.getState().notificationTemplates,summarizeLastMessage:d.getState().summarizeLastMessage,summaryThreshold:d.getState().summaryThreshold,summaryLength:d.getState().summaryLength,maxLastMessageLength:d.getState().maxLastMessageLength,autoDeleteEnabled:d.getState().autoDeleteEnabled,autoSaveEnabled:d.getState().autoSaveEnabled,autoDeleteAfterDays:d.getState().autoDeleteAfterDays,sessionRetentionAction:d.getState().sessionRetentionAction,fontSize:d.getState().fontSize,terminalFontSize:d.getState().terminalFontSize,terminalShell:d.getState().terminalShell,terminalLoginShells:d.getState().terminalLoginShells,editorFontSize:d.getState().editorFontSize,uiFont:d.getState().uiFont,monoFont:d.getState().monoFont,padding:d.getState().padding,cornerRadius:d.getState().cornerRadius,inputBarOffset:d.getState().inputBarOffset,mobileKeyboardMode:d.getState().mobileKeyboardMode,diffLayoutPreference:d.getState().diffLayoutPreference,gitChangesViewMode:d.getState().gitChangesViewMode};d.subscribe(o=>{const t={showReasoningTraces:o.showReasoningTraces,collapsibleThinkingBlocks:o.collapsibleThinkingBlocks,collapseThinkingByDefault:o.collapseThinkingByDefault,showDeletionDialog:o.showDeletionDialog,nativeNotificationsEnabled:o.nativeNotificationsEnabled,notificationMode:o.notificationMode,notifyOnSubtasks:o.notifyOnSubtasks,notifyOnCompletion:o.notifyOnCompletion,notifyOnError:o.notifyOnError,notifyOnQuestion:o.notifyOnQuestion,notificationTemplates:o.notificationTemplates,summarizeLastMessage:o.summarizeLastMessage,summaryThreshold:o.summaryThreshold,summaryLength:o.summaryLength,maxLastMessageLength:o.maxLastMessageLength,autoDeleteEnabled:o.autoDeleteEnabled,autoSaveEnabled:o.autoSaveEnabled,autoDeleteAfterDays:o.autoDeleteAfterDays,sessionRetentionAction:o.sessionRetentionAction,fontSize:o.fontSize,terminalFontSize:o.terminalFontSize,terminalShell:o.terminalShell,terminalLoginShells:o.terminalLoginShells,editorFontSize:o.editorFontSize,uiFont:o.uiFont,monoFont:o.monoFont,padding:o.padding,cornerRadius:o.cornerRadius,inputBarOffset:o.inputBarOffset,mobileKeyboardMode:o.mobileKeyboardMode,diffLayoutPreference:o.diffLayoutPreference,gitChangesViewMode:o.gitChangesViewMode},s={};t.showReasoningTraces!==e.showReasoningTraces&&(s.showReasoningTraces=t.showReasoningTraces),t.collapsibleThinkingBlocks!==e.collapsibleThinkingBlocks&&(s.collapsibleThinkingBlocks=t.collapsibleThinkingBlocks),t.collapseThinkingByDefault!==e.collapseThinkingByDefault&&(s.collapseThinkingByDefault=t.collapseThinkingByDefault),t.showDeletionDialog!==e.showDeletionDialog&&(s.showDeletionDialog=t.showDeletionDialog),t.nativeNotificationsEnabled!==e.nativeNotificationsEnabled&&(s.nativeNotificationsEnabled=t.nativeNotificationsEnabled),t.notificationMode!==e.notificationMode&&(s.notificationMode=t.notificationMode),t.notifyOnSubtasks!==e.notifyOnSubtasks&&(s.notifyOnSubtasks=t.notifyOnSubtasks),t.notifyOnCompletion!==e.notifyOnCompletion&&(s.notifyOnCompletion=t.notifyOnCompletion),t.notifyOnError!==e.notifyOnError&&(s.notifyOnError=t.notifyOnError),t.notifyOnQuestion!==e.notifyOnQuestion&&(s.notifyOnQuestion=t.notifyOnQuestion),JSON.stringify(t.notificationTemplates)!==JSON.stringify(e.notificationTemplates)&&(s.notificationTemplates=t.notificationTemplates),t.summarizeLastMessage!==e.summarizeLastMessage&&(s.summarizeLastMessage=t.summarizeLastMessage),t.summaryThreshold!==e.summaryThreshold&&(s.summaryThreshold=t.summaryThreshold),t.summaryLength!==e.summaryLength&&(s.summaryLength=t.summaryLength),t.maxLastMessageLength!==e.maxLastMessageLength&&(s.maxLastMessageLength=t.maxLastMessageLength),t.autoDeleteEnabled!==e.autoDeleteEnabled&&(s.autoDeleteEnabled=t.autoDeleteEnabled),t.autoSaveEnabled!==e.autoSaveEnabled&&(s.autoSaveEnabled=t.autoSaveEnabled),t.autoDeleteAfterDays!==e.autoDeleteAfterDays&&(s.autoDeleteAfterDays=t.autoDeleteAfterDays),t.sessionRetentionAction!==e.sessionRetentionAction&&(s.sessionRetentionAction=t.sessionRetentionAction),t.fontSize!==e.fontSize&&(s.fontSize=t.fontSize),t.terminalFontSize!==e.terminalFontSize&&(s.terminalFontSize=t.terminalFontSize),t.terminalShell!==e.terminalShell&&(s.terminalShell=t.terminalShell),t.terminalLoginShells!==e.terminalLoginShells&&(s.terminalLoginShells=t.terminalLoginShells),t.editorFontSize!==e.editorFontSize&&(s.editorFontSize=t.editorFontSize),t.uiFont!==e.uiFont&&(s.uiFont=t.uiFont),t.monoFont!==e.monoFont&&(s.monoFont=t.monoFont),t.padding!==e.padding&&(s.padding=t.padding),t.cornerRadius!==e.cornerRadius&&(s.cornerRadius=t.cornerRadius),t.inputBarOffset!==e.inputBarOffset&&(s.inputBarOffset=t.inputBarOffset),t.mobileKeyboardMode!==e.mobileKeyboardMode&&(s.mobileKeyboardMode=t.mobileKeyboardMode),t.diffLayoutPreference!==e.diffLayoutPreference&&(s.diffLayoutPreference=t.diffLayoutPreference),t.gitChangesViewMode!==e.gitChangesViewMode&&(s.gitChangesViewMode=t.gitChangesViewMode),e=t,Object.keys(s).length>0&&te(s)})},Fe=async()=>{if(typeof window>"u")return;let e=null;try{e=window.localStorage.getItem("lastDirectory")}catch(o){console.warn("Failed to read saved directory preferences:",o)}e&&B.getState().setDirectory(e,{showOverlay:!1})},F=(e,o)=>{if(e===o)return!0;if(e.length!==o.length)return!1;for(let t=0;t<e.length;t+=1)if(e[t]?.providerID!==o[t]?.providerID||e[t]?.modelID!==o[t]?.modelID)return!1;return!0},N=(e,o)=>{if(e===o)return!0;if(e.length!==o.length)return!1;for(let t=0;t<e.length;t+=1)if(e[t]!==o[t])return!1;return!0},Ee=(e,o)=>{if(e===o)return!0;const t=Object.keys(e);return t.length!==Object.keys(o).length?!1:t.every(s=>Array.isArray(o[s])&&N(e[s],o[s]))},ve=()=>{const e=d.getState();return{favoriteModels:e.favoriteModels,hiddenModels:e.hiddenModels,collapsedModelProviders:e.collapsedModelProviders,recentModels:e.recentModels,recentAgents:e.recentAgents,recentEfforts:e.recentEfforts}},W=(e,o)=>F(e.favoriteModels,o.favoriteModels)&&F(e.hiddenModels,o.hiddenModels)&&N(e.collapsedModelProviders,o.collapsedModelProviders)&&F(e.recentModels,o.recentModels)&&N(e.recentAgents,o.recentAgents)&&Ee(e.recentEfforts,o.recentEfforts),Re=e=>({favoriteModels:e.favoriteModels.slice(),hiddenModels:e.hiddenModels.slice(),collapsedModelProviders:e.collapsedModelProviders.slice(),recentModels:e.recentModels.slice(),recentAgents:e.recentAgents.slice(),recentEfforts:Object.fromEntries(Object.entries(e.recentEfforts).map(([o,t])=>[o,t.slice()]))}),Be=()=>{if(typeof window>"u")return()=>{};let e=null,o=null,t=!1,s=null;const n=()=>{e=null;const r=s;if(s=null,!r||r!==G())return;const l=ve();o&&W(o,l)||(o=Re(l),te(l).catch(()=>{}))},c=()=>{if(!t){t=!0;return}e!==null&&window.clearTimeout(e),s=G(),e=window.setTimeout(n,1200)},a=ge(()=>{e!==null&&window.clearTimeout(e),e=null,s=null,o=null}),g=d.subscribe((r,l)=>{const h={favoriteModels:r.favoriteModels,hiddenModels:r.hiddenModels,collapsedModelProviders:r.collapsedModelProviders,recentModels:r.recentModels,recentAgents:r.recentAgents,recentEfforts:r.recentEfforts},p={favoriteModels:l.favoriteModels,hiddenModels:l.hiddenModels,collapsedModelProviders:l.collapsedModelProviders,recentModels:l.recentModels,recentAgents:l.recentAgents,recentEfforts:l.recentEfforts};W(h,p)||c()});return()=>{g(),a(),e!==null&&window.clearTimeout(e)}};let Y=!1;const Q="pichamber-typography-base",Te=()=>{if(typeof document>"u")return;const o=`:root {
7
7
  ${Object.entries(fe).map(([n,c])=>` --text-${n.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${c};`).join(`
8
8
  `)}
9
9
  }
10
- `,t=document.getElementById(Q);if(t){t.textContent=o;return}const s=document.createElement("style");s.id=Q,s.textContent=o,document.head.appendChild(s)},xe=()=>{Y||typeof window>"u"||(Y=!0,Te())},J=2e4,q=()=>typeof document>"u"||document.visibilityState==="visible"&&document.hasFocus()?"visible":"hidden",_=e=>{if(!oe()&&!x())return;const o=ee();o?.push?.setVisibility&&o.push.setVisibility({visible:e,platform:me()})},ze=e=>{const o=e?.enabled??!0;A.useEffect(()=>{if(!o||!oe()&&!x()||typeof window>"u")return;if(x()){let a=!0,g=!1,r=null;const l=()=>_(a);be(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([0,1,2])).then(async({App:p})=>{if(g)return;const f=await p.getState().catch(()=>null);f&&(a=f.isActive===!0),l();const u=await p.addListener("appStateChange",({isActive:m})=>{a=m===!0,l()});if(g){u.remove();return}r=()=>{u.remove()}}).catch(()=>{});const h=window.setInterval(()=>{a&&_(!0)},J);return()=>{g=!0,window.clearInterval(h),r?.()}}if(typeof document>"u")return;const t=()=>{_(q()==="visible")},s=()=>{q()==="visible"&&_(!0)},n=()=>{_(!1)};t();const c=window.setInterval(s,J);return document.addEventListener("visibilitychange",t),window.addEventListener("pagehide",n),window.addEventListener("pageshow",t),window.addEventListener("focus",t),window.addEventListener("blur",t),()=>{window.clearInterval(c),document.removeEventListener("visibilitychange",t),window.removeEventListener("pagehide",n),window.removeEventListener("pageshow",t),window.removeEventListener("focus",t),window.removeEventListener("blur",t)}},[o])},Ie="PiChamber",X=e=>e.replace(/[-_]/g," ").replace(/\b\w/g,o=>o.toUpperCase()),Ce=e=>{const t=e.replace(/\\/g,"/").replace(/\/+$/,"").split("/").filter(Boolean);return t[t.length-1]??""},Le=(e,o)=>[e,o,Ie].filter(s=>typeof s=="string"&&s.trim().length>0).join(" | "),Ne=()=>{const e=Z(c=>c.activeProjectId?c.projects.find(a=>a.id===c.activeProjectId)??null:null),o=A.useMemo(()=>{if(!e)return null;const c=e.label?.trim();if(c)return X(c);const a=Ce(e.path);return a?X(a):null},[e]),[t,s]=A.useState(null);A.useEffect(()=>{if(typeof window>"u"||!$()){s(null);return}let c=!1;const a=async()=>{try{if(pe()){c||s(null);return}const r=window.__PICHAMBER_LOCAL_ORIGIN__||window.location.origin,l=ye();if(l&&V(l,r)){c||s(null);return}const p=(await he()).hosts.find(u=>l?V(l,Se(u)):!1),f=p?.label?.trim()?we(p.label.trim()):"Instance";c||s(f)}catch{c||s("Instance")}};a();const g=()=>{a()};return window.addEventListener("focus",g),()=>{c=!0,window.removeEventListener("focus",g)}},[]);const n=A.useMemo(()=>Le(o,t),[o,t]);A.useEffect(()=>{if(typeof document<"u"&&(document.title=n),!$())return;(async()=>{try{if(typeof navigator<"u"&&/Macintosh|Mac OS X/.test(navigator.userAgent||""))return;await de(n)}catch{return}})()},[n])};export{Ne as a,Fe as b,Be as c,xe as d,ke as s,ze as u};
10
+ `,t=document.getElementById(Q);if(t){t.textContent=o;return}const s=document.createElement("style");s.id=Q,s.textContent=o,document.head.appendChild(s)},xe=()=>{Y||typeof window>"u"||(Y=!0,Te())},q=2e4,J=()=>typeof document>"u"||document.visibilityState==="visible"&&document.hasFocus()?"visible":"hidden",_=e=>{if(!oe()&&!x())return;const o=ee();o?.push?.setVisibility&&o.push.setVisibility({visible:e,platform:me()})},Ne=e=>{const o=e?.enabled??!0;A.useEffect(()=>{if(!o||!oe()&&!x()||typeof window>"u")return;if(x()){let a=!0,g=!1,r=null;const l=()=>_(a);be(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([0,1,2])).then(async({App:p})=>{if(g)return;const f=await p.getState().catch(()=>null);f&&(a=f.isActive===!0),l();const u=await p.addListener("appStateChange",({isActive:m})=>{a=m===!0,l()});if(g){u.remove();return}r=()=>{u.remove()}}).catch(()=>{});const h=window.setInterval(()=>{a&&_(!0)},q);return()=>{g=!0,window.clearInterval(h),r?.()}}if(typeof document>"u")return;const t=()=>{_(J()==="visible")},s=()=>{J()==="visible"&&_(!0)},n=()=>{_(!1)};t();const c=window.setInterval(s,q);return document.addEventListener("visibilitychange",t),window.addEventListener("pagehide",n),window.addEventListener("pageshow",t),window.addEventListener("focus",t),window.addEventListener("blur",t),()=>{window.clearInterval(c),document.removeEventListener("visibilitychange",t),window.removeEventListener("pagehide",n),window.removeEventListener("pageshow",t),window.removeEventListener("focus",t),window.removeEventListener("blur",t)}},[o])},Ie="PiChamber",X=e=>e.replace(/[-_]/g," ").replace(/\b\w/g,o=>o.toUpperCase()),Ce=e=>{const t=e.replace(/\\/g,"/").replace(/\/+$/,"").split("/").filter(Boolean);return t[t.length-1]??""},Le=(e,o)=>[e,o,Ie].filter(s=>typeof s=="string"&&s.trim().length>0).join(" | "),ze=()=>{const e=Z(c=>c.activeProjectId?c.projects.find(a=>a.id===c.activeProjectId)??null:null),o=A.useMemo(()=>{if(!e)return null;const c=e.label?.trim();if(c)return X(c);const a=Ce(e.path);return a?X(a):null},[e]),[t,s]=A.useState(null);A.useEffect(()=>{if(typeof window>"u"||!$()){s(null);return}let c=!1;const a=async()=>{try{if(pe()){c||s(null);return}const r=window.__PICHAMBER_LOCAL_ORIGIN__||window.location.origin,l=ye();if(l&&V(l,r)){c||s(null);return}const p=(await he()).hosts.find(u=>l?V(l,Se(u)):!1),f=p?.label?.trim()?we(p.label.trim()):"Instance";c||s(f)}catch{c||s("Instance")}};a();const g=()=>{a()};return window.addEventListener("focus",g),()=>{c=!0,window.removeEventListener("focus",g)}},[]);const n=A.useMemo(()=>Le(o,t),[o,t]);A.useEffect(()=>{if(typeof document<"u"&&(document.title=n),!$())return;(async()=>{try{if(typeof navigator<"u"&&/Macintosh|Mac OS X/.test(navigator.userAgent||""))return;await de(n)}catch{return}})()},[n])};export{ze as a,Fe as b,Be as c,xe as d,ke as s,Ne as u};