Repository navigation
Commit e4177d0
fix(relay): keep a ready thread quiet through stream-establishment repair (#2124)
## Problem
Every minute, live renewal re-establishes each channel subscription.
Each open thread view then ran its establishment repair as a visible
cycle: it published `loading`, re-read the window, then published
`ready`. That happened even when no row changed. `ThreadPanel`
subscribes to the whole snapshot, so every renewal re-rendered the
entire thread subtree twice.
## Change
`src/features/relay/threads.ts`:
- An establishment repair of a view that is already `ready` no longer
publishes `loading`. The view stays ready and publishes only if the
repair changes a field.
- `publish`/`publishStatus` skip the snapshot swap and the notification
when every field is identical.
- If an older page (`loadMore`) is requested while a background repair
runs, it is queued and runs after the repair. Before this change the
busy guard dropped it, which was invisible on main because the view
showed `loading` during the repair. The queued flag is cleared wherever
`again` is cleared (`purge` and the retain-limit path).
## No behavior or traffic changes
- The relay sees identical traffic: same reads, filters and timing, and
the 60 s renewal interval is unchanged. Live REQs are equal in every
cell below.
- The repair still runs and still corrects the view. A repair that
changes rows publishes the new snapshot as before.
- The only intentional difference: a ready thread no longer flashes
`loading` during a silent repair.
- A background repair that fails still publishes `error`, as on main.
## Tests
- New: `threads.test.ts` "repairs a ready thread on stream establishment
without notifying when nothing changed, then runs an older page
requested meanwhile". It fails on main, where the snapshot goes to
`loading`.
- `thread-window.test.ts` used `status: "ready"` as its "repair
finished" signal. Because the view now stays ready throughout the
repair, the test waits on the repaired rows instead.
- On this head: the relay suite passes (2,549), and tsc and biome are
clean.
## Evidence
Browser scale harness: 400 channels, 4 tabs, 125 s idle with a renewal
tick. It ran on Linux and macOS workstations, 3 runs per cell; the table
shows medians.
| OS | engine | commits main → change | renders main → change | idle
script ms main → change | live REQs |
|---|---|---|---|---|---|
| Linux | Chromium | 123 → 58 | 10,974 → 5,069 | 533 → 366 | 166 / 166 |
| Linux | WebKit | 122 → 56 | 10,974 → 5,069 | n/a | 166 / 166 |
| macOS | Chromium | 123 → 57 | 10,974 → 5,069 | 1,031 → 890 | 166 / 166
|
| macOS | WebKit | 122 → 58 | 10,974 → 5,069 | n/a | 166 / 166 |
- Commits and renders drop 53–54% on every OS and engine.
- Over-budget frame time is within run-to-run noise in both variants.
- WebKit does not report script time.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Kalvin Chau <[email protected]>
Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <[email protected]>1 parent 7f793e9 commit e4177d0
3 files changed
Lines changed: 86 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
589 | 589 | | |
590 | 590 | | |
591 | 591 | | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | 592 | | |
600 | 593 | | |
601 | 594 | | |
602 | | - | |
| 595 | + | |
| 596 | + | |
603 | 597 | | |
604 | | - | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
605 | 606 | | |
606 | 607 | | |
607 | 608 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
648 | 648 | | |
649 | 649 | | |
650 | 650 | | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
651 | 701 | | |
652 | 702 | | |
653 | 703 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
| |||
227 | 229 | | |
228 | 230 | | |
229 | 231 | | |
230 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
231 | 237 | | |
232 | 238 | | |
233 | 239 | | |
234 | 240 | | |
235 | | - | |
| 241 | + | |
236 | 242 | | |
237 | 243 | | |
238 | 244 | | |
| |||
242 | 248 | | |
243 | 249 | | |
244 | 250 | | |
245 | | - | |
246 | 251 | | |
247 | 252 | | |
248 | 253 | | |
| |||
314 | 319 | | |
315 | 320 | | |
316 | 321 | | |
317 | | - | |
| 322 | + | |
318 | 323 | | |
319 | 324 | | |
320 | 325 | | |
| |||
323 | 328 | | |
324 | 329 | | |
325 | 330 | | |
326 | | - | |
327 | 331 | | |
328 | 332 | | |
329 | 333 | | |
| |||
337 | 341 | | |
338 | 342 | | |
339 | 343 | | |
| 344 | + | |
340 | 345 | | |
341 | 346 | | |
342 | 347 | | |
| |||
370 | 375 | | |
371 | 376 | | |
372 | 377 | | |
| 378 | + | |
373 | 379 | | |
374 | 380 | | |
375 | 381 | | |
| |||
536 | 542 | | |
537 | 543 | | |
538 | 544 | | |
| 545 | + | |
539 | 546 | | |
540 | 547 | | |
541 | 548 | | |
| |||
557 | 564 | | |
558 | 565 | | |
559 | 566 | | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
565 | 575 | | |
566 | 576 | | |
567 | 577 | | |
| |||
797 | 807 | | |
798 | 808 | | |
799 | 809 | | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
800 | 813 | | |
801 | 814 | | |
802 | 815 | | |
| |||
808 | 821 | | |
809 | 822 | | |
810 | 823 | | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
811 | 827 | | |
812 | 828 | | |
813 | 829 | | |
| |||
0 commit comments