@openchamber/web 2.0.4 → 2.1.0
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/{CodeMirrorCommentWidgets-C_zL-eri.js → CodeMirrorCommentWidgets-qlshRzAf.js} +1 -1
- package/dist/assets/{DiffView-BeN2_YYF.js → DiffView-BI_YgdKl.js} +3 -3
- package/dist/assets/FilesView-B_NJFLBH.js +17 -0
- package/dist/assets/{GitView-DLDazOo1.js → GitView-BWKg6TNS.js} +4 -4
- package/dist/assets/{GuestAttachDialog-C0xe_Lyy.js → GuestAttachDialog-DO4x4vIR.js} +1 -1
- package/dist/assets/{GuestSurfacePane-BdaurnDr.js → GuestSurfacePane-4PY11vEP.js} +1 -1
- package/dist/assets/JsonTreeView-u4yx65zn.js +1 -0
- package/dist/assets/{LinearIssuesView-BryoAHow.js → LinearIssuesView-C4gGBhU8.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-DfuEoaGq.js → MarkdownImageGallery-fqVRCTdC.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-Cfb5fTnq.js +39 -0
- package/dist/assets/OnboardingScreen-CiTV2_OT.js +1 -0
- package/dist/assets/PatchDiff-BrjhzXDM.js +1 -0
- package/dist/assets/{PierreDiffViewer-BC950e3F.js → PierreDiffViewer-CVx2e1cx.js} +5 -5
- package/dist/assets/{PlanView-B7Xgihqk.js → PlanView-DP9DOnI-.js} +4 -4
- package/dist/assets/{PluginPane-2C71F8uF.js → PluginPane-rZvoMQSi.js} +3 -3
- package/dist/assets/SettingsView-Dp9jubRs.js +30 -0
- package/dist/assets/SettingsWindow-Dst0yiV7.js +1 -0
- package/dist/assets/{SubmoduleDiffSummary-BSA9gnIO.js → SubmoduleDiffSummary-CixkM4fI.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DprkVKcj.js → ToolOutputDialog-f0cS2DIf.js} +6 -6
- package/dist/assets/ToolPartDiffPreview-CFFIAFFY.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-Kp8hKJdT.js → VirtualizedFileDiff-B-U_aQwV.js} +4 -4
- package/dist/assets/{WalkthroughView-DGnTzqIU.js → WalkthroughView-C1uB3Pl3.js} +2 -2
- package/dist/assets/{appThemeRegistry-BdEHBA4s.js → appThemeRegistry-DU-UKEHq.js} +1 -1
- package/dist/assets/{commitAndPush-LwtVa2Oc.js → commitAndPush-CtWGqrtW.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-6V1xNpO9.js → computeVirtualFileMetrics-BmhViPMt.js} +1 -1
- package/dist/assets/de-D4hpTCNY.js +10 -0
- package/dist/assets/es-Bw9m3H62.js +16 -0
- package/dist/assets/fileTreeStatus-CvPnAWSi.js +1 -0
- package/dist/assets/fr-Bhll42P0.js +14 -0
- package/dist/assets/index-Btd2mmYT.js +42 -0
- package/dist/assets/index-C-7hQnEc.css +1 -0
- package/dist/assets/{index-CmNPYddV.js → index-DwtCnbiK.js} +1 -1
- package/dist/assets/{isDiffPlainText-1bXcWCrw.js → isDiffPlainText-CPDhzF1K.js} +1 -1
- package/dist/assets/{isFilePlainText-CBAppvy1.js → isFilePlainText-n8k0lMTZ.js} +1 -1
- package/dist/assets/ja-CsHoT43d.js +16 -0
- package/dist/assets/ko-BBNdtFa4.js +16 -0
- package/dist/assets/{main-CzjTMTfW.js → main-D6rlXjug.js} +2 -2
- package/dist/assets/main-kYkr_urz.js +1000 -0
- package/dist/assets/markdownCore-CHm8ycaW.js +7 -0
- package/dist/assets/{miniChat-CP68IL8Q.js → miniChat-2JY8K3Qw.js} +2 -2
- package/dist/assets/mobile-CviaXnnU.js +2 -0
- package/dist/assets/nl-DszyktfH.js +16 -0
- package/dist/assets/openSessionFromRoute-BIlcJIf3.js +1 -0
- package/dist/assets/{web-components-ngpHPEDU.js → parseDiffFromFile-DeZzEah8.js} +5 -5
- package/dist/assets/{patchFileDiff-pqRSHLHI.js → patchFileDiff-BnEHIdM2.js} +2 -2
- package/dist/assets/pl-Bk9_mUXc.js +16 -0
- package/dist/assets/pt-BR-BIXmm3Gw.js +16 -0
- package/dist/assets/{renderElectronMiniChatApp-DKIilR7N.js → renderElectronMiniChatApp-DvUphkjj.js} +2 -2
- package/dist/assets/renderMobileApp-Cdc49X8Y.js +25 -0
- package/dist/assets/runtimeEndpointReset-Cu6RUve4.js +56 -0
- package/dist/assets/shikiHighlight-CcVzlYit.js +1 -0
- package/dist/assets/space-apply-CgJ5JYPK.js +1 -0
- package/dist/assets/space-close-C1tL-_0t.js +1 -0
- package/dist/assets/{textMateThemeFromAppTheme-BSUFChBY.js → textMateThemeFromAppTheme-CAOCeVjl.js} +1 -1
- package/dist/assets/tr-C_13w7CX.js +7 -0
- package/dist/assets/uk-BZTsG-q_.js +16 -0
- package/dist/assets/{useAppFontEffects-Dsl_sLrj.js → useAppFontEffects-CeMgbeVa.js} +185 -177
- package/dist/assets/{useInlineCommentController-d5vntsQ_.js → useInlineCommentController-U97JJifS.js} +2 -2
- package/dist/assets/useRootScrollLock-DMBY2aTT.js +2 -0
- package/dist/assets/{vendor-base-ui-DnNniUWp.js → vendor-base-ui-DWgyZK2k.js} +1 -1
- package/dist/assets/vendor-codemirror-autocomplete-DetzHhtC.js +1 -0
- package/dist/assets/{vendor-codemirror-commands-B7H_j0iU.js → vendor-codemirror-commands-ConqfjLn.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-DEPs2M5t.js → vendor-codemirror-lang-angular-Dbpx8qe-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-DhkseaMo.js → vendor-codemirror-lang-cpp-TRtQWrpl.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-O0cZX78y.js → vendor-codemirror-lang-css-DY4CGDG2.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-fMdQYcON.js → vendor-codemirror-lang-go-CLKXh6B8.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-CfgK872x.js → vendor-codemirror-lang-html-CQnNjmg9.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-CQj4S3zl.js → vendor-codemirror-lang-java-CokZKqls.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-Cc2ZYbgX.js → vendor-codemirror-lang-javascript-Kgp6fZRE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-BmZZv8g-.js → vendor-codemirror-lang-jinja-DZchyrN1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-CMBS2tG9.js → vendor-codemirror-lang-json-CkdBRvqj.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-C6Eo8hVS.js → vendor-codemirror-lang-less-_k-GKz0A.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-DSTR47-H.js → vendor-codemirror-lang-liquid-DuHUMKoh.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-BPGOH9ye.js → vendor-codemirror-lang-markdown-CdG1RXm1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-DD9udfPH.js → vendor-codemirror-lang-php-Ca15KQSA.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-HahnQaAS.js → vendor-codemirror-lang-python-B4MRHRva.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-nLTovbjv.js → vendor-codemirror-lang-rust-8fLJdxQA.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-pL2Yc72v.js → vendor-codemirror-lang-sass-CASr_yQ1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-BVBnan19.js → vendor-codemirror-lang-sql-Dc4ER-re.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-BqGzJVm1.js → vendor-codemirror-lang-vue-fu2BqdK2.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-B0_m5DqU.js → vendor-codemirror-lang-wast-BkCOgSpV.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-Dj3voadT.js → vendor-codemirror-lang-xml-7e-kPepH.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-yu-9Z5u7.js → vendor-codemirror-lang-yaml-Cq3p_9DI.js} +1 -1
- package/dist/assets/vendor-codemirror-language-CZcLdzDM.js +3 -0
- package/dist/assets/{vendor-codemirror-language-data-B1EetJur.js → vendor-codemirror-language-data-B8HKnqZy.js} +2 -2
- package/dist/assets/vendor-codemirror-search-BZNojiZO.js +2 -0
- package/dist/assets/{vendor-codemirror-state-C9awkmn-.js → vendor-codemirror-state--21VQleR.js} +1 -1
- package/dist/assets/vendor-codemirror-view-8PpN-8l4.js +4 -0
- package/dist/assets/vendor-opencode-client-Byb4ZSqI.js +12 -0
- package/dist/assets/vendor-remend-DcBOpbSu.js +24 -0
- package/dist/assets/{vendor-replit-codemirror-vim-B2DJlAhT.js → vendor-replit-codemirror-vim-EX7OnecQ.js} +1 -1
- package/dist/assets/zh-CN-C62wm2Tg.js +16 -0
- package/dist/assets/zh-TW-BgGTiQA6.js +16 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +4 -4
- package/server/index.js +58 -1
- package/server/lib/browser-control/DOCUMENTATION.md +8 -1
- package/server/lib/dev-tunnel/DOCUMENTATION.md +6 -0
- package/server/lib/dev-tunnel/runtime.js +94 -38
- package/server/lib/dev-tunnel/tunnel.test.js +16 -2
- package/server/lib/dictation/DOCUMENTATION.md +23 -10
- package/server/lib/dictation/audio.js +28 -0
- package/server/lib/dictation/local/sherpa-recognizer.js +33 -7
- package/server/lib/dictation/local/sherpa-recognizer.test.js +94 -0
- package/server/lib/dictation/local/worker-client.js +28 -10
- package/server/lib/dictation/local/worker-process.js +25 -1
- package/server/lib/dictation/stream-manager.js +160 -53
- package/server/lib/dictation/stream-manager.test.js +108 -7
- package/server/lib/enterprise-mode.d.ts +2 -0
- package/server/lib/enterprise-mode.js +84 -9
- package/server/lib/enterprise-mode.test.js +115 -0
- package/server/lib/fs/DOCUMENTATION.md +3 -2
- package/server/lib/fs/routes.js +28 -1
- package/server/lib/fs/routes.test.js +31 -5
- package/server/lib/git/DOCUMENTATION.md +1 -1
- package/server/lib/git/service.js +61 -2
- package/server/lib/git/service.test.js +141 -0
- package/server/lib/github/DOCUMENTATION.md +18 -0
- package/server/lib/github/checks-summary.js +76 -0
- package/server/lib/github/pr-summaries.js +282 -0
- package/server/lib/github/pr-summaries.test.js +209 -0
- package/server/lib/github/routes.js +42 -77
- package/server/lib/github/routes.test.js +77 -0
- package/server/lib/inherited-env.js +51 -0
- package/server/lib/inherited-env.test.js +59 -0
- package/server/lib/message-search/DOCUMENTATION.md +83 -0
- package/server/lib/message-search/indexer.js +336 -0
- package/server/lib/message-search/indexer.test.js +341 -0
- package/server/lib/message-search/routes.js +92 -0
- package/server/lib/message-search/runtime.js +234 -0
- package/server/lib/message-search/runtime.test.js +108 -0
- package/server/lib/message-search/sqlite.js +74 -0
- package/server/lib/message-search/store.js +289 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
- package/server/lib/openchamber-control/actions.js +1 -1
- package/server/lib/openchamber-control/service.js +21 -2
- package/server/lib/openchamber-control/service.test.js +50 -0
- package/server/lib/openchamber-sessions/routes.js +15 -0
- package/server/lib/openchamber-sessions/routes.test.js +31 -0
- package/server/lib/opencode/DOCUMENTATION.md +43 -38
- package/server/lib/opencode/auth.d.ts +24 -0
- package/server/lib/opencode/auth.js +130 -66
- package/server/lib/opencode/auth.test.js +114 -70
- package/server/lib/opencode/compatibility.js +4 -3
- package/server/lib/opencode/compatibility.test.js +10 -10
- package/server/lib/opencode/feature-routes-runtime.js +3 -0
- package/server/lib/opencode/lifecycle.js +21 -12
- package/server/lib/opencode/lifecycle.test.js +38 -5
- package/server/lib/opencode/provider-source-route.test.js +55 -2
- package/server/lib/opencode/routes.js +17 -4
- package/server/lib/opencode/settings-helpers.js +6 -0
- package/server/lib/opencode/settings-helpers.test.js +1 -1
- package/server/lib/opencode/settings-registry.json +16 -0
- package/server/lib/opencode/settings-runtime.js +9 -0
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/opencode/v1-migration-topup.js +13 -3
- package/server/lib/opencode/v2-install.test.js +13 -13
- package/server/lib/quota/DOCUMENTATION.md +11 -5
- package/server/lib/quota/providers/claude/auth.js +19 -6
- package/server/lib/quota/providers/claude/auth.test.js +22 -9
- package/server/lib/quota/providers/claude/index.js +3 -3
- package/server/lib/quota/providers/claude/index.test.js +3 -2
- package/server/lib/quota/providers/cline-pass.js +4 -4
- package/server/lib/quota/providers/codex.js +3 -4
- package/server/lib/quota/providers/codex.test.js +1 -1
- package/server/lib/quota/providers/copilot.js +4 -5
- package/server/lib/quota/providers/copilot.test.js +1 -1
- package/server/lib/quota/providers/deepseek.js +3 -4
- package/server/lib/quota/providers/deepseek.test.js +1 -1
- package/server/lib/quota/providers/google/auth.js +1 -3
- package/server/lib/quota/providers/google/index.js +3 -2
- package/server/lib/quota/providers/hyper.js +4 -4
- package/server/lib/quota/providers/index.js +9 -2
- package/server/lib/quota/providers/index.test.js +5 -3
- package/server/lib/quota/providers/kimi.js +16 -11
- package/server/lib/quota/providers/kimi.test.js +81 -38
- package/server/lib/quota/providers/minimax-shared.js +3 -4
- package/server/lib/quota/providers/nanogpt.js +3 -4
- package/server/lib/quota/providers/neuralwatt.js +3 -4
- package/server/lib/quota/providers/neuralwatt.test.js +1 -1
- package/server/lib/quota/providers/openai.js +2 -8
- package/server/lib/quota/providers/opencode-go.js +5 -5
- package/server/lib/quota/providers/opencode-go.test.js +1 -1
- package/server/lib/quota/providers/openrouter.js +30 -6
- package/server/lib/quota/providers/openrouter.test.js +122 -1
- package/server/lib/quota/providers/wafer.js +3 -4
- package/server/lib/quota/providers/xai.js +12 -12
- package/server/lib/quota/providers/zai.js +3 -4
- package/server/lib/quota/providers/zai.test.js +1 -1
- package/server/lib/quota/providers/zhipuai-coding-plan.js +5 -6
- package/server/lib/quota/providers/zhipuai-coding-plan.test.js +1 -1
- package/server/lib/quota/routes.js +1 -1
- package/server/lib/routing/DOCUMENTATION.md +4 -0
- package/server/lib/routing/runtime.js +45 -4
- package/server/lib/routing/runtime.test.js +35 -6
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +27 -0
- package/server/lib/scheduled-tasks/chats-scope.js +50 -0
- package/server/lib/scheduled-tasks/runtime.js +57 -23
- package/server/lib/scheduled-tasks/runtime.test.js +103 -1
- package/server/lib/scheduled-tasks/service.js +37 -29
- package/server/lib/scheduled-tasks/service.test.js +39 -0
- package/server/lib/spaces/DOCUMENTATION.md +54 -9
- package/server/lib/spaces/host.js +24 -3
- package/server/lib/spaces/journey.js +111 -11
- package/server/lib/spaces/journey.test.js +189 -8
- package/server/lib/spaces/places/docker-disk.js +151 -0
- package/server/lib/spaces/places/docker-disk.test.js +167 -0
- package/server/lib/spaces/places/docker-tools.js +11 -1
- package/server/lib/spaces/places/docker.js +4 -2
- package/server/lib/spaces/places/fake-docker.js +36 -2
- package/server/lib/spaces/routes.js +21 -4
- package/server/lib/spaces/routes.test.js +6 -2
- package/server/lib/spaces/space-archive.js +275 -0
- package/server/lib/spaces/space-archive.test.js +194 -0
- package/server/lib/spaces/space-opencode.js +139 -6
- package/server/lib/spaces/space-opencode.test.js +82 -1
- package/server/lib/spaces/space-records.js +3 -0
- package/server/lib/spaces/space-setup.js +10 -5
- package/server/lib/spaces/space-setup.test.js +8 -2
- package/server/lib/terminal/DOCUMENTATION.md +1 -0
- package/server/lib/terminal/runtime.js +6 -1
- package/server/lib/terminal/runtime.test.js +19 -0
- package/server/lib/tts/routes.js +2 -2
- package/server/lib/tts/service.js +8 -8
- package/dist/assets/FilesView-CN34wm_N.js +0 -17
- package/dist/assets/JsonTreeView-B1Xq-k2t.js +0 -1
- package/dist/assets/MarkdownRendererImpl-B_ZcWOvX.js +0 -12
- package/dist/assets/OnboardingScreen-C22bGmnP.js +0 -1
- package/dist/assets/PatchDiff-0xd6UeFB.js +0 -1
- package/dist/assets/SettingsView-m_zoFiaT.js +0 -30
- package/dist/assets/SettingsWindow-CofS020b.js +0 -1
- package/dist/assets/ToolPartDiffPreview-Dq0go_fX.js +0 -8
- package/dist/assets/de-DlgBHUAI.js +0 -10
- package/dist/assets/es-BC8G41U8.js +0 -16
- package/dist/assets/fr-I0z3vVjy.js +0 -14
- package/dist/assets/index-CgR5rJq_.js +0 -41
- package/dist/assets/index-adyy_sEk.css +0 -1
- package/dist/assets/ja-BIElEsY8.js +0 -16
- package/dist/assets/ko-DRnnHetA.js +0 -16
- package/dist/assets/main-DVX34beR.js +0 -886
- package/dist/assets/markdownCore-Cxbkn5NR.js +0 -7
- package/dist/assets/mobile-BrlBrNfZ.js +0 -2
- package/dist/assets/nl-DzUV-kwp.js +0 -16
- package/dist/assets/pl-Bb-cb7k7.js +0 -16
- package/dist/assets/pt-BR-CyIWrTcE.js +0 -16
- package/dist/assets/renderMobileApp-B0z6-x58.js +0 -25
- package/dist/assets/runtimeEndpointReset-uu1DBwLL.js +0 -52
- package/dist/assets/scheduledTasksApi-BuzWT445.js +0 -1
- package/dist/assets/shikiHighlight-BWGrY5YU.js +0 -1
- package/dist/assets/tr-DXEDSoYO.js +0 -7
- package/dist/assets/uk-C8hN--q_.js +0 -16
- package/dist/assets/useRootScrollLock-2rd5Y6gR.js +0 -2
- package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +0 -1
- package/dist/assets/vendor-codemirror-language-BgPj_McA.js +0 -3
- package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +0 -2
- package/dist/assets/vendor-codemirror-view-CiLROUVV.js +0 -4
- package/dist/assets/vendor-opencode-client-DSZl7jSi.js +0 -12
- package/dist/assets/vendor-remend-BWYYytN3.js +0 -22
- package/dist/assets/zh-CN-CtzXdjMZ.js +0 -16
- package/dist/assets/zh-TW-Ds0CADSz.js +0 -16
- package/server/lib/opencode/credential-db.js +0 -144
- package/server/lib/opencode/credential-db.test.js +0 -104
|
@@ -1505,6 +1505,98 @@ describe('createWorktree', () => {
|
|
|
1505
1505
|
}
|
|
1506
1506
|
}, 30_000);
|
|
1507
1507
|
|
|
1508
|
+
describe('from a local base branch', () => {
|
|
1509
|
+
const withDataHome = async (run) => {
|
|
1510
|
+
const previousXdgDataHome = process.env.XDG_DATA_HOME;
|
|
1511
|
+
process.env.XDG_DATA_HOME = createTempDir();
|
|
1512
|
+
try {
|
|
1513
|
+
await run();
|
|
1514
|
+
} finally {
|
|
1515
|
+
if (previousXdgDataHome === undefined) {
|
|
1516
|
+
delete process.env.XDG_DATA_HOME;
|
|
1517
|
+
} else {
|
|
1518
|
+
process.env.XDG_DATA_HOME = previousXdgDataHome;
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
};
|
|
1522
|
+
|
|
1523
|
+
// The repository sits on `next` with a local `main` tracking origin/main;
|
|
1524
|
+
// a teammate then pushes one commit to main that was never pulled.
|
|
1525
|
+
const createRepositoryBehindItsRemote = () => {
|
|
1526
|
+
const { remote, repository } = createRepositoryWithRemote({ defaultBranch: 'main' });
|
|
1527
|
+
runGit(repository, ['branch', '--track', 'main', 'origin/main']);
|
|
1528
|
+
const teammate = createTempDir();
|
|
1529
|
+
runGit(teammate, ['clone', remote, '.']);
|
|
1530
|
+
runGit(teammate, ['config', 'user.email', 'teammate@example.com']);
|
|
1531
|
+
runGit(teammate, ['config', 'user.name', 'Teammate']);
|
|
1532
|
+
fs.writeFileSync(path.join(teammate, 'pushed.txt'), 'pushed\n');
|
|
1533
|
+
runGit(teammate, ['add', 'pushed.txt']);
|
|
1534
|
+
runGit(teammate, ['commit', '-m', 'pushed later']);
|
|
1535
|
+
runGit(teammate, ['push', 'origin', 'HEAD:main']);
|
|
1536
|
+
return { repository, pushedHead: runGit(teammate, ['rev-parse', 'HEAD']).trim() };
|
|
1537
|
+
};
|
|
1538
|
+
|
|
1539
|
+
it('starts from the freshly fetched upstream when nothing is unpublished', async () => {
|
|
1540
|
+
if (!canRunGit()) return;
|
|
1541
|
+
await withDataHome(async () => {
|
|
1542
|
+
const { repository, pushedHead } = createRepositoryBehindItsRemote();
|
|
1543
|
+
const localMain = runGit(repository, ['rev-parse', 'main']).trim();
|
|
1544
|
+
|
|
1545
|
+
const created = await createWorktree(repository, {
|
|
1546
|
+
mode: 'new',
|
|
1547
|
+
branchName: 'openchamber/fresh-base',
|
|
1548
|
+
worktreeName: 'fresh-base',
|
|
1549
|
+
startRef: 'main',
|
|
1550
|
+
});
|
|
1551
|
+
|
|
1552
|
+
expect(created.sourceFetchFailed).toBeUndefined();
|
|
1553
|
+
expect(runGit(created.path, ['rev-parse', 'HEAD']).trim()).toBe(pushedHead);
|
|
1554
|
+
expect(runGit(repository, ['rev-parse', 'main']).trim()).toBe(localMain);
|
|
1555
|
+
});
|
|
1556
|
+
}, 30_000);
|
|
1557
|
+
|
|
1558
|
+
it('keeps the local branch when it has unpublished commits', async () => {
|
|
1559
|
+
if (!canRunGit()) return;
|
|
1560
|
+
await withDataHome(async () => {
|
|
1561
|
+
const { repository } = createRepositoryBehindItsRemote();
|
|
1562
|
+
runGit(repository, ['checkout', 'main']);
|
|
1563
|
+
fs.writeFileSync(path.join(repository, 'local.txt'), 'local\n');
|
|
1564
|
+
runGit(repository, ['add', 'local.txt']);
|
|
1565
|
+
runGit(repository, ['commit', '-m', 'unpublished']);
|
|
1566
|
+
runGit(repository, ['checkout', 'next']);
|
|
1567
|
+
const localMain = runGit(repository, ['rev-parse', 'main']).trim();
|
|
1568
|
+
|
|
1569
|
+
const created = await createWorktree(repository, {
|
|
1570
|
+
mode: 'new',
|
|
1571
|
+
branchName: 'openchamber/local-base',
|
|
1572
|
+
worktreeName: 'local-base',
|
|
1573
|
+
startRef: 'main',
|
|
1574
|
+
});
|
|
1575
|
+
|
|
1576
|
+
expect(runGit(created.path, ['rev-parse', 'HEAD']).trim()).toBe(localMain);
|
|
1577
|
+
});
|
|
1578
|
+
}, 30_000);
|
|
1579
|
+
|
|
1580
|
+
it('keeps the local branch and reports it when the fetch fails', async () => {
|
|
1581
|
+
if (!canRunGit()) return;
|
|
1582
|
+
await withDataHome(async () => {
|
|
1583
|
+
const { repository } = createRepositoryBehindItsRemote();
|
|
1584
|
+
runGit(repository, ['remote', 'set-url', 'origin', '/nonexistent/openchamber-unreachable.git']);
|
|
1585
|
+
const localMain = runGit(repository, ['rev-parse', 'main']).trim();
|
|
1586
|
+
|
|
1587
|
+
const created = await createWorktree(repository, {
|
|
1588
|
+
mode: 'new',
|
|
1589
|
+
branchName: 'openchamber/offline-base',
|
|
1590
|
+
worktreeName: 'offline-base',
|
|
1591
|
+
startRef: 'main',
|
|
1592
|
+
});
|
|
1593
|
+
|
|
1594
|
+
expect(created.sourceFetchFailed).toBe(true);
|
|
1595
|
+
expect(runGit(created.path, ['rev-parse', 'HEAD']).trim()).toBe(localMain);
|
|
1596
|
+
});
|
|
1597
|
+
}, 30_000);
|
|
1598
|
+
});
|
|
1599
|
+
|
|
1508
1600
|
it('rejects creation from a remote start ref that was never fetched and cannot be fetched', async () => {
|
|
1509
1601
|
if (!canRunGit()) return;
|
|
1510
1602
|
|
|
@@ -2882,3 +2974,52 @@ describe('getStatus untracked directories', () => {
|
|
|
2882
2974
|
}
|
|
2883
2975
|
});
|
|
2884
2976
|
});
|
|
2977
|
+
|
|
2978
|
+
describe('git environment inside an AppImage', () => {
|
|
2979
|
+
it('runs the worktree post-checkout hook without the AppImage launcher library path', async () => {
|
|
2980
|
+
if (!canRunGit() || process.platform === 'win32') return;
|
|
2981
|
+
const previous = {
|
|
2982
|
+
APPDIR: process.env.APPDIR,
|
|
2983
|
+
LD_LIBRARY_PATH: process.env.LD_LIBRARY_PATH,
|
|
2984
|
+
XDG_DATA_HOME: process.env.XDG_DATA_HOME,
|
|
2985
|
+
};
|
|
2986
|
+
const dataHome = createTempDir();
|
|
2987
|
+
process.env.XDG_DATA_HOME = dataHome;
|
|
2988
|
+
process.env.APPDIR = '/tmp/.mount_OpenChAbC123';
|
|
2989
|
+
process.env.LD_LIBRARY_PATH = '/tmp/.mount_OpenChAbC123/usr/lib:/opt/x:';
|
|
2990
|
+
|
|
2991
|
+
try {
|
|
2992
|
+
const repo = createTempDir();
|
|
2993
|
+
runGit(repo, ['init', '-b', 'main']);
|
|
2994
|
+
runGit(repo, ['config', 'user.email', 'test@example.com']);
|
|
2995
|
+
runGit(repo, ['config', 'user.name', 'Test User']);
|
|
2996
|
+
fs.writeFileSync(path.join(repo, 'README.md'), '# Test\n');
|
|
2997
|
+
runGit(repo, ['add', 'README.md']);
|
|
2998
|
+
runGit(repo, ['commit', '-m', 'Initial commit']);
|
|
2999
|
+
const hookLog = path.join(dataHome, 'post-checkout-env.log');
|
|
3000
|
+
const hookPath = path.join(repo, '.git', 'hooks', 'post-checkout');
|
|
3001
|
+
fs.writeFileSync(hookPath, `#!/bin/sh\nprintf '%s' "\${LD_LIBRARY_PATH-<unset>}" > ${JSON.stringify(hookLog)}\n`);
|
|
3002
|
+
fs.chmodSync(hookPath, 0o755);
|
|
3003
|
+
|
|
3004
|
+
await createWorktree(repo, {
|
|
3005
|
+
mode: 'new',
|
|
3006
|
+
worktreeName: 'hook-env-test',
|
|
3007
|
+
branchName: 'openchamber/hook-env-test',
|
|
3008
|
+
returnAfterDirectoryCreated: true,
|
|
3009
|
+
});
|
|
3010
|
+
|
|
3011
|
+
await expect.poll(() => {
|
|
3012
|
+
try {
|
|
3013
|
+
return fs.readFileSync(hookLog, 'utf8');
|
|
3014
|
+
} catch {
|
|
3015
|
+
return '';
|
|
3016
|
+
}
|
|
3017
|
+
}, { timeout: 5_000 }).toBe('/opt/x');
|
|
3018
|
+
} finally {
|
|
3019
|
+
for (const [key, value] of Object.entries(previous)) {
|
|
3020
|
+
if (value === undefined) delete process.env[key];
|
|
3021
|
+
else process.env[key] = value;
|
|
3022
|
+
}
|
|
3023
|
+
}
|
|
3024
|
+
});
|
|
3025
|
+
});
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
- `packages/web/server/lib/github/octokit.js`: Octokit factory for the current auth.
|
|
15
15
|
- `packages/web/server/lib/github/repo/index.js`: remote URL parsing and directory-to-repo resolution.
|
|
16
16
|
- `packages/web/server/lib/github/pr-status.js`: PR lookup across remotes, forks, and upstreams.
|
|
17
|
+
- `packages/web/server/lib/github/pr-summaries.js`: batched live state for PRs already known by number.
|
|
18
|
+
- `packages/web/server/lib/github/checks-summary.js`: the one checks summarizer shared by every PR route.
|
|
17
19
|
- `packages/web/server/index.js`: API route layer that calls this module.
|
|
18
20
|
- `packages/web/src/api/github.ts`: web client wrapper for GitHub endpoints.
|
|
19
21
|
|
|
@@ -90,6 +92,15 @@ that page, so callers cannot mistake a partial page for a complete one.
|
|
|
90
92
|
- The route skips the checks summary and the merge-permission lookup for a closed/merged PR: neither is actionable, and both cost extra GitHub calls.
|
|
91
93
|
- `403` and `404` during repo lookups are treated as expected gaps, not hard errors.
|
|
92
94
|
|
|
95
|
+
## Batched live summaries
|
|
96
|
+
|
|
97
|
+
- `POST /api/github/pr/summaries` takes `refs` (PRs) and `issueRefs` (issues), up to `100` `{ owner, repo, number }` in total, and answers `{ connected, fetchedAt, summaries, issueSummaries }`. An issue reads `open`, `completed`, or `not_planned` (GitHub's `NOT_PLANNED` and `DUPLICATE` close reasons); a PR number asked as an issue is simply absent.
|
|
98
|
+
- It sends one GraphQL document per `25` PRs, one after another. Each alias reads state, draft, title, head sha, `mergeable`, `mergeStateStatus` (lowercased, same values as REST `mergeable_state`) and up to `100` check contexts of the head commit. GitHub prices such a document at one point of the GraphQL budget (measured), which is separate from the REST limit.
|
|
99
|
+
- Checks go through the same summarizers as the REST routes (`checks-summary.js`), so sidebar, chat and Git view count the same runs. Do not switch to the rollup's `state` or `checkRunCountsByState`: both still count a failed run that a later re-run superseded, which paints a green PR as failing. A closed/merged PR gets `checks: null`.
|
|
100
|
+
- A PR GitHub cannot resolve (deleted, lost access) is left out of `summaries`: absence means unknown, never closed. Partial GraphQL answers keep the resolved aliases.
|
|
101
|
+
- A GraphQL `RATE_LIMITED` error (HTTP 200) records the shared rate-limit cooldown like a REST 403/429 and returns `503`; while the cooldown runs the route answers `503` without calling GitHub.
|
|
102
|
+
- This route never discovers PRs; branch-to-PR resolution stays with `GET /api/github/pr/status`.
|
|
103
|
+
|
|
93
104
|
## Shared client state model
|
|
94
105
|
|
|
95
106
|
- Client key is effectively `directory::branch`.
|
|
@@ -159,10 +170,17 @@ that page, so callers cannot mistake a partial page for a complete one.
|
|
|
159
170
|
|
|
160
171
|
## Sidebar behavior
|
|
161
172
|
|
|
173
|
+
- Sidebar rows are not watched. The tracked set is the worktree branches whose badge is on screen in the current mode: Timeline rows in Timeline; expanded project groups and Recent rows in Projects; In work rows in both. Collapse state from the Projects view never limits Timeline. For that set the sidebar runs discovery through `refreshTargets` (first resolution, then every `5m` while a branch has no PR or only a closed/merged one).
|
|
174
|
+
- Open PRs on those rows stay live through batched summaries (`useOpenPrSummarySync`): every `2m` while the window is visible, again when the window regains focus or visibility (at most once per `15s`), when new rows appear, and when cached statuses finish restoring after a reload. A PR merged or closed on GitHub turns so on the next batch, and failing checks show up the same way.
|
|
175
|
+
- The batch skips watched entries (the Git view refreshes those in full) and PRs asked about within the cadence. A failed batch keeps the last known status and waits for the next cadence.
|
|
176
|
+
- A session row shows its worktree branch's PR and the PRs linked to the session (`openchamber.linked_issues` entries of kind `pull`, see `packages/ui/src/lib/linkedIssues.ts`), each once, most urgent first (`blocked`, `open`, `draft`, `merged`, `closed`); the badge names the first and counts the rest, the tooltip lists all. Links come from a PR attached in the composer, a worktree created from a PR, the issue picker, the chat's Linked section, and a PR created in the Git view (linked to the open session when it works in that directory).
|
|
177
|
+
- A session with no PR at all shows its linked issues instead, never both and never counted together (maintainer decision, 2026-10-01): GitHub issues with live state from the same batches (`linkedIssueSummaries`, runtime-only, kept on the cadence even when closed because issues reopen), Linear and extension trackers by identifier only, muted. Issue colours reuse the PR tokens: open `--pr-open`, completed `--pr-merged`, not planned `--pr-closed`; an issue is never orange. A worktree group header follows the same rule at group level: its branch PR, or else the issues linked to the sessions in the group (a worktree started from an issue records the link on its session, not on the worktree).
|
|
178
|
+
- Linked PRs join the same live-summary batches; their state lives in `linkedSummaries` (runtime-only, never persisted). A merged link is not asked about again; a closed one stays on the cadence because it can reopen.
|
|
162
179
|
- Sidebar shows only compact PR state.
|
|
163
180
|
- Aggregation is by `directory::branch`, so multiple sessions on one branch share one signal.
|
|
164
181
|
- If multiple entries exist, sidebar keeps the strongest visible PR state.
|
|
165
182
|
- Visual state is based on PR health, not merge permissions.
|
|
183
|
+
- Orange (`blocked`) means something to fix: failed checks or conflicts (`mergeable: false`, `dirty`). A `blocked` merge state alone, which usually means a required review is missing, keeps the open colour and never reads "Ready to merge". Sidebar, Git view and Git header apply the same rule.
|
|
166
184
|
|
|
167
185
|
## Git view behavior
|
|
168
186
|
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Aggregate check runs into the summary shape shared by pr/status,
|
|
2
|
+
// pulls/context and pr/summaries, so every surface counts the same checks. Keeps `pending` as queued+in_progress+unconcluded for
|
|
3
|
+
// existing consumers while exposing the split and the earliest start time so
|
|
4
|
+
// the UI can show live "running for N minutes" state.
|
|
5
|
+
// A re-run leaves the previous completed check run in the listForRef payload
|
|
6
|
+
// alongside the new in-progress one. GitHub's UI shows only the latest run
|
|
7
|
+
// per (app, name); mirror that so counts match what users see on github.com.
|
|
8
|
+
export function dedupeCheckRuns(checkRuns) {
|
|
9
|
+
const byName = new Map();
|
|
10
|
+
for (const run of checkRuns) {
|
|
11
|
+
const key = `${run?.app?.id ?? run?.app?.slug ?? ''}::${run?.name ?? ''}`;
|
|
12
|
+
const previous = byName.get(key);
|
|
13
|
+
if (!previous) {
|
|
14
|
+
byName.set(key, run);
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const previousStartedAt = Date.parse(previous?.started_at || '') || 0;
|
|
18
|
+
const startedAt = Date.parse(run?.started_at || '') || 0;
|
|
19
|
+
if (startedAt > previousStartedAt
|
|
20
|
+
|| (startedAt === previousStartedAt && (run?.id ?? 0) > (previous?.id ?? 0))) {
|
|
21
|
+
byName.set(key, run);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return Array.from(byName.values());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function summarizeCheckRuns(checkRuns) {
|
|
28
|
+
const counts = { success: 0, failure: 0, pending: 0, inProgress: 0, queued: 0 };
|
|
29
|
+
let startedAt = null;
|
|
30
|
+
for (const run of checkRuns) {
|
|
31
|
+
const status = run?.status;
|
|
32
|
+
const conclusion = run?.conclusion;
|
|
33
|
+
if (status === 'in_progress') {
|
|
34
|
+
counts.pending += 1;
|
|
35
|
+
counts.inProgress += 1;
|
|
36
|
+
const runStartedAt = typeof run?.started_at === 'string' ? run.started_at : null;
|
|
37
|
+
if (runStartedAt && (!startedAt || runStartedAt < startedAt)) {
|
|
38
|
+
startedAt = runStartedAt;
|
|
39
|
+
}
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (status === 'queued') {
|
|
43
|
+
counts.pending += 1;
|
|
44
|
+
counts.queued += 1;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (!conclusion) {
|
|
48
|
+
counts.pending += 1;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (conclusion === 'success' || conclusion === 'neutral' || conclusion === 'skipped') {
|
|
52
|
+
counts.success += 1;
|
|
53
|
+
} else {
|
|
54
|
+
counts.failure += 1;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const total = counts.success + counts.failure + counts.pending;
|
|
58
|
+
const state = counts.failure > 0
|
|
59
|
+
? 'failure'
|
|
60
|
+
: (counts.pending > 0 ? 'pending' : (total > 0 ? 'success' : 'unknown'));
|
|
61
|
+
return { state, total, ...counts, ...(startedAt ? { startedAt } : {}) };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function summarizeCombinedStatuses(statuses) {
|
|
65
|
+
const counts = { success: 0, failure: 0, pending: 0 };
|
|
66
|
+
statuses.forEach((s) => {
|
|
67
|
+
if (s.state === 'success') counts.success += 1;
|
|
68
|
+
else if (s.state === 'failure' || s.state === 'error') counts.failure += 1;
|
|
69
|
+
else if (s.state === 'pending') counts.pending += 1;
|
|
70
|
+
});
|
|
71
|
+
const total = counts.success + counts.failure + counts.pending;
|
|
72
|
+
const state = counts.failure > 0
|
|
73
|
+
? 'failure'
|
|
74
|
+
: (counts.pending > 0 ? 'pending' : (total > 0 ? 'success' : 'unknown'));
|
|
75
|
+
return { state, total, ...counts, inProgress: counts.pending, queued: 0 };
|
|
76
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
// Live status for PRs and issues the client already knows by number.
|
|
2
|
+
//
|
|
3
|
+
// The sidebar shows many worktrees at once. Asking the full per-branch
|
|
4
|
+
// resolver for each of them costs several REST calls per PR; here one GraphQL
|
|
5
|
+
// document carries up to SUMMARY_ALIASES_PER_QUERY PRs or issues (a PR's
|
|
6
|
+
// state, draft, mergeability and check contexts; an issue's state and close
|
|
7
|
+
// reason), and GitHub prices such a document at a single point of the GraphQL
|
|
8
|
+
// budget.
|
|
9
|
+
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
|
|
12
|
+
import { dedupeCheckRuns, summarizeCheckRuns, summarizeCombinedStatuses } from './checks-summary.js';
|
|
13
|
+
|
|
14
|
+
const SUMMARY_ALIASES_PER_QUERY = 25;
|
|
15
|
+
export const MAX_SUMMARY_REFS = 100;
|
|
16
|
+
|
|
17
|
+
const GITHUB_NAME_PATTERN = /^[A-Za-z0-9._-]{1,100}$/;
|
|
18
|
+
|
|
19
|
+
// Individual check contexts rather than the rollup's counts or state: both
|
|
20
|
+
// still count a failed run that a later re-run superseded, which would paint
|
|
21
|
+
// a green PR as failing. A hundred contexts per PR does not change the
|
|
22
|
+
// document's price (measured: 25 PRs with contexts cost one point).
|
|
23
|
+
const SUMMARY_FIELDS = `
|
|
24
|
+
number
|
|
25
|
+
title
|
|
26
|
+
state
|
|
27
|
+
isDraft
|
|
28
|
+
mergeable
|
|
29
|
+
mergeStateStatus
|
|
30
|
+
headRefOid
|
|
31
|
+
commits(last: 1) {
|
|
32
|
+
nodes {
|
|
33
|
+
commit {
|
|
34
|
+
statusCheckRollup {
|
|
35
|
+
contexts(first: 100) {
|
|
36
|
+
nodes {
|
|
37
|
+
__typename
|
|
38
|
+
... on CheckRun {
|
|
39
|
+
databaseId
|
|
40
|
+
name
|
|
41
|
+
status
|
|
42
|
+
conclusion
|
|
43
|
+
startedAt
|
|
44
|
+
checkSuite { app { databaseId } }
|
|
45
|
+
}
|
|
46
|
+
... on StatusContext {
|
|
47
|
+
context
|
|
48
|
+
state
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
const ISSUE_FIELDS = `
|
|
59
|
+
number
|
|
60
|
+
title
|
|
61
|
+
state
|
|
62
|
+
stateReason
|
|
63
|
+
`;
|
|
64
|
+
|
|
65
|
+
const githubName = z.string().trim().regex(GITHUB_NAME_PATTERN);
|
|
66
|
+
const summaryRefsSchema = z.array(z.object({
|
|
67
|
+
owner: githubName,
|
|
68
|
+
repo: githubName,
|
|
69
|
+
number: z.number().int().positive(),
|
|
70
|
+
})).max(MAX_SUMMARY_REFS);
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Parse a client-supplied ref list into unique `{ owner, repo, number }`
|
|
74
|
+
* records. Returns null when the payload is not a valid list.
|
|
75
|
+
*/
|
|
76
|
+
export function parseSummaryRefs(value) {
|
|
77
|
+
const parsed = summaryRefsSchema.safeParse(value);
|
|
78
|
+
if (!parsed.success) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const refs = new Map();
|
|
82
|
+
for (const ref of parsed.data) {
|
|
83
|
+
refs.set(`${ref.owner.toLowerCase()}/${ref.repo.toLowerCase()}#${ref.number}`, ref);
|
|
84
|
+
}
|
|
85
|
+
return [...refs.values()];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const checkContextSchema = z.discriminatedUnion('__typename', [
|
|
89
|
+
z.object({
|
|
90
|
+
__typename: z.literal('CheckRun'),
|
|
91
|
+
databaseId: z.number().int().nullable(),
|
|
92
|
+
name: z.string(),
|
|
93
|
+
status: z.string(),
|
|
94
|
+
conclusion: z.string().nullable(),
|
|
95
|
+
startedAt: z.string().nullable(),
|
|
96
|
+
checkSuite: z.object({ app: z.object({ databaseId: z.number().int().nullable() }).nullable() }).nullable(),
|
|
97
|
+
}),
|
|
98
|
+
z.object({
|
|
99
|
+
__typename: z.literal('StatusContext'),
|
|
100
|
+
context: z.string(),
|
|
101
|
+
state: z.string(),
|
|
102
|
+
}),
|
|
103
|
+
]);
|
|
104
|
+
|
|
105
|
+
const prNodeSchema = z.object({
|
|
106
|
+
number: z.number().int(),
|
|
107
|
+
title: z.string(),
|
|
108
|
+
state: z.enum(['OPEN', 'CLOSED', 'MERGED']),
|
|
109
|
+
isDraft: z.boolean(),
|
|
110
|
+
mergeable: z.string().nullable(),
|
|
111
|
+
mergeStateStatus: z.string().nullable(),
|
|
112
|
+
headRefOid: z.string(),
|
|
113
|
+
commits: z.object({
|
|
114
|
+
nodes: z.array(z.object({
|
|
115
|
+
commit: z.object({
|
|
116
|
+
statusCheckRollup: z.object({
|
|
117
|
+
contexts: z.object({ nodes: z.array(checkContextSchema) }),
|
|
118
|
+
}).nullable(),
|
|
119
|
+
}),
|
|
120
|
+
})),
|
|
121
|
+
}),
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Summarize GraphQL check contexts with the REST summarizers, so the sidebar
|
|
126
|
+
* counts exactly what the Git view counts: check runs, deduplicated to the
|
|
127
|
+
* latest run per app and name, win over classic commit statuses.
|
|
128
|
+
*/
|
|
129
|
+
export function summarizeCheckContexts(contexts) {
|
|
130
|
+
const checkRuns = [];
|
|
131
|
+
const statuses = [];
|
|
132
|
+
for (const context of contexts) {
|
|
133
|
+
if (context.__typename === 'CheckRun') {
|
|
134
|
+
checkRuns.push({
|
|
135
|
+
id: context.databaseId ?? undefined,
|
|
136
|
+
name: context.name,
|
|
137
|
+
app: { id: context.checkSuite?.app?.databaseId ?? undefined },
|
|
138
|
+
status: context.status.toLowerCase(),
|
|
139
|
+
conclusion: context.conclusion ? context.conclusion.toLowerCase() : null,
|
|
140
|
+
started_at: context.startedAt ?? undefined,
|
|
141
|
+
});
|
|
142
|
+
} else {
|
|
143
|
+
statuses.push({ state: context.state.toLowerCase() });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return checkRuns.length > 0
|
|
147
|
+
? summarizeCheckRuns(dedupeCheckRuns(checkRuns))
|
|
148
|
+
: summarizeCombinedStatuses(statuses);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const issueNodeSchema = z.object({
|
|
152
|
+
number: z.number().int(),
|
|
153
|
+
title: z.string(),
|
|
154
|
+
state: z.enum(['OPEN', 'CLOSED']),
|
|
155
|
+
stateReason: z.string().nullable(),
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// GitHub's own split of a closed issue: done, or dropped (not planned or a
|
|
159
|
+
// duplicate). A reopened issue reports OPEN.
|
|
160
|
+
const toIssueState = (node) => {
|
|
161
|
+
if (node.state === 'OPEN') return 'open';
|
|
162
|
+
return node.stateReason === 'NOT_PLANNED' || node.stateReason === 'DUPLICATE' ? 'not_planned' : 'completed';
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
function toIssueSummary(ref, value) {
|
|
166
|
+
const parsed = issueNodeSchema.safeParse(value);
|
|
167
|
+
if (!parsed.success || parsed.data.number !== ref.number) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
owner: ref.owner,
|
|
172
|
+
repo: ref.repo,
|
|
173
|
+
number: ref.number,
|
|
174
|
+
title: parsed.data.title,
|
|
175
|
+
state: toIssueState(parsed.data),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const PR_STATES = { OPEN: 'open', CLOSED: 'closed', MERGED: 'merged' };
|
|
180
|
+
|
|
181
|
+
const toMergeable = (mergeable) => {
|
|
182
|
+
if (mergeable === 'MERGEABLE') return true;
|
|
183
|
+
if (mergeable === 'CONFLICTING') return false;
|
|
184
|
+
return null;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
function toSummary(ref, value) {
|
|
188
|
+
const parsed = prNodeSchema.safeParse(value);
|
|
189
|
+
if (!parsed.success || parsed.data.number !== ref.number) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
const node = parsed.data;
|
|
193
|
+
const state = PR_STATES[node.state];
|
|
194
|
+
return {
|
|
195
|
+
owner: ref.owner,
|
|
196
|
+
repo: ref.repo,
|
|
197
|
+
number: ref.number,
|
|
198
|
+
state,
|
|
199
|
+
draft: node.isDraft,
|
|
200
|
+
title: node.title,
|
|
201
|
+
headSha: node.headRefOid,
|
|
202
|
+
mergeable: toMergeable(node.mergeable),
|
|
203
|
+
mergeableState: node.mergeStateStatus ? node.mergeStateStatus.toLowerCase() : null,
|
|
204
|
+
// A closed/merged PR's checks are not actionable; the REST status route
|
|
205
|
+
// drops them too.
|
|
206
|
+
checks: state === 'open'
|
|
207
|
+
? summarizeCheckContexts(node.commits.nodes[0]?.commit.statusCheckRollup?.contexts.nodes ?? [])
|
|
208
|
+
: null,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function buildSummaryQuery(entries) {
|
|
213
|
+
const variables = {};
|
|
214
|
+
const declarations = [];
|
|
215
|
+
const selections = [];
|
|
216
|
+
entries.forEach(({ kind, ref }, index) => {
|
|
217
|
+
variables[`o${index}`] = ref.owner;
|
|
218
|
+
variables[`n${index}`] = ref.repo;
|
|
219
|
+
variables[`p${index}`] = ref.number;
|
|
220
|
+
declarations.push(`$o${index}: String!, $n${index}: String!, $p${index}: Int!`);
|
|
221
|
+
const field = kind === 'issue'
|
|
222
|
+
? `issue(number: $p${index}) { ...IssueSummary }`
|
|
223
|
+
: `pullRequest(number: $p${index}) { ...PrSummary }`;
|
|
224
|
+
selections.push(`a${index}: repository(owner: $o${index}, name: $n${index}) { ${field} }`);
|
|
225
|
+
});
|
|
226
|
+
const fragments = [
|
|
227
|
+
entries.some((entry) => entry.kind === 'pull') ? `fragment PrSummary on PullRequest {${SUMMARY_FIELDS}}` : '',
|
|
228
|
+
entries.some((entry) => entry.kind === 'issue') ? `fragment IssueSummary on Issue {${ISSUE_FIELDS}}` : '',
|
|
229
|
+
].filter(Boolean);
|
|
230
|
+
const query = `query(${declarations.join(', ')}) {\n${selections.join('\n')}\n}\n${fragments.join('\n')}`;
|
|
231
|
+
return { query, variables };
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// The GraphQL primary limit arrives as HTTP 200 with a RATE_LIMITED error,
|
|
235
|
+
// which the REST-oriented check in rate-limit.js cannot see.
|
|
236
|
+
export const isGraphqlRateLimitError = (error) => Array.isArray(error?.errors)
|
|
237
|
+
&& error.errors.some((entry) => entry?.type === 'RATE_LIMITED');
|
|
238
|
+
|
|
239
|
+
// GitHub answers a PR it cannot resolve (deleted, no access) with a per-alias
|
|
240
|
+
// error next to the data for every other alias. Octokit throws on any error,
|
|
241
|
+
// so keep the partial data and only rethrow when there is none.
|
|
242
|
+
async function runSummaryQuery(octokit, entries) {
|
|
243
|
+
const { query, variables } = buildSummaryQuery(entries);
|
|
244
|
+
try {
|
|
245
|
+
return await octokit.graphql(query, variables);
|
|
246
|
+
} catch (error) {
|
|
247
|
+
if (!isGraphqlRateLimitError(error) && error?.data) {
|
|
248
|
+
return error.data;
|
|
249
|
+
}
|
|
250
|
+
throw error;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Fetch live summaries for known PRs and issues. One GitHub could not resolve
|
|
256
|
+
* is left out of the result: absence means "unknown", never "closed".
|
|
257
|
+
*/
|
|
258
|
+
export async function fetchPrSummaries({ octokit, refs, issueRefs = [] }) {
|
|
259
|
+
const entries = [
|
|
260
|
+
...refs.map((ref) => ({ kind: 'pull', ref })),
|
|
261
|
+
...issueRefs.map((ref) => ({ kind: 'issue', ref })),
|
|
262
|
+
];
|
|
263
|
+
const summaries = [];
|
|
264
|
+
const issueSummaries = [];
|
|
265
|
+
// Chunks run one after another: GitHub's secondary limits punish bursts of
|
|
266
|
+
// concurrent GraphQL documents more than a short sequence.
|
|
267
|
+
for (let start = 0; start < entries.length; start += SUMMARY_ALIASES_PER_QUERY) {
|
|
268
|
+
const chunk = entries.slice(start, start + SUMMARY_ALIASES_PER_QUERY);
|
|
269
|
+
const data = await runSummaryQuery(octokit, chunk);
|
|
270
|
+
chunk.forEach(({ kind, ref }, index) => {
|
|
271
|
+
const repository = data?.[`a${index}`];
|
|
272
|
+
if (kind === 'issue') {
|
|
273
|
+
const summary = toIssueSummary(ref, repository?.issue);
|
|
274
|
+
if (summary) issueSummaries.push(summary);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const summary = toSummary(ref, repository?.pullRequest);
|
|
278
|
+
if (summary) summaries.push(summary);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
return { summaries, issueSummaries };
|
|
282
|
+
}
|