fix(cli): surfaced tiny model download errors

Preserved worker-side download errors through TinyTitleClient and included them in tiny-models text and JSON failures.

Fixes #3839
This commit is contained in:
roboomp
2026-06-29 22:56:40 +00:00
parent 0ba736f5bc
commit f5be8953c4
5 changed files with 89 additions and 20 deletions
@@ -1,6 +1,11 @@
import { describe, expect, it } from "bun:test";
import { resolveModels } from "@oh-my-pi/pi-coding-agent/cli/tiny-models-cli";
import { afterEach, describe, expect, it, spyOn, vi } from "bun:test";
import { resolveModels, runTinyModelsCommand } from "@oh-my-pi/pi-coding-agent/cli/tiny-models-cli";
import { TINY_LOCAL_MODELS } from "@oh-my-pi/pi-coding-agent/tiny/models";
import { tinyTitleClient } from "@oh-my-pi/pi-coding-agent/tiny/title-client";
afterEach(() => {
vi.restoreAllMocks();
});
describe("tiny-models download model resolution", () => {
it("excludes load-blocked models from `all` so the bulk prefetch stays green", () => {
@@ -25,4 +30,24 @@ describe("tiny-models download model resolution", () => {
if (!blocked) return;
expect(resolveModels(blocked.key)).toEqual([blocked.key]);
});
it("includes worker error details in JSON failures", async () => {
const output: string[] = [];
spyOn(process.stdout, "write").mockImplementation((chunk: string | Uint8Array) => {
output.push(typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk));
return true;
});
spyOn(tinyTitleClient, "downloadModel").mockResolvedValue({
ok: false,
error: "Error: runtime install failed\n at worker",
});
await expect(
runTinyModelsCommand({ action: "download", model: "lfm2-700m", flags: { json: true } }),
).rejects.toThrow("One or more tiny title models failed to download");
expect(JSON.parse(output.join(""))).toEqual({
results: [{ model: "lfm2-700m", ok: false, error: "Error: runtime install failed\n at worker" }],
});
});
});