fix(seer-explorer): Clear input when switching sessions or starting new chat#115440
Conversation
…ew chat Wraps startNewSession and switchToRun to reset inputValue, so stale text doesn't persist across session changes.
📊 Type Coverage Diff✅ No new type safety issues introduced. Coverage: 93.50% |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 63c2984. Configure here.
… callback Add optional onSuccess callback to switchToRun and startNewSession in useSeerExplorer. The callback fires after state updates but not on early return. explorerDrawerContent passes clearInput as onSuccess so stale text doesn't persist across session changes.
| if (newRunId === runId) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Bug: When starting a new chat from an unsent session, the input field is not cleared because an early return in switchToRunBase prevents the onSuccess callback from firing.
Severity: LOW
Suggested Fix
In the switchToRunBase function, move the onSuccess?.() call to before the early-return guard if (newRunId === runId) { return; }. This will ensure the callback is executed even when switching to the same runId, which includes the case where both are null.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: static/app/views/seerExplorer/hooks/useSeerExplorer.tsx#L392-L394
Potential issue: When `startNewSession` is called while a user is already in a new,
unsent session, the `runId` is `null`. The function calls `switchToRun(null, {onSuccess:
clearInput})`. Inside the `switchToRunBase` function, an early-return guard `if
(newRunId === runId)` evaluates to true because both `newRunId` and `runId` are `null`.
This causes the function to exit before the `onSuccess` callback (`clearInput`) is
invoked. As a result, if a user types text into the input field and clicks "New Chat"
without having first sent a message, the input field is not cleared.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
this is no-op, shouldnt clear

Summary
startNewSessionandswitchToRuninexplorerDrawerContent.tsxto clearinputValueafter each call, preventing stale text from persisting across session changes.Test plan