feat(web): move change requests into the Session panel
The forge panel's right-sidebar tab, its header button, and its start-page entry are replaced by Session panel entries: a Change requests section with its count and refresh, checkout and local changes rows plus a refresh in the Environment section, and an attention mark on the panel toggle. Change request cards keep their expandable rows and move their actions into a More menu; Merge stays below the rows. Environment rows receive the section owner values so a row that opens the sidebar can close the overlay, and PanelRow gains an action label for its button.
This commit is contained in:
1 parent
261f470411
commit
4f3b71a4e9
57 files changed
+1575
-1782
No files matched your search
@@ -9,8 +9,8 @@
|
||||
en: 344bcc7e9825bbc8
|
||||
zh: c1d0f4b54f5b3786
|
||||
/agent-note-change-request-panel-and-worktree-sessions/decision:
|
||||
en: 66bde24e7c601eb6
|
||||
zh: 5091591f3dc1ac85
|
||||
en: 4a16ecfeee0effbf
|
||||
zh: a56f0d2d6acb26c7
|
||||
/agent-note-change-request-panel-and-worktree-sessions/deferred:
|
||||
en: 32ef8af85f4d2f66
|
||||
zh: b82b67f94346399e
|
||||
|
||||
@@ -10,7 +10,7 @@ English | [中文](2026-10-09-forge-panel.zh.md)
|
||||
|
||||
## Decision
|
||||
|
||||
[`dsh-experimental-client-ui-forge`](../../../../packages/experimental/client-ui-forge/README.md) is a two-face package. Its Host half, the `forgePanel` Remote, assembles everything the panel shows for one Session into one streamed state; the forge registry and the binding service keep only their domain operations. Its Client half is a right-sidebar tab, a Session header button that shows or hides it, a New Session option, a creation card above the composer, a toast, and the [Session list icons and hover card section](2026-10-20-forge-session-list.md). Every surface calls a bound item a change request, the forge registry's term, whatever its code host calls it. The [forge bundle](../../../../packages/experimental/forge-bundle/README.md) ships the panel, the forge registry, the GitHub provider, the bindings, the worktree model tool, and an isolated worktree service for the panel as one default-disabled Plugins page entry.
|
||||
[`dsh-experimental-client-ui-forge`](../../../../packages/experimental/client-ui-forge/README.md) is a two-face package. Its Host half, the `forgePanel` Remote, assembles everything the panel shows for one Session into one streamed state; the forge registry and the binding service keep only their domain operations. Its Client half is a Change requests section, checkout and local changes rows, and an attention mark in the [Session panel](2026-11-05-session-panel.md), a changes view, a New Session option, a creation card above the composer, a toast, and the [Session list icons and hover card section](2026-10-20-forge-session-list.md). Every surface calls a bound item a change request, the forge registry's term, whatever its code host calls it. The [forge bundle](../../../../packages/experimental/forge-bundle/README.md) ships the panel, the forge registry, the GitHub provider, the bindings, the worktree model tool, and an isolated worktree service for the panel as one default-disabled Plugins page entry.
|
||||
|
||||
Review and worktree controls serve one code-change workflow. One Plugins entry lets users enable that workflow without having to distinguish the underlying package split. Packages and the two worktree services remain independent so each owns its before-Session or in-conversation creation flow.
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ Status: implemented
|
||||
|
||||
## Decision
|
||||
|
||||
[`dsh-experimental-client-ui-forge`](../../../../packages/experimental/client-ui-forge/README.zh.md) 是一个双端包。宿主端的 `forgePanel` Remote 把面板为一个 Session 展示的全部内容组装成一条流式状态;forge 注册表与绑定服务只保留各自的领域操作。客户端包括一个右侧边栏标签页、一个显示或隐藏它的 Session 标题栏按钮、一个新会话选项、一张位于输入框上方的创建卡片、一个 toast,以及[会话列表中的图标与悬浮卡片部分](2026-10-20-forge-session-list.zh.md)。所有界面都把已绑定的条目称为变更请求(forge 注册表的术语),不随代码托管平台的叫法变化。[forge 套件](../../../../packages/experimental/forge-bundle/README.zh.md)把面板、forge 注册表、GitHub 提供方、绑定服务、工作树模型工具与面板使用的一个隔离 worktree 服务作为插件页中默认禁用的一个条目发布。
|
||||
[`dsh-experimental-client-ui-forge`](../../../../packages/experimental/client-ui-forge/README.zh.md) 是一个双端包。宿主端的 `forgePanel` Remote 把面板为一个 Session 展示的全部内容组装成一条流式状态;forge 注册表与绑定服务只保留各自的领域操作。客户端包括[会话面板](2026-11-05-session-panel.zh.md)中的“变更请求”分栏、检出行与本地变更行和提醒标记,以及一个变更视图、一个新会话选项、一张位于输入框上方的创建卡片、一个 toast,以及[会话列表中的图标与悬浮卡片部分](2026-10-20-forge-session-list.zh.md)。所有界面都把已绑定的条目称为变更请求(forge 注册表的术语),不随代码托管平台的叫法变化。[forge 套件](../../../../packages/experimental/forge-bundle/README.zh.md)把面板、forge 注册表、GitHub 提供方、绑定服务、工作树模型工具与面板使用的一个隔离 worktree 服务作为插件页中默认禁用的一个条目发布。
|
||||
|
||||
评审与工作树控件服务于同一个代码修改流程。统一插件入口让用户可以一次启用这些能力,无需根据底层包的拆分判断应该开启哪张卡片。包与两套工作树服务仍保持独立,分别负责会话开始前和对话中创建工作树的流程。
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
- button "代码审查和变更 查看代码变更与本会话的变更请求"
|
||||
@@ -1073,7 +1073,7 @@ export interface Config {
|
||||
worktreePrefix?: string
|
||||
/** Largest diff, file read to show unchanged lines, or list of base branch refs, in bytes. */
|
||||
maxDiffBytes?: number
|
||||
/** Most untracked files a local diff or the local changes card includes. */
|
||||
/** Most untracked files a local diff or the local changes row includes. */
|
||||
maxUntrackedFiles?: number
|
||||
/** Most UTF-8 bytes of change request diffs kept in memory for later reads at the same head commit and base branch. */
|
||||
maxCachedDiffBytes?: number
|
||||
|
||||
@@ -1075,7 +1075,7 @@ export interface Config {
|
||||
worktreePrefix?: string
|
||||
/** Largest diff, file read to show unchanged lines, or list of base branch refs, in bytes. */
|
||||
maxDiffBytes?: number
|
||||
/** Most untracked files a local diff or the local changes card includes. */
|
||||
/** Most untracked files a local diff or the local changes row includes. */
|
||||
maxUntrackedFiles?: number
|
||||
/** Most UTF-8 bytes of change request diffs kept in memory for later reads at the same head commit and base branch. */
|
||||
maxCachedDiffBytes?: number
|
||||
|
||||
@@ -18,5 +18,5 @@
|
||||
en: 13dfd36f2166bba0
|
||||
zh: a369434f52f04d57
|
||||
/forges/panel:
|
||||
en: dbc28e731f357edf
|
||||
zh: a1977fafc0651427
|
||||
en: a3792c668f83bb5e
|
||||
zh: 07e9dae5338814a2
|
||||
@@ -567,7 +567,7 @@ type ForgeChangeRequestStatesFrame =
|
||||
| { readonly type: 'changed'; readonly states: readonly ForgeChangeRequestListState[] }
|
||||
```
|
||||
|
||||
The changes view reads through the same Remote. `localDiff` reads one `ForgeLocalScope` of the Session's checkout, and `changeRequestDiff` reads a bound change request at the head of its latest status through the provider's `diff`; both return files that the Host parsed into `ForgeDiffFile` hunks. `localText` and `changeRequestText` read the new side of one file, which supplies the unchanged lines between hunks. Each inspection also sizes the `branch` scope as `ForgePanelState.local` for the panel's local changes card, always against the automatic fork point. A `branch` scope whose `base` names a ref compares with the merge base of HEAD and that branch instead; `diffBases` lists the branches the view offers, with the automatic fork point.
|
||||
The changes view reads through the same Remote. `localDiff` reads one `ForgeLocalScope` of the Session's checkout, and `changeRequestDiff` reads a bound change request at the head of its latest status through the provider's `diff`; both return files that the Host parsed into `ForgeDiffFile` hunks. `localText` and `changeRequestText` read the new side of one file, which supplies the unchanged lines between hunks. Each inspection also sizes the `branch` scope as `ForgePanelState.local` for the Session panel's local changes row, always against the automatic fork point. A `branch` scope whose `base` names a ref compares with the merge base of HEAD and that branch instead; `diffBases` lists the branches the view offers, with the automatic fork point.
|
||||
|
||||
```ts type-equiv
|
||||
/** Which local changes a diff covers; each reads the Session's checkout through Git. */
|
||||
@@ -707,7 +707,7 @@ interface ForgeChangedFile {
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/** Size of the `branch` scope, which the panel's local changes card shows. */
|
||||
/** Size of the `branch` scope, which the Session panel's local changes row shows. */
|
||||
interface ForgeLocalChanges {
|
||||
/** Ref or abbreviated commit the scope compares with. */
|
||||
readonly base: string
|
||||
|
||||
@@ -567,7 +567,7 @@ type ForgeChangeRequestStatesFrame =
|
||||
| { readonly type: 'changed'; readonly states: readonly ForgeChangeRequestListState[] }
|
||||
```
|
||||
|
||||
变更视图经同一个 Remote 读取。`localDiff` 读取 Session 检出的某个 `ForgeLocalScope`;`changeRequestDiff` 经提供方的 `diff` 读取已绑定变更请求在其最新状态 head 处的变更;两者返回的文件都已在宿主上解析为 `ForgeDiffFile` 的 hunk。`localText` 与 `changeRequestText` 读取一个文件的新版本,用来补出 hunk 之间未变更的行。每次检查还会把 `branch` 范围的规模统计为 `ForgePanelState.local`,供面板的变更卡片使用,始终以自动分叉点为准。`base` 指定了引用的 `branch` 范围改为与 HEAD 和该分支的合并基准比较;`diffBases` 列出视图可选的分支以及自动分叉点。
|
||||
变更视图经同一个 Remote 读取。`localDiff` 读取 Session 检出的某个 `ForgeLocalScope`;`changeRequestDiff` 经提供方的 `diff` 读取已绑定变更请求在其最新状态 head 处的变更;两者返回的文件都已在宿主上解析为 `ForgeDiffFile` 的 hunk。`localText` 与 `changeRequestText` 读取一个文件的新版本,用来补出 hunk 之间未变更的行。每次检查还会把 `branch` 范围的规模统计为 `ForgePanelState.local`,供会话面板的本地变更行使用,始终以自动分叉点为准。`base` 指定了引用的 `branch` 范围改为与 HEAD 和该分支的合并基准比较;`diffBases` 列出视图可选的分支以及自动分叉点。
|
||||
|
||||
```ts type-equiv
|
||||
/** Which local changes a diff covers; each reads the Session's checkout through Git. */
|
||||
@@ -707,7 +707,7 @@ interface ForgeChangedFile {
|
||||
```
|
||||
|
||||
```ts type-equiv
|
||||
/** Size of the `branch` scope, which the panel's local changes card shows. */
|
||||
/** Size of the `branch` scope, which the Session panel's local changes row shows. */
|
||||
interface ForgeLocalChanges {
|
||||
/** Ref or abbreviated commit the scope compares with. */
|
||||
readonly base: string
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
en: ead6be55c7c9d7cf
|
||||
zh: 125ad36db7328551
|
||||
/deepseek-ai-dsh-client-ui-primitives/use-this-package/component-catalog:
|
||||
en: 57f5e3f2dc9eb425
|
||||
zh: 4159654b2604ec5d
|
||||
en: 4d2a0739ff2bbd7d
|
||||
zh: 07cb9e5020164ee3
|
||||
/deepseek-ai-dsh-client-ui-primitives/use-this-package/controls-and-icons:
|
||||
en: 2fc65b908307b52e
|
||||
zh: e5c1181ecd2da6e5
|
||||
|
||||
@@ -55,7 +55,7 @@ Check this table before writing a control in a feature package. A plugin cannot
|
||||
| `SegmentedTabs` | Controlled equal-width tabs with a sliding indicator and Left/Right, Home, and End navigation. The caller supplies labels, tab/panel ids, and panel content. Default `size="md"` is 42px tall with a 4px inset; `size="sm"` is 34px tall with a 2px inset. |
|
||||
| `Tag` | Read-only capsule badge; `tone` selects one of eight palettes. |
|
||||
| `PathLabel` | Single-line file path with subdued directories, a primary filename, and the full path on hover. Fitting paths align left; clipped paths preserve their suffix with a left-edge fade that updates on path and size changes. |
|
||||
| `PanelRow` | One fact row of a summary panel: a 16px decorative icon, single-line content that clips with an ellipsis, and an optional trailing value or control. The icon inherits the row ink. `onActivate` turns the icon and content into one button with hover and pressed fills while the trailing area stays outside it; other attributes, such as context-menu trigger props, reach the outer element. |
|
||||
| `PanelRow` | One fact row of a summary panel: a 16px decorative icon, single-line content that clips with an ellipsis, and an optional trailing value or control. The icon inherits the row ink. `onActivate` turns the icon and content into one button with hover and pressed fills while the trailing area stays outside it, and `actionLabel` names that button when its content does not describe the action; other attributes, such as context-menu trigger props, reach the outer element. |
|
||||
| `StateDot` | Solid green `done`, amber `warning`, red `error`, and neutral-grey `idle` marks in a 10px slot, plus a tertiary-grey 14px rotating `ongoing` loader whose animations pin to document time zero on mount and on every animation restart, such as a list reorder, so every visible loader rotates in phase. `aria-hidden`, so the render site owns the name. `appearance="step"` shows a filled check for completion and a hollow pending circle. |
|
||||
| `ConnectionIndicator` | Inline connection-recovery control across outage, retry, and recovered states. |
|
||||
| `DisclosureRow` | 24px compact disclosure that lays title and content side by side. The header supplies tertiary at rest and secondary on hover; text and icons inherit it regardless of expandability or open state unless the caller supplies a feature-specific override. Semantic status colors remain explicit. Collapsed rows preview a down chevron on hover, and expanded rows keep an up chevron visible. `headerAccessory` places an independent action outside the disclosure target and shimmer; with an accessory, the title row shrinks to its content width. Memoized with shallow prop comparison; keep callbacks and React-node props stable when their content is unchanged. |
|
||||
|
||||
@@ -55,7 +55,7 @@ kind: "package-library"
|
||||
| `SegmentedTabs` | 受控的等宽分段标签,支持滑动指示条及左/右方向键、Home、End 导航。调用方提供文案、标签与面板 id,以及面板内容。默认 `size="md"` 总高 42px、内边距 4px;`size="sm"` 总高 34px、内边距 2px。 |
|
||||
| `Tag` | 只读胶囊徽章;`tone` 选择八种配色之一。 |
|
||||
| `PathLabel` | 单行文件路径:目录使用弱化颜色,文件名使用主色,悬停可查看完整路径。空间足够时靠左显示;溢出时保留尾部并在左侧渐隐,路径或尺寸变化时更新。 |
|
||||
| `PanelRow` | 摘要面板中的一行事实:16px 装饰图标、单行内容(溢出时以省略号截断)以及可选的尾部数值或控件。图标沿用行文字颜色。传入 `onActivate` 时,图标与内容成为同一个按钮,带悬停与按下填充,尾部区域留在按钮之外;其余属性(例如右键菜单触发属性)落在外层元素上。 |
|
||||
| `PanelRow` | 摘要面板中的一行事实:16px 装饰图标、单行内容(溢出时以省略号截断)以及可选的尾部数值或控件。图标沿用行文字颜色。传入 `onActivate` 时,图标与内容成为同一个按钮,带悬停与按下填充,尾部区域留在按钮之外,内容不足以说明操作时用 `actionLabel` 为该按钮命名;其余属性(例如右键菜单触发属性)落在外层元素上。 |
|
||||
| `StateDot` | 10px 槽内的绿色 `done`、琥珀色 `warning`、红色 `error`、中性灰色 `idle` 圆点,以及 tertiary 灰色 14px 旋转 `ongoing` loading,其动画在挂载时以及每次动画重启(如列表重排)时固定到文档时间零点,所以所有可见 loading 同相旋转。它是 `aria-hidden` 的,名称由渲染点提供。 `appearance="step"` 以实心勾表示完成、空心圆表示等待。 |
|
||||
| `ConnectionIndicator` | 行内连接恢复控件,覆盖断线、重试与已恢复三种状态。 |
|
||||
| `DisclosureRow` | 24px 紧凑折叠行,标题与内容左右排列。标题行默认使用 tertiary,悬停时使用 secondary;文字与图标继承该颜色,不受能否展开及开合状态影响,调用方可提供功能专属覆盖。语义状态色保持显式指定。收起时悬停预览向下箭头,展开后持续显示向上箭头。`headerAccessory` 将独立操作放在折叠触发区域和流光之外;有此操作时,标题行收窄到内容宽度。使用浅层 prop 比较进行 memo;内容未变时,保持回调与 React 节点 prop 的引用稳定。 |
|
||||
|
||||
@@ -15,6 +15,8 @@ export interface PanelRowProps extends Omit<HTMLAttributes<HTMLElement>, 'childr
|
||||
readonly trailing?: ReactNode
|
||||
/** Make the icon and content one button with this action; the trailing area stays outside it. */
|
||||
readonly onActivate?: (() => void) | undefined
|
||||
/** Accessible name of the `onActivate` button when its visible content does not describe the action. */
|
||||
readonly actionLabel?: string | undefined
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,7 +24,7 @@ export interface PanelRowProps extends Omit<HTMLAttributes<HTMLElement>, 'childr
|
||||
* @param props - row content, the optional action, and attributes for the outer element.
|
||||
* @returns the row element.
|
||||
*/
|
||||
export function PanelRow({ icon, children, trailing, onActivate, className, ...attributes }: PanelRowProps) {
|
||||
export function PanelRow({ icon, children, trailing, onActivate, actionLabel, className, ...attributes }: PanelRowProps) {
|
||||
const body = (
|
||||
<>
|
||||
<span className={css.icon} aria-hidden="true">{icon}</span>
|
||||
@@ -33,7 +35,7 @@ export function PanelRow({ icon, children, trailing, onActivate, className, ...a
|
||||
<div {...attributes} className={clsx(css.row, className)} data-panel-row="">
|
||||
{onActivate === undefined
|
||||
? <span className={css.body}>{body}</span>
|
||||
: <button type="button" className={clsx(css.body, css.action)} onClick={onActivate}>{body}</button>}
|
||||
: <button type="button" className={clsx(css.body, css.action)} aria-label={actionLabel} onClick={onActivate}>{body}</button>}
|
||||
{trailing !== undefined && <span className={css.trailing}>{trailing}</span>}
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -29,6 +29,13 @@ describe('PanelRow', () => {
|
||||
expect(onActivate).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('names the button with the action label', () => {
|
||||
const onActivate = vi.fn()
|
||||
render(<PanelRow icon={<svg />} onActivate={onActivate} actionLabel="View the changes: 2 files">Local changes</PanelRow>)
|
||||
fireEvent.click(screen.getByRole('button', { name: 'View the changes: 2 files' }))
|
||||
expect(onActivate).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('forwards attributes such as context-menu handlers to the outer element', () => {
|
||||
const onContextMenu = vi.fn()
|
||||
const view = render(<PanelRow icon={<svg />} className="placed" onContextMenu={onContextMenu} tabIndex={0}>Row</PanelRow>)
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
en: d152484eb41ac6b4
|
||||
zh: 09388d293f9be9cb
|
||||
/deepseek-ai-dsh-client-ui-session-panel/use-this-package:
|
||||
en: d7818d67e981be3c
|
||||
zh: c7c0c704d5ef8b34
|
||||
en: c3e1c124690fe7f2
|
||||
zh: 435963ef49c6c940
|
||||
/deepseek-ai-dsh-client-ui-session-panel/use-this-package/docking-and-the-overlay:
|
||||
en: 1d99ccdba0457d10
|
||||
zh: 81833d87548d3225
|
||||
/deepseek-ai-dsh-client-ui-session-panel/use-this-package/contribute-a-section:
|
||||
en: 3e9463ce11beff16
|
||||
zh: d10d474c06afa3ca
|
||||
en: d31097f494d1a163
|
||||
zh: ce1e35fe7b1d6b91
|
||||
/deepseek-ai-dsh-client-ui-session-panel/understand-the-implementation:
|
||||
en: e59cf3dc6b08e893
|
||||
zh: 33548291a59090c2
|
||||
|
||||
@@ -25,7 +25,7 @@ English | [中文](README.zh.md)
|
||||
<a id="use-this-package"></a>
|
||||
## Use this package
|
||||
|
||||
The `@deepseek-ai/dsh-web-app` bundle loads this package by default. The toggle is the first Session header utility, before change requests, sharing, and the schedule catalog. It is an icon button with the panel name and its indicators as its accessible name, a tooltip that says whether a press shows or hides the panel, and `aria-expanded` for whether the panel shows.
|
||||
The `@deepseek-ai/dsh-web-app` bundle loads this package by default. The toggle is the first Session header utility, before sharing and the schedule catalog. It is an icon button with the panel name and its indicators as its accessible name, a tooltip that says whether a press shows or hides the panel, and `aria-expanded` for whether the panel shows.
|
||||
|
||||
### Docking and the overlay
|
||||
|
||||
@@ -36,9 +36,9 @@ A narrower gutter hides the docked panel, so it never covers the transcript. Thi
|
||||
<a id="contribute-a-section"></a>
|
||||
### Contribute a section
|
||||
|
||||
A section is one `conversation.session.panel.section` list registration: `id` addresses it, `order` sorts it ascending, and the required `label` is its title, which the panel draws in the active locale. The section component receives `presentation` (`docked` or `overlay`) and `dismissOverlay()` as owner props; it renders its body and renders nothing when it has nothing to show, which hides its title too. Register trailing title controls, such as a count or a refresh button, in the keyed `conversation.session.panel.section.actions` slot under the section's `id`. A section without a label is reported to the console and not shown.
|
||||
A section is one `conversation.session.panel.section` list registration: `id` addresses it, `order` sorts it ascending, and the required `label` is its title, which the panel draws in the active locale. The section component receives `presentation` (`docked` or `overlay`) and `dismissOverlay()` as owner props; it renders its body and renders nothing when it has nothing to show, which hides its title too. Register trailing title controls, such as a count or a refresh button, in the keyed `conversation.session.panel.section.actions` slot under the section's `id`. A section without a label is reported to the console and not shown. The shipped sections are Environment (`order: 0`), Change requests from the [forge bundle](../../experimental/client-ui-forge/README.md) (`100`), [Subagents](../ui-subagent/README.md) (`200`), and [Background jobs](../ui-jobs/README.md) (`300`).
|
||||
|
||||
Plugins share a title by registering rows in a section owner's row slot. The built-in Environment section (`id: 'environment'`, `order: 0`) declares `conversation.session.panel.environment.row`; its `project` row (`order: 0`) shows the directory of the Workspace that lists the Session, or the directory the Session was created in, with the Host home abbreviated to `~`. Right-clicking the row or pressing its More button opens the shared `directory` context menu. A plugin that owns a shared section declares its own row slot the same way.
|
||||
Plugins share a title by registering rows in a section owner's row slot. The built-in Environment section (`id: 'environment'`, `order: 0`) declares `conversation.session.panel.environment.row`, whose rows receive the same owner props as a section; its `project` row (`order: 0`) shows the directory of the Workspace that lists the Session, or the directory the Session was created in, with the Host home abbreviated to `~`. Right-clicking the row or pressing its More button opens the shared `directory` context menu. The forge bundle adds its checkout and local changes rows at orders 20 and 30. A plugin that owns a shared section declares its own row slot the same way.
|
||||
|
||||
Marks that must stay visible while the panel is hidden, such as an attention dot, go in the `conversation.session.panel.indicator` list. Each occupant includes text that names it, which becomes part of the toggle's accessible name.
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ kind: "package-reference"
|
||||
<a id="use-this-package"></a>
|
||||
## 使用本包
|
||||
|
||||
`@deepseek-ai/dsh-web-app` 套件默认加载本包。开关是会话标题栏的第一个工具按钮,位于变更请求、共享和计划任务目录之前。它是图标按钮:无障碍名称由面板名称和其角标组成,提示文字说明按下后是显示还是隐藏面板,`aria-expanded` 表示面板当前是否显示。
|
||||
`@deepseek-ai/dsh-web-app` 套件默认加载本包。开关是会话标题栏的第一个工具按钮,位于共享和计划任务目录之前。它是图标按钮:无障碍名称由面板名称和其角标组成,提示文字说明按下后是显示还是隐藏面板,`aria-expanded` 表示面板当前是否显示。
|
||||
|
||||
### 停靠与浮层
|
||||
|
||||
@@ -36,9 +36,9 @@ kind: "package-reference"
|
||||
<a id="contribute-a-section"></a>
|
||||
### 贡献分栏
|
||||
|
||||
一个分栏是 `conversation.session.panel.section` 列表里的一次注册:`id` 用于寻址,`order` 升序排列,必填的 `label` 是标题,面板按当前语言绘制。分栏组件通过 owner props 收到 `presentation`(`docked` 或 `overlay`)和 `dismissOverlay()`;它负责渲染正文,没有内容时什么都不渲染,标题随之隐藏。标题尾部的控件(例如计数或刷新按钮)注册到以分栏 `id` 为键的 keyed slot `conversation.session.panel.section.actions`。缺少 label 的分栏会报告到控制台,并且不显示。
|
||||
一个分栏是 `conversation.session.panel.section` 列表里的一次注册:`id` 用于寻址,`order` 升序排列,必填的 `label` 是标题,面板按当前语言绘制。分栏组件通过 owner props 收到 `presentation`(`docked` 或 `overlay`)和 `dismissOverlay()`;它负责渲染正文,没有内容时什么都不渲染,标题随之隐藏。标题尾部的控件(例如计数或刷新按钮)注册到以分栏 `id` 为键的 keyed slot `conversation.session.panel.section.actions`。缺少 label 的分栏会报告到控制台,并且不显示。内置的分栏依次是「环境」(`order: 0`)、[forge 套件](../../experimental/client-ui-forge/README.zh.md)的「变更请求」(`100`)、[「子智能体」](../ui-subagent/README.zh.md)(`200`)和[「后台任务」](../ui-jobs/README.zh.md)(`300`)。
|
||||
|
||||
多个插件共用一个标题时,把行注册到分栏拥有者的行 slot 中。内置「环境」分栏(`id: 'environment'`,`order: 0`)声明 `conversation.session.panel.environment.row`;其 `project` 行(`order: 0`)显示列出本会话的工作区目录,或会话创建时所在的目录,宿主家目录缩写为 `~`。右键该行或点其「更多」按钮会打开共享的 `directory` 上下文菜单。拥有共享分栏的插件用同样方式声明自己的行 slot。
|
||||
多个插件共用一个标题时,把行注册到分栏拥有者的行 slot 中。内置「环境」分栏(`id: 'environment'`,`order: 0`)声明 `conversation.session.panel.environment.row`,其中的行与分栏收到相同的 owner props;其 `project` 行(`order: 0`)显示列出本会话的工作区目录,或会话创建时所在的目录,宿主家目录缩写为 `~`。右键该行或点其「更多」按钮会打开共享的 `directory` 上下文菜单。forge 套件在 order 20 与 30 处添加检出行与本地变更行。拥有共享分栏的插件用同样方式声明自己的行 slot。
|
||||
|
||||
面板隐藏时也要可见的标记(例如需要处理的红点)放进 `conversation.session.panel.indicator` 列表。每个占位都带有说明自身的文字,这些文字会成为开关无障碍名称的一部分。
|
||||
|
||||
|
||||
@@ -3,11 +3,12 @@ import type { ReactNode } from 'react'
|
||||
import type { EnvironmentSectionProps } from './slots.ts'
|
||||
|
||||
/**
|
||||
* Render the Environment rows. The rows render straight into the section
|
||||
* body, so a section without rows renders nothing and the panel hides it.
|
||||
* @param props - the section's child renderer.
|
||||
* Render the Environment rows with the section's owner values. The rows render
|
||||
* straight into the section body, so a section without rows renders nothing
|
||||
* and the panel hides it.
|
||||
* @param props - the section's owner values and child renderer.
|
||||
* @returns the row outlet.
|
||||
*/
|
||||
export function EnvironmentSection({ renderSlot }: EnvironmentSectionProps): ReactNode {
|
||||
return renderSlot('conversation.session.panel.environment.row', {})
|
||||
export function EnvironmentSection({ presentation, dismissOverlay, renderSlot }: EnvironmentSectionProps): ReactNode {
|
||||
return renderSlot('conversation.session.panel.environment.row', { presentation, dismissOverlay })
|
||||
}
|
||||
@@ -31,8 +31,8 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
||||
* assistive technology, which becomes part of the toggle's name.
|
||||
*/
|
||||
'conversation.session.panel.indicator': { kind: 'list'; scope: 'session'; inline: true }
|
||||
/** Rows of the built-in Environment section in ascending `order`. */
|
||||
'conversation.session.panel.environment.row': { kind: 'list'; scope: 'session' }
|
||||
/** Rows of the built-in Environment section in ascending `order`; they receive the section's owner values. */
|
||||
'conversation.session.panel.environment.row': { kind: 'list'; scope: 'session'; owner: SessionPanelSectionOwnerProps }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -206,10 +206,12 @@ describe('SessionPanel', () => {
|
||||
})
|
||||
|
||||
describe('EnvironmentSection', () => {
|
||||
it('renders its rows straight into the section body', () => {
|
||||
it('renders its rows straight into the section body with the section owner values', () => {
|
||||
const renderSlot = vi.fn(() => <span>row</span>)
|
||||
render(<>{EnvironmentSection({ renderSlot } as EnvironmentSectionProps)}</>)
|
||||
expect(renderSlot).toHaveBeenCalledWith('conversation.session.panel.environment.row', {})
|
||||
const dismissOverlay = vi.fn<() => void>()
|
||||
render(<>{EnvironmentSection({ presentation: 'overlay', dismissOverlay, renderSlot } as Pick<EnvironmentSectionProps,
|
||||
'presentation' | 'dismissOverlay' | 'renderSlot'> as EnvironmentSectionProps)}</>)
|
||||
expect(renderSlot).toHaveBeenCalledWith('conversation.session.panel.environment.row', { presentation: 'overlay', dismissOverlay })
|
||||
expect(screen.getByText('row')).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -9,17 +9,17 @@
|
||||
en: 8ca3d802a44c6fd1
|
||||
zh: 2723c9e28ecea7f7
|
||||
/deepseek-ai-dsh-experimental-client-ui-forge/summary:
|
||||
en: ba5e34b6896e03e6
|
||||
zh: 516d4ae6aa123804
|
||||
en: 0f41644693170a1b
|
||||
zh: d54b0fc08c83878f
|
||||
/deepseek-ai-dsh-experimental-client-ui-forge/table-of-contents:
|
||||
en: d152484eb41ac6b4
|
||||
zh: 2f8a621b991260a1
|
||||
/deepseek-ai-dsh-experimental-client-ui-forge/use-this-package:
|
||||
en: 058035fcf2a43fd0
|
||||
zh: 92d4f4f3e68d0fc5
|
||||
en: 36c2a3a1c64b15ff
|
||||
zh: 2f0f01c08cfe0148
|
||||
/deepseek-ai-dsh-experimental-client-ui-forge/understand-the-implementation:
|
||||
en: 80ba18c47e570e5e
|
||||
zh: 2f0fce0affa48f59
|
||||
en: 81d0ada37c09eb47
|
||||
zh: b16b0f2ece5b997f
|
||||
/deepseek-ai-dsh-experimental-client-ui-forge/further-exploration:
|
||||
en: fa4d8c579ffc49ff
|
||||
zh: 5856ed7469e4585b
|
||||
|
||||
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
|
||||
|
||||
## Summary
|
||||
|
||||
This optional package shows a Session's created or pushed change requests and their changes, and starts new Sessions in their own Git worktrees. The Host `forgePanel` Remote inspects the checkout using the Session's permissions, checks code host sign-in, streams [bound change requests](../forge-session/README.md) with their polled status for one Session or for the Session list, reads diffs, and creates a requested worktree while the first message waits in the Session's inbox. The Client adds a sidebar tab, a changes view, header entries, a New Session option, a creation card, Session list icons, and toasts.
|
||||
This optional package shows a Session's created or pushed change requests and their changes, and starts new Sessions in their own Git worktrees. The Host `forgePanel` Remote inspects the checkout using the Session's permissions, checks code host sign-in, streams [bound change requests](../forge-session/README.md) with their polled status for one Session or for the Session list, reads diffs, and creates a requested worktree while the first message waits in the Session's inbox. The Client adds entries to the [Session panel](../../client/ui-session-panel/README.md), a changes view, a New Session option, a creation card, Session list icons, and toasts.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
@@ -31,13 +31,13 @@ Panel text follows the application language: Chinese, English, Japanese, Spanish
|
||||
|
||||
- **Worktree option** — on the New Session screen, New worktree sits beside the current branch at the right end of the row with the workspace and mode pickers. Both stay hidden outside a Git checkout. The branch is read-only until New worktree is checked, when it becomes the base branch selector; the menu lists recent local branches. If permissions block an existing request, its selected base stays visible without a selector and the request can still be withdrawn. Hovering, focusing, or tapping the read-only branch or base shows its full description. The option is disabled, with the reason in its tooltip, in a read-only Session and when the checkout or its Git directory lies outside the Session's writable root, as for a project that is itself a linked worktree. Sending the first message hands it to the Session at once, and it waits there while the branch `dsh-<first 8 hexadecimal digits of the Session id>-<4 random hexadecimal digits>` is created from the base under the repository's `.agents/worktrees/` and its checkout becomes the Session's working directory; the message's turn starts once the worktree exists.
|
||||
- **Creation card** — while the worktree is created, a card above the composer shows the new branch and its two steps, 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 with a new branch name, and Continue without a worktree withdraws the request so the message goes on in the current checkout.
|
||||
- **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 tab, 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 tab's Restore turns into a spinner. Continue in the project moves the Session to the source checkout. Meanwhile the tab's first row shows a warning glyph.
|
||||
- **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.
|
||||
- **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.
|
||||
- **Session panel** — the Environment section of the Session panel gains the checkout and local changes rows after the project row and a Refresh button beside its title, which inspects a checkout changed outside the Session again; a Change requests section follows it. A red 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 adds the path with the Host home shortened to `~`. 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 tooltip shows the failure; outside a Git checkout there is no row.
|
||||
- **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. 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** — whenever the `branch` scope changes files, independently of bound change requests, a card above the change requests names the ref it compares with, such as `HEAD → origin/main`, which is always the default base below, 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 when the code host repository is recognized and no open change request (including drafts) has the checked-out branch as its head, 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. Its header names the checked-out branch, or the abbreviated commit on a detached HEAD, and the base branch, which opens a searchable menu: first Default, the base commit of the worktree the Session created, else the merge base of HEAD with the default branch of the code host remote, then remote-tracking and then local branches, each most recently committed first, without the checked-out branch and, outside a created worktree, without the remote-tracking branch Default already names. Typing filters the listed rows at once and lists the branches whose names contain the text, ignoring case, after a short pause; Enter chooses the first row. Choosing another branch compares with the merge base of HEAD and that branch. The tab keeps the choice while other scopes show; closing the tab or reloading the application returns it to Default. When the chosen branch is gone, its name is struck through, and when it shares no history with HEAD, the view says so as well; both offer Use the default base branch instead of Retry. A narrow view hides the note that uncommitted changes count, then the checked-out branch. 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.
|
||||
- **Change requests section** — shows while the Session has bound change requests. Its title carries their count and Refresh, which 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 above the cards shows the `gh auth login` command when sign-in is missing. 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 toggle's red dot does. The card's More menu offers Open in browser, Copy change request link, View changes for a change request a provider serves, Ready for review for an open draft, 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. A change request the host would merge now offers Merge below its rows, 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, and a card the user expands or collapses keeps that choice across updates.
|
||||
- **Local changes row** — whenever the `branch` scope changes files, independently of bound change requests, the row names the number of changed files with the added and deleted lines and opens the changes view. Its More menu offers View changes and, when the code host repository is recognized and no open change request (including drafts) has the checked-out branch as its head, Create change request, which sends the Session a user message in the UI language that asks the Agent to create a change request for these changes; a toast reports whether it was sent.
|
||||
- **Changes view** — The Changes row and View changes item of a change request card and the local changes row open a right-sidebar tab that lists the changed files, closing the Session panel while it floats over the conversation. The local tab is named Local changes and shows Branch by default: the working tree and untracked files against the fork point. Its header names the checked-out branch, or the abbreviated commit on a detached HEAD, and the base branch, which opens a searchable menu: first Default, the base commit of the worktree the Session created, else the merge base of HEAD with the default branch of the code host remote, then remote-tracking and then local branches, each most recently committed first, without the checked-out branch and, outside a created worktree, without the remote-tracking branch Default already names. Typing filters the listed rows at once and lists the branches whose names contain the text, ignoring case, after a short pause; Enter chooses the first row. Choosing another branch compares with the merge base of HEAD and that branch. The tab keeps the choice while other scopes show; closing the tab or reloading the application returns it to Default. When the chosen branch is gone, its name is struck through, and when it shares no history with HEAD, the view says so as well; both offer Use the default base branch instead of Retry. A narrow view hides the note that uncommitted changes count, then the checked-out branch. 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.
|
||||
|
||||
The checks row initially shows the polling preview. While it is incomplete, the card uses the host’s aggregate outcome without a failure count and labels the loaded check count as partial. Opening the list loads the remaining pages for that PR through `changeRequestChecks`; its deadline is independent of polling. A failed read keeps the preview and offers Retry. Closing the list, changing the head, or unmounting cancels the read; late results are ignored. Reopening reads current details. The Remote requires a visible Session binding and rejects a response for a different head commit.
|
||||
|
||||
@@ -57,7 +57,7 @@ All files opens a searchable directory tree. Single-child directories share a ro
|
||||
|
||||
`ForgePanelController` keeps one `SessionPanel` per followed Session and disposes it when the last follower leaves. A panel starts with the Session's working directory and bindings, re-inspects after each `working-directory/change`, `tool/result`, and `sandbox/mode` event, and publishes a new `ForgePanelState` for every change. Each change request keeps the latest snapshot a poll returned while later polls fail. A failed parallel Git read cancels and joins its siblings. Inspections run one at a time with one trailing rerun, and a result for a directory the Session has since left is dropped. The code host comes from the remotes in order: the upstream's remote, then `origin`, then the rest. When an inspection finds an upstream branch on a remote a provider recognizes, the panel asks `ctx.forgeSession.discoverBranch` to bind that branch's open change requests, once per remote and branch until a refresh. A sign-in probe runs when the recognized host changes and on refresh, within `readinessTimeoutMs`; a refresh settles once the inspection and the probe it started have ended, and poll results arrive later.
|
||||
|
||||
Inspection runs `rev-parse --show-toplevel`, `rev-parse --path-format=absolute --git-common-dir`, `rev-parse --path-format=absolute --git-dir`, `symbolic-ref --short HEAD`, `rev-parse --short HEAD`, `rev-parse --abbrev-ref @{upstream}`, and `remote -v`; `branches` runs `symbolic-ref` and `for-each-ref --count=<maxBranches>`; `diffBases` finds the default fork point as `localDiff` does below, runs `for-each-ref --sort=-committerdate` over `refs/heads/` and `refs/remotes/` within `maxDiffBytes`, leaves out symbolic refs such as `origin/HEAD`, and keeps at most `maxBranches` branches of each kind whose names contain the query. Inspection then sizes the `branch` scope for the local changes card: it finds the fork point, runs `diff --numstat -z -M` against it with the same helper and submodule restrictions as `localDiff` below, and lists untracked files. Every command uses the Session's resolved sandbox mode: `read-only` and `workspace-write` require confinement, while `danger-full-access` runs without a sandbox backend. Commands disable optional index writes, hooks, the filesystem monitor, prompts, and lazy object fetches, remove inherited Git selectors and secret-bearing variables, and use their own `gitTimeoutMs` deadline and `maxOutputBytes` limit per stream. The top-level, Git, and common Git directories Git prints are resolved through `ctx.fs` into the canonical process paths that the working-directory service records; a checkout whose Git directory differs from the common one is a linked worktree. The worktree option is usable under the `danger-full-access` sandbox mode, never under `read-only`, and under `workspace-write` only when both directories lie inside the canonical workspace root of the Session's sandbox policy.
|
||||
Inspection runs `rev-parse --show-toplevel`, `rev-parse --path-format=absolute --git-common-dir`, `rev-parse --path-format=absolute --git-dir`, `symbolic-ref --short HEAD`, `rev-parse --short HEAD`, `rev-parse --abbrev-ref @{upstream}`, and `remote -v`; `branches` runs `symbolic-ref` and `for-each-ref --count=<maxBranches>`; `diffBases` finds the default fork point as `localDiff` does below, runs `for-each-ref --sort=-committerdate` over `refs/heads/` and `refs/remotes/` within `maxDiffBytes`, leaves out symbolic refs such as `origin/HEAD`, and keeps at most `maxBranches` branches of each kind whose names contain the query. Inspection then sizes the `branch` scope for the local changes row: it finds the fork point, runs `diff --numstat -z -M` against it with the same helper and submodule restrictions as `localDiff` below, and lists untracked files. Every command uses the Session's resolved sandbox mode: `read-only` and `workspace-write` require confinement, while `danger-full-access` runs without a sandbox backend. Commands disable optional index writes, hooks, the filesystem monitor, prompts, and lazy object fetches, remove inherited Git selectors and secret-bearing variables, and use their own `gitTimeoutMs` deadline and `maxOutputBytes` limit per stream. The top-level, Git, and common Git directories Git prints are resolved through `ctx.fs` into the canonical process paths that the working-directory service records; a checkout whose Git directory differs from the common one is a linked worktree. The worktree option is usable under the `danger-full-access` sandbox mode, never under `read-only`, and under `workspace-write` only when both directories lie inside the canonical workspace root of the Session's sandbox policy.
|
||||
|
||||
A worktree request is a `plugin:client-ui-forge/worktree` record, folded by the `forgeWorktree` projection: requests and withdrawals apply until the first `turn/start` or creation, and the first `created` record of an open request applies until the first `step/start`. The projection also records the Session's directory from its header and each `working-directory/change`; its client view, which the Session summary carries, is the created worktree while that directory is the worktree or lies below it, else null. `requestWorktree` refuses with `forgePanel/session-started` after a turn started or the worktree was created, with `forgePanel/worktrees-unavailable` without a `worktrees` service, and with `forgePanel/invalid-branch` for an empty branch; `cancelWorktree` refuses only with the first and needs no `worktrees` service; both forget a failed attempt. When a message enters the inbox of a Session whose request is open, an `agent/inbox/inserted` listener starts maintenance of the Session's Agent before the delivery wakes it, so the Agent latches the wake and starts the message's turn once that hold ends. The hold makes one attempt with a new branch name, publishing the running stage in the panel state with `held` set and `waiting` as `creation`, and records `created` with the source repository root. After a failed attempt, whose branch, base, failed step, and reason stay in the panel state as `failure`, or after `stopCreation`, the hold waits: `retryWorktree` makes another attempt, refused with `forgePanel/not-waiting` while none waits or one runs, and withdrawing the request lets the message go on in the current checkout. Each message that enters while the Agent is idle and the Session works in its created worktree starts a hold that checks whether the worktree is missing; while it is, the hold waits with `waiting` as `restoration`, and `restoreWorktree` or `continueInProject` runs inside it and then lets the message go on; a check that cannot answer lets the message go at once. The Agent's cancellation and the Remote's stop end a hold, and a message that enters while the Agent runs a turn or other maintenance gets none. The worktree service queues the working-directory notice, which the first step claims. An `agent/pre-step` listener creates the worktree at step 1 of a Session whose request is still open, which covers a message no hold took; it moves the notice into the proposed messages, and a failure ends the turn with the request kept. `restoreWorktree` and `continueInProject` run as maintenance of their own while no message waits; `restoreWorktree` publishes its running step as `restoration`, and clears `missing` in the same state that ends it. The bundle isolates its `worktrees` service, so enabling Git Worktrees as well leaves two independent services. `track` rejects a URL no provider recognizes with `forgePanel/unrecognized-url`. `markReady` and `merge` act only on a visible binding of the Session that a provider serves, else they refuse with `forgePanel/not-bound`; `merge` passes the head commit the card showed, and a moved head refuses with `forgePanel/stale-head`, while any other refusal is `forgePanel/action-failed` with the host's reason.
|
||||
|
||||
@@ -66,11 +66,11 @@ Restoration records `restoring` before mutation and `restored` only after succes
|
||||
|
||||
Each inspection also decides whether the worktree is missing: the Session's directory lies inside the created worktree, `ctx.fs.lstat` finds no directory there, and `show-ref` in the source repository tells whether the branch still exists.
|
||||
|
||||
`localDiff` takes the fork point from the created worktree's `baseCommit` when the Session works in it, else, for each remote in the code host order, from `symbolic-ref --quiet --short refs/remotes/<remote>/HEAD` and `merge-base HEAD`; without one the `branch` scope refuses with `forgePanel/no-fork-point`. A `branch` scope that names a base ref under `refs/heads/` or `refs/remotes/` instead takes `merge-base HEAD` with it once `show-ref --verify` finds the ref, refusing with `forgePanel/base-missing` when the ref does not exist and with `forgePanel/no-fork-point` when HEAD shares no history with it; another ref name is refused before Git runs. It runs `diff --no-ext-diff --no-textconv --submodule=short --ignore-submodules=dirty --no-color -M` with fixed `a/` and `b/` prefixes and `core.quotePath=false` against the fork point, against HEAD (the empty tree before the first commit), against the index, or with `--cached` against HEAD. Before patches and statistics, Git configuration is read to apply command-local clean/process filter overrides. A failed or truncated configuration read stops the comparison: `localDiff` reports `forgePanel/filter-config-failed`, with a retry after correcting Git configuration or the output limit; failed statistics leave the local changes card hidden. Filter enumeration uses `maxDiffBytes` for patches and `maxOutputBytes` for statistics. Untracked files, at most `maxUntrackedFiles` with the rest counted as omitted, come from `ls-files --others --exclude-standard -z` and are read through `ctx.fs` as new files, binary when their first 8,000 bytes hold a NUL byte or they are not UTF-8. A patch, file list, or file over `maxDiffBytes` refuses with `forgePanel/diff-too-large`, and a directory outside a checkout with `forgePanel/not-a-checkout`. The Host parses patches with jsdiff into files and hunks, so the browser receives no raw patch. `localText` reads the new side of one file, from the index through `show :<path>` for Staged and through `ctx.fs` otherwise, and refuses a path that leaves the checkout. `changeRequestDiff` and `changeRequestText` act only on a visible binding a provider serves, else they refuse with `forgePanel/not-bound`; they read the head commit of the binding's latest status through the provider's `diff` and `fileText`, refuse a `too-large` failure with `forgePanel/diff-too-large`, and refuse with `forgePanel/diff-failed` before a status was read or when the host refuses otherwise. The Host keeps the patches `changeRequestDiff` read, one per change request at its head commit and base branch, and drops the least recently read once they exceed `maxCachedDiffBytes`; a later read at the same head and base answers from memory for any Session, and a failed read is not kept. The commits the checkout has beyond the head come from `symbolic-ref`, `cat-file -e`, and `rev-list --count`, and are null when the checked-out branch is not the head branch, the head commit is absent, or Git fails.
|
||||
`localDiff` takes the fork point from the created worktree's `baseCommit` when the Session works in it, else, for each remote in the code host order, from `symbolic-ref --quiet --short refs/remotes/<remote>/HEAD` and `merge-base HEAD`; without one the `branch` scope refuses with `forgePanel/no-fork-point`. A `branch` scope that names a base ref under `refs/heads/` or `refs/remotes/` instead takes `merge-base HEAD` with it once `show-ref --verify` finds the ref, refusing with `forgePanel/base-missing` when the ref does not exist and with `forgePanel/no-fork-point` when HEAD shares no history with it; another ref name is refused before Git runs. It runs `diff --no-ext-diff --no-textconv --submodule=short --ignore-submodules=dirty --no-color -M` with fixed `a/` and `b/` prefixes and `core.quotePath=false` against the fork point, against HEAD (the empty tree before the first commit), against the index, or with `--cached` against HEAD. Before patches and statistics, Git configuration is read to apply command-local clean/process filter overrides. A failed or truncated configuration read stops the comparison: `localDiff` reports `forgePanel/filter-config-failed`, with a retry after correcting Git configuration or the output limit; failed statistics leave the local changes row hidden. Filter enumeration uses `maxDiffBytes` for patches and `maxOutputBytes` for statistics. Untracked files, at most `maxUntrackedFiles` with the rest counted as omitted, come from `ls-files --others --exclude-standard -z` and are read through `ctx.fs` as new files, binary when their first 8,000 bytes hold a NUL byte or they are not UTF-8. A patch, file list, or file over `maxDiffBytes` refuses with `forgePanel/diff-too-large`, and a directory outside a checkout with `forgePanel/not-a-checkout`. The Host parses patches with jsdiff into files and hunks, so the browser receives no raw patch. `localText` reads the new side of one file, from the index through `show :<path>` for Staged and through `ctx.fs` otherwise, and refuses a path that leaves the checkout. `changeRequestDiff` and `changeRequestText` act only on a visible binding a provider serves, else they refuse with `forgePanel/not-bound`; they read the head commit of the binding's latest status through the provider's `diff` and `fileText`, refuse a `too-large` failure with `forgePanel/diff-too-large`, and refuse with `forgePanel/diff-failed` before a status was read or when the host refuses otherwise. The Host keeps the patches `changeRequestDiff` read, one per change request at its head commit and base branch, and drops the least recently read once they exceed `maxCachedDiffBytes`; a later read at the same head and base answers from memory for any Session, and a failed read is not kept. The commits the checkout has beyond the head come from `symbolic-ref`, `cat-file -e`, and `rev-list --count`, and are null when the checked-out branch is not the head branch, the head commit is absent, or Git fails.
|
||||
|
||||
`changeRequestStates` streams, for the Session list, the last known number, title, state, draft flag, checks rollup, review decision, and mergeability of every change request that a listed Session the caller may read binds: a `baseline` frame, then `changed` frames. One run serves every stream. Cancellation is observed before initialization and between frames; the last stream and plugin disposal await initialization and accepted writes, then close the run’s storage domain. A later run waits for that closure before reopening the domain and reading its stored states. Binding updates received during listing override its initial snapshot. It lists Sessions through `sessionQuery` without loading them, takes the visible bindings of a loaded Session from `ctx.forgeSession` and of another from its cached `forgeChangeRequests` summary, follows binding changes of loaded Sessions, and subscribes to each bound change request through `ctx.forge.watch`; closed requests use the idle polling cadence, and merged requests remain subscribed for explicit refresh. It stores every changed state in the `forge_panel_change_requests` storage domain under the SHA-256 digest of its URL and drops unbound stored states only when every listed Session has known bindings; a failed write is logged and the state stays in memory. The stream fails when the Host lacks the Session query, projection cache, storage, or Session store service.
|
||||
|
||||
The browser entry mounts the Remote, then the UI. One stream per Session feeds the tab, the header button, the New Session option, and the creation card; it opens with the first subscriber, closes with the last, reopens after a transport reset, and keeps the last state while the Session scope is retained. Releasing that scope closes the stream and removes its cached state. The New Session option fills `conversation.hero.options` and the worktree card `conversation.input.dock`. The worktree card shows a running creation, with Cancel calling `stopCreation` while a message waits for it, or the failed or stopped attempt a message waits after, with Retry calling `retryWorktree` and Continue without a worktree calling `cancelWorktree`. The tab shortens paths with the Host home from the Remote's Host facts, read again after each transport reset. The tab reports its visibility to the header button's pressed state. The header button collapses a docked tab or closes its floating tab. The toast lives in a `shell.overlay` entry so it outlives the tab. One stream of change request states feeds the Session row icons in `sidebar.session.row.trailing` and the hover card section in `sidebar.session.row.hover` while any of them is mounted; both take a Session's worktree and bindings from its Session list summary values. The change request card takes a change request, its snapshot, and optional actions, so another surface can reuse it. The changes view is the `forge-changes` resource tab type: its addresses, `dsh-resource://forge-changes/<session>/local` and `dsh-resource://forge-changes/<session>/change/<url>`, name the source, and a navigation may name a file to scroll to. The tab type enables `keepMounted`, retaining visited bodies and their owning Session references until their tab records end. Its keyed panel hook subscribes only for the visible body; other panel surfaces may keep the shared Session stream open. Its body keeps the scope, base branch, and layout choices of each tab in a slot store, reads through the Remote, and highlights lines with the shared code highlighter; a chip title shows its name with the changes icon.
|
||||
The browser entry mounts the Remote, then the UI. One stream per Session feeds the Session panel entries, the New Session option, and the creation card; it opens with the first subscriber, closes with the last, reopens after a transport reset, and keeps the last state while the Session scope is retained. Releasing that scope closes the stream and removes its cached state. The New Session option fills `conversation.hero.options` and the worktree card `conversation.input.dock`. The worktree card shows a running creation, with Cancel calling `stopCreation` while a message waits for it, or the failed or stopped attempt a message waits after, with Retry calling `retryWorktree` and Continue without a worktree calling `cancelWorktree`. The change requests section is the `change-requests` entry of `conversation.session.panel.section` at order 100 with its count and Refresh in `conversation.session.panel.section.actions`, where the Environment section's Refresh is the `environment` entry; the checkout and local changes rows are `conversation.session.panel.environment.row` entries at orders 20 and 30, after the project row, and the attention mark is a `conversation.session.panel.indicator` entry. The checkout row shortens paths with the Host home from the Remote's Host facts, read again after each transport reset. The toast lives in a `shell.overlay` entry so it outlives the panel. One stream of change request states feeds the Session row icons in `sidebar.session.row.trailing` and the hover card section in `sidebar.session.row.hover` while any of them is mounted; both take a Session's worktree and bindings from its Session list summary values. The change request card takes a change request, its snapshot, and optional actions, so another surface can reuse it. The changes view is the `forge-changes` resource tab type: its addresses, `dsh-resource://forge-changes/<session>/local` and `dsh-resource://forge-changes/<session>/change/<url>`, name the source, and a navigation may name a file to scroll to. The tab type enables `keepMounted`, retaining visited bodies and their owning Session references until their tab records end. Its keyed panel hook subscribes only for the visible body; other panel surfaces may keep the shared Session stream open. Its body keeps the scope, base branch, and layout choices of each tab in a slot store, reads through the Remote, and highlights lines with the shared code highlighter; a chip title shows its name with the changes icon.
|
||||
|
||||
| Source | Responsibility |
|
||||
|---|---|
|
||||
@@ -84,7 +84,10 @@ The browser entry mounts the Remote, then the UI. One stream per Session feeds t
|
||||
| [`src/local-diff.ts`](src/local-diff.ts) | Fork point, local scopes, new-side text, and the `branch` scope summary |
|
||||
| [`src/client/mount.ts`](src/client/mount.ts) | Remote mount, slot entries, and action outcome mapping |
|
||||
| [`src/client/ChangeRequestCard.tsx`](src/client/ChangeRequestCard.tsx) | Reusable change request card |
|
||||
| [`src/client/LocalChangesCard.tsx`](src/client/LocalChangesCard.tsx) | Local changes card |
|
||||
| [`src/client/ChangeRequestsSection.tsx`](src/client/ChangeRequestsSection.tsx) | Change requests section and its title control |
|
||||
| [`src/client/EnvironmentRows.tsx`](src/client/EnvironmentRows.tsx) | Checkout and local changes rows |
|
||||
| [`src/client/AttentionIndicator.tsx`](src/client/AttentionIndicator.tsx) | Attention mark on the Session panel toggle |
|
||||
| [`src/client/RefreshButton.tsx`](src/client/RefreshButton.tsx) | Refresh button beside a section title |
|
||||
| [`src/client/ChangesTab.tsx`](src/client/ChangesTab.tsx) | Changes view |
|
||||
| [`src/client/BaseMenu.tsx`](src/client/BaseMenu.tsx) | Base branch menu of the Branch scope |
|
||||
| [`src/client/DiffFile.tsx`](src/client/DiffFile.tsx) | One file of the changes view |
|
||||
|
||||
@@ -9,7 +9,7 @@ kind: "package-reference"
|
||||
|
||||
## 概述
|
||||
|
||||
这个可选包展示 Session 创建或推送的变更请求及其变更,并让新 Session 在自己的 Git worktree 中开始。宿主端的 `forgePanel` Remote 使用 Session 的权限检查检出,检查代码托管平台的登录状态,为单个 Session 或会话列表以流的形式推送[已绑定变更请求](../forge-session/README.zh.md)及其轮询状态,读取 diff,并在第一条消息于 Session 的收件箱中等待时创建所请求的 worktree。客户端增加一个侧边栏标签页、一个变更视图、标题栏中的入口、一个新会话选项、一张创建卡片、会话列表中的图标,以及 toast 提示。
|
||||
这个可选包展示 Session 创建或推送的变更请求及其变更,并让新 Session 在自己的 Git worktree 中开始。宿主端的 `forgePanel` Remote 使用 Session 的权限检查检出,检查代码托管平台的登录状态,为单个 Session 或会话列表以流的形式推送[已绑定变更请求](../forge-session/README.zh.md)及其轮询状态,读取 diff,并在第一条消息于 Session 的收件箱中等待时创建所请求的 worktree。客户端在[会话面板](../../client/ui-session-panel/README.zh.md)中增加条目,并增加一个变更视图、一个新会话选项、一张创建卡片、会话列表中的图标,以及 toast 提示。
|
||||
|
||||
## 目录
|
||||
|
||||
@@ -31,13 +31,13 @@ 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 在 Session 之外被删除后,输入框上方的卡片会说明这一点;此期间发送的消息会等待、不开始这一轮,直到该 worktree 被恢复或离开,卡片也会说明消息之后会接着发送。“恢复工作树”(会话面板检出行中的“恢复”与之相同)在原目录重新检出该分支;分支也已删除时,从它开始时的提交重新创建分支;恢复期间卡片显示“准备工作树”“检出文件”两个步骤,检出行中的“恢复”变为加载状态。“在项目目录继续”把 Session 移回源检出。此期间检出行显示警示图标。
|
||||
- **会话面板**——会话面板的“环境”分栏在项目行之后增加检出行与本地变更行,标题旁增加“刷新”按钮,用来重新检查在 Session 之外改动过的检出;其后是“变更请求”分栏。打开中的变更请求存在检查失败、被要求修改或冲突时,会话标题栏中的面板开关带红点,面板隐藏时也会显示。
|
||||
- **检出行**——显示当前检出的分支(分离 HEAD 时为“不在分支上”与缩写提交),并说明检出的类型(Session 创建的 worktree 及其基准、其他 worktree 或项目目录);它的提示给出路径,宿主主目录缩写为 `~`。这一行及其“更多”按钮打开检出根目录的目录菜单。worktree 已被删除时显示警示图标并提供“恢复”。无法读取 Git 时,这一行说明这一点,提示中给出失败原因;不在 Git 检出中时不显示这一行。
|
||||
- **会话列表**——Session 在面板为它创建的 worktree 中工作时,会话行的时间之后显示分支图标;另有一个图标显示它最需要关注的变更请求的状态,依次为需要处理、打开、草稿、尚未轮询、已合并、已关闭。打开中的变更请求图标保持会话行的浅色,并用圆点标出检查进行中、已通过或失败;已合并与已关闭的保留各自的状态颜色。会话行的悬浮卡片写出 worktree 分支及其起点,再列出最多三个变更请求的编号、标题、状态与检查,并说明还有多少个。重启后,下次轮询之前显示重启前已知的状态。
|
||||
- **标签页**——顶部一行显示当前检出的分支(分离 HEAD 时为缩写提交),项目目录前显示目录图标、worktree 前显示分支图标,并说明检出的类型(Session 创建的 worktree 及其基准、其他 worktree 或项目目录);它的提示给出路径,宿主主目录缩写为 `~`,旁边的按钮复制完整路径;worktree 已被删除时提供“恢复”。其下每张变更请求卡片显示状态图标、标题(点击在浏览器中打开)与编号;图标区分打开、草稿、已合并与已关闭,打开中的变更请求(草稿除外)检查失败、被要求修改或有冲突时显示为“需要处理”,与标题栏按钮的红点一致。卡片右上角还提供“在浏览器中打开”“复制变更请求链接”与“从本会话移除”,移除后的 toast 提供“撤销”。已取消的检查单独计数;列出的检查没有失败项时,折叠卡片显示取消数量。折叠的卡片还显示打开的变更请求的检查,以及被要求修改、冲突、草稿中最需要注意的一项;已合并或已关闭的则显示结束时间。展开的卡片显示源分支与目标分支,下面每项一行:打开的变更请求依次是检查(点击该行弹出检查列表,失败的排在前面,带耗时与链接)、评审结论与未解决讨论数、合并状态,已合并或已关闭的显示结束时间;最后是按所选界面语言格式化的变更行数,点击该行打开变更视图。打开中的草稿还提供“标记为可评审”;主机现在就会合并的变更请求提供“合并”,其菜单列出仓库允许的合并方式并选中用户常用的一种,打开时固定卡片显示的 head。“确认合并”使用这个 head;轮询发现 head 变化后禁用确认,需重新检查并打开菜单。每次操作的结果都以 toast 报告;该 head 之后有新提交时不会合并。恰好有一个已绑定的变更请求处于打开状态时,它的卡片默认展开。刷新会重新检查检出与登录状态,并立即再次轮询每个变更请求;检查与登录状态确认结束前,刷新图标持续旋转。缺少登录时,横幅显示 `gh auth login` 命令。
|
||||
- **本地变更卡片**——`branch` 范围有文件变更时始终显示,不受已关联变更请求影响。变更请求列表上方的卡片显示比较的基准(例如 `HEAD → origin/main`,始终是下文的默认基准)以及新增、删除行数与文件数,点击打开变更视图;展开的文件列表像变更视图一样标出各个文件,点击某个文件时,变更视图定位到该文件。识别出代码托管仓库、且没有以当前检出分支为源分支的打开中变更请求(含草稿)时,卡片提供“创建变更请求”:它以界面语言向 Session 发送一条用户消息,请 Agent 为这些变更创建变更请求,并以 toast 报告是否已发送。
|
||||
- **变更视图**——展开的变更请求卡片上的“变更”一行与本地变更卡片会打开一个右侧边栏标签页,列出所有变更的文件。本地标签页名为“本地变更”,默认显示“分支”:工作树与未跟踪文件相对于分叉点的变更。它的标题栏写出当前检出的分支(分离 HEAD 时为缩写提交)与基准分支;点击基准分支打开可搜索的菜单:最前面是“默认”,即 Session 创建的 worktree 的基准提交,否则是 HEAD 与代码托管远端默认分支的合并基准;其后依次是远程跟踪分支与本地分支,各按最近提交排序,不含当前检出的分支,不在所创建的 worktree 中时也不含“默认”已经指向的远程跟踪分支。输入文字会立即筛选已列出的行,短暂停顿后列出名称包含该文字(不区分大小写)的分支;按 Enter 选择第一行。选择其他分支后,与 HEAD 和该分支的合并基准比较。标签页切换到其他范围时仍保留这个选择;关闭标签页或重新加载应用后回到“默认”。所选分支已不存在时,它的名称显示删除线;它与 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 下重新打开、刷新与导航都不会再从托管平台读取。
|
||||
- **变更请求分栏**——Session 有已绑定的变更请求时显示。分栏标题旁显示数量与“刷新”:刷新会重新检查检出与登录状态,并立即再次轮询每个变更请求;检查与登录状态确认结束前,刷新图标持续旋转。缺少登录时,卡片上方的横幅显示 `gh auth login` 命令。每张变更请求卡片显示状态图标、标题(点击在浏览器中打开)与编号;图标区分打开、草稿、已合并与已关闭,打开中的变更请求(草稿除外)检查失败、被要求修改或有冲突时显示为“需要处理”,与面板开关的红点一致。卡片的“更多”菜单提供“在浏览器中打开”“复制变更请求链接”、由提供方服务的变更请求的“查看变更”、打开中草稿的“标记为可评审”,以及“从本会话移除”,移除后的 toast 提供“撤销”。已取消的检查单独计数;列出的检查没有失败项时,折叠卡片显示取消数量。折叠的卡片还显示打开的变更请求的检查,以及被要求修改、冲突、草稿中最需要注意的一项;已合并或已关闭的则显示结束时间。展开的卡片显示源分支与目标分支,下面每项一行:打开的变更请求依次是检查(点击该行弹出检查列表,失败的排在前面,带耗时与链接)、评审结论与未解决讨论数、合并状态,已合并或已关闭的显示结束时间;最后是按所选界面语言格式化的变更行数,点击该行打开变更视图。主机现在就会合并的变更请求在各行下方提供“合并”,其菜单列出仓库允许的合并方式并选中用户常用的一种,打开时固定卡片显示的 head。“确认合并”使用这个 head;轮询发现 head 变化后禁用确认,需重新检查并打开菜单。每次操作的结果都以 toast 报告;该 head 之后有新提交时不会合并。恰好有一个已绑定的变更请求处于打开状态时,它的卡片默认展开;用户展开或收起某张卡片后,更新时保持这一选择。
|
||||
- **本地变更行**——`branch` 范围有文件变更时始终显示,不受已关联变更请求影响。这一行显示变更的文件数以及新增、删除行数,点击打开变更视图。它的“更多”菜单提供“查看变更”;识别出代码托管仓库、且没有以当前检出分支为源分支的打开中变更请求(含草稿)时,还提供“创建变更请求”:它以界面语言向 Session 发送一条用户消息,请 Agent 为这些变更创建变更请求,并以 toast 报告是否已发送。
|
||||
- **变更视图**——变更请求卡片上的“变更”一行与“查看变更”菜单项、以及本地变更行会打开一个右侧边栏标签页,列出所有变更的文件;会话面板浮在对话上方时随之关闭。本地标签页名为“本地变更”,默认显示“分支”:工作树与未跟踪文件相对于分叉点的变更。它的标题栏写出当前检出的分支(分离 HEAD 时为缩写提交)与基准分支;点击基准分支打开可搜索的菜单:最前面是“默认”,即 Session 创建的 worktree 的基准提交,否则是 HEAD 与代码托管远端默认分支的合并基准;其后依次是远程跟踪分支与本地分支,各按最近提交排序,不含当前检出的分支,不在所创建的 worktree 中时也不含“默认”已经指向的远程跟踪分支。输入文字会立即筛选已列出的行,短暂停顿后列出名称包含该文字(不区分大小写)的分支;按 Enter 选择第一行。选择其他分支后,与 HEAD 和该分支的合并基准比较。标签页切换到其他范围时仍保留这个选择;关闭标签页或重新加载应用后回到“默认”。所选分支已不存在时,它的名称显示删除线;它与 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 下重新打开、刷新与导航都不会再从托管平台读取。
|
||||
|
||||
检查行先显示轮询预览。不完整时,卡片使用托管平台的总体状态而不显示失败总数,并注明已加载的检查数量尚不完整。打开列表后,经 `changeRequestChecks` 单独读取该 PR 的后续页,时限独立于轮询。读取失败时保留预览并提供重试。关闭列表、head 变化或组件卸载会取消读取,忽略迟到结果;重新打开会读取当前详情。Remote 要求 URL 是该 Session 可见的绑定,并拒绝 head 提交不一致的响应。
|
||||
|
||||
@@ -57,7 +57,7 @@ diff 按文件树的深度优先顺序排列:同层目录在前、文件在后
|
||||
|
||||
`ForgePanelController` 为每个被关注的 Session 保留一个 `SessionPanel`,最后一个关注方离开时销毁它。面板从 Session 的工作目录与绑定开始,在每个 `working-directory/change`、`tool/result` 与 `sandbox/mode` 事件之后重新检查,每次变化都发布新的 `ForgePanelState`。每个变更请求在后续轮询失败时保留最近一次轮询得到的快照。并行 Git 读取失败时会取消并等待同批读取结束。检查一次只运行一个,最多再追加一次;Session 已离开的目录的结果会被丢弃。代码托管平台按远端顺序识别:先是上游所在的远端,然后是 `origin`,最后是其余远端。检查发现提供方识别的远端上有上游分支时,面板调用 `ctx.forgeSession.discoverBranch` 绑定该分支打开状态的变更请求;同一远端与分支在刷新前只查找一次。识别出的托管平台变化时以及刷新时,会在 `readinessTimeoutMs` 内检查登录状态;一次刷新在它触发的检查与登录状态检查结束后完成,轮询结果之后才到达。
|
||||
|
||||
检查运行 `rev-parse --show-toplevel`、`rev-parse --path-format=absolute --git-common-dir`、`rev-parse --path-format=absolute --git-dir`、`symbolic-ref --short HEAD`、`rev-parse --short HEAD`、`rev-parse --abbrev-ref @{upstream}` 与 `remote -v`;`branches` 运行 `symbolic-ref` 与 `for-each-ref --count=<maxBranches>`;`diffBases` 像下文的 `localDiff` 一样找出默认分叉点,在 `maxDiffBytes` 以内对 `refs/heads/` 与 `refs/remotes/` 运行 `for-each-ref --sort=-committerdate`,排除 `origin/HEAD` 等符号引用,每类最多保留 `maxBranches` 个名称包含查询文字的分支。之后,检查会为本地变更卡片统计 `branch` 范围的规模:找出分叉点,对它运行 `diff --numstat -z -M`,采用与下文 `localDiff` 相同的辅助程序和子模块限制,并列出未跟踪文件。每个命令都使用 Session 解析出的沙箱模式:`read-only` 与 `workspace-write` 需要沙箱,`danger-full-access` 无需沙箱后端。命令禁用可选的索引写入、钩子、文件系统监视器、提示与对象的延迟获取,移除继承的 Git 选择器与携带密钥的变量,并各自受 `gitTimeoutMs` 时限与每个输出流的 `maxOutputBytes` 上限约束。Git 打印的顶层目录、Git 目录与公共 Git 目录经 `ctx.fs` 解析为工作目录服务记录的规范进程路径;Git 目录与公共 Git 目录不同的检出是链接 worktree。工作树选项在 `danger-full-access` 沙箱模式下可用,在 `read-only` 下不可用,在 `workspace-write` 下只有两个目录都位于 Session 沙箱策略的规范工作区根内时才可用。
|
||||
检查运行 `rev-parse --show-toplevel`、`rev-parse --path-format=absolute --git-common-dir`、`rev-parse --path-format=absolute --git-dir`、`symbolic-ref --short HEAD`、`rev-parse --short HEAD`、`rev-parse --abbrev-ref @{upstream}` 与 `remote -v`;`branches` 运行 `symbolic-ref` 与 `for-each-ref --count=<maxBranches>`;`diffBases` 像下文的 `localDiff` 一样找出默认分叉点,在 `maxDiffBytes` 以内对 `refs/heads/` 与 `refs/remotes/` 运行 `for-each-ref --sort=-committerdate`,排除 `origin/HEAD` 等符号引用,每类最多保留 `maxBranches` 个名称包含查询文字的分支。之后,检查会为本地变更行统计 `branch` 范围的规模:找出分叉点,对它运行 `diff --numstat -z -M`,采用与下文 `localDiff` 相同的辅助程序和子模块限制,并列出未跟踪文件。每个命令都使用 Session 解析出的沙箱模式:`read-only` 与 `workspace-write` 需要沙箱,`danger-full-access` 无需沙箱后端。命令禁用可选的索引写入、钩子、文件系统监视器、提示与对象的延迟获取,移除继承的 Git 选择器与携带密钥的变量,并各自受 `gitTimeoutMs` 时限与每个输出流的 `maxOutputBytes` 上限约束。Git 打印的顶层目录、Git 目录与公共 Git 目录经 `ctx.fs` 解析为工作目录服务记录的规范进程路径;Git 目录与公共 Git 目录不同的检出是链接 worktree。工作树选项在 `danger-full-access` 沙箱模式下可用,在 `read-only` 下不可用,在 `workspace-write` 下只有两个目录都位于 Session 沙箱策略的规范工作区根内时才可用。
|
||||
|
||||
worktree 请求是一条 `plugin:client-ui-forge/worktree` 记录,由 `forgeWorktree` 投影折叠:请求与撤回在第一个 `turn/start` 或创建之前生效;在第一个 `step/start` 之前,未完成请求的第一条 `created` 记录生效。该投影还从 Session 头部与每个 `working-directory/change` 记录 Session 的目录;它的客户端视图随 Session 摘要下发,在该目录就是所创建的 worktree 或位于其下时为该 worktree,否则为 null。一轮开始或 worktree 已创建之后,`requestWorktree` 以 `forgePanel/session-started` 拒绝;没有 `worktrees` 服务时以 `forgePanel/worktrees-unavailable` 拒绝;分支名为空时以 `forgePanel/invalid-branch` 拒绝;`cancelWorktree` 只以第一种拒绝,也不需要 `worktrees` 服务;两者都会忘掉失败的尝试。消息进入有未完成请求的 Session 的收件箱时,一个 `agent/inbox/inserted` 监听器在这次投递唤醒 Agent 之前启动 Session 所属 Agent 的维护任务,因此 Agent 会暂存唤醒,等这次暂留结束后才开始这条消息的这一轮。暂留使用新分支名进行一次尝试,在面板状态中发布正在进行的阶段,设置 `held`,`waiting` 为 `creation`,并记录带源仓库根目录的 `created`。尝试失败(其分支、基准、失败步骤与原因以 `failure` 留在面板状态中)或经 `stopCreation` 停止后,暂留继续等待:`retryWorktree` 再做一次尝试,没有消息等待或已有尝试进行时以 `forgePanel/not-waiting` 拒绝;撤回请求则让消息在当前检出中继续。Agent 空闲且 Session 在所创建 worktree 中工作时,进入的每条消息都会启动一次暂留,检查该 worktree 是否缺失;缺失期间暂留以 `waiting` 为 `restoration` 等待,`restoreWorktree` 或 `continueInProject` 在暂留内运行,之后放行消息;检查无法给出结果时立即放行。Agent 的取消与 Remote 的停止都会结束暂留;Agent 正在运行一轮或其他维护任务时进入的消息不会被暂留。worktree 服务把工作目录通知排进队列,由第一步认领。一个 `agent/pre-step` 监听器在请求仍未完成的 Session 的第 1 步创建 worktree,覆盖没有被暂留的消息;它把通知移入本步提议的消息,失败时这一轮结束、请求保留。没有消息等待时,`restoreWorktree` 与 `continueInProject` 以各自的维护任务运行;`restoreWorktree` 以 `restoration` 发布正在进行的步骤,并在结束恢复的同一状态中清除 `missing`。套件把它的 `worktrees` 服务隔离,因此同时启用 Git Worktrees 时会有两个互不影响的服务。`track` 以 `forgePanel/unrecognized-url` 拒绝没有提供方识别的 URL。`markReady` 与 `merge` 只作用于该 Session 中由提供方服务的可见绑定,否则以 `forgePanel/not-bound` 拒绝;`merge` 带上卡片显示的 head 提交,head 已变化时以 `forgePanel/stale-head` 拒绝,其他拒绝都是带主机原因的 `forgePanel/action-failed`。
|
||||
|
||||
@@ -66,11 +66,11 @@ worktree 请求是一条 `plugin:client-ui-forge/worktree` 记录,由 `forgeWo
|
||||
|
||||
每次检查还会判断 worktree 是否缺失:Session 的目录位于所创建的 worktree 内,`ctx.fs.lstat` 在那里找不到目录,再由源仓库中的 `show-ref` 判断分支是否还在。
|
||||
|
||||
Session 在所创建的 worktree 中工作时,`localDiff` 以它的 `baseCommit` 为分叉点;否则按代码托管远端的顺序,对每个远端依次运行 `symbolic-ref --quiet --short refs/remotes/<remote>/HEAD` 与 `merge-base HEAD` 找出分叉点;找不到时 `branch` 范围以 `forgePanel/no-fork-point` 拒绝。`branch` 范围指定了 `refs/heads/` 或 `refs/remotes/` 下的基准引用时,`show-ref --verify` 找到该引用后改用 `merge-base HEAD` 与它的结果;引用不存在时以 `forgePanel/base-missing` 拒绝,HEAD 与它没有共同历史时以 `forgePanel/no-fork-point` 拒绝;其他引用名在运行 Git 之前即被拒绝。它以固定的 `a/`、`b/` 前缀和 `core.quotePath=false` 运行 `diff --no-ext-diff --no-textconv --submodule=short --ignore-submodules=dirty --no-color -M`,分别与分叉点、HEAD(第一次提交之前为空树)、暂存区比较,或带 `--cached` 与 HEAD 比较。读取补丁与统计前会查询 Git 配置,应用命令级 clean/process filter 覆盖。配置读取失败或被截断时停止比较:`localDiff` 报告 `forgePanel/filter-config-failed`,修正 Git 配置或读取上限后可重试;统计失败时本地变更卡片保持隐藏。过滤器枚举在读取补丁时使用 `maxDiffBytes` 上限,统计时使用 `maxOutputBytes` 上限。未跟踪文件由 `ls-files --others --exclude-standard -z` 列出,最多 `maxUntrackedFiles` 个,其余计为未列出;它们经 `ctx.fs` 读取并作为新文件加入,前 8,000 字节含 NUL 字节或不是 UTF-8 时视为二进制。补丁、文件列表或文件超过 `maxDiffBytes` 时以 `forgePanel/diff-too-large` 拒绝,目录不在检出中时以 `forgePanel/not-a-checkout` 拒绝。宿主用 jsdiff 把补丁解析为文件与 hunk,浏览器不会收到原始补丁。`localText` 读取一个文件的新版本:“已暂存”经 `show :<path>` 从暂存区读取,其余经 `ctx.fs` 读取;离开检出的路径会被拒绝。`changeRequestDiff` 与 `changeRequestText` 只作用于该 Session 中由提供方服务的可见绑定,否则以 `forgePanel/not-bound` 拒绝;它们经提供方的 `diff` 与 `fileText` 读取绑定最新状态中的 head 提交,`too-large` 失败以 `forgePanel/diff-too-large` 拒绝,尚未读到状态或托管平台以其他原因拒绝时以 `forgePanel/diff-failed` 拒绝。Host 保留 `changeRequestDiff` 读到的补丁,每个变更请求一份,按 head 提交与目标分支区分,总量超过 `maxCachedDiffBytes` 时丢弃最久未读的;之后在同一 head 与目标分支下的读取不论来自哪个 Session 都从内存返回,读取失败的结果不保留。本地分支比 head 多出的提交数由 `symbolic-ref`、`cat-file -e` 与 `rev-list --count` 得出;当前检出分支不是源分支、本地没有 head 提交或 Git 失败时为 null。
|
||||
Session 在所创建的 worktree 中工作时,`localDiff` 以它的 `baseCommit` 为分叉点;否则按代码托管远端的顺序,对每个远端依次运行 `symbolic-ref --quiet --short refs/remotes/<remote>/HEAD` 与 `merge-base HEAD` 找出分叉点;找不到时 `branch` 范围以 `forgePanel/no-fork-point` 拒绝。`branch` 范围指定了 `refs/heads/` 或 `refs/remotes/` 下的基准引用时,`show-ref --verify` 找到该引用后改用 `merge-base HEAD` 与它的结果;引用不存在时以 `forgePanel/base-missing` 拒绝,HEAD 与它没有共同历史时以 `forgePanel/no-fork-point` 拒绝;其他引用名在运行 Git 之前即被拒绝。它以固定的 `a/`、`b/` 前缀和 `core.quotePath=false` 运行 `diff --no-ext-diff --no-textconv --submodule=short --ignore-submodules=dirty --no-color -M`,分别与分叉点、HEAD(第一次提交之前为空树)、暂存区比较,或带 `--cached` 与 HEAD 比较。读取补丁与统计前会查询 Git 配置,应用命令级 clean/process filter 覆盖。配置读取失败或被截断时停止比较:`localDiff` 报告 `forgePanel/filter-config-failed`,修正 Git 配置或读取上限后可重试;统计失败时本地变更行保持隐藏。过滤器枚举在读取补丁时使用 `maxDiffBytes` 上限,统计时使用 `maxOutputBytes` 上限。未跟踪文件由 `ls-files --others --exclude-standard -z` 列出,最多 `maxUntrackedFiles` 个,其余计为未列出;它们经 `ctx.fs` 读取并作为新文件加入,前 8,000 字节含 NUL 字节或不是 UTF-8 时视为二进制。补丁、文件列表或文件超过 `maxDiffBytes` 时以 `forgePanel/diff-too-large` 拒绝,目录不在检出中时以 `forgePanel/not-a-checkout` 拒绝。宿主用 jsdiff 把补丁解析为文件与 hunk,浏览器不会收到原始补丁。`localText` 读取一个文件的新版本:“已暂存”经 `show :<path>` 从暂存区读取,其余经 `ctx.fs` 读取;离开检出的路径会被拒绝。`changeRequestDiff` 与 `changeRequestText` 只作用于该 Session 中由提供方服务的可见绑定,否则以 `forgePanel/not-bound` 拒绝;它们经提供方的 `diff` 与 `fileText` 读取绑定最新状态中的 head 提交,`too-large` 失败以 `forgePanel/diff-too-large` 拒绝,尚未读到状态或托管平台以其他原因拒绝时以 `forgePanel/diff-failed` 拒绝。Host 保留 `changeRequestDiff` 读到的补丁,每个变更请求一份,按 head 提交与目标分支区分,总量超过 `maxCachedDiffBytes` 时丢弃最久未读的;之后在同一 head 与目标分支下的读取不论来自哪个 Session 都从内存返回,读取失败的结果不保留。本地分支比 head 多出的提交数由 `symbolic-ref`、`cat-file -e` 与 `rev-list --count` 得出;当前检出分支不是源分支、本地没有 head 提交或 Git 失败时为 null。
|
||||
|
||||
`changeRequestStates` 为会话列表推送调用方可读的、已列出的 Session 所绑定的每个变更请求的最近编号、标题、状态、草稿标记、检查汇总、评审结论与可合并性:先是一个 `baseline` 帧,之后是 `changed` 帧。所有流共用一次运行。初始化之前和帧之间均响应取消;最后一条流结束及插件卸载会等待初始化与已接受的写入完成,再关闭本次运行的存储域。后续运行会等待该域关闭后重新打开,并读取已存状态。列举期间收到的绑定更新优先于初始快照。它经 `sessionQuery` 列出 Session 而不加载它们,已加载 Session 的可见绑定取自 `ctx.forgeSession`,其他 Session 的取自缓存的 `forgeChangeRequests` 摘要;它跟随已加载 Session 的绑定变化,并经 `ctx.forge.watch` 订阅每个已绑定的变更请求;已关闭的按空闲间隔轮询,已合并的保留订阅以接收显式刷新结果。每个变化了的状态以其 URL 的 SHA-256 摘要为键存入 `forge_panel_change_requests` 存储域,仅在所有已列出 Session 的绑定均已知时删除无人绑定的已存状态;写入失败时记录日志,状态仍保留在内存中。宿主缺少 Session 查询、投影缓存、存储或 Session 存储服务时,流以失败结束。
|
||||
|
||||
浏览器入口先挂载 Remote,再挂载界面。每个 Session 一条流,同时供给标签页、标题栏按钮、新会话选项与创建卡片;第一个订阅方出现时打开,最后一个离开时关闭,传输重置后重新打开,在 Session scope 保留期间保存最后的状态。释放该 scope 时关闭流并移除缓存状态。新会话选项填入 `conversation.hero.options`,worktree 卡片填入 `conversation.input.dock`。worktree 卡片显示正在进行的创建,有消息在等待时“取消”调用 `stopCreation`;或显示消息等待时失败或被停止的那次尝试,“重试”调用 `retryWorktree`,“不使用工作树”调用 `cancelWorktree`。标签页用 Remote 宿主信息中的宿主主目录缩短路径,每次传输重置后重新读取。标签页把自己是否可见报告给标题栏按钮的按下状态。标题栏按钮收起停靠的标签页,或关闭其浮动标签页。toast 位于 `shell.overlay` 条目中,因此比标签页存在得更久。只要 `sidebar.session.row.trailing` 中的会话行图标或 `sidebar.session.row.hover` 中的悬浮卡片部分有一个已挂载,就由同一条变更请求状态流供给它们;两者都从会话列表的摘要值中读取 Session 的 worktree 与绑定。变更请求卡片接收变更请求、它的快照与可选操作,其他界面可以复用。变更视图是 `forge-changes` 资源标签页类型:它的地址 `dsh-resource://forge-changes/<session>/local` 与 `dsh-resource://forge-changes/<session>/change/<url>` 指明来源,导航参数可以指定要滚动到的文件。标签页类型启用 `keepMounted`,将访问过的正文及其所属 Session 引用保留至标签页记录结束。它的 keyed panel hook 仅为可见正文订阅;其他面板界面仍可能保持共享 Session 流开启。它的正文用 slot store 按标签页保存范围、基准分支与布局选择,经 Remote 读取,并用共享的代码高亮器高亮各行;标签页标题显示变更图标与视图名称。
|
||||
浏览器入口先挂载 Remote,再挂载界面。每个 Session 一条流,同时供给会话面板中的条目、新会话选项与创建卡片;第一个订阅方出现时打开,最后一个离开时关闭,传输重置后重新打开,在 Session scope 保留期间保存最后的状态。释放该 scope 时关闭流并移除缓存状态。新会话选项填入 `conversation.hero.options`,worktree 卡片填入 `conversation.input.dock`。worktree 卡片显示正在进行的创建,有消息在等待时“取消”调用 `stopCreation`;或显示消息等待时失败或被停止的那次尝试,“重试”调用 `retryWorktree`,“不使用工作树”调用 `cancelWorktree`。变更请求分栏是 `conversation.session.panel.section` 中 order 为 100 的 `change-requests` 条目,数量与“刷新”位于 `conversation.session.panel.section.actions`,“环境”分栏的“刷新”是其中的 `environment` 条目;检出行与本地变更行是 `conversation.session.panel.environment.row` 中 order 为 20 与 30 的条目,位于项目行之后;提醒标记是 `conversation.session.panel.indicator` 条目。检出行用 Remote 宿主信息中的宿主主目录缩短路径,每次传输重置后重新读取。toast 位于 `shell.overlay` 条目中,因此比面板存在得更久。只要 `sidebar.session.row.trailing` 中的会话行图标或 `sidebar.session.row.hover` 中的悬浮卡片部分有一个已挂载,就由同一条变更请求状态流供给它们;两者都从会话列表的摘要值中读取 Session 的 worktree 与绑定。变更请求卡片接收变更请求、它的快照与可选操作,其他界面可以复用。变更视图是 `forge-changes` 资源标签页类型:它的地址 `dsh-resource://forge-changes/<session>/local` 与 `dsh-resource://forge-changes/<session>/change/<url>` 指明来源,导航参数可以指定要滚动到的文件。标签页类型启用 `keepMounted`,将访问过的正文及其所属 Session 引用保留至标签页记录结束。它的 keyed panel hook 仅为可见正文订阅;其他面板界面仍可能保持共享 Session 流开启。它的正文用 slot store 按标签页保存范围、基准分支与布局选择,经 Remote 读取,并用共享的代码高亮器高亮各行;标签页标题显示变更图标与视图名称。
|
||||
|
||||
| 源码 | 职责 |
|
||||
|---|---|
|
||||
@@ -84,7 +84,10 @@ Session 在所创建的 worktree 中工作时,`localDiff` 以它的 `baseCommi
|
||||
| [`src/local-diff.ts`](src/local-diff.ts) | 分叉点、本地范围、新版本文本与 `branch` 范围摘要 |
|
||||
| [`src/client/mount.ts`](src/client/mount.ts) | Remote 挂载、slot 条目与操作结果映射 |
|
||||
| [`src/client/ChangeRequestCard.tsx`](src/client/ChangeRequestCard.tsx) | 可复用的变更请求卡片 |
|
||||
| [`src/client/LocalChangesCard.tsx`](src/client/LocalChangesCard.tsx) | 本地变更卡片 |
|
||||
| [`src/client/ChangeRequestsSection.tsx`](src/client/ChangeRequestsSection.tsx) | 变更请求分栏及其标题控件 |
|
||||
| [`src/client/EnvironmentRows.tsx`](src/client/EnvironmentRows.tsx) | 检出行与本地变更行 |
|
||||
| [`src/client/AttentionIndicator.tsx`](src/client/AttentionIndicator.tsx) | 会话面板开关上的提醒标记 |
|
||||
| [`src/client/RefreshButton.tsx`](src/client/RefreshButton.tsx) | 分栏标题旁的刷新按钮 |
|
||||
| [`src/client/ChangesTab.tsx`](src/client/ChangesTab.tsx) | 变更视图 |
|
||||
| [`src/client/BaseMenu.tsx`](src/client/BaseMenu.tsx) | “分支”范围的基准分支菜单 |
|
||||
| [`src/client/DiffFile.tsx`](src/client/DiffFile.tsx) | 变更视图中的一个文件 |
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
"@deepseek-ai/dsh-client-locale",
|
||||
"@deepseek-ai/dsh-client-ui-conversation",
|
||||
"@deepseek-ai/dsh-client-ui-layout",
|
||||
"@deepseek-ai/dsh-client-ui-session-panel",
|
||||
"@deepseek-ai/dsh-client-ui-sidebar-right",
|
||||
"@deepseek-ai/dsh-client-ui-workspace"
|
||||
],
|
||||
@@ -75,16 +76,19 @@
|
||||
"@deepseek-ai/cordis": "workspace:~",
|
||||
"@deepseek-ai/dsh-agent": "workspace:*",
|
||||
"@deepseek-ai/dsh-agent-loop-testkit": "workspace:*",
|
||||
"@deepseek-ai/dsh-api-remote-access": "workspace:*",
|
||||
"@deepseek-ai/dsh-api-remotes": "workspace:*",
|
||||
"@deepseek-ai/dsh-api-session-controller": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-locale": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-store": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-test-runtime": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-context-menu": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-conversation": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-layout": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-primitives": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-renderer": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-session": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-session-panel": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-sidebar-right": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-slots": "workspace:*",
|
||||
"@deepseek-ai/dsh-client-ui-workspace": "workspace:*",
|
||||
@@ -99,19 +103,18 @@
|
||||
"@deepseek-ai/dsh-sandbox-policy": "workspace:*",
|
||||
"@deepseek-ai/dsh-session": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-projection": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-projection-cache": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-query": "workspace:*",
|
||||
"@deepseek-ai/dsh-subprocess": "workspace:*",
|
||||
"@deepseek-ai/dsh-subprocess-local": "workspace:*",
|
||||
"@deepseek-ai/dsh-system-prompt": "workspace:*",
|
||||
"@deepseek-ai/dsh-timeout": "workspace:*",
|
||||
"@deepseek-ai/dsh-util-workspace-path": "workspace:*",
|
||||
"@deepseek-ai/dsh-working-directory": "workspace:*",
|
||||
"@testing-library/react": "^16.3.3",
|
||||
"clsx": "^2.1.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"@deepseek-ai/dsh-timeout": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-projection-cache": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-query": "workspace:*",
|
||||
"@deepseek-ai/dsh-api-remote-access": "workspace:*"
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
"files": [
|
||||
"locale/*.json",
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/** Mark over the Session panel toggle while a bound change request needs attention. */
|
||||
|
||||
import type { ReactNode } from 'react'
|
||||
import { StateDot } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-session-panel/client'
|
||||
import type { NS } from './locales.ts'
|
||||
import type { PanelSnapshot } from './source.ts'
|
||||
import { needsAttention } from './status.ts'
|
||||
import css from './Forge.module.css'
|
||||
|
||||
/** Business face of the attention indicator. */
|
||||
export interface AttentionIndicatorInjected {
|
||||
/** Panel snapshot of the Session; bound as `usePanel`. */
|
||||
readonly hooks: { readonly panel: HostObservable<PanelSnapshot> }
|
||||
}
|
||||
|
||||
/** Full props of the attention indicator. */
|
||||
export type AttentionIndicatorProps =
|
||||
PropsRuntime<'conversation.session.panel.indicator'>
|
||||
& InjectFace<AttentionIndicatorInjected>
|
||||
& PropsLocale<typeof NS>
|
||||
|
||||
/**
|
||||
* Render a red dot, named for assistive technology, while any bound change
|
||||
* request has failing checks, requested changes, or a merge conflict.
|
||||
* @param props - panel snapshot hook and copy.
|
||||
* @returns the indicator, or null while nothing needs attention.
|
||||
*/
|
||||
export function AttentionIndicator({ usePanel, t }: AttentionIndicatorProps): ReactNode {
|
||||
const attention = usePanel(snapshot => snapshot.state?.changeRequests.some(needsAttention) === true)
|
||||
if (!attention) return null
|
||||
return (
|
||||
<span className={css.attention} data-forge-attention="">
|
||||
<StateDot state="error" size={6} />
|
||||
<span className={css.visuallyHidden}>{t('header.attention')}</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -2,15 +2,16 @@
|
||||
* One change request as a card: its title links to the host, a one-line
|
||||
* summary shows while collapsed, and while expanded one row per fact (checks,
|
||||
* review, merge state, and the changed lines, which open its changes) above
|
||||
* the ready-for-review or merge action.
|
||||
* the merge action. Opening, copying, viewing changes, marking a draft ready,
|
||||
* and removing live in the card's actions menu.
|
||||
*/
|
||||
|
||||
import { useEffect, useState, type ReactNode } from 'react'
|
||||
import clsx from 'clsx'
|
||||
import {
|
||||
Button, IconChevronDownOutlineRegular, IconChevronRightOutlineRegular, IconCloseOutlineRegular, IconCopyOutlineRegular,
|
||||
IconListPenOutlineRegular, IconRightUpOutlineRegular, IconTriangleRightFillRegular, IconUserOutlineRegular, Menu, MenuItemButton,
|
||||
StateDot, Tooltip,
|
||||
IconEllipsisOutlineRegular, IconListPenOutlineRegular, IconRightUpOutlineRegular, IconTriangleRightFillRegular, IconUserOutlineRegular,
|
||||
Menu, MenuItemButton, StateDot, Tooltip,
|
||||
type MenuEntry,
|
||||
} from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
@@ -22,7 +23,7 @@ import { formatAgo, formatDuration } from './format.ts'
|
||||
import { ChangeRequestGlyph, CheckGlyph } from './glyphs.tsx'
|
||||
import type { ForgePanelKey, NS } from './locales.ts'
|
||||
import { checkCounts, checkDuration, ciSummary, flagOf, numberOf, TONE_LABEL, toneOf } from './status.ts'
|
||||
import css from './ForgeTab.module.css'
|
||||
import css from './Forge.module.css'
|
||||
|
||||
type Translate = PropsLocale<typeof NS>['t']
|
||||
|
||||
@@ -359,7 +360,7 @@ function MergeMenu({ snapshot, name, usual, busy, onMerge, t }: {
|
||||
)
|
||||
}
|
||||
|
||||
/** The footer with the action of an open change request: mark a draft ready, or merge one the host would merge now. */
|
||||
/** The footer with the merge action of an open change request the host would merge now. */
|
||||
function Primary({ entry, snapshot, name, actions, t }: {
|
||||
readonly entry: ForgePanelChangeRequest
|
||||
readonly snapshot: ChangeRequestSnapshot
|
||||
@@ -373,18 +374,8 @@ function Primary({ entry, snapshot, name, actions, t }: {
|
||||
setBusy(true)
|
||||
void action().finally(() => { setBusy(false) })
|
||||
}
|
||||
const { markReady, merge } = actions
|
||||
if (snapshot.state !== 'open') return null
|
||||
if (snapshot.draft) {
|
||||
if (markReady === undefined) return null
|
||||
return (
|
||||
<div className={css.footer}>
|
||||
<Button size="sm" variant="outline" className={css.primaryAction} disabled={busy} onClick={() => { run(() => markReady(entry)) }}>
|
||||
{t('change.markReady')}
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const { merge } = actions
|
||||
if (snapshot.state !== 'open' || snapshot.draft) return null
|
||||
const [usual] = snapshot.mergeMethods
|
||||
if (!snapshot.mergeReady || usual === undefined || merge === undefined) return null
|
||||
return (
|
||||
@@ -401,6 +392,74 @@ function Primary({ entry, snapshot, name, actions, t }: {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* The card's actions menu: open on the host, copy the link, view the changes
|
||||
* of a served change request, mark an open draft ready, and remove the binding.
|
||||
*/
|
||||
function CardMenu({ entry, snapshot, name, url, actions, t }: {
|
||||
readonly entry: ForgePanelChangeRequest
|
||||
readonly snapshot: ChangeRequestSnapshot | null
|
||||
readonly name: string
|
||||
readonly url: string
|
||||
readonly actions: ChangeRequestActions
|
||||
readonly t: Translate
|
||||
}): ReactNode {
|
||||
const [open, setOpen] = useState(false)
|
||||
// One ready request at a time: the item stays disabled until the previous one settles.
|
||||
const [busy, setBusy] = useState(false)
|
||||
const { remove, markReady, viewChanges } = actions
|
||||
const ready = markReady !== undefined && snapshot?.state === 'open' && snapshot.draft
|
||||
? () => {
|
||||
setBusy(true)
|
||||
void markReady(entry).finally(() => { setBusy(false) })
|
||||
}
|
||||
: undefined
|
||||
const items: MenuEntry[] = [
|
||||
{ id: 'open', label: t('change.view'), icon: <IconRightUpOutlineRegular size={14} /> },
|
||||
{ id: 'copy', label: t('change.copy'), icon: <IconCopyOutlineRegular size={14} /> },
|
||||
...viewChanges !== undefined && snapshot !== null && entry.ref !== null
|
||||
? [{ id: 'changes', label: t('change.viewChanges'), icon: <IconListPenOutlineRegular size={14} /> }]
|
||||
: [],
|
||||
...ready === undefined ? [] : [{ id: 'ready', label: t('change.markReady'), disabled: busy }],
|
||||
...remove === undefined ? [] : [
|
||||
{ type: 'separator' as const, id: 'remove-separator' },
|
||||
{ id: 'remove', label: t('change.remove'), icon: <IconCloseOutlineRegular size={14} />, danger: true },
|
||||
],
|
||||
]
|
||||
const select = (id: string): void => {
|
||||
setOpen(false)
|
||||
if (id === 'open') actions.openLink(url)
|
||||
else if (id === 'copy') actions.copyLink(url)
|
||||
else if (id === 'changes') viewChanges?.(entry)
|
||||
else if (id === 'remove') remove?.(entry)
|
||||
else ready?.()
|
||||
}
|
||||
return (
|
||||
<Menu
|
||||
open={open}
|
||||
onClose={() => { setOpen(false) }}
|
||||
portal
|
||||
align="end"
|
||||
anchor={(
|
||||
<Tooltip label={t('change.actions', { name })} side="top" disabled={open}>
|
||||
<button
|
||||
type="button"
|
||||
className={css.iconButton}
|
||||
aria-label={t('change.actions', { name })}
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={open}
|
||||
onClick={() => { setOpen(!open) }}
|
||||
>
|
||||
<IconEllipsisOutlineRegular size={14} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)}
|
||||
items={items}
|
||||
onSelect={select}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function Details({ entry, snapshot, name, now, actions, locale, t }: {
|
||||
readonly entry: ForgePanelChangeRequest
|
||||
readonly snapshot: ChangeRequestSnapshot
|
||||
@@ -464,7 +523,6 @@ export function ChangeRequestCard({ entry, expanded, onToggle, now, actions, loc
|
||||
const meta = expanded
|
||||
? snapshot === null ? null : <Target snapshot={snapshot} t={t} />
|
||||
: notice === undefined ? <Summary snapshot={snapshot} now={now} t={t} /> : null
|
||||
const { remove } = actions
|
||||
return (
|
||||
<li className={css.change} data-forge-change={entry.url} data-expanded={expanded ? '' : undefined}>
|
||||
<div className={css.changeHead}>
|
||||
@@ -490,23 +548,7 @@ export function ChangeRequestCard({ entry, expanded, onToggle, now, actions, loc
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<Tooltip label={t('change.view')} side="top">
|
||||
<button type="button" className={css.iconButton} aria-label={t('change.view')} onClick={() => { actions.openLink(url) }}>
|
||||
<IconRightUpOutlineRegular size={14} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
<Tooltip label={t('change.copy')} side="top">
|
||||
<button type="button" className={css.iconButton} aria-label={t('change.copy')} onClick={() => { actions.copyLink(url) }}>
|
||||
<IconCopyOutlineRegular size={14} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
{remove !== undefined && (
|
||||
<Tooltip label={t('change.remove')} side="top">
|
||||
<button type="button" className={css.iconButton} aria-label={t('change.removeAria', { name })} onClick={() => { remove(entry) }}>
|
||||
<IconCloseOutlineRegular size={14} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)}
|
||||
<CardMenu entry={entry} snapshot={snapshot} name={name} url={url} actions={actions} t={t} />
|
||||
<button
|
||||
type="button"
|
||||
className={css.iconButton}
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
/** Session panel section listing the Session's change requests, and its title control. */
|
||||
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import { Button } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { MergeRequest } from '@deepseek-ai/dsh-experimental-forge/types'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-session-panel/client'
|
||||
import type { ForgePanelChangeRequest, ForgePanelState } from '../types.ts'
|
||||
import { ChangeRequestCard, type ChangeRequestActions } from './ChangeRequestCard.tsx'
|
||||
import type { NS } from './locales.ts'
|
||||
import { RefreshButton } from './RefreshButton.tsx'
|
||||
import type { PanelSnapshot } from './source.ts'
|
||||
import { defaultExpanded } from './status.ts'
|
||||
import css from './Forge.module.css'
|
||||
|
||||
/** Business face of the change requests section. */
|
||||
export interface ChangeRequestsSectionInjected {
|
||||
/** Panel snapshot of the Session and the active language; bound as `usePanel` and `useLocale`. */
|
||||
readonly hooks: {
|
||||
readonly panel: HostObservable<PanelSnapshot>
|
||||
readonly locale: HostObservable<string>
|
||||
}
|
||||
/** Open the stream again after it ended. */
|
||||
readonly reconnect: () => void
|
||||
/**
|
||||
* Reinspect the checkout, probe sign-in, and poll the change requests;
|
||||
* settles once the Host has inspected and probed, after reporting a failure.
|
||||
*/
|
||||
readonly refresh: () => Promise<void>
|
||||
/** Remove a change request from the Session, offering to undo it. */
|
||||
readonly remove: (entry: ForgePanelChangeRequest) => void
|
||||
/** Mark a draft ready for review; settles once the outcome is reported. */
|
||||
readonly markReady: (entry: ForgePanelChangeRequest) => Promise<void>
|
||||
/** Merge a change request as `request` describes; settles once the outcome is reported. */
|
||||
readonly merge: (entry: ForgePanelChangeRequest, request: MergeRequest) => Promise<void>
|
||||
/** Read the complete checks of an opened change request. */
|
||||
readonly readChecks: NonNullable<ChangeRequestActions['readChecks']>
|
||||
/** Open a URL outside the app. */
|
||||
readonly openLink: (url: string) => void
|
||||
/** Copy text to the clipboard and report the outcome. */
|
||||
readonly copyText: (text: string) => void
|
||||
/** Open the changes view of a bound change request in the right sidebar. */
|
||||
readonly viewChanges: (entry: ForgePanelChangeRequest) => void
|
||||
}
|
||||
|
||||
/** Full props of the change requests section. */
|
||||
export type ChangeRequestsSectionProps =
|
||||
PropsRuntime<'conversation.session.panel.section'>
|
||||
& InjectFace<ChangeRequestsSectionInjected>
|
||||
& PropsLocale<typeof NS>
|
||||
|
||||
/** Business face of the section's title control. */
|
||||
export interface ChangeRequestsActionsInjected {
|
||||
/** Panel snapshot of the Session; bound as `usePanel`. */
|
||||
readonly hooks: { readonly panel: HostObservable<PanelSnapshot> }
|
||||
/** Same refresh as the section's. */
|
||||
readonly refresh: () => Promise<void>
|
||||
}
|
||||
|
||||
/** Full props of the section's title control. */
|
||||
export type ChangeRequestsActionsProps =
|
||||
PropsRuntime<'conversation.session.panel.section.actions'>
|
||||
& InjectFace<ChangeRequestsActionsInjected>
|
||||
& PropsLocale<typeof NS>
|
||||
|
||||
type Translate = ChangeRequestsSectionProps['t']
|
||||
|
||||
function SignIn({ state, copyText, t }: {
|
||||
readonly state: ForgePanelState
|
||||
readonly copyText: (text: string) => void
|
||||
readonly t: Translate
|
||||
}): ReactNode {
|
||||
const { repository, readiness } = state
|
||||
if (repository === null || readiness === null || readiness.state === 'ready') return null
|
||||
const host = repository.host
|
||||
if (readiness.state === 'unavailable') {
|
||||
return <div className={css.banner} role="status">{t('signin.unavailable', { host, message: readiness.message ?? '' })}</div>
|
||||
}
|
||||
const command = repository.forge === 'github' ? `gh auth login --hostname ${host}` : undefined
|
||||
return (
|
||||
<div className={css.banner} role="status">
|
||||
<span>{t('signin.title', { host })}</span>
|
||||
{command === undefined
|
||||
? readiness.message !== null && <span className={css.bannerDetail}>{readiness.message}</span>
|
||||
: (
|
||||
<>
|
||||
<code className={css.bannerCommand}>{command}</code>
|
||||
<Button size="sm" variant="outline" className={css.bannerAction} onClick={() => { copyText(command) }}>
|
||||
{t('signin.copy')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the Session's change request cards. The section shows only while the
|
||||
* Session binds at least one change request; the sign-in notice and a lost
|
||||
* stream show above the cards. The only open change request starts expanded;
|
||||
* once the user expands or collapses a card, that choice holds across updates.
|
||||
* Viewing changes closes the panel's overlay.
|
||||
* @param props - panel snapshot hooks, card actions, panel owner values, and copy.
|
||||
* @returns the cards, or null without bound change requests.
|
||||
*/
|
||||
export function ChangeRequestsSection({
|
||||
usePanel, useLocale, dismissOverlay, reconnect, refresh, remove, markReady, merge, readChecks,
|
||||
openLink, copyText, viewChanges, t,
|
||||
}: ChangeRequestsSectionProps): ReactNode {
|
||||
const snapshot = usePanel(current => current)
|
||||
const locale = useLocale(value => value)
|
||||
const [chosen, setChosen] = useState<ReadonlySet<string> | null>(null)
|
||||
const state = snapshot.state
|
||||
if (state === null || state.changeRequests.length === 0) return null
|
||||
const actions: ChangeRequestActions = {
|
||||
openLink, copyLink: copyText, retry: () => { void refresh() }, remove, markReady, merge, readChecks,
|
||||
viewChanges: (entry) => {
|
||||
viewChanges(entry)
|
||||
dismissOverlay()
|
||||
},
|
||||
}
|
||||
const expanded = chosen ?? defaultExpanded(state.changeRequests)
|
||||
const toggle = (url: string): void => {
|
||||
const next = new Set(expanded)
|
||||
if (next.has(url)) next.delete(url)
|
||||
else next.add(url)
|
||||
setChosen(next)
|
||||
}
|
||||
const now = Date.now()
|
||||
return (
|
||||
<div className={css.cards} data-forge-panel="">
|
||||
{snapshot.disconnected && (
|
||||
<div className={css.disconnected} role="status">
|
||||
<span>{t('stream.failed')}</span>
|
||||
<Button size="sm" variant="outline" onClick={reconnect}>{t('retry')}</Button>
|
||||
</div>
|
||||
)}
|
||||
<SignIn state={state} copyText={copyText} t={t} />
|
||||
<ul className={css.list}>
|
||||
{state.changeRequests.map(entry => (
|
||||
<ChangeRequestCard
|
||||
key={entry.url}
|
||||
entry={entry}
|
||||
expanded={expanded.has(entry.url)}
|
||||
onToggle={() => { toggle(entry.url) }}
|
||||
now={now}
|
||||
actions={actions}
|
||||
locale={locale}
|
||||
t={t}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the change request count and a refresh button beside the section title.
|
||||
* @param props - panel snapshot hook, refresh, and copy.
|
||||
* @returns the title control, or null without bound change requests.
|
||||
*/
|
||||
export function ChangeRequestsActions({ usePanel, refresh, t }: ChangeRequestsActionsProps): ReactNode {
|
||||
const count = usePanel(snapshot => snapshot.state?.changeRequests.length ?? 0)
|
||||
if (count === 0) return null
|
||||
return (
|
||||
<>
|
||||
<span className={css.count}>{count}</span>
|
||||
<RefreshButton refresh={refresh} label={t('refresh')} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -527,138 +527,7 @@
|
||||
cursor: progress;
|
||||
}
|
||||
|
||||
/* The local changes card of the panel: its toggle and refs, the view link and create action, then its files. */
|
||||
.local {
|
||||
min-width: 0;
|
||||
border: 0.5px solid var(--dsw-alias-border-l2);
|
||||
border-radius: var(--dsw-radius-md);
|
||||
background: var(--dsw-alias-bg-layer-1);
|
||||
}
|
||||
|
||||
.localHead {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
padding: 8px 12px 2px 6px;
|
||||
}
|
||||
|
||||
.localToggle {
|
||||
display: inline-flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-height: 26px;
|
||||
padding: 0 6px;
|
||||
border: 0;
|
||||
border-radius: var(--dsw-radius-sm);
|
||||
background: transparent;
|
||||
color: var(--dsw-alias-label-primary);
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.localToggle:hover {
|
||||
background: var(--dsw-alias-interactive-bg-hover);
|
||||
}
|
||||
}
|
||||
|
||||
.localToggle svg {
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
transition: transform 120ms ease;
|
||||
}
|
||||
|
||||
.localToggle[aria-expanded='true'] svg {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.localRefs {
|
||||
min-width: 0;
|
||||
margin-left: auto;
|
||||
overflow: hidden;
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
font-family: var(--ds-font-family-code);
|
||||
font-size: 12px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.localRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 4px 10px 10px 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.localView {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
min-height: 28px;
|
||||
margin-left: -6px;
|
||||
padding: 0 6px;
|
||||
border: 0;
|
||||
border-radius: var(--dsw-radius-sm);
|
||||
background: transparent;
|
||||
color: var(--dsw-alias-label-secondary);
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.localView:hover {
|
||||
background: var(--dsw-alias-interactive-bg-hover);
|
||||
}
|
||||
}
|
||||
|
||||
.localCreate {
|
||||
flex: none;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.localFiles {
|
||||
margin: 0;
|
||||
padding: 4px 6px 8px;
|
||||
border-top: 0.5px solid var(--dsw-alias-border-l2);
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.localFile {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
min-height: 28px;
|
||||
padding: 0 6px;
|
||||
border: 0;
|
||||
border-radius: var(--dsw-radius-sm);
|
||||
background: transparent;
|
||||
color: var(--dsw-alias-label-primary);
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.localFile:hover {
|
||||
background: var(--dsw-alias-interactive-bg-hover);
|
||||
}
|
||||
}
|
||||
|
||||
.localFile .menuPath {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.localView:focus-visible,
|
||||
.localToggle:focus-visible,
|
||||
.fileToggle:focus-visible,
|
||||
.localFile:focus-visible,
|
||||
.select:focus-visible,
|
||||
.gap:focus-visible {
|
||||
outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
|
||||
import { changesTitle, parseChangesAddress } from './changes-address.ts'
|
||||
import type { NS } from './locales.ts'
|
||||
import css from './ForgeTab.module.css'
|
||||
import css from './Forge.module.css'
|
||||
|
||||
/** Props of the changes tab title. */
|
||||
export type ChangesTabTitleProps = Pick<PropsRuntime<'sidebar.right.pane.tab.title'>, 'useTabInfo'> & PropsLocale<typeof NS>
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
/** Environment section entries: the Session's checkout and its branch changes, and the section's refresh. */
|
||||
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import {
|
||||
Button, IconBranchOutlineRegular, IconEllipsisOutlineRegular, IconListPenOutlineRegular, IconWarningTriangleOutlineRegular,
|
||||
Menu, PanelRow, StateDot, Tooltip,
|
||||
} from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { HostObservable, InjectFace, PropsLocale, PropsRenderFactories, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { RemoteHostFacts } from '@deepseek-ai/dsh-api-remotes/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-context-menu/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-session-panel/client'
|
||||
import { checkoutLabel } from './checkout.ts'
|
||||
import type { NS } from './locales.ts'
|
||||
import type { PanelSnapshot } from './source.ts'
|
||||
import { RefreshButton } from './RefreshButton.tsx'
|
||||
import { openChangeRequestOf } from './status.ts'
|
||||
import css from './Forge.module.css'
|
||||
|
||||
/** Business face of the Environment section's title control. */
|
||||
export interface EnvironmentActionsInjected {
|
||||
/** Panel snapshot of the Session; bound as `usePanel`. */
|
||||
readonly hooks: { readonly panel: HostObservable<PanelSnapshot> }
|
||||
/** Reinspect the checkout, probe sign-in, and poll the change requests; settles once the Host has inspected and probed. */
|
||||
readonly refresh: () => Promise<void>
|
||||
}
|
||||
|
||||
/** Full props of the Environment section's title control. */
|
||||
export type EnvironmentActionsProps =
|
||||
PropsRuntime<'conversation.session.panel.section.actions'>
|
||||
& InjectFace<EnvironmentActionsInjected>
|
||||
& PropsLocale<typeof NS>
|
||||
|
||||
/** Business face of the checkout row. */
|
||||
export interface CheckoutRowInjected {
|
||||
/** Panel snapshot of the Session and the Host facts; bound as `usePanel` and `useHost`. */
|
||||
readonly hooks: {
|
||||
readonly panel: HostObservable<PanelSnapshot>
|
||||
readonly host: HostObservable<RemoteHostFacts>
|
||||
}
|
||||
/** Check the removed worktree of the Session out again, reporting the outcome. */
|
||||
readonly restore: () => void
|
||||
}
|
||||
|
||||
/** Full props of the checkout row. */
|
||||
export type CheckoutRowProps =
|
||||
PropsRuntime<'conversation.session.panel.environment.row'>
|
||||
& PropsRenderFactories
|
||||
& InjectFace<CheckoutRowInjected>
|
||||
& PropsLocale<typeof NS>
|
||||
|
||||
/** Business face of the local changes row. */
|
||||
export interface LocalChangesRowInjected {
|
||||
/** Panel snapshot of the Session; bound as `usePanel`. */
|
||||
readonly hooks: { readonly panel: HostObservable<PanelSnapshot> }
|
||||
/** Open the local changes view in the right sidebar. */
|
||||
readonly viewLocalChanges: () => void
|
||||
/** Ask the Session's Agent to create a change request for its changes, reporting the outcome. */
|
||||
readonly createChangeRequest: () => void
|
||||
}
|
||||
|
||||
/** Full props of the local changes row. */
|
||||
export type LocalChangesRowProps =
|
||||
PropsRuntime<'conversation.session.panel.environment.row'>
|
||||
& InjectFace<LocalChangesRowInjected>
|
||||
& PropsLocale<typeof NS>
|
||||
|
||||
/**
|
||||
* Render a refresh button beside the Environment title once the panel state
|
||||
* arrived, so a checkout changed outside the Session can be inspected again.
|
||||
* @param props - panel snapshot hook, refresh, and copy.
|
||||
* @returns the button, or null before the first state.
|
||||
*/
|
||||
export function EnvironmentActions({ usePanel, refresh, t }: EnvironmentActionsProps): ReactNode {
|
||||
const known = usePanel(snapshot => snapshot.state !== null)
|
||||
if (!known) return null
|
||||
return <RefreshButton refresh={refresh} label={t('refresh')} />
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the branch the Session works on and the kind of its directory. The
|
||||
* row and its More button open the shared directory menu on the checkout
|
||||
* root; a removed worktree offers Restore instead, and a failed inspection
|
||||
* shows a warning whose tooltip carries the failure.
|
||||
* @param props - panel snapshot and Host facts hooks, restore, menu bindings, and copy.
|
||||
* @returns the row, or null before the first inspection and outside a Git checkout.
|
||||
*/
|
||||
export function CheckoutRow({
|
||||
sessionId, usePanel, useHost, useContextMenu, renderFactorySlot, restore, t,
|
||||
}: CheckoutRowProps): ReactNode {
|
||||
const state = usePanel(snapshot => snapshot.state)
|
||||
const home = useHost(facts => facts.home)
|
||||
const { getTriggerProps } = useContextMenu()
|
||||
if (state === null) return null
|
||||
const label = checkoutLabel(state, home, t)
|
||||
if (label === undefined) {
|
||||
if (state.checkout.state !== 'failed') return null
|
||||
return (
|
||||
<PanelRow className={css.envRow} icon={<IconWarningTriangleOutlineRegular size={16} />} data-forge-checkout="" data-failed="">
|
||||
<Tooltip label={state.checkout.message} side="left">
|
||||
<span className={css.envName} tabIndex={0}>{t('checkout.failed')}</span>
|
||||
</Tooltip>
|
||||
</PanelRow>
|
||||
)
|
||||
}
|
||||
const target = { kind: 'directory', value: { sessionId, path: label.path } } as const
|
||||
const icon = label.missing
|
||||
? <IconWarningTriangleOutlineRegular size={16} />
|
||||
: <IconBranchOutlineRegular size={16} />
|
||||
const name = [label.detached ? t('checkout.detached') : undefined, label.name ?? undefined]
|
||||
.filter(part => part !== undefined).join(' · ')
|
||||
return (
|
||||
<PanelRow
|
||||
{...getTriggerProps(target)}
|
||||
className={css.envRow}
|
||||
icon={icon}
|
||||
data-forge-checkout=""
|
||||
data-missing={label.missing ? '' : undefined}
|
||||
trailing={(
|
||||
<>
|
||||
<span className={css.envNote}>{label.kind}</span>
|
||||
{label.missing
|
||||
? (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
disabled={state.worktree.restoration !== null}
|
||||
icon={state.worktree.restoration === null ? undefined : <StateDot state="ongoing" size={14} />}
|
||||
onClick={restore}
|
||||
>
|
||||
{t('checkout.restore')}
|
||||
</Button>
|
||||
)
|
||||
: renderFactorySlot('contextMenu.button', {
|
||||
target,
|
||||
label: t(label.worktree ? 'checkout.worktreeActions' : 'checkout.projectActions'),
|
||||
className: css.envMore,
|
||||
size: 'sm',
|
||||
})}
|
||||
</>
|
||||
)}
|
||||
>
|
||||
<Tooltip label={label.tooltip} side="left">
|
||||
<span className={css.envName} tabIndex={0}>{name}</span>
|
||||
</Tooltip>
|
||||
</PanelRow>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the size of the branch's changes; the row opens the local changes
|
||||
* view, and its menu offers the view and, without an open change request for
|
||||
* the branch, asking the Agent to create one. Opening the view closes the
|
||||
* panel's overlay.
|
||||
* @param props - panel snapshot hook, view and create actions, panel owner values, and copy.
|
||||
* @returns the row, or null while the branch changes no files.
|
||||
*/
|
||||
export function LocalChangesRow({ usePanel, dismissOverlay, viewLocalChanges, createChangeRequest, t }: LocalChangesRowProps): ReactNode {
|
||||
const local = usePanel(snapshot => snapshot.state?.local ?? null)
|
||||
const creatable = usePanel(snapshot => snapshot.state !== null && snapshot.state.repository !== null
|
||||
&& openChangeRequestOf(snapshot.state) === undefined)
|
||||
const [open, setOpen] = useState(false)
|
||||
if (local === null || local.files.length === 0) return null
|
||||
let additions = 0
|
||||
let deletions = 0
|
||||
for (const file of local.files) {
|
||||
additions += file.additions
|
||||
deletions += file.deletions
|
||||
}
|
||||
const count = local.files.length
|
||||
const view = (): void => {
|
||||
viewLocalChanges()
|
||||
dismissOverlay()
|
||||
}
|
||||
return (
|
||||
<PanelRow
|
||||
className={css.envRow}
|
||||
icon={<IconListPenOutlineRegular size={16} />}
|
||||
onActivate={view}
|
||||
actionLabel={t('changes.local.viewAria', { count, added: additions, deleted: deletions })}
|
||||
data-forge-local=""
|
||||
trailing={(
|
||||
<>
|
||||
<span className={css.diff}>
|
||||
<span className={css.added}>{`+${String(additions)}`}</span>
|
||||
<span className={css.deleted}>{`−${String(deletions)}`}</span>
|
||||
</span>
|
||||
<Menu
|
||||
open={open}
|
||||
onClose={() => { setOpen(false) }}
|
||||
portal
|
||||
align="end"
|
||||
anchor={(
|
||||
<button
|
||||
type="button"
|
||||
className={`${css.iconButton} ${css.envMore}`}
|
||||
aria-label={t('changes.local.actions')}
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={open}
|
||||
onClick={() => { setOpen(!open) }}
|
||||
>
|
||||
<IconEllipsisOutlineRegular size={14} />
|
||||
</button>
|
||||
)}
|
||||
items={[
|
||||
{ id: 'view', label: t('change.viewChanges') },
|
||||
...creatable ? [{ id: 'create', label: t('changes.local.create') }] : [],
|
||||
]}
|
||||
onSelect={(id) => {
|
||||
setOpen(false)
|
||||
if (id === 'create') createChangeRequest()
|
||||
else view()
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
>
|
||||
{t('changes.local.summary', { count })}
|
||||
</PanelRow>
|
||||
)
|
||||
}
|
||||
+73
-131
@@ -1,36 +1,15 @@
|
||||
/* Forge tab body: one scrolling column with the checkout row on top and the
|
||||
Session's change request cards below, at the sidebar's 13px row size. */
|
||||
.root {
|
||||
/* Change request cards in the Session panel section, at the panel's 13px row size. */
|
||||
.cards {
|
||||
--forge-fill: var(--dsw-alias-card-fill);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
box-sizing: border-box;
|
||||
padding: 12px;
|
||||
overflow-y: auto;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
color: var(--dsw-alias-label-primary);
|
||||
font-size: var(--dsh-content-font-size-secondary, 13px);
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
|
||||
/* Loading and disconnected states of a panel without state yet. */
|
||||
.centered {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 24px;
|
||||
color: var(--dsw-alias-label-secondary);
|
||||
font-size: var(--dsh-content-font-size-secondary, 13px);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.disconnected {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -39,91 +18,6 @@
|
||||
color: var(--dsw-alias-label-secondary);
|
||||
}
|
||||
|
||||
.checkout {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
padding: 8px 10px;
|
||||
border-radius: var(--dsw-radius-sm);
|
||||
background: var(--forge-fill);
|
||||
color: var(--dsw-alias-label-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.checkout:focus-visible {
|
||||
outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* The worktree the Session works in is gone. */
|
||||
.checkout[data-missing],
|
||||
.checkout[data-missing] .checkoutBranch {
|
||||
color: var(--dsw-alias-state-warn-primary);
|
||||
}
|
||||
|
||||
.checkoutName {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
border-radius: var(--dsw-radius-sm);
|
||||
}
|
||||
|
||||
.checkoutIcon {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.checkoutBranch {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: var(--dsw-alias-label-primary);
|
||||
font-family: var(--ds-font-family-code);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.checkoutNote {
|
||||
flex: none;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
/* Smaller than the card actions, with negative block margins, so the row keeps the height of its text;
|
||||
the descendant selector outranks `.iconButton`, which this button also carries. */
|
||||
.checkout .checkoutCopy {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin: -3px -4px -3px 0;
|
||||
}
|
||||
|
||||
.section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.sectionHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 4px 2px 0;
|
||||
}
|
||||
|
||||
.sectionTitle {
|
||||
margin: 0;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: var(--dsw-alias-label-secondary);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 20px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.iconButton {
|
||||
display: inline-flex;
|
||||
flex: none;
|
||||
@@ -182,23 +76,6 @@
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.empty {
|
||||
padding: 32px 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.emptyTitle {
|
||||
margin: 0;
|
||||
color: var(--dsw-alias-label-primary);
|
||||
}
|
||||
|
||||
.emptyHint {
|
||||
margin: 4px 0 0;
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -215,8 +92,8 @@
|
||||
background: var(--dsw-alias-bg-layer-1);
|
||||
}
|
||||
|
||||
/* Glyph, title link with the number line below it, then the expanded card's
|
||||
open, copy, and remove buttons and the expansion toggle. */
|
||||
/* Glyph, title link with the number line below it, then the actions menu
|
||||
and the expansion toggle. */
|
||||
.changeHead {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
@@ -268,8 +145,7 @@
|
||||
}
|
||||
|
||||
.changeTitle:focus-visible,
|
||||
.rowButton:focus-visible,
|
||||
.checkoutName:focus-visible {
|
||||
.rowButton:focus-visible {
|
||||
outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
|
||||
outline-offset: 1px;
|
||||
}
|
||||
@@ -579,3 +455,69 @@
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Change request count beside the Session panel section title. */
|
||||
.count {
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
font: var(--dsw-font-xxs-12);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* Environment rows: the kind or size trails the name, and the More button
|
||||
appears on row hover or focus; without hover it stays visible. */
|
||||
.envName {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.envName:focus-visible {
|
||||
outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
|
||||
outline-offset: 1px;
|
||||
}
|
||||
|
||||
.envNote {
|
||||
max-width: 120px;
|
||||
overflow: hidden;
|
||||
font: var(--dsw-font-xxs-12);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.envRow[data-missing] .envName,
|
||||
.envRow[data-missing] .envNote,
|
||||
.envRow[data-failed] .envName {
|
||||
color: var(--dsw-alias-state-warn-primary);
|
||||
}
|
||||
|
||||
.envRow .envMore {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.envRow .envMore {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.envRow:hover .envMore,
|
||||
.envRow:focus-within .envMore,
|
||||
.envMore[aria-expanded='true'] {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Attention mark over the Session panel toggle; the toggle positions it. */
|
||||
.attention {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.visuallyHidden {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
/** Body of the forge sidebar tab: where the Session works, its local changes, and the change requests it created or pushed. */
|
||||
|
||||
import { useEffect, useState, type ReactNode } from 'react'
|
||||
import {
|
||||
Button, IconBranchOutlineRegular, IconCopyOutlineRegular, IconFolderCloseRegular, IconWarningTriangleOutlineRegular, StateDot, Tooltip,
|
||||
} from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { RemoteHostFacts } from '@deepseek-ai/dsh-api-remotes/client'
|
||||
import type { MergeRequest } from '@deepseek-ai/dsh-experimental-forge/types'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-conversation/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
|
||||
import type { ForgePanelChangeRequest, ForgePanelState } from '../types.ts'
|
||||
import { changesAddress, type ChangesSource } from './changes-address.ts'
|
||||
import { ChangeRequestCard, type ChangeRequestActions } from './ChangeRequestCard.tsx'
|
||||
import { checkoutLabel } from './checkout.ts'
|
||||
import { LocalChangesCard } from './LocalChangesCard.tsx'
|
||||
import type { NS } from './locales.ts'
|
||||
import { RefreshGlyph } from './RefreshGlyph.tsx'
|
||||
import type { PanelSnapshot } from './source.ts'
|
||||
import { defaultExpanded, openChangeRequestOf } from './status.ts'
|
||||
import css from './ForgeTab.module.css'
|
||||
|
||||
/** Business face of the tab body. */
|
||||
export interface ForgeTabInjected {
|
||||
/** Panel snapshot of the Session and the Host facts; the renderer binds them as `usePanel` and `useHost`. */
|
||||
readonly hooks: {
|
||||
readonly panel: HostObservable<PanelSnapshot>
|
||||
readonly host: HostObservable<RemoteHostFacts>
|
||||
readonly locale: HostObservable<string>
|
||||
}
|
||||
/** Open the stream again after it ended. */
|
||||
readonly reconnect: () => void
|
||||
/**
|
||||
* Reinspect the checkout, probe sign-in, and poll the change requests;
|
||||
* settles once the Host has inspected and probed, after reporting a failure.
|
||||
*/
|
||||
readonly refresh: () => Promise<void>
|
||||
/** Remove a change request from the Session, offering to undo it. */
|
||||
readonly remove: (entry: ForgePanelChangeRequest) => void
|
||||
/** Mark a draft ready for review; settles once the outcome is reported. */
|
||||
readonly markReady: (entry: ForgePanelChangeRequest) => Promise<void>
|
||||
/** Merge a change request as `request` describes; settles once the outcome is reported. */
|
||||
readonly merge: (entry: ForgePanelChangeRequest, request: MergeRequest) => Promise<void>
|
||||
/** Read the complete checks of an opened change request. */
|
||||
readonly readChecks: NonNullable<ChangeRequestActions['readChecks']>
|
||||
/** Check the removed worktree of the Session out again, reporting the outcome. */
|
||||
readonly restore: () => void
|
||||
/** Open a URL outside the app. */
|
||||
readonly openLink: (url: string) => void
|
||||
/** Copy text to the clipboard and report the outcome. */
|
||||
readonly copyText: (text: string) => void
|
||||
/** Copy a path to the clipboard and report the outcome. */
|
||||
readonly copyPath: (path: string) => void
|
||||
/** Record whether the tab is visible, for the header entry's pressed state. */
|
||||
readonly reportVisible: (visible: boolean) => void
|
||||
/** Ask the Session's Agent to create a change request for its changes, reporting the outcome. */
|
||||
readonly createChangeRequest: () => void
|
||||
}
|
||||
|
||||
/** Full props of the tab body. */
|
||||
export type ForgeTabProps =
|
||||
Pick<PropsRuntime<'sidebar.right.pane.tab'>, 'useTabInfo' | 'sessionId'>
|
||||
& InjectFace<ForgeTabInjected>
|
||||
& PropsLocale<typeof NS>
|
||||
|
||||
type Translate = ForgeTabProps['t']
|
||||
|
||||
function Checkout({ state, home, restore, copyPath, t }: {
|
||||
readonly state: ForgePanelState
|
||||
readonly home: string | undefined
|
||||
readonly restore: () => void
|
||||
readonly copyPath: (path: string) => void
|
||||
readonly t: Translate
|
||||
}): ReactNode {
|
||||
const checkout = state.checkout
|
||||
const label = checkoutLabel(state, home, t)
|
||||
if (label === undefined) {
|
||||
if (checkout.state === 'none') return <div className={css.checkout}>{t('checkout.none')}</div>
|
||||
if (checkout.state !== 'failed') return null
|
||||
return (
|
||||
<Tooltip label={checkout.message} side="bottom">
|
||||
<div className={css.checkout} tabIndex={0}>{t('checkout.failed')}</div>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
const copyLabel = t(label.worktree ? 'checkout.copyWorktreePath' : 'checkout.copyProjectPath')
|
||||
return (
|
||||
<div className={css.checkout} data-forge-checkout="" data-missing={label.missing ? '' : undefined}>
|
||||
<Tooltip label={label.tooltip} side="bottom">
|
||||
<span className={css.checkoutName} tabIndex={0}>
|
||||
{label.missing
|
||||
? <IconWarningTriangleOutlineRegular size={14} className={css.checkoutIcon} />
|
||||
: label.worktree
|
||||
? <IconBranchOutlineRegular size={14} className={css.checkoutIcon} />
|
||||
: <IconFolderCloseRegular size={14} className={css.checkoutIcon} />}
|
||||
{label.detached && <span>{t('checkout.detached')}</span>}
|
||||
{label.detached && label.name !== null && <span aria-hidden="true">·</span>}
|
||||
{label.name !== null && <span className={css.checkoutBranch}>{label.name}</span>}
|
||||
</span>
|
||||
</Tooltip>
|
||||
<span className={css.checkoutNote}>{label.kind}</span>
|
||||
<Tooltip label={copyLabel} side="bottom">
|
||||
<button type="button" className={`${css.iconButton} ${css.checkoutCopy}`} aria-label={copyLabel} onClick={() => { copyPath(label.path) }}>
|
||||
<IconCopyOutlineRegular size={14} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
{label.missing && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
disabled={state.worktree.restoration !== null}
|
||||
icon={state.worktree.restoration === null ? undefined : <StateDot state="ongoing" size={14} />}
|
||||
onClick={restore}
|
||||
>
|
||||
{t('checkout.restore')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function SignIn({ state, copyText, t }: {
|
||||
readonly state: ForgePanelState
|
||||
readonly copyText: (text: string) => void
|
||||
readonly t: Translate
|
||||
}): ReactNode {
|
||||
const { repository, readiness } = state
|
||||
if (repository === null || readiness === null || readiness.state === 'ready') return null
|
||||
const host = repository.host
|
||||
if (readiness.state === 'unavailable') {
|
||||
return <div className={css.banner} role="status">{t('signin.unavailable', { host, message: readiness.message ?? '' })}</div>
|
||||
}
|
||||
const command = repository.forge === 'github' ? `gh auth login --hostname ${host}` : undefined
|
||||
return (
|
||||
<div className={css.banner} role="status">
|
||||
<span>{t('signin.title', { host })}</span>
|
||||
{command === undefined
|
||||
? readiness.message !== null && <span className={css.bannerDetail}>{readiness.message}</span>
|
||||
: (
|
||||
<>
|
||||
<code className={css.bannerCommand}>{command}</code>
|
||||
<Button size="sm" variant="outline" className={css.bannerAction} onClick={() => { copyText(command) }}>
|
||||
{t('signin.copy')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the forge tab of one Session. The local changes card shows whenever
|
||||
* the `branch` scope changes files, independently of bound change requests.
|
||||
* The only open change request starts expanded; once the
|
||||
* user expands or collapses a card, the panel keeps that choice across later updates.
|
||||
* @param props - tab information, panel snapshot and Host facts hooks, actions, and copy.
|
||||
* @returns the tab body.
|
||||
*/
|
||||
export function ForgeTab({
|
||||
useTabInfo, sessionId, usePanel, useHost, useLocale, reconnect, refresh, remove, markReady, merge, readChecks, restore,
|
||||
openLink, copyText, copyPath,
|
||||
reportVisible, createChangeRequest, t,
|
||||
}: ForgeTabProps): ReactNode {
|
||||
const snapshot = usePanel(current => current)
|
||||
const home = useHost(facts => facts.home)
|
||||
const locale = useLocale(value => value)
|
||||
const { tab } = useTabInfo()
|
||||
const visible = tab.visible
|
||||
const [chosen, setChosen] = useState<ReadonlySet<string> | null>(null)
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
useEffect(() => {
|
||||
reportVisible(visible)
|
||||
}, [reportVisible, visible])
|
||||
useEffect(() => () => { reportVisible(false) }, [reportVisible])
|
||||
const state = snapshot.state
|
||||
const disconnected = snapshot.disconnected && (
|
||||
<div className={css.disconnected} role="status">
|
||||
<span>{t('stream.failed')}</span>
|
||||
<Button size="sm" variant="outline" onClick={reconnect}>{t('retry')}</Button>
|
||||
</div>
|
||||
)
|
||||
if (state === null) return <div className={css.centered}>{disconnected || <StateDot state="ongoing" />}</div>
|
||||
const viewChanges = (source: ChangesSource, path?: string): void => {
|
||||
tab.actions.openResource(changesAddress({ sessionId, source }), path === undefined ? undefined : { params: { path } })
|
||||
}
|
||||
const startRefresh = (): void => {
|
||||
if (refreshing) return
|
||||
setRefreshing(true)
|
||||
void refresh().finally(() => { setRefreshing(false) })
|
||||
}
|
||||
const actions: ChangeRequestActions = {
|
||||
openLink, copyLink: copyText, retry: startRefresh, remove, markReady, merge, readChecks,
|
||||
viewChanges: (entry) => { viewChanges({ kind: 'change', url: entry.url }) },
|
||||
}
|
||||
const local = state.local !== null && state.local.files.length > 0 ? state.local : null
|
||||
const expanded = chosen ?? defaultExpanded(state.changeRequests)
|
||||
const toggle = (url: string): void => {
|
||||
const next = new Set(expanded)
|
||||
if (next.has(url)) next.delete(url)
|
||||
else next.add(url)
|
||||
setChosen(next)
|
||||
}
|
||||
const now = Date.now()
|
||||
const count = state.changeRequests.length
|
||||
return (
|
||||
<div className={css.root} data-forge-panel="">
|
||||
{disconnected}
|
||||
<Checkout state={state} home={home} restore={restore} copyPath={copyPath} t={t} />
|
||||
{local !== null && (
|
||||
<LocalChangesCard
|
||||
local={local}
|
||||
creatable={state.repository !== null && openChangeRequestOf(state) === undefined}
|
||||
view={(path) => { viewChanges({ kind: 'local' }, path) }}
|
||||
create={createChangeRequest}
|
||||
t={t}
|
||||
/>
|
||||
)}
|
||||
<section className={css.section}>
|
||||
<div className={css.sectionHeader}>
|
||||
<h3 className={css.sectionTitle}>{t('changes.title', { count })}</h3>
|
||||
<Tooltip label={t('refresh')} side="top">
|
||||
<button type="button" className={css.iconButton} aria-label={t('refresh')} aria-disabled={refreshing} onClick={startRefresh}>
|
||||
<RefreshGlyph busy={refreshing} size={14} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<SignIn state={state} copyText={copyText} t={t} />
|
||||
{count === 0
|
||||
? (
|
||||
<div className={css.empty}>
|
||||
<p className={css.emptyTitle}>{t('changes.empty')}</p>
|
||||
<p className={css.emptyHint}>{t('changes.emptyHint')}</p>
|
||||
</div>
|
||||
)
|
||||
: (
|
||||
<ul className={css.list}>
|
||||
{state.changeRequests.map(entry => (
|
||||
<ChangeRequestCard
|
||||
key={entry.url}
|
||||
entry={entry}
|
||||
expanded={expanded.has(entry.url)}
|
||||
onToggle={() => { toggle(entry.url) }}
|
||||
now={now}
|
||||
actions={actions}
|
||||
locale={locale}
|
||||
t={t}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/** Chip title of the forge tab: the change request glyph and the localized tab name. */
|
||||
|
||||
import type { ReactNode } from 'react'
|
||||
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import { ChangeRequestGlyph } from './glyphs.tsx'
|
||||
import type { NS } from './locales.ts'
|
||||
import css from './ForgeTab.module.css'
|
||||
|
||||
/**
|
||||
* Render the tab chip title in the current UI language.
|
||||
* @param props - forge panel copy.
|
||||
* @returns the glyph followed by the tab name.
|
||||
*/
|
||||
export function ForgeTabTitle({ t }: PropsLocale<typeof NS>): ReactNode {
|
||||
return (
|
||||
<>
|
||||
<span className={css.titleIcon}><ChangeRequestGlyph tone="open" tinted={false} size={16} /></span>
|
||||
<span className={css.titleText}>{t('tab.title')}</span>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/* Icon-only header entry: the shared compact Button owns the radius, height,
|
||||
and interaction fills, as for the header's other actions; the status dot
|
||||
sits at the glyph's top-right corner. */
|
||||
.trigger {
|
||||
position: relative;
|
||||
flex: none;
|
||||
width: 28px;
|
||||
padding: 0;
|
||||
color: var(--dsw-alias-label-secondary);
|
||||
}
|
||||
|
||||
/* The forge tab is visible; the pressed fill outranks the Button's hover fill. */
|
||||
.trigger[aria-pressed='true'] {
|
||||
color: var(--dsw-alias-label-primary);
|
||||
background: var(--dsw-alias-interactive-bg-active);
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.trigger[aria-pressed='true']:hover:not(:disabled) {
|
||||
color: var(--dsw-alias-label-primary);
|
||||
background: var(--dsw-alias-interactive-bg-active);
|
||||
}
|
||||
}
|
||||
|
||||
.dot {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
right: 6px;
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/** Session header entry that shows or hides the forge tab and marks change requests that need attention. */
|
||||
|
||||
import type { ReactNode } from 'react'
|
||||
import { Button, StateDot, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { HostObservable, InjectFace, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-conversation/client'
|
||||
import { ChangeRequestGlyph } from './glyphs.tsx'
|
||||
import type { NS } from './locales.ts'
|
||||
import type { PanelSnapshot } from './source.ts'
|
||||
import { needsAttention } from './status.ts'
|
||||
import css from './HeaderButton.module.css'
|
||||
|
||||
/** Business face of the header entry. */
|
||||
export interface HeaderButtonInjected {
|
||||
/** Panel snapshot and tab visibility of the Session; the renderer binds them as `usePanel` and `useVisible`. */
|
||||
readonly hooks: { readonly panel: HostObservable<PanelSnapshot>; readonly visible: HostObservable<boolean> }
|
||||
/**
|
||||
* Hide the forge tab when it is visible, otherwise open or reveal it.
|
||||
* @param visible - whether the tab is visible now.
|
||||
*/
|
||||
readonly toggle: (visible: boolean) => void
|
||||
}
|
||||
|
||||
/** Full props of the header entry. */
|
||||
export type HeaderButtonProps = InjectFace<HeaderButtonInjected> & PropsLocale<typeof NS>
|
||||
|
||||
/**
|
||||
* Show the entry once the Session has bound change requests or its directory
|
||||
* is known to be inside a Git checkout: after an inspection found one or
|
||||
* failed, or while a later inspection runs for a directory whose repository
|
||||
* is already known.
|
||||
* @param snapshot - panel snapshot.
|
||||
* @returns whether the entry shows.
|
||||
*/
|
||||
function shown(snapshot: PanelSnapshot): boolean {
|
||||
const state = snapshot.state
|
||||
if (state === null) return false
|
||||
return state.changeRequests.length > 0 || state.checkout.state === 'ready' || state.checkout.state === 'failed'
|
||||
|| (state.checkout.state === 'pending' && state.repository !== null)
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the header entry.
|
||||
* @param props - panel snapshot and visibility hooks, the toggle, and copy.
|
||||
* @returns the entry, or nothing outside a Git checkout without bound change requests.
|
||||
*/
|
||||
export function HeaderButton({ usePanel, useVisible, toggle, t }: HeaderButtonProps): ReactNode {
|
||||
const visible = usePanel(shown)
|
||||
const attention = usePanel(snapshot => snapshot.state?.changeRequests.some(needsAttention) === true)
|
||||
const pressed = useVisible(current => current)
|
||||
if (!visible) return null
|
||||
const label = t(attention ? 'header.attention' : 'header.label')
|
||||
return (
|
||||
<Tooltip label={label} side="bottom">
|
||||
<Button
|
||||
size="sm"
|
||||
className={css.trigger}
|
||||
aria-label={label}
|
||||
aria-pressed={pressed}
|
||||
data-forge-header=""
|
||||
onClick={() => { toggle(pressed) }}
|
||||
>
|
||||
<ChangeRequestGlyph tone="open" tinted={false} size={16} />
|
||||
{attention && <StateDot state="error" size={6} className={css.dot} />}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/**
|
||||
* The panel card of the checkout's `branch` scope changes, independent of
|
||||
* change request bindings: file counts and paths open the local changes view,
|
||||
* and an optional action asks the Agent for a change request.
|
||||
*/
|
||||
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import { Button, IconChevronDownOutlineRegular, IconListPenOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { ForgeLocalChanges } from '../types.ts'
|
||||
import { Counts } from './DiffFile.tsx'
|
||||
import { FileLabel } from './FileLabel.tsx'
|
||||
import type { NS } from './locales.ts'
|
||||
import css from './ChangesTab.module.css'
|
||||
|
||||
/** Props of the local changes card. */
|
||||
export interface LocalChangesCardProps {
|
||||
/** Files the `branch` scope changes and the ref it compares with. */
|
||||
readonly local: ForgeLocalChanges
|
||||
/** Whether the card offers to create a change request. */
|
||||
readonly creatable: boolean
|
||||
/** Open the changes view, scrolled to `path` when given. */
|
||||
readonly view: (path?: string) => void
|
||||
/** Ask the Agent to create a change request for the changes. */
|
||||
readonly create: () => void
|
||||
/** Forge panel copy. */
|
||||
readonly t: PropsLocale<typeof NS>['t']
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the local changes card; the file list starts collapsed.
|
||||
* @param props - the changes, the view and create actions, and copy.
|
||||
* @returns the card.
|
||||
*/
|
||||
export function LocalChangesCard({ local, creatable, view, create, t }: LocalChangesCardProps): ReactNode {
|
||||
const [open, setOpen] = useState(false)
|
||||
let additions = 0
|
||||
let deletions = 0
|
||||
for (const file of local.files) {
|
||||
additions += file.additions
|
||||
deletions += file.deletions
|
||||
}
|
||||
const count = local.files.length
|
||||
return (
|
||||
<section className={css.local} data-forge-local="">
|
||||
<div className={css.localHead}>
|
||||
<button type="button" className={css.localToggle} aria-expanded={open} onClick={() => { setOpen(value => !value) }}>
|
||||
{t('changes.local.title')}
|
||||
<IconChevronDownOutlineRegular size={12} />
|
||||
</button>
|
||||
<span className={css.localRefs}>{t('changes.local.refs', { head: 'HEAD', base: local.base })}</span>
|
||||
</div>
|
||||
<div className={css.localRow}>
|
||||
<button
|
||||
type="button"
|
||||
className={css.localView}
|
||||
aria-label={t('changes.local.viewAria', { count, added: additions, deleted: deletions })}
|
||||
onClick={() => { view() }}
|
||||
>
|
||||
<IconListPenOutlineRegular size={15} />
|
||||
<Counts file={{ additions, deletions, binary: false }} t={t} />
|
||||
<span aria-hidden="true">·</span>
|
||||
<span>{t('changes.local.files', { count })}</span>
|
||||
</button>
|
||||
{creatable && (
|
||||
<Button size="sm" variant="outline" className={css.localCreate} onClick={create}>{t('changes.local.create')}</Button>
|
||||
)}
|
||||
</div>
|
||||
{open && (
|
||||
<ul className={css.localFiles}>
|
||||
{local.files.map(file => (
|
||||
<li key={file.path}>
|
||||
<button type="button" className={css.localFile} onClick={() => { view(file.path) }}>
|
||||
<FileLabel path={file.path} className={css.menuPath} />
|
||||
<Counts file={file} t={t} />
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/** Refresh button beside a Session panel section title. */
|
||||
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import { Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import { RefreshGlyph } from './RefreshGlyph.tsx'
|
||||
import css from './Forge.module.css'
|
||||
|
||||
/** Props of the refresh button. */
|
||||
export interface RefreshButtonProps {
|
||||
/** Reinspect the checkout, probe sign-in, and poll the change requests; settles once the Host has inspected and probed. */
|
||||
readonly refresh: () => Promise<void>
|
||||
/** Accessible name and tooltip. */
|
||||
readonly label: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a refresh button whose glyph turns until the refresh settles; presses
|
||||
* while a refresh runs are ignored.
|
||||
* @param props - the refresh action and its label.
|
||||
* @returns the button.
|
||||
*/
|
||||
export function RefreshButton({ refresh, label }: RefreshButtonProps): ReactNode {
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
const start = (): void => {
|
||||
if (refreshing) return
|
||||
setRefreshing(true)
|
||||
void refresh().finally(() => { setRefreshing(false) })
|
||||
}
|
||||
return (
|
||||
<Tooltip label={label} side="top">
|
||||
<button type="button" className={css.iconButton} aria-label={label} aria-disabled={refreshing} onClick={start}>
|
||||
<RefreshGlyph busy={refreshing} size={14} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import clsx from 'clsx'
|
||||
import { IconCheckCircleFillRegular, IconCloseCircleFillRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { CheckState } from '@deepseek-ai/dsh-experimental-forge/types'
|
||||
import type { ChangeRequestTone } from './status.ts'
|
||||
import css from './ForgeTab.module.css'
|
||||
import css from './Forge.module.css'
|
||||
|
||||
const BRANCH_ENDS = (
|
||||
<>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/**
|
||||
* Browser entry of the forge panel: the sidebar tab, the changes view, the
|
||||
* header button, the worktree option and creation card, and their Remote.
|
||||
* Browser entry of the forge panel: the Session panel's change requests
|
||||
* section, Environment rows, and attention indicator, the changes view, the
|
||||
* worktree option and creation card, and their Remote.
|
||||
*/
|
||||
|
||||
import type { Context } from '@deepseek-ai/cordis'
|
||||
@@ -14,9 +15,14 @@ export type { ChangesParams, ChangesSource, ChangesTarget } from './changes-addr
|
||||
export type { ChangesTabInjected, ChangesTabProps } from './ChangesTab.tsx'
|
||||
export type { ChangesTabTitleProps } from './ChangesTabTitle.tsx'
|
||||
export type { DiffFileAction, DiffFileProps, DiffFileText } from './DiffFile.tsx'
|
||||
export type { LocalChangesCardProps } from './LocalChangesCard.tsx'
|
||||
export type { ForgeTabInjected, ForgeTabProps } from './ForgeTab.tsx'
|
||||
export type { HeaderButtonInjected, HeaderButtonProps } from './HeaderButton.tsx'
|
||||
export type { AttentionIndicatorInjected, AttentionIndicatorProps } from './AttentionIndicator.tsx'
|
||||
export type { RefreshButtonProps } from './RefreshButton.tsx'
|
||||
export type {
|
||||
ChangeRequestsActionsInjected, ChangeRequestsActionsProps, ChangeRequestsSectionInjected, ChangeRequestsSectionProps,
|
||||
} from './ChangeRequestsSection.tsx'
|
||||
export type {
|
||||
CheckoutRowInjected, CheckoutRowProps, EnvironmentActionsInjected, EnvironmentActionsProps, LocalChangesRowInjected, LocalChangesRowProps,
|
||||
} from './EnvironmentRows.tsx'
|
||||
export type { WorktreeProgressInjected, WorktreeProgressProps } from './WorktreeProgress.tsx'
|
||||
export type { WorktreeToggleInjected, WorktreeToggleProps } from './WorktreeToggle.tsx'
|
||||
export type { ActionNotice, NoticeOptions, PanelSnapshot } from './source.ts'
|
||||
|
||||
@@ -20,8 +20,6 @@ export const zh = {
|
||||
'diff.fileTree': '文件树',
|
||||
'diff.showFileTreeLeft': '在左侧显示文件树',
|
||||
'diff.moveFileTreeRight': '将文件树移到右侧',
|
||||
'guide.title': '代码审查和变更',
|
||||
'guide.description': '查看代码变更与本会话的变更请求',
|
||||
'diff.hideFileTree': '隐藏文件树',
|
||||
'review.range': '评论 {range}',
|
||||
'review.comment': '留下评论…',
|
||||
@@ -51,25 +49,21 @@ export const zh = {
|
||||
'review.recheck': '在 GitHub 查看',
|
||||
'review.confirmRetry': '已核对,允许重新提交',
|
||||
'tab.title': '变更请求',
|
||||
'header.label': '本会话的变更请求',
|
||||
'header.attention': '本会话的变更请求需要处理',
|
||||
'checkout.worktree': '工作树',
|
||||
'checkout.worktreeFrom': '工作树 · 基于 {base}',
|
||||
'checkout.project': '项目目录',
|
||||
'checkout.detached': '未在分支上',
|
||||
'checkout.restore': '恢复',
|
||||
'checkout.copyWorktreePath': '复制工作树路径',
|
||||
'checkout.copyProjectPath': '复制项目目录路径',
|
||||
'checkout.worktreeActions': '工作树目录操作',
|
||||
'checkout.projectActions': '项目目录操作',
|
||||
'checkout.none': '当前目录不是 Git 仓库',
|
||||
'checkout.failed': '无法读取 Git 信息',
|
||||
'changes.title': '本会话的变更请求 · {count}',
|
||||
'changes.empty': '本会话还没有变更请求',
|
||||
'changes.emptyHint': '本会话关联的变更请求(创建、查看、编辑或检出的,以及所在分支或推送分支上的)会显示在这里',
|
||||
'changes.local.title': '本地变更',
|
||||
'changes.local.refs': '{head} → {base}',
|
||||
'changes.local.files': '{count} 个文件',
|
||||
'changes.local.viewAria': '查看本会话的变更:{count} 个文件,新增 {added} 行,删除 {deleted} 行',
|
||||
'changes.local.create': '创建变更请求',
|
||||
'changes.local.actions': '本地变更操作',
|
||||
'changes.local.summary': '本地变更 · {count} 个文件',
|
||||
'changes.local.prompt': '为本会话的变更创建变更请求',
|
||||
'signin.title': '登录 {host} 后才能显示变更请求状态',
|
||||
'signin.copy': '复制登录命令',
|
||||
@@ -116,9 +110,10 @@ export const zh = {
|
||||
'change.unserved': '暂不支持读取该平台的变更请求状态',
|
||||
'change.view': '在浏览器中打开',
|
||||
'change.copy': '复制变更请求链接',
|
||||
'change.viewChanges': '查看变更',
|
||||
'change.actions': '{name} 的操作',
|
||||
'change.viewChangesAria': '查看 {name} 的变更:新增 {added} 行,删除 {deleted} 行',
|
||||
'change.remove': '从本会话移除',
|
||||
'change.removeAria': '从本会话移除 {name}',
|
||||
'change.row.checks': '检查',
|
||||
'change.row.review': '评审',
|
||||
'change.row.merge': '合并',
|
||||
@@ -292,8 +287,6 @@ export const en: Record<ForgePanelKey, string> = {
|
||||
'diff.fileTree': 'File tree',
|
||||
'diff.showFileTreeLeft': 'Show file tree on the left',
|
||||
'diff.moveFileTreeRight': 'Move file tree to the right',
|
||||
'guide.title': 'Code review and changes',
|
||||
'guide.description': 'Review code changes and this session’s change requests',
|
||||
'diff.hideFileTree': 'Hide file tree',
|
||||
'review.range': 'Comment on {range}',
|
||||
'review.comment': 'Leave a comment…',
|
||||
@@ -323,25 +316,21 @@ export const en: Record<ForgePanelKey, string> = {
|
||||
'review.recheck': 'View on GitHub',
|
||||
'review.confirmRetry': 'Checked; allow resubmission',
|
||||
'tab.title': 'Change requests',
|
||||
'header.label': 'Change requests of this Session',
|
||||
'header.attention': 'Change requests of this Session need attention',
|
||||
'checkout.worktree': 'Worktree',
|
||||
'checkout.worktreeFrom': 'Worktree · from {base}',
|
||||
'checkout.project': 'Project directory',
|
||||
'checkout.detached': 'Not on a branch',
|
||||
'checkout.restore': 'Restore',
|
||||
'checkout.copyWorktreePath': 'Copy worktree path',
|
||||
'checkout.copyProjectPath': 'Copy project directory path',
|
||||
'checkout.worktreeActions': 'Worktree directory actions',
|
||||
'checkout.projectActions': 'Project directory actions',
|
||||
'checkout.none': 'This directory is not a Git repository',
|
||||
'checkout.failed': 'Git information could not be read',
|
||||
'changes.title': 'Change requests of this Session · {count}',
|
||||
'changes.empty': 'This Session has no change requests yet',
|
||||
'changes.emptyHint': 'Change requests linked to this Session (created, viewed, edited, or checked out, or open on its current or pushed branches) appear here',
|
||||
'changes.local.title': 'Local changes',
|
||||
'changes.local.refs': '{head} → {base}',
|
||||
'changes.local.files': '{count} files',
|
||||
'changes.local.viewAria': 'View the changes of this Session: {count} files, {added} lines added, {deleted} lines deleted',
|
||||
'changes.local.create': 'Create change request',
|
||||
'changes.local.actions': 'Local changes actions',
|
||||
'changes.local.summary': 'Local changes · {count} files',
|
||||
'changes.local.prompt': 'Create a change request for the changes of this Session',
|
||||
'signin.title': 'Sign in to {host} to show change request status',
|
||||
'signin.copy': 'Copy sign-in command',
|
||||
@@ -388,9 +377,10 @@ export const en: Record<ForgePanelKey, string> = {
|
||||
'change.unserved': 'Change request status is not supported for this code host yet',
|
||||
'change.view': 'Open in browser',
|
||||
'change.copy': 'Copy change request link',
|
||||
'change.viewChanges': 'View changes',
|
||||
'change.actions': 'Actions for {name}',
|
||||
'change.viewChangesAria': 'View the changes of {name}: {added} lines added, {deleted} lines deleted',
|
||||
'change.remove': 'Remove from this Session',
|
||||
'change.removeAria': 'Remove {name} from this Session',
|
||||
'change.row.checks': 'Checks',
|
||||
'change.row.review': 'Review',
|
||||
'change.row.merge': 'Merge',
|
||||
@@ -568,8 +558,6 @@ export const ja: Record<ForgePanelKey, string> = {
|
||||
'diff.fileTree': 'ファイルツリー',
|
||||
'diff.showFileTreeLeft': 'ファイルツリーを左側に表示',
|
||||
'diff.moveFileTreeRight': 'ファイルツリーを右側に移動',
|
||||
'guide.title': 'コードレビューと変更',
|
||||
'guide.description': 'コードの変更とこのセッションの変更リクエストを確認',
|
||||
'diff.hideFileTree': 'ファイルツリーを非表示',
|
||||
'review.range': '{range} にコメント',
|
||||
'review.comment': 'コメントを入力…',
|
||||
@@ -602,25 +590,21 @@ export const ja: Record<ForgePanelKey, string> = {
|
||||
'list.stateChecks': '{state} · {checks}',
|
||||
'list.more': '他 {count} 件の変更リクエスト',
|
||||
'tab.title': '変更リクエスト',
|
||||
'header.label': 'このセッションの変更リクエスト',
|
||||
'header.attention': 'このセッションの変更リクエストに対応が必要です',
|
||||
'checkout.worktree': 'ワークツリー',
|
||||
'checkout.worktreeFrom': 'ワークツリー · 基点 {base}',
|
||||
'checkout.project': 'プロジェクトディレクトリ',
|
||||
'checkout.detached': 'ブランチ上にありません',
|
||||
'checkout.restore': '復元',
|
||||
'checkout.copyWorktreePath': 'ワークツリーのパスをコピー',
|
||||
'checkout.copyProjectPath': 'プロジェクトのパスをコピー',
|
||||
'checkout.worktreeActions': 'ワークツリーディレクトリの操作',
|
||||
'checkout.projectActions': 'プロジェクトディレクトリの操作',
|
||||
'checkout.none': 'このディレクトリは Git リポジトリではありません',
|
||||
'checkout.failed': 'Git 情報を読み取れませんでした',
|
||||
'changes.title': 'このセッションの変更リクエスト · {count}',
|
||||
'changes.empty': 'このセッションにはまだ変更リクエストがありません',
|
||||
'changes.emptyHint': 'このセッションで作成、表示、編集、チェックアウトした変更リクエストや、現在のブランチまたはプッシュしたブランチで開いている変更リクエストがここに表示されます',
|
||||
'changes.local.title': 'ローカルの変更',
|
||||
'changes.local.refs': '{head} → {base}',
|
||||
'changes.local.files': '{count} ファイル',
|
||||
'changes.local.viewAria': 'このセッションの変更を表示:{count} ファイル、{added} 行追加、{deleted} 行削除',
|
||||
'changes.local.create': '変更リクエストを作成',
|
||||
'changes.local.actions': 'ローカル変更の操作',
|
||||
'changes.local.summary': 'ローカル変更 · {count} 個のファイル',
|
||||
'changes.local.prompt': 'このセッションの変更について変更リクエストを作成してください',
|
||||
'signin.title': '変更リクエストの状態を表示するには {host} にログインしてください',
|
||||
'signin.copy': 'ログインコマンドをコピー',
|
||||
@@ -664,9 +648,10 @@ export const ja: Record<ForgePanelKey, string> = {
|
||||
'change.unserved': 'このコードホストの変更リクエストの状態はまだサポートされていません',
|
||||
'change.view': 'ブラウザーで開く',
|
||||
'change.copy': '変更リクエストのリンクをコピー',
|
||||
'change.viewChanges': '変更を表示',
|
||||
'change.actions': '{name} の操作',
|
||||
'change.viewChangesAria': '{name} の変更を表示:{added} 行追加、{deleted} 行削除',
|
||||
'change.remove': 'このセッションから削除',
|
||||
'change.removeAria': 'このセッションから {name} を削除',
|
||||
'change.row.checks': 'チェック',
|
||||
'change.row.review': 'レビュー',
|
||||
'change.row.merge': 'マージ',
|
||||
@@ -837,8 +822,6 @@ export const es: Record<ForgePanelKey, string> = {
|
||||
'diff.fileTree': 'Árbol de archivos',
|
||||
'diff.showFileTreeLeft': 'Mostrar árbol de archivos a la izquierda',
|
||||
'diff.moveFileTreeRight': 'Mover árbol de archivos a la derecha',
|
||||
'guide.title': 'Revisión de código y cambios',
|
||||
'guide.description': 'Revisar los cambios de código y las solicitudes de cambio de esta sesión',
|
||||
'diff.hideFileTree': 'Ocultar árbol de archivos',
|
||||
'review.range': 'Comentar {range}',
|
||||
'review.comment': 'Escribe un comentario…',
|
||||
@@ -871,25 +854,21 @@ export const es: Record<ForgePanelKey, string> = {
|
||||
'list.stateChecks': '{state} · {checks}',
|
||||
'list.more': '{count} solicitudes de cambio más',
|
||||
'tab.title': 'Solicitudes de cambio',
|
||||
'header.label': 'Solicitudes de cambio de esta sesión',
|
||||
'header.attention': 'Las solicitudes de cambio de esta sesión requieren atención',
|
||||
'checkout.worktree': 'Árbol de trabajo',
|
||||
'checkout.worktreeFrom': 'Árbol de trabajo · desde {base}',
|
||||
'checkout.project': 'Directorio del proyecto',
|
||||
'checkout.detached': 'Sin rama activa',
|
||||
'checkout.restore': 'Restaurar',
|
||||
'checkout.copyWorktreePath': 'Copiar ruta del árbol de trabajo',
|
||||
'checkout.copyProjectPath': 'Copiar ruta del proyecto',
|
||||
'checkout.worktreeActions': 'Acciones del directorio del worktree',
|
||||
'checkout.projectActions': 'Acciones del directorio del proyecto',
|
||||
'checkout.none': 'Este directorio no es un repositorio Git',
|
||||
'checkout.failed': 'No se pudo leer la información de Git',
|
||||
'changes.title': 'Solicitudes de cambio de esta sesión · {count}',
|
||||
'changes.empty': 'Esta sesión aún no tiene solicitudes de cambio',
|
||||
'changes.emptyHint': 'Aquí aparecen las solicitudes vinculadas a esta sesión: creadas, consultadas, editadas o extraídas, o abiertas en sus ramas actuales o enviadas',
|
||||
'changes.local.title': 'Cambios locales',
|
||||
'changes.local.refs': '{head} → {base}',
|
||||
'changes.local.files': '{count} archivos',
|
||||
'changes.local.viewAria': 'Ver cambios de esta sesión: {count} archivos, {added} líneas añadidas y {deleted} eliminadas',
|
||||
'changes.local.create': 'Crear solicitud de cambio',
|
||||
'changes.local.actions': 'Acciones de los cambios locales',
|
||||
'changes.local.summary': 'Cambios locales · {count} archivos',
|
||||
'changes.local.prompt': 'Crea una solicitud de cambio con los cambios de esta sesión',
|
||||
'signin.title': 'Inicia sesión en {host} para ver el estado de las solicitudes',
|
||||
'signin.copy': 'Copiar comando de inicio de sesión',
|
||||
@@ -933,9 +912,10 @@ export const es: Record<ForgePanelKey, string> = {
|
||||
'change.unserved': 'Este servicio de código aún no permite consultar el estado de las solicitudes',
|
||||
'change.view': 'Abrir en el navegador',
|
||||
'change.copy': 'Copiar enlace de la solicitud',
|
||||
'change.viewChanges': 'Ver cambios',
|
||||
'change.actions': 'Acciones de {name}',
|
||||
'change.viewChangesAria': 'Ver cambios de {name}: {added} líneas añadidas y {deleted} eliminadas',
|
||||
'change.remove': 'Quitar de esta sesión',
|
||||
'change.removeAria': 'Quitar {name} de esta sesión',
|
||||
'change.row.checks': 'Comprobaciones',
|
||||
'change.row.review': 'Revisión',
|
||||
'change.row.merge': 'Fusionar',
|
||||
@@ -1106,8 +1086,6 @@ export const fr: Record<ForgePanelKey, string> = {
|
||||
'diff.fileTree': 'Arborescence des fichiers',
|
||||
'diff.showFileTreeLeft': 'Afficher l’arborescence à gauche',
|
||||
'diff.moveFileTreeRight': 'Déplacer l’arborescence à droite',
|
||||
'guide.title': 'Revue de code et modifications',
|
||||
'guide.description': 'Examiner les modifications du code et les demandes de modification de cette session',
|
||||
'diff.hideFileTree': 'Masquer l’arborescence',
|
||||
'review.range': 'Commenter {range}',
|
||||
'review.comment': 'Laisser un commentaire…',
|
||||
@@ -1140,25 +1118,21 @@ export const fr: Record<ForgePanelKey, string> = {
|
||||
'list.stateChecks': '{state} · {checks}',
|
||||
'list.more': '{count} demandes de changement supplémentaires',
|
||||
'tab.title': 'Demandes de modification',
|
||||
'header.label': 'Demandes de modification de cette session',
|
||||
'header.attention': 'Les demandes de modification de cette session nécessitent une intervention',
|
||||
'checkout.worktree': 'Arbre de travail',
|
||||
'checkout.worktreeFrom': 'Arbre de travail · depuis {base}',
|
||||
'checkout.project': 'Dossier du projet',
|
||||
'checkout.detached': 'Aucune branche active',
|
||||
'checkout.restore': 'Restaurer',
|
||||
'checkout.copyWorktreePath': 'Copier le chemin de l’arbre de travail',
|
||||
'checkout.copyProjectPath': 'Copier le chemin du projet',
|
||||
'checkout.worktreeActions': 'Actions sur le dossier du worktree',
|
||||
'checkout.projectActions': 'Actions sur le dossier du projet',
|
||||
'checkout.none': 'Ce dossier n’est pas un dépôt Git',
|
||||
'checkout.failed': 'Impossible de lire les informations Git',
|
||||
'changes.title': 'Demandes de modification de cette session · {count}',
|
||||
'changes.empty': 'Cette session n’a pas encore de demande de modification',
|
||||
'changes.emptyHint': 'Les demandes liées à cette session apparaissent ici : créées, consultées, modifiées ou extraites, ou ouvertes sur ses branches actuelles ou envoyées',
|
||||
'changes.local.title': 'Modifications locales',
|
||||
'changes.local.refs': '{head} → {base}',
|
||||
'changes.local.files': '{count} fichiers',
|
||||
'changes.local.viewAria': 'Voir les modifications de cette session : {count} fichiers, {added} lignes ajoutées et {deleted} supprimées',
|
||||
'changes.local.create': 'Créer une demande de modification',
|
||||
'changes.local.actions': 'Actions sur les modifications locales',
|
||||
'changes.local.summary': 'Modifications locales · {count} fichiers',
|
||||
'changes.local.prompt': 'Créez une demande de modification pour les changements de cette session',
|
||||
'signin.title': 'Connectez-vous à {host} pour voir l’état des demandes',
|
||||
'signin.copy': 'Copier la commande de connexion',
|
||||
@@ -1202,9 +1176,10 @@ export const fr: Record<ForgePanelKey, string> = {
|
||||
'change.unserved': 'L’état des demandes n’est pas encore pris en charge pour cet hébergeur de code',
|
||||
'change.view': 'Ouvrir dans le navigateur',
|
||||
'change.copy': 'Copier le lien de la demande',
|
||||
'change.viewChanges': 'Voir les modifications',
|
||||
'change.actions': 'Actions pour {name}',
|
||||
'change.viewChangesAria': 'Voir les modifications de {name} : {added} lignes ajoutées et {deleted} supprimées',
|
||||
'change.remove': 'Retirer de cette session',
|
||||
'change.removeAria': 'Retirer {name} de cette session',
|
||||
'change.row.checks': 'Vérifications',
|
||||
'change.row.review': 'Revue',
|
||||
'change.row.merge': 'Fusionner',
|
||||
@@ -1375,8 +1350,6 @@ export const de: Record<ForgePanelKey, string> = {
|
||||
'diff.fileTree': 'Dateibaum',
|
||||
'diff.showFileTreeLeft': 'Dateibaum links anzeigen',
|
||||
'diff.moveFileTreeRight': 'Dateibaum nach rechts verschieben',
|
||||
'guide.title': 'Code-Review und Änderungen',
|
||||
'guide.description': 'Codeänderungen und Änderungsanfragen dieser Sitzung prüfen',
|
||||
'diff.hideFileTree': 'Dateibaum ausblenden',
|
||||
'review.range': '{range} kommentieren',
|
||||
'review.comment': 'Kommentar schreiben…',
|
||||
@@ -1409,25 +1382,21 @@ export const de: Record<ForgePanelKey, string> = {
|
||||
'list.stateChecks': '{state} · {checks}',
|
||||
'list.more': '{count} weitere Änderungsanfragen',
|
||||
'tab.title': 'Änderungsanfragen',
|
||||
'header.label': 'Änderungsanfragen dieser Sitzung',
|
||||
'header.attention': 'Änderungsanfragen dieser Sitzung erfordern Aufmerksamkeit',
|
||||
'checkout.worktree': 'Arbeitsbaum',
|
||||
'checkout.worktreeFrom': 'Arbeitsbaum · aus {base}',
|
||||
'checkout.project': 'Projektverzeichnis',
|
||||
'checkout.detached': 'Auf keinem Branch',
|
||||
'checkout.restore': 'Wiederherstellen',
|
||||
'checkout.copyWorktreePath': 'Pfad des Arbeitsbaums kopieren',
|
||||
'checkout.copyProjectPath': 'Projektpfad kopieren',
|
||||
'checkout.worktreeActions': 'Aktionen für das Worktree-Verzeichnis',
|
||||
'checkout.projectActions': 'Aktionen für das Projektverzeichnis',
|
||||
'checkout.none': 'Dieses Verzeichnis ist kein Git-Repository',
|
||||
'checkout.failed': 'Git-Informationen konnten nicht gelesen werden',
|
||||
'changes.title': 'Änderungsanfragen dieser Sitzung · {count}',
|
||||
'changes.empty': 'Diese Sitzung hat noch keine Änderungsanfragen',
|
||||
'changes.emptyHint': 'Hier erscheinen verknüpfte Änderungsanfragen: in dieser Sitzung erstellt, angesehen, bearbeitet oder ausgecheckt oder auf ihren aktuellen oder gepushten Branches geöffnet',
|
||||
'changes.local.title': 'Lokale Änderungen',
|
||||
'changes.local.refs': '{head} → {base}',
|
||||
'changes.local.files': '{count} Dateien',
|
||||
'changes.local.viewAria': 'Änderungen dieser Sitzung anzeigen: {count} Dateien, {added} Zeilen hinzugefügt, {deleted} Zeilen gelöscht',
|
||||
'changes.local.create': 'Änderungsanfrage erstellen',
|
||||
'changes.local.actions': 'Aktionen für lokale Änderungen',
|
||||
'changes.local.summary': 'Lokale Änderungen · {count} Dateien',
|
||||
'changes.local.prompt': 'Erstelle eine Änderungsanfrage für die Änderungen dieser Sitzung',
|
||||
'signin.title': 'Bei {host} anmelden, um den Status der Änderungsanfragen anzuzeigen',
|
||||
'signin.copy': 'Anmeldebefehl kopieren',
|
||||
@@ -1471,9 +1440,10 @@ export const de: Record<ForgePanelKey, string> = {
|
||||
'change.unserved': 'Der Status von Änderungsanfragen wird für diesen Code-Host noch nicht unterstützt',
|
||||
'change.view': 'Im Browser öffnen',
|
||||
'change.copy': 'Link zur Änderungsanfrage kopieren',
|
||||
'change.viewChanges': 'Änderungen anzeigen',
|
||||
'change.actions': 'Aktionen für {name}',
|
||||
'change.viewChangesAria': 'Änderungen von {name} anzeigen: {added} Zeilen hinzugefügt, {deleted} Zeilen gelöscht',
|
||||
'change.remove': 'Aus dieser Sitzung entfernen',
|
||||
'change.removeAria': '{name} aus dieser Sitzung entfernen',
|
||||
'change.row.checks': 'Prüfungen',
|
||||
'change.row.review': 'Review',
|
||||
'change.row.merge': 'Zusammenführen',
|
||||
@@ -1644,8 +1614,6 @@ export const ru: Record<ForgePanelKey, string> = {
|
||||
'diff.fileTree': 'Дерево файлов',
|
||||
'diff.showFileTreeLeft': 'Показать дерево файлов слева',
|
||||
'diff.moveFileTreeRight': 'Переместить дерево файлов вправо',
|
||||
'guide.title': 'Ревью кода и изменения',
|
||||
'guide.description': 'Просмотр изменений кода и запросов на изменение в этом сеансе',
|
||||
'diff.hideFileTree': 'Скрыть дерево файлов',
|
||||
'review.range': 'Комментарий к {range}',
|
||||
'review.comment': 'Оставьте комментарий…',
|
||||
@@ -1678,25 +1646,21 @@ export const ru: Record<ForgePanelKey, string> = {
|
||||
'list.stateChecks': '{state} · {checks}',
|
||||
'list.more': 'Ещё запросов на изменение: {count}',
|
||||
'tab.title': 'Запросы на изменение',
|
||||
'header.label': 'Запросы на изменение этого сеанса',
|
||||
'header.attention': 'Запросы на изменение этого сеанса требуют внимания',
|
||||
'checkout.worktree': 'Рабочее дерево',
|
||||
'checkout.worktreeFrom': 'Рабочее дерево · на основе {base}',
|
||||
'checkout.project': 'Каталог проекта',
|
||||
'checkout.detached': 'Вне ветки',
|
||||
'checkout.restore': 'Восстановить',
|
||||
'checkout.copyWorktreePath': 'Копировать путь рабочего дерева',
|
||||
'checkout.copyProjectPath': 'Копировать путь проекта',
|
||||
'checkout.worktreeActions': 'Действия с каталогом рабочего дерева',
|
||||
'checkout.projectActions': 'Действия с каталогом проекта',
|
||||
'checkout.none': 'Этот каталог не является репозиторием Git',
|
||||
'checkout.failed': 'Не удалось прочитать сведения Git',
|
||||
'changes.title': 'Запросы на изменение этого сеанса · {count}',
|
||||
'changes.empty': 'В этом сеансе пока нет запросов на изменение',
|
||||
'changes.emptyHint': 'Здесь отображаются связанные с сеансом запросы: созданные, просмотренные, изменённые или извлечённые, а также открытые для текущей или отправленной ветки',
|
||||
'changes.local.title': 'Локальные изменения',
|
||||
'changes.local.refs': '{head} → {base}',
|
||||
'changes.local.files': 'Файлов: {count}',
|
||||
'changes.local.viewAria': 'Просмотреть изменения сеанса: файлов — {count}, добавлено строк — {added}, удалено — {deleted}',
|
||||
'changes.local.create': 'Создать запрос на изменение',
|
||||
'changes.local.actions': 'Действия с локальными изменениями',
|
||||
'changes.local.summary': 'Локальные изменения · файлов: {count}',
|
||||
'changes.local.prompt': 'Создай запрос на изменение для изменений этого сеанса',
|
||||
'signin.title': 'Войдите на {host}, чтобы увидеть состояние запросов',
|
||||
'signin.copy': 'Копировать команду входа',
|
||||
@@ -1740,9 +1704,10 @@ export const ru: Record<ForgePanelKey, string> = {
|
||||
'change.unserved': 'Состояние запросов этого хостинга кода пока не поддерживается',
|
||||
'change.view': 'Открыть в браузере',
|
||||
'change.copy': 'Копировать ссылку на запрос',
|
||||
'change.viewChanges': 'Показать изменения',
|
||||
'change.actions': 'Действия для {name}',
|
||||
'change.viewChangesAria': 'Просмотреть изменения {name}: добавлено строк — {added}, удалено — {deleted}',
|
||||
'change.remove': 'Удалить из этого сеанса',
|
||||
'change.removeAria': 'Удалить {name} из этого сеанса',
|
||||
'change.row.checks': 'Проверки',
|
||||
'change.row.review': 'Ревью',
|
||||
'change.row.merge': 'Объединить',
|
||||
@@ -1913,8 +1878,6 @@ export const pt: Record<ForgePanelKey, string> = {
|
||||
'diff.fileTree': 'Árvore de arquivos',
|
||||
'diff.showFileTreeLeft': 'Mostrar árvore de arquivos à esquerda',
|
||||
'diff.moveFileTreeRight': 'Mover árvore de arquivos para a direita',
|
||||
'guide.title': 'Revisão de código e alterações',
|
||||
'guide.description': 'Revisar alterações de código e solicitações de alteração desta sessão',
|
||||
'diff.hideFileTree': 'Ocultar árvore de arquivos',
|
||||
'review.range': 'Comentar {range}',
|
||||
'review.comment': 'Deixe um comentário…',
|
||||
@@ -1947,25 +1910,21 @@ export const pt: Record<ForgePanelKey, string> = {
|
||||
'list.stateChecks': '{state} · {checks}',
|
||||
'list.more': 'Mais {count} solicitações de alteração',
|
||||
'tab.title': 'Solicitações de alteração',
|
||||
'header.label': 'Solicitações de alteração desta sessão',
|
||||
'header.attention': 'As solicitações de alteração desta sessão precisam de atenção',
|
||||
'checkout.worktree': 'Árvore de trabalho',
|
||||
'checkout.worktreeFrom': 'Árvore de trabalho · a partir de {base}',
|
||||
'checkout.project': 'Diretório do projeto',
|
||||
'checkout.detached': 'Fora de uma branch',
|
||||
'checkout.restore': 'Restaurar',
|
||||
'checkout.copyWorktreePath': 'Copiar caminho da árvore de trabalho',
|
||||
'checkout.copyProjectPath': 'Copiar caminho do projeto',
|
||||
'checkout.worktreeActions': 'Ações da pasta do worktree',
|
||||
'checkout.projectActions': 'Ações da pasta do projeto',
|
||||
'checkout.none': 'Este diretório não é um repositório Git',
|
||||
'checkout.failed': 'Não foi possível ler as informações do Git',
|
||||
'changes.title': 'Solicitações de alteração desta sessão · {count}',
|
||||
'changes.empty': 'Esta sessão ainda não tem solicitações de alteração',
|
||||
'changes.emptyHint': 'Aqui aparecem solicitações vinculadas à sessão: criadas, visualizadas, editadas ou usadas em checkout, ou abertas nas branches atuais ou enviadas',
|
||||
'changes.local.title': 'Alterações locais',
|
||||
'changes.local.refs': '{head} → {base}',
|
||||
'changes.local.files': '{count} arquivos',
|
||||
'changes.local.viewAria': 'Ver alterações desta sessão: {count} arquivos, {added} linhas adicionadas e {deleted} removidas',
|
||||
'changes.local.create': 'Criar solicitação de alteração',
|
||||
'changes.local.actions': 'Ações das alterações locais',
|
||||
'changes.local.summary': 'Alterações locais · {count} arquivos',
|
||||
'changes.local.prompt': 'Crie uma solicitação de alteração para as alterações desta sessão',
|
||||
'signin.title': 'Entre em {host} para ver o status das solicitações',
|
||||
'signin.copy': 'Copiar comando de login',
|
||||
@@ -2009,9 +1968,10 @@ export const pt: Record<ForgePanelKey, string> = {
|
||||
'change.unserved': 'O status de solicitações deste serviço de código ainda não é compatível',
|
||||
'change.view': 'Abrir no navegador',
|
||||
'change.copy': 'Copiar link da solicitação',
|
||||
'change.viewChanges': 'Ver alterações',
|
||||
'change.actions': 'Ações de {name}',
|
||||
'change.viewChangesAria': 'Ver alterações de {name}: {added} linhas adicionadas e {deleted} removidas',
|
||||
'change.remove': 'Remover desta sessão',
|
||||
'change.removeAria': 'Remover {name} desta sessão',
|
||||
'change.row.checks': 'Verificações',
|
||||
'change.row.review': 'Revisão',
|
||||
'change.row.merge': 'Mesclar',
|
||||
|
||||
@@ -6,8 +6,8 @@ import type {} from '@deepseek-ai/dsh-api-session-controller/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-conversation/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-layout/client'
|
||||
import { IconBranchOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-session-panel/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
|
||||
import type { HostObservable } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-workspace/client'
|
||||
@@ -18,19 +18,23 @@ import type { ForgeChangeRequestListState, ForgeChangeRequestStatesFrame, ForgeP
|
||||
import { ReviewQueue } from './review-queue.ts'
|
||||
import { formatReviewComment, type ReviewSelection } from './review.ts'
|
||||
import { ActionToast } from './ActionToast.tsx'
|
||||
import { CHANGES_ID, changesDefinition } from './changes-address.ts'
|
||||
import { AttentionIndicator, type AttentionIndicatorInjected } from './AttentionIndicator.tsx'
|
||||
import { CHANGES_ID, changesAddress, changesDefinition, type ChangesSource } from './changes-address.ts'
|
||||
import {
|
||||
ChangeRequestsActions, ChangeRequestsSection, type ChangeRequestsActionsInjected, type ChangeRequestsSectionInjected,
|
||||
} from './ChangeRequestsSection.tsx'
|
||||
import { createChangesStore } from './changes-store.ts'
|
||||
import { ChangesTab, type ChangesTabInjected } from './ChangesTab.tsx'
|
||||
import { ChangesTabTitle } from './ChangesTabTitle.tsx'
|
||||
import { ForgeTab, type ForgeTabInjected } from './ForgeTab.tsx'
|
||||
import { ForgeTabTitle } from './ForgeTabTitle.tsx'
|
||||
import { HeaderButton, type HeaderButtonInjected } from './HeaderButton.tsx'
|
||||
import {
|
||||
CheckoutRow, EnvironmentActions, LocalChangesRow, type CheckoutRowInjected, type LocalChangesRowInjected,
|
||||
} from './EnvironmentRows.tsx'
|
||||
import { de, en, es, fr, ja, NS, pt, ru, zh, type ForgePanelKey } from './locales.ts'
|
||||
import type { SessionListInjected } from './session-list.ts'
|
||||
import { SessionHoverForge } from './SessionHoverForge.tsx'
|
||||
import { SessionRowForge } from './SessionRowForge.tsx'
|
||||
import {
|
||||
createNoticeSource, createPanelSource, createStreamSource, createVisibilitySource, foldStates, type PanelSource, type VisibilitySource,
|
||||
createNoticeSource, createPanelSource, createStreamSource, foldStates, type PanelSource,
|
||||
} from './source.ts'
|
||||
import { numberOf } from './status.ts'
|
||||
import { WorktreeProgress, type WorktreeProgressInjected } from './WorktreeProgress.tsx'
|
||||
@@ -39,12 +43,6 @@ import { WorktreeToggle, type WorktreeToggleInjected } from './WorktreeToggle.ts
|
||||
/** Services required before the Remote contribution mounts. */
|
||||
export const inject = ['remote', 'slots', 'locale', 'sidebarRightTabs', 'sidebarRight', 'sessions']
|
||||
|
||||
/** Registry id of the forge tab type, also its slot key. */
|
||||
export const TAB_ID = '@deepseek-ai/dsh-experimental-client-ui-forge'
|
||||
|
||||
/** Kind of the forge tab. */
|
||||
export const TAB_KIND = 'forge-panel'
|
||||
|
||||
/**
|
||||
* Open a URL in a new browsing context without giving it access to this page.
|
||||
* @param url - change request web URL.
|
||||
@@ -53,10 +51,9 @@ function openLink(url: string): void {
|
||||
window.open(url, '_blank', 'noopener,noreferrer')
|
||||
}
|
||||
|
||||
/** Per-Session stores shared by the tab, the header button, the New Session option, and the worktree card. */
|
||||
/** Per-Session stores shared by the Session panel entries, the New Session option, and the worktree card. */
|
||||
interface SessionStores {
|
||||
readonly panel: PanelSource
|
||||
readonly visibility: VisibilitySource
|
||||
readonly reviews: WeakMap<AbortSignal, ReviewQueue>
|
||||
readonly release: () => void
|
||||
}
|
||||
@@ -83,7 +80,7 @@ function registerUi(ctx: Context): void {
|
||||
panel.close()
|
||||
stores.delete(sessionId)
|
||||
}, 'forge-panel: release Session state')
|
||||
store = { panel, visibility: createVisibilitySource(), reviews: new WeakMap(), release: () => { void dispose() } }
|
||||
store = { panel, reviews: new WeakMap(), release: () => { void dispose() } }
|
||||
stores.set(sessionId, store)
|
||||
}
|
||||
return store
|
||||
@@ -158,14 +155,18 @@ function registerUi(ctx: Context): void {
|
||||
getSnapshot: () => ctx.locale.getLocale().active,
|
||||
subscribe: listener => ctx.locale.subscribe(listener),
|
||||
}
|
||||
const tabFace = (sessionId: SessionId): ForgeTabInjected => {
|
||||
const refreshOf = (sessionId: SessionId) => async (): Promise<void> => {
|
||||
settled(await ctx.remote.forgePanel.refresh(sessionId), 'toast.refreshFailed')
|
||||
}
|
||||
const openChanges = (sessionId: SessionId, source: ChangesSource): void => {
|
||||
ctx.sidebarRight.openResourceIn(sessionId, changesAddress({ sessionId, source }))
|
||||
}
|
||||
const sectionFace = (sessionId: SessionId): ChangeRequestsSectionInjected => {
|
||||
const store = storesOf(sessionId)
|
||||
return {
|
||||
hooks: { panel: store.panel.hooks.panel, host, locale },
|
||||
hooks: { panel: store.panel.hooks.panel, locale },
|
||||
reconnect: store.panel.reconnect,
|
||||
refresh: async () => {
|
||||
settled(await ctx.remote.forgePanel.refresh(sessionId), 'toast.refreshFailed')
|
||||
},
|
||||
refresh: refreshOf(sessionId),
|
||||
remove: (entry) => { remove(sessionId, entry) },
|
||||
readChecks: async (url, headSha, signal) => {
|
||||
const result = await ctx.remote.forgePanel.changeRequestChecks(sessionId, url, headSha, signal)
|
||||
@@ -183,18 +184,31 @@ function registerUi(ctx: Context): void {
|
||||
else if (result.error.code === 'forgePanel/stale-head') notices.report('toast.mergeStale', { params: { name: nameOf(entry) } })
|
||||
else notices.report('toast.mergeFailed', { params: { message: result.error.message } })
|
||||
},
|
||||
restore: () => {
|
||||
void restore(sessionId).then((message) => {
|
||||
if (message !== undefined) notices.report('toast.restoreFailed', { params: { message } })
|
||||
})
|
||||
},
|
||||
openLink,
|
||||
copyText,
|
||||
copyPath,
|
||||
reportVisible: store.visibility.set,
|
||||
createChangeRequest: () => { createChangeRequest(sessionId) },
|
||||
viewChanges: (entry) => { openChanges(sessionId, { kind: 'change', url: entry.url }) },
|
||||
}
|
||||
}
|
||||
const sectionActionsFace = (sessionId: SessionId): ChangeRequestsActionsInjected => ({
|
||||
hooks: { panel: storesOf(sessionId).panel.hooks.panel },
|
||||
refresh: refreshOf(sessionId),
|
||||
})
|
||||
const checkoutFace = (sessionId: SessionId): CheckoutRowInjected => ({
|
||||
hooks: { panel: storesOf(sessionId).panel.hooks.panel, host },
|
||||
restore: () => {
|
||||
void restore(sessionId).then((message) => {
|
||||
if (message !== undefined) notices.report('toast.restoreFailed', { params: { message } })
|
||||
})
|
||||
},
|
||||
})
|
||||
const localFace = (sessionId: SessionId): LocalChangesRowInjected => ({
|
||||
hooks: { panel: storesOf(sessionId).panel.hooks.panel },
|
||||
viewLocalChanges: () => { openChanges(sessionId, { kind: 'local' }) },
|
||||
createChangeRequest: () => { createChangeRequest(sessionId) },
|
||||
})
|
||||
const attentionFace = (sessionId: SessionId): AttentionIndicatorInjected => ({
|
||||
hooks: { panel: storesOf(sessionId).panel.hooks.panel },
|
||||
})
|
||||
const changesFace = (sessionId: SessionId): ChangesTabInjected => {
|
||||
const store = storesOf(sessionId)
|
||||
return {
|
||||
@@ -266,18 +280,36 @@ function registerUi(ctx: Context): void {
|
||||
},
|
||||
}
|
||||
}
|
||||
ctx.effect(() => ctx.sidebarRightTabs.register({
|
||||
id: TAB_ID, kind: TAB_KIND, title: () => t('tab.title'),
|
||||
guide: [{
|
||||
id: 'review', order: 15, title: () => t('guide.title'), description: () => t('guide.description'), icon: IconBranchOutlineRegular,
|
||||
}],
|
||||
}), 'forge-panel: sidebar tab')
|
||||
ctx.slots.inject('sidebar.right.pane.tab', () => ctx.slots.register({
|
||||
name: 'sidebar.right.pane.tab', key: TAB_ID, locale: NS, inject: tabFace,
|
||||
}, ForgeTab))
|
||||
ctx.slots.inject('sidebar.right.pane.tab.title', () => ctx.slots.register({
|
||||
name: 'sidebar.right.pane.tab.title', key: TAB_ID, locale: NS,
|
||||
}, ForgeTabTitle))
|
||||
ctx.slots.inject('conversation.session.panel.section', function* () {
|
||||
yield ctx.slots.register({
|
||||
name: 'conversation.session.panel.section',
|
||||
id: 'change-requests',
|
||||
// The first section after the Environment section (0).
|
||||
order: 100,
|
||||
label: () => t('tab.title'),
|
||||
locale: NS,
|
||||
inject: sectionFace,
|
||||
}, ChangeRequestsSection)
|
||||
yield ctx.slots.register({
|
||||
name: 'conversation.session.panel.section.actions', key: 'change-requests', locale: NS, inject: sectionActionsFace,
|
||||
}, ChangeRequestsActions)
|
||||
})
|
||||
ctx.slots.inject('conversation.session.panel.environment.row', function* () {
|
||||
// The checkout this refresh inspects is what the Environment section shows.
|
||||
yield ctx.slots.register({
|
||||
name: 'conversation.session.panel.section.actions', key: 'environment', locale: NS, inject: sectionActionsFace,
|
||||
}, EnvironmentActions)
|
||||
// After the project row (0).
|
||||
yield ctx.slots.register({
|
||||
name: 'conversation.session.panel.environment.row', id: 'forge.checkout', order: 20, locale: NS, inject: checkoutFace,
|
||||
}, CheckoutRow)
|
||||
yield ctx.slots.register({
|
||||
name: 'conversation.session.panel.environment.row', id: 'forge.local', order: 30, locale: NS, inject: localFace,
|
||||
}, LocalChangesRow)
|
||||
})
|
||||
ctx.slots.inject('conversation.session.panel.indicator', () => ctx.slots.register({
|
||||
name: 'conversation.session.panel.indicator', id: 'forge.attention', locale: NS, inject: attentionFace,
|
||||
}, AttentionIndicator))
|
||||
ctx.effect(() => ctx.sidebarRightTabs.register(changesDefinition(t)), 'forge-panel: changes tab')
|
||||
ctx.slots.inject('sidebar.right.pane.tab', () => ctx.slots.register({
|
||||
name: 'sidebar.right.pane.tab', key: CHANGES_ID, locale: NS, store: createChangesStore(), inject: changesFace,
|
||||
@@ -285,25 +317,6 @@ function registerUi(ctx: Context): void {
|
||||
ctx.slots.inject('sidebar.right.pane.tab.title', () => ctx.slots.register({
|
||||
name: 'sidebar.right.pane.tab.title', key: CHANGES_ID, locale: NS,
|
||||
}, ChangesTabTitle))
|
||||
ctx.slots.inject('conversation.session.header.utilities', () => ctx.slots.register({
|
||||
name: 'conversation.session.header.utilities',
|
||||
id: 'forge-panel',
|
||||
// Left of the schedule entry (-5) and the overflow menu (0), right of open-in-app (-10).
|
||||
order: -8,
|
||||
locale: NS,
|
||||
inject: (sessionId: SessionId): HeaderButtonInjected => {
|
||||
const store = storesOf(sessionId)
|
||||
return {
|
||||
hooks: { panel: store.panel.hooks.panel, visible: store.visibility.hooks.visible },
|
||||
toggle: (visible) => {
|
||||
if (!visible) { ctx.sidebarRight.openTab(TAB_KIND); return }
|
||||
const tab = ctx.sidebarRight.tabsIn(sessionId).find(tab => tab.kind === TAB_KIND)
|
||||
if (tab === undefined) return
|
||||
ctx.sidebarRight.hide(tab.id)
|
||||
},
|
||||
}
|
||||
},
|
||||
}, HeaderButton))
|
||||
ctx.slots.inject('conversation.hero.options', () => ctx.slots.register({
|
||||
name: 'conversation.hero.options', id: 'forge-panel.worktree', locale: NS, inject: worktreeFace,
|
||||
}, WorktreeToggle))
|
||||
|
||||
@@ -236,39 +236,3 @@ export function createNoticeSource(): NoticeSource {
|
||||
dismiss: () => { publish(null) },
|
||||
}
|
||||
}
|
||||
|
||||
/** Whether one Session's forge tab is visible; the header entry reads it for its pressed state. */
|
||||
export interface VisibilitySource {
|
||||
/** Current visibility; the renderer binds it as `useVisible`. */
|
||||
readonly hooks: { readonly visible: HostObservable<boolean> }
|
||||
/**
|
||||
* Record the tab's visibility.
|
||||
* @param visible - whether the tab is visible.
|
||||
*/
|
||||
readonly set: (visible: boolean) => void
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the visibility store of one Session's forge tab, initially hidden.
|
||||
* @returns the store.
|
||||
*/
|
||||
export function createVisibilitySource(): VisibilitySource {
|
||||
let visible = false
|
||||
const listeners = new Set<() => void>()
|
||||
return {
|
||||
hooks: {
|
||||
visible: {
|
||||
getSnapshot: () => visible,
|
||||
subscribe(listener) {
|
||||
listeners.add(listener)
|
||||
return () => { listeners.delete(listener) }
|
||||
},
|
||||
},
|
||||
},
|
||||
set: (next) => {
|
||||
if (next === visible) return
|
||||
visible = next
|
||||
for (const listener of [...listeners]) listener()
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -322,7 +322,7 @@ export class SessionPanel {
|
||||
return within(root, inspection.checkout.root) && within(root, inspection.commonDir) ? null : 'outside-writable-root'
|
||||
}
|
||||
|
||||
/** Measure the `branch` scope; a failed measurement only hides the local changes card. */
|
||||
/** Measure the `branch` scope; a failed measurement only hides the local changes row. */
|
||||
private async localOf(inspection: Inspection): Promise<ForgeLocalChanges | null> {
|
||||
try {
|
||||
return await localChanges(this.ctx, this.config, this.session, inspection, this.worktree().created, this.lifetime.signal)
|
||||
|
||||
@@ -333,7 +333,7 @@ export interface ForgeChangedFile {
|
||||
readonly binary: boolean
|
||||
}
|
||||
|
||||
/** Size of the `branch` scope, which the panel's local changes card shows. */
|
||||
/** Size of the `branch` scope, which the Session panel's local changes row shows. */
|
||||
export interface ForgeLocalChanges {
|
||||
/** Ref or abbreviated commit the scope compares with. */
|
||||
readonly base: string
|
||||
@@ -362,7 +362,7 @@ export interface Config {
|
||||
worktreePrefix?: string
|
||||
/** Largest diff, file read to show unchanged lines, or list of base branch refs, in bytes. */
|
||||
maxDiffBytes?: number
|
||||
/** Most untracked files a local diff or the local changes card includes. */
|
||||
/** Most untracked files a local diff or the local changes row includes. */
|
||||
maxUntrackedFiles?: number
|
||||
/** Most UTF-8 bytes of change request diffs kept in memory for later reads at the same head commit and base branch. */
|
||||
maxCachedDiffBytes?: number
|
||||
|
||||
@@ -6,7 +6,7 @@ import { makeTranslate } from '@deepseek-ai/dsh-client-test-runtime'
|
||||
import type { ForgeFailure, MergeRequest } from '@deepseek-ai/dsh-experimental-forge/types'
|
||||
import { ChangeRequestCard, type ChangeRequestActions } from '../src/client/ChangeRequestCard.tsx'
|
||||
import { en } from '../src/client/locales.ts'
|
||||
import css from '../src/client/ForgeTab.module.css'
|
||||
import css from '../src/client/Forge.module.css'
|
||||
import type { ForgePanelChangeRequest } from '../src/types.ts'
|
||||
import { check, entry, snapshot, unserved } from './client-fixtures.client.ts'
|
||||
|
||||
@@ -35,7 +35,20 @@ function card(value: ForgePanelChangeRequest, options: { expanded?: boolean; act
|
||||
if (!(item instanceof HTMLElement) || !(head instanceof HTMLElement)) throw new Error('no change request card')
|
||||
/** The number and status line below the title, or null when it names neither. */
|
||||
const meta = (): HTMLElement | null => head.querySelector(`.${css.meta}`)
|
||||
return { view, item, head, meta, title: within(head).getByRole('link'), openLink, copyLink, retry, remove, onToggle }
|
||||
const menuButton = (): HTMLElement => within(head).getByRole('button', { name: /^Actions for / })
|
||||
/** Labels of the actions menu, closing it again. */
|
||||
const menuItems = (): string[] => {
|
||||
fireEvent.click(menuButton())
|
||||
const labels = screen.queryAllByRole('menuitem').map(row => row.textContent)
|
||||
fireEvent.click(menuButton())
|
||||
return labels
|
||||
}
|
||||
/** Open the actions menu and choose one item. */
|
||||
const choose = (label: string): void => {
|
||||
fireEvent.click(menuButton())
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: label }))
|
||||
}
|
||||
return { view, item, head, meta, menuButton, menuItems, choose, title: within(head).getByRole('link'), openLink, copyLink, retry, remove, onToggle }
|
||||
}
|
||||
|
||||
/** The number and status line of a card that has one. */
|
||||
@@ -116,9 +129,10 @@ describe('collapsed ChangeRequestCard', () => {
|
||||
expect(meta.querySelector('[data-flag]')).toBeNull()
|
||||
expect(within(b.item).queryByText(en['change.row.changes'])).toBeNull()
|
||||
expect(within(b.item).queryByText('+12')).toBeNull()
|
||||
fireEvent.click(within(b.head).getByRole('button', { name: en['change.view'] }))
|
||||
fireEvent.click(within(b.head).getByRole('button', { name: en['change.copy'] }))
|
||||
fireEvent.click(within(b.head).getByRole('button', { name: 'Remove #7 from this Session' }))
|
||||
expect(b.menuButton().getAttribute('aria-label')).toBe('Actions for #7')
|
||||
b.choose(en['change.view'])
|
||||
b.choose(en['change.copy'])
|
||||
b.choose(en['change.remove'])
|
||||
expect(b.openLink).toHaveBeenCalledWith('https://github.com/octo/demo/pull/7')
|
||||
expect(b.copyLink).toHaveBeenCalledWith('https://github.com/octo/demo/pull/7')
|
||||
expect(b.remove).toHaveBeenCalledOnce()
|
||||
@@ -231,9 +245,9 @@ describe('expanded ChangeRequestCard', () => {
|
||||
expect(within(b.item).getByText('+12,345')).toBeTruthy()
|
||||
expect(within(b.item).getByText(`${MINUS}3`)).toBeTruthy()
|
||||
|
||||
fireEvent.click(within(b.head).getByRole('button', { name: en['change.view'] }))
|
||||
fireEvent.click(within(b.head).getByRole('button', { name: en['change.copy'] }))
|
||||
fireEvent.click(within(b.head).getByRole('button', { name: 'Remove #7 from this Session' }))
|
||||
b.choose(en['change.view'])
|
||||
b.choose(en['change.copy'])
|
||||
b.choose(en['change.remove'])
|
||||
expect(b.openLink).toHaveBeenCalledWith('https://github.com/octo/demo/pull/7#web')
|
||||
expect(b.copyLink).toHaveBeenCalledWith('https://github.com/octo/demo/pull/7#web')
|
||||
expect(b.remove).toHaveBeenCalledWith(value)
|
||||
@@ -428,7 +442,8 @@ describe('expanded ChangeRequestCard', () => {
|
||||
expect(metaOf(b).textContent).toBe('#1')
|
||||
expect(within(b.item).queryByText(en['change.row.checks'])).toBeNull()
|
||||
expect(within(b.item).queryByText('+12')).toBeNull()
|
||||
fireEvent.click(within(b.head).getByRole('button', { name: en['change.copy'] }))
|
||||
expect(b.menuItems()).toEqual([en['change.view'], en['change.copy'], en['change.remove']])
|
||||
b.choose(en['change.copy'])
|
||||
expect(b.copyLink).toHaveBeenCalledWith('https://github.com/octo/demo/pull/1')
|
||||
})
|
||||
|
||||
@@ -436,16 +451,25 @@ describe('expanded ChangeRequestCard', () => {
|
||||
const b = card({ ...unserved('https://example.test/review/latest'), snapshot: snapshot(3, { url: 'https://example.test/review/latest#web' }) }, { expanded: true })
|
||||
expect(b.title.textContent).toBe('Change 3')
|
||||
expect(metaOf(b).textContent).toBe('feat → main')
|
||||
fireEvent.click(within(b.head).getByRole('button', { name: 'Remove Change 3 from this Session' }))
|
||||
expect(b.menuButton().getAttribute('aria-label')).toBe('Actions for Change 3')
|
||||
b.choose(en['change.remove'])
|
||||
expect(b.remove).toHaveBeenCalledOnce()
|
||||
fireEvent.click(within(b.head).getByRole('button', { name: en['change.view'] }))
|
||||
b.choose(en['change.view'])
|
||||
expect(b.openLink).toHaveBeenCalledWith('https://example.test/review/latest#web')
|
||||
})
|
||||
|
||||
it('closes the actions menu on Escape', () => {
|
||||
const b = card(entry(1, snapshot(1)))
|
||||
fireEvent.click(b.menuButton())
|
||||
expect(b.menuButton().getAttribute('aria-expanded')).toBe('true')
|
||||
fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' })
|
||||
expect(screen.queryByRole('menuitem')).toBeNull()
|
||||
expect(b.menuButton().getAttribute('aria-expanded')).toBe('false')
|
||||
})
|
||||
|
||||
it('omits removal on a surface without a Session binding', () => {
|
||||
const b = card(entry(1, snapshot(1)), { expanded: true, actions: { remove: undefined } })
|
||||
expect(within(b.head).queryByRole('button', { name: 'Remove #1 from this Session' })).toBeNull()
|
||||
expect(within(b.head).getByRole('button', { name: en['change.view'] })).toBeTruthy()
|
||||
expect(b.menuItems()).toEqual([en['change.view'], en['change.copy']])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -469,20 +493,21 @@ describe('ChangeRequestCard actions', () => {
|
||||
const markReady = vi.fn<(entry: ForgePanelChangeRequest) => Promise<void>>(() => pending.promise)
|
||||
const value = entry(7, snapshot(7, { draft: true, mergeReady: true }))
|
||||
const b = card(value, { expanded: true, actions: { markReady } })
|
||||
const button = within(b.item).getByRole('button', { name: en['change.markReady'] })
|
||||
const item = (): HTMLElement => screen.getByRole('menuitem', { name: en['change.markReady'] })
|
||||
expect(within(b.item).queryByRole('button', { name: en['change.merge'] })).toBeNull()
|
||||
|
||||
fireEvent.click(button)
|
||||
fireEvent.click(button)
|
||||
b.choose(en['change.markReady'])
|
||||
fireEvent.click(b.menuButton())
|
||||
expect(item().hasAttribute('disabled')).toBe(true)
|
||||
fireEvent.click(item())
|
||||
expect(markReady).toHaveBeenCalledOnce()
|
||||
expect(markReady).toHaveBeenCalledWith(value)
|
||||
expect(button.hasAttribute('disabled')).toBe(true)
|
||||
|
||||
await act(async () => {
|
||||
pending.resolve()
|
||||
await pending.promise
|
||||
})
|
||||
expect(button.hasAttribute('disabled')).toBe(false)
|
||||
expect(item().hasAttribute('disabled')).toBe(false)
|
||||
})
|
||||
|
||||
it('lists the methods the repository allows with the usual one chosen, and merges the confirmed head with the chosen one', async () => {
|
||||
@@ -491,7 +516,6 @@ describe('ChangeRequestCard actions', () => {
|
||||
const value = entry(7, snapshot(7, { mergeReady: true, mergeMethods: ['merge', 'squash', 'rebase'], headSha: head }))
|
||||
const b = card(value, { expanded: true, actions: { merge } })
|
||||
const button = within(b.item).getByRole('button', { name: en['change.merge'] })
|
||||
expect(within(b.item).queryByRole('button', { name: en['change.markReady'] })).toBeNull()
|
||||
expect(button.getAttribute('aria-expanded')).toBe('false')
|
||||
expect(button.classList.contains(css.mergeAction ?? '')).toBe(true)
|
||||
const caret = (): Element | null => button.querySelector(`.${css.mergeCaret}`)
|
||||
@@ -578,8 +602,8 @@ describe('ChangeRequestCard actions', () => {
|
||||
['it is merged', { state: 'merged', mergeReady: true }],
|
||||
['it is a closed draft', { state: 'closed', draft: true }],
|
||||
] as const)('offers neither action when %s', (_label, overrides) => {
|
||||
const b = card(entry(7, snapshot(7, overrides)), { expanded: true })
|
||||
expect(within(b.item).queryByRole('button', { name: en['change.markReady'] })).toBeNull()
|
||||
const b = card(entry(7, snapshot(7, overrides)), { expanded: true, actions: { markReady: vi.fn(async () => {}) } })
|
||||
expect(b.menuItems()).not.toContain(en['change.markReady'])
|
||||
expect(within(b.item).queryByRole('button', { name: en['change.merge'] })).toBeNull()
|
||||
})
|
||||
|
||||
@@ -587,7 +611,8 @@ describe('ChangeRequestCard actions', () => {
|
||||
const actions = { markReady: undefined, merge: undefined }
|
||||
for (const value of [entry(7, snapshot(7, { draft: true })), entry(8, snapshot(8, { mergeReady: true }))]) {
|
||||
const b = card(value, { expanded: true, actions })
|
||||
expect(within(b.item).queryAllByRole('button', { name: new RegExp(`^(${en['change.markReady']}|${en['change.merge']})$`) })).toEqual([])
|
||||
expect(b.menuItems()).not.toContain(en['change.markReady'])
|
||||
expect(within(b.item).queryByRole('button', { name: en['change.merge'] })).toBeNull()
|
||||
cleanup()
|
||||
}
|
||||
})
|
||||
@@ -613,14 +638,17 @@ describe('ChangeRequestCard changes', () => {
|
||||
})
|
||||
|
||||
describe('ChangeRequestCard layout', () => {
|
||||
it('shows the action row only for a change request with an action', () => {
|
||||
it('shows the action row only for a change request the host would merge', () => {
|
||||
const waiting = card(entry(7, snapshot(7)), { expanded: true, actions: { merge: vi.fn(async () => {}) } })
|
||||
expect(waiting.item.querySelector(`.${css.footer}`)).toBeNull()
|
||||
cleanup()
|
||||
const draft = card(entry(8, snapshot(8, { draft: true })), { expanded: true, actions: { markReady: vi.fn(async () => {}) } })
|
||||
const footer = draft.item.querySelector(`.${css.footer}`)
|
||||
expect(draft.item.querySelector(`.${css.footer}`)).toBeNull()
|
||||
cleanup()
|
||||
const mergeable = card(entry(9, snapshot(9, { mergeReady: true })), { expanded: true, actions: { merge: vi.fn(async () => {}) } })
|
||||
const footer = mergeable.item.querySelector(`.${css.footer}`)
|
||||
if (!(footer instanceof HTMLElement)) throw new Error('no action row')
|
||||
expect(within(footer).getByRole('button').textContent).toBe(en['change.markReady'])
|
||||
expect(within(footer).getByRole('button').textContent).toBe(en['change.merge'])
|
||||
})
|
||||
|
||||
it('shows the changed lines of a finished change request below its end', () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @vitest-environment jsdom
|
||||
/** Session header entry, forge and changes tab titles, and action toast rendering. */
|
||||
/** Attention indicator, changes tab title, and action toast rendering. */
|
||||
import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'
|
||||
@@ -10,8 +10,7 @@ import { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import { ActionToast } from '../src/client/ActionToast.tsx'
|
||||
import { changesAddress } from '../src/client/changes-address.ts'
|
||||
import { ChangesTabTitle } from '../src/client/ChangesTabTitle.tsx'
|
||||
import { ForgeTabTitle } from '../src/client/ForgeTabTitle.tsx'
|
||||
import { HeaderButton } from '../src/client/HeaderButton.tsx'
|
||||
import { AttentionIndicator, type AttentionIndicatorProps } from '../src/client/AttentionIndicator.tsx'
|
||||
import { en } from '../src/client/locales.ts'
|
||||
import { createNoticeSource, type PanelSnapshot } from '../src/client/source.ts'
|
||||
import type { ForgePanelState } from '../src/types.ts'
|
||||
@@ -24,74 +23,30 @@ afterEach(() => {
|
||||
|
||||
const t = makeTranslate(en)
|
||||
|
||||
describe('HeaderButton', () => {
|
||||
function header(state: ForgePanelState | null, visible = false) {
|
||||
describe('AttentionIndicator', () => {
|
||||
function indicator(state: ForgePanelState | null) {
|
||||
const panel = createSnapshotStore<PanelSnapshot>({ state, disconnected: false })
|
||||
const visibility = createSnapshotStore<boolean>(visible)
|
||||
const toggle = vi.fn<(visible: boolean) => void>()
|
||||
const view = render(
|
||||
<HeaderButton usePanel={bindSnapshotSelector(panel)} useVisible={bindSnapshotSelector(visibility)} toggle={toggle} t={t} />,
|
||||
)
|
||||
return { panel, visibility, toggle, view, button: () => view.container.querySelector('[data-forge-header]') }
|
||||
const props = { usePanel: bindSnapshotSelector(panel), t } as
|
||||
Pick<AttentionIndicatorProps, 'usePanel' | 't'> as AttentionIndicatorProps
|
||||
const view = render(<AttentionIndicator {...props} />)
|
||||
return { panel, view }
|
||||
}
|
||||
|
||||
it.each([
|
||||
['before the first state', null],
|
||||
['outside a Git checkout', ready({ checkout: { state: 'none' } })],
|
||||
['while the first inspection of an unknown repository runs', ready({ checkout: { state: 'pending' }, repository: null })],
|
||||
])('stays hidden %s', (_label, state) => {
|
||||
expect(header(state).view.container.innerHTML).toBe('')
|
||||
['without change requests', ready()],
|
||||
['while every change request is fine', ready({ changeRequests: [entry(1, snapshot(1))] })],
|
||||
])('renders nothing %s', (_label, state) => {
|
||||
expect(indicator(state).view.container.innerHTML).toBe('')
|
||||
})
|
||||
|
||||
it.each([
|
||||
['a ready checkout', ready()],
|
||||
['a failed inspection', ready({ checkout: { state: 'failed', message: 'boom' } })],
|
||||
['a repeated inspection of a known repository', ready({ checkout: { state: 'pending' } })],
|
||||
['bound change requests outside a Git checkout', ready({ checkout: { state: 'none' }, changeRequests: [entry(1, snapshot(1))] })],
|
||||
])('opens the hidden tab for %s', (_label, state) => {
|
||||
const b = header(state)
|
||||
const button = b.view.getByRole('button', { name: en['header.label'] })
|
||||
expect(button.getAttribute('aria-pressed')).toBe('false')
|
||||
expect(button.querySelector('[data-state]')).toBeNull()
|
||||
fireEvent.click(button)
|
||||
expect(b.toggle).toHaveBeenCalledWith(false)
|
||||
})
|
||||
|
||||
it('marks change requests that need attention', () => {
|
||||
const b = header(ready({ changeRequests: [entry(1, snapshot(1)), entry(2, snapshot(2, { checksRollup: 'failure' }))] }))
|
||||
const button = b.view.getByRole('button', { name: en['header.attention'] })
|
||||
expect(button.querySelector('[data-state="error"]')).not.toBeNull()
|
||||
})
|
||||
|
||||
it('follows the tab visibility and hides a visible tab', () => {
|
||||
const b = header(ready(), true)
|
||||
const button = b.view.getByRole('button', { name: en['header.label'] })
|
||||
expect(button.getAttribute('aria-pressed')).toBe('true')
|
||||
fireEvent.click(button)
|
||||
expect(b.toggle).toHaveBeenLastCalledWith(true)
|
||||
|
||||
act(() => { b.visibility.set(false) })
|
||||
expect(button.getAttribute('aria-pressed')).toBe('false')
|
||||
fireEvent.click(button)
|
||||
expect(b.toggle).toHaveBeenLastCalledWith(false)
|
||||
})
|
||||
|
||||
it('appears, changes its label, and disappears as the panel state changes', () => {
|
||||
const b = header(null)
|
||||
act(() => { b.panel.set({ state: ready(), disconnected: false }) })
|
||||
expect(b.button()?.getAttribute('aria-label')).toBe(en['header.label'])
|
||||
act(() => { b.panel.set({ state: ready({ changeRequests: [entry(1, snapshot(1, { mergeability: 'conflicting' }))] }), disconnected: false }) })
|
||||
expect(b.button()?.getAttribute('aria-label')).toBe(en['header.attention'])
|
||||
act(() => { b.panel.set({ state: ready({ checkout: { state: 'none' } }), disconnected: true }) })
|
||||
expect(b.button()).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('ForgeTabTitle', () => {
|
||||
it('shows the branch glyph and the tab name', () => {
|
||||
const view = render(<ForgeTabTitle t={t} />)
|
||||
expect(view.getByText(en['tab.title'])).toBeTruthy()
|
||||
expect(view.container.querySelector('svg')).not.toBeNull()
|
||||
it('marks change requests that need attention and names the mark', () => {
|
||||
const b = indicator(ready({ changeRequests: [entry(1, snapshot(1)), entry(2, snapshot(2, { checksRollup: 'failure' }))] }))
|
||||
const mark = b.view.container.querySelector('[data-forge-attention]')
|
||||
expect(mark?.querySelector('[data-state="error"]')).not.toBeNull()
|
||||
expect(mark?.textContent).toBe(en['header.attention'])
|
||||
act(() => { b.panel.set({ state: ready({ changeRequests: [entry(1, snapshot(1))] }), disconnected: false }) })
|
||||
expect(b.view.container.innerHTML).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,465 +0,0 @@
|
||||
// @vitest-environment jsdom
|
||||
/**
|
||||
* Forge tab body: connection states, the checkout row, the local changes card,
|
||||
* the sign-in banner, the change request list, and tab visibility.
|
||||
*/
|
||||
import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { RemoteHostFacts } from '@deepseek-ai/dsh-api-remotes/client'
|
||||
import type { MergeRequest } from '@deepseek-ai/dsh-experimental-forge/types'
|
||||
import type { PaneId, SidebarRightTabActions, SidebarRightTabInfo, TabId } from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
|
||||
import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'
|
||||
import { bindSnapshotSelector, makeTranslate } from '@deepseek-ai/dsh-client-test-runtime'
|
||||
import { IconBranchOutlineRegular, IconFolderCloseRegular, IconWarningTriangleOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import { changesAddress } from '../src/client/changes-address.ts'
|
||||
import { ForgeTab, type ForgeTabProps } from '../src/client/ForgeTab.tsx'
|
||||
import { en } from '../src/client/locales.ts'
|
||||
import type { PanelSnapshot } from '../src/client/source.ts'
|
||||
import css from '../src/client/ForgeTab.module.css'
|
||||
import type { ForgePanelChangeRequest, ForgePanelState } from '../src/types.ts'
|
||||
import { created, entry, ready, removed, snapshot, worktree } from './client-fixtures.client.ts'
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
const t = makeTranslate(en)
|
||||
const SESSION = SessionId('s1')
|
||||
const unused = (): never => { throw new Error('the forge tab does not call this tab action') }
|
||||
|
||||
/** Tab information of a forge tab whose visibility the test sets. */
|
||||
function tabInfo(visible: boolean, openResource: SidebarRightTabActions['openResource']): SidebarRightTabInfo {
|
||||
return {
|
||||
sidebar: { expanded: true, fullscreen: false },
|
||||
panel: { id: 'pane-1' as PaneId, isFloating: false },
|
||||
tab: {
|
||||
id: 'tab-forge' as TabId,
|
||||
kind: 'forge-panel',
|
||||
contentId: 'sidebar://forge-panel',
|
||||
title: en['tab.title'],
|
||||
visible,
|
||||
navigation: { address: 'sidebar://forge-panel', params: undefined, revision: 0 },
|
||||
signal: new AbortController().signal,
|
||||
actions: { bindCommands: () => () => {}, openResource, openTab: unused, close: unused },
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
function tab(state: ForgePanelState | null, options: { disconnected?: boolean; visible?: boolean; home?: string } = {}) {
|
||||
const panel = createSnapshotStore<PanelSnapshot>({ state, disconnected: options.disconnected ?? false })
|
||||
const host = createSnapshotStore<RemoteHostFacts>({ home: options.home, isLoopback: true })
|
||||
const visibility = createSnapshotStore<boolean>(options.visible ?? true)
|
||||
const useVisibility = bindSnapshotSelector(visibility)
|
||||
const reconnect = vi.fn<() => void>()
|
||||
const refresh = vi.fn<() => Promise<void>>(async () => {})
|
||||
const remove = vi.fn<(entry: ForgePanelChangeRequest) => void>()
|
||||
const markReady = vi.fn<(entry: ForgePanelChangeRequest) => Promise<void>>(async () => {})
|
||||
const merge = vi.fn<(entry: ForgePanelChangeRequest, request: MergeRequest) => Promise<void>>(async () => {})
|
||||
const readChecks = vi.fn<ForgeTabProps['readChecks']>(async () => snapshot(1))
|
||||
const restore = vi.fn<() => void>()
|
||||
const openLink = vi.fn<(url: string) => void>()
|
||||
const copyText = vi.fn<(text: string) => void>()
|
||||
const copyPath = vi.fn<(path: string) => void>()
|
||||
const reportVisible = vi.fn<(visible: boolean) => void>()
|
||||
const createChangeRequest = vi.fn<() => void>()
|
||||
const openResource = vi.fn<SidebarRightTabActions['openResource']>()
|
||||
const props: ForgeTabProps = {
|
||||
useTabInfo: () => tabInfo(useVisibility(current => current), openResource),
|
||||
sessionId: SESSION,
|
||||
usePanel: bindSnapshotSelector(panel),
|
||||
useHost: bindSnapshotSelector(host),
|
||||
useLocale: bindSnapshotSelector(createSnapshotStore<string>('en')),
|
||||
reconnect, refresh, remove, markReady, merge, readChecks, restore, openLink, copyText, copyPath, reportVisible, createChangeRequest,
|
||||
t,
|
||||
}
|
||||
const view = render(<ForgeTab {...props} />)
|
||||
return {
|
||||
view, panel, visibility, reconnect, refresh, remove, markReady, merge, readChecks, restore, openLink, copyText, copyPath, reportVisible,
|
||||
createChangeRequest, openResource,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an animation event under the name React DOM listens for here: jsdom
|
||||
* has no `AnimationEvent` but declares `WebkitAnimation`, so React DOM uses the WebKit-prefixed names.
|
||||
*/
|
||||
function animation(element: Element, phase: 'Start' | 'Iteration'): void {
|
||||
fireEvent(element, new Event(`webkitAnimation${phase}`, { bubbles: true }))
|
||||
}
|
||||
|
||||
/** The checkout row, or null when the tab shows none. */
|
||||
function checkoutRow(view: ReturnType<typeof render>): HTMLElement | null {
|
||||
const row = view.container.querySelector(`.${css.checkout}`)
|
||||
return row instanceof HTMLElement ? row : null
|
||||
}
|
||||
|
||||
/** The expansion state of each rendered card, in list order. */
|
||||
function expansion(view: ReturnType<typeof render>): boolean[] {
|
||||
return [...view.container.querySelectorAll('[data-forge-change]')].map(card => card.hasAttribute('data-expanded'))
|
||||
}
|
||||
|
||||
describe('ForgeTab connection', () => {
|
||||
it('centers a spinner until the first state arrives', () => {
|
||||
const b = tab(null)
|
||||
expect(b.view.container.querySelector('[data-state="ongoing"]')).not.toBeNull()
|
||||
expect(b.view.container.querySelector('[data-forge-panel]')).toBeNull()
|
||||
expect(b.view.queryByRole('status')).toBeNull()
|
||||
|
||||
act(() => { b.panel.set({ state: ready(), disconnected: false }) })
|
||||
expect(b.view.container.querySelector('[data-forge-panel]')).not.toBeNull()
|
||||
})
|
||||
|
||||
it('replaces the spinner with a reconnect notice while disconnected', () => {
|
||||
const b = tab(null, { disconnected: true })
|
||||
expect(b.view.container.querySelector('[data-state="ongoing"]')).toBeNull()
|
||||
const status = b.view.getByRole('status')
|
||||
expect(within(status).getByText(en['stream.failed'])).toBeTruthy()
|
||||
fireEvent.click(within(status).getByRole('button', { name: en.retry }))
|
||||
expect(b.reconnect).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('keeps the last panel state and adds the reconnect notice while disconnected', () => {
|
||||
const b = tab(ready(), { disconnected: true })
|
||||
const root = b.view.container.querySelector('[data-forge-panel]')
|
||||
if (!(root instanceof HTMLElement)) throw new Error('no panel')
|
||||
expect(root.firstElementChild?.getAttribute('role')).toBe('status')
|
||||
fireEvent.click(within(root).getByRole('button', { name: en.retry }))
|
||||
expect(b.reconnect).toHaveBeenCalledOnce()
|
||||
|
||||
act(() => { b.panel.set({ state: ready(), disconnected: false }) })
|
||||
expect(b.view.queryByRole('status')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('ForgeTab checkout', () => {
|
||||
it('shows no checkout row while the first inspection runs', () => {
|
||||
const b = tab(ready({ checkout: { state: 'pending' } }))
|
||||
expect(checkoutRow(b.view)).toBeNull()
|
||||
expect(b.view.getByText('Change requests of this Session · 0')).toBeTruthy()
|
||||
})
|
||||
|
||||
it('explains a directory outside a Git checkout', () => {
|
||||
const b = tab(ready({ checkout: { state: 'none' } }))
|
||||
expect(checkoutRow(b.view)?.textContent).toBe(en['checkout.none'])
|
||||
})
|
||||
|
||||
it('shows a failed inspection and its message on hover', () => {
|
||||
const b = tab(ready({ checkout: { state: 'failed', message: 'git status failed (128): fatal' } }))
|
||||
const row = checkoutRow(b.view)
|
||||
if (row === null) throw new Error('no checkout row')
|
||||
expect(row.textContent).toBe(en['checkout.failed'])
|
||||
fireEvent.pointerEnter(row)
|
||||
expect(b.view.getByRole('tooltip').textContent).toBe('git status failed (128): fatal')
|
||||
})
|
||||
|
||||
it('names the branch and kind of the project directory and shows its path on hover', () => {
|
||||
const b = tab(ready(), { home: '/work' })
|
||||
const row = checkoutRow(b.view)
|
||||
if (row === null) throw new Error('no checkout row')
|
||||
expect(row.textContent).toBe(`main${en['checkout.project']}`)
|
||||
fireEvent.pointerEnter(row.querySelector(`.${css.checkoutName}`)!)
|
||||
expect(b.view.getByRole('tooltip').textContent).toBe('Project directory: ~/repo')
|
||||
// The copied path keeps the home directory the tooltip abbreviates.
|
||||
fireEvent.click(within(row).getByRole('button', { name: en['checkout.copyProjectPath'] }))
|
||||
expect(b.copyPath).toHaveBeenCalledWith('/work/repo')
|
||||
})
|
||||
|
||||
it('names a detached HEAD with its commit', () => {
|
||||
const b = tab(ready({}, { branch: null }))
|
||||
expect(checkoutRow(b.view)?.textContent).toBe(`${en['checkout.detached']}·0a1b2c3${en['checkout.project']}`)
|
||||
})
|
||||
|
||||
it('calls a linked worktree another tool created a worktree', () => {
|
||||
const b = tab(ready({}, { linked: true }))
|
||||
const row = checkoutRow(b.view)
|
||||
if (row === null) throw new Error('no checkout row')
|
||||
expect(row.textContent).toBe(`main${en['checkout.worktree']}`)
|
||||
fireEvent.click(within(row).getByRole('button', { name: en['checkout.copyWorktreePath'] }))
|
||||
expect(b.copyPath).toHaveBeenCalledWith('/work/repo')
|
||||
})
|
||||
|
||||
it.each([
|
||||
['its base branch', created({ path: '/work/repo-dsh' }), 'Worktree · from main'],
|
||||
['the commit it started from', created({ path: '/work/repo-dsh', from: null, baseCommit: '0123456789abcdef' }), 'Worktree · from 0123456'],
|
||||
])('names the worktree this Session created with %s', (_label, made, kind) => {
|
||||
const b = tab(ready({ directory: '/work/repo-dsh', worktree: worktree({ created: made }) }, { root: '/work/repo-dsh', branch: 'other', linked: true }))
|
||||
const row = checkoutRow(b.view)
|
||||
if (row === null) throw new Error('no checkout row')
|
||||
expect(row.textContent).toBe(`other${kind}`)
|
||||
fireEvent.click(within(row).getByRole('button', { name: en['checkout.copyWorktreePath'] }))
|
||||
expect(b.copyPath).toHaveBeenCalledWith('/work/repo-dsh')
|
||||
})
|
||||
|
||||
it('shows detached HEAD in the worktree the Session created', () => {
|
||||
const b = tab(ready({ directory: '/work/repo-dsh', worktree: worktree({ created: created({ path: '/work/repo-dsh' }) }) },
|
||||
{ root: '/work/repo-dsh', branch: null, commit: 'abc1234', linked: true }))
|
||||
expect(checkoutRow(b.view)?.textContent).toBe(`${en['checkout.detached']}·abc1234Worktree · from main`)
|
||||
})
|
||||
|
||||
it('names a removed worktree and restores it on request', () => {
|
||||
const b = tab(removed())
|
||||
const row = checkoutRow(b.view)
|
||||
if (row === null) throw new Error('no checkout row')
|
||||
expect(row.hasAttribute('data-missing')).toBe(true)
|
||||
expect(within(row).getByText('dsh/0a1b2c3d')).toBeTruthy()
|
||||
expect(within(row).getByText(en['missing.title'])).toBeTruthy()
|
||||
fireEvent.click(within(row).getByRole('button', { name: en['checkout.restore'] }))
|
||||
expect(b.restore).toHaveBeenCalledOnce()
|
||||
// A removed worktree still offers the path it was created at.
|
||||
fireEvent.click(within(row).getByRole('button', { name: en['checkout.copyWorktreePath'] }))
|
||||
expect(b.copyPath).toHaveBeenCalledWith('/work/repo-dsh')
|
||||
})
|
||||
|
||||
it('turns the restore button into a disabled spinner while a restoration runs', () => {
|
||||
const b = tab(removed(true, false, { restoration: { phase: 'prepare' } }))
|
||||
const row = checkoutRow(b.view)
|
||||
if (row === null) throw new Error('no checkout row')
|
||||
const restore = within(row).getByRole('button', { name: en['checkout.restore'] })
|
||||
expect(restore instanceof HTMLButtonElement && restore.disabled).toBe(true)
|
||||
expect(restore.querySelector('svg[data-state="ongoing"]')).not.toBeNull()
|
||||
})
|
||||
|
||||
it.each([
|
||||
['a folder for the project directory', () => ready(), IconFolderCloseRegular],
|
||||
['a branch for a linked worktree', () => ready({}, { linked: true }), IconBranchOutlineRegular],
|
||||
['a branch for the worktree this Session created',
|
||||
() => ready({ directory: '/work/repo-dsh', worktree: worktree({ created: created({ path: '/work/repo-dsh' }) }) }, { root: '/work/repo-dsh', branch: 'other', linked: true }),
|
||||
IconBranchOutlineRegular],
|
||||
['a warning for a removed worktree', () => removed(), IconWarningTriangleOutlineRegular],
|
||||
])('marks the checkout with %s', (_label, state, Icon) => {
|
||||
const b = tab(state())
|
||||
const glyph = checkoutRow(b.view)?.querySelector(`.${css.checkoutName} svg`)
|
||||
const expected = render(<Icon size={14} className={css.checkoutIcon} />).container.innerHTML
|
||||
expect(glyph?.outerHTML).toBe(expected)
|
||||
})
|
||||
})
|
||||
|
||||
describe('ForgeTab local changes', () => {
|
||||
const local = { base: 'origin/main', files: [{ path: 'src/a.ts', additions: 3, deletions: 1, binary: false }] }
|
||||
const LOCAL_ADDRESS = changesAddress({ sessionId: SESSION, source: { kind: 'local' } })
|
||||
|
||||
it('shows the changes of the checkout, opens them, and asks for a change request', () => {
|
||||
const b = tab(ready({ local }))
|
||||
const card = b.view.container.querySelector('[data-forge-local]')
|
||||
if (!(card instanceof HTMLElement)) throw new Error('no local changes card')
|
||||
expect(within(card).getByText('HEAD → origin/main')).toBeTruthy()
|
||||
fireEvent.click(within(card).getByRole('button', { name: 'View the changes of this Session: 1 files, 3 lines added, 1 lines deleted' }))
|
||||
expect(b.openResource).toHaveBeenLastCalledWith(LOCAL_ADDRESS, undefined)
|
||||
fireEvent.click(within(card).getByRole('button', { name: en['changes.local.title'] }))
|
||||
fireEvent.click(within(card).getByRole('button', { name: 'src/a.ts+3−1' }))
|
||||
expect(b.openResource).toHaveBeenLastCalledWith(LOCAL_ADDRESS, { params: { path: 'src/a.ts' } })
|
||||
fireEvent.click(within(card).getByRole('button', { name: en['changes.local.create'] }))
|
||||
expect(b.createChangeRequest).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('offers no change request for a checkout without a code host repository', () => {
|
||||
const b = tab(ready({ local, repository: null }))
|
||||
expect(b.view.container.querySelector('[data-forge-local]')).not.toBeNull()
|
||||
expect(b.view.queryByRole('button', { name: en['changes.local.create'] })).toBeNull()
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ label: 'a project with an open PR', linked: false, draft: false },
|
||||
{ label: 'a project with a draft PR', linked: false, draft: true },
|
||||
{ label: 'a linked worktree with an open PR', linked: true, draft: false },
|
||||
{ label: 'a linked worktree with a draft PR', linked: true, draft: true },
|
||||
])('keeps local and PR changes independent in $label', ({ linked, draft }) => {
|
||||
const request = entry(7, snapshot(7, { headBranch: 'main', draft }))
|
||||
const b = tab(ready({ local, changeRequests: [request] }, { linked }))
|
||||
expect(b.view.container.querySelector('[data-forge-local]')).not.toBeNull()
|
||||
expect(b.view.container.querySelector('[data-forge-change]')).not.toBeNull()
|
||||
expect(b.view.queryByRole('button', { name: en['changes.local.create'] })).toBeNull()
|
||||
|
||||
fireEvent.click(b.view.getByRole('button', { name: 'View the changes of this Session: 1 files, 3 lines added, 1 lines deleted' }))
|
||||
expect(b.openResource).toHaveBeenLastCalledWith(LOCAL_ADDRESS, undefined)
|
||||
fireEvent.click(b.view.getByRole('button', { name: 'View the changes of #7: 12 lines added, 3 lines deleted' }))
|
||||
expect(b.openResource).toHaveBeenLastCalledWith(changesAddress({ sessionId: SESSION, source: { kind: 'change', url: request.url } }), undefined)
|
||||
})
|
||||
|
||||
it.each([
|
||||
['before the branch scope is read', ready()],
|
||||
['while the branch scope changes nothing', ready({ local: { base: 'origin/main', files: [] } })],
|
||||
])('hides the card %s', (_label, state) => {
|
||||
const b = tab(state)
|
||||
expect(b.view.container.querySelector('[data-forge-local]')).toBeNull()
|
||||
})
|
||||
|
||||
it('keeps the card while the change request of the branch is closed or the HEAD is detached', () => {
|
||||
const closed = tab(ready({ local, changeRequests: [entry(7, snapshot(7, { headBranch: 'main', state: 'closed' }))] }))
|
||||
expect(closed.view.container.querySelector('[data-forge-local]')).not.toBeNull()
|
||||
cleanup()
|
||||
const detached = tab(ready({ local, changeRequests: [entry(7, snapshot(7, { headBranch: 'main' }))] }, { branch: null }))
|
||||
expect(detached.view.container.querySelector('[data-forge-local]')).not.toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('ForgeTab sign-in banner', () => {
|
||||
it('offers the GitHub CLI sign-in command for an unauthenticated GitHub host', () => {
|
||||
const b = tab(ready({ readiness: { state: 'unauthenticated', message: 'not logged in' } }))
|
||||
const banner = b.view.getByRole('status')
|
||||
expect(within(banner).getByText('Sign in to github.com to show change request status')).toBeTruthy()
|
||||
expect(within(banner).getByText('gh auth login --hostname github.com').tagName).toBe('CODE')
|
||||
expect(within(banner).queryByText('not logged in')).toBeNull()
|
||||
fireEvent.click(within(banner).getByRole('button', { name: en['signin.copy'] }))
|
||||
expect(b.copyText).toHaveBeenCalledWith('gh auth login --hostname github.com')
|
||||
})
|
||||
|
||||
it.each([
|
||||
['with its message', 'token expired', ['Sign in to gitlab.example.test to show change request status', 'token expired']],
|
||||
['without a message', null, ['Sign in to gitlab.example.test to show change request status']],
|
||||
])('asks to sign in to another code host %s', (_label, message, texts) => {
|
||||
const b = tab(ready({
|
||||
repository: { forge: 'gitlab', host: 'gitlab.example.test', owner: 'octo', name: 'demo' },
|
||||
readiness: { state: 'unauthenticated', message },
|
||||
}))
|
||||
const banner = b.view.getByRole('status')
|
||||
expect([...banner.children].map(child => child.textContent)).toEqual(texts)
|
||||
expect(within(banner).queryByRole('button')).toBeNull()
|
||||
})
|
||||
|
||||
it.each([
|
||||
['with its message', 'spawn gh ENOENT', 'Change requests on github.com could not be read: spawn gh ENOENT'],
|
||||
['without a message', null, 'Change requests on github.com could not be read: '],
|
||||
])('explains an unreachable host %s', (_label, message, text) => {
|
||||
const b = tab(ready({ readiness: { state: 'unavailable', message } }))
|
||||
expect(b.view.getByRole('status').textContent).toBe(text)
|
||||
})
|
||||
|
||||
it.each([
|
||||
['sign-in is unknown', ready({ readiness: null })],
|
||||
['the host is signed in', ready()],
|
||||
['no provider serves the repository', ready({ repository: null, readiness: { state: 'unauthenticated', message: 'not logged in' } })],
|
||||
])('shows no banner while %s', (_label, state) => {
|
||||
const b = tab(state)
|
||||
expect(b.view.queryByRole('status')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('ForgeTab change requests', () => {
|
||||
it('shows the empty state and refreshes on request', async () => {
|
||||
const b = tab(ready())
|
||||
expect(b.view.getByText('Change requests of this Session · 0')).toBeTruthy()
|
||||
expect(b.view.getByText(en['changes.empty'])).toBeTruthy()
|
||||
expect(b.view.getByText(en['changes.emptyHint'])).toBeTruthy()
|
||||
fireEvent.click(b.view.getByRole('button', { name: en.refresh }))
|
||||
expect(b.refresh).toHaveBeenCalledOnce()
|
||||
await act(async () => {})
|
||||
})
|
||||
|
||||
it('turns the refresh glyph until the refresh settles and its turn ends, ignoring clicks meanwhile', async () => {
|
||||
const pending = Promise.withResolvers<undefined>()
|
||||
const b = tab(ready())
|
||||
b.refresh.mockReturnValueOnce(pending.promise)
|
||||
const button = b.view.getByRole('button', { name: en.refresh })
|
||||
const glyph = button.firstElementChild
|
||||
if (!(glyph instanceof HTMLElement)) throw new Error('no refresh glyph')
|
||||
expect(glyph.hasAttribute('data-turning')).toBe(false)
|
||||
|
||||
fireEvent.click(button)
|
||||
animation(glyph, 'Start')
|
||||
fireEvent.click(button)
|
||||
expect(b.refresh).toHaveBeenCalledOnce()
|
||||
expect(button.getAttribute('aria-disabled')).toBe('true')
|
||||
animation(glyph, 'Iteration')
|
||||
expect(glyph.hasAttribute('data-turning')).toBe(true)
|
||||
|
||||
await act(async () => { pending.resolve(undefined) })
|
||||
expect(button.getAttribute('aria-disabled')).toBe('false')
|
||||
expect(glyph.hasAttribute('data-turning')).toBe(true)
|
||||
animation(glyph, 'Iteration')
|
||||
expect(glyph.hasAttribute('data-turning')).toBe(false)
|
||||
})
|
||||
|
||||
it.each([
|
||||
['open', snapshot(1)],
|
||||
['draft', snapshot(1, { draft: true })],
|
||||
])('expands the only %s change request by default', (_label, only) => {
|
||||
const b = tab(ready({ changeRequests: [entry(1, only), entry(2, snapshot(2, { state: 'merged' })), entry(3, null)] }))
|
||||
expect(b.view.getByText('Change requests of this Session · 3')).toBeTruthy()
|
||||
expect(expansion(b.view)).toEqual([true, false, false])
|
||||
})
|
||||
|
||||
it('collapses every card while several change requests are open', () => {
|
||||
const b = tab(ready({ changeRequests: [entry(1, snapshot(1)), entry(2, snapshot(2))] }))
|
||||
expect(expansion(b.view)).toEqual([false, false])
|
||||
})
|
||||
|
||||
it('keeps the cards the user expanded and collapsed across later updates', () => {
|
||||
const b = tab(ready({ changeRequests: [entry(1, snapshot(1)), entry(2, snapshot(2, { state: 'closed' }))] }))
|
||||
expect(expansion(b.view)).toEqual([true, false])
|
||||
fireEvent.click(b.view.getByRole('button', { name: 'Collapse #1' }))
|
||||
fireEvent.click(b.view.getByRole('button', { name: 'Expand #2' }))
|
||||
expect(expansion(b.view)).toEqual([false, true])
|
||||
|
||||
act(() => { b.panel.set({ state: ready({ changeRequests: [entry(1, snapshot(1, { title: 'Renamed' })), entry(2, snapshot(2, { state: 'closed' }))] }), disconnected: false }) })
|
||||
expect(expansion(b.view)).toEqual([false, true])
|
||||
})
|
||||
|
||||
it('wires the card actions to the tab actions', async () => {
|
||||
const value = entry(7, snapshot(7))
|
||||
const b = tab(ready({ changeRequests: [value, entry(8, { code: 'unavailable', message: 'down' })] }))
|
||||
const card = b.view.container.querySelector('[data-forge-change="https://github.com/octo/demo/pull/7"]')
|
||||
if (!(card instanceof HTMLElement)) throw new Error('no card')
|
||||
// The only open change request starts expanded.
|
||||
fireEvent.click(within(card).getByRole('button', { name: en['change.view'] }))
|
||||
fireEvent.click(within(card).getByRole('button', { name: en['change.copy'] }))
|
||||
fireEvent.click(within(card).getByRole('button', { name: 'Remove #7 from this Session' }))
|
||||
fireEvent.click(within(card).getByRole('button', { name: 'View the changes of #7: 12 lines added, 3 lines deleted' }))
|
||||
fireEvent.click(b.view.getByRole('button', { name: en.retry }))
|
||||
expect(b.openResource).toHaveBeenCalledWith(
|
||||
changesAddress({ sessionId: SESSION, source: { kind: 'change', url: 'https://github.com/octo/demo/pull/7' } }), undefined,
|
||||
)
|
||||
expect(b.openLink).toHaveBeenCalledWith('https://github.com/octo/demo/pull/7')
|
||||
expect(b.copyText).toHaveBeenCalledWith('https://github.com/octo/demo/pull/7')
|
||||
expect(b.remove).toHaveBeenCalledWith(value)
|
||||
expect(b.refresh).toHaveBeenCalledOnce()
|
||||
await act(async () => {})
|
||||
})
|
||||
|
||||
it('wires ready for review and merge to the tab actions', async () => {
|
||||
const draft = entry(7, snapshot(7, { draft: true }))
|
||||
const mergeable = entry(8, snapshot(8, { mergeReady: true, headSha: 'b'.repeat(40) }))
|
||||
const b = tab(ready({ changeRequests: [draft, mergeable] }))
|
||||
// Two open change requests both start collapsed.
|
||||
fireEvent.click(b.view.getByRole('button', { name: 'Expand #7' }))
|
||||
fireEvent.click(b.view.getByRole('button', { name: 'Expand #8' }))
|
||||
|
||||
await act(async () => {
|
||||
fireEvent.click(b.view.getByRole('button', { name: en['change.markReady'] }))
|
||||
})
|
||||
fireEvent.click(b.view.getByRole('button', { name: en['change.merge'] }))
|
||||
await act(async () => {
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: en['change.mergeConfirm'] }))
|
||||
})
|
||||
expect(b.markReady).toHaveBeenCalledWith(draft)
|
||||
expect(b.merge).toHaveBeenCalledWith(mergeable, { method: 'squash', headSha: 'b'.repeat(40) })
|
||||
})
|
||||
|
||||
it('dates a finished change request from the current time', () => {
|
||||
vi.useFakeTimers({ toFake: ['Date'], now: Date.parse('2026-10-09T12:00:00Z') })
|
||||
try {
|
||||
const b = tab(ready({ changeRequests: [entry(1, snapshot(1, { state: 'merged', closedAt: '2026-10-09T11:00:00Z' }))] }))
|
||||
expect(b.view.getByText('Merged into main · 1 h ago')).toBeTruthy()
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('ForgeTab visibility', () => {
|
||||
it('reports the tab visibility as it changes and hidden once unmounted', () => {
|
||||
const b = tab(ready())
|
||||
expect(b.reportVisible.mock.calls).toEqual([[true]])
|
||||
|
||||
act(() => { b.visibility.set(false) })
|
||||
act(() => { b.visibility.set(true) })
|
||||
expect(b.reportVisible.mock.calls).toEqual([[true], [false], [true]])
|
||||
|
||||
b.view.unmount()
|
||||
expect(b.reportVisible.mock.calls).toEqual([[true], [false], [true], [false]])
|
||||
})
|
||||
|
||||
it('reports a tab that mounts hidden, also before the first state', () => {
|
||||
const b = tab(null, { visible: false })
|
||||
expect(b.reportVisible.mock.calls).toEqual([[false]])
|
||||
})
|
||||
})
|
||||
@@ -14,14 +14,18 @@ import { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import { RemoteError, type RemoteResult, type TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { ActionToast } from '../src/client/ActionToast.tsx'
|
||||
import { CHANGES_ID, CHANGES_KIND } from '../src/client/changes-address.ts'
|
||||
import { AttentionIndicator, type AttentionIndicatorInjected } from '../src/client/AttentionIndicator.tsx'
|
||||
import { CHANGES_ID, CHANGES_KIND, changesAddress } from '../src/client/changes-address.ts'
|
||||
import {
|
||||
ChangeRequestsActions, ChangeRequestsSection, type ChangeRequestsActionsInjected, type ChangeRequestsSectionInjected,
|
||||
} from '../src/client/ChangeRequestsSection.tsx'
|
||||
import { ChangesTab, type ChangesTabInjected } from '../src/client/ChangesTab.tsx'
|
||||
import { ChangesTabTitle } from '../src/client/ChangesTabTitle.tsx'
|
||||
import { ForgeTab, type ForgeTabInjected } from '../src/client/ForgeTab.tsx'
|
||||
import { ForgeTabTitle } from '../src/client/ForgeTabTitle.tsx'
|
||||
import { HeaderButton, type HeaderButtonInjected } from '../src/client/HeaderButton.tsx'
|
||||
import {
|
||||
CheckoutRow, EnvironmentActions, LocalChangesRow, type CheckoutRowInjected, type EnvironmentActionsInjected, type LocalChangesRowInjected,
|
||||
} from '../src/client/EnvironmentRows.tsx'
|
||||
import { en, NS, zh } from '../src/client/locales.ts'
|
||||
import { inject, mountForgePanel, TAB_ID, TAB_KIND } from '../src/client/mount.ts'
|
||||
import { inject, mountForgePanel } from '../src/client/mount.ts'
|
||||
import type { SessionListInjected } from '../src/client/session-list.ts'
|
||||
import { SessionHoverForge } from '../src/client/SessionHoverForge.tsx'
|
||||
import { SessionRowForge } from '../src/client/SessionRowForge.tsx'
|
||||
@@ -85,12 +89,24 @@ const REFUSED = {
|
||||
refused: { ok: false, error: new RemoteError('forgePanel/action-failed', 'Pull Request is not mergeable', {}) },
|
||||
} satisfies Record<string, RemoteResult<never>>
|
||||
|
||||
function isTabFace(value: Record<string, unknown>): value is Record<string, unknown> & ForgeTabInjected {
|
||||
return typeof value.reportVisible === 'function' && typeof value.copyText === 'function'
|
||||
function isSectionFace(value: Record<string, unknown>): value is Record<string, unknown> & ChangeRequestsSectionInjected {
|
||||
return typeof value.merge === 'function' && typeof value.viewChanges === 'function'
|
||||
}
|
||||
|
||||
function isHeaderFace(value: Record<string, unknown>): value is Record<string, unknown> & HeaderButtonInjected {
|
||||
return typeof value.toggle === 'function' && typeof value.hooks === 'object'
|
||||
function isActionsFace(value: Record<string, unknown>): value is Record<string, unknown> & ChangeRequestsActionsInjected {
|
||||
return typeof value.refresh === 'function' && typeof value.hooks === 'object'
|
||||
}
|
||||
|
||||
function isCheckoutFace(value: Record<string, unknown>): value is Record<string, unknown> & CheckoutRowInjected {
|
||||
return typeof value.restore === 'function' && typeof value.hooks === 'object' && value.hooks !== null && 'host' in value.hooks
|
||||
}
|
||||
|
||||
function isLocalFace(value: Record<string, unknown>): value is Record<string, unknown> & LocalChangesRowInjected {
|
||||
return typeof value.viewLocalChanges === 'function' && typeof value.createChangeRequest === 'function'
|
||||
}
|
||||
|
||||
function isAttentionFace(value: Record<string, unknown>): value is Record<string, unknown> & AttentionIndicatorInjected {
|
||||
return typeof value.hooks === 'object' && value.hooks !== null && 'panel' in value.hooks
|
||||
}
|
||||
|
||||
function isWorktreeFace(value: Record<string, unknown>): value is Record<string, unknown> & WorktreeToggleInjected {
|
||||
@@ -174,8 +190,7 @@ async function base() {
|
||||
const unregisterTab = vi.fn()
|
||||
const sidebarRightTabs = { register: vi.fn((_type: SidebarRightTabDefinition) => unregisterTab) }
|
||||
ctx.provide('sidebarRightTabs', sidebarRightTabs)
|
||||
const sidebarRight = { openTab: vi.fn(), toggleExpanded: vi.fn(), hide: vi.fn(),
|
||||
tabsIn: vi.fn(() => [{ id: 'forge-tab' as TabId, kind: TAB_KIND }]) }
|
||||
const sidebarRight = { openResourceIn: vi.fn() }
|
||||
const scopes = new Map<SessionId, ReturnType<Context['plugin']>>()
|
||||
const sessions = { scope: vi.fn<(id: SessionId) => Context | undefined>((id) => {
|
||||
let fiber = scopes.get(id)
|
||||
@@ -192,6 +207,10 @@ async function base() {
|
||||
'sidebar.right.pane.tab.title': { kind: 'keyed', scope: 'session' },
|
||||
'conversation.session.header.utilities': { kind: 'list', scope: 'session' },
|
||||
'conversation.session.header.actions': { kind: 'list', scope: 'session' },
|
||||
'conversation.session.panel.section': { kind: 'list', scope: 'session' },
|
||||
'conversation.session.panel.section.actions': { kind: 'keyed', scope: 'session' },
|
||||
'conversation.session.panel.environment.row': { kind: 'list', scope: 'session' },
|
||||
'conversation.session.panel.indicator': { kind: 'list', scope: 'session', inline: true },
|
||||
'conversation.hero.options': { kind: 'list', scope: 'session' },
|
||||
'conversation.input.dock': { kind: 'list', scope: 'session' },
|
||||
'conversation.input.left': { kind: 'list', scope: 'session' },
|
||||
@@ -210,19 +229,50 @@ async function fixture() {
|
||||
assert(dispose !== undefined)
|
||||
const entry = (slot: Parameters<typeof b.ctx.slots.entries>[0], component: unknown) =>
|
||||
b.ctx.slots.entries(slot).find(candidate => candidate.component === component)
|
||||
const tabInject = entry('sidebar.right.pane.tab', ForgeTab)?.inject
|
||||
const sectionInject = entry('conversation.session.panel.section', ChangeRequestsSection)?.inject
|
||||
const actionsInject = entry('conversation.session.panel.section.actions', ChangeRequestsActions)?.inject
|
||||
const environmentActionsInject = entry('conversation.session.panel.section.actions', EnvironmentActions)?.inject
|
||||
const checkoutInject = entry('conversation.session.panel.environment.row', CheckoutRow)?.inject
|
||||
const localInject = entry('conversation.session.panel.environment.row', LocalChangesRow)?.inject
|
||||
const attentionInject = entry('conversation.session.panel.indicator', AttentionIndicator)?.inject
|
||||
const changesInject = entry('sidebar.right.pane.tab', ChangesTab)?.inject
|
||||
const headerInject = entry('conversation.session.header.utilities', HeaderButton)?.inject
|
||||
const worktreeInject = entry('conversation.hero.options', WorktreeToggle)?.inject
|
||||
const progressInject = entry('conversation.input.dock', WorktreeProgress)?.inject
|
||||
const toastInject = entry('shell.overlay', ActionToast)?.inject
|
||||
const rowInject = entry('sidebar.session.row.trailing', SessionRowForge)?.inject
|
||||
const hoverInject = entry('sidebar.session.row.hover', SessionHoverForge)?.inject
|
||||
assert(tabInject !== undefined && headerInject !== undefined && worktreeInject !== undefined && toastInject !== undefined)
|
||||
assert(sectionInject !== undefined && actionsInject !== undefined && checkoutInject !== undefined && localInject !== undefined)
|
||||
assert(attentionInject !== undefined && environmentActionsInject !== undefined)
|
||||
assert(worktreeInject !== undefined && toastInject !== undefined)
|
||||
assert(progressInject !== undefined && changesInject !== undefined && rowInject !== undefined && hoverInject !== undefined)
|
||||
const tab = (sessionId: SessionId): ForgeTabInjected => {
|
||||
const value = tabInject(sessionId as never)
|
||||
assert(isTabFace(value))
|
||||
const section = (sessionId: SessionId): ChangeRequestsSectionInjected => {
|
||||
const value = sectionInject(sessionId as never)
|
||||
assert(isSectionFace(value))
|
||||
return value
|
||||
}
|
||||
const actions = (sessionId: SessionId): ChangeRequestsActionsInjected => {
|
||||
const value = actionsInject(sessionId as never)
|
||||
assert(isActionsFace(value))
|
||||
return value
|
||||
}
|
||||
const environmentActions = (sessionId: SessionId): EnvironmentActionsInjected => {
|
||||
const value = environmentActionsInject(sessionId as never)
|
||||
assert(isActionsFace(value))
|
||||
return value
|
||||
}
|
||||
const checkout = (sessionId: SessionId): CheckoutRowInjected => {
|
||||
const value = checkoutInject(sessionId as never)
|
||||
assert(isCheckoutFace(value))
|
||||
return value
|
||||
}
|
||||
const local = (sessionId: SessionId): LocalChangesRowInjected => {
|
||||
const value = localInject(sessionId as never)
|
||||
assert(isLocalFace(value))
|
||||
return value
|
||||
}
|
||||
const attention = (sessionId: SessionId): AttentionIndicatorInjected => {
|
||||
const value = attentionInject(sessionId as never)
|
||||
assert(isAttentionFace(value))
|
||||
return value
|
||||
}
|
||||
const changes = (sessionId: SessionId): ChangesTabInjected => {
|
||||
@@ -230,11 +280,6 @@ async function fixture() {
|
||||
assert(isChangesFace(value))
|
||||
return value
|
||||
}
|
||||
const header = (sessionId: SessionId): HeaderButtonInjected => {
|
||||
const value = headerInject(sessionId as never)
|
||||
assert(isHeaderFace(value))
|
||||
return value
|
||||
}
|
||||
const worktree = (sessionId: SessionId): WorktreeToggleInjected => {
|
||||
const value = worktreeInject(sessionId as never)
|
||||
assert(isWorktreeFace(value))
|
||||
@@ -256,7 +301,10 @@ async function fixture() {
|
||||
assert(isListFace(value))
|
||||
return value
|
||||
}
|
||||
return { ...b, dispose, entry, tab, changes, header, worktree, progress, toast, notice, list }
|
||||
return {
|
||||
...b, dispose, entry, section, actions, environmentActions, checkout, local, attention, changes, worktree, progress,
|
||||
toast, notice, list,
|
||||
}
|
||||
}
|
||||
|
||||
describe('mountForgePanel registration', () => {
|
||||
@@ -264,33 +312,35 @@ describe('mountForgePanel registration', () => {
|
||||
const f = await fixture()
|
||||
const signal = new AbortController().signal
|
||||
const url = 'https://github.com/octo/demo/pull/7'
|
||||
expect(await f.tab(S1).readChecks(url, 'a'.repeat(40), signal)).toEqual(snapshot(7))
|
||||
expect(await f.section(S1).readChecks(url, 'a'.repeat(40), signal)).toEqual(snapshot(7))
|
||||
expect(f.forgePanel.changeRequestChecks).toHaveBeenCalledWith(S1, url, 'a'.repeat(40), signal)
|
||||
f.forgePanel.changeRequestChecks.mockResolvedValueOnce(REFUSED.failed)
|
||||
await expect(f.tab(S1).readChecks(url, 'a'.repeat(40), signal)).rejects.toThrow()
|
||||
await expect(f.section(S1).readChecks(url, 'a'.repeat(40), signal)).rejects.toThrow()
|
||||
})
|
||||
|
||||
it('declares the browser services it needs', () => {
|
||||
expect(inject).toEqual(['remote', 'slots', 'locale', 'sidebarRightTabs', 'sidebarRight', 'sessions'])
|
||||
})
|
||||
|
||||
it('registers the tab types, their bodies and titles, the header button, the worktree option and card, and the toast', async () => {
|
||||
it('registers the Session panel entries, the changes tab, the worktree option and card, and the toast', async () => {
|
||||
const f = await fixture()
|
||||
expect(f.sidebarRightTabs.register).toHaveBeenCalledTimes(2)
|
||||
const type = f.sidebarRightTabs.register.mock.calls[0]?.[0]
|
||||
expect(type).toMatchObject({ id: TAB_ID, kind: TAB_KIND })
|
||||
expect([en['tab.title'], zh['tab.title']]).toContain(type?.title('sidebar://forge-panel'))
|
||||
expect(type?.guide).toHaveLength(1)
|
||||
expect([en['guide.title'], zh['guide.title']]).toContain(type?.guide?.[0]?.title())
|
||||
expect([en['guide.description'], zh['guide.description']]).toContain(type?.guide?.[0]?.description?.())
|
||||
expect(f.sidebarRightTabs.register.mock.calls[1]?.[0]).toMatchObject({ id: CHANGES_ID, kind: CHANGES_KIND })
|
||||
expect(f.entry('sidebar.right.pane.tab', ForgeTab)).toMatchObject({ options: { key: TAB_ID }, locale: NS })
|
||||
expect(f.entry('sidebar.right.pane.tab.title', ForgeTabTitle)).toMatchObject({ options: { key: TAB_ID }, locale: NS })
|
||||
expect(f.sidebarRightTabs.register).toHaveBeenCalledOnce()
|
||||
expect(f.sidebarRightTabs.register.mock.calls[0]?.[0]).toMatchObject({ id: CHANGES_ID, kind: CHANGES_KIND })
|
||||
const section = f.entry('conversation.session.panel.section', ChangeRequestsSection)
|
||||
expect(section).toMatchObject({ options: { id: 'change-requests', order: 100 }, locale: NS })
|
||||
const label = section?.options.label
|
||||
expect([en['tab.title'], zh['tab.title']]).toContain(typeof label === 'function' ? label() : label)
|
||||
expect(f.entry('conversation.session.panel.section.actions', ChangeRequestsActions))
|
||||
.toMatchObject({ options: { key: 'change-requests' }, locale: NS })
|
||||
expect(f.entry('conversation.session.panel.section.actions', EnvironmentActions)).toMatchObject({ options: { key: 'environment' }, locale: NS })
|
||||
expect(f.entry('conversation.session.panel.environment.row', CheckoutRow)).toMatchObject({ options: { id: 'forge.checkout', order: 20 }, locale: NS })
|
||||
expect(f.entry('conversation.session.panel.environment.row', LocalChangesRow)).toMatchObject({ options: { id: 'forge.local', order: 30 }, locale: NS })
|
||||
expect(f.entry('conversation.session.panel.indicator', AttentionIndicator)).toMatchObject({ options: { id: 'forge.attention' }, locale: NS })
|
||||
expect(f.entry('sidebar.right.pane.tab', ChangesTab)).toMatchObject({ options: { key: CHANGES_ID }, locale: NS })
|
||||
expect(f.entry('sidebar.right.pane.tab', ChangesTab)?.store).toBeDefined()
|
||||
expect(f.entry('sidebar.right.pane.tab.title', ChangesTabTitle)).toMatchObject({ options: { key: CHANGES_ID }, locale: NS })
|
||||
expect(f.entry('conversation.session.header.utilities', HeaderButton)).toMatchObject({ options: { id: 'forge-panel', order: -8 }, locale: NS })
|
||||
// The branch is named in the tab and the Session list, not beside the Session title.
|
||||
// The Session panel replaces the header button, and the branch is named in the panel and the Session list.
|
||||
expect(f.ctx.slots.entries('conversation.session.header.utilities')).toEqual([])
|
||||
expect(f.ctx.slots.entries('conversation.session.header.actions')).toEqual([])
|
||||
expect(f.entry('conversation.hero.options', WorktreeToggle)).toMatchObject({ options: { id: 'forge-panel.worktree' }, locale: NS })
|
||||
expect(f.entry('conversation.input.dock', WorktreeProgress)).toMatchObject({ options: { id: 'forge-panel.worktree', order: 5 }, locale: NS })
|
||||
@@ -304,8 +354,8 @@ describe('mountForgePanel registration', () => {
|
||||
|
||||
it('withdraws every entry, closes the streams, and unmounts the Remote on unload', async () => {
|
||||
const f = await fixture()
|
||||
f.tab(S1).hooks.panel.subscribe(() => {})
|
||||
f.header(S2)
|
||||
f.section(S1).hooks.panel.subscribe(() => {})
|
||||
f.attention(S2)
|
||||
f.list('row').hooks.states.subscribe(() => {})
|
||||
expect(f.streams).toHaveLength(1)
|
||||
expect(f.stateStreams).toHaveLength(1)
|
||||
@@ -319,11 +369,14 @@ describe('mountForgePanel registration', () => {
|
||||
expect(f.unregisterTab).toHaveBeenCalled()
|
||||
expect(f.unmount).toHaveBeenCalledOnce()
|
||||
for (const [slot, component] of [
|
||||
['sidebar.right.pane.tab', ForgeTab],
|
||||
['sidebar.right.pane.tab.title', ForgeTabTitle],
|
||||
['conversation.session.panel.section', ChangeRequestsSection],
|
||||
['conversation.session.panel.section.actions', ChangeRequestsActions],
|
||||
['conversation.session.panel.section.actions', EnvironmentActions],
|
||||
['conversation.session.panel.environment.row', CheckoutRow],
|
||||
['conversation.session.panel.environment.row', LocalChangesRow],
|
||||
['conversation.session.panel.indicator', AttentionIndicator],
|
||||
['sidebar.right.pane.tab', ChangesTab],
|
||||
['sidebar.right.pane.tab.title', ChangesTabTitle],
|
||||
['conversation.session.header.utilities', HeaderButton],
|
||||
['conversation.hero.options', WorktreeToggle],
|
||||
['conversation.input.dock', WorktreeProgress],
|
||||
['shell.overlay', ActionToast],
|
||||
@@ -337,7 +390,12 @@ describe('mountForgePanel registration', () => {
|
||||
|
||||
it('unmounts the Remote when the UI registration fails', async () => {
|
||||
const b = await base()
|
||||
vi.spyOn(b.ctx.slots, 'inject').mockImplementationOnce(() => { throw new Error('slot failed') })
|
||||
const original = b.ctx.slots.inject.bind(b.ctx.slots)
|
||||
// Fail after the changes tab type is registered, so its registration must be withdrawn.
|
||||
vi.spyOn(b.ctx.slots, 'inject').mockImplementation((name, ...rest) => {
|
||||
if (name === 'shell.overlay') throw new Error('slot failed')
|
||||
return original(name, ...rest)
|
||||
})
|
||||
const fiber = b.ctx.plugin({ inject: [...inject], apply: (plugin: Context) => mountForgePanel(plugin, REMOTE) })
|
||||
await expect(fiber).rejects.toThrow('slot failed')
|
||||
expect(b.unmount).toHaveBeenCalledOnce()
|
||||
@@ -368,13 +426,14 @@ describe('mountForgePanel Session list', () => {
|
||||
})
|
||||
|
||||
describe('mountForgePanel Session stores', () => {
|
||||
it('shares one panel stream per Session between the tab, the header button, the worktree option, and the worktree card', async () => {
|
||||
it('shares one panel stream per Session between the Session panel entries, the worktree option, and the worktree card', async () => {
|
||||
const f = await fixture()
|
||||
const tab = f.tab(S1)
|
||||
expect(f.header(S1).hooks.panel).toBe(tab.hooks.panel)
|
||||
expect(f.worktree(S1).hooks.panel).toBe(tab.hooks.panel)
|
||||
expect(f.progress(S1).hooks.panel).toBe(tab.hooks.panel)
|
||||
expect(f.tab(S2).hooks.panel).not.toBe(tab.hooks.panel)
|
||||
const tab = f.section(S1)
|
||||
const faces = [f.actions(S1), f.environmentActions(S1), f.checkout(S1), f.local(S1), f.attention(S1), f.worktree(S1), f.progress(S1)]
|
||||
for (const face of faces) {
|
||||
expect(face.hooks.panel).toBe(tab.hooks.panel)
|
||||
}
|
||||
expect(f.section(S2).hooks.panel).not.toBe(tab.hooks.panel)
|
||||
expect(f.forgePanel.follow).not.toHaveBeenCalled()
|
||||
|
||||
const seen: unknown[] = []
|
||||
@@ -395,8 +454,8 @@ describe('mountForgePanel Session stores', () => {
|
||||
|
||||
it('shares the Host facts between Sessions and reads them again after each reconnect', async () => {
|
||||
const f = await fixture()
|
||||
const host = f.tab(S1).hooks.host
|
||||
expect(f.tab(S2).hooks.host).toBe(host)
|
||||
const host = f.checkout(S1).hooks.host
|
||||
expect(f.checkout(S2).hooks.host).toBe(host)
|
||||
expect(host.getSnapshot()).toEqual({ home: '/home/octo', isLoopback: true })
|
||||
const listener = vi.fn()
|
||||
const unsubscribe = host.subscribe(listener)
|
||||
@@ -413,18 +472,18 @@ describe('mountForgePanel Session stores', () => {
|
||||
|
||||
it('releases a closed Session and recreates its shared state on reopen', async () => {
|
||||
const f = await fixture()
|
||||
const first = f.tab(S1)
|
||||
const first = f.section(S1)
|
||||
first.hooks.panel.subscribe(() => {})
|
||||
expect(f.header(S1).hooks.panel).toBe(first.hooks.panel)
|
||||
expect(f.attention(S1).hooks.panel).toBe(first.hooks.panel)
|
||||
f.streams[0]!.push(ready({ changeRequests: [entry(1, snapshot(1))] }))
|
||||
await settle()
|
||||
await f.scopes.get(S1)!.dispose()
|
||||
f.scopes.delete(S1)
|
||||
expect(f.streams[0]!.signal.aborted).toBe(true)
|
||||
const next = f.tab(S1)
|
||||
const next = f.section(S1)
|
||||
expect(next.hooks.panel).not.toBe(first.hooks.panel)
|
||||
expect(next.hooks.panel.getSnapshot().state).toBeNull()
|
||||
expect(f.header(S1).hooks.panel).toBe(next.hooks.panel)
|
||||
expect(f.attention(S1).hooks.panel).toBe(next.hooks.panel)
|
||||
next.hooks.panel.subscribe(() => {})
|
||||
expect(f.streams).toHaveLength(2)
|
||||
await f.dispose()
|
||||
@@ -432,55 +491,27 @@ describe('mountForgePanel Session stores', () => {
|
||||
|
||||
it('publishes the selected language and refuses state for a released Session', async () => {
|
||||
const f = await fixture()
|
||||
const locale = f.tab(S1).hooks.locale
|
||||
const locale = f.section(S1).hooks.locale
|
||||
const changed = vi.fn()
|
||||
const unsubscribe = locale.subscribe(changed)
|
||||
f.ctx.locale.addLanguage({ id: 'de', label: 'Deutsch', fallback: 'en' })
|
||||
f.ctx.locale.setLocale('de')
|
||||
expect(locale.getSnapshot()).toBe('de')
|
||||
expect(f.ctx.locale.bind(NS)('header.label')).toBe('Änderungsanfragen dieser Sitzung')
|
||||
expect(f.ctx.locale.bind(NS)('tab.title')).toBe('Änderungsanfragen')
|
||||
expect(f.ctx.locale.bind(NS)('change.mergeTitle', { name: '#7', base: 'main' })).toBe('#7 in main zusammenführen')
|
||||
expect(changed).toHaveBeenCalled()
|
||||
unsubscribe()
|
||||
f.sessions.scope.mockReturnValue(undefined)
|
||||
expect(() => f.tab(S2)).toThrow('is not retained')
|
||||
await f.dispose()
|
||||
})
|
||||
|
||||
it('shares the tab visibility of a Session with its header entry', async () => {
|
||||
const f = await fixture()
|
||||
const visible = f.header(S1).hooks.visible
|
||||
const listener = vi.fn()
|
||||
visible.subscribe(listener)
|
||||
expect(visible.getSnapshot()).toBe(false)
|
||||
|
||||
f.tab(S1).reportVisible(true)
|
||||
expect(visible.getSnapshot()).toBe(true)
|
||||
expect(listener).toHaveBeenCalledOnce()
|
||||
expect(f.header(S2).hooks.visible.getSnapshot()).toBe(false)
|
||||
await f.dispose()
|
||||
})
|
||||
|
||||
it('reveals the hidden tab from the header entry and collapses the sidebar showing it', async () => {
|
||||
const f = await fixture()
|
||||
f.header(S1).toggle(false)
|
||||
expect(f.sidebarRight.openTab).toHaveBeenCalledWith(TAB_KIND)
|
||||
expect(f.sidebarRight.toggleExpanded).not.toHaveBeenCalled()
|
||||
f.header(S1).toggle(true)
|
||||
expect(f.sidebarRight.hide).toHaveBeenCalledWith('forge-tab')
|
||||
expect(f.sidebarRight.openTab).toHaveBeenCalledOnce()
|
||||
f.sidebarRight.tabsIn.mockReturnValue([])
|
||||
f.header(S1).toggle(true)
|
||||
expect(f.sidebarRight.hide).toHaveBeenCalledOnce()
|
||||
expect(() => f.section(S2)).toThrow('is not retained')
|
||||
await f.dispose()
|
||||
})
|
||||
})
|
||||
|
||||
describe('mountForgePanel tab actions', () => {
|
||||
describe('mountForgePanel Session panel actions', () => {
|
||||
it('opens links outside the app', async () => {
|
||||
const f = await fixture()
|
||||
const open = vi.spyOn(window, 'open').mockReturnValue(null)
|
||||
f.tab(S1).openLink('https://github.com/octo/demo/pull/1')
|
||||
f.section(S1).openLink('https://github.com/octo/demo/pull/1')
|
||||
expect(open).toHaveBeenCalledWith('https://github.com/octo/demo/pull/1', '_blank', 'noopener,noreferrer')
|
||||
await f.dispose()
|
||||
})
|
||||
@@ -493,7 +524,7 @@ describe('mountForgePanel tab actions', () => {
|
||||
const writeText = vi.fn(async (_text: string) => { await write() })
|
||||
Object.defineProperty(navigator, 'clipboard', { configurable: true, value: { writeText } })
|
||||
|
||||
f.tab(S1).copyText('gh auth login --hostname github.com')
|
||||
f.section(S1).copyText('gh auth login --hostname github.com')
|
||||
await settle()
|
||||
|
||||
expect(writeText).toHaveBeenCalledWith('gh auth login --hostname github.com')
|
||||
@@ -501,40 +532,40 @@ describe('mountForgePanel tab actions', () => {
|
||||
await f.dispose()
|
||||
})
|
||||
|
||||
it('copies a checkout path to the clipboard and confirms it', async () => {
|
||||
it('opens the changes of a change request and of the branch in the right sidebar of the Session', async () => {
|
||||
const f = await fixture()
|
||||
const writeText = vi.fn(async (_text: string) => {})
|
||||
Object.defineProperty(navigator, 'clipboard', { configurable: true, value: { writeText } })
|
||||
|
||||
f.tab(S1).copyPath('/work/repo-dsh')
|
||||
await settle()
|
||||
|
||||
expect(writeText).toHaveBeenCalledWith('/work/repo-dsh')
|
||||
expect(f.notice()).toMatchObject({ key: 'toast.pathCopied', tone: 'success', params: {}, undo: undefined })
|
||||
const url = 'https://github.com/octo/demo/pull/7'
|
||||
f.section(S1).viewChanges(entry(7, snapshot(7)))
|
||||
expect(f.sidebarRight.openResourceIn).toHaveBeenCalledWith(S1, changesAddress({ sessionId: S1, source: { kind: 'change', url } }))
|
||||
f.local(S1).viewLocalChanges()
|
||||
expect(f.sidebarRight.openResourceIn).toHaveBeenLastCalledWith(S1, changesAddress({ sessionId: S1, source: { kind: 'local' } }))
|
||||
await f.dispose()
|
||||
})
|
||||
|
||||
it('refreshes through the Remote and reports only a failure', async () => {
|
||||
it('refreshes through the Remote from the section and both title controls, and reports only a failure', async () => {
|
||||
const f = await fixture()
|
||||
await f.tab(S1).refresh()
|
||||
await f.section(S1).refresh()
|
||||
await f.actions(S1).refresh()
|
||||
await f.environmentActions(S1).refresh()
|
||||
expect(f.forgePanel.refresh).toHaveBeenCalledTimes(3)
|
||||
expect(f.forgePanel.refresh).toHaveBeenCalledWith(S1)
|
||||
expect(f.notice()).toBeNull()
|
||||
|
||||
f.forgePanel.refresh.mockResolvedValueOnce(REFUSED.failed)
|
||||
await f.tab(S1).refresh()
|
||||
await f.actions(S1).refresh()
|
||||
expect(f.notice()).toMatchObject({ key: 'toast.refreshFailed', tone: 'failure' })
|
||||
await f.dispose()
|
||||
})
|
||||
|
||||
it('restores a removed worktree, confirming it or reporting why it failed until the notice is dismissed', async () => {
|
||||
const f = await fixture()
|
||||
f.tab(S1).restore()
|
||||
f.checkout(S1).restore()
|
||||
await settle()
|
||||
expect(f.forgePanel.restoreWorktree).toHaveBeenCalledWith(S1)
|
||||
expect(f.notice()).toMatchObject({ key: 'toast.restored', tone: 'success', seq: 1 })
|
||||
|
||||
f.forgePanel.restoreWorktree.mockResolvedValueOnce(REFUSED.restore)
|
||||
f.tab(S1).restore()
|
||||
f.checkout(S1).restore()
|
||||
await settle()
|
||||
expect(f.notice()).toMatchObject({
|
||||
key: 'toast.restoreFailed', tone: 'failure', seq: 2, params: { message: 'fatal: \'/work/repo-dsh\' already exists' },
|
||||
@@ -549,7 +580,7 @@ describe('mountForgePanel removal', () => {
|
||||
it('removes a change request and offers to restore it', async () => {
|
||||
const f = await fixture()
|
||||
const value = entry(7, snapshot(7))
|
||||
f.tab(S1).remove(value)
|
||||
f.section(S1).remove(value)
|
||||
await settle()
|
||||
expect(f.forgePanel.dismiss).toHaveBeenCalledWith(S1, 'https://github.com/octo/demo/pull/7')
|
||||
const removed = f.notice()
|
||||
@@ -574,7 +605,7 @@ describe('mountForgePanel removal', () => {
|
||||
['the number in its URL', unserved('https://example.test/review/17'), '#17'],
|
||||
])('names a removed unserved change request by %s, without undo', async (_label, value, name) => {
|
||||
const f = await fixture()
|
||||
f.tab(S1).remove(value)
|
||||
f.section(S1).remove(value)
|
||||
await settle()
|
||||
expect(f.notice()).toMatchObject({ key: 'toast.removed', tone: 'success', params: { name }, undo: undefined })
|
||||
await f.dispose()
|
||||
@@ -583,7 +614,7 @@ describe('mountForgePanel removal', () => {
|
||||
it('reports a failed removal without offering undo', async () => {
|
||||
const f = await fixture()
|
||||
f.forgePanel.dismiss.mockResolvedValueOnce(REFUSED.failed)
|
||||
f.tab(S1).remove(entry(7, snapshot(7)))
|
||||
f.section(S1).remove(entry(7, snapshot(7)))
|
||||
await settle()
|
||||
expect(f.notice()).toMatchObject({ key: 'toast.removeFailed', tone: 'failure', params: {}, undo: undefined })
|
||||
await f.dispose()
|
||||
@@ -597,7 +628,7 @@ describe('mountForgePanel change request actions', () => {
|
||||
])('marks a draft ready through the Remote and %s', async (_label, result, notice) => {
|
||||
const f = await fixture()
|
||||
f.forgePanel.markReady.mockResolvedValueOnce(result)
|
||||
await f.tab(S1).markReady(entry(7, snapshot(7, { draft: true })))
|
||||
await f.section(S1).markReady(entry(7, snapshot(7, { draft: true })))
|
||||
expect(f.forgePanel.markReady).toHaveBeenCalledWith(S1, 'https://github.com/octo/demo/pull/7')
|
||||
expect(f.notice()).toMatchObject(notice)
|
||||
await f.dispose()
|
||||
@@ -610,7 +641,7 @@ describe('mountForgePanel change request actions', () => {
|
||||
])('merges through the Remote with the confirmed head and %s', async (_label, result, notice) => {
|
||||
const f = await fixture()
|
||||
f.forgePanel.merge.mockResolvedValueOnce(result)
|
||||
await f.tab(S1).merge(entry(7, snapshot(7)), { method: 'rebase', headSha: 'b'.repeat(40) })
|
||||
await f.section(S1).merge(entry(7, snapshot(7)), { method: 'rebase', headSha: 'b'.repeat(40) })
|
||||
expect(f.forgePanel.merge).toHaveBeenCalledWith(S1, 'https://github.com/octo/demo/pull/7', 'rebase', 'b'.repeat(40))
|
||||
expect(f.notice()).toMatchObject(notice)
|
||||
await f.dispose()
|
||||
@@ -784,7 +815,7 @@ describe('mountForgePanel changes view', () => {
|
||||
it('reads the changes of the Session through the Remote and shares its panel stream', async () => {
|
||||
const f = await fixture()
|
||||
const view = f.changes(S1)
|
||||
expect(view.keyedHooks.panel('visible')).toBe(f.tab(S1).hooks.panel)
|
||||
expect(view.keyedHooks.panel('visible')).toBe(f.section(S1).hooks.panel)
|
||||
expect(view.keyedHooks.panel('inactive')).toBeUndefined()
|
||||
const signal = new AbortController().signal
|
||||
expect(await view.localDiff({ kind: 'staged' }, signal)).toEqual({ ok: true, value: LOCAL })
|
||||
@@ -838,7 +869,7 @@ describe('mountForgePanel changes view', () => {
|
||||
expect(f.notice()).toMatchObject({ key: 'toast.prompted', tone: 'success', params: { text } })
|
||||
|
||||
send.mockRejectedValueOnce(new Error('rejected'))
|
||||
f.tab(S1).createChangeRequest()
|
||||
f.local(S1).createChangeRequest()
|
||||
await settle()
|
||||
expect(send).toHaveBeenCalledTimes(2)
|
||||
expect(f.notice()).toMatchObject({ key: 'toast.promptFailed', tone: 'failure' })
|
||||
|
||||
@@ -0,0 +1,413 @@
|
||||
// @vitest-environment jsdom
|
||||
/**
|
||||
* Forge entries in the Session panel: the change requests section and its
|
||||
* title control, the checkout and local changes rows of the Environment
|
||||
* section, and the card actions they wire.
|
||||
*/
|
||||
import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { RemoteHostFacts } from '@deepseek-ai/dsh-api-remotes/client'
|
||||
import type { MergeRequest } from '@deepseek-ai/dsh-experimental-forge/types'
|
||||
import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'
|
||||
import { bindSnapshotSelector, contextMenuHook, makeTranslate } from '@deepseek-ai/dsh-client-test-runtime'
|
||||
import type { ContextMenuTarget } from '@deepseek-ai/dsh-client-ui-context-menu/client'
|
||||
import { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import {
|
||||
ChangeRequestsActions, ChangeRequestsSection, type ChangeRequestsActionsProps, type ChangeRequestsSectionProps,
|
||||
} from '../src/client/ChangeRequestsSection.tsx'
|
||||
import {
|
||||
CheckoutRow, EnvironmentActions, LocalChangesRow, type CheckoutRowProps, type EnvironmentActionsProps, type LocalChangesRowProps,
|
||||
} from '../src/client/EnvironmentRows.tsx'
|
||||
import { en } from '../src/client/locales.ts'
|
||||
import type { PanelSnapshot } from '../src/client/source.ts'
|
||||
import type { ForgePanelChangeRequest, ForgePanelState } from '../src/types.ts'
|
||||
import { created, entry, ready, removed, snapshot, worktree } from './client-fixtures.client.ts'
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
const t = makeTranslate(en)
|
||||
const SESSION = SessionId('s1')
|
||||
|
||||
function panelStore(state: ForgePanelState | null, disconnected = false) {
|
||||
return createSnapshotStore<PanelSnapshot>({ state, disconnected })
|
||||
}
|
||||
|
||||
function section(state: ForgePanelState | null, options: { disconnected?: boolean } = {}) {
|
||||
const panel = panelStore(state, options.disconnected)
|
||||
const handlers = {
|
||||
reconnect: vi.fn<() => void>(),
|
||||
refresh: vi.fn<() => Promise<void>>(async () => {}),
|
||||
remove: vi.fn<(entry: ForgePanelChangeRequest) => void>(),
|
||||
markReady: vi.fn<(entry: ForgePanelChangeRequest) => Promise<void>>(async () => {}),
|
||||
merge: vi.fn<(entry: ForgePanelChangeRequest, request: MergeRequest) => Promise<void>>(async () => {}),
|
||||
readChecks: vi.fn<ChangeRequestsSectionProps['readChecks']>(async () => snapshot(1)),
|
||||
openLink: vi.fn<(url: string) => void>(),
|
||||
copyText: vi.fn<(text: string) => void>(),
|
||||
viewChanges: vi.fn<(entry: ForgePanelChangeRequest) => void>(),
|
||||
dismissOverlay: vi.fn<() => void>(),
|
||||
}
|
||||
const props = {
|
||||
sessionId: SESSION,
|
||||
presentation: 'docked',
|
||||
usePanel: bindSnapshotSelector(panel),
|
||||
useLocale: bindSnapshotSelector(createSnapshotStore<string>('en')),
|
||||
...handlers,
|
||||
t,
|
||||
} as Pick<ChangeRequestsSectionProps,
|
||||
'sessionId' | 'presentation' | 'usePanel' | 'useLocale' | 'dismissOverlay' | 'reconnect' | 'refresh' | 'remove' | 'markReady'
|
||||
| 'merge' | 'readChecks' | 'openLink' | 'copyText' | 'viewChanges' | 't'> as ChangeRequestsSectionProps
|
||||
const view = render(<ChangeRequestsSection {...props} />)
|
||||
return { view, panel, ...handlers }
|
||||
}
|
||||
|
||||
/** The expansion state of each rendered card, in list order. */
|
||||
function expansion(view: ReturnType<typeof render>): boolean[] {
|
||||
return [...view.container.querySelectorAll('[data-forge-change]')].map(card => card.hasAttribute('data-expanded'))
|
||||
}
|
||||
|
||||
/** Open one card's actions menu and choose an item. */
|
||||
function chooseAction(card: HTMLElement, name: string, item: string): void {
|
||||
fireEvent.click(within(card).getByRole('button', { name: `Actions for ${name}` }))
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: item }))
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an animation event under the name React DOM listens for here: jsdom
|
||||
* has no `AnimationEvent` but declares `WebkitAnimation`, so React DOM uses the WebKit-prefixed names.
|
||||
*/
|
||||
function animation(element: Element, phase: 'Start' | 'Iteration'): void {
|
||||
fireEvent(element, new Event(`webkitAnimation${phase}`, { bubbles: true }))
|
||||
}
|
||||
|
||||
describe('ChangeRequestsSection', () => {
|
||||
it.each([
|
||||
['before the first state', null],
|
||||
['without bound change requests', ready()],
|
||||
])('renders nothing %s', (_label, state) => {
|
||||
expect(section(state).view.container.innerHTML).toBe('')
|
||||
})
|
||||
|
||||
it('keeps the cards and adds a reconnect notice while disconnected', () => {
|
||||
const b = section(ready({ changeRequests: [entry(1, snapshot(1))] }), { disconnected: true })
|
||||
const root = b.view.container.querySelector('[data-forge-panel]') as HTMLElement
|
||||
expect(root.firstElementChild?.getAttribute('role')).toBe('status')
|
||||
fireEvent.click(within(root).getByRole('button', { name: en.retry }))
|
||||
expect(b.reconnect).toHaveBeenCalledOnce()
|
||||
act(() => { b.panel.set({ state: ready({ changeRequests: [entry(1, snapshot(1))] }), disconnected: false }) })
|
||||
expect(b.view.queryByRole('status')).toBeNull()
|
||||
})
|
||||
|
||||
it.each([
|
||||
['open', snapshot(1)],
|
||||
['draft', snapshot(1, { draft: true })],
|
||||
])('expands the only %s change request by default', (_label, only) => {
|
||||
const b = section(ready({ changeRequests: [entry(1, only), entry(2, snapshot(2, { state: 'merged' })), entry(3, null)] }))
|
||||
expect(expansion(b.view)).toEqual([true, false, false])
|
||||
})
|
||||
|
||||
it('collapses every card while several are open and keeps the user choice across updates', () => {
|
||||
const b = section(ready({ changeRequests: [entry(1, snapshot(1)), entry(2, snapshot(2))] }))
|
||||
expect(expansion(b.view)).toEqual([false, false])
|
||||
fireEvent.click(b.view.getByRole('button', { name: 'Expand #2' }))
|
||||
act(() => { b.panel.set({ state: ready({ changeRequests: [entry(1, snapshot(1, { title: 'Renamed' })), entry(2, snapshot(2))] }), disconnected: false }) })
|
||||
expect(expansion(b.view)).toEqual([false, true])
|
||||
fireEvent.click(b.view.getByRole('button', { name: 'Collapse #2' }))
|
||||
expect(expansion(b.view)).toEqual([false, false])
|
||||
})
|
||||
|
||||
it('wires the card menu, the changes row, and retry to the section actions', async () => {
|
||||
const value = entry(7, snapshot(7))
|
||||
const b = section(ready({ changeRequests: [value, entry(8, { code: 'unavailable', message: 'down' })] }))
|
||||
const card = b.view.container.querySelector('[data-forge-change="https://github.com/octo/demo/pull/7"]') as HTMLElement
|
||||
chooseAction(card, '#7', en['change.view'])
|
||||
chooseAction(card, '#7', en['change.copy'])
|
||||
chooseAction(card, '#7', en['change.viewChanges'])
|
||||
chooseAction(card, '#7', en['change.remove'])
|
||||
fireEvent.click(within(card).getByRole('button', { name: 'View the changes of #7: 12 lines added, 3 lines deleted' }))
|
||||
fireEvent.click(b.view.getByRole('button', { name: en.retry }))
|
||||
expect(b.openLink).toHaveBeenCalledWith('https://github.com/octo/demo/pull/7')
|
||||
expect(b.copyText).toHaveBeenCalledWith('https://github.com/octo/demo/pull/7')
|
||||
expect(b.viewChanges).toHaveBeenCalledTimes(2)
|
||||
expect(b.viewChanges).toHaveBeenCalledWith(value)
|
||||
// Viewing changes opens the sidebar, so the panel overlay gives way.
|
||||
expect(b.dismissOverlay).toHaveBeenCalledTimes(2)
|
||||
expect(b.remove).toHaveBeenCalledWith(value)
|
||||
expect(b.refresh).toHaveBeenCalledOnce()
|
||||
await act(async () => {})
|
||||
})
|
||||
|
||||
it('offers ready for review in the menu of an open draft and merge in the footer of a mergeable card', async () => {
|
||||
const draft = entry(7, snapshot(7, { draft: true }))
|
||||
const mergeable = entry(8, snapshot(8, { mergeReady: true, headSha: 'b'.repeat(40) }))
|
||||
const b = section(ready({ changeRequests: [draft, mergeable] }))
|
||||
fireEvent.click(b.view.getByRole('button', { name: 'Expand #8' }))
|
||||
const card = b.view.container.querySelector('[data-forge-change="https://github.com/octo/demo/pull/7"]') as HTMLElement
|
||||
fireEvent.click(within(card).getByRole('button', { name: 'Actions for #7' }))
|
||||
await act(async () => { fireEvent.click(screen.getByRole('menuitem', { name: en['change.markReady'] })) })
|
||||
fireEvent.click(b.view.getByRole('button', { name: en['change.merge'] }))
|
||||
await act(async () => {
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: en['change.mergeConfirm'] }))
|
||||
})
|
||||
expect(b.markReady).toHaveBeenCalledWith(draft)
|
||||
expect(b.merge).toHaveBeenCalledWith(mergeable, { method: 'squash', headSha: 'b'.repeat(40) })
|
||||
const merged = b.view.container.querySelector('[data-forge-change="https://github.com/octo/demo/pull/8"]') as HTMLElement
|
||||
fireEvent.click(within(merged).getByRole('button', { name: 'Actions for #8' }))
|
||||
expect(screen.queryByRole('menuitem', { name: en['change.markReady'] })).toBeNull()
|
||||
})
|
||||
|
||||
it('shows the sign-in notice above the cards', () => {
|
||||
const b = section(ready({
|
||||
readiness: { state: 'unauthenticated', message: 'not logged in' },
|
||||
changeRequests: [entry(1, snapshot(1))],
|
||||
}))
|
||||
const banner = b.view.getByRole('status')
|
||||
expect(within(banner).getByText('gh auth login --hostname github.com').tagName).toBe('CODE')
|
||||
fireEvent.click(within(banner).getByRole('button', { name: en['signin.copy'] }))
|
||||
expect(b.copyText).toHaveBeenCalledWith('gh auth login --hostname github.com')
|
||||
})
|
||||
|
||||
it.each([
|
||||
['with its message', 'token expired', ['Sign in to gitlab.example.test to show change request status', 'token expired']],
|
||||
['without a message', null, ['Sign in to gitlab.example.test to show change request status']],
|
||||
])('asks to sign in to another code host %s', (_label, message, texts) => {
|
||||
const b = section(ready({
|
||||
repository: { forge: 'gitlab', host: 'gitlab.example.test', owner: 'octo', name: 'demo' },
|
||||
readiness: { state: 'unauthenticated', message },
|
||||
changeRequests: [entry(1, snapshot(1))],
|
||||
}))
|
||||
expect([...b.view.getByRole('status').children].map(child => child.textContent)).toEqual(texts)
|
||||
})
|
||||
|
||||
it.each([
|
||||
['with its message', 'spawn gh ENOENT', 'Change requests on github.com could not be read: spawn gh ENOENT'],
|
||||
['without a message', null, 'Change requests on github.com could not be read: '],
|
||||
])('explains an unreachable host %s', (_label, message, text) => {
|
||||
const b = section(ready({ readiness: { state: 'unavailable', message }, changeRequests: [entry(1, snapshot(1))] }))
|
||||
expect(b.view.getByRole('status').textContent).toBe(text)
|
||||
})
|
||||
|
||||
it.each([
|
||||
['sign-in is unknown', { readiness: null }],
|
||||
['the host is signed in', {}],
|
||||
['no provider serves the repository', { repository: null, readiness: { state: 'unauthenticated' as const, message: 'not logged in' } }],
|
||||
])('shows no notice while %s', (_label, over) => {
|
||||
const b = section(ready({ ...over, changeRequests: [entry(1, snapshot(1))] }))
|
||||
expect(b.view.queryByRole('status')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('ChangeRequestsActions', () => {
|
||||
function actions(state: ForgePanelState | null) {
|
||||
const panel = panelStore(state)
|
||||
const refresh = vi.fn<() => Promise<void>>(async () => {})
|
||||
const props = { sessionId: SESSION, usePanel: bindSnapshotSelector(panel), refresh, t } as
|
||||
Pick<ChangeRequestsActionsProps, 'sessionId' | 'usePanel' | 'refresh' | 't'> as ChangeRequestsActionsProps
|
||||
return { view: render(<ChangeRequestsActions {...props} />), refresh }
|
||||
}
|
||||
|
||||
it('renders nothing without bound change requests', () => {
|
||||
expect(actions(ready()).view.container.innerHTML).toBe('')
|
||||
cleanup()
|
||||
expect(actions(null).view.container.innerHTML).toBe('')
|
||||
})
|
||||
|
||||
it('counts the change requests and turns the refresh glyph until the refresh settles and its turn ends, ignoring clicks meanwhile', async () => {
|
||||
const pending = Promise.withResolvers<undefined>()
|
||||
const b = actions(ready({ changeRequests: [entry(1, snapshot(1)), entry(2, snapshot(2))] }))
|
||||
expect(b.view.container.textContent).toBe('2')
|
||||
b.refresh.mockReturnValueOnce(pending.promise)
|
||||
const button = b.view.getByRole('button', { name: en.refresh })
|
||||
const glyph = button.firstElementChild as HTMLElement
|
||||
expect(glyph.hasAttribute('data-turning')).toBe(false)
|
||||
|
||||
fireEvent.click(button)
|
||||
animation(glyph, 'Start')
|
||||
fireEvent.click(button)
|
||||
expect(b.refresh).toHaveBeenCalledOnce()
|
||||
expect(button.getAttribute('aria-disabled')).toBe('true')
|
||||
animation(glyph, 'Iteration')
|
||||
expect(glyph.hasAttribute('data-turning')).toBe(true)
|
||||
|
||||
await act(async () => { pending.resolve(undefined) })
|
||||
expect(button.getAttribute('aria-disabled')).toBe('false')
|
||||
expect(glyph.hasAttribute('data-turning')).toBe(true)
|
||||
animation(glyph, 'Iteration')
|
||||
expect(glyph.hasAttribute('data-turning')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('EnvironmentActions', () => {
|
||||
function actions(state: ForgePanelState | null) {
|
||||
const panel = panelStore(state)
|
||||
const refresh = vi.fn<() => Promise<void>>(async () => {})
|
||||
const props = { sessionId: SESSION, usePanel: bindSnapshotSelector(panel), refresh, t } as
|
||||
Pick<EnvironmentActionsProps, 'sessionId' | 'usePanel' | 'refresh' | 't'> as EnvironmentActionsProps
|
||||
return { view: render(<EnvironmentActions {...props} />), panel, refresh }
|
||||
}
|
||||
|
||||
it('offers refresh once the panel state arrived, also outside a Git checkout', async () => {
|
||||
const b = actions(null)
|
||||
expect(b.view.container.innerHTML).toBe('')
|
||||
act(() => { b.panel.set({ state: ready({ checkout: { state: 'none' } }), disconnected: false }) })
|
||||
fireEvent.click(b.view.getByRole('button', { name: en.refresh }))
|
||||
expect(b.refresh).toHaveBeenCalledOnce()
|
||||
await act(async () => {})
|
||||
})
|
||||
})
|
||||
|
||||
describe('CheckoutRow', () => {
|
||||
function row(state: ForgePanelState | null, home?: string) {
|
||||
const panel = panelStore(state)
|
||||
const host = createSnapshotStore<RemoteHostFacts>({ home, isLoopback: true })
|
||||
const restore = vi.fn<() => void>()
|
||||
const opened: ContextMenuTarget[] = []
|
||||
const renderFactorySlot = vi.fn((_name: string, input: { label: string }) => <button type="button">{input.label}</button>)
|
||||
const props = {
|
||||
sessionId: SESSION,
|
||||
usePanel: bindSnapshotSelector(panel),
|
||||
useHost: bindSnapshotSelector(host),
|
||||
useContextMenu: contextMenuHook((target: ContextMenuTarget) => { opened.push(target) }),
|
||||
renderFactorySlot,
|
||||
restore,
|
||||
t,
|
||||
} as Pick<CheckoutRowProps, 'sessionId' | 'usePanel' | 'useHost' | 'useContextMenu' | 'renderFactorySlot' | 'restore' | 't'> as CheckoutRowProps
|
||||
const view = render(<CheckoutRow {...props} />)
|
||||
return { view, restore, opened, renderFactorySlot, element: () => view.container.querySelector<HTMLElement>('[data-forge-checkout]') }
|
||||
}
|
||||
|
||||
it.each([
|
||||
['before the first state', null],
|
||||
['while the first inspection runs', ready({ checkout: { state: 'pending' } })],
|
||||
['outside a Git checkout', ready({ checkout: { state: 'none' } })],
|
||||
])('renders nothing %s', (_label, state) => {
|
||||
expect(row(state).view.container.innerHTML).toBe('')
|
||||
})
|
||||
|
||||
it('warns that Git could not be read and shows the failure on hover, without the directory menu', () => {
|
||||
const b = row(ready({ checkout: { state: 'failed', message: 'sandbox runner unavailable' } }))
|
||||
const element = b.element() as HTMLElement
|
||||
expect(element.hasAttribute('data-failed')).toBe(true)
|
||||
expect(element.textContent).toBe(en['checkout.failed'])
|
||||
fireEvent.pointerEnter(within(element).getByText(en['checkout.failed']))
|
||||
expect(b.view.getByRole('tooltip').textContent).toBe('sandbox runner unavailable')
|
||||
expect(b.renderFactorySlot).not.toHaveBeenCalled()
|
||||
fireEvent.contextMenu(element)
|
||||
expect(b.opened).toEqual([])
|
||||
})
|
||||
|
||||
it('names the branch and kind of the project directory, shows its path on hover, and opens the directory menu', () => {
|
||||
const b = row(ready(), '/work')
|
||||
const element = b.element() as HTMLElement
|
||||
expect(element.textContent).toBe(`main${en['checkout.project']}${en['checkout.projectActions']}`)
|
||||
fireEvent.pointerEnter(within(element).getByText('main'))
|
||||
expect(b.view.getByRole('tooltip').textContent).toBe('Project directory: ~/repo')
|
||||
expect(b.renderFactorySlot).toHaveBeenCalledWith('contextMenu.button', expect.objectContaining({
|
||||
target: { kind: 'directory', value: { sessionId: SESSION, path: '/work/repo' } },
|
||||
size: 'sm',
|
||||
}))
|
||||
fireEvent.contextMenu(element)
|
||||
expect(b.opened).toEqual([{ kind: 'directory', value: { sessionId: SESSION, path: '/work/repo' } }])
|
||||
})
|
||||
|
||||
it('names a detached HEAD with its commit and a linked worktree', () => {
|
||||
expect(row(ready({}, { branch: null })).element()?.textContent)
|
||||
.toBe(`${en['checkout.detached']} · 0a1b2c3${en['checkout.project']}${en['checkout.projectActions']}`)
|
||||
cleanup()
|
||||
expect(row(ready({}, { linked: true })).element()?.textContent)
|
||||
.toBe(`main${en['checkout.worktree']}${en['checkout.worktreeActions']}`)
|
||||
})
|
||||
|
||||
it('names the worktree this Session created with its base', () => {
|
||||
const b = row(ready({ directory: '/work/repo-dsh', worktree: worktree({ created: created({ path: '/work/repo-dsh' }) }) },
|
||||
{ root: '/work/repo-dsh', branch: 'other', linked: true }))
|
||||
expect(b.element()?.textContent).toBe(`otherWorktree · from main${en['checkout.worktreeActions']}`)
|
||||
})
|
||||
|
||||
it('names the base commit of a created worktree without a base branch, and a checkout without a commit', () => {
|
||||
const b = row(ready({ directory: '/work/repo-dsh', worktree: worktree({ created: created({ path: '/work/repo-dsh', from: null }) }) },
|
||||
{ root: '/work/repo-dsh', branch: null, linked: true }))
|
||||
expect(b.element()?.textContent).toBe(`${en['checkout.detached']} · 0a1b2c3Worktree · from ccccccc${en['checkout.worktreeActions']}`)
|
||||
cleanup()
|
||||
expect(row(ready({}, { branch: null, commit: null })).element()?.textContent)
|
||||
.toBe(`${en['checkout.detached']}${en['checkout.project']}${en['checkout.projectActions']}`)
|
||||
})
|
||||
|
||||
it('names a removed worktree and restores it on request', () => {
|
||||
const b = row(removed())
|
||||
const element = b.element() as HTMLElement
|
||||
expect(element.hasAttribute('data-missing')).toBe(true)
|
||||
expect(within(element).getByText('dsh/0a1b2c3d')).toBeTruthy()
|
||||
expect(within(element).getByText(en['missing.title'])).toBeTruthy()
|
||||
expect(b.renderFactorySlot).not.toHaveBeenCalled()
|
||||
fireEvent.click(within(element).getByRole('button', { name: en['checkout.restore'] }))
|
||||
expect(b.restore).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('turns the restore button into a disabled spinner while a restoration runs', () => {
|
||||
const b = row(removed(true, false, { restoration: { phase: 'prepare' } }))
|
||||
const restore = within(b.element() as HTMLElement).getByRole('button', { name: en['checkout.restore'] })
|
||||
expect(restore instanceof HTMLButtonElement && restore.disabled).toBe(true)
|
||||
expect(restore.querySelector('svg[data-state="ongoing"]')).not.toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('LocalChangesRow', () => {
|
||||
const local = { base: 'origin/main', files: [
|
||||
{ path: 'src/a.ts', additions: 3, deletions: 1, binary: false },
|
||||
{ path: 'src/b.ts', additions: 2, deletions: 0, binary: false },
|
||||
] }
|
||||
|
||||
function row(state: ForgePanelState | null) {
|
||||
const panel = panelStore(state)
|
||||
const viewLocalChanges = vi.fn<() => void>()
|
||||
const createChangeRequest = vi.fn<() => void>()
|
||||
const dismissOverlay = vi.fn<() => void>()
|
||||
const props = {
|
||||
sessionId: SESSION, usePanel: bindSnapshotSelector(panel), dismissOverlay, viewLocalChanges, createChangeRequest, t,
|
||||
} as Pick<LocalChangesRowProps, 'sessionId' | 'usePanel' | 'dismissOverlay' | 'viewLocalChanges' | 'createChangeRequest' | 't'> as LocalChangesRowProps
|
||||
const view = render(<LocalChangesRow {...props} />)
|
||||
return { view, viewLocalChanges, createChangeRequest, dismissOverlay }
|
||||
}
|
||||
|
||||
it.each([
|
||||
['before the first state', null],
|
||||
['before the branch scope is read', ready()],
|
||||
['while the branch scope changes nothing', ready({ local: { base: 'origin/main', files: [] } })],
|
||||
])('renders nothing %s', (_label, state) => {
|
||||
expect(row(state).view.container.innerHTML).toBe('')
|
||||
})
|
||||
|
||||
it('sums the branch changes, opens them, and asks the Agent for a change request', () => {
|
||||
const b = row(ready({ local }))
|
||||
const element = b.view.container.querySelector('[data-forge-local]') as HTMLElement
|
||||
expect(within(element).getByText('Local changes · 2 files')).toBeTruthy()
|
||||
expect(within(element).getByText('+5')).toBeTruthy()
|
||||
fireEvent.click(within(element).getByRole('button', { name: 'View the changes of this Session: 2 files, 5 lines added, 1 lines deleted' }))
|
||||
expect(b.viewLocalChanges).toHaveBeenCalledOnce()
|
||||
fireEvent.click(within(element).getByRole('button', { name: en['changes.local.actions'] }))
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: en['change.viewChanges'] }))
|
||||
expect(b.viewLocalChanges).toHaveBeenCalledTimes(2)
|
||||
// Opening the view in the sidebar closes the panel overlay.
|
||||
expect(b.dismissOverlay).toHaveBeenCalledTimes(2)
|
||||
fireEvent.click(within(element).getByRole('button', { name: en['changes.local.actions'] }))
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: en['changes.local.create'] }))
|
||||
expect(b.createChangeRequest).toHaveBeenCalledOnce()
|
||||
expect(b.dismissOverlay).toHaveBeenCalledTimes(2)
|
||||
const more = within(element).getByRole('button', { name: en['changes.local.actions'] })
|
||||
fireEvent.click(more)
|
||||
fireEvent.click(more)
|
||||
expect(screen.queryByRole('menuitem')).toBeNull()
|
||||
fireEvent.click(more)
|
||||
fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' })
|
||||
expect(screen.queryByRole('menuitem')).toBeNull()
|
||||
})
|
||||
|
||||
it.each([
|
||||
['without a code host repository', ready({ local, repository: null })],
|
||||
['while a change request of the branch is open', ready({ local, changeRequests: [entry(7, snapshot(7, { headBranch: 'main' }))] })],
|
||||
])('offers no change request %s', (_label, state) => {
|
||||
const b = row(state)
|
||||
fireEvent.click(b.view.getByRole('button', { name: en['changes.local.actions'] }))
|
||||
expect(screen.queryByRole('menuitem', { name: en['changes.local.create'] })).toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { createNoticeSource, createPanelSource, createStreamSource, createVisibilitySource, foldStates } from '../src/client/source.ts'
|
||||
import { createNoticeSource, createPanelSource, createStreamSource, foldStates } from '../src/client/source.ts'
|
||||
import type { PanelStream } from '../src/client/source.ts'
|
||||
import type { ForgeChangeRequestListState, ForgeChangeRequestStatesFrame, ForgePanelState } from '../src/types.ts'
|
||||
import { entry, listState, ready, snapshot } from './client-fixtures.client.ts'
|
||||
@@ -278,24 +278,3 @@ describe('createNoticeSource', () => {
|
||||
expect(undo).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe('createVisibilitySource', () => {
|
||||
it('starts hidden and notifies only when the visibility changes', () => {
|
||||
const visibility = createVisibilitySource()
|
||||
const listener = vi.fn()
|
||||
const unsubscribe = visibility.hooks.visible.subscribe(listener)
|
||||
expect(visibility.hooks.visible.getSnapshot()).toBe(false)
|
||||
|
||||
visibility.set(false)
|
||||
expect(listener).not.toHaveBeenCalled()
|
||||
visibility.set(true)
|
||||
visibility.set(true)
|
||||
expect(listener).toHaveBeenCalledOnce()
|
||||
expect(visibility.hooks.visible.getSnapshot()).toBe(true)
|
||||
|
||||
unsubscribe()
|
||||
visibility.set(false)
|
||||
expect(listener).toHaveBeenCalledOnce()
|
||||
expect(visibility.hooks.visible.getSnapshot()).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -26,6 +26,9 @@
|
||||
{
|
||||
"path": "../../client/store"
|
||||
},
|
||||
{
|
||||
"path": "../../client/ui-context-menu"
|
||||
},
|
||||
{
|
||||
"path": "../../client/ui-conversation/tsconfig.client.json"
|
||||
},
|
||||
@@ -41,6 +44,9 @@
|
||||
{
|
||||
"path": "../../client/ui-session"
|
||||
},
|
||||
{
|
||||
"path": "../../client/ui-session-panel"
|
||||
},
|
||||
{
|
||||
"path": "../../client/ui-sidebar-right"
|
||||
},
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
en: d152484eb41ac6b4
|
||||
zh: 2f8a621b991260a1
|
||||
/deepseek-ai-dsh-experimental-forge-bundle/use-this-package:
|
||||
en: 33679bed06be4e74
|
||||
zh: 77dcfac9570d1fbc
|
||||
en: c5a28102b730d9ec
|
||||
zh: 5b6d47c618e0f0ad
|
||||
/deepseek-ai-dsh-experimental-forge-bundle/understand-the-implementation:
|
||||
en: 5cb4136ef2058890
|
||||
zh: 5142828996eef6c7
|
||||
|
||||
@@ -25,7 +25,7 @@ Review each Session's change requests, checks, and diffs, start a new Session in
|
||||
<a id="use-this-package"></a>
|
||||
## Use this package
|
||||
|
||||
Open Plugins and enable Change requests & worktrees in the Official group. In a Git workspace, check Worktree in the composer before the first message to start the Session in a new worktree. In a Session whose directory is inside a Git checkout, the header button opens the panel. GitHub pull requests that the Session creates with `gh pr create`, opens with `gh pr view`, `gh pr edit`, or `gh pr checkout`, or works on as its branch or updates with a later `git push`, appear as change requests without further steps. Run `gh auth login --hostname <host>` in a terminal to sign in; the panel shows the command when sign-in is missing. The [panel package](../client-ui-forge/README.md#use-this-package) describes each control.
|
||||
Open Plugins and enable Change requests & worktrees in the Official group. In a Git workspace, check Worktree in the composer before the first message to start the Session in a new worktree. In a Session whose directory is inside a Git checkout, the Session panel toggle in the header shows the checkout and its change requests. GitHub pull requests that the Session creates with `gh pr create`, opens with `gh pr view`, `gh pr edit`, or `gh pr checkout`, or works on as its branch or updates with a later `git push`, appear as change requests without further steps. Run `gh auth login --hostname <host>` in a terminal to sign in; the panel shows the command when sign-in is missing. The [panel package](../client-ui-forge/README.md#use-this-package) describes each control.
|
||||
|
||||
The same switch enables the model's [`create_worktree`](../tool-worktree/README.md) tool. Turning it off removes both the panel and the tool while retaining existing checkouts and branches. For profiles that already selected the standalone worktree bundle, follow the [upgrade guide](../../../docs/upgrade-guide/v0.2.2-alpha.2/forge-worktree-entry/guide.md) before enabling this bundle.
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ kind: "package-bundle"
|
||||
<a id="use-this-package"></a>
|
||||
## 使用本包
|
||||
|
||||
打开插件页面,在官方分组中启用“变更请求与工作树”。在 Git 工作区中,发出第一条消息之前在输入框中勾选“工作树”,Session 就会在新的 worktree 中开始。Session 的目录位于 Git 检出中时,标题栏按钮会打开面板。Session 用 `gh pr create` 创建、用 `gh pr view`、`gh pr edit` 或 `gh pr checkout` 打开的 GitHub pull request,以及 Session 所在分支上或之后 `git push` 更新的 pull request,无需额外操作即会作为变更请求出现。在终端运行 `gh auth login --hostname <host>` 登录;缺少登录时,面板会显示这条命令。[面板包](../client-ui-forge/README.zh.md#use-this-package)说明了每个控件。
|
||||
打开插件页面,在官方分组中启用“变更请求与工作树”。在 Git 工作区中,发出第一条消息之前在输入框中勾选“工作树”,Session 就会在新的 worktree 中开始。Session 的目录位于 Git 检出中时,标题栏中的会话面板开关会显示检出及其变更请求。Session 用 `gh pr create` 创建、用 `gh pr view`、`gh pr edit` 或 `gh pr checkout` 打开的 GitHub pull request,以及 Session 所在分支上或之后 `git push` 更新的 pull request,无需额外操作即会作为变更请求出现。在终端运行 `gh auth login --hostname <host>` 登录;缺少登录时,面板会显示这条命令。[面板包](../client-ui-forge/README.zh.md#use-this-package)说明了每个控件。
|
||||
|
||||
同一个开关也启用模型的 [`create_worktree`](../tool-worktree/README.zh.md) 工具。关闭后面板和工具一起移除,已有检出目录与分支仍然保留。已选中独立工作树组合包的 profile,请在启用本组合包前按[升级指南](../../../docs/upgrade-guide/v0.2.2-alpha.2/forge-worktree-entry/guide.zh.md)调整配置。
|
||||
|
||||
|
||||
@@ -2088,74 +2088,12 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
declaredBy: 'an entry in \'conversation.session.header\' (client-ui-conversation), so it exists while that entry is mounted',
|
||||
occupants: [
|
||||
'client-ui-agent-preset AgentPresetLabel id \'agent-preset\'',
|
||||
'client-ui-jobs JobListAction id \'job-list\'',
|
||||
'client-ui-sidebar-terminal AgentTerminalOpener id \'agent-terminals\'',
|
||||
'client-ui-subagent SubagentCatalogAction id \'subagent-catalog\'',
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.header.actions\', () => ctx.slots.register(\n { name: \'conversation.session.header.actions\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-conversation/src/client/contract/slots.ts:254',
|
||||
},
|
||||
{
|
||||
key: 'conversation.session.header.actions.subagent.footer',
|
||||
kind: 'list',
|
||||
scope: 'session',
|
||||
summary: 'Content below the root Session\'s subagent tree.',
|
||||
doc: 'Content below the root Session\'s subagent tree.',
|
||||
registerOptions: [
|
||||
{
|
||||
name: 'id',
|
||||
requirement: 'required',
|
||||
type: 'string',
|
||||
doc: 'Your cell key. Use an id of your own: a fresh id is added beside the shipped entries, while reusing a shipped id puts you in THAT cell and replaces it. Owners that filter by id address you by it.',
|
||||
},
|
||||
{
|
||||
name: 'order',
|
||||
requirement: 'optional',
|
||||
type: 'number',
|
||||
doc: 'Position among the entries, ascending (default 0).',
|
||||
},
|
||||
{
|
||||
name: 'label',
|
||||
requirement: 'optional',
|
||||
type: 'string | (() => string)',
|
||||
doc: 'Display text where the owner projects one (nav rows, tabs). A thunk is re-read on every projection, so localized text follows the active locale without re-registering.',
|
||||
},
|
||||
],
|
||||
ownerProps: [],
|
||||
ownerPropsReferences: [],
|
||||
standardProps: [
|
||||
'useRemoteAccess: (action: RemoteEndpoint) => boolean',
|
||||
'useResource: UseResource',
|
||||
'useContextMenu: UseContextMenu',
|
||||
'useWorkspaces: SnapshotSelectorHook<WorkspaceSnapshot>',
|
||||
'usePanelInfo: UsePanelInfo',
|
||||
'useSessions: UseSessions',
|
||||
'useSessionStatus: UseSessionStatus',
|
||||
'useSessionRetainInfo: UseSessionRetainInfo',
|
||||
'useSessionAccess: (sessionId: SessionId, action: RemoteEndpoint) => boolean',
|
||||
'useWorkspaceAccess: (workspaceId: WorkspaceId, action: RemoteEndpoint) => boolean',
|
||||
'useChat: UseChat',
|
||||
'useConversation: UseConversation',
|
||||
'useInput: SnapshotSelectorHook<InputState>',
|
||||
'inputActions: InputActions',
|
||||
'useSession: SessionSnapshotSelector',
|
||||
'sessionId: SessionId',
|
||||
'useProjection: UseProjection',
|
||||
'useAccess: (action: RemoteEndpoint) => boolean',
|
||||
'useTrajectory: UseTrajectory',
|
||||
],
|
||||
keyDomain: '',
|
||||
hookContext: '',
|
||||
slotInject: '',
|
||||
declaredBy: 'an entry in \'conversation.session.header.actions\' (client-ui-subagent), so it exists while that entry is mounted',
|
||||
occupants: [
|
||||
'client-ui-agent-team TeamBoard id \'agent-team\'',
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.header.actions.subagent.footer\', () => ctx.slots.register(\n { name: \'conversation.session.header.actions.subagent.footer\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-subagent/src/client/slots.ts:6',
|
||||
},
|
||||
{
|
||||
key: 'conversation.session.header.corner',
|
||||
kind: 'single',
|
||||
@@ -2302,7 +2240,6 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
occupants: [
|
||||
'client-ui-schedule ScheduleCatalogAction id \'schedule-catalog\'',
|
||||
'client-ui-session-panel SessionPanelToggle id \'session-panel\'',
|
||||
'experimental-client-ui-forge HeaderButton id \'forge-panel\'',
|
||||
'experimental-liveshare LiveshareShareAction id \'liveshare-share\'',
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
@@ -2411,8 +2348,8 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
key: 'conversation.session.panel.environment.row',
|
||||
kind: 'list',
|
||||
scope: 'session',
|
||||
summary: 'Rows of the built-in Environment section in ascending `order`.',
|
||||
doc: 'Rows of the built-in Environment section in ascending `order`.',
|
||||
summary: 'Rows of the built-in Environment section in ascending `order`; they receive the section\'s owner values.',
|
||||
doc: 'Rows of the built-in Environment section in ascending `order`; they receive the section\'s owner values.',
|
||||
registerOptions: [
|
||||
{
|
||||
name: 'id',
|
||||
@@ -2433,8 +2370,12 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
doc: 'Display text where the owner projects one (nav rows, tabs). A thunk is re-read on every projection, so localized text follows the active locale without re-registering.',
|
||||
},
|
||||
],
|
||||
ownerProps: [],
|
||||
ownerPropsReferences: [],
|
||||
ownerProps: [
|
||||
'/** Values every section receives from the panel. */\nexport interface SessionPanelSectionOwnerProps {\n /** Current presentation; sections may lower their density in the overlay. */\n readonly presentation: SessionPanelPresentation\n /** Close the overlay, for example after a row opened another surface; no effect while docked. */\n readonly dismissOverlay: () => void\n}',
|
||||
],
|
||||
ownerPropsReferences: [
|
||||
'SessionPanelPresentation',
|
||||
],
|
||||
standardProps: [
|
||||
'useRemoteAccess: (action: RemoteEndpoint) => boolean',
|
||||
'useResource: UseResource',
|
||||
@@ -2462,6 +2403,8 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
declaredBy: 'an entry in \'conversation.session.panel.section\' (client-ui-session-panel), so it exists while that entry is mounted',
|
||||
occupants: [
|
||||
'client-ui-session-panel ProjectRow id \'project\'',
|
||||
'experimental-client-ui-forge CheckoutRow id \'forge.checkout\'',
|
||||
'experimental-client-ui-forge LocalChangesRow id \'forge.local\'',
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel.environment.row\', () => ctx.slots.register(\n { name: \'conversation.session.panel.environment.row\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
@@ -2520,7 +2463,9 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
hookContext: '',
|
||||
slotInject: '',
|
||||
declaredBy: 'an entry in \'conversation.session.header.utilities\' (client-ui-session-panel), so it exists while that entry is mounted',
|
||||
occupants: [],
|
||||
occupants: [
|
||||
'experimental-client-ui-forge AttentionIndicator id \'forge.attention\'',
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel.indicator\', () => ctx.slots.register(\n { name: \'conversation.session.panel.indicator\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:33',
|
||||
@@ -2583,7 +2528,10 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
slotInject: '',
|
||||
declaredBy: 'an entry in \'conversation.session.panel\' (client-ui-session-panel), so it exists while that entry is mounted',
|
||||
occupants: [
|
||||
'client-ui-jobs JobsSection id \'background-jobs\'',
|
||||
'client-ui-session-panel EnvironmentSection id \'environment\'',
|
||||
'client-ui-subagent SubagentsSection id \'subagents\'',
|
||||
'experimental-client-ui-forge ChangeRequestsSection id \'change-requests\'',
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel.section\', () => ctx.slots.register(\n { name: \'conversation.session.panel.section\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
@@ -2626,15 +2574,79 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
'useAccess: (action: RemoteEndpoint) => boolean',
|
||||
'useTrajectory: UseTrajectory',
|
||||
],
|
||||
keyDomain: 'open: any string the owner dispatches (no compile-time key set), none are taken yet',
|
||||
keyDomain: 'open: any string the owner dispatches (no compile-time key set), already taken: change-requests, environment, subagents',
|
||||
hookContext: '',
|
||||
slotInject: '',
|
||||
declaredBy: 'an entry in \'conversation.session.panel\' (client-ui-session-panel), so it exists while that entry is mounted',
|
||||
occupants: [],
|
||||
replaceRisk: 'none',
|
||||
occupants: [
|
||||
'client-ui-subagent SubagentsProgress key \'subagents\'',
|
||||
'experimental-client-ui-forge ChangeRequestsActions key \'change-requests\'',
|
||||
'experimental-client-ui-forge EnvironmentActions key \'environment\'',
|
||||
],
|
||||
replaceRisk: 'shadows-shipped-ui',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel.section.actions\', () => ctx.slots.register(\n { name: \'conversation.session.panel.section.actions\', key: \'<one key the owner dispatches>\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:27',
|
||||
},
|
||||
{
|
||||
key: 'conversation.session.panel.subagents.footer',
|
||||
kind: 'list',
|
||||
scope: 'session',
|
||||
summary: 'Content below the Session\'s subagent tree in the Session panel, such as the shared task board.',
|
||||
doc: 'Content below the Session\'s subagent tree in the Session panel, such as the shared task board.',
|
||||
registerOptions: [
|
||||
{
|
||||
name: 'id',
|
||||
requirement: 'required',
|
||||
type: 'string',
|
||||
doc: 'Your cell key. Use an id of your own: a fresh id is added beside the shipped entries, while reusing a shipped id puts you in THAT cell and replaces it. Owners that filter by id address you by it.',
|
||||
},
|
||||
{
|
||||
name: 'order',
|
||||
requirement: 'optional',
|
||||
type: 'number',
|
||||
doc: 'Position among the entries, ascending (default 0).',
|
||||
},
|
||||
{
|
||||
name: 'label',
|
||||
requirement: 'optional',
|
||||
type: 'string | (() => string)',
|
||||
doc: 'Display text where the owner projects one (nav rows, tabs). A thunk is re-read on every projection, so localized text follows the active locale without re-registering.',
|
||||
},
|
||||
],
|
||||
ownerProps: [],
|
||||
ownerPropsReferences: [],
|
||||
standardProps: [
|
||||
'useRemoteAccess: (action: RemoteEndpoint) => boolean',
|
||||
'useResource: UseResource',
|
||||
'useContextMenu: UseContextMenu',
|
||||
'useWorkspaces: SnapshotSelectorHook<WorkspaceSnapshot>',
|
||||
'usePanelInfo: UsePanelInfo',
|
||||
'useSessions: UseSessions',
|
||||
'useSessionStatus: UseSessionStatus',
|
||||
'useSessionRetainInfo: UseSessionRetainInfo',
|
||||
'useSessionAccess: (sessionId: SessionId, action: RemoteEndpoint) => boolean',
|
||||
'useWorkspaceAccess: (workspaceId: WorkspaceId, action: RemoteEndpoint) => boolean',
|
||||
'useChat: UseChat',
|
||||
'useConversation: UseConversation',
|
||||
'useInput: SnapshotSelectorHook<InputState>',
|
||||
'inputActions: InputActions',
|
||||
'useSession: SessionSnapshotSelector',
|
||||
'sessionId: SessionId',
|
||||
'useProjection: UseProjection',
|
||||
'useAccess: (action: RemoteEndpoint) => boolean',
|
||||
'useTrajectory: UseTrajectory',
|
||||
],
|
||||
keyDomain: '',
|
||||
hookContext: '',
|
||||
slotInject: '',
|
||||
declaredBy: 'an entry in \'conversation.session.panel.section\' (client-ui-subagent), so it exists while that entry is mounted',
|
||||
occupants: [
|
||||
'client-ui-agent-team TeamBoard id \'agent-team\'',
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel.subagents.footer\', () => ctx.slots.register(\n { name: \'conversation.session.panel.subagents.footer\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-subagent/src/client/slots.ts:7',
|
||||
},
|
||||
{
|
||||
key: 'conversation.trajectory.images',
|
||||
kind: 'single',
|
||||
@@ -4711,7 +4723,6 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
'client-ui-sidebar-right GuideBody',
|
||||
'client-ui-sidebar-terminal LazyTerminalBody',
|
||||
'client-ui-subagent SidebarChatTab',
|
||||
'experimental-client-ui-forge ForgeTab',
|
||||
'experimental-client-ui-forge ChangesTab',
|
||||
'experimental-liveshare ViewerSharePathBody',
|
||||
'experimental-session-inspector SessionInspectorView',
|
||||
@@ -4769,7 +4780,6 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
'client-ui-sidebar-files FilesTitle',
|
||||
'client-ui-sidebar-right GuideTitle',
|
||||
'client-ui-sidebar-terminal TerminalTitle',
|
||||
'experimental-client-ui-forge ForgeTabTitle',
|
||||
'experimental-client-ui-forge ChangesTabTitle',
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ Every package below exports a Cordis plugin that a bundle patch can name in a Lo
|
||||
| `@deepseek-ai/dsh-client-ui-file-drag` | no | Application-owned file drag transfers and localized failure feedback |
|
||||
| `@deepseek-ai/dsh-client-ui-goal` | no | Session goal surface: GoalBar docked above the composer, read from the goal session projection |
|
||||
| `@deepseek-ai/dsh-client-ui-input-trigger` | no | Input trigger pipeline: '/' and '@' detection, candidate menu, pick routing to registered sources |
|
||||
| `@deepseek-ai/dsh-client-ui-jobs` | no | Session-header background-job list with on-demand streaming record panels |
|
||||
| `@deepseek-ai/dsh-client-ui-jobs` | no | Session panel background-job list with on-demand streaming record panels |
|
||||
| `@deepseek-ai/dsh-client-ui-layout` | no | Shell plugin: three-column AppFrame with drag handles, ctx.layout viewing-state service (navigation + panels) |
|
||||
| `@deepseek-ai/dsh-client-ui-message-feedback` | no | The Web feedback surface: per-message Like/Dislike in the assistant-message action strip and the feedback dialog behind both ratings and /feedback, backed by the messageFeedback and sessionFeedback Host Remotes |
|
||||
| `@deepseek-ai/dsh-client-ui-model-selection` | no | Model selection over the shared model catalog, Session projection, and session.selectModel |
|
||||
|
||||
Generated
+9
@@ -4797,6 +4797,9 @@ importers:
|
||||
'@deepseek-ai/dsh-client-locale':
|
||||
specifier: workspace:*
|
||||
version: link:../locale
|
||||
'@deepseek-ai/dsh-client-store':
|
||||
specifier: workspace:*
|
||||
version: link:../store
|
||||
'@deepseek-ai/dsh-client-test-runtime':
|
||||
specifier: workspace:*
|
||||
version: link:../../test-support/client-runtime
|
||||
@@ -9343,6 +9346,9 @@ importers:
|
||||
'@deepseek-ai/dsh-client-test-runtime':
|
||||
specifier: workspace:*
|
||||
version: link:../../test-support/client-runtime
|
||||
'@deepseek-ai/dsh-client-ui-context-menu':
|
||||
specifier: workspace:*
|
||||
version: link:../../client/ui-context-menu
|
||||
'@deepseek-ai/dsh-client-ui-conversation':
|
||||
specifier: workspace:*
|
||||
version: link:../../client/ui-conversation
|
||||
@@ -9358,6 +9364,9 @@ importers:
|
||||
'@deepseek-ai/dsh-client-ui-session':
|
||||
specifier: workspace:*
|
||||
version: link:../../client/ui-session
|
||||
'@deepseek-ai/dsh-client-ui-session-panel':
|
||||
specifier: workspace:*
|
||||
version: link:../../client/ui-session-panel
|
||||
'@deepseek-ai/dsh-client-ui-sidebar-right':
|
||||
specifier: workspace:*
|
||||
version: link:../../client/ui-sidebar-right
|
||||
|
||||
Reference in new issue
Block a user