Compare commits
9 Commits
9036729cd8
...
v1.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f535fb77f | |||
| 8cf19d43c4 | |||
| 0ef4586698 | |||
| ed7c40cac9 | |||
| 1384ed9703 | |||
| 41891ddad4 | |||
| 408f517c5d | |||
| 42456f25d2 | |||
| 5c476bb13f |
@@ -19,6 +19,7 @@ from PySide6.QtCore import QRect, QSettings, QSize, Qt, QThread, QTimer, QUrl, S
|
|||||||
from PySide6.QtGui import (
|
from PySide6.QtGui import (
|
||||||
QAction,
|
QAction,
|
||||||
QColor,
|
QColor,
|
||||||
|
QCursor,
|
||||||
QDesktopServices,
|
QDesktopServices,
|
||||||
QGuiApplication,
|
QGuiApplication,
|
||||||
QIcon,
|
QIcon,
|
||||||
@@ -51,6 +52,7 @@ from PySide6.QtWidgets import (
|
|||||||
QStyledItemDelegate,
|
QStyledItemDelegate,
|
||||||
QTableWidget,
|
QTableWidget,
|
||||||
QTableWidgetItem,
|
QTableWidgetItem,
|
||||||
|
QToolTip,
|
||||||
QVBoxLayout,
|
QVBoxLayout,
|
||||||
QWidget,
|
QWidget,
|
||||||
)
|
)
|
||||||
@@ -271,10 +273,31 @@ class KeyValueTable(QWidget):
|
|||||||
self.reveal_btn.setText("Hide secrets" if on else "Show secrets")
|
self.reveal_btn.setText("Hide secrets" if on else "Show secrets")
|
||||||
self.table.viewport().update()
|
self.table.viewport().update()
|
||||||
|
|
||||||
def _changed(self, *_):
|
def _changed(self, item=None, *_):
|
||||||
|
if item is not None and item.column() == 0:
|
||||||
|
new_key = item.text().strip()
|
||||||
|
row = item.row()
|
||||||
|
if new_key and self._is_duplicate_key(new_key, row):
|
||||||
|
prev_key = item.data(Qt.ItemDataRole.UserRole)
|
||||||
|
prev_key = prev_key if prev_key is not None else ""
|
||||||
|
self.table.blockSignals(True)
|
||||||
|
item.setText(prev_key)
|
||||||
|
self.table.blockSignals(False)
|
||||||
|
QToolTip.showText(QCursor.pos(), f"Duplicate key '{new_key}' — reverted.")
|
||||||
|
return
|
||||||
|
item.setData(Qt.ItemDataRole.UserRole, new_key)
|
||||||
if self._on_change:
|
if self._on_change:
|
||||||
self._on_change()
|
self._on_change()
|
||||||
|
|
||||||
|
def _is_duplicate_key(self, key: str, ignore_row: int) -> bool:
|
||||||
|
for r in range(self.table.rowCount()):
|
||||||
|
if r == ignore_row:
|
||||||
|
continue
|
||||||
|
other = self.table.item(r, 0)
|
||||||
|
if other and other.text().strip() == key:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def _add_row(self):
|
def _add_row(self):
|
||||||
dlg = QDialog(self.window())
|
dlg = QDialog(self.window())
|
||||||
dlg.setWindowTitle(f"Add {self._key_label}")
|
dlg.setWindowTitle(f"Add {self._key_label}")
|
||||||
@@ -301,6 +324,13 @@ class KeyValueTable(QWidget):
|
|||||||
grid.addWidget(val_edit, 1, 1)
|
grid.addWidget(val_edit, 1, 1)
|
||||||
v.addLayout(grid)
|
v.addLayout(grid)
|
||||||
|
|
||||||
|
# Shown when the typed key already exists in the table.
|
||||||
|
dup_warn = QLabel("")
|
||||||
|
dup_warn.setStyleSheet(f"color: {WARN};")
|
||||||
|
dup_warn.setWordWrap(True)
|
||||||
|
dup_warn.hide()
|
||||||
|
v.addWidget(dup_warn)
|
||||||
|
|
||||||
# Type an API_KEY/TOKEN-style name and the value field masks itself.
|
# Type an API_KEY/TOKEN-style name and the value field masks itself.
|
||||||
def _sync_echo(text):
|
def _sync_echo(text):
|
||||||
secret = core.is_secret_key(text)
|
secret = core.is_secret_key(text)
|
||||||
@@ -316,7 +346,15 @@ class KeyValueTable(QWidget):
|
|||||||
ok_btn = btns.button(QDialogButtonBox.StandardButton.Ok)
|
ok_btn = btns.button(QDialogButtonBox.StandardButton.Ok)
|
||||||
ok_btn.setObjectName("primary")
|
ok_btn.setObjectName("primary")
|
||||||
ok_btn.setEnabled(False)
|
ok_btn.setEnabled(False)
|
||||||
key_edit.textChanged.connect(lambda t: ok_btn.setEnabled(bool(t.strip())))
|
|
||||||
|
def _validate(text):
|
||||||
|
k = text.strip()
|
||||||
|
dup = bool(k) and self._is_duplicate_key(k, ignore_row=-1)
|
||||||
|
ok_btn.setEnabled(bool(k) and not dup)
|
||||||
|
dup_warn.setText(f"'{k}' already exists" if dup else "")
|
||||||
|
dup_warn.setVisible(dup)
|
||||||
|
|
||||||
|
key_edit.textChanged.connect(_validate)
|
||||||
btns.accepted.connect(dlg.accept)
|
btns.accepted.connect(dlg.accept)
|
||||||
btns.rejected.connect(dlg.reject)
|
btns.rejected.connect(dlg.reject)
|
||||||
v.addWidget(btns)
|
v.addWidget(btns)
|
||||||
@@ -330,13 +368,15 @@ class KeyValueTable(QWidget):
|
|||||||
return
|
return
|
||||||
k = key_edit.text().strip()
|
k = key_edit.text().strip()
|
||||||
val = val_edit.text()
|
val = val_edit.text()
|
||||||
if not k:
|
if not k or self._is_duplicate_key(k, ignore_row=-1):
|
||||||
return
|
return
|
||||||
if self._before_change:
|
if self._before_change:
|
||||||
self._before_change()
|
self._before_change()
|
||||||
r = self.table.rowCount()
|
r = self.table.rowCount()
|
||||||
self.table.insertRow(r)
|
self.table.insertRow(r)
|
||||||
self.table.setItem(r, 0, QTableWidgetItem(k))
|
key_item = QTableWidgetItem(k)
|
||||||
|
key_item.setData(Qt.ItemDataRole.UserRole, k)
|
||||||
|
self.table.setItem(r, 0, key_item)
|
||||||
self.table.setItem(r, 1, QTableWidgetItem(val))
|
self.table.setItem(r, 1, QTableWidgetItem(val))
|
||||||
self._changed()
|
self._changed()
|
||||||
|
|
||||||
@@ -355,7 +395,9 @@ class KeyValueTable(QWidget):
|
|||||||
for k, v in (d or {}).items():
|
for k, v in (d or {}).items():
|
||||||
r = self.table.rowCount()
|
r = self.table.rowCount()
|
||||||
self.table.insertRow(r)
|
self.table.insertRow(r)
|
||||||
self.table.setItem(r, 0, QTableWidgetItem(str(k)))
|
key_item = QTableWidgetItem(str(k))
|
||||||
|
key_item.setData(Qt.ItemDataRole.UserRole, str(k))
|
||||||
|
self.table.setItem(r, 0, key_item)
|
||||||
self.table.setItem(r, 1, QTableWidgetItem(str(v)))
|
self.table.setItem(r, 1, QTableWidgetItem(str(v)))
|
||||||
self.table.blockSignals(False)
|
self.table.blockSignals(False)
|
||||||
|
|
||||||
@@ -2097,12 +2139,17 @@ class MainWindow(QMainWindow):
|
|||||||
if not (0 <= idx < len(self.servers)):
|
if not (0 <= idx < len(self.servers)):
|
||||||
return
|
return
|
||||||
entry = self.servers[idx]
|
entry = self.servers[idx]
|
||||||
|
old_name = entry.name
|
||||||
entry.name = self.editor.current_name()
|
entry.name = self.editor.current_name()
|
||||||
entry.data = self.editor.dump_data()
|
entry.data = self.editor.dump_data()
|
||||||
# The server stays in its section (enable state unchanged), so update
|
# The server stays in its section (enable state unchanged), so update
|
||||||
# its existing row in place rather than re-rendering.
|
# its existing row in place rather than re-rendering.
|
||||||
# An edit invalidates any cached "Test all" result -- the server that
|
# An edit invalidates any cached "Test all" result -- the server that
|
||||||
# was spawn-tested no longer matches what's on disk once saved.
|
# was spawn-tested no longer matches what's on disk once saved. Pop
|
||||||
|
# both names: the old one (so a rename doesn't leave a stale entry
|
||||||
|
# for whoever takes that name next) and the new one (so we don't
|
||||||
|
# inherit a stale result cached under the name being renamed to).
|
||||||
|
self._health.pop(old_name, None)
|
||||||
self._health.pop(entry.name, None)
|
self._health.pop(entry.name, None)
|
||||||
loc = self._row_of_index.get(idx)
|
loc = self._row_of_index.get(idx)
|
||||||
if loc:
|
if loc:
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ if sys.platform == "darwin":
|
|||||||
info_plist={
|
info_plist={
|
||||||
"CFBundleName": "Better Claude Config",
|
"CFBundleName": "Better Claude Config",
|
||||||
"CFBundleDisplayName": "Better Claude Config",
|
"CFBundleDisplayName": "Better Claude Config",
|
||||||
"CFBundleShortVersionString": "1.0.0",
|
"CFBundleShortVersionString": "1.2.1",
|
||||||
"CFBundleVersion": "1.0.0",
|
"CFBundleVersion": "1.2.1",
|
||||||
"NSHighResolutionCapable": True,
|
"NSHighResolutionCapable": True,
|
||||||
"NSRequiresAquaSystemAppearance": False, # supports dark mode
|
"NSRequiresAquaSystemAppearance": False, # supports dark mode
|
||||||
"LSMinimumSystemVersion": "11.0",
|
"LSMinimumSystemVersion": "11.0",
|
||||||
|
|||||||
+23
-2
@@ -59,7 +59,7 @@ KNOWN_FIELDS = {"command", "args", "env", "url", "type", "headers"}
|
|||||||
# binary. All network I/O here is fail-quiet (returns None on any problem)
|
# binary. All network I/O here is fail-quiet (returns None on any problem)
|
||||||
# so it's safe to run unattended, off the UI thread, at startup.
|
# so it's safe to run unattended, off the UI thread, at startup.
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
__version__ = "1.2.0"
|
__version__ = "1.2.1"
|
||||||
|
|
||||||
REPO_URL = "https://git.avezzano.io/the_og/better-claude-config"
|
REPO_URL = "https://git.avezzano.io/the_og/better-claude-config"
|
||||||
ISSUES_URL = f"{REPO_URL}/issues"
|
ISSUES_URL = f"{REPO_URL}/issues"
|
||||||
@@ -1581,6 +1581,23 @@ def server_log_path(name: str) -> Path | None:
|
|||||||
_STDERR_CAP = 4096 # bytes
|
_STDERR_CAP = 4096 # bytes
|
||||||
|
|
||||||
|
|
||||||
|
def _kill_process_tree_windows(pid: int) -> None:
|
||||||
|
"""
|
||||||
|
Kill `pid` and its whole descendant tree via `taskkill /T /F` (issue #13).
|
||||||
|
|
||||||
|
Popen.kill() only terminates the direct child; runner-style commands
|
||||||
|
(npx → node → server, cmd → real process) leave the actual server alive,
|
||||||
|
leaking a process on every Windows spawn test. taskkill walks the tree.
|
||||||
|
"""
|
||||||
|
flags = getattr(subprocess, "CREATE_NO_WINDOW", 0) # no console flash from the GUI exe
|
||||||
|
with contextlib.suppress(OSError):
|
||||||
|
subprocess.run(
|
||||||
|
["taskkill", "/PID", str(pid), "/T", "/F"],
|
||||||
|
capture_output=True,
|
||||||
|
creationflags=flags,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def spawn_test(data: dict, timeout: float = 3.0) -> dict:
|
def spawn_test(data: dict, timeout: float = 3.0) -> dict:
|
||||||
"""
|
"""
|
||||||
Attempt to start a stdio server and observe it for `timeout` seconds.
|
Attempt to start a stdio server and observe it for `timeout` seconds.
|
||||||
@@ -1675,6 +1692,10 @@ def _spawn_test_impl(data: dict, timeout: float) -> dict:
|
|||||||
)
|
)
|
||||||
if os.name != "nt":
|
if os.name != "nt":
|
||||||
popen_kwargs["start_new_session"] = True # own process group → clean kill
|
popen_kwargs["start_new_session"] = True # own process group → clean kill
|
||||||
|
else:
|
||||||
|
# The packaged app is windowed (console=False); without this every
|
||||||
|
# spawn test of a console server flashes a console window.
|
||||||
|
popen_kwargs["creationflags"] = getattr(subprocess, "CREATE_NO_WINDOW", 0)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen(args_list, **popen_kwargs)
|
proc = subprocess.Popen(args_list, **popen_kwargs)
|
||||||
@@ -1696,7 +1717,7 @@ def _spawn_test_impl(data: dict, timeout: float) -> dict:
|
|||||||
if os.name != "nt":
|
if os.name != "nt":
|
||||||
os.killpg(os.getpgid(proc.pid), _signal.SIGKILL)
|
os.killpg(os.getpgid(proc.pid), _signal.SIGKILL)
|
||||||
else:
|
else:
|
||||||
proc.kill() # best-effort on Windows
|
_kill_process_tree_windows(proc.pid)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
with contextlib.suppress(subprocess.TimeoutExpired):
|
with contextlib.suppress(subprocess.TimeoutExpired):
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "better-claude-config"
|
name = "better-claude-config"
|
||||||
version = "1.2.0"
|
version = "1.2.1"
|
||||||
description = "Cross-platform GUI for editing the mcpServers block of Claude Desktop and Claude Code configs"
|
description = "Cross-platform GUI for editing the mcpServers block of Claude Desktop and Claude Code configs"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = { file = "LICENSE" }
|
license = { file = "LICENSE" }
|
||||||
|
|||||||
+57
-2
@@ -3,9 +3,11 @@ proper test functions with tmp_path/monkeypatch fixtures)."""
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import urllib.error
|
import urllib.error
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -329,6 +331,55 @@ def test_spawn_test_large_stderr_does_not_deadlock():
|
|||||||
assert len(r["stderr"]) <= c._STDERR_CAP
|
assert len(r["stderr"]) <= c._STDERR_CAP
|
||||||
|
|
||||||
|
|
||||||
|
def test_windows_tree_kill_uses_taskkill(monkeypatch):
|
||||||
|
"""The Windows kill path must walk the process tree (taskkill /T /F);
|
||||||
|
Popen.kill() alone orphans grandchildren (issue #13)."""
|
||||||
|
calls = []
|
||||||
|
|
||||||
|
def fake_run(cmd, **kwargs):
|
||||||
|
calls.append(cmd)
|
||||||
|
return _FakeRC()
|
||||||
|
|
||||||
|
class _FakeRC:
|
||||||
|
returncode = 0
|
||||||
|
|
||||||
|
monkeypatch.setattr(c.subprocess, "run", fake_run)
|
||||||
|
c._kill_process_tree_windows(1234)
|
||||||
|
assert calls == [["taskkill", "/PID", "1234", "/T", "/F"]]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(os.name != "nt", reason="Windows-only: real process-tree kill")
|
||||||
|
def test_spawn_test_windows_kills_child_process_tree(tmp_path):
|
||||||
|
"""A spawn-tested parent that has its own child (npx -> node style) must
|
||||||
|
not leave the child running after the timeout kill (issue #13)."""
|
||||||
|
import subprocess as sp
|
||||||
|
import time as _t
|
||||||
|
|
||||||
|
pid_file = tmp_path / "child.pid"
|
||||||
|
parent_script = (
|
||||||
|
"import subprocess, sys, time\n"
|
||||||
|
"p = subprocess.Popen([sys.executable, '-c', 'import time; time.sleep(60)'])\n"
|
||||||
|
f"open({str(pid_file)!r}, 'w').write(str(p.pid))\n"
|
||||||
|
"time.sleep(60)\n"
|
||||||
|
)
|
||||||
|
r = c.spawn_test({"command": sys.executable, "args": ["-c", parent_script]}, timeout=2.0)
|
||||||
|
assert r["outcome"] == "ok" # parent was still running at timeout, then tree-killed
|
||||||
|
assert pid_file.is_file(), "parent never spawned its child"
|
||||||
|
child_pid = int(pid_file.read_text())
|
||||||
|
|
||||||
|
deadline = _t.time() + 5.0
|
||||||
|
alive = True
|
||||||
|
while _t.time() < deadline:
|
||||||
|
out = sp.run(
|
||||||
|
["tasklist", "/FI", f"PID eq {child_pid}"], capture_output=True, text=True
|
||||||
|
).stdout
|
||||||
|
alive = str(child_pid) in out
|
||||||
|
if not alive:
|
||||||
|
break
|
||||||
|
_t.sleep(0.25)
|
||||||
|
assert not alive, f"child pid {child_pid} survived the spawn-test kill"
|
||||||
|
|
||||||
|
|
||||||
def test_spawn_test_non_string_env_value():
|
def test_spawn_test_non_string_env_value():
|
||||||
# Pasted JSON can carry numeric env values ("env": {"PORT": 8080}) that never
|
# Pasted JSON can carry numeric env values ("env": {"PORT": 8080}) that never
|
||||||
# round-trip through the editor. Popen rejects non-str env; spawn_test must
|
# round-trip through the editor. Popen rejects non-str env; spawn_test must
|
||||||
@@ -1138,8 +1189,12 @@ def test_restart_claude_desktop_linux_refuses_without_touching_processes(monkeyp
|
|||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
def test_dunder_version_matches_pyproject():
|
def test_dunder_version_matches_pyproject():
|
||||||
# Guards against the version drifting out of sync between the two places
|
# Guards against the version drifting out of sync between the two places
|
||||||
# a human might bump it.
|
# a human might bump it. Reads pyproject.toml rather than hard-coding a
|
||||||
assert c.__version__ == "1.2.0"
|
# version here (which would make this a third place to bump).
|
||||||
|
text = (Path(__file__).parent.parent / "pyproject.toml").read_text(encoding="utf-8")
|
||||||
|
m = re.search(r'^version\s*=\s*"([^"]+)"', text, re.MULTILINE)
|
||||||
|
assert m, "no [project] version found in pyproject.toml"
|
||||||
|
assert c.__version__ == m.group(1)
|
||||||
|
|
||||||
|
|
||||||
def test_parse_version_basic():
|
def test_parse_version_basic():
|
||||||
|
|||||||
Reference in New Issue
Block a user