fix(walkthrough): address review of agent-opened walkthrough

- Wait for the model catalog once per walkthrough generation instead of before every model call
- Report open_walkthrough as requested, not opened, and drop its unused metadata
- Share the ocm tool and action names through @opencode-manager/shared
- Remove the unused source-request nonce and duplicate session check
- Scan only new messages when auto-opening the walkthrough
- Assert the request action cannot reach the internal change-walkthroughs route
This commit is contained in:
Chris Scott committed 2026-10-09 11:25:26 -04:00
1 parent aa1da8d608
commit c497df5161
14 files changed
+146 -122

No files matched your search

@@ -3,7 +3,7 @@ import { getOpenCodeGlobalConfigPath } from '@opencode-manager/shared/config/env
import type { ModelInfo, ModelRef } from '@opencode-manager/shared/opencode'
import type { OpenCodeClient } from '../../../src/services/opencode/client'
import { GenerateTextTimeoutError, generateTextWithTimeout } from '../../../src/services/opencode/generate-text'
import { MODEL_LOAD_POLL_MS, MODEL_LOAD_TIMEOUT_MS } from '../../../src/services/opencode-models'
import { MODEL_LOAD_POLL_MS } from '../../../src/services/opencode-models'
interface GenerateCall {
input: { prompt: string; model?: ModelRef }
@@ -77,35 +77,14 @@ describe('generateTextWithTimeout', () => {
expect(calls[0]?.input.model).toEqual({ providerID: 'openai', id: 'gpt-5-mini' })
})
it('waits for the provided model to load before generating', async () => {
vi.useFakeTimers()
const model: ModelRef = { providerID: 'anthropic', id: 'claude-sonnet-4', variant: 'high' }
const { client, calls } = makeClient(async () => ({ text: 'hello' }), [
[],
[{ providerID: 'anthropic', id: 'claude-sonnet-4', enabled: true } as ModelInfo],
])
const promise = generateTextWithTimeout(client, { prompt: 'write', model }, 10_000)
await vi.advanceTimersByTimeAsync(0)
expect(calls).toHaveLength(0)
await vi.advanceTimersByTimeAsync(MODEL_LOAD_POLL_MS)
await expect(promise).resolves.toBe('hello')
expect(calls).toHaveLength(1)
expect(calls[0]?.input).toEqual({ prompt: 'write', model })
})
it('generates with the provided model when its catalog never loads', async () => {
vi.useFakeTimers()
it('forwards the model when provided without reading the catalog', async () => {
const { client, calls, modelList } = makeClient(async () => ({ text: 'hello' }))
const model: ModelRef = { providerID: 'anthropic', id: 'claude-sonnet-4' }
const { client, calls } = makeClient(async () => ({ text: 'hello' }), [[]])
const promise = generateTextWithTimeout(client, { prompt: 'write', model }, 100_000)
await vi.advanceTimersByTimeAsync(MODEL_LOAD_TIMEOUT_MS)
await expect(promise).resolves.toBe('hello')
await generateTextWithTimeout(client, { prompt: 'write', model }, 1000)
expect(calls).toHaveLength(1)
expect(calls[0]?.input).toEqual({ prompt: 'write', model })
expect(modelList).not.toHaveBeenCalled()
})
it('rejects with GenerateTextTimeoutError and aborts the request after the timeout', async () => {