Skip to content

Open terminal: bring back the app the session runs in - #238

Merged
Louis-CFM merged 1 commit into
Louis-CFM:mainfrom
mateuslamaral:fix/jump-to-session-terminal
Oct 8, 2026
Merged

Louis-CFM merged 1 commit into
Louis-CFM:mainfrom
mateuslamaral:fix/jump-to-session-terminal

Conversation

@mateuslamaral

Copy link
Copy Markdown

What

"Open terminal" (finished card), the ⌃⌥T Jump to terminal shortcut and tapping a session now bring back the app the session actually runs in, instead of the first running app from a fixed list.

Why

The three places that jump to a terminal each had their own copy of ["com.apple.Terminal", "com.googlecode.iterm2", "net.kovidgoyal.kitty", "com.mitchellh.ghostty"]. With Claude Code running in any other terminal (cmux in my case, but also Warp, WezTerm, Alacritty…), none of those is running, so Coucou opens a new Terminal.app window instead of going back to the session.

nb-hook already sends the session's app as bundle_id (__CFBundleIdentifier), so the information is there. It just wasn't used for jumping.

How

  • AgentTask.sessionBundleId, stored next to sessionCwd by upsertWorkspaceTask from the hook's bundle_id.
  • TerminalTarget (Foundation only): candidates = the session's app first, then the known terminals, now including cmux, Warp, WezTerm and Alacritty.
  • TerminalTarget.activate(sessionBundleId:) (AppKit) replaces the three copies of the list. If nothing is running, the existing fallback (open Terminal.app) is unchanged.
  • Integrated terminals benefit too: a session in VS Code's terminal goes back to VS Code.

No visual change, no new permission, nothing new for the App Store build (all call sites are still under #if !APPSTORE).

Tests

bash scripts/test-terminal-target.sh

Covers: session app preferred, VS Code session, fallback order, blank or missing bundle id, nothing running, no duplicate entries.

Built with xcodegen && xcodebuild -scheme NotchBuddy -configuration Debug build: BUILD SUCCEEDED. The two new files are picked up by xcodegen. I left the regenerated project.pbxproj out of this PR: the committed one is behind project.yml on main, so regenerating it adds ~900 unrelated lines.

How to reproduce the bug

  1. Run Claude Code in cmux (or Warp), with no Terminal/iTerm/kitty/Ghostty open.
  2. Let a session finish and click Open terminal, or press ⌃⌥T.
  3. Before: a new Terminal.app window opens. After: cmux comes to the front.

🤖 Generated with Claude Code

"Open terminal" and the Jump to terminal shortcut picked the first running
app from a fixed list (Terminal, iTerm, kitty, Ghostty). Sessions in any
other terminal (cmux, Warp, WezTerm, Alacritty...) got a new Terminal.app
window instead.

The hook already sends the session's app as bundle_id. Keep it on the task
next to sessionCwd and activate that app first, then fall back to the known
terminals (now including cmux, Warp, WezTerm and Alacritty), then
Terminal.app as before. The three copies of the list now share
TerminalTarget, which has Foundation-only tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Louis-CFM
Louis-CFM merged commit 18cb7e6 into Louis-CFM:main Oct 8, 2026
Louis-CFM added a commit that referenced this pull request Oct 8, 2026
…ht app (#326)

Terminal sessions in the notch, and Open terminal brings back the right app (#282, #238)

Copy link
Copy Markdown
Owner

Merged in #326 — thank you @mateuslamaral! "Open terminal" now brings back the app the session actually runs in, VS Code included (that fixes #291). I combined it with #282's terminal detection: Claude Code's terminal first, then the session's app, then any running terminal. 🙏


Generated by Claude Code

JhoanG956 pushed a commit to JhoanG956/coucou that referenced this pull request Oct 8, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LJm3SRL9k3gBPaVtfPhwcT
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