@deepseek-ai/dsh-experimental-client-ui-forge 0.2.3-alpha.2 → 0.2.3-alpha.4
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 +10 -10
- package/README.md +37 -19
- package/README.zh.md +37 -19
- package/lib/client.js +22 -17
- package/lib/client.js.map +1 -1
- package/lib/index.js +941 -188
- package/lib/typert.host.js +894 -175
- package/lib/typert.remote-client.d.ts +35 -17
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +751 -146
- 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/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 +31 -13
- 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 +28 -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/ChangeStatus.d.ts +41 -0
- package/lib/types/client/ChangeStatus.d.ts.map +1 -0
- package/lib/types/client/ChangeStatus.js.map +1 -0
- 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 +35 -12
- 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 +11 -8
- package/lib/types/client/CommitMenu.d.ts.map +1 -1
- package/lib/types/client/CommitMenu.js.map +1 -1
- package/lib/types/client/CopyCommandButton.d.ts +19 -0
- package/lib/types/client/CopyCommandButton.d.ts.map +1 -0
- package/lib/types/client/CopyCommandButton.js.map +1 -0
- package/lib/types/client/DiffFile.d.ts +36 -5
- 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.d.ts +5 -5
- package/lib/types/client/FileLabel.d.ts.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 +21 -4
- 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 +25 -6
- 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 +36 -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/index.d.ts +1 -2
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js.map +1 -1
- 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 +111 -13
- package/lib/types/client/locales.d.ts.map +1 -1
- package/lib/types/client/locales.js.map +1 -1
- package/lib/types/client/minute-clock.d.ts +7 -0
- package/lib/types/client/minute-clock.d.ts.map +1 -0
- package/lib/types/client/minute-clock.js.map +1 -0
- 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 +26 -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 +17 -14
- 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 +19 -13
- 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 +19 -9
- 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 +15 -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 +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 -6
- package/lib/types/client/status.d.ts.map +1 -1
- package/lib/types/client/status.js.map +1 -1
- package/lib/types/client/thread-state.d.ts +2 -2
- package/lib/types/client/thread-state.d.ts.map +1 -1
- package/lib/types/client/thread-state.js.map +1 -1
- package/lib/types/client/toolbar-fold.d.ts +16 -6
- package/lib/types/client/toolbar-fold.d.ts.map +1 -1
- package/lib/types/client/toolbar-fold.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 +137 -36
- 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/panel.js.map +1 -1
- 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 +128 -13
- 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/lib/types/worktree.js.map +1 -1
- package/package.json +62 -58
- package/src/client/ActionToast.tsx +2 -2
- package/src/client/BaseMenu.module.css +15 -3
- package/src/client/BaseMenu.tsx +25 -88
- package/src/client/BranchPicker.tsx +170 -0
- package/src/client/ChangeRequestCard.tsx +194 -70
- package/src/client/ChangeRequestOverview.tsx +194 -82
- package/src/client/ChangeRequestsSection.tsx +45 -14
- package/src/client/ChangeStatus.module.css +70 -0
- package/src/client/ChangeStatus.tsx +104 -0
- package/src/client/ChangedFiles.tsx +22 -9
- package/src/client/ChangesLoading.tsx +1 -1
- package/src/client/ChangesTab.module.css +181 -33
- package/src/client/ChangesTab.tsx +499 -183
- package/src/client/ChangesTabTitle.tsx +2 -2
- package/src/client/CommitMenu.tsx +83 -42
- package/src/client/CopyCommandButton.tsx +25 -0
- package/src/client/DiffFile.tsx +147 -29
- package/src/client/EnvironmentRows.tsx +34 -28
- package/src/client/FileLabel.module.css +16 -18
- package/src/client/FileLabel.tsx +16 -32
- package/src/client/Forge.module.css +26 -6
- package/src/client/HeadMenu.tsx +69 -0
- package/src/client/HostSettings.module.css +194 -0
- package/src/client/HostSettings.tsx +194 -0
- package/src/client/LensFilter.tsx +13 -11
- package/src/client/ReasonButton.tsx +1 -1
- package/src/client/RefreshGlyph.tsx +1 -1
- package/src/client/ReviewComposer.tsx +31 -19
- package/src/client/ReviewControls.tsx +18 -9
- package/src/client/ReviewThread.tsx +65 -23
- package/src/client/ReviewThreads.tsx +133 -38
- package/src/client/SessionHoverForge.tsx +2 -2
- package/src/client/SessionRowForge.tsx +2 -2
- package/src/client/SubmitReview.tsx +7 -5
- package/src/client/ThreadList.module.css +4 -3
- package/src/client/ThreadList.tsx +11 -8
- package/src/client/ViewOptionsMenu.tsx +12 -10
- package/src/client/WorktreeNameDialog.tsx +17 -13
- package/src/client/WorktreeProgress.tsx +13 -11
- package/src/client/WorktreeSettings.tsx +8 -14
- package/src/client/WorktreeToggle.tsx +67 -37
- 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 +57 -10
- 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 +72 -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/index.ts +1 -2
- package/src/client/local-writes.ts +129 -0
- package/src/client/locales.ts +881 -97
- package/src/client/minute-clock.ts +19 -0
- package/src/client/mount.ts +121 -57
- package/src/client/review-page/ReviewActivity.tsx +406 -0
- package/src/client/review-page/ReviewChat.tsx +48 -19
- package/src/client/review-page/ReviewDetail.tsx +246 -78
- package/src/client/review-page/ReviewLabels.tsx +2 -2
- package/src/client/review-page/ReviewList.tsx +173 -151
- package/src/client/review-page/ReviewNav.tsx +1 -1
- package/src/client/review-page/ReviewPage.module.css +571 -23
- package/src/client/review-page/ReviewPage.tsx +84 -53
- package/src/client/review-page/ReviewSkeleton.tsx +108 -0
- package/src/client/review-page/ReviewStatus.tsx +74 -44
- 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 +24 -12
- 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 -9
- package/src/client/thread-state.ts +8 -7
- package/src/client/toolbar-fold.ts +59 -14
- 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 +319 -70
- package/src/local-diff.ts +151 -48
- package/src/local-write.ts +159 -0
- package/src/panel.ts +1 -1
- package/src/parse.ts +26 -4
- package/src/restore.ts +15 -0
- package/src/types.ts +121 -17
- package/src/viewer-lists.ts +124 -48
- package/src/worktree.ts +1 -1
- package/lib/types/client/AttentionIndicator.d.ts +0 -22
- package/lib/types/client/AttentionIndicator.d.ts.map +0 -1
- package/lib/types/client/AttentionIndicator.js.map +0 -1
- package/src/client/AttentionIndicator.tsx +0 -37
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/** A provider row's page on the Plugins page: the hosts the provider serves, each with its sign-in state. */
|
|
2
|
+
import { useCallback, useEffect, useId, useRef, useState, type ReactNode } from 'react'
|
|
3
|
+
import {
|
|
4
|
+
Button, IconRefreshOutlineRegular, IconTrashOutlineRegular, SettingsForm, StateDot, Tooltip, type StateDotState,
|
|
5
|
+
} from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
6
|
+
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store'
|
|
7
|
+
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
8
|
+
import type {} from '@deepseek-ai/dsh-client-ui-plugin-manager/client'
|
|
9
|
+
import { assertNever } from '@deepseek-ai/dsh-util-values'
|
|
10
|
+
import type { ForgePanelKey, NS } from './locales.ts'
|
|
11
|
+
import { CopyCommandButton } from './CopyCommandButton.tsx'
|
|
12
|
+
import type { HostFormActions, HostFormState, HostProblem } from './host-settings-form.ts'
|
|
13
|
+
import type { HostSignIn } from './host-sign-in.ts'
|
|
14
|
+
import { rowFormLabels } from './row-form-labels.ts'
|
|
15
|
+
import css from './HostSettings.module.css'
|
|
16
|
+
|
|
17
|
+
/** The forge family of a provider row that has a host page. */
|
|
18
|
+
export type HostForge = 'github' | 'gitlab'
|
|
19
|
+
|
|
20
|
+
/** Registration-side face of a provider row's host page. */
|
|
21
|
+
export interface HostSettingsInjected extends HostFormActions {
|
|
22
|
+
readonly hooks: {
|
|
23
|
+
/** The saved and staged host lists. */
|
|
24
|
+
readonly hostForm: SnapshotStore<HostFormState>
|
|
25
|
+
/** Sign-in state by saved host. */
|
|
26
|
+
readonly signIn: SnapshotStore<ReadonlyMap<string, HostSignIn>>
|
|
27
|
+
}
|
|
28
|
+
/** Which provider the row mounts. */
|
|
29
|
+
readonly forge: HostForge
|
|
30
|
+
/** Read the sign-in state of the saved hosts; `visibly` shows each host as being checked until its read answers. */
|
|
31
|
+
readonly checkSignIn: (hosts: readonly string[], visibly: boolean) => void
|
|
32
|
+
/** Copy a sign-in command and report the outcome. */
|
|
33
|
+
readonly copyCommand: (command: string) => void
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type HostSettingsProps = PropsRuntime<'plugins.row.config'> & PropsLocale<typeof NS> & InjectFace<HostSettingsInjected>
|
|
37
|
+
|
|
38
|
+
type Translate = HostSettingsProps['t']
|
|
39
|
+
|
|
40
|
+
/** What differs between the two rows' pages. */
|
|
41
|
+
interface ForgeCopy {
|
|
42
|
+
/** Key of what the provider's hosts call a change request. */
|
|
43
|
+
readonly noun: ForgePanelKey
|
|
44
|
+
/** The CLI the provider signs in with. */
|
|
45
|
+
readonly cli: string
|
|
46
|
+
/** A host name the field shows as its placeholder and a refusal names as an example. */
|
|
47
|
+
readonly example: string
|
|
48
|
+
/** Key of the refusal of a host the other provider serves. */
|
|
49
|
+
readonly taken: ForgePanelKey
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const FORGES: Record<HostForge, ForgeCopy> = {
|
|
53
|
+
github: { noun: 'noun.pullRequest', cli: 'gh', example: 'github.example.com', taken: 'hosts.taken.gitlab' },
|
|
54
|
+
gitlab: { noun: 'noun.mergeRequest', cli: 'glab', example: 'gitlab.example.com', taken: 'hosts.taken.github' },
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const STATES: Record<HostSignIn['state'], { readonly dot: StateDotState; readonly key: ForgePanelKey }> = {
|
|
58
|
+
ready: { dot: 'done', key: 'hosts.state.ready' },
|
|
59
|
+
unauthenticated: { dot: 'warning', key: 'hosts.state.unauthenticated' },
|
|
60
|
+
unavailable: { dot: 'error', key: 'hosts.state.unavailable' },
|
|
61
|
+
checking: { dot: 'ongoing', key: 'hosts.state.checking' },
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const CHECKING: HostSignIn = { state: 'checking' }
|
|
65
|
+
|
|
66
|
+
function problemText(problem: HostProblem, forge: HostForge, t: Translate): string {
|
|
67
|
+
switch (problem.kind) {
|
|
68
|
+
case 'invalid': return t('hosts.invalid', { example: FORGES[forge].example })
|
|
69
|
+
case 'duplicate': return t('hosts.duplicate', { host: problem.host })
|
|
70
|
+
case 'taken': return t(FORGES[forge].taken, { host: problem.host })
|
|
71
|
+
/* v8 ignore next -- closed union. */
|
|
72
|
+
default: return assertNever(problem, 'HostProblem')
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* One host of the list: its name, its sign-in state once saved, and its removal. A host that needs sign-in shows the
|
|
78
|
+
* provider's command to copy; a host that could not be checked shows why.
|
|
79
|
+
*/
|
|
80
|
+
function HostRow({ host, signIn, removable, disabled, onRemove, onCopy, t }: {
|
|
81
|
+
readonly host: string
|
|
82
|
+
/** The sign-in state of a saved host, or undefined for a host a save would add. */
|
|
83
|
+
readonly signIn: HostSignIn | undefined
|
|
84
|
+
/** Whether another host would remain. */
|
|
85
|
+
readonly removable: boolean
|
|
86
|
+
readonly disabled: boolean
|
|
87
|
+
readonly onRemove: (host: string) => void
|
|
88
|
+
readonly onCopy: (command: string) => void
|
|
89
|
+
readonly t: Translate
|
|
90
|
+
}): ReactNode {
|
|
91
|
+
const command = signIn?.state === 'unauthenticated' ? signIn.signIn?.command : undefined
|
|
92
|
+
const reason = signIn !== undefined && signIn.state !== 'checking' && signIn.state !== 'ready' && command === undefined ? signIn.message : null
|
|
93
|
+
return (
|
|
94
|
+
<li className={css.host} data-forge-host={host}>
|
|
95
|
+
<div className={css.row}>
|
|
96
|
+
<span className={css.name}>{host}</span>
|
|
97
|
+
{signIn === undefined
|
|
98
|
+
? <span className={css.unsaved}>{t('hosts.state.unsaved')}</span>
|
|
99
|
+
: (
|
|
100
|
+
<span className={css.state} data-state={signIn.state}>
|
|
101
|
+
<StateDot state={STATES[signIn.state].dot} />
|
|
102
|
+
{t(STATES[signIn.state].key)}
|
|
103
|
+
</span>
|
|
104
|
+
)}
|
|
105
|
+
<Tooltip label={removable ? t('hosts.remove', { host }) : t('hosts.keepOne')} side="bottom" delayMs={500}>
|
|
106
|
+
<button type="button" className={css.iconButton} aria-label={t('hosts.remove', { host })} aria-disabled={removable ? undefined : true}
|
|
107
|
+
disabled={disabled} onClick={() => { if (removable) onRemove(host) }}>
|
|
108
|
+
<IconTrashOutlineRegular size={14} />
|
|
109
|
+
</button>
|
|
110
|
+
</Tooltip>
|
|
111
|
+
</div>
|
|
112
|
+
{command !== undefined && (
|
|
113
|
+
<div className={css.command}>
|
|
114
|
+
<code className={css.commandText}>{command}</code>
|
|
115
|
+
<CopyCommandButton command={command} copyText={onCopy} label={t('signin.copyShort')}
|
|
116
|
+
ariaLabel={t('signin.copy')} variant="ghost" />
|
|
117
|
+
</div>
|
|
118
|
+
)}
|
|
119
|
+
{reason !== null && reason !== '' && <p className={css.reason}>{reason}</p>}
|
|
120
|
+
</li>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Render a provider row's configuration: the hosts it serves, staged until one save, and the sign-in state of each
|
|
126
|
+
* saved host, read when the page shows, after a save, and when the window regains focus. The summary view names the list.
|
|
127
|
+
* @param props - the Plugins page view, the staged list with its actions, the sign-in states, and copy.
|
|
128
|
+
* @returns the row page's form, or the summary line.
|
|
129
|
+
*/
|
|
130
|
+
export function HostSettings(props: HostSettingsProps): ReactNode {
|
|
131
|
+
const { t, forge, view, add: addHost } = props
|
|
132
|
+
const labelId = useId()
|
|
133
|
+
const messageId = useId()
|
|
134
|
+
const state = props.useHostForm(value => value)
|
|
135
|
+
const signIn = props.useSignIn(value => value)
|
|
136
|
+
const [text, setText] = useState('')
|
|
137
|
+
const [problem, setProblem] = useState<HostProblem>()
|
|
138
|
+
// The effect reads the latest list and check through refs, so it runs again only when the saved hosts change.
|
|
139
|
+
const saved = useRef(state.saved)
|
|
140
|
+
saved.current = state.saved
|
|
141
|
+
const checkSignIn = useRef(props.checkSignIn)
|
|
142
|
+
checkSignIn.current = props.checkSignIn
|
|
143
|
+
const shown = view === 'page' && state.available
|
|
144
|
+
const savedKey = state.saved.join('\n')
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (!shown) return
|
|
147
|
+
const again = (): void => { checkSignIn.current(saved.current, false) }
|
|
148
|
+
again()
|
|
149
|
+
window.addEventListener('focus', again)
|
|
150
|
+
return () => { window.removeEventListener('focus', again) }
|
|
151
|
+
}, [shown, savedKey])
|
|
152
|
+
const add = useCallback((): void => {
|
|
153
|
+
const refused = addHost(text)
|
|
154
|
+
setProblem(refused)
|
|
155
|
+
if (refused === undefined) setText('')
|
|
156
|
+
}, [addHost, text])
|
|
157
|
+
if (view === 'summary') return t('hosts.title')
|
|
158
|
+
const disabled = !state.writable || state.saving
|
|
159
|
+
return (
|
|
160
|
+
<SettingsForm labels={rowFormLabels(t, 'hosts.unavailable')} state={state} onSave={props.save} onDiscard={props.discard}>
|
|
161
|
+
<div className={css.field}>
|
|
162
|
+
<div className={css.head}>
|
|
163
|
+
<span className={css.label} id={labelId}>{t('hosts.title')}</span>
|
|
164
|
+
<Tooltip label={t('hosts.recheck')} side="bottom" delayMs={500}>
|
|
165
|
+
<button type="button" className={css.iconButton} aria-label={t('hosts.recheck')} onClick={() => { props.checkSignIn(state.saved, true) }}>
|
|
166
|
+
<IconRefreshOutlineRegular size={14} />
|
|
167
|
+
</button>
|
|
168
|
+
</Tooltip>
|
|
169
|
+
</div>
|
|
170
|
+
<ul className={css.hosts} aria-labelledby={labelId}>
|
|
171
|
+
{state.draft.map(host => (
|
|
172
|
+
<HostRow key={host} host={host} signIn={state.saved.includes(host) ? signIn.get(host) ?? CHECKING : undefined}
|
|
173
|
+
removable={state.draft.length > 1} disabled={disabled} onRemove={props.remove} onCopy={props.copyCommand} t={t} />
|
|
174
|
+
))}
|
|
175
|
+
</ul>
|
|
176
|
+
<div className={css.addRow}>
|
|
177
|
+
<input className={css.input} type="text" value={text} placeholder={FORGES[forge].example} aria-label={t('hosts.addLabel')}
|
|
178
|
+
aria-invalid={problem === undefined ? undefined : true} aria-describedby={messageId} disabled={disabled}
|
|
179
|
+
autoComplete="off" autoCapitalize="none" spellCheck={false}
|
|
180
|
+
onChange={(event) => { setText(event.target.value); setProblem(undefined) }}
|
|
181
|
+
onKeyDown={(event) => {
|
|
182
|
+
if (event.key !== 'Enter' || event.nativeEvent.isComposing) return
|
|
183
|
+
event.preventDefault()
|
|
184
|
+
add()
|
|
185
|
+
}} />
|
|
186
|
+
<Button variant="outline" className={css.add} disabled={disabled || text.trim() === ''} onClick={add}>{t('hosts.add')}</Button>
|
|
187
|
+
</div>
|
|
188
|
+
{problem === undefined
|
|
189
|
+
? <p id={messageId} className={css.hint}>{t('hosts.hint', { noun: t(FORGES[forge].noun), cli: FORGES[forge].cli })}</p>
|
|
190
|
+
: <p id={messageId} className={css.invalid} role="alert">{problemText(problem, forge, t)}</p>}
|
|
191
|
+
</div>
|
|
192
|
+
</SettingsForm>
|
|
193
|
+
)
|
|
194
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** The changes toolbar's filter lens menu: the Host's lenses with the files each keeps among the shown files. */
|
|
2
2
|
|
|
3
|
-
import { useState, type ReactNode } from 'react'
|
|
4
|
-
import { IconChevronDownOutlineRegular, IconLayersOutlineRegular, IconLoadingOutlineRegular, Menu, type MenuEntry } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
5
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
3
|
+
import { useCallback, useState, type ReactNode } from 'react'
|
|
4
|
+
import { IconChevronDownOutlineRegular, IconLayersOutlineRegular, IconLoadingOutlineRegular, Menu, type MenuEntry } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
5
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
6
6
|
import type { LensRun } from './lens-filter.ts'
|
|
7
7
|
import type { NS } from './locales.ts'
|
|
8
8
|
import css from './LensFilter.module.css'
|
|
@@ -70,6 +70,14 @@ export function LensFilterMenu({ lenses, chosen, run, choose, visible, t }: Prop
|
|
|
70
70
|
readonly visible: boolean
|
|
71
71
|
}): ReactNode {
|
|
72
72
|
const [open, setOpen] = useState(false)
|
|
73
|
+
const close = useCallback((): void => { setOpen(false) }, [])
|
|
74
|
+
const select = useCallback((row: string): void => {
|
|
75
|
+
setOpen(false)
|
|
76
|
+
const lens = lensOfRow(row)
|
|
77
|
+
/* v8 ignore next -- the menu offers only rows that choose a lens */
|
|
78
|
+
if (lens === undefined) return
|
|
79
|
+
choose(lens)
|
|
80
|
+
}, [choose])
|
|
73
81
|
let status: ReactNode = null
|
|
74
82
|
if (run.kind === 'running') {
|
|
75
83
|
status = <>
|
|
@@ -82,14 +90,8 @@ export function LensFilterMenu({ lenses, chosen, run, choose, visible, t }: Prop
|
|
|
82
90
|
return (
|
|
83
91
|
<Menu open={visible && open} portal dense align="start" autoFocus items={lensEntries(lenses, t)}
|
|
84
92
|
selectedId={chosen === null ? NO_LENS : lensRowId(chosen.id)}
|
|
85
|
-
onClose={
|
|
86
|
-
onSelect={
|
|
87
|
-
setOpen(false)
|
|
88
|
-
const lens = lensOfRow(row)
|
|
89
|
-
/* v8 ignore next -- the menu offers only rows that choose a lens */
|
|
90
|
-
if (lens === undefined) return
|
|
91
|
-
choose(lens)
|
|
92
|
-
}}
|
|
93
|
+
onClose={close}
|
|
94
|
+
onSelect={select}
|
|
93
95
|
anchor={(
|
|
94
96
|
<button type="button" className={css.trigger} aria-haspopup="menu" aria-expanded={visible && open}
|
|
95
97
|
aria-label={chosen === null ? t('filterLens.aria') : t('filterLens.chosenAria', { lens: chosen.title })}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** The info button of a status row that failed, whose tooltip gives the failure's reason. */
|
|
2
2
|
|
|
3
3
|
import type { ReactNode } from 'react'
|
|
4
|
-
import { IconInfoOutlineRegular, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
4
|
+
import { IconInfoOutlineRegular, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
5
5
|
import css from './Forge.module.css'
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Refresh glyph that turns while a refresh runs. */
|
|
2
2
|
|
|
3
3
|
import { useState, type ReactNode } from 'react'
|
|
4
|
-
import { IconRefreshOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
4
|
+
import { IconRefreshOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
5
5
|
import css from './RefreshGlyph.module.css'
|
|
6
6
|
|
|
7
7
|
/** Props of the refresh glyph. */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** Plain-text comment editor for a frozen selection in either review tab. */
|
|
2
2
|
|
|
3
|
-
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
|
3
|
+
import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'
|
|
4
4
|
import clsx from 'clsx'
|
|
5
|
-
import { Button, IconChevronDownOutlineRegular, Menu, MenuItemButton } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
6
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
5
|
+
import { Button, IconChevronDownOutlineRegular, Menu, MenuItemButton } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
6
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
7
7
|
import type { RemovedRecord, ReviewQueue } from './review-queue.ts'
|
|
8
8
|
import { INPUT_QUOTE_COPY, reviewRange, settleQuote, type QuoteCopy, type ReviewSelection, type ReviewSource } from './review.ts'
|
|
9
9
|
import type { NS } from './locales.ts'
|
|
@@ -38,6 +38,9 @@ export interface ReviewActions {
|
|
|
38
38
|
readonly renderActions?: (owner: Omit<ForgeCommentActionsProps, 'target'>) => ReactNode
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/** One way of sending the edited comment; a failure text preserves the form. */
|
|
42
|
+
type ReviewDeliver = (selection: ReviewSelection) => Promise<string | undefined>
|
|
43
|
+
|
|
41
44
|
/**
|
|
42
45
|
* Render a primary action with an optional second action in its menu.
|
|
43
46
|
* @param props - the main action, the optional menu action, the menu's name, and availability.
|
|
@@ -54,12 +57,18 @@ export function SplitAction({ disabled, label, run, menuLabel, menu, other }: {
|
|
|
54
57
|
readonly menu: () => void
|
|
55
58
|
}): ReactNode {
|
|
56
59
|
const [open, setOpen] = useState(false)
|
|
60
|
+
const closeMenu = useCallback((): void => { setOpen(false) }, [])
|
|
61
|
+
const toggleMenu = useCallback((): void => { setOpen(value => !value) }, [])
|
|
62
|
+
const chooseMenu = useCallback((): void => {
|
|
63
|
+
setOpen(false)
|
|
64
|
+
menu()
|
|
65
|
+
}, [menu])
|
|
57
66
|
return <div className={css.gitAction}>
|
|
58
67
|
<Button size="sm" variant="primary" className={clsx(other !== undefined && css.gitMain)} disabled={disabled} onClick={run}>{label}</Button>
|
|
59
|
-
{other !== undefined && <Menu open={open && !disabled} portal dense align="end" autoFocus onClose={
|
|
68
|
+
{other !== undefined && <Menu open={open && !disabled} portal dense align="end" autoFocus onClose={closeMenu}
|
|
60
69
|
anchor={<Button size="sm" variant="primary" className={clsx(css.gitArrow)} disabled={disabled} aria-haspopup="menu" aria-expanded={open && !disabled}
|
|
61
|
-
aria-label={menuLabel} onClick={
|
|
62
|
-
<MenuItemButton onSelect={
|
|
70
|
+
aria-label={menuLabel} onClick={toggleMenu}><IconChevronDownOutlineRegular size={14} /></Button>}>
|
|
71
|
+
<MenuItemButton onSelect={chooseMenu}>{other}</MenuItemButton>
|
|
63
72
|
</Menu>}
|
|
64
73
|
</div>
|
|
65
74
|
}
|
|
@@ -84,10 +93,10 @@ export function ReviewComposer({ selection, actions, close, visible = true, t }:
|
|
|
84
93
|
const running = useRef(false)
|
|
85
94
|
const input = useRef<HTMLTextAreaElement>(null)
|
|
86
95
|
useEffect(() => { input.current?.focus() }, [])
|
|
87
|
-
const comment = (): ReviewSelection => ({ ...selection, comment: { ...selection.comment, body: body.current } })
|
|
96
|
+
const comment = useCallback((): ReviewSelection => ({ ...selection, comment: { ...selection.comment, body: body.current } }), [selection])
|
|
88
97
|
const range = reviewRange(selection.comment)
|
|
89
98
|
/** Send the comment to the code host, closing the form once it is taken and keeping its text otherwise. */
|
|
90
|
-
const send = async (destination:
|
|
99
|
+
const send = useCallback(async (destination: ReviewDeliver | undefined): Promise<void> => {
|
|
91
100
|
if (running.current || destination === undefined) return
|
|
92
101
|
running.current = true
|
|
93
102
|
setBusy(true)
|
|
@@ -102,7 +111,16 @@ export function ReviewComposer({ selection, actions, close, visible = true, t }:
|
|
|
102
111
|
running.current = false
|
|
103
112
|
setBusy(false)
|
|
104
113
|
}
|
|
105
|
-
}
|
|
114
|
+
}, [close, comment, t])
|
|
115
|
+
const addToInput = useCallback((): void => {
|
|
116
|
+
const selected = comment()
|
|
117
|
+
settleQuote(actions.addToInput(selected), (accepted) => {
|
|
118
|
+
if (accepted) { actions.onQuoted?.(selected); close() }
|
|
119
|
+
else setError(t(copy.failed))
|
|
120
|
+
})
|
|
121
|
+
}, [actions, close, comment, copy.failed, t])
|
|
122
|
+
const runQueue = useCallback((): void => { void send(actions.queue) }, [actions.queue, send])
|
|
123
|
+
const runPublish = useCallback((): void => { void send(actions.publish) }, [actions.publish, send])
|
|
106
124
|
return (
|
|
107
125
|
<section className={css.root} aria-label={t('review.range', { range })}
|
|
108
126
|
data-forge-comment={`${selection.comment.side}${selection.comment.startLine}-${selection.comment.endLine}`}>
|
|
@@ -118,13 +136,7 @@ export function ReviewComposer({ selection, actions, close, visible = true, t }:
|
|
|
118
136
|
{error !== null && <div className={css.error} role="alert">{error}</div>}
|
|
119
137
|
<div className={css.actions}>
|
|
120
138
|
<Button size="sm" className={clsx(css.cancel)} disabled={busy} onClick={close}>{t('review.cancel')}</Button>
|
|
121
|
-
<Button size="sm" variant={actions.queue === undefined ? 'primary' : 'outline'} disabled={busy || empty} onClick={()
|
|
122
|
-
const selected = comment()
|
|
123
|
-
settleQuote(actions.addToInput(selected), (accepted) => {
|
|
124
|
-
if (accepted) { actions.onQuoted?.(selected); close() }
|
|
125
|
-
else setError(t(copy.failed))
|
|
126
|
-
})
|
|
127
|
-
}}>{t(copy.add)}</Button>
|
|
139
|
+
<Button size="sm" variant={actions.queue === undefined ? 'primary' : 'outline'} disabled={busy || empty} onClick={addToInput}>{t(copy.add)}</Button>
|
|
128
140
|
{actions.renderActions?.({
|
|
129
141
|
selection: {
|
|
130
142
|
path: selection.comment.path, side: selection.comment.side,
|
|
@@ -136,10 +148,10 @@ export function ReviewComposer({ selection, actions, close, visible = true, t }:
|
|
|
136
148
|
})}
|
|
137
149
|
{visible && actions.queue !== undefined && <SplitAction disabled={busy || actions.publishingBlocked === true || empty}
|
|
138
150
|
label={t(busy ? 'review.publishing' : actions.reviewStarted === true ? 'review.queue' : 'review.startReview')}
|
|
139
|
-
run={
|
|
140
|
-
other={actions.publish === undefined ? undefined : t('review.publish')} menu={
|
|
151
|
+
run={runQueue} menuLabel={t('review.hostActions')}
|
|
152
|
+
other={actions.publish === undefined ? undefined : t('review.publish')} menu={runPublish} />}
|
|
141
153
|
{actions.queue === undefined && actions.publish !== undefined && <Button size="sm" variant="primary"
|
|
142
|
-
disabled={busy || actions.publishingBlocked === true || empty} onClick={
|
|
154
|
+
disabled={busy || actions.publishingBlocked === true || empty} onClick={runPublish}>{t('review.publish')}</Button>}
|
|
143
155
|
|
|
144
156
|
</div>
|
|
145
157
|
</section>
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* share of shown files the reader marked viewed. The thread list shares the segmented radio group.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { useLayoutEffect, useRef, useState, type KeyboardEvent, type ReactNode } from 'react'
|
|
8
|
-
import { IconChevronDownOutlineRegular, Menu, Switch, Tooltip, type MenuEntry } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
9
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
7
|
+
import { useCallback, useLayoutEffect, useRef, useState, type KeyboardEvent, type ReactNode } from 'react'
|
|
8
|
+
import { IconChevronDownOutlineRegular, Menu, Switch, Tooltip, type MenuEntry } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
9
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
10
10
|
import type { ChangesLens } from './changes-store.ts'
|
|
11
11
|
import type { ForgePanelKey, NS } from './locales.ts'
|
|
12
12
|
import css from './ReviewControls.module.css'
|
|
@@ -14,6 +14,13 @@ import css from './ReviewControls.module.css'
|
|
|
14
14
|
/** Lenses in display order. */
|
|
15
15
|
export const LENSES: readonly ChangesLens[] = ['all', 'interface', 'implementation', 'test']
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Inert attribute for the measuring copies. React 18 forwards `inert` only as a string, and React 19
|
|
19
|
+
* treats an empty string as false; a non-empty string sets the attribute under both. Typed `object`
|
|
20
|
+
* because React 18's DOM types omit `inert` and React 19's declare it boolean.
|
|
21
|
+
*/
|
|
22
|
+
const INERT: object = { inert: 'inert' }
|
|
23
|
+
|
|
17
24
|
const LENS_LABEL: Record<ChangesLens, ForgePanelKey> = {
|
|
18
25
|
all: 'lens.all',
|
|
19
26
|
interface: 'lens.interface',
|
|
@@ -154,7 +161,7 @@ export function LensControl({ lens, counts, hideTests, choose, t, need }: LensPr
|
|
|
154
161
|
}, [key])
|
|
155
162
|
return <div ref={root} className={css.lensFit}>
|
|
156
163
|
<SegmentedChoice label={t('lens.aria')} value={lens} choose={choose} segments={segments} sizing="content" counted={counted} />
|
|
157
|
-
<div className={css.measures} aria-hidden="true" {...
|
|
164
|
+
<div className={css.measures} aria-hidden="true" {...INERT}>
|
|
158
165
|
<div ref={withCounts}><SegmentedChoice label="" value={lens} choose={choose} segments={segments} sizing="content" /></div>
|
|
159
166
|
<div ref={labelsOnly}><SegmentedChoice label="" value={lens} choose={choose} segments={segments} sizing="content" counted={false} /></div>
|
|
160
167
|
</div>
|
|
@@ -168,6 +175,11 @@ export function LensControl({ lens, counts, hideTests, choose, t, need }: LensPr
|
|
|
168
175
|
*/
|
|
169
176
|
export function LensMenu({ lens, counts, hideTests, choose, visible, t }: LensProps & { readonly visible: boolean }): ReactNode {
|
|
170
177
|
const [open, setOpen] = useState(false)
|
|
178
|
+
const close = useCallback((): void => { setOpen(false) }, [])
|
|
179
|
+
const select = useCallback((id: string): void => {
|
|
180
|
+
setOpen(false)
|
|
181
|
+
choose(id as ChangesLens)
|
|
182
|
+
}, [choose])
|
|
171
183
|
const items: MenuEntry[] = LENSES.map((item) => {
|
|
172
184
|
// Like the segment, a disabled lens shows no count, since hidden test files are not counted.
|
|
173
185
|
const disabled = item === 'test' && hideTests
|
|
@@ -179,11 +191,8 @@ export function LensMenu({ lens, counts, hideTests, choose, visible, t }: LensPr
|
|
|
179
191
|
})
|
|
180
192
|
return (
|
|
181
193
|
<Menu open={visible && open} portal dense align="start" autoFocus selectedId={lens} items={items}
|
|
182
|
-
onClose={
|
|
183
|
-
onSelect={
|
|
184
|
-
setOpen(false)
|
|
185
|
-
choose(id as ChangesLens)
|
|
186
|
-
}}
|
|
194
|
+
onClose={close}
|
|
195
|
+
onSelect={select}
|
|
187
196
|
anchor={(
|
|
188
197
|
<button type="button" className={css.trigger} aria-haspopup="menu" aria-expanded={visible && open}
|
|
189
198
|
aria-label={t('lens.menuAria', { lens: t(LENS_LABEL[lens]) })} data-forge-lens-menu={lens}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/** Inline comment records and the editing of comment drafts kept in the browser at their captured code location. */
|
|
2
2
|
|
|
3
|
-
import { useCallback, useState, useSyncExternalStore, type ReactNode } from 'react'
|
|
4
|
-
import { Button, Tag } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
5
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
3
|
+
import { useCallback, useMemo, useState, useSyncExternalStore, type ReactNode } from 'react'
|
|
4
|
+
import { Button, Tag } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
5
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
6
6
|
import type { ReviewActions } from './ReviewComposer.tsx'
|
|
7
7
|
import { CardMenu, DeleteConfirm } from './ReviewThreads.tsx'
|
|
8
8
|
import { EMPTY_FILE_REVIEW, type FileReviewState, type ReviewThread as Thread } from './review-queue.ts'
|
|
9
9
|
import { INPUT_QUOTE_COPY, reviewRange, settleQuote } from './review.ts'
|
|
10
|
-
import type { NS } from './locales.ts'
|
|
10
|
+
import type { ForgePanelKey, NS } from './locales.ts'
|
|
11
11
|
import css from './ReviewThreads.module.css'
|
|
12
12
|
import composerCss from './ReviewComposer.module.css'
|
|
13
13
|
|
|
@@ -25,6 +25,40 @@ export function useFileReview(actions: ReviewActions | undefined, path: string):
|
|
|
25
25
|
return useSyncExternalStore(actions?.records?.subscribe ?? noSubscription, read)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/** Copy of the publish button: the draft's move into the pending review, or how to start one. */
|
|
29
|
+
function publishKey(moving: boolean, started: boolean): ForgePanelKey {
|
|
30
|
+
if (moving) return 'review.publishing'
|
|
31
|
+
if (started) return 'review.queue'
|
|
32
|
+
return 'review.startReview'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The button that adds a saved comment draft to the pending review on the code host. */
|
|
36
|
+
function PublishButton({ moving, started, waiting, queue, move, t }: {
|
|
37
|
+
readonly moving: boolean
|
|
38
|
+
readonly started: boolean
|
|
39
|
+
readonly waiting: boolean
|
|
40
|
+
readonly queue: NonNullable<ReviewActions['queue']>
|
|
41
|
+
readonly move: (add: NonNullable<ReviewActions['queue']>) => Promise<void>
|
|
42
|
+
readonly t: PropsLocale<typeof NS>['t']
|
|
43
|
+
}) {
|
|
44
|
+
const publish = useCallback((): void => { void move(queue) }, [move, queue])
|
|
45
|
+
return (
|
|
46
|
+
<Button size="sm" disabled={waiting} onClick={publish}>
|
|
47
|
+
{t(publishKey(moving, started))}
|
|
48
|
+
</Button>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The button that opens a published comment again on the code host. */
|
|
53
|
+
function RecheckButton({ url, openLink, t }: {
|
|
54
|
+
readonly url: string
|
|
55
|
+
readonly openLink: (url: string) => void
|
|
56
|
+
readonly t: PropsLocale<typeof NS>['t']
|
|
57
|
+
}) {
|
|
58
|
+
const recheck = useCallback((): void => { openLink(url) }, [openLink, url])
|
|
59
|
+
return <Button size="sm" onClick={recheck}>{t('review.recheck')}</Button>
|
|
60
|
+
}
|
|
61
|
+
|
|
28
62
|
/**
|
|
29
63
|
* Render a saved comment at its line: its lines and state, the menu of its less frequent actions, its text, and Add to
|
|
30
64
|
* input. A reference or a publication receipt can be removed from the view, which leaves the main input and the code
|
|
@@ -47,15 +81,18 @@ export function ReviewThread({ thread, actions, locked, outdated, t }: PropsLoca
|
|
|
47
81
|
// A draft published while its form is open becomes a receipt, which has neither form.
|
|
48
82
|
const editing = mode === 'edit' && thread.kind === 'pending'
|
|
49
83
|
const confirming = mode === 'delete' && thread.kind === 'pending'
|
|
50
|
-
const quoted =
|
|
84
|
+
const quoted = useMemo(
|
|
85
|
+
() => editing ? { ...thread.selection, comment: { ...comment, body } } : thread.selection,
|
|
86
|
+
[body, comment, editing, thread.selection],
|
|
87
|
+
)
|
|
51
88
|
const range = reviewRange(comment)
|
|
52
89
|
const copy = actions.quoteCopy ?? INPUT_QUOTE_COPY
|
|
53
90
|
const status = thread.kind === 'pending' ? 'review.browserDraft' : thread.kind === 'published' ? 'review.published' : copy.added
|
|
54
|
-
const save = (): boolean => actions.records?.editThread(thread.key, body) === true
|
|
91
|
+
const save = useCallback((): boolean => actions.records?.editThread(thread.key, body) === true, [actions, body, thread.key])
|
|
55
92
|
const queue = actions.queue
|
|
56
93
|
const waiting = locked || moving
|
|
57
94
|
/** Add the draft to the pending review on the code host, then delete it from the browser. */
|
|
58
|
-
const move = async (add: NonNullable<ReviewActions['queue']>): Promise<void> => {
|
|
95
|
+
const move = useCallback(async (add: NonNullable<ReviewActions['queue']>): Promise<void> => {
|
|
59
96
|
setMoving(true)
|
|
60
97
|
setError(null)
|
|
61
98
|
try {
|
|
@@ -67,8 +104,8 @@ export function ReviewThread({ thread, actions, locked, outdated, t }: PropsLoca
|
|
|
67
104
|
} finally {
|
|
68
105
|
setMoving(false)
|
|
69
106
|
}
|
|
70
|
-
}
|
|
71
|
-
const select = (id: string): void => {
|
|
107
|
+
}, [actions, t, thread.selection, thread.key])
|
|
108
|
+
const select = useCallback((id: string): void => {
|
|
72
109
|
if (id === 'edit') {
|
|
73
110
|
setBody(comment.body)
|
|
74
111
|
setMode('edit')
|
|
@@ -78,7 +115,17 @@ export function ReviewThread({ thread, actions, locked, outdated, t }: PropsLoca
|
|
|
78
115
|
if (removed === null) setError(t('review.saveFailed'))
|
|
79
116
|
else actions.onRemoved?.(removed)
|
|
80
117
|
}
|
|
81
|
-
}
|
|
118
|
+
}, [actions, comment.body, t, thread.key])
|
|
119
|
+
const cancelDelete = useCallback((): void => { setError(null); setMode('view') }, [])
|
|
120
|
+
const confirmDelete = useCallback((): void => {
|
|
121
|
+
if (actions.records?.editThread(thread.key, null) !== true) setError(t('review.saveFailed'))
|
|
122
|
+
}, [actions, t, thread.key])
|
|
123
|
+
const addToInput = useCallback((): void => {
|
|
124
|
+
settleQuote(actions.addToInput(quoted), (accepted) => { if (!accepted) setError(t(copy.failed)) })
|
|
125
|
+
}, [actions, copy.failed, quoted, t])
|
|
126
|
+
const finishEdit = useCallback((): void => {
|
|
127
|
+
if (save()) { setMode('view'); setError(null) } else setError(t('review.saveFailed'))
|
|
128
|
+
}, [save, t])
|
|
82
129
|
return <section className={css.card} data-forge-review-thread={thread.kind} data-side={comment.side} aria-label={t('review.range', { range })}>
|
|
83
130
|
<div className={css.recordHeader}>
|
|
84
131
|
<div className={css.recordInfo}>
|
|
@@ -101,21 +148,16 @@ export function ReviewThread({ thread, actions, locked, outdated, t }: PropsLoca
|
|
|
101
148
|
}} />
|
|
102
149
|
: <div className={css.plain}>{comment.body}</div>}
|
|
103
150
|
{confirming && <DeleteConfirm question={t('thread.deleteConfirm')} confirmLabel={t('review.remove')} disabled={waiting} error={error}
|
|
104
|
-
cancel={
|
|
105
|
-
confirm={
|
|
151
|
+
cancel={cancelDelete}
|
|
152
|
+
confirm={confirmDelete} t={t} />}
|
|
106
153
|
{error !== null && !confirming && <div className={composerCss.error} role="alert">{error}</div>}
|
|
107
154
|
<div className={css.actions}>
|
|
108
|
-
<Button size="sm" disabled={quoted.comment.body.trim() === ''} onClick={()
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
{thread.kind === 'pending' && queue !== undefined && mode === 'view' && !outdated && <Button size="sm" disabled={waiting}
|
|
115
|
-
onClick={() => { void move(queue) }}>
|
|
116
|
-
{t(moving ? 'review.publishing' : actions.reviewStarted === true ? 'review.queue' : 'review.startReview')}
|
|
117
|
-
</Button>}
|
|
118
|
-
{thread.kind === 'published' && actions.openLink !== undefined && <Button size="sm" onClick={() => { actions.openLink?.(thread.url) }}>{t('review.recheck')}</Button>}
|
|
155
|
+
<Button size="sm" disabled={quoted.comment.body.trim() === ''} onClick={addToInput}>{t(copy.add)}</Button>
|
|
156
|
+
{editing && <Button size="sm" disabled={waiting || body.trim() === ''} onClick={finishEdit}>{t('review.done')}</Button>}
|
|
157
|
+
{thread.kind === 'pending' && queue !== undefined && mode === 'view' && !outdated && <PublishButton moving={moving}
|
|
158
|
+
started={actions.reviewStarted === true} waiting={waiting} queue={queue} move={move} t={t} />}
|
|
159
|
+
{thread.kind === 'published' && actions.openLink !== undefined
|
|
160
|
+
&& <RecheckButton url={thread.url} openLink={actions.openLink} t={t} />}
|
|
119
161
|
</div>
|
|
120
162
|
</section>
|
|
121
163
|
}
|