From 6e17001882830fd0ee519dfb00cc375ff9a2c8fb Mon Sep 17 00:00:00 2001 From: Andrew Liu <159852527+aliu39@users.noreply.github.com> Date: Tue, 12 May 2026 14:51:50 -0700 Subject: [PATCH 1/5] fix(seer-explorer): Clear input when switching sessions or starting new chat Wraps startNewSession and switchToRun to reset inputValue, so stale text doesn't persist across session changes. --- .../components/drawer/explorerDrawerContent.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx b/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx index 8c305b8060fd..60157dd1d42b 100644 --- a/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx +++ b/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx @@ -64,8 +64,8 @@ export function ExplorerDrawerContent({ errorStatusCode, isTimedOut, sendMessage, - startNewSession, - switchToRun, + startNewSession: startNewSessionBase, + switchToRun: switchToRunBase, respondToUserInput, createPR, interruptRun, @@ -75,6 +75,16 @@ export function ExplorerDrawerContent({ setOverrideCodeModeEnable, } = useSeerExplorer(); + const startNewSession = () => { + startNewSessionBase(); + setInputValue(''); + }; + const switchToRun = (...args: Parameters) => { + const result = switchToRunBase(...args); + setInputValue(''); + return result; + }; + const readOnly = sessionData?.owner_user_id !== undefined && sessionData.owner_user_id !== null && From 63c298461e1a6a7fa9186e79f68d0f9c73775937 Mon Sep 17 00:00:00 2001 From: Andrew Liu <159852527+aliu39@users.noreply.github.com> Date: Tue, 12 May 2026 14:53:31 -0700 Subject: [PATCH 2/5] ref: Remove unnecessary return in switchToRun wrapper --- .../seerExplorer/components/drawer/explorerDrawerContent.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx b/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx index 60157dd1d42b..89b804521f99 100644 --- a/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx +++ b/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx @@ -80,9 +80,8 @@ export function ExplorerDrawerContent({ setInputValue(''); }; const switchToRun = (...args: Parameters) => { - const result = switchToRunBase(...args); + switchToRunBase(...args); setInputValue(''); - return result; }; const readOnly = From 72d25689256afea0fc4d387689cbf0213619b6c8 Mon Sep 17 00:00:00 2001 From: Andrew Liu <159852527+aliu39@users.noreply.github.com> Date: Tue, 12 May 2026 15:10:56 -0700 Subject: [PATCH 3/5] fix(seer-explorer): Clear input when switching sessions via onSuccess 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. --- .../drawer/explorerDrawerContent.tsx | 23 ++++++++----------- .../seerExplorer/hooks/useSeerExplorer.tsx | 11 +++++++-- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx b/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx index 89b804521f99..b8b86d68ae62 100644 --- a/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx +++ b/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx @@ -64,8 +64,8 @@ export function ExplorerDrawerContent({ errorStatusCode, isTimedOut, sendMessage, - startNewSession: startNewSessionBase, - switchToRun: switchToRunBase, + startNewSession, + switchToRun, respondToUserInput, createPR, interruptRun, @@ -75,14 +75,7 @@ export function ExplorerDrawerContent({ setOverrideCodeModeEnable, } = useSeerExplorer(); - const startNewSession = () => { - startNewSessionBase(); - setInputValue(''); - }; - const switchToRun = (...args: Parameters) => { - switchToRunBase(...args); - setInputValue(''); - }; + const clearInput = () => setInputValue(''); const readOnly = sessionData?.owner_user_id !== undefined && @@ -217,7 +210,7 @@ export function ExplorerDrawerContent({ textAreaRef: textareaRef, panelSize: 'max', slashCommandHandlers: { - onNew: startNewSession, + onNew: () => startNewSession({onSuccess: clearInput}), onFeedback: openFeedbackForm ? handleFeedback : undefined, onLangfuse: langfuseUrl ? handleOpenLangfuse : undefined, onConversations: conversationsUrl ? handleOpenConversations : undefined, @@ -326,7 +319,9 @@ export function ExplorerDrawerContent({ }, [blocks]); // Deep link effect - useSeerExplorerDeepLink({callback: switchToRun}); + useSeerExplorerDeepLink({ + callback: newRunId => switchToRun(newRunId, {onSuccess: clearInput}), + }); // Interrupt button and placeholder state const interruptState = @@ -343,10 +338,10 @@ export function ExplorerDrawerContent({ { - startNewSession(); + startNewSession({onSuccess: clearInput}); focusInput(); }} - onChangeSession={switchToRun} + onChangeSession={newRunId => switchToRun(newRunId, {onSuccess: clearInput})} onCopySessionClick={copySessionEnabled ? copySessionToClipboard : undefined} onCopyLinkClick={runId === null ? undefined : handleCopyLink} overrideCtxEngEnable={overrideCtxEngEnable} diff --git a/static/app/views/seerExplorer/hooks/useSeerExplorer.tsx b/static/app/views/seerExplorer/hooks/useSeerExplorer.tsx index 0ea1d19f5b86..b09ae6c216bf 100644 --- a/static/app/views/seerExplorer/hooks/useSeerExplorer.tsx +++ b/static/app/views/seerExplorer/hooks/useSeerExplorer.tsx @@ -388,7 +388,7 @@ export const useSeerExplorer = () => { /** Switches to a different run and fetches its latest state. */ const switchToRun = useCallback( - (newRunId: number | null) => { + (newRunId: number | null, {onSuccess}: {onSuccess?: () => void} = {}) => { if (newRunId === runId) { return; } @@ -404,12 +404,19 @@ export const useSeerExplorer = () => { queryKey: makeSeerExplorerQueryKey(orgSlug, newRunId), }); } + + onSuccess?.(); }, [orgSlug, queryClient, runId, setRunId] ); /** Resets the hook state. The session isn't actually created until the user sends a message. */ - const startNewSession = useCallback(() => switchToRun(null), [switchToRun]); + const startNewSession = useCallback( + ({onSuccess}: {onSuccess?: () => void} = {}) => { + switchToRun(null, {onSuccess}); + }, + [switchToRun] + ); const sendMessage = useCallback( (query: string, explicitInsertIndex?: number, explicitRunId?: number | null) => { From dbc6c557747f31e307f9a4232b61b2e61559790e Mon Sep 17 00:00:00 2001 From: Andrew Liu <159852527+aliu39@users.noreply.github.com> Date: Tue, 12 May 2026 15:12:45 -0700 Subject: [PATCH 4/5] ref(seer-explorer): Add wrapped convenience callbacks and simplify clearInput --- .../components/drawer/explorerDrawerContent.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx b/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx index b8b86d68ae62..ccd477256b6d 100644 --- a/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx +++ b/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx @@ -76,6 +76,9 @@ export function ExplorerDrawerContent({ } = useSeerExplorer(); const clearInput = () => setInputValue(''); + const handleStartNewSession = () => startNewSession({onSuccess: clearInput}); + const handleSwitchToRun = (newRunId: number | null) => + switchToRun(newRunId, {onSuccess: clearInput}); const readOnly = sessionData?.owner_user_id !== undefined && @@ -204,13 +207,13 @@ export function ExplorerDrawerContent({ // Menu component const {menu, closeMenu, openPRWidget} = useExplorerMenu({ - clearInput: () => setInputValue(''), + clearInput, inputValue, focusInput, textAreaRef: textareaRef, panelSize: 'max', slashCommandHandlers: { - onNew: () => startNewSession({onSuccess: clearInput}), + onNew: handleStartNewSession, onFeedback: openFeedbackForm ? handleFeedback : undefined, onLangfuse: langfuseUrl ? handleOpenLangfuse : undefined, onConversations: conversationsUrl ? handleOpenConversations : undefined, @@ -319,9 +322,7 @@ export function ExplorerDrawerContent({ }, [blocks]); // Deep link effect - useSeerExplorerDeepLink({ - callback: newRunId => switchToRun(newRunId, {onSuccess: clearInput}), - }); + useSeerExplorerDeepLink({callback: handleSwitchToRun}); // Interrupt button and placeholder state const interruptState = @@ -338,10 +339,10 @@ export function ExplorerDrawerContent({ { - startNewSession({onSuccess: clearInput}); + handleStartNewSession(); focusInput(); }} - onChangeSession={newRunId => switchToRun(newRunId, {onSuccess: clearInput})} + onChangeSession={handleSwitchToRun} onCopySessionClick={copySessionEnabled ? copySessionToClipboard : undefined} onCopyLinkClick={runId === null ? undefined : handleCopyLink} overrideCtxEngEnable={overrideCtxEngEnable} From c732731b4f3728d3d542cc196f799fa83b2ec3e7 Mon Sep 17 00:00:00 2001 From: Andrew Liu <159852527+aliu39@users.noreply.github.com> Date: Tue, 12 May 2026 15:16:19 -0700 Subject: [PATCH 5/5] ref: Rename wrapped callbacks to startNewSession/switchToRun with Base suffix --- .../drawer/explorerDrawerContent.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx b/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx index ccd477256b6d..51df328645c2 100644 --- a/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx +++ b/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx @@ -64,8 +64,8 @@ export function ExplorerDrawerContent({ errorStatusCode, isTimedOut, sendMessage, - startNewSession, - switchToRun, + startNewSession: startNewSessionBase, + switchToRun: switchToRunBase, respondToUserInput, createPR, interruptRun, @@ -76,9 +76,9 @@ export function ExplorerDrawerContent({ } = useSeerExplorer(); const clearInput = () => setInputValue(''); - const handleStartNewSession = () => startNewSession({onSuccess: clearInput}); - const handleSwitchToRun = (newRunId: number | null) => - switchToRun(newRunId, {onSuccess: clearInput}); + const startNewSession = () => startNewSessionBase({onSuccess: clearInput}); + const switchToRun = (newRunId: number | null) => + switchToRunBase(newRunId, {onSuccess: clearInput}); const readOnly = sessionData?.owner_user_id !== undefined && @@ -213,7 +213,7 @@ export function ExplorerDrawerContent({ textAreaRef: textareaRef, panelSize: 'max', slashCommandHandlers: { - onNew: handleStartNewSession, + onNew: startNewSession, onFeedback: openFeedbackForm ? handleFeedback : undefined, onLangfuse: langfuseUrl ? handleOpenLangfuse : undefined, onConversations: conversationsUrl ? handleOpenConversations : undefined, @@ -322,7 +322,7 @@ export function ExplorerDrawerContent({ }, [blocks]); // Deep link effect - useSeerExplorerDeepLink({callback: handleSwitchToRun}); + useSeerExplorerDeepLink({callback: switchToRun}); // Interrupt button and placeholder state const interruptState = @@ -339,10 +339,10 @@ export function ExplorerDrawerContent({ { - handleStartNewSession(); + startNewSession(); focusInput(); }} - onChangeSession={handleSwitchToRun} + onChangeSession={switchToRun} onCopySessionClick={copySessionEnabled ? copySessionToClipboard : undefined} onCopyLinkClick={runId === null ? undefined : handleCopyLink} overrideCtxEngEnable={overrideCtxEngEnable}