refactor(session-panel): offer the panel row as a Component Factory instead of a primitive
PanelRow only lays out the content its contributors pass, so it belongs to the Session panel rather than ui-primitives. ui-session-panel registers it as the conversation.session.panel.row Factory; contributors render their rows through renderFactorySlot, and row attributes travel in an explicit attributes prop so the props a Factory occurrence adds never reach the DOM.
This commit is contained in:
1 parent
6af99291a8
commit
4186e5dd31
15 files changed
+83
-40
No files matched your search
@@ -18,8 +18,8 @@
|
||||
en: ead6be55c7c9d7cf
|
||||
zh: 125ad36db7328551
|
||||
/deepseek-ai-dsh-client-ui-primitives/use-this-package/component-catalog:
|
||||
en: ea784283a5e13498
|
||||
zh: 0e03621295d24e12
|
||||
en: 54c5085d03bf4c53
|
||||
zh: 6b5114206ca545f3
|
||||
/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; a row with an action or row actions fills as a whole on hover and while one of its menus is open. Other attributes, such as context-menu trigger props, reach the outer element. |
|
||||
| `StateDot` | Solid green `done`, amber `warning`, red `error`, and neutral-grey `idle` marks in a 10px slot, plus a tertiary-grey 14px rotating `ongoing` loader whose animations pin to document time zero on mount and on every animation restart, such as a list reorder, so every visible loader rotates in phase. `aria-hidden`, so the render site owns the name. `appearance="step"` shows a filled check for completion and a hollow pending circle. |
|
||||
| `ConnectionIndicator` | Inline connection-recovery control across outage, retry, and recovered states. |
|
||||
| `DisclosureRow` | 24px compact disclosure that lays title and content side by side. The header supplies tertiary at rest and secondary on hover; text and icons inherit it regardless of expandability or open state unless the caller supplies a feature-specific override. Semantic status colors remain explicit. Collapsed rows preview a down chevron on hover, and expanded rows keep an up chevron visible. `headerAccessory` places an independent action outside the disclosure target and shimmer; with an accessory, the title row shrinks to its content width. Memoized with shallow prop comparison; keep callbacks and React-node props stable when their content is unchanged. |
|
||||
|
||||
@@ -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` 仍是各自独立的控件;带操作或行操作的行在悬停时以及菜单打开期间整行填充。其余属性(例如右键菜单触发属性)落在外层元素上。 |
|
||||
| `StateDot` | 10px 槽内的绿色 `done`、琥珀色 `warning`、红色 `error`、中性灰色 `idle` 圆点,以及 tertiary 灰色 14px 旋转 `ongoing` loading,其动画在挂载时以及每次动画重启(如列表重排)时固定到文档时间零点,所以所有可见 loading 同相旋转。它是 `aria-hidden` 的,名称由渲染点提供。 `appearance="step"` 以实心勾表示完成、空心圆表示等待。 |
|
||||
| `ConnectionIndicator` | 行内连接恢复控件,覆盖断线、重试与已恢复三种状态。 |
|
||||
| `DisclosureRow` | 24px 紧凑折叠行,标题与内容左右排列。标题行默认使用 tertiary,悬停时使用 secondary;文字与图标继承该颜色,不受能否展开及开合状态影响,调用方可提供功能专属覆盖。语义状态色保持显式指定。收起时悬停预览向下箭头,展开后持续显示向上箭头。`headerAccessory` 将独立操作放在折叠触发区域和流光之外;有此操作时,标题行收窄到内容宽度。使用浅层 prop 比较进行 memo;内容未变时,保持回调与 React 节点 prop 的引用稳定。 |
|
||||
|
||||
@@ -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 { Switch } from './Switch.tsx'
|
||||
export { SegmentedControl } from './SegmentedControl.tsx'
|
||||
export type { SegmentedControlOption } from './SegmentedControl.tsx'
|
||||
|
||||
@@ -21,14 +21,14 @@
|
||||
en: 77c0fdde17b1d115
|
||||
zh: 73edb33c88e8e464
|
||||
/deepseek-ai-dsh-client-ui-session-panel/use-this-package/contribute-a-section:
|
||||
en: a297c196bb631928
|
||||
zh: 523b71276d8f847e
|
||||
en: 853f022d35daac99
|
||||
zh: 0caf8d2f6f207d82
|
||||
/deepseek-ai-dsh-client-ui-session-panel/understand-the-implementation:
|
||||
en: a6e70aa8e7e3e7fa
|
||||
zh: 2633f04bbf1e6711
|
||||
en: 645f3b40eaa5bd33
|
||||
zh: df16d5d3f25e1686
|
||||
/deepseek-ai-dsh-client-ui-session-panel/further-exploration:
|
||||
en: 413e4e321768d4b2
|
||||
zh: 85444059cd1dc565
|
||||
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.
|
||||
|
||||
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; a row with an action or row actions fills as a whole on hover and while one of its menus is open. `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.
|
||||
|
||||
-----
|
||||
|
||||
@@ -60,12 +60,13 @@ The panel projects the section list's live registrations (`entriesOfSlot`, so a
|
||||
|
||||
| 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 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>
|
||||
@@ -78,7 +79,7 @@ The panel projects the section list's live registrations (`entriesOfSlot`, so a
|
||||
- [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 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` 让只是重复面板内容的标记在面板显示时不渲染。
|
||||
|
||||
各包的摘要行都使用 `PanelRow` 原语,使不同分栏的图标、文字与尾部区域对齐;行的「更多」按钮放进它的 `menu`,各行就以同样的方式整行高亮并显示操作。
|
||||
插件把面板的行作为 Component Factory `conversation.session.panel.row` 提供。各包的分栏与环境行都用 `renderFactorySlot('conversation.session.panel.row', props)` 渲染自己的行,使不同分栏的图标、文字与尾部区域对齐。每行有一个沿用行文字颜色的 16px 装饰图标、单行内容(溢出时以省略号截断),以及可选的尾部数值或控件。`menu` 放在尾部区域之后的行操作(例如「更多」按钮),位于 16px 宽的一列,中心距行末端 14px;其中的普通 `button` 有 24px 点击区和三级文字色图标,悬停时图标变深、没有底色,因此不需要自己的 tooltip。鼠标悬停在行上、焦点在行内或其菜单打开时显示,没有悬停能力的设备上始终显示。传入 `onActivate` 时整行成为一个按钮,尾部区域与 `menu` 仍是各自独立的控件;带操作或行操作的行在悬停时以及菜单打开期间整行填充。`className` 追加到行的类名上,`attributes`(例如 `role`、`data-*` 标记与右键菜单触发属性)落在行元素上,其余属性被忽略。
|
||||
|
||||
-----
|
||||
|
||||
@@ -60,12 +60,13 @@ kind: "package-reference"
|
||||
|
||||
| 文件 | 作用 |
|
||||
|---|---|
|
||||
| [`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/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>
|
||||
@@ -78,7 +79,7 @@ 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-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
|
||||
+21
-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. */
|
||||
@@ -21,16 +29,22 @@ export interface PanelRowProps extends Omit<HTMLAttributes<HTMLElement>, 'childr
|
||||
readonly menu?: ReactNode
|
||||
/** Make the whole row one button with this action; the trailing area and the menu stay separate controls above it. */
|
||||
readonly onActivate?: (() => void) | undefined
|
||||
/** 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, className, ...attributes }: PanelRowProps) {
|
||||
export function PanelRow({ icon, children, trailing, menu, onActivate, 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,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,6 +30,7 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
||||
}
|
||||
}
|
||||
|
||||
export type { PanelRowAttributes, PanelRowProps } from './PanelRow.tsx'
|
||||
export type {
|
||||
EnvironmentSectionProps, ProjectRowInjected, ProjectRowProps, SessionPanelDockable, SessionPanelIndicatorOwnerProps, SessionPanelInjected,
|
||||
SessionPanelPresentation, SessionPanelProps, SessionPanelSectionEntry, SessionPanelSectionOwnerProps,
|
||||
@@ -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',
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
|
||||
+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)
|
||||
|
||||
@@ -43,13 +44,23 @@ describe('PanelRow', () => {
|
||||
expect(staticRow.className).not.toBe(interactive)
|
||||
})
|
||||
|
||||
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'])
|
||||
})
|
||||
})
|
||||
@@ -2469,7 +2469,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',
|
||||
@@ -2529,7 +2529,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
occupants: [],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel.indicator\', () => ctx.slots.register(\n { name: \'conversation.session.panel.indicator\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:37',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:50',
|
||||
},
|
||||
{
|
||||
key: 'conversation.session.panel.section',
|
||||
@@ -2593,7 +2593,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',
|
||||
@@ -2639,7 +2639,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
occupants: [],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel.section.actions\', () => ctx.slots.register(\n { name: \'conversation.session.panel.section.actions\', key: \'<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',
|
||||
|
||||
Reference in new issue
Block a user