@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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** Chip title of a changes tab: the changes icon and the view's name in the current language. */
|
|
2
2
|
|
|
3
3
|
import type { ReactNode } from 'react'
|
|
4
|
-
import { IconFilesDiffOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
5
|
-
import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
|
4
|
+
import { IconFilesDiffOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
5
|
+
import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
6
6
|
import type {} from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
|
|
7
7
|
import { changesTitle, parseChangesAddress } from './changes-address.ts'
|
|
8
8
|
import type { NS } from './locales.ts'
|
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
* accepted only when each of its commits has the one listed before it as its first parent.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
|
7
|
+
import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'
|
|
8
8
|
import clsx from 'clsx'
|
|
9
9
|
import {
|
|
10
10
|
Button, IconCheckOutlineRegular, IconChevronDownOutlineRegular, Menu, MenuItemButton, StateDot, Tooltip,
|
|
11
|
-
} from '@deepseek-ai/dsh-client-ui-primitives'
|
|
12
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
13
|
-
import type { ForgeCommitList } from '@deepseek-ai/dsh-experimental-forge/types'
|
|
11
|
+
} from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
12
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
13
|
+
import type { ForgeCommit, ForgeCommitList } from '@deepseek-ai/dsh-experimental-forge/types'
|
|
14
14
|
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
|
|
15
15
|
import { rangeStart } from '../commit-range.ts'
|
|
16
|
-
import type { ForgeCommitRange, ForgeLocalCommits } from '../types.ts'
|
|
16
|
+
import type { ForgeChangeCommits, ForgeCommitRange, ForgeLocalCommits } from '../types.ts'
|
|
17
17
|
import { formatAgo } from './format.ts'
|
|
18
18
|
import type { NS } from './locales.ts'
|
|
19
19
|
import css from './CommitMenu.module.css'
|
|
@@ -23,8 +23,8 @@ const SHORT = 7
|
|
|
23
23
|
|
|
24
24
|
/** Props of the commit picker. */
|
|
25
25
|
export interface CommitMenuProps extends PropsLocale<typeof NS> {
|
|
26
|
-
/** Commits shown, or null for all of them. */
|
|
27
|
-
readonly chosen:
|
|
26
|
+
/** Commits shown, or null for all of them. The owner of a change request view may show its changes up to one commit. */
|
|
27
|
+
readonly chosen: ForgeChangeCommits | null
|
|
28
28
|
/** Whether the owning tab is visible; a hidden tab keeps the menu closed. */
|
|
29
29
|
readonly visible: boolean
|
|
30
30
|
/** Read the commits; null means the source cannot show single commits. `signal` aborts the read. */
|
|
@@ -43,17 +43,49 @@ export interface CommitMenuProps extends PropsLocale<typeof NS> {
|
|
|
43
43
|
* @param t - forge panel copy.
|
|
44
44
|
* @returns the label.
|
|
45
45
|
*/
|
|
46
|
-
export function commitsLabel(chosen:
|
|
46
|
+
export function commitsLabel(chosen: ForgeChangeCommits | null, t: PropsLocale<typeof NS>['t']): string {
|
|
47
47
|
if (chosen === null) return t('commits.all')
|
|
48
|
+
// Changes up to a commit read as that commit, as one commit shown alone does.
|
|
49
|
+
if ('upTo' in chosen) return chosen.upTo.slice(0, SHORT)
|
|
48
50
|
if (chosen.from === chosen.to) return chosen.from.slice(0, SHORT)
|
|
49
51
|
return t('commits.range', { from: chosen.from.slice(0, SHORT), to: chosen.to.slice(0, SHORT) })
|
|
50
52
|
}
|
|
51
53
|
|
|
54
|
+
/** Name the shown commits in the trigger's attribute: empty for all of them, `..sha` up to a commit, else `from..to`. */
|
|
55
|
+
function commitsAttribute(chosen: ForgeChangeCommits | null): string {
|
|
56
|
+
if (chosen === null) return ''
|
|
57
|
+
return 'upTo' in chosen ? `..${chosen.upTo}` : `${chosen.from}..${chosen.to}`
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** One commit row of the picker: its short object name, its title, when it was authored, and the mark of the shown run. */
|
|
61
|
+
function CommitRow({ commit, selected, ago, onPick }: {
|
|
62
|
+
readonly commit: ForgeCommit
|
|
63
|
+
readonly selected: boolean
|
|
64
|
+
readonly ago: string
|
|
65
|
+
readonly onPick: (sha: string) => void
|
|
66
|
+
}) {
|
|
67
|
+
const sha = commit.sha
|
|
68
|
+
const pick = useCallback((): void => { onPick(sha) }, [onPick, sha])
|
|
69
|
+
return (
|
|
70
|
+
<MenuItemButton current={selected} onSelect={pick}>
|
|
71
|
+
<span className={css.option} data-forge-commit={sha}>
|
|
72
|
+
<span className={css.sha}>{sha.slice(0, SHORT)}</span>
|
|
73
|
+
<span className={css.title}>{commit.title}</span>
|
|
74
|
+
<span className={css.meta}>{ago}</span>
|
|
75
|
+
<span className={clsx(css.check, !selected && css.unchecked)}><IconCheckOutlineRegular size={14} /></span>
|
|
76
|
+
</span>
|
|
77
|
+
</MenuItemButton>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
52
81
|
/**
|
|
53
|
-
* Render the trigger and, while open, the commit list. A click shows one commit; a Shift click shows the commits
|
|
54
|
-
* from the
|
|
82
|
+
* Render the trigger and, while open, the commit list. A click shows one commit; a Shift click shows the commits up to
|
|
83
|
+
* the clicked one, from the one commit shown, wherever it was chosen, or else from the last commit clicked without Shift.
|
|
84
|
+
* Changes up to a commit, which only the view's owner chooses, have a row of their own above the list, since the list
|
|
85
|
+
* may no longer hold that commit.
|
|
55
86
|
* @param props - the shown commits, the listing read, the choose action, and copy.
|
|
56
|
-
* @returns the trigger with its portalled menu, or nothing when the source cannot show single commits
|
|
87
|
+
* @returns the trigger with its portalled menu, or nothing when the source cannot show single commits and shows all of
|
|
88
|
+
* them.
|
|
57
89
|
*/
|
|
58
90
|
export function CommitMenu({ chosen, visible, list, kept, version, choose, t }: CommitMenuProps): ReactNode {
|
|
59
91
|
const [open, setOpen] = useState(false)
|
|
@@ -64,7 +96,9 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
|
|
|
64
96
|
readonly result: RemoteResult<ForgeCommitList | ForgeLocalCommits | null>
|
|
65
97
|
} | null>(null)
|
|
66
98
|
const shift = useRef(false)
|
|
67
|
-
const
|
|
99
|
+
const range = chosen !== null && 'from' in chosen ? chosen : null
|
|
100
|
+
const upTo = chosen !== null && 'upTo' in chosen ? chosen.upTo : null
|
|
101
|
+
const anchor = useRef<string | null>(range?.from ?? null)
|
|
68
102
|
const loaded = useRef<string | null>(null)
|
|
69
103
|
const shown = visible && open
|
|
70
104
|
const key = `${version}\n${String(attempt)}`
|
|
@@ -80,13 +114,12 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
|
|
|
80
114
|
})
|
|
81
115
|
return () => { controller.abort() }
|
|
82
116
|
}, [visible, key, list])
|
|
83
|
-
if (current?.ok === true && current.value === null) return null
|
|
84
117
|
const commits = current?.ok === true && current.value !== null ? current.value : null
|
|
85
|
-
const close = (): void => {
|
|
118
|
+
const close = useCallback((): void => {
|
|
86
119
|
setOpen(false)
|
|
87
120
|
setRejected(false)
|
|
88
|
-
}
|
|
89
|
-
const pick = (sha: string | null): void => {
|
|
121
|
+
}, [])
|
|
122
|
+
const pick = useCallback((sha: string | null): void => {
|
|
90
123
|
if (sha === null || commits === null) {
|
|
91
124
|
close()
|
|
92
125
|
anchor.current = null
|
|
@@ -94,7 +127,9 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
|
|
|
94
127
|
return
|
|
95
128
|
}
|
|
96
129
|
const order = commits.commits.map(commit => commit.sha)
|
|
97
|
-
|
|
130
|
+
// One commit shown alone starts the run, also when the view's owner chose it and not a click here.
|
|
131
|
+
const held = range !== null && range.from === range.to ? range.from : anchor.current
|
|
132
|
+
const start = shift.current && held !== null && order.includes(held) ? held : sha
|
|
98
133
|
const [from, to] = order.indexOf(start) <= order.indexOf(sha) ? [start, sha] : [sha, start]
|
|
99
134
|
// Two ends cannot name a run that leaves the first-parent line, so the menu stays open and says why.
|
|
100
135
|
if (rangeStart(commits.commits, { from, to }) === 'not-linear') {
|
|
@@ -103,51 +138,56 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
|
|
|
103
138
|
}
|
|
104
139
|
close()
|
|
105
140
|
if (!shift.current || start === sha) anchor.current = sha
|
|
106
|
-
if (from !==
|
|
107
|
-
}
|
|
141
|
+
if (from !== range?.from || to !== range.to) choose({ from, to })
|
|
142
|
+
}, [choose, chosen, close, commits, range])
|
|
143
|
+
const chooseAll = useCallback((): void => { pick(null) }, [pick])
|
|
144
|
+
const retryListing = useCallback((): void => { setAttempt(count => count + 1) }, [])
|
|
145
|
+
// Changes up to a commit keep the picker, which is the way back to all commits.
|
|
146
|
+
if (current?.ok === true && current.value === null && upTo === null) return null
|
|
108
147
|
const inChosen = (index: number): boolean => {
|
|
109
|
-
if (
|
|
148
|
+
if (range === null || commits === null) return false
|
|
110
149
|
const order = commits.commits.map(commit => commit.sha)
|
|
111
|
-
return index >= order.indexOf(
|
|
150
|
+
return index >= order.indexOf(range.from) && index <= order.indexOf(range.to) && order.includes(range.from)
|
|
112
151
|
}
|
|
113
152
|
|
|
114
153
|
let body: ReactNode
|
|
115
154
|
if (current === null) {
|
|
116
155
|
body = <div className={css.status} role="status"><StateDot state="ongoing" />{t('commits.loading')}</div>
|
|
117
|
-
} else if (!current.ok
|
|
156
|
+
} else if (!current.ok) {
|
|
118
157
|
body = (
|
|
119
158
|
<div className={css.status} role="status">
|
|
120
159
|
<span>{t('commits.failed')}</span>
|
|
121
|
-
<Button size="sm" variant="outline" onClick={
|
|
160
|
+
<Button size="sm" variant="outline" onClick={retryListing}>{t('retry')}</Button>
|
|
122
161
|
</div>
|
|
123
162
|
)
|
|
124
163
|
} else {
|
|
125
164
|
const now = Date.now()
|
|
165
|
+
const rows = commits?.commits ?? []
|
|
126
166
|
body = <>
|
|
127
|
-
<MenuItemButton current={chosen === null} onSelect={
|
|
167
|
+
<MenuItemButton current={chosen === null} onSelect={chooseAll}>
|
|
128
168
|
<span className={css.option}>
|
|
129
169
|
<span className={css.allTitle}>{t('commits.all')}</span>
|
|
130
|
-
<span className={css.meta}>{t('commits.count', { count: commits.commits.length })}</span>
|
|
170
|
+
{commits !== null && <span className={css.meta}>{t('commits.count', { count: commits.commits.length })}</span>}
|
|
131
171
|
{chosen === null && <IconCheckOutlineRegular size={14} className={css.check} />}
|
|
132
172
|
</span>
|
|
133
173
|
</MenuItemButton>
|
|
134
|
-
{
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
<span className={css.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
{commits
|
|
174
|
+
{upTo !== null && (
|
|
175
|
+
<MenuItemButton current onSelect={close}>
|
|
176
|
+
<span className={css.option} data-forge-commit-up-to={upTo}>
|
|
177
|
+
<span className={css.sha}>{upTo.slice(0, SHORT)}</span>
|
|
178
|
+
<span className={css.title}>{t('commits.threadCommit')}</span>
|
|
179
|
+
<span className={css.check}><IconCheckOutlineRegular size={14} /></span>
|
|
180
|
+
</span>
|
|
181
|
+
</MenuItemButton>
|
|
182
|
+
)}
|
|
183
|
+
{rows.length > 0 && <div className={css.label} role="presentation">{t('commits.shiftHint')}</div>}
|
|
184
|
+
{rows.map((commit, index) => (
|
|
185
|
+
<CommitRow key={commit.sha} commit={commit} selected={inChosen(index)}
|
|
186
|
+
ago={formatAgo(commit.authoredAt, now, t) ?? ''} onPick={pick} />
|
|
187
|
+
))}
|
|
188
|
+
{commits?.truncated === true && (
|
|
149
189
|
<div className={css.note}>
|
|
150
|
-
{t(kept === 'oldest' ? 'commits.truncatedOldest' : 'commits.truncatedNewest', { count:
|
|
190
|
+
{t(kept === 'oldest' ? 'commits.truncatedOldest' : 'commits.truncatedNewest', { count: rows.length })}
|
|
151
191
|
</div>
|
|
152
192
|
)}
|
|
153
193
|
</>
|
|
@@ -166,7 +206,8 @@ export function CommitMenu({ chosen, visible, list, kept, version, choose, t }:
|
|
|
166
206
|
anchor={(
|
|
167
207
|
<Tooltip label={t('commits.aria', { commits: label })} side="bottom" portal delayMs={500}>
|
|
168
208
|
<button type="button" className={clsx(css.trigger, chosen !== null && css.chosen)} aria-haspopup="menu" aria-expanded={shown}
|
|
169
|
-
aria-label={t('commits.aria', { commits: label })}
|
|
209
|
+
aria-label={t('commits.aria', { commits: label })}
|
|
210
|
+
data-forge-commits={commitsAttribute(chosen)}
|
|
170
211
|
onClick={() => { setOpen(value => !value); setRejected(false) }}>
|
|
171
212
|
<span className={css.triggerName}>{label}</span>
|
|
172
213
|
<IconChevronDownOutlineRegular size={12} />
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** The button the forge surfaces use to copy a host's sign-in command. */
|
|
2
|
+
|
|
3
|
+
import { useCallback } from 'react'
|
|
4
|
+
import { Button } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
5
|
+
import type { ButtonVariant } from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Copy one host command through the caller's clipboard channel.
|
|
9
|
+
* @param props.command - the command text to copy.
|
|
10
|
+
* @param props.copyText - the surface's clipboard writer.
|
|
11
|
+
* @param props.label - the button text.
|
|
12
|
+
* @param props.ariaLabel - accessible name when the button text alone is not the action's name.
|
|
13
|
+
* @param props.variant - visual family; outlined unless the surface places it in a command row.
|
|
14
|
+
* @returns the copy button.
|
|
15
|
+
*/
|
|
16
|
+
export function CopyCommandButton({ command, copyText, label, ariaLabel, variant = 'outline' }: {
|
|
17
|
+
readonly command: string
|
|
18
|
+
readonly copyText: (text: string) => void
|
|
19
|
+
readonly label: string
|
|
20
|
+
readonly ariaLabel?: string | undefined
|
|
21
|
+
readonly variant?: ButtonVariant | undefined
|
|
22
|
+
}) {
|
|
23
|
+
const copy = useCallback((): void => { copyText(command) }, [command, copyText])
|
|
24
|
+
return <Button size="sm" variant={variant} aria-label={ariaLabel} onClick={copy}>{label}</Button>
|
|
25
|
+
}
|
package/src/client/DiffFile.tsx
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* One file of the changes view: a sticky header with the path, badges, line
|
|
3
|
-
* counts, and file actions, then its hunks unified or side by side with the
|
|
3
|
+
* counts, the writes of a local scope, the viewed mark, and file actions, then its hunks unified or side by side with the
|
|
4
4
|
* unchanged lines between them collapsed into rows that expand them. A section
|
|
5
5
|
* draws and highlights its lines once it comes within reach of the scrollport;
|
|
6
6
|
* it redraws only when its own props change.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { memo, useCallback, useEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react'
|
|
9
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState, type CSSProperties, type Dispatch, type ReactNode, type SetStateAction } from 'react'
|
|
10
10
|
import clsx from 'clsx'
|
|
11
11
|
import { flushSync } from 'react-dom'
|
|
12
12
|
import {
|
|
13
|
-
FileTypeIcon, IconChevronDownOutlineRegular, IconChevronsUpDownOutlineRegular, IconChevronUpOutlineRegular,
|
|
14
|
-
IconPlusOutlineRegular,
|
|
13
|
+
FileTypeIcon, IconCheckCircleOutlineRegular, IconChevronDownOutlineRegular, IconChevronsUpDownOutlineRegular, IconChevronUpOutlineRegular,
|
|
14
|
+
IconEllipsisOutlineRegular, IconPlusOutlineRegular,
|
|
15
15
|
Tag, Tooltip,
|
|
16
16
|
languageForPath, Menu, MenuItemButton, useCodeHighlighter, type CodeHighlighter, type HighlightSpan,
|
|
17
|
-
} from '@deepseek-ai/dsh-client-ui-primitives'
|
|
18
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
17
|
+
} from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
18
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
19
|
+
import { restorable } from '../restore.ts'
|
|
19
20
|
import type { ForgeDiffFile } from '../types.ts'
|
|
20
21
|
import {
|
|
21
22
|
drawnLines, EXPAND_STEP, hidesLine, segmentsOf, splitRows,
|
|
@@ -29,6 +30,8 @@ import type { FileReviewState } from './review-queue.ts'
|
|
|
29
30
|
import { ReviewComposer, type ReviewActions } from './ReviewComposer.tsx'
|
|
30
31
|
import reviewCss from './ReviewComposer.module.css'
|
|
31
32
|
import { FileLabel } from './FileLabel.tsx'
|
|
33
|
+
import { FileMarkGlyph } from './glyphs.tsx'
|
|
34
|
+
import type { LocalWriteKind } from './local-writes.ts'
|
|
32
35
|
import type { ForgePanelKey, NS } from './locales.ts'
|
|
33
36
|
import type { ViewedState } from './viewed-files.ts'
|
|
34
37
|
import type { SectionReach } from './section-reach.ts'
|
|
@@ -44,6 +47,10 @@ export interface DiffFileAction {
|
|
|
44
47
|
readonly label: ForgePanelKey
|
|
45
48
|
/** Runs the action. */
|
|
46
49
|
readonly run: () => void
|
|
50
|
+
/** Whether the row starts a new group of the menu. */
|
|
51
|
+
readonly separated?: boolean | undefined
|
|
52
|
+
/** Whether the row cannot be activated now. */
|
|
53
|
+
readonly disabled?: boolean | undefined
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
/** New side of a file: its lines once read, `loading` while a read runs, or undefined before any. */
|
|
@@ -64,6 +71,8 @@ export interface DiffFileHandlers {
|
|
|
64
71
|
readonly readContext: (file: ForgeDiffFile) => void
|
|
65
72
|
/** Mark a file viewed, which also collapses it, or clear the mark. */
|
|
66
73
|
readonly view: (file: ForgeDiffFile, viewed: boolean) => void
|
|
74
|
+
/** Stage or unstage the file, or ask to restore it. */
|
|
75
|
+
readonly write: (file: ForgeDiffFile, kind: LocalWriteKind) => void
|
|
67
76
|
/** Rows of a file's menu, read whenever the menu draws. */
|
|
68
77
|
readonly actions: (file: ForgeDiffFile) => readonly DiffFileAction[]
|
|
69
78
|
/** Receive a file's section element, which scrolling to the file targets, or null once it unmounts. */
|
|
@@ -104,6 +113,8 @@ export interface DiffFileProps {
|
|
|
104
113
|
readonly wrap: boolean
|
|
105
114
|
/** Badge text after the path, or empty for none. */
|
|
106
115
|
readonly badge: string
|
|
116
|
+
/** The letter a narrow view draws in place of the badge text, or empty without a badge. */
|
|
117
|
+
readonly badgeLetter: string
|
|
107
118
|
/** Hover text of the path: both paths of a renamed file, else the path. */
|
|
108
119
|
readonly tooltip: string
|
|
109
120
|
/** Whether the reader marked this change viewed, or marked an earlier change of the file. */
|
|
@@ -112,6 +123,13 @@ export interface DiffFileProps {
|
|
|
112
123
|
readonly viewedNote: string
|
|
113
124
|
/** Whether the mark cannot change now, while its write is in flight or the host's marks could not be read. */
|
|
114
125
|
readonly viewedDisabled: boolean
|
|
126
|
+
/**
|
|
127
|
+
* The local scope whose writes the header offers: staging and restoring for `unstaged`, unstaging for `staged`;
|
|
128
|
+
* undefined offers none.
|
|
129
|
+
*/
|
|
130
|
+
readonly writes?: 'unstaged' | 'staged' | undefined
|
|
131
|
+
/** Whether the header's writes wait for a write in flight or a reread of the scope. */
|
|
132
|
+
readonly writing?: boolean | undefined
|
|
115
133
|
/** Review threads of the file from the code host, or undefined while none are read; the view keeps their identity. */
|
|
116
134
|
readonly threads?: FileThreads | undefined
|
|
117
135
|
/** Whether the section draws its lines at once, as the target of a thread jump, whose card must exist to be centered. */
|
|
@@ -128,20 +146,45 @@ export interface DiffFileProps {
|
|
|
128
146
|
readonly t: Translate
|
|
129
147
|
}
|
|
130
148
|
|
|
149
|
+
/** The line counts {@link Counts} draws for one file. */
|
|
150
|
+
type CountedFile = Pick<ForgeDiffFile, 'additions' | 'deletions' | 'binary'>
|
|
151
|
+
|
|
152
|
+
const addedCount = (file: CountedFile): string => `+${file.additions.toLocaleString('en-US')}`
|
|
153
|
+
const deletedCount = (file: CountedFile): string => `−${file.deletions.toLocaleString('en-US')}`
|
|
154
|
+
|
|
155
|
+
/** The width {@link Counts} reads from the nearest ancestor that sets it, in `ch` of the counts' monospace font. */
|
|
156
|
+
export type CountsColumn = CSSProperties & { '--forge-deleted-width': string }
|
|
157
|
+
|
|
131
158
|
/**
|
|
132
|
-
*
|
|
159
|
+
* Size the deleted count of a list of files to the list's widest `−N`. The counts end at a row's trailing edge, so
|
|
160
|
+
* with one width for the deleted count every row under the element that takes the style also ends its added count on
|
|
161
|
+
* one edge.
|
|
162
|
+
* @param files - every file the list can show.
|
|
163
|
+
* @returns the style for the list's container.
|
|
164
|
+
*/
|
|
165
|
+
export function countsColumn(files: readonly CountedFile[]): CountsColumn {
|
|
166
|
+
let deleted = 0
|
|
167
|
+
for (const file of files) {
|
|
168
|
+
if (!file.binary) deleted = Math.max(deleted, deletedCount(file).length)
|
|
169
|
+
}
|
|
170
|
+
return { '--forge-deleted-width': `${deleted}ch` }
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Render added and deleted line counts, or the binary label for binary content. Under a container styled with
|
|
175
|
+
* {@link countsColumn}, the deleted count fills that width from the trailing edge.
|
|
133
176
|
* @param props - the counts and copy.
|
|
134
177
|
* @returns the counts.
|
|
135
178
|
*/
|
|
136
179
|
export function Counts({ file, t }: {
|
|
137
|
-
readonly file:
|
|
180
|
+
readonly file: CountedFile
|
|
138
181
|
readonly t: Translate
|
|
139
182
|
}): ReactNode {
|
|
140
183
|
if (file.binary) return <span>{t('diff.binaryLabel')}</span>
|
|
141
184
|
return (
|
|
142
185
|
<span className={css.counts}>
|
|
143
|
-
<span className={css.added}>{
|
|
144
|
-
<span className={css.deleted}>{
|
|
186
|
+
<span className={css.added}>{addedCount(file)}</span>
|
|
187
|
+
<span className={css.deleted}>{deletedCount(file)}</span>
|
|
145
188
|
</span>
|
|
146
189
|
)
|
|
147
190
|
}
|
|
@@ -266,6 +309,21 @@ function pairKind(pair: SplitRow): 'context' | 'change' {
|
|
|
266
309
|
return pair.left !== null && pair.left.kind === 'context' ? 'context' : 'change'
|
|
267
310
|
}
|
|
268
311
|
|
|
312
|
+
/** An open comment editor for one range, which closes itself out of the ranges being written. */
|
|
313
|
+
function RangeEditor({ item, actions, visible, setEditors, t }: {
|
|
314
|
+
readonly item: ReviewSelection
|
|
315
|
+
readonly actions: ReviewActions
|
|
316
|
+
readonly visible: boolean
|
|
317
|
+
readonly setEditors: Dispatch<SetStateAction<readonly ReviewSelection[]>>
|
|
318
|
+
readonly t: Translate
|
|
319
|
+
}) {
|
|
320
|
+
const comment = item.comment
|
|
321
|
+
const close = useCallback((): void => {
|
|
322
|
+
setEditors(list => list.filter(open => !sameRange(open.comment, comment)))
|
|
323
|
+
}, [comment, setEditors])
|
|
324
|
+
return <ReviewComposer selection={item} visible={visible} actions={actions} close={close} t={t} />
|
|
325
|
+
}
|
|
326
|
+
|
|
269
327
|
/** The hunks of one file with their collapsed and expanded unchanged lines. */
|
|
270
328
|
function Lines({ file, text, open, handlers, split, wrap, review, visible, comments, threads, folded, annotations, t }: Pick<DiffFileProps,
|
|
271
329
|
'file' | 'text' | 'open' | 'handlers' | 'split' | 'wrap' | 'review' | 'visible' | 'threads' | 'folded' | 't'> & LinesNotes): ReactNode {
|
|
@@ -329,7 +387,7 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
|
|
|
329
387
|
if (nativeSide === null) return
|
|
330
388
|
const copy = (event: ClipboardEvent): void => {
|
|
331
389
|
if (root.current === null || event.clipboardData === null
|
|
332
|
-
|| (event.target
|
|
390
|
+
|| (event.target as Partial<Element>).closest?.('input, textarea, [contenteditable="true"]') != null) return
|
|
333
391
|
const selected = readCodeSelection(root.current, nativeSide)
|
|
334
392
|
if (selected === undefined) return
|
|
335
393
|
event.preventDefault()
|
|
@@ -520,8 +578,7 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
|
|
|
520
578
|
return nodes
|
|
521
579
|
}
|
|
522
580
|
const editorOf = (item: ReviewSelection, actions: ReviewActions): ReactNode =>
|
|
523
|
-
<
|
|
524
|
-
close={() => { setEditors(list => list.filter(open => !sameRange(open.comment, item.comment))) }} t={t} />
|
|
581
|
+
<RangeEditor key={`comment-${rangeKey(item)}`} item={item} actions={actions} visible={visible} setEditors={setEditors} t={t} />
|
|
525
582
|
// Side by side, a row's comments sit in a row of two cells under its columns, each continuing its line's background.
|
|
526
583
|
const notes = (key: string, pair: SplitRow): void => {
|
|
527
584
|
const left = commentsAt('L', pair.left?.no ?? null)
|
|
@@ -630,8 +687,8 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
|
|
|
630
687
|
data-review={review === undefined ? undefined : ''}
|
|
631
688
|
data-native-side={nativeSide ?? undefined}
|
|
632
689
|
onPointerDownCapture={(event) => {
|
|
633
|
-
if (event.button !== 0
|
|
634
|
-
const side = codeSideAt(event.currentTarget, event.target)
|
|
690
|
+
if (event.button !== 0) return
|
|
691
|
+
const side = codeSideAt(event.currentTarget, event.target as Node)
|
|
635
692
|
if (side === undefined) return
|
|
636
693
|
if (!event.shiftKey || nativeSide !== side) window.getSelection()?.removeAllRanges()
|
|
637
694
|
dragging.current = 'text'
|
|
@@ -696,6 +753,27 @@ function Body(props: DiffFileProps): ReactNode {
|
|
|
696
753
|
</>
|
|
697
754
|
}
|
|
698
755
|
|
|
756
|
+
/** One row of a file's menu: it closes the menu, then runs the action. */
|
|
757
|
+
function FileMenuAction({ action, close, t }: {
|
|
758
|
+
readonly action: DiffFileAction
|
|
759
|
+
readonly close: () => void
|
|
760
|
+
readonly t: Translate
|
|
761
|
+
}) {
|
|
762
|
+
const run = useCallback((): void => {
|
|
763
|
+
close()
|
|
764
|
+
action.run()
|
|
765
|
+
}, [action, close])
|
|
766
|
+
return (
|
|
767
|
+
<MenuItemButton
|
|
768
|
+
separatorBefore={action.separated === true}
|
|
769
|
+
disabled={action.disabled === true}
|
|
770
|
+
onSelect={run}
|
|
771
|
+
>
|
|
772
|
+
{t(action.label)}
|
|
773
|
+
</MenuItemButton>
|
|
774
|
+
)
|
|
775
|
+
}
|
|
776
|
+
|
|
699
777
|
/** File actions live only while their owning tab is visible. */
|
|
700
778
|
function FileMenu({ name, file, handlers, t }: {
|
|
701
779
|
readonly name: string
|
|
@@ -704,6 +782,7 @@ function FileMenu({ name, file, handlers, t }: {
|
|
|
704
782
|
readonly t: Translate
|
|
705
783
|
}): ReactNode {
|
|
706
784
|
const [menuOpen, setMenuOpen] = useState(false)
|
|
785
|
+
const close = useCallback((): void => { setMenuOpen(false) }, [])
|
|
707
786
|
return (
|
|
708
787
|
<Menu
|
|
709
788
|
open={menuOpen}
|
|
@@ -711,7 +790,7 @@ function FileMenu({ name, file, handlers, t }: {
|
|
|
711
790
|
align="end"
|
|
712
791
|
dense
|
|
713
792
|
autoFocus
|
|
714
|
-
onClose={
|
|
793
|
+
onClose={close}
|
|
715
794
|
anchor={(
|
|
716
795
|
<button
|
|
717
796
|
type="button"
|
|
@@ -726,21 +805,38 @@ function FileMenu({ name, file, handlers, t }: {
|
|
|
726
805
|
)}
|
|
727
806
|
>
|
|
728
807
|
{handlers.actions(file).map(action => (
|
|
729
|
-
<
|
|
730
|
-
key={action.label}
|
|
731
|
-
onSelect={() => {
|
|
732
|
-
setMenuOpen(false)
|
|
733
|
-
action.run()
|
|
734
|
-
}}
|
|
735
|
-
>
|
|
736
|
-
{t(action.label)}
|
|
737
|
-
</MenuItemButton>
|
|
808
|
+
<FileMenuAction key={action.label} action={action} close={close} t={t} />
|
|
738
809
|
))}
|
|
739
810
|
{menuOpen && <div className={css.menuPlugins}>{handlers.fileMenu(file, () => { setMenuOpen(false) })}</div>}
|
|
740
811
|
</Menu>
|
|
741
812
|
)
|
|
742
813
|
}
|
|
743
814
|
|
|
815
|
+
const WRITE_COPY: Record<LocalWriteKind, { readonly tip: ForgePanelKey; readonly name: ForgePanelKey }> = {
|
|
816
|
+
stage: { tip: 'diff.stageFile', name: 'diff.stageFileAria' },
|
|
817
|
+
unstage: { tip: 'diff.unstageFile', name: 'diff.unstageFileAria' },
|
|
818
|
+
restore: { tip: 'diff.restoreFile', name: 'diff.restoreFileAria' },
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/** One write of a file as an icon button, named by its tooltip. */
|
|
822
|
+
function WriteTool({ kind, name, file, disabled, handlers, t }: {
|
|
823
|
+
readonly kind: LocalWriteKind
|
|
824
|
+
readonly name: string
|
|
825
|
+
readonly file: ForgeDiffFile
|
|
826
|
+
readonly disabled: boolean
|
|
827
|
+
readonly handlers: DiffFileHandlers
|
|
828
|
+
readonly t: Translate
|
|
829
|
+
}): ReactNode {
|
|
830
|
+
return (
|
|
831
|
+
<Tooltip label={t(WRITE_COPY[kind].tip)} side="bottom" portal delayMs={500}>
|
|
832
|
+
<button type="button" className={css.tool} aria-label={t(WRITE_COPY[kind].name, { name })} disabled={disabled} data-forge-write={kind}
|
|
833
|
+
onClick={() => { handlers.write(file, kind) }}>
|
|
834
|
+
{kind === 'stage' ? <IconPlusOutlineRegular /> : <FileMarkGlyph mark={kind} />}
|
|
835
|
+
</button>
|
|
836
|
+
</Tooltip>
|
|
837
|
+
)
|
|
838
|
+
}
|
|
839
|
+
|
|
744
840
|
/**
|
|
745
841
|
* Render one file of a diff. Until the section first comes within reach of the scrollport or a thread jump targets it,
|
|
746
842
|
* an expanded file that draws lines shows a box of about their height instead.
|
|
@@ -748,7 +844,10 @@ function FileMenu({ name, file, handlers, t }: {
|
|
|
748
844
|
* @returns the file section.
|
|
749
845
|
*/
|
|
750
846
|
function DiffFileSection(props: DiffFileProps): ReactNode {
|
|
751
|
-
const {
|
|
847
|
+
const {
|
|
848
|
+
file, expanded, large, revealed, badge, badgeLetter, tooltip, viewed, viewedNote, viewedDisabled, writes, writing = false,
|
|
849
|
+
threads, handlers, t,
|
|
850
|
+
} = props
|
|
752
851
|
const name = file.path.slice(file.path.lastIndexOf('/') + 1)
|
|
753
852
|
const element = useRef<HTMLElement | null>(null)
|
|
754
853
|
const [reached, setReached] = useState(false)
|
|
@@ -768,7 +867,7 @@ function DiffFileSection(props: DiffFileProps): ReactNode {
|
|
|
768
867
|
return (
|
|
769
868
|
<section ref={sectionRef} className={css.file} data-forge-diff-file={file.path} data-expanded={expanded ? '' : undefined}
|
|
770
869
|
data-viewed={viewed}>
|
|
771
|
-
<div className={css.fileHeader}>
|
|
870
|
+
<div className={css.fileHeader} data-forge-file-writes={writes}>
|
|
772
871
|
<button
|
|
773
872
|
type="button"
|
|
774
873
|
className={css.fileToggle}
|
|
@@ -796,13 +895,32 @@ function DiffFileSection(props: DiffFileProps): ReactNode {
|
|
|
796
895
|
</Tooltip>
|
|
797
896
|
)}
|
|
798
897
|
<span className={css.fileSpacer} data-forge-path-spacer="" />
|
|
799
|
-
{badge !== '' &&
|
|
898
|
+
{badge !== '' && (
|
|
899
|
+
// The tooltip repeats the badge's words where they are cut: past half the title, or to their letter in a narrow view.
|
|
900
|
+
<Tooltip label={badge} side="bottom" portal delayMs={500} openOnClick onlyWhenClipped>
|
|
901
|
+
<span className={css.badge} data-forge-file-badge="">
|
|
902
|
+
<span className={css.badgeText}>{badge}</span>
|
|
903
|
+
<span className={css.badgeLetter} aria-hidden="true">{badgeLetter}</span>
|
|
904
|
+
</span>
|
|
905
|
+
</Tooltip>
|
|
906
|
+
)}
|
|
800
907
|
</span>
|
|
801
908
|
{!file.binary && <Counts file={file} t={t} />}
|
|
909
|
+
{writes !== undefined && (
|
|
910
|
+
<span className={css.fileActions} data-forge-file-actions="">
|
|
911
|
+
{writes === 'unstaged' && restorable(file) && (
|
|
912
|
+
<WriteTool kind="restore" name={name} file={file} disabled={writing} handlers={handlers} t={t} />
|
|
913
|
+
)}
|
|
914
|
+
<WriteTool kind={writes === 'unstaged' ? 'stage' : 'unstage'} name={name} file={file} disabled={writing} handlers={handlers} t={t} />
|
|
915
|
+
</span>
|
|
916
|
+
)}
|
|
802
917
|
<Tooltip label={viewedNote} side="bottom" align="end" portal delayMs={500}>
|
|
803
|
-
<label className={css.viewed} data-disabled={viewedDisabled ? '' : undefined}>
|
|
918
|
+
<label className={css.viewed} data-checked={viewed === 'viewed' ? '' : undefined} data-disabled={viewedDisabled ? '' : undefined}>
|
|
804
919
|
<input type="checkbox" checked={viewed === 'viewed'} aria-label={t('viewed.aria', { name })} disabled={viewedDisabled}
|
|
805
920
|
onChange={(event) => { handlers.view(file, event.target.checked) }} />
|
|
921
|
+
<span className={css.viewedMark} aria-hidden="true">
|
|
922
|
+
{viewed === 'viewed' ? <IconCheckCircleOutlineRegular /> : <FileMarkGlyph mark="unviewed" />}
|
|
923
|
+
</span>
|
|
806
924
|
<span className={css.viewedLabel} aria-hidden="true">{t('viewed.label')}</span>
|
|
807
925
|
</label>
|
|
808
926
|
</Tooltip>
|