Notification Click Opens the Wrong Terminal Window
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.
Short answer
Not with the built-in notification, and not cleanly with a hook.
- A notification sent with
osascriptbelongs to Script Editor. The Claude Code docs say so: "osascriptroutes notifications through the built-in Script Editor app". Clicking it opens Script Editor. terminal-notifier -activatecan bring an app forward, but not a particular window of that app.- Claude Code's hook input has the session id and the folder (
cwd), but no window or tab id. The request to make the click focus the right window (claude-code#30672) was closed as not planned.
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:
- App: bring Cursor to the front. Easy. Every app has a bundle id.
- 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.
- 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:
- Terminal windows often don't show the folder. Claude Code sets its own terminal title by default, so the title may be the task, not the project.
- Two windows on the same repo (for example, a worktree opened twice) match the same name.
- It's per app. You need the right process name for each editor and terminal you use.
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.
| Fix | Level reached | Breaks when |
|---|---|---|
osascript notification | None (opens Script Editor) | Always, for clicking |
terminal-notifier -activate | App | More than one window of that app |
| Raise window by title | Window | Title doesn't contain the folder, or two windows share it |
| TTY mapping | Tab (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.
- It knows each session's window. When you start a Claude Code, Codex or Antigravity session, or send it a prompt, Rail notes the window you are typing in and keeps a reference to that window. It doesn't depend on the window title.
- Click the session, not the notification. Each session is a row on the Rail strip at the right edge of the screen. Clicking it brings that exact window forward, in the right app. That works with the second Cursor window, the third Warp window, iTerm2, Ghostty, Terminal or VS Code.
- It still works later. A notification disappears. The row stays until you deal with it, so you can click it ten minutes later.
What Rail does not do:
- It goes to the right window, not to the tab inside it. If one window holds three terminal tabs, you pick the tab. Inside SwitchStation Workspace it does go to the exact column.
- It doesn't replace your notifications. Rail can show its own banner, but the reliable path back is the row you click.
- Jumping to a window needs the macOS Accessibility permission. Rail uses it only for that. macOS 14 or later.
See how SwitchStation Rail works.
Related questions
- Background guide: Claude Code Notifications: Know When a Session Needs You
Sources
Tested 2026-12-01 against the current Claude Code docs and terminal-notifier 3.x.
- Anthropic: hooks guide (osascript and Script Editor), hooks reference (hook input fields)
- terminal-notifier README
- The question: claude-code#30672, #57592, #35206 (VS Code: focus the correct terminal), HN: back2vibing, Product Hunt: your agent is waiting