Commit d246709
authored
🤖 fix: eliminate debounce race conditions in ReviewPanel auto-refresh (#1257)
Extract refresh logic into a dedicated `useReviewRefreshController` hook
that centralizes all refresh decision-making and eliminates race
conditions.
## Changes
- New `useReviewRefreshController` hook (~300 LoC) with:
- Debounced tool completion handling (3s window)
- Hidden tab detection (queue + flush on visibilitychange)
- User interaction pausing (queue + flush on blur)
- In-flight coalescing (single follow-up after fetch completes)
- Scroll position preservation
- Simplified ReviewPanel:
- Removed ~125 lines of inline refresh logic
- Single integration point via the hook
## Race condition fixes
| Issue | Before | After |
|-------|--------|-------|
| Stale closure capture | Timer captured `filters.diffBase` at schedule
time | All state read from refs at execution time |
| Hidden tab | ❌ Refresh dropped silently | ✅ Queued, flush on
visibilitychange |
| Refresh during origin fetch | ❌ Dropped silently | ✅ Single follow-up
queued |
| Timer cleanup | Closure variable could go stale | Refs allow cleanup
from any path |
## Regression risk: MEDIUM-LOW
**Preserved behaviors:**
- 3s debounce timing (same constant)
- Origin fetch logic (same shell injection protection)
- User interaction pausing (same isPanelFocused tracking)
- Scroll position preservation
**New behaviors (improvements):**
- Hidden-tab refreshes now queued instead of dropped
- In-flight requests coalesce to single follow-up instead of dropped
**Manual smoke test checklist:**
- [ ] Open ReviewPanel with origin/main base
- [ ] Run bash tool that modifies files → refresh ~3s after
- [ ] Trigger tool during refresh → one additional refresh after first
completes
- [ ] Hide tab during tool, show tab → refresh fires on visible
- [ ] Focus panel, trigger tool, blur → refresh fires after blur
---
_Generated with `mux` • Model: `anthropic:claude-opus-4-5` • Thinking:
`high`_1 parent 4e6ee27 commit d246709
File tree
3 files changed
+411
-147
lines changed- src/browser
- components/RightSidebar/CodeReview
- hooks
3 files changed
+411
-147
lines changedLines changed: 18 additions & 147 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | 130 | | |
146 | 131 | | |
147 | 132 | | |
| |||
243 | 228 | | |
244 | 229 | | |
245 | 230 | | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | 231 | | |
257 | 232 | | |
258 | 233 | | |
259 | 234 | | |
260 | 235 | | |
261 | 236 | | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
325 | 246 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
332 | 250 | | |
333 | | - | |
| 251 | + | |
334 | 252 | | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
| 253 | + | |
| 254 | + | |
344 | 255 | | |
345 | 256 | | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | 257 | | |
387 | 258 | | |
388 | 259 | | |
| |||
896 | 767 | | |
897 | 768 | | |
898 | 769 | | |
899 | | - | |
| 770 | + | |
900 | 771 | | |
901 | 772 | | |
902 | 773 | | |
| |||
905 | 776 | | |
906 | 777 | | |
907 | 778 | | |
908 | | - | |
| 779 | + | |
909 | 780 | | |
910 | 781 | | |
911 | 782 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
0 commit comments