-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
ref(explorer): cleanup UI interrupt state and panel code #112446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,6 @@ import {Text} from '@sentry/scraps/text'; | |
| import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator'; | ||
| import {IconSeer} from 'sentry/icons'; | ||
| import {t} from 'sentry/locale'; | ||
| import type {User} from 'sentry/types/user'; | ||
| import {trackAnalytics} from 'sentry/utils/analytics'; | ||
| import {useFeedbackForm} from 'sentry/utils/useFeedbackForm'; | ||
| import {useLocation} from 'sentry/utils/useLocation'; | ||
|
|
@@ -101,18 +100,17 @@ export function ExplorerPanel() { | |
| const { | ||
| runId, | ||
| sessionData, | ||
| isPolling, | ||
| isError, | ||
| sendMessage, | ||
| deleteFromIndex, | ||
| startNewSession, | ||
| isPolling, | ||
| isError, | ||
| interruptRun, | ||
| interruptRequested, | ||
| wasJustInterrupted, | ||
| clearWasJustInterrupted, | ||
| switchToRun, | ||
| respondToUserInput, | ||
| createPR, | ||
| interruptRun, | ||
| interruptRequested, | ||
| wasJustInterrupted, | ||
| overrideCtxEngEnable, | ||
| setOverrideCtxEngEnable, | ||
| } = useSeerExplorer(); | ||
|
|
@@ -137,13 +135,6 @@ export function ExplorerPanel() { | |
| onUnminimize: useCallback(() => setIsMinimized(false), []), | ||
| }); | ||
|
|
||
| // Clear wasJustInterrupted when user starts typing | ||
| useEffect(() => { | ||
| if (inputValue.length > 0 && wasJustInterrupted) { | ||
| clearWasJustInterrupted(); | ||
| } | ||
| }, [inputValue, wasJustInterrupted, clearWasJustInterrupted]); | ||
|
|
||
| // Extract repo_pr_states from session | ||
| const repoPRStates = useMemo( | ||
| () => sessionData?.repo_pr_states ?? {}, | ||
|
|
@@ -153,25 +144,11 @@ export function ExplorerPanel() { | |
| // Get blocks from session data or empty array | ||
| const blocks = useMemo(() => sessionData?.blocks || [], [sessionData]); | ||
|
|
||
| // Check owner id to determine edit permission. Defensive against any useUser return shape. | ||
| // Despite the type annotation, useUser can return null or undefined when not logged in. | ||
| // This component is in the top-level index so we have to guard against this. | ||
| const rawUser = useUser() as unknown; | ||
| const ownerUserId = sessionData?.owner_user_id ?? undefined; | ||
| const readOnly = useMemo(() => { | ||
| const isUser = (value: unknown): value is User => | ||
| Boolean( | ||
| value && | ||
| typeof value === 'object' && | ||
| 'id' in value && | ||
| typeof value.id === 'string' | ||
| ); | ||
| const userId = isUser(rawUser) ? rawUser.id : undefined; | ||
| return ( | ||
| userId === undefined || | ||
| (ownerUserId !== undefined && ownerUserId?.toString() !== userId) | ||
| ); | ||
| }, [rawUser, ownerUserId]); | ||
| // Check owner id to determine edit permission. | ||
| const user = useUser(); | ||
| const readOnly = | ||
| sessionData?.owner_user_id !== undefined && | ||
| sessionData.owner_user_id.toString() !== user.id; | ||
aliu39 marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+148
to
+151
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The code directly accesses Suggested FixAdd a null check to ensure the Prompt for AI Agent
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ConfigStore should be hydrated before component renders. Verified in dev-ui - the old defensive check was made by AI after an unrelated test flake |
||
|
|
||
| // Get PR widget data for menu | ||
| const {menuItems: prWidgetItems, menuFooter: prWidgetFooter} = usePRWidgetData({ | ||
|
|
@@ -735,10 +712,10 @@ export function ExplorerPanel() { | |
| focusedBlockIndex={focusedBlockIndex} | ||
| inputValue={inputValue} | ||
| interruptRequested={interruptRequested} | ||
| wasJustInterrupted={wasJustInterrupted} | ||
| isMinimized={isMinimized} | ||
| isPolling={isPolling} | ||
| isVisible={isVisible} | ||
| wasJustInterrupted={wasJustInterrupted} | ||
| onClear={() => setInputValue('')} | ||
| onCreatePR={createPR} | ||
| onInputChange={handleInputChange} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.