From d52d92092d98ed2d6c48e6433cacb899582f617e Mon Sep 17 00:00:00 2001 From: gbc dev Date: Wed, 15 Jul 2026 10:10:16 +0200 Subject: gbctl: 'hud' kills any existing HUD pane before spawning (no double-HUD) gbctl hud now scans tmux for panes started with gbhud.py and kills them before spawning, so there's never more than one HUD (fixes the double-spawn flicker). Added 'gbctl hud --kill' to just tear the HUD down. --- core.3094252 | Bin 0 -> 11268096 bytes core.3095917 | Bin 0 -> 11268096 bytes core.3096524 | Bin 0 -> 11268096 bytes core.3096981 | Bin 0 -> 11268096 bytes core.3103352 | Bin 0 -> 11268096 bytes core.3104381 | Bin 0 -> 11268096 bytes core.3107696 | Bin 0 -> 11268096 bytes core.3112782 | Bin 0 -> 11268096 bytes core.3114457 | Bin 0 -> 11268096 bytes core.3115685 | Bin 0 -> 11268096 bytes core.3117279 | Bin 0 -> 11268096 bytes core.3118071 | Bin 0 -> 11268096 bytes gbctl | 27 ++++++++++++++++++++++++++- 13 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 core.3094252 create mode 100644 core.3095917 create mode 100644 core.3096524 create mode 100644 core.3096981 create mode 100644 core.3103352 create mode 100644 core.3104381 create mode 100644 core.3107696 create mode 100644 core.3112782 create mode 100644 core.3114457 create mode 100644 core.3115685 create mode 100644 core.3117279 create mode 100644 core.3118071 diff --git a/core.3094252 b/core.3094252 new file mode 100644 index 0000000..8da34bb Binary files /dev/null and b/core.3094252 differ diff --git a/core.3095917 b/core.3095917 new file mode 100644 index 0000000..549133c Binary files /dev/null and b/core.3095917 differ diff --git a/core.3096524 b/core.3096524 new file mode 100644 index 0000000..04786a5 Binary files /dev/null and b/core.3096524 differ diff --git a/core.3096981 b/core.3096981 new file mode 100644 index 0000000..b3a5c51 Binary files /dev/null and b/core.3096981 differ diff --git a/core.3103352 b/core.3103352 new file mode 100644 index 0000000..230f6a2 Binary files /dev/null and b/core.3103352 differ diff --git a/core.3104381 b/core.3104381 new file mode 100644 index 0000000..4c71880 Binary files /dev/null and b/core.3104381 differ diff --git a/core.3107696 b/core.3107696 new file mode 100644 index 0000000..965f8c9 Binary files /dev/null and b/core.3107696 differ diff --git a/core.3112782 b/core.3112782 new file mode 100644 index 0000000..88d4aca Binary files /dev/null and b/core.3112782 differ diff --git a/core.3114457 b/core.3114457 new file mode 100644 index 0000000..1c71b59 Binary files /dev/null and b/core.3114457 differ diff --git a/core.3115685 b/core.3115685 new file mode 100644 index 0000000..5d7c329 Binary files /dev/null and b/core.3115685 differ diff --git a/core.3117279 b/core.3117279 new file mode 100644 index 0000000..3973114 Binary files /dev/null and b/core.3117279 differ diff --git a/core.3118071 b/core.3118071 new file mode 100644 index 0000000..f45e7a0 Binary files /dev/null and b/core.3118071 differ diff --git a/gbctl b/gbctl index 4c3d4f9..287b16a 100755 --- a/gbctl +++ b/gbctl @@ -284,11 +284,35 @@ def cmd_screen(argv): r = subprocess.run(args, capture_output=True, text=True) sys.stdout.write(r.stdout) +def _kill_hud_panes(): + # kill any pane whose start command references the HUD, so there's never + # more than one HUD running (avoids the double-spawn tmux flicker). + n = 0 + try: + r = subprocess.run( + ["tmux", "list-panes", "-a", "-F", "#{pane_id}\t#{pane_start_command}"], + capture_output=True, text=True) + for line in r.stdout.splitlines(): + pid, _, startcmd = line.partition("\t") + if "gbhud.py" in startcmd: + subprocess.run(["tmux", "kill-pane", "-t", pid], capture_output=True) + n += 1 + except Exception: + pass + return n + def cmd_hud(argv): # spawn a tmux pane running the live debug HUD, bound to the resolved socket + killonly = "--kill" in argv + if killonly: + argv = [a for a in argv if a != "--kill"] + k = _kill_hud_panes() + print("killed %d hud pane(s)" % k) + return sock_path = _resolve_sock(argv) if "TMUX" not in os.environ: die("not inside tmux; gbctl hud needs a tmux session") + killed = _kill_hud_panes() # never leave a second HUD around hud = os.path.join(HERE, "tools", "gbhud.py") split = "-h" if "--split" in argv: @@ -298,7 +322,8 @@ def cmd_hud(argv): capture_output=True, text=True) if r.returncode != 0: die("tmux spawn failed: %s" % r.stderr.strip()) - print("hud pane=%s sock=%s" % (r.stdout.strip(), sock_path)) + note = (" (replaced %d)" % killed) if killed else "" + print("hud pane=%s sock=%s%s" % (r.stdout.strip(), sock_path, note)) def cmd_monitor(argv): secs = float(argv[0]) if argv and _isnum(argv[0]) else None -- cgit v1.3.1-sl0p