feat(chat): persist safe Codex next-turn model selection
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { chatModelLabel, chatModelSelectionNote, supportsChatModels } from "../src/chatModels.js";
|
||||
import { PipelinesRepository } from "../src/repository.js";
|
||||
|
||||
test("Codex and OpenCode expose model selection, unverified backends do not", () => {
|
||||
for (const backend of [undefined, "", "opencode", "codex"]) assert.equal(supportsChatModels(backend), true);
|
||||
for (const backend of ["claude", "unknown"]) assert.equal(supportsChatModels(backend), false);
|
||||
});
|
||||
|
||||
test("model control distinguishes saved next-turn choice from remote current model", () => {
|
||||
assert.equal(chatModelLabel({ model: "fixture-current" }), "fixture-current");
|
||||
assert.equal(chatModelLabel({ model: "fixture-selected", model_selection: "next_turn" }), "fixture-selected · next turn");
|
||||
assert.equal(chatModelLabel({ model: null }), "Model");
|
||||
assert.match(chatModelSelectionNote("codex"), /Saved by Pipelines for the next turn/);
|
||||
assert.match(chatModelSelectionNote("codex"), /Does not resume/);
|
||||
});
|
||||
|
||||
test("model switch reply preserves local next-turn acknowledgement", async () => {
|
||||
let sent;
|
||||
const repo = new PipelinesRepository({ call: async (request) => {
|
||||
sent = request;
|
||||
return { chat_model: { ...request.chat_model, selection: "next_turn" } };
|
||||
} });
|
||||
const selected = await repo.switchChatModel("fixture-thread", "fixture-provider", "fixture-model");
|
||||
assert.deepEqual(sent.chat_model, { session_id: "fixture-thread", provider: "fixture-provider", model: "fixture-model" });
|
||||
assert.equal(selected.selection, "next_turn");
|
||||
});
|
||||
Reference in New Issue
Block a user