summaryrefslogtreecommitdiff
path: root/internal/tmuxedit
diff options
context:
space:
mode:
Diffstat (limited to 'internal/tmuxedit')
-rw-r--r--internal/tmuxedit/agentutil.go5
-rw-r--r--internal/tmuxedit/claude_agent.go2
-rw-r--r--internal/tmuxedit/claude_agent_test.go10
3 files changed, 9 insertions, 8 deletions
diff --git a/internal/tmuxedit/agentutil.go b/internal/tmuxedit/agentutil.go
index 924a4a8..18ece9b 100644
--- a/internal/tmuxedit/agentutil.go
+++ b/internal/tmuxedit/agentutil.go
@@ -8,6 +8,7 @@ import (
"regexp"
"strconv"
"strings"
+ "time"
)
// promptMatch holds a regex match result with its line number in the pane.
@@ -117,6 +118,10 @@ func sendClearSequence(paneID, clearKeys string) error {
return fmt.Errorf("clear key %q failed: %w", key, err)
}
}
+ // Add delay after Escape to let Vim/Claude exit INSERT mode
+ if key == "Escape" {
+ time.Sleep(150 * time.Millisecond)
+ }
}
return nil
}
diff --git a/internal/tmuxedit/claude_agent.go b/internal/tmuxedit/claude_agent.go
index 72ba107..b84c77e 100644
--- a/internal/tmuxedit/claude_agent.go
+++ b/internal/tmuxedit/claude_agent.go
@@ -21,7 +21,7 @@ func newClaudeAgent() *claudeAgent {
sectionPat: `^─{5,}`,
promptPat: `(?m)❯\s*(.+)$`,
clearFirst: true,
- clearKeys: "Escape gg C-v G d i",
+ clearKeys: "C-a C-k",
newlineKeys: "S-Enter",
submitKeys: "Enter",
}}
diff --git a/internal/tmuxedit/claude_agent_test.go b/internal/tmuxedit/claude_agent_test.go
index a373378..1a80433 100644
--- a/internal/tmuxedit/claude_agent_test.go
+++ b/internal/tmuxedit/claude_agent_test.go
@@ -88,14 +88,10 @@ func TestClaudeAgent_ClearInput(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
- // "Escape gg C-v G d i" should send each as separate send-keys call
+ // "C-a C-k" (Emacs/readline style) should send each as separate send-keys call
want := []string{
- "send:%3:Escape",
- "send:%3:gg",
- "send:%3:C-v",
- "send:%3:G",
- "send:%3:d",
- "send:%3:i",
+ "send:%3:C-a",
+ "send:%3:C-k",
}
if len(calls) != len(want) {
t.Fatalf("got %d calls, want %d: %v", len(calls), len(want), calls)