From 19df0ced4c4198614788fbacf9d6dc305f3a4ee8 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Sun, 9 Aug 2026 20:08:32 -0700 Subject: [PATCH] Align mobile wire fixtures with create intents --- ...ructured-agent-session-integration.test.ts | 20 ++++++++++++- ...ss-version-agent-session-wire.unit.test.ts | 28 +++++++++++++++---- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/main/runtime/structured-agent-session-integration.test.ts b/src/main/runtime/structured-agent-session-integration.test.ts index 13ea352a51c..c351a907a04 100644 --- a/src/main/runtime/structured-agent-session-integration.test.ts +++ b/src/main/runtime/structured-agent-session-integration.test.ts @@ -170,6 +170,12 @@ function attachParams(fence: number | null) { } } +function createIntentParams() { + const worktree = `id:${WORKSPACE}` + const fields = { worktree, agent: 'codex' } + return { envelope: envelope('agentSession.create', fields, null), ...fields } +} + let codex: CodexScript let root: string let dispatcher: RpcDispatcher @@ -252,6 +258,16 @@ beforeEach(async () => { cleanups = new Map() const runtime = { getRuntimeId: () => 'runtime-1', + getStructuredAgentSessionCreateSupport: async () => ({ supported: true }), + resolveStructuredAgentSessionCreateIntent: async () => { + const { + envelope: _envelope, + providerHandle: _providerHandle, + ...resolved + } = attachParams(null) + return resolved + }, + publishStructuredAgentSessionTab: () => {}, ensureStructuredAgentSessionHost: () => ensureStructuredAgentSessionHost({ stateDirectory: root, @@ -295,7 +311,7 @@ describe('a structured codex session over agentSession.*', () => { expect(getStructuredAgentSessionHost()).toBeNull() const created = await ok<{ fence: number; snapshot: { items: unknown[] } }>( 'agentSession.create', - attachParams(null) + createIntentParams() ) expect(created.snapshot.items).toEqual([]) expect(codex.live().calls[0]).toMatchObject({ @@ -448,6 +464,7 @@ describe('a structured codex session over agentSession.*', () => { // no page overlaps another, and nothing the live stream showed is missing. expect([...older.page.items, ...tail.page.items].map((item) => item.body?.kind)).toEqual([ 'message', + 'status', 'message', 'tool-call', 'approval', @@ -456,6 +473,7 @@ describe('a structured codex session over agentSession.*', () => { ]) expect([...older.page.items, ...tail.page.items].map(textOf)).toEqual([ 'list files', + '', 'Two files.', '', '', diff --git a/tests/e2e/cross-version-wire/cross-version-agent-session-wire.unit.test.ts b/tests/e2e/cross-version-wire/cross-version-agent-session-wire.unit.test.ts index 738d4ecbc92..f1301bfc144 100644 --- a/tests/e2e/cross-version-wire/cross-version-agent-session-wire.unit.test.ts +++ b/tests/e2e/cross-version-wire/cross-version-agent-session-wire.unit.test.ts @@ -115,6 +115,12 @@ function attachParams(fence: number | null): Record { } } +function createIntentParams(): Record { + const worktree = `id:${WORKSPACE}` + const fields = { worktree, agent: 'codex' } + return { envelope: envelope({ method: 'agentSession.create', fields, fence: null }), ...fields } +} + function sendParams(text: string, fence: number): Record { const body = { kind: 'message', role: 'user', blocks: [{ type: 'text', text }] } return { envelope: envelope({ method: 'agentSession.send', fields: { body }, fence }), body } @@ -125,7 +131,7 @@ function paramsFor(method: string): unknown { const fence = 1 switch (method) { case 'agentSession.create': - return attachParams(null) + return createIntentParams() case 'agentSession.ensure': return attachParams(fence) case 'agentSession.send': @@ -155,6 +161,16 @@ function runtimeStub(): unknown { const cleanups = new Map void>() return { getRuntimeId: () => 'runtime-1', + getStructuredAgentSessionCreateSupport: async () => ({ supported: true }), + resolveStructuredAgentSessionCreateIntent: async () => { + const { + envelope: _envelope, + providerHandle: _providerHandle, + ...resolved + } = attachParams(null) + return resolved + }, + publishStructuredAgentSessionTab: () => {}, registerSubscriptionCleanup: (id: string, cleanup: () => void) => cleanups.set(id, cleanup), cleanupSubscription: (id: string) => { cleanups.get(id)?.() @@ -212,7 +228,7 @@ describe('cross-version structured agent sessions', () => { beforeEach(() => { operations = 0 hostCalls = { - attach: vi.fn(async () => ({ ok: true, replayed: false })), + attach: vi.fn(async () => ({ ok: true, replayed: false, value: { sessionId: SESSION } })), send: vi.fn(async () => ({ ok: true, replayed: false })), cancel: vi.fn(async () => ({ ok: true, replayed: false })), respondToPrompt: vi.fn(async () => ({ ok: true, replayed: false })), @@ -264,7 +280,9 @@ describe('cross-version structured agent sessions', () => { expect(replies[0], `${method} was refused`).toMatchObject({ ok: true }) } for (const reply of replies) { - expect(reply, `${method} was refused`).toMatchObject({ ok: true }) + expect(reply, `${method} was refused: ${JSON.stringify(reply)}`).toMatchObject({ + ok: true + }) } } }) @@ -417,7 +435,7 @@ describe('cross-version structured agent sessions', () => { }) it('resumes from the cursor the client held, with no snapshot and no replay', async () => { - const created = await answer('agentSession.create', attachParams(null)) + const created = await answer('agentSession.create', createIntentParams()) expect(created.ok).toBe(true) const first = await answer('agentSession.send', sendParams('before restart', created.fence)) expect(first.ok).toBe(true) @@ -447,7 +465,7 @@ describe('cross-version structured agent sessions', () => { }) it('refuses a write still fenced to the host generation that died', async () => { - const created = await answer('agentSession.create', attachParams(null)) + const created = await answer('agentSession.create', createIntentParams()) await bootHost('b') const reattached = await reattach(created.fence) expect(reattached.fence).toBeGreaterThan(created.fence)