Target the tmux session as =<session>: for its @loop-root option, which set-option and show-options read as a pane's target
CI / tests (pull_request) Successful in 2m57s
CI / tests (pull_request) Successful in 2m57s
This commit is contained in:
@@ -830,7 +830,7 @@ class Windows(unittest.TestCase):
|
|||||||
["-V"],
|
["-V"],
|
||||||
["list-windows", "-t", "=loop-proj", "-F", "#{window_name}\t#{pane_dead}\t#{window_id}"],
|
["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"],
|
["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"],
|
["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")
|
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")
|
||||||
|
|||||||
@@ -1295,7 +1295,7 @@ class TmuxCommands(unittest.TestCase):
|
|||||||
self.assertIsNone(tmux.start_window(window, "/r", {}, ["/b/loop-claude"], False, fake.tmux))
|
self.assertIsNone(tmux.start_window(window, "/r", {}, ["/b/loop-claude"], False, fake.tmux))
|
||||||
self.assertEqual(fake.tmux_calls, [
|
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\;"],
|
["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"],
|
["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"],
|
["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"],
|
["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):
|
def test_reads_the_checkout_the_session_names(self):
|
||||||
fake = FakeEffects(owner="/c/proj")
|
fake = FakeEffects(owner="/c/proj")
|
||||||
self.assertEqual(tmux.owner("loop-proj", fake.tmux), "/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):
|
def test_marks_a_waiting_window_by_its_pane_and_clears_the_mark(self):
|
||||||
fake = FakeEffects()
|
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([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}"])
|
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.
|
# 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):
|
def test_refuses_a_session_that_runs_another_checkouts_chunks(self):
|
||||||
for owner, named in (("/c/acme.api", "/c/acme.api"), ("", "another checkout")):
|
for owner, named in (("/c/acme.api", "/c/acme.api"), ("", "another checkout")):
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ def start_window(window: Window, cwd: str, env: typing.Mapping[str, str], comman
|
|||||||
if done.returncode:
|
if done.returncode:
|
||||||
return Failure(f"tmux could not start the window {window.target}: {done.stderr.strip() or f'it exited {done.returncode}'}")
|
return Failure(f"tmux could not start the window {window.target}: {done.stderr.strip() or f'it exited {done.returncode}'}")
|
||||||
if first:
|
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.
|
# 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"])
|
run(["set-option", "-w", "-t", done.stdout.strip(), "remain-on-exit", "failed"])
|
||||||
return None
|
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:
|
def owner(session: str, run: Tmux) -> str:
|
||||||
"""The checkout whose chunks session runs, as OWNER names it; empty where it names none."""
|
"""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:
|
def close(window: Listed, run: Tmux) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user