Skip to content

fix(tui): suppress permission sound while auto-approve is on - #54901

Closed
kyan0045 wants to merge 2 commits into
anomalyco:devfrom
kyan0045:permission-sound-autoaccept
Closed

kyan0045 wants to merge 2 commits into
anomalyco:devfrom
kyan0045:permission-sound-autoaccept

Conversation

@kyan0045

@kyan0045 kyan0045 commented Oct 12, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #48579

Type of change

  • Bug fix

What does this PR do?

The TUI alerted (sound plus terminal notification) whenever the agent asked for permission, even when that request was auto-approved and never shown to the user. Two paths auto-approve: the auto-approve permission setting, and the --auto flag. The permission request still fires in both, so the alert was noise.

The alert is now skipped only for requests this client will actually auto-approve: the open session and its subagents while the live permission mode is auto-accept. Requests from another tab, from the home screen, or from a session opened as a subagent still alert, because those are not auto-approved and stay pending. Question, done, error, and other sounds are unaffected. This also covers the --auto case reported in #53525.

The check lives in the permission.asked handler in feature-plugins/system/notifications.ts, so createTuiAttention stays generic. To read the live mode there, the TUI plugin context gains ui.permission.mode() and an exported PermissionMode type. Both are additive, so existing plugins are unaffected. Flagging it because it does widen the public plugin API.

How did you verify your code works?

bun test test/cli/cmd/tui/notifications.test.ts in packages/tui covers auto-accepted requests staying silent, requests outside the open session still alerting, and subagent-applied requests staying silent. bun typecheck is clean in packages/tui and packages/plugin.

Screenshots / recordings

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Fixes #53525

Related: #52486

Public API: adds ui.permission.mode() and the PermissionMode type to the TUI plugin context (backwards compatible)

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is right, but as written this can hide alerts for permissions that are still waiting for the user. I checked the code and ran the new tests (bun test test/attention.test.ts: 3 pass) and the type check (bun run typecheck in packages/tui: clean). I couldn't play audio in the sandbox, so I didn't check the sound end to end.

Public API: unchanged (createTuiAttention's new permissionMode input is internal; its only caller is AttentionProvider).

Concerns:

  1. Pending permissions can go silent. In the v2 TUI, auto-accept happens in the client: only the open session route replies to permission requests, and only for the open session and its subagents (routes/session/index.tsx, the autoApproved effect). A permission from a session in another tab, or one that arrives while you're on the home screen, is not approved and stays pending. With this change it also plays no sound, so the user may never notice it. The sound should be skipped only for requests this client will actually auto-approve.
  2. Layer. createTuiAttention backs context.attention.notify, which plugins use. Hard-coding the permission sound name there silences any caller that asks for that sound. The permission.asked handler in feature-plugins/system/notifications.ts is a better place, since it knows the request's session and can apply the rule from (1).
  3. The terminal notification for the same event still fires when the terminal isn't focused. That's the spam described in #53525, so that issue is only partly addressed.

Related: #53525, #52486

Comment thread packages/tui/src/attention.ts Resolved
@kyan0045

kyan0045 commented Oct 12, 2026 •

Copy link
Copy Markdown
Author

/opencode The spam described in #53525 seems like it should have it's own issue.

@kyan0045
kyan0045 force-pushed the permission-sound-autoaccept branch from 96849b1 to 0c10bae Compare October 12, 2026 18:54
@kyan0045
kyan0045 force-pushed the permission-sound-autoaccept branch from c78b606 to 54f3db7 Compare October 12, 2026 18:58
@kyan0045

Copy link
Copy Markdown
Author

/opencode review the latest changes

@opencode-agent

Copy link
Copy Markdown
Contributor

User kyan0045 does not have write permissions

github run

@kyan0045

Copy link
Copy Markdown
Author

@simonklee since you own #48579, would you mind taking a look/re-running the review whenever you have a moment?

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My two earlier concerns are resolved. The check now sits in the permission.asked handler in notifications.ts and skips the alert only for requests this client actually auto-approves (the open top-level session and its subagents). Pending permissions elsewhere still alert, and createTuiAttention is generic again. It also suppresses the terminal notification for those requests, not only the sound.

I ran bun test test/cli/cmd/tui/notifications.test.ts (13 pass) and bun run typecheck in packages/tui and packages/plugin (clean). Sound playback can't be observed in the sandbox, so I didn't check it end to end in a running TUI.

Public API: the plugin API gains ui.permission.mode(): "prompt" | "autoaccept" and an exported PermissionMode type in @opencode/plugin/tui/context. Existing plugins keep working. This does make the permission mode part of the public plugin API, which maintainers should agree to.

No other concerns.

Fixes #53525
Related: #52486

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.

Don't play permission sound if auto-approve is on TUI V2 attention sounds are still played despite --auto flag

1 participant