Files
multica/packages/core/runtimes/cli-version.test.ts
Naiyuan Qing 7d2f20f2ee feat(chat): warn when agent daemon is too old for project context (#5867)
Chat project context (MUL-5150, #5765) is rendered into the run brief by the
daemon, so daemons older than the release that ships it silently drop the
project description while still honoring the server-extracted repos. Mirror
the handoff-note soft gate: resolve the active agent's runtime cli_version
from the warm runtime cache and, when it is a stale release build, surface a
warning next to the composer chip and inside the project submenu. Selection
is never blocked — dev-describe builds and unknown runtimes stay silent.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 13:32:44 +08:00

94 lines
3.8 KiB
TypeScript

import { describe, it, expect } from "vitest";
import {
chatProjectContextSupported,
checkQuickCreateCliVersion,
checkQuickCreateFieldsCliVersion,
handoffSupported,
MIN_CHAT_PROJECT_CONTEXT_CLI_VERSION,
MIN_HANDOFF_CLI_VERSION,
} from "./cli-version";
describe("checkQuickCreateCliVersion", () => {
it("returns ok for a tagged release at or above the minimum", () => {
expect(checkQuickCreateCliVersion("v0.2.21").state).toBe("ok");
expect(checkQuickCreateCliVersion("0.3.1").state).toBe("ok");
});
it("returns too_old for a tagged release below the minimum", () => {
expect(checkQuickCreateCliVersion("v0.2.20").state).toBe("too_old");
expect(checkQuickCreateCliVersion("v0.2.15").state).toBe("too_old");
});
it("returns missing for empty or unparsable input", () => {
expect(checkQuickCreateCliVersion("").state).toBe("missing");
expect(checkQuickCreateCliVersion(undefined).state).toBe("missing");
expect(checkQuickCreateCliVersion("not-a-version").state).toBe("missing");
});
it("treats git-describe dev builds as ok regardless of base tag", () => {
expect(checkQuickCreateCliVersion("v0.2.15-235-gdaf0e935").state).toBe("ok");
expect(checkQuickCreateCliVersion("v0.2.15-235-gdaf0e935-dirty").state).toBe("ok");
expect(checkQuickCreateCliVersion("0.1.0-1-gabc1234").state).toBe("ok");
});
});
describe("checkQuickCreateFieldsCliVersion", () => {
it("requires the first daemon release that transports explicit fields", () => {
expect(checkQuickCreateFieldsCliVersion("0.4.2").state).toBe("too_old");
expect(checkQuickCreateFieldsCliVersion("0.4.3").state).toBe("ok");
expect(checkQuickCreateFieldsCliVersion("v0.4.3-1-gabc1234").state).toBe("ok");
});
});
// Mirrors server/pkg/agent/handoff_version_test.go so the frontend soft-gate
// signal and the server's authoritative one agree by construction.
describe("handoffSupported", () => {
it("supports a tagged release at or above the minimum", () => {
expect(handoffSupported(MIN_HANDOFF_CLI_VERSION)).toBe(true);
expect(handoffSupported("0.4.0")).toBe(true);
expect(handoffSupported("v0.3.28")).toBe(true);
});
it("does not support a tagged release below the minimum", () => {
expect(handoffSupported("0.3.26")).toBe(false);
expect(handoffSupported("0.2.21")).toBe(false);
});
it("fails closed on empty or unparsable input", () => {
expect(handoffSupported("")).toBe(false);
expect(handoffSupported(undefined)).toBe(false);
expect(handoffSupported(null)).toBe(false);
expect(handoffSupported("garbage")).toBe(false);
});
it("treats git-describe dev builds as supported regardless of base tag", () => {
expect(handoffSupported("v0.3.0-5-gabc1234")).toBe(true);
expect(handoffSupported("v0.1.0-235-gdaf0e935-dirty")).toBe(true);
});
});
describe("chatProjectContextSupported", () => {
it("supports a tagged release at or above the minimum", () => {
expect(chatProjectContextSupported(MIN_CHAT_PROJECT_CONTEXT_CLI_VERSION)).toBe(true);
expect(chatProjectContextSupported("v0.4.10")).toBe(true);
expect(chatProjectContextSupported("0.5.0")).toBe(true);
});
it("does not support a tagged release below the minimum", () => {
expect(chatProjectContextSupported("0.4.9")).toBe(false);
expect(chatProjectContextSupported("0.3.28")).toBe(false);
});
it("fails closed on empty or unparsable input", () => {
expect(chatProjectContextSupported("")).toBe(false);
expect(chatProjectContextSupported(undefined)).toBe(false);
expect(chatProjectContextSupported(null)).toBe(false);
expect(chatProjectContextSupported("garbage")).toBe(false);
});
it("treats git-describe dev builds as supported regardless of base tag", () => {
expect(chatProjectContextSupported("v0.4.8-37-g5d0275d68")).toBe(true);
expect(chatProjectContextSupported("v0.1.0-235-gdaf0e935-dirty")).toBe(true);
});
});