Skip to content

lib: fix current_tab/current_session race - #152

Open
tml wants to merge 1 commit into
wouterdebie:masterfrom
tml:fix/window-current-tab-race
Open

lib: fix current_tab/current_session race#152
tml wants to merge 1 commit into
wouterdebie:masterfrom
tml:fix/window-current-tab-race

Conversation

@tml

@tml tml commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

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.

Comment thread setup.py

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
tml force-pushed the fix/window-current-tab-race branch from 2327514 to 6c6ea5d Compare August 31, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant