v1.9.26: disable terminal auto-connect on single click, require double-click
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
12
gui/app.py
12
gui/app.py
@@ -154,7 +154,7 @@ class App(ctk.CTk):
|
||||
self._paned.pack(fill="both", expand=True)
|
||||
|
||||
# Sidebar
|
||||
self.sidebar = Sidebar(self._paned, self.store, on_select=self._on_server_select, session_pool=self.session_pool)
|
||||
self.sidebar = Sidebar(self._paned, self.store, on_select=self._on_server_select, on_double_click=self._on_server_connect, session_pool=self.session_pool)
|
||||
self._paned.add(self.sidebar, minsize=180, width=self.store._sidebar_width)
|
||||
self.sidebar.add_callback = self._add_server
|
||||
self.sidebar.edit_callback = self._edit_server
|
||||
@@ -307,6 +307,12 @@ class App(ctk.CTk):
|
||||
# Update session indicators after a short delay (connection is async)
|
||||
self.after(1500, self.sidebar.update_session_indicators)
|
||||
|
||||
def _on_server_connect(self, alias: str):
|
||||
"""Double-click: connect interactive tabs (terminal, files, powershell)."""
|
||||
for key, widget in self._tab_instances.items():
|
||||
if hasattr(widget, "connect"):
|
||||
widget.connect()
|
||||
|
||||
def _add_server(self):
|
||||
dialog = ServerDialog(self, self.store)
|
||||
self.wait_window(dialog)
|
||||
@@ -356,6 +362,10 @@ class App(ctk.CTk):
|
||||
self.tabview.set(_tab_label(tab_key))
|
||||
except Exception:
|
||||
pass
|
||||
# Connect the target tab if it supports explicit connection
|
||||
widget = self._tab_instances.get(tab_key)
|
||||
if widget and hasattr(widget, "connect"):
|
||||
widget.connect()
|
||||
|
||||
def _context_check_status(self, alias: str):
|
||||
"""Context menu: check single server status in background."""
|
||||
|
||||
@@ -34,10 +34,11 @@ _CONTEXT_ACTIONS = {
|
||||
|
||||
|
||||
class Sidebar(ctk.CTkFrame):
|
||||
def __init__(self, master, store, on_select=None, session_pool=None):
|
||||
def __init__(self, master, store, on_select=None, on_double_click=None, session_pool=None):
|
||||
super().__init__(master, width=250, corner_radius=0)
|
||||
self.store = store
|
||||
self.on_select = on_select
|
||||
self.on_double_click = on_double_click
|
||||
self.session_pool = session_pool
|
||||
self._selected_alias: str | None = None
|
||||
self._server_frames: dict[str, ctk.CTkFrame] = {}
|
||||
@@ -272,6 +273,7 @@ class Sidebar(ctk.CTkFrame):
|
||||
# Click handlers
|
||||
for widget in [frame, info, name_label, detail_label, badge, type_badge, session_ind]:
|
||||
widget.bind("<Button-1>", lambda e, a=alias: self._select(a))
|
||||
widget.bind("<Double-Button-1>", lambda e, a=alias: self._on_double_click(a))
|
||||
widget.bind("<Button-3>", lambda e, a=alias: self._show_context_menu(e, a))
|
||||
|
||||
self._server_frames[alias] = frame
|
||||
@@ -371,6 +373,11 @@ class Sidebar(ctk.CTkFrame):
|
||||
if self.on_select:
|
||||
self.on_select(alias)
|
||||
|
||||
def _on_double_click(self, alias: str):
|
||||
self._select(alias)
|
||||
if self.on_double_click:
|
||||
self.on_double_click(alias)
|
||||
|
||||
def _highlight_selected(self):
|
||||
for alias, frame in self._server_frames.items():
|
||||
if alias == self._selected_alias:
|
||||
|
||||
@@ -307,13 +307,17 @@ class FilesTab(ctk.CTkFrame):
|
||||
stored_path, stored_sudo = self.session_pool.get_sftp_state(alias)
|
||||
if stored_path != "/":
|
||||
self._remote_path = stored_path
|
||||
# The stored sudo mode will be applied when the connection is established
|
||||
self._connect_sftp()
|
||||
self._remote_status.configure(text=t("sftp_click_to_connect"))
|
||||
else:
|
||||
self._remote_list.populate([])
|
||||
self._remote_status.configure(text=t("connect_to_browse"))
|
||||
self._set_remote_buttons_state("disabled")
|
||||
|
||||
def connect(self):
|
||||
"""Explicitly connect SFTP (double-click or context menu)."""
|
||||
if self._current_alias and not self._sftp:
|
||||
self._connect_sftp()
|
||||
|
||||
# ── SFTP connection ──
|
||||
|
||||
def _connect_sftp(self):
|
||||
|
||||
@@ -97,7 +97,12 @@ class PowershellTab(ctk.CTkFrame):
|
||||
self._set_status(t("ps_disconnected"), "#888888")
|
||||
return
|
||||
|
||||
self._connect(alias)
|
||||
self._set_status(t("term_click_to_connect").format(alias=alias), "#f59e0b")
|
||||
|
||||
def connect(self):
|
||||
"""Explicitly connect WinRM (double-click or context menu)."""
|
||||
if self._current_alias and not self._client:
|
||||
self._connect(self._current_alias)
|
||||
|
||||
# ── Connection ───────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -61,11 +61,16 @@ class TerminalTab(ctk.CTkFrame):
|
||||
|
||||
self._current_alias = alias
|
||||
if alias:
|
||||
self._connect()
|
||||
self._terminal.set_status(t("term_click_to_connect").format(alias=alias), "#f59e0b")
|
||||
else:
|
||||
self._terminal.reset()
|
||||
self._terminal.set_status(t("term_disconnected"), "#888888")
|
||||
|
||||
def connect(self):
|
||||
"""Explicitly connect (double-click or context menu)."""
|
||||
if self._current_alias and not self._session:
|
||||
self._connect()
|
||||
|
||||
def _connect(self):
|
||||
if not self._current_alias:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user