@pi-chamber/web 1.0.4-rc.2 → 1.0.4
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-BpG1c3Hi.js +1 -0
- package/dist/assets/{DiffView-Cay8VAqL.js → DiffView-BxwoRCYx.js} +5 -5
- package/dist/assets/FileSaveConflictDialog-DP7k9a-i.js +3 -0
- package/dist/assets/{FilesView-CEeQzjc6.js → FilesView-D_2QcdUt.js} +4 -4
- package/dist/assets/{GitHubDetailScaffold-q4YP8iyJ.js → GitHubDetailScaffold-UxLAMAOl.js} +2 -2
- package/dist/assets/GitHubLinkPicker-Bh9RO1yK.js +1 -0
- package/dist/assets/{GitHubListPrimitives-XkALat1v.js → GitHubListPrimitives-DQyhT5wG.js} +1 -1
- package/dist/assets/{GitView-DV3d0oSJ.js → GitView-XBBheKRM.js} +4 -4
- package/dist/assets/{IssuesSurface-OTyt9f3A.js → IssuesSurface-BA1kpvAJ.js} +3 -3
- package/dist/assets/{JsonTreeView-X2Auiy_q.js → JsonTreeView-BAaEPL4O.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-DzgDmUsL.js +12 -0
- package/dist/assets/{PatchDiff-GMQAv4en.js → PatchDiff-BMEUsgXH.js} +1 -1
- package/dist/assets/{PierreDiffViewer-0X__nypk.js → PierreDiffViewer-BW8MO-O6.js} +2 -2
- package/dist/assets/PullRequestsSurface-B3ictm4I.js +2 -0
- package/dist/assets/SessionSwitcherContent-rLoyVqgs.js +1 -0
- package/dist/assets/SessionSwitcherDropdown-CfySKnUu.js +2 -0
- package/dist/assets/{SessionUnreadDot-CJFawQpo.js → SessionUnreadDot-CmEF9sxM.js} +1 -1
- package/dist/assets/SettingsView-BiwlwnTK.js +6 -0
- package/dist/assets/SettingsWindow-j0e99YI0.js +1 -0
- package/dist/assets/ToolOutputDialog-VlS12Xyq.js +8 -0
- package/dist/assets/ToolPartDiffPreview-DdSneZws.js +1 -0
- package/dist/assets/{VirtualizedFileDiff-CUWx7JVZ.js → VirtualizedFileDiff-BqiXjvP6.js} +1 -1
- package/dist/assets/{Virtualizer-wpC51ZBQ.js → Virtualizer-Cp_cJWbI.js} +1 -1
- package/dist/assets/{collapsible-Ce85nuXX.js → collapsible-C7oyikVm.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-3PpRLd5B.js → computeVirtualFileMetrics-BJjC-tXV.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-PoBklHMz.js → contextFileOpenGuard-BBzqKGei.js} +1 -1
- package/dist/assets/{gitStatusPredicates-BvzxqidP.js → gitStatusPredicates-Dq-E5DaH.js} +1 -1
- package/dist/assets/{githubLink-iQ51wqRa.js → githubLink-Cryd7GkG.js} +5 -5
- package/dist/assets/index-BbhXFTId.js +1 -0
- package/dist/assets/index-BnZVqcki.js +11 -0
- package/dist/assets/index-BnieExes.css +1 -0
- package/dist/assets/{main-PSCt716b.js → main-9O5IAtT_.js} +4 -4
- package/dist/assets/{main-FasHq7Ck.js → main-DWGwALIw.js} +2 -2
- package/dist/assets/{markdownCore-BH56o6Wu.js → markdownCore-B9AuEyYi.js} +1 -1
- package/dist/assets/miniChat-CgOaJfD8.js +2 -0
- package/dist/assets/mobile-BbJcYVym.js +2 -0
- package/dist/assets/nativeFileSave-BzhtrDoD.js +1 -0
- package/dist/assets/{pi-session-focus-preference-D2-1HWmY.js → pi-session-focus-preference-Bmk1iOvn.js} +4 -4
- package/dist/assets/{renderDiffWithHighlighter-l8hZWWBO.js → renderDiffWithHighlighter-CVLsdtQ5.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-R5o9NwFC.js +2 -0
- package/dist/assets/{renderFileWithHighlighter-BvDoP7ob.js → renderFileWithHighlighter-DJ9mk2bZ.js} +1 -1
- package/dist/assets/renderMobileApp-CQ9tWYIj.js +11 -0
- package/dist/assets/runtimeEndpointReset-CtK4C_5h.js +62 -0
- package/dist/assets/{runtimeSurface-B1GRkkKC.js → runtimeSurface-DBiUWYK2.js} +1 -1
- package/dist/assets/useAppFontEffects-DviRbaCJ.js +212 -0
- package/dist/assets/{useFilesViewSearch-D1jsGQrN.js → useFilesViewSearch-D2Au5Xgt.js} +1 -1
- package/dist/assets/{useGitHubRemoteSearch-zNgy2bSt.js → useGitHubRemoteSearch-D-K7aolk.js} +1 -1
- package/dist/assets/{useSwitcherItems-OCRYcHeu.js → useSwitcherItems-Dej8BzXI.js} +1 -1
- package/dist/assets/vendor-aparajita-capacitor-secure-storage-BYohCVY0.js +1 -0
- package/dist/assets/{vendor-base-ui-DIkTOIJS.js → vendor-base-ui-BscvGUFt.js} +1 -1
- package/dist/assets/vendor-boot-Dgb9NVFe.js +69 -0
- package/dist/assets/vendor-capacitor-app-BjdQVib9.js +1 -0
- package/dist/assets/vendor-capacitor-keyboard-eTtI5go3.js +1 -0
- package/dist/assets/vendor-capacitor-push-notifications-CBKq2Arn.js +1 -0
- package/dist/assets/vendor-capacitor-status-bar-9rNIGxlO.js +1 -0
- package/dist/assets/{vendor-codemirror-autocomplete-DsFn4GLp.js → vendor-codemirror-autocomplete-DxS3jwvE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-B_NMmBbS.js → vendor-codemirror-lang-angular-DdjXl9e2.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-cpp--aMr7NVt.js +1 -0
- package/dist/assets/vendor-codemirror-lang-css-CZ_qxZY9.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-go-C2KHbcll.js → vendor-codemirror-lang-go-Ca-y2Alu.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-html-COZ0L5wT.js +1 -0
- package/dist/assets/vendor-codemirror-lang-java-D3Rf3QNJ.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-javascript-DpTUrvx8.js → vendor-codemirror-lang-javascript-DwJ-IvCs.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-jinja-D_5lod6k.js +1 -0
- package/dist/assets/vendor-codemirror-lang-json-BG8C7OpC.js +1 -0
- package/dist/assets/vendor-codemirror-lang-less-CVEkoaTw.js +1 -0
- package/dist/assets/vendor-codemirror-lang-liquid-U9vj0m8w.js +1 -0
- package/dist/assets/vendor-codemirror-lang-markdown-DqlYH9gY.js +1 -0
- package/dist/assets/vendor-codemirror-lang-php-BFEiEVA1.js +1 -0
- package/dist/assets/vendor-codemirror-lang-python-Cz1dQXQd.js +3 -0
- package/dist/assets/vendor-codemirror-lang-rust-C_CoD9mj.js +1 -0
- package/dist/assets/vendor-codemirror-lang-sass-BuR0aKh5.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-sql-C_RazIaB.js → vendor-codemirror-lang-sql-DggNUjdM.js} +2 -2
- package/dist/assets/{vendor-codemirror-lang-vue-BYL0r7KR.js → vendor-codemirror-lang-vue-DFZHi2J3.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-wast-zuTN3SHT.js +1 -0
- package/dist/assets/vendor-codemirror-lang-xml-CrcvhI-k.js +1 -0
- package/dist/assets/vendor-codemirror-lang-yaml-DcVWsakb.js +1 -0
- package/dist/assets/{vendor-codemirror-language-data-DglcKYWT.js → vendor-codemirror-language-data-CCLITgCF.js} +2 -2
- package/dist/assets/{vendor-codemirror-search-DaE6R5gH.js → vendor-codemirror-search-H7NOEdbX.js} +2 -2
- package/dist/assets/{vendor-lezer-cpp-Dt99h3WT.js → vendor-lezer-cpp-C8aD2KAr.js} +1 -1
- package/dist/assets/{vendor-lezer-css-DNU_fzPI.js → vendor-lezer-css-2lbTJF-Y.js} +1 -1
- package/dist/assets/{vendor-lezer-go-BEFtcNyS.js → vendor-lezer-go-Bw6LFTrZ.js} +1 -1
- package/dist/assets/{vendor-lezer-html-DDGRhRUz.js → vendor-lezer-html-D7ym2z7S.js} +1 -1
- package/dist/assets/{vendor-lezer-java-DmfZtW09.js → vendor-lezer-java-CZhK7w21.js} +1 -1
- package/dist/assets/{vendor-lezer-javascript-oje4tdp_.js → vendor-lezer-javascript-rpKeTHZp.js} +1 -1
- package/dist/assets/{vendor-lezer-json-BRXb_bDX.js → vendor-lezer-json-C7jwsd2G.js} +1 -1
- package/dist/assets/{vendor-lezer-lr-BU2qmu_5.js → vendor-lezer-lr-DR-ylqNN.js} +1 -1
- package/dist/assets/{vendor-lezer-markdown-CicYv7V9.js → vendor-lezer-markdown-Bir0m5nB.js} +1 -1
- package/dist/assets/{vendor-lezer-php-COORrTpE.js → vendor-lezer-php-y0hIEfo1.js} +1 -1
- package/dist/assets/{vendor-lezer-python-Cuvm9X9Y.js → vendor-lezer-python-D64A9lNV.js} +1 -1
- package/dist/assets/{vendor-lezer-rust-C_zOfHbX.js → vendor-lezer-rust-E3ZA9T2L.js} +1 -1
- package/dist/assets/{vendor-lezer-sass-DWP4w7O1.js → vendor-lezer-sass-C5UFI9SP.js} +1 -1
- package/dist/assets/{vendor-lezer-xml-Br6nOYeG.js → vendor-lezer-xml-DOy7FzCR.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-CYQmm6Sb.js → vendor-lezer-yaml-kEjaSCvZ.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-CZy3BUVv.js → vendor-replit-codemirror-vim-BLfh0LPy.js} +1 -1
- package/dist/assets/{web-components-v9fuidaX.js → web-components-C7CmoFxi.js} +1 -1
- 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/routes.js +1 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -1
- package/server/lib/pi/session-daemon/supervisor.js +13 -1
- package/server/lib/pi/session-daemon/supervisor.test.js +92 -0
- package/server/lib/relay/DOCUMENTATION.md +4 -0
- package/server/lib/terminal/DOCUMENTATION.md +1 -0
- package/dist/assets/DiagramView-GKGxPczP.js +0 -1
- package/dist/assets/FileSaveConflictDialog-BRM9TJo0.js +0 -3
- package/dist/assets/GitHubLinkPicker-B9xgIW8y.js +0 -1
- package/dist/assets/MarkdownRendererImpl-1HameF6j.js +0 -12
- package/dist/assets/PullRequestsSurface-Dec20SIg.js +0 -2
- package/dist/assets/SessionSwitcherContent-DEw4nz7K.js +0 -1
- package/dist/assets/SessionSwitcherDropdown-DmLhbRzE.js +0 -2
- package/dist/assets/SettingsView-CwSspvq-.js +0 -6
- package/dist/assets/SettingsWindow-DkPv9MaU.js +0 -1
- package/dist/assets/ToolOutputDialog-DDwbOpTO.js +0 -8
- package/dist/assets/ToolPartDiffPreview-DZRP7p-Q.js +0 -1
- package/dist/assets/index-CkMnC_GK.js +0 -1
- package/dist/assets/index-Dd2OcIUY.js +0 -10
- package/dist/assets/index-DvN8zlLT.css +0 -1
- package/dist/assets/miniChat-BzfobBDq.js +0 -2
- package/dist/assets/mobile-DAzZE2EL.js +0 -2
- package/dist/assets/renderElectronMiniChatApp-DGYSIihR.js +0 -2
- package/dist/assets/renderMobileApp-CwgWG0lU.js +0 -11
- package/dist/assets/runtimeEndpointReset-CmI6dBKM.js +0 -62
- package/dist/assets/useAppFontEffects--lKKtKVo.js +0 -212
- package/dist/assets/vendor-aparajita-capacitor-secure-storage-5IShChL0.js +0 -1
- package/dist/assets/vendor-boot-DyL2td56.js +0 -69
- package/dist/assets/vendor-capacitor-app-BrDJj9I_.js +0 -1
- package/dist/assets/vendor-capacitor-core-B4EWRrHz.js +0 -1
- package/dist/assets/vendor-capacitor-keyboard-CYccoJjr.js +0 -1
- package/dist/assets/vendor-capacitor-push-notifications-KNe1zSBF.js +0 -1
- package/dist/assets/vendor-capacitor-status-bar-B-N0EOVk.js +0 -1
- package/dist/assets/vendor-codemirror-lang-cpp-GOE7Gjd0.js +0 -1
- package/dist/assets/vendor-codemirror-lang-css-Dwf2XpnZ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-html-DcKqyeGk.js +0 -1
- package/dist/assets/vendor-codemirror-lang-java-6eGbyB2k.js +0 -1
- package/dist/assets/vendor-codemirror-lang-jinja-xSUJjXhr.js +0 -1
- package/dist/assets/vendor-codemirror-lang-json-CLGxdOCz.js +0 -1
- package/dist/assets/vendor-codemirror-lang-less-6nXi1rS9.js +0 -1
- package/dist/assets/vendor-codemirror-lang-liquid-B9hmb9P8.js +0 -1
- package/dist/assets/vendor-codemirror-lang-markdown-DmFP9s6x.js +0 -1
- package/dist/assets/vendor-codemirror-lang-php-DC6To8iX.js +0 -1
- package/dist/assets/vendor-codemirror-lang-python-yuxIkjit.js +0 -3
- package/dist/assets/vendor-codemirror-lang-rust-di1Sjz-0.js +0 -1
- package/dist/assets/vendor-codemirror-lang-sass-BWpV9NPV.js +0 -1
- package/dist/assets/vendor-codemirror-lang-wast-BiVarhcz.js +0 -1
- package/dist/assets/vendor-codemirror-lang-xml-Cn1lY1ts.js +0 -1
- package/dist/assets/vendor-codemirror-lang-yaml-BZ6mZw9L.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as c}from"./vendor-boot-Dgb9NVFe.js";import{R as t}from"./vendor-react-DASdDPIk.js";import{q as $,t as d,I as A}from"./useAppFontEffects-DviRbaCJ.js";import{t as V,a as G,A as ee,bY as W}from"./index-BnZVqcki.js";import{b as te,D as re,F as ne}from"./FileSaveConflictDialog-DP7k9a-i.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-DBiUWYK2.js";import"./nativeFileSave-BzhtrDoD.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-react-drawio-Duu5LgQA.js";const se=l=>l.split("/").pop()||l;function xe(){const{files:l}=$(),[x,k]=t.useState(null),[q,R]=t.useState(""),[L,E]=t.useState(!0),[b,h]=t.useState(null),[m,F]=t.useState(!1),[M,p]=t.useState(!1),[j,P]=t.useState(!1),[U,Y]=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&&G()===n&&w.current===s,[]),K=t.useCallback(async e=>{const n=v.current+1;v.current=n;const s=G(),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&&K(e)}),[K]),t.useEffect(()=>{if(!T)return;const e=V.getState().consumePendingDiagramFile();e&&K(e)},[K,T]);const z=t.useCallback(async(e,n,s,u,r,o)=>{let a=null,f=s,B=u;try{if(B){const N=await l?.readFile?.(e);if(!i(r,o,e))return;N&&(a=N.content??null,typeof N.revision=="string"&&(f=N.revision),B=N.exists!==!1)}}catch{if(!i(r,o,e))return}i(r,o,e)&&(h({path:e,displayPath:se(e),exists:B,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)},[]),H=t.useCallback(async()=>{const e=D.current?.getXml();if(!x||!l?.writeFile||!e||e===C.current||j||m)return;const n=v.current,s=G(),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 z(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,z,X]),J=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,Y(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]),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(!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 z(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,z,X,b]),Z=t.useCallback(()=>{m||j||(h(null),p(!1))},[m,j]),_=x?x.split("/").pop()||x:"";return x?L?c.jsx("div",{className:"flex h-full items-center justify-center p-3",children:c.jsx(A,{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(A,{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:()=>{H()},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(A,{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(A,{name:"close",className:"size-4"})})]}),c.jsx("div",{className:"flex-1 min-h-0",children:c.jsx(re,{ref:D,xml:q,className:"h-full"},U)}),c.jsx(ne,{open:!!b,conflict:b,isResolving:m||j,showCompare:M,onToggleCompare:()=>p(e=>!e),onReload:()=>{J()},onOverwrite:()=>{Q()},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,18 +1,18 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{k as n,aL as St}from"./vendor-boot-Dgb9NVFe.js";import{R as r}from"./vendor-react-DASdDPIk.js";import{o as se,t as Q,a as Ze,C as ze}from"./index-BnZVqcki.js";import{dN as vt,dv as Ct,dL as Nt,aj as et,a7 as tt,ck as jt,cl as je,B as Le,I as J,q as nt,aD as oe,t as st,dD as it,ce as Lt,dO as Dt,dP as kt,p as Rt,a4 as Et,ay as At,ah as Tt,cF as Mt,h as It,at as $t,aM as Pt,a9 as _t,aa as Wt,ac as Bt}from"./useAppFontEffects-DviRbaCJ.js";import{d as rt,i as Ge,a as He,b as Ot,C as zt}from"./gitStatusPredicates-Dq-E5DaH.js";import{p as Gt}from"./VirtualizedFileDiff-BqiXjvP6.js";import{P as Ht}from"./PierreDiffViewer-BW8MO-O6.js";import{v as Ut,g as Vt}from"./contextFileOpenGuard-BBzqKGei.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./runtimeSurface-DBiUWYK2.js";import"./nativeFileSave-BzhtrDoD.js";import"./web-components-C7CmoFxi.js";import"./computeVirtualFileMetrics-BJjC-tXV.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.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-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.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-CVLsdtQ5.js";import"./vendor-diff-C3JhlQdm.js";import"./runtimeEndpointReset-CtK4C_5h.js";import"./SessionUnreadDot-CmEF9sxM.js";/* empty css */import"./permissionStore-B9Hkrqny.js";import"./appThemeRegistry-gegrE2dq.js";import"./registerCustomTheme-DmolaWWZ.js";function Kt(t,s=10){const e=[];let i;for(const l of t.split(`
|
|
2
2
|
`)){const p=l.match(vt);if(p!=null){i!=null&&(i.hunkLines.length>0&&(Re(i,s,"trailing"),Ie(i,e)),i=void 0);const u=parseInt(p[3]),b=parseInt(p[1]),g=parseInt(p[4]??"1"),c=parseInt(p[2]??"1");isNaN(u)||isNaN(b)||isNaN(g)||isNaN(c)?e.push(l):i={additionStart:u,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>s*2){const u=i.contextLines.length-s*2,b=i.contextLines.slice(-s);Re(i,s,"trailing");const{additionCount:g,deletionCount:c}=i;Ie(i,e),i={additionStart:i.additionStart+g+u,deletionStart:i.deletionStart+c+u,deletionCount:0,additionCount:0,contextLines:b,hunkLines:[]}}Re(i,s,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&&(Re(i,s,"trailing"),Ie(i,e));const a=e.join(`
|
|
3
3
|
`);return t.endsWith(`
|
|
4
4
|
`)?`${a}
|
|
5
|
-
`:a}function Re(t,s,e){if(e==="leading"&&t.contextLines.length>s){const i=t.contextLines.length-s;t.contextLines.splice(0,i),t.additionStart+=i,t.deletionStart+=i}return e==="trailing"&&t.contextLines.length>s&&(t.contextLines.length=s),t.contextLines.length>0&&(t.hunkLines.push(...t.contextLines),t.additionCount+=t.contextLines.length,t.deletionCount+=t.contextLines.length,t.contextLines.length=0),t}function Ie(t,s){s.push(`@@ -${Ue(t.deletionStart,t.deletionCount)} +${Ue(t.additionStart,t.additionCount)} @@`),s.push(...t.hunkLines)}function Ue(t,s){return s===1?`${t}`:`${t},${s}`}const qt=64,Xt=3,de=new Map,Yt=(t,s,e=Xt)=>{const i=`${t}\0${e}\0${s}`,a=de.get(i);if(a)return de.delete(i),de.set(i,a),a;const l=Qt(s),p=l?Ct(Kt(s,e),{oldFile:{name:t,contents:l.before},newFile:{name:t,contents:l.after}})??Ke(t):
|
|
5
|
+
`:a}function Re(t,s,e){if(e==="leading"&&t.contextLines.length>s){const i=t.contextLines.length-s;t.contextLines.splice(0,i),t.additionStart+=i,t.deletionStart+=i}return e==="trailing"&&t.contextLines.length>s&&(t.contextLines.length=s),t.contextLines.length>0&&(t.hunkLines.push(...t.contextLines),t.additionCount+=t.contextLines.length,t.deletionCount+=t.contextLines.length,t.contextLines.length=0),t}function Ie(t,s){s.push(`@@ -${Ue(t.deletionStart,t.deletionCount)} +${Ue(t.additionStart,t.additionCount)} @@`),s.push(...t.hunkLines)}function Ue(t,s){return s===1?`${t}`:`${t},${s}`}const qt=64,Xt=3,de=new Map,Yt=(t,s,e=Xt)=>{const i=`${t}\0${e}\0${s}`,a=de.get(i);if(a)return de.delete(i),de.set(i,a),a;const l=Qt(s),p=l?Ct(Kt(s,e),{oldFile:{name:t,contents:l.before},newFile:{name:t,contents:l.after}})??Ke(t):Nt(Jt(t,s))[0]?.files[0]??Ke(t);for(de.set(i,p);de.size>qt;){const u=de.keys().next().value;if(!u)break;de.delete(u)}return p},Jt=(t,s)=>!s.trim()||s.startsWith("diff --git ")||/^--- [^\n]*\r?\n\+\+\+ /m.test(s)?s:`Index: ${t}
|
|
6
6
|
===================================================================
|
|
7
7
|
--- ${t}
|
|
8
8
|
+++ ${t}
|
|
9
9
|
${s}`,Qt=t=>{if(!t.startsWith("diff --git ")&&!/^--- [^\n]*\t?\r?\n\+\+\+ [^\n]*\t?(?:\r?\n|$)/m.test(t))return;const s=[...t.matchAll(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@[^\n]*(?:\r?\n|$)/gm)];if(s.length!==1)return;const e=s[0],i=Number.parseInt(e[1]??"",10),a=Number.parseInt(e[2]??"",10);if(i>1||a>1||!Number.isFinite(i)||!Number.isFinite(a))return;const l=(e.index??0)+e[0].length,p=t.slice(l),u=[],b=[];let g;for(const c of p.split(/\r?\n/)){if(c.startsWith("diff --git ")||c.startsWith("@@ "))break;if(c.startsWith("\\")){if(g==="-"||g===" "){const h=u.at(-1);h&&(h.newline=!1)}if(g==="+"||g===" "){const h=b.at(-1);h&&(h.newline=!1)}continue}if(c.startsWith("-")){u.push({text:c.slice(1),newline:!0}),g="-";continue}if(c.startsWith("+")){b.push({text:c.slice(1),newline:!0}),g="+";continue}c.startsWith(" ")&&(u.push({text:c.slice(1),newline:!0}),b.push({text:c.slice(1),newline:!0}),g=" ")}return{before:Ve(u),after:Ve(b)}},Ve=t=>t.map(s=>s.text+(s.newline?`
|
|
10
|
-
`:"")).join(""),Ke=t=>Gt({name:t,contents:""},{name:t,contents:""}),Zt=t=>/^Binary files .+ differ$/m.test(t)||/^GIT binary patch$/m.test(t),Pe=(t,s,e)=>Zt(s)?{original:"",modified:"",isBinary:!0,patch:s,contextMode:e}:{original:"",modified:"",patch:s,fileDiff:Yt(t,s),contextMode:e},ot=(t,s,e)=>{const i=t??0,a=s??0;return!i&&!a?null:n.jsxs("span",{className:se("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",e?.className),children:[i?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",i]}):null,a?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",a]}):null]})},en=r.memo(function({changedFiles:s,selectedFile:e,onSelectFile:i}){return s.length===0?null:n.jsx(et,{outerClassName:"flex-1 min-h-0",className:"px-1 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:s.map(a=>{const l=rt(a),p=e===a.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>i(a.path),className:se("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",p?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(tt,{filePath:a.path,className:"h-3.5 w-3.5 flex-shrink-0"}),n.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}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:a.path,children:a.path}),ot(a.insertions,a.deletions)]})},a.path)})})})}),tn=r.memo(function(){return n.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:n.jsx("div",{className:"typography-meta text-muted-foreground",children:"Content of this file cannot be viewed."})})}),nn=r.memo(function({filePath:s,diff:e,renderSideBySide:i}){const a=e.original.length>0,l=e.modified.length>0,p=i?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",u=i?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";return n.jsx("div",{className:"w-full overflow-auto p-4",style:{contain:"layout"},children:n.jsxs("div",{className:p,children:[a&&n.jsxs("div",{className:u,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:"Original"}),n.jsx("img",{src:e.original,alt:`Original: ${s}`,className:i?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),l&&n.jsxs("div",{className:u,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:a?"Modified":"New"}),n.jsx("img",{src:e.modified,alt:`Modified: ${s}`,className:i?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]})]})})}),sn=r.memo(function({filePath:s,diff:e,renderSideBySide:i,wrapLines:a}){const l=r.useMemo(()=>Nt(s)||"text",[s]);return e.isBinary?n.jsx(tn,{}):Ne(s)?n.jsx(nn,{filePath:s,diff:e,renderSideBySide:i}):n.jsx("div",{className:"w-full",style:{contain:"layout"},children:n.jsx(Ht,{original:e.original,modified:e.modified,fileDiff:e.fileDiff,language:l,fileName:s,renderSideBySide:i,wrapLines:a,layout:"inline"})})}),$e=({label:t,icon:s,loading:e,disabled:i,tone:a,onClick:l})=>n.jsx(Le,{variant:"ghost",size:"sm",className:se("h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100",a==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",a==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:i,title:t,"aria-label":t,onClick:p=>{p.stopPropagation(),l()},children:e?n.jsx(J,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(J,{name:s,className:s==="add"?"size-4":"size-3.5"})}),rn=r.memo(function({filePath:s,staged:e,busyAction:i,disabled:a,onAction:l}){return n.jsx("div",{className:"flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:e?n.jsx($e,{label:`Unstage ${s}`,icon:"arrow-go-back",loading:i==="unstage",disabled:a,onClick:()=>l("unstage")}):n.jsxs(n.Fragment,{children:[n.jsx($e,{label:`Revert changes in ${s}`,icon:"arrow-go-back",loading:i==="discard",disabled:a,tone:"failure",onClick:()=>l("discard")}),n.jsx($e,{label:`Stage ${s}`,icon:"add",loading:i==="stage",disabled:a,tone:"success",onClick:()=>l("stage")})]})})}),at=3,on=1e6,an=15e3,qe=500,ln=r.memo(function({directory:s,file:e,layout:i,wrapLines:a,isSelected:l,isExpanded:p,isMounted:u,onSelect:b,onExpandedChange:g,registerSectionRef:c,showOpenInEditorAction:h=!1,isOpeningInEditor:w=!1,onOpenInEditor:k,staged:x=!1,showFileActions:C=!0,loadFullFiles:m=!1,initialDiffData:d=null}){const{git:_}=nt(),W=oe(r.useCallback(f=>f.directories.get(s)?.diffCache.get(e.path)??null,[s,e.path])),$=oe(f=>f.setDiff),j=oe(f=>f.fetchStatus),H=Q(f=>f.setDiffFileLayout),[F,y]=r.useState(0),[N,R]=r.useState(null),[A,M]=r.useState(!1),[L,B]=r.useState(null),[U,Z]=r.useState(!1),[ie,fe]=r.useState(null),[E,I]=r.useState(null),V=r.useRef(null),pe=r.useRef(null),O=r.useMemo(()=>rt(e),[e]),ae=i==="side-by-side",Y=m?"full":"patch",q=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,X=r.useMemo(()=>d||(x?E:ie||(W?{original:W.original,modified:W.modified,isBinary:W.isBinary,contextMode:"full"}:null)),[W,d,ie,x,E]),he=X?.contextMode===Y,ve=r.useCallback(f=>{pe.current=f,c(e.path,f)},[e.path,c]),re=r.useCallback(f=>{g(e.path,f)},[e.path,g]),me=r.useCallback(()=>{b(e.path)},[e.path,b]);r.useEffect(()=>{x?I(null):fe(null),R(null),V.current=null},[q,x]),r.useEffect(()=>{if(!p||!u)return;if(!s||d||X&&he){V.current=null,M(!1);return}const f=`${s}::${e.path}::${x?"staged":"unstaged"}::${q}::${Y}::${F}`;if(V.current===f)return;V.current=f,R(null),M(!0);let P=!1;const ee=Ze(),xe=m?on:at,ce=Ne(e.path)?_.getGitFileDiff(s,{path:e.path,staged:x}):_.getGitDiff(s,{path:e.path,staged:x,contextLines:xe}),te=an,be=new Promise((K,z)=>{setTimeout(()=>z(new Error(`Timed out after ${te}ms`)),te)});return Promise.race([ce,be]).then(K=>{if(!P){if("diff"in K){const z=Pe(e.path,K.diff,Y);x?I(z):fe(z)}else{const z={original:K.original??"",modified:K.modified??"",isBinary:K.isBinary,contextMode:"full"};x?I(z):$(s,e.path,z,ee)}M(!1)}}).catch(K=>{if(P)return;const z=K instanceof Error?K.message:String(K);R(z),M(!1)}),()=>{P=!0,V.current===f&&(V.current=null)}},[Y,X,he,F,s,e.path,q,_,d,p,u,m,$,x]);const ge=r.useCallback(()=>{re(!p),me()},[re,me,p]),le=r.useCallback(async f=>{if(!(!s||L!==null)){B(f);try{f==="stage"?await _.stageGitFile(s,e.path):f==="unstage"?await _.unstageGitFile(s,e.path):await _.revertGitFile(s,e.path,{scope:"working"}),y(P=>P+1),await j(s,_)}catch(P){const ee=f==="unstage"?"Failed to unstage changes":f==="stage"?"Failed to stage changes":"Failed to revert changes";st.error(P instanceof Error?P.message:ee)}finally{B(P=>P===f?null:P)}}},[s,j,e.path,L,_]);return n.jsxs("div",{ref:ve,className:se("scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0"),children:[n.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:n.jsxs("div",{role:"button",tabIndex:0,onClick:ge,onKeyDown:f=>{f.target===f.currentTarget&&(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),ge())},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:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:p?n.jsx(J,{name:"arrow-down-s",className:"size-4"}):n.jsx(J,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:O.color},title:O.description,"aria-label":O.description,children:O.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(tt,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const f=e.path.lastIndexOf("/");if(f===-1)return n.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,f),ee=e.path.slice(f+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:P}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:ee})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[ot(e.insertions,e.deletions),h&&k?n.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:f=>{f.stopPropagation(),k(e.path,X)},disabled:w,children:w?n.jsx(J,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(J,{name:"edit",className:"size-3.5"})}):null,n.jsx(it,{mode:ae?"side-by-side":"unified",onModeChange:f=>{const P=f==="side-by-side"?"side-by-side":"inline";H(e.path,P)},className:"opacity-70"})]})]})}),p&&n.jsxs("div",{className:"relative overflow-hidden bg-background",children:[!u&&!N?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,N?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:"Failed to load diff"}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:N}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>y(f=>f+1),children:"Retry"})]}):null,u&&A&&!X&&!N?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(J,{name:"loader-4",className:"size-4 animate-spin"}),"Loading diff..."]}):null,u&&X&&!U&&e.insertions+e.deletions>qe?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:`Large diff (${e.insertions+e.deletions} changed lines)`}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:"Rendering may be slow. You can still view the diff by clicking below."}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Z(!0),children:"Render anyway"})]}):null,u&&X&&(U||e.insertions+e.deletions<=qe)?n.jsxs(n.Fragment,{children:[n.jsx(sn,{filePath:e.path,diff:X,renderSideBySide:ae,wrapLines:a}),C?n.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20",children:n.jsx("div",{className:"pointer-events-auto",children:n.jsx(rn,{filePath:e.path,staged:x,busyAction:L,disabled:L!==null,onAction:le})})}):null]}):null]})]})}),cn=1100,Xe=300,un=t=>t<=6?t:t<=12?6:t<=25?4:2,dn=(t,s)=>Lt(t,s),Ye=(t,s)=>{const e=t.split(`
|
|
10
|
+
`:"")).join(""),Ke=t=>Gt({name:t,contents:""},{name:t,contents:""}),Zt=t=>/^Binary files .+ differ$/m.test(t)||/^GIT binary patch$/m.test(t),Pe=(t,s,e)=>Zt(s)?{original:"",modified:"",isBinary:!0,patch:s,contextMode:e}:{original:"",modified:"",patch:s,fileDiff:Yt(t,s),contextMode:e},ot=(t,s,e)=>{const i=t??0,a=s??0;return!i&&!a?null:n.jsxs("span",{className:se("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",e?.className),children:[i?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",i]}):null,a?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",a]}):null]})},en=r.memo(function({changedFiles:s,selectedFile:e,onSelectFile:i}){return s.length===0?null:n.jsx(et,{outerClassName:"flex-1 min-h-0",className:"px-1 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:s.map(a=>{const l=rt(a),p=e===a.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>i(a.path),className:se("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",p?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(tt,{filePath:a.path,className:"h-3.5 w-3.5 flex-shrink-0"}),n.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}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:a.path,children:a.path}),ot(a.insertions,a.deletions)]})},a.path)})})})}),tn=r.memo(function(){return n.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:n.jsx("div",{className:"typography-meta text-muted-foreground",children:"Content of this file cannot be viewed."})})}),nn=r.memo(function({filePath:s,diff:e,renderSideBySide:i}){const a=e.original.length>0,l=e.modified.length>0,p=i?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",u=i?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";return n.jsx("div",{className:"w-full overflow-auto p-4",style:{contain:"layout"},children:n.jsxs("div",{className:p,children:[a&&n.jsxs("div",{className:u,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:"Original"}),n.jsx("img",{src:e.original,alt:`Original: ${s}`,className:i?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),l&&n.jsxs("div",{className:u,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:a?"Modified":"New"}),n.jsx("img",{src:e.modified,alt:`Modified: ${s}`,className:i?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]})]})})}),sn=r.memo(function({filePath:s,diff:e,renderSideBySide:i,wrapLines:a}){const l=r.useMemo(()=>jt(s)||"text",[s]);return e.isBinary?n.jsx(tn,{}):je(s)?n.jsx(nn,{filePath:s,diff:e,renderSideBySide:i}):n.jsx("div",{className:"w-full",style:{contain:"layout"},children:n.jsx(Ht,{original:e.original,modified:e.modified,fileDiff:e.fileDiff,language:l,fileName:s,renderSideBySide:i,wrapLines:a,layout:"inline"})})}),$e=({label:t,icon:s,loading:e,disabled:i,tone:a,onClick:l})=>n.jsx(Le,{variant:"ghost",size:"sm",className:se("h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100",a==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",a==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:i,title:t,"aria-label":t,onClick:p=>{p.stopPropagation(),l()},children:e?n.jsx(J,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(J,{name:s,className:s==="add"?"size-4":"size-3.5"})}),rn=r.memo(function({filePath:s,staged:e,busyAction:i,disabled:a,onAction:l}){return n.jsx("div",{className:"flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:e?n.jsx($e,{label:`Unstage ${s}`,icon:"arrow-go-back",loading:i==="unstage",disabled:a,onClick:()=>l("unstage")}):n.jsxs(n.Fragment,{children:[n.jsx($e,{label:`Revert changes in ${s}`,icon:"arrow-go-back",loading:i==="discard",disabled:a,tone:"failure",onClick:()=>l("discard")}),n.jsx($e,{label:`Stage ${s}`,icon:"add",loading:i==="stage",disabled:a,tone:"success",onClick:()=>l("stage")})]})})}),at=3,on=1e6,an=15e3,qe=500,ln=r.memo(function({directory:s,file:e,layout:i,wrapLines:a,isSelected:l,isExpanded:p,isMounted:u,onSelect:b,onExpandedChange:g,registerSectionRef:c,showOpenInEditorAction:h=!1,isOpeningInEditor:w=!1,onOpenInEditor:k,staged:x=!1,showFileActions:C=!0,loadFullFiles:m=!1,initialDiffData:d=null}){const{git:_}=nt(),W=oe(r.useCallback(f=>f.directories.get(s)?.diffCache.get(e.path)??null,[s,e.path])),$=oe(f=>f.setDiff),N=oe(f=>f.fetchStatus),H=Q(f=>f.setDiffFileLayout),[F,y]=r.useState(0),[j,R]=r.useState(null),[A,M]=r.useState(!1),[L,B]=r.useState(null),[U,Z]=r.useState(!1),[ie,fe]=r.useState(null),[E,I]=r.useState(null),V=r.useRef(null),pe=r.useRef(null),O=r.useMemo(()=>rt(e),[e]),ae=i==="side-by-side",Y=m?"full":"patch",q=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,X=r.useMemo(()=>d||(x?E:ie||(W?{original:W.original,modified:W.modified,isBinary:W.isBinary,contextMode:"full"}:null)),[W,d,ie,x,E]),he=X?.contextMode===Y,ve=r.useCallback(f=>{pe.current=f,c(e.path,f)},[e.path,c]),re=r.useCallback(f=>{g(e.path,f)},[e.path,g]),me=r.useCallback(()=>{b(e.path)},[e.path,b]);r.useEffect(()=>{x?I(null):fe(null),R(null),V.current=null},[q,x]),r.useEffect(()=>{if(!p||!u)return;if(!s||d||X&&he){V.current=null,M(!1);return}const f=`${s}::${e.path}::${x?"staged":"unstaged"}::${q}::${Y}::${F}`;if(V.current===f)return;V.current=f,R(null),M(!0);let P=!1;const ee=Ze(),xe=m?on:at,ce=je(e.path)?_.getGitFileDiff(s,{path:e.path,staged:x}):_.getGitDiff(s,{path:e.path,staged:x,contextLines:xe}),te=an,be=new Promise((K,z)=>{setTimeout(()=>z(new Error(`Timed out after ${te}ms`)),te)});return Promise.race([ce,be]).then(K=>{if(!P){if("diff"in K){const z=Pe(e.path,K.diff,Y);x?I(z):fe(z)}else{const z={original:K.original??"",modified:K.modified??"",isBinary:K.isBinary,contextMode:"full"};x?I(z):$(s,e.path,z,ee)}M(!1)}}).catch(K=>{if(P)return;const z=K instanceof Error?K.message:String(K);R(z),M(!1)}),()=>{P=!0,V.current===f&&(V.current=null)}},[Y,X,he,F,s,e.path,q,_,d,p,u,m,$,x]);const ge=r.useCallback(()=>{re(!p),me()},[re,me,p]),le=r.useCallback(async f=>{if(!(!s||L!==null)){B(f);try{f==="stage"?await _.stageGitFile(s,e.path):f==="unstage"?await _.unstageGitFile(s,e.path):await _.revertGitFile(s,e.path,{scope:"working"}),y(P=>P+1),await N(s,_)}catch(P){const ee=f==="unstage"?"Failed to unstage changes":f==="stage"?"Failed to stage changes":"Failed to revert changes";st.error(P instanceof Error?P.message:ee)}finally{B(P=>P===f?null:P)}}},[s,N,e.path,L,_]);return n.jsxs("div",{ref:ve,className:se("scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0"),children:[n.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:n.jsxs("div",{role:"button",tabIndex:0,onClick:ge,onKeyDown:f=>{f.target===f.currentTarget&&(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),ge())},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:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:p?n.jsx(J,{name:"arrow-down-s",className:"size-4"}):n.jsx(J,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:O.color},title:O.description,"aria-label":O.description,children:O.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(tt,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const f=e.path.lastIndexOf("/");if(f===-1)return n.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,f),ee=e.path.slice(f+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:P}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:ee})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[ot(e.insertions,e.deletions),h&&k?n.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:f=>{f.stopPropagation(),k(e.path,X)},disabled:w,children:w?n.jsx(J,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(J,{name:"edit",className:"size-3.5"})}):null,n.jsx(it,{mode:ae?"side-by-side":"unified",onModeChange:f=>{const P=f==="side-by-side"?"side-by-side":"inline";H(e.path,P)},className:"opacity-70"})]})]})}),p&&n.jsxs("div",{className:"relative overflow-hidden bg-background",children:[!u&&!j?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,j?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:"Failed to load diff"}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:j}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>y(f=>f+1),children:"Retry"})]}):null,u&&A&&!X&&!j?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(J,{name:"loader-4",className:"size-4 animate-spin"}),"Loading diff..."]}):null,u&&X&&!U&&e.insertions+e.deletions>qe?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:`Large diff (${e.insertions+e.deletions} changed lines)`}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:"Rendering may be slow. You can still view the diff by clicking below."}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Z(!0),children:"Render anyway"})]}):null,u&&X&&(U||e.insertions+e.deletions<=qe)?n.jsxs(n.Fragment,{children:[n.jsx(sn,{filePath:e.path,diff:X,renderSideBySide:ae,wrapLines:a}),C?n.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20",children:n.jsx("div",{className:"pointer-events-auto",children:n.jsx(rn,{filePath:e.path,staged:x,busyAction:L,disabled:L!==null,onAction:le})})}):null]}):null]})]})}),cn=1100,Xe=300,un=t=>t<=6?t:t<=12?6:t<=25?4:2,dn=(t,s)=>Lt(t,s),Ye=(t,s)=>{const e=t.split(`
|
|
11
11
|
`),i=s.split(`
|
|
12
12
|
`),a=Math.min(e.length,i.length);for(let l=0;l<a;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},fn=t=>Array.isArray(t)?t.filter(s=>!s||typeof s!="object"?!1:typeof s.file=="string"):[],pn=t=>t.split(/^diff --git /m).slice(1).flatMap(e=>{const[i=""]=e.split(`
|
|
13
13
|
`,1),a=i.lastIndexOf(" b/");if(a<=2)return[];const l=i.slice(2,a),p=i.slice(a+3).trim(),u=`diff --git ${e}`,b=u.includes(`
|
|
14
14
|
new file mode `)?"added":u.includes(`
|
|
15
15
|
deleted file mode `)?"deleted":u.includes(`
|
|
16
16
|
rename from `)?"renamed":"modified";let g=0,c=0;for(const h of u.split(`
|
|
17
|
-
`))h.startsWith("+")&&!h.startsWith("+++")&&(g+=1),h.startsWith("-")&&!h.startsWith("---")&&(c+=1);return[{file:b==="deleted"?l:p,status:b,additions:g,deletions:c,patch:u}]}),hn=t=>t==="added"?"A":t==="deleted"?"D":"M";function mn({activeDiffScope:t,effectiveDirectory:s,branchBase:e,branchHead:i,git:a,sessionMessageRecords:l}){const[p,u]=r.useState([]),[b,g]=r.useState(null),[c,h]=r.useState(!1),w=r.useMemo(()=>{const C=Dt(l,{showTextJustificationActivity:!1,mergeHiddenUserTurns:!0});for(let m=C.turns.length-1;m>=0;m-=1){const d=C.turns[m];if(!d)continue;const _=d.activityParts.map(
|
|
18
|
-
`);let e=null;for(const i of s){const a=i.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(a){const l=Number.parseInt(a[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 bn({effectiveDirectory:t,activeDiffStaged:s,git:e,files:i,setDiff:a,openContextFileAtLine:l}){const[p,u]=r.useState(null),b=r.useCallback(async(g,c)=>{if(!t||!g)return;u(g);const h=Ze();try{let w=null;if(c?.patch&&!c.isBinary&&!Ne(g)?w=Qe(c.patch):c&&c.contextMode==="full"&&!c.isBinary&&!Ne(g)&&(w=Ye(c.original,c.modified)),w===null)try{const d=await e.getGitDiff(t,{path:g,staged:s,contextLines:3});w=Qe(d.diff)}catch{w=null}let k=c;if(w===null||!k){const d=await e.getGitFileDiff(t,{path:g,staged:s});k={original:d.original??"",modified:d.modified??"",isBinary:d.isBinary},s||a(t,g,k,h??void 0)}const x=w??(k.isBinary||Ne(g)?1:Ye(k.original,k.modified)),C=dn(t,g),m=await Ut(i,C,{directory:t});if(!m.ok){st.error(Vt(m.reason));return}l(t,C,x,1)}finally{u(w=>w===g?null:w)}},[s,t,i,e,l,a]);return{openingEditorFilePath:p,openFileInEditorAtChange:b}}function yn(t){const{hideStackedFileSidebar:s=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:i=!1,diffScope:a="all",branchBase:l=null,branchHead:p=null,targetFilePath:u=null}=t,{git:b,files:g}=nt(),c=Rt(),{screenWidth:h,isMobile:w}=Et(),k=At(c??null),x=Tt(c??null),C=Mt(c??null),m=oe(o=>o.setActiveDirectory),d=oe(o=>o.ensureStatus),_=oe(o=>o.fetchStatus),W=oe(o=>o.clearDiffCache),$=oe(o=>o.setDiff),[j,H]=r.useState(null),[F,y]=r.useState(!1),[N,R]=r.useState(()=>new Set),[A,M]=r.useState(()=>new Set),[L,B]=r.useState(!1),[U,Z]=r.useState(0),[ie,fe]=r.useState(()=>new Map),[E,I]=r.useState(a);r.useEffect(()=>{I(a)},[a]);const V=Q(o=>o.pendingDiffFile),pe=Q(o=>o.pendingDiffStaged),O=Q(o=>o.pendingDiffScope),ae=Q(o=>o.setPendingDiffFile),Y=Q(o=>o.diffLayoutPreference),q=Q(o=>o.diffFileLayout),X=Q(o=>o.setDiffFileLayout),he=Q(o=>o.diffWrapLines),ve=Q(o=>o.setDiffWrapLines),re=Q(o=>o.openContextFileAtLine),me=It(o=>o.currentSessionId),ge=$t(me??""),le=he,f=E==="staged"?!0:E==="working"?!1:null,P=f??F,ee=w||h<=768,xe=!s&&!ee&&h>=1024,ce=r.useRef(null),{branchDiffs:te,branchDiffError:be,branchDiffLoading:K,lastTurnDiffs:z,lastTurnDiffData:De,branchDiffData:ne}=mn({activeDiffScope:E,effectiveDirectory:c,branchBase:l,branchHead:p,git:b,sessionMessageRecords:ge}),D=r.useMemo(()=>{if(E==="turn"||E==="branch")return(E==="branch"?te:z).map(T=>({path:T.file??"",index:"",working_dir:hn(T.status),insertions:T.additions??0,deletions:T.deletions??0,isNew:T.status==="added"})).filter(T=>T.path).sort((T,G)=>T.path.localeCompare(G.path));if(!x?.files)return[];const o=x.diffStats??{},v=E==="staged"?Ge:E==="working"?He:()=>!0;return x.files.filter(v).map(S=>({...S,insertions:o[S.path]?.insertions??0,deletions:o[S.path]?.deletions??0,isNew:Ot(S)})).sort((S,T)=>S.path.localeCompare(T.path))},[E,te,z,x]),Ee=r.useMemo(()=>x?.files?x.files.filter(He).length:0,[x]),Ae=r.useMemo(()=>x?.files?x.files.filter(Ge).length:0,[x]),lt=z.length,ct=x?.files?.length??0,ut=te.length,{diffScrollRef:dt,pinnedStackedTarget:ft,pendingScrollTargetRef:ye,shouldPinAfterAlignRef:we,pendingScrollAnchorRestoreRef:_e,lastScrollAnchorRef:We,captureScrollAnchor:Be,cancelPendingScrollAlignment:Fe,queueVisibleStackedFilesSync:ke,registerSectionRef:pt,scrollToFile:Oe}=xn({pinSelectedFileHeaderToTopOnNavigate:i,scrollRequestNonce:U,changedFiles:D,expandedFiles:N,setMountedStackedFiles:M,fileDiffRefreshNonce:ie}),Se=r.useCallback(o=>{R(v=>{if(v.has(o))return v;const S=new Set(v);return S.add(o),S})},[]),Te=r.useMemo(()=>D.map(o=>o.path).join("\0"),[D]);r.useEffect(()=>{const o=Te?Te.split("\0"):[],v=new Set(o),S=`${c??""}:${E}:${e?"collapsed":"default"}`,T=ce.current!==S;ce.current=S,R(G=>{if(T){const ue=e?0:un(o.length);return new Set(o.slice(0,ue))}let Ce=!1;const je=new Set;for(const ue of G){if(!v.has(ue)){Ce=!0;continue}je.add(ue)}return Ce?je:G}),M(G=>{if(T)return new Set;let Ce=!1;const je=new Set;for(const ue of G){if(!v.has(ue)){Ce=!0;continue}je.add(ue)}return Ce?je:G})},[E,Te,c,M,e]);const Me=r.useCallback(o=>{const v=q[o.path];if(v)return v;if(Y==="inline")return"inline";if(Y==="side-by-side")return"side-by-side";const S=h<cn;return o.isNew||S?"inline":"side-by-side"},[q,Y,h]),ht=r.useMemo(()=>D.length===0?null:D.every(o=>Me(o)==="side-by-side")?"side-by-side":"inline",[D,Me]);r.useEffect(()=>{c&&(m(c),d(c,b))},[c,m,d,b]),r.useEffect(()=>{if(c)return Pt.onGitRefreshHint(o=>{ze(o.directory)===ze(c)&&(o.paths?.length&&(_e.current=Be()??We.current,W(c,o.paths),fe(v=>{const S=new Map(v);for(const T of o.paths??[])S.set(T,(S.get(T)??0)+1);return S})),_(c,b,{silent:!0}))})},[Be,W,c,_,b,We,_e]),r.useEffect(()=>{E!=="all"&&!O||V&&(O&&I(O),H(V),y(O==="staged"||!O&&pe),ae(null),we.current=!0,ye.current=V,Se(V),Z(o=>o+1))},[E,Se,V,O,pe,ye,ae,we]),r.useEffect(()=>{if(E==="all")return;const o=u?.trim();o&&(H(o),y(E==="staged"),we.current=!0,ye.current=o,Se(o),Z(v=>v+1))},[E,Se,ye,we,u]),r.useEffect(()=>{if(!j)return;D.some(v=>v.path===j)||(H(null),y(!1))},[D,j]);const mt=r.useCallback((o,v)=>{Fe(),R(S=>{const T=S.has(o);if(v===T)return S;const G=new Set(S);return v?G.add(o):G.delete(o),G}),M(S=>{const T=S.has(o);if(v===T)return S;const G=new Set(S);return v?G.add(o):G.delete(o),G}),ke()},[Fe,ke,M]),gt=r.useCallback(()=>{Fe(),R(o=>o.size>0?new Set:new Set(D.map(v=>v.path))),M(new Set),ke()},[Fe,D,ke,M]),xt=r.useCallback(o=>{},[]),bt=r.useCallback(o=>{Fe(),H(o),y(!1),we.current=!0,ye.current=o,Se(o),Z(v=>v+1),Oe(o)},[Fe,Se,ye,Oe,we]),yt=r.useCallback(o=>{const v=o==="side-by-side"?"side-by-side":"inline";D.forEach(S=>{X(S.path,v)})},[D,X]),{openingEditorFilePath:wt,openFileInEditorAtChange:Ft}=bn({effectiveDirectory:c,activeDiffStaged:P,git:b,files:g,setDiff:$,openContextFileAtLine:re});return{git:b,files:g,effectiveDirectory:c,screenWidth:h,isMobile:w,isGitRepo:k,status:x,isLoadingStatus:C,activeDiffScope:E,setActiveDiffScope:I,branchDiffs:te,branchDiffError:be,branchDiffLoading:K,diffWrapLines:le,setDiffWrapLines:ve,forcedStaged:f,displayFileStaged:F,displayFile:j,pinnedStackedTarget:ft,expandedFiles:N,mountedStackedFiles:A,loadFullFiles:L,setLoadFullFiles:B,fileDiffRefreshNonce:ie,showFileSidebar:xe,diffScrollRef:dt,lastTurnDiffData:De,branchDiffData:ne,changedFiles:D,workingFileCount:Ee,stagedFileCount:Ae,turnFileCount:lt,allFileCount:ct,branchFileCount:ut,currentLayoutForAllFiles:ht,openingEditorFilePath:wt,registerSectionRef:pt,handleStackedEntryExpandedChange:mt,handleExpandOrCollapseAll:gt,handleSelectFile:xt,handleSelectFileAndScroll:bt,handleHeaderLayoutChange:yt,openFileInEditorAtChange:Ft,getLayoutForFile:Me}}const ms=({hideStackedFileSidebar:t=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:e=!1,showOpenInEditorAction:i=!1,diffScope:a="all",onDiffScopeChange:l,branchBase:p=null,branchHead:u=null,targetFilePath:b=null,flushContent:g=!1,hideToolbar:c=!1,onHeaderControlsStateChange:h,toolbarSlot:w=null})=>{const{effectiveDirectory:k,isGitRepo:x,status:C,isLoadingStatus:m,activeDiffScope:d,setActiveDiffScope:_,branchDiffError:W,branchDiffLoading:$,diffWrapLines:j,setDiffWrapLines:H,forcedStaged:F,displayFileStaged:y,displayFile:N,pinnedStackedTarget:R,expandedFiles:A,mountedStackedFiles:M,loadFullFiles:L,setLoadFullFiles:B,fileDiffRefreshNonce:U,showFileSidebar:Z,diffScrollRef:ie,lastTurnDiffData:fe,branchDiffData:E,changedFiles:I,workingFileCount:V,stagedFileCount:pe,turnFileCount:O,allFileCount:ae,branchFileCount:Y,currentLayoutForAllFiles:q,openingEditorFilePath:X,registerSectionRef:he,handleStackedEntryExpandedChange:ve,handleExpandOrCollapseAll:re,handleSelectFile:me,handleSelectFileAndScroll:ge,handleHeaderLayoutChange:le,openFileInEditorAtChange:f,getLayoutForFile:P}=yn({hideStackedFileSidebar:t,stackedDefaultCollapsedAll:s,pinSelectedFileHeaderToTopOnNavigate:e,diffScope:a,branchBase:p,branchHead:u,targetFilePath:b});r.useEffect(()=>{c&&l?.(d)},[d,c,l]);const ee=r.useCallback(()=>{B(ne=>!ne)},[B]),xe=r.useCallback(()=>{H(!j)},[j,H]),ce=r.useCallback(()=>{le(q==="side-by-side"?"unified":"side-by-side")},[q,le]),te=A.size,be=r.useMemo(()=>({turnCount:O,branchCount:Y,expandedCount:te,totalCount:I.length,loadFullFiles:L,wrapLines:j,layoutMode:q,onExpandOrCollapseAll:re,onToggleLoadFullFiles:ee,onToggleWrapLines:xe,onToggleLayout:ce}),[O,Y,te,I.length,L,j,q,re,ee,xe,ce]);r.useEffect(()=>{c&&h?.(be)},[c,be,h]);const K=()=>{if(!k)return null;const ne=D=>F!==null?F:y&&D===N;return n.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:[Z&&n.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:"Files"}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:I.length})]}),n.jsx(en,{changedFiles:I,selectedFile:null,onSelectFile:ge})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(et,{ref:ie,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:n.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:I.map(D=>n.jsx(ln,{directory:k,file:D,layout:P(D),wrapLines:j,isSelected:!1,isExpanded:A.has(D.path),isMounted:M.has(D.path)||D.path===R,onSelect:me,onExpandedChange:ve,registerSectionRef:he,showOpenInEditorAction:i&&d!=="turn"&&d!=="branch",isOpeningInEditor:X===D.path,onOpenInEditor:(Ee,Ae)=>{f(Ee,Ae)},staged:ne(D.path),showFileActions:d!=="turn"&&d!=="branch",loadFullFiles:L,initialDiffData:d==="turn"?fe.get(D.path)??null:d==="branch"?E.get(D.path)??null:null},`${D.path}:${U.get(D.path)??0}`))})})})]})},z=()=>k?d!=="turn"&&m&&!C?n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(J,{name:"loader-4",className:"size-4 animate-spin"}),"Loading repository status..."]}):d!=="turn"&&d!=="branch"&&x===!1?n.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."}):d==="branch"&&$?n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(J,{name:"loader-4",className:"size-4 animate-spin"}),"Loading branch changes..."]}):d==="branch"&&W?n.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: ${W}`}):I.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:d==="turn"?"No last turn changes to display":"Working tree clean, no changes to display"}):K():n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Select a session directory to view diffs"}),De=n.jsxs("div",{className:w?"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:[(x!==!1||d==="turn")&&(d==="all"||d==="working"||d==="staged"||d==="turn"||d==="branch")?n.jsx(zt,{scope:d,isGitRepo:x,branchAvailable:!!(p&&u),allCount:ae,workingCount:V,stagedCount:pe,turnCount:O,branchCount:Y,onScopeChange:ne=>{_(ne),l?.(ne)}}):n.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:n.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:m&&!C?"Loading changes...":I.length===1?`${I.length} file changed`:`${I.length} files changed`})}),I.length>0&&n.jsxs(Le,{variant:"ghost",size:"sm",onClick:re,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:[n.jsx(J,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:A.size>0?"Collapse all":"Expand all"})]}),I.length>0&&d!=="turn"&&d!=="branch"&&n.jsxs(_t,{children:[n.jsx(Wt,{asChild:!0,children:n.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>B(ne=>!ne),"aria-pressed":L,"aria-label":L?"Unload full files":"Load full files",className:se("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",L&&"bg-interactive-selection text-interactive-selection-foreground"),children:n.jsx(J,{name:"file-download",className:"size-4"})})}),n.jsx(Bt,{children:n.jsx("p",{children:L?"Unload full files":"Load full files"})})]}),I.length>0&&n.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>H(!j),className:se("h-5 w-5 p-0 transition-opacity",j?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:j?"Disable line wrap":"Enable line wrap",children:n.jsx(J,{name:"text-wrap",className:"size-4"})}),q&&n.jsx(it,{mode:q==="side-by-side"?"side-by-side":"unified",onModeChange:le})]});return n.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[w?St.createPortal(De,w):c?null:De,z()]})};export{ms as DiffView};
|
|
17
|
+
`))h.startsWith("+")&&!h.startsWith("+++")&&(g+=1),h.startsWith("-")&&!h.startsWith("---")&&(c+=1);return[{file:b==="deleted"?l:p,status:b,additions:g,deletions:c,patch:u}]}),hn=t=>t==="added"?"A":t==="deleted"?"D":"M";function mn({activeDiffScope:t,effectiveDirectory:s,branchBase:e,branchHead:i,git:a,sessionMessageRecords:l}){const[p,u]=r.useState([]),[b,g]=r.useState(null),[c,h]=r.useState(!1),w=r.useMemo(()=>{const C=Dt(l,{showTextJustificationActivity:!1,mergeHiddenUserTurns:!0});for(let m=C.turns.length-1;m>=0;m-=1){const d=C.turns[m];if(!d)continue;const _=d.activityParts.map(N=>N.part).filter(N=>N.type==="tool"),W=kt(_);if(W.length>0)return W.map(N=>({file:N.path,status:"modified",additions:N.additions,deletions:N.deletions,patch:N.patch}));const $=fn(d.userMessage.info?.summary?.diffs);if($.length>0)return $}return[]},[l]);r.useEffect(()=>{if(t!=="branch"||!s||!e||!i||!a.getGitRangeDiff){u([]),g(null),h(!1);return}let C=!1;return h(!0),g(null),a.getGitRangeDiff(s,{base:e,head:i,contextLines:at}).then(m=>{C||(u(pn(m.diff??"")),h(!1))}).catch(m=>{C||(u([]),h(!1),g(m instanceof Error?m.message:String(m)))}),()=>{C=!0}},[t,e,i,s,a]);const k=r.useMemo(()=>{const C=new Map;for(const m of w)if(m.file){if(typeof m.patch=="string"){C.set(m.file,Pe(m.file,m.patch,"patch"));continue}typeof m.before!="string"&&typeof m.after!="string"||C.set(m.file,{original:m.before??"",modified:m.after??"",contextMode:"full"})}return C},[w]),x=r.useMemo(()=>{const C=new Map;for(const m of p)!m.file||typeof m.patch!="string"||C.set(m.file,Pe(m.file,m.patch,"patch"));return C},[p]);return{branchDiffs:p,branchDiffError:b,branchDiffLoading:c,lastTurnDiffs:w,lastTurnDiffData:k,branchDiffData:x}}const Je=(t,s)=>{if(s.length===0)return null;let e=null,i=null;for(const l of s)l.top<=t?(!e||l.top>e.top)&&(e=l):(!i||l.top<i.top)&&(i=l);const a=e??i;return a?{path:a.path,topOffset:a.top-t}:null},gn=(t,s,e,i)=>Math.min(Math.max(0,i),Math.max(0,t+e-s));function xn({pinSelectedFileHeaderToTopOnNavigate:t,scrollRequestNonce:s,changedFiles:e,expandedFiles:i,setMountedStackedFiles:a,fileDiffRefreshNonce:l}){const p=r.useRef(null),u=r.useRef(new Map),[b,g]=r.useState(null),c=r.useRef(null),h=r.useRef(null),w=r.useRef(!1),k=r.useRef(null),x=r.useRef(i),C=r.useRef(null);r.useLayoutEffect(()=>{x.current=i},[i]);const m=r.useRef(null),d=r.useCallback(()=>{const F=p.current;if(!F)return null;const y=F.getBoundingClientRect().top,j=[];for(const[R,A]of u.current)A&&j.push({path:R,top:A.getBoundingClientRect().top});return Je(y,j)},[]),_=r.useCallback(()=>{c.current=null,w.current=!1,g(null),h.current!==null&&(window.cancelAnimationFrame(h.current),h.current=null)},[]),W=r.useCallback(()=>{k.current=null;const F=p.current;if(!F)return;const y=F.getBoundingClientRect(),j=y.top-Xe,R=y.bottom+Xe,A={},M=[];for(const[L,B]of u.current){if(!B)continue;const U=B.getBoundingClientRect();M.push({path:L,top:U.top}),x.current.has(L)&&(U.bottom<j||U.top>R||(A[L]=!0))}C.current=Je(y.top,M),a(L=>{let B=!1;const U=new Set(L);for(const Z of Object.keys(A))U.has(Z)||(U.add(Z),B=!0);return B?U:L})},[a]),$=r.useCallback(()=>{typeof window>"u"||k.current===null&&(k.current=window.requestAnimationFrame(W))},[W]);r.useEffect(()=>{const F=p.current;if(F)return $(),F.addEventListener("scroll",$,{passive:!0}),window.addEventListener("resize",$),()=>{F.removeEventListener("scroll",$),window.removeEventListener("resize",$),k.current!==null&&(window.cancelAnimationFrame(k.current),k.current=null)}},[e,i,$]),r.useLayoutEffect(()=>{const F=m.current;if(!F)return;m.current=null;const y=p.current,j=u.current.get(F.path);if(!y||!j)return;const R=y.getBoundingClientRect().top,A=j.getBoundingClientRect().top-R;y.scrollTop=gn(y.scrollTop,F.topOffset,A,y.scrollHeight-y.clientHeight),C.current=F},[l]);const N=r.useCallback((F,y)=>{const j=u.current;y?j.set(F,y):j.delete(F),$()},[$]),H=r.useCallback(F=>{const y=u.current.get(F),j=p.current;if(!y||!j)return!1;const R=y.getBoundingClientRect().top-j.getBoundingClientRect().top;return j.scrollTo({top:j.scrollTop+R,behavior:"auto"}),!0},[]);return r.useEffect(()=>{if(!c.current)return;let y=0;const j=20;let R=!1;const A=(L=!0)=>{R||(R=!0,c.current=null,w.current=!1,L&&g(null),h.current!==null&&(window.cancelAnimationFrame(h.current),h.current=null))},M=()=>{if(R){h.current=null;return}const L=c.current;if(!L){A(),h.current=null;return}if(!H(L)){y+=1,y<j?h.current=window.requestAnimationFrame(M):(A(),h.current=null);return}if(t&&w.current){g(L),A(!1);return}A()};return h.current=window.requestAnimationFrame(M),()=>{R=!0,h.current!==null&&(window.cancelAnimationFrame(h.current),h.current=null)}},[t,s,H]),{diffScrollRef:p,fileSectionRefs:u,pinnedStackedTarget:b,pendingScrollTargetRef:c,shouldPinAfterAlignRef:w,pendingScrollAnchorRestoreRef:m,lastScrollAnchorRef:C,captureScrollAnchor:d,cancelPendingScrollAlignment:_,queueVisibleStackedFilesSync:$,registerSectionRef:N,scrollToFile:H}}const Qe=t=>{if(!t)return null;const s=t.split(`
|
|
18
|
+
`);let e=null;for(const i of s){const a=i.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(a){const l=Number.parseInt(a[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 bn({effectiveDirectory:t,activeDiffStaged:s,git:e,files:i,setDiff:a,openContextFileAtLine:l}){const[p,u]=r.useState(null),b=r.useCallback(async(g,c)=>{if(!t||!g)return;u(g);const h=Ze();try{let w=null;if(c?.patch&&!c.isBinary&&!je(g)?w=Qe(c.patch):c&&c.contextMode==="full"&&!c.isBinary&&!je(g)&&(w=Ye(c.original,c.modified)),w===null)try{const d=await e.getGitDiff(t,{path:g,staged:s,contextLines:3});w=Qe(d.diff)}catch{w=null}let k=c;if(w===null||!k){const d=await e.getGitFileDiff(t,{path:g,staged:s});k={original:d.original??"",modified:d.modified??"",isBinary:d.isBinary},s||a(t,g,k,h??void 0)}const x=w??(k.isBinary||je(g)?1:Ye(k.original,k.modified)),C=dn(t,g),m=await Ut(i,C,{directory:t});if(!m.ok){st.error(Vt(m.reason));return}l(t,C,x,1)}finally{u(w=>w===g?null:w)}},[s,t,i,e,l,a]);return{openingEditorFilePath:p,openFileInEditorAtChange:b}}function yn(t){const{hideStackedFileSidebar:s=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:i=!1,diffScope:a="all",branchBase:l=null,branchHead:p=null,targetFilePath:u=null}=t,{git:b,files:g}=nt(),c=Rt(),{screenWidth:h,isMobile:w}=Et(),k=At(c??null),x=Tt(c??null),C=Mt(c??null),m=oe(o=>o.setActiveDirectory),d=oe(o=>o.ensureStatus),_=oe(o=>o.fetchStatus),W=oe(o=>o.clearDiffCache),$=oe(o=>o.setDiff),[N,H]=r.useState(null),[F,y]=r.useState(!1),[j,R]=r.useState(()=>new Set),[A,M]=r.useState(()=>new Set),[L,B]=r.useState(!1),[U,Z]=r.useState(0),[ie,fe]=r.useState(()=>new Map),[E,I]=r.useState(a);r.useEffect(()=>{I(a)},[a]);const V=Q(o=>o.pendingDiffFile),pe=Q(o=>o.pendingDiffStaged),O=Q(o=>o.pendingDiffScope),ae=Q(o=>o.setPendingDiffFile),Y=Q(o=>o.diffLayoutPreference),q=Q(o=>o.diffFileLayout),X=Q(o=>o.setDiffFileLayout),he=Q(o=>o.diffWrapLines),ve=Q(o=>o.setDiffWrapLines),re=Q(o=>o.openContextFileAtLine),me=It(o=>o.currentSessionId),ge=$t(me??""),le=he,f=E==="staged"?!0:E==="working"?!1:null,P=f??F,ee=w||h<=768,xe=!s&&!ee&&h>=1024,ce=r.useRef(null),{branchDiffs:te,branchDiffError:be,branchDiffLoading:K,lastTurnDiffs:z,lastTurnDiffData:De,branchDiffData:ne}=mn({activeDiffScope:E,effectiveDirectory:c,branchBase:l,branchHead:p,git:b,sessionMessageRecords:ge}),D=r.useMemo(()=>{if(E==="turn"||E==="branch")return(E==="branch"?te:z).map(T=>({path:T.file??"",index:"",working_dir:hn(T.status),insertions:T.additions??0,deletions:T.deletions??0,isNew:T.status==="added"})).filter(T=>T.path).sort((T,G)=>T.path.localeCompare(G.path));if(!x?.files)return[];const o=x.diffStats??{},v=E==="staged"?Ge:E==="working"?He:()=>!0;return x.files.filter(v).map(S=>({...S,insertions:o[S.path]?.insertions??0,deletions:o[S.path]?.deletions??0,isNew:Ot(S)})).sort((S,T)=>S.path.localeCompare(T.path))},[E,te,z,x]),Ee=r.useMemo(()=>x?.files?x.files.filter(He).length:0,[x]),Ae=r.useMemo(()=>x?.files?x.files.filter(Ge).length:0,[x]),lt=z.length,ct=x?.files?.length??0,ut=te.length,{diffScrollRef:dt,pinnedStackedTarget:ft,pendingScrollTargetRef:ye,shouldPinAfterAlignRef:we,pendingScrollAnchorRestoreRef:_e,lastScrollAnchorRef:We,captureScrollAnchor:Be,cancelPendingScrollAlignment:Fe,queueVisibleStackedFilesSync:ke,registerSectionRef:pt,scrollToFile:Oe}=xn({pinSelectedFileHeaderToTopOnNavigate:i,scrollRequestNonce:U,changedFiles:D,expandedFiles:j,setMountedStackedFiles:M,fileDiffRefreshNonce:ie}),Se=r.useCallback(o=>{R(v=>{if(v.has(o))return v;const S=new Set(v);return S.add(o),S})},[]),Te=r.useMemo(()=>D.map(o=>o.path).join("\0"),[D]);r.useEffect(()=>{const o=Te?Te.split("\0"):[],v=new Set(o),S=`${c??""}:${E}:${e?"collapsed":"default"}`,T=ce.current!==S;ce.current=S,R(G=>{if(T){const ue=e?0:un(o.length);return new Set(o.slice(0,ue))}let Ce=!1;const Ne=new Set;for(const ue of G){if(!v.has(ue)){Ce=!0;continue}Ne.add(ue)}return Ce?Ne:G}),M(G=>{if(T)return new Set;let Ce=!1;const Ne=new Set;for(const ue of G){if(!v.has(ue)){Ce=!0;continue}Ne.add(ue)}return Ce?Ne:G})},[E,Te,c,M,e]);const Me=r.useCallback(o=>{const v=q[o.path];if(v)return v;if(Y==="inline")return"inline";if(Y==="side-by-side")return"side-by-side";const S=h<cn;return o.isNew||S?"inline":"side-by-side"},[q,Y,h]),ht=r.useMemo(()=>D.length===0?null:D.every(o=>Me(o)==="side-by-side")?"side-by-side":"inline",[D,Me]);r.useEffect(()=>{c&&(m(c),d(c,b))},[c,m,d,b]),r.useEffect(()=>{if(c)return Pt.onGitRefreshHint(o=>{ze(o.directory)===ze(c)&&(o.paths?.length&&(_e.current=Be()??We.current,W(c,o.paths),fe(v=>{const S=new Map(v);for(const T of o.paths??[])S.set(T,(S.get(T)??0)+1);return S})),_(c,b,{silent:!0}))})},[Be,W,c,_,b,We,_e]),r.useEffect(()=>{E!=="all"&&!O||V&&(O&&I(O),H(V),y(O==="staged"||!O&&pe),ae(null),we.current=!0,ye.current=V,Se(V),Z(o=>o+1))},[E,Se,V,O,pe,ye,ae,we]),r.useEffect(()=>{if(E==="all")return;const o=u?.trim();o&&(H(o),y(E==="staged"),we.current=!0,ye.current=o,Se(o),Z(v=>v+1))},[E,Se,ye,we,u]),r.useEffect(()=>{if(!N)return;D.some(v=>v.path===N)||(H(null),y(!1))},[D,N]);const mt=r.useCallback((o,v)=>{Fe(),R(S=>{const T=S.has(o);if(v===T)return S;const G=new Set(S);return v?G.add(o):G.delete(o),G}),M(S=>{const T=S.has(o);if(v===T)return S;const G=new Set(S);return v?G.add(o):G.delete(o),G}),ke()},[Fe,ke,M]),gt=r.useCallback(()=>{Fe(),R(o=>o.size>0?new Set:new Set(D.map(v=>v.path))),M(new Set),ke()},[Fe,D,ke,M]),xt=r.useCallback(o=>{},[]),bt=r.useCallback(o=>{Fe(),H(o),y(!1),we.current=!0,ye.current=o,Se(o),Z(v=>v+1),Oe(o)},[Fe,Se,ye,Oe,we]),yt=r.useCallback(o=>{const v=o==="side-by-side"?"side-by-side":"inline";D.forEach(S=>{X(S.path,v)})},[D,X]),{openingEditorFilePath:wt,openFileInEditorAtChange:Ft}=bn({effectiveDirectory:c,activeDiffStaged:P,git:b,files:g,setDiff:$,openContextFileAtLine:re});return{git:b,files:g,effectiveDirectory:c,screenWidth:h,isMobile:w,isGitRepo:k,status:x,isLoadingStatus:C,activeDiffScope:E,setActiveDiffScope:I,branchDiffs:te,branchDiffError:be,branchDiffLoading:K,diffWrapLines:le,setDiffWrapLines:ve,forcedStaged:f,displayFileStaged:F,displayFile:N,pinnedStackedTarget:ft,expandedFiles:j,mountedStackedFiles:A,loadFullFiles:L,setLoadFullFiles:B,fileDiffRefreshNonce:ie,showFileSidebar:xe,diffScrollRef:dt,lastTurnDiffData:De,branchDiffData:ne,changedFiles:D,workingFileCount:Ee,stagedFileCount:Ae,turnFileCount:lt,allFileCount:ct,branchFileCount:ut,currentLayoutForAllFiles:ht,openingEditorFilePath:wt,registerSectionRef:pt,handleStackedEntryExpandedChange:mt,handleExpandOrCollapseAll:gt,handleSelectFile:xt,handleSelectFileAndScroll:bt,handleHeaderLayoutChange:yt,openFileInEditorAtChange:Ft,getLayoutForFile:Me}}const gs=({hideStackedFileSidebar:t=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:e=!1,showOpenInEditorAction:i=!1,diffScope:a="all",onDiffScopeChange:l,branchBase:p=null,branchHead:u=null,targetFilePath:b=null,flushContent:g=!1,hideToolbar:c=!1,onHeaderControlsStateChange:h,toolbarSlot:w=null})=>{const{effectiveDirectory:k,isGitRepo:x,status:C,isLoadingStatus:m,activeDiffScope:d,setActiveDiffScope:_,branchDiffError:W,branchDiffLoading:$,diffWrapLines:N,setDiffWrapLines:H,forcedStaged:F,displayFileStaged:y,displayFile:j,pinnedStackedTarget:R,expandedFiles:A,mountedStackedFiles:M,loadFullFiles:L,setLoadFullFiles:B,fileDiffRefreshNonce:U,showFileSidebar:Z,diffScrollRef:ie,lastTurnDiffData:fe,branchDiffData:E,changedFiles:I,workingFileCount:V,stagedFileCount:pe,turnFileCount:O,allFileCount:ae,branchFileCount:Y,currentLayoutForAllFiles:q,openingEditorFilePath:X,registerSectionRef:he,handleStackedEntryExpandedChange:ve,handleExpandOrCollapseAll:re,handleSelectFile:me,handleSelectFileAndScroll:ge,handleHeaderLayoutChange:le,openFileInEditorAtChange:f,getLayoutForFile:P}=yn({hideStackedFileSidebar:t,stackedDefaultCollapsedAll:s,pinSelectedFileHeaderToTopOnNavigate:e,diffScope:a,branchBase:p,branchHead:u,targetFilePath:b});r.useEffect(()=>{c&&l?.(d)},[d,c,l]);const ee=r.useCallback(()=>{B(ne=>!ne)},[B]),xe=r.useCallback(()=>{H(!N)},[N,H]),ce=r.useCallback(()=>{le(q==="side-by-side"?"unified":"side-by-side")},[q,le]),te=A.size,be=r.useMemo(()=>({turnCount:O,branchCount:Y,expandedCount:te,totalCount:I.length,loadFullFiles:L,wrapLines:N,layoutMode:q,onExpandOrCollapseAll:re,onToggleLoadFullFiles:ee,onToggleWrapLines:xe,onToggleLayout:ce}),[O,Y,te,I.length,L,N,q,re,ee,xe,ce]);r.useEffect(()=>{c&&h?.(be)},[c,be,h]);const K=()=>{if(!k)return null;const ne=D=>F!==null?F:y&&D===j;return n.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:[Z&&n.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:"Files"}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:I.length})]}),n.jsx(en,{changedFiles:I,selectedFile:null,onSelectFile:ge})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(et,{ref:ie,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:n.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:I.map(D=>n.jsx(ln,{directory:k,file:D,layout:P(D),wrapLines:N,isSelected:!1,isExpanded:A.has(D.path),isMounted:M.has(D.path)||D.path===R,onSelect:me,onExpandedChange:ve,registerSectionRef:he,showOpenInEditorAction:i&&d!=="turn"&&d!=="branch",isOpeningInEditor:X===D.path,onOpenInEditor:(Ee,Ae)=>{f(Ee,Ae)},staged:ne(D.path),showFileActions:d!=="turn"&&d!=="branch",loadFullFiles:L,initialDiffData:d==="turn"?fe.get(D.path)??null:d==="branch"?E.get(D.path)??null:null},`${D.path}:${U.get(D.path)??0}`))})})})]})},z=()=>k?d!=="turn"&&m&&!C?n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(J,{name:"loader-4",className:"size-4 animate-spin"}),"Loading repository status..."]}):d!=="turn"&&d!=="branch"&&x===!1?n.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."}):d==="branch"&&$?n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(J,{name:"loader-4",className:"size-4 animate-spin"}),"Loading branch changes..."]}):d==="branch"&&W?n.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: ${W}`}):I.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:d==="turn"?"No last turn changes to display":"Working tree clean, no changes to display"}):K():n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Select a session directory to view diffs"}),De=n.jsxs("div",{className:w?"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:[(x!==!1||d==="turn")&&(d==="all"||d==="working"||d==="staged"||d==="turn"||d==="branch")?n.jsx(zt,{scope:d,isGitRepo:x,branchAvailable:!!(p&&u),allCount:ae,workingCount:V,stagedCount:pe,turnCount:O,branchCount:Y,onScopeChange:ne=>{_(ne),l?.(ne)}}):n.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:n.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:m&&!C?"Loading changes...":I.length===1?`${I.length} file changed`:`${I.length} files changed`})}),I.length>0&&n.jsxs(Le,{variant:"ghost",size:"sm",onClick:re,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:[n.jsx(J,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:A.size>0?"Collapse all":"Expand all"})]}),I.length>0&&d!=="turn"&&d!=="branch"&&n.jsxs(_t,{children:[n.jsx(Wt,{asChild:!0,children:n.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>B(ne=>!ne),"aria-pressed":L,"aria-label":L?"Unload full files":"Load full files",className:se("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",L&&"bg-interactive-selection text-interactive-selection-foreground"),children:n.jsx(J,{name:"file-download",className:"size-4"})})}),n.jsx(Bt,{children:n.jsx("p",{children:L?"Unload full files":"Load full files"})})]}),I.length>0&&n.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>H(!N),className:se("h-5 w-5 p-0 transition-opacity",N?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:N?"Disable line wrap":"Enable line wrap",children:n.jsx(J,{name:"text-wrap",className:"size-4"})}),q&&n.jsx(it,{mode:q==="side-by-side"?"side-by-side":"unified",onModeChange:le})]});return n.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[w?St.createPortal(De,w):c?null:De,z()]})};export{gs as DiffView};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{k as r}from"./vendor-boot-Dgb9NVFe.js";import{R as a}from"./vendor-react-DASdDPIk.js";import{D as j}from"./vendor-react-drawio-Duu5LgQA.js";import{o as C}from"./index-BnZVqcki.js";import{ak as E,al as S,am as N,an as B,ao as F,ap as H,B as p}from"./useAppFontEffects-DviRbaCJ.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:o,className:d,onChange:u},m){const l=a.useRef(e),c=a.useRef(null),i=a.useRef(!1),[s,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(s);v.current!==s&&(v.current=s,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]),D=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(j,{ref:c,xml:f.current||A,autosave:!0,urlParameters:{ui:o?"simple":s?"dark":"kennedy",spin:!0,libraries:!o,chrome:o,nav:o,layers:o,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:R,onAutoSave:D},s?"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
|
+
|
|
3
|
+
… truncated …`:t,Y=({open:t,conflict:e,isResolving:o,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:s=>{s||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:o,"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:o,"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:o,"aria-label":i?"Recreate file with my edits":"Overwrite with my edits",title:i?"Recreate file with my edits":"Overwrite with my edits",children:o?"Working…":"Overwrite"})]})]})})};export{T as D,Y as F,G as b,W as i,X as s};
|