fix(sessions): recognise iTermServer daemon so focus works#116
Open
StuBehan wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tolaunchd, not under the iTerm2 app — and the app itself isn't in the process parent chain to walk up to.SessionStore.walkParentChainonly did exact matches against"iTerm2"/"iTerm", so the version-suffixed daemon name (e.g.iTermServer-3.6.11) never matched.terminalAppstayednil, which:focusSelectedSession()bail at itsbundleID(for:)guard → focus was a silent no-op, andITerm2Integration.enrich(which filters onterminalApp.contains("iTerm")) to skip enrichment → no tabId / tabName / colour.Changes
SessionStore— newcanonicalTerminalApp(_:)normalises theiTermServer-*daemon back to the canonical"iTerm2", so every downstream check (bundleID lookup, iTerm enrichment, focus) recognises it. (the unblocker)Panel.focusSelectedSession()— routesession.tabIdto the activation param the terminal actually reads:ipcHookfor VSCode/Cursor/Antigravity (VSCODE_IPC_HOOK_CLI),sessionIDfor iTerm2 (its session GUID). PreviouslytabIdwas dropped entirely, so focus landed on whatever window the app last had frontmost.AppActivator.focusIterm2Session— match iTerm2 sessions onunique id(the persistent GUID our enrichment andITERM_SESSION_IDboth carry), withidkept as a fallback.Testing
swiftc -typecheck panel/*.swift shared/*.swift— clean.Follow-ups (not in this PR)
notify.sh:walk_session_chainhas the sameiTermServergap on the nudge focus path (partly masked byTERM_PROGRAM/ITERM_SESSION_ID).notify.shbut not by the Sessions tab, and isn't focusable inAppActivatorat all.🤖 Generated with Claude Code