option('session') ?? Settings::settingValue('tmux_session') ?? config('tmux.session.default_name', 'nntmux'); $sessionManager = new TmuxSessionManager($sessionName); if (! $sessionManager->sessionExists()) { $this->error("❌ Session '{$sessionName}' does not exist"); $this->info("💡 Run 'php artisan tmux:start' to create it"); return Command::FAILURE; } $this->info("📎 Attaching to session '{$sessionName}'..."); $this->info('💡 Press Ctrl+A then D to detach'); // Select monitor pane before attaching so user lands there $paneManager = new TmuxPaneManager($sessionName); try { $monitorPane = $paneManager->paneForRole(TmuxPaneRole::Monitor, '0.0'); } catch (RuntimeException $exception) { $this->error('❌ '.$exception->getMessage()); return Command::FAILURE; } if (! $paneManager->selectWindow(0) || ! $paneManager->selectPane($monitorPane)) { $this->error('❌ Unable to select the tmux monitor pane.'); return Command::FAILURE; } return $sessionManager->attachSession() ? Command::SUCCESS : Command::FAILURE; } }