[PR #57] [CLOSED] Fix window focus when opening files from CLI #65

Closed
opened 2026-03-03 16:43:35 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/nickustinov/itsypad-macos/pull/57
Author: @nickustinov
Created: 2/25/2026
Status: Closed

Base: mainHead: fix/cli-launch-focus


📝 Commits (1)

  • 5068f15 Fix window focus when opening files from CLI

📊 Changes

3 files changed (+11 additions, -3 deletions)

View changed files

📝 CHANGELOG.md (+5 -0)
📝 Sources/App/AppDelegate.swift (+4 -1)
📝 project.yml (+2 -2)

📄 Description

Fixes #52

When opening files via open -a Itsypad file.txt, the window would load the file but stay behind by one window layer instead of coming to the foreground.

Root cause: NSApp.activate(ignoringOtherApps: true) was called immediately before the file opening operation completed, causing a race condition where the window system hadn't fully processed the window changes before activation was requested.

Solution: Defer the activation call to the next run loop iteration using DispatchQueue.main.async. This ensures the window is fully initialized with the file content before requesting focus, allowing macOS to properly bring the window to the foreground.

Testing: Run open -a Itsypad somefile.txt from Terminal and verify that Itsypad window comes to the front and becomes active.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/nickustinov/itsypad-macos/pull/57 **Author:** [@nickustinov](https://github.com/nickustinov) **Created:** 2/25/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/cli-launch-focus` --- ### 📝 Commits (1) - [`5068f15`](https://github.com/nickustinov/itsypad-macos/commit/5068f15117d85d2c2bb86524d63572920caf098d) Fix window focus when opening files from CLI ### 📊 Changes **3 files changed** (+11 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+5 -0) 📝 `Sources/App/AppDelegate.swift` (+4 -1) 📝 `project.yml` (+2 -2) </details> ### 📄 Description Fixes #52 When opening files via `open -a Itsypad file.txt`, the window would load the file but stay behind by one window layer instead of coming to the foreground. *Root cause:* `NSApp.activate(ignoringOtherApps: true)` was called immediately before the file opening operation completed, causing a race condition where the window system hadn't fully processed the window changes before activation was requested. *Solution:* Defer the activation call to the next run loop iteration using `DispatchQueue.main.async`. This ensures the window is fully initialized with the file content before requesting focus, allowing macOS to properly bring the window to the foreground. *Testing:* Run `open -a Itsypad somefile.txt` from Terminal and verify that Itsypad window comes to the front and becomes active. 🤖 Generated with Claude Code --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 16:43:35 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/itsypad-macos#65
No description provided.