Open
Conversation
Add Markdown detection, parsing and rendering utilities and integrate them into message cells. Introduces KMMarkdownDetector, KMMarkdownParser and KMMarkdownRenderer which use iOS 15 AttributedString markdown parsing with fallbacks for older OS versions. Update KMChatMessageBaseCell to detect markdown in incoming (non-my) text, render Markdown into attributed strings, merge mention styling with Markdown output, and use the combined attributed text for sizing and display. Update KMChatFriendMessageCell to render reply text with the Markdown parser and include minor formatting/formatting-cleanups for constraints and image resource construction.
Comment on lines
+327
to
+332
| mentionAttributed.enumerateAttributes( | ||
| in: NSRange(location: 0, length: mentionAttributed.length), | ||
| options: [] | ||
| ) { attributes, range, _ in | ||
| if attributes.keys.contains(.foregroundColor) || | ||
| attributes.keys.contains(.backgroundColor) || |
There was a problem hiding this comment.
Bug: Height calculation in messageHeight() assumes markdown for all messages, but setMessageText() only renders it for received messages, causing layout bugs for self-sent markdown messages.
Severity: MEDIUM
Suggested Fix
The height calculation logic in messageHeight() should be aligned with the display logic in setMessageText(). It should check if the message is self-sent (viewModel.isMyMessage) and only apply markdown sizing for received messages, matching the rendering behavior.
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: Sources/Views/KMChatMessageBaseCell.swift#L327-L332
Potential issue: There is an inconsistency between message height calculation and
rendering for self-sent messages. The `messageHeight()` method calculates the cell
height assuming markdown is applied to all messages, including those sent by the user.
However, the `setMessageText()` method only renders markdown for received messages. This
causes a mismatch for self-sent messages containing markdown syntax, leading to
incorrect UI rendering, such as text clipping or improper bubble sizing.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add Markdown detection, parsing, and rendering utilities, and integrate them into message cells
Introduce
KMMarkdownDetector,KMMarkdownParser, andKMMarkdownRendererleveraging iOS 15AttributedStringMarkdown parsing with fallbacks for older OS versionsUpdate
KMChatMessageBaseCellto:Update
KMChatFriendMessageCellto:Image