Skip to content

Show loading placeholder while waiting for assistant response#2270

Open
gary149 wants to merge 3 commits into
mainfrom
claude/reduce-chat-lag-761V1
Open

Show loading placeholder while waiting for assistant response#2270
gary149 wants to merge 3 commits into
mainfrom
claude/reduce-chat-lag-761V1

Conversation

@gary149
Copy link
Copy Markdown
Collaborator

@gary149 gary149 commented May 13, 2026

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

  • Added showPendingPlaceholder derived state that displays a loading placeholder when:
    • A request is pending (pending is true)
    • AND the last message is not already an empty assistant message (to avoid duplicate placeholders)
  • Renders a ChatMessage component with loading={true} and empty content when the condition is met
  • The placeholder uses a special "pending-placeholder" ID to distinguish it from actual messages

Implementation Details

  • Uses Svelte 5 $derived rune to reactively compute when the placeholder should display
  • The placeholder message has from: "assistant" to match the expected message structure
  • Positioned after the message list but before the ModelSwitch component in the render order
  • Respects read-only mode and shared conversation settings via existing isReadOnly and shared props

https://claude.ai/code/session_01JRV3wG9NGjyM8buvtY88iA

claude added 3 commits May 12, 2026 14:59
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.
`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.
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.

2 participants