feat: add native tmux tools - #26
Conversation
There was a problem hiding this comment.
Sorry @trotsky1997, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50d0f6286a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if params.wait { | ||
| run_blocking(call_id, &tmux, &target, ¶ms, ctx).await | ||
| } else { | ||
| run_nonblocking(call_id, &tmux, &target, ¶ms, ctx).await |
There was a problem hiding this comment.
Gate tmux_run through ACP permissions
When Ra is running with an ACP host attached (ctx.client/session_id set), this path still runs arbitrary tmux_run.command locally via tmux without calling request_permission; in contrast, the existing bash, git, and gh execution tools gate host-attached executions before running terminal commands. This lets a model execute shell commands through tmux_run in ACP sessions without the user approval expected for execute-class tools.
Useful? React with 👍 / 👎.
| let valid = value.chars().all(|ch| { | ||
| ch.is_ascii_alphanumeric() || matches!(ch, '_' | '-' | '.') || (allow_percent && ch == '%') | ||
| }); |
There was a problem hiding this comment.
Reject dots in tmux window names
When a caller chooses a window name containing ., validation accepts it, but the target string is later rendered as session:window.pane; tmux's documented target-pane syntax uses . as the window/pane separator, so a window like logs.v1 becomes ambiguous and tmux_capture, tmux_send, or tmux_kill can fail or target the wrong pane after creating that window. Either disallow . for window names or target by window id instead.
Useful? React with 👍 / 👎.
| Some(pane) => format!("{session}:{window}.{pane}"), | ||
| None => format!("{session}:{window}"), |
There was a problem hiding this comment.
Use exact tmux targets for sessions and windows
When the requested logical session/window is absent but a longer name exists (for example dev while only ra__dev2 exists), these rendered targets can still match the longer target because the tmux target-session docs say lookup falls back to the start of a session name unless an = prefix forces exact matching; the same target rules apply to windows. That means tmux_capture/tmux_send/tmux_kill can operate on the wrong Ra-owned session or window instead of failing or creating the requested target.
Useful? React with 👍 / 👎.
|
Reviewed PR #26 at head Findings:
Non-blocking but worth addressing:
Verification run from an extracted PR tree with tmux 3.4 / cargo 1.94.0:
I attempted to submit this as a |
66e9f26 to
5c13f53
Compare
Co-authored-by: multica-agent <github@multica.ai>
Co-authored-by: multica-agent <github@multica.ai>
Co-authored-by: multica-agent <github@multica.ai>
- validate_name: disallow '.' in window names to prevent ambiguous tmux target parsing (session:window.pane). Sessions and panes still allow '.'; only windows are restricted. - send_args: insert '--' before literal keys payload so leading '-' characters are not parsed as tmux flags. - send_args: remove dead include_enter parameter (always false at all call sites; Enter is sent separately). - listen_response: wrap 8 positional args into ListenResponse struct to satisfy clippy's too-many-arguments lint. - text_delta: replace manual prefix-strip with strip_prefix(). - tests: update argv assertions to include '--' separator. Co-authored-by: multica-agent <github@multica.ai>
strip_exit_marker now takes the call's unique token and only recognizes markers of the form __RA_TMUX_EXIT:<token>:__<exit_code>__. A command that prints the old static marker __RA_TMUX_EXIT:N__ can no longer cause tmux_wait or tmux_run (wait:true) to return early with a false command_exit_code. wait_script updated to emit the token-scoped marker; both call sites (run_blocking, execute_tmux_wait_program) pass the token. Tests updated and a new regression test added for the wrong-token case. Co-authored-by: multica-agent <github@multica.ai>
5c13f53 to
584a5df
Compare
Summary
event,pattern,regex,hook)Closes #24.
Verification