From 968223aaa2343382bad9b3afe91b53027d9a8ef9 Mon Sep 17 00:00:00 2001 From: LegGasai Date: Thu, 5 Nov 2026 17:15:29 +0800 Subject: [PATCH 01/35] feat(web): add the floating Session panel Add dsh-client-ui-session-panel: a Session header toggle and a floating panel seated in the main Conversation body. Plugins register sections (id, order, label) and title controls; the built-in Environment section shows the project directory and accepts rows from other plugins. The panel docks only while the transcript's end gutter can hold it; the Conversation width controls report that gutter through ctx.uiConversation.layouts. A narrower gutter hides it, and the toggle then opens a transient overlay. The turn rail moves to the start edge. --- .../2026-11-05-session-panel.i18n.yaml | 28 ++ .../feature/2026-11-05-session-panel.md | 47 +++ .../feature/2026-11-05-session-panel.zh.md | 47 +++ docs/config-catalog.md | 1 + docs/config-catalog.zh.md | 1 + docs/module-graph.md | 2 + docs/module-graph.zh.md | 2 + docs/subsystems/slots.i18n.yaml | 4 +- docs/subsystems/slots.md | 11 +- docs/subsystems/slots.zh.md | 11 +- packages/bundle/web-app/cordis.patch.yml | 5 + packages/bundle/web-app/package.json | 1 + packages/client/README.i18n.yaml | 4 +- packages/client/README.md | 1 + packages/client/README.zh.md | 1 + packages/client/ui-chat/README.i18n.yaml | 4 +- packages/client/ui-chat/README.md | 2 +- packages/client/ui-chat/README.zh.md | 2 +- .../src/client/chat/TurnNavigator.module.css | 15 +- .../client/ui-conversation/README.i18n.yaml | 4 +- packages/client/ui-conversation/README.md | 2 + packages/client/ui-conversation/README.zh.md | 2 + .../ui-conversation/src/client/apply.ts | 11 +- .../src/client/contract/slots.ts | 37 +++ .../src/client/conversation/assembly.ts | 3 + .../src/client/conversation/layouts.ts | 72 ++++ .../ui-conversation/src/client/index.ts | 4 +- .../client/skeleton/ConversationContent.tsx | 25 +- .../skeleton/ConversationWidthControls.tsx | 25 +- .../tests/skeleton.client.spec.tsx | 62 +++- .../client/ui-primitives/README.i18n.yaml | 4 +- packages/client/ui-primitives/README.md | 1 + packages/client/ui-primitives/README.zh.md | 1 + .../ui-primitives/src/PanelRow.module.css | 78 +++++ .../client/ui-primitives/src/PanelRow.tsx | 40 +++ packages/client/ui-primitives/src/index.ts | 2 + .../tests/panel-row.client.spec.tsx | 41 +++ .../client/ui-session-panel/README.i18n.yaml | 43 +++ packages/client/ui-session-panel/README.md | 109 ++++++ packages/client/ui-session-panel/README.zh.md | 109 ++++++ .../client/ui-session-panel/locale/de.json | 6 + .../client/ui-session-panel/locale/en.json | 6 + .../client/ui-session-panel/locale/es.json | 6 + .../client/ui-session-panel/locale/fr.json | 6 + .../client/ui-session-panel/locale/ja.json | 6 + .../client/ui-session-panel/locale/pt.json | 6 + .../client/ui-session-panel/locale/ru.json | 6 + .../client/ui-session-panel/locale/zh.json | 6 + packages/client/ui-session-panel/package.json | 78 +++++ .../src/client/EnvironmentSection.tsx | 13 + .../src/client/ProjectRow.module.css | 12 + .../src/client/ProjectRow.tsx | 38 +++ .../src/client/SessionPanel.module.css | 93 ++++++ .../src/client/SessionPanel.tsx | 93 ++++++ .../src/client/SessionPanelToggle.module.css | 39 +++ .../src/client/SessionPanelToggle.tsx | 39 +++ .../src/client/element-ids.ts | 20 ++ .../ui-session-panel/src/client/index.ts | 99 ++++++ .../ui-session-panel/src/client/locales.ts | 79 +++++ .../ui-session-panel/src/client/sections.ts | 66 ++++ .../ui-session-panel/src/client/slots.ts | 132 ++++++++ .../ui-session-panel/src/client/visibility.ts | 89 +++++ .../ui-session-panel/src/css-modules.d.ts | 4 + packages/client/ui-session-panel/src/index.ts | 9 + .../tests/browser-plugin.client.spec.ts | 144 ++++++++ .../tests/components.client.spec.tsx | 272 +++++++++++++++ .../tests/sections.client.spec.ts | 43 +++ .../tests/visibility.client.spec.ts | 89 +++++ .../client/ui-session-panel/tsconfig.json | 57 ++++ .../client/ui-session-panel/tsdown.config.ts | 3 + .../src/client/slot-catalog.ts | 310 ++++++++++++++++-- .../references/packages.md | 1 + pnpm-lock.yaml | 66 ++++ .../verify-package-readme-model-experience.ts | 1 + tsconfig.base.json | 2 + tsconfig.client.json | 1 + 76 files changed, 2743 insertions(+), 61 deletions(-) create mode 100644 .agents/notes/implemented/feature/2026-11-05-session-panel.i18n.yaml create mode 100644 .agents/notes/implemented/feature/2026-11-05-session-panel.md create mode 100644 .agents/notes/implemented/feature/2026-11-05-session-panel.zh.md create mode 100644 packages/client/ui-conversation/src/client/conversation/layouts.ts create mode 100644 packages/client/ui-primitives/src/PanelRow.module.css create mode 100644 packages/client/ui-primitives/src/PanelRow.tsx create mode 100644 packages/client/ui-primitives/tests/panel-row.client.spec.tsx create mode 100644 packages/client/ui-session-panel/README.i18n.yaml create mode 100644 packages/client/ui-session-panel/README.md create mode 100644 packages/client/ui-session-panel/README.zh.md create mode 100644 packages/client/ui-session-panel/locale/de.json create mode 100644 packages/client/ui-session-panel/locale/en.json create mode 100644 packages/client/ui-session-panel/locale/es.json create mode 100644 packages/client/ui-session-panel/locale/fr.json create mode 100644 packages/client/ui-session-panel/locale/ja.json create mode 100644 packages/client/ui-session-panel/locale/pt.json create mode 100644 packages/client/ui-session-panel/locale/ru.json create mode 100644 packages/client/ui-session-panel/locale/zh.json create mode 100644 packages/client/ui-session-panel/package.json create mode 100644 packages/client/ui-session-panel/src/client/EnvironmentSection.tsx create mode 100644 packages/client/ui-session-panel/src/client/ProjectRow.module.css create mode 100644 packages/client/ui-session-panel/src/client/ProjectRow.tsx create mode 100644 packages/client/ui-session-panel/src/client/SessionPanel.module.css create mode 100644 packages/client/ui-session-panel/src/client/SessionPanel.tsx create mode 100644 packages/client/ui-session-panel/src/client/SessionPanelToggle.module.css create mode 100644 packages/client/ui-session-panel/src/client/SessionPanelToggle.tsx create mode 100644 packages/client/ui-session-panel/src/client/element-ids.ts create mode 100644 packages/client/ui-session-panel/src/client/index.ts create mode 100644 packages/client/ui-session-panel/src/client/locales.ts create mode 100644 packages/client/ui-session-panel/src/client/sections.ts create mode 100644 packages/client/ui-session-panel/src/client/slots.ts create mode 100644 packages/client/ui-session-panel/src/client/visibility.ts create mode 100644 packages/client/ui-session-panel/src/css-modules.d.ts create mode 100644 packages/client/ui-session-panel/src/index.ts create mode 100644 packages/client/ui-session-panel/tests/browser-plugin.client.spec.ts create mode 100644 packages/client/ui-session-panel/tests/components.client.spec.tsx create mode 100644 packages/client/ui-session-panel/tests/sections.client.spec.ts create mode 100644 packages/client/ui-session-panel/tests/visibility.client.spec.ts create mode 100644 packages/client/ui-session-panel/tsconfig.json create mode 100644 packages/client/ui-session-panel/tsdown.config.ts diff --git a/.agents/notes/implemented/feature/2026-11-05-session-panel.i18n.yaml b/.agents/notes/implemented/feature/2026-11-05-session-panel.i18n.yaml new file mode 100644 index 0000000000..4bd1f78eff --- /dev/null +++ b/.agents/notes/implemented/feature/2026-11-05-session-panel.i18n.yaml @@ -0,0 +1,28 @@ +# Bilingual-pair consistency record for 2026-11-05-session-panel.md (docs/i18n/README.md): per heading +# section, a hash of its English and Chinese blocks outside code blocks and generated regions. +# After editing either side, bring the other along and re-record with: +# pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-11-05-session-panel.md +/agent-note-session-panel-over-the-conversation-body-s-end-gutter: + en: e4548a86fa537e4a + zh: 87821d4285485faa +/agent-note-session-panel-over-the-conversation-body-s-end-gutter/problem: + en: c69d9843bc6f0b87 + zh: c31bb1b2b4d9b781 +/agent-note-session-panel-over-the-conversation-body-s-end-gutter/decision: + en: 547fe8129b027892 + zh: dc0807d782f551ae +/agent-note-session-panel-over-the-conversation-body-s-end-gutter/decision/docking-follows-the-transcript-gutter: + en: 150a7e8bf3ad556a + zh: c40fcf40af63b353 +/agent-note-session-panel-over-the-conversation-body-s-end-gutter/decision/sections-are-registrations-the-panel-draws-titles: + en: f8e69329e832c764 + zh: 2453aa8e794f46f5 +/agent-note-session-panel-over-the-conversation-body-s-end-gutter/decision/the-turn-rail-moves-to-the-start-edge: + en: 05a494885d439fde + zh: 1dc65e5266a9c7b1 +/agent-note-session-panel-over-the-conversation-body-s-end-gutter/alternatives-considered: + en: 9cf81cde02bf900b + zh: 549d92a260541e3d +/agent-note-session-panel-over-the-conversation-body-s-end-gutter/consequences: + en: c1f661c6a62953b6 + zh: 8642f081c2879307 diff --git a/.agents/notes/implemented/feature/2026-11-05-session-panel.md b/.agents/notes/implemented/feature/2026-11-05-session-panel.md new file mode 100644 index 0000000000..ca4b96e4ab --- /dev/null +++ b/.agents/notes/implemented/feature/2026-11-05-session-panel.md @@ -0,0 +1,47 @@ +# Agent Note: Session panel over the Conversation body's end gutter + +Status: implemented + +English | [中文](2026-11-05-session-panel.zh.md) + +## Problem + +Facts about the current Session — its project directory, the change requests it opened, and later its outputs — had no common home. Each owner added its own Session header button and, for anything larger than a menu, a right-sidebar tab: the forge change requests are one such tab. A sidebar tab takes width from the transcript while it shows, shows one tab at a time, and leaves the facts one click away from every message. The required surface is a summary the user can keep beside the conversation without covering it, that several plugins fill independently, that hides when there is no room, and that the user can show or hide from the Session header. + +## Decision + +[`dsh-client-ui-session-panel`](../../../../packages/client/ui-session-panel/README.md) adds a Session header toggle (`conversation.session.header.utilities`, order −10) and a floating panel that [`ui-conversation`](../../../../packages/client/ui-conversation/README.md) seats inside the main Conversation body as `conversation.session.panel`. The seat renders only for the main occurrence of an active Session, beside the width handles and outside the scrollport, so the panel neither scrolls with the transcript nor appears in embedded occurrences or on the blank home. + +### Docking follows the transcript gutter + +The panel docks only while the gutter between the transcript column and the body's end edge can hold it (344px: 48px clear of the column and its width handle, a 280px minimum width, and a 16px margin). The gutter, not the viewport width, decides because the column width is adaptive and user-draggable and the right sidebar shares the frame: the same viewport can leave 75px or 600px. The Conversation width controls already measure the body and resolve the column width, so they report the gutter after each measurement and drag frame into `ctx.uiConversation.layouts`, a per-Session source on the existing Conversation service. View activation reports whether the active View follows the transcript column; every View other than Chat fills the body, so the gutter reads zero there. + +The toggle and the panel read that source and one plugin-owned visibility state and decide the presentation with the same pure function. The toggle therefore reports `aria-expanded` truthfully and knows whether a press flips docking or opens the overlay, which a CSS-only container query cannot tell an element outside the body. + +Docking follows one persisted preference shared by every Session and defaults to on. Without room, a press opens a transient overlay for that Session above the transcript and the composer stack; it never changes the preference, and docking from a wide gutter closes it. Hiding automatically and overlaying on request keeps the transcript uncovered without making the facts unreachable on laptop widths. + +### Sections are registrations; the panel draws titles + +Each section is one list registration with `id`, `order`, and a required `label`. The panel projects the live registrations into titles, draws each title, and renders the section body with `renderSlot(..., { only: id })`; a CSS `:has()` rule hides a section whose body rendered nothing, so a section opts out by rendering nothing and no effect reports visibility to the owner. Trailing title controls are a keyed slot addressed by the section `id`, and a section that several plugins share declares its own row slot, as the built-in Environment section does with `conversation.session.panel.environment.row`. Marks that must stay visible while the panel is hidden go in an indicator list over the toggle. + +Rows from every contributor use the `PanelRow` primitive so icon, text, and trailing areas align across packages; a feature package cannot share its own row component with another feature package. + +### The turn rail moves to the start edge + +The turn rail used the end edge of the scrollport, which the docked panel now occupies. It moves to the start edge with its marks, focus ring, and preview mirrored; its existing 900px hiding rule still guarantees room beside the start-side width handle. + +## Alternatives considered + +- **A right-sidebar tab.** It already exists for change requests, but it narrows the transcript while shown, shows one tab at a time, and the [UI guidance](../../../skills/dsh-client-ui-ux/SKILL.md#reuse-before-adding) reserves the sidebar for content opened on demand rather than a resident summary. +- **The dock kit's floating window.** `FloatLayer` windows are draggable, resizable, and positioned in viewport coordinates; a summary anchored to the transcript gutter needs none of that and would have to fight the window's own placement rules. +- **Viewport-width breakpoints.** The transcript width is adaptive and draggable and the right sidebar takes a variable track, so a viewport breakpoint either covers the transcript or hides the panel with room to spare. +- **CSS-only hiding with a click-time read.** A container query on the gutter can hide the docked panel, and the toggle could read the computed result when pressed, as the background-job trigger does. The toggle would still render without knowing whether the panel shows, so `aria-expanded` and its tooltip would be wrong whenever the preference says dock but the gutter is too narrow. +- **Squeezing the transcript to make room.** Docking on laptop widths by moving the transcript column aside changes the centered column, the composer, and both width handles; it remains a separate layout decision. +- **A Session-scoped standard hook for the layout.** Adding `useConversationLayout` to every Session-scoped Slot made every component fixture in the client restate it; the layout has two readers, so a source on the existing Conversation service serves them without widening the standard props. + +## Consequences + +- With the default transcript width the body must be about 1608px wide to dock, so laptop widths use the overlay; the panel never covers the transcript unless the user opens it. +- Sections from independent plugins share one surface, ordering, and title style without depending on each other, and an occupied section id can be replaced by a higher-priority registration. +- The Conversation width controls gained one callback and the Conversation service one per-Session source; the composer stack height now lands on the content body so chrome outside the scrollport can read it. +- The turn rail's position changed for every user; its behavior and hiding rule did not. diff --git a/.agents/notes/implemented/feature/2026-11-05-session-panel.zh.md b/.agents/notes/implemented/feature/2026-11-05-session-panel.zh.md new file mode 100644 index 0000000000..136ceff8a0 --- /dev/null +++ b/.agents/notes/implemented/feature/2026-11-05-session-panel.zh.md @@ -0,0 +1,47 @@ +# Agent Note: 停靠在对话正文末端留白的会话面板 + +Status: implemented + +[English](2026-11-05-session-panel.md) | 中文 + +## Problem + +与当前会话相关的信息(项目目录、它开出的变更请求,以及之后的产物)没有统一的位置。各自的拥有者分别加会话标题栏按钮,内容一多就再开一个右侧栏标签页,forge 的变更请求就是这样一个标签页。侧栏标签页显示时占用正文宽度,一次只显示一个,而且每条消息之外都要多点一次才能看到。需要的界面是:可以放在对话旁边常驻而不遮挡正文;多个插件各自填充;没有空间时自动隐藏;用户可以从会话标题栏显示或隐藏。 + +## Decision + +[`dsh-client-ui-session-panel`](../../../../packages/client/ui-session-panel/README.zh.md) 新增一个会话标题栏开关(`conversation.session.header.utilities`,order −10)和一块悬浮面板,由 [`ui-conversation`](../../../../packages/client/ui-conversation/README.zh.md) 以 `conversation.session.panel` 落位在主对话正文内。落位只为活跃会话的主 occurrence 渲染,与宽度拖拽条同层、位于滚动容器之外,因此面板不随正文滚动,也不会出现在嵌入式 occurrence 或空白首页。 + +### 停靠取决于正文留白 + +只有正文列到正文末端边缘的留白放得下面板时才停靠(344px:与正文列及其宽度拖拽条保持 48px,最小宽度 280px,外加 16px 边距)。判断依据是留白而不是视口宽度,因为正文列宽度可自适应、可由用户拖拽,右侧栏也会占用框架宽度:同一个视口可能只剩 75px,也可能有 600px。Conversation 宽度控件本来就测量正文并计算正文列宽度,因此它在每次测量和拖拽帧后把留白上报给 `ctx.uiConversation.layouts`,这是现有 Conversation 服务上的一个按会话划分的 source。View 激活时上报当前 View 是否跟随正文列;Chat 以外的 View 都占满正文,所以此时留白读数为零。 + +开关和面板读取同一个 source 和同一份插件持有的可见性状态,并用同一个纯函数决定呈现方式。因此开关能如实报告 `aria-expanded`,也知道按下后是切换停靠还是打开浮层;纯 CSS 的容器查询无法把结果告诉正文之外的元素。 + +停靠遵循所有会话共用的一个持久化偏好,默认开启。没有空间时,按下开关会为该会话在正文和 composer 区域上方打开临时浮层;它从不改变偏好,宽留白下切换停靠也会关闭浮层。自动隐藏加按需浮层,既保证正文不被遮挡,也让笔记本宽度下的信息依然可达。 + +### 分栏是注册项;面板绘制标题 + +每个分栏是一次 list 注册,带 `id`、`order` 和必填的 `label`。面板把实时注册投影成标题并逐个绘制,再用 `renderSlot(..., { only: id })` 渲染分栏正文;CSS `:has()` 规则隐藏正文没有渲染内容的分栏,因此分栏不渲染任何内容即可退出,不需要 effect 向拥有者上报可见性。标题尾部控件是以分栏 `id` 为键的 keyed slot;多个插件共用的分栏声明自己的行 slot,内置「环境」分栏就以 `conversation.session.panel.environment.row` 这样做。面板隐藏时也要可见的标记放进开关上的角标列表。 + +所有贡献方的行都使用 `PanelRow` 原语,使不同包的图标、文字与尾部区域对齐;功能包之间不能共享各自的行组件。 + +### 轮次轨道移到起始边 + +轮次轨道原先贴在滚动容器末端边缘,停靠面板现在占用这里。轨道连同刻度、焦点环和预览镜像到起始边;原有的 900px 隐藏规则仍保证它旁边有足够空间容纳起始侧的宽度拖拽条。 + +## Alternatives considered + +- **右侧栏标签页。** 变更请求已有这种实现,但它显示时会压窄正文,一次只显示一个标签页,而且 [UI 指南](../../../skills/dsh-client-ui-ux/SKILL.md#reuse-before-adding)把侧栏留给按需打开的内容,而不是常驻摘要。 +- **dock kit 的悬浮窗。** `FloatLayer` 窗口可拖拽、可缩放、按视口坐标定位;锚定在正文留白的摘要用不上这些能力,还要对抗窗口自身的定位规则。 +- **按视口宽度断点。** 正文宽度自适应、可拖拽,右侧栏占用可变宽度,视口断点要么遮挡正文,要么在空间充足时也隐藏面板。 +- **纯 CSS 隐藏加点击时读取。** 对留白做容器查询可以隐藏停靠面板,开关在按下时读取计算结果,与后台任务按钮的做法相同。但开关渲染时仍不知道面板是否显示,偏好为停靠而留白不足时,`aria-expanded` 与提示文字都会出错。 +- **挤压正文腾出空间。** 在笔记本宽度下把正文列移开来停靠,会改变居中的正文列、composer 和两侧宽度拖拽条;这仍是另一项布局决策。 +- **会话作用域标准 hook。** 给每个会话作用域 Slot 增加 `useConversationLayout`,会让客户端所有组件测试夹具都要补上它;布局只有两个读取方,所以放在现有 Conversation 服务上的 source 即可满足,无需扩大标准 props。 + +## Consequences + +- 在默认正文宽度下,对话区要约 1608px 宽才能停靠,因此笔记本宽度使用浮层;除非用户主动打开,面板不会遮挡正文。 +- 独立插件的分栏共享同一界面、排序和标题样式,彼此不依赖;已占用的分栏 id 可以被更高优先级的注册替换。 +- Conversation 宽度控件多了一个回调,Conversation 服务多了一个按会话划分的 source;composer 区域高度现在写在正文容器上,滚动容器之外的界面元素也能读取。 +- 轮次轨道的位置对所有用户都变了;行为和隐藏规则不变。 diff --git a/docs/config-catalog.md b/docs/config-catalog.md index 77ccb897b6..a495b7a44b 100644 --- a/docs/config-catalog.md +++ b/docs/config-catalog.md @@ -4984,6 +4984,7 @@ These load from a `cordis.yml` entry with no `config:` block; they declare no co | `@deepseek-ai/dsh-client-ui-schedule` | — | [`packages/client/ui-schedule/src/index.ts`](../packages/client/ui-schedule/src/index.ts) | | `@deepseek-ai/dsh-client-ui-secret-mask` | — | [`packages/client/ui-secret-mask/src/index.ts`](../packages/client/ui-secret-mask/src/index.ts) | | `@deepseek-ai/dsh-client-ui-session` | — | [`packages/client/ui-session/src/index.ts`](../packages/client/ui-session/src/index.ts) | +| `@deepseek-ai/dsh-client-ui-session-panel` | — | [`packages/client/ui-session-panel/src/index.ts`](../packages/client/ui-session-panel/src/index.ts) | | `@deepseek-ai/dsh-client-ui-settings` | — | [`packages/client/ui-settings/src/index.ts`](../packages/client/ui-settings/src/index.ts) | | `@deepseek-ai/dsh-client-ui-settings-agent-loop` | — | [`packages/client/ui-settings-agent-loop/src/index.ts`](../packages/client/ui-settings-agent-loop/src/index.ts) | | `@deepseek-ai/dsh-client-ui-settings-general` | — | [`packages/client/ui-settings-general/src/index.ts`](../packages/client/ui-settings-general/src/index.ts) | diff --git a/docs/config-catalog.zh.md b/docs/config-catalog.zh.md index 4d4dde7b7a..924e6c8450 100644 --- a/docs/config-catalog.zh.md +++ b/docs/config-catalog.zh.md @@ -4986,6 +4986,7 @@ export interface Config { | `@deepseek-ai/dsh-client-ui-schedule` | — | [`packages/client/ui-schedule/src/index.ts`](../packages/client/ui-schedule/src/index.ts) | | `@deepseek-ai/dsh-client-ui-secret-mask` | — | [`packages/client/ui-secret-mask/src/index.ts`](../packages/client/ui-secret-mask/src/index.ts) | | `@deepseek-ai/dsh-client-ui-session` | — | [`packages/client/ui-session/src/index.ts`](../packages/client/ui-session/src/index.ts) | +| `@deepseek-ai/dsh-client-ui-session-panel` | — | [`packages/client/ui-session-panel/src/index.ts`](../packages/client/ui-session-panel/src/index.ts) | | `@deepseek-ai/dsh-client-ui-settings` | — | [`packages/client/ui-settings/src/index.ts`](../packages/client/ui-settings/src/index.ts) | | `@deepseek-ai/dsh-client-ui-settings-agent-loop` | — | [`packages/client/ui-settings-agent-loop/src/index.ts`](../packages/client/ui-settings-agent-loop/src/index.ts) | | `@deepseek-ai/dsh-client-ui-settings-general` | — | [`packages/client/ui-settings-general/src/index.ts`](../packages/client/ui-settings-general/src/index.ts) | diff --git a/docs/module-graph.md b/docs/module-graph.md index e5f11c68b4..ef28563415 100644 --- a/docs/module-graph.md +++ b/docs/module-graph.md @@ -191,6 +191,7 @@ flowchart TD pkg_client_ui_schedule["client-ui-schedule"] pkg_client_ui_secret_mask["client-ui-secret-mask"] pkg_client_ui_session["client-ui-session"] + pkg_client_ui_session_panel["client-ui-session-panel"] pkg_client_ui_settings["client-ui-settings"] pkg_client_ui_settings_account["client-ui-settings-account"] pkg_client_ui_settings_agent_loop["client-ui-settings-agent-loop"] @@ -1600,6 +1601,7 @@ flowchart TD | [`client-ui-schedule`](../packages/client/ui-schedule) | `client` | — | | [`client-ui-secret-mask`](../packages/client/ui-secret-mask) | `client` | — | | [`client-ui-session`](../packages/client/ui-session) | `client` | — | +| [`client-ui-session-panel`](../packages/client/ui-session-panel) | `client` | — | | [`client-ui-settings`](../packages/client/ui-settings) | `client` | — | | [`client-ui-settings-account`](../packages/client/ui-settings-account) | `client` | — | | [`client-ui-settings-agent-loop`](../packages/client/ui-settings-agent-loop) | `client` | — | diff --git a/docs/module-graph.zh.md b/docs/module-graph.zh.md index 62a0ff3872..faf8d00c0c 100644 --- a/docs/module-graph.zh.md +++ b/docs/module-graph.zh.md @@ -193,6 +193,7 @@ flowchart TD pkg_client_ui_schedule["client-ui-schedule"] pkg_client_ui_secret_mask["client-ui-secret-mask"] pkg_client_ui_session["client-ui-session"] + pkg_client_ui_session_panel["client-ui-session-panel"] pkg_client_ui_settings["client-ui-settings"] pkg_client_ui_settings_account["client-ui-settings-account"] pkg_client_ui_settings_agent_loop["client-ui-settings-agent-loop"] @@ -1602,6 +1603,7 @@ flowchart TD | [`client-ui-schedule`](../packages/client/ui-schedule) | `client` | — | | [`client-ui-secret-mask`](../packages/client/ui-secret-mask) | `client` | — | | [`client-ui-session`](../packages/client/ui-session) | `client` | — | +| [`client-ui-session-panel`](../packages/client/ui-session-panel) | `client` | — | | [`client-ui-settings`](../packages/client/ui-settings) | `client` | — | | [`client-ui-settings-account`](../packages/client/ui-settings-account) | `client` | — | | [`client-ui-settings-agent-loop`](../packages/client/ui-settings-agent-loop) | `client` | — | diff --git a/docs/subsystems/slots.i18n.yaml b/docs/subsystems/slots.i18n.yaml index a101ff98ea..a6e84e3f31 100644 --- a/docs/subsystems/slots.i18n.yaml +++ b/docs/subsystems/slots.i18n.yaml @@ -3,8 +3,8 @@ # After editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write docs/subsystems/slots.md /web-client-slots: - en: 15c49af3ed8b57ff - zh: e7f9189de6f4334c + en: c3e0c40beeda0651 + zh: a94d81520205694c /web-client-slots/declaration-and-lifecycle: en: f2d2c0d3b8f14ec7 zh: 441ed13ff3f81d2a diff --git a/docs/subsystems/slots.md b/docs/subsystems/slots.md index d13357d0b2..48c059b772 100644 --- a/docs/subsystems/slots.md +++ b/docs/subsystems/slots.md @@ -16,6 +16,8 @@ The root-scoped lists `sidebar.panellist.actions`, `conversation.session.header. [ui-settings](../../packages/client/ui-settings/README.md#filling-the-settings-slots) documents the settings page and navigation-icon extension points. +[ui-session-panel](../../packages/client/ui-session-panel/README.md#contribute-a-section) documents the Session panel's section, title-control, row, and toggle-indicator extension positions. + ## Declaration and lifecycle `SlotMap` is the compile-time registry. A package declaration-merges the key, cardinality, scope, owner props, keyed props, and optional slot-level inject face. The runtime declaration is the matching `children` entry on the component that owns the render location. @@ -145,6 +147,8 @@ root [AppFrame] │ ├─ conversation.session.header.lineage │ ├─ conversation.session.header.actions │ ├─ conversation.session.header.utilities +│ │ └─ id=session-panel [SessionPanelToggle] +│ │ └─ conversation.session.panel.indicator [list, inline] │ ├─ conversation.session.header.views.actions │ └─ conversation.session.header.corner └─ calls Factory: conversation.content @@ -200,7 +204,12 @@ Factory: conversation.content [ConversationContent] ├─ conversation.hero.workspace │ └─ conversation.hero.workspace.directoryFlow ├─ conversation.hero.agentPreset -└─ conversation.hero.options +├─ conversation.hero.options +└─ conversation.session.panel [SessionPanel] + ├─ conversation.session.panel.section [list] + │ └─ id=environment [EnvironmentSection] + │ └─ conversation.session.panel.environment.row [list] + └─ conversation.session.panel.section.actions [keyed] Factory: conversation.chat.user.content [UserContent] ├─ conversation.chat.user.images [MessageImages] diff --git a/docs/subsystems/slots.zh.md b/docs/subsystems/slots.zh.md index 61014d4418..3a9a70b2d1 100644 --- a/docs/subsystems/slots.zh.md +++ b/docs/subsystems/slots.zh.md @@ -16,6 +16,8 @@ root 作用域的 list `sidebar.panellist.actions`、`conversation.session.heade [ui-settings](../../packages/client/ui-settings/README.zh.md#filling-the-settings-slots) 记录设置页面与导航图标扩展点。 +[ui-session-panel](../../packages/client/ui-session-panel/README.zh.md#contribute-a-section) 记录会话面板的分栏、标题控件、行与开关角标扩展位置。 + ## 声明与生命周期 `SlotMap` 是编译期注册表。包通过声明合并写入 key、cardinality(基数)、scope、owner props、keyed props 与可选的 slot 级 inject face。运行时声明则是拥有该渲染位置的组件在 `children` 中给出的对应条目。 @@ -147,6 +149,8 @@ root [AppFrame] │ ├─ conversation.session.header.lineage │ ├─ conversation.session.header.actions │ ├─ conversation.session.header.utilities +│ │ └─ id=session-panel [SessionPanelToggle] +│ │ └─ conversation.session.panel.indicator [list, inline] │ ├─ conversation.session.header.views.actions │ └─ conversation.session.header.corner └─ calls Factory: conversation.content @@ -202,7 +206,12 @@ Factory: conversation.content [ConversationContent] ├─ conversation.hero.workspace │ └─ conversation.hero.workspace.directoryFlow ├─ conversation.hero.agentPreset -└─ conversation.hero.options +├─ conversation.hero.options +└─ conversation.session.panel [SessionPanel] + ├─ conversation.session.panel.section [list] + │ └─ id=environment [EnvironmentSection] + │ └─ conversation.session.panel.environment.row [list] + └─ conversation.session.panel.section.actions [keyed] Factory: conversation.chat.user.content [UserContent] ├─ conversation.chat.user.images [MessageImages] diff --git a/packages/bundle/web-app/cordis.patch.yml b/packages/bundle/web-app/cordis.patch.yml index 59b3473ba5..310b70dc90 100644 --- a/packages/bundle/web-app/cordis.patch.yml +++ b/packages/bundle/web-app/cordis.patch.yml @@ -433,6 +433,11 @@ - id: ui-schedule name: '@deepseek-ai/dsh-client-ui-schedule' + # Session panel: the header toggle and the floating panel over the main + # Conversation body, with the Environment section other plugins extend. + - id: ui-session-panel + name: '@deepseek-ai/dsh-client-ui-session-panel' + # Goal surface: GoalBar in the input dock over the goal session projection. - id: ui-goal name: '@deepseek-ai/dsh-client-ui-goal' diff --git a/packages/bundle/web-app/package.json b/packages/bundle/web-app/package.json index dd4860c5c0..18a9d5b95f 100644 --- a/packages/bundle/web-app/package.json +++ b/packages/bundle/web-app/package.json @@ -105,6 +105,7 @@ "@deepseek-ai/dsh-client-ui-reference": "workspace:*", "@deepseek-ai/dsh-client-ui-renderer": "workspace:*", "@deepseek-ai/dsh-client-ui-schedule": "workspace:*", + "@deepseek-ai/dsh-client-ui-session-panel": "workspace:*", "@deepseek-ai/dsh-client-ui-secret-mask": "workspace:*", "@deepseek-ai/dsh-client-ui-session": "workspace:*", "@deepseek-ai/dsh-client-ui-settings": "workspace:*", diff --git a/packages/client/README.i18n.yaml b/packages/client/README.i18n.yaml index f77d3835d7..07c98c8d89 100644 --- a/packages/client/README.i18n.yaml +++ b/packages/client/README.i18n.yaml @@ -15,8 +15,8 @@ en: 1eb35b015a6c423f zh: a8a3dceee2c9e943 /client-web-gui-browser-half/packages: - en: 2165938f26300774 - zh: 5f739534a8509545 + en: 62d58fd9b8fdb4e7 + zh: 8b6c078927a32e9d /client-web-gui-browser-half/related-documentation: en: d1d506e68fab7333 zh: 1a90fe6f3f8f24a9 diff --git a/packages/client/README.md b/packages/client/README.md index 3047a181c1..ca160f395e 100644 --- a/packages/client/README.md +++ b/packages/client/README.md @@ -68,6 +68,7 @@ The kernel packages boot and serve the page; the UI feature packages present it. | [`ui-subagent/`](ui-subagent/README.md) | Provides subagent navigation, child transcript states, and inline references | — | | [`ui-jobs/`](ui-jobs/README.md) | Lists this session's background jobs with on-demand streaming record panels | — | | [`ui-schedule/`](ui-schedule/README.md) | Provides the sidebar Automation tasks page and right Sidebar task tab, which create, edit, run, pause, resume, and delete Host scheduled tasks, plus the Session header clock and row mark | — | +| [`ui-session-panel/`](ui-session-panel/README.md) | Adds the Session header toggle and the floating Session panel whose sections plugins register, with the Environment section | — | | [`ui-model-selection/`](ui-model-selection/README.md) | Provides model selection in conversation surfaces | — | | [`ui-permission-presets/`](ui-permission-presets/README.md) | Configures default permissions and switches the current session's access | — | | [`ui-plan/`](ui-plan/README.md) | Presents active plan-mode status and its exit control | — | diff --git a/packages/client/README.zh.md b/packages/client/README.zh.md index e327a717d9..de5301fc93 100644 --- a/packages/client/README.zh.md +++ b/packages/client/README.zh.md @@ -68,6 +68,7 @@ kind: "package-group" | [`ui-subagent/`](ui-subagent/README.zh.md) | 提供 subagent 导航、子级 transcript(文本记录)状态与内联引用 | — | | [`ui-jobs/`](ui-jobs/README.zh.md) | 列出本会话的后台任务,并提供按需展开的流式输出面板 | — | | [`ui-schedule/`](ui-schedule/README.zh.md) | 提供侧栏“自动化任务”页面与右侧栏任务页签,用于创建、编辑、立即运行、暂停、恢复和删除宿主的计划任务,并提供 Session 顶部时钟与行标记 | — | +| [`ui-session-panel/`](ui-session-panel/README.zh.md) | 提供会话标题栏开关与悬浮会话面板,分栏由插件注册,并内置「环境」分栏 | — | | [`ui-model-selection/`](ui-model-selection/README.zh.md) | 在对话界面中提供模型选择 | — | | [`ui-permission-presets/`](ui-permission-presets/README.zh.md) | 配置默认权限并切换当前会话的访问模式 | — | | [`ui-plan/`](ui-plan/README.zh.md) | 展示生效中的 plan mode 状态及其退出控件 | — | diff --git a/packages/client/ui-chat/README.i18n.yaml b/packages/client/ui-chat/README.i18n.yaml index 3120b6b576..20403ed74c 100644 --- a/packages/client/ui-chat/README.i18n.yaml +++ b/packages/client/ui-chat/README.i18n.yaml @@ -36,8 +36,8 @@ en: b1630d93a52f483e zh: 59cb81ca50ecffc4 /deepseek-ai-dsh-client-ui-chat/scroll-ownership: - en: dd4e69828096c3a0 - zh: 2a9bc370f44efcd7 + en: 1bede2217882f0bd + zh: af4b389545ac8840 /deepseek-ai-dsh-client-ui-chat/model-experience: en: c17b4dd43a61c569 zh: f7414309810c3a08 diff --git a/packages/client/ui-chat/README.md b/packages/client/ui-chat/README.md index d845c15bbd..ce852e5b15 100644 --- a/packages/client/ui-chat/README.md +++ b/packages/client/ui-chat/README.md @@ -146,7 +146,7 @@ Chat waits for initial history before automatic content, scroll, or size updates Chat restores semantic anchors across history prepend and renderer remounts, with browser scroll anchoring disabled on its scrollport only while following the tail. Pinned scroll deliveries without reader movement, and reader input that reaches the floor within subpixel rounding, update follow ownership immediately, before subsequent layout changes can invalidate their floor. Other reader movement remains pending until the sampling interval or `scrollend`, even inside the follow threshold, so layout growth cannot erase small scroll gestures. Under completion-time folding, submitting transcript input or steering immediately restores tail following and clears an older pending reader sample. Under next-message folding, transcript input that no fold batch carries lands on one native animation; steering lands at once under either timing, because the running Turn keeps streaming above its echo. While the reader is pinned to the floor, `ResizeObserver` follows the new floor and selects the latest loaded Turn without reading row geometry. Once the reader moves away, flow-height changes preserve the top position and the reading-line geometry selects the active Turn. Turn-rail previews paint above sticky Markdown code-block banners, while the rail frame remains inside the transcript band above the composer. -The turn rail and back-to-bottom button sit outside the clipped transcript. They use the shared conversation scrollport for sticky positioning, or the Chat frame for absolute positioning when Chat owns its scrollport. The rail hides when the transcript's available width, excluding its horizontal padding, is at most 900px; the browser viewport width is not the criterion. +The turn rail and back-to-bottom button sit outside the clipped transcript. They use the shared conversation scrollport for sticky positioning, or the Chat frame for absolute positioning when Chat owns its scrollport. The rail sits at the scrollport's start edge, which leaves the end gutter to the [Session panel](../ui-session-panel/README.md), and its previews open toward the transcript. The rail hides when the transcript's available width, excluding its horizontal padding, is at most 900px; the browser viewport width is not the criterion. The transcript root uses `overflow-x: visible; overflow-y: clip`: vertical overflow is clipped without creating a scroll container. Sticky Markdown code banners and expanded compaction headers therefore retain the actual conversation scrollport as their reference when no nearer scrolling ancestor exists. Capped process groups and terminal sections keep their own scrollports. diff --git a/packages/client/ui-chat/README.zh.md b/packages/client/ui-chat/README.zh.md index 80402eadf2..8152e86cbc 100644 --- a/packages/client/ui-chat/README.zh.md +++ b/packages/client/ui-chat/README.zh.md @@ -146,7 +146,7 @@ Chat 等待初始历史就绪后,才允许自动内容、滚动或尺寸更新 Chat 会在历史前插与 renderer 重新挂载时恢复语义锚点,并且只在跟随底部时禁用自己滚动区域的浏览器自动锚定。没有读者移动的贴底滚动事件,以及到达底部(容许小于 1px 的取整误差)的读者输入,会立即更新跟随归属,避免后续布局变化使其底部位置失效。其他读者移动即使位于跟随阈值内,也保持待处理直到采样周期或 `scrollend`,防止布局增长抵消小幅滚动操作。采用完成时收起时,提交正文输入或 steering 会立即恢复跟随底部,并清除先前待处理的读者滚动采样。采用下次消息时收起时,没有折叠批次承载的正文输入用一次原生动画落到底部;steering 在两种时机下都立即落到底部,因为运行中的 Turn 仍在其回显上方持续输出。读者跟随底部时,`ResizeObserver` 追随新的底部,并且无需读取行几何就选中最后一个已加载轮次;读者离开底部后,高度变化会保持顶部位置,再由阅读线几何选择活跃轮次。轮次导航预览位于 Markdown 代码块粘性头栏上方,而导航外框始终处于 composer 上方的 transcript 区域内。 -轮次轨道与回到底部按钮位于正文裁剪层外。它们相对共享会话滚动容器做 sticky 定位;Chat 自己持有滚动容器时,则相对 Chat 外框做 absolute 定位。正文扣除水平内边距后的可用宽度不超过 900px 时,隐藏轮次轨道;判断依据不是浏览器视口宽度。 +轮次轨道与回到底部按钮位于正文裁剪层外。它们相对共享会话滚动容器做 sticky 定位;Chat 自己持有滚动容器时,则相对 Chat 外框做 absolute 定位。轮次轨道贴在滚动容器的起始边,把末端留白让给[会话面板](../ui-session-panel/README.zh.md),预览朝正文方向弹出。正文扣除水平内边距后的可用宽度不超过 900px 时,隐藏轮次轨道;判断依据不是浏览器视口宽度。 正文根节点使用 `overflow-x: visible; overflow-y: clip`:裁剪纵向溢出,但不创建滚动容器。因此,在没有更近的滚动祖先时,Markdown 代码块的 sticky 头栏和展开的压缩摘要头栏仍以实际会话滚动容器为参照。限高过程组和终端区域保留各自的滚动容器。 diff --git a/packages/client/ui-chat/src/client/chat/TurnNavigator.module.css b/packages/client/ui-chat/src/client/chat/TurnNavigator.module.css index c4d495b8d6..2d8166ca68 100644 --- a/packages/client/ui-chat/src/client/chat/TurnNavigator.module.css +++ b/packages/client/ui-chat/src/client/chat/TurnNavigator.module.css @@ -30,7 +30,8 @@ position: absolute; top: calc(var(--turn-rail-band) / 2); - right: 12px; + /* The start edge: the end gutter belongs to the Session panel. */ + left: 12px; width: 28px; /* Fixed-pitch marks never compress: a ladder taller than the band scrolls inside this frame instead of pushing marks under the composer or above @@ -97,14 +98,14 @@ .mark::before { position: absolute; top: 50%; - right: 0; + left: 0; width: 20px; height: 2px; border-radius: 2px; background: var(--dsw-alias-border-l4); content: ''; transform: translateY(-50%) scaleX(0.6); - transform-origin: right center; + transform-origin: left center; transition: transform 140ms ease, background-color 140ms ease; } @@ -142,11 +143,11 @@ .mark:focus-visible::after { position: absolute; - inset: 0 0 0 auto; + inset: 0 auto 0 0; width: 20px; border-radius: inherit; outline: 1px solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); - /* The scroller clips the right edge; keep the marker's ring inside it. */ + /* The scroller clips the left edge; keep the marker's ring inside it. */ outline-offset: -1px; content: ''; } @@ -158,7 +159,7 @@ calc(var(--turn-preview-center) - var(--turn-preview-height) / 2), calc(100% - var(--turn-preview-height)) ); - right: calc(100% + 10px); + left: calc(100% + 10px); box-sizing: border-box; width: min(300px, calc(100cqw - 120px)); max-height: var(--turn-preview-height); @@ -194,7 +195,7 @@ } @keyframes dsh-turn-preview-enter { - from { opacity: 0; transform: translateX(4px); } + from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: translateX(0); } } diff --git a/packages/client/ui-conversation/README.i18n.yaml b/packages/client/ui-conversation/README.i18n.yaml index c88fda7554..06d21c9a63 100644 --- a/packages/client/ui-conversation/README.i18n.yaml +++ b/packages/client/ui-conversation/README.i18n.yaml @@ -21,8 +21,8 @@ en: cc4dafd1aae02468 zh: be6b67724b7ac4a3 /deepseek-ai-dsh-client-ui-conversation/shell-and-standard-props: - en: bd2a85b9012fa3c3 - zh: e88d7e682e316a0e + en: 1d9c21bd934d1a3b + zh: 3c47d27ea72b2a2e /deepseek-ai-dsh-client-ui-conversation/temporary-composer-entries: en: 59cd63057dfb6eeb zh: b2e2c86e810b7bb8 diff --git a/packages/client/ui-conversation/README.md b/packages/client/ui-conversation/README.md index 041aa0d5d4..25bc4dab22 100644 --- a/packages/client/ui-conversation/README.md +++ b/packages/client/ui-conversation/README.md @@ -120,6 +120,8 @@ Active transcripts in the main occurrence expose content-width drag handles in t The width-handle indicator follows the pointer only during a captured drag; ordinary hover leaves its position unchanged. +The main occurrence of an active Session also renders the `conversation.session.panel` seat inside its body, beside the width handles and outside the scrollport; embedded occurrences and the blank home omit it. Its occupant positions itself against the body, which carries the transcript axis and the composer stack height `--dsh-composer-height`. `ctx.uiConversation.layouts.source(sessionId)` publishes that Session's `ConversationLayout`: `endGutter` is the space between the transcript column's end edge and the body's end edge, written by the main width controls after each measurement and drag frame and reset to zero when they unmount. It stays zero while a View other than Chat, which fills the body, is active. + The resident composer survives no-Session and Session transitions. Whitespace hides its placeholder; a whitespace-only draft without attachments cannot be sent. The no-Session state keeps the same composer surface mounted but inert while the Workspace picker connects a blank Session. The surface is a shell-owned Lexical editor: reference chips are atomic decorator nodes carrying the owner's serialization identity (submission expands them through the owner codec), the claimed slash command is an atomic leading chip that carries its claim, folder text references carry the folder glyph as an icon prefix, and the draft's text and semantic references are persisted by the per-Session Conversation store. QueueDock reads `next-turn` from the Session `inbox` projection, including cold recovered messages, and excludes only requestIds still owned by local transcript submissions. Other queued rows retain their normal display and actions. Queue operations address exact queue occurrences through the scoped `ctx.conversation` service; queue previews use the [UserText Factory](#sent-user-text) (wire session forms fold to their label) and show local or durable images and files in original attachment order. Images use thumbnails; files use compact name-and-size cards. An edit exposes the literal sent text in the ui-primitives `InlineEditor`, so line breaks survive re-editing. Durable thumbnails resolve through the session image URL cache. Busy Enter behavior is stored in the Host-backed `ui-conversation` settings namespace. The composer keymap arbitrates the trigger menu's keys through the slash pipeline — Tab settles the highlighted completion (or drills a drillable one), Escape and Shift+Tab leave the menu without settling — and leaves every other key to the editor. An overlay that takes the keyboard hands it back through `SessionInput.focus()`, which rides Lexical's own focus so the caret returns where the draft left it rather than at the start. In narrow browser settings, the busy-state Enter preference uses a smaller label gutter. Windows and macOS desktop windows retain the standard spacing. diff --git a/packages/client/ui-conversation/README.zh.md b/packages/client/ui-conversation/README.zh.md index 0ac0d779d1..8f9964211f 100644 --- a/packages/client/ui-conversation/README.zh.md +++ b/packages/client/ui-conversation/README.zh.md @@ -120,6 +120,8 @@ Session 首次绑定或缓存的 Session 成为 current 时,shell 会在渲染 宽度拖拽条的指示线只在已捕获指针的拖拽期间跟随指针,普通悬停不改变其位置。 +活跃 Session 的主 occurrence 还会在正文内渲染 `conversation.session.panel` 落位,与宽度拖拽条同层,位于滚动容器之外;嵌入式 occurrence 和空白首页不渲染它。占位组件相对正文定位,正文持有正文轴线与 composer 区域高度 `--dsh-composer-height`。`ctx.uiConversation.layouts.source(sessionId)` 发布该 Session 的 `ConversationLayout`:`endGutter` 是正文列末端边缘到正文末端边缘的距离,由主宽度控件在每次测量与拖拽帧后写入,控件卸载时归零。激活的是 Chat 以外的 View(这类 View 占满正文)时,它保持为零。 + 常驻 composer 在无 Session 与有 Session 之间保持挂载。输入空白字符会隐藏占位提示;没有附件的纯空白草稿无法发送。无 Session 时,同一个编辑器表面保持 inert,Workspace picker 连接 blank Session。该表面是 shell 所有的 Lexical 编辑器:引用 chip 是携带 owner 序列化身份的原子 decorator 节点(提交时经 owner codec 展开),已认领的 slash command 是携带认领的行首原子 chip,文件夹文本引用以图标前缀携带文件夹图形,草稿文字和引用语义字段由逐 Session Conversation store 持久化。QueueDock 从 Session 的 `inbox` 投影读取 `next-turn`,包含从冷状态恢复的消息,仅排除仍由本地 transcript 提交承接的 requestId。其他排队行保留正常展示和操作。Queue 操作通过 scoped `ctx.conversation` service 寻址准确的 queue occurrence;queue 预览使用 [UserText Factory](#sent-user-text)(wire 会话形式折叠为其标签),并按原始附件顺序展示本地或持久化的图片和文件。图片使用缩略图,文件使用紧凑的名称与大小卡片。编辑态在 ui-primitives 的 `InlineEditor` 中展示字面发送文本,因此重新编辑不会丢失换行。持久化缩略图通过会话图片 URL 缓存解析。繁忙时 Enter 行为保存在 Host-backed `ui-conversation` settings namespace。 composer 键盘映射经斜杠流水线裁决触发菜单的按键——Tab 确认高亮补全项(可下钻项则下钻),Escape 与 Shift+Tab 离开菜单且不选定——其余按键交给编辑器自身。 接管键盘的浮层通过 `SessionInput.focus()` 把键盘还回来,该路径走 Lexical 自己的 focus,因此光标回到草稿原来的位置而不是开头。 窄屏浏览器设置中,繁忙时 Enter 偏好的标签与控件间距缩小;Windows 和 macOS 桌面窗口保留标准间距。 diff --git a/packages/client/ui-conversation/src/client/apply.ts b/packages/client/ui-conversation/src/client/apply.ts index aae71928be..bad863ff72 100644 --- a/packages/client/ui-conversation/src/client/apply.ts +++ b/packages/client/ui-conversation/src/client/apply.ts @@ -45,7 +45,7 @@ import { ConversationSession, ConversationSessionHeader } from './skeleton/Conve import { InputBar } from './skeleton/InputBar.tsx' import { todoDockEntry } from './skeleton/TodoPanel.tsx' import { installStopShortcut } from './stop-shortcut.ts' -import { TRAJECTORY_VIEW_ID, resolveActiveView } from './view-selection.ts' +import { DEFAULT_VIEW_ID, TRAJECTORY_VIEW_ID, resolveActiveView } from './view-selection.ts' import { createViewPins } from './view-pins.ts' import { en, ja, es, fr, de, ru, pt, NS, zh, type ConversationKey } from './locales.ts' import { CONVERSATION_SETTINGS_NAMESPACE, type ConversationSettings } from '../submission-settings.ts' @@ -221,7 +221,10 @@ export function apply(ctx: Context, config: Config = Config({})): void { } const activateView = (sessionId: SessionId, preferred: string | null): void => { const active = resolveActiveView(viewTabs(), preferred) - if (active !== undefined) uiConversation.binding(sessionId).activate(active.id) + if (active === undefined) return + uiConversation.binding(sessionId).activate(active.id) + // Chat is the View laid out on the transcript column. + uiConversation.layouts.activate(sessionId, active.id === DEFAULT_VIEW_ID) } const restoreView = (sessionId: SessionId): void => { activateView(sessionId, readConversationViewPreference(sessionId)) @@ -354,6 +357,7 @@ export function apply(ctx: Context, config: Config = Config({})): void { 'conversation.hero.workspace': { kind: 'single', scope: 'root' }, 'conversation.hero.agentPreset': { kind: 'single', scope: 'session-maybe' }, 'conversation.hero.options': { kind: 'list', scope: 'session' }, + 'conversation.session.panel': { kind: 'single', scope: 'session' }, }, slots: { views: { scope: 'session' }, @@ -363,6 +367,9 @@ export function apply(ctx: Context, config: Config = Config({})): void { hooks: { composerBlock: sessionId === undefined ? ABSENT_BLOCK : composerBlocks.storeFor(sessionId), }, + reportEndGutter: (endGutter) => { + if (sessionId !== undefined) uiConversation.layouts.measure(sessionId, endGutter) + }, selectWorkspace: workspaceId => workspaceNavigation.openWorkspace(workspaceId, (nextId) => { if (sessionId !== undefined && nextId !== sessionId) { const from = inputHub.shell(sessionId) diff --git a/packages/client/ui-conversation/src/client/contract/slots.ts b/packages/client/ui-conversation/src/client/contract/slots.ts index e7ae7285ab..9dbe00d8bb 100644 --- a/packages/client/ui-conversation/src/client/contract/slots.ts +++ b/packages/client/ui-conversation/src/client/contract/slots.ts @@ -279,6 +279,13 @@ declare module '@deepseek-ai/dsh-client-ui-slots' { scope: 'session' owner: ConversationHeaderCornerOwnerProps } + /** + * One floating panel over the main Conversation body's end gutter. It renders + * only for the main occurrence of a Session in its active phase, never for an + * embedded occurrence or the blank home; the occupant positions itself against + * the body and reads `ctx.uiConversation.layouts` to keep clear of the transcript. + */ + 'conversation.session.panel': { kind: 'single'; scope: 'session'; owner: ConversationSessionPanelOwnerProps } /** Rows of the View tab row's More menu; the header shows More only while this list has registrations. */ 'conversation.session.header.views.actions': { kind: 'list'; scope: 'root'; owner: ConversationViewActionsOwnerProps } /** Registered Conversation target Views, rendered one at a time. */ @@ -377,6 +384,7 @@ declare module '@deepseek-ai/dsh-client-ui-slots' { 'conversation.hero.workspace': { kind: 'single'; scope: 'root' } 'conversation.hero.agentPreset': { kind: 'single'; scope: 'session-maybe' } 'conversation.hero.options': { kind: 'list'; scope: 'session' } + 'conversation.session.panel': { kind: 'single'; scope: 'session' } } inject: ConversationInjected locale: 'conversation' @@ -423,6 +431,23 @@ export interface ConversationHeaderActionOwnerProps { children?: never } +/** The Session panel's occupant derives its state from standard Session props. */ +export interface ConversationSessionPanelOwnerProps { + /** Marker field: the occupant receives no owner-specific values. */ + children?: never +} + +/** Geometry that floating chrome over the main Conversation body keeps clear of. */ +export interface ConversationLayout { + /** + * Inline space in CSS px between the transcript column's end edge and the + * body's end edge. Zero before the first measurement, while the main body + * shows another Session, and while the active View does not follow the + * transcript column (every View other than Chat). + */ + readonly endGutter: number +} + /** The header corner's occupant derives its state from standard Session props. */ export interface ConversationHeaderCornerOwnerProps { /** Marker field: the occupant receives no owner-specific values. */ @@ -472,6 +497,12 @@ export interface ConversationInjected { selectWorkspace: (workspaceId: WorkspaceId) => Promise /** Session-addressed composer block source, or the stable absent source. */ hooks: { composerBlock: ObservableSnapshot } + /** + * Record the end gutter the main body measured for this occurrence's Session; + * no effect without a Session. + * @param endGutter - space between the transcript column's end edge and the body's end edge, in CSS px. + */ + reportEndGutter: (endGutter: number) => void } /** Business callbacks injected into the strict Session body. */ @@ -664,6 +695,12 @@ export interface ConversationWidthControlsInputProps { container: HTMLDivElement | null /** Current body phase; handles render only for an active transcript. */ phase: ConversationContentInputProps['phase'] + /** + * Receive the end gutter after each measurement and drag frame, and zero when + * the controls unmount. + * @param endGutter - space between the transcript column's end edge and the body's end edge, in CSS px. + */ + onEndGutter: (endGutter: number) => void } /** Full props of the reusable Conversation Factory definition. */ diff --git a/packages/client/ui-conversation/src/client/conversation/assembly.ts b/packages/client/ui-conversation/src/client/conversation/assembly.ts index 233a72e23f..d879921d9b 100644 --- a/packages/client/ui-conversation/src/client/conversation/assembly.ts +++ b/packages/client/ui-conversation/src/client/conversation/assembly.ts @@ -26,6 +26,7 @@ import { ConversationViewRegistry } from './view-registry.ts' import { ConversationGroupRegistry } from './group-registry.ts' import { ConversationInteractionRegistry } from './interaction-registry.ts' import { UserTextRegistry } from './user-text-registry.ts' +import { ConversationLayouts } from './layouts.ts' /** Observable faces published for one Session's Conversation assembly. */ export interface ConversationBinding { @@ -211,6 +212,8 @@ export class UiConversation extends Service { readonly userText: UserTextRegistry /** Plugin-owned handlers for selection and context-menu gestures. */ readonly interactions: ConversationInteractionRegistry + /** Main Conversation body geometry per Session; the Conversation shell writes it and floating chrome reads it. */ + readonly layouts: ConversationLayouts = new ConversationLayouts() private readonly bindings = new WeakMapWithValues() private readonly images: HistoricalImageCache diff --git a/packages/client/ui-conversation/src/client/conversation/layouts.ts b/packages/client/ui-conversation/src/client/conversation/layouts.ts new file mode 100644 index 0000000000..9caa7c35cf --- /dev/null +++ b/packages/client/ui-conversation/src/client/conversation/layouts.ts @@ -0,0 +1,72 @@ +/** Per-Session geometry of the main Conversation body, published through `ctx.uiConversation.layouts`. */ +import { createSnapshotStore, type ObservableSnapshot, type SnapshotStore } from '@deepseek-ai/dsh-client-store' +import type { SessionId } from '@deepseek-ai/dsh-session/types' +import type { ConversationLayout } from '../contract/slots.ts' + +const NO_LAYOUT: ConversationLayout = Object.freeze({ endGutter: 0 }) + +interface LayoutEntry { + /** Last end gutter the main body's width controls measured, in CSS px. */ + measured: number + /** Whether the Session's active View follows the transcript column; false before the first activation. */ + followsTranscript: boolean + readonly store: SnapshotStore +} + +/** + * Layout facts of the main Conversation body, kept per Session for the + * lifetime of the Conversation plugin. The Conversation shell writes them: + * the main body's width controls report the measured end gutter, and View + * activation reports whether the active View follows the transcript column. + * The published gutter is zero while it does not, because such a View fills + * the body. Floating chrome reads one Session's facts through `source`. + */ +export class ConversationLayouts { + private readonly entries = new Map() + + /** + * Read one Session's layout source. + * @param sessionId - Session whose main body geometry is read. + * @returns a source whose identity is stable per Session and whose snapshot keeps its identity until the gutter changes. + */ + source(sessionId: SessionId): ObservableSnapshot { + return this.entryOf(sessionId).store + } + + /** + * Record the end gutter the main body measured while showing a Session. + * @param sessionId - Session the main body shows. + * @param endGutter - space between the transcript column's end edge and the body's end edge, in CSS px. + */ + measure(sessionId: SessionId, endGutter: number): void { + const entry = this.entryOf(sessionId) + entry.measured = Math.max(0, endGutter) + this.publish(entry) + } + + /** + * Record whether the View a Session activated follows the transcript column. + * @param sessionId - Session whose View changed. + * @param followsTranscript - true for a View laid out on the transcript column. + */ + activate(sessionId: SessionId, followsTranscript: boolean): void { + const entry = this.entryOf(sessionId) + entry.followsTranscript = followsTranscript + this.publish(entry) + } + + private entryOf(sessionId: SessionId): LayoutEntry { + let entry = this.entries.get(sessionId) + if (entry === undefined) { + entry = { measured: 0, followsTranscript: false, store: createSnapshotStore(NO_LAYOUT) } + this.entries.set(sessionId, entry) + } + return entry + } + + private publish(entry: LayoutEntry): void { + const endGutter = entry.followsTranscript ? entry.measured : 0 + if (entry.store.getSnapshot().endGutter === endGutter) return + entry.store.set(endGutter === 0 ? NO_LAYOUT : { endGutter }) + } +} diff --git a/packages/client/ui-conversation/src/client/index.ts b/packages/client/ui-conversation/src/client/index.ts index 8a1b95e941..069142b75c 100644 --- a/packages/client/ui-conversation/src/client/index.ts +++ b/packages/client/ui-conversation/src/client/index.ts @@ -86,8 +86,8 @@ export type { ComposerFileAttachment, ComposerImageAttachment, DraftFileUpload, DraftFileUploads, ComposerBarInjected, ComposerBarOwnerProps, ComposerBarProps, ComposerChainProps, ConversationHeaderActionOwnerProps, ConversationHeaderCornerOwnerProps, ConversationHeaderLineageOwnerProps, - ConversationContentInputProps, ConversationContentProps, - ConversationInjected, ConversationSessionHeaderInjected, ConversationSessionHeaderSlotProps, + ConversationContentInputProps, ConversationContentProps, ConversationLayout, + ConversationInjected, ConversationSessionPanelOwnerProps, ConversationSessionHeaderInjected, ConversationSessionHeaderSlotProps, ConversationSessionInjected, ConversationSessionSlotProps, ConversationSlotProps, ConversationViewActionEntry, ConversationViewActionsOwnerProps, ConversationViewsProps, ConversationWidthControlsInputProps, ConversationWidthControlsProps, diff --git a/packages/client/ui-conversation/src/client/skeleton/ConversationContent.tsx b/packages/client/ui-conversation/src/client/skeleton/ConversationContent.tsx index 4c6b8e6578..1f3f6ab5b6 100644 --- a/packages/client/ui-conversation/src/client/skeleton/ConversationContent.tsx +++ b/packages/client/ui-conversation/src/client/skeleton/ConversationContent.tsx @@ -23,7 +23,7 @@ export function ConversationContent(props: ConversationContentProps) { const { sessionId, phase, hero, useSession, useSessions, useSessionStatus, useWorkspaces, useInput, useComposerBlock, renderSlot, renderSlotChain, - selectWorkspace, t, useFactorySlot, + selectWorkspace, reportEndGutter, t, useFactorySlot, } = props const session = useSession(snapshot => snapshot) const Views = useFactorySlot('views', ConversationSessionView) @@ -42,22 +42,25 @@ export function ConversationContent(props: ConversationContentProps) { const [pendingWorkspaceId, setPendingWorkspaceId] = useState() const pickerAnchor = useRef(null) - // Publishes the two live measurements floating View chrome reads off the - // scroll body: the seat's height as --dsh-composer-height, so controls clear - // the composer as it grows, and the scrollport's own height as + // Publishes the two live measurements floating chrome reads: the seat's + // height as --dsh-composer-height, so controls clear the composer as it + // grows, and the scrollport's own height as // --dsh-conversation-viewport-height, so a control can sit in the band the - // seat leaves visible. Callback ref, not an effect; stable identity prevents - // observer churn while the first blank session fills the resident body - // outlet. + // seat leaves visible. They land on the content body, so View chrome inside + // the scrollport and the Session panel beside it read the same values. + // Callback ref, not an effect; stable identity prevents observer churn while + // the first blank session fills the resident body outlet. const seatObserver = useRef(null) const seatResizeRef = useCallback((seat: HTMLDivElement | null): void => { seatObserver.current?.disconnect() seatObserver.current = null const scroller = seat?.parentElement ?? null if (seat === null || scroller === null) return + /* v8 ignore next -- the seat always renders inside the content body. */ + const target = scroller.closest('[data-conversation-content]') ?? scroller seatObserver.current = new ResizeObserver(() => { - scroller.style.setProperty('--dsh-composer-height', `${seat.offsetHeight}px`) - scroller.style.setProperty( + target.style.setProperty('--dsh-composer-height', `${seat.offsetHeight}px`) + target.style.setProperty( '--dsh-conversation-viewport-height', `${scroller.clientHeight}px`, ) @@ -204,7 +207,9 @@ export function ConversationContent(props: ConversationContentProps) { ), })} - + + {props.variant === 'main' && sessionId !== undefined && phase === 'active' + && renderSlot('conversation.session.panel', {})} ) } diff --git a/packages/client/ui-conversation/src/client/skeleton/ConversationWidthControls.tsx b/packages/client/ui-conversation/src/client/skeleton/ConversationWidthControls.tsx index 53f42c199f..1b35ee6137 100644 --- a/packages/client/ui-conversation/src/client/skeleton/ConversationWidthControls.tsx +++ b/packages/client/ui-conversation/src/client/skeleton/ConversationWidthControls.tsx @@ -20,7 +20,12 @@ function readWidthPreference(): number | null { return Number.isFinite(value) && value > 0 ? value : null } -/** Resolve the width displayed for one measured Conversation column. */ +/** + * Resolve the width displayed for one measured Conversation column. + * @param columnWidth - measured body width in CSS px. + * @param preference - persisted dragged width, or null for the adaptive default. + * @returns the transcript column width in CSS px. + */ function resolveContentWidth(columnWidth: number, preference: number | null): number { const max = Math.max(CONTENT_MIN, columnWidth - CONTENT_EDGE_BUDGET) if (preference !== null) return Math.min(Math.max(preference, CONTENT_MIN), max) @@ -129,11 +134,14 @@ function WidthHandle(props: { } /** - * Install the main Conversation width axis and render its drag handles. + * Install the main Conversation width axis, report its end gutter, and render its drag handles. * @param props - Mounted Conversation body and current presentation phase. * @returns two active-phase width handles, or no controls outside the active phase. */ -export function ConversationWidthControls({ container, phase }: ConversationWidthControlsProps) { +export function ConversationWidthControls({ container, phase, onEndGutter }: ConversationWidthControlsProps) { + // The observer outlives renders; it reports through the latest callback. + const report = useRef(onEndGutter) + report.current = onEndGutter const publishWidths = useCallback((container: HTMLDivElement): void => { const target = container.parentElement ?? container const column = container.offsetWidth @@ -141,6 +149,7 @@ export function ConversationWidthControls({ container, phase }: ConversationWidt const preference = readWidthPreference() if (preference === null) target.style.removeProperty('--dsh-chat-user-width') else target.style.setProperty('--dsh-chat-user-width', `${resolveContentWidth(column, preference)}px`) + report.current((column - resolveContentWidth(column, preference)) / 2) }, []) useLayoutEffect(() => { @@ -148,7 +157,10 @@ export function ConversationWidthControls({ container, phase }: ConversationWidt const observer = new ResizeObserver(() => { publishWidths(container) }) observer.observe(container) publishWidths(container) - return () => { observer.disconnect() } + return () => { + observer.disconnect() + report.current(0) + } }, [container, publishWidths]) const onStart = useCallback((): number => { @@ -158,7 +170,10 @@ export function ConversationWidthControls({ container, phase }: ConversationWidt const onDrag = useCallback((width: number): void => { if (container === null) return const target = container.parentElement ?? container - target.style.setProperty('--dsh-chat-user-width', `${resolveContentWidth(container.offsetWidth, width)}px`) + const column = container.offsetWidth + const content = resolveContentWidth(column, width) + target.style.setProperty('--dsh-chat-user-width', `${content}px`) + report.current((column - content) / 2) }, [container]) const onCommit = useCallback((width: number): void => { if (container === null) return diff --git a/packages/client/ui-conversation/tests/skeleton.client.spec.tsx b/packages/client/ui-conversation/tests/skeleton.client.spec.tsx index 2a099a7d7b..c82b03cb77 100644 --- a/packages/client/ui-conversation/tests/skeleton.client.spec.tsx +++ b/packages/client/ui-conversation/tests/skeleton.client.spec.tsx @@ -147,6 +147,8 @@ function mount( entryActions?: boolean /** Isolate header capability checks from the composer's required layout observers. */ headerOnly?: boolean + /** Render the content Factory as another presentation host would. */ + contentVariant?: 'embedded' } = {}, ) { const sessionId = 'sessionId' in options ? options.sessionId : SID @@ -204,6 +206,8 @@ function mount( const frameOwners: HeroFrameOwnerProps[] = [] let actionsOwner: ConversationViewActionsOwnerProps | undefined const setPinned = vi.fn<(id: string, pinned: boolean) => void>() + /** End gutters the main width controls reported, in order. */ + const gutters: number[] = [] const renderSlot = ((key: string, owner: object, opts?: { only?: string; fallback?: ReactNode; children?: ReactNode }) => { slotCalls.push(key) if (key === 'conversation.input.model' || key === 'conversation.input.plan') { @@ -376,6 +380,7 @@ function mount( renderSlotChain, renderFactorySlot, selectWorkspace: retargetWorkspace, + reportEndGutter: (gutter) => { gutters.push(gutter) }, t, } const useFactorySlot = ((name: string, fallback: (props: never) => ReactNode) => ( @@ -383,7 +388,11 @@ function mount( )) as ConversationContentProps['useFactorySlot'] return ( - + ) }) as ConversationSlotProps['renderFactorySlot'] @@ -407,7 +416,7 @@ function mount( const props: ConversationSlotProps = { ...runtimeProps, renderSlot, renderFactorySlot } const view = render() return { - view, store, wiring, sink, retargetWorkspace, session, conversation, slotCalls, headerFactory, lineageOwners, seatOwners, open, + view, store, wiring, sink, retargetWorkspace, session, conversation, slotCalls, headerFactory, lineageOwners, seatOwners, open, gutters, pickerOwner: () => pickerOwner, frameOwner: () => frameOwners.at(-1), setPinned, @@ -1074,4 +1083,53 @@ describe('ConversationRoot resident composer', () => { const b = mount(sessionSnapshotOf({ blank: true })) expect(b.view.container.querySelector('[data-width-handle]')).toBeNull() }) + + it('reports the end gutter after each measurement and drag frame, and zero on unmount', () => { + const b = mount(sessionSnapshotOf()) + const content = b.view.container.querySelector('[data-conversation-content]') as HTMLElement + Object.defineProperty(content, 'offsetWidth', { value: 1600, configurable: true }) + act(() => { fireResize(content) }) + // Adaptive width min(1600 × 0.64, 920) = 920 leaves (1600 − 920) / 2. + expect(b.gutters.at(-1)).toBe(340) + const handle = b.view.container.querySelector('[data-width-handle="right"]') as HTMLElement + const names = ['setPointerCapture', 'releasePointerCapture', 'hasPointerCapture'] as const + const originals = names.map(name => [name, Object.getOwnPropertyDescriptor(Element.prototype, name)] as const) + const captured = new Set() + Element.prototype.setPointerCapture = function () { captured.add(this) } + Element.prototype.releasePointerCapture = function () { captured.delete(this) } + Element.prototype.hasPointerCapture = function () { return captured.has(this) } + try { + fireEvent.pointerDown(handle, { pointerId: 1, clientX: 800, clientY: 300 }) + fireEvent.pointerMove(handle, { pointerId: 1, clientX: 825, clientY: 300 }) + fireEvent.pointerUp(handle, { pointerId: 1, clientX: 825, clientY: 300 }) + // The dragged width 970 leaves (1600 − 970) / 2. + expect(b.gutters.at(-1)).toBe(315) + } finally { + for (const [name, descriptor] of originals) { + if (descriptor === undefined) Reflect.deleteProperty(Element.prototype, name) + else Object.defineProperty(Element.prototype, name, descriptor) + } + } + b.view.unmount() + expect(b.gutters.at(-1)).toBe(0) + }) + + it('renders the Session panel seat only for the main occurrence of an active Session', () => { + expect(mount(sessionSnapshotOf()).slotCalls).toContain('conversation.session.panel') + cleanup() + expect(mount(sessionSnapshotOf({ blank: true })).slotCalls).not.toContain('conversation.session.panel') + cleanup() + expect(mount(sessionSnapshotOf(), undefined, undefined, { contentVariant: 'embedded' }).slotCalls) + .not.toContain('conversation.session.panel') + }) + + it('publishes the composer stack measurements on the content body', () => { + const b = mount(sessionSnapshotOf()) + const content = b.view.container.querySelector('[data-conversation-content]') as HTMLElement + const seat = content.querySelector('[data-composer-seat]') as HTMLElement + Object.defineProperty(seat, 'offsetHeight', { value: 140, configurable: true }) + act(() => { fireResize(seat) }) + expect(content.style.getPropertyValue('--dsh-composer-height')).toBe('140px') + expect(content.style.getPropertyValue('--dsh-conversation-viewport-height')).toBe('0px') + }) }) diff --git a/packages/client/ui-primitives/README.i18n.yaml b/packages/client/ui-primitives/README.i18n.yaml index 57651951e1..3bc5cc09e4 100644 --- a/packages/client/ui-primitives/README.i18n.yaml +++ b/packages/client/ui-primitives/README.i18n.yaml @@ -18,8 +18,8 @@ en: ead6be55c7c9d7cf zh: 125ad36db7328551 /deepseek-ai-dsh-client-ui-primitives/use-this-package/component-catalog: - en: ae85dcbb25303332 - zh: 471224ebad67df91 + en: 593d2716ae6b17a6 + zh: ff2605eb22969aa6 /deepseek-ai-dsh-client-ui-primitives/use-this-package/controls-and-icons: en: 2fc65b908307b52e zh: e5c1181ecd2da6e5 diff --git a/packages/client/ui-primitives/README.md b/packages/client/ui-primitives/README.md index aa4fa2d978..d8be002218 100644 --- a/packages/client/ui-primitives/README.md +++ b/packages/client/ui-primitives/README.md @@ -55,6 +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. | | `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. | diff --git a/packages/client/ui-primitives/README.zh.md b/packages/client/ui-primitives/README.zh.md index 1eeebf6dac..d29c5816e8 100644 --- a/packages/client/ui-primitives/README.zh.md +++ b/packages/client/ui-primitives/README.zh.md @@ -55,6 +55,7 @@ kind: "package-library" | `SegmentedTabs` | 受控的等宽分段标签,支持滑动指示条及左/右方向键、Home、End 导航。调用方提供文案、标签与面板 id,以及面板内容。默认 `size="md"` 总高 42px、内边距 4px;`size="sm"` 总高 34px、内边距 2px。 | | `Tag` | 只读胶囊徽章;`tone` 选择八种配色之一。 | | `PathLabel` | 单行文件路径:目录使用弱化颜色,文件名使用主色,悬停可查看完整路径。空间足够时靠左显示;溢出时保留尾部并在左侧渐隐,路径或尺寸变化时更新。 | +| `PanelRow` | 摘要面板中的一行事实:16px 装饰图标、单行内容(溢出时以省略号截断)以及可选的尾部数值或控件。图标沿用行文字颜色。传入 `onActivate` 时,图标与内容成为同一个按钮,带悬停与按下填充,尾部区域留在按钮之外;其余属性(例如右键菜单触发属性)落在外层元素上。 | | `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 的引用稳定。 | diff --git a/packages/client/ui-primitives/src/PanelRow.module.css b/packages/client/ui-primitives/src/PanelRow.module.css new file mode 100644 index 0000000000..4a6c786fd8 --- /dev/null +++ b/packages/client/ui-primitives/src/PanelRow.module.css @@ -0,0 +1,78 @@ +/* One summary-panel fact: [16px icon] gap 8 [content 13/28] [trailing]. + The icon inherits the row ink so a fact and its glyph share one foreground. */ + +.row { + display: flex; + align-items: center; + gap: 4px; + min-width: 0; + color: var(--dsw-alias-label-primary); + font: var(--dsw-font-xs-13); +} + +.body { + display: flex; + flex: 1 1 auto; + align-items: center; + gap: 8px; + box-sizing: border-box; + min-width: 0; + height: 28px; + padding: 0 6px; + border-radius: var(--dsw-radius-sm); +} + +.action { + margin: 0; + border: 0; + color: inherit; + background: transparent; + font: inherit; + text-align: start; + cursor: pointer; +} + +@media (hover: hover) { + .action:hover { + background: var(--dsw-alias-interactive-bg-hover); + } +} + +.action:active { + background: var(--dsw-alias-interactive-bg-active); +} + +.action:focus-visible { + outline-style: solid; + outline-offset: -2px; +} + +.icon { + display: inline-flex; + flex: none; + align-items: center; + justify-content: center; + width: 16px; + height: 16px; +} + +.icon svg { + width: 16px; + height: 16px; +} + +.content { + flex: 1 1 auto; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.trailing { + display: inline-flex; + flex: none; + align-items: center; + gap: 4px; + color: var(--dsw-alias-label-tertiary); +} diff --git a/packages/client/ui-primitives/src/PanelRow.tsx b/packages/client/ui-primitives/src/PanelRow.tsx new file mode 100644 index 0000000000..a93fb95bf4 --- /dev/null +++ b/packages/client/ui-primitives/src/PanelRow.tsx @@ -0,0 +1,40 @@ +// PanelRow: one icon-led fact row of a summary panel, shared by every +// contributor so rows from different packages keep one geometry. + +import type { HTMLAttributes, ReactNode } from 'react' +import clsx from 'clsx' +import css from './PanelRow.module.css' + +/** Props of one summary-panel row. */ +export interface PanelRowProps extends Omit, 'children' | 'onClick'> { + /** Leading 16px glyph; decorative, so the row text carries the meaning. */ + readonly icon: ReactNode + /** Primary single-line content; overflow clips with an ellipsis. */ + readonly children: ReactNode + /** Optional trailing value or control, laid out after the content without shrinking. */ + readonly trailing?: ReactNode + /** Make the icon and content one button with this action; the trailing area stays outside it. */ + readonly onActivate?: (() => void) | undefined +} + +/** + * Render one summary-panel row: icon, single-line content, and an optional trailing area. + * @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) { + const body = ( + <> + + {children} + + ) + return ( +
+ {onActivate === undefined + ? {body} + : } + {trailing !== undefined && {trailing}} +
+ ) +} diff --git a/packages/client/ui-primitives/src/index.ts b/packages/client/ui-primitives/src/index.ts index 4fb059f603..8843254144 100644 --- a/packages/client/ui-primitives/src/index.ts +++ b/packages/client/ui-primitives/src/index.ts @@ -26,6 +26,8 @@ export type { SegmentedTab } from './SegmentedTabs.tsx' export { Tag } from './Tag.tsx' export type { TagTone } from './Tag.tsx' export { PathLabel } from './PathLabel.tsx' +export { PanelRow } from './PanelRow.tsx' +export type { PanelRowProps } from './PanelRow.tsx' export { Switch } from './Switch.tsx' export { SegmentedControl } from './SegmentedControl.tsx' export type { SegmentedControlOption } from './SegmentedControl.tsx' diff --git a/packages/client/ui-primitives/tests/panel-row.client.spec.tsx b/packages/client/ui-primitives/tests/panel-row.client.spec.tsx new file mode 100644 index 0000000000..7a7b28f497 --- /dev/null +++ b/packages/client/ui-primitives/tests/panel-row.client.spec.tsx @@ -0,0 +1,41 @@ +// @vitest-environment jsdom +import { cleanup, fireEvent, render, screen } from '@testing-library/react' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { PanelRow } from '@deepseek-ai/dsh-client-ui-primitives' + +afterEach(cleanup) + +describe('PanelRow', () => { + it('renders a static fact with a decorative icon and no button', () => { + const view = render(}>deepseek-harness) + expect(screen.getByText('deepseek-harness')).toBeTruthy() + expect(screen.queryByRole('button')).toBeNull() + expect(screen.getByTestId('glyph').parentElement?.getAttribute('aria-hidden')).toBe('true') + expect(view.container.querySelector('[data-panel-row]')?.children).toHaveLength(1) + }) + + it('makes the icon and content one button while the trailing control stays outside it', () => { + const onActivate = vi.fn() + const onTrailing = vi.fn() + render( + } onActivate={onActivate} trailing={}> + Local changes + , + ) + fireEvent.click(screen.getByRole('button', { name: 'Local changes' })) + expect(onActivate).toHaveBeenCalledTimes(1) + fireEvent.click(screen.getByRole('button', { name: 'More' })) + expect(onTrailing).toHaveBeenCalledTimes(1) + expect(onActivate).toHaveBeenCalledTimes(1) + }) + + it('forwards attributes such as context-menu handlers to the outer element', () => { + const onContextMenu = vi.fn() + const view = render(} className="placed" onContextMenu={onContextMenu} tabIndex={0}>Row) + const row = view.container.querySelector('[data-panel-row]') as HTMLElement + expect(row.className).toContain('placed') + expect(row.tabIndex).toBe(0) + fireEvent.contextMenu(row) + expect(onContextMenu).toHaveBeenCalledTimes(1) + }) +}) diff --git a/packages/client/ui-session-panel/README.i18n.yaml b/packages/client/ui-session-panel/README.i18n.yaml new file mode 100644 index 0000000000..c93e04fcc3 --- /dev/null +++ b/packages/client/ui-session-panel/README.i18n.yaml @@ -0,0 +1,43 @@ +# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading +# section, a hash of its English and Chinese blocks outside code blocks and generated regions. +# After editing either side, bring the other along and re-record with: +# pnpm run verify-translation-pairing --write packages/client/ui-session-panel/README.md +/: + en: b40a112d76d02bc9 + zh: 1c004debcd32eeea +/deepseek-ai-dsh-client-ui-session-panel: + en: aff5b9d70836e810 + zh: 2cb8c75d3c82fba9 +/deepseek-ai-dsh-client-ui-session-panel/summary: + en: d80ba3f8b8bf0f6c + zh: eb9b13bbfc712eba +/deepseek-ai-dsh-client-ui-session-panel/table-of-contents: + en: d152484eb41ac6b4 + zh: 09388d293f9be9cb +/deepseek-ai-dsh-client-ui-session-panel/use-this-package: + en: d7818d67e981be3c + zh: c7c0c704d5ef8b34 +/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 +/deepseek-ai-dsh-client-ui-session-panel/understand-the-implementation: + en: e59cf3dc6b08e893 + zh: 33548291a59090c2 +/deepseek-ai-dsh-client-ui-session-panel/further-exploration: + en: 4ae4610263ad0c16 + zh: df16dc60d5af7740 +/deepseek-ai-dsh-client-ui-session-panel/model-experience: + en: 7e8bbe318a76fd54 + zh: c60e87da2a37642a +/deepseek-ai-dsh-client-ui-session-panel/model-experience/kv-cache-effect: + en: 47f982e326fe77fd + zh: 275b2ef7eec3ab19 +/deepseek-ai-dsh-client-ui-session-panel/known-limitations-and-deferred-work: + en: a0a860bdaf255e6a + zh: f46448570dcaec2c +/deepseek-ai-dsh-client-ui-session-panel/known-limitations-and-deferred-work/dev-note: + en: e67f633dc6fe7773 + zh: b532016223ceceef diff --git a/packages/client/ui-session-panel/README.md b/packages/client/ui-session-panel/README.md new file mode 100644 index 0000000000..b8d1ee4f87 --- /dev/null +++ b/packages/client/ui-session-panel/README.md @@ -0,0 +1,109 @@ +--- +description: "The Session panel: a header toggle and a floating panel over the main Conversation body whose sections other plugins register, with the built-in Environment section." +kind: "package-reference" +--- + +# @deepseek-ai/dsh-client-ui-session-panel + +English | [中文](README.zh.md) + +## Summary + +`dsh-client-ui-session-panel` adds a Session header toggle that shows or hides a floating panel of facts about the current Session. The panel docks in the main Conversation body's end gutter when the gutter can hold it, and otherwise opens over the transcript on request. It draws section titles and leaves section content to the plugins that register sections; it ships the Environment section with the project directory row. + +## Table of Contents + +- [Use this package](#use-this-package) +- [Understand the implementation](#understand-the-implementation) +- [Further Exploration](#further-exploration) +- [Model Experience](#model-experience) +- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work) +- [Dev Note](#dev-note) + +----- + + +## 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. + +### Docking and the overlay + +The panel docks while the gutter between the transcript column and the body's end edge is at least 344px: 48px clear of the column and its width handle, the panel's 280px minimum width, and a 16px edge margin. Docked, it is 280–340px wide, starts 12px below the header, and scrolls inside itself. Pressing the toggle then flips one docking preference that every Session shares and that persists in `localStorage` under `dsh.sessionPanel.pinned`; the panel docks by default. + +A narrower gutter hides the docked panel, so it never covers the transcript. This includes a narrow window, an expanded right sidebar, a dragged-wide transcript column, and every View other than Chat, because those Views fill the body. Pressing the toggle then opens the panel over the transcript with the prominent elevation, above the composer stack and not covering it. The overlay closes from the toggle, on Escape, and on a pointer press outside the panel, the toggle, and any open menu, such as a row's context menu; Escape returns focus to the toggle when focus was inside the panel, and a modal above the page keeps Escape. Closing it does not change the docking preference. At most one Session's overlay is open, and docking from a wide gutter closes it. + + +### 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. + +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. + +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. + +Summary rows from every package use the `PanelRow` primitive, so icon, text, and trailing areas line up across sections. + +----- + + +## Understand the implementation + +
+Implementation internals — click to expand + +The toggle and the panel are separate Slot entries that share one plugin-owned visibility source: the persisted docking preference and the Session whose overlay is open. Both read the Session's main body geometry from `ctx.uiConversation.layouts`, which the Conversation width controls write from their existing measurement, and decide the presentation with the same pure function, so the toggle's state never disagrees with the panel. The panel renders inside the main Conversation body, which owns its positioning context, the transcript axis, and the composer stack height. + +The panel projects the section list's live registrations (`entriesOfSlot`, so a higher-priority registration with the same `id` replaces a shipped section) into `{ id, label }` rows, recomputed only when the ledger version or the locale revision changes. It renders each section through `renderSlot(..., { only: id })` inside its own title and body; a CSS `:has()` rule hides a section whose body outlet stayed empty, including a shared section whose row outlet stayed empty. + +| File | Role | +|---|---| +| [`src/client/index.ts`](src/client/index.ts) | Dictionaries, the toggle, the panel, the Environment section, and the project row | +| [`src/client/slots.ts`](src/client/slots.ts) | Slot declarations and component props | +| [`src/client/visibility.ts`](src/client/visibility.ts) | Docking threshold, presentation, and the shared visibility state | +| [`src/client/sections.ts`](src/client/sections.ts) | Section roster projection | +| [`src/client/SessionPanel.tsx`](src/client/SessionPanel.tsx) | The panel, its section titles, and Escape handling | +| [`src/client/SessionPanelToggle.tsx`](src/client/SessionPanelToggle.tsx) | The header toggle and its indicators | +| [`src/client/ProjectRow.tsx`](src/client/ProjectRow.tsx) | The project directory row | + +
+ +----- + + +## Further Exploration + +- [Web Client Slots](../../../docs/subsystems/slots.md) — list, keyed, and owner-prop semantics the sections rely on. +- [`dsh-client-ui-conversation`](../ui-conversation/README.md) — the Session header utilities, the panel seat, and the main body geometry. +- [`dsh-client-ui-primitives`](../ui-primitives/README.md#component-catalog) — `PanelRow` and `PathLabel`. + +----- + + +## Model Experience + +None, as this package renders facts the Client already holds for a human and touches no prompt, message, schema, stream, or tool result. + +#### KV Cache effect + +None; the package never assembles or sends provider requests. + +## Known Limitations and Deferred Work + + + +These limits define current package constraints, not a task backlog. + +- **Laptop widths overlay rather than dock** — with the default transcript width the body must be at least about 1608px wide to dock; narrower bodies use the overlay. Docking by moving the transcript column aside is a separate layout decision. +- **No execution environment row** — the Client has no per-Session fact for the local machine, an SSH host, or the sandbox mode, so the Environment section names only the project directory. +- **No section customization** — every live section shows; hiding or reordering sections from the panel is not offered. + + +### Dev Note + +
+Working context for maintainers — click to expand + +None. + +
diff --git a/packages/client/ui-session-panel/README.zh.md b/packages/client/ui-session-panel/README.zh.md new file mode 100644 index 0000000000..b2e8b394bf --- /dev/null +++ b/packages/client/ui-session-panel/README.zh.md @@ -0,0 +1,109 @@ +--- +description: "会话面板:会话标题栏开关与主对话区上方的悬浮面板,分栏由其他插件注册,并内置「环境」分栏。" +kind: "package-reference" +--- + +# @deepseek-ai/dsh-client-ui-session-panel + +[English](README.md) | 中文 + +## 概述 + +`dsh-client-ui-session-panel` 在会话标题栏加一个开关,用来显示或隐藏一块汇总当前会话信息的悬浮面板。主对话区末端留白放得下面板时,面板停靠在留白里;放不下时,按需浮在对话正文上方。面板只绘制分栏标题,分栏内容交给注册分栏的插件;本包内置「环境」分栏及其项目目录行。 + +## 目录 + +- [使用本包](#use-this-package) +- [理解实现](#understand-the-implementation) +- [进一步探索](#further-exploration) +- [模型体验](#model-experience) +- [已知限制与延期工作](#known-limitations-and-deferred-work) +- [开发备注](#dev-note) + +----- + + +## 使用本包 + +`@deepseek-ai/dsh-web-app` 套件默认加载本包。开关是会话标题栏的第一个工具按钮,位于变更请求、共享和计划任务目录之前。它是图标按钮:无障碍名称由面板名称和其角标组成,提示文字说明按下后是显示还是隐藏面板,`aria-expanded` 表示面板当前是否显示。 + +### 停靠与浮层 + +正文列到对话区末端边缘的留白不少于 344px 时,面板停靠:与正文列及其宽度手柄保持 48px 间距,面板最小宽度 280px,外加 16px 边距。停靠时面板宽 280–340px,位于标题栏下方 12px,内容在面板内滚动。此时按开关会切换所有会话共用的停靠偏好,偏好存放在 `localStorage` 的 `dsh.sessionPanel.pinned` 中;默认停靠。 + +留白更窄时隐藏停靠面板,保证不遮挡正文。窗口变窄、展开右侧栏、把正文列拖宽,以及切换到 Chat 以外的视图(这些视图占满对话区)都会如此。此时按开关,面板以更强的阴影浮在正文上方,位于输入框区域之上,且不遮挡输入框。浮层可以用开关关闭,也会在按 Esc 时,或在面板、开关和任何已打开的菜单(例如行的上下文菜单)之外按下指针时关闭;焦点原本在面板内时,按 Esc 后焦点回到开关,页面上方有模态框时 Esc 归模态框处理。关闭浮层不改变停靠偏好。同一时间最多一个会话的浮层处于打开状态,在宽留白下切换停靠也会关闭它。 + + +### 贡献分栏 + +一个分栏是 `conversation.session.panel.section` 列表里的一次注册:`id` 用于寻址,`order` 升序排列,必填的 `label` 是标题,面板按当前语言绘制。分栏组件通过 owner props 收到 `presentation`(`docked` 或 `overlay`)和 `dismissOverlay()`;它负责渲染正文,没有内容时什么都不渲染,标题随之隐藏。标题尾部的控件(例如计数或刷新按钮)注册到以分栏 `id` 为键的 keyed slot `conversation.session.panel.section.actions`。缺少 label 的分栏会报告到控制台,并且不显示。 + +多个插件共用一个标题时,把行注册到分栏拥有者的行 slot 中。内置「环境」分栏(`id: 'environment'`,`order: 0`)声明 `conversation.session.panel.environment.row`;其 `project` 行(`order: 0`)显示列出本会话的工作区目录,或会话创建时所在的目录,宿主家目录缩写为 `~`。右键该行或点其「更多」按钮会打开共享的 `directory` 上下文菜单。拥有共享分栏的插件用同样方式声明自己的行 slot。 + +面板隐藏时也要可见的标记(例如需要处理的红点)放进 `conversation.session.panel.indicator` 列表。每个占位都带有说明自身的文字,这些文字会成为开关无障碍名称的一部分。 + +各包的摘要行都使用 `PanelRow` 原语,使不同分栏的图标、文字与尾部区域对齐。 + +----- + + +## 理解实现 + +
+实现内幕——点击展开 + +开关与面板是两个独立的 Slot 条目,共享一个插件持有的可见性 source:持久化的停靠偏好,以及打开了浮层的会话。两者都从 `ctx.uiConversation.layouts` 读取该会话的主对话区几何信息(由 Conversation 宽度控件在已有的测量中写入),并用同一个纯函数决定呈现方式,因此开关状态始终与面板一致。面板渲染在主对话区内部,对话区持有其定位上下文、正文轴线和输入框区域高度。 + +面板把分栏列表的实时注册(`entriesOfSlot`,因此同 `id` 且优先级更高的注册会替换已发布的分栏)投影为 `{ id, label }` 行,只在台账版本或语言版本变化时重新计算。它在各分栏自己的标题和正文容器里用 `renderSlot(..., { only: id })` 渲染内容;CSS `:has()` 规则隐藏正文出口为空的分栏,也包括行出口为空的共享分栏。 + +| 文件 | 作用 | +|---|---| +| [`src/client/index.ts`](src/client/index.ts) | 字典、开关、面板、「环境」分栏与项目行 | +| [`src/client/slots.ts`](src/client/slots.ts) | Slot 声明与组件 props | +| [`src/client/visibility.ts`](src/client/visibility.ts) | 停靠阈值、呈现方式与共享可见性状态 | +| [`src/client/sections.ts`](src/client/sections.ts) | 分栏名单投影 | +| [`src/client/SessionPanel.tsx`](src/client/SessionPanel.tsx) | 面板、分栏标题与 Esc 处理 | +| [`src/client/SessionPanelToggle.tsx`](src/client/SessionPanelToggle.tsx) | 标题栏开关及其角标 | +| [`src/client/ProjectRow.tsx`](src/client/ProjectRow.tsx) | 项目目录行 | + +
+ +----- + + +## 进一步探索 + +- [Web Client Slots](../../../docs/subsystems/slots.zh.md)——分栏依赖的 list、keyed 与 owner props 语义。 +- [`dsh-client-ui-conversation`](../ui-conversation/README.zh.md)——会话标题栏工具区、面板落位与主对话区几何信息。 +- [`dsh-client-ui-primitives`](../ui-primitives/README.zh.md#component-catalog)——`PanelRow` 与 `PathLabel`。 + +----- + + +## 模型体验 + +无。本包为用户展示客户端已有的信息,不涉及任何 prompt、消息、schema、流或工具结果。 + +#### KV 缓存影响 + +无;本包从不组装或发送模型请求。 + +## 已知限制与延期工作 + + + +以下限制定义的是当前包的约束,而非任务待办清单。 + +- **笔记本宽度下使用浮层而非停靠**——在默认正文宽度下,对话区宽度需约 1608px 以上才能停靠;更窄时使用浮层。通过把正文列移开来停靠属于另一项布局决策。 +- **没有运行环境行**——客户端没有区分本机、SSH 主机或沙箱模式的会话级信息,因此「环境」分栏只显示项目目录。 +- **不能自定义分栏**——所有有内容的分栏都会显示;面板不提供隐藏或重新排序分栏的功能。 + + +### 开发备注 + +
+维护者工作语境——点击展开 + +无。 + +
diff --git a/packages/client/ui-session-panel/locale/de.json b/packages/client/ui-session-panel/locale/de.json new file mode 100644 index 0000000000..251422de2d --- /dev/null +++ b/packages/client/ui-session-panel/locale/de.json @@ -0,0 +1,6 @@ +{ + "meta": { + "title": "Sitzungsbereich", + "description": "Ein schwebender Bereich, der sich über die Sitzungskopfzeile öffnet und Informationen zur aktuellen Sitzung bündelt, etwa ihr Projektverzeichnis." + } +} diff --git a/packages/client/ui-session-panel/locale/en.json b/packages/client/ui-session-panel/locale/en.json new file mode 100644 index 0000000000..b461d8432e --- /dev/null +++ b/packages/client/ui-session-panel/locale/en.json @@ -0,0 +1,6 @@ +{ + "meta": { + "title": "Session panel", + "description": "A floating panel opened from the Session header that gathers facts about the current Session, such as its project directory." + } +} diff --git a/packages/client/ui-session-panel/locale/es.json b/packages/client/ui-session-panel/locale/es.json new file mode 100644 index 0000000000..ef7f34e387 --- /dev/null +++ b/packages/client/ui-session-panel/locale/es.json @@ -0,0 +1,6 @@ +{ + "meta": { + "title": "Panel de la sesión", + "description": "Un panel flotante que se abre desde el encabezado de la sesión y reúne información de la sesión actual, como su directorio de proyecto." + } +} diff --git a/packages/client/ui-session-panel/locale/fr.json b/packages/client/ui-session-panel/locale/fr.json new file mode 100644 index 0000000000..289ee3e312 --- /dev/null +++ b/packages/client/ui-session-panel/locale/fr.json @@ -0,0 +1,6 @@ +{ + "meta": { + "title": "Panneau de session", + "description": "Un panneau flottant ouvert depuis l'en-tête de la session qui regroupe les informations de la session en cours, comme son dossier de projet." + } +} diff --git a/packages/client/ui-session-panel/locale/ja.json b/packages/client/ui-session-panel/locale/ja.json new file mode 100644 index 0000000000..deb479ceca --- /dev/null +++ b/packages/client/ui-session-panel/locale/ja.json @@ -0,0 +1,6 @@ +{ + "meta": { + "title": "セッションパネル", + "description": "セッションのヘッダーから開くフローティングパネルで、プロジェクトディレクトリなど現在のセッションに関する情報をまとめて表示します。" + } +} diff --git a/packages/client/ui-session-panel/locale/pt.json b/packages/client/ui-session-panel/locale/pt.json new file mode 100644 index 0000000000..b5e3f34378 --- /dev/null +++ b/packages/client/ui-session-panel/locale/pt.json @@ -0,0 +1,6 @@ +{ + "meta": { + "title": "Painel da sessão", + "description": "Um painel flutuante aberto pelo cabeçalho da sessão que reúne informações da sessão atual, como a pasta do projeto." + } +} diff --git a/packages/client/ui-session-panel/locale/ru.json b/packages/client/ui-session-panel/locale/ru.json new file mode 100644 index 0000000000..7ac5e13e5e --- /dev/null +++ b/packages/client/ui-session-panel/locale/ru.json @@ -0,0 +1,6 @@ +{ + "meta": { + "title": "Панель сеанса", + "description": "Плавающая панель, которая открывается из заголовка сеанса и собирает сведения о текущем сеансе, например его каталог проекта." + } +} diff --git a/packages/client/ui-session-panel/locale/zh.json b/packages/client/ui-session-panel/locale/zh.json new file mode 100644 index 0000000000..f7fb68e766 --- /dev/null +++ b/packages/client/ui-session-panel/locale/zh.json @@ -0,0 +1,6 @@ +{ + "meta": { + "title": "会话面板", + "description": "在会话标题栏打开悬浮面板,集中展示项目目录等与当前会话相关的信息。" + } +} diff --git a/packages/client/ui-session-panel/package.json b/packages/client/ui-session-panel/package.json new file mode 100644 index 0000000000..44aa1ebc95 --- /dev/null +++ b/packages/client/ui-session-panel/package.json @@ -0,0 +1,78 @@ +{ + "name": "@deepseek-ai/dsh-client-ui-session-panel", + "description": "Floating Session panel opened from the Session header, composed of sections that plugins register", + "version": "0.2.2-rc.1", + "type": "module", + "main": "lib/index.js", + "types": "lib/types/index.d.ts", + "exports": { + ".": { + "types": "./lib/types/index.d.ts", + "default": "./lib/index.js" + }, + "./client": { + "types": "./lib/types/client/index.d.ts", + "default": "./lib/client.js" + }, + "./src/*": "./src/*", + "./package.json": "./package.json", + "./locale/*.json": "./locale/*.json" + }, + "scripts": { + "bundle": "tsdown", + "watch": "tsdown --watch" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/deepseek-ai/deepseek-harness.git", + "directory": "packages/client/ui-session-panel" + }, + "publishConfig": { + "access": "public" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "workspace:~" + }, + "devDependencies": { + "@deepseek-ai/cordis": "workspace:~", + "@deepseek-ai/dsh-api-remotes": "workspace:*", + "@deepseek-ai/dsh-api-session-controller": "workspace:*", + "@deepseek-ai/dsh-api-workspace-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-primitives": "workspace:*", + "@deepseek-ai/dsh-client-ui-renderer": "workspace:*", + "@deepseek-ai/dsh-client-ui-session": "workspace:*", + "@deepseek-ai/dsh-client-ui-slots": "workspace:*", + "@deepseek-ai/dsh-session": "workspace:*", + "@deepseek-ai/dsh-util-workspace-path": "workspace:*", + "@deepseek-ai/dsh-workspace": "workspace:*", + "@testing-library/react": "^16.3.3", + "clsx": "^2.0.0", + "react": "^18.2.0", + "react-dom": "^18.2.0" + }, + "files": [ + "locale/*.json", + "lib/index.js", + "lib/client.js", + "lib/types/**/*.d.ts", + "lib/types/**/*.d.ts.map", + "lib/**/*.js.map", + "src" + ], + "dsh": { + "client": { + "inject": [ + "@deepseek-ai/dsh-client-locale", + "@deepseek-ai/dsh-client-ui-conversation", + "@deepseek-ai/dsh-client-ui-primitives" + ], + "platform": "web" + } + } +} diff --git a/packages/client/ui-session-panel/src/client/EnvironmentSection.tsx b/packages/client/ui-session-panel/src/client/EnvironmentSection.tsx new file mode 100644 index 0000000000..eeaa815bbf --- /dev/null +++ b/packages/client/ui-session-panel/src/client/EnvironmentSection.tsx @@ -0,0 +1,13 @@ +/** Built-in Environment section: one shared title over the rows other plugins register. */ +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. + * @returns the row outlet. + */ +export function EnvironmentSection({ renderSlot }: EnvironmentSectionProps): ReactNode { + return renderSlot('conversation.session.panel.environment.row', {}) +} diff --git a/packages/client/ui-session-panel/src/client/ProjectRow.module.css b/packages/client/ui-session-panel/src/client/ProjectRow.module.css new file mode 100644 index 0000000000..e4561fd1da --- /dev/null +++ b/packages/client/ui-session-panel/src/client/ProjectRow.module.css @@ -0,0 +1,12 @@ +/* The More button appears on row hover or focus; without hover it stays visible. */ +@media (hover: hover) { + .row .more { + opacity: 0; + } + + .row:hover .more, + .row:focus-within .more, + .more[aria-expanded='true'] { + opacity: 1; + } +} diff --git a/packages/client/ui-session-panel/src/client/ProjectRow.tsx b/packages/client/ui-session-panel/src/client/ProjectRow.tsx new file mode 100644 index 0000000000..9381ce1945 --- /dev/null +++ b/packages/client/ui-session-panel/src/client/ProjectRow.tsx @@ -0,0 +1,38 @@ +/** Environment row naming the Session's project directory. */ +import type { ReactNode } from 'react' +import { IconFolderCloseRegular, PanelRow, PathLabel } from '@deepseek-ai/dsh-client-ui-primitives' +import { abbreviateHomePath } from '@deepseek-ai/dsh-util-workspace-path' +import type { ProjectRowProps } from './slots.ts' +import css from './ProjectRow.module.css' + +/** + * Render the project directory: the Workspace that lists the Session, or the + * directory the Session was created in when no Workspace lists it. The row + * and its More button open the directory context menu. + * @param props - Session values, Workspace and Session list hooks, Host facts, menu bindings, and copy. + * @returns the row, or null before the Session's directory is known. + */ +export function ProjectRow({ + sessionId, useWorkspaces, useSessions, useHost, useContextMenu, renderFactorySlot, t, +}: ProjectRowProps): ReactNode { + const workspacePath = useWorkspaces(snapshot => snapshot.items.find(item => item.sessionIds.includes(sessionId))?.path) + const createdIn = useSessions(snapshot => snapshot.byId[sessionId]?.cwd) + const home = useHost(facts => facts.home) + const { getTriggerProps } = useContextMenu() + const path = workspacePath ?? createdIn + if (path === undefined) return null + const target = { kind: 'directory', value: { sessionId, path } } as const + return ( + } + trailing={renderFactorySlot('contextMenu.button', { + target, label: t('project.actions'), className: css.more, size: 'sm', + })} + data-session-panel-project="" + > + + + ) +} diff --git a/packages/client/ui-session-panel/src/client/SessionPanel.module.css b/packages/client/ui-session-panel/src/client/SessionPanel.module.css new file mode 100644 index 0000000000..f3bc08665e --- /dev/null +++ b/packages/client/ui-session-panel/src/client/SessionPanel.module.css @@ -0,0 +1,93 @@ +/* The panel floats over the main Conversation body (position: relative), + which defines the transcript axis --dsh-chat-content-width and publishes + the composer stack height --dsh-composer-height. */ +.panel { + position: absolute; + top: 12px; + right: 16px; + /* Above the turn rail (7), level with the back-to-bottom control (8), and + below the composer seat (9); the docked width keeps 48px clear of the + transcript column and its width handle. */ + z-index: 8; + box-sizing: border-box; + width: clamp(280px, calc((100% - var(--dsh-chat-content-width)) / 2 - 64px), 340px); + max-height: calc(100% - 24px); + overflow-y: auto; + overscroll-behavior: contain; + padding: 6px 8px; + border: 0; + border-radius: var(--dsw-radius-panel); + color: var(--dsw-alias-label-primary); + background: var(--dsw-alias-bg-layer-1); + box-shadow: var(--dsw-elevation-panel); + animation: dsh-session-panel-enter 120ms ease-out; +} + +/* Over the transcript the panel takes the prominent elevation and stops above + the composer stack, whose card it would otherwise cover. */ +.panel[data-session-panel='overlay'] { + right: 12px; + z-index: 10; + width: min(340px, calc(100% - 24px)); + max-height: calc(100% - var(--dsh-composer-height, 152px) - 24px); + box-shadow: var(--dsw-elevation-prominent); +} + +.section { + padding: 4px 0 6px; +} + +/* An empty body hides its section: a plain section renders into one outlet + anchor, and a shared section renders its own row outlet inside it. */ +.section:has(> .body > [data-slot]:empty), +.section:has(> .body > [data-slot] > [data-slot]:only-child:empty) { + display: none; +} + +.section:not(:has(> .body > [data-slot]:empty), :has(> .body > [data-slot] > [data-slot]:only-child:empty)) + ~ .section:not(:has(> .body > [data-slot]:empty), :has(> .body > [data-slot] > [data-slot]:only-child:empty)) { + margin-top: 2px; + padding-top: 8px; + border-top: 0.5px solid var(--dsw-alias-border-l2); +} + +.head { + display: flex; + align-items: center; + gap: 4px; + min-height: 24px; + padding: 0 6px; +} + +.title { + flex: 1 1 auto; + min-width: 0; + margin: 0; + overflow: hidden; + color: var(--dsw-alias-label-tertiary); + font: var(--dsw-font-xxs-12); + text-overflow: ellipsis; + white-space: nowrap; +} + +.actions { + display: inline-flex; + flex: none; + align-items: center; + gap: 2px; +} + +.actions:has(> [data-slot]:empty) { + display: none; +} + +@keyframes dsh-session-panel-enter { + from { opacity: 0; transform: translateY(-4px); } + to { opacity: 1; transform: translateY(0); } +} + +@media (prefers-reduced-motion: reduce) { + .panel { + animation: none; + } +} diff --git a/packages/client/ui-session-panel/src/client/SessionPanel.tsx b/packages/client/ui-session-panel/src/client/SessionPanel.tsx new file mode 100644 index 0000000000..ffe655bc7d --- /dev/null +++ b/packages/client/ui-session-panel/src/client/SessionPanel.tsx @@ -0,0 +1,93 @@ +/** Floating Session panel: section titles drawn from the section roster, bodies from the section slot. */ +import { useCallback, useEffect, useMemo, useRef, type ReactNode } from 'react' +import { isBehindModal } from '@deepseek-ai/dsh-client-ui-primitives' +import { panelElementId, toggleElementId } from './element-ids.ts' +import type { SessionPanelProps, SessionPanelSectionOwnerProps } from './slots.ts' +import { fitsLayout, presentationOf } from './visibility.ts' +import css from './SessionPanel.module.css' + +/** + * Close the overlay on Escape and on a pointerdown outside the panel. The + * toggle and open menus, such as a row's context menu, count as inside, and a + * modal above the page keeps Escape. Escape returns focus to the toggle when + * focus was inside the panel. + * @param panel - the overlay element. + * @param open - whether the overlay shows; false detaches the listeners. + * @param toggleId - id of the Session's toggle. + * @param close - closes the overlay. + */ +function useOverlayDismissal(panel: { readonly current: HTMLElement | null }, open: boolean, toggleId: string, close: () => void): void { + useEffect(() => { + if (!open) return + const inside = (target: EventTarget | null): boolean => target instanceof Element && ( + panel.current?.contains(target) === true + || document.getElementById(toggleId)?.contains(target) === true + || target.closest('[role="menu"]') !== null + ) + const onPointerDown = (event: PointerEvent): void => { + if (!inside(event.target)) close() + } + const onKeyDown = (event: KeyboardEvent): void => { + if (event.key !== 'Escape' || event.defaultPrevented || isBehindModal(panel.current)) return + event.preventDefault() + const focused = panel.current?.contains(document.activeElement) === true + close() + if (focused) document.getElementById(toggleId)?.focus() + } + document.addEventListener('pointerdown', onPointerDown) + document.addEventListener('keydown', onKeyDown) + return () => { + document.removeEventListener('pointerdown', onPointerDown) + document.removeEventListener('keydown', onKeyDown) + } + }, [panel, open, toggleId, close]) +} + +/** + * Render the panel while it docks or shows as an overlay. Each section keeps + * its title row and body; CSS hides a section whose body rendered nothing. + * The overlay closes on Escape and on an outside pointerdown. + * @param props - Session values, the main body layout, shared visibility, sections, and copy. + * @returns the panel, or null while it is hidden. + */ +export function SessionPanel({ + sessionId, useLayout, useVisibility, useSections, closeOverlay, renderSlot, t, +}: SessionPanelProps): ReactNode { + const fits = useLayout(fitsLayout) + const presentation = useVisibility(visibility => presentationOf(fits, visibility, sessionId)) + const sections = useSections(entries => entries) + const panel = useRef(null) + const dismissOverlay = useCallback(() => { closeOverlay(sessionId) }, [closeOverlay, sessionId]) + const owner = useMemo((): SessionPanelSectionOwnerProps | undefined => presentation === 'hidden' + ? undefined + : { presentation, dismissOverlay }, + [presentation, dismissOverlay]) + useOverlayDismissal(panel, presentation === 'overlay', toggleElementId(sessionId), dismissOverlay) + if (owner === undefined) return null + return ( + + ) +} diff --git a/packages/client/ui-session-panel/src/client/SessionPanelToggle.module.css b/packages/client/ui-session-panel/src/client/SessionPanelToggle.module.css new file mode 100644 index 0000000000..0b6b15562b --- /dev/null +++ b/packages/client/ui-session-panel/src/client/SessionPanelToggle.module.css @@ -0,0 +1,39 @@ +/* Icon-only header entry: the shared compact Button owns the radius, height, + and interaction fills, as for the header's other utilities. Indicators sit + at the glyph's top-right corner. */ +.trigger { + position: relative; + flex: none; + width: 28px; + padding: 0; + color: var(--dsw-alias-label-secondary); +} + +/* The panel shows; the expanded fill outranks the Button's hover fill. */ +.trigger[aria-expanded='true'] { + color: var(--dsw-alias-label-primary); + background: var(--dsw-alias-interactive-bg-active); +} + +@media (hover: hover) { + .trigger[aria-expanded='true']:hover:not(:disabled) { + color: var(--dsw-alias-label-primary); + background: var(--dsw-alias-interactive-bg-active); + } +} + +/* The name reaches assistive technology; the tooltip carries it visually. */ +.name { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; +} + +.trigger > :global([data-slot='conversation.session.panel.indicator']) > * { + position: absolute; + top: 6px; + right: 6px; +} diff --git a/packages/client/ui-session-panel/src/client/SessionPanelToggle.tsx b/packages/client/ui-session-panel/src/client/SessionPanelToggle.tsx new file mode 100644 index 0000000000..f99d9d487c --- /dev/null +++ b/packages/client/ui-session-panel/src/client/SessionPanelToggle.tsx @@ -0,0 +1,39 @@ +/** Session header entry that shows or hides the Session panel. */ +import type { ReactNode } from 'react' +import { Button, IconFlatListOutlineRegular, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives' +import { panelElementId, toggleElementId } from './element-ids.ts' +import type { SessionPanelToggleProps } from './slots.ts' +import { fitsLayout, presentationOf } from './visibility.ts' +import css from './SessionPanelToggle.module.css' + +/** + * Render the toggle. Its accessible name is the panel name followed by the + * text of any indicator; the expanded state says whether the panel shows. + * @param props - Session values, the main body layout, shared visibility, the toggle action, and copy. + * @returns the header entry. + */ +export function SessionPanelToggle({ + sessionId, useLayout, useVisibility, toggle, renderSlot, t, +}: SessionPanelToggleProps): ReactNode { + const fits = useLayout(fitsLayout) + const open = useVisibility(visibility => presentationOf(fits, visibility, sessionId) !== 'hidden') + return ( + + + + ) +} diff --git a/packages/client/ui-session-panel/src/client/element-ids.ts b/packages/client/ui-session-panel/src/client/element-ids.ts new file mode 100644 index 0000000000..f6e881ee55 --- /dev/null +++ b/packages/client/ui-session-panel/src/client/element-ids.ts @@ -0,0 +1,20 @@ +/** DOM ids that connect a Session's toggle and panel across their separate slot entries. */ +import type { SessionId } from '@deepseek-ai/dsh-session/types' + +/** + * Id of a Session's panel element, which the toggle names in `aria-controls`. + * @param sessionId - Session that owns the panel. + * @returns the element id. + */ +export function panelElementId(sessionId: SessionId): string { + return `dsh-session-panel-${sessionId}` +} + +/** + * Id of a Session's toggle, which receives focus when its overlay closes from the keyboard. + * @param sessionId - Session whose header holds the toggle. + * @returns the element id. + */ +export function toggleElementId(sessionId: SessionId): string { + return `dsh-session-panel-toggle-${sessionId}` +} diff --git a/packages/client/ui-session-panel/src/client/index.ts b/packages/client/ui-session-panel/src/client/index.ts new file mode 100644 index 0000000000..b2f9a1d4a9 --- /dev/null +++ b/packages/client/ui-session-panel/src/client/index.ts @@ -0,0 +1,99 @@ +/** + * Session panel plugin, browser half: a Session header toggle and a floating + * panel over the main Conversation body. The panel draws the titles of the + * sections other plugins register and ships the Environment section with the + * project directory row. + */ +import type { Context as ClientContext } from '@deepseek-ai/cordis' +import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store' +import type { SessionId } from '@deepseek-ai/dsh-session/types' +import type {} from '@deepseek-ai/dsh-client-ui-conversation/client' +import type { RemoteHostFacts } from '@deepseek-ai/dsh-api-remotes/client' +import type {} from '@deepseek-ai/dsh-client-locale/client' +import type {} from '@deepseek-ai/dsh-client-ui-renderer/client' +import { EnvironmentSection } from './EnvironmentSection.tsx' +import { ProjectRow } from './ProjectRow.tsx' +import { SessionPanel } from './SessionPanel.tsx' +import { SessionPanelToggle } from './SessionPanelToggle.tsx' +import { sectionSource } from './sections.ts' +import type { ProjectRowInjected, SessionPanelInjected, SessionPanelToggleInjected } from './slots.ts' +import { SessionPanelState } from './visibility.ts' +import { de, en, es, fr, ja, NS, pt, ru, zh, type SessionPanelKey } from './locales.ts' + +declare module '@deepseek-ai/dsh-client-ui-slots' { + interface LocaleNamespaceMap { + /** Session panel copy. */ + sessionPanel: SessionPanelKey + } +} + +export type { + EnvironmentSectionProps, ProjectRowInjected, ProjectRowProps, SessionPanelInjected, + SessionPanelPresentation, SessionPanelProps, SessionPanelSectionEntry, SessionPanelSectionOwnerProps, + SessionPanelToggleInjected, SessionPanelToggleProps, SessionPanelVisibility, +} from './slots.ts' + +/** Required services: the slot registry, dictionaries, Conversation layout, and the Host facts of the Remote carrier. */ +export const inject = ['slots', 'locale', 'uiConversation', 'remote'] + +/** + * Client plugin body: register the dictionaries, the header toggle, the panel, + * and the Environment section with its project row. + * @param ctx - client root context. + */ +export function apply(ctx: ClientContext): void { + ctx.effect(() => ctx.locale.register(NS, { zh, en, ja, es, fr, de, ru, pt }), 'ui-session-panel: dictionaries') + const t = ctx.locale.bind(NS) + const state = new SessionPanelState() + const sections = sectionSource(ctx) + const host: ObservableSnapshot = { + getSnapshot: () => ctx.remote.$host, + subscribe: listener => ctx.on('connection/reset', listener), + } + + ctx.slots.inject('conversation.session.header.utilities', () => ctx.slots.register({ + name: 'conversation.session.header.utilities', + id: 'session-panel', + // The first utility: left of change requests, sharing, and the schedule catalog. + order: -10, + locale: NS, + children: { + 'conversation.session.panel.indicator': { kind: 'list', scope: 'session', inline: true }, + }, + inject: (sessionId: SessionId): SessionPanelToggleInjected => ({ + hooks: { visibility: state.visibility, layout: ctx.uiConversation.layouts.source(sessionId) }, + toggle: (sessionId, fits) => { state.toggle(sessionId, fits) }, + }), + }, SessionPanelToggle)) + + ctx.slots.inject('conversation.session.panel', () => ctx.slots.register({ + name: 'conversation.session.panel', + locale: NS, + children: { + 'conversation.session.panel.section': { kind: 'list', scope: 'session' }, + 'conversation.session.panel.section.actions': { kind: 'keyed', scope: 'session' }, + }, + inject: (sessionId: SessionId): SessionPanelInjected => ({ + hooks: { visibility: state.visibility, layout: ctx.uiConversation.layouts.source(sessionId), sections }, + closeOverlay: (sessionId) => { state.closeOverlay(sessionId) }, + }), + }, SessionPanel)) + + ctx.slots.inject('conversation.session.panel.section', () => ctx.slots.register({ + name: 'conversation.session.panel.section', + id: 'environment', + order: 0, + label: () => t('section.environment'), + children: { + 'conversation.session.panel.environment.row': { kind: 'list', scope: 'session' }, + }, + }, EnvironmentSection)) + + ctx.slots.inject('conversation.session.panel.environment.row', () => ctx.slots.register({ + name: 'conversation.session.panel.environment.row', + id: 'project', + order: 0, + locale: NS, + inject: (): ProjectRowInjected => ({ hooks: { host } }), + }, ProjectRow)) +} diff --git a/packages/client/ui-session-panel/src/client/locales.ts b/packages/client/ui-session-panel/src/client/locales.ts new file mode 100644 index 0000000000..bdab6fdd5d --- /dev/null +++ b/packages/client/ui-session-panel/src/client/locales.ts @@ -0,0 +1,79 @@ +/** `sessionPanel` namespace dictionaries. */ + +/** Dictionary namespace owned by this plugin. */ +export const NS = 'sessionPanel' + +/** Simplified Chinese dictionary (the key-set source of truth). */ +export const zh = { + 'panel.name': '会话面板', + 'toggle.show': '显示会话面板', + 'toggle.hide': '隐藏会话面板', + 'section.environment': '环境', + 'project.actions': '项目目录操作', +} as const + +/** Every key of the `sessionPanel` namespace. */ +export type SessionPanelKey = keyof typeof zh + +/** English dictionary, key-identical to the Chinese source of truth. */ +export const en: Record = { + 'panel.name': 'Session panel', + 'toggle.show': 'Show session panel', + 'toggle.hide': 'Hide session panel', + 'section.environment': 'Environment', + 'project.actions': 'Project directory actions', +} + +/** Japanese dictionary. */ +export const ja = { + 'panel.name': 'セッションパネル', + 'toggle.show': 'セッションパネルを表示', + 'toggle.hide': 'セッションパネルを非表示', + 'section.environment': '環境', + 'project.actions': 'プロジェクトディレクトリの操作', +} satisfies Record + +/** Spanish dictionary. */ +export const es = { + 'panel.name': 'Panel de la sesión', + 'toggle.show': 'Mostrar el panel de la sesión', + 'toggle.hide': 'Ocultar el panel de la sesión', + 'section.environment': 'Entorno', + 'project.actions': 'Acciones del directorio del proyecto', +} satisfies Record + +/** French dictionary. */ +export const fr = { + 'panel.name': 'Panneau de session', + 'toggle.show': 'Afficher le panneau de session', + 'toggle.hide': 'Masquer le panneau de session', + 'section.environment': 'Environnement', + 'project.actions': 'Actions sur le dossier du projet', +} satisfies Record + +/** German dictionary. */ +export const de = { + 'panel.name': 'Sitzungsbereich', + 'toggle.show': 'Sitzungsbereich anzeigen', + 'toggle.hide': 'Sitzungsbereich ausblenden', + 'section.environment': 'Umgebung', + 'project.actions': 'Aktionen für das Projektverzeichnis', +} satisfies Record + +/** Russian dictionary. */ +export const ru = { + 'panel.name': 'Панель сеанса', + 'toggle.show': 'Показать панель сеанса', + 'toggle.hide': 'Скрыть панель сеанса', + 'section.environment': 'Среда', + 'project.actions': 'Действия с каталогом проекта', +} satisfies Record + +/** Brazilian Portuguese dictionary. */ +export const pt = { + 'panel.name': 'Painel da sessão', + 'toggle.show': 'Mostrar painel da sessão', + 'toggle.hide': 'Ocultar painel da sessão', + 'section.environment': 'Ambiente', + 'project.actions': 'Ações da pasta do projeto', +} satisfies Record diff --git a/packages/client/ui-session-panel/src/client/sections.ts b/packages/client/ui-session-panel/src/client/sections.ts new file mode 100644 index 0000000000..fcc9feed5e --- /dev/null +++ b/packages/client/ui-session-panel/src/client/sections.ts @@ -0,0 +1,66 @@ +/** Projection of the section list's registrations into the titles the panel draws. */ +import type { Context as ClientContext } from '@deepseek-ai/cordis' +import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store' +import { resolveSlotLabel, type StoredEntry } from '@deepseek-ai/dsh-client-ui-slots' +import type { SessionPanelSectionEntry } from './slots.ts' + +const SECTION_SLOT = 'conversation.session.panel.section' + +/** + * Project live section registrations in display order. A registration + * without a label cannot be titled; it is reported and left out. + * @param entries - shadowing winners of the section list in ledger order. + * @param report - receives one message per unlabeled registration. + * @returns sections ordered by ascending `order`, then registration order. + */ +export function projectSections( + entries: readonly StoredEntry[], report: (message: string) => void, +): readonly SessionPanelSectionEntry[] { + const rows: (SessionPanelSectionEntry & { readonly order: number })[] = [] + for (const entry of entries) { + /* v8 ignore next -- list registration validates id at load. */ + const id = entry.options.id ?? '' + const label = resolveSlotLabel(entry.options.label) + if (label === undefined || label === '') { + report(`ui-session-panel: section "${id}" from ${entry.registrant ?? 'an unknown registrant'} has no label and is not shown`) + continue + } + rows.push({ id, label, order: entry.options.order ?? 0 }) + } + return rows.sort((a, b) => a.order - b.order).map(({ id, label }) => ({ id, label })) +} + +/** + * Observable section roster: recomputed when the section list's ledger or + * the active locale changes, and identity-stable between changes. + * @param ctx - client context whose slot registry and locale the roster follows. + * @returns the section source. + */ +export function sectionSource(ctx: ClientContext): ObservableSnapshot { + let version = -1 + let revision = -1 + let sections: readonly SessionPanelSectionEntry[] = [] + return { + getSnapshot: () => { + const nextVersion = ctx.slots.getVersion(SECTION_SLOT) + const nextRevision = ctx.locale.getSnapshot().revision + if (nextVersion !== version || nextRevision !== revision) { + const reportOnce = version !== nextVersion + version = nextVersion + revision = nextRevision + sections = projectSections(ctx.slots.entriesOfSlot(SECTION_SLOT), (message) => { + if (reportOnce) console.error(message) + }) + } + return sections + }, + subscribe: (listener) => { + const offLedger = ctx.slots.subscribe(SECTION_SLOT, listener) + const offLocale = ctx.locale.subscribe(listener) + return () => { + offLedger() + offLocale() + } + }, + } +} diff --git a/packages/client/ui-session-panel/src/client/slots.ts b/packages/client/ui-session-panel/src/client/slots.ts new file mode 100644 index 0000000000..9cc9fc259d --- /dev/null +++ b/packages/client/ui-session-panel/src/client/slots.ts @@ -0,0 +1,132 @@ +/** Session panel slot declarations and composed component props. */ +import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store' +import type { + InjectFace, PropsLocale, PropsRenderFactories, PropsRenderSlots, PropsRuntime, +} from '@deepseek-ai/dsh-client-ui-slots' +import type { RemoteHostFacts } from '@deepseek-ai/dsh-api-remotes/client' +import type { SessionId } from '@deepseek-ai/dsh-session/types' +import type { ConversationLayout } from '@deepseek-ai/dsh-client-ui-conversation/client' +import type {} from '@deepseek-ai/dsh-client-ui-context-menu/client' +import type {} from '@deepseek-ai/dsh-client-ui-session/client' +import type { NS } from './locales.ts' + +declare module '@deepseek-ai/dsh-client-ui-slots' { + interface SlotMap { + /** + * Sections of the Session panel. `id` addresses the section, `order` sorts + * the sections ascending, and the required `label` is the section title, + * which the panel draws. A section with nothing to show renders nothing, + * and the panel hides its title with it. + */ + 'conversation.session.panel.section': { + kind: 'list' + scope: 'session' + owner: SessionPanelSectionOwnerProps + } + /** Trailing controls of one section title, keyed by the section's `id`. */ + 'conversation.session.panel.section.actions': { kind: 'keyed'; scope: 'session' } + /** + * Marks over the panel toggle, such as an attention dot. They stay visible + * while the panel is hidden; each occupant includes text that names it for + * 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' } + } +} + +/** How the panel currently shows. */ +export type SessionPanelPresentation = + /** Beside the transcript in the body's end gutter. */ + | 'docked' + /** Over the transcript, opened from the toggle while the gutter is too narrow. */ + | 'overlay' + +/** Values every section receives from the panel. */ +export interface SessionPanelSectionOwnerProps { + /** Current presentation; sections may lower their density in the overlay. */ + readonly presentation: SessionPanelPresentation + /** Close the overlay, for example after a row opened another surface; no effect while docked. */ + readonly dismissOverlay: () => void +} + +/** One section the panel draws, projected from the section list's registrations. */ +export interface SessionPanelSectionEntry { + /** Registration id. */ + readonly id: string + /** Localized title. */ + readonly label: string +} + +/** Panel visibility shared by the toggle and the panel. */ +export interface SessionPanelVisibility { + /** Whether the panel docks while the gutter has room; persisted across reloads. */ + readonly pinned: boolean + /** Session whose overlay is open, or null. */ + readonly overlay: SessionId | null +} + +/** Business face of the header toggle. */ +export interface SessionPanelToggleInjected { + /** Shared visibility and the Session's main body layout; the renderer binds them as `useVisibility` and `useLayout`. */ + readonly hooks: { + readonly visibility: ObservableSnapshot + readonly layout: ObservableSnapshot + } + /** + * Show or hide the panel. With room to dock this flips the docking + * preference and closes any overlay; otherwise it opens or closes the + * Session's overlay. + * @param sessionId - Session whose header holds the toggle. + * @param fits - whether the main body's gutter can hold the docked panel now. + */ + readonly toggle: (sessionId: SessionId, fits: boolean) => void +} + +/** Business face of the panel. */ +export interface SessionPanelInjected { + /** Shared visibility, the Session's main body layout, and the projected section roster. */ + readonly hooks: { + readonly visibility: ObservableSnapshot + readonly layout: ObservableSnapshot + readonly sections: ObservableSnapshot + } + /** + * Close the Session's overlay. + * @param sessionId - Session whose overlay closes; another Session's overlay stays. + */ + readonly closeOverlay: (sessionId: SessionId) => void +} + +/** Business face of the project row. */ +export interface ProjectRowInjected { + /** Host facts from the connection's ready frame; the renderer binds them as `useHost`. */ + readonly hooks: { readonly host: ObservableSnapshot } +} + +/** Full props of the header toggle. */ +export type SessionPanelToggleProps = + PropsRuntime<'conversation.session.header.utilities'> + & PropsRenderSlots<'conversation.session.panel.indicator'> + & InjectFace + & PropsLocale + +/** Full props of the panel. */ +export type SessionPanelProps = + PropsRuntime<'conversation.session.panel'> + & PropsRenderSlots<'conversation.session.panel.section' | 'conversation.session.panel.section.actions'> + & InjectFace + & PropsLocale + +/** Full props of the built-in Environment section. */ +export type EnvironmentSectionProps = + PropsRuntime<'conversation.session.panel.section'> + & PropsRenderSlots<'conversation.session.panel.environment.row'> + +/** Full props of the project row. */ +export type ProjectRowProps = + PropsRuntime<'conversation.session.panel.environment.row'> + & PropsRenderFactories + & InjectFace + & PropsLocale diff --git a/packages/client/ui-session-panel/src/client/visibility.ts b/packages/client/ui-session-panel/src/client/visibility.ts new file mode 100644 index 0000000000..627959db05 --- /dev/null +++ b/packages/client/ui-session-panel/src/client/visibility.ts @@ -0,0 +1,89 @@ +/** Session panel visibility: the persisted docking preference, the transient overlay, and their presentation. */ +import { createSnapshotStore, type ObservableSnapshot } from '@deepseek-ai/dsh-client-store' +import type { SessionId } from '@deepseek-ai/dsh-session/types' +import type { ConversationLayout } from '@deepseek-ai/dsh-client-ui-conversation/client' +import type { SessionPanelPresentation, SessionPanelVisibility } from './slots.ts' + +/** localStorage key of the docking preference. */ +export const PINNED_STORAGE_KEY = 'dsh.sessionPanel.pinned' + +/** + * Smallest end gutter that holds the docked panel, in CSS px: 48px clear of + * the transcript column (past the width handle's 24px offset and 10px strip), + * the panel's 280px minimum width, and a 16px edge margin. + */ +export const DOCK_MIN_GUTTER = 344 + +/** + * Whether the main body's end gutter can hold the docked panel. + * @param layout - main body geometry of the Session. + * @returns true when the panel can dock without covering the transcript. + */ +export function fitsLayout(layout: ConversationLayout): boolean { + return layout.endGutter >= DOCK_MIN_GUTTER +} + +/** + * Decide how the panel shows for one Session. + * @param fits - whether the gutter can hold the docked panel. + * @param visibility - shared visibility state. + * @param sessionId - Session whose panel is decided. + * @returns the presentation, or `hidden` when the panel renders nothing. + */ +export function presentationOf( + fits: boolean, visibility: SessionPanelVisibility, sessionId: SessionId, +): SessionPanelPresentation | 'hidden' { + if (fits) return visibility.pinned ? 'docked' : 'hidden' + return visibility.overlay === sessionId ? 'overlay' : 'hidden' +} + +/** + * Visibility shared by every Session's toggle and panel. Docking follows one + * preference for all Sessions; at most one Session's overlay is open. + */ +export class SessionPanelState { + // A stored value other than `false` keeps the default: the panel docks. + private readonly pinned = createSnapshotStore(true, { persist: { name: PINNED_STORAGE_KEY } }) + private readonly overlay = createSnapshotStore(null) + private current: SessionPanelVisibility = { pinned: this.pinned.getSnapshot() !== false, overlay: null } + + /** Combined visibility; the snapshot keeps its identity until a member changes. */ + readonly visibility: ObservableSnapshot = { + getSnapshot: () => { + const pinned = this.pinned.getSnapshot() !== false + const overlay = this.overlay.getSnapshot() + if (pinned !== this.current.pinned || overlay !== this.current.overlay) this.current = { pinned, overlay } + return this.current + }, + subscribe: (listener) => { + const offPinned = this.pinned.subscribe(listener) + const offOverlay = this.overlay.subscribe(listener) + return () => { + offPinned() + offOverlay() + } + }, + } + + /** + * Show or hide the panel from a Session's toggle. + * @param sessionId - Session whose header holds the toggle. + * @param fits - whether the gutter can hold the docked panel now. + */ + toggle(sessionId: SessionId, fits: boolean): void { + if (fits) { + this.pinned.set(!this.visibility.getSnapshot().pinned) + this.overlay.set(null) + return + } + this.overlay.set(this.overlay.getSnapshot() === sessionId ? null : sessionId) + } + + /** + * Close a Session's overlay. + * @param sessionId - Session whose overlay closes; another Session's overlay stays open. + */ + closeOverlay(sessionId: SessionId): void { + if (this.overlay.getSnapshot() === sessionId) this.overlay.set(null) + } +} diff --git a/packages/client/ui-session-panel/src/css-modules.d.ts b/packages/client/ui-session-panel/src/css-modules.d.ts new file mode 100644 index 0000000000..8811db1264 --- /dev/null +++ b/packages/client/ui-session-panel/src/css-modules.d.ts @@ -0,0 +1,4 @@ +declare module '*.module.css' { + const classes: Record + export default classes +} diff --git a/packages/client/ui-session-panel/src/index.ts b/packages/client/ui-session-panel/src/index.ts new file mode 100644 index 0000000000..76ee1f0c6a --- /dev/null +++ b/packages/client/ui-session-panel/src/index.ts @@ -0,0 +1,9 @@ +/** + * Node half of the Session panel plugin. The browser half in `src/client/` + * owns every contribution; this entry exists so the package appears as an + * ordinary Loader row. + * @module @deepseek-ai/dsh-client-ui-session-panel + */ + +/** Loader-visible no-op body; the browser half carries the feature. */ +export function apply(): void {} diff --git a/packages/client/ui-session-panel/tests/browser-plugin.client.spec.ts b/packages/client/ui-session-panel/tests/browser-plugin.client.spec.ts new file mode 100644 index 0000000000..d65e7daf10 --- /dev/null +++ b/packages/client/ui-session-panel/tests/browser-plugin.client.spec.ts @@ -0,0 +1,144 @@ +/** + * ui-session-panel plugin halves: the browser entry's dictionaries, header + * toggle, panel, Environment section, and project row against the real + * SlotRegistry, the inject faces those entries receive, the section roster + * projection, fiber teardown removing every contribution (HMR safety), and + * the inert node entry. + */ +import { afterEach, describe, expect, it, vi } from 'vitest' +import { Context } from '@deepseek-ai/cordis' +import { createSnapshotStore } from '@deepseek-ai/dsh-client-store' +import { SlotRegistry } from '@deepseek-ai/dsh-client-ui-renderer/client' +import { stubConfigForm } from '@deepseek-ai/dsh-client-test-runtime' +import { apply as applyLocale, inject as localeInject } from '@deepseek-ai/dsh-client-locale/client' +import type { ConversationLayout } from '@deepseek-ai/dsh-client-ui-conversation/client' +import type { SessionId } from '@deepseek-ai/dsh-session/types' +import { apply, inject } from '../src/client/index.ts' +import type { ProjectRowInjected, SessionPanelInjected, SessionPanelToggleInjected } from '../src/client/slots.ts' +import { apply as applyNode } from '../src/index.ts' + +const SID = 'session-1' as SessionId + +afterEach(() => { + vi.restoreAllMocks() +}) + +/** Boot the browser half over a real slot tree that declares the header utilities and the panel seat. */ +async function bench() { + const ctx = new Context() + await ctx.plugin(SlotRegistry).await() + ctx.slots.register({ + name: 'root', + children: { + 'conversation.session.header.utilities': { kind: 'list', scope: 'session' }, + 'conversation.session.panel': { kind: 'single', scope: 'session' }, + }, + } as never, () => null) + const layout = createSnapshotStore({ endGutter: 400 }) + const layoutSources: SessionId[] = [] + ctx.provide('uiConversation', { + layouts: { + source: (sessionId: SessionId) => { + layoutSources.push(sessionId) + return layout + }, + }, + } as never) + const host = { home: '/Users/me', isLoopback: true } + ctx.provide('connection', { api: { settings: {} }, isLoopback: false } as never) + ctx.provide('remote', { $on: () => () => {}, $host: host } as never) + ctx.provide('configForms', { developerTools: { enabled: createSnapshotStore(true) }, get: () => stubConfigForm().scope } as never) + await ctx.plugin({ inject: localeInject, apply: applyLocale }).await() + ctx.locale.setLocale('zh') + const fiber = ctx.plugin({ inject: [...inject], apply }) + await fiber.await() + return { ctx, fiber, layout, layoutSources, host } +} + +/** Inject face of one registration, called for the test Session. */ +function faceOf(ctx: Context, slot: string, id: string | undefined): unknown { + const entry = ctx.slots.entries(slot as never).find(candidate => candidate.options.id === id) + const face = entry?.inject as ((sessionId: SessionId) => unknown) | undefined + if (face === undefined) throw new Error(`${slot} entry ${id ?? '(single)'} registered no inject face`) + return face(SID) +} + +describe('ui-session-panel browser half', () => { + it('declares the services it binds', () => { + expect(inject).toEqual(['slots', 'locale', 'uiConversation', 'remote']) + }) + + it('registers the toggle first among the header utilities, the panel, the Environment section, and the project row', async () => { + const { ctx } = await bench() + const toggle = ctx.slots.entries('conversation.session.header.utilities').find(entry => entry.options.id === 'session-panel') + expect(toggle?.options.order).toBe(-10) + expect(ctx.slots.entries('conversation.session.panel')).toHaveLength(1) + const section = ctx.slots.entries('conversation.session.panel.section').find(entry => entry.options.id === 'environment') + expect(section?.options.order).toBe(0) + expect(ctx.slots.entries('conversation.session.panel.environment.row').map(entry => entry.options.id)).toEqual(['project']) + }) + + it('hands the toggle and the panel the shared visibility and the Session layout source', async () => { + const { ctx, layout, layoutSources } = await bench() + const toggle = faceOf(ctx, 'conversation.session.header.utilities', 'session-panel') as SessionPanelToggleInjected + const panel = faceOf(ctx, 'conversation.session.panel', undefined) as SessionPanelInjected + expect(toggle.hooks.layout).toBe(layout) + expect(panel.hooks.layout).toBe(layout) + expect(layoutSources).toEqual([SID, SID]) + expect(toggle.hooks.visibility).toBe(panel.hooks.visibility) + toggle.toggle(SID, false) + expect(panel.hooks.visibility.getSnapshot()).toEqual({ pinned: true, overlay: SID }) + panel.closeOverlay(SID) + expect(panel.hooks.visibility.getSnapshot().overlay).toBeNull() + }) + + it('projects the section roster in the active locale and keeps it stable between changes', async () => { + const { ctx } = await bench() + const panel = faceOf(ctx, 'conversation.session.panel', undefined) as SessionPanelInjected + const roster = panel.hooks.sections + const first = roster.getSnapshot() + expect(first).toEqual([{ id: 'environment', label: '环境' }]) + expect(roster.getSnapshot()).toBe(first) + const listener = vi.fn() + const off = roster.subscribe(listener) + ctx.locale.setLocale('en') + expect(listener).toHaveBeenCalled() + expect(roster.getSnapshot()).toEqual([{ id: 'environment', label: 'Environment' }]) + + const error = vi.spyOn(console, 'error').mockImplementation(() => {}) + const dispose = ctx.slots.register({ name: 'conversation.session.panel.section', id: 'untitled', order: 5 }, () => null) + expect(roster.getSnapshot()).toEqual([{ id: 'environment', label: 'Environment' }]) + roster.getSnapshot() + expect(error).toHaveBeenCalledTimes(1) + ctx.locale.setLocale('zh') + roster.getSnapshot() + expect(error).toHaveBeenCalledTimes(1) + dispose() + off() + }) + + it('gives the project row the Host facts and follows connection resets', async () => { + const { ctx, host } = await bench() + const row = faceOf(ctx, 'conversation.session.panel.environment.row', 'project') as ProjectRowInjected + expect(row.hooks.host.getSnapshot()).toBe(host) + const listener = vi.fn() + const off = row.hooks.host.subscribe(listener) + ctx.emit('connection/reset' as never) + expect(listener).toHaveBeenCalledTimes(1) + off() + }) + + it('removes every contribution with the fiber (HMR safety)', async () => { + const { ctx, fiber } = await bench() + await fiber.dispose() + expect(ctx.slots.entries('conversation.session.header.utilities')).toHaveLength(0) + expect(ctx.slots.entries('conversation.session.panel')).toHaveLength(0) + expect(ctx.slots.entries('conversation.session.panel.section')).toHaveLength(0) + }) +}) + +describe('ui-session-panel node half', () => { + it('contributes no host behavior', () => { + expect(applyNode).not.toThrow() + }) +}) diff --git a/packages/client/ui-session-panel/tests/components.client.spec.tsx b/packages/client/ui-session-panel/tests/components.client.spec.tsx new file mode 100644 index 0000000000..ecdf182cdf --- /dev/null +++ b/packages/client/ui-session-panel/tests/components.client.spec.tsx @@ -0,0 +1,272 @@ +// @vitest-environment jsdom +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { cleanup, fireEvent, render, screen } from '@testing-library/react' +import type { ReactNode } from 'react' +import { contextMenuHook, makeTranslate } from '@deepseek-ai/dsh-client-test-runtime' +import type { ConversationLayout } from '@deepseek-ai/dsh-client-ui-conversation/client' +import type { SessionId } from '@deepseek-ai/dsh-session/types' +import { EnvironmentSection } from '../src/client/EnvironmentSection.tsx' +import { ProjectRow } from '../src/client/ProjectRow.tsx' +import { SessionPanel } from '../src/client/SessionPanel.tsx' +import { SessionPanelToggle } from '../src/client/SessionPanelToggle.tsx' +import type { + EnvironmentSectionProps, ProjectRowProps, SessionPanelProps, SessionPanelSectionEntry, + SessionPanelSectionOwnerProps, SessionPanelToggleProps, SessionPanelVisibility, +} from '../src/client/slots.ts' +import { DOCK_MIN_GUTTER } from '../src/client/visibility.ts' +import { en, zh } from '../src/client/locales.ts' + +const SID = 'session-1' as SessionId +const t = makeTranslate(zh) as SessionPanelToggleProps['t'] +const WIDE: ConversationLayout = { endGutter: DOCK_MIN_GUTTER } +const NARROW: ConversationLayout = { endGutter: DOCK_MIN_GUTTER - 1 } +const DOCKED: SessionPanelVisibility = { pinned: true, overlay: null } + +function selectorOf(value: T) { + return (select: (current: T) => S): S => select(value) +} + +beforeEach(() => { + vi.stubGlobal('ResizeObserver', class { + observe(): void {} + unobserve(): void {} + disconnect(): void {} + }) + vi.stubGlobal('matchMedia', vi.fn(() => ({ matches: true, addEventListener() {}, removeEventListener() {} }))) +}) + +afterEach(() => { + cleanup() + vi.unstubAllGlobals() +}) + +describe('SessionPanelToggle', () => { + function toggleProps(layout: ConversationLayout, visibility: SessionPanelVisibility, toggle = vi.fn()) { + const renderSlot = vi.fn(() => 需要处理) + const props = { + sessionId: SID, useLayout: selectorOf(layout), useVisibility: selectorOf(visibility), toggle, renderSlot, t, + } as SessionPanelToggleProps + return { props, toggle, renderSlot } + } + + it('names the panel together with its indicators and reports the docked panel as expanded', () => { + const { props, renderSlot } = toggleProps(WIDE, DOCKED) + render() + const button = screen.getByRole('button', { name: '会话面板 需要处理' }) + expect(button.getAttribute('aria-expanded')).toBe('true') + expect(button.getAttribute('aria-controls')).toBe(`dsh-session-panel-${SID}`) + expect(renderSlot).toHaveBeenCalledWith('conversation.session.panel.indicator', {}) + }) + + it('flips docking with room to dock and opens the overlay without it', () => { + const wide = toggleProps(WIDE, DOCKED) + render() + fireEvent.click(screen.getByRole('button')) + expect(wide.toggle).toHaveBeenCalledWith(SID, true) + cleanup() + const narrow = toggleProps(NARROW, DOCKED) + render() + const button = screen.getByRole('button') + expect(button.getAttribute('aria-expanded')).toBe('false') + expect(button.hasAttribute('aria-controls')).toBe(false) + fireEvent.click(button) + expect(narrow.toggle).toHaveBeenCalledWith(SID, false) + }) + + it('reports an open overlay as expanded', () => { + const { props } = toggleProps(NARROW, { pinned: false, overlay: SID }) + render() + expect(screen.getByRole('button').getAttribute('aria-expanded')).toBe('true') + }) +}) + +describe('SessionPanel', () => { + const SECTIONS: readonly SessionPanelSectionEntry[] = [ + { id: 'environment', label: '环境' }, + { id: 'change-requests', label: '变更请求' }, + ] + + function panelProps(layout: ConversationLayout, visibility: SessionPanelVisibility, closeOverlay = vi.fn()) { + const owners: SessionPanelSectionOwnerProps[] = [] + const renderSlot = ((key: string, owner: object, opts?: { only?: string; entryKey?: string }): ReactNode => { + if (key === 'conversation.session.panel.section.actions') { + return opts?.entryKey === 'change-requests' ? : null + } + owners.push(owner as SessionPanelSectionOwnerProps) + return

{`${opts?.only ?? ''} body`}

+ }) as SessionPanelProps['renderSlot'] + const props = { + sessionId: SID, + useLayout: selectorOf(layout), + useVisibility: selectorOf(visibility), + useSections: selectorOf(SECTIONS), + closeOverlay, + renderSlot, + t, + } as SessionPanelProps + return { props, owners, closeOverlay } + } + + it('renders nothing while hidden', () => { + const { props } = panelProps(WIDE, { pinned: false, overlay: null }) + const view = render() + expect(view.container.innerHTML).toBe('') + }) + + it('docks with one titled region per section in roster order and each section body', () => { + const { props, owners } = panelProps(WIDE, DOCKED) + render() + const panel = screen.getByRole('complementary', { name: '会话面板' }) + expect(panel.getAttribute('data-session-panel')).toBe('docked') + expect(panel.id).toBe(`dsh-session-panel-${SID}`) + const regions = screen.getAllByRole('region') + expect(regions.map(region => region.getAttribute('aria-labelledby'))).toEqual([ + `dsh-session-panel-${SID}-environment`, `dsh-session-panel-${SID}-change-requests`, + ]) + expect(screen.getByRole('heading', { name: '变更请求' })).toBeTruthy() + expect(screen.getByText('environment body')).toBeTruthy() + expect(screen.getByRole('button', { name: '刷新' })).toBeTruthy() + expect(owners.every(owner => owner.presentation === 'docked')).toBe(true) + }) + + it('closes the overlay on Escape from inside and returns focus to the toggle', () => { + const { props, owners, closeOverlay } = panelProps(NARROW, { pinned: true, overlay: SID }) + const toggle = document.createElement('button') + toggle.id = `dsh-session-panel-toggle-${SID}` + document.body.append(toggle) + try { + render() + const panel = screen.getByRole('complementary') + expect(panel.getAttribute('data-session-panel')).toBe('overlay') + fireEvent.keyDown(document, { key: 'Enter' }) + expect(closeOverlay).not.toHaveBeenCalled() + screen.getByRole('button', { name: '刷新' }).focus() + fireEvent.keyDown(document.activeElement as Element, { key: 'Escape' }) + expect(closeOverlay).toHaveBeenCalledWith(SID) + expect(document.activeElement).toBe(toggle) + owners[0]?.dismissOverlay() + expect(closeOverlay).toHaveBeenCalledTimes(2) + } finally { + toggle.remove() + } + }) + + it('closes the overlay on Escape from the page without moving focus', () => { + const { props, closeOverlay } = panelProps(NARROW, { pinned: true, overlay: SID }) + render() + const outside = document.createElement('input') + document.body.append(outside) + try { + outside.focus() + fireEvent.keyDown(outside, { key: 'Escape' }) + expect(closeOverlay).toHaveBeenCalledWith(SID) + expect(document.activeElement).toBe(outside) + } finally { + outside.remove() + } + }) + + it('closes the overlay on an outside pointerdown but not on the panel, the toggle, or an open menu', () => { + const { props, closeOverlay } = panelProps(NARROW, { pinned: true, overlay: SID }) + const toggle = document.createElement('button') + toggle.id = `dsh-session-panel-toggle-${SID}` + const menu = document.createElement('div') + menu.setAttribute('role', 'menu') + const item = document.createElement('button') + menu.append(item) + document.body.append(toggle, menu) + try { + render() + fireEvent.pointerDown(screen.getByText('environment body')) + fireEvent.pointerDown(toggle) + fireEvent.pointerDown(item) + expect(closeOverlay).not.toHaveBeenCalled() + fireEvent.pointerDown(document.body) + expect(closeOverlay).toHaveBeenCalledWith(SID) + } finally { + toggle.remove() + menu.remove() + } + }) + + it('leaves Escape to other handlers while docked, after another handler took it, or behind a modal', () => { + const docked = panelProps(WIDE, DOCKED) + render() + fireEvent.keyDown(document, { key: 'Escape' }) + fireEvent.pointerDown(document.body) + expect(docked.closeOverlay).not.toHaveBeenCalled() + cleanup() + const overlay = panelProps(NARROW, { pinned: true, overlay: SID }) + render() + const event = new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, cancelable: true }) + event.preventDefault() + document.dispatchEvent(event) + expect(overlay.closeOverlay).not.toHaveBeenCalled() + }) +}) + +describe('EnvironmentSection', () => { + it('renders its rows straight into the section body', () => { + const renderSlot = vi.fn(() => row) + render(<>{EnvironmentSection({ renderSlot } as EnvironmentSectionProps)}) + expect(renderSlot).toHaveBeenCalledWith('conversation.session.panel.environment.row', {}) + expect(screen.getByText('row')).toBeTruthy() + }) +}) + +describe('ProjectRow', () => { + function rowProps(over: { + workspacePath?: string + cwd?: string + home?: string + }, open = vi.fn()) { + const renderFactorySlot = vi.fn((_name: string, input: { label: string }) => ) + const props = { + sessionId: SID, + useWorkspaces: selectorOf({ + items: over.workspacePath === undefined ? [] : [{ path: over.workspacePath, sessionIds: [SID] }], + }), + useSessions: selectorOf({ byId: over.cwd === undefined ? {} : { [SID]: { cwd: over.cwd } } }), + useHost: selectorOf({ home: over.home, isLoopback: true }), + useContextMenu: contextMenuHook(open), + renderFactorySlot, + t, + } as ProjectRowProps + return { props, renderFactorySlot, open } + } + + it('shows the listing Workspace directory with the home directory abbreviated', () => { + const { props, renderFactorySlot } = rowProps({ + workspacePath: '/Users/me/projects/deepseek-harness', cwd: '/Users/me/elsewhere', home: '/Users/me', + }) + const view = render() + const label = view.container.querySelector('[data-path-label]') as HTMLElement + expect(label.getAttribute('title')).toBe('~/projects/deepseek-harness') + expect(renderFactorySlot).toHaveBeenCalledWith('contextMenu.button', expect.objectContaining({ + target: { kind: 'directory', value: { sessionId: SID, path: '/Users/me/projects/deepseek-harness' } }, + label: '项目目录操作', + size: 'sm', + })) + expect(screen.getByRole('button', { name: '项目目录操作' })).toBeTruthy() + }) + + it('falls back to the directory the Session was created in and opens the directory menu on right-click', () => { + const { props, open } = rowProps({ cwd: '/srv/app' }) + const view = render() + expect(view.container.querySelector('[data-path-label]')?.getAttribute('title')).toBe('/srv/app') + fireEvent.contextMenu(view.container.querySelector('[data-session-panel-project]') as HTMLElement) + expect(open).toHaveBeenCalledWith({ kind: 'directory', value: { sessionId: SID, path: '/srv/app' } }, expect.anything()) + }) + + it('renders nothing before the Session directory is known', () => { + const { props } = rowProps({}) + const view = render() + expect(view.container.innerHTML).toBe('') + }) +}) + +describe('dictionaries', () => { + it('keeps the English dictionary key-identical to the Chinese source of truth', () => { + expect(Object.keys(en).sort()).toEqual(Object.keys(zh).sort()) + }) +}) diff --git a/packages/client/ui-session-panel/tests/sections.client.spec.ts b/packages/client/ui-session-panel/tests/sections.client.spec.ts new file mode 100644 index 0000000000..5500f97256 --- /dev/null +++ b/packages/client/ui-session-panel/tests/sections.client.spec.ts @@ -0,0 +1,43 @@ +import { describe, expect, it, vi } from 'vitest' +import type { StoredEntry } from '@deepseek-ai/dsh-client-ui-slots' +import { projectSections } from '../src/client/sections.ts' + +function entry(id: string, order: number | undefined, label: StoredEntry['options']['label'], registrant?: string): StoredEntry { + return { + component: () => null, + options: { id, ...order === undefined ? {} : { order }, ...label === undefined ? {} : { label } }, + ...registrant === undefined ? {} : { registrant }, + } +} + +describe('projectSections', () => { + it('orders sections by ascending order, keeping registration order for ties, and resolves locale thunks', () => { + const report = vi.fn() + const sections = projectSections([ + entry('later', 100, 'Change requests'), + entry('first', 0, () => 'Environment'), + entry('tie', 100, 'Outputs'), + entry('default', undefined, 'Default order'), + ], report) + expect(sections).toEqual([ + { id: 'first', label: 'Environment' }, + { id: 'default', label: 'Default order' }, + { id: 'later', label: 'Change requests' }, + { id: 'tie', label: 'Outputs' }, + ]) + expect(report).not.toHaveBeenCalled() + }) + + it('reports and leaves out a section that cannot be titled', () => { + const report = vi.fn() + const sections = projectSections([ + entry('untitled', 0, undefined, 'acme-plugin'), + entry('blank', 1, ''), + entry('titled', 2, 'Titled'), + ], report) + expect(sections).toEqual([{ id: 'titled', label: 'Titled' }]) + expect(report).toHaveBeenCalledTimes(2) + expect(report.mock.calls[0]?.[0]).toContain('"untitled" from acme-plugin') + expect(report.mock.calls[1]?.[0]).toContain('"blank" from an unknown registrant') + }) +}) diff --git a/packages/client/ui-session-panel/tests/visibility.client.spec.ts b/packages/client/ui-session-panel/tests/visibility.client.spec.ts new file mode 100644 index 0000000000..20d6baabb2 --- /dev/null +++ b/packages/client/ui-session-panel/tests/visibility.client.spec.ts @@ -0,0 +1,89 @@ +// @vitest-environment jsdom +import { afterEach, beforeEach, describe, expect, it } from 'vitest' +import type { SessionId } from '@deepseek-ai/dsh-session/types' +import { + DOCK_MIN_GUTTER, PINNED_STORAGE_KEY, SessionPanelState, fitsLayout, presentationOf, +} from '../src/client/visibility.ts' + +const A = 'session-a' as SessionId +const B = 'session-b' as SessionId + +beforeEach(() => { localStorage.clear() }) +afterEach(() => { localStorage.clear() }) + +describe('fitsLayout', () => { + it('docks only from the minimum gutter up', () => { + expect(fitsLayout({ endGutter: DOCK_MIN_GUTTER - 1 })).toBe(false) + expect(fitsLayout({ endGutter: DOCK_MIN_GUTTER })).toBe(true) + expect(fitsLayout({ endGutter: 0 })).toBe(false) + }) +}) + +describe('presentationOf', () => { + it.each([ + [true, true, null, 'docked'], + [true, true, A, 'docked'], + [true, false, null, 'hidden'], + [true, false, A, 'hidden'], + [false, true, null, 'hidden'], + [false, false, null, 'hidden'], + [false, true, A, 'overlay'], + [false, false, A, 'overlay'], + [false, true, B, 'hidden'], + ] as const)('fits=%s pinned=%s overlay=%s shows %s', (fits, pinned, overlay, expected) => { + expect(presentationOf(fits, { pinned, overlay }, A)).toBe(expected) + }) +}) + +describe('SessionPanelState', () => { + it('docks by default and keeps the snapshot identity until a member changes', () => { + const state = new SessionPanelState() + const first = state.visibility.getSnapshot() + expect(first).toEqual({ pinned: true, overlay: null }) + expect(state.visibility.getSnapshot()).toBe(first) + }) + + it('flips and persists the docking preference when the gutter has room, closing any overlay', () => { + const state = new SessionPanelState() + state.toggle(A, false) + expect(state.visibility.getSnapshot().overlay).toBe(A) + state.toggle(A, true) + expect(state.visibility.getSnapshot()).toEqual({ pinned: false, overlay: null }) + expect(localStorage.getItem(PINNED_STORAGE_KEY)).toBe('false') + expect(new SessionPanelState().visibility.getSnapshot().pinned).toBe(false) + state.toggle(A, true) + expect(state.visibility.getSnapshot().pinned).toBe(true) + }) + + it('opens and closes one Session overlay without touching the docking preference', () => { + const state = new SessionPanelState() + state.toggle(A, false) + state.toggle(B, false) + expect(state.visibility.getSnapshot()).toEqual({ pinned: true, overlay: B }) + state.closeOverlay(A) + expect(state.visibility.getSnapshot().overlay).toBe(B) + state.toggle(B, false) + expect(state.visibility.getSnapshot().overlay).toBeNull() + state.toggle(A, false) + state.closeOverlay(A) + expect(state.visibility.getSnapshot().overlay).toBeNull() + }) + + it('treats a stored value other than false as the default', () => { + localStorage.setItem(PINNED_STORAGE_KEY, '"yes"') + expect(new SessionPanelState().visibility.getSnapshot().pinned).toBe(true) + }) + + it('notifies subscribers of both members and stops after unsubscribe', () => { + const state = new SessionPanelState() + let calls = 0 + const off = state.visibility.subscribe(() => { calls += 1 }) + state.toggle(A, false) + state.toggle(A, true) + const seen = calls + expect(seen).toBeGreaterThanOrEqual(2) + off() + state.toggle(A, true) + expect(calls).toBe(seen) + }) +}) diff --git a/packages/client/ui-session-panel/tsconfig.json b/packages/client/ui-session-panel/tsconfig.json new file mode 100644 index 0000000000..e07fa99318 --- /dev/null +++ b/packages/client/ui-session-panel/tsconfig.json @@ -0,0 +1,57 @@ +{ + "extends": "../../../tsconfig.base.client.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "lib/types" + }, + "include": [ + "src" + ], + "references": [ + { + "path": "../../../vendor/cordis" + }, + { + "path": "../../api/remotes/tsconfig.client.json" + }, + { + "path": "../../api/session-controller/tsconfig.client.json" + }, + { + "path": "../../api/workspace-controller/tsconfig.client.json" + }, + { + "path": "../locale/tsconfig.client.json" + }, + { + "path": "../store" + }, + { + "path": "../ui-context-menu" + }, + { + "path": "../ui-conversation/tsconfig.client.json" + }, + { + "path": "../ui-primitives" + }, + { + "path": "../ui-renderer" + }, + { + "path": "../ui-session" + }, + { + "path": "../ui-slots" + }, + { + "path": "../../core/session" + }, + { + "path": "../../util/workspace-path" + }, + { + "path": "../../workspace/workspace" + } + ] +} diff --git a/packages/client/ui-session-panel/tsdown.config.ts b/packages/client/ui-session-panel/tsdown.config.ts new file mode 100644 index 0000000000..7aa03cebc1 --- /dev/null +++ b/packages/client/ui-session-panel/tsdown.config.ts @@ -0,0 +1,3 @@ +import { clientBundle } from '../tsdown.client.ts' + +export default clientBundle(import.meta.dirname, ['lib/types/index.js']) 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 d3c3aefc0f..cb3cb0e61e 100644 --- a/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts +++ b/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts @@ -814,7 +814,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.composer\', () => ctx.slots.register(\n { name: \'conversation.composer\', select: owner => null },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-conversation/src/client/contract/slots.ts:290', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:297', }, { key: 'conversation.composer.bar', @@ -857,7 +857,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.composer.bar\', () => ctx.slots.register(\n { name: \'conversation.composer.bar\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-conversation/src/client/contract/slots.ts:336', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:343', }, { key: 'conversation.composer.dock', @@ -918,7 +918,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.composer.dock\', () => ctx.slots.register(\n { name: \'conversation.composer.dock\', 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:315', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:322', }, { key: 'conversation.header', @@ -1030,7 +1030,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.hero.agentPreset\', () => ctx.slots.register(\n { name: \'conversation.hero.agentPreset\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-conversation/src/client/contract/slots.ts:298', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:305', }, { key: 'conversation.hero.brand.mark', @@ -1062,7 +1062,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ occupants: [], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.hero.brand.mark\', () => ctx.slots.register(\n { name: \'conversation.hero.brand.mark\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-conversation/src/client/contract/slots.ts:296', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:303', }, { key: 'conversation.hero.frame', @@ -1109,7 +1109,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'wraps-owner-content', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.hero.frame\', () => ctx.slots.register(\n { name: \'conversation.hero.frame\', id: \'my-layer\', order: 100 },\n ({ children }) => React.createElement(\'div\', null, children),\n ))\n },\n}', - source: 'packages/client/ui-conversation/src/client/contract/slots.ts:294', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:301', }, { key: 'conversation.hero.options', @@ -1169,7 +1169,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.hero.options\', () => ctx.slots.register(\n { name: \'conversation.hero.options\', 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:300', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:307', }, { key: 'conversation.hero.workspace', @@ -1205,7 +1205,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.hero.workspace\', () => ctx.slots.register(\n { name: \'conversation.hero.workspace\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-conversation/src/client/contract/slots.ts:292', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:299', }, { key: 'conversation.hero.workspace.directoryFlow', @@ -1285,7 +1285,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.input.activity\', () => ctx.slots.register(\n { name: \'conversation.input.activity\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-conversation/src/client/contract/slots.ts:331', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:338', }, { key: 'conversation.input.attachments', @@ -1330,7 +1330,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.input.attachments\', () => ctx.slots.register(\n { name: \'conversation.input.attachments\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-conversation/src/client/contract/slots.ts:341', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:348', }, { key: 'conversation.input.dock', @@ -1399,7 +1399,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.input.dock\', () => ctx.slots.register(\n { name: \'conversation.input.dock\', 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:305', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:312', }, { key: 'conversation.input.left', @@ -1457,7 +1457,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ occupants: [], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.input.left\', () => ctx.slots.register(\n { name: \'conversation.input.left\', 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:320', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:327', }, { key: 'conversation.input.model', @@ -1501,7 +1501,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.input.model\', () => ctx.slots.register(\n { name: \'conversation.input.model\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-conversation/src/client/contract/slots.ts:362', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:369', }, { key: 'conversation.input.model.label', @@ -1667,7 +1667,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.input.overlay\', () => ctx.slots.register(\n { name: \'conversation.input.overlay\', 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:310', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:317', }, { key: 'conversation.input.permission', @@ -1711,7 +1711,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.input.permission\', () => ctx.slots.register(\n { name: \'conversation.input.permission\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-conversation/src/client/contract/slots.ts:355', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:362', }, { key: 'conversation.input.plan', @@ -1754,7 +1754,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.input.plan\', () => ctx.slots.register(\n { name: \'conversation.input.plan\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-conversation/src/client/contract/slots.ts:350', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:357', }, { key: 'conversation.input.right', @@ -1812,7 +1812,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ occupants: [], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.input.right\', () => ctx.slots.register(\n { name: \'conversation.input.right\', 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:325', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:332', }, { key: 'conversation.plan-review.actions', @@ -2227,6 +2227,7 @@ 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-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\'', ], @@ -2287,7 +2288,278 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.header.views.actions\', () => ctx.slots.register(\n { name: \'conversation.session.header.views.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:283', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:290', + }, + { + key: 'conversation.session.panel', + kind: 'single', + scope: 'session', + summary: 'One floating panel over the main Conversation body\'s end gutter.', + doc: 'One floating panel over the main Conversation body\'s end gutter. It renders\nonly for the main occurrence of a Session in its active phase, never for an\nembedded occurrence or the blank home; the occupant positions itself against\nthe body and reads `ctx.uiConversation.layouts` to keep clear of the transcript.', + registerOptions: [], + ownerProps: [ + '/** The Session panel\'s occupant derives its state from standard Session props. */\nexport interface ConversationSessionPanelOwnerProps {\n /** Marker field: the occupant receives no owner-specific values. */\n children?: never\n}', + ], + ownerPropsReferences: [], + standardProps: [ + 'useRemoteAccess: (action: RemoteEndpoint) => boolean', + 'useResource: UseResource', + 'useContextMenu: UseContextMenu', + 'useWorkspaces: SnapshotSelectorHook', + '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', + 'inputActions: InputActions', + 'useSession: SessionSnapshotSelector', + 'sessionId: SessionId', + 'useProjection: UseProjection', + 'useAccess: (action: RemoteEndpoint) => boolean', + 'useTrajectory: UseTrajectory', + ], + keyDomain: '', + hookContext: '', + slotInject: '', + declaredBy: 'factory \'conversation.content\' (client-ui-conversation), so it exists while that definition is registered', + occupants: [ + 'client-ui-session-panel SessionPanel', + ], + replaceRisk: 'shadows-shipped-ui', + example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel\', () => ctx.slots.register(\n { name: \'conversation.session.panel\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:288', + }, + { + 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`.', + 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', + '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', + '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-session-panel), so it exists while that entry is mounted', + occupants: [ + 'client-ui-session-panel ProjectRow id \'project\'', + ], + 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:35', + }, + { + key: 'conversation.session.panel.indicator', + kind: 'list', + scope: 'session', + summary: 'Marks over the panel toggle, such as an attention dot.', + doc: 'Marks over the panel toggle, such as an attention dot. They stay visible\nwhile the panel is hidden; each occupant includes text that names it for\nassistive technology, which becomes part of the toggle\'s name.', + 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', + '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', + 'inputActions: InputActions', + 'useSession: SessionSnapshotSelector', + 'sessionId: SessionId', + 'useProjection: UseProjection', + 'useAccess: (action: RemoteEndpoint) => boolean', + 'useTrajectory: UseTrajectory', + ], + keyDomain: '', + hookContext: '', + slotInject: '', + declaredBy: 'an entry in \'conversation.session.header.utilities\' (client-ui-session-panel), so it exists while that entry is mounted', + occupants: [], + 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', + }, + { + key: 'conversation.session.panel.section', + kind: 'list', + scope: 'session', + summary: 'Sections of the Session panel.', + doc: 'Sections of the Session panel. `id` addresses the section, `order` sorts\nthe sections ascending, and the required `label` is the section title,\nwhich the panel draws. A section with nothing to show renders nothing,\nand the panel hides its title with it.', + 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: [ + '/** 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', + 'useContextMenu: UseContextMenu', + 'useWorkspaces: SnapshotSelectorHook', + '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', + 'inputActions: InputActions', + 'useSession: SessionSnapshotSelector', + 'sessionId: SessionId', + 'useProjection: UseProjection', + 'useAccess: (action: RemoteEndpoint) => boolean', + 'useTrajectory: UseTrajectory', + ], + keyDomain: '', + hookContext: '', + slotInject: '', + declaredBy: 'an entry in \'conversation.session.panel\' (client-ui-session-panel), so it exists while that entry is mounted', + occupants: [ + 'client-ui-session-panel EnvironmentSection id \'environment\'', + ], + 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}', + source: 'packages/client/ui-session-panel/src/client/slots.ts:21', + }, + { + 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`.', + registerOptions: [ + { + name: 'key', + requirement: 'required', + type: 'string', + doc: 'Your cell key: the entry renders where the owner dispatches this exact key. Registering an already-occupied key replaces that occupant.', + }, + ], + ownerProps: [], + ownerPropsReferences: [], + standardProps: [ + 'useRemoteAccess: (action: RemoteEndpoint) => boolean', + 'useResource: UseResource', + 'useContextMenu: UseContextMenu', + 'useWorkspaces: SnapshotSelectorHook', + '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', + 'inputActions: InputActions', + 'useSession: SessionSnapshotSelector', + 'sessionId: SessionId', + 'useProjection: UseProjection', + 'useAccess: (action: RemoteEndpoint) => boolean', + 'useTrajectory: UseTrajectory', + ], + keyDomain: 'open: any string the owner dispatches (no compile-time key set), none are taken yet', + hookContext: '', + slotInject: '', + declaredBy: 'an entry in \'conversation.session.panel\' (client-ui-session-panel), so it exists while that entry is mounted', + occupants: [], + replaceRisk: 'none', + 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:27', }, { key: 'conversation.trajectory.images', @@ -2457,7 +2729,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.view\', () => ctx.slots.register(\n { name: \'conversation.view\', 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:285', + source: 'packages/client/ui-conversation/src/client/contract/slots.ts:292', }, { key: 'deliverables.file.actions', diff --git a/packages/preset/agent-preset/skills/cordis-composition-reference/references/packages.md b/packages/preset/agent-preset/skills/cordis-composition-reference/references/packages.md index 238deeaa99..d74b78bf35 100644 --- a/packages/preset/agent-preset/skills/cordis-composition-reference/references/packages.md +++ b/packages/preset/agent-preset/skills/cordis-composition-reference/references/packages.md @@ -98,6 +98,7 @@ Every package below exports a Cordis plugin that a bundle patch can name in a Lo | `@deepseek-ai/dsh-client-ui-schedule` | no | Host task management page and Session reminder catalog | | `@deepseek-ai/dsh-client-ui-secret-mask` | no | Web display masking for recognized credentials in sent user text | | `@deepseek-ai/dsh-client-ui-session` | no | Session Controller adapter for React and session-scoped slots | +| `@deepseek-ai/dsh-client-ui-session-panel` | no | Floating Session panel opened from the Session header, composed of sections that plugins register | | `@deepseek-ai/dsh-client-ui-settings` | no | Settings domain base plugin: shared configuration forms and the canonical settings slot-type contract | | `@deepseek-ai/dsh-client-ui-settings-account` | yes | Manage DeepSeek login and open Platform billing pages | | `@deepseek-ai/dsh-client-ui-settings-agent-loop` | no | Settings page of the agent loop on the dsh web client's Plugins page: the parallel tool-call cap of the agent-loop namespace | diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f4ac595dde..d38a4c3c8d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3080,6 +3080,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-settings': specifier: workspace:* version: link:../../client/ui-settings @@ -5651,6 +5654,69 @@ importers: specifier: ^18.2.0 version: 18.3.1 + packages/client/ui-session-panel: + devDependencies: + '@deepseek-ai/cordis': + specifier: workspace:~ + version: link:../../../vendor/cordis + '@deepseek-ai/dsh-api-remotes': + specifier: workspace:* + version: link:../../api/remotes + '@deepseek-ai/dsh-api-session-controller': + specifier: workspace:* + version: link:../../api/session-controller + '@deepseek-ai/dsh-api-workspace-controller': + specifier: workspace:* + version: link:../../api/workspace-controller + '@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 + '@deepseek-ai/dsh-client-ui-context-menu': + specifier: workspace:* + version: link:../ui-context-menu + '@deepseek-ai/dsh-client-ui-conversation': + specifier: workspace:* + version: link:../ui-conversation + '@deepseek-ai/dsh-client-ui-primitives': + specifier: workspace:* + version: link:../ui-primitives + '@deepseek-ai/dsh-client-ui-renderer': + specifier: workspace:* + version: link:../ui-renderer + '@deepseek-ai/dsh-client-ui-session': + specifier: workspace:* + version: link:../ui-session + '@deepseek-ai/dsh-client-ui-slots': + specifier: workspace:* + version: link:../ui-slots + '@deepseek-ai/dsh-session': + specifier: workspace:* + version: link:../../core/session + '@deepseek-ai/dsh-util-workspace-path': + specifier: workspace:* + version: link:../../util/workspace-path + '@deepseek-ai/dsh-workspace': + specifier: workspace:* + version: link:../../workspace/workspace + '@testing-library/react': + specifier: ^16.3.3 + version: 16.3.3(@testing-library/dom@10.4.2)(@types/react-dom@18.3.7(@types/react@18.3.31))(@types/react@18.3.31)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + clsx: + specifier: ^2.0.0 + version: 2.1.1 + react: + specifier: ^18.2.0 + version: 18.3.1 + react-dom: + specifier: ^18.2.0 + version: 18.3.1(react@18.3.1) + packages/client/ui-settings: dependencies: '@deepseek-ai/schemastery': diff --git a/scripts/verify-package-readme-model-experience.ts b/scripts/verify-package-readme-model-experience.ts index 6e44649447..a61842d496 100644 --- a/scripts/verify-package-readme-model-experience.ts +++ b/scripts/verify-package-readme-model-experience.ts @@ -96,6 +96,7 @@ const SENTENCE_MODEL_EXPERIENCE: Readonly> = { 'packages/attachment/attachment-local': { kind: 'indirect', reason: 'The local backend delegates model request rendering to provider adapters.' }, 'packages/mcp/mcp-manager': { kind: 'indirect', reason: 'The manager only mounts and disposes dsh-mcp-client instances; those instances own every model-facing tool and schema.' }, 'packages/client/ui-jobs': { kind: 'none', reason: 'Browser-side presentation of host-observed output; touches no prompt, message, schema, stream, or tool result.' }, + 'packages/client/ui-session-panel': { kind: 'none', reason: 'Browser-side summary of Session facts the Client already holds; touches no prompt, message, schema, stream, or tool result.' }, 'packages/shell/shell': { kind: 'indirect', reason: 'The service interface delegates all model rendering to dsh-tool-bash.' }, 'packages/shell/shell-env': { kind: 'indirect', reason: 'The env service exposes managed DSH_* facts through the shell tools (dsh-tool-bash/dsh-tool-pwsh); it registers no prompt or schema of its own.' }, 'packages/shell/bash-local': { kind: 'indirect', reason: 'The executor backend delegates model rendering to dsh-tool-bash.' }, diff --git a/tsconfig.base.json b/tsconfig.base.json index e130ee2d64..6964ee6bed 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -343,6 +343,8 @@ "@deepseek-ai/dsh-client-ui-jobs/client": ["./packages/client/ui-jobs/src/client/index.ts"], "@deepseek-ai/dsh-client-ui-schedule": ["./packages/client/ui-schedule/src"], "@deepseek-ai/dsh-client-ui-schedule/client": ["./packages/client/ui-schedule/src/client/index.ts"], + "@deepseek-ai/dsh-client-ui-session-panel": ["./packages/client/ui-session-panel/src"], + "@deepseek-ai/dsh-client-ui-session-panel/client": ["./packages/client/ui-session-panel/src/client/index.ts"], "@deepseek-ai/dsh-client-ui-plan": ["./packages/client/ui-plan/src"], "@deepseek-ai/dsh-client-ui-user-questions": ["./packages/client/ui-user-questions/src"], "@deepseek-ai/dsh-client-ui-trajectory": ["./packages/client/ui-trajectory/src"], diff --git a/tsconfig.client.json b/tsconfig.client.json index 0075d223e4..e0c16aaf5f 100644 --- a/tsconfig.client.json +++ b/tsconfig.client.json @@ -137,6 +137,7 @@ { "path": "./packages/client/ui-sidebar-files" }, { "path": "./packages/client/ui-jobs" }, { "path": "./packages/client/ui-schedule" }, + { "path": "./packages/client/ui-session-panel" }, { "path": "./packages/client/ui-directory-picker-browse" }, { "path": "./packages/client/ui-directory-picker-native" }, { "path": "./packages/client/ui-goal" }, From 96ce46c3d18ca464c8d82098b8831c6e1f82be7c Mon Sep 17 00:00:00 2001 From: LegGasai Date: Thu, 5 Nov 2026 17:27:28 +0800 Subject: [PATCH 02/35] fix(web): use the menu corner radius for the Session panel --- .../client/ui-session-panel/src/client/SessionPanel.module.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 f3bc08665e..8bd6ca6fa8 100644 --- a/packages/client/ui-session-panel/src/client/SessionPanel.module.css +++ b/packages/client/ui-session-panel/src/client/SessionPanel.module.css @@ -16,7 +16,8 @@ overscroll-behavior: contain; padding: 6px 8px; border: 0; - border-radius: var(--dsw-radius-panel); + /* The standard menu tier: a compact summary surface, not an enclosing panel. */ + border-radius: var(--dsw-radius-lg); color: var(--dsw-alias-label-primary); background: var(--dsw-alias-bg-layer-1); box-shadow: var(--dsw-elevation-panel); From d9421f3e0315239a61c8ad2c728be7e1ebb10a01 Mon Sep 17 00:00:00 2001 From: LegGasai Date: Thu, 5 Nov 2026 21:12:27 +0800 Subject: [PATCH 03/35] test(web): expect the turn rail at the scrollport start edge The Session panel moves the turn rail from the end edge of the Conversation scrollport to its start edge, leaving the end gutter to the panel. The floating-controls geometry check now measures the rail's 12px inset from the scrollport's start edge instead of its end edge. --- apps/web/tests/chat-scroll-contract.e2e.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/tests/chat-scroll-contract.e2e.ts b/apps/web/tests/chat-scroll-contract.e2e.ts index fd5f778c1e..20365f6478 100644 --- a/apps/web/tests/chat-scroll-contract.e2e.ts +++ b/apps/web/tests/chat-scroll-contract.e2e.ts @@ -1237,7 +1237,7 @@ describe('web e2e: long Chat scroll contract', () => { const top = viewport.top + element.clientTop return Math.max( Math.abs((railBox.top + railBox.bottom) / 2 - (top + composerBox.top) / 2), - Math.abs(viewport.left + element.clientLeft + element.clientWidth - railBox.right - 12), + Math.abs(railBox.left - viewport.left - element.clientLeft - 12), Math.abs(composerBox.top - buttonBox.bottom - 16), ) }), { timeout: 10_000 }).toBeLessThanOrEqual(GEOMETRY_TOLERANCE) From e0ad8405df8dea24b85378dd472a52c411f1c593 Mon Sep 17 00:00:00 2001 From: LegGasai Date: Thu, 5 Nov 2026 21:12:29 +0800 Subject: [PATCH 04/35] test(web): refresh goldens for the Session panel toggle The Session panel toggle is the first Session header utility, so every Session header ARIA golden gains its button ("Session panel", or the localized name in the Chinese and Japanese cases) before "More actions". --- .../tests/expected/agent-preset-selection/header.expected.md | 1 + apps/web/tests/expected/clickable-links-gallery/ui.expected.md | 1 + apps/web/tests/expected/cordis-history/ui.expected.md | 1 + .../github-ready-review/conversation-expanded.expected.md | 1 + .../expected/github-ready-review/conversation.expected.md | 1 + .../tests/expected/goal-command-presentation/ui.expected.md | 1 + apps/web/tests/expected/markdown-cjk-strong/ui.expected.md | 1 + apps/web/tests/expected/markdown-images/ui.expected.md | 1 + .../tests/expected/markdown-inline-code-links/ui.expected.md | 1 + apps/web/tests/expected/math-rendering/ui.expected.md | 1 + apps/web/tests/expected/reference-composer/order.expected.md | 1 + .../sidebar-subagent-activity/compact-running.expected.md | 1 + .../tests/expected/skill-user-invoke/ui-expanded.expected.md | 1 + apps/web/tests/expected/skill-user-invoke/ui.expected.md | 1 + apps/web/tests/expected/stats-paged-history/ui.expected.md | 1 + apps/web/tests/expected/steer-all/mid-steer.expected.md | 1 + apps/web/tests/expected/steer-all/settled-expanded.expected.md | 1 + apps/web/tests/expected/steer-all/settled.expected.md | 1 + .../snapshots/streaming-fence-highlight/mid-stream.expected.md | 1 + snapshots/web/auto-review-approval/ui.expected.md | 2 ++ snapshots/web/auto-review-denial/ui.expected.md | 3 +++ snapshots/web/bash-abort-row/ui.expected.md | 1 + snapshots/web/deepseek-messages-chat/ui.expected.md | 1 + snapshots/web/default-workspace/ui.expected.md | 1 + snapshots/web/feedback-command/ack-expanded.expected.md | 1 + snapshots/web/feedback-command/ack.expected.md | 1 + snapshots/web/feedback-release/ack-expanded.expected.md | 1 + snapshots/web/feedback-release/ack.expected.md | 1 + snapshots/web/file-upload-round/ui.expected.md | 1 + snapshots/web/fresh-round-trip/ui-expanded.expected.md | 1 + snapshots/web/fresh-round-trip/ui.expected.md | 1 + snapshots/web/goal-multi-turn-actions/ui-expanded.expected.md | 1 + snapshots/web/goal-multi-turn-actions/ui.expected.md | 1 + snapshots/web/interrupted-turn/ui.expected.md | 1 + snapshots/web/lifecycle-chrome/reloaded-expanded.expected.md | 1 + snapshots/web/lifecycle-chrome/reloaded.expected.md | 1 + snapshots/web/live-interactions/cancel-expanded.expected.md | 1 + snapshots/web/live-interactions/cancel.expected.md | 1 + snapshots/web/live-interactions/continued.expected.md | 1 + snapshots/web/live-interactions/error-auth.expected.md | 1 + snapshots/web/live-interactions/loading.expected.md | 1 + snapshots/web/live-interactions/retry-exhausted.expected.md | 1 + snapshots/web/live-interactions/retry-expanded.expected.md | 1 + snapshots/web/live-interactions/retry.expected.md | 1 + snapshots/web/live-interactions/running-draft.expected.md | 1 + snapshots/web/message-actions/ui.expected.md | 1 + snapshots/web/minimal-compact/ui.expected.md | 1 + snapshots/web/minimal-preset/ui.expected.md | 1 + snapshots/web/minimal-read-image/ui.expected.md | 1 + snapshots/web/open-in-app-ssh/header.expected.md | 1 + snapshots/web/plan-review/approved-expanded.expected.md | 1 + snapshots/web/plan-review/approved.expected.md | 1 + snapshots/web/present/ui.expected.md | 1 + snapshots/web/ptc-round/ui-ja.expected.md | 1 + snapshots/web/ptc-round/ui.expected.md | 1 + snapshots/web/question-composer/answered-expanded.expected.md | 1 + snapshots/web/question-composer/answered.expected.md | 1 + snapshots/web/question-composer/cancelled.expected.md | 1 + snapshots/web/question-composer/late-answered.expected.md | 1 + snapshots/web/question-composer/queued.expected.md | 1 + snapshots/web/queue-actions/collapsed.expected.md | 1 + snapshots/web/queue-actions/editing.expected.md | 1 + snapshots/web/queue-actions/goal-stop.expected.md | 1 + snapshots/web/queue-actions/layout.expected.md | 1 + snapshots/web/queue-actions/preserved-expanded.expected.md | 1 + snapshots/web/queue-actions/preserved.expected.md | 1 + snapshots/web/queue-actions/sending.expected.md | 1 + snapshots/web/queue-actions/ui.expected.md | 1 + snapshots/web/queued-image/delivered.expected.md | 1 + snapshots/web/queued-image/queued.expected.md | 1 + snapshots/web/rich-text-quotes/ui.expected.md | 1 + snapshots/web/seeded-history/command-row.expected.md | 1 + snapshots/web/seeded-history/feedback-row.expected.md | 1 + snapshots/web/seeded-history/ui-expanded.expected.md | 1 + snapshots/web/seeded-history/ui.expected.md | 1 + snapshots/web/skill-tool-row/ui.expected.md | 1 + snapshots/web/steering/mid-steer.expected.md | 1 + snapshots/web/steering/settled-expanded.expected.md | 1 + snapshots/web/steering/settled.expected.md | 1 + snapshots/web/steering/trajectory.expected.md | 1 + snapshots/web/subagent-conversation/nested.expected.md | 1 + snapshots/web/subagent-conversation/ui-expanded.expected.md | 1 + snapshots/web/subagent-conversation/ui.expected.md | 1 + snapshots/web/subagent-interrupt/image-queue.expected.md | 1 + snapshots/web/subagent-interrupt/offline-composer.expected.md | 1 + snapshots/web/turn-tail-actions/completed.expected.md | 1 + snapshots/web/turn-tail-actions/focused.expected.md | 1 + snapshots/web/turn-tail-actions/running.expected.md | 1 + snapshots/web/turn-tail-actions/settled.expected.md | 1 + snapshots/web/turn-tail-actions/usage-expanded.expected.md | 1 + snapshots/web/web-search-round/ui.expected.md | 1 + 91 files changed, 94 insertions(+) diff --git a/apps/web/tests/expected/agent-preset-selection/header.expected.md b/apps/web/tests/expected/agent-preset-selection/header.expected.md index 2b87066124..3b3e5e3f6e 100644 --- a/apps/web/tests/expected/agent-preset-selection/header.expected.md +++ b/apps/web/tests/expected/agent-preset-selection/header.expected.md @@ -1,5 +1,6 @@ - navigation "Session hierarchy": Seeded turn - text: Minimal mode - button "1 subagent" +- button "Session panel" - button "More actions" - button "Open right sidebar" diff --git a/apps/web/tests/expected/clickable-links-gallery/ui.expected.md b/apps/web/tests/expected/clickable-links-gallery/ui.expected.md index 50cd7bc896..aeecf7ad1c 100644 --- a/apps/web/tests/expected/clickable-links-gallery/ui.expected.md +++ b/apps/web/tests/expected/clickable-links-gallery/ui.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Clickable links gallery + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/cordis-history/ui.expected.md b/apps/web/tests/expected/cordis-history/ui.expected.md index 32e5cba5bc..56eb15e136 100644 --- a/apps/web/tests/expected/cordis-history/ui.expected.md +++ b/apps/web/tests/expected/cordis-history/ui.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Use only Cordis tools. First + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/github-ready-review/conversation-expanded.expected.md b/apps/web/tests/expected/github-ready-review/conversation-expanded.expected.md index b0546d4998..c75151fd81 100644 --- a/apps/web/tests/expected/github-ready-review/conversation-expanded.expected.md +++ b/apps/web/tests/expected/github-ready-review/conversation-expanded.expected.md @@ -11,6 +11,7 @@ - banner: - navigation "Session hierarchy": Review deepseek-ai/deepseek-harness#314 - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/github-ready-review/conversation.expected.md b/apps/web/tests/expected/github-ready-review/conversation.expected.md index 9b10e08416..df6aabe092 100644 --- a/apps/web/tests/expected/github-ready-review/conversation.expected.md +++ b/apps/web/tests/expected/github-ready-review/conversation.expected.md @@ -11,6 +11,7 @@ - banner: - navigation "Session hierarchy": Review deepseek-ai/deepseek-harness#314 - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/goal-command-presentation/ui.expected.md b/apps/web/tests/expected/goal-command-presentation/ui.expected.md index ac468809d2..60dcaaa04a 100644 --- a/apps/web/tests/expected/goal-command-presentation/ui.expected.md +++ b/apps/web/tests/expected/goal-command-presentation/ui.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": workspace - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/markdown-cjk-strong/ui.expected.md b/apps/web/tests/expected/markdown-cjk-strong/ui.expected.md index 6eee07ead9..a8f1951ae4 100644 --- a/apps/web/tests/expected/markdown-cjk-strong/ui.expected.md +++ b/apps/web/tests/expected/markdown-cjk-strong/ui.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": CJK strong emphasis + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/markdown-images/ui.expected.md b/apps/web/tests/expected/markdown-images/ui.expected.md index 4923acd2e6..b3fbac6447 100644 --- a/apps/web/tests/expected/markdown-images/ui.expected.md +++ b/apps/web/tests/expected/markdown-images/ui.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Markdown image policy + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/markdown-inline-code-links/ui.expected.md b/apps/web/tests/expected/markdown-inline-code-links/ui.expected.md index d2d68c6021..403c938a2b 100644 --- a/apps/web/tests/expected/markdown-inline-code-links/ui.expected.md +++ b/apps/web/tests/expected/markdown-inline-code-links/ui.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Inline code links + - button "Session panel" - button "More actions" - tablist: - tab "Chat" [selected] diff --git a/apps/web/tests/expected/math-rendering/ui.expected.md b/apps/web/tests/expected/math-rendering/ui.expected.md index 82c51f246e..b31a0cb736 100644 --- a/apps/web/tests/expected/math-rendering/ui.expected.md +++ b/apps/web/tests/expected/math-rendering/ui.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Math rendering + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/reference-composer/order.expected.md b/apps/web/tests/expected/reference-composer/order.expected.md index e13baba024..f2a467af85 100644 --- a/apps/web/tests/expected/reference-composer/order.expected.md +++ b/apps/web/tests/expected/reference-composer/order.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Reference order target + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/sidebar-subagent-activity/compact-running.expected.md b/apps/web/tests/expected/sidebar-subagent-activity/compact-running.expected.md index 7a26f1bae7..6e56147a9a 100644 --- a/apps/web/tests/expected/sidebar-subagent-activity/compact-running.expected.md +++ b/apps/web/tests/expected/sidebar-subagent-activity/compact-running.expected.md @@ -2,6 +2,7 @@ - navigation "Session hierarchy": Delegate a background job. - button "1 subagent" - button "1 background job" + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/skill-user-invoke/ui-expanded.expected.md b/apps/web/tests/expected/skill-user-invoke/ui-expanded.expected.md index 4c06982b08..c7a72552a8 100644 --- a/apps/web/tests/expected/skill-user-invoke/ui-expanded.expected.md +++ b/apps/web/tests/expected/skill-user-invoke/ui-expanded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": /user-invoke-demo @"meeting notes-this-i - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/skill-user-invoke/ui.expected.md b/apps/web/tests/expected/skill-user-invoke/ui.expected.md index db8db2840a..d13ca7947f 100644 --- a/apps/web/tests/expected/skill-user-invoke/ui.expected.md +++ b/apps/web/tests/expected/skill-user-invoke/ui.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": /user-invoke-demo @"meeting notes-this-i - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/stats-paged-history/ui.expected.md b/apps/web/tests/expected/stats-paged-history/ui.expected.md index 34f3cf897d..b69dca50c7 100644 --- a/apps/web/tests/expected/stats-paged-history/ui.expected.md +++ b/apps/web/tests/expected/stats-paged-history/ui.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": {{workspace}} + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/steer-all/mid-steer.expected.md b/apps/web/tests/expected/steer-all/mid-steer.expected.md index dd9afda70c..b917214246 100644 --- a/apps/web/tests/expected/steer-all/mid-steer.expected.md +++ b/apps/web/tests/expected/steer-all/mid-steer.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use the ask_user_question tool to - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/steer-all/settled-expanded.expected.md b/apps/web/tests/expected/steer-all/settled-expanded.expected.md index 3977249952..65213117f6 100644 --- a/apps/web/tests/expected/steer-all/settled-expanded.expected.md +++ b/apps/web/tests/expected/steer-all/settled-expanded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use the ask_user_question tool to - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/expected/steer-all/settled.expected.md b/apps/web/tests/expected/steer-all/settled.expected.md index 903a4d6021..db22bb3b36 100644 --- a/apps/web/tests/expected/steer-all/settled.expected.md +++ b/apps/web/tests/expected/steer-all/settled.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use the ask_user_question tool to - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/apps/web/tests/snapshots/streaming-fence-highlight/mid-stream.expected.md b/apps/web/tests/snapshots/streaming-fence-highlight/mid-stream.expected.md index 94a7638c3f..64585d3be8 100644 --- a/apps/web/tests/snapshots/streaming-fence-highlight/mid-stream.expected.md +++ b/apps/web/tests/snapshots/streaming-fence-highlight/mid-stream.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Stream one TypeScript fence for - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/auto-review-approval/ui.expected.md b/snapshots/web/auto-review-approval/ui.expected.md index ac943a33c9..117b92e6a4 100644 --- a/snapshots/web/auto-review-approval/ui.expected.md +++ b/snapshots/web/auto-review-approval/ui.expected.md @@ -2,6 +2,7 @@ - banner: - navigation "Session hierarchy": {{workspace}} + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: @@ -28,6 +29,7 @@ - banner: - navigation "Session hierarchy": {{workspace}} + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/auto-review-denial/ui.expected.md b/snapshots/web/auto-review-denial/ui.expected.md index f9b78c5d2e..5b166d0a43 100644 --- a/snapshots/web/auto-review-denial/ui.expected.md +++ b/snapshots/web/auto-review-denial/ui.expected.md @@ -2,6 +2,7 @@ - banner: - navigation "Session hierarchy": {{workspace}} + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: @@ -29,6 +30,7 @@ - banner: - navigation "Session hierarchy": {{workspace}} + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: @@ -60,6 +62,7 @@ - banner: - navigation "Session hierarchy": {{workspace}} + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/bash-abort-row/ui.expected.md b/snapshots/web/bash-abort-row/ui.expected.md index ac3d5ef116..743150b624 100644 --- a/snapshots/web/bash-abort-row/ui.expected.md +++ b/snapshots/web/bash-abort-row/ui.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": "Run two shell commands: wait" + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/deepseek-messages-chat/ui.expected.md b/snapshots/web/deepseek-messages-chat/ui.expected.md index 45809754a0..28d071f826 100644 --- a/snapshots/web/deepseek-messages-chat/ui.expected.md +++ b/snapshots/web/deepseek-messages-chat/ui.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "会话层级": 只回复 MESSAGES_WEB_READY,不调用 - text: 标准模式 + - button "会话面板" - button "更多操作" - button "打开右侧边栏" - tablist: diff --git a/snapshots/web/default-workspace/ui.expected.md b/snapshots/web/default-workspace/ui.expected.md index e88f5075a5..5946a56d28 100644 --- a/snapshots/web/default-workspace/ui.expected.md +++ b/snapshots/web/default-workspace/ui.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use the bash tool to - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/feedback-command/ack-expanded.expected.md b/snapshots/web/feedback-command/ack-expanded.expected.md index eb65a5453b..f829859e41 100644 --- a/snapshots/web/feedback-command/ack-expanded.expected.md +++ b/snapshots/web/feedback-command/ack-expanded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with the single word - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/feedback-command/ack.expected.md b/snapshots/web/feedback-command/ack.expected.md index 46ff8dc952..3e38912f14 100644 --- a/snapshots/web/feedback-command/ack.expected.md +++ b/snapshots/web/feedback-command/ack.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with the single word - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/feedback-release/ack-expanded.expected.md b/snapshots/web/feedback-release/ack-expanded.expected.md index eb65a5453b..f829859e41 100644 --- a/snapshots/web/feedback-release/ack-expanded.expected.md +++ b/snapshots/web/feedback-release/ack-expanded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with the single word - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/feedback-release/ack.expected.md b/snapshots/web/feedback-release/ack.expected.md index 46ff8dc952..3e38912f14 100644 --- a/snapshots/web/feedback-release/ack.expected.md +++ b/snapshots/web/feedback-release/ack.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with the single word - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/file-upload-round/ui.expected.md b/snapshots/web/file-upload-round/ui.expected.md index a3e682317c..48464607ba 100644 --- a/snapshots/web/file-upload-round/ui.expected.md +++ b/snapshots/web/file-upload-round/ui.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Read the attached file with - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/fresh-round-trip/ui-expanded.expected.md b/snapshots/web/fresh-round-trip/ui-expanded.expected.md index 919216af28..f9d0ec7b1f 100644 --- a/snapshots/web/fresh-round-trip/ui-expanded.expected.md +++ b/snapshots/web/fresh-round-trip/ui-expanded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use the bash tool to - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/fresh-round-trip/ui.expected.md b/snapshots/web/fresh-round-trip/ui.expected.md index e88f5075a5..5946a56d28 100644 --- a/snapshots/web/fresh-round-trip/ui.expected.md +++ b/snapshots/web/fresh-round-trip/ui.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use the bash tool to - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/goal-multi-turn-actions/ui-expanded.expected.md b/snapshots/web/goal-multi-turn-actions/ui-expanded.expected.md index f3573f01d2..bcd429686e 100644 --- a/snapshots/web/goal-multi-turn-actions/ui-expanded.expected.md +++ b/snapshots/web/goal-multi-turn-actions/ui-expanded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": workspace - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/goal-multi-turn-actions/ui.expected.md b/snapshots/web/goal-multi-turn-actions/ui.expected.md index 1b47544f84..c35449101b 100644 --- a/snapshots/web/goal-multi-turn-actions/ui.expected.md +++ b/snapshots/web/goal-multi-turn-actions/ui.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": workspace - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/interrupted-turn/ui.expected.md b/snapshots/web/interrupted-turn/ui.expected.md index f3b5c777b2..3d53c7b2a9 100644 --- a/snapshots/web/interrupted-turn/ui.expected.md +++ b/snapshots/web/interrupted-turn/ui.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Use the read tool twice + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/lifecycle-chrome/reloaded-expanded.expected.md b/snapshots/web/lifecycle-chrome/reloaded-expanded.expected.md index c4820a8dc9..b538569ac1 100644 --- a/snapshots/web/lifecycle-chrome/reloaded-expanded.expected.md +++ b/snapshots/web/lifecycle-chrome/reloaded-expanded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with the single word - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/lifecycle-chrome/reloaded.expected.md b/snapshots/web/lifecycle-chrome/reloaded.expected.md index bf189ee365..e29fb2d595 100644 --- a/snapshots/web/lifecycle-chrome/reloaded.expected.md +++ b/snapshots/web/lifecycle-chrome/reloaded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with the single word - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/live-interactions/cancel-expanded.expected.md b/snapshots/web/live-interactions/cancel-expanded.expected.md index 2d5c0c5bba..83a2c85d77 100644 --- a/snapshots/web/live-interactions/cancel-expanded.expected.md +++ b/snapshots/web/live-interactions/cancel-expanded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/live-interactions/cancel.expected.md b/snapshots/web/live-interactions/cancel.expected.md index ee2791a0a0..e21f0570b0 100644 --- a/snapshots/web/live-interactions/cancel.expected.md +++ b/snapshots/web/live-interactions/cancel.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/live-interactions/continued.expected.md b/snapshots/web/live-interactions/continued.expected.md index da8fc50a28..3fa4d33867 100644 --- a/snapshots/web/live-interactions/continued.expected.md +++ b/snapshots/web/live-interactions/continued.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/live-interactions/error-auth.expected.md b/snapshots/web/live-interactions/error-auth.expected.md index e7e5f34c64..f5eaffda23 100644 --- a/snapshots/web/live-interactions/error-auth.expected.md +++ b/snapshots/web/live-interactions/error-auth.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/live-interactions/loading.expected.md b/snapshots/web/live-interactions/loading.expected.md index 28141fb63e..64591b021f 100644 --- a/snapshots/web/live-interactions/loading.expected.md +++ b/snapshots/web/live-interactions/loading.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/live-interactions/retry-exhausted.expected.md b/snapshots/web/live-interactions/retry-exhausted.expected.md index 2269e99eb8..b6ebe548b0 100644 --- a/snapshots/web/live-interactions/retry-exhausted.expected.md +++ b/snapshots/web/live-interactions/retry-exhausted.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/live-interactions/retry-expanded.expected.md b/snapshots/web/live-interactions/retry-expanded.expected.md index ff0b7922ca..8da764297e 100644 --- a/snapshots/web/live-interactions/retry-expanded.expected.md +++ b/snapshots/web/live-interactions/retry-expanded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/live-interactions/retry.expected.md b/snapshots/web/live-interactions/retry.expected.md index 00133d103c..5848e82e74 100644 --- a/snapshots/web/live-interactions/retry.expected.md +++ b/snapshots/web/live-interactions/retry.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/live-interactions/running-draft.expected.md b/snapshots/web/live-interactions/running-draft.expected.md index 5da9965d81..3cc09b5a76 100644 --- a/snapshots/web/live-interactions/running-draft.expected.md +++ b/snapshots/web/live-interactions/running-draft.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/message-actions/ui.expected.md b/snapshots/web/message-actions/ui.expected.md index 2ee34dea49..95a12947ea 100644 --- a/snapshots/web/message-actions/ui.expected.md +++ b/snapshots/web/message-actions/ui.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Use the read tool twice + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/minimal-compact/ui.expected.md b/snapshots/web/minimal-compact/ui.expected.md index ce3f77da98..9d48d2da0a 100644 --- a/snapshots/web/minimal-compact/ui.expected.md +++ b/snapshots/web/minimal-compact/ui.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": "Remember the project requirements: imple" - text: Minimal mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/minimal-preset/ui.expected.md b/snapshots/web/minimal-preset/ui.expected.md index 472927485d..3dc7e2f314 100644 --- a/snapshots/web/minimal-preset/ui.expected.md +++ b/snapshots/web/minimal-preset/ui.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use the bash tool to - text: Minimal mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/minimal-read-image/ui.expected.md b/snapshots/web/minimal-read-image/ui.expected.md index ab1052525e..2ae95c7e0d 100644 --- a/snapshots/web/minimal-read-image/ui.expected.md +++ b/snapshots/web/minimal-read-image/ui.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use read_image to inspect red.png. - text: Minimal mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/open-in-app-ssh/header.expected.md b/snapshots/web/open-in-app-ssh/header.expected.md index f3fafda508..e960ef3f6e 100644 --- a/snapshots/web/open-in-app-ssh/header.expected.md +++ b/snapshots/web/open-in-app-ssh/header.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Use the read tool twice + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/plan-review/approved-expanded.expected.md b/snapshots/web/plan-review/approved-expanded.expected.md index a1a5c163cb..0201f1e11d 100644 --- a/snapshots/web/plan-review/approved-expanded.expected.md +++ b/snapshots/web/plan-review/approved-expanded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": "Plan a small change: add" - text: Standard mode + - button "Session panel" - button "More actions" - tablist: - tab "Chat" [selected] diff --git a/snapshots/web/plan-review/approved.expected.md b/snapshots/web/plan-review/approved.expected.md index 50c7bf0c88..6208b1aa67 100644 --- a/snapshots/web/plan-review/approved.expected.md +++ b/snapshots/web/plan-review/approved.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": "Plan a small change: add" - text: Standard mode + - button "Session panel" - button "More actions" - tablist: - tab "Chat" [selected] diff --git a/snapshots/web/present/ui.expected.md b/snapshots/web/present/ui.expected.md index 26a7e07dd0..1358b3f907 100644 --- a/snapshots/web/present/ui.expected.md +++ b/snapshots/web/present/ui.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use one run_code program to - text: PTC mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/ptc-round/ui-ja.expected.md b/snapshots/web/ptc-round/ui-ja.expected.md index 74494139d7..11220e2a3a 100644 --- a/snapshots/web/ptc-round/ui-ja.expected.md +++ b/snapshots/web/ptc-round/ui-ja.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "セッション階層": "Using ONE run_code program: run" - text: PTC モード + - button "セッションパネル" - button "その他の操作" - button "右サイドバーを開く" - tablist: diff --git a/snapshots/web/ptc-round/ui.expected.md b/snapshots/web/ptc-round/ui.expected.md index f0fe4d20a3..a0fabcb8c1 100644 --- a/snapshots/web/ptc-round/ui.expected.md +++ b/snapshots/web/ptc-round/ui.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": "Using ONE run_code program: run" - text: PTC mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/question-composer/answered-expanded.expected.md b/snapshots/web/question-composer/answered-expanded.expected.md index 8b3e7c398e..8dff29824a 100644 --- a/snapshots/web/question-composer/answered-expanded.expected.md +++ b/snapshots/web/question-composer/answered-expanded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use the ask_user_question tool to - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/question-composer/answered.expected.md b/snapshots/web/question-composer/answered.expected.md index 5030acee5b..f3def13c95 100644 --- a/snapshots/web/question-composer/answered.expected.md +++ b/snapshots/web/question-composer/answered.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use the ask_user_question tool to - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/question-composer/cancelled.expected.md b/snapshots/web/question-composer/cancelled.expected.md index b09fe00e55..29cb6d4186 100644 --- a/snapshots/web/question-composer/cancelled.expected.md +++ b/snapshots/web/question-composer/cancelled.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Use the ask_user_question tool to + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/question-composer/late-answered.expected.md b/snapshots/web/question-composer/late-answered.expected.md index 833cccd42c..752dc41523 100644 --- a/snapshots/web/question-composer/late-answered.expected.md +++ b/snapshots/web/question-composer/late-answered.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Use the ask_user_question tool to + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/question-composer/queued.expected.md b/snapshots/web/question-composer/queued.expected.md index abf6f1fe6a..1fb49f32ab 100644 --- a/snapshots/web/question-composer/queued.expected.md +++ b/snapshots/web/question-composer/queued.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Use the ask_user_question tool to + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/queue-actions/collapsed.expected.md b/snapshots/web/queue-actions/collapsed.expected.md index 272b71d385..cc35fe0bfe 100644 --- a/snapshots/web/queue-actions/collapsed.expected.md +++ b/snapshots/web/queue-actions/collapsed.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/queue-actions/editing.expected.md b/snapshots/web/queue-actions/editing.expected.md index 2fc14ac64d..98ce89344a 100644 --- a/snapshots/web/queue-actions/editing.expected.md +++ b/snapshots/web/queue-actions/editing.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/queue-actions/goal-stop.expected.md b/snapshots/web/queue-actions/goal-stop.expected.md index 92a11037e0..3bfd28417f 100644 --- a/snapshots/web/queue-actions/goal-stop.expected.md +++ b/snapshots/web/queue-actions/goal-stop.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Queue item to remove - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/queue-actions/layout.expected.md b/snapshots/web/queue-actions/layout.expected.md index b79770e640..ecf45f562a 100644 --- a/snapshots/web/queue-actions/layout.expected.md +++ b/snapshots/web/queue-actions/layout.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": workspace - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/queue-actions/preserved-expanded.expected.md b/snapshots/web/queue-actions/preserved-expanded.expected.md index 94d44ce9f8..776523a5d3 100644 --- a/snapshots/web/queue-actions/preserved-expanded.expected.md +++ b/snapshots/web/queue-actions/preserved-expanded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/queue-actions/preserved.expected.md b/snapshots/web/queue-actions/preserved.expected.md index be4dd9d5ab..d32b1a15ea 100644 --- a/snapshots/web/queue-actions/preserved.expected.md +++ b/snapshots/web/queue-actions/preserved.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/queue-actions/sending.expected.md b/snapshots/web/queue-actions/sending.expected.md index 0ce88945b0..6bb686eef7 100644 --- a/snapshots/web/queue-actions/sending.expected.md +++ b/snapshots/web/queue-actions/sending.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/queue-actions/ui.expected.md b/snapshots/web/queue-actions/ui.expected.md index 07b3fa10d5..f7e6e50b4f 100644 --- a/snapshots/web/queue-actions/ui.expected.md +++ b/snapshots/web/queue-actions/ui.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/queued-image/delivered.expected.md b/snapshots/web/queued-image/delivered.expected.md index 5fa41f79e6..d855368d94 100644 --- a/snapshots/web/queued-image/delivered.expected.md +++ b/snapshots/web/queued-image/delivered.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/queued-image/queued.expected.md b/snapshots/web/queued-image/queued.expected.md index 4f5cdbcf4e..6f63c63ac0 100644 --- a/snapshots/web/queued-image/queued.expected.md +++ b/snapshots/web/queued-image/queued.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Reply with a one-sentence description - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/rich-text-quotes/ui.expected.md b/snapshots/web/rich-text-quotes/ui.expected.md index f7e0c3a26f..8e9d4fd3e0 100644 --- a/snapshots/web/rich-text-quotes/ui.expected.md +++ b/snapshots/web/rich-text-quotes/ui.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Quote history + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/seeded-history/command-row.expected.md b/snapshots/web/seeded-history/command-row.expected.md index c8f5bab631..dcf6118c23 100644 --- a/snapshots/web/seeded-history/command-row.expected.md +++ b/snapshots/web/seeded-history/command-row.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Use the read tool twice + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/seeded-history/feedback-row.expected.md b/snapshots/web/seeded-history/feedback-row.expected.md index 0d8fedec6e..06a37daa66 100644 --- a/snapshots/web/seeded-history/feedback-row.expected.md +++ b/snapshots/web/seeded-history/feedback-row.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Use the read tool twice + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/seeded-history/ui-expanded.expected.md b/snapshots/web/seeded-history/ui-expanded.expected.md index 12f6c4d0cd..39c1b38b0f 100644 --- a/snapshots/web/seeded-history/ui-expanded.expected.md +++ b/snapshots/web/seeded-history/ui-expanded.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Use the read tool twice + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/seeded-history/ui.expected.md b/snapshots/web/seeded-history/ui.expected.md index 794fa8fad2..96227b6799 100644 --- a/snapshots/web/seeded-history/ui.expected.md +++ b/snapshots/web/seeded-history/ui.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Use the read tool twice + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/skill-tool-row/ui.expected.md b/snapshots/web/skill-tool-row/ui.expected.md index cd974f8a45..b217a3071b 100644 --- a/snapshots/web/skill-tool-row/ui.expected.md +++ b/snapshots/web/skill-tool-row/ui.expected.md @@ -1,5 +1,6 @@ - banner: - navigation "Session hierarchy": Load the editing-cordis-compositions ski + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/steering/mid-steer.expected.md b/snapshots/web/steering/mid-steer.expected.md index ccb5f7bae1..f445dafc6a 100644 --- a/snapshots/web/steering/mid-steer.expected.md +++ b/snapshots/web/steering/mid-steer.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use the ask_user_question tool to - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/steering/settled-expanded.expected.md b/snapshots/web/steering/settled-expanded.expected.md index 7841c63d07..facc318243 100644 --- a/snapshots/web/steering/settled-expanded.expected.md +++ b/snapshots/web/steering/settled-expanded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use the ask_user_question tool to - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/steering/settled.expected.md b/snapshots/web/steering/settled.expected.md index a463df9054..b606292abe 100644 --- a/snapshots/web/steering/settled.expected.md +++ b/snapshots/web/steering/settled.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use the ask_user_question tool to - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/steering/trajectory.expected.md b/snapshots/web/steering/trajectory.expected.md index 2bbaa871a0..d753c24598 100644 --- a/snapshots/web/steering/trajectory.expected.md +++ b/snapshots/web/steering/trajectory.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use the ask_user_question tool to - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/subagent-conversation/nested.expected.md b/snapshots/web/subagent-conversation/nested.expected.md index 2d68bf7341..907cdb2a34 100644 --- a/snapshots/web/subagent-conversation/nested.expected.md +++ b/snapshots/web/subagent-conversation/nested.expected.md @@ -5,6 +5,7 @@ - 'button "Switch subagent: event-sourcing researcher"': event-sourcing researcher - text: / - 'button "Switch subagent: example editor"': example editor + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/subagent-conversation/ui-expanded.expected.md b/snapshots/web/subagent-conversation/ui-expanded.expected.md index fb99690fa6..f96afdc2e1 100644 --- a/snapshots/web/subagent-conversation/ui-expanded.expected.md +++ b/snapshots/web/subagent-conversation/ui-expanded.expected.md @@ -5,6 +5,7 @@ - 'button "Switch subagent: event-sourcing researcher"': event-sourcing researcher - button "1 subagent" - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/subagent-conversation/ui.expected.md b/snapshots/web/subagent-conversation/ui.expected.md index df0bf918eb..5311790493 100644 --- a/snapshots/web/subagent-conversation/ui.expected.md +++ b/snapshots/web/subagent-conversation/ui.expected.md @@ -5,6 +5,7 @@ - 'button "Switch subagent: event-sourcing researcher"': event-sourcing researcher - button "1 subagent" - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/subagent-interrupt/image-queue.expected.md b/snapshots/web/subagent-interrupt/image-queue.expected.md index ea14ddcc39..bd9f9fb6e8 100644 --- a/snapshots/web/subagent-interrupt/image-queue.expected.md +++ b/snapshots/web/subagent-interrupt/image-queue.expected.md @@ -4,6 +4,7 @@ - text: / - 'button "Switch subagent: event-sourcing researcher"': event-sourcing researcher - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/subagent-interrupt/offline-composer.expected.md b/snapshots/web/subagent-interrupt/offline-composer.expected.md index f2b066b262..749a55388c 100644 --- a/snapshots/web/subagent-interrupt/offline-composer.expected.md +++ b/snapshots/web/subagent-interrupt/offline-composer.expected.md @@ -4,6 +4,7 @@ - text: / - 'button "Switch subagent: event-sourcing researcher"': event-sourcing researcher - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/turn-tail-actions/completed.expected.md b/snapshots/web/turn-tail-actions/completed.expected.md index 75da70b7bc..5030f76a04 100644 --- a/snapshots/web/turn-tail-actions/completed.expected.md +++ b/snapshots/web/turn-tail-actions/completed.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Begin your reply with the - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/turn-tail-actions/focused.expected.md b/snapshots/web/turn-tail-actions/focused.expected.md index b25518c55a..6976d8c922 100644 --- a/snapshots/web/turn-tail-actions/focused.expected.md +++ b/snapshots/web/turn-tail-actions/focused.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Begin your reply with the - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/turn-tail-actions/running.expected.md b/snapshots/web/turn-tail-actions/running.expected.md index e4834f582a..dd8eb4972e 100644 --- a/snapshots/web/turn-tail-actions/running.expected.md +++ b/snapshots/web/turn-tail-actions/running.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Begin your reply with the - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/turn-tail-actions/settled.expected.md b/snapshots/web/turn-tail-actions/settled.expected.md index 361f60047a..3f887c7efd 100644 --- a/snapshots/web/turn-tail-actions/settled.expected.md +++ b/snapshots/web/turn-tail-actions/settled.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Begin your reply with the - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/turn-tail-actions/usage-expanded.expected.md b/snapshots/web/turn-tail-actions/usage-expanded.expected.md index 4495ac7acc..ea6ed847d6 100644 --- a/snapshots/web/turn-tail-actions/usage-expanded.expected.md +++ b/snapshots/web/turn-tail-actions/usage-expanded.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Begin your reply with the - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: diff --git a/snapshots/web/web-search-round/ui.expected.md b/snapshots/web/web-search-round/ui.expected.md index 33b37f5230..29ace54a57 100644 --- a/snapshots/web/web-search-round/ui.expected.md +++ b/snapshots/web/web-search-round/ui.expected.md @@ -1,6 +1,7 @@ - banner: - navigation "Session hierarchy": Use web_search once with queries - text: Standard mode + - button "Session panel" - button "More actions" - button "Open right sidebar" - tablist: From 0cf96191623ec0dd1587f9162144fab3e2fc060f Mon Sep 17 00:00:00 2001 From: LegGasai Date: Fri, 6 Nov 2026 11:48:35 +0800 Subject: [PATCH 05/35] fix(panel): draw Session panel section titles in the primary text color Section titles now read as headings in the primary text color, apart from the secondary values and counts beside and below them. --- .../client/ui-session-panel/src/client/SessionPanel.module.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8bd6ca6fa8..76e9a414b6 100644 --- a/packages/client/ui-session-panel/src/client/SessionPanel.module.css +++ b/packages/client/ui-session-panel/src/client/SessionPanel.module.css @@ -65,7 +65,7 @@ min-width: 0; margin: 0; overflow: hidden; - color: var(--dsw-alias-label-tertiary); + color: var(--dsw-alias-label-primary); font: var(--dsw-font-xxs-12); text-overflow: ellipsis; white-space: nowrap; From 7da52786539bd353b52de640226a1736d27ddc25 Mon Sep 17 00:00:00 2001 From: LegGasai Date: Fri, 6 Nov 2026 12:10:29 +0800 Subject: [PATCH 06/35] feat(panel): highlight Session panel rows as a whole and reveal row menus PanelRow gains a menu slot for row actions such as a More button, shown on row hover, on focus inside the row, and while its menu is open, and always without hover. A row with an action covers its whole width with the action's button, and any row with an action or row actions fills as a whole on hover and while one of its menus stays open, instead of filling only the icon and text. The project row moves its More button into the menu slot. --- .../client/ui-primitives/README.i18n.yaml | 4 +- packages/client/ui-primitives/README.md | 2 +- packages/client/ui-primitives/README.zh.md | 2 +- .../ui-primitives/src/PanelRow.module.css | 70 +++++++++++++++---- .../client/ui-primitives/src/PanelRow.tsx | 20 ++++-- .../tests/panel-row.client.spec.tsx | 14 ++++ .../client/ui-session-panel/README.i18n.yaml | 4 +- packages/client/ui-session-panel/README.md | 2 +- packages/client/ui-session-panel/README.zh.md | 2 +- .../src/client/ProjectRow.module.css | 12 ---- .../src/client/ProjectRow.tsx | 6 +- 11 files changed, 93 insertions(+), 45 deletions(-) delete mode 100644 packages/client/ui-session-panel/src/client/ProjectRow.module.css diff --git a/packages/client/ui-primitives/README.i18n.yaml b/packages/client/ui-primitives/README.i18n.yaml index 50f2f4ff45..118b190de7 100644 --- a/packages/client/ui-primitives/README.i18n.yaml +++ b/packages/client/ui-primitives/README.i18n.yaml @@ -18,8 +18,8 @@ en: ead6be55c7c9d7cf zh: 125ad36db7328551 /deepseek-ai-dsh-client-ui-primitives/use-this-package/component-catalog: - en: 57f5e3f2dc9eb425 - zh: 4159654b2604ec5d + en: f23ddcee7e3eeb18 + zh: 2afbd08ebfa4247c /deepseek-ai-dsh-client-ui-primitives/use-this-package/controls-and-icons: en: 2fc65b908307b52e zh: e5c1181ecd2da6e5 diff --git a/packages/client/ui-primitives/README.md b/packages/client/ui-primitives/README.md index 1fcc1a9fc1..7807d24512 100644 --- a/packages/client/ui-primitives/README.md +++ b/packages/client/ui-primitives/README.md @@ -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. `menu` holds row actions, such as a More button, after the trailing area; they show on row hover, on focus inside the row, and while one has its menu open, and always without hover. `onActivate` makes the whole row one button while the trailing area and the menu stay separate controls; a row with an action or row actions fills as a whole on hover and while one of its menus is open. 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. | diff --git a/packages/client/ui-primitives/README.zh.md b/packages/client/ui-primitives/README.zh.md index 656811f72b..fd803dbaaa 100644 --- a/packages/client/ui-primitives/README.zh.md +++ b/packages/client/ui-primitives/README.zh.md @@ -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 装饰图标、单行内容(溢出时以省略号截断)以及可选的尾部数值或控件。图标沿用行文字颜色。`menu` 放在尾部区域之后的行操作(例如「更多」按钮):鼠标悬停在行上、焦点在行内或其菜单打开时显示,没有悬停能力的设备上始终显示。传入 `onActivate` 时整行成为一个按钮,尾部区域与 `menu` 仍是各自独立的控件;带操作或行操作的行在悬停时以及菜单打开期间整行填充。其余属性(例如右键菜单触发属性)落在外层元素上。 | | `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 的引用稳定。 | diff --git a/packages/client/ui-primitives/src/PanelRow.module.css b/packages/client/ui-primitives/src/PanelRow.module.css index 4a6c786fd8..58a6686aba 100644 --- a/packages/client/ui-primitives/src/PanelRow.module.css +++ b/packages/client/ui-primitives/src/PanelRow.module.css @@ -1,11 +1,18 @@ -/* One summary-panel fact: [16px icon] gap 8 [content 13/28] [trailing]. - The icon inherits the row ink so a fact and its glyph share one foreground. */ +/* One summary-panel fact: [16px icon] gap 8 [content 13/28] [trailing] [menu]. + The icon inherits the row ink so a fact and its glyph share one foreground. + A row with an action or row actions highlights as a whole; the action's + button covers the row, and the trailing area and menu sit above it. */ .row { + position: relative; display: flex; align-items: center; gap: 4px; + box-sizing: border-box; min-width: 0; + min-height: 28px; + padding: 0 6px; + border-radius: var(--dsw-radius-sm); color: var(--dsw-alias-label-primary); font: var(--dsw-font-xs-13); } @@ -15,15 +22,13 @@ flex: 1 1 auto; align-items: center; gap: 8px; - box-sizing: border-box; min-width: 0; height: 28px; - padding: 0 6px; - border-radius: var(--dsw-radius-sm); } .action { margin: 0; + padding: 0; border: 0; color: inherit; background: transparent; @@ -32,18 +37,19 @@ cursor: pointer; } -@media (hover: hover) { - .action:hover { - background: var(--dsw-alias-interactive-bg-hover); - } -} - -.action:active { - background: var(--dsw-alias-interactive-bg-active); +.action::after { + position: absolute; + inset: 0; + border-radius: inherit; + content: ''; } .action:focus-visible { - outline-style: solid; + outline: none; +} + +.row:has(> .action:focus-visible) { + outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); outline-offset: -2px; } @@ -69,10 +75,44 @@ white-space: nowrap; } -.trailing { +.trailing, +.menu { + position: relative; + z-index: 1; display: inline-flex; flex: none; align-items: center; gap: 4px; +} + +.trailing { color: var(--dsw-alias-label-tertiary); } + +@media (hover: hover) { + .interactive:hover { + background: var(--dsw-alias-interactive-bg-hover); + } + + .menu { + opacity: 0; + } + + .row:hover .menu, + .row:focus-within .menu { + opacity: 1; + } +} + +/* An open menu keeps its row highlighted and its trigger visible after the pointer leaves for the menu. */ +.interactive:has([aria-expanded='true']) { + background: var(--dsw-alias-interactive-bg-hover); +} + +.menu:has([aria-expanded='true']) { + opacity: 1; +} + +.interactive:has(> .action:active) { + background: var(--dsw-alias-interactive-bg-active); +} diff --git a/packages/client/ui-primitives/src/PanelRow.tsx b/packages/client/ui-primitives/src/PanelRow.tsx index a93fb95bf4..2a2800fb2c 100644 --- a/packages/client/ui-primitives/src/PanelRow.tsx +++ b/packages/client/ui-primitives/src/PanelRow.tsx @@ -13,28 +13,38 @@ export interface PanelRowProps extends Omit, 'childr readonly children: ReactNode /** Optional trailing value or control, laid out after the content without shrinking. */ readonly trailing?: ReactNode - /** Make the icon and content one button with this action; the trailing area stays outside it. */ + /** + * Row actions after the trailing area, such as a More button. They show + * while the pointer is over the row, focus is inside it, or one of them has + * its menu open, and always on devices without hover. + */ + readonly menu?: ReactNode + /** Make the whole row one button with this action; the trailing area and the menu stay separate controls above it. */ readonly onActivate?: (() => void) | undefined } /** - * Render one summary-panel row: icon, single-line content, and an optional trailing area. - * @param props - row content, the optional action, and attributes for the outer element. + * Render one summary-panel row: icon, single-line content, an optional + * trailing area, and optional row actions. A row with an action or row + * actions highlights as a whole on hover and while one of its menus is open. + * @param props - row content, the optional action and row actions, 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, menu, onActivate, className, ...attributes }: PanelRowProps) { const body = ( <> {children} ) + const interactive = onActivate !== undefined || menu !== undefined return ( -
+
{onActivate === undefined ? {body} : } {trailing !== undefined && {trailing}} + {menu !== undefined && {menu}}
) } diff --git a/packages/client/ui-primitives/tests/panel-row.client.spec.tsx b/packages/client/ui-primitives/tests/panel-row.client.spec.tsx index 7a7b28f497..b5c1435e04 100644 --- a/packages/client/ui-primitives/tests/panel-row.client.spec.tsx +++ b/packages/client/ui-primitives/tests/panel-row.client.spec.tsx @@ -29,6 +29,20 @@ describe('PanelRow', () => { expect(onActivate).toHaveBeenCalledTimes(1) }) + it('places row actions after the trailing area and marks only rows with an action or row actions as interactive', () => { + const view = render( + } trailing={value} menu={}>Project, + ) + const row = view.container.querySelector('[data-panel-row]') as HTMLElement + expect([...row.children].map(child => child.textContent)).toEqual(['Project', 'value', 'More']) + const interactive = row.className + cleanup() + const plain = render(} trailing={value}>Project) + const staticRow = plain.container.querySelector('[data-panel-row]') as HTMLElement + expect(staticRow.children).toHaveLength(2) + expect(staticRow.className).not.toBe(interactive) + }) + it('forwards attributes such as context-menu handlers to the outer element', () => { const onContextMenu = vi.fn() const view = render(} className="placed" onContextMenu={onContextMenu} tabIndex={0}>Row) diff --git a/packages/client/ui-session-panel/README.i18n.yaml b/packages/client/ui-session-panel/README.i18n.yaml index c93e04fcc3..0d5adc4dd8 100644 --- a/packages/client/ui-session-panel/README.i18n.yaml +++ b/packages/client/ui-session-panel/README.i18n.yaml @@ -21,8 +21,8 @@ en: 1d99ccdba0457d10 zh: 81833d87548d3225 /deepseek-ai-dsh-client-ui-session-panel/use-this-package/contribute-a-section: - en: 3e9463ce11beff16 - zh: d10d474c06afa3ca + en: 46c0aa93bceeaf0d + zh: 478acadcd8828db6 /deepseek-ai-dsh-client-ui-session-panel/understand-the-implementation: en: e59cf3dc6b08e893 zh: 33548291a59090c2 diff --git a/packages/client/ui-session-panel/README.md b/packages/client/ui-session-panel/README.md index b8d1ee4f87..f0ce954d68 100644 --- a/packages/client/ui-session-panel/README.md +++ b/packages/client/ui-session-panel/README.md @@ -42,7 +42,7 @@ Plugins share a title by registering rows in a section owner's row slot. The bui 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. -Summary rows from every package use the `PanelRow` primitive, so icon, text, and trailing areas line up across sections. +Summary rows from every package use the `PanelRow` primitive, so icon, text, and trailing areas line up across sections; put a row's More button in its `menu` so every row highlights as a whole and reveals its actions the same way. ----- diff --git a/packages/client/ui-session-panel/README.zh.md b/packages/client/ui-session-panel/README.zh.md index b2e8b394bf..86b6f8b12c 100644 --- a/packages/client/ui-session-panel/README.zh.md +++ b/packages/client/ui-session-panel/README.zh.md @@ -42,7 +42,7 @@ kind: "package-reference" 面板隐藏时也要可见的标记(例如需要处理的红点)放进 `conversation.session.panel.indicator` 列表。每个占位都带有说明自身的文字,这些文字会成为开关无障碍名称的一部分。 -各包的摘要行都使用 `PanelRow` 原语,使不同分栏的图标、文字与尾部区域对齐。 +各包的摘要行都使用 `PanelRow` 原语,使不同分栏的图标、文字与尾部区域对齐;行的「更多」按钮放进它的 `menu`,各行就以同样的方式整行高亮并显示操作。 ----- diff --git a/packages/client/ui-session-panel/src/client/ProjectRow.module.css b/packages/client/ui-session-panel/src/client/ProjectRow.module.css deleted file mode 100644 index e4561fd1da..0000000000 --- a/packages/client/ui-session-panel/src/client/ProjectRow.module.css +++ /dev/null @@ -1,12 +0,0 @@ -/* The More button appears on row hover or focus; without hover it stays visible. */ -@media (hover: hover) { - .row .more { - opacity: 0; - } - - .row:hover .more, - .row:focus-within .more, - .more[aria-expanded='true'] { - opacity: 1; - } -} diff --git a/packages/client/ui-session-panel/src/client/ProjectRow.tsx b/packages/client/ui-session-panel/src/client/ProjectRow.tsx index 9381ce1945..b0920175bf 100644 --- a/packages/client/ui-session-panel/src/client/ProjectRow.tsx +++ b/packages/client/ui-session-panel/src/client/ProjectRow.tsx @@ -3,7 +3,6 @@ import type { ReactNode } from 'react' import { IconFolderCloseRegular, PanelRow, PathLabel } from '@deepseek-ai/dsh-client-ui-primitives' import { abbreviateHomePath } from '@deepseek-ai/dsh-util-workspace-path' import type { ProjectRowProps } from './slots.ts' -import css from './ProjectRow.module.css' /** * Render the project directory: the Workspace that lists the Session, or the @@ -25,11 +24,8 @@ export function ProjectRow({ return ( } - trailing={renderFactorySlot('contextMenu.button', { - target, label: t('project.actions'), className: css.more, size: 'sm', - })} + menu={renderFactorySlot('contextMenu.button', { target, label: t('project.actions'), size: 'sm' })} data-session-panel-project="" > From 5286026ec52247d7b01462a6efab112adac8e421 Mon Sep 17 00:00:00 2001 From: LegGasai Date: Fri, 6 Nov 2026 12:56:56 +0800 Subject: [PATCH 07/35] fix(panel): draw section titles in secondary ink at medium weight Primary-ink titles read as one more row of content. Secondary ink at medium weight sets them apart from the primary rows below and from the tertiary counts and progress beside them. --- .../ui-session-panel/src/client/SessionPanel.module.css | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 76e9a414b6..2a66ada038 100644 --- a/packages/client/ui-session-panel/src/client/SessionPanel.module.css +++ b/packages/client/ui-session-panel/src/client/SessionPanel.module.css @@ -60,13 +60,15 @@ padding: 0 6px; } +/* Secondary ink at medium weight: apart from the primary rows below and the tertiary counts beside it. */ .title { flex: 1 1 auto; min-width: 0; margin: 0; overflow: hidden; - color: var(--dsw-alias-label-primary); + color: var(--dsw-alias-label-secondary); font: var(--dsw-font-xxs-12); + font-weight: 500; text-overflow: ellipsis; white-space: nowrap; } From dbd69abfa135f31fbd676240bfeceb542aa4d0da Mon Sep 17 00:00:00 2001 From: LegGasai Date: Fri, 6 Nov 2026 16:52:50 +0800 Subject: [PATCH 08/35] fix(panel): measure adopted Sessions and keep the panel overlay transient - The main width controls restart their measurement when the body adopts its first Session, so a Session opened from the blank home reports its gutter without waiting for a resize. - ConversationLayout gains `shown`: the width controls report null when the body stops showing a Session, and a released Session publishes it as not shown before its layout is dropped. Layouts no longer outlive their Session's binding scope. - The overlay follows its Session's layout and closes once the gutter can dock the panel or the body shows another Session, so it never reopens on its own. - Escape is left to an input method composing text, and focus moves to the toggle when the panel hides while it holds focus. - The client inject list names the context menu, Remote, and connection packages the panel reads, the README states Escape priority and the Chat-only gutter, and the Agent Note describes the turn rail as it is. --- .../2026-11-05-session-panel.i18n.yaml | 10 +-- .../feature/2026-11-05-session-panel.md | 6 +- .../feature/2026-11-05-session-panel.zh.md | 6 +- .../client/ui-conversation/README.i18n.yaml | 4 +- packages/client/ui-conversation/README.md | 2 +- packages/client/ui-conversation/README.zh.md | 2 +- .../src/client/contract/slots.ts | 19 +++-- .../src/client/conversation/assembly.ts | 4 +- .../src/client/conversation/layouts.ts | 71 +++++++++++++----- .../skeleton/ConversationWidthControls.tsx | 7 +- .../tests/layouts.client.spec.ts | 75 +++++++++++++++++++ .../tests/skeleton.client.spec.tsx | 29 ++++++- .../client/ui-session-panel/README.i18n.yaml | 4 +- packages/client/ui-session-panel/README.md | 2 +- packages/client/ui-session-panel/README.zh.md | 2 +- packages/client/ui-session-panel/package.json | 4 + .../src/client/SessionPanel.tsx | 45 +++++++++-- .../ui-session-panel/src/client/index.ts | 4 +- .../ui-session-panel/src/client/visibility.ts | 33 +++++++- .../tests/browser-plugin.client.spec.ts | 2 +- .../tests/components.client.spec.tsx | 63 +++++++++++++++- .../tests/visibility.client.spec.ts | 73 +++++++++++++++--- .../client/ui-session-panel/tsconfig.json | 3 + pnpm-lock.yaml | 3 + 24 files changed, 396 insertions(+), 77 deletions(-) create mode 100644 packages/client/ui-conversation/tests/layouts.client.spec.ts diff --git a/.agents/notes/implemented/feature/2026-11-05-session-panel.i18n.yaml b/.agents/notes/implemented/feature/2026-11-05-session-panel.i18n.yaml index 4bd1f78eff..8fa5341ff8 100644 --- a/.agents/notes/implemented/feature/2026-11-05-session-panel.i18n.yaml +++ b/.agents/notes/implemented/feature/2026-11-05-session-panel.i18n.yaml @@ -12,14 +12,14 @@ en: 547fe8129b027892 zh: dc0807d782f551ae /agent-note-session-panel-over-the-conversation-body-s-end-gutter/decision/docking-follows-the-transcript-gutter: - en: 150a7e8bf3ad556a - zh: c40fcf40af63b353 + en: f406a8821cdc8dc9 + zh: 42178c0188cb0f2b /agent-note-session-panel-over-the-conversation-body-s-end-gutter/decision/sections-are-registrations-the-panel-draws-titles: en: f8e69329e832c764 zh: 2453aa8e794f46f5 -/agent-note-session-panel-over-the-conversation-body-s-end-gutter/decision/the-turn-rail-moves-to-the-start-edge: - en: 05a494885d439fde - zh: 1dc65e5266a9c7b1 +/agent-note-session-panel-over-the-conversation-body-s-end-gutter/decision/the-turn-rail-sits-at-the-start-edge: + en: 08e720a4ea75d4d6 + zh: 5e2e5b8452f67d36 /agent-note-session-panel-over-the-conversation-body-s-end-gutter/alternatives-considered: en: 9cf81cde02bf900b zh: 549d92a260541e3d diff --git a/.agents/notes/implemented/feature/2026-11-05-session-panel.md b/.agents/notes/implemented/feature/2026-11-05-session-panel.md index ca4b96e4ab..5b348b9722 100644 --- a/.agents/notes/implemented/feature/2026-11-05-session-panel.md +++ b/.agents/notes/implemented/feature/2026-11-05-session-panel.md @@ -18,7 +18,7 @@ The panel docks only while the gutter between the transcript column and the body The toggle and the panel read that source and one plugin-owned visibility state and decide the presentation with the same pure function. The toggle therefore reports `aria-expanded` truthfully and knows whether a press flips docking or opens the overlay, which a CSS-only container query cannot tell an element outside the body. -Docking follows one persisted preference shared by every Session and defaults to on. Without room, a press opens a transient overlay for that Session above the transcript and the composer stack; it never changes the preference, and docking from a wide gutter closes it. Hiding automatically and overlaying on request keeps the transcript uncovered without making the facts unreachable on laptop widths. +Docking follows one persisted preference shared by every Session and defaults to on. Without room, a press opens a transient overlay for that Session above the transcript and the composer stack; it never changes the preference, and it closes once its gutter can dock the panel or the main body shows another Session, so it never reappears on its own. The panel state follows the open overlay's layout source, which the Conversation shell marks as no longer shown when the main body leaves the Session, instead of a component cleanup that React's double mount would also run. Hiding automatically and overlaying on request keeps the transcript uncovered without making the facts unreachable on laptop widths. ### Sections are registrations; the panel draws titles @@ -26,9 +26,9 @@ Each section is one list registration with `id`, `order`, and a required `label` Rows from every contributor use the `PanelRow` primitive so icon, text, and trailing areas align across packages; a feature package cannot share its own row component with another feature package. -### The turn rail moves to the start edge +### The turn rail sits at the start edge -The turn rail used the end edge of the scrollport, which the docked panel now occupies. It moves to the start edge with its marks, focus ring, and preview mirrored; its existing 900px hiding rule still guarantees room beside the start-side width handle. +The turn rail sits at the scrollport's start edge with its marks, focus ring, and preview mirrored, leaving the end gutter to the docked panel; its 900px hiding rule guarantees room beside the start-side width handle. ## Alternatives considered diff --git a/.agents/notes/implemented/feature/2026-11-05-session-panel.zh.md b/.agents/notes/implemented/feature/2026-11-05-session-panel.zh.md index 136ceff8a0..4c3712e197 100644 --- a/.agents/notes/implemented/feature/2026-11-05-session-panel.zh.md +++ b/.agents/notes/implemented/feature/2026-11-05-session-panel.zh.md @@ -18,7 +18,7 @@ Status: implemented 开关和面板读取同一个 source 和同一份插件持有的可见性状态,并用同一个纯函数决定呈现方式。因此开关能如实报告 `aria-expanded`,也知道按下后是切换停靠还是打开浮层;纯 CSS 的容器查询无法把结果告诉正文之外的元素。 -停靠遵循所有会话共用的一个持久化偏好,默认开启。没有空间时,按下开关会为该会话在正文和 composer 区域上方打开临时浮层;它从不改变偏好,宽留白下切换停靠也会关闭浮层。自动隐藏加按需浮层,既保证正文不被遮挡,也让笔记本宽度下的信息依然可达。 +停靠遵循所有会话共用的一个持久化偏好,默认开启。没有空间时,按下开关会为该会话在正文和 composer 区域上方打开临时浮层;它从不改变偏好;该会话的留白可以停靠面板,或主正文切到其他会话时,浮层关闭,因此不会自己重新出现。面板状态跟随打开浮层的会话的布局 source,主正文离开该会话时 Conversation 外壳会把它标记为不再显示;不用组件清理函数实现,因为 React 的双重挂载也会运行它。自动隐藏加按需浮层,既保证正文不被遮挡,也让笔记本宽度下的信息依然可达。 ### 分栏是注册项;面板绘制标题 @@ -26,9 +26,9 @@ Status: implemented 所有贡献方的行都使用 `PanelRow` 原语,使不同包的图标、文字与尾部区域对齐;功能包之间不能共享各自的行组件。 -### 轮次轨道移到起始边 +### 轮次轨道位于起始边 -轮次轨道原先贴在滚动容器末端边缘,停靠面板现在占用这里。轨道连同刻度、焦点环和预览镜像到起始边;原有的 900px 隐藏规则仍保证它旁边有足够空间容纳起始侧的宽度拖拽条。 +轮次轨道连同刻度、焦点环和预览位于滚动容器的起始边,末端留白留给停靠面板;它的 900px 隐藏规则保证旁边有足够空间容纳起始侧的宽度拖拽条。 ## Alternatives considered diff --git a/packages/client/ui-conversation/README.i18n.yaml b/packages/client/ui-conversation/README.i18n.yaml index 06d21c9a63..cab118cd76 100644 --- a/packages/client/ui-conversation/README.i18n.yaml +++ b/packages/client/ui-conversation/README.i18n.yaml @@ -21,8 +21,8 @@ en: cc4dafd1aae02468 zh: be6b67724b7ac4a3 /deepseek-ai-dsh-client-ui-conversation/shell-and-standard-props: - en: 1d9c21bd934d1a3b - zh: 3c47d27ea72b2a2e + en: 1939628ccfabb23d + zh: b0882827f338cf8c /deepseek-ai-dsh-client-ui-conversation/temporary-composer-entries: en: 59cd63057dfb6eeb zh: b2e2c86e810b7bb8 diff --git a/packages/client/ui-conversation/README.md b/packages/client/ui-conversation/README.md index 25bc4dab22..7a3bf52c8a 100644 --- a/packages/client/ui-conversation/README.md +++ b/packages/client/ui-conversation/README.md @@ -120,7 +120,7 @@ Active transcripts in the main occurrence expose content-width drag handles in t The width-handle indicator follows the pointer only during a captured drag; ordinary hover leaves its position unchanged. -The main occurrence of an active Session also renders the `conversation.session.panel` seat inside its body, beside the width handles and outside the scrollport; embedded occurrences and the blank home omit it. Its occupant positions itself against the body, which carries the transcript axis and the composer stack height `--dsh-composer-height`. `ctx.uiConversation.layouts.source(sessionId)` publishes that Session's `ConversationLayout`: `endGutter` is the space between the transcript column's end edge and the body's end edge, written by the main width controls after each measurement and drag frame and reset to zero when they unmount. It stays zero while a View other than Chat, which fills the body, is active. +The main occurrence of an active Session also renders the `conversation.session.panel` seat inside its body, beside the width handles and outside the scrollport; embedded occurrences and the blank home omit it. Its occupant positions itself against the body, which carries the transcript axis and the composer stack height `--dsh-composer-height`. `ctx.uiConversation.layouts.source(sessionId)` publishes that Session's `ConversationLayout`: `endGutter` is the space between the transcript column's end edge and the body's end edge, written by the main width controls after each measurement and drag frame, again when the body adopts its first Session, and reset to zero when they stop showing the Session; `shown` says whether the main body shows the Session. The gutter stays zero while a View other than the shipped Chat View (`chat`) is active, because those Views fill the body; a View registered under another id reads zero as well. A Session's layout is dropped when its binding scope is released. The resident composer survives no-Session and Session transitions. Whitespace hides its placeholder; a whitespace-only draft without attachments cannot be sent. The no-Session state keeps the same composer surface mounted but inert while the Workspace picker connects a blank Session. The surface is a shell-owned Lexical editor: reference chips are atomic decorator nodes carrying the owner's serialization identity (submission expands them through the owner codec), the claimed slash command is an atomic leading chip that carries its claim, folder text references carry the folder glyph as an icon prefix, and the draft's text and semantic references are persisted by the per-Session Conversation store. QueueDock reads `next-turn` from the Session `inbox` projection, including cold recovered messages, and excludes only requestIds still owned by local transcript submissions. Other queued rows retain their normal display and actions. Queue operations address exact queue occurrences through the scoped `ctx.conversation` service; queue previews use the [UserText Factory](#sent-user-text) (wire session forms fold to their label) and show local or durable images and files in original attachment order. Images use thumbnails; files use compact name-and-size cards. An edit exposes the literal sent text in the ui-primitives `InlineEditor`, so line breaks survive re-editing. Durable thumbnails resolve through the session image URL cache. Busy Enter behavior is stored in the Host-backed `ui-conversation` settings namespace. The composer keymap arbitrates the trigger menu's keys through the slash pipeline — Tab settles the highlighted completion (or drills a drillable one), Escape and Shift+Tab leave the menu without settling — and leaves every other key to the editor. An overlay that takes the keyboard hands it back through `SessionInput.focus()`, which rides Lexical's own focus so the caret returns where the draft left it rather than at the start. diff --git a/packages/client/ui-conversation/README.zh.md b/packages/client/ui-conversation/README.zh.md index 8f9964211f..90ae97ed3c 100644 --- a/packages/client/ui-conversation/README.zh.md +++ b/packages/client/ui-conversation/README.zh.md @@ -120,7 +120,7 @@ Session 首次绑定或缓存的 Session 成为 current 时,shell 会在渲染 宽度拖拽条的指示线只在已捕获指针的拖拽期间跟随指针,普通悬停不改变其位置。 -活跃 Session 的主 occurrence 还会在正文内渲染 `conversation.session.panel` 落位,与宽度拖拽条同层,位于滚动容器之外;嵌入式 occurrence 和空白首页不渲染它。占位组件相对正文定位,正文持有正文轴线与 composer 区域高度 `--dsh-composer-height`。`ctx.uiConversation.layouts.source(sessionId)` 发布该 Session 的 `ConversationLayout`:`endGutter` 是正文列末端边缘到正文末端边缘的距离,由主宽度控件在每次测量与拖拽帧后写入,控件卸载时归零。激活的是 Chat 以外的 View(这类 View 占满正文)时,它保持为零。 +活跃 Session 的主 occurrence 还会在正文内渲染 `conversation.session.panel` 落位,与宽度拖拽条同层,位于滚动容器之外;嵌入式 occurrence 和空白首页不渲染它。占位组件相对正文定位,正文持有正文轴线与 composer 区域高度 `--dsh-composer-height`。`ctx.uiConversation.layouts.source(sessionId)` 发布该 Session 的 `ConversationLayout`:`endGutter` 是正文列末端边缘到正文末端边缘的距离,由主宽度控件在每次测量与拖拽帧后写入,正文接上第一个 Session 时也会写入一次,不再显示该 Session 时归零;`shown` 表示主正文当前是否显示该 Session。激活的是内置 Chat View(`chat`)以外的 View 时留白保持为零,因为这类 View 占满正文;以其他 id 注册的 View 同样读到零。Session 的绑定 scope 释放时,它的布局随之丢弃。 常驻 composer 在无 Session 与有 Session 之间保持挂载。输入空白字符会隐藏占位提示;没有附件的纯空白草稿无法发送。无 Session 时,同一个编辑器表面保持 inert,Workspace picker 连接 blank Session。该表面是 shell 所有的 Lexical 编辑器:引用 chip 是携带 owner 序列化身份的原子 decorator 节点(提交时经 owner codec 展开),已认领的 slash command 是携带认领的行首原子 chip,文件夹文本引用以图标前缀携带文件夹图形,草稿文字和引用语义字段由逐 Session Conversation store 持久化。QueueDock 从 Session 的 `inbox` 投影读取 `next-turn`,包含从冷状态恢复的消息,仅排除仍由本地 transcript 提交承接的 requestId。其他排队行保留正常展示和操作。Queue 操作通过 scoped `ctx.conversation` service 寻址准确的 queue occurrence;queue 预览使用 [UserText Factory](#sent-user-text)(wire 会话形式折叠为其标签),并按原始附件顺序展示本地或持久化的图片和文件。图片使用缩略图,文件使用紧凑的名称与大小卡片。编辑态在 ui-primitives 的 `InlineEditor` 中展示字面发送文本,因此重新编辑不会丢失换行。持久化缩略图通过会话图片 URL 缓存解析。繁忙时 Enter 行为保存在 Host-backed `ui-conversation` settings namespace。 composer 键盘映射经斜杠流水线裁决触发菜单的按键——Tab 确认高亮补全项(可下钻项则下钻),Escape 与 Shift+Tab 离开菜单且不选定——其余按键交给编辑器自身。 接管键盘的浮层通过 `SessionInput.focus()` 把键盘还回来,该路径走 Lexical 自己的 focus,因此光标回到草稿原来的位置而不是开头。 diff --git a/packages/client/ui-conversation/src/client/contract/slots.ts b/packages/client/ui-conversation/src/client/contract/slots.ts index 9dbe00d8bb..d0520f411b 100644 --- a/packages/client/ui-conversation/src/client/contract/slots.ts +++ b/packages/client/ui-conversation/src/client/contract/slots.ts @@ -443,9 +443,12 @@ export interface ConversationLayout { * Inline space in CSS px between the transcript column's end edge and the * body's end edge. Zero before the first measurement, while the main body * shows another Session, and while the active View does not follow the - * transcript column (every View other than Chat). + * transcript column. Only the shipped Chat View (`chat`) follows it; a View + * registered under another id, and any View that fills the body, reads zero. */ readonly endGutter: number + /** Whether the main Conversation body currently shows the Session. */ + readonly shown: boolean } /** The header corner's occupant derives its state from standard Session props. */ @@ -500,9 +503,10 @@ export interface ConversationInjected { /** * Record the end gutter the main body measured for this occurrence's Session; * no effect without a Session. - * @param endGutter - space between the transcript column's end edge and the body's end edge, in CSS px. + * @param endGutter - space between the transcript column's end edge and the body's end edge, in CSS px; + * null when the body stops showing the Session. */ - reportEndGutter: (endGutter: number) => void + reportEndGutter: (endGutter: number | null) => void } /** Business callbacks injected into the strict Session body. */ @@ -696,11 +700,12 @@ export interface ConversationWidthControlsInputProps { /** Current body phase; handles render only for an active transcript. */ phase: ConversationContentInputProps['phase'] /** - * Receive the end gutter after each measurement and drag frame, and zero when - * the controls unmount. - * @param endGutter - space between the transcript column's end edge and the body's end edge, in CSS px. + * Receive the end gutter after each measurement and drag frame, and null when + * the controls unmount or a new callback replaces this one. + * @param endGutter - space between the transcript column's end edge and the body's end edge, in CSS px; + * null when the body stops showing the Session. */ - onEndGutter: (endGutter: number) => void + onEndGutter: (endGutter: number | null) => void } /** Full props of the reusable Conversation Factory definition. */ diff --git a/packages/client/ui-conversation/src/client/conversation/assembly.ts b/packages/client/ui-conversation/src/client/conversation/assembly.ts index d879921d9b..91348340d9 100644 --- a/packages/client/ui-conversation/src/client/conversation/assembly.ts +++ b/packages/client/ui-conversation/src/client/conversation/assembly.ts @@ -213,7 +213,7 @@ export class UiConversation extends Service { /** Plugin-owned handlers for selection and context-menu gestures. */ readonly interactions: ConversationInteractionRegistry /** Main Conversation body geometry per Session; the Conversation shell writes it and floating chrome reads it. */ - readonly layouts: ConversationLayouts = new ConversationLayouts() + readonly layouts: ConversationLayouts private readonly bindings = new WeakMapWithValues() private readonly images: HistoricalImageCache @@ -229,6 +229,7 @@ export class UiConversation extends Service { this.userText = new UserTextRegistry(ctx) this.interactions = new ConversationInteractionRegistry(ctx) this.images = new HistoricalImageCache(ctx, sessions) + this.layouts = new ConversationLayouts(sessionId => sessions.binding(sessionId)?.ctx) const rebuild = (): void => { for (const record of this.bindings.values) record.binding.rebuild() } @@ -250,6 +251,7 @@ export class UiConversation extends Service { disposeViews() disposeEvents() for (const record of [...this.bindings.values]) this.drop(record, true) + this.layouts.dispose() } }, 'ui-conversation assembly') } diff --git a/packages/client/ui-conversation/src/client/conversation/layouts.ts b/packages/client/ui-conversation/src/client/conversation/layouts.ts index 9caa7c35cf..5923c4ad39 100644 --- a/packages/client/ui-conversation/src/client/conversation/layouts.ts +++ b/packages/client/ui-conversation/src/client/conversation/layouts.ts @@ -1,46 +1,62 @@ /** Per-Session geometry of the main Conversation body, published through `ctx.uiConversation.layouts`. */ +import type { Context } from '@deepseek-ai/cordis' import { createSnapshotStore, type ObservableSnapshot, type SnapshotStore } from '@deepseek-ai/dsh-client-store' import type { SessionId } from '@deepseek-ai/dsh-session/types' import type { ConversationLayout } from '../contract/slots.ts' -const NO_LAYOUT: ConversationLayout = Object.freeze({ endGutter: 0 }) +const NO_LAYOUT: ConversationLayout = Object.freeze({ endGutter: 0, shown: false }) interface LayoutEntry { /** Last end gutter the main body's width controls measured, in CSS px. */ measured: number + /** Whether the main body shows the Session. */ + shown: boolean /** Whether the Session's active View follows the transcript column; false before the first activation. */ followsTranscript: boolean readonly store: SnapshotStore + /** Withdraw the release registered on the Session's scope. */ + release: () => void } /** - * Layout facts of the main Conversation body, kept per Session for the - * lifetime of the Conversation plugin. The Conversation shell writes them: - * the main body's width controls report the measured end gutter, and View - * activation reports whether the active View follows the transcript column. - * The published gutter is zero while it does not, because such a View fills - * the body. Floating chrome reads one Session's facts through `source`. + * Layout facts of the main Conversation body, kept per Session until the + * Session's binding scope is released. The Conversation shell writes them: + * the main body's width controls report the measured end gutter and when the + * body stops showing the Session, and View activation reports whether the + * active View follows the transcript column (only Chat does). The published + * gutter is zero while it does not, because such a View fills the body. + * Floating chrome reads one Session's facts through `source`. */ export class ConversationLayouts { private readonly entries = new Map() + /** + * @param scopeOf - the binding scope of a Session, whose release drops the + * Session's layout; undefined keeps the layout until `dispose`. + */ + constructor(private readonly scopeOf: (sessionId: SessionId) => Context | undefined) {} + /** * Read one Session's layout source. * @param sessionId - Session whose main body geometry is read. - * @returns a source whose identity is stable per Session and whose snapshot keeps its identity until the gutter changes. + * @returns a source whose identity is stable while the Session stays bound and whose snapshot keeps its identity until a fact changes. */ source(sessionId: SessionId): ObservableSnapshot { return this.entryOf(sessionId).store } /** - * Record the end gutter the main body measured while showing a Session. - * @param sessionId - Session the main body shows. - * @param endGutter - space between the transcript column's end edge and the body's end edge, in CSS px. + * Record the end gutter the main body measured while showing a Session, or that it stopped showing it. + * @param sessionId - Session the main body shows or showed. + * @param endGutter - space between the transcript column's end edge and the body's end edge, in CSS px; + * null when the body stops showing the Session. */ - measure(sessionId: SessionId, endGutter: number): void { + measure(sessionId: SessionId, endGutter: number | null): void { + // A Session already released is not shown; recording that would only recreate its entry. + if (endGutter === null && !this.entries.has(sessionId)) return const entry = this.entryOf(sessionId) - entry.measured = Math.max(0, endGutter) + entry.shown = endGutter !== null + entry.measured = endGutter === null ? 0 : Math.max(0, endGutter) this.publish(entry) } @@ -55,18 +71,35 @@ export class ConversationLayouts { this.publish(entry) } + /** Drop every Session's layout and withdraw the releases registered on their scopes. */ + dispose(): void { + for (const entry of [...this.entries.values()]) entry.release() + this.entries.clear() + } + private entryOf(sessionId: SessionId): LayoutEntry { - let entry = this.entries.get(sessionId) - if (entry === undefined) { - entry = { measured: 0, followsTranscript: false, store: createSnapshotStore(NO_LAYOUT) } - this.entries.set(sessionId, entry) + const existing = this.entries.get(sessionId) + if (existing !== undefined) return existing + const entry: LayoutEntry = { + measured: 0, shown: false, followsTranscript: false, store: createSnapshotStore(NO_LAYOUT), release: () => {}, + } + this.entries.set(sessionId, entry) + const scope = this.scopeOf(sessionId) + if (scope !== undefined) { + // Readers holding the source learn that a released Session is no longer shown. + const dispose = scope.effect(() => () => { + this.entries.delete(sessionId) + entry.store.set(NO_LAYOUT) + }, 'ui-conversation layout') + entry.release = () => { void dispose() } } return entry } private publish(entry: LayoutEntry): void { const endGutter = entry.followsTranscript ? entry.measured : 0 - if (entry.store.getSnapshot().endGutter === endGutter) return - entry.store.set(endGutter === 0 ? NO_LAYOUT : { endGutter }) + const current = entry.store.getSnapshot() + if (current.endGutter === endGutter && current.shown === entry.shown) return + entry.store.set(endGutter === 0 && !entry.shown ? NO_LAYOUT : { endGutter, shown: entry.shown }) } } diff --git a/packages/client/ui-conversation/src/client/skeleton/ConversationWidthControls.tsx b/packages/client/ui-conversation/src/client/skeleton/ConversationWidthControls.tsx index 1b35ee6137..63c08829a3 100644 --- a/packages/client/ui-conversation/src/client/skeleton/ConversationWidthControls.tsx +++ b/packages/client/ui-conversation/src/client/skeleton/ConversationWidthControls.tsx @@ -152,6 +152,9 @@ export function ConversationWidthControls({ container, phase, onEndGutter }: Con report.current((column - resolveContentWidth(column, preference)) / 2) }, []) + // A new callback means the body adopted a Session without remounting or + // resizing: the measurement restarts so that Session gets the current gutter, + // and the callback it replaces receives its final zero. useLayoutEffect(() => { if (container === null) return const observer = new ResizeObserver(() => { publishWidths(container) }) @@ -159,9 +162,9 @@ export function ConversationWidthControls({ container, phase, onEndGutter }: Con publishWidths(container) return () => { observer.disconnect() - report.current(0) + onEndGutter(null) } - }, [container, publishWidths]) + }, [container, onEndGutter, publishWidths]) const onStart = useCallback((): number => { if (container === null) return 680 diff --git a/packages/client/ui-conversation/tests/layouts.client.spec.ts b/packages/client/ui-conversation/tests/layouts.client.spec.ts new file mode 100644 index 0000000000..792fe539b4 --- /dev/null +++ b/packages/client/ui-conversation/tests/layouts.client.spec.ts @@ -0,0 +1,75 @@ +import { Context } from '@deepseek-ai/cordis' +import type { SessionId } from '@deepseek-ai/dsh-session/types' +import { describe, expect, it } from 'vitest' +import { ConversationLayouts } from '../src/client/conversation/layouts.ts' + +const S1 = 's1' as SessionId +const S2 = 's2' as SessionId + +describe('ConversationLayouts', () => { + it('publishes the measured gutter and whether the body shows the Session, while Chat is active', () => { + const layouts = new ConversationLayouts(() => undefined) + const source = layouts.source(S1) + expect(source.getSnapshot()).toEqual({ endGutter: 0, shown: false }) + layouts.measure(S1, 400) + // Before a View activates, nothing follows the transcript column. + expect(source.getSnapshot()).toEqual({ endGutter: 0, shown: true }) + layouts.activate(S1, true) + expect(source.getSnapshot()).toEqual({ endGutter: 400, shown: true }) + layouts.measure(S1, -5) + expect(source.getSnapshot()).toEqual({ endGutter: 0, shown: true }) + layouts.measure(S1, 360) + layouts.activate(S1, false) + expect(source.getSnapshot()).toEqual({ endGutter: 0, shown: true }) + layouts.activate(S1, true) + layouts.measure(S1, null) + expect(source.getSnapshot()).toEqual({ endGutter: 0, shown: false }) + expect(layouts.source(S2).getSnapshot()).toEqual({ endGutter: 0, shown: false }) + }) + + it('keeps the snapshot identity until a fact changes and notifies only on changes', () => { + const layouts = new ConversationLayouts(() => undefined) + const source = layouts.source(S1) + layouts.activate(S1, true) + layouts.measure(S1, 400) + const first = source.getSnapshot() + let notified = 0 + const off = source.subscribe(() => { notified += 1 }) + layouts.measure(S1, 400) + layouts.activate(S1, true) + expect(source.getSnapshot()).toBe(first) + expect(notified).toBe(0) + layouts.measure(S1, 380) + expect(notified).toBe(1) + off() + }) + + it('drops a Session layout when its scope is released, and every layout on dispose', async () => { + const root = new Context() + const one = root.plugin(() => {}) + const two = root.plugin(() => {}) + await Promise.all([one, two]) + const scopes = new Map([[S1, one], [S2, two]]) + const layouts = new ConversationLayouts(sessionId => scopes.get(sessionId)?.ctx) + const first = layouts.source(S1) + expect(layouts.source(S1)).toBe(first) + layouts.activate(S1, true) + layouts.measure(S1, 400) + const seen: unknown[] = [] + first.subscribe(() => { seen.push(first.getSnapshot()) }) + // A released Session no longer resolves a binding scope, and its readers see it hidden. + await scopes.get(S1)?.dispose() + scopes.delete(S1) + expect(seen).toEqual([{ endGutter: 0, shown: false }]) + // The body's final report after the release recreates nothing. + layouts.measure(S1, null) + expect(layouts.source(S1)).not.toBe(first) + expect(layouts.source(S1).getSnapshot()).toEqual({ endGutter: 0, shown: false }) + const second = layouts.source(S2) + layouts.dispose() + expect(layouts.source(S2)).not.toBe(second) + // A Session without a scope keeps its layout until dispose. + const unscoped = layouts.source('s3' as SessionId) + expect(layouts.source('s3' as SessionId)).toBe(unscoped) + }) +}) diff --git a/packages/client/ui-conversation/tests/skeleton.client.spec.tsx b/packages/client/ui-conversation/tests/skeleton.client.spec.tsx index c82b03cb77..69de5bd9f8 100644 --- a/packages/client/ui-conversation/tests/skeleton.client.spec.tsx +++ b/packages/client/ui-conversation/tests/skeleton.client.spec.tsx @@ -22,6 +22,7 @@ import { createConversationStore } from '../src/client/stores.ts' import { SessionInputShell } from '../src/client/input/facade.ts' import { en, zh } from '../src/client/locales.ts' import { ConversationContent } from '../src/client/skeleton/ConversationContent.tsx' +import { ConversationWidthControls } from '../src/client/skeleton/ConversationWidthControls.tsx' import { ConversationHeader } from '../src/client/skeleton/ConversationHeader.tsx' import { ConversationMainPanel } from '../src/client/skeleton/ConversationMainPanel.tsx' import { ConversationSession, ConversationSessionHeader } from '../src/client/skeleton/ConversationSession.tsx' @@ -33,7 +34,7 @@ import type { InputBarProps } from '../src/client/skeleton/InputBar.tsx' import type { ComposerBarOwnerProps, ConversationContentInputProps, ConversationContentProps, ConversationHeaderLineageOwnerProps, ConversationSessionHeaderSlotProps, ConversationSessionSlotProps, ConversationSlotProps, - ConversationViewActionsOwnerProps, ConversationViewsProps, HeroFrameOwnerProps, + ConversationViewActionsOwnerProps, ConversationViewsProps, HeroFrameOwnerProps, ConversationWidthControlsProps, } from '../src/client/contract/slots.ts' import type { ViewTab } from '../src/client/contract/views.ts' @@ -207,7 +208,7 @@ function mount( let actionsOwner: ConversationViewActionsOwnerProps | undefined const setPinned = vi.fn<(id: string, pinned: boolean) => void>() /** End gutters the main width controls reported, in order. */ - const gutters: number[] = [] + const gutters: (number | null)[] = [] const renderSlot = ((key: string, owner: object, opts?: { only?: string; fallback?: ReactNode; children?: ReactNode }) => { slotCalls.push(key) if (key === 'conversation.input.model' || key === 'conversation.input.plan') { @@ -1084,7 +1085,7 @@ describe('ConversationRoot resident composer', () => { expect(b.view.container.querySelector('[data-width-handle]')).toBeNull() }) - it('reports the end gutter after each measurement and drag frame, and zero on unmount', () => { + it('reports the end gutter after each measurement and drag frame, and that it stops showing the Session on unmount', () => { const b = mount(sessionSnapshotOf()) const content = b.view.container.querySelector('[data-conversation-content]') as HTMLElement Object.defineProperty(content, 'offsetWidth', { value: 1600, configurable: true }) @@ -1111,7 +1112,27 @@ describe('ConversationRoot resident composer', () => { } } b.view.unmount() - expect(b.gutters.at(-1)).toBe(0) + expect(b.gutters.at(-1)).toBeNull() + }) + + it('reports the end gutter to a newly adopted Session without a resize, and only once per callback', () => { + const body = document.createElement('div') + document.body.append(body) + Object.defineProperty(body, 'offsetWidth', { value: 1600, configurable: true }) + const props = (onEndGutter: (gutter: number | null) => void) => ({ container: body, phase: 'active', onEndGutter }) as + Pick as ConversationWidthControlsProps + const blank = vi.fn<(gutter: number | null) => void>() + const adopted = vi.fn<(gutter: number | null) => void>() + const view = render() + expect(blank).toHaveBeenLastCalledWith(340) + view.rerender() + expect(blank).toHaveBeenLastCalledWith(null) + expect(adopted.mock.calls).toEqual([[340]]) + view.rerender() + expect(adopted).toHaveBeenCalledOnce() + view.unmount() + expect(adopted).toHaveBeenLastCalledWith(null) + body.remove() }) it('renders the Session panel seat only for the main occurrence of an active Session', () => { diff --git a/packages/client/ui-session-panel/README.i18n.yaml b/packages/client/ui-session-panel/README.i18n.yaml index 0d5adc4dd8..f907fc7722 100644 --- a/packages/client/ui-session-panel/README.i18n.yaml +++ b/packages/client/ui-session-panel/README.i18n.yaml @@ -18,8 +18,8 @@ en: d7818d67e981be3c zh: c7c0c704d5ef8b34 /deepseek-ai-dsh-client-ui-session-panel/use-this-package/docking-and-the-overlay: - en: 1d99ccdba0457d10 - zh: 81833d87548d3225 + en: c10ebd54b9412ac1 + zh: a5e878ab049c44a9 /deepseek-ai-dsh-client-ui-session-panel/use-this-package/contribute-a-section: en: 46c0aa93bceeaf0d zh: 478acadcd8828db6 diff --git a/packages/client/ui-session-panel/README.md b/packages/client/ui-session-panel/README.md index f0ce954d68..776ac127d0 100644 --- a/packages/client/ui-session-panel/README.md +++ b/packages/client/ui-session-panel/README.md @@ -31,7 +31,7 @@ The `@deepseek-ai/dsh-web-app` bundle loads this package by default. The toggle The panel docks while the gutter between the transcript column and the body's end edge is at least 344px: 48px clear of the column and its width handle, the panel's 280px minimum width, and a 16px edge margin. Docked, it is 280–340px wide, starts 12px below the header, and scrolls inside itself. Pressing the toggle then flips one docking preference that every Session shares and that persists in `localStorage` under `dsh.sessionPanel.pinned`; the panel docks by default. -A narrower gutter hides the docked panel, so it never covers the transcript. This includes a narrow window, an expanded right sidebar, a dragged-wide transcript column, and every View other than Chat, because those Views fill the body. Pressing the toggle then opens the panel over the transcript with the prominent elevation, above the composer stack and not covering it. The overlay closes from the toggle, on Escape, and on a pointer press outside the panel, the toggle, and any open menu, such as a row's context menu; Escape returns focus to the toggle when focus was inside the panel, and a modal above the page keeps Escape. Closing it does not change the docking preference. At most one Session's overlay is open, and docking from a wide gutter closes it. +A narrower gutter hides the docked panel, so it never covers the transcript. This includes a narrow window, an expanded right sidebar, a dragged-wide transcript column, and every View other than Chat, because those Views fill the body. Pressing the toggle then opens the panel over the transcript with the prominent elevation, above the composer stack and not covering it. The overlay closes from the toggle, on Escape, and on a pointer press outside the panel, the toggle, and any open menu, such as a row's context menu; Escape returns focus to the toggle when focus was inside the panel. A modal above the page, an input method composing text, and a handler that already took the key, such as an open menu's, keep Escape; otherwise the overlay takes it first, so with the overlay open the first Escape from the composer closes the overlay and does not count toward stopping a running turn. Closing it does not change the docking preference. At most one Session's overlay is open; it closes once the gutter widens enough to dock and once the main body shows another Session, and switching back does not reopen it. When the panel hides while focus is inside it, focus moves to the toggle. ### Contribute a section diff --git a/packages/client/ui-session-panel/README.zh.md b/packages/client/ui-session-panel/README.zh.md index 86b6f8b12c..92130c15d4 100644 --- a/packages/client/ui-session-panel/README.zh.md +++ b/packages/client/ui-session-panel/README.zh.md @@ -31,7 +31,7 @@ kind: "package-reference" 正文列到对话区末端边缘的留白不少于 344px 时,面板停靠:与正文列及其宽度手柄保持 48px 间距,面板最小宽度 280px,外加 16px 边距。停靠时面板宽 280–340px,位于标题栏下方 12px,内容在面板内滚动。此时按开关会切换所有会话共用的停靠偏好,偏好存放在 `localStorage` 的 `dsh.sessionPanel.pinned` 中;默认停靠。 -留白更窄时隐藏停靠面板,保证不遮挡正文。窗口变窄、展开右侧栏、把正文列拖宽,以及切换到 Chat 以外的视图(这些视图占满对话区)都会如此。此时按开关,面板以更强的阴影浮在正文上方,位于输入框区域之上,且不遮挡输入框。浮层可以用开关关闭,也会在按 Esc 时,或在面板、开关和任何已打开的菜单(例如行的上下文菜单)之外按下指针时关闭;焦点原本在面板内时,按 Esc 后焦点回到开关,页面上方有模态框时 Esc 归模态框处理。关闭浮层不改变停靠偏好。同一时间最多一个会话的浮层处于打开状态,在宽留白下切换停靠也会关闭它。 +留白更窄时隐藏停靠面板,保证不遮挡正文。窗口变窄、展开右侧栏、把正文列拖宽,以及切换到 Chat 以外的视图(这些视图占满对话区)都会如此。此时按开关,面板以更强的阴影浮在正文上方,位于输入框区域之上,且不遮挡输入框。浮层可以用开关关闭,也会在按 Esc 时,或在面板、开关和任何已打开的菜单(例如行的上下文菜单)之外按下指针时关闭;焦点原本在面板内时,按 Esc 后焦点回到开关。页面上方有模态框、输入法正在组字,或已有处理程序(例如打开的菜单)接手了这次按键时,Esc 不归浮层;其余情况由浮层先处理,因此浮层打开时,在输入框按下的第一次 Esc 只关闭浮层,不计入停止当前轮次的连按。关闭浮层不改变停靠偏好。同一时间最多一个会话的浮层处于打开状态;留白变宽到可以停靠时,以及主正文切到其他会话时,浮层都会关闭,切回来也不会重新打开。面板隐藏时如果焦点在面板内,焦点移到开关。 ### 贡献分栏 diff --git a/packages/client/ui-session-panel/package.json b/packages/client/ui-session-panel/package.json index 44aa1ebc95..a67d989b2a 100644 --- a/packages/client/ui-session-panel/package.json +++ b/packages/client/ui-session-panel/package.json @@ -39,6 +39,7 @@ "@deepseek-ai/dsh-api-remotes": "workspace:*", "@deepseek-ai/dsh-api-session-controller": "workspace:*", "@deepseek-ai/dsh-api-workspace-controller": "workspace:*", + "@deepseek-ai/dsh-client-connection": "workspace:*", "@deepseek-ai/dsh-client-locale": "workspace:*", "@deepseek-ai/dsh-client-store": "workspace:*", "@deepseek-ai/dsh-client-test-runtime": "workspace:*", @@ -68,7 +69,10 @@ "dsh": { "client": { "inject": [ + "@deepseek-ai/dsh-api-remotes", + "@deepseek-ai/dsh-client-connection", "@deepseek-ai/dsh-client-locale", + "@deepseek-ai/dsh-client-ui-context-menu", "@deepseek-ai/dsh-client-ui-conversation", "@deepseek-ai/dsh-client-ui-primitives" ], diff --git a/packages/client/ui-session-panel/src/client/SessionPanel.tsx b/packages/client/ui-session-panel/src/client/SessionPanel.tsx index ffe655bc7d..39ff023b89 100644 --- a/packages/client/ui-session-panel/src/client/SessionPanel.tsx +++ b/packages/client/ui-session-panel/src/client/SessionPanel.tsx @@ -1,6 +1,6 @@ /** Floating Session panel: section titles drawn from the section roster, bodies from the section slot. */ -import { useCallback, useEffect, useMemo, useRef, type ReactNode } from 'react' -import { isBehindModal } from '@deepseek-ai/dsh-client-ui-primitives' +import { useCallback, useEffect, useMemo, useRef, type FocusEvent, type ReactNode } from 'react' +import { isBehindModal, observeComposition } from '@deepseek-ai/dsh-client-ui-primitives' import { panelElementId, toggleElementId } from './element-ids.ts' import type { SessionPanelProps, SessionPanelSectionOwnerProps } from './slots.ts' import { fitsLayout, presentationOf } from './visibility.ts' @@ -8,9 +8,10 @@ import css from './SessionPanel.module.css' /** * Close the overlay on Escape and on a pointerdown outside the panel. The - * toggle and open menus, such as a row's context menu, count as inside, and a - * modal above the page keeps Escape. Escape returns focus to the toggle when - * focus was inside the panel. + * toggle and open menus, such as a row's context menu, count as inside; a + * modal above the page and an input method composing text keep Escape, as + * does a handler that already took it. Escape returns focus to the toggle + * when focus was inside the panel. * @param panel - the overlay element. * @param open - whether the overlay shows; false detaches the listeners. * @param toggleId - id of the Session's toggle. @@ -19,6 +20,7 @@ import css from './SessionPanel.module.css' function useOverlayDismissal(panel: { readonly current: HTMLElement | null }, open: boolean, toggleId: string, close: () => void): void { useEffect(() => { if (!open) return + const composition = observeComposition(document) const inside = (target: EventTarget | null): boolean => target instanceof Element && ( panel.current?.contains(target) === true || document.getElementById(toggleId)?.contains(target) === true @@ -28,7 +30,7 @@ function useOverlayDismissal(panel: { readonly current: HTMLElement | null }, op if (!inside(event.target)) close() } const onKeyDown = (event: KeyboardEvent): void => { - if (event.key !== 'Escape' || event.defaultPrevented || isBehindModal(panel.current)) return + if (event.key !== 'Escape' || composition.guards(event) || event.defaultPrevented || isBehindModal(panel.current)) return event.preventDefault() const focused = panel.current?.contains(document.activeElement) === true close() @@ -39,10 +41,38 @@ function useOverlayDismissal(panel: { readonly current: HTMLElement | null }, op return () => { document.removeEventListener('pointerdown', onPointerDown) document.removeEventListener('keydown', onKeyDown) + composition.dispose() } }, [panel, open, toggleId, close]) } +/** + * Hand focus to the toggle when the panel hides with the keyboard inside it, + * as when a narrower gutter hides the docked panel: the focused control is + * gone and the toggle is the control that brings it back. + * @param hidden - whether the panel renders nothing. + * @param toggleId - id of the Session's toggle. + * @returns focus handlers for the panel element. + */ +function useFocusReturn(hidden: boolean, toggleId: string): { + readonly onFocus: () => void + readonly onBlur: (event: FocusEvent) => void +} { + const inside = useRef(false) + useEffect(() => { + if (!hidden || !inside.current) return + inside.current = false + document.getElementById(toggleId)?.focus({ preventScroll: true }) + }, [hidden, toggleId]) + return useMemo(() => ({ + onFocus: () => { inside.current = true }, + onBlur: (event) => { + // Removal can report no next target; only a move to another element leaves the panel. + if (event.relatedTarget instanceof Element && !event.currentTarget.contains(event.relatedTarget)) inside.current = false + }, + }), []) +} + /** * Render the panel while it docks or shows as an overlay. Each section keeps * its title row and body; CSS hides a section whose body rendered nothing. @@ -63,6 +93,7 @@ export function SessionPanel({ : { presentation, dismissOverlay }, [presentation, dismissOverlay]) useOverlayDismissal(panel, presentation === 'overlay', toggleElementId(sessionId), dismissOverlay) + const focus = useFocusReturn(owner === undefined, toggleElementId(sessionId)) if (owner === undefined) return null return (