fix: repair chat history from DB when Goose session has empty placeholders

Portal direct chat → goosed escalation can leave hollow Goose messages while
h5_conversation_messages retains the full dialogue. Backfill session detail
from DB, extend snapshot list fallback, and keep stored session id on transient
boot failures so refresh no longer looks like a blank new chat.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-05 11:04:25 +08:00
parent d3239ff292
commit 614837e199
7 changed files with 371 additions and 9 deletions
+4 -2
View File
@@ -1611,8 +1611,10 @@ export function createTkmindProxy({
}
const directSessionIds = [...owned].filter(isDirectChatSessionId);
if (directSessionIds.length > 0 && sessionSnapshotService?.isEnabled?.()) {
for (const sessionId of directSessionIds) {
const ownedMissingFromGoose = [...owned].filter((sessionId) => !sessionsById.has(sessionId));
const snapshotFallbackIds = [...new Set([...directSessionIds, ...ownedMissingFromGoose])];
if (snapshotFallbackIds.length > 0 && sessionSnapshotService?.isEnabled?.()) {
for (const sessionId of snapshotFallbackIds) {
if (sessionsById.has(sessionId)) continue;
const snapshot = await sessionSnapshotService.get(sessionId).catch(() => null);
if (!snapshot?.session) continue;