fix(tui): preserve first message in new sessions (#38542)

Co-authored-by: Kit Langton <kit.langton@gmail.com>
Co-authored-by: James Long <17031+jlongster@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot] 2026-07-23 13:59:51 -04:00 committed by GitHub
commit 18fccac6ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -298,6 +298,12 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
case "session.created":
result.session.invalidate(event.data.sessionID)
void result.session.sync(event.data.sessionID)
// Band-aid: a newly created session starts empty, so live events can be its source of truth.
// Fetching pending inputs and projected messages separately lets promotion move an input between snapshots,
// causing both requests to miss it and overwrite event-built state. Skip those racy initial reads until
// hydration can load pending and projected messages atomically.
sync.complete(`session.pending:${event.data.sessionID}`)
sync.complete(`session.message:${event.data.sessionID}`)
break
case "session.deleted":
removeSession(event.data.sessionID)