Skip to content

fix: prevent stale loading state on previous agent chat reply - #18124

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
dcc123456:fix/agent-chat-loading-state
Aug 12, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
dcc123456:fix/agent-chat-loading-state

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

Summary

fix: prevent stale loading state on previous agent chat reply

sendLoading (= !done) is global — when a new conversation's stream starts it flips to true, and any assistant message matching derivedMessages.length - 1 === i lights up the loading indicator, including the previous conversation's reply.

  • Gate the loading prop on !message.content so a reply that already has content never shows the loading state.
  • Scope the sendLoading prop passed to MessageItem to the last message only, so LoadingDots (keyed on sendLoading && isEmpty(content)) doesn't render on historical replies either.

`sendLoading` (= !done) is global — when a new conversation's stream
starts it flips to true, and any assistant message matching
`derivedMessages.length - 1 === i` lights up the loading indicator,
including the previous conversation's reply.

- Gate the `loading` prop on `!message.content` so a reply that
  already has content never shows the loading state.
- Scope the `sendLoading` prop passed to MessageItem to the last
  message only, so LoadingDots (keyed on
  `sendLoading && isEmpty(content)`) doesn't render on historical
  replies either.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Aug 11, 2026
@dcc123456
dcc123456 requested a review from wangq8 August 11, 2026 11:25
@dcc123456 dcc123456 added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Aug 11, 2026
@dcc123456
dcc123456 marked this pull request as draft August 11, 2026 11:25
@dcc123456
dcc123456 marked this pull request as ready for review August 11, 2026 11:25
@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The chat message rendering logic now limits sendLoading to the latest derived message. Assistant messages display loading only when their content is empty.

Changes

Chat loading indicators

Layer / File(s) Summary
Restrict message loading states
web/src/pages/agent/chat/box.tsx
MessageItem loading now requires empty assistant content. sendLoading is passed only to the latest derived message.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: euvre

Poem

I’m a rabbit with a loading light,
Now only one message glows bright.
Empty replies show the sign,
Older messages stay in line.
Hop, the chat state is right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description includes the required Summary section and clearly explains the stale loading indicator issue and the implemented fix.
Title check ✅ Passed The title clearly and concisely describes the fix for stale loading states in previous agent chat replies.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean fix, LGTM. The two changes together correctly prevent the stale loading indicator from appearing on previous conversation replies:

  1. !message.content gate on loading: The previous reply already has content, so it should never show a loading state regardless of sendLoading.
  2. Scoping sendLoading to the last message: Prevents LoadingDots (which renders based on sendLoading && isEmpty(content)) from showing on historical messages too.

The logic is tight and well-reasoned. No regressions — derivedMessages.length - 1 === i is already the guard used for the loading dots block on line 125. Edge case: an empty derivedMessages array would give -1 === i for both conditions, but that is a pre-existing concern, not introduced here.

✅ Approved

@wangq8 wangq8 added ci Continue Integration and removed ci Continue Integration labels Aug 11, 2026
@wangq8
wangq8 merged commit e195a25 into infiniflow:main Aug 12, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants