fix(odin): show conversation auto-title immediately (no refresh needed)

ensureActive() created the conversation and invalidated the list before the
server-side auto-title was applied (that happens on the message append), so
the sidebar showed "Nová konverzace" until a refresh. Move the
["ai","conversations"] invalidation to persist()'s success path — after the
append (and thus the auto-title) lands.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-06-08 21:22:31 +02:00
parent 434a12b4a8
commit 4b2770a000

View File

@@ -153,6 +153,9 @@ export default function OdinChat() {
})
.then((r) => {
if (!r.ok) return r.json().then((b) => Promise.reject(b?.error));
// The append applies the server-side auto-title and bumps updated_at,
// so refresh the list now (a new conversation gets its real title here).
qc.invalidateQueries({ queryKey: ["ai", "conversations"] });
})
.catch((e) => console.error("[odin] history persist failed", e));
};
@@ -191,7 +194,8 @@ export default function OdinChat() {
const id = b.data.conversation.id as number;
seededId.current = id;
setActiveId(id);
qc.invalidateQueries({ queryKey: ["ai", "conversations"] });
// Don't refresh the list yet — the conversation is still the default
// "Nová konverzace" here; persist() invalidates after the auto-title lands.
return id;
};