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:
@@ -19,6 +19,7 @@ const chatMessageSchema = z.object({
|
||||
// is strict and a client running the previous bundle still sends them; rejecting the
|
||||
// whole write would lose that user's message rather than a dead field.
|
||||
suggestions: z.array(z.string().max(200)).max(3).optional(),
|
||||
thinkingText: z.string().max(4_000).optional(),
|
||||
techniqueTruth: z.string().max(120).optional(),
|
||||
agentExecutionReceipt: agentExecutionReceiptSchema.optional(),
|
||||
workflowReceipt: workflowReceiptSchema.optional(),
|
||||
@@ -34,11 +35,14 @@ const chatSessionWriteObjectSchema = z.object({
|
||||
updated_at: z.string().datetime(),
|
||||
}).strict();
|
||||
|
||||
function limitTranscriptSize<Output extends { messages: Array<{ text: string }> }>(
|
||||
function limitTranscriptSize<Output extends { messages: Array<{ text: string; thinkingText?: string }> }>(
|
||||
schema: z.ZodType<Output>,
|
||||
): z.ZodType<Output> {
|
||||
return schema.superRefine((value, context) => {
|
||||
const totalChars = value.messages.reduce((sum, message) => sum + message.text.length, 0);
|
||||
const totalChars = value.messages.reduce(
|
||||
(sum, message) => sum + message.text.length + (message.thinkingText?.length ?? 0),
|
||||
0,
|
||||
);
|
||||
if (totalChars > CHAT_SESSION_MAX_TOTAL_MESSAGE_CHARS) {
|
||||
context.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
@@ -86,6 +90,7 @@ export type ChatSessionWrite = Readonly<{
|
||||
role: "user" | "assistant";
|
||||
text: string;
|
||||
suggestions?: readonly string[];
|
||||
thinkingText?: string;
|
||||
techniqueTruth?: string;
|
||||
agentExecutionReceipt?: AgentExecutionReceipt;
|
||||
workflowReceipt?: WorkflowReceipt;
|
||||
|
||||
Reference in New Issue
Block a user