feat: add experimental pushy delivery mode
Some checks failed
tamq-ci / test (push) Has been cancelled
Some checks failed
tamq-ci / test (push) Has been cancelled
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a03397-4d51-7fd1-8ff2-946eb22ea2bc
This commit is contained in:
parent
8186550c9a
commit
9ed8b62b45
16 changed files with 441 additions and 31 deletions
|
|
@ -9,6 +9,7 @@ import pytest
|
|||
|
||||
from tamq.broker import BrokerIdentity, InputBroker
|
||||
from tamq.control import ControlModeClient
|
||||
from tamq.service import Service
|
||||
from tamq.store import Store
|
||||
from tamq.terminal import terminal_frame, write_terminal_output
|
||||
from tamq.tmux import LaunchPlan, TmuxManager
|
||||
|
|
@ -198,3 +199,63 @@ def test_real_tmux_output_preserves_partial_input_line_and_cursor(tmp_path):
|
|||
assert (after.cursor_x, after.cursor_y) == (before.cursor_x, before.cursor_y)
|
||||
finally:
|
||||
manager._run("kill-server", check=False)
|
||||
|
||||
|
||||
@pytest.mark.skipif(shutil.which("tmux") is None, reason="tmux is not installed")
|
||||
def test_real_tmux_pushy_mode_submits_one_shell_safe_input(tmp_path, monkeypatch):
|
||||
repo = tmp_path / "audit-core"
|
||||
repo.mkdir()
|
||||
socket_name = f"tamq-pushy-{os.getpid()}-{uuid4().hex[:8]}"
|
||||
session = f"tamq-pushy-{uuid4().hex[:8]}"
|
||||
monkeypatch.setenv("TAMQ_TMUX_SOCKET", socket_name)
|
||||
manager = TmuxManager(
|
||||
session,
|
||||
tmux_command=("tmux", "-L", socket_name),
|
||||
tamq_command=(sys.executable, "-m", "tamq.cli"),
|
||||
command_dir=tmp_path / "commands",
|
||||
)
|
||||
target = f"{session}:audit-core"
|
||||
store = Store(tmp_path / "queue.sqlite3")
|
||||
|
||||
try:
|
||||
endpoint = manager.ensure_plan(
|
||||
LaunchPlan(("audit-core",), {"audit-core": str(repo)}, ())
|
||||
)
|
||||
deadline = time.monotonic() + 5
|
||||
while time.monotonic() < deadline:
|
||||
current_command = manager._run(
|
||||
"display-message", "-p", "-t", target, "#{pane_current_command}"
|
||||
)
|
||||
if current_command in {"bash", "sh", "zsh", "fish"}:
|
||||
break
|
||||
time.sleep(0.05)
|
||||
assert current_command in {"bash", "sh", "zsh", "fish"}
|
||||
|
||||
store.register_endpoint(
|
||||
endpoint.instance_key,
|
||||
endpoint.pid,
|
||||
endpoint.session,
|
||||
endpoint.repos,
|
||||
"pushy",
|
||||
)
|
||||
message_id = store.add("flex-auth", "audit-core", "What's next?\nsecond")
|
||||
service = Service(store=store)
|
||||
service._deliver_once()
|
||||
|
||||
expected = f"#flex-auth: What's next?\\x0asecond [{message_id}]"
|
||||
deadline = time.monotonic() + 5
|
||||
while time.monotonic() < deadline:
|
||||
capture = manager._run("capture-pane", "-p", "-t", target)
|
||||
if expected in capture:
|
||||
break
|
||||
time.sleep(0.05)
|
||||
assert expected in capture
|
||||
assert store.list()[0]["state"] == "injected"
|
||||
assert store.db.execute("SELECT COUNT(*) FROM leases").fetchone()[0] == 0
|
||||
|
||||
service._deliver_once()
|
||||
repeated_capture = manager._run("capture-pane", "-p", "-t", target)
|
||||
assert repeated_capture.count(expected) == 1
|
||||
finally:
|
||||
store.close()
|
||||
manager._run("kill-server", check=False)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue