Skip to content

Add markdown rendering to mobile chat screen#85

Merged
gricha merged 2 commits intomainfrom
mobile-markdown-support
Jan 10, 2026
Merged

Add markdown rendering to mobile chat screen#85
gricha merged 2 commits intomainfrom
mobile-markdown-support

Conversation

@gricha
Copy link
Copy Markdown
Owner

@gricha gricha commented Jan 10, 2026

Summary

  • Add react-native-markdown-display for rendering markdown in chat messages
  • Style code blocks, inline code, links, headings, lists to match theme system
  • Links are now clickable and open in the browser via Linking.openURL
  • Improves readability of SDK/agent responses that contain markdown

Test plan

  • Open chat session in mobile app
  • Send a message that prompts markdown response (code, links, lists)
  • Verify code blocks render with monospace font and background
  • Verify links are underlined and tappable
  • Verify styling works in both user and assistant messages

🤖 Generated with Claude Code

- Add react-native-markdown-display for rendering markdown
- Style code blocks, links, headings, lists to match theme
- Links are now clickable and open in browser
- Improves readability of SDK responses

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
<Text style={[styles.messageText, { color: colors.text }]}>{trimmedContent}</Text>
<Markdown
style={getMarkdownStyles(colors)}
onLinkPress={(url) => { Linking.openURL(url); return true }}

This comment was marked as outdated.

<Text style={[styles.messageText, { color: colors.text }]}>{trimmedContent}</Text>
<Markdown
style={getMarkdownStyles(colors)}
onLinkPress={(url) => { Linking.openURL(url).catch(() => {}); return true }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The onLinkPress handler manually opens the URL and also returns true, causing the library to open the same URL a second time.
Severity: HIGH

🔍 Detailed Analysis

The onLinkPress prop of the markdown component is configured to both manually open a URL via Linking.openURL(url) and then return true. According to the react-native-markdown-display library's API, returning true instructs the component to proceed with its default link-handling behavior, which is to also call Linking.openURL. This redundant logic will cause any link clicked by a user in the chat to be opened twice in the device's browser or default handler. This pattern is present in three separate locations within the SessionChatScreen.tsx file.

💡 Suggested Fix

In the onLinkPress callback, change the return value from true to false. This will signal to the react-native-markdown-display library that the link press has been handled manually and prevent it from executing its default behavior of opening the URL again.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: mobile/src/screens/SessionChatScreen.tsx#L256

Potential issue: The `onLinkPress` prop of the markdown component is configured to both
manually open a URL via `Linking.openURL(url)` and then `return true`. According to the
`react-native-markdown-display` library's API, returning `true` instructs the component
to proceed with its default link-handling behavior, which is to also call
`Linking.openURL`. This redundant logic will cause any link clicked by a user in the
chat to be opened twice in the device's browser or default handler. This pattern is
present in three separate locations within the `SessionChatScreen.tsx` file.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8437642

@gricha gricha merged commit a86b664 into main Jan 10, 2026
9 checks passed
@gricha gricha deleted the mobile-markdown-support branch January 10, 2026 23:18
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