Commit 31564aa
authored
🤖 fix: eliminate terminal resize race condition (#1538)
The previous approach resized the frontend terminal immediately but
debounced the PTY resize by 300ms. During that window, shell output
formatted for the old dimensions would display incorrectly in the
already-resized frontend terminal, causing text clobbering.
**Symptoms:** Output from commands like `git status --stat` would have
columns bleeding into each other - e.g., diff stats appearing mid-line,
"modified" becoming "commodified" as text from different areas
overlapped.
**Root cause:** Frontend `fitAddon.fit()` ran immediately on resize, but
`router.resize()` was debounced by 300ms. During that 300ms window, the
shell formatted output for the old PTY dimensions while the frontend
displayed it at the new dimensions.
**Fix:** Use `requestAnimationFrame` to batch resize events, then resize
both frontend and PTY in the same tick. This eliminates the window where
sizes can diverge.
- Simpler code (no setTimeout, no pendingResize state)
- Natural batching via RAF (coalesces rapid resize events)
- No race between frontend and PTY dimensions
---
_Generated with `mux` • Model: `anthropic:claude-opus-4-5` • Thinking:
`high` • Cost: $3.75_1 parent e95ad6a commit 31564aa
File tree
2 files changed
+79
-45
lines changed- src/browser
- components
- terminal
2 files changed
+79
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
325 | | - | |
326 | | - | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
327 | 351 | | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
334 | 355 | | |
335 | | - | |
336 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
337 | 359 | | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
342 | 372 | | |
343 | | - | |
344 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
345 | 377 | | |
346 | | - | |
347 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
348 | 383 | | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
| 384 | + | |
| 385 | + | |
354 | 386 | | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
372 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
373 | 403 | | |
374 | 404 | | |
375 | 405 | | |
| |||
379 | 409 | | |
380 | 410 | | |
381 | 411 | | |
382 | | - | |
383 | | - | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
384 | 415 | | |
385 | 416 | | |
386 | 417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
152 | 155 | | |
153 | | - | |
154 | | - | |
| 156 | + | |
| 157 | + | |
155 | 158 | | |
156 | 159 | | |
157 | 160 | | |
| |||
0 commit comments