Skip to content

Commit faed382

Browse files
committed
feat(slack): add compact progress style
1 parent 4970ed2 commit faed382

15 files changed

Lines changed: 172 additions & 29 deletions

‎docs/channels/slack.md‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ The default scope (`"group-mentions"`) does not fire ack reactions in direct mes
14951495
- `off`: disable live preview streaming.
14961496
- `partial`: replace preview text with the latest partial output. Set this to restore the previous default behavior.
14971497
- `block`: append chunked preview updates.
1498-
- `progress` (default): maintain one live Block Kit session card in the thread while work runs, finalize that card in place, and send the assistant's final text as a separate message.
1498+
- `progress` (default): show structured progress in one native task card when Slack supports it, with a Block Kit session-card fallback.
14991499
- `streaming.preview.toolProgress`: when draft preview is active, route tool/progress updates into the same edited preview message (default: `true`). Set `false` to keep separate tool/progress messages.
15001500
- `streaming.preview.commandText` / `streaming.progress.commandText`: `status` keeps compact tool-progress lines while hiding raw command/exec text (default); set `raw` to opt into command text.
15011501

@@ -1523,6 +1523,28 @@ In `progress` mode, Slack's native agent card is the default: the whole turn is
15231523

15241524
Set `channels.slack.streaming.progress.nativeTaskCards` to `false` to fall back to the Block Kit session card, which posts a separate message showing title, narration, plan checklist, recent activity, tool/file totals, and elapsed time, and finalizes to success or error.
15251525

1526+
Set `channels.slack.streaming.progress.style` to `"compact"` for one plain-text progress draft instead of either card surface. With the other progress controls below, commentary appears as italic text only, and an eligible final text answer replaces that same Slack message:
1527+
1528+
```json5
1529+
{
1530+
channels: {
1531+
slack: {
1532+
streaming: {
1533+
mode: "progress",
1534+
progress: {
1535+
style: "compact",
1536+
label: false,
1537+
commentary: true,
1538+
toolProgress: false,
1539+
},
1540+
},
1541+
},
1542+
},
1543+
}
1544+
```
1545+
1546+
Slack still uses normal final delivery when the reply cannot safely replace the draft, including media, errors, oversized text, split block payloads, custom outbound identity, or an edit failure.
1547+
15261548
Both surfaces link the session with **Open in OpenClaw**, but only when that link can work: `gateway.publicOrigin` must be set (the externally reachable Gateway origin) and the Control UI must not be disabled via `gateway.controlUi.enabled: false`. Installations that leave `publicOrigin` unset — where there is no way to reach OpenClaw from Slack — get no link rather than a dead one. If the Control UI is served below a path prefix, also set `gateway.controlUi.basePath`.
15271549

