diff --git a/.agents/notes/implemented/architecture/2026-09-30-structured-draft-initialization.i18n.yaml b/.agents/notes/implemented/architecture/2026-09-30-structured-draft-initialization.i18n.yaml index 68269e8997..93432e3ee9 100644 --- a/.agents/notes/implemented/architecture/2026-09-30-structured-draft-initialization.i18n.yaml +++ b/.agents/notes/implemented/architecture/2026-09-30-structured-draft-initialization.i18n.yaml @@ -15,8 +15,8 @@ en: 7f33895364a9f5cc zh: f1c79ea15f5c151e /agent-note-initial-draft-content-and-structured-reference-restoration/decision/classes-and-methods: - en: e57394545d9d93ff - zh: 5ab142e661750b82 + en: 9039c6bf700da3cf + zh: 2808757aed8615b3 /agent-note-initial-draft-content-and-structured-reference-restoration/decision/data-flow: en: dd57e639e9328f1d zh: 5e16cb2e3a73597c diff --git a/.agents/notes/implemented/architecture/2026-09-30-structured-draft-initialization.md b/.agents/notes/implemented/architecture/2026-09-30-structured-draft-initialization.md index cbb15cc56a..24355ccf35 100644 --- a/.agents/notes/implemented/architecture/2026-09-30-structured-draft-initialization.md +++ b/.agents/notes/implemented/architecture/2026-09-30-structured-draft-initialization.md @@ -37,7 +37,7 @@ The existing `dsh.conversation.` key remains. Readers accept both leg | `SessionInputShell.refreshLexiconSubscription()` / `DraftEditorRuntime.refreshLexiconSubscription()` | `InputHub` owns the Session-scope `inject` callback that connects the lexicon after caching the shell, reconnects when the service arrives or is replaced, and unsubscribes on disposal. Both connection and catalog updates rescan the current editor without writing old text back; `setDraft` does not establish the subscription | | `ConversationStoreState` / `createConversationStore` | Support structured input and legacy strings in draft storage, keeping View state and the original key | | `DefaultConversationViews` | Remove restoration and prefill effects, retaining persistence binding and unbinding. Initial saving reads the owner's current snapshot, never text captured during render | -| The existing `selectWorkspace` callback in `apply.ts` | Keep the existing cross-Workspace draft-transfer rules, passing `draftSnapshot` instead of plain text so transfer retains references | +| The cross-Workspace draft move (`moveDraft` in `apply.ts`) | Keep the existing cross-Workspace draft-transfer rules, passing `draftSnapshot` instead of plain text so transfer retains references | There is no new draft service, storage key, general task framework, or Session creation entry point. SlotRenderer, Host Session logs, command execution, and file-discovery RPCs are unchanged. `InputActions` remains the shared input-action entry; components receive no separate content-initialization callback. diff --git a/.agents/notes/implemented/architecture/2026-09-30-structured-draft-initialization.zh.md b/.agents/notes/implemented/architecture/2026-09-30-structured-draft-initialization.zh.md index 12d4e4731a..8a3a964e95 100644 --- a/.agents/notes/implemented/architecture/2026-09-30-structured-draft-initialization.zh.md +++ b/.agents/notes/implemented/architecture/2026-09-30-structured-draft-initialization.zh.md @@ -37,7 +37,7 @@ Status: implemented | `SessionInputShell.refreshLexiconSubscription()`/`DraftEditorRuntime.refreshLexiconSubscription()` | `InputHub` 拥有 Session scope 的 `inject` 回调,在缓存输入对象后连接词典,服务到达或替换时重接,销毁时退订。连接和词典更新都会重扫当前 editor,不覆盖旧文本;`setDraft` 不负责建立订阅 | | `ConversationStoreState`/`createConversationStore` | draft 支持兼容旧字符串的结构化输入,View 状态及原 key 保持 | | `DefaultConversationViews` | 删除恢复/预填 effect;保留持久化回调的绑定和解绑。初始保存只能读取 owner 的当前快照,不能把 render 时的旧文字写回 | -| `apply.ts` 中现有 `selectWorkspace` 回调 | 沿用原有跨工作区携带规则,但传递 `draftSnapshot` 而不是纯文本,防止携带时再次丢失引用 | +| 跨工作区的草稿移动(`apply.ts` 中的 `moveDraft`) | 沿用原有跨工作区携带规则,但传递 `draftSnapshot` 而不是纯文本,防止携带时再次丢失引用 | 不新增草稿服务、存储 key、通用任务框架或另一套 Session 创建入口;不改 SlotRenderer、Host Session 日志、命令执行和文件发现 RPC。`InputActions` 保留统一输入操作入口,组件不单独注入另一条内容初始化回调。 diff --git a/packages/client/ui-conversation/README.i18n.yaml b/packages/client/ui-conversation/README.i18n.yaml index 93fb959b52..4ea34ddaa5 100644 --- a/packages/client/ui-conversation/README.i18n.yaml +++ b/packages/client/ui-conversation/README.i18n.yaml @@ -21,8 +21,8 @@ en: 4a094cd97426ad18 zh: 5faadddb7e2b0a43 /deepseek-ai-dsh-client-ui-conversation/shell-and-standard-props: - en: 8ad7f24bef08474a - zh: 23accc0d5e837714 + en: 5914222b76430956 + zh: 0eefa0c999bc17a7 /deepseek-ai-dsh-client-ui-conversation/shell-and-standard-props/control-geometry: en: 876be274c65b56d9 zh: c3adbf5a16e0e38e diff --git a/packages/client/ui-conversation/README.md b/packages/client/ui-conversation/README.md index 358a1c0d46..87e68b0a19 100644 --- a/packages/client/ui-conversation/README.md +++ b/packages/client/ui-conversation/README.md @@ -108,7 +108,7 @@ A claimed command is one atomic chip at the start of the draft, and the claim la Workspace selection uses `uiWorkspace.openWorkspace` to prepare the target and commit navigation. Draft content, including structured references, and attachments move in its synchronous preparation callback only while that request is current and no submission is in flight; later navigation, owner disposal, or a submission in flight leaves the original draft in its Session. -The package occupies the root-scoped `main` key `conversation`. Its `main.conversation` shell keeps the resident `conversation.header` outside the optional-Session `conversation.content` Component Factory. The header hosts root-scoped navigation without a selected Session; titles, actions, and View tabs remain in its strict Session child. The Factory owns the shared body and Composer, reads the current Session through its standard Hook, and exposes strict-Session `views` plus root-scoped `widthControls` local positions. Its default adapter renders the existing `conversation.session` entry, while the main occurrence selects the width handles; an embedded occurrence can replace `views` and omit those handles without rendering the main Header. The shared body and Composer register the queue and Todo docks. The Todo dock uses the shared panel elevation above the composer; its rows use the shared idle, ongoing, and done markers for pending, in-progress, and completed items. `ctx.uiSession.provide()` materializes the Conversation and input sources from the same Session binding and supplies `inputActions` as a stable standard prop. +The package occupies the root-scoped `main` key `conversation`. Its `main.conversation` shell keeps the resident `conversation.header` outside the optional-Session `conversation.content` Component Factory. The header hosts root-scoped navigation without a selected Session; titles, actions, and View tabs remain in its strict Session child. The Factory owns the shared body and Composer, reads the current Session through its standard Hook, and exposes strict-Session `views` plus root-scoped `widthControls` local positions. Its default adapter renders the existing `conversation.session` entry, while the main occurrence selects the width handles; an embedded occurrence can replace `views` and omit those handles without rendering the main Header. Every occurrence passes `onWorkspaceSelected`, which decides what a Workspace picked in the Hero does. It receives the Workspace and an `adopt` function, resolves that Workspace's blank Session, shows it in place of the Session shown before, and calls `adopt` with it in the same step while it retains both Sessions; `adopt` moves the draft. The main occurrence opens the blank as the main Session, and an embedded owner may show it itself. A pick the owner no longer wants resolves without calling `adopt`; a failed pick rejects, its owner reports the failure, and the Hero returns to the Workspace it showed. An embedded occurrence may also pass `headline`, which replaces the Hero headline and preview badge. The shared body and Composer register the queue and Todo docks. The Todo dock uses the shared panel elevation above the composer; its rows use the shared idle, ongoing, and done markers for pending, in-progress, and completed items. `ctx.uiSession.provide()` materializes the Conversation and input sources from the same Session binding and supplies `inputActions` as a stable standard prop. A blank Session retains the header's leading and corner controls, including the right-sidebar opener, while hiding its title, actions, utilities, and View tabs. Selecting a Workspace creates the Session needed by these controls; the first message is not required. Without a selected Session, the strict header is absent; the resident header keeps the blank-Session 40px row on every platform, so the Hero input card sits at the same height before and after a Workspace is bound; on macOS desktop that row is also the window drag row. Sidebar entries retain their own data and execution prerequisites. A started Session header uses one row when fewer than two Views are available; the tab row reserves space only while rendered. When the title and actions do not fit, the title area clips them and fades its trailing edge before the utilities, which stay fully visible and clickable; overlays in the title and actions slots portal to stay outside that clip. diff --git a/packages/client/ui-conversation/README.zh.md b/packages/client/ui-conversation/README.zh.md index a493dcb319..8302065571 100644 --- a/packages/client/ui-conversation/README.zh.md +++ b/packages/client/ui-conversation/README.zh.md @@ -108,7 +108,7 @@ root 作用域的 `conversation.session.header.views.actions` list 有注册项 工作区选择使用 `uiWorkspace.openWorkspace` 准备目标并提交导航。草稿内容(包括结构化引用)和附件仅在该请求仍为当前请求、且没有在途提交时,通过它的同步准备回调搬移;后续导航、所有者释放或在途提交都会把原草稿留在它的 Session 中。 -本包占据 root 作用域 `main` 中的 `conversation` key。其 `main.conversation` 外壳将常驻的 `conversation.header` 放在可选 Session 的 `conversation.content` Component Factory 外。未选中 Session 时,头部仍承载根作用域导航;标题、操作和 View 标签保留在严格 Session 子组件中。Factory 拥有共享正文与 Composer,通过其标准 Hook 读取当前 Session,并公开 strict-Session `views` 与 root-scoped `widthControls` 两个局部位置。默认 adapter 渲染现有 `conversation.session` entry,主 occurrence 选择宽度拖拽条;嵌入式 occurrence 可以替换 `views`、省略拖拽条,且不渲染主 Header。共享正文与 Composer 注册 queue dock 和 Todo dock。Todo dock 在 composer 上方使用共享面板 elevation;其中的行分别以共享 idle、ongoing 与 done 标记表示待处理、进行中与已完成。`ctx.uiSession.provide()` 从同一个 Session binding 物化 Conversation 与 input source,并将 `inputActions` 作为稳定标准 prop 提供。 +本包占据 root 作用域 `main` 中的 `conversation` key。其 `main.conversation` 外壳将常驻的 `conversation.header` 放在可选 Session 的 `conversation.content` Component Factory 外。未选中 Session 时,头部仍承载根作用域导航;标题、操作和 View 标签保留在严格 Session 子组件中。Factory 拥有共享正文与 Composer,通过其标准 Hook 读取当前 Session,并公开 strict-Session `views` 与 root-scoped `widthControls` 两个局部位置。默认 adapter 渲染现有 `conversation.session` entry,主 occurrence 选择宽度拖拽条;嵌入式 occurrence 可以替换 `views`、省略拖拽条,且不渲染主 Header。每个 occurrence 都传入 `onWorkspaceSelected`,由它决定在 Hero 中选择工作区后做什么。它接收工作区和一个 `adopt` 函数:解析该工作区的空白 Session,用它替换此前显示的 Session,并在同一步、仍保留两个 Session 时以它调用 `adopt`;`adopt` 负责移动草稿。主 occurrence 把这个空白 Session 打开为主 Session,嵌入方可以自己显示它。属主不再需要的选择在不调用 `adopt` 的情况下完成;失败的选择会 reject,由属主报告失败,Hero 回到此前显示的工作区。嵌入式 occurrence 也可以传入 `headline`,用来替换 Hero 的标题与预览徽标。共享正文与 Composer 注册 queue dock 和 Todo dock。Todo dock 在 composer 上方使用共享面板 elevation;其中的行分别以共享 idle、ongoing 与 done 标记表示待处理、进行中与已完成。`ctx.uiSession.provide()` 从同一个 Session binding 物化 Conversation 与 input source,并将 `inputActions` 作为稳定标准 prop 提供。 blank Session 保留 header 的 leading 与 corner 控件,包括右侧栏展开入口,同时隐藏标题、actions、utilities 和 View tabs。选择 Workspace 会创建这些控件所需的 Session,无需先发送消息。没有选中 Session 时,strict header 不挂载;常驻 header 在所有平台都保留与 blank Session 相同的 40px 行,因此绑定 Workspace 前后 Hero 输入卡片的高度位置不变;在 macOS 桌面上,这一行同时是窗口拖拽行。侧栏各入口仍遵循自身的数据与执行环境要求。 已开始的 Session 在可用 View 少于两个时使用单行标题栏,仅在渲染标签行时保留其高度。标题与 actions 放不下时,标题区域会裁剪它们,并在 utilities 之前渐隐其末端;utilities 始终完整可见且可点击;标题与 actions slot 中的浮层通过 portal 渲染,不受该裁剪影响。 diff --git a/packages/client/ui-conversation/src/client/apply.ts b/packages/client/ui-conversation/src/client/apply.ts index b7b32009ed..2ed062b42f 100644 --- a/packages/client/ui-conversation/src/client/apply.ts +++ b/packages/client/ui-conversation/src/client/apply.ts @@ -22,7 +22,7 @@ import { sessionReferenceRule } from './user-text/session-reference-rule.ts' import { collapseWhitespaceRule, trimWhitespaceRule } from './user-text/whitespace-rules.ts' import type { ViewTab } from './contract/views.ts' import type { - ComposerBarInjected, ConversationInjected, ConversationSessionHeaderInjected, + ComposerBarInjected, ConversationInjected, ConversationSessionHeaderInjected, ConversationShellInjected, ConversationSessionInjected, DraftFileUploads, UserTextInjected, } from './contract/slots.ts' import type { InputNotice } from './contract/input.ts' @@ -112,7 +112,7 @@ function hostPathBridge(): HostPathBridge | undefined { interface WorkspaceNavigation { openSession(sessionId: SessionId): void openWorkspace( - workspaceId: Parameters[0], + workspaceId: Parameters[0], beforeOpen: (sessionId: SessionId) => void, ): Promise } @@ -329,6 +329,10 @@ export function apply(ctx: Context, config: SyncedConfig): v }, }) + const shellInjected: ConversationShellInjected = { + openWorkspace: (workspaceId, adopt) => workspaceNavigation.openWorkspace(workspaceId, adopt), + } + const registerConversationRoot = () => slots.register({ name: 'main.conversation', children: { @@ -359,7 +363,7 @@ export function apply(ctx: Context, config: SyncedConfig): v hooks: { composerBlock: sessionId === undefined ? ABSENT_BLOCK : composerBlocks.storeFor(sessionId), }, - selectWorkspace: workspaceId => workspaceNavigation.openWorkspace(workspaceId, (nextId) => { + moveDraft: (nextId) => { if (sessionId !== undefined && nextId !== sessionId) { const from = inputHub.shell(sessionId) // A draft with a submission in flight stays with the Session that is admitting it. @@ -384,7 +388,7 @@ export function apply(ctx: Context, config: SyncedConfig): v } } } - }), + }, }), }, ConversationContent) @@ -580,7 +584,7 @@ export function apply(ctx: Context, config: SyncedConfig): v yield slots.register({ name: 'main', key: 'conversation', - children: { 'main.conversation': { kind: 'single', scope: 'session-maybe' } }, + children: { 'main.conversation': { kind: 'single', scope: 'session-maybe', inject: shellInjected } }, }, ConversationPanel) yield registerConversationRoot() yield registerConversationContent() diff --git a/packages/client/ui-conversation/src/client/contract/slots.ts b/packages/client/ui-conversation/src/client/contract/slots.ts index f8bbf67c5b..4efcee6601 100644 --- a/packages/client/ui-conversation/src/client/contract/slots.ts +++ b/packages/client/ui-conversation/src/client/contract/slots.ts @@ -226,7 +226,7 @@ declare module '@deepseek-ai/dsh-client-ui-slots' { keyProps: { [Id in UserTextId]: { node: UserTextNode } } } /** Conversation shell beneath its root-scoped main-panel entry. */ - 'main.conversation': { kind: 'single'; scope: 'session-maybe' } + 'main.conversation': { kind: 'single'; scope: 'session-maybe'; inject: ConversationShellInjected } /** Strict per-Session Conversation body. */ 'conversation.session': { kind: 'single' @@ -466,10 +466,32 @@ export interface ConvViewOwnerProps { /** Base props of one target-owned Conversation View entry. */ export type ConvViewProps = PropsRuntime<'conversation.view'> -/** Business callbacks injected into the resident Conversation shell. */ +/** + * Moves the draft of the Session a Hero shows to the Session that replaces it. The occurrence owner calls it at most + * once per pick, synchronously with the step that shows the new Session, while it still retains both Sessions. + */ +export type WorkspaceSessionAdopter = (sessionId: SessionId) => void + +/** + * Handles a Workspace the Hero's picker chose: resolves that Workspace's blank Session, shows it in place of the + * Session shown before, and calls `adopt` with it in the same step. A pick the owner no longer wants resolves + * without calling `adopt`; a pick that failed rejects, and the owner reports the failure. + */ +export type WorkspaceSelectedHandler = (workspaceId: WorkspaceId, adopt: WorkspaceSessionAdopter) => Promise + +/** Business callbacks injected into the main Conversation shell. */ +export interface ConversationShellInjected { + /** Open the Workspace's blank Session as the main Session. */ + openWorkspace: WorkspaceSelectedHandler +} + +/** Business callbacks injected into the shared Conversation content. */ export interface ConversationInjected { - /** Connect and open a blank Session in the selected Workspace. */ - selectWorkspace: (workspaceId: WorkspaceId) => Promise + /** + * Move this occurrence's draft text and attachments to another Session. Both Sessions must be retained; a draft + * with a submission in flight stays where it is. + */ + moveDraft: WorkspaceSessionAdopter /** Session-addressed composer block source, or the stable absent source. */ hooks: { composerBlock: ObservableSnapshot } } @@ -683,6 +705,10 @@ export interface ConversationContentInputProps { variant: 'main' | 'embedded' phase: 'settling' | 'hero' | 'active' hero: boolean + /** What a Workspace picked in the Hero does in this occurrence; the main occurrence opens it as the main Session. */ + onWorkspaceSelected: WorkspaceSelectedHandler + /** Text the blank-session Hero shows instead of its default headline and preview badge. */ + headline?: string | undefined } /** Values passed from shared content to its occurrence-selected width controls. */ diff --git a/packages/client/ui-conversation/src/client/index.ts b/packages/client/ui-conversation/src/client/index.ts index b2ce918f76..2aa335183b 100644 --- a/packages/client/ui-conversation/src/client/index.ts +++ b/packages/client/ui-conversation/src/client/index.ts @@ -86,7 +86,7 @@ export type { ComposerBarInjected, ComposerBarOwnerProps, ComposerBarProps, ComposerChainProps, ConversationHeaderActionOwnerProps, ConversationHeaderCornerOwnerProps, ConversationHeaderLineageOwnerProps, ConversationContentInputProps, ConversationContentProps, - ConversationInjected, ConversationSessionHeaderInjected, ConversationSessionHeaderSlotProps, + ConversationInjected, ConversationSessionHeaderInjected, ConversationSessionHeaderSlotProps, ConversationShellInjected, ConversationSessionInjected, ConversationSessionSlotProps, ConversationSlotProps, ConversationViewActionEntry, ConversationViewActionsOwnerProps, ConversationViewsProps, ConversationWidthControlsInputProps, ConversationWidthControlsProps, @@ -94,6 +94,7 @@ export type { HeroAgentPresetOwnerProps, HeroBrandMarkOwnerProps, HeroFrameOwnerProps, InputControlOwnerProps, InputZone, MessageImageLabels, MessageImageLoader, MessageImageSource, MessageImagesContentInput, MessageImagesOwnerProps, UseConversation, UserTextInput, UserTextInjected, UserTextNodeOwnerProps, UserTextNodeProps, + WorkspaceSelectedHandler, WorkspaceSessionAdopter, UseConversationViews, } from './contract/slots.ts' export type { diff --git a/packages/client/ui-conversation/src/client/skeleton/ConversationContent.tsx b/packages/client/ui-conversation/src/client/skeleton/ConversationContent.tsx index 5c5d1149f8..17ab15294e 100644 --- a/packages/client/ui-conversation/src/client/skeleton/ConversationContent.tsx +++ b/packages/client/ui-conversation/src/client/skeleton/ConversationContent.tsx @@ -23,7 +23,7 @@ export function ConversationContent(props: ConversationContentProps) { const { sessionId, phase, hero, useSession, useSessions, useSessionStatus, useWorkspaces, useInput, useComposerBlock, renderSlot, renderSlotChain, - selectWorkspace, t, useFactorySlot, + moveDraft, t, useFactorySlot, } = props const session = useSession(snapshot => snapshot) const Views = useFactorySlot('views', ConversationSessionView) @@ -123,7 +123,7 @@ export function ConversationContent(props: ConversationContentProps) { onPick: (workspaceId) => { setPickerOpen(false) setPendingWorkspaceId(workspaceId) - void selectWorkspace(workspaceId).catch(() => { + void props.onWorkspaceSelected(workspaceId, moveDraft).catch(() => { setPendingWorkspaceId(current => current === workspaceId ? undefined : current) }) }, @@ -164,7 +164,7 @@ export function ConversationContent(props: ConversationContentProps) { const composerBar = (
- {hero && } + {hero && } {hero && heroWorkspaceRow} {zone !== undefined && renderSlot('conversation.input.dock', zone)} {inputBar} diff --git a/packages/client/ui-conversation/src/client/skeleton/ConversationMainPanel.tsx b/packages/client/ui-conversation/src/client/skeleton/ConversationMainPanel.tsx index dc82d99775..ef0f2ad583 100644 --- a/packages/client/ui-conversation/src/client/skeleton/ConversationMainPanel.tsx +++ b/packages/client/ui-conversation/src/client/skeleton/ConversationMainPanel.tsx @@ -11,7 +11,7 @@ const CONTENT_SLOTS = { widthControls: ConversationWidthControls } * @returns the unchanged root, Header, content, and width-control subtree. */ export function ConversationMainPanel(props: ConversationSlotProps) { - const { sessionId, useSession, useSessions, useConversation, renderSlot, renderFactorySlot } = props + const { sessionId, useSession, useSessions, useConversation, renderSlot, renderFactorySlot, openWorkspace } = props const session = useSession(s => s) const conversation = useConversation(s => s) const shellPhase = session === undefined || conversation === undefined @@ -41,6 +41,7 @@ export function ConversationMainPanel(props: ConversationSlotProps) { variant: 'main', phase, hero, + onWorkspaceSelected: openWorkspace, }, { slots: CONTENT_SLOTS, })} diff --git a/packages/client/ui-conversation/src/client/skeleton/EmptyHero.tsx b/packages/client/ui-conversation/src/client/skeleton/EmptyHero.tsx index b46db926da..9adcf1e0ac 100644 --- a/packages/client/ui-conversation/src/client/skeleton/EmptyHero.tsx +++ b/packages/client/ui-conversation/src/client/skeleton/EmptyHero.tsx @@ -67,6 +67,8 @@ export interface HeroShellProps { t: HeroTranslate /** Authorized renderer for the hero brand-mark slot. */ renderSlot: ConversationContentProps['renderSlot'] + /** Text shown instead of the default headline and preview badge. */ + headline?: string | undefined /** Overlay content after the stack (modals). */ children?: ReactNode } @@ -129,7 +131,7 @@ function HeroFish({ hovering }: { hovering: boolean }) { * @param props - see {@link HeroShellProps}. * @returns the centered hero element tree. */ -export function HeroShell({ t, renderSlot, children }: HeroShellProps) { +export function HeroShell({ t, renderSlot, headline, children }: HeroShellProps) { const [hovering, setHovering] = useState(false) return (
@@ -152,8 +154,8 @@ export function HeroShell({ t, renderSlot, children }: HeroShellProps) { {/* Own element: keeps the headline text addressable apart from the badge. */} - {t('hero.headline')} - {t('hero.preview')} + {headline ?? t('hero.headline')} + {headline === undefined && {t('hero.preview')}}
diff --git a/packages/client/ui-conversation/tests/apply-inject.client.spec.tsx b/packages/client/ui-conversation/tests/apply-inject.client.spec.tsx index 701616957f..7634435bea 100644 --- a/packages/client/ui-conversation/tests/apply-inject.client.spec.tsx +++ b/packages/client/ui-conversation/tests/apply-inject.client.spec.tsx @@ -18,7 +18,7 @@ import { } from '@deepseek-ai/dsh-client-test-runtime' import type { SessionBehaviorOverrides } from '@deepseek-ai/dsh-client-test-runtime' import { - apply, inject, type ComposerBarInjected, type ConversationInjected, + apply, inject, type ComposerBarInjected, type ConversationInjected, type ConversationShellInjected, type ConversationSessionHeaderInjected, type ConversationSessionInjected, type ViewTab, } from '@deepseek-ai/dsh-client-ui-conversation/client' import type { SessionId } from '@deepseek-ai/dsh-session/types' @@ -141,6 +141,11 @@ async function bench(renderQuote = false) { sessionId: SessionId | undefined, ) => ConversationInjected)(id) } + /** Pick a Workspace as the main occurrence does: the shell opens it and adopts the draft of the Session shown. */ + const selectWorkspace = (id: SessionId | undefined, workspaceId: WorkspaceId): Promise => { + const shell = runtime.slots.spec('main.conversation') as { inject: ConversationShellInjected } + return shell.inject.openWorkspace(workspaceId, residentApi(id).moveDraft) + } const headerApi = (id: SessionId) => { const entry = entryOf('conversation.session.header') const instance = runtime.storeOf('conversation.session.header', references.get(id)) as ConversationInstance @@ -161,7 +166,7 @@ async function bench(renderQuote = false) { const viewSource = (id: SessionId): ObservableSnapshot => conversationApi(id).injected.hooks.conversationViews return { - runtime, feature, slots: runtime.slots, entryOf, conversationApi, headerApi, residentApi, composerApi, + runtime, feature, slots: runtime.slots, entryOf, conversationApi, headerApi, residentApi, composerApi, selectWorkspace, inputApi, viewSource, sessionFake, connectWorkspace, rootUpload, uploads, rootReference, references, opened, } } @@ -666,7 +671,6 @@ describe('Conversation inject API', () => { it('moves a draft only when Workspace navigation changes Session', async () => { const b = await bench() - const resident = b.residentApi(ROOT) const { state, actions } = b.inputApi(ROOT) actions.setDraft('carry me') expect(b.composerApi(ROOT).addFiles?.([ @@ -675,7 +679,7 @@ describe('Conversation inject API', () => { await vi.waitFor(() => { expect(b.rootUpload).toHaveBeenCalledOnce() }) b.connectWorkspace.mockResolvedValueOnce(ROOT) - await resident.selectWorkspace('workspace-1' as WorkspaceId) + await b.selectWorkspace(ROOT, 'workspace-1' as WorkspaceId) expect(b.opened).toHaveBeenCalledWith(ROOT) expect(state.getSnapshot().draft).toBe('carry me') @@ -690,7 +694,7 @@ describe('Conversation inject API', () => { b.uploads.set(other, targetUpload) await b.runtime.sessions.add({ id: other, session: {} }) b.connectWorkspace.mockResolvedValueOnce(other) - await resident.selectWorkspace('workspace-2' as WorkspaceId) + await b.selectWorkspace(ROOT, 'workspace-2' as WorkspaceId) expect(b.opened).toHaveBeenCalledWith(other) expect(state.getSnapshot().draft).toBe('') expect(b.inputApi(other).state.getSnapshot().draft).toBe('carry me') @@ -711,7 +715,7 @@ describe('Conversation inject API', () => { const other = 'sending-target' as SessionId await b.runtime.sessions.add({ id: other, session: {} }) b.connectWorkspace.mockResolvedValueOnce(other) - await b.residentApi(ROOT).selectWorkspace('workspace-sending' as WorkspaceId) + await b.selectWorkspace(ROOT, 'workspace-sending' as WorkspaceId) expect(b.opened).toHaveBeenCalledWith(other) expect(b.inputApi(other).state.getSnapshot().draft).toBe('') expect(state.getSnapshot().draft).toBe('in flight') @@ -732,7 +736,7 @@ describe('Conversation inject API', () => { const other = 'structured-target' as SessionId await b.runtime.sessions.add({ id: other, session: {} }) b.connectWorkspace.mockResolvedValueOnce(other) - await b.residentApi(ROOT).selectWorkspace('workspace-structured' as WorkspaceId) + await b.selectWorkspace(ROOT, 'workspace-structured' as WorkspaceId) expect(b.inputApi(other).state.getSnapshot().draft).toBe(draft.text) expect(b.inputApi(other).state.getSnapshot().occurrences).toMatchObject(draft.references) expect(b.inputApi(ROOT).state.getSnapshot().draft).toBe('') @@ -743,12 +747,12 @@ describe('Conversation inject API', () => { it('supports no-Session navigation and propagates Workspace connection failure', async () => { const b = await bench() b.connectWorkspace.mockResolvedValueOnce(ROOT) - await b.residentApi(undefined).selectWorkspace('workspace-0' as WorkspaceId) + await b.selectWorkspace(undefined, 'workspace-0' as WorkspaceId) expect(b.opened).toHaveBeenCalledWith(ROOT) const opens = b.opened.mock.calls.length b.connectWorkspace.mockRejectedValueOnce(new Error('offline')) - await expect(b.residentApi(ROOT).selectWorkspace('workspace-4' as WorkspaceId)) + await expect(b.selectWorkspace(ROOT, 'workspace-4' as WorkspaceId)) .rejects.toThrow('offline') expect(b.opened).toHaveBeenCalledTimes(opens) await b.runtime.dispose() diff --git a/packages/client/ui-conversation/tests/apply-wiring.client.spec.tsx b/packages/client/ui-conversation/tests/apply-wiring.client.spec.tsx index 907b6ec015..5a0adbffb0 100644 --- a/packages/client/ui-conversation/tests/apply-wiring.client.spec.tsx +++ b/packages/client/ui-conversation/tests/apply-wiring.client.spec.tsx @@ -8,7 +8,7 @@ import { import { LocaleRuntime } from '@deepseek-ai/dsh-client-locale/client' import { createSnapshotStore, type ObservableSnapshot } from '@deepseek-ai/dsh-client-store' import type { SessionId } from '@deepseek-ai/dsh-session/types' -import { apply, inject, type ViewTab } from '@deepseek-ai/dsh-client-ui-conversation/client' +import { apply, inject, type ConversationShellInjected, type ViewTab } from '@deepseek-ai/dsh-client-ui-conversation/client' usePinnedBrowserLanguages('zh-CN') @@ -103,8 +103,9 @@ describe('target-neutral Conversation apply wiring', () => { b.runtime.renderRoot() expect(b.runtime.slots.entries('main').map(row => row.options.key)).toEqual(['conversation']) expect(b.runtime.slots.entries('main.conversation')).toHaveLength(1) - expect(b.runtime.slots.spec('main.conversation')) - .toEqual({ kind: 'single', scope: 'session-maybe' }) + const shell = b.runtime.slots.spec('main.conversation') as { inject: ConversationShellInjected } + expect(shell.inject.openWorkspace).toBeTypeOf('function') + expect(shell).toEqual({ kind: 'single', scope: 'session-maybe', inject: shell.inject }) expect(b.runtime.factoryOf('conversation.content').slots) .toMatchObject({ views: { scope: 'session' } }) expect(b.runtime.slots.entries('conversation.session')).toHaveLength(1) diff --git a/packages/client/ui-conversation/tests/skeleton.client.spec.tsx b/packages/client/ui-conversation/tests/skeleton.client.spec.tsx index e3efe6510e..41c2c9ea9a 100644 --- a/packages/client/ui-conversation/tests/skeleton.client.spec.tsx +++ b/packages/client/ui-conversation/tests/skeleton.client.spec.tsx @@ -32,6 +32,7 @@ import { InputBar } from '../src/client/skeleton/InputBar.tsx' import type { InputBarProps } from '../src/client/skeleton/InputBar.tsx' import type { ComposerBarOwnerProps, ConversationContentInputProps, ConversationContentProps, + WorkspaceSelectedHandler, WorkspaceSessionAdopter, ConversationHeaderLineageOwnerProps, ConversationSessionHeaderSlotProps, ConversationSessionSlotProps, ConversationSlotProps, ConversationViewActionsOwnerProps, ConversationViewsProps, HeroFrameOwnerProps, } from '../src/client/contract/slots.ts' @@ -124,7 +125,7 @@ function sessionSnapshotOf(overrides: Partial = {}): SessionSna function mount( snapshot: SessionSnapshot, workspaceRows: WorkspaceView[] = [{ ...workspace('one'), sessionIds: [SID] }], - retargetWorkspace = vi.fn(async (_workspaceId: WorkspaceId) => {}), + retargetWorkspace = vi.fn(async () => {}), options: { /** Explicit undefined exercises the shell before a Session is selected. */ sessionId?: SessionId | undefined @@ -351,6 +352,7 @@ function mount( : (opts?.fallback ?? null) )) as ConversationContentProps['renderSlotChain'] const SessionProvider: ConversationContentProps['SessionProvider'] = ({ children }) => children + const moveDraft = vi.fn() const renderFactorySlot = ((_name: string, input: ConversationContentInputProps, factoryOptions?: { slots?: Record ReactNode> }) => { @@ -377,7 +379,7 @@ function mount( renderSlot, renderSlotChain, renderFactorySlot, - selectWorkspace: retargetWorkspace, + moveDraft, t, } const useFactorySlot = ((name: string, fallback: (props: never) => ReactNode) => ( @@ -393,6 +395,7 @@ function mount( usePanelInfo: selector => selector({ activePanelId: null }), sessionId, SessionProvider, + openWorkspace: retargetWorkspace, useSession: sessionId === undefined ? () => undefined : useSession, useConversation: sessionId === undefined ? () => undefined : useConversation, useSessions: bindSnapshotSelector(sessions), @@ -409,7 +412,8 @@ function mount( const props: ConversationSlotProps = { ...runtimeProps, renderSlot, renderFactorySlot } const view = render() return { - view, store, wiring, sink, retargetWorkspace, session, conversation, slotCalls, headerFactory, lineageOwners, seatOwners, open, + view, store, wiring, sink, retargetWorkspace, moveDraft, session, conversation, slotCalls, headerFactory, lineageOwners, seatOwners, + open, pickerOwner: () => pickerOwner, frameOwner: () => frameOwners.at(-1), setPinned, @@ -437,6 +441,13 @@ describe('Hero chrome', () => { expect(brandMarkOwner.className).toBeTypeOf('string') expect(renderSlot.mock.calls[0]?.[2]?.fallback).toBeTruthy() }) + + it('shows an owner headline instead of the default headline and preview badge', () => { + const view = render( null) as never} headline="Review demo #42" />) + expect(view.getByText('Review demo #42')).toBeTruthy() + expect(view.queryByText('Into the Unknown')).toBeNull() + expect(view.queryByText('Preview')).toBeNull() + }) }) describe('ConversationRoot resident composer', () => { @@ -611,7 +622,7 @@ describe('ConversationRoot resident composer', () => { const owner = b.pickerOwner() as { open: boolean; onPick(id: WorkspaceId): void } expect(owner.open).toBe(true) act(() => { owner.onPick(wid('second')) }) - expect(b.retargetWorkspace).toHaveBeenCalledWith(wid('second')) + expect(b.retargetWorkspace).toHaveBeenCalledWith(wid('second'), b.moveDraft) expect(b.view.getByText('Selected Folder')).toBeTruthy() }) @@ -892,7 +903,7 @@ describe('ConversationRoot resident composer', () => { }) it('rolls the pending workspace label back when switching fails', async () => { - const selectWorkspace = vi.fn(async () => { throw new Error('connect failed') }) + const selectWorkspace = vi.fn(async () => { throw new Error('connect failed') }) const b = mount( sessionSnapshotOf({ blank: true }), [ @@ -904,7 +915,7 @@ describe('ConversationRoot resident composer', () => { fireEvent.click(b.view.getByRole('button', { name: '选择工作区' })) const owner = b.pickerOwner() as { onPick(id: WorkspaceId): void } await act(async () => { owner.onPick(wid('second')); await Promise.resolve() }) - expect(selectWorkspace).toHaveBeenCalledWith(wid('second')) + expect(selectWorkspace).toHaveBeenCalledWith(wid('second'), b.moveDraft) expect(b.view.queryByText('Selected Folder')).toBeNull() expect(b.view.getByText('one')).toBeTruthy() }) diff --git a/packages/client/ui-sidebar/README.i18n.yaml b/packages/client/ui-sidebar/README.i18n.yaml index 399cfacf3f..0713c88064 100644 --- a/packages/client/ui-sidebar/README.i18n.yaml +++ b/packages/client/ui-sidebar/README.i18n.yaml @@ -21,8 +21,8 @@ en: 6bc49e22f0f73f07 zh: 10883997ccb7d145 /deepseek-ai-dsh-client-ui-sidebar/use-this-package/global-panel-entries: - en: 0b5faf7b768c5498 - zh: 98afc24bf1f8a7d6 + en: e7cfc9a3d175045d + zh: 2bf0d5d6d0c64de8 /deepseek-ai-dsh-client-ui-sidebar/use-this-package/collapse-behavior: en: 61d563b0f82ff658 zh: f27504350dd14d4c @@ -36,8 +36,8 @@ en: 3e84ffdf6c7c1731 zh: 3f7b19cac6d6674f /deepseek-ai-dsh-client-ui-sidebar/understand-the-implementation: - en: 2b5dd6efe77ee023 - zh: 1dc6610bc9e50406 + en: 4d08c745534fc8f4 + zh: 164418412f91c02a /deepseek-ai-dsh-client-ui-sidebar/understand-the-implementation/slot-discipline: en: 6eefc5c45abe8a8f zh: 20b651e48a0ea903 diff --git a/packages/client/ui-sidebar/README.md b/packages/client/ui-sidebar/README.md index f2af18a4d2..0328dd05fa 100644 --- a/packages/client/ui-sidebar/README.md +++ b/packages/client/ui-sidebar/README.md @@ -41,6 +41,8 @@ The expanded brand row renders `sidebar.brand.mark` and `sidebar.brand.name` as Plugins add an icon component to the root-scoped `sidebar.panellist` list with an `id`, optional `order`, and a string or locale-aware `label`. The same id addresses the component registered in the layout's root-scoped `main` keyed slot; selecting a missing main entry throws without changing the current selection. The label supplies plain visible text, the accessible name, and the collapsed tooltip. Expanded navigation rows are 32px high with a 2px gap; collapsed rail controls remain 36px high with a 12px gap. Expanded navigation keeps an 8px bottom margin before the Workspace header. Each row reads its own selected state through `usePanelInfo`; moving DOM focus to search or a directory picker does not change the displayed panel or its selected row. With no panel registrations, neither the list nor spacing for it is rendered. The shipped composition registers no example panel. +A panel may also register non-interactive inline content in the root-scoped `sidebar.panellist.trailing` list with the same `id`, such as a count. It receives `wide` and `active`. The expanded row lays it out after the title and before the space the unpin action takes, as a Session row lays out its trailing icons, so a row without content keeps its full title width and the unpin action shows beside the content. The collapsed rail shows it over the icon's top trailing corner. It renders inside the row button, so it holds no interactive elements; its text becomes the button's accessible description, so decorative parts must be `aria-hidden`. + While the root-scoped `sidebar.panellist.actions` list has registrations, a **More** button styled as a panel row follows the rows inside the navigation landmark; the collapsed rail shows its label as a tooltip. It opens a menu whose rows are that list's registrations. Each receives `entries` (customizable panels in registration order with `id`, `label`, `pinned`, and `active`; Plugins is never listed), `onOpen(id)`, which selects the panel, `onPinnedChange(id, pinned)`, and `onDismiss()`, which closes the menu. The sidebar keeps one in-memory list of unpinned panel ids shared by every Session; Plugins always shows. While More shows, expanded rows other than Plugins show an unpin action on hover or keyboard focus; devices without hover show it continuously. Its resting color matches the Session pin marker, and its tooltip says “Unpin from left sidebar”. Both sidebar and More entries follow the same registration order rather than pin timing. The default More menu lists only unpinned panels before plugin browsing and creation; opening a panel does not pin it, while its separate pin icon returns the row to the sidebar and dismisses the menu. Choices reset when the plugin reloads and legacy localStorage values are ignored. Unpinning hides only the row, and only while More shows; without `sidebar.panellist.actions` registrations every registered row shows again. The main panel, its registration, and the current selection stay unchanged. Unregistered panel ids remain in the in-memory list until the plugin reloads. ### Collapse behavior @@ -80,7 +82,7 @@ On Desktop, the official navigation controls report `sidebar_menu_click` with `m
Implementation internals — click to expand -The shell is pure composition: `SidebarRootComponentProps` composes the layout owner share, the global `useSessions` and `useWorkspaces` hooks, the declared brand, the `sidebar.workspaces` and `sidebar.settings` child slots, and injected navigation callbacks. The sidebar declares the `sidebar.panel.icon` Component Factory, which owns the `sidebar.panellist` list; panel rows and the More menu render a panel's registered icon through that factory. Panel metadata is derived from list registrations and locale changes; selection belongs to the layout store. The injected `trackEntryClick(attributes)` forwards to `ctx.get('productAnalytics')?.track('sidebar_menu_click', attributes)`, and `selectPanel` only selects, so each control supplies its own entry and position. +The shell is pure composition: `SidebarRootComponentProps` composes the layout owner share, the global `useSessions` and `useWorkspaces` hooks, the declared brand, the `sidebar.workspaces` and `sidebar.settings` child slots, and injected navigation callbacks. The sidebar declares the `sidebar.panel.icon` Component Factory, which owns the `sidebar.panellist` list, and the `sidebar.panel.trailing` Component Factory, which owns the `sidebar.panellist.trailing` list; panel rows and the More menu render a panel's registered icon through the first, and panel rows its trailing content through the second. Panel metadata is derived from list registrations and locale changes; selection belongs to the layout store. The injected `trackEntryClick(attributes)` forwards to `ctx.get('productAnalytics')?.track('sidebar_menu_click', attributes)`, and `selectPanel` only selects, so each control supplies its own entry and position. Expanded navigation uses 8px outer gutters, hover and selected fills inset 3px on each side, and a 16px leading cell with a 6px label gap. New Session centers its content; its row keeps 4px side margins and a 6px bottom margin. Navigation adds a further 4px outside the scrollport and an 8px gap inside it that scrolls away. The logo row has no bottom margin; its content starts 16px from the column's left edge, with 5px between mark and name. Only the macOS non-fullscreen top toggle shifts 4px right while expanded, retaining that offset throughout its fade-out. Collapsed geometry stays independent. diff --git a/packages/client/ui-sidebar/README.zh.md b/packages/client/ui-sidebar/README.zh.md index ef04031f95..e68792963e 100644 --- a/packages/client/ui-sidebar/README.zh.md +++ b/packages/client/ui-sidebar/README.zh.md @@ -41,6 +41,8 @@ dsh Web 客户端的侧边栏让用户识别当前构建、启动新会话、将 插件在 root 作用域的 `sidebar.panellist` list 中注册图标组件,提供 `id`、可选 `order`,以及字符串或 locale-aware 的 `label`。同一个 id 寻址布局中 root 作用域 `main` keyed slot 的组件;选择不存在的主面板条目会抛错,并保留当前选中态。标签提供普通可见文字、无障碍名称和折叠提示。展开态导航行高 32px,间距为 2px;折叠窄栏控件保持 36px 高和 12px 间距。展开态导航区域与工作区标题行之间保留 8px 底部外边距。每一行通过 `usePanelInfo` 读取自己的选中态;DOM 焦点移到搜索框或目录选择器时,显示的面板及其列表项选中态不变。没有面板注册项时,列表及其间距均不渲染。产品随附的组合不注册示例面板。 +面板还可以用相同 `id` 在 root 作用域的 `sidebar.panellist.trailing` list 中注册不可交互的行内内容,例如数量。它接收 `wide` 与 `active`。展开的行把它排在标题之后、取消固定操作所占空间之前,与会话行排布行尾图标的方式相同:没有内容的行保留完整的标题宽度,取消固定操作显示在内容旁边。收起的窄栏在图标右上角显示它。它渲染在行按钮内,因此不能包含可交互元素;它的文字成为按钮的无障碍描述,因此装饰性的部分必须设为 `aria-hidden`。 + root 作用域的 `sidebar.panellist.actions` list 有注册项时,导航区域的面板行之后显示面板行样式的**更多**按钮;收起的窄栏以提示框显示其名称。它打开的菜单以该 list 的注册项为菜单行。每个注册项接收 `entries`(按注册顺序的可自定义面板,含 `id`、`label`、`pinned` 与 `active`;不含插件管理)、选中面板的 `onOpen(id)`、`onPinnedChange(id, pinned)`,以及关闭菜单的 `onDismiss()`。侧边栏在内存中保存所有会话共用的已收起面板 id 列表;插件管理入口始终显示。更多按钮显示时,展开态中除插件管理外的面板行在悬停或键盘聚焦时显示取消固定操作;不支持悬停的设备始终显示该操作。图标默认颜色与会话置顶标记一致,提示为“从左侧栏取消固定”。侧栏和更多菜单入口遵循相同的注册排序,不按固定时间重排。默认更多菜单在插件浏览和创建之前仅列出未固定的面板;打开面板不会将其固定,独立的固定图标则将该行放回侧边栏并关闭菜单。插件重新加载时选择重置,不读取旧 localStorage 值。收起只隐藏导航行,且仅在更多按钮显示时生效;`sidebar.panellist.actions` 没有注册项时,所有已注册的面板行重新显示。主面板、其注册和当前选中态不变。未注册面板的 id 保留在内存列表中,直到插件重新加载。 ### 折叠行为 @@ -80,7 +82,7 @@ root 作用域的 `sidebar.session.action` 是包裹新建会话行内容的 HOC
实现细节——点击展开 -外壳是纯组合:`SidebarRootComponentProps` 组合布局 owner share、全局 `useSessions` 与 `useWorkspaces` 钩子、已声明的品牌、`sidebar.workspaces` 与 `sidebar.settings` 子 slot,以及注入的导航回调。侧边栏声明 `sidebar.panel.icon` Component Factory,由它拥有 `sidebar.panellist` list;面板行和更多菜单都通过该 factory 渲染面板注册的图标。面板元数据由列表注册和 locale 变化派生;选中态属于布局存储。注入的 `trackEntryClick(attributes)` 转发到 `ctx.get('productAnalytics')?.track('sidebar_menu_click', attributes)`;`selectPanel` 只负责选中,因此由各控件自行提供入口与位置。 +外壳是纯组合:`SidebarRootComponentProps` 组合布局 owner share、全局 `useSessions` 与 `useWorkspaces` 钩子、已声明的品牌、`sidebar.workspaces` 与 `sidebar.settings` 子 slot,以及注入的导航回调。侧边栏声明 `sidebar.panel.icon` Component Factory,由它拥有 `sidebar.panellist` list,并声明 `sidebar.panel.trailing` Component Factory,由它拥有 `sidebar.panellist.trailing` list;面板行和更多菜单通过前者渲染面板注册的图标,面板行通过后者渲染行尾内容。面板元数据由列表注册和 locale 变化派生;选中态属于布局存储。注入的 `trackEntryClick(attributes)` 转发到 `ctx.get('productAnalytics')?.track('sidebar_menu_click', attributes)`;`selectPanel` 只负责选中,因此由各控件自行提供入口与位置。 展开态导航的左右外距为 8px,悬停与选中底色在两侧各内缩 3px,前置单元宽 16px,与标签间隔 6px。新会话内容居中,所在行保留 4px 左右外边距及 6px 底部外边距。导航额外保留滚动区外的 4px 与滚动区内、随内容滚走的 8px 间距。logo 行无底部外边距;内容从侧栏左边缘向内 16px 开始,标记与名称间隔 5px。仅 macOS 非全屏、侧栏展开时,顶部开关向右偏移 4px,并在整个淡出期间保持该偏移。折叠态尺寸独立保留。 diff --git a/packages/client/ui-sidebar/src/client/PanelIcon.tsx b/packages/client/ui-sidebar/src/client/PanelIcon.tsx index ba3ed5fc04..85b2fa9262 100644 --- a/packages/client/ui-sidebar/src/client/PanelIcon.tsx +++ b/packages/client/ui-sidebar/src/client/PanelIcon.tsx @@ -10,3 +10,12 @@ import type {} from './contract/slots.ts' export function PanelIcon({ id, size, active, renderSlot }: FactoryComponentPropsOf<'sidebar.panel.icon'>) { return renderSlot('sidebar.panellist', { size, active }, { only: id }) } + +/** + * Render the trailing content registered for one panel in its navigation row. + * @param props - Panel identity, row state, and the authorized child renderer. + * @returns The matching trailing content, or nothing without a registration. + */ +export function PanelTrailing({ id, wide, active, renderSlot }: FactoryComponentPropsOf<'sidebar.panel.trailing'>) { + return renderSlot('sidebar.panellist.trailing', { wide, active }, { only: id }) +} diff --git a/packages/client/ui-sidebar/src/client/SidebarRoot.module.css b/packages/client/ui-sidebar/src/client/SidebarRoot.module.css index 07189fffa7..023dd4a0c6 100644 --- a/packages/client/ui-sidebar/src/client/SidebarRoot.module.css +++ b/packages/client/ui-sidebar/src/client/SidebarRoot.module.css @@ -693,6 +693,26 @@ outline-offset: -2px; } +/* A panel's trailing content follows the title in the row's flow, as a Session row's trailing icons do: a row without + content keeps its full title width, and the title yields room only to content that shows. On the collapsed rail it + sits over the icon's top trailing corner. */ +.panelTrailing { + flex: none; + display: inline-flex; + align-items: center; + margin-left: auto; + color: var(--dsw-alias-label-tertiary); + font-size: 12px; + line-height: 18px; + font-variant-numeric: tabular-nums; +} + +.collapsed .panelTrailing { + position: absolute; + right: 5px; + top: 5px; +} + @media (hover: hover) { .panelUnpin { opacity: 0; } .panelEntry:hover { background-color: var(--dsw-alias-interactive-bg-hover); } diff --git a/packages/client/ui-sidebar/src/client/SidebarRoot.tsx b/packages/client/ui-sidebar/src/client/SidebarRoot.tsx index 353eea66de..2be8c62182 100644 --- a/packages/client/ui-sidebar/src/client/SidebarRoot.tsx +++ b/packages/client/ui-sidebar/src/client/SidebarRoot.tsx @@ -18,7 +18,7 @@ * scrollbar indirection away while it is elsewhere, so a list the user is not * pointing at carries no bar. */ -import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react' +import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from 'react' import type { PointerEvent as ReactPointerEvent } from 'react' import clsx from 'clsx' import { @@ -67,6 +67,7 @@ function PanelRow({ id, label, wide, unpinLabel, unpinTooltip, canUnpin, usePanelInfo, selectPanel, setPinned, trackEntryClick, renderFactorySlot, }: PanelRowProps) { const active = usePanelInfo(info => info.activePanelId === id) + const trailing = useId() return (
@@ -74,6 +75,7 @@ function PanelRow({ type="button" className={css.panelRow} aria-label={label} + aria-describedby={trailing} aria-current={active ? 'page' : undefined} onClick={() => { const entry = officialEntry(id) @@ -89,6 +91,7 @@ function PanelRow({ {label} )} + {renderFactorySlot('sidebar.panel.trailing', { id, wide, active })} {wide && canUnpin && diff --git a/packages/client/ui-sidebar/src/client/contract/slots.ts b/packages/client/ui-sidebar/src/client/contract/slots.ts index b6c2288656..73c1a7b082 100644 --- a/packages/client/ui-sidebar/src/client/contract/slots.ts +++ b/packages/client/ui-sidebar/src/client/contract/slots.ts @@ -25,6 +25,12 @@ declare module '@deepseek-ai/dsh-client-ui-slots' { props: SidebarPanelIconOwnerProps & { readonly id: string } children: { 'sidebar.panellist': { kind: 'list'; scope: 'root' } } } + /** Render a panel's trailing content in its navigation row. */ + 'sidebar.panel.trailing': { + scope: 'root' + props: SidebarPanelTrailingOwnerProps & { readonly id: string } + children: { 'sidebar.panellist.trailing': { kind: 'list'; scope: 'root'; inline: true } } + } } interface SlotMap { /** Non-interactive notification inside the collapsed sidebar expand button. */ @@ -45,6 +51,14 @@ declare module '@deepseek-ai/dsh-client-ui-slots' { * the sidebar owns the button and resolves its label from list metadata. */ 'sidebar.panellist': { kind: 'list'; scope: 'root'; owner: SidebarPanelIconOwnerProps } + /** + * Non-interactive inline content at the end of a panel's navigation row, registered with the panel's id, such as a + * count. The expanded row lays it out after its title, before the space its unpin action takes, so a row without + * content keeps its full title width; the collapsed rail shows it over the icon's top trailing corner. It renders + * inside the row's button: its text describes that button for assistive technology, so decorative parts are + * `aria-hidden`, and it holds no interactive elements. + */ + 'sidebar.panellist.trailing': { kind: 'list'; scope: 'root'; inline: true; owner: SidebarPanelTrailingOwnerProps } /** Rows of the panel list's More menu; the sidebar shows More only while this list has registrations. */ 'sidebar.panellist.actions': { kind: 'list'; scope: 'root'; owner: SidebarPanelActionsOwnerProps } /** @@ -107,6 +121,14 @@ export interface SidebarPanelIconOwnerProps { active: boolean } +/** Row state supplied to a panel's trailing content. */ +export interface SidebarPanelTrailingOwnerProps { + /** Whether the sidebar is expanded; the collapsed rail leaves room for a mark of a few pixels only. */ + wide: boolean + /** Whether this panel is selected in the main column. */ + active: boolean +} + /** Serializable metadata for one active global panel list registration. */ export interface SidebarPanelMetadata { /** List id and matching main panel key. */ diff --git a/packages/client/ui-sidebar/src/client/index.ts b/packages/client/ui-sidebar/src/client/index.ts index 981ea23d3a..8a31e46308 100644 --- a/packages/client/ui-sidebar/src/client/index.ts +++ b/packages/client/ui-sidebar/src/client/index.ts @@ -14,7 +14,7 @@ import type { SidebarPanelMetadata, SidebarRootInjected, SidebarSectionInjected import { createPanelPins } from './panel-pins.ts' import { HeaderLeadingControls } from './HeaderLeadingControls.tsx' import { SidebarRoot } from './SidebarRoot.tsx' -import { PanelIcon } from './PanelIcon.tsx' +import { PanelIcon, PanelTrailing } from './PanelIcon.tsx' import { en, ja, es, fr, de, ru, pt, zh, type SidebarKey } from './locales.ts' export type { @@ -90,6 +90,10 @@ export function apply(ctx: ClientContext): void { name: 'sidebar.panel.icon', scope: 'root', children: { 'sidebar.panellist': { kind: 'list', scope: 'root' } }, }, PanelIcon) + yield ctx.slots.registerFactory({ + name: 'sidebar.panel.trailing', scope: 'root', + children: { 'sidebar.panellist.trailing': { kind: 'list', scope: 'root', inline: true } }, + }, PanelTrailing) yield ctx.slots.register({ name: 'sidebar', locale: NS, diff --git a/packages/client/ui-sidebar/tests/panel-list.client.spec.tsx b/packages/client/ui-sidebar/tests/panel-list.client.spec.tsx index 554192b591..84b73a5133 100644 --- a/packages/client/ui-sidebar/tests/panel-list.client.spec.tsx +++ b/packages/client/ui-sidebar/tests/panel-list.client.spec.tsx @@ -511,3 +511,68 @@ describe('sidebar entry click analytics', () => { expect(layout.selectPanel).not.toHaveBeenCalled() }) }) + +/** Trailing content that names the row state it receives; its visible count is decorative and its text describes the row. */ +function Count({ wide, active }: PropsRuntime<'sidebar.panellist.trailing'>) { + return ( + + + 6 waiting + + ) +} + +async function mountCount(runtime: SlotTestRuntime, id: MainPanelId) { + return runtime.mount({ + inject: ['slots'], + apply(ctx: Context) { + ctx.slots.inject('sidebar.panellist.trailing', () => ctx.slots.register({ name: 'sidebar.panellist.trailing', id }, Count)) + }, + }) +} + +describe('sidebar panel trailing content', () => { + it('shows a panel registration in its own row only, describing the row button, and follows the selection', async () => { + const { runtime, locale, view } = await bench() + await mountPanels(runtime, locale) + await mountCount(runtime, ALPHA) + + const alpha = await view.findByRole('button', { name: 'Alpha panel' }) + const beta = view.getByRole('button', { name: 'Beta panel' }) + expect(alpha.getAttribute('aria-describedby')).not.toBeNull() + const described = document.getElementById(alpha.getAttribute('aria-describedby') ?? '') + expect(described?.textContent).toBe('66 waiting') + expect(within(described as HTMLElement).getByTestId('count').dataset).toMatchObject({ wide: 'true', active: 'false' }) + expect(document.getElementById(beta.getAttribute('aria-describedby') ?? '')?.textContent).toBe('') + expect(view.getAllByTestId('count')).toHaveLength(1) + // The content sits inside the row button after its title; the slot wrappers are inline spans, so nesting stays valid. + expect(alpha.contains(described)).toBe(true) + expect(described?.previousElementSibling?.textContent).toBe('Alpha panel') + const wrappers = [...(described?.querySelectorAll('[data-slot]') ?? [])] + expect(wrappers.length).toBeGreaterThan(0) + expect(wrappers.every(wrapper => wrapper.tagName === 'SPAN')).toBe(true) + expect(described?.querySelector('div')).toBeNull() + + fireEvent.click(alpha) + await waitFor(() => { expect(view.getByTestId('count').dataset.active).toBe('true') }) + }) + + it('tells the collapsed rail it is not wide', async () => { + const { runtime, locale, view } = await bench(true) + await mountPanels(runtime, locale) + await mountCount(runtime, BETA) + + await waitFor(() => { expect(view.getByTestId('count').dataset.wide).toBe('false') }) + }) + + it('removes the content when its registering fiber is disposed', async () => { + const { runtime, locale, view } = await bench() + await mountPanels(runtime, locale) + const count = await mountCount(runtime, ALPHA) + await view.findByTestId('count') + + await act(async () => { await count.dispose() }) + expect(view.queryByTestId('count')).toBeNull() + expect(view.getByRole('button', { name: 'Alpha panel' })).toBeTruthy() + }) +}) diff --git a/packages/client/ui-sidebar/tests/sidebar-styles.client.spec.ts b/packages/client/ui-sidebar/tests/sidebar-styles.client.spec.ts index d6f250313d..789c7cd550 100644 --- a/packages/client/ui-sidebar/tests/sidebar-styles.client.spec.ts +++ b/packages/client/ui-sidebar/tests/sidebar-styles.client.spec.ts @@ -194,4 +194,21 @@ describe('SidebarRoot.module.css', () => { expect(declarations('.fallbackBrandName')?.get('font-size')).toBe('17px') expect(declarations('.fallbackBrandName')?.get('white-space')).toBe('nowrap') }) + + it('lays panel trailing content out after the title like a Session row, reserving no room without content', () => { + const trailing = declarations('.panelTrailing') + expect(trailing?.get('flex')).toBe('none') + expect(trailing?.get('margin-left')).toBe('auto') + expect(trailing?.has('position')).toBe(false) + expect(declarations('.panelEntryWide .panelRow')?.get('padding-right')).toBe('38px') + expect(css).not.toMatch(/\.panelTrailing:(?:not\()?:?empty/) + expect(css).not.toMatch(/\.panelRow\s*\{[^}]*padding-right:\s*72px/) + }) + + it('pins panel trailing content over the collapsed rail icon\'s top trailing corner', () => { + const collapsed = declarations('.collapsed .panelTrailing') + expect(collapsed?.get('position')).toBe('absolute') + expect(collapsed?.get('right')).toBe('5px') + expect(collapsed?.get('top')).toBe('5px') + }) }) diff --git a/packages/client/ui-subagent/README.i18n.yaml b/packages/client/ui-subagent/README.i18n.yaml index 855eca71ba..0666bc24d6 100644 --- a/packages/client/ui-subagent/README.i18n.yaml +++ b/packages/client/ui-subagent/README.i18n.yaml @@ -15,8 +15,8 @@ en: d152484eb41ac6b4 zh: 09388d293f9be9cb /deepseek-ai-dsh-client-ui-subagent/use-this-package: - en: 77677cfa89b26de8 - zh: 83909430c95f3a6b + en: e912edfd1406cc33 + zh: da0a59a27fb4a65c /deepseek-ai-dsh-client-ui-subagent/use-this-package/browsing-the-tree: en: da87d582146106c4 zh: f640b3a3fcc11209 diff --git a/packages/client/ui-subagent/README.md b/packages/client/ui-subagent/README.md index e1a6e31218..f64c1a7b2c 100644 --- a/packages/client/ui-subagent/README.md +++ b/packages/client/ui-subagent/README.md @@ -27,7 +27,7 @@ Browse local subagent conversations and external tasks in the Session panel's Su The session header uses the session title for ordinary breadcrumbs. Subagent breadcrumbs prefer the original creation description (`entry.label`), then the agent name (`entry.name`), then the Session id. Ordinary and subagent breadcrumb titles both use 14px text with a 20px line height. Each subagent breadcrumb title is a switcher over its parent's direct catalog that marks the title's Session as current; root Sessions have no switcher. The [Session panel](../ui-session-panel/README.md#contribute-a-section) section `subagents` (order 200, titled “Subagents”) lists the current Session's direct catalog, in root and child conversations alike, when the catalog has entries or a read has failed. Showing the section reads nothing; expanding a branch prepares that branch. An absent or empty catalog hides the section and its title unless a footer contribution is available and the Session's enabled `agentTeam` projection has nondeleted shared tasks or a task-record error. Enabling Team mode alone does not show an empty section. Select a local child at any depth to open that child's conversation with its exact `{parentSessionId, childSessionId, mode}` address, or use a noncurrent local row's trailing arrow to open the same address in the right Sidebar, preferring a separate pane when room permits. Either action closes the panel's overlay or the switcher menu that holds the row. -This package registers the `dsh-resource://subagentchat/session/?parent=&mode=` resource and builtin Sidebar tab type. The resource retains the child `SessionReference` directly from its address without refreshing the parent catalog, and releases the reference when the tab record closes. The tab renders the shared `conversation.content` Factory through `sidebar.chat.conversation`, fixes the local View to Chat, and omits the main Conversation header and width controls. +This package registers the `dsh-resource://subagentchat/session/?parent=&mode=` resource and builtin Sidebar tab type. The resource retains the child `SessionReference` directly from its address without refreshing the parent catalog, and releases the reference when the tab record closes. The tab renders the shared `conversation.content` Factory through `sidebar.chat.conversation`, fixes the local View to Chat, and omits the main Conversation header and width controls. A Workspace picked in a blank child's Hero opens that Workspace's blank Session as the main Session and moves the draft to it, as the main Conversation does. The section's title control (`conversation.session.panel.section.actions`, key `subagents`) shows direct-member progress: completed, in progress, not running, and external counts in that order, with zero counts omitted and the separator matching the input task list. External tasks never count as running or completed. The section lists running subagents first, the most recently started first, and then the others, the most recently updated first. It shows five rows and then the Session panel's fold control, “Show {count} more”, which shows the rest and then reads “Show less”; the list folds only when that holds back two rows or more, the choice holds for the Session, also after the panel is hidden and shown again, and an expanded branch's own rows all show. The section hides with its title while the Session has no subagents and no failed catalog read. While direct subagents run and the panel does not show, a blue dot on the panel toggle (`conversation.session.panel.indicator`) says so and names their number for assistive technology; external tasks do not count. The Session panel scrolls the section; the tree has no nested scrolling. The breadcrumb switcher menu is 360px wide with 6px outer padding, constrained to fit the layout viewport, and only the menu scrolls. In WebKit-compatible browsers, its native 5px scrollbar sits in the right 6px inset with inset track ends and a stable gutter, preserving content width when scrolling becomes necessary. Other browsers retain their standard native scrollbar. diff --git a/packages/client/ui-subagent/README.zh.md b/packages/client/ui-subagent/README.zh.md index eaf55b25f9..4a794b4476 100644 --- a/packages/client/ui-subagent/README.zh.md +++ b/packages/client/ui-subagent/README.zh.md @@ -27,7 +27,7 @@ kind: "package-reference" 会话页头的普通面包屑使用会话标题。subagent 面包屑优先使用创建时的原始描述(`entry.label`),其次使用智能体名称(`entry.name`),最后回退到 Session id。普通与 subagent 面包屑标题均使用 14px 文字和 20px 行高。每个 subagent 面包屑标题都是覆盖其父会话直接目录的切换器,并把该标题对应的 Session 标为当前项;根 Session 没有切换器。[会话面板](../ui-session-panel/README.zh.md#contribute-a-section)分栏 `subagents`(order 200,标题为“子智能体”)在根会话和子会话中都列出当前 Session 的直接目录,前提是目录有子项或读取失败。显示分栏不读取任何内容;展开分支时准备该分支。目录缺席或为空时,分栏连同标题一起隐藏,除非存在可用的 footer 扩展,且 Session 已开启的 `agentTeam` 投影含有未删除的共享任务或任务记录错误。仅开启 Team 模式不会显示空分栏。选择任意深度的本地 child,即可用该子会话的确切 `{parentSessionId, childSessionId, mode}` 地址打开其对话;也可以使用非当前本地行的行尾箭头在右侧 Sidebar 打开同一地址,并在空间允许时优先使用独立分栏。两种操作都会关闭面板浮层或该行所在的切换器菜单。 -本包注册 `dsh-resource://subagentchat/session/?parent=&mode=` 资源与 builtin Sidebar tab 类型。资源直接根据地址保留 child 的 `SessionReference`,不刷新 parent 目录,并在 tab 记录关闭时释放 reference。tab 通过 `sidebar.chat.conversation` 渲染共享 `conversation.content` Factory,把局部 View 固定为 Chat,并省略主 Conversation 的 Header 与宽度控制。 +本包注册 `dsh-resource://subagentchat/session/?parent=&mode=` 资源与 builtin Sidebar tab 类型。资源直接根据地址保留 child 的 `SessionReference`,不刷新 parent 目录,并在 tab 记录关闭时释放 reference。tab 通过 `sidebar.chat.conversation` 渲染共享 `conversation.content` Factory,把局部 View 固定为 Chat,并省略主 Conversation 的 Header 与宽度控制。在空白 child 的 Hero 中选择工作区时,与主 Conversation 一样,把该工作区的空白 Session 打开为主 Session,并把草稿移过去。 分栏的标题控件(`conversation.session.panel.section.actions`,键为 `subagents`)显示直接成员进度:依次为已完成、进行中、未运行和外部任务数量;省略零值,分隔符与输入区任务列表一致。外部任务不计入运行中或已完成数量。分栏把运行中的子智能体排在最前,最近开始的在前,然后是其余的,最近更新的在前。它只显示五行,然后是会话面板的收起控件「显示其余 {count} 个」,点击后显示其余的行并变为「收起」;只有能收起两行及以上时列表才收起,这个选择在 Session 内保持,隐藏后再次显示面板也不变;展开某个分支后,该分支自己的行全部显示。会话没有子智能体且目录读取未失败时,分栏连同标题一起隐藏。直接子智能体运行中且面板未显示时,面板开关上的蓝点(`conversation.session.panel.indicator`)会提示这一状态,并向辅助技术说明数量;外部任务不计入。会话面板负责分栏滚动,目录树不单独滚动。面包屑切换器菜单宽度为 360px,外层内边距为 6px,并受布局视口可用宽度约束,仅菜单本身滚动。在兼容 WebKit 的浏览器中,其原生 5px 滚动条位于右侧 6px 内边距内,轨道两端内缩,并保留稳定的滚动条空间,使内容在需要滚动时保持原有宽度。其他浏览器保留标准原生滚动条。 diff --git a/packages/client/ui-subagent/src/client/sidebar-chat/index.tsx b/packages/client/ui-subagent/src/client/sidebar-chat/index.tsx index 7fa90b5286..a191bb340e 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/index.tsx +++ b/packages/client/ui-subagent/src/client/sidebar-chat/index.tsx @@ -4,7 +4,7 @@ import type { ISessions, SessionReference, } from '@deepseek-ai/dsh-api-session-controller/client' import type { ResourceProvider } from '@deepseek-ai/dsh-client-resources/client' -import type { ConversationViewsProps } from '@deepseek-ai/dsh-client-ui-conversation/client' +import type { ConversationViewsProps, WorkspaceSelectedHandler } from '@deepseek-ai/dsh-client-ui-conversation/client' import type { SidebarRightTabDefinition } from '@deepseek-ai/dsh-client-ui-sidebar-right/client' import type { PropsRenderFactories, PropsRenderSlots, PropsRuntime, TranslateNS, @@ -39,7 +39,7 @@ declare module '@deepseek-ai/dsh-client-ui-slots' { interface SlotMap { /** Session-scoped Conversation occurrence hosted by one Sidebar chat tab. */ - 'sidebar.chat.conversation': { kind: 'single'; scope: 'session' } + 'sidebar.chat.conversation': { kind: 'single'; scope: 'session'; inject: SidebarChatInjected } } } @@ -117,6 +117,12 @@ function subagentChatResourceProvider(sessions: ISessions): ResourceProvider<'su } } +/** Navigation injected into the child-Session Conversation host. */ +export interface SidebarChatInjected { + /** Open the Workspace's blank Session as the main Session. */ + readonly openWorkspace: WorkspaceSelectedHandler +} + /** Fixed Chat selection used by an embedded Conversation occurrence. */ export function FixedChatConversationView(props: ConversationViewsProps) { return <>{props.renderSlot('conversation.session', { view: 'chat' })} @@ -127,7 +133,7 @@ export type ConversationSlotPanelProps = PropsRuntime<'sidebar.chat.conversation /** Render the shared Conversation content for one explicitly provided child Session. */ export function ConversationSlotPanel({ - sessionId, useSession, useConversation, useSessions, renderFactorySlot, + sessionId, useSession, useConversation, useSessions, renderFactorySlot, openWorkspace, }: ConversationSlotPanelProps) { const session = useSession(value => value) const conversation = useConversation(value => value) @@ -139,7 +145,7 @@ export function ConversationSlotPanel({ const settling = (shellPhase === 'blank' && session.openState === 'loading' && summaryBlank !== true) const hero = shellPhase === 'blank' && (session.openState === 'open' || summaryBlank === true) const phase = settling ? 'settling' : hero ? 'hero' : 'active' - return renderFactorySlot('conversation.content', { variant: 'embedded', phase, hero }, { + return renderFactorySlot('conversation.content', { variant: 'embedded', phase, hero, onWorkspaceSelected: openWorkspace }, { slots: { views: FixedChatConversationView }, }) } @@ -188,10 +194,13 @@ export function registerSidebarChat(ctx: Context, t: TranslateNS): vo : ctx.sessions.list.getSnapshot().byId[child]?.projectionValues?.subagent?.label ?? child }, } satisfies SidebarRightTabDefinition), 'ui-subagent: Sidebar chat type') + const chatInjected: SidebarChatInjected = { + openWorkspace: (workspaceId, adopt) => ctx.uiWorkspace.openWorkspace(workspaceId, adopt), + } ctx.effect(() => ctx.slots.inject('sidebar.right.pane.tab', () => ctx.slots.register({ name: 'sidebar.right.pane.tab', key: SUBAGENT_CHAT_ID, - children: { 'sidebar.chat.conversation': { kind: 'single', scope: 'session' } }, + children: { 'sidebar.chat.conversation': { kind: 'single', scope: 'session', inject: chatInjected } }, }, SidebarChatTab)), 'ui-subagent: Sidebar chat body') ctx.effect(() => ctx.slots.inject('sidebar.chat.conversation', () => ctx.slots.register({ name: 'sidebar.chat.conversation', diff --git a/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx b/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx index db15c9cfe7..2ce07e3c8e 100644 --- a/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx +++ b/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx @@ -85,6 +85,7 @@ describe('Sidebar chat registration', () => { let provider: ResourceProvider<'subagentchat'> | undefined let definition: SidebarRightTabDefinition | undefined const registrations: { options: Record; component: unknown }[] = [] + const openWorkspace = vi.fn(() => Promise.resolve()) const ctx = { sessions: { retain, refreshProjections, list } as unknown as ISessions, resources: { register: (value: ResourceProvider<'subagentchat'>) => { provider = value; return () => {} } }, @@ -99,7 +100,7 @@ describe('Sidebar chat registration', () => { effect: (install: () => unknown) => { install(); return () => {} }, } as unknown as Context - registerSidebarChat(ctx, (key: string) => key === 'sidebar.chat' ? 'Chat' : key) + registerSidebarChat(Object.assign(ctx, { uiWorkspace: { openWorkspace } }), (key: string) => key === 'sidebar.chat' ? 'Chat' : key) expect(definition?.id).toBe(SUBAGENT_CHAT_ID) expect(definition?.kind).toBe('subagentchat') @@ -112,6 +113,13 @@ describe('Sidebar chat registration', () => { 'sidebar.right.pane.tab', 'sidebar.chat.conversation', ]) + // A Workspace picked in the child's Hero opens as the main Session, as it does in the main Conversation. + const children = registrations[0]?.options.children as { + 'sidebar.chat.conversation': { inject: { openWorkspace: (workspaceId: string, adopt: () => void) => Promise } } + } + const adopt = vi.fn() + await children['sidebar.chat.conversation'].inject.openWorkspace('workspace-1', adopt) + expect(openWorkspace).toHaveBeenCalledWith('workspace-1', adopt) const controller = new AbortController() const stream = provider!.open(subagentChatAddress(ADDRESS), { signal: controller.signal })[Symbol.asyncIterator]() @@ -204,6 +212,7 @@ describe('Sidebar chat components', () => { ])('derives the $name embedded phase and fixes the local view to Chat', ({ session: patch, summaryBlank, expected }) => { const snapshot = { ...sessionSnapshot(CHILD), ...patch } as SessionSnapshot const renderFactorySlot = vi.fn(() => null) + const openWorkspace = vi.fn() render( unknown) => select(snapshot), @@ -212,10 +221,10 @@ describe('Sidebar chat components', () => { ids: [], byId: { [CHILD]: { blank: summaryBlank } }, phase: 'ready', projectionsBySession: {}, jobsBySession: {}, } as unknown as SessionListState), renderFactorySlot, - } as unknown as Parameters[0])} />) + } as unknown as Parameters[0])} openWorkspace={openWorkspace} />) expect(renderFactorySlot).toHaveBeenCalledWith( 'conversation.content', - { variant: 'embedded', ...expected }, + { variant: 'embedded', ...expected, onWorkspaceSelected: openWorkspace }, { slots: { views: FixedChatConversationView } }, ) }) diff --git a/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts b/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts index e6bc39f269..22c3e0832c 100644 --- a/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts +++ b/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts @@ -3322,7 +3322,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], keyDomain: '', hookContext: '', - slotInject: '', + slotInject: 'ConversationShellInjected', declaredBy: 'an entry in \'main\' (client-ui-conversation), so it exists while that entry is mounted', occupants: [ 'client-ui-conversation ConversationRoot', @@ -4760,7 +4760,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'shadows-shipped-ui', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.brand.mark\', () => ctx.slots.register(\n { name: \'sidebar.brand.mark\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:37', + source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:43', }, { key: 'sidebar.brand.name', @@ -4795,7 +4795,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'shadows-shipped-ui', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.brand.name\', () => ctx.slots.register(\n { name: \'sidebar.brand.name\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:42', + source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:48', }, { key: 'sidebar.chat.conversation', @@ -4829,7 +4829,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], keyDomain: '', hookContext: '', - slotInject: '', + slotInject: 'SidebarChatInjected', declaredBy: 'an entry in \'sidebar.right.pane.tab\' (client-ui-subagent), so it exists while that entry is mounted', occupants: [ 'client-ui-subagent ConversationSlotPanel', @@ -4889,7 +4889,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.footer.action\', () => ctx.slots.register(\n { name: \'sidebar.footer.action\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:75', + source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:89', }, { key: 'sidebar.panellist', @@ -4943,7 +4943,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.panellist\', () => ctx.slots.register(\n { name: \'sidebar.panellist\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:47', + source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:53', }, { key: 'sidebar.panellist.actions', @@ -4998,7 +4998,58 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.panellist.actions\', () => ctx.slots.register(\n { name: \'sidebar.panellist.actions\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:49', + source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:63', + }, + { + key: 'sidebar.panellist.trailing', + kind: 'list', + scope: 'root', + summary: 'Non-interactive inline content at the end of a panel\'s navigation row, registered with the panel\'s id, such as a count.', + doc: 'Non-interactive inline content at the end of a panel\'s navigation row, registered with the panel\'s id, such as a\ncount. The expanded row lays it out after its title, before the space its unpin action takes, so a row without\ncontent keeps its full title width; the collapsed rail shows it over the icon\'s top trailing corner. It renders\ninside the row\'s button: its text describes that button for assistive technology, so decorative parts are\n`aria-hidden`, and it holds no interactive elements.', + registerOptions: [ + { + name: 'id', + requirement: 'required', + type: 'string', + doc: 'Your cell key. Use an id of your own: a fresh id is added beside the shipped entries, while reusing a shipped id puts you in THAT cell and replaces it. Owners that filter by id address you by it.', + }, + { + name: 'order', + requirement: 'optional', + type: 'number', + doc: 'Position among the entries, ascending (default 0).', + }, + { + name: 'label', + requirement: 'optional', + type: 'string | (() => string)', + doc: 'Display text where the owner projects one (nav rows, tabs). A thunk is re-read on every projection, so localized text follows the active locale without re-registering.', + }, + ], + ownerProps: [ + '/** Row state supplied to a panel\'s trailing content. */\nexport interface SidebarPanelTrailingOwnerProps {\n /** Whether the sidebar is expanded; the collapsed rail leaves room for a mark of a few pixels only. */\n wide: boolean\n /** Whether this panel is selected in the main column. */\n active: boolean\n}', + ], + ownerPropsReferences: [], + standardProps: [ + 'useRemoteAccess: (action: RemoteEndpoint) => boolean', + 'useResource: UseResource', + 'useContextMenu: UseContextMenu', + 'useWorkspaces: SnapshotSelectorHook', + 'usePanelInfo: UsePanelInfo', + 'useSessionStatus: UseSessionStatus', + 'useSessions: UseSessions', + 'useSessionRetainInfo: UseSessionRetainInfo', + 'useSessionAccess: (sessionId: SessionId, action: RemoteEndpoint) => boolean', + 'useWorkspaceAccess: (workspaceId: WorkspaceId, action: RemoteEndpoint) => boolean', + ], + keyDomain: '', + hookContext: '', + slotInject: '', + declaredBy: 'factory \'sidebar.panel.trailing\' (client-ui-sidebar), so it exists while that definition is registered', + occupants: [], + replaceRisk: 'none', + example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.panellist.trailing\', () => ctx.slots.register(\n { name: \'sidebar.panellist.trailing\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', + source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:61', }, { key: 'sidebar.right.pane.tab', @@ -5721,7 +5772,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'wraps-owner-content', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.session.action\', () => ctx.slots.register(\n { name: \'sidebar.session.action\', id: \'my-layer\', order: 100 },\n ({ children }) => React.createElement(\'div\', null, children),\n ))\n },\n}', - source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:86', + source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:100', }, { key: 'sidebar.session.row.hover', @@ -5922,7 +5973,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'shadows-shipped-ui', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.settings\', () => ctx.slots.register(\n { name: \'sidebar.settings\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:70', + source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:84', }, { key: 'sidebar.toggle.badge', @@ -5954,7 +6005,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'shadows-shipped-ui', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.toggle.badge\', () => ctx.slots.register(\n { name: \'sidebar.toggle.badge\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:31', + source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:37', }, { key: 'sidebar.workspaces', @@ -5988,7 +6039,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'shadows-shipped-ui', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.workspaces\', () => ctx.slots.register(\n { name: \'sidebar.workspaces\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:58', + source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:72', }, { key: 'sidebar.workspaces.directoryFlow',