@pi-chamber/web 0.9.4 → 0.9.6

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 (107) hide show
  1. package/README.md +15 -0
  2. package/dist/assets/DiagramView-0Iq1ak1I.js +1 -0
  3. package/dist/assets/{DiffView-CBOrV4hS.js → DiffView-DD1AFRi3.js} +2 -2
  4. package/dist/assets/FileSaveConflictDialog-CoKwDovb.js +3 -0
  5. package/dist/assets/FilesView-B_BF39ef.js +6 -0
  6. package/dist/assets/GitView-LFEpCasf.js +8 -0
  7. package/dist/assets/{JsonTreeView-CKWGm5MS.js → JsonTreeView-Cwjgvh4g.js} +1 -1
  8. package/dist/assets/MarkdownRendererImpl-_7kV1yNw.js +12 -0
  9. package/dist/assets/PatchDiff-DG43C1HW.js +1 -0
  10. package/dist/assets/{SessionSwitcherContent-z9VYCXrT.js → SessionSwitcherContent-DCFXPY3d.js} +1 -1
  11. package/dist/assets/SessionSwitcherDropdown-QY7FKuEQ.js +2 -0
  12. package/dist/assets/SessionUnreadDot-DGT31A3z.js +1 -0
  13. package/dist/assets/SettingsView-eG-wN-yY.js +2 -0
  14. package/dist/assets/SettingsWindow-Dvnp8YrA.js +1 -0
  15. package/dist/assets/ToolOutputDialog-IlCrS6BR.js +8 -0
  16. package/dist/assets/ToolPartDiffPreview-D68JV0rR.js +1 -0
  17. package/dist/assets/{VirtualizedFileDiff-DfaXovGB.js → VirtualizedFileDiff-Bl-rAYeh.js} +3 -3
  18. package/dist/assets/collapsible-BjniCdZ5.js +1 -0
  19. package/dist/assets/computeVirtualFileMetrics-FSOm2VrW.js +3 -0
  20. package/dist/assets/contextFileOpenGuard-Bxb6AIPa.js +1 -0
  21. package/dist/assets/gitStatusPredicates-DxolDpMd.js +134 -0
  22. package/dist/assets/index-BpmGBboM.css +1 -0
  23. package/dist/assets/index-DZnzXhTs.js +8 -0
  24. package/dist/assets/index-Dh58uD3I.js +1 -0
  25. package/dist/assets/isDiffPlainText-D3_04XCh.js +1 -0
  26. package/dist/assets/isFilePlainText-CHouYQhH.js +1 -0
  27. package/dist/assets/{main-DG1oZ0Wj.js → main-CH3EqGJI.js} +2 -2
  28. package/dist/assets/main-HzTrVvbB.js +135 -0
  29. package/dist/assets/{markdownCore-DUjQU2i0.js → markdownCore-DJU4KvHP.js} +2 -2
  30. package/dist/assets/{miniChat-BEAtOkr9.js → miniChat-Ca3TpaaA.js} +2 -2
  31. package/dist/assets/{mobile-DOFBBQg2.js → mobile-lj4gpGsO.js} +2 -2
  32. package/dist/assets/renderElectronMiniChatApp-rUFfaD-T.js +2 -0
  33. package/dist/assets/renderMobileApp-CcWQ1sCf.js +11 -0
  34. package/dist/assets/runtimeEndpointReset-D2MmSbDk.js +53 -0
  35. package/dist/assets/{runtimeSurface-CySRuLbN.js → runtimeSurface-CE_VNjdH.js} +1 -1
  36. package/dist/assets/{useAppFontEffects-C4JL1x7k.js → useAppFontEffects-BvFAP9zG.js} +102 -103
  37. package/dist/assets/useFilesViewSearch-BD79p3A2.js +7 -0
  38. package/dist/assets/usePushVisibilityBeacon-CWg0j-Wg.js +10 -0
  39. package/dist/assets/useSwitcherItems-CazJ6Yox.js +1 -0
  40. package/dist/assets/{vendor-base-ui-vkqQ2P9o.js → vendor-base-ui-CdaWtC7e.js} +1 -1
  41. package/dist/assets/vendor-beautiful-mermaid-D3YCkKz7.js +111 -0
  42. package/dist/assets/{vendor-codemirror-commands-DYppkHEk.js → vendor-codemirror-commands-CNlncqrr.js} +1 -1
  43. package/dist/assets/{vendor-codemirror-language-data-C493X_9w.js → vendor-codemirror-language-data-CP3j3-xu.js} +2 -2
  44. package/dist/assets/{vendor-replit-codemirror-vim-CGHHNQxC.js → vendor-replit-codemirror-vim-DaSwPsXt.js} +1 -1
  45. package/dist/assets/{web-components-B2Rw__yK.js → web-components-DWuadqra.js} +3 -3
  46. package/dist/index.html +4 -4
  47. package/dist/mini-chat.html +3 -3
  48. package/dist/mobile.html +3 -3
  49. package/package.json +2 -2
  50. package/server/lib/fs/DOCUMENTATION.md +15 -3
  51. package/server/lib/fs/routes.js +369 -51
  52. package/server/lib/fs/routes.test.js +565 -3
  53. package/server/lib/fs/search.js +74 -29
  54. package/server/lib/pi/routes.js +56 -3
  55. package/server/lib/pi/routes.test.js +165 -0
  56. package/server/lib/pi/session-daemon/DOCUMENTATION.md +19 -6
  57. package/server/lib/pi/session-daemon/prompt-operations.test.js +151 -3
  58. package/server/lib/pi/session-daemon/prompt-preflight.test.js +556 -0
  59. package/server/lib/pi/session-daemon/sdk-upgrade.test.js +157 -0
  60. package/server/lib/pi/session-daemon/send-operation-dedup.test.js +331 -0
  61. package/server/lib/pi/session-daemon/send-operation-registry.js +264 -0
  62. package/server/lib/pi/session-daemon/send-operation-registry.test.js +205 -0
  63. package/server/lib/pi/session-daemon/session-daemon-extensions.e2e.test.js +16 -5
  64. package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +3 -1
  65. package/server/lib/pi/session-daemon/session-daemon.js +514 -107
  66. package/server/lib/pi/session-daemon/session-daemon.test.js +37 -13
  67. package/server/lib/pi/session-daemon/session-idle-residency.test.js +749 -0
  68. package/server/lib/pi/session-daemon/session-replay.js +98 -0
  69. package/server/lib/pi/session-daemon/session-replay.test.js +628 -0
  70. package/server/lib/pi/ui-settings-store.js +16 -10
  71. package/server/lib/pi/ui-settings-store.test.js +91 -0
  72. package/server/lib/server/cors.js +6 -0
  73. package/server/lib/server/cors.test.js +3 -0
  74. package/server/lib/stt/DOCUMENTATION.md +1 -1
  75. package/server/lib/stt/local/worker-client.js +11 -3
  76. package/server/lib/stt/local/worker-client.test.js +255 -0
  77. package/server/lib/workspace/host.js +6 -2
  78. package/server/lib/workspace/host.test.js +15 -0
  79. package/dist/assets/DiagramEditor-DuGmiPZ5.js +0 -1
  80. package/dist/assets/DiagramView-CHy1Glsl.js +0 -1
  81. package/dist/assets/FilesView-CK2YVs_W.js +0 -6
  82. package/dist/assets/GitView-BEFLOv_7.js +0 -8
  83. package/dist/assets/MarkdownRendererImpl-hE_nmSqe.js +0 -12
  84. package/dist/assets/PatchDiff-BagRxMON.js +0 -1
  85. package/dist/assets/SessionSwitcherDropdown-icxJk_lT.js +0 -2
  86. package/dist/assets/SessionUnreadDot-Bv-5KguB.js +0 -1
  87. package/dist/assets/SettingsView-Ck0qxtKP.js +0 -2
  88. package/dist/assets/SettingsWindow-GQRL2CdD.js +0 -1
  89. package/dist/assets/ToolOutputDialog-CxJUXVZW.js +0 -8
  90. package/dist/assets/ToolPartDiffPreview-BXuLRWHT.js +0 -1
  91. package/dist/assets/collapsible-szfZ0Syc.js +0 -1
  92. package/dist/assets/computeVirtualFileMetrics-DG_E6iaN.js +0 -3
  93. package/dist/assets/contextFileOpenGuard-DPBE3ELv.js +0 -1
  94. package/dist/assets/gitStatusPredicates-OljV4Bb2.js +0 -134
  95. package/dist/assets/index-DNoEeZ2U.css +0 -1
  96. package/dist/assets/index-DmexVlTQ.js +0 -1
  97. package/dist/assets/index-KIdiBFJs.js +0 -8
  98. package/dist/assets/isDiffPlainText-aikgiqLb.js +0 -1
  99. package/dist/assets/isFilePlainText-D-Dl6LqX.js +0 -1
  100. package/dist/assets/main-BXdraZTZ.js +0 -135
  101. package/dist/assets/renderElectronMiniChatApp-B0K72YnS.js +0 -2
  102. package/dist/assets/renderMobileApp-Ca_BO_s4.js +0 -11
  103. package/dist/assets/runtimeEndpointReset-Cx2tsgTo.js +0 -54
  104. package/dist/assets/useFilesViewSearch-Du0DnmKs.js +0 -7
  105. package/dist/assets/usePushVisibilityBeacon-BnHxIv4r.js +0 -10
  106. package/dist/assets/useSwitcherItems-C91mwPJD.js +0 -1
  107. package/dist/assets/vendor-beautiful-mermaid-DneUawHp.js +0 -119
