fix(web): persist thinking, title sessions distinctly, and send follow-ups from the answer
Thinking disappeared on failure and never reached session storage. Keep the sanitized chain on disk and on errors, and regroup the sidebar around reports, charts, favorites, and dated history titles. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -50,6 +50,14 @@ test("chat session schema preserves the safe agent execution receipt", () => {
|
||||
assert.deepEqual(parsed.messages[0]?.agentExecutionReceipt, receipt);
|
||||
});
|
||||
|
||||
test("chat session schema keeps sanitized thinking text on assistant messages", () => {
|
||||
const parsed = chatSessionWriteSchema.parse({
|
||||
...values,
|
||||
messages: [{ role: "assistant", text: "回答", thinkingText: "先看今日节奏。" }],
|
||||
});
|
||||
assert.equal(parsed.messages[0]?.thinkingText, "先看今日节奏。");
|
||||
});
|
||||
|
||||
test("chat session writes use same-origin API instead of browser-to-Supabase requests", async () => {
|
||||
const calls: Array<{ url: string; init?: RequestInit }> = [];
|
||||
await writeChatSession(sessionId, values, "update", async (url, init) => {
|
||||
@@ -112,6 +120,7 @@ test("session API owns create and update while answer UI keeps sync failures out
|
||||
const itemRoute = readFileSync(new URL("../src/app/api/sessions/[id]/route.ts", import.meta.url), "utf8");
|
||||
const contract = readFileSync(new URL("../src/lib/chat-session-write-contract.ts", import.meta.url), "utf8");
|
||||
|
||||
assert.match(page, /thinkingText: message\.thinkingText/);
|
||||
assert.match(page, /writeChatSession\(session\.id, values, mode\)/);
|
||||
assert.doesNotMatch(page, /云端同步失败.*回答仍保留在当前页面/);
|
||||
assert.match(collectionRoute, /export async function POST/);
|
||||
@@ -122,7 +131,7 @@ test("session API owns create and update while answer UI keeps sync failures out
|
||||
assert.match(collectionRoute, /ChatSessionBodyTooLargeError/);
|
||||
assert.match(itemRoute, /ChatSessionBodyTooLargeError/);
|
||||
assert.match(collectionRoute, /const \{ id, \.\.\.values \} = parsed\.data/);
|
||||
assert.match(contract, /function limitTranscriptSize<Output extends \{ messages: Array<\{ text: string \}> \}>/);
|
||||
assert.match(contract, /function limitTranscriptSize<Output extends \{ messages: Array<\{ text: string; thinkingText\?: string \}> \}>/);
|
||||
assert.match(contract, /\): z\.ZodType<Output> \{/);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user