Snippets is an optional extension (omxterm.snippets) on most hosts. Its source
lives in extensions/snippets/. It reads the user's snippets.yaml, lists and
searches entries, and asks the core to insert or run the exact text in the
selected terminal. ADR 0044
records why it moved out of the core. The user-facing summary is the
Snippets availability note.
usesOptionalSnippets() in src/shared/snippets-mode.ts is the single platform
policy:
| Host | Snippets |
|---|---|
| Linux ARM64, Linux x64, macOS ARM64, Windows ARM64 | Optional extension |
| Windows x64 | Built-in sidebar |
| Any platform on stable 0.23.0 and earlier | Built-in sidebar |
On extension hosts, an install or runtime failure never falls back to the
built-in sidebar. Fresh configuration kits on those hosts omit the starter
snippets.yaml; Windows x64 still creates it. Windows x64 manages extensions
from 0.28.0 but keeps built-in Snippets.
New packaged profiles on extension hosts get Snippets 0.1.6 installed once, enabled but inactive until opened. See Default Snippets. Existing profiles never get it automatically.
The package has a trusted Node backend (backend.ts, catalog.ts) and an
isolated hosted page (page.ts, view.ts). It runs in the shared companion
panel next to Files and SSH Connect.
- Catalog loading. The backend reads
snippets.yamlon every panel activation, not at startup and not through a watcher. It sends one immutable snapshot to the page in bounded pages (up to 512 entries), and the page replaces its rows only once the snapshot is complete. A hidden or superseded activation cannot publish late results. - View state. Hiding keeps query and scroll. A language change relabels the controls without rebuilding them.
- Terminal delivery. The page never touches the PTY. It sends exact text to the core, which owns the target, preview and paste. See Terminal-input rules.
snippets.yaml lives beside config.json and uses the
documented YAML v1 format. Install, update,
disable and uninstall never create, copy, rewrite or delete it. A missing file
is a clean empty state. To start a catalog, copy snippets.example.yaml from
the package. That example uses POSIX printf; Windows users need commands for
their own shell.
Which home directory the extension uses depends on its version:
- 0.1.1 and later (catalog and bundled default): a nonempty
XDG_CONFIG_HOMEwins; otherwise the OS account home, independent ofHOMEorUSERPROFILE. - 0.1.0 (older installs): a nonempty
XDG_CONFIG_HOMEwins; otherwise the environment'sHOME(USERPROFILEon Windows). If that differs from the account home, 0.1.0 reads a different file from the one besideconfig.json. Updating to 0.1.1 fixes it. Upgrading the app does not update an installed 0.1.0.
View → Toggle Snippets, its Command Palette entry and its shortcut
(Ctrl+Shift+S on Linux/Windows, Cmd+Option+S on macOS, keybinds.toggleSnippets)
are the only entry point. The package's own duplicate action is withheld.
- With Snippets installed and enabled, the command opens the companion view. Invoking it again while Snippets is the visible tool closes it and drops its search and scroll. Hide or Escape keeps that state for reopening.
- Without an enabled package, it opens Settings → Extensions with an explanation. A disabled package stays disabled. Nothing is installed or enabled for the user. An unavailable extension runtime is reported separately from a missing package.
- On Windows x64, it opens the built-in sidebar.
- Custom remaps and
nullbindings keep working whether or not the package is installed.
Toggle Side Panel hides and reveals the panel as usual whenever any tool is open. When the panel is genuinely empty, it opens installed and enabled Snippets instead. Windows x64 opens its built-in sidebar.
If Snippets is not available, the panel shows one nonmodal notice for about four seconds, once per application process across all windows. It does not steal focus, open Settings, install, enable or download anything. A late view cannot open after the selection, modal or focus has moved on.
These rules come from ADR 0044. They keep the terminal's input guarantees the same as with the built-in sidebar.
- One narrow capability. The package declares
terminal.semanticInput.v1. A request carries exacttext, atitle, an optionaldescription, anintent(insertorrun). Earlier packages also sendpreview: false, which is accepted and ignored;preview: trueis refused. It cannot name a target terminal, get a PTY handle, read terminal output or inject raw keys. - Core picks the target. Core captures the selected live Surface before any asynchronous work, and every later step uses that capture. If the selection changes in transit, or the target fails or closes, delivery is refused, even if a replacement pane appears. With no live target, the request does nothing.
- Sender checks. Core rejects requests from stale, hidden or foreign views and from a retired installation.
- Exact text. Text is never expanded, normalized or truncated.
execute: falseadds no final Enter, but embedded line breaks or control characters can still execute. Protected Paste stays core-owned. - Gesture ownership. A row's Enter press, its repeats and its release never leak into the terminal after focus moves, including with Kitty keyboard reporting.
- Retirement. Disable, update or uninstall cancels pending requests. It does not end terminal sessions or undo commands already sent. Input a Surface already accepted stays with that Surface.
The builder needs a clean committed checkout and runs after npm run build
(which clears dist):
npm run build
node scripts/build-snippets-extension.mjs # writes dist/extensions
OMXTERM_SNIPPETS_BUILD=1 npm test -- test/integration/snippets-extension-build.test.tsThe builder accepts [OUTPUT [SOURCE_COMMIT]]. It writes the .omxext archive
and its .sha256 and .json receipt; the receipt's
qualification.status: not-run is a build-time field. Version, host range, API
and capabilities come from extensions/snippets/extension.json. See
Building an extension archive for
the shared rules.
npm run test:unit covers the package and its host seam, including
test/unit/snippets-extension-*.test.ts, snippets-mode.test.ts,
renderer-snippet*.test.ts and default-snippets-*.test.ts. The opt-in
production-composition fixture checks the missing-package guidance on each
extension host; see the macOS,
Linux x64 and
Windows ARM64 notes.
test/integration/snippets-smoke-packaged.test.ts checks an archive on a
packaged host, on Linux ARM64 and macOS ARM64. It launches the app with an
isolated home that has a two-entry snippets.yaml, installs the archive through
Install from file (one consent), opens Toggle Snippets, then
Inserts one entry and Runs the other. The shell writes what it received, and the
test checks it and that snippets.yaml is unchanged. It runs in seconds:
OMXTERM_SNIPPETS_SMOKE_APP=/absolute/OMXTerm-X.Y.Z-arm64.AppImage \
OMXTERM_SNIPPETS_SMOKE_ARCHIVE=/absolute/snippets-X.Y.Z.omxext \
npx vitest run test/integration/snippets-smoke-packaged.test.tsOn macOS, point the app variable at an OMXTerm.app copied out of the DMG and
run it from a logged-in desktop session. The test skips on Windows and when
either variable is unset.
Snippets ships as its own ext-snippets-vX.Y.Z prerelease. Follow
Publishing an extension archive,
then Catalog promotion. The Snippets entry is
edited by hand in both distribution/official-extensions-v1.json (every host
except macOS) and distribution/official-extensions-darwin-arm64-v1.json
(macOS), with targets linux-arm64, linux-x64, darwin-arm64 and
win32-arm64. The bundled default is a separate pinned archive; changing the
catalog entry does not change it (Default Snippets).
Users install or update in one of two ways. Both use the same captured-byte install prompt:
-
Settings → Extensions → Browse official extensions, then Install or Update on the Snippets card. Browsing is explicit; opening Settings does not fetch the catalog.
-
Settings → Extensions → Install from file with an archive downloaded from the release. This works offline once downloaded. Verify it first:
shasum -a 256 -c snippets-0.1.2.omxext.sha256 # macOS sha256sum --check snippets-0.1.2.omxext.sha256 # Linux
On Windows, compare
Get-FileHash .\snippets-0.1.2.omxext -Algorithm SHA256with the sidecar. A checksum identifies bytes, not a verified publisher.
Approving the install enables the package but does not start its backend. Toggle Snippets is the activation step. Extension code is trusted code, not a sandbox.
- Windows ARM64: installing Snippets from the public catalog failed in testing on 0.25.0 when the controlled terminal child exited unexpectedly, and the cause is unknown. It has not been re-tested on 0.27.
- Windows network silence: startup is not verified to stay network-silent on Windows; the strict test sees system-proxy discovery traffic. No Snippets catalog or archive download was observed.
- x64 packages: Linux x64 and Windows x64 packages are build-only in CI; their desktop integration is untested.