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

@ -234,11 +234,19 @@ func (d *Dispatcher) launchAgent(session, projectDir, taskFile string) error {
return fmt.Errorf("claude not ready in %q after %v", session, promptTimeout)
}
// Send the task message.
// Send the task message. Multi-line task bodies render in Claude's TUI
// as "[Pasted text #N +M lines]" — the trailing Enter that SendKeys
// appends is consumed as part of the paste, so the message would stay
// unsubmitted in the input buffer forever. Wait for the paste to
// register, then send a lone Enter to actually submit.
msg := buildTaskMessage(body, taskFile)
if err := d.tmux.SendKeys(session, msg); err != nil {
return err
}
time.Sleep(500 * time.Millisecond)
if err := d.tmux.SendEnter(session); err != nil {
return err
}
d.state.SetWorking(session, filepath.Base(taskFile))
d.logger.Printf("[dispatcher] DISPATCHED session=%q task=%s model=%s",

View file

@ -31,6 +31,10 @@ func (m *mockTmux) SendKeys(_, keys string) error {
m.sentKeys = append(m.sentKeys, keys)
return nil
}
func (m *mockTmux) SendEnter(_ string) error {
m.sentKeys = append(m.sentKeys, "<ENTER>")
return nil
}
func (m *mockTmux) CapturePaneTail(session string, _ int) (string, error) {
return m.paneOutput[session], nil
}