From 5a7589bf89708799aa219b51324c9ace9ce786e1 Mon Sep 17 00:00:00 2001 From: Turtle Date: Fri, 20 Nov 2026 04:33:40 +0800 Subject: [PATCH 01/11] feat(web): open a dragged Session in the right sidebar Drag a Session row from the Session list onto the drop target at the window's right edge to open its Conversation in the on-screen Session's right sidebar, where it accepts follow-up prompts. The tab is saved with that Session's browser-local sidebar layout. Refs #8873 Co-authored-by: liukx0205 <69756503+liukx0205@users.noreply.github.com> Co-authored-by: Yifffan <133629972+Yifffan@users.noreply.github.com> --- packages/client/ui-subagent/README.i18n.yaml | 4 +- packages/client/ui-subagent/README.md | 2 + packages/client/ui-subagent/README.zh.md | 2 + .../sidebar-chat/SessionDropZone.module.css | 68 ++++++++++ .../client/sidebar-chat/SessionDropZone.tsx | 72 ++++++++++ .../src/client/sidebar-chat/index.tsx | 120 ++++++++++++++--- .../tests/session-drop.client.spec.tsx | 127 ++++++++++++++++++ .../tests/sidebar-chat.client.spec.tsx | 49 ++++++- packages/client/ui-workspace/README.i18n.yaml | 8 +- packages/client/ui-workspace/README.md | 4 +- packages/client/ui-workspace/README.zh.md | 4 +- .../ui-workspace/src/client/contract/slots.ts | 6 + .../client/ui-workspace/src/client/index.ts | 2 +- .../ui-workspace/src/client/rows/Rows.tsx | 25 +++- .../src/client/rows/WorkspaceBrowser.tsx | 8 +- .../ui-workspace/tests/rows.client.spec.tsx | 38 ++++-- .../tests/workspace-browser.client.spec.tsx | 68 +++++++--- .../src/client/slot-catalog.ts | 19 +-- 18 files changed, 545 insertions(+), 81 deletions(-) create mode 100644 packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css create mode 100644 packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx create mode 100644 packages/client/ui-subagent/tests/session-drop.client.spec.tsx diff --git a/packages/client/ui-subagent/README.i18n.yaml b/packages/client/ui-subagent/README.i18n.yaml index 0666bc24d6..d4e1c4f8bd 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: e912edfd1406cc33 - zh: da0a59a27fb4a65c + en: f14602d90bd2050c + zh: 3e07260df8e52965 /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 f64c1a7b2c..be08239bc1 100644 --- a/packages/client/ui-subagent/README.md +++ b/packages/client/ui-subagent/README.md @@ -29,6 +29,8 @@ The session header uses the session title for ordinary breadcrumbs. Subagent bre 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. +Dragging a root Session row from the Session list shows a drop target over the window's right 40%, at least 300px wide, while another Session is on screen. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/`, an address without a query, in the on-screen Session's Sidebar column, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title. + 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. Breadcrumb switcher menus show navigation only. diff --git a/packages/client/ui-subagent/README.zh.md b/packages/client/ui-subagent/README.zh.md index 4a794b4476..86ac6c40e1 100644 --- a/packages/client/ui-subagent/README.zh.md +++ b/packages/client/ui-subagent/README.zh.md @@ -29,6 +29,8 @@ kind: "package-reference" 本包注册 `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,并把草稿移过去。 +从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,窗口右侧 40% 的区域(宽度至少 300px)会显示放置目标。在此放下后,会在屏幕上那个 Session 的 Sidebar 栏中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 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/SessionDropZone.module.css b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css new file mode 100644 index 0000000000..08726f3da2 --- /dev/null +++ b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css @@ -0,0 +1,68 @@ +/* The drop target covers the right column's default 40% band, like the dock + kit's edge band, and draws the dock kit's drop hint: a blurred ground under + a dashed card that takes the accent while the pointer is over it. */ +.zone { + position: fixed; + top: var(--dsh-frame-top-clearance, 0px); + right: 0; + bottom: 0; + box-sizing: border-box; + display: flex; + width: max(300px, 40vw); + max-width: 100vw; + padding: 8px; + pointer-events: auto; + background: color-mix(in srgb, var(--dsw-alias-bg-base) 72%, transparent); + backdrop-filter: blur(6px); + animation: zoneIn 140ms ease-out; +} + +.card { + display: flex; + flex: 1 1 auto; + flex-direction: column; + gap: 8px; + align-items: center; + justify-content: center; + min-width: 0; + padding: 12px; + overflow: hidden; + color: var(--dsw-alias-label-tertiary); + border: 1.5px dashed var(--dsw-alias-border-l2); + border-radius: var(--dsw-radius-lg); + transition: color 120ms ease-out, background-color 120ms ease-out, border-color 120ms ease-out; +} + +.zone[data-active] .card { + color: var(--dsw-alias-label-secondary); + background: color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color) 8%, transparent); + border-color: var(--dsw-alias-brand-primary-new-colorprimary-new-color); +} + +/* The left sidebar's panel icon, mirrored, as on the right Sidebar's expand button. */ +.icon { + flex: none; + width: 20px; + height: 20px; + transform: scaleX(-1); +} + +.label { + max-width: 100%; + overflow: hidden; + font-size: var(--dsh-content-font-size-secondary, 13px); + font-weight: 500; + line-height: 1.4; + text-overflow: ellipsis; + white-space: nowrap; +} + +@keyframes zoneIn { + from { opacity: 0; } + to { opacity: 1; } +} + +@media (prefers-reduced-motion: reduce) { + .zone { animation: none; } + .card { transition: none; } +} diff --git a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx new file mode 100644 index 0000000000..6f7e720e6d --- /dev/null +++ b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx @@ -0,0 +1,72 @@ +/** Drop target that opens a Session dragged from the Session list in the right Sidebar. */ +import { useState, type DragEvent } from 'react' +import { IconPanelLeftOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives' +import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots' +import type { SessionId } from '@deepseek-ai/dsh-session/types' +import type { SessionDragType } from '@deepseek-ai/dsh-client-ui-workspace/client' +import type { NS } from '../locales.ts' +import css from './SessionDropZone.module.css' + +/** Drag data type the Session list sets to a dragged row's Session id. */ +export const SESSION_DRAG_TYPE: SessionDragType = 'application/x-dsh-session' + +/** Session drag tracking and the open operation supplied by the plugin. */ +export interface SessionDropZoneInjected { + readonly hooks: { + /** Session dragged from the list that the on-screen Session's Sidebar can open; undefined otherwise. */ + readonly sessionDrag: HostObservable + } + /** Open the Session's Conversation in the on-screen Session's right Sidebar. */ + readonly openAside: (sessionId: SessionId) => void +} + +/** Props of the `shell.overlay` drop target. */ +export type SessionDropZoneProps = + PropsRuntime<'shell.overlay'> & PropsLocale & InjectFace + +/** + * Show the right-edge drop target while a Session row is dragged. + * @param props - tracked drag, open operation, and copy. + * @returns the drop target, or nothing outside a Session drag. + */ +export function SessionDropZone({ useSessionDrag, openAside, t }: SessionDropZoneProps) { + const sessionId = useSessionDrag(value => value) + return sessionId === undefined + ? null + : { openAside(sessionId) }} /> +} + +function DropTarget({ label, onDrop }: { readonly label: string; readonly onDrop: () => void }) { + const [over, setOver] = useState(false) + // Stop propagation so document-level handlers of the list's reorder drag + // keep neither the drop nor their `move` effect. + const accept = (event: DragEvent): void => { + event.preventDefault() + event.stopPropagation() + event.dataTransfer.dropEffect = 'copy' + setOver(true) + } + return ( +
{ + if (!(event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget))) setOver(false) + }} + onDrop={(event) => { + event.preventDefault() + event.stopPropagation() + setOver(false) + onDrop() + }} + > +
+
+
+ ) +} 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 a191bb340e..6318dd0573 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/index.tsx +++ b/packages/client/ui-subagent/src/client/sidebar-chat/index.tsx @@ -1,18 +1,19 @@ -/** Right-Sidebar presentation of an existing subagent Conversation. */ +/** Right-Sidebar presentation of an existing subagent or dragged root Session Conversation. */ import type { Context } from '@deepseek-ai/cordis' import type { - ISessions, SessionReference, + ISessions, SessionReference, SessionTarget, } from '@deepseek-ai/dsh-api-session-controller/client' import type { ResourceProvider } from '@deepseek-ai/dsh-client-resources/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, + HostObservable, PropsRenderFactories, PropsRenderSlots, PropsRuntime, TranslateNS, } from '@deepseek-ai/dsh-client-ui-slots' import type { SessionId } from '@deepseek-ai/dsh-session/types' import type { SubagentAddress } from '@deepseek-ai/dsh-subagent/client' -import type { NS } from '../locales.ts' +import { NS } from '../locales.ts' import css from './SidebarChat.module.css' +import { SESSION_DRAG_TYPE, SessionDropZone, type SessionDropZoneInjected } from './SessionDropZone.tsx' /** Stable implementation identity for the Sidebar tab body. */ export const SUBAGENT_CHAT_ID = '@deepseek-ai/dsh-client-ui-subagent' @@ -22,7 +23,7 @@ export const SUBAGENT_CHAT_ADDRESS = 'dsh-resource://subagentchat/session/' /** Value retained by one live chat resource occurrence. */ export interface SubagentChatResource { - readonly address: SubagentAddress + readonly address: SessionTarget readonly reference: SessionReference } @@ -56,12 +57,22 @@ export function subagentChatAddress(address: SubagentAddress): string { return `${SUBAGENT_CHAT_ADDRESS}${encodeURIComponent(address.childSessionId)}?${query}` } +/** + * Address one root Session, which carries no routing query. + * @param sessionId - Session dragged from the Session list. + * @returns canonical Sidebar resource address. + */ +export function sessionChatAddress(sessionId: SessionId): string { + return `${SUBAGENT_CHAT_ADDRESS}${encodeURIComponent(sessionId)}` +} + /** * Parse one canonical Sidebar chat resource address. * @param value - possible chat resource address. - * @returns the encoded direct-parent address, or undefined for another or malformed resource. + * @returns the encoded direct-parent address, the root Session id of an address without a query, + * or undefined for another or malformed resource. */ -export function parseSubagentChatAddress(value: string): SubagentAddress | undefined { +export function parseSubagentChatAddress(value: string): SessionTarget | undefined { let url: URL try { url = new URL(value) @@ -71,21 +82,19 @@ export function parseSubagentChatAddress(value: string): SubagentAddress | undef if (url.protocol !== 'dsh-resource:' || url.hostname.toLowerCase() !== 'subagentchat') return undefined const parts = url.pathname.split('/').filter(Boolean) if (parts.length !== 2 || parts[0] !== 'session') return undefined + let sessionId: SessionId + try { + sessionId = decodeURIComponent(parts[1] as string) as SessionId + } catch (_invalidEncoding) { + return undefined + } + if (url.search === '') return sessionId const parentSessionId = url.searchParams.get('parent') const mode = url.searchParams.get('mode') if (parentSessionId === null || parentSessionId === '' || (mode !== 'one-shot' && mode !== 'continuable' && mode !== 'unknown')) { return undefined } - try { - const childSessionId = decodeURIComponent(parts[1] as string) - return { - parentSessionId: parentSessionId as SessionId, - childSessionId: childSessionId as SessionId, - mode, - } - } catch (_invalidEncoding) { - return undefined - } + return { parentSessionId: parentSessionId as SessionId, childSessionId: sessionId, mode } } function waitForAbort(signal: AbortSignal): Promise { @@ -117,6 +126,54 @@ function subagentChatResourceProvider(sessions: ISessions): ResourceProvider<'su } } +/** + * Track Session rows dragged from the Session list while another Session is on screen. + * @param doc - document whose drag events carry the rows' data. + * @param mounted - reads the on-screen Session. + * @returns the dragged Session observable and its listener disposer. + */ +export function trackSessionDrags(doc: Document, mounted: () => SessionId | undefined): { + readonly source: HostObservable + readonly dispose: () => void +} { + let current: SessionId | undefined + const listeners = new Set<() => void>() + const publish = (next: SessionId | undefined): void => { + if (next === current) return + current = next + for (const listener of listeners) listener() + } + // The row's React handler has set the drag data by the time dragstart bubbles here. + const start = (event: DragEvent): void => { + const id = event.dataTransfer?.getData(SESSION_DRAG_TYPE) as SessionId | undefined + const onScreen = mounted() + publish(id !== undefined && id !== '' && onScreen !== undefined && onScreen !== id ? id : undefined) + } + const end = (): void => { publish(undefined) } + // A source row unmounted mid-drag fires dragend on a detached node; the first + // button-free mouse move after the drag clears the zone instead. + const move = (event: MouseEvent): void => { if (event.buttons === 0) end() } + doc.addEventListener('dragstart', start) + doc.addEventListener('dragend', end) + doc.addEventListener('drop', end) + doc.addEventListener('mousemove', move) + return { + source: { + getSnapshot: () => current, + subscribe: (listener) => { + listeners.add(listener) + return () => { listeners.delete(listener) } + }, + }, + dispose: () => { + doc.removeEventListener('dragstart', start) + doc.removeEventListener('dragend', end) + doc.removeEventListener('drop', end) + doc.removeEventListener('mousemove', move) + }, + } +} + /** Navigation injected into the child-Session Conversation host. */ export interface SidebarChatInjected { /** Open the Workspace's blank Session as the main Session. */ @@ -188,10 +245,11 @@ export function registerSidebarChat(ctx: Context, t: TranslateNS): vo priority: 'builtin', canOpen: address => parseSubagentChatAddress(address) !== undefined, title: (address) => { - const child = parseSubagentChatAddress(address)?.childSessionId - return child === undefined - ? t('sidebar.chat') - : ctx.sessions.list.getSnapshot().byId[child]?.projectionValues?.subagent?.label ?? child + const target = parseSubagentChatAddress(address) + if (target === undefined) return t('sidebar.chat') + const id = typeof target === 'string' ? target : target.childSessionId + const summary = ctx.sessions.list.getSnapshot().byId[id] + return summary?.projectionValues?.subagent?.label ?? summary?.displayTitle ?? id }, } satisfies SidebarRightTabDefinition), 'ui-subagent: Sidebar chat type') const chatInjected: SidebarChatInjected = { @@ -205,4 +263,24 @@ export function registerSidebarChat(ctx: Context, t: TranslateNS): vo ctx.effect(() => ctx.slots.inject('sidebar.chat.conversation', () => ctx.slots.register({ name: 'sidebar.chat.conversation', }, ConversationSlotPanel)), 'ui-subagent: Sidebar Conversation') + // Headless profiles can instantiate client registrations without a document. + if (typeof document === 'undefined') return + ctx.effect(() => { + const drags = trackSessionDrags(document, () => ctx.sidebarRight.mounted.getSnapshot()) + const injected: SessionDropZoneInjected = { + hooks: { sessionDrag: drags.source }, + openAside: (sessionId) => { + // The on-screen Session can leave between dragstart and drop. + if (ctx.sidebarRight.mounted.getSnapshot() === undefined) return + ctx.sidebarRight.openResource(sessionChatAddress(sessionId), { kind: 'subagentchat', destination: 'sidebar' }) + }, + } + const disposeZone = ctx.slots.inject('shell.overlay', () => ctx.slots.register({ + name: 'shell.overlay', id: 'subagent.session-drop', locale: NS, inject: () => injected, + }, SessionDropZone)) + return () => { + disposeZone() + drags.dispose() + } + }, 'ui-subagent: Session drop target') } diff --git a/packages/client/ui-subagent/tests/session-drop.client.spec.tsx b/packages/client/ui-subagent/tests/session-drop.client.spec.tsx new file mode 100644 index 0000000000..cb92306bac --- /dev/null +++ b/packages/client/ui-subagent/tests/session-drop.client.spec.tsx @@ -0,0 +1,127 @@ +// @vitest-environment jsdom +import { cleanup, createEvent, fireEvent, render, screen } from '@testing-library/react' +import { afterEach, describe, expect, it, vi } from 'vitest' +import type { HostObservable } from '@deepseek-ai/dsh-client-ui-slots' +import type { SessionId } from '@deepseek-ai/dsh-session/types' +import { trackSessionDrags } from '../src/client/sidebar-chat/index.tsx' +import { SessionDropZone, type SessionDropZoneProps } from '../src/client/sidebar-chat/SessionDropZone.tsx' + +const MAIN = 'main' as SessionId +const OTHER = 'other' as SessionId + +afterEach(() => { + cleanup() +}) + +/** jsdom lacks DragEvent; attach the transfer a browser would supply. */ +function dispatchDrag(type: string, data: Record = {}): void { + const event = new Event(type, { bubbles: true }) + Object.defineProperty(event, 'dataTransfer', { value: { getData: (format: string) => data[format] ?? '' } }) + document.body.dispatchEvent(event) +} + +describe('Session drag tracking', () => { + it('publishes a dragged list Session that another on-screen Session can open', () => { + let mounted: SessionId | undefined = MAIN + const drags = trackSessionDrags(document, () => mounted) + const listener = vi.fn() + const unsubscribe = drags.source.subscribe(listener) + expect(drags.source.getSnapshot()).toBeUndefined() + + dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }) + expect(drags.source.getSnapshot()).toBe(OTHER) + dispatchDrag('dragend') + expect(drags.source.getSnapshot()).toBeUndefined() + expect(listener).toHaveBeenCalledTimes(2) + + dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }) + dispatchDrag('drop') + expect(drags.source.getSnapshot()).toBeUndefined() + + // A row unmounted mid-drag never delivers dragend; the next button-free mouse move clears the drag. + dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }) + document.body.dispatchEvent(new MouseEvent('mousemove', { bubbles: true, buttons: 1 })) + expect(drags.source.getSnapshot()).toBe(OTHER) + document.body.dispatchEvent(new MouseEvent('mousemove', { bubbles: true, buttons: 0 })) + expect(drags.source.getSnapshot()).toBeUndefined() + + // The on-screen Session itself, a drag without Session data, and no on-screen Session publish nothing. + dispatchDrag('dragstart', { 'application/x-dsh-session': MAIN }) + dispatchDrag('dragstart', { 'text/plain': OTHER }) + mounted = undefined + dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }) + expect(drags.source.getSnapshot()).toBeUndefined() + expect(listener).toHaveBeenCalledTimes(6) + + unsubscribe() + mounted = MAIN + dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }) + expect(listener).toHaveBeenCalledTimes(6) + drags.dispose() + dispatchDrag('dragend') + expect(drags.source.getSnapshot()).toBe(OTHER) + }) +}) + +describe('Session drop zone', () => { + function mount(initial: SessionId | undefined) { + let current = initial + const openAside = vi.fn() + const source: HostObservable = { getSnapshot: () => current, subscribe: () => () => {} } + const props = { + useSessionDrag: (select: (value: SessionId | undefined) => T) => select(source.getSnapshot()), + openAside, + t: (key: string) => key === 'open.sidebar' ? 'Open in sidebar' : key, + } as Partial as SessionDropZoneProps + const view = render() + return { + ...view, + openAside, + set: (next: SessionId | undefined) => { + current = next + view.rerender() + }, + } + } + + function fire(target: Element, kind: 'dragEnter' | 'dragOver' | 'dragLeave' | 'drop', relatedTarget?: Node | null) { + const event = createEvent[kind](target) + const transfer = { dropEffect: 'none' } + Object.defineProperties(event, { dataTransfer: { value: transfer }, relatedTarget: { value: relatedTarget ?? null } }) + fireEvent(target, event) + return { event, transfer } + } + + it('renders only during a Session drag and opens the dropped Session aside', () => { + const view = mount(undefined) + expect(view.container.innerHTML).toBe('') + view.set(OTHER) + const label = screen.getByText('Open in sidebar') + const zone = view.container.querySelector('[data-session-drop-zone]') as HTMLElement + expect(zone.hasAttribute('data-active')).toBe(false) + + const over = fire(zone, 'dragOver') + expect(over.event.defaultPrevented).toBe(true) + expect(over.transfer.dropEffect).toBe('copy') + expect(zone.hasAttribute('data-active')).toBe(true) + // Moving between the zone's own children keeps the highlight; leaving the zone clears it. + fire(zone, 'dragLeave', label) + expect(zone.hasAttribute('data-active')).toBe(true) + fire(zone, 'dragLeave', null) + expect(zone.hasAttribute('data-active')).toBe(false) + fire(zone, 'dragEnter') + expect(zone.hasAttribute('data-active')).toBe(true) + + const documentDrop = vi.fn() + document.addEventListener('drop', documentDrop) + const drop = fire(zone, 'drop') + document.removeEventListener('drop', documentDrop) + expect(drop.event.defaultPrevented).toBe(true) + expect(documentDrop).not.toHaveBeenCalled() + expect(view.openAside).toHaveBeenCalledExactlyOnceWith(OTHER) + expect(zone.hasAttribute('data-active')).toBe(false) + + view.set(undefined) + expect(view.container.innerHTML).toBe('') + }) +}) 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 2ce07e3c8e..a1da2a16fb 100644 --- a/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx +++ b/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx @@ -14,7 +14,7 @@ import type { SessionId } from '@deepseek-ai/dsh-session/types' import type { SubagentAddress } from '@deepseek-ai/dsh-subagent/client' import { ConversationSlotPanel, FixedChatConversationView, parseSubagentChatAddress, - registerSidebarChat, subagentChatAddress, SUBAGENT_CHAT_ID, type SidebarChatTabProps, + registerSidebarChat, sessionChatAddress, subagentChatAddress, SUBAGENT_CHAT_ID, type SidebarChatTabProps, } from '../src/client/sidebar-chat/index.tsx' import { SidebarChatTab } from '../src/client/sidebar-chat/index.tsx' @@ -42,6 +42,12 @@ describe('Sidebar chat address', () => { .toEqual({ ...ADDRESS, mode: 'unknown' }) }) + it('addresses a root Session without a routing query', () => { + const resource = sessionChatAddress(CHILD) + expect(resource).toBe('dsh-resource://subagentchat/session/child%231') + expect(parseSubagentChatAddress(resource)).toBe(CHILD) + }) + it.each([ 'not an address', 'https://chat/session/child?parent=parent&mode=continuable', @@ -51,6 +57,7 @@ describe('Sidebar chat address', () => { 'dsh-resource://subagentchat/session/child?parent=&mode=continuable', 'dsh-resource://subagentchat/session/child?parent=parent&mode=invalid', 'dsh-resource://subagentchat/session/%?parent=parent&mode=continuable', + 'dsh-resource://subagentchat/session/%', ])('rejects %s', (address) => { expect(parseSubagentChatAddress(address)).toBeUndefined() }) @@ -75,6 +82,7 @@ describe('Sidebar chat registration', () => { displayTitle: 'Projected title', projectionValues: { subagent: { mode: 'continuable', label: 'Worker', seq: 1 } }, }, + [PARENT]: { displayTitle: 'Root title' }, }, phase: 'ready', projectionsBySession: {}, @@ -85,6 +93,7 @@ describe('Sidebar chat registration', () => { let provider: ResourceProvider<'subagentchat'> | undefined let definition: SidebarRightTabDefinition | undefined const registrations: { options: Record; component: unknown }[] = [] + const disposers: (() => void)[] = [] const openWorkspace = vi.fn(() => Promise.resolve()) const ctx = { sessions: { retain, refreshProjections, list } as unknown as ISessions, @@ -97,10 +106,19 @@ describe('Sidebar chat registration', () => { return () => {} }, }, - effect: (install: () => unknown) => { install(); return () => {} }, + effect: (install: () => unknown) => { + const dispose = install() + if (typeof dispose === 'function') disposers.push(dispose as () => void) + return () => {} + }, } as unknown as Context - registerSidebarChat(Object.assign(ctx, { uiWorkspace: { openWorkspace } }), (key: string) => key === 'sidebar.chat' ? 'Chat' : key) + const openResource = vi.fn() + let onScreen: SessionId | undefined = PARENT + registerSidebarChat( + Object.assign(ctx, { uiWorkspace: { openWorkspace }, sidebarRight: { openResource, mounted: { getSnapshot: () => onScreen } } }), + (key: string) => key === 'sidebar.chat' ? 'Chat' : key, + ) expect(definition?.id).toBe(SUBAGENT_CHAT_ID) expect(definition?.kind).toBe('subagentchat') @@ -108,11 +126,36 @@ describe('Sidebar chat registration', () => { expect(definition?.canOpen?.('dsh-resource://subagentchat/invalid')).toBe(false) expect(definition?.title(subagentChatAddress(ADDRESS))).toBe('Worker') expect(definition?.title(subagentChatAddress({ ...ADDRESS, childSessionId: 'unknown' as SessionId }))).toBe('unknown') + expect(definition?.title(sessionChatAddress(PARENT))).toBe('Root title') expect(definition?.title('invalid')).toBe('Chat') expect(registrations.map(entry => entry.options.name)).toEqual([ 'sidebar.right.pane.tab', 'sidebar.chat.conversation', + 'shell.overlay', ]) + // A dropped root Session opens in the on-screen Session's Sidebar column. + const drop = registrations[2]?.options.inject as () => { + hooks: { sessionDrag: { getSnapshot: () => SessionId | undefined } } + openAside: (sessionId: SessionId) => void + } + drop().openAside(CHILD) + expect(openResource).toHaveBeenCalledWith(sessionChatAddress(CHILD), { kind: 'subagentchat', destination: 'sidebar' }) + onScreen = undefined + drop().openAside(CHILD) + expect(openResource).toHaveBeenCalledOnce() + onScreen = PARENT + // The tracker compares the dragged row with the Sidebar's on-screen Session and stops listening on disposal. + const dragStart = (): void => { + const event = new Event('dragstart', { bubbles: true }) + Object.defineProperty(event, 'dataTransfer', { value: { getData: () => CHILD } }) + document.body.dispatchEvent(event) + } + dragStart() + expect(drop().hooks.sessionDrag.getSnapshot()).toBe(CHILD) + document.body.dispatchEvent(new Event('dragend', { bubbles: true })) + for (const dispose of disposers) dispose() + dragStart() + expect(drop().hooks.sessionDrag.getSnapshot()).toBeUndefined() // 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 } } diff --git a/packages/client/ui-workspace/README.i18n.yaml b/packages/client/ui-workspace/README.i18n.yaml index dd74524d69..32b26be6d1 100644 --- a/packages/client/ui-workspace/README.i18n.yaml +++ b/packages/client/ui-workspace/README.i18n.yaml @@ -18,8 +18,8 @@ en: 2e435d7c20a9e549 zh: 7eb26bbdacdc5b54 /deepseek-ai-dsh-client-ui-workspace/use-this-package/reordering-and-view-options: - en: 55054408b8593c70 - zh: 9fdf9861a48abba3 + en: a77f25e9153d6782 + zh: 7f60489e53305d20 /deepseek-ai-dsh-client-ui-workspace/use-this-package/workspace-hierarchy: en: cd8635fa6516441d zh: c06e251fe3dd895b @@ -33,8 +33,8 @@ en: 27089341ac2cbcc4 zh: 63d818a53a7c20e9 /deepseek-ai-dsh-client-ui-workspace/use-this-package/active-schedule-markers: - en: cecb53516a3fe30c - zh: 5d96148c1a3e6a1a + en: 6f310cd6a5842f40 + zh: ddad389d1cac6139 /deepseek-ai-dsh-client-ui-workspace/understand-the-implementation: en: 8f170900a4096408 zh: 85332e80adf39403 diff --git a/packages/client/ui-workspace/README.md b/packages/client/ui-workspace/README.md index 06d7456566..bdab6499f2 100644 --- a/packages/client/ui-workspace/README.md +++ b/packages/client/ui-workspace/README.md @@ -45,6 +45,8 @@ Pinning moves the Session to the front of its complete saved sequence without ch The selected blank **New Session** retains its provisional first slot and cannot be dragged; after its first prompt it becomes an ordinary draggable row, retaining that position in Manual or following its current timestamp in Last updated. A collapsed-group drag uses the target Session identity and keeps the source visible. Session display orders for real Workspaces, Ungrouped, and the flat list are browser-local; Workspace group drag order remains Host-durable. +Every non-blank, unarchived Session row in the tree and the single list also drags its Session id as `application/x-dsh-session`, whether or not it can be reordered. The drag allows `copy`, plus `move` while the row can be reordered. When a drop target outside the list accepts the copy, the pending reorder is discarded. + ### Workspace hierarchy Choose **Add workspace** and select a directory to register it and open a Session. **View options → Group by** defaults to **WorkSpace**, which lists Workspaces as sibling sections. Select **Workspace Tree** to nest each Workspace under its nearest registered ancestor, including Workspaces added later. Each Workspace keeps its own Sessions and row actions. Child Workspaces appear before the parent's own Sessions. Ancestors start expanded unless a saved collapsed state exists. A saved collapse also hides the current Session; ancestor folder icons stay highlighted when a descendant Workspace contains it. Row fills and hit targets span the same width at every level; only the contents indent. Workspace dragging reorders siblings; dropping on a descendant targets the nearest compatible ancestor, so an expanded parent can be moved past without collapsing it. Search-result navigation expands every ancestor. Grouping and expansion are saved in the current browser; switching modes preserves each Workspace's expansion preference, and the single-list view stays flat. @@ -93,7 +95,7 @@ Session rows share their existing action contributions between right-click and t The `mainView` reference retains the `conversation` facet. When the main view leaves a non-blank, unarchived Session, navigation first retains it as a `recentViews` reference without facets, so its history stays loaded and returning to it needs no history request, while Conversation assembly stops until it is shown again. A recent view that is running, awaits the user, or has an unread completion is always kept and does not count; up to `recentViewLimit` other recent views, 10 by default, are kept besides the main-view Session. `recentViewLimit` is a volatile field of the plugin's Host `Config`, set in its `cordis.yml` row and synced to the browser through [Client Modules](../modules/README.md#synced-plugin-configuration); a change takes effect without a page reload, releasing or keeping recent views by the new limit, and Sessions already released do not return. Until the browser receives a value, every counted recent view is kept. Beyond that the least recently left unpinned recent view is released first, then the least recently left pinned one; a released recent view returns only when the main view leaves that Session again. Returning a Session to the main view, removing or archiving it, or disposing the plugin releases its recent view. -Session and Workspace rows derive their affordances from the browser root's access Hooks: `useWorkspaceAccess` gates a Workspace's create, rename, delete, and reorder verbs, and `useSessionAccess` gates a Session row's rename, fork, drag, pin, archive, and unarchive verbs plus the search result's restore control. A refused verb is not rendered, while every Host request remains authoritative. The Ungrouped header offers no New Session, because it has no backing Workspace to start one in. Startup restoration retains its main reference without changing the selected panel or cancelling a later navigation. Archiving the main Session releases its reference and clears the main selection. Selection failure leaves a global panel visible. Session rows read `usePanelInfo` to suppress their selected appearance while a global panel is active; search and directory-picker focus alone do not leave that panel. +Session and Workspace rows derive their affordances from the browser root's access Hooks: `useWorkspaceAccess` gates a Workspace's create, rename, delete, and reorder verbs, and `useSessionAccess` gates a Session row's rename, fork, reorder drag, pin, archive, and unarchive verbs plus the search result's restore control. A refused verb is not rendered, while every Host request remains authoritative. The Ungrouped header offers no New Session, because it has no backing Workspace to start one in. Startup restoration retains its main reference without changing the selected panel or cancelling a later navigation. Archiving the main Session releases its reference and clears the main selection. Selection failure leaves a global panel visible. Session rows read `usePanelInfo` to suppress their selected appearance while a global panel is active; search and directory-picker focus alone do not leave that panel. Navigation and startup restoration obtain the selected Session's projections from its `follow`; neither issues a separate projection refresh for that Session or its parent, except that restoring a saved blank first reloads that Session's projections, because listed values are cached hints that can lag its log after an unclean Host exit. diff --git a/packages/client/ui-workspace/README.zh.md b/packages/client/ui-workspace/README.zh.md index 894e1abcf9..8267968bc7 100644 --- a/packages/client/ui-workspace/README.zh.md +++ b/packages/client/ui-workspace/README.zh.md @@ -45,6 +45,8 @@ kind: "package-reference" 当前选中的空白**新会话**保留临时首位且无法拖拽;首条提示词落地后,它成为可拖拽的普通行,在手动排序中保留该位置,在最近更新中按当前时间戳排列。折叠分组的拖拽使用目标 Session 身份,并保持来源行可见。真实 Workspace、Ungrouped 与单列表的 Session 显示顺序都保留在浏览器本地;Workspace 分组的拖拽顺序仍由 Host 持久化。 +树和单列表中每个非空白、未归档的 Session 行在拖拽时还会以 `application/x-dsh-session` 携带其 Session id,无论该行能否重排。拖拽允许 `copy`,该行可重排时还允许 `move`。列表外的放置目标接受 copy 时,待定的重排会被丢弃。 + ### 工作区层级 选择**添加工作区**并选取目录,即可注册工作区并打开 Session。**视图选项 → 分组方式**默认为**按工作区**,将工作区作为同级分组显示。选择**按工作区树**后,每个 Workspace 会位于最近的已注册祖先之下,之后添加的 Workspace 也会自动归入。每个 Workspace 保留自己的 Session 和行操作,子 Workspace 显示在父级自己的 Session 之前。祖先默认展开,已有的折叠偏好除外。保存的折叠状态也会隐藏当前 Session;如果后代 Workspace 包含当前 Session,祖先文件夹图标仍保持高亮。各层级的高亮和点击区域保持整行同宽,仅内容缩进。拖拽 Workspace 仅重排同级项目;落在后代行上时,由最近的兼容祖先接收,因此无需先折叠父级就能将其他工作区拖到其后。选择搜索结果会展开全部祖先。分组方式和展开状态保存在当前浏览器中;切换模式会保留各 Workspace 的展开偏好,单列表视图保持平铺。 @@ -93,7 +95,7 @@ Session 行渲染运行时的实时 `pendingInteraction` 分类:审批显示** `mainView` 引用保留 `conversation` 子要素。主视图离开一个非空白、未归档的 Session 时,导航先以不带子要素的 `recentViews` 引用保留它,因此其历史仍已加载,切回时无需再请求历史,而 Conversation 组装在重新显示前停止。运行中、等待用户或完成未读的最近访问会话始终保留且不计数;其余最近访问会话最多保留 `recentViewLimit` 个(默认 10),不含主视图 Session。`recentViewLimit` 是插件 Host `Config` 的 volatile 字段,在其 `cordis.yml` 行中设置,并经 [Client Modules](../modules/README.zh.md#synced-plugin-configuration) 同步到浏览器;修改后无需刷新页面即生效,按新上限释放或保留最近访问会话,已释放的 Session 不会回来。浏览器收到值之前,所有计数的最近访问会话都会保留。超出时先释放最早离开的未置顶会话,再释放最早离开的置顶会话;被释放的最近访问会话只有在主视图再次离开该 Session 时才会回来。Session 回到主视图、被移除或归档,或插件卸载时,会释放其最近访问引用。 -Session 行与 Workspace 行的可用操作来自浏览器根的访问 Hook:`useWorkspaceAccess` 门控 Workspace 的新建、重命名、删除与排序动作,`useSessionAccess` 门控 Session 行的重命名、分叉、拖拽、置顶、归档与取消归档动作,以及搜索结果的恢复控件。被拒绝的动作不渲染,但每个发往 Host 的请求仍以其授权为准。Ungrouped 标题行不提供新建会话,因为它没有可在其中新建会话的后备 Workspace。启动恢复会 retain 主 reference,不改变已选面板,也不取消后续导航。归档主 Session 会释放其 reference 并清除主选择。选择失败时保留当前全局面板。Session 行读取 `usePanelInfo`,在全局面板活跃时不显示 Session 选中样式;仅把焦点移到搜索框或目录选择器不会离开该面板。 +Session 行与 Workspace 行的可用操作来自浏览器根的访问 Hook:`useWorkspaceAccess` 门控 Workspace 的新建、重命名、删除与排序动作,`useSessionAccess` 门控 Session 行的重命名、分叉、重排拖拽、置顶、归档与取消归档动作,以及搜索结果的恢复控件。被拒绝的动作不渲染,但每个发往 Host 的请求仍以其授权为准。Ungrouped 标题行不提供新建会话,因为它没有可在其中新建会话的后备 Workspace。启动恢复会 retain 主 reference,不改变已选面板,也不取消后续导航。归档主 Session 会释放其 reference 并清除主选择。选择失败时保留当前全局面板。Session 行读取 `usePanelInfo`,在全局面板活跃时不显示 Session 选中样式;仅把焦点移到搜索框或目录选择器不会离开该面板。 导航和启动恢复通过所选 Session 的 `follow` 获取投影,不会另行刷新该 Session 或其父会话的投影;例外是恢复已保存的空白会话时先重新加载该 Session 的投影,因为列表中的值是缓存提示,Host 非正常退出后可能落后于其日志。 diff --git a/packages/client/ui-workspace/src/client/contract/slots.ts b/packages/client/ui-workspace/src/client/contract/slots.ts index bb704633b9..282091a96e 100644 --- a/packages/client/ui-workspace/src/client/contract/slots.ts +++ b/packages/client/ui-workspace/src/client/contract/slots.ts @@ -98,6 +98,12 @@ export interface SessionRowOwnerProps { displayTitle: string } +/** + * Drag data type a Session row sets to its Session id. The drag allows `copy`, and `move` while the row can be reordered; + * a drop target outside the list that accepts the Session sets `dropEffect` to `copy`, which discards the pending reorder. + */ +export type SessionDragType = 'application/x-dsh-session' + /** The row menu's open state as its owner holds it: the `useState` pair. */ export type MenuOpenState = readonly [open: boolean, setOpen: (open: boolean) => void] diff --git a/packages/client/ui-workspace/src/client/index.ts b/packages/client/ui-workspace/src/client/index.ts index 84554ac66b..1c38a6652d 100644 --- a/packages/client/ui-workspace/src/client/index.ts +++ b/packages/client/ui-workspace/src/client/index.ts @@ -67,7 +67,7 @@ import { en, ja, es, fr, de, ru, pt, zh, type WorkspaceKey } from './locales.ts' export type { StartSessionOptions, UiWorkspace } from './navigation.ts' export type { DirectoryFlowOwnerProps, DirectoryFlowSlotName, DirectoryPickingHooks, DirectoryPickingInjected, - MenuOpenState, RowToast, SessionRenameTarget, SessionRowOwnerProps, UseMenuOpenState, WorkspaceBrowserInjected, + MenuOpenState, RowToast, SessionDragType, SessionRenameTarget, SessionRowOwnerProps, UseMenuOpenState, WorkspaceBrowserInjected, SessionRowScheduleOwnerProps, WorkspaceBrowserProps, WorkspacePickerInjected, WorkspacePickerInput, WorkspacePickerProps, diff --git a/packages/client/ui-workspace/src/client/rows/Rows.tsx b/packages/client/ui-workspace/src/client/rows/Rows.tsx index 628f409158..b62bf3a09b 100644 --- a/packages/client/ui-workspace/src/client/rows/Rows.tsx +++ b/packages/client/ui-workspace/src/client/rows/Rows.tsx @@ -22,7 +22,7 @@ import type { ShortcutCatalogEntry } from '@deepseek-ai/dsh-client-shortcuts/cli import type { StateDotState } from '@deepseek-ai/dsh-client-ui-primitives' import { abbreviateHomePath } from '@deepseek-ai/dsh-util-workspace-path' import type { WorkspaceId } from '@deepseek-ai/dsh-api-workspace-controller/client' -import type { WorkspaceBrowserProps } from '../contract/slots.ts' +import type { SessionDragType, WorkspaceBrowserProps } from '../contract/slots.ts' import type { GroupNode, SearchResultNode, SessionNode } from '../tree.ts' import css from './Rows.module.css' @@ -33,6 +33,9 @@ const DRAG_PREVIEW_PROPERTIES = [ '--dsh-sidebar-paint-inset', ] as const +/** Drag data type carrying a dragged Session row's id. */ +const SESSION_DRAG_TYPE: SessionDragType = 'application/x-dsh-session' + /** The standard locale seat, prop-passed from the browser root. */ type RowTranslate = WorkspaceBrowserProps['t'] @@ -109,7 +112,11 @@ export interface RowDragProps { /** Report the hovered half while a compatible drag passes over this row. */ hover: (half: 'before' | 'after') => void drop: (half: 'before' | 'after') => void - end: () => void + /** + * End the drag. + * @param claimed - another drop target accepted the Session as a copy; the owner discards the insert marker. + */ + end: (claimed: boolean) => void } /** Drag lifecycle owned by a workspace row; its enclosing group owns hit testing. */ @@ -541,7 +548,8 @@ export function SessionNodeItem({ // their drop targets to fellow pinned rows. const renamable = useSessionAccess(node.id, 'session/rename') const reorderable = useSessionAccess(node.id, 'workspace/insertSessionBefore') - const draggable = drag !== undefined && reorderable && !row.blank && !row.archived + const draggable = !row.blank && !row.archived + const reorderDraggable = draggable && drag !== undefined && reorderable const menuOpen = useContextMenuTarget(target => target?.kind === 'session' && target.value.sessionId === node.id) const dragPreview = useRowDragPreview(css.dragPreview as string, DRAG_PREVIEW_PROPERTIES) const rowRef = useRef(null) @@ -584,12 +592,15 @@ export function SessionNodeItem({ onDragStart={!draggable ? undefined : (e) => { - e.dataTransfer.effectAllowed = 'move' - e.dataTransfer.setData('text/plain', node.id) - drag.start() + e.dataTransfer.effectAllowed = reorderDraggable ? 'copyMove' : 'copy' + e.dataTransfer.setData(SESSION_DRAG_TYPE, node.id) + if (reorderDraggable) { + e.dataTransfer.setData('text/plain', node.id) + drag.start() + } dragPreview.start(e) }} - onDragEnd={() => { if (dragPreview.clear()) drag?.end() }} + onDragEnd={(e) => { if (dragPreview.clear()) drag?.end(e.dataTransfer.dropEffect === 'copy') }} onDragOver={drag === undefined ? undefined : (e) => { diff --git a/packages/client/ui-workspace/src/client/rows/WorkspaceBrowser.tsx b/packages/client/ui-workspace/src/client/rows/WorkspaceBrowser.tsx index d852662c21..c1555c682a 100644 --- a/packages/client/ui-workspace/src/client/rows/WorkspaceBrowser.tsx +++ b/packages/client/ui-workspace/src/client/rows/WorkspaceBrowser.tsx @@ -599,8 +599,8 @@ function SessionTree({ if (drag === null) return commitSessionDrag(drag, { id: node.id, half: normalizeHalf(half) }) }, - end: () => { - if (drag?.over !== null && drag?.over !== undefined) commitSessionDrag(drag, drag.over) + end: (claimed: boolean) => { + if (!claimed && drag?.over !== null && drag?.over !== undefined) commitSessionDrag(drag, drag.over) else setDrag(null) sessionDropCommitted.current = false }, @@ -768,8 +768,8 @@ function FlatList({ drop: (half) => { if (drag !== null) commitDrag(drag, { id: node.id, half: normalizeHalf(half) }) }, - end: () => { - if (drag?.over !== null && drag?.over !== undefined) commitDrag(drag, drag.over) + end: (claimed) => { + if (!claimed && drag?.over !== null && drag?.over !== undefined) commitDrag(drag, drag.over) else setDrag(null) dropCommitted.current = false }, diff --git a/packages/client/ui-workspace/tests/rows.client.spec.tsx b/packages/client/ui-workspace/tests/rows.client.spec.tsx index ffe540d6e5..1fb0cd4893 100644 --- a/packages/client/ui-workspace/tests/rows.client.spec.tsx +++ b/packages/client/ui-workspace/tests/rows.client.spec.tsx @@ -155,6 +155,11 @@ describe('Workspace and Session hover handoff', () => { }) }) +/** jsdom lacks DragEvent — fireEvent builds no dataTransfer, which a Session row reads at drag end. */ +function dragEnd(row: Element, dropEffect: DataTransfer['dropEffect'] = 'none'): void { + fireEvent.dragEnd(row, { dataTransfer: { dropEffect } }) +} + const dataTransfer = { effectAllowed: '', dropEffect: '', setData: vi.fn(), setDragImage: vi.fn() } /** jsdom lacks DragEvent — the fireEvent fallback drops clientY, so pin it on the built event. */ @@ -172,7 +177,7 @@ describe('native row drag previews', () => { ? + }} onToggle={vi.fn()} onCreate={vi.fn()} drag={{ start: drag.start, end: () => { drag.end(false) } }} t={t} /> : { it.each(['workspace', 'session'] as const)('uses an inert offscreen %s copy without changing the source row', (kind) => { const { row, drag, transfer, start } = fixture(kind) const originalStyle = row.getAttribute('style') - fireEvent.dragEnd(row) + dragEnd(row) expect(drag.end).not.toHaveBeenCalled() const image = start() expect(transfer.setDragImage).toHaveBeenCalledWith(image, 65, 12) - expect(transfer.effectAllowed).toBe('move') + expect(transfer.effectAllowed).toBe(kind === 'session' ? 'copyMove' : 'move') expect(transfer.setData).toHaveBeenCalledWith('text/plain', kind) expect(drag.start).toHaveBeenCalledOnce() expect(image.parentElement).toBe(document.body) @@ -229,7 +234,7 @@ describe('native row drag previews', () => { expect(vi.mocked(drag.start).mock.invocationCallOrder[0]) .toBeLessThan(transfer.setDragImage.mock.invocationCallOrder[0]!) expect(image.isConnected).toBe(false) - fireEvent.dragEnd(screen.getByRole('treeitem')) + dragEnd(screen.getByRole('treeitem')) expect(drag.end).toHaveBeenCalledOnce() }) @@ -241,7 +246,7 @@ describe('native row drag previews', () => { runningSubagentCount: 0, completed: false, failed: false, updatedAt: 0, pinned: false, archived: true, }} currentId={undefined} now={0} onOpen={vi.fn()} drag={drag} t={t} />) expect(row.getAttribute('draggable')).toBe('false') - fireEvent.dragEnd(row) + dragEnd(row) expect(image.isConnected).toBe(false) expect(drag.end).toHaveBeenCalledOnce() }) @@ -252,7 +257,7 @@ describe('native row drag previews', () => { const second = start() expect(first.isConnected).toBe(false) expect(second.isConnected).toBe(true) - fireEvent.dragEnd(row) + dragEnd(row) expect(second.isConnected).toBe(false) expect(drag.end).toHaveBeenCalledOnce() const third = start() @@ -668,7 +673,14 @@ describe('workspace browser rows', () => { onRenameRequest={onRenameRequest} useSessionAccess={useSessionAccess} t={t} />) expect(useSessionAccess).toHaveBeenCalledWith(sid('s1'), 'session/rename') expect(useSessionAccess).toHaveBeenCalledWith(sid('s1'), 'workspace/insertSessionBefore') - expect(screen.getByRole('treeitem').getAttribute('draggable')).toBe('false') + // Without reorder access the row still drags its Session to other drop targets, as a copy only. + expect(screen.getByRole('treeitem').getAttribute('draggable')).toBe('true') + const transfer = { effectAllowed: '', setData: vi.fn(), setDragImage: vi.fn() } + fireEvent.dragStart(screen.getByRole('treeitem'), { dataTransfer: transfer }) + expect(transfer.effectAllowed).toBe('copy') + expect(transfer.setData.mock.calls).toEqual([['application/x-dsh-session', 's1']]) + expect(drag.start).not.toHaveBeenCalled() + dragEnd(screen.getByRole('treeitem')) fireEvent.doubleClick(screen.getByText('One')) expect(onRenameRequest).not.toHaveBeenCalled() @@ -1178,8 +1190,12 @@ describe('workspace browser rows', () => { fireEvent.drop(row, { dataTransfer }) expect(inactive.hover).not.toHaveBeenCalled() expect(inactive.drop).not.toHaveBeenCalled() - fireEvent.dragEnd(row) - expect(inactive.end).toHaveBeenCalledOnce() + dragEnd(row) + expect(inactive.end).toHaveBeenCalledExactlyOnceWith(false) + // A copy accepted by another drop target tells the owner to discard the marker. + fireEvent.dragStart(row, { dataTransfer }) + dragEnd(row, 'copy') + expect(inactive.end).toHaveBeenLastCalledWith(true) const active = dragProps({ active: true, marker: 'before' }) rerender( @@ -1226,8 +1242,8 @@ describe('workspace browser rows', () => { }} currentId={undefined} now={0} onOpen={vi.fn()} drag={drag} t={t} />) const row = screen.getByRole('treeitem') expect(row.getAttribute('draggable')).toBe('false') - fireEvent.dragEnd(row.firstElementChild!) - fireEvent.dragEnd(row) + dragEnd(row.firstElementChild!) + dragEnd(row) expect(drag.end).not.toHaveBeenCalled() }) diff --git a/packages/client/ui-workspace/tests/workspace-browser.client.spec.tsx b/packages/client/ui-workspace/tests/workspace-browser.client.spec.tsx index 8330aae4bc..a66555575d 100644 --- a/packages/client/ui-workspace/tests/workspace-browser.client.spec.tsx +++ b/packages/client/ui-workspace/tests/workspace-browser.client.spec.tsx @@ -88,6 +88,11 @@ function hook(snapshot: T) { return function select(selector: (state: T) => S): S { return selector(snapshot) } } +/** jsdom lacks DragEvent — fireEvent builds no dataTransfer, which a Session row reads at drag end. */ +function dragEnd(row: Element, dropEffect: DataTransfer['dropEffect'] = 'none'): void { + fireEvent.dragEnd(row, { dataTransfer: { dropEffect } }) +} + /** jsdom lacks DragEvent — the fireEvent fallback drops clientY, so pin it on the built event. */ function fireDrag(row: HTMLElement, kind: 'dragOver' | 'drop', clientY: number): void { const event = kind === 'dragOver' ? createEvent.dragOver(row) : createEvent.drop(row) @@ -1094,7 +1099,7 @@ describe('WorkspaceBrowser', () => { const session5 = screen.getByText('session-5').closest('[role="treeitem"]') as HTMLElement fireEvent.dragStart(session5, { dataTransfer: dragData() }) fireDrag(blankRow, 'drop', 205) - fireEvent.dragEnd(session5) + dragEnd(session5) expect(b.store.getSnapshot().sessionOrderByAccount.alpha) .toEqual(['blank', 'session-5', 'session-1', 'session-2', 'session-3', 'session-4', 'session-6']) expect(screen.getByText('session-5')).toBeTruthy() @@ -2157,7 +2162,7 @@ describe('WorkspaceBrowser', () => { Object.defineProperty(outsideDrop, 'dataTransfer', { value: dragData() }) fireEvent(document.body, outsideDrop) expect(outsideDrop.defaultPrevented).toBe(true) - fireEvent.dragEnd(source) + dragEnd(source) expect(insertWorkspaceBefore).toHaveBeenCalledWith(wid('tail'), wid('beta')) }) @@ -2218,7 +2223,7 @@ describe('WorkspaceBrowser', () => { fireEvent.dragStart(two, { dataTransfer: dragData() }) fireDrag(one, 'dragOver', 105) fireDrag(one, 'drop', 105) - fireEvent.dragEnd(two) + dragEnd(two) expect(b.store.getSnapshot().sessionOrderByAccount.alpha).toEqual(['three', 'two', 'one', 'four']) expect(screen.getAllByRole('treeitem').slice(1).map(row => row.textContent)).toEqual([ expect.stringContaining('two'), expect.stringContaining('one'), @@ -2257,14 +2262,14 @@ describe('WorkspaceBrowser', () => { fireEvent.dragStart(one, { dataTransfer: dragData() }) fireDrag(two, 'dragOver', 105) fireDrag(two, 'drop', 105) - fireEvent.dragEnd(one) + dragEnd(one) expect(b.store.getSnapshot().sessionOrderByAccount.alpha).toEqual(before) // …and an unpinned source ignores pinned targets. fireEvent.dragStart(two, { dataTransfer: dragData() }) fireDrag(one, 'dragOver', 105) fireDrag(one, 'drop', 105) - fireEvent.dragEnd(two) + dragEnd(two) expect(b.store.getSnapshot().sessionOrderByAccount.alpha).toEqual(before) }) @@ -2293,7 +2298,7 @@ describe('WorkspaceBrowser', () => { rerender(b, { useWorkspaces: hook(workspaceState([workspace('alpha', ['one', 'two', 'three'])], [], [sid('one')])), }) - fireEvent.dragEnd(within(b.view.container).getByText('one').closest('[role="treeitem"]') as HTMLElement) + dragEnd(within(b.view.container).getByText('one').closest('[role="treeitem"]') as HTMLElement) expect(b.store.getSnapshot().sessionOrderByAccount.alpha).toEqual(before) // The source unpins in flight. @@ -2308,7 +2313,7 @@ describe('WorkspaceBrowser', () => { rerender(b, { useWorkspaces: hook(workspaceState([workspace('alpha', ['one', 'two', 'three'])], [], [sid('two')])), }) - fireEvent.dragEnd(within(b.view.container).getByText('one').closest('[role="treeitem"]') as HTMLElement) + dragEnd(within(b.view.container).getByText('one').closest('[role="treeitem"]') as HTMLElement) expect(b.store.getSnapshot().sessionOrderByAccount.alpha).toEqual(before) }) @@ -2339,7 +2344,7 @@ describe('WorkspaceBrowser', () => { fireEvent.dragStart(three, { dataTransfer: dragData() }) fireDrag(one, 'dragOver', 105) fireDrag(one, 'drop', 105) - fireEvent.dragEnd(three) + dragEnd(three) expect(b.store.getSnapshot().sessionOrderByAccount[FLAT_SESSION_ORDER_KEY]) .toEqual(['two', 'one', 'three']) }) @@ -2360,7 +2365,7 @@ describe('WorkspaceBrowser', () => { }) fireEvent.dragStart(source, { dataTransfer: dragData() }) fireDrag(target, 'drop', 180) - fireEvent.dragEnd(source) + dragEnd(source) } dragAfter('one', 'three') @@ -2425,7 +2430,7 @@ describe('WorkspaceBrowser', () => { }) const dataTransfer = dragData() fireEvent.dragStart(one, { dataTransfer }) - fireEvent.dragEnd(one) + dragEnd(one) // The drag ended: rows no longer accept drops. fireDrag(two, 'drop', 180) expect(b.store.getSnapshot().sessionOrderByAccount.alpha).toBeUndefined() @@ -2453,10 +2458,39 @@ describe('WorkspaceBrowser', () => { Object.defineProperty(outsideDrop, 'dataTransfer', { value: dragData() }) fireEvent(document.body, outsideDrop) expect(outsideDrop.defaultPrevented).toBe(true) - fireEvent.dragEnd(one) + dragEnd(one) expect(b.store.getSnapshot().sessionOrderByAccount.alpha).toEqual(['two', 'one']) }) + it('discards the last Session marker when another drop target claims the Session as a copy', () => { + const b = mount({ + useSessions: hook(sessionState([summary('one', 2), summary('two', 1)])), + useWorkspaces: hook(workspaceState([workspace('alpha', ['one', 'two'])])), + }) + fireEvent.click(screen.getByText('alpha')) + const [one, two] = screen.getAllByRole('treeitem').slice(1) as [HTMLElement, HTMLElement] + two.getBoundingClientRect = () => ({ + top: 150, bottom: 184, left: 0, right: 200, width: 200, height: 34, x: 0, y: 150, toJSON: () => ({}), + }) + fireEvent.dragStart(one, { dataTransfer: dragData() }) + fireDrag(two, 'dragOver', 180) + dragEnd(one, 'copy') + expect(b.store.getSnapshot().sessionOrderByAccount.alpha).toBeUndefined() + + fireEvent.click(screen.getByRole('button', { name: '视图选项' })) + fireEvent.click(screen.getByRole('menuitem', { name: '单列表' })) + const flatOne = screen.getByText('one').closest('[role="treeitem"]') as HTMLElement + const flatTwo = screen.getByText('two').closest('[role="treeitem"]') as HTMLElement + flatTwo.getBoundingClientRect = two.getBoundingClientRect + fireEvent.dragStart(flatOne, { dataTransfer: dragData() }) + fireDrag(flatTwo, 'dragOver', 180) + dragEnd(flatOne, 'copy') + expect(b.store.getSnapshot().sessionOrderByAccount[FLAT_SESSION_ORDER_KEY]).toBeUndefined() + // The marker is gone: an ordinary drag end afterwards commits nothing. + dragEnd(flatOne) + expect(b.store.getSnapshot().sessionOrderByAccount[FLAT_SESSION_ORDER_KEY]).toBeUndefined() + }) + it('labels an unrenamed default Workspace in the reader’s language and every other title verbatim', () => { const renameWorkspace = vi.fn(async () => {}) const browser = mount({ @@ -2754,7 +2788,7 @@ describe('Workspace tree grouping', () => { fireEvent.dragStart(source, { dataTransfer: dragData() }) fireDrag(section('Child'), 'dragOver', 190) fireDrag(section('Child'), 'drop', 190) - fireEvent.dragEnd(source) + dragEnd(source) expect(b.props.insertWorkspaceBefore).toHaveBeenCalledExactlyOnceWith(wid('outside'), wid('tail')) }) @@ -2768,7 +2802,7 @@ describe('Workspace tree grouping', () => { const source = screen.getByText('Projects').closest('[role="treeitem"]')! fireEvent.dragStart(source, { dataTransfer: dragData() }) fireDrag(section('outside'), 'drop', 10) - fireEvent.dragEnd(source) + dragEnd(source) expect(b.props.insertWorkspaceBefore).not.toHaveBeenCalled() }) @@ -2779,7 +2813,7 @@ describe('Workspace tree grouping', () => { const source = screen.getByText('Projects').closest('[role="treeitem"]')! fireEvent.dragStart(source, { dataTransfer: dragData() }) fireDrag(section('outside'), 'drop', 100) - fireEvent.dragEnd(source) + dragEnd(source) expect(b.props.insertWorkspaceBefore).toHaveBeenCalledExactlyOnceWith(root.workspaceId, undefined) rerender(b, { useWorkspaces: hook(workspaceState([team, child, other, outside, root])) }) expect(screen.getAllByRole('treeitem').map(row => row.textContent)).toEqual([ @@ -2822,15 +2856,15 @@ describe('Workspace tree grouping', () => { fireDrag(beta.parentElement as HTMLElement, 'dragOver', 100) fireDrag(outside.parentElement as HTMLElement, 'dragOver', 100) fireDrag(outside.parentElement as HTMLElement, 'drop', 100) - fireEvent.dragEnd(alpha) + dragEnd(alpha) expect(b.props.insertWorkspaceBefore).not.toHaveBeenCalled() fireEvent.dragStart(beta, { dataTransfer: dragData() }) fireDrag(alpha.parentElement as HTMLElement, 'drop', 100) - fireEvent.dragEnd(beta) + dragEnd(beta) expect(b.props.insertWorkspaceBefore).not.toHaveBeenCalled() fireEvent.dragStart(alpha, { dataTransfer: dragData() }) fireDrag(beta.parentElement as HTMLElement, 'drop', 100) - fireEvent.dragEnd(alpha) + dragEnd(alpha) expect(b.props.insertWorkspaceBefore).toHaveBeenCalledOnce() expect(b.props.insertWorkspaceBefore).toHaveBeenCalledWith(wid('alpha'), wid('gamma')) }) 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 e8a3f81c05..2b5e7cc6cd 100644 --- a/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts +++ b/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts @@ -1358,7 +1358,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.hero.workspace.directoryFlow\', () => ctx.slots.register(\n { name: \'conversation.hero.workspace.directoryFlow\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-workspace/src/client/contract/slots.ts:141', + source: 'packages/client/ui-workspace/src/client/contract/slots.ts:147', }, { key: 'conversation.input.activity', @@ -4773,6 +4773,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ 'client-ui-settings-general HostReleasePrompt id \'host-release-change\'', 'client-ui-settings-session-log UploadToast id \'session-log-upload-toast\'', 'client-ui-shortcuts ShortcutReference id \'shortcuts\'', + 'client-ui-subagent SessionDropZone id \'subagent.session-drop\'', 'client-ui-workspace SessionRenameDialog id \'workspace.session-rename\'', 'client-ui-workspace SessionArchiveConfirmDialog id \'workspace.session-archive\'', 'client-ui-workspace RowActionToast id \'workspace.row-toast\'', @@ -4971,7 +4972,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.chat.conversation\', () => ctx.slots.register(\n { name: \'sidebar.chat.conversation\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-subagent/src/client/sidebar-chat/index.tsx:42', + source: 'packages/client/ui-subagent/src/client/sidebar-chat/index.tsx:43', }, { key: 'sidebar.footer.action', @@ -5968,7 +5969,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.session.row.hover\', () => ctx.slots.register(\n { name: \'sidebar.session.row.hover\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-workspace/src/client/contract/slots.ts:175', + source: 'packages/client/ui-workspace/src/client/contract/slots.ts:181', }, { key: 'sidebar.session.row.leading', @@ -6024,7 +6025,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.session.row.leading\', () => ctx.slots.register(\n { name: \'sidebar.session.row.leading\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-workspace/src/client/contract/slots.ts:161', + source: 'packages/client/ui-workspace/src/client/contract/slots.ts:167', }, { key: 'sidebar.session.row.trailing', @@ -6079,7 +6080,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.session.row.trailing\', () => ctx.slots.register(\n { name: \'sidebar.session.row.trailing\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-workspace/src/client/contract/slots.ts:170', + source: 'packages/client/ui-workspace/src/client/contract/slots.ts:176', }, { key: 'sidebar.settings', @@ -6214,7 +6215,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.directoryFlow\', () => ctx.slots.register(\n { name: \'sidebar.workspaces.directoryFlow\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-workspace/src/client/contract/slots.ts:143', + source: 'packages/client/ui-workspace/src/client/contract/slots.ts:149', }, { key: 'sidebar.workspaces.session.menu.item', @@ -6267,7 +6268,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ occupants: [], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n const copyLabel = \'Copy session title\' // Localize in the contributing package.\n ctx.slots.inject(\'sidebar.workspaces.session.menu.item\', () => ctx.slots.register(\n { name: \'sidebar.workspaces.session.menu.item\', id: \'copy-session-title\', order: 500 },\n ({ displayTitle, useMenuOpenState }) => {\n const [, setMenuOpen] = useMenuOpenState()\n return React.createElement(\n \'button\',\n {\n type: \'button\', role: \'menuitem\',\n onClick: () => { setMenuOpen(false); void navigator.clipboard.writeText(displayTitle) },\n },\n copyLabel,\n )\n },\n ))\n },\n}', - source: 'packages/client/ui-workspace/src/client/contract/slots.ts:205', + source: 'packages/client/ui-workspace/src/client/contract/slots.ts:211', }, { key: 'sidebar.workspaces.session.row.action', @@ -6323,7 +6324,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'none', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.workspaces.session.row.action\', () => ctx.slots.register(\n { name: \'sidebar.workspaces.session.row.action\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-workspace/src/client/contract/slots.ts:224', + source: 'packages/client/ui-workspace/src/client/contract/slots.ts:230', }, { key: 'tool.call.images', @@ -6578,7 +6579,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [ ], replaceRisk: 'shadows-shipped-ui', example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'workspace.picker.directoryFlow\', () => ctx.slots.register(\n { name: \'workspace.picker.directoryFlow\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-workspace/src/client/contract/slots.ts:151', + source: 'packages/client/ui-workspace/src/client/contract/slots.ts:157', }, { key: 'workspace.toast', From 4c3fb32ff1a577152c5095b3b3cd5c8f6e569ef1 Mon Sep 17 00:00:00 2001 From: Turtle Date: Fri, 20 Nov 2026 04:44:10 +0800 Subject: [PATCH 02/11] test(web): keep existing unknown casts unchanged in the sidebar chat spec Co-authored-by: liukx0205 <69756503+liukx0205@users.noreply.github.com> Co-authored-by: Yifffan <133629972+Yifffan@users.noreply.github.com> --- .../tests/sidebar-chat.client.spec.tsx | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) 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 a1da2a16fb..aadaf1e43c 100644 --- a/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx +++ b/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx @@ -82,7 +82,6 @@ describe('Sidebar chat registration', () => { displayTitle: 'Projected title', projectionValues: { subagent: { mode: 'continuable', label: 'Worker', seq: 1 } }, }, - [PARENT]: { displayTitle: 'Root title' }, }, phase: 'ready', projectionsBySession: {}, @@ -106,17 +105,26 @@ describe('Sidebar chat registration', () => { return () => {} }, }, - effect: (install: () => unknown) => { - const dispose = install() - if (typeof dispose === 'function') disposers.push(dispose as () => void) - return () => {} - }, + effect: (install: () => unknown) => { install(); return () => {} }, } as unknown as Context + const childSnapshot = list.getSnapshot + list.getSnapshot = () => { + const snapshot = childSnapshot() + return { ...snapshot, byId: { ...snapshot.byId, [PARENT]: { ...snapshot.byId[CHILD]!, displayTitle: 'Root title', projectionValues: {} } } } + } const openResource = vi.fn() let onScreen: SessionId | undefined = PARENT registerSidebarChat( - Object.assign(ctx, { uiWorkspace: { openWorkspace }, sidebarRight: { openResource, mounted: { getSnapshot: () => onScreen } } }), + Object.assign(ctx, { + uiWorkspace: { openWorkspace }, + sidebarRight: { openResource, mounted: { getSnapshot: () => onScreen } }, + effect: (install: () => unknown) => { + const dispose = install() + if (typeof dispose === 'function') disposers.push(() => { dispose() }) + return () => {} + }, + }), (key: string) => key === 'sidebar.chat' ? 'Chat' : key, ) From 2f9684765f44fdaecfa067963fa95ecc874ff0f9 Mon Sep 17 00:00:00 2001 From: Turtle Date: Fri, 20 Nov 2026 04:56:38 +0800 Subject: [PATCH 03/11] test(web): satisfy type-aware lint in drag specs Co-authored-by: liukx0205 <69756503+liukx0205@users.noreply.github.com> Co-authored-by: Yifffan <133629972+Yifffan@users.noreply.github.com> --- .../client/ui-subagent/tests/sidebar-chat.client.spec.tsx | 4 ++-- .../ui-workspace/tests/workspace-browser.client.spec.tsx | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) 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 aadaf1e43c..8b49ecfb21 100644 --- a/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx +++ b/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx @@ -119,9 +119,9 @@ describe('Sidebar chat registration', () => { Object.assign(ctx, { uiWorkspace: { openWorkspace }, sidebarRight: { openResource, mounted: { getSnapshot: () => onScreen } }, - effect: (install: () => unknown) => { + effect: (install: () => (() => void) | undefined) => { const dispose = install() - if (typeof dispose === 'function') disposers.push(() => { dispose() }) + if (dispose !== undefined) disposers.push(dispose) return () => {} }, }), diff --git a/packages/client/ui-workspace/tests/workspace-browser.client.spec.tsx b/packages/client/ui-workspace/tests/workspace-browser.client.spec.tsx index a66555575d..499c48fc38 100644 --- a/packages/client/ui-workspace/tests/workspace-browser.client.spec.tsx +++ b/packages/client/ui-workspace/tests/workspace-browser.client.spec.tsx @@ -2469,9 +2469,10 @@ describe('WorkspaceBrowser', () => { }) fireEvent.click(screen.getByText('alpha')) const [one, two] = screen.getAllByRole('treeitem').slice(1) as [HTMLElement, HTMLElement] - two.getBoundingClientRect = () => ({ + const rect = () => ({ top: 150, bottom: 184, left: 0, right: 200, width: 200, height: 34, x: 0, y: 150, toJSON: () => ({}), }) + two.getBoundingClientRect = rect fireEvent.dragStart(one, { dataTransfer: dragData() }) fireDrag(two, 'dragOver', 180) dragEnd(one, 'copy') @@ -2481,7 +2482,7 @@ describe('WorkspaceBrowser', () => { fireEvent.click(screen.getByRole('menuitem', { name: '单列表' })) const flatOne = screen.getByText('one').closest('[role="treeitem"]') as HTMLElement const flatTwo = screen.getByText('two').closest('[role="treeitem"]') as HTMLElement - flatTwo.getBoundingClientRect = two.getBoundingClientRect + flatTwo.getBoundingClientRect = rect fireEvent.dragStart(flatOne, { dataTransfer: dragData() }) fireDrag(flatTwo, 'dragOver', 180) dragEnd(flatOne, 'copy') From 01aff22399b0c97379ffe98d5f72cacaf2d8dfc9 Mon Sep 17 00:00:00 2001 From: Turtle Date: Fri, 20 Nov 2026 05:24:14 +0800 Subject: [PATCH 04/11] test(liveshare): allow copy-only Session row drags on viewer pages Co-authored-by: liukx0205 <69756503+liukx0205@users.noreply.github.com> Co-authored-by: Yifffan <133629972+Yifffan@users.noreply.github.com> --- .../tests/viewer-fork-artifact.client.spec.tsx | 16 ++++++++++++++-- .../tests/viewer-write-artifact.client.spec.tsx | 14 +++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/experimental/liveshare/tests/viewer-fork-artifact.client.spec.tsx b/packages/experimental/liveshare/tests/viewer-fork-artifact.client.spec.tsx index d4f40383b8..d919294cd7 100644 --- a/packages/experimental/liveshare/tests/viewer-fork-artifact.client.spec.tsx +++ b/packages/experimental/liveshare/tests/viewer-fork-artifact.client.spec.tsx @@ -55,6 +55,18 @@ function contextAnswer(mode: { readonly sessionMode: string; readonly sessionMod }) } + +/** Session rows on this page drag out only as copies, which open them in the right Sidebar; none is a reorder handle. */ +function expectNoReorderHandles(): void { + for (const row of document.querySelectorAll('[role="treeitem"][draggable="true"]')) { + expect(row.dataset.rowKey).toMatch(/^session:/u) + const dataTransfer = { effectAllowed: '', setData: () => {}, setDragImage: () => {} } + fireEvent.dragStart(row, { dataTransfer }) + fireEvent.dragEnd(row, { dataTransfer: { dropEffect: 'none' } }) + expect(dataTransfer.effectAllowed).toBe('copy') + } +} + describe('Assembled liveshare viewer page branching a share', () => { it('branches the shared Session into the reader\'s own child, then closes with the grant', async () => { inputFixture = installViewerInputFixture() @@ -102,8 +114,8 @@ describe('Assembled liveshare viewer page branching a share', () => { // The read-only page offers no way to change the shared Session's own settings. expect(screen.queryByRole('button', { name: /^Access mode/u })).toBeNull() // Reordering Sessions and Workspaces is the same Host state rename and delete write, so no row on - // this page is a drag handle either. - expect(document.querySelector('[role="treeitem"][draggable="true"]')).toBeNull() + // this page is a reorder handle either. + expectNoReorderHandles() // Before any branch exists, no row on this page is marked as one. expect(screen.queryByText('Fork')).toBeNull() // The branch action follows the access snapshot the owner's Gateway sent this reader, not the diff --git a/packages/experimental/liveshare/tests/viewer-write-artifact.client.spec.tsx b/packages/experimental/liveshare/tests/viewer-write-artifact.client.spec.tsx index 27dfe7fdd0..3031b7b412 100644 --- a/packages/experimental/liveshare/tests/viewer-write-artifact.client.spec.tsx +++ b/packages/experimental/liveshare/tests/viewer-write-artifact.client.spec.tsx @@ -38,6 +38,18 @@ class ResizeObserverStub { unobserve(): void {} } + +/** Session rows on this page drag out only as copies, which open them in the right Sidebar; none is a reorder handle. */ +function expectNoReorderHandles(): void { + for (const row of document.querySelectorAll('[role="treeitem"][draggable="true"]')) { + expect(row.dataset.rowKey).toMatch(/^session:/u) + const dataTransfer = { effectAllowed: '', setData: () => {}, setDragImage: () => {} } + fireEvent.dragStart(row, { dataTransfer }) + fireEvent.dragEnd(row, { dataTransfer: { dropEffect: 'none' } }) + expect(dataTransfer.effectAllowed).toBe('copy') + } +} + describe('Assembled liveshare viewer page on a writable share', () => { it('writes the shared Session, keeps the Workspace out of reach, and closes on a narrower mode', async () => { inputFixture = installViewerInputFixture() @@ -131,7 +143,7 @@ describe('Assembled liveshare viewer page on a writable share', () => { await workspaceMenu.ready expect(workspaceMenu.source.getSnapshot()).toEqual([]) workspaceMenu.dispose() - expect(document.querySelector('[role="treeitem"][draggable="true"]')).toBeNull() + expectNoReorderHandles() // The Session's own verbs stay the owner's — the one this page may use there is the branch the // mode grants — so the row's menu is not a second way into the owner's Session management: it // opens on the branch verb and carries neither rename nor archive. From b4e81dcd058a68c4052c64f4f2853d7eea2c4bd9 Mon Sep 17 00:00:00 2001 From: Turtle Date: Fri, 20 Nov 2026 06:20:27 +0800 Subject: [PATCH 05/11] fix(web): keep the Session drop target above the narrow-window drawer Co-authored-by: liukx0205 <69756503+liukx0205@users.noreply.github.com> Co-authored-by: Yifffan <133629972+Yifffan@users.noreply.github.com> --- packages/client/ui-subagent/README.i18n.yaml | 4 ++-- packages/client/ui-subagent/README.md | 2 +- packages/client/ui-subagent/README.zh.md | 2 +- .../src/client/sidebar-chat/SessionDropZone.module.css | 9 ++++++--- .../src/client/sidebar-chat/SessionDropZone.tsx | 7 +++++-- .../ui-subagent/tests/session-drop.client.spec.tsx | 9 ++++++--- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/packages/client/ui-subagent/README.i18n.yaml b/packages/client/ui-subagent/README.i18n.yaml index d4e1c4f8bd..1dac58c997 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: f14602d90bd2050c - zh: 3e07260df8e52965 + en: a705c095de602744 + zh: 839030c37d0fd31a /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 be08239bc1..b353f3a2c2 100644 --- a/packages/client/ui-subagent/README.md +++ b/packages/client/ui-subagent/README.md @@ -29,7 +29,7 @@ The session header uses the session title for ordinary breadcrumbs. Subagent bre 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. -Dragging a root Session row from the Session list shows a drop target over the window's right 40%, at least 300px wide, while another Session is on screen. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/`, an address without a query, in the on-screen Session's Sidebar column, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title. +Dragging a root Session row from the Session list shows a drop target over the window's right 40%, at least 300px wide, while another Session is on screen. The target never covers the window's leftmost 280px, so an open narrow-window drawer stays reachable, and it stacks above the drawer's mask. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/`, an address without a query, in the on-screen Session's Sidebar column, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title. 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 86ac6c40e1..dec7e87c97 100644 --- a/packages/client/ui-subagent/README.zh.md +++ b/packages/client/ui-subagent/README.zh.md @@ -29,7 +29,7 @@ kind: "package-reference" 本包注册 `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,并把草稿移过去。 -从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,窗口右侧 40% 的区域(宽度至少 300px)会显示放置目标。在此放下后,会在屏幕上那个 Session 的 Sidebar 栏中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 Session 的显示标题。 +从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,窗口右侧 40% 的区域(宽度至少 300px)会显示放置目标。放置目标不覆盖窗口最左侧 280px,因此窄窗口中已打开的抽屉仍可操作;放置目标显示在抽屉遮罩之上。在此放下后,会在屏幕上那个 Session 的 Sidebar 栏中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 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/SessionDropZone.module.css b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css index 08726f3da2..b9db96ce8b 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css +++ b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css @@ -1,15 +1,18 @@ /* The drop target covers the right column's default 40% band, like the dock kit's edge band, and draws the dock kit's drop hint: a blurred ground under - a dashed card that takes the accent while the pointer is over it. */ + a dashed card that takes the accent while the pointer is over it. It stacks + above the narrow-window drawer (71) and its mask (70), below menus and + toasts, and leaves the default 280px drawer width uncovered so the list + stays reachable for reordering. */ .zone { position: fixed; + z-index: 72; top: var(--dsh-frame-top-clearance, 0px); right: 0; bottom: 0; box-sizing: border-box; display: flex; - width: max(300px, 40vw); - max-width: 100vw; + width: min(max(300px, 40vw), calc(100vw - 280px)); padding: 8px; pointer-events: auto; background: color-mix(in srgb, var(--dsw-alias-bg-base) 72%, transparent); diff --git a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx index 6f7e720e6d..8b2eb6bceb 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx +++ b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx @@ -1,5 +1,6 @@ /** Drop target that opens a Session dragged from the Session list in the right Sidebar. */ import { useState, type DragEvent } from 'react' +import { createPortal } from 'react-dom' import { IconPanelLeftOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives' import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots' import type { SessionId } from '@deepseek-ai/dsh-session/types' @@ -46,7 +47,8 @@ function DropTarget({ label, onDrop }: { readonly label: string; readonly onDrop event.dataTransfer.dropEffect = 'copy' setOver(true) } - return ( + // A body portal stacks above the narrow-window drawer mask, which covers the frame's overlay layer. + return createPortal( - + , + document.body, ) } diff --git a/packages/client/ui-subagent/tests/session-drop.client.spec.tsx b/packages/client/ui-subagent/tests/session-drop.client.spec.tsx index cb92306bac..9cfff2b487 100644 --- a/packages/client/ui-subagent/tests/session-drop.client.spec.tsx +++ b/packages/client/ui-subagent/tests/session-drop.client.spec.tsx @@ -94,10 +94,13 @@ describe('Session drop zone', () => { it('renders only during a Session drag and opens the dropped Session aside', () => { const view = mount(undefined) - expect(view.container.innerHTML).toBe('') + expect(document.querySelector('[data-session-drop-zone]')).toBeNull() view.set(OTHER) const label = screen.getByText('Open in sidebar') - const zone = view.container.querySelector('[data-session-drop-zone]') as HTMLElement + // The zone portals to the body so it stacks above the narrow-window drawer mask. + const zone = document.querySelector('[data-session-drop-zone]')! + expect(zone.parentElement).toBe(document.body) + expect(view.container.innerHTML).toBe('') expect(zone.hasAttribute('data-active')).toBe(false) const over = fire(zone, 'dragOver') @@ -122,6 +125,6 @@ describe('Session drop zone', () => { expect(zone.hasAttribute('data-active')).toBe(false) view.set(undefined) - expect(view.container.innerHTML).toBe('') + expect(document.querySelector('[data-session-drop-zone]')).toBeNull() }) }) From c7225ab990f72243a8b641107695a991a6f72ea9 Mon Sep 17 00:00:00 2001 From: Turtle Date: Fri, 20 Nov 2026 14:25:43 +0800 Subject: [PATCH 06/11] fix(web): cover the whole area right of the Session list with the drop target Co-authored-by: liukx0205 <69756503+liukx0205@users.noreply.github.com> Co-authored-by: Yifffan <133629972+Yifffan@users.noreply.github.com> --- packages/client/ui-subagent/README.i18n.yaml | 4 +- packages/client/ui-subagent/README.md | 2 +- packages/client/ui-subagent/README.zh.md | 2 +- .../sidebar-chat/SessionDropZone.module.css | 14 +++--- .../client/sidebar-chat/SessionDropZone.tsx | 24 ++++++++--- .../src/client/sidebar-chat/index.tsx | 29 ++++++++++--- .../tests/session-drop.client.spec.tsx | 43 +++++++++++++++---- .../tests/sidebar-chat.client.spec.tsx | 4 +- 8 files changed, 88 insertions(+), 34 deletions(-) diff --git a/packages/client/ui-subagent/README.i18n.yaml b/packages/client/ui-subagent/README.i18n.yaml index 1dac58c997..719fb3c63d 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: a705c095de602744 - zh: 839030c37d0fd31a + en: 0ac6deb29564f9e8 + zh: b2bb27848569fc9a /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 b353f3a2c2..453e881cfa 100644 --- a/packages/client/ui-subagent/README.md +++ b/packages/client/ui-subagent/README.md @@ -29,7 +29,7 @@ The session header uses the session title for ordinary breadcrumbs. Subagent bre 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. -Dragging a root Session row from the Session list shows a drop target over the window's right 40%, at least 300px wide, while another Session is on screen. The target never covers the window's leftmost 280px, so an open narrow-window drawer stays reachable, and it stacks above the drawer's mask. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/`, an address without a query, in the on-screen Session's Sidebar column, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title. +Dragging a root Session row from the Session list shows a drop target while another Session is on screen. The target covers the whole window to the right of the navigation column or narrow-window drawer that the row left, with the same 8px inset on every side, and stacks above the drawer's mask. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/`, an address without a query, in the on-screen Session's Sidebar column, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title. 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 dec7e87c97..d47bee55bc 100644 --- a/packages/client/ui-subagent/README.zh.md +++ b/packages/client/ui-subagent/README.zh.md @@ -29,7 +29,7 @@ kind: "package-reference" 本包注册 `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,并把草稿移过去。 -从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,窗口右侧 40% 的区域(宽度至少 300px)会显示放置目标。放置目标不覆盖窗口最左侧 280px,因此窄窗口中已打开的抽屉仍可操作;放置目标显示在抽屉遮罩之上。在此放下后,会在屏幕上那个 Session 的 Sidebar 栏中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 Session 的显示标题。 +从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,会显示放置目标。放置目标覆盖该行被拖出的导航栏或窄窗口抽屉右侧的整个窗口区域,四边均内缩 8px,并显示在抽屉遮罩之上。在此放下后,会在屏幕上那个 Session 的 Sidebar 栏中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 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/SessionDropZone.module.css b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css index b9db96ce8b..2a9ce88476 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css +++ b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css @@ -1,18 +1,16 @@ -/* The drop target covers the right column's default 40% band, like the dock - kit's edge band, and draws the dock kit's drop hint: a blurred ground under - a dashed card that takes the accent while the pointer is over it. It stacks - above the narrow-window drawer (71) and its mask (70), below menus and - toasts, and leaves the default 280px drawer width uncovered so the list - stays reachable for reordering. */ +/* The drop target covers the window right of the navigation column the row + left (its left edge is set inline), with an 8px inset on every side, and + draws the dock kit's drop hint: a blurred ground under a dashed card that + takes the accent while the pointer is over it. It stacks above the + narrow-window drawer (71) and its mask (70), below menus and toasts. */ .zone { position: fixed; z-index: 72; - top: var(--dsh-frame-top-clearance, 0px); + top: var(--dsh-frame-chrome-top, 0px); right: 0; bottom: 0; box-sizing: border-box; display: flex; - width: min(max(300px, 40vw), calc(100vw - 280px)); padding: 8px; pointer-events: auto; background: color-mix(in srgb, var(--dsw-alias-bg-base) 72%, transparent); diff --git a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx index 8b2eb6bceb..78ad23f793 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx +++ b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx @@ -11,11 +11,18 @@ import css from './SessionDropZone.module.css' /** Drag data type the Session list sets to a dragged row's Session id. */ export const SESSION_DRAG_TYPE: SessionDragType = 'application/x-dsh-session' +/** A Session row in flight and where the drop target starts. */ +export interface SessionDrag { + readonly sessionId: SessionId + /** Right edge of the navigation column the row left, in px; the target covers the window to its right. */ + readonly inset: number +} + /** Session drag tracking and the open operation supplied by the plugin. */ export interface SessionDropZoneInjected { readonly hooks: { /** Session dragged from the list that the on-screen Session's Sidebar can open; undefined otherwise. */ - readonly sessionDrag: HostObservable + readonly sessionDrag: HostObservable } /** Open the Session's Conversation in the on-screen Session's right Sidebar. */ readonly openAside: (sessionId: SessionId) => void @@ -31,13 +38,17 @@ export type SessionDropZoneProps = * @returns the drop target, or nothing outside a Session drag. */ export function SessionDropZone({ useSessionDrag, openAside, t }: SessionDropZoneProps) { - const sessionId = useSessionDrag(value => value) - return sessionId === undefined - ? null - : { openAside(sessionId) }} /> + const drag = useSessionDrag(value => value) + if (drag === undefined) return null + const { sessionId, inset } = drag + return { openAside(sessionId) }} /> } -function DropTarget({ label, onDrop }: { readonly label: string; readonly onDrop: () => void }) { +function DropTarget({ inset, label, onDrop }: { + readonly inset: number + readonly label: string + readonly onDrop: () => void +}) { const [over, setOver] = useState(false) // Stop propagation so document-level handlers of the list's reorder drag // keep neither the drop nor their `move` effect. @@ -51,6 +62,7 @@ function DropTarget({ label, onDrop }: { readonly label: string; readonly onDrop return createPortal(
[data-shell-overlay]') !== null) return element + } + return undefined +} + /** * Track Session rows dragged from the Session list while another Session is on screen. * @param doc - document whose drag events carry the rows' data. * @param mounted - reads the on-screen Session. - * @returns the dragged Session observable and its listener disposer. + * @returns the dragged Session with the right edge of the column it left, in px, and the listener disposer. */ export function trackSessionDrags(doc: Document, mounted: () => SessionId | undefined): { - readonly source: HostObservable + readonly source: HostObservable readonly dispose: () => void } { - let current: SessionId | undefined + let current: SessionDrag | undefined const listeners = new Set<() => void>() - const publish = (next: SessionId | undefined): void => { + const publish = (next: SessionDrag | undefined): void => { if (next === current) return current = next for (const listener of listeners) listener() @@ -147,7 +159,12 @@ export function trackSessionDrags(doc: Document, mounted: () => SessionId | unde const start = (event: DragEvent): void => { const id = event.dataTransfer?.getData(SESSION_DRAG_TYPE) as SessionId | undefined const onScreen = mounted() - publish(id !== undefined && id !== '' && onScreen !== undefined && onScreen !== id ? id : undefined) + if (id === undefined || id === '' || onScreen === undefined || onScreen === id) { + publish(undefined) + return + } + const column = event.target instanceof Element ? frameColumnOf(event.target) : undefined + publish({ sessionId: id, inset: Math.round(column?.getBoundingClientRect().right ?? 0) }) } const end = (): void => { publish(undefined) } // A source row unmounted mid-drag fires dragend on a detached node; the first diff --git a/packages/client/ui-subagent/tests/session-drop.client.spec.tsx b/packages/client/ui-subagent/tests/session-drop.client.spec.tsx index 9cfff2b487..243f52bcf5 100644 --- a/packages/client/ui-subagent/tests/session-drop.client.spec.tsx +++ b/packages/client/ui-subagent/tests/session-drop.client.spec.tsx @@ -4,7 +4,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest' import type { HostObservable } from '@deepseek-ai/dsh-client-ui-slots' import type { SessionId } from '@deepseek-ai/dsh-session/types' import { trackSessionDrags } from '../src/client/sidebar-chat/index.tsx' -import { SessionDropZone, type SessionDropZoneProps } from '../src/client/sidebar-chat/SessionDropZone.tsx' +import { SessionDropZone, type SessionDrag, type SessionDropZoneProps } from '../src/client/sidebar-chat/SessionDropZone.tsx' const MAIN = 'main' as SessionId const OTHER = 'other' as SessionId @@ -14,12 +14,14 @@ afterEach(() => { }) /** jsdom lacks DragEvent; attach the transfer a browser would supply. */ -function dispatchDrag(type: string, data: Record = {}): void { +function dispatchDrag(type: string, data: Record = {}, target: EventTarget = document.body): void { const event = new Event(type, { bubbles: true }) Object.defineProperty(event, 'dataTransfer', { value: { getData: (format: string) => data[format] ?? '' } }) - document.body.dispatchEvent(event) + target.dispatchEvent(event) } +const outside = { sessionId: OTHER, inset: 0 } + describe('Session drag tracking', () => { it('publishes a dragged list Session that another on-screen Session can open', () => { let mounted: SessionId | undefined = MAIN @@ -29,7 +31,7 @@ describe('Session drag tracking', () => { expect(drags.source.getSnapshot()).toBeUndefined() dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }) - expect(drags.source.getSnapshot()).toBe(OTHER) + expect(drags.source.getSnapshot()).toEqual(outside) dispatchDrag('dragend') expect(drags.source.getSnapshot()).toBeUndefined() expect(listener).toHaveBeenCalledTimes(2) @@ -41,7 +43,7 @@ describe('Session drag tracking', () => { // A row unmounted mid-drag never delivers dragend; the next button-free mouse move clears the drag. dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }) document.body.dispatchEvent(new MouseEvent('mousemove', { bubbles: true, buttons: 1 })) - expect(drags.source.getSnapshot()).toBe(OTHER) + expect(drags.source.getSnapshot()).toEqual(outside) document.body.dispatchEvent(new MouseEvent('mousemove', { bubbles: true, buttons: 0 })) expect(drags.source.getSnapshot()).toBeUndefined() @@ -59,7 +61,28 @@ describe('Session drag tracking', () => { expect(listener).toHaveBeenCalledTimes(6) drags.dispose() dispatchDrag('dragend') - expect(drags.source.getSnapshot()).toBe(OTHER) + expect(drags.source.getSnapshot()).toEqual(outside) + }) + + it('starts the target at the right edge of the frame column the row left', () => { + const frame = document.createElement('div') + const column = document.createElement('nav') + const row = document.createElement('div') + const overlay = document.createElement('div') + overlay.setAttribute('data-shell-overlay', '') + column.append(row) + frame.append(column, overlay) + document.body.append(frame) + column.getBoundingClientRect = () => ({ right: 279.6 }) as DOMRect + const drags = trackSessionDrags(document, () => MAIN) + dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }, row) + expect(drags.source.getSnapshot()).toEqual({ sessionId: OTHER, inset: 280 }) + // A drag whose target is not an element starts at the window edge. + dispatchDrag('dragend') + dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }, document) + expect(drags.source.getSnapshot()).toEqual(outside) + drags.dispose() + frame.remove() }) }) @@ -67,9 +90,12 @@ describe('Session drop zone', () => { function mount(initial: SessionId | undefined) { let current = initial const openAside = vi.fn() - const source: HostObservable = { getSnapshot: () => current, subscribe: () => () => {} } + const source: HostObservable = { + getSnapshot: () => current === undefined ? undefined : { sessionId: current, inset: 280 }, + subscribe: () => () => {}, + } const props = { - useSessionDrag: (select: (value: SessionId | undefined) => T) => select(source.getSnapshot()), + useSessionDrag: (select: (value: SessionDrag | undefined) => T) => select(source.getSnapshot()), openAside, t: (key: string) => key === 'open.sidebar' ? 'Open in sidebar' : key, } as Partial as SessionDropZoneProps @@ -100,6 +126,7 @@ describe('Session drop zone', () => { // The zone portals to the body so it stacks above the narrow-window drawer mask. const zone = document.querySelector('[data-session-drop-zone]')! expect(zone.parentElement).toBe(document.body) + expect(zone.style.left).toBe('280px') expect(view.container.innerHTML).toBe('') expect(zone.hasAttribute('data-active')).toBe(false) 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 8b49ecfb21..d58e5e0dca 100644 --- a/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx +++ b/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx @@ -143,7 +143,7 @@ describe('Sidebar chat registration', () => { ]) // A dropped root Session opens in the on-screen Session's Sidebar column. const drop = registrations[2]?.options.inject as () => { - hooks: { sessionDrag: { getSnapshot: () => SessionId | undefined } } + hooks: { sessionDrag: { getSnapshot: () => { sessionId: SessionId; inset: number } | undefined } } openAside: (sessionId: SessionId) => void } drop().openAside(CHILD) @@ -159,7 +159,7 @@ describe('Sidebar chat registration', () => { document.body.dispatchEvent(event) } dragStart() - expect(drop().hooks.sessionDrag.getSnapshot()).toBe(CHILD) + expect(drop().hooks.sessionDrag.getSnapshot()).toEqual({ sessionId: CHILD, inset: 0 }) document.body.dispatchEvent(new Event('dragend', { bubbles: true })) for (const dispose of disposers) dispose() dragStart() From d03be2bf85a9c48f3e52ff442c396f85ed0f89d6 Mon Sep 17 00:00:00 2001 From: Turtle Date: Fri, 20 Nov 2026 14:48:10 +0800 Subject: [PATCH 07/11] fix(web): size the drop target's highlighted card to the right sidebar Co-authored-by: liukx0205 <69756503+liukx0205@users.noreply.github.com> Co-authored-by: Yifffan <133629972+Yifffan@users.noreply.github.com> --- packages/client/ui-subagent/README.i18n.yaml | 4 ++-- packages/client/ui-subagent/README.md | 2 +- packages/client/ui-subagent/README.zh.md | 2 +- .../sidebar-chat/SessionDropZone.module.css | 14 +++++++---- .../client/sidebar-chat/SessionDropZone.tsx | 11 +++++---- .../src/client/sidebar-chat/index.tsx | 12 ++++++++-- .../tests/session-drop.client.spec.tsx | 24 +++++++++++++++---- .../tests/sidebar-chat.client.spec.tsx | 4 ++-- 8 files changed, 53 insertions(+), 20 deletions(-) diff --git a/packages/client/ui-subagent/README.i18n.yaml b/packages/client/ui-subagent/README.i18n.yaml index 719fb3c63d..046b8f6f0a 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: 0ac6deb29564f9e8 - zh: b2bb27848569fc9a + en: 7e3eece5a469ece5 + zh: 806e7485183135b1 /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 453e881cfa..05ed6f460c 100644 --- a/packages/client/ui-subagent/README.md +++ b/packages/client/ui-subagent/README.md @@ -29,7 +29,7 @@ The session header uses the session title for ordinary breadcrumbs. Subagent bre 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. -Dragging a root Session row from the Session list shows a drop target while another Session is on screen. The target covers the whole window to the right of the navigation column or narrow-window drawer that the row left, with the same 8px inset on every side, and stacks above the drawer's mask. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/`, an address without a query, in the on-screen Session's Sidebar column, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title. +Dragging a root Session row from the Session list shows a drop target while another Session is on screen. The target blurs the whole window to the right of the navigation column or narrow-window drawer that the row left and accepts the drop anywhere there; its highlighted card sits at the right edge, as wide as the right Sidebar would open, with an 8px inset on every side. The target stacks above the drawer's mask. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/`, an address without a query, in the on-screen Session's Sidebar column, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title. 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 d47bee55bc..517423ca75 100644 --- a/packages/client/ui-subagent/README.zh.md +++ b/packages/client/ui-subagent/README.zh.md @@ -29,7 +29,7 @@ kind: "package-reference" 本包注册 `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,并把草稿移过去。 -从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,会显示放置目标。放置目标覆盖该行被拖出的导航栏或窄窗口抽屉右侧的整个窗口区域,四边均内缩 8px,并显示在抽屉遮罩之上。在此放下后,会在屏幕上那个 Session 的 Sidebar 栏中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 Session 的显示标题。 +从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,会显示放置目标。放置目标将该行被拖出的导航栏或窄窗口抽屉右侧的整个窗口区域模糊处理,并在该区域内任意位置接受放置;其高亮卡片位于右边缘,宽度与右侧侧边栏打开时的宽度相同,四边均内缩 8px。放置目标显示在抽屉遮罩之上。在此放下后,会在屏幕上那个 Session 的 Sidebar 栏中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 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/SessionDropZone.module.css b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css index 2a9ce88476..3ff41672e8 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css +++ b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css @@ -1,8 +1,11 @@ /* The drop target covers the window right of the navigation column the row - left (its left edge is set inline), with an 8px inset on every side, and - draws the dock kit's drop hint: a blurred ground under a dashed card that - takes the accent while the pointer is over it. It stacks above the - narrow-window drawer (71) and its mask (70), below menus and toasts. */ + left (its left edge is set inline) with the dock kit's blurred drop-hint + ground, and accepts the drop anywhere on it. The dashed card that takes the + accent while the pointer is over the target sits at the right edge with an + 8px inset on every side, as wide as the right Sidebar would open (set + inline), or across the whole target when that width is unknown. It stacks + above the narrow-window drawer (71) and its mask (70), below menus and + toasts. */ .zone { position: fixed; z-index: 72; @@ -11,6 +14,7 @@ bottom: 0; box-sizing: border-box; display: flex; + justify-content: flex-end; padding: 8px; pointer-events: auto; background: color-mix(in srgb, var(--dsw-alias-bg-base) 72%, transparent); @@ -21,6 +25,8 @@ .card { display: flex; flex: 1 1 auto; + max-width: 100%; + box-sizing: border-box; flex-direction: column; gap: 8px; align-items: center; diff --git a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx index 78ad23f793..d46ff6f340 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx +++ b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx @@ -16,6 +16,8 @@ export interface SessionDrag { readonly sessionId: SessionId /** Right edge of the navigation column the row left, in px; the target covers the window to its right. */ readonly inset: number + /** Width of the on-screen Session's right Sidebar, in px, which the highlighted card takes; zero when unknown. */ + readonly width: number } /** Session drag tracking and the open operation supplied by the plugin. */ @@ -40,12 +42,13 @@ export type SessionDropZoneProps = export function SessionDropZone({ useSessionDrag, openAside, t }: SessionDropZoneProps) { const drag = useSessionDrag(value => value) if (drag === undefined) return null - const { sessionId, inset } = drag - return { openAside(sessionId) }} /> + const { sessionId, inset, width } = drag + return { openAside(sessionId) }} /> } -function DropTarget({ inset, label, onDrop }: { +function DropTarget({ inset, width, label, onDrop }: { readonly inset: number + readonly width: number readonly label: string readonly onDrop: () => void }) { @@ -77,7 +80,7 @@ function DropTarget({ inset, label, onDrop }: { onDrop() }} > -
+
0 ? { flex: `0 1 ${String(width - 16)}px` } : undefined}>
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 8f8a639679..c85b8be230 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/index.tsx +++ b/packages/client/ui-subagent/src/client/sidebar-chat/index.tsx @@ -142,7 +142,8 @@ function frameColumnOf(node: Element): Element | undefined { * Track Session rows dragged from the Session list while another Session is on screen. * @param doc - document whose drag events carry the rows' data. * @param mounted - reads the on-screen Session. - * @returns the dragged Session with the right edge of the column it left, in px, and the listener disposer. + * @returns the dragged Session with the right edge of the column it left and the on-screen Sidebar's width, in px, + * and the listener disposer. */ export function trackSessionDrags(doc: Document, mounted: () => SessionId | undefined): { readonly source: HostObservable @@ -164,7 +165,14 @@ export function trackSessionDrags(doc: Document, mounted: () => SessionId | unde return } const column = event.target instanceof Element ? frameColumnOf(event.target) : undefined - publish({ sessionId: id, inset: Math.round(column?.getBoundingClientRect().right ?? 0) }) + // The panel keeps its resolved width while collapsed; zero means it cannot fit beside the conversation. + const panel = [...doc.querySelectorAll('[data-sidebar-right-panel]')] + .find(element => element.getAttribute('data-sidebar-right-session') === onScreen) + publish({ + sessionId: id, + inset: Math.round(column?.getBoundingClientRect().right ?? 0), + width: Math.round(panel?.getBoundingClientRect().width ?? 0), + }) } const end = (): void => { publish(undefined) } // A source row unmounted mid-drag fires dragend on a detached node; the first diff --git a/packages/client/ui-subagent/tests/session-drop.client.spec.tsx b/packages/client/ui-subagent/tests/session-drop.client.spec.tsx index 243f52bcf5..f42d808c88 100644 --- a/packages/client/ui-subagent/tests/session-drop.client.spec.tsx +++ b/packages/client/ui-subagent/tests/session-drop.client.spec.tsx @@ -20,7 +20,7 @@ function dispatchDrag(type: string, data: Record = {}, target: E target.dispatchEvent(event) } -const outside = { sessionId: OTHER, inset: 0 } +const outside = { sessionId: OTHER, inset: 0, width: 0 } describe('Session drag tracking', () => { it('publishes a dragged list Session that another on-screen Session can open', () => { @@ -74,13 +74,23 @@ describe('Session drag tracking', () => { frame.append(column, overlay) document.body.append(frame) column.getBoundingClientRect = () => ({ right: 279.6 }) as DOMRect + // The on-screen Session's right Sidebar panel sets the highlighted card's width; another Session's is ignored. + const panel = document.createElement('div') + panel.setAttribute('data-sidebar-right-panel', 'push') + panel.setAttribute('data-sidebar-right-session', MAIN) + panel.getBoundingClientRect = () => ({ width: 520.2 }) as DOMRect + const otherPanel = document.createElement('div') + otherPanel.setAttribute('data-sidebar-right-panel', 'push') + otherPanel.setAttribute('data-sidebar-right-session', OTHER) + otherPanel.getBoundingClientRect = () => ({ width: 900 }) as DOMRect + frame.append(otherPanel, panel) const drags = trackSessionDrags(document, () => MAIN) dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }, row) - expect(drags.source.getSnapshot()).toEqual({ sessionId: OTHER, inset: 280 }) + expect(drags.source.getSnapshot()).toEqual({ sessionId: OTHER, inset: 280, width: 520 }) // A drag whose target is not an element starts at the window edge. dispatchDrag('dragend') dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }, document) - expect(drags.source.getSnapshot()).toEqual(outside) + expect(drags.source.getSnapshot()).toEqual({ ...outside, width: 520 }) drags.dispose() frame.remove() }) @@ -91,7 +101,7 @@ describe('Session drop zone', () => { let current = initial const openAside = vi.fn() const source: HostObservable = { - getSnapshot: () => current === undefined ? undefined : { sessionId: current, inset: 280 }, + getSnapshot: () => current === undefined ? undefined : { sessionId: current, inset: 280, width: current === OTHER ? 516 : 0 }, subscribe: () => () => {}, } const props = { @@ -127,6 +137,8 @@ describe('Session drop zone', () => { const zone = document.querySelector('[data-session-drop-zone]')! expect(zone.parentElement).toBe(document.body) expect(zone.style.left).toBe('280px') + // The highlighted card is as wide as the Sidebar would open, inside the 8px inset. + expect((zone.firstElementChild as HTMLElement).style.flex).toBe('0 1 500px') expect(view.container.innerHTML).toBe('') expect(zone.hasAttribute('data-active')).toBe(false) @@ -151,6 +163,10 @@ describe('Session drop zone', () => { expect(view.openAside).toHaveBeenCalledExactlyOnceWith(OTHER) expect(zone.hasAttribute('data-active')).toBe(false) + // Without a known Sidebar width the card spans the whole target. + view.set(MAIN) + expect((document.querySelector('[data-session-drop-zone]')!.firstElementChild as HTMLElement).style.flex).toBe('') + view.set(undefined) expect(document.querySelector('[data-session-drop-zone]')).toBeNull() }) 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 d58e5e0dca..3a1a136ec4 100644 --- a/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx +++ b/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx @@ -143,7 +143,7 @@ describe('Sidebar chat registration', () => { ]) // A dropped root Session opens in the on-screen Session's Sidebar column. const drop = registrations[2]?.options.inject as () => { - hooks: { sessionDrag: { getSnapshot: () => { sessionId: SessionId; inset: number } | undefined } } + hooks: { sessionDrag: { getSnapshot: () => { sessionId: SessionId; inset: number; width: number } | undefined } } openAside: (sessionId: SessionId) => void } drop().openAside(CHILD) @@ -159,7 +159,7 @@ describe('Sidebar chat registration', () => { document.body.dispatchEvent(event) } dragStart() - expect(drop().hooks.sessionDrag.getSnapshot()).toEqual({ sessionId: CHILD, inset: 0 }) + expect(drop().hooks.sessionDrag.getSnapshot()).toEqual({ sessionId: CHILD, inset: 0, width: 0 }) document.body.dispatchEvent(new Event('dragend', { bubbles: true })) for (const dispose of disposers) dispose() dragStart() From 7bcd87c7c68ce7d5aff69f1da838aa2cdded2f73 Mon Sep 17 00:00:00 2001 From: Turtle Date: Fri, 20 Nov 2026 14:56:07 +0800 Subject: [PATCH 08/11] fix(web): limit the drop target to the right sidebar's area Co-authored-by: liukx0205 <69756503+liukx0205@users.noreply.github.com> Co-authored-by: Yifffan <133629972+Yifffan@users.noreply.github.com> --- packages/client/ui-subagent/README.i18n.yaml | 4 ++-- packages/client/ui-subagent/README.md | 2 +- packages/client/ui-subagent/README.zh.md | 2 +- .../sidebar-chat/SessionDropZone.module.css | 20 +++++++++---------- .../client/sidebar-chat/SessionDropZone.tsx | 8 ++++---- .../tests/session-drop.client.spec.tsx | 12 +++++------ 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/packages/client/ui-subagent/README.i18n.yaml b/packages/client/ui-subagent/README.i18n.yaml index 046b8f6f0a..5748902279 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: 7e3eece5a469ece5 - zh: 806e7485183135b1 + en: 2496fa7cbacfd5a5 + zh: 6cb7d74396aad203 /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 05ed6f460c..047f84d55c 100644 --- a/packages/client/ui-subagent/README.md +++ b/packages/client/ui-subagent/README.md @@ -29,7 +29,7 @@ The session header uses the session title for ordinary breadcrumbs. Subagent bre 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. -Dragging a root Session row from the Session list shows a drop target while another Session is on screen. The target blurs the whole window to the right of the navigation column or narrow-window drawer that the row left and accepts the drop anywhere there; its highlighted card sits at the right edge, as wide as the right Sidebar would open, with an 8px inset on every side. The target stacks above the drawer's mask. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/`, an address without a query, in the on-screen Session's Sidebar column, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title. +Dragging a root Session row from the Session list shows a drop target while another Session is on screen. The target covers the area the right Sidebar would open in, as wide as that Sidebar and never left of the navigation column or narrow-window drawer that the row left, so the chat area stays uncovered; its card has an 8px inset on every side. When the Sidebar width is unknown, the target covers the whole window right of that column. The target stacks above the drawer's mask. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/`, an address without a query, in the on-screen Session's Sidebar column, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title. 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 517423ca75..9666bab432 100644 --- a/packages/client/ui-subagent/README.zh.md +++ b/packages/client/ui-subagent/README.zh.md @@ -29,7 +29,7 @@ kind: "package-reference" 本包注册 `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,并把草稿移过去。 -从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,会显示放置目标。放置目标将该行被拖出的导航栏或窄窗口抽屉右侧的整个窗口区域模糊处理,并在该区域内任意位置接受放置;其高亮卡片位于右边缘,宽度与右侧侧边栏打开时的宽度相同,四边均内缩 8px。放置目标显示在抽屉遮罩之上。在此放下后,会在屏幕上那个 Session 的 Sidebar 栏中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 Session 的显示标题。 +从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,会显示放置目标。放置目标覆盖右侧侧边栏打开时所占的区域,宽度与该侧边栏相同,且始终位于该行被拖出的导航栏或窄窗口抽屉的右侧,因此聊天区域不被覆盖;其卡片四边均内缩 8px。侧边栏宽度未知时,放置目标覆盖该栏右侧的整个窗口区域。放置目标显示在抽屉遮罩之上。在此放下后,会在屏幕上那个 Session 的 Sidebar 栏中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 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/SessionDropZone.module.css b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css index 3ff41672e8..fe7358bdb2 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css +++ b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css @@ -1,20 +1,20 @@ -/* The drop target covers the window right of the navigation column the row - left (its left edge is set inline) with the dock kit's blurred drop-hint - ground, and accepts the drop anywhere on it. The dashed card that takes the - accent while the pointer is over the target sits at the right edge with an - 8px inset on every side, as wide as the right Sidebar would open (set - inline), or across the whole target when that width is unknown. It stacks - above the narrow-window drawer (71) and its mask (70), below menus and - toasts. */ +/* The drop target covers the area the right Sidebar would open in: as wide + as that Sidebar (measured values set inline), never left of the navigation column + or narrow-window drawer the row came from, and that whole area right of the + column when the Sidebar width is unknown. It leaves the chat area uncovered + and draws the dock kit's drop hint with an 8px inset on every side: a blurred + ground under a dashed card that takes the accent while the pointer is over + it. It stacks above the narrow-window drawer (71) and its mask (70), below + menus and toasts. */ .zone { position: fixed; z-index: 72; + left: max(var(--session-drop-inset), calc(100vw - var(--session-drop-width, 100vw))); top: var(--dsh-frame-chrome-top, 0px); right: 0; bottom: 0; box-sizing: border-box; display: flex; - justify-content: flex-end; padding: 8px; pointer-events: auto; background: color-mix(in srgb, var(--dsw-alias-bg-base) 72%, transparent); @@ -25,8 +25,6 @@ .card { display: flex; flex: 1 1 auto; - max-width: 100%; - box-sizing: border-box; flex-direction: column; gap: 8px; align-items: center; diff --git a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx index d46ff6f340..843040d867 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx +++ b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx @@ -1,5 +1,5 @@ /** Drop target that opens a Session dragged from the Session list in the right Sidebar. */ -import { useState, type DragEvent } from 'react' +import { useState, type CSSProperties, type DragEvent } from 'react' import { createPortal } from 'react-dom' import { IconPanelLeftOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives' import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots' @@ -16,7 +16,7 @@ export interface SessionDrag { readonly sessionId: SessionId /** Right edge of the navigation column the row left, in px; the target covers the window to its right. */ readonly inset: number - /** Width of the on-screen Session's right Sidebar, in px, which the highlighted card takes; zero when unknown. */ + /** Width of the on-screen Session's right Sidebar, in px, which the target takes; zero when unknown. */ readonly width: number } @@ -65,7 +65,7 @@ function DropTarget({ inset, width, label, onDrop }: { return createPortal(
0 ? { '--session-drop-width': `${String(width)}px` } : {}) } as CSSProperties} data-session-drop-zone="" data-active={over || undefined} onDragEnter={accept} @@ -80,7 +80,7 @@ function DropTarget({ inset, width, label, onDrop }: { onDrop() }} > -
0 ? { flex: `0 1 ${String(width - 16)}px` } : undefined}> +
diff --git a/packages/client/ui-subagent/tests/session-drop.client.spec.tsx b/packages/client/ui-subagent/tests/session-drop.client.spec.tsx index f42d808c88..4d521e9245 100644 --- a/packages/client/ui-subagent/tests/session-drop.client.spec.tsx +++ b/packages/client/ui-subagent/tests/session-drop.client.spec.tsx @@ -74,7 +74,7 @@ describe('Session drag tracking', () => { frame.append(column, overlay) document.body.append(frame) column.getBoundingClientRect = () => ({ right: 279.6 }) as DOMRect - // The on-screen Session's right Sidebar panel sets the highlighted card's width; another Session's is ignored. + // The on-screen Session's right Sidebar panel sets the target's width; another Session's is ignored. const panel = document.createElement('div') panel.setAttribute('data-sidebar-right-panel', 'push') panel.setAttribute('data-sidebar-right-session', MAIN) @@ -136,9 +136,9 @@ describe('Session drop zone', () => { // The zone portals to the body so it stacks above the narrow-window drawer mask. const zone = document.querySelector('[data-session-drop-zone]')! expect(zone.parentElement).toBe(document.body) - expect(zone.style.left).toBe('280px') - // The highlighted card is as wide as the Sidebar would open, inside the 8px inset. - expect((zone.firstElementChild as HTMLElement).style.flex).toBe('0 1 500px') + // The target is as wide as the Sidebar would open, and never reaches left of the navigation column. + expect(zone.style.getPropertyValue('--session-drop-inset')).toBe('280px') + expect(zone.style.getPropertyValue('--session-drop-width')).toBe('516px') expect(view.container.innerHTML).toBe('') expect(zone.hasAttribute('data-active')).toBe(false) @@ -163,9 +163,9 @@ describe('Session drop zone', () => { expect(view.openAside).toHaveBeenCalledExactlyOnceWith(OTHER) expect(zone.hasAttribute('data-active')).toBe(false) - // Without a known Sidebar width the card spans the whole target. + // Without a known Sidebar width the target spans the window right of the navigation column. view.set(MAIN) - expect((document.querySelector('[data-session-drop-zone]')!.firstElementChild as HTMLElement).style.flex).toBe('') + expect(document.querySelector('[data-session-drop-zone]')!.style.getPropertyValue('--session-drop-width')).toBe('') view.set(undefined) expect(document.querySelector('[data-session-drop-zone]')).toBeNull() From 0c574bebd94825a9e4ae54fddd629c8b28471512 Mon Sep 17 00:00:00 2001 From: Turtle Date: Fri, 20 Nov 2026 15:40:02 +0800 Subject: [PATCH 09/11] fix(web): show one Session drop target per right sidebar pane Co-authored-by: liukx0205 <69756503+liukx0205@users.noreply.github.com> Co-authored-by: Yifffan <133629972+Yifffan@users.noreply.github.com> --- packages/client/ui-subagent/README.i18n.yaml | 4 +- packages/client/ui-subagent/README.md | 2 +- packages/client/ui-subagent/README.zh.md | 2 +- .../sidebar-chat/SessionDropZone.module.css | 19 ++--- .../client/sidebar-chat/SessionDropZone.tsx | 54 ++++++++------ .../src/client/sidebar-chat/index.tsx | 54 ++++++++++---- .../tests/session-drop.client.spec.tsx | 71 +++++++++++++++---- .../tests/sidebar-chat.client.spec.tsx | 10 +-- 8 files changed, 148 insertions(+), 68 deletions(-) diff --git a/packages/client/ui-subagent/README.i18n.yaml b/packages/client/ui-subagent/README.i18n.yaml index 5748902279..ff802b4bf9 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: 2496fa7cbacfd5a5 - zh: 6cb7d74396aad203 + en: 1db14b45b7b0676f + zh: bc0d093b3fc49620 /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 047f84d55c..7c1ab7931d 100644 --- a/packages/client/ui-subagent/README.md +++ b/packages/client/ui-subagent/README.md @@ -29,7 +29,7 @@ The session header uses the session title for ordinary breadcrumbs. Subagent bre 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. -Dragging a root Session row from the Session list shows a drop target while another Session is on screen. The target covers the area the right Sidebar would open in, as wide as that Sidebar and never left of the navigation column or narrow-window drawer that the row left, so the chat area stays uncovered; its card has an 8px inset on every side. When the Sidebar width is unknown, the target covers the whole window right of that column. The target stacks above the drawer's mask. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/`, an address without a query, in the on-screen Session's Sidebar column, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title. +Dragging a root Session row from the Session list shows a drop target while another Session is on screen. While the right Sidebar is open, one target covers each docked pane, leaving the panes' divider and the chat area visible, and a drop opens the Session in that pane. While it is collapsed, one target covers the area the Sidebar would open in, never left of the navigation column or narrow-window drawer that the row left, or that whole area right of the column when the Sidebar cannot fit. Each target's card has an 8px inset on every side, and targets stack above the drawer's mask. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/`, an address without a query, in the on-screen Session's Sidebar, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title. 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 9666bab432..d3d7e12510 100644 --- a/packages/client/ui-subagent/README.zh.md +++ b/packages/client/ui-subagent/README.zh.md @@ -29,7 +29,7 @@ kind: "package-reference" 本包注册 `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,并把草稿移过去。 -从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,会显示放置目标。放置目标覆盖右侧侧边栏打开时所占的区域,宽度与该侧边栏相同,且始终位于该行被拖出的导航栏或窄窗口抽屉的右侧,因此聊天区域不被覆盖;其卡片四边均内缩 8px。侧边栏宽度未知时,放置目标覆盖该栏右侧的整个窗口区域。放置目标显示在抽屉遮罩之上。在此放下后,会在屏幕上那个 Session 的 Sidebar 栏中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 Session 的显示标题。 +从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,会显示放置目标。右侧侧边栏打开时,每个分栏各由一个放置目标覆盖,分栏之间的分割线和聊天区域保持可见;在某个分栏上放下时,会在该分栏中打开该 Session。侧边栏收起时,一个放置目标覆盖侧边栏打开时所占的区域,且始终位于该行被拖出的导航栏或窄窗口抽屉的右侧;侧边栏放不下时,该放置目标覆盖该栏右侧的整个区域。每个放置目标的卡片四边均内缩 8px,放置目标显示在抽屉遮罩之上。在此放下后,会在屏幕上那个 Session 的 Sidebar 中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 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/SessionDropZone.module.css b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css index fe7358bdb2..4f3e0c1419 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css +++ b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css @@ -1,18 +1,13 @@ -/* The drop target covers the area the right Sidebar would open in: as wide - as that Sidebar (measured values set inline), never left of the navigation column - or narrow-window drawer the row came from, and that whole area right of the - column when the Sidebar width is unknown. It leaves the chat area uncovered - and draws the dock kit's drop hint with an 8px inset on every side: a blurred - ground under a dashed card that takes the accent while the pointer is over - it. It stacks above the narrow-window drawer (71) and its mask (70), below - menus and toasts. */ +/* One drop target covers each docked pane of the open right Sidebar, leaving + the Sidebar's divider and the chat area visible, or the area a collapsed + Sidebar would open in (rectangles set inline). Each draws the dock kit's + drop hint with an 8px inset on every side: a blurred ground under a dashed + card that takes the accent while the pointer is over it. Targets stack + above the narrow-window drawer (71) and its mask (70), below menus and + toasts. */ .zone { position: fixed; z-index: 72; - left: max(var(--session-drop-inset), calc(100vw - var(--session-drop-width, 100vw))); - top: var(--dsh-frame-chrome-top, 0px); - right: 0; - bottom: 0; box-sizing: border-box; display: flex; padding: 8px; diff --git a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx index 843040d867..02fe595e0b 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx +++ b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx @@ -1,23 +1,31 @@ /** Drop target that opens a Session dragged from the Session list in the right Sidebar. */ -import { useState, type CSSProperties, type DragEvent } from 'react' +import { useState, type DragEvent } from 'react' import { createPortal } from 'react-dom' import { IconPanelLeftOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives' import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots' import type { SessionId } from '@deepseek-ai/dsh-session/types' import type { SessionDragType } from '@deepseek-ai/dsh-client-ui-workspace/client' +import type { PaneId } from '@deepseek-ai/dsh-client-ui-sidebar-right/client' import type { NS } from '../locales.ts' import css from './SessionDropZone.module.css' /** Drag data type the Session list sets to a dragged row's Session id. */ export const SESSION_DRAG_TYPE: SessionDragType = 'application/x-dsh-session' -/** A Session row in flight and where the drop target starts. */ +/** Viewport rectangle, in px, where a dragged Session can land. */ +export interface SessionDropTarget { + /** Docked Sidebar pane the Session opens in; absent for the area a collapsed Sidebar would open in. */ + readonly paneId?: PaneId + readonly left: number + readonly top: number + readonly width: number + readonly height: number +} + +/** A Session row in flight and where it can land. */ export interface SessionDrag { readonly sessionId: SessionId - /** Right edge of the navigation column the row left, in px; the target covers the window to its right. */ - readonly inset: number - /** Width of the on-screen Session's right Sidebar, in px, which the target takes; zero when unknown. */ - readonly width: number + readonly targets: readonly SessionDropTarget[] } /** Session drag tracking and the open operation supplied by the plugin. */ @@ -26,8 +34,8 @@ export interface SessionDropZoneInjected { /** Session dragged from the list that the on-screen Session's Sidebar can open; undefined otherwise. */ readonly sessionDrag: HostObservable } - /** Open the Session's Conversation in the on-screen Session's right Sidebar. */ - readonly openAside: (sessionId: SessionId) => void + /** Open the Session's Conversation in the on-screen Session's right Sidebar, in the named docked pane if any. */ + readonly openAside: (sessionId: SessionId, paneId?: PaneId) => void } /** Props of the `shell.overlay` drop target. */ @@ -35,20 +43,28 @@ export type SessionDropZoneProps = PropsRuntime<'shell.overlay'> & PropsLocale & InjectFace /** - * Show the right-edge drop target while a Session row is dragged. + * Show a drop target over each place in the right Sidebar a dragged Session row can open in. * @param props - tracked drag, open operation, and copy. * @returns the drop target, or nothing outside a Session drag. */ export function SessionDropZone({ useSessionDrag, openAside, t }: SessionDropZoneProps) { const drag = useSessionDrag(value => value) if (drag === undefined) return null - const { sessionId, inset, width } = drag - return { openAside(sessionId) }} /> + const { sessionId, targets } = drag + // A body portal stacks above the narrow-window drawer mask, which covers the frame's overlay layer. + return createPortal( + <> + {targets.map(target => ( + { openAside(sessionId, target.paneId) }} /> + ))} + , + document.body, + ) } -function DropTarget({ inset, width, label, onDrop }: { - readonly inset: number - readonly width: number +function DropTarget({ target, label, onDrop }: { + readonly target: SessionDropTarget readonly label: string readonly onDrop: () => void }) { @@ -61,12 +77,11 @@ function DropTarget({ inset, width, label, onDrop }: { event.dataTransfer.dropEffect = 'copy' setOver(true) } - // A body portal stacks above the narrow-window drawer mask, which covers the frame's overlay layer. - return createPortal( + return (
0 ? { '--session-drop-width': `${String(width)}px` } : {}) } as CSSProperties} - data-session-drop-zone="" + style={{ left: target.left, top: target.top, width: target.width, height: target.height }} + data-session-drop-zone={target.paneId ?? ''} data-active={over || undefined} onDragEnter={accept} onDragOver={accept} @@ -84,7 +99,6 @@ function DropTarget({ inset, width, label, onDrop }: {
-
, - document.body, +
) } 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 c85b8be230..3a81800e9d 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/index.tsx +++ b/packages/client/ui-subagent/src/client/sidebar-chat/index.tsx @@ -5,7 +5,7 @@ import type { } from '@deepseek-ai/dsh-api-session-controller/client' import type { ResourceProvider } from '@deepseek-ai/dsh-client-resources/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 { PaneId, SidebarRightTabDefinition } from '@deepseek-ai/dsh-client-ui-sidebar-right/client' import type { HostObservable, PropsRenderFactories, PropsRenderSlots, PropsRuntime, TranslateNS, } from '@deepseek-ai/dsh-client-ui-slots' @@ -13,7 +13,9 @@ import type { SessionId } from '@deepseek-ai/dsh-session/types' import type { SubagentAddress } from '@deepseek-ai/dsh-subagent/client' import { NS } from '../locales.ts' import css from './SidebarChat.module.css' -import { SESSION_DRAG_TYPE, SessionDropZone, type SessionDrag, type SessionDropZoneInjected } from './SessionDropZone.tsx' +import { + SESSION_DRAG_TYPE, SessionDropZone, type SessionDrag, type SessionDropTarget, type SessionDropZoneInjected, +} from './SessionDropZone.tsx' /** Stable implementation identity for the Sidebar tab body. */ export const SUBAGENT_CHAT_ID = '@deepseek-ai/dsh-client-ui-subagent' @@ -138,12 +140,41 @@ function frameColumnOf(node: Element): Element | undefined { return undefined } +/** + * Measure where a dragged Session can land in the on-screen Session's right Sidebar. + * @param doc - document holding the frame. + * @param onScreen - the Session whose Sidebar receives the drop. + * @param column - navigation column the row left; the target never reaches left of it. + * @returns one target per docked pane while the Sidebar is open, else the area the Sidebar would open in. + */ +function dropTargets(doc: Document, onScreen: SessionId, column: Element | undefined): SessionDropTarget[] { + const inset = Math.round(column?.getBoundingClientRect().right ?? 0) + const panel = [...doc.querySelectorAll('[data-sidebar-right-panel]')] + .find(element => element.getAttribute('data-sidebar-right-session') === onScreen) + if (panel?.hasAttribute('data-sidebar-right-open') === true) { + const panes = [...panel.querySelectorAll('[data-dockkit-pane]')].flatMap((pane) => { + const rect = pane.getBoundingClientRect() + return rect.width > 0 && rect.height > 0 ? [{ paneId: pane.getAttribute('data-dockkit-pane') as PaneId, rect }] : [] + }) + if (panes.length > 0) { + return panes.map(({ paneId, rect }) => ({ + paneId, left: Math.round(rect.left), top: Math.round(rect.top), width: Math.round(rect.width), height: Math.round(rect.height), + })) + } + } + // A collapsed panel keeps its resolved width; zero means it cannot fit beside the conversation. + const viewport = doc.documentElement.clientWidth + const width = Math.round(panel?.getBoundingClientRect().width ?? 0) + const left = Math.max(inset, width > 0 ? viewport - width : inset) + const top = Math.round(column?.getBoundingClientRect().top ?? 0) + return [{ left, top, width: Math.max(0, viewport - left), height: Math.max(0, doc.documentElement.clientHeight - top) }] +} + /** * Track Session rows dragged from the Session list while another Session is on screen. * @param doc - document whose drag events carry the rows' data. * @param mounted - reads the on-screen Session. - * @returns the dragged Session with the right edge of the column it left and the on-screen Sidebar's width, in px, - * and the listener disposer. + * @returns the dragged Session with its drop targets, and the listener disposer. */ export function trackSessionDrags(doc: Document, mounted: () => SessionId | undefined): { readonly source: HostObservable @@ -165,14 +196,7 @@ export function trackSessionDrags(doc: Document, mounted: () => SessionId | unde return } const column = event.target instanceof Element ? frameColumnOf(event.target) : undefined - // The panel keeps its resolved width while collapsed; zero means it cannot fit beside the conversation. - const panel = [...doc.querySelectorAll('[data-sidebar-right-panel]')] - .find(element => element.getAttribute('data-sidebar-right-session') === onScreen) - publish({ - sessionId: id, - inset: Math.round(column?.getBoundingClientRect().right ?? 0), - width: Math.round(panel?.getBoundingClientRect().width ?? 0), - }) + publish({ sessionId: id, targets: dropTargets(doc, onScreen, column) }) } const end = (): void => { publish(undefined) } // A source row unmounted mid-drag fires dragend on a detached node; the first @@ -294,10 +318,12 @@ export function registerSidebarChat(ctx: Context, t: TranslateNS): vo const drags = trackSessionDrags(document, () => ctx.sidebarRight.mounted.getSnapshot()) const injected: SessionDropZoneInjected = { hooks: { sessionDrag: drags.source }, - openAside: (sessionId) => { + openAside: (sessionId, paneId) => { // The on-screen Session can leave between dragstart and drop. if (ctx.sidebarRight.mounted.getSnapshot() === undefined) return - ctx.sidebarRight.openResource(sessionChatAddress(sessionId), { kind: 'subagentchat', destination: 'sidebar' }) + ctx.sidebarRight.openResource(sessionChatAddress(sessionId), paneId === undefined + ? { kind: 'subagentchat', destination: 'sidebar' } + : { kind: 'subagentchat', paneId }) }, } const disposeZone = ctx.slots.inject('shell.overlay', () => ctx.slots.register({ diff --git a/packages/client/ui-subagent/tests/session-drop.client.spec.tsx b/packages/client/ui-subagent/tests/session-drop.client.spec.tsx index 4d521e9245..74352d4b72 100644 --- a/packages/client/ui-subagent/tests/session-drop.client.spec.tsx +++ b/packages/client/ui-subagent/tests/session-drop.client.spec.tsx @@ -3,6 +3,7 @@ import { cleanup, createEvent, fireEvent, render, screen } from '@testing-librar import { afterEach, describe, expect, it, vi } from 'vitest' import type { HostObservable } from '@deepseek-ai/dsh-client-ui-slots' import type { SessionId } from '@deepseek-ai/dsh-session/types' +import type { PaneId } from '@deepseek-ai/dsh-client-ui-sidebar-right/client' import { trackSessionDrags } from '../src/client/sidebar-chat/index.tsx' import { SessionDropZone, type SessionDrag, type SessionDropZoneProps } from '../src/client/sidebar-chat/SessionDropZone.tsx' @@ -20,7 +21,7 @@ function dispatchDrag(type: string, data: Record = {}, target: E target.dispatchEvent(event) } -const outside = { sessionId: OTHER, inset: 0, width: 0 } +const outside = { sessionId: OTHER, targets: [{ left: 0, top: 0, width: 0, height: 0 }] } describe('Session drag tracking', () => { it('publishes a dragged list Session that another on-screen Session can open', () => { @@ -64,7 +65,7 @@ describe('Session drag tracking', () => { expect(drags.source.getSnapshot()).toEqual(outside) }) - it('starts the target at the right edge of the frame column the row left', () => { + it('measures the on-screen Sidebar: its docked panes while open, else the area it would open in', () => { const frame = document.createElement('div') const column = document.createElement('nav') const row = document.createElement('div') @@ -73,8 +74,10 @@ describe('Session drag tracking', () => { column.append(row) frame.append(column, overlay) document.body.append(frame) - column.getBoundingClientRect = () => ({ right: 279.6 }) as DOMRect - // The on-screen Session's right Sidebar panel sets the target's width; another Session's is ignored. + column.getBoundingClientRect = () => ({ right: 279.6, top: 0 }) as DOMRect + const width = vi.spyOn(document.documentElement, 'clientWidth', 'get').mockReturnValue(1440) + const height = vi.spyOn(document.documentElement, 'clientHeight', 'get').mockReturnValue(800) + // Another Session's panel is ignored. const panel = document.createElement('div') panel.setAttribute('data-sidebar-right-panel', 'push') panel.setAttribute('data-sidebar-right-session', MAIN) @@ -85,13 +88,47 @@ describe('Session drag tracking', () => { otherPanel.getBoundingClientRect = () => ({ width: 900 }) as DOMRect frame.append(otherPanel, panel) const drags = trackSessionDrags(document, () => MAIN) + // Collapsed: the area the Sidebar would open in, never left of the navigation column. dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }, row) - expect(drags.source.getSnapshot()).toEqual({ sessionId: OTHER, inset: 280, width: 520 }) - // A drag whose target is not an element starts at the window edge. + expect(drags.source.getSnapshot()).toEqual({ sessionId: OTHER, targets: [{ left: 920, top: 0, width: 520, height: 800 }] }) dispatchDrag('dragend') + panel.getBoundingClientRect = () => ({ width: 1300 }) as DOMRect + dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }, row) + expect(drags.source.getSnapshot()).toEqual({ sessionId: OTHER, targets: [{ left: 280, top: 0, width: 1160, height: 800 }] }) + dispatchDrag('dragend') + + // Open: one target per visible docked pane, so the divider between panes and the chat area stay uncovered. + panel.setAttribute('data-sidebar-right-open', '') + const pane = (id: string, rect: Partial): HTMLElement => { + const element = document.createElement('section') + element.setAttribute('data-dockkit-pane', id) + element.getBoundingClientRect = () => rect as DOMRect + panel.append(element) + return element + } + const left = pane('p1', { left: 920.4, top: 0, width: 259.5, height: 800 }) + pane('p2', { left: 1181, top: 0, width: 259, height: 800 }) + pane('hidden', { left: 0, top: 0, width: 0, height: 0 }) + dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }, row) + expect(drags.source.getSnapshot()).toEqual({ sessionId: OTHER, targets: [ + { paneId: 'p1', left: 920, top: 0, width: 260, height: 800 }, + { paneId: 'p2', left: 1181, top: 0, width: 259, height: 800 }, + ] }) + dispatchDrag('dragend') + // An open panel without a measured pane falls back to the panel area. + for (const element of panel.querySelectorAll('[data-dockkit-pane]')) element.remove() + left.remove() + dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }, row) + expect(drags.source.getSnapshot()).toEqual({ sessionId: OTHER, targets: [{ left: 280, top: 0, width: 1160, height: 800 }] }) + dispatchDrag('dragend') + // A drag whose target is not an element starts at the window edge. + panel.remove() + otherPanel.remove() dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }, document) - expect(drags.source.getSnapshot()).toEqual({ ...outside, width: 520 }) + expect(drags.source.getSnapshot()).toEqual({ sessionId: OTHER, targets: [{ left: 0, top: 0, width: 1440, height: 800 }] }) drags.dispose() + width.mockRestore() + height.mockRestore() frame.remove() }) }) @@ -101,7 +138,12 @@ describe('Session drop zone', () => { let current = initial const openAside = vi.fn() const source: HostObservable = { - getSnapshot: () => current === undefined ? undefined : { sessionId: current, inset: 280, width: current === OTHER ? 516 : 0 }, + getSnapshot: () => current === undefined ? undefined : { + sessionId: current, + targets: current === OTHER + ? [{ left: 924, top: 0, width: 516, height: 800 }] + : [{ paneId: 'p1' as PaneId, left: 920, top: 0, width: 260, height: 800 }, { paneId: 'p2' as PaneId, left: 1181, top: 0, width: 259, height: 800 }], + }, subscribe: () => () => {}, } const props = { @@ -136,9 +178,7 @@ describe('Session drop zone', () => { // The zone portals to the body so it stacks above the narrow-window drawer mask. const zone = document.querySelector('[data-session-drop-zone]')! expect(zone.parentElement).toBe(document.body) - // The target is as wide as the Sidebar would open, and never reaches left of the navigation column. - expect(zone.style.getPropertyValue('--session-drop-inset')).toBe('280px') - expect(zone.style.getPropertyValue('--session-drop-width')).toBe('516px') + expect([zone.style.left, zone.style.top, zone.style.width, zone.style.height]).toEqual(['924px', '0px', '516px', '800px']) expect(view.container.innerHTML).toBe('') expect(zone.hasAttribute('data-active')).toBe(false) @@ -160,12 +200,15 @@ describe('Session drop zone', () => { document.removeEventListener('drop', documentDrop) expect(drop.event.defaultPrevented).toBe(true) expect(documentDrop).not.toHaveBeenCalled() - expect(view.openAside).toHaveBeenCalledExactlyOnceWith(OTHER) + expect(view.openAside).toHaveBeenCalledExactlyOnceWith(OTHER, undefined) expect(zone.hasAttribute('data-active')).toBe(false) - // Without a known Sidebar width the target spans the window right of the navigation column. + // A split Sidebar shows one target per pane, and a drop opens the Session in that pane. view.set(MAIN) - expect(document.querySelector('[data-session-drop-zone]')!.style.getPropertyValue('--session-drop-width')).toBe('') + const panes = document.querySelectorAll('[data-session-drop-zone]') + expect([...panes].map(element => element.dataset.sessionDropZone)).toEqual(['p1', 'p2']) + fire(panes[1]!, 'drop') + expect(view.openAside).toHaveBeenLastCalledWith(MAIN, 'p2') view.set(undefined) expect(document.querySelector('[data-session-drop-zone]')).toBeNull() 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 3a1a136ec4..f0e348f616 100644 --- a/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx +++ b/packages/client/ui-subagent/tests/sidebar-chat.client.spec.tsx @@ -143,14 +143,16 @@ describe('Sidebar chat registration', () => { ]) // A dropped root Session opens in the on-screen Session's Sidebar column. const drop = registrations[2]?.options.inject as () => { - hooks: { sessionDrag: { getSnapshot: () => { sessionId: SessionId; inset: number; width: number } | undefined } } - openAside: (sessionId: SessionId) => void + hooks: { sessionDrag: { getSnapshot: () => { sessionId: SessionId } | undefined } } + openAside: (sessionId: SessionId, paneId?: string) => void } drop().openAside(CHILD) expect(openResource).toHaveBeenCalledWith(sessionChatAddress(CHILD), { kind: 'subagentchat', destination: 'sidebar' }) + drop().openAside(CHILD, 'pane-2') + expect(openResource).toHaveBeenLastCalledWith(sessionChatAddress(CHILD), { kind: 'subagentchat', paneId: 'pane-2' }) onScreen = undefined drop().openAside(CHILD) - expect(openResource).toHaveBeenCalledOnce() + expect(openResource).toHaveBeenCalledTimes(2) onScreen = PARENT // The tracker compares the dragged row with the Sidebar's on-screen Session and stops listening on disposal. const dragStart = (): void => { @@ -159,7 +161,7 @@ describe('Sidebar chat registration', () => { document.body.dispatchEvent(event) } dragStart() - expect(drop().hooks.sessionDrag.getSnapshot()).toEqual({ sessionId: CHILD, inset: 0, width: 0 }) + expect(drop().hooks.sessionDrag.getSnapshot()?.sessionId).toBe(CHILD) document.body.dispatchEvent(new Event('dragend', { bubbles: true })) for (const dispose of disposers) dispose() dragStart() From 28a4dc72a16eb6e6f210618621e9c74275b9be13 Mon Sep 17 00:00:00 2001 From: Turtle Date: Fri, 20 Nov 2026 15:47:10 +0800 Subject: [PATCH 10/11] chore(web): regenerate the client slot catalog Co-authored-by: liukx0205 <69756503+liukx0205@users.noreply.github.com> Co-authored-by: Yifffan <133629972+Yifffan@users.noreply.github.com> --- .../extensions/cordis-client-runner/src/client/slot-catalog.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2b5e7cc6cd..642ad176e8 100644 --- a/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts +++ b/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts @@ -4972,7 +4972,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.chat.conversation\', () => ctx.slots.register(\n { name: \'sidebar.chat.conversation\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}', - source: 'packages/client/ui-subagent/src/client/sidebar-chat/index.tsx:43', + source: 'packages/client/ui-subagent/src/client/sidebar-chat/index.tsx:45', }, { key: 'sidebar.footer.action', From f6c1be6c6318bd09c09200d3909326d0c942827a Mon Sep 17 00:00:00 2001 From: Turtle Date: Fri, 20 Nov 2026 17:58:28 +0800 Subject: [PATCH 11/11] fix(web): keep sidebar borders visible and quiet idle pane targets Co-authored-by: liukx0205 <69756503+liukx0205@users.noreply.github.com> Co-authored-by: Yifffan <133629972+Yifffan@users.noreply.github.com> --- packages/client/ui-subagent/README.i18n.yaml | 4 +-- packages/client/ui-subagent/README.md | 2 +- packages/client/ui-subagent/README.zh.md | 2 +- .../sidebar-chat/SessionDropZone.module.css | 32 +++++++++++-------- .../client/sidebar-chat/SessionDropZone.tsx | 7 ++-- .../tests/session-drop.client.spec.tsx | 3 ++ 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/packages/client/ui-subagent/README.i18n.yaml b/packages/client/ui-subagent/README.i18n.yaml index ff802b4bf9..6fc2584f08 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: 1db14b45b7b0676f - zh: bc0d093b3fc49620 + en: f84d90b7cbf653e5 + zh: e49313ff82710c2f /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 7c1ab7931d..3148c77be9 100644 --- a/packages/client/ui-subagent/README.md +++ b/packages/client/ui-subagent/README.md @@ -29,7 +29,7 @@ The session header uses the session title for ordinary breadcrumbs. Subagent bre 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. -Dragging a root Session row from the Session list shows a drop target while another Session is on screen. While the right Sidebar is open, one target covers each docked pane, leaving the panes' divider and the chat area visible, and a drop opens the Session in that pane. While it is collapsed, one target covers the area the Sidebar would open in, never left of the navigation column or narrow-window drawer that the row left, or that whole area right of the column when the Sidebar cannot fit. Each target's card has an 8px inset on every side, and targets stack above the drawer's mask. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/`, an address without a query, in the on-screen Session's Sidebar, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title. +Dragging a root Session row from the Session list shows a drop target while another Session is on screen. While the right Sidebar is open, one target covers each docked pane, leaving the panes' divider and the chat area visible, and a drop opens the Session in that pane. While it is collapsed, one target covers the area the Sidebar would open in, never left of the navigation column or narrow-window drawer that the row left, or that whole area right of the column when the Sidebar cannot fit. Each target draws only its card, 8px in from every side, so the Sidebar's left border and the divider between panes stay visible; with several panes, only the target under the pointer shows its card. Targets stack above the drawer's mask. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/`, an address without a query, in the on-screen Session's Sidebar, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title. 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 d3d7e12510..dfe63ced3c 100644 --- a/packages/client/ui-subagent/README.zh.md +++ b/packages/client/ui-subagent/README.zh.md @@ -29,7 +29,7 @@ kind: "package-reference" 本包注册 `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,并把草稿移过去。 -从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,会显示放置目标。右侧侧边栏打开时,每个分栏各由一个放置目标覆盖,分栏之间的分割线和聊天区域保持可见;在某个分栏上放下时,会在该分栏中打开该 Session。侧边栏收起时,一个放置目标覆盖侧边栏打开时所占的区域,且始终位于该行被拖出的导航栏或窄窗口抽屉的右侧;侧边栏放不下时,该放置目标覆盖该栏右侧的整个区域。每个放置目标的卡片四边均内缩 8px,放置目标显示在抽屉遮罩之上。在此放下后,会在屏幕上那个 Session 的 Sidebar 中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 Session 的显示标题。 +从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,会显示放置目标。右侧侧边栏打开时,每个分栏各由一个放置目标覆盖,分栏之间的分割线和聊天区域保持可见;在某个分栏上放下时,会在该分栏中打开该 Session。侧边栏收起时,一个放置目标覆盖侧边栏打开时所占的区域,且始终位于该行被拖出的导航栏或窄窗口抽屉的右侧;侧边栏放不下时,该放置目标覆盖该栏右侧的整个区域。每个放置目标只绘制其卡片,卡片四边各内缩 8px,因此侧边栏的左边框和分栏之间的分割线保持可见;有多个分栏时,只有指针下方的放置目标显示其卡片。放置目标显示在抽屉遮罩之上。在此放下后,会在屏幕上那个 Session 的 Sidebar 中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 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/SessionDropZone.module.css b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css index 4f3e0c1419..d51272b3fa 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css +++ b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.module.css @@ -1,10 +1,11 @@ -/* One drop target covers each docked pane of the open right Sidebar, leaving - the Sidebar's divider and the chat area visible, or the area a collapsed - Sidebar would open in (rectangles set inline). Each draws the dock kit's - drop hint with an 8px inset on every side: a blurred ground under a dashed - card that takes the accent while the pointer is over it. Targets stack - above the narrow-window drawer (71) and its mask (70), below menus and - toasts. */ +/* One drop target covers each docked pane of the open right Sidebar, or the + area a collapsed Sidebar would open in (rectangles set inline). The target + itself paints nothing, so the pane's own left border and the divider between + panes stay visible; its card, 8px in from every side, carries the dock kit's + drop hint: a blurred ground under a dashed frame that takes the accent while + the pointer is over it. With several targets, only the one under the pointer + shows its card. Targets stack above the narrow-window drawer (71) and its + mask (70), below menus and toasts. */ .zone { position: fixed; z-index: 72; @@ -12,9 +13,6 @@ display: flex; padding: 8px; pointer-events: auto; - background: color-mix(in srgb, var(--dsw-alias-bg-base) 72%, transparent); - backdrop-filter: blur(6px); - animation: zoneIn 140ms ease-out; } .card { @@ -30,12 +28,21 @@ color: var(--dsw-alias-label-tertiary); border: 1.5px dashed var(--dsw-alias-border-l2); border-radius: var(--dsw-radius-lg); + background: color-mix(in srgb, var(--dsw-alias-bg-base) 72%, transparent); + backdrop-filter: blur(6px); transition: color 120ms ease-out, background-color 120ms ease-out, border-color 120ms ease-out; + animation: zoneIn 140ms ease-out; +} + +.zone[data-quiet]:not([data-active]) .card { + visibility: hidden; } .zone[data-active] .card { color: var(--dsw-alias-label-secondary); - background: color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color) 8%, transparent); + background: + linear-gradient(color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color) 8%, transparent)), + color-mix(in srgb, var(--dsw-alias-bg-base) 72%, transparent); border-color: var(--dsw-alias-brand-primary-new-colorprimary-new-color); } @@ -63,6 +70,5 @@ } @media (prefers-reduced-motion: reduce) { - .zone { animation: none; } - .card { transition: none; } + .card { transition: none; animation: none; } } diff --git a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx index 02fe595e0b..8551830c67 100644 --- a/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx +++ b/packages/client/ui-subagent/src/client/sidebar-chat/SessionDropZone.tsx @@ -55,7 +55,7 @@ export function SessionDropZone({ useSessionDrag, openAside, t }: SessionDropZon return createPortal( <> {targets.map(target => ( - 1} label={t('open.sidebar')} onDrop={() => { openAside(sessionId, target.paneId) }} /> ))} , @@ -63,8 +63,10 @@ export function SessionDropZone({ useSessionDrag, openAside, t }: SessionDropZon ) } -function DropTarget({ target, label, onDrop }: { +function DropTarget({ target, quiet, label, onDrop }: { readonly target: SessionDropTarget + /** Show the card only while the pointer is over this target, because another target shares the drag. */ + readonly quiet: boolean readonly label: string readonly onDrop: () => void }) { @@ -83,6 +85,7 @@ function DropTarget({ target, label, onDrop }: { style={{ left: target.left, top: target.top, width: target.width, height: target.height }} data-session-drop-zone={target.paneId ?? ''} data-active={over || undefined} + data-quiet={quiet || undefined} onDragEnter={accept} onDragOver={accept} onDragLeave={(event) => { diff --git a/packages/client/ui-subagent/tests/session-drop.client.spec.tsx b/packages/client/ui-subagent/tests/session-drop.client.spec.tsx index 74352d4b72..6f44435425 100644 --- a/packages/client/ui-subagent/tests/session-drop.client.spec.tsx +++ b/packages/client/ui-subagent/tests/session-drop.client.spec.tsx @@ -207,6 +207,9 @@ describe('Session drop zone', () => { view.set(MAIN) const panes = document.querySelectorAll('[data-session-drop-zone]') expect([...panes].map(element => element.dataset.sessionDropZone)).toEqual(['p1', 'p2']) + // With several panes, each target keeps its card hidden until the pointer is over it. + expect([...panes].every(element => element.hasAttribute('data-quiet'))).toBe(true) + expect(zone.hasAttribute('data-quiet')).toBe(false) fire(panes[1]!, 'drop') expect(view.openAside).toHaveBeenLastCalledWith(MAIN, 'p2')