Files
plugins/packages/agent-console/test/v1/acp-model-switch.test.ts
T
qingnian108 654d3bea1c agent-console 1.3.6: keep chat pinned to the bottom on tall virtualized replies (#787)
agent-console 1.3.6: the chat stays stuck to the bottom as virtualized rows measure taller than their estimate, while a reply streams, and when a hidden view becomes visible. Only an upward scroll during a user gesture leaves the bottom, and jump follows rows as they measure. An ACP default model the session skipped is no longer recorded as synced, so the next idle send tries it again.

Reviewed at baf6475e on mote (HOME=$(mktemp -d), Node 22, npm ci --workspaces=false): tsc daemon+web ok; verify:build byte for byte; vitest 73 files, 544 passed, 17 skipped, with chat-scroll-browser run in Chromium 1248 rather than skipped; bun scripts/check.mjs agent-console ok. With origin/main's Chat.tsx and manager.ts put back and app/ rebuilt, the browser test fails (gap 760 > 2) and both new manager tests fail. 1.3.6 is the next version after dist's 1.3.5. Not tried: the real magpie webviews. PR CI green.
2026-11-06 18:53:53 +08:00

37 lines
2.0 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { createAcpProvider } from "../../daemon/src/providers/acp/provider.js";
afterEach(() => vi.unstubAllEnvs());
describe("ACP explicit model pick vs default validation", () => {
it("validates saved/default models but sends a newly enabled explicit pick beyond the startup snapshot", async () => {
const dir = mkdtempSync(join(tmpdir(), "acp-model-switch-"));
const log = join(dir, "config.jsonl");
vi.stubEnv("FAKE_ACP_CONFIG_OPTIONS", JSON.stringify([
{ id: "model", category: "model", type: "select", currentValue: "magpie/old", options: [{ value: "magpie/old" }] },
]));
vi.stubEnv("FAKE_ACP_CONFIG_LOG", log);
const p = createAcpProvider({ id: "fake-model", name: "Fake ACP", binName: "fake-acp", acpArgs: [], installHint: "" });
const session = await p.createSession({
threadId: "t1", cwd: dir, model: "bogus-saved-model", mode: "default", effort: null, resumeId: null,
launch: { cmd: process.execPath, prefixArgs: [resolve(__dirname, "fixtures/fake-acp-agent.mjs")] },
});
const calls = () => existsSync(log) ? readFileSync(log, "utf8").trim().split("\n").map((x) => JSON.parse(x)) : [];
try {
// 1.3.6: a skipped default reports false so the manager doesn't mark it synced
expect(await session.setModel("bogus-unprefixed-model")).toBe(false);
expect(calls()).toEqual([]); // Both startup and unchecked defaults are rejected.
expect(await session.setModel("magpie/old")).toBe(true);
expect(calls().map((c) => c.value)).toEqual(["magpie/old"]);
await session.setModel("magpie/new", { force: true });
expect(calls().map((c) => c.value)).toEqual(["magpie/old", "magpie/new"]);
} finally {
await session.close();
rmSync(dir, { recursive: true, force: true });
}
});
});