Browser acceptance of the activity panel surfaced the product problem: a background bash registers in both planes, so the header grew two near- identical popovers — "background jobs" with lifecycle and duration, "activities" with live output — listing the same work twice. The service planes stay orthogonal (jobs: model-visible control with a consuming read cursor; activities: transient non-consuming observation). The join happens per row in the UI projection instead: - dsh-client-ui-activity renders the single merged "tasks" list. Each jobsBySession row joins the activity carrying its correlation.jobId — the job supplies identity, lifecycle (stopping exists only there), duration, and the model-visible detail; the activity supplies the expandable live-output panel. Standalone activities (workflow runs) keep their own rows; without the activity registry, job rows still render and the control degrades to the old job list exactly. - dsh-client-ui-jobs is deleted (pre-release, no shim); the merged entry takes its slot order. The job locale namespace folds into activity. - User-facing copy says "task" (任务): N tasks running / N 个任务进行中. - Hierarchy: live rows first as two lines (label over kind badge and status, ticking duration), a Finished divider when both sections exist, settled rows compacted to one de-emphasized line, and the output panel hangs behind a spine under its row. Deliberately not joined: subagent rows stay bare (the subagent panel is their surface) and foreground commands stay in tool cards. Both web e2e scenarios now assert one Tasks list; the background-job scenario's row gained a live-output panel, proving the join end to end. Agent Note: 2026-08-25-unified-task-list.
117 lines
4.9 KiB
TypeScript
117 lines
4.9 KiB
TypeScript
/**
|
|
* ui-activity plugin halves: the browser entry's dictionary and header-slot
|
|
* registrations against the real SlotRegistry (with fiber teardown proving
|
|
* removal — HMR safety), the inert node entry, and the invariant companion's
|
|
* ownership reservation.
|
|
*/
|
|
import { Context } from '@deepseek-ai/cordis'
|
|
import { describe, expect, it } from 'vitest'
|
|
import InvariantRegistry from '@deepseek-ai/dsh-invariants'
|
|
import { SlotRegistry } from '@deepseek-ai/dsh-client-ui-renderer/client'
|
|
import { stubSettingsScope } from '@deepseek-ai/dsh-client-test-runtime'
|
|
import { apply as applyLocale, inject as localeInject } from '@deepseek-ai/dsh-client-locale/client'
|
|
import { apply, inject } from '../src/client/index.ts'
|
|
import { apply as applyNode } from '../src/index.ts'
|
|
import * as ActivityInvariant from '../src/invariant.ts'
|
|
import { en, NS, zh } from '../src/client/locales.ts'
|
|
|
|
/** Slot ledger reader: entry ids currently registered in the header list. */
|
|
function headerEntryIds(ctx: Context): (string | undefined)[] {
|
|
return ctx.slots
|
|
.entries('conversation.session.header.actions')
|
|
.map(entry => entry.options.id)
|
|
}
|
|
|
|
/** Ids handed to the stubbed feed's observe control. */
|
|
const observed: string[] = []
|
|
|
|
/** Boot the browser half over a real slot tree that declares the header list. */
|
|
async function bench(): Promise<{ ctx: Context; fiber: ReturnType<Context['plugin']> }> {
|
|
const ctx = new Context()
|
|
await ctx.plugin(SlotRegistry).await()
|
|
ctx.slots.register({
|
|
name: 'root',
|
|
children: {
|
|
'conversation.session.header.actions': { kind: 'list', scope: 'session' },
|
|
},
|
|
} as never, () => null)
|
|
ctx.provide('sessions', {} as never)
|
|
ctx.provide('activityFeed', {
|
|
state: { getSnapshot: () => ({ rowsBySession: {}, observed: {}, phase: 'pending' }), subscribe: () => () => {} },
|
|
observe: (id: string) => { observed.push(id); return () => {} },
|
|
} as never)
|
|
// The locale plugin binds a settings scope, which reads the connection handle
|
|
// and the forwarded-event port.
|
|
ctx.provide('connection', { api: { settings: {} }, isLoopback: false } as never)
|
|
ctx.provide('remote', { $on: () => () => {} } as never)
|
|
ctx.provide('settingsScope', { bind: () => stubSettingsScope().scope } as never)
|
|
await ctx.plugin({ inject: localeInject, apply: applyLocale }).await()
|
|
// These specs assert the shipped Chinese copy. There is no jsdom `window` in
|
|
// this lane, so browser-language detection never runs and the locale comes
|
|
// from FALLBACK_LOCALE (en): state the asserted locale explicitly.
|
|
ctx.locale.setLocale('zh')
|
|
const fiber = ctx.plugin({ inject: [...inject], apply })
|
|
await fiber.await()
|
|
return { ctx, fiber }
|
|
}
|
|
|
|
describe('ui-activity browser half', () => {
|
|
it('declares the services it binds', () => {
|
|
expect(inject).toEqual(['sessions', 'activityFeed', 'slots', 'locale'])
|
|
})
|
|
|
|
it('exposes the feed source and observation control through the inject face', async () => {
|
|
const { ctx } = await bench()
|
|
const entry = ctx.slots
|
|
.entries('conversation.session.header.actions')
|
|
.find(candidate => candidate.options.id === 'activity-list')
|
|
const face = (entry as unknown as {
|
|
inject: () => { hooks: { activity: unknown }; observe: (id: string) => () => void }
|
|
}).inject()
|
|
expect(face.hooks.activity).toBeDefined()
|
|
const stopper = face.observe('bash-1')
|
|
expect(observed).toEqual(['bash-1'])
|
|
stopper()
|
|
})
|
|
|
|
it('registers the header action, and fiber teardown removes it (HMR safety)', async () => {
|
|
const { ctx, fiber } = await bench()
|
|
expect(headerEntryIds(ctx)).toContain('activity-list')
|
|
await fiber.dispose()
|
|
expect(headerEntryIds(ctx)).not.toContain('activity-list')
|
|
})
|
|
|
|
it('registers both dictionaries under its own namespace and releases them with the fiber', async () => {
|
|
const { ctx, fiber } = await bench()
|
|
const translate = ctx.locale.bind(NS)
|
|
expect(translate('list.aria')).toBe(zh['list.aria'])
|
|
ctx.locale.setLocale('en')
|
|
expect(translate('list.aria')).toBe(en['list.aria'])
|
|
|
|
// Withdrawn dictionaries leave the key unresolved rather than translated.
|
|
await fiber.dispose()
|
|
expect(translate('list.aria')).not.toBe(en['list.aria'])
|
|
})
|
|
|
|
it('keeps the English dictionary key-identical to the Chinese source of truth', () => {
|
|
expect(Object.keys(en).sort()).toEqual(Object.keys(zh).sort())
|
|
})
|
|
})
|
|
|
|
describe('ui-activity node half', () => {
|
|
it('contributes no host behavior', () => {
|
|
// The node half exists only so the plugin appears in the Loader tree.
|
|
expect(applyNode).not.toThrow()
|
|
})
|
|
})
|
|
|
|
describe('ui-activity invariant companion', () => {
|
|
it('reserves package ownership under its declared companion name', async () => {
|
|
const ctx = new Context()
|
|
await ctx.plugin(InvariantRegistry, { enabled: true })
|
|
await ctx.plugin(ActivityInvariant)
|
|
expect(ActivityInvariant.name).toBe('client-ui-activity-invariant')
|
|
expect(ActivityInvariant.inject).toEqual(['invariants'])
|
|
})
|
|
})
|