$ show zellij-org/zellij
Zellij is a high-craft terminal multiplexer written in Rust, offering a client-server architecture with native and web clients. It manages terminals, panes, tabs, and sessions with full VT emulation, mouse support, and a plugin system based on WebAssembly. The server handles panes (tiled, floating, stacked), PTY I/O, scrollback, search, sixel/Kitty graphics, and session serialization for resurrection. Plugins (built-in: bars, strider, configuration, prompt, session-manager, etc.) extend the UI via a widget framework with serialization through ANSI DCS escapes. The client processes keyboard/mouse input, provides a web client with xterm.js and WebSocket transport, and supports remote attach with token-based auth. The codebase is exceptionally well-tested (unit + integration test suites, snapshot-based), with clean trait abstractions (ClientOsApi, ServerOsApi, ZellijPlugin) and a custom build system (xtask). It is not a data/research repository.
The LLM identified 3 files worth highlighting for reuse:
Implements a FocusGroup widget that manages focus across child Widgets (buttons, menus, text inputs, etc.). It handles keyboard and mouse navigation (Tab, Arrow keys, click-to-focus), forwards events to the focused child, and renders the active child. The widget is serializable via custom DCS escape sequences, making it portable across terminal environments. This component demonstrates clean separation of widget logic and could be extracted for any terminal-based UI framework.
Dedicated thread for writing data to PTY file descriptors with backpressure. Maintains a per-pane write queue (HashMap<u32, VecDeque<PendingWrite>>), applies non-blocking writes via try_write, and implements a polling timeout to avoid spinning. Handles partial writes and buffer full conditions gracefully. This pattern solves the common problem of blocking PTY writes in async contexts and is reusable in any application that needs to write to slow file descriptors without blocking the main thread.
Defines core geometry types (Dimension, PaneGeom, Position) used for tiling and floating pane layouts. Dimension supports Percent and Fixed constraints with combine/adjust/resolve methods. PaneGeom provides intersection, contains, and relative-to operations. These types are independent of the rest of Zellij and could be extracted as a standalone crate for any application that needs flexible layout constraint solving (e.g., window managers, dashboard builders).