@pi-chamber/web 0.9.7 → 0.9.8-rc.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 (61) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/{DiagramView-BvrCkm_z.js → DiagramView-BMBrrFLy.js} +1 -1
  3. package/dist/assets/{DiffView-DMvRLRN1.js → DiffView-yVBxHkBI.js} +1 -1
  4. package/dist/assets/{FileSaveConflictDialog-DGa9u43J.js → FileSaveConflictDialog-D0siEm8l.js} +1 -1
  5. package/dist/assets/{FilesView-CNHu4RnC.js → FilesView-CkcKBKkT.js} +4 -4
  6. package/dist/assets/{GitView-Cbepz-bR.js → GitView-CfuhQOfc.js} +3 -3
  7. package/dist/assets/{JsonTreeView-C2X5oXQm.js → JsonTreeView-6kRdE1BO.js} +1 -1
  8. package/dist/assets/{MarkdownRendererImpl-BanSCkPy.js → MarkdownRendererImpl-CRWbN_Jc.js} +1 -1
  9. package/dist/assets/{PatchDiff-i_9BIlgo.js → PatchDiff-B0ssv8Aw.js} +1 -1
  10. package/dist/assets/{SessionSwitcherContent-DxS_rFuS.js → SessionSwitcherContent-NmfI4B0Z.js} +1 -1
  11. package/dist/assets/{SessionSwitcherDropdown-AVghToww.js → SessionSwitcherDropdown-DmE2hYTN.js} +2 -2
  12. package/dist/assets/SessionUnreadDot-LDTswryg.js +1 -0
  13. package/dist/assets/SettingsView-D0iw6y_H.js +2 -0
  14. package/dist/assets/{SettingsWindow-BfPUzBbq.js → SettingsWindow-BT2TzUBK.js} +1 -1
  15. package/dist/assets/{ToolOutputDialog-CJ87b80H.js → ToolOutputDialog-Bnl51bva.js} +5 -5
  16. package/dist/assets/{ToolPartDiffPreview-bF486Lz1.js → ToolPartDiffPreview-DgPtLS_h.js} +1 -1
  17. package/dist/assets/{VirtualizedFileDiff-CFpvcZ1g.js → VirtualizedFileDiff-D3zBpYIS.js} +4 -4
  18. package/dist/assets/collapsible-_urywMu5.js +1 -0
  19. package/dist/assets/{computeVirtualFileMetrics-CsAu9rOt.js → computeVirtualFileMetrics-y2AJzpKw.js} +2 -2
  20. package/dist/assets/{contextFileOpenGuard-rILslsBJ.js → contextFileOpenGuard-DYUFkrPT.js} +1 -1
  21. package/dist/assets/{gitStatusPredicates-D_31YElh.js → gitStatusPredicates-CbFfOlbV.js} +1 -1
  22. package/dist/assets/index-CrqlVJXp.js +8 -0
  23. package/dist/assets/{index-CXLVW_GG.js → index-DwJJarzh.js} +1 -1
  24. package/dist/assets/{isDiffPlainText-BX609Lau.js → isDiffPlainText-kXPOivsq.js} +1 -1
  25. package/dist/assets/{isFilePlainText-FgBWqu9b.js → isFilePlainText-BBIPqnLo.js} +1 -1
  26. package/dist/assets/{main-tv2uysSs.js → main-BshSYpnV.js} +3 -3
  27. package/dist/assets/{main-C_pL2r_k.js → main-RrPyfmCA.js} +2 -2
  28. package/dist/assets/{markdownCore-D3Ibaffd.js → markdownCore-BxXmpZtB.js} +1 -1
  29. package/dist/assets/{miniChat-B0xQlBzZ.js → miniChat-DRNgmC-q.js} +2 -2
  30. package/dist/assets/{mobile-BmSlVuhn.js → mobile-CdmgVKW4.js} +2 -2
  31. package/dist/assets/{renderElectronMiniChatApp-C4xZzAnn.js → renderElectronMiniChatApp-B80Jqq8b.js} +2 -2
  32. package/dist/assets/{renderMobileApp-Bi8wTGd5.js → renderMobileApp-CLcBvRiy.js} +3 -3
  33. package/dist/assets/{runtimeEndpointReset-B6_gFvBD.js → runtimeEndpointReset-DHHCemOu.js} +6 -6
  34. package/dist/assets/{runtimeSurface-egSD9pqj.js → runtimeSurface-C9kx2zfD.js} +1 -1
  35. package/dist/assets/{useAppFontEffects-C9QQrBIx.js → useAppFontEffects-Dp6vM-Zr.js} +83 -83
  36. package/dist/assets/{useFilesViewSearch-BTZutbn-.js → useFilesViewSearch-Bc8PTYrg.js} +2 -2
  37. package/dist/assets/{usePushVisibilityBeacon-BZcHxSo-.js → usePushVisibilityBeacon-DMcKyNtE.js} +1 -1
  38. package/dist/assets/{useSwitcherItems-Dw5tHQh8.js → useSwitcherItems-DEvsORZ_.js} +1 -1
  39. package/dist/assets/{vendor-base-ui-CdaWtC7e.js → vendor-base-ui-C60wdVnS.js} +1 -1
  40. package/dist/assets/{vendor-codemirror-language-data-0f_rLdj_.js → vendor-codemirror-language-data-DLimsiRH.js} +2 -2
  41. package/dist/assets/{vendor-floating-ui-dom-WyXykhNi.js → vendor-floating-ui-dom-Bkw82kL9.js} +1 -1
  42. package/dist/assets/{vendor-floating-ui-react-dom-BZOGXAGe.js → vendor-floating-ui-react-dom-KLmnYDaG.js} +1 -1
  43. package/dist/assets/{web-components-CYngz9Ml.js → web-components-05Oa3k7a.js} +3 -3
  44. package/dist/index.html +3 -3
  45. package/dist/mini-chat.html +2 -2
  46. package/dist/mobile.html +2 -2
  47. package/package.json +1 -1
  48. package/server/lib/pi/routes.js +12 -6
  49. package/server/lib/pi/routes.test.js +44 -16
  50. package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -1
  51. package/server/lib/pi/session-daemon/prompt-preflight.test.js +5 -1
  52. package/server/lib/pi/session-daemon/send-operation-dedup.test.js +15 -5
  53. package/server/lib/pi/session-daemon/send-operation-registry.js +26 -23
  54. package/server/lib/pi/session-daemon/send-operation-registry.test.js +26 -20
  55. package/server/lib/pi/session-daemon/session-daemon.js +24 -12
  56. package/server/lib/pi/ui-settings-store.js +6 -0
  57. package/server/lib/pi/ui-settings-store.test.js +16 -0
  58. package/dist/assets/SessionUnreadDot-CDRZswx-.js +0 -1
  59. package/dist/assets/SettingsView-hyAGp836.js +0 -2
  60. package/dist/assets/collapsible-DesjbW8a.js +0 -1
  61. package/dist/assets/index-BZpvAhrX.js +0 -8
