fix(chat): load message history on first conversation click#730
Merged
viettranx merged 2 commits intonextlevelbuilder:devfrom Apr 7, 2026
Merged
Conversation
…from clean state The skipNextHistoryRef was unconditionally set when sessionKey transitioned from empty to non-empty. This prevented loadHistory() from running when clicking an existing conversation from the initial /chat page. The skip was only intended for the new-chat send flow where the optimistic message is already displayed. Guard the skip with expectingRunRef so it only activates when a message send is in flight. Closes nextlevelbuilder#729
Before/after screenshots and HTML comparison report showing first conversation click behavior fix.
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.
Problem
Clicking a conversation from the Chat page's initial state (no session selected) does not load messages. The URL updates, sidebar highlights the conversation, but the main area shows "Start a conversation" placeholder. Only after clicking a different conversation do messages load.
Closes #729
Visual Review
Full comparison report
Chat — First Click from Clean State
Before: Clicking "Chat a95c8ffa" from initial state — conversation highlighted but main area shows empty "Start a conversation" placeholder.
After: Same click — conversation messages load immediately on first click.
All captures: same instance (claw backend), same user (kai/Master), same agent (glm thục bô), same conversation. Callout borders mark the review area.
Root Cause
skipNextHistoryRefwas unconditionally set totruewheneversessionKeytransitioned from empty to non-empty (line 61 inuse-chat-messages.ts). This skip was intended only for the new-chat send flow, where an optimistic user message is already displayed andloadHistory()would race withchat.send. However, it also fired when clicking an existing conversation from the sidebar — preventingloadHistory()from running.What changed
ui/web/src/pages/chat/hooks/use-chat-messages.tsskipNextHistoryRefwithexpectingRunRef.currentcheckValidation
pnpm run buildpasseschat.historywas never called on first click