Repository navigation
fix(web): keep reasoning and internet options when regenerating an answer - #18226
Conversation
…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]>
…t-regenerate-send-options
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe 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. ChangesResend option persistence
Estimated code review effort: 3 (Moderate) | ~20 minutes Mergeability Score: ⚪ Minimal · up to 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
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
wangq8
left a comment
There was a problem hiding this comment.
Approach is sound and fixes the reported issue (regenerate dropping the reasoning/internet options). A few observations:
-
Semantics:
resolveResendOptionsreplays 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. -
Deps churn: Adding
messagestosendMessage'suseCallbackdeps meanssendMessage(and theregenerateMessage/handlePressEntercallbacks that depend on it) is recreated on every stream chunk, sinceuseCurrentChatSession().messageschanges while streaming. Minor re-render churn during streaming. Consider reading the store snapshot inside the callback (like the olduseChatStreamStore.getState().sessions[...]pattern) to keep the dep list stable while still getting a fresh history. -
Fallback correctness: The new
messages: [...(Array.isArray(explicitMessages) ? explicitMessages : messages), message]also incidentally fixes a latent spread-of-undefined —handlePressEnterpassesmessages: undefinedfor existing conversations (currentMessagesis 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.
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
reasoningandinternetparameters. Each view now remembers theoptions 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.