Skip to content

Commit 8bc0f82

Browse files
feat: add OPENCODE_NO_NOTIFY env var to suppress notifications
When opencode is invoked programmatically from an external harness (build orchestrators, CI pipelines, automation tools), desktop notifications are unhelpful and disruptive. Example: worktrunk (wt step commit) calls opencode run to generate commit messages — these sessions send "Ready for review" notifications that are pure noise since no human is waiting for them. Setting OPENCODE_NO_NOTIFY=1 or OPENCODE_NO_NOTIFY=true disables all notification types by returning an empty plugin at init time. This is opt-in — existing behavior is unchanged when the env var is not set.
1 parent 52f905d commit 8bc0f82

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ Configuration keys:
105105
- `sounds`: per-event sounds (`idle`, `error`, `permission`, optional `question`).
106106
- `quietHours`: scheduled suppression window.
107107

108+
### Disabling notifications with `OPENCODE_NO_NOTIFY`
109+
110+
When opencode is invoked programmatically from an external harness (build orchestrators, CI pipelines, automation scripts), desktop notifications are unhelpful and disruptive. Set the `OPENCODE_NO_NOTIFY` environment variable to suppress all notification types:
111+
112+
```bash
113+
OPENCODE_NO_NOTIFY=1 opencode run "your task"
114+
```
115+
116+
When set to `"1"` or `"true"`, the entire plugin is disabled at initialization — no event listeners are registered, no notifications are sent. This is opt-in; existing behavior is unchanged when the env var is not set.
117+
108118
**Available macOS sounds:** Basso, Blow, Bottle, Frog, Funk, Glass, Hero, Morse, Ping, Pop, Purr, Sosumi, Submarine, Tink
109119

110120
## FAQ
@@ -122,7 +132,7 @@ No. Smart defaults prevent noise:
122132

123133
### Can I disable it temporarily?
124134

125-
This plugin does not currently expose an `enabled` config flag. To disable notifications, remove/uninstall the plugin (for example: `ocx remove kdco/notify`) and add it back when needed.
135+
Set the `OPENCODE_NO_NOTIFY=1` environment variable to suppress all notifications for a session. See [Configuration](#disabling-notifications-with-opencode_no_notify) for details. To uninstall entirely, run `ocx remove kdco/notify` and add it back when needed.
126136

127137
## Supported Terminals
128138

src/notify.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,11 @@ async function handleQuestionAsked(
486486
// ==========================================
487487

488488
export const NotifyPlugin: Plugin = async (ctx) => {
489+
// When invoked programmatically from a harness, suppress all notifications
490+
if (process.env.OPENCODE_NO_NOTIFY === "1" || process.env.OPENCODE_NO_NOTIFY === "true") {
491+
return {}
492+
}
493+
489494
const { client } = ctx
490495

491496
// Load config once at startup

0 commit comments

Comments
 (0)