lib: fix current_tab/current_session race - #152
Open
tml wants to merge 1 commit into
Open
Conversation
tml
commented
Aug 28, 2026
Contributor
Author
There was a problem hiding this comment.
Not sure if you want to update this or not, if you want a new PR that doesn't update this LMK
…and tabs window.current_tab and tab.current_session depend on selected_tab_id and active_session_id, which iTerm2's Python API only populates via an async pubsub notification sent after tab/window creation. Reading them immediately after create_window/create_tab races that notification: on slower machines or heavier iTerm2 sessions the notification hasn't landed yet, so current_tab is still None and pane = window.current_tab.current_session raises AttributeError. Use the Tab object returned directly from creation instead, and read its sessions list (populated synchronously from the pane tree) rather than current_session. Also bump Python classifier/requires metadata to cover 3.9 and 3.13/3.14 support, and update the test suite to match the new create_window/create_tab return-value contract and shell/PATH fixture.
tml
force-pushed
the
fix/window-current-tab-race
branch
from
August 31, 2026 14:11
2327514 to
6c6ea5d
Compare
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.
on freshly created windows and tabs
window.current_tab and tab.current_session depend on selected_tab_id and active_session_id, which iTerm2's Python API only populates via an async pubsub notification sent after tab/window creation. Reading them immediately after create_window/create_tab races that notification: on slower machines or heavier iTerm2 sessions the notification hasn't landed yet, so current_tab is still None and pane = window.current_tab.current_session raises AttributeError.
Use the Tab object returned directly from creation instead, and read its sessions list (populated synchronously from the pane tree) rather than current_session. Also bump Python classifier/requires metadata to cover 3.9 and 3.13/3.14 support, and update the test suite to match the new create_window/create_tab return-value contract and shell/PATH fixture.