feat(cli): add macOS run-event notifications (interactive only)#19056
feat(cli): add macOS run-event notifications (interactive only)#19056
Conversation
Summary of ChangesHello @LyalinDotCom, 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 introduces a significant user experience improvement for macOS users of the interactive Gemini CLI by adding native notifications. The primary goal is to alert users to critical interactive prompts or the completion of a response when the CLI application is not in focus, thereby reducing the need for constant monitoring. The implementation carefully considers user preferences, platform specifics, and terminal capabilities to deliver a reliable and non-intrusive notification system. Highlights
Changelog
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable feature by adding macOS native notifications for interactive runs, improving user awareness for action-required states and response completions. The implementation is robust, with thoughtful handling of different terminal capabilities (OSC 9 with a BEL fallback) and unreliable focus event reporting. The logic for triggering notifications is comprehensive and well-tested. I've identified one area for improvement regarding string truncation to ensure correct handling of multi-byte Unicode characters, which is detailed in a specific comment. Overall, this is a great addition to the CLI.
|
Size Change: +11.4 kB (+0.05%) Total Size: 24.5 MB
ℹ️ View Unchanged
|
jackwotherspoon
left a comment
There was a problem hiding this comment.
What do you think about having the setting be general.enableNotifications instead of general.enableMacOsNotifications to be future proof.
A single setting vs 3 seems nicer to me.
|
I caught a few things I want to clean up before we merge. [ ] Refactor AppContainer: I realized I put too much one-off notification logic here. I’m going to move the state transitions into a dedicated hook composed of our existing selectors. [ ] DRY up string handling: I'm going to swap my bespoke string pipeline for the shared truncation/sanitization helpers we already have. [ ] Fix logic duplication: I need to reuse the existing confirmation queue/head selection logic rather than duplicating the pending-tool traversal. [ ] Terminal Capabilities: I'll replace the hardcoded OSC9 allowlists with actual capability detection (or at least centralized constants) and document the fallback paths. [ ] Magic Numbers: I need to remove the magic numbers (like the 220 cap) and encode them as documented constraints. [ ] Tests: I need to align the tests with vi.stubEnv conventions and add behavior tests for the cooldown/repeated prompts to ensure I haven't regressed notification delivery. [ ] Naming: I’m going to rename the scope to reflect transport semantics (OSC9 + BEL) rather than platform branding. |
|
Following up on my checklist, here is what I have fixed:
Implemented in commit |
| @@ -524,6 +545,358 @@ describe('AppContainer State Management', () => { | |||
| }); | |||
|
|
|||
There was a problem hiding this comment.
these tests need to be improved
c8c57d8 to
78d996f
Compare
85fb4d7 to
91f9338
Compare
Summary
This PR adds macOS notifications for interactive Gemini CLI runs and tightens trigger behavior so notifications only fire for in-run events that require user awareness.
Fixes #14696
Final Behavior
general.enableMacOsNotifications(default:false).process.platform === 'darwin').Responding -> IdleNotification Transport
Focus Handling
hasReceivedFocusEvent) so notifications still work when terminals do not emit focus events consistently.Settings / Schema / Docs
general.enableMacOsNotificationsto settings schema and docs.Tests
Updated and added tests across:
packages/cli/src/utils/macosNotifications.test.tspackages/cli/src/ui/AppContainer.test.tsxpackages/cli/src/ui/hooks/useFocus.test.tsxpackages/cli/src/gemini.test.tsxValidated suites include:
npm test -w @google/gemini-cli -- src/utils/macosNotifications.test.tsnpm test -w @google/gemini-cli -- src/ui/AppContainer.test.tsx src/ui/hooks/useFocus.test.tsxnpm test -w @google/gemini-cli -- src/gemini.test.tsx