Skip to content

Trace and preserve Markdown through message copy and paste #279

Description

@yaacovcorcos

Problem

Markdown obtained after copying and pasting a rendered assistant message has sometimes differed from the stored message source. In the investigated examples, stored $PCO_2$ appeared downstream as $PCO\_2$, along with HTML space entities and unusual emphasis markers. A blanket unescape would corrupt intentional TeX and Markdown, so the transformation must be located before changing behavior.

Verified diagnosis

  • Read-only inspection of an authorized example confirmed that the stored response contains $PCO_2$, with no escaped underscore.
  • The same stored text existed in the parent and fork, excluding fork creation as the source of the change.
  • The message-copy button does not itself add underscore escapes to the text passed to its clipboard writer.

Relevant paths:

  • apps/web/src/components/chat/MessageCopyButton.tsx
  • apps/web/src/hooks/useCopyToClipboard.ts
  • apps/web/src/markdown-clipboard.ts
  • the receiving Markdown composer serialization path

Investigation required

For a synthetic message containing subscripts, intentional escaped underscores, emphasis, entities, and mixed Hebrew/English text, capture and compare:

  1. Stored message source.
  2. Text supplied to the copy action.
  3. Written text/plain and text/html clipboard flavors.
  4. The receiving composer's parsed and serialized source.

Run the matrix for the message copy button and manual selection copy. Record the exact app version and receiving surface.

Desired behavior

The plain Markdown flavor should preserve authored syntax predictably, and paste handling should not introduce or remove escapes without a format-specific reason. Rich HTML and plain text may differ structurally, but each must have a defined contract.

Non-goals

  • Do not globally replace \_ with _.
  • Do not infer the faulty component from screenshot text.
  • Do not change stored messages while diagnosing clipboard behavior.

Validation

Cover intentional literal underscores, TeX subscripts, links, code, emphasis, HTML entities, Hebrew/English text, and copy/paste round trips. Verify native clipboard flavors and manual behavior before closure.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.needs-triageIssue needs maintainer review and initial categorization.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions