From 30b0e9e0a756042220142b25fd387b8250e1648d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 16 Nov 2026 12:47:28 +0100 Subject: [PATCH] Target the tmux session as =: for its @loop-root option, which set-option and show-options read as a pane's target --- bin/loop_claude/test_black_box.py | 2 +- bin/loop_claude/test_loop_claude.py | 6 +++--- bin/loop_claude/tmux.py | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/loop_claude/test_black_box.py b/bin/loop_claude/test_black_box.py index a167edb9..c490bd4a 100644 --- a/bin/loop_claude/test_black_box.py +++ b/bin/loop_claude/test_black_box.py @@ -830,7 +830,7 @@ class Windows(unittest.TestCase): ["-V"], ["list-windows", "-t", "=loop-proj", "-F", "#{window_name}\t#{pane_dead}\t#{window_id}"], ["new-session", "-d", "-s", "loop-proj", "-n", "item-4", "-c", str(checkout.root), "-e", "LOOP_CLAUDE_JUDGE_MODEL=judge-model", "-e", "LOOP_CLAUDE_WORKER_MODEL=worker-model", "-P", "-F", "#{window_id}", "--", str(checkout.script), "--chunk", "item-4", "ship it"], - ["set-option", "-t", "=loop-proj", "@loop-root", str(checkout.root)], + ["set-option", "-t", "=loop-proj:", "@loop-root", str(checkout.root)], ["set-option", "-w", "-t", "@7", "remain-on-exit", "failed"], ]) self.assertEqual(run.stdout, "started item-4 in the tmux session loop-proj\nnot on a terminal; see the chunks with `tmux attach -t =loop-proj`\n") diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index f800d203..3c247a70 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1295,7 +1295,7 @@ class TmuxCommands(unittest.TestCase): self.assertIsNone(tmux.start_window(window, "/r", {}, ["/b/loop-claude"], False, fake.tmux)) self.assertEqual(fake.tmux_calls, [ ["new-session", "-d", "-s", "loop-proj", "-n", "item-7", "-c", "/r", "-e", "LOOP_CLAUDE_X=1", "-P", "-F", "#{window_id}", "--", "/b/loop-claude", "--chunk", "item-7", "ship it\;"], - ["set-option", "-t", "=loop-proj", "@loop-root", "/r"], + ["set-option", "-t", "=loop-proj:", "@loop-root", "/r"], ["set-option", "-w", "-t", "@9", "remain-on-exit", "failed"], ["new-window", "-d", "-t", "=loop-proj:", "-n", "item-7", "-c", "/r", "-P", "-F", "#{window_id}", "--", "/b/loop-claude"], ["set-option", "-w", "-t", "@9", "remain-on-exit", "failed"], @@ -1311,7 +1311,7 @@ class TmuxCommands(unittest.TestCase): def test_reads_the_checkout_the_session_names(self): fake = FakeEffects(owner="/c/proj") self.assertEqual(tmux.owner("loop-proj", fake.tmux), "/c/proj") - self.assertEqual(fake.tmux_calls, [["show-options", "-qv", "-t", "=loop-proj", "@loop-root"]]) + self.assertEqual(fake.tmux_calls, [["show-options", "-qv", "-t", "=loop-proj:", "@loop-root"]]) def test_marks_a_waiting_window_by_its_pane_and_clears_the_mark(self): fake = FakeEffects() @@ -1440,7 +1440,7 @@ class StartChunks(unittest.TestCase): self.assertEqual([word for word in first if "=" in word], ["LOOP_CLAUDE_WORKER_MODEL=m"]) self.assertEqual(fake.tmux_calls[0], ["list-windows", "-t", f"={self.session}", "-F", "#{window_name}\t#{pane_dead}\t#{window_id}"]) # The session names the checkout whose chunks it runs. - self.assertIn(["set-option", "-t", f"={self.session}", "@loop-root", str(self.root)], fake.tmux_calls) + self.assertIn(["set-option", "-t", f"={self.session}:", "@loop-root", str(self.root)], fake.tmux_calls) def test_refuses_a_session_that_runs_another_checkouts_chunks(self): for owner, named in (("/c/acme.api", "/c/acme.api"), ("", "another checkout")): diff --git a/bin/loop_claude/tmux.py b/bin/loop_claude/tmux.py index d5992c78..1f2e0519 100644 --- a/bin/loop_claude/tmux.py +++ b/bin/loop_claude/tmux.py @@ -75,7 +75,8 @@ def start_window(window: Window, cwd: str, env: typing.Mapping[str, str], comman if done.returncode: return Failure(f"tmux could not start the window {window.target}: {done.stderr.strip() or f'it exited {done.returncode}'}") if first: - run(["set-option", "-t", f"={window.session}", OWNER, cwd]) + # set-option and show-options read a target as a pane's, so `=session` alone names no session. + run(["set-option", "-t", f"={window.session}:", OWNER, cwd]) # By the ID, since a window of the same name may still be closing. A loop that fails before the option is set closes its window, and its stop is still sent as a DM. run(["set-option", "-w", "-t", done.stdout.strip(), "remain-on-exit", "failed"]) return None @@ -83,7 +84,7 @@ def start_window(window: Window, cwd: str, env: typing.Mapping[str, str], comman def owner(session: str, run: Tmux) -> str: """The checkout whose chunks session runs, as OWNER names it; empty where it names none.""" - return run(["show-options", "-qv", "-t", f"={session}", OWNER]).stdout.strip() + return run(["show-options", "-qv", "-t", f"={session}:", OWNER]).stdout.strip() def close(window: Listed, run: Tmux) -> None: