395ed91891
A brand-new session's first turn persists to the SessionDB a beat after the gateway emits message.complete, so a refresh fired in that window gets a listSessions(min_messages=1) page that omits the new row. sessionsToKeep() already shields the *active* chat from this race, but a session you started and then navigated away from is — at the next refresh — neither working, pinned, nor active, so mergeSessionPage() evicts it. Nothing re-fetches afterward, so it stays gone until the app restarts. Track sessions whose turn just settled (a real working->idle transition) in a short, auto-expiring grace window and add them to the merge keep-set. This bridges the persist race for non-active chats without resurrecting deleted rows (mergeSessionPage only revives rows still in the in-memory list, which optimistic delete/archive already drop). Repro: start a new chat, send a message, then click another session before the reply lands — the new session vanishes from the sidebar.