Repository navigation
Commit 4c92a01
fix(observer-feed): replace activeChannelId token with resetGeneration counter
Channel-string equality fails the A→B→A case: an in-flight old-A request
snapshotting channelId="A" passes every guard after the user returns to A,
allowing it to mark fresh-A exhausted and steal fresh-A's fetch lock.
Replace activeChannelId-as-ownership with a monotonically increasing
resetGeneration counter in ArchivePagingState. applyChannelReset()
increments it on every call. fetchOlderArchived snapshots the counter at
request start and rechecks snapshot === ps.resetGeneration after every
async boundary (backfill, Tauri read, ingest). The finally block clears
ps.isFetching only if the snapshot still matches. A→B→A produces gen
sequences 1→2→3, so old-A (gen=1) is always rejected by fresh-A (gen=3)
regardless of channel name. activeChannelId is retained as a diagnostic
label only — not as an ownership token.
Mounted-hook regressions updated:
- test (a) comment corrected: this test was GREEN at dfb2d03 (stale
closure was already fixed in round 1, not this round)
- test (b) extended with a lock-probe step: after stale A resolves, call
fetchOlderArchived() directly while B's first read is in flight and
assert no new Tauri read starts (lock held). This makes the test fail
independently when the finally guard is removed — not just when the
post-ingest exhaustion write is present.
- test (c) new: A→B→A mounted regression. Old-A's decrypt deferred,
switch A→B→A, fresh-A's first read deferred. Resolves old-A first,
then lock-probes (concurrent call must be rejected), then resolves
fresh-A and asserts it reads ≥2 pages.
Mutation verification (run before this commit):
- Remove post-ingest check (line ~342): tests (b) and (c) go RED ✓
- Remove finally guard (line ~357): tests (b) and (c) go RED ✓
Co-authored-by: Will Pfleger <[email protected]>
Signed-off-by: Will Pfleger <[email protected]>1 parent af45fbf commit 4c92a01
3 files changed
Lines changed: 330 additions & 83 deletions
File tree
- desktop/src/features/agents/ui
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
40 | 45 | | |
41 | 46 | | |
42 | 47 | | |
| |||
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
| 62 | + | |
57 | 63 | | |
58 | 64 | | |
59 | 65 | | |
| |||
64 | 70 | | |
65 | 71 | | |
66 | 72 | | |
67 | | - | |
68 | | - | |
| 73 | + | |
| 74 | + | |
69 | 75 | | |
70 | 76 | | |
71 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
72 | 84 | | |
73 | 85 | | |
74 | 86 | | |
| |||
81 | 93 | | |
82 | 94 | | |
83 | 95 | | |
| 96 | + | |
84 | 97 | | |
85 | 98 | | |
86 | 99 | | |
| |||
0 commit comments