Skip to content

Let a restarted OpenCode window receive peer messages without typed input (narrowed form (a) of closed #2006) - #2014

Closed
dmlguq456 wants to merge 1 commit into
mainfrom
opencode-idle-adopt-1129
Closed

dmlguq456 wants to merge 1 commit into
mainfrom
opencode-idle-adopt-1129

Conversation

@dmlguq456

Copy link
Copy Markdown
Owner

What

The narrowed form (a) of the closed #2006: a resting OpenCode window that was open across an install receives peer messages without anyone typing in it first.

Cause. An install changes the OpenCode config, so OpenCode starts the Hearting plugin again. The new instance has seen no event of a session that was already resting, so its own sessions list is empty, and its existing 5 s tick starts only after the first turn (env()). The window stays native-pending ("input not settled, type once") until someone types.

Change (existing path only, +60 net production lines).

  1. An OpenCode 2 instance arms its existing tick at its start (arm() is the old timer block, moved into a function).
  2. Inside that tick, when the pending folder's time moved (the first tick always lists), the new read-only peer-message.py pending --recipients names the sessions a message waits for (cap 32, no keys).
  3. Each listed session that is this directory's root session (existing foreign / child / worker checks) and answers session.wait joins the instance's own sessions with its status filled.
  4. Sending, completion notices and watch wake stay with the existing tick, its own idle check and delivery as before.

Not brought back from #2006: peerRetry, keys, skip limits, truncated/gone, claim-held, transient-failure classes, a new claim rule. A listing that failed is simply asked again on the next tick; a busy session joins by its own next session.idle.

Tests

  • opencode_v2_plugin.test.py: a fresh instance (no env(), no status event) lists once, adopts only the resting root session, sends on the next tick; foreign / child / worker sessions are never read twice nor looked after; zero helper calls while the folder time stands still, one per change; a failed or unreadable listing is asked again.
  • peer_message.test.py: pending --recipients lists only pending rows that resolve to a valid OpenCode session, newest first, capped, and writes nothing.
  • Real TUI scenes (harness_behavior_cases_idle_adopt.py, private tmux, loopback model, throwaway HOME): rest / busy / permission form / another directory's session. The rest scene fails on origin/main and passes here.

What changes for the user

Situation Before After
Resting OpenCode window open across an install, peer message arrives waits until someone types once received within seconds, no input
Busy window waits for the turn same
Permission / question form open waits until answered same
Another directory's session not this window's same
Claude and Codex — unchanged

Known limit: a session that was merely busy at the first look joins by its own next session.idle, as before.

🤖 Generated with Claude Code

…nput

An install restarts the OpenCode plugin, and the new instance has seen no
event of a session that was already resting: its own session list is empty
and its 5 s tick starts only after the first turn, so a resting window held
its peer messages until someone typed once.

Narrowed form (a) of the closed #2006: the instance arms its existing tick at
its start, and inside that tick, when the pending folder's time moved, the new
read-only `peer-message.py pending --recipients` names the sessions a message
waits for. Each root session of this directory (the existing foreign, child
and worker checks) that answers `wait` joins the instance's own `sessions`
with its status filled; sending, completion and watch wake stay with the
existing tick and its own idle check. No retry state, key, claim rule or
second delivery path is added.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@dmlguq456 dmlguq456 closed this Nov 29, 2026
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