feat(seer-explorer): add hook to open explorer#104540
Conversation
| useEffect(() => { | ||
| const hasBlocks = sessionBlocks && sessionBlocks.length > 0; | ||
|
|
||
| if (isWaitingForSessionData && sessionRunId && hasBlocks) { | ||
| document.dispatchEvent(new SeerExplorerSessionReadyEvent(sessionRunId)); | ||
| setIsWaitingForSessionData(false); | ||
| } | ||
| }, [sessionRunId, sessionBlocks, isWaitingForSessionData]); |
There was a problem hiding this comment.
Bug: Loading indicator persists when initial message POST fails for a new run.
Severity: HIGH | Confidence: High
🔍 Detailed Analysis
When openSeerExplorer({startNewRun: true, initialMessage: 'text'}) is called and the initial message POST request fails, isWaitingForSessionData will persist indefinitely as true. This keeps the loading indicator visible even though an error state has been reached. The setRunId() function is never called on POST failure, causing sessionRunId to remain undefined. Consequently, the useEffect condition to clear isWaitingForSessionData (isWaitingForSessionData && sessionRunId && hasBlocks) is never met.
💡 Suggested Fix
Set isWaitingForSessionData = false in the sendMessage error handler, or modify the useEffect condition to clear the loading state to isWaitingForSessionData && (sessionRunId || hasBlocks).
🤖 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/openSeerExplorer.tsx#L225-L232
Potential issue: When `openSeerExplorer({startNewRun: true, initialMessage: 'text'})` is
called and the initial message POST request fails, `isWaitingForSessionData` will
persist indefinitely as `true`. This keeps the loading indicator visible even though an
error state has been reached. The `setRunId()` function is never called on POST failure,
causing `sessionRunId` to remain `undefined`. Consequently, the `useEffect` condition to
clear `isWaitingForSessionData` (`isWaitingForSessionData && sessionRunId && hasBlocks`)
is never met.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 6279097
| ) : ( | ||
| <IconSeer size="xl" variant="waiting" /> | ||
| )} | ||
| <Text>{!isLoading && t('Ask Seer anything about your application.')}</Text> |
There was a problem hiding this comment.
Bug: Empty text element renders with margin during loading
When isLoading is true, the expression !isLoading && t(...) evaluates to false, which renders an empty Text element. The Text styled component has margin-top applied, so an invisible div with margin is rendered below the loading indicator. This causes extra spacing in the loading state that likely wasn't intended. The Text element probably shouldn't render at all when loading.
|
|
||
| if (onRunCreated) { | ||
| onRunCreatedRef.current = onRunCreated; | ||
| } |
There was a problem hiding this comment.
Bug: Stale callback invoked when switching runs without new callback
The onRunCreatedRef is only set when onRunCreated is provided, but it's never cleared when a subsequent operation doesn't include a callback. If a user calls openSeerExplorer with onRunCreated, then before that run completes calls openSeerExplorer again with just a runId (no callback), the stale callback from the first call will be invoked with the second operation's run ID. This could cause the wrong run ID to be stored in the caller's state (like seerRunIdRef in dynamicGrouping.tsx).
Additional Locations (1)
Adds a re-usable hook to open the Seer Explorer panel, supporting options to start a new run or open an existing run ID, and also to send an initial message. Update the dynamic grouping explorer button to use this hook instead of requiring copy paste Closes AIML-1966 --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
Adds a re-usable hook to open the Seer Explorer panel, supporting options to start a new run or open an existing run ID, and also to send an initial message.
Update the dynamic grouping explorer button to use this hook instead of requiring copy paste
Closes AIML-1966