Modes

Mouser has two kinds of modes: mode plugins (commander, below), which change how you work with the files under the shell, and the input modes of the command line.

Input modes

Mouser supports vim-style input modes:

Mode switching

Actions

Keybindings

Menus, keybindings and the command line dispatch the same named actions.

Mode plugins

Built in: commander (esc :c), chat (esc :a) and preferences (esc :p, preferences.md).

The last mode is remembered

When a window closes, Mouser saves the mode it was in (or none if no mode was on) to $MOUSER_HOME/state/last-mode (state, not configuration), and the next launch starts in it. With several windows, the last one to close wins. A remembered mode that has since been disabled or uninstalled is skipped quietly (no mode). Restoring only switches the mode: the chat starts empty and sends nothing, and no model is picked or downloaded until you use it. Delete the file to go back to the default (the first enabled mode).

Exactly one mode plugin is active at a time (or none). Mouser starts in the default mode, commander. Switching replaces the current mode; there is no stacking. The second official mode is chat (esc :a), the agent; see docs/chat.md. Since 1.4.0 no mode is compiled into Mouser: commander, chat and preferences are plugin programs (mouser-commander, mouser-chat, mouser-preferences) that first run installs from plugins.lock (signed, checked; the -full release bundles carry them for offline installs; docs/downloads.md). The modes are plugins (P6): the switcher lists the enabled modes from the plugin registry in priority order, and the first is the default. mouser plugin disable commander (or chat) takes one out; with every mode off Mouser is a plain terminal. Installed mode plugins (kind = "mode" over the command transport, with a [mode] hotkey) join after the official modes; see docs/plugins.md §Mode plugins and examples/plugins/hello-mode.

Remapping

~/.mouser/modes.toml (the Mouser home), one section per mode:

[focus]
        key = "ctrl+alt+k"      # the toggle: alt+<key> or ctrl+alt+<letter>, never plain
        [commander.keys]
        switch_view = "t"       # a character, up / down / left / right / enter / tab / space /
                                # backspace / pageup / pagedown / home / end / f1, alt+<key>, ctrl+alt+<letter>
        

Every key is rebindable. An unknown action or key is reported in the status bar and the defaults are kept. The old modifier = "alt" setting is ignored (keys are plain while the mode has focus).

Panel size and fullscreen

