Add markdown rendering to mobile chat screen#85
Conversation
- 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.
This comment was marked as outdated.
Sorry, something went wrong.
| <Text style={[styles.messageText, { color: colors.text }]}>{trimmedContent}</Text> | ||
| <Markdown | ||
| style={getMarkdownStyles(colors)} | ||
| onLinkPress={(url) => { Linking.openURL(url).catch(() => {}); return true }} |
There was a problem hiding this comment.
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
Summary
react-native-markdown-displayfor rendering markdown in chat messagesLinking.openURLTest plan
🤖 Generated with Claude Code