mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 18:00:54 +00:00
fix(mattermost): share progress draft labels
This commit is contained in:
@@ -243,11 +243,17 @@ describe("createMattermostDraftStream", () => {
|
||||
});
|
||||
|
||||
describe("buildMattermostToolStatusText", () => {
|
||||
it("renders a status with the tool name", () => {
|
||||
expect(buildMattermostToolStatusText({ name: "read" })).toBe("Running `read`…");
|
||||
it("renders a status with the shared tool label", () => {
|
||||
expect(buildMattermostToolStatusText({ name: "read" })).toBe("📖 Read");
|
||||
});
|
||||
|
||||
it("falls back to a generic running tool status", () => {
|
||||
expect(buildMattermostToolStatusText({ name: "exec" })).toBe("Running `exec`…");
|
||||
it("honors raw exec detail mode", () => {
|
||||
expect(
|
||||
buildMattermostToolStatusText({
|
||||
name: "exec",
|
||||
args: { command: "pnpm test -- --watch=false" },
|
||||
detailMode: "raw",
|
||||
}),
|
||||
).toBe("🛠️ Exec: run tests, `pnpm test -- --watch=false`");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createFinalizableDraftLifecycle } from "openclaw/plugin-sdk/channel-lifecycle";
|
||||
import { formatChannelProgressDraftLine } from "openclaw/plugin-sdk/channel-streaming";
|
||||
import {
|
||||
createMattermostPost,
|
||||
deleteMattermostPost,
|
||||
@@ -31,9 +32,23 @@ function normalizeMattermostDraftText(text: string, maxChars: number): string {
|
||||
return `${trimmed.slice(0, Math.max(0, maxChars - 3)).trimEnd()}...`;
|
||||
}
|
||||
|
||||
export function buildMattermostToolStatusText(params: { name?: string; phase?: string }): string {
|
||||
const tool = params.name?.trim() ? ` \`${params.name.trim()}\`` : " tool";
|
||||
return `Running${tool}…`;
|
||||
export function buildMattermostToolStatusText(params: {
|
||||
name?: string;
|
||||
phase?: string;
|
||||
args?: Record<string, unknown>;
|
||||
detailMode?: "explain" | "raw";
|
||||
}): string {
|
||||
return (
|
||||
formatChannelProgressDraftLine(
|
||||
{
|
||||
event: "tool",
|
||||
name: params.name,
|
||||
phase: params.phase,
|
||||
args: params.args,
|
||||
},
|
||||
params.detailMode ? { detailMode: params.detailMode } : undefined,
|
||||
) ?? "Running tool..."
|
||||
);
|
||||
}
|
||||
|
||||
export function createMattermostDraftStream(params: {
|
||||
|
||||
Reference in New Issue
Block a user