Skip to content

Preserve multiline user prompt formatting after submission #65

@roackb2

Description

@roackb2

Problem

When a user pastes or types multiline content into the TUI prompt and submits it, the submitted You message is rendered as one long flattened paragraph. Newlines are removed, making the prompt hard to read and visually different from what the user submitted.

The attached screenshots show a long multiline task prompt that was submitted with line breaks and bullet-like sections, but the conversation view renders it as a dense single block with no meaningful line breaks.

This is especially painful for copied task briefs, checklists, code-adjacent notes, file lists, and instructions where line boundaries carry structure.

Desired behavior

The displayed user message should preserve the submitted multiline formatting as closely as possible.

If a user submits:

Please implement two fixes:

1. Improve search_files performance
2. Fix approval prompts

Relevant files:
- src/core/tools/...
- src/cli/chat/...

The You message in the conversation should keep those line breaks and list boundaries, rather than flattening everything into one paragraph.

The stored conversation/session history should also retain the original user text, so re-rendering or resuming a session does not lose formatting.

Likely implementation area

Current code appears to normalize submitted prompt text as inline text before command handling and execution:

  • src/cli/chat/submit.ts
    • submitChatPrompt(...)
    • const prompt = normalizeInlineText(args.value);
  • src/cli/chat/utils/format.ts
    • normalizeInlineText(value) currently does:
value.replace(/\r?\n+/g, ' ').replace(/\s+/g, ' ').trim()

This is appropriate for some inline command parsing, but it is too destructive for normal user prompts.

Rendering may also contribute:

  • src/cli/chat/components/ConversationPanel.tsx
    • parseMessageBlocks(...)
    • collapseParagraphBlocks(...) merges adjacent paragraph blocks with a space

For user-authored messages, Heddle should avoid collapsing meaningful submitted line breaks unless there is an explicit formatting reason.

Suggested direction

Separate command normalization from prompt preservation:

  • Keep a raw or lightly trimmed submitted prompt for user messages, history, and LLM input.
  • Use an inline-normalized copy only for slash-command detection, local command parsing, and shell-command detection where appropriate.
  • Preserve line breaks in ConversationLine.text for user messages.
  • Adjust ConversationPanel parsing/rendering so user message line breaks survive display, including adjacent plain paragraph lines.

The exact internal shape can differ, but avoid a shared normalizer that silently destroys formatting for normal chat content.

Acceptance criteria

  • Submitting a multiline prompt preserves line breaks in the visible You message.
  • Session history/storage preserves multiline user prompts across restart/resume.
  • LLM input receives the intended multiline prompt, not a flattened one.
  • Slash commands still work when typed as a single-line command.
  • Shell commands using ! still work as before for normal single-line input.
  • Tests cover multiline user prompt submission and rendering.
  • Tests cover that command parsing still uses normalized command text where needed without flattening normal chat prompts.

UX rationale

Users often paste structured instructions into Heddle. The submitted conversation should be a faithful record of what they sent. Flattening multiline prompts removes structure, makes long prompts difficult to audit, and creates a mismatch between the prompt box and the conversation transcript.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingux

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions