@devries-cameron20 / t3code-1 / commits / ff8a831067
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(antigravity): accept UTF-16 text attachments with a BOM (#39456)

Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Simone committed Nov 20, 2026 at 02:41 UTC ff8a83106773936314e527f116255e66df426a1f
2 files changed +40 -27
apps/server/src/provider/acp/AntigravityAcpSupport.test.ts
+32 -25
@@ -324,31 +324,36 @@ it.layer(NodeServices.layer)("buildAntigravityPrompt", (it) => {
324 }),
325 );
326
327 - it.effect("embeds UTF-8 code from the selected environment and keeps the upload in place", () =>
328 - Effect.gen(function* () {
329 - const selectedEnvironment = yield* makeAttachmentFixture();
330 - const otherEnvironment = yield* makeAttachmentFixture();
331 - const source = ' const name = "caf\u00e9";\n';
332 - const upload = yield* selectedEnvironment.write(textAttachment, source);
333 - yield* otherEnvironment.write(textAttachment, "Different environment.");
334 - const prompt = yield* buildAntigravityPrompt({
335 - input: undefined,
336 - attachments: [textAttachment],
337 - resolveAttachmentPath: selectedEnvironment.resolve,
338 - promptCapabilities: { image: true, audio: true, embeddedContext: true },
339 - });
327 + it.effect.each(["utf8", "utf16le", "utf16be"] as const)(
328 + "embeds %s code from the selected environment and keeps the upload in place",
329 + (encoding) =>
330 + Effect.gen(function* () {
331 + const selectedEnvironment = yield* makeAttachmentFixture();
332 + const otherEnvironment = yield* makeAttachmentFixture();
333 + const source = ' const name = "caf\u00e9 🚀";\r\n';
334 + const bytes =
335 + encoding === "utf8" ? Buffer.from(source) : Buffer.from("\ufeff" + source, "utf16le");
336 + if (encoding === "utf16be") bytes.swap16();
337 + const upload = yield* selectedEnvironment.write(textAttachment, bytes);
338 + yield* otherEnvironment.write(textAttachment, "Different environment.");
339 + const prompt = yield* buildAntigravityPrompt({
340 + input: undefined,
341 + attachments: [textAttachment],
342 + resolveAttachmentPath: selectedEnvironment.resolve,
343 + promptCapabilities: { image: true, audio: true, embeddedContext: true },
344 + });
345
341 - expect(prompt).toEqual([
342 - {
343 - type: "resource",
344 - resource: { uri: upload.uri, mimeType: "application/octet-stream", text: source },
345 - },
346 - ]);
347 - expect(yield* selectedEnvironment.fs.readFileString(upload.filePath)).toBe(source);
348 - expect(
349 - yield* selectedEnvironment.fs.readDirectory(selectedEnvironment.attachmentsDir),
350 - ).toHaveLength(1);
351 - }),
346 + expect(prompt).toEqual([
347 + {
348 + type: "resource",
349 + resource: { uri: upload.uri, mimeType: "application/octet-stream", text: source },
350 + },
351 + ]);
352 + expect(Buffer.from(yield* selectedEnvironment.fs.readFile(upload.filePath))).toEqual(bytes);
353 + expect(
354 + yield* selectedEnvironment.fs.readDirectory(selectedEnvironment.attachmentsDir),
355 + ).toHaveLength(1);
356 + }),
357 );
358
359 it.effect("keeps folded clipboard text out of native context", () =>
@@ -634,7 +639,9 @@ it.layer(NodeServices.layer)("buildAntigravityPrompt", (it) => {
639 );
640
641 it.effect.each([
637 - { bytes: new Uint8Array([0xff, 0xfe, 0x61]), message: "is not a UTF-8 text file" },
642 + { bytes: new Uint8Array([0x80]), message: "is not a UTF-8 text file" },
643 + { bytes: new Uint8Array([0xff, 0xfe, 0x61]), message: "is not a UTF-16LE text file" },
644 + { bytes: new Uint8Array([0xfe, 0xff, 0x00, 0x00]), message: "contains binary data" },
645 { bytes: new Uint8Array([0x61, 0, 0x62]), message: "contains binary data" },
646 ])("rejects binary data disguised as code: $message", ({ bytes, message }) =>
647 Effect.gen(function* () {
apps/server/src/provider/acp/AntigravityAcpSupport.ts
+8 -2
@@ -486,11 +486,17 @@ export const buildAntigravityPrompt = Effect.fn("buildAntigravityPrompt")(functi
486 } else if (audio) {
487 blocks.push({ type: "audio", data: Buffer.from(bytes).toString("base64"), mimeType });
488 } else {
489 + const encoding =
490 + bytes[0] === 0xff && bytes[1] === 0xfe
491 + ? "UTF-16LE"
492 + : bytes[0] === 0xfe && bytes[1] === 0xff
493 + ? "UTF-16BE"
494 + : "UTF-8";
495 const decoded = yield* Effect.try({
490 - try: () => new TextDecoder("utf-8", { fatal: true }).decode(bytes),
496 + try: () => new TextDecoder(encoding, { fatal: true }).decode(bytes),
497 catch: () =>
498 EffectAcpErrors.AcpRequestError.invalidParams(
493 - `Attachment '${attachment.name}' is not a UTF-8 text file.`,
499 + `Attachment '${attachment.name}' is not a ${encoding} text file.`,
500 ),
501 });
502 if (decoded.includes("\0")) {