fix(slack): apply mrkdwn conversion in streaming and preview paths

The native streaming path (chatStream) and preview final edit path
(chat.update) send raw Markdown text without converting to Slack
mrkdwn format. This causes **bold** to appear as literal asterisks
instead of rendered bold text.

Apply markdownToSlackMrkdwn() in streaming.ts (start/append/stop) and
in dispatch.ts (preview final edit via chat.update) to match the
non-streaming delivery path behavior.

Closes #31892
This commit is contained in:
SidQin-cyber
2026-03-03 00:48:54 +08:00
committed by Peter Steinberger
parent f534ea9906
commit 1c61440ff3
2 changed files with 6 additions and 4 deletions

View File

@@ -12,6 +12,7 @@ import { danger, logVerbose, shouldLogVerbose } from "../../../globals.js";
import { resolveAgentOutboundIdentity } from "../../../infra/outbound/identity.js";
import { removeSlackReaction } from "../../actions.js";
import { createSlackDraftStream } from "../../draft-stream.js";
import { markdownToSlackMrkdwn } from "../../format.js";
import { recordSlackThreadParticipation } from "../../sent-thread-cache.js";
import {
applyAppendOnlyStreamUpdate,
@@ -290,7 +291,7 @@ export async function dispatchPreparedSlackMessage(prepared: PreparedSlackMessag
token: ctx.botToken,
channel: draftChannelId,
ts: draftMessageId,
text: finalText.trim(),
text: markdownToSlackMrkdwn(finalText.trim()),
});
return;
} catch (err) {

View File

@@ -14,6 +14,7 @@
import type { WebClient } from "@slack/web-api";
import type { ChatStreamer } from "@slack/web-api/dist/chat-stream.js";
import { logVerbose } from "../globals.js";
import { markdownToSlackMrkdwn } from "./format.js";
// ---------------------------------------------------------------------------
// Types
@@ -99,7 +100,7 @@ export async function startSlackStream(
// If initial text is provided, send it as the first append which will
// trigger the ChatStreamer to call chat.startStream under the hood.
if (text) {
await streamer.append({ markdown_text: text });
await streamer.append({ markdown_text: markdownToSlackMrkdwn(text) });
logVerbose(`slack-stream: appended initial text (${text.length} chars)`);
}
@@ -121,7 +122,7 @@ export async function appendSlackStream(params: AppendSlackStreamParams): Promis
return;
}
await session.streamer.append({ markdown_text: text });
await session.streamer.append({ markdown_text: markdownToSlackMrkdwn(text) });
logVerbose(`slack-stream: appended ${text.length} chars`);
}
@@ -147,7 +148,7 @@ export async function stopSlackStream(params: StopSlackStreamParams): Promise<vo
}`,
);
await session.streamer.stop(text ? { markdown_text: text } : undefined);
await session.streamer.stop(text ? { markdown_text: markdownToSlackMrkdwn(text) } : undefined);
logVerbose("slack-stream: stream stopped");
}