Merge master into fix/conversation-column-one-axis-scroll
This commit is contained in:
@@ -111,7 +111,7 @@ export async function runHeadless(task: string): Promise<void> {
|
||||
const abort = new AbortController()
|
||||
const frames = api.events.mux({}, abort.signal)
|
||||
const idle = new Promise<void>((resolve) => {
|
||||
ctx.on('agent/status', (agent, status) => {
|
||||
ctx.on('agent/status', ({ agent, status }) => {
|
||||
if (agent.id === created.sessionId && status === 'idle') resolve()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -26,6 +26,7 @@ const SNAPSHOT_DIR = fileURLToPath(new URL('./snapshots/lifecycle-chrome', impor
|
||||
const FIXTURE = join(SNAPSHOT_DIR, 'session.jsonl')
|
||||
const HERO_EXPECTED = join(SNAPSHOT_DIR, 'hero.expected.md')
|
||||
const COMMAND_MENU_EXPECTED = join(SNAPSHOT_DIR, 'command-menu.expected.md')
|
||||
const FUZZY_COMMAND_MENU_EXPECTED = join(SNAPSHOT_DIR, 'command-menu-fuzzy.expected.md')
|
||||
const PLAN_ACTIVE_EXPECTED = join(SNAPSHOT_DIR, 'plan-active.expected.md')
|
||||
// Post-reload golden: the same settled conversation rebuilt purely from
|
||||
// persistence + history — byte-equal rendering is exactly the recovery claim.
|
||||
@@ -83,6 +84,12 @@ describe('web e2e: lifecycle & chrome (workspace flow / reload / dark mode)', ()
|
||||
expect(Math.abs(
|
||||
launchedBox!.y + launchedBox!.height - typedBox!.y - typedBox!.height,
|
||||
)).toBeLessThan(1)
|
||||
await input.fill('/cpt')
|
||||
await expect.poll(() => menu.getByRole('option').allTextContents()).toEqual([
|
||||
'compactCompact older conversation history',
|
||||
])
|
||||
const fuzzySnapshot = await captureStableAria(page, '[role="listbox"]', scaffold.workspaceCwd)
|
||||
await compareOrRefreshGolden(FUZZY_COMMAND_MENU_EXPECTED, fuzzySnapshot, MODE)
|
||||
await input.fill('')
|
||||
await expect.poll(() => menu.count()).toBe(0)
|
||||
})
|
||||
@@ -258,7 +265,7 @@ describe('web e2e: lifecycle & chrome (workspace flow / reload / dark mode)', ()
|
||||
it.skipIf(MODE === 'record')('keeps the fixture inventory closed', async () => {
|
||||
expect(tripwire.warnings).toEqual([])
|
||||
await assertFixtureInventory(SNAPSHOT_DIR, [
|
||||
'session.jsonl', 'command-menu.expected.md', 'hero.expected.md', 'plan-active.expected.md', 'reloaded.expected.md',
|
||||
'session.jsonl', 'command-menu.expected.md', 'command-menu-fuzzy.expected.md', 'hero.expected.md', 'plan-active.expected.md', 'reloaded.expected.md',
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
- listbox "Trigger suggestions":
|
||||
- text: Commands
|
||||
- option "compact Compact older conversation history" [selected]
|
||||
@@ -12,6 +12,9 @@
|
||||
// assembled application can show is that the path a user actually takes
|
||||
// reaches it: the real selection service, the real client session opening over
|
||||
// the real /api transport, and a real browser deciding what is painted.
|
||||
// The initial Workspace pick also records the resident Hero/composer nodes and
|
||||
// proves that opening the first blank Session fills the strict outlets without
|
||||
// replacing those nodes.
|
||||
//
|
||||
// The round-trip against a loopback host is far too fast to observe, so this
|
||||
// scenario HOLDS the `session.history` response open at the browser's network
|
||||
@@ -55,9 +58,6 @@ describe('web e2e: startup auto-selection', () => {
|
||||
tripwire = watchConsole(page)
|
||||
await page.goto(scaffold.baseUrl, { waitUntil: 'load' })
|
||||
await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
|
||||
// A registered workspace is the precondition for auto-selection: the first
|
||||
// load has nothing to select, so the reload below is the path under test.
|
||||
await connectFreshWorkspace(page, scaffold.workspaceCwd, 'startup-auto-selection')
|
||||
}, 180_000)
|
||||
|
||||
afterAll(async () => {
|
||||
@@ -65,6 +65,48 @@ describe('web e2e: startup auto-selection', () => {
|
||||
await scaffold?.close()
|
||||
})
|
||||
|
||||
it('keeps the resident Hero and composer nodes when the first Workspace session appears', async () => {
|
||||
onTestFailed(() => saveFailureShot(page, 'web-e2e-first-workspace-stable-tree'))
|
||||
await page.locator(`${ROOT_PHASE}[data-phase="hero"]`).waitFor({ timeout: 15_000 })
|
||||
await page.evaluate(() => {
|
||||
const refs = {
|
||||
root: document.querySelector('div[data-phase="hero"]'),
|
||||
workspaceChip: document.querySelector('[aria-label="Choose workspace"]'),
|
||||
scrollBody: document.querySelector('[data-conversation-scroll]'),
|
||||
composerSeat: document.querySelector('[data-composer-seat]'),
|
||||
textarea: document.querySelector('textarea'),
|
||||
}
|
||||
if (Object.values(refs).some(node => node === null)) throw new Error('incomplete initial Hero tree')
|
||||
;(window as unknown as { __heroTree: typeof refs }).__heroTree = refs
|
||||
})
|
||||
|
||||
// A registered Workspace is the precondition for the reload case below;
|
||||
// this first connection is also the no-Workspace → Workspace path.
|
||||
await connectFreshWorkspace(page, scaffold.workspaceCwd, 'startup-auto-selection')
|
||||
|
||||
expect(await page.evaluate(() => {
|
||||
const before = (window as unknown as { __heroTree: Record<string, Element> }).__heroTree
|
||||
return {
|
||||
phase: document.querySelector('div[data-phase]')?.getAttribute('data-phase'),
|
||||
root: document.querySelector('div[data-phase="hero"]') === before.root,
|
||||
workspaceChip: document.querySelector('[aria-label="Choose workspace"]') === before.workspaceChip,
|
||||
scrollBody: document.querySelector('[data-conversation-scroll]') === before.scrollBody,
|
||||
composerSeat: document.querySelector('[data-composer-seat]') === before.composerSeat,
|
||||
textarea: document.querySelector('textarea') === before.textarea,
|
||||
textareaEnabled: !(document.querySelector('textarea') as HTMLTextAreaElement).disabled,
|
||||
}
|
||||
})).toEqual({
|
||||
phase: 'hero',
|
||||
root: true,
|
||||
workspaceChip: true,
|
||||
scrollBody: true,
|
||||
composerSeat: true,
|
||||
textarea: true,
|
||||
textareaEnabled: true,
|
||||
})
|
||||
expect(tripwire.pageErrors).toEqual([])
|
||||
}, 120_000)
|
||||
|
||||
it('keeps the hero and the composer on screen while the auto-selected blank session opens', async () => {
|
||||
onTestFailed(() => saveFailureShot(page, 'web-e2e-startup-auto-selection'))
|
||||
// Runs before any page script on the reload below, so the first phase the
|
||||
|
||||
@@ -18,10 +18,110 @@ function rejectStandaloneServe(): Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Vendor-chunk membership, by exact npm package name — the heavy render
|
||||
* families (math, highlight, markdown) that change only on dependency bumps.
|
||||
* Only packages workspace code imports DIRECTLY need listing: their private
|
||||
* transitive dependencies (oniguruma machinery, character tables, …) are
|
||||
* imported solely by these and rollup's chunk coloring pulls them into
|
||||
* vendor automatically. A dependency shared with index-side code falls back
|
||||
* to index — a few kB of dilution, never a correctness problem. Anything not
|
||||
* listed (react family, the vendored cordis workspace, tiny helpers like
|
||||
* anser/clsx, all workspace code) stays in the default `index` chunk, so
|
||||
* editing shell code re-hashes only index and returning clients keep the
|
||||
* cached vendor chunk.
|
||||
*
|
||||
* Boundary invariant: every member must be react-free. A package that
|
||||
* imports react/jsx-runtime must never be listed — rollup folds a module
|
||||
* shared between the entry and a manual chunk into the manual chunk, so one
|
||||
* react-importing member would drag the single shared react copy into
|
||||
* vendor. The React side of markdown/math rendering is workspace code and
|
||||
* rides index.
|
||||
*/
|
||||
const VENDOR_PACKAGES: ReadonlySet<string> = new Set([
|
||||
// math
|
||||
'katex',
|
||||
// syntax highlight (@shikijs/langs is handled separately below —
|
||||
// lazy grammars must not land here)
|
||||
'shiki',
|
||||
// markdown parse pipeline (micromark/mdast; the incremental React renderer
|
||||
// over it is workspace code)
|
||||
'mdast-util-from-markdown',
|
||||
'mdast-util-gfm',
|
||||
'mdast-util-math',
|
||||
'micromark-core-commonmark',
|
||||
'micromark-extension-gfm',
|
||||
'micromark-extension-math',
|
||||
'micromark-factory-space',
|
||||
'micromark-util-character',
|
||||
'micromark-util-classify-character',
|
||||
'micromark-util-sanitize-uri',
|
||||
'micromark-util-symbol',
|
||||
'micromark-util-types',
|
||||
])
|
||||
|
||||
/**
|
||||
* Boot grammars statically imported by ui-primitives' highlight.ts
|
||||
* (`@shikijs/langs/typescript` → `dist/typescript.mjs`, etc.). They live in
|
||||
* the same package as the lazy read-card grammars, but unlike those they are
|
||||
* part of the initial load and belong in the vendor chunk; the lazy ones must
|
||||
* stay unassigned so each keeps its own on-demand chunk.
|
||||
*/
|
||||
const BOOT_GRAMMAR_FILES: readonly string[] = [
|
||||
'dist/typescript.mjs',
|
||||
'dist/shellscript.mjs',
|
||||
'dist/json.mjs',
|
||||
]
|
||||
|
||||
/** Font asset extensions routed to assets/fonts/ (KaTeX's woff2/woff/ttf faces today). */
|
||||
const FONT_EXTENSIONS: readonly string[] = ['.woff2', '.woff', '.ttf']
|
||||
|
||||
/** npm package name of a resolved module id (the segment after the LAST `node_modules/` — pnpm nests the real package under an inner node_modules). */
|
||||
function npmPackageOf(id: string): string | undefined {
|
||||
const parts = id.split('/node_modules/')
|
||||
if (parts.length === 1) return undefined
|
||||
const [first, second] = parts[parts.length - 1].split('/')
|
||||
if (first.startsWith('.')) return undefined // .pnpm store segment, not a package
|
||||
if (first.startsWith('@')) return second === undefined ? undefined : `${first}/${second}`
|
||||
return first
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [rejectStandaloneServe(), react()],
|
||||
build: {
|
||||
sourcemap: true,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
// Output layout: the two main chunks stay at assets/ root; lazy
|
||||
// @shikijs/langs grammar chunks group under assets/langs/; fonts
|
||||
// (today all KaTeX faces referenced by vendor.css) group under
|
||||
// assets/fonts/. Sourcemaps need no arrangement: rollup writes each
|
||||
// .map next to its js and references it by bare relative filename.
|
||||
chunkFileNames(chunk): string {
|
||||
// Grammar chunks are recognized by their member modules, not the
|
||||
// facade: shared embedded-grammar chunks (e.g. html+javascript,
|
||||
// split out because php/ruby/mdx embed them) have no facade at all.
|
||||
// index and vendor are excluded by name — vendor legitimately
|
||||
// carries the three boot grammars.
|
||||
if (chunk.name === 'index' || chunk.name === 'vendor') return 'assets/[name]-[hash].js'
|
||||
const isLangChunk = chunk.moduleIds.some(id => id.includes('/node_modules/@shikijs/langs/'))
|
||||
return isLangChunk ? 'assets/langs/[name]-[hash].js' : 'assets/[name]-[hash].js'
|
||||
},
|
||||
assetFileNames(asset): string {
|
||||
const fileName = asset.names[0] ?? ''
|
||||
const isFont = FONT_EXTENSIONS.some(ext => fileName.endsWith(ext))
|
||||
return isFont ? 'assets/fonts/[name]-[hash][extname]' : 'assets/[name]-[hash][extname]'
|
||||
},
|
||||
manualChunks(id: string): string | undefined {
|
||||
const pkg = npmPackageOf(id)
|
||||
if (pkg === undefined) return undefined // workspace + vendored cordis: index
|
||||
if (pkg === '@shikijs/langs') {
|
||||
return BOOT_GRAMMAR_FILES.some(file => id.endsWith(`/${file}`)) ? 'vendor' : undefined
|
||||
}
|
||||
return VENDOR_PACKAGES.has(pkg) ? 'vendor' : undefined
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
// Workspace packages resolve to SOURCE: package.json exports point at lib
|
||||
|
||||
Reference in New Issue
Block a user