Skip to content

Commit 48c33c3

Browse files
committed
fix(telegram): scope assistant preview config
1 parent 30c7bdd commit 48c33c3

9 files changed

Lines changed: 68 additions & 34 deletions

File tree

docs/channels/telegram.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ curl "https://api.telegram.org/bot<bot_token>/getUpdates"
318318
- `progress` keeps one editable status draft for tool progress, clears it at completion, and sends the final answer as a normal message
319319
- `streaming.preview.toolProgress` controls whether tool/progress updates reuse the same edited preview message (default: `true` when preview streaming is active)
320320
- `streaming.preview.commandText` controls command/exec detail inside those tool-progress lines: `raw` (default, preserves released behavior) or `status` (tool label only)
321+
- `streaming.progress.assistantPreview` (default: `false`) opts into a second temporary draft for assistant answer partials while the progress/status draft stays visible
321322
- `streaming.progress.commentary` (default: `false`) opts into assistant commentary/preamble text in the temporary progress draft
322323
- legacy `channels.telegram.streamMode`, boolean `streaming` values, and retired native draft preview keys are detected; run `openclaw doctor --fix` to migrate them to current streaming config
323324

@@ -375,6 +376,23 @@ curl "https://api.telegram.org/bot<bot_token>/getUpdates"
375376
}
376377
```
377378

379+
To keep the progress draft visible while answer text streams in a separate temporary assistant preview, opt into the Telegram-only assistant preview lane:
380+
381+
```json
382+
{
383+
"channels": {
384+
"telegram": {
385+
"streaming": {
386+
"mode": "progress",
387+
"progress": {
388+
"assistantPreview": true
389+
}
390+
}
391+
}
392+
}
393+
}
394+
```
395+
378396
Use `streaming.mode: "off"` only when you want final-only delivery: Telegram preview edits are disabled and generic tool/progress chatter is suppressed instead of being sent as standalone status messages. Approval prompts, media payloads, and errors still route through normal final delivery. Use `streaming.preview.toolProgress: false` when you only want to keep answer preview edits while hiding the tool-progress status lines.
379397

380398
<Note>

extensions/telegram/src/bot-message-dispatch.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2681,9 +2681,11 @@ describe("dispatchTelegramMessage draft streaming", () => {
26812681
},
26822682
});
26832683

2684-
expect(progressDraftStream.update).toHaveBeenCalledWith("Shelling\n\n`🛠️ Exec`");
2685-
expect(progressDraftStream.update).not.toHaveBeenCalledWith(
2686-
"I am checking the logs and will report back shortly.",
2684+
expect(progressDraftStream.updatePreview).toHaveBeenCalledWith(
2685+
expect.objectContaining({ text: "Shelling\n\n`🛠️ Exec`" }),
2686+
);
2687+
expect(progressDraftStream.updatePreview).not.toHaveBeenCalledWith(
2688+
expect.objectContaining({ text: "I am checking the logs and will report back shortly." }),
26872689
);
26882690
expect(assistantDraftStream.update).toHaveBeenCalledWith(
26892691
"I am checking the logs and will report back shortly.",

extensions/telegram/src/config-ui-hints.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ export const telegramChannelConfigUiHints = {
106106
label: "Telegram Progress Tool Lines",
107107
help: "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery.",
108108
},
109+
"streaming.progress.assistantPreview": {
110+
label: "Telegram Assistant Preview Lane",
111+
help: "In progress mode, stream assistant answer partials in a separate temporary draft while keeping the progress/status draft visible. Default: false.",
112+
},
109113
"streaming.progress.commandText": {
110114
label: "Telegram Progress Command Text",
111115
help: 'Command/exec detail in progress draft lines: "raw" preserves released behavior; "status" shows only the tool label.',

extensions/telegram/src/lane-delivery.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function createHarness(params?: {
4646
lastPartialText: "",
4747
hasStreamedMessage: false,
4848
finalized: false,
49+
activeChunkIndex: 0,
4950
},
5051
};
5152
const sendPayload = vi.fn().mockResolvedValue(true);
@@ -234,10 +235,7 @@ describe("createLaneTextDeliverer", () => {
234235
expect(answer.update).toHaveBeenCalledWith(previousBlock);
235236
expect(answer.update).not.toHaveBeenCalledWith(nextAssistantBlock);
236237
expect(harness.clearDraftLane).toHaveBeenCalledTimes(1);
237-
expect(harness.sendPayload).toHaveBeenCalledWith(
238-
{ text: previousBlock },
239-
{ durable: false },
240-
);
238+
expect(harness.sendPayload).toHaveBeenCalledWith({ text: previousBlock }, { durable: false });
241239
expect(harness.sendPayload).not.toHaveBeenCalledWith(
242240
{ text: nextAssistantBlock },
243241
expect.anything(),

src/channels/streaming.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,8 @@ export function resolveChannelProgressDraftAssistantPreview(
778778
defaultValue = false,
779779
): boolean {
780780
const config = getChannelStreamingConfigObject(entry);
781-
return asBoolean(config?.progress?.assistantPreview) ?? defaultValue;
781+
const progress = asObjectRecord(config?.progress);
782+
return asBoolean(progress?.assistantPreview) ?? defaultValue;
782783
}
783784

784785
export function resolveChannelStreamingProgressCommentary(

src/config/bundled-channel-config-metadata.generated.ts

Lines changed: 18 additions & 18 deletions
Large diffs are not rendered by default.

src/config/types.base.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ export type ChannelStreamingProgressConfig = {
6666
render?: "text" | "rich";
6767
/** Include compact tool/task progress in the draft. Default: true. */
6868
toolProgress?: boolean;
69-
/**
70-
* While mode="progress", also stream assistant answer partials in a separate
71-
* transient preview message instead of replacing the progress/status draft.
72-
* Default: false.
73-
*/
74-
assistantPreview?: boolean;
7569
/** Command/exec progress detail in the draft. "raw" preserves released behavior; "status" shows only the tool label. Default: "raw". */
7670
commandText?: ChannelStreamingCommandTextMode;
7771
/** Include assistant commentary/preamble text in the progress draft. Default: false. */

src/config/types.telegram.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Defines Telegram channel configuration types.
22
import type {
33
ChannelPreviewStreamingConfig,
4+
ChannelStreamingProgressConfig,
45
ChannelStreamingPreviewConfig,
56
ContextVisibilityMode,
67
DmPolicy,
@@ -68,8 +69,21 @@ export type TelegramInlineButtonsScope = "off" | "dm" | "group" | "all" | "allow
6869
export type TelegramStreamingMode = "off" | "partial" | "block" | "progress";
6970
export type TelegramExecApprovalTarget = "dm" | "channel" | "both";
7071

71-
export type TelegramPreviewStreamingConfig = Omit<ChannelPreviewStreamingConfig, "preview"> & {
72+
export type TelegramStreamingProgressConfig = ChannelStreamingProgressConfig & {
73+
/**
74+
* While mode="progress", also stream assistant answer partials in a separate
75+
* transient preview message instead of replacing the progress/status draft.
76+
* Default: false.
77+
*/
78+
assistantPreview?: boolean;
79+
};
80+
81+
export type TelegramPreviewStreamingConfig = Omit<
82+
ChannelPreviewStreamingConfig,
83+
"preview" | "progress"
84+
> & {
7285
preview?: ChannelStreamingPreviewConfig;
86+
progress?: TelegramStreamingProgressConfig;
7387
};
7488

7589
export type TelegramExecApprovalConfig = {

src/config/zod-schema.providers-core.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,13 @@ const ChannelStreamingProgressSchema = z
9797
maxLineChars: z.number().int().positive().optional(),
9898
render: z.enum(["text", "rich"]).optional(),
9999
toolProgress: z.boolean().optional(),
100-
assistantPreview: z.boolean().optional(),
101100
commandText: z.enum(["raw", "status"]).optional(),
102101
commentary: z.boolean().optional(),
103102
})
104103
.strict();
104+
const TelegramStreamingProgressSchema = ChannelStreamingProgressSchema.extend({
105+
assistantPreview: z.boolean().optional(),
106+
}).strict();
105107
const SlackStreamingProgressSchema = ChannelStreamingProgressSchema.extend({
106108
nativeTaskCards: z.boolean().optional(),
107109
}).strict();
@@ -123,6 +125,7 @@ const ChannelPreviewStreamingConfigSchema = z
123125
.strict();
124126
const TelegramPreviewStreamingConfigSchema = ChannelPreviewStreamingConfigSchema.extend({
125127
preview: ChannelStreamingPreviewSchema.optional(),
128+
progress: TelegramStreamingProgressSchema.optional(),
126129
}).strict();
127130
const DiscordPreviewStreamingConfigSchema = ChannelPreviewStreamingConfigSchema;
128131
const SlackStreamingConfigSchema = ChannelPreviewStreamingConfigSchema.extend({

0 commit comments

Comments
 (0)