While a mode has the keyboard, Mouser itself takes four plain keys (before the mode's own; [host.keys] in modes.toml):

Key Action
F (Shift+F) mode panel fullscreen on / off (also the ⤢ button at the panel's bottom left)
] panel taller (10% of the terminal per press)
[ panel shorter (never below a tenth, or four rows)
. context menu for the selected item

Drag the panel's bottom edge (the pointer turns into ↕) to resize it with the mouse. The size is saved in preferences.toml as [window] dock_height (a percentage, 10–100) and dock_full, so it survives restarts. Fullscreen hides the shell behind the panel; the terminal keeps its size, so nothing reflows. None of these keys reach the shell's bindings: they only work while the mode has focus (ctrl+alt+k). While a search or text field is focused they are typed instead. One-character keys are case sensitive in modes.toml (F is Shift+F, f is f).

Keyboard help

? (or F1) while a mode has the keyboard, or ctrl+shift+k from anywhere, opens Keyboard help: a window listing every key and what it does, in three groups: the current mode's keys (your modes.toml remaps included), Mouser's keys while a mode has focus (F ] [ .) and the global keys (F10, Alt+Esc, esc :, tabs, clipboard, font size, mouse). It is built from the live key tables each time it opens, so it can never disagree with what the keys do. ↑/↓, PgUp/PgDn and Home/End scroll it (x–y of N at the bottom when it does not fit); ?, q, F1 or Esc close it. While it is open other keys wait (F10 and Alt+Esc still work). A mode plugin gets it for free: its [[mode.keys]] are listed with their describe text (an action called keys or help that answers show_keys opens it, as commander does).

Context menus

Right-click in a mode's view (or press .) for a menu of every action that applies right now: the item under the pointer (file, folder, image, media ...) and the view's state (list, fullscreen image, playing clip, text viewer). Each row shows the action's current key, so the menu also teaches the keys. The menu is built from the same action registry as the key bindings, so a new or remapped action shows up automatically. ↑/↓ and Enter pick, a row's own key picks it, Esc or a click elsewhere closes it. Disabled actions are shown muted. Modes answer menu.open with their entries (see docs/mode-protocol.md); a mode that does not gets no menu.

Commander's menus (keys are the defaults):

Where Entries
a file open (Enter), copy (y), copy to… (c), move to… (M), rename… (r), delete… (d), copy path (Y), mark (Space), pipe (|), back (u)
an image, video or audio file the same, with play (Enter) and play / view fullscreen
a folder open (Enter), sync the shell here (e), the file entries, paste (p), back (u)
the empty area back, sync (s), new folder… (n), paste (p), sort by name / modified / size (N / D / S), reverse (R), list / grid / carousel (L / G / C), switch view (v), larger / smaller tiles (z / x), dotfiles (h), search (/), mark all (*), first / last, options (o), manual (m), keyboard help (?)
image view, fullscreen or not zoom in / out (= / -), fit (0), 100% (1), pan (arrows; ← / → step images when not zoomed), fullscreen / exit fullscreen (f), copy path, close (q)
player, fullscreen or not play / pause (k), back / forward 10 s (j / l), volume (- / =), fullscreen / exit fullscreen (f), copy path, close (q)
text, Markdown, PDF or document view, the manual scroll (↑ / ↓), page up / down, previous / next file (← / →), copy text (T), copy path (Y), close (q)

File changes never happen straight away: copy to, move to, rename and new folder first ask for the destination or name in commander's prompt line. Tab completes paths (relative to the current folder, with ~ expansion; directories get a trailing slash) and names; repeated Tab cycles matches, Shift+Tab goes back. Enter goes on, Esc cancels), then every change (delete and paste too) waits for your yes on Mouser's approval card, which lists what will change. Nothing is ever overwritten: a target that exists stops the change. Delete is permanent (folders with everything in them); the card says so. copy remembers the items for paste in another folder; copy path and copy text put text on the clipboard. In an SSH session the changes run on the remote host (the card says on user@host), over the session's own ssh connection, with the same rules (nothing overwritten, a folder never moved into itself); paste between this machine and a remote one is refused. The commander plugin declares files.write for them. The text view has no zoom of its own (use Mouser's font size, ctrl+= / ctrl+-).

Commander

A view docked above the prompt (the terminal grid moves down; about half the window) that starts in the shell's working directory (/proc/<pid>/cwd on Linux, OSC 7 elsewhere) and keeps its own folder after that: browsing in commander never types into the shell or changes its folder (s syncs, below). A cd you type in the shell still moves commander there. Header: the directory, item count and the equivalent ls flags, then the view, options, man and help buttons; a search field filters the folder as you type.

Keys while commander has the keyboard (ctrl+alt+k or a click; plain keys, all remappable):

key list grid carousel
v switch view: list → grid → carousel
L / G / C list / grid / carousel view same same
? or F1 keyboard help: every key and what it does (above) same same
↑ / ↓ previous / next row row above / below (follows the wrap) previous / next item
← / → previous / next item previous / next tile previous / next item
PgUp / PgDn a screen of rows a screen of tiles 5 items
Home / End first / last first / last first / last
u, Backspace back: where you came from (like popd), else the parent folder; in the file view / player it closes the view same same
Enter open: a folder is browsed (the shell stays where it is), video/audio open the player (below), anything else opens the full-width file view (image or text; ↑/↓/PgUp/PgDn scroll it, ←/→ step through files) same same
q (or Esc) close the file view / window; with nothing open, back to the shell same same
/ search: type to filter (the first match is selected), Enter keeps the filter, Esc clears it same same
space mark / unmark the item (then moves on in list and carousel) same same
* mark all / clear marks same same
| pipe: a prompt in the view; Enter types printf '%s\n' <paths> | <cmd> into the shell, so the output lands in the shell same same
z / x larger / smaller tiles
h dotfiles on/off (ls -a) same same
o / m options window / manual same same
i the header's ••• menu when narrow same same
ctrl+alt+k or Esc give the keyboard back to the shell same same
s sync: move the shell to commander's folder (silently; see below) same same
e sync the shell to the selected folder same same
O open the selected image or video fullscreen same same
y / p copy the marked (or selected) items / paste them here (approval card) same same
c / M copy to… / move to… (asks for the folder) same same
r / d / n rename… / delete… / new folder… (approval card) same same
Y / T copy the path / the text of the file view to the clipboard same same
N / D / S / R sort by name / modified / size, reverse same same

Every entry of commander's menus has a key (a test fails if one does not), and the keyboard help lists them all. Upper-case letters are Shift+letter, so they never clash with the plain keys.

Back works like popd, inside commander (it never runs pushd/popd). Entering a folder or opening a file pushes where you were onto a navigation stack: the path as you saw it (a symlink stays a symlink), the selection and the scroll. Back pops it and puts you exactly there again. With nothing on the stack (after a cd you typed, a breadcrumb jump, or at startup) back goes to the parent of the path you see, not of the resolved one, so leaving a symlinked folder never lands in its target's real parent. Remote (SSH) folders work the same way (listed over the ssh side channel, never by typing into the remote shell).

Sync (s). The shell's prompt stays as it is while you browse. s moves the shell to commander's folder, from anywhere in commander (the file view and player included), without leaving it. It never types: no cd on the line, nothing in the history, the half-typed line kept. How it gets there:

shell how
bash 4.4+, zsh, fish with mouser shell-integration idle at the prompt: at once, through the integration's silent cd (Fuzzball s c, docs/protocol/shell.md), prompt redrawn in place; running a command: at its next prompt
PowerShell with mouser shell-integration pwsh at the next prompt: the prompt function reads the folder from its sync file and runs Set-Location (PowerShell only redraws its prompt after a command; Enter on an empty line takes it at once)
no integration (bash older than 4.4, other shells, a remote shell without it) nothing happens; the status bar says so

Both keys are rebindable in modes.toml (sync, search).

Player. Video and audio open in commander's own player (MODES.md: "a player will appear"). Video frames are decoded by ffmpeg to RGBA, fitted to the view's width and drawn through Mouser's image path; Mouser plays the sound itself (cpal: ALSA/PipeWire on Linux, CoreAudio, WASAPI). Audio files get a minimal view: name, progress bar, time, volume and the keys. Keys (plain, remappable, while commander has the keyboard; they only act while a player is open):

key
k (Space in fullscreen) play / pause
j / l back / forward 10 s
- / = volume down / up (10 %)
q or Esc close
f fullscreen (below)

How it stays in sync: two ffmpeg readers of the same file start at the same seek point, one for video (-an, RGBA at the file's frame rate, each frame stamped with its PTS = start + n/fps) and one for audio (-vn, f32 at the device rate). The audio output callback counts the samples it hands to the device and notes when each buffer was handed over; the clock is the frame being played now: that buffer's first frame plus the time since, minus the device latency the backend reports (so it moves smoothly instead of in buffer-sized steps), never past what the device was given. Frames can only appear when the window redraws, so the clock is read half a redraw interval ahead (measured as a moving average): the error is centred on zero. A due frame is shown unless it is already a whole frame late and the next one is due too; only then is it dropped; early frames are held. Files without audio use a wall clock. Pause silences the output and freezes the clock (the readers just wait, nothing restarts); volume is applied to the samples in-process. A seek flushes both queues and restarts both readers with -ss at the target, so audio and video start together. Measured (Linux, 25 fps test file with a flash and a beep each second, 64 s of play plus 7 seeks, 2350 frames): video vs the audio clock mean -0.2 ms, p95 9.5 ms, max 24.7 ms, 0 frames dropped, no drift (first 10 s +0.5 ms, last 10 s -2.9 ms); 61-76 ms from a seek key to the first new frame. MOUSER_PLAYER_LOG=<file> writes clock pts per shown frame and the seek gaps.

Nothing is started until a file is opened; playback stops (the readers are killed) when the viewer closes, another file is shown or the mode is left. Without ffmpeg and ffprobe on PATH, media falls back to the desktop opener (xdg-open, open on macOS).

What you have typed is kept. Pipe runs without losing a half-typed command: Mouser sends Ctrl+E, a space and Ctrl+U (the line goes to the shell's kill ring), the command and Enter, then, once the shell is the terminal's foreground process again (the command finished), Ctrl+Y and Backspace to put the line back (the cursor ends at its end). The added space makes sure an empty line stays empty instead of yanking an older kill.

shell
bash (readline, emacs mode) kept (tested)
zsh (zle, emacs keymap) kept (tested)
fish kept (Ctrl+U/Ctrl+Y use its kill ring; tested when installed)
vi keymaps (set -o vi, bindkey -v) not supported: in insert mode Ctrl+E/Ctrl+Y differ; leave the line empty before opening
a program reading the terminal (less) after pipe the yank waits until it exits

On Windows the shell's foreground state cannot be read, so the line is put back after a short pause.

Mouse in every view: a click selects, a double-click (400 ms) opens, the wheel moves the selection (it scrolls the file view and the manual). The selection is highlighted and the view scrolls to keep it on screen. Marks show as * and as a count in the header. Pipe takes the marked paths in listing order, or the selected path when nothing is marked; paths are single-quoted (' becomes '\''). Marks are per folder.

Commander takes no key from the shell: without focus it binds only the toggle, so alt+t, alt+f, alt+Backspace and the rest stay the shell's. Clicks: a click selects an item, a second click opens it; the wheel over the view moves the selection.

. and .. are never listed. Going up is the back control in the header (‹ back (u), ‹ back when narrow; greyed out at /), u or Backspace (both remappable, both in ctrl+shift+k). Going up selects the folder you came from. The header path is clickable: each segment goes to that folder (long paths lose their leading segments to …).

Search (/ or a click on the field) takes the typed letters while it is open (bright field, "searching · type to filter" hint). Tab completes matching names in the folder. It filters as you type and shows N matches for "q" or no matches for "q"; Enter keeps the filter, Esc cancels. Without focus everything you type, viewer or player open or not, goes straight to the shell. An Esc right after an Esc that closed a viewer or window (within 1.5 s) is swallowed instead of being held for the shell: held, it reached the shell glued to the next key (Esc c is readline's meta-c), which ate the first letter of what you typed next.

Type badges. Every grid tile and carousel item has a small round badge for its type, centred exactly on the box's top-right corner and drawn on top of the preview: a folder shape for folders, else a short mark (IMG image, VID video, AUD audio, TXT text, </> code, MD Markdown, PDF, ZIP archive, BIN binary or executable, {} JSON/TOML/YAML config, Aa font, DOC document or spreadsheet, … anything else). The type comes from the file extension (the same detection the previews use); a file with an execute bit and no known type is a binary. Grid and carousel leave room above and between the boxes for the overhang. The badges are drawn by Mouser itself (no image assets).

Previews load lazily on a worker thread: only what is on screen is requested (grid: the visible tiles; carousel: the focused item and its two neighbours) and the queue is replaced as you move, so off-screen items are skipped. They load in order: grid tiles top-left first, the carousel's focused item before its neighbours. Until one is ready the tile shows its kind dimly (image, ▶ video). If a thumbnail of another size is already decoded (the grid used a smaller tile, or the carousel is sliding a neighbour into view), that picture is shown instead of the kind label so the tile does not flash. Formats: PNG, JPEG, GIF, WebP, BMP. Video thumbnails: one ffmpeg frame at 10 % of the duration (at most 30 s in; 1 s if unknown; the first frame if that fails), scaled to the tile, cached in memory and on disk in $MOUSER_HOME/cache/thumbs/ keyed by path, mtime, size and tile size. Without ffmpeg the tile says ▶ video.

Previews and player frames are clipped to the view (never over the prompt), and are left out under the options and manual windows so nothing shows through them.

Carousel motion. Moving between items slides the strip (the focused item and the partial neighbours together) over 180 ms with an ease-in-out curve (cubic; ease-in alone looked like it lurched at the stop). A key during a slide retargets from where the strip is, without a jump; jumps of more than 3 items only slide the last one. Redraws are requested only while it moves (a ticker every 8 ms, stopped at the end). Measured (Linux, release, 655 px window): 50 fps while sliding (frame p50 19.8 ms, p95 20.0, max 38.6), idle frames only on other events. Loading stays lazy: what is on the strip plus the selection's neighbours, so the incoming item loads during the slide.

SSH sessions. When the tab's shell is on another host commander lists that host:

Image zoom, player controls, header menu

Remote files (SSH sessions)

Remote listings preview, view and play like local ones, through mouser_core::fetch:

Scroll position

When a view doesn't fit, commander shows where you are: a slim scrollbar on the right of the list, grid and text views, and x–y of N (text: lines x–y of N) at the right of the search row. The carousel shows n of N and a track under the picture.

As a plugin program

Commander is a separate program (mouser-commander, transport = "mode", source in plugins/commander and the WeirdBrains/mouser-commander repo), built only on mouser-mode-api; Mouser has no built-in commander since 1.4.0. It runs as you, like any program you start: it lists the folder and decodes thumbnails and previews itself, and its view goes to Mouser with the images inline (sent once, then reused by key). It needs files.read (to be told the shell's folder) and shell.type (sync, pipe, and keys it passes on), and remote.read for remote shells (Mouser tells it the ssh session and the folder's listing; it fetches previews and files over that session's ssh, below):

cargo build --release -p mouser-commander
        mkdir -p /tmp/commander-plugin && cp plugins/commander/plugin.toml target/release/mouser-commander /tmp/commander-plugin/
        mouser plugin install /tmp/commander-plugin
        mouser plugin permissions commander run=allow files.read=allow shell.type=allow remote.read=allow
        

mouser-commander --manifest prints its plugin.toml. Keys, remaps in modes.toml, the views, search, pipe, the file view with Markdown, and image zoom are tested end to end: plugins/commander/tests/through_mouser.rs starts the program through Mouser's adapter and checks what it draws (list, grid, carousel, search, the file view, images) and the effects it asks for (sync's cd, pipe's command line); remote_through_mouser.rs does the same for a remote folder over a fake ssh (list, grid tiles and snippets, the image and text views). A bound key the mode passes on (k with no player) goes nowhere (commander has the keyboard, so nothing is typed into the shell) let it through. The player runs in the plugin too: it starts ffmpeg itself, plays the audio, and hands each frame to Mouser through shared memory (player_through_mouser.rs: a 1280x720 60 fps clip arrives at 61.5 fps through Mouser, debug build on Linux; the test's floor is 30, 20 on CI).

Plugin API (mouser_render::modes)

A mode implements the Mode trait and is registered with Host::new (the first mode is the default). Mouser registers the enabled mode plugins with Host::from_registry; tests register their own modes with Host::new.

item what the mode provides
name(), hotkey() name and the letter typed after esc :
bindings() default bindings Binding { id, key, describe }; the host loads modes.toml overrides, shows them in ctrl+shift+k and routes a bound key to action(id, 0)
activate(), deactivate() lifecycle; deactivate drops transient state
cwd_changed(dir) the shell's directory (called every frame; cheap when unchanged)
action(id, arg) a bound key, or a click on an item with UiAction::Mode { action, arg }; the wheel over the view sends "scroll" with ±steps
wants_text(), text(bytes) a focused input (search) takes plain typing
escape() close the mode's window or input
view(ctx, keymap) the render contribution: View { dock, panel, images } — a panel docked above the prompt inside ctx.area, an optional floating window and images (window pixels plus source rect)
set_waker(w) redraw from another thread (e.g. when a preview finished)

Actions return an Effect for Mouser to carry out: Type text into the shell, Open a file with the desktop opener, ShowKeys, Say (status bar). The core has no commander-specific code: key routing, esc :, the key and mode windows and remapping are generic.

The interface passes plain data only (ids, paths, panels, pixels), so it can be served across a C ABI or a socket later.

Future work: third-party modes, loaded like engines (a shared library with a versioned ABI or a helper process speaking the same calls), installed under ~/.mouser/modes/; DJ, Director, Debugger and Artist from MODES.md.

Source: docs/modes.md