fix(sessions): keep rectification result titles when a new chat opens

The case insert trigger writes the result time, then the existing open persist sends the minted title back. A before-update guard keeps that result unless the user chose a non-automatic name, and a new session reads the stored title into the sidebar.
This commit is contained in:
jesse-ux
2026-09-25 02:04:56 +08:00
parent 88fe67df9b
commit a94a1d6748
6 changed files with 71 additions and 4 deletions
@@ -3,6 +3,7 @@
import { useEffect, useRef, useState, type Dispatch, type MutableRefObject, type SetStateAction } from "react";
import { resolveSessionTitle } from "@/lib/agent-reply";
import { fetchSessionDetail } from "@/lib/home-cloud-sync";
import { rectificationOpenIdentity } from "@/lib/rectification-session-open";
import { showChatNotice as setComposerNotice } from "@/lib/chat-notice";
import { writeSessionUrl } from "@/lib/chat-session-url";
@@ -292,6 +293,17 @@ export function useRectificationSurface(params: RectificationSurfaceParams) {
};
setSessions((current) => [merged, ...current.filter((session) => session.id !== merged.id)]);
void persistSession(merged).catch(() => {});
// New sessions have no local title to preserve (BUG-699). The case insert
// trigger already wrote the result title. Read that back so the sidebar
// does not keep the minted "生时校正" after persist.
if (!existing) {
void fetchSessionDetail(opened.sessionId, modelCatalog).then((serverSession) => {
if (!serverSession || serverSession.sessionType !== "birth_time_rectification") return;
updateSession(opened.sessionId, (session) => (
session.title === serverSession.title ? session : { ...session, title: serverSession.title }
));
}).catch(() => {});
}
// One reveal: turns and snapshot are read before the surface mounts, so
// the reader never sees an empty transcript or an empty question area