feat(web): add plan mode controls
This commit is contained in:
@@ -14,6 +14,7 @@ const PLUGINS: readonly (WebBootEntry & { dir: string })[] = [
|
||||
{ id: '@deepseek-ai/dsh-client-ui-layout', dir: 'ui-layout', url: '/plugins/ui-layout.js', rev: 'fx', inject: ['@deepseek-ai/dsh-client-runtime'] },
|
||||
{ id: '@deepseek-ai/dsh-client-ui-sidebar', dir: 'ui-sidebar', url: '/plugins/ui-sidebar.js', rev: 'fx', inject: ['@deepseek-ai/dsh-client-ui-layout'] },
|
||||
{ id: '@deepseek-ai/dsh-client-ui-conversation', dir: 'ui-conversation', url: '/plugins/ui-conversation.js', rev: 'fx', inject: ['@deepseek-ai/dsh-client-ui-layout'] },
|
||||
{ id: '@deepseek-ai/dsh-client-ui-plan', dir: 'ui-plan', url: '/plugins/ui-plan.js', rev: 'fx', inject: ['@deepseek-ai/dsh-client-ui-conversation'] },
|
||||
{ id: '@deepseek-ai/dsh-client-ui-trajectory', dir: 'ui-trajectory', url: '/plugins/ui-trajectory.js', rev: 'fx', inject: ['@deepseek-ai/dsh-client-ui-conversation'] },
|
||||
]
|
||||
|
||||
@@ -77,7 +78,8 @@ function titleSurfaces(label: string): { sidebar: string; breadcrumb: string; do
|
||||
return { sidebar, breadcrumb, documentTitle: document.title }
|
||||
}
|
||||
|
||||
it('projects initial and revised durable titles through the built eight-plugin fixture app', async () => {
|
||||
/** Boot the built fixture graph into the per-test root. */
|
||||
function bootFixtureApp(): void {
|
||||
const root = document.querySelector<HTMLElement>('#root')
|
||||
if (root === null) throw new Error('snapshot root missing')
|
||||
act(() => {
|
||||
@@ -89,7 +91,10 @@ it('projects initial and revised durable titles through the built eight-plugin f
|
||||
executeBundle: (code) => { (0, eval)(code) },
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
it('projects initial and revised durable titles through the built nine-plugin fixture app', async () => {
|
||||
bootFixtureApp()
|
||||
const projectLabel = await screen.findByText('fixture', {}, { timeout: 10_000 })
|
||||
const projectRow = projectLabel.closest<HTMLElement>('[role="treeitem"]')
|
||||
if (projectRow === null) throw new Error('fixture project row missing')
|
||||
@@ -112,3 +117,53 @@ it('projects initial and revised durable titles through the built eight-plugin f
|
||||
await expect(`${JSON.stringify({ initial, revised }, null, 2)}\n`)
|
||||
.toMatchFileSnapshot('./snapshots/session-title.json')
|
||||
})
|
||||
|
||||
it('snapshots pending and committed plan targets without implicit turn cancellation', async () => {
|
||||
bootFixtureApp()
|
||||
await screen.findByText('fixture', {}, { timeout: 10_000 })
|
||||
fireEvent.click(screen.getByRole('button', { name: 'New session' }))
|
||||
const select: HTMLSelectElement = await screen.findByRole('combobox', { name: '协作模式' }, { timeout: 10_000 })
|
||||
const capture = (stage: string) => {
|
||||
const chip = select.parentElement?.querySelector('span')?.textContent ?? ''
|
||||
return {
|
||||
stage,
|
||||
label: chip,
|
||||
value: select.value,
|
||||
title: select.parentElement?.getAttribute('title') ?? '',
|
||||
primary: screen.getByRole('button', { name: /^(发送|停止)$/ }).getAttribute('aria-label'),
|
||||
}
|
||||
}
|
||||
|
||||
const initial = capture('initial')
|
||||
fireEvent.change(select, { target: { value: 'plan' } })
|
||||
await screen.findByTitle(/计划模式将在下一次模型请求时生效/)
|
||||
const planPending = capture('plan-pending')
|
||||
|
||||
const input = screen.getByPlaceholderText(/输入消息/)
|
||||
fireEvent.change(input, { target: { value: 'commit plan' } })
|
||||
fireEvent.click(screen.getByRole('button', { name: '发送' }))
|
||||
await screen.findByTitle('当前为计划模式')
|
||||
const planCommitted = capture('plan-committed')
|
||||
|
||||
fireEvent.change(select, { target: { value: 'default' } })
|
||||
await screen.findByTitle(/默认模式将在下一次模型请求时生效/)
|
||||
const defaultPendingWhileRunning = capture('default-pending-running')
|
||||
fireEvent.click(screen.getByRole('button', { name: '停止' }))
|
||||
await waitFor(() => { expect(screen.getByRole('button', { name: '发送' })).toBeTruthy() })
|
||||
const defaultPendingAfterStop = capture('default-pending-stopped')
|
||||
|
||||
fireEvent.change(input, { target: { value: 'commit default' } })
|
||||
fireEvent.click(screen.getByRole('button', { name: '发送' }))
|
||||
await screen.findByTitle('当前为默认模式')
|
||||
const defaultCommitted = capture('default-committed')
|
||||
fireEvent.click(screen.getByRole('button', { name: '停止' }))
|
||||
|
||||
await expect(`${JSON.stringify({
|
||||
initial,
|
||||
planPending,
|
||||
planCommitted,
|
||||
defaultPendingWhileRunning,
|
||||
defaultPendingAfterStop,
|
||||
defaultCommitted,
|
||||
}, null, 2)}\n`).toMatchFileSnapshot('./snapshots/plan-mode.json')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user