@@ -76,7 +76,11 @@ const makeErrorAutofixData = (errorMessage: string): AutofixResponse => {
76
76
} ;
77
77
78
78
/** 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
+ ) => {
80
84
if ( ! autofixData && ! runStarted ) {
81
85
return false ;
82
86
}
@@ -106,7 +110,7 @@ const isPolling = (autofixData: AutofixData | null, runStarted: boolean) => {
106
110
}
107
111
108
112
// Continue polling if there's an active comment thread, even if the run is completed
109
- if ( hasActiveCommentThread ) {
113
+ if ( ! isSidebar && hasActiveCommentThread ) {
110
114
return true ;
111
115
}
112
116
@@ -131,7 +135,14 @@ export const useAutofixData = ({groupId}: {groupId: string}) => {
131
135
return { data : data ?. autofix ?? null , isPending} ;
132
136
} ;
133
137
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
+ ) => {
135
146
const api = useApi ( ) ;
136
147
const queryClient = useQueryClient ( ) ;
137
148
@@ -146,10 +157,11 @@ export const useAiAutofix = (group: GroupWithAutofix, event: Event) => {
146
157
if (
147
158
isPolling (
148
159
query . state . data ?. [ 0 ] ?. autofix || null ,
149
- ! ! currentRunId || waitingForNextRun
160
+ ! ! currentRunId || waitingForNextRun ,
161
+ options . isSidebar
150
162
)
151
163
) {
152
- return POLL_INTERVAL ;
164
+ return options . pollInterval ?? POLL_INTERVAL ;
153
165
}
154
166
return false ;
155
167
} ,
0 commit comments