fix(mattermost): preserve Markdown formatting + native tables#2
fix(mattermost): preserve Markdown formatting + native tables#2
Conversation
… natively Three related bugs in the Mattermost channel plugin: 1. normalizeMention() used \s+ replacement which collapsed newlines into spaces, destroying all block-level Markdown (headings, lists, blockquotes, task lists) in inbound messages. Fixed to only collapse horizontal whitespace (spaces/tabs) while preserving newlines. 2. DEFAULT_TABLE_MODES did not include mattermost, so it fell through to the "code" default which wraps tables in fenced code blocks. Mattermost clients render pipe tables natively, so the correct default is "off". 3. When tableMode was "code" and a message contained tables, the entire text was re-rendered through the IR pipeline which also stripped block formatting from non-table content. Also extracted normalizeMention to monitor-helpers.ts for testability and added unit tests for both fixes. Fixes: openclaw#12247, openclaw#12245, openclaw#12238
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1702fa2b81
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .replace(/[^\S\n]+/g, " ") | ||
| .replace(/ ?\n ?/g, "\n") |
There was a problem hiding this comment.
Keep leading indentation after mention removal
Collapsing all horizontal whitespace here still strips indentation that Markdown relies on, so messages like @bot\n- item\n - nested or indented code blocks lose structure after normalization (nested becomes a top-level list item, code block indentation is removed). This means the new mention-normalization path still corrupts common multi-line Markdown inputs in Mattermost whenever a bot mention is present.
Useful? React with 👍 / 👎.
…eedback) Replaced blanket horizontal-whitespace collapse with a line-by-line approach that only collapses runs of multiple spaces after non-space characters, preserving leading indentation for nested lists and code blocks.
|
@codex what about that fix? |
|
To use Codex here, create a Codex account and connect to github. |
…of source text Address review feedback: replace brittle fs.readFileSync source inspection with direct import of the exported map.
Fixes three related Mattermost Markdown issues:
Changes:
Fixes openclaw#12247 openclaw#12245 openclaw#12238
Tests: pnpm vitest run extensions/mattermost/