* Sync one-shot probe: asks tmux directly whether this client is in control * mode via `#{client_control_mode}`. Runs on first isTmuxControlMode() call * when the env heuristic can't decide; result is cached. * * Sync (spawnSync) because the answer gates whether we enter fullscreen — an * async
()
| 54 | * query whatever tmux server happens to be running rather than our client. |
| 55 | */ |
| 56 | function probeTmuxControlModeSync(): void { |
| 57 | // Seed cache with heuristic result so early returns below don't leave it |
| 58 | // undefined — isTmuxControlMode() is called 15+ times per render, and an |
| 59 | // undefined cache would re-enter this function (re-spawning tmux in the |
| 60 | // failure case) on every call. |
| 61 | tmuxControlModeProbed = isTmuxControlModeEnvHeuristic() |
| 62 | if (tmuxControlModeProbed) return |
| 63 | if (!process.env.TMUX) return |
| 64 | // Only probe when iTerm might be involved: TERM_PROGRAM is iTerm.app |
| 65 | // (covered above) or not set (SSH often doesn't propagate it). When |
| 66 | // TERM_PROGRAM is explicitly a non-iTerm terminal, skip — tmux -CC is |
| 67 | // an iTerm-only feature, so the subprocess would be wasted. |
| 68 | if (process.env.TERM_PROGRAM) return |
| 69 | let result |
| 70 | try { |
| 71 | result = spawnSync( |
| 72 | 'tmux', |
| 73 | ['display-message', '-p', '#{client_control_mode}'], |
| 74 | { encoding: 'utf8', timeout: 2000 }, |
| 75 | ) |
| 76 | } catch { |
| 77 | // spawnSync can throw on some platforms (e.g. ENOENT on Windows if tmux |
| 78 | // is absent and the runtime surfaces it as an exception rather than in |
| 79 | // result.error). Treat the same as a non-zero exit. |
| 80 | return |
| 81 | } |
| 82 | // Non-zero exit / spawn error: tmux too old (format var added in 2.4) or |
| 83 | // unavailable. Keep the heuristic result cached. |
| 84 | if (result.status !== 0) return |
| 85 | tmuxControlModeProbed = result.stdout.trim() === '1' |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * True when running under `tmux -CC` (iTerm2 integration mode). |
no test coverage detected