fix(slack): route DM replies to original channel, not App Home

When @mentioned in a DM between two other users, replies were going to
the sender's App Home instead of the original DM channel.

Root cause: `user:${message.user}` target triggers `conversations.open()`
in send.ts, which opens a new bot↔user DM rather than using the original
channel ID.

Fix: Always use `channel:${message.channel}` for the reply target.
The Slack API accepts channel IDs for all conversation types.

Note: lastRoute tracking (line 538) intentionally still uses user:X
for identity/session purposes.

Fixes #2412

Co-Authored-By: Warp <agent@warp.dev>
This commit is contained in:
Mac Bennett 2026-01-26 17:24:23 -05:00
parent fe1f2d971a
commit 24399137ae

View File

@ -437,7 +437,10 @@ export async function prepareSlackMessage(params: {
});
}
const slackTo = isDirectMessage ? `user:${message.user}` : `channel:${message.channel}`;
// Always use channel ID for replies - user:X triggers conversations.open which
// creates a bot↔user DM (App Home) instead of posting to the original channel.
// This broke @mentions in DMs between two other users. See #2412.
const slackTo = `channel:${message.channel}`;
const channelDescription = [channelInfo?.topic, channelInfo?.purpose]
.map((entry) => entry?.trim())