diff --git a/packages/provider-bridge-acp/src/bridge/bridge.test.ts b/packages/provider-bridge-acp/src/bridge/bridge.test.ts index 06f4cd4ce..73aa9e83c 100644 --- a/packages/provider-bridge-acp/src/bridge/bridge.test.ts +++ b/packages/provider-bridge-acp/src/bridge/bridge.test.ts @@ -1210,11 +1210,49 @@ describe("acp bridge", () => { }); }); - it("falls back to the synthetic model when the list command prints no models", async () => { - const emptyId = sendModelList({ modelLines: "no model lines here" }); - expect((await waitForResponse(emptyId)).result).toMatchObject({ - models: [{ id: "acp-default", isDefault: true }], + it.each([ + ["exits unsuccessfully", "process.exit(2)"], + ["prints no models", "process.stdout.write('no model lines here')"], + ["times out", "setInterval(() => {}, 1000)"], + ])( + "fails model/list when the configured command %s without a cached catalog", + async (_failure, script) => { + const failingId = sendModelList({ + agent: { command: process.execPath, args: ["-e", script] }, + modelListArgs: ["--"], + }); + const response = await waitFor( + () => findResponse(failingId), + `response ${failingId}`, + 40_000, + ); + expect(response.error?.message).toBe( + "ACP model list command failed to provide a model catalog.", + ); + expect(response.result).toBeUndefined(); + }, + 45_000, + ); + + it("keeps the last good CLI catalog when the same command later fails", async () => { + const scriptPath = join(workspaceDir, "model-list.cjs"); + writeFileSync( + scriptPath, + "process.stdout.write('cached-model - Cached Model\\n')", + ); + const launch = { + agent: { command: process.execPath, args: [scriptPath] }, + modelListArgs: ["--"], + }; + const first = await waitForResponse(sendModelList(launch)); + expect(first.result).toMatchObject({ + models: [{ id: "cached-model", displayName: "Cached Model" }], }); + + writeFileSync(scriptPath, "process.exit(2)"); + const second = await waitForResponse(sendModelList(launch)); + expect(second.error).toBeUndefined(); + expect(second.result).toEqual(first.result); }); it("keeps CLI reasoning on the resolved model variant instead of ACP config", async () => {