fix(slack): honour replyToMode off for typing indicator#18036
fix(slack): honour replyToMode off for typing indicator#18036theoseo wants to merge 3 commits intoopenclaw:mainfrom
Conversation
9e48d0b to
3411d7a
Compare
When replyToMode is 'off' in DMs, replies should stay in the main conversation even when the typing indicator creates a thread context. Previously, when incomingThreadTs was set (from the typing indicator's thread), replyToMode was forced to 'all', causing all replies to go into the thread. Now, for direct messages, the user's configured replyToMode is always respected. For channels/groups, the existing behavior is preserved (stay in thread if already in one). This fix: - Keeps the typing indicator working (statusThreadTs fallback preserved) - Prevents DM replies from being forced into threads - Maintains channel thread continuity Fixes openclaw#16868
3411d7a to
6d2a7d8
Compare
Additional Comments (1)
Then replace the const replyThreadTs = threadCtx.incomingThreadTs ?? (ctx.replyToMode === "all" ? threadCtx.messageTs : undefined);
const statusThreadTs = replyThreadTs ?? threadCtx.messageTs;This eliminates the redundant context resolution. Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! Prompt To Fix With AIThis is a comment left during a code review.
Path: src/slack/monitor/message-handler/dispatch.ts
Line: 42:45
Comment:
**Redundant `resolveSlackThreadContext` call**
`resolveSlackThreadTargets` (line 38) already calls `resolveSlackThreadContext` internally and discards `isThreadReply`. You could avoid the duplicate computation by calling `resolveSlackThreadContext` once and deriving both `statusThreadTs` and `isThreadReply` from it:
```suggestion
const threadCtx = resolveSlackThreadContext({
message,
replyToMode: ctx.replyToMode,
});
const { isThreadReply } = threadCtx;
```
Then replace the `resolveSlackThreadTargets` call above (lines 38-41) with inline computation:
```ts
const replyThreadTs = threadCtx.incomingThreadTs ?? (ctx.replyToMode === "all" ? threadCtx.messageTs : undefined);
const statusThreadTs = replyThreadTs ?? threadCtx.messageTs;
```
This eliminates the redundant context resolution.
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise. |
- Add isThreadReply to resolveSlackThreadTargets return value - Remove duplicate call in dispatch.ts - Addresses greptile review feedback with cleaner DRY approach
|
Thanks for the review @greptile-apps! You're right about the redundant This approach:
Changed in commit 34368fc. |
|
Thanks for the thoughtful refactor! Moving One small suggestion: consider adding a JSDoc comment to This will help future maintainers understand the distinction between "has thread_ts" vs "is an actual thread reply" without needing to trace through the Slack integration logic. The refactor looks solid otherwise! 👍 |
Document return values including isThreadReply distinction between genuine user thread replies vs bot status message thread context.
|
Good idea! Added JSDoc documentation in 69e7902. 📝 |
|
Thanks for the DM-specific fix and follow-up refactor. I’m closing this in favor of #23799, which includes your Your contribution remains part of the merged path. If I missed any behavior from this branch, tell me and I’ll reopen review right away. |
Summary
When
replyToModeis"off"in DMs, replies should stay in the main conversation even when the typing indicator creates a thread context.Problem
Previously, when
incomingThreadTswas set (from the typing indicator's thread),replyToModewas forced to"all", causing all replies to go into the thread. This created an unexpected UX where:replyToMode: off)incomingThreadTssetreplyToMode: off)Solution
For direct messages, always respect the user's configured
replyToMode. For channels/groups, preserve existing behavior (stay in thread if already in one).Changes
src/slack/monitor/replies.ts: AddchatTypeparam, respectreplyToModein DMssrc/slack/monitor/message-handler/dispatch.ts: PasschatTypeto reply plannerTesting
Fixes #16868
Greptile Summary
This PR fixes a bug where Slack DM replies were incorrectly forced into threads when
replyToModewas set to"off". The typing indicator's status message creates a thread context (thread_ts), and previously this caused all subsequent replies to be threaded regardless of user configuration. The fix addschatTypeandisThreadReplyparameters to the reply planning logic, so that in DMs where the thread context comes from the typing indicator (not a real user thread reply), the configuredreplyToModeis respected.src/slack/monitor/replies.ts: ExtendedcreateSlackReplyReferencePlannerandcreateSlackReplyDeliveryPlanwith optionalchatTypeandisThreadReplyparams. TheeffectiveModelogic now bypasses thread-sticking for DMs whenisThreadReplyis false.src/slack/monitor/message-handler/dispatch.ts: Added a call toresolveSlackThreadContextto obtainisThreadReply, and passes bothchatTypeandisThreadReplyto the reply delivery plan.chatType: "direct"with/withoutisThreadReply) are not covered by unit tests.Confidence Score: 4/5
chatType === "direct") with no real thread reply (!isThreadReply), and all other code paths remain identical. Default parameter values ensure backward compatibility for existing callers likeresolveSlackThreadTs. The only concern is the absence of unit tests for the new DM-specific behavior paths, though the author reports manual verification.Last reviewed commit: 6d2a7d8
(2/5) Greptile learns from your feedback when you react with thumbs up/down!