Skip to content

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

Open
kyan0045 wants to merge 1 commit into
anomalyco:devfrom
kyan0045:permission-sound-autoaccept
Open

kyan0045 wants to merge 1 commit into
anomalyco:devfrom
kyan0045:permission-sound-autoaccept

Conversation

@kyan0045

@kyan0045 kyan0045 commented Oct 25, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #48579

Type of change

  • Bug fix

What does this PR do?

The TUI played the permission alert (sound plus terminal notification) for requests that were auto-approved and never shown, so auto-accept produced constant noise.

The permission.asked handler in feature-plugins/system/notifications.ts now skips the alert 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, the home screen, or a session opened as a subagent still alert, because those are not auto-approved and stay pending.

To read the live mode from that handler, the TUI plugin context gains ui.permission.mode() and an exported PermissionMode type. This is additive and existing plugins are unaffected, but it does widen the public plugin API, so it needs a maintainer decision.

This replaces #54901: I deleted my fork failing to realise that would close my pull requests. -_- That PR's review found the initial placement and scoping wrong; both were fixed before it closed.

Related: #53525 (closed as a duplicate of #48579)

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 run typecheck:tsc 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).

Related: #47545

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

@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 change looks correct. Its check matches what the session view actually auto-approves: the open session and its subagents in auto-accept mode, and nothing when the open session is itself a subagent. Since only one session view is mounted at a time, requests from other tabs or the home screen stay pending and still alert. The new tests pass, and type checks pass in packages/tui and packages/plugin. I could not reproduce the sound or notification end to end in a simulated TUI, because the simulated model never triggered a permission request.

Public API: adds ui.permission.mode(): PermissionMode to the TUI plugin context and exports the type PermissionMode = "prompt" | "autoaccept" from @opencode/plugin/tui/context. This is additive and backwards compatible for plugins that use the context. Code that builds its own TUI plugin context object (like the test harness here) now has to provide ui.permission. Maintainers should decide whether this belongs in the public plugin API.

One concern, noted inline: which requests get auto-approved is now decided in two places, and they can drift apart.

Related: #47545

})
}

function willAutoApprove(context: Plugin.Context, sessionID: string) {

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.

This copies the auto-approve scope from routes/session/index.tsx (the descendantSessionIDs/permissions memos and the auto-accept createEffect). If one changes without the other, for example if auto-accept starts covering other tabs or stops skipping subagent routes, requests will either be silenced while left pending (the bad case) or alert again. Could both places use one shared helper for the scope, or could a comment on each side point to the other, so they stay in sync?

This branch has not been deployed

No deployments
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

1 participant