# Workspace image preview and zoom Files opens PNG, JPEG (`jpg`/`jpeg`), GIF, WebP, SVG, BMP and TIFF (`tif`/`tiff`) in a read-only image surface. Extension matching is case-insensitive. Loading, transfer/decode errors and size or memory limits are displayed in the surface. Other files retain the existing text or unsupported/binary preview. Images do not create editor buffers, syntax highlights or autosave work. Images initially fit the available area, preserve their aspect ratio and never upscale a small image automatically. Images opened from Files stay in the file panel when clicked; zoom and pan operate directly in that panel. Markdown/diagram images and attachments can still open the shared lightbox. Files, Markdown/diagram lightboxes and attachment lightboxes share these gestures: - Pinch on the trackpad or hold **Ctrl** while scrolling the mouse wheel to zoom around the pointer. - Drag the image, or scroll without Ctrl, to pan when the image exceeds the viewport. - The initial fit responds to viewport resizing. Manual zoom retains its scale and clamps the pan to the new viewport. - Escape or a plain lightbox click closes it and restores focus. Dragging, including releasing on the scrim, does not close it. Zoom normally spans 1%–3200%, allowing a smaller minimum when needed to fit a large image. Layout dimensions are capped at 131072 logical pixels for extreme SVGs. Scaling and panning reuse the current texture instead of decoding or rasterizing on each gesture. Gestures notify the owning view rather than refreshing the whole window, preserving unrelated view caches. Ctrl + wheel up increases zoom; wheel down decreases it. SVG detail therefore remains bounded by the raster budget at high zoom. ## Routing and resource lifecycle `files/image_preview.rs` reads image bytes exclusively through `WorkspaceFilesClient::read_image` (`ReadWorkspaceImage`). The request retains its workspace target and target device. It requires a nonempty expected checkout ID. For legacy chats/plain folders with no synced checkout identity, `ReadWorkspaceFile` first obtains the owning host's checkout ID; its text is discarded and never becomes the image or an editor buffer. The UI never opens the workspace path on its own filesystem. The existing transport limits remain: at most 8 MiB of image bytes, 384 KiB chunks, stable checkout ID, content hash, MIME type and size across chunks, valid base64, monotonic offsets and consistent completion. Empty checkout identities and content hashes are rejected. Decoding runs on the background executor, with a 30-second deadline for the complete read/decode request. `image_media.rs` is shared with Markdown. Raster decoding limits each side to 4096 pixels and decoder allocation to 64 MiB. Animated input is flattened to its first frame. SVG parsing disables embedded/external image resolution and reserializes the parsed tree, so scripts, HTML and resource URLs do not reach GPUI. Prepared SVG rasters are capped at 4096 pixels per side; enlarged variants at 2097152 pixels. Memory accounting includes the prepared source, decoded CPU pixels and GPU texture. Each Files image surface admits at most 64 MiB of retained image resources, including its panel rendering variants. A generation guard rejects obsolete work. Collapsing the right panel or switching files, tabs or chats suspends image loads, clears media and schedules asset/atlas eviction. Resuming reloads from the owning workspace. Watcher updates do not reload hidden images; modifications, deletion and renaming invalidate the relevant image. Changing the target suspends the old view before clearing documents. Closing/disposal releases the image preview resources. Text documents retain their existing cache and editing lifecycle. Renaming an edited text file to an image extension preserves its buffer and pending save; image conversion waits until those edits are resolved. Watcher events continue through text conflict handling while edits remain. ## Tool-call image previews A tool chip whose call or output names an image file (PNG, JPEG, GIF, WebP, BMP, SVG, TIFF; at most four per chip) previews it when the chip is expanded. Relative paths resolve against the chat's cwd on the owning host. Bytes arrive through `ReadAttachmentChunk`, so its jail applies: the owning host's uploads directory (plus any read-only legacy uploads roots) and the working directory of every chat in the workspace on that host, not just the chat that ran the tool. A projectless chat's working directory is the home directory, so any image under home on that host is readable. When the tool result itself embeds image bytes, the engine stores a copy in the profile uploads directory (named by the chat and the bytes, so the same picture again in a chat is one file) and names it on the tool part as `previewPaths`; a client that reads `previewPaths` (the zgx app) previews that copy, so a scratch path named by the call does not have to be readable. Claude Code's note that only describes an image's displayed size (`[Image: original WxH, displayed at WxH. …]`, `[Image: source: …]`) is not taken as a subagent message. Paths with no embedded bytes, and bytes the store rejects, still show *Image unavailable*. Network and device paths (UNC `\\host\share`, `//host/share`, `\\?\UNC\…`, `\\.\…`) and drive-relative paths (`C:x.png`) are never previewed. The engine also jails each path lexically, resolving `.`/`..` without touching the filesystem, before it canonicalizes the path, so a path outside every root is refused without being opened. `tool_images.rs` decodes one static frame on the background executor within the shared raster limits (4096 pixels per side, 64 MiB decoder allocation), downsamples it to at most 1120×440 and hands BGRA pixels straight to GPUI as a `RenderImage` (no re-encode, no asset cache). Nothing is read or decoded for collapsed chips or hidden groups. Collapsing starts a 600 ms grace; then the CPU frame and the sprite-atlas tiles are released. Reopening inside the grace reuses the texture, so rapid toggling never re-reads or re-decodes. Previews that are expanded but unpainted for 2 s count against a 64 MiB budget; painted ones are never evicted. Chat switches and transcript disposal release everything. Right-clicking a tool preview, a user attachment thumbnail, a generated image or an image a reply names in Markdown opens **Copy path** / **Copy image**. Copy image fetches the original file from its owning device, not the preview (a Markdown image through `ReadChatImageChunk`, under its chat's jail); SVG is copied as the sanitized, re-serialized tree. `cargo run --locked -p zeron-ui --example tool-images-fixture --features appshots-fixture` opens an isolated session with mock images. `-- --capture