fix(forge): address check states and review accessibility

This commit is contained in:
Yichen Jiang committed 2026-10-28 17:45:32 +08:00
1 parent 2cb769b430
commit 2d709ab5be
26 files changed
+150 -74

No files matched your search

@@ -8,7 +8,7 @@
- button "全部折叠"
- button "左右对比" [pressed]
- button "自动换行" [pressed]
- button "文件树" [expanded] [pressed]
- button "将文件树移到右侧" [expanded]
- region "全部 2 个文件":
- button "收起 panel.ts" [expanded]
- text: src/panel.ts +2 −2
@@ -1,6 +1 @@
- button "工作区文件 浏览会话工作区的文件 ⌥ ⌘ P"
- button "代码审查和变更 查看代码变更与本会话的变更请求"
- button "新建终端 在会话工作区运行命令"
- button "选择 Shell"
- text: "⌃ `"
- button "更多工具"
@@ -3,7 +3,7 @@
- button "关闭"
- text: 待提交评论(1)
- textbox "评审总结…"
- text: 请求更改时,请填写评审总结
- status: 请求更改时,请填写评审总结
- radio "评论"
- text: 评论
- radio "批准"
@@ -3,7 +3,7 @@
- button "关闭"
- text: 待提交评论(1)
- textbox "评审总结…": 需要补充边界检查
- text: 请求更改时,请填写评审总结
- status: 请求更改时,请填写评审总结
- radio "评论"
- text: 评论
- radio "批准"
+12 -12
View File
@@ -114,7 +114,7 @@ if (args[0] === 'auth' && args[1] === 'status') {
if (args[0] === 'api' && args[1] === 'graphql') {
const query = args.find(arg => arg.startsWith('query=')).slice('query='.length)
const check = (name, conclusion, completedAt, databaseId = 101) => ({
__typename: 'CheckRun', name, status: 'COMPLETED', conclusion, databaseId,
__typename: 'CheckRun', id: 'check-' + databaseId, name, status: 'COMPLETED', conclusion, databaseId,
detailsUrl: 'https://github.com/octo/demo/actions/runs/1', startedAt: '2026-10-09T00:00:00Z', completedAt,
checkSuite: { app: { id: 'github-actions' }, workflowRun: { event: 'pull_request', workflow: { id: 'ci', name: 'CI' } } },
})
@@ -637,7 +637,7 @@ it.skipIf(MODE === 'record')('shows the local changes of the Session by scope an
const guide = page.locator('[data-sidebar-right-guide]')
await guide.getByRole('button', { name: /^代码审查和变更/ }).waitFor()
await compareOrRefreshGolden(join(EXPECTED, 'review-guide.expected.md'),
await captureStableAria(page, '[data-sidebar-right-guide]', scaffold.workspaceCwd), MODE)
await captureStableAria(page, '[data-sidebar-right-guide-entry="forge-panel"]', scaffold.workspaceCwd), MODE)
await guide.getByRole('button', { name: /^代码审查和变更/ }).click()
// The New Session screen inspected the checkout before these changes, which came from outside the Session.
await page.locator('[data-forge-panel]').getByRole('button', { name: '刷新状态', exact: true }).click()
@@ -733,26 +733,26 @@ it.skipIf(MODE === 'record')('shows the local changes of the Session by scope an
await fileTree.getByRole('textbox', { name: '筛选文件…' }).fill('src')
await fileTree.getByRole('textbox', { name: '筛选文件…' }).fill('')
await fileTree.getByRole('button', { name: 'src', exact: true }).click()
await view.getByRole('button', { name: '文件树', exact: true }).click()
await view.getByRole('button', { name: /^(将文件树移到右侧|隐藏文件树|在左侧显示文件树)$/ }).click()
expect(await treeIsLeft()).toBe(false)
expect(await fileTree.getByRole('button', { name: 'src', exact: true }).getAttribute('aria-expanded')).toBe('false')
await page.setViewportSize({ width: 390, height: 844 })
expect(await fileTree.isVisible()).toBe(false)
expect(await view.getByRole('button', { name: '文件树', exact: true }).isVisible()).toBe(false)
expect(await view.getByRole('button', { name: /^(将文件树移到右侧|隐藏文件树|在左侧显示文件树)$/ }).isVisible()).toBe(false)
await view.getByRole('button', { name: '全部 2 个文件', exact: true }).click()
await page.getByRole('menu').getByRole('textbox', { name: '筛选文件…' }).waitFor()
await page.keyboard.press('Escape')
await page.setViewportSize({ width: 1680, height: 1000 })
expect(await treeIsLeft()).toBe(false)
await view.getByRole('button', { name: '文件树', exact: true }).click()
await view.getByRole('button', { name: /^(将文件树移到右侧|隐藏文件树|在左侧显示文件树)$/ }).click()
expect(await fileTree.isVisible()).toBe(false)
await view.getByRole('button', { name: '文件树', exact: true }).click()
await view.getByRole('button', { name: /^(将文件树移到右侧|隐藏文件树|在左侧显示文件树)$/ }).click()
expect(await treeIsLeft()).toBe(true)
expect(await fileTree.getByRole('button', { name: 'src', exact: true }).getAttribute('aria-expanded')).toBe('false')
await fileTree.getByRole('textbox', { name: '筛选文件…' }).fill('src')
await view.getByRole('button', { name: '文件树', exact: true }).click()
await view.getByRole('button', { name: '文件树', exact: true }).click()
await view.getByRole('button', { name: '文件树', exact: true }).click()
await view.getByRole('button', { name: /^(将文件树移到右侧|隐藏文件树|在左侧显示文件树)$/ }).click()
await view.getByRole('button', { name: /^(将文件树移到右侧|隐藏文件树|在左侧显示文件树)$/ }).click()
await view.getByRole('button', { name: /^(将文件树移到右侧|隐藏文件树|在左侧显示文件树)$/ }).click()
expect(await fileTree.getByRole('textbox', { name: '筛选文件…' }).inputValue()).toBe('src')
await compareOrRefreshGolden(join(EXPECTED, 'file-tree-toggle.expected.md'),
await captureStableAria(page, '[data-forge-changes="change"]', scaffold.workspaceCwd), MODE)
@@ -775,7 +775,7 @@ it.skipIf(MODE === 'record')('shows the local changes of the Session by scope an
expect(searchBounds.x + searchBounds.width).toBeLessThanOrEqual(treeBounds.x + treeBounds.width)
await resizeTree.press('ArrowRight')
const resizedWidth = await resizeTree.getAttribute('aria-valuenow')
await view.getByRole('button', { name: '文件树', exact: true }).click()
await view.getByRole('button', { name: /^(将文件树移到右侧|隐藏文件树|在左侧显示文件树)$/ }).click()
expect(await treeIsLeft()).toBe(false)
expect(await resizeTree.getAttribute('aria-valuenow')).toBe(resizedWidth)
await resizeTree.press('ArrowLeft')
@@ -789,8 +789,8 @@ it.skipIf(MODE === 'record')('shows the local changes of the Session by scope an
await page.mouse.up()
expect(Number(await resizeTree.getAttribute('aria-valuenow'))).toBeGreaterThan(Number(resizedWidth))
const rightWidth = await resizeTree.getAttribute('aria-valuenow')
await view.getByRole('button', { name: '文件树', exact: true }).click()
await view.getByRole('button', { name: '文件树', exact: true }).click()
await view.getByRole('button', { name: /^(将文件树移到右侧|隐藏文件树|在左侧显示文件树)$/ }).click()
await view.getByRole('button', { name: /^(将文件树移到右侧|隐藏文件树|在左侧显示文件树)$/ }).click()
expect(await resizeTree.getAttribute('aria-valuenow')).toBe(rightWidth)
for (const side of ['old', 'new'] as const) {
const firstLine = await panelFile.locator(`[data-review-code][data-${side}-line="2"]`).boundingBox()
@@ -15,8 +15,8 @@
en: d152484eb41ac6b4
zh: 2f8a621b991260a1
/deepseek-ai-dsh-experimental-client-ui-forge/use-this-package:
en: 53b49373e7f41cb0
zh: 4d404e7e87d90604
en: c9d6c3593afe51b3
zh: 076b162b200beb92
/deepseek-ai-dsh-experimental-client-ui-forge/understand-the-implementation:
en: 013e84157a09da7e
zh: cd9f1232acfe4783
@@ -35,7 +35,7 @@ Panel text follows the application language: Chinese, English, Japanese, Spanish
- **Code review and changes** — on the right-sidebar start page, opens the same change request tab as the Session header button.
- **Header button** — appears when the Session has bound change requests or its directory is inside a Git checkout, and shows or hides the tab. A red dot marks an open change request with failed checks, requested changes, or conflicts.
- **Session list** — after a Session row's time, a branch glyph shows while the Session works in the worktree the panel created for it, and a glyph shows the state of its most urgent change request: one needing attention first, then open, draft, not yet polled, merged, and closed. The glyph of an open change request keeps the row's subdued color with a dot for running, passed, or failed checks; merged and closed ones keep their state colors. The row's hover card names the worktree branch and what it started from, then up to three change requests with their number, title, state, and checks, and how many more there are. A restart shows the states known before it until the next poll.
- **Tab** — the first row names the checked-out branch, or the abbreviated commit on a detached HEAD, after a folder glyph for the project directory or a branch glyph for a worktree, and the kind of checkout, which is the worktree the Session created with its base, another worktree, or the project directory; its tooltip adds the path with the Host home shortened to `~`, its button copies the full path, and for a removed worktree it offers Restore. Below it, each change request card shows a glyph for its state, its title, which opens it in the browser, and its number; the glyph tells open, draft, merged, and closed apart, and marks an open one that is not a draft with failed checks, requested changes, or conflicts as needing attention, as the header button's red dot does. The card's header also offers Open in browser, Copy change request link, and Remove from this Session, whose toast offers Undo. A collapsed card adds the checks of an open change request and the most urgent of requested changes, conflicts, or draft, or when a merged or closed one ended. An expanded card shows the head and base branches, then one row per fact: for an open change request the checks, whose row opens the list of checks with failed ones first and their durations and links, the review decision with unresolved threads, and the merge state, or when a merged or closed one ended; and the changed lines, formatted in the selected UI language, whose row opens the changes view. An open draft also offers Ready for review; a change request the host would merge now offers Merge, whose menu lists the methods the repository allows with the user's usual one chosen and pins the displayed head when opened. Confirm merge uses that head; a polled head change disables confirmation until the menu is reopened after review. A toast reports each outcome, and new commits since that head stop the merge. When exactly one bound change request is open, its card starts expanded. Refresh inspects the checkout, checks sign-in, and polls every change request again; its icon turns until the inspection and the sign-in check end. A banner shows the `gh auth login` command when sign-in is missing.
- **Tab** — the first row names the checked-out branch, or the abbreviated commit on a detached HEAD, after a folder glyph for the project directory or a branch glyph for a worktree, and the kind of checkout, which is the worktree the Session created with its base, another worktree, or the project directory; its tooltip adds the path with the Host home shortened to `~`, its button copies the full path, and for a removed worktree it offers Restore. Below it, each change request card shows a glyph for its state, its title, which opens it in the browser, and its number; the glyph tells open, draft, merged, and closed apart, and marks an open one that is not a draft with failed checks, requested changes, or conflicts as needing attention, as the header button's red dot does. The card's header also offers Open in browser, Copy change request link, and Remove from this Session, whose toast offers Undo. Cancelled checks have a separate count; a collapsed card names cancellations when no listed check failed. A collapsed card adds the checks of an open change request and the most urgent of requested changes, conflicts, or draft, or when a merged or closed one ended. An expanded card shows the head and base branches, then one row per fact: for an open change request the checks, whose row opens the list of checks with failed ones first and their durations and links, the review decision with unresolved threads, and the merge state, or when a merged or closed one ended; and the changed lines, formatted in the selected UI language, whose row opens the changes view. An open draft also offers Ready for review; a change request the host would merge now offers Merge, whose menu lists the methods the repository allows with the user's usual one chosen and pins the displayed head when opened. Confirm merge uses that head; a polled head change disables confirmation until the menu is reopened after review. A toast reports each outcome, and new commits since that head stop the merge. When exactly one bound change request is open, its card starts expanded. Refresh inspects the checkout, checks sign-in, and polls every change request again; its icon turns until the inspection and the sign-in check end. A banner shows the `gh auth login` command when sign-in is missing.
- **Local changes card** — while the `branch` scope changes files and no open change request has the checked-out branch as its head, a card above the change requests names the ref it compares with, such as `HEAD → origin/main`, and shows the added and deleted lines and the number of files, which open the changes view; its file list, which names files as the changes view does, opens the view at one file. Create change request, offered once the code host repository is recognized, sends the Session a user message in the UI language that asks the Agent to create a change request for these changes, and a toast reports whether it was sent.
- **Changes view** — The Changes row of an expanded change request card and the local changes card open a right-sidebar tab that lists the changed files. The local tab is named Local changes and shows Branch by default: the working tree and untracked files against the fork point, which is the base commit of the worktree the Session created, else the merge base of HEAD with the default branch of the code host remote. Uncommitted compares them with HEAD, Unstaged with the index, and Staged compares the index with HEAD. A change request view shows the host's diff at its head and says how many commits the checked-out branch has beyond that head when it is the change request's head branch. The toolbar jumps to a file, totals the changed lines, refreshes, and switches between two columns and one and between wrapped and cut long lines. Visited changes tabs stay mounted across tab and Session switches, hiding the sidebar, and docking changes, preserving file folds, revealed large files, expanded context, layout, and scroll position while the diff is unchanged. Hidden changes views release their panel subscription and defer diff reads; returning reads again only when the latest head or local summary differs. A refresh that replaces the diff discards expanded context, and changed content may move the reading position. Temporary menus close when the view is hidden. Closing the tab or reloading the application discards this progress. Files are named before their directories, which use smaller subdued type and shorten first; hovering one shows its complete path, and both paths for a renamed file. Each file shows badges for a new, deleted, or renamed file, the last naming the old file name, or the old path when only the directory changed, and, in the Branch scope, an untracked one, and a menu that copies its path and opens the whole file in the sidebar for local changes or its page at the head in the browser for a change request. Unchanged lines between hunks collapse into rows that expand from the file's new side: the working tree, the index for Staged, or the head commit through the code host; a file that changed after the diff was read stays collapsed until the view reads again. A binary file and an untracked file over `maxDiffBytes` show a note instead of their lines, a file whose hunks draw more than 1,000 lines starts as one collapsed strip that names its changed lines and draws them when opened, and a file below files that change more than 5,000 lines starts collapsed. The view reads again on Refresh and the page refresh shortcut, on each navigation, when the change request's head moves, and when the Branch scope's summary changes; a change request's view first waits for the status that names its head, unless no provider serves it or that poll failed. While a read replaces changes already shown, the Refresh icon turns. A change request whose diff the code host or its provider refuses over a size limit, such as a GitHub diff over 300 files, says its changes are too large to show here and offers View in browser; another failed read offers Retry and, for a change request, View in browser. A change request's diff is downloaded once per head commit and base branch while it stays cached, so reopening, refreshing, and navigating at the same head read nothing from the host.
@@ -43,7 +43,7 @@ Click the diff content to focus it. Left and Right move to the previous and next
`gitCommand`, `gitTimeoutMs`, `graceMs`, `maxOutputBytes`, `readinessTimeoutMs`, `maxBranches`, `worktreePrefix`, `maxDiffBytes`, `maxUntrackedFiles`, and `maxCachedDiffBytes` are listed in the [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-experimental-client-ui-forge).
All files opens a searchable directory tree. 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. 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. Files and folders reserve the same disclosure column so each child is indented from its parent. 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. 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; multiple quotes are sent together only when the user sends that composer. The GitHub split button starts or adds to a pending review; its menu publishes a single comment immediately. Comments remain beside their code after quoting, queueing, or publishing. Pending comments are edited or removed there. Request changes requires a review summary; the dialog explains this beside the summary field. Submit review in the PR title bar opens a centered dialog showing only the pending count, summary, and Comment, Approve, or Request changes. Added and deleted files show only their populated line-number column. Pending reviews and comment records 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 its comments, summary, and decision, and reopening starts an empty review. Published GitHub comments and references already added to the main composer are unaffected. 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. 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. Files and folders reserve the same disclosure column so each child is indented from its parent. 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. 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; multiple quotes are sent together only when the user sends that composer. The GitHub split button starts or adds to a pending review; its menu publishes a single comment immediately. Comments remain beside their code after quoting, queueing, or publishing. Pending comments are edited or removed there. 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. Added and deleted files show only their populated line-number column. Pending reviews and comment records 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 its comments, summary, and decision, and reopening starts an empty review. Published GitHub comments and references already added to the main composer are unaffected. 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.
-----
@@ -32,10 +32,10 @@ kind: "package-reference"
- **工作树选项**——在新会话页面上,“新建工作树”与当前分支一起位于工作区与模式选择器那一行的右端。不在 Git 检出中时,两者均隐藏。分支默认为只读展示;勾选“新建工作树”后,它变为基准分支选择器,菜单列出最近的本地分支。权限阻止已有请求时,仍只读显示已选基准,并允许取消请求。悬停、聚焦或轻点只读分支或基准会显示完整说明。Session 为只读,或检出及其 Git 目录不在 Session 的可写根内(例如项目本身就是链接 worktree)时,该选项不可用,提示中说明原因。发送第一条消息后,消息立即交给 Session 并在那里等待,同时从基准分支在仓库的 `.agents/worktrees/` 下创建分支 `dsh-<Session id 前 8 位十六进制数>-<4 位随机十六进制数>`,并把它的检出设为 Session 的工作目录;worktree 建好后这条消息的这一轮才开始。
- **创建卡片**——创建 worktree 期间,输入框上方的卡片显示新分支以及“创建分支”“检出文件”两个步骤;“更多详情”会列出分支与基准。“取消”停止这次尝试。尝试被停止或失败后,消息继续等待,失败时卡片显示原因:“重试”换一个新分支名再试;“不使用工作树”撤回请求,消息在当前检出中继续发送。
- **工作树已被删除**——Session 所在的 worktree 在 Session 之外被删除后,输入框上方的卡片会说明这一点;此期间发送的消息会等待、不开始这一轮,直到该 worktree 被恢复或离开,卡片也会说明消息之后会接着发送。“恢复工作树”(标签页中的“恢复”与之相同)在原目录重新检出该分支;分支也已删除时,从它开始时的提交重新创建分支;恢复期间卡片显示“准备工作树”“检出文件”两个步骤,标签页中的“恢复”变为加载状态。“在项目目录继续”把 Session 移回源检出。此期间标签页顶部一行显示警示图标。
- **代码审查和变更** — 右侧栏起始页中的入口,与会话标题栏按钮打开同一个变更请求标签页。
- **代码审查和变更**——右侧栏起始页中的入口,与会话标题栏按钮打开同一个变更请求标签页。
- **标题栏按钮**——Session 有已绑定的变更请求、或其目录位于 Git 检出中时出现,用来显示或隐藏标签页。打开状态的变更请求存在检查失败、被要求修改或冲突时,按钮带红点。
- **会话列表**——Session 在面板为它创建的 worktree 中工作时,会话行的时间之后显示分支图标;另有一个图标显示它最需要关注的变更请求的状态,依次为需要处理、打开、草稿、尚未轮询、已合并、已关闭。打开中的变更请求图标保持会话行的浅色,并用圆点标出检查进行中、已通过或失败;已合并与已关闭的保留各自的状态颜色。会话行的悬浮卡片写出 worktree 分支及其起点,再列出最多三个变更请求的编号、标题、状态与检查,并说明还有多少个。重启后,下次轮询之前显示重启前已知的状态。
- **标签页**——顶部一行显示当前检出的分支(分离 HEAD 时为缩写提交),项目目录前显示目录图标、worktree 前显示分支图标,并说明检出的类型(Session 创建的 worktree 及其基准、其他 worktree 或项目目录);它的提示给出路径,宿主主目录缩写为 `~`,旁边的按钮复制完整路径;worktree 已被删除时提供“恢复”。其下每张变更请求卡片显示状态图标、标题(点击在浏览器中打开)与编号;图标区分打开、草稿、已合并与已关闭,打开中的变更请求(草稿除外)检查失败、被要求修改或有冲突时显示为“需要处理”,与标题栏按钮的红点一致。卡片右上角还提供“在浏览器中打开”“复制变更请求链接”与“从本会话移除”,移除后的 toast 提供“撤销”。折叠的卡片还显示打开的变更请求的检查,以及被要求修改、冲突、草稿中最需要注意的一项;已合并或已关闭的则显示结束时间。展开的卡片显示源分支与目标分支,下面每项一行:打开的变更请求依次是检查(点击该行弹出检查列表,失败的排在前面,带耗时与链接)、评审结论与未解决讨论数、合并状态,已合并或已关闭的显示结束时间;最后是按所选界面语言格式化的变更行数,点击该行打开变更视图。打开中的草稿还提供“标记为可评审”;主机现在就会合并的变更请求提供“合并”,其菜单列出仓库允许的合并方式并选中用户常用的一种,打开时固定卡片显示的 head。“确认合并”使用这个 head;轮询发现 head 变化后禁用确认,需重新检查并打开菜单。每次操作的结果都以 toast 报告;该 head 之后有新提交时不会合并。恰好有一个已绑定的变更请求处于打开状态时,它的卡片默认展开。刷新会重新检查检出与登录状态,并立即再次轮询每个变更请求;检查与登录状态确认结束前,刷新图标持续旋转。缺少登录时,横幅显示 `gh auth login` 命令。
- **标签页**——顶部一行显示当前检出的分支(分离 HEAD 时为缩写提交),项目目录前显示目录图标、worktree 前显示分支图标,并说明检出的类型(Session 创建的 worktree 及其基准、其他 worktree 或项目目录);它的提示给出路径,宿主主目录缩写为 `~`,旁边的按钮复制完整路径;worktree 已被删除时提供“恢复”。其下每张变更请求卡片显示状态图标、标题(点击在浏览器中打开)与编号;图标区分打开、草稿、已合并与已关闭,打开中的变更请求(草稿除外)检查失败、被要求修改或有冲突时显示为“需要处理”,与标题栏按钮的红点一致。卡片右上角还提供“在浏览器中打开”“复制变更请求链接”与“从本会话移除”,移除后的 toast 提供“撤销”。已取消的检查单独计数;列出的检查没有失败项时,折叠卡片显示取消数量。折叠的卡片还显示打开的变更请求的检查,以及被要求修改、冲突、草稿中最需要注意的一项;已合并或已关闭的则显示结束时间。展开的卡片显示源分支与目标分支,下面每项一行:打开的变更请求依次是检查(点击该行弹出检查列表,失败的排在前面,带耗时与链接)、评审结论与未解决讨论数、合并状态,已合并或已关闭的显示结束时间;最后是按所选界面语言格式化的变更行数,点击该行打开变更视图。打开中的草稿还提供“标记为可评审”;主机现在就会合并的变更请求提供“合并”,其菜单列出仓库允许的合并方式并选中用户常用的一种,打开时固定卡片显示的 head。“确认合并”使用这个 head;轮询发现 head 变化后禁用确认,需重新检查并打开菜单。每次操作的结果都以 toast 报告;该 head 之后有新提交时不会合并。恰好有一个已绑定的变更请求处于打开状态时,它的卡片默认展开。刷新会重新检查检出与登录状态,并立即再次轮询每个变更请求;检查与登录状态确认结束前,刷新图标持续旋转。缺少登录时,横幅显示 `gh auth login` 命令。
- **本地变更卡片**——`branch` 范围有文件变更、且没有以当前检出分支为源分支的打开中变更请求时,变更请求列表上方的卡片显示比较的基准(例如 `HEAD → origin/main`)以及新增、删除行数与文件数,点击打开变更视图;展开的文件列表像变更视图一样标出各个文件,点击某个文件时,变更视图定位到该文件。识别出代码托管仓库后,卡片提供“创建变更请求”:它以界面语言向 Session 发送一条用户消息,请 Agent 为这些变更创建变更请求,并以 toast 报告是否已发送。
- **变更视图**——展开的变更请求卡片上的“变更”一行与本地变更卡片会打开一个右侧边栏标签页,列出所有变更的文件。本地标签页名为“本地变更”,默认显示“分支”:工作树与未跟踪文件相对于分叉点的变更;分叉点是 Session 创建的 worktree 的基准提交,否则是 HEAD 与代码托管远端默认分支的合并基准。“未提交”与 HEAD 比较,“未暂存”与暂存区比较,“已暂存”比较暂存区与 HEAD。变更请求的视图显示托管平台在其 head 处的 diff;当前检出分支就是该变更请求的源分支时,还会说明本地分支比该 head 多出几个提交。工具栏可以跳到某个文件、汇总变更行数、刷新,并在左右对比与单栏对比、自动换行与截断长行之间切换。访问过的变更标签页会在切换标签页与 Session、隐藏侧边栏及调整停靠位置时保持挂载,在 diff 未改变时保留文件折叠、大文件展开、上下文展开、布局与滚动位置。隐藏的变更视图释放面板订阅并推迟 diff 读取;返回时仅在最新 head 或本地摘要不同时重新读取。刷新替换 diff 后会丢弃展开的上下文,内容变化也可能移动阅读位置。视图隐藏时关闭临时菜单。关闭标签页或重新加载应用后不保留这些进度。文件名在前,目录在后,用更小的浅色字显示,空间不够时目录先缩短;悬停时显示完整路径,重命名的文件显示新旧两条路径。每个文件带有新文件、已删除、重命名的标记(重命名标记写出原文件名,只换了目录时写出原路径),“分支”范围下的未跟踪文件还标“未提交”;文件菜单可以复制路径,本地变更可在侧边栏打开整个文件,变更请求可在浏览器中查看该文件在 head 处的页面。hunk 之间未变更的行折叠成一行,点击后从文件的新版本展开:工作树、“已暂存”时为暂存区,或经托管平台读取的 head 提交;读取 diff 之后文件又有修改时不会展开,直到视图重新读取。二进制文件与超过 `maxDiffBytes` 的未跟踪文件只显示一条说明;hunk 超过 1,000 行的文件先显示为一条写出变更行数的折叠条,点击后才绘制;前面的文件累计变更超过 5,000 行后,其后的文件默认收起。刷新与页面刷新快捷键、每次导航、变更请求的 head 变化,以及“分支”范围的摘要变化时,视图都会重新读取;变更请求的视图会先等到给出 head 的状态再读取,除非没有提供方服务它或那次轮询失败。重新读取已显示的变更时,刷新图标会旋转。托管平台或其提供方因超过大小上限拒绝给出 diff 的变更请求(例如 GitHub 上超过 300 个文件的 diff)显示“变更太大,无法在这里显示”并提供“在浏览器中查看”;其他读取失败提供“重试”,变更请求还提供“在浏览器中查看”。变更请求的 diff 在缓存期间对每个 head 提交与目标分支只下载一次,因此在同一 head 下重新打开、刷新与导航都不会再从托管平台读取。
@@ -43,7 +43,7 @@ kind: "package-reference"
`gitCommand`、`gitTimeoutMs`、`graceMs`、`maxOutputBytes`、`readinessTimeoutMs`、`maxBranches`、`worktreePrefix`、`maxDiffBytes`、`maxUntrackedFiles` 与 `maxCachedDiffBytes` 列在[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-experimental-client-ui-forge)中。
“全部文件”打开可搜索的目录树;只有一个子目录的路径会合并显示,重命名文件也可以按旧路径搜索。较宽的变更面板会在 diff 旁显示同一棵树,工具栏的“文件树”按钮按“左侧 → 右侧 → 隐藏”循环切换,默认显示在左侧。移动或隐藏文件树,以及切换标签页与 Session 时保留搜索、折叠状态、选中文件和宽度。拖动分隔线,或聚焦分隔线后使用方向键,可以调整文件树宽度。文件与文件夹预留相同的展开箭头列,子项相对父目录向内缩进。本地变更与每个 PR 保留独立标签页。划选代码文字或通过行号选择同一已显示 hunk、同一侧的连续行,文字划选与复制都限定在起始侧。点击“+”才打开纯文本评论框。评论框支持换行和输入法组合输入,只有点击操作按钮才提交。可拖动底边调整高度。“添加到输入框”将评论作为可移除的引用加入主输入框,多条引用只会在用户发送主输入框时一起发送。GitHub 分段按钮用于开始或加入待提交评审,下拉菜单可以立即发布单条评论。评论在引用、暂存或发布后保留在对应代码旁,暂存评论可在那里编辑或删除。“请求更改”需要填写评审总结,弹窗在总结输入框旁说明此要求。PR 标题栏中的“提交评审”打开居中弹窗,只显示待提交数量、总结以及“评论”“批准”“请求更改”选项。新建和删除文件只显示有内容的一侧行号。待提交评审与评论记录按 Session 和页签保存在当前浏览器,包括最初评审的 head。切换 Session 或隐藏面板时保留;关闭页签会清空该页签的评论、总结与评审决定,重新打开从空评审开始。已发布到 GitHub 的评论与已加入主输入框的引用不受影响。head 变化后需要重新选择评论行。代码变化后的记录保留在文件末尾;文件已不在 diff 中时,记录显示在 diff 之后。页签保持打开时,结果不明的提交在重新加载后仍会阻止重复发送,直到用户检查 GitHub 并明确允许再次提交。
“全部文件”打开可搜索的目录树;只有一个子目录的路径会合并显示,重命名文件也可以按旧路径搜索。较宽的变更面板会在 diff 旁显示同一棵树,工具栏的“文件树”按钮按“左侧 → 右侧 → 隐藏”循环切换,默认显示在左侧。按钮的无障碍名称说明下一步操作,移动或隐藏文件树时焦点仍留在按钮上。移动或隐藏文件树,以及切换标签页与 Session 时保留搜索、折叠状态、选中文件和宽度。拖动分隔线,或聚焦分隔线后使用方向键,可以调整文件树宽度。文件与文件夹预留相同的展开箭头列,子项相对父目录向内缩进。本地变更与每个 PR 保留独立标签页。划选代码文字或通过行号选择同一已显示 hunk、同一侧的连续行,文字划选与复制都限定在起始侧。点击“+”才打开纯文本评论框。评论框支持换行和输入法组合输入,只有点击操作按钮才提交。可拖动底边调整高度。“添加到输入框”将评论作为可移除的引用加入主输入框,多条引用只会在用户发送主输入框时一起发送。GitHub 分段按钮用于开始或加入待提交评审,下拉菜单可以立即发布单条评论。评论在引用、暂存或发布后保留在对应代码旁,暂存评论可在那里编辑或删除。“请求更改”需要填写评审总结,弹窗在总结输入框旁说明此要求,并在切换评审决定时播报。PR 标题栏中的“提交评审”打开居中弹窗,只显示待提交数量、总结以及“评论”“批准”“请求更改”选项。新建和删除文件只显示有内容的一侧行号。待提交评审与评论记录按 Session 和页签保存在当前浏览器,包括最初评审的 head。切换 Session 或隐藏面板时保留;关闭页签会清空该页签的评论、总结与评审决定,重新打开从空评审开始。已发布到 GitHub 的评论与已加入主输入框的引用不受影响。head 变化后需要重新选择评论行。代码变化后的记录保留在文件末尾;文件已不在 diff 中时,记录显示在 diff 之后。页签保持打开时,结果不明的提交在重新加载后仍会阻止重复发送,直到用户检查 GitHub 并明确允许再次提交。
-----
@@ -167,10 +167,10 @@ function Summary({ snapshot, now, t }: {
return (
<>
<span className={css.ci} data-tone={ci.kind === 'failed' ? 'error' : undefined}>
{ci.kind !== 'none' && <CheckGlyph state={ROLLUP[snapshot.checksRollup]} size={12} />}
{ci.kind !== 'none' && <CheckGlyph state={ci.kind === 'cancelled' ? 'cancelled' : ROLLUP[snapshot.checksRollup]} size={12} />}
{ci.kind === 'failed'
? ci.count > 0 ? t('change.ci.failed', { count: ci.count }) : t('change.ci.failedUnlisted')
: t(`change.ci.${ci.kind}`)}
: ci.kind === 'cancelled' ? t('change.ci.cancelled', { count: ci.count }) : t(`change.ci.${ci.kind}`)}
</span>
{flag !== undefined && <span className={css.flag} data-flag={flag}>{t(`change.flag.${flag}`)}</span>}
</>
@@ -207,6 +207,7 @@ function ChecksRow({ snapshot, openLink, t }: {
...counts.failed > 0 ? [t('change.checks.failed', { count: counts.failed })] : [],
...counts.running > 0 ? [t('change.checks.running', { count: counts.running })] : [],
...counts.passed > 0 ? [t('change.checks.passed', { count: counts.passed })] : [],
...counts.cancelled > 0 ? [t('change.checks.cancelled', { count: counts.cancelled })] : [],
...counts.other > 0 ? [t('change.checks.other', { count: counts.other })] : [],
].join(' · ')
const close = (): void => { setOpen(false) }
@@ -623,6 +623,7 @@ export function ChangesTab({
// The toolbar collapses every file while any is expanded, as the files on screen show, and expands every file otherwise.
const anyExpanded = files.some(file => chosen[file.path] ?? initial.has(file.path))
const expansionLabel = t(anyExpanded ? 'diff.collapseAll' : 'diff.expandAll')
const treeAction = t(treePosition === 'left' ? 'diff.moveFileTreeRight' : treePosition === 'right' ? 'diff.hideFileTree' : 'diff.showFileTreeLeft')
let additions = 0
let deletions = 0
for (const file of files) {
@@ -673,9 +674,9 @@ export function ChangesTab({
</button>
</Tooltip>
<span className={css.treeToggle}>
<Tooltip label={t(treePosition === 'left' ? 'diff.moveFileTreeRight' : treePosition === 'right' ? 'diff.hideFileTree' : 'diff.showFileTreeLeft')} side="bottom">
<button type="button" className={css.tool} aria-label={t('diff.fileTree')} aria-expanded={treePosition !== 'hidden'}
aria-pressed={treePosition !== 'hidden'} aria-controls={treeId} disabled={files.length === 0}
<Tooltip label={treeAction} side="bottom">
<button type="button" className={css.tool} aria-label={treeAction} aria-expanded={treePosition !== 'hidden'}
aria-controls={treeId} disabled={files.length === 0}
onClick={() => { setTreePosition(value => value === 'left' ? 'right' : value === 'right' ? 'hidden' : 'left') }}>
<IconWorkspaceTreeOutlineRegular />
</button>
@@ -51,7 +51,7 @@ export function SubmitReview({ queue, url, headSha, busy, error, submit, close,
aria-label={t('review.summary')} placeholder={t('review.summary')} required={requiresSummary}
aria-describedby={requiresSummary ? summaryHint : undefined}
onChange={(event) => { queue.summarize(event.target.value, state.event) }} />
{requiresSummary && <div id={summaryHint} className={css.hint}>{t('review.summaryRequired')}</div>}
<div id={summaryHint} className={css.hint} role="status">{requiresSummary ? t('review.summaryRequired') : ''}</div>
</div>
<div className={css.decisions}>
{(['comment', 'approve', 'request-changes'] as const).map(value => <label key={value}>
@@ -94,10 +94,12 @@ export const zh = {
'change.ci.running': '检查中',
'change.ci.passed': '检查通过',
'change.ci.failed': '{count} 项检查失败',
'change.ci.cancelled': '已取消 {count} 项检查',
'change.ci.failedUnlisted': '检查失败',
'change.checks.failed': '{count} 项失败',
'change.checks.running': '{count} 项进行中',
'change.checks.passed': '{count} 项通过',
'change.checks.cancelled': '{count} 项已取消',
'change.checks.other': '其他 {count} 项',
'change.checks.truncated': '只列出前 {count} 项',
'change.check.running': '进行中',
@@ -348,10 +350,12 @@ export const en: Record<ForgePanelKey, string> = {
'change.ci.running': 'Checks running',
'change.ci.passed': 'Checks passed',
'change.ci.failed': '{count} checks failed',
'change.ci.cancelled': '{count} checks cancelled',
'change.ci.failedUnlisted': 'Checks failed',
'change.checks.failed': '{count} failed',
'change.checks.running': '{count} running',
'change.checks.passed': '{count} passed',
'change.checks.cancelled': '{count} cancelled',
'change.checks.other': '{count} other',
'change.checks.truncated': 'Only the first {count} are listed',
'change.check.running': 'Running',
@@ -606,10 +610,12 @@ export const ja: Record<ForgePanelKey, string> = {
'change.ci.running': 'チェック実行中',
'change.ci.passed': 'チェック成功',
'change.ci.failed': '{count} 件のチェックが失敗',
'change.ci.cancelled': '{count} 件のチェックがキャンセルされました',
'change.ci.failedUnlisted': 'チェック失敗',
'change.checks.failed': '{count} 件失敗',
'change.checks.running': '{count} 件実行中',
'change.checks.passed': '{count} 件成功',
'change.checks.cancelled': '{count} 件キャンセル',
'change.checks.other': 'その他 {count} 件',
'change.checks.truncated': '最初の {count} 件のみ表示',
'change.check.running': '実行中',
@@ -857,10 +863,12 @@ export const es: Record<ForgePanelKey, string> = {
'change.ci.running': 'Comprobaciones en curso',
'change.ci.passed': 'Comprobaciones superadas',
'change.ci.failed': '{count} comprobaciones fallidas',
'change.ci.cancelled': '{count} comprobaciones canceladas',
'change.ci.failedUnlisted': 'Comprobaciones fallidas',
'change.checks.failed': '{count} fallidas',
'change.checks.running': '{count} en curso',
'change.checks.passed': '{count} superadas',
'change.checks.cancelled': '{count} canceladas',
'change.checks.other': '{count} más',
'change.checks.truncated': 'Solo se muestran las primeras {count}',
'change.check.running': 'En curso',
@@ -1108,10 +1116,12 @@ export const fr: Record<ForgePanelKey, string> = {
'change.ci.running': 'Vérifications en cours',
'change.ci.passed': 'Vérifications réussies',
'change.ci.failed': '{count} vérifications échouées',
'change.ci.cancelled': '{count} vérifications annulées',
'change.ci.failedUnlisted': 'Échec des vérifications',
'change.checks.failed': '{count} échouées',
'change.checks.running': '{count} en cours',
'change.checks.passed': '{count} réussies',
'change.checks.cancelled': '{count} annulées',
'change.checks.other': '{count} autres',
'change.checks.truncated': 'Seules les {count} premières sont affichées',
'change.check.running': 'En cours',
@@ -1302,7 +1312,7 @@ export const de: Record<ForgePanelKey, string> = {
'review.summary': 'Zusammenfassung der Review…',
'review.approve': 'Genehmigen',
'review.requestChanges': 'Änderungen anfordern',
'review.summaryRequired': 'Gib eine Zusammenfassung der Prüfung ein, um Änderungen anzufordern.',
'review.summaryRequired': 'Gib eine Zusammenfassung des Reviews ein, um Änderungen anzufordern.',
'review.commentOnly': 'Kommentieren',
'review.drafts': 'Ausstehende Kommentare ({count})',
'review.edit': 'Bearbeiten',
@@ -1359,10 +1369,12 @@ export const de: Record<ForgePanelKey, string> = {
'change.ci.running': 'Prüfungen laufen',
'change.ci.passed': 'Prüfungen bestanden',
'change.ci.failed': '{count} Prüfungen fehlgeschlagen',
'change.ci.cancelled': '{count} Prüfungen abgebrochen',
'change.ci.failedUnlisted': 'Prüfungen fehlgeschlagen',
'change.checks.failed': '{count} fehlgeschlagen',
'change.checks.running': '{count} laufen',
'change.checks.passed': '{count} bestanden',
'change.checks.cancelled': '{count} abgebrochen',
'change.checks.other': '{count} weitere',
'change.checks.truncated': 'Nur die ersten {count} werden angezeigt',
'change.check.running': 'Läuft',
@@ -1610,10 +1622,12 @@ export const ru: Record<ForgePanelKey, string> = {
'change.ci.running': 'Проверки выполняются',
'change.ci.passed': 'Проверки пройдены',
'change.ci.failed': 'Не пройдено проверок: {count}',
'change.ci.cancelled': 'Проверок отменено: {count}',
'change.ci.failedUnlisted': 'Проверки не пройдены',
'change.checks.failed': 'Не пройдено: {count}',
'change.checks.running': 'Выполняется: {count}',
'change.checks.passed': 'Пройдено: {count}',
'change.checks.cancelled': 'Отменено: {count}',
'change.checks.other': 'Других: {count}',
'change.checks.truncated': 'Показаны только первые {count}',
'change.check.running': 'Выполняется',
@@ -1861,10 +1875,12 @@ export const pt: Record<ForgePanelKey, string> = {
'change.ci.running': 'Verificações em andamento',
'change.ci.passed': 'Verificações aprovadas',
'change.ci.failed': '{count} verificações falharam',
'change.ci.cancelled': '{count} verificações canceladas',
'change.ci.failedUnlisted': 'As verificações falharam',
'change.checks.failed': '{count} falharam',
'change.checks.running': '{count} em andamento',
'change.checks.passed': '{count} aprovadas',
'change.checks.cancelled': '{count} canceladas',
'change.checks.other': '{count} outras',
'change.checks.truncated': 'Apenas as primeiras {count} são exibidas',
'change.check.running': 'Em andamento',
@@ -27,16 +27,18 @@ export type CiSummary =
| { readonly kind: 'passed' }
/** `count` is the number of failed checks the host listed, which can be zero when the list is truncated. */
| { readonly kind: 'failed'; readonly count: number }
| { readonly kind: 'cancelled'; readonly count: number }
/** Checks grouped by outcome; `other` holds neutral, skipped, and cancelled checks. */
/** Checks grouped by outcome; `other` holds neutral and skipped checks. */
export interface CheckCounts {
readonly failed: number
readonly running: number
readonly passed: number
readonly cancelled: number
readonly other: number
}
const SETTLED: Record<Exclude<ChecksRollup, 'failure'>, Exclude<CiSummary['kind'], 'failed'>> = {
const SETTLED: Record<Exclude<ChecksRollup, 'failure'>, Exclude<CiSummary['kind'], 'failed' | 'cancelled'>> = {
none: 'none',
pending: 'running',
success: 'passed',
@@ -75,21 +77,28 @@ export function checkCounts(checks: readonly ChangeRequestCheck[]): CheckCounts
let failed = 0
let running = 0
let passed = 0
let cancelled = 0
for (const check of checks) {
if (check.state === 'failure') failed++
else if (check.state === 'pending') running++
else if (check.state === 'success') passed++
else if (check.state === 'cancelled') cancelled++
}
return { failed, running, passed, other: checks.length - failed - running - passed }
return { failed, running, passed, cancelled, other: checks.length - failed - running - passed - cancelled }
}
/**
* Summarize the checks of a change request from the host's combined outcome.
* @param snapshot - change request status.
* @returns the combined outcome with the failed count.
* @returns the combined outcome with its failure or cancellation count.
*/
export function ciSummary(snapshot: ChangeRequestSnapshot): CiSummary {
if (snapshot.checksRollup === 'failure') return { kind: 'failed', count: checkCounts(snapshot.checks).failed }
if (snapshot.checksRollup === 'failure') {
const counts = checkCounts(snapshot.checks)
return counts.failed === 0 && counts.cancelled > 0
? { kind: 'cancelled', count: counts.cancelled }
: { kind: 'failed', count: counts.failed }
}
return { kind: SETTLED[snapshot.checksRollup] }
}
@@ -131,6 +131,7 @@ describe('collapsed ChangeRequestCard', () => {
checksRollup: 'failure',
checks: [check('lint', { state: 'failure' }), check('test'), check('types', { state: 'failure' })],
}, '2 checks failed', 'failure', 'error'],
['cancelled checks', { checksRollup: 'failure', checks: [check('build', { state: 'cancelled' })] }, '1 checks cancelled', 'cancelled', null],
['failed checks the host did not list', { checksRollup: 'failure', checksTruncated: true }, en['change.ci.failedUnlisted'], 'failure', 'error'],
] as const)('states %s', (_label, overrides, text, glyph, tone) => {
const ci = within(metaOf(card(entry(1, snapshot(1, overrides))))).getByText(text)
@@ -292,7 +293,7 @@ describe('expanded ChangeRequestCard', () => {
const toggle = within(b.item).getByText(en['change.row.checks']).closest('button')
if (toggle === null) throw new Error('the checks row does not open a list')
const summary = rowValue(b.item, en['change.row.checks'])
expect(summary.textContent).toBe('1 failed · 2 running · 2 passed · 3 other')
expect(summary.textContent).toBe('1 failed · 2 running · 2 passed · 1 cancelled · 2 other')
expect(summary.getAttribute('data-tone')).toBe('error')
// The row leads with the combined outcome.
expect(toggle.querySelector('[data-forge-check]')?.getAttribute('data-forge-check')).toBe('failure')
@@ -1051,12 +1051,20 @@ describe('line review actions', () => {
fireEvent.change(tree.getByRole('textbox'), { target: { value: 'app.ts' } })
fireEvent.click(tree.getByRole('button', { name: 'src/app.ts' }))
expect(tree.getByRole('button', { name: 'src/app.ts' }).getAttribute('aria-current')).toBe('true')
fireEvent.click(m.view.getByRole('button', { name: en['diff.fileTree'] }))
expect(m.view.getByRole('button', { name: en['diff.fileTree'] }).getAttribute('aria-expanded')).toBe('true')
const toggle = m.view.getByRole('button', { name: en['diff.moveFileTreeRight'] })
toggle.focus()
fireEvent.click(toggle)
expect(m.view.getByRole('button', { name: en['diff.hideFileTree'] })).toBe(toggle)
expect(toggle.getAttribute('aria-expanded')).toBe('true')
expect(document.activeElement).toBe(toggle)
expect(tree.getByRole('button', { name: 'src/app.ts' }).getAttribute('aria-current')).toBe('true')
fireEvent.click(m.view.getByRole('button', { name: en['diff.fileTree'] }))
expect(m.view.getByRole('button', { name: en['diff.fileTree'] }).getAttribute('aria-expanded')).toBe('false')
fireEvent.click(m.view.getByRole('button', { name: en['diff.fileTree'] }))
fireEvent.click(toggle)
expect(m.view.getByRole('button', { name: en['diff.showFileTreeLeft'] })).toBe(toggle)
expect(toggle.getAttribute('aria-expanded')).toBe('false')
expect(document.activeElement).toBe(toggle)
fireEvent.click(toggle)
expect(m.view.getByRole('button', { name: en['diff.moveFileTreeRight'] })).toBe(toggle)
expect(document.activeElement).toBe(toggle)
expect(tree.getByRole('textbox')).toHaveProperty('value', 'app.ts')
fireEvent.change(tree.getByRole('textbox'), { target: { value: '' } })
fireEvent.click(tree.getByRole('button', { name: 'src' }))
@@ -299,9 +299,12 @@ describe('submission availability', () => {
submit={vi.fn()} close={vi.fn()} check={vi.fn()} reconcile={vi.fn()} t={t} />)
const button = view.getByRole('button', { name: 'Submit review' })
const summary = view.getByRole('textbox')
const announcement = view.getByRole('status')
expect(announcement.textContent).toBe('')
fireEvent.click(view.getByRole('radio', { name: 'Request changes' }))
expect(button).toHaveProperty('disabled', true)
expect(summary).toHaveProperty('required', true)
expect(announcement.textContent).toBe(en['review.summaryRequired'])
expect(view.getByText(en['review.summaryRequired']).id).toBe(summary.getAttribute('aria-describedby'))
fireEvent.change(summary, { target: { value: ' ' } })
expect(button).toHaveProperty('disabled', true)
@@ -311,7 +314,8 @@ describe('submission availability', () => {
fireEvent.click(view.getByRole('radio', { name: 'Approve' }))
expect(button).toHaveProperty('disabled', false)
expect(summary).toHaveProperty('required', false)
expect(view.queryByText(en['review.summaryRequired'])).toBeNull()
expect(announcement.textContent).toBe('')
expect(view.getByRole('status')).toBe(announcement)
})
it.each(['local', 'different-pr', 'different-head', 'empty-comment', 'load', 'save'] as const)('blocks %s and retains the review in the modal', (kind) => {
@@ -27,8 +27,8 @@ describe('toneOf', () => {
})
describe('checkCounts', () => {
it('groups neutral, skipped, and cancelled checks as other', () => {
expect(checkCounts([])).toEqual({ failed: 0, running: 0, passed: 0, other: 0 })
it('counts cancellations separately from neutral and skipped checks', () => {
expect(checkCounts([])).toEqual({ failed: 0, running: 0, passed: 0, cancelled: 0, other: 0 })
expect(checkCounts([
check('lint', { state: 'failure' }),
check('test', { state: 'pending' }),
@@ -37,7 +37,7 @@ describe('checkCounts', () => {
check('e2e', { state: 'skipped' }),
check('perf', { state: 'cancelled' }),
check('types', { state: 'failure' }),
])).toEqual({ failed: 2, running: 1, passed: 1, other: 3 })
])).toEqual({ failed: 2, running: 1, passed: 1, cancelled: 1, other: 2 })
})
})
@@ -50,6 +50,13 @@ describe('ciSummary', () => {
expect(ciSummary(snapshot(1, { checksRollup, checks: [check('lint', { state: 'failure' })] }))).toEqual(summary)
})
it('names cancellations when no listed check failed, and gives failures precedence', () => {
const cancelled = check('build', { state: 'cancelled' })
expect(ciSummary(snapshot(1, { checksRollup: 'failure', checks: [cancelled] }))).toEqual({ kind: 'cancelled', count: 1 })
expect(ciSummary(snapshot(1, { checksRollup: 'failure', checks: [cancelled, check('lint', { state: 'failure' })] })))
.toEqual({ kind: 'failed', count: 1 })
})
it('counts the listed failures of a failed rollup, which can be none when the list is truncated', () => {
const failed = snapshot(1, {
checksRollup: 'failure',
@@ -15,8 +15,8 @@
en: d152484eb41ac6b4
zh: 2f8a621b991260a1
/deepseek-ai-dsh-experimental-forge-github/use-this-package:
en: c3b6398a712e1f0f
zh: 747dfb11f1bf247a
en: 1f2e2e6270c96eda
zh: e3791d7d1ed1663c
/deepseek-ai-dsh-experimental-forge-github/understand-the-implementation:
en: 90f3c10096be642a
zh: 4e1b663c52019ac2
+2 -2
View File
@@ -38,9 +38,9 @@ The provider runs `gh` as a host process, even when Sessions execute commands in
The provider serves a remote URL in `https`, `http`, `ssh`, or `git` form, or in scp form such as `[email protected]:owner/name.git`, when its host is configured. HTTP(S) remotes retain custom ports in the host identity; SSH and Git transport ports are excluded. It serves pull request URLs of the form `https://<host>/<owner>/<name>/pull/<number>` with any trailing path, query, or fragment, and builds that form without the suffix as the canonical URL. A readiness probe runs `gh auth status --hostname <host>`: exit status 0 is `ready`, another exit status is `unauthenticated` with the first diagnostic line, and a `gh` that cannot start is `unavailable`. A head lookup returns up to 20 open pull requests whose head is the branch, newest first, excluding pull requests from forks; a lookup of the default branch returns none.
Check pagination reads the entire head-commit rollup before publishing a snapshot. Runs with the same application, workflow, event, and check name keep only the newest run id; a queued replacement supersedes an older completed run. Commit status contexts keep the newest result per context name. Counts and the overall indicator use these current results; unknown context kinds retain GitHub’s aggregate state. A failed or non-advancing page rejects that pull request’s snapshot instead of publishing a partial count.
Check pagination reads the entire head-commit rollup before publishing a snapshot. Runs with the same application, workflow, event, and check name keep only the newest run id; a queued replacement supersedes an older completed run. Runs without a numeric database id are retained by their node id because their relative age is unknown. Commit status contexts keep the newest result per context name. Counts and the overall indicator use these current results; unknown context kinds retain GitHub’s aggregate state. A failed or non-advancing page rejects that pull request’s snapshot instead of publishing a partial count.
Unfinished check runs and checks awaiting required action map to `pending`. Other completed checks map to `success`, `failure` (failure, timed out, or startup failure), `cancelled`, `skipped`, or `neutral`. Check runs keep their start and completion times. Commit status contexts map `SUCCESS` to `success`, `FAILURE` and `ERROR` to `failure`, and every other state to `pending`, and carry no times. A GraphQL `NOT_FOUND` error becomes a `not-found` failure. A response without GraphQL data or errors, including an HTTP error JSON body, uses the first stderr diagnostic or the body's message. Authentication diagnostics become `unauthenticated`; rate limits and other failures become `unavailable`. Head lookups preserve the same diagnostic in their rejection.
Unfinished check runs and completed runs with stale, missing, or unrecognized conclusions map to `pending`. Other completed checks map to `success`, `failure` (failure, timed out, startup failure, or action required), `cancelled`, `skipped`, or `neutral`. Cancelled checks keep the rollup non-passing. Check runs keep their start and completion times. Commit status contexts map `SUCCESS` to `success`, `FAILURE` and `ERROR` to `failure`, and every other state to `pending`, and carry no times. A GraphQL `NOT_FOUND` error becomes a `not-found` failure. A response without GraphQL data or errors, including an HTTP error JSON body, uses the first stderr diagnostic or the body's message. Authentication diagnostics become `unauthenticated`; oversized check pages become `too-large`; rate limits and other failures become `unavailable`. Head lookups preserve the same diagnostic in their rejection.
A pull request is `mergeReady` when it is open, not a draft, GitHub reports its merge state as `CLEAN`, `HAS_HOOKS`, or `UNSTABLE`, and the signed-in user has write, maintain, or admin permission. `mergeMethods` lists the squash, merge-commit, and rebase methods the repository allows, the user's default merge method first. Marking ready runs `gh pr ready <number> --repo <host>/<owner>/<name>`. Merging calls `PUT repos/<owner>/<name>/pulls/<number>/merge` through `gh api` with the method and the expected head SHA, so GitHub refuses once new commits arrived, which is reported as `stale`. Unlike `gh pr merge`, it never enables auto-merge, never joins a merge queue, and never deletes the head branch. A refused action reports GitHub's message, and a diagnostic that mentions authentication becomes `unauthenticated`.
@@ -38,9 +38,9 @@ kind: "package-reference"
当主机在配置中时,提供方服务 `https`、`http`、`ssh`、`git` 形式的远端 URL,以及 `[email protected]:owner/name.git` 这类 scp 形式。HTTP(S) 远端在主机标识中保留自定义端口;SSH 和 Git 传输端口不计入主机标识。它服务 `https://<host>/<owner>/<name>/pull/<number>` 形式的 pull request URL,允许其后附带任意路径、查询或片段,并以去掉这些后缀的形式作为规范 URL。就绪探测运行 `gh auth status --hostname <host>`:退出码为 0 时为 `ready`,其他退出码为 `unauthenticated` 并带第一行诊断,`gh` 无法启动时为 `unavailable`。按 head 分支查找时,最多返回 20 个以该分支为 head 的打开状态 pull request,按创建时间从新到旧排列,不包含来自 fork 的 pull request;查找默认分支时返回空结果。
检查分页读取 head 提交的完整汇总后才发布快照。同一应用、工作流、触发事件与检查名称的运行只保留运行 id 最新的一条;新的排队运行会替代旧的已完成运行。提交状态上下文按名称保留最新结果。数量与总体指示图标都使用这些当前结果;遇到未知上下文类型时保留 GitHub 的汇总状态。分页失败或游标不前进时,该 PR 的快照读取失败,不发布不完整的数量。
检查分页读取 head 提交的完整汇总后才发布快照。同一应用、工作流、触发事件与检查名称的运行只保留运行 id 最新的一条;新的排队运行会替代旧的已完成运行。缺少数字数据库 id 的运行无法确定先后,因此按节点 id 保留。提交状态上下文按名称保留最新结果。数量与总体指示图标都使用这些当前结果;遇到未知上下文类型时保留 GitHub 的汇总状态。分页失败或游标不前进时,该 PR 的快照读取失败,不发布不完整的数量。
未完成的检查运行(check run)与等待必要操作的检查映射为 `pending`。其他已完成的检查映射为 `success`、`failure`(失败、超时或启动失败)、`cancelled`、`skipped` 或 `neutral`。检查运行保留其开始与完成时间。提交状态上下文把 `SUCCESS` 映射为 `success`,把 `FAILURE` 与 `ERROR` 映射为 `failure`,其余状态均映射为 `pending`,且不带时间。GraphQL 的 `NOT_FOUND` 错误转为 `not-found` 失败。响应不含 GraphQL data 或 errors 时(包括 HTTP 错误 JSON),使用 stderr 的首条诊断或响应体的 message。认证诊断转为 `unauthenticated`;限流与其他失败转为 `unavailable`。head 查找在拒绝时保留相同诊断。
未完成的检查运行(check run),以及结论已过期、缺失或无法识别的已完成运行,均映射为 `pending`。其他已完成的检查映射为 `success`、`failure`(失败、超时、启动失败或需要操作)、`cancelled`、`skipped` 或 `neutral`。已取消的检查使汇总保持未通过状态。检查运行保留其开始与完成时间。提交状态上下文把 `SUCCESS` 映射为 `success`,把 `FAILURE` 与 `ERROR` 映射为 `failure`,其余状态均映射为 `pending`,且不带时间。GraphQL 的 `NOT_FOUND` 错误转为 `not-found` 失败。响应不含 GraphQL data 或 errors 时(包括 HTTP 错误 JSON),使用 stderr 的首条诊断或响应体的 message。认证诊断转为 `unauthenticated`;超出输出大小上限的检查分页转为 `too-large`;限流与其他失败转为 `unavailable`。head 查找在拒绝时保留相同诊断。
pull request 处于打开状态、不是草稿、GitHub 报告其合并状态为 `CLEAN`、`HAS_HOOKS` 或 `UNSTABLE`,且已登录用户具有 write、maintain 或 admin 权限时,`mergeReady` 为真。`mergeMethods` 列出仓库允许的压缩合并、合并提交与变基合并方式,用户默认的合并方式排在最前。标记为可评审运行 `gh pr ready <number> --repo <host>/<owner>/<name>`。合并经 `gh api` 调用 `PUT repos/<owner>/<name>/pulls/<number>/merge`,带上合并方式与预期的 head SHA,因此有新提交到达后 GitHub 会拒绝,报告为 `stale`。与 `gh pr merge` 不同,它从不启用自动合并、从不加入合并队列,也从不删除 head 分支。被拒绝的操作报告 GitHub 的原因,提到身份验证的诊断转为 `unauthenticated`。
@@ -13,7 +13,7 @@ const CHECK_FIELDS = `pageInfo { hasNextPage endCursor }
nodes {
__typename
... on CheckRun {
databaseId name status conclusion detailsUrl startedAt completedAt
id databaseId name status conclusion detailsUrl startedAt completedAt
checkSuite { app { id } workflowRun { event workflow { id name } } }
}
... on StatusContext { context state targetUrl createdAt }
@@ -44,7 +44,8 @@ export const HEAD_QUERY = `query($owner: String!, $name: String!, $branch: Strin
const checkRunSchema = z.object({
__typename: z.literal('CheckRun'),
databaseId: z.number().int().nonnegative(),
id: z.string(),
databaseId: z.number().int().nonnegative().nullable(),
name: z.string(),
status: z.string(),
conclusion: z.string().nullable(),
@@ -308,8 +309,10 @@ function toSnapshot(
if (run.success) {
const suite = run.data.checkSuite
const workflow = suite?.workflowRun
const key = JSON.stringify(['run', run.data.name, suite?.app?.id, workflow?.workflow.id, workflow?.event])
retain(key, run.data.databaseId, {
// A queued run may have neither a database id nor timestamps. Retain such runs by node id rather than guessing their age.
const key = run.data.databaseId === null ? JSON.stringify(['unranked-run', run.data.id])
: JSON.stringify(['run', run.data.name, suite?.app?.id, workflow?.workflow.id, workflow?.event])
retain(key, run.data.databaseId ?? 0, {
name: run.data.name,
state: checkRunState(run.data.status, run.data.conclusion),
url: run.data.detailsUrl,
@@ -360,7 +363,7 @@ function toSnapshot(
reviewDecision: reviewDecision(node.reviewDecision),
checks,
checksRollup: summary,
checksTruncated: rollup?.contexts.pageInfo.hasNextPage ?? false,
checksTruncated: false,
unresolvedThreads: node.reviewThreads.nodes.filter(thread => !thread.isResolved).length,
updatedAt: node.updatedAt,
closedAt: node.closedAt,
@@ -387,13 +390,14 @@ function checkRunState(status: string, conclusion: string | null): CheckState {
if (status !== 'COMPLETED') return 'pending'
switch (conclusion) {
case 'SUCCESS': return 'success'
case 'ACTION_REQUIRED': return 'pending'
case 'ACTION_REQUIRED':
case 'FAILURE':
case 'TIMED_OUT':
case 'STARTUP_FAILURE': return 'failure'
case 'CANCELLED': return 'cancelled'
case 'SKIPPED': return 'skipped'
default: return 'neutral'
case 'NEUTRAL': return 'neutral'
default: return 'pending'
}
}
@@ -226,7 +226,7 @@ export class GitHubProvider implements ForgeProvider {
} catch (error) {
if (signal.aborted) throw signal.reason
if (error instanceof GhUnavailableError || error instanceof GhTimeoutError || error instanceof GhOutputLimitError) {
return { ok: false, failure: { code: 'unavailable', message: error.message } }
return { ok: false, failure: { code: error instanceof GhOutputLimitError ? 'too-large' : 'unavailable', message: error.message } }
}
throw error
}
@@ -11,7 +11,7 @@ export function pull(number: number, repository: ForgeRepository = demo): Change
/** One CheckRun context node as GitHub returns it. */
export function checkRun(name: string, status: string, conclusion: string | null, workflow: string | null = 'ci'): Record<string, unknown> {
return {
__typename: 'CheckRun', databaseId: 1,
__typename: 'CheckRun', id: 'check-1', databaseId: 1,
name,
status,
conclusion,
@@ -105,7 +105,7 @@ describe('snapshot mapping', () => {
it.each([
['QUEUED', null, 'pending'], ['COMPLETED', 'SUCCESS', 'success'], ['COMPLETED', 'CANCELLED', 'failure'],
['COMPLETED', 'ACTION_REQUIRED', 'pending'],
['COMPLETED', 'ACTION_REQUIRED', 'failure'],
] as const)('summarizes the latest %s/%s run instead of a superseded failure', async (status, conclusion, expected) => {
const result = await single(pullRequestNode(1, {}, [
checkRun('build', 'COMPLETED', 'FAILURE'), { ...checkRun('build', status, conclusion), databaseId: 2 },
@@ -114,11 +114,36 @@ describe('snapshot mapping', () => {
expect(result.checksRollup).toBe(expected)
})
it('reports malformed known checks instead of publishing a smaller count', async () => {
await expect(single(pullRequestNode(1, {}, [{ ...checkRun('build', 'COMPLETED', 'SUCCESS'), databaseId: null }])))
it.each(['STALE', null, 'FUTURE_CONCLUSION'])('does not report completed %s as passing', async (conclusion) => {
const result = await single(pullRequestNode(1, {}, [checkRun('build', 'COMPLETED', conclusion)], 'SUCCESS'))
expect(result.checksRollup).toBe('pending')
})
it('retains unranked runs by node id without guessing their age from missing times', async () => {
const queued = { ...checkRun('build', 'QUEUED', null), id: 'queued', databaseId: null }
const failed = { ...checkRun('build', 'COMPLETED', 'FAILURE'), id: 'failed', databaseId: null }
const passed = { ...checkRun('build', 'COMPLETED', 'SUCCESS'), databaseId: 9 }
const result = await single(pullRequestNode(1, {}, [queued, failed, queued, passed]))
expect(result.checks.map(check => check.state)).toEqual(['pending', 'failure', 'success'])
expect(result.checksRollup).toBe('failure')
expect(result.checksTruncated).toBe(false)
expect((await single(pullRequestNode(1, {}, [queued, passed]))).checksRollup).toBe('pending')
expect((await single(pullRequestNode(1, {}, [failed]))).checksRollup).toBe('failure')
})
it.each([-1, '1'])('reports malformed known check id %s instead of publishing a smaller count', async (databaseId) => {
await expect(single(pullRequestNode(1, {}, [{ ...checkRun('build', 'COMPLETED', 'SUCCESS'), databaseId }])))
.rejects.toThrow('unexpected GitHub check fields')
})
it.each(['FAILURE', 'PENDING'] as const)('preserves the raw %s rollup when an unknown context cannot be summarized', async (state) => {
const result = await single(pullRequestNode(1, {}, [
checkRun('build', 'COMPLETED', 'SUCCESS'), { __typename: 'FutureContext' },
], state))
expect(result.checksRollup).toBe(state === 'FAILURE' ? 'failure' : 'pending')
expect(result.checksTruncated).toBe(false)
})
it.each([
['OPEN', 'open'],
['CLOSED', 'closed'],
@@ -149,12 +174,13 @@ describe('snapshot mapping', () => {
['COMPLETED', 'FAILURE', 'failure'],
['COMPLETED', 'TIMED_OUT', 'failure'],
['COMPLETED', 'STARTUP_FAILURE', 'failure'],
['COMPLETED', 'ACTION_REQUIRED', 'pending'],
['COMPLETED', 'ACTION_REQUIRED', 'failure'],
['COMPLETED', 'CANCELLED', 'cancelled'],
['COMPLETED', 'SKIPPED', 'skipped'],
['COMPLETED', 'NEUTRAL', 'neutral'],
['COMPLETED', 'STALE', 'neutral'],
['COMPLETED', null, 'neutral'],
['COMPLETED', 'STALE', 'pending'],
['COMPLETED', null, 'pending'],
['COMPLETED', 'FUTURE_CONCLUSION', 'pending'],
['IN_PROGRESS', null, 'pending'],
['QUEUED', null, 'pending'],
])('maps check run %s/%s to %s', async (status, conclusion, expected) => {
@@ -94,14 +94,18 @@ describe('GitHub provider fetch', () => {
expect(gh.calls).toHaveLength(1)
})
it.each([new GhTimeoutError('timed out'), new GhOutputLimitError('too much output'), new GhUnavailableError('gh missing')])(
'contains a failed continuation process to its pull request', async (error) => {
it.each([
[new GhTimeoutError('timed out'), 'unavailable'],
[new GhOutputLimitError('too much output'), 'too-large'],
[new GhUnavailableError('gh missing'), 'unavailable'],
] as const)(
'contains a failed continuation process to its pull request', async (error, code) => {
const gh = fakeGh((args) => {
if (args.includes('id=fixed-rollup')) throw error
return output({ data: { r0: { p0: firstPage(), p1: pullRequestNode(2) } } })
})
const results = await provider(gh.run).fetch([pull(1), pull(2)], signal)
expect(results.get(changeRequestKey(pull(1)))).toEqual({ code: 'unavailable', message: error.message })
expect(results.get(changeRequestKey(pull(1)))).toEqual({ code, message: error.message })
expect(results.get(changeRequestKey(pull(2)))).toMatchObject({ title: 'Change 2' })
},
)
@@ -88,7 +88,7 @@ const node = (number) => ({
commits: { nodes: [{ commit: { statusCheckRollup: {
id: 'rollup-' + number, state: number === 7 ? 'PENDING' : 'SUCCESS',
contexts: { pageInfo: { hasNextPage: false, endCursor: null }, nodes: [{
__typename: 'CheckRun', databaseId: 1, name: 'test', status: number === 7 ? 'IN_PROGRESS' : 'COMPLETED', conclusion: number === 7 ? null : 'SUCCESS',
__typename: 'CheckRun', id: 'check-1', databaseId: 1, name: 'test', status: number === 7 ? 'IN_PROGRESS' : 'COMPLETED', conclusion: number === 7 ? null : 'SUCCESS',
detailsUrl: null, startedAt: null, completedAt: null, checkSuite: { app: { id: 'actions' }, workflowRun: { event: 'pull_request', workflow: { id: 'ci', name: 'ci' } } },
}] },
} } }] },