Skip to content

fix(web): keep reasoning and internet options when regenerating an answer - #18226

Merged
wangq8 merged 2 commits into
infiniflow:mainfrom
dcc123456:fix/web-chat-regenerate-send-options
Aug 13, 2026
Merged

wangq8 merged 2 commits into
infiniflow:mainfrom
dcc123456:fix/web-chat-regenerate-send-options

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

Summary

fix(web): keep reasoning and internet options when regenerating an answer

The regenerate button lives in the transcript, which cannot reach the
thinking / internet toggles held as local state inside NextMessageInput,
so both single and multi-model chat resent the question without the
reasoning and internet parameters. Each view now remembers the
options of its last send and replays them, falling back to the input
box's own defaults (persisted thinking level, internet off) so a freshly
mounted view stays in sync with the visible toggles.

dcc123456 and others added 2 commits August 13, 2026 17:26
…swer

The regenerate button lives in the transcript, which cannot reach the
thinking / internet toggles held as local state inside NextMessageInput,
so both single and multi-model chat resent the question without the
`reasoning` and `internet` parameters. Each view now remembers the
options of its last send and replays them, falling back to the input
box's own defaults (persisted thinking level, internet off) so a freshly
mounted view stays in sync with the visible toggles.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@dosubot dosubot Bot added size:M This PR changes 30-99 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
@dcc123456
dcc123456 requested a review from wangq8 August 13, 2026 09:42
@dcc123456 dcc123456 added the ci Continue Integration label Aug 13, 2026
@dcc123456
dcc123456 marked this pull request as draft August 13, 2026 09:42
@dcc123456
dcc123456 marked this pull request as ready for review August 13, 2026 09:43
@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: 68712697-fe01-4517-b1f7-a667a1c518b1

📥 Commits

Reviewing files that changed from the base of the PR and between a6dcc0f and be5fdae.

📒 Files selected for processing (3)
  • web/src/pages/next-chats/chat/chat-box/next-multiple-chat-box.tsx
  • web/src/pages/next-chats/hooks/use-send-chat-message.ts
  • web/src/pages/next-chats/utils.ts

📝 Walkthrough

Walkthrough

The chat flow now stores the latest thinking and internet settings for each chat card. Normal sends forward these settings. Regeneration reuses them and supports explicit, including empty, message history.

Changes

Resend option persistence

Layer / File(s) Summary
Resolve options and send history
web/src/pages/next-chats/utils.ts, web/src/pages/next-chats/hooks/use-send-chat-message.ts
sendMessage stores the latest send options, accepts optional history, preserves explicit history lists, and resolves options for regeneration with persisted defaults.
Persist options per chat card
web/src/pages/next-chats/chat/chat-box/next-multiple-chat-box.tsx
Each chat card records incoming thinking and internet settings and applies resolved options when regenerating messages.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Mergeability Score: ⚪ Minimal · up to be5fd

This localized change preserves reasoning and internet options during answer regeneration; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant NextMultipleChatBox
  participant sendMessage
  participant resolveResendOptions
  participant StreamRequest
  NextMultipleChatBox->>NextMultipleChatBox: store latest card send options
  NextMultipleChatBox->>sendMessage: send message and history
  sendMessage->>StreamRequest: send normal request with options
  NextMultipleChatBox->>sendMessage: regenerate question
  sendMessage->>resolveResendOptions: resolve latest or default options
  resolveResendOptions-->>sendMessage: return resend options
  sendMessage->>StreamRequest: send regenerated request with history and options
Loading

Possibly related PRs

Suggested reviewers: qinling0210

Poem

I’m a rabbit with options tucked tight,
Thinking and internet settings stay right.
Each card remembers the latest send,
Regeneration follows that trend.
Empty history still joins the flight—
Hop, resend, and stream it bright!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 and concisely identifies the fix for preserving reasoning and internet options during answer regeneration.
Description check ✅ Passed The description includes the required Summary section and clearly explains the problem, affected views, behavior, and fallback defaults.

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 marked this pull request as draft August 13, 2026 09:43
@dcc123456
dcc123456 marked this pull request as ready for review August 13, 2026 09:43

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

Approach is sound and fixes the reported issue (regenerate dropping the reasoning/internet options). A few observations:

  1. Semantics: resolveResendOptions replays the options of the last sent message, not the input box's currently-visible toggles. If a user changes the thinking/internet toggle without sending and then clicks regenerate, the regenerate will ignore the visible change. This matches your documented design, just flagging the edge case so it's an intentional tradeoff.

  2. Deps churn: Adding messages to sendMessage's useCallback deps means sendMessage (and the regenerateMessage/handlePressEnter callbacks that depend on it) is recreated on every stream chunk, since useCurrentChatSession().messages changes while streaming. Minor re-render churn during streaming. Consider reading the store snapshot inside the callback (like the old useChatStreamStore.getState().sessions[...] pattern) to keep the dep list stable while still getting a fresh history.

  3. Fallback correctness: The new messages: [...(Array.isArray(explicitMessages) ? explicitMessages : messages), message] also incidentally fixes a latent spread-of-undefined — handlePressEnter passes messages: undefined for existing conversations (currentMessages is always [] there), which previously would throw on [...undefined, message]. Worth noting the fallback relies on the React closure being pre-append; if a future refactor reads fresh store state there it would re-send the question twice (the original code's comment warned about exactly this).

Types line up (enableThinking is a string, storage.getThinkingLevel() returns a string; all fields on NextMessageInputOnPressEnterParameter are optional). No blocking issues.

@wangq8
wangq8 merged commit 9d1a779 into infiniflow:main Aug 13, 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:M This PR changes 30-99 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