@deepseek-ai/dsh-experimental-client-ui-forge 0.2.2-rc.5 → 0.2.3-alpha.2
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 +12 -12
- package/README.md +47 -30
- package/README.zh.md +47 -30
- package/lib/client.js +18 -8
- package/lib/client.js.map +1 -1
- package/lib/index.js +2444 -406
- package/lib/typert.host.js +3433 -950
- package/lib/typert.remote-client.d.ts +89 -14
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +3155 -978
- package/lib/types/branch-name.d.ts +30 -0
- package/lib/types/branch-name.d.ts.map +1 -0
- package/lib/types/branch-name.js.map +1 -0
- package/lib/types/client/AttentionIndicator.d.ts +22 -0
- package/lib/types/client/AttentionIndicator.d.ts.map +1 -0
- package/lib/types/client/AttentionIndicator.js.map +1 -0
- package/lib/types/client/BaseMenu.d.ts.map +1 -1
- package/lib/types/client/BaseMenu.js.map +1 -1
- package/lib/types/client/ChangeRequestCard.d.ts +87 -9
- 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 +126 -10
- 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 +76 -0
- package/lib/types/client/ChangeRequestsSection.d.ts.map +1 -0
- package/lib/types/client/ChangeRequestsSection.js.map +1 -0
- package/lib/types/client/ChangedFiles.d.ts +6 -2
- 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 +14 -0
- package/lib/types/client/ChangesLoading.d.ts.map +1 -0
- package/lib/types/client/ChangesLoading.js.map +1 -0
- package/lib/types/client/ChangesTab.d.ts +62 -14
- package/lib/types/client/ChangesTab.d.ts.map +1 -1
- package/lib/types/client/ChangesTab.js.map +1 -1
- package/lib/types/client/ChangesTabTitle.js.map +1 -1
- package/lib/types/client/DiffFile.d.ts +23 -4
- 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 +79 -0
- package/lib/types/client/EnvironmentRows.d.ts.map +1 -0
- package/lib/types/client/EnvironmentRows.js.map +1 -0
- package/lib/types/client/FileTreePane.d.ts +5 -2
- package/lib/types/client/FileTreePane.d.ts.map +1 -1
- package/lib/types/client/FileTreePane.js.map +1 -1
- package/lib/types/client/LensFilter.d.ts +50 -0
- package/lib/types/client/LensFilter.d.ts.map +1 -0
- package/lib/types/client/LensFilter.js.map +1 -0
- package/lib/types/client/ReasonButton.d.ts +15 -0
- package/lib/types/client/ReasonButton.d.ts.map +1 -0
- package/lib/types/client/ReasonButton.js.map +1 -0
- package/lib/types/client/ReviewComposer.d.ts +11 -4
- 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 +18 -7
- 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 +3 -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 +32 -2
- package/lib/types/client/ReviewThreads.d.ts.map +1 -1
- package/lib/types/client/ReviewThreads.js.map +1 -1
- package/lib/types/client/SessionHoverForge.d.ts.map +1 -1
- package/lib/types/client/SessionHoverForge.js.map +1 -1
- package/lib/types/client/SubmitReview.d.ts +4 -4
- package/lib/types/client/SubmitReview.d.ts.map +1 -1
- package/lib/types/client/SubmitReview.js.map +1 -1
- package/lib/types/client/ThreadList.js.map +1 -1
- package/lib/types/client/ViewOptionsMenu.d.ts +7 -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 +38 -0
- package/lib/types/client/WorktreeNameDialog.d.ts.map +1 -0
- package/lib/types/client/WorktreeNameDialog.js.map +1 -0
- package/lib/types/client/WorktreeProgress.d.ts +14 -3
- package/lib/types/client/WorktreeProgress.d.ts.map +1 -1
- package/lib/types/client/WorktreeProgress.js.map +1 -1
- package/lib/types/client/WorktreeToggle.d.ts +22 -15
- package/lib/types/client/WorktreeToggle.d.ts.map +1 -1
- package/lib/types/client/WorktreeToggle.js.map +1 -1
- package/lib/types/client/action-notices.d.ts +25 -0
- package/lib/types/client/action-notices.d.ts.map +1 -0
- package/lib/types/client/action-notices.js.map +1 -0
- package/lib/types/client/annotations.d.ts +41 -0
- package/lib/types/client/annotations.d.ts.map +1 -0
- package/lib/types/client/annotations.js.map +1 -0
- package/lib/types/client/branch-search.d.ts +38 -0
- package/lib/types/client/branch-search.d.ts.map +1 -0
- package/lib/types/client/branch-search.js.map +1 -0
- package/lib/types/client/change-requests-store.d.ts +25 -0
- package/lib/types/client/change-requests-store.d.ts.map +1 -0
- package/lib/types/client/change-requests-store.js.map +1 -0
- package/lib/types/client/changes-address.d.ts +3 -1
- package/lib/types/client/changes-address.d.ts.map +1 -1
- package/lib/types/client/changes-address.js.map +1 -1
- package/lib/types/client/changes-service.d.ts +119 -0
- package/lib/types/client/changes-service.d.ts.map +1 -0
- package/lib/types/client/changes-service.js.map +1 -0
- package/lib/types/client/changes-store.d.ts +6 -2
- package/lib/types/client/changes-store.d.ts.map +1 -1
- package/lib/types/client/changes-store.js.map +1 -1
- package/lib/types/client/checkout.d.ts.map +1 -1
- package/lib/types/client/checkout.js.map +1 -1
- package/lib/types/client/diff-rows.d.ts +49 -7
- package/lib/types/client/diff-rows.d.ts.map +1 -1
- package/lib/types/client/diff-rows.js.map +1 -1
- package/lib/types/client/file-tree.d.ts +7 -0
- package/lib/types/client/file-tree.d.ts.map +1 -1
- package/lib/types/client/file-tree.js.map +1 -1
- package/lib/types/client/forge-copy.d.ts +29 -0
- package/lib/types/client/forge-copy.d.ts.map +1 -0
- package/lib/types/client/forge-copy.js.map +1 -0
- package/lib/types/client/format.d.ts +8 -0
- 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 +3 -3
- 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 +73 -0
- package/lib/types/client/highlight-context.d.ts.map +1 -0
- package/lib/types/client/highlight-context.js.map +1 -0
- package/lib/types/client/index.d.ts +9 -5
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js.map +1 -1
- package/lib/types/client/lens-filter.d.ts +69 -0
- package/lib/types/client/lens-filter.d.ts.map +1 -0
- package/lib/types/client/lens-filter.js.map +1 -0
- package/lib/types/client/locales.d.ts +188 -36
- package/lib/types/client/locales.d.ts.map +1 -1
- package/lib/types/client/locales.js.map +1 -1
- package/lib/types/client/mount.d.ts +0 -4
- 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/ReviewChat.d.ts +112 -0
- package/lib/types/client/review-page/ReviewChat.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewChat.js.map +1 -0
- package/lib/types/client/review-page/ReviewDetail.d.ts +56 -0
- package/lib/types/client/review-page/ReviewDetail.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewDetail.js.map +1 -0
- package/lib/types/client/review-page/ReviewLabels.d.ts +32 -0
- package/lib/types/client/review-page/ReviewLabels.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewLabels.js.map +1 -0
- package/lib/types/client/review-page/ReviewList.d.ts +68 -0
- package/lib/types/client/review-page/ReviewList.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewList.js.map +1 -0
- package/lib/types/client/review-page/ReviewNav.d.ts +28 -0
- package/lib/types/client/review-page/ReviewNav.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewNav.js.map +1 -0
- package/lib/types/client/review-page/ReviewPage.d.ts +61 -0
- package/lib/types/client/review-page/ReviewPage.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewPage.js.map +1 -0
- package/lib/types/client/review-page/ReviewStatus.d.ts +37 -0
- package/lib/types/client/review-page/ReviewStatus.d.ts.map +1 -0
- package/lib/types/client/review-page/ReviewStatus.js.map +1 -0
- package/lib/types/client/review-page/host-stream.d.ts +24 -0
- package/lib/types/client/review-page/host-stream.d.ts.map +1 -0
- package/lib/types/client/review-page/host-stream.js.map +1 -0
- package/lib/types/client/review-page/review-lists.d.ts +116 -0
- package/lib/types/client/review-page/review-lists.d.ts.map +1 -0
- package/lib/types/client/review-page/review-lists.js.map +1 -0
- package/lib/types/client/review-page/review-mount.d.ts +50 -0
- package/lib/types/client/review-page/review-mount.d.ts.map +1 -0
- package/lib/types/client/review-page/review-mount.js.map +1 -0
- package/lib/types/client/review-page/review-store.d.ts +79 -0
- package/lib/types/client/review-page/review-store.d.ts.map +1 -0
- package/lib/types/client/review-page/review-store.js.map +1 -0
- package/lib/types/client/review-queue.d.ts +19 -0
- 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 +0 -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 +18 -0
- package/lib/types/client/review.d.ts.map +1 -1
- package/lib/types/client/review.js.map +1 -1
- package/lib/types/client/slots.d.ts +114 -0
- package/lib/types/client/slots.d.ts.map +1 -0
- package/lib/types/client/slots.js.map +1 -0
- package/lib/types/client/source.d.ts +29 -23
- package/lib/types/client/source.d.ts.map +1 -1
- package/lib/types/client/source.js.map +1 -1
- package/lib/types/client/status.d.ts +13 -2
- package/lib/types/client/status.d.ts.map +1 -1
- package/lib/types/client/status.js.map +1 -1
- package/lib/types/git.d.ts +4 -15
- package/lib/types/git.d.ts.map +1 -1
- package/lib/types/git.js.map +1 -1
- package/lib/types/index.d.ts +346 -28
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/lens-version.d.ts +14 -0
- package/lib/types/lens-version.d.ts.map +1 -0
- package/lib/types/lens-version.js.map +1 -0
- package/lib/types/lenses.d.ts +122 -0
- package/lib/types/lenses.d.ts.map +1 -0
- package/lib/types/lenses.js.map +1 -0
- package/lib/types/local-diff.d.ts +16 -0
- package/lib/types/local-diff.d.ts.map +1 -1
- package/lib/types/local-diff.js.map +1 -1
- package/lib/types/panel.d.ts +59 -8
- package/lib/types/panel.d.ts.map +1 -1
- package/lib/types/panel.js.map +1 -1
- package/lib/types/parse.d.ts +24 -8
- package/lib/types/parse.d.ts.map +1 -1
- package/lib/types/parse.js.map +1 -1
- package/lib/types/review-cache.d.ts +29 -19
- package/lib/types/review-cache.d.ts.map +1 -1
- package/lib/types/review-cache.js.map +1 -1
- package/lib/types/states.d.ts +11 -7
- package/lib/types/states.d.ts.map +1 -1
- package/lib/types/states.js.map +1 -1
- package/lib/types/types.d.ts +266 -20
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/viewer-lists.d.ts +113 -0
- package/lib/types/viewer-lists.d.ts.map +1 -0
- package/lib/types/viewer-lists.js.map +1 -0
- package/lib/types/worktree.d.ts +20 -11
- package/lib/types/worktree.d.ts.map +1 -1
- package/lib/types/worktree.js.map +1 -1
- package/locale/de.json +1 -1
- package/locale/en.json +1 -1
- package/locale/es.json +1 -1
- package/locale/fr.json +1 -1
- package/locale/ja.json +1 -1
- package/locale/pt.json +1 -1
- package/locale/ru.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +61 -52
- package/src/branch-name.ts +74 -0
- package/src/client/AttentionIndicator.tsx +37 -0
- package/src/client/BaseMenu.module.css +0 -20
- package/src/client/BaseMenu.tsx +9 -52
- package/src/client/ChangeRequestCard.tsx +276 -131
- package/src/client/ChangeRequestOverview.module.css +1 -1
- package/src/client/ChangeRequestOverview.tsx +183 -67
- package/src/client/ChangeRequestsSection.tsx +234 -0
- package/src/client/ChangedFiles.module.css +5 -1
- package/src/client/ChangedFiles.tsx +72 -36
- package/src/client/ChangesLoading.module.css +110 -0
- package/src/client/ChangesLoading.tsx +69 -0
- package/src/client/ChangesTab.module.css +83 -114
- package/src/client/ChangesTab.tsx +331 -100
- package/src/client/ChangesTabTitle.tsx +3 -3
- package/src/client/DiffFile.tsx +241 -45
- package/src/client/EnvironmentRows.tsx +263 -0
- package/src/client/FileLabel.tsx +1 -1
- package/src/client/FileTreePane.tsx +11 -6
- package/src/client/{ForgeTab.module.css → Forge.module.css} +130 -275
- package/src/client/LensFilter.module.css +87 -0
- package/src/client/LensFilter.tsx +105 -0
- package/src/client/ReasonButton.tsx +23 -0
- package/src/client/ReviewComposer.module.css +2 -8
- package/src/client/ReviewComposer.tsx +27 -8
- package/src/client/ReviewControls.module.css +39 -0
- package/src/client/ReviewControls.tsx +71 -15
- package/src/client/ReviewThread.tsx +55 -30
- package/src/client/ReviewThreads.module.css +24 -0
- package/src/client/ReviewThreads.tsx +56 -21
- package/src/client/SessionHoverForge.tsx +2 -1
- package/src/client/SubmitReview.tsx +11 -8
- package/src/client/ThreadList.tsx +1 -1
- package/src/client/ViewOptionsMenu.tsx +19 -4
- package/src/client/WorktreeNameDialog.module.css +53 -0
- package/src/client/WorktreeNameDialog.tsx +93 -0
- package/src/client/WorktreeProgress.tsx +100 -35
- package/src/client/WorktreeToggle.module.css +121 -5
- package/src/client/WorktreeToggle.tsx +178 -61
- package/src/client/action-notices.ts +38 -0
- package/src/client/annotations.ts +105 -0
- package/src/client/branch-search.tsx +77 -0
- package/src/client/change-requests-store.ts +50 -0
- package/src/client/changes-address.ts +3 -1
- package/src/client/changes-service.ts +173 -0
- package/src/client/changes-store.ts +103 -91
- package/src/client/checkout.ts +2 -1
- package/src/client/diff-rows.ts +100 -16
- package/src/client/file-tree.ts +29 -0
- package/src/client/forge-copy.ts +49 -0
- package/src/client/format.ts +14 -0
- package/src/client/glyphs.tsx +12 -13
- package/src/client/highlight-context.ts +213 -0
- package/src/client/index.ts +20 -5
- package/src/client/lens-filter.ts +136 -0
- package/src/client/locales.ts +1504 -288
- package/src/client/mount.ts +228 -109
- package/src/client/review-page/ReviewChat.tsx +311 -0
- package/src/client/review-page/ReviewDetail.tsx +331 -0
- package/src/client/review-page/ReviewLabels.tsx +94 -0
- package/src/client/review-page/ReviewList.tsx +461 -0
- package/src/client/review-page/ReviewNav.tsx +47 -0
- package/src/client/review-page/ReviewPage.module.css +946 -0
- package/src/client/review-page/ReviewPage.tsx +287 -0
- package/src/client/review-page/ReviewStatus.tsx +259 -0
- package/src/client/review-page/host-stream.ts +63 -0
- package/src/client/review-page/review-lists.ts +207 -0
- package/src/client/review-page/review-mount.ts +228 -0
- package/src/client/review-page/review-store.ts +94 -0
- package/src/client/review-queue.ts +30 -0
- package/src/client/review-threads.ts +0 -12
- package/src/client/review.ts +27 -0
- package/src/client/slots.ts +92 -0
- package/src/client/source.ts +67 -43
- package/src/client/status.ts +16 -4
- package/src/git.ts +16 -38
- package/src/index.ts +900 -152
- package/src/lens-version.ts +27 -0
- package/src/lenses.ts +284 -0
- package/src/local-diff.ts +48 -1
- package/src/panel.ts +123 -28
- package/src/parse.ts +86 -10
- package/src/review-cache.ts +57 -37
- package/src/states.ts +38 -18
- package/src/types.ts +267 -21
- package/src/viewer-lists.ts +375 -0
- package/src/worktree.ts +64 -34
- package/lib/types/client/ForgeTab.d.ts +0 -65
- package/lib/types/client/ForgeTab.d.ts.map +0 -1
- package/lib/types/client/ForgeTab.js.map +0 -1
- package/lib/types/client/ForgeTabTitle.d.ts +0 -11
- package/lib/types/client/ForgeTabTitle.d.ts.map +0 -1
- package/lib/types/client/ForgeTabTitle.js.map +0 -1
- package/lib/types/client/HeaderButton.d.ts +0 -27
- package/lib/types/client/HeaderButton.d.ts.map +0 -1
- package/lib/types/client/HeaderButton.js.map +0 -1
- package/lib/types/client/LocalChangesCard.d.ts +0 -29
- package/lib/types/client/LocalChangesCard.d.ts.map +0 -1
- package/lib/types/client/LocalChangesCard.js.map +0 -1
- package/src/client/ForgeTab.tsx +0 -263
- package/src/client/ForgeTabTitle.tsx +0 -21
- package/src/client/HeaderButton.module.css +0 -29
- package/src/client/HeaderButton.tsx +0 -68
- package/src/client/LocalChangesCard.tsx +0 -83
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/** Chip title of a changes tab: the changes icon and the view's name in the current language. */
|
|
2
2
|
|
|
3
3
|
import type { ReactNode } from 'react'
|
|
4
|
-
import {
|
|
4
|
+
import { IconFilesDiffOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
5
5
|
import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
|
6
6
|
import type {} from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
|
|
7
7
|
import { changesTitle, parseChangesAddress } from './changes-address.ts'
|
|
8
8
|
import type { NS } from './locales.ts'
|
|
9
|
-
import css from './
|
|
9
|
+
import css from './Forge.module.css'
|
|
10
10
|
|
|
11
11
|
/** Props of the changes tab title. */
|
|
12
12
|
export type ChangesTabTitleProps = Pick<PropsRuntime<'sidebar.right.pane.tab.title'>, 'useTabInfo'> & PropsLocale<typeof NS>
|
|
@@ -21,7 +21,7 @@ export function ChangesTabTitle({ useTabInfo, t }: ChangesTabTitleProps): ReactN
|
|
|
21
21
|
const target = parseChangesAddress(tab.contentId)
|
|
22
22
|
return (
|
|
23
23
|
<>
|
|
24
|
-
<span className={css.titleIcon}><
|
|
24
|
+
<span className={css.titleIcon}><IconFilesDiffOutlineRegular size={16} /></span>
|
|
25
25
|
<span className={css.titleText}>{target === undefined ? tab.title : changesTitle(target.source, t)}</span>
|
|
26
26
|
</>
|
|
27
27
|
)
|
package/src/client/DiffFile.tsx
CHANGED
|
@@ -10,18 +10,21 @@ import { memo, useCallback, useEffect, useMemo, useRef, useState, type CSSProper
|
|
|
10
10
|
import clsx from 'clsx'
|
|
11
11
|
import { flushSync } from 'react-dom'
|
|
12
12
|
import {
|
|
13
|
-
FileTypeIcon, IconChevronDownOutlineRegular, IconChevronsUpDownOutlineRegular,
|
|
13
|
+
FileTypeIcon, IconChevronDownOutlineRegular, IconChevronsUpDownOutlineRegular, IconChevronUpOutlineRegular, IconEllipsisOutlineRegular,
|
|
14
|
+
IconPlusOutlineRegular,
|
|
14
15
|
Tag, Tooltip,
|
|
15
16
|
languageForPath, Menu, MenuItemButton, useCodeHighlighter, type CodeHighlighter, type HighlightSpan,
|
|
16
17
|
} from '@deepseek-ai/dsh-client-ui-primitives'
|
|
17
18
|
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
18
19
|
import type { ForgeDiffFile } from '../types.ts'
|
|
19
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
drawnLines, EXPAND_STEP, hidesLine, segmentsOf, splitRows,
|
|
22
|
+
type DiffRow, type DiffSegment, type GapExpansion, type GapReveal, type SplitCell, type SplitRow,
|
|
23
|
+
} from './diff-rows.ts'
|
|
20
24
|
import { codeSideAt, readCodeSelection } from './code-selection.ts'
|
|
21
25
|
import { reviewMatches, selectReviewLines, type ReviewSelection } from './review.ts'
|
|
22
26
|
import { ReviewThread, useFileReview } from './ReviewThread.tsx'
|
|
23
27
|
import { OutdatedThreads, ThreadCard, type FileThreads, type LineThread, type ThreadActions } from './ReviewThreads.tsx'
|
|
24
|
-
import { gapOf } from './review-threads.ts'
|
|
25
28
|
import type { FileReviewState } from './review-queue.ts'
|
|
26
29
|
import { ReviewComposer, type ReviewActions } from './ReviewComposer.tsx'
|
|
27
30
|
import reviewCss from './ReviewComposer.module.css'
|
|
@@ -29,6 +32,8 @@ import { FileLabel } from './FileLabel.tsx'
|
|
|
29
32
|
import type { ForgePanelKey, NS } from './locales.ts'
|
|
30
33
|
import type { ViewedState } from './viewed-files.ts'
|
|
31
34
|
import type { SectionReach } from './section-reach.ts'
|
|
35
|
+
import type { SourcedAnnotation } from './annotations.ts'
|
|
36
|
+
import { oldSideLines, runKey, sideRun, useContextHighlight, type FileSides, type SideRun } from './highlight-context.ts'
|
|
32
37
|
import css from './ChangesTab.module.css'
|
|
33
38
|
|
|
34
39
|
type Translate = PropsLocale<typeof NS>['t']
|
|
@@ -53,8 +58,10 @@ export interface DiffFileHandlers {
|
|
|
53
58
|
readonly toggle: (file: ForgeDiffFile) => void
|
|
54
59
|
/** Show a large file anyway. */
|
|
55
60
|
readonly reveal: (path: string) => void
|
|
56
|
-
/**
|
|
57
|
-
readonly expand: (file: ForgeDiffFile, index: number) => void
|
|
61
|
+
/** Show more of one gap of a file. */
|
|
62
|
+
readonly expand: (file: ForgeDiffFile, index: number, expansion: GapExpansion) => void
|
|
63
|
+
/** Read a file's new side ahead of any expansion, for highlighting rows after its collapsed lines; a source may ignore it. */
|
|
64
|
+
readonly readContext: (file: ForgeDiffFile) => void
|
|
58
65
|
/** Mark a file viewed, which also collapses it, or clear the mark. */
|
|
59
66
|
readonly view: (file: ForgeDiffFile, viewed: boolean) => void
|
|
60
67
|
/** Rows of a file's menu, read whenever the menu draws. */
|
|
@@ -65,6 +72,12 @@ export interface DiffFileHandlers {
|
|
|
65
72
|
readonly nextThread: (path: string) => void
|
|
66
73
|
/** Tells each expanded section when it comes within reach of the scrollport, which draws its lines. */
|
|
67
74
|
readonly reach: SectionReach
|
|
75
|
+
/** Draw the content of one line annotation through its source's `forge.diff.line.annotation` entry. */
|
|
76
|
+
readonly annotation: (path: string, item: SourcedAnnotation) => ReactNode
|
|
77
|
+
/** Draw the plugin rows of a file's menu through `forge.changes.file.menu`. */
|
|
78
|
+
readonly fileMenu: (file: ForgeDiffFile, dismiss: () => void) => ReactNode
|
|
79
|
+
/** Show the hunks the chosen lens folds in a file. */
|
|
80
|
+
readonly unfold: (path: string) => void
|
|
68
81
|
}
|
|
69
82
|
|
|
70
83
|
/** Props of one file section. */
|
|
@@ -83,8 +96,8 @@ export interface DiffFileProps {
|
|
|
83
96
|
readonly revealed: boolean
|
|
84
97
|
/** The file's new side, which supplies collapsed unchanged lines. */
|
|
85
98
|
readonly text: DiffFileText
|
|
86
|
-
/**
|
|
87
|
-
readonly open:
|
|
99
|
+
/** The lines each expanded gap shows, by gap index. */
|
|
100
|
+
readonly open: ReadonlyMap<number, GapReveal>
|
|
88
101
|
/** Whether deletions and additions show in two columns; a file with only additions or only deletions keeps one. */
|
|
89
102
|
readonly split: boolean
|
|
90
103
|
/** Whether long lines wrap. */
|
|
@@ -103,6 +116,12 @@ export interface DiffFileProps {
|
|
|
103
116
|
readonly threads?: FileThreads | undefined
|
|
104
117
|
/** Whether the section draws its lines at once, as the target of a thread jump, whose card must exist to be centered. */
|
|
105
118
|
readonly drawNow?: boolean | undefined
|
|
119
|
+
/** Line annotations of the file in stacking order, or undefined for none; the view keeps their identity. */
|
|
120
|
+
readonly annotations?: readonly SourcedAnnotation[] | undefined
|
|
121
|
+
/** Most annotations the file shows, the rest counted below them, or undefined to show none while the limit is unknown. */
|
|
122
|
+
readonly annotationLimit?: number | undefined
|
|
123
|
+
/** Indexes of the hunks the chosen lens folds with the lens's title, or undefined for none; the view keeps their identity. */
|
|
124
|
+
readonly folded?: { readonly hunks: ReadonlySet<number>; readonly lens: string } | undefined
|
|
106
125
|
/** Actions shared by every section of the view. */
|
|
107
126
|
readonly handlers: DiffFileHandlers
|
|
108
127
|
/** Forge panel copy. */
|
|
@@ -132,23 +151,33 @@ const SIGN: Record<DiffRow['kind'], string> = { add: '+', del: '-', context: ''
|
|
|
132
151
|
/** Highlighted tokens of one side's lines by line number, or undefined while the grammar is unavailable. */
|
|
133
152
|
type SideSpans = ReadonlyMap<number, readonly HighlightSpan[]> | undefined
|
|
134
153
|
|
|
135
|
-
/** A segment ready to draw: collapsed lines, or rows with the tokens of each side. */
|
|
154
|
+
/** A segment ready to draw: collapsed lines, or rows with the tokens of each side and the lines each side numbers. */
|
|
136
155
|
type Prepared =
|
|
137
|
-
| {
|
|
138
|
-
| {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (no !== null) numbered.push({ no, text: row.text })
|
|
156
|
+
| Extract<DiffSegment, { kind: 'gap' | 'folded' }>
|
|
157
|
+
| {
|
|
158
|
+
readonly kind: 'rows'
|
|
159
|
+
readonly rows: readonly DiffRow[]
|
|
160
|
+
readonly old: SideSpans
|
|
161
|
+
readonly new: SideSpans
|
|
162
|
+
readonly oldRun: SideRun | undefined
|
|
163
|
+
readonly newRun: SideRun | undefined
|
|
146
164
|
}
|
|
147
|
-
|
|
148
|
-
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Highlight one side of a run of rows as one fragment, so tokens spanning lines keep their state. The tokens are kept by
|
|
168
|
+
* the change and the run's lines in `kept`, which the caller replaces with the file or the highlighter.
|
|
169
|
+
*/
|
|
170
|
+
function sideSpans(run: SideRun | undefined, change: string, highlighter: CodeHighlighter, kept: Map<string, SideSpans>): SideSpans {
|
|
171
|
+
if (run === undefined) return new Map()
|
|
172
|
+
const key = runKey(change, run)
|
|
173
|
+
const known = kept.get(key)
|
|
174
|
+
if (known !== undefined) return known
|
|
175
|
+
const highlighted = highlighter(run.texts.join('\n'))
|
|
149
176
|
if (highlighted === undefined) return undefined
|
|
150
177
|
// Shiki omits a final empty token row, so a final empty line gets no tokens.
|
|
151
|
-
|
|
178
|
+
const spans = new Map(run.texts.map((_text, index) => [run.first + index, highlighted[index] ?? []]))
|
|
179
|
+
kept.set(key, spans)
|
|
180
|
+
return spans
|
|
152
181
|
}
|
|
153
182
|
|
|
154
183
|
function Code({ text, spans, old, next }: {
|
|
@@ -180,13 +209,66 @@ function rangeKey(item: ReviewSelection): string {
|
|
|
180
209
|
return `${item.comment.side}${item.comment.startLine}-${item.comment.endLine}`
|
|
181
210
|
}
|
|
182
211
|
|
|
212
|
+
/** A file's annotations as it shows them: on lines, on the whole file, written on an earlier change, and how many the limit leaves out. */
|
|
213
|
+
interface FileAnnotations {
|
|
214
|
+
readonly lines: readonly SourcedAnnotation[]
|
|
215
|
+
readonly file: readonly SourcedAnnotation[]
|
|
216
|
+
readonly outdated: readonly SourcedAnnotation[]
|
|
217
|
+
readonly hidden: number
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const NO_ANNOTATIONS: FileAnnotations = { lines: [], file: [], outdated: [], hidden: 0 }
|
|
221
|
+
|
|
222
|
+
/** Group the first `limit` annotations of a file by where they show; none show while the limit is unknown. */
|
|
223
|
+
function groupAnnotations(
|
|
224
|
+
file: ForgeDiffFile, items: readonly SourcedAnnotation[] | undefined, limit: number | undefined,
|
|
225
|
+
): FileAnnotations {
|
|
226
|
+
if (items === undefined || items.length === 0 || limit === undefined) return NO_ANNOTATIONS
|
|
227
|
+
const lines: SourcedAnnotation[] = []
|
|
228
|
+
const whole: SourcedAnnotation[] = []
|
|
229
|
+
const outdated: SourcedAnnotation[] = []
|
|
230
|
+
for (const item of items.slice(0, limit)) {
|
|
231
|
+
const { place, digest } = item.annotation
|
|
232
|
+
if (digest !== undefined && digest !== file.digest) outdated.push(item)
|
|
233
|
+
else if (place === 'file') whole.push(item)
|
|
234
|
+
else lines.push(item)
|
|
235
|
+
}
|
|
236
|
+
return { lines, file: whole, outdated, hidden: Math.max(0, items.length - limit) }
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** Whether a line of one side falls in one of the hunks. */
|
|
240
|
+
function inHunks(file: ForgeDiffFile, hunks: readonly number[], side: 'L' | 'R', line: number): boolean {
|
|
241
|
+
return hunks.some((index) => {
|
|
242
|
+
const hunk = file.hunks[index]
|
|
243
|
+
/* v8 ignore next -- folded indexes name hunks of the file */
|
|
244
|
+
if (hunk === undefined) return false
|
|
245
|
+
const start = side === 'L' ? hunk.oldStart : hunk.newStart
|
|
246
|
+
return line >= start && line < start + (side === 'L' ? hunk.oldLines : hunk.newLines)
|
|
247
|
+
})
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** The saved comments and plugin annotations the lines of a file place. */
|
|
251
|
+
interface LinesNotes {
|
|
252
|
+
readonly comments: FileReviewState
|
|
253
|
+
readonly annotations: readonly SourcedAnnotation[]
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** One annotation's frame, which holds the content its source's slot entry draws. */
|
|
257
|
+
function Annotation({ path, item, handlers }: {
|
|
258
|
+
readonly path: string
|
|
259
|
+
readonly item: SourcedAnnotation
|
|
260
|
+
readonly handlers: DiffFileHandlers
|
|
261
|
+
}): ReactNode {
|
|
262
|
+
return <div className={css.annotation} data-forge-annotation={`${item.source}/${item.annotation.key}`}>{handlers.annotation(path, item)}</div>
|
|
263
|
+
}
|
|
264
|
+
|
|
183
265
|
function pairKind(pair: SplitRow): 'context' | 'change' {
|
|
184
266
|
return pair.left !== null && pair.left.kind === 'context' ? 'context' : 'change'
|
|
185
267
|
}
|
|
186
268
|
|
|
187
269
|
/** The hunks of one file with their collapsed and expanded unchanged lines. */
|
|
188
|
-
function Lines({ file, text, open, handlers, split, wrap, review, visible, comments, threads, t }: Pick<DiffFileProps,
|
|
189
|
-
'file' | 'text' | 'open' | 'handlers' | 'split' | 'wrap' | 'review' | 'visible' | 'threads' | 't'> &
|
|
270
|
+
function Lines({ file, text, open, handlers, split, wrap, review, visible, comments, threads, folded, annotations, t }: Pick<DiffFileProps,
|
|
271
|
+
'file' | 'text' | 'open' | 'handlers' | 'split' | 'wrap' | 'review' | 'visible' | 'threads' | 'folded' | 't'> & LinesNotes): ReactNode {
|
|
190
272
|
const lines = typeof text === 'object' ? text : undefined
|
|
191
273
|
const columns = split && file.additions > 0 && file.deletions > 0
|
|
192
274
|
const singleSide = file.status === 'added' ? 'R' : file.status === 'deleted' ? 'L' : null
|
|
@@ -194,6 +276,7 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
|
|
|
194
276
|
for (const hunk of file.hunks) maximum = Math.max(maximum, hunk.oldStart + hunk.oldLines - 1, hunk.newStart + hunk.newLines - 1)
|
|
195
277
|
const style: CSSProperties & { '--forge-number-width': string } = { '--forge-number-width': `calc(${Math.max(2, String(maximum).length)}ch + 12px)` }
|
|
196
278
|
const highlighter = useCodeHighlighter(languageForPath(file.path))
|
|
279
|
+
const foldLens = folded === undefined ? '' : folded.lens
|
|
197
280
|
const [selection, setSelection] = useState<ReviewSelection | null>(null)
|
|
198
281
|
// Mirrors `selection` for the release of a hover-plus drag, whose listener outlives the render that chose the range.
|
|
199
282
|
const chosen = useRef<ReviewSelection | null>(null)
|
|
@@ -271,9 +354,39 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
|
|
|
271
354
|
window.removeEventListener('pointercancel', finish)
|
|
272
355
|
}
|
|
273
356
|
}, [selecting, nativeSelection])
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
357
|
+
// A hunk that holds an open comment form or a comment saved in this browser stays drawn: folding it would move the form,
|
|
358
|
+
// which loses its text, and show the saved comment as written on lines the diff no longer has.
|
|
359
|
+
const foldHunks = useMemo(() => {
|
|
360
|
+
if (folded === undefined) return undefined
|
|
361
|
+
const holds = (index: number): boolean => editors.some(item => inHunks(file, [index], item.comment.side, item.comment.endLine))
|
|
362
|
+
|| (review !== undefined && comments.threads.some(thread => reviewMatches(thread.selection, review.source, file)
|
|
363
|
+
&& inHunks(file, [index], thread.selection.comment.side, thread.selection.comment.endLine)))
|
|
364
|
+
return new Set([...folded.hunks].filter(index => !holds(index)))
|
|
365
|
+
}, [folded, editors, review, comments.threads, file])
|
|
366
|
+
// Runs whose lines stay the same keep their tokens when the file's text arrives or another gap expands.
|
|
367
|
+
const kept = useMemo(() => new Map<string, SideSpans>(), [file, highlighter])
|
|
368
|
+
const prepared = useMemo(() => segmentsOf(file, lines, open, foldHunks).map((segment): Prepared => {
|
|
369
|
+
if (segment.kind !== 'rows') return segment
|
|
370
|
+
const oldRun = sideRun(segment.rows, 'old')
|
|
371
|
+
const newRun = sideRun(segment.rows, 'new')
|
|
372
|
+
return {
|
|
373
|
+
...segment, oldRun, newRun,
|
|
374
|
+
old: sideSpans(oldRun, file.digest, highlighter, kept), new: sideSpans(newRun, file.digest, highlighter, kept),
|
|
375
|
+
}
|
|
376
|
+
}), [file, lines, open, foldHunks, highlighter, kept])
|
|
377
|
+
// Rows drawn after collapsed lines take the colors of the lines before them once the whole file is known, after they draw.
|
|
378
|
+
const runs = useMemo(() => prepared.flatMap(segment => segment.kind !== 'rows' ? []
|
|
379
|
+
: [segment.oldRun, segment.newRun].filter((run): run is SideRun => run !== undefined)), [prepared])
|
|
380
|
+
const sides = useMemo((): FileSides | undefined => lines === undefined ? undefined
|
|
381
|
+
: { new: lines, old: oldSideLines(lines, file.hunks) }, [lines, file.hunks])
|
|
382
|
+
const corrected = useContextHighlight(runs, sides, file.digest, highlighter, root, selecting)
|
|
383
|
+
const spansOf = (spans: SideSpans, run: SideRun | undefined): SideSpans => run === undefined ? spans
|
|
384
|
+
: corrected.get(runKey(file.digest, run)) ?? spans
|
|
385
|
+
const collapsed = prepared.some(segment => segment.kind === 'gap')
|
|
386
|
+
const grammar = languageForPath(file.path) !== undefined
|
|
387
|
+
useEffect(() => {
|
|
388
|
+
if (text === undefined && collapsed && grammar) handlers.readContext(file)
|
|
389
|
+
}, [text, collapsed, grammar, file, handlers])
|
|
277
390
|
// Returns whether the range was accepted; a range across hunks or outside them keeps the previous selection.
|
|
278
391
|
const choose = (side: 'L' | 'R', line: number, extend: boolean): boolean => {
|
|
279
392
|
/* v8 ignore next -- the line buttons and hover pluses that choose a range draw only with review actions */
|
|
@@ -326,7 +439,7 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
|
|
|
326
439
|
choose(side, line, event.shiftKey)
|
|
327
440
|
}}>{line}</button>
|
|
328
441
|
{plus !== null && (
|
|
329
|
-
<Tooltip label={t('review.addComment')} portal>
|
|
442
|
+
<Tooltip label={t('review.addComment')} portal delayMs={500}>
|
|
330
443
|
<button type="button" className={reviewCss.add} aria-label={t('review.addComment')}
|
|
331
444
|
onPointerDown={(event) => { event.preventDefault() }} onClick={() => { compose(plus) }}>
|
|
332
445
|
<IconPlusOutlineRegular size={14} />
|
|
@@ -366,6 +479,16 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
|
|
|
366
479
|
const unplaced = new Set(threads === undefined ? [] : threads.lines.map(item => ({ ...item, actions: threads.actions })))
|
|
367
480
|
const threadCard = (item: LineThread & { readonly actions: ThreadActions }): ReactNode =>
|
|
368
481
|
<ThreadCard key={`thread-${item.thread.id}`} thread={item.thread} place={item.place} actions={item.actions} t={t} />
|
|
482
|
+
// Plugin annotations follow the host threads on the row of their last line, or the collapsed or folded lines that hold it.
|
|
483
|
+
const unplacedNotes = new Set(annotations)
|
|
484
|
+
const annotationOf = (item: SourcedAnnotation): ReactNode =>
|
|
485
|
+
<Annotation key={`annotation-${item.source}-${item.annotation.key}`} path={file.path} item={item} handlers={handlers} />
|
|
486
|
+
const lastLine = (item: SourcedAnnotation): { readonly side: 'L' | 'R'; readonly line: number } => {
|
|
487
|
+
const place = item.annotation.place
|
|
488
|
+
/* v8 ignore next -- only line annotations reach the lines */
|
|
489
|
+
if (place === 'file') return { side: 'R', line: 0 }
|
|
490
|
+
return { side: place.side, line: place.endLine }
|
|
491
|
+
}
|
|
369
492
|
// The editors, the saved comments, then the host threads whose ranges end on this side's line.
|
|
370
493
|
const commentsAt = (side: 'L' | 'R', line: number | null): ReactNode[] => {
|
|
371
494
|
const nodes: ReactNode[] = []
|
|
@@ -388,6 +511,12 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
|
|
|
388
511
|
nodes.push(threadCard(item))
|
|
389
512
|
unplaced.delete(item)
|
|
390
513
|
}
|
|
514
|
+
for (const item of unplacedNotes) {
|
|
515
|
+
const at = lastLine(item)
|
|
516
|
+
if (at.side !== side || at.line !== line) continue
|
|
517
|
+
nodes.push(annotationOf(item))
|
|
518
|
+
unplacedNotes.delete(item)
|
|
519
|
+
}
|
|
391
520
|
return nodes
|
|
392
521
|
}
|
|
393
522
|
const editorOf = (item: ReviewSelection, actions: ReviewActions): ReactNode =>
|
|
@@ -406,23 +535,72 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
|
|
|
406
535
|
)
|
|
407
536
|
rows.push(<div key={key} className={css.notes} data-forge-notes="">{side(pair.left, left)}{side(pair.right, right)}</div>)
|
|
408
537
|
}
|
|
538
|
+
// A gap of at most one step shows wholly on one click; a longer one shows a step down from the hunk above it or up
|
|
539
|
+
// from the hunk below it. The unknown lines after the last hunk show their first step once read.
|
|
540
|
+
const gapRow = (segment: Extract<DiffSegment, { kind: 'gap' }>): ReactNode => {
|
|
541
|
+
const loading = text === 'loading'
|
|
542
|
+
const label = segment.count === null ? t('diff.unchangedRest') : t('diff.unchanged', { count: segment.count.toLocaleString('en-US') })
|
|
543
|
+
if (segment.count === null || segment.count <= EXPAND_STEP) {
|
|
544
|
+
return <button key={`gap-${segment.index}`} type="button" className={css.gap} disabled={loading}
|
|
545
|
+
data-forge-diff-gap={segment.index} onClick={() => { handlers.expand(file, segment.index, segment.count === null ? 'down' : 'all') }}>
|
|
546
|
+
<IconChevronsUpDownOutlineRegular size={12} />
|
|
547
|
+
{label}
|
|
548
|
+
</button>
|
|
549
|
+
}
|
|
550
|
+
const step = (expansion: 'down' | 'up'): ReactNode => {
|
|
551
|
+
const name = t(expansion === 'down' ? 'diff.expandDown' : 'diff.expandUp', { count: String(EXPAND_STEP) })
|
|
552
|
+
return <Tooltip key={expansion} label={name} side="bottom">
|
|
553
|
+
<button type="button" className={css.gapStep} aria-label={name} disabled={loading} data-forge-gap-step={expansion}
|
|
554
|
+
onClick={() => { handlers.expand(file, segment.index, expansion) }}>
|
|
555
|
+
{expansion === 'down' ? <IconChevronDownOutlineRegular size={12} /> : <IconChevronUpOutlineRegular size={12} />}
|
|
556
|
+
</button>
|
|
557
|
+
</Tooltip>
|
|
558
|
+
}
|
|
559
|
+
return <div key={`gap-${segment.index}`} className={css.gapSteps} role="group" aria-label={label} data-forge-diff-gap={segment.index}>
|
|
560
|
+
{segment.edge !== 'leading' && step('down')}
|
|
561
|
+
{segment.edge !== 'trailing' && step('up')}
|
|
562
|
+
<span>{label}</span>
|
|
563
|
+
</div>
|
|
564
|
+
}
|
|
409
565
|
for (const [at, segment] of prepared.entries()) {
|
|
566
|
+
const oldSpans = segment.kind === 'rows' ? spansOf(segment.old, segment.oldRun) : undefined
|
|
567
|
+
const newSpans = segment.kind === 'rows' ? spansOf(segment.new, segment.newRun) : undefined
|
|
410
568
|
if (segment.kind === 'gap') {
|
|
411
|
-
rows.push(
|
|
412
|
-
|
|
569
|
+
rows.push(gapRow(segment))
|
|
570
|
+
for (const item of unplaced) {
|
|
571
|
+
if (!hidesLine(segment, item.place.side, item.place.endLine)) continue
|
|
572
|
+
rows.push(threadCard(item))
|
|
573
|
+
unplaced.delete(item)
|
|
574
|
+
}
|
|
575
|
+
for (const item of unplacedNotes) {
|
|
576
|
+
const at = lastLine(item)
|
|
577
|
+
if (!hidesLine(segment, at.side, at.line)) continue
|
|
578
|
+
rows.push(annotationOf(item))
|
|
579
|
+
unplacedNotes.delete(item)
|
|
580
|
+
}
|
|
581
|
+
} else if (segment.kind === 'folded') {
|
|
582
|
+
rows.push(<button key={`folded-${segment.hunks.join(',')}`} type="button" className={clsx(css.gap, css.lensFold)}
|
|
583
|
+
data-forge-lens-fold={segment.hunks.join(',')} onClick={() => { handlers.unfold(file.path) }}>
|
|
413
584
|
<IconChevronsUpDownOutlineRegular size={12} />
|
|
414
|
-
{
|
|
585
|
+
<span className={css.lensFoldText}>{t('filterLens.folded', { count: String(segment.hunks.length), lens: foldLens })}</span>
|
|
586
|
+
<span className={css.lensFoldAction}>{t('filterLens.unfold')}</span>
|
|
415
587
|
</button>)
|
|
416
588
|
for (const item of unplaced) {
|
|
417
|
-
if (
|
|
589
|
+
if (!inHunks(file, segment.hunks, item.place.side, item.place.endLine)) continue
|
|
418
590
|
rows.push(threadCard(item))
|
|
419
591
|
unplaced.delete(item)
|
|
420
592
|
}
|
|
593
|
+
for (const item of unplacedNotes) {
|
|
594
|
+
const place = lastLine(item)
|
|
595
|
+
if (!inHunks(file, segment.hunks, place.side, place.line)) continue
|
|
596
|
+
rows.push(annotationOf(item))
|
|
597
|
+
unplacedNotes.delete(item)
|
|
598
|
+
}
|
|
421
599
|
} else if (columns) {
|
|
422
600
|
for (const [index, pair] of splitRows(segment.rows).entries()) {
|
|
423
601
|
rows.push(<div key={`${at}-${index}`} className={css.pair} data-diff-pair={pairKind(pair)}
|
|
424
602
|
onPointerEnter={(event) => { extendAdd(event.buttons, pair.left?.no ?? null, pair.right?.no ?? null) }}>
|
|
425
|
-
{cell(pair.left,
|
|
603
|
+
{cell(pair.left, oldSpans, 'L')}{cell(pair.right, newSpans, 'R')}
|
|
426
604
|
</div>)
|
|
427
605
|
notes(`notes-${at}-${index}`, pair)
|
|
428
606
|
}
|
|
@@ -433,7 +611,7 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
|
|
|
433
611
|
rows.push(<div key={`${at}-${index}`} className={clsx(css.line, css[row.kind], (marked('L', row.old) || marked('R', row.new)) && reviewCss.selected)} data-diff-line={row.kind}
|
|
434
612
|
onPointerEnter={(event) => { extendAdd(event.buttons, row.old, row.new) }}>
|
|
435
613
|
{singleSide !== 'R' && number('L', row.old, row.kind === 'del' && !labeled)}{singleSide !== 'L' && number('R', row.new, row.kind !== 'del' && !labeled)}<span className={css.sign}>{SIGN[row.kind]}</span>
|
|
436
|
-
<Code text={row.text} old={row.old} next={row.new} spans={row.kind === 'del' ?
|
|
614
|
+
<Code text={row.text} old={row.old} next={row.new} spans={row.kind === 'del' ? oldSpans?.get(row.old) : newSpans?.get(row.new)} />
|
|
437
615
|
</div>)
|
|
438
616
|
rows.push(...commentsAt('L', row.old), ...commentsAt('R', row.new))
|
|
439
617
|
}
|
|
@@ -447,6 +625,7 @@ function Lines({ file, text, open, handlers, split, wrap, review, visible, comme
|
|
|
447
625
|
}
|
|
448
626
|
}
|
|
449
627
|
for (const item of unplaced) rows.push(threadCard(item))
|
|
628
|
+
for (const item of unplacedNotes) rows.push(annotationOf(item))
|
|
450
629
|
return <div ref={root} className={css.code} style={style} data-single-side={singleSide ?? undefined} data-split={columns ? '' : undefined} data-wrap={wrap ? '' : undefined}
|
|
451
630
|
data-review={review === undefined ? undefined : ''}
|
|
452
631
|
data-native-side={nativeSide ?? undefined}
|
|
@@ -471,13 +650,16 @@ function drawsLines(file: ForgeDiffFile, large: boolean, revealed: boolean): boo
|
|
|
471
650
|
}
|
|
472
651
|
|
|
473
652
|
/** The file's lines or the note that replaces them, with its saved comments; host threads on lines follow when no lines show. */
|
|
474
|
-
function Content(props: DiffFileProps): ReactNode {
|
|
475
|
-
const { file, large, revealed, handlers, review, threads, t } = props
|
|
653
|
+
function Content(props: DiffFileProps & { readonly notes: FileAnnotations }): ReactNode {
|
|
654
|
+
const { file, large, revealed, handlers, review, threads, notes, t } = props
|
|
476
655
|
const comments = useFileReview(review, file.path)
|
|
477
656
|
const records = review === undefined ? null : comments.threads.map(thread => <ReviewThread key={thread.key} thread={thread}
|
|
478
657
|
actions={review} locked={comments.locked} outdated={!reviewMatches(thread.selection, review.source, file)} t={t} />)
|
|
479
|
-
const lineThreads =
|
|
480
|
-
|
|
658
|
+
const lineThreads = <>
|
|
659
|
+
{threads?.lines.map(item =>
|
|
660
|
+
<ThreadCard key={item.thread.id} thread={item.thread} place={item.place} actions={threads.actions} t={t} />)}
|
|
661
|
+
{notes.lines.map(item => <Annotation key={`${item.source}-${item.annotation.key}`} path={file.path} item={item} handlers={handlers} />)}
|
|
662
|
+
</>
|
|
481
663
|
if (file.binary) return <><p className={css.fileNote}>{t('diff.binary')}</p>{records}{lineThreads}</>
|
|
482
664
|
if (file.oversized) return <><p className={css.fileNote}>{t('diff.fileTooLarge')}</p>{records}{lineThreads}</>
|
|
483
665
|
if (file.hunks.length === 0) return <>{records}{lineThreads}</>
|
|
@@ -490,16 +672,27 @@ function Content(props: DiffFileProps): ReactNode {
|
|
|
490
672
|
</button>{records}{lineThreads}</>
|
|
491
673
|
)
|
|
492
674
|
}
|
|
493
|
-
return <Lines {...props} comments={comments} />
|
|
675
|
+
return <Lines {...props} comments={comments} annotations={notes.lines} />
|
|
494
676
|
}
|
|
495
677
|
|
|
496
678
|
/** Host threads on the whole file, the lines, then the host threads that later commits made outdated. */
|
|
497
679
|
function Body(props: DiffFileProps): ReactNode {
|
|
498
|
-
const { threads, t } = props
|
|
680
|
+
const { file, threads, handlers, t } = props
|
|
681
|
+
const notes = groupAnnotations(file, props.annotations, props.annotationLimit)
|
|
682
|
+
const frame = (item: SourcedAnnotation): ReactNode =>
|
|
683
|
+
<Annotation key={`${item.source}-${item.annotation.key}`} path={file.path} item={item} handlers={handlers} />
|
|
499
684
|
return <>
|
|
500
685
|
{threads?.file.map(thread => <ThreadCard key={thread.id} thread={thread} place={{ kind: 'file' }} actions={threads.actions} t={t} />)}
|
|
501
|
-
|
|
686
|
+
{notes.file.map(frame)}
|
|
687
|
+
<Content {...props} notes={notes} />
|
|
502
688
|
{threads !== undefined && <OutdatedThreads threads={threads.outdated} actions={threads.actions} t={t} />}
|
|
689
|
+
{notes.outdated.length > 0 && (
|
|
690
|
+
<div className={css.outdatedAnnotations} data-forge-outdated-annotations="">
|
|
691
|
+
<div className={css.outdatedAnnotationsTitle}>{t('annotation.outdated', { count: String(notes.outdated.length) })}</div>
|
|
692
|
+
{notes.outdated.map(frame)}
|
|
693
|
+
</div>
|
|
694
|
+
)}
|
|
695
|
+
{notes.hidden > 0 && <p className={css.fileNote} data-forge-hidden-annotations="">{t('annotation.hidden', { count: String(notes.hidden) })}</p>}
|
|
503
696
|
</>
|
|
504
697
|
}
|
|
505
698
|
|
|
@@ -543,6 +736,7 @@ function FileMenu({ name, file, handlers, t }: {
|
|
|
543
736
|
{t(action.label)}
|
|
544
737
|
</MenuItemButton>
|
|
545
738
|
))}
|
|
739
|
+
{menuOpen && <div className={css.menuPlugins}>{handlers.fileMenu(file, () => { setMenuOpen(false) })}</div>}
|
|
546
740
|
</Menu>
|
|
547
741
|
)
|
|
548
742
|
}
|
|
@@ -593,7 +787,7 @@ function DiffFileSection(props: DiffFileProps): ReactNode {
|
|
|
593
787
|
<Tag tone="warning" className={css.changedTag}><span className={css.changedText}>{t('viewed.changed')}</span></Tag>
|
|
594
788
|
)}
|
|
595
789
|
{threads !== undefined && threads.unresolved > 0 && (
|
|
596
|
-
<Tooltip label={t('thread.next')} side="bottom">
|
|
790
|
+
<Tooltip label={t('thread.next')} side="bottom" delayMs={500}>
|
|
597
791
|
<button type="button" className={css.threadCount} aria-label={t('thread.unresolvedAria', { name, count: threads.unresolved })}
|
|
598
792
|
onClick={() => { handlers.nextThread(file.path) }}>
|
|
599
793
|
<span className={css.threadCountText}>{t('thread.unresolvedCount', { count: threads.unresolved })}</span>
|
|
@@ -605,11 +799,13 @@ function DiffFileSection(props: DiffFileProps): ReactNode {
|
|
|
605
799
|
{badge !== '' && <span className={css.badge}>{badge}</span>}
|
|
606
800
|
</span>
|
|
607
801
|
{!file.binary && <Counts file={file} t={t} />}
|
|
608
|
-
<label
|
|
609
|
-
<
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
802
|
+
<Tooltip label={viewedNote} side="bottom" align="end" portal delayMs={500}>
|
|
803
|
+
<label className={css.viewed} data-disabled={viewedDisabled ? '' : undefined}>
|
|
804
|
+
<input type="checkbox" checked={viewed === 'viewed'} aria-label={t('viewed.aria', { name })} disabled={viewedDisabled}
|
|
805
|
+
onChange={(event) => { handlers.view(file, event.target.checked) }} />
|
|
806
|
+
<span className={css.viewedLabel} aria-hidden="true">{t('viewed.label')}</span>
|
|
807
|
+
</label>
|
|
808
|
+
</Tooltip>
|
|
613
809
|
{props.visible && <FileMenu name={name} file={file} handlers={handlers} t={t} />}
|
|
614
810
|
</div>
|
|
615
811
|
{expanded && (waiting ? <div className={css.unreached} style={placeholder} data-forge-diff-unreached="" /> : <Body {...props} />)}
|