diff --git a/src/main/acp/discovery/acp-listing-session-models.test.ts b/src/main/acp/discovery/acp-listing-session-models.test.ts index db6633c8fb2..987d1237c05 100644 --- a/src/main/acp/discovery/acp-listing-session-models.test.ts +++ b/src/main/acp/discovery/acp-listing-session-models.test.ts @@ -24,7 +24,9 @@ const LEARNED_EFFORTS = [ it('publishes inventory before a slow optional effort reply and retains its valid late result', async () => { vi.useFakeTimers() - onTestFinished(() => vi.useRealTimers()) + onTestFinished(() => { + vi.useRealTimers() + }) const late = Promise.withResolvers< Awaited> @@ -44,7 +46,10 @@ it('publishes inventory before a slow optional effort reply and retains its vali deleteSession: async () => ({}), close: async () => {} } - const run = runAgentModelCatalogSession( + const run = runAgentModelCatalogSession< + AcpModelCatalogSessionConnection, + Awaited> + >( () => connection, (connection, ready) => readSessionModels( @@ -164,8 +169,18 @@ function accumulatedCatalogHarness(count: number) { serialize: async (_id, task) => task(), scopeOwned: async () => null })) - const read = (waitForListing = true, selectedModel?: string) => - externalRead({ agent: 'opencode2', workspacePath: '/workspace', waitForListing, selectedModel }) + const read = async (waitForListing = true, selectedModel?: string) => { + const result = await externalRead({ + agent: 'opencode2', + workspacePath: '/workspace', + waitForListing, + selectedModel + }) + if (result.origin === 'unknown') { + throw new Error('Expected the listing inventory') + } + return result + } onTestFinished(() => service.stop()) const answer = (index: number) => { const request = requests[index]! @@ -178,7 +193,9 @@ it.each([10, 100])( 'accumulates %i untargeted menus without publishing the full catalog per reply', async (count) => { vi.useFakeTimers() - onTestFinished(() => vi.useRealTimers()) + onTestFinished(() => { + vi.useRealTimers() + }) const h = accumulatedCatalogHarness(count) const first = h.read() await vi.advanceTimersByTimeAsync(0) @@ -211,7 +228,9 @@ it.each(['snapshot', 'deadline', 'selected'])( 'exposes accumulated menus at a %s boundary while the next switch is unanswered', async (boundary) => { vi.useFakeTimers() - onTestFinished(() => vi.useRealTimers()) + onTestFinished(() => { + vi.useRealTimers() + }) const h = accumulatedCatalogHarness(5) const first = h.read() await first @@ -259,7 +278,9 @@ it.each(['snapshot', 'deadline', 'selected'])( it('keeps a slow OpenCode 1.x version response and selects its command listing', async () => { vi.useFakeTimers() - onTestFinished(() => vi.useRealTimers()) + onTestFinished(() => { + vi.useRealTimers() + }) const version = Promise.withResolvers<{ version: string }>() const requested = Promise.withResolvers() const base = acpLaunchSpecFor('opencode')! diff --git a/src/main/acp/discovery/acp-model-catalog-selected-demand.test.ts b/src/main/acp/discovery/acp-model-catalog-selected-demand.test.ts index 0eb2b91f5eb..a768e570567 100644 --- a/src/main/acp/discovery/acp-model-catalog-selected-demand.test.ts +++ b/src/main/acp/discovery/acp-model-catalog-selected-demand.test.ts @@ -83,6 +83,9 @@ it('starts the first OMP listing on demand collected before admission, without a selectedModel: 'provider/selected', waitForListing: true }) + if (result.origin === 'unknown') { + throw new Error('Expected the selected model inventory') + } expect(result.models?.find((row) => row.id === 'provider/selected')).toMatchObject({ efforts: [{ value: 'high', label: 'High' }] }) diff --git a/src/main/native-chat/agent-model-catalog/agent-model-catalog-shared-listing.test.ts b/src/main/native-chat/agent-model-catalog/agent-model-catalog-shared-listing.test.ts index c35f172f2d0..9720d720134 100644 --- a/src/main/native-chat/agent-model-catalog/agent-model-catalog-shared-listing.test.ts +++ b/src/main/native-chat/agent-model-catalog/agent-model-catalog-shared-listing.test.ts @@ -162,7 +162,9 @@ it.each([false, true])( 'keeps a slow successful listing after its reader leaves (saved=%s)', async (saved) => { vi.useFakeTimers() - onTestFinished(() => vi.useRealTimers()) + onTestFinished(() => { + vi.useRealTimers() + }) const h = sharedListingHarness() if (saved) { const initial = h.service.read({ agent: 'codex', waitForListing: true }) @@ -186,7 +188,12 @@ it.each([false, true])( const reader = h.service.read({ agent: 'codex', waitForListing: true }) await vi.advanceTimersByTimeAsync(30_000) expect(await reader).toMatchObject({ listingInProgress: true, waitExpired: true }) - expect(h.service.snapshot({ agent: 'codex' }).models?.[0]?.id).toBe(saved ? 'saved' : undefined) + const snapshot = h.service.snapshot({ agent: 'codex' }) + if (saved) { + expect(snapshot).toMatchObject({ models: [{ id: 'saved' }] }) + } else { + expect(snapshot.origin).toBe('unknown') + } await vi.advanceTimersByTimeAsync(15_000) answer.resolve({ ...listing('slow-success'), complete: true }) await vi.advanceTimersByTimeAsync(0) @@ -201,7 +208,9 @@ it.each([true, false])( 'delivers progress and waits for a changed observation (progress=%s)', async (progress) => { vi.useFakeTimers() - onTestFinished(() => vi.useRealTimers()) + onTestFinished(() => { + vi.useRealTimers() + }) const h = sharedListingHarness() const answer = Promise.withResolvers() let publish: AgentModelCatalogProgress | undefined @@ -324,7 +333,9 @@ it('fences obsolete progress and final results while retaining admission until c it('withdraws an abandoned queued scope while the two admitted listings continue', async () => { vi.useFakeTimers() - onTestFinished(() => vi.useRealTimers()) + onTestFinished(() => { + vi.useRealTimers() + }) const h = sharedListingHarness() void h.service.demand({ agent: 'codex', workspacePath: '/own-a' }) void h.service.demand({ agent: 'codex', workspacePath: '/own-b' }) diff --git a/src/main/native-chat/agent-model-catalog/agent-model-catalog-shared-setup.test.ts b/src/main/native-chat/agent-model-catalog/agent-model-catalog-shared-setup.test.ts index a2a15342d1c..613981d2654 100644 --- a/src/main/native-chat/agent-model-catalog/agent-model-catalog-shared-setup.test.ts +++ b/src/main/native-chat/agent-model-catalog/agent-model-catalog-shared-setup.test.ts @@ -229,7 +229,9 @@ it("keeps the folder's defaults when they arrive after a shorter last reader lef it('delivers inventory before slow folder defaults, then delivers the proven default', async () => { vi.useFakeTimers() - onTestFinished(() => vi.useRealTimers()) + onTestFinished(() => { + vi.useRealTimers() + }) const h = harness(agent) const settings = Promise.withResolvers() h.folder.settings = settings @@ -336,7 +338,9 @@ it.each([10, 100])( 'registers %i readers and unique targets once per shared flight', async (count) => { vi.useFakeTimers() - onTestFinished(() => vi.useRealTimers()) + onTestFinished(() => { + vi.useRealTimers() + }) for (const delayedScope of [false, true]) { const h = harness('opencode2') const scope = Promise.withResolvers() diff --git a/src/main/pi/rpc/options/rpc-model-catalog-probe.test.ts b/src/main/pi/rpc/options/rpc-model-catalog-probe.test.ts index 83731374522..d58a9d477aa 100644 --- a/src/main/pi/rpc/options/rpc-model-catalog-probe.test.ts +++ b/src/main/pi/rpc/options/rpc-model-catalog-probe.test.ts @@ -4,7 +4,9 @@ import type { AgentModelCatalogSuccess } from '../../../native-chat/agent-model- it('publishes a slow inventory independently of state, then keeps the late default', async () => { vi.useFakeTimers() - onTestFinished(() => vi.useRealTimers()) + onTestFinished(() => { + vi.useRealTimers() + }) const inventory = Promise.withResolvers() const state = Promise.withResolvers() const requested = Promise.withResolvers() diff --git a/src/renderer/src/components/agent/agent-launch-picker-acquisition.test.ts b/src/renderer/src/components/agent/agent-launch-picker-acquisition.test.ts index 27c29331d57..11d58425ccb 100644 --- a/src/renderer/src/components/agent/agent-launch-picker-acquisition.test.ts +++ b/src/renderer/src/components/agent/agent-launch-picker-acquisition.test.ts @@ -230,13 +230,19 @@ it('keeps an open picker subscribed after usable progress until late enrichment onTestFinished(close) await vi.waitFor(() => expect(published[0]?.catalog).toMatchObject({ listingInProgress: true })) next = enriched.promise - inventory.resolve({ origin: 'probe', models: [model('listed')], listingInProgress: true }) + inventory.resolve({ + origin: 'probe', + fetchedAt: 1, + models: [model('listed')], + listingInProgress: true + }) await vi.waitFor(() => expect(published[0]?.catalog).toMatchObject({ models: [{ id: 'listed' }] }) ) expect(published[0]?.catalogRead).toBe('pending') enriched.resolve({ origin: 'probe', + fetchedAt: 2, models: [ { ...model('listed'), defaultEffort: 'high', efforts: [{ value: 'high', label: 'High' }] } ]