Commit 2cff652
fix(channels): address review — hydration race, double-submit, seen depth
Seven findings from a review of this stack.
- The seen store's storage is async (IPC), so both sides raced hydration.
Reads: an empty map is indistinguishable from "nothing ever read", so
every channel with activity bolded for the first frames of each boot.
Writes: a channel opened during boot stamped itself seen, then zustand's
default merge replaced that stamp with what was on disk and lost it —
the channel you just read stayed bold. Gate reads on `hasHydrated` and
merge the two maps (later visit per channel wins) instead of replacing.
- CreateChannelModal relied on `disabled={busy}`, which only lands a render
after the mutation starts, so a double-click (or a held ⌘Enter) fired two
creates — and folder creation isn't idempotent by path, so that's two
channels of the same name. Latch synchronously.
- ensurePersonalChannel's in-flight guard settled when the POST returned,
but callers pass the `channels` from their last render — a click in that
gap saw no existing "me" and no in-flight create, and made a second.
Remember what was created until the list catches up.
- Marking a channel read only happened on its feed, so reading it via
Artifacts/Recents/CONTEXT.md left it bold. Moved into ChannelHeader,
which every channel surface renders — a new surface now gets it free.
- ChannelGroup's onOpenChange ignored the value Base UI emits and blind
toggled, so a redundant event would invert the section.
- Unread was resolved two ways (by name for shared rows, by id for #me).
One predicate now mirrors useBackendChannel's mapping for both.
- latestActivityForChannel built a map of every channel to read one key.
Covered by 10 new tests: the store's hydration merge (the clobber case
fails without the fix) and ensurePersonalChannel's races.
Not addressed, deliberately: the seen store stays in @posthog/ui rather
than moving to core per the layering rule. Every persisted store in the
app lives in ui because persistence goes through electronStorage, a
ui/shell adapter; core has no persisted store to follow, and its sibling
(activitySeenStore, the same concept for the Activity page) sits in ui.
Moving it needs a platform storage interface — worth doing, but as its own
change rather than smuggled into this one.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019G63f4afY9vsbKsvK654Wj1 parent 1009a4d commit 2cff652
11 files changed
Lines changed: 349 additions & 65 deletions
File tree
- packages
- core/src/canvas
- ui/src/features/canvas
- components
- hooks
- stores
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
56 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
57 | 66 | | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
Lines changed: 13 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | 60 | | |
62 | 61 | | |
63 | 62 | | |
64 | | - | |
| 63 | + | |
65 | 64 | | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
69 | 68 | | |
70 | 69 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 70 | + | |
79 | 71 | | |
80 | 72 | | |
81 | 73 | | |
| |||
527 | 519 | | |
528 | 520 | | |
529 | 521 | | |
530 | | - | |
| 522 | + | |
531 | 523 | | |
532 | 524 | | |
533 | | - | |
534 | | - | |
535 | | - | |
| 525 | + | |
536 | 526 | | |
537 | 527 | | |
538 | 528 | | |
| |||
707 | 697 | | |
708 | 698 | | |
709 | 699 | | |
710 | | - | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
711 | 706 | | |
712 | 707 | | |
713 | 708 | | |
| |||
755 | 750 | | |
756 | 751 | | |
757 | 752 | | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
| 753 | + | |
772 | 754 | | |
773 | 755 | | |
774 | 756 | | |
| |||
803 | 785 | | |
804 | 786 | | |
805 | 787 | | |
806 | | - | |
| 788 | + | |
807 | 789 | | |
808 | 790 | | |
809 | 791 | | |
| |||
819 | 801 | | |
820 | 802 | | |
821 | 803 | | |
822 | | - | |
| 804 | + | |
823 | 805 | | |
824 | 806 | | |
825 | 807 | | |
| |||
Lines changed: 22 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
87 | 102 | | |
88 | 103 | | |
89 | 104 | | |
| |||
186 | 201 | | |
187 | 202 | | |
188 | 203 | | |
189 | | - | |
| 204 | + | |
| 205 | + | |
190 | 206 | | |
191 | 207 | | |
192 | | - | |
| 208 | + | |
193 | 209 | | |
194 | 210 | | |
195 | 211 | | |
| |||
225 | 241 | | |
226 | 242 | | |
227 | 243 | | |
228 | | - | |
| 244 | + | |
229 | 245 | | |
230 | 246 | | |
231 | 247 | | |
| |||
335 | 351 | | |
336 | 352 | | |
337 | 353 | | |
338 | | - | |
| 354 | + | |
339 | 355 | | |
340 | 356 | | |
341 | 357 | | |
342 | 358 | | |
343 | 359 | | |
344 | 360 | | |
345 | 361 | | |
346 | | - | |
| 362 | + | |
347 | 363 | | |
348 | 364 | | |
349 | 365 | | |
| |||
Lines changed: 2 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | | - | |
35 | 33 | | |
36 | 34 | | |
37 | 35 | | |
38 | 36 | | |
39 | | - | |
40 | 37 | | |
41 | 38 | | |
42 | 39 | | |
| |||
78 | 75 | | |
79 | 76 | | |
80 | 77 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 78 | + | |
| 79 | + | |
94 | 80 | | |
95 | 81 | | |
96 | 82 | | |
| |||
Lines changed: 79 additions & 0 deletions
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
| |||
19 | 25 | | |
20 | 26 | | |
21 | 27 | | |
22 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
23 | 35 | | |
24 | | - | |
25 | | - | |
26 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
27 | 44 | | |
28 | 45 | | |
29 | 46 | | |
0 commit comments