fix(feishu): preserve per-chat model state

This commit is contained in:
Hunter B
2026-05-30 23:55:00 -07:00
parent 30db74bcdb
commit feefae16c6
3 changed files with 58 additions and 10 deletions
@@ -12,8 +12,10 @@ import {
parseCommand,
parseList,
parseTextContent,
preservedChatStateFields,
splitMessage,
stripGroupPrefix,
helpText,
validateBridgeConfig
} from "../src/lib.mjs";
@@ -89,12 +91,36 @@ test("commandAction maps bridge commands and falls back to prompts", () => {
kind: "resume",
threadId: "thread-1"
});
assert.deepEqual(commandAction(parseCommand("/model deepseek-v4-pro")), {
kind: "set_model",
modelName: "deepseek-v4-pro"
});
assert.deepEqual(commandAction(parseCommand("/unknown value")), {
kind: "prompt",
prompt: "/unknown value"
});
});
test("helpText documents per-chat model switching", () => {
assert.match(helpText(), /\/model <name\|default>/);
});
test("preservedChatStateFields carries model across state replacement", () => {
assert.deepEqual(
preservedChatStateFields({
threadId: "old-thread",
model: "deepseek-v4-flash",
replyToMessageId: "om_123",
activeTurnId: "turn-1"
}),
{
model: "deepseek-v4-flash",
replyToMessageId: "om_123"
}
);
assert.deepEqual(preservedChatStateFields({ model: null }), { model: null });
});
test("parseApprovalDecisionArgs extracts remember flag", () => {
assert.deepEqual(parseApprovalDecisionArgs("ap_123 remember"), {
approvalId: "ap_123",