fix: start-agent.sh - stale socket cleanup și window numbering corect
- Adăugat cleanup automat pentru socket tmux stale (după restart container) - Corectat indexarea window/pane pentru base-index 1 - Simplificat layout-ul la 2 panouri fără send-keys Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,12 @@ export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
||||
'
|
||||
|
||||
# ---- Clean stale socket if tmux server is dead ----
|
||||
TMUX_SOCK="/tmp/tmux-$(id -u)/default"
|
||||
if [ -e "$TMUX_SOCK" ] && ! tmux ls &>/dev/null; then
|
||||
rm -f "$TMUX_SOCK"
|
||||
fi
|
||||
|
||||
# ---- Attach if exists ----
|
||||
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
|
||||
echo "Attaching to existing session: $SESSION_NAME"
|
||||
@@ -25,30 +31,12 @@ echo "Creating new session: $SESSION_NAME"
|
||||
# ---- Create session ----
|
||||
tmux new-session -d -s "$SESSION_NAME" -c "$WORKDIR"
|
||||
|
||||
# Pane 0: Main shell (editor / ssh / control)
|
||||
tmux send-keys -t "$SESSION_NAME:0.0" "cd $WORKDIR && clear" C-m
|
||||
tmux send-keys -t "$SESSION_NAME:0.0" "$NVM_LOAD" C-m
|
||||
# ---- Enable mouse (click between panes + scroll) ----
|
||||
tmux set-option -g mouse on
|
||||
|
||||
# Pane 1: Right (AI / ssh / tools)
|
||||
tmux split-window -h -t "$SESSION_NAME:0" -c "$WORKDIR"
|
||||
tmux send-keys -t "$SESSION_NAME:0.1" "$NVM_LOAD" C-m
|
||||
tmux send-keys -t "$SESSION_NAME:0.1" "echo 'AI / tools pane (run claude manually)'" C-m
|
||||
# Pane 2: Right
|
||||
tmux split-window -h -t "$SESSION_NAME:1" -c "$WORKDIR"
|
||||
|
||||
# Pane 2: Bottom-left (review / second shell)
|
||||
tmux select-pane -t "$SESSION_NAME:0.0"
|
||||
tmux split-window -v -c "$WORKDIR"
|
||||
tmux send-keys -t "$SESSION_NAME:0.2" "$NVM_LOAD" C-m
|
||||
tmux send-keys -t "$SESSION_NAME:0.2" "echo 'Review / ssh pane'" C-m
|
||||
|
||||
# Pane 3: Bottom (tests / logs)
|
||||
tmux select-pane -t "$SESSION_NAME:0.0"
|
||||
tmux split-window -v -c "$WORKDIR"
|
||||
tmux send-keys -t "$SESSION_NAME:0.3" "$NVM_LOAD" C-m
|
||||
tmux send-keys -t "$SESSION_NAME:0.3" "echo 'Tests / logs pane'" C-m
|
||||
|
||||
# ---- Layout & focus ----
|
||||
tmux select-layout -t "$SESSION_NAME" tiled
|
||||
tmux select-pane -t "$SESSION_NAME:0.0"
|
||||
|
||||
# ---- Attach ----
|
||||
tmux attach-session -t "$SESSION_NAME"
|
||||
# ---- Focus left pane & attach ----
|
||||
tmux select-pane -t "$SESSION_NAME:1.1"
|
||||
tmux attach-session -t "$SESSION_NAME"
|
||||
Reference in New Issue
Block a user