@openchamber/web 1.20.0 → 1.21.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/bin/cli.test.js +35 -0
- package/bin/lib/DOCUMENTATION.md +12 -0
- package/bin/lib/cli-settings-accessors.js +111 -0
- package/bin/lib/cli-settings-accessors.test.js +189 -0
- package/bin/lib/cli-startup.js +29 -9
- package/bin/lib/commands-connect-url.js +12 -14
- package/dist/assets/{CodeMirrorCommentWidgets-C36E738Y.js → CodeMirrorCommentWidgets-BGj8TJxW.js} +1 -1
- package/dist/assets/CommitSection-DwGiXyjf.js +1 -0
- package/dist/assets/DiffView-Db6bjVv1.js +4 -0
- package/dist/assets/FilesView-DQOa7Lgz.js +17 -0
- package/dist/assets/GitView-CHzJxTi0.js +6 -0
- package/dist/assets/{JsonTreeView-KnXFN2A-.js → JsonTreeView-CggOsLot.js} +1 -1
- package/dist/assets/MarkdownImageGallery-DoZpaHev.js +1 -0
- package/dist/assets/MarkdownRendererImpl-B5Y5xCOz.js +12 -0
- package/dist/assets/OnboardingScreen-C98d69Fp.js +1 -0
- package/dist/assets/{PatchDiff-BzVOVog8.js → PatchDiff-DJYMUiXA.js} +1 -1
- package/dist/assets/PierreDiffViewer-CY2bx_SB.js +157 -0
- package/dist/assets/PlanView-PkiOY_9H.js +5 -0
- package/dist/assets/SettingsView-D-K3ELCM.js +28 -0
- package/dist/assets/SettingsWindow-oyOm2fHR.js +1 -0
- package/dist/assets/{ToolOutputDialog-BB1c--Zr.js → ToolOutputDialog-lKyeQTPL.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-DaOIDISD.js → ToolPartDiffPreview-C7kBQNAA.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-lESMT-2b.js → VirtualizedFileDiff-BP7ebDFF.js} +4 -4
- package/dist/assets/{Virtualizer-X_7XPoTH.js → Virtualizer-CZlLSacm.js} +1 -1
- package/dist/assets/Virtualizer-D_a8gKmg.js +1 -0
- package/dist/assets/{WalkthroughView-CaSYE0lw.js → WalkthroughView-MuJodAHD.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-DkRR5b75.js → computeVirtualFileMetrics-CZ0xPeaT.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-C9abMBTb.js +1 -0
- package/dist/assets/de-CEoCz3j6.js +9 -0
- package/dist/assets/es-DwyXCqaL.js +15 -0
- package/dist/assets/fr-CS7Csln9.js +13 -0
- package/dist/assets/index-CUKcHnUA.css +1 -0
- package/dist/assets/index-CaPAjwXQ.js +1 -0
- package/dist/assets/index-DIvDEKE-.js +7 -0
- package/dist/assets/{isDiffPlainText-BG53Ixxy.js → isDiffPlainText-ZBvDxhVB.js} +1 -1
- package/dist/assets/{isFilePlainText-BbV-39jl.js → isFilePlainText-DiLRrkJr.js} +1 -1
- package/dist/assets/ja-vnwqLcx6.js +15 -0
- package/dist/assets/ko-CXuSfZv5.js +15 -0
- package/dist/assets/main-D5RWr6sJ.js +2 -0
- package/dist/assets/main-DLlfDjQ_.js +926 -0
- package/dist/assets/{markdown-shiki.worker-CKGJ1J33.js → markdown-shiki.worker-D5fBU-lw.js} +5 -5
- package/dist/assets/markdownCore-CcTcLsQF.js +3 -0
- package/dist/assets/{miniChat-ldEghBLB.js → miniChat-CqR3icsk.js} +2 -2
- package/dist/assets/mobile-RN_UTTlB.js +2 -0
- package/dist/assets/{patchFileDiff-BcFaMtMu.js → patchFileDiff-CjRR5ESs.js} +1 -1
- package/dist/assets/pl-BJxry0Mi.js +15 -0
- package/dist/assets/pt-BR-DxLmkhdv.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-1wC94fQK.js +2 -0
- package/dist/assets/renderMobileApp-ltva2Plg.js +25 -0
- package/dist/assets/runtimeEndpointReset-D6SmNZaP.js +15 -0
- package/dist/assets/scheduledTasksApi-mjMDet_H.js +1 -0
- package/dist/assets/{shikiHighlight-DCT2Sq_z.js → shikiHighlight-fGmFkxAM.js} +1 -1
- package/dist/assets/tr-5Mk_hQ2Q.js +6 -0
- package/dist/assets/uk-ClgQjmlw.js +15 -0
- package/dist/assets/{useAppFontEffects-B53Rb6m7.js → useAppFontEffects-KP8_yiGW.js} +176 -184
- package/dist/assets/useInlineCommentController-HIjtuhxD.js +2 -0
- package/dist/assets/useRootScrollLock-BSiQ5F75.js +1 -0
- package/dist/assets/{vendor-base-ui-DsHmyMwp.js → vendor-base-ui-BeMD8X_w.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-vch3tJ4c.js → vendor-codemirror-language-data-DrTPkHl4.js} +2 -2
- package/dist/assets/{vendor-floating-ui-core-CXmKXOXc.js → vendor-floating-ui-core-PuGzNPnN.js} +1 -1
- package/dist/assets/{vendor-floating-ui-dom-WyXykhNi.js → vendor-floating-ui-dom-BTvzWks8.js} +1 -1
- package/dist/assets/{vendor-floating-ui-react-dom-DKpLs02S.js → vendor-floating-ui-react-dom-DxYCWdHj.js} +1 -1
- package/dist/assets/{vendor-floating-ui-utils-BzXdqYpP.js → vendor-floating-ui-utils-D6FqdtJt.js} +1 -1
- package/dist/assets/{vendor-framer-motion-CRSgBxjL.js → vendor-framer-motion-livSKyyV.js} +1 -1
- package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +1 -0
- package/dist/assets/vendor-linkify-it-DZCzzDkK.js +1 -0
- package/dist/assets/vendor-marked-linkify-it-CXI_LHIE.js +1 -0
- package/dist/assets/{vendor-motion-dom-DJLgZh4Q.js → vendor-motion-dom-D_o3BTI3.js} +1 -1
- package/dist/assets/vendor-uc.micro-BAd0H0z4.js +1 -0
- package/dist/assets/vendor-zod-BLfBSgBh.js +39 -0
- package/dist/assets/{web-components-pcwCTWjC.js → web-components-DOXvU-tB.js} +4 -4
- package/dist/assets/zh-CN-Ba6y8H-i.js +15 -0
- package/dist/assets/zh-TW-Dv8yyhN1.js +15 -0
- package/dist/index.html +7 -7
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/dist/site.webmanifest +1 -1
- package/dist/sw.js +1 -1
- package/package.json +4 -4
- package/public/site.webmanifest +1 -1
- package/server/index.js +10 -2
- package/server/lib/client-auth/pairing.js +8 -7
- package/server/lib/client-auth/pairing.test.js +5 -1
- package/server/lib/client-auth/remote-clients.js +9 -1
- package/server/lib/client-auth/remote-clients.test.js +17 -0
- package/server/lib/cloudflare-tunnel.js +1 -1
- package/server/lib/fs/DOCUMENTATION.md +1 -0
- package/server/lib/fs/routes.js +21 -0
- package/server/lib/fs/routes.test.js +89 -3
- package/server/lib/git/DOCUMENTATION.md +4 -3
- package/server/lib/git/service.js +128 -6
- package/server/lib/git/service.test.js +191 -1
- package/server/lib/github/pr-status.js +10 -1
- package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
- package/server/lib/markdown-image-grants/routes.js +3 -1
- package/server/lib/markdown-image-grants/routes.test.js +14 -0
- package/server/lib/openchamber-sessions/routes.js +4 -1
- package/server/lib/openchamber-sessions/routes.test.js +23 -0
- package/server/lib/opencode/env-runtime.js +17 -1
- package/server/lib/opencode/env-runtime.test.js +56 -0
- package/server/lib/opencode/lifecycle.js +48 -9
- package/server/lib/opencode/lifecycle.test.js +125 -1
- package/server/lib/opencode/managed-process-registry.d.ts +13 -0
- package/server/lib/opencode/managed-process-registry.js +213 -163
- package/server/lib/opencode/managed-process-registry.test.mjs +285 -0
- package/server/lib/opencode/project-directory-runtime.js +16 -11
- package/server/lib/opencode/project-directory-runtime.test.js +32 -12
- package/server/lib/opencode/pwa-manifest-routes.js +1 -1
- package/server/lib/opencode/routes-upgrade.test.js +96 -12
- package/server/lib/opencode/routes.js +53 -5
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +10 -0
- package/server/lib/opencode/theme-runtime.js +1 -1
- package/server/lib/opencode/theme-runtime.test.js +129 -0
- package/server/lib/quota/DOCUMENTATION.md +19 -0
- package/server/lib/quota/providers/copilot.js +26 -10
- package/server/lib/quota/providers/copilot.test.js +78 -0
- package/server/lib/quota/providers/index.js +4 -18
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/service.js +34 -2
- package/server/lib/relay/service.test.js +69 -0
- package/server/lib/session-goal/runtime.js +2 -1
- package/server/lib/session-goal/runtime.test.js +4 -2
- package/server/lib/small-model/DOCUMENTATION.md +11 -5
- package/server/lib/small-model/call.js +64 -20
- package/server/lib/small-model/call.test.js +184 -2
- package/server/lib/terminal/DOCUMENTATION.md +2 -0
- package/server/lib/terminal/runtime.js +29 -1
- package/server/lib/terminal/runtime.test.js +26 -0
- package/server/lib/tunnels/install-help.js +2 -2
- package/server/lib/tunnels/install-help.test.js +9 -0
- package/server/lib/ui-auth/ui-auth.js +2 -2
- package/server/lib/ui-auth/ui-auth.test.js +2 -2
- package/server/lib/walkthrough/languages.js +1 -0
- package/dist/assets/CommitSection-C-F3AX6D.js +0 -1
- package/dist/assets/DiagramEditor-BPECg1jS.js +0 -1
- package/dist/assets/DiagramView-D0YNMix8.js +0 -1
- package/dist/assets/DiffView-BHWaMYCC.js +0 -4
- package/dist/assets/FilesView-NMBCW2Tm.js +0 -14
- package/dist/assets/GitView-Rp8P1KEI.js +0 -6
- package/dist/assets/MarkdownImageGallery-BMn3mtor.js +0 -1
- package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +0 -12
- package/dist/assets/OnboardingScreen-CenIeD4v.js +0 -1
- package/dist/assets/PierreDiffViewer-Dlby4XqT.js +0 -136
- package/dist/assets/PlanView-Czu1KMJa.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +0 -1
- package/dist/assets/SettingsView-B6vmuf-c.js +0 -28
- package/dist/assets/SettingsWindow-CauZpdD3.js +0 -1
- package/dist/assets/contextPanelEmbeddedChat-BEARQjgn.js +0 -1
- package/dist/assets/de-DFdX3ABv.js +0 -9
- package/dist/assets/es-iC-FKvV9.js +0 -15
- package/dist/assets/fr-BBbi_1AL.js +0 -13
- package/dist/assets/index-BiEgzzkg.js +0 -1
- package/dist/assets/index-Cwmuwk3V.js +0 -7
- package/dist/assets/index-GNm1wgUH.css +0 -1
- package/dist/assets/ja-DQLQJL2J.js +0 -15
- package/dist/assets/ko-BeElEB4Y.js +0 -15
- package/dist/assets/main-Dpzo18z7.js +0 -2
- package/dist/assets/main-WMjtYzJs.js +0 -921
- package/dist/assets/markdownCore--tDmyI_v.js +0 -2
- package/dist/assets/mobile-Dk-VGreF.js +0 -2
- package/dist/assets/pl-CLHt2_vV.js +0 -15
- package/dist/assets/pt-BR-C_MPUq7e.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +0 -2
- package/dist/assets/renderMobileApp-CDfHS5rr.js +0 -25
- package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +0 -15
- package/dist/assets/scheduledTasksApi-BFSlqgnG.js +0 -1
- package/dist/assets/uk-PhsC-c4-.js +0 -15
- package/dist/assets/useInlineCommentController-DSfrIBKT.js +0 -2
- package/dist/assets/vendor-zod-C9ioTTSo.js +0 -39
- package/dist/assets/zh-CN-wF-NOFHM.js +0 -15
- package/dist/assets/zh-TW-4m4-A7rT.js +0 -15
- package/server/lib/quota/providers/command-code.js +0 -90
- package/server/lib/quota/providers/command-code.test.js +0 -85
package/dist/index.html
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<!-- Web app manifest (endpoint-first with data URL fallback) -->
|
|
19
19
|
<script>
|
|
20
20
|
const baseUrl = location.origin;
|
|
21
|
-
const defaultAppName = 'OpenChamber
|
|
21
|
+
const defaultAppName = 'OpenChamber';
|
|
22
22
|
const defaultShortName = 'OpenChamber';
|
|
23
23
|
const pwaNameStorageKey = 'openchamber.pwaName';
|
|
24
24
|
const pwaOrientationStorageKey = 'openchamber.pwaOrientation';
|
|
@@ -509,16 +509,16 @@
|
|
|
509
509
|
pointer-events: none;
|
|
510
510
|
}
|
|
511
511
|
</style>
|
|
512
|
-
<script type="module" crossorigin src="/assets/main-
|
|
512
|
+
<script type="module" crossorigin src="/assets/main-D5RWr6sJ.js"></script>
|
|
513
513
|
<link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
|
|
514
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-zod-C9ioTTSo.js">
|
|
515
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
|
|
516
514
|
<link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
|
|
517
515
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
|
|
518
516
|
<link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
|
|
519
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
520
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
521
|
-
<link rel="
|
|
517
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-zod-BLfBSgBh.js">
|
|
518
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
|
|
519
|
+
<link rel="modulepreload" crossorigin href="/assets/index-DIvDEKE-.js">
|
|
520
|
+
<link rel="modulepreload" crossorigin href="/assets/contextPanelEmbeddedChat-C9abMBTb.js">
|
|
521
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CUKcHnUA.css">
|
|
522
522
|
</head>
|
|
523
523
|
<body class="h-full bg-background text-foreground">
|
|
524
524
|
<div id="root" class="h-full">
|
package/dist/mini-chat.html
CHANGED
|
@@ -74,15 +74,15 @@
|
|
|
74
74
|
}
|
|
75
75
|
</style>
|
|
76
76
|
|
|
77
|
-
<script type="module" crossorigin src="/assets/miniChat-
|
|
77
|
+
<script type="module" crossorigin src="/assets/miniChat-CqR3icsk.js"></script>
|
|
78
78
|
<link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
|
|
79
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-zod-C9ioTTSo.js">
|
|
80
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
|
|
81
79
|
<link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
|
|
82
80
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
|
|
83
81
|
<link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
|
|
84
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
85
|
-
<link rel="
|
|
82
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-zod-BLfBSgBh.js">
|
|
83
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
|
|
84
|
+
<link rel="modulepreload" crossorigin href="/assets/index-DIvDEKE-.js">
|
|
85
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CUKcHnUA.css">
|
|
86
86
|
</head>
|
|
87
87
|
<body class="h-full bg-background text-foreground">
|
|
88
88
|
<div id="root" class="h-full">
|
package/dist/mobile.html
CHANGED
|
@@ -63,15 +63,15 @@
|
|
|
63
63
|
})();
|
|
64
64
|
</script>
|
|
65
65
|
|
|
66
|
-
<script type="module" crossorigin src="/assets/mobile-
|
|
66
|
+
<script type="module" crossorigin src="/assets/mobile-RN_UTTlB.js"></script>
|
|
67
67
|
<link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
|
|
68
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-zod-C9ioTTSo.js">
|
|
69
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
|
|
70
68
|
<link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
|
|
71
69
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
|
|
72
70
|
<link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
|
|
73
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
74
|
-
<link rel="
|
|
71
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-zod-BLfBSgBh.js">
|
|
72
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
|
|
73
|
+
<link rel="modulepreload" crossorigin href="/assets/index-DIvDEKE-.js">
|
|
74
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CUKcHnUA.css">
|
|
75
75
|
</head>
|
|
76
76
|
<body class="h-full bg-background text-foreground">
|
|
77
77
|
<div id="root" class="h-full"></div>
|
package/dist/site.webmanifest
CHANGED
package/dist/sw.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";self.addEventListener("install",t=>{t.waitUntil(self.skipWaiting())}),self.addEventListener("activate",t=>{t.waitUntil(self.clients.claim())}),self.addEventListener("push",t=>{t.waitUntil((async()=>{const i=t.data?.json()??null;if(!i||(await self.clients.matchAll({type:"window",includeUncontrolled:!0})).some(
|
|
1
|
+
(function(){"use strict";self.addEventListener("install",t=>{t.waitUntil(self.skipWaiting())}),self.addEventListener("activate",t=>{t.waitUntil(self.clients.claim())}),self.addEventListener("push",t=>{t.waitUntil((async()=>{const i=t.data?.json()??null;if(!i||(await self.clients.matchAll({type:"window",includeUncontrolled:!0})).some(l=>l.visibilityState==="visible"||l.focused))return;const a=i.title||"OpenChamber",n=i.body??"",o=i.icon??"/apple-touch-icon-180x180.png",c=i.badge??"/favicon-32.png";await self.registration.showNotification(a,{body:n,icon:o,badge:c,tag:i.tag,data:i.data})})())}),self.addEventListener("notificationclick",t=>{t.notification.close();const s=(t.notification.data??null)?.url??"/";t.waitUntil((async()=>{const e=new URL(s,self.location.origin).href,a=await self.clients.matchAll({type:"window",includeUncontrolled:!0});for(const n of a){try{"navigate"in n&&await n.navigate(e)}catch{}if("focus"in n)return n.focus()}if(self.clients.openWindow)return self.clients.openWindow(e)})())})})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openchamber/web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./server/index.js",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"dev": "bun run build:watch",
|
|
16
|
-
"dev:server": "bun server/index.js --port ${OPENCHAMBER_PORT:-3001}",
|
|
17
|
-
"dev:server:watch": "nodemon --watch server --ext js --exec \"bun server/index.js --port ${OPENCHAMBER_PORT:-3001}\"",
|
|
16
|
+
"dev:server": "OPENCHAMBER_RELAY_HOST=${OPENCHAMBER_RELAY_HOST:-off} bun server/index.js --port ${OPENCHAMBER_PORT:-3001}",
|
|
17
|
+
"dev:server:watch": "OPENCHAMBER_RELAY_HOST=${OPENCHAMBER_RELAY_HOST:-off} nodemon --watch server --ext js --exec \"bun server/index.js --port ${OPENCHAMBER_PORT:-3001}\"",
|
|
18
18
|
"build": "vite build",
|
|
19
19
|
"build:watch": "vite build --watch",
|
|
20
20
|
"type-check": "tsc --noEmit",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@clack/prompts": "^1.1.0",
|
|
27
27
|
"@octokit/rest": "^22.0.1",
|
|
28
|
-
"@opencode-ai/sdk": "1.18.
|
|
28
|
+
"@opencode-ai/sdk": "1.18.25",
|
|
29
29
|
"@simplewebauthn/server": "13.3.1",
|
|
30
30
|
"bun-pty": "^0.4.5",
|
|
31
31
|
"compression": "^1.8.1",
|
package/public/site.webmanifest
CHANGED
package/server/index.js
CHANGED
|
@@ -1162,8 +1162,8 @@ const openCodeLifecycleRuntime = createOpenCodeLifecycleRuntime({
|
|
|
1162
1162
|
return [...new Set(directories)];
|
|
1163
1163
|
},
|
|
1164
1164
|
// A managed restart can move OpenCode to a NEW port (the old one may stay
|
|
1165
|
-
// occupied
|
|
1166
|
-
//
|
|
1165
|
+
// occupied if killProcessOnPort/waitForPortRelease didn't free it in time,
|
|
1166
|
+
// on any platform). Rebind the message-stream upstream readers to the current port
|
|
1167
1167
|
// so the UI keeps receiving events instead of staying pinned to the old
|
|
1168
1168
|
// process (#2638). The runtime is created later by the startup pipeline;
|
|
1169
1169
|
// by the time any restart runs, it is assigned.
|
|
@@ -1815,6 +1815,14 @@ async function main(options = {}) {
|
|
|
1815
1815
|
fs,
|
|
1816
1816
|
process,
|
|
1817
1817
|
}),
|
|
1818
|
+
// Dev/debug instances share the data dir (and thus the relay identity) with
|
|
1819
|
+
// the production instance, so they must not host the relay on their own —
|
|
1820
|
+
// paired devices would land on them. OPENCHAMBER_RELAY_HOST=off disables
|
|
1821
|
+
// passive hosting explicitly (dev scripts set it); the Electron dev shell is
|
|
1822
|
+
// covered via OPENCHAMBER_ELECTRON_DEV. OPENCHAMBER_RELAY_HOST=on overrides
|
|
1823
|
+
// both. Explicit enable/pairing on the instance still hosts regardless.
|
|
1824
|
+
allowPassiveHost: process.env.OPENCHAMBER_RELAY_HOST === 'on'
|
|
1825
|
+
|| (process.env.OPENCHAMBER_RELAY_HOST !== 'off' && process.env.OPENCHAMBER_ELECTRON_DEV !== '1'),
|
|
1818
1826
|
// Relay demand = any paired device or pending pairing session that uses the
|
|
1819
1827
|
// relay transport. Drives the auto on/off lifecycle.
|
|
1820
1828
|
hasRelayDemand: async () => {
|
|
@@ -262,14 +262,15 @@ export const createClientPairingRuntime = ({
|
|
|
262
262
|
if (!constantTimeEqual(session.secretHash, hashSecret(normalizedSecret), crypto)) throw redeemError();
|
|
263
263
|
|
|
264
264
|
// The operator's typed pairing label is THIS server's name for the device
|
|
265
|
-
// (shown in the device list)
|
|
266
|
-
// label
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|| normalizeOptionalString(deviceName)
|
|
270
|
-
|| 'Remote client';
|
|
265
|
+
// (shown in the device list) and wins outright. The device's self-reported
|
|
266
|
+
// label is only a fallback: on a re-pair with the same dedupeKey,
|
|
267
|
+
// createClient keeps the replaced record's label over it, so a rescan
|
|
268
|
+
// without a typed name does not reset the device to the app default.
|
|
271
269
|
const result = await remoteClientAuthRuntime.createClient({
|
|
272
|
-
label,
|
|
270
|
+
label: normalizeOptionalString(session.label),
|
|
271
|
+
fallbackLabel: normalizeOptionalString(clientLabel)
|
|
272
|
+
|| normalizeOptionalString(deviceName)
|
|
273
|
+
|| 'Remote client',
|
|
273
274
|
clientKind: normalizedKind,
|
|
274
275
|
dedupeKey: normalizeOptionalString(dedupeKey) || `pairing:${session.id}`,
|
|
275
276
|
authMethod: 'pairing',
|
|
@@ -13,7 +13,7 @@ const makeRuntime = async (options = {}) => {
|
|
|
13
13
|
createClient: vi.fn(async (input) => {
|
|
14
14
|
const client = {
|
|
15
15
|
id: `client-${createdClients.length + 1}`,
|
|
16
|
-
label: input.label,
|
|
16
|
+
label: input.label ?? input.fallbackLabel,
|
|
17
17
|
clientKind: input.clientKind,
|
|
18
18
|
authMethod: input.authMethod,
|
|
19
19
|
pairingId: input.pairingId,
|
|
@@ -61,6 +61,10 @@ describe('client auth pairing runtime', () => {
|
|
|
61
61
|
pairingId: created.pairing.id,
|
|
62
62
|
clientKind: 'mobile',
|
|
63
63
|
dedupeKey: 'device-key',
|
|
64
|
+
// No operator-typed pairing label: the app-reported name is only a
|
|
65
|
+
// fallback so a re-pair keeps the existing device record's label.
|
|
66
|
+
label: null,
|
|
67
|
+
fallbackLabel: 'Iryna iPhone',
|
|
64
68
|
}));
|
|
65
69
|
|
|
66
70
|
await expect(runtime.redeemPairingSession({
|
|
@@ -157,6 +157,7 @@ export const createRemoteClientAuthRuntime = ({ fsPromises, path, crypto, storeP
|
|
|
157
157
|
|
|
158
158
|
const createClient = async ({
|
|
159
159
|
label,
|
|
160
|
+
fallbackLabel,
|
|
160
161
|
expiresAt,
|
|
161
162
|
clientKind,
|
|
162
163
|
dedupeKey,
|
|
@@ -172,9 +173,16 @@ export const createRemoteClientAuthRuntime = ({ fsPromises, path, crypto, storeP
|
|
|
172
173
|
const store = await readStore();
|
|
173
174
|
const normalizedDedupeKey = normalizeOptionalString(dedupeKey);
|
|
174
175
|
const token = generateToken();
|
|
176
|
+
// A dedupe-keyed mint REPLACES the previous record for the same device,
|
|
177
|
+
// so an operator-visible name must survive the replacement: an explicit
|
|
178
|
+
// label wins, otherwise the replaced record's label is kept, and only a
|
|
179
|
+
// first-ever mint falls back to the client-reported default.
|
|
180
|
+
const existing = normalizedDedupeKey
|
|
181
|
+
? store.clients.find((entry) => entry.dedupeKey === normalizedDedupeKey)
|
|
182
|
+
: null;
|
|
175
183
|
const client = {
|
|
176
184
|
id: generateId(),
|
|
177
|
-
label: normalizeLabel(label),
|
|
185
|
+
label: normalizeLabel(normalizeOptionalString(label) || existing?.label || fallbackLabel),
|
|
178
186
|
tokenHash: hashToken(token),
|
|
179
187
|
createdAt: nowIso(),
|
|
180
188
|
lastUsedAt: null,
|
|
@@ -83,6 +83,23 @@ describe('remote client auth runtime', () => {
|
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
+
it('keeps the replaced record label on a dedupe re-mint without an explicit label', async () => {
|
|
87
|
+
const { dir, runtime } = await createRuntime();
|
|
88
|
+
try {
|
|
89
|
+
await runtime.createClient({ label: 'Iryna iPhone', dedupeKey: 'mobile:device-1', fallbackLabel: 'OpenChamber Mobile' });
|
|
90
|
+
const remint = await runtime.createClient({ dedupeKey: 'mobile:device-1', fallbackLabel: 'OpenChamber Mobile' });
|
|
91
|
+
expect(remint.client.label).toBe('Iryna iPhone');
|
|
92
|
+
|
|
93
|
+
const renamed = await runtime.createClient({ label: 'Work phone', dedupeKey: 'mobile:device-1', fallbackLabel: 'OpenChamber Mobile' });
|
|
94
|
+
expect(renamed.client.label).toBe('Work phone');
|
|
95
|
+
|
|
96
|
+
const fresh = await runtime.createClient({ dedupeKey: 'mobile:device-2', fallbackLabel: 'OpenChamber Mobile' });
|
|
97
|
+
expect(fresh.client.label).toBe('OpenChamber Mobile');
|
|
98
|
+
} finally {
|
|
99
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
86
103
|
it('keeps the token store private on disk', async () => {
|
|
87
104
|
const { dir, runtime } = await createRuntime();
|
|
88
105
|
try {
|
|
@@ -64,7 +64,7 @@ Install instructions for your platform:
|
|
|
64
64
|
Windows: winget install --id Cloudflare.cloudflared
|
|
65
65
|
Linux: Download from https://github.com/cloudflare/cloudflared/releases
|
|
66
66
|
|
|
67
|
-
Or visit: https://developers.cloudflare.com/cloudflare-one/networks/connectors/
|
|
67
|
+
Or visit: https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/
|
|
68
68
|
`);
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -25,6 +25,7 @@ Own filesystem API behavior for the web server runtime, including workspace-boun
|
|
|
25
25
|
- `GET /api/fs/list`
|
|
26
26
|
- Owns exec job queue state (`execJobs`) and lifecycle/TTL pruning.
|
|
27
27
|
- Enforces workspace boundary checks with active project + worktree fallback support.
|
|
28
|
+
- The active project directory is validated with `fs.realpath`, so when the project root is itself a symlink the workspace base no longer matches the paths the client sends. Workspace resolution therefore retries against the raw directory the client requested (`requestedDirectory` from `resolveProjectDirectory`) before falling back to worktree roots. Symlinks are still resolved afterwards, and write/exec routes keep their canonical containment check against the resolved base.
|
|
28
29
|
- `createFsSearchRuntime({ fsPromises, path, spawn, resolveGitBinaryForSpawn })` from `search.js`
|
|
29
30
|
- Returns `{ searchFilesystemFiles(rootPath, options) }`.
|
|
30
31
|
- Supports fuzzy matching, hidden-file handling, and optional `git check-ignore` filtering.
|
package/server/lib/fs/routes.js
CHANGED
|
@@ -267,6 +267,27 @@ const resolveWorkspacePathFromContext = async ({ req, targetPath, resolveProject
|
|
|
267
267
|
return resolved;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
+
// The active project directory is validated with fs.realpath, so the base is
|
|
271
|
+
// canonical while the client (and the file tree) addresses files under the
|
|
272
|
+
// user-visible root, which may itself be a symlink. Retry against the raw
|
|
273
|
+
// directory the client asked for so those paths stay addressable. Symlink
|
|
274
|
+
// resolution still happens afterwards, and the routes that need canonical
|
|
275
|
+
// containment re-check it against this base.
|
|
276
|
+
const requestedBase = resolvedProject.requestedDirectory;
|
|
277
|
+
if (typeof requestedBase === 'string' && requestedBase && requestedBase !== resolvedProject.directory) {
|
|
278
|
+
const lexical = resolveWorkspacePath({
|
|
279
|
+
targetPath,
|
|
280
|
+
baseDirectory: requestedBase,
|
|
281
|
+
path,
|
|
282
|
+
os,
|
|
283
|
+
normalizeDirectoryPath,
|
|
284
|
+
openchamberUserConfigRoot,
|
|
285
|
+
});
|
|
286
|
+
if (lexical.ok) {
|
|
287
|
+
return lexical;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
270
291
|
return resolveWorkspacePathFromWorktrees({
|
|
271
292
|
targetPath,
|
|
272
293
|
baseDirectory: resolvedProject.directory,
|
|
@@ -165,7 +165,7 @@ const registerUpload = (fsPromises) => {
|
|
|
165
165
|
return getRoute('POST', '/api/fs/upload');
|
|
166
166
|
};
|
|
167
167
|
|
|
168
|
-
const registerRead = (fsPromises) => {
|
|
168
|
+
const registerRead = (fsPromises, resolveProjectDirectory = async () => ({ directory: '/repo' })) => {
|
|
169
169
|
const { app, getRoute } = createRouteRegistry();
|
|
170
170
|
registerFsRoutes(app, {
|
|
171
171
|
os: { homedir: () => '/home/user' },
|
|
@@ -177,7 +177,7 @@ const registerRead = (fsPromises) => {
|
|
|
177
177
|
spawn: vi.fn(),
|
|
178
178
|
crypto: { randomUUID: () => 'job-0' },
|
|
179
179
|
normalizeDirectoryPath: (p) => p,
|
|
180
|
-
resolveProjectDirectory
|
|
180
|
+
resolveProjectDirectory,
|
|
181
181
|
buildAugmentedPath: () => '/usr/bin',
|
|
182
182
|
resolveGitBinaryForSpawn: () => 'git',
|
|
183
183
|
openchamberUserConfigRoot: '/home/user/.config',
|
|
@@ -682,8 +682,94 @@ describe('fs read', () => {
|
|
|
682
682
|
expect(warn).toHaveBeenCalledWith(expect.stringContaining('Read retry exhausted for /repo/file.txt'));
|
|
683
683
|
warn.mockRestore();
|
|
684
684
|
});
|
|
685
|
-
});
|
|
686
685
|
|
|
686
|
+
it('reads files inside the workspace whose canonical path escapes through a symlinked directory', async () => {
|
|
687
|
+
// ~/test_folder -> /outside/shared: the requested path is lexically inside
|
|
688
|
+
// the workspace, the realpath is not. The read must follow the symlink
|
|
689
|
+
// instead of rejecting it as an outside path.
|
|
690
|
+
const fsPromises = {
|
|
691
|
+
realpath: vi.fn(async (targetPath) => {
|
|
692
|
+
if (targetPath === '/repo/link/file.txt') return '/outside/shared/file.txt';
|
|
693
|
+
return targetPath;
|
|
694
|
+
}),
|
|
695
|
+
stat: vi.fn(async () => ({ isFile: () => true, size: 5 })),
|
|
696
|
+
readFile: vi.fn(async () => 'hello'),
|
|
697
|
+
};
|
|
698
|
+
const handler = registerRead(fsPromises);
|
|
699
|
+
|
|
700
|
+
const res = await callRead(handler, { path: '/repo/link/file.txt' });
|
|
701
|
+
|
|
702
|
+
expect(res.statusCode).toBe(200);
|
|
703
|
+
expect(res.body).toBe('hello');
|
|
704
|
+
expect(fsPromises.readFile).toHaveBeenCalledWith('/outside/shared/file.txt', 'utf8');
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
it('rejects reads of canonical paths outside the workspace that no workspace symlink reaches', async () => {
|
|
708
|
+
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
709
|
+
const fsPromises = {
|
|
710
|
+
stat: vi.fn(async () => ({ isFile: () => true, size: 6 })),
|
|
711
|
+
readFile: vi.fn(async () => 'secret'),
|
|
712
|
+
};
|
|
713
|
+
const handler = registerRead(fsPromises);
|
|
714
|
+
|
|
715
|
+
const res = await callRead(handler, { path: '/outside/shared/file.txt' });
|
|
716
|
+
|
|
717
|
+
expect(res.statusCode).toBe(400);
|
|
718
|
+
expect(res.body).toEqual({ error: 'Path is outside of active workspace' });
|
|
719
|
+
expect(fsPromises.readFile).not.toHaveBeenCalled();
|
|
720
|
+
warn.mockRestore();
|
|
721
|
+
});
|
|
722
|
+
|
|
723
|
+
it('reads files under a symlinked project root addressed via the client-sent lexical directory', async () => {
|
|
724
|
+
// /home/user/proj -> /real/proj: the validated base is canonical but the
|
|
725
|
+
// client (and the file tree) address files under the lexical root.
|
|
726
|
+
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
727
|
+
const fsPromises = {
|
|
728
|
+
realpath: vi.fn(async (targetPath) => {
|
|
729
|
+
if (targetPath === '/home/user/proj') return '/real/proj';
|
|
730
|
+
if (targetPath === '/home/user/proj/file.txt') return '/real/proj/file.txt';
|
|
731
|
+
return targetPath;
|
|
732
|
+
}),
|
|
733
|
+
stat: vi.fn(async () => ({ isFile: () => true, size: 4 })),
|
|
734
|
+
readFile: vi.fn(async () => 'data'),
|
|
735
|
+
};
|
|
736
|
+
const handler = registerRead(fsPromises, async () => ({
|
|
737
|
+
directory: '/real/proj',
|
|
738
|
+
requestedDirectory: '/home/user/proj',
|
|
739
|
+
}));
|
|
740
|
+
const res = createMockResponse();
|
|
741
|
+
|
|
742
|
+
await handler({
|
|
743
|
+
query: { path: '/home/user/proj/file.txt' },
|
|
744
|
+
get: (name) => (name === 'x-opencode-directory' ? '/home/user/proj' : undefined),
|
|
745
|
+
}, res);
|
|
746
|
+
|
|
747
|
+
expect(res.statusCode).toBe(200);
|
|
748
|
+
expect(res.body).toBe('data');
|
|
749
|
+
expect(fsPromises.readFile).toHaveBeenCalledWith('/real/proj/file.txt', 'utf8');
|
|
750
|
+
warn.mockRestore();
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
it('rejects path traversal that escapes the workspace even when it passes through a symlinked directory', async () => {
|
|
754
|
+
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
755
|
+
const fsPromises = {
|
|
756
|
+
realpath: vi.fn(async (targetPath) => {
|
|
757
|
+
if (targetPath === '/repo/link') return '/outside/shared';
|
|
758
|
+
return targetPath;
|
|
759
|
+
}),
|
|
760
|
+
stat: vi.fn(async () => ({ isFile: () => true, size: 6 })),
|
|
761
|
+
readFile: vi.fn(async () => 'secret'),
|
|
762
|
+
};
|
|
763
|
+
const handler = registerRead(fsPromises);
|
|
764
|
+
|
|
765
|
+
const res = await callRead(handler, { path: '/repo/sub/../../etc/passwd' });
|
|
766
|
+
|
|
767
|
+
expect(res.statusCode).toBe(400);
|
|
768
|
+
expect(res.body).toEqual({ error: 'Path is outside of active workspace' });
|
|
769
|
+
expect(fsPromises.readFile).not.toHaveBeenCalled();
|
|
770
|
+
warn.mockRestore();
|
|
771
|
+
});
|
|
772
|
+
});
|
|
687
773
|
describe('fs reveal', () => {
|
|
688
774
|
it.each([
|
|
689
775
|
['linux', 'xdg-open', ['/repo']],
|
|
@@ -40,7 +40,7 @@ The following functions are exported and used by the web server:
|
|
|
40
40
|
### Branch Operations
|
|
41
41
|
- `getBranches(directory)`: Get list of local and remote branches (filtered to active remote branches).
|
|
42
42
|
- `createBranch(directory, branchName, options)`: Create and checkout a new branch.
|
|
43
|
-
- `checkoutBranch(directory, branchName)`: Checkout an existing branch.
|
|
43
|
+
- `checkoutBranch(directory, branchName)`: Checkout an existing branch. A remote-tracking name (`origin/main`, or the `remotes/`-prefixed form) resolves to the local branch of that name, created with `--track` when it does not exist yet, because the branch selector offers remote branches as places to work rather than commits to inspect — a literal checkout of the remote ref would detach HEAD. A local branch whose own name looks like a remote ref wins over that resolution, and anything unresolvable is checked out as requested. The returned `branch` is the branch that was actually checked out, which callers should report instead of the requested name.
|
|
44
44
|
- `deleteBranch(directory, branch, options)`: Delete a branch (supports force flag).
|
|
45
45
|
- `renameBranch(directory, oldName, newName)`: Rename a branch and preserve upstream tracking.
|
|
46
46
|
- `getRemotes(directory)`: Get list of configured remotes.
|
|
@@ -121,9 +121,10 @@ The following functions are internal helpers used by exported functions:
|
|
|
121
121
|
- `rebaseInProgress`: Object with `{ headName, onto }` if rebase in progress.
|
|
122
122
|
|
|
123
123
|
### Branches Response
|
|
124
|
-
- `all`: Local branches plus remote-tracking branches that
|
|
124
|
+
- `all`: Local branches plus every branch each reachable remote reports via `ls-remote --heads`, formatted as `remotes/<remote>/<branch>`. This is a union: local remote-tracking refs deleted on the remote are pruned, and branches that exist on the remote without a local tracking ref (never fetched) are still included, so a freshly pushed branch appears without requiring a fetch. A remote that fails to answer keeps its locally known branches in the list: "we could not ask" must not be reported as "these branches are gone", because callers use this list to decide whether a base branch exists at all.
|
|
125
125
|
- `current`: Current branch name.
|
|
126
|
-
- `branches`: Per-branch detail keyed by branch name, as reported by `git branch`.
|
|
126
|
+
- `branches`: Per-branch detail keyed by branch name, as reported by `git branch`. Remote-only entries in `all` — branches `ls-remote` reported that were never fetched — have **no** entry here, because `git branch` never saw them. Consumers must treat a missing detail entry as normal and read the name from `all`.
|
|
127
|
+
- Never-fetched remote-only branches also have no local ref, so any operation that resolves one locally has to account for that: `checkoutBranch` fetches the single branch (`git fetch <remote> <branch>`) before creating the tracking branch, and the range helpers (`getRangeDiff`, `getRangeFiles`) reject an unresolvable ref with `Ref "<ref>" is not available locally. Fetch it before comparing.` instead of surfacing git's "ambiguous argument".
|
|
127
128
|
- `defaultBranches`: Each remote's default branch, keyed by remote name. Read from the local `remotes/<name>/HEAD` symbolic ref; for a remote that has none — clone writes it, a hand-added remote may not — the remote itself is asked once with `ls-remote --symref`. A remote that answers neither is absent rather than guessed, and consumers fall back to conventional branch names. Omitted entirely by runtimes that do not provide this Git metadata.
|
|
128
129
|
|
|
129
130
|
### Runtime availability of range diffs
|
|
@@ -2599,6 +2599,25 @@ export async function getUntrackedDiffs(directory, filePaths = [], { concurrency
|
|
|
2599
2599
|
return results;
|
|
2600
2600
|
}
|
|
2601
2601
|
|
|
2602
|
+
const refResolvesToCommit = async (git, ref) => git
|
|
2603
|
+
.raw(['rev-parse', '--verify', '--quiet', `${ref}^{commit}`])
|
|
2604
|
+
.then((value) => Boolean(String(value || '').trim()))
|
|
2605
|
+
.catch(() => false);
|
|
2606
|
+
|
|
2607
|
+
/**
|
|
2608
|
+
* The branch list includes remote-only branches that `ls-remote` reported but
|
|
2609
|
+
* the repository never fetched (#2098), so a comparison can name a ref that does
|
|
2610
|
+
* not exist locally. Say that plainly instead of letting git's "ambiguous
|
|
2611
|
+
* argument" surface as an opaque failure.
|
|
2612
|
+
*/
|
|
2613
|
+
async function assertRangeRefsResolve(git, refs) {
|
|
2614
|
+
for (const ref of refs) {
|
|
2615
|
+
if (!(await refResolvesToCommit(git, ref))) {
|
|
2616
|
+
throw new Error(`Ref "${ref}" is not available locally. Fetch it before comparing.`);
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2602
2621
|
export async function getRangeDiff(directory, { base, head, path: filePath, contextLines = 3 } = {}) {
|
|
2603
2622
|
const { directoryPath, directoryGit, repoRoot, git } = await createRepositoryGitContext(directory);
|
|
2604
2623
|
const baseRef = typeof base === 'string' ? base.trim() : '';
|
|
@@ -2641,6 +2660,8 @@ export async function getRangeDiff(directory, { base, head, path: filePath, cont
|
|
|
2641
2660
|
}
|
|
2642
2661
|
}
|
|
2643
2662
|
|
|
2663
|
+
await assertRangeRefsResolve(git, [resolvedBase, headRef]);
|
|
2664
|
+
|
|
2644
2665
|
const args = ['diff', '--no-color'];
|
|
2645
2666
|
if (typeof contextLines === 'number' && !Number.isNaN(contextLines)) {
|
|
2646
2667
|
args.push(`-U${Math.max(0, contextLines)}`);
|
|
@@ -2660,7 +2681,8 @@ const BRANCH_CREATION_SOURCE_RE = /^branch: Created from (.+)$/;
|
|
|
2660
2681
|
* Parse a branch reflog (`git reflog show --format=%gs <branch>`) and return the
|
|
2661
2682
|
* ref the branch was created from, when that source is itself a named ref.
|
|
2662
2683
|
*
|
|
2663
|
-
* Returns null when the branch was created from `HEAD
|
|
2684
|
+
* Returns null when the branch was created from `HEAD` (bare, as `git switch -c`
|
|
2685
|
+
* / `git checkout -b` without an explicit start point record) or a raw commit
|
|
2664
2686
|
* (detached start): the original branch name is not recorded anywhere in that
|
|
2665
2687
|
* case, and guessing a base from commit topology would be a heuristic, not an
|
|
2666
2688
|
* answer. Callers should ask the user to pick a base instead.
|
|
@@ -2675,7 +2697,9 @@ export function parseBranchCreationSource(reflogText) {
|
|
|
2675
2697
|
const match = lines[index].match(BRANCH_CREATION_SOURCE_RE);
|
|
2676
2698
|
if (!match) continue;
|
|
2677
2699
|
const source = match[1].trim();
|
|
2678
|
-
|
|
2700
|
+
// Bare `HEAD` (`git switch -c` from the current branch) and `HEAD@{...}`
|
|
2701
|
+
// (detached start) both lack a named source; a raw commit hash does too.
|
|
2702
|
+
if (!source || /^HEAD(@|$)/.test(source) || /^[0-9a-f]{7,40}$/i.test(source)) {
|
|
2679
2703
|
return null;
|
|
2680
2704
|
}
|
|
2681
2705
|
return source;
|
|
@@ -2738,6 +2762,8 @@ export async function getRangeFiles(directory, { base, head } = {}) {
|
|
|
2738
2762
|
// ignore
|
|
2739
2763
|
}
|
|
2740
2764
|
|
|
2765
|
+
await assertRangeRefsResolve(git, [resolvedBase, headRef]);
|
|
2766
|
+
|
|
2741
2767
|
// `-C` (copy detection among changed files only, so cheap) makes copies
|
|
2742
2768
|
// surface as C entries instead of plain additions; rename detection is on
|
|
2743
2769
|
// by default.
|
|
@@ -3744,7 +3770,7 @@ async function filterActiveRemoteBranches(git, remoteBranches) {
|
|
|
3744
3770
|
}
|
|
3745
3771
|
}));
|
|
3746
3772
|
|
|
3747
|
-
|
|
3773
|
+
const activeBranches = remoteBranches.filter(remoteBranch => {
|
|
3748
3774
|
const match = remoteBranch.match(/^remotes\/[^\/]+\/(.+)$/);
|
|
3749
3775
|
if (!match) return false;
|
|
3750
3776
|
const remoteName = remoteBranch.split('/')[1];
|
|
@@ -3752,6 +3778,25 @@ async function filterActiveRemoteBranches(git, remoteBranches) {
|
|
|
3752
3778
|
if (unreachableRemotes.has(remoteName)) return true;
|
|
3753
3779
|
return branchesByRemote.get(remoteName)?.has(branchName) ?? false;
|
|
3754
3780
|
});
|
|
3781
|
+
|
|
3782
|
+
// A branch pushed to the remote that was never fetched locally has no
|
|
3783
|
+
// remote-tracking ref, so `git branch` never reports it — but ls-remote
|
|
3784
|
+
// just told us it exists. Add those so a freshly pushed branch shows up
|
|
3785
|
+
// without requiring a fetch first (#2098). Unreachable remotes have no
|
|
3786
|
+
// ls-remote data and therefore add nothing here; their local view above
|
|
3787
|
+
// is preserved unchanged.
|
|
3788
|
+
const seenBranches = new Set(activeBranches);
|
|
3789
|
+
for (const [remoteName, actualRemoteBranches] of branchesByRemote) {
|
|
3790
|
+
for (const branchName of actualRemoteBranches) {
|
|
3791
|
+
const qualifiedBranch = `remotes/${remoteName}/${branchName}`;
|
|
3792
|
+
if (!seenBranches.has(qualifiedBranch)) {
|
|
3793
|
+
seenBranches.add(qualifiedBranch);
|
|
3794
|
+
activeBranches.push(qualifiedBranch);
|
|
3795
|
+
}
|
|
3796
|
+
}
|
|
3797
|
+
}
|
|
3798
|
+
|
|
3799
|
+
return activeBranches;
|
|
3755
3800
|
} catch (error) {
|
|
3756
3801
|
console.warn('Failed to filter active remote branches, returning all:', error.message);
|
|
3757
3802
|
return remoteBranches;
|
|
@@ -3770,12 +3815,81 @@ export async function createBranch(directory, branchName, options = {}) {
|
|
|
3770
3815
|
}
|
|
3771
3816
|
}
|
|
3772
3817
|
|
|
3818
|
+
// Deliberately not `--quiet`: simple-git resolves a quiet non-zero exit as
|
|
3819
|
+
// success, so the ref itself has to be echoed for the answer to mean anything.
|
|
3820
|
+
const gitRefExists = async (git, ref) => {
|
|
3821
|
+
try {
|
|
3822
|
+
const output = await git.raw(['show-ref', '--verify', ref]);
|
|
3823
|
+
return String(output).trim().length > 0;
|
|
3824
|
+
} catch {
|
|
3825
|
+
return false;
|
|
3826
|
+
}
|
|
3827
|
+
};
|
|
3828
|
+
|
|
3829
|
+
/**
|
|
3830
|
+
* The branch selector lists remote-tracking branches beside local ones, so
|
|
3831
|
+
* picking `origin/main` means "work on main", not "detach HEAD at the remote's
|
|
3832
|
+
* commit" — which is what a literal checkout of a remote-tracking ref does.
|
|
3833
|
+
* Resolve such a pick to the local branch, creating it with tracking when it
|
|
3834
|
+
* does not exist yet. Anything we cannot resolve is checked out as requested,
|
|
3835
|
+
* leaving git's own DWIM behavior intact.
|
|
3836
|
+
*/
|
|
3837
|
+
const resolveBranchCheckoutTarget = async (git, branchName) => {
|
|
3838
|
+
const requested = String(branchName || '').trim();
|
|
3839
|
+
if (!requested) {
|
|
3840
|
+
throw new Error('Branch name is required');
|
|
3841
|
+
}
|
|
3842
|
+
|
|
3843
|
+
const asRequested = { branch: requested, remoteRef: null };
|
|
3844
|
+
|
|
3845
|
+
if (await gitRefExists(git, `refs/heads/${requested}`)) {
|
|
3846
|
+
return asRequested;
|
|
3847
|
+
}
|
|
3848
|
+
|
|
3849
|
+
const remoteRef = requested.replace(/^remotes\//, '');
|
|
3850
|
+
const remotes = await git.getRemotes();
|
|
3851
|
+
const remote = remotes.find((entry) => entry?.name && remoteRef.startsWith(`${entry.name}/`));
|
|
3852
|
+
if (!remote) {
|
|
3853
|
+
return asRequested;
|
|
3854
|
+
}
|
|
3855
|
+
|
|
3856
|
+
const localBranch = remoteRef.slice(remote.name.length + 1);
|
|
3857
|
+
// `origin/HEAD` names no branch of its own; it is a pointer to one.
|
|
3858
|
+
if (!localBranch || localBranch === 'HEAD') {
|
|
3859
|
+
return asRequested;
|
|
3860
|
+
}
|
|
3861
|
+
|
|
3862
|
+
// The branch list also carries branches that only `ls-remote` knows about
|
|
3863
|
+
// (#2098): they exist on the remote but were never fetched, so there is no
|
|
3864
|
+
// remote-tracking ref and a literal checkout fails with a pathspec error.
|
|
3865
|
+
// Fetch the single branch first so the tracking ref exists, then fall through
|
|
3866
|
+
// to the normal create-with-tracking path.
|
|
3867
|
+
if (!(await gitRefExists(git, `refs/remotes/${remoteRef}`))) {
|
|
3868
|
+
try {
|
|
3869
|
+
await git.fetch(remote.name, localBranch);
|
|
3870
|
+
} catch (error) {
|
|
3871
|
+
throw new Error(`Failed to fetch ${localBranch} from ${remote.name}: ${error?.message || error}`);
|
|
3872
|
+
}
|
|
3873
|
+
if (!(await gitRefExists(git, `refs/remotes/${remoteRef}`))) {
|
|
3874
|
+
throw new Error(`Branch ${localBranch} no longer exists on remote ${remote.name}`);
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
|
|
3878
|
+
const localExists = await gitRefExists(git, `refs/heads/${localBranch}`);
|
|
3879
|
+
return { branch: localBranch, remoteRef: localExists ? null : remoteRef };
|
|
3880
|
+
};
|
|
3881
|
+
|
|
3773
3882
|
export async function checkoutBranch(directory, branchName) {
|
|
3774
3883
|
const { git } = await createRepositoryGitContext(directory);
|
|
3775
3884
|
|
|
3776
3885
|
try {
|
|
3777
|
-
await git
|
|
3778
|
-
|
|
3886
|
+
const target = await resolveBranchCheckoutTarget(git, branchName);
|
|
3887
|
+
if (target.remoteRef) {
|
|
3888
|
+
await git.raw(['checkout', '-b', target.branch, '--track', target.remoteRef]);
|
|
3889
|
+
} else {
|
|
3890
|
+
await git.checkout(target.branch);
|
|
3891
|
+
}
|
|
3892
|
+
return { success: true, branch: target.branch };
|
|
3779
3893
|
} catch (error) {
|
|
3780
3894
|
console.error('Failed to checkout branch:', error);
|
|
3781
3895
|
throw error;
|
|
@@ -3895,7 +4009,15 @@ export async function getWorktrees(directory) {
|
|
|
3895
4009
|
path: entry.worktree,
|
|
3896
4010
|
}));
|
|
3897
4011
|
} catch (error) {
|
|
3898
|
-
|
|
4012
|
+
// Worktrees are an optional feature. When the caller passes a directory
|
|
4013
|
+
// that is not inside any git repository (for example, the managed
|
|
4014
|
+
// OpenCode's working directory or an unconfigured project path), git
|
|
4015
|
+
// exits with "fatal: not a git repository ...". Treat that as an
|
|
4016
|
+
// authoritative empty result so the route handler can still respond
|
|
4017
|
+
// 200 [] and the desktop main.log stays free of noise.
|
|
4018
|
+
if (!isNotGitRepositoryError(error)) {
|
|
4019
|
+
console.warn('Failed to list worktrees, returning empty list:', error?.message || error);
|
|
4020
|
+
}
|
|
3899
4021
|
return [];
|
|
3900
4022
|
}
|
|
3901
4023
|
}
|