Connect to another device without disconnecting first

Connect and Discover stay enabled while a device is connected. Pressing
Connect in the dialog drops the current device before the new one is
tried; cancelling the dialog leaves the connection alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 23:49:25 +03:00
co-authored by Claude Opus 5.5
parent dbeeb78916
commit 9b1d029b14
3 changed files with 32 additions and 9 deletions
+14 -4
View File
@@ -2316,7 +2316,8 @@ def do_device_connect():
wiresheet.render_components([])
app_state.window.title(app_state.base_window_title())
connect_dialog.ConnectDialog(app_state.window, _connect_to_device)
connect_dialog.ConnectDialog(app_state.window, _connect_to_device,
on_before_connect=_drop_device_before_connect)
def do_device_discover():
@@ -2337,7 +2338,18 @@ def do_device_discover():
wiresheet.render_components([])
app_state.window.title(app_state.base_window_title())
connect_dialog.DiscoverDialog(app_state.window, _connect_to_device)
connect_dialog.DiscoverDialog(app_state.window, _connect_to_device,
on_before_connect=_drop_device_before_connect)
def _drop_device_before_connect():
"""One device at a time: the one already connected goes before the next is tried.
Called when Connect is pressed, not when the dialog opens, so backing out of the
dialog leaves the current connection alone.
"""
if app_state.device_session is not None:
do_device_disconnect()
def _connect_to_device(host, port, user, password):
@@ -2358,8 +2370,6 @@ def _connect_to_device(host, port, user, password):
def _on_connected(ds, root_comp):
"""Main-thread callback after successful connect."""
app_state.window.title(app_state.base_window_title_live())
menu_device.entryconfig("Connect...", state="disabled")
menu_device.entryconfig("Discover...", state="disabled")
menu_device.entryconfig("Disconnect", state="normal")
menu_device.entryconfig("Download to SAX...", state="normal")
app_state.set_status(f"Connected to {app_state.device_host}:{app_state.device_port}")