mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:30:44 +00:00
fix(mattermost): suppress draft progress chatter
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
resolveMattermostThreadSessionContext,
|
||||
shouldFinalizeMattermostPreviewAfterDispatch,
|
||||
shouldClearMattermostDraftPreview,
|
||||
shouldSuppressMattermostDefaultToolProgressMessages,
|
||||
shouldUpdateMattermostDraftToolProgress,
|
||||
type MattermostMentionGateInput,
|
||||
type MattermostRequireMentionResolverInput,
|
||||
@@ -314,6 +315,37 @@ describe("shouldUpdateMattermostDraftToolProgress", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldSuppressMattermostDefaultToolProgressMessages", () => {
|
||||
type MattermostConfig = NonNullable<NonNullable<OpenClawConfig["channels"]>["mattermost"]>;
|
||||
|
||||
function resolveSuppressDefaultProgress(mattermostConfig: MattermostConfig) {
|
||||
const account = resolveMattermostAccount({
|
||||
cfg: {
|
||||
channels: {
|
||||
mattermost: mattermostConfig,
|
||||
},
|
||||
},
|
||||
accountId: "default",
|
||||
allowUnresolvedSecretRef: true,
|
||||
});
|
||||
return shouldSuppressMattermostDefaultToolProgressMessages(account);
|
||||
}
|
||||
|
||||
it("suppresses standalone progress messages while draft previews are active", () => {
|
||||
expect(resolveSuppressDefaultProgress({ enabled: true })).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps standalone progress messages available when draft streaming is off", () => {
|
||||
expect(
|
||||
resolveSuppressDefaultProgress({
|
||||
streaming: {
|
||||
mode: "off",
|
||||
},
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldClearMattermostDraftPreview", () => {
|
||||
it("deletes the preview after successful normal final delivery", () => {
|
||||
expect(
|
||||
|
||||
@@ -127,6 +127,12 @@ export function shouldUpdateMattermostDraftToolProgress(
|
||||
);
|
||||
}
|
||||
|
||||
export function shouldSuppressMattermostDefaultToolProgressMessages(
|
||||
account: Pick<ResolvedMattermostAccount, "streamingMode">,
|
||||
): boolean {
|
||||
return account.streamingMode !== "off";
|
||||
}
|
||||
|
||||
type MediaKind = "image" | "audio" | "video" | "document" | "unknown";
|
||||
|
||||
type MattermostReaction = {
|
||||
@@ -1648,6 +1654,8 @@ export async function monitorMattermostProvider(opts: MonitorMattermostOpts = {}
|
||||
});
|
||||
const draftPreviewEnabled = account.streamingMode !== "off";
|
||||
const draftToolProgressEnabled = shouldUpdateMattermostDraftToolProgress(account);
|
||||
const suppressDefaultToolProgressMessages =
|
||||
shouldSuppressMattermostDefaultToolProgressMessages(account);
|
||||
const draftStream = draftPreviewEnabled
|
||||
? createMattermostDraftStream({
|
||||
client,
|
||||
@@ -1844,6 +1852,9 @@ export async function monitorMattermostProvider(opts: MonitorMattermostOpts = {}
|
||||
replyOptions: {
|
||||
...replyOptions,
|
||||
disableBlockStreaming: true,
|
||||
...(suppressDefaultToolProgressMessages
|
||||
? { suppressDefaultToolProgressMessages: true }
|
||||
: {}),
|
||||
onModelSelected,
|
||||
onPartialReply: (payload) => {
|
||||
if (account.streamingMode !== "progress") {
|
||||
|
||||
Reference in New Issue
Block a user