Skip to content

fix(web): seed new conversation from server prologue before appending question - #18206

Merged
wangq8 merged 2 commits into
infiniflow:mainfrom
dcc123456:fix/web-hydrate-new-chat-prologue
Aug 13, 2026
Merged

wangq8 merged 2 commits into
infiniflow:mainfrom
dcc123456:fix/web-hydrate-new-chat-prologue

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

Summary

fix(web): seed new conversation from server prologue before appending question

A freshly created conversation is persisted under a server-generated id, so the prologue seeded on the temporary id never carries over and the first answer rendered without it. Hydrate the real session id from the server list before appending the question, so the ordering doesn't trip the streaming authority check and wipe the just-appended question and placeholder.

… question

A freshly created conversation is persisted under a server-generated id, so
the prologue seeded on the temporary id never carries over and the first
answer rendered without it. Hydrate the real session id from the server list
before appending the question, so the ordering doesn't trip the streaming
authority check and wipe the just-appended question and placeholder.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. 🧰 typescript Pull requests that update Typescript code labels Aug 13, 2026
@coderabbitai

coderabbitai Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bdeea580-6fdb-4cf2-a4b9-7d2ccd02324a

📥 Commits

Reviewing files that changed from the base of the PR and between 3f88456 and 588d55d.

📒 Files selected for processing (1)
  • web/src/pages/next-chats/hooks/use-send-chat-message.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/pages/next-chats/hooks/use-send-chat-message.ts

📝 Walkthrough

Walkthrough

The send-message flow now hydrates non-empty server messages with UUIDs before appending a new question. The callback dependency list includes hydrateFromServer.

Changes

Chat message hydration

Layer / File(s) Summary
Hydrate messages before question insertion
web/src/pages/next-chats/hooks/use-send-chat-message.ts
The send flow uses buildMessageListWithUuid to hydrate server messages before it appends a question. The callback dependency list includes hydrateFromServer.

Estimated code review effort: 2 (Simple) | ~10 minutes

Mergeability Score: ⚪ Minimal · up to 588d5

This change hydrates the server-created conversation before adding the first question so the initial prologue and answer render correctly; no actionable merge-blocking risk remains beyond normal checks.

Poem

A rabbit sends a question bright,
UUIDs line the chat just right.
Server messages hop in place,
Then new words join the race.
Dependencies thump with care.

🚥 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.
Title check ✅ Passed The title clearly summarizes the main change: hydrating the server prologue before appending the question.
Description check ✅ Passed The description includes the required Summary section and explains the problem, cause, and implemented fix.

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.

@dcc123456
dcc123456 requested a review from wangq8 August 13, 2026 06:06
@dcc123456
dcc123456 marked this pull request as draft August 13, 2026 06:06
@dcc123456
dcc123456 marked this pull request as ready for review August 13, 2026 06:06

@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.

Thanks for the fix — the root cause is correctly identified: for a freshly created conversation the store session is keyed on the server-generated id, so the prologue seeded on the temporary id is orphaned and the first render drops it. Hydrating from currentMessages (which carries the server-seeded prologue) before appendQuestion is the right ordering, and the currentMessages.length > 0 guard correctly scopes this to the new-conversation path (existing conversations return an empty list).

A few notes:

  1. Ordering vs. authority check — correct. hydrateFromServer rejects a server list shorter than the local one, so hydrating after appendQuestion would either wipe the just-appended question/placeholder or be rejected. Doing it first leaves the session at [prologue, question, placeholder], so the later single-chat-box hydration (where the server still returns only the prologue) is correctly rejected instead of truncating. 👍

  2. Merge conflicts — gh pr view reports mergeable: CONFLICTING. Please rebase on main and resolve before merge.

  3. Missing test — this store has subtle length/authority-guard logic. A regression test covering "new conversation hydrates the server prologue before appending the question, and the question isn't wiped by a subsequent stale server list" would be valuable. None is included here.

  4. Minor — buildMessageListWithUuid also omits reference; harmless for the prologue, but the helper does more than its name suggests. Non-blocking.

LGTM once the conflicts are resolved.

@dcc123456
dcc123456 marked this pull request as draft August 13, 2026 06:50
@dcc123456
dcc123456 marked this pull request as ready for review August 13, 2026 06:50
@wangq8 wangq8 added the ci Continue Integration label Aug 13, 2026
@wangq8
wangq8 merged commit bb4b58e into infiniflow:main Aug 13, 2026
6 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:S This PR changes 10-29 lines, ignoring generated files. 🧰 typescript Pull requests that update Typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants