Lumen
DocsWorking on Lumen

Working on Lumen

Lumen is written in Rust. It draws with GPUI (Zed's GPU UI framework) and runs terminals with alacritty_terminal.

Building

See Building from source for the dependencies. Then:

Shell
cargo run --release
./install.sh             # build and install this checkout, with menu entry and icon
./install.sh --restart   # the same, then restart the running Lumen (closes its shells)

The Rust version is pinned in rust-toolchain.toml, so your build, CI and the releases all use the same one. rustup downloads it the first time you build.

Tests

Shell
cargo test
python3 -m unittest discover -s python/tests   # the Python package
python3 -m unittest discover -s plugins/tests  # the built-in plugins

Pull requests and pushes to main run these, and cargo clippy with warnings as errors, on Linux and macOS (the workflow).

Source layout

File What it does
src/main.rs Actions, fonts, window creation
src/keymap.rs Default shortcuts and the [keys] table
src/api.rs Socket API server: JSON-RPC requests and the event stream
src/cli.rs The lumen msg command
src/info.rs The lumen info command
src/campfire.rs The lumen campfire command
src/plugins/ Plugins, in two files:
mod.rs Plugin manifests, discovery, approvals and update checks
supervisor.rs Running plugins: each one's process, restarts, stopping, logs, settings and commands
src/workspace/ The window, in six files:
mod.rs The window's state, session restore, tab and pane actions, and drawing the whole
titlebar.rs Title bar, tab strip, tab colours and badges, window controls
panes.rs Pane tree, its layout, dividers and each pane's frame
palettes.rs Command palette, theme picker and tab colour picker
plugin_host.rs Starting and reloading plugins, approvals, their prompts, pickers and logs
socket_api.rs Answering the socket API's requests
src/terminal_view.rs Grid rendering, cursor, selection, mouse and key input
src/pty.rs Shell process + alacritty_terminal state and event loop; plugin panes, which a plugin draws instead
src/input.rs Keystroke → escape-sequence encoding, legacy and kitty keyboard protocol
src/links.rs URL and OSC 8 hyperlink detection
src/search.rs Find in scrollback: matching, navigation, highlights
src/scrollbar.rs Scrollbar geometry: the thumb, command marks, and where a click or drag scrolls to
src/vi.rs Keyboard select mode: keys, motions, selections
src/glyphs.rs Per-character glyph cache used to draw the grid
src/boxdraw.rs Box-drawing, block and powerline characters as shapes
src/mouse.rs Mouse event encoding for programs in mouse mode
src/palette.rs Command palette
src/quick.rs The quick terminal: opening, showing and hiding it, and its window hints (X11)
src/hotkey.rs quick-terminal-key: parsing it and grabbing it from every app (X11)
src/theme.rs Theme palettes and 256-colour table
src/settings.rs Settings global and config file
src/session.rs Saved windows and pane layouts (JSON) and loading/sanitising them
src/shell_integration.rs Loading the shell scripts; turning their OSC 133/7 marks into hidden links
src/marks.rs Finding prompts, exit statuses and command output in the grid
shell-integration/ The bash, zsh and fish scripts
assets/icons/ The app icon: Linux hicolor sizes, macOS Lumen.icns, SVG sources
assets/linux/ The .desktop menu entry
assets/screenshot.png The screenshot at the top of the README
assets/screenshots/ The rest of the README's screenshots (how they're taken)
install.sh Build and install this checkout for testing (menu entry, icon, Lumen.app)
scripts/ install-linux.sh (menu entry and icons), bundle-macos.sh (Lumen.app), package-linux.sh (the Linux release tarball), screenshots.py (the product screenshots)
dist/install.sh The installer lumenshell.dev/install serves: downloads a release, checks it and installs it
dist/homebrew/lumen.rb The Homebrew cask; each release fills it in and pushes it to lumenshell/homebrew-tap
.github/workflows/release.yml Builds Linux and macOS releases when a v* tag is pushed (how to release)
.github/workflows/ci.yml Runs Clippy and the tests on every pull request and push to main
examples/ Scripts using lumen msg and the socket API, and example plugins
python/ lumen_plugin, the Python package for plugins (built into Lumen), and its tests
plugins/ The built-in plugins (built into Lumen; turned on in Plugins), and tests
docs/ User guides and reference, linked from the README
vendor/xim-ctext/ A patched copy of the decoder GPUI's X11 input-method client uses, so input methods can't crash Lumen (why)
vendor/gpui/ A patched copy of GPUI that draws on X11 as soon as output arrives instead of waiting for the next frame, sets up the GPU in the background, and gives out a window's X11 id (why)

Screenshots

scripts/screenshots.py takes the README's screenshots the same way every time, at twice the usual pixel density:

Shell
cargo build --release
scripts/screenshots.py              # every scene
scripts/screenshots.py palette find # just these
scripts/screenshots.py --list       # what there is

It runs Lumen on a virtual X display (Xvfb), with Mesa's software Vulkan driver, so nothing appears on your screen and your own config, session and Lumen windows are left alone. Each scene starts a fresh Lumen in a demo home folder:

  • a clean prompt, and USER=you;
  • a small web shop project with a fixed git history;
  • stand-ins for npm that print the same test run and dev server every time;
  • the todo plugin approved, with a seeded todo list.

The pomodoro scene shows a plugin from the registry. Its source is taken from a checkout at ../sn/lumen-pomodoro (or wherever LUMEN_POMODORO says), so nothing is downloaded; without one, that scene is skipped.

The scene lays out tabs and panes with lumen msg, presses keys through XTEST where it needs the palette or a plugin, and saves the window framed: rounded corners, a hairline edge and a soft shadow on a sunset gradient (lavender through rose and coral to sand). The main shot shows a whole 1280×800 workspace; the feature shots are close-ups, a 760×475 window so the feature fills it. The main shot goes to assets/screenshot.png and the rest to assets/screenshots/, including the tab strip twice: tabs.png tight, and tabs-tile.png on a backdrop the size of the close-ups. To add a scene, write a scene_<name> function and list it in SCENES.

It needs Linux with xvfb, imagemagick, python3-xlib, python3-pil and mesa-vulkan-drivers. Copy the results into the website's static/img/ when they change.

Releasing

  1. Set version in Cargo.toml, run cargo build so Cargo.lock follows, and commit.
  2. Tag it and push the tag: git tag v0.2.0 && git push origin v0.2.0.

The release workflow then:

  • builds Linux x86_64 and arm64 and a universal macOS app
  • publishes the release with SHA256SUMS
  • updates the cask in lumenshell/homebrew-tap

The Homebrew step needs a HOMEBREW_TAP_TOKEN secret: a fine-grained token with Contents read and write on that repo.

To sign and notarize the macOS app, so it opens without a Gatekeeper warning, the macOS job needs five secrets: MACOS_CERT_P12 and MACOS_CERT_PASSWORD (the Developer ID Application certificate, as a base64 .p12), and MACOS_NOTARY_KEY, MACOS_NOTARY_KEY_ID and MACOS_NOTARY_ISSUER (an App Store Connect API key). Without them the app gets an ad-hoc signature only.

A tag with a hyphen, like v0.2.0-rc.1, makes a pre-release and leaves Homebrew alone.

To try a build without releasing, run the workflow by hand from the Actions tab. The files are attached to the run.