
























@@ -1,3 +1,4 @@
1+// Verifies live session model selection, switch queuing, and pending-flag cleanup.
12import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
2334const state = vi.hoisted(() => ({
@@ -63,6 +64,8 @@ type ShouldSwitchParams = Parameters<
6364>[0];
64656566function makeShouldSwitchParams(overrides: Partial<ShouldSwitchParams> = {}): ShouldSwitchParams {
67+// Defaults model an active Anthropic run so individual tests can override
68+// only the persisted/live selection fields under scrutiny.
6669return {
6770cfg: { session: { store: "/tmp/custom-store.json" } },
6871sessionKey: "main",
@@ -232,6 +235,8 @@ describe("live model switch", () => {
232235});
233236234237it("preserves provider when runtime model is a vendor-prefixed OpenRouter id", async () => {
238+// OpenRouter models often contain provider-like slashes. An explicit
239+// runtime provider must keep the full nested model id intact.
235240state.loadSessionStoreMock.mockReturnValue({
236241main: {
237242modelProvider: "openrouter",
@@ -310,6 +315,8 @@ describe("live model switch", () => {
310315});
311316312317it("routes normalized overrides back through persisted ref resolution", async () => {
318+// Normalization strips duplicate provider prefixes before handing the
319+// choice to the shared persisted-ref resolver.
313320state.loadSessionStoreMock.mockReturnValue({
314321main: {
315322providerOverride: "z-ai",
@@ -337,6 +344,8 @@ describe("live model switch", () => {
337344});
338345339346it("queues a live switch only when an active run was aborted", async () => {
347+// Switching live runs is two-phase: abort the active run, then queue the
348+// selected provider/model for the restarted embedded run to consume.
340349state.abortEmbeddedAgentRunMock.mockReturnValue(true);
341350342351const { requestLiveSessionModelSwitch } = await loadModule();
@@ -508,6 +517,8 @@ describe("live model switch", () => {
508517});
509518510519it("clears the stale liveModelSwitchPending flag when models already match", async () => {
520+// A stale pending flag should self-heal once the active runtime already
521+// matches the persisted selection.
511522const sessionEntry = {
512523liveModelSwitchPending: true,
513524providerOverride: "anthropic",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。