fix(tmux): send Escape before Enter for vim mode compatibility
NudgeSession and NudgePane now send Escape key before Enter to exit vim INSERT mode if enabled. Harmless in normal mode. Fixes #307 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
7f4c3201cf
commit
1ece29e1fd
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user