Skip to content

feat(seer-explorer): add hook to open explorer#104540

Merged
roaga merged 6 commits intomasterfrom
explorer/external-open
Dec 8, 2025
Merged

feat(seer-explorer): add hook to open explorer#104540
roaga merged 6 commits intomasterfrom
explorer/external-open

Conversation

@roaga
Copy link
Copy Markdown
Contributor

@roaga roaga commented Dec 8, 2025

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

@roaga roaga requested a review from aliu39 December 8, 2025 20:01
@linear
Copy link
Copy Markdown

linear bot commented Dec 8, 2025

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Dec 8, 2025
@roaga roaga changed the title feat(explorer): add hook to open explorer feat(seer-explorer): add hook to open explorer Dec 8, 2025
@roaga roaga marked this pull request as ready for review December 8, 2025 20:47
@roaga roaga requested review from a team as code owners December 8, 2025 20:47
Comment on lines +225 to +232
useEffect(() => {
const hasBlocks = sessionBlocks && sessionBlocks.length > 0;

if (isWaitingForSessionData && sessionRunId && hasBlocks) {
document.dispatchEvent(new SeerExplorerSessionReadyEvent(sessionRunId));
setIsWaitingForSessionData(false);
}
}, [sessionRunId, sessionBlocks, isWaitingForSessionData]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web


if (onRunCreated) {
onRunCreatedRef.current = onRunCreated;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Fix in Cursor Fix in Web

@roaga roaga merged commit a030338 into master Dec 8, 2025
49 checks passed
@roaga roaga deleted the explorer/external-open branch December 8, 2025 21:11
ryan953 pushed a commit that referenced this pull request Dec 9, 2025
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>
@github-actions github-actions bot locked and limited conversation to collaborators Dec 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants