diff --git a/.github/pr-assets/730/after-chat-first-click-raw.png b/.github/pr-assets/730/after-chat-first-click-raw.png new file mode 100644 index 000000000..038bbb5fa Binary files /dev/null and b/.github/pr-assets/730/after-chat-first-click-raw.png differ diff --git a/.github/pr-assets/730/after-chat-first-click.png b/.github/pr-assets/730/after-chat-first-click.png new file mode 100644 index 000000000..47d8e9f2b Binary files /dev/null and b/.github/pr-assets/730/after-chat-first-click.png differ diff --git a/.github/pr-assets/730/before-chat-first-click.png b/.github/pr-assets/730/before-chat-first-click.png new file mode 100644 index 000000000..ff3679ddd Binary files /dev/null and b/.github/pr-assets/730/before-chat-first-click.png differ diff --git a/.github/pr-assets/730/index.html b/.github/pr-assets/730/index.html new file mode 100644 index 000000000..7e33c9b5d --- /dev/null +++ b/.github/pr-assets/730/index.html @@ -0,0 +1,71 @@ + + + + + +PR #730 — fix(chat): first conversation click + + + + + +

fix(chat): load message history on first conversation click

+

PR #730 — Closes #729

+ +
+
+

Bug

+

First conversation click from clean state shows empty placeholder instead of messages

+
+
+

Root Cause

+

skipNextHistoryRef unconditionally set on empty→non-empty transition, skipping loadHistory()

+
+
+

Fix

+

Guard skip with expectingRunRef.current — only active during new-chat send flow

+
+
+ +
+ Same instance (claw:3000 backend), same user (kai/Master), same agent (glm thục bô), same conversation (Chat a95c8ffa), light theme. Callout borders mark the review area. +
+ +
+

Chat — First Click from Clean State

+
+
+
BEFORE
+ Before: empty placeholder on first click +

Before: Clicking "Chat a95c8ffa" from initial state — conversation highlighted but main area shows "Start a conversation" placeholder. Messages never load.

+
+
+
AFTER
+ After: messages load on first click +

After: Same click — conversation messages load immediately. The 5-message history is displayed correctly on first click.

+
+
+
+ + diff --git a/ui/web/src/pages/chat/hooks/use-chat-messages.ts b/ui/web/src/pages/chat/hooks/use-chat-messages.ts index 6bee88fc1..a95067ece 100644 --- a/ui/web/src/pages/chat/hooks/use-chat-messages.ts +++ b/ui/web/src/pages/chat/hooks/use-chat-messages.ts @@ -58,7 +58,14 @@ export function useChatMessages(sessionKey: string, agentId: string) { if (sessionKey === prevKeyRef.current) return; const wasEmpty = !prevKeyRef.current; prevKeyRef.current = sessionKey; - if (wasEmpty) { skipNextHistoryRef.current = true; return; } // new-chat send flow, don't reset + if (wasEmpty) { + // Only skip history when a send is in flight (expectingRunRef). Selecting + // an existing conversation from the sidebar must still load messages. + if (expectingRunRef.current) { + skipNextHistoryRef.current = true; + } + return; + } setStreamText(null); setThinkingText(null); setToolStream([]); setIsRunning(false); setActivity(null); setBlockReplies([]); setTeamTasks([]);