fix(chat): avoid implicit stream reuse
This commit is contained in:
@@ -2,6 +2,7 @@ import { describe, expect, it } from "bun:test";
|
||||
|
||||
import {
|
||||
buildForkedSessionUiState,
|
||||
resolveRequestedStreamSessionId,
|
||||
} from "../../src/routes/chat.js";
|
||||
import {
|
||||
buildPromptWithLearningContext,
|
||||
@@ -14,6 +15,38 @@ import { type SessionTurnRecord } from "../../src/sessions/transcriptStore.js";
|
||||
import { type MemoryStore } from "../../src/memory/store.js";
|
||||
import { type OpencodeRuntimeAdapter } from "../../src/runtime/opencode.js";
|
||||
|
||||
describe("resolveRequestedStreamSessionId", () => {
|
||||
it("uses only explicit session_id for normal chat reuse", () => {
|
||||
const createClientSessionId = () => {
|
||||
throw new Error("should not create a demo session id");
|
||||
};
|
||||
|
||||
expect(
|
||||
resolveRequestedStreamSessionId({
|
||||
sessionId: " existing-session ",
|
||||
promptText: "检查压力异常",
|
||||
createClientSessionId,
|
||||
}),
|
||||
).toBe("existing-session");
|
||||
|
||||
expect(
|
||||
resolveRequestedStreamSessionId({
|
||||
promptText: "检查压力异常",
|
||||
createClientSessionId,
|
||||
}),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("keeps the pressure trend demo on its generated client session id", () => {
|
||||
expect(
|
||||
resolveRequestedStreamSessionId({
|
||||
promptText: "展示最近压力趋势",
|
||||
createClientSessionId: () => "demo-session",
|
||||
}),
|
||||
).toBe("demo-session");
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldGenerateSessionTitle", () => {
|
||||
it("allows auto-title generation for the first turn when the title was not edited", () => {
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user