section 7: Phase 7: Browse recent multi-runs: open, discard, and fuse f

This commit is contained in:
Chris Scott committed 2026-10-07 18:33:03 -04:00
1 parent 0aaa2bd3d6
commit a9a1fd8d5a
2 files changed
+566 -37

No files matched your search

+193 -14
View File
@@ -1,15 +1,20 @@
import { randomUUID } from 'node:crypto'
import type { Context, ToastOptions } from '@opencode/plugin/tui/context'
import {
FusionUnavailableDetailsSchema,
MULTI_RUN_FUSION_MIN_SOURCES,
MULTI_RUN_MAX_MODELS,
type FuseMultiRunRequest,
type LaunchMultiRunRequest,
type MultiRun,
type MultiRunEntry,
type MultiRunEntryStatus,
} from '@opencode-manager/shared/schemas'
import { formatOpenCodeModelRef } from '@opencode-manager/shared/opencode'
import { ManagerApi, ManagerApiError, isManagerRouteMissing } from './manager-api.js'
import { resolveManagerAuth } from './manager-auth.js'
import type { ManagerAuthOk } from './manager-auth.js'
import { multiSelectDialog, promptDialog, selectDialog, slashArgument } from './tui-dialogs.js'
import { confirmDialog, multiSelectDialog, promptDialog, selectDialog, slashArgument } from './tui-dialogs.js'
import type { RemoteContext } from './remote-context.js'
export const MULTI_RUN_ATTACH_REQUIRED =
@@ -55,10 +60,32 @@ function defaultMultiRunName(prompt: string): string {
return prompt.split('\n')[0].slice(0, 80)
}
const ENTRY_STATUS_LABELS: Record<MultiRunEntryStatus, string> = {
starting: 'Starting',
started: 'Started',
failed: 'Failed',
discarded: 'Discarded',
}
export function formatEntryStatus(entry: MultiRunEntry): string {
const parts = [ENTRY_STATUS_LABELS[entry.status], entry.isolated ? 'isolated' : 'shared directory']
if (entry.error) parts.push(entry.error)
return parts.join(' · ')
}
function startedSources(run: MultiRun): (MultiRunEntry & { sessionId: string })[] {
return run.entries.filter(
(entry): entry is MultiRunEntry & { sessionId: string } => entry.status === 'started' && entry.sessionId !== null,
)
}
function startedSessionIds(run: MultiRun): string[] {
return run.entries
.filter((entry): entry is MultiRunEntry & { sessionId: string } => entry.status === 'started' && entry.sessionId !== null)
.map((entry) => entry.sessionId)
return startedSources(run).map((entry) => entry.sessionId)
}
function runSummary(run: MultiRun): string {
const started = run.entries.filter((entry) => entry.status === 'started').length
return `${run.entries.length} models · ${started} started · ${run.fusions.length} fusions`
}
function multiRunLaunchToast(run: MultiRun): ToastOptions {
@@ -75,6 +102,14 @@ function showMultiRunError(context: Context, error: unknown): void {
return
}
if (error instanceof ManagerApiError) {
const unavailable = FusionUnavailableDetailsSchema.safeParse(error.details)
if (unavailable.success && unavailable.data.unavailableSources.length > 0) {
context.ui.toast.show({
variant: 'error',
message: unavailable.data.unavailableSources.map((source) => `${source.model}: ${source.message}`).join('\n'),
})
return
}
context.ui.toast.show({ variant: 'error', message: error.message })
return
}
@@ -125,6 +160,153 @@ async function launchMultiRunFlow(context: Context, api: ManagerApi, repoId: num
openManagerSessions(context, startedSessionIds(run))
}
type RunChoice = { kind: 'new' } | { kind: 'run'; run: MultiRun }
type RunAction =
| { kind: 'open'; sessionId: string }
| { kind: 'fuse' }
| { kind: 'discard'; entry: MultiRunEntry }
async function discardEntryFlow(context: Context, api: ManagerApi, run: MultiRun, entry: MultiRunEntry): Promise<void> {
const confirmed = await confirmDialog(context, {
title: 'Discard run',
message: entry.isolated
? `Discard ${entry.model} and remove its workspace directory? This cannot be undone.`
: `Discard ${entry.model}? This cannot be undone.`,
})
if (!confirmed) return
await api.discardMultiRunEntry(run.id, entry.id)
context.ui.toast.show({ variant: 'success', message: `Discarded ${entry.model}` })
}
async function fuseMultiRunFlow(context: Context, api: ManagerApi, run: MultiRun): Promise<void> {
const entryIds = await multiSelectDialog<number>(context, {
title: 'Fusion sources',
options: startedSources(run).map((entry) => ({
title: entry.model,
description: formatEntryStatus(entry),
value: entry.id,
})),
min: MULTI_RUN_FUSION_MIN_SOURCES,
max: MULTI_RUN_MAX_MODELS,
})
if (!entryIds) return
const model = await selectDialog(context, 'Synthesis model', await listModelOptions(context))
if (!model) return
const instructions = await promptDialog(context, {
title: 'Instructions (optional)',
description: 'Optional guidance for the synthesis.',
placeholder: 'Optional guidance',
})
const requiresIsolation = run.entries.some((entry) => entryIds.includes(entry.id) && !entry.isolated)
let isolate = true
if (!requiresIsolation) {
const chosen = await selectDialog<boolean>(context, 'Isolation', [
{ title: 'Isolated worktree (recommended)', value: true },
{ title: 'Shared repo directory', value: false },
])
if (chosen === undefined) return
isolate = chosen
}
const baseRef = isolate
? await promptDialog(context, {
title: 'Start from',
description: 'The synthesis workspace starts from this branch.',
placeholder: 'Current HEAD',
value: run.baseRef ?? '',
})
: undefined
const requestId = randomUUID()
const request: FuseMultiRunRequest = {
requestId,
entryIds,
model,
isolate,
...(instructions ? { instructions } : {}),
...(isolate && baseRef ? { baseRef } : {}),
}
const updated = await api.fuseMultiRun(run.id, request)
const fusion = updated.fusions.find((candidate) => candidate.requestId === requestId)
if (!fusion) return
if (fusion.status === 'failed') {
context.ui.toast.show({ variant: 'error', message: fusion.error ?? `Fusion of ${fusion.model} failed` })
return
}
context.ui.toast.show({ variant: 'success', message: `Fused ${fusion.model}` })
if (fusion.sessionId) openManagerSessions(context, [fusion.sessionId])
}
async function browseRunFlow(context: Context, api: ManagerApi, run: MultiRun): Promise<void> {
const options: { title: string; description?: string; value: RunAction; disabled?: boolean }[] = []
for (const entry of run.entries) {
if (entry.sessionId) {
options.push({
title: `Open ${entry.model}`,
description: formatEntryStatus(entry),
value: { kind: 'open', sessionId: entry.sessionId },
})
}
}
for (const fusion of run.fusions) {
if (fusion.sessionId) {
options.push({ title: `Open fusion ${fusion.model}`, value: { kind: 'open', sessionId: fusion.sessionId } })
}
}
options.push({
title: 'Fuse results…',
value: { kind: 'fuse' },
disabled: startedSources(run).length < MULTI_RUN_FUSION_MIN_SOURCES,
})
for (const entry of run.entries) {
if (entry.status === 'started' || entry.status === 'failed') {
options.push({ title: `Discard ${entry.model}…`, value: { kind: 'discard', entry } })
}
}
const action = await selectDialog(context, run.name, options)
if (!action) return
if (action.kind === 'open') {
openManagerSessions(context, [action.sessionId])
return
}
if (action.kind === 'discard') {
await discardEntryFlow(context, api, run, action.entry)
return
}
await fuseMultiRunFlow(context, api, run)
}
async function browseMultiRunsFlow(context: Context, api: ManagerApi, repoId: number): Promise<void> {
const runs = await api.listMultiRuns(repoId)
const choice = await selectDialog<RunChoice>(context, 'Multi-runs', [
{ title: 'New multi-run…', value: { kind: 'new' } },
...runs.map((run) => ({ title: run.name, description: runSummary(run), value: { kind: 'run' as const, run } })),
])
if (!choice) return
if (choice.kind === 'new') {
const prompt = await promptDialog(context, {
title: 'Multi-run prompt',
description: 'The prompt to send to every model.',
placeholder: 'Describe the task',
})
if (!prompt) return
await launchMultiRunFlow(context, api, repoId, prompt)
return
}
await browseRunFlow(context, api, choice.run)
}
export async function runMultiRunCommand(
context: Context,
deps: MultiRunCommandDeps,
@@ -143,18 +325,15 @@ export async function runMultiRunCommand(
return
}
const prompt =
slashArgument(input, 'multirun') ||
(await promptDialog(context, {
title: 'Multi-run prompt',
description: 'The prompt to send to every model.',
placeholder: 'Describe the task',
}))
if (!prompt) return
const api = deps.createApi ? deps.createApi(auth) : new ManagerApi(auth.managerUrl, auth.token)
await launchMultiRunFlow(context, api, remote.repoId, prompt)
const prompt = slashArgument(input, 'multirun')
if (prompt) {
await launchMultiRunFlow(context, api, remote.repoId, prompt)
return
}
await browseMultiRunsFlow(context, api, remote.repoId)
} catch (error) {
showMultiRunError(context, error)
}
+373 -23
View File
@@ -6,6 +6,7 @@ import {
listModelOptions,
openManagerSessions,
runMultiRunCommand,
formatEntryStatus,
MULTI_RUN_ATTACH_REQUIRED,
MULTI_RUN_ROUTE_MISSING,
} from '../src/tui-multi-run.js'
@@ -13,6 +14,7 @@ import { ManagerApiError } from '../src/manager-api.js'
import type { ManagerApi } from '../src/manager-api.js'
import { resolveManagerAuth } from '../src/manager-auth.js'
import type { RemoteContext } from '../src/remote-context.js'
import type { MultiRunFusion } from '@opencode-manager/shared/schemas'
vi.mock('../src/manager-auth.js', () => ({
resolveManagerAuth: vi.fn(),
@@ -72,6 +74,25 @@ function multiRun(overrides: Partial<MultiRun> = {}): MultiRun {
}
}
function fusion(overrides: Partial<MultiRunFusion> = {}): MultiRunFusion {
return {
id: 9,
requestId: 'req-1',
model: 'anthropic/claude',
instructions: null,
isolated: true,
baseRef: null,
status: 'started',
sessionId: 'ses_f',
directory: '/work/f',
error: null,
sources: [],
createdAt: 1,
updatedAt: 1,
...overrides,
}
}
function createFakeContext() {
const toast = vi.fn()
const prompt = vi.fn()
@@ -99,6 +120,8 @@ function makeApi() {
return {
launchMultiRun: vi.fn(async () => multiRun()),
listMultiRuns: vi.fn(async () => [] as MultiRun[]),
fuseMultiRun: vi.fn(async () => multiRun()),
discardMultiRunEntry: vi.fn(async () => multiRun()),
}
}
@@ -172,6 +195,16 @@ describe('openManagerSessions', () => {
})
})
describe('formatEntryStatus', () => {
it('describes the status, isolation and error', () => {
expect(formatEntryStatus(entry({ status: 'started', isolated: true }))).toBe('Started · isolated')
expect(formatEntryStatus(entry({ status: 'failed', isolated: false, error: 'model unavailable' }))).toBe(
'Failed · shared directory · model unavailable',
)
expect(formatEntryStatus(entry({ status: 'discarded', isolated: true }))).toBe('Discarded · isolated')
})
})
describe('runMultiRunCommand', () => {
it('refuses when not attached to a Manager', async () => {
const fake = createFakeContext()
@@ -341,29 +374,6 @@ describe('runMultiRunCommand', () => {
expect(api.launchMultiRun).not.toHaveBeenCalled()
})
it('asks for the prompt when the command has none', async () => {
const fake = createFakeContext()
const api = makeApi()
fake.list.mockReturnValue([model()])
fake.prompt.mockResolvedValueOnce('from dialog').mockResolvedValueOnce('sweep').mockResolvedValueOnce(undefined)
fake.select.mockResolvedValueOnce(0).mockResolvedValueOnce(-1).mockResolvedValueOnce(true)
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(fake.prompt).toHaveBeenNthCalledWith(1, expect.objectContaining({ title: 'Multi-run prompt' }))
expect(api.launchMultiRun).toHaveBeenCalledWith(expect.objectContaining({ prompt: 'from dialog' }))
})
it('does nothing when the prompt dialog is dismissed', async () => {
const fake = createFakeContext()
const api = makeApi()
fake.prompt.mockResolvedValueOnce(undefined)
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(api.launchMultiRun).not.toHaveBeenCalled()
})
it('reports an auth failure without calling the API', async () => {
const fake = createFakeContext()
const api = makeApi()
@@ -401,3 +411,343 @@ describe('runMultiRunCommand', () => {
expect(fake.toast).toHaveBeenCalledWith({ variant: 'error', message: MULTI_RUN_ROUTE_MISSING })
})
})
describe('runMultiRunCommand browse', () => {
it('lists recent runs with a new multi-run option first', async () => {
const fake = createFakeContext()
const api = makeApi()
api.listMultiRuns.mockResolvedValue([
multiRun({
id: 3,
name: 'sweep',
entries: [entry({ id: 1, status: 'started' }), entry({ id: 2, status: 'failed', sessionId: null })],
fusions: [fusion()],
}),
])
fake.select.mockResolvedValueOnce(undefined)
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(api.listMultiRuns).toHaveBeenCalledWith(1)
expect(fake.select).toHaveBeenCalledWith(
expect.objectContaining({
title: 'Multi-runs',
options: [
{ title: 'New multi-run…', value: { kind: 'new' } },
expect.objectContaining({
title: 'sweep',
description: '2 models · 1 started · 1 fusions',
value: expect.objectContaining({ kind: 'run' }),
}),
],
}),
)
expect(api.launchMultiRun).not.toHaveBeenCalled()
})
it('launches a new multi-run from the list', async () => {
const fake = createFakeContext()
const api = makeApi()
fake.list.mockReturnValue([model()])
fake.select
.mockResolvedValueOnce({ kind: 'new' })
.mockResolvedValueOnce(0)
.mockResolvedValueOnce(-1)
.mockResolvedValueOnce(false)
fake.prompt.mockResolvedValueOnce('from list').mockResolvedValueOnce('sweep')
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(fake.prompt).toHaveBeenNthCalledWith(1, expect.objectContaining({ title: 'Multi-run prompt' }))
expect(fake.prompt).toHaveBeenNthCalledWith(2, expect.objectContaining({ title: 'Multi-run name' }))
expect(api.launchMultiRun).toHaveBeenCalledWith(
expect.objectContaining({ repoId: 1, prompt: 'from list', name: 'sweep' }),
)
})
it('does nothing when the new multi-run prompt is dismissed', async () => {
const fake = createFakeContext()
const api = makeApi()
fake.select.mockResolvedValueOnce({ kind: 'new' })
fake.prompt.mockResolvedValueOnce(undefined)
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(api.launchMultiRun).not.toHaveBeenCalled()
})
it('opens an entry session from the run menu', async () => {
const fake = createFakeContext()
const api = makeApi()
const run = multiRun({ id: 3, name: 'sweep', entries: [entry({ id: 1, sessionId: 'ses_1' })], fusions: [] })
api.listMultiRuns.mockResolvedValue([run])
fake.select
.mockResolvedValueOnce({ kind: 'run', run })
.mockResolvedValueOnce({ kind: 'open', sessionId: 'ses_1' })
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(fake.select).toHaveBeenNthCalledWith(
2,
expect.objectContaining({
title: 'sweep',
options: expect.arrayContaining([
expect.objectContaining({
title: 'Open openai/gpt-5',
description: 'Started · isolated',
value: { kind: 'open', sessionId: 'ses_1' },
}),
]),
}),
)
expect(fake.open).toHaveBeenCalledWith('ses_1')
expect(fake.focus).toHaveBeenCalledWith('ses_1')
})
it('opens a fusion session from the run menu', async () => {
const fake = createFakeContext()
const api = makeApi()
const run = multiRun({ id: 3, name: 'sweep', entries: [], fusions: [fusion({ sessionId: 'ses_f' })] })
api.listMultiRuns.mockResolvedValue([run])
fake.select
.mockResolvedValueOnce({ kind: 'run', run })
.mockResolvedValueOnce({ kind: 'open', sessionId: 'ses_f' })
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(fake.select).toHaveBeenNthCalledWith(
2,
expect.objectContaining({
options: expect.arrayContaining([
expect.objectContaining({ title: 'Open fusion anthropic/claude', value: { kind: 'open', sessionId: 'ses_f' } }),
]),
}),
)
expect(fake.open).toHaveBeenCalledWith('ses_f')
})
it('disables fusion until enough results have started', async () => {
const fake = createFakeContext()
const api = makeApi()
const run = multiRun({ id: 3, name: 'sweep', entries: [entry({ id: 1, status: 'started' })], fusions: [] })
api.listMultiRuns.mockResolvedValue([run])
fake.select.mockResolvedValueOnce({ kind: 'run', run }).mockResolvedValueOnce(undefined)
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(fake.select).toHaveBeenNthCalledWith(
2,
expect.objectContaining({
options: expect.arrayContaining([
expect.objectContaining({ title: 'Fuse results…', disabled: true, value: { kind: 'fuse' } }),
]),
}),
)
})
it('discards an entry after confirmation', async () => {
const fake = createFakeContext()
const api = makeApi()
const run = multiRun({ id: 3, name: 'sweep', entries: [entry({ id: 1, isolated: true })], fusions: [] })
api.listMultiRuns.mockResolvedValue([run])
fake.select
.mockResolvedValueOnce({ kind: 'run', run })
.mockResolvedValueOnce({ kind: 'discard', entry: run.entries[0] })
fake.confirm.mockResolvedValueOnce(true)
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(fake.confirm).toHaveBeenCalledWith(
expect.objectContaining({ message: expect.stringContaining('workspace directory') }),
)
expect(api.discardMultiRunEntry).toHaveBeenCalledWith(3, 1)
expect(fake.toast).toHaveBeenCalledWith({ variant: 'success', message: 'Discarded openai/gpt-5' })
})
it('uses the plain discard message for a shared entry and skips the API on decline', async () => {
const fake = createFakeContext()
const api = makeApi()
const run = multiRun({ id: 3, name: 'sweep', entries: [entry({ id: 1, isolated: false })], fusions: [] })
api.listMultiRuns.mockResolvedValue([run])
fake.select
.mockResolvedValueOnce({ kind: 'run', run })
.mockResolvedValueOnce({ kind: 'discard', entry: run.entries[0] })
fake.confirm.mockResolvedValueOnce(false)
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(fake.confirm).toHaveBeenCalledWith(
expect.objectContaining({ message: expect.not.stringContaining('workspace directory') }),
)
expect(api.discardMultiRunEntry).not.toHaveBeenCalled()
})
it('fuses selected results and opens the fusion session', async () => {
const fake = createFakeContext()
const api = makeApi()
const run = multiRun({
id: 3,
name: 'sweep',
baseRef: 'main',
entries: [
entry({ id: 1, sessionId: 'ses_1', isolated: true }),
entry({ id: 2, sessionId: 'ses_2', isolated: true }),
],
fusions: [],
})
api.listMultiRuns.mockResolvedValue([run])
api.fuseMultiRun.mockImplementation(async (_runId, request) =>
multiRun({ fusions: [fusion({ requestId: request.requestId, sessionId: 'ses_f' })] }),
)
fake.list.mockReturnValue([model({ providerID: 'anthropic', id: 'claude', name: 'Claude' })])
fake.select
.mockResolvedValueOnce({ kind: 'run', run })
.mockResolvedValueOnce({ kind: 'fuse' })
.mockResolvedValueOnce(0)
.mockResolvedValueOnce(1)
.mockResolvedValueOnce(-1)
.mockResolvedValueOnce('anthropic/claude')
.mockResolvedValueOnce(true)
fake.prompt.mockResolvedValueOnce('compare').mockResolvedValueOnce('main')
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(api.fuseMultiRun).toHaveBeenCalledWith(
3,
expect.objectContaining({
entryIds: [1, 2],
model: 'anthropic/claude',
instructions: 'compare',
isolate: true,
baseRef: 'main',
requestId: expect.any(String),
}),
)
expect(fake.prompt).toHaveBeenNthCalledWith(
2,
expect.objectContaining({ title: 'Start from', value: 'main' }),
)
expect(fake.open).toHaveBeenCalledWith('ses_f')
})
it('forces isolation when a selected source is not isolated', async () => {
const fake = createFakeContext()
const api = makeApi()
const run = multiRun({
id: 3,
name: 'sweep',
entries: [
entry({ id: 1, sessionId: 'ses_1', isolated: false }),
entry({ id: 2, sessionId: 'ses_2', isolated: true }),
],
fusions: [],
})
api.listMultiRuns.mockResolvedValue([run])
api.fuseMultiRun.mockImplementation(async (_runId, request) =>
multiRun({ fusions: [fusion({ requestId: request.requestId })] }),
)
fake.list.mockReturnValue([model({ providerID: 'anthropic', id: 'claude', name: 'Claude' })])
fake.select
.mockResolvedValueOnce({ kind: 'run', run })
.mockResolvedValueOnce({ kind: 'fuse' })
.mockResolvedValueOnce(0)
.mockResolvedValueOnce(1)
.mockResolvedValueOnce(-1)
.mockResolvedValueOnce('anthropic/claude')
fake.prompt.mockResolvedValueOnce(undefined).mockResolvedValueOnce(undefined)
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(api.fuseMultiRun).toHaveBeenCalledWith(3, expect.objectContaining({ isolate: true }))
expect(fake.select).toHaveBeenCalledTimes(6)
})
it('reports a failed fusion', async () => {
const fake = createFakeContext()
const api = makeApi()
const run = multiRun({
id: 3,
name: 'sweep',
entries: [entry({ id: 1, sessionId: 'ses_1' }), entry({ id: 2, sessionId: 'ses_2' })],
fusions: [],
})
api.listMultiRuns.mockResolvedValue([run])
api.fuseMultiRun.mockImplementation(async (_runId, request) =>
multiRun({
fusions: [fusion({ requestId: request.requestId, status: 'failed', sessionId: null, error: 'model overloaded' })],
}),
)
fake.list.mockReturnValue([model()])
fake.select
.mockResolvedValueOnce({ kind: 'run', run })
.mockResolvedValueOnce({ kind: 'fuse' })
.mockResolvedValueOnce(0)
.mockResolvedValueOnce(1)
.mockResolvedValueOnce(-1)
.mockResolvedValueOnce('openai/gpt-5')
.mockResolvedValueOnce(false)
fake.prompt.mockResolvedValueOnce(undefined)
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(fake.toast).toHaveBeenCalledWith({ variant: 'error', message: 'model overloaded' })
expect(fake.open).not.toHaveBeenCalled()
})
it('lists unavailable sources when the Manager rejects the fusion', async () => {
const fake = createFakeContext()
const api = makeApi()
const run = multiRun({
id: 3,
name: 'sweep',
entries: [entry({ id: 1, sessionId: 'ses_1' }), entry({ id: 2, sessionId: 'ses_2' })],
fusions: [],
})
api.listMultiRuns.mockResolvedValue([run])
api.fuseMultiRun.mockRejectedValue(
new ManagerApiError('conflict', 409, 'FUSION_SOURCES_UNAVAILABLE', 'fuse multi-run', {
unavailableSources: [
{ entryId: 1, model: 'openai/gpt-5', reason: 'not-started', message: 'has not started' },
{ entryId: 2, model: 'anthropic/claude', reason: 'failed', message: 'failed' },
],
}),
)
fake.list.mockReturnValue([model()])
fake.select
.mockResolvedValueOnce({ kind: 'run', run })
.mockResolvedValueOnce({ kind: 'fuse' })
.mockResolvedValueOnce(0)
.mockResolvedValueOnce(1)
.mockResolvedValueOnce(-1)
.mockResolvedValueOnce('openai/gpt-5')
.mockResolvedValueOnce(false)
fake.prompt.mockResolvedValueOnce(undefined)
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(fake.toast).toHaveBeenCalledWith({
variant: 'error',
message: 'openai/gpt-5: has not started\nanthropic/claude: failed',
})
})
it('reports a list failure', async () => {
const fake = createFakeContext()
const api = makeApi()
api.listMultiRuns.mockRejectedValue(new ManagerApiError('list failed', 500, 'boom', 'list multi-runs'))
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(fake.toast).toHaveBeenCalledWith({ variant: 'error', message: 'list failed' })
})
it('reports an outdated Manager when the list route is missing', async () => {
const fake = createFakeContext()
const api = makeApi()
api.listMultiRuns.mockRejectedValue(new ManagerApiError('not found', 404, null, 'list multi-runs'))
await runMultiRunCommand(fake.context, depsFor(api), '/multirun')
expect(fake.toast).toHaveBeenCalledWith({ variant: 'error', message: MULTI_RUN_ROUTE_MISSING })
})
})