Skip to content

[Bug] Preserve logical newlines across paste, serialization, and user bubbles #352

Description

@AlphaCatMeow

Affected area

Desktop UI (agent-gui / React) and Gateway WebUI.

Version or commit

main@7de95a20bf93cfe026a57f6367c453e74a50acef

Environment

  • Windows 11 desktop app (pnpm --dir crates/agent-gui tauri dev)
  • Self-hosted Gateway backend and Gateway WebUI
  • The affected desktop React path is shared by Windows, macOS, and Linux

Steps to reproduce

  1. Paste alpha\n\nbeta into the message composer. The clipboard may contain only text/plain or both text/plain and text/html.
  2. Send the message and inspect the optimistic user bubble.
  3. Reload the window or restore the same conversation from history.
  4. Repeat with LF, CRLF, CR, leading/trailing newlines, and multiple consecutive blank lines.
  5. Compare a manually typed message with the same logical text.

Expected behavior

  • CRLF/CR may normalize to LF, but the number and position of logical newlines remain unchanged.
  • A single blank line renders as one blank line.
  • Composer draft, outbound payload, history/replay, desktop bubble, and Gateway WebUI bubble contain the same logical text.
  • Manual input and paste produce identical payloads and rendering.

Actual behavior

  • Chromium represents a pasted empty line as DIV > BR.
  • The composer serializer counts both the block boundary and the placeholder BR, so alpha\n\nbeta becomes alpha\n\n\nbeta.
  • Full-message trim() calls remove valid leading and trailing logical newlines.
  • The user bubble faithfully renders the already-expanded text, making one blank line appear roughly three lines high.
  • A trailing LF remains in DOM text but Chromium does not allocate its final visual line box.

Evidence

The deterministic production-module browser reproduction records every stage:

Stage Before fix for alpha\n\nbeta Expected
Clipboard 2 newlines 2
Composer 3 newlines 2
Outbound 3 newlines 2
History/replay 3 newlines 2
User bubble DOM 3 newlines 2

GUI and Gateway WebUI screenshots with the corrected five-stage counts and visual spacing are attached below.

Pre-submit checklist

  • I searched existing issues and pull requests and found no duplicate issue.
  • This is not a security vulnerability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions