Skip to content

fix(mobile): hide unused link reference definitions like desktop - #8389

Open
cwschroeder wants to merge 1 commit into
block:mainfrom
cwschroeder:fix/mobile-hide-link-definitions
Open

cwschroeder wants to merge 1 commit into
block:mainfrom
cwschroeder:fix/mobile-hide-link-definitions

Conversation

@cwschroeder

Copy link
Copy Markdown

Summary

A CommonMark link reference definition such as [label]: # renders as nothing on desktop, because react-markdown drops definition nodes. The mobile renderer (gpt_markdown) has no definitions and shows the line as plain text, so the same message looks different on the two clients.

Agent tooling uses such a line to carry a machine-readable marker above a human-readable post. On desktop the post starts with the text; on mobile it starts with the marker.

MessageContent now removes definitions that no reference in the message uses, before the existing link normalization.

  • Definitions that a [label] points to stay. Mobile cannot resolve the reference, and the raw line is the only place the destination is visible, so removing it would lose information.
  • Fenced code and lines that continue a paragraph are left alone, as in CommonMark.
  • CRLF line endings are handled.

Testing

  • flutter test test/features/channels/message_content/link_reference_definitions_test.dart: nine cases (leading and inner unused definitions, full and collapsed references, fenced code, paragraph continuation, look-alikes, CRLF, no-op).
  • flutter test test/features/channels/message_content_test.dart: new widget test renders a message through MessageContent and asserts the marker text is gone while the body renders. It fails when the call in MessageContent is removed.
  • dart format and flutter analyze on the changed files: clean.

Not checked on a device or simulator.

🤖 Generated with Claude Code

A CommonMark link reference definition such as `[label]: #` renders as
nothing on desktop, because react-markdown drops definition nodes. The
mobile renderer (gpt_markdown) has no definitions and shows the line as
plain text, so the same message looks different on the two clients.
Agent tooling uses such a line to carry a machine-readable marker on top
of a human-readable post; on mobile the marker stays visible.

MessageContent now removes definitions that no reference in the message
uses before the existing link normalization. Definitions that a
`[label]` points to stay, because mobile cannot resolve the reference and
the raw line is the only place the destination is visible. Fenced code
and lines that continue a paragraph are left alone, as in CommonMark.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christian Schröder <christian.w.schroeder@gmail.com>
@cwschroeder
cwschroeder requested a review from a team as a code owner October 16, 2026 06:35
@github-actions

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is 93ffc37cbdb7ced6a07eca11744931cdffb82e20...2a999f4d80e5d84fdd72c019a3ad6415621bb76f.
A new review must complete for this exact range. When manual authorization
is required, a user with write access must comment exactly
@buzz-security-review 2a999f4d80e5d84fdd72c019a3ad6415621bb76f to authorize a new review.
Any previous review applies only to its recorded range.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant