@deepseek-ai/dsh-experimental-client-ui-forge 0.2.2-alpha.3 → 0.2.2-rc.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 +8 -8
- package/README.md +41 -14
- package/README.zh.md +40 -13
- package/lib/client.js +13 -11800
- package/lib/client.js.map +1 -0
- package/lib/index.js +1340 -115
- package/lib/typert.host.js +1715 -212
- package/lib/typert.remote-client.d.ts +42 -5
- package/lib/typert.remote-client.d.ts.map +1 -0
- package/lib/typert.remote-client.js +1523 -244
- package/lib/types/client/ActionToast.d.ts.map +1 -0
- package/lib/types/client/ActionToast.js.map +1 -0
- package/lib/types/client/BaseMenu.d.ts +30 -0
- package/lib/types/client/BaseMenu.d.ts.map +1 -0
- package/lib/types/client/BaseMenu.js.map +1 -0
- package/lib/types/client/ChangeRequestCard.d.ts +9 -5
- package/lib/types/client/ChangeRequestCard.d.ts.map +1 -0
- package/lib/types/client/ChangeRequestCard.js.map +1 -0
- package/lib/types/client/ChangeRequestOverview.d.ts +124 -0
- package/lib/types/client/ChangeRequestOverview.d.ts.map +1 -0
- package/lib/types/client/ChangeRequestOverview.js.map +1 -0
- package/lib/types/client/ChangedFiles.d.ts +2 -0
- package/lib/types/client/ChangedFiles.d.ts.map +1 -0
- package/lib/types/client/ChangedFiles.js.map +1 -0
- package/lib/types/client/ChangesTab.d.ts +30 -5
- package/lib/types/client/ChangesTab.d.ts.map +1 -0
- package/lib/types/client/ChangesTab.js.map +1 -0
- package/lib/types/client/ChangesTabTitle.d.ts.map +1 -0
- package/lib/types/client/ChangesTabTitle.js.map +1 -0
- package/lib/types/client/CommitMenu.d.ts +41 -0
- package/lib/types/client/CommitMenu.d.ts.map +1 -0
- package/lib/types/client/CommitMenu.js.map +1 -0
- package/lib/types/client/DiffFile.d.ts +47 -15
- package/lib/types/client/DiffFile.d.ts.map +1 -0
- package/lib/types/client/DiffFile.js.map +1 -0
- package/lib/types/client/FileLabel.d.ts.map +1 -0
- package/lib/types/client/FileLabel.js.map +1 -0
- package/lib/types/client/FileTreePane.d.ts +4 -2
- package/lib/types/client/FileTreePane.d.ts.map +1 -0
- package/lib/types/client/FileTreePane.js.map +1 -0
- package/lib/types/client/ForgeTab.d.ts +9 -1
- package/lib/types/client/ForgeTab.d.ts.map +1 -0
- package/lib/types/client/ForgeTab.js.map +1 -0
- package/lib/types/client/ForgeTabTitle.d.ts.map +1 -0
- package/lib/types/client/ForgeTabTitle.js.map +1 -0
- package/lib/types/client/HeaderButton.d.ts.map +1 -0
- package/lib/types/client/HeaderButton.js.map +1 -0
- package/lib/types/client/LocalChangesCard.d.ts.map +1 -0
- package/lib/types/client/LocalChangesCard.js.map +1 -0
- package/lib/types/client/RefreshGlyph.d.ts.map +1 -0
- package/lib/types/client/RefreshGlyph.js.map +1 -0
- package/lib/types/client/ReviewComposer.d.ts +20 -6
- package/lib/types/client/ReviewComposer.d.ts.map +1 -0
- package/lib/types/client/ReviewComposer.js.map +1 -0
- package/lib/types/client/ReviewControls.d.ts +79 -0
- package/lib/types/client/ReviewControls.d.ts.map +1 -0
- package/lib/types/client/ReviewControls.js.map +1 -0
- package/lib/types/client/ReviewThread.d.ts +4 -4
- package/lib/types/client/ReviewThread.d.ts.map +1 -0
- package/lib/types/client/ReviewThread.js.map +1 -0
- package/lib/types/client/ReviewThreads.d.ts +108 -0
- package/lib/types/client/ReviewThreads.d.ts.map +1 -0
- package/lib/types/client/ReviewThreads.js.map +1 -0
- package/lib/types/client/SessionHoverForge.d.ts.map +1 -0
- package/lib/types/client/SessionHoverForge.js.map +1 -0
- package/lib/types/client/SessionRowForge.d.ts +1 -1
- package/lib/types/client/SessionRowForge.d.ts.map +1 -0
- package/lib/types/client/SessionRowForge.js.map +1 -0
- package/lib/types/client/SubmitReview.d.ts +12 -4
- package/lib/types/client/SubmitReview.d.ts.map +1 -0
- package/lib/types/client/SubmitReview.js.map +1 -0
- package/lib/types/client/ThreadList.d.ts +43 -0
- package/lib/types/client/ThreadList.d.ts.map +1 -0
- package/lib/types/client/ThreadList.js.map +1 -0
- package/lib/types/client/ViewOptionsMenu.d.ts +31 -0
- package/lib/types/client/ViewOptionsMenu.d.ts.map +1 -0
- package/lib/types/client/ViewOptionsMenu.js.map +1 -0
- package/lib/types/client/WorktreeProgress.d.ts.map +1 -0
- package/lib/types/client/WorktreeProgress.js.map +1 -0
- package/lib/types/client/WorktreeSettings.d.ts +12 -0
- package/lib/types/client/WorktreeSettings.d.ts.map +1 -0
- package/lib/types/client/WorktreeSettings.js.map +1 -0
- package/lib/types/client/WorktreeToggle.d.ts.map +1 -0
- package/lib/types/client/WorktreeToggle.js.map +1 -0
- package/lib/types/client/changes-address.d.ts.map +1 -0
- package/lib/types/client/changes-address.js.map +1 -0
- package/lib/types/client/changes-store.d.ts +20 -5
- package/lib/types/client/changes-store.d.ts.map +1 -0
- package/lib/types/client/changes-store.js.map +1 -0
- package/lib/types/client/checkout.d.ts.map +1 -0
- package/lib/types/client/checkout.js.map +1 -0
- package/lib/types/client/code-selection.d.ts.map +1 -0
- package/lib/types/client/code-selection.js.map +1 -0
- package/lib/types/client/diff-rows.d.ts.map +1 -0
- package/lib/types/client/diff-rows.js.map +1 -0
- package/lib/types/client/file-tree.d.ts.map +1 -0
- package/lib/types/client/file-tree.js.map +1 -0
- package/lib/types/client/format.d.ts.map +1 -0
- package/lib/types/client/format.js.map +1 -0
- package/lib/types/client/glyphs.d.ts +4 -2
- package/lib/types/client/glyphs.d.ts.map +1 -0
- package/lib/types/client/glyphs.js.map +1 -0
- package/lib/types/client/host-viewed.d.ts +84 -0
- package/lib/types/client/host-viewed.d.ts.map +1 -0
- package/lib/types/client/host-viewed.js.map +1 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/index.js.map +1 -0
- package/lib/types/client/locales.d.ts +175 -3
- package/lib/types/client/locales.d.ts.map +1 -0
- package/lib/types/client/locales.js.map +1 -0
- package/lib/types/client/menu-search.d.ts +10 -0
- package/lib/types/client/menu-search.d.ts.map +1 -0
- package/lib/types/client/menu-search.js.map +1 -0
- package/lib/types/client/mount.d.ts +4 -0
- package/lib/types/client/mount.d.ts.map +1 -0
- package/lib/types/client/mount.js.map +1 -0
- package/lib/types/client/review-queue.d.ts +5 -8
- package/lib/types/client/review-queue.d.ts.map +1 -0
- package/lib/types/client/review-queue.js.map +1 -0
- package/lib/types/client/review-threads.d.ts +108 -0
- package/lib/types/client/review-threads.d.ts.map +1 -0
- package/lib/types/client/review-threads.js.map +1 -0
- package/lib/types/client/review.d.ts +31 -4
- package/lib/types/client/review.d.ts.map +1 -0
- package/lib/types/client/review.js.map +1 -0
- package/lib/types/client/section-reach.d.ts +26 -0
- package/lib/types/client/section-reach.d.ts.map +1 -0
- package/lib/types/client/section-reach.js.map +1 -0
- package/lib/types/client/session-list.d.ts.map +1 -0
- package/lib/types/client/session-list.js.map +1 -0
- package/lib/types/client/source.d.ts.map +1 -0
- package/lib/types/client/source.js.map +1 -0
- package/lib/types/client/status.d.ts.map +1 -0
- package/lib/types/client/status.js.map +1 -0
- package/lib/types/client/thread-state.d.ts +68 -0
- package/lib/types/client/thread-state.d.ts.map +1 -0
- package/lib/types/client/thread-state.js.map +1 -0
- package/lib/types/client/toolbar-fold.d.ts +19 -0
- package/lib/types/client/toolbar-fold.d.ts.map +1 -0
- package/lib/types/client/toolbar-fold.js.map +1 -0
- package/lib/types/client/viewed-files.d.ts +70 -0
- package/lib/types/client/viewed-files.d.ts.map +1 -0
- package/lib/types/client/viewed-files.js.map +1 -0
- package/lib/types/client/worktree-settings-form.d.ts +32 -0
- package/lib/types/client/worktree-settings-form.d.ts.map +1 -0
- package/lib/types/client/worktree-settings-form.js.map +1 -0
- package/lib/types/commit-range.d.ts +17 -0
- package/lib/types/commit-range.d.ts.map +1 -0
- package/lib/types/commit-range.js.map +1 -0
- package/lib/types/diff.d.ts +10 -2
- package/lib/types/diff.d.ts.map +1 -0
- package/lib/types/diff.js.map +1 -0
- package/lib/types/git.d.ts.map +1 -0
- package/lib/types/git.js.map +1 -0
- package/lib/types/index.d.ts +194 -14
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/layers.d.ts +66 -0
- package/lib/types/layers.d.ts.map +1 -0
- package/lib/types/layers.js.map +1 -0
- package/lib/types/local-diff.d.ts +54 -6
- package/lib/types/local-diff.d.ts.map +1 -0
- package/lib/types/local-diff.js.map +1 -0
- package/lib/types/panel.d.ts.map +1 -0
- package/lib/types/panel.js.map +1 -0
- package/lib/types/parse.d.ts +16 -0
- package/lib/types/parse.d.ts.map +1 -0
- package/lib/types/parse.js.map +1 -0
- package/lib/types/patch-cache.d.ts +12 -7
- package/lib/types/patch-cache.d.ts.map +1 -0
- package/lib/types/patch-cache.js.map +1 -0
- package/lib/types/review-cache.d.ts +54 -0
- package/lib/types/review-cache.d.ts.map +1 -0
- package/lib/types/review-cache.js.map +1 -0
- package/lib/types/states.d.ts.map +1 -0
- package/lib/types/states.js.map +1 -0
- package/lib/types/types.d.ts +113 -11
- package/lib/types/types.d.ts.map +1 -0
- package/lib/types/types.js.map +1 -0
- package/lib/types/wildmatch.d.ts +14 -0
- package/lib/types/wildmatch.d.ts.map +1 -0
- package/lib/types/wildmatch.js.map +1 -0
- package/lib/types/worktree.d.ts +8 -6
- package/lib/types/worktree.d.ts.map +1 -0
- package/lib/types/worktree.js.map +1 -0
- package/package.json +59 -49
- package/src/client/ActionToast.tsx +38 -0
- package/src/client/BaseMenu.module.css +153 -0
- package/src/client/BaseMenu.tsx +180 -0
- package/src/client/ChangeRequestCard.tsx +439 -0
- package/src/client/ChangeRequestOverview.module.css +196 -0
- package/src/client/ChangeRequestOverview.tsx +620 -0
- package/src/client/ChangedFiles.module.css +26 -0
- package/src/client/ChangedFiles.tsx +144 -0
- package/src/client/ChangesTab.module.css +984 -0
- package/src/client/ChangesTab.tsx +1288 -0
- package/src/client/ChangesTabTitle.tsx +28 -0
- package/src/client/CommitMenu.module.css +139 -0
- package/src/client/CommitMenu.tsx +186 -0
- package/src/client/DiffFile.tsx +621 -0
- package/src/client/FileLabel.module.css +53 -0
- package/src/client/FileLabel.tsx +66 -0
- package/src/client/FileTreePane.module.css +10 -0
- package/src/client/FileTreePane.tsx +79 -0
- package/src/client/ForgeTab.module.css +627 -0
- package/src/client/ForgeTab.tsx +263 -0
- package/src/client/ForgeTabTitle.tsx +21 -0
- package/src/client/HeaderButton.module.css +29 -0
- package/src/client/HeaderButton.tsx +68 -0
- package/src/client/LocalChangesCard.tsx +83 -0
- package/src/client/RefreshGlyph.module.css +22 -0
- package/src/client/RefreshGlyph.tsx +35 -0
- package/src/client/ReviewComposer.module.css +37 -0
- package/src/client/ReviewComposer.tsx +128 -0
- package/src/client/ReviewControls.module.css +162 -0
- package/src/client/ReviewControls.tsx +191 -0
- package/src/client/ReviewThread.tsx +96 -0
- package/src/client/ReviewThreads.module.css +326 -0
- package/src/client/ReviewThreads.tsx +443 -0
- package/src/client/SessionHoverForge.tsx +72 -0
- package/src/client/SessionList.module.css +85 -0
- package/src/client/SessionRowForge.tsx +86 -0
- package/src/client/SubmitReview.module.css +26 -0
- package/src/client/SubmitReview.tsx +95 -0
- package/src/client/ThreadList.module.css +218 -0
- package/src/client/ThreadList.tsx +165 -0
- package/src/client/ViewOptionsMenu.tsx +79 -0
- package/src/client/WorktreeProgress.module.css +226 -0
- package/src/client/WorktreeProgress.tsx +280 -0
- package/src/client/WorktreeSettings.module.css +29 -0
- package/src/client/WorktreeSettings.tsx +42 -0
- package/src/client/WorktreeToggle.module.css +132 -0
- package/src/client/WorktreeToggle.tsx +165 -0
- package/src/client/changes-address.ts +110 -0
- package/src/client/changes-store.ts +155 -0
- package/src/client/checkout.ts +75 -0
- package/src/client/code-selection.ts +53 -0
- package/src/client/diff-rows.ts +199 -0
- package/src/client/file-tree.ts +86 -0
- package/src/client/format.ts +37 -0
- package/src/client/glyphs.tsx +151 -0
- package/src/client/host-viewed.ts +195 -0
- package/src/client/index.ts +31 -0
- package/src/client/locales.ts +3446 -0
- package/src/client/menu-search.ts +16 -0
- package/src/client/mount.ts +439 -0
- package/src/client/review-queue.ts +256 -0
- package/src/client/review-threads.ts +204 -0
- package/src/client/review.ts +120 -0
- package/src/client/section-reach.ts +61 -0
- package/src/client/session-list.ts +79 -0
- package/src/client/source.ts +274 -0
- package/src/client/status.ts +171 -0
- package/src/client/thread-state.ts +127 -0
- package/src/client/toolbar-fold.ts +70 -0
- package/src/client/viewed-files.ts +178 -0
- package/src/client/worktree-settings-form.ts +43 -0
- package/src/commit-range.ts +27 -0
- package/src/css-modules.d.ts +5 -0
- package/src/diff.ts +162 -0
- package/src/git.ts +293 -0
- package/src/index.ts +1162 -0
- package/src/layers.ts +163 -0
- package/src/local-diff.ts +438 -0
- package/src/panel.ts +422 -0
- package/src/parse.ts +137 -0
- package/src/patch-cache.ts +73 -0
- package/src/review-cache.ts +98 -0
- package/src/states.ts +350 -0
- package/src/types.ts +504 -0
- package/src/wildmatch.ts +121 -0
- package/src/worktree.ts +576 -0
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Review threads of a change request inside the changes view: a thread card at its lines or at the top of its file, a
|
|
3
|
+
* resolved thread folded into one row, and the outdated threads of a file in a section after its lines. A card offers
|
|
4
|
+
* the writes the signed-in user may make: a reply, published at once or added to the pending review, resolving or
|
|
5
|
+
* unresolving the thread, and editing or deleting the user's own comments.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
|
9
|
+
import clsx from 'clsx'
|
|
10
|
+
import {
|
|
11
|
+
Button, IconCheckOutlineRegular, IconChevronDownOutlineRegular, IconEllipsisOutlineRegular, IconRightUpOutlineRegular, MarkdownText,
|
|
12
|
+
Menu, Tag, Tooltip, type MarkdownLabels,
|
|
13
|
+
} from '@deepseek-ai/dsh-client-ui-primitives'
|
|
14
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
15
|
+
import type { ForgeReviewComment, ForgeReviewThread, ForgeReviewWrite, ForgeThreadId } from '@deepseek-ai/dsh-experimental-forge/types'
|
|
16
|
+
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
|
|
17
|
+
import { formatAgo } from './format.ts'
|
|
18
|
+
import { anchorRange, hunkExcerpt, type ThreadPlace } from './review-threads.ts'
|
|
19
|
+
import { SplitAction } from './ReviewComposer.tsx'
|
|
20
|
+
import type { NS } from './locales.ts'
|
|
21
|
+
import css from './ReviewThreads.module.css'
|
|
22
|
+
import composerCss from './ReviewComposer.module.css'
|
|
23
|
+
|
|
24
|
+
type Translate = PropsLocale<typeof NS>['t']
|
|
25
|
+
|
|
26
|
+
/** Each member of a union without its `headSha`. */
|
|
27
|
+
type WithoutHead<T> = T extends unknown ? Omit<T, 'headSha'> : never
|
|
28
|
+
|
|
29
|
+
/** A write to one thread or its comments, without the head commit the changes view adds. */
|
|
30
|
+
export type ThreadWrite = WithoutHead<Extract<ForgeReviewWrite, { readonly kind: 'reply' | 'resolve' | 'edit-comment' | 'delete-comment' }>>
|
|
31
|
+
|
|
32
|
+
/** Writes the signed-in user can make to the threads of one changes view. */
|
|
33
|
+
export interface ThreadWrites {
|
|
34
|
+
/** Send a write; resolves to the message to show, or undefined once the code host took it. */
|
|
35
|
+
readonly write: (write: ThreadWrite) => Promise<string | undefined>
|
|
36
|
+
/** Whether the user has a pending review, which every reply then joins. */
|
|
37
|
+
readonly reviewStarted: boolean
|
|
38
|
+
/** Whether the user can add a reply to a pending review, starting one when needed. */
|
|
39
|
+
readonly canReview: boolean
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Reads, actions, and identities every thread card of one changes view shares. */
|
|
43
|
+
export interface ThreadActions {
|
|
44
|
+
/** Login of the change request's author, or null when the host hides it. */
|
|
45
|
+
readonly author: string | null
|
|
46
|
+
/** Quote the whole thread in the main input without sending it; false when the input refused it. */
|
|
47
|
+
readonly addToInput: (thread: ForgeReviewThread, range: string | null) => boolean
|
|
48
|
+
/** Open a URL outside the app. */
|
|
49
|
+
readonly openLink: (url: string) => void
|
|
50
|
+
/** Read a file of the change request's repository at a commit. */
|
|
51
|
+
readonly readText: (commit: string, path: string) => Promise<RemoteResult<string>>
|
|
52
|
+
/** Report that the input refused a thread. */
|
|
53
|
+
readonly inputFailed: () => void
|
|
54
|
+
/** The latest jump to a thread, which unfolds that thread and its section until the reader folds them again; null before any. */
|
|
55
|
+
readonly focused: ThreadFocus | null
|
|
56
|
+
/** Writes the user can make, or null when the code host takes none from this view. */
|
|
57
|
+
readonly writes: ThreadWrites | null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** One jump to a thread; each jump has its own revision, so a jump to the same thread unfolds it again. */
|
|
61
|
+
export interface ThreadFocus {
|
|
62
|
+
readonly id: ForgeThreadId
|
|
63
|
+
readonly revision: number
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** A host thread shown on lines of one side. */
|
|
67
|
+
export interface LineThread {
|
|
68
|
+
readonly thread: ForgeReviewThread
|
|
69
|
+
readonly place: Extract<ThreadPlace, { readonly kind: 'line' }>
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Host threads of one file and the actions their cards share. */
|
|
73
|
+
export interface FileThreads {
|
|
74
|
+
/** Threads on lines, which follow the row of their last line. */
|
|
75
|
+
readonly lines: readonly LineThread[]
|
|
76
|
+
/** Threads on the whole file, shown above its lines. */
|
|
77
|
+
readonly file: readonly ForgeReviewThread[]
|
|
78
|
+
/** Threads no longer on the head's lines, shown after them. */
|
|
79
|
+
readonly outdated: readonly ForgeReviewThread[]
|
|
80
|
+
/** Unresolved threads of the file in every place, including threads the chosen commits do not show. */
|
|
81
|
+
readonly unresolved: number
|
|
82
|
+
/** Reads, actions, and identities shared by the cards. */
|
|
83
|
+
readonly actions: ThreadActions
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The commit a thread was written on, abbreviated, or null for a file thread. */
|
|
87
|
+
function writtenOn(thread: ForgeReviewThread): string | null {
|
|
88
|
+
return thread.original === null ? null : thread.original.commit.slice(0, 7)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Build the Markdown chrome copy of comment bodies.
|
|
93
|
+
* @param t - forge panel copy.
|
|
94
|
+
* @returns labels for code fences and footnotes.
|
|
95
|
+
*/
|
|
96
|
+
export function useMarkdownLabels(t: Translate): MarkdownLabels {
|
|
97
|
+
return useMemo(() => ({
|
|
98
|
+
code: { copyLabel: t('thread.copy'), copiedLabel: t('thread.copied'),
|
|
99
|
+
toolbarLabels: { codeLabel: t('thread.codeBlock'), wrapLabel: t('thread.wrap'), unwrapLabel: t('thread.unwrap') } },
|
|
100
|
+
footnotes: t('thread.footnotes'),
|
|
101
|
+
}), [t])
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Render an author's avatar, or the first letter of the login when the image is missing or fails.
|
|
106
|
+
* @param props - the comment's author and the avatar size.
|
|
107
|
+
* @returns the round avatar.
|
|
108
|
+
*/
|
|
109
|
+
export function Avatar({ author, size = 20 }: { readonly author: ForgeReviewComment['author']; readonly size?: number }): ReactNode {
|
|
110
|
+
const [failed, setFailed] = useState(false)
|
|
111
|
+
const login = author?.login ?? '?'
|
|
112
|
+
return <span className={css.avatar} style={{ width: size, height: size, fontSize: Math.round(size * 0.45) }} aria-hidden="true">
|
|
113
|
+
{author?.avatarUrl != null && !failed
|
|
114
|
+
? <img src={author.avatarUrl} alt="" width={size} height={size} referrerPolicy="no-referrer" onError={() => { setFailed(true) }} />
|
|
115
|
+
: login.slice(0, 1).toUpperCase()}
|
|
116
|
+
</span>
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Run one write at a time for a card section, keeping its error until the next attempt. */
|
|
120
|
+
function useWriting(t: Translate): {
|
|
121
|
+
readonly busy: boolean
|
|
122
|
+
readonly error: string | null
|
|
123
|
+
readonly run: (send: () => Promise<string | undefined>) => Promise<boolean>
|
|
124
|
+
} {
|
|
125
|
+
const [busy, setBusy] = useState(false)
|
|
126
|
+
const [error, setError] = useState<string | null>(null)
|
|
127
|
+
const running = useRef(false)
|
|
128
|
+
const run = async (send: () => Promise<string | undefined>): Promise<boolean> => {
|
|
129
|
+
if (running.current) return false
|
|
130
|
+
running.current = true
|
|
131
|
+
setBusy(true)
|
|
132
|
+
setError(null)
|
|
133
|
+
try {
|
|
134
|
+
const failure = await send()
|
|
135
|
+
setError(failure ?? null)
|
|
136
|
+
return failure === undefined
|
|
137
|
+
} catch (_error) {
|
|
138
|
+
setError(t('thread.writeUnknown'))
|
|
139
|
+
return false
|
|
140
|
+
} finally {
|
|
141
|
+
running.current = false
|
|
142
|
+
setBusy(false)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return { busy, error, run }
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** A plain-text field with Cancel and the actions that send it, for a reply or a comment edit. */
|
|
149
|
+
function TextForm({ label, initial, busy, error, cancel, children }: {
|
|
150
|
+
readonly label: string
|
|
151
|
+
readonly initial: string
|
|
152
|
+
readonly busy: boolean
|
|
153
|
+
readonly error: string | null
|
|
154
|
+
readonly cancel: { readonly label: string; readonly run: () => void }
|
|
155
|
+
/** The sending actions, given the current text and whether it is blank. */
|
|
156
|
+
readonly children: (text: string, blank: boolean) => ReactNode
|
|
157
|
+
}): ReactNode {
|
|
158
|
+
const [text, setText] = useState(initial)
|
|
159
|
+
return <div className={css.form}>
|
|
160
|
+
<textarea autoFocus className={composerCss.input} rows={3} value={text} disabled={busy} aria-label={label} placeholder={label}
|
|
161
|
+
onChange={(event) => { setText(event.target.value) }} />
|
|
162
|
+
{error !== null && <div className={composerCss.error} role="alert">{error}</div>}
|
|
163
|
+
<div className={css.formActions}>
|
|
164
|
+
<Button size="sm" className={clsx(composerCss.cancel)} disabled={busy} onClick={cancel.run}>{cancel.label}</Button>
|
|
165
|
+
{children(text, text.trim() === '')}
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Tells the card which of its forms hold text the reader is writing, so it does not fold them away. */
|
|
171
|
+
type Drafting = (form: string, active: boolean) => void
|
|
172
|
+
|
|
173
|
+
function Comment({ comment, last, actions, labels, now, drafting, t }: {
|
|
174
|
+
readonly comment: ForgeReviewComment
|
|
175
|
+
readonly drafting: Drafting
|
|
176
|
+
/** Whether the comment is the only one of its thread, so deleting it deletes the thread. */
|
|
177
|
+
readonly last: boolean
|
|
178
|
+
readonly actions: ThreadActions
|
|
179
|
+
readonly labels: MarkdownLabels
|
|
180
|
+
readonly now: number
|
|
181
|
+
readonly t: Translate
|
|
182
|
+
}): ReactNode {
|
|
183
|
+
const [mode, setMode] = useState<'view' | 'edit' | 'delete'>('view')
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
drafting(comment.id, mode === 'edit')
|
|
186
|
+
return () => { drafting(comment.id, false) }
|
|
187
|
+
}, [drafting, comment.id, mode])
|
|
188
|
+
const [menu, setMenu] = useState(false)
|
|
189
|
+
const writing = useWriting(t)
|
|
190
|
+
const writes = actions.writes
|
|
191
|
+
const login = comment.author?.login ?? null
|
|
192
|
+
const editable = writes !== null && comment.viewerCanEdit
|
|
193
|
+
const deletable = writes !== null && comment.viewerCanDelete
|
|
194
|
+
const menuLabel = t('thread.commentActions', { author: login ?? t('thread.deletedAuthor') })
|
|
195
|
+
const send = async (write: ThreadWrite): Promise<void> => {
|
|
196
|
+
if (writes !== null && await writing.run(() => writes.write(write))) setMode('view')
|
|
197
|
+
}
|
|
198
|
+
return <div className={css.comment} data-forge-thread-comment={comment.id}>
|
|
199
|
+
<Avatar author={comment.author} />
|
|
200
|
+
<div className={css.commentMain}>
|
|
201
|
+
<div className={css.commentHeader}>
|
|
202
|
+
<span className={css.login}>{login ?? t('thread.deletedAuthor')}</span>
|
|
203
|
+
<span className={css.time} title={comment.createdAt}>{formatAgo(comment.createdAt, now, t) ?? comment.createdAt}</span>
|
|
204
|
+
{login !== null && login === actions.author && <Tag tone="outline">{t('thread.author')}</Tag>}
|
|
205
|
+
{comment.author?.bot === true && <Tag tone="outline">{t('thread.bot')}</Tag>}
|
|
206
|
+
{comment.pending && <Tag tone="warning">{t('review.pending')}</Tag>}
|
|
207
|
+
{(editable || deletable) && mode === 'view' && <>
|
|
208
|
+
<span className={css.spacer} />
|
|
209
|
+
<Menu open={menu} portal dense align="end" autoFocus onClose={() => { setMenu(false) }}
|
|
210
|
+
items={[...editable ? [{ id: 'edit', label: t('review.edit') }] : [], ...deletable ? [{ id: 'delete', label: t('review.remove') }] : []]}
|
|
211
|
+
onSelect={(id) => { setMenu(false); setMode(id === 'edit' ? 'edit' : 'delete') }}
|
|
212
|
+
anchor={<span className={css.menuAnchor}><Tooltip label={menuLabel} side="bottom">
|
|
213
|
+
<button type="button" className={css.icon} aria-label={menuLabel} aria-haspopup="menu" aria-expanded={menu}
|
|
214
|
+
onClick={() => { setMenu(value => !value) }}><IconEllipsisOutlineRegular size={14} /></button>
|
|
215
|
+
</Tooltip></span>} />
|
|
216
|
+
</>}
|
|
217
|
+
</div>
|
|
218
|
+
{mode === 'edit'
|
|
219
|
+
? <TextForm label={t('thread.editAria')} initial={comment.body} busy={writing.busy} error={writing.error}
|
|
220
|
+
cancel={{ label: t('review.cancel'), run: () => { setMode('view') } }}>
|
|
221
|
+
{(text, blank) => <Button size="sm" variant="primary" disabled={writing.busy || blank || text === comment.body}
|
|
222
|
+
onClick={() => { void send({ kind: 'edit-comment', comment: comment.id, body: text }) }}>
|
|
223
|
+
{t(writing.busy ? 'thread.saving' : 'thread.save')}
|
|
224
|
+
</Button>}
|
|
225
|
+
</TextForm>
|
|
226
|
+
// Raw HTML renders nothing, as GitHub hides comments and unknown tags, and never enters the DOM.
|
|
227
|
+
: <div className={css.body}><MarkdownText text={comment.body} labels={labels} variant="body" omitHtml /></div>}
|
|
228
|
+
{mode === 'delete' && <div className={css.confirm} role="group" aria-label={t(last ? 'thread.deleteLast' : 'thread.deleteConfirm')}>
|
|
229
|
+
<span className={css.confirmText}>{t(last ? 'thread.deleteLast' : 'thread.deleteConfirm')}</span>
|
|
230
|
+
<Button size="sm" disabled={writing.busy} onClick={() => { setMode('view') }}>{t('review.cancel')}</Button>
|
|
231
|
+
<Button size="sm" variant="primary" disabled={writing.busy} onClick={() => { void send({ kind: 'delete-comment', comment: comment.id }) }}>
|
|
232
|
+
{t(writing.busy ? 'thread.deleting' : 'review.remove')}
|
|
233
|
+
</Button>
|
|
234
|
+
{writing.error !== null && <div className={clsx(composerCss.error, css.confirmError)} role="alert">{writing.error}</div>}
|
|
235
|
+
</div>}
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* The reply field of a thread. Without a pending review it replies at once, and its menu starts one with the reply; with
|
|
242
|
+
* one, it adds the reply to it, since GitHub adds every reply of the user to the pending review.
|
|
243
|
+
*/
|
|
244
|
+
function Reply({ thread, writes, drafting, t }: PropsLocale<typeof NS> & {
|
|
245
|
+
readonly thread: ForgeReviewThread
|
|
246
|
+
readonly writes: ThreadWrites
|
|
247
|
+
readonly drafting: Drafting
|
|
248
|
+
}): ReactNode {
|
|
249
|
+
const [open, setOpen] = useState(false)
|
|
250
|
+
useEffect(() => {
|
|
251
|
+
drafting('reply', open)
|
|
252
|
+
return () => { drafting('reply', false) }
|
|
253
|
+
}, [drafting, open])
|
|
254
|
+
const writing = useWriting(t)
|
|
255
|
+
if (!open) {
|
|
256
|
+
return <button type="button" className={css.replyPrompt} onClick={() => { setOpen(true) }}>{t('thread.replyPlaceholder')}</button>
|
|
257
|
+
}
|
|
258
|
+
const send = async (text: string, pending: boolean): Promise<void> => {
|
|
259
|
+
if (await writing.run(() => writes.write({ kind: 'reply', thread: thread.id, body: text, pending }))) setOpen(false)
|
|
260
|
+
}
|
|
261
|
+
return <TextForm label={t('thread.replyPlaceholder')} initial="" busy={writing.busy} error={writing.error}
|
|
262
|
+
cancel={{ label: t('review.cancel'), run: () => { setOpen(false) } }}>
|
|
263
|
+
{(text, blank) => writes.reviewStarted
|
|
264
|
+
? <Button size="sm" variant="primary" disabled={writing.busy || blank} onClick={() => { void send(text, true) }}>
|
|
265
|
+
{t(writing.busy ? 'review.publishing' : 'review.queue')}
|
|
266
|
+
</Button>
|
|
267
|
+
: <SplitAction disabled={writing.busy || blank} label={t(writing.busy ? 'review.publishing' : 'thread.reply')}
|
|
268
|
+
run={() => { void send(text, false) }} menuLabel={t('thread.replyActions')}
|
|
269
|
+
other={writes.canReview ? t('review.startReview') : undefined} menu={() => { void send(text, true) }} />}
|
|
270
|
+
</TextForm>
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** Resolve or unresolve a thread. */
|
|
274
|
+
function Resolution({ thread, writes, t }: PropsLocale<typeof NS> & {
|
|
275
|
+
readonly thread: ForgeReviewThread
|
|
276
|
+
readonly writes: ThreadWrites
|
|
277
|
+
}): ReactNode {
|
|
278
|
+
const writing = useWriting(t)
|
|
279
|
+
return <>
|
|
280
|
+
<Button size="sm" disabled={writing.busy}
|
|
281
|
+
onClick={() => { void writing.run(() => writes.write({ kind: 'resolve', thread: thread.id, resolved: !thread.resolved })) }}>
|
|
282
|
+
{t(thread.resolved ? 'thread.unresolve' : 'thread.resolve')}
|
|
283
|
+
</Button>
|
|
284
|
+
{writing.error !== null && <div className={clsx(composerCss.error, css.actionError)} role="alert">{writing.error}</div>}
|
|
285
|
+
</>
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Render one thread: its place, every comment, its reply field, and its actions. A resolved thread folds into one row
|
|
290
|
+
* until the reader unfolds it or jumps to it.
|
|
291
|
+
* @param props - the thread, where it shows, the shared actions, and copy.
|
|
292
|
+
* @returns the thread card or its folded row.
|
|
293
|
+
*/
|
|
294
|
+
export function ThreadCard({ thread, place, actions, t }: PropsLocale<typeof NS> & {
|
|
295
|
+
readonly thread: ForgeReviewThread
|
|
296
|
+
readonly place: ThreadPlace
|
|
297
|
+
readonly actions: ThreadActions
|
|
298
|
+
}): ReactNode {
|
|
299
|
+
const [open, setOpen] = useState(false)
|
|
300
|
+
// The jump the reader folded the thread after, which no longer unfolds it.
|
|
301
|
+
const [foldedAt, setFoldedAt] = useState<number | null>(null)
|
|
302
|
+
const labels = useMarkdownLabels(t)
|
|
303
|
+
const now = Date.now()
|
|
304
|
+
const focused = actions.focused?.id === thread.id && actions.focused.revision !== foldedAt
|
|
305
|
+
// A thread resolved elsewhere while the reader writes a reply or an edit stays open, so the text is not lost.
|
|
306
|
+
const [drafts, setDrafts] = useState<ReadonlySet<string>>(() => new Set())
|
|
307
|
+
const drafting = useCallback<Drafting>((form, active) => {
|
|
308
|
+
setDrafts((value) => {
|
|
309
|
+
if (value.has(form) === active) return value
|
|
310
|
+
const next = new Set(value)
|
|
311
|
+
if (active) next.add(form)
|
|
312
|
+
else next.delete(form)
|
|
313
|
+
return next
|
|
314
|
+
})
|
|
315
|
+
}, [])
|
|
316
|
+
const unfolded = open || !thread.resolved || focused || drafts.size > 0
|
|
317
|
+
const side = place.kind === 'line' ? place.side : thread.side
|
|
318
|
+
const original = place.kind === 'outdated' && thread.original !== null ? thread.original : null
|
|
319
|
+
// The composer names an outdated thread by the lines it was written on, as its label does.
|
|
320
|
+
const range = place.kind === 'line' ? anchorRange(place.side, place) : original !== null ? anchorRange(thread.side, original) : null
|
|
321
|
+
const commit = writtenOn(thread)
|
|
322
|
+
const first = thread.comments[0]
|
|
323
|
+
const url = first?.url ?? null
|
|
324
|
+
const writes = actions.writes
|
|
325
|
+
if (!unfolded) {
|
|
326
|
+
return <div className={css.folded} data-forge-thread={thread.id} data-side={side}>
|
|
327
|
+
<IconCheckOutlineRegular size={14} />
|
|
328
|
+
<span className={css.foldedText}>{t('thread.resolvedRow', { author: first?.author?.login ?? t('thread.deletedAuthor') })}</span>
|
|
329
|
+
<button type="button" className={css.link} aria-expanded={false} onClick={() => { setOpen(true) }}>{t('thread.expand')}</button>
|
|
330
|
+
</div>
|
|
331
|
+
}
|
|
332
|
+
const label = original !== null ? t('thread.originally', { range: anchorRange(thread.side, original) }) : range ?? t('thread.fileLevel')
|
|
333
|
+
return <section className={css.card} data-forge-thread={thread.id} data-side={side}
|
|
334
|
+
data-resolved={thread.resolved ? '' : undefined} aria-label={label} tabIndex={-1}>
|
|
335
|
+
<div className={css.header}>
|
|
336
|
+
<span className={css.place}>
|
|
337
|
+
{label}
|
|
338
|
+
{commit !== null && <> · {t('thread.onCommit', { commit })}</>}
|
|
339
|
+
</span>
|
|
340
|
+
{place.kind === 'outdated' && <Tag tone="warning">{t('thread.outdatedTag')}</Tag>}
|
|
341
|
+
{thread.resolved && <Tag tone="success">{t('thread.filter.resolved')}</Tag>}
|
|
342
|
+
<span className={css.spacer} />
|
|
343
|
+
{thread.resolved && <button type="button" className={css.link} aria-expanded onClick={() => {
|
|
344
|
+
setOpen(false)
|
|
345
|
+
setFoldedAt(actions.focused?.revision ?? null)
|
|
346
|
+
}}>{t('thread.collapse')}</button>}
|
|
347
|
+
{original !== null && thread.side === 'R' && <OriginalFile thread={thread} commit={original.commit} actions={actions} t={t} />}
|
|
348
|
+
</div>
|
|
349
|
+
{place.kind === 'outdated' && thread.diffHunk !== null && original !== null
|
|
350
|
+
&& <Excerpt hunk={thread.diffHunk} side={thread.side} lines={original.endLine - original.startLine + 1} />}
|
|
351
|
+
<div className={css.comments}>
|
|
352
|
+
{thread.comments.map(comment => <Comment key={comment.id} comment={comment} last={thread.comments.length === 1}
|
|
353
|
+
actions={actions} labels={labels} now={now} drafting={drafting} t={t} />)}
|
|
354
|
+
</div>
|
|
355
|
+
{writes !== null && thread.viewerCanReply && <Reply thread={thread} writes={writes} drafting={drafting} t={t} />}
|
|
356
|
+
<div className={css.actions}>
|
|
357
|
+
<Button size="sm" onClick={() => { if (!actions.addToInput(thread, range)) actions.inputFailed() }}>
|
|
358
|
+
{t('review.addToInput')}
|
|
359
|
+
</Button>
|
|
360
|
+
{url !== null && <Button size="sm" onClick={() => { actions.openLink(url) }}>
|
|
361
|
+
<IconRightUpOutlineRegular size={14} />{t('thread.openOnHost')}
|
|
362
|
+
</Button>}
|
|
363
|
+
{writes !== null && thread.viewerCanResolve && <Resolution thread={thread} writes={writes} t={t} />}
|
|
364
|
+
</div>
|
|
365
|
+
</section>
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** The end of a recorded diff hunk: the lines a thread was written on and a few before them. */
|
|
369
|
+
function Excerpt({ hunk, side, lines }: { readonly hunk: string; readonly side: 'L' | 'R'; readonly lines: number }): ReactNode {
|
|
370
|
+
const excerpt = hunkExcerpt(hunk, side, lines)
|
|
371
|
+
return <div className={css.excerpt}>
|
|
372
|
+
{excerpt.header !== null && <div className={clsx(css.excerptLine, css.excerptHeader)}>{excerpt.header}</div>}
|
|
373
|
+
{excerpt.lines.map((line, index) => <div key={index} className={clsx(css.excerptLine,
|
|
374
|
+
line.startsWith('+') && css.added, line.startsWith('-') && css.deleted)}>{line}</div>)}
|
|
375
|
+
</div>
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Show the whole file at the commit a thread was written on, with the thread's lines marked, under the thread header.
|
|
380
|
+
* Only a new-side thread offers it: its lines number that commit's file.
|
|
381
|
+
*/
|
|
382
|
+
function OriginalFile({ thread, commit, actions, t }: PropsLocale<typeof NS> & {
|
|
383
|
+
readonly thread: ForgeReviewThread
|
|
384
|
+
readonly commit: string
|
|
385
|
+
readonly actions: ThreadActions
|
|
386
|
+
}): ReactNode {
|
|
387
|
+
const [state, setState] = useState<{ readonly lines: readonly string[] } | 'closed' | 'loading' | { readonly failed: string }>('closed')
|
|
388
|
+
const marked = useRef<HTMLDivElement>(null)
|
|
389
|
+
useEffect(() => { marked.current?.scrollIntoView({ block: 'center' }) }, [state])
|
|
390
|
+
const toggle = (): void => {
|
|
391
|
+
if (state !== 'closed' && state !== 'loading') { setState('closed'); return }
|
|
392
|
+
setState('loading')
|
|
393
|
+
void actions.readText(commit, thread.path).then((result) => {
|
|
394
|
+
setState(result.ok ? { lines: result.value.split('\n') } : { failed: result.error.message })
|
|
395
|
+
})
|
|
396
|
+
}
|
|
397
|
+
const open = state !== 'closed'
|
|
398
|
+
const range = thread.original
|
|
399
|
+
return <>
|
|
400
|
+
<button type="button" className={css.link} aria-expanded={open} disabled={state === 'loading'} onClick={toggle}>
|
|
401
|
+
{t(open ? 'thread.hideOriginal' : 'thread.viewOriginal')}
|
|
402
|
+
</button>
|
|
403
|
+
{open && <div className={css.original} role="region" aria-label={t('thread.viewOriginal')}>
|
|
404
|
+
{state === 'loading' ? <div className={css.originalNote}>{t('thread.originalLoading')}</div>
|
|
405
|
+
: 'failed' in state ? <div className={css.originalNote} role="alert">{t('thread.originalFailed', { message: state.failed })}</div>
|
|
406
|
+
: state.lines.map((line, index) => {
|
|
407
|
+
const number = index + 1
|
|
408
|
+
const inside = range !== null && number >= range.startLine && number <= range.endLine
|
|
409
|
+
return <div key={index} ref={inside && number === range.startLine ? marked : undefined}
|
|
410
|
+
className={clsx(css.originalLine, inside && css.marked)}>
|
|
411
|
+
<span className={css.originalNumber}>{number}</span><span>{line}</span>
|
|
412
|
+
</div>
|
|
413
|
+
})}
|
|
414
|
+
</div>}
|
|
415
|
+
</>
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Render the outdated threads of a file after its lines, as one section the reader can fold.
|
|
420
|
+
* @param props - the threads, the shared actions, and copy.
|
|
421
|
+
* @returns the section, or nothing without outdated threads.
|
|
422
|
+
*/
|
|
423
|
+
export function OutdatedThreads({ threads, actions, t }: PropsLocale<typeof NS> & {
|
|
424
|
+
readonly threads: readonly ForgeReviewThread[]
|
|
425
|
+
readonly actions: ThreadActions
|
|
426
|
+
}): ReactNode {
|
|
427
|
+
// The section is folded after the jump with this revision, or -1 before any jump, or null while unfolded.
|
|
428
|
+
const [folded, setFolded] = useState<number | null>(null)
|
|
429
|
+
if (threads.length === 0) return null
|
|
430
|
+
const jump = actions.focused
|
|
431
|
+
const open = folded === null || (jump !== null && jump.revision !== folded && threads.some(thread => thread.id === jump.id))
|
|
432
|
+
return <section className={css.outdated} data-forge-outdated-threads="">
|
|
433
|
+
<div className={css.outdatedHeader}>
|
|
434
|
+
<span>{t('thread.outdatedSection', { count: threads.length })}</span>
|
|
435
|
+
<span className={css.spacer} />
|
|
436
|
+
<button type="button" className={css.link} aria-expanded={open} onClick={() => { setFolded(open ? jump?.revision ?? -1 : null) }}>
|
|
437
|
+
{t(open ? 'thread.collapse' : 'thread.expand')}
|
|
438
|
+
<IconChevronDownOutlineRegular size={12} className={clsx(!open && css.turned)} />
|
|
439
|
+
</button>
|
|
440
|
+
</div>
|
|
441
|
+
{open && threads.map(thread => <ThreadCard key={thread.id} thread={thread} place={{ kind: 'outdated' }} actions={actions} t={t} />)}
|
|
442
|
+
</section>
|
|
443
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The forge section of a Session row's hover card: the worktree branch while
|
|
3
|
+
* the Session works in the worktree the panel created for it, and its change
|
|
4
|
+
* requests, most urgent first.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ReactNode } from 'react'
|
|
8
|
+
import { IconBranchOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
9
|
+
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
|
10
|
+
// Type-only: pulls the ui-workspace SlotMap merge (the Session row seats).
|
|
11
|
+
import type {} from '@deepseek-ai/dsh-client-ui-workspace/client'
|
|
12
|
+
import { ChangeRequestGlyph } from './glyphs.tsx'
|
|
13
|
+
import type { NS } from './locales.ts'
|
|
14
|
+
import { useSessionForgeFacts, type SessionListInjected } from './session-list.ts'
|
|
15
|
+
import { CHECKS_LABEL, rowChecks, stateLine } from './SessionRowForge.tsx'
|
|
16
|
+
import { TONE_LABEL } from './status.ts'
|
|
17
|
+
import css from './SessionList.module.css'
|
|
18
|
+
|
|
19
|
+
/** Change requests the hover card lists before naming how many more there are. */
|
|
20
|
+
export const HOVER_CHANGE_REQUEST_LIMIT = 3
|
|
21
|
+
|
|
22
|
+
/** Full props of the hover section. */
|
|
23
|
+
export type SessionHoverForgeProps =
|
|
24
|
+
PropsRuntime<'sidebar.session.row.hover'> & PropsLocale<typeof NS> & InjectFace<SessionListInjected>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Render the forge section of a Session's hover card.
|
|
28
|
+
* @param props - the row's Session, the shared hooks, and copy.
|
|
29
|
+
* @returns the section, or null for a Session without a worktree or change requests.
|
|
30
|
+
*/
|
|
31
|
+
export function SessionHoverForge({ sessionId, useSessions, useStates, t }: SessionHoverForgeProps): ReactNode {
|
|
32
|
+
const facts = useSessionForgeFacts(useSessions, useStates, sessionId)
|
|
33
|
+
if (facts.worktree === null && facts.changeRequests.length === 0) return null
|
|
34
|
+
const shown = facts.changeRequests.slice(0, HOVER_CHANGE_REQUEST_LIMIT)
|
|
35
|
+
const omitted = facts.changeRequests.length - shown.length
|
|
36
|
+
const worktree = facts.worktree
|
|
37
|
+
return (
|
|
38
|
+
<div className={css.hover} data-forge-session-hover="">
|
|
39
|
+
{worktree !== null && (
|
|
40
|
+
<div className={css.hoverItem}>
|
|
41
|
+
<span className={css.hoverIcon} aria-hidden="true"><IconBranchOutlineRegular size={12} /></span>
|
|
42
|
+
<span className={css.hoverBody}>
|
|
43
|
+
<span className={css.hoverBranch}>{worktree.branch}</span>
|
|
44
|
+
<span className={css.hoverNote}>{t('checkout.worktreeFrom', { base: worktree.from ?? worktree.baseCommit.slice(0, 7) })}</span>
|
|
45
|
+
</span>
|
|
46
|
+
</div>
|
|
47
|
+
)}
|
|
48
|
+
{shown.map((entry) => {
|
|
49
|
+
const checks = rowChecks(entry)
|
|
50
|
+
return (
|
|
51
|
+
<div className={css.hoverItem} key={entry.url} data-forge-session-hover-change={entry.tone}>
|
|
52
|
+
<span className={css.hoverIcon} data-tone={entry.tone} aria-hidden="true">
|
|
53
|
+
<ChangeRequestGlyph tone={entry.tone} tinted={false} size={12} />
|
|
54
|
+
</span>
|
|
55
|
+
<span className={css.hoverBody}>
|
|
56
|
+
<span className={css.hoverTitle}>{entry.state === undefined ? entry.url : `#${entry.state.number} ${entry.state.title}`}</span>
|
|
57
|
+
<span className={css.hoverNote}>
|
|
58
|
+
<span aria-hidden="true">
|
|
59
|
+
{t(TONE_LABEL[entry.tone])}
|
|
60
|
+
{checks !== 'none' && <span className={css.hoverSeparator}>·</span>}
|
|
61
|
+
{checks !== 'none' && <span data-checks={checks}>{t(CHECKS_LABEL[checks])}</span>}
|
|
62
|
+
</span>
|
|
63
|
+
<span className={css.visuallyHidden}>{stateLine(entry, t)}</span>
|
|
64
|
+
</span>
|
|
65
|
+
</span>
|
|
66
|
+
</div>
|
|
67
|
+
)
|
|
68
|
+
})}
|
|
69
|
+
{omitted > 0 && <div className={css.hoverMore}>{t('list.more', { count: omitted })}</div>}
|
|
70
|
+
</div>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/* One icon in the Session row's resting seat, sized to the row's 20px line. */
|
|
2
|
+
.icon {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
flex: none;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
height: 20px;
|
|
8
|
+
color: var(--dsw-alias-label-tertiary);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* Hover card section: the card keeps one dark surface in both themes, so it
|
|
12
|
+
* uses the hover card label and state tokens. */
|
|
13
|
+
.hover {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
gap: 8px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.hoverItem {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: flex-start;
|
|
22
|
+
gap: 8px;
|
|
23
|
+
min-width: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.hoverIcon {
|
|
27
|
+
display: inline-flex;
|
|
28
|
+
flex: none;
|
|
29
|
+
align-items: center;
|
|
30
|
+
height: 16px;
|
|
31
|
+
color: var(--dsw-alias-hovercard-label-tertiary);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.hoverIcon[data-tone='merged'] {
|
|
35
|
+
color: var(--dsw-alias-hovercard-state-done);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.hoverIcon[data-tone='closed'] {
|
|
39
|
+
color: var(--dsw-alias-hovercard-state-error);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.hoverBody {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
min-width: 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.hoverBranch,
|
|
49
|
+
.hoverTitle {
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
color: var(--dsw-alias-hovercard-label-primary);
|
|
52
|
+
font-size: 12px;
|
|
53
|
+
line-height: 16px;
|
|
54
|
+
text-overflow: ellipsis;
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.hoverBranch {
|
|
59
|
+
font-family: var(--ds-font-family-code);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.hoverNote,
|
|
63
|
+
.hoverMore {
|
|
64
|
+
color: var(--dsw-alias-hovercard-label-tertiary);
|
|
65
|
+
font-size: 12px;
|
|
66
|
+
line-height: 16px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.hoverSeparator {
|
|
70
|
+
margin: 0 4px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.hoverNote [data-checks='failure'] {
|
|
74
|
+
color: var(--dsw-alias-hovercard-state-error);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* The state and checks as one phrase for assistive technology, which skips the separator glyph. */
|
|
78
|
+
.visuallyHidden {
|
|
79
|
+
position: absolute;
|
|
80
|
+
width: 1px;
|
|
81
|
+
height: 1px;
|
|
82
|
+
overflow: hidden;
|
|
83
|
+
clip-path: inset(50%);
|
|
84
|
+
white-space: nowrap;
|
|
85
|
+
}
|