@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
|
@@ -12,25 +12,31 @@
|
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
14
|
useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, type CSSProperties, type KeyboardEvent,
|
|
15
|
-
type ReactNode,
|
|
15
|
+
type ReactNode, type RefObject,
|
|
16
16
|
} from 'react'
|
|
17
17
|
import clsx from 'clsx'
|
|
18
18
|
import {
|
|
19
19
|
Button, IconBranchOutlineRegular, IconChevronDownOutlineRegular, IconChevronsUpDownOutlineRegular, IconCompareSplitOutlineRegular,
|
|
20
|
-
IconInfoOutlineRegular,
|
|
20
|
+
IconInfoOutlineRegular, IconNowrapFillRegular, IconWorkspaceTreeOutlineRegular,
|
|
21
21
|
IconWrapFillRegular,
|
|
22
|
-
Menu, Tooltip,
|
|
22
|
+
Menu, Modal, Tooltip,
|
|
23
23
|
type MenuEntry,
|
|
24
|
-
} from '@deepseek-ai/dsh-client-ui-primitives'
|
|
25
|
-
import type {
|
|
24
|
+
} from '@deepseek-ai/dsh-client-ui-primitives/client'
|
|
25
|
+
import type {
|
|
26
|
+
GlobalStandardProps, HostObservable, InjectFace, PropsLocale, PropsRenderSlots, PropsRuntime, PropsStore,
|
|
27
|
+
} from '@deepseek-ai/dsh-client-ui-slots/client'
|
|
28
|
+
// Type-only: the `useMediaQuery` standard prop merge.
|
|
29
|
+
import type {} from '@deepseek-ai/dsh-client-ui-responsive/client'
|
|
26
30
|
import type { SidebarRightTabInfo } from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
|
|
27
31
|
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
|
|
28
32
|
import { assertNever } from '@deepseek-ai/dsh-util-values'
|
|
29
33
|
import { fileAddressFor, pathPartsOf } from '@deepseek-ai/dsh-util-workspace-path'
|
|
30
34
|
import type {
|
|
31
|
-
ForgeBaseBranch, ForgeBaseBranches, ForgeChangeRequestDiff, ForgeCommitRange, ForgeDiffFile, ForgeExtensionState,
|
|
32
|
-
ForgeLensKeep, ForgeLensRequest, ForgeLocalCommits, ForgeLocalDiff, ForgeLocalScope,
|
|
35
|
+
ForgeBaseBranch, ForgeBaseBranches, ForgeChangeCommits, ForgeChangeRequestDiff, ForgeCommitRange, ForgeDiffFile, ForgeExtensionState,
|
|
36
|
+
ForgeLensFrame, ForgeLensKeep, ForgeLensRequest, ForgeLocalCommits, ForgeLocalDiff, ForgeLocalScope, ForgeLocalWrite,
|
|
37
|
+
ForgeLocalWriteResult,
|
|
33
38
|
} from '../types.ts'
|
|
39
|
+
import { restorable } from '../restore.ts'
|
|
34
40
|
import { lensVersion } from '../lens-version.ts'
|
|
35
41
|
import type {
|
|
36
42
|
ForgeCommitList, ForgeReviewData, ForgeReviewRequest, ForgeReviewResult, ForgeReviewThread, ForgeReviewWrite, ForgeReviewWriteResult,
|
|
@@ -40,22 +46,25 @@ import { sameReviewSource, type RemovedRecord, type ReviewQueue } from './review
|
|
|
40
46
|
import { ReviewThread, useFileReview } from './ReviewThread.tsx'
|
|
41
47
|
import type { ReviewActions } from './ReviewComposer.tsx'
|
|
42
48
|
import { SubmitReview } from './SubmitReview.tsx'
|
|
43
|
-
import type { QuoteCopy, ReviewSelection, ReviewSource } from './review.ts'
|
|
49
|
+
import type { QuoteCopy, ReviewHead, ReviewSelection, ReviewSource } from './review.ts'
|
|
44
50
|
import { BaseMenu } from './BaseMenu.tsx'
|
|
51
|
+
import { HeadMenu } from './HeadMenu.tsx'
|
|
45
52
|
import { parseChangesAddress, type ChangesSource, type ChangesTarget } from './changes-address.ts'
|
|
46
|
-
import type { ChangesLens, createChangesStore } from './changes-store.ts'
|
|
53
|
+
import type { ChangesHead, ChangesLens, createChangesStore } from './changes-store.ts'
|
|
54
|
+
import { ChangeStatus, type BoundStatusActions, type ChangeStatusFacts } from './ChangeStatus.tsx'
|
|
47
55
|
import { CommitMenu } from './CommitMenu.tsx'
|
|
48
56
|
import { HideTestsSwitch, LensControl, LensMenu, LENSES, ViewedProgress } from './ReviewControls.tsx'
|
|
49
57
|
import { viewedStateOf, type ViewedFiles, type ViewedMarks } from './viewed-files.ts'
|
|
50
58
|
import { hostViewedOf, useHostViewed, type HostViewed } from './host-viewed.ts'
|
|
51
|
-
import { Counts, DiffFile, type DiffFileAction, type DiffFileHandlers } from './DiffFile.tsx'
|
|
59
|
+
import { Counts, countsColumn, DiffFile, type DiffFileAction, type DiffFileHandlers } from './DiffFile.tsx'
|
|
52
60
|
import { SectionReach } from './section-reach.ts'
|
|
53
61
|
import { FileTreePane, type FileTreePosition } from './FileTreePane.tsx'
|
|
54
62
|
import { changedFileTree, filesInTreeOrder } from './file-tree.ts'
|
|
55
63
|
import { ChangedFilesMenu, type ChangedFilesProps, type ChangedFilesState } from './ChangedFiles.tsx'
|
|
56
64
|
import { ChangesLoading } from './ChangesLoading.tsx'
|
|
57
65
|
import { drawnLines, matchesHunks, revealGap, textLines, type GapExpansion, type GapReveal } from './diff-rows.ts'
|
|
58
|
-
import { ChangeRequestGlyph } from './glyphs.tsx'
|
|
66
|
+
import { ChangeRequestGlyph, ForgeGlyph } from './glyphs.tsx'
|
|
67
|
+
import { useLocalWrites } from './local-writes.ts'
|
|
59
68
|
import type { ForgePanelKey, NS } from './locales.ts'
|
|
60
69
|
import { useForgeCopy } from './forge-copy.ts'
|
|
61
70
|
import { RefreshGlyph } from './RefreshGlyph.tsx'
|
|
@@ -65,7 +74,7 @@ import type { SourcedAnnotation, ViewAnnotations } from './annotations.ts'
|
|
|
65
74
|
import { foldedHunks, useLensRun } from './lens-filter.ts'
|
|
66
75
|
import { LensFilterMenu, type LensChoice } from './LensFilter.tsx'
|
|
67
76
|
import type {} from './slots.ts'
|
|
68
|
-
import { observeToolbarFold } from './toolbar-fold.ts'
|
|
77
|
+
import { observeHeaderFold, observeToolbarFold } from './toolbar-fold.ts'
|
|
69
78
|
import type { FileThreads, ThreadActions, ThreadFocus, ThreadWrite } from './ReviewThreads.tsx'
|
|
70
79
|
import { inFileOrder, type ThreadFilter } from './review-threads.ts'
|
|
71
80
|
import { usePlacedThreads, useThreadRead, type PlacedThread } from './thread-state.ts'
|
|
@@ -79,10 +88,13 @@ type Translate = PropsLocale<typeof NS>['t']
|
|
|
79
88
|
/** Kind of a local scope. */
|
|
80
89
|
type ScopeKind = ForgeLocalScope['kind']
|
|
81
90
|
|
|
82
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* A file the view scrolls to once, and the thread card it centers there with whether that card takes the focus. The
|
|
93
|
+
* thread's web page opens instead when the changes read by then lack the file; null without a page.
|
|
94
|
+
*/
|
|
83
95
|
interface Wanted {
|
|
84
96
|
readonly path: string
|
|
85
|
-
readonly center: { readonly id: ForgeThreadId; readonly focus: boolean } | null
|
|
97
|
+
readonly center: { readonly id: ForgeThreadId; readonly focus: boolean; readonly url: string | null } | null
|
|
86
98
|
}
|
|
87
99
|
|
|
88
100
|
/** Business face of the changes tab body. */
|
|
@@ -101,26 +113,40 @@ export interface ChangesTabInjected {
|
|
|
101
113
|
readonly panel: (visibility: string) => HostObservable<PanelSnapshot> | undefined
|
|
102
114
|
readonly annotations: (address: string) => HostObservable<ViewAnnotations>
|
|
103
115
|
}
|
|
104
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Lens titles Client plugins describe, the Host's lenses and annotation limit, and the active UI language; bound as
|
|
118
|
+
* `useLenses`, `useExtensions`, and `useLocale`.
|
|
119
|
+
*/
|
|
105
120
|
readonly hooks: {
|
|
106
121
|
readonly lenses: HostObservable<readonly ForgeLensDescription[]>
|
|
107
122
|
readonly extensions: HostObservable<StreamSnapshot<ForgeExtensionState | null>>
|
|
123
|
+
readonly locale: HostObservable<string>
|
|
108
124
|
}
|
|
125
|
+
/** The actions the status blocks of a change request's view run on it, beyond opening a link. */
|
|
126
|
+
readonly changeActions: BoundStatusActions
|
|
109
127
|
/** Classify the shown files with a Host lens; `signal` aborts the stream. */
|
|
110
128
|
readonly changesLens: (request: ForgeLensRequest, signal: AbortSignal) => HostStream<ForgeLensFrame>
|
|
111
129
|
/** Open the panel stream again after it ended. */
|
|
112
130
|
readonly reconnect: () => void
|
|
113
131
|
/** Read the local changes of one scope; `signal` aborts the read. */
|
|
114
132
|
readonly localDiff: (scope: ForgeLocalScope, signal: AbortSignal) => Promise<RemoteResult<ForgeLocalDiff>>
|
|
115
|
-
/**
|
|
116
|
-
readonly
|
|
133
|
+
/** Stage, unstage, or restore files of the local changes, or return index entries to an earlier tree; never retried. */
|
|
134
|
+
readonly localWrite: (write: ForgeLocalWrite) => Promise<RemoteResult<ForgeLocalWriteResult>>
|
|
135
|
+
/**
|
|
136
|
+
* Read the branches the `branch` scope of the head branch `head`, by its full ref, or of the Session's own checkout
|
|
137
|
+
* for null, can compare with, whose names contain `query`; `signal` aborts the read.
|
|
138
|
+
*/
|
|
139
|
+
readonly diffBases: (head: string | null, query: string, signal: AbortSignal) => Promise<RemoteResult<ForgeBaseBranches>>
|
|
117
140
|
/** Read the new side of one file in a local scope. */
|
|
118
141
|
readonly localText: (scope: ForgeLocalScope, path: string) => Promise<RemoteResult<string>>
|
|
119
|
-
/**
|
|
120
|
-
|
|
142
|
+
/**
|
|
143
|
+
* List the commits of the `branch` scope of the head branch `head`, or of the Session's own checkout for null,
|
|
144
|
+
* compared with `base`, or with the automatic fork point for null; `signal` aborts the read.
|
|
145
|
+
*/
|
|
146
|
+
readonly localCommits: (head: string | null, base: string | null, signal: AbortSignal) => Promise<RemoteResult<ForgeLocalCommits>>
|
|
121
147
|
/** Read the changes of a change request, or of consecutive commits of it, by its binding URL; `signal` aborts the read. */
|
|
122
148
|
readonly changeRequestDiff: (
|
|
123
|
-
url: string, commits:
|
|
149
|
+
url: string, commits: ForgeChangeCommits | null, signal: AbortSignal,
|
|
124
150
|
) => Promise<RemoteResult<ForgeChangeRequestDiff>>
|
|
125
151
|
/** List the commits of a change request, or null when its provider does not read commits; `signal` aborts the read. */
|
|
126
152
|
readonly changeRequestCommits: (url: string, signal: AbortSignal) => Promise<RemoteResult<ForgeCommitList | null>>
|
|
@@ -163,6 +189,7 @@ export type ChangesTabProps =
|
|
|
163
189
|
& PropsStore<ReturnType<typeof createChangesStore>>
|
|
164
190
|
& InjectFace<ChangesTabInjected>
|
|
165
191
|
& PropsLocale<typeof NS>
|
|
192
|
+
& Pick<GlobalStandardProps, 'useMediaQuery'>
|
|
166
193
|
|
|
167
194
|
/** The tab facts the changes view reads: its sidebar tab's, or the review page's for one change request. */
|
|
168
195
|
export interface ChangesViewTab extends Pick<SidebarRightTabInfo['tab'], 'visible' | 'navigation' | 'signal'> {
|
|
@@ -172,8 +199,11 @@ export interface ChangesViewTab extends Pick<SidebarRightTabInfo['tab'], 'visibl
|
|
|
172
199
|
readonly actions: Pick<SidebarRightTabInfo['tab']['actions'], 'bindCommands'>
|
|
173
200
|
}
|
|
174
201
|
|
|
202
|
+
/** The tab's props that it resolves itself before it draws the view. */
|
|
203
|
+
type TabOnlyProps = 'useTabInfo' | 'sessionId' | 'usePanel' | 'useAnnotations' | 'useLocale' | 'useMediaQuery' | 'changeActions'
|
|
204
|
+
|
|
175
205
|
/** Props of the changes view, which the changes tab and the review page draw. */
|
|
176
|
-
export type ChangesViewProps = Omit<ChangesTabProps,
|
|
206
|
+
export type ChangesViewProps = Omit<ChangesTabProps, TabOnlyProps> & {
|
|
177
207
|
/** Tab facts. */
|
|
178
208
|
readonly tab: ChangesViewTab
|
|
179
209
|
/** What the view shows. */
|
|
@@ -188,6 +218,11 @@ export type ChangesViewProps = Omit<ChangesTabProps, 'useTabInfo' | 'sessionId'
|
|
|
188
218
|
readonly openFile: ((path: string) => void) | undefined
|
|
189
219
|
/** Copy of the quote actions where they quote somewhere other than the Session's input. */
|
|
190
220
|
readonly quoteCopy?: QuoteCopy | undefined
|
|
221
|
+
/**
|
|
222
|
+
* What the status control of a change request's view needs; undefined where the surroundings show the status, as on
|
|
223
|
+
* the review page, and the view then has no such control.
|
|
224
|
+
*/
|
|
225
|
+
readonly status?: ChangeStatusFacts | undefined
|
|
191
226
|
}
|
|
192
227
|
|
|
193
228
|
/** Changes of either source as the view draws them. */
|
|
@@ -197,6 +232,10 @@ type ChangesData =
|
|
|
197
232
|
readonly files: readonly ForgeDiffFile[]
|
|
198
233
|
/** Scope the files were read in. */
|
|
199
234
|
readonly scope: ForgeLocalScope
|
|
235
|
+
/** The branch the files show in place of the Session's checked-out one, or null for the Session's own checkout. */
|
|
236
|
+
readonly head: ChangesHead | null
|
|
237
|
+
/** Top-level directory of the worktree the files were read in for `head`, or null when they come from its commits. */
|
|
238
|
+
readonly worktree: string | null
|
|
200
239
|
/** Name of what the `branch` scope compared with; null for other scopes. */
|
|
201
240
|
readonly base: string | null
|
|
202
241
|
/** Untracked files left out. */
|
|
@@ -207,10 +246,10 @@ type ChangesData =
|
|
|
207
246
|
readonly files: readonly ForgeDiffFile[]
|
|
208
247
|
/** Binding URL of the change request. */
|
|
209
248
|
readonly url: string
|
|
210
|
-
/** Commit the files end at
|
|
249
|
+
/** Commit the files end at: the head, the last chosen commit, or the commit they go up to; it supplies unchanged lines. */
|
|
211
250
|
readonly headSha: string
|
|
212
251
|
/** Commits the files cover, or null for the whole change request. */
|
|
213
|
-
readonly commits:
|
|
252
|
+
readonly commits: ForgeChangeCommits | null
|
|
214
253
|
/** Commits the checkout's branch has beyond the head, or null. */
|
|
215
254
|
readonly localAhead: number | null
|
|
216
255
|
/** Web page of each file at the head. */
|
|
@@ -244,6 +283,8 @@ const NO_FOLDS: ReadonlyMap<string, { readonly hunks: ReadonlySet<number>; reado
|
|
|
244
283
|
|
|
245
284
|
const NO_PATHS: ReadonlySet<string> = new Set()
|
|
246
285
|
|
|
286
|
+
const NO_COMMITS: ReadonlySet<string> = new Set()
|
|
287
|
+
|
|
247
288
|
const NO_ANNOTATIONS: ViewAnnotations = new Map()
|
|
248
289
|
|
|
249
290
|
/** The toolbar row's close action, which has no menu to close. */
|
|
@@ -272,6 +313,9 @@ const FAILURE: Partial<Record<string, ForgePanelKey>> = {
|
|
|
272
313
|
'forgePanel/commits-not-linear': 'commits.notLinear',
|
|
273
314
|
}
|
|
274
315
|
|
|
316
|
+
/** Git's name for the checked-out commit, shown for a checkout that has neither a branch nor a commit yet. */
|
|
317
|
+
const GIT_HEAD = 'HEAD'
|
|
318
|
+
|
|
275
319
|
/** Failures of a chosen base branch, which offer the automatic fork point instead of a retry. */
|
|
276
320
|
const BASE_FAILURE: Partial<Record<string, ForgePanelKey>> = {
|
|
277
321
|
'forgePanel/base-missing': 'diff.baseMissing',
|
|
@@ -295,6 +339,7 @@ function baseFailureOf(failed: string | null, base: ForgeBaseBranch | null, t: T
|
|
|
295
339
|
* status, beside the diff; marks read at another head refuse the read as the diff refuses a moved head.
|
|
296
340
|
* @param source - local changes or a change request.
|
|
297
341
|
* @param scope - local scope to read.
|
|
342
|
+
* @param localHead - the branch the local scope shows in place of the Session's checked-out one, or null.
|
|
298
343
|
* @param commits - chosen commits of a change request, or null for all of it.
|
|
299
344
|
* @param head - head commit of the change request's latest status, or null.
|
|
300
345
|
* @param fresh - whether the viewed marks are read from the code host although the host keeps some, as after a refresh.
|
|
@@ -305,7 +350,8 @@ function baseFailureOf(failed: string | null, base: ForgeBaseBranch | null, t: T
|
|
|
305
350
|
async function readChanges(
|
|
306
351
|
source: ChangesSource,
|
|
307
352
|
scope: ForgeLocalScope,
|
|
308
|
-
|
|
353
|
+
localHead: ChangesHead | null,
|
|
354
|
+
commits: ForgeChangeCommits | null,
|
|
309
355
|
head: string | null,
|
|
310
356
|
fresh: boolean,
|
|
311
357
|
reads: Pick<ChangesTabInjected, 'localDiff' | 'changeRequestDiff' | 'changeRequestViewed'>,
|
|
@@ -314,8 +360,8 @@ async function readChanges(
|
|
|
314
360
|
if (source.kind === 'local') {
|
|
315
361
|
const result = await reads.localDiff(scope, signal)
|
|
316
362
|
if (!result.ok) return result
|
|
317
|
-
const { files, base, omitted } = result.value
|
|
318
|
-
return { ok: true, value: { kind: 'local', files, scope, base, omitted } }
|
|
363
|
+
const { files, base, omitted, worktree } = result.value
|
|
364
|
+
return { ok: true, value: { kind: 'local', files, scope, head: localHead, worktree: worktree ?? null, base, omitted } }
|
|
319
365
|
}
|
|
320
366
|
const [result, marks] = await Promise.all([
|
|
321
367
|
reads.changeRequestDiff(source.url, commits, signal),
|
|
@@ -328,31 +374,49 @@ async function readChanges(
|
|
|
328
374
|
return { ok: true, value: { kind: 'change', files, url: source.url, headSha, commits, localAhead, fileUrls, viewed } }
|
|
329
375
|
}
|
|
330
376
|
|
|
377
|
+
/** The sentence that says what restoring a file of the `unstaged` scope does to it. */
|
|
378
|
+
function restoreCopyOf(file: ForgeDiffFile): ForgePanelKey {
|
|
379
|
+
return file.untracked ? 'diff.restore.untracked' : file.status === 'deleted' ? 'diff.restore.deleted' : 'diff.restore.modified'
|
|
380
|
+
}
|
|
381
|
+
|
|
331
382
|
/** The ref that identifies a comparison: the chosen base branch, or null for the automatic fork point and other scopes. */
|
|
332
383
|
function baseRefOf(scope: ForgeLocalScope): string | null {
|
|
333
384
|
return scope.kind === 'branch' ? scope.base : null
|
|
334
385
|
}
|
|
335
386
|
|
|
387
|
+
/** The consecutive commits among a tab's chosen commits, or null for all commits and for changes up to one commit. */
|
|
388
|
+
function rangeOf(commits: ForgeChangeCommits | null): ForgeCommitRange | null {
|
|
389
|
+
return commits !== null && 'from' in commits ? commits : null
|
|
390
|
+
}
|
|
391
|
+
|
|
336
392
|
/** The commits a local scope shows, or null for all of them and for scopes other than `branch`. */
|
|
337
393
|
function commitsOf(scope: ForgeLocalScope): ForgeCommitRange | null {
|
|
338
394
|
return scope.kind === 'branch' ? scope.commits : null
|
|
339
395
|
}
|
|
340
396
|
|
|
341
|
-
/**
|
|
397
|
+
/**
|
|
398
|
+
* The source review comments on loaded changes record: the change request head, or the local scope with its base and,
|
|
399
|
+
* for another branch than the Session's checked-out one, that branch with the worktree the changes were read in.
|
|
400
|
+
* Changes up to a commit are the whole change request as that commit ended it, so they record that commit as the head.
|
|
401
|
+
*/
|
|
342
402
|
function reviewSourceOf(data: ChangesData): ReviewSource {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
403
|
+
if (data.kind === 'change') return { kind: 'change', url: data.url, headSha: data.headSha, commits: rangeOf(data.commits) }
|
|
404
|
+
const head: ReviewHead | undefined = data.head === null ? undefined : { key: data.head.ref, name: data.head.name, root: data.worktree }
|
|
405
|
+
return {
|
|
406
|
+
kind: 'local', scope: data.scope.kind, base: data.base, baseRef: baseRefOf(data.scope), commits: commitsOf(data.scope),
|
|
407
|
+
...(head === undefined ? {} : { head }),
|
|
408
|
+
}
|
|
346
409
|
}
|
|
347
410
|
|
|
348
411
|
/**
|
|
349
|
-
* Identity of a diff source for viewed marks: the change request or local scope with its base ref and chosen commits
|
|
412
|
+
* Identity of a diff source for viewed marks: the change request or local scope with its base ref and chosen commits,
|
|
413
|
+
* and the head while it is not the Session's own checkout, whose marks keep the identity they had before heads.
|
|
350
414
|
* A change request's marks stay across head commits, so a file whose change a new push altered reads as changed.
|
|
351
415
|
*/
|
|
352
416
|
function viewedSourceOf(source: ReviewSource): string {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
417
|
+
if (source.kind === 'change') return JSON.stringify(['change', source.url, source.commits])
|
|
418
|
+
const local = ['local', source.scope, source.baseRef, source.commits]
|
|
419
|
+
return JSON.stringify(source.head === undefined ? local : [...local, source.head.key])
|
|
356
420
|
}
|
|
357
421
|
|
|
358
422
|
/**
|
|
@@ -392,19 +456,54 @@ function pathTooltipOf(file: ForgeDiffFile, t: Translate): string {
|
|
|
392
456
|
return file.status === 'renamed' && file.previousPath !== null ? t('diff.renamedPath', { from: file.previousPath, path: file.path }) : file.path
|
|
393
457
|
}
|
|
394
458
|
|
|
459
|
+
/** The badge after a path and the letter a narrow view draws in its place. */
|
|
460
|
+
interface FileBadge {
|
|
461
|
+
readonly text: string
|
|
462
|
+
/** Git's status letter for the change, or `U` for an untracked file as editors mark it; the same in every language. */
|
|
463
|
+
readonly letter: string
|
|
464
|
+
}
|
|
465
|
+
|
|
395
466
|
/** The badge after a path: how the file changed, and whether a branch view's file is untracked. */
|
|
396
|
-
function badgeOf(file: ForgeDiffFile, data: ChangesData, t: Translate):
|
|
467
|
+
function badgeOf(file: ForgeDiffFile, data: ChangesData, t: Translate): FileBadge {
|
|
397
468
|
const parts: string[] = []
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
469
|
+
let letter = ''
|
|
470
|
+
if (file.status === 'added') {
|
|
471
|
+
parts.push(t('diff.newFile'))
|
|
472
|
+
letter = 'A'
|
|
473
|
+
} else if (file.status === 'deleted') {
|
|
474
|
+
parts.push(t('diff.deletedFile'))
|
|
475
|
+
letter = 'D'
|
|
476
|
+
} else if (file.status === 'renamed' && file.previousPath !== null) {
|
|
477
|
+
parts.push(t('diff.renamed', { from: renamedFrom(file.previousPath, file.path) }))
|
|
478
|
+
letter = 'R'
|
|
479
|
+
}
|
|
480
|
+
if (file.untracked && data.kind === 'local' && data.scope.kind === 'branch') {
|
|
481
|
+
parts.push(t('diff.badgeUncommitted'))
|
|
482
|
+
letter = 'U'
|
|
483
|
+
}
|
|
484
|
+
return { text: parts.join(' · '), letter }
|
|
403
485
|
}
|
|
404
486
|
|
|
405
|
-
|
|
487
|
+
/**
|
|
488
|
+
* Fold a header row for as long as it shows: its names shorten first, then its controls take their compact forms.
|
|
489
|
+
* @returns the ref of the row.
|
|
490
|
+
*/
|
|
491
|
+
function useHeaderFold(): RefObject<HTMLDivElement | null> {
|
|
492
|
+
const row = useRef<HTMLDivElement>(null)
|
|
493
|
+
useLayoutEffect(() => {
|
|
494
|
+
/* v8 ignore next -- a header renders its row whenever it renders */
|
|
495
|
+
if (row.current === null) return
|
|
496
|
+
return observeHeaderFold(row.current)
|
|
497
|
+
}, [])
|
|
498
|
+
return row
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function ChangeHeader({ url, entry, status, openLink, commitMenu, reviewCount, reviewDisabled, onReview, t }: {
|
|
406
502
|
readonly url: string
|
|
503
|
+
/** The change request's panel entry; undefined before the panel names it and while the tab is hidden, which reads no panel state. */
|
|
407
504
|
readonly entry: ChangeRequestEntry | undefined
|
|
505
|
+
/** What the status control needs, or undefined for a view without one. */
|
|
506
|
+
readonly status: ChangeStatusFacts | undefined
|
|
408
507
|
/** Commit picker left of the review button. */
|
|
409
508
|
readonly commitMenu: ReactNode
|
|
410
509
|
readonly reviewCount: number
|
|
@@ -417,20 +516,30 @@ function ChangeHeader({ url, entry, openLink, commitMenu, reviewCount, reviewDis
|
|
|
417
516
|
const number = numberOf(entry ?? { ref: null, url })
|
|
418
517
|
const tone = toneOf(snapshot)
|
|
419
518
|
const href = snapshot === null ? url : snapshot.url
|
|
519
|
+
const row = useHeaderFold()
|
|
520
|
+
const title = snapshot === null ? url : snapshot.title
|
|
420
521
|
return (
|
|
421
|
-
<div className={css.header}>
|
|
522
|
+
<div ref={row} className={css.header}>
|
|
422
523
|
<ChangeRequestGlyph tone={tone} label={t('change.stateAria', { state: t(TONE_LABEL[tone]) })} />
|
|
423
|
-
<span className={css.
|
|
424
|
-
|
|
524
|
+
<span className={css.headerName}>
|
|
525
|
+
<Tooltip label={title} side="bottom" portal delayMs={500} maxWidth={360} onlyWhenClipped>
|
|
526
|
+
<span className={css.headerTitle} data-fold-floor="">{title}</span>
|
|
527
|
+
</Tooltip>
|
|
528
|
+
{number !== null && <span className={css.headerNumber}>{t('change.number', { number })}</span>}
|
|
529
|
+
</span>
|
|
425
530
|
<span className={css.headerEnd}>
|
|
531
|
+
{/* A hidden tab has no entry, so the control unmounts there with its open panel and the menus of its blocks. */}
|
|
532
|
+
{status !== undefined && entry !== undefined && snapshot !== null && (
|
|
533
|
+
<ChangeStatus entry={entry} snapshot={snapshot} {...status} t={t} />
|
|
534
|
+
)}
|
|
426
535
|
{commitMenu}
|
|
427
536
|
<Button size="sm" variant="outline" className={css.headerAction} disabled={reviewDisabled} onClick={onReview}>
|
|
428
537
|
{t('review.submit')}{reviewCount > 0 ? ` (${reviewCount})` : ''}
|
|
429
538
|
</Button>
|
|
430
539
|
</span>
|
|
431
|
-
<Tooltip label={t('change.
|
|
432
|
-
<button type="button" className={css.tool} aria-label={t('change.
|
|
433
|
-
<
|
|
540
|
+
<Tooltip label={t('change.viewOn')} side="bottom" delayMs={500}>
|
|
541
|
+
<button type="button" className={css.tool} aria-label={t('change.viewOn')} onClick={() => { openLink(href) }}>
|
|
542
|
+
<ForgeGlyph forge={entry?.forge?.forge ?? null} />
|
|
434
543
|
</button>
|
|
435
544
|
</Tooltip>
|
|
436
545
|
</div>
|
|
@@ -438,44 +547,77 @@ function ChangeHeader({ url, entry, openLink, commitMenu, reviewCount, reviewDis
|
|
|
438
547
|
}
|
|
439
548
|
|
|
440
549
|
/**
|
|
441
|
-
* The local view's header: for the `branch` scope
|
|
442
|
-
*
|
|
550
|
+
* The local view's header: the head picker, then for the `branch` scope the base branch picker, whose menu says
|
|
551
|
+
* whether uncommitted changes count; for another scope, what it compares. Writes and the create button belong to the
|
|
552
|
+
* Session's own checkout.
|
|
443
553
|
*/
|
|
444
|
-
function LocalHeader({
|
|
554
|
+
function LocalHeader({
|
|
555
|
+
state, scope, head, headMissing, base, baseLabel, missing, visible, diffBases, chooseHead, choose, commitMenu, bulk, createChangeRequest,
|
|
556
|
+
t,
|
|
557
|
+
}: {
|
|
445
558
|
readonly state: ChangesPanelState | null
|
|
446
559
|
/** Commit picker of the `branch` scope, left of the create button. */
|
|
447
560
|
readonly commitMenu: ReactNode
|
|
561
|
+
/** The write of every shown file that the scope offers, or null for a scope, head, or Session without writes. */
|
|
562
|
+
readonly bulk: { readonly label: string; readonly disabled: boolean; readonly run: () => void } | null
|
|
448
563
|
readonly scope: ScopeKind
|
|
564
|
+
/** The branch the view shows in place of the Session's checked-out one, or null for the Session's own checkout. */
|
|
565
|
+
readonly head: ChangesHead | null
|
|
566
|
+
/** Whether the chosen head no longer exists. */
|
|
567
|
+
readonly headMissing: boolean
|
|
449
568
|
readonly base: ForgeBaseBranch | null
|
|
569
|
+
/** Name of the base another head's loaded `branch` scope compared with, or null before it loaded; the panel names the own checkout's. */
|
|
570
|
+
readonly baseLabel: string | null
|
|
450
571
|
/** Whether the chosen base branch no longer exists. */
|
|
451
572
|
readonly missing: boolean
|
|
452
573
|
readonly visible: boolean
|
|
453
574
|
readonly diffBases: ChangesTabInjected['diffBases']
|
|
575
|
+
readonly chooseHead: (head: ChangesHead | null) => void
|
|
454
576
|
readonly choose: (base: ForgeBaseBranch | null) => void
|
|
455
577
|
readonly createChangeRequest: () => void
|
|
456
578
|
readonly t: Translate
|
|
457
579
|
}): ReactNode {
|
|
458
|
-
const creatable = state !== null && state.repository !== null && openChangeRequestOf(state) === undefined
|
|
580
|
+
const creatable = head === null && state !== null && state.repository !== null && openChangeRequestOf(state) === undefined
|
|
459
581
|
const checkout = state?.checkout.state === 'ready' ? state.checkout.checkout : null
|
|
460
|
-
const
|
|
582
|
+
const headRef = head?.ref ?? null
|
|
583
|
+
const listBases = useCallback((query: string, signal: AbortSignal) => diffBases(headRef, query, signal), [diffBases, headRef])
|
|
584
|
+
// Branches a reader can show: every branch but the one the Session has checked out, which is its own checkout's row.
|
|
585
|
+
const listHeads = useCallback((query: string, signal: AbortSignal) => diffBases(null, query, signal), [diffBases])
|
|
586
|
+
// A branch that no worktree has checked out is read from its commits; a checkout's comparison counts its uncommitted changes.
|
|
587
|
+
const committedOnly = head !== null && head.worktree === null
|
|
588
|
+
const baseNote = t(committedOnly ? 'diff.base.noteCommitted' : 'diff.base.note')
|
|
589
|
+
// The base the automatic choice compares with: the panel's for the Session's own checkout, else the one the diff was read with.
|
|
590
|
+
const automaticBase = head === null ? state?.local?.base : baseLabel
|
|
591
|
+
const row = useHeaderFold()
|
|
461
592
|
return (
|
|
462
|
-
<div className={css.header}>
|
|
593
|
+
<div ref={row} className={css.header}>
|
|
594
|
+
<span className={css.headerIcon}><IconBranchOutlineRegular size={15} /></span>
|
|
595
|
+
<HeadMenu chosen={head} own={checkout?.branch ?? checkout?.commit ?? GIT_HEAD} missing={headMissing} visible={visible}
|
|
596
|
+
list={listHeads} choose={chooseHead} t={t} />
|
|
463
597
|
{scope === 'branch' ? <>
|
|
464
|
-
<span className={css.headerIcon}><IconBranchOutlineRegular size={15} /></span>
|
|
465
|
-
<Tooltip label={head} side="bottom" delayMs={500}>
|
|
466
|
-
<span className={css.headerHead} tabIndex={0} data-forge-head="">{head}</span>
|
|
467
|
-
</Tooltip>
|
|
468
598
|
<span className={css.headerArrow} aria-hidden="true">→</span>
|
|
469
|
-
<BaseMenu chosen={base} label={base?.name ??
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
</> :
|
|
473
|
-
<
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
599
|
+
<BaseMenu chosen={base} label={base?.name ?? automaticBase ?? t('diff.base.automatic')}
|
|
600
|
+
missing={missing} note={baseNote}
|
|
601
|
+
visible={visible} list={listBases} choose={choose} t={t} />
|
|
602
|
+
</> : (
|
|
603
|
+
<Tooltip label={t(SCOPE_NOTE[scope])} side="bottom" portal delayMs={500} onlyWhenClipped>
|
|
604
|
+
<span className={css.headerNote}>{t(SCOPE_NOTE[scope])}</span>
|
|
605
|
+
</Tooltip>
|
|
606
|
+
)}
|
|
607
|
+
{(scope === 'branch' || creatable || bulk !== null) && <span className={css.headerEnd} data-forge-header-buttons={scope === 'branch' ? undefined : ''}>
|
|
477
608
|
{scope === 'branch' && commitMenu}
|
|
478
|
-
{
|
|
609
|
+
{bulk !== null && (
|
|
610
|
+
<Button size="sm" variant="outline" className={css.headerAction} disabled={bulk.disabled} data-forge-write-all="" onClick={bulk.run}>{bulk.label}</Button>
|
|
611
|
+
)}
|
|
612
|
+
{creatable && (
|
|
613
|
+
// The tooltip names the button only in its icon form, where the label is cut off.
|
|
614
|
+
<Tooltip label={t('changes.local.create')} side="bottom" align="end" portal delayMs={500} onlyWhenClipped>
|
|
615
|
+
<Button size="sm" variant="outline" className={clsx(css.headerAction, css.compactable)} onClick={createChangeRequest}>
|
|
616
|
+
<span className={css.compactIcon} aria-hidden="true"><ChangeRequestGlyph tone="open" tinted={false} size={15} /></span>
|
|
617
|
+
<span className={css.compactText}>{t('changes.local.create')}</span>
|
|
618
|
+
</Button>
|
|
619
|
+
</Tooltip>
|
|
620
|
+
)}
|
|
479
621
|
</span>}
|
|
480
622
|
</div>
|
|
481
623
|
)
|
|
@@ -487,6 +629,11 @@ function ScopeMenu({ scope, choose, t }: {
|
|
|
487
629
|
readonly t: Translate
|
|
488
630
|
}): ReactNode {
|
|
489
631
|
const [open, setOpen] = useState(false)
|
|
632
|
+
const close = useCallback((): void => { setOpen(false) }, [])
|
|
633
|
+
const select = useCallback((id: string): void => {
|
|
634
|
+
setOpen(false)
|
|
635
|
+
choose(id as ScopeKind)
|
|
636
|
+
}, [choose])
|
|
490
637
|
const items: MenuEntry[] = [
|
|
491
638
|
{ id: 'uncommitted', label: t(SCOPE_LABEL.uncommitted) },
|
|
492
639
|
{ id: 'unstaged', label: t(SCOPE_LABEL.unstaged) },
|
|
@@ -503,11 +650,8 @@ function ScopeMenu({ scope, choose, t }: {
|
|
|
503
650
|
autoFocus
|
|
504
651
|
selectedId={scope}
|
|
505
652
|
items={items}
|
|
506
|
-
onClose={
|
|
507
|
-
onSelect={
|
|
508
|
-
setOpen(false)
|
|
509
|
-
choose(id as ScopeKind)
|
|
510
|
-
}}
|
|
653
|
+
onClose={close}
|
|
654
|
+
onSelect={select}
|
|
511
655
|
anchor={(
|
|
512
656
|
<button type="button" className={css.select} aria-haspopup="menu" aria-expanded={open} data-forge-scope={scope}
|
|
513
657
|
onClick={() => { setOpen(value => !value) }}>
|
|
@@ -547,8 +691,15 @@ function OrphanReviews({ path, actions, t }: PropsLocale<typeof NS> & {
|
|
|
547
691
|
* @param props - tab information, the tab's choices, the panel snapshot hook, reads and actions, and copy.
|
|
548
692
|
* @returns the view body.
|
|
549
693
|
*/
|
|
550
|
-
export function ChangesTab({
|
|
694
|
+
export function ChangesTab({
|
|
695
|
+
useTabInfo, sessionId, usePanel, useAnnotations, useLocale, useMediaQuery, changeActions, ...props
|
|
696
|
+
}: ChangesTabProps): ReactNode {
|
|
551
697
|
const { tab } = useTabInfo()
|
|
698
|
+
const locale = useLocale(value => value)
|
|
699
|
+
const coarsePointer = useMediaQuery('(pointer: coarse)')
|
|
700
|
+
const { openLink } = props
|
|
701
|
+
const status = useMemo(() => ({ locale, coarsePointer, actions: { ...changeActions, openLink } }),
|
|
702
|
+
[locale, coarsePointer, changeActions, openLink])
|
|
552
703
|
const target = useMemo(() => parseChangesAddress(tab.contentId), [tab.contentId])
|
|
553
704
|
if (target === undefined) throw new Error(`forge-panel: not a changes address "${tab.contentId}"`)
|
|
554
705
|
const snapshot = usePanel(tab.visible ? 'visible' : 'inactive')
|
|
@@ -558,7 +709,7 @@ export function ChangesTab({ useTabInfo, sessionId, usePanel, useAnnotations, ..
|
|
|
558
709
|
tabActions.openResource(fileAddressFor(sessionId, undefined, path))
|
|
559
710
|
}, [tabActions, sessionId])
|
|
560
711
|
return <ChangesView {...props} tab={tab} source={target.source} target={target} snapshot={snapshot} annotations={annotations}
|
|
561
|
-
openFile={openFile} />
|
|
712
|
+
openFile={openFile} status={status} />
|
|
562
713
|
}
|
|
563
714
|
|
|
564
715
|
/**
|
|
@@ -567,8 +718,9 @@ export function ChangesTab({ useTabInfo, sessionId, usePanel, useAnnotations, ..
|
|
|
567
718
|
* @returns the view body.
|
|
568
719
|
*/
|
|
569
720
|
export function ChangesView({
|
|
570
|
-
tab, source, target, snapshot, annotations: viewAnnotations, openFile, quoteCopy, useStore, actions, reconnect,
|
|
571
|
-
|
|
721
|
+
tab, source, target: viewTarget, snapshot, annotations: viewAnnotations, openFile, quoteCopy, status, useStore, actions, reconnect,
|
|
722
|
+
localDiff,
|
|
723
|
+
localWrite, diffBases, localText,
|
|
572
724
|
localCommits, changeRequestDiff, changeRequestText, changeRequestCommits, changeRequestReview, changeRequestReviewWrite, viewedFiles,
|
|
573
725
|
changeRequestViewed, setFileViewed, openLink, copyPath, createChangeRequest, addReviewToInput, addThreadToInput, reviewQueue,
|
|
574
726
|
submitReview, report, useLenses, useExtensions, changesLens, renderSlot, t: translate,
|
|
@@ -697,15 +849,25 @@ export function ChangesView({
|
|
|
697
849
|
const chosenCommits = choices?.commits ?? null
|
|
698
850
|
const lens = choices?.lens ?? 'all'
|
|
699
851
|
const hideTests = choices?.hideTests ?? false
|
|
700
|
-
|
|
701
|
-
|
|
852
|
+
// The branch local changes show in place of the Session's checked-out one; a change request view has none.
|
|
853
|
+
const localHead = source.kind === 'local' ? choices?.head ?? null : null
|
|
854
|
+
const headRef = localHead?.ref ?? null
|
|
855
|
+
// The Session's own checkout names no head, so its scopes keep the identity they had before heads.
|
|
856
|
+
const localScope = useMemo((): ForgeLocalScope => {
|
|
857
|
+
const shown = headRef === null ? {} : { head: headRef }
|
|
858
|
+
return scope === 'branch' ? { kind: 'branch', ...shown, base: base?.ref ?? null, commits: rangeOf(chosenCommits) } : { kind: scope, ...shown }
|
|
859
|
+
}, [scope, headRef, base, chosenCommits])
|
|
860
|
+
// Other plugins contribute to the Session's own local changes; another head shows without their slots and annotations.
|
|
861
|
+
const target = localHead === null ? viewTarget : null
|
|
702
862
|
const changeCommits = source.kind === 'change' ? chosenCommits : null
|
|
703
863
|
const changeUrlOf = source.kind === 'change' ? source.url : ''
|
|
704
864
|
const listChangeCommits = useCallback(
|
|
705
865
|
(signal: AbortSignal) => changeRequestCommits(changeUrlOf, signal), [changeRequestCommits, changeUrlOf],
|
|
706
866
|
)
|
|
707
867
|
const baseRef = base?.ref ?? null
|
|
708
|
-
const listLocalCommits = useCallback(
|
|
868
|
+
const listLocalCommits = useCallback(
|
|
869
|
+
(signal: AbortSignal) => localCommits(headRef, baseRef, signal), [localCommits, headRef, baseRef],
|
|
870
|
+
)
|
|
709
871
|
const split = choices?.split ?? true
|
|
710
872
|
const wrap = choices?.wrap ?? true
|
|
711
873
|
// A read starts once the panel state arrives and again when what it describes moves. A change request's read
|
|
@@ -720,10 +882,15 @@ export function ChangesView({
|
|
|
720
882
|
const headCommit = state !== null && state.checkout.state === 'ready' ? state.checkout.checkout.commit : null
|
|
721
883
|
// The commits change with the head of a change request, with the local HEAD, branch, or base, and on a refresh.
|
|
722
884
|
const commitsVersion = `${attempt}\n${source.kind === 'local'
|
|
723
|
-
? `${baseRef ?? ''}\n${headCommit ?? ''}\n${JSON.stringify(state?.local ?? null)}` : head ?? ''}`
|
|
885
|
+
? `${headRef ?? ''}\n${baseRef ?? ''}\n${headCommit ?? ''}\n${JSON.stringify(state?.local ?? null)}` : head ?? ''}`
|
|
724
886
|
const dataKey = source.kind === 'local' ? JSON.stringify(localScope) : `change\n${JSON.stringify(changeCommits)}`
|
|
725
887
|
const [loaded, setLoaded] = useState<{ readonly key: string; readonly data: ChangesData } | null>(null)
|
|
726
888
|
const [failure, setFailure] = useState<{ readonly key: string; readonly code: string } | null>(null)
|
|
889
|
+
// Commits the code host answered it does not have when the reader opened a thread written on them. Threads written on
|
|
890
|
+
// them are lost and open in their file's outdated section; a refresh forgets the commits, so the host is asked again.
|
|
891
|
+
const [goneAt, setGoneAt] = useState<{ readonly attempt: number; readonly commits: ReadonlySet<string> }>(
|
|
892
|
+
{ attempt, commits: NO_COMMITS })
|
|
893
|
+
const gone = goneAt.attempt === attempt ? goneAt.commits : NO_COMMITS
|
|
727
894
|
// Names the read the inputs ask for; it is in flight until `finished` matches it.
|
|
728
895
|
const read = version === null ? null : `${dataKey}\n${navigation.revision}\n${attempt}\n${version}`
|
|
729
896
|
const [finished, setFinished] = useState<string | null>(null)
|
|
@@ -743,7 +910,7 @@ export function ChangesView({
|
|
|
743
910
|
const readAt = latestStatusAt.current
|
|
744
911
|
const fresh = finishedAttempt.current !== attempt
|
|
745
912
|
const reads = { localDiff, changeRequestDiff, changeRequestViewed }
|
|
746
|
-
void readChanges(source, localScope, changeCommits, head, fresh, reads, controller.signal)
|
|
913
|
+
void readChanges(source, localScope, localHead, changeCommits, head, fresh, reads, controller.signal)
|
|
747
914
|
.then((result) => {
|
|
748
915
|
if (controller.signal.aborted) return
|
|
749
916
|
if (!result.ok && result.error.code === 'forgePanel/stale-head') {
|
|
@@ -751,18 +918,39 @@ export function ChangesView({
|
|
|
751
918
|
setFailure(null)
|
|
752
919
|
return
|
|
753
920
|
}
|
|
921
|
+
// The code host does not have the commit the changes go up to, which a thread written on it named: the view
|
|
922
|
+
// returns to all commits, where that thread stays in its file's outdated section and the pending jump ends.
|
|
923
|
+
if (!result.ok && result.error.code === 'forgePanel/commits-missing' && changeCommits !== null && 'upTo' in changeCommits) {
|
|
924
|
+
const commit = changeCommits.upTo
|
|
925
|
+
setGoneAt(value => ({ attempt, commits: new Set([...value.attempt === attempt ? value.commits : [], commit]) }))
|
|
926
|
+
actions.committed(tab.id, null)
|
|
927
|
+
live.current.report('toast.commitGone', { params: { commit: commit.slice(0, 7) } })
|
|
928
|
+
return
|
|
929
|
+
}
|
|
930
|
+
// The worktree that had the shown branch checked out is gone, so the tab falls back to the branch's commits,
|
|
931
|
+
// read again because what it loaded for the `branch` scope counted that worktree's files.
|
|
932
|
+
if (!result.ok && result.error.code === 'forgePanel/no-working-tree') {
|
|
933
|
+
setFinished(null)
|
|
934
|
+
setLoaded(null)
|
|
935
|
+
actions.rooted(tab.id, null)
|
|
936
|
+
return
|
|
937
|
+
}
|
|
754
938
|
finishedAttempt.current = attempt
|
|
755
939
|
setFinished(read)
|
|
756
940
|
if (result.ok) {
|
|
757
941
|
setLoaded({ key: dataKey, data: result.value })
|
|
758
942
|
setFailure(null)
|
|
943
|
+
// A worktree added or removed since the branch was listed decides which scopes the branch has.
|
|
944
|
+
if (result.value.kind === 'local' && localHead !== null && result.value.worktree !== localHead.worktree) {
|
|
945
|
+
actions.rooted(tab.id, result.value.worktree)
|
|
946
|
+
}
|
|
759
947
|
} else {
|
|
760
948
|
setFailure({ key: dataKey, code: result.error.code })
|
|
761
949
|
}
|
|
762
950
|
})
|
|
763
951
|
return () => { controller.abort() }
|
|
764
|
-
}, [tab.visible, read, refused, waiting, source, localScope, changeCommits, head, attempt, dataKey, localDiff,
|
|
765
|
-
changeRequestViewed])
|
|
952
|
+
}, [tab.visible, tab.id, actions, read, refused, waiting, source, localScope, localHead, changeCommits, head, attempt, dataKey, localDiff,
|
|
953
|
+
changeRequestDiff, changeRequestViewed])
|
|
766
954
|
const data = loaded !== null && loaded.key === dataKey ? loaded.data : null
|
|
767
955
|
// Threads show only while they were read at the head of the latest status and, for the whole change request, at
|
|
768
956
|
// the head the shown diff was read at, so their positions number the shown files.
|
|
@@ -770,9 +958,13 @@ export function ChangesView({
|
|
|
770
958
|
const prAuthor = entry?.snapshot?.author ?? null
|
|
771
959
|
const threadRead = useThreadRead({ visible: tab.visible, url: source.kind === 'change' ? source.url : null, head: prHead,
|
|
772
960
|
updatedAt: entry?.snapshot?.updatedAt ?? null, statusAt, attempt, revision: reviewRevision + hostRevision, read: changeRequestReview })
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
const
|
|
961
|
+
// While other commits of the change request load, its threads stay placed in the changes shown before, so the thread
|
|
962
|
+
// list and its toolbar button stay where they are, with the list's scroll position, instead of leaving and coming back.
|
|
963
|
+
const threadsOn = data ?? (loaded?.data.kind === 'change' && source.kind === 'change' && loaded.data.url === source.url ? loaded.data : null)
|
|
964
|
+
const review = threadsOn?.kind === 'change' && threadRead.review !== null && threadRead.review.headSha === prHead
|
|
965
|
+
&& (threadsOn.commits !== null || threadsOn.headSha === prHead) ? threadRead.review : null
|
|
966
|
+
const placed = usePlacedThreads(review,
|
|
967
|
+
threadsOn?.kind === 'change' ? { head: prHead ?? '', end: threadsOn.headSha, commits: threadsOn.commits, gone } : null)
|
|
776
968
|
const [threadList, setThreadList] = useState<{
|
|
777
969
|
readonly open: boolean
|
|
778
970
|
readonly filter: ThreadFilter
|
|
@@ -782,6 +974,9 @@ export function ChangesView({
|
|
|
782
974
|
const threadsToggle = useRef<HTMLButtonElement>(null)
|
|
783
975
|
const [focus, setFocus] = useState<ThreadFocus | null>(null)
|
|
784
976
|
const allFiles = useMemo(() => filesInTreeOrder(changedFileTree(data?.files ?? [])), [data])
|
|
977
|
+
// The thread list orders its files as the changes its threads are placed in do.
|
|
978
|
+
const threadFiles = useMemo(() => data !== null || threadsOn === null ? allFiles : filesInTreeOrder(changedFileTree(threadsOn.files)),
|
|
979
|
+
[data, threadsOn, allFiles])
|
|
785
980
|
// A Host filter lens keeps files only once its result for the shown files arrived; until then every file shows.
|
|
786
981
|
const extensions = useExtensions(current => current.state)
|
|
787
982
|
const descriptions = useLenses(current => current)
|
|
@@ -798,6 +993,7 @@ export function ChangesView({
|
|
|
798
993
|
})
|
|
799
994
|
const kept = lensRun.run.kind === 'ready' ? lensRun.run.files : null
|
|
800
995
|
const files = useMemo(() => allFiles.filter(file => shownBy(file, lens, hideTests, kept)), [allFiles, lens, hideTests, kept])
|
|
996
|
+
const countColumn = useMemo(() => countsColumn(files), [files])
|
|
801
997
|
const lensCounts = useMemo(() => Object.fromEntries(LENSES.map(item => [item,
|
|
802
998
|
allFiles.filter(file => shownBy(file, item, hideTests, kept)).length])) as Record<ChangesLens, number>, [allFiles, hideTests, kept])
|
|
803
999
|
const lensTitle = (id: string): string => {
|
|
@@ -822,7 +1018,7 @@ export function ChangesView({
|
|
|
822
1018
|
actions.filtered(tab.id, null)
|
|
823
1019
|
report('filterLens.removed', { params: { lens: live.current.lensTitle(withdrawn) } })
|
|
824
1020
|
}, [withdrawn, actions, tab.id, report])
|
|
825
|
-
const chooseLens = (next: string | null): void => { actions.filtered(tab.id, next) }
|
|
1021
|
+
const chooseLens = useCallback((next: string | null): void => { actions.filtered(tab.id, next) }, [actions, tab.id])
|
|
826
1022
|
// The hunks each kept file folds stay folded until the reader shows them for that file; a new result folds again.
|
|
827
1023
|
const [unfolded, setUnfolded] = useState<{ readonly kept: typeof kept; readonly paths: ReadonlySet<string> }>(
|
|
828
1024
|
{ kept: null, paths: new Set() })
|
|
@@ -839,7 +1035,7 @@ export function ChangesView({
|
|
|
839
1035
|
}
|
|
840
1036
|
return map
|
|
841
1037
|
}, [allFiles, kept, shownPaths, foldTitle])
|
|
842
|
-
const annotations = viewAnnotations ?? NO_ANNOTATIONS
|
|
1038
|
+
const annotations = (localHead === null ? viewAnnotations : undefined) ?? NO_ANNOTATIONS
|
|
843
1039
|
// Annotations wait for the Host's limit.
|
|
844
1040
|
const annotationLimit = extensions?.maxAnnotationsPerFile
|
|
845
1041
|
const shownSource = useMemo(() => data === null ? null : reviewSourceOf(data), [data])
|
|
@@ -861,7 +1057,7 @@ export function ChangesView({
|
|
|
861
1057
|
const failed = failure !== null && failure.key === dataKey ? failure.code : null
|
|
862
1058
|
// Review marks can refresh while a file read is in flight. The commit supplies its text and the patch digests identify its gaps.
|
|
863
1059
|
const expansionSource = useMemo(() => data?.kind === 'change'
|
|
864
|
-
? JSON.stringify([data.url, data.headSha, data.commits
|
|
1060
|
+
? JSON.stringify([data.url, data.headSha, data.commits, data.files.map(file => file.digest)])
|
|
865
1061
|
: data, [data])
|
|
866
1062
|
const [expansion, setExpansion] = useState<Expansion>({ source: null, texts: {}, open: {} })
|
|
867
1063
|
const current = expansion.source === expansionSource ? expansion : { source: expansionSource, texts: {}, open: {} }
|
|
@@ -902,12 +1098,18 @@ export function ChangesView({
|
|
|
902
1098
|
if (kept !== null && !Object.hasOwn(kept, hidden.path)) actions.filtered(tab.id, null)
|
|
903
1099
|
return
|
|
904
1100
|
}
|
|
1101
|
+
const { center } = wanted
|
|
1102
|
+
// A thread opened before these changes were read has no card in them when they lack its file, so it opens on the host.
|
|
1103
|
+
if (center !== null && !allFiles.some(file => file.path === wanted.path)) {
|
|
1104
|
+
if (center.url !== null) openLink(center.url)
|
|
1105
|
+
setWanted(null)
|
|
1106
|
+
return
|
|
1107
|
+
}
|
|
905
1108
|
// The browser's scroll anchoring keeps the section in place while the sections above it draw their lines.
|
|
906
1109
|
const section = sections.current.get(wanted.path)
|
|
907
1110
|
section?.scrollIntoView({ block: 'start' })
|
|
908
1111
|
// A thread the reader opened from the thread list or a file's unresolved count centers inside its file, which the jump
|
|
909
1112
|
// expanded and revealed; the jump ends here, so a later jump to the file stops at its header.
|
|
910
|
-
const { center } = wanted
|
|
911
1113
|
if (center !== null) {
|
|
912
1114
|
/* v8 ignore next 4 -- a centered thread's file is drawn and its card unfolded, so both are found. */
|
|
913
1115
|
const card = [...section?.querySelectorAll<HTMLElement>('[data-forge-thread]') ?? []]
|
|
@@ -917,21 +1119,44 @@ export function ChangesView({
|
|
|
917
1119
|
}
|
|
918
1120
|
if (scrollport.current !== null) jumpPosition.current = { data, top: scrollport.current.scrollTop }
|
|
919
1121
|
setWanted(null)
|
|
920
|
-
}, [tab.visible, wanted, data, allFiles, lens, hideTests, kept, actions, tab.id])
|
|
921
|
-
const refresh = (): void => { setAttempt(value => value + 1) }
|
|
1122
|
+
}, [tab.visible, wanted, data, allFiles, lens, hideTests, kept, actions, tab.id, openLink])
|
|
1123
|
+
const refresh = useCallback((): void => { setAttempt(value => value + 1) }, [])
|
|
1124
|
+
const writes = useLocalWrites({ localWrite, report, reread: refresh, rereading })
|
|
1125
|
+
// Staging and restoring act on the `unstaged` scope and unstaging on `staged`; in the other scopes a write could leave
|
|
1126
|
+
// the shown diff unchanged. Writes reach the Session's own checkout only, so another head offers none.
|
|
1127
|
+
const writeSide = data?.kind === 'local' && data.head === null && (data.scope.kind === 'unstaged' || data.scope.kind === 'staged')
|
|
1128
|
+
? data.scope.kind : undefined
|
|
922
1129
|
const root = state !== null && state.checkout.state === 'ready' ? state.checkout.checkout.root : null
|
|
923
1130
|
// A chosen base branch that is gone or shares no history with HEAD offers the automatic fork point instead.
|
|
924
1131
|
const baseFailure = baseFailureOf(failed, source.kind === 'local' && scope === 'branch' ? base : null, t)
|
|
925
1132
|
// Configuration reads may recover after the user fixes Git settings or raises the output limit.
|
|
926
1133
|
const message = failed === null ? undefined : FAILURE[failed]
|
|
927
|
-
const failureText = baseFailure ?? t(message ?? 'diff.error')
|
|
928
1134
|
const changeUrl = source.kind === 'change' ? entry?.snapshot?.url ?? source.url : null
|
|
929
|
-
|
|
930
|
-
const
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
)
|
|
1135
|
+
// The change request's own page, which the recheck of an unknown review outcome opens rather than the snapshot's.
|
|
1136
|
+
const recheckUrl = source.kind === 'change' ? source.url : null
|
|
1137
|
+
// A head that is gone offers the Session's own checkout instead of a retry.
|
|
1138
|
+
const headMissing = failed === 'forgePanel/head-missing' && localHead !== null
|
|
1139
|
+
const failureText = baseFailure ?? (headMissing ? t('diff.headMissing', { head: localHead.name }) : t(message ?? 'diff.error'))
|
|
1140
|
+
const retry = baseFailure === undefined && !headMissing && (message === undefined || failed === 'forgePanel/filter-config-failed')
|
|
1141
|
+
const chooseAutomaticBase = useCallback((): void => { actions.based(tab.id, null) }, [actions, tab.id])
|
|
1142
|
+
const backToOwnHead = useCallback((): void => { actions.headed(tab.id, null) }, [actions, tab.id])
|
|
1143
|
+
const showAllCommits = useCallback((): void => { actions.committed(tab.id, null) }, [actions, tab.id])
|
|
1144
|
+
const openChangeInBrowser = useCallback((): void => {
|
|
1145
|
+
/* v8 ignore next -- the control renders only once the change has a link */
|
|
1146
|
+
if (changeUrl !== null) openLink(changeUrl)
|
|
1147
|
+
}, [changeUrl, openLink])
|
|
1148
|
+
const recheckReview = useCallback((): void => {
|
|
1149
|
+
/* v8 ignore next -- the control renders only once a recheck link exists */
|
|
1150
|
+
if (recheckUrl !== null) openLink(recheckUrl)
|
|
1151
|
+
}, [openLink, recheckUrl])
|
|
1152
|
+
let automaticBase: ReactNode = false
|
|
1153
|
+
if (baseFailure !== undefined) {
|
|
1154
|
+
automaticBase = <Button size="sm" variant="outline" onClick={chooseAutomaticBase}>{t('diff.useAutomaticBase')}</Button>
|
|
1155
|
+
} else if (headMissing) {
|
|
1156
|
+
automaticBase = <Button size="sm" variant="outline" data-forge-head-own="" onClick={backToOwnHead}>{t('diff.head.back')}</Button>
|
|
1157
|
+
} else if (failed === 'forgePanel/commits-missing' || failed === 'forgePanel/commits-not-linear') {
|
|
1158
|
+
automaticBase = <Button size="sm" variant="outline" onClick={showAllCommits}>{t('commits.showAll')}</Button>
|
|
1159
|
+
}
|
|
935
1160
|
|
|
936
1161
|
const update = (change: (value: Expansion) => Expansion): void => {
|
|
937
1162
|
setExpansion((previous) => {
|
|
@@ -979,21 +1204,32 @@ export function ChangesView({
|
|
|
979
1204
|
}
|
|
980
1205
|
const fileActions = (owner: ChangesData, file: ForgeDiffFile): DiffFileAction[] => {
|
|
981
1206
|
const list: DiffFileAction[] = [{ label: 'diff.copyPath', run: () => { copyPath(file.path) } }]
|
|
982
|
-
if (file.status
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1207
|
+
if (file.status !== 'deleted') {
|
|
1208
|
+
if (owner.kind === 'local') {
|
|
1209
|
+
// The path names the Session's own working tree, which holds another head's file in another version or not at all.
|
|
1210
|
+
if (owner.head === null && root !== null && openFile !== undefined) {
|
|
1211
|
+
list.push({ label: 'diff.openFileInSidebar', run: () => { openFile(`${root}/${file.path}`) } })
|
|
1212
|
+
}
|
|
1213
|
+
} else {
|
|
1214
|
+
const url = owner.fileUrls[file.path]
|
|
1215
|
+
if (url !== undefined) list.push({ label: 'diff.openFileInBrowser', run: () => { openLink(url) } })
|
|
986
1216
|
}
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
|
|
1217
|
+
}
|
|
1218
|
+
// The header's writes again, for a narrow pane on a device without hover, where the header hides them.
|
|
1219
|
+
if (writeSide === 'unstaged') {
|
|
1220
|
+
list.push({ label: 'diff.stageFile', separated: true, disabled: writes.writing, run: () => { writes.write('stage', [file]) } })
|
|
1221
|
+
if (restorable(file)) list.push({ label: 'diff.restoreFileMenu', disabled: writes.writing, run: () => { writes.write('restore', [file]) } })
|
|
1222
|
+
} else if (writeSide === 'staged') {
|
|
1223
|
+
list.push({ label: 'diff.unstageFile', separated: true, disabled: writes.writing, run: () => { writes.write('unstage', [file]) } })
|
|
990
1224
|
}
|
|
991
1225
|
return list
|
|
992
1226
|
}
|
|
993
1227
|
|
|
994
|
-
// A review addresses the head commit
|
|
995
|
-
// the
|
|
996
|
-
// are published as one review.
|
|
1228
|
+
// A review addresses the head commit whatever commits the view shows: the head the whole diff was read at, or the head
|
|
1229
|
+
// of the latest status beside chosen commits. A pending review on the code host is submitted or discarded there;
|
|
1230
|
+
// without one, the summary and any comment drafts kept in the browser are published as one review.
|
|
1231
|
+
let reviewHead: string | null = null
|
|
1232
|
+
if (data?.kind === 'change') reviewHead = data.commits === null ? data.headSha : prHead
|
|
997
1233
|
const pendingReview = review?.pendingReview ?? null
|
|
998
1234
|
const finishWrite = async (send: () => Promise<string | undefined>, done: ForgePanelKey): Promise<void> => {
|
|
999
1235
|
if (reviewRunning.current) return
|
|
@@ -1013,37 +1249,54 @@ export function ChangesView({
|
|
|
1013
1249
|
setReviewBusy(false)
|
|
1014
1250
|
}
|
|
1015
1251
|
}
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1252
|
+
// The change request a review addresses, at `reviewHead`; local changes offer no review form.
|
|
1253
|
+
const reviewData = data !== null && data.kind === 'change' ? data : null
|
|
1254
|
+
const closeReview = useCallback((): void => { setReviewOpen(false) }, [])
|
|
1255
|
+
const checkReview = useCallback((): void => {
|
|
1256
|
+
/* v8 ignore next -- the check control renders only with a change request */
|
|
1257
|
+
if (reviewData !== null) openLink(reviewData.url)
|
|
1258
|
+
}, [openLink, reviewData])
|
|
1259
|
+
const reconcileReview = useCallback((): void => {
|
|
1260
|
+
queue.finish(false)
|
|
1261
|
+
setReviewError(null)
|
|
1262
|
+
}, [queue])
|
|
1263
|
+
const discardReview = useCallback((): void => {
|
|
1264
|
+
/* v8 ignore next -- the discard control renders only with a change request, the head a review addresses, and a pending review */
|
|
1265
|
+
if (reviewData === null || reviewHead === null || pendingReview === null) return
|
|
1266
|
+
void finishWrite(() => writeReview(reviewData.url, { kind: 'discard-pending', headSha: reviewHead, review: pendingReview.id }), 'review.discarded')
|
|
1267
|
+
}, [finishWrite, pendingReview, reviewData, reviewHead, writeReview])
|
|
1268
|
+
const submitReviewForm = useCallback((): void => {
|
|
1269
|
+
/* v8 ignore next -- the review form renders only with a change request and the head a review addresses */
|
|
1270
|
+
if (reviewData === null || reviewHead === null) return
|
|
1271
|
+
const latest = queue.getSnapshot()
|
|
1272
|
+
if (pendingReview === null) {
|
|
1273
|
+
void publishReview(reviewData.url, { kind: 'review', headSha: reviewHead, event: latest.event,
|
|
1274
|
+
body: latest.body, comments: latest.comments.map(item => item.comment) }, url => queue.finish(true, url))
|
|
1275
|
+
return
|
|
1276
|
+
}
|
|
1277
|
+
// The submission is kept as the write to reconcile until the host answers, so an unknown outcome blocks another
|
|
1278
|
+
// submission, which would otherwise publish a second review once the pending review no longer reads.
|
|
1279
|
+
void finishWrite(async () => {
|
|
1280
|
+
if (!queue.begin({ kind: 'review', headSha: reviewHead, event: latest.event, body: latest.body, comments: [] })) {
|
|
1281
|
+
return t('review.saveFailed')
|
|
1027
1282
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
if (!queue.
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
}
|
|
1044
|
-
discard={pendingReview === null ? undefined :
|
|
1045
|
-
void finishWrite(() => writeReview(data.url, { kind: 'discard-pending', headSha: data.headSha, review: pendingReview.id }), 'review.discarded')
|
|
1046
|
-
}} t={t} />
|
|
1283
|
+
const refusal = await sendWrite(reviewData.url, { kind: 'submit-pending', headSha: reviewHead, review: pendingReview.id,
|
|
1284
|
+
event: latest.event, body: latest.body })
|
|
1285
|
+
if (refusal === undefined) {
|
|
1286
|
+
if (!queue.finish(true)) report('review.saveFailed')
|
|
1287
|
+
return undefined
|
|
1288
|
+
}
|
|
1289
|
+
if (!refusal.unknown) queue.finish(false)
|
|
1290
|
+
return refusal.message
|
|
1291
|
+
}, 'review.submitted')
|
|
1292
|
+
}, [finishWrite, pendingReview, publishReview, queue, report, reviewData, reviewHead, sendWrite, t])
|
|
1293
|
+
const reviewForm = tab.visible && reviewData !== null && reviewOpen && reviewHead !== null && <SubmitReview queue={queue}
|
|
1294
|
+
url={reviewData.url} headSha={reviewHead} pending={pendingReview} events={review?.reviewEvents ?? null} busy={reviewBusy}
|
|
1295
|
+
error={reviewError}
|
|
1296
|
+
close={closeReview}
|
|
1297
|
+
check={checkReview} reconcile={reconcileReview}
|
|
1298
|
+
submit={submitReviewForm}
|
|
1299
|
+
discard={pendingReview === null ? undefined : discardReview} t={t} />
|
|
1047
1300
|
|
|
1048
1301
|
/** Add a comment to the pending review on the code host at the head the comment was selected on. */
|
|
1049
1302
|
const addPending = (selection: ReviewSelection): Promise<string | undefined> => {
|
|
@@ -1058,8 +1311,8 @@ export function ChangesView({
|
|
|
1058
1311
|
}
|
|
1059
1312
|
const recordActions: ReviewActions = {
|
|
1060
1313
|
source: shownSource ?? (source.kind === 'local'
|
|
1061
|
-
? { kind: 'local', scope,
|
|
1062
|
-
: { kind: 'change', url: source.url, headSha: '', commits: changeCommits }),
|
|
1314
|
+
? reviewSourceOf({ kind: 'local', files: [], scope: localScope, head: localHead, worktree: localHead?.worktree ?? null, base: null, omitted: 0 })
|
|
1315
|
+
: { kind: 'change', url: source.url, headSha: '', commits: rangeOf(changeCommits) }),
|
|
1063
1316
|
records: queue, addToInput: addReviewToInput, openLink, quoteCopy, onRemoved: reportRemoved,
|
|
1064
1317
|
}
|
|
1065
1318
|
const absentPaths = [...new Set([...reviewState.comments, ...reviewState.records.map(item => item.selection)]
|
|
@@ -1070,11 +1323,13 @@ export function ChangesView({
|
|
|
1070
1323
|
// Thread groups keep their identity across renders that change neither the threads nor what their cards share, so
|
|
1071
1324
|
// only the sections whose threads changed redraw.
|
|
1072
1325
|
const url = data?.kind === 'change' ? data.url : null
|
|
1326
|
+
const family = entry?.forge?.forge ?? null
|
|
1073
1327
|
const threadActions = useMemo((): ThreadActions | null => review === null || url === null ? null : {
|
|
1074
1328
|
author: prAuthor,
|
|
1075
1329
|
addToInput: (thread, range) => addThreadToInput(thread, url, range),
|
|
1076
1330
|
quoteCopy,
|
|
1077
1331
|
openLink,
|
|
1332
|
+
forge: family,
|
|
1078
1333
|
readText: (commit, path) => changeRequestText(url, commit, path),
|
|
1079
1334
|
inputFailed: () => { live.current.report(quoteCopy?.failed ?? 'thread.inputFailed') },
|
|
1080
1335
|
focused: focus,
|
|
@@ -1083,7 +1338,7 @@ export function ChangesView({
|
|
|
1083
1338
|
reviewStarted: review.pendingReview !== null,
|
|
1084
1339
|
canReview: review.viewerCanReview,
|
|
1085
1340
|
},
|
|
1086
|
-
}, [review, url, prAuthor, addThreadToInput, quoteCopy, openLink, changeRequestText, focus])
|
|
1341
|
+
}, [review, url, prAuthor, addThreadToInput, quoteCopy, openLink, family, changeRequestText, focus])
|
|
1087
1342
|
const fileThreads = useMemo(() => new Map<string, FileThreads>(threadActions === null ? []
|
|
1088
1343
|
: [...placed.files].map(([path, group]) => [path, { ...group, actions: threadActions }])), [placed.files, threadActions])
|
|
1089
1344
|
/** Show a file's next unresolved thread in display order after the one last shown, or its first. */
|
|
@@ -1095,25 +1350,33 @@ export function ChangesView({
|
|
|
1095
1350
|
if (next !== undefined) openThread(next, false)
|
|
1096
1351
|
}
|
|
1097
1352
|
/** Close the thread list at the reader's request and return the focus to its toggle. */
|
|
1098
|
-
const closeThreadList = (): void => {
|
|
1353
|
+
const closeThreadList = useCallback((): void => {
|
|
1099
1354
|
setThreadList(value => ({ ...value, open: false }))
|
|
1100
1355
|
threadsToggle.current?.focus()
|
|
1101
|
-
}
|
|
1356
|
+
}, [])
|
|
1102
1357
|
/**
|
|
1103
|
-
* Show a thread
|
|
1104
|
-
*
|
|
1105
|
-
*
|
|
1358
|
+
* Show a thread in its file, unfolded and centered; `focusCard` moves the focus to it. With `written`, an outdated
|
|
1359
|
+
* thread shows in the changes up to the commit it was written on, where its lines still are, while the status names
|
|
1360
|
+
* the base commit those changes start from; without that commit, and when it is lost, it stays in its file's outdated
|
|
1361
|
+
* section. Chosen commits that do not show the thread give way to all commits, whose diff holds the file of every
|
|
1362
|
+
* thread with a position at the head: commits that do not hold its lines, and commits whose changes lack its file or
|
|
1363
|
+
* are still being read, when the thread list shows the places of the changes read before. A thread on a file that
|
|
1364
|
+
* all commits lack opens on the host, at once when they are loaded and else once they are.
|
|
1106
1365
|
*/
|
|
1107
|
-
const openThread = ({ thread, place }: PlacedThread, focusCard: boolean): void => {
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1366
|
+
const openThread = ({ thread, place }: PlacedThread, focusCard: boolean, written = false): void => {
|
|
1367
|
+
const original = written && place.kind === 'outdated' && !place.lost && entry?.snapshot?.baseSha !== undefined ? thread.original : null
|
|
1368
|
+
// No file is held while other changes are read.
|
|
1369
|
+
const held = allFiles.some(file => file.path === thread.path)
|
|
1370
|
+
const url = thread.comments[0]?.url ?? null
|
|
1371
|
+
if (original !== null) actions.committed(tab.id, { upTo: original.commit })
|
|
1372
|
+
else if (place.kind === 'elsewhere' || (!held && changeCommits !== null)) actions.committed(tab.id, null)
|
|
1373
|
+
else if (!held && data !== null) {
|
|
1111
1374
|
if (url !== null) openLink(url)
|
|
1112
1375
|
return
|
|
1113
1376
|
}
|
|
1114
1377
|
setFocus(value => ({ id: thread.id, revision: (value?.revision ?? 0) + 1 }))
|
|
1115
1378
|
setRevealed(value => new Set([...value, thread.path]))
|
|
1116
|
-
jump(thread.path, { id: thread.id, focus: focusCard })
|
|
1379
|
+
jump(thread.path, { id: thread.id, focus: focusCard, url })
|
|
1117
1380
|
}
|
|
1118
1381
|
const jump = (path: string, center: Wanted['center'] = null): void => {
|
|
1119
1382
|
setTreeState(value => ({ ...value, selected: path }))
|
|
@@ -1140,8 +1403,9 @@ export function ChangesView({
|
|
|
1140
1403
|
/** Whether a key press belongs to a field, a comment, a menu, or a text selection rather than to the file list. */
|
|
1141
1404
|
const typing = (container: HTMLElement, origin: EventTarget): boolean => {
|
|
1142
1405
|
const selection = window.getSelection()
|
|
1143
|
-
|
|
1144
|
-
|
|
1406
|
+
// A target other than an element has no `closest`, so it counts as typing.
|
|
1407
|
+
return !container.contains(origin as Node)
|
|
1408
|
+
|| (origin as Partial<Element>).closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"]), [data-forge-comment], [role="menu"]') !== null
|
|
1145
1409
|
|| (selection !== null && !selection.isCollapsed)
|
|
1146
1410
|
}
|
|
1147
1411
|
const navigateFiles = (event: KeyboardEvent<HTMLDivElement>): void => {
|
|
@@ -1175,8 +1439,10 @@ export function ChangesView({
|
|
|
1175
1439
|
}
|
|
1176
1440
|
/** The shown file whose section holds an element or a text node, if any. */
|
|
1177
1441
|
const fileAt = (target: EventTarget | null | undefined): ForgeDiffFile | undefined => {
|
|
1178
|
-
|
|
1179
|
-
const
|
|
1442
|
+
// A text node has no `closest`, so its parent element answers.
|
|
1443
|
+
const node = target as Partial<Element> | null | undefined
|
|
1444
|
+
const section = node?.closest?.('[data-forge-diff-file]') ?? node?.parentElement?.closest('[data-forge-diff-file]')
|
|
1445
|
+
const path = section?.getAttribute('data-forge-diff-file')
|
|
1180
1446
|
return files.find(file => file.path === path)
|
|
1181
1447
|
}
|
|
1182
1448
|
// `V` marks or clears the file being read, from anywhere in the tab except fields, comments, and menus: the file
|
|
@@ -1198,7 +1464,7 @@ export function ChangesView({
|
|
|
1198
1464
|
// props and state, which the retried render assigns again.
|
|
1199
1465
|
const callbacks = {
|
|
1200
1466
|
data, expandedByDefault, expand, readContext, markViewed, fileActions, publishReview, writeReview, addPending, report, nextThread,
|
|
1201
|
-
lensTitle, renderSlot, kept, reportRemoved, t,
|
|
1467
|
+
lensTitle, renderSlot, kept, reportRemoved, t, write: writes.write,
|
|
1202
1468
|
}
|
|
1203
1469
|
const live = useRef(callbacks)
|
|
1204
1470
|
live.current = callbacks
|
|
@@ -1223,6 +1489,7 @@ export function ChangesView({
|
|
|
1223
1489
|
/* v8 ignore next -- sections render only while changes are loaded */
|
|
1224
1490
|
if (owner !== null) mark(owner, file, viewed)
|
|
1225
1491
|
},
|
|
1492
|
+
write: (file, kind) => { live.current.write(kind, [file]) },
|
|
1226
1493
|
actions: (file) => {
|
|
1227
1494
|
const { data: owner, fileActions: list } = live.current
|
|
1228
1495
|
/* v8 ignore next -- sections render only while changes are loaded */
|
|
@@ -1288,7 +1555,7 @@ export function ChangesView({
|
|
|
1288
1555
|
{retry && <Button size="sm" variant="outline" onClick={refresh}>{t('retry')}</Button>}
|
|
1289
1556
|
{automaticBase}
|
|
1290
1557
|
{changeUrl !== null && (
|
|
1291
|
-
<Button size="sm" variant="outline" onClick={
|
|
1558
|
+
<Button size="sm" variant="outline" onClick={openChangeInBrowser}>{t('diff.viewInBrowser')}</Button>
|
|
1292
1559
|
)}
|
|
1293
1560
|
</div>
|
|
1294
1561
|
)}
|
|
@@ -1301,13 +1568,14 @@ export function ChangesView({
|
|
|
1301
1568
|
body = <div className={css.files}>{orphanRecords}<div className={css.centered}>{t('lens.empty')}</div></div>
|
|
1302
1569
|
} else {
|
|
1303
1570
|
body = (
|
|
1304
|
-
<div ref={attachScrollport} className={css.files} data-forge-changes-scroll="" role="region"
|
|
1571
|
+
<div ref={attachScrollport} className={css.files} style={countColumn} data-forge-changes-scroll="" role="region"
|
|
1305
1572
|
aria-label={t('diff.allFiles', { count: files.length })} aria-keyshortcuts="ArrowLeft ArrowRight V" tabIndex={0}
|
|
1306
1573
|
onKeyDown={navigateFiles} onScroll={(event) => {
|
|
1307
1574
|
if (jumpPosition.current?.top !== event.currentTarget.scrollTop) jumpPosition.current = null
|
|
1308
1575
|
}}>
|
|
1309
1576
|
{files.map((file) => {
|
|
1310
1577
|
const path = file.path
|
|
1578
|
+
const badge = badgeOf(file, data, t)
|
|
1311
1579
|
return (
|
|
1312
1580
|
<DiffFile
|
|
1313
1581
|
key={path}
|
|
@@ -1321,7 +1589,8 @@ export function ChangesView({
|
|
|
1321
1589
|
open={current.open[path] ?? NO_GAPS}
|
|
1322
1590
|
split={split}
|
|
1323
1591
|
wrap={wrap}
|
|
1324
|
-
badge={
|
|
1592
|
+
badge={badge.text}
|
|
1593
|
+
badgeLetter={badge.letter}
|
|
1325
1594
|
tooltip={pathTooltipOf(file, t)}
|
|
1326
1595
|
threads={fileThreads.get(path)}
|
|
1327
1596
|
annotations={annotations.get(path)}
|
|
@@ -1332,6 +1601,8 @@ export function ChangesView({
|
|
|
1332
1601
|
viewedNote={host === null ? t('viewed.hint') : host.unavailable ? t('viewed.unavailable')
|
|
1333
1602
|
: host.saving(path) ? t('viewed.saving') : t('viewed.hintHost')}
|
|
1334
1603
|
viewedDisabled={host !== null && (host.unavailable || host.saving(path))}
|
|
1604
|
+
writes={writeSide}
|
|
1605
|
+
writing={writes.writing}
|
|
1335
1606
|
handlers={handlers}
|
|
1336
1607
|
t={t}
|
|
1337
1608
|
/>
|
|
@@ -1354,7 +1625,27 @@ export function ChangesView({
|
|
|
1354
1625
|
const toggleExpansion = (): void => { setChosen(Object.fromEntries(files.map(file => [file.path, !anyExpanded]))) }
|
|
1355
1626
|
const toggleSplit = (): void => { actions.toggledSplit(tab.id) }
|
|
1356
1627
|
const toggleWrap = (): void => { actions.toggledWrap(tab.id) }
|
|
1357
|
-
const toggleTests = (): void => { actions.toggledTests(tab.id) }
|
|
1628
|
+
const toggleTests = useCallback((): void => { actions.toggledTests(tab.id) }, [actions, tab.id])
|
|
1629
|
+
const chooseScope = useCallback((next: ForgeLocalScope['kind']): void => { actions.scoped(tab.id, next) }, [actions, tab.id])
|
|
1630
|
+
const dropUncertainReview = useCallback((): void => {
|
|
1631
|
+
queue.finish(false)
|
|
1632
|
+
setReviewError(null)
|
|
1633
|
+
}, [queue])
|
|
1634
|
+
const retryLens = useCallback((): void => { setLensAttempt(value => value + 1) }, [])
|
|
1635
|
+
const clearLens = useCallback((): void => { chooseLens(null) }, [chooseLens])
|
|
1636
|
+
const chooseThreadFilter = useCallback((filter: ThreadFilter): void => {
|
|
1637
|
+
setThreadList(value => ({ ...value, filter }))
|
|
1638
|
+
}, [])
|
|
1639
|
+
const claimThreadList = useCallback((): void => { setThreadList(value => ({ ...value, claim: false })) }, [])
|
|
1640
|
+
const openListedThread = useCallback((entry: PlacedThread, covering: boolean): void => {
|
|
1641
|
+
// A list that covers the files closes and hands the focus to the thread it opens, which it would cover.
|
|
1642
|
+
if (covering) setThreadList(value => ({ ...value, open: false }))
|
|
1643
|
+
openThread(entry, covering, true)
|
|
1644
|
+
}, [openThread])
|
|
1645
|
+
const chooseCommit = useCallback((next: ForgeCommitRange | null): void => { actions.committed(tab.id, next) }, [actions, tab.id])
|
|
1646
|
+
const chooseLocalHead = useCallback((next: ChangesHead | null): void => { actions.headed(tab.id, next) }, [actions, tab.id])
|
|
1647
|
+
const chooseBase = useCallback((next: ForgeBaseBranch | null): void => { actions.based(tab.id, next) }, [actions, tab.id])
|
|
1648
|
+
const openReview = useCallback((): void => { setReviewOpen(true) }, [])
|
|
1358
1649
|
const treeAction = t(treePosition === 'left' ? 'diff.moveFileTreeRight' : treePosition === 'right' ? 'diff.hideFileTree' : 'diff.showFileTreeLeft')
|
|
1359
1650
|
let additions = 0
|
|
1360
1651
|
let deletions = 0
|
|
@@ -1365,33 +1656,51 @@ export function ChangesView({
|
|
|
1365
1656
|
const viewedCount = files.filter(file => viewedStateOf(marks, file.path, file.digest) === 'viewed').length
|
|
1366
1657
|
const treeShown = allFiles.length > 0 && treePosition !== 'hidden'
|
|
1367
1658
|
const lensProps = { lens, counts: lensCounts, hideTests, choose: (next: ChangesLens) => { actions.lensed(tab.id, next) }, t }
|
|
1368
|
-
const
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1659
|
+
const localSource = source.kind === 'local'
|
|
1660
|
+
const commitList = localSource ? listLocalCommits : listChangeCommits
|
|
1661
|
+
const commitKept = localSource ? 'newest' : 'oldest'
|
|
1662
|
+
const commitMenu = localSource && scope !== 'branch' ? null : (
|
|
1663
|
+
// The narrowest header leaves out a picker that shows every commit; chosen commits stay, to say what the files are of.
|
|
1664
|
+
<span className={clsx(css.commitSlot, chosenCommits === null && css.foldCommits)}>
|
|
1665
|
+
<CommitMenu chosen={chosenCommits} visible={tab.visible}
|
|
1666
|
+
list={commitList} kept={commitKept} version={commitsVersion}
|
|
1667
|
+
choose={chooseCommit} t={t} />
|
|
1668
|
+
</span>
|
|
1669
|
+
)
|
|
1670
|
+
const baseLabel = data?.kind === 'local' ? data.base : null
|
|
1671
|
+
const bulk = writeSide === undefined ? null : {
|
|
1672
|
+
label: t(writeSide === 'unstaged' ? 'diff.stageAll' : 'diff.unstageAll'),
|
|
1673
|
+
disabled: writes.writing || files.length === 0,
|
|
1674
|
+
run: () => { writes.write(writeSide === 'unstaged' ? 'stage' : 'unstage', files) },
|
|
1675
|
+
}
|
|
1372
1676
|
const toolbarStyle: CSSProperties & { '--forge-tree-width': string } = { '--forge-tree-width': `${treeWidth}px` }
|
|
1373
1677
|
return (
|
|
1374
1678
|
<div className={css.root} data-forge-changes={source.kind} onKeyDown={toggleViewed}>
|
|
1375
1679
|
{source.kind === 'local'
|
|
1376
|
-
? <LocalHeader state={state} scope={scope}
|
|
1377
|
-
|
|
1680
|
+
? <LocalHeader state={state} scope={scope} head={localHead} headMissing={headMissing} base={base}
|
|
1681
|
+
baseLabel={baseLabel} missing={failed === 'forgePanel/base-missing'} visible={tab.visible}
|
|
1682
|
+
diffBases={diffBases} chooseHead={chooseLocalHead}
|
|
1683
|
+
choose={chooseBase} commitMenu={commitMenu}
|
|
1684
|
+
bulk={bulk}
|
|
1378
1685
|
createChangeRequest={createChangeRequest} t={t} />
|
|
1379
|
-
: <ChangeHeader url={source.url} entry={entry} openLink={openLink} commitMenu={commitMenu}
|
|
1686
|
+
: <ChangeHeader url={source.url} entry={entry} status={status} openLink={openLink} commitMenu={commitMenu}
|
|
1380
1687
|
reviewCount={(pendingReview?.comments ?? 0) + reviewState.comments.length}
|
|
1381
|
-
reviewDisabled={
|
|
1688
|
+
reviewDisabled={reviewHead === null} onReview={openReview} t={t} />}
|
|
1382
1689
|
{!reviewOpen && reviewState.error !== null && <Notice>{t(reviewState.error === 'load' ? 'review.loadFailed' : 'review.saveFailed')}</Notice>}
|
|
1383
1690
|
{!reviewOpen && reviewState.uncertain !== null && !reviewBusy && source.kind === 'change' && <div className={css.reviewNotice} role="alert">
|
|
1384
1691
|
<span>{t('review.unknown')}</span>
|
|
1385
1692
|
{reviewState.uncertain.kind === 'comment' && <blockquote>{reviewState.uncertain.comment.body}</blockquote>}
|
|
1386
|
-
<Button size="sm" variant="outline" onClick={
|
|
1387
|
-
<Button size="sm" variant="outline" onClick={
|
|
1693
|
+
<Button size="sm" variant="outline" onClick={recheckReview}>{t('review.recheck')}</Button>
|
|
1694
|
+
<Button size="sm" variant="outline" onClick={dropUncertainReview}>{t('review.confirmRetry')}</Button>
|
|
1388
1695
|
</div>}
|
|
1389
1696
|
{!reviewOpen && reviewError !== null && reviewState.uncertain === null && <Notice>{reviewError}</Notice>}
|
|
1390
1697
|
<div className={css.toolbar} data-tree={treeShown ? treePosition : 'hidden'} style={toolbarStyle}>
|
|
1391
1698
|
{/* Above the file tree, the lens spans the tree's width; elsewhere a menu in the toolbar takes its place. */}
|
|
1392
1699
|
{treeShown && <div className={css.lensCell}><LensControl {...lensProps} need={setLensWidth} /></div>}
|
|
1393
1700
|
<div ref={toolbarRow} className={css.toolbarMain}>
|
|
1394
|
-
{
|
|
1701
|
+
{/* A branch that no worktree has checked out has neither a working tree nor an index, so it has the `branch` scope alone. */}
|
|
1702
|
+
{tab.visible && source.kind === 'local' && (localHead === null || localHead.worktree !== null)
|
|
1703
|
+
&& <ScopeMenu scope={scope} choose={chooseScope} t={t} />}
|
|
1395
1704
|
{tab.visible && (
|
|
1396
1705
|
<span className={css.filesSlot}><ChangedFilesMenu {...navigator} loading={data === null && failed === null} visible /></span>
|
|
1397
1706
|
)}
|
|
@@ -1478,8 +1787,8 @@ export function ChangesView({
|
|
|
1478
1787
|
<Notice action={<span className={css.noticeAction}>
|
|
1479
1788
|
{lensRun.run.code === 'forgePanel/lens-stale'
|
|
1480
1789
|
? <Button size="sm" variant="outline" onClick={refresh}>{t('diff.refresh')}</Button>
|
|
1481
|
-
: <Button size="sm" variant="outline" onClick={
|
|
1482
|
-
<Button size="sm" variant="outline" onClick={
|
|
1790
|
+
: <Button size="sm" variant="outline" onClick={retryLens}>{t('retry')}</Button>}
|
|
1791
|
+
<Button size="sm" variant="outline" onClick={clearLens}>{t('filterLens.clear')}</Button>
|
|
1483
1792
|
</span>}>
|
|
1484
1793
|
{lensRun.run.code === 'forgePanel/lens-stale' ? t('filterLens.stale', { lens: chosenChoice.title })
|
|
1485
1794
|
: lensRun.run.code === 'forgePanel/lens-interrupted' ? t('filterLens.interrupted', { lens: chosenChoice.title })
|
|
@@ -1502,18 +1811,25 @@ export function ChangesView({
|
|
|
1502
1811
|
{allFiles.length > 0 && (
|
|
1503
1812
|
<FileTreePane {...navigator} id={treeId} position={treePosition} least={lensWidth} onWidth={setTreeWidth} />
|
|
1504
1813
|
)}
|
|
1505
|
-
{review !== null &&
|
|
1506
|
-
<ThreadList entries={placed.entries} files={
|
|
1507
|
-
filter={threadList.filter} choose={
|
|
1508
|
-
claim={threadList.claim} claimed={
|
|
1509
|
-
open={
|
|
1510
|
-
|
|
1511
|
-
if (covering) setThreadList(value => ({ ...value, open: false }))
|
|
1512
|
-
openThread(entry, covering)
|
|
1513
|
-
}}
|
|
1514
|
-
openLink={openLink} close={closeThreadList} t={t} />
|
|
1814
|
+
{review !== null && threadsOn?.kind === 'change' && threadList.open && (
|
|
1815
|
+
<ThreadList entries={placed.entries} files={threadFiles} truncated={review.truncated} url={threadsOn.url}
|
|
1816
|
+
filter={threadList.filter} choose={chooseThreadFilter}
|
|
1817
|
+
claim={threadList.claim} claimed={claimThreadList}
|
|
1818
|
+
open={openListedThread}
|
|
1819
|
+
openLink={openLink} forge={family} close={closeThreadList} t={t} />
|
|
1515
1820
|
)}
|
|
1516
1821
|
</div>
|
|
1822
|
+
{writes.restoring !== null && (
|
|
1823
|
+
<Modal open tone="warning" title={t('diff.restore.title')} closeLabel={t('review.close')} onClose={writes.restoring.cancel}
|
|
1824
|
+
footer={(
|
|
1825
|
+
<>
|
|
1826
|
+
<Button variant="outline" data-modal-autofocus onClick={writes.restoring.cancel}>{t('review.cancel')}</Button>
|
|
1827
|
+
<Button variant="primary" onClick={writes.restoring.confirm}>{t('diff.restore.confirm')}</Button>
|
|
1828
|
+
</>
|
|
1829
|
+
)}>
|
|
1830
|
+
<p className={css.restoreText}>{t(restoreCopyOf(writes.restoring.file), { path: writes.restoring.file.path })}</p>
|
|
1831
|
+
</Modal>
|
|
1832
|
+
)}
|
|
1517
1833
|
</div>
|
|
1518
1834
|
)
|
|
1519
1835
|
}
|