Skip to content

Commit 54619d4

Browse files
committed
fix(discord): keep progress drafts for tool-only replies
1 parent 81a578f commit 54619d4

4 files changed

Lines changed: 35 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Docs: https://docs.openclaw.ai
2929
- Agents/edit tool: honor `file_path` and related path aliases when resolving edit-recovery targets, so post-write errors no longer surface false edit failures after the file actually changed. Fixes #81909. Thanks @giodl73-repo.
3030
- QQBot: treat only explicit truthy `QQBOT_DEBUG` values as enabling debug logs, so false-like values such as `0` no longer expose debug output. Fixes #82644. (#82697) Thanks @leno23.
3131
- Agents/session_status: resolve implicit no-arg status lookups against the live run session, so `/think` changes report the current thinking level instead of stale sandbox state. Fixes #82669. (#82696) Thanks @leno23.
32+
- Discord: keep progress drafts visible for message-tool-only guild replies under the default coding tool profile. Fixes #82747. Thanks @eliranwong.
3233
- Gateway/diagnostics: add opt-in critical memory pressure stability snapshots with gateway logs, V8 heap, cgroup, active-resource, and redacted large session-file evidence. Fixes #82518.
3334
- Doctor/Gateway: avoid treating unrelated macOS LaunchAgents as legacy gateways just because their environment values mention old checkout paths.
3435
- CLI/setup: collapse raw gateway config keys in existing-config summaries into friendly `Model` and `Gateway` rows.

‎extensions/discord/src/monitor/message-handler.draft-preview.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ export function createDiscordDraftPreviewController(params: {
4848
const accountBlockStreamingEnabled =
4949
resolveChannelStreamingBlockEnabled(params.discordConfig) ??
5050
params.cfg.agents?.defaults?.blockStreamingDefault === "on";
51+
const canStreamProgressDraftForToolOnlySource =
52+
params.sourceRepliesAreToolOnly && discordStreamMode === "progress";
5153
const canStreamDraft =
52-
!params.sourceRepliesAreToolOnly &&
54+
(!params.sourceRepliesAreToolOnly || canStreamProgressDraftForToolOnlySource) &&
5355
discordStreamMode !== "off" &&
5456
!accountBlockStreamingEnabled;
5557
const draftStream = canStreamDraft

‎extensions/discord/src/monitor/message-handler.process.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ type DispatchInboundParams = {
145145
onCompactionEnd?: () => Promise<void> | void;
146146
onPartialReply?: (payload: { text?: string }) => Promise<void> | void;
147147
onAssistantMessageStart?: () => Promise<void> | void;
148+
allowProgressCallbacksWhenSourceDeliverySuppressed?: boolean;
148149
};
149150
};
150151
const dispatchInboundMessage = vi.hoisted(() =>
@@ -1530,6 +1531,32 @@ describe("processDiscordMessage draft streaming", () => {
15301531
expect(deliverDiscordReply).not.toHaveBeenCalled();
15311532
});
15321533

1534+
it("streams Discord tool progress for coding-profile message-tool-only guild replies", async () => {
1535+
const draftStream = createMockDraftStreamForTest();
1536+
1537+
dispatchInboundMessage.mockImplementationOnce(async (params?: DispatchInboundParams) => {
1538+
expect(params?.replyOptions?.sourceReplyDeliveryMode).toBe("message_tool_only");
1539+
expect(params?.replyOptions?.allowProgressCallbacksWhenSourceDeliverySuppressed).toBe(true);
1540+
await params?.replyOptions?.onToolStart?.({ name: "exec", phase: "start" });
1541+
await params?.replyOptions?.onItemEvent?.({ progressText: "exec done" });
1542+
return createNoQueuedDispatchResult();
1543+
});
1544+
1545+
const ctx = await createBaseContext({
1546+
cfg: {
1547+
tools: { profile: "coding" },
1548+
session: { store: "/tmp/openclaw-discord-process-test-sessions.json" },
1549+
},
1550+
route: BASE_CHANNEL_ROUTE,
1551+
});
1552+
1553+
await runProcessDiscordMessage(ctx);
1554+
1555+
expect(getLastDispatchReplyOptions()?.sourceReplyDeliveryMode).toBe("message_tool_only");
1556+
expect(draftStream.update).toHaveBeenCalledWith("Pinching...\n🛠️ Exec\n• exec done");
1557+
expect(deliverDiscordReply).not.toHaveBeenCalled();
1558+
});
1559+
15331560
it("keeps Discord preview streaming off when explicitly disabled", async () => {
15341561
await runSingleChunkFinalScenario({ streaming: { mode: "off" }, maxLinesPerMessage: 5 });
15351562
expect(createDiscordDraftStream).not.toHaveBeenCalled();

‎extensions/discord/src/monitor/message-handler.process.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,10 @@ export async function processDiscordMessage(
656656
abortSignal,
657657
skillFilter: channelConfig?.skills,
658658
sourceReplyDeliveryMode,
659+
allowProgressCallbacksWhenSourceDeliverySuppressed:
660+
sourceRepliesAreToolOnly && draftPreview.draftStream && draftPreview.isProgressMode
661+
? true
662+
: undefined,
659663
disableBlockStreaming: sourceRepliesAreToolOnly
660664
? true
661665
: (draftPreview.disableBlockStreamingForDraft ??

0 commit comments

Comments
 (0)