Skip to content

Comments

feat: Implement desktop notifications for user permission prompts#14927

Closed
StoyanD wants to merge 48 commits intogoogle-gemini:mainfrom
StoyanD:feat/policy-notifications
Closed

feat: Implement desktop notifications for user permission prompts#14927
StoyanD wants to merge 48 commits intogoogle-gemini:mainfrom
StoyanD:feat/policy-notifications

Conversation

@StoyanD
Copy link
Contributor

@StoyanD StoyanD commented Dec 11, 2025

Summary

Implements desktop notifications for permissions, should ease multitasking when
using gemini-cli

Details

Fixes #14696

This PR implements OS-level desktop notifications when the Gemini CLI pauses and
requires user confirmation or input. This significantly improves the user
experience by alerting users immediately when their input is needed, even if
they are focused on another application. Clicking the notification will bring
the terminal into focus, allowing for quick interaction.

Notification demo video:

policy-notification-promt.mp4

Settings toggle:
Screenshot 2025-12-10 at 7 59 03 PM

Related Issues

Related to #14696

How to Validate

Request a policy ask required permission in Xterm/VScode terminal, and move to
another screen causing focus to switch. Should see a notification that when
clicked takes you back to the terminal

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

…ompts

This commit introduces desktop notifications to alert users when the Gemini CLI
requires their permission to execute a command, especially when the CLI
application is not in focus.

Key changes include:
- Added  setting to control notification behavior.
- Integrated  for cross-platform desktop notifications.
- Implemented  React hook to manage notification logic,
  considering application focus, operating system, and terminal program for
  proper activation on macOS.
- Included an icon asset for notifications.
Ensures that the desktop notification for user permission prompts is displayed
only once per confirmation event. Toggling application focus while waiting for
confirmation will no longer trigger repeated notifications.

- Added `useRef` to track notification state.
- Updated `useNotification` hook to reset state only when confirmation is no longer pending.
- Added regression tests for duplicate notification scenarios.
@StoyanD StoyanD requested review from a team as code owners December 11, 2025 01:49
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @StoyanD, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the user experience of the Gemini CLI by integrating desktop notifications. When the CLI requires user confirmation or input, and the application is not in focus, a system-level notification will now be triggered. This feature aims to improve multitasking efficiency by providing immediate alerts, with the added benefit on macOS of bringing the terminal back into focus upon clicking the notification. The functionality is controlled by a new "ui.enableNotifications" setting, allowing users to opt-in.

Highlights

  • Desktop Notifications: Implemented OS-level desktop notifications for user permission prompts in the Gemini CLI.
  • User Experience Improvement: Notifications alert users when input is needed, even when multitasking, and can bring the terminal into focus on click (macOS).
  • Configurable Setting: A new "ui.enableNotifications" boolean setting has been added, defaulting to "false", allowing users to enable or disable this feature.
  • New Hook & Dependencies: Introduced a "useNotification" React hook and added "node-notifier" and its related dependencies to handle cross-platform notifications.
  • Documentation & Schema Updates: The new setting is documented in "configuration.md" and defined in "settingsSchema.ts" and "settings.schema.json".
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces desktop notifications for user permission prompts, which is a great enhancement for user experience, especially when multitasking. The implementation is solid, leveraging node-notifier and a new React hook useNotification. The logic correctly handles different states, platform specifics for macOS, and terminals with poor focus detection support. The addition of comprehensive unit tests for the new hook is commendable and ensures the feature is robust. The configuration options are well-documented and integrated into the settings schema. Overall, this is a high-quality contribution, and I have no high or critical concerns.

@StoyanD
Copy link
Contributor Author

StoyanD commented Dec 11, 2025

@Alexmarco-gif can i get a review?

@nahid6970
Copy link

why anyone not reviewing i would love to havethis feature in windows

@StoyanD
Copy link
Contributor Author

StoyanD commented Dec 21, 2025

@nahid6970 do u have a windows machine? if so can you test this branch out to see if it works( im pretty sure it should)

@nahid6970
Copy link

@StoyanD how to test it in windows? i dont see anything related to notification in windows latest version of gemini

@StoyanD
Copy link
Contributor Author

StoyanD commented Dec 27, 2025

@nahid6970 you'd have to install this branch locally on a windows machine and test. The notification library I'm using is cross platform, so it should work. The way I've tested is using a command to create a file, then opening another app before the cli asks for permission. When the cli app asks for permission it's already backgrounded so it shows a notification

@samyarkd
Copy link

samyarkd commented Jan 2, 2026

This will be a big improvement to the user experience. I'm waiting for this.

@anowardear062-svg
Copy link

Thanks

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces desktop notifications for user permission prompts, which is a great enhancement for user experience. The implementation is solid, adding a new NotificationService and integrating it with the existing configuration and event systems. I've found one critical issue related to string quoting in a platform-specific command which would cause a crash on Windows, and another high-severity issue for using a synchronous, blocking call where an asynchronous one would be safer and more performant, aligning with our guidelines on avoiding blocking the event loop. Once these are addressed, the feature should be in good shape.

