refactor(session-panel): offer row hover details as a panel Factory with data props
The details a panel row shows in its hover card took React nodes for the title, lines, and measure icons and lived in ui-primitives. The three lists pass strings for the first two and one of two icons, so the component moves to ui-session-panel as the conversation.session.panel.details Component Factory: props are data, and a measure names its kind, which selects the icon.
This commit is contained in:
1 parent
e66b080437
commit
0277971e87
25 files changed
+265
-182
No files matched your search
@@ -589,7 +589,7 @@ describe('web e2e: agent teamwork panel', () => {
|
||||
expect(await row.getByText('team-panel-researcher', { exact: true }).count()).toBe(0)
|
||||
expect(await panel.evaluate(element => element.scrollWidth <= element.clientWidth)).toBe(true)
|
||||
await primary.hover()
|
||||
const card = page.locator('[data-hover-details]')
|
||||
const card = page.locator('[data-session-panel-details]')
|
||||
await card.waitFor()
|
||||
expect(await card.evaluate(element => [...element.children].slice(0, 2).map(child => child.textContent)))
|
||||
.toEqual([RESEARCHER_DESCRIPTION, 'Owner: team-panel-researcher'])
|
||||
|
||||
@@ -498,7 +498,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () =
|
||||
await row.getByRole('button', { name: `Expand ${LABEL} descendants`, exact: true }).waitFor()
|
||||
expect(await row.getByRole('button', { name: `Open ${LABEL} in sidebar`, exact: true }).count()).toBe(1)
|
||||
await primary.hover()
|
||||
const card = page.locator('[data-hover-details]')
|
||||
const card = page.locator('[data-session-panel-details]')
|
||||
await card.waitFor()
|
||||
expect(await card.evaluate(element => [...element.children].map(child => child.textContent).slice(0, 3)))
|
||||
.toEqual([LABEL, `Owner: ${CHILD_NAME}`, 'completed · continuable'])
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import type { TeamProjection, TeamTaskView, TeamTaskId } from '@deepseek-ai/dsh-agent-team/client'
|
||||
import type {} from '@deepseek-ai/dsh-api-session-controller/client'
|
||||
import {
|
||||
HoverCard, HoverCardGroup, HoverDetails, IconChevronDownOutlineRegular,
|
||||
HoverCard, HoverCardGroup, IconChevronDownOutlineRegular,
|
||||
StateDot, Tooltip, type StateDotState,
|
||||
} from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { PropsLocale, PropsRenderFactories, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
@@ -71,7 +71,7 @@ function progressLabel(tasks: readonly VisibleTask[], t: TeamBoardProps['t']): s
|
||||
].join('\u2002·\u2002')
|
||||
}
|
||||
|
||||
function TaskRow({ task, rootId, expanded, onToggle, t }: Pick<TeamBoardProps, 't'> & {
|
||||
function TaskRow({ task, rootId, expanded, onToggle, renderFactorySlot, t }: Pick<TeamBoardProps, 'renderFactorySlot' | 't'> & {
|
||||
task: VisibleTask
|
||||
rootId: SessionId
|
||||
expanded: boolean
|
||||
@@ -103,13 +103,11 @@ function TaskRow({ task, rootId, expanded, onToggle, t }: Pick<TeamBoardProps, '
|
||||
<span className={css.chevron} aria-hidden><IconChevronDownOutlineRegular size={14} /></span>
|
||||
</button>
|
||||
)}
|
||||
content={(
|
||||
<HoverDetails
|
||||
title={task.subject}
|
||||
lines={[t('hover.owner', { name: owner }), ...task.description ? [task.description] : []]}
|
||||
status={{ state, label: status }}
|
||||
/>
|
||||
)}
|
||||
content={renderFactorySlot('conversation.session.panel.details', {
|
||||
title: task.subject,
|
||||
lines: [t('hover.owner', { name: owner }), ...task.description ? [task.description] : []],
|
||||
status: { state, label: status },
|
||||
})}
|
||||
/>
|
||||
{expanded && (
|
||||
<div className={css.details} id={detailsId} data-team-task-details>
|
||||
@@ -160,6 +158,7 @@ export function TeamBoard({ sessionId, useProjection, useStore, actions, renderF
|
||||
key={task.id} task={task} rootId={sessionId}
|
||||
expanded={expandedTaskId === task.id}
|
||||
onToggle={() => { setExpandedTaskId(current => current === task.id ? null : task.id) }}
|
||||
renderFactorySlot={renderFactorySlot}
|
||||
t={t}
|
||||
/>
|
||||
))}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { zh as commonZh } from '@deepseek-ai/dsh-client-locale/src/locales/zh.ts
|
||||
import { TeamBoard, TeamProgress, type TeamBoardProps, type TeamProgressProps } from '../src/client/TeamBoard.tsx'
|
||||
import { createTeamBoardStore } from '../src/client/team-board-store.ts'
|
||||
import { en, zh } from '../src/client/locales.ts'
|
||||
import type { PanelDetailsProps, PanelFoldProps } from '@deepseek-ai/dsh-client-ui-session-panel/client'
|
||||
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
@@ -51,11 +52,23 @@ function summary(id: SessionId, title?: string): SessionSummary {
|
||||
type BoardStore = ReturnType<ReturnType<typeof createTeamBoardStore>['create']>
|
||||
|
||||
/**
|
||||
* The Session panel's fold control Factory as this suite renders it: a button with its state, name, and label.
|
||||
* ui-session-panel's own suite owns the control's markup.
|
||||
* The Session panel's Factories as this suite renders them: the fold control as a button with its state, name, and
|
||||
* label, and a row's details as one element per part in order. ui-session-panel's own suite owns their markup.
|
||||
*/
|
||||
function renderFold(_name: string, input: { expanded: boolean; label: string; name: string; onToggle: () => void }) {
|
||||
return <button type="button" data-fold="" aria-expanded={input.expanded} aria-label={input.name} onClick={input.onToggle}>{input.label}</button>
|
||||
function renderPanelFactory(name: string, input: object) {
|
||||
if (name === 'conversation.session.panel.details') {
|
||||
const { title, lines = [], status, facts = [] } = input as PanelDetailsProps
|
||||
return (
|
||||
<div data-session-panel-details="">
|
||||
{title !== undefined && <div>{title}</div>}
|
||||
{lines.map(line => <div key={line}>{line}</div>)}
|
||||
{status !== undefined && <div data-state={status.state}>{status.label}</div>}
|
||||
{facts.length > 0 && <div>{facts.map(fact => <span key={fact.kind} data-fact={fact.kind}>{fact.label}</span>)}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const fold = input as PanelFoldProps
|
||||
return <button type="button" data-fold="" aria-expanded={fold.expanded} aria-label={fold.name} onClick={fold.onToggle}>{fold.label}</button>
|
||||
}
|
||||
|
||||
function bench(options: {
|
||||
@@ -80,7 +93,7 @@ function bench(options: {
|
||||
const props = {
|
||||
sessionId, useProjection,
|
||||
useSessions: bindSnapshotSelector(sessions),
|
||||
useStore: bindSnapshotSelector(store), actions: store.actions, renderFactorySlot: renderFold,
|
||||
useStore: bindSnapshotSelector(store), actions: store.actions, renderFactorySlot: renderPanelFactory,
|
||||
t: makeTranslate(zh, commonZh),
|
||||
} as TeamBoardProps
|
||||
return { props, sessions, store }
|
||||
@@ -458,7 +471,7 @@ describe('TeamBoard', () => {
|
||||
const button = row()
|
||||
const anchor = button.parentElement as HTMLElement
|
||||
const details = (): string[] | null => {
|
||||
const card = document.querySelector('[data-hover-details]')
|
||||
const card = document.querySelector('[data-session-panel-details]')
|
||||
return card === null ? null : [...card.children].map(child => child.textContent ?? '')
|
||||
}
|
||||
fireEvent.pointerEnter(anchor, { pointerType: 'mouse' })
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useId, useMemo, useRef, useState } from 'react'
|
||||
import type { JobsSnapshot, JobView, ObservedJob } from '@deepseek-ai/dsh-api-job-controller/client'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import {
|
||||
HoverCard, HoverCardGroup, HoverDetails, IconChevronDownOutlineRegular, IconClockOutlineRegular, IconStopFillRegular, MarqueeText,
|
||||
HoverCard, HoverCardGroup, IconChevronDownOutlineRegular, IconStopFillRegular, MarqueeText,
|
||||
StateDot, type StateDotState, TerminalBlock, type TerminalBlockLabels, Tooltip, useHoverMarquee,
|
||||
} from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { InjectFace, PropsLocale, PropsRenderFactories, PropsRuntime, PropsStore, TranslateNS } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
@@ -190,7 +190,7 @@ function ordered(jobs: readonly JobView[]): JobView[] {
|
||||
type KillState = 'idle' | 'armed' | 'pending' | 'failed'
|
||||
|
||||
/** One job row plus, when observable and expanded, its live output panel. */
|
||||
function JobItem({ job, view, expanded, now, onToggle, kill, t }: {
|
||||
function JobItem({ job, view, expanded, now, onToggle, kill, renderFactorySlot, t }: Pick<JobsSectionProps, 'renderFactorySlot'> & {
|
||||
job: JobView
|
||||
view: ObservedJob | undefined
|
||||
expanded: boolean
|
||||
@@ -233,13 +233,11 @@ function JobItem({ job, view, expanded, now, onToggle, kill, t }: {
|
||||
<HoverCard
|
||||
grouped
|
||||
disabled={onStop && kill !== undefined}
|
||||
content={(
|
||||
<HoverDetails
|
||||
lines={[job.kind]}
|
||||
status={{ state: dotState(job), label: state }}
|
||||
facts={[{ icon: <IconClockOutlineRegular />, label: duration }]}
|
||||
/>
|
||||
)}
|
||||
content={renderFactorySlot('conversation.session.panel.details', {
|
||||
lines: [job.kind],
|
||||
status: { state: dotState(job), label: state },
|
||||
facts: [{ kind: 'duration', label: duration }],
|
||||
})}
|
||||
anchor={(
|
||||
// A command its cell clips crawls into view while the pointer rests on the row.
|
||||
<div
|
||||
@@ -449,6 +447,7 @@ export function JobsSection({
|
||||
onToggle={() => {
|
||||
setExpandedKey(current => current === String(job.id) ? undefined : String(job.id))
|
||||
}}
|
||||
renderFactorySlot={renderFactorySlot}
|
||||
{...job.status === 'running' && mayKill
|
||||
? {
|
||||
kill: {
|
||||
|
||||
@@ -8,6 +8,7 @@ import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import { JobsRunningIndicator, JobsSection, type JobsRunningIndicatorProps, type JobsSectionProps } from '../src/client/JobsSection.tsx'
|
||||
import { createJobsSectionStore } from '../src/client/jobs-store.ts'
|
||||
import { en, zh, ru } from '../src/client/locales.ts'
|
||||
import type { PanelDetailsProps, PanelFoldProps } from '@deepseek-ai/dsh-client-ui-session-panel/client'
|
||||
|
||||
beforeEach(() => {
|
||||
class TooltipObserver implements ResizeObserver {
|
||||
@@ -61,11 +62,23 @@ function outputJob(over: Partial<JobView> = {}): JobView {
|
||||
type SectionStore = ReturnType<ReturnType<typeof createJobsSectionStore>['create']>
|
||||
|
||||
/**
|
||||
* The Session panel's fold control Factory as this suite renders it: a button with its state, name, and label.
|
||||
* ui-session-panel's own suite owns the control's markup.
|
||||
* The Session panel's Factories as this suite renders them: the fold control as a button with its state, name, and
|
||||
* label, and a row's details as one element per part in order. ui-session-panel's own suite owns their markup.
|
||||
*/
|
||||
function renderFold(_name: string, input: { expanded: boolean; label: string; name: string; onToggle: () => void }) {
|
||||
return <button type="button" data-fold="" aria-expanded={input.expanded} aria-label={input.name} onClick={input.onToggle}>{input.label}</button>
|
||||
function renderPanelFactory(name: string, input: object) {
|
||||
if (name === 'conversation.session.panel.details') {
|
||||
const { title, lines = [], status, facts = [] } = input as PanelDetailsProps
|
||||
return (
|
||||
<div data-session-panel-details="">
|
||||
{title !== undefined && <div>{title}</div>}
|
||||
{lines.map(line => <div key={line}>{line}</div>)}
|
||||
{status !== undefined && <div data-state={status.state}>{status.label}</div>}
|
||||
{facts.length > 0 && <div>{facts.map(fact => <span key={fact.kind} data-fact={fact.kind}>{fact.label}</span>)}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const fold = input as PanelFoldProps
|
||||
return <button type="button" data-fold="" aria-expanded={fold.expanded} aria-label={fold.name} onClick={fold.onToggle}>{fold.label}</button>
|
||||
}
|
||||
|
||||
/** Test-local selector hook over a framework-neutral store instance. */
|
||||
@@ -90,7 +103,7 @@ function props(
|
||||
}
|
||||
return {
|
||||
sessionId: SESSION, useJobs, watchRows, observe, killJob, useStore: hookOf(store), actions: store.actions, t,
|
||||
useAccess: () => mayKill, renderFactorySlot: renderFold,
|
||||
useAccess: () => mayKill, renderFactorySlot: renderPanelFactory,
|
||||
} as Pick<JobsSectionProps,
|
||||
'sessionId' | 'useJobs' | 'watchRows' | 'observe' | 'killJob' | 'useStore' | 'actions' | 't' | 'useAccess' | 'renderFactorySlot'> as JobsSectionProps
|
||||
}
|
||||
@@ -683,9 +696,9 @@ describe('JobsSection hover', () => {
|
||||
const anchor = row.parentElement as HTMLElement
|
||||
fireEvent.pointerEnter(anchor, { pointerType: 'mouse' })
|
||||
act(() => { vi.advanceTimersByTime(499) })
|
||||
expect(document.querySelector('[data-hover-details]')).toBeNull()
|
||||
expect(document.querySelector('[data-session-panel-details]')).toBeNull()
|
||||
act(() => { vi.advanceTimersByTime(1) })
|
||||
const card = document.querySelector('[data-hover-details]') as HTMLElement
|
||||
const card = document.querySelector('[data-session-panel-details]') as HTMLElement
|
||||
expect([...card.children].map(child => child.textContent)).toEqual(['bash', '运行中', '10秒'])
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
@@ -703,7 +716,7 @@ describe('JobsSection hover', () => {
|
||||
fireEvent.pointerEnter(anchor, { pointerType: 'mouse' })
|
||||
fireEvent.pointerEnter(stop, { pointerType: 'mouse' })
|
||||
act(() => { vi.advanceTimersByTime(1000) })
|
||||
expect(document.querySelector('[data-hover-details]')).toBeNull()
|
||||
expect(document.querySelector('[data-session-panel-details]')).toBeNull()
|
||||
expect(screen.getByRole('tooltip', { hidden: true }).textContent).toBe(zh['kill.stop'])
|
||||
fireEvent.pointerLeave(stop, { pointerType: 'mouse' })
|
||||
fireEvent.pointerLeave(anchor, { pointerType: 'mouse' })
|
||||
@@ -711,10 +724,10 @@ describe('JobsSection hover', () => {
|
||||
// A card the row opened closes once the pointer reaches the stop control.
|
||||
fireEvent.pointerEnter(anchor, { pointerType: 'mouse' })
|
||||
act(() => { vi.advanceTimersByTime(500) })
|
||||
expect(document.querySelector('[data-hover-details]')).not.toBeNull()
|
||||
expect(document.querySelector('[data-session-panel-details]')).not.toBeNull()
|
||||
fireEvent.pointerEnter(stop, { pointerType: 'mouse' })
|
||||
act(() => { vi.advanceTimersByTime(1000) })
|
||||
expect(document.querySelector('[data-hover-details]')).toBeNull()
|
||||
expect(document.querySelector('[data-session-panel-details]')).toBeNull()
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
en: 33a5b39959a595c6
|
||||
zh: efd1088e9f13ed67
|
||||
/deepseek-ai-dsh-client-ui-primitives/use-this-package/component-catalog:
|
||||
en: fd5a93dfbab3c456
|
||||
zh: b246d0ca77f063fb
|
||||
en: bd746373375bcd7a
|
||||
zh: f37e43b679c06229
|
||||
/deepseek-ai-dsh-client-ui-primitives/use-this-package/controls-and-icons:
|
||||
en: fd3499ef403a0594
|
||||
zh: 3a17727316d3c666
|
||||
|
||||
@@ -66,7 +66,6 @@ Check this table before writing a control in a feature package. A plugin cannot
|
||||
| `RiskConfirmation` | Sensitive action gated behind an explicit checkbox, using the shared warning-title layout. |
|
||||
| `Tooltip` | Hover and keyboard-focus text anchored to a cloned child; optional `delayMs` controls hover delay and `focusDelayMs` controls keyboard-focus delay, both defaulting to 0 ms. Optional `portal` rendering escapes clipping containers and ancestor stacking contexts that cap the bubble's z-index. |
|
||||
| `HoverCard`, `HoverCardGroup` | Readable, optionally copyable hover preview; a physical list can opt cards into shared first-display dwell and exclusive display. A compact card opens beside the anchor's end edge, or beside its start edge when it would cross the viewport's end and fits there, as for rows of a panel at the window's end; with room on neither side it keeps to the viewport's end margin over the anchor. |
|
||||
| `HoverDetails` | Body of a HoverCard that details a summary-panel row on the card's dark surface: an optional title, which wraps, secondary lines such as the owner, the state after its dot, and measures such as tokens and duration after 14px icons. |
|
||||
| `DraggableImage` | Original-image gestures with explicit transfer and feedback callbacks. |
|
||||
| `ImageLightbox` | Shared image modal with focus restoration and Escape dismissal. |
|
||||
| `usePointerGrace` | Cancelable dismissal delay that lets the pointer cross the gap between a trigger and its card; pending timers are cleared on unmount. |
|
||||
|
||||
@@ -66,7 +66,6 @@ kind: "package-library"
|
||||
| `RiskConfirmation` | 以显式复选框把关的敏感操作确认,采用共用的警告标题布局。 |
|
||||
| `Tooltip` | 锚定在克隆子元素上的悬停与键盘聚焦提示;可选的 `delayMs` 控制悬停延迟,`focusDelayMs` 控制键盘聚焦延迟,均默认为 0 毫秒。可通过 `portal` 渲染到外层,避免被容器裁剪,或受祖先层叠上下文限制其 z-index。 |
|
||||
| `HoverCard`、`HoverCardGroup` | 可阅读、可选带复制按钮的悬停预览;物理列表可选择让卡片共享首次显示等待,并互斥显示。紧凑卡片出现在锚点结束一侧;会超出视口结束边缘、而开始一侧放得下时出现在开始一侧,例如窗口末端面板中的行;两侧都放不下时贴着视口结束边缘的留白,盖在锚点上。 |
|
||||
| `HoverDetails` | 在 HoverCard 深色底面上说明摘要面板某一行的卡片内容:可选且可换行的标题、负责人等次要文字行、状态点及状态,以及带 14px 图标的 token、用时等度量。 |
|
||||
| `DraggableImage` | 通过显式传递与反馈回调提供原图拖放。 |
|
||||
| `ImageLightbox` | 共享图片浮层,支持焦点恢复与 Esc 关闭。 |
|
||||
| `usePointerGrace` | 可取消的延迟关闭,让指针能够跨越触发控件与卡片间的空隙;卸载时清除待执行定时器。 |
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/** Body of a HoverCard that details one row of a summary panel. */
|
||||
|
||||
import type { ReactNode } from 'react'
|
||||
import { StateDot, type StateDotState } from './StateDot.tsx'
|
||||
import css from './HoverDetails.module.css'
|
||||
|
||||
/** What a row's hover card says about it. */
|
||||
export interface HoverDetailsProps {
|
||||
/**
|
||||
* The full name of what the row shows; it wraps instead of clipping. Omit it
|
||||
* when the name can run long, such as a command, and the row's own view
|
||||
* shows it in full.
|
||||
*/
|
||||
readonly title?: ReactNode
|
||||
/** Lines in secondary type under the title, such as the owner; each stops after six lines. */
|
||||
readonly lines?: readonly ReactNode[]
|
||||
/** The state, after its dot. */
|
||||
readonly status?: { readonly state: StateDotState; readonly label: string } | undefined
|
||||
/** Measures on one line, each after its 14px icon, such as tokens and duration. */
|
||||
readonly facts?: readonly { readonly icon: ReactNode; readonly label: string }[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the details of one summary-panel row for its HoverCard, on the card's
|
||||
* dark surface in both themes: the title, secondary lines, the state, and the
|
||||
* measures. Absent or empty parts render nothing.
|
||||
* @param props - title, lines, state, and measures.
|
||||
* @returns the card body.
|
||||
*/
|
||||
export function HoverDetails({ title, lines = [], status, facts = [] }: HoverDetailsProps): ReactNode {
|
||||
return (
|
||||
<div className={css.details} data-hover-details="">
|
||||
{title !== undefined && <div className={css.title}>{title}</div>}
|
||||
{lines.map((line, index) => <div key={index} className={css.line}>{line}</div>)}
|
||||
{status !== undefined && (
|
||||
<div className={css.status}>
|
||||
<StateDot state={status.state} />
|
||||
<span>{status.label}</span>
|
||||
</div>
|
||||
)}
|
||||
{facts.length > 0 && (
|
||||
<div className={css.facts}>
|
||||
{facts.map(fact => (
|
||||
<span key={fact.label} className={css.fact}>
|
||||
<span className={css.factIcon} aria-hidden="true">{fact.icon}</span>
|
||||
{fact.label}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -27,8 +27,6 @@ export { Tag } from './Tag.tsx'
|
||||
export type { TagTone } from './Tag.tsx'
|
||||
export { PathLabel } from './PathLabel.tsx'
|
||||
export { MarqueeText, useHoverMarquee } from './Marquee.tsx'
|
||||
export { HoverDetails } from './HoverDetails.tsx'
|
||||
export type { HoverDetailsProps } from './HoverDetails.tsx'
|
||||
export type { HoverMarquee, MarqueeTextProps } from './Marquee.tsx'
|
||||
export { Switch } from './Switch.tsx'
|
||||
export { SegmentedControl } from './SegmentedControl.tsx'
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
// @vitest-environment jsdom
|
||||
import { cleanup, render, screen } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { HoverDetails } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
describe('HoverDetails', () => {
|
||||
it('stacks the title, lines, state, and measures in order', () => {
|
||||
const view = render(
|
||||
<HoverDetails
|
||||
title="Survey open-source harnesses"
|
||||
lines={['Owner: open-source-arch']}
|
||||
status={{ state: 'done', label: 'Completed' }}
|
||||
facts={[{ icon: <svg data-testid="tokens" />, label: '3.3M tok' }, { icon: <svg />, label: '6m 56s' }]}
|
||||
/>,
|
||||
)
|
||||
const root = view.container.querySelector('[data-hover-details]') as HTMLElement
|
||||
expect([...root.children].map(child => child.textContent))
|
||||
.toEqual(['Survey open-source harnesses', 'Owner: open-source-arch', 'Completed', '3.3M tok6m 56s'])
|
||||
expect(root.children[2]?.querySelector('[data-state="done"]')).not.toBeNull()
|
||||
expect(screen.getByTestId('tokens').parentElement?.getAttribute('aria-hidden')).toBe('true')
|
||||
})
|
||||
|
||||
it('renders only the title when nothing else is given', () => {
|
||||
const view = render(<HoverDetails title="sleep 30" />)
|
||||
expect((view.container.querySelector('[data-hover-details]') as HTMLElement).children).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('starts with the lines when the title is omitted', () => {
|
||||
const view = render(<HoverDetails lines={['bash']} status={{ state: 'ongoing', label: 'running' }} />)
|
||||
expect([...(view.container.querySelector('[data-hover-details]') as HTMLElement).children].map(child => child.textContent))
|
||||
.toEqual(['bash', 'running'])
|
||||
})
|
||||
})
|
||||
@@ -21,11 +21,11 @@
|
||||
en: 67b33b9f412a687d
|
||||
zh: 2a9b8c89c8bb22e4
|
||||
/deepseek-ai-dsh-client-ui-session-panel/use-this-package/contribute-a-section:
|
||||
en: d3ac82caeb26cf10
|
||||
zh: 58e56d35f6f9c8da
|
||||
en: b76852d8740aee0f
|
||||
zh: ccfeb7774e1b0e27
|
||||
/deepseek-ai-dsh-client-ui-session-panel/understand-the-implementation:
|
||||
en: c07801d6f61a5868
|
||||
zh: d04b6cdff989018a
|
||||
en: ede595ecc4aab24a
|
||||
zh: 5a30a4042ab7483a
|
||||
/deepseek-ai-dsh-client-ui-session-panel/further-exploration:
|
||||
en: 09b403af819bd155
|
||||
zh: e949998de4794393
|
||||
|
||||
@@ -61,6 +61,8 @@ Leave out a part the row does not have: a `<button>` body or a menu part is what
|
||||
|
||||
A section whose list can grow long folds it. It shows the first five rows of the list, or of each group the list has, and then a fold control as the last row, which shows the rest or folds them again. A list folds only when that holds back two rows or more, since the control takes a row itself, and it orders its rows so that the ones it holds back are the least current. The plugin offers the control as the `conversation.session.panel.fold` Component Factory: `renderFactorySlot('conversation.session.panel.fold', { expanded, label, name, onToggle })` renders a row marked `data-session-panel-row="fold"` whose body is the button, in the 12px tertiary type of the section counts, with a 14px chevron in the icon column that points down while rows are held back and up once they all show. `label` is the visible text for the current state, such as “Show 14 more” or “Show less”, and `name` is the accessible name, which starts with `label` and names what the list holds. The section keeps the fold state and decides which rows show; a store declared on its registration keeps the choice while the panel is hidden.
|
||||
|
||||
A row whose single line clips its name or leaves out its owner, state, or measures shows them in a hover card. The plugin offers the card's content as the `conversation.session.panel.details` Component Factory: wrap the row in a `HoverCard` and pass `renderFactorySlot('conversation.session.panel.details', { title, lines, status, facts })` as its `content`. Every prop is optional data. `title` is the row's full name, which wraps; leave it out when the name can run long, such as a command, and the row's own view shows it in full. `lines` are secondary lines such as the owner, each stopping after six lines. `status` is a `StateDot` state with its label. `facts` are measures on one line, at most one of each `kind`: `tokens` after a database icon and `duration` after a clock, each with its `label`. The details use the card's dark surface in both themes.
|
||||
|
||||
-----
|
||||
|
||||
<a id="understand-the-implementation"></a>
|
||||
@@ -84,6 +86,7 @@ The panel projects the section list's live registrations (`entriesOfSlot`, so a
|
||||
| [`src/client/SessionPanel.module.css`](src/client/SessionPanel.module.css) | The panel's geometry, the dock probe, and the rules for marked rows |
|
||||
| [`src/client/ProjectRow.tsx`](src/client/ProjectRow.tsx) | The working folder row |
|
||||
| [`src/client/PanelFold.tsx`](src/client/PanelFold.tsx) | The fold control of a folded list, offered as a Component Factory |
|
||||
| [`src/client/PanelDetails.tsx`](src/client/PanelDetails.tsx) | The details in a row's hover card, offered as a Component Factory |
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ kind: "package-reference"
|
||||
|
||||
列表可能很长的分栏会把它收起:只显示列表(或列表里每个分组)的前五行,然后以收起控件作为最后一行,用来显示其余的行或再次收起。只有这样做能收起两行及以上时才收起,因为控件自己也占一行;列表按顺序排列,使被收起的是最不需要看的行。插件把这个控件作为 Component Factory `conversation.session.panel.fold` 提供:`renderFactorySlot('conversation.session.panel.fold', { expanded, label, name, onToggle })` 渲染一个标记为 `data-session-panel-row="fold"` 的行,body 就是按钮,使用分栏计数的 12px 三级文字,图标列里是 14px 的箭头,还有行被收起时朝下,全部显示后朝上。`label` 是当前状态的可见文字,例如「显示其余 14 个」或「收起」;`name` 是无障碍名称,以 `label` 开头并说明列表里是什么。收起状态由分栏保存,显示哪些行也由分栏决定;在注册上声明 store 可以让这个选择在面板隐藏期间保留。
|
||||
|
||||
单行显示会截断名称,或放不下负责人、状态、度量的行,把这些内容放进悬停卡片。插件把卡片内容作为 Component Factory `conversation.session.panel.details` 提供:用 `HoverCard` 包住行,并把 `renderFactorySlot('conversation.session.panel.details', { title, lines, status, facts })` 作为它的 `content`。所有属性都是可选的数据。`title` 是行的完整名称,可以换行;名称可能很长(例如命令)而行自己的视图会完整显示它时,不要传。`lines` 是负责人等次要文字行,每行最多显示六行。`status` 是 `StateDot` 的状态及其文字。`facts` 是排在一行里的度量,每种 `kind` 最多一个:`tokens` 前面是数据库图标,`duration` 前面是时钟图标,各带自己的 `label`。卡片内容在两种主题下都使用卡片的深色底面。
|
||||
|
||||
-----
|
||||
|
||||
<a id="understand-the-implementation"></a>
|
||||
@@ -84,6 +86,7 @@ kind: "package-reference"
|
||||
| [`src/client/SessionPanel.module.css`](src/client/SessionPanel.module.css) | 面板的几何、停靠探针,以及带标记的行的样式规则 |
|
||||
| [`src/client/ProjectRow.tsx`](src/client/ProjectRow.tsx) | 工作目录行 |
|
||||
| [`src/client/PanelFold.tsx`](src/client/PanelFold.tsx) | 被收起列表的收起控件,以 Component Factory 提供 |
|
||||
| [`src/client/PanelDetails.tsx`](src/client/PanelDetails.tsx) | 行的悬停卡片里的详情,以 Component Factory 提供 |
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
+4
-3
@@ -1,6 +1,7 @@
|
||||
/* A row's hover card body, on the HoverCard's dark surface in both themes: the
|
||||
title in primary ink, lines in secondary ink, then the state and measures in
|
||||
tertiary ink, as the sidebar's Session hover card sets them. */
|
||||
/* The details of a panel row in its HoverCard, on the card's dark surface in
|
||||
both themes: the title in primary ink, lines in secondary ink, then the
|
||||
state and measures in tertiary ink, as the sidebar's Session hover card sets
|
||||
them. */
|
||||
.details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* The details of one Session panel row, shown in the row's HoverCard. The
|
||||
* plugin offers it as the `conversation.session.panel.details` Component
|
||||
* Factory, so the rows of every section describe themselves alike.
|
||||
*/
|
||||
import type { ReactNode } from 'react'
|
||||
import { IconClockOutlineRegular, IconDatabaseOutlineRegular, StateDot } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { FactoryComponentPropsOf } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { PanelDetailsFact } from './slots.ts'
|
||||
import css from './PanelDetails.module.css'
|
||||
|
||||
const factIcons = {
|
||||
tokens: IconDatabaseOutlineRegular,
|
||||
duration: IconClockOutlineRegular,
|
||||
} satisfies Record<PanelDetailsFact['kind'], typeof IconClockOutlineRegular>
|
||||
|
||||
/**
|
||||
* Render a row's details on the HoverCard's dark surface in both themes: the
|
||||
* title, secondary lines, the state after its dot, and the measures on one
|
||||
* line, each after the 14px icon of its kind. Absent or empty parts render
|
||||
* nothing.
|
||||
* @param props - title, lines, state, and measures.
|
||||
* @returns the card body.
|
||||
*/
|
||||
export function PanelDetails({
|
||||
title, lines = [], status, facts = [],
|
||||
}: FactoryComponentPropsOf<'conversation.session.panel.details'>): ReactNode {
|
||||
return (
|
||||
<div className={css.details} data-session-panel-details="">
|
||||
{title !== undefined && <div className={css.title}>{title}</div>}
|
||||
{lines.map((line, index) => <div key={index} className={css.line}>{line}</div>)}
|
||||
{status !== undefined && (
|
||||
<div className={css.status}>
|
||||
<StateDot state={status.state} />
|
||||
<span>{status.label}</span>
|
||||
</div>
|
||||
)}
|
||||
{facts.length > 0 && (
|
||||
<div className={css.facts}>
|
||||
{facts.map((fact) => {
|
||||
const Icon = factIcons[fact.kind]
|
||||
return (
|
||||
<span key={fact.kind} className={css.fact} data-fact={fact.kind}>
|
||||
<span className={css.factIcon} aria-hidden="true"><Icon /></span>
|
||||
{fact.label}
|
||||
</span>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -2,8 +2,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, lays out the rows they mark, offers the fold control
|
||||
* their lists end with, and ships the Environment section with the working
|
||||
* folder row.
|
||||
* their lists end with and the details their rows show on hover, and ships the
|
||||
* Environment section with the working folder row.
|
||||
*/
|
||||
import type { Context as ClientContext } from '@deepseek-ai/cordis'
|
||||
import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store'
|
||||
@@ -14,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 { PanelDetails } from './PanelDetails.tsx'
|
||||
import { PanelFold } from './PanelFold.tsx'
|
||||
import { ProjectRow } from './ProjectRow.tsx'
|
||||
import { SessionPanel } from './SessionPanel.tsx'
|
||||
@@ -31,17 +32,18 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
||||
}
|
||||
|
||||
export type {
|
||||
EnvironmentSectionProps, PanelFoldProps, ProjectRowInjected, ProjectRowProps, SessionPanelDockable, SessionPanelIndicatorOwnerProps,
|
||||
SessionPanelInjected, SessionPanelPresentation, SessionPanelProbes, SessionPanelProps, SessionPanelSectionEntry,
|
||||
SessionPanelSectionOwnerProps, SessionPanelToggleInjected, SessionPanelToggleProps, SessionPanelVisibility,
|
||||
EnvironmentSectionProps, PanelDetailsFact, PanelDetailsProps, PanelFoldProps, ProjectRowInjected, ProjectRowProps, SessionPanelDockable,
|
||||
SessionPanelIndicatorOwnerProps, SessionPanelInjected, SessionPanelPresentation, SessionPanelProbes, SessionPanelProps,
|
||||
SessionPanelSectionEntry, SessionPanelSectionOwnerProps, SessionPanelToggleInjected, SessionPanelToggleProps, SessionPanelVisibility,
|
||||
} from './slots.ts'
|
||||
|
||||
/** Required services: the slot registry, dictionaries, and the Host facts of the Remote carrier. */
|
||||
export const inject = ['slots', 'locale', 'remote']
|
||||
|
||||
/**
|
||||
* Client plugin body: register the dictionaries, the fold control Factory, the
|
||||
* header toggle, the panel, and the Environment section with its project row.
|
||||
* Client plugin body: register the dictionaries, the fold control and row
|
||||
* details Factories, the header toggle, the panel, and the Environment section
|
||||
* with its project row.
|
||||
* @param ctx - client root context.
|
||||
*/
|
||||
export function apply(ctx: ClientContext): void {
|
||||
@@ -56,6 +58,7 @@ export function apply(ctx: ClientContext): void {
|
||||
}
|
||||
|
||||
ctx.slots.registerFactory({ name: 'conversation.session.panel.fold', scope: 'root' }, PanelFold)
|
||||
ctx.slots.registerFactory({ name: 'conversation.session.panel.details', scope: 'root' }, PanelDetails)
|
||||
|
||||
ctx.slots.inject('conversation.session.header.utilities', () => ctx.slots.register({
|
||||
name: 'conversation.session.header.utilities',
|
||||
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
} from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { RemoteHostFacts } from '@deepseek-ai/dsh-api-remotes/client'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import type { StateDotState } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-conversation/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-chat/client'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-context-menu/client'
|
||||
@@ -52,9 +53,40 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
||||
* decides which rows show.
|
||||
*/
|
||||
'conversation.session.panel.fold': { scope: 'root'; props: PanelFoldProps }
|
||||
/**
|
||||
* The details of one panel row, for the content of the row's HoverCard: the
|
||||
* row's full name, secondary lines such as its owner, its state, and its
|
||||
* measures. A row whose single line clips or leaves these out shows them
|
||||
* here.
|
||||
*/
|
||||
'conversation.session.panel.details': { scope: 'root'; props: PanelDetailsProps }
|
||||
}
|
||||
}
|
||||
|
||||
/** What a panel row's hover card says about the row. */
|
||||
export interface PanelDetailsProps {
|
||||
/**
|
||||
* The full name of what the row shows; it wraps instead of clipping. Omit it
|
||||
* when the name can run long, such as a command, and the row's own view
|
||||
* shows it in full.
|
||||
*/
|
||||
readonly title?: string | undefined
|
||||
/** Lines in secondary type under the title, such as the owner; each stops after six lines. */
|
||||
readonly lines?: readonly string[] | undefined
|
||||
/** The state, after its dot. */
|
||||
readonly status?: { readonly state: StateDotState; readonly label: string } | undefined
|
||||
/** Measures on one line, at most one of each kind. */
|
||||
readonly facts?: readonly PanelDetailsFact[] | undefined
|
||||
}
|
||||
|
||||
/** One measure in a panel row's hover card. */
|
||||
export interface PanelDetailsFact {
|
||||
/** What the measure counts, which selects its icon: a database for `tokens`, a clock for `duration`. */
|
||||
readonly kind: 'tokens' | 'duration'
|
||||
/** The measure as the card shows it, such as "3.3M tok" or "6m 56s". */
|
||||
readonly label: string
|
||||
}
|
||||
|
||||
/** Props of the fold control that ends a folded panel list. */
|
||||
export interface PanelFoldProps {
|
||||
/** Whether the list shows every row; the control then folds it again. */
|
||||
|
||||
@@ -57,9 +57,10 @@ describe('ui-session-panel browser half', () => {
|
||||
expect(inject).toEqual(['slots', 'locale', 'remote'])
|
||||
})
|
||||
|
||||
it('registers the fold control Factory, the toggle first among the header utilities, the panel in the Chat aside, the Environment section, and the project row', async () => {
|
||||
it('registers the fold control and row details Factories, 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.fold')).toHaveLength(1)
|
||||
expect(ctx.slots.snapshot('factory:conversation.session.panel.details')).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)
|
||||
@@ -130,6 +131,7 @@ describe('ui-session-panel browser half', () => {
|
||||
const { ctx, fiber } = await bench()
|
||||
await fiber.dispose()
|
||||
expect(ctx.slots.snapshot('factory:conversation.session.panel.fold')).toHaveLength(0)
|
||||
expect(ctx.slots.snapshot('factory:conversation.session.panel.details')).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)
|
||||
|
||||
@@ -7,13 +7,14 @@ import { bindSnapshotSelector, contextMenuHook, makeTranslate } from '@deepseek-
|
||||
import type { FactoryComponentPropsOf } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import { EnvironmentSection } from '../src/client/EnvironmentSection.tsx'
|
||||
import { PanelDetails } from '../src/client/PanelDetails.tsx'
|
||||
import { PanelFold } from '../src/client/PanelFold.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, SessionPanelDockable, SessionPanelProbes, SessionPanelProps, SessionPanelSectionEntry,
|
||||
SessionPanelSectionOwnerProps, SessionPanelToggleProps, SessionPanelVisibility,
|
||||
EnvironmentSectionProps, PanelDetailsProps, ProjectRowProps, SessionPanelDockable, SessionPanelProbes, SessionPanelProps,
|
||||
SessionPanelSectionEntry, SessionPanelSectionOwnerProps, SessionPanelToggleProps, SessionPanelVisibility,
|
||||
} from '../src/client/slots.ts'
|
||||
import { SessionPanelState } from '../src/client/visibility.ts'
|
||||
import { en, zh } from '../src/client/locales.ts'
|
||||
@@ -505,6 +506,41 @@ describe('PanelFold', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('PanelDetails', () => {
|
||||
/** Render the details with the props a row passes; the renderer's standard seats are left out, as the details read none. */
|
||||
function details(input: PanelDetailsProps): HTMLElement {
|
||||
const view = render(<PanelDetails {...input as FactoryComponentPropsOf<'conversation.session.panel.details'>} />)
|
||||
return view.container.querySelector('[data-session-panel-details]') as HTMLElement
|
||||
}
|
||||
|
||||
it('stacks the title, lines, state, and measures in order, each measure after the icon of its kind', () => {
|
||||
const root = details({
|
||||
title: 'Survey open-source harnesses',
|
||||
lines: ['Owner: open-source-arch'],
|
||||
status: { state: 'done', label: 'Completed' },
|
||||
facts: [{ kind: 'tokens', label: '3.3M tok' }, { kind: 'duration', label: '6m 56s' }],
|
||||
})
|
||||
expect([...root.children].map(child => child.textContent))
|
||||
.toEqual(['Survey open-source harnesses', 'Owner: open-source-arch', 'Completed', '3.3M tok6m 56s'])
|
||||
expect(root.children[2]?.querySelector('[data-state="done"]')).not.toBeNull()
|
||||
const facts = [...(root.children[3] as HTMLElement).children]
|
||||
expect(facts.map(fact => [fact.getAttribute('data-fact'), fact.querySelector('svg')?.getAttribute('data-icon')])).toEqual([
|
||||
['tokens', 'dsw-icon-database-outline-regular'],
|
||||
['duration', 'dsw-icon-clock-outline-regular'],
|
||||
])
|
||||
expect(facts.every(fact => fact.firstElementChild?.getAttribute('aria-hidden') === 'true')).toBe(true)
|
||||
})
|
||||
|
||||
it('renders only the title when nothing else is given', () => {
|
||||
expect(details({ title: 'sleep 30' }).children).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('starts with the lines when the title is omitted', () => {
|
||||
const root = details({ lines: ['bash'], status: { state: 'ongoing', label: 'running' } })
|
||||
expect([...root.children].map(child => child.textContent)).toEqual(['bash', 'running'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('dictionaries', () => {
|
||||
it('keeps the English dictionary key-identical to the Chinese source of truth', () => {
|
||||
expect(Object.keys(en).sort()).toEqual(Object.keys(zh).sort())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** Subagent catalog tree shared by the Session panel section and the breadcrumb switcher. */
|
||||
import { useEffect, useRef, useState, type KeyboardEvent, type MouseEvent } from 'react'
|
||||
import { useEffect, useRef, useState, type KeyboardEvent, type MouseEvent, type ReactNode } from 'react'
|
||||
import type {
|
||||
SessionListState, SessionProjectionMap, SessionProjectionSnapshot, SessionSummary,
|
||||
} from '@deepseek-ai/dsh-api-session-controller/client'
|
||||
@@ -7,9 +7,9 @@ import type { SessionStatusSnapshot } from '@deepseek-ai/dsh-client-ui-session-s
|
||||
import type { SubagentAddress } from '@deepseek-ai/dsh-subagent/client'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
||||
import {
|
||||
HoverCard, HoverDetails, IconCheckOutlineRegular, IconChevronRightOutlineRegular, IconClockOutlineRegular, IconDatabaseOutlineRegular,
|
||||
IconRefreshOutlineRegular, StateDot, Tooltip,
|
||||
HoverCard, IconCheckOutlineRegular, IconChevronRightOutlineRegular, IconRefreshOutlineRegular, StateDot, Tooltip,
|
||||
} from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { PanelDetailsProps } from '@deepseek-ai/dsh-client-ui-session-panel/client'
|
||||
import type { TranslateNS } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { NS } from './locales.ts'
|
||||
import type {} from '@deepseek-ai/dsh-token-meter/client'
|
||||
@@ -46,8 +46,7 @@ interface CatalogRowsProps {
|
||||
refreshProjection: (parentSessionId: SessionId) => void
|
||||
toggleBranch: (childSessionId: SessionId) => void
|
||||
closeCatalog: () => void
|
||||
/** One-line rows whose name, owner, state, and measures show in a hover card. */
|
||||
dense: boolean
|
||||
panelDetails: CatalogTreeProps['panelDetails']
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,8 +220,9 @@ function catalogProgress(entries: SubagentCatalogSnapshot['entries'], summaries:
|
||||
/** Render one catalog level and recurse only through explicitly expanded rows. */
|
||||
function CatalogRows({
|
||||
parentSessionId, currentSessionId, catalog, catalogs, summaries, expanded, level,
|
||||
openChild, openChildAside, refreshProjection, toggleBranch, closeCatalog, dense, t,
|
||||
openChild, openChildAside, refreshProjection, toggleBranch, closeCatalog, panelDetails, t,
|
||||
}: CatalogRowsProps & { t: TranslateNS<typeof NS> }) {
|
||||
const dense = panelDetails !== undefined
|
||||
const [now, setNow] = useState(() => Date.now())
|
||||
const running = catalog.entries.some(entry => entry.activity === 'running')
|
||||
useEffect(() => {
|
||||
@@ -399,17 +399,15 @@ function CatalogRows({
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
const details = (
|
||||
<HoverDetails
|
||||
title={primaryLabel}
|
||||
lines={secondaryLabel === undefined ? [] : [t('hover.owner', { name: secondaryLabel })]}
|
||||
status={{ state: dotState, label: [activity, mode].filter(value => value !== undefined).join(' · ') }}
|
||||
facts={[
|
||||
...tokenMetric === undefined ? [] : [{ icon: <IconDatabaseOutlineRegular />, label: tokenMetric }],
|
||||
...durationMetric === undefined ? [] : [{ icon: <IconClockOutlineRegular />, label: durationMetric.exact }],
|
||||
]}
|
||||
/>
|
||||
)
|
||||
const details = panelDetails?.({
|
||||
title: primaryLabel,
|
||||
lines: secondaryLabel === undefined ? [] : [t('hover.owner', { name: secondaryLabel })],
|
||||
status: { state: dotState, label: [activity, mode].filter(value => value !== undefined).join(' · ') },
|
||||
facts: [
|
||||
...tokenMetric === undefined ? [] : [{ kind: 'tokens' as const, label: tokenMetric }],
|
||||
...durationMetric === undefined ? [] : [{ kind: 'duration' as const, label: durationMetric.exact }],
|
||||
],
|
||||
})
|
||||
|
||||
return (
|
||||
<div key={entry.id} className={css.node}>
|
||||
@@ -438,7 +436,7 @@ function CatalogRows({
|
||||
refreshProjection={refreshProjection}
|
||||
toggleBranch={toggleBranch}
|
||||
closeCatalog={closeCatalog}
|
||||
dense={dense}
|
||||
panelDetails={panelDetails}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
@@ -521,8 +519,12 @@ export interface CatalogTreeProps {
|
||||
onOpened: () => void
|
||||
/** Focus the first row on mount, as a keyboard-opened popover does. */
|
||||
focusFirst?: boolean
|
||||
/** One-line rows whose name, owner, state, and measures show in a hover card, as the Session panel lists them. */
|
||||
dense?: boolean
|
||||
/**
|
||||
* Renders the Session panel's row details. With it the tree lists one-line
|
||||
* rows, as the Session panel does, and each row shows its name, owner,
|
||||
* state, and measures in a hover card.
|
||||
*/
|
||||
panelDetails?: ((details: PanelDetailsProps) => ReactNode) | undefined
|
||||
t: TranslateNS<typeof NS>
|
||||
}
|
||||
|
||||
@@ -535,7 +537,7 @@ export interface CatalogTreeProps {
|
||||
*/
|
||||
export function CatalogTree({
|
||||
rootSessionId, currentSessionId, catalog, catalogs, summaries,
|
||||
openChild, openChildAside, prepareLevel, onOpened, focusFirst = false, dense = false, t,
|
||||
openChild, openChildAside, prepareLevel, onOpened, focusFirst = false, panelDetails, t,
|
||||
}: CatalogTreeProps) {
|
||||
const [expanded, setExpanded] = useState<ReadonlySet<SessionId>>(() => new Set())
|
||||
const treeRef = useRef<HTMLDivElement>(null)
|
||||
@@ -592,7 +594,7 @@ export function CatalogTree({
|
||||
refreshProjection={prepareLevel}
|
||||
toggleBranch={toggleBranch}
|
||||
closeCatalog={onOpened}
|
||||
dense={dense}
|
||||
panelDetails={panelDetails}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/** Session panel section listing the current Session's subagents. */
|
||||
import { useMemo } from 'react'
|
||||
import { useCallback, useMemo } from 'react'
|
||||
import { HoverCardGroup } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { InjectFace, PropsLocale, PropsRenderFactories, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { NS } from './locales.ts'
|
||||
import type {} from '@deepseek-ai/dsh-client-ui-session-panel/client'
|
||||
import type { PanelDetailsProps } from '@deepseek-ai/dsh-client-ui-session-panel/client'
|
||||
import {
|
||||
CatalogTree, deriveCatalogs, levelPreparer, progressOf, type Catalogs, type SubagentCatalogInjected, type SubagentCatalogSnapshot,
|
||||
} from './SubagentCatalog.tsx'
|
||||
@@ -100,6 +100,9 @@ export function SubagentsSection({
|
||||
const catalog = catalogs[sessionId]
|
||||
const unfolded = useStore(state => state.unfolded)
|
||||
const prepareLevel = useMemo(() => levelPreparer(prepareCatalog), [prepareCatalog])
|
||||
const panelDetails = useCallback(
|
||||
(details: PanelDetailsProps) => renderFactorySlot('conversation.session.panel.details', details), [renderFactorySlot],
|
||||
)
|
||||
const ordered = useMemo(() => catalog === undefined ? NO_ENTRIES : sectionOrder(catalog.entries, summaries), [catalog, summaries])
|
||||
// Folding holds back two rows or more, since the fold control takes a row itself.
|
||||
const foldable = ordered.length > FOLD_LIMIT + 1
|
||||
@@ -122,7 +125,7 @@ export function SubagentsSection({
|
||||
openChildAside={openChildAside}
|
||||
prepareLevel={prepareLevel}
|
||||
onOpened={dismissOverlay}
|
||||
dense
|
||||
panelDetails={panelDetails}
|
||||
t={t}
|
||||
/>
|
||||
</HoverCardGroup>
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
import { SubagentReadOnlyComposer } from '../src/client/SubagentReadOnlyComposer.tsx'
|
||||
import { createSubagentsSectionStore } from '../src/client/subagents-store.ts'
|
||||
import { en, zh } from '../src/client/locales.ts'
|
||||
import type { PanelDetailsProps, PanelFoldProps } from '@deepseek-ai/dsh-client-ui-session-panel/client'
|
||||
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
@@ -188,7 +189,7 @@ async function hoverDetailsOf(row: HTMLElement): Promise<string[] | null> {
|
||||
const anchor = row.parentElement as HTMLElement
|
||||
fireEvent.pointerEnter(anchor, { pointerType: 'mouse' })
|
||||
await act(async () => { await vi.advanceTimersByTimeAsync(500) })
|
||||
const card = document.querySelector('[data-hover-details]')
|
||||
const card = document.querySelector('[data-session-panel-details]')
|
||||
const lines = card === null ? null : [...card.children].map(child => child.textContent ?? '')
|
||||
fireEvent.pointerLeave(anchor, { pointerType: 'mouse' })
|
||||
await act(async () => { await vi.advanceTimersByTimeAsync(400) })
|
||||
@@ -210,11 +211,23 @@ function HeaderCatalog({ store, ...props }: HeaderCatalogProps) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The Session panel's fold control Factory as these suites render it: a button with its state, name, and label.
|
||||
* ui-session-panel's own suite owns the control's markup.
|
||||
* The Session panel's Factories as these suites render them: the fold control as a button with its state, name, and
|
||||
* label, and a row's details as one element per part in order. ui-session-panel's own suite owns their markup.
|
||||
*/
|
||||
function renderFold(_name: string, input: { expanded: boolean; label: string; name: string; onToggle: () => void }) {
|
||||
return <button type="button" data-fold="" aria-expanded={input.expanded} aria-label={input.name} onClick={input.onToggle}>{input.label}</button>
|
||||
function renderPanelFactory(name: string, input: object) {
|
||||
if (name === 'conversation.session.panel.details') {
|
||||
const { title, lines = [], status, facts = [] } = input as PanelDetailsProps
|
||||
return (
|
||||
<div data-session-panel-details="">
|
||||
{title !== undefined && <div>{title}</div>}
|
||||
{lines.map(line => <div key={line}>{line}</div>)}
|
||||
{status !== undefined && <div data-state={status.state}>{status.label}</div>}
|
||||
{facts.length > 0 && <div>{facts.map(fact => <span key={fact.kind} data-fact={fact.kind}>{fact.label}</span>)}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const fold = input as PanelFoldProps
|
||||
return <button type="button" data-fold="" aria-expanded={fold.expanded} aria-label={fold.name} onClick={fold.onToggle}>{fold.label}</button>
|
||||
}
|
||||
|
||||
/** The section with the panel owner values, its Session's store (a fresh one unless given), and the fold control. */
|
||||
@@ -222,7 +235,7 @@ function Section({ store, dismissOverlay, ...props }: Omit<HeaderCatalogProps, '
|
||||
const [own] = useState(() => store ?? createSubagentsSectionStore().create())
|
||||
const [useStore] = useState(() => bindSnapshotSelector(own))
|
||||
const sectionProps = {
|
||||
...props, presentation: 'docked', dismissOverlay: dismissOverlay ?? vi.fn(), useStore, actions: own.actions, renderFactorySlot: renderFold,
|
||||
...props, presentation: 'docked', dismissOverlay: dismissOverlay ?? vi.fn(), useStore, actions: own.actions, renderFactorySlot: renderPanelFactory,
|
||||
} as SubagentsSectionProps
|
||||
return <SubagentsSection {...sectionProps} />
|
||||
}
|
||||
|
||||
@@ -2465,7 +2465,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel.environment.row\', () => ctx.slots.register(\n { name: \'conversation.session.panel.environment.row\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:44',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:45',
|
||||
},
|
||||
{
|
||||
key: 'conversation.session.panel.indicator',
|
||||
@@ -2529,7 +2529,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel.indicator\', () => ctx.slots.register(\n { name: \'conversation.session.panel.indicator\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:37',
|
||||
source: 'packages/client/ui-session-panel/src/client/slots.ts:38',
|
||||
},
|
||||
{
|
||||
key: 'conversation.session.panel.section',
|
||||
@@ -2597,7 +2597,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:23',
|
||||
},
|
||||
{
|
||||
key: 'conversation.session.panel.section.actions',
|
||||
@@ -2647,7 +2647,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
],
|
||||
replaceRisk: 'shadows-shipped-ui',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.session.panel.section.actions\', () => ctx.slots.register(\n { name: \'conversation.session.panel.section.actions\', key: \'<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:29',
|
||||
},
|
||||
{
|
||||
key: 'conversation.trajectory.images',
|
||||
|
||||
Reference in new issue
Block a user