SwitchStation Download free for Mac

Notification Click Opens the Wrong Terminal Window

Updated · SSS Flow

Not with the built-in notification. An osascript notification belongs to Script Editor, terminal-notifier can bring an app forward but not one of its windows, and Claude Code's hook input has no window or tab id. DIY fixes raise the window whose title contains the project name; they work until titles change or two windows share a folder.

I get a macOS notification when Claude Code needs me, but clicking it doesn't help. It opens Script Editor, or it brings up the terminal app on whatever window was in front last. I have three Cursor windows and two Warp windows open, so I still end up hunting for the right one. Is there a fix?

Put together from 5 similar questions on GitHub, Hacker News and Product Hunt. Links at the end.

Three nested levels, app, window and tab; a click on a macOS notification reaches the app level but not the right window or the right tab inside it

Short answer

Not with the built-in notification, and not cleanly with a hook.

The DIY fix that works best raises the window whose title contains the project name. It works until titles change or two windows share a folder.

Why does the click land in the wrong place?

There are three levels a click can reach, and each needs more information than the one before:

  1. App: bring Cursor to the front. Easy. Every app has a bundle id.
  2. Window: bring the second Cursor window to the front. You need to know which window the session runs in. The hook doesn't tell you.
  3. Tab: select the right tab or terminal pane inside that window. You need the app's own scripting support, and each terminal is different.

Most fixes stop at level 1. That is why the click "works" with one window and fails with three.

App ≠ window ≠ tab. A fix is only as good as the level it can reach.

What do people usually try?

1. The osascript notification from the docs

"command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"

This is the first example in the hooks guide. It's good for "something happened". Clicking it opens Script Editor, because that is the app that posted it. Level reached: none.

2. terminal-notifier with -activate

terminal-notifier posts a notification from the command line and can act on the click. -activate <bundle id> will "bring an application to the front":

terminal-notifier -title "Claude Code" -message "api-server needs you" -activate com.todesktop.230313mzl4w4u92

(That id is Cursor's. Find any app's id with osascript -e 'id of app "Warp"'.)

Level reached: app. Cursor comes forward, but on the window you used last, not the one that needs you.

3. Raise the window by its title

This is the workaround in claude-code#30672, where its author calls it "fragile". The hook knows cwd. Most editors put the folder name in the window title. So find the window whose title contains the folder name, and raise it:

-- raise.applescript: osascript raise.applescript Cursor api-server
on run {appName, folderName}
  tell application "System Events" to tell process appName
    set frontmost to true
    perform action "AXRaise" of (first window whose name contains folderName)
  end tell
end run

Run it from terminal-notifier -execute "osascript /path/raise.applescript Cursor api-server", so it happens on click. Whatever runs it needs the Accessibility permission.

Level reached: window, when the title cooperates. Where it stops:

4. Map the session to its terminal by TTY

People in claude-code#57592 record which TTY each session started on, then use ps and the terminal's scripting to find that tab. In theory this reaches level 3. In practice the author called it "fragile and per-user", and it breaks as soon as you switch terminal apps. That issue was closed as not planned too.

FixLevel reachedBreaks when
osascript notificationNone (opens Script Editor)Always, for clicking
terminal-notifier -activateAppMore than one window of that app
Raise window by titleWindowTitle doesn't contain the folder, or two windows share it
TTY mappingTab (one terminal app)You use more than one terminal or editor

What do these fixes still miss?

The click handler is the easy part. The hard part is identity. The event says which folder needs you, not which window, and several windows can share one folder. Anything that wants to land on the right window has to remember, for each session, where it actually runs. And it has to keep remembering when windows move, close or change titles.

SwitchStation's answer

Official answer · SSS Flow

SwitchStation Rail is a free, open source macOS app that does that remembering.

Illustration: A Rail row for the sample project web-app is clicked, and the second of two Cursor windows comes to the front while the first stays behind

What Rail does not do:

See how SwitchStation Rail works.

Download free for Mac

Sources

Tested 2026-12-01 against the current Claude Code docs and terminal-notifier 3.x.