@pi-chamber/web 0.2.2 → 0.3.1

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 (71) 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-DPjTv8fA.js → CommitSection-C336377Z.js} +1 -1
  4. package/dist/assets/{DiagramEditor-ChOor9l9.js → DiagramEditor-gHLCXHtr.js} +1 -1
  5. package/dist/assets/{DiagramView-3hAT86v_.js → DiagramView-DlHzRRBc.js} +1 -1
  6. package/dist/assets/{DiffView-D1dyOiw2.js → DiffView-5wHwK-lg.js} +1 -1
  7. package/dist/assets/{FilesView-BCzghrc7.js → FilesView-5bswI3JZ.js} +6 -6
  8. package/dist/assets/{GitView-CYF1E1p4.js → GitView-BfykGpGh.js} +4 -4
  9. package/dist/assets/{JsonTreeView-CrJO6LNu.js → JsonTreeView-HVwQS7qG.js} +1 -1
  10. package/dist/assets/{MarkdownRendererImpl-BmKjrkGD.js → MarkdownRendererImpl-kjd4e0N8.js} +1 -1
  11. package/dist/assets/{PatchDiff-DgvPLx6x.js → PatchDiff-Dlm4RU8n.js} +1 -1
  12. package/dist/assets/{PierreDiffViewer-InnT0JVA.js → PierreDiffViewer-St32rXlD.js} +1 -1
  13. package/dist/assets/{SessionSwitcherDropdown-C0OdvirK.js → SessionSwitcherDropdown-D5bWfZNA.js} +100 -101
  14. package/dist/assets/SettingsView-FGe5TEQq.js +4 -0
  15. package/dist/assets/SettingsWindow-Ck_uhTnx.js +1 -0
  16. package/dist/assets/{ToolOutputDialog-gzwcb8nI.js → ToolOutputDialog-BCONUv3r.js} +5 -5
  17. package/dist/assets/{ToolPartDiffPreview-C45V5bhy.js → ToolPartDiffPreview-BdVuk2kc.js} +1 -1
  18. package/dist/assets/{VirtualizedFileDiff-uKfnkQWb.js → VirtualizedFileDiff-BsAZM0jo.js} +1 -1
  19. package/dist/assets/{collapsible-Bq8sDiKS.js → collapsible-Wnmq-13H.js} +1 -1
  20. package/dist/assets/{computeVirtualFileMetrics-BPgZ_RSe.js → computeVirtualFileMetrics-skbyL2Az.js} +2 -2
  21. package/dist/assets/{contextFileOpenGuard-CydO7PkI.js → contextFileOpenGuard-BsxQITMZ.js} +1 -1
  22. package/dist/assets/index-8TL2HlaR.js +8 -0
  23. package/dist/assets/{index-BSuNNtBh.js → index-Bfp6eYap.js} +1 -1
  24. package/dist/assets/index-riABQmQ_.css +1 -0
  25. package/dist/assets/{isDiffPlainText-f9b4cKNo.js → isDiffPlainText-dZkfk3yG.js} +1 -1
  26. package/dist/assets/{isFilePlainText-BjESb-gU.js → isFilePlainText-UL_tMQZx.js} +1 -1
  27. package/dist/assets/{main-B508FBXr.js → main-CHQfoyRP.js} +2 -2
  28. package/dist/assets/main-DbnYXZeK.js +133 -0
  29. package/dist/assets/{markdownCore-BFmf8a-O.js → markdownCore-qX3mJFkL.js} +2 -2
  30. package/dist/assets/{miniChat-BTlz8IPL.js → miniChat-3QtCNwHl.js} +2 -2
  31. package/dist/assets/{mobile-DBkrRt80.js → mobile-B_CyfRAX.js} +2 -2
  32. package/dist/assets/renderElectronMiniChatApp-OToslrv-.js +1 -0
  33. package/dist/assets/renderMobileApp-BD_wep_I.js +14 -0
  34. package/dist/assets/{runtimeSurface-Bec4O8FD.js → runtimeSurface-CkdOpqo7.js} +1 -1
  35. package/dist/assets/{useInlineCommentController-CHmIm0Rr.js → useInlineCommentController-DVif5Fr8.js} +2 -2
  36. package/dist/assets/usePanelSlide-C_PJmPXW.js +56 -0
  37. package/dist/assets/{useWindowTitle-CE5N_NeU.js → useWindowTitle-BZVlLMCy.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-language-data-q1yHU1R9.js → vendor-codemirror-language-data-C-924Z4o.js} +2 -2
  40. package/dist/assets/{vendor-sonner-dWA7qvjr.js → vendor-sonner-CW8w438f.js} +1 -1
  41. package/dist/assets/{web-components-CLirSfwt.js → web-components-BG-6PEN4.js} +1 -1
  42. package/dist/index.html +4 -4
  43. package/dist/mini-chat.html +3 -3
  44. package/dist/mobile.html +3 -3
  45. package/package.json +1 -1
  46. package/server/lib/package-manager.js +0 -34
  47. package/server/lib/pi/routes.js +52 -4
  48. package/server/lib/pi/routes.test.js +14 -6
  49. package/server/lib/pi/session-daemon/DOCUMENTATION.md +4 -3
  50. package/server/lib/pi/session-daemon/message-entry-aliases.js +100 -0
  51. package/server/lib/pi/session-daemon/runtime-registry.js +3 -0
  52. package/server/lib/pi/session-daemon/session-daemon.js +184 -16
  53. package/server/lib/pi/session-daemon/session-daemon.test.js +310 -5
  54. package/server/lib/pi/session-daemon/supervisor.js +20 -1
  55. package/server/lib/pi/session-daemon/supervisor.test.js +43 -0
  56. package/server/lib/tunnels/DOCUMENTATION.md +6 -7
  57. package/server/lib/tunnels/executable-search.test.js +4 -4
  58. package/server/lib/tunnels/install-help.js +0 -10
  59. package/server/lib/tunnels/install-help.test.js +0 -9
  60. package/server/lib/tunnels/types.js +0 -1
  61. package/dist/assets/SettingsView-JAfC_cBL.js +0 -3
  62. package/dist/assets/SettingsWindow-BBEsjcJE.js +0 -1
  63. package/dist/assets/index-CH7o4-_q.js +0 -8
  64. package/dist/assets/index-o4Eea60G.css +0 -1
  65. package/dist/assets/main-nG4uFyAy.js +0 -133
  66. package/dist/assets/renderElectronMiniChatApp-DW3fSR5w.js +0 -1
  67. package/dist/assets/renderMobileApp-9qkroKty.js +0 -14
  68. package/dist/assets/usePanelSlide-DCX8qQ4K.js +0 -56
  69. package/server/lib/ngrok-tunnel.js +0 -343
  70. package/server/lib/ngrok-tunnel.test.js +0 -50
  71. 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{h as E,d4 as T,d5 as j,av as se,d6 as ne,cS as ie,d7 as re,aa as k,b as Z,d8 as ae,d9 as le,da as P,db as ce,dc as de}from"./SessionSwitcherDropdown-C0OdvirK.js";import{ao as ue,l as B,r as U,o as ee,u as d,U as te,a1 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,al as he,ar as Se,am as we}from"./index-CH7o4-_q.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-D5bWfZNA.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-8TL2HlaR.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 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 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},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 {
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()})},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)},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(" | "),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};
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};