diff --git a/packages/client/ui-chat/README.i18n.yaml b/packages/client/ui-chat/README.i18n.yaml index 2dc317ad69..f9b09eb73f 100644 --- a/packages/client/ui-chat/README.i18n.yaml +++ b/packages/client/ui-chat/README.i18n.yaml @@ -39,8 +39,8 @@ en: f6d8bbae13a1a8f8 zh: 96c8f400c215e33d /deepseek-ai-dsh-client-ui-chat/scroll-ownership: - en: 983f27806146e9ea - zh: bb60333c7a6736ed + en: 26d32be41a7bb8af + zh: 3a5f8a10ec8a271f /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 e4b1ec62d5..fb0bf43efd 100644 --- a/packages/client/ui-chat/README.md +++ b/packages/client/ui-chat/README.md @@ -160,7 +160,7 @@ Chat restores semantic anchors across history prepend and renderer remounts, wit 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 `conversation.chat.aside` slot holds one Session-level occupant beside the transcript, such as the [Session panel](../ui-session-panel/README.md). Every Chat View occurrence, main or embedded, renders it in a zero-height layer at the top of the Chat frame, positioned like the turn rail, so it stays in place while the transcript scrolls and inherits `--dsh-composer-height` and `--dsh-conversation-viewport-height` from the shared scrollport. The layer stacks above the turn rail and the back-to-bottom button and passes pointer events through. Its owner prop `endGutter` is half the width the frame leaves around the transcript column, in whole CSS px, computed from the widths a `ResizeObserver` reports for the layer and the column. It follows window and sidebar resizes and dragged column widths without reading element geometry, stays zero without `ResizeObserver`, and re-renders the layer only when it changes. +The `conversation.chat.aside` slot holds one Session-level occupant beside the transcript, such as the [Session panel](../ui-session-panel/README.md). Every Chat View occurrence, main or embedded, renders it in a zero-height layer at the top of the Chat frame, positioned like the turn rail, so it stays in place while the transcript scrolls and inherits `--dsh-composer-height` and `--dsh-conversation-viewport-height` from the shared scrollport. The layer stacks above the turn rail and the back-to-bottom button and passes pointer events through. Its owner prop `endGutter` is an observable source of half the width the frame leaves around the transcript column, in whole CSS px, computed from the widths a `ResizeObserver` reports for the layer and the column. It follows window and sidebar resizes and dragged column widths without reading element geometry and stays zero without `ResizeObserver`. The source keeps its identity, so the layer renders once and a resize re-renders only an occupant whose derived value changes; an occupant sizes itself in CSS, where the same gutter is `(100% - var(--dsh-chat-content-width)) / 2` of the layer. 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 d470865a92..dab40b7fbc 100644 --- a/packages/client/ui-chat/README.zh.md +++ b/packages/client/ui-chat/README.zh.md @@ -160,7 +160,7 @@ Chat 会在历史前插与 renderer 重新挂载时恢复语义锚点,并且 轮次轨道与回到底部按钮位于正文裁剪层外。它们相对共享会话滚动容器做 sticky 定位;Chat 自己持有滚动容器时,则相对 Chat 外框做 absolute 定位。轮次轨道贴在滚动容器的起始边,把末端留白让给[会话面板](../ui-session-panel/README.zh.md),预览朝正文方向弹出。正文扣除水平内边距后的可用宽度不超过 900px 时,隐藏轮次轨道;判断依据不是浏览器视口宽度。 -`conversation.chat.aside` slot 放一个位于正文旁边、面向整个会话的组件,例如[会话面板](../ui-session-panel/README.zh.md)。每个 Chat 视图实例(主正文区或嵌入的)都会渲染它:它位于 Chat 外框顶部的零高度图层中,定位方式与轮次轨道相同,因此不随正文滚动,并从共享滚动容器继承 `--dsh-composer-height` 与 `--dsh-conversation-viewport-height`。该图层叠在轮次轨道与回到底部按钮之上,自身不拦截指针事件。owner 属性 `endGutter` 是外框在正文列两侧留出宽度的一半(整数 CSS px),由 `ResizeObserver` 报告的图层与正文列宽度算出。它跟随窗口、侧栏尺寸变化和拖动后的正文宽度,不读取元素几何;没有 `ResizeObserver` 时保持为 0;只有它变化时图层才重新渲染。 +`conversation.chat.aside` slot 放一个位于正文旁边、面向整个会话的组件,例如[会话面板](../ui-session-panel/README.zh.md)。每个 Chat 视图实例(主正文区或嵌入的)都会渲染它:它位于 Chat 外框顶部的零高度图层中,定位方式与轮次轨道相同,因此不随正文滚动,并从共享滚动容器继承 `--dsh-composer-height` 与 `--dsh-conversation-viewport-height`。该图层叠在轮次轨道与回到底部按钮之上,自身不拦截指针事件。owner 属性 `endGutter` 是一个可订阅的数据源,值为外框在正文列两侧留出宽度的一半(整数 CSS px),由 `ResizeObserver` 报告的图层与正文列宽度算出。它跟随窗口、侧栏尺寸变化和拖动后的正文宽度,不读取元素几何;没有 `ResizeObserver` 时保持为 0。数据源的引用不变,因此图层只渲染一次,尺寸变化只让由它推导出的值发生变化的占位组件重新渲染;占位组件用 CSS 决定自身尺寸,同一留白在图层中为 `(100% - var(--dsh-chat-content-width)) / 2`。 正文根节点使用 `overflow-x: visible; overflow-y: clip`:裁剪纵向溢出,但不创建滚动容器。因此,在没有更近的滚动祖先时,Markdown 代码块的 sticky 头栏和展开的压缩摘要头栏仍以实际会话滚动容器为参照。限高过程组和终端区域保留各自的滚动容器。 diff --git a/packages/client/ui-chat/src/client/chat/ChatAside.tsx b/packages/client/ui-chat/src/client/chat/ChatAside.tsx index fd04a76b3f..99f4ecf6e3 100644 --- a/packages/client/ui-chat/src/client/chat/ChatAside.tsx +++ b/packages/client/ui-chat/src/client/chat/ChatAside.tsx @@ -1,5 +1,6 @@ -/** The Chat View's aside layer: one Session-level occupant beside the transcript, given the end gutter it keeps within. */ +/** The Chat View's aside layer: one Session-level occupant beside the transcript, given the end gutter as an observable source. */ import { memo, useLayoutEffect, useMemo, useRef, useState, type RefObject } from 'react' +import { createSnapshotStore, type ObservableSnapshot } from '@deepseek-ai/dsh-client-store' import type { PropsRenderSlots } from '@deepseek-ai/dsh-client-ui-slots' import type { ChatAsideOwnerProps } from '../contract/slots.ts' import css from './ChatView.module.css' @@ -9,12 +10,16 @@ import css from './ChatView.module.css' * layer, which spans the Chat frame, and for the transcript column, which * covers window and sidebar resizes and a dragged column width. The column * is centered in the frame, so the gutter is half their difference; no - * element geometry is read. Without ResizeObserver the gutter stays zero. + * element geometry is read. Each change is published to the returned source, + * so the layer itself never re-renders for a resize. Without ResizeObserver + * the gutter stays zero. * @param layer - the aside layer, a child of the Chat frame that precedes the transcript column. - * @returns the gutter in whole CSS px, zero until both widths are known. + * @returns the gutter in whole CSS px, zero until both widths are known; one source for the layer's lifetime. */ -function useEndGutter(layer: RefObject): number { - const [gutter, setGutter] = useState(0) +function useEndGutter(layer: RefObject): ObservableSnapshot { + const [gutter] = useState(() => createSnapshotStore(0)) + // Observing before the first paint lets the first report land before that paint, so an occupant that the gutter + // shows, such as a docked panel, does not miss the frame in which its Chat View mounts. useLayoutEffect(() => { if (typeof ResizeObserver === 'undefined') return // The frame's DOM is in place, though its own refs attach after this child's layout effect. @@ -28,19 +33,19 @@ function useEndGutter(layer: RefObject): number { else columnWidth = entry.contentRect.width } if (layerWidth === undefined || columnWidth === undefined) return - setGutter(Math.max(0, Math.round((layerWidth - columnWidth) / 2))) + gutter.set(Math.max(0, Math.round((layerWidth - columnWidth) / 2))) }) observer.observe(layerElement) observer.observe(column) return () => { observer.disconnect() } - }, [layer]) + }, [layer, gutter]) return gutter } /** * Render the aside layer with its occupant. The Chat View's `renderSlot` is - * stable per registration, so the layer re-renders only when the gutter - * changes, not with every transcript update. + * stable per registration and the gutter source keeps its identity, so the + * layer renders once: neither transcript updates nor resizes re-render it. * @param props - the Chat View's slot renderer. * @returns the zero-height aside layer. */ diff --git a/packages/client/ui-chat/src/client/contract/slots.ts b/packages/client/ui-chat/src/client/contract/slots.ts index 47566f6a34..4430c81374 100644 --- a/packages/client/ui-chat/src/client/contract/slots.ts +++ b/packages/client/ui-chat/src/client/contract/slots.ts @@ -391,10 +391,14 @@ export type ChatFlowSlotProps = export interface ChatAsideOwnerProps { /** * Inline space in CSS px between the transcript column's end edge and the - * Chat frame's end edge, measured again whenever the frame or the column - * resizes; zero before the first measurement. + * Chat frame's end edge, followed whenever the frame or the column resizes; + * zero before the first measurement. The source keeps its identity for the + * layer's lifetime and publishes changes without re-rendering the layer, so + * an occupant subscribes for the decisions it derives from the gutter and + * sizes itself in CSS, where the gutter is + * `(100% - var(--dsh-chat-content-width)) / 2` of the layer. */ - readonly endGutter: number + readonly endGutter: ObservableSnapshot } /** Full Chat view props. */ @@ -448,7 +452,7 @@ declare module '@deepseek-ai/dsh-client-ui-slots' { * scrolls and inherits the shared scrollport's composer and viewport * heights. The layer passes pointer events through; the occupant * positions itself in it, enables its own pointer events, and keeps - * within `endGutter` to stay clear of the transcript column. + * within the end gutter to stay clear of the transcript column. */ 'conversation.chat.aside': { kind: 'single'; scope: 'session'; owner: ChatAsideOwnerProps } diff --git a/packages/client/ui-chat/tests/chat-view.client.spec.tsx b/packages/client/ui-chat/tests/chat-view.client.spec.tsx index 26797e8de5..47a58a9660 100644 --- a/packages/client/ui-chat/tests/chat-view.client.spec.tsx +++ b/packages/client/ui-chat/tests/chat-view.client.spec.tsx @@ -869,7 +869,7 @@ describe('Chat node rendering', () => { }) describe('ChatView', () => { - it('renders the aside with half the width the frame leaves around the transcript column, following resizes', () => { + it('gives the aside a gutter source that follows half the width the frame leaves around the transcript column, rendering the aside once', () => { const observers: { callback: ResizeObserverCallback; targets: Element[] }[] = [] vi.stubGlobal('ResizeObserver', class { readonly targets: Element[] = [] @@ -892,31 +892,34 @@ describe('ChatView', () => { const entries = sizes.map(([target, width]) => ({ target, contentRect: { width } }) as ResizeObserverEntry) act(() => { gutter?.callback(entries, {} as ResizeObserver) }) } + expect(h.asideOwners).toHaveLength(1) + const source = (h.asideOwners[0] as ChatAsideOwnerProps).endGutter + const published: number[] = [] + const off = source.subscribe(() => { published.push(source.getSnapshot()) }) // Nothing is known until both widths arrive. deliver([layer, 1600.4]) - expect(h.asideOwners.at(-1)).toEqual({ endGutter: 0 }) + expect(source.getSnapshot()).toBe(0) deliver([column, 760]) - expect(h.asideOwners.at(-1)).toEqual({ endGutter: 420 }) + expect(source.getSnapshot()).toBe(420) deliver([column, 880]) - expect(h.asideOwners.at(-1)).toEqual({ endGutter: 360 }) - // Height-only growth reports the same widths and keeps the owner identity. - const owner = h.asideOwners.at(-1) + expect(source.getSnapshot()).toBe(360) + // Height-only growth reports the same widths and publishes nothing. deliver([column, 880]) - expect(h.asideOwners.at(-1)).toBe(owner) deliver([layer, 700]) - expect(h.asideOwners.at(-1)).toEqual({ endGutter: 0 }) + expect(source.getSnapshot()).toBe(0) + expect(published).toEqual([420, 360, 0]) + off() expect(rect).not.toHaveBeenCalled() - // Transcript updates do not re-render the aside. - const settled = h.asideOwners.length + // Neither resizes nor transcript updates re-render the aside. act(() => { h.setSession({ running: true }) }) - expect(h.asideOwners).toHaveLength(settled) + expect(h.asideOwners).toHaveLength(1) }) it('keeps the aside gutter at zero without ResizeObserver', () => { vi.stubGlobal('ResizeObserver', undefined) const h = makeHarness({}, {}, chatSnapshotFixture({ nodes: [user(1, 'hello')] })) render() - expect(h.asideOwners.at(-1)).toEqual({ endGutter: 0 }) + expect((h.asideOwners.at(-1) as ChatAsideOwnerProps).endGutter.getSnapshot()).toBe(0) }) it('renders only referenced Nodes without deleting unreferenced Node data', () => { diff --git a/packages/client/ui-primitives/README.i18n.yaml b/packages/client/ui-primitives/README.i18n.yaml index b193be7fe8..0e8e2b7041 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: d96304d5e7dadc20 - zh: 16e9c75a7356f2b4 + en: 63b4c333dfc5e71d + zh: cf68909712014233 /deepseek-ai-dsh-client-ui-primitives/use-this-package/controls-and-icons: en: 8265fa792c6fd9ec zh: 600d2af4d5a3d183 diff --git a/packages/client/ui-primitives/README.md b/packages/client/ui-primitives/README.md index a789c3c6d6..8d7eabbb41 100644 --- a/packages/client/ui-primitives/README.md +++ b/packages/client/ui-primitives/README.md @@ -55,7 +55,6 @@ 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. `menu` holds row actions, such as a More button, after the trailing area in a 16px column whose center sits 14px from the row's end; a plain `button` there gets a 24px target and a tertiary glyph that darkens on hover without a fill, so it needs no tooltip of its own. 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, and `actionLabel` names that button when its content does not describe the action, starting with the visible text; a row with an action or row actions fills as a whole on hover and while one of its menus is open. `detail` adds a second line in smaller tertiary type that clips with an ellipsis, such as the consequence of a status or a command to run; the icon stays beside the first line and the trailing area and menu center on the row. Other attributes, such as context-menu trigger props, reach the outer element. | | `MarqueeText`, `useHoverMarquee` | Single-line text that clips with an ellipsis at rest, and the row handlers that marquee it: entering the row crawls a clipped text at 30px/s to its far edge and holds it there, fading the edges that still hide text; leaving returns it to the start at once. Overflow of at most 8px, touch pointers, and text that fits stay put; reduced motion jumps to the far edge. | | `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. | diff --git a/packages/client/ui-primitives/README.zh.md b/packages/client/ui-primitives/README.zh.md index 2aa10897bc..c7523d6437 100644 --- a/packages/client/ui-primitives/README.zh.md +++ b/packages/client/ui-primitives/README.zh.md @@ -55,7 +55,6 @@ kind: "package-library" | `SegmentedTabs` | 受控的等宽分段标签,支持滑动指示条及左/右方向键、Home、End 导航。调用方提供文案、标签与面板 id,以及面板内容。默认 `size="md"` 总高 42px、内边距 4px;`size="sm"` 总高 34px、内边距 2px。 | | `Tag` | 只读胶囊徽章;`tone` 选择八种配色之一。 | | `PathLabel` | 单行文件路径:目录使用弱化颜色,文件名使用主色,悬停可查看完整路径。空间足够时靠左显示;溢出时保留尾部并在左侧渐隐,路径或尺寸变化时更新。 | -| `PanelRow` | 摘要面板中的一行事实:16px 装饰图标、单行内容(溢出时以省略号截断)以及可选的尾部数值或控件。图标沿用行文字颜色。`menu` 放在尾部区域之后的行操作(例如「更多」按钮),位于 16px 宽的一列,中心距行末端 14px;其中的普通 `button` 有 24px 点击区和三级文字色图标,悬停时图标变深、没有底色,因此不需要自己的 tooltip。鼠标悬停在行上、焦点在行内或其菜单打开时显示,没有悬停能力的设备上始终显示。传入 `onActivate` 时整行成为一个按钮,尾部区域与 `menu` 仍是各自独立的控件,内容不足以说明操作时用 `actionLabel` 为该按钮命名,并以可见文字开头;带操作或行操作的行在悬停时以及菜单打开期间整行填充。`detail` 在内容下方加一行更小的浅灰文字,溢出时以省略号截断,例如某个状态的后果或要运行的命令;图标留在第一行旁边,尾部区域和菜单在整行中垂直居中。其余属性(例如右键菜单触发属性)落在外层元素上。 | | `MarqueeText`、`useHoverMarquee` | 静止时以省略号截断的单行文字,以及让它滚动显示的行处理函数:指针进入行时,被截断的文字以 30px/s 匀速滚到末尾并停在那里,仍有文字被遮住的边缘渐隐;离开时立即回到开头。溢出不超过 8px、触摸指针以及放得下的文字都不滚动;减少动态效果时直接跳到末尾。 | | `StateDot` | 10px 槽内的绿色 `done`、琥珀色 `warning`、红色 `error`、中性灰色 `idle` 圆点,以及 tertiary 灰色 14px 旋转 `ongoing` loading,其动画在挂载时以及每次动画重启(如列表重排)时固定到文档时间零点,所以所有可见 loading 同相旋转。它是 `aria-hidden` 的,名称由渲染点提供。 `appearance="step"` 以实心勾表示完成、空心圆表示等待。 | | `ConnectionIndicator` | 行内连接恢复控件,覆盖断线、重试与已恢复三种状态。 | diff --git a/packages/client/ui-primitives/src/index.ts b/packages/client/ui-primitives/src/index.ts index 4ac4a0ff75..479f6ef961 100644 --- a/packages/client/ui-primitives/src/index.ts +++ b/packages/client/ui-primitives/src/index.ts @@ -26,8 +26,6 @@ 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 { MarqueeText, useHoverMarquee } from './Marquee.tsx' export { HoverDetails } from './HoverDetails.tsx' export type { HoverDetailsProps } from './HoverDetails.tsx' diff --git a/packages/client/ui-session-panel/README.i18n.yaml b/packages/client/ui-session-panel/README.i18n.yaml index c008a7d3d1..426e5260e6 100644 --- a/packages/client/ui-session-panel/README.i18n.yaml +++ b/packages/client/ui-session-panel/README.i18n.yaml @@ -21,14 +21,14 @@ en: 77c0fdde17b1d115 zh: 73edb33c88e8e464 /deepseek-ai-dsh-client-ui-session-panel/use-this-package/contribute-a-section: - en: 99599996872b9193 - zh: 430988f01adb40fe + en: d9be9db35539e9b4 + zh: c2597c59f94d594e /deepseek-ai-dsh-client-ui-session-panel/understand-the-implementation: - en: f996b40c78ce18ba - zh: d66ed6289f8eed50 + en: 645f3b40eaa5bd33 + zh: df16d5d3f25e1686 /deepseek-ai-dsh-client-ui-session-panel/further-exploration: - en: 5fa707ada69696c4 - zh: 595d8b2d7de42181 + en: 199265f8d5f900b5 + zh: 6023b70acb15184e /deepseek-ai-dsh-client-ui-session-panel/model-experience: en: 7e8bbe318a76fd54 zh: c60e87da2a37642a diff --git a/packages/client/ui-session-panel/README.md b/packages/client/ui-session-panel/README.md index 282b43ab7a..fc634b6f5a 100644 --- a/packages/client/ui-session-panel/README.md +++ b/packages/client/ui-session-panel/README.md @@ -44,7 +44,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 is one element: the toggle sizes it to a 6px dot at the glyph's corner, and the occupant sets its `background` and includes text that names it, which becomes part of the toggle's accessible name. Occupants overlap, and a higher `order` paints above a lower one. The `panelShown` owner prop lets a mark that only repeats the panel's content render nothing while the panel shows. Subagents and Background jobs show a blue dot while work runs and the panel does not show (orders 10 and 20); the forge bundle's red attention dot (order 100) paints above them and stays while the panel shows. -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. +The plugin offers its row as the `conversation.session.panel.row` Component Factory. Sections and Environment rows from every package render their rows with `renderFactorySlot('conversation.session.panel.row', props)`, so icon, text, and trailing areas line up across sections. A row has a 16px decorative icon that inherits the row ink, single-line content that clips with an ellipsis, and an optional trailing value or control. `menu` holds row actions, such as a More button, after the trailing area in a 16px column whose center sits 14px from the row's end; a plain `button` there gets a 24px target and a tertiary glyph that darkens on hover without a fill, so it needs no tooltip of its own. 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, and `actionLabel` names that button when its content does not describe the action, starting with the visible text; a row with an action or row actions fills as a whole on hover and while one of its menus is open. `detail` adds a second line in smaller tertiary type that clips with an ellipsis, such as the consequence of a status or a command to run; the icon stays beside the first line and the trailing area and menu center on the row. `className` adds to the row's class, and `attributes`, such as `role`, `data-*` markers, and context-menu trigger props, reach the row element; other props are ignored. ----- @@ -54,18 +54,19 @@ Summary rows from every package use the `PanelRow` primitive, so icon, text, and
Implementation internals — click to expand -The panel is the `conversation.chat.aside` occupant of [`dsh-client-ui-chat`](../ui-chat/README.md#scroll-ownership), so it renders only in Chat Views. The toggle and the panel are separate Slot entries that share one plugin-owned state: the persisted docking preference, the Session whose overlay is open, and the end gutter each mounted panel reports from its `endGutter` owner prop. A panel withdraws its report when it unmounts or its Chat View moves to another Session. The panel decides its presentation from its own gutter; the toggle reads the widest gutter of its Session, and a Session without one shows no Chat View. Both decide with the same pure function, so the toggle's state never disagrees with the panel. The aside layer inherits the scrollport's composer and viewport heights, and the docked width follows the gutter through `--dsh-session-panel-gutter`. +The panel is the `conversation.chat.aside` occupant of [`dsh-client-ui-chat`](../ui-chat/README.md#scroll-ownership), so it renders only in Chat Views. The toggle and the panel are separate Slot entries that share one plugin-owned state: the persisted docking preference, the Session whose overlay is open, and whether each Session has room to dock. Each mounted panel registers the `endGutter` source of its Chat View with that state, and stops when it unmounts or its Chat View moves to another Session; a Session has room while any of its sources holds the docked panel, and a Session without a source shows no Chat View. The panel decides its presentation from its own source, and both decide with the same pure function, so the toggle's state never disagrees with the panel. The panel and the toggle subscribe only to whether the gutter holds the docked panel, so a resize renders them again only when it crosses the 344px threshold, and opening, closing, or docking the panel renders nothing in the Chat View. The aside layer inherits the scrollport's composer and viewport heights and the transcript width `--dsh-chat-content-width`, from which CSS sizes the docked panel. 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/index.ts`](src/client/index.ts) | Dictionaries, the row Factory, 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, the shared visibility state, and the reported gutters | +| [`src/client/visibility.ts`](src/client/visibility.ts) | Docking threshold, presentation, the shared visibility state, and each Session's room to dock | | [`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/PanelRow.tsx`](src/client/PanelRow.tsx) | The panel row behind the `conversation.session.panel.row` Factory | | [`src/client/ProjectRow.tsx`](src/client/ProjectRow.tsx) | The working folder row |
@@ -76,9 +77,9 @@ The panel projects the section list's live registrations (`entriesOfSlot`, so a ## Further Exploration - [Web Client Slots](../../../docs/subsystems/slots.md) — list, keyed, and owner-prop semantics the sections rely on. -- [`dsh-client-ui-chat`](../ui-chat/README.md#scroll-ownership) — the `conversation.chat.aside` layer and its end gutter. +- [`dsh-client-ui-chat`](../ui-chat/README.md#scroll-ownership) — the `conversation.chat.aside` layer and its end gutter source. - [`dsh-client-ui-conversation`](../ui-conversation/README.md) — the Session header utilities. -- [`dsh-client-ui-primitives`](../ui-primitives/README.md#component-catalog) — `PanelRow` and `PathLabel`. +- [`dsh-client-ui-primitives`](../ui-primitives/README.md#component-catalog) — `Button`, `Tooltip`, the icons, and the modal and composition guards. ----- diff --git a/packages/client/ui-session-panel/README.zh.md b/packages/client/ui-session-panel/README.zh.md index 6cf9349485..d5d19bd332 100644 --- a/packages/client/ui-session-panel/README.zh.md +++ b/packages/client/ui-session-panel/README.zh.md @@ -44,7 +44,7 @@ kind: "package-reference" 面板隐藏时也要可见的标记(例如提示需要处理的圆点)放进 `conversation.session.panel.indicator` 列表。每个占位是一个元素:开关把它定为图标角上的 6px 圆点,占位负责设置 `background`,并带有说明自身的文字,这些文字会成为开关无障碍名称的一部分。占位会重叠,`order` 高的画在低的上方。owner 属性 `panelShown` 让只是重复面板内容的标记在面板显示时不渲染。「子智能体」与「后台任务」在任务运行且面板未显示时显示蓝点(order 10 和 20);forge 套件的红色提醒点(order 100)画在它们上方,面板显示时也保留。 -各包的摘要行都使用 `PanelRow` 原语,使不同分栏的图标、文字与尾部区域对齐;行的「更多」按钮放进它的 `menu`,各行就以同样的方式整行高亮并显示操作。 +插件把面板的行作为 Component Factory `conversation.session.panel.row` 提供。各包的分栏与环境行都用 `renderFactorySlot('conversation.session.panel.row', props)` 渲染自己的行,使不同分栏的图标、文字与尾部区域对齐。每行有一个沿用行文字颜色的 16px 装饰图标、单行内容(溢出时以省略号截断),以及可选的尾部数值或控件。`menu` 放在尾部区域之后的行操作(例如「更多」按钮),位于 16px 宽的一列,中心距行末端 14px;其中的普通 `button` 有 24px 点击区和三级文字色图标,悬停时图标变深、没有底色,因此不需要自己的 tooltip。鼠标悬停在行上、焦点在行内或其菜单打开时显示,没有悬停能力的设备上始终显示。传入 `onActivate` 时整行成为一个按钮,尾部区域与 `menu` 仍是各自独立的控件,内容不足以说明操作时用 `actionLabel` 为该按钮命名,并以可见文字开头;带操作或行操作的行在悬停时以及菜单打开期间整行填充。`detail` 在内容下方加一行更小的浅灰文字,溢出时以省略号截断,例如某个状态的后果或要运行的命令;图标留在第一行旁边,尾部区域和菜单在整行中垂直居中。`className` 追加到行的类名上,`attributes`(例如 `role`、`data-*` 标记与右键菜单触发属性)落在行元素上,其余属性被忽略。 ----- @@ -54,18 +54,19 @@ kind: "package-reference"
实现内幕——点击展开 -面板是 [`dsh-client-ui-chat`](../ui-chat/README.zh.md#scroll-ownership) 中 `conversation.chat.aside` 的占位组件,因此只渲染在 Chat 视图中。开关与面板是两个独立的 Slot 条目,共享一份插件持有的状态:持久化的停靠偏好、打开了浮层的会话,以及每个已挂载面板从 owner 属性 `endGutter` 上报的末端留白。面板卸载或其 Chat 视图换到另一个会话时撤回上报。面板根据自己的留白决定呈现方式;开关读取该会话最宽的留白,没有留白的会话表示没有 Chat 视图在显示它。两者用同一个纯函数决定,因此开关状态始终与面板一致。侧边层从滚动容器继承输入框区域与视口高度,停靠宽度通过 `--dsh-session-panel-gutter` 跟随留白。 +面板是 [`dsh-client-ui-chat`](../ui-chat/README.zh.md#scroll-ownership) 中 `conversation.chat.aside` 的占位组件,因此只渲染在 Chat 视图中。开关与面板是两个独立的 Slot 条目,共享一份插件持有的状态:持久化的停靠偏好、打开了浮层的会话,以及每个会话是否有停靠空间。每个已挂载的面板把所在 Chat 视图的 `endGutter` 数据源登记到这份状态里,面板卸载或其 Chat 视图换到另一个会话时取消登记;会话的任一数据源能容纳停靠面板时,该会话就有停靠空间,没有数据源的会话表示没有 Chat 视图在显示它。面板根据自己的数据源决定呈现方式,两者用同一个纯函数决定,因此开关状态始终与面板一致。面板与开关只订阅留白能否容纳停靠面板,因此尺寸变化只在跨过 344px 阈值时才让它们重新渲染;打开、关闭或停靠面板也不会让 Chat 视图重新渲染。侧边层从滚动容器继承输入框区域与视口高度,以及正文宽度 `--dsh-chat-content-width`,停靠宽度由 CSS 据此算出。 面板把分栏列表的实时注册(`entriesOfSlot`,因此同 `id` 且优先级更高的注册会替换已发布的分栏)投影为 `{ id, label }` 行,只在台账版本或语言版本变化时重新计算。它在各分栏自己的标题和正文容器里用 `renderSlot(..., { only: id })` 渲染内容;CSS `:has()` 规则隐藏正文出口为空的分栏,也包括行出口为空的共享分栏。 | 文件 | 作用 | |---|---| -| [`src/client/index.ts`](src/client/index.ts) | 字典、开关、面板、「环境」分栏与项目行 | +| [`src/client/index.ts`](src/client/index.ts) | 字典、行 Factory、开关、面板、「环境」分栏与项目行 | | [`src/client/slots.ts`](src/client/slots.ts) | Slot 声明与组件 props | -| [`src/client/visibility.ts`](src/client/visibility.ts) | 停靠阈值、呈现方式、共享可见性状态与上报的留白 | +| [`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/PanelRow.tsx`](src/client/PanelRow.tsx) | `conversation.session.panel.row` Factory 渲染的面板行 | | [`src/client/ProjectRow.tsx`](src/client/ProjectRow.tsx) | 工作目录行 |
@@ -76,9 +77,9 @@ kind: "package-reference" ## 进一步探索 - [Web Client Slots](../../../docs/subsystems/slots.zh.md)——分栏依赖的 list、keyed 与 owner props 语义。 -- [`dsh-client-ui-chat`](../ui-chat/README.zh.md#scroll-ownership)——`conversation.chat.aside` 图层及其末端留白。 +- [`dsh-client-ui-chat`](../ui-chat/README.zh.md#scroll-ownership)——`conversation.chat.aside` 图层及其末端留白数据源。 - [`dsh-client-ui-conversation`](../ui-conversation/README.zh.md)——会话标题栏工具区。 -- [`dsh-client-ui-primitives`](../ui-primitives/README.zh.md#component-catalog)——`PanelRow` 与 `PathLabel`。 +- [`dsh-client-ui-primitives`](../ui-primitives/README.zh.md#component-catalog)——`Button`、`Tooltip`、图标,以及模态层与输入法组合的判断。 ----- diff --git a/packages/client/ui-primitives/src/PanelRow.module.css b/packages/client/ui-session-panel/src/client/PanelRow.module.css similarity index 98% rename from packages/client/ui-primitives/src/PanelRow.module.css rename to packages/client/ui-session-panel/src/client/PanelRow.module.css index ef945c1e02..400c777878 100644 --- a/packages/client/ui-primitives/src/PanelRow.module.css +++ b/packages/client/ui-session-panel/src/client/PanelRow.module.css @@ -1,4 +1,4 @@ -/* One summary-panel fact: [16px icon] gap 8 [content 13/28] [trailing] [menu]. +/* One Session 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. The diff --git a/packages/client/ui-primitives/src/PanelRow.tsx b/packages/client/ui-session-panel/src/client/PanelRow.tsx similarity index 70% rename from packages/client/ui-primitives/src/PanelRow.tsx rename to packages/client/ui-session-panel/src/client/PanelRow.tsx index 0bf043313b..74caea0069 100644 --- a/packages/client/ui-primitives/src/PanelRow.tsx +++ b/packages/client/ui-session-panel/src/client/PanelRow.tsx @@ -1,12 +1,20 @@ -// PanelRow: one icon-led fact row of a summary panel, shared by every -// contributor so rows from different packages keep one geometry. +/** + * One icon-led fact row of the Session panel. The plugin offers it as the + * `conversation.session.panel.row` Component Factory, so rows that other + * packages contribute 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'> { +/** Attributes of the row element, such as `role`, `data-*` markers, and a context-menu trigger's handlers. */ +export type PanelRowAttributes = + Omit, 'children' | 'className' | 'onClick'> + & { readonly [marker: `data-${string}`]: string | undefined } + +/** Props of one Session panel row. */ +export interface PanelRowProps { /** Leading 16px glyph; decorative, so the row text carries the meaning. */ readonly icon: ReactNode /** Primary single-line content; overflow clips with an ellipsis. */ @@ -32,16 +40,24 @@ export interface PanelRowProps extends Omit, 'childr * the menu centered on the row. */ readonly detail?: ReactNode + /** Class of the row element, added to the row's own. */ + readonly className?: string | undefined + /** Attributes of the row element; the row keeps its own class and `data-panel-row`. */ + readonly attributes?: PanelRowAttributes | undefined } /** - * Render one summary-panel row: icon, single-line content, an optional + * Render one Session 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. + * Props outside {@link PanelRowProps}, such as the ones a Factory occurrence + * adds, are ignored. + * @param props - row content, the optional action and row actions, and attributes for the row element. * @returns the row element. */ -export function PanelRow({ icon, children, trailing, menu, onActivate, actionLabel, detail, className, ...attributes }: PanelRowProps) { +export function PanelRow({ + icon, children, trailing, menu, onActivate, actionLabel, detail, className, attributes, +}: PanelRowProps): ReactNode { const body = ( <> diff --git a/packages/client/ui-session-panel/src/client/ProjectRow.tsx b/packages/client/ui-session-panel/src/client/ProjectRow.tsx index 6e3dd45b18..add253e0da 100644 --- a/packages/client/ui-session-panel/src/client/ProjectRow.tsx +++ b/packages/client/ui-session-panel/src/client/ProjectRow.tsx @@ -1,8 +1,9 @@ /** Environment row naming the Session's working folder. */ import type { ReactNode } from 'react' -import { IconFolderCloseRegular, PanelRow, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives' +import { IconFolderCloseRegular, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives' import { abbreviateHomePath, pathPartsOf } from '@deepseek-ai/dsh-util-workspace-path' import type {} from '@deepseek-ai/dsh-working-directory/types' +import { PanelRow } from './PanelRow.tsx' import type { ProjectRowProps } from './slots.ts' import css from './ProjectRow.module.css' @@ -34,10 +35,9 @@ export function ProjectRow({ const target = { kind: 'directory', value: { sessionId, path } } as const return ( } menu={renderFactorySlot('contextMenu.button', { target, label: t('project.actions') })} - data-session-panel-project="" + attributes={{ ...getTriggerProps(target), '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 index 69655e3ea6..c54051e831 100644 --- a/packages/client/ui-session-panel/src/client/SessionPanel.module.css +++ b/packages/client/ui-session-panel/src/client/SessionPanel.module.css @@ -1,15 +1,16 @@ -/* The panel floats in the Chat View's aside layer, a zero-height box at the - top of the Chat frame that passes pointer events through. The layer +/* The panel floats in the Chat View's aside layer, a zero-height box across + the top of the Chat frame that passes pointer events through. The layer inherits the scrollport's --dsh-conversation-viewport-height and - --dsh-composer-height; the panel receives the Chat View's end gutter as - --dsh-session-panel-gutter. */ + --dsh-composer-height, and the transcript width --dsh-chat-content-width, + so the end gutter is half the layer width the transcript leaves. */ .panel { position: absolute; top: 12px; right: 16px; box-sizing: border-box; - /* The docked width keeps 48px clear of the transcript column and its width handle. */ - width: clamp(280px, calc(var(--dsh-session-panel-gutter, 0px) - 64px), 340px); + /* The docked width keeps 48px clear of the transcript column and its width handle, + as the back-to-bottom control computes the same gutter. */ + width: clamp(280px, calc((100% - var(--dsh-chat-content-width, 100%)) / 2 - 64px), 340px); /* Stops above the composer stack, whose seat fades and takes presses across the body's full width. */ max-height: calc(var(--dsh-conversation-viewport-height, 100dvh) - var(--dsh-composer-height, 152px) - 24px); overflow-y: auto; diff --git a/packages/client/ui-session-panel/src/client/SessionPanel.tsx b/packages/client/ui-session-panel/src/client/SessionPanel.tsx index 6061155c7f..93000a6266 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 in the Chat View's aside: section titles drawn from the section roster, bodies from the section slot. */ import { - useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, type CSSProperties, type FocusEvent, type ReactNode, + useCallback, useEffect, useLayoutEffect, useMemo, useRef, useSyncExternalStore, type FocusEvent, type ReactNode, } from 'react' import { isBehindModal, observeComposition } from '@deepseek-ai/dsh-client-ui-primitives' import { panelElementId, toggleElementId } from './element-ids.ts' @@ -75,33 +75,23 @@ function useFocusReturn(hidden: boolean, toggleId: string): { }), []) } -/** - * Report the Chat View's end gutter for this panel while it is mounted, and - * withdraw it when the panel unmounts or its Chat View moves to another - * Session. A changed gutter replaces the report without withdrawing it. - * @param measure - records one panel's gutter. - * @param sessionId - Session the Chat View shows. - * @param endGutter - the Chat View's end gutter in CSS px. - */ -function useGutterReport(measure: SessionPanelProps['measure'], sessionId: SessionPanelProps['sessionId'], endGutter: number): void { - const instance = useId() - useLayoutEffect(() => () => { measure(sessionId, instance, null) }, [measure, sessionId, instance]) - useLayoutEffect(() => { measure(sessionId, instance, endGutter) }, [measure, sessionId, instance, endGutter]) -} - /** * 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. The docked - * width follows the Chat View's end gutter. - * @param props - Session values, the Chat View's end gutter, shared visibility, sections, the gutter report, and copy. + * The overlay closes on Escape and on an outside pointerdown. CSS sizes the + * docked panel from the transcript width; the gutter source decides only + * whether it can dock, so a resize re-renders the panel only when it crosses + * the docking threshold. + * @param props - Session values, the Chat View's end gutter source, shared visibility, sections, the gutter tracking, and copy. * @returns the panel, or null while it is hidden. */ export function SessionPanel({ - sessionId, endGutter, useVisibility, useSections, measure, closeOverlay, renderSlot, t, + sessionId, endGutter, useVisibility, useSections, track, closeOverlay, renderSlot, t, }: SessionPanelProps): ReactNode { - useGutterReport(measure, sessionId, endGutter) - const fits = fitsGutter(endGutter) + // Registered before paint, so a Chat View remount keeps the header toggle available instead of flashing unavailable. + useLayoutEffect(() => track(sessionId, endGutter), [track, sessionId, endGutter]) + const followGutter = useCallback((listener: () => void) => endGutter.subscribe(listener), [endGutter]) + const fits = useSyncExternalStore(followGutter, () => fitsGutter(endGutter.getSnapshot())) const presentation = useVisibility(visibility => presentationOf(fits, visibility, sessionId)) const sections = useSections(entries => entries) const panel = useRef(null) @@ -117,7 +107,6 @@ export function SessionPanel({