@@ -1,7 +1,7 @@
1
- import{R as c}from"./vendor-react-B5Z1Mdn3.js";import{t as l,aF as W}from"./useAppFontEffects-C9QQrBIx.js";import{O as D}from"./index-BZpvAhrX.js";const v=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},M=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},N=e=>e.startsWith("/")||e.startsWith("//")||/^[A-Za-z]:\//.test(e),y=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,S=(e,t)=>{const s=u(t),n=u(e);if(!s||!n)return!1;const i=y(s),a=y(n);return a===i||a.startsWith(`${i}/`)},V=(e,t)=>{const s=u(t),n=u(e);if(!S(n,s))return[];const a=n.slice(s.length).replace(/^\//,"").split("/"),w=[];let r=s;for(let d=0;d<a.length-1;d++)r=r?`${r}/${a[d]}`:a[d],w.push(r);return w},Z=(e,t)=>{if(!t)return"";const s=u(t);if(!e||!S(s,e))return s;const n=s.slice(e.length);return n.startsWith("/")?n.slice(1):n},x=new Set(["node_modules"]),O=e=>x.has(e),L=e=>{const t=u(e);return t==="node_modules"||t.endsWith("/node_modules")||t.includes("/node_modules/")},q=e=>{const s=(e instanceof Error?e.message:String(e??"")).toLowerCase();return s.includes("is a directory")||s.includes("eisdir")},B=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")},H=2e5,U=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
1
+ import{R as c}from"./vendor-react-B5Z1Mdn3.js";import{t as l,aE as W}from"./useAppFontEffects-Dp6vM-Zr.js";import{P as D}from"./index-CrqlVJXp.js";const v=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},M=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},N=e=>e.startsWith("/")||e.startsWith("//")||/^[A-Za-z]:\//.test(e),y=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,S=(e,t)=>{const s=u(t),n=u(e);if(!s||!n)return!1;const i=y(s),a=y(n);return a===i||a.startsWith(`${i}/`)},V=(e,t)=>{const s=u(t),n=u(e);if(!S(n,s))return[];const a=n.slice(s.length).replace(/^\//,"").split("/"),w=[];let r=s;for(let d=0;d<a.length-1;d++)r=r?`${r}/${a[d]}`:a[d],w.push(r);return w},Z=(e,t)=>{if(!t)return"";const s=u(t);if(!e||!S(s,e))return s;const n=s.slice(e.length);return n.startsWith("/")?n.slice(1):n},x=new Set(["node_modules"]),q=e=>x.has(e),L=e=>{const t=u(e);return t==="node_modules"||t.endsWith("/node_modules")||t.includes("/node_modules/")},B=e=>{const s=(e instanceof Error?e.message:String(e??"")).toLowerCase();return s.includes("is a directory")||s.includes("eisdir")},H=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")},O=2e5,U=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
2
  `:`
