Skip to content

feat(cli): add OS desktop notifications for task completion and errors#27126

Open
PranavAgarkar07 wants to merge 1 commit into
anomalyco:devfrom
PranavAgarkar07:feat/cli-notifications
Open

feat(cli): add OS desktop notifications for task completion and errors#27126
PranavAgarkar07 wants to merge 1 commit into
anomalyco:devfrom
PranavAgarkar07:feat/cli-notifications

Conversation

@PranavAgarkar07
Copy link
Copy Markdown

@PranavAgarkar07 PranavAgarkar07 commented May 12, 2026

Issue for this PR

Related features requested in #7242, #13334, #18366 — partially addressed by PR #20963 for TUI mode. This PR complements #20963 by covering the non-interactive opencode run path.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When running opencode run, the session completes silently if you're not watching the terminal. The same happens in the TUI when the window is minimized or on another workspace.

This adds native OS desktop notifications (notify-send on Linux, osascript on macOS) on session idle and error events. A OPENCODE_DISABLE_NOTIFICATIONS env flag lets you opt out.

Relationship to PR #20963 (built-in TUI system notifications):

Dimension PR #20963 This PR
Mode TUI only (app.tsx) Non-interactive run + TUI
Notification body Generic "Task complete" Prompt title (bold) + agent/model + first lines of output or error
Config tui.json toggle OPENCODE_DISABLE_NOTIFICATIONS env flag
Focus detection Yes No

The two PRs target different execution paths and touch separate files. #20963 handles the case where you're working in the TUI and step away. This PR handles opencode run — where you submit a prompt and the session runs in the foreground, completing silently if you tab away.

Notification design:

Success:

Title: fix login bug
Body:  Claude 3.5 Sonnet (anthropic)
       The issue was in src/auth.ts where the token...

Error:

Title: fix login bug
Body:  ✗ timeout after 60 seconds of tool use

How did you verify your code works?

Ran a half-dozen prompts at various lengths through bun run --conditions=browser ./src/index.ts run "<prompt>" and watched for the notification popup:

  • Short prompts ("say hi") — notification shows the prompt title + agent name + single-line response
  • Long output — truncated to first 3 non-empty lines, 200 chars
  • Long prompt — truncated to 100 chars in title
  • Error case — shows ✗ prefix with error message
  • Edge cases with --continue, --command /help — agent/model tracking works through resume and command paths
  • Verified no code conflicts with feat(tui): built-in system notifications for session completion #20963 (touches different files / different areas of app.tsx)

Screenshots / recordings

N/A — CLI notifications, no UI change.

Checklist

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

- Add OPENCODE_DISABLE_NOTIFICATIONS flag to disable native notifications
- Create notify module with notify-send (Linux) and osascript (macOS) support
- Show rich notifications in non-interactive mode with prompt, agent/model, and output snippet
- Show native notifications on session idle/error in TUI mode
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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

I found 2 potentially related PRs:

  1. PR Add TUI notifications and attention sounds (disabled by default) #26980: "tui notifications (WIP)"

  2. PR feat(tui): built-in system notifications for session completion #20963: "feat(tui): built-in system notifications for session completion"

Both of these PRs appear to address desktop/system notifications functionality, which overlaps with the current PR's scope of adding OS notifications for task completion and errors in both CLI and TUI modes. You may want to check if these are closed/merged or if there's any duplicate work being done.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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