Skip to content

Commit 3546a54

Browse files
committed
fix(mattermost): honor progress tool silence
1 parent 8a1e220 commit 3546a54

3 files changed

Lines changed: 67 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Docs: https://docs.openclaw.ai
4141
- Control UI/WebChat: collapse duplicate in-flight internal text sends onto the active Gateway run so rapid repeat submits do not start fresh `agent:main:main` dispatches. Fixes #75737. Thanks @dsdsddd1 and @BunsDev.
4242
- Mattermost: accept the documented `channels.mattermost.streaming` config and honor `streaming: "off"` by disabling draft preview posts. Thanks @vincentkoc.
4343
- Mattermost: expose streaming progress config labels and help text in generated channel config metadata so Control UI/docs can explain the new `channels.mattermost.streaming.progress.*` fields. Thanks @vincentkoc.
44+
- Mattermost: honor `channels.mattermost.streaming.progress.toolProgress=false` in progress draft mode so compact tool status lines stay hidden until final delivery. Thanks @vincentkoc.
4445
- Discord: keep progress draft boundary callbacks bound during streaming replies, so extension lint stays green while progress previews transition between assistant and reasoning blocks. Thanks @vincentkoc.
4546
- Discord: resolve SecretRef-backed bot tokens from the active runtime snapshot for named accounts and keep unresolved configured tokens from crashing status or health checks. (#76987) Thanks @joshavant.
4647
- Channels/streaming: expose `streaming.progress.label`, `labels`, `maxLines`, and `toolProgress` in bundled channel config metadata so progress draft settings appear in config, docs, and control surfaces. Thanks @vincentkoc.

extensions/mattermost/src/mattermost/monitor.test.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
resolveMattermostThreadSessionContext,
1818
shouldFinalizeMattermostPreviewAfterDispatch,
1919
shouldClearMattermostDraftPreview,
20+
shouldUpdateMattermostDraftToolProgress,
2021
type MattermostMentionGateInput,
2122
type MattermostRequireMentionResolverInput,
2223
} from "./monitor.js";
@@ -266,6 +267,53 @@ describe("canFinalizeMattermostPreviewInPlace", () => {
266267
});
267268
});
268269

270+
describe("shouldUpdateMattermostDraftToolProgress", () => {
271+
type MattermostConfig = NonNullable<NonNullable<OpenClawConfig["channels"]>["mattermost"]>;
272+
273+
function resolveToolProgressEnabled(mattermostConfig: MattermostConfig) {
274+
const account = resolveMattermostAccount({
275+
cfg: {
276+
channels: {
277+
mattermost: mattermostConfig,
278+
},
279+
},
280+
accountId: "default",
281+
allowUnresolvedSecretRef: true,
282+
});
283+
return shouldUpdateMattermostDraftToolProgress(account);
284+
}
285+
286+
it("shows tool status draft lines by default", () => {
287+
expect(resolveToolProgressEnabled({ enabled: true })).toBe(true);
288+
});
289+
290+
it("honors disabled progress-mode tool status lines", () => {
291+
expect(
292+
resolveToolProgressEnabled({
293+
streaming: {
294+
mode: "progress",
295+
progress: {
296+
toolProgress: false,
297+
},
298+
},
299+
}),
300+
).toBe(false);
301+
});
302+
303+
it("keeps tool status draft lines disabled when draft streaming is off", () => {
304+
expect(
305+
resolveToolProgressEnabled({
306+
streaming: {
307+
mode: "off",
308+
progress: {
309+
toolProgress: true,
310+
},
311+
},
312+
}),
313+
).toBe(false);
314+
});
315+
});
316+
269317
describe("shouldClearMattermostDraftPreview", () => {
270318
it("deletes the preview after successful normal final delivery", () => {
271319
expect(

extensions/mattermost/src/mattermost/monitor.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { deliverFinalizableDraftPreview } from "openclaw/plugin-sdk/channel-lifecycle";
2+
import { resolveChannelStreamingPreviewToolProgress } from "openclaw/plugin-sdk/channel-streaming";
23
import { createClaimableDedupe, type ClaimableDedupe } from "openclaw/plugin-sdk/persistent-dedupe";
34
import { isReasoningReplyPayload } from "openclaw/plugin-sdk/reply-payload";
45
import { resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/security-runtime";
@@ -8,7 +9,11 @@ import {
89
normalizeOptionalString,
910
} from "openclaw/plugin-sdk/text-runtime";
1011
import { getMattermostRuntime } from "../runtime.js";
11-
import { resolveMattermostAccount, resolveMattermostReplyToMode } from "./accounts.js";
12+
import {
13+
resolveMattermostAccount,
14+
resolveMattermostReplyToMode,
15+
type ResolvedMattermostAccount,
16+
} from "./accounts.js";
1217
import {
1318
createMattermostClient,
1419
fetchMattermostMe,
@@ -114,6 +119,14 @@ export type MonitorMattermostOpts = {
114119
webSocketFactory?: MattermostWebSocketFactory;
115120
};
116121

122+
export function shouldUpdateMattermostDraftToolProgress(
123+
account: Pick<ResolvedMattermostAccount, "config" | "streamingMode">,
124+
): boolean {
125+
return (
126+
account.streamingMode !== "off" && resolveChannelStreamingPreviewToolProgress(account.config)
127+
);
128+
}
129+
117130
type MediaKind = "image" | "audio" | "video" | "document" | "unknown";
118131

119132
type MattermostReaction = {
@@ -1634,6 +1647,7 @@ export async function monitorMattermostProvider(opts: MonitorMattermostOpts = {}
16341647
},
16351648
});
16361649
const draftPreviewEnabled = account.streamingMode !== "off";
1650+
const draftToolProgressEnabled = shouldUpdateMattermostDraftToolProgress(account);
16371651
const draftStream = draftPreviewEnabled
16381652
? createMattermostDraftStream({
16391653
client,
@@ -1848,6 +1862,9 @@ export async function monitorMattermostProvider(opts: MonitorMattermostOpts = {}
18481862
}
18491863
},
18501864
onToolStart: async (payload) => {
1865+
if (!draftToolProgressEnabled) {
1866+
return;
1867+
}
18511868
draftStream.update(buildMattermostToolStatusText(payload));
18521869
},
18531870
},

0 commit comments

Comments
 (0)