Sidebar session list grows the figma 239-10458 feature set and the
workspace/session browsing region moves wholesale into ui-workspace:
- Group-by menu (WorkSpace / In one list): flat mode lists every session
top-level, strictly newest-first; the choice persists across reloads.
- Session rows get a 500ms hover detail card (title / relative time /
status line) and a ... menu (Rename / Fork session / Delete session,
visual-only for now); workspace headers get ... with Rename (wired) and
Delete workspace (visual-only).
- workspace.rename RPC: trims, rejects duplicate titles on the create
chain (workspace-name-conflict), no-op on same title; modal dialog with
client-side duplicate pre-check.
- workspace.insertSessionBefore RPC (DOM-insertBefore semantics, omitted
anchor appends): HTML5 drag reorder of root sessions inside a workspace
group; order truth stays host-side, the view refreshes from the
response/changed frame.
- Activity pinning removed: the session/event touchSession chain is gone;
workspace accounts are manually owned (new sessions prepend, explicit
reordering only). Contracts and tests updated, api catalog regenerated.
- ui-sidebar reduced to the column shell (brand, fold state machine, New
Session, Settings) exposing one sidebar.workspaces hole with a two-fact
owner share {wide, expandSidebar}; ui-workspace owns the whole region
(header, search, grouped/flat lists, dialogs, drag) plus the picker via
a shared WorkspaceCreateFlow. The old sidebar.workspace picker slot and
its deferral indirection are gone.
- ui-primitives: Menu gains label entries, danger rows, and
closeOnPointerLeave; new HoverCard (portaled, open-delay, disabled
guard). Hover card and row menu never coexist.
84 lines
4.0 KiB
TypeScript
84 lines
4.0 KiB
TypeScript
import { Context } from 'cordis'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
import { SlotsService } from '@deepseek-ai/dsh-client-runtime/client'
|
|
import { apply, inject } from '@deepseek-ai/dsh-client-ui-workspace/client'
|
|
import type { WorkspaceBrowserInjected, WorkspacePickerInjected } from '@deepseek-ai/dsh-client-ui-workspace/client'
|
|
import { WorkspaceBrowser } from '../src/client/WorkspaceBrowser.tsx'
|
|
import { WorkspacePicker } from '../src/client/WorkspacePicker.tsx'
|
|
|
|
async function bench() {
|
|
const ctx = new Context()
|
|
await ctx.plugin(SlotsService).await()
|
|
const create = vi.fn(async (input: { name: string } | { path: string }) => ({
|
|
workspaceId: 'ws-new' as never,
|
|
path: 'name' in input ? `/projects/${input.name}` : input.path,
|
|
title: 'new', sessionIds: [], createdAt: '0', updatedAt: '0',
|
|
}))
|
|
const startSession = vi.fn()
|
|
const rename = vi.fn(async () => ({}))
|
|
const insertSessionBefore = vi.fn(async () => ({}))
|
|
const open = vi.fn()
|
|
ctx.provide('workspaces', { create, startSession, rename, insertSessionBefore } as never)
|
|
ctx.provide('sessions', { open } as never)
|
|
return { ctx, slots: ctx.get('slots') as SlotsService, create, startSession, rename, insertSessionBefore, open }
|
|
}
|
|
|
|
type HoleName = 'sidebar.workspaces' | 'conversation.empty.workspace'
|
|
|
|
/** Declare one or both holes with a single root registration ('root' is a single slot). */
|
|
function declare(slots: SlotsService, ...names: HoleName[]): () => void {
|
|
const children = Object.fromEntries(names.map(name => [name, { kind: 'single', scope: 'root' }]))
|
|
return slots.register({ name: 'root', children } as never, () => null)
|
|
}
|
|
|
|
describe('ui-workspace apply', () => {
|
|
it('declares the services it drives', () => {
|
|
expect(inject).toEqual(['slots', 'sessions', 'workspaces'])
|
|
})
|
|
|
|
it('registers browser and picker for declarations arriving before or after apply', async () => {
|
|
const before = await bench()
|
|
declare(before.slots, 'sidebar.workspaces')
|
|
await before.ctx.plugin({ inject: [...inject], apply }).await()
|
|
expect(before.slots.entries('sidebar.workspaces')[0]!.component).toBe(WorkspaceBrowser)
|
|
|
|
const after = await bench()
|
|
await after.ctx.plugin({ inject: [...inject], apply }).await()
|
|
declare(after.slots, 'conversation.empty.workspace')
|
|
await Promise.resolve()
|
|
expect(after.slots.entries('conversation.empty.workspace')[0]!.component).toBe(WorkspacePicker)
|
|
})
|
|
|
|
it('routes browser actions and picker creation to the services', async () => {
|
|
const b = await bench()
|
|
declare(b.slots, 'sidebar.workspaces', 'conversation.empty.workspace')
|
|
await b.ctx.plugin({ inject: [...inject], apply }).await()
|
|
|
|
const browser = (b.slots.entries('sidebar.workspaces')[0]!.inject as () => WorkspaceBrowserInjected)()
|
|
browser.startSession('ws' as never, 'prompt')
|
|
expect(b.startSession).toHaveBeenCalledWith('ws', 'prompt')
|
|
browser.open('session' as never)
|
|
expect(b.open).toHaveBeenCalledWith('session')
|
|
await browser.renameWorkspace('ws' as never, 'renamed')
|
|
expect(b.rename).toHaveBeenCalledWith('ws', 'renamed')
|
|
await browser.insertSessionBefore('ws' as never, 's1' as never, 's2' as never)
|
|
expect(b.insertSessionBefore).toHaveBeenCalledWith('ws', 's1', 's2')
|
|
await browser.createWorkspace({ name: 'project' })
|
|
expect(b.create).toHaveBeenCalledWith({ name: 'project' })
|
|
|
|
const picker = (b.slots.entries('conversation.empty.workspace')[0]!.inject as () => WorkspacePickerInjected)()
|
|
await picker.createWorkspace({ path: '/tmp/project' })
|
|
expect(b.create).toHaveBeenCalledWith({ path: '/tmp/project' })
|
|
})
|
|
|
|
it('unregisters both entries on teardown', async () => {
|
|
const b = await bench()
|
|
declare(b.slots, 'sidebar.workspaces', 'conversation.empty.workspace')
|
|
const fiber = b.ctx.plugin({ inject: [...inject], apply })
|
|
await fiber.await()
|
|
await fiber.dispose()
|
|
expect(b.slots.entries('sidebar.workspaces')).toHaveLength(0)
|
|
expect(b.slots.entries('conversation.empty.workspace')).toHaveLength(0)
|
|
})
|
|
})
|