feat(local-terminal): close orphaned native tab on session kill#141
Merged
Conversation
The local_terminal feature opened a native iTerm/Terminal/emulator tab
per session that ran `tmux attach …; exec ${SHELL} -l`. The unconditional
exec tail was meant to survive a manual detach (Ctrl-b d) without losing
scrollback — but it also kept the tab alive as a bare login shell after a
session kill, leaving a leftover tab on every /kill.
Guard the tail on the per-window group session still existing:
`tmux attach …; tmux has-session -t <group> && exec …`. A manual detach
leaves the group alive (shell stays, scrollback preserved); kill_window
tears the group down (see _kill_grouped_session_for_window), so has-session
fails, the bash -c wrapper exits cleanly, and the host terminal closes the
now-orphaned tab. Applied to both the macOS and Linux command builders.
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.
Проблема
При включённом
local_terminalкаждая новая сессия открывает нативную вкладку iTerm/Terminal/эмулятора, которая запускаетtmux attach …; exec ${SHELL} -l. Безусловныйexec-хвост был нужен, чтобы пережить ручной detach (Ctrl-b d) без потери scrollback — но он же оставлял вкладку висеть голым логин-шеллом после kill сессии, замусоривая iTerm на каждый/kill.Фикс
Хвостовой
execстал условным от живости per-window group-сессии:kill_windowсносит group (_kill_grouped_session_for_window) →has-sessionпадает →bash -cвыходит чисто → терминал закрывает осиротевшую вкладку.Применено к обоим билдерам команд — macOS (
_build_tmux_command) и Linux (_build_linux_shell_cmd).Проверки
ruff check/ruff format --check— ✅pyright— ✅ 0 errorstest_exec_guarded_by_has_session,test_linux_exec_guarded_by_has_session— ✅🤖 Generated with Claude Code