fix(channels): skip empty progress drafts

This commit is contained in:
Vincent Koc
2026-05-03 16:44:09 -07:00
parent d609859a8b
commit d2ba09b301
5 changed files with 71 additions and 21 deletions

View File

@@ -2794,6 +2794,24 @@ describe("matrix monitor handler draft streaming", () => {
await finish();
});
it("does not create a blank Matrix progress draft when label and lines are disabled", async () => {
const { dispatch } = createStreamingHarness({
streaming: "progress",
previewToolProgressEnabled: false,
accountConfig: {
streaming: { mode: "progress", progress: { label: false, toolProgress: false } },
} as never,
});
const { opts, finish } = await dispatch();
await opts.onItemEvent?.({ progressText: "tool one" });
await opts.onItemEvent?.({ progressText: "tool two" });
expect(opts.suppressDefaultToolProgressMessages).toBe(true);
expect(sendSingleTextMessageMatrixMock).not.toHaveBeenCalled();
await finish();
});
it("keeps partial preview-first finalization on the existing draft when text is unchanged", async () => {
const { dispatch, redactEventMock } = createStreamingHarness({
blockStreamingEnabled: true,

View File

@@ -1504,15 +1504,17 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
if (!draftStream || !progressDraftStreaming) {
return;
}
draftStream.update(
formatChannelProgressDraftText({
entry: progressConfigEntry,
lines: previewToolProgressLines,
seed: progressSeed,
formatLine: formatMatrixToolProgressMarkdownCode,
bullet: "-",
}),
);
const previewText = formatChannelProgressDraftText({
entry: progressConfigEntry,
lines: previewToolProgressLines,
seed: progressSeed,
formatLine: formatMatrixToolProgressMarkdownCode,
bullet: "-",
});
if (!previewText) {
return;
}
draftStream.update(previewText);
};
const progressDraftGate = createChannelProgressDraftGate({
onStart: renderProgressDraft,