Skip to content

Commit 8718bd0

Browse files
MrFlounderclaude
andcommitted
fix(ws): wait for shell ready before sending commands after respawn-pane
The fixed 0.5s sleep after tmux respawn-pane was not enough time for zsh to fully initialize (especially with plugins/themes). This caused send-keys to fire while the shell was still loading, eating the first character(s) of the command (e.g. "clear" became "lear"). Replace with a poll loop that waits for the shell process to appear in the pane, then adds a small buffer before sending keys. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7e6b8b2 commit 8718bd0

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/crabcode

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,13 @@ EOF
15111511
[ -n "$dev_cmd" ] && tmux send-keys -t "$SESSION_NAME:$window_name.$p_server" "$dev_cmd" C-m
15121512

15131513
tmux respawn-pane -k -t "$SESSION_NAME:$window_name.$p_main" -c "$dir"
1514-
sleep 0.5
1514+
# Wait for shell to be ready (zsh/bash init can take >0.5s with plugins)
1515+
for _i in $(seq 1 20); do
1516+
local pcmd=$(tmux display-message -t "$SESSION_NAME:$window_name.$p_main" -p '#{pane_current_command}' 2>/dev/null)
1517+
[[ "$pcmd" =~ ^(bash|zsh|sh|fish)$ ]] && break
1518+
sleep 0.2
1519+
done
1520+
sleep 0.3
15151521
[ -n "$claude_cmd" ] && tmux send-keys -t "$SESSION_NAME:$window_name.$p_main" "clear && $claude_cmd" C-m
15161522

15171523
success "Workspace $num started with ticket prompt"
@@ -1963,7 +1969,13 @@ continue_workspace() {
19631969
[ -n "$dev_cmd" ] && tmux send-keys -t "$SESSION_NAME:$window_name.$p_server" "$dev_cmd" C-m
19641970

19651971
tmux respawn-pane -k -t "$SESSION_NAME:$window_name.$p_main" -c "$dir"
1966-
sleep 0.5
1972+
# Wait for shell to be ready (zsh/bash init can take >0.5s with plugins)
1973+
for _i in $(seq 1 20); do
1974+
local pcmd=$(tmux display-message -t "$SESSION_NAME:$window_name.$p_main" -p '#{pane_current_command}' 2>/dev/null)
1975+
[[ "$pcmd" =~ ^(bash|zsh|sh|fish)$ ]] && break
1976+
sleep 0.2
1977+
done
1978+
sleep 0.3
19671979
[ -n "$claude_cmd" ] && tmux send-keys -t "$SESSION_NAME:$window_name.$p_main" "clear && $claude_cmd" C-m
19681980

19691981
success "Workspace $num continued with previous session"

0 commit comments

Comments
 (0)