3
3
  `},_=e=>e.replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`
5
5
  `),Q=(e,t)=>{const s=_(e);return t===`\r
6
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 w=c.useRef(null),[r,d]=c.useState(null),[f,R]=c.useState(null),[p,z]=c.useState(""),[h,C]=c.useState(!1),E=c.useCallback(($,m)=>{d($),R(m),z($==="rename"&&m.name||""),C(!1)},[]),b=c.useCallback(()=>d(null),[]),A=c.useCallback(async $=>{if($?.preventDefault(),!r||!f)return;const m=p.trim();if(r==="createFile"&&!m){l.error("Filename is required");return}if(r==="createFolder"&&!m){l.error("Folder name is required");return}if(r==="rename"&&!m){l.error("Name is required");return}if(r==="createFile"&&!e.writeFile){l.error("Write not supported");return}if(r==="rename"&&!e.rename){l.error("Rename not supported");return}if(r==="delete"&&!e.delete){l.error("Delete not supported");return}C(!0);try{if(r==="createFile"){const o=f.path,g=u(`${o?`${o}/`:""}${m}`);try{(await e.writeFile(g,"",{expectedRevision:null})).success&&(l.success("File created"),await n(o))}catch(F){if(F?.reason==="file-revision-conflict"||F?.name==="FileRevisionConflictError")l.error("File already exists");else throw F}}else if(r==="createFolder"){const o=f.path,g=u(`${o?`${o}/`:""}${m}`);(await e.createDirectory(g)).success&&(l.success("Folder created"),await n(o))}else{const o=f.path,g=o.split("/").slice(0,-1).join("/"),F=s===o||s.startsWith(`${o}/`);(r==="rename"?await e.rename(o,u(`${g?`${g}/`:""}${m}`)):await e.delete(o)).success&&(l.success(r==="rename"?"Renamed successfully":"Deleted successfully"),await n(g),t&&i(t,o),F&&a())}d(null)}catch{l.error("Operation failed")}finally{C(!1)}},[a,e,p,r,n,i,t,s,f]);return{operation:r,target:f,inputValue:p,setInputValue:z,submitting:h,inputRef:w,open:E,close:b,submit:A,capabilities:{canCreateFile:!!e.writeFile,canCreateFolder:!!e.createDirectory,canRename:!!e.rename,canDelete:!!e.delete}}}function K({directory:e,query:t,chrome:s,showGitignored:n}){const i=D(R=>R.searchFiles),a=W(t,200),[w,r]=c.useState([]),[d,f]=c.useState(!1);return c.useEffect(()=>{const R=a.trim();if(!e||!R){r([]),f(!1);return}let p=!1;return f(!0),i(e,R,s==="mobile"?40:150,{includeHidden:!0,respectGitignore:s==="desktop"&&!n,type:"file"}).then(z=>{p||r(z.filter(h=>n||!L(h.path)).map(h=>({name:h.name,path:u(h.path),type:"file",extension:h.extension,relativePath:h.relativePath})))}).catch(()=>{p||r([])}).finally(()=>{p||f(!1)}),()=>{p=!0}},[s,a,e,i,n]),{results:w,searching:d}}export{H as M,M as a,G as b,T as c,J as d,X as e,U as f,Z as g,u as h,N as i,Q as j,S as k,v as l,B as m,_ as n,q as o,V as p,O as s,y as t,K as u};
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 w=c.useRef(null),[r,d]=c.useState(null),[f,R]=c.useState(null),[p,z]=c.useState(""),[h,C]=c.useState(!1),E=c.useCallback(($,m)=>{d($),R(m),z($==="rename"&&m.name||""),C(!1)},[]),b=c.useCallback(()=>d(null),[]),A=c.useCallback(async $=>{if($?.preventDefault(),!r||!f)return;const m=p.trim();if(r==="createFile"&&!m){l.error("Filename is required");return}if(r==="createFolder"&&!m){l.error("Folder name is required");return}if(r==="rename"&&!m){l.error("Name is required");return}if(r==="createFile"&&!e.writeFile){l.error("Write not supported");return}if(r==="rename"&&!e.rename){l.error("Rename not supported");return}if(r==="delete"&&!e.delete){l.error("Delete not supported");return}C(!0);try{if(r==="createFile"){const o=f.path,g=u(`${o?`${o}/`:""}${m}`);try{(await e.writeFile(g,"",{expectedRevision:null})).success&&(l.success("File created"),await n(o))}catch(F){if(F?.reason==="file-revision-conflict"||F?.name==="FileRevisionConflictError")l.error("File already exists");else throw F}}else if(r==="createFolder"){const o=f.path,g=u(`${o?`${o}/`:""}${m}`);(await e.createDirectory(g)).success&&(l.success("Folder created"),await n(o))}else{const o=f.path,g=o.split("/").slice(0,-1).join("/"),F=s===o||s.startsWith(`${o}/`);(r==="rename"?await e.rename(o,u(`${g?`${g}/`:""}${m}`)):await e.delete(o)).success&&(l.success(r==="rename"?"Renamed successfully":"Deleted successfully"),await n(g),t&&i(t,o),F&&a())}d(null)}catch{l.error("Operation failed")}finally{C(!1)}},[a,e,p,r,n,i,t,s,f]);return{operation:r,target:f,inputValue:p,setInputValue:z,submitting:h,inputRef:w,open:E,close:b,submit:A,capabilities:{canCreateFile:!!e.writeFile,canCreateFolder:!!e.createDirectory,canRename:!!e.rename,canDelete:!!e.delete}}}function K({directory:e,query:t,chrome:s,showGitignored:n}){const i=D(R=>R.searchFiles),a=W(t,200),[w,r]=c.useState([]),[d,f]=c.useState(!1);return c.useEffect(()=>{const R=a.trim();if(!e||!R){r([]),f(!1);return}let p=!1;return f(!0),i(e,R,s==="mobile"?40:150,{includeHidden:!0,respectGitignore:s==="desktop"&&!n,type:"file"}).then(z=>{p||r(z.filter(h=>n||!L(h.path)).map(h=>({name:h.name,path:u(h.path),type:"file",extension:h.extension,relativePath:h.relativePath})))}).catch(()=>{p||r([])}).finally(()=>{p||f(!1)}),()=>{p=!0}},[s,a,e,i,n]),{results:w,searching:d}}export{O as M,M as a,G as b,T as c,J as d,X as e,U as f,Z as g,u as h,N as i,Q as j,S as k,v as l,H as m,_ as n,B as o,V as p,q as s,y as t,K as u};
@@ -1,5 +1,5 @@
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{f as b,bL as I,bM as k,g as C,a8 as V,bN as Y,bv as W,bO as K,bP as z,a as J,bQ as q,bR as D,bS as Q}from"./useAppFontEffects-C9QQrBIx.js";import{aL as Z,o as T,aM as X,a as ee,t as A,aN as te,l as se,aO as oe,R as U,i as P,b as ne}from"./index-BZpvAhrX.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(!b.getState().currentSessionId)return console.log("[ERROR] No active session"),null;const t=D();if(!t||t.length===0)return console.log("[ERROR] No messages in current session"),null;for(let o=t.length-1;o>=0;o--){const s=t[o];if(s.role==="assistant"){const l=(I(s.id)||[]).map(i=>{const g={id:i.id,type:i.type};return i.type==="text"?(g.text=i.text,g.textLength=i.text?.length||0):i.type==="tool"?(g.tool=i.tool,g.state=i.state?.status):(i.type==="step-start"||i.type==="step-finish")&&(g.isStepMarker=!0),g}),u=l.some(i=>i.type==="text"&&i.text&&i.text.trim().length>0),a=l.some(i=>i.type==="tool"),d=l.some(i=>i.type==="step-start"||i.type==="step-finish"),p=l.length===0,f=!u&&!a&&(!p||d),r={messageId:s.id,role:s.role,timestamp:s.time?.created||0,partsCount:l.length,parts:l,isEmpty:p,isEmptyResponse:f,raw:s};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:d,onlyStepMarkers:d&&!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)!"),d&&!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,n=80){return!e||typeof e!="string"||e.length<=n?e:e.substring(0,n)+"…"},truncateMessages(e){return e.map(n=>({...n,parts:(I(n.id)||[]).map(t=>{const o={...t};return"text"in t&&(o.text=this.truncateString(t.text)),"textPreview"in t&&(o.textPreview=this.truncateString(t.textPreview)),t.state&&(o.state={...t.state},"output"in t.state&&(o.state.output=this.truncateString(t.state.output)),"error"in t.state&&(o.state.error=this.truncateString(t.state.error)),t.state.metadata&&"preview"in t.state.metadata&&(o.state.metadata={...t.state.metadata,preview:this.truncateString(t.state.metadata.preview)})),o})}))},getAllMessages(e=!1){if(!b.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const o=D();return console.log(`[MESSAGES] Total messages in session: ${o.length}`),o.forEach((s,m)=>{const l=I(s.id)||[];console.log(`[${m}] ${s.role} - ${s.id} - ${l.length} parts`)}),e?this.truncateMessages(o):o},async getAppStatus(){const e=T.getState(),n=b.getState(),t=J.getState(),o=e.currentDirectory||null,s=C().getState(),m=s.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 d=(()=>{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)}}})(),p=A(),f=typeof window<"u"&&!!window.__PICHAMBER_ELECTRON__,r=async c=>{try{return await c.json()}catch{return null}},g=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 w={isGitRepo:null};if(o)try{const c=A()?.git.checkIsGitRepository??te;w.isGitRepo=await c(o)}catch(c){w={isGitRepo:null,error:c instanceof Error?c.message:String(c)}}const E=t.projects.map(c=>({id:c.id,path:c.path,label:c.label})),S={runtime:{platform:p?.runtime?.platform??null,isDesktop:f,hasRuntimeApis:!!p,desktopServerOrigin:null},location:typeof window<"u"?{href:window.location?.href??null,origin:window.location?.origin??null}:null,directories:{currentDirectory:o,piDirectory:m,homeDirectory:e.homeDirectory||null,isHomeReady:e.isHomeReady,hasPersistedDirectory:e.hasPersistedDirectory,isSwitchingDirectory:e.isSwitchingDirectory},projects:{total:t.projects.length,activeProjectId:t.activeProjectId,samples:E},sessions:{total:l.length,currentSessionId:n.currentSessionId,uniqueDirectories:u.size,directorySamples:Array.from(u).slice(0,5),directoryCounts:a},git:w,localStorage:d,pi:{health:R,connection:s.connection},pichamber:{settingsInfo:g},recentSendFailures:B(),currentSessionDirectoryResolution:n.currentSessionId?this.diagnoseSessionDirectory(n.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 n=b.getState(),t=e??n.currentSessionId;if(!t)return console.log("[ERROR] No session selected and no session id passed"),null;const o=Y(t),s=W().find(g=>g.id===t),m=s?.directory??null,l=t===n.currentSessionId?n.currentSessionDirectory:null,a=K({session:s??null,currentDirectory:l}),d=n.getDirectoryForSession(t),p=z(t),f=[["owning child store",o],["session record",m],["current selection",l],["runtime memory",p.runtime],["persisted memory",p.persisted]],r=d?f.find(([,g])=>g&&g!==d):void 0,i={sessionId:t,isCurrentSession:t===n.currentSessionId,routedDirectory:d,resolvedFrom:a.source,conflict:r?{source:r[0],directory:r[1]}:null,sources:Q(),details:{owningChildStore:o,sessionRecordDirectory:m,sessionIndexed:!!s,currentSessionDirectory:n.currentSessionDirectory,rememberedForRuntime:p.runtime,persistedAcrossRestarts:p.persisted,activeDirectory:T.getState().currentDirectory??null,piSessionDirectory:C().getState().directory??null}};return console.log("[DEBUG] Session directory resolution:",i),r?console.warn(`[ALERT] Directory sources disagree: routing to "${d}" while "${r[1]}" came from ${r[0]}.`):d?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 n=e.isEmpty||e.isEmptyResponse;return n?(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!"),n},getStreamingState(){const e=b.getState(),n=C().getState().reducer.bySession,t=new Map;for(const[s,m]of n)t.set(s,k(m));const o=e.currentSessionId?t.get(e.currentSessionId)??null:null;return console.log("[STREAM] Streaming State:",{streamingMessageId:o,streamingMessageIds:Array.from(t.entries())}),{streamingMessageId:o,streamingMessageIds:t}},findEmptyMessages(){if(!b.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const o=D().filter(s=>s.role==="assistant").filter(s=>{const m=I(s.id)||[],l=m.some(a=>a.type==="text"&&a.text&&a.text.trim().length>0),u=m.some(a=>a.type==="tool");return m.length===0||!l&&!u});return console.log(`[INSPECT] Found ${o.length} empty assistant messages`),o.forEach((s,m)=>{const l=I(s.id)||[];console.log(`[${m}] Empty message:`,{messageId:s.id,partsCount:l.length,provider:s.providerID,model:s.modelID,timestamp:s.time?.created})}),o},showRetryHelp(){console.log(`[DEBUG] How to handle empty Claude responses:
2
+ import{e as b,bK as I,bL as k,g as C,a7 as V,bM as Y,bu as W,bN as K,bO as z,a as J,bP as q,bQ as D,bR as Q}from"./useAppFontEffects-Dp6vM-Zr.js";import{aM as Z,q as T,aN as X,a as ee,v as A,aO as te,m as se,aP as oe,S as U,i as P,b as ne}from"./index-CrqlVJXp.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(!b.getState().currentSessionId)return console.log("[ERROR] No active session"),null;const t=D();if(!t||t.length===0)return console.log("[ERROR] No messages in current session"),null;for(let o=t.length-1;o>=0;o--){const s=t[o];if(s.role==="assistant"){const l=(I(s.id)||[]).map(i=>{const g={id:i.id,type:i.type};return i.type==="text"?(g.text=i.text,g.textLength=i.text?.length||0):i.type==="tool"?(g.tool=i.tool,g.state=i.state?.status):(i.type==="step-start"||i.type==="step-finish")&&(g.isStepMarker=!0),g}),u=l.some(i=>i.type==="text"&&i.text&&i.text.trim().length>0),a=l.some(i=>i.type==="tool"),d=l.some(i=>i.type==="step-start"||i.type==="step-finish"),p=l.length===0,f=!u&&!a&&(!p||d),r={messageId:s.id,role:s.role,timestamp:s.time?.created||0,partsCount:l.length,parts:l,isEmpty:p,isEmptyResponse:f,raw:s};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:d,onlyStepMarkers:d&&!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)!"),d&&!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,n=80){return!e||typeof e!="string"||e.length<=n?e:e.substring(0,n)+"…"},truncateMessages(e){return e.map(n=>({...n,parts:(I(n.id)||[]).map(t=>{const o={...t};return"text"in t&&(o.text=this.truncateString(t.text)),"textPreview"in t&&(o.textPreview=this.truncateString(t.textPreview)),t.state&&(o.state={...t.state},"output"in t.state&&(o.state.output=this.truncateString(t.state.output)),"error"in t.state&&(o.state.error=this.truncateString(t.state.error)),t.state.metadata&&"preview"in t.state.metadata&&(o.state.metadata={...t.state.metadata,preview:this.truncateString(t.state.metadata.preview)})),o})}))},getAllMessages(e=!1){if(!b.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const o=D();return console.log(`[MESSAGES] Total messages in session: ${o.length}`),o.forEach((s,m)=>{const l=I(s.id)||[];console.log(`[${m}] ${s.role} - ${s.id} - ${l.length} parts`)}),e?this.truncateMessages(o):o},async getAppStatus(){const e=T.getState(),n=b.getState(),t=J.getState(),o=e.currentDirectory||null,s=C().getState(),m=s.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 d=(()=>{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)}}})(),p=A(),f=typeof window<"u"&&!!window.__PICHAMBER_ELECTRON__,r=async c=>{try{return await c.json()}catch{return null}},g=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 w={isGitRepo:null};if(o)try{const c=A()?.git.checkIsGitRepository??te;w.isGitRepo=await c(o)}catch(c){w={isGitRepo:null,error:c instanceof Error?c.message:String(c)}}const E=t.projects.map(c=>({id:c.id,path:c.path,label:c.label})),S={runtime:{platform:p?.runtime?.platform??null,isDesktop:f,hasRuntimeApis:!!p,desktopServerOrigin:null},location:typeof window<"u"?{href:window.location?.href??null,origin:window.location?.origin??null}:null,directories:{currentDirectory:o,piDirectory:m,homeDirectory:e.homeDirectory||null,isHomeReady:e.isHomeReady,hasPersistedDirectory:e.hasPersistedDirectory,isSwitchingDirectory:e.isSwitchingDirectory},projects:{total:t.projects.length,activeProjectId:t.activeProjectId,samples:E},sessions:{total:l.length,currentSessionId:n.currentSessionId,uniqueDirectories:u.size,directorySamples:Array.from(u).slice(0,5),directoryCounts:a},git:w,localStorage:d,pi:{health:R,connection:s.connection},pichamber:{settingsInfo:g},recentSendFailures:B(),currentSessionDirectoryResolution:n.currentSessionId?this.diagnoseSessionDirectory(n.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 n=b.getState(),t=e??n.currentSessionId;if(!t)return console.log("[ERROR] No session selected and no session id passed"),null;const o=Y(t),s=W().find(g=>g.id===t),m=s?.directory??null,l=t===n.currentSessionId?n.currentSessionDirectory:null,a=K({session:s??null,currentDirectory:l}),d=n.getDirectoryForSession(t),p=z(t),f=[["owning child store",o],["session record",m],["current selection",l],["runtime memory",p.runtime],["persisted memory",p.persisted]],r=d?f.find(([,g])=>g&&g!==d):void 0,i={sessionId:t,isCurrentSession:t===n.currentSessionId,routedDirectory:d,resolvedFrom:a.source,conflict:r?{source:r[0],directory:r[1]}:null,sources:Q(),details:{owningChildStore:o,sessionRecordDirectory:m,sessionIndexed:!!s,currentSessionDirectory:n.currentSessionDirectory,rememberedForRuntime:p.runtime,persistedAcrossRestarts:p.persisted,activeDirectory:T.getState().currentDirectory??null,piSessionDirectory:C().getState().directory??null}};return console.log("[DEBUG] Session directory resolution:",i),r?console.warn(`[ALERT] Directory sources disagree: routing to "${d}" while "${r[1]}" came from ${r[0]}.`):d?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 n=e.isEmpty||e.isEmptyResponse;return n?(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!"),n},getStreamingState(){const e=b.getState(),n=C().getState().reducer.bySession,t=new Map;for(const[s,m]of n)t.set(s,k(m));const o=e.currentSessionId?t.get(e.currentSessionId)??null:null;return console.log("[STREAM] Streaming State:",{streamingMessageId:o,streamingMessageIds:Array.from(t.entries())}),{streamingMessageId:o,streamingMessageIds:t}},findEmptyMessages(){if(!b.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const o=D().filter(s=>s.role==="assistant").filter(s=>{const m=I(s.id)||[],l=m.some(a=>a.type==="text"&&a.text&&a.text.trim().length>0),u=m.some(a=>a.type==="tool");return m.length===0||!l&&!u});return console.log(`[INSPECT] Found ${o.length} empty assistant messages`),o.forEach((s,m)=>{const l=I(s.id)||[];console.log(`[${m}] Empty message:`,{messageId:s.id,partsCount:l.length,provider:s.providerID,model:s.modelID,timestamp:s.time?.created})}),o},showRetryHelp(){console.log(`[DEBUG] How to handle empty Claude responses:
3
3
  `),console.log("1. Check the last message:"),console.log(` __piDebug.getLastAssistantMessage()
4
4
  `),console.log("2. Find all empty messages in session:"),console.log(` __piDebug.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)
@@ -1 +1 @@
1
- import{R as f}from"./vendor-react-B5Z1Mdn3.js";import{aD as B,a as D,b as v,c as z,aI as L,d as g,r as j}from"./useAppFontEffects-C9QQrBIx.js";const M=50,p=n=>{if(!n)return null;const s=n.replace(/\\/g,"/");return s==="/"?"/":s.replace(/\/+$/,"")},k=(n,s)=>{const a=p(n),c=p(s);return!a||!c?!1:a===c||a.startsWith(`${c}/`)},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:a=null,maxParents:c=M}=s,l=B({archived:!1}),P=D(t=>t.projects),u=v(t=>t.ids),d=z(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)=>g(r,o,u,d))});const y=l.filter(e=>!e.time?.archived).filter(e=>!e.parentID).filter(e=>{if(!a)return!0;const r=j(e);return h(r)?.id===a}).sort((e,r)=>g(e,r,u,d)).slice(0,c),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),I=O(o),m=(r?S.get(r):void 0)??null;return{node:i(e),projectId:o?.id??null,groupDirectory:r,secondaryMeta:{projectLabel:I,branchLabel:m&&m!==I?m:null}}})},[l,S,n,h,c,u,a,d])};export{w as u};
1
+ import{R as f}from"./vendor-react-B5Z1Mdn3.js";import{aC as B,a as v,b as z,c as D,aH as L,d as I,r as j}from"./useAppFontEffects-Dp6vM-Zr.js";const M=50,p=n=>{if(!n)return null;const s=n.replace(/\\/g,"/");return s==="/"?"/":s.replace(/\/+$/,"")},k=(n,s)=>{const a=p(n),c=p(s);return!a||!c?!1:a===c||a.startsWith(`${c}/`)},O=n=>{if(!n)return null;const s=n.label?.trim();return s||(n.path.split(/[\\/]/).filter(Boolean).at(-1)??n.path)},N=(n,s={})=>{const{scopeProjectId:a=null,maxParents:c=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(!a)return!0;const r=j(e);return h(r)?.id===a}).sort((e,r)=>I(e,r,u,d)).slice(0,c),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,c,u,a,d])};export{N as u};