Skip to content

Commit 1c4a18d

Browse files
fix(feishu): send full streaming card content
1 parent 53a7545 commit 1c4a18d

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

extensions/feishu/src/streaming-card.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ describe("FeishuStreamingSession", () => {
180180

181181
expect(updateBodies).toHaveLength(1);
182182
expect(JSON.parse(updateBodies[0] ?? "{}")).toEqual({
183-
content: " small",
183+
content: "hello small",
184184
sequence: 2,
185185
uuid: "s_card_1_2",
186186
});
@@ -212,13 +212,13 @@ describe("FeishuStreamingSession", () => {
212212

213213
expect(updateBodies).toHaveLength(1);
214214
expect(JSON.parse(updateBodies[0] ?? "{}")).toEqual({
215-
content: "!",
215+
content: "hello!",
216216
sequence: 2,
217217
uuid: "s_card_2_2",
218218
});
219219
});
220220

221-
it("retries unsent suffix content after a failed delta update", async () => {
221+
it("retries full card content after a failed content update", async () => {
222222
vi.useFakeTimers();
223223
vi.setSystemTime(3_000);
224224
const updateBodies: string[] = [];
@@ -245,18 +245,18 @@ describe("FeishuStreamingSession", () => {
245245

246246
expect(updateBodies).toHaveLength(2);
247247
expect(JSON.parse(updateBodies[0] ?? "{}")).toEqual({
248-
content: " world",
248+
content: "hello world",
249249
sequence: 2,
250250
uuid: "s_card_3_2",
251251
});
252252
expect(JSON.parse(updateBodies[1] ?? "{}")).toEqual({
253-
content: " world!",
253+
content: "hello world!",
254254
sequence: 3,
255255
uuid: "s_card_3_3",
256256
});
257257
});
258258

259-
it("retries unsent suffix content after a non-OK delta update", async () => {
259+
it("retries full card content after a non-OK content update", async () => {
260260
vi.useFakeTimers();
261261
vi.setSystemTime(3_500);
262262
const updateBodies: string[] = [];
@@ -283,12 +283,12 @@ describe("FeishuStreamingSession", () => {
283283

284284
expect(updateBodies).toHaveLength(2);
285285
expect(JSON.parse(updateBodies[0] ?? "{}")).toEqual({
286-
content: " world",
286+
content: "hello world",
287287
sequence: 2,
288288
uuid: "s_card_5_2",
289289
});
290290
expect(JSON.parse(updateBodies[1] ?? "{}")).toEqual({
291-
content: " world!",
291+
content: "hello world!",
292292
sequence: 3,
293293
uuid: "s_card_5_3",
294294
});

extensions/feishu/src/streaming-card.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,9 @@ function resolveStreamingCardAppendContent(previousText: string, nextText: strin
158158
if (!nextText || nextText === previousText) {
159159
return "";
160160
}
161-
if (!previousText) {
162-
return nextText;
163-
}
164-
return nextText.startsWith(previousText) ? nextText.slice(previousText.length) : nextText;
161+
// The CardKit content endpoint overwrites the markdown element body, so send
162+
// the complete visible text instead of only the newly generated suffix.
163+
return nextText;
165164
}
166165

167166
export function mergeStreamingText(

0 commit comments

Comments
 (0)