@openchamber/web 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AboutDialog-C1ulAXh5.js +1 -0
- package/dist/assets/ArchiveView-DJo1Bpw_.js +1 -0
- package/dist/assets/{CommandPalette-1VlA7PbL.js → CommandPalette-B6r6DPF9.js} +2 -2
- package/dist/assets/{DiffView-SHdJJ6tl.js → DiffView-mJuVm7Z4.js} +2 -2
- package/dist/assets/{FilePreviewCommentMenu-DlVgwRsr.js → FilePreviewCommentMenu-Ca4ziuof.js} +1 -1
- package/dist/assets/{FilesView-BeMtsSlV.js → FilesView-BBFbfDp9.js} +3 -3
- package/dist/assets/{GitView-npRGKKx8.js → GitView-WL1wkRFF.js} +3 -3
- package/dist/assets/GuestSurfacePane-peVDY5gW.js +1 -0
- package/dist/assets/HelpDialog-Dxc2yneu.js +1 -0
- package/dist/assets/{InProgressOperationBanner-B6iO22_7.js → InProgressOperationBanner-Dy0RiPsD.js} +1 -1
- package/dist/assets/JsonTreeView-BKUmh7Iw.js +1 -0
- package/dist/assets/MarkdownImageGallery-Cd6hLNmi.js +1 -0
- package/dist/assets/MarkdownRendererImpl-C-3B3mBt.js +1 -0
- package/dist/assets/MemoryDebugPanel-b116r1SF.js +1 -0
- package/dist/assets/OnboardingScreen-vBEhpU3q.js +1 -0
- package/dist/assets/OpenCodeStatusDialog-DH7dJ6MH.js +1 -0
- package/dist/assets/{PatchDiff-Du2s7T3U.js → PatchDiff-yM7vgQgi.js} +1 -1
- package/dist/assets/{PierreDiffViewer-B9K0gBvV.js → PierreDiffViewer-DnHKbYGl.js} +1 -1
- package/dist/assets/{PlanView-IkTcPrbw.js → PlanView-j0hLJmto.js} +2 -2
- package/dist/assets/RunOverview-ZuFZvDcu.js +2 -0
- package/dist/assets/ScheduledTasksDialog-UKXFFI91.js +5 -0
- package/dist/assets/{SettingsView-DIy5ZL4-.js → SettingsView-gB_NvyX4.js} +8 -8
- package/dist/assets/SettingsWindow-Dfb_RFpD.js +1 -0
- package/dist/assets/SourceBoardView-BjaL0nKs.js +1 -0
- package/dist/assets/SpaceAccessDialog-XzHRmIdT.js +1 -0
- package/dist/assets/SpaceApplyDialog-CxX9mrzT.js +1 -0
- package/dist/assets/{SpaceRow-YPmKQKeD.js → SpaceRow-vCpOCANO.js} +1 -1
- package/dist/assets/SpaceSetupOutput-CDZvJCf_.js +1 -0
- package/dist/assets/SpacesView-D3a9bCzn.js +1 -0
- package/dist/assets/{SubmoduleDiffSummary-RDY5md3p.js → SubmoduleDiffSummary-CQyRcvDZ.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Dx85XZJs.js → ToolOutputDialog-judR_5mS.js} +2 -2
- package/dist/assets/{ToolPartDiffPreview-Dtv0xF9O.js → ToolPartDiffPreview-Ca9ISxfg.js} +1 -1
- package/dist/assets/UsageStatsView-C63Emjfj.js +1 -0
- package/dist/assets/{Virtualizer-DL535kyR.js → Virtualizer-DNgIEKcx.js} +1 -1
- package/dist/assets/{WalkthroughView-DcxbT5tc.js → WalkthroughView-D74b_7sC.js} +2 -2
- package/dist/assets/WorktreesView-hcm8Eb_C.js +1 -0
- package/dist/assets/appThemeRegistry-COeayQaQ.js +1 -0
- package/dist/assets/{ar-lP51qqz9.js → ar-1_zdYVV5.js} +2 -2
- package/dist/assets/computeVirtualFileMetrics-MZqvCQy0.js +3 -0
- package/dist/assets/{de-CpROAvTV.js → de-Ci7SGEQP.js} +3 -3
- package/dist/assets/{decorate-BNB7jeKg.js → decorate-CZeRRVC7.js} +1 -1
- package/dist/assets/{es-Bb8LKRhE.js → es-ZJii-6Tt.js} +2 -2
- package/dist/assets/{fr-BlNN9FC2.js → fr-C-hK8mvI.js} +2 -2
- package/dist/assets/{he-r546pCuc.js → he-t07CylP8.js} +2 -2
- package/dist/assets/index-D2tPUss-.js +1 -0
- package/dist/assets/{initializeSharedPreferences-dCHO04bl.js → initializeSharedPreferences-FxFkTjgn.js} +1 -1
- package/dist/assets/{isDiffPlainText-BwicHPpI.js → isDiffPlainText-C1F9opE5.js} +1 -1
- package/dist/assets/{isFilePlainText-Dk2R7BJo.js → isFilePlainText-B4SyJ-ni.js} +1 -1
- package/dist/assets/{ja-evNvJAHz.js → ja-iJr8aONy.js} +2 -2
- package/dist/assets/{katex-CMY-1eWf.css → katex-BEX7X_K8.css} +1 -1
- package/dist/assets/{katex.min-Iw9WSgM9.js → katex.min-C-51hS9A.js} +18 -18
- package/dist/assets/{ko-BPQP7lXe.js → ko-D5ow_yz-.js} +2 -2
- package/dist/assets/main-BtGnuno4.js +1048 -0
- package/dist/assets/main-uj5954n5.js +2 -0
- package/dist/assets/markdownCore-rBXCnAJp.js +9 -0
- package/dist/assets/miniChat-yWQmT2OS.js +2 -0
- package/dist/assets/mobile-NDAeGtzL.js +2 -0
- package/dist/assets/{moveWorkspacePath-B31RGdgu.js → moveWorkspacePath-BINgpJ9S.js} +1 -1
- package/dist/assets/{nl-CkQXd1nU.js → nl-CfqYrSVe.js} +2 -2
- package/dist/assets/{parseDiffFromFile-DcsKSY0J.js → parseDiffFromFile--DE4eHIp.js} +2 -2
- package/dist/assets/{patchFileDiff-Cx-HpjyI.js → patchFileDiff-BfFUmWgS.js} +1 -1
- package/dist/assets/pierreDiffTint-D9K6_CVD.js +29 -0
- package/dist/assets/{pl-C4i9Aizi.js → pl-Bn2_jAhL.js} +4 -4
- package/dist/assets/{pt-BR-CoYnG1CH.js → pt-BR-ZSDgn6cI.js} +2 -2
- package/dist/assets/relocateRestoredSession-C85Tk2y9.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-BvAEmWhZ.js +2 -0
- package/dist/assets/{renderMobileApp-gDKxRJQi.js → renderMobileApp-T20l8ise.js} +7 -7
- package/dist/assets/{restartOpenCode-dq-SGun3.js → restartOpenCode-VEmIrLer.js} +1 -1
- package/dist/assets/runtimeEndpointReset-ExJsaWzA.js +55 -0
- package/dist/assets/scheduledTasksApi-NSyxVfHu.js +1 -0
- package/dist/assets/{selectionMarkdown-sDTBbKLh.js → selectionMarkdown-BJ2RhTXc.js} +2 -2
- package/dist/assets/{sessionOwnership-kZAtwMQd.js → sessionOwnership-BAX1xEJC.js} +1 -1
- package/dist/assets/{shikiHighlight-BRNXPlF-.js → shikiHighlight-DOzrE7BE.js} +1 -1
- package/dist/assets/{space-apply-CCOKLfrX.js → space-apply-DB_ZfJBW.js} +1 -1
- package/dist/assets/space-close-1kNlTkW1.js +1 -0
- package/dist/assets/{spaceNetwork-DUxJClu3.js → spaceNetwork-DA16ov_y.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-B6UJwdZz.js → textMateThemeFromAppTheme-BfIrjFAU.js} +1 -1
- package/dist/assets/{tr-D-_lz-lC.js → tr-C89uz1hs.js} +2 -2
- package/dist/assets/{uk-B49PGMYB.js → uk-uTYVPFrO.js} +2 -2
- package/dist/assets/{useAppFontEffects-3EN8Ava3.js → useAppFontEffects-C1ceAD51.js} +185 -185
- package/dist/assets/useCallableModelProviders-BkLsgs6y.js +1 -0
- package/dist/assets/{useInlineCommentController-l9cWyfuR.js → useInlineCommentController-ynkUsoVA.js} +1 -1
- package/dist/assets/{useRootScrollLock-UAQn24Y8.js → useRootScrollLock-DnoKH1HE.js} +2 -2
- package/dist/assets/{vendor-codemirror-autocomplete-C8FBSI9t.js → vendor-codemirror-autocomplete-BRKmCSiY.js} +1 -1
- package/dist/assets/{vendor-codemirror-commands-BhRb6jns.js → vendor-codemirror-commands-MmBpgSOc.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-angular-Bj5Pk8sp.js +1 -0
- package/dist/assets/vendor-codemirror-lang-cpp-tZt-BOgi.js +1 -0
- package/dist/assets/vendor-codemirror-lang-css-DfdrZ848.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-go-BHJEONih.js → vendor-codemirror-lang-go-C9OcoXdP.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-html-C5kFuJzc.js +1 -0
- package/dist/assets/vendor-codemirror-lang-java-Divn2dnj.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-javascript-CUmSxayT.js → vendor-codemirror-lang-javascript-DmPuKUEa.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-jinja-B-8miA-Q.js +1 -0
- package/dist/assets/vendor-codemirror-lang-json-L0wsFFxi.js +1 -0
- package/dist/assets/vendor-codemirror-lang-less-CWlCIxCI.js +1 -0
- package/dist/assets/vendor-codemirror-lang-liquid-Dm8xthAW.js +1 -0
- package/dist/assets/vendor-codemirror-lang-markdown-CPn-qinN.js +1 -0
- package/dist/assets/vendor-codemirror-lang-php-DKIOifjN.js +1 -0
- package/dist/assets/vendor-codemirror-lang-python-BAVa3Hg5.js +3 -0
- package/dist/assets/vendor-codemirror-lang-rust-Dab90hdg.js +1 -0
- package/dist/assets/vendor-codemirror-lang-sass-eezaHFBZ.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-sql-C1Jj9uuJ.js → vendor-codemirror-lang-sql-Vu-PR7cv.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-vue-BthRGZHy.js +1 -0
- package/dist/assets/vendor-codemirror-lang-wast-Db6KSic0.js +1 -0
- package/dist/assets/vendor-codemirror-lang-xml-DQkh4sc1.js +1 -0
- package/dist/assets/vendor-codemirror-lang-yaml-Bt2N__AW.js +1 -0
- package/dist/assets/vendor-codemirror-language-DkBxRck3.js +3 -0
- package/dist/assets/vendor-codemirror-language-data-CTYHXywt.js +2 -0
- package/dist/assets/{vendor-codemirror-search-CvXM_pZg.js → vendor-codemirror-search-BKAwkhkm.js} +1 -1
- package/dist/assets/vendor-codemirror-streamparser-CmlTsbN2.js +1 -0
- package/dist/assets/vendor-codemirror-view-B66jUSmE.js +4 -0
- package/dist/assets/{vendor-replit-codemirror-vim-Ck2X_WZC.js → vendor-replit-codemirror-vim-D0bqFa1D.js} +5 -5
- package/dist/assets/{worker-DdhrXE7g.js → worker-BbEdJ2Oi.js} +18 -18
- package/dist/assets/workerFactory-Bw5qLmrM.js +1 -0
- package/dist/assets/{zh-CN-CS-9Os9n.js → zh-CN-DdTNG52a.js} +2 -2
- package/dist/assets/{zh-TW-D0XYVdcl.js → zh-TW-DPm_33Fi.js} +2 -2
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +2 -2
- package/server/index.js +4 -0
- package/server/lib/environment/store.js +3 -4
- package/server/lib/environment/store.test.js +17 -0
- package/server/lib/fs/DOCUMENTATION.md +4 -2
- package/server/lib/fs/routes.js +48 -13
- package/server/lib/fs/routes.test.js +118 -5
- package/server/lib/git/DOCUMENTATION.md +3 -1
- package/server/lib/git/contributor-remote.js +4 -0
- package/server/lib/git/contributor-remote.test.js +21 -0
- package/server/lib/git/service.js +20 -25
- package/server/lib/git/service.test.js +99 -0
- package/server/lib/git/worktree-creation.js +4 -5
- package/server/lib/github/DOCUMENTATION.md +1 -1
- package/server/lib/github/routes.auth.test.js +14 -0
- package/server/lib/github/routes.js +13 -5
- package/server/lib/github/routes.mutations.test.js +18 -2
- package/server/lib/message-queue/DOCUMENTATION.md +8 -2
- package/server/lib/message-queue/runtime.js +3 -2
- package/server/lib/message-queue/runtime.test.js +64 -2
- package/server/lib/openchamber-control/service.js +48 -13
- package/server/lib/openchamber-control/service.test.js +42 -0
- package/server/lib/opencode/DOCUMENTATION.md +3 -1
- package/server/lib/opencode/project-start-command.d.ts +11 -0
- package/server/lib/opencode/project-start-command.js +56 -0
- package/server/lib/opencode/project-start-command.test.js +80 -0
- package/server/lib/opencode/session-activity.js +43 -3
- package/server/lib/opencode/session-activity.test.js +97 -0
- package/server/lib/opencode/settings-runtime.js +19 -1
- package/server/lib/opencode/settings-runtime.test.js +23 -0
- package/server/lib/opencode/skill-routes.js +34 -1
- package/server/lib/opencode/skill-routes.test.js +99 -0
- package/server/lib/quota/DOCUMENTATION.md +13 -1
- package/server/lib/quota/providers/antigravity/api.js +104 -0
- package/server/lib/quota/providers/antigravity/auth.js +45 -0
- package/server/lib/quota/providers/antigravity/index.js +76 -0
- package/server/lib/quota/providers/antigravity/transforms.js +168 -0
- package/server/lib/quota/providers/antigravity/transforms.test.js +162 -0
- package/server/lib/quota/providers/codex.js +28 -4
- package/server/lib/quota/providers/codex.test.js +29 -0
- package/server/lib/quota/providers/google/auth.js +4 -49
- package/server/lib/quota/providers/google/transforms.js +3 -22
- package/server/lib/quota/providers/index.js +8 -0
- package/server/lib/quota/providers/opencode-go.js +3 -1
- package/server/lib/quota/providers/opencode-go.test.js +12 -0
- package/server/lib/routing/DOCUMENTATION.md +3 -1
- package/server/lib/routing/runtime.js +34 -1
- package/server/lib/routing/runtime.test.js +43 -1
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +11 -0
- package/server/lib/scheduled-tasks/existing-session.js +52 -8
- package/server/lib/scheduled-tasks/existing-session.test.js +121 -0
- package/server/lib/scheduled-tasks/routes.js +26 -0
- package/server/lib/scheduled-tasks/runtime.js +1 -0
- package/server/lib/session-assist/runtime.js +3 -0
- package/server/lib/session-assist/runtime.test.js +47 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +10 -1
- package/server/lib/skills-catalog/install.js +1 -1
- package/server/lib/skills-catalog/installed-sources.d.ts +17 -0
- package/server/lib/skills-catalog/installed-sources.js +112 -0
- package/server/lib/skills-catalog/installed-sources.test.js +94 -0
- package/server/lib/small-model/DOCUMENTATION.md +12 -5
- package/server/lib/small-model/index.js +6 -4
- package/server/lib/small-model/index.test.js +40 -0
- package/server/lib/small-model/routes.js +3 -2
- package/server/lib/source-control/change-request-worktree.js +2 -6
- package/server/lib/source-control/mutation-storage.js +4 -1
- package/server/lib/source-control/mutation-storage.test.js +21 -0
- package/server/lib/spaces/DOCUMENTATION.md +1 -1
- package/server/lib/spaces/journey.js +10 -3
- package/server/lib/spaces/journey.test.js +13 -1
- package/server/lib/terminal/history.js +22 -2
- package/server/lib/terminal/history.test.js +23 -0
- package/server/lib/terminal/theme-response.js +14 -0
- package/server/lib/terminal/theme-response.test.js +10 -0
- package/dist/assets/AboutDialog-e8ek_kPI.js +0 -1
- package/dist/assets/ArchiveView-CjF4_TFg.js +0 -1
- package/dist/assets/GuestSurfacePane-4kmEXPLD.js +0 -1
- package/dist/assets/HelpDialog-CITMqPDK.js +0 -1
- package/dist/assets/JsonTreeView-xGikhCtL.js +0 -1
- package/dist/assets/MarkdownImageGallery-D0FJyr7C.js +0 -1
- package/dist/assets/MarkdownRendererImpl-BIM7Pjwk.js +0 -1
- package/dist/assets/MemoryDebugPanel-CBk8QW-M.js +0 -1
- package/dist/assets/OnboardingScreen-Cy6ARiMS.js +0 -1
- package/dist/assets/OpenCodeStatusDialog-YMHuJzwt.js +0 -1
- package/dist/assets/RunOverview-CHkGSW1x.js +0 -2
- package/dist/assets/ScheduledTasksDialog-77SO8zdJ.js +0 -4
- package/dist/assets/SettingsWindow-X74FIkdo.js +0 -1
- package/dist/assets/SourceBoardView-Cff2ejOW.js +0 -1
- package/dist/assets/SpaceAccessDialog-BXMZNRei.js +0 -1
- package/dist/assets/SpaceApplyDialog-BEJd2ryu.js +0 -1
- package/dist/assets/SpaceSetupOutput-Cb3XcIII.js +0 -1
- package/dist/assets/SpacesView-I3HaRKtW.js +0 -1
- package/dist/assets/UsageStatsView-DwTt9zIz.js +0 -1
- package/dist/assets/WorktreesView-Bh7GLvrR.js +0 -1
- package/dist/assets/appThemeRegistry-Bzb67M9O.js +0 -1
- package/dist/assets/computeVirtualFileMetrics-WAp98Bb7.js +0 -3
- package/dist/assets/index-BsupKM40.js +0 -1
- package/dist/assets/main-C_QGhDBL.js +0 -1048
- package/dist/assets/main-pWZ7F_hy.js +0 -2
- package/dist/assets/markdownCore-6gz4uJDQ.js +0 -9
- package/dist/assets/miniChat-DnaTfdYh.js +0 -2
- package/dist/assets/mobile-C7DIJqP8.js +0 -2
- package/dist/assets/pierreDiffTint-B297eqF0.js +0 -28
- package/dist/assets/relocateRestoredSession-D3lujODj.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-BF4hNe69.js +0 -2
- package/dist/assets/runtimeEndpointReset-D6Lxhk0S.js +0 -55
- package/dist/assets/scheduledTasksApi-DUbAMrjW.js +0 -1
- package/dist/assets/space-close-CWcWwH4_.js +0 -1
- package/dist/assets/useCallableModelProviders-BB9xkUzM.js +0 -1
- package/dist/assets/vendor-codemirror-lang-angular-BpYCRJSk.js +0 -1
- package/dist/assets/vendor-codemirror-lang-cpp-BI3uPyjT.js +0 -1
- package/dist/assets/vendor-codemirror-lang-css-B2_PZTBl.js +0 -1
- package/dist/assets/vendor-codemirror-lang-html-BpvvTxbZ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-java-BM5LQZ4u.js +0 -1
- package/dist/assets/vendor-codemirror-lang-jinja-D8nLZQPK.js +0 -1
- package/dist/assets/vendor-codemirror-lang-json-VDxF27mO.js +0 -1
- package/dist/assets/vendor-codemirror-lang-less-BecU2BJP.js +0 -1
- package/dist/assets/vendor-codemirror-lang-liquid-DCw83Anh.js +0 -1
- package/dist/assets/vendor-codemirror-lang-markdown-CimQAQbQ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-php-C5Kpnpyb.js +0 -1
- package/dist/assets/vendor-codemirror-lang-python-BFE1OJNx.js +0 -3
- package/dist/assets/vendor-codemirror-lang-rust-hqZDyGIJ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-sass-CAZML-Jl.js +0 -1
- package/dist/assets/vendor-codemirror-lang-vue-BHOTXcKp.js +0 -1
- package/dist/assets/vendor-codemirror-lang-wast-DcCHfPUI.js +0 -1
- package/dist/assets/vendor-codemirror-lang-xml-BO_V-1wZ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-yaml-CPimap_N.js +0 -1
- package/dist/assets/vendor-codemirror-language-BBADuAkg.js +0 -3
- package/dist/assets/vendor-codemirror-language-data-Cu5ZbrPm.js +0 -2
- package/dist/assets/vendor-codemirror-view-1e0FQ6Wn.js +0 -4
- package/dist/assets/workerFactory-De9YXIdE.js +0 -1
|
@@ -263,6 +263,48 @@ describe('OpenChamber control service', () => {
|
|
|
263
263
|
expect(moveToWorktree).toHaveBeenCalledTimes(1);
|
|
264
264
|
});
|
|
265
265
|
|
|
266
|
+
it('finds the target session directory on a later session.list page', async () => {
|
|
267
|
+
const { service, client } = createService();
|
|
268
|
+
client.session.list
|
|
269
|
+
.mockResolvedValueOnce({ data: [{ id: 'ses_early', location: { directory: '/repo' } }], cursor: { next: 'page-2' } })
|
|
270
|
+
.mockResolvedValueOnce({ data: [{ id: 'ses_target', location: { directory: '/repo/worktrees/target' } }], cursor: { next: null } });
|
|
271
|
+
|
|
272
|
+
await expect(service.resolveSessionDirectory('ses_target')).resolves.toBe('/repo/worktrees/target');
|
|
273
|
+
expect(client.session.list).toHaveBeenNthCalledWith(2, { cursor: 'page-2' });
|
|
274
|
+
expect(client.session.list).toHaveBeenCalledTimes(2);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('keeps paging session.list until the requested limit is satisfied', async () => {
|
|
278
|
+
const { service, client } = createService();
|
|
279
|
+
client.session.list
|
|
280
|
+
.mockResolvedValueOnce({ data: [{ id: 'ses_1', location: { directory: '/repo' }, time: {} }], cursor: { next: 'page-2' } })
|
|
281
|
+
.mockResolvedValueOnce({ data: [{ id: 'ses_2', location: { directory: '/other' }, time: {} }], cursor: { next: null } });
|
|
282
|
+
|
|
283
|
+
await expect(service.execute('session.list', { limit: 2 })).resolves.toEqual({
|
|
284
|
+
sessions: [
|
|
285
|
+
{ id: 'ses_1', location: { directory: '/repo' }, time: {} },
|
|
286
|
+
{ id: 'ses_2', location: { directory: '/other' }, time: {} },
|
|
287
|
+
],
|
|
288
|
+
limit: 2,
|
|
289
|
+
directory: null,
|
|
290
|
+
archived: 'excluded',
|
|
291
|
+
});
|
|
292
|
+
expect(client.session.list).toHaveBeenNthCalledWith(2, { cursor: 'page-2' });
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it('stops paging the session list when a cursor repeats', async () => {
|
|
296
|
+
const { service, client } = createService();
|
|
297
|
+
client.session.list.mockResolvedValue({
|
|
298
|
+
data: [{ id: 'ses_1', location: { directory: '/repo' }, time: {} }],
|
|
299
|
+
cursor: { next: 'loop' },
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
const { sessions } = await service.execute('session.list', { limit: 10 });
|
|
303
|
+
|
|
304
|
+
expect(sessions).toEqual([{ id: 'ses_1', location: { directory: '/repo' }, time: {} }]);
|
|
305
|
+
expect(client.session.list).toHaveBeenCalledTimes(2);
|
|
306
|
+
});
|
|
307
|
+
|
|
266
308
|
it('falls back to the context directory when the session is not in the global list', async () => {
|
|
267
309
|
const { service, sessionService } = createService();
|
|
268
310
|
sessionService.send.mockResolvedValue({ sessionId: 'ses_unknown', directory: '/repo', promptDispatched: true });
|
|
@@ -6,6 +6,7 @@ This module provides OpenCode server integration utilities for the web server ru
|
|
|
6
6
|
## Entrypoints and structure
|
|
7
7
|
- `packages/web/server/lib/opencode/index.js`: public entrypoint (currently baseline placeholder).
|
|
8
8
|
- `packages/web/server/lib/opencode/auth.js`: provider authentication file operations.
|
|
9
|
+
- `packages/web/server/lib/opencode/project-start-command.js`: the project's start command (`commands.start`) that the web server and the VS Code extension host run in every worktree they create. OpenCode 2.x keeps it on its project record, so the reader asks the running OpenCode in the directory the worktree is requested from (the contributor trust prompt asks in the primary checkout, never inside the fork's checkout): `GET /api/location` names the project, whose ID 2.x derives from the origin remote and so differs from OpenChamber's root-commit worktree ID, and `GET /api/project` holds the record. A failed read runs no command and logs a warning; the worktree is still created. Wired once per runtime with `configureProjectStartCommandSource`, the way `auth.js` is.
|
|
9
10
|
- `packages/web/server/lib/opencode/auth-state-runtime.js`: managed OpenCode server auth password/header runtime.
|
|
10
11
|
- `packages/web/server/lib/opencode/cli-options.js`: CLI/environment option parsing for server startup arguments.
|
|
11
12
|
- `packages/web/server/lib/opencode/cli-entry-runtime.js`: CLI entrypoint runtime that detects direct execution, parses CLI options, and starts server bootstrap.
|
|
@@ -63,7 +64,7 @@ and OpenChamber resolves the directory itself.
|
|
|
63
64
|
- `packages/web/server/lib/opencode/pwa-manifest-routes.js`: PWA manifest route registration with recent-session shortcut resolution and short-lived caching.
|
|
64
65
|
- `packages/web/server/lib/opencode/project-icon-routes.js`: project icon upload/read/discovery route registration and icon storage orchestration.
|
|
65
66
|
- `packages/web/server/lib/opencode/skill-routes.js`: route registration for skill config CRUD, supporting files, and skills catalog scan/install flows.
|
|
66
|
-
- `packages/web/server/lib/opencode/settings-runtime.js`: Settings persistence runtime (disk IO, migrations, normalization, project validation, and persisted update serialization).
|
|
67
|
+
- `packages/web/server/lib/opencode/settings-runtime.js`: Settings persistence runtime (disk IO, migrations, normalization, project validation, and persisted update serialization). With no project stored, the legacy migration turns a stored `lastDirectory` into the first project, except a folder inside the chats roots (`chatRoots` dep, compared lexically and by realpath): with no project open the UI's last directory is usually a chat's, and a chat belongs to no project.
|
|
67
68
|
- `packages/web/server/lib/opencode/settings-helpers.js`: Settings payload sanitization/format helpers runtime for response shaping and persisted merge prep. `lastDirectory: ''` is kept as written: the UI sends it when the last project is removed, and every reader (the warm-up, the legacy last-directory-to-project migration, request directory resolution) treats it as unset.
|
|
68
69
|
- `packages/web/server/lib/opencode/settings-normalization-runtime.js`: path/settings/tunnel normalization and sanitization helpers runtime used by settings/routes/config wiring.
|
|
69
70
|
- `packages/web/server/lib/opencode/theme-runtime.js`: custom theme JSON validation and theme directory loading runtime for settings utility routes.
|
|
@@ -303,6 +304,7 @@ Installer output is discarded, not forwarded to clients or logs.
|
|
|
303
304
|
`prompt-response.js` rejects a successful HTML app-shell response at server-owned dispatch boundaries. Raw prompt, context-restoration, and queue sends call `assertPromptResponse`; the session-route and scheduled-task SDK factories call `assertOpenCodeApiResponse` before the SDK decodes the body. The SDK still owns declared error statuses and their bodies. A rejected dispatch must not remove a queued item or record its project knowledge as delivered.
|
|
304
305
|
|
|
305
306
|
## Public exports (session-activity.js)
|
|
307
|
+
- `hasWorkingDescendants(id, statuses)` is the queue delivery check returned by the probe. It follows the running sessions' parent links through at most 8 ancestors. Reads share one timeout and each session record is read once per check. Failed or malformed records and cycles return `null` unless another chain proves a running descendant; a chain deeper than 8 counts as unrelated, matching the UI's `MAX_SUBAGENT_DEPTH`. Parent links are refreshed on the next check. The direct-child check used by other consumers keeps its existing behavior.
|
|
306
308
|
- `createSessionActivityProbe({ buildOpenCodeUrl, getOpenCodeAuthHeaders, timeoutMs })`: whether a session's turn really ended. A parent goes idle while a background subagent works and runs again when OpenCode hands the result back. `fetchActiveSessionStatuses()` reads `/api/session/active`, `fetchChildSessionIds(id)` pages `GET /api/session?parentID=`, `hasWorkingChildren(id, statuses)` combines them. Every read answers `null` when OpenCode could not be asked. Used by the goal loop (waits) and the notification runtime (stays silent on the pause).
|
|
307
309
|
|
|
308
310
|
## Public exports (session-runtime.js)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Where the start command comes from: the running OpenCode in production, a fixture in tests. */
|
|
2
|
+
export type ProjectStartCommandSource = {
|
|
3
|
+
read: (directory: string) => Promise<string>;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export function configureProjectStartCommandSource(next: ProjectStartCommandSource | null): void;
|
|
7
|
+
export function openCodeProjectStartCommandSource(connection: {
|
|
8
|
+
buildOpenCodeUrl: (path: string, prefix?: string) => string;
|
|
9
|
+
getOpenCodeAuthHeaders: () => Record<string, string>;
|
|
10
|
+
}): ProjectStartCommandSource;
|
|
11
|
+
export function readProjectStartCommand(directory: string): Promise<string>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The project's start command (`commands.start`): what OpenCode runs in every
|
|
3
|
+
* new worktree of a project, such as a dependency install. Shared by the web
|
|
4
|
+
* server and the VS Code extension host, which create worktrees themselves and
|
|
5
|
+
* so run it themselves.
|
|
6
|
+
*
|
|
7
|
+
* OpenCode 2.x keeps the command on its project record, in its database, and
|
|
8
|
+
* hands it out through the API only. The project ID comes from OpenCode too:
|
|
9
|
+
* 2.x derives it from the origin remote, while OpenChamber's own worktree ID is
|
|
10
|
+
* the root commit, so the two differ for most repositories. `GET /api/location`
|
|
11
|
+
* names the project a checkout belongs to and `GET /api/project` holds its
|
|
12
|
+
* record. Both reads are scoped to the directory the worktree is requested
|
|
13
|
+
* from, which the user already works in, so they start no new location.
|
|
14
|
+
*
|
|
15
|
+
* A failed read runs no command and logs why, the same outcome as a failing
|
|
16
|
+
* command: the worktree itself is still created.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { OpenCode } from '@opencode/client';
|
|
20
|
+
|
|
21
|
+
// Wired once per runtime: `server/index.js` on the web server, the extension
|
|
22
|
+
// entry point in VS Code. Until then no command runs.
|
|
23
|
+
let source = null;
|
|
24
|
+
|
|
25
|
+
/** Wires the reader to a source (`{ read(directory) }`). Pass `null` to detach. */
|
|
26
|
+
export function configureProjectStartCommandSource(next) {
|
|
27
|
+
source = next ?? null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The running OpenCode as the source. The URL and auth headers are read on
|
|
32
|
+
* every call because the port and the server password both move across an
|
|
33
|
+
* OpenCode restart.
|
|
34
|
+
*/
|
|
35
|
+
export const openCodeProjectStartCommandSource = ({ buildOpenCodeUrl, getOpenCodeAuthHeaders }) => ({
|
|
36
|
+
read: async (directory) => {
|
|
37
|
+
const client = OpenCode.make({
|
|
38
|
+
baseUrl: buildOpenCodeUrl('', '').replace(/\/+$/, ''),
|
|
39
|
+
headers: { ...getOpenCodeAuthHeaders(), 'x-opencode-directory': encodeURIComponent(directory) },
|
|
40
|
+
});
|
|
41
|
+
const [location, projects] = await Promise.all([client.location.get(), client.project.list()]);
|
|
42
|
+
const project = projects.find((entry) => entry.id === location.project.id);
|
|
43
|
+
return project?.commands?.start?.trim() ?? '';
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/** The start command of the project `directory` belongs to, or '' when there is none or it cannot be read. */
|
|
48
|
+
export const readProjectStartCommand = async (directory) => {
|
|
49
|
+
if (!source) return '';
|
|
50
|
+
try {
|
|
51
|
+
return await source.read(directory);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.warn('Failed to read the project start command from OpenCode:', error instanceof Error ? error.message : String(error));
|
|
54
|
+
return '';
|
|
55
|
+
}
|
|
56
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import http from 'node:http';
|
|
3
|
+
|
|
4
|
+
import { configureProjectStartCommandSource, openCodeProjectStartCommandSource, readProjectStartCommand } from './project-start-command.js';
|
|
5
|
+
|
|
6
|
+
describe('readProjectStartCommand from the running OpenCode', () => {
|
|
7
|
+
let server;
|
|
8
|
+
let requests;
|
|
9
|
+
let projects;
|
|
10
|
+
let failing;
|
|
11
|
+
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
requests = [];
|
|
14
|
+
failing = false;
|
|
15
|
+
// OpenCode 2.x names the project by its origin remote, so the record the
|
|
16
|
+
// checkout resolves to carries an ID unrelated to the root commit.
|
|
17
|
+
projects = [
|
|
18
|
+
{ id: 'other-project', canonical: '/work/other', commands: { start: 'echo other' }, time: { created: 1, updated: 1, active: 1 }, sandboxes: [] },
|
|
19
|
+
{ id: 'remote-hash', canonical: '/work/my repo', commands: { start: ' bun install ' }, time: { created: 1, updated: 1, active: 1 }, sandboxes: [] },
|
|
20
|
+
];
|
|
21
|
+
server = http.createServer((req, res) => {
|
|
22
|
+
requests.push({ url: req.url, directory: req.headers['x-opencode-directory'] ?? null, authorization: req.headers.authorization });
|
|
23
|
+
res.setHeader('content-type', 'application/json');
|
|
24
|
+
if (failing) {
|
|
25
|
+
res.statusCode = 500;
|
|
26
|
+
res.end(JSON.stringify({ name: 'UnknownError', message: 'boom' }));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (req.url.startsWith('/api/location')) {
|
|
30
|
+
res.end(JSON.stringify({ directory: '/work/my repo', project: { id: 'remote-hash', directory: '/work/my repo', canonical: '/work/my repo' } }));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (req.url.startsWith('/api/project')) {
|
|
34
|
+
res.end(JSON.stringify(projects));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
res.statusCode = 404;
|
|
38
|
+
res.end('{}');
|
|
39
|
+
});
|
|
40
|
+
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
|
|
41
|
+
const { port } = server.address();
|
|
42
|
+
configureProjectStartCommandSource(openCodeProjectStartCommandSource({
|
|
43
|
+
buildOpenCodeUrl: (path) => `http://127.0.0.1:${port}${path}`,
|
|
44
|
+
getOpenCodeAuthHeaders: () => ({ Authorization: 'Basic test' }),
|
|
45
|
+
}));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
afterEach(async () => {
|
|
49
|
+
configureProjectStartCommandSource(null);
|
|
50
|
+
vi.restoreAllMocks();
|
|
51
|
+
await new Promise((resolve) => server.close(resolve));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('answers the command of the project the checkout resolves to, asked in that checkout', async () => {
|
|
55
|
+
await expect(readProjectStartCommand('/work/my repo')).resolves.toBe('bun install');
|
|
56
|
+
expect(requests.map(({ url }) => url.split('?')[0]).sort()).toEqual(['/api/location', '/api/project']);
|
|
57
|
+
for (const request of requests) {
|
|
58
|
+
expect(request.directory).toBe(encodeURIComponent('/work/my repo'));
|
|
59
|
+
expect(request.authorization).toBe('Basic test');
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('answers nothing for a project without a start command', async () => {
|
|
64
|
+
delete projects[1].commands;
|
|
65
|
+
await expect(readProjectStartCommand('/work/my repo')).resolves.toBe('');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('runs nothing and logs when OpenCode cannot answer', async () => {
|
|
69
|
+
failing = true;
|
|
70
|
+
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
71
|
+
await expect(readProjectStartCommand('/work/my repo')).resolves.toBe('');
|
|
72
|
+
expect(warn).toHaveBeenCalledWith('Failed to read the project start command from OpenCode:', expect.any(String));
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('runs nothing before a source is wired', async () => {
|
|
76
|
+
configureProjectStartCommandSource(null);
|
|
77
|
+
await expect(readProjectStartCommand('/work/my repo')).resolves.toBe('');
|
|
78
|
+
expect(requests).toEqual([]);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -12,18 +12,21 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { unwrapOpenCodeResponse } from './response-envelope.js';
|
|
15
|
+
import { z } from 'zod';
|
|
15
16
|
|
|
16
17
|
const CHILDREN_PAGE_SIZE = 50;
|
|
17
18
|
const CHILDREN_MAX_PAGES = 8;
|
|
19
|
+
const MAX_SUBAGENT_DEPTH = 8;
|
|
20
|
+
const sessionLineageSchema = z.object({ id: z.string().min(1), parentID: z.string().min(1).nullish() });
|
|
18
21
|
|
|
19
22
|
export const createSessionActivityProbe = ({ buildOpenCodeUrl, getOpenCodeAuthHeaders, timeoutMs = 10_000, fetchImpl = fetch }) => {
|
|
20
|
-
const openCodeGet = async (fetchPath, query) => {
|
|
23
|
+
const openCodeGet = async (fetchPath, query, signal = AbortSignal.timeout(timeoutMs)) => {
|
|
21
24
|
const base = buildOpenCodeUrl(fetchPath, '');
|
|
22
25
|
const search = new URLSearchParams(query || {}).toString();
|
|
23
26
|
const response = await fetchImpl(search ? `${base}?${search}` : base, {
|
|
24
27
|
method: 'GET',
|
|
25
28
|
headers: { Accept: 'application/json', ...getOpenCodeAuthHeaders() },
|
|
26
|
-
signal
|
|
29
|
+
signal,
|
|
27
30
|
});
|
|
28
31
|
if (!response.ok) {
|
|
29
32
|
throw new Error(`OpenCode GET ${fetchPath} failed with ${response.status}`);
|
|
@@ -74,5 +77,42 @@ export const createSessionActivityProbe = ({ buildOpenCodeUrl, getOpenCodeAuthHe
|
|
|
74
77
|
return children.some((id) => Boolean(statuses[id]));
|
|
75
78
|
};
|
|
76
79
|
|
|
77
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Queue delivery waits for running descendants, including nested subagents.
|
|
82
|
+
* A chain deeper than `MAX_SUBAGENT_DEPTH` counts as unrelated, as in the
|
|
83
|
+
* UI's ancestor walk, so a deep tree elsewhere cannot hold every queue.
|
|
84
|
+
*/
|
|
85
|
+
const hasWorkingDescendants = async (sessionId, statuses) => {
|
|
86
|
+
const parents = new Map();
|
|
87
|
+
const signal = AbortSignal.timeout(timeoutMs);
|
|
88
|
+
let unknown = false;
|
|
89
|
+
for (const activeId of Object.keys(statuses)) {
|
|
90
|
+
if (activeId === sessionId) continue;
|
|
91
|
+
let current = activeId;
|
|
92
|
+
const visited = new Set();
|
|
93
|
+
for (let depth = 0; current && depth < MAX_SUBAGENT_DEPTH; depth += 1) {
|
|
94
|
+
if (signal.aborted) return null;
|
|
95
|
+
if (visited.has(current)) {
|
|
96
|
+
unknown = true;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
visited.add(current);
|
|
100
|
+
if (!parents.has(current)) {
|
|
101
|
+
const body = await openCodeGet(`/api/session/${encodeURIComponent(current)}`, undefined, signal).catch(() => null);
|
|
102
|
+
const parsed = sessionLineageSchema.safeParse(body);
|
|
103
|
+
parents.set(current, parsed.success && parsed.data.id === current ? parsed.data.parentID ?? null : undefined);
|
|
104
|
+
}
|
|
105
|
+
const parentId = parents.get(current);
|
|
106
|
+
if (parentId === undefined) {
|
|
107
|
+
unknown = true;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
if (parentId === sessionId) return true;
|
|
111
|
+
current = parentId;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return unknown ? null : false;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return { fetchActiveSessionStatuses, fetchChildSessionIds, hasWorkingChildren, hasWorkingDescendants };
|
|
78
118
|
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { createSessionActivityProbe } from './session-activity.js';
|
|
3
|
+
|
|
4
|
+
const createProbe = (sessions, { failureId, timeoutMs = 10_000, delayMs = 0 } = {}) => {
|
|
5
|
+
const reads = [];
|
|
6
|
+
const signals = new Set();
|
|
7
|
+
const probe = createSessionActivityProbe({
|
|
8
|
+
buildOpenCodeUrl: (route) => `http://opencode.test${route}`,
|
|
9
|
+
getOpenCodeAuthHeaders: () => ({}),
|
|
10
|
+
timeoutMs,
|
|
11
|
+
fetchImpl: async (url, init) => {
|
|
12
|
+
const id = decodeURIComponent(new URL(url).pathname.split('/').at(-1));
|
|
13
|
+
reads.push(id);
|
|
14
|
+
signals.add(init.signal);
|
|
15
|
+
if (delayMs) await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
16
|
+
if (id === failureId) return new Response(null, { status: 503 });
|
|
17
|
+
return Response.json({ data: sessions[id] ?? null });
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
return { probe, reads, signals };
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
describe('queue descendant activity', () => {
|
|
24
|
+
const running = { type: 'running' };
|
|
25
|
+
|
|
26
|
+
it('detects a live grandchild through an idle intermediate session', async () => {
|
|
27
|
+
const { probe, reads } = createProbe({ child: { id: 'child', parentID: 'root' }, grandchild: { id: 'grandchild', parentID: 'child' } });
|
|
28
|
+
expect(await probe.hasWorkingDescendants('root', { grandchild: running })).toBe(true);
|
|
29
|
+
expect(reads).toEqual(['grandchild', 'child']);
|
|
30
|
+
expect(await probe.hasWorkingDescendants('root', {})).toBe(false);
|
|
31
|
+
expect(reads).toHaveLength(2);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('does not block on an unrelated active tree or count the parent itself', async () => {
|
|
35
|
+
const { probe, reads } = createProbe({ other: { id: 'other' }, child: { id: 'child', parentID: 'other' } });
|
|
36
|
+
expect(await probe.hasWorkingDescendants('root', { root: running, child: running })).toBe(false);
|
|
37
|
+
expect(reads).toEqual(['child', 'other']);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('reads shared ancestry once within a probe and refreshes it on the next probe', async () => {
|
|
41
|
+
const sessions = { other: { id: 'other' } };
|
|
42
|
+
const statuses = {};
|
|
43
|
+
for (let index = 0; index < 100; index += 1) {
|
|
44
|
+
const id = `child_${index}`;
|
|
45
|
+
sessions[id] = { id, parentID: 'other' };
|
|
46
|
+
statuses[id] = running;
|
|
47
|
+
}
|
|
48
|
+
const { probe, reads, signals } = createProbe(sessions);
|
|
49
|
+
expect(await probe.hasWorkingDescendants('root', statuses)).toBe(false);
|
|
50
|
+
expect(reads).toHaveLength(101);
|
|
51
|
+
expect(signals.size).toBe(1);
|
|
52
|
+
sessions.other.parentID = 'root';
|
|
53
|
+
expect(await probe.hasWorkingDescendants('root', { child_0: running })).toBe(true);
|
|
54
|
+
expect(reads).toHaveLength(103);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('keeps unreadable lineage unknown and allows a later successful read', async () => {
|
|
58
|
+
const sessions = { grandchild: { id: 'grandchild', parentID: 'child' }, child: { id: 'child', parentID: 'root' } };
|
|
59
|
+
const { probe } = createProbe(sessions, { failureId: 'child' });
|
|
60
|
+
expect(await probe.hasWorkingDescendants('root', { grandchild: running })).toBeNull();
|
|
61
|
+
expect(await createProbe(sessions).probe.hasWorkingDescendants('root', { grandchild: running })).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('rejects missing, malformed and mismatched session records', async () => {
|
|
65
|
+
for (const record of [null, {}, { id: 'other' }, { id: 'child', parentID: 123 }, { id: 'child', parentID: '' }]) {
|
|
66
|
+
const { probe } = createProbe({ child: record });
|
|
67
|
+
expect(await probe.hasWorkingDescendants('root', { child: running })).toBeNull();
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('still reports a proven descendant when another active lineage fails', async () => {
|
|
72
|
+
const { probe } = createProbe({ child: { id: 'child', parentID: 'root' } });
|
|
73
|
+
expect(await probe.hasWorkingDescendants('root', { missing: running, child: running })).toBe(true);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('bounds cyclic lineage and preserves the unknown result', async () => {
|
|
77
|
+
const { probe, reads } = createProbe({ a: { id: 'a', parentID: 'b' }, b: { id: 'b', parentID: 'a' } });
|
|
78
|
+
expect(await probe.hasWorkingDescendants('root', { a: running })).toBeNull();
|
|
79
|
+
expect(reads).toEqual(['a', 'b']);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('accepts an eighth-level descendant and treats a deeper chain as unrelated', async () => {
|
|
83
|
+
const sessions = {};
|
|
84
|
+
for (let depth = 1; depth <= 9; depth += 1) sessions[`child_${depth}`] = { id: `child_${depth}`, parentID: depth === 1 ? 'root' : `child_${depth - 1}` };
|
|
85
|
+
const { probe, reads } = createProbe(sessions);
|
|
86
|
+
expect(await probe.hasWorkingDescendants('root', { child_8: running })).toBe(true);
|
|
87
|
+
expect(reads).toHaveLength(8);
|
|
88
|
+
expect(await probe.hasWorkingDescendants('root', { child_9: running })).toBe(false);
|
|
89
|
+
expect(reads).toHaveLength(16);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('uses one deadline for the entire lineage walk', async () => {
|
|
93
|
+
const { probe, reads } = createProbe({ child: { id: 'child', parentID: 'parent' } }, { timeoutMs: 1, delayMs: 10 });
|
|
94
|
+
expect(await probe.hasWorkingDescendants('root', { child: running })).toBeNull();
|
|
95
|
+
expect(reads).toEqual(['child']);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -68,6 +68,7 @@ export const createSettingsRuntime = (deps) => {
|
|
|
68
68
|
normalizeManagedRemoteTunnelPresetTokens,
|
|
69
69
|
syncManagedRemoteTunnelConfigWithPresets,
|
|
70
70
|
upsertManagedRemoteTunnelToken,
|
|
71
|
+
chatRoots = [],
|
|
71
72
|
onManagedPluginSettingsChanged = async () => {},
|
|
72
73
|
onMessageSearchEnabledChanged = () => {},
|
|
73
74
|
onMessageSearchReasoningChanged = () => {},
|
|
@@ -769,6 +770,23 @@ export const createSettingsRuntime = (deps) => {
|
|
|
769
770
|
return (await Promise.all(validations)).filter((p) => p !== null);
|
|
770
771
|
};
|
|
771
772
|
|
|
773
|
+
const isWithinRoot = (candidate, root) => {
|
|
774
|
+
const relative = path.relative(root, candidate);
|
|
775
|
+
return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
// A chat's folder belongs to no project. With no project open, the folder
|
|
779
|
+
// the UI last browsed is often a chat's, and it must not become one.
|
|
780
|
+
const isChatDirectory = async (candidate) => {
|
|
781
|
+
const roots = chatRoots.filter(Boolean).map((root) => path.resolve(root));
|
|
782
|
+
if (roots.some((root) => isWithinRoot(candidate, root))) {
|
|
783
|
+
return true;
|
|
784
|
+
}
|
|
785
|
+
const realCandidate = await fsPromises.realpath(candidate);
|
|
786
|
+
const realRoots = await Promise.all(roots.map((root) => fsPromises.realpath(root).catch(() => null)));
|
|
787
|
+
return realRoots.some((root) => root && isWithinRoot(realCandidate, root));
|
|
788
|
+
};
|
|
789
|
+
|
|
772
790
|
const migrateSettingsFromLegacyLastDirectory = async (current) => {
|
|
773
791
|
const settings = current && typeof current === 'object' ? current : {};
|
|
774
792
|
const now = Date.now();
|
|
@@ -787,7 +805,7 @@ export const createSettingsRuntime = (deps) => {
|
|
|
787
805
|
if (candidate) {
|
|
788
806
|
try {
|
|
789
807
|
const stats = await fsPromises.stat(candidate);
|
|
790
|
-
if (stats.isDirectory()) {
|
|
808
|
+
if (stats.isDirectory() && !(await isChatDirectory(candidate))) {
|
|
791
809
|
const id = createProjectIdFromPath(candidate);
|
|
792
810
|
nextProjects = [
|
|
793
811
|
{
|
|
@@ -9,6 +9,7 @@ import { createSettingsRuntime } from './settings-runtime.js';
|
|
|
9
9
|
const createRuntime = async ({
|
|
10
10
|
mergePersistedSettings = (_current, changes) => changes,
|
|
11
11
|
onManagedPluginSettingsChanged = undefined,
|
|
12
|
+
chatRoots = undefined,
|
|
12
13
|
} = {}) => {
|
|
13
14
|
const tempRoot = await fsPromises.mkdtemp(path.join(os.tmpdir(), 'oc-settings-runtime-'));
|
|
14
15
|
const settingsFilePath = path.join(tempRoot, 'settings.json');
|
|
@@ -29,6 +30,7 @@ const createRuntime = async ({
|
|
|
29
30
|
normalizeManagedRemoteTunnelPresetTokens: (value) => value,
|
|
30
31
|
syncManagedRemoteTunnelConfigWithPresets: async () => {},
|
|
31
32
|
upsertManagedRemoteTunnelToken: async () => {},
|
|
33
|
+
chatRoots,
|
|
32
34
|
onManagedPluginSettingsChanged,
|
|
33
35
|
});
|
|
34
36
|
|
|
@@ -100,6 +102,27 @@ describe('settings runtime', () => {
|
|
|
100
102
|
}
|
|
101
103
|
});
|
|
102
104
|
|
|
105
|
+
it('never turns a chat folder stored as the last directory into a project', async () => {
|
|
106
|
+
const tempRoot = await fsPromises.mkdtemp(path.join(os.tmpdir(), 'oc-settings-chats-'));
|
|
107
|
+
const chatsRoot = path.join(tempRoot, 'chats');
|
|
108
|
+
const { runtime, cleanup } = await createRuntime({ chatRoots: [chatsRoot] });
|
|
109
|
+
try {
|
|
110
|
+
const chat = path.join(chatsRoot, '2026-10-12', 'session-a');
|
|
111
|
+
await fsPromises.mkdir(chat, { recursive: true });
|
|
112
|
+
await runtime.writeSettingsToDisk({ projects: [], lastDirectory: chat });
|
|
113
|
+
expect((await runtime.readSettingsFromDiskMigrated()).projects).toEqual([]);
|
|
114
|
+
|
|
115
|
+
// The same folder reached through a link to the chats root.
|
|
116
|
+
const alias = path.join(tempRoot, 'chats-alias');
|
|
117
|
+
await fsPromises.symlink(chatsRoot, alias, 'junction');
|
|
118
|
+
await runtime.writeSettingsToDisk({ projects: [], lastDirectory: path.join(alias, '2026-10-12', 'session-a') });
|
|
119
|
+
expect((await runtime.readSettingsFromDiskMigrated()).projects).toEqual([]);
|
|
120
|
+
} finally {
|
|
121
|
+
await cleanup();
|
|
122
|
+
await fsPromises.rm(tempRoot, { recursive: true, force: true });
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
103
126
|
it('uses OpenChamber themes when a new install has no theme preferences', async () => {
|
|
104
127
|
const { runtime, cleanup } = await createRuntime();
|
|
105
128
|
try {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { OpenCode } from '@opencode/client';
|
|
2
2
|
import { buildAppliedResponse } from './config-mutation-response.js';
|
|
3
3
|
import { OPENCODE_CONFIG_DIR } from './shared.js';
|
|
4
|
+
import { asNonEmptyString } from '../shared/guards.js';
|
|
5
|
+
import { appendInstalledSources, isInstalledFromSource, readInstalledSources, removeInstalledSources } from '../skills-catalog/installed-sources.js';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Matches how OpenCode reads its own boolean env flags: any value other than
|
|
@@ -486,13 +488,19 @@ export const registerSkillRoutes = (app, dependencies) => {
|
|
|
486
488
|
}
|
|
487
489
|
|
|
488
490
|
const excludedSkills = new Set(src.excludedSkills || []);
|
|
491
|
+
// Provenance recorded at install time makes the badge source-aware; a
|
|
492
|
+
// name the registry has never heard of keeps the old name match, so
|
|
493
|
+
// skills installed before the registry existed look unchanged (#4756).
|
|
494
|
+
const provenanceByName = readInstalledSources();
|
|
489
495
|
const items = (scanResult.items || []).filter((item) => !excludedSkills.has(item.skillName)).map((item) => {
|
|
490
496
|
const installed = installedByName.get(item.skillName);
|
|
497
|
+
const isInstalled = Boolean(installed)
|
|
498
|
+
&& isInstalledFromSource(provenanceByName, item.skillName, src.id, item.skillDir);
|
|
491
499
|
return {
|
|
492
500
|
sourceId: src.id,
|
|
493
501
|
...item,
|
|
494
502
|
gitIdentityId: src.gitIdentityId,
|
|
495
|
-
installed:
|
|
503
|
+
installed: isInstalled
|
|
496
504
|
? { isInstalled: true, scope: installed.scope, source: installed.source }
|
|
497
505
|
: { isInstalled: false },
|
|
498
506
|
};
|
|
@@ -552,6 +560,7 @@ export const registerSkillRoutes = (app, dependencies) => {
|
|
|
552
560
|
const {
|
|
553
561
|
source,
|
|
554
562
|
subpath,
|
|
563
|
+
sourceId,
|
|
555
564
|
gitIdentityId,
|
|
556
565
|
scope,
|
|
557
566
|
targetSource,
|
|
@@ -615,6 +624,24 @@ export const registerSkillRoutes = (app, dependencies) => {
|
|
|
615
624
|
const installed = result.installed || [];
|
|
616
625
|
const skipped = result.skipped || [];
|
|
617
626
|
const installedAny = installed.length > 0;
|
|
627
|
+
const provenanceSourceId = asNonEmptyString(sourceId);
|
|
628
|
+
|
|
629
|
+
if (installedAny && provenanceSourceId) {
|
|
630
|
+
try {
|
|
631
|
+
appendInstalledSources(installed.map((entry) => ({
|
|
632
|
+
skillName: entry.skillName,
|
|
633
|
+
skillDir: entry.skillDir,
|
|
634
|
+
scope: entry.scope,
|
|
635
|
+
source: entry.source,
|
|
636
|
+
sourceId: provenanceSourceId,
|
|
637
|
+
sourceRef: source,
|
|
638
|
+
})));
|
|
639
|
+
} catch (error) {
|
|
640
|
+
// Provenance only refines the Installed badge; a failed write must
|
|
641
|
+
// not fail an install that already succeeded.
|
|
642
|
+
console.error('Failed to record skill install provenance:', error);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
618
645
|
|
|
619
646
|
res.json({
|
|
620
647
|
ok: true,
|
|
@@ -828,6 +855,12 @@ export const registerSkillRoutes = (app, dependencies) => {
|
|
|
828
855
|
}
|
|
829
856
|
|
|
830
857
|
deleteSkill(skillName, directory);
|
|
858
|
+
try {
|
|
859
|
+
removeInstalledSources(skillName);
|
|
860
|
+
} catch (error) {
|
|
861
|
+
// Provenance only refines the Installed badge; the skill is gone either way.
|
|
862
|
+
console.error('Failed to forget skill install provenance:', error);
|
|
863
|
+
}
|
|
831
864
|
res.json(buildAppliedResponse(
|
|
832
865
|
`Skill ${skillName} deleted successfully.`,
|
|
833
866
|
));
|
|
@@ -315,6 +315,105 @@ describe('skill-routes directory soft fallback', () => {
|
|
|
315
315
|
expect(catalogPayload.sources[0]).not.toHaveProperty('excludedSkills');
|
|
316
316
|
});
|
|
317
317
|
|
|
318
|
+
it('marks installed only for the source the skill was installed from', async () => {
|
|
319
|
+
projectRoot = createTempProject();
|
|
320
|
+
const skillDir = path.join(projectRoot, '.agents', 'skills', 'skill-creator');
|
|
321
|
+
fs.mkdirSync(skillDir, { recursive: true });
|
|
322
|
+
fs.writeFileSync(path.join(skillDir, 'SKILL.md'), '---\nname: skill-creator\ndescription: Creates skills\n---\nBody\n');
|
|
323
|
+
|
|
324
|
+
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'oc-skills-data-'));
|
|
325
|
+
const previousDataDir = process.env.OPENCHAMBER_DATA_DIR;
|
|
326
|
+
process.env.OPENCHAMBER_DATA_DIR = dataDir;
|
|
327
|
+
try {
|
|
328
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
329
|
+
fs.writeFileSync(path.join(dataDir, 'skills-installed-sources.json'), JSON.stringify({
|
|
330
|
+
version: 1,
|
|
331
|
+
entries: [{ skillName: 'skill-creator', skillDir: 'skills/skill-creator', scope: 'user', source: 'opencode', sourceId: 'acme', sourceRef: 'acme/skills' }],
|
|
332
|
+
}));
|
|
333
|
+
|
|
334
|
+
const scanItem = (repoSource) => ({ repoSource, skillDir: 'skills/skill-creator', skillName: 'skill-creator', installable: true });
|
|
335
|
+
appHandle = startSkillsApp({
|
|
336
|
+
projectRoot,
|
|
337
|
+
overrides: {
|
|
338
|
+
getCuratedSkillsSources: () => [
|
|
339
|
+
{ id: 'acme', label: 'Acme', source: 'acme/skills', defaultSubpath: 'skills' },
|
|
340
|
+
{ id: 'other', label: 'Other', source: 'other/skills', defaultSubpath: 'skills' },
|
|
341
|
+
],
|
|
342
|
+
parseSkillRepoSource: () => ({ ok: true, host: 'github.com', normalizedRepo: 'owner/repo' }),
|
|
343
|
+
scanSkillsRepository: async (input) => ({ ok: true, items: [scanItem(input?.source === 'other/skills' ? 'other/skills' : 'acme/skills')] }),
|
|
344
|
+
},
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
const fromAcme = await (await fetch(
|
|
348
|
+
`${appHandle.baseUrl}/api/config/skills/catalog/source?sourceId=acme&directory=${encodeURIComponent(projectRoot)}`,
|
|
349
|
+
)).json();
|
|
350
|
+
expect(fromAcme.items).toHaveLength(1);
|
|
351
|
+
expect(fromAcme.items[0].installed).toMatchObject({ isInstalled: true });
|
|
352
|
+
|
|
353
|
+
const fromOther = await (await fetch(
|
|
354
|
+
`${appHandle.baseUrl}/api/config/skills/catalog/source?sourceId=other&directory=${encodeURIComponent(projectRoot)}`,
|
|
355
|
+
)).json();
|
|
356
|
+
expect(fromOther.items).toHaveLength(1);
|
|
357
|
+
expect(fromOther.items[0].installed).toMatchObject({ isInstalled: false });
|
|
358
|
+
|
|
359
|
+
// A name the registry has never heard of keeps the old name match.
|
|
360
|
+
fs.rmSync(path.join(dataDir, 'skills-installed-sources.json'));
|
|
361
|
+
const legacy = await (await fetch(
|
|
362
|
+
`${appHandle.baseUrl}/api/config/skills/catalog/source?sourceId=other&directory=${encodeURIComponent(projectRoot)}`,
|
|
363
|
+
)).json();
|
|
364
|
+
expect(legacy.items[0].installed).toMatchObject({ isInstalled: true });
|
|
365
|
+
} finally {
|
|
366
|
+
if (previousDataDir === undefined) delete process.env.OPENCHAMBER_DATA_DIR;
|
|
367
|
+
else process.env.OPENCHAMBER_DATA_DIR = previousDataDir;
|
|
368
|
+
fs.rmSync(dataDir, { recursive: true, force: true });
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it('records install provenance for what an install returned', async () => {
|
|
373
|
+
projectRoot = createTempProject();
|
|
374
|
+
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'oc-skills-data-'));
|
|
375
|
+
const previousDataDir = process.env.OPENCHAMBER_DATA_DIR;
|
|
376
|
+
process.env.OPENCHAMBER_DATA_DIR = dataDir;
|
|
377
|
+
try {
|
|
378
|
+
appHandle = startSkillsApp({
|
|
379
|
+
projectRoot,
|
|
380
|
+
overrides: {
|
|
381
|
+
resolveCatalogGitIdentity: async () => ({ ok: true, identity: { transport: 'https', credentialId: 'ref', endpoint: 'https://github.com/owner/repo.git' } }),
|
|
382
|
+
installSkillsFromRepository: async () => ({
|
|
383
|
+
ok: true,
|
|
384
|
+
installed: [{ skillName: 'skill-creator', skillDir: 'skills/skill-creator', scope: 'user', source: 'opencode' }],
|
|
385
|
+
skipped: [],
|
|
386
|
+
}),
|
|
387
|
+
},
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
const install = await fetch(`${appHandle.baseUrl}/api/config/skills/install`, {
|
|
391
|
+
method: 'POST',
|
|
392
|
+
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
393
|
+
body: JSON.stringify({
|
|
394
|
+
source: 'owner/repo',
|
|
395
|
+
sourceId: 'acme',
|
|
396
|
+
scope: 'user',
|
|
397
|
+
selections: [{ skillDir: 'skills/skill-creator' }],
|
|
398
|
+
}),
|
|
399
|
+
});
|
|
400
|
+
expect(install.status).toBe(200);
|
|
401
|
+
|
|
402
|
+
const payload = JSON.parse(fs.readFileSync(path.join(dataDir, 'skills-installed-sources.json'), 'utf8'));
|
|
403
|
+
expect(payload.version).toBe(1);
|
|
404
|
+
expect(payload.entries).toContainEqual(expect.objectContaining({
|
|
405
|
+
skillName: 'skill-creator',
|
|
406
|
+
skillDir: 'skills/skill-creator',
|
|
407
|
+
sourceId: 'acme',
|
|
408
|
+
sourceRef: 'owner/repo',
|
|
409
|
+
}));
|
|
410
|
+
} finally {
|
|
411
|
+
if (previousDataDir === undefined) delete process.env.OPENCHAMBER_DATA_DIR;
|
|
412
|
+
else process.env.OPENCHAMBER_DATA_DIR = previousDataDir;
|
|
413
|
+
fs.rmSync(dataDir, { recursive: true, force: true });
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
|
|
318
417
|
it('leaves supporting files out of the list and keeps them in the skill detail', async () => {
|
|
319
418
|
projectRoot = createTempProject();
|
|
320
419
|
const skillDir = path.join(projectRoot, '.agents', 'skills', 'files-skill');
|