feat: async non-blocking command execution for tmux panes#287
Merged
Conversation
8f25469 to
6f4c0fb
Compare
- Implement function to detect child processes for a given pane using pgrep - Add method to verify pane responsiveness by sending input and capturing output
- Add tokio async runtime for concurrent pane command execution - Change from Rc to Arc for thread-safe reference counting - Implement pane readiness checking before command execution - Add child process monitoring to detect command completion - Commands within a pane execute sequentially, multiple panes run in parallel - Store JoinHandles and implement Drop to abort tasks on cleanup - Session attachment no longer blocks on pane command execution - Add Send + Sync + 'static bounds to Runner trait
- Replace intrusive echo test with PID-based readiness check - Check if pane has no child processes to determine readiness - Add wait_for_tasks method to ensure tasks complete before exit - Block on task completion when using --skip-attach - Add debug logging for pane readiness and command execution - Add test YAML files to verify parallel/sequential execution Verified working: Commands within each pane execute sequentially while multiple panes run in parallel.
- Remove overly verbose debug logs - Keep useful debug logs for -vvvv troubleshooting - Remove test YAML files from repository root
- Change from 50 attempts × 100ms (5s) to 60 second timeout - Increase poll interval to 200ms to reduce overhead - Add elapsed time logging for better debugging - Prevents commands from being skipped when shell startup is slow
- Replace PID-based readiness check with output stability detection - Capture pane output twice with 200ms delay and compare - Pane is ready when output stops changing (stabilized) - Works correctly with slow shell initialization (direnv, devenv, plugins) - PID check now only used for command completion detection - Non-intrusive: no test commands or key presses sent to pane
- Always wait for async tasks to finish sending commands before CLI exits - Previously tasks were aborted when attaching (not using --skip-attach) - Commands are sent via tmux send-keys within async tasks - If tasks abort, commands never get sent to panes - Now waits for all tasks whether using --skip-attach or not
- attach-session blocks, keeping CLI alive while user is in session - switch-client returns immediately, so must wait for tasks first - skip-attach exits immediately, so must wait for tasks first - This allows instant attach while ensuring commands execute
122c81f to
958ab3c
Compare
- Replace flake-utils and systems inputs with flake-parts and nixpkgs-lib in flake.lock - Add nixpkgs-lib_2 input and update references in flake.lock - Update rustnix input dependencies to use flake-parts, devenv, and fenix - Synchronize rustnix revision and narHash to latest state - Add fenix and devenv input follows for rustnix in flake.nix - Standardize argument structure in nix/devenv/ci.nix and developer.nix to explicit attribute sets - Remove trailing newlines and minor formatting inconsistencies in Nix files
35d0168 to
a434e24
Compare
- Add sysinfo as a dependency for enhanced process inspection - Replace pgrep-based child process detection with sysinfo in TmuxClient - Implement sysinfo-based methods for retrieving child processes and their commands - Update pane_command logic to prefer sysinfo, falling back to pgrep for compatibility - Remove unused debug import and refactor related code for clarity - Remove legacy mux_get_session test relying on pgrep-based process detection
- Move task waiting logic into explicit branches for attach and switch-client scenarios - Ensure tasks are awaited after switch-client and when skipping attach, aligning CLI exit behavior - Remove redundant conditional block to streamline control flow - Add comments clarifying when tasks are awaited versus run in background
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Key Implementation Details
Async Architecture:
Pane Readiness Detection:
Command Execution:
Benefits: