@pi-chamber/web 1.0.4 → 1.0.5-rc.2
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/README.md +1 -1
- package/bin/cli.js +21 -2
- package/bin/cli.test.js +164 -4
- package/bin/lib/DOCUMENTATION.md +3 -3
- package/bin/lib/cli-args.js +96 -13
- package/bin/lib/commands-connect-url-tailscale.test.js +136 -0
- package/bin/lib/commands-connect-url.js +146 -39
- package/bin/lib/commands-connect-url.test.js +126 -0
- package/bin/lib/commands-serve.js +45 -2
- package/bin/lib/commands-status.js +28 -5
- package/bin/lib/commands-status.test.js +107 -0
- package/bin/lib/commands-tunnel.js +36 -10
- package/dist/assets/{DiagramView-BpG1c3Hi.js → DiagramView-BWG8peHt.js} +1 -1
- package/dist/assets/DiffView-C_uRNQMT.js +18 -0
- package/dist/assets/{FileSaveConflictDialog-DP7k9a-i.js → FileSaveConflictDialog-DlH8IWDL.js} +2 -2
- package/dist/assets/FilesView-RnF9JBPu.js +6 -0
- package/dist/assets/{GitHubDetailScaffold-UxLAMAOl.js → GitHubDetailScaffold-BTRvUnwh.js} +2 -2
- package/dist/assets/{GitHubLinkPicker-Bh9RO1yK.js → GitHubLinkPicker-CGi8p2zF.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-DQyhT5wG.js → GitHubListPrimitives-XckcmdeA.js} +1 -1
- package/dist/assets/{GitView-XBBheKRM.js → GitView-DyPJ8Oay.js} +4 -4
- package/dist/assets/{IssuesSurface-BA1kpvAJ.js → IssuesSurface-rQ78ziEu.js} +3 -3
- package/dist/assets/{JsonTreeView-BAaEPL4O.js → JsonTreeView-Cy5NKUzx.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DzgDmUsL.js → MarkdownRendererImpl-C5AlnAbG.js} +1 -1
- package/dist/assets/{PatchDiff-BMEUsgXH.js → PatchDiff-D6048My1.js} +1 -1
- package/dist/assets/PierreDiffViewer-_000TWrM.js +135 -0
- package/dist/assets/PullRequestsSurface-eACi4Yxm.js +2 -0
- package/dist/assets/SessionSwitcherContent-CFMjBIfH.js +1 -0
- package/dist/assets/SessionSwitcherDropdown-CINW_ydZ.js +2 -0
- package/dist/assets/SessionUnreadDot-YZJi4IFP.js +1 -0
- package/dist/assets/SettingsView-DBiQXIji.js +6 -0
- package/dist/assets/{SettingsWindow-j0e99YI0.js → SettingsWindow-Wvd56oG1.js} +1 -1
- package/dist/assets/StickyHorizontalScrollbar-BMITjK4e.js +8 -0
- package/dist/assets/{ToolOutputDialog-VlS12Xyq.js → ToolOutputDialog-DeDXQNWw.js} +4 -4
- package/dist/assets/{ToolPartDiffPreview-DdSneZws.js → ToolPartDiffPreview-DuN8fldE.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-BqiXjvP6.js → VirtualizedFileDiff-BYVjUxk9.js} +4 -4
- package/dist/assets/{Virtualizer-Cp_cJWbI.js → Virtualizer-DP6HbEeC.js} +1 -1
- package/dist/assets/{collapsible-C7oyikVm.js → collapsible-BOcd0lzY.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-BJjC-tXV.js → computeVirtualFileMetrics-E4gJTgVF.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-BBzqKGei.js → contextFileOpenGuard-CcGZtZsz.js} +1 -1
- package/dist/assets/{gitStatusPredicates-Dq-E5DaH.js → gitStatusPredicates-C2H7tf7t.js} +1 -1
- package/dist/assets/{githubLink-Cryd7GkG.js → githubLink-DTEEkgAl.js} +5 -5
- package/dist/assets/{index-BbhXFTId.js → index-BKc_DF05.js} +1 -1
- package/dist/assets/index-DWSrsQWl.js +11 -0
- package/dist/assets/index-DsQIBAWK.css +1 -0
- package/dist/assets/main-BNoO2jRw.js +136 -0
- package/dist/assets/main-DnCR4Jva.js +2 -0
- package/dist/assets/{markdownCore-B9AuEyYi.js → markdownCore-CP1hsIRw.js} +2 -2
- package/dist/assets/{miniChat-CgOaJfD8.js → miniChat-BBI_B4OS.js} +2 -2
- package/dist/assets/mobile-dRWyYBgl.js +2 -0
- package/dist/assets/{nativeFileSave-BzhtrDoD.js → nativeFileSave-CFuugNKV.js} +1 -1
- package/dist/assets/pi-session-focus-preference-Cw78V7mw.js +9 -0
- package/dist/assets/{renderDiffWithHighlighter-CVLsdtQ5.js → renderDiffWithHighlighter-kdzNWs8-.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-uVOQvccp.js +2 -0
- package/dist/assets/{renderFileWithHighlighter-DJ9mk2bZ.js → renderFileWithHighlighter-BdeYSXwS.js} +1 -1
- package/dist/assets/renderMobileApp-Cdg1IAhJ.js +11 -0
- package/dist/assets/runtimeEndpointReset-thviM404.js +62 -0
- package/dist/assets/{runtimeSurface-DBiUWYK2.js → runtimeSurface-Der4qUnI.js} +1 -1
- package/dist/assets/useAppFontEffects-Bd0btzjJ.js +212 -0
- package/dist/assets/{useFilesViewSearch-D2Au5Xgt.js → useFilesViewSearch-Yvk43YOy.js} +3 -3
- package/dist/assets/useGitHubRemoteSearch-BUjSEnXC.js +1 -0
- package/dist/assets/{useSwitcherItems-Dej8BzXI.js → useSwitcherItems-D2opwbRZ.js} +1 -1
- package/dist/assets/{vendor-aparajita-capacitor-secure-storage-BYohCVY0.js → vendor-aparajita-capacitor-secure-storage-BDrMx_CE.js} +1 -1
- package/dist/assets/{vendor-base-ui-BscvGUFt.js → vendor-base-ui-CKRUCG-f.js} +1 -1
- package/dist/assets/{vendor-boot-Dgb9NVFe.js → vendor-boot-EC6IyLt1.js} +13 -13
- package/dist/assets/{vendor-capacitor-app-BjdQVib9.js → vendor-capacitor-app-BaupizkW.js} +1 -1
- package/dist/assets/{vendor-capacitor-keyboard-eTtI5go3.js → vendor-capacitor-keyboard-9BVxykO7.js} +1 -1
- package/dist/assets/{vendor-capacitor-status-bar-9rNIGxlO.js → vendor-capacitor-status-bar-BsrUwiaA.js} +1 -1
- package/dist/assets/{vendor-codemirror-autocomplete-DxS3jwvE.js → vendor-codemirror-autocomplete-CGpAsPWp.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-DdjXl9e2.js → vendor-codemirror-lang-angular-CDJoHJSY.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp--aMr7NVt.js → vendor-codemirror-lang-cpp-BmHofQls.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-CZ_qxZY9.js → vendor-codemirror-lang-css-RM2HqXZ0.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-Ca-y2Alu.js → vendor-codemirror-lang-go-Crwca_X7.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-COZ0L5wT.js → vendor-codemirror-lang-html-CHSHUpwq.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-D3Rf3QNJ.js → vendor-codemirror-lang-java-lhQXgWu0.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-DwJ-IvCs.js → vendor-codemirror-lang-javascript-Dw4kFO4e.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-D_5lod6k.js → vendor-codemirror-lang-jinja-_pAC3UTN.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-BG8C7OpC.js → vendor-codemirror-lang-json-B-b1vAv-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-CVEkoaTw.js → vendor-codemirror-lang-less-xIgOi1ze.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-U9vj0m8w.js → vendor-codemirror-lang-liquid-CP49m5dB.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-DqlYH9gY.js → vendor-codemirror-lang-markdown-BTht2ATe.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-BFEiEVA1.js → vendor-codemirror-lang-php-BguZDhaO.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-Cz1dQXQd.js → vendor-codemirror-lang-python-CH6_em9L.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-C_CoD9mj.js → vendor-codemirror-lang-rust-EG_DtGyi.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-BuR0aKh5.js → vendor-codemirror-lang-sass-BknY5Qpo.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-DggNUjdM.js → vendor-codemirror-lang-sql-B0f-qCZo.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-DFZHi2J3.js → vendor-codemirror-lang-vue-CyGn9snv.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-zuTN3SHT.js → vendor-codemirror-lang-wast-CsFfSyyB.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-CrcvhI-k.js → vendor-codemirror-lang-xml-Cdan_Jp1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-DcVWsakb.js → vendor-codemirror-lang-yaml-COI5hck8.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-CCLITgCF.js → vendor-codemirror-language-data-CqU7kHmg.js} +2 -2
- package/dist/assets/{vendor-codemirror-search-H7NOEdbX.js → vendor-codemirror-search-DUfSCF9S.js} +1 -1
- package/dist/assets/{vendor-lezer-cpp-C8aD2KAr.js → vendor-lezer-cpp-DMZOJzBa.js} +1 -1
- package/dist/assets/{vendor-lezer-css-2lbTJF-Y.js → vendor-lezer-css-DUkkbMp7.js} +1 -1
- package/dist/assets/{vendor-lezer-go-Bw6LFTrZ.js → vendor-lezer-go-CHIhCNY6.js} +1 -1
- package/dist/assets/{vendor-lezer-html-D7ym2z7S.js → vendor-lezer-html-B3h0MOrG.js} +1 -1
- package/dist/assets/{vendor-lezer-java-CZhK7w21.js → vendor-lezer-java-tMazV_6X.js} +1 -1
- package/dist/assets/{vendor-lezer-javascript-rpKeTHZp.js → vendor-lezer-javascript-ctwLWf4v.js} +1 -1
- package/dist/assets/{vendor-lezer-json-C7jwsd2G.js → vendor-lezer-json-BP_UAzLL.js} +1 -1
- package/dist/assets/{vendor-lezer-lr-DR-ylqNN.js → vendor-lezer-lr-B8TQctNw.js} +1 -1
- package/dist/assets/{vendor-lezer-markdown-Bir0m5nB.js → vendor-lezer-markdown-aGLZf_3h.js} +1 -1
- package/dist/assets/{vendor-lezer-php-y0hIEfo1.js → vendor-lezer-php-D5zCNzlt.js} +1 -1
- package/dist/assets/{vendor-lezer-python-D64A9lNV.js → vendor-lezer-python-EJ4Im4y2.js} +1 -1
- package/dist/assets/{vendor-lezer-rust-E3ZA9T2L.js → vendor-lezer-rust-DO5c7OtA.js} +1 -1
- package/dist/assets/{vendor-lezer-sass-C5UFI9SP.js → vendor-lezer-sass-CMi6zfXI.js} +1 -1
- package/dist/assets/{vendor-lezer-xml-DOy7FzCR.js → vendor-lezer-xml-0MHMeZDp.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-kEjaSCvZ.js → vendor-lezer-yaml-BE2EFjpA.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-BLfh0LPy.js → vendor-replit-codemirror-vim-AnOuN8yJ.js} +1 -1
- package/dist/assets/{web-components-C7CmoFxi.js → web-components-BeROQeen.js} +3 -3
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/dist/sw.js +1 -1
- package/package.json +1 -2
- package/server/index.js +72 -30
- package/server/lib/client-auth/DOCUMENTATION.md +15 -1
- package/server/lib/client-auth/pairing.js +2 -12
- package/server/lib/client-auth/remote-clients.js +2 -12
- package/server/lib/cloudflare-tunnel.js +0 -132
- package/server/lib/fs/DOCUMENTATION.md +8 -0
- package/server/lib/fs/atomic-write.js +111 -0
- package/server/lib/fs/atomic-write.test.js +133 -0
- package/server/lib/notifications/DOCUMENTATION.md +43 -32
- package/server/lib/notifications/pi-notification-watcher.js +8 -7
- package/server/lib/notifications/pi-notification-watcher.test.js +88 -2
- package/server/lib/pi/routes-extension-events.test.js +231 -0
- package/server/lib/pi/routes.js +137 -4
- package/server/lib/pi/routes.test.js +248 -2
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +17 -4
- package/server/lib/pi/session-daemon/daemon-process.js +2 -0
- package/server/lib/pi/session-daemon/engines/index.js +6 -0
- package/server/lib/pi/session-daemon/extension-bridge-draft.test.js +1 -1
- package/server/lib/pi/session-daemon/extension-bridge.js +24 -0
- package/server/lib/pi/session-daemon/extension-message-render.js +74 -0
- package/server/lib/pi/session-daemon/extension-message-render.test.js +164 -0
- package/server/lib/pi/session-daemon/extension-tool-render.js +13 -6
- package/server/lib/pi/session-daemon/pending-input.js +188 -0
- package/server/lib/pi/session-daemon/pending-input.test.js +202 -0
- package/server/lib/pi/session-daemon/session-daemon-engines.test.js +828 -0
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +296 -6
- package/server/lib/pi/session-daemon/session-daemon-turn.e2e.test.js +9 -0
- package/server/lib/pi/session-daemon/session-daemon.js +219 -19
- package/server/lib/pi/session-daemon/session-daemon.test.js +30 -2
- package/server/lib/pi/session-daemon/session-engine-router.js +390 -0
- package/server/lib/pi/session-daemon/session-engine-router.test.js +515 -0
- package/server/lib/pi/session-daemon/session-engines.js +467 -0
- package/server/lib/pi/session-daemon/session-engines.test.js +383 -0
- package/server/lib/pi/snippets-store.js +8 -17
- package/server/lib/pi/ui-settings-store.js +6 -10
- package/server/lib/pi/ui-settings-store.test.js +37 -1
- package/server/lib/relay/DOCUMENTATION.md +6 -4
- package/server/lib/relay/identity-store.js +116 -0
- package/server/lib/relay/identity-store.test.js +169 -0
- package/server/lib/relay/identity.js +6 -4
- package/server/lib/relay/server-id.js +63 -0
- package/server/lib/relay/server-id.test.js +132 -0
- package/server/lib/relay/signing-key.js +14 -11
- package/server/lib/security/bind-host.js +6 -2
- package/server/lib/security/bind-host.test.js +17 -0
- package/server/lib/server/core-routes.js +27 -1
- package/server/lib/server/lan-addresses.js +18 -6
- package/server/lib/server/lan-addresses.test.js +28 -0
- package/server/lib/server/tunnel-auth.js +47 -7
- package/server/lib/server/tunnel-auth.rate-limit.test.js +164 -0
- package/server/lib/server/tunnel-service.DOCUMENTATION.md +3 -4
- package/server/lib/server/tunnel-service.js +23 -20
- package/server/lib/server/tunnel-service.test.js +19 -2
- package/server/lib/stt/config-store.js +5 -15
- package/server/lib/tailscale/DOCUMENTATION.md +285 -0
- package/server/lib/tailscale/nc-probe.js +220 -0
- package/server/lib/tailscale/routes.js +45 -0
- package/server/lib/tailscale/service.js +1012 -0
- package/server/lib/tailscale/tailscale.js +302 -0
- package/server/lib/tailscale/tailscale.test.js +2080 -0
- package/server/lib/tunnels/DOCUMENTATION.md +3 -4
- package/server/lib/tunnels/providers/cloudflare.js +1 -22
- package/server/lib/tunnels/types.js +0 -2
- package/server/lib/ui-auth/DOCUMENTATION.md +31 -0
- package/server/lib/ui-auth/ui-auth.js +80 -6
- package/server/lib/ui-auth/ui-auth.test.js +136 -0
- package/server/lib/ui-auth/ui-passkeys.js +2 -13
- package/server/lib/update-job-store.js +4 -6
- package/dist/assets/DiffView-BxwoRCYx.js +0 -18
- package/dist/assets/FilesView-D_2QcdUt.js +0 -6
- package/dist/assets/PierreDiffViewer-BW8MO-O6.js +0 -134
- package/dist/assets/PullRequestsSurface-B3ictm4I.js +0 -2
- package/dist/assets/SessionSwitcherContent-rLoyVqgs.js +0 -1
- package/dist/assets/SessionSwitcherDropdown-CfySKnUu.js +0 -2
- package/dist/assets/SessionUnreadDot-CmEF9sxM.js +0 -1
- package/dist/assets/SettingsView-BiwlwnTK.js +0 -6
- package/dist/assets/index-BnZVqcki.js +0 -11
- package/dist/assets/index-BnieExes.css +0 -1
- package/dist/assets/main-9O5IAtT_.js +0 -136
- package/dist/assets/main-DWGwALIw.js +0 -2
- package/dist/assets/mobile-BbJcYVym.js +0 -2
- package/dist/assets/pi-session-focus-preference-Bmk1iOvn.js +0 -10
- package/dist/assets/renderElectronMiniChatApp-R5o9NwFC.js +0 -2
- package/dist/assets/renderMobileApp-CQ9tWYIj.js +0 -11
- package/dist/assets/runtimeEndpointReset-CtK4C_5h.js +0 -62
- package/dist/assets/useAppFontEffects-DviRbaCJ.js +0 -212
- package/dist/assets/useGitHubRemoteSearch-D-K7aolk.js +0 -1
- package/dist/assets/vendor-capacitor-push-notifications-CBKq2Arn.js +0 -1
- package/server/lib/notifications/delivery-runtime.js +0 -314
- package/server/lib/notifications/delivery-runtime.test.js +0 -85
- package/server/lib/notifications/routes.js +0 -74
- package/server/lib/relay/service.js +0 -9
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readInstanceOptions } from './cli-process.js';
|
|
2
2
|
import { discoverLifecycleInstances, discoverDesktopInstance } from './cli-lifecycle.js';
|
|
3
|
+
import { requestJson } from './cli-http.js';
|
|
3
4
|
import {
|
|
4
5
|
intro as clackIntro,
|
|
5
6
|
outro as clackOutro,
|
|
@@ -33,21 +34,37 @@ async function statusCommand(options = {}) {
|
|
|
33
34
|
}
|
|
34
35
|
: null;
|
|
35
36
|
|
|
36
|
-
const cliInstances = runningInstances
|
|
37
|
+
const cliInstances = await Promise.all(runningInstances
|
|
37
38
|
.filter((instance) => instance.runtime !== 'desktop')
|
|
38
|
-
.map((instance) => {
|
|
39
|
+
.map(async (instance) => {
|
|
39
40
|
const storedOptions = instance.instanceFilePath ? (readInstanceOptions(instance.instanceFilePath) || {}) : {};
|
|
40
41
|
const passwordProtected = storedOptions.hasUiPassword === true
|
|
41
42
|
|| (typeof storedOptions.uiPassword === 'string' && storedOptions.uiPassword.trim().length > 0);
|
|
42
43
|
|
|
44
|
+
// Best-effort Tailscale state per instance: a failure (older server,
|
|
45
|
+
// unreachable) reports unknown rather than failing the whole status.
|
|
46
|
+
let tailscale = null;
|
|
47
|
+
try {
|
|
48
|
+
const { response, body } = await requestJson(instance.port, '/api/pichamber/tailscale/status', { timeoutMs: 1500 });
|
|
49
|
+
if (response.ok && body && typeof body.state === 'string') {
|
|
50
|
+
tailscale = {
|
|
51
|
+
state: body.state,
|
|
52
|
+
...(typeof body.url === 'string' ? { url: body.url } : {}),
|
|
53
|
+
...(body.config && typeof body.config.mode === 'string' ? { mode: body.config.mode } : {}),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
|
|
43
59
|
return {
|
|
44
60
|
runtime: instance.source === 'probe' ? 'unmanaged' : 'cli',
|
|
45
61
|
port: instance.port,
|
|
46
62
|
pid: instance.pid,
|
|
47
63
|
launchMode: instance.launchMode || 'daemon',
|
|
48
64
|
passwordProtected: instance.source === 'probe' ? null : passwordProtected,
|
|
65
|
+
...(tailscale ? { tailscale } : {}),
|
|
49
66
|
};
|
|
50
|
-
});
|
|
67
|
+
}));
|
|
51
68
|
|
|
52
69
|
const explicitDesktop = options.explicitPort
|
|
53
70
|
? runningInstances.find((entry) => entry.runtime === 'desktop')
|
|
@@ -81,8 +98,11 @@ async function statusCommand(options = {}) {
|
|
|
81
98
|
}
|
|
82
99
|
|
|
83
100
|
for (const instance of instances) {
|
|
101
|
+
const tailscaleSuffix = instance.tailscale?.state && instance.tailscale.state !== 'off'
|
|
102
|
+
? ` tailscale:${instance.tailscale.state}${instance.tailscale.url ? ` tailscale-url:${instance.tailscale.url}` : ''}`
|
|
103
|
+
: '';
|
|
84
104
|
process.stdout.write(
|
|
85
|
-
`port ${instance.port} mode:${instance.launchMode || 'n/a'} pass:${toPasswordProtectionLabel(instance.passwordProtected)}\n`
|
|
105
|
+
`port ${instance.port} mode:${instance.launchMode || 'n/a'} pass:${toPasswordProtectionLabel(instance.passwordProtected)}${tailscaleSuffix}\n`
|
|
86
106
|
);
|
|
87
107
|
}
|
|
88
108
|
return;
|
|
@@ -100,7 +120,10 @@ async function statusCommand(options = {}) {
|
|
|
100
120
|
const pidSuffix = Number.isFinite(instance.pid) ? ` (PID: ${instance.pid})` : '';
|
|
101
121
|
const modeDetail = instance.launchMode ? `mode: ${instance.launchMode}` : '';
|
|
102
122
|
const protectionDetail = `password: ${toPasswordProtectionLabel(instance.passwordProtected)}`;
|
|
103
|
-
const
|
|
123
|
+
const tailscaleDetail = instance.tailscale?.state && instance.tailscale.state !== 'off'
|
|
124
|
+
? `tailscale: ${instance.tailscale.state}${instance.tailscale.url ? ` (${instance.tailscale.url})` : ''}`
|
|
125
|
+
: '';
|
|
126
|
+
const detail = [modeDetail, protectionDetail, tailscaleDetail].filter(Boolean).join('; ');
|
|
104
127
|
if (instance.runtime === 'desktop') {
|
|
105
128
|
logStatus('info', `desktop app on port ${instance.port}${pidSuffix}`, detail);
|
|
106
129
|
} else {
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
vi.mock('./cli-lifecycle.js', () => ({
|
|
4
|
+
discoverLifecycleInstances: vi.fn(),
|
|
5
|
+
discoverDesktopInstance: vi.fn(),
|
|
6
|
+
}));
|
|
7
|
+
|
|
8
|
+
vi.mock('./cli-http.js', () => ({
|
|
9
|
+
requestJson: vi.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
vi.mock('./cli-process.js', () => ({
|
|
13
|
+
readInstanceOptions: vi.fn(),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
import { discoverDesktopInstance, discoverLifecycleInstances } from './cli-lifecycle.js';
|
|
17
|
+
import { requestJson } from './cli-http.js';
|
|
18
|
+
import { readInstanceOptions } from './cli-process.js';
|
|
19
|
+
import { statusCommand } from './commands-status.js';
|
|
20
|
+
|
|
21
|
+
async function captureOutput(fn) {
|
|
22
|
+
const originalStdoutWrite = process.stdout.write;
|
|
23
|
+
const originalStderrWrite = process.stderr.write;
|
|
24
|
+
let stdout = '';
|
|
25
|
+
let stderr = '';
|
|
26
|
+
const capture = (target) => (chunk, encoding, callback) => {
|
|
27
|
+
target.value += Buffer.isBuffer(chunk) ? chunk.toString('utf8') : String(chunk);
|
|
28
|
+
if (typeof encoding === 'function') encoding();
|
|
29
|
+
if (typeof callback === 'function') callback();
|
|
30
|
+
return true;
|
|
31
|
+
};
|
|
32
|
+
const stdoutTarget = { value: '' };
|
|
33
|
+
const stderrTarget = { value: '' };
|
|
34
|
+
process.stdout.write = capture(stdoutTarget);
|
|
35
|
+
process.stderr.write = capture(stderrTarget);
|
|
36
|
+
try {
|
|
37
|
+
await fn();
|
|
38
|
+
stdout = stdoutTarget.value;
|
|
39
|
+
stderr = stderrTarget.value;
|
|
40
|
+
return { stdout, stderr };
|
|
41
|
+
} finally {
|
|
42
|
+
process.stdout.write = originalStdoutWrite;
|
|
43
|
+
process.stderr.write = originalStderrWrite;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function stubInstance() {
|
|
48
|
+
vi.mocked(discoverLifecycleInstances).mockResolvedValue([
|
|
49
|
+
{
|
|
50
|
+
port: 3000,
|
|
51
|
+
pid: 1234,
|
|
52
|
+
pidFilePath: '/tmp/pichamber-3000.pid',
|
|
53
|
+
instanceFilePath: '/tmp/pichamber-3000.json',
|
|
54
|
+
launchMode: 'daemon',
|
|
55
|
+
runtime: 'web',
|
|
56
|
+
source: 'registry',
|
|
57
|
+
},
|
|
58
|
+
]);
|
|
59
|
+
vi.mocked(discoverDesktopInstance).mockResolvedValue(null);
|
|
60
|
+
vi.mocked(readInstanceOptions).mockReturnValue({});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
describe('status quiet tailscale tokens', () => {
|
|
64
|
+
beforeEach(() => {
|
|
65
|
+
vi.resetAllMocks();
|
|
66
|
+
stubInstance();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('emits tailscale state and url as separate whitespace-delimited tokens', async () => {
|
|
70
|
+
vi.mocked(requestJson).mockResolvedValue({
|
|
71
|
+
response: { ok: true },
|
|
72
|
+
body: { state: 'active', url: 'https://host.ts.net:8443', config: { mode: 'private' } },
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const { stdout } = await captureOutput(() => statusCommand({ explicitPort: true, port: 3000, quiet: true }));
|
|
76
|
+
|
|
77
|
+
expect(stdout).toContain('port 3000 mode:daemon pass:no tailscale:active tailscale-url:https://host.ts.net:8443');
|
|
78
|
+
expect(stdout).not.toContain('tailscale:active:https://');
|
|
79
|
+
const tokens = stdout.trim().split('\n')[0].split(/\s+/);
|
|
80
|
+
expect(tokens).toContain('tailscale:active');
|
|
81
|
+
expect(tokens).toContain('tailscale-url:https://host.ts.net:8443');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('emits only the state token when no tailscale url exists', async () => {
|
|
85
|
+
vi.mocked(requestJson).mockResolvedValue({
|
|
86
|
+
response: { ok: true },
|
|
87
|
+
body: { state: 'active' },
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const { stdout } = await captureOutput(() => statusCommand({ explicitPort: true, port: 3000, quiet: true }));
|
|
91
|
+
|
|
92
|
+
const tokens = stdout.trim().split('\n')[0].split(/\s+/);
|
|
93
|
+
expect(tokens).toContain('tailscale:active');
|
|
94
|
+
expect(tokens.some((token) => token.startsWith('tailscale-url:'))).toBe(false);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('omits tailscale tokens when tailscale is off', async () => {
|
|
98
|
+
vi.mocked(requestJson).mockResolvedValue({
|
|
99
|
+
response: { ok: true },
|
|
100
|
+
body: { state: 'off' },
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const { stdout } = await captureOutput(() => statusCommand({ explicitPort: true, port: 3000, quiet: true }));
|
|
104
|
+
|
|
105
|
+
expect(stdout.trim()).toBe('port 3000 mode:daemon pass:no');
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -92,6 +92,21 @@ async function displayTunnelQrCode(url) {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
const QUICK_TUNNEL_REMOVED_MESSAGE = 'Quick tunnels were removed because their URL changed on every restart. Use `pichamber pair --tailscale [--public]` or `pichamber tunnel start --mode managed-remote --token-file <path> --hostname <host>`.';
|
|
96
|
+
const TUNNEL_MODE_REQUIRED_MESSAGE = 'A tunnel mode is required: --mode managed-remote or --mode managed-local. Quick tunnels were removed; use `pichamber pair --tailscale [--public]` or `pichamber tunnel profile add --mode managed-remote --name <name> --hostname <host> --token-file <path>`.';
|
|
97
|
+
|
|
98
|
+
function throwQuickTunnelRemoved() {
|
|
99
|
+
const error = new TunnelCliError(QUICK_TUNNEL_REMOVED_MESSAGE, EXIT_CODE.USAGE_ERROR);
|
|
100
|
+
error.code = 'quick_tunnel_removed';
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function throwTunnelModeRequired() {
|
|
105
|
+
const error = new TunnelCliError(TUNNEL_MODE_REQUIRED_MESSAGE, EXIT_CODE.USAGE_ERROR);
|
|
106
|
+
error.code = 'tunnel_mode_required';
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
|
|
95
110
|
function isTruthyEnv(value) {
|
|
96
111
|
if (typeof value !== 'string') return false;
|
|
97
112
|
const normalized = value.trim().toLowerCase();
|
|
@@ -1045,7 +1060,7 @@ async function tunnelCommand(options, subcommand, action, deps) {
|
|
|
1045
1060
|
console.log('');
|
|
1046
1061
|
|
|
1047
1062
|
// ── Section 3: Modes ────────────────────────────────────
|
|
1048
|
-
const DOCTOR_NOISE_CHECK_IDS = new Set(['startup_readiness'
|
|
1063
|
+
const DOCTOR_NOISE_CHECK_IDS = new Set(['startup_readiness']);
|
|
1049
1064
|
const modes = doctorResult.modes || [];
|
|
1050
1065
|
if (modes.length === 0) {
|
|
1051
1066
|
return;
|
|
@@ -1170,15 +1185,18 @@ async function tunnelCommand(options, subcommand, action, deps) {
|
|
|
1170
1185
|
hostname = typeof options.hostname === 'string' && options.hostname.trim().length > 0 ? options.hostname : selectedProfile.hostname;
|
|
1171
1186
|
}
|
|
1172
1187
|
|
|
1173
|
-
// Interactive profile selection when no profile/mode specified in TTY
|
|
1188
|
+
// Interactive profile selection when no profile/mode specified in TTY.
|
|
1189
|
+
// Stored quick profiles from older versions can no longer start, so
|
|
1190
|
+
// they are hidden here instead of failing after selection.
|
|
1174
1191
|
if (!selectedProfile && !mode && canPrompt(options)) {
|
|
1175
1192
|
const store = ensureTunnelProfilesMigrated();
|
|
1176
|
-
|
|
1193
|
+
const startableProfiles = store.profiles.filter((entry) => entry.mode !== 'quick');
|
|
1194
|
+
if (startableProfiles.length > 0) {
|
|
1177
1195
|
const profileChoice = await clackSelect({
|
|
1178
1196
|
message: 'Start from a saved profile or choose a mode?',
|
|
1179
1197
|
options: [
|
|
1180
1198
|
{ value: '__mode__', label: 'Choose a mode manually' },
|
|
1181
|
-
...
|
|
1199
|
+
...startableProfiles.map((p) => ({
|
|
1182
1200
|
value: p.id,
|
|
1183
1201
|
label: `${p.name} (${p.provider}/${p.mode})`,
|
|
1184
1202
|
hint: p.hostname,
|
|
@@ -1190,7 +1208,7 @@ async function tunnelCommand(options, subcommand, action, deps) {
|
|
|
1190
1208
|
return;
|
|
1191
1209
|
}
|
|
1192
1210
|
if (profileChoice !== '__mode__') {
|
|
1193
|
-
selectedProfile =
|
|
1211
|
+
selectedProfile = startableProfiles.find((p) => p.id === profileChoice);
|
|
1194
1212
|
if (selectedProfile) {
|
|
1195
1213
|
provider = provider || selectedProfile.provider;
|
|
1196
1214
|
mode = mode || selectedProfile.mode;
|
|
@@ -1203,6 +1221,12 @@ async function tunnelCommand(options, subcommand, action, deps) {
|
|
|
1203
1221
|
|
|
1204
1222
|
provider = provider || 'cloudflare';
|
|
1205
1223
|
|
|
1224
|
+
// Quick tunnels were removed: fail fast in every mode (interactive,
|
|
1225
|
+
// quiet, json, non-TTY) before prompting for anything else.
|
|
1226
|
+
if (mode === 'quick') {
|
|
1227
|
+
throwQuickTunnelRemoved();
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1206
1230
|
// Interactive mode selection when mode not yet resolved in TTY
|
|
1207
1231
|
if (!mode && canPrompt(options)) {
|
|
1208
1232
|
const providerCaps = DEFAULT_TUNNEL_PROVIDER_CAPABILITIES.find(
|
|
@@ -1226,7 +1250,9 @@ async function tunnelCommand(options, subcommand, action, deps) {
|
|
|
1226
1250
|
}
|
|
1227
1251
|
}
|
|
1228
1252
|
|
|
1229
|
-
|
|
1253
|
+
if (!mode) {
|
|
1254
|
+
throwTunnelModeRequired();
|
|
1255
|
+
}
|
|
1230
1256
|
if (mode === 'managed-remote') {
|
|
1231
1257
|
if (!(typeof hostname === 'string' && hostname.trim().length > 0)) {
|
|
1232
1258
|
if (canPrompt(options)) {
|
|
@@ -1441,7 +1467,7 @@ async function tunnelCommand(options, subcommand, action, deps) {
|
|
|
1441
1467
|
printJson(dryRunResult);
|
|
1442
1468
|
} else if (!isQuietMode(options)) {
|
|
1443
1469
|
clackIntro('Tunnel Start (dry-run)');
|
|
1444
|
-
logStatus('info', `Would start ${clackFormatProviderWithIcon(provider)}/${mode}`, hostname || '(
|
|
1470
|
+
logStatus('info', `Would start ${clackFormatProviderWithIcon(provider)}/${mode}`, hostname || '(hostname from config)');
|
|
1445
1471
|
clackOutro('dry-run complete (no changes applied)');
|
|
1446
1472
|
}
|
|
1447
1473
|
return;
|
|
@@ -1496,7 +1522,7 @@ async function tunnelCommand(options, subcommand, action, deps) {
|
|
|
1496
1522
|
`Provider: ${provider}`,
|
|
1497
1523
|
`Mode: ${mode}`,
|
|
1498
1524
|
`Target: ${options.explicitPort ? `port ${options.port}` : 'running or auto-started server'}`,
|
|
1499
|
-
`Hostname: ${hostname || '
|
|
1525
|
+
`Hostname: ${hostname || 'n/a (managed-local uses its config file)'}`,
|
|
1500
1526
|
`Profile: ${selectedProfile?.name || 'none'}`,
|
|
1501
1527
|
].join('\n'));
|
|
1502
1528
|
const approved = await clackConfirm({
|
|
@@ -1621,9 +1647,9 @@ async function tunnelCommand(options, subcommand, action, deps) {
|
|
|
1621
1647
|
if (!response.ok || !body?.ok) {
|
|
1622
1648
|
spin?.error('Tunnel start failed');
|
|
1623
1649
|
const baseError = body?.error || `Tunnel start failed (${response.status})`;
|
|
1624
|
-
const isCloudflareTimeout = /context deadline exceeded|Client\.Timeout exceeded while awaiting headers|failed to request
|
|
1650
|
+
const isCloudflareTimeout = /context deadline exceeded|Client\.Timeout exceeded while awaiting headers|failed to request Tunnel/i.test(baseError);
|
|
1625
1651
|
const userError = isCloudflareTimeout
|
|
1626
|
-
? `Cloudflare
|
|
1652
|
+
? `Cloudflare tunnel request timed out. ${baseError}`
|
|
1627
1653
|
: baseError;
|
|
1628
1654
|
throw new Error(`${userError} Run \`pichamber logs -p ${instance.port}\` for details.`);
|
|
1629
1655
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as c}from"./vendor-boot-
|
|
1
|
+
import{k as c}from"./vendor-boot-EC6IyLt1.js";import{R as t}from"./vendor-react-DASdDPIk.js";import{z as $,t as d,I as B}from"./useAppFontEffects-Bd0btzjJ.js";import{f as W,a as A,m as ee,bW as T}from"./index-DWSrsQWl.js";import{b as te,D as re,F as ne}from"./FileSaveConflictDialog-DlH8IWDL.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-Der4qUnI.js";import"./nativeFileSave-CFuugNKV.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-react-drawio-Duu5LgQA.js";const se=l=>l.split("/").pop()||l;function xe(){const{files:l}=$(),[x,k]=t.useState(null),[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),G=W(e=>e.pendingDiagramFile);t.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const i=t.useCallback((e,n,s)=>I.current&&v.current===e&&A()===n&&w.current===s,[]),z=t.useCallback(async e=>{const n=v.current+1;v.current=n;const s=A(),u=l?.readFile;S.current+=1,y.current+=1,E(!0),k(e),w.current=e,h(null),p(!1),P(!1),F(!1);try{const r=await u?.(e);if(!i(n,s,e))return;if(!r){d.error("Failed to read file"),k(null),w.current=null,C.current="",R(""),g.current=void 0,E(!1);return}C.current=r.content,R(r.content),g.current=r.revision}catch(r){if(!i(n,s,e))return;d.error(r instanceof Error?r.message:"Failed to read file"),k(null),w.current=null,C.current="",R(""),g.current=void 0,E(!1);return}finally{i(n,s,e)&&E(!1)}},[l,i]);t.useEffect(()=>ee(()=>{if(v.current+=1,g.current=void 0,S.current+=1,y.current+=1,!I.current)return;h(null),p(!1),P(!1),F(!1);const e=w.current;e&&z(e)}),[z]),t.useEffect(()=>{if(!G)return;const e=W.getState().consumePendingDiagramFile();e&&z(e)},[z,G]);const K=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=A(),u=x,r=e,o=S.current+1;S.current=o,P(!0);try{const a=await X(u,r,!1,n,s);if(a.stale)return;if(!a.success){d.error("Failed to write file");return}O(r,a.revision)}catch(a){if(!i(n,s,u))return;if(T(a)){await K(u,r,a.currentRevision??null,a.exists,n,s);return}d.error(a instanceof Error?a.message:"Save failed")}finally{S.current===o&&P(!1)}},[O,x,l,i,m,j,K,X]),Q=t.useCallback(async()=>{const e=b;if(!e||m||!i(v.current,e.runtimeKey,e.path))return;const n=v.current,s=e.runtimeKey;if(!e.exists){k(null),w.current=null,C.current="",R(""),g.current=void 0,h(null),p(!1);return}const u=y.current+1;y.current=u,F(!0);try{const r=await l?.readFile?.(e.path);if(!i(n,s,e.path))return;if(!r){d.error("Failed to read file");return}C.current=r.content??"",R(r.content??""),g.current=r.revision,H(o=>o+1),h(null),p(!1)}catch(r){if(!i(n,s,e.path))return;d.error(r instanceof Error?r.message:"Failed to read file")}finally{y.current===u&&F(!1)}},[l,i,m,b]),Y=t.useCallback(async()=>{const e=b;if(!e||m||!i(v.current,e.runtimeKey,e.path))return;const n=v.current,s=e.runtimeKey;if(!l?.writeFile){d.error("Saving not supported");return}const o=D.current?.getXml()??e.dirtyContent;if(!o){d.error("Failed to write file");return}const a=y.current+1;y.current=a,F(!0);try{const f=await X(e.path,o,!0,n,s);if(f.stale)return;if(!f.success){d.error("Failed to write file");return}O(o,f.revision),h(null),p(!1)}catch(f){if(!i(n,s,e.path))return;if(T(f)){await K(e.path,o,f.currentRevision??e.currentRevision,f.exists,n,s);return}d.error(f instanceof Error?f.message:"Save failed")}finally{y.current===a&&F(!1)}},[O,l,i,m,K,X,b]),Z=t.useCallback(()=>{m||j||(h(null),p(!1))},[m,j]),_=x?x.split("/").pop()||x:"";return x?M?c.jsx("div",{className:"flex h-full items-center justify-center p-3",children:c.jsx(B,{name:"loader-4",className:"size-4 animate-spin"})}):c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[c.jsx(B,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:_}),c.jsx("button",{type:"button",onClick:()=>{J()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Save diagram",children:c.jsx(B,{name:"save-3",className:"size-4"})}),c.jsx("button",{type:"button",onClick:()=>W.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};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{k as t,aL as St}from"./vendor-boot-EC6IyLt1.js";import{R as r}from"./vendor-react-DASdDPIk.js";import{e as re,f as Y,a as et,p as Oe}from"./index-DWSrsQWl.js";import{e6 as Nt,dQ as Ct,e4 as Lt,at as tt,ah as nt,cx as Dt,cy as ke,B as Se,I as z,z as st,aN as ce,t as it,dY as rt,ai as kt,al as Rt,an as Et,ap as Ge,cr as At,e7 as Tt,e8 as Mt,y as It,ae as Pt,aI as $t,ar as Wt,cS as _t,h as Bt,aD as zt,aW as Ot,aj as Gt,ak as Ht,am as Ut}from"./useAppFontEffects-Bd0btzjJ.js";import{d as ot,i as He,a as Ue,b as Vt,C as Kt}from"./gitStatusPredicates-C2H7tf7t.js";import{p as qt}from"./VirtualizedFileDiff-BYVjUxk9.js";import{P as Xt}from"./PierreDiffViewer-_000TWrM.js";import{v as Yt,g as Qt}from"./contextFileOpenGuard-CcGZtZsz.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./runtimeSurface-Der4qUnI.js";import"./nativeFileSave-CFuugNKV.js";import"./web-components-BeROQeen.js";import"./computeVirtualFileMetrics-E4gJTgVF.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./renderDiffWithHighlighter-kdzNWs8-.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-BMITjK4e.js";import"./runtimeEndpointReset-thviM404.js";import"./SessionUnreadDot-YZJi4IFP.js";/* empty css */import"./permissionStore-B9Hkrqny.js";import"./appThemeRegistry-gegrE2dq.js";import"./registerCustomTheme-DmolaWWZ.js";function Jt(n,s=10){const e=[];let i;for(const l of n.split(`
|
|
2
|
+
`)){const p=l.match(Nt);if(p!=null){i!=null&&(i.hunkLines.length>0&&(Ee(i,s,"trailing"),Ie(i,e)),i=void 0);const d=parseInt(p[3]),b=parseInt(p[1]),g=parseInt(p[4]??"1"),c=parseInt(p[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>s*2){const d=i.contextLines.length-s*2,b=i.contextLines.slice(-s);Ee(i,s,"trailing");const{additionCount:g,deletionCount:c}=i;Ie(i,e),i={additionStart:i.additionStart+g+d,deletionStart:i.deletionStart+c+d,deletionCount:0,additionCount:0,contextLines:b,hunkLines:[]}}Ee(i,s,i.hunkLines.length===0?"leading":"before-change"),i.hunkLines.push(l),l.startsWith("+")?i.additionCount+=1:l.startsWith("-")&&(i.deletionCount+=1)}}i!=null&&i.hunkLines.length>0&&(Ee(i,s,"trailing"),Ie(i,e));const a=e.join(`
|
|
3
|
+
`);return n.endsWith(`
|
|
4
|
+
`)?`${a}
|
|
5
|
+
`:a}function Ee(n,s,e){if(e==="leading"&&n.contextLines.length>s){const i=n.contextLines.length-s;n.contextLines.splice(0,i),n.additionStart+=i,n.deletionStart+=i}return e==="trailing"&&n.contextLines.length>s&&(n.contextLines.length=s),n.contextLines.length>0&&(n.hunkLines.push(...n.contextLines),n.additionCount+=n.contextLines.length,n.deletionCount+=n.contextLines.length,n.contextLines.length=0),n}function Ie(n,s){s.push(`@@ -${Ve(n.deletionStart,n.deletionCount)} +${Ve(n.additionStart,n.additionCount)} @@`),s.push(...n.hunkLines)}function Ve(n,s){return s===1?`${n}`:`${n},${s}`}const Zt=64,en=3,he=new Map,tn=(n,s,e=en)=>{const i=`${n}\0${e}\0${s}`,a=he.get(i);if(a)return he.delete(i),he.set(i,a),a;const l=sn(s),p=l?Ct(Jt(s,e),{oldFile:{name:n,contents:l.before},newFile:{name:n,contents:l.after}})??qe(n):Lt(nn(n,s))[0]?.files[0]??qe(n);for(he.set(i,p);he.size>Zt;){const d=he.keys().next().value;if(!d)break;he.delete(d)}return p},nn=(n,s)=>!s.trim()||s.startsWith("diff --git ")||/^--- [^\n]*\r?\n\+\+\+ /m.test(s)?s:`Index: ${n}
|
|
6
|
+
===================================================================
|
|
7
|
+
--- ${n}
|
|
8
|
+
+++ ${n}
|
|
9
|
+
${s}`,sn=n=>{if(!n.startsWith("diff --git ")&&!/^--- [^\n]*\t?\r?\n\+\+\+ [^\n]*\t?(?:\r?\n|$)/m.test(n))return;const s=[...n.matchAll(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@[^\n]*(?:\r?\n|$)/gm)];if(s.length!==1)return;const e=s[0],i=Number.parseInt(e[1]??"",10),a=Number.parseInt(e[2]??"",10);if(i>1||a>1||!Number.isFinite(i)||!Number.isFinite(a))return;const l=(e.index??0)+e[0].length,p=n.slice(l),d=[],b=[];let g;for(const c of p.split(/\r?\n/)){if(c.startsWith("diff --git ")||c.startsWith("@@ "))break;if(c.startsWith("\\")){if(g==="-"||g===" "){const h=d.at(-1);h&&(h.newline=!1)}if(g==="+"||g===" "){const h=b.at(-1);h&&(h.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:Ke(d),after:Ke(b)}},Ke=n=>n.map(s=>s.text+(s.newline?`
|
|
10
|
+
`:"")).join(""),qe=n=>qt({name:n,contents:""},{name:n,contents:""}),rn=n=>/^Binary files .+ differ$/m.test(n)||/^GIT binary patch$/m.test(n),$e=(n,s,e)=>rn(s)?{original:"",modified:"",isBinary:!0,patch:s,contextMode:e}:{original:"",modified:"",patch:s,fileDiff:tn(n,s),contextMode:e},at=(n,s,e)=>{const i=n??0,a=s??0;return!i&&!a?null:t.jsxs("span",{className:re("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,a?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",a]}):null]})},on=r.memo(function({changedFiles:s,selectedFile:e,onSelectFile:i}){return s.length===0?null:t.jsx(tt,{outerClassName:"flex-1 min-h-0",className:"px-1 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:s.map(a=>{const l=ot(a),p=e===a.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>i(a.path),className:re("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",p?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(nt,{filePath:a.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:a.path,children:a.path}),at(a.insertions,a.deletions)]})},a.path)})})})}),an=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."})})}),ln=r.memo(function({filePath:s,diff:e,renderSideBySide:i}){const a=e.original.length>0,l=e.modified.length>0,p=i?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",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:p,children:[a&&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: ${s}`,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:a?"Modified":"New"}),t.jsx("img",{src:e.modified,alt:`Modified: ${s}`,className:i?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]})]})})}),cn=r.memo(function({filePath:s,diff:e,renderSideBySide:i,wrapLines:a}){const l=r.useMemo(()=>Dt(s)||"text",[s]);return e.isBinary?t.jsx(an,{}):ke(s)?t.jsx(ln,{filePath:s,diff:e,renderSideBySide:i}):t.jsx("div",{className:"w-full",style:{contain:"layout"},children:t.jsx(Xt,{original:e.original,modified:e.modified,fileDiff:e.fileDiff,language:l,fileName:s,renderSideBySide:i,wrapLines:a,layout:"inline"})})}),Pe=({label:n,icon:s,loading:e,disabled:i,tone:a,onClick:l})=>t.jsx(Se,{variant:"ghost",size:"sm",className:re("h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100",a==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",a==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:i,title:n,"aria-label":n,onClick:p=>{p.stopPropagation(),l()},children:e?t.jsx(z,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(z,{name:s,className:s==="add"?"size-4":"size-3.5"})}),un=r.memo(function({filePath:s,staged:e,busyAction:i,disabled:a,onAction:l}){return t.jsx("div",{className:"flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:e?t.jsx(Pe,{label:`Unstage ${s}`,icon:"arrow-go-back",loading:i==="unstage",disabled:a,onClick:()=>l("unstage")}):t.jsxs(t.Fragment,{children:[t.jsx(Pe,{label:`Revert changes in ${s}`,icon:"arrow-go-back",loading:i==="discard",disabled:a,tone:"failure",onClick:()=>l("discard")}),t.jsx(Pe,{label:`Stage ${s}`,icon:"add",loading:i==="stage",disabled:a,tone:"success",onClick:()=>l("stage")})]})})}),lt=3,dn=1e6,fn=15e3,Xe=500,pn=r.memo(function({directory:s,file:e,layout:i,wrapLines:a,isSelected:l,isExpanded:p,isMounted:d,onSelect:b,onExpandedChange:g,registerSectionRef:c,showOpenInEditorAction:h=!1,isOpeningInEditor:w=!1,onOpenInEditor:D,staged:x=!1,showFileActions:S=!0,loadFullFiles:m=!1,initialDiffData:f=null}){const{git:P}=st(),$=ce(r.useCallback(u=>u.directories.get(s)?.diffCache.get(e.path)??null,[s,e.path])),M=ce(u=>u.setDiff),N=ce(u=>u.fetchStatus),O=Y(u=>u.setDiffFileLayout),v=Y(u=>u.setDiffWrapLines),[y,L]=r.useState(0),[k,R]=r.useState(null),[W,C]=r.useState(!1),[_,V]=r.useState(null),[Z,me]=r.useState(!1),[ue,E]=r.useState(null),[I,ee]=r.useState(null),te=r.useRef(null),Q=r.useRef(null),oe=r.useMemo(()=>ot(e),[e]),X=i==="side-by-side",K=m?"full":"patch",ae=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,J=r.useMemo(()=>f||(x?I:ue||($?{original:$.original,modified:$.modified,isBinary:$.isBinary,contextMode:"full"}:null)),[$,f,ue,x,I]),ge=J?.contextMode===K,de=r.useCallback(u=>{Q.current=u,c(e.path,u)},[e.path,c]),xe=r.useCallback(u=>{g(e.path,u)},[e.path,g]),be=r.useCallback(()=>{b(e.path)},[e.path,b]);r.useEffect(()=>{x?ee(null):E(null),R(null),te.current=null},[ae,x]),r.useEffect(()=>{if(!p||!d)return;if(!s||f||J&&ge){te.current=null,C(!1);return}const u=`${s}::${e.path}::${x?"staged":"unstaged"}::${ae}::${K}::${y}`;if(te.current===u)return;te.current=u,R(null),C(!0);let T=!1;const ne=et(),ye=m?dn:lt,fe=ke(e.path)?P.getGitFileDiff(s,{path:e.path,staged:x}):P.getGitDiff(s,{path:e.path,staged:x,contextLines:ye}),se=fn,Ce=new Promise((q,B)=>{setTimeout(()=>B(new Error(`Timed out after ${se}ms`)),se)});return Promise.race([fe,Ce]).then(q=>{if(!T){if("diff"in q){const B=$e(e.path,q.diff,K);x?ee(B):E(B)}else{const B={original:q.original??"",modified:q.modified??"",isBinary:q.isBinary,contextMode:"full"};x?ee(B):M(s,e.path,B,ne)}C(!1)}}).catch(q=>{if(T)return;const B=q instanceof Error?q.message:String(q);R(B),C(!1)}),()=>{T=!0,te.current===u&&(te.current=null)}},[K,J,ge,y,s,e.path,ae,P,f,p,d,m,M,x]);const le=r.useCallback(()=>{xe(!p),be()},[xe,be,p]),Ne=r.useCallback(async u=>{if(!(!s||_!==null)){V(u);try{u==="stage"?await P.stageGitFile(s,e.path):u==="unstage"?await P.unstageGitFile(s,e.path):await P.revertGitFile(s,e.path,{scope:"working"}),L(T=>T+1),await N(s,P)}catch(T){const ne=u==="unstage"?"Failed to unstage changes":u==="stage"?"Failed to stage changes":"Failed to revert changes";it.error(T instanceof Error?T.message:ne)}finally{V(T=>T===u?null:T)}}},[s,N,e.path,_,P]);return t.jsxs("div",{ref:de,className:re("scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0"),children:[t.jsx("div",{className:re("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:le,onKeyDown:u=>{u.target===u.currentTarget&&(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),le())},className:re("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:p?t.jsx(z,{name:"arrow-down-s",className:"size-4"}):t.jsx(z,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:oe.color},title:oe.description,"aria-label":oe.description,children:oe.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(nt,{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 T=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:T}),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:[at(e.insertions,e.deletions),h&&D?t.jsx(Se,{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(),D(e.path,J)},disabled:w,children:w?t.jsx(z,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(z,{name:"edit",className:"size-3.5"})}):null,t.jsx(rt,{mode:X?"side-by-side":"unified",onModeChange:u=>{const T=u==="side-by-side"?"side-by-side":"inline";O(e.path,T)},className:"opacity-70"}),t.jsxs(kt,{children:[t.jsx(Rt,{asChild:!0,children:t.jsx(Se,{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(z,{name:"more-2-fill",className:"size-3.5"})})}),t.jsxs(Et,{align:"end",onClick:u=>{u.stopPropagation()},onPointerDown:u=>{u.stopPropagation()},children:[t.jsxs(Ge,{onSelect:()=>{v(!a)},children:[t.jsx(z,{name:"text-wrap",className:"size-4"}),t.jsx("span",{className:"flex-1",children:"Wrap lines"}),a?t.jsx(z,{name:"check",className:"size-4"}):null]}),t.jsxs(Ge,{onSelect:()=>{O(e.path,X?"inline":"side-by-side")},children:[t.jsx(z,{name:X?"align-justify":"layout-column",className:"size-4"}),X?"Switch to unified view":"Switch to side-by-side view"]})]})]})]})]})}),p&&t.jsxs("div",{className:"relative overflow-clip bg-background",children:[!d&&!k?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,k?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:k}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>L(u=>u+1),children:"Retry"})]}):null,d&&W&&!J&&!k?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),"Loading diff..."]}):null,d&&J&&!Z&&e.insertions+e.deletions>Xe?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:()=>me(!0),children:"Render anyway"})]}):null,d&&J&&(Z||e.insertions+e.deletions<=Xe)?t.jsxs(t.Fragment,{children:[t.jsx(cn,{filePath:e.path,diff:J,renderSideBySide:X,wrapLines:a}),S?t.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20",children:t.jsx("div",{className:"pointer-events-auto",children:t.jsx(un,{filePath:e.path,staged:x,busyAction:_,disabled:_!==null,onAction:Ne})})}):null]}):null]})]})}),hn=1100,Ye=300,mn=n=>n<=6?n:n<=12?6:n<=25?4:2,gn=(n,s)=>At(n,s),Qe=(n,s)=>{const e=n.split(`
|
|
11
|
+
`),i=s.split(`
|
|
12
|
+
`),a=Math.min(e.length,i.length);for(let l=0;l<a;l+=1)if(e[l]!==i[l])return l+1;return i.length>e.length?e.length+1:e.length>i.length?Math.max(1,i.length):1},xn=n=>Array.isArray(n)?n.filter(s=>!s||typeof s!="object"?!1:typeof s.file=="string"):[],bn=n=>n.split(/^diff --git /m).slice(1).flatMap(e=>{const[i=""]=e.split(`
|
|
13
|
+
`,1),a=i.lastIndexOf(" b/");if(a<=2)return[];const l=i.slice(2,a),p=i.slice(a+3).trim(),d=`diff --git ${e}`,b=d.includes(`
|
|
14
|
+
new file mode `)?"added":d.includes(`
|
|
15
|
+
deleted file mode `)?"deleted":d.includes(`
|
|
16
|
+
rename from `)?"renamed":"modified";let g=0,c=0;for(const h of d.split(`
|
|
17
|
+
`))h.startsWith("+")&&!h.startsWith("+++")&&(g+=1),h.startsWith("-")&&!h.startsWith("---")&&(c+=1);return[{file:b==="deleted"?l:p,status:b,additions:g,deletions:c,patch:d}]}),yn=n=>n==="added"?"A":n==="deleted"?"D":"M";function wn({activeDiffScope:n,effectiveDirectory:s,branchBase:e,branchHead:i,git:a,sessionMessageRecords:l}){const[p,d]=r.useState([]),[b,g]=r.useState(null),[c,h]=r.useState(!1),w=r.useMemo(()=>{const S=Tt(l,{showTextJustificationActivity:!1,mergeHiddenUserTurns:!0});for(let m=S.turns.length-1;m>=0;m-=1){const f=S.turns[m];if(!f)continue;const P=f.activityParts.map(N=>N.part).filter(N=>N.type==="tool"),$=Mt(P);if($.length>0)return $.map(N=>({file:N.path,status:"modified",additions:N.additions,deletions:N.deletions,patch:N.patch}));const M=xn(f.userMessage.info?.summary?.diffs);if(M.length>0)return M}return[]},[l]);r.useEffect(()=>{if(n!=="branch"||!s||!e||!i||!a.getGitRangeDiff){d([]),g(null),h(!1);return}let S=!1;return h(!0),g(null),a.getGitRangeDiff(s,{base:e,head:i,contextLines:lt}).then(m=>{S||(d(bn(m.diff??"")),h(!1))}).catch(m=>{S||(d([]),h(!1),g(m instanceof Error?m.message:String(m)))}),()=>{S=!0}},[n,e,i,s,a]);const D=r.useMemo(()=>{const S=new Map;for(const m of w)if(m.file){if(typeof m.patch=="string"){S.set(m.file,$e(m.file,m.patch,"patch"));continue}typeof m.before!="string"&&typeof m.after!="string"||S.set(m.file,{original:m.before??"",modified:m.after??"",contextMode:"full"})}return S},[w]),x=r.useMemo(()=>{const S=new Map;for(const m of p)!m.file||typeof m.patch!="string"||S.set(m.file,$e(m.file,m.patch,"patch"));return S},[p]);return{branchDiffs:p,branchDiffError:b,branchDiffLoading:c,lastTurnDiffs:w,lastTurnDiffData:D,branchDiffData:x}}const Je=(n,s)=>{if(s.length===0)return null;let e=null,i=null;for(const l of s)l.top<=n?(!e||l.top>e.top)&&(e=l):(!i||l.top<i.top)&&(i=l);const a=e??i;return a?{path:a.path,topOffset:a.top-n}:null},Fn=(n,s,e,i)=>Math.min(Math.max(0,i),Math.max(0,n+e-s));function vn({pinSelectedFileHeaderToTopOnNavigate:n,scrollRequestNonce:s,changedFiles:e,expandedFiles:i,setMountedStackedFiles:a,fileDiffRefreshNonce:l}){const p=r.useRef(null),d=r.useRef(new Map),[b,g]=r.useState(null),c=r.useRef(null),h=r.useRef(null),w=r.useRef(!1),D=r.useRef(null),x=r.useRef(i),S=r.useRef(null);r.useLayoutEffect(()=>{x.current=i},[i]);const m=r.useRef(null),f=r.useCallback(()=>{const v=p.current;if(!v)return null;const y=v.getBoundingClientRect().top,L=[];for(const[k,R]of d.current)R&&L.push({path:k,top:R.getBoundingClientRect().top});return Je(y,L)},[]),P=r.useCallback(()=>{c.current=null,w.current=!1,g(null),h.current!==null&&(window.cancelAnimationFrame(h.current),h.current=null)},[]),$=r.useCallback(()=>{D.current=null;const v=p.current;if(!v)return;const y=v.getBoundingClientRect(),L=y.top-Ye,k=y.bottom+Ye,R={},W=[];for(const[C,_]of d.current){if(!_)continue;const V=_.getBoundingClientRect();W.push({path:C,top:V.top}),x.current.has(C)&&(V.bottom<L||V.top>k||(R[C]=!0))}S.current=Je(y.top,W),a(C=>{let _=!1;const V=new Set(C);for(const Z of Object.keys(R))V.has(Z)||(V.add(Z),_=!0);return _?V:C})},[a]),M=r.useCallback(()=>{typeof window>"u"||D.current===null&&(D.current=window.requestAnimationFrame($))},[$]);r.useEffect(()=>{const v=p.current;if(v)return M(),v.addEventListener("scroll",M,{passive:!0}),window.addEventListener("resize",M),()=>{v.removeEventListener("scroll",M),window.removeEventListener("resize",M),D.current!==null&&(window.cancelAnimationFrame(D.current),D.current=null)}},[e,i,M]),r.useLayoutEffect(()=>{const v=m.current;if(!v)return;m.current=null;const y=p.current,L=d.current.get(v.path);if(!y||!L)return;const k=y.getBoundingClientRect().top,R=L.getBoundingClientRect().top-k;y.scrollTop=Fn(y.scrollTop,v.topOffset,R,y.scrollHeight-y.clientHeight),S.current=v},[l]);const N=r.useCallback((v,y)=>{const L=d.current;y?L.set(v,y):L.delete(v),M()},[M]),O=r.useCallback(v=>{const y=d.current.get(v),L=p.current;if(!y||!L)return!1;const k=y.getBoundingClientRect().top-L.getBoundingClientRect().top;return L.scrollTo({top:L.scrollTop+k,behavior:"auto"}),!0},[]);return r.useEffect(()=>{if(!c.current)return;let y=0;const L=20;let k=!1;const R=(C=!0)=>{k||(k=!0,c.current=null,w.current=!1,C&&g(null),h.current!==null&&(window.cancelAnimationFrame(h.current),h.current=null))},W=()=>{if(k){h.current=null;return}const C=c.current;if(!C){R(),h.current=null;return}if(!O(C)){y+=1,y<L?h.current=window.requestAnimationFrame(W):(R(),h.current=null);return}if(n&&w.current){g(C),R(!1);return}R()};return h.current=window.requestAnimationFrame(W),()=>{k=!0,h.current!==null&&(window.cancelAnimationFrame(h.current),h.current=null)}},[n,s,O]),{diffScrollRef:p,fileSectionRefs:d,pinnedStackedTarget:b,pendingScrollTargetRef:c,shouldPinAfterAlignRef:w,pendingScrollAnchorRestoreRef:m,lastScrollAnchorRef:S,captureScrollAnchor:f,cancelPendingScrollAlignment:P,queueVisibleStackedFilesSync:M,registerSectionRef:N,scrollToFile:O}}const Ze=n=>{if(!n)return null;const s=n.split(`
|
|
18
|
+
`);let e=null;for(const i of s){const a=i.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(a){const l=Number.parseInt(a[1]??"",10);e=Number.isFinite(l)&&l>=1?l:null;continue}if(e!==null){if(i.startsWith(" ")){e+=1;continue}if(i.startsWith("+"))return e;if(i.startsWith("-"))return Math.max(1,e)}}return null};function jn({effectiveDirectory:n,activeDiffStaged:s,git:e,files:i,setDiff:a,openContextFileAtLine:l}){const[p,d]=r.useState(null),b=r.useCallback(async(g,c)=>{if(!n||!g)return;d(g);const h=et();try{let w=null;if(c?.patch&&!c.isBinary&&!ke(g)?w=Ze(c.patch):c&&c.contextMode==="full"&&!c.isBinary&&!ke(g)&&(w=Qe(c.original,c.modified)),w===null)try{const f=await e.getGitDiff(n,{path:g,staged:s,contextLines:3});w=Ze(f.diff)}catch{w=null}let D=c;if(w===null||!D){const f=await e.getGitFileDiff(n,{path:g,staged:s});D={original:f.original??"",modified:f.modified??"",isBinary:f.isBinary},s||a(n,g,D,h??void 0)}const x=w??(D.isBinary||ke(g)?1:Qe(D.original,D.modified)),S=gn(n,g),m=await Yt(i,S,{directory:n});if(!m.ok){it.error(Qt(m.reason));return}l(n,S,x,1)}finally{d(w=>w===g?null:w)}},[s,n,i,e,l,a]);return{openingEditorFilePath:p,openFileInEditorAtChange:b}}function Sn(n){const{hideStackedFileSidebar:s=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:i=!1,diffScope:a="all",branchBase:l=null,branchHead:p=null,targetFilePath:d=null}=n,{git:b,files:g}=st(),c=It(),{screenWidth:h,isMobile:w}=Pt(),D=$t(c??null),x=Wt(c??null),S=_t(c??null),m=ce(o=>o.setActiveDirectory),f=ce(o=>o.ensureStatus),P=ce(o=>o.fetchStatus),$=ce(o=>o.clearDiffCache),M=ce(o=>o.setDiff),[N,O]=r.useState(null),[v,y]=r.useState(!1),[L,k]=r.useState(()=>new Set),[R,W]=r.useState(()=>new Set),[C,_]=r.useState(!1),[V,Z]=r.useState(0),[me,ue]=r.useState(()=>new Map),[E,I]=r.useState(a);r.useEffect(()=>{I(a)},[a]);const ee=Y(o=>o.pendingDiffFile),te=Y(o=>o.pendingDiffStaged),Q=Y(o=>o.pendingDiffScope),oe=Y(o=>o.setPendingDiffFile),X=Y(o=>o.diffLayoutPreference),K=Y(o=>o.diffFileLayout),ae=Y(o=>o.setDiffFileLayout),J=Y(o=>o.diffWrapLinesOverride),ge=Y(o=>o.wrapLinesByDefault),de=Y(o=>o.setDiffWrapLines),xe=Y(o=>o.openContextFileAtLine),be=Bt(o=>o.currentSessionId),le=zt(be??""),Ne=J??ge,u=E==="staged"?!0:E==="working"?!1:null,T=u??v,ne=w||h<=768,ye=!s&&!ne&&h>=1024,fe=r.useRef(null),{branchDiffs:se,branchDiffError:Ce,branchDiffLoading:q,lastTurnDiffs:B,lastTurnDiffData:ie,branchDiffData:G}=wn({activeDiffScope:E,effectiveDirectory:c,branchBase:l,branchHead:p,git:b,sessionMessageRecords:le}),H=r.useMemo(()=>{if(E==="turn"||E==="branch")return(E==="branch"?se:B).map(A=>({path:A.file??"",index:"",working_dir:yn(A.status),insertions:A.additions??0,deletions:A.deletions??0,isNew:A.status==="added"})).filter(A=>A.path).sort((A,U)=>A.path.localeCompare(U.path));if(!x?.files)return[];const o=x.diffStats??{},j=E==="staged"?He:E==="working"?Ue:()=>!0;return x.files.filter(j).map(F=>({...F,insertions:o[F.path]?.insertions??0,deletions:o[F.path]?.deletions??0,isNew:Vt(F)})).sort((F,A)=>F.path.localeCompare(A.path))},[E,se,B,x]),Ae=r.useMemo(()=>x?.files?x.files.filter(Ue).length:0,[x]),ct=r.useMemo(()=>x?.files?x.files.filter(He).length:0,[x]),ut=B.length,dt=x?.files?.length??0,ft=se.length,{diffScrollRef:pt,pinnedStackedTarget:ht,pendingScrollTargetRef:we,shouldPinAfterAlignRef:Fe,pendingScrollAnchorRestoreRef:We,lastScrollAnchorRef:_e,captureScrollAnchor:Be,cancelPendingScrollAlignment:ve,queueVisibleStackedFilesSync:Re,registerSectionRef:mt,scrollToFile:ze}=vn({pinSelectedFileHeaderToTopOnNavigate:i,scrollRequestNonce:V,changedFiles:H,expandedFiles:L,setMountedStackedFiles:W,fileDiffRefreshNonce:me}),je=r.useCallback(o=>{k(j=>{if(j.has(o))return j;const F=new Set(j);return F.add(o),F})},[]),Te=r.useMemo(()=>H.map(o=>o.path).join("\0"),[H]);r.useEffect(()=>{const o=Te?Te.split("\0"):[],j=new Set(o),F=`${c??""}:${E}:${e?"collapsed":"default"}`,A=fe.current!==F;fe.current=F,k(U=>{if(A){const pe=e?0:mn(o.length);return new Set(o.slice(0,pe))}let Le=!1;const De=new Set;for(const pe of U){if(!j.has(pe)){Le=!0;continue}De.add(pe)}return Le?De:U}),W(U=>{if(A)return new Set;let Le=!1;const De=new Set;for(const pe of U){if(!j.has(pe)){Le=!0;continue}De.add(pe)}return Le?De:U})},[E,Te,c,W,e]);const Me=r.useCallback(o=>{const j=K[o.path];if(j)return j;if(X==="inline")return"inline";if(X==="side-by-side")return"side-by-side";const F=h<hn;return o.isNew||F?"inline":"side-by-side"},[K,X,h]),gt=r.useMemo(()=>H.length===0?null:H.every(o=>Me(o)==="side-by-side")?"side-by-side":"inline",[H,Me]);r.useEffect(()=>{c&&(m(c),f(c,b))},[c,m,f,b]),r.useEffect(()=>{if(c)return Ot.onGitRefreshHint(o=>{Oe(o.directory)===Oe(c)&&(o.paths?.length&&(We.current=Be()??_e.current,$(c,o.paths),ue(j=>{const F=new Map(j);for(const A of o.paths??[])F.set(A,(F.get(A)??0)+1);return F})),P(c,b,{silent:!0}))})},[Be,$,c,P,b,_e,We]),r.useEffect(()=>{E!=="all"&&!Q||ee&&(Q&&I(Q),O(ee),y(Q==="staged"||!Q&&te),oe(null),Fe.current=!0,we.current=ee,je(ee),Z(o=>o+1))},[E,je,ee,Q,te,we,oe,Fe]),r.useEffect(()=>{if(E==="all")return;const o=d?.trim();o&&(O(o),y(E==="staged"),Fe.current=!0,we.current=o,je(o),Z(j=>j+1))},[E,je,we,Fe,d]),r.useEffect(()=>{if(!N)return;H.some(j=>j.path===N)||(O(null),y(!1))},[H,N]);const xt=r.useCallback((o,j)=>{ve(),k(F=>{const A=F.has(o);if(j===A)return F;const U=new Set(F);return j?U.add(o):U.delete(o),U}),W(F=>{const A=F.has(o);if(j===A)return F;const U=new Set(F);return j?U.add(o):U.delete(o),U}),Re()},[ve,Re,W]),bt=r.useCallback(()=>{ve(),k(o=>o.size>0?new Set:new Set(H.map(j=>j.path))),W(new Set),Re()},[ve,H,Re,W]),yt=r.useCallback(o=>{},[]),wt=r.useCallback(o=>{ve(),O(o),y(!1),Fe.current=!0,we.current=o,je(o),Z(j=>j+1),ze(o)},[ve,je,we,ze,Fe]),Ft=r.useCallback(o=>{const j=o==="side-by-side"?"side-by-side":"inline";H.forEach(F=>{ae(F.path,j)})},[H,ae]),{openingEditorFilePath:vt,openFileInEditorAtChange:jt}=jn({effectiveDirectory:c,activeDiffStaged:T,git:b,files:g,setDiff:M,openContextFileAtLine:xe});return{git:b,files:g,effectiveDirectory:c,screenWidth:h,isMobile:w,isGitRepo:D,status:x,isLoadingStatus:S,activeDiffScope:E,setActiveDiffScope:I,branchDiffs:se,branchDiffError:Ce,branchDiffLoading:q,diffWrapLines:Ne,setDiffWrapLines:de,forcedStaged:u,displayFileStaged:v,displayFile:N,pinnedStackedTarget:ht,expandedFiles:L,mountedStackedFiles:R,loadFullFiles:C,setLoadFullFiles:_,fileDiffRefreshNonce:me,showFileSidebar:ye,diffScrollRef:pt,lastTurnDiffData:ie,branchDiffData:G,changedFiles:H,workingFileCount:Ae,stagedFileCount:ct,turnFileCount:ut,allFileCount:dt,branchFileCount:ft,currentLayoutForAllFiles:gt,openingEditorFilePath:vt,registerSectionRef:mt,handleStackedEntryExpandedChange:xt,handleExpandOrCollapseAll:bt,handleSelectFile:yt,handleSelectFileAndScroll:wt,handleHeaderLayoutChange:Ft,openFileInEditorAtChange:jt,getLayoutForFile:Me}}const vs=({hideStackedFileSidebar:n=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:e=!1,showOpenInEditorAction:i=!1,diffScope:a="all",onDiffScopeChange:l,branchBase:p=null,branchHead:d=null,targetFilePath:b=null,flushContent:g=!1,hideToolbar:c=!1,onHeaderControlsStateChange:h,toolbarSlot:w=null})=>{const{effectiveDirectory:D,isGitRepo:x,status:S,isLoadingStatus:m,activeDiffScope:f,setActiveDiffScope:P,branchDiffError:$,branchDiffLoading:M,diffWrapLines:N,setDiffWrapLines:O,forcedStaged:v,displayFileStaged:y,displayFile:L,pinnedStackedTarget:k,expandedFiles:R,mountedStackedFiles:W,loadFullFiles:C,setLoadFullFiles:_,fileDiffRefreshNonce:V,showFileSidebar:Z,diffScrollRef:me,lastTurnDiffData:ue,branchDiffData:E,changedFiles:I,workingFileCount:ee,stagedFileCount:te,turnFileCount:Q,allFileCount:oe,branchFileCount:X,currentLayoutForAllFiles:K,openingEditorFilePath:ae,registerSectionRef:J,handleStackedEntryExpandedChange:ge,handleExpandOrCollapseAll:de,handleSelectFile:xe,handleSelectFileAndScroll:be,handleHeaderLayoutChange:le,openFileInEditorAtChange:Ne,getLayoutForFile:u}=Sn({hideStackedFileSidebar:n,stackedDefaultCollapsedAll:s,pinSelectedFileHeaderToTopOnNavigate:e,diffScope:a,branchBase:p,branchHead:d,targetFilePath:b});r.useEffect(()=>{c&&l?.(f)},[f,c,l]);const T=r.useCallback(()=>{_(ie=>!ie)},[_]),ne=r.useCallback(()=>{O(!N)},[N,O]),ye=r.useCallback(()=>{le(K==="side-by-side"?"unified":"side-by-side")},[K,le]),fe=R.size,se=r.useMemo(()=>({turnCount:Q,branchCount:X,expandedCount:fe,totalCount:I.length,loadFullFiles:C,wrapLines:N,layoutMode:K,onExpandOrCollapseAll:de,onToggleLoadFullFiles:T,onToggleWrapLines:ne,onToggleLayout:ye}),[Q,X,fe,I.length,C,N,K,de,T,ne,ye]);r.useEffect(()=>{c&&h?.(se)},[c,se,h]);const Ce=()=>{if(!D)return null;const ie=G=>v!==null?v:y&&G===L;return t.jsxs("div",{className:re("flex min-w-0 flex-1 min-h-0 h-full",g?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[Z&&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:I.length})]}),t.jsx(on,{changedFiles:I,selectedFile:null,onSelectFile:be})]}),t.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:t.jsxs(tt,{ref:me,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:I.map(G=>t.jsx(pn,{directory:D,file:G,layout:u(G),wrapLines:N,isSelected:!1,isExpanded:R.has(G.path),isMounted:W.has(G.path)||G.path===k,onSelect:xe,onExpandedChange:ge,registerSectionRef:J,showOpenInEditorAction:i&&f!=="turn"&&f!=="branch",isOpeningInEditor:ae===G.path,onOpenInEditor:(H,Ae)=>{Ne(H,Ae)},staged:ie(G.path),showFileActions:f!=="turn"&&f!=="branch",loadFullFiles:C,initialDiffData:f==="turn"?ue.get(G.path)??null:f==="branch"?E.get(G.path)??null:null},`${G.path}:${V.get(G.path)??0}`))}),t.jsx("div",{"aria-hidden":"true",className:"h-16 shrink-0"})]})})]})},q=()=>D?f!=="turn"&&m&&!S?t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),"Loading repository status..."]}):f!=="turn"&&f!=="branch"&&x===!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."}):f==="branch"&&M?t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),"Loading branch changes..."]}):f==="branch"&&$?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: ${$}`}):I.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:f==="turn"?"No last turn changes to display":"Working tree clean, no changes to display"}):Ce():t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Select a session directory to view diffs"}),B=t.jsxs("div",{className:w?"flex min-w-0 flex-1 items-center gap-1.5":"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[(x!==!1||f==="turn")&&(f==="all"||f==="working"||f==="staged"||f==="turn"||f==="branch")?t.jsx(Kt,{scope:f,isGitRepo:x,branchAvailable:!!(p&&d),allCount:oe,workingCount:ee,stagedCount:te,turnCount:Q,branchCount:X,onScopeChange:ie=>{P(ie),l?.(ie)}}):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:m&&!S?"Loading changes...":I.length===1?`${I.length} file changed`:`${I.length} files changed`})}),I.length>0&&t.jsxs(Se,{variant:"ghost",size:"sm",onClick:de,className:re("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:R.size>0?"Collapse all":"Expand all",children:[t.jsx(z,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:R.size>0?"Collapse all":"Expand all"})]}),I.length>0&&f!=="turn"&&f!=="branch"&&t.jsxs(Gt,{children:[t.jsx(Ht,{asChild:!0,children:t.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>_(ie=>!ie),"aria-pressed":C,"aria-label":C?"Unload full files":"Load full files",className:re("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",C&&"bg-interactive-selection text-interactive-selection-foreground"),children:t.jsx(z,{name:"file-download",className:"size-4"})})}),t.jsx(Ut,{children:t.jsx("p",{children:C?"Unload full files":"Load full files"})})]}),I.length>0&&t.jsx(Se,{variant:"ghost",size:"sm",onClick:()=>O(!N),className:re("h-5 w-5 p-0 transition-opacity",N?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:N?"Disable line wrap":"Enable line wrap",children:t.jsx(z,{name:"text-wrap",className:"size-4"})}),K&&t.jsx(rt,{mode:K==="side-by-side"?"side-by-side":"unified",onModeChange:le})]});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[w?St.createPortal(B,w):c?null:B,q()]})};export{vs as DiffView};
|
package/dist/assets/{FileSaveConflictDialog-DP7k9a-i.js → FileSaveConflictDialog-DlH8IWDL.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{k as r}from"./vendor-boot-
|
|
1
|
+
import{k as r}from"./vendor-boot-EC6IyLt1.js";import{R as a}from"./vendor-react-DASdDPIk.js";import{D as j}from"./vendor-react-drawio-Duu5LgQA.js";import{e as C}from"./index-DWSrsQWl.js";import{au as E,av as S,aw as N,ax as B,ay as F,az as H,B as p}from"./useAppFontEffects-Bd0btzjJ.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]),D=a.useCallback(n=>{l.current=n.xml,u?.(n.xml)},[u]);return r.jsx("div",{ref:g,className:C("h-full w-full",d),children:r.jsx(j,{ref:c,xml:f.current||A,autosave:!0,urlParameters:{ui:s?"simple":o?"dark":"kennedy",spin:!0,libraries:!s,chrome:s,nav:s,layers:s,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:R,onAutoSave:D},o?"dark":"light")})}),X=(t,e)=>!t||t.runtimeKey!==e.runtimeKey||t.root!==e.root||t.path!==e.path||t.generation!==e.generation,b=t=>{if(typeof t=="string")return t;if(t===null)return null},G=(t,e)=>{if(e===!0)return t!==void 0?{expectedRevision:b(t),overwrite:!0}:{overwrite:!0};if(t!==void 0)return{expectedRevision:b(t)}},W=(t,e)=>!!(t&&e&&t.runtimeKey===e.runtimeKey&&t.root===e.root&&t.path===e.path&&t.generation===e.generation),k=(t,e=4e3)=>t.length>e?`${t.slice(0,e)}
|
|
2
2
|
|
|
3
|
-
… truncated …`:t,Y=({open:t,conflict:e,isResolving:
|
|
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};
|