@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
|
@@ -9,7 +9,9 @@ export interface CodeSelection {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
function codeAt(node: Node | null): HTMLElement | null {
|
|
12
|
-
|
|
12
|
+
// A text node has no `closest`, so its parent element answers.
|
|
13
|
+
return (node as Partial<Element> | null)?.closest?.<HTMLElement>('[data-review-code]')
|
|
14
|
+
?? node?.parentElement?.closest<HTMLElement>('[data-review-code]') ?? null
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
/**
|
package/src/client/forge-copy.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useMemo } from 'react'
|
|
4
4
|
import type { ForgeDescription } from '@deepseek-ai/dsh-experimental-forge/types'
|
|
5
|
-
import type { TranslateNS } from '@deepseek-ai/dsh-client-ui-slots'
|
|
5
|
+
import type { TranslateNS } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
6
6
|
import type { NS } from './locales.ts'
|
|
7
7
|
|
|
8
8
|
/** The `forge` and `noun` parameters of copy that names the code host; a type alias so it passes as notice parameters. */
|
|
@@ -47,3 +47,13 @@ export function useForgeCopy(translate: TranslateNS<typeof NS>, url: string | nu
|
|
|
47
47
|
function hostOf(url: string): string {
|
|
48
48
|
return /^[a-z][a-z\d+.-]*:\/\/([^/?#]+)/i.exec(url)?.[1] ?? url
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Name the action that opens a change request on its code host.
|
|
53
|
+
* @param translate - forge panel copy.
|
|
54
|
+
* @param forge - product name of the code host, or null when no provider names one.
|
|
55
|
+
* @returns the label that names the code host, or the one that names the browser without a name.
|
|
56
|
+
*/
|
|
57
|
+
export function openOnLabel(translate: TranslateNS<typeof NS>, forge: string | null): string {
|
|
58
|
+
return forge === null ? translate('change.view') : translate('change.viewOn', { forge })
|
|
59
|
+
}
|
package/src/client/format.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Localized durations and relative times shown on change request cards. */
|
|
2
2
|
|
|
3
|
-
import { relativeTime } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
4
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
3
|
+
import { relativeTime } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
4
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
5
5
|
import type { NS } from './locales.ts'
|
|
6
6
|
|
|
7
7
|
type Translate = PropsLocale<typeof NS>['t']
|
package/src/client/glyphs.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/** Lifecycle glyphs of change requests
|
|
1
|
+
/** Lifecycle glyphs of change requests, outcome glyphs of their checks, the marks of their code hosts, and the marks of file headers. */
|
|
2
2
|
|
|
3
3
|
import type { ReactNode } from 'react'
|
|
4
4
|
import clsx from 'clsx'
|
|
5
|
-
import { IconCheckCircleFillRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
5
|
+
import { IconCheckCircleFillRegular, IconRightUpOutlineRegular, LinkIconRegular } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
6
6
|
import type { CheckState, ChecksRollup } from '@deepseek-ai/dsh-experimental-forge/types'
|
|
7
7
|
import type { ChangeRequestTone } from './status.ts'
|
|
8
8
|
import css from './Forge.module.css'
|
|
@@ -18,8 +18,8 @@ const BRANCH_ENDS = (
|
|
|
18
18
|
/** The head branch line that bends back toward the base, shared by the open and blocked shapes. */
|
|
19
19
|
const TOWARD_BASE = (
|
|
20
20
|
<>
|
|
21
|
-
<path d="M12 10.
|
|
22
|
-
<path d="M9.6
|
|
21
|
+
<path d="M12 10.9V5.5C12 4.4 11.1 3.5 10 3.5H8.2" />
|
|
22
|
+
<path d="M9.6 1.9L8 3.5L9.6 5.1" />
|
|
23
23
|
</>
|
|
24
24
|
)
|
|
25
25
|
|
|
@@ -60,7 +60,7 @@ const SHAPES: Record<ChangeRequestTone, ReactNode> = {
|
|
|
60
60
|
closed: (
|
|
61
61
|
<>
|
|
62
62
|
{BRANCH_ENDS}
|
|
63
|
-
<path d="M4 5.1V10.9M12 10.
|
|
63
|
+
<path d="M4 5.1V10.9M12 10.9V7.1M10.4 1.9L13.6 5.1M13.6 1.9L10.4 5.1" />
|
|
64
64
|
</>
|
|
65
65
|
),
|
|
66
66
|
}
|
|
@@ -148,3 +148,48 @@ export function CheckGlyph({ state, size = 16 }: { readonly state: CheckState; r
|
|
|
148
148
|
</span>
|
|
149
149
|
)
|
|
150
150
|
}
|
|
151
|
+
|
|
152
|
+
/** The public host whose site mark stands for each forge family, self-hosted instances included. */
|
|
153
|
+
const FORGE_SITE: Readonly<Record<string, string>> = { github: 'https://github.com', gitlab: 'https://gitlab.com' }
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Draw the mark of a code host on an action that opens it: the site mark of the provider's forge family, whatever the
|
|
157
|
+
* host name, or the leaving arrow for a family without a mark and for no provider.
|
|
158
|
+
* @param props.forge - forge family of the change request's provider, such as `github`, or null without one.
|
|
159
|
+
* @param props.size - width and height in pixels, 14 by default.
|
|
160
|
+
* @returns the decorative glyph.
|
|
161
|
+
*/
|
|
162
|
+
export function ForgeGlyph({ forge, size = 14 }: { readonly forge: string | null; readonly size?: number | undefined }): ReactNode {
|
|
163
|
+
const site = forge === null ? undefined : FORGE_SITE[forge]
|
|
164
|
+
return site === undefined ? <IconRightUpOutlineRegular size={size} /> : <LinkIconRegular kind="url" href={site} size={size} />
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** A file header mark the shared icons have no drawing of. */
|
|
168
|
+
export type FileMark = 'unstage' | 'restore' | 'unviewed'
|
|
169
|
+
|
|
170
|
+
const FILE_MARKS: Record<FileMark, ReactNode> = {
|
|
171
|
+
// The horizontal stroke of the shared plus, which stages.
|
|
172
|
+
unstage: <path vectorEffect="non-scaling-stroke" d="M2 8H14" />,
|
|
173
|
+
restore: (
|
|
174
|
+
<g strokeLinecap="round" strokeLinejoin="round">
|
|
175
|
+
<path vectorEffect="non-scaling-stroke" d="M5.5 2.5L2.5 5.5L5.5 8.5" />
|
|
176
|
+
<path vectorEffect="non-scaling-stroke" d="M2.5 5.5H9.5A4 4 0 0 1 9.5 13.5H6" />
|
|
177
|
+
</g>
|
|
178
|
+
),
|
|
179
|
+
// The ring of the shared check circle, which marks a viewed file.
|
|
180
|
+
unviewed: <circle vectorEffect="non-scaling-stroke" cx="8" cy="8" r="6.5" />,
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Draw a decorative mark of a file header at the weight of the shared Regular icons: a minus for unstaging, an arrow
|
|
185
|
+
* turning back for restoring, and the empty ring of a file that is not viewed.
|
|
186
|
+
* @param props.mark - which mark to draw.
|
|
187
|
+
* @returns the glyph, 16 pixels wide unless its control sizes it.
|
|
188
|
+
*/
|
|
189
|
+
export function FileMarkGlyph({ mark }: { readonly mark: FileMark }): ReactNode {
|
|
190
|
+
return (
|
|
191
|
+
<svg width={16} height={16} viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth={1} aria-hidden="true" data-forge-file-mark={mark}>
|
|
192
|
+
{FILE_MARKS[mark]}
|
|
193
|
+
</svg>
|
|
194
|
+
)
|
|
195
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { useCallback, useEffect, useRef, useState, type RefObject } from 'react'
|
|
9
|
-
import type { CodeHighlighter, HighlightSpan } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
9
|
+
import type { CodeHighlighter, HighlightSpan } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
10
10
|
import type { ForgeDiffHunk } from '../types.ts'
|
|
11
11
|
import type { DiffRow } from './diff-rows.ts'
|
|
12
12
|
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|