Skip to content

fix(ui): show Loading rather than "No messages yet" while history loads - #490

Draft
mprokopov wants to merge 1 commit into
LiteLLM-Labs:mainfrom
mprokopov:fix/runtime-chat-loading-state
Draft

fix(ui): show Loading rather than "No messages yet" while history loads#490
mprokopov wants to merge 1 commit into
LiteLLM-Labs:mainfrom
mprokopov:fix/runtime-chat-loading-state

Conversation

@mprokopov

Copy link
Copy Markdown

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). runtimeEventsToMessages returns an array, so before the replay resolves it returns []:

  • the empty state renders on displayMessages.length === 0
  • Loading… renders only on !displayMessages

So 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.message among them.

Change

Hold runtimeMessages at null until the replay has returned, so the existing loading branch is used. Three details:

  • the flag resets per session, alongside the other per-session state, so switching sessions cannot show the previous one's result
  • it is set on failure as well as success. listRuntimeEvents is 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 on Loading… forever
  • dependency arrays updated; eslint reports no new exhaustive-deps warning

Checks

tsc --noEmit exit 0, eslint exit 0 (one pre-existing warning in onboarding/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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant