Merge branch 'feat/session-panel' into feat/session-panel-sections
PanelRow moved from ui-primitives into ui-session-panel as the conversation.session.panel.row Factory, so the detail line and actionLabel this branch added move with it, and the forge checkout, connection, local changes, and sign-in rows render through renderFactorySlot with their row attributes in the attributes prop.
This commit is contained in:
commit
e7dfa74ac0
32 files changed
+521
-378
No files matched your search
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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 头栏和展开的压缩摘要头栏仍以实际会话滚动容器为参照。限高过程组和终端区域保留各自的滚动容器。
|
||||
|
||||
|
||||
@@ -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<HTMLElement>): number {
|
||||
const [gutter, setGutter] = useState(0)
|
||||
function useEndGutter(layer: RefObject<HTMLElement>): ObservableSnapshot<number> {
|
||||
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<HTMLElement>): 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.
|
||||
*/
|
||||
|
||||
@@ -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<number>
|
||||
}
|
||||
|
||||
/** 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 }
|
||||
|
||||
|
||||
@@ -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(<h.ChatView {...h.props} />)
|
||||
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', () => {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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. |
|
||||
|
||||
@@ -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` | 行内连接恢复控件,覆盖断线、重试与已恢复三种状态。 |
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
<details>
|
||||
<summary>Implementation internals — click to expand</summary>
|
||||
|
||||
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 |
|
||||
|
||||
</details>
|
||||
@@ -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.
|
||||
|
||||
-----
|
||||
|
||||
|
||||
@@ -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"
|
||||
<details>
|
||||
<summary>实现内幕——点击展开</summary>
|
||||
|
||||
面板是 [`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) | 工作目录行 |
|
||||
|
||||
</details>
|
||||
@@ -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`、图标,以及模态层与输入法组合的判断。
|
||||
|
||||
-----
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
+23
-7
@@ -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<HTMLAttributes<HTMLElement>, 'children' | 'onClick'> {
|
||||
/** Attributes of the row element, such as `role`, `data-*` markers, and a context-menu trigger's handlers. */
|
||||
export type PanelRowAttributes =
|
||||
Omit<HTMLAttributes<HTMLElement>, '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<HTMLAttributes<HTMLElement>, '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 = (
|
||||
<>
|
||||
<span className={css.icon} aria-hidden="true">{icon}</span>
|
||||
@@ -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 (
|
||||
<PanelRow
|
||||
{...getTriggerProps(target)}
|
||||
icon={<IconFolderCloseRegular size={16} />}
|
||||
menu={renderFactorySlot('contextMenu.button', { target, label: t('project.actions') })}
|
||||
data-session-panel-project=""
|
||||
attributes={{ ...getTriggerProps(target), 'data-session-panel-project': '' }}
|
||||
>
|
||||
<Tooltip label={`${t('project.label')}\n${shown}`} side="left" delayMs={500}>
|
||||
<span className={css.folder} tabIndex={0}>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<HTMLElement>(null)
|
||||
@@ -117,7 +107,6 @@ export function SessionPanel({
|
||||
<aside
|
||||
id={panelElementId(sessionId)}
|
||||
className={css.panel}
|
||||
style={{ '--dsh-session-panel-gutter': `${endGutter}px` } as CSSProperties}
|
||||
aria-label={t('panel.name')}
|
||||
ref={panel}
|
||||
onFocus={focus.onFocus}
|
||||
|
||||
@@ -3,7 +3,7 @@ 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 { fitsGutter, presentationOf } from './visibility.ts'
|
||||
import { presentationOf } from './visibility.ts'
|
||||
import css from './SessionPanelToggle.module.css'
|
||||
|
||||
/**
|
||||
@@ -11,16 +11,15 @@ import css from './SessionPanelToggle.module.css'
|
||||
* text of any indicator; the expanded state says whether the panel shows.
|
||||
* While no Chat View shows the Session, as in the trajectory View, the panel
|
||||
* has no place to show: the toggle is unavailable and its tooltip says so.
|
||||
* @param props - Session values, the Chat View gutters, shared visibility, the toggle action, and copy.
|
||||
* @param props - Session values, the room to dock, shared visibility, the toggle action, and copy.
|
||||
* @returns the header entry.
|
||||
*/
|
||||
export function SessionPanelToggle({
|
||||
sessionId, useGutters, useVisibility, toggle, renderSlot, t,
|
||||
sessionId, useDockable, useVisibility, toggle, renderSlot, t,
|
||||
}: SessionPanelToggleProps): ReactNode {
|
||||
const gutter = useGutters(gutters => gutters.get(sessionId))
|
||||
const fits = gutter !== undefined && fitsGutter(gutter)
|
||||
const shown = useVisibility(visibility => presentationOf(fits, visibility, sessionId) !== 'hidden')
|
||||
const available = gutter !== undefined
|
||||
const dockable = useDockable(entries => entries.get(sessionId))
|
||||
const shown = useVisibility(visibility => presentationOf(dockable === true, visibility, sessionId) !== 'hidden')
|
||||
const available = dockable !== undefined
|
||||
const open = available && shown
|
||||
const label = available ? t(open ? 'toggle.hide' : 'toggle.show') : t('toggle.unavailable')
|
||||
return (
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/**
|
||||
* Session panel plugin, browser half: a Session header toggle and a floating
|
||||
* panel in the Chat View's aside. The panel draws the titles of the sections
|
||||
* other plugins register and ships the Environment section with the working
|
||||
* other plugins register, offers the row Component Factory those sections
|
||||
* render their rows with, and ships the Environment section with the working
|
||||
* folder row.
|
||||
*/
|
||||
import type { Context as ClientContext } from '@deepseek-ai/cordis'
|
||||
@@ -13,6 +14,7 @@ import type {} from '@deepseek-ai/dsh-client-connection/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 { PanelRow } from './PanelRow.tsx'
|
||||
import { ProjectRow } from './ProjectRow.tsx'
|
||||
import { SessionPanel } from './SessionPanel.tsx'
|
||||
import { SessionPanelToggle } from './SessionPanelToggle.tsx'
|
||||
@@ -28,8 +30,9 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
||||
}
|
||||
}
|
||||
|
||||
export type { PanelRowAttributes, PanelRowProps } from './PanelRow.tsx'
|
||||
export type {
|
||||
EnvironmentSectionProps, ProjectRowInjected, ProjectRowProps, SessionPanelGutters, SessionPanelIndicatorOwnerProps, SessionPanelInjected,
|
||||
EnvironmentSectionProps, ProjectRowInjected, ProjectRowProps, SessionPanelDockable, SessionPanelIndicatorOwnerProps, SessionPanelInjected,
|
||||
SessionPanelPresentation, SessionPanelProps, SessionPanelSectionEntry, SessionPanelSectionOwnerProps,
|
||||
SessionPanelToggleInjected, SessionPanelToggleProps, SessionPanelVisibility,
|
||||
} from './slots.ts'
|
||||
@@ -38,8 +41,8 @@ export type {
|
||||
export const inject = ['slots', 'locale', 'remote']
|
||||
|
||||
/**
|
||||
* Client plugin body: register the dictionaries, the header toggle, the panel,
|
||||
* and the Environment section with its project row.
|
||||
* Client plugin body: register the dictionaries, the row Component Factory,
|
||||
* the header toggle, the panel, and the Environment section with its project row.
|
||||
* @param ctx - client root context.
|
||||
*/
|
||||
export function apply(ctx: ClientContext): void {
|
||||
@@ -53,6 +56,8 @@ export function apply(ctx: ClientContext): void {
|
||||
subscribe: listener => ctx.on('connection/reset', listener),
|
||||
}
|
||||
|
||||
ctx.slots.registerFactory({ name: 'conversation.session.panel.row', scope: 'root' }, PanelRow)
|
||||
|
||||
ctx.slots.inject('conversation.session.header.utilities', () => ctx.slots.register({
|
||||
name: 'conversation.session.header.utilities',
|
||||
id: 'session-panel',
|
||||
@@ -63,7 +68,7 @@ export function apply(ctx: ClientContext): void {
|
||||
'conversation.session.panel.indicator': { kind: 'list', scope: 'session', inline: true },
|
||||
},
|
||||
inject: (): SessionPanelToggleInjected => ({
|
||||
hooks: { visibility: state.visibility, gutters: state.gutters },
|
||||
hooks: { visibility: state.visibility, dockable: state.dockable },
|
||||
toggle: (sessionId) => { state.toggle(sessionId) },
|
||||
}),
|
||||
}, SessionPanelToggle))
|
||||
@@ -77,7 +82,7 @@ export function apply(ctx: ClientContext): void {
|
||||
},
|
||||
inject: (): SessionPanelInjected => ({
|
||||
hooks: { visibility: state.visibility, sections },
|
||||
measure: (sessionId, instance, endGutter) => { state.measure(sessionId, instance, endGutter) },
|
||||
track: (sessionId, endGutter) => state.track(sessionId, endGutter),
|
||||
closeOverlay: (sessionId) => { state.closeOverlay(sessionId) },
|
||||
}),
|
||||
}, SessionPanel))
|
||||
|
||||
@@ -10,8 +10,21 @@ import type {} from '@deepseek-ai/dsh-client-ui-chat/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'
|
||||
import type { PanelRowProps } from './PanelRow.tsx'
|
||||
|
||||
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
||||
interface SlotFactoryMap {
|
||||
/**
|
||||
* One icon-led fact row of the Session panel, for the rows that sections
|
||||
* and Environment row entries render: a 16px decorative icon, single-line
|
||||
* content that clips with an ellipsis, an optional trailing area, row
|
||||
* actions that show on hover and focus, and an optional whole-row action.
|
||||
* Rows from every package render through it, so they share one geometry
|
||||
* and the columns the panel aligns to.
|
||||
*/
|
||||
'conversation.session.panel.row': { scope: 'root'; props: PanelRowProps }
|
||||
}
|
||||
|
||||
interface SlotMap {
|
||||
/**
|
||||
* Sections of the Session panel. `id` addresses the section, `order` sorts
|
||||
@@ -83,18 +96,18 @@ export interface SessionPanelVisibility {
|
||||
}
|
||||
|
||||
/**
|
||||
* End gutter of each Session whose Chat View holds a panel, in CSS px; the
|
||||
* widest one when several Chat Views show the Session. A Session without an
|
||||
* entry shows no Chat View.
|
||||
* Whether each Session whose Chat View holds a panel has room to dock it:
|
||||
* true when the end gutter of at least one of its Chat Views holds the docked
|
||||
* panel. A Session without an entry shows no Chat View.
|
||||
*/
|
||||
export type SessionPanelGutters = ReadonlyMap<SessionId, number>
|
||||
export type SessionPanelDockable = ReadonlyMap<SessionId, boolean>
|
||||
|
||||
/** Business face of the header toggle. */
|
||||
export interface SessionPanelToggleInjected {
|
||||
/** Shared visibility and the Chat View gutters; the renderer binds them as `useVisibility` and `useGutters`. */
|
||||
/** Shared visibility and each Session's room to dock; the renderer binds them as `useVisibility` and `useDockable`. */
|
||||
readonly hooks: {
|
||||
readonly visibility: ObservableSnapshot<SessionPanelVisibility>
|
||||
readonly gutters: ObservableSnapshot<SessionPanelGutters>
|
||||
readonly dockable: ObservableSnapshot<SessionPanelDockable>
|
||||
}
|
||||
/**
|
||||
* Show or hide the panel. With room to dock this flips the docking
|
||||
@@ -113,12 +126,13 @@ export interface SessionPanelInjected {
|
||||
readonly sections: ObservableSnapshot<readonly SessionPanelSectionEntry[]>
|
||||
}
|
||||
/**
|
||||
* Record the end gutter of one mounted panel, or that it unmounted.
|
||||
* Follow a mounted panel's Chat View gutter for the Session's room to dock,
|
||||
* which the toggle reads, until the returned disposer runs.
|
||||
* @param sessionId - Session the panel's Chat View shows.
|
||||
* @param instance - identity of the panel within the page.
|
||||
* @param endGutter - the Chat View's end gutter in CSS px; null when the panel unmounts or leaves the Session.
|
||||
* @param endGutter - the Chat View's end gutter source.
|
||||
* @returns stops following the source.
|
||||
*/
|
||||
readonly measure: (sessionId: SessionId, instance: string, endGutter: number | null) => void
|
||||
readonly track: (sessionId: SessionId, endGutter: ObservableSnapshot<number>) => () => void
|
||||
/**
|
||||
* Close the Session's overlay.
|
||||
* @param sessionId - Session whose overlay closes; another Session's overlay stays.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/** Session panel visibility: the persisted docking preference, the transient overlay, the Chat View gutters, and their presentation. */
|
||||
/** Session panel visibility: the persisted docking preference, the transient overlay, each Session's room to dock, and the presentation. */
|
||||
import { createSnapshotStore, type ObservableSnapshot } from '@deepseek-ai/dsh-client-store'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import type { SessionPanelGutters, SessionPanelPresentation, SessionPanelVisibility } from './slots.ts'
|
||||
import type { SessionPanelDockable, SessionPanelPresentation, SessionPanelVisibility } from './slots.ts'
|
||||
|
||||
/** localStorage key of the docking preference. */
|
||||
export const PINNED_STORAGE_KEY = 'dsh.sessionPanel.pinned'
|
||||
@@ -13,7 +13,7 @@ export const PINNED_STORAGE_KEY = 'dsh.sessionPanel.pinned'
|
||||
*/
|
||||
export const DOCK_MIN_GUTTER = 344
|
||||
|
||||
const NO_GUTTERS: SessionPanelGutters = new Map()
|
||||
const NO_ENTRIES: SessionPanelDockable = new Map()
|
||||
|
||||
/**
|
||||
* Whether a Chat View's end gutter can hold the docked panel.
|
||||
@@ -39,19 +39,19 @@ export function presentationOf(
|
||||
}
|
||||
|
||||
/**
|
||||
* Visibility shared by every Session's toggle and panel, and the end gutter
|
||||
* each mounted panel reports from its Chat View. Docking follows one
|
||||
* preference for all Sessions; at most one Session's overlay is open, and it
|
||||
* closes once its Session's gutter can hold the docked panel or no Chat View
|
||||
* shows that Session any longer.
|
||||
* Visibility shared by every Session's toggle and panel, and whether each
|
||||
* Session has room to dock, derived from the end gutters of the Chat Views
|
||||
* whose panels are mounted. Docking follows one preference for all Sessions;
|
||||
* at most one Session's overlay is open, and it closes once its Session has
|
||||
* room to dock or no Chat View shows that Session any longer.
|
||||
*/
|
||||
export class SessionPanelState {
|
||||
// A stored value other than `false` keeps the default: the panel docks.
|
||||
private readonly pinned = createSnapshotStore<unknown>(true, { persist: { name: PINNED_STORAGE_KEY } })
|
||||
private readonly overlay = createSnapshotStore<SessionId | null>(null)
|
||||
private readonly widest = createSnapshotStore<SessionPanelGutters>(NO_GUTTERS)
|
||||
/** Gutter of every mounted panel, by Session and panel instance. */
|
||||
private readonly reports = new Map<SessionId, Map<string, number>>()
|
||||
private readonly room = createSnapshotStore<SessionPanelDockable>(NO_ENTRIES)
|
||||
/** The Chat View gutter source of every mounted panel, by Session; each registration is its own entry. */
|
||||
private readonly sources = new Map<SessionId, Set<{ readonly gutter: ObservableSnapshot<number> }>>()
|
||||
private current: SessionPanelVisibility = { pinned: this.pinned.getSnapshot() !== false, overlay: null }
|
||||
/** Stops following the open overlay's gutter. */
|
||||
private unfollow: () => void = () => {}
|
||||
@@ -74,28 +74,34 @@ export class SessionPanelState {
|
||||
},
|
||||
}
|
||||
|
||||
/** The widest gutter of each Session with a mounted panel; the snapshot keeps its identity until one changes. */
|
||||
readonly gutters: ObservableSnapshot<SessionPanelGutters> = this.widest
|
||||
/**
|
||||
* Whether each Session with a mounted panel has room to dock it. The
|
||||
* snapshot keeps its identity until a Session gains or loses its entry or
|
||||
* crosses the docking threshold, so a resize that stays on one side of the
|
||||
* threshold publishes nothing.
|
||||
*/
|
||||
readonly dockable: ObservableSnapshot<SessionPanelDockable> = this.room
|
||||
|
||||
/**
|
||||
* Record the end gutter of one mounted panel, or that it unmounted.
|
||||
* Follow the Chat View gutter of one mounted panel until the returned
|
||||
* disposer runs; a Session has room to dock while any of its sources does.
|
||||
* @param sessionId - Session the panel's Chat View shows.
|
||||
* @param instance - identity of the panel within the page.
|
||||
* @param endGutter - the gutter in CSS px, or null when the panel unmounts or leaves the Session.
|
||||
* @param gutter - the Chat View's end gutter source.
|
||||
* @returns stops following the source.
|
||||
*/
|
||||
measure(sessionId: SessionId, instance: string, endGutter: number | null): void {
|
||||
const panels = this.reports.get(sessionId) ?? new Map<string, number>()
|
||||
if (endGutter === null) panels.delete(instance)
|
||||
else panels.set(instance, endGutter)
|
||||
if (panels.size === 0) this.reports.delete(sessionId)
|
||||
else this.reports.set(sessionId, panels)
|
||||
const widest = panels.size === 0 ? undefined : Math.max(...panels.values())
|
||||
const gutters = this.widest.getSnapshot()
|
||||
if (gutters.get(sessionId) === widest) return
|
||||
const next = new Map(gutters)
|
||||
if (widest === undefined) next.delete(sessionId)
|
||||
else next.set(sessionId, widest)
|
||||
this.widest.set(next)
|
||||
track(sessionId: SessionId, gutter: ObservableSnapshot<number>): () => void {
|
||||
const entry = { gutter }
|
||||
const sources = this.sources.get(sessionId) ?? new Set()
|
||||
sources.add(entry)
|
||||
this.sources.set(sessionId, sources)
|
||||
const off = gutter.subscribe(() => { this.publish(sessionId) })
|
||||
this.publish(sessionId)
|
||||
return () => {
|
||||
off()
|
||||
sources.delete(entry)
|
||||
if (sources.size === 0) this.sources.delete(sessionId)
|
||||
this.publish(sessionId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,9 +111,9 @@ export class SessionPanelState {
|
||||
* @param sessionId - Session whose header holds the toggle.
|
||||
*/
|
||||
toggle(sessionId: SessionId): void {
|
||||
const gutter = this.widest.getSnapshot().get(sessionId)
|
||||
if (gutter === undefined) return
|
||||
if (fitsGutter(gutter)) {
|
||||
const dockable = this.room.getSnapshot().get(sessionId)
|
||||
if (dockable === undefined) return
|
||||
if (dockable) {
|
||||
this.pinned.set(!this.visibility.getSnapshot().pinned)
|
||||
this.setOverlay(null)
|
||||
return
|
||||
@@ -134,9 +140,20 @@ export class SessionPanelState {
|
||||
this.overlay.set(sessionId)
|
||||
if (sessionId === null) return
|
||||
const check = (): void => {
|
||||
const gutter = this.widest.getSnapshot().get(sessionId)
|
||||
if (gutter === undefined || fitsGutter(gutter)) this.closeOverlay(sessionId)
|
||||
if (this.room.getSnapshot().get(sessionId) !== false) this.closeOverlay(sessionId)
|
||||
}
|
||||
this.unfollow = this.widest.subscribe(check)
|
||||
this.unfollow = this.room.subscribe(check)
|
||||
}
|
||||
|
||||
/** Recompute one Session's room to dock from its sources, publishing only a changed entry. */
|
||||
private publish(sessionId: SessionId): void {
|
||||
const sources = this.sources.get(sessionId)
|
||||
const dockable = sources === undefined ? undefined : [...sources].some(source => fitsGutter(source.gutter.getSnapshot()))
|
||||
const room = this.room.getSnapshot()
|
||||
if (room.get(sessionId) === dockable) return
|
||||
const next = new Map(room)
|
||||
if (dockable === undefined) next.delete(sessionId)
|
||||
else next.set(sessionId, dockable)
|
||||
this.room.set(next)
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,9 @@ describe('ui-session-panel browser half', () => {
|
||||
expect(inject).toEqual(['slots', 'locale', 'remote'])
|
||||
})
|
||||
|
||||
it('registers the toggle first among the header utilities, the panel in the Chat aside, the Environment section, and the project row', async () => {
|
||||
it('registers the row Factory, the toggle first among the header utilities, the panel in the Chat aside, the Environment section, and the project row', async () => {
|
||||
const { ctx } = await bench()
|
||||
expect(ctx.slots.snapshot('factory:conversation.session.panel.row')).toHaveLength(1)
|
||||
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.chat.aside')).toHaveLength(1)
|
||||
@@ -67,21 +68,21 @@ describe('ui-session-panel browser half', () => {
|
||||
expect(ctx.slots.entries('conversation.session.panel.environment.row').map(entry => entry.options.id)).toEqual(['project'])
|
||||
})
|
||||
|
||||
it('hands the toggle the gutters the panel reports, and both the shared visibility', async () => {
|
||||
it('hands the toggle the room to dock the panel tracks, and both the shared visibility', async () => {
|
||||
const { ctx, fiber } = await bench()
|
||||
const toggle = faceOf(ctx, 'conversation.session.header.utilities', 'session-panel') as SessionPanelToggleInjected
|
||||
const panel = faceOf(ctx, 'conversation.chat.aside', undefined) as SessionPanelInjected
|
||||
expect(toggle.hooks.visibility).toBe(panel.hooks.visibility)
|
||||
panel.measure(SID, 'main', 300)
|
||||
expect(toggle.hooks.gutters.getSnapshot().get(SID)).toBe(300)
|
||||
const stop = panel.track(SID, createSnapshotStore(300))
|
||||
expect(toggle.hooks.dockable.getSnapshot().get(SID)).toBe(false)
|
||||
toggle.toggle(SID)
|
||||
expect(panel.hooks.visibility.getSnapshot()).toEqual({ pinned: true, overlay: SID })
|
||||
panel.closeOverlay(SID)
|
||||
expect(panel.hooks.visibility.getSnapshot().overlay).toBeNull()
|
||||
toggle.toggle(SID)
|
||||
// Disposing the plugin stops the open overlay from following the gutters.
|
||||
// Disposing the plugin stops the open overlay from following the room to dock.
|
||||
await fiber.dispose()
|
||||
panel.measure(SID, 'main', null)
|
||||
stop()
|
||||
expect(panel.hooks.visibility.getSnapshot().overlay).toBe(SID)
|
||||
})
|
||||
|
||||
@@ -124,6 +125,7 @@ describe('ui-session-panel browser half', () => {
|
||||
it('removes every contribution with the fiber (HMR safety)', async () => {
|
||||
const { ctx, fiber } = await bench()
|
||||
await fiber.dispose()
|
||||
expect(ctx.slots.snapshot('factory:conversation.session.panel.row')).toHaveLength(0)
|
||||
expect(ctx.slots.entries('conversation.session.header.utilities')).toHaveLength(0)
|
||||
expect(ctx.slots.entries('conversation.chat.aside')).toHaveLength(0)
|
||||
expect(ctx.slots.entries('conversation.session.panel.section')).toHaveLength(0)
|
||||
|
||||
@@ -5,12 +5,13 @@ import { useRef, type ReactNode } from 'react'
|
||||
import { useModalLayer } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import { contextMenuHook, makeTranslate } from '@deepseek-ai/dsh-client-test-runtime'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'
|
||||
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, SessionPanelGutters, SessionPanelProps, SessionPanelSectionEntry,
|
||||
EnvironmentSectionProps, ProjectRowProps, SessionPanelDockable, SessionPanelProps, SessionPanelSectionEntry,
|
||||
SessionPanelSectionOwnerProps, SessionPanelToggleProps, SessionPanelVisibility,
|
||||
} from '../src/client/slots.ts'
|
||||
import { DOCK_MIN_GUTTER } from '../src/client/visibility.ts'
|
||||
@@ -52,17 +53,17 @@ function tooltipAfterHover(anchor: Element): { readonly early: boolean; readonly
|
||||
}
|
||||
|
||||
describe('SessionPanelToggle', () => {
|
||||
function toggleProps(gutter: number | undefined, visibility: SessionPanelVisibility, toggle = vi.fn()) {
|
||||
function toggleProps(dockable: boolean | undefined, visibility: SessionPanelVisibility, toggle = vi.fn()) {
|
||||
const renderSlot = vi.fn(() => <span>需要处理</span>)
|
||||
const gutters: SessionPanelGutters = new Map(gutter === undefined ? [] : [[SID, gutter]])
|
||||
const entries: SessionPanelDockable = new Map(dockable === undefined ? [] : [[SID, dockable]])
|
||||
const props = {
|
||||
sessionId: SID, useGutters: selectorOf(gutters), useVisibility: selectorOf(visibility), toggle, renderSlot, t,
|
||||
sessionId: SID, useDockable: selectorOf(entries), 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)
|
||||
const { props, renderSlot } = toggleProps(true, DOCKED)
|
||||
render(<SessionPanelToggle {...props} />)
|
||||
const button = screen.getByRole('button', { name: '会话面板 需要处理' })
|
||||
expect(button.getAttribute('aria-expanded')).toBe('true')
|
||||
@@ -71,12 +72,12 @@ describe('SessionPanelToggle', () => {
|
||||
})
|
||||
|
||||
it('flips docking with room to dock and opens the overlay without it', () => {
|
||||
const wide = toggleProps(WIDE, DOCKED)
|
||||
const wide = toggleProps(true, DOCKED)
|
||||
render(<SessionPanelToggle {...wide.props} />)
|
||||
fireEvent.click(screen.getByRole('button'))
|
||||
expect(wide.toggle).toHaveBeenCalledWith(SID)
|
||||
cleanup()
|
||||
const narrow = toggleProps(NARROW, DOCKED)
|
||||
const narrow = toggleProps(false, DOCKED)
|
||||
render(<SessionPanelToggle {...narrow.props} />)
|
||||
const button = screen.getByRole('button')
|
||||
expect(button.getAttribute('aria-expanded')).toBe('false')
|
||||
@@ -86,19 +87,19 @@ describe('SessionPanelToggle', () => {
|
||||
})
|
||||
|
||||
it('reports an open overlay as expanded', () => {
|
||||
const { props } = toggleProps(NARROW, { pinned: false, overlay: SID })
|
||||
const { props } = toggleProps(false, { pinned: false, overlay: SID })
|
||||
render(<SessionPanelToggle {...props} />)
|
||||
expect(screen.getByRole('button').getAttribute('aria-expanded')).toBe('true')
|
||||
})
|
||||
|
||||
it('tells its indicators whether the panel shows', () => {
|
||||
const { props, renderSlot } = toggleProps(NARROW, DOCKED)
|
||||
const { props, renderSlot } = toggleProps(false, DOCKED)
|
||||
render(<SessionPanelToggle {...props} />)
|
||||
expect(renderSlot).toHaveBeenCalledWith('conversation.session.panel.indicator', { panelShown: false })
|
||||
})
|
||||
|
||||
it('shows its tooltip after 500ms of hover', () => {
|
||||
const { props } = toggleProps(WIDE, DOCKED)
|
||||
const { props } = toggleProps(true, DOCKED)
|
||||
render(<SessionPanelToggle {...props} />)
|
||||
expect(tooltipAfterHover(screen.getByRole('button'))).toEqual({ early: false, at500: true })
|
||||
})
|
||||
@@ -122,7 +123,8 @@ describe('SessionPanel', () => {
|
||||
{ id: 'change-requests', label: '变更请求' },
|
||||
]
|
||||
|
||||
function panelProps(endGutter: number, visibility: SessionPanelVisibility, closeOverlay = vi.fn(), measure = vi.fn()) {
|
||||
function panelProps(gutter: number, visibility: SessionPanelVisibility, closeOverlay = vi.fn(), track = vi.fn(() => () => {})) {
|
||||
const endGutter = createSnapshotStore(gutter)
|
||||
const owners: SessionPanelSectionOwnerProps[] = []
|
||||
const renderSlot = ((key: string, owner: object, opts?: { only?: string; entryKey?: string }): ReactNode => {
|
||||
if (key === 'conversation.session.panel.section.actions') {
|
||||
@@ -136,28 +138,49 @@ describe('SessionPanel', () => {
|
||||
endGutter,
|
||||
useVisibility: selectorOf(visibility),
|
||||
useSections: selectorOf(SECTIONS),
|
||||
measure,
|
||||
track,
|
||||
closeOverlay,
|
||||
renderSlot,
|
||||
t,
|
||||
} as SessionPanelProps
|
||||
return { props, owners, closeOverlay, measure }
|
||||
return { props, owners, closeOverlay, track, endGutter }
|
||||
}
|
||||
|
||||
it('reports its Chat View gutter while mounted, replacing it on change and withdrawing it on a Session change and unmount', () => {
|
||||
const measure = vi.fn()
|
||||
const view = render(<SessionPanel {...panelProps(420, DOCKED, vi.fn(), measure).props} />)
|
||||
expect(measure.mock.calls).toEqual([[SID, expect.any(String), 420]])
|
||||
const instance = measure.mock.calls[0]?.[1] as string
|
||||
expect(screen.getByRole('complementary').style.getPropertyValue('--dsh-session-panel-gutter')).toBe('420px')
|
||||
view.rerender(<SessionPanel {...panelProps(400, DOCKED, vi.fn(), measure).props} />)
|
||||
expect(measure.mock.calls.at(-1)).toEqual([SID, instance, 400])
|
||||
expect(measure.mock.calls.some(call => call[2] === null)).toBe(false)
|
||||
it('tracks its Chat View gutter source while mounted, moving with a Session change and stopping on unmount', () => {
|
||||
const stops: string[] = []
|
||||
const track = vi.fn((sessionId: SessionId) => () => { stops.push(sessionId) })
|
||||
const first = panelProps(420, DOCKED, vi.fn(), track)
|
||||
const view = render(<SessionPanel {...first.props} />)
|
||||
expect(track.mock.calls).toEqual([[SID, first.endGutter]])
|
||||
// A gutter change publishes through the source; the registration stays.
|
||||
act(() => { first.endGutter.set(400) })
|
||||
expect(track).toHaveBeenCalledTimes(1)
|
||||
const other = 'session-2' as SessionId
|
||||
view.rerender(<SessionPanel {...{ ...panelProps(400, DOCKED, vi.fn(), measure).props, sessionId: other }} />)
|
||||
expect(measure.mock.calls.slice(-2)).toEqual([[SID, instance, null], [other, instance, 400]])
|
||||
view.rerender(<SessionPanel {...{ ...first.props, sessionId: other }} />)
|
||||
expect(stops).toEqual([SID])
|
||||
expect(track.mock.calls.at(-1)).toEqual([other, first.endGutter])
|
||||
view.unmount()
|
||||
expect(measure.mock.calls.at(-1)).toEqual([other, instance, null])
|
||||
expect(stops).toEqual([SID, other])
|
||||
// CSS sizes the docked panel; no measured width reaches its style.
|
||||
render(<SessionPanel {...panelProps(420, DOCKED).props} />)
|
||||
expect(screen.getByRole('complementary').getAttribute('style')).toBeNull()
|
||||
})
|
||||
|
||||
it('renders again only when its gutter crosses the docking threshold', () => {
|
||||
const { props, owners, endGutter } = panelProps(WIDE + 100, DOCKED)
|
||||
render(<SessionPanel {...props} />)
|
||||
const renders = (): number => owners.length
|
||||
const settled = renders()
|
||||
act(() => { endGutter.set(WIDE + 40) })
|
||||
act(() => { endGutter.set(WIDE) })
|
||||
expect(renders()).toBe(settled)
|
||||
expect(screen.getByRole('complementary').getAttribute('data-session-panel')).toBe('docked')
|
||||
act(() => { endGutter.set(NARROW) })
|
||||
expect(screen.queryByRole('complementary')).toBeNull()
|
||||
act(() => { endGutter.set(NARROW - 200) })
|
||||
act(() => { endGutter.set(WIDE + 10) })
|
||||
expect(screen.getByRole('complementary').getAttribute('data-session-panel')).toBe('docked')
|
||||
expect(renders()).toBe(settled * 2)
|
||||
})
|
||||
|
||||
it('renders nothing while hidden', () => {
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import { readFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
const css = readFileSync(fileURLToPath(new URL('../src/PanelRow.module.css', import.meta.url)), 'utf8')
|
||||
const css = readFileSync(fileURLToPath(new URL('../src/client/PanelRow.module.css', import.meta.url)), 'utf8')
|
||||
|
||||
function declarations(selector: string): Map<string, string> {
|
||||
const found = new Map<string, string>()
|
||||
+14
-3
@@ -1,7 +1,8 @@
|
||||
// @vitest-environment jsdom
|
||||
/** The Session panel row the `conversation.session.panel.row` Factory renders. */
|
||||
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'
|
||||
import { PanelRow } from '../src/client/PanelRow.tsx'
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
@@ -62,13 +63,23 @@ describe('PanelRow', () => {
|
||||
expect(row.className).not.toBe(plain.className)
|
||||
})
|
||||
|
||||
it('forwards attributes such as context-menu handlers to the outer element', () => {
|
||||
it('puts its attributes, such as context-menu handlers and markers, and its class on the row element', () => {
|
||||
const onContextMenu = vi.fn()
|
||||
const view = render(<PanelRow icon={<svg />} className="placed" onContextMenu={onContextMenu} tabIndex={0}>Row</PanelRow>)
|
||||
const view = render(
|
||||
<PanelRow icon={<svg />} className="placed" attributes={{ onContextMenu, tabIndex: 0, 'data-marker': 'on' }}>Row</PanelRow>,
|
||||
)
|
||||
const row = view.container.querySelector('[data-panel-row]') as HTMLElement
|
||||
expect(row.className).toContain('placed')
|
||||
expect(row.tabIndex).toBe(0)
|
||||
expect(row.getAttribute('data-marker')).toBe('on')
|
||||
fireEvent.contextMenu(row)
|
||||
expect(onContextMenu).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('leaves props outside its own, such as a Factory occurrence adds, off the row element', () => {
|
||||
const extra = { renderFactorySlot: vi.fn(), useFactorySlot: vi.fn(), useWorkspaces: vi.fn() }
|
||||
const view = render(<PanelRow {...{ icon: <svg />, children: 'Row', ...extra }} />)
|
||||
const row = view.container.querySelector('[data-panel-row]') as HTMLElement
|
||||
expect(row.getAttributeNames().sort()).toEqual(['class', 'data-panel-row'])
|
||||
})
|
||||
})
|
||||
@@ -1,6 +1,7 @@
|
||||
// @vitest-environment jsdom
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'
|
||||
import {
|
||||
DOCK_MIN_GUTTER, PINNED_STORAGE_KEY, SessionPanelState, fitsGutter, presentationOf,
|
||||
} from '../src/client/visibility.ts'
|
||||
@@ -10,12 +11,17 @@ const B = 'session-b' as SessionId
|
||||
const NARROW = 200
|
||||
const WIDE = DOCK_MIN_GUTTER
|
||||
|
||||
/** A Chat View whose panel the state tracks: its gutter source and the disposer of that registration. */
|
||||
function chatView(state: SessionPanelState, sessionId: SessionId, gutter: number) {
|
||||
const source = createSnapshotStore(gutter)
|
||||
const stop = state.track(sessionId, source)
|
||||
return { source, stop }
|
||||
}
|
||||
|
||||
/** A state whose Chat Views show `A` and `B` with narrow gutters. */
|
||||
function newState(): SessionPanelState {
|
||||
function newState() {
|
||||
const state = new SessionPanelState()
|
||||
state.measure(A, 'main', NARROW)
|
||||
state.measure(B, 'main', NARROW)
|
||||
return state
|
||||
return { state, a: chatView(state, A, NARROW), b: chatView(state, B, NARROW) }
|
||||
}
|
||||
|
||||
beforeEach(() => { localStorage.clear() })
|
||||
@@ -45,35 +51,37 @@ describe('presentationOf', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('SessionPanelState gutters', () => {
|
||||
it('keeps the widest gutter of each Session and drops a Session once its last panel unmounts', () => {
|
||||
describe('SessionPanelState room to dock', () => {
|
||||
it('gives a Session room while any of its Chat Views has it, and drops the Session once its last panel stops', () => {
|
||||
const state = new SessionPanelState()
|
||||
const empty = state.gutters.getSnapshot()
|
||||
expect(empty.size).toBe(0)
|
||||
state.measure(A, 'main', 420)
|
||||
state.measure(A, 'embedded', 16)
|
||||
expect(state.gutters.getSnapshot().get(A)).toBe(420)
|
||||
state.measure(A, 'main', null)
|
||||
expect(state.gutters.getSnapshot().get(A)).toBe(16)
|
||||
state.measure(A, 'embedded', null)
|
||||
expect(state.gutters.getSnapshot().has(A)).toBe(false)
|
||||
// A withdrawal for a panel that never reported changes nothing.
|
||||
const before = state.gutters.getSnapshot()
|
||||
state.measure(B, 'main', null)
|
||||
expect(state.gutters.getSnapshot()).toBe(before)
|
||||
expect(state.dockable.getSnapshot().size).toBe(0)
|
||||
const main = chatView(state, A, 420)
|
||||
const embedded = chatView(state, A, 16)
|
||||
expect(state.dockable.getSnapshot().get(A)).toBe(true)
|
||||
main.stop()
|
||||
expect(state.dockable.getSnapshot().get(A)).toBe(false)
|
||||
embedded.source.set(WIDE)
|
||||
expect(state.dockable.getSnapshot().get(A)).toBe(true)
|
||||
embedded.stop()
|
||||
expect(state.dockable.getSnapshot().has(A)).toBe(false)
|
||||
// A stopped source publishes nothing.
|
||||
const before = state.dockable.getSnapshot()
|
||||
embedded.source.set(NARROW)
|
||||
expect(state.dockable.getSnapshot()).toBe(before)
|
||||
})
|
||||
|
||||
it('keeps the snapshot identity until a widest gutter changes', () => {
|
||||
it('publishes only when a Session crosses the docking threshold', () => {
|
||||
const state = new SessionPanelState()
|
||||
state.measure(A, 'main', 420)
|
||||
const first = state.gutters.getSnapshot()
|
||||
const view = chatView(state, A, 420)
|
||||
const first = state.dockable.getSnapshot()
|
||||
let calls = 0
|
||||
const off = state.gutters.subscribe(() => { calls += 1 })
|
||||
state.measure(A, 'embedded', 16)
|
||||
state.measure(A, 'main', 420)
|
||||
expect(state.gutters.getSnapshot()).toBe(first)
|
||||
const off = state.dockable.subscribe(() => { calls += 1 })
|
||||
view.source.set(400)
|
||||
view.source.set(WIDE)
|
||||
chatView(state, A, 16)
|
||||
expect(state.dockable.getSnapshot()).toBe(first)
|
||||
expect(calls).toBe(0)
|
||||
state.measure(A, 'main', 400)
|
||||
view.source.set(WIDE - 1)
|
||||
expect(calls).toBe(1)
|
||||
off()
|
||||
})
|
||||
@@ -81,17 +89,17 @@ describe('SessionPanelState gutters', () => {
|
||||
|
||||
describe('SessionPanelState visibility', () => {
|
||||
it('docks by default and keeps the snapshot identity until a member changes', () => {
|
||||
const state = newState()
|
||||
const { state } = newState()
|
||||
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 = newState()
|
||||
const { state, a } = newState()
|
||||
state.toggle(A)
|
||||
expect(state.visibility.getSnapshot().overlay).toBe(A)
|
||||
state.measure(A, 'main', WIDE)
|
||||
a.source.set(WIDE)
|
||||
expect(state.visibility.getSnapshot().overlay).toBeNull()
|
||||
state.toggle(A)
|
||||
expect(state.visibility.getSnapshot()).toEqual({ pinned: false, overlay: null })
|
||||
@@ -102,7 +110,7 @@ describe('SessionPanelState visibility', () => {
|
||||
})
|
||||
|
||||
it('opens and closes one Session overlay without touching the docking preference', () => {
|
||||
const state = newState()
|
||||
const { state } = newState()
|
||||
state.toggle(A)
|
||||
state.toggle(B)
|
||||
expect(state.visibility.getSnapshot()).toEqual({ pinned: true, overlay: B })
|
||||
@@ -124,15 +132,15 @@ describe('SessionPanelState visibility', () => {
|
||||
|
||||
it('treats a stored value other than false as the default', () => {
|
||||
localStorage.setItem(PINNED_STORAGE_KEY, '"yes"')
|
||||
expect(newState().visibility.getSnapshot().pinned).toBe(true)
|
||||
expect(newState().state.visibility.getSnapshot().pinned).toBe(true)
|
||||
})
|
||||
|
||||
it('notifies subscribers of both members and stops after unsubscribe', () => {
|
||||
const state = newState()
|
||||
const { state, a } = newState()
|
||||
let calls = 0
|
||||
const off = state.visibility.subscribe(() => { calls += 1 })
|
||||
state.toggle(A)
|
||||
state.measure(A, 'main', WIDE)
|
||||
a.source.set(WIDE)
|
||||
state.toggle(A)
|
||||
const seen = calls
|
||||
expect(seen).toBeGreaterThanOrEqual(2)
|
||||
@@ -142,34 +150,34 @@ describe('SessionPanelState visibility', () => {
|
||||
})
|
||||
|
||||
it('closes an overlay once its gutter can dock the panel, without reopening it when the gutter narrows again', () => {
|
||||
const state = newState()
|
||||
const { state, a } = newState()
|
||||
state.toggle(A)
|
||||
state.measure(A, 'main', 300)
|
||||
a.source.set(300)
|
||||
expect(state.visibility.getSnapshot().overlay).toBe(A)
|
||||
state.measure(A, 'main', WIDE)
|
||||
a.source.set(WIDE)
|
||||
expect(state.visibility.getSnapshot()).toEqual({ pinned: true, overlay: null })
|
||||
state.measure(A, 'main', NARROW)
|
||||
a.source.set(NARROW)
|
||||
expect(presentationOf(false, state.visibility.getSnapshot(), A)).toBe('hidden')
|
||||
})
|
||||
|
||||
it('closes an overlay once no Chat View shows its Session, so returning to it shows no overlay', () => {
|
||||
const state = newState()
|
||||
const { state, a } = newState()
|
||||
state.toggle(A)
|
||||
state.measure(A, 'main', null)
|
||||
a.stop()
|
||||
expect(state.visibility.getSnapshot().overlay).toBeNull()
|
||||
state.measure(A, 'main', NARROW)
|
||||
chatView(state, A, NARROW)
|
||||
expect(presentationOf(false, state.visibility.getSnapshot(), A)).toBe('hidden')
|
||||
})
|
||||
|
||||
it('follows only the open overlay, and nothing after dispose', () => {
|
||||
const state = newState()
|
||||
const { state, a, b } = newState()
|
||||
state.toggle(A)
|
||||
state.toggle(B)
|
||||
// A's Chat View no longer matters once B holds the overlay.
|
||||
state.measure(A, 'main', null)
|
||||
a.stop()
|
||||
expect(state.visibility.getSnapshot().overlay).toBe(B)
|
||||
state.dispose()
|
||||
state.measure(B, 'main', null)
|
||||
b.stop()
|
||||
expect(state.visibility.getSnapshot().overlay).toBe(B)
|
||||
})
|
||||
})
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
import { useRef, type ReactNode } from 'react'
|
||||
import {
|
||||
Button, IconWarningTriangleOutlineRegular, MarqueeText, PanelRow, useHoverMarquee,
|
||||
Button, IconWarningTriangleOutlineRegular, MarqueeText, useHoverMarquee,
|
||||
} from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { HostObservable, InjectFace, PropsLocale, PropsRenderSlots, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type {
|
||||
HostObservable, InjectFace, PropsLocale, PropsRenderFactories, PropsRenderSlots, PropsRuntime, PropsStore,
|
||||
} from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { ForgeReadiness, MergeRequest } from '@deepseek-ai/dsh-experimental-forge/types'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-session-panel/client'
|
||||
import type { ForgePanelChangeRequest, ForgePanelState } from '../types.ts'
|
||||
@@ -57,6 +59,7 @@ export interface ChangeRequestsSectionInjected {
|
||||
export type ChangeRequestsSectionProps =
|
||||
PropsRuntime<'conversation.session.panel.section'>
|
||||
& Pick<PropsRenderSlots<'forge.change-request.card.actions'>, 'renderSlot'>
|
||||
& PropsRenderFactories
|
||||
& InjectFace<ChangeRequestsSectionInjected>
|
||||
& PropsStore<ReturnType<typeof createChangeRequestsSectionStore>>
|
||||
& PropsLocale<typeof NS>
|
||||
@@ -94,11 +97,11 @@ function signInNeedOf(state: ForgePanelState): SignInNeed | null {
|
||||
* sign-in check. A reason the host gave shows from the info button; a clipped
|
||||
* title or command crawls into view while the pointer rests on the row.
|
||||
*/
|
||||
function SignInRow({ need, copyText, t }: {
|
||||
function SignInRow({ need, copyText, renderFactorySlot, t }: {
|
||||
readonly need: SignInNeed
|
||||
readonly copyText: (text: string) => void
|
||||
readonly t: Translate
|
||||
}): ReactNode {
|
||||
} & PropsRenderFactories): ReactNode {
|
||||
const titleRef = useRef<HTMLSpanElement>(null)
|
||||
const commandRef = useRef<HTMLSpanElement>(null)
|
||||
const titleMarquee = useHoverMarquee(titleRef)
|
||||
@@ -110,23 +113,17 @@ function SignInRow({ need, copyText, t }: {
|
||||
? <ReasonButton reason={readiness.message} label={t('reason.show')} />
|
||||
: undefined
|
||||
const marquee = command === undefined ? titleMarquee : commandMarquee
|
||||
return (
|
||||
<PanelRow
|
||||
icon={<IconWarningTriangleOutlineRegular size={16} />}
|
||||
role="status"
|
||||
data-forge-signin={readiness.state}
|
||||
onPointerEnter={marquee.enter}
|
||||
onPointerLeave={marquee.leave}
|
||||
detail={command === undefined ? undefined : <MarqueeText ref={commandRef} className={css.signinCommand}>{command}</MarqueeText>}
|
||||
trailing={command === undefined ? reason : (
|
||||
<Button size="sm" variant="outline" aria-label={t('signin.copy')} onClick={() => { copyText(command) }}>
|
||||
{t('signin.copyShort')}
|
||||
</Button>
|
||||
)}
|
||||
>
|
||||
<MarqueeText ref={titleRef} className={css.statusTitle}>{t(unavailable ? 'signin.unavailable' : 'signin.title', { host })}</MarqueeText>
|
||||
</PanelRow>
|
||||
)
|
||||
return renderFactorySlot('conversation.session.panel.row', {
|
||||
icon: <IconWarningTriangleOutlineRegular size={16} />,
|
||||
attributes: { role: 'status', 'data-forge-signin': readiness.state, onPointerEnter: marquee.enter, onPointerLeave: marquee.leave },
|
||||
detail: command === undefined ? undefined : <MarqueeText ref={commandRef} className={css.signinCommand}>{command}</MarqueeText>,
|
||||
trailing: command === undefined ? reason : (
|
||||
<Button size="sm" variant="outline" aria-label={t('signin.copy')} onClick={() => { copyText(command) }}>
|
||||
{t('signin.copyShort')}
|
||||
</Button>
|
||||
),
|
||||
children: <MarqueeText ref={titleRef} className={css.statusTitle}>{t(unavailable ? 'signin.unavailable' : 'signin.title', { host })}</MarqueeText>,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +139,8 @@ function SignInRow({ need, copyText, t }: {
|
||||
*/
|
||||
export function ChangeRequestsSection({
|
||||
usePanel, useLocale, dismissOverlay, refresh, remove, markReady, merge, readChecks,
|
||||
rerunChecks, requestReviews, reviewerCandidates, updateBranch, openLink, copyText, viewChanges, useStore, actions: store, renderSlot, t,
|
||||
rerunChecks, requestReviews, reviewerCandidates, updateBranch, openLink, copyText, viewChanges, useStore, actions: store, renderSlot,
|
||||
renderFactorySlot, t,
|
||||
}: ChangeRequestsSectionProps): ReactNode {
|
||||
const snapshot = usePanel(current => current)
|
||||
const locale = useLocale(value => value)
|
||||
@@ -166,7 +164,7 @@ export function ChangeRequestsSection({
|
||||
const now = Date.now()
|
||||
return (
|
||||
<div className={css.cards} data-forge-panel="">
|
||||
{signIn !== null && <SignInRow need={signIn} copyText={copyText} t={t} />}
|
||||
{signIn !== null && <SignInRow need={signIn} copyText={copyText} renderFactorySlot={renderFactorySlot} t={t} />}
|
||||
{state.changeRequests.length > 0 && (
|
||||
<ul className={css.list}>
|
||||
{state.changeRequests.map(entry => (
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import {
|
||||
Button, IconBranchOutlineRegular, IconEllipsisOutlineRegular, IconFilesDiffOutlineRegular, IconWarningTriangleOutlineRegular,
|
||||
MarqueeText, Menu, PanelRow, StateDot, Tooltip, useHoverMarquee,
|
||||
MarqueeText, Menu, StateDot, Tooltip, useHoverMarquee,
|
||||
} from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { HostObservable, InjectFace, PropsLocale, PropsRenderFactories, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { RemoteHostFacts } from '@deepseek-ai/dsh-api-remotes/client'
|
||||
@@ -52,6 +52,7 @@ export interface LocalChangesRowInjected {
|
||||
/** Full props of the local changes row. */
|
||||
export type LocalChangesRowProps =
|
||||
PropsRuntime<'conversation.session.panel.environment.row'>
|
||||
& PropsRenderFactories
|
||||
& InjectFace<LocalChangesRowInjected>
|
||||
& PropsLocale<typeof NS>
|
||||
|
||||
@@ -90,12 +91,13 @@ export function CheckoutRow({
|
||||
const label = checkoutLabel(state, home, t)
|
||||
if (label === undefined) {
|
||||
if (state.checkout.state !== 'failed') return null
|
||||
return (
|
||||
<PanelRow className={css.envRow} icon={<IconWarningTriangleOutlineRegular size={16} />} data-forge-checkout="" data-failed=""
|
||||
trailing={<ReasonButton reason={state.checkout.message} label={t('reason.show')} />}>
|
||||
<span className={css.envName}>{t('checkout.failed')}</span>
|
||||
</PanelRow>
|
||||
)
|
||||
return renderFactorySlot('conversation.session.panel.row', {
|
||||
className: css.envRow,
|
||||
icon: <IconWarningTriangleOutlineRegular size={16} />,
|
||||
attributes: { 'data-forge-checkout': '', 'data-failed': '' },
|
||||
trailing: <ReasonButton reason={state.checkout.message} label={t('reason.show')} />,
|
||||
children: <span className={css.envName}>{t('checkout.failed')}</span>,
|
||||
})
|
||||
}
|
||||
const target = { kind: 'directory', value: { sessionId, path: label.path } } as const
|
||||
const icon = label.missing
|
||||
@@ -103,41 +105,42 @@ export function CheckoutRow({
|
||||
: <IconBranchOutlineRegular size={16} />
|
||||
const name = [label.detached ? t('checkout.detached') : undefined, label.name ?? undefined]
|
||||
.filter(part => part !== undefined).join(' · ')
|
||||
return (
|
||||
<PanelRow
|
||||
{...getTriggerProps(target)}
|
||||
className={css.envRow}
|
||||
icon={icon}
|
||||
data-forge-checkout=""
|
||||
data-missing={label.missing ? '' : undefined}
|
||||
onPointerEnter={marquee.enter}
|
||||
onPointerLeave={marquee.leave}
|
||||
trailing={(
|
||||
<>
|
||||
<span className={css.envNote}>{label.kind}</span>
|
||||
{label.missing && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
disabled={state.worktree.restoration !== null}
|
||||
icon={state.worktree.restoration === null ? undefined : <StateDot state="ongoing" size={14} />}
|
||||
onClick={restore}
|
||||
>
|
||||
{t('checkout.restore')}
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
menu={label.missing ? undefined : renderFactorySlot('contextMenu.button', {
|
||||
target,
|
||||
label: t(label.worktree ? 'checkout.worktreeActions' : 'checkout.projectActions'),
|
||||
})}
|
||||
>
|
||||
return renderFactorySlot('conversation.session.panel.row', {
|
||||
className: css.envRow,
|
||||
icon,
|
||||
attributes: {
|
||||
...getTriggerProps(target),
|
||||
'data-forge-checkout': '',
|
||||
'data-missing': label.missing ? '' : undefined,
|
||||
onPointerEnter: marquee.enter,
|
||||
onPointerLeave: marquee.leave,
|
||||
},
|
||||
trailing: (
|
||||
<>
|
||||
<span className={css.envNote}>{label.kind}</span>
|
||||
{label.missing && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
disabled={state.worktree.restoration !== null}
|
||||
icon={state.worktree.restoration === null ? undefined : <StateDot state="ongoing" size={14} />}
|
||||
onClick={restore}
|
||||
>
|
||||
{t('checkout.restore')}
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
),
|
||||
menu: label.missing ? undefined : renderFactorySlot('contextMenu.button', {
|
||||
target,
|
||||
label: t(label.worktree ? 'checkout.worktreeActions' : 'checkout.projectActions'),
|
||||
}),
|
||||
children: (
|
||||
<Tooltip label={label.tooltip} side="left" delayMs={500}>
|
||||
<MarqueeText ref={nameRef} className={css.envName} tabIndex={0}>{name}</MarqueeText>
|
||||
</Tooltip>
|
||||
</PanelRow>
|
||||
)
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
/** Business face of the connection row. */
|
||||
@@ -151,6 +154,7 @@ export interface ConnectionRowInjected {
|
||||
/** Full props of the connection row. */
|
||||
export type ConnectionRowProps =
|
||||
PropsRuntime<'conversation.session.panel.environment.row'>
|
||||
& PropsRenderFactories
|
||||
& InjectFace<ConnectionRowInjected>
|
||||
& PropsLocale<typeof NS>
|
||||
|
||||
@@ -161,21 +165,17 @@ export type ConnectionRowProps =
|
||||
* @param props - panel snapshot hook, reconnect action, and copy.
|
||||
* @returns the row, or null while the stream is open.
|
||||
*/
|
||||
export function ConnectionRow({ usePanel, reconnect, t }: ConnectionRowProps): ReactNode {
|
||||
export function ConnectionRow({ usePanel, reconnect, renderFactorySlot, t }: ConnectionRowProps): ReactNode {
|
||||
const disconnected = usePanel(snapshot => snapshot.disconnected)
|
||||
if (!disconnected) return null
|
||||
return (
|
||||
<PanelRow
|
||||
className={css.envRow}
|
||||
icon={<IconWarningTriangleOutlineRegular size={16} />}
|
||||
role="status"
|
||||
data-forge-connection=""
|
||||
detail={t('connection.detail')}
|
||||
trailing={<Button size="sm" variant="outline" onClick={reconnect}>{t('retry')}</Button>}
|
||||
>
|
||||
<span className={css.statusTitle}>{t('connection.title')}</span>
|
||||
</PanelRow>
|
||||
)
|
||||
return renderFactorySlot('conversation.session.panel.row', {
|
||||
className: css.envRow,
|
||||
icon: <IconWarningTriangleOutlineRegular size={16} />,
|
||||
attributes: { role: 'status', 'data-forge-connection': '' },
|
||||
detail: t('connection.detail'),
|
||||
trailing: <Button size="sm" variant="outline" onClick={reconnect}>{t('retry')}</Button>,
|
||||
children: <span className={css.statusTitle}>{t('connection.title')}</span>,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,7 +186,9 @@ export function ConnectionRow({ usePanel, reconnect, t }: ConnectionRowProps): R
|
||||
* @param props - panel snapshot hook, view and create actions, panel owner values, and copy.
|
||||
* @returns the row, or null while the branch changes no files.
|
||||
*/
|
||||
export function LocalChangesRow({ usePanel, dismissOverlay, viewLocalChanges, createChangeRequest, t }: LocalChangesRowProps): ReactNode {
|
||||
export function LocalChangesRow({
|
||||
usePanel, dismissOverlay, viewLocalChanges, createChangeRequest, renderFactorySlot, t,
|
||||
}: LocalChangesRowProps): ReactNode {
|
||||
const local = usePanel(snapshot => snapshot.state?.local ?? null)
|
||||
const creatable = usePanel(snapshot => snapshot.state !== null && snapshot.state.repository !== null
|
||||
&& openChangeRequestOf(snapshot.state) === undefined)
|
||||
@@ -203,49 +205,46 @@ export function LocalChangesRow({ usePanel, dismissOverlay, viewLocalChanges, cr
|
||||
viewLocalChanges()
|
||||
dismissOverlay()
|
||||
}
|
||||
return (
|
||||
<PanelRow
|
||||
className={css.envRow}
|
||||
icon={<IconFilesDiffOutlineRegular size={16} />}
|
||||
onActivate={view}
|
||||
actionLabel={t('changes.local.viewAria', { count, added: additions, deleted: deletions })}
|
||||
data-forge-local=""
|
||||
trailing={(
|
||||
<span className={css.diff}>
|
||||
<span className={css.added}>{`+${String(additions)}`}</span>
|
||||
<span className={css.deleted}>{`−${String(deletions)}`}</span>
|
||||
</span>
|
||||
)}
|
||||
menu={(
|
||||
<Menu
|
||||
open={open}
|
||||
onClose={() => { setOpen(false) }}
|
||||
portal
|
||||
align="end"
|
||||
anchor={(
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('changes.local.actions')}
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={open}
|
||||
onClick={() => { setOpen(!open) }}
|
||||
>
|
||||
<IconEllipsisOutlineRegular />
|
||||
</button>
|
||||
)}
|
||||
items={[
|
||||
{ id: 'view', label: t('change.viewChanges') },
|
||||
...creatable ? [{ id: 'create', label: t('changes.local.create') }] : [],
|
||||
]}
|
||||
onSelect={(id) => {
|
||||
setOpen(false)
|
||||
if (id === 'create') createChangeRequest()
|
||||
else view()
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
>
|
||||
{t('changes.local.summary', { count })}
|
||||
</PanelRow>
|
||||
)
|
||||
return renderFactorySlot('conversation.session.panel.row', {
|
||||
className: css.envRow,
|
||||
icon: <IconFilesDiffOutlineRegular size={16} />,
|
||||
onActivate: view,
|
||||
actionLabel: t('changes.local.viewAria', { count, added: additions, deleted: deletions }),
|
||||
attributes: { 'data-forge-local': '' },
|
||||
trailing: (
|
||||
<span className={css.diff}>
|
||||
<span className={css.added}>{`+${String(additions)}`}</span>
|
||||
<span className={css.deleted}>{`−${String(deletions)}`}</span>
|
||||
</span>
|
||||
),
|
||||
menu: (
|
||||
<Menu
|
||||
open={open}
|
||||
onClose={() => { setOpen(false) }}
|
||||
portal
|
||||
align="end"
|
||||
anchor={(
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('changes.local.actions')}
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={open}
|
||||
onClick={() => { setOpen(!open) }}
|
||||
>
|
||||
<IconEllipsisOutlineRegular />
|
||||
</button>
|
||||
)}
|
||||
items={[
|
||||
{ id: 'view', label: t('change.viewChanges') },
|
||||
...creatable ? [{ id: 'create', label: t('changes.local.create') }] : [],
|
||||
]}
|
||||
onSelect={(id) => {
|
||||
setOpen(false)
|
||||
if (id === 'create') createChangeRequest()
|
||||
else view()
|
||||
}}
|
||||
/>
|
||||
),
|
||||
children: t('changes.local.summary', { count }),
|
||||
})
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import type { PanelSnapshot } from '../src/client/source.ts'
|
||||
import type { ForgePanelChangeRequest, ForgePanelState } from '../src/types.ts'
|
||||
import { createChangeRequestsSectionStore } from '../src/client/change-requests-store.ts'
|
||||
import { created, entry, ready, removed, snapshot, worktree } from './client-fixtures.client.ts'
|
||||
import { renderPanelRows } from './panel-row-factory.client.tsx'
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
@@ -52,6 +53,7 @@ function section(state: ForgePanelState | null, options: { disconnected?: boolea
|
||||
dismissOverlay: vi.fn<() => void>(),
|
||||
// Plugins' card actions: a marker naming the change request it was drawn for.
|
||||
renderSlot: vi.fn((_name: string, owner: { url: string }) => <span data-plugin-action={owner.url} />),
|
||||
renderFactorySlot: renderPanelRows(),
|
||||
}
|
||||
const props = {
|
||||
sessionId: SESSION,
|
||||
@@ -64,7 +66,8 @@ function section(state: ForgePanelState | null, options: { disconnected?: boolea
|
||||
t,
|
||||
} as Pick<ChangeRequestsSectionProps,
|
||||
'sessionId' | 'presentation' | 'usePanel' | 'useLocale' | 'useStore' | 'actions' | 'dismissOverlay' | 'refresh'
|
||||
| 'remove' | 'markReady' | 'merge' | 'readChecks' | 'openLink' | 'copyText' | 'viewChanges' | 'renderSlot' | 't'> as ChangeRequestsSectionProps
|
||||
| 'remove' | 'markReady' | 'merge' | 'readChecks' | 'openLink' | 'copyText' | 'viewChanges' | 'renderSlot' | 'renderFactorySlot'
|
||||
| 't'> as ChangeRequestsSectionProps
|
||||
const view = render(<ChangeRequestsSection {...props} />)
|
||||
return { view, panel, store, ...handlers }
|
||||
}
|
||||
@@ -282,7 +285,7 @@ describe('CheckoutRow', () => {
|
||||
const restore = vi.fn<() => void>()
|
||||
const refreshIfStale = vi.fn<() => void>()
|
||||
const opened: ContextMenuTarget[] = []
|
||||
const renderFactorySlot = vi.fn((_name: string, input: { label: string }) => <button type="button">{input.label}</button>)
|
||||
const renderFactorySlot = renderPanelRows((_name, input: { label: string }) => <button type="button">{input.label}</button>)
|
||||
const props = {
|
||||
sessionId: SESSION,
|
||||
usePanel: bindSnapshotSelector(panel),
|
||||
@@ -349,7 +352,7 @@ describe('CheckoutRow', () => {
|
||||
// A press shows it too, for touch screens that cannot hover.
|
||||
fireEvent.click(reason)
|
||||
expect(b.view.getByRole('tooltip').textContent).toBe('sandbox runner unavailable')
|
||||
expect(b.renderFactorySlot).not.toHaveBeenCalled()
|
||||
expect(b.renderFactorySlot).not.toHaveBeenCalledWith('contextMenu.button', expect.anything())
|
||||
fireEvent.contextMenu(element)
|
||||
expect(b.opened).toEqual([])
|
||||
})
|
||||
@@ -418,7 +421,7 @@ describe('CheckoutRow', () => {
|
||||
expect(element.hasAttribute('data-missing')).toBe(true)
|
||||
expect(within(element).getByText('dsh/0a1b2c3d')).toBeTruthy()
|
||||
expect(within(element).getByText(en['missing.title'])).toBeTruthy()
|
||||
expect(b.renderFactorySlot).not.toHaveBeenCalled()
|
||||
expect(b.renderFactorySlot).not.toHaveBeenCalledWith('contextMenu.button', expect.anything())
|
||||
fireEvent.click(within(element).getByRole('button', { name: en['checkout.restore'] }))
|
||||
expect(b.restore).toHaveBeenCalledOnce()
|
||||
})
|
||||
@@ -435,8 +438,8 @@ describe('ConnectionRow', () => {
|
||||
function row(state: ForgePanelState | null, disconnected: boolean) {
|
||||
const panel = panelStore(state, disconnected)
|
||||
const reconnect = vi.fn<() => void>()
|
||||
const props = { sessionId: SESSION, usePanel: bindSnapshotSelector(panel), reconnect, t } as
|
||||
Pick<ConnectionRowProps, 'sessionId' | 'usePanel' | 'reconnect' | 't'> as ConnectionRowProps
|
||||
const props = { sessionId: SESSION, usePanel: bindSnapshotSelector(panel), reconnect, renderFactorySlot: renderPanelRows(), t } as
|
||||
Pick<ConnectionRowProps, 'sessionId' | 'usePanel' | 'reconnect' | 'renderFactorySlot' | 't'> as ConnectionRowProps
|
||||
return { view: render(<ConnectionRow {...props} />), panel, reconnect }
|
||||
}
|
||||
|
||||
@@ -472,8 +475,10 @@ describe('LocalChangesRow', () => {
|
||||
const createChangeRequest = vi.fn<() => void>()
|
||||
const dismissOverlay = vi.fn<() => void>()
|
||||
const props = {
|
||||
sessionId: SESSION, usePanel: bindSnapshotSelector(panel), dismissOverlay, viewLocalChanges, createChangeRequest, t,
|
||||
} as Pick<LocalChangesRowProps, 'sessionId' | 'usePanel' | 'dismissOverlay' | 'viewLocalChanges' | 'createChangeRequest' | 't'> as LocalChangesRowProps
|
||||
sessionId: SESSION, usePanel: bindSnapshotSelector(panel), dismissOverlay, viewLocalChanges, createChangeRequest,
|
||||
renderFactorySlot: renderPanelRows(), t,
|
||||
} as Pick<LocalChangesRowProps,
|
||||
'sessionId' | 'usePanel' | 'dismissOverlay' | 'viewLocalChanges' | 'createChangeRequest' | 'renderFactorySlot' | 't'> as LocalChangesRowProps
|
||||
const view = render(<LocalChangesRow {...props} />)
|
||||
return { view, viewLocalChanges, createChangeRequest, dismissOverlay }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* The Session panel's `conversation.session.panel.row` Factory as these
|
||||
* suites render it: the row's parts in the row's order, its attributes on the
|
||||
* row element, and its action as a button. ui-session-panel's own suite owns
|
||||
* the row's geometry and interaction states.
|
||||
*/
|
||||
import type { ReactNode } from 'react'
|
||||
import { vi } from 'vitest'
|
||||
import type { PanelRowProps } from '@deepseek-ai/dsh-client-ui-session-panel/client'
|
||||
|
||||
/**
|
||||
* Render one row the way the Factory lays it out.
|
||||
* @param props - the row's Factory input.
|
||||
* @returns the row element.
|
||||
*/
|
||||
function PanelRowDouble({
|
||||
icon, children, trailing, menu, onActivate, actionLabel, detail, className, attributes,
|
||||
}: PanelRowProps): ReactNode {
|
||||
const body = (
|
||||
<>
|
||||
<span aria-hidden="true">{icon}</span>
|
||||
<span>{children}</span>
|
||||
{detail !== undefined && <span>{detail}</span>}
|
||||
</>
|
||||
)
|
||||
return (
|
||||
<div {...attributes} className={className} data-panel-row="">
|
||||
{onActivate === undefined ? <span>{body}</span> : <button type="button" aria-label={actionLabel} onClick={onActivate}>{body}</button>}
|
||||
{trailing}
|
||||
{menu}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* A recording `renderFactorySlot` that renders panel rows and hands every other Factory to `other`.
|
||||
* @param other - renders the other Factories the component under test uses.
|
||||
* @returns the mock.
|
||||
*/
|
||||
export function renderPanelRows(other: (name: string, input: never) => ReactNode = () => null) {
|
||||
return vi.fn((name: string, input: object): ReactNode => name === 'conversation.session.panel.row'
|
||||
? <PanelRowDouble {...input as PanelRowProps} />
|
||||
: other(name, input as never))
|
||||
}
|
||||
@@ -221,12 +221,14 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
kind: 'single',
|
||||
scope: 'session',
|
||||
summary: 'One Session-level occupant beside the transcript, such as a summary panel.',
|
||||
doc: 'One Session-level occupant beside the transcript, such as a summary\npanel. Every Chat View occurrence renders it in a zero-height layer at\nthe top of the Chat frame, which stays in place while the transcript\nscrolls and inherits the shared scrollport\'s composer and viewport\nheights. The layer passes pointer events through; the occupant\npositions itself in it, enables its own pointer events, and keeps\nwithin `endGutter` to stay clear of the transcript column.',
|
||||
doc: 'One Session-level occupant beside the transcript, such as a summary\npanel. Every Chat View occurrence renders it in a zero-height layer at\nthe top of the Chat frame, which stays in place while the transcript\nscrolls and inherits the shared scrollport\'s composer and viewport\nheights. The layer passes pointer events through; the occupant\npositions itself in it, enables its own pointer events, and keeps\nwithin the end gutter to stay clear of the transcript column.',
|
||||
registerOptions: [],
|
||||
ownerProps: [
|
||||
'/** Geometry the Chat View gives its aside occupant. */\nexport interface ChatAsideOwnerProps {\n /**\n * Inline space in CSS px between the transcript column\'s end edge and the\n * Chat frame\'s end edge, measured again whenever the frame or the column\n * resizes; zero before the first measurement.\n */\n readonly endGutter: number\n}',
|
||||
'/** Geometry the Chat View gives its aside occupant. */\nexport interface ChatAsideOwnerProps {\n /**\n * Inline space in CSS px between the transcript column\'s end edge and the\n * Chat frame\'s end edge, followed whenever the frame or the column resizes;\n * zero before the first measurement. The source keeps its identity for the\n * layer\'s lifetime and publishes changes without re-rendering the layer, so\n * an occupant subscribes for the decisions it derives from the gutter and\n * sizes itself in CSS, where the gutter is\n * `(100% - var(--dsh-chat-content-width)) / 2` of the layer.\n */\n readonly endGutter: ObservableSnapshot<number>\n}',
|
||||
],
|
||||
ownerPropsReferences: [
|
||||
'ObservableSnapshot',
|
||||
],
|
||||
ownerPropsReferences: [],
|
||||
standardProps: [
|
||||
'useRemoteAccess: (action: RemoteEndpoint) => boolean',
|
||||
'useResource: UseResource',
|
||||
@@ -257,7 +259,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.chat.aside\', () => ctx.slots.register(\n { name: \'conversation.chat.aside\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:453',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:457',
|
||||
},
|
||||
{
|
||||
key: 'conversation.chat.assistant-actions',
|
||||
@@ -321,7 +323,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.chat.assistant-actions\', () => ctx.slots.register(\n { name: \'conversation.chat.assistant-actions\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:518',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:522',
|
||||
},
|
||||
{
|
||||
key: 'conversation.chat.commandview',
|
||||
@@ -375,7 +377,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.chat.commandview\', () => ctx.slots.register(\n { name: \'conversation.chat.commandview\', key: \'<one key the owner dispatches>\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:500',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:504',
|
||||
},
|
||||
{
|
||||
key: 'conversation.chat.flow',
|
||||
@@ -422,7 +424,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.chat.flow\', () => ctx.slots.register(\n { name: \'conversation.chat.flow\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:456',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:460',
|
||||
},
|
||||
{
|
||||
key: 'conversation.chat.markdown.fence',
|
||||
@@ -488,7 +490,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.chat.markdown.fence\', () => ctx.slots.register(\n { name: \'conversation.chat.markdown.fence\', id: \'my-layer\', order: 100 },\n ({ children }) => React.createElement(\'div\', null, children),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:443',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:447',
|
||||
},
|
||||
{
|
||||
key: 'conversation.chat.message.images',
|
||||
@@ -535,7 +537,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.chat.message.images\', () => ctx.slots.register(\n { name: \'conversation.chat.message.images\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:492',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:496',
|
||||
},
|
||||
{
|
||||
key: 'conversation.chat.node',
|
||||
@@ -608,7 +610,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.chat.node\', () => ctx.slots.register(\n { name: \'conversation.chat.node\', key: \'<one key the owner dispatches>\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:468',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:472',
|
||||
},
|
||||
{
|
||||
key: 'conversation.chat.reasoning.body',
|
||||
@@ -652,7 +654,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.chat.reasoning.body\', () => ctx.slots.register(\n { name: \'conversation.chat.reasoning.body\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:506',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:510',
|
||||
},
|
||||
{
|
||||
key: 'conversation.chat.text-interaction',
|
||||
@@ -704,7 +706,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.chat.text-interaction\', () => ctx.slots.register(\n { name: \'conversation.chat.text-interaction\', key: \'<one key the owner dispatches>\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:441',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:445',
|
||||
},
|
||||
{
|
||||
key: 'conversation.chat.turnTail',
|
||||
@@ -771,7 +773,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.chat.turnTail\', () => ctx.slots.register(\n { name: \'conversation.chat.turnTail\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:512',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:516',
|
||||
},
|
||||
{
|
||||
key: 'conversation.chat.user.before',
|
||||
@@ -821,7 +823,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.chat.user.before\', () => ctx.slots.register(\n { name: \'conversation.chat.user.before\', select: owner => null },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:482',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:486',
|
||||
},
|
||||
{
|
||||
key: 'conversation.chat.user.images',
|
||||
@@ -868,7 +870,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.chat.user.images\', () => ctx.slots.register(\n { name: \'conversation.chat.user.images\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:494',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:498',
|
||||
},
|
||||
{
|
||||
key: 'conversation.composer',
|
||||
@@ -2411,7 +2413,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel.environment.row\', () => ctx.slots.register(\n { name: \'conversation.session.panel.environment.row\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:44',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:57',
|
||||
},
|
||||
{
|
||||
key: 'conversation.session.panel.indicator',
|
||||
@@ -2475,7 +2477,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel.indicator\', () => ctx.slots.register(\n { name: \'conversation.session.panel.indicator\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:37',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:50',
|
||||
},
|
||||
{
|
||||
key: 'conversation.session.panel.section',
|
||||
@@ -2543,7 +2545,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel.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:22',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:35',
|
||||
},
|
||||
{
|
||||
key: 'conversation.session.panel.section.actions',
|
||||
@@ -2593,7 +2595,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
],
|
||||
replaceRisk: 'shadows-shipped-ui',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel.section.actions\', () => ctx.slots.register(\n { name: \'conversation.session.panel.section.actions\', key: \'<one key the owner dispatches>\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:28',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:41',
|
||||
},
|
||||
{
|
||||
key: 'conversation.trajectory.images',
|
||||
@@ -4648,7 +4650,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'shell.quota-notice\', () => ctx.slots.register(\n { name: \'shell.quota-notice\', select: owner => null },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:526',
|
||||
source: 'packages/client/ui-chat/src/client/contract/slots.ts:530',
|
||||
},
|
||||
{
|
||||
key: 'sidebar',
|
||||
|
||||
Reference in new issue
Block a user