Merge pull request #8875 from deepseek-harness/turtle/drag-session-to-rail-39796288b5d4

feat(web): open a dragged Session in the right sidebar
This commit is contained in:
Turtle authored and GitHub committed 2026-11-20 18:22:37 +08:00
commit 34c375c78d
20 files changed
+767 -84

No files matched your search

+2 -2
View File
@@ -15,8 +15,8 @@
en: d152484eb41ac6b4
zh: 09388d293f9be9cb
/deepseek-ai-dsh-client-ui-subagent/use-this-package:
en: e912edfd1406cc33
zh: da0a59a27fb4a65c
en: f84d90b7cbf653e5
zh: e49313ff82710c2f
/deepseek-ai-dsh-client-ui-subagent/use-this-package/browsing-the-tree:
en: da87d582146106c4
zh: f640b3a3fcc11209
+2
View File
@@ -29,6 +29,8 @@ The session header uses the session title for ordinary breadcrumbs. Subagent bre
This package registers the `dsh-resource://subagentchat/session/<child>?parent=<parent>&mode=<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 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/<id>`, 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.
Breadcrumb switcher menus show navigation only.
+2
View File
@@ -29,6 +29,8 @@ kind: "package-reference"
本包注册 `dsh-resource://subagentchat/session/<child>?parent=<parent>&mode=<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/<id>`(不带查询参数的地址);如果已有 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 内边距内,轨道两端内缩,并保留稳定的滚动条空间,使内容在需要滚动时保持原有宽度。其他浏览器保留标准原生滚动条。
面包屑切换器菜单只显示导航。
@@ -0,0 +1,74 @@
/* 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;
box-sizing: border-box;
display: flex;
padding: 8px;
pointer-events: auto;
}
.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);
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:
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);
}
/* 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) {
.card { transition: none; animation: none; }
}
@@ -0,0 +1,107 @@
/** 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'
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'
/** 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
readonly targets: readonly SessionDropTarget[]
}
/** 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<SessionDrag | undefined>
}
/** 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. */
export type SessionDropZoneProps =
PropsRuntime<'shell.overlay'> & PropsLocale<typeof NS> & InjectFace<SessionDropZoneInjected>
/**
* 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, targets } = drag
// A body portal stacks above the narrow-window drawer mask, which covers the frame's overlay layer.
return createPortal(
<>
{targets.map(target => (
<DropTarget key={`${sessionId}:${target.paneId ?? ''}`} target={target} quiet={targets.length > 1} label={t('open.sidebar')}
onDrop={() => { openAside(sessionId, target.paneId) }} />
))}
</>,
document.body,
)
}
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
}) {
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<HTMLDivElement>): void => {
event.preventDefault()
event.stopPropagation()
event.dataTransfer.dropEffect = 'copy'
setOver(true)
}
return (
<div
className={css.zone}
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) => {
if (!(event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget))) setOver(false)
}}
onDrop={(event) => {
event.preventDefault()
event.stopPropagation()
setOver(false)
onDrop()
}}
>
<div className={css.card}>
<IconPanelLeftOutlineRegular className={css.icon} aria-hidden="true" />
<span className={css.label}>{label}</span>
</div>
</div>
)
}
@@ -1,18 +1,21 @@
/** 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 { PaneId, 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 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'
@@ -22,7 +25,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 +59,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 +84,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<void> {
@@ -117,6 +128,101 @@ function subagentChatResourceProvider(sessions: ISessions): ResourceProvider<'su
}
}
/**
* Find the frame column holding a dragged row: the frame's child that is a sibling of its overlay layer.
* @param node - drag source.
* @returns the left navigation column, or undefined outside the frame.
*/
function frameColumnOf(node: Element): Element | undefined {
for (let element = node, parent = node.parentElement; parent !== null; element = parent, parent = parent.parentElement) {
if (parent.querySelector(':scope > [data-shell-overlay]') !== null) return element
}
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 its drop targets, and the listener disposer.
*/
export function trackSessionDrags(doc: Document, mounted: () => SessionId | undefined): {
readonly source: HostObservable<SessionDrag | undefined>
readonly dispose: () => void
} {
let current: SessionDrag | undefined
const listeners = new Set<() => void>()
const publish = (next: SessionDrag | 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()
if (id === undefined || id === '' || onScreen === undefined || onScreen === id) {
publish(undefined)
return
}
const column = event.target instanceof Element ? frameColumnOf(event.target) : undefined
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
// 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 +294,11 @@ export function registerSidebarChat(ctx: Context, t: TranslateNS<typeof NS>): 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 +312,26 @@ export function registerSidebarChat(ctx: Context, t: TranslateNS<typeof NS>): 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, paneId) => {
// The on-screen Session can leave between dragstart and drop.
if (ctx.sidebarRight.mounted.getSnapshot() === undefined) return
ctx.sidebarRight.openResource(sessionChatAddress(sessionId), paneId === undefined
? { kind: 'subagentchat', destination: 'sidebar' }
: { kind: 'subagentchat', paneId })
},
}
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')
}
@@ -0,0 +1,219 @@
// @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 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'
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<string, string> = {}, target: EventTarget = document.body): void {
const event = new Event(type, { bubbles: true })
Object.defineProperty(event, 'dataTransfer', { value: { getData: (format: string) => data[format] ?? '' } })
target.dispatchEvent(event)
}
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', () => {
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()).toEqual(outside)
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()).toEqual(outside)
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()).toEqual(outside)
})
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')
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, 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)
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)
// 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, 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<DOMRect>): 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({ sessionId: OTHER, targets: [{ left: 0, top: 0, width: 1440, height: 800 }] })
drags.dispose()
width.mockRestore()
height.mockRestore()
frame.remove()
})
})
describe('Session drop zone', () => {
function mount(initial: SessionId | undefined) {
let current = initial
const openAside = vi.fn()
const source: HostObservable<SessionDrag | undefined> = {
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 = {
useSessionDrag: <T,>(select: (value: SessionDrag | undefined) => T) => select(source.getSnapshot()),
openAside,
t: (key: string) => key === 'open.sidebar' ? 'Open in sidebar' : key,
} as Partial<SessionDropZoneProps> as SessionDropZoneProps
const view = render(<SessionDropZone {...props} />)
return {
...view,
openAside,
set: (next: SessionId | undefined) => {
current = next
view.rerender(<SessionDropZone {...props} />)
},
}
}
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(document.querySelector('[data-session-drop-zone]')).toBeNull()
view.set(OTHER)
const label = screen.getByText('Open in sidebar')
// The zone portals to the body so it stacks above the narrow-window drawer mask.
const zone = document.querySelector<HTMLElement>('[data-session-drop-zone]')!
expect(zone.parentElement).toBe(document.body)
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)
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, undefined)
expect(zone.hasAttribute('data-active')).toBe(false)
// A split Sidebar shows one target per pane, and a drop opens the Session in that pane.
view.set(MAIN)
const panes = document.querySelectorAll<HTMLElement>('[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')
view.set(undefined)
expect(document.querySelector('[data-session-drop-zone]')).toBeNull()
})
})
@@ -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()
})
@@ -85,6 +92,7 @@ describe('Sidebar chat registration', () => {
let provider: ResourceProvider<'subagentchat'> | undefined
let definition: SidebarRightTabDefinition | undefined
const registrations: { options: Record<string, unknown>; component: unknown }[] = []
const disposers: (() => void)[] = []
const openWorkspace = vi.fn(() => Promise.resolve())
const ctx = {
sessions: { retain, refreshProjections, list } as unknown as ISessions,
@@ -99,8 +107,26 @@ describe('Sidebar chat registration', () => {
},
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: {} } } }
}
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 } },
effect: (install: () => (() => void) | undefined) => {
const dispose = install()
if (dispose !== undefined) disposers.push(dispose)
return () => {}
},
}),
(key: string) => key === 'sidebar.chat' ? 'Chat' : key,
)
expect(definition?.id).toBe(SUBAGENT_CHAT_ID)
expect(definition?.kind).toBe('subagentchat')
@@ -108,11 +134,38 @@ 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: 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).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 => {
const event = new Event('dragstart', { bubbles: true })
Object.defineProperty(event, 'dataTransfer', { value: { getData: () => CHILD } })
document.body.dispatchEvent(event)
}
dragStart()
expect(drop().hooks.sessionDrag.getSnapshot()?.sessionId).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<void> } }
@@ -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
+3 -1
View File
@@ -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.
+3 -1
View File
@@ -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 非正常退出后可能落后于其日志。
@@ -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]
@@ -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,
@@ -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<HTMLDivElement>(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) => {
@@ -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
},
@@ -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', () => {
? <ProjectRowItem group={{
key: 'workspace', workspaceId: wid('workspace'), cwd: '/workspace', createdAt: 0,
label: 'Draggable row', sessionCount: 0, expanded: true, containsCurrent: false, sessions: [],
}} onToggle={vi.fn()} onCreate={vi.fn()} drag={drag} t={t} />
}} onToggle={vi.fn()} onCreate={vi.fn()} drag={{ start: drag.start, end: () => { drag.end(false) } }} t={t} />
: <SessionNodeItem node={{
id: sid('session'), title: 'Draggable row', blank: false, running: false,
runningSubagentCount: 0, completed: false, failed: false, updatedAt: 0, pinned: false, archived: false,
@@ -196,11 +201,11 @@ describe('native row drag previews', () => {
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()
})
@@ -88,6 +88,11 @@ function hook<T>(snapshot: T) {
return function select<S>(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,40 @@ 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]
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')
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 = rect
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 +2789,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 +2803,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 +2814,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 +2857,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'))
})
@@ -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<HTMLElement>('[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
@@ -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<HTMLElement>('[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.
@@ -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',
@@ -4823,6 +4823,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\'',
@@ -5021,7 +5022,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:45',
},
{
key: 'sidebar.footer.action',
@@ -6018,7 +6019,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',
@@ -6074,7 +6075,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',
@@ -6129,7 +6130,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',
@@ -6264,7 +6265,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',
@@ -6317,7 +6318,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',
@@ -6373,7 +6374,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',
@@ -6628,7 +6629,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',