fix remote clients command
Testing / test (push) Successful in 25s
Package Extension / package-extension (push) Successful in 9s
Build & Publish Package / publish (push) Successful in 21s

This commit is contained in:
2026-04-30 13:49:32 +02:00
parent 6785b9f70c
commit 2f982fa714
5 changed files with 63 additions and 22 deletions
+33 -19
View File
@@ -181,6 +181,8 @@ def main(ctx, browser, remote, token):
ctx.obj["browser_explicit"] = browser is not None
if browser:
os.environ["BROWSER_CLI_PROFILE"] = browser
ctx.obj["remote"] = remote
ctx.obj["token"] = token
if remote:
os.environ["BROWSER_CLI_REMOTE"] = remote
if token:
@@ -211,29 +213,41 @@ def clients_group(ctx):
if ctx.invoked_subcommand is not None:
return
profiles: dict[str, str] = {}
if REGISTRY_PATH.exists():
try:
profiles = json.loads(REGISTRY_PATH.read_text())
except Exception:
pass
all_clients = []
for profile_name, sock_path in profiles.items():
display_profile = display_browser_name(profile_name, sock_path)
remote = (ctx.obj or {}).get("remote") or os.environ.get("BROWSER_CLI_REMOTE")
if remote:
try:
result = send_command("clients.list", profile=profile_name)
result = send_command("clients.list", profile=(ctx.obj or {}).get("browser"))
for c in (result or []):
c["profile"] = display_profile
c["profile"] = c.get("profile") or (ctx.obj or {}).get("browser") or "remote"
all_clients.append(c)
except (BrowserNotConnected, RuntimeError):
# Socket registered but browser no longer connected
all_clients.append({
"profile": display_profile,
"name": "",
"version": "",
"extensionVersion": "disconnected",
})
except (BrowserNotConnected, RuntimeError) as e:
console.print(f"[red]Error:[/red] {e}")
sys.exit(1)
else:
profiles: dict[str, str] = {}
if REGISTRY_PATH.exists():
try:
profiles = json.loads(REGISTRY_PATH.read_text())
except Exception:
pass
for profile_name, sock_path in profiles.items():
display_profile = display_browser_name(profile_name, sock_path)
try:
result = send_command("clients.list", profile=profile_name)
for c in (result or []):
c["profile"] = display_profile
all_clients.append(c)
except (BrowserNotConnected, RuntimeError):
# Socket registered but browser no longer connected
all_clients.append({
"profile": display_profile,
"name": "",
"version": "",
"extensionVersion": "disconnected",
})
if not all_clients:
console.print("[yellow]No browser clients found. Start a browser with the extension enabled first.[/yellow]")