Skip to content

fix(opencode): debounce UserPromptSubmit to prevent spam sounds - #566

Open
GuillaumeAmat wants to merge 1 commit into
PeonPing:mainfrom
GuillaumeAmat:fix/opencode-debounce-userpromptsubmit
Open

fix(opencode): debounce UserPromptSubmit to prevent spam sounds#566
GuillaumeAmat wants to merge 1 commit into
PeonPing:mainfrom
GuillaumeAmat:fix/opencode-debounce-userpromptsubmit

Conversation

@GuillaumeAmat

@GuillaumeAmat GuillaumeAmat commented Aug 5, 2026

Copy link
Copy Markdown

Context

I've just migrated from Claude Code to OpenCode, and while I loved the PeonPing experience in Claude Code, it's been a "nightmare" with OpenCode: all the (sub)agents throw sounds at me at the same time 😅

I've tried to enable the suppress_subagent_complete and suppress_delegate_sessions settings, but it didn't help.

GLM 5.2 came with the fix I'm proposing in this PR. Happy to rework/refine it if you find any issue. Cheers!

Problem

OpenCode fires multiple session.status: busy events per interaction. The adapter forwarded each one as UserPromptSubmit, hitting peon.sh's spam threshold (3 events / 10s) and triggering user.spam sounds repeatedly — even with suppress_subagent_complete and suppress_delegate_sessions enabled (those only affect subagent/delegate sessions, not the main session).

Related closed issues that fixed adjacent problems but left this gap:

Fix

Add an isBusy flag in the adapter that tracks whether the session is already in busy state. UserPromptSubmit now only fires on the first transition to busy — subsequent busy events during the same interaction are silently skipped. The flag resets on session.idle, session.error, or any non-busy status.

Verification

peon debug on
# ... use opencode for a few interactions ...
peon logs --last 50
# Before: multiple [route] category=user.spam per interaction
# After: only ONE [route] category=user.spam (or none if under threshold)
peon debug off

Changes

  • adapters/opencode/peon-ping.ts: +10/-2
    • Added let isBusy = false alongside existing session state
    • Set isBusy = false in session.idle and session.error handlers
    • Gate firePeon("UserPromptSubmit") behind !isBusy in session.status handler
    • Reset isBusy = false on non-busy/non-running status

OpenCode fires multiple session.status:busy events per interaction.
Each was forwarded as UserPromptSubmit, hitting the spam threshold
(3/10s) and triggering user.spam sounds repeatedly.

Add isBusy flag: only fire UserPromptSubmit on first busy transition,
skip subsequent busy events until session goes idle or errors.

Fixes PeonPing#336 PeonPing#458 (remaining gap after those fixes)
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

@GuillaumeAmat is attempting to deploy a commit to the Gary Sheng's projects Team on Vercel.

A member of the Team first needs to authorize it.

@workflow

Copy link
Copy Markdown

Independently hit this and confirmed the diagnosis — multiple busy events per interaction tripping the user.spam threshold (Linux/NixOS, opencode + GLM). One suggestion: tracking busy state per sessionID (e.g. a Set, added on first busy, cleared on idle/error/non-busy) instead of a single isBusy flag would keep the debounce correct when several sessions run in one opencode instance — with a global flag, a second session's first prompt is suppressed while another session is busy. Otherwise works great as a fix for the single-session case.

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.

2 participants