{"record":{"id":"f9282d6aff843d15","repo":"chenhg5/cc-connect","slug":"tmux-send-keys-w","errorCode":null,"errorMessage":"tmux: send-keys: %w","messagePattern":"tmux: send-keys: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/tmux/session.go","lineNumber":108,"sourceCode":"\tif s.pollCancel != nil {\n\t\ts.pollCancel()\n\t\ts.pollCancel = nil\n\t}\n\n\t// Snapshot the full scrollback (history + visible pane) before sending.\n\t// extractResponse diffs against this to find exactly what the agent added,\n\t// regardless of whether the TUI rewrites lines in-place or scrolls them.\n\tbaseline, _ := captureScrollback(s.target)\n\tvisibleBase, _ := capturePane(s.target) // for poll stability comparison\n\ts.baselineCapture = baseline\n\n\tpollCtx, pollCancel := context.WithCancel(s.ctx)\n\ts.pollCancel = pollCancel\n\ts.mu.Unlock()\n\n\tif err := sendKeys(s.target, prompt); err != nil {\n\t\tpollCancel()\n\t\treturn fmt.Errorf(\"tmux: send-keys: %w\", err)\n\t}\n\n\tgo s.poll(pollCtx, visibleBase)\n\treturn nil\n}\n\nfunc (s *tmuxSession) poll(ctx context.Context, baseline string) {\n\tticker := time.NewTicker(s.pollInt)\n\tdefer ticker.Stop()\n\n\tprev := baseline\n\tstable := 0\n\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn\n\t\tcase <-ticker.C:","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/tmux/session.go#L90-L126","documentation":"Send injects the prompt into the tmux pane via sendKeys(s.target, prompt). If the underlying tmux command fails (non-zero exit), Send cancels the just-started polling goroutine and returns 'tmux: send-keys: %w'. This means the prompt never reached the terminal.","triggerScenarios":"The tmux target (session:window.pane) no longer exists — tmux was restarted, the session was killed, or the pane closed — so `tmux send-keys -t <target>` exits with an error.","commonSituations":"User closed the tmux pane or ran `tmux kill-session` while chatting; server rebooted and tmux wasn't restored; the configured tmux target string has a typo so the target never existed; tmux binary missing from PATH in a daemonized environment.","solutions":["Run `tmux list-sessions` / `tmux display-message -t <target>` to confirm the target exists","Recreate the tmux session/pane (or correct the target string in config) and send again","Verify the tmux binary is on PATH for the user running cc-connect (`cc-connect doctor` if available)","If sessions are transient, use tmux resurrect/continue or have the agent create its own session rather than attaching to a user-managed one"],"exampleFix":"// config.toml: wrong target\n# target = \"agent:0.1\"   # pane does not exist\n// after\n# target = \"agent:0.0\"","handlingStrategy":"fallback","validationCode":"// verify target before sending\ncmd := exec.Command(\"tmux\", \"has-session\", \"-t\", targetSession)\nif err := cmd.Run(); err != nil {\n    return fmt.Errorf(\"tmux target %q missing\", targetSession)\n}","typeGuard":null,"tryCatchPattern":"// Go\nif err := sess.Send(prompt, id, nil, files); err != nil {\n    if strings.Contains(err.Error(), \"send-keys\") {\n        slog.Error(\"tmux pane gone; recreate session\", \"err\", err)\n        // fall back to restarting the tmux session\n    }\n}","preventionTips":["Supervise tmux sessions (tmux resurrect, systemd user units) so panes survive reboots","Verify the configured target exists at session start, not first Send","Ensure the tmux binary is on PATH for the cc-connect daemon user"],"tags":["tmux","process","external-command"],"backgroundTag":"git-command-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}