Architecture
Mimir is a TUI workspace, not a terminal emulator. It owns a renderer, a workspace of sessions, and one view per section. External programs do the work; Mimir decides where they run and how their output is shown.
Layers
src/app Shell: section state, rail, status bar, module layers, overlays
src/core Config, config checks, chords, keymap, prefix state machine
src/modules terminal/ (PTY + split layout), browser/, notes/, system/,
files/, network/, movies/, profile/, project/, vault/, config/
src/services process (PTY, /proc), config/state stores, browser engine,
files, network, movies, profile, project, vault (bw CLI),
repos (git reads), integrations
src/types Shared section and session types
test/ Unit tests and in-process UI testsTwo contracts keep the layers apart:
- Modules receive
ModuleProps(active,config,workspace, notices) and never reach into the shell. A hidden module does no work. - Services are pure data or process adapters. Views call them; they do not import views.
Sections and the rail
src/types/tab.ts keeps navigation declarative:
SECTIONS- every section id and its label.TOP_TABS- the flat top bar: Terminal, System, Files, Browser, Notes, Movies. Their order is the order of theAlt+1…6slots.SYSTEM_TABS- the views inside System: Overview, Processes, Containers and Network. They share the only rail in the app instead of taking top-bar slots.TAB_GLYPHS- one glyph per section, for the rail.
Settings and Identities are sections but not destinations: they are absent from
TOP_TABS, and the palette is the way in (Ctrl+, also opens Settings). src/app/App.tsx owns the active section
and remembers the last System view so System returns to it.
src/app/layout/Workspace.tsx mounts a section on first use, keeps it for five
minutes after you leave, then releases its view to free memory. Terminal is
always mounted so its PTYs are never interrupted.
src/services/project/ holds the Current Project: the selected directory, a
short recent list, and resolution of a bare name or path. It is context, not a
section - ProjectPicker and ProjectPanel are overlays, and new shells take
their cwd from it. Repository facts come from the read-only git adapters in
src/services/repos/repos.ts.
src/services/vault/ and src/modules/vault/ are the Bitwarden integration and
nothing else: the bw CLI is the only boundary, the session key lives in the
service module's memory, and the panel is palette-only. It stores no state and
has no config, so removing the module leaves the rest of the workspace
untouched.
Mounted is not the same as listening. A hidden view keeps its state, but its
keyboard and resize subscriptions are gated on active by
src/app/modules/hooks.ts. Without that gate every visited section leaves a
listener on the renderer and Node reports an emitter leak at the tenth.
Sessions live outside views
A pane is a viewport; a session is a PTY. TerminalWorkspace owns both, so
switching sections never stops a shell or loses scrollback. TerminalSession
pipes bytes between the PTY and OpenTUI's embedded terminal renderable, reads
the live working directory from /proc/<pid>/cwd, and disposes the process
group on exit.
"Active work" is read from /proc/<pid>/task/<pid>/children, ignoring zombies,
and only when a close is requested. There is no idle polling.
Configuration and state
| File | Purpose | Mode |
|---|---|---|
$XDG_CONFIG_HOME/mimir/config.json | User configuration | 0644 |
$XDG_CONFIG_HOME/mimir/themes/*.json | Theme plugins | 0644 |
$XDG_CONFIG_HOME/mimir/profiles.json | Account metadata | 0600 |
$XDG_DATA_HOME/mimir/notes/ | Notes and documents | user default |
$XDG_STATE_HOME/mimir/sessions.json | Saved pane layout | user default |
$XDG_STATE_HOME/mimir/layouts.json | Named layouts | user default |
$XDG_STATE_HOME/mimir/project.json | Current project and recent projects | user default |
$XDG_STATE_HOME/mimir/browser.json | Tabs, history, cookies | 0600 |
The config file is watched at the directory level (editors save by renaming), so an edit applies without a restart. Running shells keep their environment; new sessions and new views use the new values.
Sampling policy
Nothing polls in the background:
- System samples once a second only while visible; the top-task preview samples every three seconds.
- Processes samples every two seconds only while visible and needs two samples before CPU shares are meaningful.
- Containers lists containers and samples
docker statsevery four seconds while visible; logs follow the selection every three seconds. - Network samples once a second only while visible.
- Weather is fetched while System is visible, cached for ten minutes.
- Browser starts its engine lazily and pumps page timers only while visible.
Shutdown
Quitting, SIGTERM, SIGINT, SIGHUP - and renderer destruction on SIGKILL
of the parent - closes every PTY process group, persists the layout, and
restores the terminal. No shells are left behind.
Adding a section
- Add the id to
TabIdand aSECTIONSentry insrc/types/tab.ts. - Put it in
TOP_TABS, or inSYSTEM_TABSif it belongs with the machine views, and give it a glyph. - Add a view under
src/modules/<section>/that acceptsModuleProps. - Mount it in
Workspace.tsxbehind aLayerand use the gated module hooks. - Add a command-palette entry if it needs one, and extend the help overlay.
Alt slots stop at the length of TOP_TABS; System views cycle with [ / ],
and Settings stays off the bar. That keeps the shortcut set honest instead of
inventing chords that silently do nothing. An integration that does not need a
permanent destination belongs in the palette, not in the top bar.
How Mimir is built: the shell, modules, services, PTY sessions, configuration, sampling policy and shutdown.