FocusSession tries to focus an existing tab/pane that is already running the named harness binary with the given session UUID. The `binary` arg is the harness's executable name (e.g. "claude", "codex", "gemini") — backends use it to filter the process table down to relevant rows. Returns (true, nil)
(sessionID, binary string)
| 138 | // - Terminal.app: pid → tty via ps, then osascript walk |
| 139 | // - iTerm2 (default): pid → tty via ps, then osascript walk |
| 140 | func FocusSession(sessionID, binary string) (bool, error) { |
| 141 | switch Detect() { |
| 142 | case BackendZellij: |
| 143 | return zellij.FocusSession(sessionID, binary) |
| 144 | case BackendKitty: |
| 145 | return kitty.FocusSession(sessionID, binary) |
| 146 | case BackendTerminal: |
| 147 | return terminal.FocusSession(sessionID, binary) |
| 148 | default: |
| 149 | return iterm.FocusSession(sessionID, binary) |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | // ShellQuote is re-exported so callers don't need to import the chosen |
| 154 | // backend just to quote a value before handing it to SpawnTab. All |