ref(explorer): cleanup UI interrupt state and panel code#112446
Open
ref(explorer): cleanup UI interrupt state and panel code#112446
Conversation
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 178f2ed. Configure here.
Removed timeout management from waiting and interrupt helpers.
Comment on lines
+148
to
+151
| const user = useUser(); | ||
| const readOnly = | ||
| sessionData?.owner_user_id !== undefined && | ||
| sessionData.owner_user_id.toString() !== user.id; |
Contributor
There was a problem hiding this comment.
Bug: The code directly accesses user.id, but useUser() can return undefined before the application is fully hydrated. This can cause a runtime crash.
Severity: CRITICAL
Suggested Fix
Add a null check to ensure the user object is defined before attempting to access its id property. The comparison logic should only execute when user is not null or undefined.
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/explorerPanel.tsx#L148-L151
Potential issue: The `useUser()` hook can return `undefined` before the `ConfigStore` is
hydrated with user data. The code accesses `user.id` without checking if `user` is
defined. If the component renders before user data is available and
`sessionData.owner_user_id` exists, the expression `sessionData.owner_user_id.toString()
!== user.id` will attempt to read the `id` property of `undefined`, causing a
`TypeError` and a runtime crash. The previous implementation guarded against this exact
scenario, and the test validating this guard was removed in this pull request.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Code organization and cleanup for explorer chat UI, before implementing a polling timeout. Should not affect current functionality.
Refactors:
Use helpers
_onNewRequestand_onRequestErrorfor repeated interrupt/waiting state management inuseSeerExplorer. This will soon include timeout stateMoves the "response complete" detection from inline code (ran every render) into a
useEffect. In general we could use a lot less useEffect's but seems correct here - reducing effects is a larger refactor for another daySimplifies interrupt detection by removing the
prevInterruptRequestedRefapproach —wasJustInterruptedis now set directly when polling stops after an interrupt request.startNewSessiondelegates toswitchToRun(null)to deduplicate codeSimplifies the
readOnlycomputation inexplorerPanelby removing defensive type-checking arounduseUser(). The comment is not accurateSimplify props for disabled textarea in case of read-only
Cleanup:
Removes the always-poll-when-drawer-open (
isSeerDrawerOpen) condition. Chat is no longer embedded into seer drawer.Removes
clearWasJustInterruptedfrom hook API. Clearing on user request + switch session is sufficientRemoves
isPendingfrom the hook's return value (unused externally and not useful due to polling)