Add Device > Discover menu with standalone discovery dialog

Discover dialog shows a device list with Port, Wait Time fields and a
Discover button. Selecting a device and clicking Connect (or double-
clicking) opens a credentials prompt for username/password, then
connects. The Connect dialog is reverted to its original simple form.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-19 13:42:18 +03:00
co-authored by Claude Opus 4.6
parent ef5437ed36
commit 55f76d60df
3 changed files with 271 additions and 67 deletions
+24
View File
@@ -1960,6 +1960,27 @@ def do_device_connect():
connect_dialog.ConnectDialog(app_state.window, _connect_to_device)
def do_device_discover():
"""Opens the discover dialog to scan for devices on the network."""
if app_state.current_file_path and not app_state.live_mode:
if app_state.is_dirty:
answer = messagebox.askyesnocancel(
"Unsaved Changes",
"The current file has unsaved changes.\n\n"
"Save before connecting to a device?",
)
if answer is None:
return
if answer:
sax_file.execute_direct_overwrite_save()
sax_file.reset_to_startup_state()
sax_file.refresh_treeview_from_dom(None)
wiresheet.render_components([])
app_state.window.title(app_state.base_window_title())
connect_dialog.DiscoverDialog(app_state.window, _connect_to_device)
def _connect_to_device(host, port, user, password):
"""Called from the connect dialog's background thread."""
ds = device_session.DeviceSession()
@@ -1979,6 +2000,7 @@ 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}")
@@ -2044,6 +2066,7 @@ def do_device_disconnect():
app_state.window.title(app_state.base_window_title())
menu_device.entryconfig("Connect...", state="normal")
menu_device.entryconfig("Discover...", state="normal")
menu_device.entryconfig("Disconnect", state="disabled")
menu_device.entryconfig("Download to SAX...", state="disabled")
app_state.set_status("Disconnected")
@@ -2222,6 +2245,7 @@ menu_bar = tk.Menu(window)
menu_device = tk.Menu(menu_bar, tearoff=0)
menu_device.add_command(label="Connect...", command=do_device_connect)
menu_device.add_command(label="Discover...", command=do_device_discover)
menu_device.add_command(label="Disconnect", command=do_device_disconnect, state="disabled")
menu_device.add_separator()
menu_device.add_command(label="Download to SAX...", command=do_download_to_sax, state="disabled")