fix(dispatcher): send a lone Enter after the task paste to submit it

Multi-line task bodies arrived in Claude Code as "[Pasted text #N +M lines]"
and sat in the input buffer forever — the trailing Enter that SendKeys
appends to the paste is consumed as a newline inside the paste, not as a
submit. Observed live on ccl-auto-11 (secumon) and ccl-auto-12 (secuops):
prompt visible, agent idle.

- tmux.Client grows a SendEnter(session) method. ExecClient runs
  `tmux send-keys -t <sess> Enter` (no preceding text), which Claude's
  TUI accepts as the explicit submit action after a paste.
- Dispatcher: after SendKeys(msg), sleep 500ms for the paste to register,
  then SendEnter. Same sequence a human would perform.
- Five mockTmux implementations updated (quota, dispatcher, switcher,
  lifecycle, watcher tests).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ubuntu 2026-04-15 20:49:59 +00:00
parent eb6b74c547
commit 6b109ed1bc
8 changed files with 72 additions and 3 deletions

View file

@ -16,8 +16,14 @@ type Client interface {
CreateSession(name, workdir string) error
// KillSession destroys the named session.
KillSession(name string) error
// SendKeys sends key strokes to the first window of a session.
// SendKeys sends key strokes to the first window of a session, terminated
// by a single Enter. Note: when keys contains newlines, Claude Code's
// TUI treats the whole block as a paste and the trailing Enter is
// consumed as part of it — call SendEnter afterwards to submit.
SendKeys(session, keys string) error
// SendEnter sends a lone Enter keypress. Used to submit a multi-line
// paste in Claude Code after SendKeys.
SendEnter(session string) error
// CapturePaneTail returns the last n lines from the session's active pane.
CapturePaneTail(session string, lines int) (string, error)
}
@ -78,6 +84,15 @@ func (c *ExecClient) SendKeys(session, keys string) error {
return nil
}
// SendEnter sends a lone Enter keypress to the session's first pane.
func (c *ExecClient) SendEnter(session string) error {
out, err := run("send-keys", "-t", session, "Enter")
if err != nil {
return fmt.Errorf("tmux send-keys Enter %q: %w (%s)", session, err, out)
}
return nil
}
// CapturePaneTail captures the last n lines from the session's active pane.
func (c *ExecClient) CapturePaneTail(session string, lines int) (string, error) {
out, err := run("capture-pane", "-p", "-t", session,