The live question slot disappeared on refresh because it was never written to assistant_message. Attach the current collect_spoken prompt to that turn before finalize so chat history keeps it. Co-authored-by: Cursor <cursoragent@cursor.com>
29 lines
1.7 KiB
TypeScript
29 lines
1.7 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { composeCollectSpokenAssistantText, detachCollectSpokenAssistantText } from "../src/lib/rectification-agentic/v9/collect-prompt.ts";
|
|
import { GENERIC_COLLECT_QUESTION } from "../src/lib/rectification-agentic/user-copy.ts";
|
|
|
|
test("composeCollectSpokenAssistantText joins by exact prompt identity", () => {
|
|
const greeting = "你好,我是生时校正助手。";
|
|
const combined = `${greeting}\n\n${GENERIC_COLLECT_QUESTION}`;
|
|
assert.equal(composeCollectSpokenAssistantText(greeting, GENERIC_COLLECT_QUESTION), combined);
|
|
assert.equal(composeCollectSpokenAssistantText(combined, GENERIC_COLLECT_QUESTION), combined);
|
|
assert.equal(composeCollectSpokenAssistantText("", GENERIC_COLLECT_QUESTION), GENERIC_COLLECT_QUESTION);
|
|
assert.equal(composeCollectSpokenAssistantText(GENERIC_COLLECT_QUESTION, GENERIC_COLLECT_QUESTION), GENERIC_COLLECT_QUESTION);
|
|
assert.equal(composeCollectSpokenAssistantText(greeting, " "), greeting);
|
|
assert.equal(
|
|
composeCollectSpokenAssistantText(` ${greeting} `, ` ${GENERIC_COLLECT_QUESTION} `),
|
|
combined,
|
|
);
|
|
});
|
|
|
|
test("detachCollectSpokenAssistantText removes only an exact trailing stem", () => {
|
|
const greeting = "你好,我是生时校正助手。";
|
|
const combined = `${greeting}\n\n${GENERIC_COLLECT_QUESTION}`;
|
|
assert.equal(detachCollectSpokenAssistantText(combined, GENERIC_COLLECT_QUESTION), greeting);
|
|
assert.equal(detachCollectSpokenAssistantText(greeting, GENERIC_COLLECT_QUESTION), greeting);
|
|
assert.equal(detachCollectSpokenAssistantText(GENERIC_COLLECT_QUESTION, GENERIC_COLLECT_QUESTION), GENERIC_COLLECT_QUESTION);
|
|
assert.equal(detachCollectSpokenAssistantText("", GENERIC_COLLECT_QUESTION), "");
|
|
});
|