Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): streamed replies are no longer rescanned from the top #19990

ClosedEmanuelMedinaAraujo(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/19990/headopened View on GitHub

Showing 2 changed files with 134 additions and 21 deletions.

x
0 of 2 viewed, 2 left
40 additions and 0 deletionsapps/server/src/orchestration-v2/assistantStreaming.test.tsModified
View file
@@ -148,3 +148,43 @@
rest: "Next",
});
});
+​
+it("delivers the same boundaries when resuming a streaming scan as when rescanning", () => {
+ const fixture = [
+ "**Plan**\n",
+ "First paragraph runs on\nacross lines.\n\n",
+ "- one\n- two\n 1. nested\n",
+ "\t+ tab item \r\n3)\t \r\n12. ordered\n",
+ "# Heading\n",
+ "Body under heading.\n\n",
+ " ```ts\n const a = 1;\n\n ```\n",
+ "~~~\nnot ``` a close\n~~~~\n",
+ "Tail without newline",
+ ].join("");
+ const filter = makeAssistantStreamingFilter("paragraph");
+ let delivered = "";
+ // Each update is past the 400ms window, so every prefix is scanned.
+ for (let end = 1; end <= fixture.length; end += 1) {
+ const text = fixture.slice(0, end);
+ const { ready } = splitBufferedAssistantText(text);
+ const result = filter(message(text), end * 1_000);
+ if (ready && ready !== delivered) {
+ expect(result).toMatchObject({ message: { text: ready } });
+ delivered = ready;
+ } else {
+ expect(result).toBeNull();
+ }