@pi-chamber/web 1.0.6-rc.4 → 1.0.6-rc.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.
- package/dist/assets/{DiagramView-BZ--w7Lh.js → DiagramView-BxBfOrN5.js} +1 -1
- package/dist/assets/{DiffView-Dtn6otnT.js → DiffView-CSC9GMrb.js} +3 -3
- package/dist/assets/{FileSaveConflictDialog-p1ik30al.js → FileSaveConflictDialog-C_MNWp6w.js} +1 -1
- package/dist/assets/{FilesView-D0Z0VmQm.js → FilesView-DeN6KmNt.js} +4 -4
- package/dist/assets/{GitHubDetailScaffold-a27RksFo.js → GitHubDetailScaffold-CrtJwlqV.js} +2 -2
- package/dist/assets/{GitHubLinkPicker-B0CfzNfk.js → GitHubLinkPicker-g6w8K95J.js} +1 -1
- package/dist/assets/GitHubListPrimitives-lAi2ywE3.js +1 -0
- package/dist/assets/{GitView-BNkoaVYl.js → GitView-D9_em8Vx.js} +5 -5
- package/dist/assets/IssuesSurface-DCiHe6TE.js +7 -0
- package/dist/assets/{JsonTreeView-CEiJsFnP.js → JsonTreeView-D64mTfTx.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-418ChlsN.js → MarkdownRendererImpl-DwE90rTA.js} +3 -3
- package/dist/assets/PatchDiff-CcIwURzW.js +1 -0
- package/dist/assets/{PierreDiffViewer-CkuyY9ne.js → PierreDiffViewer-tN7awL0-.js} +2 -2
- package/dist/assets/PullRequestsSurface-iX4r3QlS.js +2 -0
- package/dist/assets/{SessionSwitcherContent-DkfjRgwv.js → SessionSwitcherContent-DrrM0ObM.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-CEw8BEs6.js → SessionSwitcherDropdown-B9_0JwY7.js} +2 -2
- package/dist/assets/SessionUnreadDot-Bpgp2gLO.js +1 -0
- package/dist/assets/SettingsView-C4hec1iy.js +6 -0
- package/dist/assets/{SettingsWindow-D03Z9QyW.js → SettingsWindow-Bepcpy0R.js} +1 -1
- package/dist/assets/{StickyHorizontalScrollbar-CONTbZgX.js → StickyHorizontalScrollbar-DNsbTLS7.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DibddNlz.js → ToolOutputDialog-Dl9-vpvL.js} +5 -5
- package/dist/assets/{ToolPartDiffPreview-Bx7T1M2f.js → ToolPartDiffPreview-CLlHEPYD.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-BY-mDMT8.js → VirtualizedFileDiff-D9OpUpR3.js} +4 -4
- package/dist/assets/{Virtualizer-cIf8dSOQ.js → Virtualizer-okhy9Aq3.js} +1 -1
- package/dist/assets/{collapsible-BhQdnj8G.js → collapsible-ZT74WYMA.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-CzkFqhaU.js → computeVirtualFileMetrics-CDv_UBXL.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-CjCOK8EB.js → contextFileOpenGuard-BJ2sAhZG.js} +1 -1
- package/dist/assets/{fileTreeStatus-CPTpyKOV.js → fileTreeStatus-B2PDFobt.js} +2 -2
- package/dist/assets/{gitStatusPredicates-_GNbGCCb.js → gitStatusPredicates-BDdOjxH_.js} +1 -1
- package/dist/assets/{githubLink-CwIFogWd.js → githubLink-wwC2_C_9.js} +2 -2
- package/dist/assets/index-BaLCg7tL.css +1 -0
- package/dist/assets/{index-DjOKW10B.js → index-MXKT8Ir9.js} +1 -1
- package/dist/assets/index-fmzQmSSv.js +11 -0
- package/dist/assets/{main-C51a3z3b.js → main-CnW7qm2b.js} +2 -2
- package/dist/assets/{main-1wmEZ4Is.js → main-DmHVgAh0.js} +4 -4
- package/dist/assets/{markdownCore-Dsr6dY5C.js → markdownCore-DOFhfL5i.js} +2 -2
- package/dist/assets/{miniChat-DCxCx1fF.js → miniChat-D_Wl2jlx.js} +2 -2
- package/dist/assets/{mobile-D6Ac2Mu3.js → mobile-Cl-KcfGW.js} +2 -2
- package/dist/assets/{nativeFileSave-P_Eg5Dgb.js → nativeFileSave-B4Rg6n8u.js} +1 -1
- package/dist/assets/{pi-session-focus-preference-DjDyjZ1C.js → pi-session-focus-preference-BqEU9Iq6.js} +3 -3
- package/dist/assets/{renderDiffWithHighlighter-CK_inhQE.js → renderDiffWithHighlighter-U7WjeGm9.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-wBNgFl0U.js → renderElectronMiniChatApp-BJxNc9OP.js} +2 -2
- package/dist/assets/{renderFileWithHighlighter-B_PFeRW5.js → renderFileWithHighlighter-DiwpFgMp.js} +1 -1
- package/dist/assets/{renderMobileApp-B3mhxGnb.js → renderMobileApp-d5KpyvBc.js} +3 -3
- package/dist/assets/runtimeEndpointReset-Cd4yJDsk.js +62 -0
- package/dist/assets/{runtimeSurface-C3YPOBlg.js → runtimeSurface-X62LLBLv.js} +1 -1
- package/dist/assets/{useAppFontEffects-CoFst31H.js → useAppFontEffects-FKnY7Fe2.js} +92 -92
- package/dist/assets/useGitHubRemoteSearch-4QMXIODG.js +1 -0
- package/dist/assets/{useSwitcherItems-DHCCg4GF.js → useSwitcherItems-DtCNsq8u.js} +1 -1
- package/dist/assets/{vendor-aparajita-capacitor-secure-storage-B9_YeZyx.js → vendor-aparajita-capacitor-secure-storage-DVZvgYu4.js} +1 -1
- package/dist/assets/{vendor-base-ui-CKSCJw-4.js → vendor-base-ui-BCqPBzDj.js} +1 -1
- package/dist/assets/{vendor-boot-Ciu-Edvy.js → vendor-boot-3SaHYVb1.js} +1 -1
- package/dist/assets/{vendor-capacitor-app-Bpy_aPMq.js → vendor-capacitor-app-NbQ-WiPS.js} +1 -1
- package/dist/assets/{vendor-capacitor-keyboard-DO8AIjrZ.js → vendor-capacitor-keyboard-CgrHt8iN.js} +1 -1
- package/dist/assets/{vendor-capacitor-status-bar-SQkytwUW.js → vendor-capacitor-status-bar-CWt0OF5t.js} +1 -1
- package/dist/assets/{vendor-codemirror-autocomplete-CInQsE8a.js → vendor-codemirror-autocomplete-WThuuUAz.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-QbsN3LGE.js → vendor-codemirror-lang-angular-BbLGCxF6.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-BT5U7lxV.js → vendor-codemirror-lang-cpp-Cceks-9O.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-dF-Dxbty.js → vendor-codemirror-lang-css-D1wpUg3Z.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-e4dp1bar.js → vendor-codemirror-lang-go-Cv0zXHHM.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-DKcbBVQ4.js → vendor-codemirror-lang-html-DbL8oT9H.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-CB2-FWv6.js → vendor-codemirror-lang-java-CNugenuC.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-B1zJk7xE.js → vendor-codemirror-lang-javascript-Bx_FIyZF.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-BsERjdSd.js → vendor-codemirror-lang-jinja-DDGjB3Zq.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-C0pZ0NhY.js → vendor-codemirror-lang-json-DIvqf9Pb.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-_N9HmR4h.js → vendor-codemirror-lang-less-D8r9dGG1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-D02xJRCD.js → vendor-codemirror-lang-liquid-B24mguYi.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-_6ojeUuZ.js → vendor-codemirror-lang-markdown-v3yG2sbf.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-DguCnbJA.js → vendor-codemirror-lang-php-BcZGalqy.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-Byr5gw5f.js → vendor-codemirror-lang-python-b-JqEwQy.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-DN6Wh0eK.js → vendor-codemirror-lang-rust-B1uZxDW-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-DOlEW7q1.js → vendor-codemirror-lang-sass-DqPrngKp.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-BJzE9Dby.js → vendor-codemirror-lang-sql-UyCnpt-k.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-DR8E-2nr.js → vendor-codemirror-lang-vue-xDwYkovV.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-n6lcDH5S.js → vendor-codemirror-lang-wast-CF3169p_.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-Cf2lmlmY.js → vendor-codemirror-lang-xml-FCtVhuOb.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-DSR_E0yh.js → vendor-codemirror-lang-yaml-g0sPmAnv.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-CSid5JuX.js → vendor-codemirror-language-data-B03xgzP2.js} +2 -2
- package/dist/assets/{vendor-codemirror-search-8lY3lt6q.js → vendor-codemirror-search-Dw3Wpu15.js} +1 -1
- package/dist/assets/{vendor-lezer-cpp-DZYTDKiD.js → vendor-lezer-cpp-Cu3E-KUI.js} +1 -1
- package/dist/assets/{vendor-lezer-css-6qV4fYNQ.js → vendor-lezer-css-Cb8vp67u.js} +1 -1
- package/dist/assets/{vendor-lezer-go-BDi_Iblq.js → vendor-lezer-go-BTsIaOm7.js} +1 -1
- package/dist/assets/{vendor-lezer-html-BjqcY-oJ.js → vendor-lezer-html-UQMsUwj-.js} +1 -1
- package/dist/assets/{vendor-lezer-java-J2BXqz1h.js → vendor-lezer-java-BIWrFrAx.js} +1 -1
- package/dist/assets/{vendor-lezer-javascript-CiQ9F8yX.js → vendor-lezer-javascript-BH2Etgoy.js} +1 -1
- package/dist/assets/{vendor-lezer-json-BxN83KKR.js → vendor-lezer-json-CE-QUCwM.js} +1 -1
- package/dist/assets/{vendor-lezer-lr-BVsDua_K.js → vendor-lezer-lr-HY6Yc0Vr.js} +1 -1
- package/dist/assets/{vendor-lezer-markdown-BkMtRQ3X.js → vendor-lezer-markdown-xFL3Evwf.js} +1 -1
- package/dist/assets/{vendor-lezer-php-B3XqnXdP.js → vendor-lezer-php-Cr_mQGrG.js} +1 -1
- package/dist/assets/{vendor-lezer-python-D342CidI.js → vendor-lezer-python-BNRFWCb0.js} +1 -1
- package/dist/assets/{vendor-lezer-rust-Dbfg_4LA.js → vendor-lezer-rust-BvfOK5cU.js} +1 -1
- package/dist/assets/{vendor-lezer-sass-ClxPaFt1.js → vendor-lezer-sass-qoxiLisk.js} +1 -1
- package/dist/assets/{vendor-lezer-xml-I_S6FQ1u.js → vendor-lezer-xml--x8SSpqU.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-COA6HWLP.js → vendor-lezer-yaml-BDo1JaEr.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-7IE2zVmx.js → vendor-replit-codemirror-vim-D1Fe7FiY.js} +1 -1
- package/dist/assets/{web-components-CzkvK_V5.js → web-components-D5QImbWv.js} +4 -4
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/lib/pi/archive-store.js +38 -10
- package/server/lib/pi/archive-store.test.js +10 -0
- package/server/lib/pi/routes.js +65 -18
- package/server/lib/pi/routes.test.js +189 -8
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +5 -1
- package/server/lib/pi/session-daemon/session-daemon-engines.test.js +18 -0
- package/server/lib/pi/session-daemon/session-daemon.js +24 -1
- package/server/lib/pi/session-shelf-store.js +155 -84
- package/server/lib/pi/session-shelf-store.test.js +134 -33
- package/server/lib/pi/ui-settings-store.js +59 -0
- package/server/lib/pi/ui-settings-store.test.js +105 -6
- package/dist/assets/GitHubListPrimitives-LFdR70l6.js +0 -1
- package/dist/assets/IssuesSurface-D4kD7_VW.js +0 -7
- package/dist/assets/PatchDiff-BtOv_oLB.js +0 -1
- package/dist/assets/PullRequestsSurface-PML07zr-.js +0 -2
- package/dist/assets/SessionUnreadDot-DXUn8-ss.js +0 -1
- package/dist/assets/SettingsView-BvUeFUqw.js +0 -6
- package/dist/assets/index-Cfrwo5uQ.js +0 -11
- package/dist/assets/index-D7k62S9M.css +0 -1
- package/dist/assets/runtimeEndpointReset-D8lAOCUB.js +0 -62
- package/dist/assets/useGitHubRemoteSearch-C0-6hhMJ.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as c}from"./vendor-boot-
|
|
1
|
+
import{j as c}from"./vendor-boot-3SaHYVb1.js";import{R as t}from"./vendor-react-Bz1tRBxM.js";import{z as $,t as d,I as B}from"./useAppFontEffects-FKnY7Fe2.js";import{h as V,b as A,p as ee,cG as W}from"./index-fmzQmSSv.js";import{b as te,D as re,F as ne}from"./FileSaveConflictDialog-C_MNWp6w.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-X62LLBLv.js";import"./nativeFileSave-B4Rg6n8u.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./vendor-react-drawio-IYnLUY5N.js";const se=l=>l.split("/").pop()||l;function xe(){const{files:l}=$(),[x,k]=t.useState(null),[L,R]=t.useState(""),[M,E]=t.useState(!0),[b,h]=t.useState(null),[m,F]=t.useState(!1),[U,p]=t.useState(!1),[j,P]=t.useState(!1),[q,H]=t.useState(0),g=t.useRef(void 0),C=t.useRef(""),v=t.useRef(0),S=t.useRef(0),y=t.useRef(0),D=t.useRef(null),I=t.useRef(!0),w=t.useRef(null),T=V(e=>e.pendingDiagramFile);t.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const i=t.useCallback((e,n,s)=>I.current&&v.current===e&&A()===n&&w.current===s,[]),z=t.useCallback(async e=>{const n=v.current+1;v.current=n;const s=A(),u=l?.readFile;S.current+=1,y.current+=1,E(!0),k(e),w.current=e,h(null),p(!1),P(!1),F(!1);try{const r=await u?.(e);if(!i(n,s,e))return;if(!r){d.error("Failed to read file"),k(null),w.current=null,C.current="",R(""),g.current=void 0,E(!1);return}C.current=r.content,R(r.content),g.current=r.revision}catch(r){if(!i(n,s,e))return;d.error(r instanceof Error?r.message:"Failed to read file"),k(null),w.current=null,C.current="",R(""),g.current=void 0,E(!1);return}finally{i(n,s,e)&&E(!1)}},[l,i]);t.useEffect(()=>ee(()=>{if(v.current+=1,g.current=void 0,S.current+=1,y.current+=1,!I.current)return;h(null),p(!1),P(!1),F(!1);const e=w.current;e&&z(e)}),[z]),t.useEffect(()=>{if(!T)return;const e=V.getState().consumePendingDiagramFile();e&&z(e)},[z,T]);const K=t.useCallback(async(e,n,s,u,r,o)=>{let a=null,f=s,G=u;try{if(G){const N=await l?.readFile?.(e);if(!i(r,o,e))return;N&&(a=N.content??null,typeof N.revision=="string"&&(f=N.revision),G=N.exists!==!1)}}catch{if(!i(r,o,e))return}i(r,o,e)&&(h({path:e,displayPath:se(e),exists:G,currentRevision:f,currentContent:a,dirtyContent:n,runtimeKey:o}),p(!1))},[l,i]),X=t.useCallback(async(e,n,s,u,r)=>{const o=await l?.writeFile?.(e,n,te(g.current,s?!0:void 0));return i(u,r,e)?{stale:!1,success:!!o?.success,revision:o?.revision}:{stale:!0}},[l,i]),O=t.useCallback((e,n)=>{C.current=e,typeof n<"u"&&(g.current=n),D.current?.getXml()===e&&R(e)},[]),J=t.useCallback(async()=>{const e=D.current?.getXml();if(!x||!l?.writeFile||!e||e===C.current||j||m)return;const n=v.current,s=A(),u=x,r=e,o=S.current+1;S.current=o,P(!0);try{const a=await X(u,r,!1,n,s);if(a.stale)return;if(!a.success){d.error("Failed to write file");return}O(r,a.revision)}catch(a){if(!i(n,s,u))return;if(W(a)){await K(u,r,a.currentRevision??null,a.exists,n,s);return}d.error(a instanceof Error?a.message:"Save failed")}finally{S.current===o&&P(!1)}},[O,x,l,i,m,j,K,X]),Q=t.useCallback(async()=>{const e=b;if(!e||m||!i(v.current,e.runtimeKey,e.path))return;const n=v.current,s=e.runtimeKey;if(!e.exists){k(null),w.current=null,C.current="",R(""),g.current=void 0,h(null),p(!1);return}const u=y.current+1;y.current=u,F(!0);try{const r=await l?.readFile?.(e.path);if(!i(n,s,e.path))return;if(!r){d.error("Failed to read file");return}C.current=r.content??"",R(r.content??""),g.current=r.revision,H(o=>o+1),h(null),p(!1)}catch(r){if(!i(n,s,e.path))return;d.error(r instanceof Error?r.message:"Failed to read file")}finally{y.current===u&&F(!1)}},[l,i,m,b]),Y=t.useCallback(async()=>{const e=b;if(!e||m||!i(v.current,e.runtimeKey,e.path))return;const n=v.current,s=e.runtimeKey;if(!l?.writeFile){d.error("Saving not supported");return}const o=D.current?.getXml()??e.dirtyContent;if(!o){d.error("Failed to write file");return}const a=y.current+1;y.current=a,F(!0);try{const f=await X(e.path,o,!0,n,s);if(f.stale)return;if(!f.success){d.error("Failed to write file");return}O(o,f.revision),h(null),p(!1)}catch(f){if(!i(n,s,e.path))return;if(W(f)){await K(e.path,o,f.currentRevision??e.currentRevision,f.exists,n,s);return}d.error(f instanceof Error?f.message:"Save failed")}finally{y.current===a&&F(!1)}},[O,l,i,m,K,X,b]),Z=t.useCallback(()=>{m||j||(h(null),p(!1))},[m,j]),_=x?x.split("/").pop()||x:"";return x?M?c.jsx("div",{className:"flex h-full items-center justify-center p-3",children:c.jsx(B,{name:"loader-4",className:"size-4 animate-spin"})}):c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[c.jsx(B,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:_}),c.jsx("button",{type:"button",onClick:()=>{J()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Save diagram",children:c.jsx(B,{name:"save-3",className:"size-4"})}),c.jsx("button",{type:"button",onClick:()=>V.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Close diagram view",children:c.jsx(B,{name:"close",className:"size-4"})})]}),c.jsx("div",{className:"flex-1 min-h-0",children:c.jsx(re,{ref:D,xml:L,className:"h-full"},q)}),c.jsx(ne,{open:!!b,conflict:b,isResolving:m||j,showCompare:U,onToggleCompare:()=>p(e=>!e),onReload:()=>{Q()},onOverwrite:()=>{Y()},onClose:Z})]}):c.jsx("div",{className:"flex h-full items-center justify-center p-3",children:c.jsx("div",{className:"typography-ui text-muted-foreground",children:"Pick a file from the tree."})})}export{xe as DiagramView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as t,aP as Rt}from"./vendor-boot-
|
|
1
|
+
import{j as t,aP as Rt}from"./vendor-boot-3SaHYVb1.js";import{R as r}from"./vendor-react-Bz1tRBxM.js";import{f as se,h as Y,b as ot,n as Je}from"./index-fmzQmSSv.js";import{eu as Et,ea as At,es as Tt,aP as lt,cT as ct,dI as Mt,dd as Re,B as Le,I as G,z as ut,bj as ce,t as dt,ek as ft,a$ as It,b0 as Pt,b1 as $t,bv as Qe,dz as Wt,ev as _t,ew as Bt,y as zt,as as Ot,bF as Gt,cU as Ht,e7 as Ut,h as Vt,ba as qt,az as Kt,aR as Xt,aS as Yt,aT as Jt}from"./useAppFontEffects-FKnY7Fe2.js";import{d as pt,b as ht,i as Ge,a as He,c as Qt,C as Zt}from"./gitStatusPredicates-BDdOjxH_.js";import{p as en}from"./VirtualizedFileDiff-D9OpUpR3.js";import{P as tn}from"./PierreDiffViewer-tN7awL0-.js";import{v as nn,g as sn}from"./contextFileOpenGuard-BJ2sAhZG.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./runtimeSurface-X62LLBLv.js";import"./nativeFileSave-B4Rg6n8u.js";import"./web-components-D5QImbWv.js";import"./computeVirtualFileMetrics-CDv_UBXL.js";import"./vendor-shiki-BEwTOAFg.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-engine-javascript-DL394yyj.js";import"./vendor-oniguruma-to-es-DgwFOwdE.js";import"./vendor-oniguruma-parser-BrbMHgHx.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./renderDiffWithHighlighter-U7WjeGm9.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-DNsbTLS7.js";import"./runtimeEndpointReset-Cd4yJDsk.js";import"./SessionUnreadDot-Bpgp2gLO.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./appThemeRegistry-Ca8eGRB9.js";import"./registerCustomTheme-C-h6lsYW.js";function rn(s,n=10){const e=[];let i;for(const l of s.split(`
|
|
2
2
|
`)){const f=l.match(Et);if(f!=null){i!=null&&(i.hunkLines.length>0&&(Pe(i,n,"trailing"),ze(i,e)),i=void 0);const d=parseInt(f[3]),b=parseInt(f[1]),g=parseInt(f[4]??"1"),c=parseInt(f[2]??"1");isNaN(d)||isNaN(b)||isNaN(g)||isNaN(c)?e.push(l):i={additionStart:d,deletionStart:b,additionCount:0,deletionCount:0,hunkLines:[],contextLines:[]};continue}if(i==null){e.push(l);continue}if(l.startsWith(" "))i.contextLines.push(l);else if(l!==""){if(i.hunkLines.length>0&&i.contextLines.length>n*2){const d=i.contextLines.length-n*2,b=i.contextLines.slice(-n);Pe(i,n,"trailing");const{additionCount:g,deletionCount:c}=i;ze(i,e),i={additionStart:i.additionStart+g+d,deletionStart:i.deletionStart+c+d,deletionCount:0,additionCount:0,contextLines:b,hunkLines:[]}}Pe(i,n,i.hunkLines.length===0?"leading":"before-change"),i.hunkLines.push(l),l.startsWith("+")?i.additionCount+=1:l.startsWith("-")&&(i.deletionCount+=1)}}i!=null&&i.hunkLines.length>0&&(Pe(i,n,"trailing"),ze(i,e));const o=e.join(`
|
|
3
3
|
`);return s.endsWith(`
|
|
4
4
|
`)?`${o}
|
|
@@ -7,7 +7,7 @@ import{j as t,aP as Rt}from"./vendor-boot-Ciu-Edvy.js";import{R as r}from"./vend
|
|
|
7
7
|
--- ${s}
|
|
8
8
|
+++ ${s}
|
|
9
9
|
${n}`,un=s=>{if(!s.startsWith("diff --git ")&&!/^--- [^\n]*\t?\r?\n\+\+\+ [^\n]*\t?(?:\r?\n|$)/m.test(s))return;const n=[...s.matchAll(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@[^\n]*(?:\r?\n|$)/gm)];if(n.length!==1)return;const e=n[0],i=Number.parseInt(e[1]??"",10),o=Number.parseInt(e[2]??"",10);if(i>1||o>1||!Number.isFinite(i)||!Number.isFinite(o))return;const l=(e.index??0)+e[0].length,f=s.slice(l),d=[],b=[];let g;for(const c of f.split(/\r?\n/)){if(c.startsWith("diff --git ")||c.startsWith("@@ "))break;if(c.startsWith("\\")){if(g==="-"||g===" "){const p=d.at(-1);p&&(p.newline=!1)}if(g==="+"||g===" "){const p=b.at(-1);p&&(p.newline=!1)}continue}if(c.startsWith("-")){d.push({text:c.slice(1),newline:!0}),g="-";continue}if(c.startsWith("+")){b.push({text:c.slice(1),newline:!0}),g="+";continue}c.startsWith(" ")&&(d.push({text:c.slice(1),newline:!0}),b.push({text:c.slice(1),newline:!0}),g=" ")}return{before:et(d),after:et(b)}},et=s=>s.map(n=>n.text+(n.newline?`
|
|
10
|
-
`:"")).join(""),tt=s=>en({name:s,contents:""},{name:s,contents:""}),dn=s=>/^Binary files .+ differ$/m.test(s)||/^GIT binary patch$/m.test(s),Ue=(s,n,e)=>dn(n)?{original:"",modified:"",isBinary:!0,patch:n,contextMode:e}:{original:"",modified:"",patch:n,fileDiff:ln(s,n),contextMode:e},gt=(s,n,e)=>{const i=s??0,o=n??0;return!i&&!o?null:t.jsxs("span",{className:se("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",e?.className),children:[i?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",i]}):null,o?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",o]}):null]})},fn=r.memo(function({changedFiles:n,selectedFile:e,onSelectFile:i}){return n.length===0?null:t.jsx(lt,{outerClassName:"flex-1 min-h-0",className:"px-1 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:n.map(o=>{const l=pt(o),f=e===o.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>i(o.path),className:se("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",f?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(ct,{filePath:o.path,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:l.color},title:l.description,"aria-label":l.description,children:l.code}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:o.path,children:o.path}),gt(o.insertions,o.deletions)]})},o.path)})})})});function pn(s,n,e){return s==="staged"?{source:"staged",staged:!0}:s==="working"?{source:"unstaged",staged:!1}:{source:"head",staged:e.staged&&n.path===e.path||ht(n)}}function hn(s,n){return s!=="all"?null:ht(n)?"Staged":mt(s,n)?"Partly staged":"Not staged"}function mt(s,n){return s==="all"&&Ge(n)&&He(n)}const gn=r.memo(function(){return t.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:t.jsx("div",{className:"typography-meta text-muted-foreground",children:"Content of this file cannot be viewed."})})}),mn=r.memo(function({filePath:n,diff:e,renderSideBySide:i}){const o=e.original.length>0,l=e.modified.length>0,f=i?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",d=i?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";return t.jsx("div",{className:"w-full overflow-auto p-4",style:{contain:"layout"},children:t.jsxs("div",{className:f,children:[o&&t.jsxs("div",{className:d,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:"Original"}),t.jsx("img",{src:e.original,alt:`Original: ${n}`,className:i?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),l&&t.jsxs("div",{className:d,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:o?"Modified":"New"}),t.jsx("img",{src:e.modified,alt:`Modified: ${n}`,className:i?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]})]})})}),xn=r.memo(function({filePath:n,diff:e,renderSideBySide:i,wrapLines:o}){const l=r.useMemo(()=>Mt(n)||"text",[n]);return e.isBinary?t.jsx(gn,{}):Re(n)?t.jsx(mn,{filePath:n,diff:e,renderSideBySide:i}):t.jsx("div",{className:"w-full",style:{contain:"layout"},children:t.jsx(tn,{original:e.original,modified:e.modified,fileDiff:e.fileDiff,language:l,fileName:n,renderSideBySide:i,wrapLines:o,layout:"inline"})})}),Oe=({label:s,text:n,icon:e,loading:i,disabled:o,tone:l,onClick:f})=>t.jsxs(Le,{variant:"ghost",size:"sm",className:se("h-6 gap-1 rounded-md bg-transparent px-2 typography-micro font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground",l==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",l==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:o,title:s,"aria-label":s,onClick:d=>{d.stopPropagation(),f()},children:[i?t.jsx(G,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(G,{name:e,className:"size-3.5"}),n]}),bn=r.memo(function({filePath:n,staged:e,partlyStaged:i=!1,busyAction:o,disabled:l,onAction:f}){return t.jsx("div",{className:"flex items-center gap-1",children:e?t.jsx(Oe,{label:`Unstage ${n}`,text:"Unstage",icon:"arrow-go-back",loading:o==="unstage",disabled:l,onClick:()=>f("unstage")}):t.jsxs(t.Fragment,{children:[t.jsx(Oe,{label:i?`Revert unstaged changes in ${n}`:`Revert changes in ${n}`,text:i?"Revert unstaged":"Revert",icon:"arrow-go-back",loading:o==="discard",disabled:l,tone:"failure",onClick:()=>f("discard")}),t.jsx(Oe,{label:i?`Stage the rest of ${n}`:`Stage ${n}`,text:i?"Stage the rest":"Stage",icon:"add",loading:o==="stage",disabled:l,tone:"success",onClick:()=>f("stage")})]})})}),xt=3,yn=1e6,wn=15e3,nt=500,Fn=r.memo(function({directory:n,file:e,layout:i,wrapLines:o,isSelected:l,isExpanded:f,isMounted:d,onSelect:b,onExpandedChange:g,registerSectionRef:c,showOpenInEditorAction:p=!1,isOpeningInEditor:F=!1,onOpenInEditor:k,diffSource:x,staged:S=!1,stageLabel:h=null,partlyStaged:$=!1,showFileActions:m=!0,loadFullFiles:V=!1,initialDiffData:R=null}){const{git:C}=ut(),E=ce(r.useCallback(u=>u.directories.get(n)?.diffCache.get(e.path)??null,[n,e.path])),w=ce(u=>u.setDiff),y=ce(u=>u.fetchStatus),L=J(u=>u.setDiffFileLayout),M=J(u=>u.setDiffWrapLines),[A,_]=r.useState(0),[N,z]=r.useState(null),[q,K]=r.useState(!1),[ie,ge]=r.useState(null),[T,W]=r.useState(!1),[Y,ae]=r.useState(null),B=r.useRef(null),me=r.useRef(null),Q=r.useMemo(()=>pt(e),[e]),H=i==="side-by-side",re=V?"full":"patch",ue=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,Z=r.useMemo(()=>R||(Y?.source===x?Y.data:x!=="head"||!E?null:{original:E.original,modified:E.modified,isBinary:E.isBinary,contextMode:"full"}),[E,x,R,Y]),oe=Z?.contextMode===re,De=r.useCallback(u=>{me.current=u,c(e.path,u)},[e.path,c]),xe=r.useCallback(u=>{g(e.path,u)},[e.path,g]),le=r.useCallback(()=>{b(e.path)},[e.path,b]);r.useEffect(()=>{ae(null),z(null),B.current=null},[x,ue]),r.useEffect(()=>{if(!f||!d)return;if(!n||R||Z&&oe){B.current=null,K(!1);return}const u=`${n}::${e.path}::${x}::${ue}::${re}::${A}`;if(B.current===u)return;B.current=u,z(null),K(!0);let P=!1;const ne=ot(),de=V?yn:xt,ee=Re(e.path)?C.getGitFileDiff(n,{path:e.path,staged:x==="staged"}):C.getGitDiff(n,{path:e.path,source:x,contextLines:de}),ye=wn,we=new Promise((O,te)=>{setTimeout(()=>te(new Error(`Timed out after ${ye}ms`)),ye)});return Promise.race([ee,we]).then(O=>{if(!P){if("diff"in O){const te=Ue(e.path,O.diff,re);ae({source:x,data:te})}else{const te={original:O.original??"",modified:O.modified??"",isBinary:O.isBinary,contextMode:"full"};x==="head"?w(n,e.path,te,ne):ae({source:x,data:te})}K(!1)}}).catch(O=>{if(P)return;const te=O instanceof Error?O.message:String(O);z(te),K(!1)}),()=>{P=!0,B.current===u&&(B.current=null)}},[re,Z,oe,A,x,n,e.path,ue,C,R,f,d,V,w]);const be=r.useCallback(()=>{xe(!f),le()},[xe,le,f]),Ee=r.useCallback(async u=>{if(!(!n||ie!==null)){ge(u);try{u==="stage"?await C.stageGitFile(n,e.path):u==="unstage"?await C.unstageGitFile(n,e.path):await C.revertGitFile(n,e.path,{scope:"working"}),_(P=>P+1),await y(n,C)}catch(P){const ne=u==="unstage"?"Failed to unstage changes":u==="stage"?"Failed to stage changes":"Failed to revert changes";dt.error(P instanceof Error?P.message:ne)}finally{ge(P=>P===u?null:P)}}},[n,y,e.path,ie,C]);return t.jsxs("div",{ref:De,className:se("scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0"),children:[t.jsx("div",{className:se("z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80","sticky top-0"),children:t.jsxs("div",{role:"button",tabIndex:0,onClick:be,onKeyDown:u=>{u.target===u.currentTarget&&(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),be())},className:se("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",l?"bg-[var(--interactive-selection)]/35":null),children:[t.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),t.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:f?t.jsx(G,{name:"arrow-down-s",className:"size-4"}):t.jsx(G,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Q.color},title:Q.description,"aria-label":Q.description,children:Q.code}),t.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(ct,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const u=e.path.lastIndexOf("/");if(u===-1)return t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:e.path});const P=e.path.slice(0,u),ne=e.path.slice(u+1);return t.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:P}),t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsx("span",{className:"text-foreground",children:ne})]})]})})()]})})]}),t.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[h&&m?t.jsx("span",{className:"typography-micro text-muted-foreground",children:h}):null,gt(e.insertions,e.deletions),p&&k?t.jsx(Le,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:"Open this file in editor at change",onClick:u=>{u.stopPropagation(),k(e.path,Z)},disabled:F,children:F?t.jsx(G,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(G,{name:"edit",className:"size-3.5"})}):null,t.jsx(ft,{mode:H?"side-by-side":"unified",onModeChange:u=>{const P=u==="side-by-side"?"side-by-side":"inline";L(e.path,P)},className:"opacity-70"}),t.jsxs(It,{children:[t.jsx(Pt,{asChild:!0,children:t.jsx(Le,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:"File view options","aria-label":"File view options",onClick:u=>{u.stopPropagation()},onPointerDown:u=>{u.stopPropagation()},children:t.jsx(G,{name:"more-2-fill",className:"size-3.5"})})}),t.jsxs($t,{align:"end",onClick:u=>{u.stopPropagation()},onPointerDown:u=>{u.stopPropagation()},children:[t.jsxs(Qe,{onSelect:()=>{M(!o)},children:[t.jsx(G,{name:"text-wrap",className:"size-4"}),t.jsx("span",{className:"flex-1",children:"Wrap lines"}),o?t.jsx(G,{name:"check",className:"size-4"}):null]}),t.jsxs(Qe,{onSelect:()=>{L(e.path,H?"inline":"side-by-side")},children:[t.jsx(G,{name:H?"align-justify":"layout-column",className:"size-4"}),H?"Switch to unified view":"Switch to side-by-side view"]})]})]})]})]})}),f&&t.jsxs("div",{className:"relative overflow-clip bg-background",children:[!d&&!N?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,N?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:"Failed to load diff"}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:N}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>_(u=>u+1),children:"Retry"})]}):null,d&&q&&!Z&&!N?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(G,{name:"loader-4",className:"size-4 animate-spin"}),"Loading diff..."]}):null,d&&Z&&!T&&e.insertions+e.deletions>nt?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:`Large diff (${e.insertions+e.deletions} changed lines)`}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:"Rendering may be slow. You can still view the diff by clicking below."}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>W(!0),children:"Render anyway"})]}):null,d&&Z&&(T||e.insertions+e.deletions<=nt)?t.jsxs(t.Fragment,{children:[t.jsx(xn,{filePath:e.path,diff:Z,renderSideBySide:H,wrapLines:o}),m?t.jsx("div",{className:"flex justify-end border-t border-border/40 px-2 py-1",children:t.jsx(bn,{filePath:e.path,staged:S,partlyStaged:$,busyAction:ie,disabled:ie!==null,onAction:Ee})}):null]}):null]})]})}),jn=1100,st=300,vn=s=>s<=6?s:s<=12?6:s<=25?4:2,Sn=(s,n)=>Wt(s,n),it=(s,n)=>{const e=s.split(`
|
|
10
|
+
`:"")).join(""),tt=s=>en({name:s,contents:""},{name:s,contents:""}),dn=s=>/^Binary files .+ differ$/m.test(s)||/^GIT binary patch$/m.test(s),Ue=(s,n,e)=>dn(n)?{original:"",modified:"",isBinary:!0,patch:n,contextMode:e}:{original:"",modified:"",patch:n,fileDiff:ln(s,n),contextMode:e},gt=(s,n,e)=>{const i=s??0,o=n??0;return!i&&!o?null:t.jsxs("span",{className:se("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",e?.className),children:[i?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",i]}):null,o?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",o]}):null]})},fn=r.memo(function({changedFiles:n,selectedFile:e,onSelectFile:i}){return n.length===0?null:t.jsx(lt,{outerClassName:"flex-1 min-h-0",className:"px-1 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:n.map(o=>{const l=pt(o),f=e===o.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>i(o.path),className:se("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",f?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(ct,{filePath:o.path,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:l.color},title:l.description,"aria-label":l.description,children:l.code}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:o.path,children:o.path}),gt(o.insertions,o.deletions)]})},o.path)})})})});function pn(s,n,e){return s==="staged"?{source:"staged",staged:!0}:s==="working"?{source:"unstaged",staged:!1}:{source:"head",staged:e.staged&&n.path===e.path||ht(n)}}function hn(s,n){return s!=="all"?null:ht(n)?"Staged":mt(s,n)?"Partly staged":"Not staged"}function mt(s,n){return s==="all"&&Ge(n)&&He(n)}const gn=r.memo(function(){return t.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:t.jsx("div",{className:"typography-meta text-muted-foreground",children:"Content of this file cannot be viewed."})})}),mn=r.memo(function({filePath:n,diff:e,renderSideBySide:i}){const o=e.original.length>0,l=e.modified.length>0,f=i?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",d=i?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";return t.jsx("div",{className:"w-full overflow-auto p-4",style:{contain:"layout"},children:t.jsxs("div",{className:f,children:[o&&t.jsxs("div",{className:d,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:"Original"}),t.jsx("img",{src:e.original,alt:`Original: ${n}`,className:i?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),l&&t.jsxs("div",{className:d,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:o?"Modified":"New"}),t.jsx("img",{src:e.modified,alt:`Modified: ${n}`,className:i?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]})]})})}),xn=r.memo(function({filePath:n,diff:e,renderSideBySide:i,wrapLines:o}){const l=r.useMemo(()=>Mt(n)||"text",[n]);return e.isBinary?t.jsx(gn,{}):Re(n)?t.jsx(mn,{filePath:n,diff:e,renderSideBySide:i}):t.jsx("div",{className:"w-full",style:{contain:"layout"},children:t.jsx(tn,{original:e.original,modified:e.modified,fileDiff:e.fileDiff,language:l,fileName:n,renderSideBySide:i,wrapLines:o,layout:"inline"})})}),Oe=({label:s,text:n,icon:e,loading:i,disabled:o,tone:l,onClick:f})=>t.jsxs(Le,{variant:"ghost",size:"sm",className:se("h-6 gap-1 rounded-md bg-transparent px-2 typography-micro font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground",l==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",l==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:o,title:s,"aria-label":s,onClick:d=>{d.stopPropagation(),f()},children:[i?t.jsx(G,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(G,{name:e,className:"size-3.5"}),n]}),bn=r.memo(function({filePath:n,staged:e,partlyStaged:i=!1,busyAction:o,disabled:l,onAction:f}){return t.jsx("div",{className:"flex items-center gap-1",children:e?t.jsx(Oe,{label:`Unstage ${n}`,text:"Unstage",icon:"arrow-go-back",loading:o==="unstage",disabled:l,onClick:()=>f("unstage")}):t.jsxs(t.Fragment,{children:[t.jsx(Oe,{label:i?`Revert unstaged changes in ${n}`:`Revert changes in ${n}`,text:i?"Revert unstaged":"Revert",icon:"arrow-go-back",loading:o==="discard",disabled:l,tone:"failure",onClick:()=>f("discard")}),t.jsx(Oe,{label:i?`Stage the rest of ${n}`:`Stage ${n}`,text:i?"Stage the rest":"Stage",icon:"add",loading:o==="stage",disabled:l,tone:"success",onClick:()=>f("stage")})]})})}),xt=3,yn=1e6,wn=15e3,nt=500,Fn=r.memo(function({directory:n,file:e,layout:i,wrapLines:o,isSelected:l,isExpanded:f,isMounted:d,onSelect:b,onExpandedChange:g,registerSectionRef:c,showOpenInEditorAction:p=!1,isOpeningInEditor:F=!1,onOpenInEditor:k,diffSource:x,staged:S=!1,stageLabel:h=null,partlyStaged:$=!1,showFileActions:m=!0,loadFullFiles:V=!1,initialDiffData:R=null}){const{git:C}=ut(),E=ce(r.useCallback(u=>u.directories.get(n)?.diffCache.get(e.path)??null,[n,e.path])),w=ce(u=>u.setDiff),y=ce(u=>u.fetchStatus),L=Y(u=>u.setDiffFileLayout),M=Y(u=>u.setDiffWrapLines),[A,_]=r.useState(0),[N,z]=r.useState(null),[q,K]=r.useState(!1),[ie,ge]=r.useState(null),[T,W]=r.useState(!1),[J,ae]=r.useState(null),B=r.useRef(null),me=r.useRef(null),Q=r.useMemo(()=>pt(e),[e]),H=i==="side-by-side",re=V?"full":"patch",ue=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,Z=r.useMemo(()=>R||(J?.source===x?J.data:x!=="head"||!E?null:{original:E.original,modified:E.modified,isBinary:E.isBinary,contextMode:"full"}),[E,x,R,J]),oe=Z?.contextMode===re,De=r.useCallback(u=>{me.current=u,c(e.path,u)},[e.path,c]),xe=r.useCallback(u=>{g(e.path,u)},[e.path,g]),le=r.useCallback(()=>{b(e.path)},[e.path,b]);r.useEffect(()=>{ae(null),z(null),B.current=null},[x,ue]),r.useEffect(()=>{if(!f||!d)return;if(!n||R||Z&&oe){B.current=null,K(!1);return}const u=`${n}::${e.path}::${x}::${ue}::${re}::${A}`;if(B.current===u)return;B.current=u,z(null),K(!0);let P=!1;const ne=ot(),de=V?yn:xt,ee=Re(e.path)?C.getGitFileDiff(n,{path:e.path,staged:x==="staged"}):C.getGitDiff(n,{path:e.path,source:x,contextLines:de}),ye=wn,we=new Promise((O,te)=>{setTimeout(()=>te(new Error(`Timed out after ${ye}ms`)),ye)});return Promise.race([ee,we]).then(O=>{if(!P){if("diff"in O){const te=Ue(e.path,O.diff,re);ae({source:x,data:te})}else{const te={original:O.original??"",modified:O.modified??"",isBinary:O.isBinary,contextMode:"full"};x==="head"?w(n,e.path,te,ne):ae({source:x,data:te})}K(!1)}}).catch(O=>{if(P)return;const te=O instanceof Error?O.message:String(O);z(te),K(!1)}),()=>{P=!0,B.current===u&&(B.current=null)}},[re,Z,oe,A,x,n,e.path,ue,C,R,f,d,V,w]);const be=r.useCallback(()=>{xe(!f),le()},[xe,le,f]),Ee=r.useCallback(async u=>{if(!(!n||ie!==null)){ge(u);try{u==="stage"?await C.stageGitFile(n,e.path):u==="unstage"?await C.unstageGitFile(n,e.path):await C.revertGitFile(n,e.path,{scope:"working"}),_(P=>P+1),await y(n,C)}catch(P){const ne=u==="unstage"?"Failed to unstage changes":u==="stage"?"Failed to stage changes":"Failed to revert changes";dt.error(P instanceof Error?P.message:ne)}finally{ge(P=>P===u?null:P)}}},[n,y,e.path,ie,C]);return t.jsxs("div",{ref:De,className:se("scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0"),children:[t.jsx("div",{className:se("z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80","sticky top-0"),children:t.jsxs("div",{role:"button",tabIndex:0,onClick:be,onKeyDown:u=>{u.target===u.currentTarget&&(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),be())},className:se("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",l?"bg-[var(--interactive-selection)]/35":null),children:[t.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),t.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:f?t.jsx(G,{name:"arrow-down-s",className:"size-4"}):t.jsx(G,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Q.color},title:Q.description,"aria-label":Q.description,children:Q.code}),t.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(ct,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const u=e.path.lastIndexOf("/");if(u===-1)return t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:e.path});const P=e.path.slice(0,u),ne=e.path.slice(u+1);return t.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:P}),t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsx("span",{className:"text-foreground",children:ne})]})]})})()]})})]}),t.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[h&&m?t.jsx("span",{className:"typography-micro text-muted-foreground",children:h}):null,gt(e.insertions,e.deletions),p&&k?t.jsx(Le,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:"Open this file in editor at change",onClick:u=>{u.stopPropagation(),k(e.path,Z)},disabled:F,children:F?t.jsx(G,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(G,{name:"edit",className:"size-3.5"})}):null,t.jsx(ft,{mode:H?"side-by-side":"unified",onModeChange:u=>{const P=u==="side-by-side"?"side-by-side":"inline";L(e.path,P)},className:"opacity-70"}),t.jsxs(It,{children:[t.jsx(Pt,{asChild:!0,children:t.jsx(Le,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:"File view options","aria-label":"File view options",onClick:u=>{u.stopPropagation()},onPointerDown:u=>{u.stopPropagation()},children:t.jsx(G,{name:"more-2-fill",className:"size-3.5"})})}),t.jsxs($t,{align:"end",onClick:u=>{u.stopPropagation()},onPointerDown:u=>{u.stopPropagation()},children:[t.jsxs(Qe,{onSelect:()=>{M(!o)},children:[t.jsx(G,{name:"text-wrap",className:"size-4"}),t.jsx("span",{className:"flex-1",children:"Wrap lines"}),o?t.jsx(G,{name:"check",className:"size-4"}):null]}),t.jsxs(Qe,{onSelect:()=>{L(e.path,H?"inline":"side-by-side")},children:[t.jsx(G,{name:H?"align-justify":"layout-column",className:"size-4"}),H?"Switch to unified view":"Switch to side-by-side view"]})]})]})]})]})}),f&&t.jsxs("div",{className:"relative overflow-clip bg-background",children:[!d&&!N?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,N?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:"Failed to load diff"}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:N}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>_(u=>u+1),children:"Retry"})]}):null,d&&q&&!Z&&!N?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(G,{name:"loader-4",className:"size-4 animate-spin"}),"Loading diff..."]}):null,d&&Z&&!T&&e.insertions+e.deletions>nt?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:`Large diff (${e.insertions+e.deletions} changed lines)`}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:"Rendering may be slow. You can still view the diff by clicking below."}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>W(!0),children:"Render anyway"})]}):null,d&&Z&&(T||e.insertions+e.deletions<=nt)?t.jsxs(t.Fragment,{children:[t.jsx(xn,{filePath:e.path,diff:Z,renderSideBySide:H,wrapLines:o}),m?t.jsx("div",{className:"flex justify-end border-t border-border/40 px-2 py-1",children:t.jsx(bn,{filePath:e.path,staged:S,partlyStaged:$,busyAction:ie,disabled:ie!==null,onAction:Ee})}):null]}):null]})]})}),jn=1100,st=300,vn=s=>s<=6?s:s<=12?6:s<=25?4:2,Sn=(s,n)=>Wt(s,n),it=(s,n)=>{const e=s.split(`
|
|
11
11
|
`),i=n.split(`
|
|
12
12
|
`),o=Math.min(e.length,i.length);for(let l=0;l<o;l+=1)if(e[l]!==i[l])return l+1;return i.length>e.length?e.length+1:e.length>i.length?Math.max(1,i.length):1},Nn=s=>Array.isArray(s)?s.filter(n=>!n||typeof n!="object"?!1:typeof n.file=="string"):[],Cn=s=>s.split(/^diff --git /m).slice(1).flatMap(e=>{const[i=""]=e.split(`
|
|
13
13
|
`,1),o=i.lastIndexOf(" b/");if(o<=2)return[];const l=i.slice(2,o),f=i.slice(o+3).trim(),d=`diff --git ${e}`,b=d.includes(`
|
|
@@ -15,4 +15,4 @@ new file mode `)?"added":d.includes(`
|
|
|
15
15
|
deleted file mode `)?"deleted":d.includes(`
|
|
16
16
|
rename from `)?"renamed":"modified";let g=0,c=0;for(const p of d.split(`
|
|
17
17
|
`))p.startsWith("+")&&!p.startsWith("+++")&&(g+=1),p.startsWith("-")&&!p.startsWith("---")&&(c+=1);return[{file:b==="deleted"?l:f,status:b,additions:g,deletions:c,patch:d}]}),Ln=s=>s==="added"?"A":s==="deleted"?"D":"M";function Dn({activeDiffScope:s,effectiveDirectory:n,branchBase:e,branchHead:i,git:o,sessionMessageRecords:l}){const[f,d]=r.useState([]),[b,g]=r.useState(null),[c,p]=r.useState(!1),F=r.useMemo(()=>{const S=_t(l,{showTextJustificationActivity:!1,mergeHiddenUserTurns:!0});for(let h=S.turns.length-1;h>=0;h-=1){const $=S.turns[h];if(!$)continue;const m=$.activityParts.map(C=>C.part).filter(C=>C.type==="tool"),V=Bt(m);if(V.length>0)return V.map(C=>({file:C.path,status:"modified",additions:C.additions,deletions:C.deletions,patch:C.patch}));const R=Nn($.userMessage.info?.summary?.diffs);if(R.length>0)return R}return[]},[l]);r.useEffect(()=>{if(s!=="branch"||!n||!e||!i||!o.getGitRangeDiff){d([]),g(null),p(!1);return}let S=!1;return p(!0),g(null),o.getGitRangeDiff(n,{base:e,head:i,contextLines:xt}).then(h=>{S||(d(Cn(h.diff??"")),p(!1))}).catch(h=>{S||(d([]),p(!1),g(h instanceof Error?h.message:String(h)))}),()=>{S=!0}},[s,e,i,n,o]);const k=r.useMemo(()=>{const S=new Map;for(const h of F)if(h.file){if(typeof h.patch=="string"){S.set(h.file,Ue(h.file,h.patch,"patch"));continue}typeof h.before!="string"&&typeof h.after!="string"||S.set(h.file,{original:h.before??"",modified:h.after??"",contextMode:"full"})}return S},[F]),x=r.useMemo(()=>{const S=new Map;for(const h of f)!h.file||typeof h.patch!="string"||S.set(h.file,Ue(h.file,h.patch,"patch"));return S},[f]);return{branchDiffs:f,branchDiffError:b,branchDiffLoading:c,lastTurnDiffs:F,lastTurnDiffData:k,branchDiffData:x}}const rt=(s,n)=>{if(n.length===0)return null;let e=null,i=null;for(const l of n)l.top<=s?(!e||l.top>e.top)&&(e=l):(!i||l.top<i.top)&&(i=l);const o=e??i;return o?{path:o.path,topOffset:o.top-s}:null},kn=(s,n,e,i)=>Math.min(Math.max(0,i),Math.max(0,s+e-n));function Rn({pinSelectedFileHeaderToTopOnNavigate:s,scrollRequestNonce:n,changedFiles:e,expandedFiles:i,setMountedStackedFiles:o,fileDiffRefreshNonce:l}){const f=r.useRef(null),d=r.useRef(new Map),[b,g]=r.useState(null),c=r.useRef(null),p=r.useRef(null),F=r.useRef(!1),k=r.useRef(null),x=r.useRef(i),S=r.useRef(null);r.useLayoutEffect(()=>{x.current=i},[i]);const h=r.useRef(null),$=r.useCallback(()=>{const w=f.current;if(!w)return null;const y=w.getBoundingClientRect().top,L=[];for(const[M,A]of d.current)A&&L.push({path:M,top:A.getBoundingClientRect().top});return rt(y,L)},[]),m=r.useCallback(()=>{c.current=null,F.current=!1,g(null),p.current!==null&&(window.cancelAnimationFrame(p.current),p.current=null)},[]),V=r.useCallback(()=>{k.current=null;const w=f.current;if(!w)return;const y=w.getBoundingClientRect(),L=y.top-st,M=y.bottom+st,A={},_=[];for(const[N,z]of d.current){if(!z)continue;const q=z.getBoundingClientRect();_.push({path:N,top:q.top}),x.current.has(N)&&(q.bottom<L||q.top>M||(A[N]=!0))}S.current=rt(y.top,_),o(N=>{let z=!1;const q=new Set(N);for(const K of Object.keys(A))q.has(K)||(q.add(K),z=!0);return z?q:N})},[o]),R=r.useCallback(()=>{typeof window>"u"||k.current===null&&(k.current=window.requestAnimationFrame(V))},[V]);r.useEffect(()=>{const w=f.current;if(w)return R(),w.addEventListener("scroll",R,{passive:!0}),window.addEventListener("resize",R),()=>{w.removeEventListener("scroll",R),window.removeEventListener("resize",R),k.current!==null&&(window.cancelAnimationFrame(k.current),k.current=null)}},[e,i,R]),r.useLayoutEffect(()=>{const w=h.current;if(!w)return;h.current=null;const y=f.current,L=d.current.get(w.path);if(!y||!L)return;const M=y.getBoundingClientRect().top,A=L.getBoundingClientRect().top-M;y.scrollTop=kn(y.scrollTop,w.topOffset,A,y.scrollHeight-y.clientHeight),S.current=w},[l]);const C=r.useCallback((w,y)=>{const L=d.current;y?L.set(w,y):L.delete(w),R()},[R]),E=r.useCallback(w=>{const y=d.current.get(w),L=f.current;if(!y||!L)return!1;const M=y.getBoundingClientRect().top-L.getBoundingClientRect().top;return L.scrollTo({top:L.scrollTop+M,behavior:"auto"}),!0},[]);return r.useEffect(()=>{if(!c.current)return;let y=0;const L=20;let M=!1;const A=(N=!0)=>{M||(M=!0,c.current=null,F.current=!1,N&&g(null),p.current!==null&&(window.cancelAnimationFrame(p.current),p.current=null))},_=()=>{if(M){p.current=null;return}const N=c.current;if(!N){A(),p.current=null;return}if(!E(N)){y+=1,y<L?p.current=window.requestAnimationFrame(_):(A(),p.current=null);return}if(s&&F.current){g(N),A(!1);return}A()};return p.current=window.requestAnimationFrame(_),()=>{M=!0,p.current!==null&&(window.cancelAnimationFrame(p.current),p.current=null)}},[s,n,E]),{diffScrollRef:f,fileSectionRefs:d,pinnedStackedTarget:b,pendingScrollTargetRef:c,shouldPinAfterAlignRef:F,pendingScrollAnchorRestoreRef:h,lastScrollAnchorRef:S,captureScrollAnchor:$,cancelPendingScrollAlignment:m,queueVisibleStackedFilesSync:R,registerSectionRef:C,scrollToFile:E}}const at=s=>{if(!s)return null;const n=s.split(`
|
|
18
|
-
`);let e=null;for(const i of n){const o=i.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(o){const l=Number.parseInt(o[1]??"",10);e=Number.isFinite(l)&&l>=1?l:null;continue}if(e!==null){if(i.startsWith(" ")){e+=1;continue}if(i.startsWith("+"))return e;if(i.startsWith("-"))return Math.max(1,e)}}return null};function En({effectiveDirectory:s,activeDiffStaged:n,git:e,files:i,setDiff:o,openContextFileAtLine:l}){const[f,d]=r.useState(null),b=r.useCallback(async(g,c)=>{if(!s||!g)return;d(g);const p=ot();try{let F=null;if(c?.patch&&!c.isBinary&&!Re(g)?F=at(c.patch):c&&c.contextMode==="full"&&!c.isBinary&&!Re(g)&&(F=it(c.original,c.modified)),F===null)try{const $=await e.getGitDiff(s,{path:g,staged:n,contextLines:3});F=at($.diff)}catch{F=null}let k=c;if(F===null||!k){const $=await e.getGitFileDiff(s,{path:g,staged:n});k={original:$.original??"",modified:$.modified??"",isBinary:$.isBinary},n||o(s,g,k,p??void 0)}const x=F??(k.isBinary||Re(g)?1:it(k.original,k.modified)),S=Sn(s,g),h=await nn(i,S,{directory:s});if(!h.ok){dt.error(sn(h.reason));return}l(s,S,x,1)}finally{d(F=>F===g?null:F)}},[n,s,i,e,l,o]);return{openingEditorFilePath:f,openFileInEditorAtChange:b}}function An(s){const{hideStackedFileSidebar:n=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:i=!1,diffScope:o="all",branchBase:l=null,branchHead:f=null,targetFilePath:d=null}=s,{git:b,files:g}=ut(),c=zt(),{screenWidth:p,isMobile:F}=Ot(),k=Gt(c??null),x=Ht(c??null),S=Ut(c??null),h=ce(a=>a.setActiveDirectory),$=ce(a=>a.ensureStatus),m=ce(a=>a.fetchStatus),V=ce(a=>a.clearDiffCache),R=ce(a=>a.setDiff),[C,E]=r.useState(null),[w,y]=r.useState(!1),[L,M]=r.useState(()=>new Set),[A,_]=r.useState(()=>new Set),[N,z]=r.useState(!1),[q,K]=r.useState(0),[ie,ge]=r.useState(()=>new Map),[T,W]=r.useState(o);r.useEffect(()=>{W(o)},[o]);const Y=J(a=>a.pendingDiffFile),ae=J(a=>a.pendingDiffStaged),B=J(a=>a.pendingDiffScope),me=J(a=>a.setPendingDiffFile),Q=J(a=>a.diffLayoutPreference),H=J(a=>a.diffFileLayout),re=J(a=>a.setDiffFileLayout),ue=J(a=>a.diffWrapLinesOverride),Z=J(a=>a.wrapLinesByDefault),oe=J(a=>a.setDiffWrapLines),De=J(a=>a.openContextFileAtLine),xe=Vt(a=>a.currentSessionId),le=qt(xe??""),be=ue??Z,u=(T==="staged"?!0:T==="working"?!1:null)??w,P=F||p<=768,ne=!n&&!P&&p>=1024,de=r.useRef(null),{branchDiffs:ee,branchDiffError:ye,branchDiffLoading:we,lastTurnDiffs:O,lastTurnDiffData:te,branchDiffData:Ae}=Dn({activeDiffScope:T,effectiveDirectory:c,branchBase:l,branchHead:f,git:b,sessionMessageRecords:le}),D=r.useMemo(()=>{if(T==="turn"||T==="branch")return(T==="branch"?ee:O).map(I=>({path:I.file??"",index:"",working_dir:Ln(I.status),insertions:I.additions??0,deletions:I.deletions??0,isNew:I.status==="added"})).filter(I=>I.path).sort((I,X)=>I.path.localeCompare(X.path));if(!x?.files)return[];const a=x.diffStats??{},j=T==="staged"?Ge:T==="working"?He:()=>!0;return x.files.filter(j).map(v=>({...v,insertions:a[v.path]?.insertions??0,deletions:a[v.path]?.deletions??0,isNew:Qt(v)})).sort((v,I)=>v.path.localeCompare(I.path))},[T,ee,O,x]),U=r.useMemo(()=>x?.files?x.files.filter(He).length:0,[x]),Te=r.useMemo(()=>x?.files?x.files.filter(Ge).length:0,[x]),$e=O.length,We=x?.files?.length??0,bt=ee.length,{diffScrollRef:yt,pinnedStackedTarget:wt,pendingScrollTargetRef:Fe,shouldPinAfterAlignRef:je,pendingScrollAnchorRestoreRef:Ve,lastScrollAnchorRef:qe,captureScrollAnchor:Ke,cancelPendingScrollAlignment:ve,queueVisibleStackedFilesSync:Me,registerSectionRef:Ft,scrollToFile:Xe}=Rn({pinSelectedFileHeaderToTopOnNavigate:i,scrollRequestNonce:q,changedFiles:D,expandedFiles:L,setMountedStackedFiles:_,fileDiffRefreshNonce:ie}),Se=r.useCallback(a=>{M(j=>{if(j.has(a))return j;const v=new Set(j);return v.add(a),v})},[]),Ie=r.useRef(null),_e=r.useMemo(()=>D.map(a=>a.path).join("\0"),[D]);r.useEffect(()=>{const a=_e?_e.split("\0"):[],j=new Set(a),v=`${c??""}:${T}:${e?"collapsed":"default"}`,I=de.current!==v;de.current=v;const X=Ie.current,Ne=X&&j.has(X)?X:null;Ne&&(Ie.current=null),M(ke=>{if(I){const pe=e?0:vn(a.length),Je=new Set(a.slice(0,pe));return Ne&&Je.add(Ne),Je}let Ce=!1;const fe=new Set;for(const pe of ke){if(!j.has(pe)){Ce=!0;continue}fe.add(pe)}return Ne&&!fe.has(Ne)&&(fe.add(Ne),Ce=!0),Ce?fe:ke}),_(ke=>{if(I)return new Set;let Ce=!1;const fe=new Set;for(const pe of ke){if(!j.has(pe)){Ce=!0;continue}fe.add(pe)}return Ce?fe:ke})},[T,_e,c,_,e]);const Be=r.useCallback(a=>{const j=H[a.path];if(j)return j;if(Q==="inline")return"inline";if(Q==="side-by-side")return"side-by-side";const v=p<jn;return a.isNew||v?"inline":"side-by-side"},[H,Q,p]),jt=r.useMemo(()=>D.length===0?null:D.every(a=>Be(a)==="side-by-side")?"side-by-side":"inline",[D,Be]);r.useEffect(()=>{c&&(h(c),$(c,b))},[c,h,$,b]),r.useEffect(()=>{if(c)return Kt.onGitRefreshHint(a=>{Ye(a.directory)===Ye(c)&&(a.paths?.length&&(Ve.current=Ke()??qe.current,V(c,a.paths),ge(j=>{const v=new Map(j);for(const I of a.paths??[])v.set(I,(v.get(I)??0)+1);return v})),m(c,b,{silent:!0}))})},[Ke,V,c,m,b,qe,Ve]),r.useEffect(()=>{T!=="all"&&!B||Y&&(B&&W(B),E(Y),y(B==="staged"||!B&&ae),me(null),je.current=!0,Fe.current=Y,Ie.current=Y,Se(Y),K(a=>a+1))},[T,Se,Y,B,ae,Fe,me,je]),r.useEffect(()=>{if(T==="all")return;const a=d?.trim();a&&(E(a),y(T==="staged"),je.current=!0,Fe.current=a,Ie.current=a,Se(a),K(j=>j+1))},[T,Se,Fe,je,d]),r.useEffect(()=>{if(!C)return;D.some(j=>j.path===C)||(E(null),y(!1))},[D,C]);const vt=r.useCallback((a,j)=>{ve(),M(v=>{const I=v.has(a);if(j===I)return v;const X=new Set(v);return j?X.add(a):X.delete(a),X}),_(v=>{const I=v.has(a);if(j===I)return v;const X=new Set(v);return j?X.add(a):X.delete(a),X}),Me()},[ve,Me,_]),St=r.useCallback(()=>{ve(),M(a=>a.size>0?new Set:new Set(D.map(j=>j.path))),_(new Set),Me()},[ve,D,Me,_]),Nt=r.useCallback(a=>{},[]),Ct=r.useCallback(a=>{ve(),E(a),y(!1),je.current=!0,Fe.current=a,Se(a),K(j=>j+1),Xe(a)},[ve,Se,Fe,Xe,je]),Lt=r.useCallback(a=>{const j=a==="side-by-side"?"side-by-side":"inline";D.forEach(v=>{re(v.path,j)})},[D,re]),{openingEditorFilePath:Dt,openFileInEditorAtChange:kt}=En({effectiveDirectory:c,activeDiffStaged:u,git:b,files:g,setDiff:R,openContextFileAtLine:De});return{git:b,files:g,effectiveDirectory:c,screenWidth:p,isMobile:F,isGitRepo:k,status:x,isLoadingStatus:S,activeDiffScope:T,setActiveDiffScope:W,branchDiffs:ee,branchDiffError:ye,branchDiffLoading:we,diffWrapLines:be,setDiffWrapLines:oe,displayFileStaged:w,displayFile:C,pinnedStackedTarget:wt,expandedFiles:L,mountedStackedFiles:A,loadFullFiles:N,setLoadFullFiles:z,fileDiffRefreshNonce:ie,showFileSidebar:ne,diffScrollRef:yt,lastTurnDiffData:te,branchDiffData:Ae,changedFiles:D,workingFileCount:U,stagedFileCount:Te,turnFileCount:$e,allFileCount:We,branchFileCount:bt,currentLayoutForAllFiles:jt,openingEditorFilePath:Dt,registerSectionRef:Ft,handleStackedEntryExpandedChange:vt,handleExpandOrCollapseAll:St,handleSelectFile:Nt,handleSelectFileAndScroll:Ct,handleHeaderLayoutChange:Lt,openFileInEditorAtChange:kt,getLayoutForFile:Be}}const Rs=({hideStackedFileSidebar:s=!1,stackedDefaultCollapsedAll:n=!1,pinSelectedFileHeaderToTopOnNavigate:e=!1,showOpenInEditorAction:i=!1,diffScope:o="all",onDiffScopeChange:l,branchBase:f=null,branchHead:d=null,targetFilePath:b=null,flushContent:g=!1,hideToolbar:c=!1,onHeaderControlsStateChange:p,toolbarSlot:F=null,onlyFilePath:k=null})=>{const{effectiveDirectory:x,isGitRepo:S,status:h,isLoadingStatus:$,activeDiffScope:m,setActiveDiffScope:V,branchDiffError:R,branchDiffLoading:C,diffWrapLines:E,setDiffWrapLines:w,displayFileStaged:y,displayFile:L,pinnedStackedTarget:M,expandedFiles:A,mountedStackedFiles:_,loadFullFiles:N,setLoadFullFiles:z,fileDiffRefreshNonce:q,showFileSidebar:K,diffScrollRef:ie,lastTurnDiffData:ge,branchDiffData:T,changedFiles:W,workingFileCount:Y,stagedFileCount:ae,turnFileCount:B,allFileCount:me,branchFileCount:Q,currentLayoutForAllFiles:H,openingEditorFilePath:re,registerSectionRef:ue,handleStackedEntryExpandedChange:Z,handleExpandOrCollapseAll:oe,handleSelectFile:De,handleSelectFileAndScroll:xe,handleHeaderLayoutChange:le,openFileInEditorAtChange:be,getLayoutForFile:Ee}=An({hideStackedFileSidebar:s,stackedDefaultCollapsedAll:n,pinSelectedFileHeaderToTopOnNavigate:e,diffScope:o,branchBase:f,branchHead:d,targetFilePath:b});r.useEffect(()=>{c&&l?.(m)},[m,c,l]);const u=r.useCallback(()=>{z(D=>!D)},[z]),P=r.useCallback(()=>{w(!E)},[E,w]),ne=r.useCallback(()=>{le(H==="side-by-side"?"unified":"side-by-side")},[H,le]),de=A.size,ee=k&&m!=="turn"&&m!=="branch"?W.find(D=>D.path===k)??null:null,ye=ee?[ee]:W,we=r.useMemo(()=>({turnCount:B,branchCount:Q,focusedFilePath:ee?.path??null,expandedCount:de,totalCount:W.length,loadFullFiles:N,wrapLines:E,layoutMode:H,onExpandOrCollapseAll:oe,onToggleLoadFullFiles:u,onToggleWrapLines:P,onToggleLayout:ne}),[B,Q,ee,de,W.length,N,E,H,oe,u,P,ne]);r.useEffect(()=>{c&&p?.(we)},[c,we,p]);const O=()=>{if(!x)return null;const D={path:L,staged:y};return t.jsxs("div",{className:se("flex min-w-0 flex-1 min-h-0 h-full",g?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[K&&t.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[t.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:"Files"}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:W.length})]}),t.jsx(fn,{changedFiles:W,selectedFile:null,onSelectFile:xe})]}),t.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:t.jsxs(lt,{ref:ie,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none]",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:[t.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:ye.map(U=>{const Te=pn(m,U,D);return t.jsx(Fn,{directory:x,file:U,layout:Ee(U),wrapLines:E,isSelected:!1,isExpanded:A.has(U.path),isMounted:_.has(U.path)||U.path===M,onSelect:De,onExpandedChange:Z,registerSectionRef:ue,showOpenInEditorAction:i&&m!=="turn"&&m!=="branch",isOpeningInEditor:re===U.path,onOpenInEditor:($e,We)=>{be($e,We)},diffSource:Te.source,staged:Te.staged,stageLabel:hn(m,U),partlyStaged:mt(m,U),showFileActions:m!=="turn"&&m!=="branch",loadFullFiles:N,initialDiffData:m==="turn"?ge.get(U.path)??null:m==="branch"?T.get(U.path)??null:null},`${U.path}:${q.get(U.path)??0}`)})}),t.jsx("div",{"aria-hidden":"true",className:"h-16 shrink-0"})]})})]})},te=()=>x?m!=="turn"&&$&&!h?t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(G,{name:"loader-4",className:"size-4 animate-spin"}),"Loading repository status..."]}):m!=="turn"&&m!=="branch"&&S===!1?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Not a git repository. Use the Git tab to initialize or change directories."}):m==="branch"&&C?t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(G,{name:"loader-4",className:"size-4 animate-spin"}),"Loading branch changes..."]}):m==="branch"&&R?t.jsx("div",{className:"flex flex-1 items-center justify-center px-4 text-center text-sm text-muted-foreground",children:`Failed to load branch changes: ${R}`}):W.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:m==="turn"?"No last turn changes to display":"Working tree clean, no changes to display"}):O():t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Select a session directory to view diffs"}),Ae=t.jsxs("div",{className:F?"flex min-w-0 flex-1 items-center gap-1.5":"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[(S!==!1||m==="turn")&&(m==="all"||m==="working"||m==="staged"||m==="turn"||m==="branch")?t.jsx(Zt,{scope:m,isGitRepo:S,branchAvailable:!!(f&&d),allCount:me,workingCount:Y,stagedCount:ae,turnCount:B,branchCount:Q,focusedFilePath:ee?.path??null,onScopeChange:D=>{V(D),l?.(D)}}):t.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:t.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:$&&!h?"Loading changes...":W.length===1?`${W.length} file changed`:`${W.length} files changed`})}),W.length>0&&t.jsxs(Le,{variant:"ghost",size:"sm",onClick:oe,className:se("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:A.size>0?"Collapse all":"Expand all",children:[t.jsx(G,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:A.size>0?"Collapse all":"Expand all"})]}),W.length>0&&m!=="turn"&&m!=="branch"&&t.jsxs(Xt,{children:[t.jsx(Jt,{asChild:!0,children:t.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>z(D=>!D),"aria-pressed":N,"aria-label":N?"Unload full files":"Load full files",className:se("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",N&&"bg-interactive-selection text-interactive-selection-foreground"),children:t.jsx(G,{name:"file-download",className:"size-4"})})}),t.jsx(Yt,{children:t.jsx("p",{children:N?"Unload full files":"Load full files"})})]}),W.length>0&&t.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>w(!E),className:se("h-5 w-5 p-0 transition-opacity",E?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:E?"Disable line wrap":"Enable line wrap",children:t.jsx(G,{name:"text-wrap",className:"size-4"})}),H&&t.jsx(ft,{mode:H==="side-by-side"?"side-by-side":"unified",onModeChange:le})]});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[F?Rt.createPortal(Ae,F):c?null:Ae,te()]})};export{Rs as DiffView};
|
|
18
|
+
`);let e=null;for(const i of n){const o=i.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(o){const l=Number.parseInt(o[1]??"",10);e=Number.isFinite(l)&&l>=1?l:null;continue}if(e!==null){if(i.startsWith(" ")){e+=1;continue}if(i.startsWith("+"))return e;if(i.startsWith("-"))return Math.max(1,e)}}return null};function En({effectiveDirectory:s,activeDiffStaged:n,git:e,files:i,setDiff:o,openContextFileAtLine:l}){const[f,d]=r.useState(null),b=r.useCallback(async(g,c)=>{if(!s||!g)return;d(g);const p=ot();try{let F=null;if(c?.patch&&!c.isBinary&&!Re(g)?F=at(c.patch):c&&c.contextMode==="full"&&!c.isBinary&&!Re(g)&&(F=it(c.original,c.modified)),F===null)try{const $=await e.getGitDiff(s,{path:g,staged:n,contextLines:3});F=at($.diff)}catch{F=null}let k=c;if(F===null||!k){const $=await e.getGitFileDiff(s,{path:g,staged:n});k={original:$.original??"",modified:$.modified??"",isBinary:$.isBinary},n||o(s,g,k,p??void 0)}const x=F??(k.isBinary||Re(g)?1:it(k.original,k.modified)),S=Sn(s,g),h=await nn(i,S,{directory:s});if(!h.ok){dt.error(sn(h.reason));return}l(s,S,x,1)}finally{d(F=>F===g?null:F)}},[n,s,i,e,l,o]);return{openingEditorFilePath:f,openFileInEditorAtChange:b}}function An(s){const{hideStackedFileSidebar:n=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:i=!1,diffScope:o="all",branchBase:l=null,branchHead:f=null,targetFilePath:d=null}=s,{git:b,files:g}=ut(),c=zt(),{screenWidth:p,isMobile:F}=Ot(),k=Gt(c??null),x=Ht(c??null),S=Ut(c??null),h=ce(a=>a.setActiveDirectory),$=ce(a=>a.ensureStatus),m=ce(a=>a.fetchStatus),V=ce(a=>a.clearDiffCache),R=ce(a=>a.setDiff),[C,E]=r.useState(null),[w,y]=r.useState(!1),[L,M]=r.useState(()=>new Set),[A,_]=r.useState(()=>new Set),[N,z]=r.useState(!1),[q,K]=r.useState(0),[ie,ge]=r.useState(()=>new Map),[T,W]=r.useState(o);r.useEffect(()=>{W(o)},[o]);const J=Y(a=>a.pendingDiffFile),ae=Y(a=>a.pendingDiffStaged),B=Y(a=>a.pendingDiffScope),me=Y(a=>a.setPendingDiffFile),Q=Y(a=>a.diffLayoutPreference),H=Y(a=>a.diffFileLayout),re=Y(a=>a.setDiffFileLayout),ue=Y(a=>a.diffWrapLinesOverride),Z=Y(a=>a.wrapLinesByDefault),oe=Y(a=>a.setDiffWrapLines),De=Y(a=>a.openContextFileAtLine),xe=Vt(a=>a.currentSessionId),le=qt(xe??""),be=ue??Z,u=(T==="staged"?!0:T==="working"?!1:null)??w,P=F||p<=768,ne=!n&&!P&&p>=1024,de=r.useRef(null),{branchDiffs:ee,branchDiffError:ye,branchDiffLoading:we,lastTurnDiffs:O,lastTurnDiffData:te,branchDiffData:Ae}=Dn({activeDiffScope:T,effectiveDirectory:c,branchBase:l,branchHead:f,git:b,sessionMessageRecords:le}),D=r.useMemo(()=>{if(T==="turn"||T==="branch")return(T==="branch"?ee:O).map(I=>({path:I.file??"",index:"",working_dir:Ln(I.status),insertions:I.additions??0,deletions:I.deletions??0,isNew:I.status==="added"})).filter(I=>I.path).sort((I,X)=>I.path.localeCompare(X.path));if(!x?.files)return[];const a=x.diffStats??{},j=T==="staged"?Ge:T==="working"?He:()=>!0;return x.files.filter(j).map(v=>({...v,insertions:a[v.path]?.insertions??0,deletions:a[v.path]?.deletions??0,isNew:Qt(v)})).sort((v,I)=>v.path.localeCompare(I.path))},[T,ee,O,x]),U=r.useMemo(()=>x?.files?x.files.filter(He).length:0,[x]),Te=r.useMemo(()=>x?.files?x.files.filter(Ge).length:0,[x]),$e=O.length,We=x?.files?.length??0,bt=ee.length,{diffScrollRef:yt,pinnedStackedTarget:wt,pendingScrollTargetRef:Fe,shouldPinAfterAlignRef:je,pendingScrollAnchorRestoreRef:Ve,lastScrollAnchorRef:qe,captureScrollAnchor:Ke,cancelPendingScrollAlignment:ve,queueVisibleStackedFilesSync:Me,registerSectionRef:Ft,scrollToFile:Xe}=Rn({pinSelectedFileHeaderToTopOnNavigate:i,scrollRequestNonce:q,changedFiles:D,expandedFiles:L,setMountedStackedFiles:_,fileDiffRefreshNonce:ie}),Se=r.useCallback(a=>{M(j=>{if(j.has(a))return j;const v=new Set(j);return v.add(a),v})},[]),Ie=r.useRef(null),_e=r.useMemo(()=>D.map(a=>a.path).join("\0"),[D]);r.useEffect(()=>{const a=_e?_e.split("\0"):[],j=new Set(a),v=`${c??""}:${T}:${e?"collapsed":"default"}`,I=de.current!==v;de.current=v;const X=Ie.current,Ne=X&&j.has(X)?X:null;Ne&&(Ie.current=null),M(ke=>{if(I){const pe=e?0:vn(a.length),Ye=new Set(a.slice(0,pe));return Ne&&Ye.add(Ne),Ye}let Ce=!1;const fe=new Set;for(const pe of ke){if(!j.has(pe)){Ce=!0;continue}fe.add(pe)}return Ne&&!fe.has(Ne)&&(fe.add(Ne),Ce=!0),Ce?fe:ke}),_(ke=>{if(I)return new Set;let Ce=!1;const fe=new Set;for(const pe of ke){if(!j.has(pe)){Ce=!0;continue}fe.add(pe)}return Ce?fe:ke})},[T,_e,c,_,e]);const Be=r.useCallback(a=>{const j=H[a.path];if(j)return j;if(Q==="inline")return"inline";if(Q==="side-by-side")return"side-by-side";const v=p<jn;return a.isNew||v?"inline":"side-by-side"},[H,Q,p]),jt=r.useMemo(()=>D.length===0?null:D.every(a=>Be(a)==="side-by-side")?"side-by-side":"inline",[D,Be]);r.useEffect(()=>{c&&(h(c),$(c,b))},[c,h,$,b]),r.useEffect(()=>{if(c)return Kt.onGitRefreshHint(a=>{Je(a.directory)===Je(c)&&(a.paths?.length&&(Ve.current=Ke()??qe.current,V(c,a.paths),ge(j=>{const v=new Map(j);for(const I of a.paths??[])v.set(I,(v.get(I)??0)+1);return v})),m(c,b,{silent:!0}))})},[Ke,V,c,m,b,qe,Ve]),r.useEffect(()=>{T!=="all"&&!B||J&&(B&&W(B),E(J),y(B==="staged"||!B&&ae),me(null),je.current=!0,Fe.current=J,Ie.current=J,Se(J),K(a=>a+1))},[T,Se,J,B,ae,Fe,me,je]),r.useEffect(()=>{if(T==="all")return;const a=d?.trim();a&&(E(a),y(T==="staged"),je.current=!0,Fe.current=a,Ie.current=a,Se(a),K(j=>j+1))},[T,Se,Fe,je,d]),r.useEffect(()=>{if(!C)return;D.some(j=>j.path===C)||(E(null),y(!1))},[D,C]);const vt=r.useCallback((a,j)=>{ve(),M(v=>{const I=v.has(a);if(j===I)return v;const X=new Set(v);return j?X.add(a):X.delete(a),X}),_(v=>{const I=v.has(a);if(j===I)return v;const X=new Set(v);return j?X.add(a):X.delete(a),X}),Me()},[ve,Me,_]),St=r.useCallback(()=>{ve(),M(a=>a.size>0?new Set:new Set(D.map(j=>j.path))),_(new Set),Me()},[ve,D,Me,_]),Nt=r.useCallback(a=>{},[]),Ct=r.useCallback(a=>{ve(),E(a),y(!1),je.current=!0,Fe.current=a,Se(a),K(j=>j+1),Xe(a)},[ve,Se,Fe,Xe,je]),Lt=r.useCallback(a=>{const j=a==="side-by-side"?"side-by-side":"inline";D.forEach(v=>{re(v.path,j)})},[D,re]),{openingEditorFilePath:Dt,openFileInEditorAtChange:kt}=En({effectiveDirectory:c,activeDiffStaged:u,git:b,files:g,setDiff:R,openContextFileAtLine:De});return{git:b,files:g,effectiveDirectory:c,screenWidth:p,isMobile:F,isGitRepo:k,status:x,isLoadingStatus:S,activeDiffScope:T,setActiveDiffScope:W,branchDiffs:ee,branchDiffError:ye,branchDiffLoading:we,diffWrapLines:be,setDiffWrapLines:oe,displayFileStaged:w,displayFile:C,pinnedStackedTarget:wt,expandedFiles:L,mountedStackedFiles:A,loadFullFiles:N,setLoadFullFiles:z,fileDiffRefreshNonce:ie,showFileSidebar:ne,diffScrollRef:yt,lastTurnDiffData:te,branchDiffData:Ae,changedFiles:D,workingFileCount:U,stagedFileCount:Te,turnFileCount:$e,allFileCount:We,branchFileCount:bt,currentLayoutForAllFiles:jt,openingEditorFilePath:Dt,registerSectionRef:Ft,handleStackedEntryExpandedChange:vt,handleExpandOrCollapseAll:St,handleSelectFile:Nt,handleSelectFileAndScroll:Ct,handleHeaderLayoutChange:Lt,openFileInEditorAtChange:kt,getLayoutForFile:Be}}const Rs=({hideStackedFileSidebar:s=!1,stackedDefaultCollapsedAll:n=!1,pinSelectedFileHeaderToTopOnNavigate:e=!1,showOpenInEditorAction:i=!1,diffScope:o="all",onDiffScopeChange:l,branchBase:f=null,branchHead:d=null,targetFilePath:b=null,flushContent:g=!1,hideToolbar:c=!1,onHeaderControlsStateChange:p,toolbarSlot:F=null,onlyFilePath:k=null})=>{const{effectiveDirectory:x,isGitRepo:S,status:h,isLoadingStatus:$,activeDiffScope:m,setActiveDiffScope:V,branchDiffError:R,branchDiffLoading:C,diffWrapLines:E,setDiffWrapLines:w,displayFileStaged:y,displayFile:L,pinnedStackedTarget:M,expandedFiles:A,mountedStackedFiles:_,loadFullFiles:N,setLoadFullFiles:z,fileDiffRefreshNonce:q,showFileSidebar:K,diffScrollRef:ie,lastTurnDiffData:ge,branchDiffData:T,changedFiles:W,workingFileCount:J,stagedFileCount:ae,turnFileCount:B,allFileCount:me,branchFileCount:Q,currentLayoutForAllFiles:H,openingEditorFilePath:re,registerSectionRef:ue,handleStackedEntryExpandedChange:Z,handleExpandOrCollapseAll:oe,handleSelectFile:De,handleSelectFileAndScroll:xe,handleHeaderLayoutChange:le,openFileInEditorAtChange:be,getLayoutForFile:Ee}=An({hideStackedFileSidebar:s,stackedDefaultCollapsedAll:n,pinSelectedFileHeaderToTopOnNavigate:e,diffScope:o,branchBase:f,branchHead:d,targetFilePath:b});r.useEffect(()=>{c&&l?.(m)},[m,c,l]);const u=r.useCallback(()=>{z(D=>!D)},[z]),P=r.useCallback(()=>{w(!E)},[E,w]),ne=r.useCallback(()=>{le(H==="side-by-side"?"unified":"side-by-side")},[H,le]),de=A.size,ee=k&&m!=="turn"&&m!=="branch"?W.find(D=>D.path===k)??null:null,ye=ee?[ee]:W,we=r.useMemo(()=>({turnCount:B,branchCount:Q,focusedFilePath:ee?.path??null,expandedCount:de,totalCount:W.length,loadFullFiles:N,wrapLines:E,layoutMode:H,onExpandOrCollapseAll:oe,onToggleLoadFullFiles:u,onToggleWrapLines:P,onToggleLayout:ne}),[B,Q,ee,de,W.length,N,E,H,oe,u,P,ne]);r.useEffect(()=>{c&&p?.(we)},[c,we,p]);const O=()=>{if(!x)return null;const D={path:L,staged:y};return t.jsxs("div",{className:se("flex min-w-0 flex-1 min-h-0 h-full",g?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[K&&t.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[t.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:"Files"}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:W.length})]}),t.jsx(fn,{changedFiles:W,selectedFile:null,onSelectFile:xe})]}),t.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:t.jsxs(lt,{ref:ie,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none]",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:[t.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:ye.map(U=>{const Te=pn(m,U,D);return t.jsx(Fn,{directory:x,file:U,layout:Ee(U),wrapLines:E,isSelected:!1,isExpanded:A.has(U.path),isMounted:_.has(U.path)||U.path===M,onSelect:De,onExpandedChange:Z,registerSectionRef:ue,showOpenInEditorAction:i&&m!=="turn"&&m!=="branch",isOpeningInEditor:re===U.path,onOpenInEditor:($e,We)=>{be($e,We)},diffSource:Te.source,staged:Te.staged,stageLabel:hn(m,U),partlyStaged:mt(m,U),showFileActions:m!=="turn"&&m!=="branch",loadFullFiles:N,initialDiffData:m==="turn"?ge.get(U.path)??null:m==="branch"?T.get(U.path)??null:null},`${U.path}:${q.get(U.path)??0}`)})}),t.jsx("div",{"aria-hidden":"true",className:"h-16 shrink-0"})]})})]})},te=()=>x?m!=="turn"&&$&&!h?t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(G,{name:"loader-4",className:"size-4 animate-spin"}),"Loading repository status..."]}):m!=="turn"&&m!=="branch"&&S===!1?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Not a git repository. Use the Git tab to initialize or change directories."}):m==="branch"&&C?t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(G,{name:"loader-4",className:"size-4 animate-spin"}),"Loading branch changes..."]}):m==="branch"&&R?t.jsx("div",{className:"flex flex-1 items-center justify-center px-4 text-center text-sm text-muted-foreground",children:`Failed to load branch changes: ${R}`}):W.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:m==="turn"?"No last turn changes to display":"Working tree clean, no changes to display"}):O():t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Select a session directory to view diffs"}),Ae=t.jsxs("div",{className:F?"flex min-w-0 flex-1 items-center gap-1.5":"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[(S!==!1||m==="turn")&&(m==="all"||m==="working"||m==="staged"||m==="turn"||m==="branch")?t.jsx(Zt,{scope:m,isGitRepo:S,branchAvailable:!!(f&&d),allCount:me,workingCount:J,stagedCount:ae,turnCount:B,branchCount:Q,focusedFilePath:ee?.path??null,onScopeChange:D=>{V(D),l?.(D)}}):t.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:t.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:$&&!h?"Loading changes...":W.length===1?`${W.length} file changed`:`${W.length} files changed`})}),W.length>0&&t.jsxs(Le,{variant:"ghost",size:"sm",onClick:oe,className:se("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:A.size>0?"Collapse all":"Expand all",children:[t.jsx(G,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:A.size>0?"Collapse all":"Expand all"})]}),W.length>0&&m!=="turn"&&m!=="branch"&&t.jsxs(Xt,{children:[t.jsx(Yt,{asChild:!0,children:t.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>z(D=>!D),"aria-pressed":N,"aria-label":N?"Unload full files":"Load full files",className:se("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",N&&"bg-interactive-selection text-interactive-selection-foreground"),children:t.jsx(G,{name:"file-download",className:"size-4"})})}),t.jsx(Jt,{children:t.jsx("p",{children:N?"Unload full files":"Load full files"})})]}),W.length>0&&t.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>w(!E),className:se("h-5 w-5 p-0 transition-opacity",E?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:E?"Disable line wrap":"Enable line wrap",children:t.jsx(G,{name:"text-wrap",className:"size-4"})}),H&&t.jsx(ft,{mode:H==="side-by-side"?"side-by-side":"unified",onModeChange:le})]});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[F?Rt.createPortal(Ae,F):c?null:Ae,te()]})};export{Rs as DiffView};
|
package/dist/assets/{FileSaveConflictDialog-p1ik30al.js → FileSaveConflictDialog-C_MNWp6w.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as r}from"./vendor-boot-
|
|
1
|
+
import{j as r}from"./vendor-boot-3SaHYVb1.js";import{R as a}from"./vendor-react-Bz1tRBxM.js";import{D}from"./vendor-react-drawio-IYnLUY5N.js";import{f as C}from"./index-fmzQmSSv.js";import{av as E,aw as S,aB as N,ax as B,ay as F,aC as H,B as p}from"./useAppFontEffects-FKnY7Fe2.js";const A='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function w(){if(typeof document>"u")return!1;const t=document.documentElement.getAttribute("data-theme");return t==="dark"||!t&&window.matchMedia("(prefers-color-scheme: dark)").matches}const T=a.forwardRef(function({xml:e,readOnly:s,className:d,onChange:u},m){const l=a.useRef(e),c=a.useRef(null),i=a.useRef(!1),[o,y]=a.useState(w),f=a.useRef(e),h=a.useRef(e);h.current!==e&&(h.current=e,f.current=e,l.current=e);const v=a.useRef(o);v.current!==o&&(v.current=o,f.current=l.current);const g=a.useRef(null);a.useEffect(()=>{const n=()=>y(w());n();const x=new MutationObserver(n);return x.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>x.disconnect()},[]),a.useEffect(()=>{const n=setTimeout(()=>{g.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(n)},[]),a.useImperativeHandle(m,()=>({getXml:()=>l.current}));const R=a.useCallback(()=>{!e&&!i.current&&(i.current=!0,setTimeout(()=>{c.current?.template({})},500))},[e]),j=a.useCallback(n=>{l.current=n.xml,u?.(n.xml)},[u]);return r.jsx("div",{ref:g,className:C("h-full w-full",d),children:r.jsx(D,{ref:c,xml:f.current||A,autosave:!0,urlParameters:{ui:s?"simple":o?"dark":"kennedy",spin:!0,libraries:!s,chrome:s,nav:s,layers:s,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:R,onAutoSave:j},o?"dark":"light")})}),X=(t,e)=>!t||t.runtimeKey!==e.runtimeKey||t.root!==e.root||t.path!==e.path||t.generation!==e.generation,b=t=>{if(typeof t=="string")return t;if(t===null)return null},G=(t,e)=>{if(e===!0)return t!==void 0?{expectedRevision:b(t),overwrite:!0}:{overwrite:!0};if(t!==void 0)return{expectedRevision:b(t)}},W=(t,e)=>!!(t&&e&&t.runtimeKey===e.runtimeKey&&t.root===e.root&&t.path===e.path&&t.generation===e.generation),k=(t,e=4e3)=>t.length>e?`${t.slice(0,e)}
|
|
2
2
|
|
|
3
3
|
… truncated …`:t,Y=({open:t,conflict:e,isResolving:s,showCompare:d,onToggleCompare:u,onReload:m,onOverwrite:l,onClose:c})=>{if(!e)return null;const i=!e.exists;return r.jsx(E,{open:t,onOpenChange:o=>{o||c()},children:r.jsxs(S,{showCloseButton:!1,className:"max-w-lg",children:[r.jsxs(N,{children:[r.jsx(B,{children:i?"File deleted on disk":"File changed on disk"}),r.jsx(F,{children:i?`“${e.displayPath}” was deleted since you opened it. Your edits are preserved. Reload to discard them, or overwrite to recreate the file.`:`“${e.displayPath}” changed since you opened it. Your edits are preserved. Reload to discard them and load the current version, or overwrite to keep your edits.`})]}),d&&!i?r.jsxs("div",{className:"grid max-h-64 grid-cols-1 gap-2 overflow-auto py-2",children:[r.jsxs("div",{children:[r.jsx("div",{className:"typography-meta text-muted-foreground",children:"Current version on disk"}),r.jsx("pre",{className:"mt-1 max-h-28 overflow-auto rounded-md bg-[var(--surface-subtle)] p-2 text-xs whitespace-pre-wrap break-words",children:k(e.currentContent??"")})]}),r.jsxs("div",{children:[r.jsx("div",{className:"typography-meta text-muted-foreground",children:"Your edits"}),r.jsx("pre",{className:"mt-1 max-h-28 overflow-auto rounded-md bg-[var(--surface-subtle)] p-2 text-xs whitespace-pre-wrap break-words",children:k(e.dirtyContent)})]})]}):null,r.jsxs(H,{className:"flex flex-wrap gap-2",children:[i?null:r.jsx(p,{variant:"outline",onClick:u,disabled:s,"aria-label":d?"Hide version comparison":"Compare versions",title:d?"Hide version comparison":"Compare versions",children:d?"Hide compare":"Compare"}),r.jsx(p,{variant:"outline",onClick:m,disabled:s,"aria-label":i?"Discard edits and close":"Reload current version",title:i?"Discard edits and close":"Reload current version",children:i?"Discard edits":"Reload"}),r.jsx(p,{variant:"destructive",onClick:l,disabled:s,"aria-label":i?"Recreate file with my edits":"Overwrite with my edits",title:i?"Recreate file with my edits":"Overwrite with my edits",children:s?"Working…":"Overwrite"})]})]})})};export{T as D,Y as F,G as b,W as i,X as s};
|