feat(forge): draw the review lists as skeleton rows while they are read

The list column showed plain blocks until its first frame and one block per unread list. It now draws rows laid out
as the items of the reader's view, detailed or compact, with the fill and pulse of the changes view's reading state,
so the column keeps its geometry when the items arrive.
This commit is contained in:
LegGasai committed 2026-11-18 11:50:33 +08:00
1 parent 7c34ed36cc
commit ece93f95ec
6 files changed
+130 -18

No files matched your search

@@ -15,8 +15,8 @@
en: d152484eb41ac6b4
zh: 2f8a621b991260a1
/deepseek-ai-dsh-experimental-client-ui-forge/use-this-package:
en: 7aad33d4c460be3d
zh: 560b9fe59d5545f3
en: fadf273600342463
zh: 6ac48a0ef35d1669
/deepseek-ai-dsh-experimental-client-ui-forge/understand-the-implementation:
en: 4778e1dca2c6ff47
zh: a8589b3e950a8ca1
@@ -33,7 +33,7 @@ Panel text follows the application language: Chinese, English, Japanese, Spanish
- **Archive cleanup** — archiving a Session lets the [worktree service](../worktree/README.md) reclaim the clean, unreferenced worktree it created, whether through the New Session option or the model's `enter_worktree` tool, while retaining the branch and its commits. A scheduled cleanup uses the archive notice “Archived; the worktree will be cleaned up”; one that ends retained returns to the ordinary notice, and one that fails replaces it with a warning while the Session stays archived. Undo cancels deletion before admission or waits for an admitted deletion; a removed checkout uses the existing Restore worktree flow. The bundle's worktree row on the Plugins page offers Keep worktrees when archiving: once saved, archiving keeps every worktree and shows the ordinary archive notice; the switch is read at each archive, so it does not affect a cleanup already scheduled.
- **Creation card** — while the worktree is created, a card above the composer shows the new branch and its steps: fetching a remote base branch, creating the branch, and checking out files; More details adds the branch and base. Cancel stops the attempt. After a stopped or failed attempt the message keeps waiting, and the card shows the reason of a failure: Retry tries again, on the chosen name or a new generated one, and Continue without a worktree withdraws the request so the message goes on in the current checkout. A failed fetch also offers Use the last fetched version, which starts from the remote branch as last fetched. When the chosen branch or its directory already exists, Rename opens the naming dialog, whose Retry saves the new name and tries again.
- **Removed worktree** — when the worktree the Session works in has been removed outside the Session, a card above the composer says so, and a message sent meanwhile waits without starting its turn until the worktree is restored or left; the card then says that the message goes on afterwards. Restore worktree, also offered as Restore in the Session panel's checkout row, checks the branch out again at the same directory, or creates the branch again at the commit it started from when the branch is gone too; while it runs, the card follows its two steps, preparing the worktree and checking out files, and the checkout row's Restore turns into a spinner. Continue in the project moves the Session to the source checkout. Meanwhile the checkout row shows a warning glyph.
- **Code review page** — the Code review row in the left navigation counts the open change requests that ask the signed-in user for a review and opens a page with three lists: Review requested, Created by me, and Involving me, each most recently updated first across every host a provider lists them on, read only while the page or the count shows. A list item names the repository when the lists span more than one, the author, the update time, the issues it closes, and at most one hint, such as You requested changes · Requested again or a team request; the search box filters the lists by title, number, repository, and author under the [client search rule](../../client/AGENTS.md#search-and-filter) and opens a pasted change request link with Enter. The view menu, laid out like the Session list's, switches between the Detailed view and a Compact view of one line per change request, whose title scrolls into view on hover and whose hover card lists the details, reads one repository, and leaves out team requests. The detail shows the state, repository and number, labels on one line that fold into +N, the title, author, times, and branches, the ready-for-review or merge action, and a More menu; Summary shows the description beside the card rows, Changes shows the changes view with review threads, viewed files, and review submission, where Add to chat and Quote in chat put a comment or thread into the change request's conversation draft and count it on the Chat tab, and Chat starts a conversation in a blank Session of the Workspace whose folder has the repository's name, quoting the change request and offering three prompts, and binds the change request at the first message; New conversation starts another, and Open in main view shows it in the main view. Below 880 px of page width one column shows; signing in, rate limits, and unrecognized links show where they apply.
- **Code review page** — the Code review row in the left navigation counts the open change requests that ask the signed-in user for a review and opens a page with three lists: Review requested, Created by me, and Involving me, each most recently updated first across every host a provider lists them on, read only while the page or the count shows. While a list is read, skeleton rows laid out as the chosen view stand in for its items. A list item names the repository when the lists span more than one, the author, the update time, the issues it closes, and at most one hint, such as You requested changes · Requested again or a team request; the search box filters the lists by title, number, repository, and author under the [client search rule](../../client/AGENTS.md#search-and-filter) and opens a pasted change request link with Enter. The view menu, laid out like the Session list's, switches between the Detailed view and a Compact view of one line per change request, whose title scrolls into view on hover and whose hover card lists the details, reads one repository, and leaves out team requests. The detail shows the state, repository and number, labels on one line that fold into +N, the title, author, times, and branches, the ready-for-review or merge action, and a More menu; Summary shows the description beside the card rows, Changes shows the changes view with review threads, viewed files, and review submission, where Add to chat and Quote in chat put a comment or thread into the change request's conversation draft and count it on the Chat tab, and Chat starts a conversation in a blank Session of the Workspace whose folder has the repository's name, quoting the change request and offering three prompts, and binds the change request at the first message; New conversation starts another, and Open in main view shows it in the main view. Below 880 px of page width one column shows; signing in, rate limits, and unrecognized links show where they apply.
- **Session panel** — the Environment section of the Session panel gains the checkout and local changes rows after the project row, and the connection row at its end while the panel stream is lost, and a Change requests section follows it. The panel has no refresh control: when it opens and when the window regains focus, it inspects the checkout again, checks sign-in, and polls every change request, at most once every 10 seconds per Session, so changes made outside the Session appear on return. A yellow dot on the panel toggle in the Session header marks an open change request with failed checks, requested changes, or conflicts, also while the panel is hidden.
- **Checkout row** — names the checked-out branch, or Not on a branch with the abbreviated commit on a detached HEAD, and the kind of checkout, which is the worktree the Session created with its base, another worktree, or the project directory; its tooltip, shown after 500ms of hover, adds the path with the Host home shortened to `~`, and a branch name the row clips crawls into view while the pointer rests on the row. The row and its More button open the directory menu of the checkout root. For a removed worktree it shows a warning glyph and offers Restore. When Git cannot be read, the row says so, and its info button shows the failure after 500ms of hover, at once on keyboard focus, or on a press; outside a Git checkout there is no row.
- **Connection row** — when the Session's panel stream ends, also before it delivered a first state, a status row at the end of the Environment section says the status stopped updating and that the Git and change request details may be out of date; Retry opens the stream again and the row goes away.
@@ -33,7 +33,7 @@ kind: "package-reference"
- **归档清理**——归档一个会话后,由[工作树服务](../worktree/README.zh.md)回收它创建的干净且无人引用的工作树,无论来自新会话选项还是模型的 `enter_worktree` 工具,分支及其提交保留。清理排队后,归档提示为“已归档,工作树将被清理”;最终保留时恢复为普通归档提示,失败时替换为警告而会话仍保持归档。撤销归档会取消尚未获准的删除,或等待已获准的删除结束;已移除的工作树使用现有的“恢复工作树”流程。插件页上该套件的 worktree 行提供“归档时不删除工作树”开关:保存后,归档会保留所有工作树并显示普通归档提示;开关在每次归档时读取,不影响已排队的清理。
- **创建卡片**——创建 worktree 期间,输入框上方的卡片显示新分支及其步骤:获取远程基准分支、创建分支、检出文件;“更多详情”会列出分支与基准。“取消”停止这次尝试。尝试被停止或失败后,消息继续等待,失败时卡片显示原因:“重试”再试一次,使用指定的名称或新的自动名称;“不使用工作树”撤回请求,消息在当前检出中继续发送。获取失败时还提供“使用上次获取的版本”,从上次获取的远程分支开始。指定的分支或其目录已存在时,“更改名称”打开命名对话框,其中的“重试”保存新名称并再试一次。
- **工作树已被删除**——Session 所在的 worktree 在 Session 之外被删除后,输入框上方的卡片会说明这一点;此期间发送的消息会等待、不开始这一轮,直到该 worktree 被恢复或离开,卡片也会说明消息之后会接着发送。“恢复工作树”(会话面板检出行中的“恢复”与之相同)在原目录重新检出该分支;分支也已删除时,从它开始时的提交重新创建分支;恢复期间卡片显示“准备工作树”“检出文件”两个步骤,检出行中的“恢复”变为加载状态。“在项目目录继续”把 Session 移回源检出。此期间检出行显示警示图标。
- **代码评审页**——左侧导航的“代码评审”一行显示请登录用户评审的未关闭变更请求数,点开是包含“待我评审”“我创建的”“与我有关”三个列表的页面;每个列表合并提供方能列出的全部主机,按更新时间倒序,只在页面或计数显示时读取。列表项在列表跨多个仓库时写出仓库名,并显示作者、更新时间、会关闭的 issue 和至多一条提示,如“你请求过修改 · 已再次请求”或团队请求;搜索框按[客户端搜索规则](../../client/AGENTS.md#search-and-filter)以标题、编号、仓库和作者筛选列表,粘贴变更请求链接后按 Enter 打开。视图菜单与会话列表的一致:可在“详细”与“紧凑”之间切换(紧凑为每个变更请求一行,悬停时标题滚动显示完整内容,悬停卡列出详情),可只读一个仓库,也可排除团队请求。详情显示状态、仓库与编号、单行标签(放不下时收进 +N)、标题、作者、时间和分支,以及标记为可评审或合并操作和“更多”菜单;“概要”在描述旁显示卡片各行,“变更”显示变更视图,含评审讨论、已审阅文件和提交评审,其中“添加到对话”“引用到对话”把评论或讨论放进该变更请求对话的草稿,并在“对话”标签上计数;“对话”在文件夹名与仓库同名的工作区的空白会话中开始对话,引用该变更请求并提供三个提示,首条消息时绑定该变更请求;“新对话”另开一个,“在主界面打开”在主界面显示它。页面宽度不足 880 px 时只显示一栏;需要登录、触发限流或链接无法识别时在对应位置提示。
- **代码评审页**——左侧导航的“代码评审”一行显示请登录用户评审的未关闭变更请求数,点开是包含“待我评审”“我创建的”“与我有关”三个列表的页面;每个列表合并提供方能列出的全部主机,按更新时间倒序,只在页面或计数显示时读取。列表读取期间,按所选视图排布的骨架行占据列表项的位置。列表项在列表跨多个仓库时写出仓库名,并显示作者、更新时间、会关闭的 issue 和至多一条提示,如“你请求过修改 · 已再次请求”或团队请求;搜索框按[客户端搜索规则](../../client/AGENTS.md#search-and-filter)以标题、编号、仓库和作者筛选列表,粘贴变更请求链接后按 Enter 打开。视图菜单与会话列表的一致:可在“详细”与“紧凑”之间切换(紧凑为每个变更请求一行,悬停时标题滚动显示完整内容,悬停卡列出详情),可只读一个仓库,也可排除团队请求。详情显示状态、仓库与编号、单行标签(放不下时收进 +N)、标题、作者、时间和分支,以及标记为可评审或合并操作和“更多”菜单;“概要”在描述旁显示卡片各行,“变更”显示变更视图,含评审讨论、已审阅文件和提交评审,其中“添加到对话”“引用到对话”把评论或讨论放进该变更请求对话的草稿,并在“对话”标签上计数;“对话”在文件夹名与仓库同名的工作区的空白会话中开始对话,引用该变更请求并提供三个提示,首条消息时绑定该变更请求;“新对话”另开一个,“在主界面打开”在主界面显示它。页面宽度不足 880 px 时只显示一栏;需要登录、触发限流或链接无法识别时在对应位置提示。
- **会话面板**——会话面板的“环境”分栏在项目行之后增加检出行与本地变更行,面板流断开时末尾再加连接行,其后是“变更请求”分栏。面板没有刷新控件:打开时以及窗口重新获得焦点时,它会重新检查检出与登录状态,并轮询每个变更请求,每个会话每 10 秒最多一次,因此在 Session 之外做的改动在切回来时就会出现。打开中的变更请求存在检查失败、被要求修改或冲突时,会话标题栏中的面板开关带黄点,面板隐藏时也会显示。
- **检出行**——显示当前检出的分支(分离 HEAD 时为“不在分支上”与缩写提交),并说明检出的类型(Session 创建的 worktree 及其基准、其他 worktree 或项目目录);悬停 500ms 后出现的提示给出路径,宿主主目录缩写为 `~`;分支名放不下时,指针停在这一行上会滚动显示全文。这一行及其“更多”按钮打开检出根目录的目录菜单。worktree 已被删除时显示警示图标并提供“恢复”。无法读取 Git 时,这一行说明这一点,行尾的信息按钮在悬停 500ms、键盘聚焦或按下时给出失败原因;不在 Git 检出中时不显示这一行。
- **连接行**——Session 的面板流结束时(包括还没收到第一份状态就结束),环境分栏末尾的状态行说明状态已停止更新,Git 与变更请求信息可能已过时;「重试」重新打开流,这一行随即消失。
@@ -23,6 +23,7 @@ import {
type ReviewItem, type ReviewRepository, type ReviewSection,
} from './review-lists.ts'
import type { ReviewView } from './review-store.ts'
import loading from './ChangesLoading.module.css'
import css from './ReviewPage.module.css'
type Translate = PropsLocale<typeof NS>['t']
@@ -311,6 +312,50 @@ function SectionFailure({ section, copyText, t }: {
return <div className={css.notice} role="status">{t('reviewPage.listFailed', { host, message: failure.message })}</div>
}
/**
* Bar widths of the skeleton rows, in percent of a row's text column: the title's first line, its second line or 0
* for a one-line title, and the meta line.
*/
const SKELETON_ROWS = [
{ title: 94, wrapped: 46, meta: 38 },
{ title: 82, wrapped: 0, meta: 45 },
{ title: 97, wrapped: 63, meta: 33 },
{ title: 71, wrapped: 0, meta: 41 },
{ title: 90, wrapped: 35, meta: 48 },
{ title: 86, wrapped: 57, meta: 36 },
] as const
/**
* Listed change requests drawn as skeletons while a list is read, laid out as the rows of the reader's view. They
* carry no text and are hidden from assistive technology; the caller marks the busy region.
*/
function SkeletonItems({ view, count }: { readonly view: ReviewView; readonly count: number }): ReactNode {
return (
<div aria-hidden="true" data-forge-review-skeleton={view}>
{SKELETON_ROWS.slice(0, count).map((row, index) => view === 'compact'
? (
<div key={index} className={css.skeletonCompact}>
<span className={clsx(loading.fill, css.skeletonGlyph)} />
<span className={css.skeletonText}>
<span className={clsx(loading.fill, css.skeletonBar)} style={{ width: `${row.title}%` }} />
</span>
<span className={clsx(loading.fill, css.skeletonTime)} />
</div>
)
: (
<div key={index} className={css.skeletonItem}>
<span className={clsx(loading.fill, css.skeletonGlyph)} />
<span className={css.skeletonText}>
<span className={clsx(loading.fill, css.skeletonBar)} style={{ width: `${row.title}%` }} />
{row.wrapped > 0 && <span className={clsx(loading.fill, css.skeletonBar)} style={{ width: `${row.wrapped}%` }} />}
<span className={clsx(loading.fill, css.skeletonBar, css.skeletonMeta)} style={{ width: `${row.meta}%` }} />
</span>
</div>
))}
</div>
)
}
/**
* Render the list column.
* @param props - the latest frame, the reader's choices, and their handlers.
@@ -335,8 +380,9 @@ export function ReviewList(props: ReviewListProps): ReactNode {
)
} else if (frame === undefined) {
body = (
<div className={css.skeleton} aria-busy="true" aria-label={t('reviewPage.loading')}>
{[0, 1, 2, 3].map(index => <span key={index} className={css.skeletonRow} />)}
<div aria-busy="true" aria-label={t('reviewPage.loading')}>
<div className={css.skeletonHeader} aria-hidden="true"><span className={clsx(loading.fill, css.skeletonHeading)} /></div>
<SkeletonItems view={view} count={SKELETON_ROWS.length} />
</div>
)
} else if (sections.length === 0) {
@@ -361,7 +407,7 @@ export function ReviewList(props: ReviewListProps): ReactNode {
{open && <>
<SectionFailure section={section} copyText={copyText} t={t} />
{section.items === null
? section.failure === null && <div className={css.skeleton} aria-busy="true"><span className={css.skeletonRow} /></div>
? section.failure === null && <div aria-busy="true"><SkeletonItems view={view} count={3} /></div>
: shown.length === 0
? <p className={css.sectionEmpty}>{t(query.trim() === '' ? 'reviewPage.empty.section' : 'reviewPage.empty.search')}</p>
: (
@@ -392,18 +392,67 @@
overflow-wrap: anywhere;
}
.skeleton {
/* Skeleton rows copy the boxes of `.sectionHeader`, `.item`, and `.compactItem`: each bar sits on the line of the
text it stands for, so the list does not move when the rows arrive. The fill and pulse are the changes view's. */
.skeletonHeader {
display: flex;
flex-direction: column;
gap: 10px;
align-items: center;
height: 32px;
padding: 0 8px;
}
.skeletonHeading {
width: 72px;
height: 10px;
}
.skeletonItem {
display: flex;
gap: 8px;
padding: 8px;
}
.skeletonRow {
display: block;
height: 36px;
border-radius: var(--dsw-radius-sm);
background: var(--dsw-alias-card-fill);
.skeletonCompact {
display: flex;
align-items: center;
gap: 8px;
height: 32px;
padding: 0 8px;
}
.skeletonGlyph {
flex: none;
width: 16px;
height: 16px;
}
.skeletonItem .skeletonGlyph {
margin-top: 2px;
}
.skeletonText {
display: flex;
flex: 1;
flex-direction: column;
min-width: 0;
}
/* A 10px bar centered on a 20px title line. */
.skeletonBar {
height: 10px;
margin: 5px 0;
}
/* An 8px bar centered on the 18px meta line, 2px below the title as in `.itemText`. */
.skeletonMeta {
height: 8px;
margin-top: 7px;
}
.skeletonTime {
flex: none;
width: 28px;
height: 8px;
}
.empty,
@@ -64,8 +64,25 @@ function inRepository(number: number, owner: string, name: string, overrides: Pa
describe('ReviewList states', () => {
it('shows a skeleton until the first frame, and a retry once the list stream stopped without one', () => {
const loading = renderList()
expect(loading.view.getByLabelText('Reading the lists').getAttribute('aria-busy')).toBe('true')
const busy = loading.view.getByLabelText('Reading the lists')
expect(busy.getAttribute('aria-busy')).toBe('true')
expect(loading.view.getByRole('heading', { name: 'Code review' })).toBeTruthy()
// The skeleton is a heading bar above rows laid out as detailed items: a glyph, one or two title lines, and a meta line.
expect(busy.textContent).toBe('')
const rows = busy.querySelectorAll(`[data-forge-review-skeleton="detailed"] > .${css.skeletonItem}`)
expect(rows).toHaveLength(6)
expect([...rows].map(row => row.querySelectorAll(`.${css.skeletonBar}`).length)).toEqual([3, 2, 3, 2, 3, 3])
expect(rows[0]?.querySelectorAll(`.${css.skeletonMeta}`)).toHaveLength(1)
expect(busy.querySelector('[data-forge-review-skeleton]')?.getAttribute('aria-hidden')).toBe('true')
expect(busy.querySelector(`.${css.skeletonHeading}`)).not.toBeNull()
cleanup()
// The compact view reads as one-line rows: a glyph, a title bar, and a time bar.
const compact = renderList({ view: 'compact' })
const lines = compact.view.getByLabelText('Reading the lists').querySelectorAll(`[data-forge-review-skeleton="compact"] > .${css.skeletonCompact}`)
expect(lines).toHaveLength(6)
expect(lines[0]?.querySelectorAll(`.${css.skeletonBar}`)).toHaveLength(1)
expect(lines[0]?.querySelector(`.${css.skeletonTime}`)).not.toBeNull()
cleanup()
const stopped = renderList({ stopped: { code: 'ended', message: '' } })
@@ -141,9 +158,9 @@ describe('ReviewList sections', () => {
expect(b.view.queryByText(/more not listed/)).toBeNull()
})
it('shows a skeleton row for a list no host has read yet, and only the failure once a read failed', () => {
it('shows skeleton rows for a list no host has read yet, and only the failure once a read failed', () => {
const b = renderList({ frame: frame(host({ authored: list(null), involved: failedList('unavailable', 'GitHub is down') })) })
expect(b.section('authored').querySelector('[aria-busy="true"]')).not.toBeNull()
expect(b.section('authored').querySelectorAll(`[aria-busy="true"] .${css.skeletonItem}`)).toHaveLength(3)
expect(within(b.section('authored')).queryByRole('button', { name: /\d/ })).toBeNull()
const involved = b.section('involved')
expect(involved.querySelector('[aria-busy="true"]')).toBeNull()