Replace blocking execSync with exec in focusUtils to improve event loop performance. Update NotificationService to handle async focus checks.
@StoyanD
Copy link
Contributor Author

StoyanD commented Jan 30, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a well-implemented desktop notification system for user permission prompts, which is a significant improvement to the user experience, especially for those who multitask. The implementation is robust, featuring a new NotificationService, integration with the policy engine through a notify flag, and a sophisticated focus detection mechanism with OS-level checks and fallbacks. The inclusion of terminal-specific notifications for iTerm, Kitty, and Warp demonstrates great attention to detail. The code is well-structured, thoroughly tested, and all relevant documentation and configuration schemas have been updated. Overall, this is a high-quality contribution with no major issues identified.

default:
return `Tool requires confirmation`;
}
const name = confirmationDetails.title.startsWith('Confirm: ')
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this changed?

@Adib234
Copy link
Contributor

Adib234 commented Feb 6, 2026

Pull Request Review

I have reviewed the changes in PR #14927. Overall, the implementation of desktop notifications is a great addition to the user experience. However, I've identified a few areas for improvement to ensure consistency with project standards and to prevent potential bugs.

Core Architecture & Memory Management

  • Memory Leak in Core Config: The NotificationService subscribes to both coreEvents and the MessageBus. In packages/core/src/config/config.ts, the notificationService.dispose() method should be called within the Config.dispose() method to ensure event listeners are properly cleaned up.
  • Settings Update Logic: The new ui.enableNotifications setting is marked with requiresRestart: false, but there is currently no logic to propagate settings changes to the NotificationService during a session. Please add an update mechanism in the core Config class to call notificationService.updateConfig() when settings are updated.

Test Quality & Best Practices

  • Use Existing Mocks: In NotificationService.test.ts, you are manually mocking the MessageBus. Please use the existing MockMessageBus from packages/core/src/test-utils/mock-message-bus.ts instead to maintain consistency and leverage existing test utilities.
  • Platform Mocking: For better Vitest consistency, consider using vi.spyOn(process, 'platform', 'get') rather than Object.defineProperty when mocking the operating system in tests.

General Observations

  • MacOS Seatbelt Verification: The focus detection on macOS relies on lsappinfo. Could you confirm if this command has been verified to work specifically when running within the MacOS Seatbelt sandbox?

Please let me know if you have any questions about these suggestions!

@Adib234
Copy link
Contributor

Adib234 commented Feb 6, 2026

Hi, thanks for addressing my comments! Sorry for getting back to you now, I was a bit busy this week 😅

- Propagate notification settings dynamically without restart
- Prevent memory leaks by disposing NotificationService in Config
- Improve tests with MockMessageBus and idiomatic platform spying
- Fix TypeScript errors in NotificationService callbacks
@StoyanD
Copy link
Contributor Author

StoyanD commented Feb 10, 2026

@Adib234 thanks for the reviews. i updated the pr

@StoyanD StoyanD requested a review from Adib234 February 10, 2026 21:38
@Adib234
Copy link
Contributor

Adib234 commented Feb 11, 2026

hi the build is failing

Copy link
Contributor

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

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

@StoyanD I did a quick pass.

We definitely want this to be disabled by default and be opt-in for the first little while.

Once we have more users testing it and any bugs or issues (Windows/Linux support) that may arise have been fixed we can then make it enabled by default.

Also I think we want to also notify when agent is finished, not just on tool/prompt confirmations.

Let me know what you think.

| Show Spinner | `ui.showSpinner` | Show the spinner during operations. | `true` |
| Enable Loading Phrases | `ui.accessibility.enableLoadingPhrases` | Enable loading phrases during operations. | `true` |
| Screen Reader Mode | `ui.accessibility.screenReader` | Render output in plain-text to be more screen reader accessible | `false` |
| Enable Notifications | `ui.enableNotifications` | Enable notifications for user permission prompts when the CLI is not in focus. Tested on mac, experimental on win/linux | `true` |
Copy link
Contributor

Choose a reason for hiding this comment

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

ui components should be Gemini CLI UI related flags.

Notifications are not a Gemini CLI UI specific setting, would rather see this move to general I think.

Comment on lines +321 to +323
- **Description:** Enable notifications for user permission prompts when the
CLI is not in focus. Tested on mac, experimental on win/linux
- **Default:** `true`
Copy link
Contributor

Choose a reason for hiding this comment

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

Should not default to true to begin with. Especially when we are saying this is potentially a macOS only feature. This should be opt-in to begin with and default to false.

Also does this only notify when use confirmation is needed? Or does it also notify when agent is finished?

I think we would want notifications on agent being done as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gemini-cli gemini-cli bot added the 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. label Feb 16, 2026
@scidomino
Copy link
Collaborator

Inspired by this PR we pulled out the MacOS stuff (which we felt is more stable) and will be merging our own version in #19056. The linux/win stuff feels shakier to us so we're leaving that out for now. Closing this out as support for non-macos should build on top of #19056.

Thanks for the contribution!

@scidomino scidomino closed this Feb 18, 2026
@helalsoft
Copy link

As a windows user, my disappointment is immeasurable and my day is ruined.

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

Labels

area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Desktop Notification for User Permission Prompts

9 participants