feat(imessage): add markdown.strip config option#7118
feat(imessage): add markdown.strip config option#7118PeterRosdahl wants to merge 4 commits intoopenclaw:mainfrom
Conversation
| accountId, | ||
| }); | ||
| const result = await send(to, text, { | ||
| const finalText = maybeStripMarkdown(text, cfg, accountId); |
There was a problem hiding this comment.
[P1] sendMedia currently always passes text through maybeStripMarkdown, but text is likely optional/undefined for media sends (many channels support media-without-caption). If text is undefined, stripMarkdown(text) will throw at runtime.
Consider guarding the caption:
| const finalText = maybeStripMarkdown(text, cfg, accountId); | |
| const finalText = text ? maybeStripMarkdown(text, cfg, accountId) : text; |
(or adjust the types to guarantee text is always a string for media sends). Is text guaranteed to be a non-empty string for sendMedia, or is it optional/undefined when sending media without a caption?
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/channels/plugins/outbound/imessage.ts
Line: 31:31
Comment:
[P1] `sendMedia` currently always passes `text` through `maybeStripMarkdown`, but `text` is likely optional/undefined for media sends (many channels support media-without-caption). If `text` is `undefined`, `stripMarkdown(text)` will throw at runtime.
Consider guarding the caption:
```suggestion
const finalText = text ? maybeStripMarkdown(text, cfg, accountId) : text;
```
(or adjust the types to guarantee `text` is always a string for media sends). Is `text` guaranteed to be a non-empty string for `sendMedia`, or is it optional/undefined when sending media without a caption?
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Thanks for the review! This is already handled - maybeStripMarkdown returns early if text is falsy:
if (!text) return text;And there's an explicit test case "handles undefined caption in media sends" that verifies this behavior works correctly with undefined captions.
Feedback: Additional Code Path NeededThanks for working on this! The Issue: Missing Monitor PathThe PR correctly patches the outbound adapter ( However, there's a second code path that also needs patching: This file handles replies to incoming messages (the normal chat flow), which is the most common use case. Currently, the monitor path calls Without patching both paths, Suggestion: Link HandlingAdditionally, consider how iMessage auto-linkifies URLs, so users still get a clickable link. Converting to just "Click here" loses the URL entirely. Summary
Happy to help test if needed! |
|
Thanks for the thorough review @Jodameister! Both issues addressed: 1. Monitor path patched — Added 2. Link handling improved — Added test coverage for the new link behavior. Ready for another look! |
Update: Code structure changed in v2026.2.xJust updated to 2026.2.2-3 and noticed the source file structure has changed significantly. Old structure (before bundling):
New structure (bundled):
The patch locations are now:
Both still call Note: The Just wanted to flag this in case the PR needs adjustment for the new bundled structure. 🙂 |
|
Small correction to my previous comment: After further testing, I found that the iMessage code is actually present in 3 separate bundles, not just one:
Each contains the The code structure is still the same (bundled), but it's split across multiple entry points rather than a single file. |
|
Found the issue causing CI failures:
Quick fix: git rm openclaw-2026-02-02.log
echo "*.log" >> .gitignore
git add .gitignore
git commit -m "chore: remove log file and ignore future logs"
git pushRe: Jodameister's bundling feedback: The |
bfc1ccb to
f92900f
Compare
This comment was marked as spam.
This comment was marked as spam.
c065c3f to
0591553
Compare
|
Re-triggered CI after flaky Bun download failure (502 from GitHub releases). |
Adds a new 'strip' option to the markdown config that allows
stripping markdown formatting from outbound messages.
This is useful for channels like iMessage and SMS that don't
render markdown - raw asterisks and hashes look ugly to recipients.
Usage:
channels:
imessage:
markdown:
strip: true
The option can be set at channel level or per-account.
Closes openclaw#3846
…n links - Apply stripMarkdown() in imessage/monitor/deliver.ts (the main chat reply path) when markdown.strip config is enabled. Previously only the outbound adapter path was patched. - Change stripMarkdown() link handling: [text](url) now becomes just url instead of text. iMessage/SMS auto-linkify URLs, so this gives users clickable links instead of losing the URL entirely.
9be3b7d to
5e07a29
Compare
|
Rebased on latest main to pick up recent changes. |
|
👋 Friendly ping! CI is green after rebase on main. This PR adds a |
|
This pull request has been automatically marked as stale due to inactivity. |
Summary
Adds a new
stripoption to the markdown config that allows stripping markdown formatting from outbound messages.This is useful for channels like iMessage and SMS that don't render markdown - raw asterisks and hashes look ugly to recipients.
Usage
The option can be set at channel level or per-account.
Changes
strip?: booleantoMarkdownConfigtypestriptoMarkdownConfigSchemazod schemastripMarkdown()when enabledSince SMS goes through the same iMessage channel (Apple Messages handles both), this also covers SMS.
Closes #3846
Greptile Overview
Greptile Summary
Adds a
markdown.stripoption to the shared markdown config (types + Zod schema) and wires it into the iMessage outbound adapter so outbound text/captions can have markdown formatting removed when enabled. Includes a new Vitest suite covering default behavior, channel-level enablement, per-account overrides, header stripping, and media caption stripping.Confidence Score: 3/5
sendMediaapplies markdown stripping unconditionally totext, which may be optional; if undefined, it can throw at runtime depending on adapter contract.(2/5) Greptile learns from your feedback when you react with thumbs up/down!