fix: preserve macOS app lifecycle on window close#105
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThe changes implement a comprehensive window lifecycle management system for the Electron app, addressing platform-specific behavior around window closure and app termination. The solution introduces deep-link queuing/flushing for windows awaiting readiness, multi-window support with intelligent window selection, and IPC-based coordination between main and renderer processes. Changes
Sequence Diagram(s)sequenceDiagram
participant Renderer
participant MainProcess as Main Process
participant DeepLinkQueue as Deep-Link Queue
Renderer->>MainProcess: External deep link arrives (on-url/second-instance)
MainProcess->>DeepLinkQueue: emitDeepLinks() checks shouldQueueDeepLinks()
alt mainWindow not ready
DeepLinkQueue-->>DeepLinkQueue: Queue deep links
else mainWindow ready
DeepLinkQueue-->>Renderer: Send deep links immediately
end
Renderer->>Renderer: Register handler via onDeepLink()
Renderer->>MainProcess: reportDeepLinkReady() via IPC
MainProcess->>MainProcess: Mark window in deepLinkReadyWindows
MainProcess->>DeepLinkQueue: flushPendingDeepLinksForReadyWindow()
DeepLinkQueue->>DeepLinkQueue: takeQueuedDeepLinksForReadyWindow()
DeepLinkQueue-->>Renderer: Flush queued deep links
Renderer->>Renderer: Handler processes deep links
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request refactors the Electron window lifecycle management by introducing a dedicated module and unit tests. Key changes include platform-specific handling for window closing and activation, improved deep link queuing, and more flexible menu command targeting. A potential race condition was identified in the deep link handling logic where links could become stuck in the queue if they arrive while the main window is still loading.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
Fix macOS window lifecycle so closing the last PawWork window with Cmd+W keeps the app process running instead of quitting.
Add a small tested lifecycle helper for macOS window-close behavior, activate-based window restoration, deep-link queueing while no window is ready, and focused-window menu command routing.
Why
Fixes #96.
PawWork used Electron's File > Close role, but the main process did not handle window-all-closed or activate. On macOS, closing the last BrowserWindow therefore quit the app instead of keeping PawWork available in the Dock/menu bar.
Related Issue
Fixes #96
How To Verify
Manual check: launched the built Electron app from this branch with an isolated temporary HOME, waited for CI smoke readiness, sent Cmd+W via System Events, and confirmed the process stayed alive. Then activated the app again and confirmed it stayed alive after recreating/focusing a window.
Screenshots or Recordings
Not applicable. This is desktop shell lifecycle behavior, not a visible UI change.
Checklist
devbranchSummary by CodeRabbit
New Features
Tests