mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
Both Workspace surfaces offered "Open local folder…" and "Create a new
workspace" for one outcome. The browse occupant already carries its own
New folder affordance, so picking a directory covered creating one; the
name dialog only added a second vocabulary and a create target the
operator could neither see nor choose.
The surviving entry is named after the outcome — "Add workspace…" — and a
menu now appears only where there is something to choose between: with no
Workspace listed (the add-only sidebar header, or an empty hero list) the
anchor gesture raises the directory flow directly instead of a one-row
popover. An empty list counts as final only after the list baseline lands,
and a composition with no directory-flow occupant hides the sidebar button
rather than offering a dead one.
WorkspaceCreateFlow becomes WorkspacePickFlow (createOnly -> addOnly) and
the injected createWorkspace narrows to { path }. The host's
workspace.create({ name }) branch and `dsh web --workspace-root` lost their
last product consumer; both are marked at the call site for a follow-up.
114 lines
5.7 KiB
TypeScript
114 lines
5.7 KiB
TypeScript
// Web e2e scenario: the plan-review takeover. The shipped composition mounts
|
|
// plan mode and its client seat, so `/plan <task>` enters plan mode for real
|
|
// and the recorded turn ends on exit_plan_mode blocking against the live
|
|
// userInteraction seam. The composer is then occupied by the plan decision
|
|
// card — not the generic question flow — and approving it through the card
|
|
// completes the turn with the approval in the log.
|
|
// Replay is deterministic: the plan content arrives from replayed chunks, the
|
|
// review wait is real, and the approve click is the test's own gesture (the
|
|
// turn cannot complete without it, in record and replay alike).
|
|
import { readFile } from 'node:fs/promises'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { join } from 'node:path'
|
|
import type { Browser, Page } from 'playwright'
|
|
import { chromium } from 'playwright'
|
|
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
|
|
import type { SessionEvent } from '@deepseek-ai/dsh-session'
|
|
import {
|
|
assertFixtureInventory, captureStableAria, compareOrRefreshGolden, fixtureUserPrompts,
|
|
launchWebScaffold, recordFixture, watchConsole, webSnapshotMode, type WebScaffold,
|
|
} from './scaffold.ts'
|
|
import { connectFreshWorkspace, newEnglishPage, saveFailureShot } from './support.ts'
|
|
|
|
const SNAPSHOT_DIR = fileURLToPath(new URL('./snapshots/plan-review', import.meta.url))
|
|
const FIXTURE = join(SNAPSHOT_DIR, 'session.jsonl')
|
|
// The waiting golden owns the decision card; the approved golden owns the
|
|
// transcript the approval leaves behind — the state the card cannot see.
|
|
const REVIEW_EXPECTED = join(SNAPSHOT_DIR, 'review.expected.md')
|
|
const APPROVED_EXPECTED = join(SNAPSHOT_DIR, 'approved.expected.md')
|
|
const MODE = webSnapshotMode()
|
|
|
|
// One command line: /plan enters plan mode and submits the rest as the turn's
|
|
// message. The task is deliberately self-contained (nothing to explore in a
|
|
// fresh workspace) so the recorded turn is a plan and its review, and the
|
|
// approved continuation is one word.
|
|
const TASK = 'Plan a small change: add a --greeting flag to a CLI. Do not read or write any files. '
|
|
+ 'Call exit_plan_mode with a short plan of at most five bullet points. '
|
|
+ 'Once the plan is approved, reply with the single word DONE and stop.'
|
|
const LINE = `/plan ${TASK}`
|
|
|
|
describe('web e2e: plan review takeover round trip', () => {
|
|
let scaffold: WebScaffold
|
|
let browser: Browser
|
|
let page: Page
|
|
let tripwire: ReturnType<typeof watchConsole>
|
|
const sessionEvents: SessionEvent[] = []
|
|
|
|
beforeAll(async () => {
|
|
scaffold = await launchWebScaffold(MODE === 'record' ? {} : { replayFixture: FIXTURE, paceMs: 15 })
|
|
scaffold.ctx.on('session/event', (_session, event: SessionEvent) => { sessionEvents.push(event) })
|
|
browser = await chromium.launch()
|
|
// English page: the decision copy is the surface under test, and the
|
|
// golden pins one language.
|
|
page = await newEnglishPage(browser)
|
|
tripwire = watchConsole(page)
|
|
await page.goto(scaffold.baseUrl, { waitUntil: 'load' })
|
|
await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
|
|
await connectFreshWorkspace(page, scaffold.workspaceCwd)
|
|
}, 120_000)
|
|
|
|
afterAll(async () => {
|
|
await browser?.close()
|
|
await scaffold?.close()
|
|
})
|
|
|
|
it('reviews the plan on a decision card and approves through it', async () => {
|
|
onTestFailed(() => saveFailureShot(page, 'web-e2e-plan-review'))
|
|
if (MODE !== 'record') {
|
|
expect(fixtureUserPrompts(await readFile(FIXTURE, 'utf8'))).toEqual([TASK])
|
|
}
|
|
const input = page.locator('textarea').first()
|
|
await input.waitFor({ timeout: 10_000 })
|
|
const settled = scaffold.whenTurnSettled(MODE === 'record' ? 180_000 : 30_000)
|
|
await input.fill(LINE)
|
|
await input.press('Enter')
|
|
|
|
// The card takes over the input area while exit_plan_mode blocks. Its
|
|
// presence is a STABLE waiting state (it stays until answered), so a plain
|
|
// waitFor is race-free.
|
|
const card = page.locator('[data-plan-review-key]')
|
|
await card.waitFor({ timeout: MODE === 'record' ? 120_000 : 30_000 })
|
|
// The plan-review request must NOT land on the generic question flow.
|
|
expect(await page.locator('[data-question-key]').count()).toBe(0)
|
|
await expect.poll(() => card.getByText('Plan review').count(), { timeout: 10_000 }).toBeGreaterThan(0)
|
|
|
|
if (MODE !== 'record') {
|
|
const snapshot = await captureStableAria(page, '[data-plan-review-key]', scaffold.workspaceCwd)
|
|
await compareOrRefreshGolden(REVIEW_EXPECTED, snapshot, MODE)
|
|
}
|
|
|
|
await card.getByRole('button', { name: 'Approve' }).click()
|
|
|
|
const sessionId = await settled
|
|
if (MODE === 'record') {
|
|
await recordFixture(scaffold, sessionId, FIXTURE)
|
|
return
|
|
}
|
|
// World state: the approval reached the tool, and plan mode is left behind.
|
|
const results = sessionEvents.filter(e => e.type === 'tool/result')
|
|
expect(JSON.stringify(results.at(-1))).toContain('Plan approved')
|
|
await expect.poll(() => page.getByText('DONE', { exact: true }).count(), { timeout: 15_000 }).toBeGreaterThanOrEqual(1)
|
|
// Card gone; regular input restored.
|
|
expect(await page.locator('[data-plan-review-key]').count()).toBe(0)
|
|
await expect.poll(() => page.locator('textarea').first().isEnabled(), { timeout: 10_000 }).toBe(true)
|
|
const snapshot = await captureStableAria(page, '[class*="centerCol"]', scaffold.workspaceCwd)
|
|
await compareOrRefreshGolden(APPROVED_EXPECTED, snapshot, MODE)
|
|
expect(tripwire.pageErrors).toEqual([])
|
|
expect(tripwire.warnings).toEqual([])
|
|
}, 200_000)
|
|
|
|
it.skipIf(MODE === 'record')('keeps the fixture inventory closed', async () => {
|
|
await assertFixtureInventory(SNAPSHOT_DIR, ['session.jsonl', 'review.expected.md', 'approved.expected.md'])
|
|
})
|
|
})
|