Code blocks & canvas
Every fenced code block in an assistant reply is syntax-highlighted, line-numbered and comes with a small toolbar. For longer snippets, its Open button pops the block into the code canvas - a wider, easier-to-read panel alongside the conversation - where HTML can also be previewed as a page.
Inline actions
Each code block has a header showing its language (or text when the model didn’t tag one) and three buttons, four on an HTML block:
- Preview - HTML blocks only: open the canvas on the rendered page (the tooltip reads Preview in canvas). See HTML preview.
- Open - pop the block out into the canvas panel (the tooltip reads Open in canvas).
- Export - save to a file via the native save dialog. The default filename comes from the block’s language tag (
snippet.ts,snippet.py,Dockerfile, and so on); untagged or unrecognised languages save assnippet.txt. - Copy - put the snippet on the clipboard exactly as the model wrote it. Works for everything, even non-code (JSON, logs, plain prose in a fenced block).
While a reply is still streaming, the block being written shows as plain text; highlighting is applied once the block is complete. A block over 50,000 characters stays plain text, so a huge one can’t hold up the window.
The canvas panel
The canvas opens in the right-hand slot of the window and holds one snippet at a time - opening another block replaces it. It shows:
- Header - a close button, the title (Code Canvas, Text canvas for plain text, or the file name when opened from an attachment) and a badge with the language.
- VS Code - write the snippet to a scratch file in Loach’s cache folder and open it in VS Code. On Windows and Linux this goes through the
codecommand; if it isn’t on your PATH, a message tells you to run Shell Command: Install ‘code’ command in PATH in VS Code rather than failing silently. On macOS Loach asks the system to open the file in Visual Studio Code directly. It sends a snapshot: a block that is still streaming doesn’t keep updating in VS Code. - Copy - mirrors the inline action.
- Export - same sensible-filename defaults; for an attachment, the default is the original file name.
- Read-only body with line numbers and language-aware highlighting. Unknown languages fall back to auto-detection, and snippets over 50,000 characters show as plain text to keep the window responsive.
- Live updates - open the canvas on the block a reply is still writing and it follows that block as more tokens arrive, as plain text until the reply finishes. Then it keeps the finished block; code blocks the reply goes on to write don’t replace it.
- Resizable - drag the left edge to set the panel width (at least 320 px, always leaving the transcript 420 px); your choice is remembered.
The canvas is also where text and code attachment previews open - clicking a recognised code or text file chip routes straight here, with the same highlighting and export controls.
The canvas and the parameters sidebar share the same right-hand slot. While the canvas is open it takes the slot; close it and the parameters panel comes back if it was open. On windows narrower than 1080 px, opening the canvas also folds the left sidebar to its icon rail so the transcript keeps a usable width - it returns when the canvas closes (see the sidebar on narrow windows).
Private Chat has no canvas: while it’s open, code blocks show neither Open nor Preview. Copy and Export still work.
HTML preview
An HTML code block (tagged html or htm) has a Preview button that opens the canvas straight on the rendered page. An .html or .htm attachment opens in the canvas too, on its code. Either way, a Code / Preview switch under the canvas header flips between the source and the page.
- Scripts start off - a preview first shows the page’s markup and styles only, labelled Offline sandbox · scripts off. Run scripts runs its JavaScript and turns into Stop scripts. It applies to that exact code only: open different code and its scripts start off again.
- Reload - starts the page over from scratch.
- While the reply streams - the preview shows The preview appears when the code finishes generating. until the reply is done, and Run scripts and Reload stay disabled until then.
The page runs in an offline sandbox, cut off from Loach, your files and the network. Only what the page itself contains loads - inline styles and scripts, and images, fonts and media embedded as data: URLs. Scripts, stylesheets, images and fonts from the web don’t, so neither do libraries from a CDN such as Tailwind or Chart.js. Forms don’t submit; pop-ups, downloads and dialogs such as alert() do nothing; embedded frames (<iframe>, <object>, <embed>) are removed; and WebRTC isn’t available. localStorage and sessionStorage work, but only in memory until the page reloads, and there are no cookies. A page that sets no background shows on white, like a browser tab.
Typing or clicking inside a preview counts as activity for auto-lock, and Ctrl + Shift + L (⌘ + Shift + L on macOS) still locks Loach while the preview has focus.
On macOS and Linux the preview runs on the same thread as Loach itself, so a script that never stops - an endless loop, say - freezes the whole app, lock screen included, until you quit it. That’s why scripts start off, and it’s what the Run scripts tooltip warns about there. On Windows the preview runs in a process of its own, and the tooltip just says the scripts run still sandboxed and offline.