Gemini models corrupts large UTF-8 source files during surgical edits

I asked Gemini about it and here’s its official bug report I asked it to create (which I submitted to the in-app “Submit bug” option):

Monaco Code Editor fails to inflate/decompress secondary transport chunks for workspace files, rendering raw zlib binary streams in the UI.

Description:
When opening any text file larger than 524,288 bytes (512 KiB) in the AI Studio workspace “Code” editor pane, the editor displays clean plain text up to byte offset 524,288, but immediately displays raw compressed binary characters (e.g. x\x9c\xed\xbd... / zlib stream payload) from offset 524,289 through the end of the file.
The underlying file on the container disk is 100% valid, uncorrupted UTF-8 text, and the application preview runs normally. The issue lies entirely in the web frontend’s file-sync transport deserializer / Monaco receiver.

Root Cause & Technical Details:

  1. Chunked Transport Layer: The workspace file streaming service splits files exceeding 512 KiB (524,288 bytes) into chunks:
  • Chunk 0 (0 – 524,288 bytes): Sent as plain text.
  • Chunk 1+ (524,288+ bytes): Sent as a compressed zlib deflate stream.
  1. Missing In-Browser Decompression: The web client’s Monaco file receiver concatenates the raw binary buffer of Chunk 1 directly onto Chunk 0 without calling zlib.inflate() / decompression on the secondary chunk.

  2. Result: The user interface displays raw compressed bytes starting at the 512 KiB mark, preventing code viewing, manual editing, and browser-based file exports for files over 512 KiB.

Steps to Reproduce:

  1. Create or open any single text file in the workspace (e.g., index.html or bundle.js) with a size of valid ASCII/UTF-8 code.
  2. Open the file in the Code tab inside Google AI Studio.
  3. Scroll down to the exact byte offset corresponding to 524,288 bytes.
  4. Observe that code prior to this point renders correctly, but the remainder of the file appears as garbled zlib binary text (xr...).

Expected Behavior:
The Monaco file transport layer should decompress/inflate all secondary chunks before populating the editor model buffer, displaying 100% plain text across the entire file regardless of file size.

Environment Info:

  • Platform: Google AI Studio Build (Cloud Run Workspace Container)
  • Component: In-Browser Code Tab / Monaco Editor File Sync Transport
  • Chunking Threshold: 524,288 bytes (512 KiB)