@@ -1,7 +0,0 @@
1
- import{R as c}from"./vendor-react-B5Z1Mdn3.js";import{t as m,s as P}from"./useAppFontEffects-C4JL1x7k.js";import{d as W}from"./index-KIdiBFJs.js";const M=e=>{const t=u(e);if(!t)return"";if(t==="/"||/^[A-Za-z]:\/$/.test(t))return t;const s=t.lastIndexOf("/");if(s<0)return t;if(s===0)return"/";const n=t.slice(0,s);return/^[A-Za-z]:$/.test(n)?`${n}/`:n},N=e=>e.slice().sort((t,s)=>t.type!==s.type?t.type==="directory"?-1:1:t.name.localeCompare(s.name)),u=e=>{if(!e)return"";const t=e.replace(/\\/g,"/"),s=t.startsWith("//");let n=t.replace(/\/+/g,"/");s&&!n.startsWith("//")&&(n=`/${n}`);const i=n==="/",a=/^[A-Za-z]:\/$/.test(n);return!i&&!a&&(n=n.replace(/\/+$/,"")),n},V=e=>e.startsWith("/")||e.startsWith("//")||/^[A-Za-z]:\//.test(e),S=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,b=(e,t)=>{const s=u(t),n=u(e);if(!s||!n)return!1;const i=S(s),a=S(n);return a===i||a.startsWith(`${i}/`)},Z=(e,t)=>{const s=u(t),n=u(e);if(!b(n,s))return[];const a=n.slice(s.length).replace(/^\//,"").split("/"),g=[];let r=s;for(let l=0;l<a.length-1;l++)r=r?`${r}/${a[l]}`:a[l],g.push(r);return g},q=(e,t)=>{if(!t)return"";const s=u(t);if(!e||!b(s,e))return s;const n=s.slice(e.length);return n.startsWith("/")?n.slice(1):n},D=new Set(["node_modules"]),B=e=>D.has(e),L=e=>{const t=u(e);return t==="node_modules"||t.endsWith("/node_modules")||t.includes("/node_modules/")},O=e=>{const s=(e instanceof Error?e.message:String(e??"")).toLowerCase();return s.includes("is a directory")||s.includes("eisdir")},U=e=>{const s=(e instanceof Error?e.message:String(e??"")).toLowerCase();return s.includes("file not found")||s.includes("enoent")||s.includes("no such file")||s.includes("does not exist")},v=2e5,H=e=>{let t=0,s=0;for(let n=0;n<e.length;n+=1)e.charCodeAt(n)===10&&(n>0&&e.charCodeAt(n-1)===13?t+=1:s+=1);return t>s?`\r
2
- `:`
3
- `},_=e=>e.replace(/\r\n/g,`
4
- `).replace(/\r/g,`
5
- `),Q=(e,t)=>{const s=_(e);return t===`\r
6
- `?s.replace(/\n/g,`\r
7
- `):s},J=e=>{if(!e)return!1;const t=e.toLowerCase().split(".").pop();return t==="md"||t==="markdown"},T=e=>{if(!e)return!1;const t=e.toLowerCase().split(".").pop();return t==="json"||t==="jsonc"||t==="json5"||t==="geojson"},X=e=>{if(!e)return!1;const t=e.toLowerCase().split(".").pop();return t==="html"||t==="htm"};function G({files:e,root:t,selectedPath:s,refreshDirectory:n,removeOpenPathsByPrefix:i,clearSelectedPath:a}){const g=c.useRef(null),[r,l]=c.useState(null),[p,z]=c.useState(null),[h,F]=c.useState(""),[R,d]=c.useState(!1),y=c.useCallback(($,f)=>{l($),z(f),F($==="rename"&&f.name||""),d(!1)},[]),E=c.useCallback(()=>l(null),[]),A=c.useCallback(async $=>{if($?.preventDefault(),!r||!p)return;const f=h.trim();if(r==="createFile"&&!f){m.error("Filename is required");return}if(r==="createFolder"&&!f){m.error("Folder name is required");return}if(r==="rename"&&!f){m.error("Name is required");return}if(r==="createFile"&&!e.writeFile){m.error("Write not supported");return}if(r==="rename"&&!e.rename){m.error("Rename not supported");return}if(r==="delete"&&!e.delete){m.error("Delete not supported");return}d(!0);try{if(r==="createFile"){const o=p.path,w=u(`${o?`${o}/`:""}${f}`);(await e.writeFile(w,"")).success&&(m.success("File created"),await n(o))}else if(r==="createFolder"){const o=p.path,w=u(`${o?`${o}/`:""}${f}`);(await e.createDirectory(w)).success&&(m.success("Folder created"),await n(o))}else{const o=p.path,w=o.split("/").slice(0,-1).join("/"),C=s===o||s.startsWith(`${o}/`);(r==="rename"?await e.rename(o,u(`${w?`${w}/`:""}${f}`)):await e.delete(o)).success&&(m.success(r==="rename"?"Renamed successfully":"Deleted successfully"),await n(w),t&&i(t,o),C&&a())}l(null)}catch{m.error("Operation failed")}finally{d(!1)}},[a,e,h,r,n,i,t,s,p]);return{operation:r,target:p,inputValue:h,setInputValue:F,submitting:R,inputRef:g,open:y,close:E,submit:A,capabilities:{canCreateFile:!!e.writeFile,canCreateFolder:!!e.createDirectory,canRename:!!e.rename,canDelete:!!e.delete}}}function K({directory:e,query:t,chrome:s,showHidden:n,showGitignored:i}){const a=W(h=>h.searchFiles),g=P(t,200),[r,l]=c.useState([]),[p,z]=c.useState(!1);return c.useEffect(()=>{const h=g.trim();if(!e||!h){l([]),z(!1);return}let F=!1;return z(!0),a(e,h,s==="mobile"?40:150,{includeHidden:s==="mobile"||n,respectGitignore:s==="desktop"&&!i,type:"file"}).then(R=>{F||l(R.filter(d=>i||!L(d.path)).map(d=>({name:d.name,path:u(d.path),type:"file",extension:d.extension,relativePath:d.relativePath})))}).catch(()=>{F||l([])}).finally(()=>{F||z(!1)}),()=>{F=!0}},[s,g,e,a,n,i]),{results:r,searching:p}}export{v as M,J as a,X as b,u as c,H as d,B as e,V as f,q as g,N as h,T as i,b as j,M as k,K as l,U as m,_ as n,O as o,Z as p,Q as s,S as t,G as u};
@@ -1,10 +0,0 @@
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{k as I,y as D,z as k,A as V,B as Y,C as W,E as K,F as z,G as N,c as J,H as q,J as b,K as Z}from"./useAppFontEffects-C4JL1x7k.js";import{s as Q,f as M,p as X,h as ee,j as A,k as te,r as se,S as oe,l as H,i as T,m as ne}from"./index-KIdiBFJs.js";import{_ as re}from"./vendor-vite-runtime-DD1OZmLC.js";import{R as ie}from"./vendor-react-B5Z1Mdn3.js";const ae=[];function B(){return[...ae].reverse()}const le={getLastAssistantMessage(){if(!I.getState().currentSessionId)return console.log("[ERROR] No active session"),null;const t=b();if(!t||t.length===0)return console.log("[ERROR] No messages in current session"),null;for(let n=t.length-1;n>=0;n--){const o=t[n];if(o.role==="assistant"){const l=(D(o.id)||[]).map(i=>{const d={id:i.id,type:i.type};return i.type==="text"?(d.text=i.text,d.textLength=i.text?.length||0):i.type==="tool"?(d.tool=i.tool,d.state=i.state?.status):(i.type==="step-start"||i.type==="step-finish")&&(d.isStepMarker=!0),d}),u=l.some(i=>i.type==="text"&&i.text&&i.text.trim().length>0),a=l.some(i=>i.type==="tool"),g=l.some(i=>i.type==="step-start"||i.type==="step-finish"),m=l.length===0,f=!u&&!a&&(!m||g),r={messageId:o.id,role:o.role,timestamp:o.time?.created||0,partsCount:l.length,parts:l,isEmpty:m,isEmptyResponse:f,raw:o};return console.log("[INSPECT] Last Assistant Message:",r),console.log("[SUMMARY] Summary:",{messageId:r.messageId,partsCount:r.partsCount,isEmpty:r.isEmpty,isEmptyResponse:r.isEmptyResponse,hasText:u,hasTools:a,hasStepMarkers:g,onlyStepMarkers:g&&!u&&!a}),r.isEmpty&&console.warn("[WARNING] Message has NO parts!"),r.isEmptyResponse&&(console.warn("[WARNING] Message has parts but NO meaningful content (empty text, no tools)!"),g&&!u&&!a&&(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"))),r}}return console.log("[ERROR] No assistant messages found in current session"),null},truncateString(e,s=80){return!e||typeof e!="string"||e.length<=s?e:e.substring(0,s)+"…"},truncateMessages(e){return e.map(s=>({...s,parts:(D(s.id)||[]).map(t=>{const n={...t};return"text"in t&&(n.text=this.truncateString(t.text)),"textPreview"in t&&(n.textPreview=this.truncateString(t.textPreview)),t.state&&(n.state={...t.state},"output"in t.state&&(n.state.output=this.truncateString(t.state.output)),"error"in t.state&&(n.state.error=this.truncateString(t.state.error)),t.state.metadata&&"preview"in t.state.metadata&&(n.state.metadata={...t.state.metadata,preview:this.truncateString(t.state.metadata.preview)})),n})}))},getAllMessages(e=!1){if(!I.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const n=b();return console.log(`[MESSAGES] Total messages in session: ${n.length}`),n.forEach((o,p)=>{const l=D(o.id)||[];console.log(`[${p}] ${o.role} - ${o.id} - ${l.length} parts`)}),e?this.truncateMessages(n):n},async getAppStatus(){const e=M.getState(),s=I.getState(),t=J.getState(),n=e.currentDirectory||null,o=N().getState(),p=o.directory??null,l=q(),u=new Set,a={};l.forEach(c=>{const y=c.directory;typeof y=="string"&&y.trim().length>0?(u.add(y),a[y]=(a[y]??0)+1):a["(none)"]=(a["(none)"]??0)+1});const g=(()=>{if(typeof window>"u")return{available:!1};try{return{available:!0,lastDirectory:window.localStorage.getItem("lastDirectory"),homeDirectory:window.localStorage.getItem("homeDirectory")}}catch(c){return{available:!1,error:c instanceof Error?c.message:String(c)}}})(),m=A(),f=typeof window<"u"&&!!window.__PICHAMBER_ELECTRON__,r=async c=>{try{return await c.json()}catch{return null}},d=await(async c=>{try{const y=await se(c);return y.ok?await r(y):{status:y.status}}catch(y){return{error:y instanceof Error?y.message:String(y)}}})("/api/pi/ui-settings");let R=null;try{R=await X.health({runtimeKey:ee()})}catch(c){R={error:c instanceof Error?c.message:String(c)}}let E={isGitRepo:null};if(n)try{const c=A()?.git.checkIsGitRepository??te;E.isGitRepo=await c(n)}catch(c){E={isGitRepo:null,error:c instanceof Error?c.message:String(c)}}const w=t.projects.map(c=>({id:c.id,path:c.path,label:c.label})),S={runtime:{platform:m?.runtime?.platform??null,isDesktop:f,hasRuntimeApis:!!m,desktopServerOrigin:null},location:typeof window<"u"?{href:window.location?.href??null,origin:window.location?.origin??null}:null,directories:{currentDirectory:n,piDirectory:p,homeDirectory:e.homeDirectory||null,isHomeReady:e.isHomeReady,hasPersistedDirectory:e.hasPersistedDirectory,isSwitchingDirectory:e.isSwitchingDirectory},projects:{total:t.projects.length,activeProjectId:t.activeProjectId,samples:w},sessions:{total:l.length,currentSessionId:s.currentSessionId,lastLoadedDirectory:s.lastLoadedDirectory,uniqueDirectories:u.size,directorySamples:Array.from(u).slice(0,5),directoryCounts:a},git:E,localStorage:g,pi:{health:R,connection:o.connection},pichamber:{settingsInfo:d},recentSendFailures:B(),currentSessionDirectoryResolution:s.currentSessionId?this.diagnoseSessionDirectory(s.currentSessionId):null};return console.log("[DEBUG] App status snapshot:",S),S},getRecentSendFailures(){const e=B();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 s=I.getState(),t=e??s.currentSessionId;if(!t)return console.log("[ERROR] No session selected and no session id passed"),null;const n=Y(t),o=W().find(d=>d.id===t),p=o?.directory??null,l=t===s.currentSessionId?s.currentSessionDirectory:null,a=K({session:o??null,currentDirectory:l}),g=s.getDirectoryForSession(t),m=z(t),f=[["owning child store",n],["session record",p],["current selection",l],["runtime memory",m.runtime],["persisted memory",m.persisted]],r=g?f.find(([,d])=>d&&d!==g):void 0,i={sessionId:t,isCurrentSession:t===s.currentSessionId,routedDirectory:g,resolvedFrom:a.source,conflict:r?{source:r[0],directory:r[1]}:null,sources:Z(),details:{owningChildStore:n,sessionRecordDirectory:p,sessionIndexed:!!o,currentSessionDirectory:s.currentSessionDirectory,rememberedForRuntime:m.runtime,persistedAcrossRestarts:m.persisted,activeDirectory:M.getState().currentDirectory??null,piSessionDirectory:N().getState().directory??null}};return console.log("[DEBUG] Session directory resolution:",i),r?console.warn(`[ALERT] Directory sources disagree: routing to "${g}" while "${r[1]}" came from ${r[0]}.`):g?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."),i},async buildDiagnosticsReport(){const e=await this.getAppStatus();return JSON.stringify(e,null,2)},async copyTextToClipboard(e){return V(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 s=e.isEmpty||e.isEmptyResponse;return s?(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!"),s},getStreamingState(){const e=I.getState(),s=k.getState(),t=e.currentSessionId?s.streamingMessageIds.get(e.currentSessionId)??null:null;return console.log("[STREAM] Streaming State:",{streamingMessageId:t,streamingMessageIds:Array.from(s.streamingMessageIds.entries()),messageStreamStates:Array.from(s.messageStreamStates.entries())}),{streamingMessageId:t,streamingMessageIds:s.streamingMessageIds,streamStates:s.messageStreamStates}},findEmptyMessages(){if(!I.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const n=b().filter(o=>o.role==="assistant").filter(o=>{const p=D(o.id)||[],l=p.some(a=>a.type==="text"&&a.text&&a.text.trim().length>0),u=p.some(a=>a.type==="tool");return p.length===0||!l&&!u});return console.log(`[INSPECT] Found ${n.length} empty assistant messages`),n.forEach((o,p)=>{const l=D(o.id)||[];console.log(`[${p}] Empty message:`,{messageId:o.id,partsCount:l.length,provider:o.providerID,model:o.modelID,timestamp:o.time?.created})}),n},showRetryHelp(){console.log(`[DEBUG] How to handle empty Claude responses:
3
- `),console.log("1. Check the last message:"),console.log(` __piDebug.getLastAssistantMessage()
4
- `),console.log("2. Find all empty messages in session:"),console.log(` __piDebug.findEmptyMessages()
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:s=!1,verbose:t=!0,maxTableRows:n=25}=e;if(!I.getState().currentSessionId)return console.log("[ERROR] No active session"),{summary:null,rows:[]};const l=b(),u=s?l:l.filter(r=>r.role==="assistant"),a={totalMessages:l.length,analyzedMessages:u.length,completedMissing:0,completedBeforeTool:0,completedBeforeReasoning:0,runningToolsWhenCompleted:0,reasoningOpenWhenCompleted:0,withTools:0,withReasoning:0},g=r=>typeof r=="number"&&Number.isFinite(r)?r:null,m=r=>{const i=r.filter(d=>typeof d=="number");return i.length>0?Math.max(...i):null},f=u.map((r,i)=>{const d=r,R=D(r.id)||[],E=d.time??{},w=g(E.completed),S=w!==null,c=R.filter(h=>h.type==="tool"),y=R.filter(h=>h.type==="reasoning"),_=m(c.map(h=>g(h.state?.time?.end??h.state?.time?.start))),C=m(y.map(h=>g(h.time?.end??h.time?.start))),U=m([_,C].filter(h=>h!==null)),P=c.some(h=>["pending","running","started"].includes(h.state?.status)),L=y.some(h=>typeof h.time?.end!="number");c.length>0&&(a.withTools+=1),y.length>0&&(a.withReasoning+=1),S||(a.completedMissing+=1);const x=!!(S&&typeof _=="number"&&w<_);x&&(a.completedBeforeTool+=1);const O=!!(S&&typeof C=="number"&&w<C);return O&&(a.completedBeforeReasoning+=1),S&&P&&(a.runningToolsWhenCompleted+=1),S&&L&&(a.reasoningOpenWhenCompleted+=1),{index:i,messageId:d.id,role:d.role,completedAt:w,latestToolTimestamp:_,latestReasoningTimestamp:C,latestPartTimestamp:U,completed_missing:!S,completed_before_tool:x,completed_before_reasoning:O,running_tools_when_completed:!!(S&&P),reasoning_open_when_completed:!!(S&&L),has_tools:c.length>0,has_reasoning:y.length>0}});return t&&(console.table(f.slice(0,n)),f.length>n&&console.log(`Displayed first ${n} rows out of ${f.length}.`),console.log("[SUMMARY] Message completion timing:",a)),{summary:a,rows:f}},checkCompletionStatus(){if(!I.getState().currentSessionId)return console.log("[ERROR] No active session"),null;const n=b().filter(w=>w.role==="assistant");if(n.length===0)return console.log("[ERROR] No assistant messages"),null;const o=n[n.length-1],l=(D(o.id)||[]).filter(w=>w.type==="step-finish"),u=o.finish==="stop",g=o.time?.completed,m=o.status,f=typeof g=="number"&&g>0||m==="completed",r=!!(f&&u),i=k.getState(),d=o.sessionID?i.streamingMessageIds.get(o.sessionID)??null:null,R=i.messageStreamStates.get(o.id),E=o.id===d;return console.log("[SUMMARY] Completion Status:"),console.log("Message ID:",o.id),console.log("time.completed:",g,"(type:",typeof g,")"),console.log("status:",m),console.log("hasCompletedFlag:",f),console.log("hasStopReason:",u),console.log("messageIsComplete:",r),console.log("lifecycle phase:",R?.phase),console.log("isStreamingCandidate:",E),console.log("streamingMessageId:",d),console.log("Step-finish parts:",l),{messageId:o.id,completed:g,status:m,hasCompletedFlag:f,hasStopReason:u,messageIsComplete:r,stepFinishParts:l,raw:o}}};typeof window<"u"&&(window.__piDebug=le,Q()&&(console.log("[DEBUG] Pi debug utilities loaded. Use window.__piDebug in the console."),console.log("Available commands:"),console.log(" __piDebug.getLastAssistantMessage() - Get last assistant message details"),console.log(" __piDebug.getAllMessages(truncate?) - List all messages (truncate=true for short preview)"),console.log(" __piDebug.truncateMessages(messages) - Truncate long fields in messages array"),console.log(" __piDebug.getAppStatus() - Show app status snapshot"),console.log(" __piDebug.diagnoseSessionDirectory(sessionId?) - Show how the session directory is resolved"),console.log(" __piDebug.getRecentSendFailures() - List prompt sends that were rejected and rolled back"),console.log(" __piDebug.checkLastMessage() - Check if last message is problematic"),console.log(" __piDebug.findEmptyMessages() - Find all empty assistant messages"),console.log(" __piDebug.showRetryHelp() - Show instructions for handling empty responses"),console.log(" __piDebug.getStreamingState() - Get streaming state info"),console.log(" __piDebug.analyzeMessageCompletionConsistency(opts?) - Compare time.completed vs part timings"),console.log(" __piDebug.checkCompletionStatus() - Check completion status of last message")),window.addEventListener("error",e=>{try{const s=e.message||"",t=e.filename||"";typeof s=="string"&&s.includes("this._renderer.value.dimensions")&&/xterm/i.test(String(t))&&e.preventDefault()}catch{}}));const pe=async()=>{if(typeof window>"u")return;let e=null;try{e=window.localStorage.getItem("lastDirectory")}catch(s){console.warn("Failed to read saved directory preferences:",s)}e&&M.getState().setDirectory(e,{showOverlay:!1})};let F=!1;const G="pichamber-typography-base",ce=()=>{if(typeof document>"u")return;const s=`:root {
7
- ${Object.entries(oe).map(([o,p])=>` --text-${o.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${p};`).join(`
8
- `)}
9
- }
10
- `,t=document.getElementById(G);if(t){t.textContent=s;return}const n=document.createElement("style");n.id=G,n.textContent=s,document.head.appendChild(n)},ye=()=>{F||typeof window>"u"||(F=!0,ce())},$=2e4,j=()=>typeof document>"u"||document.visibilityState==="visible"&&document.hasFocus()?"visible":"hidden",v=e=>{if(!H()&&!T())return;const s=A();s?.push?.setVisibility&&s.push.setVisibility({visible:e,platform:ne()})},fe=e=>{const s=e?.enabled??!0;ie.useEffect(()=>{if(!s||!H()&&!T()||typeof window>"u")return;if(T()){let l=!0,u=!1,a=null;const g=()=>v(l);re(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([0,1,2])).then(async({App:f})=>{if(u)return;const r=await f.getState().catch(()=>null);r&&(l=r.isActive===!0),g();const i=await f.addListener("appStateChange",({isActive:d})=>{l=d===!0,g()});if(u){i.remove();return}a=()=>{i.remove()}}).catch(()=>{});const m=window.setInterval(()=>{l&&v(!0)},$);return()=>{u=!0,window.clearInterval(m),a?.()}}if(typeof document>"u")return;const t=()=>{v(j()==="visible")},n=()=>{j()==="visible"&&v(!0)},o=()=>{v(!1)};t();const p=window.setInterval(n,$);return document.addEventListener("visibilitychange",t),window.addEventListener("pagehide",o),window.addEventListener("pageshow",t),window.addEventListener("focus",t),window.addEventListener("blur",t),()=>{window.clearInterval(p),document.removeEventListener("visibilitychange",t),window.removeEventListener("pagehide",o),window.removeEventListener("pageshow",t),window.removeEventListener("focus",t),window.removeEventListener("blur",t)}},[s])};export{pe as a,ye as s,fe as u};
@@ -1 +0,0 @@
1
- import{R as f}from"./vendor-react-B5Z1Mdn3.js";import{u as B,c as v,d as z,e as D,f as L,g as I,r as j}from"./useAppFontEffects-C4JL1x7k.js";const M=50,p=n=>{if(!n)return null;const s=n.replace(/\\/g,"/");return s==="/"?"/":s.replace(/\/+$/,"")},k=(n,s)=>{const c=p(n),a=p(s);return!c||!a?!1:c===a||c.startsWith(`${a}/`)},O=n=>{if(!n)return null;const s=n.label?.trim();return s||(n.path.split(/[\\/]/).filter(Boolean).at(-1)??n.path)},w=(n,s={})=>{const{scopeProjectId:c=null,maxParents:a=M}=s,l=B({archived:!1}),P=v(t=>t.projects),u=z(t=>t.ids),d=D(t=>t.rankById),S=L(),b=f.useMemo(()=>P.map(t=>({...t,normalizedPath:p(t.path)})).filter(t=>t.normalizedPath),[P]),h=f.useCallback(t=>t?b.filter(i=>k(t,i.normalizedPath)).sort((i,e)=>(e.normalizedPath?.length??0)-(i.normalizedPath?.length??0))[0]??null:null,[b]);return f.useMemo(()=>{if(!n)return[];const t=new Map;for(const e of l){const r=e.parentID;if(!r||e.time?.archived)continue;const o=t.get(r);o?o.push(e):t.set(r,[e])}t.forEach(e=>{e.sort((r,o)=>I(r,o,u,d))});const y=l.filter(e=>!e.time?.archived).filter(e=>!e.parentID).filter(e=>{if(!c)return!0;const r=j(e);return h(r)?.id===c}).sort((e,r)=>I(e,r,u,d)).slice(0,a),i=e=>{const r=t.get(e.id)??[];return{session:e,children:r.map(o=>i(o))}};return y.map(e=>{const r=j(e),o=h(r),g=O(o),m=(r?S.get(r):void 0)??null;return{node:i(e),projectId:o?.id??null,groupDirectory:r,secondaryMeta:{projectLabel:g,branchLabel:m&&m!==g?m:null}}})},[l,S,n,h,a,u,c,d])};export{w as u};