summaryrefslogtreecommitdiff
path: root/internal/tmuxedit/capture_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-08 11:14:36 +0200
committerPaul Buetow <paul@buetow.org>2026-02-08 11:14:36 +0200
commit5e825543dc55a2c649e68dce6341844ad71fa217 (patch)
treef7aae1c1d130f08c383f95a23413bdde7843dc0f /internal/tmuxedit/capture_test.go
parent023ed82e612451caa38ec46106ed9d148ab9a595 (diff)
add hexai-tmux-edit: tmux popup editor for AI agent prompts
New tool that opens $EDITOR in a tmux popup for composing longer prompts when working with AI CLI agents (Claude Code, Cursor, Amp, Aider, etc.). Captures existing prompt text from the target pane, pre-fills the editor, and sends edited text back via tmux send-keys. Config-driven agent detection via regex patterns in [tmux_edit] config section. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/tmuxedit/capture_test.go')
-rw-r--r--internal/tmuxedit/capture_test.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/internal/tmuxedit/capture_test.go b/internal/tmuxedit/capture_test.go
new file mode 100644
index 0000000..40d0e98
--- /dev/null
+++ b/internal/tmuxedit/capture_test.go
@@ -0,0 +1,51 @@
+package tmuxedit
+
+import (
+ "fmt"
+ "testing"
+)
+
+func TestCapturePane_Success(t *testing.T) {
+ old := runCommand
+ defer func() { runCommand = old }()
+ runCommand = func(name string, args ...string) ([]byte, error) {
+ if name == "tmux" && len(args) >= 3 && args[0] == "capture-pane" {
+ return []byte("Claude Code v1.0\n> hello world\n"), nil
+ }
+ return nil, fmt.Errorf("unexpected: %s %v", name, args)
+ }
+ got, err := capturePane("%5")
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+ if got != "Claude Code v1.0\n> hello world" {
+ t.Errorf("got %q, want trimmed content", got)
+ }
+}
+
+func TestCapturePane_Error(t *testing.T) {
+ old := runCommand
+ defer func() { runCommand = old }()
+ runCommand = func(string, ...string) ([]byte, error) {
+ return nil, fmt.Errorf("pane not found")
+ }
+ _, err := capturePane("%999")
+ if err == nil {
+ t.Fatal("expected error for failed capture")
+ }
+}
+
+func TestCapturePane_EmptyContent(t *testing.T) {
+ old := runCommand
+ defer func() { runCommand = old }()
+ runCommand = func(string, ...string) ([]byte, error) {
+ return []byte("\n\n"), nil
+ }
+ got, err := capturePane("%1")
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+ if got != "" {
+ t.Errorf("got %q, want empty string", got)
+ }
+}