mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 16:40:49 +00:00
fix(mattermost): honor progress tool silence
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
resolveMattermostThreadSessionContext,
|
||||
shouldFinalizeMattermostPreviewAfterDispatch,
|
||||
shouldClearMattermostDraftPreview,
|
||||
shouldUpdateMattermostDraftToolProgress,
|
||||
type MattermostMentionGateInput,
|
||||
type MattermostRequireMentionResolverInput,
|
||||
} from "./monitor.js";
|
||||
@@ -266,6 +267,53 @@ describe("canFinalizeMattermostPreviewInPlace", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldUpdateMattermostDraftToolProgress", () => {
|
||||
type MattermostConfig = NonNullable<NonNullable<OpenClawConfig["channels"]>["mattermost"]>;
|
||||
|
||||
function resolveToolProgressEnabled(mattermostConfig: MattermostConfig) {
|
||||
const account = resolveMattermostAccount({
|
||||
cfg: {
|
||||
channels: {
|
||||
mattermost: mattermostConfig,
|
||||
},
|
||||
},
|
||||
accountId: "default",
|
||||
allowUnresolvedSecretRef: true,
|
||||
});
|
||||
return shouldUpdateMattermostDraftToolProgress(account);
|
||||
}
|
||||
|
||||
it("shows tool status draft lines by default", () => {
|
||||
expect(resolveToolProgressEnabled({ enabled: true })).toBe(true);
|
||||
});
|
||||
|
||||
it("honors disabled progress-mode tool status lines", () => {
|
||||
expect(
|
||||
resolveToolProgressEnabled({
|
||||
streaming: {
|
||||
mode: "progress",
|
||||
progress: {
|
||||
toolProgress: false,
|
||||
},
|
||||
},
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps tool status draft lines disabled when draft streaming is off", () => {
|
||||
expect(
|
||||
resolveToolProgressEnabled({
|
||||
streaming: {
|
||||
mode: "off",
|
||||
progress: {
|
||||
toolProgress: true,
|
||||
},
|
||||
},
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldClearMattermostDraftPreview", () => {
|
||||
it("deletes the preview after successful normal final delivery", () => {
|
||||
expect(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { deliverFinalizableDraftPreview } from "openclaw/plugin-sdk/channel-lifecycle";
|
||||
import { resolveChannelStreamingPreviewToolProgress } from "openclaw/plugin-sdk/channel-streaming";
|
||||
import { createClaimableDedupe, type ClaimableDedupe } from "openclaw/plugin-sdk/persistent-dedupe";
|
||||
import { isReasoningReplyPayload } from "openclaw/plugin-sdk/reply-payload";
|
||||
import { resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/security-runtime";
|
||||
@@ -8,7 +9,11 @@ import {
|
||||
normalizeOptionalString,
|
||||
} from "openclaw/plugin-sdk/text-runtime";
|
||||
import { getMattermostRuntime } from "../runtime.js";
|
||||
import { resolveMattermostAccount, resolveMattermostReplyToMode } from "./accounts.js";
|
||||
import {
|
||||
resolveMattermostAccount,
|
||||
resolveMattermostReplyToMode,
|
||||
type ResolvedMattermostAccount,
|
||||
} from "./accounts.js";
|
||||
import {
|
||||
createMattermostClient,
|
||||
fetchMattermostMe,
|
||||
@@ -114,6 +119,14 @@ export type MonitorMattermostOpts = {
|
||||
webSocketFactory?: MattermostWebSocketFactory;
|
||||
};
|
||||
|
||||
export function shouldUpdateMattermostDraftToolProgress(
|
||||
account: Pick<ResolvedMattermostAccount, "config" | "streamingMode">,
|
||||
): boolean {
|
||||
return (
|
||||
account.streamingMode !== "off" && resolveChannelStreamingPreviewToolProgress(account.config)
|
||||
);
|
||||
}
|
||||
|
||||
type MediaKind = "image" | "audio" | "video" | "document" | "unknown";
|
||||
|
||||
type MattermostReaction = {
|
||||
@@ -1634,6 +1647,7 @@ export async function monitorMattermostProvider(opts: MonitorMattermostOpts = {}
|
||||
},
|
||||
});
|
||||
const draftPreviewEnabled = account.streamingMode !== "off";
|
||||
const draftToolProgressEnabled = shouldUpdateMattermostDraftToolProgress(account);
|
||||
const draftStream = draftPreviewEnabled
|
||||
? createMattermostDraftStream({
|
||||
client,
|
||||
@@ -1848,6 +1862,9 @@ export async function monitorMattermostProvider(opts: MonitorMattermostOpts = {}
|
||||
}
|
||||
},
|
||||
onToolStart: async (payload) => {
|
||||
if (!draftToolProgressEnabled) {
|
||||
return;
|
||||
}
|
||||
draftStream.update(buildMattermostToolStatusText(payload));
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user