@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
|
@@ -10,6 +10,7 @@ import { createRequire } from 'module';
|
|
|
10
10
|
import crypto from 'node:crypto';
|
|
11
11
|
import { fingerprintRemoteUrl } from '../source-control/url-redaction.js';
|
|
12
12
|
import { readWorktreeDirectorySetting } from '../opencode/shared.js';
|
|
13
|
+
import { readProjectStartCommand } from '../opencode/project-start-command.js';
|
|
13
14
|
import { normalizeGitOutputPath } from './output-path.js';
|
|
14
15
|
import { overlayEnvironment } from '../environment/variables.js';
|
|
15
16
|
import { primaryWorktreeRootFromGitDir, unsupportedRepositoryRootReason } from './repository-root.js';
|
|
@@ -1204,8 +1205,11 @@ const resolveGitCommitFilePath = async (repoRoot, hash, candidates) => {
|
|
|
1204
1205
|
// simple-git 3.36 refuses GIT_EDITOR unless allowUnsafeEditor is enabled, and
|
|
1205
1206
|
// once an instance has an explicit env it also rejects inherited PAGER or
|
|
1206
1207
|
// GIT_ASKPASS values. Run editor-free continuation commands directly instead.
|
|
1208
|
+
// The full git environment must survive the override: git execs the no-op
|
|
1209
|
+
// editor through PATH, and an env of only GIT_EDITOR makes that spawn search
|
|
1210
|
+
// the execvp fallback (/bin:/usr/bin), where NixOS has no `true`.
|
|
1207
1211
|
const runGitCommandWithoutEditor = async (cwd, args) => {
|
|
1208
|
-
const result = await runGitCommand(cwd, args, { env: { GIT_EDITOR: 'true' } });
|
|
1212
|
+
const result = await runGitCommand(cwd, args, { env: { ...(await buildGitEnv(cwd)), GIT_EDITOR: 'true' } });
|
|
1209
1213
|
if (!result.success) {
|
|
1210
1214
|
throw new Error(result.message || 'Git command failed');
|
|
1211
1215
|
}
|
|
@@ -1405,7 +1409,7 @@ export const inspectContributorCheckoutActions = async (directory, provenance) =
|
|
|
1405
1409
|
const head = String((await runGitCommandOrThrow(directory, ['rev-parse', 'HEAD'], 'Failed to inspect worktree HEAD')).stdout || '').trim().toLowerCase();
|
|
1406
1410
|
if (head !== provenance.sourceSha) throw Object.assign(new Error('Contributor worktree HEAD changed'), { code: 'STALE_CONFIG', status: 409 });
|
|
1407
1411
|
const hook = await inspectPostCheckoutHook(directory);
|
|
1408
|
-
const projectCommand = await
|
|
1412
|
+
const projectCommand = await readProjectStartCommand((await resolvePrimaryWorktreeRoot(directory)).root);
|
|
1409
1413
|
const setupCommand = String(provenance.setupCommand || '').trim();
|
|
1410
1414
|
const actions = [];
|
|
1411
1415
|
if (hook) actions.push(hook);
|
|
@@ -1708,9 +1712,9 @@ export async function getIntegrateConflictDetails(tmpDir) {
|
|
|
1708
1712
|
const [status, unmerged, diff, meta, patch] = await Promise.all([
|
|
1709
1713
|
runGitCommand(target, ['status', '--porcelain']),
|
|
1710
1714
|
runGitCommand(target, ['diff', '--name-only', '--diff-filter=U']),
|
|
1711
|
-
runGitCommand(target, ['diff']),
|
|
1715
|
+
runGitCommand(target, ['diff', '--no-ext-diff']),
|
|
1712
1716
|
runGitCommand(target, ['show', '--no-patch', '--pretty=fuller', 'CHERRY_PICK_HEAD']),
|
|
1713
|
-
runGitCommand(target, ['show', 'CHERRY_PICK_HEAD']),
|
|
1717
|
+
runGitCommand(target, ['show', '--no-ext-diff', 'CHERRY_PICK_HEAD']),
|
|
1714
1718
|
]);
|
|
1715
1719
|
|
|
1716
1720
|
return {
|
|
@@ -1974,6 +1978,7 @@ const resolveWorktreeProjectContext = async (directory, options = {}) => {
|
|
|
1974
1978
|
|
|
1975
1979
|
return {
|
|
1976
1980
|
projectID,
|
|
1981
|
+
requestedDirectory: directoryPath,
|
|
1977
1982
|
sandbox,
|
|
1978
1983
|
primaryWorktree,
|
|
1979
1984
|
worktreeRoot,
|
|
@@ -2118,18 +2123,6 @@ const runWorktreeStartCommand = async (directory, command) => {
|
|
|
2118
2123
|
return result;
|
|
2119
2124
|
};
|
|
2120
2125
|
|
|
2121
|
-
const loadProjectStartCommand = async (projectID) => {
|
|
2122
|
-
const storagePath = path.join(getOpenCodeDataPath(), 'storage', 'project', `${projectID}.json`);
|
|
2123
|
-
try {
|
|
2124
|
-
const raw = await fsp.readFile(storagePath, 'utf8');
|
|
2125
|
-
const parsed = JSON.parse(raw);
|
|
2126
|
-
const start = typeof parsed?.commands?.start === 'string' ? parsed.commands.start.trim() : '';
|
|
2127
|
-
return start || '';
|
|
2128
|
-
} catch {
|
|
2129
|
-
return '';
|
|
2130
|
-
}
|
|
2131
|
-
};
|
|
2132
|
-
|
|
2133
2126
|
// OpenCode owns its own project/sandbox registry. It records a worktree as a
|
|
2134
2127
|
// sandbox itself when an instance boots for that directory, and filters entries
|
|
2135
2128
|
// whose directory no longer exists when reading them back. OpenChamber used to
|
|
@@ -2169,8 +2162,10 @@ const cleanupFailedFastWorktreeCreate = async (context, candidate) => {
|
|
|
2169
2162
|
}
|
|
2170
2163
|
};
|
|
2171
2164
|
|
|
2172
|
-
|
|
2173
|
-
|
|
2165
|
+
// `projectDirectory` is the directory the worktree was requested from: the user
|
|
2166
|
+
// already works there, so OpenCode answers without starting another location.
|
|
2167
|
+
const runWorktreeStartScripts = async (directory, projectDirectory, startCommand) => {
|
|
2168
|
+
const projectStart = await readProjectStartCommand(projectDirectory);
|
|
2174
2169
|
if (projectStart) {
|
|
2175
2170
|
const projectResult = await runWorktreeStartCommand(directory, projectStart);
|
|
2176
2171
|
if (!projectResult.success) {
|
|
@@ -2192,7 +2187,7 @@ const runWorktreeStartScripts = async (directory, projectID, startCommand) => {
|
|
|
2192
2187
|
const queueWorktreeBootstrap = (args) => {
|
|
2193
2188
|
const {
|
|
2194
2189
|
directory,
|
|
2195
|
-
|
|
2190
|
+
projectDirectory,
|
|
2196
2191
|
primaryWorktree,
|
|
2197
2192
|
localBranch,
|
|
2198
2193
|
setUpstream,
|
|
@@ -2247,7 +2242,7 @@ const queueWorktreeBootstrap = (args) => {
|
|
|
2247
2242
|
bootstrapStore,
|
|
2248
2243
|
);
|
|
2249
2244
|
if (!contributorFork) {
|
|
2250
|
-
await runWorktreeStartScripts(directory,
|
|
2245
|
+
await runWorktreeStartScripts(directory, projectDirectory, startCommand).catch((error) => {
|
|
2251
2246
|
console.warn('Worktree start script task failed:', error instanceof Error ? error.message : String(error));
|
|
2252
2247
|
});
|
|
2253
2248
|
}
|
|
@@ -3263,7 +3258,7 @@ async function readStatus(normalizedDirectory, lightMode) {
|
|
|
3263
3258
|
}
|
|
3264
3259
|
|
|
3265
3260
|
const getNoIndexDiff = async (repoRoot, repoPath, contextLines) => {
|
|
3266
|
-
const args = ['diff', '--no-color', '--full-index'];
|
|
3261
|
+
const args = ['diff', '--no-color', '--full-index', '--no-ext-diff'];
|
|
3267
3262
|
if (Number.isFinite(contextLines)) {
|
|
3268
3263
|
args.push(`-U${Math.max(0, contextLines)}`);
|
|
3269
3264
|
}
|
|
@@ -3300,7 +3295,7 @@ export async function getPathDiff(directory, { path: filePath, staged = false, c
|
|
|
3300
3295
|
|
|
3301
3296
|
async function readDiff({ repoRoot, git }, fileContext, { staged, contextLines }) {
|
|
3302
3297
|
try {
|
|
3303
|
-
const args = ['diff', '--no-color', '--full-index'];
|
|
3298
|
+
const args = ['diff', '--no-color', '--full-index', '--no-ext-diff'];
|
|
3304
3299
|
|
|
3305
3300
|
if (typeof contextLines === 'number' && !Number.isNaN(contextLines)) {
|
|
3306
3301
|
args.push(`-U${Math.max(0, contextLines)}`);
|
|
@@ -3487,7 +3482,7 @@ export async function getRangeDiff(directory, { base, head, path: filePath, cont
|
|
|
3487
3482
|
|
|
3488
3483
|
await assertRangeRefsResolve(git, [baseRef, headRef]);
|
|
3489
3484
|
|
|
3490
|
-
const args = ['diff', '--no-color'];
|
|
3485
|
+
const args = ['diff', '--no-color', '--no-ext-diff'];
|
|
3491
3486
|
if (typeof contextLines === 'number' && !Number.isNaN(contextLines)) {
|
|
3492
3487
|
args.push(`-U${Math.max(0, contextLines)}`);
|
|
3493
3488
|
}
|
|
@@ -5292,7 +5287,7 @@ async function attachGitWorktreeToCandidateWithoutRemoteRollback(context, candid
|
|
|
5292
5287
|
if (bootstrapStatus.status === WORKTREE_BOOTSTRAP_PENDING) {
|
|
5293
5288
|
queueWorktreeBootstrap({
|
|
5294
5289
|
directory: candidate.directory,
|
|
5295
|
-
|
|
5290
|
+
projectDirectory: context.requestedDirectory,
|
|
5296
5291
|
primaryWorktree: context.primaryWorktree,
|
|
5297
5292
|
localBranch,
|
|
5298
5293
|
setUpstream: shouldSetUpstream,
|
|
@@ -6806,7 +6801,7 @@ export async function getConflictDetails(directory) {
|
|
|
6806
6801
|
.filter(Boolean);
|
|
6807
6802
|
|
|
6808
6803
|
// Get current diff
|
|
6809
|
-
const diff = await git.raw(['diff']).catch(() => '');
|
|
6804
|
+
const diff = await git.raw(['diff', '--no-ext-diff']).catch(() => '');
|
|
6810
6805
|
|
|
6811
6806
|
// simple-git resolves a quiet `rev-parse --verify` miss with empty output instead of rejecting.
|
|
6812
6807
|
let operation = 'merge';
|
|
@@ -9,6 +9,7 @@ import { loadSourceSections, parseSource, sourceKey } from '../walkthrough/sourc
|
|
|
9
9
|
import { registerGitRoutes } from './routes.js';
|
|
10
10
|
import { isUserAction } from '../environment/refresh-scope.js';
|
|
11
11
|
import { normalizeGitOutputPath } from './output-path.js';
|
|
12
|
+
import { configureProjectStartCommandSource } from '../opencode/project-start-command.js';
|
|
12
13
|
|
|
13
14
|
import {
|
|
14
15
|
configureGitEnvironment,
|
|
@@ -759,6 +760,55 @@ describe.runIf(canRunGit())('untracked diffs', () => {
|
|
|
759
760
|
});
|
|
760
761
|
});
|
|
761
762
|
|
|
763
|
+
// An external diff configured in git (difftastic via diff.external, or
|
|
764
|
+
// GIT_EXTERNAL_DIFF in the session environment) replaces patch text with its own
|
|
765
|
+
// format. The UI parses patches as unified diffs, so patch-producing calls must
|
|
766
|
+
// always use git's internal diff machinery.
|
|
767
|
+
describe.runIf(canRunGit())('diff output with diff.external configured', () => {
|
|
768
|
+
// `echo` runs on every platform's shell and its output is never a unified diff.
|
|
769
|
+
// simple-git's safety plugin refuses to configure diff.external, so the fixture
|
|
770
|
+
// writes it through runGit like any other local git config.
|
|
771
|
+
const useFakeExternalDiff = (tmpDir) => runGit(tmpDir, ['config', 'diff.external', 'echo EXTERNAL-DIFF-OUTPUT']);
|
|
772
|
+
|
|
773
|
+
it('returns a unified working-tree diff the UI parser can split', async () => {
|
|
774
|
+
const { tmpDir, git } = await createTempRepo();
|
|
775
|
+
useFakeExternalDiff(tmpDir);
|
|
776
|
+
await git.commit('one', { '--allow-empty': null });
|
|
777
|
+
await writeFile(tmpDir, 'file.txt', ORIGINAL_FILE);
|
|
778
|
+
await git.add('file.txt');
|
|
779
|
+
await git.commit('Initial');
|
|
780
|
+
await writeFile(tmpDir, 'file.txt', EDITED_FILE);
|
|
781
|
+
|
|
782
|
+
const diff = await getDiff(tmpDir, { path: 'file.txt' });
|
|
783
|
+
expect(diff).toContain('diff --git');
|
|
784
|
+
expect(diff).not.toContain('EXTERNAL-DIFF-OUTPUT');
|
|
785
|
+
// ORIGINAL_FILE and EDITED_FILE change line 1 and line 20: two hunks. The
|
|
786
|
+
// point is that the parser sees hunks at all — difftastic-format text splits to zero.
|
|
787
|
+
expect(splitHunks(diff)).toHaveLength(2);
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
it('keeps untracked-file and range diffs unified', async () => {
|
|
791
|
+
const { tmpDir, git } = await createTempRepo();
|
|
792
|
+
useFakeExternalDiff(tmpDir);
|
|
793
|
+
await git.commit('one', { '--allow-empty': null });
|
|
794
|
+
await git.raw(['branch', 'base-branch']);
|
|
795
|
+
await writeFile(tmpDir, 'file.txt', 'changed\n');
|
|
796
|
+
await git.add('file.txt');
|
|
797
|
+
await git.commit('two');
|
|
798
|
+
await git.raw(['branch', 'head-branch']);
|
|
799
|
+
await writeFile(tmpDir, 'new.txt', 'untracked\n');
|
|
800
|
+
|
|
801
|
+
const [untracked] = await getUntrackedDiffs(tmpDir, ['new.txt']);
|
|
802
|
+
expect(untracked).toContain('@@');
|
|
803
|
+
expect(untracked).not.toContain('EXTERNAL-DIFF-OUTPUT');
|
|
804
|
+
|
|
805
|
+
const range = await getRangeDiff(tmpDir, { base: 'base-branch', head: 'head-branch' });
|
|
806
|
+
expect(range).toContain('diff --git');
|
|
807
|
+
expect(range).toContain('@@');
|
|
808
|
+
expect(range).not.toContain('EXTERNAL-DIFF-OUTPUT');
|
|
809
|
+
});
|
|
810
|
+
});
|
|
811
|
+
|
|
762
812
|
describe('symlink diffs', () => {
|
|
763
813
|
it('treats an untracked directory symlink as a link in patch and split diffs', async () => {
|
|
764
814
|
if (!canRunGit() || process.platform === 'win32') return;
|
|
@@ -1621,6 +1671,55 @@ describe('createWorktree', () => {
|
|
|
1621
1671
|
}
|
|
1622
1672
|
});
|
|
1623
1673
|
|
|
1674
|
+
it('runs the start command OpenCode keeps for the project in the new worktree', async () => {
|
|
1675
|
+
if (!canRunGit()) return;
|
|
1676
|
+
|
|
1677
|
+
// The project is a subfolder of the repository: the read goes to that
|
|
1678
|
+
// folder, which OpenCode already serves, and the command runs at the root
|
|
1679
|
+
// of the new worktree.
|
|
1680
|
+
const repo = createTempDir();
|
|
1681
|
+
const projectFolder = path.join(repo, 'app');
|
|
1682
|
+
fs.mkdirSync(projectFolder);
|
|
1683
|
+
runGit(repo, ['init', '-b', 'main']);
|
|
1684
|
+
runGit(repo, ['config', 'user.email', 'test@example.com']);
|
|
1685
|
+
runGit(repo, ['config', 'user.name', 'Test User']);
|
|
1686
|
+
fs.writeFileSync(path.join(projectFolder, 'README.md'), '# Test\n');
|
|
1687
|
+
runGit(repo, ['add', 'app/README.md']);
|
|
1688
|
+
runGit(repo, ['commit', '-m', 'Initial commit']);
|
|
1689
|
+
|
|
1690
|
+
const previousXdgDataHome = process.env.XDG_DATA_HOME;
|
|
1691
|
+
process.env.XDG_DATA_HOME = createTempDir();
|
|
1692
|
+
const askedFor = [];
|
|
1693
|
+
const markerScript = path.join(createTempDir(), 'project-start.cjs');
|
|
1694
|
+
fs.writeFileSync(markerScript, "require('node:fs').writeFileSync('START_RAN', process.cwd());\n");
|
|
1695
|
+
configureProjectStartCommandSource({
|
|
1696
|
+
read: async (directory) => {
|
|
1697
|
+
askedFor.push(directory);
|
|
1698
|
+
return `${JSON.stringify(process.execPath)} ${JSON.stringify(markerScript)}`;
|
|
1699
|
+
},
|
|
1700
|
+
});
|
|
1701
|
+
|
|
1702
|
+
try {
|
|
1703
|
+
const created = await createWorktree(projectFolder, {
|
|
1704
|
+
mode: 'new',
|
|
1705
|
+
branchName: 'feature/project-start',
|
|
1706
|
+
worktreeName: 'project-start',
|
|
1707
|
+
returnAfterDirectoryCreated: true,
|
|
1708
|
+
});
|
|
1709
|
+
|
|
1710
|
+
await expect.poll(
|
|
1711
|
+
async () => (await getWorktreeBootstrapStatus(created.path)).phase,
|
|
1712
|
+
{ timeout: 5_000 },
|
|
1713
|
+
).toBe('setup-ready');
|
|
1714
|
+
expect(fs.readFileSync(path.join(created.path, 'START_RAN'), 'utf8')).toBe(fs.realpathSync(created.path));
|
|
1715
|
+
expect(askedFor.map((directory) => fs.realpathSync(directory))).toEqual([fs.realpathSync(projectFolder)]);
|
|
1716
|
+
} finally {
|
|
1717
|
+
configureProjectStartCommandSource(null);
|
|
1718
|
+
if (previousXdgDataHome === undefined) delete process.env.XDG_DATA_HOME;
|
|
1719
|
+
else process.env.XDG_DATA_HOME = previousXdgDataHome;
|
|
1720
|
+
}
|
|
1721
|
+
});
|
|
1722
|
+
|
|
1624
1723
|
it('does not report Git-ready when checkout hydration is incomplete', async () => {
|
|
1625
1724
|
if (!canRunGit()) return;
|
|
1626
1725
|
const repo = createTempDir();
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* upstream.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { forkRemoteName } from './contributor-remote.js';
|
|
12
|
+
|
|
11
13
|
/** A refusal with the HTTP status and body fields the route answers with. */
|
|
12
14
|
export class WorktreeCreationError extends Error {
|
|
13
15
|
constructor(message, status, code, details = {}) {
|
|
@@ -30,11 +32,6 @@ export const hasClientContributorAuthority = (body) => body?.contributorFork !==
|
|
|
30
32
|
// A change request from this repository itself is fetched onto the primary
|
|
31
33
|
// remote it already has, under that remote's own URL, so the checkout adds no
|
|
32
34
|
// second remote for the same project. Only a fork gets a remote of its own.
|
|
33
|
-
// A fork's remote is named after its owner, which the provider just said; the
|
|
34
|
-
// picker cannot always know it (GitLab lists merge requests without it).
|
|
35
|
-
const forkRemoteName = (owner) => `pr-${String(owner || '').trim().toLowerCase()
|
|
36
|
-
.replace(/[^a-z0-9._-]+/g, '-').replace(/-+/g, '-').replace(/^-+|-+$/g, '') || 'head'}`;
|
|
37
|
-
|
|
38
35
|
const worktreeInputForSource = (input, source) => ({
|
|
39
36
|
...input,
|
|
40
37
|
changeRequestSource: undefined,
|
|
@@ -57,6 +54,8 @@ export const createWorktreeCreation = ({
|
|
|
57
54
|
}) => {
|
|
58
55
|
const changeRequestSourceOnRepository = async (directory, source) => {
|
|
59
56
|
if (source.classification !== 'same-repository') {
|
|
57
|
+
// A fork's remote is named after its owner, which the provider just said;
|
|
58
|
+
// the picker cannot always know it (GitLab lists merge requests without it).
|
|
60
59
|
return source.sourceProject?.owner
|
|
61
60
|
? Object.freeze({ ...source, requestedRemoteName: forkRemoteName(source.sourceProject.owner) })
|
|
62
61
|
: source;
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
- Comments and reviews take the same path: `/pr/comment` (a pull request's conversation, through the issues comments API), `/pr/review` (`approve` or `request-changes` for the target's `headSha`, the commit the user read, so a push since refuses it as a changed target; requesting changes needs text, which GitHub posts as the review body) and `/issues/comment` (refuses a number GitHub reports as a pull request). Record kinds are `change-request-comment`, `change-request-review` and `issue-comment`. A comment or review interrupted after dispatch stays `outcome-unknown`: nothing but its private text would tell a lost write from one never sent, and that text is not persisted. A `403`/`404`/`422` refusal answers with GitHub's own reason (`SOURCE_CONTROL_MUTATION_REJECTED`), such as a review of the user's own pull request; it is not stored.
|
|
75
75
|
- `/pr/state` and `/issues/state` close or reopen (`state: 'open' | 'closed'`; record kinds `change-request-state`, `issue-state`). The issue route refuses a pull request number. Restart reconciliation reads the item: the asked state is success, the other open/closed state a definite not-applied failure. A merged pull request reads `closed` and GitHub refuses to reopen it with its own reason.
|
|
76
76
|
- `/pr/labels`, `/issues/labels` and `/pr/reviewers` set the whole set, deduplicated and sorted so a repeat digests the same (record kinds `change-request-labels`, `issue-labels`, `change-request-reviewers`). Labels go through `issues.setLabels`; reviewers are compared with the requested ones and added, then removed, in two calls: asking again for the same set repairs a failure between them. Reconciliation succeeds only when the current set matches; anything else stays `outcome-unknown`, since another edit may have moved it. `GET /references/labels` and `/references/reviewers` (repository labels, assignable users, one page of 100 each) check the repository against the bound network like `/references/detail`. The detail's `pull.reviewers` lists requested users; team requests are left out. `pull.checks` summarizes the head commit's check contexts with `summarizeCheckContexts`, the same counting as the list statuses, and is null for a closed or merged PR.
|
|
77
|
-
- Canonical mutations resolve the exact local credential and its revision before inspecting durable state. The exact credential ID and revision remain in authorization and digest input, while the route derives the provider-user ID from that resolved credential and passes it separately as receipt actor `providerAccountId` and audit identity. A client-supplied provider-user ID is never accepted as authority and cannot affect either value. Terminal records replay their compact result or stored error without provider repository preflight, but only after exact credential resolution. Running records lazily read only the provider state needed for reconciliation and never repeat a write. New keys retain the full strict preflight before claim and the single provider write. Changed credential, revision, input, or binding authority conflicts. Provider `4xx` rejections are definite failures; `5xx` and statusless transport failures after dispatch remain `outcome-unknown`.
|
|
77
|
+
- Canonical mutations resolve the exact local credential and its revision before inspecting durable state. The exact credential ID and revision remain in authorization and digest input, while the route derives the provider-user ID from that resolved credential and passes it separately as receipt actor `providerAccountId` and audit identity. A client-supplied provider-user ID is never accepted as authority and cannot affect either value. Terminal records replay their compact result or stored error without provider repository preflight, but only after exact credential resolution. Running records lazily read only the provider state needed for reconciliation and never repeat a write. New keys retain the full strict preflight before claim and the single provider write. Changed credential, revision, input, or binding authority conflicts. Provider `4xx` rejections are definite failures; `5xx` and statusless transport failures after dispatch remain `outcome-unknown`. A `403`/`404`/`405`/`409`/`422` from any GitHub request of the mutation, the preflight reads as much as the write, answers with GitHub's own reason (`SOURCE_CONTROL_MUTATION_REJECTED`), such as an organization restricting OAuth apps or a merge blocked by branch protection; the stored record keeps only its status and code. Any other failure answers the generic `GitHub mutation failed`, and the server log records its status, code, and error name, never its message.
|
|
78
78
|
- Cross-process execution exclusion, lock errors, and stopped-writer orphan recovery follow the [source-control lock contract](../source-control/DOCUMENTATION.md#cross-process-locks-and-manual-recovery). A live or crashed owner's execution lock blocks reconciliation; restarting alone does not remove it.
|
|
79
79
|
- Durable mutation records keep the exact credential account actor used for replay authorization, binding authority, server-resolved project and PR coordinates, an input digest, and compact public results only. Receipt and audit actor metadata use the separately verified provider-user ID. PR title/body text and raw provider payloads are not persisted or logged.
|
|
80
80
|
- A succeeded canonical mutation, including replay or restart reconciliation, invalidates PR status and context entries for every linked-worktree directory sharing its account credential, repository ID, binding revision, primary remote, and target number. It also cancels writes from matching canonical reads that started before invalidation, so their later responses cannot refill those caches. Other accounts, repositories, and bindings remain cached. Pull-list, history, and search-miss invalidation is limited to the same credential and target repository; matching in-flight writers may finish for their original callers but cannot restore invalidated entries. In-flight tokens are discarded when each request settles. Failed, conflicted, and outcome-unknown mutations do not invalidate caches.
|
|
@@ -1266,4 +1266,18 @@ describe('gh CLI account consent', () => {
|
|
|
1266
1266
|
|
|
1267
1267
|
expect(response.body).toMatchObject({ connected: true, user: { login: 'cli-user' }, ghCli: { active: true } });
|
|
1268
1268
|
});
|
|
1269
|
+
|
|
1270
|
+
// A session with no saved account, only the gh CLI login, switched on by
|
|
1271
|
+
// hand from the Settings card (#4712).
|
|
1272
|
+
it('activates the gh CLI account when it is the only credential', async () => {
|
|
1273
|
+
stubGitHubUsers();
|
|
1274
|
+
|
|
1275
|
+
const before = await request(makeApp()).get('/api/source-control/github/auth/status').expect(200);
|
|
1276
|
+
expect(before.body).toMatchObject({ connected: false, ghCli: { available: true, active: false } });
|
|
1277
|
+
|
|
1278
|
+
const response = await request(makeApp()).post('/api/source-control/github/auth/activate')
|
|
1279
|
+
.send({ accountId: 'github.com#cli:9' }).expect(200);
|
|
1280
|
+
|
|
1281
|
+
expect(response.body).toMatchObject({ connected: true, user: { login: 'cli-user' }, ghCli: { active: true } });
|
|
1282
|
+
});
|
|
1269
1283
|
});
|
|
@@ -607,11 +607,12 @@ export function registerGitHubRoutes(app, options = {}) {
|
|
|
607
607
|
return 'outcome-unknown';
|
|
608
608
|
};
|
|
609
609
|
// GitHub's own reason for refusing a write (a locked conversation, a review
|
|
610
|
-
// of your own pull request
|
|
611
|
-
//
|
|
610
|
+
// of your own pull request, a merge blocked by branch protection, an
|
|
611
|
+
// organization restricting OAuth apps) is what the user needs to read; the
|
|
612
|
+
// generic mutation error would hide it.
|
|
612
613
|
const providerRejection = (error) => {
|
|
613
614
|
const status = error?.response?.status ?? error?.status;
|
|
614
|
-
if (![403, 404, 422].includes(status)) return error;
|
|
615
|
+
if (![403, 404, 405, 409, 422].includes(status)) return error;
|
|
615
616
|
const data = error?.response?.data;
|
|
616
617
|
const first = Array.isArray(data?.errors) ? data.errors[0] : undefined;
|
|
617
618
|
const detail = [first, first?.message, data?.message].find((value) => isProviderString(value) && value.trim());
|
|
@@ -681,7 +682,11 @@ export function registerGitHubRoutes(app, options = {}) {
|
|
|
681
682
|
const code = isProviderString(error?.code) && error.code
|
|
682
683
|
? error.code
|
|
683
684
|
: 'GITHUB_MUTATION_FAILED';
|
|
684
|
-
const
|
|
685
|
+
const ownMessage = isMutationContextError(error) || code.startsWith('SOURCE_CONTROL_MUTATION_') || code.startsWith('SOURCE_CONTROL_LOCK_');
|
|
686
|
+
// The generic answer hides the cause from the user, so the log keeps its
|
|
687
|
+
// status and code; never the message, which may echo private input.
|
|
688
|
+
if (!ownMessage && status !== 401) console.warn(`GitHub mutation failed: ${status} ${code} ${error?.name ?? 'unknown'}`);
|
|
689
|
+
const message = ownMessage
|
|
685
690
|
? error.message
|
|
686
691
|
: status === 401 ? 'GitHub account is unavailable' : 'GitHub mutation failed';
|
|
687
692
|
const body = { error: message, code };
|
|
@@ -1077,7 +1082,10 @@ export function registerGitHubRoutes(app, options = {}) {
|
|
|
1077
1082
|
await invalidateCanonicalMutationCaches(context, accountContext, execution.record.target);
|
|
1078
1083
|
return res.json(changeRequestReceipt(execution.record, execution.replayed, accountContext.providerUserId));
|
|
1079
1084
|
} catch (error) {
|
|
1080
|
-
|
|
1085
|
+
// A refusal from any GitHub request on the way, the preflight reads as
|
|
1086
|
+
// much as the write, answers with GitHub's reason. The failed record is
|
|
1087
|
+
// already stored with its status and code by then.
|
|
1088
|
+
return sendCanonicalMutationError(res, error?.response ? providerRejection(error) : error);
|
|
1081
1089
|
}
|
|
1082
1090
|
};
|
|
1083
1091
|
|
|
@@ -799,7 +799,7 @@ describe('canonical GitHub mutations', () => {
|
|
|
799
799
|
|
|
800
800
|
it('does not retry or invalidate after a definite provider rejection', async () => {
|
|
801
801
|
const account = await auth.setGitHubAuth({ accessToken: 'token-one', user: { id: 1, login: 'actor' } });
|
|
802
|
-
const fetch = vi.fn(async () => jsonResponse({ message: '
|
|
802
|
+
const fetch = vi.fn(async () => jsonResponse({ message: 'A pull request already exists for acme:feature.' }, 422));
|
|
803
803
|
vi.stubGlobal('fetch', fetch);
|
|
804
804
|
const { app, store } = makeApp();
|
|
805
805
|
const now = vi.spyOn(Date, 'now');
|
|
@@ -813,13 +813,29 @@ describe('canonical GitHub mutations', () => {
|
|
|
813
813
|
now.mockReturnValue(2_000);
|
|
814
814
|
const response = await request(app).post('/api/source-control/github/pr/create')
|
|
815
815
|
.send({ ...context(account.accountId), title: 'private title' }).expect(422);
|
|
816
|
-
expect(response.body).toEqual({ error: '
|
|
816
|
+
expect(response.body).toEqual({ error: 'A pull request already exists for acme:feature.', code: 'SOURCE_CONTROL_MUTATION_REJECTED' });
|
|
817
817
|
expect(fetch).toHaveBeenCalledOnce();
|
|
818
818
|
expect(store.records.get('request-one')).toMatchObject({ state: 'failed', result: { failureStatus: 422, failureCode: 'GITHUB_MUTATION_REJECTED' } });
|
|
819
819
|
now.mockReturnValue(3_000);
|
|
820
820
|
expect((await request(app).get('/api/source-control/github/pr/status').query(statusQuery)).body.fetchedAt).toBe(1_000);
|
|
821
821
|
});
|
|
822
822
|
|
|
823
|
+
it('answers with GitHub\'s reason when it refuses a read before the write', async () => {
|
|
824
|
+
const account = await auth.setGitHubAuth({ accessToken: 'token-one', user: { id: 1, login: 'actor' } });
|
|
825
|
+
const restricted = 'Although you appear to have the correct authorization credentials, the `acme` organization has enabled OAuth App access restrictions.';
|
|
826
|
+
const fetch = vi.fn(async () => jsonResponse({ message: restricted }, 403));
|
|
827
|
+
vi.stubGlobal('fetch', fetch);
|
|
828
|
+
const { app, store } = makeApp();
|
|
829
|
+
|
|
830
|
+
const response = await request(app).post('/api/source-control/github/pr/merge')
|
|
831
|
+
.send({ ...context(account.accountId, { target: { project: { owner: 'acme', name: 'app' }, number: 7 } }), method: 'squash' })
|
|
832
|
+
.expect(403);
|
|
833
|
+
|
|
834
|
+
expect(response.body).toEqual({ error: restricted, code: 'SOURCE_CONTROL_MUTATION_REJECTED' });
|
|
835
|
+
expect(fetch).toHaveBeenCalledOnce();
|
|
836
|
+
expect(store.records.size).toBe(0);
|
|
837
|
+
});
|
|
838
|
+
|
|
823
839
|
it('invalidates canonical status only for the successful mutation authority', async () => {
|
|
824
840
|
const acting = await auth.setGitHubAuth({ accessToken: 'token-one', user: { id: 1, login: 'actor' } });
|
|
825
841
|
const unrelated = await auth.setGitHubAuth({ accessToken: 'token-two', user: { id: 2, login: 'other' } });
|
|
@@ -28,7 +28,9 @@ JSON bodies enabled in `opencode/core-routes.js`; stopped by
|
|
|
28
28
|
the queued send config names `openchamber/auto`, and answers with the real
|
|
29
29
|
model and agent. OpenCode 2.x holds both on the session, so the queue applies
|
|
30
30
|
them with the `POST /api/session/:id/model` and `/agent` calls it already
|
|
31
|
-
makes. The queue captures the sentinel like any other send config.
|
|
31
|
+
makes. The queue captures the sentinel like any other send config. The request
|
|
32
|
+
text it routes on carries the same image attachment fact as a direct send
|
|
33
|
+
(`attachmentHint`).
|
|
32
34
|
|
|
33
35
|
## Item
|
|
34
36
|
|
|
@@ -135,9 +137,13 @@ persisted "sending" flag would strand a message forever.
|
|
|
135
137
|
the tick re-arms with backoff.
|
|
136
138
|
The turn must also be over for the session's subagents: a parent idles
|
|
137
139
|
while a background subagent works and runs again when OpenCode hands the
|
|
138
|
-
result back. While `../opencode/session-activity.js` finds a running
|
|
140
|
+
result back. While `../opencode/session-activity.js` finds a running descendant
|
|
139
141
|
the head waits (the rerun's idle event re-arms it, a 5 s recheck covers a
|
|
140
142
|
missed one); a failed check is unknown and backs off like the rest.
|
|
143
|
+
The descendant check follows live active sessions through at most 8 parent
|
|
144
|
+
links, including idle intermediate subagents; a deeper chain counts as
|
|
145
|
+
unrelated, as in the UI. Unreadable lineage, cycles and the shared fetch
|
|
146
|
+
deadline keep the queue held with the existing retry policy. It does not scan historical child pages.
|
|
141
147
|
5. The head is marked in flight (broadcast), then sent. The captured model and
|
|
142
148
|
agent are switched onto the session first (`POST /session/:id/model`,
|
|
143
149
|
`/agent`), because v2 holds both on the session rather than in the body; a
|
|
@@ -16,6 +16,7 @@ import path from 'path';
|
|
|
16
16
|
import { assertPromptResponse } from '../opencode/prompt-response.js';
|
|
17
17
|
import { unwrapOpenCodeResponse } from '../opencode/response-envelope.js';
|
|
18
18
|
import { createSessionActivityProbe } from '../opencode/session-activity.js';
|
|
19
|
+
import { attachmentHint } from '../routing/runtime.js';
|
|
19
20
|
|
|
20
21
|
const QUEUE_FILE_NAME = 'message-queue.json';
|
|
21
22
|
const QUEUE_FILE_VERSION = 1;
|
|
@@ -438,7 +439,7 @@ export function createMessageQueueRuntime({
|
|
|
438
439
|
const hasWorkingSubagents = async (sessionId) => {
|
|
439
440
|
const statuses = await activityProbe.fetchActiveSessionStatuses();
|
|
440
441
|
if (!statuses) return null;
|
|
441
|
-
return activityProbe.
|
|
442
|
+
return activityProbe.hasWorkingDescendants(sessionId, statuses);
|
|
442
443
|
};
|
|
443
444
|
|
|
444
445
|
const isSessionIdle = async (sessionId, directory) => {
|
|
@@ -521,7 +522,7 @@ export function createMessageQueueRuntime({
|
|
|
521
522
|
directory,
|
|
522
523
|
model,
|
|
523
524
|
agent,
|
|
524
|
-
requestText: item.text,
|
|
525
|
+
requestText: `${item.text}${attachmentHint({ files: promptFiles })}`.trim(),
|
|
525
526
|
}) : null;
|
|
526
527
|
if (routed) {
|
|
527
528
|
model = routed.model;
|
|
@@ -65,6 +65,11 @@ const createOpenCode = () => {
|
|
|
65
65
|
const parentID = new URL(url).searchParams.get('parentID');
|
|
66
66
|
return Response.json({ data: (state.children[parentID] ?? []).map((id) => ({ id, parentID })), cursor: {} });
|
|
67
67
|
}
|
|
68
|
+
if (/^\/api\/session\/[^/]+$/.test(pathname) && method === 'GET') {
|
|
69
|
+
const id = decodeURIComponent(pathname.split('/').at(-1));
|
|
70
|
+
const parentID = Object.keys(state.children).find((parent) => state.children[parent].includes(id));
|
|
71
|
+
return wrapped({ id, parentID });
|
|
72
|
+
}
|
|
68
73
|
if (pathname.endsWith('/message')) return Response.json({ data: state.tail, cursor: {} });
|
|
69
74
|
if (pathname === '/api/command') return wrapped(state.commands);
|
|
70
75
|
if (method === 'POST' && (pathname.endsWith('/model') || pathname.endsWith('/agent'))) {
|
|
@@ -320,6 +325,22 @@ describe('auto routing', () => {
|
|
|
320
325
|
expect(resolveAutoSelection).toHaveBeenCalledTimes(2);
|
|
321
326
|
expect(resolveAutoSelection.mock.calls[0][0]).toMatchObject({ sessionId: SESSION, directory: DIRECTORY, requestText: 'plain' });
|
|
322
327
|
});
|
|
328
|
+
|
|
329
|
+
it('tells the classifier about an image attached to a queued send', async () => {
|
|
330
|
+
const resolveAutoSelection = vi.fn(async () => null);
|
|
331
|
+
const { runtime, openCode, emit } = createRuntime({ resolveAutoSelection });
|
|
332
|
+
runtime.start();
|
|
333
|
+
openCode.state.statuses = { [SESSION]: { type: 'busy' } };
|
|
334
|
+
const auto = { providerID: 'openchamber', modelID: 'auto', agent: 'build' };
|
|
335
|
+
const image = { id: 'a', filename: 'shot.png', mimeType: 'image/png', size: 1, source: 'local', dataUrl: 'data:image/png;base64,AAAA' };
|
|
336
|
+
await runtime.enqueue(SESSION, DIRECTORY, item({ content: "what's wrong?", text: "what's wrong?", attachments: [image], sendConfig: auto }));
|
|
337
|
+
|
|
338
|
+
openCode.state.statuses = {};
|
|
339
|
+
emit({ type: 'session.status', properties: { sessionID: SESSION, status: { type: 'idle' } } });
|
|
340
|
+
await settle();
|
|
341
|
+
|
|
342
|
+
expect(resolveAutoSelection.mock.calls[0][0].requestText).toBe("what's wrong?\n\n[The user attached an image: shot.png]");
|
|
343
|
+
});
|
|
323
344
|
});
|
|
324
345
|
|
|
325
346
|
describe('parseQueuedItemInput', () => {
|
|
@@ -420,6 +441,48 @@ describe('message queue runtime', () => {
|
|
|
420
441
|
expect(openCode.state.sent[0].body).toEqual({ text: 'next' });
|
|
421
442
|
});
|
|
422
443
|
|
|
444
|
+
it('keeps queued messages until a nested background subagent finishes', async () => {
|
|
445
|
+
const { runtime, openCode, emit } = createRuntime();
|
|
446
|
+
runtime.start();
|
|
447
|
+
openCode.state.children = { [SESSION]: ['ses_child'], ses_child: ['ses_grandchild'] };
|
|
448
|
+
openCode.state.active = { ses_grandchild: { type: 'running' } };
|
|
449
|
+
await runtime.enqueue(SESSION, DIRECTORY, item({ content: 'first', text: 'first' }));
|
|
450
|
+
await runtime.enqueue(SESSION, DIRECTORY, item({ content: 'second', text: 'second' }));
|
|
451
|
+
emit({ type: 'session.status', properties: { sessionID: SESSION, status: { type: 'idle' } } });
|
|
452
|
+
await settle();
|
|
453
|
+
expect(openCode.state.sent).toHaveLength(0);
|
|
454
|
+
expect(runtime.sessionSnapshot(SESSION).items).toHaveLength(2);
|
|
455
|
+
|
|
456
|
+
openCode.state.active = {};
|
|
457
|
+
emit({ type: 'session.status', properties: { sessionID: SESSION, status: { type: 'idle' } } });
|
|
458
|
+
await settle();
|
|
459
|
+
expect(openCode.state.sent.map((entry) => entry.body.text)).toEqual(['first']);
|
|
460
|
+
expect(runtime.sessionSnapshot(SESSION).items).toHaveLength(1);
|
|
461
|
+
emit({ type: 'session.status', properties: { sessionID: SESSION, status: { type: 'busy' } } });
|
|
462
|
+
emit({ type: 'session.status', properties: { sessionID: SESSION, status: { type: 'idle' } } });
|
|
463
|
+
await settle();
|
|
464
|
+
expect(openCode.state.sent.map((entry) => entry.body.text)).toEqual(['first', 'second']);
|
|
465
|
+
runtime.stop();
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
it('keeps the queue intact when a nested lineage read fails', async () => {
|
|
469
|
+
const { runtime, openCode, emit } = createRuntime();
|
|
470
|
+
runtime.start();
|
|
471
|
+
openCode.state.children = { [SESSION]: ['ses_child'], ses_child: ['ses_grandchild'] };
|
|
472
|
+
openCode.state.active = { ses_grandchild: { type: 'running' } };
|
|
473
|
+
openCode.state.failNext = /\/api\/session\/ses_child$/;
|
|
474
|
+
await runtime.enqueue(SESSION, DIRECTORY, item());
|
|
475
|
+
emit({ type: 'session.status', properties: { sessionID: SESSION, status: { type: 'idle' } } });
|
|
476
|
+
await settle();
|
|
477
|
+
expect(openCode.state.sent).toHaveLength(0);
|
|
478
|
+
expect(runtime.sessionSnapshot(SESSION).items).toHaveLength(1);
|
|
479
|
+
openCode.state.active = {};
|
|
480
|
+
emit({ type: 'session.status', properties: { sessionID: SESSION, status: { type: 'idle' } } });
|
|
481
|
+
await settle();
|
|
482
|
+
expect(openCode.state.sent).toHaveLength(1);
|
|
483
|
+
runtime.stop();
|
|
484
|
+
});
|
|
485
|
+
|
|
423
486
|
it('does not send into a running turn even when the status event says idle', async () => {
|
|
424
487
|
const { runtime, openCode, emit } = createRuntime({ now: () => 10_000 });
|
|
425
488
|
runtime.start();
|
|
@@ -571,12 +634,11 @@ describe('message queue runtime', () => {
|
|
|
571
634
|
const { runtime, openCode, emit } = createRuntime();
|
|
572
635
|
runtime.start();
|
|
573
636
|
let release;
|
|
574
|
-
// active map, message tail, the subagent check (active map
|
|
637
|
+
// active map, message tail, the subagent check (empty active map),
|
|
575
638
|
// model switch, then the prompt itself (held open until released)
|
|
576
639
|
openCode.fetchImpl.mockImplementationOnce(async () => Response.json({ location: {}, data: {} }))
|
|
577
640
|
.mockImplementationOnce(async () => Response.json({ data: [], cursor: {} }))
|
|
578
641
|
.mockImplementationOnce(async () => Response.json({ data: {} }))
|
|
579
|
-
.mockImplementationOnce(async () => Response.json({ data: [], cursor: {} }))
|
|
580
642
|
.mockImplementationOnce(async () => new Response(null, { status: 204 }))
|
|
581
643
|
.mockImplementationOnce(() => new Promise((resolve) => { release = () => resolve(new Response(null, { status: 204 })); }));
|
|
582
644
|
const { itemId } = await runtime.enqueue(SESSION, DIRECTORY, item());
|
|
@@ -389,10 +389,18 @@ export const createOpenChamberControlService = (dependencies) => {
|
|
|
389
389
|
const resolveSessionDirectory = async (sessionID) => {
|
|
390
390
|
try {
|
|
391
391
|
const client = await getClient();
|
|
392
|
-
const
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
392
|
+
const seenCursors = new Set();
|
|
393
|
+
let cursor;
|
|
394
|
+
for (;;) {
|
|
395
|
+
const response = await client.session.list(cursor ? { cursor } : {});
|
|
396
|
+
const sessions = Array.isArray(response?.data) ? response.data : [];
|
|
397
|
+
const session = sessions.find((item) => item?.id === sessionID);
|
|
398
|
+
if (session) return asNonEmptyString(session?.location?.directory) || null;
|
|
399
|
+
const next = asNonEmptyString(response?.cursor?.next);
|
|
400
|
+
if (!next || seenCursors.has(next)) return null;
|
|
401
|
+
seenCursors.add(next);
|
|
402
|
+
cursor = next;
|
|
403
|
+
}
|
|
396
404
|
} catch {
|
|
397
405
|
return null;
|
|
398
406
|
}
|
|
@@ -804,15 +812,42 @@ export const createOpenChamberControlService = (dependencies) => {
|
|
|
804
812
|
const client = await getClient(directory);
|
|
805
813
|
if (action === 'session.list') {
|
|
806
814
|
const limit = positiveInteger(input.limit, 10, 'limit');
|
|
807
|
-
|
|
808
|
-
//
|
|
809
|
-
//
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
815
|
+
// Session reads are cursor-paginated: one upstream page is not the
|
|
816
|
+
// collection. Collect only until the limit is satisfied, skip ids a
|
|
817
|
+
// repeated page already contributed, and stop on a cursor seen twice
|
|
818
|
+
// so a pathological server cannot spin the walk.
|
|
819
|
+
const collected = [];
|
|
820
|
+
const seenCursors = new Set();
|
|
821
|
+
const seenSessionIds = new Set();
|
|
822
|
+
let cursor;
|
|
823
|
+
for (;;) {
|
|
824
|
+
const listInput = {};
|
|
825
|
+
if (directory) listInput.directory = directory;
|
|
826
|
+
if (cursor) listInput.cursor = cursor;
|
|
827
|
+
const response = await client.session.list(listInput);
|
|
828
|
+
// Archive is OpenChamber state; overlay it so callers keep reading
|
|
829
|
+
// it off the session the way OpenCode used to report it.
|
|
830
|
+
const page = await Promise.all((Array.isArray(response?.data) ? response.data : []).map(async (session) => {
|
|
831
|
+
const archived = await archivedAt(session?.id);
|
|
832
|
+
return archived ? { ...session, time: { ...session.time, archived } } : session;
|
|
833
|
+
}));
|
|
834
|
+
for (const session of page) {
|
|
835
|
+
const id = asNonEmptyString(session?.id);
|
|
836
|
+
if (id) {
|
|
837
|
+
if (seenSessionIds.has(id)) continue;
|
|
838
|
+
seenSessionIds.add(id);
|
|
839
|
+
}
|
|
840
|
+
if (input.all !== true && session?.time?.archived) continue;
|
|
841
|
+
collected.push(session);
|
|
842
|
+
if (collected.length >= limit) break;
|
|
843
|
+
}
|
|
844
|
+
if (collected.length >= limit) break;
|
|
845
|
+
const next = asNonEmptyString(response?.cursor?.next);
|
|
846
|
+
if (!next || page.length === 0 || seenCursors.has(next)) break;
|
|
847
|
+
seenCursors.add(next);
|
|
848
|
+
cursor = next;
|
|
849
|
+
}
|
|
850
|
+
let sessions = collected.slice(0, limit);
|
|
816
851
|
if (input.withStatus === true) {
|
|
817
852
|
// One global call now: v2 reports active sessions across directories.
|
|
818
853
|
const statuses = await activeSessions(client).catch(() => null);
|