@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,115 @@
|
|
|
1
|
+
/** Staged host list of a provider row, using the shared Plugins form model. */
|
|
2
|
+
import { SettingsFormModel, type SettingsFormScope, type SettingsFormShell } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
3
|
+
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store'
|
|
4
|
+
|
|
5
|
+
/** The live-editable field of a forge provider's Config. */
|
|
6
|
+
export interface HostSettings {
|
|
7
|
+
hosts: string[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** The saved and staged host lists with the shared form status. */
|
|
11
|
+
export interface HostFormState extends SettingsFormShell {
|
|
12
|
+
/** Hosts the provider serves, as its configuration lists them. */
|
|
13
|
+
readonly saved: readonly string[]
|
|
14
|
+
/** Hosts a save would store: `saved` while nothing is staged. */
|
|
15
|
+
readonly draft: readonly string[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Why a typed host was not staged. */
|
|
19
|
+
export type HostProblem =
|
|
20
|
+
| { readonly kind: 'invalid' }
|
|
21
|
+
| { readonly kind: 'duplicate'; readonly host: string }
|
|
22
|
+
| { readonly kind: 'taken'; readonly host: string }
|
|
23
|
+
|
|
24
|
+
/** What a provider row's host list offers its page. */
|
|
25
|
+
export interface HostFormActions {
|
|
26
|
+
/**
|
|
27
|
+
* Stage one more host. The text is a host name with an optional port, or a URL, of which only the host is taken.
|
|
28
|
+
* @param text - what the reader typed.
|
|
29
|
+
* @returns undefined once staged or for blank text, else why the host was refused.
|
|
30
|
+
*/
|
|
31
|
+
readonly add: (text: string) => HostProblem | undefined
|
|
32
|
+
/** Stage the removal of a host; the last host stays. */
|
|
33
|
+
readonly remove: (host: string) => void
|
|
34
|
+
/** Write the staged list, then read back what the Host accepted. */
|
|
35
|
+
readonly save: () => void
|
|
36
|
+
/** Drop the staged list. */
|
|
37
|
+
readonly discard: () => void
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A host name with an optional port. The providers' Config holds the same rule and decides what a save stores; this
|
|
42
|
+
* copy only answers before a save.
|
|
43
|
+
*/
|
|
44
|
+
const HOST = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*(:\d+)?$/i
|
|
45
|
+
|
|
46
|
+
/** A URL with a scheme, of which a typed host keeps only the authority. */
|
|
47
|
+
const URL_FORM = /^[a-z][a-z0-9+.-]*:\/\//i
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Read the host a reader typed: a URL gives its host and port, any other text is taken as written, in lowercase.
|
|
51
|
+
* @param text - what the reader typed.
|
|
52
|
+
* @returns the lowercase host, which may still be malformed.
|
|
53
|
+
*/
|
|
54
|
+
export function typedHost(text: string): string {
|
|
55
|
+
const trimmed = text.trim()
|
|
56
|
+
const host = URL_FORM.test(trimmed) && URL.canParse(trimmed) ? new URL(trimmed).host : trimmed
|
|
57
|
+
return host.toLowerCase()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function listed(text: string): string[] {
|
|
61
|
+
return text.split('\n').filter(host => host !== '')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Stages additions and removals of a provider's hosts until the reader saves them as one list. */
|
|
65
|
+
export class HostSettingsForm {
|
|
66
|
+
private readonly form: SettingsFormModel<HostSettings>
|
|
67
|
+
private readonly state: SnapshotStore<HostFormState>
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param scope - Host-backed configuration form of the provider row.
|
|
71
|
+
* @param taken - hosts the other providers serve now, which this row cannot add.
|
|
72
|
+
*/
|
|
73
|
+
constructor(private readonly scope: SettingsFormScope<HostSettings>, private readonly taken: () => readonly string[]) {
|
|
74
|
+
this.form = new SettingsFormModel(scope, [{
|
|
75
|
+
field: 'hosts',
|
|
76
|
+
format: value => (value as readonly string[] | undefined ?? []).join('\n'),
|
|
77
|
+
// `remove` keeps the last host, so every staged text lists at least one.
|
|
78
|
+
parse: text => ({ kind: 'set', value: listed(text) }),
|
|
79
|
+
}])
|
|
80
|
+
this.state = this.form.bind(() => ({
|
|
81
|
+
...this.form.shell(), saved: this.scope.getSnapshot().value?.hosts ?? [], draft: listed(this.form.field('hosts').text),
|
|
82
|
+
}))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Build the registration face for the row page.
|
|
87
|
+
* @returns the list observable with the add, remove, save, and discard actions.
|
|
88
|
+
*/
|
|
89
|
+
inject(): { hooks: { hostForm: SnapshotStore<HostFormState> } } & HostFormActions {
|
|
90
|
+
const { edit, save, discard } = this.form.actions()
|
|
91
|
+
const stage = (hosts: readonly string[]): void => { edit('hosts', hosts.join('\n')) }
|
|
92
|
+
return {
|
|
93
|
+
hooks: { hostForm: this.state },
|
|
94
|
+
add: (text) => {
|
|
95
|
+
const host = typedHost(text)
|
|
96
|
+
if (host === '') return undefined
|
|
97
|
+
if (!HOST.test(host)) return { kind: 'invalid' }
|
|
98
|
+
const { draft } = this.state.getSnapshot()
|
|
99
|
+
if (draft.some(other => other.toLowerCase() === host)) return { kind: 'duplicate', host }
|
|
100
|
+
if (this.taken().some(other => other.toLowerCase() === host)) return { kind: 'taken', host }
|
|
101
|
+
stage([...draft, host])
|
|
102
|
+
return undefined
|
|
103
|
+
},
|
|
104
|
+
remove: (host) => {
|
|
105
|
+
const { draft } = this.state.getSnapshot()
|
|
106
|
+
if (draft.length > 1) stage(draft.filter(other => other !== host))
|
|
107
|
+
},
|
|
108
|
+
save,
|
|
109
|
+
discard,
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Release the accepted-value subscription. */
|
|
114
|
+
dispose(): void { this.form.dispose() }
|
|
115
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Sign-in state of the hosts a provider row serves, read through `forgePanel.hostReadiness`. */
|
|
2
|
+
import { createSnapshotStore, type SnapshotStore } from '@deepseek-ai/dsh-client-store'
|
|
3
|
+
import type { ForgeReadiness } from '@deepseek-ai/dsh-experimental-forge/types'
|
|
4
|
+
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
|
|
5
|
+
|
|
6
|
+
/** What the page knows of one host: its readiness once read, or that the first read is under way. */
|
|
7
|
+
export type HostSignIn = ForgeReadiness | { readonly state: 'checking' }
|
|
8
|
+
|
|
9
|
+
/** Reads one host's readiness; the signal ends the read. */
|
|
10
|
+
export type HostReadinessRead = (host: string, signal: AbortSignal) => Promise<RemoteResult<ForgeReadiness>>
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Keeps the last read sign-in state of each host of one provider. A check reads every named host at once and forgets
|
|
14
|
+
* the hosts it does not name; a later check ends the reads of an earlier one.
|
|
15
|
+
*/
|
|
16
|
+
export class HostSignInStates {
|
|
17
|
+
/** Sign-in state by host as the provider's configuration lists it. */
|
|
18
|
+
readonly states: SnapshotStore<ReadonlyMap<string, HostSignIn>> = createSnapshotStore<ReadonlyMap<string, HostSignIn>>(new Map())
|
|
19
|
+
private reads = new AbortController()
|
|
20
|
+
|
|
21
|
+
/** @param read - one host's readiness read. */
|
|
22
|
+
constructor(private readonly read: HostReadinessRead) {}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Read the sign-in state of `hosts`.
|
|
26
|
+
* @param hosts - every host to keep a state for.
|
|
27
|
+
* @param visibly - show each host as being checked until its read answers; otherwise a host keeps the state it has.
|
|
28
|
+
*/
|
|
29
|
+
check(hosts: readonly string[], visibly: boolean): void {
|
|
30
|
+
this.reads.abort()
|
|
31
|
+
const reads = new AbortController()
|
|
32
|
+
this.reads = reads
|
|
33
|
+
const known = this.states.getSnapshot()
|
|
34
|
+
this.states.set(new Map(hosts.map(host => [host, visibly ? { state: 'checking' } : known.get(host) ?? { state: 'checking' }])))
|
|
35
|
+
for (const host of hosts) {
|
|
36
|
+
void this.read(host, reads.signal).then((result) => {
|
|
37
|
+
if (reads.signal.aborted) return
|
|
38
|
+
const readiness: ForgeReadiness = result.ok ? result.value : { state: 'unavailable', message: result.error.message, signIn: null }
|
|
39
|
+
this.states.set(new Map(this.states.getSnapshot()).set(host, readiness))
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** End the reads under way; their answers are dropped. */
|
|
45
|
+
dispose(): void { this.reads.abort() }
|
|
46
|
+
}
|
package/src/client/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Browser entry of the forge panel: the Session panel's change requests
|
|
3
|
-
* section
|
|
3
|
+
* section and Environment rows, the changes view, the
|
|
4
4
|
* worktree option and creation card, and their Remote.
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -27,7 +27,6 @@ export type {
|
|
|
27
27
|
export type { ChangesTabInjected, ChangesTabProps } from './ChangesTab.tsx'
|
|
28
28
|
export type { ChangesTabTitleProps } from './ChangesTabTitle.tsx'
|
|
29
29
|
export type { DiffFileAction, DiffFileProps, DiffFileText } from './DiffFile.tsx'
|
|
30
|
-
export type { AttentionIndicatorInjected, AttentionIndicatorProps } from './AttentionIndicator.tsx'
|
|
31
30
|
export type {
|
|
32
31
|
ChangeRequestsActionsInjected, ChangeRequestsActionsProps, ChangeRequestsSectionInjected, ChangeRequestsSectionProps,
|
|
33
32
|
} from './ChangeRequestsSection.tsx'
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/** The writes the changes view makes to local changes: their requests, their one confirmation, and their notices. */
|
|
2
|
+
|
|
3
|
+
import { useRef, useState } from 'react'
|
|
4
|
+
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
|
|
5
|
+
import type { ForgeDiffFile, ForgeLocalWrite, ForgeLocalWriteResult } from '../types.ts'
|
|
6
|
+
import type { ForgePanelKey } from './locales.ts'
|
|
7
|
+
import type { NoticeOptions } from './source.ts'
|
|
8
|
+
|
|
9
|
+
/** A write a reader asks for on files of the shown scope. */
|
|
10
|
+
export type LocalWriteKind = 'stage' | 'unstage' | 'restore'
|
|
11
|
+
|
|
12
|
+
/** What the writes need from the view. */
|
|
13
|
+
export interface LocalWritesDeps {
|
|
14
|
+
/** Send one write to the Host; never retried. */
|
|
15
|
+
readonly localWrite: (write: ForgeLocalWrite) => Promise<RemoteResult<ForgeLocalWriteResult>>
|
|
16
|
+
/** Show a notice. */
|
|
17
|
+
readonly report: (key: ForgePanelKey, options?: NoticeOptions) => void
|
|
18
|
+
/** Read the shown scope again. */
|
|
19
|
+
readonly reread: () => void
|
|
20
|
+
/** Whether the shown scope is being read again; until it ends, the shown files can be ones a write already changed. */
|
|
21
|
+
readonly rereading: boolean
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The writes of one changes view. */
|
|
25
|
+
export interface LocalWrites {
|
|
26
|
+
/** Whether a write is in flight or the scope is read again; no write of the shown files starts until both end. */
|
|
27
|
+
readonly writing: boolean
|
|
28
|
+
/** The file whose restoration waits for the reader's answer, with the two answers; null while none waits. */
|
|
29
|
+
readonly restoring: { readonly file: ForgeDiffFile; readonly confirm: () => void; readonly cancel: () => void } | null
|
|
30
|
+
/** Stage or unstage the files at once; ask before restoring the first of them. Without files, or while `writing`, nothing happens. */
|
|
31
|
+
readonly write: (kind: LocalWriteKind, files: readonly ForgeDiffFile[]) => void
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Notices of refusals the Host reports by code; any other failure shows its message. */
|
|
35
|
+
const REFUSED: Readonly<Record<string, ForgePanelKey>> = {
|
|
36
|
+
'forgePanel/local-stale': 'toast.writeStale',
|
|
37
|
+
'forgePanel/local-path-replaced': 'toast.writeReplaced',
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Every path a file's change names: a rename also names the path it left. */
|
|
41
|
+
function pathsOf(files: readonly ForgeDiffFile[]): string[] {
|
|
42
|
+
return files.flatMap(file => file.previousPath === null ? [file.path] : [file.previousPath, file.path])
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Build the request for one kind of write.
|
|
47
|
+
* @param kind - the write.
|
|
48
|
+
* @param files - files of the shown scope: `unstaged` for staging and restoring, `staged` for unstaging.
|
|
49
|
+
* @returns the request, which names each staged or restored file with the digest of the change shown.
|
|
50
|
+
*/
|
|
51
|
+
export function writeRequest(kind: LocalWriteKind, files: readonly ForgeDiffFile[]): ForgeLocalWrite {
|
|
52
|
+
if (kind === 'unstage') return { kind, paths: pathsOf(files) }
|
|
53
|
+
return { kind, files: files.map(file => ({ path: file.path, digest: file.digest })) }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The last segment of a path, which notices name a file by. */
|
|
57
|
+
function nameOf(path: string): string {
|
|
58
|
+
return path.slice(path.lastIndexOf('/') + 1)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Hold the writes of one changes view. Every settled write reads the scope again, since even a failed one can have
|
|
63
|
+
* changed some of its paths. A staged or unstaged set reports with an undo that returns the index entries of those
|
|
64
|
+
* paths to their state before the write; a restoration cannot be undone, so it waits for a confirmation.
|
|
65
|
+
* @param deps - the Remote write, the notice reporter, and the reread of the shown scope.
|
|
66
|
+
* @returns the state and actions of the writes.
|
|
67
|
+
*/
|
|
68
|
+
export function useLocalWrites(deps: LocalWritesDeps): LocalWrites {
|
|
69
|
+
const [writing, setWriting] = useState(false)
|
|
70
|
+
const [asked, setAsked] = useState<ForgeDiffFile | null>(null)
|
|
71
|
+
// The state above lags a second press within the same frame.
|
|
72
|
+
const busy = useRef(false)
|
|
73
|
+
const latest = useRef(deps)
|
|
74
|
+
latest.current = deps
|
|
75
|
+
|
|
76
|
+
const send = (request: ForgeLocalWrite, settled: (result: RemoteResult<ForgeLocalWriteResult>) => void): void => {
|
|
77
|
+
busy.current = true
|
|
78
|
+
setWriting(true)
|
|
79
|
+
void latest.current.localWrite(request).then((result) => {
|
|
80
|
+
busy.current = false
|
|
81
|
+
setWriting(false)
|
|
82
|
+
latest.current.reread()
|
|
83
|
+
settled(result)
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
const undo = (tree: string, paths: readonly string[]): void => {
|
|
87
|
+
if (busy.current) {
|
|
88
|
+
latest.current.report('toast.undoFailed')
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
send({ kind: 'reindex', tree, paths }, (result) => { if (!result.ok) latest.current.report('toast.undoFailed') })
|
|
92
|
+
}
|
|
93
|
+
const start = (kind: LocalWriteKind, files: readonly ForgeDiffFile[], first: ForgeDiffFile): void => {
|
|
94
|
+
send(writeRequest(kind, files), (result) => {
|
|
95
|
+
const { report } = latest.current
|
|
96
|
+
if (!result.ok) {
|
|
97
|
+
report(REFUSED[result.error.code] ?? 'toast.writeFailed', { params: { message: result.error.message } })
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
const name = nameOf(first.path)
|
|
101
|
+
if (kind === 'restore') {
|
|
102
|
+
report(first.untracked ? 'toast.fileDeleted' : 'toast.fileRestored', { tone: 'success', params: { name } })
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
const one = files.length === 1
|
|
106
|
+
const key = kind === 'stage' ? one ? 'toast.staged' : 'toast.stagedMany' : one ? 'toast.unstaged' : 'toast.unstagedMany'
|
|
107
|
+
const tree = result.value.undo
|
|
108
|
+
const paths = pathsOf(files)
|
|
109
|
+
report(key, { tone: 'success', params: { name, count: files.length }, ...tree === null ? {} : { undo: () => { undo(tree, paths) } } })
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
writing: writing || deps.rereading,
|
|
114
|
+
restoring: asked === null ? null : {
|
|
115
|
+
file: asked,
|
|
116
|
+
confirm: () => {
|
|
117
|
+
setAsked(null)
|
|
118
|
+
start('restore', [asked], asked)
|
|
119
|
+
},
|
|
120
|
+
cancel: () => { setAsked(null) },
|
|
121
|
+
},
|
|
122
|
+
write: (kind, files) => {
|
|
123
|
+
const [first] = files
|
|
124
|
+
if (busy.current || latest.current.rereading || first === undefined) return
|
|
125
|
+
if (kind === 'restore') setAsked(first)
|
|
126
|
+
else start(kind, files, first)
|
|
127
|
+
},
|
|
128
|
+
}
|
|
129
|
+
}
|