feat: Restart Claude Desktop button after save (#9)
After a successful save, shows a 'Restart Claude Desktop' button next to the status line. Only shown when the saved profile targets Claude Desktop (core.profile_targets_claude_desktop) -- never for Claude Code, which has no GUI process to bounce. Clicking it calls core.restart_claude_desktop() and reports success/failure. The button hides again on further edits or when switching/reloading profiles.
This commit is contained in:
@@ -1135,9 +1135,19 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
root.addLayout(self._build_actionbar())
|
root.addLayout(self._build_actionbar())
|
||||||
|
|
||||||
|
status_row = QHBoxLayout()
|
||||||
|
status_row.setContentsMargins(0, 0, 0, 0)
|
||||||
self.status = QLabel("Ready.")
|
self.status = QLabel("Ready.")
|
||||||
self.status.setObjectName("statusbar")
|
self.status.setObjectName("statusbar")
|
||||||
root.addWidget(self.status)
|
status_row.addWidget(self.status, 1)
|
||||||
|
self.restart_btn = QPushButton("Restart Claude Desktop")
|
||||||
|
self.restart_btn.setToolTip(
|
||||||
|
"Quit and relaunch Claude Desktop so the saved config takes effect"
|
||||||
|
)
|
||||||
|
self.restart_btn.clicked.connect(self._restart_claude_desktop)
|
||||||
|
self.restart_btn.hide()
|
||||||
|
status_row.addWidget(self.restart_btn)
|
||||||
|
root.addLayout(status_row)
|
||||||
|
|
||||||
self._restore_layout()
|
self._restore_layout()
|
||||||
self.reload_profiles()
|
self.reload_profiles()
|
||||||
@@ -1384,6 +1394,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.current_profile = profile
|
self.current_profile = profile
|
||||||
self.servers = core.extract_servers(self.full_config)
|
self.servers = core.extract_servers(self.full_config)
|
||||||
self.dirty = False
|
self.dirty = False
|
||||||
|
self.restart_btn.hide()
|
||||||
self._undo_stack.clear()
|
self._undo_stack.clear()
|
||||||
self.undo_btn.setEnabled(False)
|
self.undo_btn.setEnabled(False)
|
||||||
self._refresh_tables(select_index=0 if self.servers else -1)
|
self._refresh_tables(select_index=0 if self.servers else -1)
|
||||||
@@ -1753,6 +1764,7 @@ class MainWindow(QMainWindow):
|
|||||||
f"Merged & saved {self.current_profile.path}{bnote}"
|
f"Merged & saved {self.current_profile.path}{bnote}"
|
||||||
f" · Restart {self.current_profile.label} to apply."
|
f" · Restart {self.current_profile.label} to apply."
|
||||||
)
|
)
|
||||||
|
self._offer_restart_button()
|
||||||
return
|
return
|
||||||
# else OVERWRITE: fall through to normal write
|
# else OVERWRITE: fall through to normal write
|
||||||
|
|
||||||
@@ -1770,6 +1782,29 @@ class MainWindow(QMainWindow):
|
|||||||
self.status.setText(
|
self.status.setText(
|
||||||
f"Saved {self.current_profile.path}{bnote} · Restart {self.current_profile.label} to apply."
|
f"Saved {self.current_profile.path}{bnote} · Restart {self.current_profile.label} to apply."
|
||||||
)
|
)
|
||||||
|
self._offer_restart_button()
|
||||||
|
|
||||||
|
# --- restart Claude Desktop (issue #9) -------------------------------- #
|
||||||
|
def _offer_restart_button(self):
|
||||||
|
"""Show the 'Restart Claude Desktop' button after a successful save,
|
||||||
|
but only when the just-saved profile is Claude Desktop -- restarting
|
||||||
|
makes no sense for Claude Code, which has no GUI process to bounce."""
|
||||||
|
if self.current_profile and core.profile_targets_claude_desktop(self.current_profile):
|
||||||
|
self.restart_btn.show()
|
||||||
|
else:
|
||||||
|
self.restart_btn.hide()
|
||||||
|
|
||||||
|
def _restart_claude_desktop(self):
|
||||||
|
self.restart_btn.setEnabled(False)
|
||||||
|
try:
|
||||||
|
result = core.restart_claude_desktop()
|
||||||
|
finally:
|
||||||
|
self.restart_btn.setEnabled(True)
|
||||||
|
self.restart_btn.hide()
|
||||||
|
if result.success:
|
||||||
|
self.status.setText(f"{self.status.text()} · {result.detail}")
|
||||||
|
else:
|
||||||
|
QMessageBox.warning(self, "Restart failed", result.detail)
|
||||||
|
|
||||||
def _restore_from_backup(self):
|
def _restore_from_backup(self):
|
||||||
if not self.current_profile:
|
if not self.current_profile:
|
||||||
@@ -1798,6 +1833,7 @@ class MainWindow(QMainWindow):
|
|||||||
# --- dirty / status -------------------------------------------------- #
|
# --- dirty / status -------------------------------------------------- #
|
||||||
def _mark_dirty(self):
|
def _mark_dirty(self):
|
||||||
self.dirty = True
|
self.dirty = True
|
||||||
|
self.restart_btn.hide()
|
||||||
self._validate()
|
self._validate()
|
||||||
self._update_status(saved=False)
|
self._update_status(saved=False)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user