Skip to content

fix(sessions): recognise iTermServer daemon so focus works#116

Open
StuBehan wants to merge 1 commit into
mainfrom
fix/sessions-focus-window
Open

fix(sessions): recognise iTermServer daemon so focus works#116
StuBehan wants to merge 1 commit into
mainfrom
fix/sessions-focus-window

Conversation

@StuBehan

@StuBehan StuBehan commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Problem

Pressing ⏎ Focus on the Sessions tab did nothing — it never brought the session's window/tab to the front. The tab also showed reduced session data (no terminal name, tab label, or accent colour) for iTerm2 sessions.

Root cause

iTerm2 3.5+ runs each session under a detached iTermServer-<version> daemon (session restoration) that is parented to launchd, not under the iTerm2 app — and the app itself isn't in the process parent chain to walk up to.

SessionStore.walkParentChain only did exact matches against "iTerm2"/"iTerm", so the version-suffixed daemon name (e.g. iTermServer-3.6.11) never matched. terminalApp stayed nil, which:

  • made focusSelectedSession() bail at its bundleID(for:) guard → focus was a silent no-op, and
  • caused ITerm2Integration.enrich (which filters on terminalApp.contains("iTerm")) to skip enrichment → no tabId / tabName / colour.

Changes

  • SessionStore — new canonicalTerminalApp(_:) normalises the iTermServer-* daemon back to the canonical "iTerm2", so every downstream check (bundleID lookup, iTerm enrichment, focus) recognises it. (the unblocker)
  • Panel.focusSelectedSession() — route session.tabId to the activation param the terminal actually reads: ipcHook for VSCode/Cursor/Antigravity (VSCODE_IPC_HOOK_CLI), sessionID for iTerm2 (its session GUID). Previously tabId was dropped entirely, so focus landed on whatever window the app last had frontmost.
  • AppActivator.focusIterm2Session — match iTerm2 sessions on unique id (the persistent GUID our enrichment and ITERM_SESSION_ID both carry), with id kept as a fallback.

Testing

  • swiftc -typecheck panel/*.swift shared/*.swift — clean.
  • Verified live: with the daemon recognised, iTerm2 sessions show their terminal/tab metadata again and ⏎ jumps to the exact pane.

Follow-ups (not in this PR)

  • notify.sh:walk_session_chain has the same iTermServer gap on the nudge focus path (partly masked by TERM_PROGRAM/ITERM_SESSION_ID).
  • Zed is recognised by notify.sh but not by the Sessions tab, and isn't focusable in AppActivator at all.

🤖 Generated with Claude Code

iTerm2 3.5+ runs each session under a detached iTermServer-<version>
daemon parented to launchd, not under the iTerm2 app — so terminalApp
never matched, which dropped tab enrichment and made Enter-to-focus a
silent no-op. Normalise the daemon to "iTerm2", route session.tabId to
the correct activation param (ipcHook for VSCode/Cursor, sessionID for
iTerm2), and match iTerm2 sessions on `unique id` (with `id` fallback).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant