Repository navigation
fix(v2): one alert per machine when several terminals show the same session - #139
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Fixes #138.
Problem
On OpenCode 2, several terminals can attach to one server. When two or more of them show the same session, each one alerts for every event, so one finished task gives one popup and one sound per open terminal. #137 handled clients in other projects; this is the same-project case.
Fix
Policy: one alert per event per machine. Terminals on different machines each still alert.
Before delivering, a V2 terminal claims the event by creating a marker file in the user's temp directory, named by a hash of the project directory and the event's identity (the same keys the adapter already uses for replay dedupe: event ID, permission request ID, inbox ID, form ID, session ID). Only the first exclusive create succeeds; the other terminals skip delivery but still update their session state. Any error other than "already exists" fails open and delivers. Markers older than an hour are pruned.
The claim happens before focus suppression, so whichever terminal claims decides alone. V1 and V2 server commands are unchanged.
Checked
Not checked
Surfaces
Generated with Claude Code using Claude Opus 5.5