File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -233,14 +233,24 @@ if [[ "$FORCE_SEND" != true ]] && [[ -f "$LAST_SENT_FILE" ]]; then
233233 fi
234234fi
235235
236+ # Clear any existing input in the buffer before sending new text
237+ # This prevents concatenation when commands are sent in rapid succession
238+ tmux send-keys -t " $SESSION_NAME " C-u
239+ sleep 0.05
240+
236241# Send text using bracketed paste mode
237242# \e[200~ = start bracketed paste
238243# \e[201~ = end bracketed paste
239244tmux send-keys -t " $SESSION_NAME " $' \e [200~' " $TEXT " $' \e [201~'
240245
241- # Optionally press Enter
246+ # Optionally press Enter (with small delay to let TUI apps process the paste first)
242247if [[ " $AUTO_ENTER " == true ]]; then
248+ sleep 0.05
243249 tmux send-keys -t " $SESSION_NAME " Enter
250+ # Wait for CLI to process Enter and clear input buffer before returning
251+ # This prevents the next send from concatenating with the previous input
252+ # 200ms is needed for slower CLIs like Codex to fully process the command
253+ sleep 0.2
244254fi
245255
246256# Log the text send as YAML and update last-sent tracker
Original file line number Diff line number Diff line change @@ -119,8 +119,9 @@ while [[ $# -gt 0 ]]; do
119119done
120120
121121# Generate session name if not provided
122+ # Use timestamp + PID + random suffix to avoid collisions when running multiple agents in parallel
122123if [[ -z " $SESSION_NAME " ]]; then
123- SESSION_NAME=" tui-test-$( date +%s) "
124+ SESSION_NAME=" tui-test-$( date +%s) - $$ - $RANDOM "
124125fi
125126
126127# Check if tmux is available
182183SESSION_DIR=" $PROJECT_ROOT /debug/tmux-sessions/$SESSION_NAME "
183184mkdir -p " $SESSION_DIR "
184185
186+ # Clear deduplication state from any previous session with the same name
187+ rm -f " $SESSION_DIR /.last-sent-text"
188+
185189# Save session info as YAML
186190cat > " $SESSION_DIR /session-info.yaml" << EOF
187191session: $SESSION_NAME
You can’t perform that action at this time.
0 commit comments