@deepseek-ai/dsh-experimental-client-ui-forge 0.2.3-alpha.2 → 0.2.3-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +8 -8
- package/README.md +29 -12
- package/README.zh.md +29 -12
- package/lib/client.js +21 -16
- package/lib/client.js.map +1 -1
- package/lib/index.js +874 -170
- package/lib/typert.host.js +831 -156
- package/lib/typert.remote-client.d.ts +29 -11
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +727 -134
- package/lib/types/client/ActionToast.d.ts +1 -1
- package/lib/types/client/ActionToast.d.ts.map +1 -1
- package/lib/types/client/ActionToast.js.map +1 -1
- package/lib/types/client/AttentionIndicator.d.ts +1 -1
- package/lib/types/client/AttentionIndicator.d.ts.map +1 -1
- package/lib/types/client/BaseMenu.d.ts +6 -4
- package/lib/types/client/BaseMenu.d.ts.map +1 -1
- package/lib/types/client/BaseMenu.js.map +1 -1
- package/lib/types/client/BranchPicker.d.ts +84 -0
- package/lib/types/client/BranchPicker.d.ts.map +1 -0
- package/lib/types/client/BranchPicker.js.map +1 -0
- package/lib/types/client/ChangeRequestCard.d.ts +21 -12
- 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 +12 -6
- 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 +5 -3
- package/lib/types/client/ChangeRequestsSection.d.ts.map +1 -1
- package/lib/types/client/ChangeRequestsSection.js.map +1 -1
- package/lib/types/client/ChangedFiles.d.ts +1 -1
- 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 +1 -1
- package/lib/types/client/ChangesLoading.d.ts.map +1 -1
- package/lib/types/client/ChangesTab.d.ts +15 -7
- package/lib/types/client/ChangesTab.d.ts.map +1 -1
- package/lib/types/client/ChangesTab.js.map +1 -1
- package/lib/types/client/ChangesTabTitle.d.ts +1 -1
- package/lib/types/client/ChangesTabTitle.d.ts.map +1 -1
- package/lib/types/client/ChangesTabTitle.js.map +1 -1
- package/lib/types/client/CommitMenu.d.ts +3 -3
- package/lib/types/client/CommitMenu.d.ts.map +1 -1
- package/lib/types/client/CommitMenu.js.map +1 -1
- package/lib/types/client/DiffFile.d.ts +16 -2
- 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 +6 -6
- package/lib/types/client/EnvironmentRows.d.ts.map +1 -1
- package/lib/types/client/EnvironmentRows.js.map +1 -1
- package/lib/types/client/FileLabel.js.map +1 -1
- package/lib/types/client/HeadMenu.d.ts +35 -0
- package/lib/types/client/HeadMenu.d.ts.map +1 -0
- package/lib/types/client/HeadMenu.js.map +1 -0
- package/lib/types/client/HostSettings.d.ts +33 -0
- package/lib/types/client/HostSettings.d.ts.map +1 -0
- package/lib/types/client/HostSettings.js.map +1 -0
- package/lib/types/client/LensFilter.d.ts +2 -2
- package/lib/types/client/LensFilter.d.ts.map +1 -1
- package/lib/types/client/LensFilter.js.map +1 -1
- package/lib/types/client/ReasonButton.js.map +1 -1
- package/lib/types/client/RefreshGlyph.js.map +1 -1
- package/lib/types/client/ReviewComposer.d.ts +1 -1
- 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 +1 -1
- 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 +1 -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 +4 -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 +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/SessionRowForge.d.ts +1 -1
- package/lib/types/client/SessionRowForge.d.ts.map +1 -1
- package/lib/types/client/SessionRowForge.js.map +1 -1
- package/lib/types/client/SubmitReview.d.ts +1 -1
- package/lib/types/client/SubmitReview.d.ts.map +1 -1
- package/lib/types/client/SubmitReview.js.map +1 -1
- package/lib/types/client/ThreadList.d.ts +3 -1
- package/lib/types/client/ThreadList.d.ts.map +1 -1
- package/lib/types/client/ThreadList.js.map +1 -1
- package/lib/types/client/ViewOptionsMenu.d.ts +1 -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 +1 -1
- package/lib/types/client/WorktreeNameDialog.d.ts.map +1 -1
- package/lib/types/client/WorktreeNameDialog.js.map +1 -1
- package/lib/types/client/WorktreeProgress.d.ts +1 -1
- package/lib/types/client/WorktreeProgress.d.ts.map +1 -1
- package/lib/types/client/WorktreeProgress.js.map +1 -1
- package/lib/types/client/WorktreeSettings.d.ts +1 -1
- package/lib/types/client/WorktreeSettings.d.ts.map +1 -1
- package/lib/types/client/WorktreeSettings.js.map +1 -1
- package/lib/types/client/WorktreeToggle.d.ts +1 -1
- package/lib/types/client/WorktreeToggle.d.ts.map +1 -1
- package/lib/types/client/WorktreeToggle.js.map +1 -1
- package/lib/types/client/annotations.d.ts +1 -1
- package/lib/types/client/annotations.d.ts.map +1 -1
- package/lib/types/client/branch-search.d.ts +1 -1
- package/lib/types/client/branch-search.d.ts.map +1 -1
- package/lib/types/client/branch-search.js.map +1 -1
- package/lib/types/client/changes-address.d.ts +1 -1
- package/lib/types/client/changes-address.d.ts.map +1 -1
- package/lib/types/client/changes-service.d.ts +1 -1
- package/lib/types/client/changes-service.d.ts.map +1 -1
- package/lib/types/client/changes-store.d.ts +18 -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 +1 -1
- package/lib/types/client/checkout.d.ts.map +1 -1
- package/lib/types/client/code-selection.d.ts.map +1 -1
- package/lib/types/client/code-selection.js.map +1 -1
- package/lib/types/client/forge-copy.d.ts +8 -1
- package/lib/types/client/forge-copy.d.ts.map +1 -1
- package/lib/types/client/forge-copy.js.map +1 -1
- package/lib/types/client/format.d.ts +1 -1
- 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 +23 -1
- 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 +1 -1
- package/lib/types/client/highlight-context.d.ts.map +1 -1
- package/lib/types/client/host-settings-form.d.ts +69 -0
- package/lib/types/client/host-settings-form.d.ts.map +1 -0
- package/lib/types/client/host-settings-form.js.map +1 -0
- package/lib/types/client/host-sign-in.d.ts +31 -0
- package/lib/types/client/host-sign-in.d.ts.map +1 -0
- package/lib/types/client/host-sign-in.js.map +1 -0
- package/lib/types/client/local-writes.d.ts +47 -0
- package/lib/types/client/local-writes.d.ts.map +1 -0
- package/lib/types/client/local-writes.js.map +1 -0
- package/lib/types/client/locales.d.ts +106 -9
- 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 +15 -1
- 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/ReviewActivity.d.ts +44 -0
- package/lib/types/client/review-page/ReviewActivity.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewActivity.js.map +1 -0
- package/lib/types/client/review-page/ReviewChat.d.ts +1 -1
- package/lib/types/client/review-page/ReviewChat.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewChat.js.map +1 -1
- package/lib/types/client/review-page/ReviewDetail.d.ts +23 -9
- package/lib/types/client/review-page/ReviewDetail.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewDetail.js.map +1 -1
- package/lib/types/client/review-page/ReviewLabels.d.ts +1 -1
- package/lib/types/client/review-page/ReviewLabels.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewLabels.js.map +1 -1
- package/lib/types/client/review-page/ReviewList.d.ts +10 -8
- package/lib/types/client/review-page/ReviewList.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewList.js.map +1 -1
- package/lib/types/client/review-page/ReviewNav.d.ts +1 -1
- package/lib/types/client/review-page/ReviewNav.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewPage.d.ts +15 -12
- package/lib/types/client/review-page/ReviewPage.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewPage.js.map +1 -1
- package/lib/types/client/review-page/ReviewSkeleton.d.ts +26 -0
- package/lib/types/client/review-page/ReviewSkeleton.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewSkeleton.js.map +1 -0
- package/lib/types/client/review-page/ReviewStatus.d.ts +5 -3
- package/lib/types/client/review-page/ReviewStatus.d.ts.map +1 -1
- package/lib/types/client/review-page/ReviewStatus.js.map +1 -1
- package/lib/types/client/review-page/review-activity.d.ts +37 -0
- package/lib/types/client/review-page/review-activity.d.ts.map +1 -0
- package/lib/types/client/review-page/review-activity.js.map +1 -0
- package/lib/types/client/review-page/review-lists.d.ts +48 -13
- package/lib/types/client/review-page/review-lists.d.ts.map +1 -1
- package/lib/types/client/review-page/review-lists.js.map +1 -1
- package/lib/types/client/review-page/review-mount.d.ts +3 -1
- package/lib/types/client/review-page/review-mount.d.ts.map +1 -1
- package/lib/types/client/review-page/review-mount.js.map +1 -1
- package/lib/types/client/review-page/review-store.d.ts +18 -8
- package/lib/types/client/review-page/review-store.d.ts.map +1 -1
- package/lib/types/client/review-page/review-store.js.map +1 -1
- package/lib/types/client/review-queue.d.ts +1 -1
- 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 +1 -1
- package/lib/types/client/review-threads.d.ts.map +1 -1
- package/lib/types/client/review.d.ts +12 -1
- package/lib/types/client/review.d.ts.map +1 -1
- package/lib/types/client/review.js.map +1 -1
- package/lib/types/client/row-form-labels.d.ts +12 -0
- package/lib/types/client/row-form-labels.d.ts.map +1 -0
- package/lib/types/client/row-form-labels.js.map +1 -0
- package/lib/types/client/session-list.d.ts +1 -1
- package/lib/types/client/session-list.d.ts.map +1 -1
- package/lib/types/client/slots.d.ts +1 -1
- package/lib/types/client/slots.d.ts.map +1 -1
- package/lib/types/client/source.d.ts +1 -1
- package/lib/types/client/source.d.ts.map +1 -1
- package/lib/types/client/status.d.ts +7 -0
- package/lib/types/client/status.d.ts.map +1 -1
- package/lib/types/client/status.js.map +1 -1
- package/lib/types/client/worktree-settings-form.d.ts +1 -1
- package/lib/types/client/worktree-settings-form.d.ts.map +1 -1
- package/lib/types/client/worktree-settings-form.js.map +1 -1
- package/lib/types/diff.d.ts.map +1 -1
- package/lib/types/diff.js.map +1 -1
- package/lib/types/git.d.ts +22 -0
- package/lib/types/git.d.ts.map +1 -1
- package/lib/types/git.js.map +1 -1
- package/lib/types/index.d.ts +113 -25
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/local-diff.d.ts +81 -23
- package/lib/types/local-diff.d.ts.map +1 -1
- package/lib/types/local-diff.js.map +1 -1
- package/lib/types/local-write.d.ts +44 -0
- package/lib/types/local-write.d.ts.map +1 -0
- package/lib/types/local-write.js.map +1 -0
- package/lib/types/parse.d.ts +12 -3
- package/lib/types/parse.d.ts.map +1 -1
- package/lib/types/parse.js.map +1 -1
- package/lib/types/restore.d.ts +12 -0
- package/lib/types/restore.d.ts.map +1 -0
- package/lib/types/restore.js.map +1 -0
- package/lib/types/types.d.ts +106 -8
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/viewer-lists.d.ts +22 -13
- package/lib/types/viewer-lists.d.ts.map +1 -1
- package/lib/types/viewer-lists.js.map +1 -1
- package/package.json +60 -58
- package/src/client/ActionToast.tsx +2 -2
- package/src/client/AttentionIndicator.tsx +1 -1
- package/src/client/BaseMenu.module.css +12 -3
- package/src/client/BaseMenu.tsx +25 -88
- package/src/client/BranchPicker.tsx +161 -0
- package/src/client/ChangeRequestCard.tsx +138 -44
- package/src/client/ChangeRequestOverview.tsx +21 -9
- package/src/client/ChangeRequestsSection.tsx +12 -6
- package/src/client/ChangedFiles.tsx +2 -2
- package/src/client/ChangesLoading.tsx +1 -1
- package/src/client/ChangesTab.module.css +95 -16
- package/src/client/ChangesTab.tsx +190 -72
- package/src/client/ChangesTabTitle.tsx +2 -2
- package/src/client/CommitMenu.tsx +7 -5
- package/src/client/DiffFile.tsx +67 -11
- package/src/client/EnvironmentRows.tsx +21 -17
- package/src/client/FileLabel.tsx +1 -1
- package/src/client/Forge.module.css +28 -1
- package/src/client/HeadMenu.tsx +69 -0
- package/src/client/HostSettings.module.css +194 -0
- package/src/client/HostSettings.tsx +192 -0
- package/src/client/LensFilter.tsx +2 -2
- package/src/client/ReasonButton.tsx +1 -1
- package/src/client/RefreshGlyph.tsx +1 -1
- package/src/client/ReviewComposer.tsx +2 -2
- package/src/client/ReviewControls.tsx +10 -3
- package/src/client/ReviewThread.tsx +2 -2
- package/src/client/ReviewThreads.tsx +7 -4
- package/src/client/SessionHoverForge.tsx +2 -2
- package/src/client/SessionRowForge.tsx +2 -2
- package/src/client/SubmitReview.tsx +2 -2
- package/src/client/ThreadList.tsx +6 -3
- package/src/client/ViewOptionsMenu.tsx +2 -2
- package/src/client/WorktreeNameDialog.tsx +2 -2
- package/src/client/WorktreeProgress.tsx +2 -2
- package/src/client/WorktreeSettings.tsx +4 -11
- package/src/client/WorktreeToggle.tsx +2 -2
- package/src/client/annotations.ts +1 -1
- package/src/client/branch-search.tsx +2 -2
- package/src/client/changes-address.ts +1 -1
- package/src/client/changes-service.ts +1 -1
- package/src/client/changes-store.ts +49 -5
- package/src/client/checkout.ts +1 -1
- package/src/client/code-selection.ts +3 -1
- package/src/client/forge-copy.ts +11 -1
- package/src/client/format.ts +2 -2
- package/src/client/glyphs.tsx +50 -5
- package/src/client/highlight-context.ts +1 -1
- package/src/client/host-settings-form.ts +115 -0
- package/src/client/host-sign-in.ts +46 -0
- package/src/client/local-writes.ts +129 -0
- package/src/client/locales.ts +841 -65
- package/src/client/mount.ts +56 -7
- package/src/client/review-page/ReviewActivity.tsx +405 -0
- package/src/client/review-page/ReviewChat.tsx +2 -2
- package/src/client/review-page/ReviewDetail.tsx +201 -64
- package/src/client/review-page/ReviewLabels.tsx +2 -2
- package/src/client/review-page/ReviewList.tsx +153 -136
- package/src/client/review-page/ReviewNav.tsx +1 -1
- package/src/client/review-page/ReviewPage.module.css +490 -13
- package/src/client/review-page/ReviewPage.tsx +44 -21
- package/src/client/review-page/ReviewSkeleton.tsx +108 -0
- package/src/client/review-page/ReviewStatus.tsx +14 -9
- package/src/client/review-page/review-activity.ts +64 -0
- package/src/client/review-page/review-lists.ts +85 -22
- package/src/client/review-page/review-mount.ts +24 -7
- package/src/client/review-page/review-store.ts +24 -7
- package/src/client/review-queue.ts +7 -3
- package/src/client/review-threads.ts +1 -1
- package/src/client/review.ts +20 -2
- package/src/client/row-form-labels.ts +17 -0
- package/src/client/session-list.ts +1 -1
- package/src/client/slots.ts +1 -1
- package/src/client/source.ts +1 -1
- package/src/client/status.ts +20 -0
- package/src/client/worktree-settings-form.ts +1 -1
- package/src/diff.ts +8 -5
- package/src/git.ts +31 -1
- package/src/index.ts +241 -50
- package/src/local-diff.ts +151 -48
- package/src/local-write.ts +159 -0
- package/src/parse.ts +26 -4
- package/src/restore.ts +15 -0
- package/src/types.ts +97 -12
- package/src/viewer-lists.ts +124 -48
package/src/types.ts
CHANGED
|
@@ -219,6 +219,16 @@ export interface ForgeReviewList {
|
|
|
219
219
|
readonly failure: ForgeFailure | null
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
+
/** One repository on one host, which the review page's lists can be read in. */
|
|
223
|
+
export interface ForgeReviewRepository {
|
|
224
|
+
/** Host name of the provider that lists the repository, compared without case. */
|
|
225
|
+
readonly host: string
|
|
226
|
+
/** Owner or namespace; nested groups of a GitLab project stay in it. */
|
|
227
|
+
readonly owner: string
|
|
228
|
+
/** Repository name. */
|
|
229
|
+
readonly name: string
|
|
230
|
+
}
|
|
231
|
+
|
|
222
232
|
/** The review page's lists on one host of one provider. */
|
|
223
233
|
export interface ForgeReviewHost {
|
|
224
234
|
/** Forge family of the provider. */
|
|
@@ -227,6 +237,11 @@ export interface ForgeReviewHost {
|
|
|
227
237
|
readonly host: string
|
|
228
238
|
/** Login of the signed-in user the latest successful read named, or null before one. */
|
|
229
239
|
readonly viewer: string | null
|
|
240
|
+
/**
|
|
241
|
+
* The command that signs the provider's CLI in to the host, while the latest read failed for lack of sign-in and the
|
|
242
|
+
* provider names one; null otherwise.
|
|
243
|
+
*/
|
|
244
|
+
readonly signIn: string | null
|
|
230
245
|
/** Each list the provider offers on the host; a list it does not offer is absent. */
|
|
231
246
|
readonly lists: Partial<Readonly<Record<ForgeViewerFilter, ForgeReviewList>>>
|
|
232
247
|
}
|
|
@@ -332,11 +347,19 @@ export interface ForgeBaseBranch {
|
|
|
332
347
|
readonly ref: string
|
|
333
348
|
/** The ref without `refs/heads/` or `refs/remotes/`, such as `master` or `origin/master`. */
|
|
334
349
|
readonly name: string
|
|
350
|
+
/**
|
|
351
|
+
* Directory Git registered for the worktree that has this local branch checked out, absent when none has; a scope
|
|
352
|
+
* that names the branch as its head reads that worktree.
|
|
353
|
+
*/
|
|
354
|
+
readonly worktree?: string
|
|
335
355
|
}
|
|
336
356
|
|
|
337
357
|
/** What the `branch` scope compares with while no base branch is chosen. */
|
|
338
358
|
export interface ForgeAutomaticBase {
|
|
339
|
-
/**
|
|
359
|
+
/**
|
|
360
|
+
* The created worktree's base branch or abbreviated base commit, or the default branch of the code host remote;
|
|
361
|
+
* for a scope with a `head`, the Session's checked-out branch, or its abbreviated HEAD commit when detached.
|
|
362
|
+
*/
|
|
340
363
|
readonly name: string
|
|
341
364
|
/** Whether the fork point is the base commit of the worktree the Session created rather than a merge base. */
|
|
342
365
|
readonly worktree: boolean
|
|
@@ -348,7 +371,7 @@ export interface ForgeBaseBranches {
|
|
|
348
371
|
readonly automatic: ForgeAutomaticBase | null
|
|
349
372
|
/** Remote-tracking branches without symbolic refs such as `origin/HEAD`, most recently committed first, at most `maxBranches`. */
|
|
350
373
|
readonly remote: readonly ForgeBaseBranch[]
|
|
351
|
-
/** Local branches other than the
|
|
374
|
+
/** Local branches other than the one the scope shows, most recently committed first, at most `maxBranches`. */
|
|
352
375
|
readonly local: readonly ForgeBaseBranch[]
|
|
353
376
|
}
|
|
354
377
|
|
|
@@ -363,21 +386,28 @@ export interface ForgeCommitRange {
|
|
|
363
386
|
readonly to: string
|
|
364
387
|
}
|
|
365
388
|
|
|
366
|
-
/**
|
|
389
|
+
/**
|
|
390
|
+
* Which local changes a diff covers. Without `head` each reads the checkout of the Session's current directory through
|
|
391
|
+
* Git. With `head`, the full ref name of a branch under `refs/heads/` or `refs/remotes/`, it reads that branch in place
|
|
392
|
+
* of the checked-out one: in the worktree of the repository that has the branch checked out, where every scope applies
|
|
393
|
+
* and HEAD below is that worktree's, or, when no worktree has it, from the branch's commits, where only the `branch`
|
|
394
|
+
* scope applies and no uncommitted or untracked file shows.
|
|
395
|
+
*/
|
|
367
396
|
export type ForgeLocalScope =
|
|
368
397
|
/**
|
|
369
|
-
* The working tree and untracked files against a fork point: the merge base of HEAD with the
|
|
370
|
-
* `base`
|
|
371
|
-
*
|
|
372
|
-
* of
|
|
398
|
+
* The working tree and untracked files against a fork point: the merge base of HEAD with the `base` ref. While
|
|
399
|
+
* `base` is null, a scope with a `head` uses the merge base with the commit the Session's own HEAD names; a scope
|
|
400
|
+
* without one uses the base commit of the worktree the Session created, else the merge base of HEAD with the
|
|
401
|
+
* default branch of the code host remote. With `commits`, only the changes of those commits between the fork
|
|
402
|
+
* point and HEAD, without uncommitted or untracked files.
|
|
373
403
|
*/
|
|
374
|
-
| { readonly kind: 'branch'; readonly base: string | null; readonly commits: ForgeCommitRange | null }
|
|
404
|
+
| { readonly kind: 'branch'; readonly head?: string; readonly base: string | null; readonly commits: ForgeCommitRange | null }
|
|
375
405
|
/** The working tree and untracked files against HEAD. */
|
|
376
|
-
| { readonly kind: 'uncommitted' }
|
|
406
|
+
| { readonly kind: 'uncommitted'; readonly head?: string }
|
|
377
407
|
/** The working tree and untracked files against the index. */
|
|
378
|
-
| { readonly kind: 'unstaged' }
|
|
408
|
+
| { readonly kind: 'unstaged'; readonly head?: string }
|
|
379
409
|
/** The index against HEAD. */
|
|
380
|
-
| { readonly kind: 'staged' }
|
|
410
|
+
| { readonly kind: 'staged'; readonly head?: string }
|
|
381
411
|
|
|
382
412
|
/** One hunk of a file diff. */
|
|
383
413
|
export interface ForgeDiffHunk {
|
|
@@ -417,6 +447,8 @@ export interface ForgeDiffFile {
|
|
|
417
447
|
readonly oversized: boolean
|
|
418
448
|
/** Whether Git does not track the file yet; only local diffs list such files. */
|
|
419
449
|
readonly untracked: boolean
|
|
450
|
+
/** Whether the path is a submodule, whose change is the commit recorded for it and whose hunks hold no file content. */
|
|
451
|
+
readonly submodule: boolean
|
|
420
452
|
/** Lines added. */
|
|
421
453
|
readonly additions: number
|
|
422
454
|
/** Lines deleted. */
|
|
@@ -440,6 +472,46 @@ export interface ForgeLocalDiff {
|
|
|
440
472
|
readonly files: readonly ForgeDiffFile[]
|
|
441
473
|
/** Untracked files left out beyond `maxUntrackedFiles`. */
|
|
442
474
|
readonly omitted: number
|
|
475
|
+
/**
|
|
476
|
+
* Top-level directory of the worktree the scope read for its `head`; absent for the Session's own checkout and for
|
|
477
|
+
* a head read from its commits.
|
|
478
|
+
*/
|
|
479
|
+
readonly worktree?: string
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/** One file of a local write, as the `unstaged` scope listed it for the reader. */
|
|
483
|
+
export interface ForgeLocalWriteFile {
|
|
484
|
+
/** Path relative to the repository root, as the diff names it. */
|
|
485
|
+
readonly path: string
|
|
486
|
+
/** Digest of the change the reader saw. */
|
|
487
|
+
readonly digest: string
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* A write a person makes from the changes view to the index or the working tree of the Session's checkout, on whole
|
|
492
|
+
* files. The person's press authorizes it, so the Session's access mode does not bound it.
|
|
493
|
+
*/
|
|
494
|
+
export type ForgeLocalWrite =
|
|
495
|
+
/** Copy the working-tree state of the files into the index, adding untracked files and recording deletions. */
|
|
496
|
+
| { readonly kind: 'stage'; readonly files: readonly ForgeLocalWriteFile[] }
|
|
497
|
+
/** Return the index entries of the paths to HEAD; a staged rename names both of its paths. */
|
|
498
|
+
| { readonly kind: 'unstage'; readonly paths: readonly string[] }
|
|
499
|
+
/**
|
|
500
|
+
* Return the working-tree files to their index entries and delete untracked files. A file Git tracks without
|
|
501
|
+
* content yet, as `git add --intent-to-add` leaves it, is refused, because its index entry is empty; so is a
|
|
502
|
+
* submodule, whose checkout a restore leaves as it is.
|
|
503
|
+
*/
|
|
504
|
+
| { readonly kind: 'restore'; readonly files: readonly ForgeLocalWriteFile[] }
|
|
505
|
+
/** Return the index entries of the paths to `tree`, the {@link ForgeLocalWriteResult.undo} of an earlier write. */
|
|
506
|
+
| { readonly kind: 'reindex'; readonly tree: string; readonly paths: readonly string[] }
|
|
507
|
+
|
|
508
|
+
/** What a local write left for undoing it. */
|
|
509
|
+
export interface ForgeLocalWriteResult {
|
|
510
|
+
/**
|
|
511
|
+
* Object name of the index as a tree before a `stage` or `unstage`, which a `reindex` of the same paths returns to;
|
|
512
|
+
* null for other writes and while the index holds unmerged entries.
|
|
513
|
+
*/
|
|
514
|
+
readonly undo: string | null
|
|
443
515
|
}
|
|
444
516
|
|
|
445
517
|
/** Changes of a change request, or of consecutive commits of it, as its code host computes them. */
|
|
@@ -648,7 +720,7 @@ export interface Config {
|
|
|
648
720
|
reviewListIntervalMs?: number
|
|
649
721
|
/** Milliseconds between two reads of the review page's navigation count while it is shown. */
|
|
650
722
|
reviewCountIntervalMs?: number
|
|
651
|
-
/** Largest delay in milliseconds between two reads of the review page's lists or count after consecutive
|
|
723
|
+
/** Largest delay in milliseconds between two reads of the review page's lists or count on one host after its consecutive failed reads. */
|
|
652
724
|
reviewMaxBackoffMs?: number
|
|
653
725
|
/** Most change requests one review page list shows, capped by each provider's own limit. */
|
|
654
726
|
reviewPageSize?: number
|
|
@@ -698,6 +770,13 @@ declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
|
698
770
|
'forgePanel/no-fork-point': Record<string, never>
|
|
699
771
|
/** The base branch chosen for the `branch` scope does not exist, as after the branch was deleted. */
|
|
700
772
|
'forgePanel/base-missing': Record<string, never>
|
|
773
|
+
/** The branch a local scope reads in place of the checked-out one does not exist, as after the branch was deleted. */
|
|
774
|
+
'forgePanel/head-missing': Record<string, never>
|
|
775
|
+
/**
|
|
776
|
+
* A scope other than `branch` named a branch that no worktree has checked out, as after its worktree was removed;
|
|
777
|
+
* only the `branch` scope reads such a branch.
|
|
778
|
+
*/
|
|
779
|
+
'forgePanel/no-working-tree': Record<string, never>
|
|
701
780
|
/** Filter configuration could not be read completely; no comparison ran. Correct Git settings or the output limit before retrying. */
|
|
702
781
|
'forgePanel/filter-config-failed': Record<string, never>
|
|
703
782
|
/**
|
|
@@ -713,12 +792,18 @@ declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
|
713
792
|
'forgePanel/commits-missing': Record<string, never>
|
|
714
793
|
/** A chosen commit after the first lacks the commit listed before it as its first parent, so two ends cannot name the run. */
|
|
715
794
|
'forgePanel/commits-not-linear': Record<string, never>
|
|
795
|
+
/** A file's unstaged change is not the one the reader saw; nothing was written. */
|
|
796
|
+
'forgePanel/local-stale': Record<string, never>
|
|
797
|
+
/** A file listed as deleted has a directory at its path, which a write of that path would reach into; nothing was written. */
|
|
798
|
+
'forgePanel/local-path-replaced': Record<string, never>
|
|
716
799
|
/** The code host did not provide the signed-in user's viewed marks on the change request's files; the message says why. */
|
|
717
800
|
'forgePanel/viewed-failed': Record<string, never>
|
|
718
801
|
/** The code host did not list the accounts a review can be requested from; the message says why. */
|
|
719
802
|
'forgePanel/reviewers-failed': Record<string, never>
|
|
720
803
|
/** The code host did not provide a change request's description; the message says why. */
|
|
721
804
|
'forgePanel/description-failed': Record<string, never>
|
|
805
|
+
/** The code host did not provide a change request's activity; the message says why. */
|
|
806
|
+
'forgePanel/activity-failed': Record<string, never>
|
|
722
807
|
/** The code host's provider cannot read review threads, so the changes view shows none. */
|
|
723
808
|
'forgePanel/review-unsupported': Record<string, never>
|
|
724
809
|
/** The code host did not provide the change request's review threads, or its status has not been read yet; the message says why. */
|
package/src/viewer-lists.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The review page's lists of the signed-in user's change requests and its navigation count. Lists are read only while
|
|
3
3
|
* some reader streams them and the count only while some reader streams it; neither joins the forge's status polling.
|
|
4
|
-
* Readers of one repository scope share one poller, which reads every list of every host each round, hosts in
|
|
5
|
-
* and each host's lists one after another, so one host has at most one read in flight. A
|
|
6
|
-
*
|
|
4
|
+
* Readers of one repository scope share one poller, which reads every list of every due host each round, hosts in
|
|
5
|
+
* parallel and each host's lists one after another, so one host has at most one read in flight. A host whose read
|
|
6
|
+
* failed is read again later each time, as status polling waits after consecutive failures, while the other hosts
|
|
7
|
+
* keep their cadence. A scope that names a repository reads only the host the repository is on.
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
import type {
|
|
10
11
|
ForgeFailure, ForgeViewerFilter, ForgeViewerList, ForgeViewerQuery, ForgeViewerSource,
|
|
11
12
|
} from '@deepseek-ai/dsh-experimental-forge/types'
|
|
12
|
-
import type { ForgeReviewCountFrame, ForgeReviewFrame, ForgeReviewHost, ForgeReviewList } from './types.ts'
|
|
13
|
+
import type { ForgeReviewCountFrame, ForgeReviewFrame, ForgeReviewHost, ForgeReviewList, ForgeReviewRepository } from './types.ts'
|
|
13
14
|
|
|
14
15
|
/** The lists in the order the page shows them. */
|
|
15
16
|
const FILTERS: readonly ForgeViewerFilter[] = ['review-requested', 'authored', 'involved']
|
|
@@ -22,6 +23,8 @@ export interface ViewerListSources {
|
|
|
22
23
|
readonly list: (forge: string, query: ForgeViewerQuery, signal: AbortSignal) => Promise<ForgeViewerList | ForgeFailure>
|
|
23
24
|
/** Read the size of every list on one host. */
|
|
24
25
|
readonly count: (forge: string, host: string, signal: AbortSignal) => Promise<ReadonlyMap<ForgeViewerFilter, number> | ForgeFailure>
|
|
26
|
+
/** The command that signs the provider's CLI in to a host, or null when the provider names none. */
|
|
27
|
+
readonly signIn: (forge: string, host: string, signal: AbortSignal) => Promise<string | null>
|
|
25
28
|
/** Report a read that rejected instead of resolving to a failure. */
|
|
26
29
|
readonly report: (error: unknown) => void
|
|
27
30
|
}
|
|
@@ -32,14 +35,14 @@ export interface ViewerListTiming {
|
|
|
32
35
|
readonly listIntervalMs: number
|
|
33
36
|
/** Milliseconds between two rounds of the count poller. */
|
|
34
37
|
readonly countIntervalMs: number
|
|
35
|
-
/** Largest delay in milliseconds after consecutive failed
|
|
38
|
+
/** Largest delay in milliseconds before a host is read again after consecutive failed reads. */
|
|
36
39
|
readonly maxBackoffMs: number
|
|
37
40
|
/** Most change requests one list read asks for, before each provider's own limit. */
|
|
38
41
|
readonly pageSize: number
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
/** One repository to list in, or null for every repository. */
|
|
42
|
-
export type ViewerScope =
|
|
44
|
+
/** One repository on one host to list in, or null for every repository of every host. */
|
|
45
|
+
export type ViewerScope = ForgeReviewRepository | null
|
|
43
46
|
|
|
44
47
|
/** A stream's latest undelivered frame; a newer frame replaces one the reader has not taken. */
|
|
45
48
|
export class Reader<T> {
|
|
@@ -92,15 +95,15 @@ export class Reader<T> {
|
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
/** A loop that runs one round, waits, and repeats until stopped; a refresh ends the wait early. */
|
|
98
|
+
/** A loop that runs one round, waits as long as the round asks, and repeats until stopped; a refresh ends the wait early. */
|
|
96
99
|
class Poller {
|
|
97
100
|
private readonly aborter = new AbortController()
|
|
98
101
|
private wake: (() => void) | undefined
|
|
99
102
|
private refreshing = false
|
|
100
|
-
private failures = 0
|
|
101
103
|
readonly done: Promise<void>
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
/** @param round - runs one round, `forced` after a refresh, and resolves to the milliseconds to wait before the next. */
|
|
106
|
+
constructor(private readonly round: (signal: AbortSignal, forced: boolean) => Promise<number>) {
|
|
104
107
|
this.done = this.loop()
|
|
105
108
|
}
|
|
106
109
|
|
|
@@ -123,12 +126,12 @@ class Poller {
|
|
|
123
126
|
private async loop(): Promise<void> {
|
|
124
127
|
const { signal } = this.aborter
|
|
125
128
|
while (!signal.aborted) {
|
|
129
|
+
const forced = this.refreshing
|
|
126
130
|
this.refreshing = false
|
|
127
|
-
const
|
|
128
|
-
this.failures = succeeded ? 0 : this.failures + 1
|
|
131
|
+
const wait = await this.round(signal, forced)
|
|
129
132
|
if (this.skipsWait(signal)) continue
|
|
130
133
|
await new Promise<void>((resolve) => {
|
|
131
|
-
const timer = setTimeout(resolve,
|
|
134
|
+
const timer = setTimeout(resolve, wait)
|
|
132
135
|
this.wake = () => { clearTimeout(timer); resolve() }
|
|
133
136
|
})
|
|
134
137
|
this.wake = undefined
|
|
@@ -136,28 +139,72 @@ class Poller {
|
|
|
136
139
|
}
|
|
137
140
|
}
|
|
138
141
|
|
|
139
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* When each host of one poller is read next. A host is due at once until its first read settles; after a read it is
|
|
144
|
+
* due one delay after the start of the round that read it, and the delay grows with its consecutive failed reads.
|
|
145
|
+
*/
|
|
146
|
+
class HostSchedule {
|
|
147
|
+
private readonly hosts = new Map<string, { readonly failures: number; readonly dueAt: number }>()
|
|
148
|
+
|
|
149
|
+
/** @param delay - milliseconds between two reads of a host after the given number of consecutive failed reads. */
|
|
150
|
+
constructor(private readonly delay: (failures: number) => number) {}
|
|
151
|
+
|
|
152
|
+
/** Whether a round that starts at `now` reads the host. */
|
|
153
|
+
due(key: string, now: number): boolean {
|
|
154
|
+
return (this.hosts.get(key)?.dueAt ?? 0) <= now
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Record whether the read of the host succeeded in the round that started at `started`. */
|
|
158
|
+
settle(key: string, started: number, succeeded: boolean): void {
|
|
159
|
+
const failures = succeeded ? 0 : (this.hosts.get(key)?.failures ?? 0) + 1
|
|
160
|
+
this.hosts.set(key, { failures, dueAt: started + this.delay(failures) })
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Milliseconds from `now` until the first of `keys` is due, or the delay between two successful reads without any key. */
|
|
164
|
+
wait(keys: readonly string[], now: number): number {
|
|
165
|
+
if (keys.length === 0) return this.delay(0)
|
|
166
|
+
return Math.max(0, Math.min(...keys.map(key => this.hosts.get(key)?.dueAt ?? 0)) - now)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** One host a scope reads, with the provider that lists on it. */
|
|
171
|
+
interface Target {
|
|
172
|
+
readonly source: ForgeViewerSource
|
|
173
|
+
readonly host: string
|
|
174
|
+
readonly key: string
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** The readers of one repository scope, the poller they share, when each host is read next, and what was read. */
|
|
140
178
|
class Scope {
|
|
141
179
|
readonly readers = new Set<Reader<ForgeReviewFrame>>()
|
|
142
180
|
readonly hosts = new Map<string, ForgeReviewHost>()
|
|
181
|
+
readonly schedule: HostSchedule
|
|
143
182
|
reading = false
|
|
144
183
|
readonly poller: Poller
|
|
145
184
|
|
|
146
185
|
/**
|
|
147
|
-
* @param
|
|
148
|
-
* @param
|
|
186
|
+
* @param repository - the repository the scope lists in, or null for every repository of every host.
|
|
187
|
+
* @param round - reads the scope's due hosts once, every host when `forced`; resolves to the wait before the next round.
|
|
188
|
+
* @param delay - milliseconds between two reads of a host after the given number of consecutive failed reads.
|
|
149
189
|
*/
|
|
150
|
-
constructor(
|
|
151
|
-
|
|
190
|
+
constructor(
|
|
191
|
+
readonly repository: ViewerScope,
|
|
192
|
+
round: (scope: Scope, signal: AbortSignal, forced: boolean) => Promise<number>,
|
|
193
|
+
delay: (failures: number) => number,
|
|
194
|
+
) {
|
|
195
|
+
this.schedule = new HostSchedule(delay)
|
|
196
|
+
this.poller = new Poller((signal, forced) => round(this, signal, forced))
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** The hosts the scope reads, in registration and configuration order: every host, or the one its repository is on. */
|
|
200
|
+
targets(order: readonly ForgeViewerSource[]): Target[] {
|
|
201
|
+
const only = this.repository?.host.toLowerCase()
|
|
202
|
+
return order.flatMap(source => source.hosts.filter(host => only === undefined || host === only)
|
|
203
|
+
.map(host => ({ source, host, key: hostKey(source.forge, host) })))
|
|
152
204
|
}
|
|
153
205
|
|
|
154
206
|
frame(order: readonly ForgeViewerSource[]): ForgeReviewFrame {
|
|
155
|
-
const hosts
|
|
156
|
-
for (const source of order) {
|
|
157
|
-
for (const host of source.hosts) {
|
|
158
|
-
hosts.push(this.hosts.get(hostKey(source.forge, host)) ?? emptyHost(source, host))
|
|
159
|
-
}
|
|
160
|
-
}
|
|
207
|
+
const hosts = this.targets(order).map(({ source, host, key }) => this.hosts.get(key) ?? emptyHost(source, host))
|
|
161
208
|
return { hosts, reading: this.reading }
|
|
162
209
|
}
|
|
163
210
|
}
|
|
@@ -167,6 +214,7 @@ export class ViewerLists {
|
|
|
167
214
|
private readonly scopes = new Map<string, Scope>()
|
|
168
215
|
private readonly countReaders = new Set<Reader<ForgeReviewCountFrame>>()
|
|
169
216
|
private readonly counts = new Map<string, number>()
|
|
217
|
+
private readonly countSchedule = new HostSchedule(failures => this.delay(this.timing.countIntervalMs, failures))
|
|
170
218
|
private countPoller: Poller | undefined
|
|
171
219
|
private disposed = false
|
|
172
220
|
|
|
@@ -179,18 +227,19 @@ export class ViewerLists {
|
|
|
179
227
|
/**
|
|
180
228
|
* Stream the lists of one repository scope: the lists read so far first, then a frame after each read settles.
|
|
181
229
|
* The stream ends when `signal` aborts or the hub is disposed; the last stream of a scope stops its reads.
|
|
182
|
-
* @param scope - one repository, or null for every repository.
|
|
230
|
+
* @param scope - one repository on its host, or null for every repository of every host.
|
|
183
231
|
* @param signal - ends the stream.
|
|
184
232
|
* @returns frames, each complete.
|
|
185
233
|
*/
|
|
186
234
|
async *lists(scope: ViewerScope, signal: AbortSignal): AsyncIterable<ForgeReviewFrame> {
|
|
187
235
|
signal.throwIfAborted()
|
|
188
236
|
if (this.disposed) return
|
|
189
|
-
const key = scope === null ? '' : `${scope.owner}/${scope.name}`.toLowerCase()
|
|
237
|
+
const key = scope === null ? '' : `${scope.host}\n${scope.owner}/${scope.name}`.toLowerCase()
|
|
190
238
|
let state = this.scopes.get(key)
|
|
191
239
|
if (state === undefined) {
|
|
192
240
|
state = new Scope(
|
|
193
|
-
(created, round) => this.readScope(created,
|
|
241
|
+
scope, (created, round, forced) => this.readScope(created, round, forced),
|
|
242
|
+
failures => this.delay(this.timing.listIntervalMs, failures),
|
|
194
243
|
)
|
|
195
244
|
this.scopes.set(key, state)
|
|
196
245
|
}
|
|
@@ -221,7 +270,7 @@ export class ViewerLists {
|
|
|
221
270
|
const reader = new Reader<ForgeReviewCountFrame>(signal)
|
|
222
271
|
this.countReaders.add(reader)
|
|
223
272
|
reader.push(this.countFrame())
|
|
224
|
-
this.countPoller ??= new Poller(
|
|
273
|
+
this.countPoller ??= new Poller((round, forced) => this.readCounts(round, forced))
|
|
225
274
|
try {
|
|
226
275
|
yield* reader.frames()
|
|
227
276
|
} finally {
|
|
@@ -271,45 +320,72 @@ export class ViewerLists {
|
|
|
271
320
|
await Promise.all(pollers.map(async (poller) =>{ await poller.stop() }))
|
|
272
321
|
}
|
|
273
322
|
|
|
274
|
-
/**
|
|
275
|
-
|
|
276
|
-
|
|
323
|
+
/**
|
|
324
|
+
* Read every list of the scope's due hosts once, of every host when `forced`.
|
|
325
|
+
* @returns milliseconds until the scope's next host is due.
|
|
326
|
+
*/
|
|
327
|
+
private async readScope(scope: Scope, signal: AbortSignal, forced: boolean): Promise<number> {
|
|
328
|
+
const started = Date.now()
|
|
329
|
+
const targets = scope.targets(this.sources.sources())
|
|
330
|
+
const repository = scope.repository === null ? null : { owner: scope.repository.owner, name: scope.repository.name }
|
|
277
331
|
scope.reading = true
|
|
278
332
|
this.publish(scope)
|
|
279
|
-
|
|
333
|
+
await Promise.all(targets.filter(target => forced || scope.schedule.due(target.key, started)).map(async ({ source, host, key }) => {
|
|
280
334
|
let succeeded = true
|
|
281
335
|
let hostFailure: ForgeFailure | undefined
|
|
282
336
|
for (const filter of FILTERS) {
|
|
283
337
|
if (!source.filters.has(filter)) continue
|
|
284
338
|
const query: ForgeViewerQuery = { host, filter, repository, limit: Math.min(source.maxItems, this.timing.pageSize) }
|
|
285
339
|
const result = hostFailure ?? await this.read(() => this.sources.list(source.forge, query, signal), signal)
|
|
286
|
-
if (signal.aborted) return
|
|
340
|
+
if (signal.aborted) return
|
|
287
341
|
if ('code' in result && HOST_FAILURES.has(result.code)) hostFailure = result
|
|
288
342
|
succeeded = this.settle(scope, source, host, filter, result) && succeeded
|
|
289
343
|
if (repository === null && !('code' in result) && filter === 'review-requested') {
|
|
290
|
-
this.counts.set(
|
|
344
|
+
this.counts.set(key, result.total)
|
|
291
345
|
this.publishCount()
|
|
292
346
|
}
|
|
293
347
|
this.publish(scope)
|
|
294
348
|
}
|
|
295
|
-
|
|
296
|
-
|
|
349
|
+
const signIn = hostFailure?.code === 'unauthenticated' ? await this.signInOf(scope, source, host, signal) : null
|
|
350
|
+
if (signal.aborted) return
|
|
351
|
+
const current = scope.hosts.get(key) ?? emptyHost(source, host)
|
|
352
|
+
if (current.signIn !== signIn) {
|
|
353
|
+
scope.hosts.set(key, { ...current, signIn })
|
|
354
|
+
this.publish(scope)
|
|
355
|
+
}
|
|
356
|
+
scope.schedule.settle(key, started, succeeded)
|
|
357
|
+
}))
|
|
297
358
|
scope.reading = false
|
|
298
359
|
if (!signal.aborted) this.publish(scope)
|
|
299
|
-
return
|
|
360
|
+
return scope.schedule.wait(targets.map(target => target.key), Date.now())
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/** The sign-in command the scope already holds for the host, else the one its provider names now, else null. */
|
|
364
|
+
private async signInOf(scope: Scope, source: ForgeViewerSource, host: string, signal: AbortSignal): Promise<string | null> {
|
|
365
|
+
const known = scope.hosts.get(hostKey(source.forge, host))?.signIn ?? null
|
|
366
|
+
if (known !== null) return known
|
|
367
|
+
const command = await this.read<string | null>(() => this.sources.signIn(source.forge, host, signal), signal)
|
|
368
|
+
return typeof command === 'string' ? command : null
|
|
300
369
|
}
|
|
301
370
|
|
|
302
|
-
/**
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
371
|
+
/**
|
|
372
|
+
* Read the count of every due host once, of every host when `forced`.
|
|
373
|
+
* @returns milliseconds until the next host is due.
|
|
374
|
+
*/
|
|
375
|
+
private async readCounts(signal: AbortSignal, forced: boolean): Promise<number> {
|
|
376
|
+
const started = Date.now()
|
|
377
|
+
const targets = this.sources.sources().filter(source => source.filters.has('review-requested'))
|
|
378
|
+
.flatMap(source => source.hosts.map(host => ({ source, host, key: hostKey(source.forge, host) })))
|
|
379
|
+
await Promise.all(targets.filter(target => forced || this.countSchedule.due(target.key, started)).map(async ({ source, host, key }) => {
|
|
306
380
|
const result = await this.read(() => this.sources.count(source.forge, host, signal), signal)
|
|
307
|
-
if (signal.aborted
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
381
|
+
if (signal.aborted) return
|
|
382
|
+
if (!('code' in result)) {
|
|
383
|
+
this.counts.set(key, result.get('review-requested') ?? 0)
|
|
384
|
+
this.publishCount()
|
|
385
|
+
}
|
|
386
|
+
this.countSchedule.settle(key, started, !('code' in result))
|
|
387
|
+
}))
|
|
388
|
+
return this.countSchedule.wait(targets.map(target => target.key), Date.now())
|
|
313
389
|
}
|
|
314
390
|
|
|
315
391
|
/** Run one read, turning a rejection into an `unavailable` failure and reporting it unless `signal` aborted. */
|
|
@@ -371,5 +447,5 @@ function hostKey(forge: string, host: string): string {
|
|
|
371
447
|
function emptyHost(source: ForgeViewerSource, host: string): ForgeReviewHost {
|
|
372
448
|
const lists: Partial<Record<ForgeViewerFilter, ForgeReviewList>> = {}
|
|
373
449
|
for (const filter of FILTERS) if (source.filters.has(filter)) lists[filter] = EMPTY_LIST
|
|
374
|
-
return { forge: source.forge, host, viewer: null, lists }
|
|
450
|
+
return { forge: source.forge, host, viewer: null, signIn: null, lists }
|
|
375
451
|
}
|