diff --git a/apps/web/tests/forge-panel.e2e.ts b/apps/web/tests/forge-panel.e2e.ts index 502e64ea33..df85abc053 100644 --- a/apps/web/tests/forge-panel.e2e.ts +++ b/apps/web/tests/forge-panel.e2e.ts @@ -1142,6 +1142,14 @@ it.skipIf(MODE === 'record')('shows the local changes of the Session by scope an await captureStableAria(page, '[data-composer-input]', scaffold.workspaceCwd), MODE) expect((await readPersistedEvents(scaffold, sessionId)).some(event => event.type === 'user/message' && event.data.content.some(block => block.type === 'text' && block.text.includes('## User Comment')))).toBe(false) + // Removing a reference card leaves its quote in the composer, and the notice's Undo puts the card back at its line. + const extra = local.locator('[data-forge-diff-file="src/extra.ts"]') + await extra.getByRole('button', { name: '评论 R1 的操作', exact: true }).click() + await page.getByRole('menuitem', { name: '移除', exact: true }).click() + await expect.poll(() => extra.locator('[data-forge-review-thread]').count()).toBe(0) + expect(await page.locator('[data-composer-input]').first().innerText()).toContain('请检查这项修改') + await page.getByRole('alert').filter({ hasText: '已移除' }).getByRole('button', { name: '撤销', exact: true }).click() + await extra.locator('[data-forge-review-thread="agent"]').getByText('请检查这项修改', { exact: true }).waitFor() const reviewed = scaffold.whenTurnSettled() await page.locator('[data-composer-input]').first().press('Enter') await reviewed diff --git a/packages/experimental/client-ui-forge/README.i18n.yaml b/packages/experimental/client-ui-forge/README.i18n.yaml index 8c7ce42b15..58ff19d90f 100644 --- a/packages/experimental/client-ui-forge/README.i18n.yaml +++ b/packages/experimental/client-ui-forge/README.i18n.yaml @@ -15,8 +15,8 @@ en: d152484eb41ac6b4 zh: 2f8a621b991260a1 /deepseek-ai-dsh-experimental-client-ui-forge/use-this-package: - en: 2c853cfbae8b7cfd - zh: 82148507cefd6d17 + en: c2b46d13622b98ab + zh: f8b61ca06bc89bc0 /deepseek-ai-dsh-experimental-client-ui-forge/understand-the-implementation: en: 4778e1dca2c6ff47 zh: a8589b3e950a8ca1 diff --git a/packages/experimental/client-ui-forge/README.md b/packages/experimental/client-ui-forge/README.md index 930f903ad5..4e3a6b2c96 100644 --- a/packages/experimental/client-ui-forge/README.md +++ b/packages/experimental/client-ui-forge/README.md @@ -51,7 +51,7 @@ The diff follows the file tree’s depth-first order: directories before files, `gitCommand`, `gitTimeoutMs`, `graceMs`, `maxOutputBytes`, `readinessTimeoutMs`, `maxBranches`, `worktreePrefix`, `maxDiffBytes`, `maxUntrackedFiles`, `maxCachedDiffBytes`, `maxCachedReviewBytes`, `reviewRefreshMs`, `maxCommits`, `testPaths`, `interfacePaths`, `lensTimeoutMs`, `maxLensReadBytes`, `maxCachedLensBytes`, and `maxAnnotationsPerFile` are listed in the [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-experimental-client-ui-forge). -All files opens a searchable directory tree with the selected file scrolled to its middle. Single-child directories share a row, and renamed files also match their old path. A wide changes pane shows the same tree beside the diff; its File tree toolbar button cycles through left, right, and hidden, starting on the left. Its accessible name describes the next action, and focus stays on the button when it moves or hides the tree. The search, folds, selection, and width survive moving or hiding the tree and switching tabs or Sessions. Drag the divider or use its arrow keys to resize the tree, which stays at least as wide as the lens above it needs to show the layer names whole. Files and folders reserve the same disclosure column so each child is indented from its parent. The tree already shows each directory, so only a renamed file names both paths, in a tooltip after 500ms of hover; a name its row clips crawls into view while the pointer rests on the row. Local changes and each PR retain separate tabs. Select code text or use line numbers to select a range within one displayed hunk and side; text selection and copying stay on the starting side. The plus button opens the plain-text comment editor. With a mouse, hovering a line also shows a plus beside its line number, which stays clickable, on the hovered side in two columns and on the line's own side in one column; pressing it selects that line, dragging extends the range on that side, and releasing opens the editor. Several editors can stay open at once, and choosing the range of an open one focuses it again. In two columns, each comment sits under its own side of the row, so a left and a right comment share that row side by side, each continuing its line’s background. It accepts newlines and IME composition; only its action buttons submit the comment. Drag its lower edge to adjust the height. Add to input inserts a removable quote into the main composer that shows the file name, side and lines, and comment, and on hover the file path; multiple quotes are sent together only when the user sends that composer. Once the review threads are read and the user may review, the split button adds the comment to the user's pending review on the code host, starting one when there is none; the comment then shows as a thread tagged Pending, which only the user sees until the review is submitted. Its menu publishes a single comment immediately and is absent while the user has a pending review. Agent references and published comments remain beside their code. Request changes requires a review summary; the dialog explains this beside the summary field and announces the requirement when the decision changes. Submit review in the PR title bar opens a centered dialog showing only the pending count, summary, and Comment, Approve, or Request changes. With a pending review, it submits that review, keeping a submission whose outcome is unknown blocked until the user checks GitHub, as a direct submission is, and Discard review deletes the review and its comments after a confirmation; without one, it publishes the summary as one review. Decisions the code host does not let the user record are unavailable, such as Approve and Request changes on the user's own pull request on GitHub; when only Comment remains, the dialog says so. The view's copy names the code host and its word for a change request, such as GitHub and PR, after the change request's provider. Added and deleted files show only their populated line-number column. The summary, decision, and records of Agent references and published comments are stored in this browser per Session and tab, including the original PR head commit. Switching Sessions or hiding the pane retains them; closing the tab clears them, and reopening starts an empty summary. The pending review, published GitHub comments, and references already added to the main composer are unaffected. Comment drafts an earlier version kept in this browser stay beside their code tagged Browser draft and can be edited, deleted, or added to the pending review; they keep Submit review disabled while a pending review exists, and without one Submit review publishes them with the summary. Records whose code changed remain visible below their file, or after the diff when the file is absent. A changed head requires fresh line selections. While the tab remains open, an uncertain write stays blocked across reloads until the user checks GitHub and explicitly permits another submission. +All files opens a searchable directory tree with the selected file scrolled to its middle. Single-child directories share a row, and renamed files also match their old path. A wide changes pane shows the same tree beside the diff; its File tree toolbar button cycles through left, right, and hidden, starting on the left. Its accessible name describes the next action, and focus stays on the button when it moves or hides the tree. The search, folds, selection, and width survive moving or hiding the tree and switching tabs or Sessions. Drag the divider or use its arrow keys to resize the tree, which stays at least as wide as the lens above it needs to show the layer names whole. Files and folders reserve the same disclosure column so each child is indented from its parent. The tree already shows each directory, so only a renamed file names both paths, in a tooltip after 500ms of hover; a name its row clips crawls into view while the pointer rests on the row. Local changes and each PR retain separate tabs. Select code text or use line numbers to select a range within one displayed hunk and side; text selection and copying stay on the starting side. The plus button opens the plain-text comment editor. With a mouse, hovering a line also shows a plus beside its line number, which stays clickable, on the hovered side in two columns and on the line's own side in one column; pressing it selects that line, dragging extends the range on that side, and releasing opens the editor. Several editors can stay open at once, and choosing the range of an open one focuses it again. In two columns, each comment sits under its own side of the row, so a left and a right comment share that row side by side, each continuing its line’s background. It accepts newlines and IME composition; only its action buttons submit the comment. Drag its lower edge to adjust the height. Add to input inserts a removable quote into the main composer that shows the file name, side and lines, and comment, and on hover the file path; multiple quotes are sent together only when the user sends that composer. Once the review threads are read and the user may review, the split button adds the comment to the user's pending review on the code host, starting one when there is none; the comment then shows as a thread tagged Pending, which only the user sees until the review is submitted. Its menu publishes a single comment immediately and is absent while the user has a pending review. Agent references and published comments remain beside their code as cards that name their lines and state; Remove in a card's menu takes the card out of the view, leaves the main composer and the code host unchanged, and shows a notice that offers Undo. Request changes requires a review summary; the dialog explains this beside the summary field and announces the requirement when the decision changes. Submit review in the PR title bar opens a centered dialog showing only the pending count, summary, and Comment, Approve, or Request changes. With a pending review, it submits that review, keeping a submission whose outcome is unknown blocked until the user checks GitHub, as a direct submission is, and Discard review deletes the review and its comments after a confirmation; without one, it publishes the summary as one review. Decisions the code host does not let the user record are unavailable, such as Approve and Request changes on the user's own pull request on GitHub; when only Comment remains, the dialog says so. The view's copy names the code host and its word for a change request, such as GitHub and PR, after the change request's provider. Added and deleted files show only their populated line-number column. The summary, decision, and records of Agent references and published comments are stored in this browser per Session and tab, including the original PR head commit. Switching Sessions or hiding the pane retains them; closing the tab clears them, and reopening starts an empty summary. The pending review, published GitHub comments, and references already added to the main composer are unaffected. Comment drafts an earlier version kept in this browser stay beside their code tagged Browser draft and can be edited, deleted after a confirmation, or added to the pending review; they keep Submit review disabled while a pending review exists, and without one Submit review publishes them with the summary. Records whose code changed remain visible below their file, or after the diff when the file is absent. A changed head requires fresh line selections. While the tab remains open, an uncertain write stays blocked across reloads until the user checks GitHub and explicitly permits another submission. ----- diff --git a/packages/experimental/client-ui-forge/README.zh.md b/packages/experimental/client-ui-forge/README.zh.md index 8f75e3262f..6e9a50ef69 100644 --- a/packages/experimental/client-ui-forge/README.zh.md +++ b/packages/experimental/client-ui-forge/README.zh.md @@ -51,7 +51,7 @@ diff 按文件树的深度优先顺序排列:同层目录在前、文件在后 `gitCommand`、`gitTimeoutMs`、`graceMs`、`maxOutputBytes`、`readinessTimeoutMs`、`maxBranches`、`worktreePrefix`、`maxDiffBytes`、`maxUntrackedFiles`、`maxCachedDiffBytes`、`maxCachedReviewBytes`、`reviewRefreshMs`、`maxCommits`、`testPaths`、`interfacePaths`、`lensTimeoutMs`、`maxLensReadBytes`、`maxCachedLensBytes` 与 `maxAnnotationsPerFile` 列在[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-experimental-client-ui-forge)中。 -“全部文件”打开可搜索的目录树,并把选中文件滚动到中间;只有一个子目录的路径会合并显示,重命名文件也可以按旧路径搜索。较宽的变更面板会在 diff 旁显示同一棵树,工具栏的“文件树”按钮按“左侧 → 右侧 → 隐藏”循环切换,默认显示在左侧。按钮的无障碍名称说明下一步操作,移动或隐藏文件树时焦点仍留在按钮上。移动或隐藏文件树,以及切换标签页与 Session 时保留搜索、折叠状态、选中文件和宽度。拖动分隔线,或聚焦分隔线后使用方向键,可以调整文件树宽度;文件树至少保持上方透镜完整显示各层名称所需的宽度。文件与文件夹预留相同的展开箭头列,子项相对父目录向内缩进。树已经表示了目录,所以只有重命名的文件会在悬停 500ms 后用提示显示新旧两条路径;文件名放不下时,指针停在这一行上会滚动显示全文。本地变更与每个 PR 保留独立标签页。划选代码文字或通过行号选择同一已显示 hunk、同一侧的连续行,文字划选与复制都限定在起始侧。点击“+”打开纯文本评论框。使用鼠标时,悬停在某一行上也会在其行号旁显示“+”,行号仍可点击:两栏时显示在悬停的一侧,单栏时显示在该行所属的一侧;按下即选中这一行,拖动可在同一侧扩展范围,松开即打开评论框。可以同时打开多个评论框,再次选中已打开评论框的范围会回到该评论框。两栏时每条评论位于该行自己一侧的下方,左右两侧的评论并排处在同一行,各自延续所在行的底色。评论框支持换行和输入法组合输入,只有点击操作按钮才提交。可拖动底边调整高度。“添加到输入框”将评论作为可移除的引用加入主输入框,引用显示文件名、侧与行号以及评论,悬停时显示文件路径;多条引用只会在用户发送主输入框时一起发送。读到评审讨论且用户可以评审时,分段按钮会把这条评论加入用户在代码托管平台上的待提交评审,没有时先开始一个;评论随后显示为带“待提交”标签的讨论,提交评审之前只有用户自己能看到。下拉菜单可以立即发布单条评论;用户有待提交评审时没有该菜单。Agent 引用和已发布的评论保留在对应代码旁。“请求更改”需要填写评审总结,弹窗在总结输入框旁说明此要求,并在切换评审决定时播报。PR 标题栏中的“提交评审”打开居中弹窗,只显示待提交数量、总结以及“评论”“批准”“请求更改”选项。有待提交评审时提交该评审,结果不明的提交与直接提交一样,在用户到 GitHub 核对之前阻止再次提交;“丢弃评审”在确认后删除该评审及其中的评论;没有待提交评审时,把总结作为一次评审发布。代码托管平台不允许用户记录的结论不可用,例如在 GitHub 上用户自己的 PR 里,“批准”和“请求更改”不可用;只剩“评论”时,对话框会说明。视图中的文案按变更请求的提供方称呼代码托管平台及其对变更请求的叫法,例如 GitHub 和 PR。新建和删除文件只显示有内容的一侧行号。总结、评审决定,以及 Agent 引用与已发布评论的记录按 Session 和页签保存在当前浏览器,包括最初评审的 head。切换 Session 或隐藏面板时保留;关闭页签会清空它们,重新打开从空总结开始。待提交评审、已发布到 GitHub 的评论与已加入主输入框的引用不受影响。早期版本保存在此浏览器中的评论草稿保留在对应代码旁,带“浏览器草稿”标签,可以编辑、删除或加入待提交评审;存在待提交评审时,它们会让“提交评审”保持不可用;没有待提交评审时,“提交评审”把它们连同总结一起发布。head 变化后需要重新选择评论行。代码变化后的记录保留在文件末尾;文件已不在 diff 中时,记录显示在 diff 之后。页签保持打开时,结果不明的提交在重新加载后仍会阻止重复发送,直到用户检查 GitHub 并明确允许再次提交。 +“全部文件”打开可搜索的目录树,并把选中文件滚动到中间;只有一个子目录的路径会合并显示,重命名文件也可以按旧路径搜索。较宽的变更面板会在 diff 旁显示同一棵树,工具栏的“文件树”按钮按“左侧 → 右侧 → 隐藏”循环切换,默认显示在左侧。按钮的无障碍名称说明下一步操作,移动或隐藏文件树时焦点仍留在按钮上。移动或隐藏文件树,以及切换标签页与 Session 时保留搜索、折叠状态、选中文件和宽度。拖动分隔线,或聚焦分隔线后使用方向键,可以调整文件树宽度;文件树至少保持上方透镜完整显示各层名称所需的宽度。文件与文件夹预留相同的展开箭头列,子项相对父目录向内缩进。树已经表示了目录,所以只有重命名的文件会在悬停 500ms 后用提示显示新旧两条路径;文件名放不下时,指针停在这一行上会滚动显示全文。本地变更与每个 PR 保留独立标签页。划选代码文字或通过行号选择同一已显示 hunk、同一侧的连续行,文字划选与复制都限定在起始侧。点击“+”打开纯文本评论框。使用鼠标时,悬停在某一行上也会在其行号旁显示“+”,行号仍可点击:两栏时显示在悬停的一侧,单栏时显示在该行所属的一侧;按下即选中这一行,拖动可在同一侧扩展范围,松开即打开评论框。可以同时打开多个评论框,再次选中已打开评论框的范围会回到该评论框。两栏时每条评论位于该行自己一侧的下方,左右两侧的评论并排处在同一行,各自延续所在行的底色。评论框支持换行和输入法组合输入,只有点击操作按钮才提交。可拖动底边调整高度。“添加到输入框”将评论作为可移除的引用加入主输入框,引用显示文件名、侧与行号以及评论,悬停时显示文件路径;多条引用只会在用户发送主输入框时一起发送。读到评审讨论且用户可以评审时,分段按钮会把这条评论加入用户在代码托管平台上的待提交评审,没有时先开始一个;评论随后显示为带“待提交”标签的讨论,提交评审之前只有用户自己能看到。下拉菜单可以立即发布单条评论;用户有待提交评审时没有该菜单。Agent 引用和已发布的评论以卡片保留在对应代码旁,卡片标出行范围和状态;卡片菜单里的“移除”把卡片从视图中去掉,不改动主输入框和代码托管平台,随后的提示提供“撤销”。“请求更改”需要填写评审总结,弹窗在总结输入框旁说明此要求,并在切换评审决定时播报。PR 标题栏中的“提交评审”打开居中弹窗,只显示待提交数量、总结以及“评论”“批准”“请求更改”选项。有待提交评审时提交该评审,结果不明的提交与直接提交一样,在用户到 GitHub 核对之前阻止再次提交;“丢弃评审”在确认后删除该评审及其中的评论;没有待提交评审时,把总结作为一次评审发布。代码托管平台不允许用户记录的结论不可用,例如在 GitHub 上用户自己的 PR 里,“批准”和“请求更改”不可用;只剩“评论”时,对话框会说明。视图中的文案按变更请求的提供方称呼代码托管平台及其对变更请求的叫法,例如 GitHub 和 PR。新建和删除文件只显示有内容的一侧行号。总结、评审决定,以及 Agent 引用与已发布评论的记录按 Session 和页签保存在当前浏览器,包括最初评审的 head。切换 Session 或隐藏面板时保留;关闭页签会清空它们,重新打开从空总结开始。待提交评审、已发布到 GitHub 的评论与已加入主输入框的引用不受影响。早期版本保存在此浏览器中的评论草稿保留在对应代码旁,带“浏览器草稿”标签,可以编辑、确认后删除或加入待提交评审;存在待提交评审时,它们会让“提交评审”保持不可用;没有待提交评审时,“提交评审”把它们连同总结一起发布。head 变化后需要重新选择评论行。代码变化后的记录保留在文件末尾;文件已不在 diff 中时,记录显示在 diff 之后。页签保持打开时,结果不明的提交在重新加载后仍会阻止重复发送,直到用户检查 GitHub 并明确允许再次提交。 ----- diff --git a/packages/experimental/client-ui-forge/src/client/ChangesTab.tsx b/packages/experimental/client-ui-forge/src/client/ChangesTab.tsx index c05b0d3feb..0db33ea710 100644 --- a/packages/experimental/client-ui-forge/src/client/ChangesTab.tsx +++ b/packages/experimental/client-ui-forge/src/client/ChangesTab.tsx @@ -36,7 +36,7 @@ import type { ForgeCommitList, ForgeReviewData, ForgeReviewRequest, ForgeReviewResult, ForgeReviewThread, ForgeReviewWrite, ForgeReviewWriteResult, ForgeThreadId, ForgeViewedFiles, ForgeViewedRequest, } from '@deepseek-ai/dsh-experimental-forge/types' -import { sameReviewSource, type ReviewQueue } from './review-queue.ts' +import { sameReviewSource, type RemovedRecord, type ReviewQueue } from './review-queue.ts' import { ReviewThread, useFileReview } from './ReviewThread.tsx' import type { ReviewActions } from './ReviewComposer.tsx' import { SubmitReview } from './SubmitReview.tsx' @@ -70,7 +70,7 @@ import type { FileThreads, ThreadActions, ThreadFocus, ThreadWrite } from './Rev import { inFileOrder, type ThreadFilter } from './review-threads.ts' import { usePlacedThreads, useThreadRead, type PlacedThread } from './thread-state.ts' import { ThreadList } from './ThreadList.tsx' -import type { HostStream, PanelSnapshot, StreamSnapshot } from './source.ts' +import type { HostStream, NoticeOptions, PanelSnapshot, StreamSnapshot } from './source.ts' import { numberOf, openChangeRequestOf, TONE_LABEL, toneOf } from './status.ts' import css from './ChangesTab.module.css' @@ -149,8 +149,8 @@ export interface ChangesTabInjected { readonly copyPath: (path: string) => void /** Ask the Session's Agent to create a change request for its changes, reporting the outcome. */ readonly createChangeRequest: () => void - /** Show a failure notice. */ - readonly report: (key: ForgePanelKey, params?: Readonly>) => void + /** Show a notice: a failure unless the options name another tone, with the undo action they carry. */ + readonly report: (key: ForgePanelKey, options?: NoticeOptions) => void } /** Full props of the changes tab body. */ @@ -562,8 +562,8 @@ export function ChangesTab({ return message } if (!complete(result.url)) return t('review.unknown') - if (request.kind === 'review') report('review.submitted') - else report('review.published', hostCopy) + if (request.kind === 'review') report('review.submitted', { tone: 'success' }) + else report('review.published', { tone: 'success', params: hostCopy }) if (request.kind === 'review') setReviewOpen(false) return undefined } catch (_error) { @@ -768,7 +768,7 @@ export function ChangesTab({ useEffect(() => { if (withdrawn === null) return actions.filtered(tab.id, null) - report('filterLens.removed', { lens: live.current.lensTitle(withdrawn) }) + report('filterLens.removed', { params: { lens: live.current.lensTitle(withdrawn) } }) }, [withdrawn, actions, tab.id, report]) const chooseLens = (next: string | null): void => { actions.filtered(tab.id, next) } // The hunks each kept file folds stay folded until the reader shows them for that file; a new result folds again. @@ -796,9 +796,9 @@ export function ChangesTab({ const hostOwner = useMemo(() => data?.kind === 'change' && data.viewed !== null ? { url: data.url, headSha: data.headSha, files: data.files, viewed: data.viewed } : null, [data]) const host = useHostViewed(hostOwner, setFileViewed, (failure) => { - if (failure.kind === 'stale') report('viewed.syncStale', hostCopy) - else if (failure.kind === 'unknown') report('viewed.syncUnknown', { message: failure.message }) - else report('viewed.syncFailed', { ...hostCopy, message: failure.message }) + if (failure.kind === 'stale') report('viewed.syncStale', { params: hostCopy }) + else if (failure.kind === 'unknown') report('viewed.syncUnknown', { params: { message: failure.message } }) + else report('viewed.syncFailed', { params: { ...hostCopy, message: failure.message } }) }) const marks = host?.marks ?? localMarks // Files marked viewed at their current change, which the file tree draws subdued. @@ -900,7 +900,7 @@ export function ChangesTab({ return } if (result.ok) report('toast.expandStale') - else report('toast.expandFailed', { message: result.error.message }) + else report('toast.expandFailed', { params: { message: result.error.message } }) update((value) => { const { [path]: _text, ...texts } = value.texts const { [path]: _open, ...open } = value.open @@ -954,7 +954,7 @@ export function ChangesTab({ setReviewError(failure) return } - report(done) + report(done, { tone: 'success' }) setReviewOpen(false) } finally { reviewRunning.current = false @@ -1000,11 +1000,15 @@ export function ChangesTab({ return writeReview(selection.source.url, { kind: 'add-pending', headSha: selection.source.headSha, comment: { path, side, startLine, endLine, body } }) } + /** Report a reference or receipt removed from the view and offer to put it back where it was. */ + const reportRemoved = (removed: RemovedRecord): void => { + report('review.recordRemoved', { tone: 'success', undo: () => { if (!queue.restoreRecord(removed)) report('toast.undoFailed') } }) + } const recordActions: ReviewActions = { source: shownSource ?? (source.kind === 'local' ? { kind: 'local', scope, base: null, baseRef: baseRefOf(localScope), commits: commitsOf(localScope) } : { kind: 'change', url: source.url, headSha: '', commits: changeCommits }), - records: queue, addToInput: addReviewToInput, openLink, + records: queue, addToInput: addReviewToInput, openLink, onRemoved: reportRemoved, } const absentPaths = [...new Set([...reviewState.comments, ...reviewState.records.map(item => item.selection)] .filter(item => sameReviewSource(item.source, recordActions.source)).map(item => item.comment.path))] @@ -1141,7 +1145,7 @@ export function ChangesTab({ // props and state, which the retried render assigns again. const callbacks = { data, expandedByDefault, expand, readContext, markViewed, fileActions, publishReview, writeReview, addPending, report, nextThread, - lensTitle, renderSlot, kept, t, + lensTitle, renderSlot, kept, reportRemoved, t, } const live = useRef(callbacks) live.current = callbacks @@ -1199,6 +1203,7 @@ export function ChangesTab({ renderActions: owner => live.current.renderSlot('forge.diff.comment.actions', { target, ...owner }), records: queue, openLink, reviewStarted, onQuoted: (selection) => { if (!queue.recordAgent(selection)) live.current.report('review.saveFailed') }, + onRemoved: (removed) => { live.current.reportRemoved(removed) }, publishingBlocked, ...queueable ? { queue: (selection: ReviewSelection) => live.current.addPending(selection) } : {}, ...single ? { diff --git a/packages/experimental/client-ui-forge/src/client/ReviewComposer.module.css b/packages/experimental/client-ui-forge/src/client/ReviewComposer.module.css index d79ac0b0e2..5a1a4eb81d 100644 --- a/packages/experimental/client-ui-forge/src/client/ReviewComposer.module.css +++ b/packages/experimental/client-ui-forge/src/client/ReviewComposer.module.css @@ -1,9 +1,8 @@ /* Inline review forms use the same field, action, and badge treatments as settings and conversation controls. */ -.root, .thread { box-sizing: border-box; width: calc(100% - 20px); max-width: 680px; margin: 10px; padding: 12px; border: 0.5px solid var(--dsw-alias-border-l3); border-radius: var(--dsw-radius-md); background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); font: var(--dsw-font-xs-13); font-family: Inter, var(--dsw-font-family); white-space: normal; } -.root { background: var(--dsw-alias-bg-layer-2); border-radius: var(--dsw-radius-lg); } +.root { box-sizing: border-box; width: calc(100% - 20px); max-width: 680px; margin: 10px; padding: 12px; border: 0.5px solid var(--dsw-alias-border-l3); border-radius: var(--dsw-radius-lg); background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); font: var(--dsw-font-xs-13); font-family: Inter, var(--dsw-font-family); white-space: normal; } .root:focus-within { border-color: var(--dsw-alias-border-l4); } /* Side by side, a comment fills its side's cell under the code instead of the row's width. */ -[data-forge-comments] > .root, [data-forge-comments] > .thread { width: auto; max-width: none; margin: 0; } +[data-forge-comments] > .root { width: auto; max-width: none; margin: 0; } .title { margin-bottom: 12px; color: var(--dsw-alias-label-secondary); overflow-wrap: anywhere; } /* Fixed-size textarea layout stays local during typing; native resizing can still change its outer height. */ .input { display: block; box-sizing: border-box; width: 100%; height: 88px; min-height: 88px; contain: strict; padding: 10px 12px; resize: vertical; border: 0.5px solid var(--dsw-alias-border-l4); border-radius: var(--dsw-radius-md); outline: none; background: var(--dsw-alias-bg-layer-3); color: var(--dsw-alias-label-primary); font: inherit; } @@ -16,11 +15,6 @@ .gitAction { display: inline-flex; flex: none; align-items: stretch; } .gitMain { border-start-end-radius: 0; border-end-end-radius: 0; } .gitArrow { width: 30px; padding: 0; border-start-start-radius: 0; border-end-start-radius: 0; border-inline-start: 0.5px solid color-mix(in srgb, var(--dsw-alias-label-primary-foreground) 25%, transparent); } -.threadHeader { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; } -.author { font-weight: 500; } -.range { color: var(--dsw-alias-label-secondary); font-size: 12px; } -.commentBody { white-space: pre-wrap; overflow-wrap: anywhere; } -.threadActions { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px -8px -4px; } .gutter { position: relative; } .line { display: block; width: 100%; height: 100%; padding: 0; color: inherit; text-align: inherit; cursor: pointer; border: 0; border-radius: 0; background: transparent; font: inherit; user-select: none; touch-action: pan-y; } .selected { background: var(--dsw-alias-interactive-bg-hover); outline: 1px solid var(--dsw-alias-border-l2); outline-offset: -1px; } diff --git a/packages/experimental/client-ui-forge/src/client/ReviewComposer.tsx b/packages/experimental/client-ui-forge/src/client/ReviewComposer.tsx index 843b307aff..6c0f1de869 100644 --- a/packages/experimental/client-ui-forge/src/client/ReviewComposer.tsx +++ b/packages/experimental/client-ui-forge/src/client/ReviewComposer.tsx @@ -4,7 +4,7 @@ import { useEffect, useRef, useState, type ReactNode } from 'react' import clsx from 'clsx' import { Button, IconChevronDownOutlineRegular, Menu, MenuItemButton } from '@deepseek-ai/dsh-client-ui-primitives' import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots' -import type { ReviewQueue } from './review-queue.ts' +import type { RemovedRecord, ReviewQueue } from './review-queue.ts' import { reviewRange, type ReviewSelection, type ReviewSource } from './review.ts' import type { NS } from './locales.ts' import type { ForgeCommentActionsProps } from './slots.ts' @@ -26,6 +26,8 @@ export interface ReviewActions { readonly addToInput: (selection: ReviewSelection) => boolean /** Retain a new comment after its quote was accepted. */ readonly onQuoted?: (selection: ReviewSelection) => void + /** Report a reference or publication receipt the reader removed from the view, so the report can offer to put it back. */ + readonly onRemoved?: (removed: RemovedRecord) => void /** Publish one comment; an error string preserves the editor. */ readonly publish?: (selection: ReviewSelection) => Promise /** Add one comment to the pending review on the code host, starting one when needed; an error string preserves the editor. */ diff --git a/packages/experimental/client-ui-forge/src/client/ReviewThread.tsx b/packages/experimental/client-ui-forge/src/client/ReviewThread.tsx index b7f2f818a5..6917585d13 100644 --- a/packages/experimental/client-ui-forge/src/client/ReviewThread.tsx +++ b/packages/experimental/client-ui-forge/src/client/ReviewThread.tsx @@ -4,10 +4,12 @@ import { useCallback, useState, useSyncExternalStore, type ReactNode } from 'rea import { Button, Tag } from '@deepseek-ai/dsh-client-ui-primitives' import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots' import type { ReviewActions } from './ReviewComposer.tsx' +import { CardMenu, DeleteConfirm } from './ReviewThreads.tsx' import { EMPTY_FILE_REVIEW, type FileReviewState, type ReviewThread as Thread } from './review-queue.ts' import { reviewRange } from './review.ts' import type { NS } from './locales.ts' -import css from './ReviewComposer.module.css' +import css from './ReviewThreads.module.css' +import composerCss from './ReviewComposer.module.css' const noSubscription = (): (() => void) => () => {} @@ -24,7 +26,9 @@ export function useFileReview(actions: ReviewActions | undefined, path: string): } /** - * Render a saved comment at its line. A comment draft kept in the browser can be edited, deleted, or moved into the + * Render a saved comment at its line: its lines and state, the menu of its less frequent actions, its text, and Add to + * input. A reference or a publication receipt can be removed from the view, which leaves the main input and the code + * host as they are. A comment draft kept in the browser can be edited, deleted after a confirmation, or moved into the * pending review on the code host. * @param props - record, edit availability, source actions, and localized copy. * @returns one compact inline comment card. @@ -35,16 +39,20 @@ export function ReviewThread({ thread, actions, locked, outdated, t }: PropsLoca readonly locked: boolean readonly outdated: boolean }): ReactNode { - const [editing, setEditing] = useState(false) + const [mode, setMode] = useState<'view' | 'edit' | 'delete'>('view') const [body, setBody] = useState(thread.selection.comment.body) const [error, setError] = useState(null) const [moving, setMoving] = useState(false) const comment = thread.selection.comment - const quoted = editing && thread.kind === 'pending' ? { ...thread.selection, comment: { ...comment, body } } : thread.selection + // A draft published while its form is open becomes a receipt, which has neither form. + const editing = mode === 'edit' && thread.kind === 'pending' + const confirming = mode === 'delete' && thread.kind === 'pending' + const quoted = editing ? { ...thread.selection, comment: { ...comment, body } } : thread.selection const range = reviewRange(comment) const status = thread.kind === 'pending' ? 'review.browserDraft' : thread.kind === 'published' ? 'review.published' : 'review.quoted' const save = (): boolean => actions.records?.editThread(thread.key, body) === true const queue = actions.queue + const waiting = locked || moving /** Add the draft to the pending review on the code host, then delete it from the browser. */ const move = async (add: NonNullable): Promise => { setMoving(true) @@ -59,37 +67,53 @@ export function ReviewThread({ thread, actions, locked, outdated, t }: PropsLoca setMoving(false) } } - return
-
- {t('review.yourComment')} - {range} - {t(outdated ? 'review.outdated' : status)} + const select = (id: string): void => { + if (id === 'edit') { + setBody(comment.body) + setMode('edit') + } else if (id === 'delete') setMode('delete') + else { + const removed = actions.records?.removeRecord(thread.key) ?? null + if (removed === null) setError(t('review.saveFailed')) + else actions.onRemoved?.(removed) + } + } + return
+
+
+ {range} + {t(status)} + {outdated && {t('review.outdated')}} +
+ {!confirming && }
- {editing && thread.kind === 'pending' - ?