Skip to content

Commit bdfa32f

Browse files
authored
fix(autofix): Fix polling w/ comment thread on sidebar + lower poll rate (#87233)
When on the sidebar and there's a comment thread we shouldn't still be polling. Also reduces the poll rate when on the sidebar.
1 parent ee33a8f commit bdfa32f

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

static/app/components/events/autofix/useAutofix.tsx

+17-5
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ const makeErrorAutofixData = (errorMessage: string): AutofixResponse => {
7676
};
7777

7878
/** Will not poll when the autofix is in an error state or has completed */
79-
const isPolling = (autofixData: AutofixData | null, runStarted: boolean) => {
79+
const isPolling = (
80+
autofixData: AutofixData | null,
81+
runStarted: boolean,
82+
isSidebar?: boolean
83+
) => {
8084
if (!autofixData && !runStarted) {
8185
return false;
8286
}
@@ -106,7 +110,7 @@ const isPolling = (autofixData: AutofixData | null, runStarted: boolean) => {
106110
}
107111

108112
// Continue polling if there's an active comment thread, even if the run is completed
109-
if (hasActiveCommentThread) {
113+
if (!isSidebar && hasActiveCommentThread) {
110114
return true;
111115
}
112116

@@ -131,7 +135,14 @@ export const useAutofixData = ({groupId}: {groupId: string}) => {
131135
return {data: data?.autofix ?? null, isPending};
132136
};
133137

134-
export const useAiAutofix = (group: GroupWithAutofix, event: Event) => {
138+
export const useAiAutofix = (
139+
group: GroupWithAutofix,
140+
event: Event,
141+
options: {
142+
isSidebar?: boolean;
143+
pollInterval?: number;
144+
} = {}
145+
) => {
135146
const api = useApi();
136147
const queryClient = useQueryClient();
137148

@@ -146,10 +157,11 @@ export const useAiAutofix = (group: GroupWithAutofix, event: Event) => {
146157
if (
147158
isPolling(
148159
query.state.data?.[0]?.autofix || null,
149-
!!currentRunId || waitingForNextRun
160+
!!currentRunId || waitingForNextRun,
161+
options.isSidebar
150162
)
151163
) {
152-
return POLL_INTERVAL;
164+
return options.pollInterval ?? POLL_INTERVAL;
153165
}
154166
return false;
155167
},

static/app/views/issueDetails/streamline/sidebar/solutionsSectionCtaButton.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ export function SolutionsSectionCtaButton({
4343
const openButtonRef = useRef<HTMLButtonElement>(null);
4444

4545
const {isPending: isAutofixPending} = useAutofixData({groupId: group.id});
46-
const {autofixData} = useAiAutofix(group, event);
46+
const {autofixData} = useAiAutofix(group, event, {
47+
isSidebar: true,
48+
pollInterval: 1500,
49+
});
4750

4851
const openSolutionsDrawer = useOpenSolutionsDrawer(
4952
group,

0 commit comments

Comments
 (0)