Skip to content

fix(ancs): treat the opening replay as backlog when there is nothing to compare it to - #349

Merged
zackb merged 1 commit into
zackb:mainfrom
fernando2393:pr/ancs-first-replay
Nov 25, 2026
Merged

zackb merged 1 commit into
zackb:mainfrom
fernando2393:pr/ancs-first-replay

Conversation

@fernando2393

Copy link
Copy Markdown
Contributor

Follow-up to #348, for the gap discussed in #346: the first session after the daemon starts has no earlier copy to match against, and since #343 the daemon restarts at every logout, so the same old entries still popped up once per login.

Change

When a session starts with an empty registry, the run of additions that opens it is marked pre-existing. The run is the first addition within 10 s of subscribing, then no gap over 1 s (ReplayBurst). Everything in that replay was already on the phone. A notification that happens to land inside the burst is still listed, just without a popup. Later sessions are untouched and rely on #348. This uses the daemon's own monotonic clock, never the phone's Date.

Testing

  • ReplayBurst unit tests: the opening run counts, a late addition after the run doesn't, nothing counts without a start or once the start window has passed, and only additions belong to it. The suite passes.
  • On my iPhone, after a daemon restart, the replay arrived 240 ms after subscribing (all within 32 ms). All 6 entries that iOS left unflagged were marked, and nothing popped up.

Independent of #348: they touch different functions, and either can land first.

🤖 Generated with Claude Code

@zackb zackb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just needs the comments fixed and rebase on main

// up, so the same notification arrives again after each reconnect. Dedupe is
// on the notification UID, but a Modified event is a genuine update the user
// should see, so it is never suppressed by having seen the UID before.
// The replay that opens a session with nothing earlier to compare it against (the daemon just started): iOS does

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was inserted between NotificationRegistry class and it's comments

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved ReplayBurst above it, and rebased on main.

…to compare it to

an earlier session. The first session after the daemon starts has no earlier
copy, and since zackb#343 the daemon restarts at every logout, so the same old
entries still popped up once per login.

When a session starts with an empty registry, the run of additions that opens it
(the first within ReplayBurst::START of subscribing, then no gap longer than
ReplayBurst::GAP) is marked pre-existing. Everything in that replay was already
on the phone. A notification that lands inside the burst is still listed, just
without a popup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fernando2393

Copy link
Copy Markdown
Contributor Author

Heads-up: this and #341 both add tests at the end of test_ancs_notifications.cpp, so whichever is merged second will conflict there. Either order is fine, and I'll rebase the other one right after.

@zackb
zackb merged commit d5d05d0 into zackb:main Nov 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants