diff --git a/internal/tmux/tmux.go b/internal/tmux/tmux.go index afa03fd0..117beacb 100644 --- a/internal/tmux/tmux.go +++ b/internal/tmux/tmux.go @@ -281,7 +281,7 @@ func (t *Tmux) SendKeysDelayedDebounced(session, keys string, preDelayMs, deboun // NudgeSession sends a message to a Claude Code session reliably. // This is the canonical way to send messages to Claude sessions. -// Uses: literal mode + 500ms debounce + separate Enter. +// Uses: literal mode + 500ms debounce + ESC (for vim mode) + separate Enter. // Verification is the Witness's job (AI), not this function. func (t *Tmux) NudgeSession(session, message string) error { // 1. Send text in literal mode (handles special characters) @@ -292,7 +292,12 @@ func (t *Tmux) NudgeSession(session, message string) error { // 2. Wait 500ms for paste to complete (tested, required) time.Sleep(500 * time.Millisecond) - // 3. Send Enter with retry (critical for message submission) + // 3. Send Escape to exit vim INSERT mode if enabled (harmless in normal mode) + // See: https://github.com/anthropics/gastown/issues/307 + _, _ = t.run("send-keys", "-t", session, "Escape") + time.Sleep(100 * time.Millisecond) + + // 4. Send Enter with retry (critical for message submission) var lastErr error for attempt := 0; attempt < 3; attempt++ { if attempt > 0 { @@ -318,7 +323,12 @@ func (t *Tmux) NudgePane(pane, message string) error { // 2. Wait 500ms for paste to complete (tested, required) time.Sleep(500 * time.Millisecond) - // 3. Send Enter with retry (critical for message submission) + // 3. Send Escape to exit vim INSERT mode if enabled (harmless in normal mode) + // See: https://github.com/anthropics/gastown/issues/307 + _, _ = t.run("send-keys", "-t", pane, "Escape") + time.Sleep(100 * time.Millisecond) + + // 4. Send Enter with retry (critical for message submission) var lastErr error for attempt := 0; attempt < 3; attempt++ { if attempt > 0 {