Skip to content

Implement notification actions and categories for timer events#151

Open
mookwoo wants to merge 4 commits into
michaelvillar:masterfrom
mookwoo:feature/notification-actions
Open

Implement notification actions and categories for timer events#151
mookwoo wants to merge 4 commits into
michaelvillar:masterfrom
mookwoo:feature/notification-actions

Conversation

@mookwoo
Copy link
Copy Markdown

@mookwoo mookwoo commented May 30, 2026

This pull request adds actionable notifications to the timer application, allowing users to interact directly with timer notifications (e.g., restart, add time, stop) and improves how notifications are handled and routed to the correct timer window. The main changes include registering notification categories, handling notification actions, associating notifications with specific timer controllers, and adding new timer control methods.

Notification actions and handling:

  • Registered a notification category with three actions ("Restart", "+5 min", "Stop") for timer completion notifications, enabling actionable notifications in the app (registerNotificationCategories in AppDelegate.swift). [1] [2]
  • Implemented a handler for notification actions that routes the selected action to the appropriate timer controller based on a unique identifier in the notification payload (userNotificationCenter(_:didReceive:withCompletionHandler:) and handleNotificationAction in AppDelegate.swift). [1] [2]

Timer controller enhancements:

  • Added a unique identifier property to each MVTimerController instance to associate notifications with specific timer windows.
  • Modified timer completion notifications to include the controller identifier and category, enabling precise action routing.

Timer control methods:

  • Added new methods to MVTimerController for restarting the last timer, adding five minutes, and resetting the timer, supporting the new notification actions.

Identifiers centralization:

  • Introduced a new MVNotificationIdentifiers enum to centralize all notification-related string constants.

Copilot AI review requested due to automatic review settings May 30, 2026 15:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds actionable “timer complete” notifications and routes notification actions back to the correct MVTimerController instance.

Changes:

  • Introduces notification category/action identifiers and a userInfo key for controller routing.
  • Attaches notification category + controller identifier to timer-complete notifications.
  • Implements UNNotificationCenter action handling to restart/add time/stop/open the corresponding timer window.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
Timer/MVUserDefaultsKeys.swift Adds shared notification identifier constants used across controller + AppDelegate.
Timer/MVTimerController.swift Adds per-controller UUID and new timer action helpers; enriches notification payload with category + routing info.
Timer/AppDelegate.swift Registers notification categories and handles notification actions by delegating to the correct controller.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Timer/AppDelegate.swift Outdated
Comment thread Timer/AppDelegate.swift
Comment thread Timer/AppDelegate.swift Outdated
Comment thread Timer/AppDelegate.swift Outdated
Comment thread Timer/MVUserDefaultsKeys.swift
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread Timer/AppDelegate.swift
Comment thread Timer/AppDelegate.swift Outdated
Comment thread Timer/AppDelegate.swift
@mookwoo
Copy link
Copy Markdown
Author

mookwoo commented Jun 1, 2026

Addressed the remaining Copilot review comments:

  • Split the notification userInfo key into MVNotificationUserInfoKeys so it is no longer grouped with notification category/action identifiers.
  • Reworked notification response handling to dispatch onto the main queue, perform the timer action, then call the completion handler afterward.
  • Applied the current staysOnTop window level when creating a fallback timer controller.
  • Aligned the notification “Stop” action with the existing stop command behavior.

Verified with make test.

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.

2 participants