diff --git a/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx b/static/app/views/seerExplorer/components/drawer/explorerDrawerContent.tsx index 8c305b8060fd52..51df328645c2e7 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,11 @@ export function ExplorerDrawerContent({ setOverrideCodeModeEnable, } = useSeerExplorer(); + const clearInput = () => setInputValue(''); + const startNewSession = () => startNewSessionBase({onSuccess: clearInput}); + const switchToRun = (newRunId: number | null) => + switchToRunBase(newRunId, {onSuccess: clearInput}); + const readOnly = sessionData?.owner_user_id !== undefined && sessionData.owner_user_id !== null && @@ -202,7 +207,7 @@ export function ExplorerDrawerContent({ // Menu component const {menu, closeMenu, openPRWidget} = useExplorerMenu({ - clearInput: () => setInputValue(''), + clearInput, inputValue, focusInput, textAreaRef: textareaRef, diff --git a/static/app/views/seerExplorer/hooks/useSeerExplorer.tsx b/static/app/views/seerExplorer/hooks/useSeerExplorer.tsx index 0ea1d19f5b8620..b09ae6c216bfe0 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) => {