Skip to content

fix(webpush): do not push a repeated all_set for the same session - #10

Merged
chaodu-agent merged 1 commit into
mainfrom
fix/webpush-dedupe-all-set
Nov 26, 2026
Merged

chaodu-agent merged 1 commit into
mainfrom
fix/webpush-dedupe-all-set

Conversation

@chaodu-agent

Copy link
Copy Markdown
Contributor

Problem

Kiro sends an all_set on every turn end, so one session can produce several all_set events in a row, and each one became a Web Push.

Fix

nearpushd does not push an all_set when the same session's previous stateful event in the in-memory event buffer (buffer_size, the replay buffer) is already all_set.

  • Store::push_with_prior looks up, under the same lock as the insert, the newest buffered event with the same session that has a state. Stateless records (for example dismissed) are skipped.
  • commit() passes that state in PushCtx::prior_state; webpush::should_push drops all_set after all_set. This is the only change to the push decision.
  • Every state counts as a boundary, including working and states hidden by the filter or never pushed.
  • No prior event in the buffer (for example after a restart that rotated it out) pushes as before.
  • The event is still stored, broadcast, and shown on the page. your_turn and allow are unaffected. No new config key.
  • README and docs/apple-watch.md get one sentence each.

Design choices

  • Events without a session have nothing to match on, so they are never deduplicated.
  • A muted (paused) all_set still counts as the prior, so the first all_set after unpausing is skipped if the one before it, sent while paused, was also all_set. This follows rule (d): every state counts, pushed or not.

Tests

New: webpush::tests::repeated_all_set_is_not_pushed and store::tests::push_with_prior_reports_the_sessions_last_stateful_event. Together they cover: consecutive all_set suppressed, your_turn in between allows the next one, a stateless event in between is skipped, no prior pushes, sessions do not affect each other, and every event is still stored.

Run on macmini (fresh clone of this branch):

  • cargo test -p nearpushd: 215 passed, 0 failed (128 + 55 + 13 + 19)
  • cargo build --release --locked -p nearpushd: ok

Store::push_with_prior returns, under the store lock, the state of the
session's newest buffered event that has a state (stateless records such
as 'dismissed' are skipped). commit() passes it in PushCtx and should_push
drops an all_set whose prior is all_set. The event is still stored and
shown; your_turn/allow are unaffected; no prior in the buffer pushes.

Verified on macmini: cargo test -p nearpushd -> 215 passed, 0 failed
(128+55+13+19); cargo build --release --locked -p nearpushd -> ok.
@chaodu-agent
chaodu-agent marked this pull request as ready for review November 26, 2026 13:11
@chaodu-agent
chaodu-agent merged commit ad893dc into main Nov 26, 2026
1 check 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.

1 participant