Show loading placeholder while waiting for assistant response#2270
Open
gary149 wants to merge 3 commits into
Open
Show loading placeholder while waiting for assistant response#2270gary149 wants to merge 3 commits into
gary149 wants to merge 3 commits into
Conversation
The await on Promise.all((files ?? []).map(file2base64)) in writeMessage always yielded a microtask before addChildren inserted the user message into the reactive tree — even on text-only sends where the array is empty. Short-circuit to [] when there are no files so the bubble can render in the same task as the Enter keydown. Also drop a dead unawaited tick() in ChatInput's submit handler.
This reverts commit a83a5d9.
`pending = true` is set synchronously at the top of writeMessage, but ChatWindow only renders its loader placeholder when messages.length === 0 (i.e. only on the first send of a fresh conversation). For an existing conversation, the user has no visual feedback until writeMessage finishes its async work (file base64 encoding, MCP store hydration) and addChildren inserts the blank assistant node. Render an extra bouncing-dots assistant placeholder at the end of the message list whenever `pending` is true and the in-tree last message isn't already an empty assistant. Once writeMessage gets through to addChildren, that condition flips and the in-tree empty assistant takes over the loader visual — same dots, no double-loader.
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.
Summary
Adds a pending placeholder message to the chat window while waiting for the assistant to respond, improving UX by providing visual feedback during the request-to-response period.
Changes
showPendingPlaceholderderived state that displays a loading placeholder when:pendingis true)ChatMessagecomponent withloading={true}and empty content when the condition is met"pending-placeholder"ID to distinguish it from actual messagesImplementation Details
$derivedrune to reactively compute when the placeholder should displayfrom: "assistant"to match the expected message structureModelSwitchcomponent in the render orderisReadOnlyandsharedpropshttps://claude.ai/code/session_01JRV3wG9NGjyM8buvtY88iA