Skip to content

Add OS notifications for turn completions#1780

Open
malekelkssas wants to merge 2 commits intopingdotgg:mainfrom
malekelkssas:feature/turn-notifications
Open

Add OS notifications for turn completions#1780
malekelkssas wants to merge 2 commits intopingdotgg:mainfrom
malekelkssas:feature/turn-notifications

Conversation

@malekelkssas
Copy link
Copy Markdown

@malekelkssas malekelkssas commented Apr 6, 2026

  • New setting to enable/disable notifications when turns finish
  • Tracker detects thread state transitions (running → idle/error/stopped)
  • Notifications only show when tab is unfocused; fallback to in-app toast when focused
  • Handles permission requests and restricted contexts gracefully

What Changed

Added system-level (OS) notifications that fire when a turn finishes and the
user is not actively focused on the app. Includes a toggle in Settings → General.

  • New enableTurnCompletionNotifications client setting (off by default)
  • Tracks thread session transitions (running → idle/ready/error/stopped/interrupted)
  • Fires native OS notification via the Notification API when the page loses focus
  • Falls back to an in-app toast when the tab is actively focused
  • Automatically prompts for browser notification permission when toggled on
  • Seeds tracker from snapshot so page refreshes mid-turn still detect completion

Why

When running long agent tasks, users often switch to another app (terminal, IDE,
browser tab) while waiting. There was no way to know the turn finished without
manually checking back. This adds an ambient signal through the OS notification
system so the user gets notified wherever they are — same as any other desktop
notification on their system (Linux, macOS, Windows).

UI Change

Notification setting

after

video record for the notification trigger

Screencast_._.webm

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Medium Risk
Adds new client setting and hooks notification logic into the root orchestration event pipeline; behavior depends on browser Notification permissions/focus detection and could introduce noisy or missed notifications if tracking is wrong.

Overview
Adds opt-in OS-level notifications when an orchestration turn completes, driven by a new enableTurnCompletionNotifications client setting (default off).

Introduces turnCompletionNotifier.ts to track running threads from snapshots and thread.session-set events, request notification permission, and emit browser Notifications only when the page isn’t actively focused (with graceful fallback).

Wires the notifier into __root.tsx’s event-batch processing to detect running→non-running transitions and either show an OS notification or fall back to an in-app toast; also adds a Settings toggle (with reset support) that prompts for permission when enabled.

Reviewed by Cursor Bugbot for commit 08b67ff. Configure here.

Note

Add OS notifications for thread turn completions

  • Adds a new enableTurnCompletionNotifications boolean to settings.ts (default false) and a toggle in the General Settings panel that requests browser Notification permission on enable.
  • Adds turnCompletionNotifier.ts with utilities to track running threads, detect turn-completion transitions from event batches, and fire OS notifications when the page is not focused.
  • The event router in __root.tsx calls these utilities on each event batch, falling back to in-app toasts when OS notifications are unavailable or permission is denied.
  • Behavioral Change: enabling the setting will trigger a browser permission prompt; OS notifications are only sent when the page is not focused.

Macroscope summarized 08b67ff.

- New setting to enable/disable notifications when turns finish
- Tracker detects thread state transitions (running → idle/error/stopped)
- Notifications only show when tab is unfocused; fallback to in-app toast when focused
- Handles permission requests and restricted contexts gracefully
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a200676f-4412-4b74-a9d3-557d1e8536ed

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 6, 2026
@malekelkssas
Copy link
Copy Markdown
Author

@cursor review

@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 6, 2026

Approvability

Verdict: Needs human review

This PR introduces a new user-facing feature (OS browser notifications for turn completions) with ~190 lines of new logic, including state tracking and browser API integration. While the feature is gated behind a setting that defaults to off and is well-structured, new features introducing new user-facing behavior warrant human review regardless of how self-contained they are.

You can customize Macroscope's approvability policy. Learn more.

- Update the tracker to replace running threads with those from the current snapshot, ensuring accurate state representation.
- Integrate notification permission request into settings panel for turn completion notifications.
- Adjust settings restoration to include the new turn completion notification option.
@malekelkssas
Copy link
Copy Markdown
Author

@cursor review

Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 08b67ff. Configure here.

(id) => useStore.getState().threads.find((t) => t.id === id),
(id) => useStore.getState().projects.find((p) => p.id === id),
)
: [];
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.

Tracker state becomes stale when notifications are disabled

Low Severity

When notificationsEnabledRef.current is false, extractTurnCompletions is entirely skipped. This function has a critical side effect: it maintains the runningThreadIds module-level tracker by adding IDs on "running" events and removing them on completion events. Skipping it when notifications are disabled means stale "running" entries accumulate and are never cleaned up. If a thread was tracked as "running" before notifications were toggled off, and the thread completes during the disabled period, its ID stays in the set. When notifications are re-enabled, any subsequent non-running session-set for that thread could trigger a spurious completion notification. The tracker update logic needs to run unconditionally, independent of whether notifications are shown.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 08b67ff. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant