Skip to content

Commit

Permalink
[breadboard] Don't delete completed chunk.
Browse files Browse the repository at this point in the history
- **Don't delete completed chunk.**
- **Update versions.**
- **docs(changeset): Don't delete completed chunk.**
  • Loading branch information
dglazkov authored Dec 21, 2024
1 parent f6c31d3 commit e4521d9
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .changeset/twelve-mails-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@breadboard-ai/visual-editor": patch
"@breadboard-ai/board-server": patch
"@google-labs/breadboard": patch
---

Don't delete completed chunk.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/board-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"registry": "https://wombat-dressing-room.appspot.com"
},
"private": true,
"version": "0.10.0",
"version": "0.10.1",
"description": "Board Server",
"main": "./dist/server/index.js",
"exports": "./dist/server/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/breadboard-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"dependencies": {
"@breadboard-ai/build": "0.11.0",
"@breadboard-ai/import": "0.1.13",
"@breadboard-ai/visual-editor": "1.24.1",
"@breadboard-ai/visual-editor": "1.24.2",
"@google-labs/breadboard": "^0.30.0",
"@google-labs/core-kit": "^0.17.0",
"@google-labs/template-kit": "^0.3.15",
Expand Down
10 changes: 3 additions & 7 deletions packages/breadboard/src/remote/chunk-repair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ export const chunkRepairTransform = () => {
// the two chunks likely have a complete chunk somewhere in the middle
// (or not), yet there's a broken left-over chunk at the end.
return new TransformStream<string, string>({
transform(chunk, controller) {
transform(incomingChunk, controller) {
const enqueue = (chunk: string) => {
controller.enqueue(`${chunk}\n\n`);
};

const missingEndMarker = !chunk.endsWith("\n\n");
const chunks = chunk.split("\n\n");
const missingEndMarker = !incomingChunk.endsWith("\n\n");
const chunks = incomingChunk.split("\n\n");
if (!missingEndMarker) {
chunks.pop();
}
Expand Down Expand Up @@ -69,10 +69,6 @@ export const chunkRepairTransform = () => {
if (brokenChunk !== null) {
// Variant 1: x | o
const completeChunks = getCompleteChunks(brokenChunk, chunk);
console.assert(
completeChunks.pop() === "",
"Last complete chunk must be an empty string"
);
for (const completeChunk of completeChunks) {
enqueue(completeChunk);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/breadboard/tests/node/http/chunk-repair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ const repair = async (incoming: string[], repaired: string[]) => {
};

describe("Chunk Repair Transform", async () => {
test.skip("nice chunks", async () => {
test("nice chunks", async () => {
await repair(["foo\n\n", "bar\n\n"], ["foo\n\n", "bar\n\n"]);
});
test.skip("broken chunks", async () => {
test("broken chunks", async () => {
await repair(["foo\n", "\nbar\n\n"], ["foo\n\n", "bar\n\n"]);
await repair(["foo\n\nba", "r\n\n"], ["foo\n\n", "bar\n\n"]);
await repair(
Expand Down
2 changes: 1 addition & 1 deletion packages/visual-editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@breadboard-ai/visual-editor",
"version": "1.24.1",
"version": "1.24.2",
"description": "The Visual Editor for Breadboard",
"main": "./build/index.js",
"exports": {
Expand Down

0 comments on commit e4521d9

Please sign in to comment.