Repository navigation
fix: order session lists so states stop flapping and notifications repeat - #83
Merged
Merged
Conversation
The session-list heartbeat reaches a phone over every relay and over the direct link, and a bridge may publish one again, so lists arrive out of order, and a replay after a phone restarts brings old ones back. The optional `rev` (the bridge's clock in ms, strictly increasing) lets a phone apply only a list newer than the newest it applied. Co-Authored-By: Claude Code <noreply@anthropic.com>
Every session list carries a `rev`: the clock in ms, or one past the last when the clock has not moved past it (two lists in one millisecond, or a clock set back). The last one is stored, so a restarted bridge keeps counting up. Co-Authored-By: Claude Code <noreply@anthropic.com>
The same session list reaches the phone over every relay and the direct link, a bridge may publish one again, and after the phone restarts the direct link replays the last minutes of the bridge's events. Each was applied as it came, so a late list stepped sessions back (a finished turn showed as running again, or a newer session as stale) and the step forward afterwards announced the turn's end once more. The phone now remembers, per machine and across restarts, the rev of the newest list it applied and ignores any list no newer than that: no state change, no presence update, no notification. A session-failed message is also told once, not again when the same failure arrives a second time. Co-Authored-By: Claude Code <noreply@anthropic.com>
The agent repeats the turn state it is in (the Claude SDK reports `requires_action` and `running` alike as running), and each report published a new session list. Only a change of state now does. Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
deymosh
force-pushed
the
fix/session-state-ordering
branch
from
October 1, 2026 01:12
892e65b to
c35c6e1
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On the phone a session sometimes:
Cause (traced): the phone applied every session-list heartbeat as it arrived, with nothing to say which list was newest. The same list reaches the phone over every relay and over the direct link, the bridge can re-publish one, and after an app restart the direct link replays the last couple of minutes of the bridge's events. Any of these can apply an older list over a newer one, which:
Fix
sessionsgets an optionalrev, with a corpus fixture (valid and rejected).rev: the clock in ms, kept ahead of the stored last value, so a restart or a clock set back can't lower it. A list is also published only when a turn state actually changes.rev, persisted with the machine store. An older or equal list is ignored entirely: no state change, presence update or notification. Asession-failedis announced only once.Test plan
cargo clippy --workspace --all-targets -D warnings,cargo test --workspace-p bridge-runtime --test e2e -- --ignored)🤖 Generated with Claude Code