Skip to content

fix(v2): one alert per machine when several terminals show the same session - #139

Merged
mohak34 merged 1 commit into
mainfrom
fix/v2-one-alert-per-machine
Oct 6, 2026
Merged

mohak34 merged 1 commit into
mainfrom
fix/v2-one-alert-per-machine

Conversation

@mohak34

@mohak34 mohak34 commented Oct 6, 2026

Copy link
Copy Markdown
Owner

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

  • New tests: two V2 notifiers receiving the same event deliver once, and a new event still delivers; claim unit tests for first-wins and fail-open on an unusable temp directory. The V2 test fails on main.
  • Existing V2, notifier, delivery and index tests pass; typecheck passes.

Not checked

  • No manual run with two real OpenCode 2 terminals.
  • Only tested on Linux. Windows and macOS use their per-user temp directories, untested.

Surfaces

  • Hosts: V2 terminal only. V1 and V2 server untouched.
  • Channels: all terminal channels (sound, popup, bell, click command) follow the single claim.
  • Docs: README OpenCode 2 delivery, SPEC suppression order, CHANGELOG.

Generated with Claude Code using Claude Opus 5.5

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mohak34
mohak34 merged commit f26aa69 into main Oct 6, 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.

V2: several clients on the same session each alert for one event

1 participant