fix(ui): show Loading rather than "No messages yet" while history loads - #490
Draft
mprokopov wants to merge 1 commit into
Draft
fix(ui): show Loading rather than "No messages yet" while history loads#490mprokopov wants to merge 1 commit into
mprokopov wants to merge 1 commit into
Conversation
For a runtime-backed session the chat pane derives messages from the runtime event history instead of the persisted message store. `runtimeEventsToMessages` returns an array, so before the history replay resolves it returns `[]` — and the empty state renders on `displayMessages.length === 0`, while "Loading…" only renders on `!displayMessages`. So the pane says "No messages yet. Type a message below to start the conversation." for the whole duration of the replay. On a slow gateway that is 20-40s of a populated session claiming to be empty, which reads as data loss rather than as loading. (See the companion fix for why the replay is slow.) Hold `runtimeMessages` at null until the replay has come back, so the existing loading branch is used. The flag is reset per session alongside the other per-session state, and is set on failure as well as success — `listRuntimeEvents` is deliberately best-effort and returns `[]` for a non-JSON or error response, so a failed replay must fall through to the empty state rather than sit on "Loading…" forever.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A populated session renders as empty for as long as its history takes to load.
For a runtime-backed session the chat pane derives messages from the runtime event history rather than the persisted message store (
page.tsx,displayMessages).runtimeEventsToMessagesreturns an array, so before the replay resolves it returns[]:displayMessages.length === 0Loading…renders only on!displayMessagesSo the pane shows "No messages yet. Type a message below to start the conversation." for the entire replay, on a session that has plenty of messages.
What it looks like
A 38-event session took 20s to replay (see #489 for why). For those 20s the UI actively states the session is empty and invites you to start it — which reads as data loss, not as loading. The events were all present the whole time: 18
agent.messageamong them.Change
Hold
runtimeMessagesatnulluntil the replay has returned, so the existing loading branch is used. Three details:listRuntimeEventsis deliberately best-effort — it returns[]for a non-JSON or error response rather than throwing — so a failed replay has to fall through to the empty state instead of sitting onLoading…forevereslintreports no newexhaustive-depswarningChecks
tsc --noEmitexit 0,eslintexit 0 (one pre-existing warning inonboarding/page.tsx, unrelated).Relationship to #489
Independent but complementary. #489 makes the replay fast; this makes the wait honest. Either alone leaves a real gap — with #489 only, a slow or large session still flashes a false empty state; with this only, you wait 20s on a spinner.