diff --git a/apps/web/tests/session-panel-layout.e2e.ts b/apps/web/tests/session-panel-layout.e2e.ts index 3526d22931..7036560cb6 100644 --- a/apps/web/tests/session-panel-layout.e2e.ts +++ b/apps/web/tests/session-panel-layout.e2e.ts @@ -392,10 +392,12 @@ describe.skipIf(MODE === 'record')('web e2e: Session panel layout', () => { const registered = ['environment', 'subagents', 'background-jobs'] await expect.poll(order, { timeout: 20_000 }).toEqual(registered) - // At rest the handle keeps its column and does not show; over the title row it shows, on the rows' More column. + // At rest the handle does not show and takes no room: the title's trailing count runs to the row's 6px padding. + // Over the title row the handle shows on the rows' More column, and the count stays where it was and fades under it. await page.mouse.move(5, 5) const handle = (id: string) => head(id).evaluate((element) => { const button = element.querySelector('[data-session-panel-grip]')! + const trailing = element.children[1] as HTMLElement const box = element.getBoundingClientRect() const target = button.getBoundingClientRect() return { @@ -403,14 +405,17 @@ describe.skipIf(MODE === 'record')('web e2e: Session panel layout', () => { opacity: getComputedStyle(button).opacity, target: [target.width, target.height], center: box.right - (target.left + target.width / 2), + trailing: trailing.textContent, + trailingEnd: box.right - trailing.getBoundingClientRect().right, + faded: getComputedStyle(trailing).maskImage !== 'none', } }) - const resting = { cursor: 'grab', target: [24, 24], center: 14 } - expect(await handle('subagents')).toEqual({ ...resting, opacity: '0' }) + const resting = { cursor: 'grab', target: [24, 24], center: 14, trailing: '1 external', trailingEnd: 6 } + expect(await handle('subagents')).toEqual({ ...resting, opacity: '0', faded: false }) await head('subagents').hover() await expect.poll(async () => (await handle('subagents')).opacity).toBe('1') - expect(await handle('subagents')).toEqual({ ...resting, opacity: '1' }) - expect((await handle('background-jobs')).opacity).toBe('0') + expect(await handle('subagents')).toEqual({ ...resting, opacity: '1', faded: true }) + expect(await grip('background-jobs').evaluate(element => getComputedStyle(element).opacity)).toBe('0') // Drag Background jobs by its title row onto the upper half of Environment. const from = (await head('background-jobs').boundingBox())! diff --git a/packages/client/ui-session-panel/README.i18n.yaml b/packages/client/ui-session-panel/README.i18n.yaml index 704cbbb28a..ff7630a902 100644 --- a/packages/client/ui-session-panel/README.i18n.yaml +++ b/packages/client/ui-session-panel/README.i18n.yaml @@ -24,11 +24,11 @@ en: 275d7ee3241b5cb4 zh: c3823108af08a10e /deepseek-ai-dsh-client-ui-session-panel/use-this-package/section-order: - en: a29dad8bfe07f190 - zh: 06c20cd9a96930d3 + en: 8827dc803c305d40 + zh: e6f53d1888351f8b /deepseek-ai-dsh-client-ui-session-panel/use-this-package/contribute-a-section: - en: ab60e3caa3fa8c16 - zh: 423fde36894023b3 + en: 2d4b89484e2bbd35 + zh: 8eeee872b5a4c78e /deepseek-ai-dsh-client-ui-session-panel/understand-the-implementation: en: 45a4a1e0170077bc zh: 864a924066f14b76 diff --git a/packages/client/ui-session-panel/README.md b/packages/client/ui-session-panel/README.md index 2735dd3467..f8d5c1fa3c 100644 --- a/packages/client/ui-session-panel/README.md +++ b/packages/client/ui-session-panel/README.md @@ -47,14 +47,14 @@ Pinning also sets the docking preference, so pinning a panel that the toggle had ### Section order -Sections show in ascending `order` until the reader arranges them. Each section's title row is a drag source: over it the pointer is a grab cursor and a drag handle shows at the row's end, in the column of the rows' More buttons. The handle's column is always kept, so the title's trailing controls do not move when the handle shows; it shows on hover of the title row, on keyboard focus, during a drag, and always without hover. Dragging the row dims its section, and the section under the pointer shows a 2px line on its top or bottom edge, whichever half the pointer is over; a drop moves the dragged section there. +Sections show in ascending `order` until the reader arranges them. Each section's title row is a drag source: over it the pointer is a grab cursor and a drag handle shows over the row's end, in the column of the rows' More buttons. The handle takes no room in the row: the title's trailing content, such as a count, runs to the row's end, stays in place when the handle shows, and fades out under it. The handle shows while the pointer is over the title row, while it has keyboard focus, and during a drag. Dragging the row dims its section, and the section under the pointer shows a 2px line on its top or bottom edge, whichever half the pointer is over; a drop moves the dragged section there. The handle is a button named “Reorder” with the section's title, and its tooltip says how to reorder. With focus on it, the up and down arrow keys move the section past the nearest section that shows, and focus stays on the handle. The order is one preference for every Session, persisted in `localStorage` under `dsh.sessionPanel.sectionOrder` as the ids of every live section, including the ones with nothing to show. A section registered after the reader arranged the others follows the section it follows in the registered order. ### Contribute a section -A section is one `conversation.session.panel.section` list registration: `id` addresses it, `order` sorts it ascending until the reader [arranges the sections](#section-order), 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`), [Shared tasks](../ui-agent-team/README.md) (`250`), and [Background jobs](../ui-jobs/README.md) (`300`). +A section is one `conversation.session.panel.section` list registration: `id` addresses it, `order` sorts it ascending until the reader [arranges the sections](#section-order), 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 content, such as a count, in the keyed `conversation.session.panel.section.actions` slot under the section's `id`; the [drag handle](#section-order) covers its last 20px while the title row is hovered, so a control placed there keeps clear of the row's end. 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`), [Shared tasks](../ui-agent-team/README.md) (`250`), 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`, whose rows receive the same owner props as a section; its `project` row (`order: 0`) shows the Session's working folder: the current directory from the `workingDirectory` projection, or, before the projection arrives or when it records none, the directory the Session was created in, then the directory of the Workspace that lists the Session. The row shows the folder name followed by its parent folder in tertiary ink, which clips with an ellipsis; its tooltip, shown after 500ms of hover, names the working folder and gives the full path. Both abbreviate the Host home 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. diff --git a/packages/client/ui-session-panel/README.zh.md b/packages/client/ui-session-panel/README.zh.md index 8504e5fc6d..ccf5c2ffa0 100644 --- a/packages/client/ui-session-panel/README.zh.md +++ b/packages/client/ui-session-panel/README.zh.md @@ -47,14 +47,14 @@ kind: "package-reference" ### 分栏顺序 -用户调整之前,分栏按 `order` 升序显示。每个分栏的标题行都可以拖动:指针移到标题行上时变为抓手,行末出现拖动图标,位于各行「更多」按钮所在的那一列。图标所在的列始终保留,因此图标出现时标题行末尾的控件不会移动;图标在悬停标题行、键盘聚焦、拖动期间显示,在不支持悬停的设备上始终显示。拖动标题行时,该分栏变淡,指针下方的分栏在上边缘或下边缘显示一条 2px 的线,取决于指针位于它的上半还是下半;松开后被拖动的分栏移到那里。 +用户调整之前,分栏按 `order` 升序显示。每个分栏的标题行都可以拖动:指针移到标题行上时变为抓手,拖动图标浮现在行末,位于各行「更多」按钮所在的那一列。图标不占用标题行的空间:标题行末尾的内容(例如计数)一直排到行末,图标出现时位置不变,被图标盖住的部分渐隐。图标在指针位于标题行上、获得键盘焦点以及拖动期间显示。拖动标题行时,该分栏变淡,指针下方的分栏在上边缘或下边缘显示一条 2px 的线,取决于指针位于它的上半还是下半;松开后被拖动的分栏移到那里。 拖动图标是一个按钮,名称为「调整」加分栏标题,提示文字说明调整顺序的方式。焦点在它上面时,上下方向键让分栏越过最近一个显示着的分栏,焦点留在图标上。顺序是所有会话共用的一个偏好,以全部有效分栏(包括当前没有内容的分栏)的 id 列表存放在 `localStorage` 的 `dsh.sessionPanel.sectionOrder` 中。用户调整之后才注册的分栏,排在按注册顺序位于它前面的那个分栏之后。 ### 贡献分栏 -一个分栏是 `conversation.session.panel.section` 列表里的一次注册:`id` 用于寻址,`order` 在用户[调整分栏顺序](#section-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-agent-team/README.zh.md)(`250`)和[「后台任务」](../ui-jobs/README.zh.md)(`300`)。 +一个分栏是 `conversation.session.panel.section` 列表里的一次注册:`id` 用于寻址,`order` 在用户[调整分栏顺序](#section-order)之前决定升序排列,必填的 `label` 是标题,面板按当前语言绘制。分栏组件通过 owner props 收到 `presentation`(`docked` 或 `overlay`)和 `dismissOverlay()`;它负责渲染正文,没有内容时什么都不渲染,标题随之隐藏。标题尾部的内容(例如计数)注册到以分栏 `id` 为键的 keyed slot `conversation.session.panel.section.actions`;悬停标题行时,[拖动图标](#section-order)会盖住它末尾的 20px,因此放在那里的控件要避开行末。缺少 label 的分栏会报告到控制台,并且不显示。内置的分栏依次是「环境」(`order: 0`)、[forge 套件](../../experimental/client-ui-forge/README.zh.md)的「变更请求」(`100`)、[「子智能体」](../ui-subagent/README.zh.md)(`200`)、[「共享任务」](../ui-agent-team/README.zh.md)(`250`)和[「后台任务」](../ui-jobs/README.zh.md)(`300`)。 多个插件共用一个标题时,把行注册到分栏拥有者的行 slot 中。内置「环境」分栏(`id: 'environment'`,`order: 0`)声明 `conversation.session.panel.environment.row`,其中的行与分栏收到相同的 owner props;其 `project` 行(`order: 0`)显示会话的工作目录:`workingDirectory` 投影记录的当前目录;投影尚未送达或没有记录时,依次取会话创建时所在的目录、列出本会话的工作区目录。该行先显示目录名,再以三级文字色显示父目录,放不下时以省略号截断;悬停 500ms 后出现的提示写明工作目录并给出完整路径。两处都把宿主家目录缩写为 `~`。右键该行或点其「更多」按钮会打开共享的 `directory` 上下文菜单。forge 套件在 order 20 与 30 处添加检出行与本地变更行。拥有共享分栏的插件用同样方式声明自己的行 slot。 diff --git a/packages/client/ui-session-panel/src/client/SessionPanel.module.css b/packages/client/ui-session-panel/src/client/SessionPanel.module.css index e79a7ec1a8..e1a2fbc697 100644 --- a/packages/client/ui-session-panel/src/client/SessionPanel.module.css +++ b/packages/client/ui-session-panel/src/client/SessionPanel.module.css @@ -195,8 +195,9 @@ border-top: 0.5px solid var(--dsw-alias-border-l2); } -/* The title row is the section's drag source. */ +/* The title row is the section's drag source, and the box its drag handle is placed in. */ .head { + position: relative; display: flex; align-items: center; gap: 8px; @@ -233,41 +234,54 @@ display: none; } -/* The drag handle ends the title row in the column of the rows' More - buttons: a 16px column whose 24px target reaches past it, as theirs does. - The column is always there, so the title's trailing controls do not move - when the handle shows: on hover of the title row, on keyboard focus, during - a drag, and always without hover. The start margin keeps it at the row's - end when the section has no trailing controls. */ +/* The drag handle lies over the end of the title row, in the column of the + rows' More buttons: a 24px target whose center is 14px from the row's + end. It takes no room in the row, so the title's trailing content runs to + the row's end as it does without the handle. The handle shows while the + pointer is over the title row, while it has keyboard focus, and during a + drag; the trailing content then fades out under it. */ .grip { + position: absolute; + top: 0; + right: 2px; display: inline-flex; - flex: none; align-items: center; justify-content: center; width: 24px; height: 24px; - margin: 0 -4px 0 auto; + margin: 0; padding: 0; border: 0; border-radius: var(--dsw-radius-xs); color: var(--dsw-alias-label-tertiary); background: transparent; cursor: grab; + opacity: 0; } .grip:focus-visible { outline-offset: -2px; } +.grip:focus-visible, +.section[data-dragging] .grip { + opacity: 1; +} + +/* The trailing content ends 6px from the row's end and the handle reaches + 26px from it: transparent across the handle, opaque 16px further in. */ +.head:has(> .grip:focus-visible) > .actions, +.section[data-dragging] > .head > .actions { + mask-image: linear-gradient(to left, transparent 20px, #000 36px); +} + @media (hover: hover) { - .grip { - opacity: 0; + .head:hover > .grip { + opacity: 1; } - .head:hover > .grip, - .grip:focus-visible, - .section[data-dragging] .grip { - opacity: 1; + .head:hover > .actions { + mask-image: linear-gradient(to left, transparent 20px, #000 36px); } .grip:hover { diff --git a/packages/client/ui-session-panel/src/client/slots.ts b/packages/client/ui-session-panel/src/client/slots.ts index e40b0c5d9a..1aa5053bf2 100644 --- a/packages/client/ui-session-panel/src/client/slots.ts +++ b/packages/client/ui-session-panel/src/client/slots.ts @@ -26,7 +26,11 @@ declare module '@deepseek-ai/dsh-client-ui-slots' { scope: 'session' owner: SessionPanelSectionOwnerProps } - /** Trailing controls of one section title, keyed by the section's `id`. */ + /** + * Trailing content of one section title, such as a count, keyed by the + * section's `id`. The section's drag handle covers its last 20px while the + * title row is hovered, and the content fades out under it. + */ 'conversation.session.panel.section.actions': { kind: 'keyed'; scope: 'session' } /** * Marks over the panel toggle, such as an attention dot. Each occupant is diff --git a/packages/client/ui-session-panel/tests/session-panel-styles.client.spec.ts b/packages/client/ui-session-panel/tests/session-panel-styles.client.spec.ts index 600b132bb9..d6d5b0d6b7 100644 --- a/packages/client/ui-session-panel/tests/session-panel-styles.client.spec.ts +++ b/packages/client/ui-session-panel/tests/session-panel-styles.client.spec.ts @@ -106,18 +106,24 @@ describe('SessionPanel.module.css docking geometry', () => { }) describe('SessionPanel.module.css section reordering', () => { - it('makes the title row a drag source and ends it with a handle on the More column, whose room is always kept', () => { - expect(declarationsOf('.head')['cursor']).toBe('grab') - // A 16px column like the rows' menu part: the 24px target reaches 4px past it on both sides. + it('makes the title row a drag source and lays the handle over its end, on the More column, without taking room in the row', () => { + expect(declarationsOf('.head')).toMatchObject({ cursor: 'grab', position: 'relative' }) + // Out of the row's flow: 2px in and 24px wide puts its center 14px from the row's end, the rows' More column. expect(declarationsOf('.grip')).toMatchObject({ - 'flex': 'none', 'width': '24px', 'height': '24px', 'margin': '0 -4px 0 auto', 'cursor': 'grab', - 'color': 'var(--dsw-alias-label-tertiary)', 'background': 'transparent', + 'position': 'absolute', 'top': '0', 'right': '2px', 'width': '24px', 'height': '24px', 'margin': '0', 'cursor': 'grab', + 'color': 'var(--dsw-alias-label-tertiary)', 'background': 'transparent', 'opacity': '0', }) - // It hides by opacity, never by display, so the trailing controls keep their place when it shows. - expect(declarationsOf('.grip')['display']).toBe('inline-flex') + }) + + it('shows the handle on title-row hover, keyboard focus, and during a drag, and fades the trailing content under it', () => { + const fade = 'linear-gradient(to left, transparent 20px, #000 36px)' + expect(declarationsOf('.grip:focus-visible, .section[data-dragging] .grip')).toEqual({ opacity: '1' }) + expect(declarationsOf('.head:has(> .grip:focus-visible) > .actions, .section[data-dragging] > .head > .actions')) + .toEqual({ 'mask-image': fade }) + // The pointer rules stay inside the hover media query, so a touch that latches hover shows no handle. const hover = [...css.matchAll(/@media \(hover: hover\) \{([\s\S]*?)\n\}/g)].map(block => block[1]).join('\n') - expect(hover).toMatch(/\.grip \{\s*opacity: 0;/) - expect(hover).toMatch(/\.head:hover > \.grip,\s*\.grip:focus-visible,\s*\.section\[data-dragging\] \.grip \{\s*opacity: 1;/) + expect(hover).toMatch(/\.head:hover > \.grip \{\s*opacity: 1;/) + expect(hover).toContain(`.head:hover > .actions {\n mask-image: ${fade};`) }) it('dims the dragged section and draws the landing line on the edge of the section under the pointer', () => { diff --git a/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts b/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts index a33e77ee03..f9fa4f6363 100644 --- a/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts +++ b/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts @@ -2465,7 +2465,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], 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}', - source: 'packages/client/ui-session-panel/src/client/slots.ts:46', + source: 'packages/client/ui-session-panel/src/client/slots.ts:50', }, { key: 'conversation.session.panel.indicator', @@ -2529,7 +2529,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], 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:39', + source: 'packages/client/ui-session-panel/src/client/slots.ts:43', }, { key: 'conversation.session.panel.section', @@ -2603,8 +2603,8 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ key: 'conversation.session.panel.section.actions', kind: 'keyed', scope: 'session', - summary: 'Trailing controls of one section title, keyed by the section\'s `id`.', - doc: 'Trailing controls of one section title, keyed by the section\'s `id`.', + summary: 'Trailing content of one section title, such as a count, keyed by the section\'s `id`.', + doc: 'Trailing content of one section title, such as a count, keyed by the\nsection\'s `id`. The section\'s drag handle covers its last 20px while the\ntitle row is hovered, and the content fades out under it.', registerOptions: [ { name: 'key', @@ -2647,7 +2647,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], 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: \'\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-session-panel/src/client/slots.ts:30', + source: 'packages/client/ui-session-panel/src/client/slots.ts:34', }, { key: 'conversation.trajectory.images',