@openchamber/web 2.3.2 → 2.3.3
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-MZbHWRua.js → AboutDialog-Ctk2zvrv.js} +1 -1
- package/dist/assets/{ArchiveView-CkeSWPcI.js → ArchiveView-sbNreasJ.js} +1 -1
- package/dist/assets/{CommandPalette-CtKzNzwW.js → CommandPalette-BICwnwAZ.js} +2 -2
- package/dist/assets/{DiffView-DaXjHTAq.js → DiffView-B5yeuxv8.js} +1 -1
- package/dist/assets/{FilesView-DMNYEydF.js → FilesView-ni2zfAwL.js} +7 -7
- package/dist/assets/{GitView-HXttTpUw.js → GitView-C0QgeC9O.js} +3 -3
- package/dist/assets/{GuestSurfacePane-KzguENQG.js → GuestSurfacePane-D1gLktSj.js} +1 -1
- package/dist/assets/{HelpDialog-9YZGhBgT.js → HelpDialog-CxC6qTaS.js} +1 -1
- package/dist/assets/{InProgressOperationBanner-DzGIwGH2.js → InProgressOperationBanner-JFV70YFh.js} +1 -1
- package/dist/assets/{JsonTreeView-D9rP8jM8.js → JsonTreeView-RsbV4Usa.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-CZK5DoOX.js +1 -0
- package/dist/assets/{MemoryDebugPanel-Ct0h3RWh.js → MemoryDebugPanel-caUWOKiz.js} +1 -1
- package/dist/assets/{OnboardingScreen-B5Zzb1Mp.js → OnboardingScreen-BDT-J2JP.js} +1 -1
- package/dist/assets/{OpenCodeStatusDialog-CXBWWRh8.js → OpenCodeStatusDialog-Cxa2yqOB.js} +1 -1
- package/dist/assets/{PatchDiff-DhDAQ5em.js → PatchDiff-C1pnbAsJ.js} +1 -1
- package/dist/assets/{PierreDiffViewer-DPa08AmN.js → PierreDiffViewer-D0zX2Msu.js} +1 -1
- package/dist/assets/PlanView-BxRCMuGe.js +5 -0
- package/dist/assets/{ProjectActionsDialog-DATu0aBc.js → ProjectActionsDialog-D660By4K.js} +1 -1
- package/dist/assets/{RunOverview-D6xy_vME.js → RunOverview-C1uTMnQS.js} +2 -2
- package/dist/assets/{ScheduledTasksDialog-BWXVnfrf.js → ScheduledTasksDialog-S-gAgo7Z.js} +5 -5
- package/dist/assets/SettingsView-CVpfbdob.js +30 -0
- package/dist/assets/{SettingsWindow-Cx6TrtY0.js → SettingsWindow-Dd1hHvgh.js} +1 -1
- package/dist/assets/SourceBoardView-DbGWAxtS.js +1 -0
- package/dist/assets/SpaceAccessDialog-muTSsEJ9.js +1 -0
- package/dist/assets/{SpaceApplyDialog-BtuwtlaG.js → SpaceApplyDialog-Dsf6MNGm.js} +1 -1
- package/dist/assets/{SpaceRow-MXqvd-dr.js → SpaceRow-7Z6ebRtm.js} +1 -1
- package/dist/assets/{SpaceSetupOutput-Uo5LS7Jy.js → SpaceSetupOutput-BytPfCOC.js} +1 -1
- package/dist/assets/{SpacesView-DvoOh4sM.js → SpacesView-CYCrlp0D.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-CyMwDeoP.js → SubmoduleDiffSummary-VrNUbIqF.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BaUZIVzc.js → ToolOutputDialog-DHORjBND.js} +7 -7
- package/dist/assets/{ToolPartDiffPreview-DmMwdcF4.js → ToolPartDiffPreview-BLAXe7C5.js} +1 -1
- package/dist/assets/{UsageStatsView-D7WrDBTC.js → UsageStatsView-BxtYEAa0.js} +1 -1
- package/dist/assets/{Virtualizer-CnU8pYMb.js → Virtualizer-Bl4Cf-H-.js} +1 -1
- package/dist/assets/{WalkthroughView-r0Ho9F4Z.js → WalkthroughView-B2BJJ4u5.js} +2 -2
- package/dist/assets/{WorktreesView-C-t7uxq1.js → WorktreesView-Dv0AO9dF.js} +1 -1
- package/dist/assets/{appThemeRegistry-BUY7Ge9i.js → appThemeRegistry-xm_W0svA.js} +1 -1
- package/dist/assets/{ar-HauNhDvN.js → ar-Cj8UF12m.js} +4 -4
- package/dist/assets/{computeVirtualFileMetrics-CUof18z3.js → computeVirtualFileMetrics-Cx05cmWI.js} +2 -2
- package/dist/assets/{de-fEoJ_Yyp.js → de-fSQ1ho01.js} +4 -4
- package/dist/assets/{decorate-BkTSGAlD.js → decorate-jpF7GA6t.js} +2 -2
- package/dist/assets/{es-CKNTBsZW.js → es-DrdzhSlK.js} +5 -5
- package/dist/assets/{fileContentPoller-BJWgy1fX.js → fileContentPoller-C0f20jNG.js} +3 -3
- package/dist/assets/{flexokiTheme-BArobfXV.js → flexokiTheme-DKNCYSqL.js} +1 -1
- package/dist/assets/{fr-C23655Pi.js → fr-Cmz6Da4q.js} +4 -4
- package/dist/assets/{he-CphXS_Fv.js → he-COJRUNy4.js} +4 -4
- package/dist/assets/{index-B27cSA9V.js → index-C8Mw8uvl.js} +1 -1
- package/dist/assets/{initializeSharedPreferences-CucsmDMw.js → initializeSharedPreferences-U9-v9mfq.js} +1 -1
- package/dist/assets/{isDiffPlainText-DSCjvV0m.js → isDiffPlainText-DW43IghW.js} +1 -1
- package/dist/assets/{isFilePlainText-C7g4UPox.js → isFilePlainText-Duq5CiuG.js} +1 -1
- package/dist/assets/{ja-BmsU2iQe.js → ja-Ce0NvDHZ.js} +4 -4
- package/dist/assets/katex-BZNCT55U.css +1 -0
- package/dist/assets/katex.min-EZjpSwGK.js +65 -0
- package/dist/assets/{ko-CxISpkje.js → ko-BGFcCLLq.js} +4 -4
- package/dist/assets/main-BUetg9hg.js +1048 -0
- package/dist/assets/{main-CGPiw9fS.js → main-Be_jmIlF.js} +2 -2
- package/dist/assets/markdownCore-BkTeS4gA.js +10 -0
- package/dist/assets/{miniChat-DVEKVYKe.js → miniChat-g1RgiLLS.js} +2 -2
- package/dist/assets/{mobile-Q_FVBe4I.js → mobile-DBli3U-T.js} +2 -2
- package/dist/assets/{moveWorkspacePath-CyZJ-2aD.js → moveWorkspacePath-CnYc96Xo.js} +1 -1
- package/dist/assets/{nl-jnTBQ_gU.js → nl-Cu1nxo5t.js} +4 -4
- package/dist/assets/{parseDiffFromFile-OHXXXyzL.js → parseDiffFromFile-DEjkjYod.js} +3 -3
- package/dist/assets/{patchFileDiff-BZrb6h2u.js → patchFileDiff-D__42sau.js} +5 -5
- package/dist/assets/{pierreDiffTint-DHf2xvyt.js → pierreDiffTint-3oatL635.js} +4 -4
- package/dist/assets/pl-4LdEMgWI.js +20 -0
- package/dist/assets/{pt-BR-BfpsFrHv.js → pt-BR-2UbEBNgC.js} +5 -5
- package/dist/assets/{relocateRestoredSession-DInneXVI.js → relocateRestoredSession-pkxyd_lV.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-D0tKJFBB.js +2 -0
- package/dist/assets/renderMobileApp-D6bOYHuP.js +25 -0
- package/dist/assets/{restartOpenCode-DwBaMPJK.js → restartOpenCode-FYqjpaWc.js} +1 -1
- package/dist/assets/runtimeEndpointReset-6CNNzem4.js +74 -0
- package/dist/assets/{scheduledTasksApi-ClJplEhR.js → scheduledTasksApi-BbnQ4W-W.js} +1 -1
- package/dist/assets/{selectionMarkdown-BuveYuup.js → selectionMarkdown-D8QAxC44.js} +1 -1
- package/dist/assets/sessionOwnership-BBuf0UCB.js +1 -0
- package/dist/assets/{shikiHighlight-DJAESrna.js → shikiHighlight-CweIj1cL.js} +1 -1
- package/dist/assets/{space-apply-DWFLwXbI.js → space-apply-CEi013sa.js} +1 -1
- package/dist/assets/{space-close-BYDbwdWc.js → space-close-BuStkLrZ.js} +1 -1
- package/dist/assets/{spaceNetwork-DHrhfbKM.js → spaceNetwork-tH2d5Mgs.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-DcAZmUlv.js → textMateThemeFromAppTheme-DLJBL6al.js} +1 -1
- package/dist/assets/tr-Bg0Qt-mG.js +11 -0
- package/dist/assets/{uk-C82aEtvs.js → uk-vcnOugr0.js} +5 -5
- package/dist/assets/useAppFontEffects-Cs6k0JKv.js +773 -0
- package/dist/assets/{useCallableModelProviders-BU_455MN.js → useCallableModelProviders-BsGEzsl2.js} +1 -1
- package/dist/assets/{useInlineCommentController-AuUrVz9U.js → useInlineCommentController-CVYaPzfO.js} +2 -2
- package/dist/assets/{useRootScrollLock-Cpk7NmBa.js → useRootScrollLock-Dov-44ov.js} +2 -2
- package/dist/assets/{vendor-codemirror-language-data-BYGweLoh.js → vendor-codemirror-language-data-DBekkZIx.js} +2 -2
- package/dist/assets/vendor-tanstack-react-virtual-Dozz-7fb.js +1 -0
- package/dist/assets/vendor-tanstack-virtual-core-DKBj55Em.js +1 -0
- package/dist/assets/{vendor-yaml-3778uTud.js → vendor-yaml-CE-D_49-.js} +1 -1
- package/dist/assets/{zh-CN-DEq7j9I5.js → zh-CN-C3UhwFsk.js} +5 -5
- package/dist/assets/{zh-TW-DgCN99T-.js → zh-TW-D0CmmMvp.js} +5 -5
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +5 -5
- package/server/index.js +13 -1
- package/server/lib/agent-memory/actions.js +22 -9
- package/server/lib/agent-memory/actions.test.js +57 -0
- package/server/lib/agent-memory/runtime.js +8 -5
- package/server/lib/agent-tool/DOCUMENTATION.md +17 -1
- package/server/lib/agent-tool/runtime.js +41 -7
- package/server/lib/agent-tool/runtime.test.js +11 -0
- package/server/lib/git/DOCUMENTATION.md +17 -5
- package/server/lib/git/lfs-discovery.js +7 -4
- package/server/lib/git/lfs-discovery.test.js +60 -0
- package/server/lib/git/network-operations.js +9 -3
- package/server/lib/git/network-operations.test.js +31 -2
- package/server/lib/git/service.js +72 -12
- package/server/lib/git/service.test.js +65 -0
- package/server/lib/github/DOCUMENTATION.md +1 -0
- package/server/lib/github/reference-search.js +49 -18
- package/server/lib/github/reference-search.test.js +28 -6
- package/server/lib/github/routes.js +87 -1
- package/server/lib/github/routes.mutations.test.js +38 -0
- package/server/lib/github/routes.test.js +1 -0
- package/server/lib/gitlab/DOCUMENTATION.md +4 -0
- package/server/lib/gitlab/client.js +23 -0
- package/server/lib/gitlab/client.test.js +28 -1
- package/server/lib/gitlab/mappers.js +9 -0
- package/server/lib/gitlab/resources.js +153 -4
- package/server/lib/gitlab/resources.test.js +107 -0
- package/server/lib/gitlab/routes.js +120 -1
- package/server/lib/gitlab/routes.test.js +59 -0
- package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
- package/server/lib/markdown-image-grants/routes.js +14 -2
- package/server/lib/markdown-image-grants/routes.test.js +23 -0
- package/server/lib/notifications/APNS.md +24 -23
- package/server/lib/notifications/DOCUMENTATION.md +2 -2
- package/server/lib/notifications/apns-runtime.js +8 -5
- package/server/lib/notifications/apns-runtime.test.js +26 -0
- package/server/lib/notifications/message.js +5 -3
- package/server/lib/notifications/message.test.js +9 -0
- package/server/lib/notifications/runtime.js +44 -9
- package/server/lib/notifications/trigger-runtime.test.js +84 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
- package/server/lib/openchamber-control/actions.js +18 -2
- package/server/lib/openchamber-control/project-knowledge.js +17 -3
- package/server/lib/openchamber-control/project-knowledge.test.js +14 -0
- package/server/lib/openchamber-control/render-page.js +58 -0
- package/server/lib/openchamber-control/service.js +9 -0
- package/server/lib/openchamber-control/service.test.js +43 -0
- package/server/lib/openchamber-sessions/routes.js +1 -0
- package/server/lib/openchamber-sessions/worktree-move.js +26 -10
- package/server/lib/openchamber-sessions/worktree-move.test.js +36 -0
- package/server/lib/opencode/DOCUMENTATION.md +1 -1
- package/server/lib/opencode/managed-config-file.js +3 -2
- package/server/lib/opencode/managed-config-file.test.js +20 -6
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +1 -1
- package/server/lib/opencode/settings-registry.json +3 -0
- package/server/lib/opencode/settings-runtime.js +1 -0
- package/server/lib/project-context/DOCUMENTATION.md +25 -1
- package/server/lib/project-context/plan-progress.js +69 -0
- package/server/lib/project-context/plan-progress.test.js +58 -0
- package/server/lib/project-context/routes.http.test.js +22 -0
- package/server/lib/project-context/routes.js +20 -0
- package/server/lib/project-context/runtime.js +132 -18
- package/server/lib/project-context/runtime.test.js +58 -0
- package/server/lib/provider-read-cache/index.js +7 -1
- package/server/lib/provider-read-cache/index.test.js +12 -0
- package/server/lib/relay/DOCUMENTATION.md +17 -1
- package/server/lib/session-knowledge/DOCUMENTATION.md +17 -0
- package/server/lib/session-knowledge/runtime.js +29 -6
- package/server/lib/session-knowledge/runtime.test.js +26 -1
- package/server/lib/source-control/audit-storage.js +1 -0
- package/server/lib/source-control/mutation-storage.js +3 -0
- package/server/lib/spaces/DOCUMENTATION.md +14 -9
- package/server/lib/spaces/code-out.js +13 -4
- package/server/lib/spaces/code-out.test.js +5 -3
- package/server/lib/spaces/dispatcher.js +12 -5
- package/server/lib/spaces/dispatcher.test.js +19 -1
- package/server/lib/spaces/gatekeeper-channel.js +8 -7
- package/server/lib/spaces/gatekeeper-channel.test.js +10 -0
- package/server/lib/spaces/gatekeeper-program.cjs +38 -3
- package/server/lib/spaces/gatekeeper-program.test.js +20 -0
- package/server/lib/spaces/hardening.js +14 -1
- package/server/lib/spaces/hardening.test.js +5 -0
- package/server/lib/spaces/host-providers.js +165 -0
- package/server/lib/spaces/host-providers.test.js +100 -0
- package/server/lib/spaces/host.js +16 -4
- package/server/lib/spaces/journey.js +87 -17
- package/server/lib/spaces/journey.test.js +90 -2
- package/server/lib/spaces/layout.js +15 -5
- package/server/lib/spaces/places/docker-live-support.js +2 -0
- package/server/lib/spaces/places/docker.test.js +2 -0
- package/server/lib/spaces/places/fake-docker.js +3 -0
- package/server/lib/spaces/places/grants.docker.live.test.js +71 -7
- package/server/lib/spaces/routes.js +9 -0
- package/server/lib/spaces/routes.test.js +4 -2
- package/server/lib/spaces/space-opencode.js +31 -14
- package/server/lib/spaces/space-opencode.test.js +15 -2
- package/server/lib/spaces/space-records.js +8 -0
- package/server/lib/spaces/space-records.test.js +7 -3
- package/server/lib/spaces/websocket.test.js +13 -1
- package/server/lib/ui-auth/ui-auth.js +28 -3
- package/server/lib/ui-auth/ui-auth.test.js +31 -0
- package/dist/assets/MarkdownRendererImpl-B2LsA09C.js +0 -1
- package/dist/assets/PlanView-Dt5EN_JK.js +0 -5
- package/dist/assets/SettingsView-BolP_tuu.js +0 -30
- package/dist/assets/SourceBoardView-yca1qvgB.js +0 -1
- package/dist/assets/SpaceAccessDialog-CZ-u75py.js +0 -1
- package/dist/assets/katex-rNcbfUj4.css +0 -1
- package/dist/assets/katex.min-DQ8qF6NR.js +0 -65
- package/dist/assets/main-CVHM3_8W.js +0 -1048
- package/dist/assets/markdownCore-D5ZOJXeO.js +0 -9
- package/dist/assets/pl-Bj-Hy0X5.js +0 -20
- package/dist/assets/renderElectronMiniChatApp-B_5BeSF6.js +0 -2
- package/dist/assets/renderMobileApp-DGEXUTk-.js +0 -25
- package/dist/assets/runtimeEndpointReset-CIpvn8QG.js +0 -59
- package/dist/assets/sessionOwnership-BZoGed9N.js +0 -1
- package/dist/assets/tr-qMRMBQ8r.js +0 -11
- package/dist/assets/useAppFontEffects-Bih1DxXi.js +0 -745
- package/dist/assets/vendor-tanstack-react-virtual-CvuLsk7D.js +0 -1
- package/dist/assets/vendor-tanstack-virtual-core-DPaNcJcT.js +0 -1
|
@@ -10,6 +10,12 @@ const pointer = (size = 42) => [
|
|
|
10
10
|
].join('\n');
|
|
11
11
|
const configOutput = (records) => records.map(([key, value]) => `${key}\n${value}\0`).join('');
|
|
12
12
|
const attributesOutput = (records) => records.map(([path, value]) => `${path}\0filter\0${value}\0`).join('');
|
|
13
|
+
const canonicalFilters = [
|
|
14
|
+
['filter.lfs.clean', 'git-lfs clean -- %f'],
|
|
15
|
+
['filter.lfs.smudge', 'git-lfs smudge -- %f'],
|
|
16
|
+
['filter.lfs.process', 'git-lfs filter-process'],
|
|
17
|
+
['filter.lfs.required', 'true'],
|
|
18
|
+
];
|
|
13
19
|
|
|
14
20
|
const input = (overrides = {}) => ({
|
|
15
21
|
attributesOutput: attributesOutput([['assets/model.bin', 'lfs']]),
|
|
@@ -113,6 +119,60 @@ describe('LFS publication discovery', () => {
|
|
|
113
119
|
});
|
|
114
120
|
});
|
|
115
121
|
|
|
122
|
+
describe.each([['checkout', discoverLfs], ['publication', resolveLfsPushConfig]])('LFS configuration validation for %s', (_label, resolve) => {
|
|
123
|
+
const read = (overrides) => resolve(input({ lfsConfigOutput: '', effectiveConfigOutput: '', ...overrides }));
|
|
124
|
+
|
|
125
|
+
it.each([1, 2])('accepts %i copies of canonical effective filters', (copies) => {
|
|
126
|
+
expect(() => read({ effectiveConfigOutput: configOutput(Array.from({ length: copies }, () => canonicalFilters).flat()) })).not.toThrow();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it.each(['filter.lfs.clean', 'filter.lfs.smudge', 'filter.lfs.process'])('rejects conflicting %s values in either order', (key) => {
|
|
130
|
+
const canonical = canonicalFilters.find(([filter]) => filter === key);
|
|
131
|
+
for (const records of [[canonical, [key, 'sh -c unsafe']], [[key, 'sh -c unsafe'], canonical]]) {
|
|
132
|
+
expect(() => read({ effectiveConfigOutput: configOutput(records) }))
|
|
133
|
+
.toThrow(expect.objectContaining({ code: 'INVALID_LFS_DISCOVERY_INPUT' }));
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it.each(['filter.lfs.clean', 'filter.lfs.smudge', 'filter.lfs.process'])('rejects identical unsafe %s values', (key) => {
|
|
138
|
+
const record = [key, 'sh -c unsafe'];
|
|
139
|
+
expect(() => read({ effectiveConfigOutput: configOutput([record, record]) }))
|
|
140
|
+
.toThrow(expect.objectContaining({ code: 'INVALID_LFS_DISCOVERY_INPUT' }));
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it.each([
|
|
144
|
+
['lfs.customtransfer.bad.path', '/tmp/program'],
|
|
145
|
+
['lfs.customtransfer.bad.args', '--execute'],
|
|
146
|
+
['lfs.standalonetransferagent', 'custom'],
|
|
147
|
+
])('rejects %s alongside repeated canonical filters', (key, value) => {
|
|
148
|
+
expect(() => read({ effectiveConfigOutput: configOutput([...canonicalFilters, ...canonicalFilters, [key, value]]) }))
|
|
149
|
+
.toThrow(expect.objectContaining({ code: 'UNSAFE_LFS_EXECUTABLE_CONFIG' }));
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it.each(['lfs.url', 'lfs.pushurl', 'lfs.storage', 'remote.origin.lfsurl'])('keeps duplicate effective %s values strict', (key) => {
|
|
153
|
+
const record = [key, 'https://example.com/storage'];
|
|
154
|
+
expect(() => read({ effectiveConfigOutput: configOutput([record, record]) })).toThrow(`contains duplicate ${key}`);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('keeps duplicate committed metadata strict', () => {
|
|
158
|
+
const record = ['lfs.url', 'https://example.com/storage'];
|
|
159
|
+
expect(() => read({ lfsConfigOutput: configOutput([record, record]) })).toThrow('contains duplicate lfs.url');
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('rejects repeated non-canonical required settings', () => {
|
|
163
|
+
const record = ['filter.lfs.required', 'false'];
|
|
164
|
+
expect(() => read({ effectiveConfigOutput: configOutput([record, record]) })).toThrow('contains duplicate filter.lfs.required');
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it.each([
|
|
168
|
+
['filter.lfs.clean\ngit-lfs clean -- %f', 'incomplete'],
|
|
169
|
+
['filter.lfs.clean\0', 'malformed'],
|
|
170
|
+
['filter.lfs.clean\n\0', 'malformed'],
|
|
171
|
+
])('rejects invalid effective config %j', (output, message) => {
|
|
172
|
+
expect(() => read({ effectiveConfigOutput: output })).toThrow(message);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
116
176
|
describe('incremental LFS file discovery', () => {
|
|
117
177
|
it('reads sizes from the tree listing and asks Git only for paths it lacks', async () => {
|
|
118
178
|
const files = Array.from({ length: 2_000 }, (_, index) => ({ path: `file-${index}`, content: `ordinary ${index}` }));
|
|
@@ -55,6 +55,12 @@ const readTreeListing = (treeOutput) => ({
|
|
|
55
55
|
treeObjects: parseTreeObjects(treeOutput),
|
|
56
56
|
});
|
|
57
57
|
const terminal = (state, code, message) => ({ state, error: publicError(code, message) });
|
|
58
|
+
// A remote-tracking ref mirrors the remote, so it follows a force-pushed
|
|
59
|
+
// branch the way `git fetch` with the default refspec does. A local branch
|
|
60
|
+
// destination is never moved backwards.
|
|
61
|
+
const singleRefFetchRefspec = (sourceRef, destinationRef) => (
|
|
62
|
+
`${destinationRef.startsWith('refs/remotes/') ? '+' : ''}${sourceRef}:${destinationRef}`
|
|
63
|
+
);
|
|
58
64
|
const fileIdentity = (stats) => `${stats.dev}:${stats.ino}`;
|
|
59
65
|
// Linux reuses an inode number when a directory is removed and recreated in the
|
|
60
66
|
// same parent, so device and inode alone cannot tell a replaced directory from
|
|
@@ -1623,7 +1629,7 @@ export function createNetworkOperations({
|
|
|
1623
1629
|
temporaryRef = plan.target.operation === 'pull' ? `refs/openchamber/network/${plan.operationId}` : plan.target.destinationRef;
|
|
1624
1630
|
await commandResult(plan, controls, [
|
|
1625
1631
|
'fetch', '--no-tags', ...(plan.target.operation === 'pull' ? ['--no-recurse-submodules'] : []),
|
|
1626
|
-
'--', plan.rawEndpoint,
|
|
1632
|
+
'--', plan.rawEndpoint, singleRefFetchRefspec(plan.target.sourceRef, temporaryRef),
|
|
1627
1633
|
], context, deadline, { transfer: true });
|
|
1628
1634
|
await controls.markStepCompleted('transferred');
|
|
1629
1635
|
if (plan.target.operation === 'fetch') result = { state: 'succeeded' };
|
|
@@ -1747,7 +1753,7 @@ export function createNetworkOperations({
|
|
|
1747
1753
|
await revalidatePullHead(headPlan, controls, deadline);
|
|
1748
1754
|
await commandResult(fetchPlan, controls, [
|
|
1749
1755
|
'fetch', '--no-tags', '--no-recurse-submodules', '--', fetchPlan.rawEndpoint,
|
|
1750
|
-
|
|
1756
|
+
singleRefFetchRefspec(fetchPlan.target.sourceRef, fetchPlan.target.destinationRef),
|
|
1751
1757
|
], context, deadline, { transfer: true, transferRole: 'fetch' });
|
|
1752
1758
|
await controls.markStepCompleted('transferred');
|
|
1753
1759
|
if (await safeRevoke(context, plan.operationId)) {
|
|
@@ -2227,7 +2233,7 @@ export function createNetworkOperations({
|
|
|
2227
2233
|
await controls.markStepCompleted('authenticated');
|
|
2228
2234
|
await revalidateContributorSource(plan, controls, deadline);
|
|
2229
2235
|
await commandResult(plan, controls, [
|
|
2230
|
-
'fetch', '--no-tags', '--', plan.rawEndpoint,
|
|
2236
|
+
'fetch', '--no-tags', '--', plan.rawEndpoint, singleRefFetchRefspec(plan.target.sourceRef, plan.target.destinationRef),
|
|
2231
2237
|
], context, deadline, { transfer: true });
|
|
2232
2238
|
await controls.markStepCompleted('transferred');
|
|
2233
2239
|
const fetchedSha = String(await awaitPhase(
|
|
@@ -433,6 +433,34 @@ describe('Git network operations', () => {
|
|
|
433
433
|
expect(JSON.stringify(auditStore.plan.mock.calls)).not.toMatch(/https:\/\/|lfs-secret|parent-secret/);
|
|
434
434
|
});
|
|
435
435
|
|
|
436
|
+
it.each(['checkout inspection', 'publication preparation'])('accepts identical global and local canonical LFS filters during %s', async (operation) => {
|
|
437
|
+
const fixture = await createLfsPublicationFixture();
|
|
438
|
+
await fixture.git('checkout', 'feature');
|
|
439
|
+
fixture.env.GIT_CONFIG_GLOBAL = path.join(fixture.parent, 'global.gitconfig');
|
|
440
|
+
for (const [key, value] of [
|
|
441
|
+
['filter.lfs.clean', 'git-lfs clean -- %f'],
|
|
442
|
+
['filter.lfs.smudge', 'git-lfs smudge -- %f'],
|
|
443
|
+
['filter.lfs.process', 'git-lfs filter-process'],
|
|
444
|
+
['filter.lfs.required', 'true'],
|
|
445
|
+
]) {
|
|
446
|
+
await fixture.git('config', '--global', key, value);
|
|
447
|
+
await fixture.git('config', '--local', key, value);
|
|
448
|
+
}
|
|
449
|
+
if (operation === 'checkout inspection') {
|
|
450
|
+
const result = await fixture.service.inspectCheckoutHydration({
|
|
451
|
+
directory: fixture.directory, parentEndpoint: ENDPOINT, parentRemoteName: 'publish',
|
|
452
|
+
});
|
|
453
|
+
expect(result.requirements).toEqual([{ kind: 'lfs', path: '.', endpoint: {
|
|
454
|
+
displayUrl: fixture.lfsEndpoint, fingerprint: fingerprintRemoteUrl(fixture.lfsEndpoint),
|
|
455
|
+
} }]);
|
|
456
|
+
expect(fixture.transfers.calls.some((call) => call.args.includes('fetch') || call.args.includes('push') || call.args.includes('clone'))).toBe(false);
|
|
457
|
+
} else {
|
|
458
|
+
const plan = await fixture.service.plan(fixture.pushRequest);
|
|
459
|
+
expect(await fixture.service.execute(plan.operationId)).toMatchObject({ state: 'succeeded' });
|
|
460
|
+
expect(fixture.transfers.calls.filter((call) => call.args.includes('push'))).toHaveLength(2);
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
|
|
436
464
|
it('publishes ordinary history without probing git-lfs or adding a network transfer', async () => {
|
|
437
465
|
const fixture = await createLfsPublicationFixture({ ordinary: true });
|
|
438
466
|
fixture.binaryResult.code = 1;
|
|
@@ -920,7 +948,8 @@ describe('Git network operations', () => {
|
|
|
920
948
|
expect(setupValue.calls).toHaveLength(1);
|
|
921
949
|
const fetchCall = setupValue.calls[0];
|
|
922
950
|
expect(fetchCall.args).toEqual(expect.arrayContaining([
|
|
923
|
-
|
|
951
|
+
// Forced, so a force-pushed change request head still replaces the stale tracking ref.
|
|
952
|
+
'fetch', '--no-tags', '--', ENDPOINT, '+refs/heads/feature:refs/remotes/pr-alice/feature',
|
|
924
953
|
]));
|
|
925
954
|
expect(fetchCall.options.env.GIT_ASKPASS).toBeUndefined();
|
|
926
955
|
expect(fetchCall.options.env.SSH_AUTH_SOCK).toBeUndefined();
|
|
@@ -2845,7 +2874,7 @@ process.exit(safe ? 0 : 1);
|
|
|
2845
2874
|
expect(setupValue.validateGitTransportContext.mock.calls.map(([value]) => [value.remote, value.endpointKind]))
|
|
2846
2875
|
.toEqual(expect.arrayContaining([['upstream', 'fetch'], ['origin', 'push']]));
|
|
2847
2876
|
expect(setupValue.calls[0].args.slice(-6)).toEqual([
|
|
2848
|
-
'fetch', '--no-tags', '--no-recurse-submodules', '--', fetchEndpoint, 'refs/heads/main:refs/remotes/upstream/main',
|
|
2877
|
+
'fetch', '--no-tags', '--no-recurse-submodules', '--', fetchEndpoint, '+refs/heads/main:refs/remotes/upstream/main',
|
|
2849
2878
|
]);
|
|
2850
2879
|
expect(setupValue.calls.find((call) => call.args.includes('rebase')).args.slice(-4)).toEqual(['rebase', '--no-verify', '--no-autostash', SHA]);
|
|
2851
2880
|
expect(setupValue.calls.at(-2).args.slice(-4)).toEqual(['push', '--', pushEndpoint, `${SHA}:refs/heads/published`]);
|
|
@@ -5146,6 +5146,40 @@ export async function previewWorktreeCreate(directory, input = {}) {
|
|
|
5146
5146
|
};
|
|
5147
5147
|
}
|
|
5148
5148
|
|
|
5149
|
+
const readLocalBranchTip = async (primaryWorktree, branch) => {
|
|
5150
|
+
const result = await runGitCommand(primaryWorktree, ['rev-parse', '--verify', '--quiet', `refs/heads/${branch}^{commit}`]);
|
|
5151
|
+
return result.success ? String(result.stdout || '').trim() : '';
|
|
5152
|
+
};
|
|
5153
|
+
|
|
5154
|
+
/**
|
|
5155
|
+
* A change request's local branch can be left over from an earlier worktree
|
|
5156
|
+
* of it that was removed. That branch is reused and moved to the change
|
|
5157
|
+
* request head. When it diverged from the head (the head was force-pushed),
|
|
5158
|
+
* its old tip is first kept in `<branch>-backup-<sha>`, so no commit becomes
|
|
5159
|
+
* unreachable. Returns null when there is no such branch or it is checked out
|
|
5160
|
+
* elsewhere, which the ordinary creation checks report.
|
|
5161
|
+
*/
|
|
5162
|
+
const prepareChangeRequestLocalBranch = async (primaryWorktree, input = {}) => {
|
|
5163
|
+
const expectedRevision = String(input?.expectedRevision || '').trim();
|
|
5164
|
+
if (input?.changeRequestTransfer !== true || !expectedRevision) return null;
|
|
5165
|
+
const remoteRef = await resolveRemoteBranchRef(primaryWorktree, String(input?.existingBranch || '').trim());
|
|
5166
|
+
const branch = cleanBranchName(String(input?.branchName || '').trim() || remoteRef?.branch || '');
|
|
5167
|
+
if (!remoteRef || !branch) return null;
|
|
5168
|
+
const tip = await readLocalBranchTip(primaryWorktree, branch);
|
|
5169
|
+
if (!tip || await findBranchInUse(primaryWorktree, branch)) return null;
|
|
5170
|
+
if (await isAncestorRef(primaryWorktree, tip, expectedRevision)) return { branch, tip, backupBranch: null };
|
|
5171
|
+
|
|
5172
|
+
const backupBranch = `${branch}-backup-${tip.slice(0, 7)}`;
|
|
5173
|
+
const backupTip = await readLocalBranchTip(primaryWorktree, backupBranch);
|
|
5174
|
+
if (backupTip && backupTip !== tip) {
|
|
5175
|
+
throw new Error(`Branch ${branch} has commits the change request no longer has, and ${backupBranch} already exists`);
|
|
5176
|
+
}
|
|
5177
|
+
if (!backupTip) {
|
|
5178
|
+
await runGitCommandOrThrow(primaryWorktree, ['branch', '--no-track', backupBranch, tip], `Failed to keep ${branch} as ${backupBranch}`);
|
|
5179
|
+
}
|
|
5180
|
+
return { branch, tip, backupBranch };
|
|
5181
|
+
};
|
|
5182
|
+
|
|
5149
5183
|
async function attachGitWorktreeToCandidateWithoutRemoteRollback(context, candidate, input = {}, serverOptions = {}) {
|
|
5150
5184
|
const mode = input?.mode === 'existing' ? 'existing' : 'new';
|
|
5151
5185
|
const startRef = normalizeStartRef(input?.startRef);
|
|
@@ -5166,6 +5200,8 @@ async function attachGitWorktreeToCandidateWithoutRemoteRollback(context, candid
|
|
|
5166
5200
|
});
|
|
5167
5201
|
}
|
|
5168
5202
|
let createdLocalBranch = false;
|
|
5203
|
+
// A leftover change request branch this attempt moves; a failed attempt puts it back.
|
|
5204
|
+
let movedLocalBranch = null;
|
|
5169
5205
|
const worktreeAddArgs = ['worktree', 'add', '--no-checkout'];
|
|
5170
5206
|
|
|
5171
5207
|
if (mode === 'existing') {
|
|
@@ -5178,13 +5214,25 @@ async function attachGitWorktreeToCandidateWithoutRemoteRollback(context, candid
|
|
|
5178
5214
|
throw new Error(`Branch is already checked out in ${inUse.worktree}`);
|
|
5179
5215
|
}
|
|
5180
5216
|
|
|
5181
|
-
|
|
5217
|
+
const reusedBranch = serverOptions.changeRequestLocalBranch;
|
|
5218
|
+
if (resolved.createLocalBranch && reusedBranch?.branch === localBranch) {
|
|
5219
|
+
if (await readLocalBranchTip(context.primaryWorktree, localBranch) !== reusedBranch.tip) {
|
|
5220
|
+
throw new Error(`Branch ${localBranch} changed during worktree creation`);
|
|
5221
|
+
}
|
|
5222
|
+
worktreeAddArgs.push('-B', localBranch);
|
|
5223
|
+
movedLocalBranch = reusedBranch;
|
|
5224
|
+
} else if (resolved.createLocalBranch) {
|
|
5182
5225
|
worktreeAddArgs.push('-b', localBranch);
|
|
5183
5226
|
createdLocalBranch = true;
|
|
5184
5227
|
}
|
|
5185
5228
|
worktreeAddArgs.push(candidate.directory, expectedRevision && resolved.createLocalBranch
|
|
5186
5229
|
? expectedRevision
|
|
5187
5230
|
: resolved.checkoutRef);
|
|
5231
|
+
if (movedLocalBranch && contributorFork) {
|
|
5232
|
+
// The leftover branch may still track something; contributor worktrees never do.
|
|
5233
|
+
await runGitCommand(context.primaryWorktree, ['config', '--unset-all', `branch.${localBranch}.remote`]);
|
|
5234
|
+
await runGitCommand(context.primaryWorktree, ['config', '--unset-all', `branch.${localBranch}.merge`]);
|
|
5235
|
+
}
|
|
5188
5236
|
|
|
5189
5237
|
if (resolved.upstream) {
|
|
5190
5238
|
inferredUpstream = {
|
|
@@ -5238,15 +5286,21 @@ async function attachGitWorktreeToCandidateWithoutRemoteRollback(context, candid
|
|
|
5238
5286
|
await runGitCommandOrThrow(context.primaryWorktree, worktreeAddArgs, 'Failed to create git worktree');
|
|
5239
5287
|
await publishWorktreeTopologyChange(context.primaryWorktree);
|
|
5240
5288
|
|
|
5289
|
+
// Undoes what this attempt did to the local branch, once its worktree is removed.
|
|
5290
|
+
const releaseLocalBranch = async () => {
|
|
5291
|
+
if (createdLocalBranch) return (await runGitCommand(context.primaryWorktree, ['branch', '-D', localBranch])).success;
|
|
5292
|
+
if (movedLocalBranch) {
|
|
5293
|
+
return (await runGitCommand(context.primaryWorktree, ['branch', '-f', localBranch, movedLocalBranch.tip])).success;
|
|
5294
|
+
}
|
|
5295
|
+
return true;
|
|
5296
|
+
};
|
|
5297
|
+
|
|
5241
5298
|
if (expectedRevision) {
|
|
5242
5299
|
const createdHead = await runGitCommand(candidate.directory, ['rev-parse', '--verify', 'HEAD']);
|
|
5243
5300
|
if (!createdHead.success || String(createdHead.stdout || '').trim() !== expectedRevision) {
|
|
5244
5301
|
const removed = await runGitCommand(context.primaryWorktree, ['worktree', 'remove', '--force', candidate.directory]);
|
|
5245
|
-
if (
|
|
5246
|
-
|
|
5247
|
-
if (!branchRemoved.success) {
|
|
5248
|
-
throw new Error('Created worktree revision does not match the requested change request head, and the new local branch could not be removed safely');
|
|
5249
|
-
}
|
|
5302
|
+
if (removed.success && !(await releaseLocalBranch())) {
|
|
5303
|
+
throw new Error('Created worktree revision does not match the requested change request head, and the local branch could not be restored safely');
|
|
5250
5304
|
}
|
|
5251
5305
|
if (!removed.success) {
|
|
5252
5306
|
throw new Error('Created worktree revision does not match the requested change request head, and the worktree could not be removed safely');
|
|
@@ -5276,9 +5330,7 @@ async function attachGitWorktreeToCandidateWithoutRemoteRollback(context, candid
|
|
|
5276
5330
|
});
|
|
5277
5331
|
} catch (error) {
|
|
5278
5332
|
const removed = await runGitCommand(context.primaryWorktree, ['worktree', 'remove', '--force', candidate.directory]);
|
|
5279
|
-
if (
|
|
5280
|
-
await runGitCommand(context.primaryWorktree, ['branch', '-D', localBranch]);
|
|
5281
|
-
}
|
|
5333
|
+
if (removed.success) await releaseLocalBranch();
|
|
5282
5334
|
throw error;
|
|
5283
5335
|
}
|
|
5284
5336
|
}
|
|
@@ -5517,6 +5569,14 @@ export async function createWorktree(directory, input = {}, serverOptions = {})
|
|
|
5517
5569
|
}
|
|
5518
5570
|
const prepared = await prepareWorktreeCreateSource(context, input);
|
|
5519
5571
|
const preparedInput = prepared.input;
|
|
5572
|
+
const changeRequestLocalBranch = mode === 'existing'
|
|
5573
|
+
? await prepareChangeRequestLocalBranch(context.primaryWorktree, preparedInput)
|
|
5574
|
+
: null;
|
|
5575
|
+
const attachOptions = changeRequestLocalBranch ? { ...serverOptions, changeRequestLocalBranch } : serverOptions;
|
|
5576
|
+
// Tells the user where a diverged leftover branch's commits went.
|
|
5577
|
+
const withBranchBackup = (result) => (changeRequestLocalBranch?.backupBranch
|
|
5578
|
+
? { ...result, branchBackup: changeRequestLocalBranch.backupBranch }
|
|
5579
|
+
: result);
|
|
5520
5580
|
|
|
5521
5581
|
await fsp.mkdir(context.worktreeRoot, { recursive: true });
|
|
5522
5582
|
|
|
@@ -5553,7 +5613,7 @@ export async function createWorktree(directory, input = {}, serverOptions = {})
|
|
|
5553
5613
|
: candidate.branch;
|
|
5554
5614
|
|
|
5555
5615
|
const task = bootstrapStatus.status === WORKTREE_BOOTSTRAP_PENDING
|
|
5556
|
-
? attachGitWorktreeToCandidate(context, candidate, preparedInput,
|
|
5616
|
+
? attachGitWorktreeToCandidate(context, candidate, preparedInput, attachOptions).catch(async (error) => {
|
|
5557
5617
|
await setWorktreeBootstrapState(
|
|
5558
5618
|
candidate.directory,
|
|
5559
5619
|
WORKTREE_BOOTSTRAP_FAILED,
|
|
@@ -5581,10 +5641,10 @@ export async function createWorktree(directory, input = {}, serverOptions = {})
|
|
|
5581
5641
|
result.sourceFetchFailed = true;
|
|
5582
5642
|
if (prepared.sourceFetchReason) result.sourceFetchReason = prepared.sourceFetchReason;
|
|
5583
5643
|
}
|
|
5584
|
-
return result;
|
|
5644
|
+
return withBranchBackup(result);
|
|
5585
5645
|
}
|
|
5586
5646
|
|
|
5587
|
-
const result = await attachGitWorktreeToCandidate(context, candidate, preparedInput,
|
|
5647
|
+
const result = withBranchBackup(await attachGitWorktreeToCandidate(context, candidate, preparedInput, attachOptions));
|
|
5588
5648
|
if (!prepared.sourceFetchFailed) return result;
|
|
5589
5649
|
return prepared.sourceFetchReason
|
|
5590
5650
|
? { ...result, sourceFetchFailed: true, sourceFetchReason: prepared.sourceFetchReason }
|
|
@@ -2816,6 +2816,71 @@ exec "$REAL_GIT" "$@"
|
|
|
2816
2816
|
});
|
|
2817
2817
|
}, 30_000);
|
|
2818
2818
|
|
|
2819
|
+
// A worktree of this change request was removed earlier and left its local branch behind.
|
|
2820
|
+
const commitOnBranch = (repository, branch, file, start = 'next') => {
|
|
2821
|
+
runGit(repository, ['checkout', '-B', branch, start]);
|
|
2822
|
+
fs.writeFileSync(path.join(repository, file), `${file}\n`);
|
|
2823
|
+
runGit(repository, ['add', file]);
|
|
2824
|
+
runGit(repository, ['commit', '-m', file]);
|
|
2825
|
+
const sha = runGit(repository, ['rev-parse', 'HEAD']).trim();
|
|
2826
|
+
runGit(repository, ['checkout', 'next']);
|
|
2827
|
+
return sha;
|
|
2828
|
+
};
|
|
2829
|
+
const transferredSameRepositoryInput = (remote, worktreeName, expectedRevision) => ({
|
|
2830
|
+
mode: 'existing',
|
|
2831
|
+
branchName: 'feature/login',
|
|
2832
|
+
worktreeName,
|
|
2833
|
+
existingBranch: 'remotes/origin/feature/login',
|
|
2834
|
+
ensureRemoteName: 'origin',
|
|
2835
|
+
ensureRemoteUrl: remote,
|
|
2836
|
+
changeRequestTransfer: true,
|
|
2837
|
+
contributorTransferComplete: true,
|
|
2838
|
+
expectedRevision,
|
|
2839
|
+
});
|
|
2840
|
+
|
|
2841
|
+
it('moves a leftover change request branch that trails the head, without a backup', async () => {
|
|
2842
|
+
if (!canRunGit()) return;
|
|
2843
|
+
|
|
2844
|
+
await withDataHome(async () => {
|
|
2845
|
+
const { remote, repository } = createRepositoryWithRemote();
|
|
2846
|
+
const leftover = commitOnBranch(repository, 'feature/login', 'FIRST.md');
|
|
2847
|
+
const head = commitOnBranch(repository, 'head-source', 'SECOND.md', leftover);
|
|
2848
|
+
runGit(repository, ['update-ref', 'refs/remotes/origin/feature/login', head]);
|
|
2849
|
+
|
|
2850
|
+
const created = await createWorktree(repository, transferredSameRepositoryInput(remote, 'pr-7-behind', head));
|
|
2851
|
+
|
|
2852
|
+
expect(created.branch).toBe('feature/login');
|
|
2853
|
+
expect(created.branchBackup).toBeUndefined();
|
|
2854
|
+
expect(runGit(created.path, ['rev-parse', 'HEAD']).trim()).toBe(head);
|
|
2855
|
+
expect(runGit(repository, ['branch', '--list', 'feature/login-backup-*']).trim()).toBe('');
|
|
2856
|
+
});
|
|
2857
|
+
}, 30_000);
|
|
2858
|
+
|
|
2859
|
+
it('keeps a diverged leftover change request branch in a backup before moving it to the head', async () => {
|
|
2860
|
+
if (!canRunGit()) return;
|
|
2861
|
+
|
|
2862
|
+
await withDataHome(async () => {
|
|
2863
|
+
const { remote, repository } = createRepositoryWithRemote();
|
|
2864
|
+
const leftover = commitOnBranch(repository, 'feature/login', 'OLD.md');
|
|
2865
|
+
const head = commitOnBranch(repository, 'rebased', 'REBASED.md');
|
|
2866
|
+
runGit(repository, ['update-ref', 'refs/remotes/origin/feature/login', head]);
|
|
2867
|
+
|
|
2868
|
+
const created = await createWorktree(repository, {
|
|
2869
|
+
...transferredSameRepositoryInput(remote, 'pr-7-diverged', head),
|
|
2870
|
+
returnAfterDirectoryCreated: true,
|
|
2871
|
+
});
|
|
2872
|
+
|
|
2873
|
+
const backup = `feature/login-backup-${leftover.slice(0, 7)}`;
|
|
2874
|
+
expect(created.branchBackup).toBe(backup);
|
|
2875
|
+
expect(runGit(repository, ['rev-parse', `refs/heads/${backup}`]).trim()).toBe(leftover);
|
|
2876
|
+
await expect.poll(() => getWorktreeBootstrapStatus(created.path).then((status) => status.status), {
|
|
2877
|
+
timeout: 5_000,
|
|
2878
|
+
}).toBe('ready');
|
|
2879
|
+
expect(runGit(created.path, ['rev-parse', 'HEAD']).trim()).toBe(head);
|
|
2880
|
+
expect(runGit(created.path, ['branch', '--show-current']).trim()).toBe('feature/login');
|
|
2881
|
+
});
|
|
2882
|
+
}, 30_000);
|
|
2883
|
+
|
|
2819
2884
|
it('rejects a fork branch that moved away from the requested PR head revision', async () => {
|
|
2820
2885
|
if (!canRunGit()) return;
|
|
2821
2886
|
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
- Route, PR discovery, and repository metadata caches use an opaque digest of both account ID and credential. Canonical status cache keys also include the trusted repository ID and binding revision, so path replacement and rebinding cannot reuse a warm response. Exact accounts and repository bindings are resolved before cache reads, and bound repository validation always precedes fork metadata cache reads.
|
|
73
73
|
- Canonical PR create, update, merge, and ready routes validate the complete mutation context before credential, Git, cache, or provider access. They use only the validated account and trusted primary remote, require the target and source to belong to the provider-reported fork network, and return durable mutation receipts. Retired `/api/github/pr/*` mutations never enter this flow.
|
|
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
|
+
- Review threads: `/pr/thread/reply` (`threadId`, `body`) answers one through GraphQL `addPullRequestReviewThreadReply`, and `/pr/thread/resolve` (`threadId`, `resolved`) resolves or reopens it through `resolveReviewThread` / `unresolveReviewThread`. A thread id is global on GitHub, so before writing the server reads the node and refuses (`SOURCE_CONTROL_MUTATION_TARGET_INVALID`) a thread that is not on the target pull request. GraphQL refusals arrive as errors with status 200 and are reported as `422` with GitHub's reason. Record kinds are `change-request-thread-reply` (reconciles as `outcome-unknown`, like a comment) and `change-request-thread-resolve` (reconciles by reading the thread's state). The board's detail read (`reference-search.js`) returns each review thread as the comment that opened it, with `thread: { id, resolved, canResolve, canReply, replies }`, where `canResolve` is the viewer's permission for the change the thread can take next.
|
|
75
76
|
- `/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
77
|
- `/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
78
|
- 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.
|
|
@@ -76,6 +76,9 @@ fragment PullReference on PullRequest {
|
|
|
76
76
|
const DETAIL_COMMENT_LIMIT = 50;
|
|
77
77
|
// The newest commits, so the preview can show what each review answered.
|
|
78
78
|
const DETAIL_COMMIT_LIMIT = 50;
|
|
79
|
+
// The newest review threads, and the comments that open and answer each.
|
|
80
|
+
const DETAIL_THREAD_LIMIT = 50;
|
|
81
|
+
const DETAIL_THREAD_COMMENT_LIMIT = 50;
|
|
79
82
|
|
|
80
83
|
const DETAIL_QUERY = `
|
|
81
84
|
query ReferenceDetail($owner: String!, $repo: String!, $number: Int!) {
|
|
@@ -116,13 +119,17 @@ query ReferenceDetail($owner: String!, $repo: String!, $number: Int!) {
|
|
|
116
119
|
nodes { commit { oid messageHeadline committedDate url author { name user { login avatarUrl } } } }
|
|
117
120
|
}
|
|
118
121
|
reviews(last: 30) {
|
|
122
|
+
nodes { author { login avatarUrl } body state createdAt url }
|
|
123
|
+
}
|
|
124
|
+
# Comments on lines come as the threads they open, replies included.
|
|
125
|
+
reviewThreads(last: ${DETAIL_THREAD_LIMIT}) {
|
|
119
126
|
nodes {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
comments(first:
|
|
127
|
+
id
|
|
128
|
+
isResolved
|
|
129
|
+
viewerCanResolve
|
|
130
|
+
viewerCanUnresolve
|
|
131
|
+
viewerCanReply
|
|
132
|
+
comments(first: ${DETAIL_THREAD_COMMENT_LIMIT}) {
|
|
126
133
|
nodes { author { login avatarUrl } body createdAt url path line originalLine }
|
|
127
134
|
}
|
|
128
135
|
}
|
|
@@ -247,6 +254,15 @@ const detailSchema = z.object({
|
|
|
247
254
|
state: z.string(),
|
|
248
255
|
createdAt: z.string().nullable(),
|
|
249
256
|
url: z.string(),
|
|
257
|
+
})),
|
|
258
|
+
}),
|
|
259
|
+
reviewThreads: z.object({
|
|
260
|
+
nodes: z.array(z.object({
|
|
261
|
+
id: z.string().min(1),
|
|
262
|
+
isResolved: z.boolean(),
|
|
263
|
+
viewerCanResolve: z.boolean(),
|
|
264
|
+
viewerCanUnresolve: z.boolean(),
|
|
265
|
+
viewerCanReply: z.boolean(),
|
|
250
266
|
comments: z.object({
|
|
251
267
|
nodes: z.array(detailCommentSchema.extend({
|
|
252
268
|
path: z.string().nullable(),
|
|
@@ -337,7 +353,9 @@ const byCreatedAt = (left, right) => (Date.parse(left.createdAt ?? '') || 0) - (
|
|
|
337
353
|
/**
|
|
338
354
|
* Comments of one issue or PR, oldest first, and for a PR its size, review
|
|
339
355
|
* decision and checks. A PR's reviews join the comments: a review's own text
|
|
340
|
-
* (or its verdict when it has none) and each
|
|
356
|
+
* (or its verdict when it has none), and each review thread as the comment
|
|
357
|
+
* that opened it, with its replies, whether it is resolved, and what this
|
|
358
|
+
* account may do with it.
|
|
341
359
|
* Null when the repo has no such number.
|
|
342
360
|
*/
|
|
343
361
|
export async function fetchReferenceDetail({ octokit, owner, repo, number }) {
|
|
@@ -363,17 +381,30 @@ export async function fetchReferenceDetail({ octokit, owner, repo, number }) {
|
|
|
363
381
|
if (review.body.trim() || state === 'approved' || state === 'changes_requested') {
|
|
364
382
|
comments.push({ author: toAuthor(review.author), body: review.body, createdAt: review.createdAt, url: review.url, path: null, line: null, review: state });
|
|
365
383
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
384
|
+
}
|
|
385
|
+
const lineComment = (comment) => ({
|
|
386
|
+
author: toAuthor(comment.author),
|
|
387
|
+
body: comment.body,
|
|
388
|
+
createdAt: comment.createdAt,
|
|
389
|
+
url: comment.url,
|
|
390
|
+
path: comment.path,
|
|
391
|
+
line: comment.line ?? comment.originalLine,
|
|
392
|
+
review: 'commented',
|
|
393
|
+
});
|
|
394
|
+
// A thread reads as its first comment with the answers under it.
|
|
395
|
+
for (const thread of item.reviewThreads.nodes) {
|
|
396
|
+
const [first, ...replies] = thread.comments.nodes;
|
|
397
|
+
if (!first) continue;
|
|
398
|
+
comments.push({
|
|
399
|
+
...lineComment(first),
|
|
400
|
+
thread: {
|
|
401
|
+
id: thread.id,
|
|
402
|
+
resolved: thread.isResolved,
|
|
403
|
+
canResolve: thread.isResolved ? thread.viewerCanUnresolve : thread.viewerCanResolve,
|
|
404
|
+
canReply: thread.viewerCanReply,
|
|
405
|
+
replies: replies.map(lineComment),
|
|
406
|
+
},
|
|
407
|
+
});
|
|
377
408
|
}
|
|
378
409
|
comments.sort(byCreatedAt);
|
|
379
410
|
return {
|
|
@@ -143,7 +143,7 @@ describe('toReference', () => {
|
|
|
143
143
|
describe('fetchReferenceDetail', () => {
|
|
144
144
|
const graphqlReturning = (item) => ({ graphql: async () => ({ repository: { issueOrPullRequest: item } }) });
|
|
145
145
|
const author = { login: 'octo', avatarUrl: 'https://avatars/octo' };
|
|
146
|
-
const pull = (reviews = []) => ({
|
|
146
|
+
const pull = (reviews = [], threads = []) => ({
|
|
147
147
|
__typename: 'PullRequest',
|
|
148
148
|
number: 9,
|
|
149
149
|
state: 'OPEN',
|
|
@@ -166,6 +166,7 @@ describe('fetchReferenceDetail', () => {
|
|
|
166
166
|
author: { name: 'Octo Cat', user: author },
|
|
167
167
|
} }] },
|
|
168
168
|
reviews: { nodes: reviews },
|
|
169
|
+
reviewThreads: { nodes: threads },
|
|
169
170
|
});
|
|
170
171
|
|
|
171
172
|
it('reads an issue with its comments', async () => {
|
|
@@ -184,11 +185,12 @@ describe('fetchReferenceDetail', () => {
|
|
|
184
185
|
|
|
185
186
|
it('merges a PR review into its comments, oldest first, with size and review', async () => {
|
|
186
187
|
const detail = await fetchReferenceDetail({ octokit: graphqlReturning(pull([
|
|
187
|
-
{ author, body: '', state: 'COMMENTED', createdAt: '2026-10-01T09:00:00Z', url: 'r1',
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
188
|
+
{ author, body: '', state: 'COMMENTED', createdAt: '2026-10-01T09:00:00Z', url: 'r1' },
|
|
189
|
+
{ author, body: '', state: 'APPROVED', createdAt: '2026-10-01T11:00:00Z', url: 'r2' },
|
|
190
|
+
], [{
|
|
191
|
+
id: 'PRRT_one', isResolved: false, viewerCanResolve: true, viewerCanUnresolve: false, viewerCanReply: true,
|
|
192
|
+
comments: { nodes: [{ author, body: 'nit', createdAt: '2026-10-01T09:00:00Z', url: 'c1', path: 'src/a.ts', line: null, originalLine: 7 }] },
|
|
193
|
+
}])), owner: 'acme', repo: 'app', number: 9 });
|
|
192
194
|
expect(detail?.comments.map((comment) => [comment.body, comment.review, comment.path, comment.line])).toEqual([
|
|
193
195
|
['nit', 'commented', 'src/a.ts', 7],
|
|
194
196
|
['first', null, null, null],
|
|
@@ -213,6 +215,26 @@ describe('fetchReferenceDetail', () => {
|
|
|
213
215
|
});
|
|
214
216
|
});
|
|
215
217
|
|
|
218
|
+
it('reads a review thread as its first comment with the replies under it', async () => {
|
|
219
|
+
const detail = await fetchReferenceDetail({ octokit: graphqlReturning(pull([], [{
|
|
220
|
+
id: 'PRRT_two', isResolved: true, viewerCanResolve: false, viewerCanUnresolve: true, viewerCanReply: true,
|
|
221
|
+
comments: { nodes: [
|
|
222
|
+
{ author, body: 'rename this', createdAt: '2026-10-01T09:00:00Z', url: 'c1', path: 'src/a.ts', line: 3, originalLine: 3 },
|
|
223
|
+
{ author: null, body: 'done', createdAt: '2026-10-01T10:00:00Z', url: 'c2', path: 'src/a.ts', line: 3, originalLine: 3 },
|
|
224
|
+
] },
|
|
225
|
+
}])), owner: 'acme', repo: 'app', number: 9 });
|
|
226
|
+
const opener = detail?.comments.find((comment) => comment.url === 'c1');
|
|
227
|
+
expect(opener?.thread).toEqual({
|
|
228
|
+
id: 'PRRT_two',
|
|
229
|
+
resolved: true,
|
|
230
|
+
// A resolved thread is reopened, so that is the permission that counts.
|
|
231
|
+
canResolve: true,
|
|
232
|
+
canReply: true,
|
|
233
|
+
replies: [{ author: null, body: 'done', createdAt: '2026-10-01T10:00:00Z', url: 'c2', path: 'src/a.ts', line: 3, review: 'commented' }],
|
|
234
|
+
});
|
|
235
|
+
expect(detail?.comments.some((comment) => comment.url === 'c2')).toBe(false);
|
|
236
|
+
});
|
|
237
|
+
|
|
216
238
|
it('answers null for a missing number', async () => {
|
|
217
239
|
expect(await fetchReferenceDetail({ octokit: graphqlReturning(null), owner: 'acme', repo: 'app', number: 9 })).toBeNull();
|
|
218
240
|
});
|