15281550
- A reply thread must be available for native text streaming and Slack assistant thread status to appear. Thread selection still follows `replyToMode`.
@@ -1548,7 +1570,7 @@ Use draft preview instead of Slack native text streaming:
15481570
}
15491571
```
15501572

1551-
Opt in to Slack native progress task cards:
1573+
Select Slack native progress task cards explicitly:
15521574

15531575
```json5
15541576
{

‎docs/concepts/progress-drafts.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ the final answer, except for the label if one is configured.
392392
| Discord | Send one message, then edit it. | `progress` is explicit opt-in; the status draft is deleted after the final answer lands. |
393393
| Matrix | Send one event, then edit it. | Account-level streaming config controls account-level drafts. |
394394
| Microsoft Teams | Native Teams stream in personal chats. | `streaming.mode: "block"` maps to Teams block delivery instead. |
395-
| Slack | Native stream or editable draft post. | Needs a reply thread target; top-level DMs without one still get draft preview posts and edits. |
395+
| Slack | Native stream or editable draft post. | Card style is the default; `progress.style: "compact"` uses one text draft that an eligible final answer replaces. |
396396
| Telegram | Send one message, then edit it. | If a message lands between the progress draft and the answer, the draft reposts below it (post-new-then-delete-old) instead of scroll-jumping the client. |
397397
| Mattermost | Editable draft post. | `block` mode rotates between completed text and tool-activity posts; other modes fold tool activity into the same draft-style post. |
398398

@@ -410,6 +410,8 @@ When the final answer is ready, OpenClaw tries to keep the chat clean:
410410
visible record of the failed turn.
411411
- If the draft can safely become the final answer (`partial`/`block` modes),
412412
OpenClaw edits it in place.
413+
- Slack's compact progress style also promotes the progress draft into an
414+
eligible final text answer by editing that message in place.
413415
- If the channel uses native progress streaming, OpenClaw finalizes that
414416
stream when the native transport accepts the final text.
415417
- Otherwise (media, an approval prompt, an explicit reply target, too many
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{"seq":1,"at":0,"dir":"in","kind":"reply-start"}
2+
{"seq":2,"at":0,"dir":"out","kind":"assistant.threads.setStatus","data":{"payload":{"channel_id":"C0TRACE","status":"is typing...","thread_ts":"ts#1"},"result":{"ok":true},"target":"C0TRACE/ts#1"}}
3+
{"seq":3,"at":0,"dir":"in","kind":"partial","data":{"text":"Checking the current Slack behavior."}}
4+
{"seq":4,"at":0,"dir":"out","kind":"chat.postMessage","data":{"payload":{"channel":"C0TRACE","text":"_Checking the current Slack behavior._","thread_ts":"ts#1","unfurl_links":false},"result":{"ts":"ts#2"},"target":"C0TRACE"}}
5+
{"seq":5,"at":2000,"dir":"in","kind":"final","data":{"text":"Compact Slack progress is ready."}}
6+
{"seq":6,"at":2000,"dir":"out","kind":"chat.update","data":{"payload":{"channel":"C0TRACE","text":"Compact Slack progress is ready.","ts":"ts#2"},"result":{"ok":true},"target":"ts#2"}}
7+
{"seq":7,"at":2000,"dir":"in","kind":"idle"}
8+
{"seq":8,"at":2000,"dir":"out","kind":"assistant.threads.setStatus","data":{"payload":{"channel_id":"C0TRACE","status":"","thread_ts":"ts#1"},"result":{"ok":true},"target":"C0TRACE/ts#1"}}

‎extensions/slack/src/config-schema.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ function expectSlackConfigKeyRejected(config: unknown, key: string) {
3333
}
3434

3535
describe("slack config schema", () => {
36+
it("accepts compact progress style", () => {
37+
expectSlackConfigValid({
38+
streaming: {
39+
mode: "progress",
40+
progress: { style: "compact" },
41+
},
42+
});
43+
expectSlackConfigIssue(
44+
{ streaming: { mode: "progress", progress: { style: "plain" } } },
45+
"streaming.progress.style",
46+
);
47+
});
48+
3649
it("accepts capability arrays and rejects retired interactive reply objects", () => {
3750
expectSlackConfigValid({ capabilities: ["presentation"] });
3851
expectSlackConfigIssue({ capabilities: { interactiveReplies: true } }, "capabilities");

‎extensions/slack/src/config-schema.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const SecretInputSchema = buildSecretInputSchema();
2727
const SLACK_PRESENCE_EVENT_PROMPT_MAX_CHARS = 20_000;
2828

2929
const SlackStreamingProgressSchema = ChannelStreamingProgressSchema.extend({
30+
style: z.enum(["card", "compact"]).optional(),
3031
nativeTaskCards: z.boolean().optional(),
3132
}).strict();
3233
const SlackStreamingConfigSchema = ChannelPreviewStreamingConfigSchema.extend({

‎extensions/slack/src/config-ui-hints.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ export const slackChannelConfigUiHints = {
3434
"Show tool/progress activity in the live draft preview message (default: true). Set false to hide interim tool updates while the draft preview stays active.",
3535
"preview.commandText":
3636
'Command/exec detail in preview tool-progress lines: "status" is the safe default; "raw" opts into command text.',
37+
"progress.style":
38+
'Slack progress presentation: "card" (default) uses structured task/session cards; "compact" keeps one editable text draft that the final answer replaces in place when Slack can safely edit it.',
3739
"progress.nativeTaskCards":
38-
'Slack native task-card progress updates when channels.slack.streaming.mode="progress" and streaming.nativeTransport is enabled. Set false to fall back to the Block Kit progress card. Default: true.',
40+
'Slack native task-card progress updates when channels.slack.streaming.mode="progress", progress.style="card", and streaming.nativeTransport is enabled. Set false to fall back to the Block Kit progress card. Default: true.',
3941
},
4042
progress: { labels: "openclaw" },
4143
}),

‎extensions/slack/src/delivery-trace.test.ts‎

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ type SlackTraceScenarioName =
181181
| "final-blocks-and-text"
182182
| "cancel-mid-stream"
183183
| "preview-edit-fallback"
184+
| "progress-compact-commentary"
184185
| "progress-session-card"
185186
| "progress-native-unified";
186187

@@ -209,6 +210,8 @@ const SHORT_FINAL_TEXT = "All checks passed. Ship it.";
209210
const PREVIEW_PARTIAL_ONE = "Compiling the changelog";
210211
const PREVIEW_PARTIAL_TWO = "Compiling the changelog for 2026.1.0.";
211212
const PREVIEW_FINAL_TEXT = "Compiling the changelog for 2026.1.0.\n\nDone: 12 entries.";
213+
const COMPACT_COMMENTARY_TEXT = "Checking the current Slack behavior.";
214+
const COMPACT_FINAL_TEXT = "Compact Slack progress is ready.";
212215

213216
const BLOCKS_FINAL_TEXT = "Release 2026.1.0 is ready to ship.";
214217
// Portable presentation actions; slack renders them as Block Kit and must
@@ -276,6 +279,13 @@ const slackTraceScenarios: Record<SlackTraceScenarioName, readonly DeliveryTrace
276279
{ kind: "final", text: PREVIEW_FINAL_TEXT },
277280
{ kind: "idle" },
278281
],
282+
"progress-compact-commentary": [
283+
{ kind: "reply-start" },
284+
{ kind: "partial", text: COMPACT_COMMENTARY_TEXT },
285+
{ kind: "advance", ms: 2000 },
286+
{ kind: "final", text: COMPACT_FINAL_TEXT },
287+
{ kind: "idle" },
288+
],
279289
"progress-session-card": [
280290
{ kind: "reply-start" },
281291
{ kind: "tool-progress", name: "read", phase: "start" },
@@ -460,6 +470,7 @@ function createRecordingSlackClient(): Record<string, unknown> {
460470
}
461471

462472
function createPreparedTraceMessage(scenario: SlackTraceScenarioName): PreparedSlackMessage {
473+
const compactProgress = scenario === "progress-compact-commentary";
463474
const progressCard = scenario === "progress-session-card";
464475
const nativeProgress = scenario === "progress-native-unified";
465476
const cfg = {
@@ -520,19 +531,31 @@ function createPreparedTraceMessage(scenario: SlackTraceScenarioName): PreparedS
520531
},
521532
account: {
522533
accountId: "default",
523-
config: progressCard
524-
? // Native task cards are the progress default; this scenario owns the
525-
// Block Kit opt-out path.
526-
{ streaming: { progress: { nativeTaskCards: false } } }
527-
: nativeProgress
528-
? // Empty progress config on purpose: proves the shipped default.
529-
{ streaming: { mode: "progress" } }
530-
: {
531-
streaming: {
532-
mode: "partial",
533-
nativeTransport: NATIVE_SCENARIOS.has(scenario),
534+
config: compactProgress
535+
? {
536+
streaming: {
537+
mode: "progress",
538+
progress: {
539+
style: "compact",
540+
label: false,
541+
commentary: true,
542+
toolProgress: false,
534543
},
535544
},
545+
}
546+
: progressCard
547+
? // Native task cards are the progress default; this scenario owns the
548+
// Block Kit opt-out path.
549+
{ streaming: { progress: { nativeTaskCards: false } } }
550+
: nativeProgress
551+
? // Empty progress config on purpose: proves the shipped default.
552+
{ streaming: { mode: "progress" } }
553+
: {
554+
streaming: {
555+
mode: "partial",
556+
nativeTransport: NATIVE_SCENARIOS.has(scenario),
557+
},
558+
},
536559
},
537560
message: {
538561
type: "message",
@@ -611,7 +634,13 @@ async function setupSlackTrace(
611634
case "partial":
612635
// Present only on the draft-preview tier; native streaming leaves
613636
// onPartialReply undefined and partials stay IN-only script context.
614-
if (scenario === "progress-native-unified") {
637+
if (scenario === "progress-compact-commentary") {
638+
await turn.replyOptions.onItemEvent?.({
639+
kind: "preamble",
640+
itemId: "preamble-1",
641+
progressText: step.text,
642+
});
643+
} else if (scenario === "progress-native-unified") {
615644
await turn.replyOptions.onItemEvent?.({
616645
kind: "preamble",
617646
itemId: "preamble-1",

‎extensions/slack/src/monitor/message-handler/dispatch-helpers.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,21 @@ export function resolveExplicitSlackProgressTitle(
8484
return trimmed && trimmed.toLowerCase() !== "auto" ? trimmed : undefined;
8585
}
8686

87+
export function resolveSlackProgressStyle(
88+
entry: Parameters<typeof resolveChannelProgressDraftConfig>[0],
89+
): "card" | "compact" {
90+
const style = Reflect.get(resolveChannelProgressDraftConfig(entry), "style");
91+
return style === "compact" ? "compact" : "card";
92+
}
93+
8794
// Slack's native agent card is the default progress surface; operators opt out
8895
// with an explicit `false`, which falls back to the Block Kit progress card.
8996
export function resolveSlackNativeProgressTaskCards(
9097
entry: Parameters<typeof resolveChannelProgressDraftConfig>[0],
9198
): boolean {
99+
if (resolveSlackProgressStyle(entry) === "compact") {
100+
return false;
101+
}
92102
const streaming = entry?.streaming;
93103
if (!streaming || typeof streaming !== "object" || Array.isArray(streaming)) {
94104
return true;

‎extensions/slack/src/monitor/message-handler/dispatch-progress.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import {
2525
} from "../../progress-blocks.js";
2626
import { applyAppendOnlyStreamUpdate } from "../../stream-mode.js";
2727
import { appendSlackStream, stopSlackStream } from "../../streaming.js";
28-
import { resolveExplicitSlackProgressTitle } from "./dispatch-helpers.js";
28+
import {
29+
resolveExplicitSlackProgressTitle,
30+
resolveSlackProgressStyle,
31+
} from "./dispatch-helpers.js";
2932
import {
3033
createSlackDraftProgressCardRuntime,
3134
formatSlackProgressDraftLine,
@@ -127,7 +130,8 @@ export function createSlackProgressRuntime(runtimeParams: {
127130
};
128131
const progressWorkCounter = createChannelProgressWorkCounter();
129132
const progressSeed = `${account.accountId}:${message.channel}`;
130-
const useDraftProgressCard = Boolean(draftStream) && isProgressMode;
133+
const useDraftProgressCard =
134+
Boolean(draftStream) && isProgressMode && resolveSlackProgressStyle(account.config) === "card";
131135
const explicitProgressTitle = resolveExplicitSlackProgressTitle(account.config);
132136
const progressDraftMaxLineChars = resolveChannelProgressDraftMaxLineChars(account.config);
133137
const progressCard = createSlackDraftProgressCardRuntime({

‎extensions/slack/src/monitor/message-handler/dispatch.preview-fallback.test.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4147,6 +4147,48 @@ describe("dispatchPreparedSlackMessage preview fallback", () => {
41474147
expect(draftUpdateTexts(draftStream).join("\n")).not.toMatch(/Working|💬|•|⏱️/u);
41484148
});
41494149

4150+
it("replaces compact commentary progress with the final answer", async () => {
4151+
const draftStream = createDraftStreamStub();
4152+
createSlackDraftStreamMock.mockReturnValueOnce(draftStream);
4153+
finalizeSlackPreviewEditMock.mockResolvedValueOnce(undefined);
4154+
mockedSlackStreamingMode = "progress";
4155+
mockedSlackDraftMode = "status_final";
4156+
mockedDispatchSequence = [{ kind: "final", payload: { text: FINAL_REPLY_TEXT } }];
4157+
mockedReplyOptionEvents = [
4158+
{
4159+
kind: "item",
4160+
itemKind: "preamble",
4161+
itemId: "preamble-1",
4162+
progressText: "Checking the current Slack behavior.",
4163+
},
4164+
];
4165+
4166+
await dispatchPreparedSlackMessage(
4167+
createPreparedSlackMessage({
4168+
accountConfig: {
4169+
streaming: {
4170+
mode: "progress",
4171+
progress: {
4172+
style: "compact",
4173+
label: false,
4174+
commentary: true,
4175+
toolProgress: false,
4176+
},
4177+
},
4178+
},
4179+
}),
4180+
);
4181+
4182+
expectLastDraftUpdateText(draftStream, "_Checking the current Slack behavior._");
4183+
expectMockCallArgFields(finalizeSlackPreviewEditMock, 0, "compact progress final edit", {
4184+
channelId: "C123",
4185+
messageId: "171234.567",
4186+
text: FINAL_REPLY_TEXT,
4187+
});
4188+
expect(deliverRepliesMock).not.toHaveBeenCalled();
4189+
expect(draftStream.clear).not.toHaveBeenCalled();
4190+
});
4191+
41504192
it("uses the enterprise event client for Slack commentary drafts", async () => {
41514193
const draftStream = createDraftStreamStub();
41524194
createSlackDraftStreamMock.mockReturnValueOnce(draftStream);

0 commit comments

Comments
 (0)