Skip to content

af send: Enter (\r) doesn't submit multi-line formatted messages #492

@waleedkadous

Description

@waleedkadous

Bug (Updated Diagnosis)

af send messages never get their Enter keystroke processed by Claude Code. The user always has to press Enter manually after the message appears.

Root Cause

The formatted message is a multi-line block:

### [ARCHITECT INSTRUCTION | 2026-...] ###
PR approved. Please merge.
###############################

This gets written to the PTY as a single session.write(formattedMessage + '\r'). The PTY/terminal processes the embedded \n characters as line breaks. By the time the trailing \r arrives, the cursor is on an empty line after the ### footer. The \r submits that empty line, not the message content.

This is fundamentally different from how the terminal handles human input — Claude Code sees a multi-line paste event and displays it, but the trailing \r just adds a blank Enter after the display.

Why Cron Messages Work

Cron messages (af-cron) also use the same format and \r, but they appear to work because the Claude Code process treats the pasted block as input regardless — the message content itself triggers the AI to respond. The \r was never actually submitting the message; it was always just adding a blank line.

History

Fix Options

  1. Send \r before the message: Write '\r' + formattedMessage + '\r' so the first Enter clears any partial input, then the message is pasted, then the final Enter submits
  2. Send \r\n at the end: Some terminals need \r\n rather than just \r
  3. Investigate how Claude Code handles pasted input: Maybe there's a bracket-paste mode issue where the message needs to be wrapped in paste markers

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions