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:
parent
eb6b74c547
commit
6b109ed1bc
8 changed files with 72 additions and 3 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@ func (m *mockTmux) SendKeys(session, keys string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *mockTmux) SendEnter(session string) error {
|
||||
m.sendKeysCalls = append(m.sendKeysCalls, session)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockTmux) CapturePaneTail(session string, lines int) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ func (m *mockTmux) HasSession(name string) bool { return m.sessions[name]
|
|||
func (m *mockTmux) CreateSession(name, _ string) error { m.sessions[name] = true; return nil }
|
||||
func (m *mockTmux) KillSession(_ string) error { return nil }
|
||||
func (m *mockTmux) SendKeys(_, _ string) error { return nil }
|
||||
func (m *mockTmux) SendEnter(_ string) error { return nil }
|
||||
func (m *mockTmux) CapturePaneTail(session string, _ int) (string, error) {
|
||||
return m.paneOutput[session], nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@ func (m *mockTmux) SendKeys(session, keys string) error {
|
|||
m.sendKeyCalls = append(m.sendKeyCalls, session+":"+keys)
|
||||
return nil
|
||||
}
|
||||
func (m *mockTmux) SendEnter(session string) error {
|
||||
m.sendKeyCalls = append(m.sendKeyCalls, session+":<ENTER>")
|
||||
return nil
|
||||
}
|
||||
func (m *mockTmux) CapturePaneTail(session string, _ int) (string, error) {
|
||||
return m.paneOutput[session], nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ func (m *mockTmux) HasSession(name string) bool { return m.sessions
|
|||
func (m *mockTmux) CreateSession(name, _ string) error { m.sessions[name] = true; return nil }
|
||||
func (m *mockTmux) KillSession(_ string) error { return nil }
|
||||
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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue