Normalize iTerm2 session ID alias handling#33
Merged
Conversation
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.
Summary
Normalize iTerm2 session ID aliases before session lookup so CLI commands accept both shell-facing IDs and canonical API IDs.
Changes
normalize_session_idinsrc/it2/core/session_handler.pyto convertw<window>t<tab>p<pane>:<GUID>andw<window>t<tab>p<pane>.<GUID>into canonical GUIDs.get_session_by_idhelper insrc/it2/core/session_handler.pyand route session resolution through this helper.session focusinsrc/it2/commands/session.pyto use normalized lookup.profile applyinsrc/it2/commands/profile.pyto use normalized lookup.app broadcast addinsrc/it2/commands/app.pyto use normalized lookup.tests/test_session_handler.py,tests/test_session_commands.py,tests/test_profile_commands.py, andtests/test_app_commands.pyto cover alias formats.Why
iTerm2 often exposes session IDs via shell integration values (e.g.
ITERM_SESSION_IDandsession.termid) that include window/tab/pane prefixes. The Python API lookup uses exactSession.session_idGUID matching, so alias IDs can fail even when the session exists.Notes
activeandallremain unchanged.blackformatting totests/test_session_commands.py.Testing
uv run --with ruff ruff check src testsuv run --with mypy --with types-PyYAML mypy srcuv run --with black black --check .uv run --with pytest-asyncio pytest -q tests/test_session_handler.py tests/test_session_commands.py tests/test_profile_commands.py tests/test_app_commands.py