@deepseek-ai/dsh-experimental-client-ui-forge 0.2.2-rc.4 → 0.2.3-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +12 -12
- package/README.md +47 -30
- package/README.zh.md +47 -30
- package/lib/client.js +18 -8
- package/lib/client.js.map +1 -1
- package/lib/index.js +2444 -406
- package/lib/typert.host.js +3433 -950
- package/lib/typert.remote-client.d.ts +89 -14
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +3155 -978
- package/lib/types/branch-name.d.ts +30 -0
- package/lib/types/branch-name.d.ts.map +1 -0
- package/lib/types/branch-name.js.map +1 -0
- package/lib/types/client/AttentionIndicator.d.ts +22 -0
- package/lib/types/client/AttentionIndicator.d.ts.map +1 -0
- package/lib/types/client/AttentionIndicator.js.map +1 -0
- package/lib/types/client/BaseMenu.d.ts.map +1 -1
- package/lib/types/client/BaseMenu.js.map +1 -1
- package/lib/types/client/ChangeRequestCard.d.ts +87 -9
- package/lib/types/client/ChangeRequestCard.d.ts.map +1 -1
- package/lib/types/client/ChangeRequestCard.js.map +1 -1
- package/lib/types/client/ChangeRequestOverview.d.ts +126 -10
- package/lib/types/client/ChangeRequestOverview.d.ts.map +1 -1
- package/lib/types/client/ChangeRequestOverview.js.map +1 -1
- package/lib/types/client/ChangeRequestsSection.d.ts +76 -0
- package/lib/types/client/ChangeRequestsSection.d.ts.map +1 -0
- package/lib/types/client/ChangeRequestsSection.js.map +1 -0
- package/lib/types/client/ChangedFiles.d.ts +6 -2
- package/lib/types/client/ChangedFiles.d.ts.map +1 -1
- package/lib/types/client/ChangedFiles.js.map +1 -1
- package/lib/types/client/ChangesLoading.d.ts +14 -0
- package/lib/types/client/ChangesLoading.d.ts.map +1 -0
- package/lib/types/client/ChangesLoading.js.map +1 -0
- package/lib/types/client/ChangesTab.d.ts +62 -14
- package/lib/types/client/ChangesTab.d.ts.map +1 -1
- package/lib/types/client/ChangesTab.js.map +1 -1
- package/lib/types/client/ChangesTabTitle.js.map +1 -1
- package/lib/types/client/DiffFile.d.ts +23 -4
- package/lib/types/client/DiffFile.d.ts.map +1 -1
- package/lib/types/client/DiffFile.js.map +1 -1
- package/lib/types/client/EnvironmentRows.d.ts +79 -0
- package/lib/types/client/EnvironmentRows.d.ts.map +1 -0
- package/lib/types/client/EnvironmentRows.js.map +1 -0
- package/lib/types/client/FileTreePane.d.ts +5 -2
- package/lib/types/client/FileTreePane.d.ts.map +1 -1
- package/lib/types/client/FileTreePane.js.map +1 -1
- package/lib/types/client/LensFilter.d.ts +50 -0
- package/lib/types/client/LensFilter.d.ts.map +1 -0
- package/lib/types/client/LensFilter.js.map +1 -0
- package/lib/types/client/ReasonButton.d.ts +15 -0
- package/lib/types/client/ReasonButton.d.ts.map +1 -0
- package/lib/types/client/ReasonButton.js.map +1 -0
- package/lib/types/client/ReviewComposer.d.ts +11 -4
- package/lib/types/client/ReviewComposer.d.ts.map +1 -1
- package/lib/types/client/ReviewComposer.js.map +1 -1
- package/lib/types/client/ReviewControls.d.ts +18 -7
- package/lib/types/client/ReviewControls.d.ts.map +1 -1
- package/lib/types/client/ReviewControls.js.map +1 -1
- package/lib/types/client/ReviewThread.d.ts +3 -1
- package/lib/types/client/ReviewThread.d.ts.map +1 -1
- package/lib/types/client/ReviewThread.js.map +1 -1
- package/lib/types/client/ReviewThreads.d.ts +32 -2
- package/lib/types/client/ReviewThreads.d.ts.map +1 -1
- package/lib/types/client/ReviewThreads.js.map +1 -1
- package/lib/types/client/SessionHoverForge.d.ts.map +1 -1
- package/lib/types/client/SessionHoverForge.js.map +1 -1
- package/lib/types/client/SubmitReview.d.ts +4 -4
- package/lib/types/client/SubmitReview.d.ts.map +1 -1
- package/lib/types/client/SubmitReview.js.map +1 -1
- package/lib/types/client/ThreadList.js.map +1 -1
- package/lib/types/client/ViewOptionsMenu.d.ts +7 -1
- package/lib/types/client/ViewOptionsMenu.d.ts.map +1 -1
- package/lib/types/client/ViewOptionsMenu.js.map +1 -1
- package/lib/types/client/WorktreeNameDialog.d.ts +38 -0
- package/lib/types/client/WorktreeNameDialog.d.ts.map +1 -0
- package/lib/types/client/WorktreeNameDialog.js.map +1 -0
- package/lib/types/client/WorktreeProgress.d.ts +14 -3
- package/lib/types/client/WorktreeProgress.d.ts.map +1 -1
- package/lib/types/client/WorktreeProgress.js.map +1 -1
- package/lib/types/client/WorktreeToggle.d.ts +22 -15
- package/lib/types/client/WorktreeToggle.d.ts.map +1 -1
- package/lib/types/client/WorktreeToggle.js.map +1 -1
- package/lib/types/client/action-notices.d.ts +25 -0
- package/lib/types/client/action-notices.d.ts.map +1 -0
- package/lib/types/client/action-notices.js.map +1 -0
- package/lib/types/client/annotations.d.ts +41 -0
- package/lib/types/client/annotations.d.ts.map +1 -0
- package/lib/types/client/annotations.js.map +1 -0
- package/lib/types/client/branch-search.d.ts +38 -0
- package/lib/types/client/branch-search.d.ts.map +1 -0
- package/lib/types/client/branch-search.js.map +1 -0
- package/lib/types/client/change-requests-store.d.ts +25 -0
- package/lib/types/client/change-requests-store.d.ts.map +1 -0
- package/lib/types/client/change-requests-store.js.map +1 -0
- package/lib/types/client/changes-address.d.ts +3 -1
- package/lib/types/client/changes-address.d.ts.map +1 -1
- package/lib/types/client/changes-address.js.map +1 -1
- package/lib/types/client/changes-service.d.ts +119 -0
- package/lib/types/client/changes-service.d.ts.map +1 -0
- package/lib/types/client/changes-service.js.map +1 -0
- package/lib/types/client/changes-store.d.ts +6 -2
- package/lib/types/client/changes-store.d.ts.map +1 -1
- package/lib/types/client/changes-store.js.map +1 -1
- package/lib/types/client/checkout.d.ts.map +1 -1
- package/lib/types/client/checkout.js.map +1 -1
- package/lib/types/client/diff-rows.d.ts +49 -7
- package/lib/types/client/diff-rows.d.ts.map +1 -1
- package/lib/types/client/diff-rows.js.map +1 -1
- package/lib/types/client/file-tree.d.ts +7 -0
- package/lib/types/client/file-tree.d.ts.map +1 -1
- package/lib/types/client/file-tree.js.map +1 -1
- package/lib/types/client/forge-copy.d.ts +29 -0
- package/lib/types/client/forge-copy.d.ts.map +1 -0
- package/lib/types/client/forge-copy.js.map +1 -0
- package/lib/types/client/format.d.ts +8 -0
- package/lib/types/client/format.d.ts.map +1 -1
- package/lib/types/client/format.js.map +1 -1
- package/lib/types/client/glyphs.d.ts +3 -3
- package/lib/types/client/glyphs.d.ts.map +1 -1
- package/lib/types/client/glyphs.js.map +1 -1
- package/lib/types/client/highlight-context.d.ts +73 -0
- package/lib/types/client/highlight-context.d.ts.map +1 -0
- package/lib/types/client/highlight-context.js.map +1 -0
- package/lib/types/client/index.d.ts +9 -5
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js.map +1 -1
- package/lib/types/client/lens-filter.d.ts +69 -0
- package/lib/types/client/lens-filter.d.ts.map +1 -0
- package/lib/types/client/lens-filter.js.map +1 -0
- package/lib/types/client/locales.d.ts +188 -36
- package/lib/types/client/locales.d.ts.map +1 -1
- package/lib/types/client/locales.js.map +1 -1
- package/lib/types/client/mount.d.ts +0 -4
- package/lib/types/client/mount.d.ts.map +1 -1
- package/lib/types/client/mount.js.map +1 -1
- package/lib/types/client/review-page/ReviewChat.d.ts +112 -0
- package/lib/types/client/review-page/ReviewChat.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewChat.js.map +1 -0
- package/lib/types/client/review-page/ReviewDetail.d.ts +56 -0
- package/lib/types/client/review-page/ReviewDetail.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewDetail.js.map +1 -0
- package/lib/types/client/review-page/ReviewLabels.d.ts +32 -0
- package/lib/types/client/review-page/ReviewLabels.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewLabels.js.map +1 -0
- package/lib/types/client/review-page/ReviewList.d.ts +68 -0
- package/lib/types/client/review-page/ReviewList.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewList.js.map +1 -0
- package/lib/types/client/review-page/ReviewNav.d.ts +28 -0
- package/lib/types/client/review-page/ReviewNav.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewNav.js.map +1 -0
- package/lib/types/client/review-page/ReviewPage.d.ts +61 -0
- package/lib/types/client/review-page/ReviewPage.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewPage.js.map +1 -0
- package/lib/types/client/review-page/ReviewStatus.d.ts +37 -0
- package/lib/types/client/review-page/ReviewStatus.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewStatus.js.map +1 -0
- package/lib/types/client/review-page/host-stream.d.ts +24 -0
- package/lib/types/client/review-page/host-stream.d.ts.map +1 -0
- package/lib/types/client/review-page/host-stream.js.map +1 -0
- package/lib/types/client/review-page/review-lists.d.ts +116 -0
- package/lib/types/client/review-page/review-lists.d.ts.map +1 -0
- package/lib/types/client/review-page/review-lists.js.map +1 -0
- package/lib/types/client/review-page/review-mount.d.ts +50 -0
- package/lib/types/client/review-page/review-mount.d.ts.map +1 -0
- package/lib/types/client/review-page/review-mount.js.map +1 -0
- package/lib/types/client/review-page/review-store.d.ts +79 -0
- package/lib/types/client/review-page/review-store.d.ts.map +1 -0
- package/lib/types/client/review-page/review-store.js.map +1 -0
- package/lib/types/client/review-queue.d.ts +19 -0
- package/lib/types/client/review-queue.d.ts.map +1 -1
- package/lib/types/client/review-queue.js.map +1 -1
- package/lib/types/client/review-threads.d.ts +0 -8
- package/lib/types/client/review-threads.d.ts.map +1 -1
- package/lib/types/client/review-threads.js.map +1 -1
- package/lib/types/client/review.d.ts +18 -0
- package/lib/types/client/review.d.ts.map +1 -1
- package/lib/types/client/review.js.map +1 -1
- package/lib/types/client/slots.d.ts +114 -0
- package/lib/types/client/slots.d.ts.map +1 -0
- package/lib/types/client/slots.js.map +1 -0
- package/lib/types/client/source.d.ts +29 -23
- package/lib/types/client/source.d.ts.map +1 -1
- package/lib/types/client/source.js.map +1 -1
- package/lib/types/client/status.d.ts +13 -2
- package/lib/types/client/status.d.ts.map +1 -1
- package/lib/types/client/status.js.map +1 -1
- package/lib/types/git.d.ts +4 -15
- package/lib/types/git.d.ts.map +1 -1
- package/lib/types/git.js.map +1 -1
- package/lib/types/index.d.ts +346 -28
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/lens-version.d.ts +14 -0
- package/lib/types/lens-version.d.ts.map +1 -0
- package/lib/types/lens-version.js.map +1 -0
- package/lib/types/lenses.d.ts +122 -0
- package/lib/types/lenses.d.ts.map +1 -0
- package/lib/types/lenses.js.map +1 -0
- package/lib/types/local-diff.d.ts +16 -0
- package/lib/types/local-diff.d.ts.map +1 -1
- package/lib/types/local-diff.js.map +1 -1
- package/lib/types/panel.d.ts +59 -8
- package/lib/types/panel.d.ts.map +1 -1
- package/lib/types/panel.js.map +1 -1
- package/lib/types/parse.d.ts +24 -8
- package/lib/types/parse.d.ts.map +1 -1
- package/lib/types/parse.js.map +1 -1
- package/lib/types/review-cache.d.ts +29 -19
- package/lib/types/review-cache.d.ts.map +1 -1
- package/lib/types/review-cache.js.map +1 -1
- package/lib/types/states.d.ts +11 -7
- package/lib/types/states.d.ts.map +1 -1
- package/lib/types/states.js.map +1 -1
- package/lib/types/types.d.ts +266 -20
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/viewer-lists.d.ts +113 -0
- package/lib/types/viewer-lists.d.ts.map +1 -0
- package/lib/types/viewer-lists.js.map +1 -0
- package/lib/types/worktree.d.ts +20 -11
- package/lib/types/worktree.d.ts.map +1 -1
- package/lib/types/worktree.js.map +1 -1
- package/locale/de.json +1 -1
- package/locale/en.json +1 -1
- package/locale/es.json +1 -1
- package/locale/fr.json +1 -1
- package/locale/ja.json +1 -1
- package/locale/pt.json +1 -1
- package/locale/ru.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +58 -49
- package/src/branch-name.ts +74 -0
- package/src/client/AttentionIndicator.tsx +37 -0
- package/src/client/BaseMenu.module.css +0 -20
- package/src/client/BaseMenu.tsx +9 -52
- package/src/client/ChangeRequestCard.tsx +276 -131
- package/src/client/ChangeRequestOverview.module.css +1 -1
- package/src/client/ChangeRequestOverview.tsx +183 -67
- package/src/client/ChangeRequestsSection.tsx +234 -0
- package/src/client/ChangedFiles.module.css +5 -1
- package/src/client/ChangedFiles.tsx +72 -36
- package/src/client/ChangesLoading.module.css +110 -0
- package/src/client/ChangesLoading.tsx +69 -0
- package/src/client/ChangesTab.module.css +83 -114
- package/src/client/ChangesTab.tsx +331 -100
- package/src/client/ChangesTabTitle.tsx +3 -3
- package/src/client/DiffFile.tsx +241 -45
- package/src/client/EnvironmentRows.tsx +263 -0
- package/src/client/FileLabel.tsx +1 -1
- package/src/client/FileTreePane.tsx +11 -6
- package/src/client/{ForgeTab.module.css → Forge.module.css} +130 -275
- package/src/client/LensFilter.module.css +87 -0
- package/src/client/LensFilter.tsx +105 -0
- package/src/client/ReasonButton.tsx +23 -0
- package/src/client/ReviewComposer.module.css +2 -8
- package/src/client/ReviewComposer.tsx +27 -8
- package/src/client/ReviewControls.module.css +39 -0
- package/src/client/ReviewControls.tsx +71 -15
- package/src/client/ReviewThread.tsx +55 -30
- package/src/client/ReviewThreads.module.css +24 -0
- package/src/client/ReviewThreads.tsx +56 -21
- package/src/client/SessionHoverForge.tsx +2 -1
- package/src/client/SubmitReview.tsx +11 -8
- package/src/client/ThreadList.tsx +1 -1
- package/src/client/ViewOptionsMenu.tsx +19 -4
- package/src/client/WorktreeNameDialog.module.css +53 -0
- package/src/client/WorktreeNameDialog.tsx +93 -0
- package/src/client/WorktreeProgress.tsx +100 -35
- package/src/client/WorktreeToggle.module.css +121 -5
- package/src/client/WorktreeToggle.tsx +178 -61
- package/src/client/action-notices.ts +38 -0
- package/src/client/annotations.ts +105 -0
- package/src/client/branch-search.tsx +77 -0
- package/src/client/change-requests-store.ts +50 -0
- package/src/client/changes-address.ts +3 -1
- package/src/client/changes-service.ts +173 -0
- package/src/client/changes-store.ts +103 -91
- package/src/client/checkout.ts +2 -1
- package/src/client/diff-rows.ts +100 -16
- package/src/client/file-tree.ts +29 -0
- package/src/client/forge-copy.ts +49 -0
- package/src/client/format.ts +14 -0
- package/src/client/glyphs.tsx +12 -13
- package/src/client/highlight-context.ts +213 -0
- package/src/client/index.ts +20 -5
- package/src/client/lens-filter.ts +136 -0
- package/src/client/locales.ts +1504 -288
- package/src/client/mount.ts +228 -109
- package/src/client/review-page/ReviewChat.tsx +311 -0
- package/src/client/review-page/ReviewDetail.tsx +331 -0
- package/src/client/review-page/ReviewLabels.tsx +94 -0
- package/src/client/review-page/ReviewList.tsx +461 -0
- package/src/client/review-page/ReviewNav.tsx +47 -0
- package/src/client/review-page/ReviewPage.module.css +946 -0
- package/src/client/review-page/ReviewPage.tsx +287 -0
- package/src/client/review-page/ReviewStatus.tsx +259 -0
- package/src/client/review-page/host-stream.ts +63 -0
- package/src/client/review-page/review-lists.ts +207 -0
- package/src/client/review-page/review-mount.ts +228 -0
- package/src/client/review-page/review-store.ts +94 -0
- package/src/client/review-queue.ts +30 -0
- package/src/client/review-threads.ts +0 -12
- package/src/client/review.ts +27 -0
- package/src/client/slots.ts +92 -0
- package/src/client/source.ts +67 -43
- package/src/client/status.ts +16 -4
- package/src/git.ts +16 -38
- package/src/index.ts +900 -152
- package/src/lens-version.ts +27 -0
- package/src/lenses.ts +284 -0
- package/src/local-diff.ts +48 -1
- package/src/panel.ts +123 -28
- package/src/parse.ts +86 -10
- package/src/review-cache.ts +57 -37
- package/src/states.ts +38 -18
- package/src/types.ts +267 -21
- package/src/viewer-lists.ts +375 -0
- package/src/worktree.ts +64 -34
- package/lib/types/client/ForgeTab.d.ts +0 -65
- package/lib/types/client/ForgeTab.d.ts.map +0 -1
- package/lib/types/client/ForgeTab.js.map +0 -1
- package/lib/types/client/ForgeTabTitle.d.ts +0 -11
- package/lib/types/client/ForgeTabTitle.d.ts.map +0 -1
- package/lib/types/client/ForgeTabTitle.js.map +0 -1
- package/lib/types/client/HeaderButton.d.ts +0 -27
- package/lib/types/client/HeaderButton.d.ts.map +0 -1
- package/lib/types/client/HeaderButton.js.map +0 -1
- package/lib/types/client/LocalChangesCard.d.ts +0 -29
- package/lib/types/client/LocalChangesCard.d.ts.map +0 -1
- package/lib/types/client/LocalChangesCard.js.map +0 -1
- package/src/client/ForgeTab.tsx +0 -263
- package/src/client/ForgeTabTitle.tsx +0 -21
- package/src/client/HeaderButton.module.css +0 -29
- package/src/client/HeaderButton.tsx +0 -68
- package/src/client/LocalChangesCard.tsx +0 -83
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Service } from "@deepseek-ai/cordis";
|
|
|
2
2
|
import z from "@deepseek-ai/schemastery";
|
|
3
3
|
import { changeRequestKey } from "@deepseek-ai/dsh-experimental-forge";
|
|
4
4
|
import { appendPluginRecord, pluginRecordOf } from "@deepseek-ai/dsh-session";
|
|
5
|
-
import { MAX_TIMER_DELAY_MS, deadline } from "@deepseek-ai/dsh-timeout";
|
|
5
|
+
import { MAX_TIMER_DELAY_MS, deadline, timeoutOf } from "@deepseek-ai/dsh-timeout";
|
|
6
6
|
import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
7
7
|
import { assertNever } from "@deepseek-ai/dsh-util-values";
|
|
8
8
|
import { createHash } from "node:crypto";
|
|
@@ -13,8 +13,57 @@ import { isDeepStrictEqual } from "node:util";
|
|
|
13
13
|
import { isAbsolute, relative, sep } from "node:path";
|
|
14
14
|
import { CREATED_RECORD, createdWorktreeSchema, generatedWorktreeName } from "@deepseek-ai/dsh-experimental-worktree";
|
|
15
15
|
import { z as z$1 } from "zod";
|
|
16
|
-
import { Buffer } from "node:buffer";
|
|
16
|
+
import { Buffer as Buffer$1 } from "node:buffer";
|
|
17
17
|
import { defineDomain } from "@deepseek-ai/dsh-storage-domain";
|
|
18
|
+
//#region lib/types/branch-name.js
|
|
19
|
+
/** Branch-name rules and branch labels shared by the Host and the Client; free of Node imports. */
|
|
20
|
+
/** Prefix of the full names of local branches. */
|
|
21
|
+
const LOCAL_REF_PREFIX = "refs/heads/";
|
|
22
|
+
/** Prefix of the full names of remote-tracking branches. */
|
|
23
|
+
const REMOTE_REF_PREFIX = "refs/remotes/";
|
|
24
|
+
/** Characters Git refuses anywhere in a ref name: ASCII controls, `~ ^ : ? * [`, and the backslash. */
|
|
25
|
+
const FORBIDDEN = /[\u0000-\u001f\u007f~^:?*[\\]/;
|
|
26
|
+
/**
|
|
27
|
+
* Find the first rule a new branch name breaks. `git check-ref-format` stays the final check on the Host.
|
|
28
|
+
* @param name - candidate branch name.
|
|
29
|
+
* @returns the broken rule, or null when the name passes every rule.
|
|
30
|
+
*/
|
|
31
|
+
function branchNameProblem(name) {
|
|
32
|
+
if (name.length === 0) return "empty";
|
|
33
|
+
if (/\s/.test(name)) return "space";
|
|
34
|
+
if (FORBIDDEN.test(name)) return "character";
|
|
35
|
+
if (name.startsWith("-")) return "leading-dash";
|
|
36
|
+
if (name.startsWith("/")) return "leading-slash";
|
|
37
|
+
if (name.endsWith("/")) return "trailing-slash";
|
|
38
|
+
if (name.includes("//")) return "double-slash";
|
|
39
|
+
if (name.includes("..")) return "double-dot";
|
|
40
|
+
if (name.endsWith(".")) return "trailing-dot";
|
|
41
|
+
if (name === "@") return "at";
|
|
42
|
+
if (name.includes("@{")) return "at-brace";
|
|
43
|
+
const segments = name.split("/");
|
|
44
|
+
if (segments.some((segment) => segment.startsWith("."))) return "dot-segment";
|
|
45
|
+
if (segments.some((segment) => segment.endsWith(".lock"))) return "lock-segment";
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The name a branch shows: a full local or remote-tracking branch name without its `refs/heads/` or
|
|
50
|
+
* `refs/remotes/` prefix; any other revision, such as a short name an earlier panel recorded, as it is.
|
|
51
|
+
* @param ref - branch or revision.
|
|
52
|
+
* @returns the shown name.
|
|
53
|
+
*/
|
|
54
|
+
function branchLabel(ref) {
|
|
55
|
+
for (const prefix of [LOCAL_REF_PREFIX, REMOTE_REF_PREFIX]) if (ref.startsWith(prefix) && ref.length > prefix.length) return ref.slice(prefix.length);
|
|
56
|
+
return ref;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Whether a revision is the full name of a remote-tracking branch, which a worktree creation fetches first.
|
|
60
|
+
* @param ref - branch or revision, or null for HEAD.
|
|
61
|
+
* @returns whether `ref` lies under `refs/remotes/`.
|
|
62
|
+
*/
|
|
63
|
+
function isRemoteRef(ref) {
|
|
64
|
+
return ref !== null && ref.startsWith("refs/remotes/") && ref.length > 13;
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
18
67
|
//#region lib/types/parse.js
|
|
19
68
|
/** Parsers for the porcelain output of the read-only Git commands the panel runs. */
|
|
20
69
|
/**
|
|
@@ -29,7 +78,7 @@ function parseTopLevel(output) {
|
|
|
29
78
|
return root;
|
|
30
79
|
}
|
|
31
80
|
/**
|
|
32
|
-
* Read the first line of a one-name output such as `git symbolic-ref --
|
|
81
|
+
* Read the first line of a one-name output such as `git symbolic-ref --quiet HEAD`.
|
|
33
82
|
* @param output - stdout of the command.
|
|
34
83
|
* @returns the name, or null when the command printed none.
|
|
35
84
|
*/
|
|
@@ -71,16 +120,85 @@ function parseBaseBranches(output, current, query, limit) {
|
|
|
71
120
|
};
|
|
72
121
|
}
|
|
73
122
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
123
|
+
* Select the branches a new worktree can start from out of `git for-each-ref` output, keeping its order within
|
|
124
|
+
* each group: the checked-out branch, each remote's default branch, the other local branches, and the other
|
|
125
|
+
* remote-tracking branches of each remote. A remote's default branch is the branch its `refs/remotes/<remote>/HEAD`
|
|
126
|
+
* names; remote-tracking branches of unconfigured remotes and other symbolic refs are left out.
|
|
127
|
+
* @param output - stdout of `git for-each-ref --format=%(refname)%00%(symref)` over {@link BASE_REF_PREFIXES}.
|
|
76
128
|
* @param current - checked-out branch, or null when HEAD is detached.
|
|
77
|
-
* @param
|
|
78
|
-
* @param
|
|
79
|
-
* @
|
|
129
|
+
* @param remotes - configured remotes in the order their groups take.
|
|
130
|
+
* @param query - text the names must contain, ignoring case; empty or blank for every branch.
|
|
131
|
+
* @param limit - most branches in the local group and in each remote's group.
|
|
132
|
+
* @param repositoryOf - the repository a remote's group names.
|
|
133
|
+
* @returns the branches, with remotes that have no listed branch left out.
|
|
80
134
|
*/
|
|
81
|
-
function
|
|
82
|
-
const
|
|
83
|
-
|
|
135
|
+
function parseWorktreeBases(output, current, remotes, query, limit, repositoryOf) {
|
|
136
|
+
const [heads, tracking] = BASE_REF_PREFIXES;
|
|
137
|
+
const needle = query.trim().toLowerCase();
|
|
138
|
+
const matches = (name) => name.toLowerCase().includes(needle);
|
|
139
|
+
const listed = [];
|
|
140
|
+
const remoteHeads = /* @__PURE__ */ new Map();
|
|
141
|
+
for (const line of output.split(/\r?\n/)) {
|
|
142
|
+
const [ref = "", symref = ""] = line.split("\0");
|
|
143
|
+
if (ref.length === 0) continue;
|
|
144
|
+
if (symref.length === 0) {
|
|
145
|
+
listed.push(ref);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
const owner = ref.startsWith(tracking) ? upstreamBranch(ref.slice(tracking.length), remotes) : void 0;
|
|
149
|
+
if (owner?.branch === "HEAD") remoteHeads.set(owner.remote.name, symref);
|
|
150
|
+
}
|
|
151
|
+
const present = new Set(listed);
|
|
152
|
+
const defaultRefs = /* @__PURE__ */ new Set();
|
|
153
|
+
const defaults = [];
|
|
154
|
+
for (const remote of remotes) {
|
|
155
|
+
const target = remoteHeads.get(remote.name);
|
|
156
|
+
if (target === void 0 || !present.has(target) || !target.startsWith(`${tracking}${remote.name}/`)) continue;
|
|
157
|
+
defaultRefs.add(target);
|
|
158
|
+
const name = target.slice(tracking.length);
|
|
159
|
+
if (matches(name)) defaults.push({
|
|
160
|
+
ref: target,
|
|
161
|
+
name,
|
|
162
|
+
remote: remote.name
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const local = [];
|
|
166
|
+
const groups = remotes.map((remote) => ({
|
|
167
|
+
remote,
|
|
168
|
+
branches: []
|
|
169
|
+
}));
|
|
170
|
+
for (const ref of listed) {
|
|
171
|
+
if (ref.startsWith(heads)) {
|
|
172
|
+
const name = ref.slice(heads.length);
|
|
173
|
+
if (name !== current && local.length < limit && matches(name)) local.push({
|
|
174
|
+
ref,
|
|
175
|
+
name
|
|
176
|
+
});
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (!ref.startsWith(tracking) || defaultRefs.has(ref)) continue;
|
|
180
|
+
const name = ref.slice(tracking.length);
|
|
181
|
+
const owner = upstreamBranch(name, remotes)?.remote;
|
|
182
|
+
const group = groups.find((candidate) => candidate.remote === owner);
|
|
183
|
+
if (group !== void 0 && group.branches.length < limit && matches(name)) group.branches.push({
|
|
184
|
+
ref,
|
|
185
|
+
name
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const currentRef = `${heads}${current ?? ""}`;
|
|
189
|
+
return {
|
|
190
|
+
current: current !== null && present.has(currentRef) && matches(current) ? {
|
|
191
|
+
ref: currentRef,
|
|
192
|
+
name: current
|
|
193
|
+
} : null,
|
|
194
|
+
defaults,
|
|
195
|
+
local,
|
|
196
|
+
remotes: groups.filter((group) => group.branches.length > 0).map(({ remote, branches }) => ({
|
|
197
|
+
name: remote.name,
|
|
198
|
+
repository: repositoryOf(remote),
|
|
199
|
+
branches
|
|
200
|
+
}))
|
|
201
|
+
};
|
|
84
202
|
}
|
|
85
203
|
/**
|
|
86
204
|
* Group the lines of `git remote -v` by remote.
|
|
@@ -123,6 +241,20 @@ function upstreamBranch(upstream, remotes) {
|
|
|
123
241
|
};
|
|
124
242
|
}
|
|
125
243
|
/**
|
|
244
|
+
* Name the repository a remote's group shows: `owner/name` of the first URL a provider recognizes, else the first URL
|
|
245
|
+
* without the user name and password a URL can carry as a token, since the name reaches the browser.
|
|
246
|
+
* @param remote - remote with its URLs, fetch URL first.
|
|
247
|
+
* @param recognize - the repository a provider recognizes from a URL, or undefined.
|
|
248
|
+
* @returns the name, or null for a remote without a URL.
|
|
249
|
+
*/
|
|
250
|
+
function remoteRepository(remote, recognize) {
|
|
251
|
+
for (const url of remote.urls) {
|
|
252
|
+
const repository = recognize(url);
|
|
253
|
+
if (repository !== void 0) return `${repository.owner}/${repository.name}`;
|
|
254
|
+
}
|
|
255
|
+
return remote.urls[0]?.replace(/^([A-Za-z][A-Za-z0-9+.-]*:\/\/)[^/?#]*@/, "$1") ?? null;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
126
258
|
* Order remotes for code host recognition: the upstream's remote first, then
|
|
127
259
|
* `origin`, then the rest in listed order.
|
|
128
260
|
* @param upstream - upstream branch such as `origin/main`, or null.
|
|
@@ -137,7 +269,7 @@ function remoteOrder(upstream, remotes) {
|
|
|
137
269
|
//#endregion
|
|
138
270
|
//#region lib/types/git.js
|
|
139
271
|
/** Git queries in a Session's current directory, using its permissions and execution world. */
|
|
140
|
-
var __addDisposableResource$
|
|
272
|
+
var __addDisposableResource$2 = function(env, value, async) {
|
|
141
273
|
if (value !== null && value !== void 0) {
|
|
142
274
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
143
275
|
var dispose, inner;
|
|
@@ -166,7 +298,7 @@ var __addDisposableResource$1 = function(env, value, async) {
|
|
|
166
298
|
} else if (async) env.stack.push({ async: true });
|
|
167
299
|
return value;
|
|
168
300
|
};
|
|
169
|
-
var __disposeResources$
|
|
301
|
+
var __disposeResources$2 = (function(SuppressedError) {
|
|
170
302
|
return function(env) {
|
|
171
303
|
function fail(e) {
|
|
172
304
|
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
@@ -298,34 +430,6 @@ async function inspectCheckout(ctx, config, session, directory, signal) {
|
|
|
298
430
|
remotes: parseRemotes(remotes.stdout)
|
|
299
431
|
};
|
|
300
432
|
}
|
|
301
|
-
/**
|
|
302
|
-
* List the local branches that can start a worktree of the checkout containing
|
|
303
|
-
* `directory`, using the Session's permissions as in {@link inspectCheckout}.
|
|
304
|
-
* @param ctx - context that provides `subprocess`, `sandbox`, and `sandboxPolicy`.
|
|
305
|
-
* @param config - executable and process limits.
|
|
306
|
-
* @param session - Session whose sandbox policy and execution world apply.
|
|
307
|
-
* @param directory - absolute directory inside the checkout.
|
|
308
|
-
* @param limit - most branch names to return.
|
|
309
|
-
* @param signal - cancellation of every command.
|
|
310
|
-
* @returns the checked-out branch and local branches, the checked-out one first and then most recently committed first.
|
|
311
|
-
* @throws when `directory` is not inside a checkout, or Git cannot run, fails, times out, or prints more than `maxOutputBytes`.
|
|
312
|
-
*/
|
|
313
|
-
async function listBranches(ctx, config, session, directory, limit, signal) {
|
|
314
|
-
const [current, refs] = await together(signal, (signal) => {
|
|
315
|
-
const git = gitIn(ctx, config, session, directory, signal);
|
|
316
|
-
return [currentBranch(git), git("for-each-ref", [
|
|
317
|
-
"for-each-ref",
|
|
318
|
-
"--sort=-committerdate",
|
|
319
|
-
`--count=${limit}`,
|
|
320
|
-
"--format=%(refname:lstrip=2)",
|
|
321
|
-
"refs/heads/"
|
|
322
|
-
])];
|
|
323
|
-
});
|
|
324
|
-
return {
|
|
325
|
-
current,
|
|
326
|
-
branches: baseBranches$1(current, refs.stdout, limit)
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
433
|
/** A failed read cancels its siblings and returns only after every read has finished cleanup. */
|
|
330
434
|
async function together(signal, start) {
|
|
331
435
|
const stop = new AbortController();
|
|
@@ -350,7 +454,7 @@ async function together(signal, start) {
|
|
|
350
454
|
* @throws when Git cannot run, fails, times out, or prints more than `maxOutputBytes`.
|
|
351
455
|
*/
|
|
352
456
|
async function hasBranch(ctx, config, session, repositoryRoot, branch, signal) {
|
|
353
|
-
return (await gitIn(ctx, config, session, repositoryRoot, signal)("show-ref", [
|
|
457
|
+
return (await gitIn(ctx, config, session, repositoryRoot, signal, repositoryRoot)("show-ref", [
|
|
354
458
|
"show-ref",
|
|
355
459
|
"--verify",
|
|
356
460
|
"--quiet",
|
|
@@ -366,21 +470,30 @@ async function hasBranch(ctx, config, session, repositoryRoot, branch, signal) {
|
|
|
366
470
|
* @param session - Session whose sandbox policy and execution world apply.
|
|
367
471
|
* @param directory - working directory of every command.
|
|
368
472
|
* @param signal - cancellation of every command.
|
|
473
|
+
* @param root - checkout that bounds the commands in place of the Session's workspace root: the source
|
|
474
|
+
* repository of the Session's worktree, which is read while the worktree directory may be gone.
|
|
369
475
|
* @returns the runner.
|
|
370
476
|
*/
|
|
371
|
-
function gitIn(ctx, config, session, directory, signal) {
|
|
372
|
-
const
|
|
477
|
+
function gitIn(ctx, config, session, directory, signal, root) {
|
|
478
|
+
const resolved = ctx.sandboxPolicy.resolve({ session });
|
|
479
|
+
const policy = root === void 0 ? resolved : {
|
|
480
|
+
...resolved,
|
|
481
|
+
workspaceRoot: root
|
|
482
|
+
};
|
|
373
483
|
return (name, args, allowedExitCodes = [0], configOverrides = {}) => runGit(ctx, config, policy, directory, name, args, signal, allowedExitCodes, configOverrides);
|
|
374
484
|
}
|
|
375
|
-
/**
|
|
485
|
+
/**
|
|
486
|
+
* Read the checked-out local branch, including an unborn one; null when HEAD is detached or names a ref outside
|
|
487
|
+
* `refs/heads/`. The full ref is read because the short form turns `main` into `heads/main` while a tag shares the name.
|
|
488
|
+
*/
|
|
376
489
|
async function currentBranch(git) {
|
|
377
490
|
const head = await git("symbolic-ref", [
|
|
378
491
|
"symbolic-ref",
|
|
379
492
|
"--quiet",
|
|
380
|
-
"--short",
|
|
381
493
|
"HEAD"
|
|
382
494
|
], [0, 1]);
|
|
383
|
-
|
|
495
|
+
const ref = head.exitCode === 0 ? parseName(head.stdout) : null;
|
|
496
|
+
return ref !== null && ref.startsWith("refs/heads/") ? ref.slice(11) : null;
|
|
384
497
|
}
|
|
385
498
|
/** Read the abbreviated commit HEAD names; null while the checked-out branch has no commit. */
|
|
386
499
|
async function headCommit(git) {
|
|
@@ -398,7 +511,7 @@ async function runGit(ctx, config, policy, cwd, name, args, signal, allowedExitC
|
|
|
398
511
|
hasError: false
|
|
399
512
|
};
|
|
400
513
|
try {
|
|
401
|
-
const timeout = __addDisposableResource$
|
|
514
|
+
const timeout = __addDisposableResource$2(env_1, deadline(signal, config.gitTimeoutMs, "FORGE_PANEL_GIT_TIMEOUT"), false);
|
|
402
515
|
const command = [
|
|
403
516
|
await ctx.subprocess.resolveExecutable(config.gitCommand, void 0, timeout.signal),
|
|
404
517
|
...GIT_PREFIX,
|
|
@@ -447,7 +560,7 @@ async function runGit(ctx, config, policy, cwd, name, args, signal, allowedExitC
|
|
|
447
560
|
env_1.error = e_1;
|
|
448
561
|
env_1.hasError = true;
|
|
449
562
|
} finally {
|
|
450
|
-
__disposeResources$
|
|
563
|
+
__disposeResources$2(env_1);
|
|
451
564
|
}
|
|
452
565
|
}
|
|
453
566
|
function firstLine(text) {
|
|
@@ -1069,11 +1182,14 @@ const BINARY_PROBE = 8e3;
|
|
|
1069
1182
|
* @returns the fork point, or null when no remote names a default branch or HEAD shares no history with it.
|
|
1070
1183
|
*/
|
|
1071
1184
|
async function forkPoint(git, inspection, created) {
|
|
1072
|
-
if (created !== null && created.path === inspection.checkout.root)
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1185
|
+
if (created !== null && created.path === inspection.checkout.root) {
|
|
1186
|
+
const label = created.from === null ? created.baseCommit.slice(0, 7) : branchLabel(created.from);
|
|
1187
|
+
return {
|
|
1188
|
+
commit: created.baseCommit,
|
|
1189
|
+
label,
|
|
1190
|
+
worktree: true
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1077
1193
|
for (const remote of remoteOrder(inspection.upstream, inspection.remotes)) {
|
|
1078
1194
|
const head = await git("remote-head", [
|
|
1079
1195
|
"symbolic-ref",
|
|
@@ -1263,6 +1379,47 @@ async function localText(ctx, config, session, root, scope, path, signal) {
|
|
|
1263
1379
|
return text;
|
|
1264
1380
|
}
|
|
1265
1381
|
/**
|
|
1382
|
+
* Read the old side of one changed file in a scope: the fork point for the `branch` scope, the first parent of the
|
|
1383
|
+
* first chosen commit for chosen commits, the index for `unstaged`, else HEAD.
|
|
1384
|
+
* @param ctx - context that provides `subprocess`, `sandbox`, and `sandboxPolicy`.
|
|
1385
|
+
* @param config - Git and size limits.
|
|
1386
|
+
* @param session - Session whose sandbox policy and execution world apply.
|
|
1387
|
+
* @param root - top-level directory of the checkout.
|
|
1388
|
+
* @param scope - the scope whose old side to read.
|
|
1389
|
+
* @param fork - the `branch` scope's fork point, or null for other scopes.
|
|
1390
|
+
* @param path - path relative to `root` on the old side, as the diff names it.
|
|
1391
|
+
* @param signal - cancellation.
|
|
1392
|
+
* @returns the text, or null when the old side has no such file or holds binary content.
|
|
1393
|
+
* @throws NoForkPoint for the `branch` scope without `fork`; CommitsMissing for a chosen commit that is not a full
|
|
1394
|
+
* object name; DiffTooLarge over `maxDiffBytes`; an Error for a path outside the checkout or a failed read.
|
|
1395
|
+
*/
|
|
1396
|
+
async function localOldText(ctx, config, session, root, scope, fork, path, signal) {
|
|
1397
|
+
if (!insideCheckout(path)) throw new Error(`forge-panel: ${JSON.stringify(path)} is not a path inside the checkout`);
|
|
1398
|
+
let revision;
|
|
1399
|
+
switch (scope.kind) {
|
|
1400
|
+
case "branch":
|
|
1401
|
+
if (fork === null) throw new NoForkPoint("The checkout has no fork point to compare its branch with");
|
|
1402
|
+
if (scope.commits !== null && !COMMIT.test(scope.commits.from)) throw new CommitsMissing("The chosen commit is not a full object name");
|
|
1403
|
+
revision = scope.commits === null ? fork.commit : `${scope.commits.from}^`;
|
|
1404
|
+
break;
|
|
1405
|
+
case "unstaged":
|
|
1406
|
+
revision = "";
|
|
1407
|
+
break;
|
|
1408
|
+
case "uncommitted":
|
|
1409
|
+
case "staged":
|
|
1410
|
+
revision = "HEAD";
|
|
1411
|
+
break;
|
|
1412
|
+
/* v8 ignore next -- closed ForgeLocalScope union exhaustiveness guard */
|
|
1413
|
+
default: return assertNever(scope, "ForgeLocalScope.kind");
|
|
1414
|
+
}
|
|
1415
|
+
const shown = await bounded(gitIn(ctx, {
|
|
1416
|
+
...config,
|
|
1417
|
+
maxOutputBytes: config.maxDiffBytes
|
|
1418
|
+
}, session, root, signal)("show", ["show", `${revision}:${path}`], [0, 128]));
|
|
1419
|
+
if (shown.exitCode !== 0 || shown.stdout.slice(0, BINARY_PROBE).includes("\0")) return null;
|
|
1420
|
+
return shown.stdout;
|
|
1421
|
+
}
|
|
1422
|
+
/**
|
|
1266
1423
|
* Measure the `branch` scope for the panel's card.
|
|
1267
1424
|
* @param ctx - context that provides `fs`, `subprocess`, `sandbox`, and `sandboxPolicy`.
|
|
1268
1425
|
* @param config - Git and size limits.
|
|
@@ -1479,6 +1636,345 @@ function insideCheckout(path) {
|
|
|
1479
1636
|
return path.split(/[/\\]/).every((segment) => segment !== "..");
|
|
1480
1637
|
}
|
|
1481
1638
|
//#endregion
|
|
1639
|
+
//#region lib/types/lenses.js
|
|
1640
|
+
/** Filter lenses registered on the forge panel host, the runs that classify one diff with one of them, and the kept results. */
|
|
1641
|
+
var __addDisposableResource$1 = function(env, value, async) {
|
|
1642
|
+
if (value !== null && value !== void 0) {
|
|
1643
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
1644
|
+
var dispose, inner;
|
|
1645
|
+
if (async) {
|
|
1646
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
1647
|
+
dispose = value[Symbol.asyncDispose];
|
|
1648
|
+
}
|
|
1649
|
+
if (dispose === void 0) {
|
|
1650
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
1651
|
+
dispose = value[Symbol.dispose];
|
|
1652
|
+
if (async) inner = dispose;
|
|
1653
|
+
}
|
|
1654
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
1655
|
+
if (inner) dispose = function() {
|
|
1656
|
+
try {
|
|
1657
|
+
inner.call(this);
|
|
1658
|
+
} catch (e) {
|
|
1659
|
+
return Promise.reject(e);
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
env.stack.push({
|
|
1663
|
+
value,
|
|
1664
|
+
dispose,
|
|
1665
|
+
async
|
|
1666
|
+
});
|
|
1667
|
+
} else if (async) env.stack.push({ async: true });
|
|
1668
|
+
return value;
|
|
1669
|
+
};
|
|
1670
|
+
var __disposeResources$1 = (function(SuppressedError) {
|
|
1671
|
+
return function(env) {
|
|
1672
|
+
function fail(e) {
|
|
1673
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
1674
|
+
env.hasError = true;
|
|
1675
|
+
}
|
|
1676
|
+
var r, s = 0;
|
|
1677
|
+
function next() {
|
|
1678
|
+
while (r = env.stack.pop()) try {
|
|
1679
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
1680
|
+
if (r.dispose) {
|
|
1681
|
+
var result = r.dispose.call(r.value);
|
|
1682
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
|
|
1683
|
+
fail(e);
|
|
1684
|
+
return next();
|
|
1685
|
+
});
|
|
1686
|
+
} else s |= 1;
|
|
1687
|
+
} catch (e) {
|
|
1688
|
+
fail(e);
|
|
1689
|
+
}
|
|
1690
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
1691
|
+
if (env.hasError) throw env.error;
|
|
1692
|
+
}
|
|
1693
|
+
return next();
|
|
1694
|
+
};
|
|
1695
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
1696
|
+
var e = new Error(message);
|
|
1697
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1698
|
+
});
|
|
1699
|
+
/** Why a lens run produced no result; the message names the cause for the reader. */
|
|
1700
|
+
var LensFailed = class extends Error {
|
|
1701
|
+
name = "LensFailed";
|
|
1702
|
+
};
|
|
1703
|
+
/** The reason a run stops when its lens's registration ends. */
|
|
1704
|
+
var LensWithdrawn = class extends Error {
|
|
1705
|
+
name = "LensWithdrawn";
|
|
1706
|
+
};
|
|
1707
|
+
/**
|
|
1708
|
+
* The lenses registered on one panel host. Identities are unique while registered; the follow streams of every reader
|
|
1709
|
+
* receive the list after each change, and end once the registry closes.
|
|
1710
|
+
*/
|
|
1711
|
+
var LensRegistry = class {
|
|
1712
|
+
entries = /* @__PURE__ */ new Map();
|
|
1713
|
+
listeners = /* @__PURE__ */ new Set();
|
|
1714
|
+
closed = new AbortController();
|
|
1715
|
+
/**
|
|
1716
|
+
* Register a lens.
|
|
1717
|
+
* @param lens - the lens.
|
|
1718
|
+
* @returns the disposer, which aborts the lens's running classifications and waits for them.
|
|
1719
|
+
* @throws when another registration holds `lens.id`.
|
|
1720
|
+
*/
|
|
1721
|
+
add(lens) {
|
|
1722
|
+
if (this.entries.has(lens.id)) throw new Error(`forge-panel: a lens "${lens.id}" is already registered`);
|
|
1723
|
+
const lifetime = new AbortController();
|
|
1724
|
+
const runs = /* @__PURE__ */ new Set();
|
|
1725
|
+
const registration = {
|
|
1726
|
+
lens,
|
|
1727
|
+
lifetime: lifetime.signal,
|
|
1728
|
+
track: (run) => {
|
|
1729
|
+
const settled = run.then(() => void 0, () => void 0);
|
|
1730
|
+
runs.add(settled);
|
|
1731
|
+
settled.then(() => runs.delete(settled));
|
|
1732
|
+
return run;
|
|
1733
|
+
}
|
|
1734
|
+
};
|
|
1735
|
+
this.entries.set(lens.id, registration);
|
|
1736
|
+
this.changed();
|
|
1737
|
+
return async () => {
|
|
1738
|
+
this.entries.delete(lens.id);
|
|
1739
|
+
lifetime.abort(new LensWithdrawn(`the lens "${lens.id}" was unregistered`));
|
|
1740
|
+
this.changed();
|
|
1741
|
+
await Promise.allSettled([...runs]);
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Find a registered lens.
|
|
1746
|
+
* @param id - its identity.
|
|
1747
|
+
* @returns the registration, or undefined while no lens holds the identity.
|
|
1748
|
+
*/
|
|
1749
|
+
get(id) {
|
|
1750
|
+
return this.entries.get(id);
|
|
1751
|
+
}
|
|
1752
|
+
/**
|
|
1753
|
+
* Stream the registered lenses: the current list first, then the list after each change; changes that arrive while
|
|
1754
|
+
* the reader is busy collapse into the next list.
|
|
1755
|
+
* @param signal - ends the stream.
|
|
1756
|
+
* @returns identities and versions in registration order.
|
|
1757
|
+
*/
|
|
1758
|
+
async *follow(signal) {
|
|
1759
|
+
const stop = AbortSignal.any([signal, this.closed.signal]);
|
|
1760
|
+
let wake = Promise.withResolvers();
|
|
1761
|
+
const listener = () => {
|
|
1762
|
+
wake.resolve();
|
|
1763
|
+
};
|
|
1764
|
+
this.listeners.add(listener);
|
|
1765
|
+
stop.addEventListener("abort", listener);
|
|
1766
|
+
try {
|
|
1767
|
+
while (!stop.aborted) {
|
|
1768
|
+
const current = wake;
|
|
1769
|
+
yield [...this.entries.values()].map(({ lens }) => ({
|
|
1770
|
+
id: lens.id,
|
|
1771
|
+
version: lens.version
|
|
1772
|
+
}));
|
|
1773
|
+
await current.promise;
|
|
1774
|
+
wake = Promise.withResolvers();
|
|
1775
|
+
}
|
|
1776
|
+
} finally {
|
|
1777
|
+
this.listeners.delete(listener);
|
|
1778
|
+
stop.removeEventListener("abort", listener);
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
/** End every follow stream; registrations still end through their own disposers. */
|
|
1782
|
+
close() {
|
|
1783
|
+
this.closed.abort();
|
|
1784
|
+
}
|
|
1785
|
+
changed() {
|
|
1786
|
+
for (const listener of this.listeners) listener();
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
/**
|
|
1790
|
+
* Classify one diff with one lens. The lens's signal aborts with the caller's, when the registration ends, and after
|
|
1791
|
+
* `timeoutMs`; the run settles then even when the lens ignores its signal, while the registration's disposer waits until
|
|
1792
|
+
* `classify` itself settles. A run whose signal aborted before it started does not call the lens. Paths the lens names
|
|
1793
|
+
* outside the diff are left out of the result.
|
|
1794
|
+
* @param registration - the registered lens.
|
|
1795
|
+
* @param subject - the diff and its reader.
|
|
1796
|
+
* @param limits - deadline, read budget, and result bound.
|
|
1797
|
+
* @param signal - the caller's cancellation.
|
|
1798
|
+
* @param progress - receives the lens's progress while it runs.
|
|
1799
|
+
* @returns the files the lens kept.
|
|
1800
|
+
* @throws `signal.reason` once the caller aborts; a {@link LensWithdrawn} once the registration ends; a
|
|
1801
|
+
* {@link LensFailed} when the lens rejects, runs past the deadline, reads past the budget, or answers over the bound.
|
|
1802
|
+
*/
|
|
1803
|
+
async function runLens(registration, subject, limits, signal, progress) {
|
|
1804
|
+
const env_1 = {
|
|
1805
|
+
stack: [],
|
|
1806
|
+
error: void 0,
|
|
1807
|
+
hasError: false
|
|
1808
|
+
};
|
|
1809
|
+
try {
|
|
1810
|
+
const operation = __addDisposableResource$1(env_1, deadline(AbortSignal.any([signal, registration.lifetime]), limits.timeoutMs, "FORGE_LENS_TIMEOUT"), false).signal;
|
|
1811
|
+
const byPath = new Map(subject.files.map((file) => [file.path, file]));
|
|
1812
|
+
let read = 0;
|
|
1813
|
+
const overBudget = () => new LensFailed(`the lens read more than maxLensReadBytes (${limits.maxReadBytes} bytes) of file text`);
|
|
1814
|
+
const input = {
|
|
1815
|
+
source: subject.source,
|
|
1816
|
+
files: subject.files,
|
|
1817
|
+
text: async (side, path, inner) => {
|
|
1818
|
+
const file = byPath.get(path);
|
|
1819
|
+
if (file === void 0) throw new Error(`forge-panel: ${JSON.stringify(path)} is not a file of this diff`);
|
|
1820
|
+
if (read > limits.maxReadBytes) throw overBudget();
|
|
1821
|
+
const text = await subject.read(side, file, AbortSignal.any([inner, operation]));
|
|
1822
|
+
if (text === null) return null;
|
|
1823
|
+
read += Buffer.byteLength(text);
|
|
1824
|
+
if (read > limits.maxReadBytes) throw overBudget();
|
|
1825
|
+
return text;
|
|
1826
|
+
},
|
|
1827
|
+
progress: (done, total) => {
|
|
1828
|
+
if (!operation.aborted) progress(done, total);
|
|
1829
|
+
}
|
|
1830
|
+
};
|
|
1831
|
+
let result;
|
|
1832
|
+
try {
|
|
1833
|
+
operation.throwIfAborted();
|
|
1834
|
+
const stopped = new Promise((_resolve, reject) => {
|
|
1835
|
+
operation.addEventListener("abort", () => {
|
|
1836
|
+
reject(new Error("the lens run stopped", { cause: operation.reason }));
|
|
1837
|
+
}, { once: true });
|
|
1838
|
+
});
|
|
1839
|
+
stopped.catch(() => void 0);
|
|
1840
|
+
const classified = registration.track(Promise.resolve().then(() => registration.lens.classify(input, operation)));
|
|
1841
|
+
result = await Promise.race([classified, stopped]);
|
|
1842
|
+
} catch (error) {
|
|
1843
|
+
if (signal.aborted) throw signal.reason;
|
|
1844
|
+
if (registration.lifetime.aborted) throw registration.lifetime.reason;
|
|
1845
|
+
if (timeoutOf(operation) !== void 0) throw new LensFailed(`the lens ran past lensTimeoutMs (${limits.timeoutMs} ms)`);
|
|
1846
|
+
if (error instanceof LensFailed) throw error;
|
|
1847
|
+
throw new LensFailed(`the lens failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1848
|
+
}
|
|
1849
|
+
if (read > limits.maxReadBytes) throw overBudget();
|
|
1850
|
+
const files = {};
|
|
1851
|
+
for (const [path, keep] of Object.entries(result.files)) if (byPath.has(path)) files[path] = keep;
|
|
1852
|
+
if (Buffer.byteLength(JSON.stringify(files)) > limits.maxResultBytes) throw new LensFailed(`the lens result exceeds maxCachedLensBytes (${limits.maxResultBytes} bytes)`);
|
|
1853
|
+
return files;
|
|
1854
|
+
} catch (e_1) {
|
|
1855
|
+
env_1.error = e_1;
|
|
1856
|
+
env_1.hasError = true;
|
|
1857
|
+
} finally {
|
|
1858
|
+
__disposeResources$1(env_1);
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* Turn one run into frames: the latest progress whenever the lens reported some since the last frame, then the result.
|
|
1863
|
+
* @param run - starts the run with the progress receiver.
|
|
1864
|
+
* @returns progress frames, then one result frame.
|
|
1865
|
+
* @throws the run's failure after its last progress frame.
|
|
1866
|
+
*/
|
|
1867
|
+
async function* lensFrames(run) {
|
|
1868
|
+
const reports = {
|
|
1869
|
+
latest: null,
|
|
1870
|
+
finished: false
|
|
1871
|
+
};
|
|
1872
|
+
const finished = () => reports.finished;
|
|
1873
|
+
let wake = Promise.withResolvers();
|
|
1874
|
+
const outcome = run((done, total) => {
|
|
1875
|
+
reports.latest = {
|
|
1876
|
+
done,
|
|
1877
|
+
total
|
|
1878
|
+
};
|
|
1879
|
+
wake.resolve();
|
|
1880
|
+
});
|
|
1881
|
+
const settled = outcome.then(() => {
|
|
1882
|
+
reports.finished = true;
|
|
1883
|
+
}, () => {
|
|
1884
|
+
reports.finished = true;
|
|
1885
|
+
});
|
|
1886
|
+
while (!finished()) {
|
|
1887
|
+
const current = wake;
|
|
1888
|
+
await Promise.race([current.promise, settled]);
|
|
1889
|
+
wake = Promise.withResolvers();
|
|
1890
|
+
const reported = reports.latest;
|
|
1891
|
+
reports.latest = null;
|
|
1892
|
+
if (reported !== null && !finished()) yield {
|
|
1893
|
+
kind: "progress",
|
|
1894
|
+
done: reported.done,
|
|
1895
|
+
total: reported.total
|
|
1896
|
+
};
|
|
1897
|
+
}
|
|
1898
|
+
yield {
|
|
1899
|
+
kind: "result",
|
|
1900
|
+
files: await outcome
|
|
1901
|
+
};
|
|
1902
|
+
}
|
|
1903
|
+
/** Lens results kept for later requests, at most `maxBytes` of them as JSON, the least recently used dropped first. */
|
|
1904
|
+
var LensCache = class {
|
|
1905
|
+
maxBytes;
|
|
1906
|
+
entries = /* @__PURE__ */ new Map();
|
|
1907
|
+
bytes = 0;
|
|
1908
|
+
/** @param maxBytes - `maxCachedLensBytes`. */
|
|
1909
|
+
constructor(maxBytes) {
|
|
1910
|
+
this.maxBytes = maxBytes;
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* Read a kept result, which becomes the most recently used.
|
|
1914
|
+
* @param key - the request's files, lens, and lens version.
|
|
1915
|
+
* @returns the result, or undefined when none is kept.
|
|
1916
|
+
*/
|
|
1917
|
+
get(key) {
|
|
1918
|
+
const entry = this.entries.get(key);
|
|
1919
|
+
if (entry === void 0) return void 0;
|
|
1920
|
+
this.entries.delete(key);
|
|
1921
|
+
this.entries.set(key, entry);
|
|
1922
|
+
return entry.files;
|
|
1923
|
+
}
|
|
1924
|
+
/**
|
|
1925
|
+
* Keep a result no larger than `maxBytes`, replacing one under the same key and dropping the least recently used
|
|
1926
|
+
* results until the rest fit.
|
|
1927
|
+
* @param key - the request's files, lens, and lens version.
|
|
1928
|
+
* @param files - the result.
|
|
1929
|
+
*/
|
|
1930
|
+
set(key, files) {
|
|
1931
|
+
const previous = this.entries.get(key);
|
|
1932
|
+
if (previous !== void 0) {
|
|
1933
|
+
this.entries.delete(key);
|
|
1934
|
+
this.bytes -= previous.bytes;
|
|
1935
|
+
}
|
|
1936
|
+
const bytes = Buffer.byteLength(JSON.stringify(files));
|
|
1937
|
+
this.entries.set(key, {
|
|
1938
|
+
files,
|
|
1939
|
+
bytes
|
|
1940
|
+
});
|
|
1941
|
+
this.bytes += bytes;
|
|
1942
|
+
for (const [oldest, entry] of this.entries) {
|
|
1943
|
+
if (this.bytes <= this.maxBytes) break;
|
|
1944
|
+
this.entries.delete(oldest);
|
|
1945
|
+
this.bytes -= entry.bytes;
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
};
|
|
1949
|
+
//#endregion
|
|
1950
|
+
//#region lib/types/lens-version.js
|
|
1951
|
+
/**
|
|
1952
|
+
* The version of a diff's files that a lens request names. The panel host and the changes view compute it alike, so a
|
|
1953
|
+
* request refers to exactly the files its view shows.
|
|
1954
|
+
*/
|
|
1955
|
+
/**
|
|
1956
|
+
* Name the files of one diff: equal versions describe the same paths with the same changes in the same order.
|
|
1957
|
+
* @param files - the diff's files in display order.
|
|
1958
|
+
* @returns 14 hexadecimal digits of a 53-bit hash over each path and change digest.
|
|
1959
|
+
*/
|
|
1960
|
+
function lensVersion(files) {
|
|
1961
|
+
let h1 = 3735928559;
|
|
1962
|
+
let h2 = 1103547991;
|
|
1963
|
+
for (const file of files) for (const text of [
|
|
1964
|
+
file.path,
|
|
1965
|
+
"\0",
|
|
1966
|
+
file.digest,
|
|
1967
|
+
""
|
|
1968
|
+
]) for (let index = 0; index < text.length; index += 1) {
|
|
1969
|
+
const code = text.charCodeAt(index);
|
|
1970
|
+
h1 = Math.imul(h1 ^ code, 2654435761);
|
|
1971
|
+
h2 = Math.imul(h2 ^ code, 1597334677);
|
|
1972
|
+
}
|
|
1973
|
+
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
1974
|
+
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
1975
|
+
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(16).padStart(14, "0");
|
|
1976
|
+
}
|
|
1977
|
+
//#endregion
|
|
1482
1978
|
//#region lib/types/worktree.js
|
|
1483
1979
|
/** The worktree a Session requests before it starts: its record, its projection, and its creation. */
|
|
1484
1980
|
/** Plugin record type of worktree requests, withdrawals, and creations. */
|
|
@@ -1500,7 +1996,8 @@ const worktreeSchema = z$1.object({
|
|
|
1500
1996
|
const recordSchema = z$1.discriminatedUnion("action", [
|
|
1501
1997
|
z$1.object({
|
|
1502
1998
|
action: z$1.literal("request"),
|
|
1503
|
-
from: z$1.string().min(1).nullable()
|
|
1999
|
+
from: z$1.string().min(1).nullable(),
|
|
2000
|
+
name: z$1.string().min(1).exactOptional()
|
|
1504
2001
|
}).strict(),
|
|
1505
2002
|
z$1.object({ action: z$1.literal("cancel") }).strict(),
|
|
1506
2003
|
z$1.object({
|
|
@@ -1523,9 +2020,12 @@ const recordSchema = z$1.discriminatedUnion("action", [
|
|
|
1523
2020
|
*/
|
|
1524
2021
|
const forgeWorktreeProjection = {
|
|
1525
2022
|
key: "forgeWorktree",
|
|
1526
|
-
stateVersion:
|
|
2023
|
+
stateVersion: 8,
|
|
1527
2024
|
stateSchema: z$1.object({
|
|
1528
|
-
request: z$1.object({
|
|
2025
|
+
request: z$1.object({
|
|
2026
|
+
from: z$1.string().min(1).nullable(),
|
|
2027
|
+
name: z$1.string().min(1).nullable()
|
|
2028
|
+
}).strict().nullable(),
|
|
1529
2029
|
created: worktreeSchema.nullable(),
|
|
1530
2030
|
locked: z$1.boolean(),
|
|
1531
2031
|
stepped: z$1.boolean(),
|
|
@@ -1570,7 +2070,7 @@ function apply(state, event) {
|
|
|
1570
2070
|
...state,
|
|
1571
2071
|
stepped: true
|
|
1572
2072
|
};
|
|
1573
|
-
case "
|
|
2073
|
+
case "workspace-root/change": return state.cwd === event.data.cwd ? state : {
|
|
1574
2074
|
...state,
|
|
1575
2075
|
cwd: event.data.cwd
|
|
1576
2076
|
};
|
|
@@ -1597,7 +2097,10 @@ function applyRecord(state, event) {
|
|
|
1597
2097
|
switch (data.action) {
|
|
1598
2098
|
case "request": return state.locked || settled ? state : {
|
|
1599
2099
|
...state,
|
|
1600
|
-
request: {
|
|
2100
|
+
request: {
|
|
2101
|
+
from: data.from,
|
|
2102
|
+
name: data.name ?? null
|
|
2103
|
+
}
|
|
1601
2104
|
};
|
|
1602
2105
|
case "cancel": return state.locked || settled || state.request === null ? state : {
|
|
1603
2106
|
...state,
|
|
@@ -1624,6 +2127,8 @@ var CreationFailure = class extends Error {
|
|
|
1624
2127
|
branch;
|
|
1625
2128
|
phase;
|
|
1626
2129
|
reason;
|
|
2130
|
+
/** Whether the branch or the checkout directory of that name already existed. */
|
|
2131
|
+
exists;
|
|
1627
2132
|
/**
|
|
1628
2133
|
* @param branch - branch the attempt created.
|
|
1629
2134
|
* @param phase - step that failed.
|
|
@@ -1636,30 +2141,38 @@ var CreationFailure = class extends Error {
|
|
|
1636
2141
|
this.phase = phase;
|
|
1637
2142
|
this.reason = reason;
|
|
1638
2143
|
this.name = "CreationFailure";
|
|
2144
|
+
this.exists = cause instanceof Error && cause.name === "WorktreeError" && "code" in cause && cause.code === "WORKTREE_ALREADY_EXISTS";
|
|
1639
2145
|
}
|
|
1640
2146
|
};
|
|
1641
2147
|
/**
|
|
1642
2148
|
* The failure a waiting message shows for an attempt.
|
|
1643
2149
|
* @param error - what the attempt threw.
|
|
1644
|
-
* @param from - base
|
|
2150
|
+
* @param from - base of the attempt, or null for HEAD.
|
|
2151
|
+
* @param fetch - whether the attempt fetched its remote base branch first.
|
|
1645
2152
|
* @returns the failure.
|
|
1646
2153
|
*/
|
|
1647
|
-
function failureOf(error, from) {
|
|
2154
|
+
function failureOf(error, from, fetch) {
|
|
1648
2155
|
return error instanceof CreationFailure ? {
|
|
1649
2156
|
branch: error.branch,
|
|
1650
2157
|
from,
|
|
2158
|
+
fetch,
|
|
1651
2159
|
phase: error.phase,
|
|
1652
|
-
message: error.reason
|
|
2160
|
+
message: error.reason,
|
|
2161
|
+
exists: error.exists
|
|
1653
2162
|
} : {
|
|
1654
2163
|
branch: null,
|
|
1655
2164
|
from,
|
|
1656
|
-
|
|
1657
|
-
|
|
2165
|
+
fetch,
|
|
2166
|
+
phase: fetch ? "fetch" : "prepare",
|
|
2167
|
+
message: messageOf(error),
|
|
2168
|
+
exists: false
|
|
1658
2169
|
};
|
|
1659
2170
|
}
|
|
1660
2171
|
/**
|
|
1661
|
-
* Creates requested worktrees, one attempt
|
|
1662
|
-
*
|
|
2172
|
+
* Creates requested worktrees, one attempt per call on the requested branch
|
|
2173
|
+
* name or on a new generated one, fetching a remote-tracking base branch
|
|
2174
|
+
* first unless the attempt skips it, and holds the turn of a message while
|
|
2175
|
+
* the Session's worktree is not ready.
|
|
1663
2176
|
* A hold is maintenance of the Session's Agent that starts while the message
|
|
1664
2177
|
* enters the inbox, before the delivery wakes the Agent, so the Agent starts
|
|
1665
2178
|
* the message's turn once the hold ends. A creation hold makes an attempt
|
|
@@ -1780,21 +2293,29 @@ var WorktreeCreations = class {
|
|
|
1780
2293
|
/**
|
|
1781
2294
|
* Make another attempt for the message that waits after a failed or stopped one.
|
|
1782
2295
|
* @param session - Session whose message waits.
|
|
2296
|
+
* @param fetch - false skips fetching a remote-tracking base branch for this attempt, which then starts from the
|
|
2297
|
+
* commit last fetched.
|
|
1783
2298
|
* @returns whether a waiting message without a running attempt took the decision.
|
|
1784
2299
|
*/
|
|
1785
|
-
retry(session) {
|
|
2300
|
+
retry(session, fetch) {
|
|
1786
2301
|
const hold = this.holds.get(session);
|
|
1787
2302
|
if (hold?.kind !== "creation" || hold.next === void 0) return false;
|
|
1788
|
-
hold.next.resolve(
|
|
2303
|
+
hold.next.resolve({
|
|
2304
|
+
kind: "retry",
|
|
2305
|
+
fetch
|
|
2306
|
+
});
|
|
1789
2307
|
return true;
|
|
1790
2308
|
}
|
|
1791
2309
|
/**
|
|
1792
|
-
* Read the request again after it changed
|
|
2310
|
+
* Read the request again after it changed: a request that no longer asks for a worktree lets the waiting message
|
|
2311
|
+
* go on, and a request that still does keeps it waiting for another attempt.
|
|
1793
2312
|
* @param session - Session whose request changed.
|
|
1794
2313
|
*/
|
|
1795
2314
|
recheck(session) {
|
|
1796
2315
|
const hold = this.holds.get(session);
|
|
1797
|
-
if (hold?.kind
|
|
2316
|
+
if (hold?.kind !== "creation") return;
|
|
2317
|
+
const state = this.states.stateOf(session);
|
|
2318
|
+
if (state.request === null || state.created !== null || state.locked) hold.next?.resolve({ kind: "recheck" });
|
|
1798
2319
|
}
|
|
1799
2320
|
/**
|
|
1800
2321
|
* Run work on the removed worktree a message waits for, inside the wait; its success lets the message go on.
|
|
@@ -1857,27 +2378,30 @@ var WorktreeCreations = class {
|
|
|
1857
2378
|
}
|
|
1858
2379
|
}
|
|
1859
2380
|
/**
|
|
1860
|
-
* Create a Session's requested worktree
|
|
1861
|
-
* record it on the Session. The running
|
|
1862
|
-
* {@link WorktreeCreations.of} until the record
|
|
2381
|
+
* Create a Session's requested worktree on the requested branch name, or on a
|
|
2382
|
+
* new generated one, enter it, and record it on the Session. The running
|
|
2383
|
+
* creation is readable through {@link WorktreeCreations.of} until the record
|
|
2384
|
+
* exists or the attempt fails.
|
|
1863
2385
|
* @param agent - Agent of the Session.
|
|
1864
|
-
* @param
|
|
2386
|
+
* @param request - base, or null for HEAD of the current checkout, and branch name, or null to generate one.
|
|
1865
2387
|
* @param signal - cancellation of the attempt.
|
|
1866
2388
|
* @param held - whether a message waits for the creation before its turn starts.
|
|
2389
|
+
* @param fetch - whether the attempt fetches its base first; true only for a remote-tracking base branch.
|
|
1867
2390
|
* @returns the created worktree.
|
|
1868
2391
|
* @throws {@link CreationFailure} when the attempt fails; the cancellation reason once `signal` aborts.
|
|
1869
2392
|
*/
|
|
1870
|
-
async create(agent,
|
|
1871
|
-
return await this.run(signal, (operation) => this.createCheckout(agent,
|
|
2393
|
+
async create(agent, request, signal, held, fetch) {
|
|
2394
|
+
return await this.run(signal, (operation) => this.createCheckout(agent, request, operation, held, fetch));
|
|
1872
2395
|
}
|
|
1873
|
-
async createCheckout(agent, from, signal, held) {
|
|
2396
|
+
async createCheckout(agent, { from, name }, signal, held, fetch) {
|
|
1874
2397
|
const worktrees = this.ctx.get("worktrees");
|
|
1875
2398
|
if (worktrees === void 0) throw new Error("No worktree service is mounted");
|
|
1876
2399
|
const session = agent.session;
|
|
1877
2400
|
let status = {
|
|
1878
|
-
phase: "prepare",
|
|
1879
|
-
branch: generatedWorktreeName(this.prefix, session.id),
|
|
2401
|
+
phase: fetch ? "fetch" : "prepare",
|
|
2402
|
+
branch: name ?? generatedWorktreeName(this.prefix, session.id),
|
|
1880
2403
|
from,
|
|
2404
|
+
fetch,
|
|
1881
2405
|
held
|
|
1882
2406
|
};
|
|
1883
2407
|
this.failures.delete(session);
|
|
@@ -1886,10 +2410,12 @@ var WorktreeCreations = class {
|
|
|
1886
2410
|
try {
|
|
1887
2411
|
let created;
|
|
1888
2412
|
try {
|
|
1889
|
-
|
|
2413
|
+
const request = {
|
|
1890
2414
|
name: status.branch,
|
|
1891
|
-
...from === null ? {} : { from }
|
|
1892
|
-
|
|
2415
|
+
...from === null ? {} : { from },
|
|
2416
|
+
...fetch ? { fetch } : {}
|
|
2417
|
+
};
|
|
2418
|
+
created = await worktrees.create(agent, request, signal, (phase) => {
|
|
1893
2419
|
status = {
|
|
1894
2420
|
...status,
|
|
1895
2421
|
phase
|
|
@@ -1955,26 +2481,27 @@ var WorktreeCreations = class {
|
|
|
1955
2481
|
*/
|
|
1956
2482
|
async runCreation(agent, hold, signal) {
|
|
1957
2483
|
const session = agent.session;
|
|
2484
|
+
let skipFetch = false;
|
|
1958
2485
|
for (;;) {
|
|
1959
2486
|
const state = this.states.stateOf(session);
|
|
1960
2487
|
if (state.request === null || state.created !== null || state.locked) return;
|
|
1961
2488
|
const stop = new AbortController();
|
|
1962
2489
|
hold.stop = stop;
|
|
2490
|
+
const fetch = !skipFetch && isRemoteRef(state.request.from);
|
|
1963
2491
|
try {
|
|
1964
|
-
await this.create(agent, state.request
|
|
2492
|
+
await this.create(agent, state.request, AbortSignal.any([signal, stop.signal]), true, fetch);
|
|
1965
2493
|
return;
|
|
1966
2494
|
} catch (error) {
|
|
1967
2495
|
signal.throwIfAborted();
|
|
1968
2496
|
if (stop.signal.aborted) this.failures.delete(session);
|
|
1969
|
-
else this.failures.set(session, failureOf(error, state.request.from));
|
|
2497
|
+
else this.failures.set(session, failureOf(error, state.request.from, fetch));
|
|
1970
2498
|
this.changed(session);
|
|
1971
2499
|
} finally {
|
|
1972
2500
|
hold.stop = void 0;
|
|
1973
2501
|
}
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
}
|
|
2502
|
+
const decision = await this.wait(hold, signal);
|
|
2503
|
+
if (decision.kind === "recheck") return;
|
|
2504
|
+
skipFetch = !decision.fetch;
|
|
1978
2505
|
}
|
|
1979
2506
|
}
|
|
1980
2507
|
/** Check the worktree the Session works in and, when it is gone, run the work that restores or leaves it until one succeeds. */
|
|
@@ -2021,7 +2548,7 @@ var WorktreeCreations = class {
|
|
|
2021
2548
|
async preStep(agent, step, signal, next) {
|
|
2022
2549
|
const state = this.states.stateOf(agent.session);
|
|
2023
2550
|
if (step !== 1 || state.request === null || state.created !== null || state.stepped) return await next();
|
|
2024
|
-
await this.create(agent, state.request
|
|
2551
|
+
await this.create(agent, state.request, signal, false, isRemoteRef(state.request.from));
|
|
2025
2552
|
const decision = await next();
|
|
2026
2553
|
if (decision.kind === "reject" || decision.messages.length === 0) return decision;
|
|
2027
2554
|
const notices = agent.inbox.nextStep.filter((message) => message.source.kind === "working-directory");
|
|
@@ -2095,15 +2622,22 @@ var __disposeResources = (function(SuppressedError) {
|
|
|
2095
2622
|
});
|
|
2096
2623
|
/**
|
|
2097
2624
|
* Panel state of one Session. Construction starts the first checkout
|
|
2098
|
-
* inspection and watches the Session's change requests.
|
|
2625
|
+
* inspection and watches the Session's change requests. A panel given what the
|
|
2626
|
+
* previous panel of the Session kept publishes that state first, with the
|
|
2627
|
+
* current bindings and worktree facts, unless the Session has moved to another
|
|
2628
|
+
* directory. Inspections run one at
|
|
2099
2629
|
* a time; a request that arrives during one runs once more after it, and a
|
|
2100
2630
|
* result for a directory the Session has since left is dropped. A sign-in
|
|
2101
|
-
* probe runs when an inspection recognizes a new code host
|
|
2631
|
+
* probe runs when an inspection recognizes a new code host, after the first
|
|
2632
|
+
* inspection of a panel whose kept probe did not find the host ready, on
|
|
2633
|
+
* `refresh`, on `revisit` while the host is not ready, and once when status
|
|
2634
|
+
* reads on a host shown as ready start to be refused as unauthenticated;
|
|
2102
2635
|
* a probe result for a host the panel no longer shows is dropped. Each change
|
|
2103
2636
|
* request keeps the latest snapshot a poll returned while later polls fail.
|
|
2104
2637
|
* When an inspection finds an upstream branch on a remote a provider
|
|
2105
2638
|
* recognizes, the open change requests of that branch are bound as discovered,
|
|
2106
|
-
* once per remote and branch until a refresh
|
|
2639
|
+
* once per remote and branch until a refresh, or until a panel starts or is
|
|
2640
|
+
* revisited while the Session shows no change request. The
|
|
2107
2641
|
* worktree facts follow the `forgeWorktree` projection, the live creation, and the last failed one;
|
|
2108
2642
|
* each inspection also decides whether the Session's sandbox can write the
|
|
2109
2643
|
* checkout and its shared Git directory, which a new worktree needs, whether
|
|
@@ -2116,6 +2650,7 @@ var SessionPanel = class {
|
|
|
2116
2650
|
session;
|
|
2117
2651
|
worktreeStates;
|
|
2118
2652
|
creations;
|
|
2653
|
+
reviewRevision;
|
|
2119
2654
|
onIdle;
|
|
2120
2655
|
current;
|
|
2121
2656
|
followers = /* @__PURE__ */ new Set();
|
|
@@ -2127,42 +2662,77 @@ var SessionPanel = class {
|
|
|
2127
2662
|
missing = null;
|
|
2128
2663
|
inspection = null;
|
|
2129
2664
|
rerun = null;
|
|
2130
|
-
/** Remote URL and branch of the upstream that the last branch lookup covered, until
|
|
2665
|
+
/** Remote URL and branch of the upstream that the last branch lookup covered, until the next lookup is due. */
|
|
2131
2666
|
discovered = null;
|
|
2667
|
+
/** Whether the readiness the panel started with must be probed again after its first inspection. */
|
|
2668
|
+
unconfirmed = false;
|
|
2669
|
+
/** Whether a refused status read already started a sign-in probe, until no status read on the host is refused. */
|
|
2670
|
+
questioned = false;
|
|
2132
2671
|
/**
|
|
2133
2672
|
* @param ctx - service context that provides the forge, Session, directory, and process services.
|
|
2134
|
-
* @param config - Git limits
|
|
2673
|
+
* @param config - Git limits, the sign-in probe deadline, and the worktree branch name prefix.
|
|
2135
2674
|
* @param session - Session the panel describes.
|
|
2136
2675
|
* @param worktreeStates - reads the `forgeWorktree` projection of the Session.
|
|
2137
2676
|
* @param creations - reads the running creation and restoration, the last failed creation, and what a message of the
|
|
2138
2677
|
* Session waits for.
|
|
2678
|
+
* @param reviewRevision - reads how many review changes were announced for a change request.
|
|
2679
|
+
* @param kept - what the previous panel of the Session kept, when there was one.
|
|
2139
2680
|
* @param onIdle - called when the last follower leaves.
|
|
2140
2681
|
*/
|
|
2141
|
-
constructor(ctx, config, session, worktreeStates, creations, onIdle) {
|
|
2682
|
+
constructor(ctx, config, session, worktreeStates, creations, reviewRevision, kept, onIdle) {
|
|
2142
2683
|
this.ctx = ctx;
|
|
2143
2684
|
this.config = config;
|
|
2144
2685
|
this.session = session;
|
|
2145
2686
|
this.worktreeStates = worktreeStates;
|
|
2146
2687
|
this.creations = creations;
|
|
2688
|
+
this.reviewRevision = reviewRevision;
|
|
2147
2689
|
this.onIdle = onIdle;
|
|
2148
|
-
|
|
2149
|
-
|
|
2690
|
+
const directory = ctx.workingDirectory.get(session);
|
|
2691
|
+
const start = kept?.state.directory === directory ? kept : void 0;
|
|
2692
|
+
if (start !== void 0) {
|
|
2693
|
+
for (const [url, snapshot] of start.snapshots) this.snapshots.set(url, snapshot);
|
|
2694
|
+
this.blocker = start.blocker;
|
|
2695
|
+
this.missing = start.missing;
|
|
2696
|
+
this.unconfirmed = start.state.readiness?.state !== "ready";
|
|
2697
|
+
}
|
|
2698
|
+
const changeRequests = this.entries(ctx.forgeSession.changeRequests(session));
|
|
2699
|
+
if (start !== void 0 && changeRequests.length > 0) this.discovered = start.discovered;
|
|
2700
|
+
this.current = start === void 0 ? {
|
|
2701
|
+
directory,
|
|
2150
2702
|
checkout: { state: "pending" },
|
|
2151
2703
|
repository: null,
|
|
2152
2704
|
readiness: null,
|
|
2153
|
-
changeRequests
|
|
2705
|
+
changeRequests,
|
|
2154
2706
|
worktree: this.worktree(),
|
|
2155
2707
|
local: null
|
|
2708
|
+
} : {
|
|
2709
|
+
...start.state,
|
|
2710
|
+
changeRequests,
|
|
2711
|
+
worktree: this.worktree()
|
|
2156
2712
|
};
|
|
2157
|
-
this.stopWatching = ctx.forgeSession.watch(session, (
|
|
2713
|
+
this.stopWatching = ctx.forgeSession.watch(session, (latest) => {
|
|
2158
2714
|
this.publish({
|
|
2159
2715
|
...this.current,
|
|
2160
|
-
changeRequests: this.entries(
|
|
2716
|
+
changeRequests: this.entries(latest)
|
|
2161
2717
|
});
|
|
2162
|
-
|
|
2718
|
+
this.confirmSignIn(latest);
|
|
2719
|
+
}, { maxAgeMs: config.statusMaxAgeMs });
|
|
2163
2720
|
this.inspect();
|
|
2164
2721
|
}
|
|
2165
2722
|
/**
|
|
2723
|
+
* Name what the next panel of the Session starts from.
|
|
2724
|
+
* @returns the last published state and what the inspections and status polls found.
|
|
2725
|
+
*/
|
|
2726
|
+
keep() {
|
|
2727
|
+
return {
|
|
2728
|
+
state: this.current,
|
|
2729
|
+
snapshots: this.snapshots,
|
|
2730
|
+
blocker: this.blocker,
|
|
2731
|
+
missing: this.missing,
|
|
2732
|
+
discovered: this.discovered
|
|
2733
|
+
};
|
|
2734
|
+
}
|
|
2735
|
+
/**
|
|
2166
2736
|
* Yield the current state, then each later state, until `signal` aborts or the panel stops.
|
|
2167
2737
|
* @param signal - ends this follower.
|
|
2168
2738
|
* @returns the states in publication order; intermediate states may be skipped.
|
|
@@ -2204,7 +2774,7 @@ var SessionPanel = class {
|
|
|
2204
2774
|
* @param event - committed Session event.
|
|
2205
2775
|
*/
|
|
2206
2776
|
observe(event) {
|
|
2207
|
-
if (event.type === "
|
|
2777
|
+
if (event.type === "workspace-root/change") {
|
|
2208
2778
|
this.publish({
|
|
2209
2779
|
...this.current,
|
|
2210
2780
|
directory: event.data.cwd,
|
|
@@ -2259,20 +2829,45 @@ var SessionPanel = class {
|
|
|
2259
2829
|
await Promise.all([inspection, probe]);
|
|
2260
2830
|
}
|
|
2261
2831
|
/**
|
|
2262
|
-
*
|
|
2263
|
-
*
|
|
2832
|
+
* Bring the panel up to date after its surface showed again: reinspect the checkout, poll each bound change request
|
|
2833
|
+
* whose latest poll is older than `statusMaxAgeMs`, probe sign-in again unless the last probe found the host ready,
|
|
2834
|
+
* and let the inspection look the upstream branch up again while the Session shows no change request.
|
|
2835
|
+
* @returns settles once the inspection and the sign-in probe have ended; each poll publishes its result when it finishes.
|
|
2264
2836
|
*/
|
|
2265
|
-
async
|
|
2266
|
-
this.
|
|
2837
|
+
async revisit() {
|
|
2838
|
+
if (this.current.changeRequests.length === 0) this.discovered = null;
|
|
2839
|
+
const inspection = this.inspect();
|
|
2840
|
+
const { repository, readiness } = this.current;
|
|
2841
|
+
const probe = repository !== null && readiness !== null && readiness.state !== "ready" ? this.probe(repository) : void 0;
|
|
2842
|
+
for (const entry of this.current.changeRequests) if (entry.ref !== null) this.ctx.forge.refresh(entry.ref, { maxAgeMs: this.config.statusMaxAgeMs });
|
|
2843
|
+
await Promise.all([inspection, probe]);
|
|
2844
|
+
}
|
|
2845
|
+
/** Publish the review revisions of the bound change requests after a review change was announced. */
|
|
2846
|
+
reviewChanged() {
|
|
2847
|
+
this.publish({
|
|
2848
|
+
...this.current,
|
|
2849
|
+
changeRequests: this.entries(this.ctx.forgeSession.changeRequests(this.session))
|
|
2850
|
+
});
|
|
2851
|
+
}
|
|
2852
|
+
/**
|
|
2853
|
+
* Stop inspections, probes, and the change request watch, end every follower, and wait for pending work.
|
|
2854
|
+
* @returns settles once pending inspections and probes have ended.
|
|
2855
|
+
*/
|
|
2856
|
+
async dispose() {
|
|
2857
|
+
this.lifetime.abort();
|
|
2267
2858
|
this.stopWatching();
|
|
2268
2859
|
await Promise.allSettled(this.tasks);
|
|
2269
2860
|
}
|
|
2270
2861
|
entries(changeRequests) {
|
|
2271
2862
|
return changeRequests.map((entry) => {
|
|
2272
2863
|
if (entry.update !== null && "snapshot" in entry.update) this.snapshots.set(entry.url, entry.update.snapshot);
|
|
2864
|
+
const reviewRevision = entry.ref === null ? 0 : this.reviewRevision(entry.ref);
|
|
2865
|
+
const forge = entry.ref === null ? null : this.ctx.forge.describe(entry.ref.repository.forge) ?? null;
|
|
2273
2866
|
return {
|
|
2274
2867
|
...entry,
|
|
2275
|
-
|
|
2868
|
+
forge,
|
|
2869
|
+
snapshot: this.snapshots.get(entry.url) ?? null,
|
|
2870
|
+
reviewRevision
|
|
2276
2871
|
};
|
|
2277
2872
|
});
|
|
2278
2873
|
}
|
|
@@ -2281,6 +2876,7 @@ var SessionPanel = class {
|
|
|
2281
2876
|
return {
|
|
2282
2877
|
editable: this.ctx.get("worktrees") !== void 0 && !state.locked && state.created === null,
|
|
2283
2878
|
blocker: this.blocker,
|
|
2879
|
+
namePrefix: this.config.worktreePrefix,
|
|
2284
2880
|
request: state.request,
|
|
2285
2881
|
created: state.created,
|
|
2286
2882
|
creation: this.creations.of(this.session),
|
|
@@ -2352,9 +2948,8 @@ var SessionPanel = class {
|
|
|
2352
2948
|
}
|
|
2353
2949
|
let missing = null;
|
|
2354
2950
|
try {
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
} catch (_error) {}
|
|
2951
|
+
missing = await missingWorktree(this.ctx, this.config, this.session, this.worktreeStates.stateOf(this.session), directory, this.lifetime.signal);
|
|
2952
|
+
} catch (_worktreeUnreadable) {}
|
|
2358
2953
|
if (this.lifetime.signal.aborted || this.current.directory !== directory) return;
|
|
2359
2954
|
this.blocker = blocker;
|
|
2360
2955
|
this.missing = missing;
|
|
@@ -2368,7 +2963,8 @@ var SessionPanel = class {
|
|
|
2368
2963
|
worktree: this.worktree(),
|
|
2369
2964
|
local
|
|
2370
2965
|
});
|
|
2371
|
-
if (repository !== null && !sameHost) this.probe(repository);
|
|
2966
|
+
if (repository !== null && (!sameHost || this.unconfirmed)) this.probe(repository);
|
|
2967
|
+
this.unconfirmed = false;
|
|
2372
2968
|
if (upstream !== null) this.discover(upstream);
|
|
2373
2969
|
}
|
|
2374
2970
|
/** The upstream branch with the first URL of its remote that a provider recognizes. */
|
|
@@ -2393,9 +2989,10 @@ var SessionPanel = class {
|
|
|
2393
2989
|
if (policy.mode === "danger-full-access") return null;
|
|
2394
2990
|
if (policy.mode === "read-only") return "read-only";
|
|
2395
2991
|
const root = this.ctx.fs.processPath(await this.ctx.fs.resolve(policy.workspaceRoot, { signal: this.lifetime.signal }));
|
|
2396
|
-
|
|
2992
|
+
const granted = [root, ...policy.additionalWritableRoots ?? []].some((directory) => within(directory, inspection.commonDir));
|
|
2993
|
+
return within(root, inspection.checkout.root) && granted ? null : "outside-writable-root";
|
|
2397
2994
|
}
|
|
2398
|
-
/** Measure the `branch` scope; a failed measurement only hides the local changes
|
|
2995
|
+
/** Measure the `branch` scope; a failed measurement only hides the local changes row. */
|
|
2399
2996
|
async localOf(inspection) {
|
|
2400
2997
|
try {
|
|
2401
2998
|
return await localChanges(this.ctx, this.config, this.session, inspection, this.worktree().created, this.lifetime.signal);
|
|
@@ -2410,6 +3007,25 @@ var SessionPanel = class {
|
|
|
2410
3007
|
}
|
|
2411
3008
|
return null;
|
|
2412
3009
|
}
|
|
3010
|
+
/**
|
|
3011
|
+
* Probe sign-in again when a status read on the host the panel shows as ready was refused as unauthenticated, once
|
|
3012
|
+
* until a status read on that host is no longer refused.
|
|
3013
|
+
*/
|
|
3014
|
+
confirmSignIn(changeRequests) {
|
|
3015
|
+
const { repository, readiness } = this.current;
|
|
3016
|
+
if (repository === null) return;
|
|
3017
|
+
if (!changeRequests.some((entry) => entry.ref !== null && hostOf(entry.ref.repository) === hostOf(repository) && entry.update !== null && "failure" in entry.update && entry.update.failure.code === "unauthenticated")) {
|
|
3018
|
+
this.questioned = false;
|
|
3019
|
+
return;
|
|
3020
|
+
}
|
|
3021
|
+
if (this.questioned || readiness?.state !== "ready") return;
|
|
3022
|
+
this.questioned = true;
|
|
3023
|
+
this.publish({
|
|
3024
|
+
...this.current,
|
|
3025
|
+
readiness: null
|
|
3026
|
+
});
|
|
3027
|
+
this.probe(repository);
|
|
3028
|
+
}
|
|
2413
3029
|
/** Probe sign-in on the repository's host; resolves once the probe has ended. */
|
|
2414
3030
|
probe(repository) {
|
|
2415
3031
|
const host = hostOf(repository);
|
|
@@ -2433,7 +3049,8 @@ var SessionPanel = class {
|
|
|
2433
3049
|
} catch (error) {
|
|
2434
3050
|
readiness = {
|
|
2435
3051
|
state: "unavailable",
|
|
2436
|
-
message: error instanceof Error ? error.message : String(error)
|
|
3052
|
+
message: error instanceof Error ? error.message : String(error),
|
|
3053
|
+
signIn: null
|
|
2437
3054
|
};
|
|
2438
3055
|
}
|
|
2439
3056
|
if (this.lifetime.signal.aborted || this.current.repository === null || hostOf(this.current.repository) !== host) return;
|
|
@@ -2476,7 +3093,7 @@ async function missingWorktree(ctx, config, session, state, directory, signal) {
|
|
|
2476
3093
|
"--path-format=absolute",
|
|
2477
3094
|
"--git-common-dir"
|
|
2478
3095
|
]);
|
|
2479
|
-
const source = await gitIn(ctx, config, session, created.repositoryRoot, signal)("common-dir", [
|
|
3096
|
+
const source = await gitIn(ctx, config, session, created.repositoryRoot, signal, created.repositoryRoot)("common-dir", [
|
|
2480
3097
|
"rev-parse",
|
|
2481
3098
|
"--path-format=absolute",
|
|
2482
3099
|
"--git-common-dir"
|
|
@@ -2544,7 +3161,7 @@ var PatchCache = class {
|
|
|
2544
3161
|
*/
|
|
2545
3162
|
set(key, version, value) {
|
|
2546
3163
|
this.remove(key);
|
|
2547
|
-
const bytes = Buffer.byteLength(value.patch) + Buffer.byteLength(value.attributes);
|
|
3164
|
+
const bytes = Buffer$1.byteLength(value.patch) + Buffer$1.byteLength(value.attributes);
|
|
2548
3165
|
if (bytes > this.maxBytes) return;
|
|
2549
3166
|
this.entries.set(key, {
|
|
2550
3167
|
version,
|
|
@@ -2567,21 +3184,22 @@ var PatchCache = class {
|
|
|
2567
3184
|
//#endregion
|
|
2568
3185
|
//#region lib/types/review-cache.js
|
|
2569
3186
|
/**
|
|
2570
|
-
* Review
|
|
2571
|
-
*
|
|
3187
|
+
* Review reads of change requests kept in memory: the review threads and the viewed marks. The changes view reads
|
|
3188
|
+
* them from the code host again only after the version they were read at changes, the kept read reaches its age
|
|
3189
|
+
* limit, or a write drops it.
|
|
2572
3190
|
*/
|
|
2573
3191
|
/**
|
|
2574
|
-
* One read of
|
|
2575
|
-
*
|
|
2576
|
-
* is not kept, so
|
|
3192
|
+
* One read of one kind per change request, bounded by age and by the total UTF-8 size of the kept reads as JSON; the
|
|
3193
|
+
* least recently read change request leaves first. A read that started before a drop or an amendment of any change
|
|
3194
|
+
* request is not kept, so a read made before a write never replaces what the write left.
|
|
2577
3195
|
*/
|
|
2578
3196
|
var ReviewCache = class {
|
|
2579
3197
|
maxBytes;
|
|
2580
3198
|
maxAgeMs;
|
|
2581
3199
|
entries = /* @__PURE__ */ new Map();
|
|
2582
3200
|
bytes = 0;
|
|
2583
|
-
/** Number of drops so far. */
|
|
2584
|
-
|
|
3201
|
+
/** Number of drops and amendments so far. */
|
|
3202
|
+
writes = 0;
|
|
2585
3203
|
/**
|
|
2586
3204
|
* @param maxBytes - most UTF-8 bytes kept together; a larger read is not kept.
|
|
2587
3205
|
* @param maxAgeMs - age in milliseconds at which a kept read is no longer returned.
|
|
@@ -2591,44 +3209,69 @@ var ReviewCache = class {
|
|
|
2591
3209
|
this.maxAgeMs = maxAgeMs;
|
|
2592
3210
|
}
|
|
2593
3211
|
/**
|
|
2594
|
-
* Read
|
|
2595
|
-
*
|
|
3212
|
+
* Read what is kept for a change request at a version while it is younger than the age limit, marking it the most
|
|
3213
|
+
* recently read.
|
|
2596
3214
|
* @param key - the change request.
|
|
2597
|
-
* @param version -
|
|
3215
|
+
* @param version - the version the reader needs.
|
|
2598
3216
|
* @param now - current epoch milliseconds.
|
|
2599
|
-
* @returns the
|
|
3217
|
+
* @returns the kept read, or undefined when none is kept at that version or it reached the age limit.
|
|
2600
3218
|
*/
|
|
2601
3219
|
get(key, version, now) {
|
|
2602
3220
|
const entry = this.entries.get(key);
|
|
2603
3221
|
if (entry?.version !== version || now - entry.readAt >= this.maxAgeMs) return void 0;
|
|
2604
3222
|
this.entries.delete(key);
|
|
2605
3223
|
this.entries.set(key, entry);
|
|
2606
|
-
return entry.
|
|
3224
|
+
return entry.read;
|
|
2607
3225
|
}
|
|
2608
3226
|
/**
|
|
2609
3227
|
* Name the cache's state when a read starts, for {@link ReviewCache.set}.
|
|
2610
3228
|
* @returns the token of the read.
|
|
2611
3229
|
*/
|
|
2612
3230
|
token() {
|
|
2613
|
-
return this.
|
|
3231
|
+
return this.writes;
|
|
2614
3232
|
}
|
|
2615
3233
|
/**
|
|
2616
3234
|
* Keep a read in place of the change request's earlier one, then drop the least recently read change requests
|
|
2617
|
-
* until the rest fit within `maxBytes`. A read whose token a drop outdated is not kept.
|
|
3235
|
+
* until the rest fit within `maxBytes`. A read whose token a drop or an amendment outdated is not kept.
|
|
2618
3236
|
* @param key - the change request.
|
|
2619
|
-
* @param version -
|
|
2620
|
-
* @param
|
|
3237
|
+
* @param version - the version the read was made at.
|
|
3238
|
+
* @param read - what was read.
|
|
2621
3239
|
* @param readAt - epoch milliseconds when the read started.
|
|
2622
3240
|
* @param token - what {@link ReviewCache.token} returned when the read started.
|
|
2623
3241
|
*/
|
|
2624
|
-
set(key, version,
|
|
2625
|
-
if (token !== this.
|
|
3242
|
+
set(key, version, read, readAt, token) {
|
|
3243
|
+
if (token !== this.writes) return;
|
|
3244
|
+
this.keep(key, version, read, readAt);
|
|
3245
|
+
}
|
|
3246
|
+
/**
|
|
3247
|
+
* Forget the read kept for a change request, and every read in flight, after a write changed it.
|
|
3248
|
+
* @param key - the change request.
|
|
3249
|
+
*/
|
|
3250
|
+
drop(key) {
|
|
3251
|
+
this.writes += 1;
|
|
3252
|
+
this.forget(key);
|
|
3253
|
+
}
|
|
3254
|
+
/**
|
|
3255
|
+
* Apply a write whose effect on the read is known: a read kept at `version` becomes `change(read)` and keeps its
|
|
3256
|
+
* age, and one kept at another version is forgotten. Reads in flight are not kept, as after a drop.
|
|
3257
|
+
* @param key - the change request.
|
|
3258
|
+
* @param version - the version the write was made at.
|
|
3259
|
+
* @param change - what the kept read is after the write.
|
|
3260
|
+
*/
|
|
3261
|
+
amend(key, version, change) {
|
|
3262
|
+
this.writes += 1;
|
|
3263
|
+
const entry = this.entries.get(key);
|
|
3264
|
+
if (entry === void 0) return;
|
|
3265
|
+
if (entry.version === version) this.keep(key, version, change(entry.read), entry.readAt);
|
|
3266
|
+
else this.forget(key);
|
|
3267
|
+
}
|
|
3268
|
+
keep(key, version, read, readAt) {
|
|
2626
3269
|
this.forget(key);
|
|
2627
|
-
const bytes = Buffer.byteLength(JSON.stringify(
|
|
3270
|
+
const bytes = Buffer$1.byteLength(JSON.stringify(read));
|
|
2628
3271
|
if (bytes > this.maxBytes) return;
|
|
2629
3272
|
this.entries.set(key, {
|
|
2630
3273
|
version,
|
|
2631
|
-
|
|
3274
|
+
read,
|
|
2632
3275
|
readAt,
|
|
2633
3276
|
bytes
|
|
2634
3277
|
});
|
|
@@ -2639,14 +3282,6 @@ var ReviewCache = class {
|
|
|
2639
3282
|
this.bytes -= entry.bytes;
|
|
2640
3283
|
}
|
|
2641
3284
|
}
|
|
2642
|
-
/**
|
|
2643
|
-
* Forget the threads kept for a change request, and every read in flight, after a write changed them.
|
|
2644
|
-
* @param key - the change request.
|
|
2645
|
-
*/
|
|
2646
|
-
drop(key) {
|
|
2647
|
-
this.drops += 1;
|
|
2648
|
-
this.forget(key);
|
|
2649
|
-
}
|
|
2650
3285
|
forget(key) {
|
|
2651
3286
|
const previous = this.entries.get(key);
|
|
2652
3287
|
if (previous === void 0) return;
|
|
@@ -2697,23 +3332,23 @@ const changeRequestStatesDomain = defineDomain({
|
|
|
2697
3332
|
function storedKey(url) {
|
|
2698
3333
|
return createHash("sha256").update(url).digest("hex");
|
|
2699
3334
|
}
|
|
2700
|
-
function listStateOf(
|
|
3335
|
+
function listStateOf(brief, url) {
|
|
2701
3336
|
return {
|
|
2702
3337
|
url,
|
|
2703
|
-
number:
|
|
2704
|
-
title:
|
|
2705
|
-
state:
|
|
2706
|
-
draft:
|
|
2707
|
-
checksRollup:
|
|
2708
|
-
reviewDecision:
|
|
2709
|
-
mergeability:
|
|
3338
|
+
number: brief.ref.number,
|
|
3339
|
+
title: brief.title,
|
|
3340
|
+
state: brief.state,
|
|
3341
|
+
draft: brief.draft,
|
|
3342
|
+
checksRollup: brief.checksRollup,
|
|
3343
|
+
reviewDecision: brief.reviewDecision,
|
|
3344
|
+
mergeability: brief.mergeability
|
|
2710
3345
|
};
|
|
2711
3346
|
}
|
|
2712
3347
|
function sameState(left, right) {
|
|
2713
3348
|
return left !== void 0 && left.title === right.title && left.state === right.state && left.draft === right.draft && left.checksRollup === right.checksRollup && left.reviewDecision === right.reviewDecision && left.mergeability === right.mergeability && left.number === right.number;
|
|
2714
3349
|
}
|
|
2715
3350
|
/** One stream's pending changes, coalesced by URL until the reader takes them. */
|
|
2716
|
-
var Reader = class {
|
|
3351
|
+
var Reader$1 = class {
|
|
2717
3352
|
allowed;
|
|
2718
3353
|
signal;
|
|
2719
3354
|
pending = /* @__PURE__ */ new Map();
|
|
@@ -2767,6 +3402,7 @@ var Run = class {
|
|
|
2767
3402
|
sources;
|
|
2768
3403
|
readers;
|
|
2769
3404
|
storage;
|
|
3405
|
+
readAt;
|
|
2770
3406
|
states = /* @__PURE__ */ new Map();
|
|
2771
3407
|
sessionsOf = /* @__PURE__ */ new Map();
|
|
2772
3408
|
urlsOf = /* @__PURE__ */ new Map();
|
|
@@ -2776,10 +3412,17 @@ var Run = class {
|
|
|
2776
3412
|
starting = true;
|
|
2777
3413
|
writes = /* @__PURE__ */ new Set();
|
|
2778
3414
|
stopped = false;
|
|
2779
|
-
|
|
3415
|
+
/**
|
|
3416
|
+
* @param sources - what the run reads, follows, and polls.
|
|
3417
|
+
* @param readers - the streams the run publishes to.
|
|
3418
|
+
* @param storage - the stored states, which the run owns and closes.
|
|
3419
|
+
* @param readAt - epoch milliseconds of the latest read of each URL in this process, kept across runs.
|
|
3420
|
+
*/
|
|
3421
|
+
constructor(sources, readers, storage, readAt) {
|
|
2780
3422
|
this.sources = sources;
|
|
2781
3423
|
this.readers = readers;
|
|
2782
3424
|
this.storage = storage;
|
|
3425
|
+
this.readAt = readAt;
|
|
2783
3426
|
for (const [, state] of storage.table.entries()) this.states.set(state.url, state);
|
|
2784
3427
|
this.stopBindings = sources.onBindings((id, urls) => {
|
|
2785
3428
|
if (this.starting) this.startupBindings.set(id, urls);
|
|
@@ -2801,6 +3444,7 @@ var Run = class {
|
|
|
2801
3444
|
for (const [url] of this.states) {
|
|
2802
3445
|
if (this.sessionsOf.has(url)) continue;
|
|
2803
3446
|
this.states.delete(url);
|
|
3447
|
+
this.readAt.delete(url);
|
|
2804
3448
|
this.write(() => this.storage.table.delete(storedKey(url)));
|
|
2805
3449
|
}
|
|
2806
3450
|
}
|
|
@@ -2855,10 +3499,18 @@ var Run = class {
|
|
|
2855
3499
|
if (this.polls.has(url)) return;
|
|
2856
3500
|
const ref = this.sources.refOf(url);
|
|
2857
3501
|
if (ref === void 0) return;
|
|
3502
|
+
const state = this.states.get(url);
|
|
3503
|
+
const known = state === void 0 ? void 0 : {
|
|
3504
|
+
state: state.state,
|
|
3505
|
+
mergeability: state.mergeability,
|
|
3506
|
+
checksRollup: state.checksRollup,
|
|
3507
|
+
fetchedAt: this.readAt.get(url) ?? 0
|
|
3508
|
+
};
|
|
2858
3509
|
this.polls.set(url, this.sources.watch(ref, (update) => {
|
|
2859
3510
|
if ("failure" in update) return;
|
|
2860
|
-
this.
|
|
2861
|
-
|
|
3511
|
+
this.readAt.set(url, update.fetchedAt);
|
|
3512
|
+
this.settle(url, ids, listStateOf(update.brief, url));
|
|
3513
|
+
}, known));
|
|
2862
3514
|
}
|
|
2863
3515
|
settle(url, ids, state) {
|
|
2864
3516
|
if (this.stopped || sameState(this.states.get(url), state)) return;
|
|
@@ -2880,6 +3532,8 @@ var Run = class {
|
|
|
2880
3532
|
var ChangeRequestStates = class {
|
|
2881
3533
|
sources;
|
|
2882
3534
|
readers = /* @__PURE__ */ new Set();
|
|
3535
|
+
/** Epoch milliseconds of the latest read of each change request URL, which outlives the runs. */
|
|
3536
|
+
readAt = /* @__PURE__ */ new Map();
|
|
2883
3537
|
stopping = Promise.resolve();
|
|
2884
3538
|
disposed = false;
|
|
2885
3539
|
run;
|
|
@@ -2898,7 +3552,7 @@ var ChangeRequestStates = class {
|
|
|
2898
3552
|
async *stream(allowed, signal) {
|
|
2899
3553
|
signal.throwIfAborted();
|
|
2900
3554
|
if (this.disposed) return;
|
|
2901
|
-
const reader = new Reader(allowed, signal);
|
|
3555
|
+
const reader = new Reader$1(allowed, signal);
|
|
2902
3556
|
this.readers.add(reader);
|
|
2903
3557
|
try {
|
|
2904
3558
|
const run = await Promise.race([this.ensureRun(), reader.closed.then(() => void 0)]);
|
|
@@ -2934,7 +3588,7 @@ var ChangeRequestStates = class {
|
|
|
2934
3588
|
let run;
|
|
2935
3589
|
try {
|
|
2936
3590
|
aborter.signal.throwIfAborted();
|
|
2937
|
-
run = new Run(this.sources, this.readers, storage);
|
|
3591
|
+
run = new Run(this.sources, this.readers, storage, this.readAt);
|
|
2938
3592
|
await run.start(aborter.signal);
|
|
2939
3593
|
return run;
|
|
2940
3594
|
} catch (error) {
|
|
@@ -2959,6 +3613,366 @@ var ChangeRequestStates = class {
|
|
|
2959
3613
|
}
|
|
2960
3614
|
};
|
|
2961
3615
|
//#endregion
|
|
3616
|
+
//#region lib/types/viewer-lists.js
|
|
3617
|
+
/**
|
|
3618
|
+
* The review page's lists of the signed-in user's change requests and its navigation count. Lists are read only while
|
|
3619
|
+
* some reader streams them and the count only while some reader streams it; neither joins the forge's status polling.
|
|
3620
|
+
* Readers of one repository scope share one poller, which reads every list of every host each round, hosts in parallel
|
|
3621
|
+
* and each host's lists one after another, so one host has at most one read in flight. A round with a failure delays
|
|
3622
|
+
* the next round as status polling does after consecutive failures.
|
|
3623
|
+
*/
|
|
3624
|
+
/** The lists in the order the page shows them. */
|
|
3625
|
+
const FILTERS = [
|
|
3626
|
+
"review-requested",
|
|
3627
|
+
"authored",
|
|
3628
|
+
"involved"
|
|
3629
|
+
];
|
|
3630
|
+
/** A stream's latest undelivered frame; a newer frame replaces one the reader has not taken. */
|
|
3631
|
+
var Reader = class {
|
|
3632
|
+
signal;
|
|
3633
|
+
pending;
|
|
3634
|
+
wake;
|
|
3635
|
+
ended = false;
|
|
3636
|
+
abort = () => {
|
|
3637
|
+
this.end();
|
|
3638
|
+
};
|
|
3639
|
+
constructor(signal) {
|
|
3640
|
+
this.signal = signal;
|
|
3641
|
+
signal.addEventListener("abort", this.abort, { once: true });
|
|
3642
|
+
}
|
|
3643
|
+
/**
|
|
3644
|
+
* Offer a frame, replacing one the reader has not taken; ignored after the stream ended.
|
|
3645
|
+
* @param frame - the frame.
|
|
3646
|
+
*/
|
|
3647
|
+
push(frame) {
|
|
3648
|
+
if (this.ended) return;
|
|
3649
|
+
this.pending = frame;
|
|
3650
|
+
this.wake?.();
|
|
3651
|
+
}
|
|
3652
|
+
/** End the stream once the reader took the frame it waits for. */
|
|
3653
|
+
end() {
|
|
3654
|
+
this.ended = true;
|
|
3655
|
+
this.wake?.();
|
|
3656
|
+
}
|
|
3657
|
+
/** End the stream and stop following its abort signal. */
|
|
3658
|
+
dispose() {
|
|
3659
|
+
this.signal.removeEventListener("abort", this.abort);
|
|
3660
|
+
this.end();
|
|
3661
|
+
}
|
|
3662
|
+
/**
|
|
3663
|
+
* Yield each latest frame as the reader takes it, until the stream ends.
|
|
3664
|
+
* @returns the frames.
|
|
3665
|
+
*/
|
|
3666
|
+
async *frames() {
|
|
3667
|
+
while (!this.ended) {
|
|
3668
|
+
if (this.pending === void 0) {
|
|
3669
|
+
await new Promise((resolve) => {
|
|
3670
|
+
this.wake = resolve;
|
|
3671
|
+
});
|
|
3672
|
+
this.wake = void 0;
|
|
3673
|
+
continue;
|
|
3674
|
+
}
|
|
3675
|
+
const frame = this.pending;
|
|
3676
|
+
this.pending = void 0;
|
|
3677
|
+
yield frame;
|
|
3678
|
+
}
|
|
3679
|
+
}
|
|
3680
|
+
};
|
|
3681
|
+
/** A loop that runs one round, waits, and repeats until stopped; a refresh ends the wait early. */
|
|
3682
|
+
var Poller = class {
|
|
3683
|
+
round;
|
|
3684
|
+
delay;
|
|
3685
|
+
aborter = new AbortController();
|
|
3686
|
+
wake;
|
|
3687
|
+
refreshing = false;
|
|
3688
|
+
failures = 0;
|
|
3689
|
+
done;
|
|
3690
|
+
constructor(round, delay) {
|
|
3691
|
+
this.round = round;
|
|
3692
|
+
this.delay = delay;
|
|
3693
|
+
this.done = this.loop();
|
|
3694
|
+
}
|
|
3695
|
+
refresh() {
|
|
3696
|
+
this.refreshing = true;
|
|
3697
|
+
this.wake?.();
|
|
3698
|
+
}
|
|
3699
|
+
async stop() {
|
|
3700
|
+
this.aborter.abort(/* @__PURE__ */ new Error("viewer lists stopped"));
|
|
3701
|
+
this.wake?.();
|
|
3702
|
+
await this.done;
|
|
3703
|
+
}
|
|
3704
|
+
/** Whether the loop starts its next round at once: it stopped, or a refresh arrived during the round. */
|
|
3705
|
+
skipsWait(signal) {
|
|
3706
|
+
return signal.aborted || this.refreshing;
|
|
3707
|
+
}
|
|
3708
|
+
async loop() {
|
|
3709
|
+
const { signal } = this.aborter;
|
|
3710
|
+
while (!signal.aborted) {
|
|
3711
|
+
this.refreshing = false;
|
|
3712
|
+
const succeeded = await this.round(signal);
|
|
3713
|
+
this.failures = succeeded ? 0 : this.failures + 1;
|
|
3714
|
+
if (this.skipsWait(signal)) continue;
|
|
3715
|
+
await new Promise((resolve) => {
|
|
3716
|
+
const timer = setTimeout(resolve, this.delay(this.failures));
|
|
3717
|
+
this.wake = () => {
|
|
3718
|
+
clearTimeout(timer);
|
|
3719
|
+
resolve();
|
|
3720
|
+
};
|
|
3721
|
+
});
|
|
3722
|
+
this.wake = void 0;
|
|
3723
|
+
}
|
|
3724
|
+
}
|
|
3725
|
+
};
|
|
3726
|
+
/** The readers of one repository scope, the poller they share, and what it read. */
|
|
3727
|
+
var Scope = class {
|
|
3728
|
+
readers = /* @__PURE__ */ new Set();
|
|
3729
|
+
hosts = /* @__PURE__ */ new Map();
|
|
3730
|
+
reading = false;
|
|
3731
|
+
poller;
|
|
3732
|
+
/**
|
|
3733
|
+
* @param round - reads every list of the scope once; resolves to whether every read succeeded.
|
|
3734
|
+
* @param delay - milliseconds before the next round after the given number of consecutive failed rounds.
|
|
3735
|
+
*/
|
|
3736
|
+
constructor(round, delay) {
|
|
3737
|
+
this.poller = new Poller((signal) => round(this, signal), delay);
|
|
3738
|
+
}
|
|
3739
|
+
frame(order) {
|
|
3740
|
+
const hosts = [];
|
|
3741
|
+
for (const source of order) for (const host of source.hosts) hosts.push(this.hosts.get(hostKey(source.forge, host)) ?? emptyHost(source, host));
|
|
3742
|
+
return {
|
|
3743
|
+
hosts,
|
|
3744
|
+
reading: this.reading
|
|
3745
|
+
};
|
|
3746
|
+
}
|
|
3747
|
+
};
|
|
3748
|
+
/** Streams the review page's lists and navigation count, reading them only while streamed. */
|
|
3749
|
+
var ViewerLists = class {
|
|
3750
|
+
sources;
|
|
3751
|
+
timing;
|
|
3752
|
+
scopes = /* @__PURE__ */ new Map();
|
|
3753
|
+
countReaders = /* @__PURE__ */ new Set();
|
|
3754
|
+
counts = /* @__PURE__ */ new Map();
|
|
3755
|
+
countPoller;
|
|
3756
|
+
disposed = false;
|
|
3757
|
+
/**
|
|
3758
|
+
* @param sources - the registry reads and the report of a rejected read.
|
|
3759
|
+
* @param timing - cadence and size of the reads.
|
|
3760
|
+
*/
|
|
3761
|
+
constructor(sources, timing) {
|
|
3762
|
+
this.sources = sources;
|
|
3763
|
+
this.timing = timing;
|
|
3764
|
+
}
|
|
3765
|
+
/**
|
|
3766
|
+
* Stream the lists of one repository scope: the lists read so far first, then a frame after each read settles.
|
|
3767
|
+
* The stream ends when `signal` aborts or the hub is disposed; the last stream of a scope stops its reads.
|
|
3768
|
+
* @param scope - one repository, or null for every repository.
|
|
3769
|
+
* @param signal - ends the stream.
|
|
3770
|
+
* @returns frames, each complete.
|
|
3771
|
+
*/
|
|
3772
|
+
async *lists(scope, signal) {
|
|
3773
|
+
signal.throwIfAborted();
|
|
3774
|
+
if (this.disposed) return;
|
|
3775
|
+
const key = scope === null ? "" : `${scope.owner}/${scope.name}`.toLowerCase();
|
|
3776
|
+
let state = this.scopes.get(key);
|
|
3777
|
+
if (state === void 0) {
|
|
3778
|
+
state = new Scope((created, round) => this.readScope(created, scope, round), (failures) => this.delay(this.timing.listIntervalMs, failures));
|
|
3779
|
+
this.scopes.set(key, state);
|
|
3780
|
+
}
|
|
3781
|
+
const reader = new Reader(signal);
|
|
3782
|
+
state.readers.add(reader);
|
|
3783
|
+
reader.push(state.frame(this.sources.sources()));
|
|
3784
|
+
try {
|
|
3785
|
+
yield* reader.frames();
|
|
3786
|
+
} finally {
|
|
3787
|
+
reader.dispose();
|
|
3788
|
+
state.readers.delete(reader);
|
|
3789
|
+
if (state.readers.size === 0 && this.scopes.get(key) === state) {
|
|
3790
|
+
this.scopes.delete(key);
|
|
3791
|
+
await state.poller.stop();
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
/**
|
|
3796
|
+
* Stream the navigation count: the latest count first, then each change. The stream ends when `signal` aborts or the
|
|
3797
|
+
* hub is disposed; the last stream stops the count reads.
|
|
3798
|
+
* @param signal - ends the stream.
|
|
3799
|
+
* @returns frames, each complete.
|
|
3800
|
+
*/
|
|
3801
|
+
async *count(signal) {
|
|
3802
|
+
signal.throwIfAborted();
|
|
3803
|
+
if (this.disposed) return;
|
|
3804
|
+
const reader = new Reader(signal);
|
|
3805
|
+
this.countReaders.add(reader);
|
|
3806
|
+
reader.push(this.countFrame());
|
|
3807
|
+
this.countPoller ??= new Poller((round) => this.readCounts(round), (failures) => this.delay(this.timing.countIntervalMs, failures));
|
|
3808
|
+
try {
|
|
3809
|
+
yield* reader.frames();
|
|
3810
|
+
} finally {
|
|
3811
|
+
reader.dispose();
|
|
3812
|
+
this.countReaders.delete(reader);
|
|
3813
|
+
if (this.countReaders.size === 0) await this.stopCounting();
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
/** Stop the count reads; a disposed hub already stopped them. */
|
|
3817
|
+
async stopCounting() {
|
|
3818
|
+
const poller = this.countPoller;
|
|
3819
|
+
this.countPoller = void 0;
|
|
3820
|
+
await poller?.stop();
|
|
3821
|
+
}
|
|
3822
|
+
/** Read every streamed list and the count again at once. */
|
|
3823
|
+
refresh() {
|
|
3824
|
+
for (const scope of this.scopes.values()) scope.poller.refresh();
|
|
3825
|
+
this.countPoller?.refresh();
|
|
3826
|
+
}
|
|
3827
|
+
/** Forget hosts that no longer have a provider, publish that, and read the hosts that gained one. */
|
|
3828
|
+
sourcesChanged() {
|
|
3829
|
+
const current = new Set(this.sources.sources().flatMap((source) => source.hosts.map((host) => hostKey(source.forge, host))));
|
|
3830
|
+
for (const key of [...this.counts.keys()]) if (!current.has(key)) this.counts.delete(key);
|
|
3831
|
+
for (const scope of this.scopes.values()) {
|
|
3832
|
+
for (const key of [...scope.hosts.keys()]) if (!current.has(key)) scope.hosts.delete(key);
|
|
3833
|
+
this.publish(scope);
|
|
3834
|
+
}
|
|
3835
|
+
this.publishCount();
|
|
3836
|
+
this.refresh();
|
|
3837
|
+
}
|
|
3838
|
+
/**
|
|
3839
|
+
* End every stream and stop every read.
|
|
3840
|
+
* @returns settles once every poller stopped.
|
|
3841
|
+
*/
|
|
3842
|
+
async dispose() {
|
|
3843
|
+
this.disposed = true;
|
|
3844
|
+
const pollers = [...this.scopes.values()].map((scope) => scope.poller);
|
|
3845
|
+
if (this.countPoller !== void 0) pollers.push(this.countPoller);
|
|
3846
|
+
for (const scope of this.scopes.values()) for (const reader of scope.readers) reader.end();
|
|
3847
|
+
for (const reader of this.countReaders) reader.end();
|
|
3848
|
+
this.scopes.clear();
|
|
3849
|
+
this.countPoller = void 0;
|
|
3850
|
+
await Promise.all(pollers.map(async (poller) => {
|
|
3851
|
+
await poller.stop();
|
|
3852
|
+
}));
|
|
3853
|
+
}
|
|
3854
|
+
/** Read every list of every host once; resolves to whether every read succeeded. */
|
|
3855
|
+
async readScope(scope, repository, signal) {
|
|
3856
|
+
const order = this.sources.sources();
|
|
3857
|
+
scope.reading = true;
|
|
3858
|
+
this.publish(scope);
|
|
3859
|
+
const results = await Promise.all(order.flatMap((source) => source.hosts.map(async (host) => {
|
|
3860
|
+
let succeeded = true;
|
|
3861
|
+
let hostFailure;
|
|
3862
|
+
for (const filter of FILTERS) {
|
|
3863
|
+
if (!source.filters.has(filter)) continue;
|
|
3864
|
+
const query = {
|
|
3865
|
+
host,
|
|
3866
|
+
filter,
|
|
3867
|
+
repository,
|
|
3868
|
+
limit: Math.min(source.maxItems, this.timing.pageSize)
|
|
3869
|
+
};
|
|
3870
|
+
const result = hostFailure ?? await this.read(() => this.sources.list(source.forge, query, signal), signal);
|
|
3871
|
+
if (signal.aborted) return false;
|
|
3872
|
+
if ("code" in result && HOST_FAILURES.has(result.code)) hostFailure = result;
|
|
3873
|
+
succeeded = this.settle(scope, source, host, filter, result) && succeeded;
|
|
3874
|
+
if (repository === null && !("code" in result) && filter === "review-requested") {
|
|
3875
|
+
this.counts.set(hostKey(source.forge, host), result.total);
|
|
3876
|
+
this.publishCount();
|
|
3877
|
+
}
|
|
3878
|
+
this.publish(scope);
|
|
3879
|
+
}
|
|
3880
|
+
return succeeded;
|
|
3881
|
+
})));
|
|
3882
|
+
scope.reading = false;
|
|
3883
|
+
if (!signal.aborted) this.publish(scope);
|
|
3884
|
+
return results.every(Boolean);
|
|
3885
|
+
}
|
|
3886
|
+
/** Read the count of every host once; resolves to whether every read succeeded. */
|
|
3887
|
+
async readCounts(signal) {
|
|
3888
|
+
return (await Promise.all(this.sources.sources().flatMap((source) => source.hosts.map(async (host) => {
|
|
3889
|
+
if (!source.filters.has("review-requested")) return true;
|
|
3890
|
+
const result = await this.read(() => this.sources.count(source.forge, host, signal), signal);
|
|
3891
|
+
if (signal.aborted || "code" in result) return false;
|
|
3892
|
+
this.counts.set(hostKey(source.forge, host), result.get("review-requested") ?? 0);
|
|
3893
|
+
this.publishCount();
|
|
3894
|
+
return true;
|
|
3895
|
+
})))).every(Boolean);
|
|
3896
|
+
}
|
|
3897
|
+
/** Run one read, turning a rejection into an `unavailable` failure and reporting it unless `signal` aborted. */
|
|
3898
|
+
async read(run, signal) {
|
|
3899
|
+
try {
|
|
3900
|
+
return await run();
|
|
3901
|
+
} catch (error) {
|
|
3902
|
+
if (!signal.aborted) this.sources.report(error);
|
|
3903
|
+
return {
|
|
3904
|
+
code: "unavailable",
|
|
3905
|
+
message: error instanceof Error ? error.message : String(error)
|
|
3906
|
+
};
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
/** Record one list read; resolves to whether it succeeded. */
|
|
3910
|
+
settle(scope, source, host, filter, result) {
|
|
3911
|
+
const key = hostKey(source.forge, host);
|
|
3912
|
+
const current = scope.hosts.get(key) ?? emptyHost(source, host);
|
|
3913
|
+
const previous = current.lists[filter] ?? EMPTY_LIST;
|
|
3914
|
+
const list = "code" in result ? {
|
|
3915
|
+
...previous,
|
|
3916
|
+
failure: result
|
|
3917
|
+
} : {
|
|
3918
|
+
items: result.items,
|
|
3919
|
+
total: result.total,
|
|
3920
|
+
fetchedAt: Date.now(),
|
|
3921
|
+
failure: null
|
|
3922
|
+
};
|
|
3923
|
+
scope.hosts.set(key, {
|
|
3924
|
+
...current,
|
|
3925
|
+
viewer: "code" in result ? current.viewer : result.viewer,
|
|
3926
|
+
lists: {
|
|
3927
|
+
...current.lists,
|
|
3928
|
+
[filter]: list
|
|
3929
|
+
}
|
|
3930
|
+
});
|
|
3931
|
+
return !("code" in result);
|
|
3932
|
+
}
|
|
3933
|
+
publish(scope) {
|
|
3934
|
+
const frame = scope.frame(this.sources.sources());
|
|
3935
|
+
for (const reader of scope.readers) reader.push(frame);
|
|
3936
|
+
}
|
|
3937
|
+
publishCount() {
|
|
3938
|
+
const frame = this.countFrame();
|
|
3939
|
+
for (const reader of this.countReaders) reader.push(frame);
|
|
3940
|
+
}
|
|
3941
|
+
countFrame() {
|
|
3942
|
+
return { reviewRequested: this.counts.size === 0 ? null : [...this.counts.values()].reduce((sum, value) => sum + value, 0) };
|
|
3943
|
+
}
|
|
3944
|
+
delay(interval, failures) {
|
|
3945
|
+
return failures === 0 ? interval : Math.min(this.timing.maxBackoffMs, interval * 2 ** failures);
|
|
3946
|
+
}
|
|
3947
|
+
};
|
|
3948
|
+
const EMPTY_LIST = {
|
|
3949
|
+
items: null,
|
|
3950
|
+
total: 0,
|
|
3951
|
+
fetchedAt: null,
|
|
3952
|
+
failure: null
|
|
3953
|
+
};
|
|
3954
|
+
/** Failures that the other lists of the host would meet in the same round, so the round reads them no further. */
|
|
3955
|
+
const HOST_FAILURES = new Set([
|
|
3956
|
+
"unauthenticated",
|
|
3957
|
+
"rate-limited",
|
|
3958
|
+
"unavailable"
|
|
3959
|
+
]);
|
|
3960
|
+
/** The identity of one host of one provider. */
|
|
3961
|
+
function hostKey(forge, host) {
|
|
3962
|
+
return JSON.stringify([forge, host]);
|
|
3963
|
+
}
|
|
3964
|
+
/** A host with an empty entry for each list its provider offers. */
|
|
3965
|
+
function emptyHost(source, host) {
|
|
3966
|
+
const lists = {};
|
|
3967
|
+
for (const filter of FILTERS) if (source.filters.has(filter)) lists[filter] = EMPTY_LIST;
|
|
3968
|
+
return {
|
|
3969
|
+
forge: source.forge,
|
|
3970
|
+
host,
|
|
3971
|
+
viewer: null,
|
|
3972
|
+
lists
|
|
3973
|
+
};
|
|
3974
|
+
}
|
|
3975
|
+
//#endregion
|
|
2962
3976
|
//#region lib/types/index.js
|
|
2963
3977
|
/** Host Remote of the forge panel: checkout, code host, sign-in, change request, and worktree state per Session. */
|
|
2964
3978
|
var __runInitializers = function(thisArg, initializers, value) {
|
|
@@ -3019,12 +4033,35 @@ let ForgePanelController = (() => {
|
|
|
3019
4033
|
let _instanceExtraInitializers = [];
|
|
3020
4034
|
let _follow_decorators;
|
|
3021
4035
|
let _changeRequestStates_decorators;
|
|
4036
|
+
let _reviewLists_decorators;
|
|
4037
|
+
let _reviewCount_decorators;
|
|
4038
|
+
let _reviewRefresh_decorators;
|
|
4039
|
+
let _reviewPoll_decorators;
|
|
4040
|
+
let _reviewChangeRequest_decorators;
|
|
4041
|
+
let _reviewDescription_decorators;
|
|
4042
|
+
let _reviewChecks_decorators;
|
|
4043
|
+
let _reviewThreads_decorators;
|
|
4044
|
+
let _reviewThreadWrite_decorators;
|
|
4045
|
+
let _reviewSubmit_decorators;
|
|
4046
|
+
let _reviewDiff_decorators;
|
|
4047
|
+
let _reviewCommits_decorators;
|
|
4048
|
+
let _reviewText_decorators;
|
|
4049
|
+
let _reviewViewed_decorators;
|
|
4050
|
+
let _reviewSetViewed_decorators;
|
|
4051
|
+
let _reviewMarkReady_decorators;
|
|
4052
|
+
let _reviewMerge_decorators;
|
|
4053
|
+
let _reviewRerunChecks_decorators;
|
|
4054
|
+
let _reviewRequestReviews_decorators;
|
|
4055
|
+
let _reviewReviewerCandidates_decorators;
|
|
4056
|
+
let _reviewUpdateBranch_decorators;
|
|
4057
|
+
let _reviewStage_decorators;
|
|
3022
4058
|
let _worktreeCleanup_decorators;
|
|
3023
|
-
let
|
|
4059
|
+
let _worktreeBases_decorators;
|
|
3024
4060
|
let _diffBases_decorators;
|
|
3025
4061
|
let _track_decorators;
|
|
3026
4062
|
let _dismiss_decorators;
|
|
3027
4063
|
let _refresh_decorators;
|
|
4064
|
+
let _revisit_decorators;
|
|
3028
4065
|
let _localDiff_decorators;
|
|
3029
4066
|
let _localCommits_decorators;
|
|
3030
4067
|
let _localText_decorators;
|
|
@@ -3032,6 +4069,8 @@ let ForgePanelController = (() => {
|
|
|
3032
4069
|
let _changeRequestCommits_decorators;
|
|
3033
4070
|
let _changeRequestDiff_decorators;
|
|
3034
4071
|
let _changeRequestText_decorators;
|
|
4072
|
+
let _extensions_decorators;
|
|
4073
|
+
let _changesLens_decorators;
|
|
3035
4074
|
let _changeRequestViewed_decorators;
|
|
3036
4075
|
let _setFileViewed_decorators;
|
|
3037
4076
|
let _changeRequestReview_decorators;
|
|
@@ -3054,12 +4093,35 @@ let ForgePanelController = (() => {
|
|
|
3054
4093
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
3055
4094
|
_follow_decorators = [Remote({ mode: "stream" })];
|
|
3056
4095
|
_changeRequestStates_decorators = [Remote({ mode: "stream" })];
|
|
4096
|
+
_reviewLists_decorators = [Remote({ mode: "stream" })];
|
|
4097
|
+
_reviewCount_decorators = [Remote({ mode: "stream" })];
|
|
4098
|
+
_reviewRefresh_decorators = [Remote];
|
|
4099
|
+
_reviewPoll_decorators = [Remote];
|
|
4100
|
+
_reviewChangeRequest_decorators = [Remote({ mode: "stream" })];
|
|
4101
|
+
_reviewDescription_decorators = [Remote];
|
|
4102
|
+
_reviewChecks_decorators = [Remote];
|
|
4103
|
+
_reviewThreads_decorators = [Remote];
|
|
4104
|
+
_reviewThreadWrite_decorators = [Remote];
|
|
4105
|
+
_reviewSubmit_decorators = [Remote];
|
|
4106
|
+
_reviewDiff_decorators = [Remote];
|
|
4107
|
+
_reviewCommits_decorators = [Remote];
|
|
4108
|
+
_reviewText_decorators = [Remote];
|
|
4109
|
+
_reviewViewed_decorators = [Remote];
|
|
4110
|
+
_reviewSetViewed_decorators = [Remote];
|
|
4111
|
+
_reviewMarkReady_decorators = [Remote];
|
|
4112
|
+
_reviewMerge_decorators = [Remote];
|
|
4113
|
+
_reviewRerunChecks_decorators = [Remote];
|
|
4114
|
+
_reviewRequestReviews_decorators = [Remote];
|
|
4115
|
+
_reviewReviewerCandidates_decorators = [Remote];
|
|
4116
|
+
_reviewUpdateBranch_decorators = [Remote];
|
|
4117
|
+
_reviewStage_decorators = [Remote];
|
|
3057
4118
|
_worktreeCleanup_decorators = [Remote];
|
|
3058
|
-
|
|
4119
|
+
_worktreeBases_decorators = [Remote];
|
|
3059
4120
|
_diffBases_decorators = [Remote];
|
|
3060
4121
|
_track_decorators = [Remote];
|
|
3061
4122
|
_dismiss_decorators = [Remote];
|
|
3062
4123
|
_refresh_decorators = [Remote];
|
|
4124
|
+
_revisit_decorators = [Remote];
|
|
3063
4125
|
_localDiff_decorators = [Remote];
|
|
3064
4126
|
_localCommits_decorators = [Remote];
|
|
3065
4127
|
_localText_decorators = [Remote];
|
|
@@ -3067,6 +4129,8 @@ let ForgePanelController = (() => {
|
|
|
3067
4129
|
_changeRequestCommits_decorators = [Remote];
|
|
3068
4130
|
_changeRequestDiff_decorators = [Remote];
|
|
3069
4131
|
_changeRequestText_decorators = [Remote];
|
|
4132
|
+
_extensions_decorators = [Remote({ mode: "stream" })];
|
|
4133
|
+
_changesLens_decorators = [Remote({ mode: "stream" })];
|
|
3070
4134
|
_changeRequestViewed_decorators = [Remote];
|
|
3071
4135
|
_setFileViewed_decorators = [Remote];
|
|
3072
4136
|
_changeRequestReview_decorators = [Remote];
|
|
@@ -3106,244 +4170,519 @@ let ForgePanelController = (() => {
|
|
|
3106
4170
|
},
|
|
3107
4171
|
metadata: _metadata
|
|
3108
4172
|
}, null, _instanceExtraInitializers);
|
|
3109
|
-
__esDecorate(this, null,
|
|
4173
|
+
__esDecorate(this, null, _reviewLists_decorators, {
|
|
3110
4174
|
kind: "method",
|
|
3111
|
-
name: "
|
|
4175
|
+
name: "reviewLists",
|
|
3112
4176
|
static: false,
|
|
3113
4177
|
private: false,
|
|
3114
4178
|
access: {
|
|
3115
|
-
has: (obj) => "
|
|
3116
|
-
get: (obj) => obj.
|
|
4179
|
+
has: (obj) => "reviewLists" in obj,
|
|
4180
|
+
get: (obj) => obj.reviewLists
|
|
3117
4181
|
},
|
|
3118
4182
|
metadata: _metadata
|
|
3119
4183
|
}, null, _instanceExtraInitializers);
|
|
3120
|
-
__esDecorate(this, null,
|
|
4184
|
+
__esDecorate(this, null, _reviewCount_decorators, {
|
|
3121
4185
|
kind: "method",
|
|
3122
|
-
name: "
|
|
4186
|
+
name: "reviewCount",
|
|
3123
4187
|
static: false,
|
|
3124
4188
|
private: false,
|
|
3125
4189
|
access: {
|
|
3126
|
-
has: (obj) => "
|
|
3127
|
-
get: (obj) => obj.
|
|
4190
|
+
has: (obj) => "reviewCount" in obj,
|
|
4191
|
+
get: (obj) => obj.reviewCount
|
|
3128
4192
|
},
|
|
3129
4193
|
metadata: _metadata
|
|
3130
4194
|
}, null, _instanceExtraInitializers);
|
|
3131
|
-
__esDecorate(this, null,
|
|
4195
|
+
__esDecorate(this, null, _reviewRefresh_decorators, {
|
|
3132
4196
|
kind: "method",
|
|
3133
|
-
name: "
|
|
4197
|
+
name: "reviewRefresh",
|
|
3134
4198
|
static: false,
|
|
3135
4199
|
private: false,
|
|
3136
4200
|
access: {
|
|
3137
|
-
has: (obj) => "
|
|
3138
|
-
get: (obj) => obj.
|
|
4201
|
+
has: (obj) => "reviewRefresh" in obj,
|
|
4202
|
+
get: (obj) => obj.reviewRefresh
|
|
3139
4203
|
},
|
|
3140
4204
|
metadata: _metadata
|
|
3141
4205
|
}, null, _instanceExtraInitializers);
|
|
3142
|
-
__esDecorate(this, null,
|
|
4206
|
+
__esDecorate(this, null, _reviewPoll_decorators, {
|
|
3143
4207
|
kind: "method",
|
|
3144
|
-
name: "
|
|
4208
|
+
name: "reviewPoll",
|
|
3145
4209
|
static: false,
|
|
3146
4210
|
private: false,
|
|
3147
4211
|
access: {
|
|
3148
|
-
has: (obj) => "
|
|
3149
|
-
get: (obj) => obj.
|
|
4212
|
+
has: (obj) => "reviewPoll" in obj,
|
|
4213
|
+
get: (obj) => obj.reviewPoll
|
|
3150
4214
|
},
|
|
3151
4215
|
metadata: _metadata
|
|
3152
4216
|
}, null, _instanceExtraInitializers);
|
|
3153
|
-
__esDecorate(this, null,
|
|
4217
|
+
__esDecorate(this, null, _reviewChangeRequest_decorators, {
|
|
3154
4218
|
kind: "method",
|
|
3155
|
-
name: "
|
|
4219
|
+
name: "reviewChangeRequest",
|
|
3156
4220
|
static: false,
|
|
3157
4221
|
private: false,
|
|
3158
4222
|
access: {
|
|
3159
|
-
has: (obj) => "
|
|
3160
|
-
get: (obj) => obj.
|
|
4223
|
+
has: (obj) => "reviewChangeRequest" in obj,
|
|
4224
|
+
get: (obj) => obj.reviewChangeRequest
|
|
3161
4225
|
},
|
|
3162
4226
|
metadata: _metadata
|
|
3163
4227
|
}, null, _instanceExtraInitializers);
|
|
3164
|
-
__esDecorate(this, null,
|
|
4228
|
+
__esDecorate(this, null, _reviewDescription_decorators, {
|
|
3165
4229
|
kind: "method",
|
|
3166
|
-
name: "
|
|
4230
|
+
name: "reviewDescription",
|
|
3167
4231
|
static: false,
|
|
3168
4232
|
private: false,
|
|
3169
4233
|
access: {
|
|
3170
|
-
has: (obj) => "
|
|
3171
|
-
get: (obj) => obj.
|
|
4234
|
+
has: (obj) => "reviewDescription" in obj,
|
|
4235
|
+
get: (obj) => obj.reviewDescription
|
|
3172
4236
|
},
|
|
3173
4237
|
metadata: _metadata
|
|
3174
4238
|
}, null, _instanceExtraInitializers);
|
|
3175
|
-
__esDecorate(this, null,
|
|
4239
|
+
__esDecorate(this, null, _reviewChecks_decorators, {
|
|
3176
4240
|
kind: "method",
|
|
3177
|
-
name: "
|
|
4241
|
+
name: "reviewChecks",
|
|
3178
4242
|
static: false,
|
|
3179
4243
|
private: false,
|
|
3180
4244
|
access: {
|
|
3181
|
-
has: (obj) => "
|
|
3182
|
-
get: (obj) => obj.
|
|
4245
|
+
has: (obj) => "reviewChecks" in obj,
|
|
4246
|
+
get: (obj) => obj.reviewChecks
|
|
3183
4247
|
},
|
|
3184
4248
|
metadata: _metadata
|
|
3185
4249
|
}, null, _instanceExtraInitializers);
|
|
3186
|
-
__esDecorate(this, null,
|
|
4250
|
+
__esDecorate(this, null, _reviewThreads_decorators, {
|
|
3187
4251
|
kind: "method",
|
|
3188
|
-
name: "
|
|
4252
|
+
name: "reviewThreads",
|
|
3189
4253
|
static: false,
|
|
3190
4254
|
private: false,
|
|
3191
4255
|
access: {
|
|
3192
|
-
has: (obj) => "
|
|
3193
|
-
get: (obj) => obj.
|
|
4256
|
+
has: (obj) => "reviewThreads" in obj,
|
|
4257
|
+
get: (obj) => obj.reviewThreads
|
|
3194
4258
|
},
|
|
3195
4259
|
metadata: _metadata
|
|
3196
4260
|
}, null, _instanceExtraInitializers);
|
|
3197
|
-
__esDecorate(this, null,
|
|
4261
|
+
__esDecorate(this, null, _reviewThreadWrite_decorators, {
|
|
3198
4262
|
kind: "method",
|
|
3199
|
-
name: "
|
|
4263
|
+
name: "reviewThreadWrite",
|
|
3200
4264
|
static: false,
|
|
3201
4265
|
private: false,
|
|
3202
4266
|
access: {
|
|
3203
|
-
has: (obj) => "
|
|
3204
|
-
get: (obj) => obj.
|
|
4267
|
+
has: (obj) => "reviewThreadWrite" in obj,
|
|
4268
|
+
get: (obj) => obj.reviewThreadWrite
|
|
3205
4269
|
},
|
|
3206
4270
|
metadata: _metadata
|
|
3207
4271
|
}, null, _instanceExtraInitializers);
|
|
3208
|
-
__esDecorate(this, null,
|
|
4272
|
+
__esDecorate(this, null, _reviewSubmit_decorators, {
|
|
3209
4273
|
kind: "method",
|
|
3210
|
-
name: "
|
|
4274
|
+
name: "reviewSubmit",
|
|
3211
4275
|
static: false,
|
|
3212
4276
|
private: false,
|
|
3213
4277
|
access: {
|
|
3214
|
-
has: (obj) => "
|
|
3215
|
-
get: (obj) => obj.
|
|
4278
|
+
has: (obj) => "reviewSubmit" in obj,
|
|
4279
|
+
get: (obj) => obj.reviewSubmit
|
|
3216
4280
|
},
|
|
3217
4281
|
metadata: _metadata
|
|
3218
4282
|
}, null, _instanceExtraInitializers);
|
|
3219
|
-
__esDecorate(this, null,
|
|
4283
|
+
__esDecorate(this, null, _reviewDiff_decorators, {
|
|
3220
4284
|
kind: "method",
|
|
3221
|
-
name: "
|
|
4285
|
+
name: "reviewDiff",
|
|
3222
4286
|
static: false,
|
|
3223
4287
|
private: false,
|
|
3224
4288
|
access: {
|
|
3225
|
-
has: (obj) => "
|
|
3226
|
-
get: (obj) => obj.
|
|
4289
|
+
has: (obj) => "reviewDiff" in obj,
|
|
4290
|
+
get: (obj) => obj.reviewDiff
|
|
3227
4291
|
},
|
|
3228
4292
|
metadata: _metadata
|
|
3229
4293
|
}, null, _instanceExtraInitializers);
|
|
3230
|
-
__esDecorate(this, null,
|
|
4294
|
+
__esDecorate(this, null, _reviewCommits_decorators, {
|
|
3231
4295
|
kind: "method",
|
|
3232
|
-
name: "
|
|
4296
|
+
name: "reviewCommits",
|
|
3233
4297
|
static: false,
|
|
3234
4298
|
private: false,
|
|
3235
4299
|
access: {
|
|
3236
|
-
has: (obj) => "
|
|
3237
|
-
get: (obj) => obj.
|
|
4300
|
+
has: (obj) => "reviewCommits" in obj,
|
|
4301
|
+
get: (obj) => obj.reviewCommits
|
|
3238
4302
|
},
|
|
3239
4303
|
metadata: _metadata
|
|
3240
4304
|
}, null, _instanceExtraInitializers);
|
|
3241
|
-
__esDecorate(this, null,
|
|
4305
|
+
__esDecorate(this, null, _reviewText_decorators, {
|
|
3242
4306
|
kind: "method",
|
|
3243
|
-
name: "
|
|
4307
|
+
name: "reviewText",
|
|
3244
4308
|
static: false,
|
|
3245
4309
|
private: false,
|
|
3246
4310
|
access: {
|
|
3247
|
-
has: (obj) => "
|
|
3248
|
-
get: (obj) => obj.
|
|
4311
|
+
has: (obj) => "reviewText" in obj,
|
|
4312
|
+
get: (obj) => obj.reviewText
|
|
3249
4313
|
},
|
|
3250
4314
|
metadata: _metadata
|
|
3251
4315
|
}, null, _instanceExtraInitializers);
|
|
3252
|
-
__esDecorate(this, null,
|
|
4316
|
+
__esDecorate(this, null, _reviewViewed_decorators, {
|
|
3253
4317
|
kind: "method",
|
|
3254
|
-
name: "
|
|
4318
|
+
name: "reviewViewed",
|
|
3255
4319
|
static: false,
|
|
3256
4320
|
private: false,
|
|
3257
4321
|
access: {
|
|
3258
|
-
has: (obj) => "
|
|
3259
|
-
get: (obj) => obj.
|
|
4322
|
+
has: (obj) => "reviewViewed" in obj,
|
|
4323
|
+
get: (obj) => obj.reviewViewed
|
|
3260
4324
|
},
|
|
3261
4325
|
metadata: _metadata
|
|
3262
4326
|
}, null, _instanceExtraInitializers);
|
|
3263
|
-
__esDecorate(this, null,
|
|
4327
|
+
__esDecorate(this, null, _reviewSetViewed_decorators, {
|
|
3264
4328
|
kind: "method",
|
|
3265
|
-
name: "
|
|
4329
|
+
name: "reviewSetViewed",
|
|
3266
4330
|
static: false,
|
|
3267
4331
|
private: false,
|
|
3268
4332
|
access: {
|
|
3269
|
-
has: (obj) => "
|
|
3270
|
-
get: (obj) => obj.
|
|
4333
|
+
has: (obj) => "reviewSetViewed" in obj,
|
|
4334
|
+
get: (obj) => obj.reviewSetViewed
|
|
3271
4335
|
},
|
|
3272
4336
|
metadata: _metadata
|
|
3273
4337
|
}, null, _instanceExtraInitializers);
|
|
3274
|
-
__esDecorate(this, null,
|
|
4338
|
+
__esDecorate(this, null, _reviewMarkReady_decorators, {
|
|
3275
4339
|
kind: "method",
|
|
3276
|
-
name: "
|
|
4340
|
+
name: "reviewMarkReady",
|
|
3277
4341
|
static: false,
|
|
3278
4342
|
private: false,
|
|
3279
4343
|
access: {
|
|
3280
|
-
has: (obj) => "
|
|
3281
|
-
get: (obj) => obj.
|
|
4344
|
+
has: (obj) => "reviewMarkReady" in obj,
|
|
4345
|
+
get: (obj) => obj.reviewMarkReady
|
|
3282
4346
|
},
|
|
3283
4347
|
metadata: _metadata
|
|
3284
4348
|
}, null, _instanceExtraInitializers);
|
|
3285
|
-
__esDecorate(this, null,
|
|
4349
|
+
__esDecorate(this, null, _reviewMerge_decorators, {
|
|
3286
4350
|
kind: "method",
|
|
3287
|
-
name: "
|
|
4351
|
+
name: "reviewMerge",
|
|
3288
4352
|
static: false,
|
|
3289
4353
|
private: false,
|
|
3290
4354
|
access: {
|
|
3291
|
-
has: (obj) => "
|
|
3292
|
-
get: (obj) => obj.
|
|
4355
|
+
has: (obj) => "reviewMerge" in obj,
|
|
4356
|
+
get: (obj) => obj.reviewMerge
|
|
3293
4357
|
},
|
|
3294
4358
|
metadata: _metadata
|
|
3295
4359
|
}, null, _instanceExtraInitializers);
|
|
3296
|
-
__esDecorate(this, null,
|
|
4360
|
+
__esDecorate(this, null, _reviewRerunChecks_decorators, {
|
|
3297
4361
|
kind: "method",
|
|
3298
|
-
name: "
|
|
4362
|
+
name: "reviewRerunChecks",
|
|
3299
4363
|
static: false,
|
|
3300
4364
|
private: false,
|
|
3301
4365
|
access: {
|
|
3302
|
-
has: (obj) => "
|
|
3303
|
-
get: (obj) => obj.
|
|
4366
|
+
has: (obj) => "reviewRerunChecks" in obj,
|
|
4367
|
+
get: (obj) => obj.reviewRerunChecks
|
|
3304
4368
|
},
|
|
3305
4369
|
metadata: _metadata
|
|
3306
4370
|
}, null, _instanceExtraInitializers);
|
|
3307
|
-
__esDecorate(this, null,
|
|
4371
|
+
__esDecorate(this, null, _reviewRequestReviews_decorators, {
|
|
3308
4372
|
kind: "method",
|
|
3309
|
-
name: "
|
|
4373
|
+
name: "reviewRequestReviews",
|
|
3310
4374
|
static: false,
|
|
3311
4375
|
private: false,
|
|
3312
4376
|
access: {
|
|
3313
|
-
has: (obj) => "
|
|
3314
|
-
get: (obj) => obj.
|
|
4377
|
+
has: (obj) => "reviewRequestReviews" in obj,
|
|
4378
|
+
get: (obj) => obj.reviewRequestReviews
|
|
3315
4379
|
},
|
|
3316
4380
|
metadata: _metadata
|
|
3317
4381
|
}, null, _instanceExtraInitializers);
|
|
3318
|
-
__esDecorate(this, null,
|
|
4382
|
+
__esDecorate(this, null, _reviewReviewerCandidates_decorators, {
|
|
3319
4383
|
kind: "method",
|
|
3320
|
-
name: "
|
|
4384
|
+
name: "reviewReviewerCandidates",
|
|
3321
4385
|
static: false,
|
|
3322
4386
|
private: false,
|
|
3323
4387
|
access: {
|
|
3324
|
-
has: (obj) => "
|
|
3325
|
-
get: (obj) => obj.
|
|
4388
|
+
has: (obj) => "reviewReviewerCandidates" in obj,
|
|
4389
|
+
get: (obj) => obj.reviewReviewerCandidates
|
|
3326
4390
|
},
|
|
3327
4391
|
metadata: _metadata
|
|
3328
4392
|
}, null, _instanceExtraInitializers);
|
|
3329
|
-
__esDecorate(this, null,
|
|
4393
|
+
__esDecorate(this, null, _reviewUpdateBranch_decorators, {
|
|
3330
4394
|
kind: "method",
|
|
3331
|
-
name: "
|
|
4395
|
+
name: "reviewUpdateBranch",
|
|
3332
4396
|
static: false,
|
|
3333
4397
|
private: false,
|
|
3334
4398
|
access: {
|
|
3335
|
-
has: (obj) => "
|
|
3336
|
-
get: (obj) => obj.
|
|
4399
|
+
has: (obj) => "reviewUpdateBranch" in obj,
|
|
4400
|
+
get: (obj) => obj.reviewUpdateBranch
|
|
3337
4401
|
},
|
|
3338
4402
|
metadata: _metadata
|
|
3339
4403
|
}, null, _instanceExtraInitializers);
|
|
3340
|
-
__esDecorate(this, null,
|
|
4404
|
+
__esDecorate(this, null, _reviewStage_decorators, {
|
|
3341
4405
|
kind: "method",
|
|
3342
|
-
name: "
|
|
4406
|
+
name: "reviewStage",
|
|
3343
4407
|
static: false,
|
|
3344
4408
|
private: false,
|
|
3345
4409
|
access: {
|
|
3346
|
-
has: (obj) => "
|
|
4410
|
+
has: (obj) => "reviewStage" in obj,
|
|
4411
|
+
get: (obj) => obj.reviewStage
|
|
4412
|
+
},
|
|
4413
|
+
metadata: _metadata
|
|
4414
|
+
}, null, _instanceExtraInitializers);
|
|
4415
|
+
__esDecorate(this, null, _worktreeCleanup_decorators, {
|
|
4416
|
+
kind: "method",
|
|
4417
|
+
name: "worktreeCleanup",
|
|
4418
|
+
static: false,
|
|
4419
|
+
private: false,
|
|
4420
|
+
access: {
|
|
4421
|
+
has: (obj) => "worktreeCleanup" in obj,
|
|
4422
|
+
get: (obj) => obj.worktreeCleanup
|
|
4423
|
+
},
|
|
4424
|
+
metadata: _metadata
|
|
4425
|
+
}, null, _instanceExtraInitializers);
|
|
4426
|
+
__esDecorate(this, null, _worktreeBases_decorators, {
|
|
4427
|
+
kind: "method",
|
|
4428
|
+
name: "worktreeBases",
|
|
4429
|
+
static: false,
|
|
4430
|
+
private: false,
|
|
4431
|
+
access: {
|
|
4432
|
+
has: (obj) => "worktreeBases" in obj,
|
|
4433
|
+
get: (obj) => obj.worktreeBases
|
|
4434
|
+
},
|
|
4435
|
+
metadata: _metadata
|
|
4436
|
+
}, null, _instanceExtraInitializers);
|
|
4437
|
+
__esDecorate(this, null, _diffBases_decorators, {
|
|
4438
|
+
kind: "method",
|
|
4439
|
+
name: "diffBases",
|
|
4440
|
+
static: false,
|
|
4441
|
+
private: false,
|
|
4442
|
+
access: {
|
|
4443
|
+
has: (obj) => "diffBases" in obj,
|
|
4444
|
+
get: (obj) => obj.diffBases
|
|
4445
|
+
},
|
|
4446
|
+
metadata: _metadata
|
|
4447
|
+
}, null, _instanceExtraInitializers);
|
|
4448
|
+
__esDecorate(this, null, _track_decorators, {
|
|
4449
|
+
kind: "method",
|
|
4450
|
+
name: "track",
|
|
4451
|
+
static: false,
|
|
4452
|
+
private: false,
|
|
4453
|
+
access: {
|
|
4454
|
+
has: (obj) => "track" in obj,
|
|
4455
|
+
get: (obj) => obj.track
|
|
4456
|
+
},
|
|
4457
|
+
metadata: _metadata
|
|
4458
|
+
}, null, _instanceExtraInitializers);
|
|
4459
|
+
__esDecorate(this, null, _dismiss_decorators, {
|
|
4460
|
+
kind: "method",
|
|
4461
|
+
name: "dismiss",
|
|
4462
|
+
static: false,
|
|
4463
|
+
private: false,
|
|
4464
|
+
access: {
|
|
4465
|
+
has: (obj) => "dismiss" in obj,
|
|
4466
|
+
get: (obj) => obj.dismiss
|
|
4467
|
+
},
|
|
4468
|
+
metadata: _metadata
|
|
4469
|
+
}, null, _instanceExtraInitializers);
|
|
4470
|
+
__esDecorate(this, null, _refresh_decorators, {
|
|
4471
|
+
kind: "method",
|
|
4472
|
+
name: "refresh",
|
|
4473
|
+
static: false,
|
|
4474
|
+
private: false,
|
|
4475
|
+
access: {
|
|
4476
|
+
has: (obj) => "refresh" in obj,
|
|
4477
|
+
get: (obj) => obj.refresh
|
|
4478
|
+
},
|
|
4479
|
+
metadata: _metadata
|
|
4480
|
+
}, null, _instanceExtraInitializers);
|
|
4481
|
+
__esDecorate(this, null, _revisit_decorators, {
|
|
4482
|
+
kind: "method",
|
|
4483
|
+
name: "revisit",
|
|
4484
|
+
static: false,
|
|
4485
|
+
private: false,
|
|
4486
|
+
access: {
|
|
4487
|
+
has: (obj) => "revisit" in obj,
|
|
4488
|
+
get: (obj) => obj.revisit
|
|
4489
|
+
},
|
|
4490
|
+
metadata: _metadata
|
|
4491
|
+
}, null, _instanceExtraInitializers);
|
|
4492
|
+
__esDecorate(this, null, _localDiff_decorators, {
|
|
4493
|
+
kind: "method",
|
|
4494
|
+
name: "localDiff",
|
|
4495
|
+
static: false,
|
|
4496
|
+
private: false,
|
|
4497
|
+
access: {
|
|
4498
|
+
has: (obj) => "localDiff" in obj,
|
|
4499
|
+
get: (obj) => obj.localDiff
|
|
4500
|
+
},
|
|
4501
|
+
metadata: _metadata
|
|
4502
|
+
}, null, _instanceExtraInitializers);
|
|
4503
|
+
__esDecorate(this, null, _localCommits_decorators, {
|
|
4504
|
+
kind: "method",
|
|
4505
|
+
name: "localCommits",
|
|
4506
|
+
static: false,
|
|
4507
|
+
private: false,
|
|
4508
|
+
access: {
|
|
4509
|
+
has: (obj) => "localCommits" in obj,
|
|
4510
|
+
get: (obj) => obj.localCommits
|
|
4511
|
+
},
|
|
4512
|
+
metadata: _metadata
|
|
4513
|
+
}, null, _instanceExtraInitializers);
|
|
4514
|
+
__esDecorate(this, null, _localText_decorators, {
|
|
4515
|
+
kind: "method",
|
|
4516
|
+
name: "localText",
|
|
4517
|
+
static: false,
|
|
4518
|
+
private: false,
|
|
4519
|
+
access: {
|
|
4520
|
+
has: (obj) => "localText" in obj,
|
|
4521
|
+
get: (obj) => obj.localText
|
|
4522
|
+
},
|
|
4523
|
+
metadata: _metadata
|
|
4524
|
+
}, null, _instanceExtraInitializers);
|
|
4525
|
+
__esDecorate(this, null, _changeRequestChecks_decorators, {
|
|
4526
|
+
kind: "method",
|
|
4527
|
+
name: "changeRequestChecks",
|
|
4528
|
+
static: false,
|
|
4529
|
+
private: false,
|
|
4530
|
+
access: {
|
|
4531
|
+
has: (obj) => "changeRequestChecks" in obj,
|
|
4532
|
+
get: (obj) => obj.changeRequestChecks
|
|
4533
|
+
},
|
|
4534
|
+
metadata: _metadata
|
|
4535
|
+
}, null, _instanceExtraInitializers);
|
|
4536
|
+
__esDecorate(this, null, _changeRequestCommits_decorators, {
|
|
4537
|
+
kind: "method",
|
|
4538
|
+
name: "changeRequestCommits",
|
|
4539
|
+
static: false,
|
|
4540
|
+
private: false,
|
|
4541
|
+
access: {
|
|
4542
|
+
has: (obj) => "changeRequestCommits" in obj,
|
|
4543
|
+
get: (obj) => obj.changeRequestCommits
|
|
4544
|
+
},
|
|
4545
|
+
metadata: _metadata
|
|
4546
|
+
}, null, _instanceExtraInitializers);
|
|
4547
|
+
__esDecorate(this, null, _changeRequestDiff_decorators, {
|
|
4548
|
+
kind: "method",
|
|
4549
|
+
name: "changeRequestDiff",
|
|
4550
|
+
static: false,
|
|
4551
|
+
private: false,
|
|
4552
|
+
access: {
|
|
4553
|
+
has: (obj) => "changeRequestDiff" in obj,
|
|
4554
|
+
get: (obj) => obj.changeRequestDiff
|
|
4555
|
+
},
|
|
4556
|
+
metadata: _metadata
|
|
4557
|
+
}, null, _instanceExtraInitializers);
|
|
4558
|
+
__esDecorate(this, null, _changeRequestText_decorators, {
|
|
4559
|
+
kind: "method",
|
|
4560
|
+
name: "changeRequestText",
|
|
4561
|
+
static: false,
|
|
4562
|
+
private: false,
|
|
4563
|
+
access: {
|
|
4564
|
+
has: (obj) => "changeRequestText" in obj,
|
|
4565
|
+
get: (obj) => obj.changeRequestText
|
|
4566
|
+
},
|
|
4567
|
+
metadata: _metadata
|
|
4568
|
+
}, null, _instanceExtraInitializers);
|
|
4569
|
+
__esDecorate(this, null, _extensions_decorators, {
|
|
4570
|
+
kind: "method",
|
|
4571
|
+
name: "extensions",
|
|
4572
|
+
static: false,
|
|
4573
|
+
private: false,
|
|
4574
|
+
access: {
|
|
4575
|
+
has: (obj) => "extensions" in obj,
|
|
4576
|
+
get: (obj) => obj.extensions
|
|
4577
|
+
},
|
|
4578
|
+
metadata: _metadata
|
|
4579
|
+
}, null, _instanceExtraInitializers);
|
|
4580
|
+
__esDecorate(this, null, _changesLens_decorators, {
|
|
4581
|
+
kind: "method",
|
|
4582
|
+
name: "changesLens",
|
|
4583
|
+
static: false,
|
|
4584
|
+
private: false,
|
|
4585
|
+
access: {
|
|
4586
|
+
has: (obj) => "changesLens" in obj,
|
|
4587
|
+
get: (obj) => obj.changesLens
|
|
4588
|
+
},
|
|
4589
|
+
metadata: _metadata
|
|
4590
|
+
}, null, _instanceExtraInitializers);
|
|
4591
|
+
__esDecorate(this, null, _changeRequestViewed_decorators, {
|
|
4592
|
+
kind: "method",
|
|
4593
|
+
name: "changeRequestViewed",
|
|
4594
|
+
static: false,
|
|
4595
|
+
private: false,
|
|
4596
|
+
access: {
|
|
4597
|
+
has: (obj) => "changeRequestViewed" in obj,
|
|
4598
|
+
get: (obj) => obj.changeRequestViewed
|
|
4599
|
+
},
|
|
4600
|
+
metadata: _metadata
|
|
4601
|
+
}, null, _instanceExtraInitializers);
|
|
4602
|
+
__esDecorate(this, null, _setFileViewed_decorators, {
|
|
4603
|
+
kind: "method",
|
|
4604
|
+
name: "setFileViewed",
|
|
4605
|
+
static: false,
|
|
4606
|
+
private: false,
|
|
4607
|
+
access: {
|
|
4608
|
+
has: (obj) => "setFileViewed" in obj,
|
|
4609
|
+
get: (obj) => obj.setFileViewed
|
|
4610
|
+
},
|
|
4611
|
+
metadata: _metadata
|
|
4612
|
+
}, null, _instanceExtraInitializers);
|
|
4613
|
+
__esDecorate(this, null, _changeRequestReview_decorators, {
|
|
4614
|
+
kind: "method",
|
|
4615
|
+
name: "changeRequestReview",
|
|
4616
|
+
static: false,
|
|
4617
|
+
private: false,
|
|
4618
|
+
access: {
|
|
4619
|
+
has: (obj) => "changeRequestReview" in obj,
|
|
4620
|
+
get: (obj) => obj.changeRequestReview
|
|
4621
|
+
},
|
|
4622
|
+
metadata: _metadata
|
|
4623
|
+
}, null, _instanceExtraInitializers);
|
|
4624
|
+
__esDecorate(this, null, _submitReview_decorators, {
|
|
4625
|
+
kind: "method",
|
|
4626
|
+
name: "submitReview",
|
|
4627
|
+
static: false,
|
|
4628
|
+
private: false,
|
|
4629
|
+
access: {
|
|
4630
|
+
has: (obj) => "submitReview" in obj,
|
|
4631
|
+
get: (obj) => obj.submitReview
|
|
4632
|
+
},
|
|
4633
|
+
metadata: _metadata
|
|
4634
|
+
}, null, _instanceExtraInitializers);
|
|
4635
|
+
__esDecorate(this, null, _changeRequestReviewWrite_decorators, {
|
|
4636
|
+
kind: "method",
|
|
4637
|
+
name: "changeRequestReviewWrite",
|
|
4638
|
+
static: false,
|
|
4639
|
+
private: false,
|
|
4640
|
+
access: {
|
|
4641
|
+
has: (obj) => "changeRequestReviewWrite" in obj,
|
|
4642
|
+
get: (obj) => obj.changeRequestReviewWrite
|
|
4643
|
+
},
|
|
4644
|
+
metadata: _metadata
|
|
4645
|
+
}, null, _instanceExtraInitializers);
|
|
4646
|
+
__esDecorate(this, null, _markReady_decorators, {
|
|
4647
|
+
kind: "method",
|
|
4648
|
+
name: "markReady",
|
|
4649
|
+
static: false,
|
|
4650
|
+
private: false,
|
|
4651
|
+
access: {
|
|
4652
|
+
has: (obj) => "markReady" in obj,
|
|
4653
|
+
get: (obj) => obj.markReady
|
|
4654
|
+
},
|
|
4655
|
+
metadata: _metadata
|
|
4656
|
+
}, null, _instanceExtraInitializers);
|
|
4657
|
+
__esDecorate(this, null, _merge_decorators, {
|
|
4658
|
+
kind: "method",
|
|
4659
|
+
name: "merge",
|
|
4660
|
+
static: false,
|
|
4661
|
+
private: false,
|
|
4662
|
+
access: {
|
|
4663
|
+
has: (obj) => "merge" in obj,
|
|
4664
|
+
get: (obj) => obj.merge
|
|
4665
|
+
},
|
|
4666
|
+
metadata: _metadata
|
|
4667
|
+
}, null, _instanceExtraInitializers);
|
|
4668
|
+
__esDecorate(this, null, _rerunChecks_decorators, {
|
|
4669
|
+
kind: "method",
|
|
4670
|
+
name: "rerunChecks",
|
|
4671
|
+
static: false,
|
|
4672
|
+
private: false,
|
|
4673
|
+
access: {
|
|
4674
|
+
has: (obj) => "rerunChecks" in obj,
|
|
4675
|
+
get: (obj) => obj.rerunChecks
|
|
4676
|
+
},
|
|
4677
|
+
metadata: _metadata
|
|
4678
|
+
}, null, _instanceExtraInitializers);
|
|
4679
|
+
__esDecorate(this, null, _requestReviews_decorators, {
|
|
4680
|
+
kind: "method",
|
|
4681
|
+
name: "requestReviews",
|
|
4682
|
+
static: false,
|
|
4683
|
+
private: false,
|
|
4684
|
+
access: {
|
|
4685
|
+
has: (obj) => "requestReviews" in obj,
|
|
3347
4686
|
get: (obj) => obj.requestReviews
|
|
3348
4687
|
},
|
|
3349
4688
|
metadata: _metadata
|
|
@@ -3469,17 +4808,39 @@ let ForgePanelController = (() => {
|
|
|
3469
4808
|
testPaths: z.array(z.string()).default([]),
|
|
3470
4809
|
interfacePaths: z.array(z.string()).default([]),
|
|
3471
4810
|
maxCachedReviewBytes: z.number().default(16777216),
|
|
3472
|
-
reviewRefreshMs: z.number().default(6e4)
|
|
4811
|
+
reviewRefreshMs: z.number().default(6e4),
|
|
4812
|
+
statusMaxAgeMs: z.number().default(1e4),
|
|
4813
|
+
lensTimeoutMs: z.number().default(6e4),
|
|
4814
|
+
maxLensReadBytes: z.number().default(33554432),
|
|
4815
|
+
maxCachedLensBytes: z.number().default(4194304),
|
|
4816
|
+
maxAnnotationsPerFile: z.number().default(100),
|
|
4817
|
+
reviewListIntervalMs: z.number().default(12e4),
|
|
4818
|
+
reviewCountIntervalMs: z.number().default(3e5),
|
|
4819
|
+
reviewMaxBackoffMs: z.number().default(18e5),
|
|
4820
|
+
reviewPageSize: z.number().default(50)
|
|
3473
4821
|
});
|
|
3474
4822
|
home = __runInitializers(this, _instanceExtraInitializers);
|
|
3475
4823
|
config;
|
|
3476
4824
|
panels = /* @__PURE__ */ new Map();
|
|
4825
|
+
/** What the last panel of a Session kept when its last follower left. */
|
|
4826
|
+
keptPanels = /* @__PURE__ */ new WeakMap();
|
|
3477
4827
|
worktreeStates;
|
|
3478
4828
|
creations;
|
|
3479
4829
|
patches;
|
|
3480
4830
|
layers;
|
|
3481
4831
|
reviews;
|
|
4832
|
+
/** The viewed marks read for each change request, by head commit. */
|
|
4833
|
+
viewed;
|
|
4834
|
+
lenses = new LensRegistry();
|
|
4835
|
+
lensResults;
|
|
4836
|
+
/** Review changes `forge/review-changed` announced per change request, which each panel entry reports. */
|
|
4837
|
+
reviewRevisions = /* @__PURE__ */ new Map();
|
|
3482
4838
|
states;
|
|
4839
|
+
viewerLists;
|
|
4840
|
+
/** The change request a review conversation's draft quotes, per Session, bound once its first message enters the inbox. */
|
|
4841
|
+
staged = /* @__PURE__ */ new Map();
|
|
4842
|
+
/** Review page streams of change requests shown in full, which a review change makes publish again. */
|
|
4843
|
+
reviewFollowers = /* @__PURE__ */ new Set();
|
|
3483
4844
|
stopPanels;
|
|
3484
4845
|
stopStates;
|
|
3485
4846
|
constructor(ctx, config) {
|
|
@@ -3491,7 +4852,12 @@ let ForgePanelController = (() => {
|
|
|
3491
4852
|
"graceMs",
|
|
3492
4853
|
"maxOutputBytes",
|
|
3493
4854
|
"readinessTimeoutMs",
|
|
3494
|
-
"reviewRefreshMs"
|
|
4855
|
+
"reviewRefreshMs",
|
|
4856
|
+
"statusMaxAgeMs",
|
|
4857
|
+
"lensTimeoutMs",
|
|
4858
|
+
"reviewListIntervalMs",
|
|
4859
|
+
"reviewCountIntervalMs",
|
|
4860
|
+
"reviewMaxBackoffMs"
|
|
3495
4861
|
]) {
|
|
3496
4862
|
const value = resolved[key];
|
|
3497
4863
|
if (!Number.isSafeInteger(value) || value <= 0 || value > MAX_TIMER_DELAY_MS) throw new Error(`forge-panel: ${key} must be a positive integer no greater than ${MAX_TIMER_DELAY_MS}`);
|
|
@@ -3502,15 +4868,25 @@ let ForgePanelController = (() => {
|
|
|
3502
4868
|
"maxUntrackedFiles",
|
|
3503
4869
|
"maxCachedDiffBytes",
|
|
3504
4870
|
"maxCommits",
|
|
3505
|
-
"maxCachedReviewBytes"
|
|
4871
|
+
"maxCachedReviewBytes",
|
|
4872
|
+
"maxLensReadBytes",
|
|
4873
|
+
"maxCachedLensBytes",
|
|
4874
|
+
"maxAnnotationsPerFile",
|
|
4875
|
+
"reviewPageSize"
|
|
3506
4876
|
]) if (!Number.isSafeInteger(resolved[key]) || resolved[key] <= 0) throw new Error(`forge-panel: ${key} must be a positive integer`);
|
|
3507
|
-
if (
|
|
4877
|
+
if (resolved.reviewMaxBackoffMs < Math.max(resolved.reviewListIntervalMs, resolved.reviewCountIntervalMs)) throw new Error("forge-panel: reviewMaxBackoffMs must be at least reviewListIntervalMs and reviewCountIntervalMs");
|
|
4878
|
+
if (branchNameProblem(`${resolved.worktreePrefix}0`) !== null) throw new Error("forge-panel: worktreePrefix must start a valid Git branch name");
|
|
3508
4879
|
for (const key of ["testPaths", "interfacePaths"]) if (resolved[key].some((glob) => glob.trim() === "")) throw new Error(`forge-panel: ${key} entries must not be empty`);
|
|
3509
4880
|
this.layers = new FileLayers(resolved.testPaths, resolved.interfacePaths);
|
|
3510
4881
|
this.home = ctx;
|
|
3511
4882
|
this.config = resolved;
|
|
3512
4883
|
this.patches = new PatchCache(resolved.maxCachedDiffBytes);
|
|
3513
4884
|
this.reviews = new ReviewCache(resolved.maxCachedReviewBytes, resolved.reviewRefreshMs);
|
|
4885
|
+
this.viewed = new ReviewCache(resolved.maxCachedReviewBytes, resolved.reviewRefreshMs);
|
|
4886
|
+
this.lensResults = new LensCache(resolved.maxCachedLensBytes);
|
|
4887
|
+
ctx.effect(() => () => {
|
|
4888
|
+
this.lenses.close();
|
|
4889
|
+
}, "forge-panel: lens streams");
|
|
3514
4890
|
this.stopPanels = ctx.effect(() => async () => {
|
|
3515
4891
|
const panels = [...this.panels.values()];
|
|
3516
4892
|
this.panels.clear();
|
|
@@ -3519,6 +4895,23 @@ let ForgePanelController = (() => {
|
|
|
3519
4895
|
this.stopStates = ctx.effect(() => async () => {
|
|
3520
4896
|
await this.states?.dispose();
|
|
3521
4897
|
}, "forge-panel: stop change request states");
|
|
4898
|
+
this.viewerLists = new ViewerLists({
|
|
4899
|
+
sources: () => ctx.forge.viewerSources(),
|
|
4900
|
+
list: async (forge, query, signal) => await ctx.forge.listForViewer(forge, query, signal),
|
|
4901
|
+
count: async (forge, host, signal) => await ctx.forge.countForViewer(forge, host, signal),
|
|
4902
|
+
report: (error) => {
|
|
4903
|
+
ctx.logger.warn(`forge-panel: reading a review list failed: ${String(error)}`);
|
|
4904
|
+
}
|
|
4905
|
+
}, {
|
|
4906
|
+
listIntervalMs: resolved.reviewListIntervalMs,
|
|
4907
|
+
countIntervalMs: resolved.reviewCountIntervalMs,
|
|
4908
|
+
maxBackoffMs: resolved.reviewMaxBackoffMs,
|
|
4909
|
+
pageSize: resolved.reviewPageSize
|
|
4910
|
+
});
|
|
4911
|
+
const viewerLists = this.viewerLists;
|
|
4912
|
+
ctx.effect(() => async () => {
|
|
4913
|
+
await viewerLists.dispose();
|
|
4914
|
+
}, "forge-panel: stop review lists");
|
|
3522
4915
|
}
|
|
3523
4916
|
async [Service.init]() {
|
|
3524
4917
|
const ctx = this.home;
|
|
@@ -3533,12 +4926,22 @@ let ForgePanelController = (() => {
|
|
|
3533
4926
|
this.creations = new WorktreeCreations(ctx, this.worktreeStates, this.config.worktreePrefix, (session) => {
|
|
3534
4927
|
this.panels.get(session)?.updateWorktree();
|
|
3535
4928
|
});
|
|
3536
|
-
const inbox = ctx.on("agent/inbox/inserted", ({ agent }) => {
|
|
3537
|
-
this.
|
|
4929
|
+
const inbox = ctx.on("agent/inbox/inserted", ({ agent, message }) => {
|
|
4930
|
+
this.bindStaged(agent.session);
|
|
4931
|
+
this.holdTurn(agent, message);
|
|
4932
|
+
});
|
|
4933
|
+
const providers = ctx.on("forge/providers-changed", () => {
|
|
4934
|
+
this.viewerLists.sourcesChanged();
|
|
3538
4935
|
});
|
|
3539
4936
|
const events = ctx.on("session/event", (session, event) => {
|
|
3540
4937
|
this.panels.get(session)?.observe(event);
|
|
3541
4938
|
});
|
|
4939
|
+
const disposed = ctx.on("session/disposed", (session) => {
|
|
4940
|
+
this.staged.delete(session.id);
|
|
4941
|
+
});
|
|
4942
|
+
const reviewChanges = ctx.on("forge/review-changed", (ref, change) => {
|
|
4943
|
+
this.reviewChanged(ref, change);
|
|
4944
|
+
});
|
|
3542
4945
|
const services = ctx.on("internal/service", (name) => {
|
|
3543
4946
|
if (name !== "worktrees") return;
|
|
3544
4947
|
for (const panel of this.panels.values()) panel.updateWorktree();
|
|
@@ -3548,6 +4951,9 @@ let ForgePanelController = (() => {
|
|
|
3548
4951
|
yield stateOwner.dispose;
|
|
3549
4952
|
yield inbox;
|
|
3550
4953
|
yield events;
|
|
4954
|
+
yield disposed;
|
|
4955
|
+
yield reviewChanges;
|
|
4956
|
+
yield providers;
|
|
3551
4957
|
yield services;
|
|
3552
4958
|
yield stopPanels;
|
|
3553
4959
|
yield stopStates;
|
|
@@ -3555,53 +4961,390 @@ let ForgePanelController = (() => {
|
|
|
3555
4961
|
}, "forge-panel: drain before releasing state");
|
|
3556
4962
|
}
|
|
3557
4963
|
/**
|
|
3558
|
-
* Stream the panel state of a Session: the current state first, then each
|
|
3559
|
-
* later state. Intermediate states may be skipped when the reader is slower
|
|
3560
|
-
* than the updates. The stream ends when `signal` aborts or the Remote stops.
|
|
3561
|
-
* @param session - Session to follow.
|
|
3562
|
-
* @param signal - ends the stream.
|
|
3563
|
-
* @returns panel states in publication order.
|
|
4964
|
+
* Stream the panel state of a Session: the current state first, then each
|
|
4965
|
+
* later state. Intermediate states may be skipped when the reader is slower
|
|
4966
|
+
* than the updates. The stream ends when `signal` aborts or the Remote stops.
|
|
4967
|
+
* @param session - Session to follow.
|
|
4968
|
+
* @param signal - ends the stream.
|
|
4969
|
+
* @returns panel states in publication order.
|
|
4970
|
+
*/
|
|
4971
|
+
async *follow(session, signal) {
|
|
4972
|
+
yield* this.panelOf(session).follow(signal);
|
|
4973
|
+
}
|
|
4974
|
+
/**
|
|
4975
|
+
* Stream the last known state of every change request that a listed
|
|
4976
|
+
* Session the caller may read binds: the stored states first, then each
|
|
4977
|
+
* state a poll changes or a new binding reveals. Listing reads no Session
|
|
4978
|
+
* log: loaded Sessions report their bindings, others the cached Session
|
|
4979
|
+
* summary, and a Session without one shows nothing until it is opened.
|
|
4980
|
+
* Closed requests are polled at the idle cadence so reopening is observed. The
|
|
4981
|
+
* stream ends when `signal` aborts or the Remote stops.
|
|
4982
|
+
* @param signal - ends the stream.
|
|
4983
|
+
* @returns frames in publication order.
|
|
4984
|
+
* @throws when the Host lacks the Session query, projection cache, storage, or Session store service.
|
|
4985
|
+
*/
|
|
4986
|
+
async *changeRequestStates(signal) {
|
|
4987
|
+
const access = this.ctx.get("remoteAccess");
|
|
4988
|
+
yield* this.changeRequestStatesHub().stream((id) => access === void 0 || access.allows({
|
|
4989
|
+
kind: "session",
|
|
4990
|
+
id
|
|
4991
|
+
}), signal);
|
|
4992
|
+
}
|
|
4993
|
+
/**
|
|
4994
|
+
* Stream the review page's lists of the signed-in user's open change requests on every host a provider lists them on:
|
|
4995
|
+
* the lists read so far first, then a frame after each read settles. Readers of one repository scope share one
|
|
4996
|
+
* reader, which reads every `reviewListIntervalMs` while some stream lasts and backs off after failed rounds up to
|
|
4997
|
+
* `reviewMaxBackoffMs`; nothing is read while no stream lasts. The stream ends when `signal` aborts or the Remote stops.
|
|
4998
|
+
* @param repository - one repository to list in, or null for every repository the user can read.
|
|
4999
|
+
* @param signal - ends the stream.
|
|
5000
|
+
* @returns frames, each complete.
|
|
5001
|
+
*/
|
|
5002
|
+
async *reviewLists(repository, signal) {
|
|
5003
|
+
yield* this.viewerLists.lists(repository, signal);
|
|
5004
|
+
}
|
|
5005
|
+
/**
|
|
5006
|
+
* Stream the number of open change requests that ask the signed-in user for a review, summed over the hosts read:
|
|
5007
|
+
* the latest count first, then each change. It is read every `reviewCountIntervalMs` while some stream lasts, and a
|
|
5008
|
+
* list stream of every repository updates it as well. The stream ends when `signal` aborts or the Remote stops.
|
|
5009
|
+
* @param signal - ends the stream.
|
|
5010
|
+
* @returns frames, each complete.
|
|
5011
|
+
*/
|
|
5012
|
+
async *reviewCount(signal) {
|
|
5013
|
+
yield* this.viewerLists.count(signal);
|
|
5014
|
+
}
|
|
5015
|
+
/**
|
|
5016
|
+
* Read every streamed review page list and the count again at once.
|
|
5017
|
+
* @param signal - request cancellation.
|
|
5018
|
+
*/
|
|
5019
|
+
async reviewRefresh(signal) {
|
|
5020
|
+
signal.throwIfAborted();
|
|
5021
|
+
this.viewerLists.refresh();
|
|
5022
|
+
}
|
|
5023
|
+
/**
|
|
5024
|
+
* Poll one change request the review page shows at once; its stream reports the result.
|
|
5025
|
+
* @param url - web URL of the change request.
|
|
5026
|
+
* @param signal - request cancellation.
|
|
5027
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL.
|
|
5028
|
+
*/
|
|
5029
|
+
async reviewPoll(url, signal) {
|
|
5030
|
+
signal.throwIfAborted();
|
|
5031
|
+
this.home.forge.refresh(this.served(url).ref);
|
|
5032
|
+
}
|
|
5033
|
+
/**
|
|
5034
|
+
* Stream one change request the review page shows in full: its latest polling result first, then each later result
|
|
5035
|
+
* and each review change `forge/review-changed` announces for it. The change request is polled through `ctx.forge`
|
|
5036
|
+
* while the stream lasts. Review page reads and actions name a change request by URL and need no Session binding, so
|
|
5037
|
+
* only callers that may use the Host's code host credentials reach them.
|
|
5038
|
+
* @param url - web URL of the change request.
|
|
5039
|
+
* @param signal - ends the stream.
|
|
5040
|
+
* @returns frames, each complete.
|
|
5041
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL.
|
|
5042
|
+
*/
|
|
5043
|
+
async *reviewChangeRequest(url, signal) {
|
|
5044
|
+
signal.throwIfAborted();
|
|
5045
|
+
const { ref } = this.served(url);
|
|
5046
|
+
const key = changeRequestKey(ref);
|
|
5047
|
+
const reader = new Reader(signal);
|
|
5048
|
+
let update = this.home.forge.latest(ref) ?? null;
|
|
5049
|
+
let snapshot = update !== null && "snapshot" in update ? update.snapshot : null;
|
|
5050
|
+
const emit = () => {
|
|
5051
|
+
const forge = this.home.forge.describe(ref.repository.forge) ?? null;
|
|
5052
|
+
reader.push({
|
|
5053
|
+
url,
|
|
5054
|
+
ref,
|
|
5055
|
+
forge,
|
|
5056
|
+
update,
|
|
5057
|
+
snapshot,
|
|
5058
|
+
reviewRevision: this.reviewRevisions.get(key) ?? 0
|
|
5059
|
+
});
|
|
5060
|
+
};
|
|
5061
|
+
const follower = {
|
|
5062
|
+
key,
|
|
5063
|
+
emit
|
|
5064
|
+
};
|
|
5065
|
+
this.reviewFollowers.add(follower);
|
|
5066
|
+
const stop = this.home.forge.watch(ref, (next) => {
|
|
5067
|
+
update = next;
|
|
5068
|
+
if ("snapshot" in next) snapshot = next.snapshot;
|
|
5069
|
+
emit();
|
|
5070
|
+
}, { maxAgeMs: this.config.statusMaxAgeMs });
|
|
5071
|
+
emit();
|
|
5072
|
+
try {
|
|
5073
|
+
yield* reader.frames();
|
|
5074
|
+
} finally {
|
|
5075
|
+
stop();
|
|
5076
|
+
this.reviewFollowers.delete(follower);
|
|
5077
|
+
reader.dispose();
|
|
5078
|
+
}
|
|
5079
|
+
}
|
|
5080
|
+
/**
|
|
5081
|
+
* Read the description and labels of a change request for the review page.
|
|
5082
|
+
* @param url - web URL of the change request.
|
|
5083
|
+
* @param signal - request cancellation.
|
|
5084
|
+
* @returns the description.
|
|
5085
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/description-failed` with the
|
|
5086
|
+
* host's reason when the host does not provide it.
|
|
5087
|
+
*/
|
|
5088
|
+
async reviewDescription(url, signal) {
|
|
5089
|
+
signal.throwIfAborted();
|
|
5090
|
+
const result = await this.home.forge.readDescription(this.served(url).ref, signal);
|
|
5091
|
+
if ("code" in result) throw new RemoteError("forgePanel/description-failed", result.message, {});
|
|
5092
|
+
return result;
|
|
5093
|
+
}
|
|
5094
|
+
/**
|
|
5095
|
+
* Read every check of a change request the review page shows.
|
|
5096
|
+
* @param url - web URL of the change request.
|
|
5097
|
+
* @param headSha - head commit whose checks the page shows.
|
|
5098
|
+
* @param signal - request cancellation.
|
|
5099
|
+
* @returns the snapshot with every check.
|
|
5100
|
+
* @throws as {@link ForgePanelController.changeRequestChecks} does, with `forgePanel/unrecognized-url` in place of
|
|
5101
|
+
* `forgePanel/not-bound`.
|
|
5102
|
+
*/
|
|
5103
|
+
async reviewChecks(url, headSha, signal) {
|
|
5104
|
+
signal.throwIfAborted();
|
|
5105
|
+
return await this.readChecks(this.served(url).ref, headSha, signal, () => {});
|
|
5106
|
+
}
|
|
5107
|
+
/**
|
|
5108
|
+
* Read the review threads of a change request the review page shows, at the head of its latest status.
|
|
5109
|
+
* @param url - web URL of the change request.
|
|
5110
|
+
* @param headSha - head commit the page shows.
|
|
5111
|
+
* @param fresh - whether to read from the host even when threads at this head and update time are kept.
|
|
5112
|
+
* @param signal - request cancellation.
|
|
5113
|
+
* @returns the threads at `headSha`.
|
|
5114
|
+
* @throws as {@link ForgePanelController.changeRequestReview} does, with `forgePanel/unrecognized-url` in place of
|
|
5115
|
+
* `forgePanel/not-bound`.
|
|
5116
|
+
*/
|
|
5117
|
+
async reviewThreads(url, headSha, fresh, signal) {
|
|
5118
|
+
signal.throwIfAborted();
|
|
5119
|
+
return await this.readThreads(this.served(url), headSha, fresh, signal);
|
|
5120
|
+
}
|
|
5121
|
+
/**
|
|
5122
|
+
* Write to the review threads or the pending review of a change request the review page shows.
|
|
5123
|
+
* @param url - web URL of the change request.
|
|
5124
|
+
* @param write - the write and the head commit the user saw.
|
|
5125
|
+
* @param signal - request cancellation.
|
|
5126
|
+
* @returns whether the host took the write, as {@link ForgePanelController.changeRequestReviewWrite} does.
|
|
5127
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; an error for an invalid write.
|
|
5128
|
+
*/
|
|
5129
|
+
async reviewThreadWrite(url, write, signal) {
|
|
5130
|
+
signal.throwIfAborted();
|
|
5131
|
+
return await this.writeThreads(this.served(url).ref, write, signal);
|
|
5132
|
+
}
|
|
5133
|
+
/**
|
|
5134
|
+
* Publish a line comment or a completed review on a change request the review page shows.
|
|
5135
|
+
* @param url - web URL of the change request.
|
|
5136
|
+
* @param request - reviewed head, ranges, plain text, and explicit review decision.
|
|
5137
|
+
* @param signal - request cancellation.
|
|
5138
|
+
* @returns confirmed publication or a typed failure, as {@link ForgePanelController.submitReview} does.
|
|
5139
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; an error for an invalid review.
|
|
5140
|
+
*/
|
|
5141
|
+
async reviewSubmit(url, request, signal) {
|
|
5142
|
+
signal.throwIfAborted();
|
|
5143
|
+
return await this.publishReview(this.served(url).ref, request, signal);
|
|
5144
|
+
}
|
|
5145
|
+
/**
|
|
5146
|
+
* Read the changes of a change request the review page shows, or of consecutive commits of it.
|
|
5147
|
+
* @param url - web URL of the change request.
|
|
5148
|
+
* @param commits - consecutive commits of the change request, or null for all of it.
|
|
5149
|
+
* @param signal - request cancellation.
|
|
5150
|
+
* @returns the files and the commit they end at, without a local checkout count.
|
|
5151
|
+
* @throws as {@link ForgePanelController.changeRequestDiff} does, with `forgePanel/unrecognized-url` in place of
|
|
5152
|
+
* `forgePanel/not-bound`.
|
|
5153
|
+
*/
|
|
5154
|
+
async reviewDiff(url, commits, signal) {
|
|
5155
|
+
signal.throwIfAborted();
|
|
5156
|
+
return await this.readDiff(this.served(url), commits, signal, async () => await Promise.resolve(null));
|
|
5157
|
+
}
|
|
5158
|
+
/**
|
|
5159
|
+
* List the commits of a change request the review page shows.
|
|
5160
|
+
* @param url - web URL of the change request.
|
|
5161
|
+
* @param signal - request cancellation.
|
|
5162
|
+
* @returns the commits, or null when the provider does not read commits.
|
|
5163
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/diff-failed` when the host does
|
|
5164
|
+
* not list them.
|
|
5165
|
+
*/
|
|
5166
|
+
async reviewCommits(url, signal) {
|
|
5167
|
+
signal.throwIfAborted();
|
|
5168
|
+
const list = await this.home.forge.commits(this.served(url).ref, signal);
|
|
5169
|
+
if (list !== void 0 && "code" in list) throw readError(list);
|
|
5170
|
+
return list ?? null;
|
|
5171
|
+
}
|
|
5172
|
+
/**
|
|
5173
|
+
* Read one file of a change request's repository at a commit for the review page.
|
|
5174
|
+
* @param url - web URL of the change request.
|
|
5175
|
+
* @param commit - commit object name.
|
|
5176
|
+
* @param path - path relative to the repository root.
|
|
5177
|
+
* @param signal - request cancellation.
|
|
5178
|
+
* @returns the text.
|
|
5179
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/diff-too-large` or
|
|
5180
|
+
* `forgePanel/diff-failed` when the host does not provide the file.
|
|
5181
|
+
*/
|
|
5182
|
+
async reviewText(url, commit, path, signal) {
|
|
5183
|
+
signal.throwIfAborted();
|
|
5184
|
+
const text = await this.home.forge.fileText(this.served(url).ref, commit, path, signal);
|
|
5185
|
+
if (typeof text !== "string") throw readError(text);
|
|
5186
|
+
return text;
|
|
5187
|
+
}
|
|
5188
|
+
/**
|
|
5189
|
+
* Read the signed-in user's viewed marks on the files of a change request the review page shows, as
|
|
5190
|
+
* {@link ForgePanelController.changeRequestViewed} keeps them.
|
|
5191
|
+
* @param url - web URL of the change request.
|
|
5192
|
+
* @param headSha - head commit of the shown diff.
|
|
5193
|
+
* @param fresh - whether to read the host although kept marks could answer, as after a refresh.
|
|
5194
|
+
* @param signal - request cancellation.
|
|
5195
|
+
* @returns the marks, or null when the provider keeps no viewed marks.
|
|
5196
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head` or
|
|
5197
|
+
* `forgePanel/viewed-failed` as {@link ForgePanelController.changeRequestViewed} does.
|
|
5198
|
+
*/
|
|
5199
|
+
async reviewViewed(url, headSha, fresh, signal) {
|
|
5200
|
+
signal.throwIfAborted();
|
|
5201
|
+
return await this.readViewed(this.served(url).ref, headSha, fresh, signal);
|
|
5202
|
+
}
|
|
5203
|
+
/**
|
|
5204
|
+
* Set or clear the signed-in user's viewed mark on one file of a change request the review page shows.
|
|
5205
|
+
* @param url - web URL of the change request.
|
|
5206
|
+
* @param request - the file, its mark, and the head commit of the shown diff.
|
|
5207
|
+
* @param signal - request cancellation.
|
|
5208
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; the action errors of
|
|
5209
|
+
* {@link ForgePanelController.setFileViewed}.
|
|
5210
|
+
*/
|
|
5211
|
+
async reviewSetViewed(url, request, signal) {
|
|
5212
|
+
signal.throwIfAborted();
|
|
5213
|
+
await this.writeViewed(this.served(url).ref, request, signal);
|
|
5214
|
+
}
|
|
5215
|
+
/**
|
|
5216
|
+
* Mark a draft change request the review page shows ready for review.
|
|
5217
|
+
* @param url - web URL of the change request.
|
|
5218
|
+
* @param signal - request cancellation.
|
|
5219
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/action-failed` or
|
|
5220
|
+
* `forgePanel/action-unknown` with the host's reason.
|
|
5221
|
+
*/
|
|
5222
|
+
async reviewMarkReady(url, signal) {
|
|
5223
|
+
signal.throwIfAborted();
|
|
5224
|
+
const failure = await this.home.forge.markReady(this.served(url).ref, signal);
|
|
5225
|
+
if (failure !== void 0) throw actionError(failure);
|
|
5226
|
+
}
|
|
5227
|
+
/**
|
|
5228
|
+
* Merge a change request the review page shows while its head is still `headSha`.
|
|
5229
|
+
* @param url - web URL of the change request.
|
|
5230
|
+
* @param method - how the commits enter the base branch.
|
|
5231
|
+
* @param headSha - head commit the user confirmed.
|
|
5232
|
+
* @param signal - request cancellation.
|
|
5233
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head`,
|
|
5234
|
+
* `forgePanel/action-failed`, or `forgePanel/action-unknown` with the host's reason.
|
|
5235
|
+
*/
|
|
5236
|
+
async reviewMerge(url, method, headSha, signal) {
|
|
5237
|
+
signal.throwIfAborted();
|
|
5238
|
+
const failure = await this.home.forge.merge(this.served(url).ref, {
|
|
5239
|
+
method,
|
|
5240
|
+
headSha
|
|
5241
|
+
}, signal);
|
|
5242
|
+
if (failure !== void 0) throw actionError(failure);
|
|
5243
|
+
}
|
|
5244
|
+
/**
|
|
5245
|
+
* Rerun the failed checks of a change request the review page shows.
|
|
5246
|
+
* @param url - web URL of the change request.
|
|
5247
|
+
* @param request - the head commit whose checks the user saw.
|
|
5248
|
+
* @param signal - request cancellation.
|
|
5249
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head`,
|
|
5250
|
+
* `forgePanel/action-failed`, or `forgePanel/action-unknown` with the host's reason.
|
|
5251
|
+
*/
|
|
5252
|
+
async reviewRerunChecks(url, request, signal) {
|
|
5253
|
+
signal.throwIfAborted();
|
|
5254
|
+
const failure = await this.home.forge.rerunChecks(this.served(url).ref, request, signal);
|
|
5255
|
+
if (failure !== void 0) throw actionError(failure);
|
|
5256
|
+
}
|
|
5257
|
+
/**
|
|
5258
|
+
* Request reviews of a change request the review page shows from more reviewers.
|
|
5259
|
+
* @param url - web URL of the change request.
|
|
5260
|
+
* @param reviewers - the reviewers to ask, by kind and login.
|
|
5261
|
+
* @param signal - request cancellation.
|
|
5262
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/action-failed` or
|
|
5263
|
+
* `forgePanel/action-unknown` with the host's reason; an error without reviewers.
|
|
3564
5264
|
*/
|
|
3565
|
-
async
|
|
3566
|
-
|
|
5265
|
+
async reviewRequestReviews(url, reviewers, signal) {
|
|
5266
|
+
signal.throwIfAborted();
|
|
5267
|
+
await this.askReviews(this.served(url).ref, reviewers, signal);
|
|
3567
5268
|
}
|
|
3568
5269
|
/**
|
|
3569
|
-
*
|
|
3570
|
-
*
|
|
3571
|
-
*
|
|
3572
|
-
*
|
|
3573
|
-
*
|
|
3574
|
-
*
|
|
3575
|
-
*
|
|
3576
|
-
* @param signal - ends the stream.
|
|
3577
|
-
* @returns frames in publication order.
|
|
3578
|
-
* @throws when the Host lacks the Session query, projection cache, storage, or Session store service.
|
|
5270
|
+
* List accounts a review of a change request the review page shows can be requested from.
|
|
5271
|
+
* @param url - web URL of the change request.
|
|
5272
|
+
* @param query - text the login or name contains; empty for the host's suggestions.
|
|
5273
|
+
* @param signal - request cancellation.
|
|
5274
|
+
* @returns the accounts, the host's suggestions first.
|
|
5275
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/reviewers-failed` when the host
|
|
5276
|
+
* does not list them.
|
|
3579
5277
|
*/
|
|
3580
|
-
async
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
5278
|
+
async reviewReviewerCandidates(url, query, signal) {
|
|
5279
|
+
signal.throwIfAborted();
|
|
5280
|
+
return await this.candidatesOf(this.served(url).ref, query, signal);
|
|
5281
|
+
}
|
|
5282
|
+
/**
|
|
5283
|
+
* Bring the base branch's new commits into the head branch of a change request the review page shows.
|
|
5284
|
+
* @param url - web URL of the change request.
|
|
5285
|
+
* @param method - merge or rebase.
|
|
5286
|
+
* @param headSha - head commit the user confirmed.
|
|
5287
|
+
* @param signal - request cancellation.
|
|
5288
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head`,
|
|
5289
|
+
* `forgePanel/action-failed`, or `forgePanel/action-unknown` with the host's reason.
|
|
5290
|
+
*/
|
|
5291
|
+
async reviewUpdateBranch(url, method, headSha, signal) {
|
|
5292
|
+
signal.throwIfAborted();
|
|
5293
|
+
const failure = await this.home.forge.updateBranch(this.served(url).ref, {
|
|
5294
|
+
method,
|
|
5295
|
+
headSha
|
|
5296
|
+
}, signal);
|
|
5297
|
+
if (failure !== void 0) throw actionError(failure);
|
|
5298
|
+
}
|
|
5299
|
+
/**
|
|
5300
|
+
* Remember the change request a review conversation's draft quotes, or forget it with null. When the Session's next
|
|
5301
|
+
* message enters its inbox, the change request is bound to the Session with a `track` record before the turn starts;
|
|
5302
|
+
* a Session that already started is bound at its next message. The choice lives in memory until then.
|
|
5303
|
+
* @param sessionId - the Session whose draft quotes the change request; staging neither loads nor resumes it.
|
|
5304
|
+
* @param url - web URL of the change request, or null.
|
|
5305
|
+
* @param signal - request cancellation.
|
|
5306
|
+
* @throws `forgePanel/unrecognized-url` when no provider serves the URL.
|
|
5307
|
+
*/
|
|
5308
|
+
async reviewStage(sessionId, url, signal) {
|
|
5309
|
+
signal.throwIfAborted();
|
|
5310
|
+
if (url === null) {
|
|
5311
|
+
this.staged.delete(sessionId);
|
|
5312
|
+
return;
|
|
5313
|
+
}
|
|
5314
|
+
this.served(url);
|
|
5315
|
+
this.staged.set(sessionId, url);
|
|
3586
5316
|
}
|
|
3587
5317
|
/**
|
|
3588
5318
|
* Read or await the worktree service's archive cleanup of the Session's checkout.
|
|
3589
|
-
* @param
|
|
5319
|
+
* @param sessionId - Session whose cleanup is visible to the caller; reading neither loads nor resumes it.
|
|
3590
5320
|
* @param revision - null reads now; a matching revision waits for completion.
|
|
3591
5321
|
* @returns the cleanup state, or null without a worktree service, an attempt, or a current revision.
|
|
3592
5322
|
*/
|
|
3593
|
-
async worktreeCleanup(
|
|
3594
|
-
return await this.home.get("worktrees")?.cleanupOf(
|
|
5323
|
+
async worktreeCleanup(sessionId, revision) {
|
|
5324
|
+
return await this.home.get("worktrees")?.cleanupOf(sessionId, revision) ?? null;
|
|
3595
5325
|
}
|
|
3596
5326
|
/**
|
|
3597
|
-
* List the
|
|
3598
|
-
*
|
|
5327
|
+
* List the branches that can start a worktree of the Session's current checkout: the checked-out branch, each
|
|
5328
|
+
* remote's default branch, other local branches, and each remote's other remote-tracking branches, remotes in the
|
|
5329
|
+
* order the panel recognizes code hosts.
|
|
5330
|
+
* @param session - Session whose checkout is read.
|
|
5331
|
+
* @param query - text the branch names must contain, ignoring case; empty for every branch.
|
|
3599
5332
|
* @param signal - request cancellation.
|
|
3600
|
-
* @returns the
|
|
3601
|
-
* @throws
|
|
5333
|
+
* @returns the branches, at most `maxBranches` local branches and `maxBranches` per remote, most recently committed first.
|
|
5334
|
+
* @throws `forgePanel/not-a-checkout` outside a checkout; the Git error when Git fails or the listed refs exceed `maxDiffBytes`.
|
|
3602
5335
|
*/
|
|
3603
|
-
async
|
|
3604
|
-
|
|
5336
|
+
async worktreeBases(session, query, signal) {
|
|
5337
|
+
signal.throwIfAborted();
|
|
5338
|
+
const inspection = await this.checkoutOf(session, signal);
|
|
5339
|
+
return parseWorktreeBases((await gitIn(this.home, {
|
|
5340
|
+
...this.config,
|
|
5341
|
+
maxOutputBytes: this.config.maxDiffBytes
|
|
5342
|
+
}, session, inspection.checkout.root, signal)("worktree-bases", [
|
|
5343
|
+
"for-each-ref",
|
|
5344
|
+
"--sort=-committerdate",
|
|
5345
|
+
"--format=%(refname)%00%(symref)",
|
|
5346
|
+
...BASE_REF_PREFIXES
|
|
5347
|
+
])).stdout, inspection.checkout.branch, remoteOrder(inspection.upstream, inspection.remotes), query, this.config.maxBranches, (remote) => remoteRepository(remote, (url) => this.home.forge.repositoryFromRemote(url)));
|
|
3605
5348
|
}
|
|
3606
5349
|
/**
|
|
3607
5350
|
* List the branches the `branch` scope of the Session's current checkout can compare with.
|
|
@@ -3645,13 +5388,26 @@ let ForgePanelController = (() => {
|
|
|
3645
5388
|
/**
|
|
3646
5389
|
* Reinspect a followed Session's checkout, probe sign-in again, and poll its
|
|
3647
5390
|
* change requests at once; an unfollowed Session is unchanged.
|
|
3648
|
-
* @param
|
|
5391
|
+
* @param sessionId - Session whose panel refreshes; refreshing neither loads nor resumes it.
|
|
5392
|
+
* @param signal - request cancellation.
|
|
5393
|
+
* @returns settles once the inspection and the sign-in probe have ended; poll results reach the panel stream later.
|
|
5394
|
+
*/
|
|
5395
|
+
async refresh(sessionId, signal) {
|
|
5396
|
+
signal.throwIfAborted();
|
|
5397
|
+
for (const [session, panel] of this.panels) if (session.id === sessionId) await panel.refresh();
|
|
5398
|
+
}
|
|
5399
|
+
/**
|
|
5400
|
+
* Bring a followed Session's panel up to date after its surface showed again: reinspect the checkout, poll the
|
|
5401
|
+
* change requests whose latest poll is older than `statusMaxAgeMs`, probe sign-in again unless the last probe found
|
|
5402
|
+
* the host ready, and look the upstream branch up again while the Session shows no change request; an unfollowed
|
|
5403
|
+
* Session is unchanged.
|
|
5404
|
+
* @param sessionId - Session whose panel is revisited; revisiting neither loads nor resumes it.
|
|
3649
5405
|
* @param signal - request cancellation.
|
|
3650
5406
|
* @returns settles once the inspection and the sign-in probe have ended; poll results reach the panel stream later.
|
|
3651
5407
|
*/
|
|
3652
|
-
async
|
|
5408
|
+
async revisit(sessionId, signal) {
|
|
3653
5409
|
signal.throwIfAborted();
|
|
3654
|
-
|
|
5410
|
+
for (const [session, panel] of this.panels) if (session.id === sessionId) await panel.revisit();
|
|
3655
5411
|
}
|
|
3656
5412
|
/**
|
|
3657
5413
|
* Read the changes one scope covers in the checkout of the Session's
|
|
@@ -3728,11 +5484,9 @@ let ForgePanelController = (() => {
|
|
|
3728
5484
|
*/
|
|
3729
5485
|
async changeRequestChecks(session, url, headSha, signal) {
|
|
3730
5486
|
signal.throwIfAborted();
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
if (result.headSha !== headSha) throw new RemoteError("forgePanel/stale-head", "The change request head changed; refresh its status", {});
|
|
3735
|
-
return result;
|
|
5487
|
+
return await this.readChecks(this.bound(session, url).ref, headSha, signal, () => {
|
|
5488
|
+
this.bound(session, url);
|
|
5489
|
+
});
|
|
3736
5490
|
}
|
|
3737
5491
|
/**
|
|
3738
5492
|
* List the commits of a change request of a Session at its current head, which the changes view can show one or
|
|
@@ -3773,30 +5527,13 @@ let ForgePanelController = (() => {
|
|
|
3773
5527
|
*/
|
|
3774
5528
|
async changeRequestDiff(session, url, commits, signal) {
|
|
3775
5529
|
signal.throwIfAborted();
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
if (read === void 0) {
|
|
3784
|
-
read = await this.patchAt(ref, headSha, async (operation) => await this.home.forge.diff(ref, headSha, operation), signal);
|
|
3785
|
-
this.patches.set(key, version, read);
|
|
3786
|
-
}
|
|
3787
|
-
const files = this.layers.classify(parseDiff(read.patch), read.attributes);
|
|
3788
|
-
let localAhead = null;
|
|
3789
|
-
try {
|
|
3790
|
-
localAhead = await aheadOf(gitIn(this.home, this.config, session, this.home.workingDirectory.get(session), signal), headBranch, headSha);
|
|
3791
|
-
} catch (_error) {}
|
|
3792
|
-
signal.throwIfAborted();
|
|
3793
|
-
const fileUrls = Object.fromEntries(files.map((file) => [file.path, this.home.forge.fileUrl(ref, headSha, file.path)]));
|
|
3794
|
-
return {
|
|
3795
|
-
headSha,
|
|
3796
|
-
files,
|
|
3797
|
-
localAhead,
|
|
3798
|
-
fileUrls
|
|
3799
|
-
};
|
|
5530
|
+
return await this.readDiff(this.bound(session, url), commits, signal, async (headBranch, headSha) => {
|
|
5531
|
+
try {
|
|
5532
|
+
return await aheadOf(gitIn(this.home, this.config, session, this.home.workingDirectory.get(session), signal), headBranch, headSha);
|
|
5533
|
+
} catch (_error) {
|
|
5534
|
+
return null;
|
|
5535
|
+
}
|
|
5536
|
+
});
|
|
3800
5537
|
}
|
|
3801
5538
|
/**
|
|
3802
5539
|
* Read one file of a change request's repository at a commit, which
|
|
@@ -3818,23 +5555,106 @@ let ForgePanelController = (() => {
|
|
|
3818
5555
|
return text;
|
|
3819
5556
|
}
|
|
3820
5557
|
/**
|
|
5558
|
+
* Register a filter lens as an effect on the calling fiber. The changes views list it while it is registered; ending
|
|
5559
|
+
* the registration aborts its running classifications and waits for them.
|
|
5560
|
+
* @param lens - the lens.
|
|
5561
|
+
* @returns the disposer that unregisters the lens and waits for its classifications to stop.
|
|
5562
|
+
* @throws when another registration holds `lens.id`.
|
|
5563
|
+
*/
|
|
5564
|
+
registerLens(lens) {
|
|
5565
|
+
const dispose = this.ctx.effect(() => this.lenses.add(lens), "forge-panel: lens");
|
|
5566
|
+
return async () => {
|
|
5567
|
+
await dispose();
|
|
5568
|
+
};
|
|
5569
|
+
}
|
|
5570
|
+
/**
|
|
5571
|
+
* Stream the facts every changes view reads about the panel's extensions: the current facts first, then the facts
|
|
5572
|
+
* after each lens registration or withdrawal. The stream ends when `signal` aborts or the Remote stops.
|
|
5573
|
+
* @param signal - ends the stream.
|
|
5574
|
+
* @returns the registered lenses and the annotation limit, in publication order.
|
|
5575
|
+
*/
|
|
5576
|
+
async *extensions(signal) {
|
|
5577
|
+
for await (const lenses of this.lenses.follow(signal)) yield {
|
|
5578
|
+
lenses,
|
|
5579
|
+
maxAnnotationsPerFile: this.config.maxAnnotationsPerFile
|
|
5580
|
+
};
|
|
5581
|
+
}
|
|
5582
|
+
/**
|
|
5583
|
+
* Classify the files a changes view of a Session shows with one registered lens: progress frames while the lens
|
|
5584
|
+
* runs, then the files it keeps. Results for the same files, lens, and lens version are reused from memory until
|
|
5585
|
+
* `maxCachedLensBytes` evicts them. Local changes are read with the Session's permissions; a change request's files
|
|
5586
|
+
* are those `changeRequestDiff` reads.
|
|
5587
|
+
* @param session - Session whose checkout or binding the view shows.
|
|
5588
|
+
* @param request - the view's source, the version of the files it shows, and the lens.
|
|
5589
|
+
* @param signal - ends the classification.
|
|
5590
|
+
* @returns progress frames, then one result frame.
|
|
5591
|
+
* @throws `forgePanel/lens-missing` while no lens holds the identity or once its registration ends;
|
|
5592
|
+
* `forgePanel/lens-stale` before a change request's status was read, when the files differ from `request.version`, and
|
|
5593
|
+
* when local files changed while the lens ran;
|
|
5594
|
+
* `forgePanel/lens-failed` when the lens fails, runs past `lensTimeoutMs`, reads past `maxLensReadBytes`, or answers
|
|
5595
|
+
* over `maxCachedLensBytes`; the errors of `localDiff` and `changeRequestDiff` for the files.
|
|
5596
|
+
*/
|
|
5597
|
+
async *changesLens(session, request, signal) {
|
|
5598
|
+
signal.throwIfAborted();
|
|
5599
|
+
const registration = this.lenses.get(request.lens);
|
|
5600
|
+
if (registration === void 0) throw new RemoteError("forgePanel/lens-missing", `No lens "${request.lens}" is registered`, {});
|
|
5601
|
+
const subject = await this.lensSubject(session, request.source, signal);
|
|
5602
|
+
signal.throwIfAborted();
|
|
5603
|
+
if (registration.lifetime.aborted) throw new RemoteError("forgePanel/lens-missing", `No lens "${request.lens}" is registered`, {});
|
|
5604
|
+
if (lensVersion(subject.files) !== request.version) throw new RemoteError("forgePanel/lens-stale", "The changes were read again since the view showed them", {});
|
|
5605
|
+
const key = JSON.stringify([
|
|
5606
|
+
subject.key,
|
|
5607
|
+
request.version,
|
|
5608
|
+
request.lens,
|
|
5609
|
+
registration.lens.version
|
|
5610
|
+
]);
|
|
5611
|
+
const kept = this.lensResults.get(key);
|
|
5612
|
+
if (kept !== void 0) {
|
|
5613
|
+
yield {
|
|
5614
|
+
kind: "result",
|
|
5615
|
+
files: kept
|
|
5616
|
+
};
|
|
5617
|
+
return;
|
|
5618
|
+
}
|
|
5619
|
+
const limits = {
|
|
5620
|
+
timeoutMs: this.config.lensTimeoutMs,
|
|
5621
|
+
maxReadBytes: this.config.maxLensReadBytes,
|
|
5622
|
+
maxResultBytes: this.config.maxCachedLensBytes
|
|
5623
|
+
};
|
|
5624
|
+
try {
|
|
5625
|
+
for await (const frame of lensFrames((progress) => runLens(registration, subject, limits, signal, progress))) {
|
|
5626
|
+
if (frame.kind === "result") {
|
|
5627
|
+
if (request.source.kind === "local") {
|
|
5628
|
+
if (lensVersion((await this.lensSubject(session, request.source, signal)).files) !== request.version) throw new RemoteError("forgePanel/lens-stale", "The changes moved while the lens read them", {});
|
|
5629
|
+
}
|
|
5630
|
+
this.lensResults.set(key, frame.files);
|
|
5631
|
+
}
|
|
5632
|
+
yield frame;
|
|
5633
|
+
}
|
|
5634
|
+
} catch (error) {
|
|
5635
|
+
if (error instanceof LensWithdrawn) throw new RemoteError("forgePanel/lens-missing", error.message, {});
|
|
5636
|
+
if (error instanceof LensFailed) throw new RemoteError("forgePanel/lens-failed", error.message, {});
|
|
5637
|
+
throw error;
|
|
5638
|
+
}
|
|
5639
|
+
}
|
|
5640
|
+
/**
|
|
3821
5641
|
* Read the signed-in user's viewed marks on the files of a change request of a Session, which the host keeps for the
|
|
3822
|
-
* whole change request.
|
|
5642
|
+
* whole change request. Marks read at the same head are kept in memory and returned until they are `reviewRefreshMs`
|
|
5643
|
+
* old or `maxCachedReviewBytes` evicts them; a mark saved through `ctx.forge` at that head replaces the kept state
|
|
5644
|
+
* of its file, so the read after a save costs no request.
|
|
3823
5645
|
* @param session - Session the change request is bound to.
|
|
3824
5646
|
* @param url - binding URL of the change request.
|
|
3825
5647
|
* @param headSha - head commit of the shown diff; marks read at another head are refused.
|
|
5648
|
+
* @param fresh - whether to read the host although kept marks could answer, as after a refresh.
|
|
3826
5649
|
* @param signal - request cancellation.
|
|
3827
5650
|
* @returns the marks at `headSha`, or null when the provider keeps no viewed marks.
|
|
3828
5651
|
* @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
|
|
3829
5652
|
* `forgePanel/stale-head` when the head moved past `headSha`, which is then polled again; `forgePanel/viewed-failed`
|
|
3830
5653
|
* when the host does not provide the marks otherwise.
|
|
3831
5654
|
*/
|
|
3832
|
-
async changeRequestViewed(session, url, headSha, signal) {
|
|
5655
|
+
async changeRequestViewed(session, url, headSha, fresh, signal) {
|
|
3833
5656
|
signal.throwIfAborted();
|
|
3834
|
-
|
|
3835
|
-
if (result === void 0) return null;
|
|
3836
|
-
if ("code" in result) throw new RemoteError(result.code === "stale" ? "forgePanel/stale-head" : "forgePanel/viewed-failed", result.message, {});
|
|
3837
|
-
return result;
|
|
5657
|
+
return await this.readViewed(this.bound(session, url).ref, headSha, fresh, signal);
|
|
3838
5658
|
}
|
|
3839
5659
|
/**
|
|
3840
5660
|
* Set or clear the signed-in user's viewed mark on one file of a change request of a Session.
|
|
@@ -3849,10 +5669,7 @@ let ForgePanelController = (() => {
|
|
|
3849
5669
|
*/
|
|
3850
5670
|
async setFileViewed(session, url, request, signal) {
|
|
3851
5671
|
signal.throwIfAborted();
|
|
3852
|
-
|
|
3853
|
-
if (request.path === "") throw new Error("Invalid viewed file");
|
|
3854
|
-
const failure = await this.home.forge.setViewed(ref, request, signal);
|
|
3855
|
-
if (failure !== void 0) throw actionError(failure);
|
|
5672
|
+
await this.writeViewed(this.bound(session, url).ref, request, signal);
|
|
3856
5673
|
}
|
|
3857
5674
|
/**
|
|
3858
5675
|
* Read the review threads of a change request of a Session at the head commit of its displayed diff. Threads read
|
|
@@ -3874,19 +5691,7 @@ let ForgePanelController = (() => {
|
|
|
3874
5691
|
*/
|
|
3875
5692
|
async changeRequestReview(session, url, headSha, fresh, signal) {
|
|
3876
5693
|
signal.throwIfAborted();
|
|
3877
|
-
|
|
3878
|
-
if (update === null || !("snapshot" in update)) throw new RemoteError("forgePanel/review-failed", "The change request status has not been read yet", {});
|
|
3879
|
-
if (update.snapshot.headSha !== headSha) throw new RemoteError("forgePanel/stale-head", `The change request head moved from ${headSha} to ${update.snapshot.headSha}`, {});
|
|
3880
|
-
const key = changeRequestKey(ref);
|
|
3881
|
-
const version = JSON.stringify([headSha, update.snapshot.updatedAt]);
|
|
3882
|
-
const readAt = Date.now();
|
|
3883
|
-
const kept = fresh ? void 0 : this.reviews.get(key, version, readAt);
|
|
3884
|
-
if (kept !== void 0) return kept;
|
|
3885
|
-
const token = this.reviews.token();
|
|
3886
|
-
const review = await this.home.forge.readReview(ref, headSha, signal);
|
|
3887
|
-
if ("code" in review) throw reviewError(review);
|
|
3888
|
-
this.reviews.set(key, version, review, readAt, token);
|
|
3889
|
-
return review;
|
|
5694
|
+
return await this.readThreads(this.bound(session, url), headSha, fresh, signal);
|
|
3890
5695
|
}
|
|
3891
5696
|
/**
|
|
3892
5697
|
* Publish a line comment or completed review for a visible Session binding. The threads kept for the change request
|
|
@@ -3899,16 +5704,7 @@ let ForgePanelController = (() => {
|
|
|
3899
5704
|
*/
|
|
3900
5705
|
async submitReview(session, url, request, signal) {
|
|
3901
5706
|
signal.throwIfAborted();
|
|
3902
|
-
|
|
3903
|
-
if (!isCommit(request.headSha)) throw new Error("Invalid review commit");
|
|
3904
|
-
const comments = request.kind === "comment" ? [request.comment] : request.comments;
|
|
3905
|
-
if (!comments.every(validComment)) throw new Error("Invalid review comment");
|
|
3906
|
-
if (request.kind === "review" && request.event !== "approve" && request.body.trim() === "" && comments.length === 0) throw new Error("Empty review");
|
|
3907
|
-
try {
|
|
3908
|
-
return await this.home.forge.submitReview(ref, request, signal);
|
|
3909
|
-
} finally {
|
|
3910
|
-
this.reviews.drop(changeRequestKey(ref));
|
|
3911
|
-
}
|
|
5707
|
+
return await this.publishReview(this.bound(session, url).ref, request, signal);
|
|
3912
5708
|
}
|
|
3913
5709
|
/**
|
|
3914
5710
|
* Write to the review threads or the pending review of a change request of a Session while its head is still the
|
|
@@ -3925,14 +5721,7 @@ let ForgePanelController = (() => {
|
|
|
3925
5721
|
*/
|
|
3926
5722
|
async changeRequestReviewWrite(session, url, write, signal) {
|
|
3927
5723
|
signal.throwIfAborted();
|
|
3928
|
-
|
|
3929
|
-
if (!isCommit(write.headSha)) throw new Error("Invalid review commit");
|
|
3930
|
-
if (!validWrite(write)) throw new Error("Invalid review write");
|
|
3931
|
-
try {
|
|
3932
|
-
return await this.home.forge.writeReview(ref, write, signal);
|
|
3933
|
-
} finally {
|
|
3934
|
-
this.reviews.drop(changeRequestKey(ref));
|
|
3935
|
-
}
|
|
5724
|
+
return await this.writeThreads(this.bound(session, url).ref, write, signal);
|
|
3936
5725
|
}
|
|
3937
5726
|
/**
|
|
3938
5727
|
* Mark a draft change request of a Session ready for review; the change
|
|
@@ -3998,10 +5787,7 @@ let ForgePanelController = (() => {
|
|
|
3998
5787
|
*/
|
|
3999
5788
|
async requestReviews(session, url, reviewers, signal) {
|
|
4000
5789
|
signal.throwIfAborted();
|
|
4001
|
-
|
|
4002
|
-
if (reviewers.length === 0 || reviewers.some((reviewer) => reviewer.login.trim() === "")) throw new Error("Invalid reviewers");
|
|
4003
|
-
const failure = await this.home.forge.requestReviews(ref, { reviewers }, signal);
|
|
4004
|
-
if (failure !== void 0) throw actionError(failure);
|
|
5790
|
+
await this.askReviews(this.bound(session, url).ref, reviewers, signal);
|
|
4005
5791
|
}
|
|
4006
5792
|
/**
|
|
4007
5793
|
* List accounts a review of a change request of a Session can be requested from.
|
|
@@ -4015,9 +5801,7 @@ let ForgePanelController = (() => {
|
|
|
4015
5801
|
*/
|
|
4016
5802
|
async reviewerCandidates(session, url, query, signal) {
|
|
4017
5803
|
signal.throwIfAborted();
|
|
4018
|
-
|
|
4019
|
-
if ("code" in result) throw new RemoteError("forgePanel/reviewers-failed", result.message, {});
|
|
4020
|
-
return result;
|
|
5804
|
+
return await this.candidatesOf(this.bound(session, url).ref, query, signal);
|
|
4021
5805
|
}
|
|
4022
5806
|
/**
|
|
4023
5807
|
* Bring the base branch's new commits into the head branch of a change request of a Session while its head is still
|
|
@@ -4043,25 +5827,35 @@ let ForgePanelController = (() => {
|
|
|
4043
5827
|
/**
|
|
4044
5828
|
* Ask for a new worktree before the Session's first turn, replacing an open
|
|
4045
5829
|
* request and forgetting a failed attempt. While the next message waits in
|
|
4046
|
-
* the inbox, or else at the first step proposal, the panel creates
|
|
4047
|
-
*
|
|
4048
|
-
*
|
|
4049
|
-
*
|
|
5830
|
+
* the inbox, or else at the first step proposal, the panel creates the
|
|
5831
|
+
* branch `name`, or a generated branch per attempt when it is null, from
|
|
5832
|
+
* `from`, or from HEAD of the current checkout when it is null, and enters
|
|
5833
|
+
* its checkout; a remote-tracking `from` is fetched first. A message that
|
|
5834
|
+
* already waits after a failed or stopped attempt keeps waiting for
|
|
5835
|
+
* {@link ForgePanelController.retryWorktree}.
|
|
4050
5836
|
* @param session - Session without a started turn.
|
|
4051
|
-
* @param from - local base branch, or null for HEAD.
|
|
5837
|
+
* @param from - full name of a local or remote-tracking base branch, or null for HEAD.
|
|
5838
|
+
* @param name - new branch name, or null to generate one per attempt.
|
|
4052
5839
|
* @param signal - request cancellation.
|
|
4053
|
-
* @throws `forgePanel/invalid-branch` when `from` is empty; `forgePanel/
|
|
5840
|
+
* @throws `forgePanel/invalid-branch` when `from` is empty; `forgePanel/invalid-name` when `name` breaks
|
|
5841
|
+
* a branch-name rule; `forgePanel/branch-exists` when the checkout has a local branch named `name`;
|
|
5842
|
+
* `forgePanel/not-a-checkout` when a name is checked outside a checkout; `forgePanel/worktrees-unavailable`
|
|
4054
5843
|
* without a worktree service; `forgePanel/session-started` after a turn started or the worktree was
|
|
4055
5844
|
* created; `forgePanel/session-busy` while the worktree is being created.
|
|
4056
5845
|
*/
|
|
4057
|
-
async requestWorktree(session, from, signal) {
|
|
5846
|
+
async requestWorktree(session, from, name, signal) {
|
|
4058
5847
|
signal.throwIfAborted();
|
|
4059
5848
|
if (from?.length === 0) throw new RemoteError("forgePanel/invalid-branch", "The base branch name is empty", {});
|
|
4060
5849
|
this.editableWorktree(session);
|
|
5850
|
+
if (name !== null) {
|
|
5851
|
+
await this.checkBranchName(session, name, signal);
|
|
5852
|
+
this.editableWorktree(session);
|
|
5853
|
+
}
|
|
4061
5854
|
this.creations.forget(session);
|
|
4062
5855
|
appendPluginRecord(session, WORKTREE_RECORD, {
|
|
4063
5856
|
action: "request",
|
|
4064
|
-
from
|
|
5857
|
+
from,
|
|
5858
|
+
...name === null ? {} : { name }
|
|
4065
5859
|
});
|
|
4066
5860
|
this.creations.recheck(session);
|
|
4067
5861
|
}
|
|
@@ -4093,15 +5887,18 @@ let ForgePanelController = (() => {
|
|
|
4093
5887
|
this.creations.stop(session);
|
|
4094
5888
|
}
|
|
4095
5889
|
/**
|
|
4096
|
-
* Make another attempt,
|
|
4097
|
-
* of the Session waits for after a failed or
|
|
5890
|
+
* Make another attempt, on the requested branch name or a new generated
|
|
5891
|
+
* one, at the worktree a message of the Session waits for after a failed or
|
|
5892
|
+
* stopped attempt.
|
|
4098
5893
|
* @param session - Session whose message waits.
|
|
5894
|
+
* @param fetch - false skips fetching a remote-tracking base branch for this attempt, which then starts from the
|
|
5895
|
+
* commit last fetched.
|
|
4099
5896
|
* @param signal - request cancellation.
|
|
4100
5897
|
* @throws `forgePanel/not-waiting` when no message waits or an attempt is running.
|
|
4101
5898
|
*/
|
|
4102
|
-
async retryWorktree(session, signal) {
|
|
5899
|
+
async retryWorktree(session, fetch, signal) {
|
|
4103
5900
|
signal.throwIfAborted();
|
|
4104
|
-
if (!this.creations.retry(session)) throw new RemoteError("forgePanel/not-waiting", "No message waits for another attempt at the worktree", {});
|
|
5901
|
+
if (!this.creations.retry(session, fetch)) throw new RemoteError("forgePanel/not-waiting", "No message waits for another attempt at the worktree", {});
|
|
4105
5902
|
}
|
|
4106
5903
|
/**
|
|
4107
5904
|
* Check out the created worktree of a Session again at its recorded
|
|
@@ -4153,14 +5950,17 @@ let ForgePanelController = (() => {
|
|
|
4153
5950
|
});
|
|
4154
5951
|
}
|
|
4155
5952
|
/**
|
|
4156
|
-
* Hold the turn of a message entering a Session's
|
|
5953
|
+
* Hold the turn of a message entering a Session's next-turn queue while the
|
|
4157
5954
|
* Session's requested worktree does not exist yet, or while the worktree
|
|
4158
5955
|
* the Session works in is checked and, when gone, until it is restored or
|
|
4159
5956
|
* left. The message is entering, so the delivery has not woken the Agent
|
|
4160
|
-
* yet and its wake waits for the hold.
|
|
5957
|
+
* yet and its wake waits for the hold. A message for the next step, such as
|
|
5958
|
+
* a notice another plugin queues, opens no turn and gets no hold.
|
|
4161
5959
|
* @param agent - Agent whose inbox receives the message.
|
|
5960
|
+
* @param message - the entering message.
|
|
4162
5961
|
*/
|
|
4163
|
-
holdTurn(agent) {
|
|
5962
|
+
holdTurn(agent, message) {
|
|
5963
|
+
if (!agent.inbox.nextTurn.some((queued) => queued.id === message.id)) return;
|
|
4164
5964
|
const session = agent.session;
|
|
4165
5965
|
const state = this.worktreeState(session);
|
|
4166
5966
|
if (state.request !== null && state.created === null && !state.locked) this.creations.holdCreation(agent);
|
|
@@ -4179,8 +5979,20 @@ let ForgePanelController = (() => {
|
|
|
4179
5979
|
const missing = panel === void 0 ? await missingWorktree(this.home, this.config, session, this.worktreeState(session), directory, signal) : await panel.checkMissing(signal);
|
|
4180
5980
|
return this.home.workingDirectory.get(session) === directory ? missing : null;
|
|
4181
5981
|
}
|
|
4182
|
-
/** The
|
|
4183
|
-
async
|
|
5982
|
+
/** The files of a change request at the head a status recorded, read once per head and base branch while the cache keeps them. */
|
|
5983
|
+
async headFiles(ref, snapshot, signal) {
|
|
5984
|
+
const { headSha, baseBranch } = snapshot;
|
|
5985
|
+
const key = changeRequestKey(ref);
|
|
5986
|
+
const version = JSON.stringify([headSha, baseBranch]);
|
|
5987
|
+
let read = this.patches.get(key, version);
|
|
5988
|
+
if (read === void 0) {
|
|
5989
|
+
read = await this.patchAt(ref, headSha, async (operation) => await this.home.forge.diff(ref, headSha, operation), signal);
|
|
5990
|
+
this.patches.set(key, version, read);
|
|
5991
|
+
}
|
|
5992
|
+
return this.layers.classify(parseDiff(read.patch), read.attributes);
|
|
5993
|
+
}
|
|
5994
|
+
/** The files of consecutive commits of a change request, from the first one's first parent, which is returned too, to the last. */
|
|
5995
|
+
async commitFiles(ref, commits, signal) {
|
|
4184
5996
|
const list = await this.home.forge.commits(ref, signal);
|
|
4185
5997
|
if (list === void 0) throw new RemoteError("forgePanel/diff-failed", "The code host provider does not read commits", {});
|
|
4186
5998
|
if ("code" in list) throw readError(list);
|
|
@@ -4190,13 +6002,9 @@ let ForgePanelController = (() => {
|
|
|
4190
6002
|
const parent = start.parent;
|
|
4191
6003
|
if (parent === null) throw new RemoteError("forgePanel/diff-failed", "The first chosen commit has no parent to compare with", {});
|
|
4192
6004
|
const { patch, attributes } = await this.patchAt(ref, commits.to, async (operation) => await this.home.forge.compare(ref, parent, commits.to, operation), signal);
|
|
4193
|
-
const files = this.layers.classify(parseDiff(patch), attributes);
|
|
4194
|
-
const fileUrls = Object.fromEntries(files.map((file) => [file.path, this.home.forge.fileUrl(ref, commits.to, file.path)]));
|
|
4195
6005
|
return {
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
localAhead: null,
|
|
4199
|
-
fileUrls
|
|
6006
|
+
files: this.layers.classify(parseDiff(patch), attributes),
|
|
6007
|
+
parent
|
|
4200
6008
|
};
|
|
4201
6009
|
}
|
|
4202
6010
|
/**
|
|
@@ -4241,6 +6049,124 @@ let ForgePanelController = (() => {
|
|
|
4241
6049
|
if (inspection === void 0) throw new RemoteError("forgePanel/not-a-checkout", "The Session's directory is not inside a Git checkout", {});
|
|
4242
6050
|
return inspection;
|
|
4243
6051
|
}
|
|
6052
|
+
/** Read every check of a change request, refusing a list read at another head; `recheck` runs once the host answers. */
|
|
6053
|
+
async readChecks(ref, headSha, signal, recheck) {
|
|
6054
|
+
const result = await this.home.forge.fetchChecks(ref, signal);
|
|
6055
|
+
recheck();
|
|
6056
|
+
if ("code" in result) throw new RemoteError("forgePanel/checks-failed", result.message, {});
|
|
6057
|
+
if (result.headSha !== headSha) throw new RemoteError("forgePanel/stale-head", "The change request head changed; refresh its status", {});
|
|
6058
|
+
return result;
|
|
6059
|
+
}
|
|
6060
|
+
/** Read the changes of a change request at the head of its latest status, or of chosen commits; `ahead` counts local commits. */
|
|
6061
|
+
async readDiff(target, commits, signal, ahead) {
|
|
6062
|
+
const { ref, update } = target;
|
|
6063
|
+
if (update === null || !("snapshot" in update)) throw new RemoteError("forgePanel/diff-failed", "The change request status has not been read yet", {});
|
|
6064
|
+
if (commits !== null) {
|
|
6065
|
+
const { files } = await this.commitFiles(ref, commits, signal);
|
|
6066
|
+
const fileUrls = Object.fromEntries(files.map((file) => [file.path, this.home.forge.fileUrl(ref, commits.to, file.path)]));
|
|
6067
|
+
return {
|
|
6068
|
+
headSha: commits.to,
|
|
6069
|
+
files,
|
|
6070
|
+
localAhead: null,
|
|
6071
|
+
fileUrls
|
|
6072
|
+
};
|
|
6073
|
+
}
|
|
6074
|
+
const { headSha, headBranch } = update.snapshot;
|
|
6075
|
+
const files = await this.headFiles(ref, update.snapshot, signal);
|
|
6076
|
+
const localAhead = await ahead(headBranch, headSha);
|
|
6077
|
+
signal.throwIfAborted();
|
|
6078
|
+
return {
|
|
6079
|
+
headSha,
|
|
6080
|
+
files,
|
|
6081
|
+
localAhead,
|
|
6082
|
+
fileUrls: Object.fromEntries(files.map((file) => [file.path, this.home.forge.fileUrl(ref, headSha, file.path)]))
|
|
6083
|
+
};
|
|
6084
|
+
}
|
|
6085
|
+
/** Read the viewed marks at a head commit, reusing marks kept for that head unless `fresh`. */
|
|
6086
|
+
async readViewed(ref, headSha, fresh, signal) {
|
|
6087
|
+
const key = changeRequestKey(ref);
|
|
6088
|
+
const readAt = Date.now();
|
|
6089
|
+
const kept = fresh ? void 0 : this.viewed.get(key, headSha, readAt);
|
|
6090
|
+
if (kept !== void 0) return kept;
|
|
6091
|
+
const token = this.viewed.token();
|
|
6092
|
+
const result = await this.home.forge.viewedFiles(ref, headSha, signal);
|
|
6093
|
+
if (result === void 0) return null;
|
|
6094
|
+
if ("code" in result) throw new RemoteError(result.code === "stale" ? "forgePanel/stale-head" : "forgePanel/viewed-failed", result.message, {});
|
|
6095
|
+
this.viewed.set(key, headSha, result, readAt, token);
|
|
6096
|
+
return result;
|
|
6097
|
+
}
|
|
6098
|
+
/** Set or clear a viewed mark. */
|
|
6099
|
+
async writeViewed(ref, request, signal) {
|
|
6100
|
+
if (request.path === "") throw new Error("Invalid viewed file");
|
|
6101
|
+
const failure = await this.home.forge.setViewed(ref, request, signal);
|
|
6102
|
+
if (failure !== void 0) throw actionError(failure);
|
|
6103
|
+
}
|
|
6104
|
+
/** Read the review threads at the head of the latest status, reusing threads kept for that head and update time. */
|
|
6105
|
+
async readThreads(target, headSha, fresh, signal) {
|
|
6106
|
+
const { ref, update } = target;
|
|
6107
|
+
if (update === null || !("snapshot" in update)) throw new RemoteError("forgePanel/review-failed", "The change request status has not been read yet", {});
|
|
6108
|
+
if (update.snapshot.headSha !== headSha) throw new RemoteError("forgePanel/stale-head", `The change request head moved from ${headSha} to ${update.snapshot.headSha}`, {});
|
|
6109
|
+
const key = changeRequestKey(ref);
|
|
6110
|
+
const version = JSON.stringify([headSha, update.snapshot.updatedAt]);
|
|
6111
|
+
const readAt = Date.now();
|
|
6112
|
+
const kept = fresh ? void 0 : this.reviews.get(key, version, readAt);
|
|
6113
|
+
if (kept !== void 0) return kept;
|
|
6114
|
+
const token = this.reviews.token();
|
|
6115
|
+
const review = await this.home.forge.readReview(ref, headSha, signal);
|
|
6116
|
+
if ("code" in review) throw reviewError(review);
|
|
6117
|
+
this.reviews.set(key, version, review, readAt, token);
|
|
6118
|
+
return review;
|
|
6119
|
+
}
|
|
6120
|
+
/** Publish a comment or a completed review, then drop the threads kept for the change request. */
|
|
6121
|
+
async publishReview(ref, request, signal) {
|
|
6122
|
+
if (!isCommit(request.headSha)) throw new Error("Invalid review commit");
|
|
6123
|
+
const comments = request.kind === "comment" ? [request.comment] : request.comments;
|
|
6124
|
+
if (!comments.every(validComment)) throw new Error("Invalid review comment");
|
|
6125
|
+
if (request.kind === "review" && request.event !== "approve" && request.body.trim() === "" && comments.length === 0) throw new Error("Empty review");
|
|
6126
|
+
try {
|
|
6127
|
+
return await this.home.forge.submitReview(ref, request, signal);
|
|
6128
|
+
} finally {
|
|
6129
|
+
this.reviews.drop(changeRequestKey(ref));
|
|
6130
|
+
}
|
|
6131
|
+
}
|
|
6132
|
+
/** Write to the review threads or the pending review, then drop the threads kept for the change request. */
|
|
6133
|
+
async writeThreads(ref, write, signal) {
|
|
6134
|
+
if (!isCommit(write.headSha)) throw new Error("Invalid review commit");
|
|
6135
|
+
if (!validWrite(write)) throw new Error("Invalid review write");
|
|
6136
|
+
try {
|
|
6137
|
+
return await this.home.forge.writeReview(ref, write, signal);
|
|
6138
|
+
} finally {
|
|
6139
|
+
this.reviews.drop(changeRequestKey(ref));
|
|
6140
|
+
}
|
|
6141
|
+
}
|
|
6142
|
+
/** The change request a review page URL names, with its latest polling result. */
|
|
6143
|
+
/** Request reviews of a change request from the given accounts, refusing an empty list or an empty login. */
|
|
6144
|
+
async askReviews(ref, reviewers, signal) {
|
|
6145
|
+
if (reviewers.length === 0 || reviewers.some((reviewer) => reviewer.login.trim() === "")) throw new Error("Invalid reviewers");
|
|
6146
|
+
const failure = await this.home.forge.requestReviews(ref, { reviewers }, signal);
|
|
6147
|
+
if (failure !== void 0) throw actionError(failure);
|
|
6148
|
+
}
|
|
6149
|
+
/** List accounts a review of a change request can be requested from, failing with the host's reason. */
|
|
6150
|
+
async candidatesOf(ref, query, signal) {
|
|
6151
|
+
const result = await this.home.forge.reviewerCandidates(ref, query, signal);
|
|
6152
|
+
if ("code" in result) throw new RemoteError("forgePanel/reviewers-failed", result.message, {});
|
|
6153
|
+
return result;
|
|
6154
|
+
}
|
|
6155
|
+
served(url) {
|
|
6156
|
+
const ref = this.home.forge.changeRequestFromUrl(url);
|
|
6157
|
+
if (ref === void 0) throw new RemoteError("forgePanel/unrecognized-url", "No provider serves this change request URL", {});
|
|
6158
|
+
return {
|
|
6159
|
+
ref,
|
|
6160
|
+
update: this.home.forge.latest(ref) ?? null
|
|
6161
|
+
};
|
|
6162
|
+
}
|
|
6163
|
+
/** Bind the change request a review conversation staged once the Session's message enters its inbox. */
|
|
6164
|
+
bindStaged(session) {
|
|
6165
|
+
const url = this.staged.get(session.id);
|
|
6166
|
+
if (url === void 0) return;
|
|
6167
|
+
this.staged.delete(session.id);
|
|
6168
|
+
if (this.home.forge.changeRequestFromUrl(url) !== void 0) this.home.forgeSession.track(session, url);
|
|
6169
|
+
}
|
|
4244
6170
|
/** A visible binding of the Session that a provider serves, which actions and reads are limited to. */
|
|
4245
6171
|
bound(session, url) {
|
|
4246
6172
|
const entry = this.home.forgeSession.changeRequests(session).find((candidate) => candidate.url === url);
|
|
@@ -4253,6 +6179,15 @@ let ForgePanelController = (() => {
|
|
|
4253
6179
|
worktreeState(session) {
|
|
4254
6180
|
return this.worktreeStates.stateOf(session);
|
|
4255
6181
|
}
|
|
6182
|
+
/**
|
|
6183
|
+
* Refuse a new branch name that breaks a branch-name rule or names a local branch of the Session's checkout. The
|
|
6184
|
+
* rules cover every name `git check-ref-format` refuses, which the worktree service runs again at creation.
|
|
6185
|
+
*/
|
|
6186
|
+
async checkBranchName(session, name, signal) {
|
|
6187
|
+
if (branchNameProblem(name) !== null) throw new RemoteError("forgePanel/invalid-name", "The new branch name is invalid", {});
|
|
6188
|
+
const root = (await this.checkoutOf(session, signal)).checkout.root;
|
|
6189
|
+
if (await hasBranch(this.home, this.config, session, root, name, signal)) throw new RemoteError("forgePanel/branch-exists", `A local branch named ${name} exists`, {});
|
|
6190
|
+
}
|
|
4256
6191
|
editableWorktree(session) {
|
|
4257
6192
|
if (this.home.get("worktrees") === void 0) throw new RemoteError("forgePanel/worktrees-unavailable", "No worktree service is mounted", {});
|
|
4258
6193
|
return this.changeableWorktree(session);
|
|
@@ -4319,7 +6254,7 @@ let ForgePanelController = (() => {
|
|
|
4319
6254
|
if (key === "forgeChangeRequests") listener(session.id, visibleUrls(session));
|
|
4320
6255
|
}),
|
|
4321
6256
|
refOf: (url) => ctx.forge.changeRequestFromUrl(url),
|
|
4322
|
-
watch: (ref, listener) => ctx.forge.
|
|
6257
|
+
watch: (ref, listener, known) => ctx.forge.watchBrief(ref, listener, known),
|
|
4323
6258
|
open: async () => {
|
|
4324
6259
|
const domain = await storage.open(changeRequestStatesDomain);
|
|
4325
6260
|
return {
|
|
@@ -4333,14 +6268,129 @@ let ForgePanelController = (() => {
|
|
|
4333
6268
|
});
|
|
4334
6269
|
return this.states;
|
|
4335
6270
|
}
|
|
6271
|
+
/**
|
|
6272
|
+
* Bring what is kept for a change request up to date after an accepted review change, and let its panel entries
|
|
6273
|
+
* report it: a saved viewed mark replaces the kept state of its file, which a host lists for every changed file, and
|
|
6274
|
+
* leaves the kept threads; any other change drops the kept threads.
|
|
6275
|
+
*/
|
|
6276
|
+
reviewChanged(ref, change) {
|
|
6277
|
+
const key = changeRequestKey(ref);
|
|
6278
|
+
switch (change.kind) {
|
|
6279
|
+
case "viewed": {
|
|
6280
|
+
const { path, viewed } = change;
|
|
6281
|
+
this.viewed.amend(key, change.headSha, (marks) => path in marks.files ? {
|
|
6282
|
+
...marks,
|
|
6283
|
+
files: {
|
|
6284
|
+
...marks.files,
|
|
6285
|
+
[path]: viewed ? "viewed" : "unviewed"
|
|
6286
|
+
}
|
|
6287
|
+
} : marks);
|
|
6288
|
+
break;
|
|
6289
|
+
}
|
|
6290
|
+
case "write":
|
|
6291
|
+
case "submit":
|
|
6292
|
+
this.reviews.drop(key);
|
|
6293
|
+
break;
|
|
6294
|
+
/* v8 ignore next -- closed ForgeReviewChange kind union exhaustiveness guard */
|
|
6295
|
+
default: assertNever(change, "ForgeReviewChange.kind");
|
|
6296
|
+
}
|
|
6297
|
+
this.reviewRevisions.set(key, (this.reviewRevisions.get(key) ?? 0) + 1);
|
|
6298
|
+
for (const panel of this.panels.values()) panel.reviewChanged();
|
|
6299
|
+
for (const follower of this.reviewFollowers) if (follower.key === key) follower.emit();
|
|
6300
|
+
}
|
|
6301
|
+
/** The files a lens request names with their reader and the key results for them are kept under. */
|
|
6302
|
+
async lensSubject(session, source, signal) {
|
|
6303
|
+
if (source.kind === "local") {
|
|
6304
|
+
const inspection = await this.checkoutOf(session, signal);
|
|
6305
|
+
const root = inspection.checkout.root;
|
|
6306
|
+
const { scope } = source;
|
|
6307
|
+
const fork = scope.kind !== "branch" ? null : await diffing(scope.base === null ? forkPoint(gitIn(this.home, this.config, session, root, signal), inspection, this.worktreeState(session).created) : chosenForkPoint(gitIn(this.home, this.config, session, root, signal), scope.base));
|
|
6308
|
+
const { files } = await diffing(localDiff(this.home, this.config, session, root, fork, scope, this.layers, signal));
|
|
6309
|
+
return {
|
|
6310
|
+
key: JSON.stringify([
|
|
6311
|
+
"local",
|
|
6312
|
+
session.id,
|
|
6313
|
+
scope
|
|
6314
|
+
]),
|
|
6315
|
+
source: {
|
|
6316
|
+
kind: "local",
|
|
6317
|
+
scope
|
|
6318
|
+
},
|
|
6319
|
+
files,
|
|
6320
|
+
read: async (side, file, inner) => {
|
|
6321
|
+
if (file.binary || (side === "old" ? file.status === "added" : file.status === "deleted")) return null;
|
|
6322
|
+
return side === "new" ? await diffing(localText(this.home, this.config, session, root, scope, file.path, inner)) : await diffing(localOldText(this.home, this.config, session, root, scope, fork, file.previousPath ?? file.path, inner));
|
|
6323
|
+
}
|
|
6324
|
+
};
|
|
6325
|
+
}
|
|
6326
|
+
const { ref, update } = this.bound(session, source.url);
|
|
6327
|
+
if (update === null || !("snapshot" in update)) throw new RemoteError("forgePanel/lens-stale", "The change request status has not been read yet", {});
|
|
6328
|
+
const { snapshot } = update;
|
|
6329
|
+
const { commits } = source;
|
|
6330
|
+
let files;
|
|
6331
|
+
let newCommit;
|
|
6332
|
+
let oldCommit;
|
|
6333
|
+
if (commits === null) {
|
|
6334
|
+
files = await this.headFiles(ref, snapshot, signal);
|
|
6335
|
+
newCommit = snapshot.headSha;
|
|
6336
|
+
let base;
|
|
6337
|
+
oldCommit = async (inner) => {
|
|
6338
|
+
base ??= this.mergeBaseOf(ref, snapshot, inner);
|
|
6339
|
+
try {
|
|
6340
|
+
return await base;
|
|
6341
|
+
} catch (error) {
|
|
6342
|
+
base = void 0;
|
|
6343
|
+
throw error;
|
|
6344
|
+
}
|
|
6345
|
+
};
|
|
6346
|
+
} else {
|
|
6347
|
+
const read = await this.commitFiles(ref, commits, signal);
|
|
6348
|
+
files = read.files;
|
|
6349
|
+
newCommit = commits.to;
|
|
6350
|
+
oldCommit = () => Promise.resolve(read.parent);
|
|
6351
|
+
}
|
|
6352
|
+
return {
|
|
6353
|
+
key: JSON.stringify([
|
|
6354
|
+
"change",
|
|
6355
|
+
changeRequestKey(ref),
|
|
6356
|
+
newCommit,
|
|
6357
|
+
commits
|
|
6358
|
+
]),
|
|
6359
|
+
source: {
|
|
6360
|
+
kind: "change",
|
|
6361
|
+
ref,
|
|
6362
|
+
headSha: snapshot.headSha,
|
|
6363
|
+
commits
|
|
6364
|
+
},
|
|
6365
|
+
files,
|
|
6366
|
+
read: async (side, file, inner) => {
|
|
6367
|
+
if (file.binary || (side === "old" ? file.status === "added" : file.status === "deleted")) return null;
|
|
6368
|
+
const commit = side === "new" ? newCommit : await oldCommit(inner);
|
|
6369
|
+
const text = await this.home.forge.fileText(ref, commit, side === "new" ? file.path : file.previousPath ?? file.path, inner);
|
|
6370
|
+
if (typeof text === "string") return text;
|
|
6371
|
+
if (text.code === "not-found") return null;
|
|
6372
|
+
throw new Error(text.message);
|
|
6373
|
+
}
|
|
6374
|
+
};
|
|
6375
|
+
}
|
|
6376
|
+
/** The merge base whose files the old side of a change request's diff at the status's head shows. */
|
|
6377
|
+
async mergeBaseOf(ref, snapshot, signal) {
|
|
6378
|
+
if (snapshot.baseSha === void 0) throw new Error("The code host provider reports no base commit to read the old side at");
|
|
6379
|
+
const base = await this.home.forge.mergeBase(ref, snapshot.baseSha, snapshot.headSha, signal);
|
|
6380
|
+
if (typeof base !== "string") throw new Error(base.message);
|
|
6381
|
+
return base;
|
|
6382
|
+
}
|
|
4336
6383
|
panelOf(session) {
|
|
4337
6384
|
let panel = this.panels.get(session);
|
|
4338
6385
|
if (panel === void 0) {
|
|
4339
|
-
const
|
|
6386
|
+
const revision = (ref) => this.reviewRevisions.get(changeRequestKey(ref)) ?? 0;
|
|
6387
|
+
const idle = () => {
|
|
4340
6388
|
if (this.panels.get(session) !== created) return;
|
|
4341
6389
|
this.panels.delete(session);
|
|
6390
|
+
this.keptPanels.set(session, created.keep());
|
|
4342
6391
|
created.dispose();
|
|
4343
|
-
}
|
|
6392
|
+
};
|
|
6393
|
+
const created = new SessionPanel(this.home, this.config, session, this.worktreeStates, this.creations, revision, this.keptPanels.get(session), idle);
|
|
4344
6394
|
panel = created;
|
|
4345
6395
|
this.panels.set(session, panel);
|
|
4346
6396
|
}
|
|
@@ -4394,6 +6444,7 @@ function readError(failure) {
|
|
|
4394
6444
|
case "stale": return new RemoteError("forgePanel/stale-head", failure.message, {});
|
|
4395
6445
|
case "not-found":
|
|
4396
6446
|
case "unauthenticated":
|
|
6447
|
+
case "rate-limited":
|
|
4397
6448
|
case "unsupported":
|
|
4398
6449
|
case "unavailable": return new RemoteError("forgePanel/diff-failed", failure.message, {});
|
|
4399
6450
|
/* v8 ignore next -- closed ForgeFailure code union exhaustiveness guard */
|
|
@@ -4413,6 +6464,7 @@ function reviewError(failure) {
|
|
|
4413
6464
|
case "not-found":
|
|
4414
6465
|
case "unauthenticated":
|
|
4415
6466
|
case "too-large":
|
|
6467
|
+
case "rate-limited":
|
|
4416
6468
|
case "unavailable": return new RemoteError("forgePanel/review-failed", failure.message, {});
|
|
4417
6469
|
/* v8 ignore next -- closed ForgeFailure code union exhaustiveness guard */
|
|
4418
6470
|
default: return assertNever(failure.code, "ForgeFailure.code");
|
|
@@ -4445,19 +6497,5 @@ async function diffing(reading) {
|
|
|
4445
6497
|
function actionError(failure) {
|
|
4446
6498
|
return new RemoteError(failure.code === "stale" ? "forgePanel/stale-head" : failure.code === "unknown" ? "forgePanel/action-unknown" : "forgePanel/action-failed", failure.message, {});
|
|
4447
6499
|
}
|
|
4448
|
-
/**
|
|
4449
|
-
* Whether `prefix` followed by hexadecimal digits is a branch name that Git
|
|
4450
|
-
* accepts: no leading `-` or `/`, no empty component, no component that
|
|
4451
|
-
* starts with `.` or ends with `.lock`, and none of `..`, `@{`, whitespace,
|
|
4452
|
-
* control characters, `~`, `^`, `:`, `?`, `*`, `[`, or `\`.
|
|
4453
|
-
* @param prefix - configured worktree branch prefix.
|
|
4454
|
-
* @returns whether every generated name passes `git check-ref-format --branch`.
|
|
4455
|
-
*/
|
|
4456
|
-
function branchPrefix(prefix) {
|
|
4457
|
-
const name = `${prefix}0`;
|
|
4458
|
-
if (name.startsWith("-") || name.includes("..") || name.includes("@{")) return false;
|
|
4459
|
-
for (const char of name) if (char <= " " || char === "" || "~^:?*[\\".includes(char)) return false;
|
|
4460
|
-
return name.split("/").every((part) => part.length > 0 && !part.startsWith(".") && !part.endsWith(".lock"));
|
|
4461
|
-
}
|
|
4462
6500
|
//#endregion
|
|
4463
6501
|
export { ForgePanelController, ForgePanelController as default };
|