@pi-chamber/web 1.0.7-rc.1 → 1.0.8-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AgentsSurface-BmHImX8m.js +1 -0
- package/dist/assets/ChoicesArtifact-C71fGOm2.js +1 -0
- package/dist/assets/DiagramView-BZQxoiZu.js +1 -0
- package/dist/assets/{DiffView-C3rA5DfE.js → DiffView-C70pbgk-.js} +6 -6
- package/dist/assets/FileSaveConflictDialog-Cu8c3gBV.js +3 -0
- package/dist/assets/FilesView-nFJYEdRw.js +6 -0
- package/dist/assets/GitHubDetailScaffold-Jvv_tgbl.js +11 -0
- package/dist/assets/GitHubLinkPicker-BXD2ODRi.js +1 -0
- package/dist/assets/GitHubListPrimitives-BWI706F0.js +1 -0
- package/dist/assets/{GitView-OpFCss_4.js → GitView-MIDG5RYW.js} +5 -5
- package/dist/assets/{IssuesSurface-DD6Gz5Ox.js → IssuesSurface-uNlozeu0.js} +2 -2
- package/dist/assets/{JsonTreeView-Dj75jgH6.js → JsonTreeView-CSLsTriz.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-CnIzmT1p.js → MarkdownRendererImpl-Cs-7BfWi.js} +3 -3
- package/dist/assets/PatchDiff-axbsnbTJ.js +1 -0
- package/dist/assets/PierreDiffViewer-lwn6w_5w.js +147 -0
- package/dist/assets/PullRequestsSurface-o_AXDjbO.js +2 -0
- package/dist/assets/{SessionSwitcherContent-CUz6Cc1-.js → SessionSwitcherContent-C4CMlcbv.js} +1 -1
- package/dist/assets/SessionSwitcherDropdown-DCBVuCoo.js +2 -0
- package/dist/assets/SessionUnreadDot-DyeIrsro.js +1 -0
- package/dist/assets/SettingsView-BHBpt2Um.js +7 -0
- package/dist/assets/{SettingsWindow-J6YOvGcV.js → SettingsWindow-Cb4st5y5.js} +1 -1
- package/dist/assets/{StickyHorizontalScrollbar-DNsbTLS7.js → StickyHorizontalScrollbar-CMbTn5WQ.js} +1 -1
- package/dist/assets/SubagentsArtifact-BzeMEoFP.js +1 -0
- package/dist/assets/ToolOutputDialog-BP2mOWdV.js +8 -0
- package/dist/assets/ToolPartDiffPreview-D49XBR9b.js +1 -0
- package/dist/assets/{VirtualizedFileDiff-Dq8pyTGy.js → VirtualizedFileDiff-CLgDONEQ.js} +4 -4
- package/dist/assets/{Virtualizer-okhy9Aq3.js → Virtualizer-PxblpQn6.js} +1 -1
- package/dist/assets/VisualFrame-CJrAvWSo.js +22 -0
- package/dist/assets/VisualsArtifact-DqLGgU-Q.js +1 -0
- package/dist/assets/{collapsible-D6qdoq7-.js → collapsible-BeyKtQGB.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-uXZ9uhI_.js → computeVirtualFileMetrics-DmO6H8u6.js} +2 -2
- package/dist/assets/contextFileOpenGuard-DOK251YW.js +1 -0
- package/dist/assets/{fileTreeStatus-C_7jbeGv.js → fileTreeStatus-CnzR7kxA.js} +2 -2
- package/dist/assets/gitStatusPredicates-4kPg2t6j.js +1 -0
- package/dist/assets/githubLink-QvaLfNNT.js +10 -0
- package/dist/assets/{index-I2QYqABE.js → index-B2v0_mez.js} +8 -8
- package/dist/assets/index-D3F4JrPN.css +1 -0
- package/dist/assets/{index-DD0xW5WE.js → index-DMX9wT1Z.js} +1 -1
- package/dist/assets/{main-BnWf2tm9.js → main-BW9J3Y72.js} +2 -2
- package/dist/assets/main-BirYxac2.js +137 -0
- package/dist/assets/{markdownCore-C-Ulh4n9.js → markdownCore-CxmcPur8.js} +2 -2
- package/dist/assets/miniChat-BRB11eEs.js +2 -0
- package/dist/assets/{mobile-BuAWpKj9.js → mobile-DJZYYCuB.js} +2 -2
- package/dist/assets/{nativeFileSave-Cp9i5QGd.js → nativeFileSave-B6QpoPRn.js} +1 -1
- package/dist/assets/pi-session-focus-preference-PWoh3LNA.js +9 -0
- package/dist/assets/{renderDiffWithHighlighter-DD-iWWus.js → renderDiffWithHighlighter-C48T6YFJ.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-N-BQdJl0.js +2 -0
- package/dist/assets/{renderFileWithHighlighter-B0pofdV1.js → renderFileWithHighlighter-8Kt2MyTN.js} +1 -1
- package/dist/assets/{renderMobileApp-B3P_bita.js → renderMobileApp-B7cT7m5b.js} +3 -3
- package/dist/assets/runtimeEndpointReset-BC6yGnxN.js +62 -0
- package/dist/assets/runtimeSurface-kIEoYsPP.js +1 -0
- package/dist/assets/selection-BTEdLRVK.js +1 -0
- package/dist/assets/useAppFontEffects-EcTZ_I_I.js +225 -0
- package/dist/assets/useGitHubRemoteSearch-DIBHNu8r.js +1 -0
- package/dist/assets/useSwitcherItems-DfLbfX37.js +1 -0
- package/dist/assets/{vendor-aparajita-capacitor-secure-storage-DVZvgYu4.js → vendor-aparajita-capacitor-secure-storage-DUoR8t1G.js} +1 -1
- package/dist/assets/{vendor-base-ui-BCqPBzDj.js → vendor-base-ui-DE6jnTiC.js} +1 -1
- package/dist/assets/{vendor-boot-3SaHYVb1.js → vendor-boot-D-KEJjsM.js} +29 -29
- package/dist/assets/{vendor-capacitor-app-NbQ-WiPS.js → vendor-capacitor-app-CO5jS31X.js} +1 -1
- package/dist/assets/{vendor-capacitor-keyboard-CgrHt8iN.js → vendor-capacitor-keyboard-335osRpd.js} +1 -1
- package/dist/assets/{vendor-capacitor-status-bar-CWt0OF5t.js → vendor-capacitor-status-bar-lB9y4H9d.js} +1 -1
- package/dist/assets/{vendor-codemirror-autocomplete-WThuuUAz.js → vendor-codemirror-autocomplete-BKvJ8PfM.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-BbLGCxF6.js → vendor-codemirror-lang-angular-wjCUD0bM.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-Cceks-9O.js → vendor-codemirror-lang-cpp-LJzlG8sJ.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-D1wpUg3Z.js → vendor-codemirror-lang-css-DoEEdEpW.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-Cv0zXHHM.js → vendor-codemirror-lang-go-DexsLPb8.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-DbL8oT9H.js → vendor-codemirror-lang-html-h25V-Hp5.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-CNugenuC.js → vendor-codemirror-lang-java-D8xoT8cv.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-Bx_FIyZF.js → vendor-codemirror-lang-javascript-DF3GDYje.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-DDGjB3Zq.js → vendor-codemirror-lang-jinja-BboTHFdn.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-DIvqf9Pb.js → vendor-codemirror-lang-json-DCqvG1nE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-D8r9dGG1.js → vendor-codemirror-lang-less-B8ZrSKJM.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-B24mguYi.js → vendor-codemirror-lang-liquid-DF9S5m5F.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-v3yG2sbf.js → vendor-codemirror-lang-markdown-6BNbCEPe.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-BcZGalqy.js → vendor-codemirror-lang-php-CQwAz1Hd.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-b-JqEwQy.js → vendor-codemirror-lang-python-DQym-8Tx.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-B1uZxDW-.js → vendor-codemirror-lang-rust-DknzOTkO.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-DqPrngKp.js → vendor-codemirror-lang-sass-dB0Rm5HI.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-UyCnpt-k.js → vendor-codemirror-lang-sql-CCQUnnD-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-xDwYkovV.js → vendor-codemirror-lang-vue-h1M5bF00.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-CF3169p_.js → vendor-codemirror-lang-wast-DWgtlGfu.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-FCtVhuOb.js → vendor-codemirror-lang-xml-DncwoCUY.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-g0sPmAnv.js → vendor-codemirror-lang-yaml-C7QkS5ER.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-B03xgzP2.js → vendor-codemirror-language-data-BUZIlm3G.js} +2 -2
- package/dist/assets/{vendor-codemirror-search-Dw3Wpu15.js → vendor-codemirror-search-BlDCaCMK.js} +1 -1
- package/dist/assets/{vendor-lezer-cpp-Cu3E-KUI.js → vendor-lezer-cpp-B4JK1BC1.js} +1 -1
- package/dist/assets/{vendor-lezer-css-Cb8vp67u.js → vendor-lezer-css-DRxDmhcy.js} +1 -1
- package/dist/assets/{vendor-lezer-go-BTsIaOm7.js → vendor-lezer-go-DsUgfmxi.js} +1 -1
- package/dist/assets/{vendor-lezer-html-UQMsUwj-.js → vendor-lezer-html-qr9pUPmM.js} +1 -1
- package/dist/assets/{vendor-lezer-java-BIWrFrAx.js → vendor-lezer-java-6UyNiQiB.js} +1 -1
- package/dist/assets/{vendor-lezer-javascript-BH2Etgoy.js → vendor-lezer-javascript-CUdJ0VGA.js} +1 -1
- package/dist/assets/{vendor-lezer-json-CE-QUCwM.js → vendor-lezer-json-BKYAA8Hu.js} +1 -1
- package/dist/assets/{vendor-lezer-lr-HY6Yc0Vr.js → vendor-lezer-lr-DluApmOX.js} +1 -1
- package/dist/assets/{vendor-lezer-markdown-xFL3Evwf.js → vendor-lezer-markdown-B-uzYzYT.js} +1 -1
- package/dist/assets/{vendor-lezer-php-Cr_mQGrG.js → vendor-lezer-php-DI6PNjlz.js} +1 -1
- package/dist/assets/{vendor-lezer-python-BNRFWCb0.js → vendor-lezer-python-Bj232yb5.js} +1 -1
- package/dist/assets/{vendor-lezer-rust-BvfOK5cU.js → vendor-lezer-rust-DlPG_Yau.js} +1 -1
- package/dist/assets/{vendor-lezer-sass-qoxiLisk.js → vendor-lezer-sass-CBsyWB2A.js} +1 -1
- package/dist/assets/{vendor-lezer-xml--x8SSpqU.js → vendor-lezer-xml-C1FmgtmE.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-BDo1JaEr.js → vendor-lezer-yaml-DpHmjriG.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-D1Fe7FiY.js → vendor-replit-codemirror-vim-Cvk64got.js} +1 -1
- package/dist/assets/{web-components-DB-GDG7P.js → web-components-C_DsTJis.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 +2 -1
- package/plugins/registry.json +7 -0
- package/plugins/subagents/LICENSE +25 -0
- package/plugins/subagents/agents/planner.md +36 -0
- package/plugins/subagents/agents/reviewer.md +34 -0
- package/plugins/subagents/agents/scout.md +49 -0
- package/plugins/subagents/agents/worker.md +23 -0
- package/plugins/subagents/extension.js +631 -0
- package/plugins/subagents/extension.test.js +295 -0
- package/plugins/subagents/package.json +41 -0
- package/plugins/visuals/choices.js +168 -0
- package/plugins/visuals/extension.js +87 -0
- package/plugins/visuals/files.js +74 -0
- package/plugins/visuals/package.json +32 -0
- package/server/index.js +20 -0
- package/server/lib/github/DOCUMENTATION.md +4 -2
- package/server/lib/github/gh-cli.js +35 -9
- package/server/lib/github/gh-cli.test.js +122 -0
- package/server/lib/notifications/pi-notification-watcher.js +3 -0
- package/server/lib/notifications/pi-notification-watcher.test.js +10 -0
- package/server/lib/open-url/DOCUMENTATION.md +1 -1
- package/server/lib/pi/extension-protocol.js +54 -0
- package/server/lib/pi/fixtures/pichamber-gui-demo.ts +12 -13
- package/server/lib/pi/routes-extension-events.test.js +115 -0
- package/server/lib/pi/routes.js +307 -5
- package/server/lib/pi/routes.test.js +296 -1
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +25 -8
- package/server/lib/pi/session-daemon/extension-bridge.js +89 -29
- package/server/lib/pi/session-daemon/extension-config.js +719 -0
- package/server/lib/pi/session-daemon/extension-config.test.js +618 -0
- package/server/lib/pi/session-daemon/extension-controls.js +177 -0
- package/server/lib/pi/session-daemon/extension-controls.test.js +181 -0
- package/server/lib/pi/session-daemon/extension-name.js +6 -0
- package/server/lib/pi/session-daemon/extension-name.test.js +5 -0
- package/server/lib/pi/session-daemon/extension-palette.js +146 -0
- package/server/lib/pi/session-daemon/extension-palette.test.js +107 -0
- package/server/lib/pi/session-daemon/extension-replacements.js +138 -0
- package/server/lib/pi/session-daemon/extension-replacements.test.js +116 -0
- package/server/lib/pi/session-daemon/extension-ui-mode.js +30 -0
- package/server/lib/pi/session-daemon/extension-ui-mode.test.js +34 -0
- package/server/lib/pi/session-daemon/pichamber-ui.js +44 -0
- package/server/lib/pi/session-daemon/plugin-host.js +245 -0
- package/server/lib/pi/session-daemon/plugin-host.test.js +192 -0
- package/server/lib/pi/session-daemon/session-daemon-controls.e2e.test.js +205 -0
- package/server/lib/pi/session-daemon/session-daemon-drafts.e2e.test.js +409 -0
- package/server/lib/pi/session-daemon/session-daemon-extension-config.e2e.test.js +196 -0
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +137 -6
- package/server/lib/pi/session-daemon/session-daemon-plugins.e2e.test.js +272 -0
- package/server/lib/pi/session-daemon/session-daemon-providers.e2e.test.js +153 -0
- package/server/lib/pi/session-daemon/session-daemon.js +568 -61
- package/server/lib/pi/session-daemon/session-daemon.test.js +164 -4
- package/server/lib/pi/session-daemon/session-engine-router.js +7 -0
- package/server/lib/pi/session-daemon/session-engine-router.test.js +20 -0
- package/server/lib/pi/session-daemon/supervisor.js +22 -3
- package/server/lib/pi/settings-store.js +14 -0
- package/server/lib/pi/settings-store.test.js +11 -0
- package/server/lib/plugins/DOCUMENTATION.md +186 -0
- package/server/lib/plugins/daemon-sync.js +78 -0
- package/server/lib/plugins/daemon-sync.supervisor.test.js +83 -0
- package/server/lib/plugins/daemon-sync.test.js +96 -0
- package/server/lib/plugins/impact.js +139 -0
- package/server/lib/plugins/impact.test.js +82 -0
- package/server/lib/plugins/manifest.js +195 -0
- package/server/lib/plugins/manifest.test.js +118 -0
- package/server/lib/plugins/registry.js +59 -0
- package/server/lib/plugins/routes.js +92 -0
- package/server/lib/plugins/routes.test.js +219 -0
- package/server/lib/plugins/service.js +161 -0
- package/server/lib/plugins/store.js +261 -0
- package/server/lib/plugins/store.test.js +188 -0
- package/server/lib/plugins/visuals-extension.test.js +237 -0
- package/server/lib/server-browser/DOCUMENTATION.md +32 -7
- package/server/lib/server-browser/browser-tab.js +4 -1
- package/server/lib/server-browser/downloads.js +261 -34
- package/server/lib/server-browser/downloads.test.js +171 -0
- package/server/lib/server-browser/runtime.integration.test.js +47 -0
- package/server/lib/server-browser/runtime.js +16 -0
- package/server/lib/server-browser/server-browser.js +25 -6
- package/server/lib/tunnels/executable-search.js +5 -1
- package/server/lib/tunnels/executable-search.test.js +26 -0
- package/dist/assets/DiagramView-DyF8zzYx.js +0 -1
- package/dist/assets/FileSaveConflictDialog-CC4F--8H.js +0 -3
- package/dist/assets/FilesView-Dsg-QTJu.js +0 -6
- package/dist/assets/GitHubDetailScaffold-C9WuBMGr.js +0 -11
- package/dist/assets/GitHubLinkPicker-BkVdYxZT.js +0 -1
- package/dist/assets/GitHubListPrimitives-CcVlv_rJ.js +0 -1
- package/dist/assets/PatchDiff-DND5RBnF.js +0 -1
- package/dist/assets/PierreDiffViewer-Cq5CIrmH.js +0 -147
- package/dist/assets/PullRequestsSurface-g8HAvbFg.js +0 -2
- package/dist/assets/SessionSwitcherDropdown-COZ50Y5a.js +0 -2
- package/dist/assets/SessionUnreadDot-DOUcgBw6.js +0 -1
- package/dist/assets/SettingsView-AFymxZYC.js +0 -6
- package/dist/assets/ToolOutputDialog-5Tc7HM4z.js +0 -8
- package/dist/assets/ToolPartDiffPreview-7GiFbVl7.js +0 -1
- package/dist/assets/contextFileOpenGuard-CckKFYjI.js +0 -1
- package/dist/assets/gitStatusPredicates-CNLvdt2V.js +0 -1
- package/dist/assets/githubLink-0EoMGZKd.js +0 -10
- package/dist/assets/index-BaLCg7tL.css +0 -1
- package/dist/assets/main-yQe-k30g.js +0 -137
- package/dist/assets/miniChat-DKK1hotU.js +0 -2
- package/dist/assets/pi-session-focus-preference-DaWQ2rEE.js +0 -9
- package/dist/assets/renderElectronMiniChatApp-CKuFQBRo.js +0 -2
- package/dist/assets/runtimeEndpointReset-DutinXZK.js +0 -62
- package/dist/assets/runtimeSurface-CFwnvks_.js +0 -1
- package/dist/assets/useAppFontEffects-DQlUEhzN.js +0 -213
- package/dist/assets/useGitHubRemoteSearch-BoZvJAk3.js +0 -1
- package/dist/assets/useSwitcherItems-Dy2yumiU.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t}from"./vendor-boot-D-KEJjsM.js";import{R as f}from"./vendor-react-Bz1tRBxM.js";import{w as v,S as y,B as x,I as m}from"./useAppFontEffects-EcTZ_I_I.js";import{p as w,r as S,u as j,a as A,b as I,c as k}from"./selection-BTEdLRVK.js";import"./vendor-clsx-B-dksMZM.js";import"./index-B2v0_mez.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-kIEoYsPP.js";import"./nativeFileSave-B6QpoPRn.js";const R=(s,a)=>s.length===a.length&&s.every((i,c)=>i===a[c]),T=s=>s==="running"||s==="pending"?"running":s==="error"?"error":s==="cancelled"?"cancelled":"completed",z=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}),D=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),F=s=>{const a=new Date(s);return a.toDateString()===new Date().toDateString()?z.format(a):D.format(a)};function b({title:s,count:a}){return t.jsxs("header",{className:"flex items-baseline gap-2 px-0.5",children:[t.jsx("h3",{className:"typography-meta font-medium text-foreground",children:s}),t.jsx("span",{className:"typography-micro tabular-nums text-subtle-foreground",children:a})]})}function H({sessionId:s}){const a=v(e=>{if(!s)return[];const n=e.reducer.bySession.get(s);if(!n)return[];const r=[];for(const l of n.parts.values())l.type==="tool"&&l.tool?.name===y&&r.push(l);return r},R,s?`session:${s}`:"chrome"),i=f.useMemo(()=>a.flatMap(e=>{const n=T(e.tool?.state),r=w(e.tool?.metadata,n)??(n==="running"?S(e.tool?.input):null);return!r||r.runs.length===0?[]:[{id:e.id,startedAt:e.tool?.startedAt??0,details:r}]}).sort((e,n)=>n.startedAt-e.startedAt),[a]),{active:c,finished:h}=f.useMemo(()=>{const e=[],n=[];for(const r of i)r.details.runs.forEach((l,p)=>{const N={key:`${r.id}:${p}`,callId:r.id,index:p,startedAt:r.startedAt,run:l};(l.status==="running"||l.status==="queued"?e:n).push(N)});return{active:e,finished:n}},[i]),d=j(e=>e.selected),u=j(e=>e.select),o=d?i.find(e=>e.id===d.callId):void 0,g=d&&o?o.details.runs[d.index]:void 0;if(g&&o){const{runs:e}=o.details,n=d?.index??0;return t.jsxs("div",{className:"@container flex h-full min-h-0 flex-col","data-testid":"agents-surface",children:[t.jsxs("nav",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-border/60 px-1.5","aria-label":"Sub-agent",children:[t.jsxs(x,{variant:"ghost",size:"xs",className:"text-muted-foreground",onClick:()=>u(null),children:[t.jsx(m,{name:"arrow-left-s",className:"size-4"}),"All agents"]}),e.length>1?t.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[t.jsx("span",{className:"mr-1 typography-micro tabular-nums text-subtle-foreground",children:`${n+1} of ${e.length}`}),t.jsx(x,{variant:"ghost",size:"icon",className:"size-7","aria-label":"Previous sub-agent",disabled:n===0,onClick:()=>u({callId:o.id,index:n-1}),children:t.jsx(m,{name:"arrow-up-s",className:"size-4"})}),t.jsx(x,{variant:"ghost",size:"icon",className:"size-7","aria-label":"Next sub-agent",disabled:n===e.length-1,onClick:()=>u({callId:o.id,index:n+1}),children:t.jsx(m,{name:"arrow-down-s",className:"size-4"})})]}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:t.jsx(A,{run:g})})]})}return i.length===0?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1.5 p-6 text-center",children:[t.jsx(m,{name:"robot-2","aria-hidden":"true",className:"size-6 text-subtle-foreground"}),t.jsx("p",{className:"typography-ui-label font-medium text-foreground",children:"No sub-agents in this session"}),t.jsx("p",{className:"max-w-64 text-balance typography-micro text-muted-foreground",children:"When the agent hands work to sub-agents, each one shows up here with its steps and answer."})]}):t.jsxs("div",{className:"@container flex h-full min-h-0 flex-col gap-5 overflow-y-auto p-3","data-testid":"agents-surface",children:[c.length>0?t.jsxs("section",{className:"space-y-2","aria-label":"Working",children:[t.jsx(b,{title:"Working",count:c.length}),t.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-2",children:c.map(e=>t.jsx(I,{run:e.run,onOpen:()=>u({callId:e.callId,index:e.index})},e.key))})]}):null,h.length>0?t.jsxs("section",{className:"space-y-1","aria-label":"Finished",children:[t.jsx(b,{title:"Finished",count:h.length}),t.jsx("ul",{className:"-mx-1.5",children:h.map(e=>t.jsx("li",{children:t.jsx(k,{run:e.run,time:e.startedAt>0?F(e.startedAt):void 0,onOpen:()=>u({callId:e.callId,index:e.index})})},e.key))})]}):null]})}export{H as AgentsSurface};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t}from"./vendor-boot-D-KEJjsM.js";import{R as d}from"./vendor-react-Bz1tRBxM.js";import{B as y,I as v,f as F,m as R,n as _,p as M}from"./useAppFontEffects-EcTZ_I_I.js";import{c as T}from"./index-B2v0_mez.js";import{u as B,V as L,b as V,c as G,P as X,d as K}from"./VisualFrame-CJrAvWSo.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-kIEoYsPP.js";import"./nativeFileSave-B6QpoPRn.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";const W=6,Y=/^data:image\/(?:png|jpeg|webp|gif|svg\+xml);base64,/,Q=e=>typeof e=="string"&&Y.test(e),b=e=>e.toUpperCase(),U=e=>String.fromCharCode(97+e),J=(e,s)=>{if(!e||typeof e!="object")return null;const n=e,r=typeof n.label=="string"?n.label.trim():"";if(!r)return null;const a=typeof n.id=="string"&&/^[a-z]$/.test(n.id)?n.id:U(s),o=typeof n.description=="string"?n.description.trim():"";return{id:a,label:r,...o?{description:o}:{},...typeof n.html=="string"&&n.html.length>0?{html:n.html}:{},...Q(n.image)?{image:n.image}:{},...typeof n.path=="string"&&n.path.trim()?{path:n.path.trim()}:{}}},S=e=>{if(!Array.isArray(e)||e.length===0)return null;const s=[],n=new Set;for(const[r,a]of e.slice(0,W).entries()){const o=J(a,r);if(!o||n.has(o.id))return null;n.add(o.id),s.push(o)}return s},k=e=>typeof e=="string"&&e.trim()?e.trim():"Choose one",Z=e=>{if(!e||typeof e!="object")return null;const s=e,n=S(s.options);if(!n||n.some(a=>a.html===void 0&&a.image===void 0))return null;const r={title:k(s.title),options:n};if(s.answer===null)return{...r,answer:null};if(s.answer&&typeof s.answer=="object"){const a=s.answer;if(typeof a.id!="string"||!n.some(l=>l.id===a.id))return r;const o=typeof a.note=="string"?a.note.trim():"";return{...r,answer:{id:a.id,...o?{note:o}:{}}}}return r},q=e=>{if(!e||typeof e!="object")return null;const s=e,n=S(s.options);return n?{title:k(s.title),options:n.map(r=>{const a={...r};return delete a.image,a})}:null},ee=e=>e.choices.length===0?null:{title:k(e.title),options:e.choices.map(s=>{const n=`${b(s.id)}: `,r=s.label.startsWith(n)?s.label.slice(n.length):s.label;return{id:s.id,label:r||s.label,...s.description?{description:s.description}:{}}})},te=(e,s)=>{const n=r=>r?e.find(a=>a.id===r):void 0;return n(s.picked)??n(s.chosenId)??e.find(r=>s.offered?.includes(r.id))??e[0]},se=e=>{const s=e?.options;return Array.isArray(s)?s.reduce((n,r)=>{const a=r?.html;return n+(typeof a=="string"?a.length:0)},0):0},D=120,H=560,ne=240,re=2e3,ae=(e,s,n)=>Math.min(n,Math.max(s,e)),O=e=>`${b(e.id)}: ${e.label}`;function ie({option:e,allowNetwork:s,expanded:n,onExpandedChange:r}){const a=V(e.html,s),o=d.useRef(null),l=G(o),[m,u]=d.useState("page"),[p,j]=d.useState(null),w=p??ne,f=O(e),N=d.useCallback(g=>{j(ae(g,D,H))},[]);return t.jsxs("div",{ref:o,style:{height:w},"data-choice-page":p===null?"loading":"fitted",children:[l?t.jsx(X,{title:f,srcDoc:a,style:{height:w},onHeight:N}):null,t.jsx(K,{details:{title:f,html:e.html},srcDoc:a,open:n,onOpenChange:r,view:m,onViewChange:u})]})}function oe({option:e,expanded:s,onExpandedChange:n}){const r=O(e);return t.jsxs(t.Fragment,{children:[t.jsx("img",{src:e.image,alt:e.description?`${r}. ${e.description}`:r,className:"block w-full bg-[var(--surface-muted)] object-contain",style:{maxHeight:H}}),t.jsx(R,{open:s,onOpenChange:n,children:t.jsxs(_,{showCloseButton:!1,className:"h-[calc(100dvh-2rem)] w-[min(1200px,calc(100vw-2rem))] max-w-none gap-0 overflow-hidden bg-background p-0",children:[t.jsxs("div",{className:"flex h-11 shrink-0 items-center gap-2 border-b border-border/60 pl-4 pr-2",children:[t.jsx(M,{className:"min-w-0 flex-1 truncate typography-ui-header font-medium leading-normal",children:r}),t.jsx(y,{variant:"ghost",size:"xs",className:"text-muted-foreground",onClick:()=>n(!1),"aria-label":"Close",title:"Close",children:t.jsx(v,{name:"close",className:"size-3.5"})})]}),t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto bg-[var(--surface-muted)] p-4",children:t.jsx("img",{src:e.image,alt:r,className:"max-h-full max-w-full object-contain"})})]})})]})}function le({option:e,allowNetwork:s,expanded:n,onExpandedChange:r}){return e.html!==void 0?t.jsx(ie,{option:e,allowNetwork:s,expanded:n,onExpandedChange:r}):e.image!==void 0?t.jsx(oe,{option:e,expanded:n,onExpandedChange:r}):t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 px-4 py-8 text-center text-muted-foreground",style:{minHeight:D},children:[t.jsx("span",{className:"typography-meta",children:"Preview not loaded"}),e.path?t.jsx("span",{className:"max-w-full truncate font-mono typography-micro text-subtle-foreground",children:e.path}):null]})}const ce=(e,s)=>s?"Waiting for your choice":e.answer===null?"No choice made":e.answer?`You chose ${b(e.answer.id)}`:null;function de({details:e,question:s,allowNetwork:n}){const[r,a]=d.useState(""),[o,l]=d.useState(!1),[m,u]=d.useState(!1),[p,j]=d.useState(!1),[w,f]=d.useState(null),N=d.useId(),g=e.answer?.id,c=te(e.options,{picked:w,chosenId:g,offered:s?.choices.map(i=>i.id)}),C=b(c.id),I=i=>{l(!0),u(!1),i.catch(()=>u(!0)).finally(()=>l(!1))},A=ce(e,!!s),E=!!s?.choices.some(i=>i.id===c.id),z=c.html!==void 0||c.image!==void 0,P=i=>{if(i.key!=="ArrowLeft"&&i.key!=="ArrowRight")return;const h=e.options.findIndex($=>$.id===c.id),x=e.options[(h+(i.key==="ArrowRight"?1:-1)+e.options.length)%e.options.length];i.preventDefault(),f(x.id),i.currentTarget.querySelector(`[data-choice-tab="${x.id}"]`)?.focus()};return t.jsxs("section",{className:"my-3 space-y-2","data-plugin-artifact":"visuals-choices","aria-label":e.title,children:[t.jsxs("header",{className:"flex min-h-7 flex-wrap items-baseline gap-x-2",children:[t.jsx("h3",{className:"min-w-0 typography-ui-label font-medium text-foreground [text-wrap:balance]",children:e.title}),A?t.jsx("span",{className:"typography-micro text-subtle-foreground",children:A}):null]}),t.jsxs("figure",{className:"overflow-hidden rounded-xl border border-border/60 bg-background","data-choice":c.id,children:[t.jsxs("div",{className:"flex h-11 items-center gap-2 border-b border-border/60 pl-2 pr-1.5",children:[t.jsx("div",{role:"group","aria-label":"Options",className:"scrollbar-none flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto py-1",onKeyDown:P,children:e.options.map(i=>{const h=b(i.id),x=i.id===c.id;return t.jsxs(y,{variant:"chip",size:"xs",className:"max-w-[14rem] shrink-0 gap-1.5","aria-pressed":x,tabIndex:x?0:-1,"data-choice-tab":i.id,"data-chosen":i.id===g||void 0,title:i.label,onClick:()=>f(i.id),children:[t.jsx("span",{"aria-hidden":"true",className:"typography-micro font-medium text-muted-foreground",children:h}),t.jsx("span",{className:"sr-only",children:`${h}: `}),t.jsx("span",{className:"min-w-0 truncate",children:i.label}),i.id===g?t.jsxs(t.Fragment,{children:[t.jsx(v,{name:"check","aria-hidden":"true",className:"size-3.5 shrink-0"}),t.jsx("span",{className:"sr-only",children:", chosen"})]}):null]},i.id)})}),z?t.jsx(y,{variant:"ghost",size:"xs",className:"shrink-0 text-muted-foreground",onClick:()=>j(!0),"aria-label":`Expand ${C}`,title:"Expand",children:t.jsx(v,{name:"fullscreen",className:"size-3.5"})}):null]}),t.jsx("div",{className:"grid",children:e.options.map(i=>{const h=i.id===c.id;return t.jsx("div",{className:T("min-w-0 [grid-area:1/1]",h?null:"pointer-events-none invisible"),"aria-hidden":h?void 0:!0,"data-choice-panel":i.id,children:t.jsx(le,{option:i,allowNetwork:n,expanded:h&&p,onExpandedChange:j})},i.id)})}),c.description||E?t.jsxs("figcaption",{className:"flex min-h-11 items-center gap-3 border-t border-border/60 px-3 py-2",children:[t.jsx("p",{className:"min-w-0 flex-1 typography-meta text-muted-foreground [text-wrap:pretty]",children:c.description??""}),E&&s?t.jsx(y,{size:"sm",className:"shrink-0",onClick:()=>I(s.answer(c.id,r)),disabled:o,children:`Choose ${C}`}):null]}):null]}),s?t.jsxs("div",{className:"flex items-center gap-2",children:[s.allowNote?t.jsxs(t.Fragment,{children:[t.jsx("label",{htmlFor:N,className:"sr-only",children:"Note to send with your choice"}),t.jsx(F,{id:N,value:r,onChange:i=>a(i.target.value),placeholder:"Add a note for the agent (optional)",maxLength:re,disabled:o,className:"h-8 flex-1"})]}):t.jsx("span",{className:"flex-1"}),t.jsx(y,{variant:"ghost",size:"sm",className:"shrink-0 text-muted-foreground",onClick:()=>I(s.dismiss()),disabled:o,children:"Skip"})]}):e.answer?.note?t.jsxs("p",{className:"typography-meta text-muted-foreground [text-wrap:pretty]",children:[t.jsx("span",{className:"text-foreground",children:"Your note: "}),e.answer.note]}):null,m?t.jsx("p",{role:"alert",className:"typography-meta text-[var(--status-error)]",children:"Could not send your answer. Check your connection and try again."}):null]})}function ve({part:e,directory:s,question:n}){const r=B(s),a=e.state?.status,o=e.state?.metadata,l=e.state?.input,m=a==="pending"||a==="running",u=d.useMemo(()=>Z(o)??(m&&n?q(l)??ee(n):null),[l,o,n,m]);if(m&&!u){const p=l?.title;return t.jsx(L,{title:typeof p=="string"?p:void 0,size:se(l),label:"Drawing options"})}return!u||!m&&a!=="completed"?null:t.jsx(de,{details:u,question:m?n:void 0,allowNetwork:r})}export{ve as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as c}from"./vendor-boot-D-KEJjsM.js";import{R as t}from"./vendor-react-Bz1tRBxM.js";import{j as $,t as d,I as B}from"./useAppFontEffects-EcTZ_I_I.js";import{u as A,b as G,s as ee,i as W}from"./index-B2v0_mez.js";import{b as te,D as re,F as ne}from"./FileSaveConflictDialog-Cu8c3gBV.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-kIEoYsPP.js";import"./nativeFileSave-B6QpoPRn.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=A(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=A.getState().consumePendingDiagramFile();e&&K(e)},[K,T]);const z=t.useCallback(async(e,n,s,u,r,o)=>{let a=null,f=s,V=u;try{if(V){const N=await l?.readFile?.(e);if(!i(r,o,e))return;N&&(a=N.content??null,typeof N.revision=="string"&&(f=N.revision),V=N.exists!==!1)}}catch{if(!i(r,o,e))return}i(r,o,e)&&(h({path:e,displayPath:se(e),exists:V,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=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]),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 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?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:()=>A.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,18 +1,18 @@
|
|
|
1
|
-
import{j as t,
|
|
2
|
-
`)){const f=l.match(Et);if(f!=null){i!=null&&(i.hunkLines.length>0&&(Pe(i,n,"trailing"),
|
|
1
|
+
import{j as t,b1 as Rt}from"./vendor-boot-D-KEJjsM.js";import{R as r}from"./vendor-react-Bz1tRBxM.js";import{c as se,u as Q,b as ot,n as Ye}from"./index-B2v0_mez.js";import{bL as Et,bH as At,aS as Tt,aj as lt,aW as ct,bl as Mt,K as Re,B as Le,I as G,j as ut,ax as ce,t as dt,bm as ft,D as It,h as Pt,i as $t,a1 as Je,b8 as Wt,bM as _t,bN as Bt,aZ as Ot,ai as zt,bO as Gt,bP as Ht,bQ as Ut,x as Vt,bR as qt,bS as Kt,ap as Xt,aq as Qt,ar as Yt}from"./useAppFontEffects-EcTZ_I_I.js";import{d as pt,i as ht,a as Ge,b as He,c as Jt,C as Zt}from"./gitStatusPredicates-4kPg2t6j.js";import{p as en}from"./VirtualizedFileDiff-CLgDONEQ.js";import{P as tn}from"./PierreDiffViewer-lwn6w_5w.js";import{v as nn,g as sn}from"./contextFileOpenGuard-DOK251YW.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-kIEoYsPP.js";import"./nativeFileSave-B6QpoPRn.js";import"./web-components-C_DsTJis.js";import"./computeVirtualFileMetrics-DmO6H8u6.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-C48T6YFJ.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-CMbTn5WQ.js";import"./runtimeEndpointReset-BC6yGnxN.js";import"./SessionUnreadDot-DyeIrsro.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
|
+
`)){const f=l.match(Et);if(f!=null){i!=null&&(i.hunkLines.length>0&&(Pe(i,n,"trailing"),Oe(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;Oe(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"),Oe(i,e));const o=e.join(`
|
|
3
3
|
`);return s.endsWith(`
|
|
4
4
|
`)?`${o}
|
|
5
|
-
`:o}function Pe(s,n,e){if(e==="leading"&&s.contextLines.length>n){const i=s.contextLines.length-n;s.contextLines.splice(0,i),s.additionStart+=i,s.deletionStart+=i}return e==="trailing"&&s.contextLines.length>n&&(s.contextLines.length=n),s.contextLines.length>0&&(s.hunkLines.push(...s.contextLines),s.additionCount+=s.contextLines.length,s.deletionCount+=s.contextLines.length,s.contextLines.length=0),s}function
|
|
5
|
+
`:o}function Pe(s,n,e){if(e==="leading"&&s.contextLines.length>n){const i=s.contextLines.length-n;s.contextLines.splice(0,i),s.additionStart+=i,s.deletionStart+=i}return e==="trailing"&&s.contextLines.length>n&&(s.contextLines.length=n),s.contextLines.length>0&&(s.hunkLines.push(...s.contextLines),s.additionCount+=s.contextLines.length,s.deletionCount+=s.contextLines.length,s.contextLines.length=0),s}function Oe(s,n){n.push(`@@ -${Ze(s.deletionStart,s.deletionCount)} +${Ze(s.additionStart,s.additionCount)} @@`),n.push(...s.hunkLines)}function Ze(s,n){return n===1?`${s}`:`${s},${n}`}const an=64,on=3,he=new Map,ln=(s,n,e=on)=>{const i=`${s}\0${e}\0${n}`,o=he.get(i);if(o)return he.delete(i),he.set(i,o),o;const l=un(n),f=l?At(rn(n,e),{oldFile:{name:s,contents:l.before},newFile:{name:s,contents:l.after}})??tt(s):Tt(cn(s,n))[0]?.files[0]??tt(s);for(he.set(i,f);he.size>an;){const d=he.keys().next().value;if(!d)break;he.delete(d)}return f},cn=(s,n)=>!n.trim()||n.startsWith("diff --git ")||/^--- [^\n]*\r?\n\+\+\+ /m.test(n)?n:`Index: ${s}
|
|
6
6
|
===================================================================
|
|
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=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(`
|
|
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"})})}),ze=({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(ze,{label:`Unstage ${n}`,text:"Unstage",icon:"arrow-go-back",loading:o==="unstage",disabled:l,onClick:()=>f("unstage")}):t.jsxs(t.Fragment,{children:[t.jsx(ze,{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(ze,{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=Q(u=>u.setDiffFileLayout),M=Q(u=>u.setDiffWrapLines),[A,_]=r.useState(0),[N,O]=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),J=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),O(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,O(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((z,te)=>{setTimeout(()=>te(new Error(`Timed out after ${ye}ms`)),ye)});return Promise.race([ee,we]).then(z=>{if(!P){if("diff"in z){const te=Ue(e.path,z.diff,re);ae({source:x,data:te})}else{const te={original:z.original??"",modified:z.modified??"",isBinary:z.isBinary,contextMode:"full"};x==="head"?w(n,e.path,te,ne):ae({source:x,data:te})}K(!1)}}).catch(z=>{if(P)return;const te=z instanceof Error?z.message:String(z);O(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:J.color},title:J.description,"aria-label":J.description,children:J.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(Je,{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(Je,{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(`
|
|
14
14
|
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
|
-
`))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,
|
|
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};
|
|
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,O]of d.current){if(!O)continue;const q=O.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 O=!1;const q=new Set(N);for(const K of Object.keys(A))q.has(K)||(q.add(K),O=!0);return O?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=Ot(),{screenWidth:p,isMobile:F}=zt(),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,O]=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=Q(a=>a.pendingDiffFile),ae=Q(a=>a.pendingDiffStaged),B=Q(a=>a.pendingDiffScope),me=Q(a=>a.setPendingDiffFile),J=Q(a=>a.diffLayoutPreference),H=Q(a=>a.diffFileLayout),re=Q(a=>a.setDiffFileLayout),ue=Q(a=>a.diffWrapLinesOverride),Z=Q(a=>a.wrapLinesByDefault),oe=Q(a=>a.setDiffWrapLines),De=Q(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:z,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:z).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:Jt(v)})).sort((v,I)=>v.path.localeCompare(I.path))},[T,ee,z,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=z.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),Qe=new Set(a.slice(0,pe));return Ne&&Qe.add(Ne),Qe}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(J==="inline")return"inline";if(J==="side-by-side")return"side-by-side";const v=p<jn;return a.isNew||v?"inline":"side-by-side"},[H,J,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:O,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:O,fileDiffRefreshNonce:q,showFileSidebar:K,diffScrollRef:ie,lastTurnDiffData:ge,branchDiffData:T,changedFiles:W,workingFileCount:Y,stagedFileCount:ae,turnFileCount:B,allFileCount:me,branchFileCount:J,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(()=>{O(D=>!D)},[O]),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:J,focusedFilePath:ee?.path??null,expandedCount:de,totalCount:W.length,loadFullFiles:N,wrapLines:E,layoutMode:H,onExpandOrCollapseAll:oe,onToggleLoadFullFiles:u,onToggleWrapLines:P,onToggleLayout:ne}),[B,J,ee,de,W.length,N,E,H,oe,u,P,ne]);r.useEffect(()=>{c&&p?.(we)},[c,we,p]);const z=()=>{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"}):z():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:J,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(Qt,{asChild:!0,children:t.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>O(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};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{j as r}from"./vendor-boot-D-KEJjsM.js";import{R as a}from"./vendor-react-Bz1tRBxM.js";import{D}from"./vendor-react-drawio-IYnLUY5N.js";import{c as C}from"./index-B2v0_mez.js";import{m as E,n as S,o as N,p as B,q as F,U as H,B as p}from"./useAppFontEffects-EcTZ_I_I.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
|
+
|
|
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};
|