chenhg5/cc-connect · error
tmux: send-keys: %w
Error message
tmux: send-keys: %w
What it means
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.
Source
Thrown at agent/tmux/session.go:108
if s.pollCancel != nil {
s.pollCancel()
s.pollCancel = nil
}
// Snapshot the full scrollback (history + visible pane) before sending.
// extractResponse diffs against this to find exactly what the agent added,
// regardless of whether the TUI rewrites lines in-place or scrolls them.
baseline, _ := captureScrollback(s.target)
visibleBase, _ := capturePane(s.target) // for poll stability comparison
s.baselineCapture = baseline
pollCtx, pollCancel := context.WithCancel(s.ctx)
s.pollCancel = pollCancel
s.mu.Unlock()
if err := sendKeys(s.target, prompt); err != nil {
pollCancel()
return fmt.Errorf("tmux: send-keys: %w", err)
}
go s.poll(pollCtx, visibleBase)
return nil
}
func (s *tmuxSession) poll(ctx context.Context, baseline string) {
ticker := time.NewTicker(s.pollInt)
defer ticker.Stop()
prev := baseline
stable := 0
for {
select {
case <-ctx.Done():
return
case <-ticker.C:View on GitHub (pinned to 4000b2338a)
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
Example fix
// config.toml: wrong target # target = "agent:0.1" # pane does not exist // after # target = "agent:0.0"
Defensive patterns
Strategy: fallback
Validate before calling
// verify target before sending
cmd := exec.Command("tmux", "has-session", "-t", targetSession)
if err := cmd.Run(); err != nil {
return fmt.Errorf("tmux target %q missing", targetSession)
} Try / catch
// Go
if err := sess.Send(prompt, id, nil, files); err != nil {
if strings.Contains(err.Error(), "send-keys") {
slog.Error("tmux pane gone; recreate session", "err", err)
// fall back to restarting the tmux session
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/f9282d6aff843d15.
Report an issue: GitHub.