Skip to content

Commit c5299af

Browse files
committed
fix(plugin-sdk): gate assistant preview to progress mode
1 parent 7541abe commit c5299af

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/channels/streaming.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,9 @@ export function resolveChannelProgressDraftAssistantPreview(
816816
entry: StreamingCompatEntry | null | undefined,
817817
defaultValue = false,
818818
): boolean {
819+
if (resolveChannelPreviewStreamMode(entry, "partial") !== "progress") {
820+
return false;
821+
}
819822
const config = getChannelStreamingConfigObject(entry);
820823
const progress = asObjectRecord(config?.progress);
821824
return asBoolean(progress?.assistantPreview) ?? defaultValue;

src/plugin-sdk/channel-streaming.test.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ describe("channel-streaming", () => {
121121
).toBe(false);
122122
});
123123

124-
it("defaults progress assistant preview off unless explicitly enabled", () => {
124+
it("enables progress assistant preview only for progress-mode drafts", () => {
125125
expect(resolveChannelProgressDraftAssistantPreview({ streaming: { mode: "progress" } })).toBe(
126126
false,
127127
);
@@ -130,6 +130,21 @@ describe("channel-streaming", () => {
130130
streaming: { mode: "progress", progress: { assistantPreview: true } },
131131
}),
132132
).toBe(true);
133+
expect(
134+
resolveChannelProgressDraftAssistantPreview({
135+
streaming: { mode: "partial", progress: { assistantPreview: true } },
136+
}),
137+
).toBe(false);
138+
expect(
139+
resolveChannelProgressDraftAssistantPreview({
140+
streaming: { mode: "block", progress: { assistantPreview: true } },
141+
}),
142+
).toBe(false);
143+
expect(
144+
resolveChannelProgressDraftAssistantPreview({
145+
streaming: { mode: "off", progress: { assistantPreview: true } },
146+
}),
147+
).toBe(false);
133148
});
134149

135150
it("falls back to legacy flat fields when the canonical object is absent", () => {

0 commit comments

Comments
 (0)