L Loach Docs
Ctrl K

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:

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:

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.

Heads up

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.

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.

Scripts on macOS and Linux

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.