feat(web): persist session-dot acknowledgements across reloads

`flags.done`/`flags.error` are unread markers: the plugin keeps raising them
until nvim's own TabEnter, while `markSeen` only cleared them in the in-memory
store. The next snapshot — a reload, or a reconnect's resync — replayed the
flag, so a notification the user had already consumed blinked again and the
dot looked stuck on unread.

The acknowledgement is now durable in `localStorage` (`pi2-seen-sessions`, per
browser), recorded under the occurrence it was given for: the id of the
transcript's newest entry. A replayed snapshot ends on the same entry, so
ingress clears the flag; the next completed turn appends entries first, so its
token differs and that new notification blinks again. A row with no entries
cannot be scoped and keeps the in-memory-only behaviour. `removeSession`
forgets the ledger row and the `tmp-N` → real-id migration moves it. This stays
a client-side view concern — the wire, the reducer and `fixtures/` are
untouched.
This commit is contained in:
yuez committed 2026-10-30 16:19:40 +08:00
1 parent 2f2f1bb518
commit 00c81a56f4
4 files changed
+261 -6

No files matched your search

+11
View File
@@ -122,6 +122,17 @@ so the session you open stops being green or red — which is why a viewed child
failure is solid while an unviewed one blinks. The canonical reducer (`src/protocol/reducer.ts`)
and `fixtures/` are deliberately untouched: this is a client-side view concern.
The acknowledgement is **durable**, because the plugin keeps raising the flag until nvim's own
`TabEnter`: an in-memory-only `markSeen` meant the next snapshot (a page reload, or a reconnect's
resync) replayed `done: true` and the green blink returned for a notification the user had
already seen. `web/src/features/chat/acknowledged.ts` persists it in `localStorage`
(`pi2-seen-sessions`, per browser) under the **occurrence** it was given for — the id of the
transcript's newest entry. A replayed snapshot is the same occurrence (same trailing entry id),
so the store clears the flag on ingress; the next completed turn appends entries first, so its
token differs and that new notification blinks again. A notification for a state with no entries
cannot be scoped and is never suppressed. `removeSession` forgets the row and the `tmp-N` →
real-id migration moves it.
## One clock for every dot
No dot animates itself. `web/src/lib/blink.ts` owns a single ref-counted 500ms interval that