The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
hn: command panel, Appearance, side bar, machines and local models
Tim5c87885905e7
diff --git a/docs/plans/2026-09-30-001-tui-command-panel-plan.md b/docs/plans/2026-09-30-001-tui-command-panel-plan.mdnew file mode 100644index 000000000..541deaa93--- /dev/null+++ b/docs/plans/2026-09-30-001-tui-command-panel-plan.md@@ -0,0 +1,304 @@+# hn: one command panel, the desktop's features in it, a vertical status bar++Status: **IN PROGRESS** — worktree `autonomous-harness-models-ux`, nothing committed yet.++## Goal++A terminal user of `hn` remembers **one key** (`prefix + Enter`), types what they want+(`theme`, `models`, `link`, `new`…), and drives everything with **arrows + Enter**. Every list+opens in **one panel component** that looks the same everywhere, follows the chosen theme, and+never moves. The TUI reaches parity with the desktop app's features, drawn the TUI way.++**Focus (owner, final): theme → config → machine → local model.** Merge in that order (agent A,+then B, then C); `hn-dev` is updated after each merge for the owner to try.++## Status at 18:33 (overrides the Status column below where they differ)++All three agents' work is merged into this worktree; the full suite passes (243/243, no build+warnings); `hn-dev` (18:32) carries it. Nothing committed.++| Rows | State | How it was checked |+|---|---|---|+| Q1–Q10, Q14–Q15, Q17–Q19, Q21, Q30–Q31, Q34, Q39, B1–B5 | Done | tests; live in an isolated hn |+| Q11, Q28 (local models; switch the current pane's model) | Done — agent C, merged | its 17 tests with fake daemon replies; live shows the offline notes only (no daemon in the isolated run) |+| Q12, Q22, Q29 (Connect machine, Add phone + QR, machines & devices; robots dropped) | Done — agent B, merged | its 14 tests incl. QR encode → draw → decode round trip; live offline states |+| Q13, Q16, Q20, Q36, Q42 (side bar: current machine → windows → nested panes with name + repo; no tab row) | Done | tests; live |+| Q23 (box panes, focus/attention colours) | Done | tests; live |+| Q48 | No round marks anywhere (● ○ ◌): the harnesses' own marks | Done — state marks (spinner for starting, `·` offline), `theme::machine_mark` (`✓`, spinner, `?`, `✗`, `·`), `✓` for a chosen value / an installed package / a model in use |+| Q49 | Launcher bottom block as fzf had it: keys line, `n/m (marked)` + rule, the query with the scopes | Done |+| Q50 | Bigger panel (nine tenths of the window) | Done |+| Q51 | Harnesses list: no state headings, most recent first | Done |+| Q52 | No scrollbars | Done — panel list and preview |+| Q53 | Models: hide a Shared grid with nothing to show ("Nobody was serving here…") | Done — kept while waking or when it can be woken |+| Q54 | Engine icons for the subscription quota in the side bar footer (`✳ 43%`), not in window/pane names | Done — `#{usage_remaining_icons}` |+| Q55 | Commands' "App" group and "Quit" unclear | Done — group "Settings & help": Appearance…, Keyboard shortcuts…, Quick help, Close hn |+| Q56 | Side bar: no `grouped`/`flat` switch, no ` new` / `menu` row | Done |+| Q57 | Idle windows/panes showed a meaningless `·` | Done — no mark when idle, paused, offline or a shell |+| Q58 | Clicking or focusing a pane another window has the keyboard of should take it, not wait for typing | Done — `App::take_if_watching` on focus and window switch; test |+| Q46 | Space around panes: exactly one cell everywhere — at the window's edges as between two boxes, across and down — never doubled, as the desktop app spaces its panes | Done — `App::box_inner` (a cell off each edge without a gap of its own; the side bar's blank edge counts) + `pane_frame::boxed_in`; test `the_space_around_every_box_is_one_cell_across_and_down` (5 layouts); live, bottom status and left bar |+| Q47 | Side bar footer: no time, no "left" | Done |+| Q43 | Launcher's scope strip (`harnesses > commands @ machines…`) at the bottom of the panel | Done — live |+| Q44 | Appearance: drop "Border line" and "Indicators" (tmux.conf keeps them); "Border style" becomes **Borders on/off** | Done — tests |+| Q45 | Side bar footer was a jumble (status-right cut into lines: long session name, one count a line, machine again) | Done — structured: daemon (when down), `Claude 43% left`, counts on one line, time; nothing already shown elsewhere |+| Q33 | **Reverted at the owner's word** (18:40): the shared line made panes look glued, the titles running into each other. Each pane is its own box again, a cell apart, as the reference shows | tests `boxes_frame_each_pane_a_cell_apart…`, `each_pane_is_its_own_box…`; live |+| Q35 (rename window / session) | Done | live, status bar at the bottom and with the side bar |+| Q40 (usage & status line in the side bar's footer, session name first) | Done | tests; live (usage needs a daemon) |+| Q41 (drag the side bar's width, kept in tui.toml) | Done | tests |+| Q37 (accent from the terminal's own palette via OSC 4) | Done in code | tests of the picking; not seen live yet — needs the owner's Ghostty |+| Q38 (New Harness in the panel, chooser in place) | Done | test `the_form_stays_put_when_a_chooser_opens` |+| Commands: tmux commands hidden until you search; hints only in Commands/Appearance; bigger preview | Done | tests; live |+| ↑N/↓N ahead/behind on a pane's repo line | Not possible yet | the fleet data has no ahead/behind field |+| Q8 / step 3 (install as plain `hn`, restart the hn server) | Waiting for the owner's go | — |++## Rules for every step (from the owner's requests)++| # | Rule | Where it is enforced |+|---|------|----------------------|+| R1 | One panel component for every list/modal: centred, dimmed backdrop, **no border** | `tui/src/settings.rs` (`chrome`, `fill`, `backdrop`, `area`) |+| R2 | Fixed position and size — stepping into a section or filtering never moves it | `settings::area` depends on the window only; test `the_panel_does_not_move_when_a_section_opens` |+| R3 | Panel colours follow the current theme (native when none is chosen) | `settings::chrome` from `theme::pane_palette()` — **step 4** |+| R4 | Only arrows + Enter (+ Esc/← back); typing filters | `input.rs` picker keys, `settings::top_down` |+| R5 | A preview shows the whole result and does not jump; hovering changes only its own part | `settings::preview`, `Look::with` |+| R6 | Works as plain `hn` — never a path to a dev binary | install step (see "Shipping") |+| R7 | Verified in the real binary, isolated from the live daemon, before reporting | "How each step is verified" |+| R8 | Ask before every commit and push | — |+| R9 | Never change what a tmux key does; hn's keys go only where tmux has none | `keys.rs` test `every_tmux_key_does_what_tmux_does` |+| R10 | The product never names the outside projects used as design references | grep before every commit |++## Requests, one line each, with status++| # | Request (owner's words, condensed) | Status |+|---|---|---|+| Q1 | Inside a section no options showed | **Done** — refresh no longer rebuilds the settings list (`input.rs` `refill`) |+| Q2 | Remove the border, like the new-harness modal; one ratatui component | **Done** — panel has none; New Harness form lost its border and shares `settings::chrome` |+| Q3 | Modal must not move when entering a section (as prefix+N does) | **Done** — settings/commands/all lists; the New Harness form is placed as if its chooser were open, so opening one never moves it (test `the_form_stays_put_when_a_chooser_opens`) |+| Q4 | Preview shows all sections at once and doesn't refresh away | **Done** — mini hn: panes, borders, title rows, indicators, focus, layout, theme, status bar |+| Q5 | Preview status bar follows the theme | **Done** — preview palette built from the theme (`theme::pane_palette_of`) |+| Q6 | Choosing a theme really recolours hn (not only the accent) | **Done, to verify live** — theme colours stand in for the terminal's (`term_out::set_theme_colours`), pushed to daemons (`push_theme`); "Terminal default" row resets |+| Q7 | Opencode-style palette: one key, type `theme`… | **Done, to verify live** — `prefix + Enter` → Commands panel; Settings opens in place, Esc returns. (Space stays tmux's `next-layout`: no tmux key changes — owner's rule R9.) |+| Q8 | Open it from `hn`, not a path | **Step 3** — install the build as `hn` |+| Q9 | Modal style native / synced with the current theme | **Done** — `settings::chrome_for(pane_palette)`; verified live (panel 38,39,40 → 44,44,47 on a theme change); New Harness uses the same |+| B1 | Bug: typing in a section (e.g. `adwaita` in Theme) left the cursor on the 2nd match | **Done** — panel lists go to the best match on every query change; test |+| B2 | Commands rows show no key for hn's own entries (`New Harness…` should say `C-b N`) | **Done** — `modal::own_key` maps each entry to the command its key runs; test |+| B3 | Tests wrote the real `~/.config/harness/tui.toml` (a new test did, once — restored byte-for-byte) and could write `~/.harness/tui/*` | **Done** — under `cfg(test)` `config::path()` and `app::state_dir()` are a per-process temp folder |+| Q10 | prefix + s (search) in this modal | **Step 5** |+| Q11 | Local models in this modal, with desktop parity | **Step 6** |+| Q12 | Link device section | **Step 7** |+| Q13 | Status bar vertical (left/right) or horizontal; tabs shown; grouped by linked machines; single-pane group | **Step 8** |+| Q14 | Other desktop features brought into the TUI in this modal | **Step 9** — inventory below |+| Q15 | Rename "Status line" section (it is pane title rows) to avoid clashing with the status bar | **Done** — now "Pane titles" |+| Q16 | Vertical bar in the owner's reference style: machines → windows → panes grouped, click to navigate, tmux keys still work | **Step 8** |+| Q17 | Make sure nothing is missed; a detailed plan | This file — every request gets a row here |+| Q18 | Every current list in this panel: prefix + s "Search harnesses", `>` commands, `@` machines, `#` projects, `:` models, `*` store, `?` help | **Done** — every picker is a panel (`@hn-lists fzf` brings fzf's look back); the launcher shows its scope strip; verified live |+| Q20 | Vertical bar: machines, each with its windows grouped; top part = the current window's panes, the selected one highlighted | **Step 8** |+| Q21 | Group rows in the panel under titles, like opencode | **Step 5a** — group headings in `settings::list` (Row.group, never drawn until now) |+| Q22 | Connect machine (as the app has it) and Add phone, the QR code shown like the app's | **Step 7** — same QR payload/link as `add_phone_dialog.dart`, drawn with half-block cells, scannable at the panel's size |+| Q23 | Panes drawn as boxes by default (each pane its own single-line frame, as in the owner's reference); the frame changes colour when the pane is focused or its harness needs permission/input — as the app shows its coloured line | **Step 8** (agent A) |+| Q25 | Owner: the swarm/team conversation view and the notifications work (inbox + settings) are **not needed** | **Dropped** |+| Q27 | Owner: scope is **config + connect machine (core) + local models** only; the rest of step 9 (share, filters/sort, account, usage, about, store) not needed now | **Dropped** — agents D1/D2 stopped, their worktrees and code deleted; nothing of theirs was merged |+| Q29 | Owner: Connect machine and **Add phone** are in the core scope | **Step 7, first priority** (agent B); Robots & dial **dropped** (owner, final) |+| Q30 | Launcher fixes from the owner's screenshot: `@` lands on this machine with its preview; fewer footer keys (Enter, Esc, and "answer" only when the row waits on you); rows ran off the panel (a long right column: project + machine + age) — also seen after `@` then ⌫; blue text | **Done** — right column uses its short form and ≤ ⅓ of the row; headings muted bold, cursor row in text colour bold; regression test `long_rows_stay_in_the_panel_and_at_lands_on_this_machine` |+| Q31 | Pane borders: a full box around each pane, not a shared line in the middle | **Done** — agent A merged; verified live (separate frames, 1-cell gap, focused frame in the accent, others muted) |+| Q32 | Tabs over the panes with the side bar didn't follow the theme | **Superseded by Q36** (the tab row is removed) |+| Q33 | Less space between panes: box frames share one line between neighbours (`┬ ┴ ├ ┤ ┼`), no double border + gap | **Next** (main agent, after agent A's bar rework lands) |+| Q34 | "Settings" is really **Appearance** | **Done** — panel title, Commands entry "Appearance…", `:appearance`, placeholder |+| Q35 | Test rename session / rename window (prompts) with the new chrome | **Next** — live, with the status bar at the bottom and the side bar |+| Q36 | Side bar: no tab row; its top part groups **windows → panes** like the machines part; each pane shows name + repo (project · branch) as before | **In progress** (agent A, in the main worktree) |+| Q37 | Active pane border, current tab and tab text were a fixed teal, not the terminal's theme | **Done in code** — with no theme chosen the accent comes from the terminal's own palette (OSC 4, colours 1-7, picked as a bundled theme's is); fixed teal only if the terminal doesn't answer |+| Q38 | New Harness form sat off-centre; it should look like the menus | **Done in code** — the form is the panel (`settings::area`), a chooser opens in its place |+| Q39 | Pane titles default **top** (off / bottom are the user's choice) | **Done** — default back to top |+| B4 | Commands search: `appe` ranked tmux's set-buffer over Appearance (matched its description) | **Done** — Commands match names and keywords only (`picker.live`) |+| B5 | Tests raced on the global colours (theme/accent) | **Done** — `term_out::colours_lock()` in every test that sets or compares them |+| Q40 | With the side bar the subscription usage metric (status-right) disappeared; show it at the bottom | **In progress** (agent A) — footer block of the bar: usage remaining, fleet counts, daemon, watching, where, clock (status-right's own formats) |+| Q42 | Side bar top: the header is the **current machine's name** (not "panes"); under it the windows, each with its panes nested | **In progress** (agent A) |+| Q41 | The side bar can't be dragged narrower/wider | **In progress** (agent A) — drag the separator (18–36), double-click resets, width kept in tui.toml |+| Q28 | Switch the model of the **current pane** like the app: subscription runs out → open the picker → switch to a local model (download → start → serve → retarget), and back | **Step 6, first priority** (agent C told) |+| Q26 | Home screen (wordmark) follows the theme | **Done** — wordmark already used the theme accent and text the theme's colours; with a theme chosen the screen now stands on the theme's background (`themed_home`); test |+| Q24 | Work split across parallel agents | Agents A (step 8 + Q23), B (step 7 + Q22), C (step 6), D (step 9); step 5 + merge + install in the main worktree |+| Q19 | Keep the preview (in every list that has one) | **Done** — `ui::panel_preview` runs the list's own preview on the right (the live harness screen included); verified live |++## Steps++### 1. Settings panel — done+`hn theme` / `:theme`: sections (Pane titles, Indicators, Border line, Focus, Split direction,+Layout, Theme) → options; Enter applies live and writes `~/.config/harness/tui.toml` `[look]`+(folder created if missing). Theme list starts with **Terminal default**.++### 2. Commands panel — done, to verify live+`prefix + Enter` (unbound in tmux; command `choose-command`). Rows: hn's commands by menu name,+then every tmux command, each with its real key. Enter runs; commands needing words open the `:`+prompt prefilled. **Settings…** turns the same panel into Settings; Esc/← comes back to Commands.++### 3. Ship it as `hn` (Q8)+`hn` → `~/.local/bin/harness tui` → `~/.harness/bin/harness-tui`. Install the release build there+the way earlier dev builds were (keep a `harness-tui.bak.<stamp>`; copy then `mv`, never overwrite+the running file in place). The running `--local-server` keeps the old binary until it restarts —+**ask the owner before restarting it** (it serves their live harnesses). Check `hn --version`+and that the automatic updater will not immediately put the release build back.++### 4. Panel colours follow the theme (Q9, R3)+`settings::chrome()` today uses fixed greys (25/25/25, 247/247/247). Derive from+`theme::pane_palette()` (which now follows `@hn-theme`): panel = `surface` lifted toward+`foreground` a few %, muted = `pal.muted`, selected row = `inactive_surface`, accent =+`theme::accent()`, backdrop = `canvas` dimmed. New Harness uses the same `chrome`, so it follows too.+Test: two themes → two different panel surfaces; NO_COLOR still readable.++### 5. Search (prefix + s) and the other lists in the panel (Q10, Q3, Q18, Q19)+The launcher's header shows its scopes as today (`Search harnesses · > commands · @ machines ·+# projects · : models · * store · ? help`); typing a scope character switches the list **inside+the same panel** (same place, same size) and the right side shows that list's preview.+`choose-tree -s` / the launcher (`PickerKind::Open` and its `@ # > : * ?` scopes) drawn by+`settings::draw` instead of fzf full-screen: list left, the **live pane preview** right (reuse+`ui::preview` into the panel's right rect). Keep fzf semantics: scopes, marks (Tab), C-v/C-x/M-…+keys, the "said" search, live re-ranking. Mouse: rows, wheel, preview scroll. Then Machines,+Projects, Store, Layout, Help, Keys, Buffers → one list at a time, each with a test.+Also: the New Harness side chooser keeps the form where it is (no re-centre).+Keep an escape hatch: users with `FZF_DEFAULT_OPTS` set keep fzf's look? — **open question O1**.++### 6. Local models in the panel (Q11) — desktop parity+From the models survey (desktop file:line in the survey notes):+- Rows by section: **This computer** (memory/disk line), **Shared · <grid>**, **Subscriptions**,+ **APIs**; each row: name, size, tok/s (measured or `~` estimate), state word+ (Get / Downloading n% / Running / ● In use).+- Preview: size, download + free disk, memory fits/needs, speed, **context window**, params, quant,+ machine, state, the Enter sentence.+- Actions: Enter = **Use** (download → start → wait → `agent_retarget {agentId, gridModel, gridName}`),+ `^S` stop; one local model runs at a time; progress from `operation`.+- Polling: every 4 s while busy/visible, else 60 s; `grid_models_changed` push.+- Per-pane model switch (`agent_retarget`, `clearGrid`) and the pane's "Starting up…" note.+- Resting shared sections: "Show models" wakes (`grid_models_list {wake}`), re-read 5 s up to 60 s.+- Backend: `grid_fleet_models_list`, `grid_fleet_model_{download,start,stop}`, `grid_models_list`,+ `agent_retarget`, `api_connections`.++### 7. Link device (Q12) — a **Machines & devices** view in the panel+Today the TUI can only link *to* a machine (M-l → password prompt → `harness link connect`).+Everything else is missing. Each row below is a Commands entry and a section in the panel:+- **This computer**: remote password status / set / change / clear —+ `harness remote-password {status --json | set --stdin --json | clear --json}`.+- **Linked from here**: list, refresh, unlink — `harness link list`, `harness link unlink <id>`.+- **Link a machine**: password prompt with the CLI's progress stages (connecting → deriving key →+ exchanging → verifying) from `harness link connect <id> --stdin --json` NDJSON.+- **Your machines**: online/offline, rename (`PATCH /api/machines/:id {name}`), remove from account+ (`DELETE /api/machines/:id`), and **Add a machine** (copyable install / login / password steps).+- **Add phone**: one-time sign-in code (`POST /api/auth/handoff`) + QR drawn with half-blocks;+ pairing via `phone_pair {code}`.+- ~~**Robots / dial**~~ — dropped by the owner (Q29): `harness autonomous-device {status|list|discover|pair --code-stdin --device|revoke}+ --json`; dial settings via `dial_settings`.+Writes (set password, unlink, remove, pair) ask y/n in the panel first.++### 8. Status bar: vertical or horizontal (Q13, Q15, Q16)+Reference: the owner's screenshot at the start of this task. What it draws, and what hn takes:++```+spaces │ ▆▆▆▆ + ← tab strip: active tab a filled accent block, + new+○ autonomous-grid │ ┌───────────────┐┌───────────────┐+ main │ │ pane ││ pane (active: │ ← thin single borders, active in accent+· ishot │ │ ││ accent border)│+○ autonomous-harness │ │ ││ │+ feat/grid-harnes… ↑1 │+▌autonomous-harness │ ← current row: filled highlight+new ● menu │ ← divider: new (harness) · menu (the Commands panel)+agents grouped │ ← toggle: grouped / flat+○ autonomou… · Omarchy │ ← name · machine, dim+ claude │ ← engine, dim second line+ « │ ← collapse the bar+```++hn's version (setting **Status bar**: `bottom` · `top` · `left` · `right`; `left`/`right` = the bar):+- Owner's words (Q20): "vertical will show machine, and group all the windows in that machine, and+ the vertical on top will show the single pane selected in that window."+- **Top section — this window's panes**: one row per pane of the current window (`1 claude`,+ `2 codex`…, engine + state dim), the focused pane highlighted. Click = focus that pane.+- **Machines section — machine → its windows**: each linked machine (● online / ○ away) as a+ heading, its windows (swarms) grouped under it; a window with panes on several machines appears+ under each of them. The current window highlighted. Click = select that window.+- **Divider**: `new` (New Harness) · `● menu` (Commands panel, = prefix + Enter).+- **Bottom section — harnesses**, `grouped` by machine (toggle `grouped` / flat by attention):+ name · machine (dim), engine + state (dim) on the second line; needs-you first.+- **Click** any row: machine → its first window; window → select it; pane → focus it; harness →+ open it (as the launcher does). Wheel scrolls the bar. `«` collapses it to a 2-column strip.+- **tmux keys keep working**: prefix n/p/0-9/w/s/o/arrows move the highlight with the real focus.+- Tab strip at the top (option **Tabs**: on/off), active tab filled with the accent, `+` = new window.+- Width 24 columns (O2). The body shrinks by the bar: `App::body`, `window_area`, mouse+ hit-testing, `status_ranges`, pane sizes (`fit_panes`), and the panel's `area` all follow.+- The preview in Settings draws the bar. "Status line" section renamed **Pane titles** — done.++Drawing rules to match (from studying the reference's source):+1. Bar 26 columns (clamp 18–36); its last column is a `│` separator in a dim surface colour that is+ also the resize handle (drag; double-click resets). Content uses width − 1.+2. Two sections split 50/50 (draggable 10–90 %, each ≥ 3 rows): top list, then a full-width `─`+ rule (the drag divider), then the bottom list.+3. Section header row: ` title` bold in the muted colour, a blank row after it; the bottom header+ has a clickable right-aligned mode label (`grouped` / `priority`).+4. Entries are 2 lines: line 1 at x+1 `ICON NAME`, line 2 at x+3 secondary text; 2 columns kept+ free on the right for a `▸`/`▾` group toggle. Children of a group use `├─ ` / `└─ ` prefixes.+5. Glyphs: `●` working/blocked/done, `○` idle, `·` unknown; colours yellow / red / teal / green /+ muted. Separator between parts ` · ` in the muted colour.+6. Name: text + bold when focused, else a softer text; second line accent-ish when focused, else+ muted. `↑N` green, `↓N` red, hidden when 0.+7. Highlight fills the whole 2-line entry: focused → active-row background; keyboard cursor →+ selection background.+8. Truncate by display width with `…`; share width between parts, dropping the leftmost first.+9. Footer row of the top section: ` new` left, `menu` right (a `●` accent before it when there is+ a notice). `«` at the bottom right collapses the bar to a 4-column rail (`n` + glyph per row,+ `»` to expand).+10. Tabs: one row; each tab label + 4 wide (min 8), centred label, 1-column gaps; active = filled+ accent with the panel colour as text; inactive = surface background, muted text; ` + ` after.+11. Pane borders: merged junction glyphs; accent where a cell touches the focused pane, muted+ elsewhere; title ` label ` in the top border, accent + bold when focused.+12. Mouse: press + release without moving = focus (window / tab); moving ≥ 1 cell = reorder drag;+ a harness row focuses its pane anywhere; wheel scrolls lists by one entry and switches tabs over+ the tab row; right-click opens a context menu (rename / close / new).+13. The bar keeps no focus of its own: it follows the real focus and scrolls the focused entry+ into view when focus changes.+14. Colours come from one palette (accent, panel, active row, selection, surfaces, muted, text,+ green/yellow/red/teal); the terminal-default theme uses ANSI colours + the terminal's background.++### 8a. Saved keys hide new default keys (found while testing step 2)+The hn server saves its **whole** key table in `~/.harness/tui/sessions-<name>.server.json` and+`server::take` → `keys_from` replaces the defaults with it. So an existing user never gets a key hn+adds later. **Done**: `Keymap::migrate_defaults` adds hn's new keys (today: Enter →+`choose-command`) where the saved table has nothing on that key; a key the user bound is left alone.+Also: tests read the real `$HOME` state file (pre-existing) — point tests at a temp `HOME`.++### 9. Other desktop features (Q14) — **DROPPED for now by the owner (Q25, Q27)**; kept as a list for later+From the desktop survey, in order of what a terminal user misses most:+1. **Share a harness**: invite by email for N days, list/remove people, public/private link —+ `harness_share_{list,invite,remove,link}`; **Shared with you** list.+2. **Notification inbox**: finished / failed / needs-input with read state (`agent_seen`,+ `app_unread`), not only questions; **Notifications** settings rows (on-screen, sound, OS) instead+ of the `HARNESS_TUI_NOTIFY` env var.+3. **Harnesses filtered and sorted**: needs input / running / paused filters; sort by recent / name /+ machine / project (the desktop's Harnesses panel).+4. **Account**: `harness auth status --json`, login, logout.+5. **Usage**: beyond quota — harnesses started, time, turns, tokens by model/project.+6. **About**: version, update check status.+7. **Store**: remove, ratings/reviews.+8. **Swarm conversation** (`team` RPC), **Experimental** flags (`/api/experimental-settings`).+Not for a terminal: wallpaper/background, UI font, flash firmware.++## How each step is verified (R7)++1. Unit tests for rows/keys/geometry; one test through `ui::draw` on a `TestBackend`.+2. Full suite once: `cargo test --release --color=never > scratchpad/tui-tests.txt`.+3. `cargo build --release`, then the real binary in a private tmux socket+ (`tmux -L claude-settings`), env `-u TMUX`, `PORT=19999` (no daemon — shows "daemon down"),+ `HOME`/`XDG_CONFIG_HOME` = scratch dir, `HN_SOCKET_NAME=claudetest`, `HARNESS_TUI_DESK=off`.+ Drive with `send-keys`, read with `capture-pane`; kill only the `claudetest` server after.+4. Steps that need the daemon (models, link device): read-only calls first; anything that writes+ (download, start, retarget, link) only with the owner's go-ahead.++## Open questions++- **O1** Should the launcher (prefix + s) always use the panel, or keep fzf's full-screen look+ when the user has `FZF_DEFAULT_OPTS` set?+- **O2** Vertical bar width: fixed (24 cols like the app) or a setting?+- **O3** ~~Replacing `C-b Space`~~ — decided: never change a tmux key; the panel is `C-b Enter`.+- **O4** A chosen theme recolours panes via the daemon's `theme_set` — the desktop app uses the same+ call, so the last one to set it wins on a shared machine. OK?++## Survey notes++Desktop model features vs TUI: 20 features, TUI has 2 fully (New Harness model choice, usage),+partial: local model list/start/download/stop, Store packages; missing: pane model switch, Models+panel, Model Manager, shared sections, wake, live push, onboarding, "New" badge, details preview.diff --git a/tui/Cargo.lock b/tui/Cargo.lockindex 8c898fe5b..a2fb205eb 100644--- a/tui/Cargo.lock+++ b/tui/Cargo.lock@@ -528,6 +528,12 @@ version = "1.0.7"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"+[[package]]+name = "foldhash"+version = "0.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"+[[package]]name = "foldhash"version = "0.2.0"@@ -583,6 +589,34 @@ dependencies = ["slab",]+[[package]]+name = "g2gen"+version = "1.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c5a7e0eb46f83a20260b850117d204366674e85d3a908d90865c78df9a6b1dfc"+dependencies = [+ "g2poly",+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "g2p"+version = "1.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "539e2644c030d3bf4cd208cb842d2ce2f80e82e6e8472390bcef83ceba0d80ad"+dependencies = [+ "g2gen",+ "g2poly",+]++[[package]]+name = "g2poly"+version = "1.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "312d2295c7302019c395cfb90dacd00a82a2eabd700429bba9c7a3f38dbbe11b"+[[package]]name = "generic-array"version = "0.14.7"@@ -626,8 +660,10 @@ dependencies = ["flate2","futures-util","libc",+ "qrcodegen","ratatui","regex",+ "rqrr","serde","serde_json","tokio",@@ -638,6 +674,17 @@ dependencies = ["uuid",]+[[package]]+name = "hashbrown"+version = "0.15.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"+dependencies = [+ "allocator-api2",+ "equivalent",+ "foldhash 0.1.5",+]+[[package]]name = "hashbrown"version = "0.16.1"@@ -646,7 +693,7 @@ checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"dependencies = ["allocator-api2","equivalent",- "foldhash",+ "foldhash 0.2.0",][[package]]@@ -657,7 +704,7 @@ checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"dependencies = ["allocator-api2","equivalent",- "foldhash",+ "foldhash 0.2.0",][[package]]@@ -847,6 +894,15 @@ version = "0.4.34"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"+[[package]]+name = "lru"+version = "0.12.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38"+dependencies = [+ "hashbrown 0.15.5",+]+[[package]]name = "lru"version = "0.18.5"@@ -1199,6 +1255,12 @@ dependencies = ["unicode-ident",]+[[package]]+name = "qrcodegen"+version = "1.8.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4339fc7a1021c9c1621d87f5e3505f2805c8c105420ba2f2a4df86814590c142"+[[package]]name = "quote"version = "1.0.47"@@ -1280,7 +1342,7 @@ dependencies = ["hashbrown 0.17.1","itertools","kasuari",- "lru",+ "lru 0.18.5","palette","serde","strum",@@ -1391,6 +1453,16 @@ version = "0.8.11"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"+[[package]]+name = "rqrr"+version = "0.9.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f2260da7f69877ba68c49a0c2d9946829848236c708dd40d2a6baf8c868ee887"+dependencies = [+ "g2p",+ "lru 0.12.5",+]+[[package]]name = "rustc_version"version = "0.4.1"diff --git a/tui/Cargo.toml b/tui/Cargo.tomlindex 95a74b36b..8d3864e30 100644--- a/tui/Cargo.toml+++ b/tui/Cargo.toml@@ -19,6 +19,12 @@ unicode-width = "0.2.2"unicode-segmentation = "1.13"libc = "0.2"uuid = { version = "1.26.1", features = ["v4"] }+# Add phone: the pairing link as a QR code, drawn with half-block characters.+qrcodegen = "1.8"++[dev-dependencies]+# Reads the drawn QR code back, so a test proves the phone would get the exact link.+rqrr = { version = "0.9", default-features = false }# Retain tmux pane attributes unsupported by the upstream renderer.[patch.crates-io]diff --git a/tui/THIRD_PARTY_NOTICES.md b/tui/THIRD_PARTY_NOTICES.mdindex ab9542926..4742d1c22 100644--- a/tui/THIRD_PARTY_NOTICES.md+++ b/tui/THIRD_PARTY_NOTICES.md@@ -64,7 +64,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.```-## Rust crates (242)+## Rust crates (250)| Crate | Version | Licence ||---|---|---|@@ -130,6 +130,7 @@ THE SOFTWARE.| fixedbitset | 0.4.2 | MIT/Apache-2.0 || flate2 | 1.1.10 | MIT OR Apache-2.0 || fnv | 1.0.7 | Apache-2.0 / MIT |+| foldhash | 0.1.5 | Zlib || foldhash | 0.2.0 | Zlib || futures-core | 0.3.34 | MIT OR Apache-2.0 || futures-io | 0.3.34 | MIT OR Apache-2.0 |@@ -137,9 +138,13 @@ THE SOFTWARE.| futures-sink | 0.3.34 | MIT OR Apache-2.0 || futures-task | 0.3.34 | MIT OR Apache-2.0 || futures-util | 0.3.34 | MIT OR Apache-2.0 |+| g2gen | 1.2.2 | MIT/Apache-2.0 |+| g2p | 1.2.2 | MIT/Apache-2.0 |+| g2poly | 1.2.2 | MIT/Apache-2.0 || generic-array | 0.14.7 | MIT || getrandom | 0.3.4 | MIT OR Apache-2.0 || getrandom | 0.4.3 | MIT OR Apache-2.0 |+| hashbrown | 0.15.5 | MIT OR Apache-2.0 || hashbrown | 0.16.1 | MIT OR Apache-2.0 || hashbrown | 0.17.1 | MIT OR Apache-2.0 || heck | 0.5.0 | MIT OR Apache-2.0 |@@ -166,6 +171,7 @@ THE SOFTWARE.| litrs | 1.0.0 | MIT OR Apache-2.0 || lock_api | 0.4.14 | MIT OR Apache-2.0 || log | 0.4.34 | MIT OR Apache-2.0 |+| lru | 0.12.5 | MIT || lru | 0.18.5 | MIT || mac_address | 1.1.8 | MIT OR Apache-2.0 || memchr | 2.8.3 | Unlicense OR MIT |@@ -203,6 +209,7 @@ THE SOFTWARE.| portable-atomic | 1.15.0 | Apache-2.0 OR MIT || powerfmt | 0.2.0 | MIT OR Apache-2.0 || proc-macro2 | 1.0.107 | MIT OR Apache-2.0 |+| qrcodegen | 1.8.0 | MIT || quote | 1.0.47 | MIT OR Apache-2.0 || r-efi | 5.3.0 | MIT OR Apache-2.0 OR LGPL-2.1-or-later || r-efi | 6.0.0 | MIT OR Apache-2.0 OR LGPL-2.1-or-later |@@ -221,6 +228,7 @@ THE SOFTWARE.| regex | 1.13.1 | MIT OR Apache-2.0 || regex-automata | 0.4.18 | MIT OR Apache-2.0 || regex-syntax | 0.8.11 | MIT OR Apache-2.0 |+| rqrr | 0.9.3 | (MIT OR Apache-2.0) AND ISC || rustc_version | 0.4.1 | MIT OR Apache-2.0 || rustix | 1.1.5 | Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT || rustix-openpty | 0.2.0 | Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT |@@ -2064,7 +2072,7 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHERDEALINGS IN THE SOFTWARE.```-**foldhash 0.2.0**+**foldhash 0.1.5, foldhash 0.2.0**```Copyright (c) 2024 Orson Peters@@ -2207,7 +2215,7 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHERDEALINGS IN THE SOFTWARE.```-**hashbrown 0.16.1, hashbrown 0.17.1**+**hashbrown 0.15.5, hashbrown 0.16.1, hashbrown 0.17.1**```Copyright (c) 2016 Amanieu d'Antras@@ -2859,7 +2867,7 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHERDEALINGS IN THE SOFTWARE.```-**lru 0.18.5**+**lru 0.12.5, lru 0.18.5**```MIT License@@ -4357,3 +4365,79 @@ freely, subject to the following restrictions:3. This notice may not be removed or altered from any source distribution.```++**g2gen 1.2.2, g2p 1.2.2, g2poly 1.2.2**++```+The MIT License (MIT)+Copyright (c) 2018 Moritz 'WanzenBug' Wanzenböck++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE+OR OTHER DEALINGS IN THE SOFTWARE.+```++**qrcodegen 1.8.0**++```+MIT License++Copyright (c) Project Nayuki++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+```++**rqrr 0.9.3**++```+Copyright 2019 Moritz Wanzenböck <[email protected]>++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject+to the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.+```diff --git a/tui/scripts/gen_terminal_themes.py b/tui/scripts/gen_terminal_themes.pynew file mode 100644index 000000000..df11b6933--- /dev/null+++ b/tui/scripts/gen_terminal_themes.py@@ -0,0 +1,143 @@+#!/usr/bin/env python3+"""Regenerate `src/terminal_themes.rs` from a terminal's bundled theme files.++A terminal ships ~460 theme config files: a 16-colour palette plus background/foreground.+This script reads them from a directory and writes them into the TUI as a static Rust+array, so `hn theme` can preview every one without needing the source terminal installed.++Usage:+ python3 tui/scripts/gen_terminal_themes.py [THEMES_DIR]++The themes directory defaults to Ghostty's on macOS (the 463 themes hn ships with).+On other platforms pass the path to any directory of `theme`-style config files.+"""++import os+import re+import sys++DEFAULTS = [+ "/Applications/Ghostty.app/Contents/Resources/ghostty/themes",+ "/usr/share/ghostty/themes",+]+++def hex_to_rgb(h: str) -> tuple[int, int, int]:+ h = h.lstrip("#")+ return (int(h[0:2], 16), int(h[2:4], 16), int(h[4:6], 16))+++def esc(s: str) -> str:+ return s.replace("\\", "\\\\").replace('"', '\\"')+++def read_theme(path: str) -> tuple[str, str, str, dict[int, str]]:+ """Return (name, background, foreground, palette)."""+ name = os.path.basename(path)+ bg = fg = None+ pal: dict[int, str] = {}+ with open(path, encoding="utf-8") as f:+ for line in f:+ line = line.strip()+ m = re.match(r"^background\s*=\s*(\S+)$", line)+ if m:+ bg = m.group(1)+ continue+ m = re.match(r"^foreground\s*=\s*(\S+)$", line)+ if m:+ fg = m.group(1)+ continue+ m = re.match(r"^palette\s*=\s*(\d+)\s*=\s*(\S+)$", line)+ if m:+ pal[int(m.group(1))] = m.group(2)+ return name, bg, fg, pal+++def main() -> int:+ theme_dir = None+ for arg in sys.argv[1:]:+ if os.path.isdir(arg):+ theme_dir = arg+ break+ if theme_dir is None:+ for d in DEFAULTS:+ if os.path.isdir(d):+ theme_dir = d+ break+ if theme_dir is None:+ print("error: could not find a themes directory", file=sys.stderr)+ return 1++ themes = []+ for fn in sorted(os.listdir(theme_dir)):+ path = os.path.join(theme_dir, fn)+ if not os.path.isfile(path):+ continue+ name, bg, fg, pal = read_theme(path)+ if bg is None or fg is None:+ continue+ themes.append((name, bg, fg, pal))++ lines = []+ lines.append("//! hn's bundled terminal colour themes. Each theme is a terminal's 16-colour")+ lines.append("//! palette plus its background and foreground, used by the `hn theme` picker.")+ lines.append("//!")+ lines.append("//! Generated by scripts/gen_terminal_themes.py — do not hand-edit.")+ lines.append("")+ lines.append("/// One bundled terminal theme.")+ lines.append("#[derive(Clone, Copy, Debug)]")+ lines.append("pub struct TerminalTheme {")+ lines.append(" pub name: &'static str,")+ lines.append(" pub background: [u8; 3],")+ lines.append(" pub foreground: [u8; 3],")+ lines.append(" /// ANSI 0-15, in palette order.")+ lines.append(" pub palette: [[u8; 3]; 16],")+ lines.append("}")+ lines.append("")+ lines.append("/// Every bundled theme, sorted by name.")+ lines.append("pub static TERMINAL_THEMES: &[TerminalTheme] = &[")+ for name, bg, fg, pal in themes:+ bgc = hex_to_rgb(bg)+ fgc = hex_to_rgb(fg)+ palc = [hex_to_rgb(pal.get(i, "#000000")) for i in range(16)]+ lines.append(" TerminalTheme {")+ lines.append(f' name: "{esc(name)}",')+ lines.append(f" background: [{bgc[0]}, {bgc[1]}, {bgc[2]}],")+ lines.append(f" foreground: [{fgc[0]}, {fgc[1]}, {fgc[2]}],")+ lines.append(" palette: [")+ for p in palc:+ lines.append(f" [{p[0]}, {p[1]}, {p[2]}],")+ lines.append(" ],")+ lines.append(" },")+ lines.append("];")+ lines.append("")+ lines.append("#[cfg(test)]")+ lines.append("mod tests {")+ lines.append(" use super::*;")+ lines.append(" #[test]")+ lines.append(" fn terminal_themes_are_parseable_and_nonempty() {")+ lines.append(" assert!(TERMINAL_THEMES.len() > 400);")+ lines.append(" for t in TERMINAL_THEMES {")+ lines.append(" assert!(!t.name.is_empty());")+ lines.append(" }")+ lines.append(" }")+ lines.append(" #[test]")+ lines.append(" fn palette_has_16_entries() {")+ lines.append(" for t in TERMINAL_THEMES {")+ lines.append(" assert_eq!(t.palette.len(), 16);")+ lines.append(" }")+ lines.append(" }")+ lines.append("}")+ lines.append("")++ here = os.path.dirname(os.path.abspath(__file__))+ out = os.path.join(here, "..", "src", "terminal_themes.rs")+ with open(out, "w", encoding="utf-8") as f:+ f.write("\n".join(lines))++ print(f"wrote {len(themes)} themes to {os.path.normpath(out)}")+ return 0+++if __name__ == "__main__":+ sys.exit(main())diff --git a/tui/src/app.rs b/tui/src/app.rsindex f1603ac65..7d7c42b2a 100644--- a/tui/src/app.rs+++ b/tui/src/app.rs@@ -177,7 +177,16 @@ pub fn options_from(row: &Value) -> std::collections::BTreeMap<String, String> {/// Where a server name's (-L) sessions are kept between clients.pub fn sessions_path(name: Option<&str>) -> std::path::PathBuf {let name = name.map(str::to_string).or_else(|| std::env::var("HN_SOCKET_NAME").ok()).filter(|n| !n.is_empty()).unwrap_or_else(|| "default".into());- std::path::PathBuf::from(std::env::var("HOME").unwrap_or_default()).join(".harness").join("tui").join(format!("sessions-{name}.json"))+ state_dir().join(format!("sessions-{name}.json"))+}++/// Where hn keeps its state (~/.harness/tui). Tests never read or write the real one: theirs is+/// a folder of their own.+pub fn state_dir() -> std::path::PathBuf {+ #[cfg(test)]+ return std::env::temp_dir().join(format!("hn-test-{}", std::process::id())).join("tui");+ #[allow(unreachable_code)]+ std::path::PathBuf::from(std::env::var("HOME").unwrap_or_default()).join(".harness").join("tui")}/// The agent a reply is about (`agentId`).@@ -517,8 +526,8 @@ pub struct App {pub new_harness_draft: Option<Box<crate::new_harness::Form>>,/// Each harness's selectable models (`models_list`), for ⌥I.pub models: HashMap<(String, String), Vec<Value>>,- /// Each machine's local models (the grid): downloaded, running, available.- pub local_models: HashMap<String, Vec<Value>>,+ /// ── models: the Models view's replies (local models, grids, APIs) and a Use under way ──+ pub models_view: crate::models::Models,/// Each machine's last measured round trip (the live roster request), for `@`.pub rtt: HashMap<String, Duration>,pub homes: HashMap<String, String>,@@ -780,6 +789,13 @@ pub struct App {/// `#()` commands in formats: their last output, run again every status-interval.pub jobs: std::cell::RefCell<std::collections::HashMap<String, crate::format::Job>>,pub fleet_marked: bool,+ // ── status bar ──+ /// The status bar down a side: where its entries were drawn (what a click there does), its+ /// lists' scroll, and whether it is folded to a rail.+ pub bar: crate::bar::State,+ // ── machines & devices ──+ /// The panel's machine and device views: what the CLI and the daemon last said (devices.rs).+ pub devices: crate::devices::Devices,}impl App {@@ -960,7 +976,7 @@ impl App {dsh: HashMap::new(),new_harness_draft: None,models: HashMap::new(),- local_models: HashMap::new(),+ models_view: Default::default(),rtt: HashMap::new(),homes: HashMap::new(),last_focus_sent: None,@@ -984,6 +1000,8 @@ impl App {key_table: None,key_table_until: None,fleet_marked: false,+ bar: Default::default(),+ devices: Default::default(),}}@@ -1331,6 +1349,8 @@ impl App {fn on_frame(&mut self, machine_id: &str, ty: &str, payload: Value) {// The dial's frames come from this computer's daemon, to the windows on it.if machine_id == self.fleet.local_id && crate::dial::on_frame(self, ty, &payload) { return }+ // ── models: a message to a resting model starts its pane's "Starting up…" ──+ crate::models::watch_turn(self, machine_id, ty, &payload);match ty {"agent_synced" | "agent_created" | "agent_renamed" => {let row = payload.get("agent").cloned().unwrap_or(payload.clone());@@ -1565,6 +1585,8 @@ impl App {}}}+ // ── models: the daemon's picture of the grids changed — the whole list, pushed ──+ "grid_models_changed" => crate::models::on_push(self, machine_id, &payload),_ => {}}}@@ -3564,11 +3586,15 @@ impl App {let (w, h) = self.tabs.get(self.active).and_then(|t| t.root.as_ref().map(|r| r.size()).or(t.size)).unwrap_or_else(|| self.default_size());return Rect::new(0, 0, w, h);}+ // The bar down a side takes its columns.+ if let Some(bar) = self.bar_rect() { return Rect::new(if bar.x == 0 { bar.width } else { 0 }, 0, self.size.0.saturating_sub(bar.width), self.size.1) }Rect::new(0, if self.status_top { n } else { 0 }, self.size.0, self.size.1.saturating_sub(n))}/// tmux's status option: how many status lines (off, on, 2 … 5).pub fn status_lines(&self) -> u16 {+ // (The bar down a side is the status line: none across the bottom as well.)+ if self.bar_side().is_some() { return 0 }let lines = match self.options.get("status", "", None).as_deref() { Some("off") => 0, Some("2") => 2, Some("3") => 3, Some("4") => 4, Some("5") => 5, _ => 1 };// tmux's CLIENT_STATUSOFF: keep a pane row when the terminal cannot fit the status.if !self.headless && self.size.1 <= lines { 0 } else { lines }@@ -3678,8 +3704,8 @@ impl App {self.options.get("mode-keys", &tab, self.focused()).as_deref() != Some("vi")}- /// A window's pane-border-status as it shows: hn's default (top) where it has several panes;- /// once you set it yourself, as tmux has it — on a lone pane too, and bottom or off.+ /// A window's pane-border-status: the classic (default) look has none — a plain line+ /// between panes; the opt-in "panes" look and tmux's own show pane titles instead.pub fn pane_status(&self, tab: &Tab) -> layout::Status {// (A window one row tall: no room for a title row — the row is the pane's, as tmux shows it.)if !self.headless && self.body().height < 2 { return layout::Status::Off }@@ -3698,7 +3724,8 @@ impl App {/// The program's actual viewport, shared by drawing, PTY resizing and mouse coordinates.pub fn content_of(&self, tab: &Tab, r: Rect) -> Rect {- if self.options.pane_look() { crate::pane_frame::frame(r, self.window_area(tab), self.pane_status(tab)).content }+ if self.options.pane_look() { crate::pane_frame::frame(r, self.window_area(tab), self.box_inner(tab), self.pane_status(tab)).content }+ else if self.options.box_panes() { crate::pane_frame::boxed_in(r, self.window_area(tab), self.box_inner(tab), self.pane_status(tab)).content }else { self.layout_content_of(tab, r) }}@@ -3760,6 +3787,14 @@ impl App {self.sync_titles();self.fit_panes();self.refresh_pane_info(pane);+ self.take_if_watching(pane);+ }++ /// A pane you come to (a click, a key, the bar) that another window has the keyboard of is+ /// yours at once — as typing in it would make it — not "Take control" first.+ pub fn take_if_watching(&mut self, pane: u64) {+ let Some(p) = self.panes.get(&pane) else { return };+ if matches!(p.phase, Phase::Watching(_)) && !p.read_only && !p.opening { self.open_stream(pane, true) }}/// A machine's first roster since hn started, read against when you last looked at each of@@ -3799,7 +3834,7 @@ impl App {/// seen.json's path.fn seen_path() -> std::path::PathBuf {- std::path::PathBuf::from(std::env::var("HOME").unwrap_or_default()).join(".harness").join("tui").join("seen.json")+ state_dir().join("seen.json")}/// When you last looked at each harness, from the run before (the first run starts the clock).@@ -4248,8 +4283,14 @@ impl App {placed}- /// Wide tiles split left|right, tall ones top/bottom — the way a tiling window manager does.+ /// Wide tiles split left|right, tall ones top/bottom — the way a tiling window manager does —+ /// unless `@hn-layout` (`[look].layout_orientation`) pins it to vertical or horizontal.pub fn smart_dir(&self) -> Dir {+ match self.options.look_orientation() {+ "vertical" => return Dir::Vertical,+ "horizontal" => return Dir::Horizontal,+ _ => {}+ }let Some(focus) = self.focused() else { return Dir::Horizontal };let rect = self.rects.iter().find(|(id, _)| *id == focus).map(|(_, r)| *r).unwrap_or(self.body());if rect.width as f32 >= rect.height as f32 * 2.2 { Dir::Horizontal } else { Dir::Vertical }@@ -4725,6 +4766,7 @@ impl App {if changed { self.tabs[index].touch(); self.alert(index, ACTIVITY) }if let Some(f) = self.tabs[index].focus { self.seen(f) }self.fit_panes();+ if let Some(f) = self.tabs[index].focus { self.take_if_watching(f) }}}@@ -5004,6 +5046,110 @@ impl App {self.arrange_tab(index, layout::Named::of(preset));}+ /// `tui.toml`'s `[look]` table: set each choice as a global option, so `hn show` reflects it+ /// and the daemon (which reads options, not the file) keeps the running look. The file is a+ /// startup default; `hn set -g` afterward still wins.+ pub fn apply_look(&mut self, look: Option<&crate::config::Look>) {+ let Some(look) = look else { return };+ let global = crate::options::SetFlags { global: true, ..Default::default() };+ for (name, value) in look.assignments() {+ let _ = self.options.set(&name, Some(value.as_str()), &global, "", 0);+ }+ // ── status bar ──+ if let Some(b) = look.status_bar.as_deref().filter(|b| matches!(*b, "top" | "bottom")) { self.status_top = b == "top" }+ self.sync_accent();+ }++ /// Push the `@hn-accent` option (as the look holds it) to the colour layer, so `theme::accent()`+ /// draws chrome with it — and `@hn-theme`'s colours, so the status bar, the pane surfaces and+ /// the panes the daemons paint take the theme's. Called whenever the look is applied or a knob+ /// changes.+ pub fn sync_accent(&mut self) {+ crate::term_out::set_accent_override(self.options.get("@hn-accent", "", None));+ crate::settings::set_fzf_lists(self.options.get("@hn-lists", "", None).as_deref() == Some("fzf"));+ let hex = |c: [u8; 3]| format!("#{:02x}{:02x}{:02x}", c[0], c[1], c[2]);+ let theme = self.options.get("@hn-theme", "", None)+ .and_then(|n| crate::terminal_themes::TERMINAL_THEMES.iter().find(|t| t.name == n))+ .map(|t| (hex(t.background), hex(t.foreground)));+ if crate::term_out::set_theme_colours(theme) { self.push_theme() }+ }++ /// `hn theme`: a knob's new value from the picker. Applies it live (so the daemon, which reads+ /// options, changes the running look) and writes the config file's `[look]` table. Returns the+ /// confirmation shown in the picker.+ pub fn set_look(&mut self, knob: &str, value: &str) -> String {+ let global = crate::options::SetFlags { global: true, ..Default::default() };+ let (name, message) = match knob {+ // A preset also sets its focus (line or surface), so choosing one resets any knob+ // the user set earlier; they can override it again right after.+ "preset" => {+ let surface = crate::config::Look::look_preset(value).iter().any(|(_, v)| *v == "surface");+ let _ = self.options.set("@hn-focus", Some(if surface { "surface" } else { "line" }), &global, "", 0);+ ("@hn-look", format!("look: {value}"))+ }+ "focus" => ("@hn-focus", format!("focus: {value}")),+ "border_lines" => ("pane-border-lines", format!("border: {value}")),+ "border_indicators" => ("pane-border-indicators", format!("indicators: {value}")),+ "border_status" => ("pane-border-status", format!("title row: {value}")),+ "layout_orientation" => ("@hn-layout", format!("split: {value}")),+ "layout_preset" => ("@hn-layout-preset", format!("layout: {value}")),+ // A terminal theme only names the palette; hn keeps the choice recorded so it survives+ // a restart, and the theme draws on the terminal (OSC 10/11). Its signature colour+ // becomes the chrome accent so picking one visibly changes hn.+ "theme" => {+ // (None chosen: the terminal's own colours again, and hn's own accent.)+ if value.is_empty() {+ let unset = crate::options::SetFlags { global: true, unset: true, ..Default::default() };+ let _ = self.options.set("@hn-accent", None, &unset, "", 0);+ let _ = self.options.set("@hn-theme", None, &unset, "", 0);+ self.sync_accent();+ let i = self.active;+ self.layout_changed(i);+ self.persist_look();+ return "theme: the terminal's own".into();+ }+ if let Some(a) = crate::theme::theme_accent_hex(value) {+ let _ = self.options.set("@hn-accent", Some(a.as_str()), &global, "", 0);+ }+ ("@hn-theme", format!("theme: {value}"))+ }+ // ── status bar ──+ // (At the top or the bottom the bar is tmux's status line: status-position places it.)+ "status_bar" => {+ if matches!(value, "top" | "bottom") { let _ = self.options.set("status-position", Some(value), &global, "", 0); self.status_top = value == "top" }+ ("@hn-status-bar", format!("status bar: {value}"))+ }+ "border_style" => ("@hn-border", format!("border style: {value}")),+ _ => return format!("unknown: {value}"),+ };+ let _ = self.options.set(name, Some(value), &global, "", 0);+ self.sync_accent();+ // (The bar and the frames change the panes' room: every program is told its size.)+ if matches!(knob, "status_bar" | "border_style") { self.redraw_all = true; self.fit_panes() }+ let i = self.active;+ self.layout_changed(i);+ self.persist_look();+ message+ }++ /// Write the current look (as the options hold it) to tui.toml's `[look]`, best-effort.+ pub fn persist_look(&mut self) {+ let mut look = crate::config::Look::default();+ look.preset = self.options.get("@hn-look", "", None);+ look.focus = self.options.get("@hn-focus", "", None);+ look.border_lines = self.options.get("pane-border-lines", "", None);+ look.border_indicators = self.options.get("pane-border-indicators", "", None);+ look.border_status = self.options.get("pane-border-status", "", None);+ look.layout_orientation = self.options.get("@hn-layout", "", None);+ look.layout_preset = self.options.get("@hn-layout-preset", "", None);+ look.theme = self.options.get("@hn-theme", "", None);+ // ── status bar ──+ look.status_bar = self.options.get("@hn-status-bar", "", None);+ look.border_style = self.options.get("@hn-border", "", None);+ look.status_bar_width = self.options.get("@hn-status-bar-width", "", None);+ if let Err(e) = crate::config::write_look(&look) { self.say(format!("could not write tui.toml: {e}"), crate::theme::DANGER) }+ }+// ── the desk: tabs shared with every window on the account ─────────────────fn load_desk(&mut self) {@@ -5378,7 +5524,7 @@ impl App {true}- fn prs_path() -> std::path::PathBuf { std::path::PathBuf::from(std::env::var("HOME").unwrap_or_default()).join(".harness").join("tui").join("prs.json") }+ fn prs_path() -> std::path::PathBuf { state_dir().join("prs.json") }/// prs.json as this computer's clients last wrote it (read again at most every ten seconds).fn read_prs(&mut self) {@@ -5513,6 +5659,8 @@ impl App {// Since you were here: once every machine's harnesses are listed, so it counts them all.if self.back_from.is_some() && !self.headless && self.fleet_ready() { self.back_again() }self.enrich();+ // ── models: this computer's models read as often as the Models view needs ──+ crate::models::tick(self);self.maybe_start_shell();self.release_waiting();self.release_cli();diff --git a/tui/src/bar.rs b/tui/src/bar.rsnew file mode 100644index 000000000..801584fe9--- /dev/null+++ b/tui/src/bar.rs@@ -0,0 +1,878 @@+//! The status bar down a side (`@hn-status-bar left|right`, the Settings' **Status bar**): under+//! the current machine's name, the session's windows with their panes nested under each (a pane's+//! harness and the repo it works in); then the machines and each one's windows; then what the+//! status line's right side says (bar_more.rs). The bar has no focus of its own — it shows where+//! the real focus is, so tmux's keys (prefix n, p, 0-9, o, the arrows, w, s) move its highlight,+//! and a click on an entry runs the tmux command that key would. Its separator is a handle: drag+//! it to make the bar wider or narrower (`@hn-status-bar-width`), double-click it for the default.++use std::time::{Duration, Instant};++use crossterm::event::{MouseButton, MouseEvent, MouseEventKind};+use ratatui::buffer::Buffer;+use ratatui::layout::Rect;+use ratatui::style::{Color, Modifier, Style};+use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};++use crate::app::App;+use crate::fleet::State as Harness;+use crate::theme;++/// The bar's width, its last column the separator; how narrow and wide it may be dragged.+pub const WIDTH: u16 = 26;+pub const MIN_WIDTH: u16 = 18;+pub const MAX_WIDTH: u16 = 36;+/// Folded to a rail: a number and a glyph for each entry, and the separator.+pub const RAIL: u16 = 4;+/// The window keeps at least this many columns beside the bar.+const ROOM: u16 = 20;+/// Two presses on the separator this close together are a double click.+const DOUBLE_CLICK: Duration = Duration::from_millis(400);+/// A section's header and the blank row after it.+const HEADER: u16 = 2;+/// The two lists keep at least this many rows between them; the footer has what is left.+const LISTS: u16 = 12;++#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum Side { Left, Right }++/// What a place on the bar does when clicked, or the list the wheel scrolls there.+#[derive(Clone, Debug, PartialEq, Eq)]+pub enum Hit {+ /// A pane (its window's index, and the pane): select that window, then the pane.+ Pane(usize, u64),+ /// A window (by index): select it — its heading, or an entry under a machine.+ Window(usize),+ /// A machine's heading: its first window, if it has one.+ Machine(Option<usize>),+ /// `«` folds the bar to a rail, `»` opens it again.+ Fold,+ Unfold,+ /// The separator: dragged, the bar's width follows; double-clicked, the default width again.+ Separator,+ /// The lists (for the wheel): the windows, the machines.+ Windows,+ Machines,+}++/// The bar's own state: nothing of it is a focus — only how it is shown.+#[derive(Clone, Debug, Default)]+pub struct State {+ pub folded: bool,+ /// The first entry shown in each list: the windows, the machines.+ pub scroll: [usize; 2],+ /// How far each list can scroll, as last drawn.+ pub max_scroll: [usize; 2],+ /// Where each place was drawn, for the mouse.+ pub hits: Vec<(Rect, Hit)>,+ /// The focus the lists last followed (the window's id and its pane): when it moves, its+ /// entries are scrolled into view.+ followed: Option<(String, Option<u64>)>,+ /// A drag begun on the separator is resizing the bar.+ pub resizing: bool,+ /// When the separator was last pressed (a second press soon after is a double click).+ pressed: Option<Instant>,+}++impl App {+ /// Where box panes' frames (and blurred surfaces) may go: the whole window. Only two panes side+ /// by side, or stacked, have a cell between them — tmux's divider — so a box meets the window's+ /// edges and the status line, and beside the bar its blank edge is the one cell.+ pub fn box_inner(&self, tab: &crate::app::Tab) -> Rect { self.window_area(tab) }++ /// The side the status bar is on — none when it is tmux's status line (bottom, top), when+ /// `status off` hides it, and when the terminal is too narrow for it and a window beside it.+ pub fn bar_side(&self) -> Option<Side> {+ if self.headless { return None }+ let side = match self.options.status_bar() { "left" => Side::Left, "right" => Side::Right, _ => return None };+ if self.options.get("status", "", None).as_deref() == Some("off") { return None }+ if self.size.0 < self.bar_width() + ROOM || self.size.1 < 4 { return None }+ Some(side)+ }++ /// The bar's columns: `@hn-status-bar-width` (18 to 36, 26 unless dragged; narrower when the+ /// terminal would leave the window too little), or the rail's when folded.+ pub fn bar_width(&self) -> u16 {+ if self.bar.folded { return RAIL }+ let want = self.options.get("@hn-status-bar-width", "", None).and_then(|v| v.trim().parse::<u16>().ok()).unwrap_or(WIDTH);+ want.clamp(MIN_WIDTH, MAX_WIDTH).min(self.size.0.saturating_sub(ROOM)).max(MIN_WIDTH)+ }++ /// The bar [width] columns wide — kept to 18..36 and the window's 20 columns beside it — and+ /// the panes fitted to what is left (the option set; tui.toml is written when a drag ends).+ pub fn set_bar_width(&mut self, width: u16) {+ let width = width.clamp(MIN_WIDTH, MAX_WIDTH.min(self.size.0.saturating_sub(ROOM)).max(MIN_WIDTH));+ if self.options.get("@hn-status-bar-width", "", None).and_then(|v| v.trim().parse::<u16>().ok()) == Some(width) { return }+ let global = crate::options::SetFlags { global: true, ..Default::default() };+ let _ = self.options.set("@hn-status-bar-width", Some(&width.to_string()), &global, "", 0);+ self.redraw_all = true;+ self.fit_panes();+ }++ /// The bar: the terminal's full height down its side.+ pub fn bar_rect(&self) -> Option<Rect> {+ let side = self.bar_side()?;+ let w = self.bar_width();+ Some(Rect::new(if side == Side::Left { 0 } else { self.size.0 - w }, 0, w, self.size.1))+ }++ /// Where the window starts past the bar: what the mouse takes off its column (and row) for+ /// the window's cells.+ pub fn bar_offset(&self) -> (u16, u16) {+ match self.bar_rect() { Some(bar) => (if bar.x == 0 { bar.width } else { 0 }, 0), None => (0, 0) }+ }+}++// ── colours ──────────────────────────────────────────────────────────────────++/// The bar's colours, from the theme in use (the terminal's own when none is chosen): its surface,+/// the current entry's row, the separator, the text in three strengths, the accent, and the states+/// in the terminal's own ANSI colours.+struct Colours { bg: Color, row: Color, rule: Color, text: Color, soft: Color, muted: Color, accent: Color, green: Color }++fn colours() -> Colours {+ let pal = theme::pane_palette();+ if theme::no_color() {+ let r = Color::Reset;+ return Colours { bg: r, row: r, rule: r, text: r, soft: r, muted: r, accent: r, green: r };+ }+ let fit = theme::depth_fit;+ Colours {+ bg: fit(pal.surface), row: fit(mix(pal.surface, pal.foreground, 12)), rule: fit(pal.border),+ text: fit(pal.foreground), soft: fit(pal.inactive_foreground), muted: fit(pal.muted), accent: theme::paint(theme::accent()),+ green: theme::paint(theme::ONLINE),+ }+}++/// [a] moved [amount] % toward [b] (RGB; any other colour stays as it is).+fn mix(a: Color, b: Color, amount: u16) -> Color {+ let (Color::Rgb(ar, ag, ab), Color::Rgb(br, bg, bb)) = (a, b) else { return a };+ let c = |a: u8, b: u8| ((a as u16 * (100 - amount) + b as u16 * amount) / 100) as u8;+ Color::Rgb(c(ar, br), c(ag, bg), c(ab, bb))+}++/// A harness's state as the bar marks it: the marks hn gives harnesses everywhere else (the+/// launcher, the home screen, the panes' titles) — its spinner working, `?` waiting on you, `✓`+/// done, `✗` failed, `·` idle — in their colours; nothing known (a shell), a quiet `·`.+fn mark(state: Option<Harness>, c: &Colours, tick: u64) -> (&'static str, Color) {+ match state {+ // (Nothing to say — idle, paused, offline, a shell: a blank, not a dot that means nothing.)+ None | Some(Harness::Ready | Harness::Paused | Harness::Offline) => (" ", c.muted),+ Some(s) => { let (dot, _, colour) = theme::state_mark(s, tick); (dot, if colour == theme::MUTED { c.muted } else { colour }) }+ }+}++// ── text ─────────────────────────────────────────────────────────────────────++/// [text] in at most [cols] display columns, `…` where it was cut.+fn cut(text: &str, cols: usize) -> String {+ if text.width() <= cols { return text.to_string() }+ if cols == 0 { return String::new() }+ let (mut out, mut used) = (String::new(), 0);+ for ch in text.chars() {+ let w = ch.width().unwrap_or(0);+ if used + w + 1 > cols { break }+ out.push(ch);+ used += w;+ }+ out.push('…');+ out+}++/// A repo in [width] columns: `project · branch`, the project whole while the branch keeps a few+/// columns, the branch cut with `…`; too narrow for both, the branch alone (the leftmost goes first).+fn repo(project: &str, branch: &str, width: usize) -> Vec<String> {+ match (project.is_empty(), branch.is_empty()) {+ (_, true) => vec![cut(project, width)],+ (true, false) => vec![cut(branch, width)],+ _ if width < 12 => vec![cut(branch, width)],+ _ => {+ let pw = project.width().min(width - 3 - branch.width().min(8));+ vec![cut(project, pw), cut(branch, width - 3 - cut(project, pw).width())]+ }+ }+}++/// [spans] from column [x] of row [y], no further than [right]. Returns the column after them.+fn put(buf: &mut Buffer, mut x: u16, y: u16, right: u16, spans: &[(String, Style)]) -> u16 {+ for (text, style) in spans {+ if x >= right { break }+ let room = (right - x) as usize;+ let shown = cut(text, room);+ buf.set_stringn(x, y, &shown, room, *style);+ x += shown.width() as u16;+ }+ x+}++// ── the entries ──────────────────────────────────────────────────────────────++/// One entry of a list: its rows (each indented from the list's left edge, as spans), what a+/// click on it does, and whether it is where the focus is (filled with the current row's colour).+struct Entry { rows: Vec<(u16, Vec<(String, Style)>)>, right: Option<(String, Style)>, hit: Hit, current: bool }++impl Entry { fn height(&self) -> u16 { self.rows.len() as u16 } }++/// A machine as a heading: its mark as the lists give it (`✓` connected, `·` away…), then its+/// name, bold, in [width] columns.+fn machine_spans(app: &App, c: &Colours, id: &str, width: u16) -> Vec<(String, Style)> {+ let machine = app.fleet.machine(id);+ let name = machine.map(|m| m.name.clone()).filter(|n| !n.is_empty()).unwrap_or_else(|| if id == app.fleet.local_id || id.is_empty() { crate::app::hostname() } else { id.to_string() });+ let here = id == app.fleet.local_id && !app.daemon_down;+ let (dot, colour) = match machine {+ _ if here => ("✓", c.green),+ Some(m) => theme::machine_mark(&m.reach, m.online(), app.tick),+ None => ("·", c.muted),+ };+ let colour = if colour == theme::MUTED { c.muted } else { colour };+ vec![(dot.to_string(), Style::default().fg(colour).add_modifier(Modifier::BOLD)), (" ".into(), Style::default()), (cut(&name, width.saturating_sub(1 + 2 + 2) as usize), Style::default().fg(c.text).add_modifier(Modifier::BOLD))]+}++/// A window's row: ` ✓ N:name` (the mark of the most urgent of its harnesses), after [prefix] when it sits+/// under a machine, its pane count dim on the right when it has several; the current window's on+/// the current row's colour.+fn window_entry(app: &App, c: &Colours, width: u16, i: usize, prefix: Option<&str>) -> Entry {+ let tab = &app.tabs[i];+ let here = i == app.active;+ let bg = |s: Style| if here { s.bg(c.row) } else { s };+ let (glyph, colour) = mark(app.window_state(i), c, app.tick);+ let count = tab.panes().len();+ let right = (count > 1).then(|| (count.to_string(), bg(Style::default().fg(c.muted))));+ let label = format!("{}:{}", app.win_num(i), tab.name);+ let mut spans = Vec::new();+ let mut used = 1 + 2 + right.as_ref().map(|(t, _)| t.width() + 1).unwrap_or(0);+ if let Some(p) = prefix { spans.push((p.to_string(), bg(Style::default().fg(c.muted)))); used += p.width() }+ // (No mark, no room kept for one: the name moves up to where it would be.)+ if glyph != " " { spans.push((format!("{glyph} "), bg(Style::default().fg(colour)))); used += 2 }+ let name = if here { Style::default().fg(c.text).add_modifier(Modifier::BOLD) } else { Style::default().fg(c.soft) };+ spans.push((cut(&label, (width as usize).saturating_sub(used)), bg(name)));+ Entry { rows: vec![(1, spans)], right, hit: Hit::Window(i), current: here }+}++/// A pane under its window's heading: `├─ ⠹ name` (its harness's mark and name, else the pane's title), and+/// under it the repo it works in — project · branch — or a shell's folder, dim; the focused pane+/// bold on the current row's colour.+fn pane_entry(app: &App, c: &Colours, width: u16, window: usize, id: u64, last: bool, here: bool) -> Entry {+ let (glyph, colour) = mark(app.pane_state(id), c, app.tick);+ let pane = app.panes.get(&id);+ let agent = pane.and_then(|p| app.fleet.agent(&p.machine_id, &p.agent_id));+ let harness = agent.filter(|a| a.engine != "terminal");+ let folder = |path: &str| path.trim_end_matches('/').rsplit('/').next().unwrap_or("").to_string();+ let name = match harness { Some(a) if !a.name.is_empty() => a.name.clone(), _ => crate::format::pane_title(app, window, id) };+ let room = width.saturating_sub(1 + 5 + 2) as usize;+ let where_ = match harness {+ Some(a) if !a.project.is_empty() || !a.branch.is_empty() => repo(&a.project, &a.branch, room),+ _ => vec![cut(&pane.and_then(|p| p.cwd.as_deref()).map(folder).filter(|f| !f.is_empty()).or_else(|| agent.map(|a| folder(&a.cwd))).unwrap_or_default(), room)],+ };+ let bg = |s: Style| if here { s.bg(c.row) } else { s };+ let dim = bg(Style::default().fg(c.muted));+ let name_style = bg(if here { Style::default().fg(c.text).add_modifier(Modifier::BOLD) } else { Style::default().fg(c.soft) });+ let second = bg(Style::default().fg(if here { c.accent } else { c.muted }));+ // (No mark, no room kept for one: the name sits by the branch, its repo under it.)+ let marked = glyph != " ";+ let mut line1 = vec![(if last { "└─ " } else { "├─ " }.to_string(), dim)];+ if marked { line1.push((format!("{glyph} "), bg(Style::default().fg(colour)))) }+ line1.push((cut(&name, width.saturating_sub(1 + 3 + 2 + if marked { 2 } else { 0 }) as usize), name_style));+ let mut line2 = vec![(match (last, marked) { (true, true) => " ", (true, false) => " ", (false, true) => "│ ", (false, false) => "│ " }.to_string(), dim)];+ for (k, part) in where_.into_iter().enumerate() {+ if k > 0 { line2.push((" · ".into(), dim)) }+ line2.push((part, second));+ }+ Entry { rows: vec![(1, line1), (1, line2)], right: None, hit: Hit::Pane(window, id), current: here }+}++/// The session's windows, each its heading with its panes nested under it — a window of one+/// pane just its heading.+fn window_entries(app: &App, c: &Colours, width: u16) -> Vec<Entry> {+ let mut out = Vec::new();+ for (i, tab) in app.tabs.iter().enumerate() {+ out.push(window_entry(app, c, width, i, None));+ let panes = if tab.home || tab.root.is_none() { Vec::new() } else { tab.panes() };+ if panes.len() < 2 { continue }+ let n = panes.len();+ for (k, id) in panes.into_iter().enumerate() { out.push(pane_entry(app, c, width, i, id, k + 1 == n, i == app.active && tab.focus == Some(id))) }+ }+ out+}++/// The machines, each with the windows that have a pane on it (a window on several machines+/// under each; one with no pane yet, this computer's).+fn machine_entries(app: &App, c: &Colours, width: u16) -> Vec<Entry> {+ let windows: Vec<usize> = (0..app.tabs.len()).collect();+ // Each window's machines: its panes', in order (none yet: this computer's).+ let on: Vec<Vec<String>> = app.tabs.iter().map(|t| {+ let mut ms: Vec<String> = Vec::new();+ for p in t.panes() { if let Some(m) = app.panes.get(&p).map(|p| p.machine_id.clone()) { if !ms.contains(&m) { ms.push(m) } } }+ if ms.is_empty() { ms.push(app.fleet.local_id.clone()) }+ ms+ }).collect();+ // The machines: this computer first, then the account's, then any a window names that the+ // account's list does not have (yet).+ let mut machines: Vec<String> = Vec::new();+ if !app.fleet.local_id.is_empty() { machines.push(app.fleet.local_id.clone()) }+ for m in &app.fleet.machines { if !machines.contains(&m.id) { machines.push(m.id.clone()) } }+ for ms in &on { for m in ms { if !machines.contains(m) { machines.push(m.clone()) } } }+ let mut out = Vec::new();+ for id in machines {+ let mine: Vec<usize> = windows.iter().copied().filter(|i| on[*i].contains(&id)).collect();+ out.push(Entry { rows: vec![(1, machine_spans(app, c, &id, width))], right: None, hit: Hit::Machine(mine.first().copied()), current: false });+ let n = mine.len();+ for (k, i) in mine.into_iter().enumerate() { out.push(window_entry(app, c, width, i, Some(if k + 1 == n { "└─ " } else { "├─ " }))) }+ }+ out+}++// ── drawing ──────────────────────────────────────────────────────────────────++/// The first entry to show so that entry [target] is in view, from [scroll], in [rows] rows.+fn reveal(entries: &[Entry], rows: u16, scroll: usize, target: usize) -> usize {+ if target < scroll { return target }+ let mut first = scroll;+ while first < target && entries[first..=target].iter().map(Entry::height).sum::<u16>() > rows { first += 1 }+ first+}++/// The furthest a list can scroll: the first entry from which the rest all fit.+fn max_scroll(entries: &[Entry], rows: u16) -> usize {+ let mut used = 0;+ for (i, e) in entries.iter().enumerate().rev() {+ used += e.height();+ if used > rows { return i + 1 }+ }+ 0+}++/// [entries] from [scroll] into [area], each filled with the current row's colour when it is+/// the current one; where each went is kept for the mouse.+fn list(buf: &mut Buffer, area: Rect, entries: &[Entry], scroll: usize, c: &Colours, hits: &mut Vec<(Rect, Hit)>) {+ let mut y = area.y;+ for e in entries.iter().skip(scroll) {+ if y + e.height() > area.bottom() { break }+ let rect = Rect::new(area.x, y, area.width, e.height());+ if e.current { buf.set_style(rect, Style::default().bg(c.row)) }+ for (k, (indent, spans)) in e.rows.iter().enumerate() {+ let right = area.right().saturating_sub(2);+ let right = if k == 0 { e.right.as_ref().map(|(t, _)| right.saturating_sub(t.width() as u16 + 1)).unwrap_or(right) } else { right };+ put(buf, area.x + indent, y + k as u16, right, spans);+ }+ if let Some((t, s)) = &e.right { let w = t.width() as u16; put(buf, area.right().saturating_sub(w + 2), y, area.right(), &[(t.clone(), *s)]); }+ hits.push((rect, e.hit.clone()));+ y += e.height();+ }+}++/// The bar, as the window is now.+pub fn draw(buf: &mut Buffer, app: &mut App) {+ let Some(bar) = app.bar_rect() else { app.bar.hits.clear(); return };+ let c = colours();+ let mut hits = Vec::new();+ crate::term_out::clear_extras(bar);+ for y in bar.y..bar.bottom() { for x in bar.x..bar.right() { if let Some(cell) = buf.cell_mut((x, y)) { cell.reset(); cell.set_style(Style::default().bg(c.bg)); } } }+ // The separator: the bar's last column facing the panes (its first, on the right) — the+ // handle that resizes it, in the accent while it does.+ let sx = if bar.x == 0 { bar.right() - 1 } else { bar.x };+ // (Beside box panes or blurred surfaces the pane's own edge is the line: the handle is a blank+ // column, which still takes the drag — `││` would be two lines where one is meant, and the+ // blank column is the one cell of space every pane has.)+ let quiet = (app.options.box_panes() || app.options.pane_look()) && !app.bar.resizing;+ for y in bar.y..bar.bottom() { if let Some(cell) = buf.cell_mut((sx, y)) { cell.set_symbol(if quiet { " " } else { "│" }).set_style(Style::default().fg(if app.bar.resizing { c.accent } else { c.rule }).bg(c.bg)); } }+ hits.push((Rect::new(sx, bar.y, 1, bar.height), Hit::Separator));+ let content = Rect::new(if bar.x == 0 { bar.x } else { bar.x + 1 }, bar.y, bar.width - 1, bar.height);+ let width = content.width;+ let windows = window_entries(app, &c, width);+ let machines = machine_entries(app, &c, width);+ // The focus moved (a key, a click, another client): its entries come into view.+ let now = Some((app.tab().id.clone(), app.focused()));+ let follow = app.bar.followed != now;+ app.bar.followed = now;+ if app.bar.folded { rail(buf, content, app, &c, &mut hits) }+ else {+ // Over the `«` row, what the status line's right side says, as far as the lists leave room.+ let footer_h = crate::bar_more::footer_height(app, width).min(content.height.saturating_sub(LISTS + 1));+ let footer_h = if footer_h >= 2 { footer_h } else { 0 };+ let lists = Rect::new(content.x, content.y, width, content.height - footer_h - 1);+ // The windows over the machines, half each, a rule between; a short terminal has the windows.+ let both = lists.height >= LISTS;+ let top_h = if both { (lists.height / 2).clamp(HEADER + 2, lists.height - HEADER - 2) } else { lists.height };+ let top = Rect::new(content.x, content.y, width, top_h);+ let header = |buf: &mut Buffer, y: u16, title: &str| { put(buf, content.x, y, content.right(), &[(title.to_string(), Style::default().fg(c.muted).add_modifier(Modifier::BOLD))]); };+ // The top's header: the machine you are on — the focused pane's, else this computer.+ let here = app.focused().and_then(|f| app.panes.get(&f)).map(|p| p.machine_id.clone()).unwrap_or_else(|| app.fleet.local_id.clone());+ put(buf, content.x + 1, top.y, content.right(), &machine_spans(app, &c, &here, width));+ // (No buttons: a new harness and the commands are their keys' — prefix N, prefix Enter.)+ let area = Rect::new(top.x, top.y + HEADER, width, top_h.saturating_sub(HEADER));+ scroll_list(app, 0, &windows, area, follow);+ list(buf, area, &windows, app.bar.scroll[0], &c, &mut hits);+ hits.push((area, Hit::Windows));+ if both {+ let ry = top.bottom();+ put(buf, content.x, ry, content.right(), &[("─".repeat(width as usize), Style::default().fg(c.rule))]);+ let bottom = Rect::new(content.x, ry + 1, width, lists.bottom() - ry - 1);+ // (Always each machine with its windows under it: no flat list to switch to.)+ header(buf, bottom.y, " machines");+ let area = Rect::new(bottom.x, bottom.y + HEADER, width, bottom.height.saturating_sub(HEADER));+ scroll_list(app, 1, &machines, area, follow);+ list(buf, area, &machines, app.bar.scroll[1], &c, &mut hits);+ hits.push((area, Hit::Machines));+ }+ if footer_h > 0 { crate::bar_more::footer(buf, app, Rect::new(content.x, lists.bottom(), width, footer_h)) }+ // `«` folds the bar, bottom right.+ let fx = content.right().saturating_sub(1);+ put(buf, fx, content.bottom() - 1, content.right(), &[("«".into(), Style::default().fg(c.muted))]);+ hits.push((Rect::new(fx, content.bottom() - 1, 1, 1), Hit::Fold));+ }+ app.bar.hits = hits;+}++/// Keep list [which]'s scroll where it can be, the focused row brought into view when the focus+/// has just moved.+fn scroll_list(app: &mut App, which: usize, entries: &[Entry], area: Rect, follow: bool) {+ let max = max_scroll(entries, area.height);+ app.bar.max_scroll[which] = max;+ let mut s = app.bar.scroll[which].min(max);+ if follow { if let Some(t) = entries.iter().rposition(|e| e.current) { s = reveal(entries, area.height, s, t) } }+ app.bar.scroll[which] = s;+}++/// The bar folded to a rail: a number and a glyph for each pane of the current window, a rule,+/// the same for each window, and `»` to open it again.+fn rail(buf: &mut Buffer, content: Rect, app: &App, c: &Colours, hits: &mut Vec<(Rect, Hit)>) {+ let half = content.height.div_ceil(2);+ let mut row = |buf: &mut Buffer, y: u16, n: usize, glyph: (&str, Color), current: bool, hit: Hit| {+ let rect = Rect::new(content.x, y, content.width, 1);+ if current { buf.set_style(rect, Style::default().bg(c.row)) }+ let number = Style::default().fg(if current { c.text } else { c.muted });+ put(buf, content.x, y, content.right(), &[(format!("{:<2}", n), number), (glyph.0.to_string(), Style::default().fg(glyph.1))]);+ hits.push((rect, hit));+ };+ let tab = app.tab();+ let panes = if tab.home || tab.root.is_none() { Vec::new() } else { tab.panes() };+ for (k, id) in panes.into_iter().enumerate().take(half.saturating_sub(1) as usize) {+ row(buf, content.y + k as u16, k + 1, mark(app.pane_state(id), c, app.tick), tab.focus == Some(id), Hit::Pane(app.active, id));+ }+ let ry = content.y + half.saturating_sub(1);+ put(buf, content.x, ry, content.right(), &[("─".repeat(content.width as usize), Style::default().fg(c.rule))]);+ for i in (0..app.tabs.len()).take(content.bottom().saturating_sub(ry + 2) as usize) {+ row(buf, ry + 1 + i as u16, app.win_num(i), mark(app.window_state(i), c, app.tick), i == app.active, Hit::Window(i));+ }+ let fy = content.bottom() - 1;+ let fx = content.x + content.width / 2;+ put(buf, fx, fy, content.right(), &[("»".into(), Style::default().fg(c.muted))]);+ hits.push((Rect::new(fx, fy, 1, 1), Hit::Unfold));+}++// ── the mouse ────────────────────────────────────────────────────────────────++/// The place under (x, y): the entry or button there, else the list.+pub fn hit_at(app: &App, x: u16, y: u16) -> Option<Hit> {+ let inside = |r: &Rect| x >= r.x && x < r.right() && y >= r.y && y < r.bottom();+ let list = |h: &Hit| matches!(h, Hit::Windows | Hit::Machines);+ app.bar.hits.iter().rev().find(|(r, h)| inside(r) && !list(h)).or_else(|| app.bar.hits.iter().find(|(r, _)| inside(r))).map(|(_, h)| h.clone())+}++/// What a click on [hit] does: the tmux command its key would run, or the bar's own change.+pub fn click(app: &mut App, hit: Hit) {+ let select = |app: &mut App, i: usize| { let n = app.win_num(i); crate::commands::execute(app, &format!("select-window -t :{n}")) };+ match hit {+ Hit::Pane(i, id) => {+ if i >= app.tabs.len() || !app.panes.contains_key(&id) { return }+ if i != app.active { select(app, i) }+ crate::commands::execute(app, &format!("select-pane -t {}", crate::pane::tag(id)))+ }+ Hit::Window(i) | Hit::Machine(Some(i)) => { if i < app.tabs.len() { select(app, i) } }+ Hit::Fold | Hit::Unfold => { app.bar.folded = hit == Hit::Fold; app.redraw_all = true; app.fit_panes() }+ Hit::Machine(None) | Hit::Separator | Hit::Windows | Hit::Machines => {}+ }+}++/// The wheel over the bar: its list moves by one entry.+pub fn wheel(app: &mut App, hit: Hit, up: bool) {+ let step = |s: usize, max: usize| if up { s.saturating_sub(1) } else { (s + 1).min(max) };+ // (A window's or a pane's entry: the list it is in — the machines' when it is drawn there.)+ let rect = app.bar.hits.iter().find(|(_, h)| *h == hit).map(|(r, _)| *r).unwrap_or_default();+ let in_machines = app.bar.hits.iter().any(|(r, h)| *h == Hit::Machines && r.intersection(rect) == rect && rect.area() > 0);+ let k = match hit {+ Hit::Windows => 0,+ Hit::Machines | Hit::Machine(_) | Hit::Fold => 1,+ Hit::Window(_) | Hit::Pane(..) => usize::from(in_machines),+ Hit::Separator | Hit::Unfold => return,+ };+ app.bar.scroll[k] = step(app.bar.scroll[k], app.bar.max_scroll[k]);+}++/// The separator dragged to column [x]: the bar's width follows it.+fn resize_to(app: &mut App, x: u16) {+ let Some(bar) = app.bar_rect() else { return };+ let width = if bar.x == 0 { x.saturating_add(1) } else { app.size.0.saturating_sub(x) };+ app.set_bar_width(width);+}++/// A mouse event from the terminal: the bar's when it is over it (or it is resizing the bar) —+/// true then. A drag begun in a pane (a selection, a border) is the pane's wherever it goes.+pub fn mouse(app: &mut App, ev: &MouseEvent) -> bool {+ // A drag on the separator: the width follows the mouse wherever it goes, until let go (the+ // width then written to tui.toml).+ if app.bar.resizing {+ match ev.kind {+ MouseEventKind::Drag(MouseButton::Left) => { resize_to(app, ev.column); return true }+ MouseEventKind::Up(_) => { app.bar.resizing = false; app.redraw_all = true; app.persist_look(); return true }+ _ => app.bar.resizing = false,+ }+ }+ let Some(bar) = app.bar_rect() else { return false };+ let inside = ev.column >= bar.x && ev.column < bar.right() && ev.row >= bar.y && ev.row < bar.bottom();+ if !inside { return false }+ if app.mouse_state.drag.is_some() && matches!(ev.kind, MouseEventKind::Drag(_) | MouseEventKind::Up(_)) { return false }+ let hit = hit_at(app, ev.column, ev.row);+ match ev.kind {+ MouseEventKind::Down(MouseButton::Left) => match hit {+ // (The rail is opened with `»`, not dragged.)+ Some(Hit::Separator) if !app.bar.folded => {+ if app.bar.pressed.take().is_some_and(|t| t.elapsed() < DOUBLE_CLICK) { app.set_bar_width(WIDTH); app.persist_look() }+ else { app.bar.pressed = Some(Instant::now()); app.bar.resizing = true; app.redraw_all = true }+ }+ Some(h) => click(app, h),+ None => {}+ },+ MouseEventKind::ScrollUp | MouseEventKind::ScrollDown => { if let Some(h) = hit { wheel(app, h, matches!(ev.kind, MouseEventKind::ScrollUp)) } }+ _ => {}+ }+ true+}++#[cfg(test)]+mod tests {+ use super::*;+ use crate::app::Tab;+ use crate::layout::{Dir, Node};+ use crate::pane::{Pane, Phase};+ use serde_json::json;++ /// A window of three (claude and codex on this computer, in the harness repo; a shell on+ /// `lab`), a second window of one on `lab`, the bar on [side].+ fn app(size: (u16, u16), side: &str) -> App {+ let (sink, _) = tokio::sync::mpsc::unbounded_channel();+ let mut app = App::new(19791, sink, size);+ app.fleet.local_id = "local".into();+ app.fleet.machines.push(crate::fleet::Machine { id: "local".into(), name: "studio".into(), local: true, status: "online".into(), reach: crate::fleet::Reach::Ready });+ app.fleet.machines.push(crate::fleet::Machine { id: "lab".into(), name: "lab".into(), local: false, status: "offline".into(), reach: crate::fleet::Reach::Offline });+ let repo = json!({"name": "autonomous-harness", "branch": "feat/grid-harness-codex", "cwd": "/src/autonomous-harness"});+ app.fleet.merge_roster("local", &[json!({"id": "a1", "name": "fix login", "engine": "claude", "project": repo}), json!({"id": "a2", "name": "tests", "engine": "codex", "project": repo})]);+ app.fleet.merge_roster("lab", &[json!({"id": "a3", "name": "deploy", "engine": "claude"}), json!({"id": "a4", "name": "", "engine": "terminal", "project": {"cwd": "/home/me/ops"}})]);+ let global = crate::options::SetFlags { global: true, ..Default::default() };+ let _ = app.options.set("@hn-status-bar", Some(side), &global, "", 0);+ let mut one = Tab::new("work");+ let mut root = Node::new(1, 100, 30);+ root.split(1, 2, Dir::Horizontal);+ root.split(2, 3, Dir::Vertical);+ one.root = Some(root);+ one.focus = Some(1);+ let mut two = Tab::new("ops");+ two.root = Some(Node::new(4, 100, 30));+ two.focus = Some(4);+ for (id, m, a) in [(1, "local", "a1"), (2, "local", "a2"), (3, "lab", "a4"), (4, "lab", "a3")] {+ let mut p = Pane::new(id, m, a, 40, 20);+ p.phase = Phase::Live;+ app.panes.insert(id, p);+ }+ app.tabs = vec![one, two];+ app.active = 0;+ app.fit_panes();+ app+ }++ fn screen(app: &mut App) -> (String, Buffer) {+ let (w, h) = app.size;+ let mut term = ratatui::Terminal::new(ratatui::backend::TestBackend::new(w, h)).unwrap();+ term.draw(|f| crate::ui::draw(f, app)).unwrap();+ let buf = term.backend().buffer().clone();+ ((0..h).map(|y| (0..w).map(|x| buf[(x, y)].symbol().to_string()).collect::<String>()).collect::<Vec<_>>().join("\n"), buf)+ }++ fn row(s: &str, y: usize) -> String { s.lines().nth(y).unwrap_or("").to_string() }++ fn ev(kind: MouseEventKind, column: u16, row: u16) -> MouseEvent { MouseEvent { kind, column, row, modifiers: crossterm::event::KeyModifiers::NONE } }++ #[test]+ fn the_bar_takes_its_columns_at_every_size() {+ for (w, h) in [(80u16, 24u16), (150, 42), (46, 10), (200, 60)] {+ for side in ["left", "right"] {+ let mut app = app((w, h), side);+ let bar = app.bar_rect().unwrap();+ assert_eq!((bar.width, bar.height, bar.y), (WIDTH, h, 0));+ assert_eq!(bar.x, if side == "left" { 0 } else { w - WIDTH });+ // The whole height beside the bar is the window's: no row over the panes.+ let body = app.body();+ assert_eq!(body, Rect::new(if side == "left" { WIDTH } else { 0 }, 0, w - WIDTH, h), "{w}x{h} {side}");+ assert_eq!(app.status_lines(), 0, "the bar is the status line");+ assert_eq!(app.bar_offset(), (if side == "left" { WIDTH } else { 0 }, 0));+ // Every pane is laid out in the body, and fills it (tmux's cells).+ assert!(app.rects.iter().all(|(_, r)| r.intersection(body) == *r), "{w}x{h} {side}: {:?}", app.rects);+ assert_eq!(app.tab().root.as_ref().unwrap().size(), (body.width, body.height));+ let _ = screen(&mut app);+ // Folded, the rail's four columns.+ click(&mut app, Hit::Fold);+ assert_eq!(app.body().width, w - RAIL);+ click(&mut app, Hit::Unfold);+ assert_eq!(app.body().width, w - WIDTH);+ }+ }+ // Too narrow for the bar and a window: none, and tmux's status line again.+ let app = app((36, 20), "left");+ assert!(app.bar_rect().is_none());+ assert_eq!(app.status_lines(), 1);+ // `status off` hides it as it hides the status line; bottom and top are the status line.+ let mut off = self::app((120, 30), "left");+ let _ = off.options.set("status", Some("off"), &crate::options::SetFlags { global: true, ..Default::default() }, "", 0);+ assert!(off.bar_rect().is_none());+ assert_eq!(self::app((120, 30), "bottom").body(), Rect::new(0, 0, 120, 29));+ }++ #[test]+ fn the_bar_draws_the_machine_its_windows_with_their_panes_then_the_machines() {+ for side in ["left", "right"] {+ let mut app = app((120, 36), side);+ let (s, buf) = screen(&mut app);+ let x0 = if side == "left" { 0 } else { 120 - WIDTH as usize + 1 };+ let bar = |y: usize| row(&s, y).chars().skip(x0).take(WIDTH as usize - 1).collect::<String>();+ // The machine you are on (the focused pane's), online.+ assert_eq!(bar(0).trim_end(), " ✓ studio", "{s}");+ // (Each window named for its harness, as automatic-rename names it; idle harnesses and+ // shells have no mark, and no room kept for one — the name sits close.)+ assert!(bar(2).starts_with(" 0:fix login") && bar(2).trim_end().ends_with('3'), "{}", bar(2));+ assert!(bar(3).starts_with(" ├─ fix login"), "{}", bar(3));+ assert!(bar(4).starts_with(" │ auton… · feat/gr…"), "the repo under the name: {}", bar(4));+ assert!(bar(5).starts_with(" ├─ tests"), "{}", bar(5));+ assert!(bar(7).starts_with(" └─ "), "a shell: {}", bar(7));+ assert!(bar(8).starts_with(" ops"), "a shell's folder under its name: {}", bar(8));+ assert!(!s.contains(" · 0:") && !s.contains("├─ · "), "no dot for idle:\n{s}");+ // A window of one pane: just its heading.+ assert!(bar(9).starts_with(" 1:deploy") && bar(10).trim().is_empty(), "{}\n{}", bar(9), bar(10));+ // The current window's heading and the focused pane's two rows on the current row's+ // colour; the other panes and windows not.+ let bx = if side == "left" { 8 } else { 120 - WIDTH + 9 };+ assert_eq!(buf[(bx, 2)].bg, buf[(bx, 3)].bg);+ assert_eq!(buf[(bx, 3)].bg, buf[(bx, 4)].bg);+ assert_ne!(buf[(bx, 3)].bg, buf[(bx, 5)].bg);+ assert_ne!(buf[(bx, 2)].bg, buf[(bx, 9)].bg);+ // The separator down the side facing the panes: beside box panes (the default) a blank+ // column, the frames' edge being the line; beside tmux's lines, a `│`.+ let sx = if side == "left" { WIDTH - 1 } else { 120 - WIDTH };+ assert!((0..36).all(|y| buf[(sx, y)].symbol() == " "));+ let body = app.body();+ assert_eq!(buf[(if side == "left" { body.x } else { body.right() - 1 }, body.y + 3)].symbol(), "│", "the frame's own edge");+ // The windows' footer, the rule, the machines with their windows (one on both).+ let footer = crate::bar_more::footer_height(&app, WIDTH - 1).min(36 - 13);+ let footer = if footer >= 2 { footer as usize } else { 0 };+ let lists = 36 - footer - 1;+ let top = lists / 2;+ // (No ` new` / `menu` row and no `grouped` switch: their keys do that.)+ assert!(!s.contains("menu") && !s.contains("grouped"), "{s}");+ assert!(bar(top).chars().all(|c| c == '─'), "{}", bar(top));+ assert_eq!(bar(top + 1).trim_end(), " machines", "{}", bar(top + 1));+ assert!(bar(top + 3).starts_with(" ✓ studio"), "{}", bar(top + 3));+ assert!(bar(top + 4).starts_with(" └─ 0:fix login"), "{}", bar(top + 4));+ assert!(bar(top + 5).starts_with(" · lab"), "away: {}", bar(top + 5));+ assert!(bar(top + 7).starts_with(" └─ 1:deploy"), "offline, nothing known: {}", bar(top + 7));+ // The footer (status-right) over the last row, and `«` on it.+ if footer > 0 { assert!(bar(lists).starts_with("──"), "{s}") }+ assert_eq!(bar(35).trim_end().chars().last(), Some('«'));+ // No tabs over the panes: the boxes fill the window to its edges (beside the bar, its+ // blank edge is the one cell).+ let inner = app.box_inner(app.tab());+ assert_eq!(buf[(inner.x, inner.y)].symbol(), "┌");+ assert_eq!(buf[(inner.right() - 1, inner.bottom() - 1)].symbol(), "┘");+ assert_eq!(inner, app.body());+ }+ }++ /// A repo in the bar's width: the project whole while the branch keeps a few columns.+ #[test]+ fn a_repo_keeps_its_project_and_cuts_its_branch() {+ assert_eq!(repo("autonomous-harness", "feat/grid-harness-codex", 44), ["autonomous-harness", "feat/grid-harness-codex"]);+ assert_eq!(repo("autonomous-harness", "feat/grid-harness-codex", 40), ["autonomous-harness", "feat/grid-harness-…"]);+ assert_eq!(repo("autonomous-harness", "feat/grid-harness-codex", 30), ["autonomous-harness", "feat/gri…"]);+ assert_eq!(repo("autonomous-harness", "feat/grid-harness-codex", 17), ["auton…", "feat/gr…"]);+ assert_eq!(repo("autonomous-harness", "main", 17), ["autonomou…", "main"]);+ assert_eq!(repo("app", "", 10), ["app"]);+ assert_eq!(repo("autonomous-harness", "main", 10), ["main"], "too narrow for both: the branch");+ for (p, b, w) in [("autonomous-harness", "feat/grid-harness-codex", 17usize), ("x", "y", 12), ("a-long-project-name", "b", 20)] {+ let parts = repo(p, b, w);+ assert!(parts.iter().map(|s| s.width()).sum::<usize>() + 3 * (parts.len() - 1) <= w, "{p} {b} {w}: {parts:?}");+ }+ }++ #[test]+ fn a_click_on_the_bar_does_what_its_entry_says() {+ let mut app = app((120, 36), "left");+ let _ = screen(&mut app);+ // A pane row (either of its two lines): focus it.+ assert_eq!(hit_at(&app, 8, 6), Some(Hit::Pane(0, 2)));+ assert!(mouse(&mut app, &ev(MouseEventKind::Down(MouseButton::Left), 8, 6)));+ assert_eq!(app.focused(), Some(2));+ // A window's heading: select it.+ assert_eq!(hit_at(&app, 8, 9), Some(Hit::Window(1)));+ assert!(mouse(&mut app, &ev(MouseEventKind::Down(MouseButton::Left), 8, 9)));+ assert_eq!(app.active, 1);+ // A pane of another window: that window, then the pane.+ let _ = screen(&mut app);+ let (r, _) = app.bar.hits.iter().find(|(_, h)| *h == Hit::Pane(0, 3)).cloned().unwrap();+ assert!(mouse(&mut app, &ev(MouseEventKind::Down(MouseButton::Left), r.x + 4, r.y)));+ assert_eq!((app.active, app.focused()), (0, Some(3)));+ // The machine `lab`'s heading: its first window. A click in a pane is not the bar's.+ let _ = screen(&mut app);+ let (r, _) = app.bar.hits.iter().find(|(_, h)| *h == Hit::Machine(Some(0))).cloned().unwrap();+ assert_eq!(hit_at(&app, r.x + 3, r.y), Some(Hit::Machine(Some(0))));+ assert!(!mouse(&mut app, &ev(MouseEventKind::Down(MouseButton::Left), 60, 10)));+ // `«` folds the bar and `»` opens it.+ let _ = screen(&mut app);+ let fold = app.bar.hits.iter().find(|(_, h)| *h == Hit::Fold).map(|(r, _)| *r).unwrap();+ assert!(mouse(&mut app, &ev(MouseEventKind::Down(MouseButton::Left), fold.x, fold.y)));+ assert!(app.bar.folded);+ let (s, _) = screen(&mut app);+ assert!(row(&s, 35).contains('»'), "{s}");+ assert_eq!(app.bar_offset().0, RAIL);+ }++ #[test]+ fn the_separator_drags_the_width_and_a_double_click_resets_it() {+ for side in ["left", "right"] {+ let mut app = app((120, 36), side);+ let _ = screen(&mut app);+ // The separator's column, for a bar [w] wide.+ let at = |w: u16| if side == "left" { w - 1 } else { 120 - w };+ let drag = |app: &mut App, to: u16| {+ assert!(mouse(app, &ev(MouseEventKind::Down(MouseButton::Left), at(app.bar_width()), 5)));+ app.bar.pressed = None;+ assert!(app.bar.resizing);+ assert!(mouse(app, &ev(MouseEventKind::Drag(MouseButton::Left), to, 6)));+ assert!(mouse(app, &ev(MouseEventKind::Up(MouseButton::Left), to, 6)));+ assert!(!app.bar.resizing);+ let _ = screen(app);+ };+ drag(&mut app, at(20));+ assert_eq!(app.bar_width(), 20);+ assert_eq!(app.body().width, 100, "the panes fitted to what is left");+ assert_eq!(app.tab().root.as_ref().unwrap().size().0, 100);+ drag(&mut app, at(34));+ assert_eq!(app.bar_width(), 34);+ assert_eq!(app.options.get("@hn-status-bar-width", "", None).as_deref(), Some("34"));+ // Held at both ends: 18 at least, 36 at most.+ drag(&mut app, if side == "left" { 3 } else { 117 });+ assert_eq!(app.bar_width(), MIN_WIDTH);+ drag(&mut app, if side == "left" { 80 } else { 40 });+ assert_eq!(app.bar_width(), MAX_WIDTH);+ // A double click on it: the default width again.+ let sx = at(app.bar_width());+ assert!(mouse(&mut app, &ev(MouseEventKind::Down(MouseButton::Left), sx, 5)));+ assert!(mouse(&mut app, &ev(MouseEventKind::Up(MouseButton::Left), sx, 5)));+ assert!(mouse(&mut app, &ev(MouseEventKind::Down(MouseButton::Left), sx, 5)));+ assert_eq!(app.bar_width(), WIDTH);+ }+ // Never leaving the window under 20 columns.+ let mut narrow = app((50, 30), "left");+ narrow.set_bar_width(MAX_WIDTH);+ assert_eq!(narrow.bar_width(), 30);+ assert_eq!(narrow.body().width, 20);+ // The width goes through tui.toml: written as the look is, read back as an option at boot.+ let look = crate::config::Look { status_bar_width: narrow.options.get("@hn-status-bar-width", "", None), ..Default::default() };+ assert!(look.assignments().contains(&("@hn-status-bar-width".to_string(), "30".to_string())));+ }++ #[test]+ fn the_wheel_scrolls_a_list_by_one_entry_and_the_focus_is_followed() {+ let mut app = app((80, 14), "left");+ let (s, _) = screen(&mut app);+ // A short bar: the windows' list shows a few rows of the eight its entries take.+ let max = app.bar.max_scroll[0];+ assert!(max >= 1, "{s}");+ for _ in 0..max + 2 { wheel(&mut app, Hit::Windows, false) }+ assert_eq!(app.bar.scroll[0], max, "no further than the last entry");+ for _ in 0..max + 2 { wheel(&mut app, Hit::Windows, true) }+ assert_eq!(app.bar.scroll[0], 0);+ // tmux's keys move the focus; the bar follows it into view.+ crate::commands::execute(&mut app, "select-pane -t %2");+ let (s, _) = screen(&mut app);+ assert_eq!(app.focused(), Some(3));+ let shown = app.bar.hits.iter().any(|(_, h)| *h == Hit::Pane(0, 3));+ assert!(shown && app.bar.scroll[0] > 0, "{s}");+ }++ /// A pane another window has the keyboard of is taken as soon as you come to it — by+ /// select-pane (a key) and by a click on its entry in the bar — not only once you type.+ #[test]+ fn coming_to_a_watched_pane_takes_it() {+ let mut app = app((120, 36), "left");+ for id in [2, 3] { app.panes.get_mut(&id).unwrap().phase = Phase::Watching("studio · other window".into()) }+ crate::commands::execute(&mut app, "select-pane -t %1");+ assert_eq!(app.focused(), Some(2));+ assert!(!matches!(app.panes[&2].phase, Phase::Watching(_)), "a key to it takes it");+ let _ = screen(&mut app);+ let hit = app.bar.hits.iter().find(|(_, h)| *h == Hit::Pane(0, 3)).map(|(_, h)| h.clone()).unwrap();+ click(&mut app, hit);+ assert_eq!(app.focused(), Some(3));+ assert!(!matches!(app.panes[&3].phase, Phase::Watching(_)), "a click on it takes it");+ }++ // ── box panes ──++ /// Box panes: each pane its own frame, a cell apart (never one line shared by two panes) — the+ /// focused one's in the accent, the one waiting on you in the attention colour, the others quiet.+ #[test]+ fn each_pane_is_its_own_box_in_the_focus_and_attention_colours() {+ let _colours = crate::term_out::colours_lock();+ let mut app = app((120, 36), "bottom");+ app.fleet.agents.get_mut(&("local".to_string(), "a2".to_string())).unwrap().question = Some(crate::fleet::Question {+ request_id: "r".into(), answer_key: "k".into(), prompt: "Allow edit?".into(), options: vec![], multi: false, since: std::time::Instant::now(),+ });+ let _ = app.options.set("pane-border-status", Some("off"), &crate::options::SetFlags { global: true, ..Default::default() }, "", 0);+ app.fit_panes();+ let (s, buf) = screen(&mut app);+ let frame = |id: u64| { let r = app.rects.iter().find(|(p, _)| *p == id).map(|(_, r)| *r).unwrap(); crate::pane_frame::boxed_in(r, app.window_area(app.tab()), app.box_inner(app.tab()), app.pane_status(app.tab())).surface };+ let (left, top_right, below) = (frame(1), frame(2), frame(3));+ let mid = left.y + left.height / 2;+ // The left box's right edge, one blank cell, the right box's left edge.+ assert_eq!(buf[(left.right() - 1, mid)].symbol(), "│", "{s}");+ assert_eq!(buf[(left.right(), mid)].symbol(), " ", "a gap between the boxes:\n{s}");+ assert_eq!(buf[(top_right.x, top_right.y + 1)].symbol(), "│", "{s}");+ assert_eq!(buf[(left.x, left.y)].symbol(), "┌");+ assert_eq!(buf[(top_right.x, top_right.y)].symbol(), "┌", "the right box is its own, not a joint:\n{s}");+ let (accent, attention) = (theme::paint(theme::accent()), theme::paint(theme::ATTENTION));+ assert_eq!(buf[(left.right() - 1, mid)].fg, accent, "the focused pane's frame");+ assert_eq!(buf[(top_right.x, top_right.y + 1)].fg, attention, "the waiting pane's frame");+ assert_ne!(buf[(below.x, below.y + 1)].fg, accent, "a quiet frame");+ assert_ne!(buf[(below.x, below.y + 1)].fg, attention, "a quiet frame");+ // The program is inside its frame.+ assert_eq!(app.content_of(app.tab(), app.rects.iter().find(|(p, _)| *p == 1).unwrap().1), Rect::new(left.x + 1, left.y + 1, left.width - 2, left.height - 2));+ }++ /// Two panes next to each other have one cell between them — across and down, boxes or+ /// blurred surfaces, pane titles off and on top, the status line at the bottom or the bar at a+ /// side: never each pane's space added to the other's. At the window's edges and the status+ /// line a pane has none (beside the bar, its blank edge is the one cell).+ #[test]+ fn panes_side_by_side_have_one_cell_between_and_none_at_the_edges() {+ for focus in ["line", "surface"] { for (side, titles) in [("bottom", "off"), ("bottom", "top"), ("left", "off"), ("left", "top"), ("right", "top")] {+ let mut app = app((120, 36), side);+ let global = crate::options::SetFlags { global: true, ..Default::default() };+ let _ = app.options.set("pane-border-status", Some(titles), &global, "", 0);+ let _ = app.options.set("@hn-focus", Some(focus), &global, "", 0);+ app.fit_panes();+ let (s, _) = screen(&mut app);+ let tab = app.tab();+ let (canvas, inner, status) = (app.window_area(tab), app.box_inner(tab), app.pane_status(tab));+ let f: Vec<Rect> = [1, 2, 3].iter().map(|id| { let r = app.rects.iter().find(|(p, _)| p == id).unwrap().1; crate::pane_frame::frame(r, canvas, inner, status).surface }).collect();+ let at = format!("{focus}, {side}, titles {titles}:\n{s}");+ // Across: the left edge (the bar's blank column when it is on the left), between, the right edge.+ assert_eq!(f[0].x, canvas.x, "left edge {at}");+ if side == "left" { assert_eq!(canvas.x, app.bar_width(), "the bar's blank edge is the gap {at}"); }+ assert_eq!(f[1].x - f[0].right(), 1, "between, across {at}");+ assert_eq!(f[1].right(), canvas.right(), "right edge {at}");+ if side == "right" { assert_eq!(app.size.0 - app.bar_width(), canvas.right(), "the bar's blank edge is the gap {at}"); }+ // Down: the top edge, between the two stacked panes, the bottom edge (the status line).+ assert_eq!(f[0].y, canvas.y, "top edge {at}");+ assert_eq!(f[2].y - f[1].bottom(), 1, "between, down {at}");+ assert_eq!((f[0].bottom(), f[2].bottom()), (canvas.bottom(), canvas.bottom()), "bottom edge {at}");+ } }+ }+}diff --git a/tui/src/bar_more.rs b/tui/src/bar_more.rsnew file mode 100644index 000000000..dc5a8b0cd--- /dev/null+++ b/tui/src/bar_more.rs@@ -0,0 +1,91 @@+//! The status bar down a side, its footer: what tmux's status line shows on its right (the+//! subscription left, the harnesses' counts, the daemon, where you are, the time), which has no+//! line of its own while the bar stands in for it.+use ratatui::buffer::Buffer;+use ratatui::layout::Rect;+use ratatui::style::Style;++use crate::app::App;+use crate::theme;++/// The footer's lines, each one thing: the daemon when it is down, the subscription left, the+/// harnesses' counts on one line. (Where you are — the machine, which names the session too — is+/// the bar's own heading, and the folder each pane's title: not said again.)+const LINES: [&str; 3] = [+ "#{?daemon_down,#[fg=red#,bold]daemon down#[default],}",+ "#{?usage_remaining,#{usage_remaining_icons},}",+ "#{?fleet,#{s/ / /:fleet},}",+];++fn items(app: &App) -> Vec<String> {+ LINES.iter().map(|fmt| crate::format::expand(app, fmt, app.active, app.focused(), true).trim().to_string()).filter(|s| !plain(s).is_empty()).collect()+}++/// An item's words without its `#[…]` styles.+fn plain(s: &str) -> String {+ let mut out = String::new();+ let mut rest = s;+ while let Some(at) = rest.find("#[") {+ out.push_str(&rest[..at]);+ rest = rest[at..].find(']').map(|end| &rest[at + end + 1..]).unwrap_or("");+ }+ out.push_str(rest);+ out.trim().to_string()+}++/// The rows the footer takes at the bottom of the bar: a rule, then one row an item (at most+/// six, and never more than a third of the bar).+pub fn footer_height(app: &App, width: u16) -> u16 {+ let _ = width;+ let n = items(app).len().min(6) as u16;+ if n == 0 { 0 } else { (n + 1).min(app.size.1 / 3) }+}++/// Draw the footer in [r]: a rule over it, then status-right's items, each in its own styles.+pub fn footer(buf: &mut Buffer, app: &App, r: Rect) {+ if r.height == 0 || r.width < 4 { return }+ let pal = theme::pane_palette();+ let base = Style::default().fg(theme::paint(pal.muted)).bg(theme::depth_fit(pal.surface));+ for x in r.x..r.right() { if let Some(c) = buf.cell_mut((x, r.y)) { c.set_symbol("─").set_style(Style::default().fg(theme::paint(pal.border)).bg(base.bg.unwrap_or_default())); } }+ for (row, item) in items(app).iter().take(r.height.saturating_sub(1) as usize).enumerate() {+ let y = r.y + 1 + row as u16;+ for x in r.x..r.right() { if let Some(c) = buf.cell_mut((x, y)) { c.reset(); c.set_style(base); } }+ let cells = crate::draw::format_draw_over(item, base, r.width.saturating_sub(2));+ for (i, cell) in cells.into_iter().enumerate() {+ if let Some((ch, cs)) = cell { if let Some(c) = buf.cell_mut((r.x + 1 + i as u16, y)) { c.set_symbol(if ch.is_empty() { " " } else { &ch }); c.set_style(cs); } }+ }+ }+}++#[cfg(test)]+mod tests {+ use super::*;++ fn app() -> App {+ let (sink, _) = tokio::sync::mpsc::unbounded_channel();+ let mut app = App::new(19789, sink, (120, 36));+ app.fleet.local_id = "local".into();+ app.fleet.machines.push(crate::fleet::Machine { id: "local".into(), name: "studio".into(), local: true, status: "online".into(), reach: crate::fleet::Reach::Ready });+ app+ }++ /// The footer says one thing a line and nothing twice: the daemon when down (bold) — no machine,+ /// session, path or time (the bar's heading has the machine, which names the session).+ #[test]+ fn the_footer_says_one_thing_a_line() {+ let mut app = app();+ app.daemon_down = true;+ let lines = items(&app);+ assert!(lines[0].contains("daemon down"), "{lines:?}");+ assert!(!lines.iter().any(|l| l.len() == 5 && l.as_bytes()[2] == b':'), "no time: {lines:?}");+ assert!(!lines.iter().any(|l| l.contains("studio")), "no machine again: {lines:?}");+ let h = footer_height(&app, 26);+ assert_eq!(h, lines.len() as u16 + 1);+ let r = Rect::new(0, 30, 26, h);+ let mut buf = Buffer::empty(Rect::new(0, 0, 26, 36));+ footer(&mut buf, &app, r);+ let row = |y: u16| (0..26).map(|x| buf[(x, y)].symbol().to_string()).collect::<String>();+ assert!(row(30).starts_with("──"));+ assert!(row(31).contains("daemon down") && buf[(1, 31)].style().add_modifier.contains(ratatui::style::Modifier::BOLD));+ }+}diff --git a/tui/src/commands.rs b/tui/src/commands.rsindex 62710858c..228baa0be 100644--- a/tui/src/commands.rs+++ b/tui/src/commands.rs@@ -85,6 +85,7 @@ pub const COMMANDS: &[(&str, &str, &str)] = &[("confirm-before", "confirm", "Ask y/n before a command"),("new-harness", "newh", "New harness: [engine] [@machine] [folder] — or choose"),("new-terminal", "newt", "A shell on this pane's machine"),+ ("choose-command", "choosec", "Every command and setting by name (C-b Enter)"),("clone-harness", "cloneh", "A second harness with this one's history"),("restart-harness", "restarth", "Restart this harness"),("pause-harness", "pauseh", "Pause this harness (the conversation is kept)"),@@ -1242,6 +1243,10 @@ fn run_words(app: &mut App, words: &[String]) {fn after_set(app: &mut App, name: &str, now: Option<String>, global: bool, tab: Option<usize>) {let name = name.to_string();if name == "@hn-look" { app.redraw_all = true; app.fit_panes(); app.push_theme(); }+ // (Set by hand too — `set -g @hn-theme …`, `@hn-lists fzf`: the colours and lists follow.)+ if matches!(name.as_str(), "@hn-accent" | "@hn-theme" | "@hn-lists") { app.sync_accent(); app.redraw_all = true }+ // (The bar down a side and the pane frames change the panes' room.)+ if matches!(name.as_str(), "@hn-status-bar" | "@hn-border" | "@hn-focus") { app.redraw_all = true; app.fit_panes(); }// alerts_reset_all: every window's silence timer starts again.if name == "monitor-silence" { for t in app.tabs.iter_mut() { t.last_output = std::time::Instant::now() } }if name.starts_with('@') && now.is_none() { app.opts.user.remove(&name); return }@@ -3479,6 +3484,7 @@ fn run_words_in(app: &mut App, words: &[String]) {}"new-harness" => { if words.len() < 2 { input::run(app, "new") } else { input::new_harness_words(app, &words[1..]) } }"new-terminal" => input::run(app, "terminal"),+ "choose-command" => input::run(app, "commands"),// A harness's verbs, on -t's harness (the hook's in a harness-* hook), else the focused// pane's; from a shell -t is needed, and one mid-turn is restarted or paused only with -y// (the keys ask first).diff --git a/tui/src/config.rs b/tui/src/config.rsindex 4d485e4d6..c20a3bfdb 100644--- a/tui/src/config.rs+++ b/tui/src/config.rs@@ -1,4 +1,4 @@-//! `~/.config/harness/tui.toml` — the person's own keys and a few switches.+//! `~/.config/harness/tui.toml` — the person's own keys, a few switches, and the look of hn.//!//! ```toml//! prefix = "ctrl+a" # instead of ctrl+space@@ -10,8 +10,24 @@//! "alt+h" = "none" # give ⌥h back to the pane (vim, readline…)//! "alt+x" = "close-pane"//! "super+k" = "palette"+//!+//! [look]+//! preset = "classic" # classic|panes|tmux|vim|lazyvim — a named bundle+//! focus = "line" # line|surface — a highlighted border vs the "blurred" surface+//! border_lines = "single" # single|double|heavy|simple|number+//! border_indicators = "colour" # off|colour|arrows|both+//! border_status = "off" # off|top|bottom (each pane's title row)+//! layout_orientation = "auto" # auto|vertical|horizontal (default split direction)+//! layout_preset = "auto" # auto|even-horizontal|even-vertical|main-horizontal|main-vertical|tiled+//! # optional color overrides (#rrggbb or a tmux colour name)+//! # active_border = "#7aa2f7"+//! # border = "#3b4261"+//! # accent = "#7aa2f7"//! ```//!+//! Every `[look]` field is optional: an unset one falls back to the preset (or hn's default).+//! The file is a startup default — `hn set -g` afterward still wins.+//!//! A key names modifiers (`ctrl` `alt` `shift` `super`, joined by `+`) and one key: a character,//! or `enter` `tab` `esc` `space` `backspace` `left` `right` `up` `down` `pageup` `pagedown`//! `home` `end` `f1`…`f12`. A command is anything ⌥P's `>` lists by id (see `harness tui --keys`),@@ -79,21 +95,117 @@ impl Chord {}}+/// The one place the look/theme of hn is configured — a named preset plus per-knob overrides.+/// Every field is optional: unset fields fall back to the preset (or hn's default look).+#[derive(Clone, Debug, Default, PartialEq)]+pub struct Look {+ /// The named look: `classic` (default) | `panes` | `tmux` | `vim` | `lazyvim`.+ pub preset: Option<String>,+ /// Pane focus: `line` (active pane's border is highlighted) | `surface` ("blur": the active+ /// pane's surface pops and the rest are dimmed, no border line).+ pub focus: Option<String>,+ /// `pane-border-lines`: single | double | heavy | simple | number.+ pub border_lines: Option<String>,+ /// `pane-border-indicators`: off | colour | arrows | both.+ pub border_indicators: Option<String>,+ /// `pane-border-status` (each pane's title row): off | top | bottom.+ pub border_status: Option<String>,+ /// Default split direction for a new harness/pane: auto | vertical | horizontal.+ pub layout_orientation: Option<String>,+ /// The layout arranged when a tab has several panes: auto | even-horizontal | even-vertical+ /// | main-horizontal | main-vertical | tiled.+ pub layout_preset: Option<String>,+ /// Optional color overrides (`#rrggbb` or a tmux colour name).+ pub active_border: Option<String>,+ pub border: Option<String>,+ pub accent: Option<String>,+ /// A bundled terminal theme picked from `hn theme` (one of hn's bundled theme names). hn+ /// draws its palette from the terminal, so the theme's colours show up there; hn only records+ /// the choice here (and tints its chrome with the theme's signature colour) so it survives a+ /// restart. `None` = keep the terminal's own theme.+ pub theme: Option<String>,+ // ── status bar ──+ /// Where the status bar goes: `bottom` (default) | `top` (tmux's status line, status-position)+ /// | `left` | `right` (a bar down the side: the windows with their panes, the machines with theirs).+ pub status_bar: Option<String>,+ /// How panes are set apart: `box` (default: each pane its own frame) | `line` (tmux's shared lines).+ pub border_style: Option<String>,+ /// The bar's width down a side, in columns (18-36; 26 unless dragged).+ pub status_bar_width: Option<String>,+}+pub struct Config {pub prefix: Chord,/// Whether the file named a prefix (else tmux's, or ~/.tmux.conf's, stands).pub prefix_set: bool,pub keys: Vec<(Chord, Option<String>)>,+ /// The `[look]` table, if any.+ pub look: Option<Look>,pub problems: Vec<String>,}+impl Look {+ /// The bundle each named look sets beyond its `@hn-look` value. Focus (line|surface) is the+ /// piece that changes the most — how panes are drawn (a highlighted border vs a "blurred"+ /// surface) — so it is what the presets differ by. Colors are left to the theme or [look].+ pub fn look_preset(preset: &str) -> Vec<(&'static str, &'static str)> {+ match preset {+ "panes" | "lazyvim" => vec![("@hn-focus", "surface")],+ _ => vec![],+ }+ }++ /// The `(option, value)` pairs this `[look]` table sets at boot: the preset's defaults first,+ /// then whichever knobs the file named, which override them.+ pub fn assignments(&self) -> Vec<(String, String)> {+ let preset = self.preset.as_deref().unwrap_or("classic");+ // `@hn-look` tells structure which bundle is on; `@hn-focus` (from the preset or an+ // explicit `focus`) tells how panes are drawn. Both are options, so `hn show` sees them.+ let mut out: Vec<(String, String)> = vec![("@hn-look".into(), preset.to_string())];+ // A preset's `@hn-focus` is its default; an explicit `focus` knob overrides it, so do not+ // emit the preset's when the file named one (the later assignment would win anyway).+ for (n, v) in Self::look_preset(preset) {+ if n == "@hn-focus" && self.focus.is_some() { continue }+ out.push((n.into(), v.into()))+ }+ if let Some(f) = &self.focus { out.push(("@hn-focus".into(), f.clone())) }+ if let Some(b) = &self.border_lines { out.push(("pane-border-lines".into(), b.clone())) }+ if let Some(b) = &self.border_indicators { out.push(("pane-border-indicators".into(), b.clone())) }+ if let Some(b) = &self.border_status { out.push(("pane-border-status".into(), b.clone())) }+ if let Some(o) = &self.layout_orientation { out.push(("@hn-layout".into(), o.clone())) }+ if let Some(o) = &self.layout_preset { out.push(("@hn-layout-preset".into(), o.clone())) }+ if let Some(c) = &self.active_border { out.push(("pane-active-border-style".into(), format!("fg={c}"))) }+ if let Some(c) = &self.border { out.push(("pane-border-style".into(), format!("fg={c}"))) }+ // The accent: an explicit `accent` wins; otherwise a chosen terminal theme supplies its+ // signature color (so the picker's choice tints chrome at boot too, not only live).+ if let Some(c) = &self.accent { out.push(("@hn-accent".into(), c.clone())) }+ else if let Some(g) = &self.theme {+ if let Some(a) = crate::theme::theme_accent_hex(g) { out.push(("@hn-accent".into(), a)) }+ }+ if let Some(g) = &self.theme { out.push(("@hn-theme".into(), g.clone())) }+ // ── status bar ──+ // (At the top or the bottom it is tmux's own status line, so status-position says where.)+ if let Some(b) = &self.status_bar {+ out.push(("@hn-status-bar".into(), b.clone()));+ if matches!(b.as_str(), "top" | "bottom") { out.push(("status-position".into(), b.clone())) }+ }+ if let Some(b) = &self.border_style { out.push(("@hn-border".into(), b.clone())) }+ if let Some(w) = &self.status_bar_width { out.push(("@hn-status-bar-width".into(), w.clone())) }+ out+ }+}+impl Default for Config {fn default() -> Self {- Config { prefix: Chord::normal(KeyCode::Char('b'), KeyModifiers::CONTROL), prefix_set: false, keys: Vec::new(), problems: Vec::new() }+ Config { prefix: Chord::normal(KeyCode::Char('b'), KeyModifiers::CONTROL), prefix_set: false, keys: Vec::new(), look: None, problems: Vec::new() }}}pub fn path() -> PathBuf {+ // (Tests never read or write the real config: theirs is their own.)+ #[cfg(test)]+ return std::env::temp_dir().join(format!("hn-test-{}", std::process::id())).join("harness").join("tui.toml");+ #[allow(unreachable_code)]let base = std::env::var("XDG_CONFIG_HOME").ok().filter(|s| !s.is_empty()).map(PathBuf::from).unwrap_or_else(|| PathBuf::from(std::env::var("HOME").unwrap_or_default()).join(".config"));base.join("harness").join("tui.toml")@@ -124,9 +236,99 @@ pub fn load() -> Config {}}}+ if let Some(look) = value.get("look").and_then(|v| v.as_table()) { config.look = Some(look_of(look, &mut config.problems)) }config}+/// The `[look]` table as read, a knob that is not a string said in [problems].+fn look_of(look: &toml::Table, problems: &mut Vec<String>) -> Look {+ let mut l = Look::default();+ let mut field = |t: &toml::Table, key: &str, slot: &mut Option<String>| {+ if let Some(v) = t.get(key) {+ if let Some(s) = v.as_str() { *slot = Some(s.to_string()) }+ else { problems.push(format!("tui.toml look.{key}: expected a string")) }+ }+ };+ field(look, "preset", &mut l.preset);+ field(look, "focus", &mut l.focus);+ field(look, "border_lines", &mut l.border_lines);+ field(look, "border_indicators", &mut l.border_indicators);+ field(look, "border_status", &mut l.border_status);+ field(look, "layout_orientation", &mut l.layout_orientation);+ field(look, "layout_preset", &mut l.layout_preset);+ field(look, "active_border", &mut l.active_border);+ field(look, "border", &mut l.border);+ field(look, "accent", &mut l.accent);+ field(look, "theme", &mut l.theme);+ // ── status bar ──+ field(look, "status_bar", &mut l.status_bar);+ field(look, "border_style", &mut l.border_style);+ field(look, "status_bar_width", &mut l.status_bar_width);+ // (An older file's `tabs` is left alone: the tabs over the panes are gone, the bar lists the windows.)+ l+}++/// Write the `[look]` table back to the file, replacing an existing `[look]` section in place and+/// leaving the rest of the file (and its comments) untouched. Used by the `hn theme` picker so the+/// file stays the single place the look is described.+pub fn write_look(look: &Look) -> std::io::Result<()> {+ let p = path();+ let existing = std::fs::read_to_string(&p).unwrap_or_default();+ // (A first setting on a machine with no config yet: its folder too.)+ if let Some(dir) = p.parent() { std::fs::create_dir_all(dir)? }+ std::fs::write(p, replace_look_section(&existing, &format_look(look)))?;+ Ok(())+}++fn is_section_header(line: &str) -> bool { line.starts_with('[') && line.trim_end().ends_with(']') }++fn format_look(look: &Look) -> String {+ let mut s = String::from("[look]\n");+ let push = |slot: &Option<String>, key: &str, s: &mut String| {+ if let Some(v) = slot { s.push_str(&format!("{key} = \"{}\"\n", v.replace('\\', "\\\\").replace('"', "\\\""))) }+ };+ push(&look.preset, "preset", &mut s);+ push(&look.focus, "focus", &mut s);+ push(&look.border_lines, "border_lines", &mut s);+ push(&look.border_indicators, "border_indicators", &mut s);+ push(&look.border_status, "border_status", &mut s);+ push(&look.layout_orientation, "layout_orientation", &mut s);+ push(&look.layout_preset, "layout_preset", &mut s);+ push(&look.theme, "theme", &mut s);+ // ── status bar ──+ push(&look.status_bar, "status_bar", &mut s);+ push(&look.border_style, "border_style", &mut s);+ push(&look.status_bar_width, "status_bar_width", &mut s);+ s+}++fn replace_look_section(text: &str, block: &str) -> String {+ let lines: Vec<&str> = text.lines().collect();+ let header_at = lines.iter().position(|l| is_section_header(l) && l.trim() == "[look]");+ let Some(header_at) = header_at else {+ // No [look] yet: append a fresh section, separated from whatever preceded it.+ let mut out = text.to_string();+ if !out.is_empty() {+ if !out.ends_with('\n') { out.push('\n') }+ out.push('\n');+ }+ out.push_str(block);+ if !out.ends_with('\n') { out.push('\n') }+ return out;+ };+ // Replace from the header through the line before the next section header (or end).+ let next_header = lines[header_at + 1..].iter().position(|l| is_section_header(l)).map(|i| header_at + 1 + i).unwrap_or(lines.len());+ let mut out: Vec<&str> = lines[..header_at].to_vec();+ let tail = lines[next_header..].to_vec();+ // Rebuild: head lines, the new block as its own lines, then the tail.+ let block_lines: Vec<&str> = block.lines().collect();+ out.extend(block_lines.iter().copied());+ out.extend(tail.iter().copied());+ let mut joined = out.join("\n");+ joined.push('\n');+ joined+}+#[cfg(test)]mod tests {use super::*;@@ -141,6 +343,55 @@ mod tests {assert!(Chord::parse("hyper+x").is_err());}+ #[test]+ fn look_preset_sets_surface_for_the_blur_bundles() {+ assert_eq!(Look::look_preset("lazyvim"), vec![("@hn-focus", "surface")]);+ assert_eq!(Look::look_preset("panes"), vec![("@hn-focus", "surface")]);+ assert!(Look::look_preset("vim").is_empty());+ assert!(Look::look_preset("classic").is_empty());+ assert!(Look::look_preset("tmux").is_empty());+ }++ #[test]+ fn look_assignments_follow_preset_then_overrides() {+ // Defaults from the preset, with an explicit `focus` replacing the preset's surface.+ let look = Look {+ preset: Some("lazyvim".into()), focus: Some("line".into()),+ border_lines: Some("heavy".into()), layout_orientation: Some("vertical".into()),+ active_border: Some("#7aa2f7".into()), ..Default::default()+ };+ let a = look.assignments();+ let get = |name: &str| a.iter().find(|(n, _)| n == name).map(|(_, v)| v.clone());+ assert_eq!(get("@hn-look").as_deref(), Some("lazyvim"));+ // The explicit `focus` replaces the preset's, not added after it.+ assert_eq!(get("@hn-focus").as_deref(), Some("line"));+ assert_eq!(get("pane-border-lines").as_deref(), Some("heavy"));+ assert_eq!(get("@hn-layout").as_deref(), Some("vertical"));+ assert_eq!(get("pane-active-border-style").as_deref(), Some("fg=#7aa2f7"));+ // The surface preset, without an override, keeps its default focus.+ let plain = Look { preset: Some("panes".into()), ..Default::default() };+ let b = plain.assignments();+ let get_b = |name: &str| b.iter().find(|(n, _)| n == name).map(|(_, v)| v.clone());+ assert_eq!(get_b("@hn-focus").as_deref(), Some("surface"));+ }++ #[test]+ fn theme_is_recorded_and_replayed() {+ // Choosing a terminal theme writes it to the config; at boot `@hn-theme` is replayed so+ // the picker marks it, and its signature colour becomes the accent unless one is named.+ let look = Look { preset: Some("panes".into()), theme: Some("Atom One Dark".into()), ..Default::default() };+ let a = look.assignments();+ assert_eq!(a.iter().find(|(n, _)| n == "@hn-theme").map(|(_, v)| v.as_str()), Some("Atom One Dark"));+ assert!(a.iter().any(|(n, _)| n == "@hn-accent"));+ // The [look] block carries it, escaping quotes/backslashes.+ let block = format_look(&look);+ assert!(block.contains("theme = \"Atom One Dark\"\n"));+ // An explicit `accent` wins over the theme's own.+ let explicit = Look { theme: Some("Atom One Dark".into()), accent: Some("#abcdef".into()), ..Default::default() };+ let b = explicit.assignments();+ assert_eq!(b.iter().find(|(n, _)| n == "@hn-accent").map(|(_, v)| v.as_str()), Some("#abcdef"));+ }+#[test]fn keys_from_the_terminal_as_tmux_names_them() {let key = |code, mods| crate::keys::name(&Chord::of(&KeyEvent::new(code, mods)));@@ -154,4 +405,46 @@ mod tests {assert_eq!(Chord::of(&KeyEvent::new(KeyCode::Char('4'), KeyModifiers::CONTROL)), crate::keys::parse("C-\\").unwrap());assert_eq!(key(KeyCode::Char('4'), KeyModifiers::ALT), "M-4");}++ #[test]+ fn replace_look_section_rewrites_in_place_and_preserves_rest() {+ // Replaces an existing [look] block, keeping the lines before and after (and comments).+ let original = "prefix = \"ctrl+a\"\n# my comment\n[look]\npreset = \"classic\"\nfocus = \"line\"\n[keys]\n\"alt+h\" = \"none\"\n";+ let block = "[look]\npreset = \"panes\"\nfocus = \"surface\"\nborder_lines = \"single\"\n";+ let replaced = replace_look_section(original, block);+ assert!(replaced.starts_with("prefix = \"ctrl+a\"\n# my comment\n"));+ assert!(replaced.contains("[look]\npreset = \"panes\"\nfocus = \"surface\"\nborder_lines = \"single\"\n"));+ assert!(!replaced.contains("preset = \"classic\""));+ assert!(replaced.ends_with("[keys]\n\"alt+h\" = \"none\"\n"));++ // Appends a fresh [look] section when the file has none.+ let none = "prefix = \"ctrl+a\"\n";+ let appended = replace_look_section(none, block);+ assert!(appended.ends_with("prefix = \"ctrl+a\"\n\n[look]\npreset = \"panes\"\nfocus = \"surface\"\nborder_lines = \"single\"\n"));+ }++ // ── status bar ──++ #[test]+ fn the_status_bar_and_border_style_go_through_tui_toml_and_back() {+ let look = Look { status_bar: Some("left".into()), border_style: Some("line".into()), ..Default::default() };+ let text = format_look(&look);+ assert!(text.contains("status_bar = \"left\"\nborder_style = \"line\"\n"), "{text}");+ let value: toml::Value = text.parse().unwrap();+ let mut problems = Vec::new();+ assert_eq!(look_of(value.get("look").and_then(|v| v.as_table()).unwrap(), &mut problems), look);+ assert!(problems.is_empty());+ // An older file's `tabs` line reads as nothing, and says no problem.+ let old: toml::Value = format!("{text}tabs = \"off\"\n").parse().unwrap();+ assert_eq!(look_of(old.get("look").and_then(|v| v.as_table()).unwrap(), &mut problems), look);+ assert!(problems.is_empty());+ // Each is an option at boot; at the top or bottom the bar is tmux's status line, placed so.+ let a = look.assignments();+ let get = |a: &[(String, String)], n: &str| a.iter().find(|(k, _)| k == n).map(|(_, v)| v.clone());+ assert_eq!(get(&a, "@hn-status-bar").as_deref(), Some("left"));+ assert_eq!(get(&a, "@hn-border").as_deref(), Some("line"));+ assert_eq!(get(&a, "status-position"), None);+ let top = Look { status_bar: Some("top".into()), ..Default::default() }.assignments();+ assert_eq!(get(&top, "status-position").as_deref(), Some("top"));+ }}diff --git a/tui/src/daemon.rs b/tui/src/daemon.rsindex c6ab56b9c..994a7b06a 100644--- a/tui/src/daemon.rs+++ b/tui/src/daemon.rs@@ -245,6 +245,12 @@ impl Link {// ── REST on the same port (machines, desk, status) ──────────────────────────────pub async fn http_json(port: u16, method: &str, path: &str, body: Option<&Value>) -> Result<Value, RpcError> {+ http_json_for(port, method, path, body, Duration::from_secs(15)).await+}++/// [http_json] with its own wait: a long poll (`POST /api/pair` holds the request for as long as a+/// phone's handshake runs) needs more than the usual 15 s.+pub async fn http_json_for(port: u16, method: &str, path: &str, body: Option<&Value>, wait: Duration) -> Result<Value, RpcError> {use tokio::io::{AsyncReadExt, AsyncWriteExt};let work = async {let mut stream = tokio::net::TcpStream::connect(("127.0.0.1", port)).await.map_err(|e| RpcError::new("DAEMON_UNREACHABLE", e.to_string()))?;@@ -268,7 +274,7 @@ pub async fn http_json(port: u16, method: &str, path: &str, body: Option<&Value>}Ok(if value.get("success").is_some() && value.get("data").is_some() { value["data"].clone() } else { value })};- tokio::time::timeout(Duration::from_secs(15), work).await.unwrap_or_else(|_| Err(RpcError::new("TIMEOUT", "the daemon did not answer")))+ tokio::time::timeout(wait, work).await.unwrap_or_else(|_| Err(RpcError::new("TIMEOUT", "the daemon did not answer")))}fn dechunk(body: &[u8]) -> Vec<u8> {diff --git a/tui/src/devices.rs b/tui/src/devices.rsnew file mode 100644index 000000000..80128c59c--- /dev/null+++ b/tui/src/devices.rs@@ -0,0 +1,1791 @@+//! Machines & devices in the panel — the desktop app's machine and device screens, drawn the TUI+//! way and reached from the Commands panel (its Machines group):+//!+//! - **Connect a machine…** — a machine on the account that is not linked yet, its remote password+//! (hidden), then `harness link connect <id> --stdin --json` with the stages it reports, live.+//! - **Machines & devices…** — this computer's remote password, the account's machines (rename,+//! remove), the links made from here (unlink), and the steps that add another machine.+//! - **Add phone…** — the QR code the app shows (the very same link), in half blocks.+//!+//! Everything that writes asks y/n in the panel's footer first. The CLI and the daemon's REST go+//! through one [Req] → [Reply] runner, which tests replace with fake answers: nothing here reaches a+//! real daemon or CLI from a test.++use std::collections::HashMap;+use std::time::{Duration, Instant};++use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};+use ratatui::buffer::Buffer;+use ratatui::layout::{Position, Rect};+use ratatui::style::{Color, Modifier, Style};+use ratatui::text::{Line, Span};+use serde_json::{json, Value};+use unicode_width::UnicodeWidthStr;++use crate::app::App;+use crate::fleet::{Reach, State};+use crate::modal::{Modal, PickerKind};+use crate::picker::{Picker, Row};+use crate::settings::{self, Chrome};+use crate::theme::{self, fg};++// ── what the app shows (desktop wording, kept word for word) ──────────────────++/// Where Harness is downloaded (link_another_machine_dialog.dart).+pub const DOWNLOAD_URL: &str = "https://www.autonomous.ai/harness";+/// A server's three steps, run on THAT machine over SSH: copied, never run here.+pub const INSTALL: &str = "curl -fsSL https://cdn.autonomous.ai/harness/cli/install.sh | bash";+pub const LOGIN: &str = "harness login";+pub const START: &str = "harness start && harness remote-password set";++/// Where the Add Phone QR points (add_phone_dialog.dart `phonePairLink`): the phone parses exactly+/// this, so the TUI's code is the app's, byte for byte.+const PAIR_HOST: &str = "harness.autonomous.ai";+const PAIR_PATH: &str = "/pair";+/// The pairing code's characters: no 0 O 1 I L, which read alike — and no U: the daemon maps U to V+/// and the phone does not, so a code with a U in it would never match.+const CODE_ALPHABET: &[u8] = b"ABCDEFGHJKMNPQRSTVWXYZ23456789";+const CODE_LEN: usize = 16;+/// What `/api/pair` answers when this daemon cannot pair a phone at all.+const UNAVAILABLE: &str = "PAIRING_UNAVAILABLE";++/// `link connect --json`'s stages, in order, and what each is in words.+pub const STAGES: [(&str, &str); 4] = [+ ("connecting", "Connecting"),+ ("deriving_key", "Checking the password"),+ ("exchanging", "Exchanging keys"),+ ("verifying", "Verifying the link"),+];++/// The three views, each a Commands row.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum View { Connect, Phone, Machines }++impl View {+ pub const ALL: [View; 3] = [View::Connect, View::Phone, View::Machines];+ /// Its command id (the Commands row's, `run`'s).+ pub fn id(self) -> &'static str {+ match self { View::Connect => "connect-machine", View::Phone => "add-phone", View::Machines => "devices" }+ }+ pub fn of(id: &str) -> Option<View> { View::ALL.into_iter().find(|v| v.id() == id) }+ pub fn title(self) -> &'static str {+ match self { View::Connect => "Connect a machine", View::Phone => "Add your phone", View::Machines => "Machines & devices" }+ }+ fn placeholder(self) -> &'static str {+ match self {+ View::Connect => "Search machines not linked yet",+ View::Phone => "Search paired devices",+ View::Machines => "Search machines, links and steps",+ }+ }+}++// ── the state ────────────────────────────────────────────────────────────────++/// A machine this computer has linked (`harness link list`).+#[derive(Clone, Debug, PartialEq)]+pub struct Linked { pub machine: String, pub fingerprint: String, pub at: String }++/// A `link connect` under way, or just over: the stage it last reported, and how it ended.+pub struct Linking { pub machine: String, pub name: String, pub stage: String, pub result: Option<Result<String, String>> }++/// Add phone: the code the QR carries, the sign-in code with it, and the pairing's round of asking.+#[derive(Default)]+pub struct Phone {+ /// The view is open (its rounds stop when it is not), and which opening this is.+ pub open: bool,+ pub generation: u64,+ pub code: String,+ pub email: Option<String>,+ pub signed_out: bool,+ /// The one-time sign-in code (`h=`), once asked for: none after asking is a QR without one —+ /// the phone then asks for an emailed code.+ pub sign_in: Option<String>,+ pub sign_in_asked: bool,+ /// You said yes: the daemon is handed the code (`POST /api/pair`) for as long as the QR shows.+ pub armed: bool,+ pub connected: Option<String>,+ pub message: Option<String>,+ /// A message that tells you to do something ("scan the new code"): the next "no phone yet"+ /// leaves it up.+ pub sticky: bool,+ pub stopped: bool,+ pub paired: Vec<Value>,+ /// Where the QR was last drawn, and the last encoding (link, room) → modules.+ pub drawn: std::cell::Cell<Option<Rect>>,+ cache: std::cell::RefCell<Option<(String, u16, u16, Option<Vec<Vec<bool>>>)>>,+}++/// A line typed into the panel's query line, and what it is for.+#[derive(Clone, Debug)]+pub enum Entry {+ Link { machine: String, name: String },+ NewPassword,+ RepeatPassword { first: String },+ Rename { machine: String, name: String },+}++/// What a yes does.+#[derive(Clone, Debug)]+pub enum Act {+ Link { machine: String, name: String, password: String },+ SetPassword(String),+ ClearPassword,+ Unlink { machine: String, name: String },+ Rename { machine: String, name: String },+ Remove { machine: String, name: String },+ Unpair { fingerprint: String, name: String },+ ArmPhone,+}++/// The panel is asking: a line to type (a password shown as dots), or a y/n before a write.+#[derive(Clone, Debug)]+pub enum Ask {+ Entry { what: Entry, label: String, value: String, secret: bool },+ Confirm { question: String, act: Act },+}++pub struct Devices {+ /// `remote-password status --json` ({hasPassword, fingerprint, setAt}), or why it is unknown.+ pub password: Option<Result<Value, String>>,+ pub links: Option<Result<Vec<Linked>, String>>,+ /// `GET /api/machines`'s rows, by machine id (what the fleet does not keep: when it was seen).+ pub account: HashMap<String, Value>,+ pub link: Option<Linking>,+ pub phone: Phone,+ pub ask: Option<Ask>,+ /// A level inside a view: a machine's actions (`m:<id>`).+ pub sub: Option<String>,+ /// The footer's line: what happened, or (true) what went wrong — until the next thing does.+ pub footer: Option<(String, bool, Instant)>,+ pub loading: Vec<&'static str>,+ /// None: the real CLI and daemon. Tests put fake answers here.+ pub runner: Option<Runner>,+}++impl Default for Devices {+ fn default() -> Devices {+ Devices {+ password: None, links: None, account: HashMap::new(), link: None, phone: Phone::default(), ask: None, sub: None, footer: None, loading: Vec::new(), runner: default_runner(),+ }+ }+}++/// Under test nothing real is ever run: the CLI and the daemon answer that they are not there.+#[cfg(test)]+fn default_runner() -> Option<Runner> {+ Some(Box::new(|req: &Req| match req {+ Req::Wait(_) => None,+ Req::Cli { .. } => Some(Reply::Cli { ok: false, out: String::new(), err: "no Harness CLI in tests".into() }),+ Req::Http { .. } => Some(Reply::Http(Err(("TEST".into(), "no daemon in tests".into())))),+ _ => Some(Reply::Done),+ }))+}+#[cfg(not(test))]+fn default_runner() -> Option<Runner> { None }++// ── the runner ───────────────────────────────────────────────────────────────++/// One thing a view asks of the world.+#[derive(Clone, Debug, PartialEq)]+pub enum Req {+ /// The Harness CLI with these arguments; [stdin] is one line for it to read (a password), so a+ /// secret is never an argument another process could see.+ Cli { args: Vec<String>, stdin: Option<String> },+ /// This computer's daemon, over its REST.+ Http { method: &'static str, path: String, body: Option<Value> },+ /// Text for the clipboard of the computer you sit at.+ Copy(String),+ /// A pause, then the next round (the phone's pairing, its sign-in code).+ Wait(Duration),+}++#[derive(Clone, Debug)]+pub enum Reply {+ Cli { ok: bool, out: String, err: String },+ /// The body (its `data`, when enveloped), or (code, message).+ Http(Result<Value, (String, String)>),+ Done,+}++/// Answers a [Req] at once (Some), or never (None: a pause that is not over).+pub type Runner = Box<dyn FnMut(&Req) -> Option<Reply> + Send>;++fn cli(args: &[&str], stdin: Option<String>) -> Req { Req::Cli { args: args.iter().map(|a| a.to_string()).collect(), stdin } }+fn http(method: &'static str, path: impl Into<String>, body: Option<Value>) -> Req { Req::Http { method, path: path.into(), body } }++/// Run [req]; [then] gets its reply on the app loop, [line] each line the CLI prints as it prints it.+pub fn ask(app: &mut App, req: Req, line: Option<fn(&mut App, &str)>, then: impl FnOnce(&mut App, Reply) + Send + 'static) {+ if let Some(mut run) = app.devices.runner.take() {+ let reply = run(&req);+ app.devices.runner.get_or_insert(run);+ let Some(reply) = reply else { return };+ if let (Some(line), Reply::Cli { out, .. }) = (line, &reply) { for l in out.lines() { line(app, l) } }+ return then(app, reply);+ }+ match req {+ Req::Cli { args, stdin } => { let sink = app.sink.clone(); app.spawn(run_cli(args, stdin, line, sink), then) }+ Req::Http { method, path, body } => {+ let port = app.port;+ // (A phone's handshake holds `/api/pair` open while it runs; the app waits 60 s for it.)+ let wait = Duration::from_secs(if path == "/api/pair" { 65 } else { 20 });+ app.spawn(async move { Reply::Http(crate::daemon::http_json_for(port, method, &path, body.as_ref(), wait).await.map_err(|e| (e.code, e.detail))) }, then)+ }+ Req::Copy(text) => { crate::clipboard::store(&text); then(app, Reply::Done) }+ Req::Wait(d) => app.spawn(async move { tokio::time::sleep(d).await; Reply::Done }, then),+ }+}++/// The CLI that started us (node + its script), else `harness` on PATH — as M-l always ran it: its+/// stdin one line then closed, its stdout read line by line (each to [line] as it comes), its+/// stderr drained so a full pipe never stalls it.+async fn run_cli(args: Vec<String>, stdin: Option<String>, line: Option<fn(&mut App, &str)>, sink: tokio::sync::mpsc::UnboundedSender<crate::event::Event>) -> Reply {+ use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt};+ use std::process::Stdio;+ let exe = std::env::var("HARNESS_CLI").unwrap_or_else(|_| "harness".into());+ let script: Vec<String> = std::env::var("HARNESS_CLI_ARGS").ok().and_then(|a| serde_json::from_str(&a).ok()).unwrap_or_default();+ let spawned = tokio::process::Command::new(exe).args(script).args(&args).stdin(Stdio::piped()).stdout(Stdio::piped()).stderr(Stdio::piped()).kill_on_drop(true).spawn();+ let mut child = match spawned { Ok(c) => c, Err(e) => return Reply::Cli { ok: false, out: String::new(), err: format!("Could not run the Harness CLI: {e}") } };+ if let Some(mut input) = child.stdin.take() {+ if let Some(text) = stdin { let _ = input.write_all(format!("{text}\n").as_bytes()).await; }+ }+ let mut errors = child.stderr.take();+ let drain = tokio::spawn(async move { let mut s = String::new(); if let Some(e) = errors.as_mut() { let _ = e.read_to_string(&mut s).await; } s });+ let mut out = String::new();+ if let Some(pipe) = child.stdout.take() {+ let mut lines = tokio::io::BufReader::new(pipe).lines();+ let read = async {+ while let Ok(Some(l)) = lines.next_line().await {+ if let Some(f) = line { let each = l.clone(); let _ = sink.send(crate::event::Event::Apply(Box::new(move |app: &mut App| f(app, &each)))); }+ out.push_str(&l);+ out.push('\n');+ }+ };+ // (A link's handshake takes seconds; past two minutes it is stuck.)+ if tokio::time::timeout(Duration::from_secs(120), read).await.is_err() {+ let _ = child.kill().await;+ return Reply::Cli { ok: false, out, err: "The command timed out. Refresh before trying it again.".into() };+ }+ }+ let ok = child.wait().await.map(|s| s.success()).unwrap_or(false);+ Reply::Cli { ok, out, err: drain.await.unwrap_or_default() }+}++// ── reading what the CLI says ────────────────────────────────────────────────++/// The last JSON object a `--json` command printed — its result; progress lines (`stage`) aside.+pub fn last_json(out: &str) -> Option<Value> {+ out.lines().filter_map(|l| serde_json::from_str::<Value>(l.trim()).ok()).filter(|v| v.is_object() && v.get("stage").is_none()).last()+}++/// The stage a `link connect --json` line reports (`{"stage":"deriving_key"}`), if it is one.+pub fn stage_of(line: &str) -> Option<String> {+ serde_json::from_str::<Value>(line.trim()).ok()?.get("stage")?.as_str().map(str::to_string)+}++/// `harness link list`'s rows: ` 1. <machineId> <fingerprint> (linked 2026-09-30 12:00)`.+pub fn parse_links(out: &str) -> Vec<Linked> {+ let re = regex::Regex::new(r"(?m)^\s*\d+\.\s+(\S+)\s+(\S+)\s+\(linked\s+([\d-]+\s[\d:]+)\)").expect("link list pattern");+ re.captures_iter(out).map(|c| Linked { machine: c[1].to_string(), fingerprint: c[2].to_string(), at: c[3].to_string() }).collect()+}++/// What a CLI that failed said, on one line (its ✗ taken off), else [fallback].+fn cli_error(out: &str, err: &str, fallback: &str) -> String {+ let said = |s: &str| s.lines().map(|l| l.trim().trim_start_matches('✗').trim()).filter(|l| !l.is_empty() && !l.starts_with('{')).collect::<Vec<_>>().join(" ");+ let e = said(err);+ let o = said(out);+ if !e.is_empty() { e } else if !o.is_empty() { o } else { fallback.to_string() }+}++// ── the phone's link and its QR code ────────────────────────────────────────++/// A fresh one-time pairing code, from the OS's secure source (a v4 id's random bytes): the whole+/// secret the pairing rests on, so never a guessable one.+pub fn new_code() -> String {+ let mut out = String::new();+ while out.len() < CODE_LEN {+ let bytes = *uuid::Uuid::new_v4().as_bytes();+ // (Bytes 6 and 8 carry the id's version and variant; the other fourteen are random. 240 is+ // 8 × 30: a byte under it picks each symbol as often as any other.)+ for (i, b) in bytes.iter().enumerate() {+ if i == 6 || i == 8 || out.len() == CODE_LEN || *b >= 240 { continue }+ out.push(CODE_ALPHABET[(*b % 30) as usize] as char);+ }+ }+ out+}++/// Dart's `Uri.encodeQueryComponent`, which the app encodes the link's parts with: letters, digits+/// and `-._~` as they are, a space as `+`, every other byte of the UTF-8 as `%XX`.+fn query_component(s: &str) -> String {+ let mut out = String::new();+ for b in s.bytes() {+ match b {+ b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'.' | b'_' | b'~' => out.push(b as char),+ b' ' => out.push('+'),+ _ => out.push_str(&format!("%{b:02X}")),+ }+ }+ out+}++/// `https://harness.autonomous.ai/pair#e=<email>&m=<machineId>&c=<code>&h=<sign-in code>` — all of+/// it in the fragment, which a browser never sends to a server, so the code stays off every log.+pub fn pair_link(email: &str, machine: &str, code: &str, sign_in: Option<&str>) -> String {+ let h = sign_in.map(|s| format!("&h={}", query_component(s))).unwrap_or_default();+ format!("https://{PAIR_HOST}{PAIR_PATH}#e={}&m={}&c={code}{h}", query_component(email), query_component(machine))+}++/// [text] as a QR code that fits [cols] × [rows] cells (two modules a cell, one above the other):+/// its modules (true: dark) with the quiet zone around them — the app's error correction (M) and+/// four-module margin where they fit, less of either only where they do not. None: it cannot fit.+pub fn qr_modules(text: &str, cols: u16, rows: u16) -> Option<Vec<Vec<bool>>> {+ use qrcodegen::{QrCode, QrCodeEcc, QrSegment, Version};+ let segs = [QrSegment::make_bytes(text.as_bytes())];+ let mut codes: Vec<(QrCodeEcc, Option<QrCode>)> = [QrCodeEcc::Medium, QrCodeEcc::Low].into_iter().map(|e| (e, QrCode::encode_segments_advanced(&segs, e, Version::MIN, Version::MAX, None, false).ok())).collect();+ for quiet in [4, 3, 2] {+ for (_, code) in codes.iter_mut() {+ let Some(code) = code.as_ref() else { continue };+ let total = code.size() + 2 * quiet;+ if total > cols as i32 || total > rows as i32 * 2 { continue }+ return Some((0..total).map(|y| (0..total).map(|x| code.get_module(x - quiet, y - quiet)).collect()).collect());+ }+ }+ None+}++/// The least room [text]'s code takes (cells: columns, rows).+fn qr_least(text: &str) -> (u16, u16) {+ use qrcodegen::{QrCode, QrCodeEcc, QrSegment, Version};+ let size = QrCode::encode_segments_advanced(&[QrSegment::make_bytes(text.as_bytes())], QrCodeEcc::Low, Version::MIN, Version::MAX, None, false).map(|c| c.size()).unwrap_or(177);+ let total = (size + 4) as u16;+ (total, total.div_ceil(2))+}++/// Draw [modules] at (x, y), two to a cell (▀ ▄ █), dark on light whatever the theme — a light code+/// on a dark field is one many phone cameras will not read — dimmed once it is spent. Returns its+/// rectangle.+pub fn draw_qr(buf: &mut Buffer, x: u16, y: u16, modules: &[Vec<bool>], spent: bool) -> Rect {+ let dark = if spent { Color::Rgb(200, 200, 200) } else { Color::Rgb(0, 0, 0) };+ let style = Style::default().fg(theme::depth_fit(dark)).bg(theme::depth_fit(Color::Rgb(255, 255, 255)));+ let n = modules.len();+ let rows = n.div_ceil(2);+ for row in 0..rows {+ for col in 0..n {+ let top = modules[2 * row][col];+ let bottom = modules.get(2 * row + 1).is_some_and(|r| r[col]);+ let glyph = match (top, bottom) { (true, true) => "█", (true, false) => "▀", (false, true) => "▄", _ => " " };+ if let Some(cell) = buf.cell_mut((x + col as u16, y + row as u16)) { cell.reset(); cell.set_symbol(glyph); cell.set_style(style); }+ }+ }+ Rect::new(x, y, n as u16, rows as u16)+}++/// "Mac" where the app runs on one; "computer" anywhere else.+fn this_computer() -> &'static str { if cfg!(target_os = "macos") { "Mac" } else { "computer" } }++/// Who and what the QR is for: the account's email and this computer's machine id — none while+/// either is not known yet.+fn target(app: &App) -> Option<(String, String)> {+ let email = app.devices.phone.email.clone()?;+ let machine = app.fleet.local_id.clone();+ if app.daemon_down || machine.is_empty() || crate::local::is_local(&machine) { return None }+ Some((email, machine))+}++/// The link the QR shows now: once the sign-in code has been asked for (a QR that changed right+/// after it appeared would be one scanned without it).+pub fn phone_link(app: &App) -> Option<String> {+ let p = &app.devices.phone;+ if !p.sign_in_asked || p.code.is_empty() { return None }+ let (email, machine) = target(app)?;+ Some(pair_link(&email, &machine, &p.code, p.sign_in.as_deref()))+}++// ── opening, leaving ─────────────────────────────────────────────────────────++/// Open [view] as its own panel (a command, or `run`).+pub fn open(app: &mut App, view: View) {+ enter(app, view);+ crate::input::picker(app, PickerKind::Devices(view), view.title(), view.placeholder());+ if let Some(p) = picker_mut(app) { p.keep_order = true; p.vset(0, 1) }+ opened(app, view);+}++/// Chosen in the Commands panel: the view opens in the same panel, and Esc comes back to it.+pub fn from_commands(app: &mut App, mut picker: Picker, view: View) {+ enter(app, view);+ picker.from_commands = true;+ picker.placeholder = view.placeholder().into();+ picker.keep_order = true;+ picker.theme_in = None;+ picker.clear_query();+ picker.rows.clear();+ fill(app, view, &mut picker);+ picker.scroll = 0;+ picker.vset(0, 1);+ app.modal = Some(Modal::Picker { kind: PickerKind::Devices(view), picker });+ opened(app, view);+}++/// M-l on a machine (the machines list): Connect a machine, its password asked for at once.+pub fn connect_to(app: &mut App, machine: String) {+ open(app, View::Connect);+ if let Some(p) = picker_mut(app) { p.select(&format!("m:{machine}")) }+ let name = name_of(app, &machine);+ start_link(app, machine, name);+}++/// A view's fresh start: nothing asked, no level, nothing said.+fn enter(app: &mut App, view: View) {+ let d = &mut app.devices;+ d.ask = None;+ d.sub = None;+ d.footer = None;+ if view == View::Phone {+ let generation = d.phone.generation + 1;+ let email = d.phone.email.take();+ d.phone = Phone { open: true, generation, code: new_code(), email, ..Phone::default() };+ } else {+ d.phone.open = false;+ }+}++/// What a view needs read when it opens.+fn opened(app: &mut App, view: View) {+ match view {+ View::Connect => load_account(app),+ View::Machines => { load_password(app); load_links(app); load_account(app); load_me(app) }+ View::Phone => {+ load_me(app);+ let generation = app.devices.phone.generation;+ sign_in(app, generation);+ load_pairs(app);+ // (The QR shows at once; handing the daemon its code is a write, so it waits for a yes —+ // asked at once, unless there is no Harness here to hand it to.)+ if !app.daemon_down { confirm(app, format!("Let the phone that scans this code pair with this {}?", this_computer()), Act::ArmPhone) }+ }+ }+}++fn picker_mut(app: &mut App) -> Option<&mut Picker> {+ match &mut app.modal { Some(Modal::Picker { kind: PickerKind::Devices(_), picker }) => Some(picker), _ => None }+}++fn view_of(app: &App) -> Option<View> {+ match &app.modal { Some(Modal::Picker { kind: PickerKind::Devices(v), .. }) => Some(*v), _ => None }+}++/// The open view's rows again, from what is known now.+fn again(app: &mut App) { crate::input::refill(app) }++fn note(app: &mut App, text: impl Into<String>) { app.devices.footer = Some((text.into(), false, Instant::now())) }+fn fail(app: &mut App, text: impl Into<String>) { app.devices.footer = Some((text.into(), true, Instant::now())) }+fn loading(app: &mut App, what: &'static str, on: bool) {+ let l = &mut app.devices.loading;+ if on { if !l.contains(&what) { l.push(what) } } else { l.retain(|w| *w != what) }+}+fn is_loading(app: &App, what: &str) -> bool { app.devices.loading.contains(&what) }++fn name_of(app: &App, machine: &str) -> String {+ let name = app.fleet.machine_name(machine);+ if name.is_empty() { machine.to_string() } else { name }+}++// ── reads ────────────────────────────────────────────────────────────────────++fn load_password(app: &mut App) {+ loading(app, "password", true);+ ask(app, cli(&["remote-password", "status", "--json"], None), None, |app, reply| {+ loading(app, "password", false);+ app.devices.password = Some(match &reply {+ Reply::Cli { out, err, .. } => last_json(out).filter(|v| v.get("hasPassword").is_some()).ok_or_else(|| cli_error(out, err, "Password status is unavailable.")),+ _ => Err("Password status is unavailable.".into()),+ });+ again(app);+ });+}++fn load_links(app: &mut App) {+ loading(app, "links", true);+ ask(app, cli(&["link", "list"], None), None, |app, reply| {+ loading(app, "links", false);+ app.devices.links = Some(match &reply {+ Reply::Cli { ok: true, out, .. } => Ok(parse_links(out)),+ Reply::Cli { out, err, .. } => Err(cli_error(out, err, "Could not load linked machines. Try again.")),+ _ => Err("Could not load linked machines. Try again.".into()),+ });+ again(app);+ });+}++fn load_account(app: &mut App) {+ // (The fleet's own read keeps names and online states; this one keeps the rest of each row.)+ if app.devices.runner.is_none() { app.refresh_machines() }+ ask(app, http("GET", "/api/machines", None), None, |app, reply| {+ if let Reply::Http(Ok(v)) = reply {+ for row in v.get("machines").and_then(Value::as_array).into_iter().flatten() {+ if let Some(id) = row.get("machineId").and_then(Value::as_str) { app.devices.account.insert(id.to_string(), row.clone()); }+ }+ again(app);+ }+ });+}++fn load_me(app: &mut App) {+ ask(app, http("GET", "/api/auth/me", None), None, |app, reply| {+ match reply {+ Reply::Http(Ok(v)) => {+ app.devices.phone.email = v.pointer("/user/email").and_then(Value::as_str).map(str::trim).filter(|e| e.contains('@')).map(str::to_string);+ app.devices.phone.signed_out = false;+ }+ Reply::Http(Err((code, _))) if code == "HTTP_401" => app.devices.phone.signed_out = true,+ _ => {}+ }+ again(app);+ });+}++fn load_pairs(app: &mut App) {+ ask(app, http("GET", "/api/pairs", None), None, |app, reply| {+ let Reply::Http(Ok(v)) = reply else { return };+ // (A `web` pairing: a phone or another computer — not a device on a cable.)+ let mut pairs: Vec<Value> = v.get("pairs").and_then(Value::as_array).into_iter().flatten()+ .filter(|p| p.get("fingerprint").and_then(Value::as_str).is_some_and(|f| !f.is_empty()) && p.get("role").and_then(Value::as_str).is_none_or(|r| r == "web"))+ .cloned().collect();+ pairs.sort_by_key(|p| std::cmp::Reverse(p.get("pairedAt").and_then(Value::as_u64).unwrap_or(0)));+ app.devices.phone.paired = pairs;+ again(app);+ });+}++/// The sign-in code for the QR, asked for again before it runs out — while the QR is on screen. A+/// failure is not retried sooner: the QR works without one.+fn sign_in(app: &mut App, generation: u64) {+ ask(app, http("POST", "/api/auth/handoff", Some(json!({}))), None, move |app, reply| {+ if !phone_live(app, generation) { return }+ let got = match reply {+ Reply::Http(Ok(v)) => v.get("code").and_then(Value::as_str).filter(|c| !c.is_empty()).map(|c| (c.to_string(), v.get("expiresIn").and_then(Value::as_u64).filter(|t| *t > 0).unwrap_or(60))),+ _ => None,+ };+ let ttl = got.as_ref().map(|g| g.1).unwrap_or(60);+ app.devices.phone.sign_in = got.map(|g| g.0);+ app.devices.phone.sign_in_asked = true;+ again(app);+ if app.devices.phone.connected.is_some() || app.devices.phone.stopped { return }+ // (Renewed with at least half a minute left in the one on screen.)+ let wait = if ttl > 30 && ttl - 30 < 60 { ttl - 30 } else { 60 };+ ask(app, Req::Wait(Duration::from_secs(wait)), None, move |app, _| if phone_live(app, generation) { sign_in(app, generation) });+ });+}++fn phone_live(app: &App, generation: u64) -> bool {+ let p = &app.devices.phone;+ p.open && p.generation == generation && view_of(app) == Some(View::Phone)+}++/// One round of handing the daemon the code (`POST /api/pair`, what `harness pair <code>` sends): it+/// answers at once with no phone waiting, and holds on while a phone's handshake runs — then again,+/// for as long as the QR is on screen and armed.+fn phone_round(app: &mut App, generation: u64) {+ if !phone_live(app, generation) { return }+ let p = &app.devices.phone;+ if !p.armed || p.connected.is_some() || p.stopped { return }+ if target(app).is_none() { return ask(app, Req::Wait(Duration::from_millis(1500)), None, move |app, _| phone_round(app, generation)) }+ let code = p.code.clone();+ ask(app, http("POST", "/api/pair", Some(json!({ "code": code }))), None, move |app, reply| {+ if !phone_live(app, generation) { return }+ let error = match reply {+ Reply::Http(Ok(v)) => {+ let label = v.get("label").and_then(Value::as_str).map(str::trim).filter(|l| !l.is_empty()).unwrap_or("phone").to_string();+ app.devices.phone.connected = Some(label.clone());+ app.devices.phone.message = None;+ app.devices.ask = None;+ note(app, format!("✓ Connected {label}"));+ load_pairs(app);+ again(app);+ return;+ }+ Reply::Http(Err((code, message))) => pair_error(&code, &message),+ _ => "UNREACHABLE".to_string(),+ };+ let computer = this_computer();+ let p = &mut app.devices.phone;+ let mut say = |text: String, sticky: bool| { p.message = Some(text); p.sticky = sticky };+ let wait = match error.as_str() {+ // No phone yet, one whose minute ran out, one mid-handshake with somebody else.+ "NO_INTENT" | "EXPIRED" | "BUSY" => { if !p.sticky { p.message = None } 1500 }+ // The phone holds the old code and the daemon has spent it: a new one, a new QR.+ "CODE_MISMATCH" => { say("That didn't match. Scan the new code.".into(), true); p.code = new_code(); 1500 }+ "RATE_LIMITED" => { say("Too many tries. Wait a minute.".into(), false); 60_000 }+ "BACKEND_DOWN" => { say(format!("This {computer} can't reach Harness right now."), false); 1500 }+ "TIMEOUT" => { say("Your phone stopped answering. Scan again.".into(), true); 1500 }+ "CANCELLED" => { say("Cancelled on your phone. Scan again.".into(), true); 1500 }+ UNAVAILABLE => { say(format!("Update Harness on this {computer} to add a phone."), false); p.stopped = true; again(app); return }+ other => { say(format!("Could not pair ({other}). Trying again."), false); 5000 }+ };+ again(app);+ ask(app, Req::Wait(Duration::from_millis(wait)), None, move |app, _| phone_round(app, generation));+ });+}++/// `/api/pair`'s answer as the app reads it: the daemon's own code (`{error: NO_INTENT}` on a 409),+/// no pairing to be had (a daemon from before it answers 404; nobody on the port), or a timeout.+fn pair_error(code: &str, message: &str) -> String {+ match code {+ "HTTP_404" | "DAEMON_UNREACHABLE" => UNAVAILABLE.into(),+ "TIMEOUT" => "TIMEOUT".into(),+ c if c.starts_with("HTTP_") && !message.is_empty() && message != "request failed" => message.to_string(),+ _ => "UNREACHABLE".into(),+ }+}++// ── writes (each after its yes) ──────────────────────────────────────────────++fn run_act(app: &mut App, act: Act) {+ match act {+ Act::Link { machine, name, password } => link_connect(app, machine, name, password),+ Act::SetPassword(password) => {+ note(app, "Setting password…");+ ask(app, cli(&["remote-password", "set", "--stdin", "--json"], Some(password)), None, |app, reply| {+ let Reply::Cli { out, err, .. } = &reply else { return fail(app, "harness remote-password set failed") };+ match last_json(out) {+ Some(v) if v.get("ok").and_then(Value::as_bool) == Some(true) => {+ app.devices.password = Some(Ok(json!({ "hasPassword": true, "fingerprint": v.get("fingerprint").cloned().unwrap_or(Value::Null), "setAt": crate::fleet::now_ms() })));+ note(app, "Password set.");+ }+ Some(v) => { let code = v.get("error").and_then(Value::as_str).unwrap_or("harness remote-password set failed").to_string(); fail(app, password_error(&code)) }+ None => fail(app, cli_error(out, err, "harness remote-password set failed")),+ }+ again(app);+ });+ }+ Act::ClearPassword => {+ note(app, "Clearing password…");+ ask(app, cli(&["remote-password", "clear", "--json"], None), None, |app, reply| {+ let Reply::Cli { out, err, .. } = &reply else { return fail(app, "harness remote-password clear failed") };+ match last_json(out) {+ Some(v) if v.get("ok").and_then(Value::as_bool) == Some(true) => { app.devices.password = Some(Ok(json!({ "hasPassword": false }))); note(app, "Password cleared.") }+ Some(v) => fail(app, v.get("error").and_then(Value::as_str).unwrap_or("harness remote-password clear failed").to_string()),+ None => fail(app, cli_error(out, err, "harness remote-password clear failed")),+ }+ again(app);+ });+ }+ Act::Unlink { machine, name } => {+ note(app, "Unlinking machine…");+ ask(app, cli(&["link", "unlink", &machine], None), None, move |app, reply| {+ match &reply {+ Reply::Cli { ok: true, .. } => { note(app, format!("Unlinked {name}")); load_links(app) }+ Reply::Cli { out, err, .. } => fail(app, cli_error(out, err, "harness link unlink failed")),+ _ => fail(app, "harness link unlink failed"),+ }+ again(app);+ });+ }+ Act::Rename { machine, name } => {+ note(app, "Saving…");+ let path = format!("/api/machines/{machine}");+ ask(app, http("PATCH", path, Some(json!({ "name": name }))), None, move |app, reply| {+ match reply {+ Reply::Http(Ok(v)) => {+ let saved = v.get("name").and_then(Value::as_str).map(str::trim).filter(|n| !n.is_empty()).unwrap_or(&name).to_string();+ if let Some(m) = app.fleet.machine_mut(&machine) { m.name = saved.clone() }+ if let Some(row) = app.devices.account.get_mut(&machine) { row["name"] = json!(saved) }+ note(app, format!("Renamed to {saved}"));+ }+ Reply::Http(Err((_, message))) => fail(app, message),+ _ => fail(app, "Could not rename it"),+ }+ again(app);+ });+ }+ Act::Remove { machine, name } => {+ note(app, "Deleting machine…");+ let path = format!("/api/machines/{machine}");+ ask(app, http("DELETE", path, None), None, move |app, reply| {+ match reply {+ Reply::Http(Ok(_)) => {+ app.fleet.machines.retain(|m| m.id != machine);+ app.devices.account.remove(&machine);+ if app.devices.sub.as_deref() == Some(&format!("m:{machine}")) { app.devices.sub = None }+ note(app, format!("Deleted {name} from your account"));+ }+ Reply::Http(Err((_, message))) => fail(app, message),+ _ => fail(app, "Could not delete it"),+ }+ again(app);+ });+ }+ Act::Unpair { fingerprint, name } => {+ ask(app, http("POST", "/api/revoke", Some(json!({ "id": fingerprint }))), None, move |app, reply| {+ match reply {+ Reply::Http(Ok(v)) if v.get("error").is_none() => { app.devices.phone.paired.retain(|p| p.get("fingerprint").and_then(Value::as_str) != Some(&fingerprint)); note(app, format!("Removed {name}")) }+ _ => fail(app, format!("Couldn't remove {name}. Try again.")),+ }+ again(app);+ });+ }+ Act::ArmPhone => {+ app.devices.phone.armed = true;+ again(app);+ let generation = app.devices.phone.generation;+ phone_round(app, generation);+ }+ }+}++fn password_error(code: &str) -> String {+ match code {+ "NOT_SIGNED_IN" => "This computer is not signed in. Run: harness login".into(),+ "EMPTY_PASSWORD" => "Enter a password".into(),+ "MISMATCH" => "Passwords do not match".into(),+ c => c.to_string(),+ }+}++/// `harness link connect <id> --stdin --json [--name=…]`, the password on its stdin: each stage it+/// prints shown as it comes; its last line says how it went.+pub fn link_connect(app: &mut App, machine: String, name: String, password: String) {+ app.devices.link = Some(Linking { machine: machine.clone(), name: name.clone(), stage: "connecting".into(), result: None });+ let mut args: Vec<String> = ["link", "connect", &machine, "--stdin", "--json"].iter().map(|s| s.to_string()).collect();+ if !name.is_empty() && name != machine { args.push(format!("--name={name}")) }+ note(app, format!("Linking {name}… it continues if you close this"));+ again(app);+ ask(app, Req::Cli { args, stdin: Some(password) }, Some(link_line), move |app, reply| {+ let result = match &reply {+ Reply::Cli { out, err, .. } => match last_json(out) {+ Some(v) if v.get("ok").and_then(Value::as_bool) == Some(true) => Ok(v.get("fingerprint").and_then(Value::as_str).unwrap_or("").to_string()),+ // (`message` is the CLI's sentence for the code; `error` the bare code, from a CLI too old to send one.)+ Some(v) => Err(v.get("message").or_else(|| v.get("error")).and_then(Value::as_str).unwrap_or("harness link connect failed").to_string()),+ None => Err(cli_error(out, err, "harness link connect produced no result")),+ },+ _ => Err("harness link connect failed".into()),+ };+ match &result {+ Ok(_) => {+ note(app, format!("Linked {name}"));+ app.say(format!("Linked {name}"), theme::ONLINE);+ if let Some(m) = app.fleet.machine_mut(&machine) { m.reach = Reach::Unknown }+ if app.devices.runner.is_none() { app.connect(&machine) }+ }+ Err(e) => { fail(app, format!("Could not link: {e}")); app.say(format!("Could not link {name}: {e}"), theme::DANGER) }+ }+ if let Some(l) = app.devices.link.as_mut().filter(|l| l.machine == machine) { l.result = Some(result) }+ again(app);+ });+}++fn link_line(app: &mut App, line: &str) {+ let Some(stage) = stage_of(line) else { return };+ if let Some(l) = app.devices.link.as_mut().filter(|l| l.result.is_none()) { l.stage = stage }+ again(app);+}++// ── asking ───────────────────────────────────────────────────────────────────++fn entry(app: &mut App, what: Entry, label: impl Into<String>, value: &str, secret: bool) {+ app.devices.ask = Some(Ask::Entry { what, label: label.into(), value: value.to_string(), secret });+}++fn confirm(app: &mut App, question: impl Into<String>, act: Act) { app.devices.ask = Some(Ask::Confirm { question: question.into(), act }) }++fn start_link(app: &mut App, machine: String, name: String) {+ let label = format!("Remote password for {name}");+ entry(app, Entry::Link { machine, name }, label, "", true);+ note(app, "Enter the remote password set on this machine.");+}++/// Enter on a typed line: the next line, or the y/n before the write.+fn submit(app: &mut App, what: Entry, value: String) {+ match what {+ Entry::Link { machine, name } => {+ if value.is_empty() { start_link(app, machine, name); return fail(app, "Enter the remote password first") }+ confirm(app, format!("Link {name} with this password?"), Act::Link { machine, name, password: value });+ }+ Entry::NewPassword => {+ if value.is_empty() { entry(app, Entry::NewPassword, "New remote password", "", true); return fail(app, "Enter a password") }+ entry(app, Entry::RepeatPassword { first: value }, "Repeat password", "", true);+ }+ Entry::RepeatPassword { first } => {+ if value != first { entry(app, Entry::NewPassword, "New remote password", "", true); return fail(app, "Passwords do not match") }+ confirm(app, "Set this computer's remote password? Anyone with it can link a machine here.", Act::SetPassword(value));+ }+ Entry::Rename { machine, name } => {+ let new = value.trim().to_string();+ if new.is_empty() { entry(app, Entry::Rename { machine, name: name.clone() }, "Machine name", &name, false); return fail(app, "Name cannot be empty") }+ if new == name { return note(app, "Nothing changed") }+ confirm(app, format!("Rename {name} to {new}?"), Act::Rename { machine, name: new });+ }+ }+}++/// A key while the panel asks: a y/n answered, or a line typed (Enter goes on, Esc lets it go).+fn answer_key(app: &mut App, key: KeyEvent) {+ let ctrl = key.modifiers.contains(KeyModifiers::CONTROL);+ match app.devices.ask.take() {+ Some(Ask::Confirm { question, act }) => match key.code {+ KeyCode::Char('y' | 'Y') if !ctrl => run_act(app, act),+ KeyCode::Char('n' | 'N') | KeyCode::Esc => note(app, "Nothing changed"),+ KeyCode::Char('c' | 'g') if ctrl => note(app, "Nothing changed"),+ _ => app.devices.ask = Some(Ask::Confirm { question, act }),+ },+ Some(Ask::Entry { what, label, mut value, secret }) => {+ match key.code {+ KeyCode::Enter => { app.devices.footer = None; return submit(app, what, value) }+ KeyCode::Esc => return note(app, "Nothing changed"),+ KeyCode::Char('c' | 'g') if ctrl => return note(app, "Nothing changed"),+ KeyCode::Char('u') if ctrl => value.clear(),+ KeyCode::Char('h') if ctrl => { value.pop(); }+ KeyCode::Backspace => { value.pop(); }+ KeyCode::Char(c) if !ctrl && !key.modifiers.contains(KeyModifiers::ALT) => value.push(c),+ _ => {}+ }+ app.devices.ask = Some(Ask::Entry { what, label, value, secret });+ }+ None => {}+ }+}++/// A key in one of the views, before the list's own keys: an answer while the panel asks, Esc (or ←+/// on an empty query) one level back. Anything else goes back to the list.+pub fn key(app: &mut App, kind: PickerKind, picker: Picker, key: KeyEvent) -> Result<(), (PickerKind, Picker)> {+ let PickerKind::Devices(view) = kind else { return Err((kind, picker)) };+ if app.devices.ask.is_some() {+ app.modal = Some(Modal::Picker { kind, picker });+ answer_key(app, key);+ again(app);+ return Ok(());+ }+ let plain = key.modifiers.is_empty();+ let back = key.code == KeyCode::Esc || (key.code == KeyCode::Left && plain && picker.query.is_empty());+ if !back { return Err((kind, picker)) }+ app.modal = Some(Modal::Picker { kind, picker });+ step_back(app, view);+ Ok(())+}++/// Out of a machine's actions; out of the view to the command list it+/// was chosen from; else the panel closes.+fn step_back(app: &mut App, view: View) {+ app.devices.footer = None;+ if let Some(sub) = app.devices.sub.take() {+ again(app);+ if let Some(p) = picker_mut(app) { p.clear_query(); p.select(&sub) }+ return;+ }+ app.devices.phone.open = false;+ let Some(Modal::Picker { mut picker, .. }) = app.modal.take() else { return };+ if !picker.from_commands { return }+ settings::back_to_commands(app, &mut picker);+ settings::cursor_to(&mut picker, &format!("cmd:{}", view.id()));+ app.modal = Some(Modal::Picker { kind: PickerKind::Commands, picker });+}++/// Enter on a row.+pub fn choose(app: &mut App, view: View, picker: Picker, enter: bool) {+ let id = picker.current_id();+ app.modal = Some(Modal::Picker { kind: PickerKind::Devices(view), picker });+ if !enter { return }+ let Some(id) = id else { return };+ app.devices.footer = None;+ let (what, rest) = id.split_once(':').unwrap_or((id.as_str(), ""));+ let rest = rest.to_string();+ match (view, what) {+ (View::Connect, "m") => { let name = name_of(app, &rest); start_link(app, rest, name) }+ (_, "m") => sub(app, format!("m:{rest}")),+ (_, "act") => machine_action(app, &rest),+ (_, "pw") => match rest.as_str() {+ "set" => entry(app, Entry::NewPassword, "New remote password", "", true),+ "clear" => confirm(app, "Prevent new links using this password? Existing links and sessions stay connected.", Act::ClearPassword),+ _ => load_password(app),+ },+ (_, "ln") if rest.is_empty() => { note(app, "Loading linked machines…"); load_links(app) }+ (_, "ln") => { let name = name_of(app, &rest); confirm(app, format!("Remove this computer’s saved link to {name}? A new connection will need that machine’s password."), Act::Unlink { machine: rest, name }) }+ (_, "add") => match rest.as_str() {+ "download" => copy(app, DOWNLOAD_URL),+ "connect" => switch(app, View::Connect),+ "install" => copy(app, INSTALL),+ "login" => copy(app, LOGIN),+ "start" => copy(app, START),+ _ => copy(app, &format!("{INSTALL}\n{LOGIN}\n{START}")),+ },+ (_, "ph") => match rest.as_str() {+ "arm" => confirm(app, format!("Let the phone that scans this code pair with this {}?", this_computer()), Act::ArmPhone),+ "new" => { app.devices.phone.code = new_code(); app.devices.phone.message = None; note(app, "A new code — the old one no longer pairs") }+ fp => {+ let name = app.devices.phone.paired.iter().find(|p| p.get("fingerprint").and_then(Value::as_str) == Some(fp)).map(device_name).unwrap_or_else(|| "this device".into());+ confirm(app, format!("Remove {name}'s access to this {}? Scanning the code again adds it back.", this_computer()), Act::Unpair { fingerprint: fp.to_string(), name })+ }+ },+ _ => {}+ }+ again(app);+}++/// Into a level of the view (a machine's actions), the cursor on its first row.+fn sub(app: &mut App, level: String) {+ app.devices.sub = Some(level);+ again(app);+ if let Some(p) = picker_mut(app) { p.clear_query(); p.scroll = 0; p.vset(0, 1) }+}++/// Over to another view in the same panel (Esc still goes back where the first one came from).+fn switch(app: &mut App, view: View) {+ enter(app, view);+ if let Some(Modal::Picker { kind, picker }) = &mut app.modal {+ *kind = PickerKind::Devices(view);+ picker.placeholder = view.placeholder().into();+ picker.clear_query();+ picker.rows.clear();+ }+ again(app);+ if let Some(p) = picker_mut(app) { p.scroll = 0; p.vset(0, 1) }+ opened(app, view);+}++fn copy(app: &mut App, text: &str) {+ let shown = text.lines().next().unwrap_or("").to_string();+ ask(app, Req::Copy(text.to_string()), None, move |app, _| note(app, format!("Copied: {shown}")));+}++fn machine_action(app: &mut App, rest: &str) {+ let Some((verb, machine)) = rest.split_once(':') else { return };+ let (machine, name) = (machine.to_string(), name_of(app, machine));+ match verb {+ "rename" => entry(app, Entry::Rename { machine, name: name.clone() }, "Machine name", &name, false),+ "remove" => confirm(app, format!("Delete {name} from your account?"), Act::Remove { machine, name }),+ "connect" => { switch(app, View::Connect); if let Some(p) = picker_mut(app) { p.select(&format!("m:{machine}")) } start_link(app, machine, name) }+ "open" => {+ app.devices.sub = None;+ let kind = PickerKind::Open { filter: crate::modal::Filter::All, machine: Some(machine), project: None };+ let (title, placeholder) = crate::modal::launcher_title(app, &kind);+ let mut next = Picker::new(title, placeholder);+ next.prefixed = true;+ crate::input::fill(app, &kind, &mut next);+ app.modal = Some(Modal::Picker { kind, picker: next });+ }+ _ => {}+ }+}++// ── rows ─────────────────────────────────────────────────────────────────────++fn span(text: impl Into<String>, style: Style) -> Span<'static> { Span::styled(text.into(), style) }+fn dot(glyph: &str, color: Color) -> Vec<Span<'static>> { vec![span(format!("{glyph} "), fg(color))] }+fn info(id: &str, text: impl Into<String>, group: &str) -> Row { let mut r = Row::new(id, text).group(group).lead(dot(" ", theme::MUTED)); r.disabled = true; r }++/// A machine's dot, colour and word, as the machines list says them.+fn reach(app: &App, m: &crate::fleet::Machine) -> (&'static str, Color, String) {+ let linking = app.devices.link.as_ref().is_some_and(|l| l.machine == m.id && l.result.is_none());+ // (The harnesses' marks, no round ones: `✓`, a spinner connecting, `?` to link, `✗`, `·`.)+ let spin = theme::spinner(app.tick);+ match &m.reach {+ _ if linking => (spin, theme::WARN, "connecting…".into()),+ _ if m.local => ("✓", theme::ONLINE, "this computer".into()),+ _ if !m.online() => ("·", theme::MUTED, "offline".into()),+ Reach::Ready => ("✓", theme::ONLINE, "connected".into()),+ Reach::Connecting => (spin, theme::WARN, "connecting…".into()),+ Reach::NeedsLink => ("?", theme::ATTENTION, "online · not linked".into()),+ Reach::Error(e) => ("✗", theme::DANGER, e.chars().take(40).collect()),+ _ => ("·", theme::SOFT, "online".into()),+ }+}++/// Its harnesses in counts (`2 waiting · 1 working`).+fn counts(app: &App, machine: &str) -> String {+ let here: Vec<State> = app.fleet.agents.values().filter(|a| a.machine_id == machine && a.engine != "terminal").map(|a| app.fleet.state_of(a)).collect();+ let n = |s: State| here.iter().filter(|x| **x == s).count();+ let said = [(State::NeedsInput, "waiting"), (State::Failed, "failed"), (State::Done, "done"), (State::Working, "working"), (State::Ready, "idle")]+ .iter().filter(|(s, _)| n(*s) > 0).map(|(s, w)| format!("{} {w}", n(*s))).collect::<Vec<_>>().join(" · ");+ if said.is_empty() { "no harnesses".into() } else { said }+}++/// (Re)build the open view's rows.+pub fn fill(app: &App, view: View, picker: &mut Picker) {+ picker.keep_order = true;+ let rows = match view {+ View::Connect => connect_rows(app),+ View::Machines => match app.devices.sub.as_deref().and_then(|s| s.strip_prefix("m:")) { Some(id) => action_rows(app, id), None => machines_rows(app) },+ View::Phone => phone_rows(app),+ };+ // (Rebuilt in their own order, not the last one's: a row that arrives lands in its group.)+ picker.rows.clear();+ picker.set_rows(rows);+ picker.hints = vec![("enter", "choose"), ("esc", "back")];+}++fn connect_rows(app: &App) -> Vec<Row> {+ let (mut ready, mut done, mut away) = (Vec::new(), Vec::new(), Vec::new());+ for m in app.fleet.machines.iter().filter(|m| !m.local) {+ let (glyph, color, word) = reach(app, m);+ let linking = app.devices.link.as_ref().is_some_and(|l| l.machine == m.id && l.result.is_none());+ // (One just linked stays in view, how it went beside it.)+ if app.devices.link.as_ref().is_some_and(|l| l.machine == m.id && matches!(l.result, Some(Ok(_)))) {+ done.push(Row::new(format!("m:{}", m.id), m.name.clone()).group("Linked just now").extra(m.id.clone()).lead(dot("✓", theme::ONLINE)).detail(vec![span("linked", fg(theme::ONLINE))]).right("linked"));+ } else if linking || (m.reach == Reach::NeedsLink && m.online()) {+ ready.push(Row::new(format!("m:{}", m.id), m.name.clone()).group("Not linked yet").extra(m.id.clone()).lead(dot(glyph, color)).detail(vec![span(word, fg(color))]).right("enter links it"));+ } else if !m.online() {+ let mut r = Row::new(format!("m:{}", m.id), m.name.clone()).group("Offline").extra(m.id.clone()).lead(dot(glyph, color)).detail(vec![span(format!("Open Harness on {} to bring it online.", m.name), fg(theme::MUTED))]).right("offline");+ r.disabled = true;+ away.push(r);+ }+ }+ if ready.is_empty() { ready.push(info("none", if app.daemon_down { "Harness is not running on this computer" } else { "Every machine on your account that is online is linked" }, "Not linked yet")) }+ ready.extend(done);+ ready.extend(away);+ ready+}++fn machines_rows(app: &App) -> Vec<Row> {+ let mut rows = Vec::new();+ let here = "This computer";+ let password = app.devices.password.as_ref();+ let set = password.and_then(|p| p.as_ref().ok()).and_then(|v| v.get("hasPassword")).and_then(Value::as_bool);+ let state = match password {+ _ if is_loading(app, "password") && password.is_none() => "reading…".to_string(),+ None => "…".into(),+ Some(Err(_)) => "unavailable".into(),+ Some(Ok(v)) => if set == Some(true) { v.get("setAt").and_then(Value::as_u64).map(|t| format!("set {}", crate::fleet::ago(t))).map(|s| if s == "set " { "set".into() } else { s }).unwrap_or_else(|| "set".into()) } else { "not set".into() },+ };+ let color = match set { Some(true) => theme::ONLINE, Some(false) => theme::MUTED, None => theme::WARN };+ rows.push(Row::new("pw:set", if set == Some(true) { "Change password…" } else { "Set password…" }).group(here).extra("remote password")+ .lead(dot(if set == Some(true) { "✓" } else { "·" }, color)).detail(vec![span("the remote password another machine links here with", fg(theme::MUTED))]).right(state));+ if set == Some(true) { rows.push(Row::new("pw:clear", "Clear password…").group(here).extra("remote password").lead(dot(" ", theme::MUTED)).detail(vec![span("no new links by password", fg(theme::MUTED))])) }+ if matches!(password, Some(Err(_))) { rows.push(Row::new("pw:status", "Retry").group(here).extra("password status").lead(dot("↻", theme::MUTED)).detail(vec![span("Password status is unavailable.", fg(theme::WARN))])) }++ let yours = "Your machines";+ for m in &app.fleet.machines {+ if crate::local::is_local(&m.id) { continue }+ let (glyph, color, word) = reach(app, m);+ let rtt = app.rtt.get(&m.id).filter(|_| m.usable()).map(|d| format!("{}ms ", d.as_millis())).unwrap_or_default();+ rows.push(Row::new(format!("m:{}", m.id), m.name.clone()).group(yours).extra(format!("{} {word}", m.id)).lead(dot(glyph, color)).detail(vec![span(word, fg(color))]).right(format!("{rtt}{}", counts(app, &m.id))));+ }+ if app.fleet.machines.iter().all(|m| crate::local::is_local(&m.id)) { rows.push(info("m-none", if app.daemon_down { "Harness is not running on this computer" } else { "Loading machines…" }, yours)) }++ let linked = "Linked from here";+ match &app.devices.links {+ None => rows.push(info("ln-loading", "Loading linked machines…", linked)),+ Some(Err(e)) => rows.push(info("ln-error", e.clone(), linked)),+ Some(Ok(list)) if list.is_empty() => rows.push(info("ln-none", "No machines linked yet.", linked)),+ Some(Ok(list)) => for l in list {+ let name = name_of(app, &l.machine);+ rows.push(Row::new(format!("ln:{}", l.machine), name).group(linked).extra(format!("{} {}", l.machine, l.fingerprint)).lead(dot("⇄", theme::TEAL)).detail(vec![span(l.fingerprint.clone(), fg(theme::MUTED))]).right(format!("linked {}", l.at)));+ },+ }+ rows.push(Row::new("ln:", "Refresh links").group(linked).lead(dot("↻", theme::MUTED)).detail(vec![span("Machines this computer can connect to.", fg(theme::MUTED))]));++ // The app's two steps, then a server's three — each Enter copies what it names.+ let add = "Add a machine";+ let email = app.devices.phone.email.clone();+ let sign = email.as_ref().map(|e| format!("Sign in as {e}.")).unwrap_or_else(|| "Sign in with the same account.".into());+ rows.push(Row::new("add:download", "1. Open Harness on your other computer.").group(add).extra("download").lead(dot("⧉", theme::TEAL)).detail(vec![span(sign, fg(theme::MUTED))]).right("copy"));+ rows.push(Row::new("add:connect", "2. Open Machines and choose Set password.").group(add).extra("password connect").lead(dot("→", theme::TEAL)).detail(vec![span("Back here, click Connect and enter that password.", fg(theme::MUTED))]));+ let server = "Set up a server";+ rows.push(Row::new("add:install", "1. Install the CLI (skip if installed)").group(server).extra(INSTALL).lead(dot("⧉", theme::TEAL)).detail(vec![span(INSTALL, fg(theme::MUTED))]).right("copy"));+ rows.push(Row::new("add:login", format!("2. Sign in as {}", email.as_deref().unwrap_or("your account"))).group(server).extra(LOGIN).lead(dot("⧉", theme::TEAL)).detail(vec![span(LOGIN, fg(theme::MUTED))]).right("copy"));+ rows.push(Row::new("add:start", "3. Start Harness and set a remote password").group(server).extra(START).lead(dot("⧉", theme::TEAL)).detail(vec![span(START, fg(theme::MUTED))]).right("copy"));+ rows.push(Row::new("add:all", "Copy commands").group(server).extra("all three").lead(dot("⧉", theme::TEAL)).detail(vec![span("Run these on your server over SSH:", fg(theme::MUTED))]).right("copy all"));+ rows+}++fn action_rows(app: &App, id: &str) -> Vec<Row> {+ let Some(m) = app.fleet.machine(id) else { return vec![info("gone", "That machine is gone", "")] };+ let group = m.name.clone();+ let mut rows = Vec::new();+ let act = |verb: &str, label: &str, hint: &str, glyph: &str| Row::new(format!("act:{verb}:{id}"), label).group(group.clone()).lead(dot(glyph, theme::TEAL)).detail(vec![span(hint.to_string(), fg(theme::MUTED))]);+ if m.usable() { rows.push(act("open", "Open its harnesses", "the harnesses list, on this machine", "→")) }+ if m.reach == Reach::NeedsLink && m.online() { rows.push(act("connect", "Connect…", "its remote password, then link", "⇄")) }+ rows.push(act("rename", "Rename…", "the name every device on the account shows", "✎"));+ if !m.local { rows.push(act("remove", "Remove from account…", "delete it from your account", "✗")) }+ rows+}++fn device_name(p: &Value) -> String {+ let label = p.get("label").and_then(Value::as_str).unwrap_or("").trim();+ if label.is_empty() || label == "harness link" || label == "browser" { "Linked device".into() } else { label.to_string() }+}++/// How long ago, in one short word: now, 5m, 3h, 2d, 6w.+fn short_ago(ms: u64) -> String {+ let mins = crate::fleet::now_ms().saturating_sub(ms) / 60_000;+ match mins { 0 => "now".into(), 1..=59 => format!("{mins}m"), 60..=1439 => format!("{}h", mins / 60), _ if mins / 1440 < 14 => format!("{}d", mins / 1440), _ => format!("{}w", mins / 1440 / 7) }+}++fn phone_rows(app: &App) -> Vec<Row> {+ let p = &app.devices.phone;+ let mut rows = Vec::new();+ let group = format!("Paired with this {}", this_computer());+ for d in &p.paired {+ let Some(fp) = d.get("fingerprint").and_then(Value::as_str) else { continue };+ let online = d.get("online").and_then(Value::as_bool) == Some(true);+ let when = if online { "online".to_string() } else { short_ago(d.get("pairedAt").and_then(Value::as_u64).unwrap_or(0)) };+ rows.push(Row::new(format!("ph:{fp}"), device_name(d)).group(group.clone()).extra(fp.to_string()).lead(dot(if online { "✓" } else { "·" }, if online { theme::ONLINE } else { theme::MUTED })).right(format!("{when} enter removes")));+ }+ if !p.armed && !p.stopped && p.connected.is_none() { rows.push(Row::new("ph:arm", "Let a phone pair…").group("This code").lead(dot("▸", theme::TEAL)).detail(vec![span("hands this computer the code", fg(theme::MUTED))])) }+ rows.push(Row::new("ph:new", "New code").group("This code").lead(dot("↻", theme::MUTED)).detail(vec![span("the old one stops pairing", fg(theme::MUTED))]));+ rows+}++// ── previews ─────────────────────────────────────────────────────────────────++fn dim(text: impl Into<String>) -> Span<'static> { Span::styled(text.into(), Style::default().add_modifier(Modifier::DIM)) }+fn bold(text: impl Into<String>) -> Span<'static> { Span::styled(text.into(), Style::default().add_modifier(Modifier::BOLD)) }+fn kv(k: &str, v: impl Into<String>) -> Line<'static> { Line::from(vec![dim(format!("{k:<10}")), Span::raw(v.into())]) }+fn enter_does(text: impl Into<String>) -> Vec<Line<'static>> { vec![Line::raw(""), Line::from(vec![Span::styled("enter ", fg(theme::accent())), dim(text)])] }++/// The right side for the row under the cursor: what it is, and what Enter does.+pub fn preview(app: &App, view: View, id: &str) -> Vec<Line<'static>> {+ let (what, rest) = id.split_once(':').unwrap_or((id, ""));+ match what {+ _ if app.daemon_down && matches!(id, "none" | "m-none") => vec![Line::raw("Harness is not running on this computer."), Line::raw(""), dim("Start it with `harness start`, then come back.").into()],+ "none" => vec![Line::raw("Every machine on your account that is online is linked."), Line::raw(""), dim("To add another: Machines & devices… › Add a machine.").into()],+ "m" => {+ let mut out = machine_lines(app, rest);+ if view == View::Connect {+ out.push(Line::raw(""));+ out.push(dim("Enter the remote password set on this machine.").into());+ out.extend(stage_lines(app, rest));+ if app.devices.link.as_ref().is_none_or(|l| l.machine != rest) { out.extend(enter_does("type its remote password, then link")) }+ } else {+ out.extend(enter_does("its actions — open, connect, rename, remove from account"));+ }+ out+ }+ "act" => {+ let (verb, machine) = rest.split_once(':').unwrap_or((rest, ""));+ let mut out = machine_lines(app, machine);+ out.extend(enter_does(match verb {+ "open" => "opens its harnesses",+ "connect" => "asks for its remote password, then links it",+ "rename" => "asks for its new name, then y/n",+ "remove" => "asks y/n, then deletes it from your account",+ _ => "",+ }));+ out+ }+ "pw" => {+ let mut out = Vec::new();+ match &app.devices.password {+ Some(Ok(v)) if v.get("hasPassword").and_then(Value::as_bool) == Some(true) => {+ out.push(Line::from(vec![Span::styled("Remote password is set", fg(theme::ONLINE).add_modifier(Modifier::BOLD))]));+ if let Some(f) = v.get("fingerprint").and_then(Value::as_str) { out.push(kv("fingerprint", f)) }+ if let Some(t) = v.get("setAt").and_then(Value::as_u64) { out.push(kv("set", format!("{} ago", crate::fleet::ago(t)))) }+ out.push(Line::raw(""));+ out.push(dim("On the other machine: Link machine → select this computer → enter its password.").into());+ }+ Some(Ok(_)) => { out.push(bold("No remote password set.").into()); out.push(Line::raw("")); out.push(dim("Use this password on the other machine to link to this computer.").into()) }+ Some(Err(e)) => { out.push(Line::from(vec![Span::styled("Password status is unavailable.", fg(theme::WARN))])); if e != "Password status is unavailable." { out.push(dim(e.clone()).into()) } }+ None => out.push(dim("Reading password status…").into()),+ }+ out.extend(enter_does(match rest { "set" => "asks for the new password twice, then y/n", "clear" => "asks y/n, then clears it — existing links stay", _ => "reads its status again" }));+ out+ }+ "ln" if rest.is_empty() => { let mut out = vec![Line::from(dim("Machines this computer can connect to."))]; out.extend(enter_does("reads `harness link list` again")); out }+ "ln" => {+ let Some(Ok(list)) = &app.devices.links else { return vec![] };+ let Some(l) = list.iter().find(|l| l.machine == rest) else { return vec![] };+ let mut out = vec![bold(name_of(app, rest)).into(), Line::raw(""), kv("machine", l.machine.clone()), kv("fingerprint", l.fingerprint.clone()), kv("linked", l.at.clone())];+ out.extend(enter_does("asks y/n, then unlinks it — a new connection will need its password"));+ out+ }+ "add" => {+ let (text, copies): (&str, String) = match rest {+ "download" => ("Download Harness on your other computer and sign in with the same account.", DOWNLOAD_URL.into()),+ "connect" => ("On the other computer: Machines → Set password. Back here, Connect a machine and enter that password.", String::new()),+ "install" => ("Run these on your server over SSH:", INSTALL.into()),+ "login" => ("Open the printed sign-in link in a browser on any device.", LOGIN.into()),+ "start" => ("Start Harness and set a remote password.", START.into()),+ _ => ("Run these on your server over SSH:", format!("{INSTALL}\n{LOGIN}\n{START}")),+ };+ let mut out = vec![Line::raw(text.to_string()), Line::raw("")];+ for l in copies.lines() { out.push(Line::from(vec![Span::styled(l.to_string(), fg(theme::TEAL))])) }+ out.extend(enter_does(if copies.is_empty() { "opens Connect a machine".to_string() } else { "copies it — to the clipboard of the computer you sit at".to_string() }));+ out+ }+ "ph" => {+ let Some(d) = app.devices.phone.paired.iter().find(|p| p.get("fingerprint").and_then(Value::as_str) == Some(rest)) else {+ return enter_does(if rest == "new" { "draws a new code; the old one no longer pairs" } else { "asks y/n, then hands this computer the code while the QR shows" });+ };+ let mut out = vec![bold(device_name(d)).into(), Line::raw(""), kv("fingerprint", rest.to_string())];+ if let Some(t) = d.get("pairedAt").and_then(Value::as_u64) { out.push(kv("paired", format!("{} ago", crate::fleet::ago(t)))) }+ out.extend(enter_does("asks y/n, then takes its access away"));+ out+ }+ _ => vec![],+ }+}++fn machine_lines(app: &App, id: &str) -> Vec<Line<'static>> {+ let Some(m) = app.fleet.machine(id) else { return vec![dim("(gone)").into()] };+ let (glyph, color, word) = reach(app, m);+ let mut out = vec![Line::from(vec![bold(m.name.clone()), dim(if m.local { " this computer" } else { "" })]), Line::raw("")];+ out.push(Line::from(vec![dim(format!("{:<10}", "status")), Span::styled(format!("{glyph} {word}"), fg(color))]));+ if let Some(rtt) = app.rtt.get(id).filter(|_| m.usable()) { out.push(kv("rtt", format!("{}ms", rtt.as_millis()))) }+ let row = app.devices.account.get(id);+ let seen = row.and_then(|r| ["lastSeenAt", "lastSeen", "lastActiveAt", "updatedAt"].iter().find_map(|k| r.get(*k)));+ match seen {+ Some(Value::Number(n)) => { let ms = n.as_u64().unwrap_or(0); let ms = if ms < 10_000_000_000 { ms * 1000 } else { ms }; out.push(kv("last seen", format!("{} ago", crate::fleet::ago(ms)))) }+ Some(Value::String(s)) => out.push(kv("last seen", s.clone())),+ _ if m.online() => out.push(kv("last seen", "now")),+ _ => {}+ }+ out.push(kv("harnesses", counts(app, id)));+ let mut agents: Vec<_> = app.fleet.agents.values().filter(|a| a.machine_id == id && a.status != "stopped").collect();+ agents.sort_by_key(|a| std::cmp::Reverse(a.recency()));+ for a in agents.iter().take(6) { out.push(Line::from(vec![Span::raw(format!(" {}", a.name)), dim(format!(" {}", a.project))])) }+ if !m.online() && !m.local { out.push(Line::raw("")); out.push(dim(format!("Open Harness on {} to bring it online.", m.name)).into()) }+ out+}++/// The link's stages as far as they got: ✓ done, the spinner on the one it is at, ✗ where it+/// failed, · still to come — then how it ended.+fn stage_lines(app: &App, machine: &str) -> Vec<Line<'static>> {+ let Some(l) = app.devices.link.as_ref().filter(|l| l.machine == machine) else { return vec![] };+ let at = STAGES.iter().position(|(s, _)| *s == l.stage).unwrap_or(0);+ let mut out = vec![Line::raw("")];+ for (i, (_, words)) in STAGES.iter().enumerate() {+ let (mark, color) = match &l.result {+ Some(Ok(_)) => ("✓", theme::ONLINE),+ Some(Err(_)) if i == at => ("✗", theme::DANGER),+ _ if i < at => ("✓", theme::ONLINE),+ None if i == at => (theme::spinner(app.tick), theme::WARN),+ _ => ("·", theme::MUTED),+ };+ out.push(Line::from(vec![Span::styled(format!("{mark} "), fg(color)), Span::raw(words.to_string())]));+ }+ out.push(Line::raw(""));+ match &l.result {+ Some(Ok(f)) => { out.push(Line::from(vec![Span::styled(format!("✓ Linked {}", l.name), fg(theme::ONLINE).add_modifier(Modifier::BOLD))])); if !f.is_empty() { out.push(kv("fingerprint", f.clone())) } }+ Some(Err(e)) => out.push(Line::from(vec![Span::styled(format!("✗ {e}"), fg(theme::DANGER))])),+ None => out.push(dim("Connecting continues if you close this prompt.").into()),+ }+ out+}++// ── drawing ──────────────────────────────────────────────────────────────────++/// A title, where you are inside it, and the way out.+fn head(buf: &mut Buffer, app: &App, title: &str, x: u16, y: u16, right: u16, c: &Chrome) {+ let mut at = x + settings::put(buf, x, y, right.saturating_sub(x), title, c.base.add_modifier(Modifier::BOLD));+ let level = app.devices.sub.as_deref().and_then(|s| s.strip_prefix("m:")).map(|id| name_of(app, id));+ if let Some(level) = level {+ at += settings::put(buf, at, y, right.saturating_sub(at), " › ", c.muted);+ settings::put(buf, at, y, right.saturating_sub(at), &level, c.accent);+ }+ settings::put(buf, right.saturating_sub(3), y, 3, "esc", c.muted);+}++/// The query line — or, while the panel asks for a line, that line (a password as dots).+fn query_line(buf: &mut Buffer, app: &App, picker: &Picker, x: u16, y: u16, right: u16, c: &Chrome) -> Option<Position> {+ let w = right.saturating_sub(x);+ if let Some(Ask::Entry { label, value, secret, .. }) = &app.devices.ask {+ let at = x + settings::put(buf, x, y, w, &format!("{label} › "), c.accent);+ let shown = if *secret { "•".repeat(value.chars().count()) } else { value.clone() };+ settings::put(buf, at, y, right.saturating_sub(at), &shown, c.base);+ return Some(Position::new((at + shown.width() as u16).min(right), y));+ }+ settings::put(buf, x, y, 2, "›", c.accent);+ let shown = if picker.query.is_empty() { (picker.placeholder.as_str(), c.muted) } else { (picker.query.as_str(), c.base) };+ settings::put(buf, x + 2, y, w.saturating_sub(2), shown.0, shown.1);+ picker.prompt_at.set((y, x + 2));+ let before: String = picker.query.chars().take(picker.qcursor).collect();+ (app.devices.ask.is_none()).then(|| Position::new((x + 2 + before.width() as u16).min(right), y))+}++/// [lines] in [r], each wrapped at its words; a dim span in the panel's muted colour. Returns the+/// rows used.+fn text(buf: &mut Buffer, r: Rect, lines: &[Line<'static>], c: &Chrome) -> u16 {+ let mut y = r.y;+ for line in lines {+ if y >= r.bottom() { break }+ let (mut x, mut wrapped) = (r.x, false);+ for s in &line.spans {+ let style = if s.style.add_modifier.contains(Modifier::DIM) { c.muted.patch(s.style.remove_modifier(Modifier::DIM)) } else { c.base.patch(s.style) };+ for word in s.content.split_inclusive(' ') {+ let bare = word.trim_end();+ let w = bare.width() as u16;+ if x + w > r.right() && x > r.x && w > 0 { y += 1; x = r.x; wrapped = true; if y >= r.bottom() { return y - r.y } }+ // (A wrapped line starts at its word, not at the space before it; the space after+ // the last word that fits is left off rather than cut.)+ if wrapped && x == r.x && bare.is_empty() { continue }+ let piece = if x + word.width() as u16 > r.right() { bare } else { word };+ x += settings::put(buf, x, y, r.right().saturating_sub(x), piece, style);+ }+ }+ y += 1;+ }+ y.saturating_sub(r.y)+}++/// What the footer says: the question being asked, the typed line's keys, what just happened or+/// went wrong, else the keys.+fn footer(buf: &mut Buffer, app: &App, picker: &Picker, x: u16, y: u16, w: u16, c: &Chrome) {+ let danger = c.base.patch(fg(theme::DANGER));+ let (line, style) = match &app.devices.ask {+ Some(Ask::Confirm { question, .. }) => (format!("{question} y/n"), c.accent),+ Some(Ask::Entry { what, .. }) => {+ let go = match what { Entry::Link { .. } => "link", Entry::NewPassword => "next", Entry::RepeatPassword { .. } => "set", Entry::Rename { .. } => "rename" };+ match app.devices.footer.as_ref() {+ Some((t, err, _)) => (format!("{t} enter {go} esc cancel"), if *err { danger } else { c.muted }),+ None => (format!("enter {go} esc cancel"), c.muted),+ }+ }+ None => match app.devices.footer.as_ref().filter(|(_, err, at)| *err || at.elapsed() < Duration::from_secs(6)) {+ Some((t, err, _)) => (t.clone(), if *err { danger } else { c.accent }),+ None => (format!("↑↓ move enter choose type to search esc {}", if app.devices.sub.is_some() || picker.from_commands { "back" } else { "close" }), c.muted),+ },+ };+ // (Too long for one line — a question beside the QR code — it takes the line above too.)+ if line.width() as u16 <= w || y == 0 { settings::put(buf, x, y, w, &line, style); return }+ let line = Line::from(Span::styled(line, Style::default().fg(style.fg.unwrap_or(Color::Reset)).add_modifier(style.add_modifier)));+ text(buf, Rect::new(x, y - 1, w, 2), &[line], c);+}++/// Draw [view] as the panel: the settings panel's surface, title, query line, list and footer, the+/// row's preview on the right — and for Add phone the QR code, as tall as the panel.+pub fn draw(buf: &mut Buffer, app: &App, body: Rect, view: View, picker: &mut Picker) -> Option<Position> {+ let c = settings::chrome();+ settings::backdrop(buf, body, c.backdrop);+ if body.width < 24 || body.height < 8 {+ settings::put(buf, body.x, body.y, body.width, &format!("{} · resize or Esc", view.title()), c.base);+ return None;+ }+ let r = settings::area(body);+ settings::fill(buf, r, c.base);+ picker.screen_area.set(r);+ picker.preview_area.set(None);+ picker.bar.set(None);+ if view == View::Phone { return phone_draw(buf, app, r, picker, &c) }+ let (x, right) = (r.x + 2, r.right().saturating_sub(2));+ let inner_w = right.saturating_sub(x);+ head(buf, app, view.title(), x, r.y + 1, right, &c);+ let cursor = query_line(buf, app, picker, x, r.y + 3, right, &c);+ let (top, bottom) = (r.y + 5, r.bottom().saturating_sub(3));+ let side = inner_w >= 64;+ let list_w = if side { (inner_w / 2).clamp(30, 48) } else { inner_w };+ settings::list(buf, picker, Rect::new(x, top, list_w, bottom.saturating_sub(top)), &c, !side);+ if side {+ let px = x + list_w + 3;+ let lines = picker.current_id().map(|id| preview(app, view, &id)).unwrap_or_default();+ text(buf, Rect::new(px, r.y + 3, right.saturating_sub(px), bottom.saturating_sub(r.y + 3)), &lines, &c);+ }+ footer(buf, app, picker, x, r.bottom().saturating_sub(2), inner_w, &c);+ cursor+}++/// Add phone: the QR on the left, from the panel's top to its bottom (two modules a row), and+/// beside it what to do, the code in text, the paired devices, and the footer.+fn phone_draw(buf: &mut Buffer, app: &App, r: Rect, picker: &mut Picker, c: &Chrome) -> Option<Position> {+ let p = &app.devices.phone;+ let right = r.right().saturating_sub(2);+ let mut tx = r.x + 2;+ let mut needs = None;+ p.drawn.set(None);+ let link = phone_link(app);+ if let Some(link) = &link {+ let (cols, rows) = (r.width.saturating_sub(2 + 34), r.height);+ let cached = p.cache.borrow().as_ref().filter(|(l, w, h, _)| l == link && *w == cols && *h == rows).map(|(_, _, _, m)| m.clone());+ let modules = cached.unwrap_or_else(|| { let m = qr_modules(link, cols, rows); *p.cache.borrow_mut() = Some((link.clone(), cols, rows, m.clone())); m });+ match modules {+ Some(m) => {+ let n = m.len().div_ceil(2) as u16;+ let at = draw_qr(buf, r.x + 1, r.y + (r.height - n) / 2, &m, p.connected.is_some() || p.stopped);+ p.drawn.set(Some(at));+ tx = at.right() + 3;+ }+ None => needs = Some(qr_least(link)),+ }+ }+ let tw = right.saturating_sub(tx);+ head(buf, app, View::Phone.title(), tx, r.y + 1, right, c);+ let computer = this_computer();+ let mut lines: Vec<Line<'static>> = Vec::new();+ let status = |text: String, color: Color| Line::from(Span::styled(text, fg(color)));+ if p.signed_out {+ lines.push(Line::raw("Sign in to add your phone."));+ } else if target(app).is_none() {+ lines.push(dim(if p.email.is_some() || app.daemon_down { format!("Waiting for Harness on this {computer}…") } else { "Waiting for your account…".into() }).into());+ } else if !p.sign_in_asked {+ lines.push(dim("Getting a sign-in code…").into());+ } else {+ if let Some((w, h)) = needs {+ // (The panel is at most 104 × 28; the words beside the code take 34 columns.)+ lines.push(status(if h <= 28 && w + 36 <= 104 { format!("Make the window at least {}×{} to show the QR code.", w + 40, h + 3) } else { "The QR code is too big for the panel.".into() }, theme::WARN));+ }+ lines.push(match (&p.connected, &p.message) {+ (Some(label), _) => status(format!("✓ Connected {label}"), theme::ONLINE),+ (None, Some(m)) => status(m.clone(), theme::DANGER),+ _ if !p.armed => dim("Not pairing yet").into(),+ _ => dim("Scan with Harness on your iPhone").into(),+ });+ lines.push(Line::raw(""));+ let grouped: Vec<String> = p.code.as_bytes().chunks(4).map(|g| String::from_utf8_lossy(g).to_string()).collect();+ lines.push(Line::from(vec![dim("Code "), bold(grouped.join(" "))]));+ let machine = app.fleet.machine_name(&app.fleet.local_id);+ lines.push(dim(format!("Pairs with {} · signs in as {}", if machine.is_empty() { format!("this {computer}") } else { machine }, p.email.clone().unwrap_or_default())).into());+ if p.sign_in.is_none() { lines.push(dim("Your phone will ask for an emailed sign-in code.").into()) }+ }+ let used = text(buf, Rect::new(tx, r.y + 3, tw, r.height.saturating_sub(6)), &lines, c);+ let top = r.y + 3 + used + 1;+ let bottom = r.bottom().saturating_sub(3);+ if top < bottom { settings::list(buf, picker, Rect::new(tx, top, tw, bottom - top), c, false) } else { picker.row_at.clear() }+ footer(buf, app, picker, tx, r.bottom().saturating_sub(2), tw, c);+ None+}++#[cfg(test)]+mod tests {+ use super::*;+ use std::sync::{Arc, Mutex};+ use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};++ const LOCAL: &str = "4f3c2b1a-9e8d-4c7b-a6f5-0e1d2c3b4a59";+ const REMOTE: &str = "7a6b5c4d-3e2f-4a1b-9c8d-7e6f5a4b3c2d";+ const OFF: &str = "11111111-2222-4333-8444-555555555555";++ fn app(size: (u16, u16)) -> App {+ let (sink, _) = tokio::sync::mpsc::unbounded_channel();+ let mut app = App::new(19789, sink, size);+ app.fleet.local_id = LOCAL.into();+ app.fleet.machines.push(crate::fleet::Machine { id: LOCAL.into(), name: "studio".into(), local: true, status: "online".into(), reach: Reach::Ready });+ app.fleet.machines.push(crate::fleet::Machine { id: REMOTE.into(), name: "gpu-box".into(), local: false, status: "online".into(), reach: Reach::NeedsLink });+ app.fleet.machines.push(crate::fleet::Machine { id: OFF.into(), name: "laptop".into(), local: false, status: "offline".into(), reach: Reach::Offline });+ app+ }++ /// The world as the tests' fake CLI and daemon tell it.+ fn world(req: &Req) -> Option<Reply> {+ let ok = |out: &str| Some(Reply::Cli { ok: true, out: format!("{out}\n"), err: String::new() });+ match req {+ Req::Wait(_) => None,+ Req::Cli { args, .. } => match args.iter().map(String::as_str).collect::<Vec<_>>().as_slice() {+ ["remote-password", "status", "--json"] => ok(r#"{"hasPassword":true,"fingerprint":"K7QF-2M9D","setAt":1759200000000}"#),+ ["link", "list"] => ok(&format!("\n Linked machines:\n\n 1. {REMOTE} K7QF-2M9D-X4PL (linked 2026-09-30 09:15)\n")),+ ["link", "connect", ..] => ok("{\"stage\":\"connecting\"}\n{\"stage\":\"deriving_key\"}\n{\"stage\":\"exchanging\"}\n{\"stage\":\"verifying\"}\n{\"ok\":true,\"fingerprint\":\"ZZ99-AA11\",\"machineId\":\"x\",\"mutual\":true}"),+ _ => ok(r#"{"ok":true}"#),+ },+ Req::Http { method, path, .. } => Some(Reply::Http(match (*method, path.as_str()) {+ ("GET", "/api/machines") => Ok(json!({ "machines": [{ "machineId": REMOTE, "name": "gpu-box", "status": "online", "lastSeenAt": 1759200000000u64 }] })),+ ("GET", "/api/auth/me") => Ok(json!({ "user": { "email": "[email protected]" } })),+ ("POST", "/api/auth/handoff") => Ok(json!({ "code": "hs_4d1f0c6e2b9a8f7e6d5c4b3a2f1e0d9c8b7a6f5e", "expiresIn": 90 })),+ ("GET", "/api/pairs") => Ok(json!({ "pairs": [{ "fingerprint": "PH-1", "label": "Dee's iPhone", "pairedAt": 1759200000000u64, "online": true, "role": "web" }, { "fingerprint": "DEV-1", "label": "Cabled gadget", "role": "device" }] })),+ ("POST", "/api/pair") => Err(("HTTP_409".into(), "NO_INTENT".into())),+ _ => Ok(json!({})),+ })),+ _ => Some(Reply::Done),+ }+ }++ /// The fake world, every request it was asked written down.+ fn fake(app: &mut App) -> Arc<Mutex<Vec<Req>>> {+ let log = Arc::new(Mutex::new(Vec::new()));+ let seen = log.clone();+ app.devices.runner = Some(Box::new(move |req: &Req| { seen.lock().unwrap().push(req.clone()); world(req) }));+ log+ }++ fn press(app: &mut App, code: KeyCode) { crate::input::modal_key(app, KeyEvent::new(code, KeyModifiers::NONE)) }+ fn typed(app: &mut App, text: &str) { for c in text.chars() { press(app, KeyCode::Char(c)) } }+ fn go_to(app: &mut App, id: &str) {+ let Some(Modal::Picker { picker: p, .. }) = &mut app.modal else { panic!("no list open") };+ p.select(id);+ assert_eq!(p.current_id().as_deref(), Some(id), "no row {id}");+ }+ fn ids(app: &App) -> Vec<String> { match &app.modal { Some(Modal::Picker { picker, .. }) => picker.rows.iter().map(|r| r.id.clone()).collect(), _ => vec![] } }+ fn clis(log: &Arc<Mutex<Vec<Req>>>, first: &str) -> Vec<Req> { log.lock().unwrap().iter().filter(|r| matches!(r, Req::Cli { args, .. } if args.first().map(String::as_str) == Some(first))).cloned().collect() }+ fn has(log: &Arc<Mutex<Vec<Req>>>, want: &Req) -> bool { log.lock().unwrap().contains(want) }++ fn screen(app: &mut App, w: u16, h: u16) -> (String, Buffer) {+ let mut term = ratatui::Terminal::new(ratatui::backend::TestBackend::new(w, h)).unwrap();+ term.draw(|f| crate::ui::draw(f, app)).unwrap();+ let buf = term.backend().buffer().clone();+ ((0..h).map(|y| (0..w).map(|x| buf[(x, y)].symbol().to_string()).collect::<String>()).collect::<Vec<_>>().join("\n"), buf)+ }++ #[test]+ fn the_commands_panel_lists_the_three_views_under_machines() {+ let app = app((150, 42));+ let rows = crate::modal::command_rows(&app);+ for view in View::ALL {+ let row = rows.iter().find(|r| r.id == format!("cmd:{}", view.id())).unwrap_or_else(|| panic!("{} missing", view.id()));+ assert_eq!(row.group.as_deref(), Some("Machines"));+ assert!(crate::input::is_command(view.id()));+ }+ }++ #[test]+ fn machines_and_devices_has_its_sections_and_rows() {+ let mut app = app((150, 42));+ let _log = fake(&mut app);+ crate::input::run(&mut app, "devices");+ let rows = ids(&app);+ for id in ["pw:set", "pw:clear", &format!("m:{LOCAL}"), &format!("m:{REMOTE}"), &format!("m:{OFF}"), &format!("ln:{REMOTE}"), "ln:", "add:download", "add:connect", "add:install", "add:login", "add:start", "add:all"] {+ assert!(rows.iter().any(|r| r == id), "{id} missing from {rows:?}");+ }+ let Some(Modal::Picker { picker, .. }) = &app.modal else { panic!() };+ let groups: Vec<&str> = picker.rows.iter().filter_map(|r| r.group.as_deref()).collect::<Vec<_>>();+ let mut seen: Vec<&str> = Vec::new();+ for g in groups { if seen.last() != Some(&g) { seen.push(g) } }+ assert_eq!(seen, vec!["This computer", "Your machines", "Linked from here", "Add a machine", "Set up a server"], "each group once, in order");+ assert!(picker.rows.iter().any(|r| r.id == "add:login" && r.label == "2. Sign in as [email protected]"), "the server steps name the account");+ // A machine opens its actions: no Remove for this computer, Connect for one not linked.+ go_to(&mut app, &format!("m:{REMOTE}"));+ press(&mut app, KeyCode::Enter);+ let acts = ids(&app);+ assert!(acts.contains(&format!("act:connect:{REMOTE}")) && acts.contains(&format!("act:remove:{REMOTE}")) && acts.contains(&format!("act:rename:{REMOTE}")), "{acts:?}");+ press(&mut app, KeyCode::Esc);+ assert_eq!(picker_mut(&mut app).and_then(|p| p.current_id()), Some(format!("m:{REMOTE}")), "back on the machine");+ go_to(&mut app, &format!("m:{LOCAL}"));+ press(&mut app, KeyCode::Enter);+ assert!(!ids(&app).iter().any(|r| r.starts_with("act:remove")), "this computer cannot be removed here");+ }++ #[test]+ fn connect_lists_only_the_machines_not_linked() {+ let mut app = app((150, 42));+ let _log = fake(&mut app);+ crate::input::run(&mut app, "connect-machine");+ let Some(Modal::Picker { picker, .. }) = &app.modal else { panic!() };+ let usable: Vec<&str> = picker.rows.iter().filter(|r| !r.disabled).map(|r| r.id.as_str()).collect();+ assert_eq!(usable, vec![format!("m:{REMOTE}").as_str()]);+ assert!(picker.rows.iter().any(|r| r.id == format!("m:{OFF}") && r.disabled), "an offline one is shown, not chosen");+ }++ #[test]+ fn connecting_asks_the_password_hidden_then_yes_then_shows_each_stage() {+ let mut app = app((150, 42));+ let log = fake(&mut app);+ crate::input::run(&mut app, "connect-machine");+ press(&mut app, KeyCode::Enter);+ assert!(matches!(app.devices.ask, Some(Ask::Entry { secret: true, .. })), "the password is asked for, hidden");+ press(&mut app, KeyCode::Enter);+ assert_eq!(app.devices.footer.as_ref().map(|f| f.0.as_str()), Some("Enter the remote password first"));+ typed(&mut app, "hunter2");+ let (s, _) = screen(&mut app, 150, 42);+ assert!(s.contains("Remote password for gpu-box › •••••••") && !s.contains("hunter2"), "shown as dots:\n{s}");+ press(&mut app, KeyCode::Enter);+ assert!(clis(&log, "link").iter().all(|r| !matches!(r, Req::Cli { args, .. } if args[1] == "connect")), "nothing runs before the yes");+ assert!(matches!(app.devices.ask, Some(Ask::Confirm { .. })));+ press(&mut app, KeyCode::Char('y'));+ let run = clis(&log, "link").into_iter().find(|r| matches!(r, Req::Cli { args, .. } if args[1] == "connect")).expect("link connect ran");+ assert_eq!(run, Req::Cli { args: ["link", "connect", REMOTE, "--stdin", "--json", "--name=gpu-box"].iter().map(|s| s.to_string()).collect(), stdin: Some("hunter2".into()) }, "the password on stdin, never an argument");+ let l = app.devices.link.as_ref().unwrap();+ assert_eq!(l.stage, "verifying");+ assert_eq!(l.result, Some(Ok("ZZ99-AA11".into())));+ let (s, _) = screen(&mut app, 150, 42);+ for stage in STAGES.iter().map(|s| s.1) { assert!(s.contains(&format!("✓ {stage}")), "{stage} done:\n{s}") }+ assert!(s.contains("Linked gpu-box"));+ }++ /// M-l on a machine (the machines list) is this same flow: the panel, its password asked for.+ #[test]+ fn m_l_opens_connect_with_the_password_asked() {+ let mut app = app((150, 42));+ let _log = fake(&mut app);+ connect_to(&mut app, REMOTE.into());+ assert!(matches!(&app.modal, Some(Modal::Picker { kind: PickerKind::Devices(View::Connect), picker }) if picker.current_id() == Some(format!("m:{REMOTE}"))));+ assert!(matches!(&app.devices.ask, Some(Ask::Entry { what: Entry::Link { machine, .. }, secret: true, .. }) if machine == REMOTE));+ }++ #[test]+ fn stages_come_in_as_the_cli_prints_them_and_a_refusal_says_why() {+ assert_eq!(stage_of(r#"{"stage":"deriving_key"}"#).as_deref(), Some("deriving_key"));+ assert_eq!(stage_of(r#"{"ok":true}"#), None);+ assert_eq!(stage_of("not json"), None);+ let out = "{\"stage\":\"connecting\"}\n{\"stage\":\"deriving_key\"}\n{\"ok\":false,\"error\":\"WRONG_PASSWORD\",\"message\":\"That password is wrong. Check it against the other machine and try again.\"}\n";+ assert_eq!(last_json(out).and_then(|v| v.get("error").cloned()), Some(json!("WRONG_PASSWORD")), "a stage line is never the result");+ let mut app = app((150, 42));+ let reply = out.to_string();+ app.devices.runner = Some(Box::new(move |req: &Req| match req { Req::Cli { .. } => Some(Reply::Cli { ok: false, out: reply.clone(), err: String::new() }), _ => world(req) }));+ link_connect(&mut app, REMOTE.into(), "gpu-box".into(), "wrong".into());+ let l = app.devices.link.as_ref().unwrap();+ assert_eq!(l.stage, "deriving_key", "it failed where it was");+ assert_eq!(l.result, Some(Err("That password is wrong. Check it against the other machine and try again.".into())));+ let lines: Vec<String> = stage_lines(&app, REMOTE).iter().map(|l| l.spans.iter().map(|s| s.content.to_string()).collect()).collect();+ assert!(lines.iter().any(|l| l == "✓ Connecting") && lines.iter().any(|l| l == "✗ Checking the password") && lines.iter().any(|l| l == "· Exchanging keys"), "{lines:?}");+ }++ #[test]+ fn link_list_is_read_from_the_cli_text() {+ let out = "\n Linked machines:\n\n 1. 7a6b5c4d-3e2f K7QF-2M9D (linked 2026-09-30 09:15)\n 12. box-2 AB12 (linked 2026-01-02 03:04)\n";+ assert_eq!(parse_links(out), vec![+ Linked { machine: "7a6b5c4d-3e2f".into(), fingerprint: "K7QF-2M9D".into(), at: "2026-09-30 09:15".into() },+ Linked { machine: "box-2".into(), fingerprint: "AB12".into(), at: "2026-01-02 03:04".into() },+ ]);+ assert!(parse_links("\n No machines linked yet.\n").is_empty());+ }++ #[test]+ fn every_write_asks_first() {+ let mut app = app((150, 42));+ let log = fake(&mut app);+ crate::input::run(&mut app, "devices");+ // Unlink: y/n first; n changes nothing, y runs it.+ go_to(&mut app, &format!("ln:{REMOTE}"));+ press(&mut app, KeyCode::Enter);+ assert!(matches!(&app.devices.ask, Some(Ask::Confirm { question, .. }) if question.contains("gpu-box")));+ press(&mut app, KeyCode::Char('n'));+ let unlink = cli(&["link", "unlink", REMOTE], None);+ assert!(!has(&log, &unlink), "n: nothing ran");+ go_to(&mut app, &format!("ln:{REMOTE}"));+ press(&mut app, KeyCode::Enter);+ press(&mut app, KeyCode::Char('y'));+ assert!(has(&log, &unlink), "y: unlinked");+ // Set password: twice, a mismatch caught, then y/n.+ go_to(&mut app, "pw:set");+ press(&mut app, KeyCode::Enter);+ typed(&mut app, "abc");+ press(&mut app, KeyCode::Enter);+ typed(&mut app, "abd");+ press(&mut app, KeyCode::Enter);+ assert_eq!(app.devices.footer.as_ref().map(|f| f.0.as_str()), Some("Passwords do not match"));+ typed(&mut app, "abc");+ press(&mut app, KeyCode::Enter);+ typed(&mut app, "abc");+ press(&mut app, KeyCode::Enter);+ let set = cli(&["remote-password", "set", "--stdin", "--json"], Some("abc".into()));+ assert!(!has(&log, &set));+ press(&mut app, KeyCode::Char('y'));+ assert!(has(&log, &set), "the password went on stdin");+ // Clear.+ go_to(&mut app, "pw:clear");+ press(&mut app, KeyCode::Enter);+ press(&mut app, KeyCode::Esc);+ assert!(!has(&log, &cli(&["remote-password", "clear", "--json"], None)));+ // Rename, then remove from the account.+ go_to(&mut app, &format!("m:{REMOTE}"));+ press(&mut app, KeyCode::Enter);+ go_to(&mut app, &format!("act:rename:{REMOTE}"));+ press(&mut app, KeyCode::Enter);+ press(&mut app, KeyCode::Char('u'));+ crate::input::modal_key(&mut app, KeyEvent::new(KeyCode::Char('u'), KeyModifiers::CONTROL));+ typed(&mut app, "render-box");+ press(&mut app, KeyCode::Enter);+ let rename = http("PATCH", format!("/api/machines/{REMOTE}"), Some(json!({ "name": "render-box" })));+ assert!(!has(&log, &rename));+ press(&mut app, KeyCode::Char('y'));+ assert!(has(&log, &rename));+ assert_eq!(app.fleet.machine_name(REMOTE), "render-box");+ go_to(&mut app, &format!("act:remove:{REMOTE}"));+ press(&mut app, KeyCode::Enter);+ let remove = http("DELETE", format!("/api/machines/{REMOTE}"), None);+ assert!(!has(&log, &remove));+ press(&mut app, KeyCode::Char('y'));+ assert!(has(&log, &remove));+ assert!(app.fleet.machine(REMOTE).is_none(), "gone from the list");+ }++ #[test]+ fn the_phone_link_is_the_apps() {+ assert_eq!(pair_link("[email protected]", "m-1", "ABCDEFGHJKMNPQRS", Some("a b/c")), "https://harness.autonomous.ai/pair#e=dev%2Bhn%40example.com&m=m-1&c=ABCDEFGHJKMNPQRS&h=a+b%2Fc");+ assert_eq!(pair_link("[email protected]", "m", "C", None), "https://harness.autonomous.ai/pair#e=a%40b.co&m=m&c=C");+ for _ in 0..50 {+ let code = new_code();+ assert_eq!(code.len(), CODE_LEN);+ assert!(code.bytes().all(|b| CODE_ALPHABET.contains(&b)), "{code}");+ }+ assert_ne!(new_code(), new_code());+ }++ /// Read the QR drawn in [buf] at [at] back to its modules, as a camera would see them, and decode it.+ fn decode(buf: &Buffer, at: Rect) -> String {+ let n = at.width as usize;+ let mut grid = vec![vec![false; n]; at.height as usize * 2];+ for row in 0..at.height as usize {+ for col in 0..n {+ let s = buf[(at.x + col as u16, at.y + row as u16)].symbol().to_string();+ grid[2 * row][col] = s == "█" || s == "▀";+ grid[2 * row + 1][col] = s == "█" || s == "▄";+ assert_eq!(buf[(at.x + col as u16, at.y + row as u16)].bg, theme::depth_fit(Color::Rgb(255, 255, 255)), "light behind every module");+ }+ }+ let scale = 6;+ let (w, h) = ((n + 8) * scale, (grid.len() + 8) * scale);+ let mut img = rqrr::PreparedImage::prepare_from_greyscale(w, h, |x, y| {+ let (mx, my) = ((x / scale) as isize - 4, (y / scale) as isize - 4);+ let dark = mx >= 0 && my >= 0 && (my as usize) < grid.len() && (mx as usize) < n && grid[my as usize][mx as usize];+ if dark { 0 } else { 255 }+ });+ let grids = img.detect_grids();+ assert_eq!(grids.len(), 1, "one code found");+ grids[0].decode().expect("it decodes").1+ }++ #[test]+ fn the_qr_drawn_in_half_blocks_reads_back_as_the_exact_link() {+ for link in [+ pair_link("[email protected]", LOCAL, "ABCDEFGHJKMNPQRS", None),+ pair_link("[email protected]", LOCAL, "ABCDEFGHJKMNPQRS", Some("hs_4d1f0c6e2b9a8f7e6d5c4b3a2f1e0d9c8b7a6f5e")),+ ] {+ let modules = qr_modules(&link, 70, 28).expect("fits the panel at 150×42");+ assert!(modules.len() <= 56, "two modules a row, 28 rows");+ let mut buf = Buffer::empty(Rect::new(0, 0, 80, 30));+ let at = draw_qr(&mut buf, 1, 1, &modules, false);+ assert_eq!(decode(&buf, at), link);+ }+ assert!(qr_modules(&pair_link("[email protected]", LOCAL, "ABCDEFGHJKMNPQRS", None), 40, 18).is_none(), "too small: none, not an unreadable one");+ }++ #[test]+ fn add_phone_shows_the_qr_for_the_link_and_arms_only_after_a_yes() {+ let mut app = app((150, 42));+ let log = fake(&mut app);+ crate::input::run(&mut app, "add-phone");+ let pair = |log: &Arc<Mutex<Vec<Req>>>| log.lock().unwrap().iter().filter(|r| matches!(r, Req::Http { path, .. } if path == "/api/pair")).count();+ assert_eq!(pair(&log), 0, "not armed before the yes");+ let link = phone_link(&app).expect("a link");+ assert!(link.starts_with("https://harness.autonomous.ai/pair#e=dev%2Bhn%40example.com&m=") && link.contains("&h=hs_"), "{link}");+ let (s, buf) = screen(&mut app, 150, 42);+ let at = app.devices.phone.drawn.get().expect("the QR is drawn");+ assert_eq!(decode(&buf, at), link, "the screen's code is the link");+ let grouped: Vec<String> = app.devices.phone.code.as_bytes().chunks(4).map(|g| String::from_utf8_lossy(g).to_string()).collect();+ assert!(s.contains(&grouped.join(" ")), "the code in text:\n{s}");+ assert!(s.contains("Dee's iPhone") && !s.contains("Cabled gadget"), "the phones and computers paired, nothing else:\n{s}");+ press(&mut app, KeyCode::Char('y'));+ assert_eq!(pair(&log), 1, "armed: the code handed over");+ assert!(has(&log, &http("POST", "/api/pair", Some(json!({ "code": app.devices.phone.code })))));+ assert!(app.devices.phone.message.is_none(), "no phone yet is not an error");+ }++ #[test]+ fn each_view_draws_at_80x24_and_150x42() {+ for (w, h) in [(80u16, 24u16), (150, 42)] {+ for view in View::ALL {+ let mut app = app((w, h));+ let _log = fake(&mut app);+ crate::input::run(&mut app, view.id());+ let (s, _) = screen(&mut app, w, h);+ assert!(s.contains(view.title()), "{} at {w}x{h}:\n{s}", view.id());+ match view {+ View::Machines => assert!(s.contains("This computer") && s.contains("Your machines") && s.contains("enter choose"), "{s}"),+ View::Connect => assert!(s.contains("gpu-box") && s.contains("Not linked yet") && s.contains("enter choose"), "{s}"),+ View::Phone if w == 80 => assert!(s.contains("to show the QR code") && app.devices.phone.drawn.get().is_none(), "too small says so:\n{s}"),+ View::Phone => assert!(app.devices.phone.drawn.get().is_some(), "{s}"),+ }+ if view == View::Phone { assert!(s.contains("y/n"), "asks before handing over the code:\n{s}") }+ }+ }+ }++ #[test]+ fn opened_from_commands_esc_goes_back_there() {+ let mut app = app((150, 42));+ let _log = fake(&mut app);+ crate::input::run(&mut app, "commands");+ go_to(&mut app, "cmd:devices");+ press(&mut app, KeyCode::Enter);+ assert!(matches!(&app.modal, Some(Modal::Picker { kind: PickerKind::Devices(View::Machines), .. })));+ press(&mut app, KeyCode::Esc);+ let Some(Modal::Picker { kind, picker }) = &app.modal else { panic!("closed") };+ assert!(matches!(kind, PickerKind::Commands));+ assert_eq!(picker.current_id().as_deref(), Some("cmd:devices"));+ }++ #[test]+ fn nothing_real_runs_under_test() {+ let mut app = app((150, 42));+ crate::input::run(&mut app, "devices");+ assert!(matches!(app.devices.password, Some(Err(_))), "the CLI is not there in tests");+ }+}diff --git a/tui/src/fleet.rs b/tui/src/fleet.rsindex 40da846b5..1f670b00e 100644--- a/tui/src/fleet.rs+++ b/tui/src/fleet.rs@@ -112,6 +112,28 @@ pub struct Agent {/// When its transcript last changed, as the daemon last read it (tokenUsage.updatedAt, ms):/// what it last did, while no window was watching too.pub usage_at: u64,+ // ── models: the model its engine is pointed at (the frame's `grid`) ──+ /// A grid's or a saved API's model (`grid.model`; empty on its own login), that endpoint+ /// (`grid.baseUrl`, which tells one API from another), whether the computers serving it rest+ /// (`grid.state`: asleep, waking), and why it will not answer now (`grid.note`: its reason —+ /// offline, not_served — the model, and the computer).+ pub grid_model: String,+ pub grid_base_url: String,+ pub grid_state: String,+ pub grid_note: Option<(String, String, String)>,+}++/// `grid.note`, read as the desktop reads it: a reason it does not know, or one missing the names+/// its sentence needs, is no note.+fn grid_note(note: &Value) -> Option<(String, String, String)> {+ let model = s(note, "model");+ let machine = s(note, "machine");+ match s(note, "reason").as_str() {+ _ if model.is_empty() => None,+ "not_served" => Some(("not_served".into(), model, machine)),+ "offline" if !machine.is_empty() => Some(("offline".into(), model, machine)),+ _ => None,+ }}/// A pull request for an agent's branch: its number, state (Open, Draft, Merged, Closed), link.@@ -315,6 +337,11 @@ pub fn agent_from(machine_id: &str, row: &Value, previous: Option<&Agent>) -> Agusage_at: row.get("tokenUsage").map(|u| time(u, "updatedAt")).filter(|t| *t > 0).or(previous.map(|p| p.usage_at)).unwrap_or(0),todos: previous.map(|p| p.todos.clone()).unwrap_or_default(),subagents: previous.map(|p| p.subagents.clone()).unwrap_or_default(),+ // ── models ── (the daemon pushes the row again when its note clears)+ grid_model: s(&row["grid"], "model"),+ grid_base_url: s(&row["grid"], "baseUrl"),+ grid_state: s(&row["grid"], "state"),+ grid_note: grid_note(&row["grid"]["note"]),}}@@ -511,7 +538,7 @@ impl Fleet {// ── the roster between runs ────────────────────────────────────────────────────fn cache_path() -> std::path::PathBuf {- std::path::PathBuf::from(std::env::var("HOME").unwrap_or_default()).join(".harness").join("tui").join("fleet.json")+ crate::app::state_dir().join("fleet.json")}impl Fleet {diff --git a/tui/src/format.rs b/tui/src/format.rsindex 031c242fb..57fbdcb5f 100644--- a/tui/src/format.rs+++ b/tui/src/format.rs@@ -1007,7 +1007,7 @@ pub fn agent_mark(state: crate::fleet::State, tick: u64) -> String {/// One remaining figure per subscription, across every machine with a reading. The local/// reading wins when machines share an account; unnamed accounts cannot safely be merged./// Machine labels distinguish additional subscriptions without repeating them for shared ones.-fn quota_remaining<'a>(readings: impl Iterator<Item = (&'a str, &'a crate::fleet::Usage)>, local: &str, machine_name: impl Fn(&str) -> String, marked: bool) -> String {+fn quota_remaining<'a>(readings: impl Iterator<Item = (&'a str, &'a crate::fleet::Usage)>, local: &str, machine_name: impl Fn(&str) -> String, marked: bool, icons: bool) -> String {let mut readings: Vec<_> = readings.filter(|(_, u)| !u.windows.is_empty()).collect();readings.sort_by(|(am, a), (bm, b)| (&a.provider, *am != local, machine_name(am), am).cmp(&(&b.provider, *bm != local, machine_name(bm), bm)));let mut seen = std::collections::HashSet::new();@@ -1017,7 +1017,7 @@ fn quota_remaining<'a>(readings: impl Iterator<Item = (&'a str, &'a crate::fleetlet remaining = 100.0 - used;// A little allowance remains: don't round it to a misleading exhausted 0%.let number = if remaining > 0.0 && remaining < 1.0 { "<1%".into() } else { format!("{remaining:.0}%") };- let mut label = quota_provider(&u.provider);+ let mut label = if icons { quota_icon(&u.provider) } else { quota_provider(&u.provider) };if *machine != local && readings.iter().filter(|(_, other)| other.provider == u.provider).count() > 1 {label.push('@'); label.push_str(&clip_middle(&machine_name(machine), 12));}@@ -1027,6 +1027,15 @@ fn quota_remaining<'a>(readings: impl Iterator<Item = (&'a str, &'a crate::fleet}).collect::<Vec<_>>().join(" ")}+/// A subscription's provider as its engine's icon, in the engine's colour (`✳` Claude, `◎`+/// Codex/OpenAI…); a provider with no engine of its own, its name.+fn quota_icon(provider: &str) -> String {+ let engine = match provider.to_ascii_lowercase().as_str() { "anthropic" | "claude" => "claude", "openai" | "chatgpt" | "codex" => "codex", _ => return quota_provider(provider) };+ let (mark, colour) = crate::theme::engine_mark(engine);+ if crate::theme::no_color() { return mark.to_string() }+ format!("#[fg={}]{mark}#[fg=default]", crate::tmuxconf::colour_name(crate::theme::paint(colour)))+}+fn quota_provider(provider: &str) -> String {let mut chars = provider.chars();chars.next().map(|c| c.to_uppercase().collect::<String>() + chars.as_str()).unwrap_or_default()@@ -1097,7 +1106,7 @@ fn pane_heading_columns(app: &App, window: usize, pane: u64) -> usize {if app.options.pane_look() {let Some(tab) = app.tabs.get(window) else { return 0 };let Some(tile) = tab_rect(app, window, pane) else { return 0 };- crate::pane_frame::frame(tile, app.window_area(tab), app.pane_status(tab)).title+ crate::pane_frame::frame(tile, app.window_area(tab), app.box_inner(tab), app.pane_status(tab)).title.map(|r| r.width.saturating_sub(2) as usize).unwrap_or(0)} else {content_rect(app, window, pane).map(|r| r.width.saturating_sub(4) as usize).unwrap_or(0)@@ -1108,8 +1117,20 @@ fn pane_heading(app: &App, window: usize, pane: u64) -> String {let watcher = app.panes.get(&pane).and_then(|p| match &p.phase {crate::pane::Phase::Watching(who) => Some(who.as_str()), _ => None,});- compact_pane_heading(&pane_title(app, window, pane), app.pane_state(pane), watcher,- pane_heading_columns(app, window, pane).saturating_sub(1), app.tick)+ let columns = pane_heading_columns(app, window, pane).saturating_sub(1);+ let title = pane_title(app, window, pane);+ // ── models: what its model says when it will not answer now (Starting up…, offline, not+ // served), after the name — the name keeps a dozen columns, the note is cut to what is left ──+ if let Some(note) = app.panes.get(&pane).and_then(|p| crate::models::pane_note(app, &p.machine_id, &p.agent_id)) {+ use unicode_width::UnicodeWidthStr;+ let keep = title.width().min(12) + 4;+ if columns > keep + 12 {+ let note = clip_middle(¬e, (columns - keep - 1).min(note.width()));+ let head = compact_pane_heading(&title, app.pane_state(pane), watcher, columns - note.width() - 1, app.tick);+ return format!("{head} #[fg=yellow]{note}#[fg=default]");+ }+ }+ compact_pane_heading(&title, app.pane_state(pane), watcher, columns, app.tick)}/// Keep state visible after the name. Watcher detail yields before the pane's identity;@@ -1366,7 +1387,11 @@ fn table(app: &App, name: &str, window: usize, pane_id: Option<u64>) -> Option<V// Compact remaining allowance for every subscription, not just the one in danger."usage_remaining" | "usage_remaining_mark" => quota_remaining(app.usage.iter().flat_map(|(machine, readings)| readings.iter().map(move |u| (machine.as_str(), u))),- &app.fleet.local_id, |id| app.fleet.machine_name(id), name == "usage_remaining_mark"),+ &app.fleet.local_id, |id| app.fleet.machine_name(id), name == "usage_remaining_mark", false),+ // The same, each subscription by its engine's icon (`✳ 43% ◎ 80%`): the side bar's.+ "usage_remaining_icons" => quota_remaining(+ app.usage.iter().flat_map(|(machine, readings)| readings.iter().map(move |u| (machine.as_str(), u))),+ &app.fleet.local_id, |id| app.fleet.machine_name(id), true, true),"usage_high" | "usage_high_mark" => quota_warning(app.usage.values().flatten(), name == "usage_high_mark"),"fleet_tokens" => { let t: u64 = app.fleet.agents.values().map(|a| a.tokens).sum(); if t > 0 { crate::fleet::compact(t) } else { String::new() } }"pane_branch" => agent.map(|a| a.branch.clone()).unwrap_or_default(),@@ -1701,8 +1726,8 @@ mod tests {let other = quota("other", Some("c"), &[30.0]);let empty = quota("missing", None, &[]);let readings = [("local", &other), ("local", &codex), ("local", &empty), ("local", &claude)];- assert_eq!(super::quota_remaining(readings.into_iter(), "local", str::to_string, false), "Claude 58% Codex 89% Other 70%");- assert_eq!(super::quota_remaining(std::iter::empty(), "local", str::to_string, false), "");+ assert_eq!(super::quota_remaining(readings.into_iter(), "local", str::to_string, false, false), "Claude 58% Codex 89% Other 70%");+ assert_eq!(super::quota_remaining(std::iter::empty(), "local", str::to_string, false, false), "");// The existing per-window format continues reporting used quota for custom configs.assert_eq!(claude.line(), "claude limit 42% limit 18%");}@@ -1715,8 +1740,8 @@ mod tests {let unknown = quota("codex", None, &[11.0]);let readings = [("studio", &distinct), ("shared", &shared), ("local", &local), ("studio", &unknown), ("local", &unknown)];let expected = "Claude 58% Claude@studio 20% Codex 89% Codex@studio 89%";- assert_eq!(super::quota_remaining(readings.into_iter(), "local", str::to_string, false), expected);- assert_eq!(super::quota_remaining(readings.into_iter().rev(), "local", str::to_string, false), expected);+ assert_eq!(super::quota_remaining(readings.into_iter(), "local", str::to_string, false, false), expected);+ assert_eq!(super::quota_remaining(readings.into_iter().rev(), "local", str::to_string, false, false), expected);}#[test]@@ -1724,8 +1749,8 @@ mod tests {for (used, number) in [(0.0, "100%"), (79.0, "21%"), (80.0, "20%"), (99.7, "<1%"), (100.0, "0%"), (120.0, "0%")] {let u = quota("claude", None, &[used]);let plain = format!("Claude {number}");- assert_eq!(super::quota_remaining(std::iter::once(("local", &u)), "local", str::to_string, false), plain);- let styled = super::quota_remaining(std::iter::once(("local", &u)), "local", str::to_string, true);+ assert_eq!(super::quota_remaining(std::iter::once(("local", &u)), "local", str::to_string, false, false), plain);+ let styled = super::quota_remaining(std::iter::once(("local", &u)), "local", str::to_string, true, false);if used < 80.0 || crate::theme::no_color() { assert_eq!(styled, plain) }else { assert!(styled.starts_with("Claude #[fg=")); assert!(styled.ends_with(&format!("]{number}#[fg=default]"))); }assert!(!styled.contains("reverse") && !styled.contains("bg="));diff --git a/tui/src/input.rs b/tui/src/input.rsindex 4896d3a37..fd9a227ae 100644--- a/tui/src/input.rs+++ b/tui/src/input.rs@@ -257,6 +257,9 @@ fn on_mouse(app: &mut App, mouse: MouseEvent) {if matches!(mouse.kind, MouseEventKind::Moved) && !app.wants_motion() { return }// hn's lists and prompts keep the mouse as they have it; copy mode and a menu are tmux's.if app.modal.is_some() && !matches!(app.modal, Some(Modal::Copy { .. }) | Some(Modal::Menu(_))) { return modal_mouse(app, mouse) }+ // ── status bar ──+ // (The bar down a side and the tabs over the panes: theirs, unless a menu is open.)+ if !matches!(app.modal, Some(Modal::Menu(_))) && crate::bar::mouse(app, &mouse) { return }crate::mouse::on_event(app, mouse);}@@ -276,11 +279,11 @@ fn modal_mouse(app: &mut App, mouse: MouseEvent) {match mouse.kind {MouseEventKind::ScrollUp | MouseEventKind::ScrollDown => {let up = matches!(mouse.kind, MouseEventKind::ScrollUp);- if let Some(Modal::Picker { picker, .. }) = &mut app.modal {+ if let Some(Modal::Picker { picker, kind }) = &mut app.modal {if in_preview { picker.preview_by(if up { -1 } else { 1 }) }else if inside(list) {if shift && multi { picker.toggle_mark(); }- let r: i64 = if theme::fzf().reverse { -1 } else { 1 };+ let r: i64 = if crate::settings::top_down(kind) { -1 } else { 1 };picker.move_by(if up { r } else { -r })}}@@ -370,8 +373,8 @@ pub fn scroll_by(app: &mut App, lines: i32) {let up = lines > 0;let n = lines.unsigned_abs() as usize;match &mut app.modal {- Some(Modal::Picker { picker, .. }) => {- let r: i64 = if theme::fzf().reverse { -1 } else { 1 };+ Some(Modal::Picker { picker, kind }) => {+ let r: i64 = if crate::settings::top_down(kind) { -1 } else { 1 };picker.move_by(if up { r } else { -r } * n as i64);return;}@@ -575,7 +578,7 @@ fn fill_rows(app: &App, kind: &PickerKind, picker: &mut Picker) {// Its spinner turns while what it lists is still coming in, as fzf's does while it reads.let busy = match kind {PickerKind::Store => is_loading(&format!("dsh {}", app.fleet.local_id)),- PickerKind::Models => is_loading(&format!("grid {}", modal::models_machine(app))) || focused_agent(app).is_some_and(|(m, a)| is_loading(&format!("models {m} {a}"))),+ PickerKind::Models => crate::models::loading(app) || focused_agent(app).is_some_and(|(m, a)| is_loading(&format!("models {m} {a}"))),_ => false,};picker.busy = busy.then(|| "loading".to_string());@@ -625,17 +628,23 @@ fn fill_rows(app: &App, kind: &PickerKind, picker: &mut Picker) {picker.hints = vec![("enter", "its harnesses"), ("C-t", "a session of them"), ("M-n", "new harness there")];picker.empty = "No projects yet.".into();}+ // ── models: the Models view's sections (models.rs), then the engine's own models ──PickerKind::Models => {- let mut rows = modal::model_rows(app);- rows.extend(modal::local_model_rows(app));+ let mut rows = crate::models::rows(app, crate::models::searched(picker));+ let in_use = crate::models::in_use_row(&rows);+ rows.extend(modal::model_rows(app));+ // (Rebuilt in its sections each time — a model moves to where its state puts it, a+ // reply come late lands in its section — the cursor staying on its row.)+ picker.rows.clear();picker.set_rows(rows);- // Start on the model it runs, so ↑/↓ are "a little more / less" from where it is.+ // Start on the model it runs — the grid model it is on, else its engine's model — so+ // ↑/↓ are "a little more / less" from where it is.if picker.query.trim() == ":" && picker.selected_id.is_none() {- if let Some(current) = focused_agent(app).and_then(|(m, a)| app.fleet.agent(&m, &a).map(|x| x.model.clone())) {+ if let Some(current) = in_use.or_else(|| focused_agent(app).and_then(|(m, a)| app.fleet.agent(&m, &a).map(|x| x.model.clone()))) {if let Some(at) = picker.visible.iter().position(|(i, _)| picker.rows[*i].id == current) { picker.cursor = at; picker.selected_id = Some(current) }}}- picker.hints = vec![("enter", "use · start · get"), ("C-x", "stop a local model")];+ picker.hints = vec![("enter", "use · get"), ("C-s", "stop a local model")];picker.empty = if app.focused().is_none() { "Focus a harness to switch its model.".into() } else { "Loading its models…".into() };picker.status = app.focused().and_then(|f| app.panes.get(&f)).and_then(|p| app.fleet.agent(&p.machine_id, &p.agent_id)).map(|a| a.name.clone()).unwrap_or_default();}@@ -648,12 +657,28 @@ fn fill_rows(app: &App, kind: &PickerKind, picker: &mut Picker) {picker.empty = "Nobody is waiting on you.".into();}PickerKind::Machines => {+ let was = picker.current_id();picker.set_rows(modal::machine_rows(app));+ // Come to from another list (`@`): the cursor on the machine you are on — the focused+ // pane's, else this one — with its preview beside it. A refresh leaves it where it is.+ if !was.is_some_and(|w| app.fleet.machines.iter().any(|m| m.id == w)) {+ let here = app.focused().and_then(|p| app.panes.get(&p)).map(|p| p.machine_id.clone()).filter(|m| !m.is_empty()).unwrap_or_else(|| app.fleet.local_id.clone());+ picker.select(&here);+ }let up = app.fleet.machines.iter().filter(|m| m.usable()).count();picker.status = format!("{up}/{} connected", app.fleet.machines.len());picker.hints = vec![("enter", "its harnesses"), ("M-n", "new there"), ("C-t", "terminal there"), ("M-l", "link")];}PickerKind::Layout => { picker.set_rows(modal::layout_rows()); picker.hints = vec![("enter", "apply")] }+ PickerKind::Theme => {+ picker.keep_order = true;+ picker.theme_in = None;+ picker.set_rows(modal::theme_sections(app));+ picker.hints = vec![("→/enter", "open"), ("enter", "set"), ("esc", "done")];+ }+ // (Typed into, it ranks by match, best first, as fzf does; empty, it keeps its groups. A+ // query matches a command's name and keywords, not the description shown beside it.)+ PickerKind::Commands => { picker.live = true; picker.set_rows(modal::command_rows_for(app, !picker.query.is_empty())); picker.hints = vec![("enter", "run")] }PickerKind::Help => { picker.set_rows(modal::mode_rows(app)); picker.hints = vec![("enter", "go")] }PickerKind::Store => {let catalog = app.dsh.get(&app.fleet.local_id).cloned().unwrap_or_default();@@ -710,6 +735,8 @@ fn fill_rows(app: &App, kind: &PickerKind, picker: &mut Picker) {picker.empty = "no buffers".into();picker.hints = vec![("enter", "paste")];}+ // ── machines & devices ──+ PickerKind::Devices(view) => crate::devices::fill(app, *view, picker),}}@@ -771,19 +798,9 @@ fn prepare(app: &mut App, kind: &PickerKind) {}}-fn load_local_models(app: &mut App) {- let machine = modal::models_machine(app);- let Some(link) = app.link(&machine) else { return };- let mark = loading(format!("grid {machine}"), true);- app.spawn(async move { link.rpc("grid_fleet_models_list", json!({}), Duration::from_secs(30)).await }, move |app, reply| {- loading(mark, false);- if let Ok(reply) = reply { app.local_models.insert(machine, reply.get("models").and_then(|v| v.as_array()).cloned().unwrap_or_default()); }- refill(app);- });-}-fn load_models(app: &mut App) {- load_local_models(app);+ // ── models: this computer's models, the grids and the saved APIs (models.rs) ──+ crate::models::open(app);let Some((machine, agent)) = focused_agent(app) else { return };let Some(link) = app.link(&machine) else { return };let mark = loading(format!("models {machine} {agent}"), true);@@ -819,6 +836,8 @@ pub fn run(app: &mut App, command: &str) {"machines" => launch(app, "@", Filter::All),"help" => launch(app, "?", Filter::All),"layout" => picker(app, PickerKind::Layout, "layout", ""),+ "theme" | "appearance" => picker(app, PickerKind::Theme, "Appearance", "Search appearance"),+ "commands" => picker(app, PickerKind::Commands, "Commands", "Type a command — appearance, new, layout, models…"),"store" => launch(app, "*", Filter::All),"new" => crate::new_harness::open(app, None, None),"terminal" => {@@ -919,6 +938,8 @@ pub fn run(app: &mut App, command: &str) {"choose-buffer" => picker(app, PickerKind::Buffers, "buffers", ""),"quit" => app.quit = true,c if c.starts_with("tab-") => { if let Some(n) = c[4..].parse::<usize>().ok().and_then(|n| n.checked_sub(1)) { app.select_tab(n) } }+ // ── machines & devices ──+ "connect-machine" | "add-phone" | "devices" => { if let Some(view) = crate::devices::View::of(command) { crate::devices::open(app, view) } }_ => {}}}@@ -1033,7 +1054,8 @@ pub fn refill(app: &mut App) {if !matches!(app.modal, Some(Modal::Picker { .. })) { return }if let Some(Modal::Picker { kind, mut picker }) = app.modal.take() {let was = picker.current_id();- if !matches!(kind, PickerKind::Route { .. } | PickerKind::Palette | PickerKind::Help | PickerKind::Layout) { fill(app, &kind, &mut picker) }+ // (The settings panel changes only by your keys: a refresh would step out of its section.)+ if !matches!(kind, PickerKind::Route { .. } | PickerKind::Palette | PickerKind::Help | PickerKind::Layout | PickerKind::Theme | PickerKind::Commands) { fill(app, &kind, &mut picker) }// (The cursor put on another row by the list, not by a key: a moment before it answers.)if was.is_some() && picker.current_id() != was { picker.landed = Some(Instant::now()) }app.modal = Some(Modal::Picker { kind, picker });@@ -1345,7 +1367,7 @@ fn creation_finished(app: &mut App, machine: String, session: u32, opts: NewOpts}}-fn modal_key(app: &mut App, key: KeyEvent) {+pub(crate) fn modal_key(app: &mut App, key: KeyEvent) {let Some(modal) = app.modal.take() else { return };match modal {Modal::NewHarness(form) => crate::new_harness::key(app, form, key),@@ -1919,7 +1941,9 @@ fn schedule_said(app: &mut App, kind: &PickerKind, picker: &Picker) {/// fzf's keys: ↑ C-k C-p away from the prompt, ↓ C-j C-n toward it (the list reads bottom-up);/// Tab marks; C-t/C-x/C-v open in a new window / below / beside (fzf.vim); C-/ the preview.-fn picker_key(app: &mut App, key: KeyEvent, kind: PickerKind, mut picker: Picker) {+fn picker_key(app: &mut App, key: KeyEvent, kind: PickerKind, picker: Picker) {+ // ── machines & devices ── (a line typed or a y/n answered in the panel; Esc/← a level back)+ let (kind, mut picker) = match crate::devices::key(app, kind, picker, key) { Ok(()) => return, Err(back) => back };// A row a key goes to is one you chose to look at (the list moving it there is not).let was = picker.current_id();let key_moves = matches!(key.code, KeyCode::Up | KeyCode::Down | KeyCode::PageUp | KeyCode::PageDown | KeyCode::Tab | KeyCode::BackTab)@@ -1940,7 +1964,7 @@ fn picker_key(app: &mut App, key: KeyEvent, kind: PickerKind, mut picker: Picker}}let multi = picker.multi_override.map(|n| n > 0).unwrap_or((matches!(kind, PickerKind::Open { .. } | PickerKind::Inbox) || theme::fzf_opts().multi) && crate::picker::scope_of(&picker.query).is_none());- let up = if theme::fzf().reverse { -1 } else { 1 };+ let up = if crate::settings::top_down(&kind) { -1 } else { 1 };if let Some(actions) = theme::fzf_opts().binds.iter().rev().find(|(key, _)| key == event).map(|(_, actions)| actions.clone()) {let previous_query = picker.query.clone();let previous_search = picker.search.clone();@@ -1975,7 +1999,7 @@ fn picker_key(app: &mut App, key: KeyEvent, kind: PickerKind, mut picker: Pickerlet multi = picker.multi_override.map(|n| n > 0).unwrap_or(multi);// unbind / toggle-bind: that key does nothing in this list now.if picker.unbound.contains(&fzf_key_name(&key)) { app.modal = Some(Modal::Picker { kind, picker }); return }- let up: i64 = if theme::fzf().reverse { -1 } else { 1 };+ let up: i64 = if crate::settings::top_down(&kind) { -1 } else { 1 };// FZF_DEFAULT_OPTS --bind: your key:action pairs come first (the last bind for a key wins,// as in fzf). A key bound only to what hn does not run (execute, become, reload …) keeps this// list's own meaning of it; one with an action hn runs never falls back to it.@@ -1988,6 +2012,30 @@ fn picker_key(app: &mut App, key: KeyEvent, kind: PickerKind, mut picker: PickerEnd::Stay => {}}} else {+ // The look/theme picker: right on a section opens it, left/Esc steps out one level (a plain+ // arrow with an empty query — with a query they edit the query, as fzf's do).+ if matches!(kind, PickerKind::Theme) {+ let no_mod = !ctrl && !alt && !shift;+ if no_mod && key.code == KeyCode::Right && picker.query.is_empty() {+ if let Some(sec) = picker.current_id().and_then(|id| id.strip_prefix("section:").map(|s| s.to_string())) {+ crate::settings::open_section(app, &mut picker, &sec);+ app.modal = Some(Modal::Picker { kind, picker });+ return;+ }+ }+ let back = (no_mod && key.code == KeyCode::Left && picker.query.is_empty()) || key.code == KeyCode::Esc;+ if back && picker.theme_in.is_some() {+ crate::settings::close_section(app, &mut picker);+ app.modal = Some(Modal::Picker { kind, picker });+ return;+ }+ // Opened from the command list: Esc (or ← on the sections) is a step back to it.+ if back && picker.from_commands {+ crate::settings::back_to_commands(app, &mut picker);+ app.modal = Some(Modal::Picker { kind: PickerKind::Commands, picker });+ return;+ }+ }match key.code {KeyCode::Esc => { SPLIT.with(|s| s.set(None)); return }KeyCode::Char('c' | 'g' | 'q') if ctrl => { SPLIT.with(|s| s.set(None)); return }@@ -2112,6 +2160,15 @@ fn picker_key(app: &mut App, key: KeyEvent, kind: PickerKind, mut picker: Pickerlet (next, changed) = remode(app, kind, &mut picker);kind = next;if changed { prepare(app, &kind); fill(app, &kind, &mut picker) }+ // ── models: a search lists what "More models" and a folded API hide ──+ else if matches!(kind, PickerKind::Models) { fill(app, &kind, &mut picker) }+ // The command list: tmux's commands join it once you search, and leave when you stop.+ if matches!(kind, PickerKind::Commands) && before.is_empty() != picker.query.is_empty() {+ picker.rows.clear();+ picker.set_rows(modal::command_rows_for(app, !picker.query.is_empty()));+ }+ // The panel's lists: what you type puts the cursor on the best match.+ if crate::settings::is_panel(&kind) { picker.to_top() }// --bind change:…, fzf's event for a query that changed (change:first puts the cursor back// on the best match).if let Some(actions) = theme::fzf_opts().binds.iter().rev().find(|(k, _)| k == "change").map(|(_, a)| a.clone()) {@@ -2493,7 +2550,7 @@ fn choose(app: &mut App, kind: PickerKind, mut picker: Picker, choice: Choice) {let keep = |app: &mut App, kind: PickerKind, picker: Picker| app.modal = Some(Modal::Picker { kind, picker });// A list of keys, buffers, commands or text: only Enter picks — the harness lists' keys (C-v// beside, C-x below, M-p pause …) do nothing here, as keys fzf has no action for.- if choice != Choice::Enter && matches!(kind, PickerKind::Keys | PickerKind::Buffers | PickerKind::Palette | PickerKind::Help | PickerKind::Messages | PickerKind::Output { .. }) { return keep(app, kind, picker) }+ if choice != Choice::Enter && matches!(kind, PickerKind::Keys | PickerKind::Buffers | PickerKind::Palette | PickerKind::Commands | PickerKind::Help | PickerKind::Messages | PickerKind::Output { .. }) { return keep(app, kind, picker) }match kind.clone() {PickerKind::Open { .. } if id.as_deref().map(|i| i.starts_with("session:")).unwrap_or(false) => {let sid = id.as_deref().and_then(|i| i.strip_prefix("session:")).and_then(|n| n.parse().ok()).unwrap_or(app.session_id);@@ -2601,33 +2658,16 @@ fn choose(app: &mut App, kind: PickerKind, mut picker: Picker, choice: Choice) {fill(app, &kind, &mut next);app.modal = Some(Modal::Picker { kind, picker: next });}- PickerKind::Models if id.as_deref().map(|i| i.starts_with("grid:")).unwrap_or(false) => {- let id = id.unwrap();- let Some((machine, model)) = id.trim_start_matches("grid:").split_once('\t').map(|(m, x)| (m.to_string(), x.to_string())) else { return keep(app, kind, picker) };- let state = app.local_models.get(&machine).and_then(|l| l.iter().find(|m| m.get("id").and_then(|v| v.as_str()) == Some(model.as_str()))).and_then(|m| m.get("state").and_then(|v| v.as_str())).unwrap_or("available").to_string();- let running = state == "running" || state == "serving";- let action = match (choice, running, state.as_str()) {- (Choice::SplitDown, true, _) => "grid_fleet_model_stop",- (Choice::Enter, false, "downloaded") => "grid_fleet_model_start",- (Choice::Enter, false, _) => {- // A download is gigabytes: the first Enter asks, the second one means it.- if picker.armed.as_deref() != Some(id.as_str()) { picker.armed = Some(id.clone()); picker.say("Enter again to download it"); return keep(app, kind, picker) }- "grid_fleet_model_download"- }- (_, true, _) => { picker.say("Running — ^S stops it"); return keep(app, kind, picker) }- _ => return keep(app, kind, picker),- };- picker.armed = None;- let Some(link) = app.link(&machine) else { return keep(app, kind, picker) };- let label = picker.current().map(|r| r.label.clone()).unwrap_or_default();- picker.say(match action { "grid_fleet_model_stop" => format!("Stopping {label}…"), "grid_fleet_model_start" => format!("Starting {label}…"), _ => format!("Downloading {label}…") });- app.spawn(async move { link.rpc(action, json!({ "modelId": model }), Duration::from_secs(600)).await }, move |app, reply| {- match reply { Ok(_) => app.say(format!("{label}: done"), theme::ONLINE), Err(e) => app.say(format!("{label}: {e}"), theme::DANGER) }- load_local_models(app);- });+ // ── models: Enter uses a row of the Models view, C-s stops a local model (models.rs) ──+ PickerKind::Models if id.as_deref().is_some_and(crate::models::is_row) => {+ if !matches!(choice, Choice::Enter | Choice::SplitDown) { return keep(app, kind, picker) }+ crate::models::choose(app, &mut picker, id.as_deref().unwrap_or(""), choice == Choice::SplitDown);+ fill(app, &kind, &mut picker);return keep(app, kind, picker);}PickerKind::Models => {+ // (The engine's own models: only Enter switches.)+ if choice != Choice::Enter { return keep(app, kind, picker) }let Some(model) = id else { return keep(app, kind, picker) };let Some((machine, agent)) = focused_agent(app) else { return };let Some(link) = app.link(&machine) else { return };@@ -2644,15 +2684,51 @@ fn choose(app: &mut App, kind: PickerKind, mut picker: Picker, choice: Choice) {PickerKind::Layout => {if let Some(index) = id.and_then(|i| i.parse::<usize>().ok()) { app.apply_preset(Preset::ALL[index].0) }}+ PickerKind::Theme => {+ if choice == Choice::Enter {+ let under = picker.theme_in.clone();+ if let Some(id) = id {+ if let Some(section) = under {+ // Inside a section: Enter sets that option (and the ● moves to it).+ if let Some((knob, value)) = id.split_once(':') {+ let msg = app.set_look(knob, value);+ picker.say(msg);+ picker.set_rows(modal::theme_options(app, §ion));+ crate::settings::cursor_to(&mut picker, &id);+ }+ } else if let Some(sec) = id.strip_prefix("section:") {+ // The section list: Enter opens the section's options.+ crate::settings::open_section(app, &mut picker, sec);+ }+ }+ }+ return keep(app, kind, picker);+ }+ PickerKind::Commands => {+ let Some(id) = id else { return keep(app, kind, picker) };+ if let Some(name) = id.strip_prefix("tmux:") {+ // A command that needs words goes to the prompt with its name typed; the rest run.+ if modal::NEEDS_ARGS.contains(&name) { app.modal = Some(Modal::Prompt(Prompt::status(PromptKind::Command { template: None, more: Vec::new(), answers: Vec::new(), one: false, digits: false, incremental: false, ptype: 0, last: String::new() }, ":", &format!("{name} ")))) }+ else { commands::execute(app, name) }+ } else if id == "cmd:theme" {+ // Settings open in this same panel, where the command list was.+ crate::settings::into_settings(app, &mut picker);+ return keep(app, PickerKind::Theme, picker);+ } else if let Some(view) = id.strip_prefix("cmd:").and_then(crate::devices::View::of) {+ // ── machines & devices ── (in this same panel too; Esc comes back here)+ return crate::devices::from_commands(app, picker, view);+ } else if let Some(cmd) = id.strip_prefix("cmd:") {+ run(app, cmd)+ }+ }PickerKind::Machines => {let Some(machine) = id else { return keep(app, kind, picker) };match choice {Choice::New => { if app.link(&machine).is_some() { new_what(app, machine) } }Choice::Tab => create(app, machine, What { engine: "terminal".into(), dsh: None, label: "Terminal".into() }, None, None),- Choice::Link => {- let name = app.fleet.machine_name(&machine);- prompt(app, PromptKind::LinkPassword { machine }, &format!("Link {name}"), "Its remote password (set there with `harness remote-password set`)", "", "", true)- }+ // M-l: Connect a machine in the panel, its password asked for (hidden), the CLI's+ // stages shown as they come.+ Choice::Link => crate::devices::connect_to(app, machine),_ => {let kind = PickerKind::Open { filter: Filter::All, machine: Some(machine), project: None };let (title, placeholder) = modal::launcher_title(app, &kind);@@ -2682,6 +2758,8 @@ fn choose(app: &mut App, kind: PickerKind, mut picker: Picker, choice: Choice) {app.say(format!("Sent to {name}"), theme::ONLINE);}}+ // ── machines & devices ──+ PickerKind::Devices(view) => crate::devices::choose(app, view, picker, choice == Choice::Enter),}}@@ -2791,35 +2869,6 @@ fn submit_prompt(app: &mut App, p: Prompt) {for (machine, agent) in &targets { if let Some(link) = app.link(machine) { link.send("message", json!({ "agentId": agent, "content": value })); } }app.say(format!("Sent to {} harness{}", targets.len(), if targets.len() == 1 { "" } else { "es" }), theme::ONLINE);}- PromptKind::LinkPassword { machine } => {- if value.is_empty() { return }- // The CLI that started us (node + its script), else `harness` on PATH.- let exe = std::env::var("HARNESS_CLI").unwrap_or_else(|_| "harness".into());- // Its loader flags and script (tsx in a dev checkout), as the launcher passed them.- let script: Vec<String> = std::env::var("HARNESS_CLI_ARGS").ok().and_then(|a| serde_json::from_str(&a).ok()).unwrap_or_default();- let id = machine.clone();- app.say("Linking…", theme::SOFT);- app.spawn(async move {- let run = tokio::process::Command::new(exe).args(script.iter()).args(["link", "connect", &id, "--stdin", "--json"]).stdin(std::process::Stdio::piped()).stdout(std::process::Stdio::piped()).stderr(std::process::Stdio::piped()).spawn();- match run {- Ok(mut child) => {- use tokio::io::AsyncWriteExt;- if let Some(mut stdin) = child.stdin.take() { let _ = stdin.write_all(format!("{value}\n").as_bytes()).await; }- child.wait_with_output().await.map(|o| (o.status.success(), String::from_utf8_lossy(&o.stdout).to_string() + &String::from_utf8_lossy(&o.stderr))).unwrap_or((false, "failed".into()))- }- Err(e) => (false, e.to_string()),- }- }, move |app, (ok, out)| {- if ok { app.say("Linked", theme::ONLINE); if let Some(m) = app.fleet.machine_mut(&machine) { m.reach = crate::fleet::Reach::Unknown } app.connect(&machine) }- else {- // `--json` answers with {ok, message}; anything else, its first error-looking line.- let said = out.lines().filter_map(|l| serde_json::from_str::<serde_json::Value>(l).ok()).find_map(|v| v.get("message").or_else(|| v.get("error")).and_then(|m| m.as_str()).map(str::to_string))- .or_else(|| out.lines().map(str::trim).find(|l| l.contains('✗') || l.to_lowercase().contains("error")).map(str::to_string))- .unwrap_or_else(|| "the link was refused".into());- app.say(format!("Could not link: {said}"), theme::DANGER)- }- });- }}}@@ -2835,7 +2884,9 @@ pub fn is_command(id: &str) -> bool {| "broadcast" | "clone" | "restart" | "pause" | "take" | "rename" | "tab" | "rename-tab" | "close-tab" | "next-tab" | "prev-tab"| "split-right" | "split-down" | "close-pane" | "zoom" | "equalize" | "pane-tab" | "copy-mode" | "find" | "tab-left" | "tab-right"| "last-tab" | "next-waiting" | "prev-waiting" | "resume-focused" | "last-harness" | "tree" | "info" | "messages" | "keys"- | "choose-buffer" | "quit")+ | "theme" | "appearance" | "commands" | "choose-buffer" | "quit"+ // ── machines & devices ──+ | "connect-machine" | "add-phone" | "devices")}@@ -3139,4 +3190,67 @@ mod tests {assert_eq!(forward_word_vi(&c, c.len(), ws), c.len());assert_eq!(end_word(&c, c.len(), ws), c.len());}++ /// `theme` from the command prompt (`: theme`) or the launcher must open the theme picker —+ /// the same dispatch `input::run` executes. Guards the `is_command`/`picker` wiring end to end.+ #[test]+ fn theme_command_opens_the_theme_picker() {+ let (sink, _) = tokio::sync::mpsc::unbounded_channel();+ let mut app = App::new(19789, sink, (80, 24));+ app.fleet.local_id = "local".into();+ app.fleet.machines.push(crate::fleet::Machine {+ id: "local".into(), name: "studio".into(), local: true, status: "online".into(), reach: crate::fleet::Reach::Ready,+ });+ app.homes.insert("local".into(), "/home/dev".into());++ // is_command("theme") is true, so the command-prompt routes it here.+ assert!(is_command("theme"));+ run(&mut app, "theme");++ let modal = app.modal.as_ref().expect("`theme` should open a picker modal");+ let Modal::Picker { kind, picker } = modal else {+ panic!("`theme` opened a non-picker modal");+ };+ assert!(matches!(kind, PickerKind::Theme), "opened {:?}", std::mem::discriminant(kind));++ // Level one: the section list, not the whole flat gallery — sections only, no groups.+ assert!(picker.theme_in.is_none(), "opens on the sections");+ assert_eq!(picker.rows.first().map(|r| r.id.as_str()), Some("section:status"));+ assert!(picker.rows.iter().all(|r| r.id.starts_with("section:")), "level one lists sections only");++ // Each section opens onto its options; the theme section lists every bundled theme.+ use crate::terminal_themes::TERMINAL_THEMES;+ let theme_opts = crate::modal::theme_options(&app, "theme");+ assert_eq!(theme_opts.len(), TERMINAL_THEMES.len() + 1, "the terminal's own, then every bundled theme");+ let first_id = format!("theme:{}", TERMINAL_THEMES[0].name);+ assert_eq!(theme_opts.get(1).map(|r| r.id.as_str()), Some(first_id.as_str()));+ for r in &theme_opts { assert!(!r.lead.is_empty(), "mark missing on {}", r.id); }+ }++ /// Enter opens a section (level one → level two), and the picker stays open on that section's+ /// options. Guards the drill-in navigation (the option apply is `set_look`, tested elsewhere).+ #[test]+ fn theme_enter_opens_the_section() {+ let (sink, _) = tokio::sync::mpsc::unbounded_channel();+ let mut app = App::new(19789, sink, (80, 24));+ app.fleet.local_id = "local".into();+ app.fleet.machines.push(crate::fleet::Machine {+ id: "local".into(), name: "studio".into(), local: true, status: "online".into(), reach: crate::fleet::Reach::Ready,+ });+ app.homes.insert("local".into(), "/home/dev".into());++ picker(&mut app, PickerKind::Theme, "look & theme", "esc done");+ {+ let Modal::Picker { kind, picker } = app.modal.take().unwrap() else { panic!() };+ assert!(matches!(kind, PickerKind::Theme));+ assert!(picker.theme_in.is_none(), "opens on the sections");+ assert_eq!(picker.current_id().as_deref(), Some("section:status"));+ choose(&mut app, kind, picker, Choice::Enter);+ }+ let Modal::Picker { kind, picker } = app.modal.as_ref().unwrap() else { panic!() };+ assert!(matches!(kind, PickerKind::Theme));+ assert_eq!(picker.theme_in.as_deref(), Some("status"), "Enter opened the section");+ assert!(picker.rows.iter().all(|r| r.id.starts_with("border_status:")), "the section's options show");+ assert!(picker.rows.iter().any(|r| r.lead.iter().any(|s| s.content.as_ref() == "✓ ")), "the current option is marked");+ }}diff --git a/tui/src/keys.rs b/tui/src/keys.rsindex a3bf3cdfd..857145bb7 100644--- a/tui/src/keys.rs+++ b/tui/src/keys.rs@@ -151,6 +151,8 @@ impl Keymap {// ── keys tmux leaves unbound: the Harness ones ──b(ch('C'), "customize-mode -Z", false, "Customize options");// Harness's own, on keys tmux leaves unbound.+ // (Enter: the one key to remember — every command and setting by name.)+ b(k(KeyCode::Enter, none), "choose-command", false, "Commands and settings, by name");b(ch('N'), "new-harness", false, "New Harness: agent, project and options");b(ch('@'), "choose-tree -m", false, "Machines (then their harnesses)");b(ch('T'), "new-terminal", false, "New terminal (a shell) beside this pane");@@ -187,6 +189,20 @@ impl Keymap {Keymap { prefix: k(KeyCode::Char('b'), ctrl), prefix2: None, prefix_table: t, root_table: root, copy_vi: Vec::new(), copy_emacs: Vec::new(), named: Default::default(), copy_unbound: Vec::new(), removed: Vec::new(), repeat_ms: 500, hint_ms: 600 }}+ /// A prefix table saved before hn added a key: the new key is added where the table has+ /// nothing on it (a key bound by hand to something else is left as it is).+ pub fn migrate_defaults(table: &mut Vec<Binding>) {+ // (key, command, note) — hn's keys added since tables were first saved.+ const ADDED: &[(&str, &str, &str)] = &[+ ("Enter", "choose-command", "Commands and settings, by name"),+ ];+ for (key, command, note) in ADDED {+ let Ok(chord) = parse(key) else { continue };+ if table.iter().any(|b| b.chord == chord) { continue }+ table.push(Binding { chord, command: (*command).into(), repeat: false, note: (*note).into() });+ }+ }+/// Every key table, as `list-keys` walks them: by name, each by key code. The copy-mode tables/// are tmux's defaults (tests/fixtures), with what was bound over them and without what was/// unbound.@@ -504,6 +520,20 @@ pub fn of(key: &KeyEvent) -> Chord { Chord::of(key) }mod tests {use super::*;+ /// A table saved before Enter opened the command list gets it (Space stays tmux's+ /// next-layout); Enter bound by hand to something else keeps it.+ #[test]+ fn a_saved_table_gets_the_keys_added_since() {+ let mut old = vec![Binding { chord: parse("Space").unwrap(), command: "next-layout".into(), repeat: false, note: String::new() }];+ Keymap::migrate_defaults(&mut old);+ assert_eq!(old[0].command, "next-layout");+ assert!(old.iter().any(|b| name(&b.chord) == "Enter" && b.command == "choose-command"));+ let mut mine = vec![Binding { chord: parse("Enter").unwrap(), command: "resize-pane -Z".into(), repeat: false, note: String::new() }];+ Keymap::migrate_defaults(&mut mine);+ assert_eq!(mine.len(), 1);+ assert_eq!(mine[0].command, "resize-pane -Z");+ }+#[test]fn tmux_spellings() {assert_eq!(parse("C-b").unwrap(), Chord::normal(KeyCode::Char('b'), KeyModifiers::CONTROL));diff --git a/tui/src/main.rs b/tui/src/main.rsindex 56f01ddc3..46c5718cb 100644--- a/tui/src/main.rs+++ b/tui/src/main.rs@@ -15,18 +15,21 @@ mod ids;mod history;mod mirror;mod server;+mod settings;mod ipc;mod keys;mod preview;mod config;mod copy;mod daemon;+mod devices;mod dial;mod draw;mod event;mod fleet;mod format;mod fzf;+mod terminal_themes;mod input;mod layout;mod local;@@ -45,6 +48,11 @@ mod term_input;mod tmuxconf;mod ui;mod viewer;+// ── status bar ──+mod bar;+mod bar_more;+// ── models: the Models view (step 6) ──+mod models;use std::io::{self, BufWriter, Write};use std::time::{Duration, Instant};@@ -161,6 +169,7 @@ async fn run_headless(config: config::Config, port: u16) -> io::Result<()> {app.cfg_finished = true;app.config_files = read;if config.prefix_set { app.keymap.prefix = config.prefix }+ app.apply_look(config.look.as_ref());// The server's options, keys, buffers and environment: this client's if it is the first.server::join(&mut app);// When each harness was last looked at (seen.json): what finished while no one looked is@@ -291,16 +300,20 @@ async fn run(config: config::Config) -> io::Result<()> {f.rest = f.rest[starts[k]..].to_vec();}}+ // `hn <command>` where the command is an in-TUI one (theme, palette, layout…): tmux's CLI+ // would answer "unknown command", because these are not tmux commands. The client starts and+ // runs it itself, once the launcher is up — as `;`'s chain is (`start_then`).+ let gui = !f.rest.is_empty() && f.rest.iter().all(|w| crate::input::is_command(w));// hn <command>: answered from here (hn ls) or by the running client (a tmux command).- if let Some(code) = cli::run(&f.rest, explicit, f.socket.as_deref(), f.name.as_deref()).await { std::process::exit(code) }+ if !gui { if let Some(code) = cli::run(&f.rest, explicit, f.socket.as_deref(), f.name.as_deref()).await { std::process::exit(code) } }// -L name, starting a client: its socket's name.if let Some(n) = &f.name { unsafe { std::env::set_var("HN_SOCKET_NAME", n) } }// hn new -s work / hn attach -t work: the session this client starts in.// `hn new … \; split-window …`: the command that starts this client, then the chain after it// (run in the client once its session is there, as tmux runs the rest of the command line).- let cut = f.rest.iter().position(|w| w == ";").unwrap_or(f.rest.len());- let then: Vec<String> = f.rest.get(cut + 1..).map(|r| r.to_vec()).unwrap_or_default();- let start = cli::start_session(&f.rest[..cut]);+ let cut = if gui { 0 } else { f.rest.iter().position(|w| w == ";").unwrap_or(f.rest.len()) };+ let then: Vec<String> = if gui { f.rest.clone() } else { f.rest.get(cut + 1..).map(|r| r.to_vec()).unwrap_or_default() };+ let start = if gui { None } else { cli::start_session(&f.rest[..cut]) };// attach with nothing to attach to (no client, no session kept; the desk's is always there):// tmux's words, before it would look for a terminal — `hn attach || hn new` makes one.@@ -411,6 +424,7 @@ async fn run(config: config::Config) -> io::Result<()> {app.cfg_finished = true;app.config_files = read.clone();if config.prefix_set { app.keymap.prefix = config.prefix }+ app.apply_look(config.look.as_ref());for (chord, command) in &config.keys {match command { Some(c) => app.keymap.bind(keys::Table::Root, *chord, c.clone(), false), None => app.keymap.unbind(keys::Table::Root, chord) }}diff --git a/tui/src/modal.rs b/tui/src/modal.rsindex b4a906a92..adf7e48dd 100644--- a/tui/src/modal.rs+++ b/tui/src/modal.rs@@ -1,12 +1,13 @@//! The overlays and what their rows are: the fzf list's modes (harnesses, > commands, @ machines,//! # projects, : models, * store, ? help), needs input, the New Harness form, layouts, and the-//! one-line prompts (rename, first message, send, link password).+//! one-line prompts (rename, first message, send).use ratatui::style::Style;use ratatui::text::Span;use serde_json::Value;use crate::app::App;+use crate::terminal_themes::TERMINAL_THEMES;use crate::fleet::{ago, Reach, State};use crate::layout::Preset;use crate::picker::{Picker, Row};@@ -44,6 +45,10 @@ pub enum PickerKind {Layout,Help,Store,+ /// The look & theme of hn: a `[look]` preset or a knob, applied live and written to tui.toml.+ Theme,+ /// C-b Enter: every command by name, in the settings panel — type a few letters, Enter runs it.+ Commands,/// A task routed to a harness; [voice]: the dial's spoken task it answers.Route { text: String, voice: Option<String> },/// `show-messages`, `list-keys`, `choose-buffer`.@@ -52,6 +57,9 @@ pub enum PickerKind {Buffers,/// What `list-windows`, `list-panes`, `show-options`… print, in a view (tmux's view mode).Output { title: String, lines: Vec<String> },+ // ── machines & devices ──+ /// Connect a machine, Add phone, Machines & devices: the desktop's machine screens in the panel.+ Devices(crate::devices::View),}#[derive(Clone, Debug)]@@ -60,7 +68,6 @@ pub enum PromptKind {RenameHarness { machine: String, agent: String },Send,Broadcast,- LinkPassword { machine: String },/// A question's answer, typed: option numbers or your own words./// The question's request id when M-a was pressed: a new one meanwhile is not answered.Answer { machine: String, agent: String, request: String },@@ -165,7 +172,7 @@ pub const ENGINES: [&str; 14] = ["claude", "codex", "opencode", "cursor", "pi",pub const COMMANDS: &[(&str, &str, &str, &str, &str)] = &[("open", "Harnesses…", "⌥P", "every harness on every machine", "Harness"),("projects", "Projects…", "⌥O", "a project, then one of its harnesses", "Harness"),- ("models", "Models…", "⌥I", "switch this harness's model and effort", "Harness"),+ ("models", "Models…", "⌥I", "local, shared, subscriptions, APIs — use one on this harness", "Harness"),("new", "New Harness…", "⌥N", "", "Harness"),("terminal", "New Terminal", "⌥⇧T", "a shell on this pane's machine", "Harness"),("inbox", "Harnesses needing input", "⌥⇧I", "", "Harness"),@@ -195,9 +202,15 @@ pub const COMMANDS: &[(&str, &str, &str, &str, &str)] = &[("copy-mode", "Copy Mode", "⌥V", "select and copy with the keyboard", "Panes"),("machines", "Machines", "⌥M", "", "Machines"),("store", "Harness Store", "⌥S", "", "Machines"),- ("help", "Keyboard Shortcuts", "⌥/", "", "App"),- ("keys", "Every Key…", "", "every binding, searched as you type (C-b ? lists them as tmux does)", "App"),- ("quit", "Quit", "⌥Q", "harnesses keep running", "App"),+ // ── machines & devices ──+ ("connect-machine", "Connect a machine…", "", "a machine not linked yet, with its remote password", "Machines"),+ ("add-phone", "Add phone…", "", "a QR code your phone scans to sign in and pair", "Machines"),+ ("devices", "Machines & devices…", "", "this computer's password, your machines, links, add a machine", "Machines"),+ // (hn itself: how it looks, its keys, and closing it.)+ ("theme", "Appearance…", "", "theme, status bar, borders, focus, layout — settings", "Settings & help"),+ ("keys", "Keyboard shortcuts…", "", "every key and what it does, searched as you type", "Settings & help"),+ ("help", "Quick help", "⌥/", "what the search box can do: > @ # : * ?", "Settings & help"),+ ("quit", "Close hn", "⌥Q", "your harnesses keep running", "Settings & help"),];@@ -224,10 +237,8 @@ pub fn agent_rows(app: &App, filter: Filter, machine: Option<&str>, project: Optlet state = app.fleet.state_of(a);let (dot, _, color) = state_mark(state, app.tick);let (mark, mark_color) = engine_mark(&a.engine);- let group = match state {- State::NeedsInput => "Needs you", State::Failed => "Failed", State::Done => "Done", State::Working => "Working", State::Starting => "Starting",- State::Ready => "Idle", State::Paused => "Paused", State::Offline => "Offline",- };+ // (No headings by state: the list is one, the one active last first — its mark says+ // what each is doing.)let is_open = open.contains(&a.key());// Its one line: the question it asks, what it is doing now, what its last turn came to,// why it failed — the rest in the finder's dim.@@ -268,7 +279,6 @@ pub fn agent_rows(app: &App, filter: Filter, machine: Option<&str>, project: Opt.extra(format!("{} {} {} {} {} {} {} {} {}", a.project, a.branch, app.fleet.machine_name(&a.machine_id), a.engine, engine_label(&a.engine), a.dsh, pr, pr_words, words))// What it is doing now and how long it has been as it is change as you look..volatile(matches!(state, State::Working | State::Starting), narrow.chars().count())- .group(group).lead(vec![span(dot, fg(color)), span(" ", Style::default()), span(mark, fg(mark_color)), span(" ", Style::default())]).detail(detail).right(right)@@ -292,7 +302,7 @@ pub fn external_rows(app: &App) -> Vec<Row> {Row::new(format!("external:{}:{}", x.machine, x.session_id), title).extra(format!("{} {} {} {}", x.cwd, x.engine, engine_label(&x.engine), app.fleet.machine_name(&x.machine))).group("Not in Harness")- .lead(vec![span("◌", fg(theme::MUTED)), span(" ", Style::default()), span(mark, fg(mark_color)), span(" ", Style::default())])+ .lead(vec![span("‖", fg(theme::MUTED)), span(" ", Style::default()), span(mark, fg(mark_color)), span(" ", Style::default())]).detail(vec![span(folder, fg(theme::MUTED))]).right(right).right_narrow(ago(x.last_at))@@ -360,7 +370,7 @@ pub fn launcher_title(app: &App, kind: &PickerKind) -> (String, String) {PickerKind::Palette => ("commands".into(), "Run anything by name".into()),PickerKind::Machines => ("machines".into(), "Choose a machine, then one of its harnesses".into()),PickerKind::Projects => ("projects".into(), "Choose a project, then one of its harnesses".into()),- PickerKind::Models => ("models".into(), "Switch the focused harness's model and effort".into()),+ PickerKind::Models => ("models".into(), "Search models — Enter uses one on the focused harness".into()),PickerKind::Store => ("store".into(), "Find a harness in the Store".into()),PickerKind::Help => ("quick access".into(), "What this box can do".into()),_ => (String::new(), String::new()),@@ -397,63 +407,36 @@ pub fn project_rows(app: &App) -> Vec<Row> {let counts = state_counts(app, app.fleet.agents.values().filter(|a| a.machine_id == machine && a.project_root == root));let right = format!("{}{}{} harness{}{}", if many { format!("{} ", app.fleet.machine_name(&machine)) } else { String::new() }, if counts.is_empty() { String::new() } else { format!("{counts} ") }, all, if all == 1 { "" } else { "es" }, if live > 0 { format!(" · {live} live") } else { String::new() });(recent, Row::new(format!("proj:{machine}\t{root}"), name).extra(format!("{short} {}", app.fleet.machine_name(&machine)))- .lead(vec![span(if live > 0 { "● " } else { "○ " }, fg(if live > 0 { theme::ONLINE } else { theme::MUTED }))])+ .lead(vec![span(if live > 0 { "✓ " } else { "· " }, fg(if live > 0 { theme::ONLINE } else { theme::MUTED }))]).detail(vec![span(short, fg(theme::MUTED))]).right(right).boost(if live > 0 { 30 } else { 0 }))}).collect();rows.sort_by(|a, b| b.0.cmp(&a.0));rows.into_iter().map(|(_, r)| r).collect()}-/// `:`: the focused harness's models, the one it runs marked.+/// `:`, after the Models view's sections (models.rs): the focused harness's engine's own models+/// and efforts (`agent_update selectedModel`), the one it runs marked — headed by the engine, so+/// they read as its own section.pub fn model_rows(app: &App) -> Vec<Row> {let Some((machine, agent)) = app.focused().and_then(|f| app.panes.get(&f)).map(|p| (p.machine_id.clone(), p.agent_id.clone())) else { return vec![] };- let current = app.fleet.agent(&machine, &agent).map(|a| a.model.clone()).unwrap_or_default();+ let (current, engine) = app.fleet.agent(&machine, &agent).map(|a| (a.model.clone(), engine_label(&a.engine).to_string())).unwrap_or_default();let list = app.models.get(&(machine, agent)).cloned().unwrap_or_default();list.iter().filter_map(|m| {let id = m.get("id")?.as_str()?.to_string();let name = m.get("displayName").and_then(Value::as_str).unwrap_or(&id).to_string();let (family, effort) = name.split_once(" / ").map(|(a, b)| (a.to_string(), b.to_string())).unwrap_or((name.clone(), String::new()));let on = id == current;- Some(Row::new(id, name.clone()).group(family).extra(effort)- .lead(vec![span(if on { "● " } else { " " }, fg(theme::ONLINE))])+ Some(Row::new(id, name.clone()).group(format!("{engine} · {family}")).extra(effort)+ .lead(vec![span(if on { "✓ " } else { " " }, fg(theme::ONLINE))]).right(if on { "current".to_string() } else { String::new() }))}).collect()}-/// The machine a `:` list is about: the focused pane's, else this computer.-pub fn models_machine(app: &App) -> String {- app.focused().and_then(|f| app.panes.get(&f)).map(|p| p.machine_id.clone()).unwrap_or_else(|| app.fleet.local_id.clone())-}--/// `:`, part two: the machine's local models — start one that is downloaded, get one that is not.-pub fn local_model_rows(app: &App) -> Vec<Row> {- let machine = models_machine(app);- let name = app.fleet.machine_name(&machine);- let Some(list) = app.local_models.get(&machine) else { return vec![] };- let gb = |b: f64| if b >= 1e9 { format!("{:.1} GB", b / 1e9) } else { format!("{:.0} MB", b / 1e6) };- let mut rows: Vec<(u8, Row)> = list.iter().filter_map(|m| {- let id = m.get("id")?.as_str()?;- let state = m.get("state").and_then(Value::as_str).unwrap_or("available");- let label = m.get("name").and_then(Value::as_str).unwrap_or(id).to_string();- let size = m.get("sizeBytes").and_then(Value::as_f64).map(gb).unwrap_or_default();- let (dot, color, rank) = match state { "running" | "serving" => ("●", theme::ONLINE, 0), "downloaded" => ("○", theme::SOFT, 1), s if s.contains("load") || s.contains("start") => ("◌", theme::WARN, 0), _ => ("·", theme::MUTED, 2) };- let action = match rank { 0 => "running · ^S stops", 1 => "enter starts", _ => "enter downloads" };- let recommended = m.get("recommended").and_then(Value::as_bool).unwrap_or(false);- Some((rank, Row::new(format!("grid:{machine}\t{id}"), label).group(format!("Local models · {name}"))- .extra(format!("{id} {} {state}", m.get("quant").and_then(Value::as_str).unwrap_or("")))- .lead(vec![span(format!("{dot} "), fg(color))])- .detail(vec![span(format!("{state}{}", if recommended { " · recommended" } else { "" }), fg(theme::MUTED))])- .right(format!("{size} {action}"))))- }).collect();- rows.sort_by_key(|(rank, _)| *rank);- rows.into_iter().map(|(_, r)| r).collect()-}-/// `?`: what the box does, one prefix per line, then every key.pub fn mode_rows(app: &App) -> Vec<Row> {let hint = |c: &str| app.keymap.hint(c).unwrap_or_default();let modes = [(">", "commands", "every tmux command, by name", hint("command-prompt")), ("@", "machines", "a machine, then its harnesses", hint("choose-tree -m")),- ("#", "projects", "a project folder, then its harnesses", String::new()), (":", "models", "this harness's model; local models", hint("choose-tree -i")),+ ("#", "projects", "a project folder, then its harnesses", String::new()), (":", "models", "local, shared, subscriptions, APIs", hint("choose-tree -i")),("*", "store", "the Harness Store", hint("choose-tree -S"))];let mut rows: Vec<Row> = modes.iter().map(|(p, t, d, k)| Row::new(format!("mode:{p}"), format!("{p} {t}")).detail(vec![span(*d, Style::default().add_modifier(ratatui::style::Modifier::DIM))]).right(k.clone())).collect();let prefix = crate::keys::name(&app.keymap.prefix);@@ -493,6 +476,50 @@ pub fn palette_rows(app: &App) -> Vec<Row> {}).collect()}+/// C-b Enter: hn's own commands (by the names they have in the menus), then every tmux command —+/// each with the key that runs it, where one does.+pub fn command_rows(app: &App) -> Vec<Row> {+ let own = COMMANDS.iter().map(|(id, title, _, hint, group)| {+ let key = own_key(app, id).unwrap_or_default();+ // (Ranked above a tmux command that matches as well: `appe` is Appearance, not a word in+ // set-buffer's description.)+ Row::new(format!("cmd:{id}"), *title).extra(format!("{id} {hint} {group}")).detail(vec![span(*hint, fg(theme::MUTED))]).right(key).group(*group).boost(40)+ });+ let tmux = crate::commands::COMMANDS.iter().map(|(name, alias, about)| {+ let key = app.keymap.key_for_name(name).unwrap_or_default();+ // (Found by its name and alias: its description is shown, not searched — a word in it+ // would outrank what you meant, `appe` → set-buffer's "appends".)+ Row::new(format!("tmux:{name}"), *name).extra(alias.to_string()).detail(vec![span(*about, fg(theme::MUTED))]).right(key).group("tmux commands")+ });+ own.chain(tmux).collect()+}++/// The command list as it shows: hn's own commands when it opens, tmux's too once you search —+/// they are many, and there for the one you type.+pub fn command_rows_for(app: &App, searching: bool) -> Vec<Row> {+ command_rows(app).into_iter().filter(|r| searching || !r.id.starts_with("tmux:")).collect()+}++/// The key (prefix, then the key) that runs one of hn's own commands, as the prefix table has it+/// now — so a rebinding shows. The command each menu entry is on a key as.+fn own_key(app: &App, id: &str) -> Option<String> {+ let runs = match id {+ "open" => "choose-tree -Zs", "models" => "choose-tree -i", "new" => "new-harness", "terminal" => "new-terminal",+ "inbox" => "choose-tree -a", "next-waiting" => "next-harness", "send" => "send-task", "broadcast" => "broadcast",+ "clone" => "clone-harness", "restart" => "restart-harness", "pause" => "pause-harness", "tab" => "new-window",+ "rename-tab" => "rename-window", "close-tab" => "kill-window", "next-tab" => "next-window", "prev-tab" => "previous-window",+ "split-right" => "split-window -h", "split-down" => "split-window", "close-pane" => "kill-pane", "zoom" => "resize-pane -Z",+ "equalize" => "select-layout -E", "find" => "find-window", "copy-mode" => "copy-mode", "machines" => "choose-tree -m",+ "store" => "choose-tree -S", "help" => "list-keys -N", "theme" | "commands" => "choose-command",+ _ => return None,+ };+ let table = &app.keymap.prefix_table;+ let hit = table.iter().find(|b| b.command == runs)+ .or_else(|| table.iter().find(|b| b.command.split(|c: char| c.is_whitespace() || c == '{' || c == '"').any(|w| w == runs)))+ .or_else(|| table.iter().find(|b| b.command.contains(runs)))?;+ Some(format!("{} {}", crate::keys::name(&app.keymap.prefix), crate::keys::name(&hit.chord)))+}+/// Commands that mean nothing without words after them.pub const NEEDS_ARGS: &[&str] = &["select-window", "rename-window", "move-window", "select-pane", "resize-pane", "swap-pane", "select-layout", "send-keys", "command-prompt", "confirm-before", "display-message", "send-message", "rename-harness", "send-task", "broadcast"];@@ -501,14 +528,16 @@ pub fn machine_rows(app: &App) -> Vec<Row> {// Its harnesses by what they do: the fleet's counts, for this machine.let here: Vec<State> = app.fleet.agents.values().filter(|a| a.machine_id == m.id && a.engine != "terminal").map(|a| app.fleet.state_of(a)).collect();let n = |s: State| here.iter().filter(|x| **x == s).count();- let (dot, color, word) = match &m.reach {- _ if m.local && m.reach == Reach::Ready => ("●", theme::ONLINE, "this computer".to_string()),- Reach::Ready => ("●", theme::ONLINE, "connected".into()),- Reach::Connecting => ("◌", theme::WARN, "connecting…".into()),- Reach::NeedsLink => ("●", theme::ATTENTION, "not linked — M-l links it".into()),- Reach::Error(e) => ("●", theme::DANGER, e.chars().take(40).collect()),- _ if m.online() => ("○", theme::SOFT, "online".into()),- _ => ("○", theme::MUTED, "offline".into()),+ // (The harnesses' marks, no round ones: `✓` connected, a spinner connecting, `?` to link…)+ let (dot, color) = theme::machine_mark(&m.reach, m.online(), app.tick);+ let word: String = match &m.reach {+ _ if m.local && m.reach == Reach::Ready => "this computer".into(),+ Reach::Ready => "connected".into(),+ Reach::Connecting => "connecting…".into(),+ Reach::NeedsLink => "not linked — M-l links it".into(),+ Reach::Error(e) => e.chars().take(40).collect(),+ _ if m.online() => "online".into(),+ _ => "offline".into(),};let rtt = app.rtt.get(&m.id).filter(|_| m.usable()).map(|d| format!("{}ms ", d.as_millis())).unwrap_or_default();let counts = [(State::NeedsInput, "waiting"), (State::Failed, "failed"), (State::Done, "done"), (State::Working, "working"), (State::Ready, "idle")]@@ -525,12 +554,95 @@ pub fn layout_rows() -> Vec<Row> {Preset::ALL.iter().enumerate().map(|(i, (_, name, detail))| Row::new(i.to_string(), *name).detail(vec![span(*detail, fg(theme::MUTED))])).collect()}+/// `hn theme`: every choice in the config file's `[look]` table, one per row, the current value+/// marked. Picking a row applies it live and writes it back to `tui.toml` — so the file stays the+/// single place the look is described.+/// The look/theme picker, level one: the sections. Right/Enter opens one's options in the same+/// list; the right pane previews the one the cursor is on.+pub fn theme_sections(app: &App) -> Vec<Row> {+ let o = &app.options;+ let status = o.get("pane-border-status", "", None).unwrap_or_else(|| "top".into());+ // (Named as its options are: the highlighted border, or the rest blurred.)+ let focus = if o.focus_style() == "surface" { "blurred" } else { "border" };+ let orientation = o.look_orientation().to_string();+ let layout_preset = o.get("@hn-layout-preset", "", None).unwrap_or_else(|| "auto".into());+ let theme = o.get("@hn-theme", "", None).unwrap_or_default();++ let sec = |id: &str, title: &str, detail: &str, cur: &str| Row::new(id, title)+ .detail(vec![span(detail, fg(theme::MUTED))])+ .right(if cur.is_empty() { "—".into() } else { cur.to_string() });++ vec![+ // (The lines' glyphs and tmux's arrow indicators are tmux.conf's to set: with every pane its+ // own box, coloured when focused, they say nothing more.)+ sec("section:status", "Pane titles", "pane-border-status", &status),+ sec("section:focus", "Focus", "focus_style", focus),+ sec("section:split", "Split direction", "layout_orientation", &orientation),+ sec("section:layout", "Layout", "@hn-layout-preset", &layout_preset),+ sec("section:theme", "Theme", "bundled terminal themes", if theme.is_empty() { "terminal" } else { &theme }),+ // ── status bar ──+ sec("section:bar", "Status bar", "status_bar", status_bar_of(app)),+ sec("section:boxes", "Borders", "every pane its own box", if border_style_of(app) == "box" { "on" } else { "off" }),+ ]+}++// ── status bar ──++/// Where the status bar is: `@hn-status-bar`, or (none said) where tmux.conf's status-position put it.+fn status_bar_of(app: &App) -> &'static str { match app.options.status_bar() { "bottom" if app.status_top => "top", b => b } }++/// How panes are set apart: `box` unless `@hn-border line`.+fn border_style_of(app: &App) -> &'static str { if app.options.get("@hn-border", "", None).as_deref() == Some("line") { "line" } else { "box" } }++/// The look/theme picker, level two: the options of one section. Enter on one applies it (and the+/// ▼ moves to it); Left/Esc returns to the section list.+pub fn theme_options(app: &App, section: &str) -> Vec<Row> {+ let o = &app.options;+ let mark = |is: bool| if is { "✓ " } else { " " };+ let lead = |is: bool| vec![span(mark(is), fg(if is { theme::accent() } else { theme::MUTED }))];+ let current = |key: &str, default: &str| o.get(key, "", None).unwrap_or_else(|| default.into());+ let opt = |id: String, label: &str, picked: bool, hint: &str| {+ Row::new(id, label).lead(lead(picked)).detail(vec![span(if picked { "current" } else { hint }, fg(theme::MUTED))])+ };+ match section {+ "status" => { let cur = current("pane-border-status", "top");+ ["off", "top", "bottom"].iter().map(|v| opt(format!("border_status:{v}"), *v, cur == *v, "pane-border-status")).collect() }+ "indicators" => { let cur = current("pane-border-indicators", "colour");+ ["off", "colour", "arrows", "both"].iter().map(|v| opt(format!("border_indicators:{v}"), *v, cur == *v, "pane-border-indicators")).collect() }+ "border" => { let cur = current("pane-border-lines", "single");+ ["single", "double", "heavy", "simple", "number"].iter().map(|v| opt(format!("border_lines:{v}"), *v, cur == *v, "pane-border-lines")).collect() }+ "focus" => { let cur = o.focus_style().to_string();+ ["line", "surface"].iter().map(|v| opt(format!("focus:{v}"), if *v == "line" { "border" } else { "blurred" }, cur == *v, "focus_style")).collect() }+ "split" => { let cur = o.look_orientation().to_string();+ ["auto", "vertical", "horizontal"].iter().map(|v| opt(format!("layout_orientation:{v}"), *v, cur == *v, "layout_orientation")).collect() }+ "layout" => { let cur = current("@hn-layout-preset", "auto");+ ["auto", "even-horizontal", "even-vertical", "main-horizontal", "main-vertical", "tiled"].iter().map(|v| opt(format!("layout_preset:{v}"), *v, cur == *v, "@hn-layout-preset")).collect() }+ "theme" => {+ let cur = o.get("@hn-theme", "", None).unwrap_or_default();+ // First, no theme: the terminal's own colours.+ let native = Row::new("theme:", "Terminal default").extra("none default terminal").lead(lead(cur.is_empty()));+ std::iter::once(native).chain(TERMINAL_THEMES.iter().map(|t| {+ let picked = cur == t.name;+ Row::new(format!("theme:{}", t.name), t.name).extra(t.name).lead(lead(picked))+ })).collect()+ }+ // ── status bar ──+ "bar" => { let cur = status_bar_of(app);+ [("bottom", "tmux's status line, at the bottom"), ("top", "tmux's status line, at the top"), ("left", "a bar down the left: windows and their panes, machines"), ("right", "a bar down the right")]+ .iter().map(|(v, hint)| opt(format!("status_bar:{v}"), v, cur == *v, hint)).collect() }+ "boxes" => { let cur = border_style_of(app);+ [("box", "on", "every pane its own box"), ("line", "off", "tmux's lines between panes")]+ .iter().map(|(v, label, hint)| opt(format!("border_style:{v}"), label, cur == *v, hint)).collect() }+ _ => vec![],+ }+}+pub fn new_machine_rows(app: &App, prefer: &str) -> Vec<Row> {let mut rows: Vec<Row> = app.fleet.machines.iter().filter(|m| m.usable()).map(|m| {let running = app.fleet.agents.values().filter(|a| a.machine_id == m.id && a.status == "active").count();Row::new(m.id.clone(), m.name.clone())- .lead(vec![span(if m.id == prefer { "● " } else { "○ " }, fg(if m.id == prefer { theme::accent() } else { theme::ONLINE }))])+ .lead(vec![span(if m.id == prefer { "✓ " } else { " " }, fg(theme::accent()))]).detail(vec![span(format!("{}{running} running", if m.local { "this computer · " } else { "" }), fg(theme::MUTED))])}).collect();rows.sort_by_key(|r| r.id != prefer);@@ -564,7 +676,7 @@ pub fn store_rows(catalog: &[Value]) -> Vec<Row> {let description = row.get("description").and_then(Value::as_str).unwrap_or("");let category = row.get("category").and_then(Value::as_str).unwrap_or(if installed { "Installed" } else { "Available" });Some(Row::new(id, name).extra(format!("{id} {description} {category}")).group(category.to_string())- .lead(vec![span(if installed { "● " } else { "○ " }, fg(if installed { theme::ONLINE } else { theme::MUTED }))])+ .lead(vec![span(if installed { "✓ " } else { " " }, fg(theme::ONLINE))]).detail(vec![span(description.to_string(), fg(theme::MUTED))]))}).collect()}@@ -584,3 +696,106 @@ pub fn route_rows(reply: &Value) -> Vec<Row> {rows.sort_by_key(|r| !r.id.ends_with(best) || best.is_empty());rows}++#[cfg(test)]+mod theme_row_tests {+ use super::*;+ use crate::app::App;+ use crate::terminal_themes::TERMINAL_THEMES;++ fn app() -> App {+ let (sink, _) = tokio::sync::mpsc::unbounded_channel();+ let mut app = App::new(19789, sink, (150, 42));+ app.fleet.local_id = "local".into();+ app.fleet.machines.push(crate::fleet::Machine {+ id: "local".into(), name: "studio".into(), local: true, status: "online".into(), reach: crate::fleet::Reach::Ready,+ });+ app.homes.insert("local".into(), "/home/dev".into());+ app+ }++ #[test]+ fn theme_sections_list_the_look_sections() {+ let app = app();+ let rows = theme_sections(&app);+ let ids: Vec<&str> = rows.iter().map(|r| r.id.as_str()).collect();+ assert_eq!(ids, vec!["section:status", "section:focus", "section:split", "section:layout", "section:theme",+ // ── status bar ──+ "section:bar", "section:boxes"]);+ // Each section shows its current value and opens onto a non-empty option list.+ assert!(rows.iter().all(|r| !r.right.is_empty()), "each section shows a value");+ for r in &rows {+ let sec = r.id.strip_prefix("section:").unwrap();+ assert!(!theme_options(&app, sec).is_empty(), "{sec} has options");+ }+ }++ #[test]+ fn theme_options_list_every_bundled_theme() {+ let app = app();+ let rows = theme_options(&app, "theme");+ // The terminal's own colours first, then every bundled theme.+ assert_eq!(rows.len(), TERMINAL_THEMES.len() + 1, "every bundled theme listed");+ assert_eq!(rows.first().map(|r| r.id.as_str()), Some("theme:"));+ let first_id = format!("theme:{}", TERMINAL_THEMES[0].name);+ assert_eq!(rows.get(1).map(|r| r.id.as_str()), Some(first_id.as_str()));+ assert!(rows.iter().all(|r| !r.lead.is_empty()), "mark on every theme row");+ }++ #[test]+ fn matching_theme_is_marked() {+ let a0 = app();+ let rows = theme_options(&a0, "theme");+ let idx = rows.iter().position(|r| r.id == "theme:Adwaita").unwrap();+ assert!(!rows[idx].lead.iter().any(|s| s.content.as_ref() == "✓ "));+ let mut a1 = app();+ let global = crate::options::SetFlags { global: true, ..Default::default() };+ let _ = a1.options.set("@hn-theme", Some("Adwaita"), &global, "", 0);+ let rows = theme_options(&a1, "theme");+ let idx = rows.iter().position(|r| r.id == "theme:Adwaita").unwrap();+ assert!(rows[idx].lead.iter().any(|s| s.content.as_ref() == "✓ "));+ }++ #[test]+ fn an_option_section_lists_its_choices() {+ let app = app();+ let status_opts = theme_options(&app, "status");+ let status_ids: Vec<&str> = status_opts.iter().map(|r| r.id.as_str()).collect();+ assert_eq!(status_ids, vec!["border_status:off", "border_status:top", "border_status:bottom"]);+ let split_opts = theme_options(&app, "split");+ let split_ids: Vec<&str> = split_opts.iter().map(|r| r.id.as_str()).collect();+ assert_eq!(split_ids, vec!["layout_orientation:auto", "layout_orientation:vertical", "layout_orientation:horizontal"]);+ }++ // ── status bar ──++ #[test]+ fn the_status_bar_and_border_style_sections_mark_what_is_in_use() {+ let _colours = crate::term_out::colours_lock();+ let mut app = app();+ let ids = |rows: Vec<Row>| rows.iter().map(|r| r.id.clone()).collect::<Vec<_>>();+ let picked = |rows: Vec<Row>| rows.iter().find(|r| r.lead.iter().any(|s| s.content.as_ref() == "✓ ")).map(|r| r.id.clone());+ assert_eq!(ids(theme_options(&app, "bar")), ["status_bar:bottom", "status_bar:top", "status_bar:left", "status_bar:right"]);+ assert_eq!(ids(theme_options(&app, "boxes")), ["border_style:box", "border_style:line"]);+ // The tabs over the panes are gone: no section, and an old knob sets nothing.+ assert!(theme_options(&app, "tabs").is_empty());+ assert!(app.set_look("tabs", "off").starts_with("unknown"));+ // The defaults: the status line at the bottom, boxes.+ assert_eq!(picked(theme_options(&app, "bar")).as_deref(), Some("status_bar:bottom"));+ assert_eq!(picked(theme_options(&app, "boxes")).as_deref(), Some("border_style:box"));+ // tmux.conf's status-position top is where the bar is, until the section says otherwise.+ app.status_top = true;+ assert_eq!(picked(theme_options(&app, "bar")).as_deref(), Some("status_bar:top"));+ let _ = app.set_look("status_bar", "left");+ let _ = app.set_look("border_style", "line");+ assert_eq!(picked(theme_options(&app, "bar")).as_deref(), Some("status_bar:left"));+ assert_eq!(picked(theme_options(&app, "boxes")).as_deref(), Some("border_style:line"));+ let rows = theme_sections(&app);+ let right = |id: &str| rows.iter().find(|r| r.id == id).map(|r| r.right.clone()).unwrap_or_default();+ assert_eq!((right("section:bar"), right("section:boxes")), ("left".into(), "off".into()));+ // Back to the bottom: tmux's status line, placed there.+ let _ = app.set_look("status_bar", "bottom");+ assert!(!app.status_top);+ assert_eq!(app.options.get("status-position", "", None).as_deref(), Some("bottom"));+ }+}diff --git a/tui/src/models.rs b/tui/src/models.rsnew file mode 100644index 000000000..3d746df49--- /dev/null+++ b/tui/src/models.rs@@ -0,0 +1,1801 @@+//! The Models view — `:` in the launcher, and Models… in the Commands panel: every model a harness+//! can run on, in the desktop's sections (This computer, Shared · <grid>, Subscriptions, APIs, the+//! downloads that fit this computer), each row saying what Enter does on it. Enter is **Use**: a+//! local model is downloaded, started and waited for until it serves, then the focused harness is+//! moved onto it (`agent_retarget`); a shared or API model moves it at once; a subscription puts it+//! back on its own login. ^S stops a local model. One local model runs at a time.+//!+//! The daemon's replies are read here defensively, the way the desktop's `LocalModel`, `GridModels`+//! and `ApiConnection` read them: an older daemon's missing fields are absent, never a failure.++use std::collections::{HashMap, HashSet};+use std::time::{Duration, Instant};++use ratatui::style::{Modifier, Style};+use ratatui::text::{Line, Span};+use serde_json::{json, Value};++use crate::app::App;+use crate::daemon::RpcError;+use crate::fleet::Machine;+use crate::picker::{Picker, Row};+use crate::theme::{self, engine_label, fg};++pub const GIB: f64 = 1024.0 * 1024.0 * 1024.0;+/// How long Use waits for a started model to serve before it says so (the desktop's three minutes).+const USE_WAIT: Duration = Duration::from_secs(180);+/// A pane waiting on a resting model says "Starting up…" this long, then that it may take longer —+/// and nothing past the cap: its own terminal is the better witness by then.+const START_STILL: Duration = Duration::from_secs(60);+const START_CAP: Duration = Duration::from_secs(180);+/// A section woken ("Show models") is read again this often, for at most this long: the daemon's+/// own wake gives up at 45 s.+const WAKE_EVERY: Duration = Duration::from_secs(5);+const WAKE_FOR: Duration = Duration::from_secs(60);+/// The downloads listed before "More models".+const SHOWN_DOWNLOADS: usize = 5;++fn num(v: &Value) -> Option<f64> { v.as_f64().filter(|n| n.is_finite() && *n >= 0.0) }+fn text(v: &Value) -> Option<String> { v.as_str().map(str::trim).filter(|s| !s.is_empty()).map(str::to_string) }+fn span(t: impl Into<String>, style: Style) -> Span<'static> { Span::styled(t.into(), style) }++// ── the replies ──────────────────────────────────────────────────────────────────++/// A download, start or stop the daemon owns (`operation`): it survives the view closing.+#[derive(Clone, Debug, PartialEq)]+pub struct Operation { pub id: String, pub model: String, pub action: String, pub stage: String, pub phase: String, pub progress: Option<f64>, pub error: Option<String> }++impl Operation {+ /// Read as the desktop's `LocalModelOperation.parse`: anything it does not know is no operation.+ pub fn parse(v: &Value) -> Option<Operation> {+ let s = |k: &str| v.get(k).and_then(Value::as_str).map(str::to_string);+ let (action, stage, phase) = (s("action")?, s("stage")?, s("phase")?);+ if !["download", "start", "stop"].contains(&action.as_str()) || !["checking", "downloading", "starting", "verifying", "stopping"].contains(&stage.as_str()) || !["running", "done", "failed"].contains(&phase.as_str()) { return None }+ Some(Operation { id: s("id")?, model: s("modelId")?, action, stage, phase, progress: v.get("progress").and_then(num).map(|p| p.clamp(0.0, 1.0)), error: s("error") })+ }+ pub fn active(&self) -> bool { self.phase == "running" }+ pub fn failed(&self) -> bool { self.phase == "failed" }+ pub fn label(&self) -> &'static str {+ match self.stage.as_str() { "downloading" => "Downloading", "starting" => "Starting", "verifying" => "Testing", "stopping" => "Stopping", _ => "Checking" }+ }+ /// `Downloading 42%`: what a row and its preview say while it runs.+ pub fn word(&self) -> String { match self.progress { Some(p) => format!("{} {}%", self.label(), (p * 100.0).floor() as u32), None => self.label().to_string() } }+}++/// One model of this computer's (`grid_fleet_models_list`): downloaded, running, or one the grid's+/// catalog says fits it.+#[derive(Clone, Debug, Default, PartialEq)]+pub struct LocalModel {+ pub id: String, pub name: String, pub state: String, pub size: Option<f64>, pub quant: Option<String>, pub recommended: bool,+ pub can_start: bool, pub can_stop: bool, pub tok_s: Option<f64>, pub requests: Option<f64>, pub window_secs: Option<f64>,+ /// The catalog's word on it for this machine: its window, speed and billions of parameters.+ pub context: Option<f64>, pub est_tok_s: Option<f64>, pub params_b: Option<f64>,+ pub operation: Option<Operation>, pub asleep: bool,+}++impl LocalModel {+ fn from(v: &Value) -> Option<LocalModel> {+ let id = text(&v["id"])?;+ Some(LocalModel {+ name: text(&v["name"]).unwrap_or_else(|| id.clone()), state: text(&v["state"]).unwrap_or_else(|| "available".into()),+ size: num(&v["sizeBytes"]), quant: text(&v["quant"]), recommended: v["recommended"] == true, can_start: v["canStart"] == true, can_stop: v["canStop"] == true,+ tok_s: num(&v["tokensPerSecond"]), requests: num(&v["requests"]), window_secs: num(&v["windowSeconds"]),+ context: num(&v["contextWindow"]), est_tok_s: num(&v["estTokS"]), params_b: num(&v["paramsB"]),+ operation: Operation::parse(&v["operation"]), asleep: v["gridAsleep"] == true, id,+ })+ }+ pub fn running(&self) -> bool { self.state == "running" }+ pub fn downloaded(&self) -> bool { self.state == "downloaded" || self.running() }+ /// Running, parked while this computer's models rest: it answers again on the next message.+ pub fn resting(&self) -> bool { self.running() && self.asleep }+ /// Its quantization: the daemon's, else the one its file name says (`…-Q4_K_M.gguf`) — never+ /// guessed from its size.+ pub fn quantization(&self) -> Option<String> {+ if let Some(q) = &self.quant { return Some(q.clone()) }+ self.id.split(|c: char| !(c.is_ascii_alphanumeric() || c == '_')).find(|w| {+ let u = w.to_ascii_uppercase();+ let digit_after = |p: &str| u.strip_prefix(p).is_some_and(|r| r.starts_with(|c: char| c.is_ascii_digit()));+ digit_after("IQ") || digit_after("Q") || digit_after("MXFP") || ["BF16", "FP16", "F16"].contains(&u.as_str())+ }).map(str::to_ascii_uppercase)+ }+}++/// What `grid_fleet_models_list` answers: the models, the machine's memory and free disk, and+/// whether an operation is under way.+#[derive(Clone, Debug, Default, PartialEq)]+pub struct Snapshot { pub models: Vec<LocalModel>, pub memory: Option<f64>, pub free_disk: Option<f64>, pub hardware: Option<String>, pub notice: Option<String>, pub busy: bool, pub supports_download: bool }++/// None when there is no list — a daemon too old for it, or a reply that failed.+pub fn parse_local(reply: &Value) -> Option<Snapshot> {+ let models = reply["models"].as_array()?.iter().filter_map(LocalModel::from).collect();+ Some(Snapshot {+ models, memory: num(&reply["memoryBytes"]).filter(|m| *m > 0.0), free_disk: num(&reply["freeDiskBytes"]), hardware: text(&reply["hardware"]),+ // A sentence beside the list, never a failure (an `error` fails the whole request).+ notice: text(&reply["notice"]), busy: reply["busy"] == true, supports_download: reply["supportsDownload"] == true,+ })+}++/// A model a grid serves; `offline` names the computer when every one serving it seems offline.+#[derive(Clone, Debug, PartialEq)]+pub struct GridModel { pub id: String, pub node: String, pub offline: Option<String> }++/// One grid this computer is signed into: the account's own, or a shared one, and how it answered+/// the daemon's last look (`awake`, `asleep`, `waking`, `unknown`; empty from an older daemon).+#[derive(Clone, Debug, Default, PartialEq)]+pub struct Section { pub name: String, pub own: bool, pub models: Vec<GridModel>, pub state: String, pub seen: bool, pub age: Option<u64>, pub outcome: String }++/// `grid_models_list`'s answer, and the `grid_models_changed` push (the same document).+#[derive(Clone, Debug, Default, PartialEq)]+pub struct Grids { pub grid_name: Option<String>, pub sections: Vec<Section>, pub engines: Option<Vec<String>>, pub launch: bool, pub reachable: bool }++impl Grids {+ /// Whether [engine] may be pointed at a grid model: only an engine the daemon lists, when it+ /// sent a list (an older one did not, and refused nothing).+ pub fn can_run(&self, engine: &str) -> bool { self.engines.as_ref().is_none_or(|e| e.iter().any(|x| x.eq_ignore_ascii_case(engine))) }+ pub fn waking(&self) -> bool { self.sections.iter().any(|s| s.state == "waking") }+}++pub fn parse_grids(reply: &Value) -> Grids {+ let models = |raw: &Value| raw.as_array().into_iter().flatten().filter_map(|m| {+ let id = text(&m["id"])?;+ let node = m["node"].as_str().unwrap_or("").to_string();+ let offline = match &m["unavailable"] {+ Value::Object(u) if u.get("reason").and_then(Value::as_str) == Some("offline") => u.get("machine").and_then(text),+ Value::Bool(true) => Some(node.clone()),+ _ => None,+ };+ Some(GridModel { id, node, offline })+ }).collect::<Vec<_>>();+ let mut sections: Vec<Section> = reply["grids"].as_array().into_iter().flatten().filter_map(|g| Some(Section {+ name: text(&g["name"])?, own: g["own"] == true, models: models(&g["models"]), state: g["state"].as_str().unwrap_or("").to_string(),+ seen: g["seenAt"].is_string(), age: num(&g["lastKnownAge"]).map(|a| a.round() as u64), outcome: g["wakeOutcome"].as_str().unwrap_or("").to_string(),+ })).collect();+ let grid_name = text(&reply["gridName"]);+ // An older daemon names its own grid alone.+ if sections.is_empty() { if let Some(name) = &grid_name { sections.push(Section { name: name.clone(), own: true, models: models(&reply["models"]), ..Default::default() }) } }+ Grids {+ grid_name, sections,+ engines: reply["localModelEngines"].as_array().map(|a| a.iter().filter_map(Value::as_str).map(str::to_ascii_lowercase).collect()),+ launch: reply["supportsModelLaunch"] == true, reachable: reply.get("error").is_none_or(Value::is_null),+ }+}++/// What a resting section says beside its list — the desktop's `sectionWords`, word for word: a+/// subtitle under its heading, one sentence above its rows, and whether it offers "Show models".+#[derive(Clone, Debug, Default, PartialEq)]+pub struct Words { pub subtitle: Option<String>, pub sentence: Option<String>, pub offer_wake: bool }+++pub const STARTING_UP_WAIT: &str = "Starting up… usually 15–40 s";++/// "just now", then whole minutes, hours and days — rounded down, never younger than it is.+pub fn list_age(seconds: u64) -> String {+ match seconds { s if s < 60 => "just now".into(), s if s < 3600 => format!("{}min ago", s / 60), s if s < 86400 => format!("{}h ago", s / 3600), s => format!("{}d ago", s / 86400) }+}++/// [asking]: a wake this view sent and has not heard back about.+pub fn section_words(s: &Section, asking: bool) -> Words {+ let has = !s.models.is_empty();+ let no_record = s.age.is_none();+ let subtitle = (s.state == "asleep" && has).then(|| match s.age { Some(a) => format!("Asleep {}", list_age(a)), None => "Asleep".to_string() });+ let mut offer_wake = false;+ let sentence = if s.state == "waking" { Some(STARTING_UP_WAIT.to_string()) }+ else if s.outcome == "not_started" { Some(format!("Couldn't start {} right now — it will start on your next message", if s.own { "your models" } else { s.name.as_str() })) }+ else if s.outcome == "nobody_serving" { Some("Nobody is serving a model here right now".to_string()) }+ else if s.state == "asleep" && !has && no_record { offer_wake = !asking; asking.then(|| STARTING_UP_WAIT.to_string()) }+ else if s.state == "asleep" && !has { Some("Nobody was serving here when it went to sleep".to_string()) }+ else if s.state == "unknown" && (has || s.seen || !no_record) { Some("Not answering right now".to_string()) }+ else { None };+ Words { subtitle, sentence, offer_wake }+}++/// An API saved on this computer (`api_connections`) — its key stays in the daemon.+#[derive(Clone, Debug, Default, PartialEq)]+pub struct Api { pub id: String, pub name: String, pub base_url: String, pub header: String, pub prefix: String }++impl Api {+ /// Coding agents send a custom endpoint only `Authorization: Bearer <key>`: only such an API+ /// lists models a harness can run on (the CLI's `servesModels`).+ pub fn serves_models(&self) -> bool { self.header.eq_ignore_ascii_case("authorization") && self.prefix.eq_ignore_ascii_case("bearer") }+ pub fn host(&self) -> String { let rest = self.base_url.split_once("://").map(|(_, r)| r).unwrap_or(&self.base_url); rest.split(['/', '?', '#']).next().unwrap_or(rest).to_string() }+}++/// One model an API lists: no key, only what the API says of it.+#[derive(Clone, Debug, PartialEq)]+pub struct ApiModel { pub id: String, pub name: Option<String>, pub context: Option<u64> }++/// The saved APIs, or why there are none to show.+pub fn parse_apis(reply: &Value) -> Result<Vec<Api>, String> {+ let rows = reply["connections"].as_array().ok_or("Update Harness on this computer to connect APIs.")?;+ Ok(rows.iter().filter_map(|c| {+ let s = |k: &str, d: &str| c[k].as_str().unwrap_or(d).to_string();+ let id = text(&c["id"])?;+ Some(Api { id, name: s("name", ""), base_url: s("baseUrl", ""), header: s("authHeader", "Authorization"), prefix: s("authPrefix", "Bearer") })+ }).collect())+}++pub fn parse_api_models(reply: &Value) -> Option<Vec<ApiModel>> {+ Some(reply["models"].as_array()?.iter().filter_map(|m| Some(ApiModel {+ id: text(&m["id"])?, name: text(&m["name"]), context: m["contextWindow"].as_u64().filter(|w| *w > 0),+ })).collect())+}++/// An agent account's subscription, from the usage the status line reads (`usage_read`): how much+/// of its tightest window is left.+#[derive(Clone, Debug, PartialEq)]+pub struct Sub { pub engine: String, pub title: String, pub account: String, pub left: Option<f64>, pub status: String, pub details: Vec<String> }++/// What is left of a window, as the desktop says it: never a positive remainder rounded to 0.+fn left_of(used: f64) -> String { let left = (100.0 - used).clamp(0.0, 100.0); if left > 0.0 && left < 1.0 { "<1%".into() } else { format!("{}%", left.floor() as u32) } }++pub fn subscriptions(app: &App) -> Vec<Sub> {+ let mut machines: Vec<&String> = app.usage.keys().collect();+ machines.sort_by_key(|m| (**m != app.fleet.local_id, (*m).clone()));+ let mut out: Vec<Sub> = Vec::new();+ for m in machines {+ for u in &app.usage[m] {+ let account = u.account.clone().unwrap_or_default();+ if out.iter().any(|s| s.engine == u.provider && s.account == account) { continue }+ let tightest = u.windows.iter().max_by(|a, b| a.used.total_cmp(&b.used));+ let title = match u.provider.as_str() { "claude" => "Anthropic".to_string(), "codex" => "OpenAI".to_string(), p => engine_label(p).to_string() };+ out.push(Sub {+ engine: u.provider.clone(), title, account,+ left: tightest.map(|w| (100.0 - w.used).clamp(0.0, 100.0)),+ status: tightest.map(|w| format!("{} left", left_of(w.used))).unwrap_or_else(|| "Usage unavailable".into()),+ details: u.windows.iter().map(|w| format!("{} — {} left", w.label, left_of(w.used))).collect(),+ });+ }+ }+ out+}++// ── what the view keeps ──────────────────────────────────────────────────────────++/// Where a Use is: getting the weights, starting them, waiting for the grid to list the model as+/// served, or moving the harness onto it.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum Step { Get, Start, Serve, Switch }++/// Enter's Use on a local model, carried through its steps as the replies come in. It outlives+/// the view: a download takes minutes, and the view must not hold the terminal that long — the+/// harness moves when the model serves, and the status line says so.+#[derive(Clone, Debug)]+pub struct Use { pub model: String, pub name: String, pub machine: String, pub agent: String, pub step: Step, pub since: Instant }++/// An `agent_retarget` sent: the harness, the model it goes to (empty: its own login), and when —+/// "Switching…" on the row and the pane until its frame says it is there (the pane restarts), or+/// a minute passes.+#[derive(Clone, Debug)]+pub struct Switch { pub machine: String, pub agent: String, pub to: String, pub name: String, pub since: Instant }++const SWITCH_FOR: Duration = Duration::from_secs(60);++/// The model the focused harness is being moved to, while it is.+fn switching_for<'a>(app: &'a App, t: Option<&Target>) -> Option<&'a str> {+ let (t, s) = (t?, app.models_view.switching.as_ref()?);+ (s.machine == t.machine && s.agent == t.agent && !switched(app, s)).then_some(s.to.as_str())+}++/// Whether [s] is over: the harness's frame says it is on the model now, or it took too long.+fn switched(app: &App, s: &Switch) -> bool {+ s.since.elapsed() >= SWITCH_FOR || app.fleet.agent(&s.machine, &s.agent).is_none_or(|a| a.grid_model.eq_ignore_ascii_case(&s.to))+}++/// Everything the Models view knows, kept on the App (and read by the pane headings).+#[derive(Default)]+pub struct Models {+ /// Each machine's local models, when they were last read, and a read out now.+ pub local: HashMap<String, Snapshot>,+ pub local_error: HashMap<String, String>,+ pub read_at: HashMap<String, Instant>,+ pub reading: HashSet<String>,+ /// The grids each machine reads (`grid_models_list`), the same way.+ pub grids: HashMap<String, Grids>,+ pub grids_at: HashMap<String, Instant>,+ pub grids_reading: HashSet<String>,+ /// This computer's saved APIs, each API's models, and those unfolded under their API.+ pub apis: Option<Result<Vec<Api>, String>>,+ pub api_models: HashMap<String, Result<Vec<ApiModel>, String>>,+ pub api_open: HashSet<String>,+ /// "More models": the whole catalog shown, not its first five.+ pub more: bool,+ /// A download, start or stop asked and not yet answered (machine, model, action), then its+ /// acknowledgement, until a read shows the daemon's own receipt.+ pub pending: Option<(String, String, &'static str)>,+ pub op: Option<(String, Operation)>,+ pub using: Option<Use>,+ /// A harness asked to move and not yet seen on its new model (its frame's `grid.model`).+ pub switching: Option<Switch>,+ /// Why the last Use of a row failed (row id, words): its preview says so.+ pub use_error: Option<(String, String)>,+ /// Sections a wake was sent for and not yet answered; the re-reads that follow one.+ pub asking: HashSet<String>,+ pub follow_until: Option<Instant>,+ /// Harnesses sent a message while their model's computers rest: since when (the pane says+ /// "Starting up…" until the model answers).+ pub starts: HashMap<(String, String), Instant>,+ /// What the view asked of the daemons (machine, request, payload) — the tests read it.+ #[cfg(test)]+ pub sent: Vec<(String, String, Value)>,+}++impl Models {+ /// The operation on [m]: this view's acknowledgement while it is the newer word, else the+ /// daemon's receipt.+ pub fn op_for<'a>(&'a self, machine: &str, m: &'a LocalModel) -> Option<&'a Operation> {+ match &self.op { Some((at, o)) if at == machine && o.model == m.id => Some(o), _ => m.operation.as_ref() }+ }+ /// A download, start or stop is under way on [machine]: nothing else starts meanwhile.+ pub fn busy(&self, machine: &str) -> bool {+ self.local.get(machine).is_some_and(|s| s.busy) || self.pending.as_ref().is_some_and(|p| p.0 == machine) || self.op.as_ref().is_some_and(|(m, o)| m == machine && o.active())+ }+}++/// How often this computer's models are read: every 4 s while the view is open or something is+/// under way, else every minute.+pub fn poll_every(open: bool, busy: bool) -> Duration { Duration::from_secs(if open || busy { 4 } else { 60 }) }++/// How often the grids are read (pushes keep them current between): every 4 s while a Use waits+/// for its model to serve, every 5 s while a woken section starts up, every 20 s while the view is+/// open, else not at all.+pub fn grids_every(open: bool, serving: bool, waking: bool) -> Option<Duration> {+ if serving { Some(Duration::from_secs(4)) } else if waking { Some(WAKE_EVERY) } else if open { Some(Duration::from_secs(20)) } else { None }+}++fn due(last: Option<&Instant>, every: Duration, now: Instant) -> bool { last.is_none_or(|t| now.saturating_duration_since(*t) >= every) }++// ── the harness a Use is for ─────────────────────────────────────────────────────++/// The focused harness: what a Use moves, and what its grid fields say it is on now.+#[derive(Clone, Debug)]+pub struct Target { pub machine: String, pub agent: String, pub engine: String, pub grid_model: String, pub base_url: String }++pub fn target(app: &App) -> Option<Target> {+ let (machine, agent) = crate::input::focused_agent(app)?;+ let a = app.fleet.agent(&machine, &agent)?;+ if a.engine == "terminal" { return None }+ Some(Target { engine: a.engine.clone(), grid_model: a.grid_model.clone(), base_url: a.grid_base_url.clone(), machine, agent })+}++/// Whether [engine] can be pointed at a model here: the daemon's picture says it may.+pub fn can_run(app: &App, engine: &str) -> bool { app.models_view.grids.get(&app.fleet.local_id).is_some_and(|g| g.reachable && g.can_run(engine)) }++fn up(app: &App, machine: &str) -> bool { app.fleet.machine(machine).is_some_and(Machine::usable) }++/// The own grid's listing of [m] once it serves — (section, the grid's id for it).+fn served_in(grids: Option<&Grids>, m: &LocalModel) -> Option<(String, String)> {+ grids?.sections.iter().filter(|s| s.own).find_map(|s| s.models.iter()+ .find(|x| x.offline.is_none() && (x.id.eq_ignore_ascii_case(&m.id) || x.id.eq_ignore_ascii_case(&m.name)))+ .map(|x| (s.name.clone(), x.id.clone())))+}++/// Everything that decides a local model's row: what it says, and what Enter and ^S may do.+#[derive(Clone, Debug, Default)]+pub struct Facts {+ pub op: Option<Operation>,+ /// The harness is being moved onto it right now.+ pub switching: bool,+ pub in_use: bool, pub active: bool, pub failed: bool,+ pub pending: Option<&'static str>,+ pub busy: bool,+ /// Use moves the harness onto it now (it serves); Use starts it first.+ pub use_running: bool, pub use_start: bool,+ /// Get downloads it; and goes on to start it and move the harness onto it.+ pub get: bool, pub get_use: bool,+ /// Another model running here — the one to stop first: one local model runs at a time.+ pub other: Option<String>,+ pub served: Option<(String, String)>,+}++impl Facts {+ /// The word at the end of its row: what Enter does on it (Use, Get) unless something is+ /// happening to it or the harness is on it already; else its state.+ pub fn word(&self, m: &LocalModel) -> String {+ if self.switching { return SWITCHING.into() }+ if self.in_use { return "✓ In use".into() }+ if let Some(o) = self.op.as_ref().filter(|o| o.active()) { return o.word() }+ if let Some(p) = self.pending { return p.into() }+ if self.failed { return "Failed".into() }+ if self.use_running || self.use_start { return "Use".into() }+ if self.get { return "Get".into() }+ if m.running() { "Running".into() } else if m.downloaded() { "Downloaded".into() } else { String::new() }+ }+}++fn pending_word(action: &str) -> &'static str { match action { "download" => "Downloading", "start" => "Starting", _ => "Stopping" } }++pub fn facts(app: &App, m: &LocalModel, t: Option<&Target>) -> Facts {+ let v = &app.models_view;+ let machine = app.fleet.local_id.as_str();+ let op = v.op_for(machine, m).cloned();+ let active = op.as_ref().is_some_and(Operation::active);+ let busy = v.busy(machine);+ let online = up(app, machine) && v.local.contains_key(machine);+ let other = v.local.get(machine).and_then(|s| s.models.iter().find(|o| o.can_stop && o.id != m.id)).map(|o| o.name.clone());+ let runs = t.is_some_and(|t| can_run(app, &t.engine));+ let served = served_in(v.grids.get(machine), m);+ let in_use = t.is_some_and(|t| m.running() && !t.grid_model.is_empty()+ && (served.as_ref().is_some_and(|(_, id)| id.eq_ignore_ascii_case(&t.grid_model)) || m.id.eq_ignore_ascii_case(&t.grid_model) || m.name.eq_ignore_ascii_case(&t.grid_model)));+ let get = !m.downloaded() && m.can_start && !busy && online;+ let names = |id: &str| m.id.eq_ignore_ascii_case(id) || m.name.eq_ignore_ascii_case(id) || served.as_ref().is_some_and(|(_, s)| s.eq_ignore_ascii_case(id));+ Facts {+ switching: switching_for(app, t).is_some_and(|to| !to.is_empty() && names(to)),+ failed: op.as_ref().is_some_and(Operation::failed),+ pending: v.pending.as_ref().filter(|p| p.0 == machine && p.1 == m.id).map(|p| pending_word(p.2)),+ use_running: runs && m.running() && !active && served.is_some(),+ use_start: runs && m.downloaded() && !m.running() && m.can_start && !busy && online,+ get_use: get && runs && other.is_none(),+ op, in_use, active, busy, get, other, served,+ }+}++// ── sizes and words ──────────────────────────────────────────────────────────────++/// Bytes as a person reads a model's size: `2.7 GB` under ten, `27 GB` above.+pub fn gb(bytes: f64) -> String { let g = bytes / GIB; if g < 9.95 { format!("{g:.1} GB") } else { format!("{:.0} GB", g.round()) } }++/// A context window as people say it: `64K`, `128K` (binary sizes), `200K`, `1M`.+pub fn context_label(tokens: u64) -> String {+ if tokens >= 1_000_000 { let m = format!("{:.1}", tokens as f64 / 1e6); return format!("{}M", m.strip_suffix(".0").unwrap_or(&m)) }+ if tokens % 1024 == 0 { format!("{}K", tokens / 1024) } else { format!("{}K", (tokens as f64 / 1000.0).round() as u64) }+}++fn window_label(seconds: f64) -> String {+ let s = seconds.round() as u64;+ if s > 0 && s % 86400 == 0 { format!("{}d", s / 86400) } else if s > 0 && s % 3600 == 0 { format!("{}h", s / 3600) } else { format!("{}m", (seconds / 60.0).round() as u64) }+}++/// This computer as its owner calls it: `this Mac` on a Mac.+pub fn this_computer() -> &'static str { if cfg!(target_os = "macos") { "this Mac" } else { "this computer" } }++fn capital(s: &str) -> String { let mut c = s.chars(); c.next().map(|f| f.to_uppercase().collect::<String>() + c.as_str()).unwrap_or_default() }++/// `On your machines · this Mac · 64 GB memory · 120 GB free`: this computer's models, then the+/// ones the account's other machines serve.+pub fn local_heading(snap: Option<&Snapshot>) -> String {+ let mut parts = vec!["On your machines".to_string(), this_computer().to_string()];+ if let Some(m) = snap.and_then(|s| s.memory) { parts.push(format!("{} memory", gb(m))) }+ if let Some(d) = snap.and_then(|s| s.free_disk) { parts.push(format!("{} free", gb(d))) }+ parts.join(" · ")+}++/// `Get for this Mac · 64 GB`: the downloads, and the memory they were chosen for.+pub fn catalog_heading(snap: Option<&Snapshot>) -> String {+ let mut h = format!("Get for {}", this_computer());+ if let Some(m) = snap.and_then(|s| s.memory) { h.push_str(&format!(" · {}", gb(m))) }+ h+}++/// A row's size and speed in two columns that line up, then its word: `20 GB ~78 tok/s Get`.+fn columns(size: &str, speed: &str, word: &str) -> String { format!("{size:>6} {speed:>9} {word:>9}") }++fn speed(m: &LocalModel) -> String {+ match (m.running().then_some(m.tok_s).flatten(), m.est_tok_s) {+ (Some(s), _) => format!("{} tok/s", s.round() as u64),+ (None, Some(e)) => format!("~{} tok/s", e.round() as u64),+ _ => String::new(),+ }+}++// ── the rows ─────────────────────────────────────────────────────────────────────++/// The query without the launcher's `:`.+pub fn searched(picker: &Picker) -> &str {+ let q = picker.query.trim_start();+ if picker.prefixed { q.strip_prefix(':').unwrap_or(q) } else { q }+}++pub fn is_row(id: &str) -> bool { id.starts_with("mv:") }++fn note(key: &str, words: &str, group: &str) -> Row {+ Row::new(format!("mv:note:{key}"), words.to_string()).group(group.to_string()).lead(vec![span(" ", Style::default())]).extra("note")+}++fn local_row(app: &App, m: &LocalModel, t: Option<&Target>, group: &str) -> Row {+ let f = facts(app, m, t);+ let word = f.word(m);+ // (No round marks: `✓` in use, `↻` busy, `✗` failed, `▶` running, `·` downloaded, `↓` to get.)+ let (dot, color) = if f.in_use { ("✓ ", theme::accent()) } else if f.active || f.pending.is_some() { ("↻ ", theme::WARN) } else if f.failed { ("✗ ", theme::DANGER) }+ else if m.running() { ("▶ ", theme::ONLINE) } else if m.downloaded() { ("· ", theme::SOFT) } else { ("↓ ", theme::MUTED) };+ let quant = m.quantization().unwrap_or_default();+ Row::new(format!("mv:local:{}", m.id), m.name.clone()).group(group.to_string())+ .extra(format!("{} {quant} {word} local{}", m.id, if m.recommended { " recommended" } else { "" }))+ .lead(vec![span(dot, fg(color))])+ .detail(vec![span(quant, fg(theme::MUTED))])+ .right(columns(&m.size.map(gb).unwrap_or_default(), &speed(m), &word))+}++/// The word a grid model's row ends with: in use, Use, or why not.+fn grid_word(app: &App, x: &GridModel, t: Option<&Target>) -> String {+ match t {+ _ if switching_for(app, t).is_some_and(|to| to.eq_ignore_ascii_case(&x.id)) => SWITCHING.into(),+ Some(t) if t.grid_model.eq_ignore_ascii_case(&x.id) => "✓ In use".into(),+ _ if x.offline.is_some() => "Offline".into(),+ Some(t) if can_run(app, &t.engine) => "Use".into(),+ _ => String::new(),+ }+}++fn grid_row(app: &App, s: &Section, x: &GridModel, t: Option<&Target>, group: &str) -> Row {+ let word = grid_word(app, x, t);+ let (dot, color) = if word.starts_with('✓') { ("✓ ", theme::accent()) } else if x.offline.is_some() { ("· ", theme::MUTED) } else { ("◆ ", theme::TEAL) };+ Row::new(format!("mv:grid:{}\t{}\t{}", s.name, x.node, x.id), x.id.clone()).group(group.to_string())+ .extra(format!("{} {} {} {}", s.name, x.node, if s.own { "local" } else { "shared" }, word))+ .lead(vec![span(dot, fg(color))])+ .detail(vec![span(x.node.clone(), fg(theme::MUTED))])+ .right(format!("{word:>9}"))+}++fn sub_word(app: &App, sub: &Sub, t: Option<&Target>) -> String {+ if t.is_some_and(|t| t.engine == sub.engine) && switching_for(app, t) == Some("") { return SWITCHING.into() }+ match sub_payload(app, sub, t) { Ok(_) => "Use".into(), Err(why) if why == IN_USE => "✓ In use".into(), Err(_) => String::new() }+}++/// Amber once the tightest window is nearly out (the desktop's low water).+const LOW_WATER: f64 = 20.0;++/// The subscription the harness's own login is: its engine's — the account its machine is signed+/// in to, else one with a figure, else any.+fn subscription_for<'a>(app: &App, subs: &'a [Sub], t: &Target) -> Option<&'a Sub> {+ let theirs = app.usage.get(&t.machine).and_then(|u| u.iter().find(|u| u.provider == t.engine)).map(|u| u.account.clone().unwrap_or_default());+ let mine = || subs.iter().filter(|s| s.engine == t.engine);+ mine().find(|s| Some(&s.account) == theirs.as_ref()).or_else(|| mine().find(|s| s.left.is_some())).or_else(|| mine().next())+}++/// A subscription's row: how much is left and whether that is running low, then Use / In use.+fn sub_row(app: &App, sub: &Sub, t: Option<&Target>, group: &str, twin: bool) -> Row {+ let word = sub_word(app, sub, t);+ let low = sub.left.is_some_and(|l| l <= LOW_WATER);+ let health = match sub.left { Some(_) if low => " · Running low", Some(_) => " · Healthy", None => "" };+ let label = if twin && !sub.account.is_empty() { format!("{} · {}", sub.title, sub.account) } else { sub.title.clone() };+ let (dot, color) = if low { ("! ", theme::WARN) } else if word.starts_with('✓') { ("✓ ", theme::accent()) } else { ("◇ ", theme::SOFT) };+ Row::new(format!("mv:sub:{}\t{}", sub.engine, sub.account), label).group(group.to_string())+ .extra(format!("{} {} subscription own login {word}", sub.engine, sub.account))+ .lead(vec![span(dot, fg(color))])+ .detail(vec![span(if sub.account.is_empty() { String::new() } else { format!("key ···{}", sub.account) }, fg(theme::MUTED))])+ .right(format!("{}{health} {word:>9}", sub.status))+}++/// The rows of the Models view, in its sections. [query]: what is typed (a search lists what+/// "More models" and a folded API hide).+pub fn rows(app: &App, query: &str) -> Vec<Row> {+ let searching = !query.trim().is_empty();+ let t = target(app);+ let t = t.as_ref();+ let v = &app.models_view;+ let machine = app.fleet.local_id.clone();+ let snap = v.local.get(&machine);+ let mut out = Vec::new();++ // The harness's own login first — its engine's subscription, how much of it is left, and+ // whether that is running low (the reason to move it onto a model below). With no harness in+ // front, every subscription.+ let subs = subscriptions(app);+ match t {+ Some(t) => out.extend(subscription_for(app, &subs, t).map(|sub| sub_row(app, sub, Some(t), "Subscription", false))),+ None => out.extend(subs.iter().map(|sub| sub_row(app, sub, None, "Subscriptions", subs.iter().filter(|s| s.title == sub.title).count() > 1))),+ }++ // On your machines: this computer's models — running, downloaded, being got right now — then+ // the own grid's models the account's other machines serve.+ let head = local_heading(snap);+ if let Some(t) = t.filter(|t| v.grids.contains_key(&machine) && !can_run(app, &t.engine)) {+ out.push(note("engine", &format!("{} can only run on its own login.", engine_label(&t.engine)), &head));+ }+ match snap {+ None => out.push(note("local", if !up(app, &machine) { "Connect this computer to see its models." } else { v.local_error.get(&machine).map(String::as_str).unwrap_or("Finding models that fit…") }, &head)),+ Some(s) => {+ if let Some(n) = &s.notice { out.push(note("notice", n, &head)) }+ let rank = |m: &LocalModel| if v.op_for(&machine, m).is_some_and(Operation::active) || v.pending.as_ref().is_some_and(|p| p.1 == m.id) { 0 } else if m.running() { 1 } else if m.downloaded() { 2 } else { 3 };+ let mut mine: Vec<(u8, usize, &LocalModel)> = s.models.iter().enumerate().map(|(i, m)| (rank(m), i, m)).filter(|(r, _, _)| *r < 3).collect();+ mine.sort_by_key(|(r, i, _)| (*r, *i));+ let theirs = v.grids.get(&machine).is_some_and(|g| g.sections.iter().any(|s| s.own && !s.models.is_empty()));+ if mine.is_empty() && !theirs && !searching { out.push(note("none", "No models here yet — get one below", &head)) }+ out.extend(mine.into_iter().map(|(_, _, m)| local_row(app, m, t, &head)));+ }+ }++ if let Some(g) = v.grids.get(&machine) {+ // (This computer's own are above, by their local names.)+ let here: Vec<&LocalModel> = snap.map(|s| s.models.iter().filter(|m| m.running()).collect()).unwrap_or_default();+ for s in g.sections.iter().filter(|s| s.own) {+ for x in s.models.iter().filter(|x| !here.iter().any(|m| x.id.eq_ignore_ascii_case(&m.id) || x.id.eq_ignore_ascii_case(&m.name))) {+ out.push(grid_row(app, s, x, t, &head));+ }+ }+ for s in g.sections.iter().filter(|s| !s.own) {+ let words = section_words(s, v.asking.contains(&s.name));+ // (A grid with no model to show is not shown — "Nobody was serving here…" says nothing+ // you can use; one that is resting with models to wake keeps its "Show models".)+ let asleep_empty = s.state == "asleep" && !words.offer_wake && !v.asking.contains(&s.name);+ if s.models.is_empty() && (searching || asleep_empty || (words.subtitle.is_none() && words.sentence.is_none() && !words.offer_wake)) { continue }+ let head = match &words.subtitle { Some(sub) => format!("Shared · {} · {sub}", s.name), None => format!("Shared · {}", s.name) };+ if !searching {+ if let Some(sentence) = &words.sentence { out.push(note(&format!("grid:{}", s.name), sentence, &head)) }+ if words.offer_wake {+ out.push(Row::new(format!("mv:wake:{}", s.name), "Show models").group(head.clone()).extra(format!("{} wake", s.name))+ .lead(vec![span("↻ ", fg(theme::accent()))]).right("usually 15–40 s"));+ }+ }+ out.extend(s.models.iter().map(|x| grid_row(app, s, x, t, &head)));+ }+ if !g.reachable && !searching { out.push(note("shared", "Shared models are unavailable.", "Shared")) }+ }++ // APIs saved on this computer: each folds its models until Enter (or a search) opens it.+ match &v.apis {+ Some(Err(why)) if !searching => out.push(note("apis", why, "APIs")),+ Some(Ok(apis)) => for api in apis {+ let listed = v.api_models.get(&api.id);+ let open = v.api_open.contains(&api.id) || searching;+ let hint = match listed { _ if !api.serves_models() => "Tools".to_string(), Some(Ok(l)) if !l.is_empty() => format!("{} model{}", l.len(), if l.len() == 1 { "" } else { "s" }), None => "Loading…".into(), _ => "Tools".into() };+ out.push(Row::new(format!("mv:api:{}", api.id), api.name.clone()).group("APIs").extra(format!("{} api", api.host()))+ .lead(vec![span(if open && api.serves_models() { "▾ " } else { "▸ " }, fg(theme::MUTED))])+ .detail(vec![span(api.host(), fg(theme::MUTED))]).right(hint));+ if !open { continue }+ if let Some(Ok(models)) = listed {+ for m in models {+ let word = match api_payload(app, api, &m.id, t) {+ _ if switching_for(app, t) == Some(m.id.as_str()) => SWITCHING.to_string(),+ Ok(_) => "Use".to_string(), Err(w) if w == IN_USE => "✓ In use".into(), Err(_) => String::new(),+ };+ out.push(Row::new(format!("mv:apimodel:{}\t{}", api.id, m.id), m.id.clone()).group("APIs")+ .extra(format!("{} {} api", api.name, m.name.clone().unwrap_or_default()))+ .lead(vec![span(" ", Style::default()), span(if word.starts_with('✓') { "✓ " } else { "· " }, fg(if word.starts_with('✓') { theme::accent() } else { theme::MUTED }))])+ .detail(vec![span(m.context.map(|w| format!("{} context", context_label(w))).unwrap_or_default(), fg(theme::MUTED))])+ .right(format!("{word:>9}")));+ }+ }+ },+ _ => {}+ }++ // The downloads that fit this computer, in the daemon's order (its best for a coding agent+ // first): five, then "More models".+ if let Some(s) = snap {+ let get: Vec<&LocalModel> = s.models.iter().filter(|m| !m.downloaded() && !v.op_for(&machine, m).is_some_and(Operation::active) && v.pending.as_ref().is_none_or(|p| p.1 != m.id)).collect();+ let head = catalog_heading(snap);+ let shown = if v.more || searching { get.len() } else { get.len().min(SHOWN_DOWNLOADS) };+ out.extend(get.iter().take(shown).map(|m| local_row(app, m, t, &head)));+ if !searching && get.len() > SHOWN_DOWNLOADS {+ let label = if v.more { "Show fewer".to_string() } else { format!("More models ({})", get.len() - SHOWN_DOWNLOADS) };+ out.push(Row::new("mv:more", label).group(head).extra("more models").lead(vec![span(if v.more { "− " } else { "+ " }, fg(theme::accent()))]));+ }+ }+ out+}++/// The row the harness is on now, if the view lists it: where the cursor starts.+pub fn in_use_row(rows: &[Row]) -> Option<String> { rows.iter().find(|r| is_row(&r.id) && r.right.trim_end().ends_with("✓ In use")).map(|r| r.id.clone()) }++// ── what Enter and ^S do ─────────────────────────────────────────────────────────++/// Why Use does nothing on the row the harness is already on.+const IN_USE: &str = "This harness is on it";+/// The word on a row, and on the pane, while the harness moves onto it.+pub const SWITCHING: &str = "Switching…";+const NO_HARNESS: &str = "Focus a harness to move it onto a model";++/// What a key on a row comes to — decided here, done by [run]; the tests read the plan.+#[derive(Clone, Debug, PartialEq)]+pub enum Plan {+ Nothing,+ Say(String),+ /// Something that writes and costs: said first, done on the same key again (the picker's+ /// `armed`).+ Arm(String, Box<Plan>),+ /// `agent_retarget` on [machine] with [payload] (its `agentId` in it).+ Retarget { machine: String, payload: Value, name: String },+ /// A local model got ready for the harness and the harness moved onto it.+ Use { model: String, download: bool },+ /// A download, start or stop alone (no harness to move).+ Act { model: String, action: &'static str },+ Wake(String),+ More,+ Api(String),+}++fn local_model(app: &App, id: &str) -> Option<LocalModel> { app.models_view.local.get(&app.fleet.local_id)?.models.iter().find(|m| m.id == id).cloned() }++fn sub_payload(app: &App, sub: &Sub, t: Option<&Target>) -> Result<Value, String> {+ let t = t.ok_or(NO_HARNESS)?;+ if t.engine != sub.engine { return Err(format!("Use this subscription in a {} harness.", engine_label(&sub.engine))) }+ // The harness's machine's own login for that engine, when its usage was read: the same account.+ if let Some(theirs) = app.usage.get(&t.machine).and_then(|u| u.iter().find(|u| u.provider == sub.engine)) {+ if theirs.account.clone().unwrap_or_default() != sub.account { return Err("This account is not signed in on the harness's machine.".into()) }+ }+ if t.grid_model.is_empty() { return Err(IN_USE.into()) }+ Ok(json!({ "agentId": t.agent, "clearGrid": true }))+}++/// A URL's root as the daemon compares two: no trailing slash, no `/v1`.+fn url_root(url: &str) -> &str { let u = url.trim_end_matches('/'); u.strip_suffix("/v1").unwrap_or(u) }++fn api_payload(app: &App, api: &Api, model: &str, t: Option<&Target>) -> Result<Value, String> {+ let t = t.ok_or(NO_HARNESS)?;+ if !api.serves_models() { return Err("Tools only".into()) }+ if t.machine != app.fleet.local_id { return Err("Only a harness on this computer can use its saved APIs.".into()) }+ if !can_run(app, &t.engine) { return Err(format!("{} runs only on its own login", engine_label(&t.engine))) }+ if t.grid_model == model && !t.base_url.is_empty() && url_root(&t.base_url) == url_root(&api.base_url) { return Err(IN_USE.into()) }+ Ok(json!({ "agentId": t.agent, "apiConnection": api.id, "apiModel": model }))+}++/// What Enter does on row [id].+pub fn plan_enter(app: &App, id: &str) -> Plan {+ let t = target(app);+ let t = t.as_ref();+ let v = &app.models_view;+ let say = |s: &str| Plan::Say(s.to_string());+ if id == "mv:more" { return Plan::More }+ if let Some(name) = id.strip_prefix("mv:wake:") { return if v.asking.contains(name) { say(STARTING_UP_WAIT) } else { Plan::Wake(name.to_string()) } }+ if let Some(key) = id.strip_prefix("mv:api:") { return Plan::Api(key.to_string()) }+ if let Some(rest) = id.strip_prefix("mv:apimodel:") {+ let Some((api, model)) = rest.split_once('\t') else { return Plan::Nothing };+ let Some(api) = v.apis.as_ref().and_then(|a| a.as_ref().ok()).and_then(|l| l.iter().find(|x| x.id == api)) else { return Plan::Nothing };+ return match api_payload(app, api, model, t) { Ok(payload) => Plan::Retarget { machine: app.fleet.local_id.clone(), payload, name: model.to_string() }, Err(why) => Plan::Say(why) };+ }+ if let Some(rest) = id.strip_prefix("mv:sub:") {+ let Some(sub) = subscriptions(app).into_iter().find(|s| format!("{}\t{}", s.engine, s.account) == rest) else { return Plan::Nothing };+ let machine = t.map(|t| t.machine.clone()).unwrap_or_default();+ return match sub_payload(app, &sub, t) { Ok(payload) => Plan::Retarget { machine, payload, name: format!("its {} login", sub.title) }, Err(why) => Plan::Say(why) };+ }+ if let Some(rest) = id.strip_prefix("mv:grid:") {+ let mut parts = rest.splitn(3, '\t');+ let (Some(grid), Some(_node), Some(model)) = (parts.next(), parts.next(), parts.next()) else { return Plan::Nothing };+ let offline = v.grids.get(&app.fleet.local_id).and_then(|g| g.sections.iter().find(|s| s.name == grid)).and_then(|s| s.models.iter().find(|x| x.id == model)).and_then(|x| x.offline.clone());+ let Some(t) = t else { return say(NO_HARNESS) };+ if t.grid_model.eq_ignore_ascii_case(model) { return say(IN_USE) }+ if !can_run(app, &t.engine) { return Plan::Say(format!("{} runs only on its own login", engine_label(&t.engine))) }+ let go = Plan::Retarget { machine: t.machine.clone(), payload: json!({ "agentId": t.agent, "gridModel": model, "gridName": grid }), name: model.to_string() };+ return match offline { Some(who) => Plan::Arm(format!("{who} seems offline — Enter again to switch anyway"), Box::new(go)), None => go };+ }+ let Some(model) = id.strip_prefix("mv:local:") else { return Plan::Nothing };+ let Some(m) = local_model(app, model) else { return say("This model is gone. Try again in a moment.") };+ let f = facts(app, &m, t);+ if f.in_use { return say(IN_USE) }+ if let Some(u) = v.using.as_ref().filter(|u| u.model == m.id) { return Plan::Say(using_label(app, u)) }+ if f.active || f.pending.is_some() || f.busy { return say("Wait for the current model operation to finish.") }+ if let (true, Some(t), Some((grid, served))) = (f.use_running, t, f.served.clone()) {+ return Plan::Retarget { machine: t.machine.clone(), payload: json!({ "agentId": t.agent, "gridModel": served, "gridName": grid }), name: m.name.clone() };+ }+ if m.running() {+ return match t {+ None => say("Running — ^S stops it"),+ Some(t) if !can_run(app, &t.engine) => Plan::Say(format!("{} runs only on its own login", engine_label(&t.engine))),+ Some(_) => say("Not serving yet — try again in a moment"),+ };+ }+ if m.downloaded() {+ if let Some(o) = &f.other { return Plan::Say(format!("Stop {o} first: one local model runs at a time — ^S on it")) }+ if f.use_start { return Plan::Use { model: m.id.clone(), download: false } }+ return match t {+ None if m.can_start && up(app, &app.fleet.local_id) => Plan::Act { model: m.id.clone(), action: "start" },+ Some(t) if !can_run(app, &t.engine) => Plan::Say(format!("{} runs only on its own login", engine_label(&t.engine))),+ _ => say("It cannot start now. Try again in a moment."),+ };+ }+ if !f.get { return say(if !m.can_start { "This model does not fit here now." } else { "It cannot be got now. Try again in a moment." }) }+ let supports = v.local.get(&app.fleet.local_id).is_some_and(|s| s.supports_download);+ let go = if f.get_use { Plan::Use { model: m.id.clone(), download: true } } else { Plan::Act { model: m.id.clone(), action: if supports { "download" } else { "start" } } };+ // A download is gigabytes: the first Enter says what the second will do.+ let size = m.size.map(gb).map(|s| format!(" ({s})")).unwrap_or_default();+ let then = if f.get_use { " — then it starts and this harness moves onto it" } else { "" };+ Plan::Arm(format!("Enter again to get {}{size}{then}", m.name), Box::new(go))+}++/// What ^S does on row [id]: stop a local model (asked first).+pub fn plan_stop(app: &App, id: &str) -> Plan {+ let Some(m) = id.strip_prefix("mv:local:").and_then(|model| local_model(app, model)) else { return Plan::Nothing };+ let f = facts(app, &m, None);+ if f.busy { return Plan::Say("Wait for the current model operation to finish.".into()) }+ if !m.can_stop { return Plan::Say(if m.running() { "Other models share its engine — stop it from the desktop's Model Manager".into() } else { "It is not running".into() }) }+ Plan::Arm(format!("^S again stops {} — the download is kept", m.name), Box::new(Plan::Act { model: m.id.clone(), action: "stop" }))+}++/// Enter (or ^S, [stop]) on row [id] of the view: planned, then done.+pub fn choose(app: &mut App, picker: &mut Picker, id: &str, stop: bool) {+ let key = format!("{id}\u{1f}{}", if stop { "stop" } else { "enter" });+ let plan = if stop { plan_stop(app, id) } else { plan_enter(app, id) };+ run(app, picker, plan, &key);+}++fn run(app: &mut App, picker: &mut Picker, plan: Plan, key: &str) {+ if !matches!(plan, Plan::Arm(..)) { picker.armed = None }+ match plan {+ Plan::Nothing => {}+ Plan::Say(s) => picker.say(s),+ Plan::Arm(words, then) => {+ if picker.armed.as_deref() == Some(key) { picker.armed = None; run(app, picker, *then, key) }+ else { picker.armed = Some(key.to_string()); picker.say(words) }+ }+ Plan::Retarget { machine, payload, name } => {+ let who = payload["agentId"].as_str().and_then(|a| app.fleet.agent(&machine, a)).map(|a| a.name.clone()).unwrap_or_else(|| "the harness".into());+ picker.say(format!("Switching {who} to {name}…"));+ retarget(app, &machine, payload, &name, false);+ }+ Plan::Use { model, download } => { start_use(app, &model, download); if let Some(u) = app.models_view.using.clone() { picker.say(using_label(app, &u)) } }+ Plan::Act { model, action } => { picker.say(format!("{}…", pending_word(action))); act(app, &model, action) }+ Plan::Wake(name) => { wake(app, &name); picker.say(STARTING_UP_WAIT) }+ Plan::More => app.models_view.more = !app.models_view.more,+ Plan::Api(key) => {+ let v = &mut app.models_view;+ if !v.api_open.remove(&key) { v.api_open.insert(key.clone()); if !v.api_models.contains_key(&key) { read_api_models(app, &key) } }+ }+ }+}++/// What a Use is doing, for the footer: `Downloading 42%…`, `Starting…`, `Moving it…`.+pub fn using_label(app: &App, u: &Use) -> String {+ let m = local_model(app, &u.model);+ let op = m.as_ref().and_then(|m| app.models_view.op_for(&app.fleet.local_id, m));+ match (u.step, op) {+ (Step::Get, Some(o)) if o.active() && o.stage == "downloading" => format!("{}…", o.word()),+ (Step::Get, _) => format!("Getting {}…", u.name),+ (Step::Start, _) => format!("Starting {}…", u.name),+ (Step::Serve, _) => format!("Waiting for {} to serve…", u.name),+ (Step::Switch, _) => format!("Moving the harness onto {}…", u.name),+ }+}++// ── talking to the daemon ────────────────────────────────────────────────────────++/// One request of the view's to [machine]'s daemon, its reply applied on the loop. False when the+/// machine is not connected (nothing was sent).+fn rpc(app: &mut App, machine: &str, ty: &'static str, payload: Value, wait: Duration, then: impl FnOnce(&mut App, Result<Value, RpcError>) + Send + 'static) -> bool {+ // Under test no daemon is ever asked: the request is written down, and the test answers it.+ #[cfg(test)]+ {+ let _ = (wait, then);+ app.models_view.sent.push((machine.to_string(), ty.to_string(), payload));+ true+ }+ #[cfg(not(test))]+ {+ let Some(link) = app.link(machine) else { return false };+ app.spawn(async move { link.rpc(ty, payload, wait).await }, then);+ true+ }+}++/// A daemon's refusal in its own words (the sentence it put in `error`, or its detail).+fn why(e: &RpcError) -> String { if e.detail.is_empty() { e.code.clone() } else { e.detail.clone() } }++fn read_local(app: &mut App, machine: &str) {+ app.models_view.reading.insert(machine.to_string());+ let m = machine.to_string();+ if !rpc(app, machine, "grid_fleet_models_list", json!({ "refresh": false }), Duration::from_secs(30), move |app, r| on_local(app, &m, r)) {+ app.models_view.reading.remove(machine);+ app.models_view.read_at.insert(machine.to_string(), Instant::now());+ }+}++/// A read of [machine]'s local models answered.+pub fn on_local(app: &mut App, machine: &str, reply: Result<Value, RpcError>) {+ let v = &mut app.models_view;+ v.reading.remove(machine);+ v.read_at.insert(machine.to_string(), Instant::now());+ match reply.ok().as_ref().and_then(parse_local) {+ Some(s) => {+ // The daemon's receipt supersedes this view's acknowledgement.+ if v.op.as_ref().is_some_and(|(m, o)| m == machine && (!s.busy || s.models.iter().any(|x| x.operation.as_ref().is_some_and(|y| y.id == o.id)))) { v.op = None }+ v.local_error.remove(machine);+ v.local.insert(machine.to_string(), s);+ }+ None => { v.local_error.insert(machine.to_string(), "Models are unavailable. Try again.".into()); }+ }+ advance(app);+ crate::input::refill(app);+}++fn read_grids(app: &mut App, machine: &str) {+ app.models_view.grids_reading.insert(machine.to_string());+ let m = machine.to_string();+ // rowState: offline rows come as `unavailable`, and this window's pushes in the same form.+ if !rpc(app, machine, "grid_models_list", json!({ "rowState": true }), Duration::from_secs(30), move |app, r| on_grids(app, &m, r)) {+ app.models_view.grids_reading.remove(machine);+ app.models_view.grids_at.insert(machine.to_string(), Instant::now());+ }+}++/// A read of the grids answered. One that could not reach the machine keeps what was shown.+pub fn on_grids(app: &mut App, machine: &str, reply: Result<Value, RpcError>) {+ let v = &mut app.models_view;+ v.grids_reading.remove(machine);+ v.grids_at.insert(machine.to_string(), Instant::now());+ match reply {+ Ok(r) => { v.grids.insert(machine.to_string(), parse_grids(&r)); }+ Err(_) => { v.grids.entry(machine.to_string()).or_insert_with(|| Grids { reachable: false, ..Default::default() }); }+ }+ advance(app);+ crate::input::refill(app);+}++/// `grid_models_changed`: the daemon's picture changed — the whole document, taken as it is.+pub fn on_push(app: &mut App, machine: &str, payload: &Value) {+ app.models_view.grids.insert(machine.to_string(), parse_grids(payload));+ app.models_view.grids_at.insert(machine.to_string(), Instant::now());+ advance(app);+ crate::input::refill(app);+}++/// "Show models": wake a resting section. The daemon answers at once with it `waking`; the view+/// reads again every 5 s until it is up, or a minute has passed.+pub fn wake(app: &mut App, name: &str) {+ let machine = app.fleet.local_id.clone();+ if !app.models_view.asking.insert(name.to_string()) { return }+ let (m, n) = (machine.clone(), name.to_string());+ rpc(app, &machine, "grid_models_list", json!({ "rowState": true, "wake": [name] }), Duration::from_secs(12), move |app, r| on_wake(app, &m, &n, r));+}++pub fn on_wake(app: &mut App, machine: &str, name: &str, reply: Result<Value, RpcError>) {+ let v = &mut app.models_view;+ v.asking.remove(name);+ if let Ok(r) = reply {+ let grids = parse_grids(&r);+ if grids.waking() { v.follow_until = Some(Instant::now() + WAKE_FOR) }+ v.grids.insert(machine.to_string(), grids);+ v.grids_at.insert(machine.to_string(), Instant::now());+ }+ crate::input::refill(app);+}++fn read_apis(app: &mut App) {+ let machine = app.fleet.local_id.clone();+ rpc(app, &machine, "api_connections", json!({ "action": "list" }), Duration::from_secs(20), on_apis);+}++pub fn on_apis(app: &mut App, reply: Result<Value, RpcError>) {+ let list = match reply { Ok(r) => parse_apis(&r), Err(e) => Err(if e.detail.is_empty() { "APIs are unavailable. Try again.".into() } else { e.detail.clone() }) };+ let serving: Vec<String> = list.as_ref().map(|l| l.iter().filter(|a| a.serves_models()).map(|a| a.id.clone()).collect()).unwrap_or_default();+ app.models_view.apis = Some(list);+ for id in serving { if !app.models_view.api_models.contains_key(&id) { read_api_models(app, &id) } }+ crate::input::refill(app);+}++fn read_api_models(app: &mut App, id: &str) {+ let machine = app.fleet.local_id.clone();+ let key = id.to_string();+ rpc(app, &machine, "api_connections", json!({ "action": "models", "id": id }), Duration::from_secs(25), move |app, r| on_api_models(app, &key, r));+}++pub fn on_api_models(app: &mut App, id: &str, reply: Result<Value, RpcError>) {+ let listed = match reply {+ Ok(r) => parse_api_models(&r).ok_or_else(|| "Update Harness on this computer to use API models.".to_string()),+ Err(e) => Err(if e.detail.is_empty() { "Models are unavailable. Try again.".into() } else { e.detail.clone() }),+ };+ app.models_view.api_models.insert(id.to_string(), listed);+ crate::input::refill(app);+}++/// A download, start or stop of this computer's [model].+fn act(app: &mut App, model: &str, action: &'static str) {+ let machine = app.fleet.local_id.clone();+ app.models_view.pending = Some((machine.clone(), model.to_string(), action));+ app.models_view.use_error = None;+ let ty = match action { "download" => "grid_fleet_model_download", "start" => "grid_fleet_model_start", _ => "grid_fleet_model_stop" };+ let m = machine.clone();+ if !rpc(app, &machine, ty, json!({ "modelId": model }), Duration::from_secs(30), move |app, r| on_act(app, &m, r)) {+ app.models_view.pending = None;+ app.say("This computer is not connected", theme::WARN);+ }+}++/// The daemon took (or refused) a download, start or stop: read again for its receipt.+pub fn on_act(app: &mut App, machine: &str, reply: Result<Value, RpcError>) {+ app.models_view.pending = None;+ match reply {+ Ok(r) => app.models_view.op = Operation::parse(&r["operation"]).map(|o| (machine.to_string(), o)),+ Err(e) => { let w = why(&e); if app.models_view.using.is_some() { fail(app, &w) } else { app.say(w, theme::WARN) } }+ }+ read_local(app, machine);+ advance(app);+ crate::input::refill(app);+}++/// Move the harness in [payload] (`agent_retarget`): its pane restarts on the model.+fn retarget(app: &mut App, machine: &str, payload: Value, name: &str, job: bool) {+ let n = name.to_string();+ let agent = payload["agentId"].as_str().unwrap_or("").to_string();+ // Where it goes: a grid's or an API's model, or (clearGrid) back to its own login.+ let to = payload["gridModel"].as_str().or_else(|| payload["apiModel"].as_str()).unwrap_or("").to_string();+ app.models_view.switching = Some(Switch { machine: machine.to_string(), agent, to, name: name.to_string(), since: Instant::now() });+ if !rpc(app, machine, "agent_retarget", payload, Duration::from_secs(60), move |app, r| on_retarget(app, &n, job, r)) {+ app.models_view.switching = None;+ app.say("That machine is not connected", theme::WARN);+ if job { app.models_view.using = None }+ }+}++/// A refusal of `agent_retarget` in words a person can act on.+fn retarget_error(e: &RpcError) -> String {+ match e.code.as_str() {+ _ if !e.detail.is_empty() => e.detail.clone(),+ "UNSUPPORTED_ON_REMOTE" => "That machine cannot switch models — update Harness there.".into(),+ "OWNER_REQUIRED" => "Only this computer's owner can use its saved APIs.".into(),+ "GRID_UNAVAILABLE" => "Could not read the machine's grid. Try again.".into(),+ "MISSING_AGENT_ID" | "AGENT_NOT_FOUND" => "That harness is gone.".into(),+ code => code.to_string(),+ }+}++/// The daemon moved the harness (its pane restarts on the model — "Switching…" stays until its+/// frame says so), or said why not.+pub fn on_retarget(app: &mut App, name: &str, job: bool, reply: Result<Value, RpcError>) {+ if job { app.models_view.using = None }+ let who = app.models_view.switching.as_ref().and_then(|s| app.fleet.agent(&s.machine, &s.agent)).map(|a| a.name.clone()).unwrap_or_else(|| "the harness".into());+ match reply {+ Ok(_) => app.say(format!("Switching {who} to {name}…"), theme::ONLINE),+ Err(e) => {+ let w = format!("Could not switch {who} to {name}: {}", retarget_error(&e));+ if let Some(s) = app.models_view.switching.take() { app.models_view.use_error = Some((format!("mv:switch:{}", s.to), w.clone())) }+ app.say(w, theme::DANGER);+ }+ }+ crate::input::refill(app);+}++// ── Use, step by step ────────────────────────────────────────────────────────────++/// What a Use does next, from what the daemon last said.+#[derive(Clone, Debug, PartialEq)]+pub enum Next { Wait, Start, Serve, Retarget { grid: String, model: String }, Fail(String) }++/// Where [job] goes from here, given this computer's models ([snap]), the operation on its model+/// ([op]), whether a request is still out ([pending]) and the grids ([grids]).+pub fn next(job: &Use, snap: Option<&Snapshot>, op: Option<&Operation>, pending: bool, grids: Option<&Grids>, now: Instant) -> Next {+ if pending { return Next::Wait }+ let m = snap.and_then(|s| s.models.iter().find(|m| m.id == job.model));+ let active = op.is_some_and(Operation::active);+ let late = now.saturating_duration_since(job.since) > USE_WAIT;+ const STILL: &str = "The model is still starting. Try Enter again when it is ready.";+ match job.step {+ // A download takes as long as it takes: no deadline, its progress on the row.+ Step::Get => {+ if let Some(o) = op.filter(|o| o.failed()) { return Next::Fail(o.error.clone().unwrap_or_else(|| "Could not download this model. Try again.".into())) }+ match m { Some(m) if m.downloaded() && !active && !snap.is_some_and(|s| s.busy) => if m.running() { Next::Serve } else { Next::Start }, _ => Next::Wait }+ }+ Step::Start => {+ if let Some(o) = op.filter(|o| o.failed()) { return Next::Fail(o.error.clone().unwrap_or_else(|| "Could not start this model. Try again.".into())) }+ if m.is_some_and(|m| m.running()) && !active { return Next::Serve }+ if late { Next::Fail(STILL.into()) } else { Next::Wait }+ }+ Step::Serve => {+ if let Some((grid, model)) = m.and_then(|m| served_in(grids, m)) { return Next::Retarget { grid, model } }+ if late { Next::Fail(STILL.into()) } else { Next::Wait }+ }+ Step::Switch => Next::Wait,+ }+}++/// Use on [model]: download it (or start it), then carry on from each reply (see [advance]).+fn start_use(app: &mut App, model: &str, download: bool) {+ let Some(t) = target(app) else { return };+ let Some(m) = local_model(app, model) else { return };+ let supports = app.models_view.local.get(&app.fleet.local_id).is_some_and(|s| s.supports_download);+ app.models_view.using = Some(Use { model: m.id.clone(), name: m.name.clone(), machine: t.machine, agent: t.agent, step: if download { Step::Get } else { Step::Start }, since: Instant::now() });+ act(app, &m.id, if download && supports { "download" } else { "start" });+}++fn fail(app: &mut App, why: &str) {+ let Some(job) = app.models_view.using.take() else { return };+ app.models_view.use_error = Some((format!("mv:local:{}", job.model), why.to_string()));+ app.say(format!("{}: {why}", job.name), theme::WARN);+}++/// Take the Use on as far as what the daemon has said allows.+pub fn advance(app: &mut App) {+ let Some(job) = app.models_view.using.clone() else { return };+ let machine = app.fleet.local_id.clone();+ let v = &app.models_view;+ let snap = v.local.get(&machine);+ let m = snap.and_then(|s| s.models.iter().find(|m| m.id == job.model));+ let op = match m { Some(m) => v.op_for(&machine, m).cloned(), None => v.op.as_ref().filter(|(_, o)| o.model == job.model).map(|(_, o)| o.clone()) };+ let pending = v.pending.as_ref().is_some_and(|p| p.1 == job.model);+ let step = |app: &mut App, step: Step| if let Some(u) = app.models_view.using.as_mut() { u.step = step; u.since = Instant::now() };+ match next(&job, snap, op.as_ref(), pending, v.grids.get(&machine), Instant::now()) {+ Next::Wait => {}+ Next::Start => { step(app, Step::Start); act(app, &job.model, "start") }+ Next::Serve => { step(app, Step::Serve); read_grids(app, &machine) }+ Next::Retarget { grid, model } => {+ step(app, Step::Switch);+ retarget(app, &job.machine, json!({ "agentId": job.agent, "gridModel": model, "gridName": grid }), &job.name, true);+ }+ Next::Fail(why) => fail(app, &why),+ }+}++// ── opening, polling, pushes ─────────────────────────────────────────────────────++/// The view opened: read what it shows now (what was read in the last 20 s of the grids is kept).+pub fn open(app: &mut App) {+ let machine = app.fleet.local_id.clone();+ if machine.is_empty() || app.link(&machine).is_none() { return }+ if !app.models_view.reading.contains(&machine) { read_local(app, &machine) }+ if !app.models_view.grids_reading.contains(&machine) && due(app.models_view.grids_at.get(&machine), Duration::from_secs(20), Instant::now()) { read_grids(app, &machine) }+ read_apis(app);+}++/// Whether the view is still reading what it shows (its spinner turns).+pub fn loading(app: &App) -> bool { !app.models_view.reading.is_empty() || !app.models_view.grids_reading.is_empty() }++/// Every tick: read this computer's models as often as [poll_every] says, the grids as often as+/// [grids_every] says, and take a Use on (its deadlines).+pub fn tick(app: &mut App) {+ let open = matches!(&app.modal, Some(crate::modal::Modal::Picker { kind: crate::modal::PickerKind::Models, .. }));+ app.models_view.starts.retain(|_, at| at.elapsed() < START_CAP);+ if app.models_view.switching.as_ref().is_some_and(|s| switched(app, s)) { app.models_view.switching = None }+ let machine = app.fleet.local_id.clone();+ if machine.is_empty() || app.link(&machine).is_none() { return }+ let now = Instant::now();+ let v = &app.models_view;+ let busy = v.busy(&machine) || v.using.is_some();+ let local_due = !v.reading.contains(&machine) && due(v.read_at.get(&machine), poll_every(open, busy), now);+ let serving = v.using.as_ref().is_some_and(|u| u.step == Step::Serve);+ let waking = v.follow_until.is_some_and(|t| now < t) && v.grids.get(&machine).is_some_and(Grids::waking);+ let grids_due = !v.grids_reading.contains(&machine) && grids_every(open, serving, waking).is_some_and(|e| due(v.grids_at.get(&machine), e, now));+ if !waking { app.models_view.follow_until = None }+ if local_due { read_local(app, &machine) }+ if grids_due { read_grids(app, &machine) }+ advance(app);+}++// ── the pane's note ──────────────────────────────────────────────────────────────++/// A turn event of a harness: a message sent while its model's computers rest starts the pane's+/// "Starting up…"; the model answering (or the turn ending) ends it.+pub fn watch_turn(app: &mut App, machine: &str, ty: &str, payload: &Value) {+ let answered = matches!(ty, "text_delta" | "tool_start" | "turn_ended" | "done" | "agent_deleted");+ if !answered && ty != "turn_started" { return }+ let flag = |k: &str| payload.get(k).and_then(Value::as_bool).unwrap_or(false);+ let Some(a) = app.fleet.event_agent(machine, payload) else { return };+ let (key, resting) = (a.key(), matches!(a.grid_state.as_str(), "asleep" | "waking"));+ if answered { app.models_view.starts.remove(&key); return }+ // A turn picked back up at attach, or a sub-agent's, is not a message sent now.+ if flag("replay") || flag("subagent") || !resting { return }+ app.models_view.starts.entry(key).or_insert_with(Instant::now);+}++/// What a harness's pane heading says about its model, when it will not answer now: waiting on+/// its resting computers, or the daemon's note (`grid.note`) — offline, or not served (then which+/// key picks another).+pub fn pane_note(app: &App, machine: &str, agent: &str) -> Option<String> {+ if let Some(s) = app.models_view.switching.as_ref().filter(|s| s.machine == machine && s.agent == agent && !switched(app, s)) {+ return Some(format!("Switching to {}…", s.name));+ }+ if let Some(at) = app.models_view.starts.get(&(machine.to_string(), agent.to_string())) {+ let e = at.elapsed();+ if e < START_STILL { return Some("Starting up…".into()) }+ if e < START_CAP { return Some("Still starting — this can take up to a minute".into()) }+ }+ let (reason, model, who) = app.fleet.agent(machine, agent)?.grid_note.clone()?;+ match reason.as_str() {+ "offline" => Some(format!("{who} seems offline — {model} won't answer until it's back")),+ "not_served" => Some(format!("{model} isn't being served right now · Pick another: {}", app.keymap.hint("choose-tree -i").unwrap_or_else(|| "Models…".into()))),+ _ => None,+ }+}++// ── the preview ──────────────────────────────────────────────────────────────────++fn kv(k: &str, v: impl Into<String>) -> Line<'static> { Line::from(vec![span(format!("{k:<9}"), Style::default().add_modifier(Modifier::DIM)), Span::raw(v.into())]) }+fn bold(t: impl Into<String>) -> Line<'static> { Line::from(span(t, Style::default().add_modifier(Modifier::BOLD))) }+fn warn(t: impl Into<String>) -> Line<'static> { Line::from(span(t, fg(theme::WARN))) }+fn dim(t: impl Into<String>) -> Line<'static> { Line::from(span(t, Style::default().add_modifier(Modifier::DIM))) }++/// The preview of row [id]: what decides between models, and what Enter does.+pub fn preview(app: &App, id: &str) -> Vec<Line<'static>> {+ let t = target(app);+ let t = t.as_ref();+ let v = &app.models_view;+ let machine = app.fleet.local_id.clone();+ // Why its last Use or switch failed: by the row, or by the model the switch went to.+ let failed = |to: &str| v.use_error.as_ref().filter(|(row, _)| row == id || *row == format!("mv:switch:{to}")).map(|(_, w)| warn(w.clone()));+ if let Some(model) = id.strip_prefix("mv:local:") {+ let Some(m) = local_model(app, model) else { return vec![dim("(gone)")] };+ let snap = v.local.get(&machine);+ let f = facts(app, &m, t);+ let failed = failed(f.served.as_ref().map(|(_, s)| s.as_str()).unwrap_or(&m.id));+ let active = f.op.as_ref().is_some_and(Operation::active);+ let status = if let Some(o) = f.op.as_ref().filter(|o| o.active()) { o.word() } else if let Some(p) = f.pending { p.to_string() } else if f.failed { "Failed · try again".into() }+ else if m.running() { "Running".into() } else if m.downloaded() { "Downloaded".into() } else { "Not downloaded".into() };+ let status = if f.switching { format!("{SWITCHING} this harness is moving onto it") } else if f.in_use { format!("{status} · this harness is on it") } else { status };+ let mut out = vec![bold(m.name.clone()), Line::raw(status)];+ out.extend(failed);+ out.push(Line::raw(""));+ let here = this_computer();+ if let Some(size) = m.size {+ let free = snap.and_then(|s| s.free_disk).filter(|_| !m.downloaded()).map(|d| format!(" · {} free", gb(d))).unwrap_or_default();+ out.push(kv(if m.downloaded() { "Size" } else { "Download" }, format!("{}{free}", gb(size))));+ if let Some(mem) = snap.and_then(|s| s.memory) { out.push(kv("Memory", format!("{} · {here} has {}", if size <= mem { "fits".to_string() } else { format!("needs {}", gb(size)) }, gb(mem)))) }+ }+ match (m.running().then_some(m.tok_s).flatten(), m.est_tok_s) {+ (Some(s), _) => out.push(kv("Speed", format!("{s:.1} tok/s"))),+ (None, Some(e)) => out.push(kv("Speed", format!("~{} tok/s on {here} (estimate)", e.round() as u64))),+ _ => {}+ }+ if let Some(w) = m.context { out.push(kv("Context", format!("{} window", context_label(w as u64)))) }+ if let Some(p) = m.params_b { out.push(kv("Params", format!("{p}B"))) }+ out.push(kv("Quant", m.quantization().unwrap_or_else(|| "—".into())));+ out.push(kv("Machine", capital(here)));+ if let (true, Some(r), Some(w)) = (m.running(), m.requests, m.window_secs) { out.push(kv("Window", format!("{} req / {}", r as u64, window_label(w)))) }+ if m.resting() { out.push(kv("State", "Resting until your next message")) }+ let short = !m.downloaded() && f.pending.is_none() && !active && m.size.zip(snap.and_then(|s| s.free_disk)).is_some_and(|(s, d)| s + GIB > d);+ if short { out.push(warn(format!("Free up disk space on {here} to get it."))) }+ else if !m.downloaded() && !snap.is_some_and(|s| s.supports_download) && m.can_start && f.pending.is_none() && !active { out.push(warn(format!("Downloads and starts on {here}."))) }+ let mut said = Vec::new();+ if !f.in_use {+ if f.get_use { said.push("Enter gets it: downloads it, starts it, and moves this harness onto it.".to_string()) }+ else if f.get { said.push(match &f.other { None => "Enter downloads it.".into(), Some(o) => format!("Enter downloads it. Stop {o} to run it: one local model runs at a time.") }) }+ else if f.use_running { said.push("Enter moves this harness onto it.".into()) }+ else if f.use_start { said.push(match &f.other { None => "Enter starts it and moves this harness onto it.".into(), Some(o) => format!("Stop {o} first: one local model runs at a time.") }) }+ else if t.is_none() && m.downloaded() && !m.running() && m.can_start { said.push("Enter starts it.".into()) }+ }+ if m.can_stop { said.push("^S stops it and frees its memory. The download is kept.".into()) }+ if !said.is_empty() { out.push(Line::raw("")); out.extend(said.into_iter().map(|s| Line::from(span(s, fg(theme::accent()))))) }+ if let Some(e) = f.op.as_ref().and_then(|o| o.error.clone()) { out.push(warn(e)) }+ if let Some(e) = snap.and_then(|s| s.notice.clone()).or_else(|| v.local_error.get(&machine).cloned()) { out.push(warn(e)) }+ return out;+ }+ if let Some(rest) = id.strip_prefix("mv:grid:") {+ let mut parts = rest.splitn(3, '\t');+ let (grid, node, model) = (parts.next().unwrap_or(""), parts.next().unwrap_or(""), parts.next().unwrap_or(""));+ let section = v.grids.get(&machine).and_then(|g| g.sections.iter().find(|s| s.name == grid));+ let x = section.and_then(|s| s.models.iter().find(|x| x.id == model));+ let own = section.is_some_and(|s| s.own);+ let status = match x.and_then(|x| x.offline.clone()) { Some(who) => format!("{who} seems offline — its models come back when it does"), None => "Available".into() };+ let status = match grid_word(app, x.cloned().as_ref().unwrap_or(&GridModel { id: model.to_string(), node: node.to_string(), offline: None }), t).as_str() {+ SWITCHING => format!("{SWITCHING} this harness is moving onto it"),+ "✓ In use" => format!("{status} · this harness is on it"),+ _ => status,+ };+ let mut out = vec![bold(model.to_string()), Line::raw(status)];+ out.extend(failed(model));+ out.push(Line::raw(""));+ out.push(kv("Machine", node.to_string()));+ out.push(kv("Source", if own { "On your machines".to_string() } else { format!("Shared · {grid}") }));+ let said = match plan_enter(app, id) { Plan::Retarget { .. } => "Enter moves this harness onto it.".to_string(), Plan::Arm(..) => "Enter twice moves this harness onto it anyway.".into(), Plan::Say(w) => w, _ => String::new() };+ if !said.is_empty() { out.push(Line::raw("")); out.push(Line::from(span(said, fg(theme::accent())))) }+ return out;+ }+ if let Some(name) = id.strip_prefix("mv:wake:") {+ return vec![bold(format!("Shared · {name}")), Line::raw("Resting to save resources. It starts by itself when you send a message."), Line::raw(""),+ Line::from(span("Enter wakes it to show its models (usually 15–40 s).", fg(theme::accent())))];+ }+ if let Some(rest) = id.strip_prefix("mv:sub:") {+ let Some(sub) = subscriptions(app).into_iter().find(|s| format!("{}\t{}", s.engine, s.account) == rest) else { return vec![] };+ let low = sub.left.is_some_and(|l| l <= LOW_WATER);+ let mut out = vec![bold(if sub.account.is_empty() { sub.title.clone() } else { format!("{} · key ···{}", sub.title, sub.account) })];+ out.push(match sub.left { Some(_) if low => warn(format!("{} · Running low", sub.status)), Some(_) => Line::raw(format!("{} · Healthy", sub.status)), None => Line::raw(sub.status.clone()) });+ match sub_word(app, &sub, t).as_str() {+ SWITCHING => out.push(Line::raw(format!("{SWITCHING} this harness is going back to its own login"))),+ "✓ In use" => out.push(Line::raw("This harness is on it".to_string())),+ _ => {}+ }+ out.extend(failed(""));+ out.push(Line::raw(""));+ out.extend(sub.details.iter().take(3).map(|d| kv("Window", d.clone())));+ out.push(kv("Agent", engine_label(&sub.engine).to_string()));+ out.push(kv("Source", "Subscription"));+ let said = match sub_payload(app, &sub, t) { Ok(_) => "Enter puts this harness back on its own login.".to_string(), Err(w) => w };+ out.push(Line::raw(""));+ out.push(Line::from(span(said, fg(theme::accent()))));+ if low && sub_word(app, &sub, t).starts_with('✓') { out.push(Line::from(span("Running low: Enter on a model below moves this harness onto it.", fg(theme::WARN)))) }+ return out;+ }+ if let Some(key) = id.strip_prefix("mv:api:") {+ let Some(api) = v.apis.as_ref().and_then(|a| a.as_ref().ok()).and_then(|l| l.iter().find(|x| x.id == key)) else { return vec![] };+ let mut out = vec![bold(api.name.clone()), Line::raw(api.host()), Line::raw("")];+ match v.api_models.get(&api.id) {+ _ if !api.serves_models() => out.push(Line::raw("For harness tools: it lists no models a harness can run on.")),+ Some(Ok(l)) => out.push(kv("Models", l.len().to_string())),+ Some(Err(e)) => out.push(warn(e.clone())),+ None => out.push(dim("Reading its models…")),+ }+ if api.serves_models() { out.push(Line::raw("")); out.push(Line::from(span(if v.api_open.contains(&api.id) { "Enter folds its models." } else { "Enter shows its models." }, fg(theme::accent())))) }+ return out;+ }+ if let Some(rest) = id.strip_prefix("mv:apimodel:") {+ let Some((key, model)) = rest.split_once('\t') else { return vec![] };+ let Some(api) = v.apis.as_ref().and_then(|a| a.as_ref().ok()).and_then(|l| l.iter().find(|x| x.id == key)) else { return vec![] };+ let listed = v.api_models.get(key).and_then(|r| r.as_ref().ok()).and_then(|l| l.iter().find(|m| m.id == model)).cloned();+ let mut out = vec![bold(model.to_string()), Line::raw(api.name.clone())];+ out.extend(failed(model));+ out.push(Line::raw(""));+ if let Some(n) = listed.as_ref().and_then(|m| m.name.clone()) { out.push(kv("Name", n)) }+ if let Some(w) = listed.and_then(|m| m.context) { out.push(kv("Context", format!("{} window", context_label(w)))) }+ out.push(kv("Source", format!("API · {}", api.host())));+ let said = match api_payload(app, api, model, t) { Ok(_) => "Enter moves this harness onto it.".to_string(), Err(w) => w };+ out.push(Line::raw(""));+ out.push(Line::from(span(said, fg(theme::accent()))));+ return out;+ }+ if id == "mv:more" {+ let n = v.local.get(&machine).map(|s| s.models.iter().filter(|m| !m.downloaded()).count()).unwrap_or(0);+ return vec![bold(format!("{n} models that fit {}", this_computer())), Line::raw(""), Line::from(span(if v.more { "Enter shows the first five." } else { "Enter lists them all." }, fg(theme::accent())))];+ }+ id.strip_prefix("mv:note:").map(|_| vec![]).unwrap_or_default()+}++#[cfg(test)]+mod tests {+ use super::*;+ use crate::fleet::{Reach, Usage, Window};++ /// This computer, one Claude harness focused in the one pane, on its own login — its+ /// subscription at 12% left.+ fn app() -> App {+ let (sink, _) = tokio::sync::mpsc::unbounded_channel();+ let mut app = App::new(19791, sink, (150, 42));+ app.fleet.local_id = "local".into();+ app.fleet.machines.push(Machine { id: "local".into(), name: "studio".into(), local: true, status: "online".into(), reach: Reach::Ready });+ frame(&mut app, json!({}));+ let mut tab = crate::app::Tab::with_wid("work", 1);+ tab.root = Some(crate::layout::Node::new(1, 150, 40));+ tab.focus = Some(1);+ app.panes.insert(1, crate::pane::Pane::new(1, "local", "a1", 150, 40));+ app.tabs = vec![tab];+ app.active = 0;+ app.usage.insert("local".into(), vec![Usage { provider: "claude".into(), account: Some("7f0c".into()), windows: vec![Window { label: "5h".into(), used: 88.0, resets: None }, Window { label: "week".into(), used: 40.0, resets: None }] }]);+ app+ }++ /// The harness's frame, its `grid` as given (`{}`: on its own login).+ fn frame(app: &mut App, grid: Value) {+ let key = ("local".to_string(), "a1".to_string());+ let row = json!({ "id": "a1", "name": "fix-login", "engine": "claude", "selectedModel": "opus", "grid": grid });+ let a = crate::fleet::agent_from("local", &row, app.fleet.agents.get(&key));+ app.fleet.agents.insert(key, a);+ }++ fn model(id: &str, state: &str, gib: f64) -> Value {+ json!({ "id": id, "name": id, "state": state, "sizeBytes": gib * GIB, "canStart": state != "running", "canStop": state == "running", "estTokS": 40 })+ }++ /// The daemon's `grid_fleet_models_list`: a 20 GB catalog pick, a downloaded model, and six+ /// more downloads (the catalog is longer than five).+ fn local_reply(qwen: Value, busy: bool) -> Value {+ let mut models = vec![qwen, model("gemma-12b", "downloaded", 7.5)];+ models.extend((1..=6).map(|i| model(&format!("extra-{i}"), "available", 4.0)));+ json!({ "models": models, "memoryBytes": 64.0 * GIB, "freeDiskBytes": 120.0 * GIB, "busy": busy, "supportsDownload": true, "observedAt": "2026-09-30T00:00:00.000Z" })+ }++ fn qwen(state: &str, operation: Value) -> Value {+ json!({ "id": "qwen-35b", "name": "Qwen3.6-35B-A3B", "state": state, "sizeBytes": 20.0 * GIB, "quant": "Q4_K_M", "canStart": state != "running", "canStop": state == "running",+ "contextWindow": 131072, "estTokS": 78.2, "paramsB": 35, "operation": operation })+ }++ fn op(action: &str, stage: &str, phase: &str, progress: Option<f64>) -> Value {+ json!({ "id": format!("op-{action}"), "modelId": "qwen-35b", "action": action, "stage": stage, "phase": phase, "progress": progress, "updatedAt": "2026-09-30T00:00:00.000Z" })+ }++ /// `grid_models_list`: the own grid serving [served], a shared grid with one row offline, and+ /// a shared grid asleep with no record.+ fn grids_reply(served: &[&str]) -> Value {+ let own: Vec<Value> = served.iter().map(|id| json!({ "id": id, "node": "studio" })).collect();+ json!({ "gridName": "own-grid", "localModelEngines": ["claude", "codex"], "supportsModelLaunch": true, "grids": [+ { "name": "own-grid", "own": true, "state": "awake", "models": own },+ { "name": "team", "own": false, "state": "awake", "models": [{ "id": "llama-70b", "node": "gpu-box" }, { "id": "mistral", "node": "lap", "unavailable": { "reason": "offline", "machine": "lap" } }] },+ { "name": "night", "own": false, "state": "asleep", "models": [] },+ ] })+ }++ fn loaded() -> App {+ let mut app = app();+ on_local(&mut app, "local", Ok(local_reply(qwen("available", Value::Null), false)));+ on_grids(&mut app, "local", Ok(grids_reply(&[])));+ app+ }++ fn row<'a>(rows: &'a [Row], id: &str) -> &'a Row { rows.iter().find(|r| r.id == id).unwrap_or_else(|| panic!("no row {id}: {:?}", rows.iter().map(|r| &r.id).collect::<Vec<_>>())) }+ fn last_sent(app: &App) -> (String, String, Value) { app.models_view.sent.last().cloned().expect("nothing sent") }+ fn toast(app: &App) -> String { app.toast.as_ref().map(|t| t.0.clone()).unwrap_or_default() }+ fn flash(p: &Picker) -> String { p.flash.as_ref().map(|f| f.0.clone()).unwrap_or_default() }+ fn text(lines: &[Line]) -> String { lines.iter().map(|l| l.spans.iter().map(|s| s.content.as_ref()).collect::<String>()).collect::<Vec<_>>().join("\n") }++ /// The owner's flow, end to end on fake replies: the subscription runs low, so the focused+ /// harness is moved onto a local model that is not downloaded yet — Get (asked twice) →+ /// download → start → wait until the grid lists it → `agent_retarget {agentId, gridModel,+ /// gridName}` → "Switching…" until its frame says it is there → back to the subscription with+ /// `clearGrid`.+ #[test]+ fn the_focused_harness_moves_onto_a_local_model_and_back() {+ let mut app = loaded();+ let rows = rows(&app, "");+ // The harness's own login first, running low, and it is on it.+ assert_eq!(rows[0].group.as_deref(), Some("Subscription"));+ assert!(rows[0].right.contains("12% left · Running low") && rows[0].right.ends_with("✓ In use"), "{}", rows[0].right);+ assert_eq!(in_use_row(&rows).as_deref(), Some("mv:sub:claude\t7f0c"));+ assert!(row(&rows, "mv:local:qwen-35b").right.ends_with("Get"));++ // Get: the first Enter only says what the second will do.+ let mut picker = Picker::new("models", "");+ choose(&mut app, &mut picker, "mv:local:qwen-35b", false);+ assert!(app.models_view.sent.is_empty(), "nothing downloads on the first Enter");+ assert!(flash(&picker).starts_with("Enter again to get Qwen3.6-35B-A3B (20 GB) — then it starts"), "{}", flash(&picker));+ choose(&mut app, &mut picker, "mv:local:qwen-35b", false);+ assert_eq!(last_sent(&app), ("local".into(), "grid_fleet_model_download".into(), json!({ "modelId": "qwen-35b" })));+ assert_eq!(app.models_view.using.as_ref().map(|u| u.step), Some(Step::Get));++ // The daemon takes it; its progress is the row's word.+ on_act(&mut app, "local", Ok(json!({ "operation": op("download", "downloading", "running", Some(0.1)) })));+ assert_eq!(last_sent(&app).1, "grid_fleet_models_list");+ on_local(&mut app, "local", Ok(local_reply(qwen("available", op("download", "downloading", "running", Some(0.42))), true)));+ assert!(row(&rows_of(&app), "mv:local:qwen-35b").right.ends_with("Downloading 42%"));+ assert_eq!(app.models_view.using.as_ref().map(|u| u.step), Some(Step::Get), "a download has no deadline");++ // Downloaded: it is started.+ on_local(&mut app, "local", Ok(local_reply(qwen("downloaded", op("download", "downloading", "done", None)), false)));+ assert_eq!(last_sent(&app), ("local".into(), "grid_fleet_model_start".into(), json!({ "modelId": "qwen-35b" })));+ assert_eq!(app.models_view.using.as_ref().map(|u| u.step), Some(Step::Start));+ on_act(&mut app, "local", Ok(json!({ "operation": op("start", "starting", "running", None) })));+ on_local(&mut app, "local", Ok(local_reply(qwen("downloaded", op("start", "starting", "running", None)), true)));+ assert_eq!(app.models_view.using.as_ref().map(|u| u.step), Some(Step::Start), "still starting");++ // Running: the grid is asked whether it serves it — not yet, then yes.+ on_local(&mut app, "local", Ok(local_reply(qwen("running", op("start", "verifying", "done", None)), false)));+ assert_eq!(last_sent(&app), ("local".into(), "grid_models_list".into(), json!({ "rowState": true })));+ on_grids(&mut app, "local", Ok(grids_reply(&[])));+ assert_eq!(app.models_view.using.as_ref().map(|u| u.step), Some(Step::Serve));+ on_grids(&mut app, "local", Ok(grids_reply(&["qwen-35b"])));+ assert_eq!(last_sent(&app), ("local".into(), "agent_retarget".into(), json!({ "agentId": "a1", "gridModel": "qwen-35b", "gridName": "own-grid" })));++ // Switching… on the row and on the pane, until the harness's frame says it is there.+ assert!(row(&rows_of(&app), "mv:local:qwen-35b").right.ends_with(SWITCHING));+ assert_eq!(pane_note(&app, "local", "a1").as_deref(), Some("Switching to Qwen3.6-35B-A3B…"));+ on_retarget(&mut app, "Qwen3.6-35B-A3B", true, Ok(json!({ "retargeted": true })));+ assert!(app.models_view.using.is_none());+ assert!(toast(&app).contains("Switching fix-login to Qwen3.6-35B-A3B"), "{}", toast(&app));+ frame(&mut app, json!({ "model": "qwen-35b", "state": "awake" }));+ let rows = rows_of(&app);+ assert!(row(&rows, "mv:local:qwen-35b").right.ends_with("✓ In use"));+ assert!(pane_note(&app, "local", "a1").is_none());+ assert!(rows[0].right.ends_with("Use"), "its own login is a Use away: {}", rows[0].right);++ // And back to the subscription.+ let before = app.models_view.sent.len();+ choose(&mut app, &mut picker, "mv:sub:claude\t7f0c", false);+ assert_eq!(app.models_view.sent.len(), before + 1);+ assert_eq!(last_sent(&app), ("local".into(), "agent_retarget".into(), json!({ "agentId": "a1", "clearGrid": true })));+ assert!(rows_of(&app)[0].right.ends_with(SWITCHING));+ frame(&mut app, json!({}));+ assert!(rows_of(&app)[0].right.ends_with("✓ In use"));+ }++ fn rows_of(app: &App) -> Vec<Row> { rows(app, "") }++ /// A switch the daemon refuses says why — on the status line and in the row's preview — and+ /// the row is no longer "Switching…".+ #[test]+ fn a_refused_switch_says_why() {+ let mut app = loaded();+ let mut picker = Picker::new("models", "");+ choose(&mut app, &mut picker, "mv:grid:team\tgpu-box\tllama-70b", false);+ assert_eq!(last_sent(&app), ("local".into(), "agent_retarget".into(), json!({ "agentId": "a1", "gridModel": "llama-70b", "gridName": "team" })));+ assert!(row(&rows_of(&app), "mv:grid:team\tgpu-box\tllama-70b").right.ends_with(SWITCHING));+ on_retarget(&mut app, "llama-70b", false, Err(RpcError::new("GRID_UNAVAILABLE", "Could not read this machine's grid endpoint.")));+ assert_eq!(toast(&app), "Could not switch fix-login to llama-70b: Could not read this machine's grid endpoint.");+ assert!(row(&rows_of(&app), "mv:grid:team\tgpu-box\tllama-70b").right.ends_with("Use"));+ assert!(text(&preview(&app, "mv:grid:team\tgpu-box\tllama-70b")).contains("Could not switch fix-login"));+ assert_eq!(retarget_error(&RpcError::new("UNSUPPORTED_ON_REMOTE", "")), "That machine cannot switch models — update Harness there.");+ }++ /// A Use that fails on the way — a refused start, a failed download, a model that never+ /// serves — stops, says why, and the preview keeps it.+ #[test]+ fn a_use_that_fails_says_why() {+ let mut app = loaded();+ let mut picker = Picker::new("models", "");+ // The downloaded model: Use starts it (no second Enter: nothing to download).+ choose(&mut app, &mut picker, "mv:local:gemma-12b", false);+ assert_eq!(last_sent(&app), ("local".into(), "grid_fleet_model_start".into(), json!({ "modelId": "gemma-12b" })));+ on_act(&mut app, "local", Err(RpcError::new("Stop a running model to make room, then try again.", "")));+ assert!(app.models_view.using.is_none());+ assert_eq!(toast(&app), "gemma-12b: Stop a running model to make room, then try again.");+ assert!(text(&preview(&app, "mv:local:gemma-12b")).contains("Stop a running model to make room"));++ // A download the daemon reports failed.+ let job = Use { model: "qwen-35b".into(), name: "Qwen".into(), machine: "local".into(), agent: "a1".into(), step: Step::Get, since: Instant::now() };+ let failed = Operation::parse(&op("download", "downloading", "failed", None)).map(|mut o| { o.error = Some("The download stopped. Start again to resume.".into()); o });+ assert_eq!(next(&job, None, failed.as_ref(), false, None, Instant::now()), Next::Fail("The download stopped. Start again to resume.".into()));+ // Started, but never listed as served: after three minutes it says so.+ let snap = parse_local(&local_reply(qwen("running", Value::Null), false)).unwrap();+ let late = Instant::now() + USE_WAIT + Duration::from_secs(1);+ let serving = Use { step: Step::Serve, ..job.clone() };+ assert_eq!(next(&serving, Some(&snap), None, false, Some(&parse_grids(&grids_reply(&[]))), Instant::now()), Next::Wait);+ assert!(matches!(next(&serving, Some(&snap), None, false, Some(&parse_grids(&grids_reply(&[]))), late), Next::Fail(w) if w.contains("still starting")));+ // A request still out: nothing moves.+ assert_eq!(next(&serving, Some(&snap), None, true, Some(&parse_grids(&grids_reply(&["qwen-35b"]))), Instant::now()), Next::Wait);+ assert_eq!(next(&serving, Some(&snap), None, false, Some(&parse_grids(&grids_reply(&["QWEN-35B"]))), Instant::now()), Next::Retarget { grid: "own-grid".into(), model: "QWEN-35B".into() });+ }++ /// One local model runs at a time: with another running, Use says to stop it first, and Get+ /// only downloads. While an operation runs, nothing else starts.+ #[test]+ fn one_local_model_runs_at_a_time() {+ let mut app = app();+ let mut reply = local_reply(qwen("available", Value::Null), false);+ reply["models"].as_array_mut().unwrap().push(json!({ "id": "phi", "name": "Phi", "state": "running", "sizeBytes": 3.0 * GIB, "canStart": false, "canStop": true, "tokensPerSecond": 91.3 }));+ on_local(&mut app, "local", Ok(reply));+ on_grids(&mut app, "local", Ok(grids_reply(&["phi"])));+ assert_eq!(plan_enter(&app, "mv:local:gemma-12b"), Plan::Say("Stop Phi first: one local model runs at a time — ^S on it".into()));+ match plan_enter(&app, "mv:local:qwen-35b") { Plan::Arm(_, then) => assert_eq!(*then, Plan::Act { model: "qwen-35b".into(), action: "download" }), p => panic!("{p:?}") }+ let rows = rows_of(&app);+ assert!(row(&rows, "mv:local:phi").right.contains("91 tok/s") && row(&rows, "mv:local:phi").right.ends_with("Use"), "measured speed, and it serves: Use");+ assert!(row(&rows, "mv:local:qwen-35b").right.contains("~78 tok/s"), "an estimate before it runs");+ // ^S stops, asked first.+ let mut picker = Picker::new("models", "");+ choose(&mut app, &mut picker, "mv:local:phi", true);+ assert!(app.models_view.sent.iter().all(|s| s.1 != "grid_fleet_model_stop"));+ assert!(flash(&picker).starts_with("^S again stops Phi"));+ choose(&mut app, &mut picker, "mv:local:phi", true);+ assert_eq!(last_sent(&app), ("local".into(), "grid_fleet_model_stop".into(), json!({ "modelId": "phi" })));+ // While it stops, the daemon is busy: nothing else starts.+ assert_eq!(plan_enter(&app, "mv:local:qwen-35b"), Plan::Say("Wait for the current model operation to finish.".into()));+ assert!(row(&rows_of(&app), "mv:local:phi").right.ends_with("Stopping"));+ }++ /// The sections, in the order the per-pane picker has them: Subscription, On your machines+ /// (with this computer's memory and free disk), Shared · <grid> (a resting one offering "Show+ /// models"), APIs, then five downloads and "More models (N)".+ #[test]+ fn rows_are_in_sections() {+ let mut app = loaded();+ let rows = rows_of(&app);+ let mut groups: Vec<&str> = rows.iter().filter_map(|r| r.group.as_deref()).collect();+ groups.dedup();+ let here = this_computer();+ assert_eq!(groups, vec!["Subscription".to_string(), format!("On your machines · {here} · 64 GB memory · 120 GB free"), "Shared · team".into(), "Shared · night".into(), format!("Get for {here} · 64 GB")]);+ assert!(row(&rows, "mv:grid:team\tlap\tmistral").right.ends_with("Offline"));+ assert!(row(&rows, "mv:wake:night").label == "Show models");+ let downloads: Vec<&Row> = rows.iter().filter(|r| r.group.as_deref().is_some_and(|g| g.starts_with("Get for"))).collect();+ assert_eq!(downloads.len(), 6, "five, then More models");+ assert_eq!(downloads[5].label, "More models (2)");+ // More models lists them all; a search too, without the row.+ let mut picker = Picker::new("models", "");+ choose(&mut app, &mut picker, "mv:more", false);+ assert_eq!(rows_of(&app).iter().filter(|r| r.id.starts_with("mv:local:extra")).count(), 6);+ assert_eq!(row(&rows_of(&app), "mv:more").label, "Show fewer");+ app.models_view.more = false;+ assert_eq!(super::rows(&app, "extra").iter().filter(|r| r.id.starts_with("mv:local:extra")).count(), 6);+ assert!(super::rows(&app, "extra").iter().all(|r| r.id != "mv:more"));+ // No harness in front: every subscription, and nothing to Use.+ app.tabs[0].focus = None;+ let rows = rows_of(&app);+ assert_eq!(rows[0].group.as_deref(), Some("Subscriptions"));+ assert!(row(&rows, "mv:grid:team\tgpu-box\tllama-70b").right.trim().is_empty());+ assert_eq!(plan_enter(&app, "mv:grid:team\tgpu-box\tllama-70b"), Plan::Say(NO_HARNESS.into()));+ }++ /// An engine the daemon cannot point at a model says so, and offers only its own login.+ #[test]+ fn an_engine_that_runs_only_on_its_login_says_so() {+ let mut app = loaded();+ let key = ("local".to_string(), "a1".to_string());+ app.fleet.agents.get_mut(&key).unwrap().engine = "cursor".into();+ let rows = rows_of(&app);+ assert!(rows.iter().any(|r| r.label == "Cursor can only run on its own login."), "{:?}", rows.iter().map(|r| &r.label).collect::<Vec<_>>());+ assert_eq!(plan_enter(&app, "mv:grid:team\tgpu-box\tllama-70b"), Plan::Say("Cursor runs only on its own login".into()));+ }++ /// An offline row is listed, and Enter on it asks before switching anyway.+ #[test]+ fn an_offline_row_asks_before_switching() {+ let app = loaded();+ match plan_enter(&app, "mv:grid:team\tlap\tmistral") {+ Plan::Arm(words, then) => {+ assert_eq!(words, "lap seems offline — Enter again to switch anyway");+ assert!(matches!(*then, Plan::Retarget { ref payload, .. } if payload["gridModel"] == "mistral"));+ }+ p => panic!("{p:?}"),+ }+ }++ /// "Show models" wakes a resting section, and the view reads again every 5 s while it starts.+ #[test]+ fn show_models_wakes_a_resting_section() {+ let mut app = loaded();+ let mut picker = Picker::new("models", "");+ choose(&mut app, &mut picker, "mv:wake:night", false);+ assert_eq!(last_sent(&app), ("local".into(), "grid_models_list".into(), json!({ "rowState": true, "wake": ["night"] })));+ assert!(rows_of(&app).iter().any(|r| r.label == STARTING_UP_WAIT), "the wake in flight says so");+ assert_eq!(plan_enter(&app, "mv:wake:night"), Plan::Say(STARTING_UP_WAIT.into()), "once, however often it is pressed");+ let mut waking = grids_reply(&[]);+ waking["grids"][2]["state"] = json!("waking");+ on_wake(&mut app, "local", "night", Ok(waking));+ assert!(app.models_view.follow_until.is_some());+ assert_eq!(grids_every(false, false, true), Some(Duration::from_secs(5)));+ let rows = rows_of(&app);+ assert!(rows.iter().any(|r| r.label == STARTING_UP_WAIT && r.group.as_deref() == Some("Shared · night")));+ }++ #[test]+ fn polling_is_every_four_seconds_while_busy_or_open_else_a_minute() {+ assert_eq!(poll_every(true, false), Duration::from_secs(4));+ assert_eq!(poll_every(false, true), Duration::from_secs(4));+ assert_eq!(poll_every(false, false), Duration::from_secs(60));+ assert_eq!(grids_every(true, false, false), Some(Duration::from_secs(20)));+ assert_eq!(grids_every(false, true, false), Some(Duration::from_secs(4)));+ assert_eq!(grids_every(false, false, false), None);+ let now = Instant::now();+ assert!(due(None, Duration::from_secs(4), now));+ assert!(!due(Some(&now), Duration::from_secs(4), now));+ }++ /// `grid_models_changed` is the whole list: taken as it is, the rows follow.+ #[test]+ fn a_push_replaces_the_grids() {+ let mut app = loaded();+ on_push(&mut app, "local", &json!({ "gridName": "own-grid", "grids": [{ "name": "own-grid", "own": true, "models": [{ "id": "big", "node": "tower" }] }] }));+ let rows = rows_of(&app);+ assert!(rows.iter().any(|r| r.id == "mv:grid:own-grid\ttower\tbig"));+ assert!(rows.iter().all(|r| !r.id.starts_with("mv:grid:team")));+ }++ #[test]+ fn replies_are_read_defensively() {+ let s = parse_local(&local_reply(qwen("available", op("download", "downloading", "running", Some(1.7))), true)).unwrap();+ let q = &s.models[0];+ assert_eq!((q.context, q.est_tok_s, q.params_b, q.quantization().as_deref()), (Some(131072.0), Some(78.2), Some(35.0), Some("Q4_K_M")));+ assert_eq!(q.operation.as_ref().and_then(|o| o.progress), Some(1.0), "progress held to 0–1");+ assert!(s.busy && s.supports_download && s.memory == Some(64.0 * GIB));+ assert!(parse_local(&json!({ "error": "x" })).is_none());+ assert!(Operation::parse(&json!({ "id": "x", "modelId": "m", "action": "fly", "stage": "checking", "phase": "running" })).is_none());+ let unnamed = LocalModel::from(&json!({ "id": "unsloth/Qwen3-8B-UD-Q4_K_XL.gguf" })).unwrap();+ assert_eq!(unnamed.quantization().as_deref(), Some("Q4_K_XL"));+ assert_eq!(unnamed.state, "available");++ let g = parse_grids(&grids_reply(&["a"]));+ assert_eq!(g.sections.len(), 3);+ assert_eq!(g.sections[1].models[1].offline.as_deref(), Some("lap"));+ assert!(g.can_run("Claude") && !g.can_run("cursor") && g.reachable);+ let old = parse_grids(&json!({ "gridName": "mine", "models": [{ "id": "m", "node": "n" }] }));+ assert!(old.sections[0].own && old.can_run("anything"), "an older daemon: its own grid, nothing refused");+ assert!(!parse_grids(&json!({ "error": "GRID_MODELS_FAILED" })).reachable);++ let apis = parse_apis(&json!({ "connections": [{ "id": "or", "name": "OpenRouter", "baseUrl": "https://openrouter.ai/api/v1" }, { "id": "x", "name": "X", "baseUrl": "https://x.dev", "authHeader": "x-api-key", "authPrefix": "" }], "presets": [] })).unwrap();+ assert!(apis[0].serves_models() && !apis[1].serves_models());+ assert_eq!(apis[0].host(), "openrouter.ai");+ assert!(parse_apis(&json!({})).is_err());+ let models = parse_api_models(&json!({ "models": [{ "id": "a", "contextWindow": 200000 }, { "id": " " }] })).unwrap();+ assert_eq!(models, vec![ApiModel { id: "a".into(), name: None, context: Some(200000) }]);++ let a = crate::fleet::agent_from("m", &json!({ "id": "a", "grid": { "model": "q", "baseUrl": "http://x/v1", "state": "asleep", "note": { "reason": "offline", "model": "q", "machine": "lap" } } }), None);+ assert_eq!((a.grid_model.as_str(), a.grid_state.as_str(), a.grid_note.clone()), ("q", "asleep", Some(("offline".into(), "q".into(), "lap".into()))));+ let b = crate::fleet::agent_from("m", &json!({ "id": "a", "grid": { "note": { "reason": "offline", "model": "q" } } }), None);+ assert!(b.grid_note.is_none(), "an offline note needs its computer");+ }++ /// The desktop's table of what a resting section says.+ #[test]+ fn a_resting_section_says_what_the_desktop_says() {+ let s = |state: &str, models: usize, age: Option<u64>, outcome: &str| Section { name: "team".into(), state: state.into(), age, outcome: outcome.into(),+ models: (0..models).map(|i| GridModel { id: format!("m{i}"), node: "n".into(), offline: None }).collect(), ..Default::default() };+ assert_eq!(section_words(&s("asleep", 1, Some(180), ""), false).subtitle.as_deref(), Some("Asleep 3min ago"));+ assert!(section_words(&s("asleep", 0, None, ""), false).offer_wake);+ assert_eq!(section_words(&s("asleep", 0, None, ""), true), Words { subtitle: None, sentence: Some(STARTING_UP_WAIT.into()), offer_wake: false });+ assert_eq!(section_words(&s("asleep", 0, Some(60), ""), false).sentence.as_deref(), Some("Nobody was serving here when it went to sleep"));+ assert_eq!(section_words(&s("awake", 0, None, "nobody_serving"), false).sentence.as_deref(), Some("Nobody is serving a model here right now"));+ assert_eq!(section_words(&s("awake", 0, None, "not_started"), false).sentence.as_deref(), Some("Couldn't start team right now — it will start on your next message"));+ assert_eq!(section_words(&s("unknown", 2, None, ""), false).sentence.as_deref(), Some("Not answering right now"));+ let w = section_words(&s("awake", 2, None, ""), false);+ assert!(w.subtitle.is_none() && w.sentence.is_none() && !w.offer_wake);+ assert_eq!(list_age(30), "just now");+ assert_eq!(list_age(7200), "2h ago");+ }++ /// Saved APIs fold their models until Enter; a model of one is used on a harness here.+ #[test]+ fn saved_apis_fold_and_their_models_are_used() {+ let mut app = loaded();+ on_apis(&mut app, Ok(json!({ "connections": [{ "id": "or", "name": "OpenRouter", "baseUrl": "https://openrouter.ai/api/v1" }], "presets": [] })));+ assert_eq!(last_sent(&app), ("local".into(), "api_connections".into(), json!({ "action": "models", "id": "or" })));+ on_api_models(&mut app, "or", Ok(json!({ "models": [{ "id": "deepseek/v4", "contextWindow": 131072 }] })));+ let rows = rows_of(&app);+ assert_eq!(row(&rows, "mv:api:or").right, "1 model");+ assert!(rows.iter().all(|r| !r.id.starts_with("mv:apimodel:")), "folded");+ let mut picker = Picker::new("models", "");+ choose(&mut app, &mut picker, "mv:api:or", false);+ assert!(row(&rows_of(&app), "mv:apimodel:or\tdeepseek/v4").right.ends_with("Use"));+ choose(&mut app, &mut picker, "mv:apimodel:or\tdeepseek/v4", false);+ assert_eq!(last_sent(&app), ("local".into(), "agent_retarget".into(), json!({ "agentId": "a1", "apiConnection": "or", "apiModel": "deepseek/v4" })));+ assert!(text(&preview(&app, "mv:apimodel:or\tdeepseek/v4")).contains("128K window"));+ frame(&mut app, json!({ "model": "deepseek/v4", "baseUrl": "https://openrouter.ai/api/v1/" }));+ assert!(row(&rows_of(&app), "mv:apimodel:or\tdeepseek/v4").right.ends_with("✓ In use"));+ }++ /// The preview: what decides between models, and what Enter does.+ #[test]+ fn the_preview_says_what_decides_and_what_enter_does() {+ let mut app = loaded();+ let here = this_computer();+ let s = text(&preview(&app, "mv:local:qwen-35b"));+ for want in ["Qwen3.6-35B-A3B", "Not downloaded", "Download 20 GB · 120 GB free", &format!("Memory fits · {here} has 64 GB"), &format!("Speed ~78 tok/s on {here} (estimate)"),+ "Context 128K window", "Params 35B", "Quant Q4_K_M", "Machine This", "Enter gets it: downloads it, starts it, and moves this harness onto it."] {+ assert!(s.contains(want), "{want:?} missing:\n{s}");+ }+ // Not room on the disk for it: said before Get.+ on_local(&mut app, "local", Ok({ let mut r = local_reply(qwen("available", Value::Null), false); r["freeDiskBytes"] = json!(10.0 * GIB); r }));+ assert!(text(&preview(&app, "mv:local:qwen-35b")).contains(&format!("Free up disk space on {here} to get it.")));+ let sub = text(&preview(&app, "mv:sub:claude\t7f0c"));+ assert!(sub.contains("12% left · Running low") && sub.contains("5h — 12% left") && sub.contains("This harness is on it") && sub.contains("Running low: Enter on a model below"), "{sub}");+ assert!(text(&preview(&app, "mv:wake:night")).contains("Enter wakes it"));+ assert!(text(&preview(&app, "mv:grid:team\tlap\tmistral")).contains("lap seems offline"));+ assert!(text(&preview(&app, "mv:more")).contains("7 models that fit"));+ assert!(crate::preview::lines(&app, &crate::modal::PickerKind::Models, "mv:local:gemma-12b").iter().any(|l| l.spans.iter().any(|s| s.content.contains("Enter starts it and moves this harness onto it."))));+ }++ /// The pane's note: "Starting up…" from a message sent while the model's computers rest+ /// until the model answers; the daemon's note when its model will not answer.+ #[test]+ fn the_pane_says_when_its_model_will_not_answer() {+ let mut app = loaded();+ frame(&mut app, json!({ "model": "llama-70b", "state": "asleep" }));+ watch_turn(&mut app, "local", "turn_started", &json!({ "agentId": "a1", "replay": true }));+ assert!(pane_note(&app, "local", "a1").is_none(), "a replayed turn is not a message sent now");+ watch_turn(&mut app, "local", "turn_started", &json!({ "agentId": "a1" }));+ assert_eq!(pane_note(&app, "local", "a1").as_deref(), Some("Starting up…"));+ app.models_view.starts.insert(("local".into(), "a1".into()), Instant::now() - Duration::from_secs(90));+ assert_eq!(pane_note(&app, "local", "a1").as_deref(), Some("Still starting — this can take up to a minute"));+ watch_turn(&mut app, "local", "text_delta", &json!({ "agentId": "a1" }));+ assert!(pane_note(&app, "local", "a1").is_none());+ frame(&mut app, json!({ "model": "llama-70b", "state": "awake" }));+ watch_turn(&mut app, "local", "turn_started", &json!({ "agentId": "a1" }));+ assert!(pane_note(&app, "local", "a1").is_none(), "an awake model starts no wait");+ frame(&mut app, json!({ "model": "llama-70b", "note": { "reason": "offline", "model": "llama-70b", "machine": "gpu-box" } }));+ assert_eq!(pane_note(&app, "local", "a1").as_deref(), Some("gpu-box seems offline — llama-70b won't answer until it's back"));+ frame(&mut app, json!({ "model": "llama-70b", "note": { "reason": "not_served", "model": "llama-70b" } }));+ assert!(pane_note(&app, "local", "a1").is_some_and(|n| n.starts_with("llama-70b isn't being served right now · Pick another")));+ }++ #[test]+ fn sizes_and_windows_read_as_the_desktop_says_them() {+ assert_eq!(gb(2.7 * GIB), "2.7 GB");+ assert_eq!(gb(27.4 * GIB), "27 GB");+ assert_eq!(context_label(131072), "128K");+ assert_eq!(context_label(200000), "200K");+ assert_eq!(context_label(1_000_000), "1M");+ assert_eq!(context_label(1_500_000), "1.5M");+ assert_eq!(window_label(3600.0), "1h");+ assert_eq!(left_of(99.6), "<1%");+ assert_eq!(left_of(88.0), "12%");+ }++ fn screen(app: &mut App, w: u16, h: u16) -> String {+ let mut term = ratatui::Terminal::new(ratatui::backend::TestBackend::new(w, h)).unwrap();+ term.draw(|f| crate::ui::draw(f, app)).unwrap();+ let buf = term.backend().buffer().clone();+ (0..h).map(|y| (0..w).map(|x| buf[(x, y)].symbol().to_string()).collect::<String>()).collect::<Vec<_>>().join("\n")+ }++ /// The `:` scope and Models… open the panel on the focused harness's row, in sections — at+ /// 150×42 and at 80×24.+ #[test]+ fn models_draws_as_the_panel() {+ // Opened before the replies come: each lands in its own section, not after the rest.+ let mut app = app();+ on_grids(&mut app, "local", Ok(grids_reply(&[])));+ crate::input::run(&mut app, "models");+ on_local(&mut app, "local", Ok(local_reply(qwen("available", Value::Null), false)));+ let Some(crate::modal::Modal::Picker { kind: crate::modal::PickerKind::Models, picker }) = &app.modal else { panic!("not open") };+ assert_eq!(picker.current_id().as_deref(), Some("mv:sub:claude\t7f0c"), "on the row the harness is on");+ let s = screen(&mut app, 150, 42);+ for want in ["Models", "Subscription", "Anthropic", "12% left · Running low", "On your machines", "gemma-12b", "Shared · team", "llama-70b", "Show models"] {+ assert!(s.contains(want), "{want:?} missing at 150×42:\n{s}");+ }+ let at = |w: &str| s.find(w).unwrap_or(usize::MAX);+ // (The launcher's lists read bottom up: the first section by the query, the rest over it,+ // each heading over its rows.)+ // ("Subscription" is in the preview too, higher up: the list's is the last.)+ let sub = s.rfind("Subscription").unwrap_or(0);+ assert!(at("Get for") < at("Shared · team") && at("Shared · team") < at("On your machines") && at("On your machines") < at("gemma-12b") && at("gemma-12b") < sub, "sections out of order:\n{s}");+ app.size = (80, 24);+ app.fit_panes();+ let s = screen(&mut app, 80, 24);+ for want in ["Models", "Subscription", "Anthropic", "On your machines"] { assert!(s.contains(want), "{want:?} missing at 80×24:\n{s}") }+ // Scrolled up (the list reads from the bottom), the downloads and More models are there.+ let s = { crate::input::modal_key(&mut app, crossterm::event::KeyEvent::new(crossterm::event::KeyCode::PageUp, crossterm::event::KeyModifiers::NONE)); crate::input::modal_key(&mut app, crossterm::event::KeyEvent::new(crossterm::event::KeyCode::PageUp, crossterm::event::KeyModifiers::NONE)); screen(&mut app, 80, 24) };+ assert!(s.contains("More models (2)") || s.contains("Get for"), "{s}");+ // It is in the Commands panel, in the Harness group.+ assert!(crate::modal::command_rows(&app).iter().any(|r| r.id == "cmd:models" && r.group.as_deref() == Some("Harness")));+ }+}diff --git a/tui/src/mouse.rs b/tui/src/mouse.rsindex a562a9dd2..0294a496c 100644--- a/tui/src/mouse.rs+++ b/tui/src/mouse.rs@@ -64,6 +64,11 @@ pub struct Event {/// The status line's first row (-1: none) and how many rows it has.pub statusat: i32,pub statuslines: u16,+ // ── status bar ──+ /// Where the window starts past the bar down a side (0, 0 without it):+ /// taken off the event's column and row wherever the window's cells are meant.+ pub ox: u16,+ pub oy: u16,}/// Who takes a drag's motion (tty->mouse_drag_update and _release).@@ -226,6 +231,7 @@ fn check(app: &mut App, m: &mut Event, double: bool) -> Option<Key> {let lines = app.status_lines();m.statuslines = lines;m.statusat = if lines == 0 { -1 } else if app.status_top { 0 } else { app.size.1.saturating_sub(lines) as i32 };+ (m.ox, m.oy) = app.bar_offset();let mut place = None;if m.statusat != -1 && (y as i32) >= m.statusat && (y as i32) < m.statusat + lines as i32 {let row = (y as i32 - m.statusat) as u16;@@ -241,7 +247,7 @@ fn check(app: &mut App, m: &mut Event, double: bool) -> Option<Key> {});}if place.is_none() {- let (px, py) = (x as u32, body_y(m, y) as u32);+ let (px, py) = (body_x(m, x) as u32, body_y(m, y) as u32);let body = app.body();if px > body.width as u32 || py > body.height as u32 { return None }let geoms = app.visible_layout_geoms();@@ -302,9 +308,12 @@ fn check(app: &mut App, m: &mut Event, double: bool) -> Option<Key> {fn body_y(m: &Event, y: u16) -> u16 {if m.statusat == 0 && y >= m.statuslines { y - m.statuslines }else if m.statusat > 0 && y as i32 >= m.statusat { (m.statusat - 1) as u16 }- else { y }+ else { y.saturating_sub(m.oy) }}+/// A column counted in the window: past the bar when it is down the left.+fn body_x(m: &Event, x: u16) -> u16 { x.saturating_sub(m.ox) }+/// cmd_mouse_window: the window a mouse event was for — a status range's, else the current one.pub fn mouse_window(app: &App, m: &Event) -> Option<usize> {if !m.valid { return None }@@ -325,7 +334,8 @@ pub fn mouse_at(app: &App, pane: u64, m: &Event, last: bool) -> Option<(u16, u16let (x, mut y) = if last { (m.lx, m.ly) } else { (m.x, m.y) };if m.statusat == 0 && y >= m.statuslines { y -= m.statuslines }let (_, g) = app.visible_geoms().into_iter().find(|(id, _)| *id == pane)?;- let (x, y) = (x as u32, y as u32);+ // (Over the bar down a side: not in any pane.)+ let (x, y) = (x.checked_sub(m.ox)? as u32, y.checked_sub(m.oy)? as u32);if x < g.x || x >= g.x + g.w || y < g.y || y >= g.y + g.h { return None }Some(((x - g.x) as u16, (y - g.y) as u16))}@@ -386,7 +396,7 @@ pub fn resize_begin(app: &mut App, m: &Event) {fn resize_update(app: &mut App, m: &Event) {let Some(w) = mouse_window(app, m) else { app.mouse_state.drag = None; return };- let (x, y, lx, ly) = (m.x as u32, body_y(m, m.y) as u32, m.lx as u32, body_y(m, m.ly) as u32);+ let (x, y, lx, ly) = (body_x(m, m.x) as u32, body_y(m, m.y) as u32, body_x(m, m.lx) as u32, body_y(m, m.ly) as u32);app.drag_border(w, lx, ly, x, y);}diff --git a/tui/src/new_harness.rs b/tui/src/new_harness.rsindex c967916df..7f970fe07 100644--- a/tui/src/new_harness.rs+++ b/tui/src/new_harness.rs@@ -15,8 +15,7 @@ use crossterm::event::{use ratatui::{buffer::Buffer,layout::{Position, Rect},- style::{Color, Modifier, Style},- widgets::{Block, BorderType, Borders, Widget},+ style::{Modifier, Style},};use serde_json::{Value, json};use std::{collections::HashMap, time::Duration};@@ -275,8 +274,7 @@ fn short_path(path: &str, home: &str) -> String {}}fn defaults_path() -> std::path::PathBuf {- std::path::PathBuf::from(std::env::var("HOME").unwrap_or_default())- .join(".harness/tui/new-harness.json")+ crate::app::state_dir().join("new-harness.json")}fn defaults() -> Value {if cfg!(test) {@@ -1563,6 +1561,23 @@ mod tests {app}+ /// Opening a chooser beside the form (an agent, here) leaves the form where it was, on a wide+ /// window and a narrow one.+ #[tokio::test]+ async fn the_form_stays_put_when_a_chooser_opens() {+ let mut app = app();+ open(&mut app, None, Some("/home/dev/project".into()));+ let Some(Modal::NewHarness(mut form)) = app.modal.take() else { panic!() };+ for body in [Rect::new(0, 0, 150, 41), Rect::new(0, 0, 90, 30)] {+ form.child = None;+ draw(&mut Buffer::empty(body), body, &mut form);+ let alone = form.area;+ child(&mut app, &mut form, Choice::Agent, "codex");+ draw(&mut Buffer::empty(body), body, &mut form);+ assert_eq!(form.area, alone, "the form moved at {}x{}", body.width, body.height);+ }+ }+#[tokio::test]async fn draft_survives_picker_escape_and_late_refresh() {let mut app = app();diff --git a/tui/src/new_harness/view.rs b/tui/src/new_harness/view.rsindex d97a8a620..15b9a2898 100644--- a/tui/src/new_harness/view.rs+++ b/tui/src/new_harness/view.rs@@ -23,23 +23,8 @@ fn put(buf: &mut Buffer, x: u16, y: u16, width: u16, text: &str, style: Style) {buf.set_stringn(x, y, out, width as usize, style);}-fn panel(buf: &mut Buffer, r: Rect, title: &str, base: Style, border: Style) {- crate::term_out::clear_extras(r);- for y in r.y..r.bottom() {- for x in r.x..r.right() {- if let Some(c) = buf.cell_mut((x, y)) {- c.reset();- c.set_style(base);- }- }- }- Block::default()- .borders(Borders::ALL)- .border_type(BorderType::Rounded)- .border_style(border)- .render(r, buf);- let _ = title;-}+/// The form's surface, as the settings panel draws its own: filled, no border.+fn panel(buf: &mut Buffer, r: Rect, base: Style) { crate::settings::fill(buf, r, base) }pub fn draw(buf: &mut Buffer, body: Rect, form: &mut Form) -> Option<Position> {form.hits.clear();@@ -56,74 +41,20 @@ pub fn draw(buf: &mut Buffer, body: Rect, form: &mut Form) -> Option<Position> {);return None;}- let (_, foreground, light) = theme::palette();- let base = if theme::no_color() {- Style::default()- } else {- theme::fg(foreground).bg(theme::depth_fit(if light {- Color::Rgb(247, 247, 247)- } else {- Color::Rgb(25, 25, 25)- }))- };- let accent = base.patch(theme::bold(theme::accent()));- let muted = base.patch(theme::fg(if light {- Color::Rgb(92, 98, 104)- } else {- Color::Rgb(167, 173, 180)- }));- let border = base.patch(theme::fg(theme::pane_palette().active_foreground));- // Keep the working panes visible under the form, with a quiet backdrop.- crate::term_out::clear_extras(body);- let backdrop = if theme::no_color() {- Style::default().add_modifier(Modifier::DIM)- } else {- theme::fg(if light {- Color::Rgb(185, 185, 185)- } else {- Color::Rgb(32, 32, 32)- })- .bg(theme::depth_fit(if light {- Color::Rgb(230, 230, 230)- } else {- Color::Rgb(4, 4, 4)- }))- .remove_modifier(Modifier::BOLD | Modifier::REVERSED | Modifier::DIM | Modifier::UNDERLINED)- };- for y in body.y..body.bottom() {- for x in body.x..body.right() {- if let Some(c) = buf.cell_mut((x, y)) {- c.set_style(backdrop);- }- }- }- let side = form.child.is_some() && body.width >= 110;- let form_w = if side {- ((u32::from(body.width) - 5) * 3 / 5).min(76) as u16- } else {- body.width.saturating_sub(4).min(76)- };- let child_w = if side {- (body.width - form_w - 5).min(60)- } else {- form_w- };+ // The settings panel's colours, and its quiet backdrop over the working panes.+ let crate::settings::Chrome { base, muted, accent, backdrop, .. } = crate::settings::chrome();+ crate::settings::backdrop(buf, body, backdrop);+ // The form is the menus' panel: centred, the one size whatever is open — and a chooser (an+ // agent, a machine, a folder…) opens in its place, as a section of Appearance does, so+ // nothing moves.+ let side = false;+ let r = crate::settings::area(body);+ let (x, y, form_w, form_h) = (r.x, r.y, r.width, r.height);+ let (child_w, child_h) = (form_w, form_h);let fields = form.fields();- let form_h = (fields.len() as u16 * 2 + 3).min(body.height.saturating_sub(2).max(5));- let child_h = form- .child- .as_ref()- .map(|c| if c.kind.editing() { 8 } else { 22 })- .unwrap_or(0)- .min(body.height.saturating_sub(2).max(5));- let total_w = if side { form_w + 2 + child_w } else { form_w };- let height = form_h.max(child_h);- let x = body.x + (body.width - total_w) / 2;- let y = body.y + (body.height - height) / 2;- let r = Rect::new(x, y, form_w, form_h);form.area = r;if form.child.is_none() || side || !form.child_active {- panel(buf, r, "New Harness", base, border);+ panel(buf, r, base);let gap = if form_h >= fields.len() as u16 * 2 + 3 {2} else {@@ -201,7 +132,7 @@ pub fn draw(buf: &mut Buffer, body: Rect, form: &mut Form) -> Option<Position> {};let r = Rect::new(if side { x + form_w + 2 } else { x }, y, child_w, child_h);form.child_area = r;- panel(buf, r, &c.picker.title, base, border);+ panel(buf, r, base);let query_x = r.x + 4;let query_y = r.y + 2;let query_w = r.width.saturating_sub(6) as usize;diff --git a/tui/src/options/mod.rs b/tui/src/options/mod.rsindex b0069b3e7..1fe2ff875 100644--- a/tui/src/options/mod.rs+++ b/tui/src/options/mod.rs@@ -88,6 +88,8 @@ pub fn defaults() -> &'static BTreeMap<String, String> {static D: OnceLock<BTreeMap<String, String>> = OnceLock::new();D.get_or_init(|| {let mut m = tmux_defaults().clone();+ // (Each pane's title at its top by default — off and bottom are yours to choose, in+ // Appearance → Pane titles.)m.insert("pane-border-status".into(), "top".into());// Each pane's title row: the harness's name, then its state symbol, [watching — who// has it] when another window has the pane to type in, and its project and branch@@ -238,12 +240,49 @@ impl Store {/// panes' title rows), where you have not set them yourself.pub fn tmux_look(&self) -> bool { self.get("@hn-look", "", None).as_deref() == Some("tmux") }+ /// How panes are drawn: `surface` (the "blur" look — the active pane's surface pops, the rest+ /// are dimmed, no border line) or `line` (the classic highlighted border). Set directly by+ /// `@hn-focus` (from the config's `[look].focus`) or, for the legacy `panes` preset, by+ /// `@hn-look panes`.+ pub fn focus_style(&self) -> &'static str {+ match self.get("@hn-focus", "", None).as_deref() {+ Some("surface") => "surface",+ _ => "line",+ }+ }+/// The normal hn presentation; classic keeps the earlier line borders.- pub fn pane_look(&self) -> bool { !matches!(self.get("@hn-look", "", None).as_deref(), Some("tmux" | "classic")) }+ pub fn pane_look(&self) -> bool {+ self.focus_style() == "surface" || self.get("@hn-look", "", None).as_deref() == Some("panes")+ }++ /// `@hn-layout`: the default split direction for a new harness/pane — `auto` (tmux-style, by+ /// the shape of the pane being split), `vertical` or `horizontal`.+ pub fn look_orientation(&self) -> &'static str {+ match self.get("@hn-layout", "", None).as_deref() {+ Some("vertical") => "vertical",+ Some("horizontal") => "horizontal",+ _ => "auto",+ }+ }/// Reduce motion independently of the status/pane appearance.pub fn animations(&self) -> bool { !matches!(self.get("@hn-animations", "", None).as_deref(), Some("off" | "0" | "no")) }+ // ── status bar ──++ /// `@hn-status-bar` (tui.toml `status_bar`): `bottom` or `top` (tmux's status line, where+ /// status-position puts it), or `left`/`right` — the bar down that side.+ pub fn status_bar(&self) -> &'static str {+ match self.get("@hn-status-bar", "", None).as_deref() { Some("left") => "left", Some("right") => "right", Some("top") => "top", _ => "bottom" }+ }++ /// `@hn-border` box (the default): every pane its own frame, a cell apart. `line` is tmux's+ /// shared lines; the blurred surfaces and `@hn-look tmux` draw as they always have.+ pub fn box_panes(&self) -> bool {+ !self.tmux_look() && !self.pane_look() && self.get("@hn-border", "", None).as_deref() != Some("line")+ }+/// The default for a name: hn's, or tmux's under `@hn-look tmux`.fn default_of(&self, name: &str, inherit_window_style: bool) -> Option<String> {if LOOK.contains(&name) && self.tmux_look() { tmux_defaults().get(name).cloned() }@@ -253,6 +292,11 @@ impl Store {if name == "window-active-style" && inherit_window_style { Some("default".into()) }else { pane_default(name) }}+ else if name == "pane-border-status" && self.pane_look() {+ // The opt-in "panes" look keeps each pane's title row; only the classic (default)+ // look drops it, so panes are divided by a plain line.+ Some("top".into())+ }else { defaults().get(name).cloned() }}@@ -611,6 +655,8 @@ mod tests {let mut s = Store::default();let g = SetFlags { global: true, ..Default::default() };let gw = SetFlags { global: true, window: true, ..Default::default() };+ assert!(!s.pane_look()); // the classic line-border look is the default+ s.set("@hn-look", Some("panes"), &g, "", 0).unwrap();assert!(s.pane_look());assert!(s.get("window-style", "", None).unwrap().starts_with("fg=#"));s.set("window-style", Some("bg=blue"), &gw, "", 0).unwrap();@@ -630,6 +676,7 @@ mod tests {SetFlags { window: true, ..Default::default() },SetFlags { pane: true, ..Default::default() }] {let mut s = Store::default();+ s.set("@hn-look", Some("panes"), &SetFlags { global: true, ..Default::default() }, "w", 1).unwrap();assert_ne!(s.get("window-style", "w", Some(1)), s.get("window-active-style", "w", Some(1)));s.set("window-style", Some("fg=red,bg=blue"), &f, "w", 1).unwrap();assert_eq!(s.get("window-active-style", "w", Some(1)).as_deref(), Some("default"));diff --git a/tui/src/pane_frame.rs b/tui/src/pane_frame.rsindex a8580be22..7a14ce2ab 100644--- a/tui/src/pane_frame.rs+++ b/tui/src/pane_frame.rs@@ -7,37 +7,39 @@ use crate::layout::Status;#[derive(Clone, Copy, Debug)]pub struct Frame { pub surface: Rect, pub content: Rect, pub title: Option<Rect> }-pub fn frame(tile: Rect, canvas: Rect, status: Status) -> Frame {+/// A pane as a blurred surface: a box's cells ([boxed_in]) with no line drawn — the surface+/// filled, its edge cell the padding where a box has its line, the title in its top (or bottom)+/// row. So the space between two panes is one cell, as between boxes, never each pane's own+/// padding added to its neighbour's.+pub fn frame(tile: Rect, canvas: Rect, inner: Rect, status: Status) -> Frame { boxed_in(tile, canvas, inner, status) }++// ── box panes ──++/// A pane as a box (`@hn-border box`): its own single-line frame on the pane's outer cells+/// (`surface`), the program inside it. The cell tmux keeps between panes — its divider, or a lower+/// pane's title row — is left empty: a gap, so each pane reads as a box of its own (never two+/// panes on one line). The title goes into the frame's top (or bottom) line (`title`), the top+/// pane's own title row being its frame's top line. The layout's cells stay tmux's, so splits,+/// resizes and layouts are unchanged.+#[cfg(test)]+pub fn boxed(tile: Rect, canvas: Rect, status: Status) -> Frame { boxed_in(tile, canvas, canvas, status) }++/// [boxed], every frame kept inside [inner]: the window less a cell at each edge that has no gap+/// of its own (`App::box_inner`) — so the space around a box is one cell everywhere, at the+/// window's edges as between two boxes, never two.+pub fn boxed_in(tile: Rect, canvas: Rect, inner: Rect, status: Status) -> Frame {let mut outer = tile;- // A small pane gives its cells to the program. Larger panes keep one-cell outer space.- if tile.width >= 12 && canvas.width >= 40 {- if tile.x == canvas.x { outer.x += 1; outer.width -= 1; }- if tile.right() == canvas.right() { outer.width = outer.width.saturating_sub(1); }- }- if tile.height >= 8 && canvas.height >= 12 {- // With top/bottom status, tmux borrows the divider row for a pane title. Leave- // that row as a gutter and draw the title inside the surface instead.- if tile.y == canvas.y || status == Status::Top { outer.y += 1; outer.height -= 1; }- if tile.bottom() == canvas.bottom() || status == Status::Bottom { outer.height = outer.height.saturating_sub(1); }+ match status {+ Status::Top if tile.y != canvas.y => { outer.y += 1; outer.height = outer.height.saturating_sub(1) }+ Status::Bottom if tile.bottom() != canvas.bottom() => outer.height = outer.height.saturating_sub(1),+ _ => {}}- // Fill the entire pane. The former outline cells are now blank padding, keeping- // title/content coordinates stable while focus is shown by the background alone.- let surface = outer;- let roomy = tile != canvas && tile.width >= 12 && canvas.width >= 40- && tile.height >= 8 && canvas.height >= 12;- let inner = if roomy {- Rect::new(surface.x + 1, surface.y + 1, surface.width - 2, surface.height - 2)- } else { surface };- let title = (inner.height > 1 && status != Status::Off).then(|| Rect::new(inner.x,- if status == Status::Bottom { inner.bottom() - 1 } else { inner.y }, inner.width, 1));- let mut content = inner;- if title.is_some() {- if status == Status::Top { content.y += 1; }- content.height -= 1;- }- if content.width >= 12 { content.x += 1; content.width -= 2; }- if content.height >= 10 { content.y += 1; content.height -= 2; }- Frame { surface, content, title }+ outer = outer.intersection(inner);+ // Too small for a frame with something in it: the program has every cell.+ if outer.width < 3 || outer.height < 3 { let cells = if outer.height == 0 { tile } else { outer }; return Frame { surface: cells, content: cells, title: None } }+ let content = Rect::new(outer.x + 1, outer.y + 1, outer.width - 2, outer.height - 2);+ let title = (status != Status::Off).then(|| Rect::new(outer.x + 1, if status == Status::Bottom { outer.bottom() - 1 } else { outer.y }, outer.width - 2, 1));+ Frame { surface: outer, content, title }}#[cfg(test)]@@ -45,35 +47,47 @@ mod tests {use super::*;#[test]- fn small_panes_keep_usable_cells_and_every_rect_stays_inside() {- for w in 1..=100 { for h in 1..=40 { for status in [Status::Off, Status::Top, Status::Bottom] {- let tile = Rect::new(3, 2, w, h);- let canvas = Rect::new(0, 0, w + 8, h + 6);- let f = frame(tile, canvas, status);- assert_eq!(f.surface.intersection(tile), f.surface);- assert_eq!(f.content.intersection(f.surface), f.content);- assert!(f.content.width > 0 && f.content.height > 0);- if let Some(title) = f.title { assert_eq!(title.intersection(f.content).height, 0); }-- } } }+ fn blurred_surfaces_sit_where_the_boxes_do() {+ let canvas = Rect::new(0, 0, 120, 40);+ let inner = Rect::new(1, 1, 118, 38);+ for status in [Status::Off, Status::Top, Status::Bottom] {+ let (left, right) = (frame(Rect::new(0, 0, 59, 40), canvas, inner, status), frame(Rect::new(60, 0, 60, 40), canvas, inner, status));+ assert_eq!(right.surface.x - left.surface.right(), 1, "{status:?}: one cell between two surfaces");+ assert_eq!(right.content.x - left.content.right(), 3, "{status:?}: each surface's edge cell, then the gap");+ assert_eq!(left.surface, boxed_in(Rect::new(0, 0, 59, 40), canvas, inner, status).surface);+ }}+ // ── box panes ──+#[test]- fn stacked_and_side_by_side_surfaces_leave_divider_gaps() {- let canvas = Rect::new(0, 0, 120, 40);- let left = frame(Rect::new(0, 0, 59, 40), canvas, Status::Top);- let right = frame(Rect::new(60, 0, 60, 40), canvas, Status::Top);- assert_eq!(right.surface.x - left.surface.right(), 1);- assert_eq!(left.surface.intersection(right.surface).width, 0);- let top = frame(Rect::new(0, 0, 120, 20), canvas, Status::Top);- let bottom = frame(Rect::new(0, 20, 120, 20), canvas, Status::Top);- assert_eq!(bottom.surface.y - top.surface.bottom(), 1);- assert_eq!(top.surface.intersection(bottom.surface).height, 0);- assert!(top.content.y > top.title.unwrap().y);- let single = frame(canvas, canvas, Status::Top);- assert_eq!(single.title.unwrap().y, single.surface.y);- // Compact and single panes give the extra padding back to their content.- let compact = frame(Rect::new(20, 20, 40, 5), canvas, Status::Top);- assert_eq!(compact.title.unwrap().y, compact.surface.y);+ fn boxes_frame_each_pane_a_cell_apart_with_the_title_in_the_frame() {+ use crate::layout::{Dir, Node};+ let canvas = Rect::new(26, 1, 100, 40);+ for status in [Status::Off, Status::Top, Status::Bottom] {+ // Three panes: a left one, and a right column of two (tmux's cells, titles included).+ let mut n = Node::new(1, canvas.width, canvas.height);+ n.status = status;+ n.split(1, 2, Dir::Horizontal);+ n.split(2, 3, Dir::Vertical);+ let mut tiles = Vec::new();+ n.rects(canvas, &mut tiles);+ let boxes: Vec<Frame> = tiles.iter().map(|(_, t)| boxed(*t, canvas, status)).collect();+ for (i, b) in boxes.iter().enumerate() {+ assert_eq!(b.surface.intersection(canvas), b.surface, "{status:?}: inside the window");+ assert_eq!(b.content, Rect::new(b.surface.x + 1, b.surface.y + 1, b.surface.width - 2, b.surface.height - 2));+ match status { Status::Off => assert!(b.title.is_none()), Status::Top => assert_eq!(b.title.unwrap().y, b.surface.y), Status::Bottom => assert_eq!(b.title.unwrap().y, b.surface.bottom() - 1) }+ for other in &boxes[i + 1..] { assert_eq!(b.surface.intersection(other.surface).area(), 0, "{status:?}: frames never share a cell") }+ }+ // One empty cell between side-by-side frames and between stacked ones — each pane a+ // box of its own; the window's edges are the outer frames' edges.+ assert_eq!(boxes[1].surface.x - boxes[0].surface.right(), 1, "{status:?}");+ assert_eq!(boxes[2].surface.y - boxes[1].surface.bottom(), 1, "{status:?}");+ assert_eq!((boxes[0].surface.x, boxes[0].surface.y, boxes[0].surface.bottom()), (canvas.x, canvas.y, canvas.bottom()));+ assert_eq!(boxes[1].surface.right(), canvas.right());+ }+ // A pane too small for a frame keeps every cell for its program.+ let tiny = boxed(Rect::new(30, 5, 2, 5), canvas, Status::Off);+ assert_eq!(tiny.content, Rect::new(30, 5, 2, 5));}}diff --git a/tui/src/picker.rs b/tui/src/picker.rsindex 793de715e..e82d20498 100644--- a/tui/src/picker.rs+++ b/tui/src/picker.rs@@ -213,6 +213,10 @@ pub struct Picker {pub track_current: Option<String>,/// search(…): what is searched for in place of the query, until the query changes.pub search: Option<String>,+ /// The look/theme picker: the section the cursor is inside (None: the section list is shown).+ pub theme_in: Option<String>,+ /// Opened from the command list (C-b Space): Esc goes back to it rather than closing.+ pub from_commands: bool,}impl Picker {@@ -290,6 +294,8 @@ impl Picker {excluded: Default::default(),track_current: None,search: None,+ theme_in: None,+ from_commands: false,preview_of: None,preview_fresh: std::cell::Cell::new(true),preview_reposition: Default::default(),diff --git a/tui/src/preview.rs b/tui/src/preview.rsindex 21bacc572..4c0d00f8f 100644--- a/tui/src/preview.rs+++ b/tui/src/preview.rs@@ -28,7 +28,11 @@ pub fn lines(app: &App, kind: &PickerKind, id: &str) -> Vec<Line<'static>> {PickerKind::Keys => id.split_once('\t').map(|(k, c)| vec![Line::from(vec![bold(format!("{} {k}", crate::keys::name(&app.keymap.prefix)))]), Line::raw(""), Line::raw(c.to_string())]).unwrap_or_default(),PickerKind::Buffers => app.paste.get(id).map(|b| b.data.lines().map(|l| ansi_line(l, crate::theme::fzf_opts().tabstop)).collect()).unwrap_or_default(),PickerKind::Store => store(app, id),- PickerKind::Models => vec![Line::raw(id.rsplit(':').next().unwrap_or(id).to_string())],+ // ── models: a Models view row's facts and what Enter does (models.rs) ──+ PickerKind::Models if crate::models::is_row(id) => crate::models::preview(app, id),+ PickerKind::Models => vec![Line::raw(id.rsplit(':').next().unwrap_or(id).to_string()), Line::raw(""), Line::raw("Enter switches this harness to it.")],+ // ── machines & devices ──+ PickerKind::Devices(view) => crate::devices::preview(app, *view, id),_ => vec![],}}diff --git a/tui/src/server.rs b/tui/src/server.rsindex 823bc6f0c..ca058895b 100644--- a/tui/src/server.rs+++ b/tui/src/server.rs@@ -107,6 +107,8 @@ fn keys_from(v: &Value, mut k: Keymap) -> Keymap {if let Some(c) = v.get("prefix").and_then(Value::as_str).and_then(|s| crate::keys::parse(s).ok()) { k.prefix = c }k.prefix2 = v.get("prefix2").and_then(Value::as_str).and_then(|s| crate::keys::parse(s).ok());k.prefix_table = bindings_from(&v["prefix-table"]);+ // (Kept before a default changed: that default moves on with it.)+ Keymap::migrate_defaults(&mut k.prefix_table);k.root_table = bindings_from(&v["root"]);k.copy_vi = bindings_from(&v["copy-mode-vi"]);k.copy_emacs = bindings_from(&v["copy-mode"]);diff --git a/tui/src/settings.rs b/tui/src/settings.rsnew file mode 100644index 000000000..764d3c441--- /dev/null+++ b/tui/src/settings.rs@@ -0,0 +1,860 @@+//! The settings panel: `hn theme` drawn as one centred panel in the New Harness style — a quiet+//! backdrop over the panes, no border, and a fixed size, so it stays put as you step into a+//! section. The list is on the left; the right is one preview of the whole look (every section at+//! once), which only changes where the row under the cursor would change it.+use ratatui::buffer::Buffer;+use ratatui::layout::{Position, Rect};+use ratatui::style::{Color, Modifier, Style};+use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};++use crate::app::App;+use crate::modal::PickerKind;+use crate::picker::Picker;+use crate::terminal_themes::{TerminalTheme, TERMINAL_THEMES};+use crate::theme;++/// `@hn-lists fzf`: hn's lists drawn as fzf draws them (full screen, FZF_DEFAULT_OPTS's look)+/// rather than as this panel — for those who want fzf's own. Settings and commands stay panels.+static FZF_LISTS: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);++pub fn set_fzf_lists(on: bool) { FZF_LISTS.store(on, std::sync::atomic::Ordering::Relaxed) }++/// The lists drawn as this panel rather than as fzf's full-screen list: every one, unless+/// `@hn-lists fzf` asks for fzf's.+pub fn is_panel(kind: &PickerKind) -> bool {+ matches!(kind, PickerKind::Theme | PickerKind::Commands | PickerKind::Devices(_) | PickerKind::Models) || !FZF_LISTS.load(std::sync::atomic::Ordering::Relaxed)+}++/// Whether [kind]'s list reads top-down (↑ toward its first row): fzf's under --layout=reverse,+/// and the panel's menus; the launcher's lists read bottom-up in the panel too, their query+/// under them, as fzf's do.+pub fn top_down(kind: &PickerKind) -> bool {+ if is_panel(kind) { !crate::modal::is_launcher(kind) } else { theme::fzf().reverse }+}++/// Step into [section]: its options in the same list, the cursor on the one in use.+pub fn open_section(app: &App, picker: &mut Picker, section: &str) {+ picker.theme_in = Some(section.to_string());+ picker.clear_query();+ picker.rows.clear();+ picker.set_rows(crate::modal::theme_options(app, section));+ let current = picker.rows.iter().find(|r| r.lead.iter().any(|s| s.content.as_ref() == "✓ ")).map(|r| r.id.clone());+ picker.scroll = 0;+ if let Some(id) = current { cursor_to(picker, &id) } else { picker.vset(0, 1) }+}++/// Step back out to the sections, the cursor on the one just left.+pub fn close_section(app: &App, picker: &mut Picker) {+ let from = picker.theme_in.take().map(|s| format!("section:{s}"));+ picker.clear_query();+ picker.rows.clear();+ picker.set_rows(crate::modal::theme_sections(app));+ picker.scroll = 0;+ if let Some(id) = from { cursor_to(picker, &id) }+}++/// Settings chosen in the command list: the same panel shows the sections, and Esc comes back.+pub fn into_settings(app: &App, picker: &mut Picker) {+ picker.from_commands = true;+ picker.placeholder = "Search appearance".into();+ picker.keep_order = true;+ picker.live = false;+ picker.theme_in = None;+ picker.clear_query();+ picker.rows.clear();+ picker.set_rows(crate::modal::theme_sections(app));+ picker.scroll = 0;+ picker.vset(0, 1);+}++/// Back from the settings to the command list, the cursor on Settings.+pub fn back_to_commands(app: &App, picker: &mut Picker) {+ picker.from_commands = false;+ picker.theme_in = None;+ picker.placeholder = "Type a command — appearance, new, layout, models…".into();+ picker.keep_order = false;+ picker.live = true;+ picker.clear_query();+ picker.rows.clear();+ picker.set_rows(crate::modal::command_rows_for(app, false));+ picker.scroll = 0;+ cursor_to(picker, "cmd:theme");+}++/// Put the cursor on the row [id] (where the filter shows it).+pub fn cursor_to(picker: &mut Picker, id: &str) { picker.select(id) }++/// The panel's colours, shared with the New Harness form so the two read as one component:+/// its surface, muted and accent text, and the backdrop laid over the panes behind it.+pub struct Chrome { pub base: Style, pub muted: Style, pub accent: Style, pub backdrop: Style, pub selected: Style }++pub fn chrome() -> Chrome {+ if theme::no_color() {+ let base = Style::default();+ return Chrome { base, muted: base.add_modifier(Modifier::DIM), accent: base.add_modifier(Modifier::BOLD), backdrop: base.add_modifier(Modifier::DIM), selected: base.add_modifier(Modifier::REVERSED) };+ }+ chrome_for(theme::pane_palette())+}++/// The panel's colours from [pal] — the theme in use (or the terminal's own colours): the panel is+/// its surface lifted a little toward the text, the backdrop its surface pushed down, so the panel+/// stands out in any theme, light or dark.+pub fn chrome_for(pal: theme::PanePalette) -> Chrome {+ let (bg, fg) = (pal.surface, pal.foreground);+ let light = matches!(bg, Color::Rgb(r, g, b) if 299 * r as u32 + 587 * g as u32 + 114 * b as u32 > 128_000);+ let floor = if light { Color::Rgb(160, 160, 160) } else { Color::Rgb(0, 0, 0) };+ let panel = mix(bg, fg, if light { 3 } else { 7 });+ let base = theme::fg(fg).bg(theme::depth_fit(panel));+ let muted = base.patch(theme::fg(pal.muted));+ let accent = base.patch(theme::bold(theme::accent()));+ let backdrop = theme::fg(mix(bg, fg, 18)).bg(theme::depth_fit(mix(bg, floor, 45)))+ .remove_modifier(Modifier::BOLD | Modifier::REVERSED | Modifier::DIM | Modifier::UNDERLINED);+ // (The cursor's row: the text's own colour, bold, on a lifted surface — the accent is for the+ // pointer and the query's mark, not for words.)+ let selected = base.add_modifier(Modifier::BOLD).bg(theme::depth_fit(mix(panel, fg, 10)));+ Chrome { base, muted, accent, backdrop, selected }+}++/// [a] moved [amount] % toward [b] (RGB; any other colour stays as it is).+fn mix(a: Color, b: Color, amount: u16) -> Color {+ let (Color::Rgb(ar, ag, ab), Color::Rgb(br, bg, bb)) = (a, b) else { return a };+ let c = |a: u8, b: u8| ((a as u16 * (100 - amount) + b as u16 * amount) / 100) as u8;+ Color::Rgb(c(ar, br), c(ag, bg), c(ab, bb))+}++/// Dim every cell of [area] under the panel, keeping what is drawn there visible.+pub fn backdrop(buf: &mut Buffer, area: Rect, style: Style) {+ crate::term_out::clear_extras(area);+ for y in area.y..area.bottom() { for x in area.x..area.right() { if let Some(c) = buf.cell_mut((x, y)) { c.set_style(style); } } }+}++/// Fill [r] with the panel's surface — no border: the surface against the backdrop is the edge.+pub fn fill(buf: &mut Buffer, r: Rect, base: Style) {+ crate::term_out::clear_extras(r);+ for y in r.y..r.bottom() { for x in r.x..r.right() { if let Some(c) = buf.cell_mut((x, y)) { c.reset(); c.set_style(base); } } }+}++/// [text] at (x, y) in at most [width] columns, cut with an ellipsis. Returns the columns used.+pub fn put(buf: &mut Buffer, x: u16, y: u16, width: u16, text: &str, style: Style) -> u16 {+ if width == 0 { return 0 }+ let limit = width as usize;+ let cut = text.width() > limit;+ let (mut out, mut used) = (String::new(), 0);+ for ch in text.chars().filter(|c| !c.is_control()) {+ let w = ch.width().unwrap_or(0);+ if used + w > limit - usize::from(cut) { break }+ out.push(ch);+ used += w;+ }+ if cut { out.push('…'); used += 1 }+ buf.set_stringn(x, y, out, limit, style);+ used as u16+}++/// Where the panel goes in [body]: centred, and the same size whatever the list holds.+pub fn area(body: Rect) -> Rect {+ // (Room for a preview that can be read: nine tenths of the window each way, and at least 4+ // columns and 2 rows of it around the panel.)+ let w = (body.width * 9 / 10).min(body.width.saturating_sub(4));+ let h = (body.height * 9 / 10).min(body.height.saturating_sub(2));+ Rect::new(body.x + (body.width - w) / 2, body.y + (body.height - h) / 2, w, h)+}++/// Draw the panel for [picker] over [body]; returns where the terminal cursor goes (the query),+/// and the rect on the right where the list's own preview goes (the caller draws it: a harness's+/// preview is its live screen, which needs the whole app).+pub fn draw(buf: &mut Buffer, app: &App, body: Rect, kind: &PickerKind, picker: &mut Picker) -> (Option<Position>, Option<Rect>) {+ // ── machines & devices ── (the same panel, laid out by devices.rs: Add phone's QR code takes+ // the panel's whole height, and each view draws its own right side)+ if let PickerKind::Devices(view) = kind { return (crate::devices::draw(buf, app, body, *view, picker), None) }+ let c = chrome();+ backdrop(buf, body, c.backdrop);+ if body.width < 24 || body.height < 8 {+ put(buf, body.x, body.y, body.width, &format!("{} · resize or Esc", title(app, kind, picker)), c.base);+ return (None, None);+ }+ let r = area(body);+ fill(buf, r, c.base);+ picker.screen_area.set(r);+ let (x, right) = (r.x + 2, r.right().saturating_sub(2));+ let inner_w = right.saturating_sub(x);++ // Title: where you are, and how to leave.+ let mut at = x + put(buf, x, r.y + 1, inner_w, &title(app, kind, picker), c.base.add_modifier(Modifier::BOLD));+ if let Some(section) = picker.theme_in.as_deref() {+ at += put(buf, at, r.y + 1, right.saturating_sub(at), " › ", c.muted);+ at += put(buf, at, r.y + 1, right.saturating_sub(at), section_title(section), c.accent);+ }+ // What the list says of itself (a count, "searching…"), before the way out.+ let status = picker.busy.clone().unwrap_or_else(|| picker.status.clone());+ if !status.is_empty() {+ let w = (status.width() as u16).min(right.saturating_sub(at + 8));+ put(buf, right.saturating_sub(w + 6), r.y + 1, w, &status, c.muted);+ }+ put(buf, right.saturating_sub(3), r.y + 1, 3, "esc", c.muted);++ // The query: at the top of the menus (as the New Harness chooser has its own); at the bottom+ // of the launcher's lists, fzf's way, its keys and its count over it (below).+ let launcher = crate::modal::is_launcher(kind);+ let qy = if launcher { r.bottom().saturating_sub(2) } else { r.y + 3 };+ put(buf, x, qy, 2, "›", c.accent);+ let hint = if launcher { format!("Search {}", title(app, kind, picker).to_lowercase()) } else { picker.placeholder.clone() };+ let shown = if picker.query.is_empty() { (hint.as_str(), c.muted) } else { (picker.query.as_str(), c.base) };+ let qw = put(buf, x + 2, qy, inner_w.saturating_sub(2), shown.0, shown.1);+ picker.prompt_at.set((qy, x + 2));+ let before: String = picker.query.chars().take(picker.qcursor).collect();+ let cursor = Position::new((x + 2 + before.width() as u16).min(right), qy);++ if launcher {+ // After the query: the lists it switches between, the one you are in marked.+ let here = crate::picker::scope_of(&picker.query);+ let mut sx = x + 2 + qw + 3;+ for (ch, name) in [(Some('>'), "commands"), (Some('@'), "machines"), (Some('#'), "projects"), (Some(':'), "models"), (Some('*'), "store"), (Some('?'), "help")] {+ let text = format!("{} {name}", ch.unwrap_or(' '));+ if sx + text.width() as u16 > right { break }+ let on = here == ch;+ sx += put(buf, sx, qy, right.saturating_sub(sx), &text, if on { c.base.add_modifier(Modifier::BOLD | Modifier::UNDERLINED) } else { c.muted }) + 3;+ }+ // Over it: how many rows match of how many (and how many marked), a rule after.+ let count = format!("{}/{} ({})", picker.visible.len(), picker.rows.len(), picker.marked.len());+ let cw = put(buf, x, qy - 1, inner_w, &count, c.muted);+ for cx in x + cw + 1..right { put(buf, cx, qy - 1, 1, "─", c.muted.remove_modifier(Modifier::BOLD)); }+ // Over that: this list's keys, `key what` · `key what`, the keys bold.+ let mut kx = x;+ for (i, (k, what)) in picker.hints.iter().enumerate() {+ if i > 0 { kx += put(buf, kx, qy - 2, right.saturating_sub(kx), " · ", c.muted); }+ kx += put(buf, kx, qy - 2, right.saturating_sub(kx), k, c.base.add_modifier(Modifier::BOLD));+ kx += put(buf, kx, qy - 2, right.saturating_sub(kx), &format!(" {what}"), c.muted);+ if kx >= right { break }+ }+ }++ // The list, and beside it the preview when there is room for both.+ // (Without a keys row, the list and the preview reach down to the panel's last rows; the+ // launcher's reach down to its keys.)+ let (top, bottom) = if launcher { (r.y + 3, r.bottom().saturating_sub(5)) } else { (r.y + 5, r.bottom().saturating_sub(if keyed(kind) { 3 } else { 1 })) };+ let rows = bottom.saturating_sub(top) as usize;+ // (Commands need no preview: the list takes the width, a row's hint beside its name. A list+ // that is the whole answer — output, messages, keys — has none either.)+ let settings = matches!(kind, PickerKind::Theme);+ let side = inner_w >= 64 && (settings || (picker.preview && !matches!(kind, PickerKind::Commands)));+ // (A list's preview gets the larger part: a harness's screen, a machine's, a model's facts.)+ let list_w = if !side { inner_w } else if settings { (inner_w * 2 / 5).clamp(28, 40) } else { (inner_w * 2 / 5).clamp(30, 48) };+ list_from(buf, picker, Rect::new(x, top, list_w, rows as u16), &c, !side, launcher);+ picker.preview_area.set(None);+ picker.bar.set(None);+ let mut shown = None;+ if side {+ let px = x + list_w + 3;+ // (The settings' preview is the page's picture, from the query line down; a list's is+ // beside its rows, under the query and the scopes, which keep the whole width.)+ let from = if settings { r.y + 3 } else { top };+ let pr = Rect::new(px, from, right.saturating_sub(px), bottom.saturating_sub(from));+ if settings {+ let look = Look::of(app).with(picker.theme_in.as_ref().and(picker.current_id()).as_deref());+ preview(buf, pr, &look, &c);+ } else {+ // A thin rule between the list and its preview, in the panel's muted colour.+ for y in pr.y..pr.bottom() { put(buf, px - 2, y, 1, "│", c.muted.remove_modifier(Modifier::BOLD)); }+ picker.preview_area.set(Some((pr, 'r')));+ shown = Some(pr);+ }+ }++ // The footer: what was just said, else — in the menus (Commands, Appearance) — their keys. The+ // other lists say nothing there: their room is the list's and the preview's.+ // (The launcher's: in place of its keys, for the moment it is said.)+ let fy = r.bottom().saturating_sub(if launcher { 4 } else if keyed(kind) { 2 } else { 1 });+ let flash = picker.flash.as_ref().filter(|(_, at)| at.elapsed().as_secs() < 3).map(|(t, _)| t.clone());+ let keys = match kind {+ PickerKind::Commands => Some("↑↓ move enter run type to search esc close"),+ PickerKind::Theme if picker.theme_in.is_some() => Some("↑↓ move enter apply ← back esc back"),+ PickerKind::Theme if picker.from_commands => Some("↑↓ move → open type to search esc back"),+ PickerKind::Theme => Some("↑↓ move → open type to search esc close"),+ _ => None,+ };+ match (flash, keys) {+ (Some(text), _) => { put(buf, x, fy, inner_w, &" ".repeat(inner_w as usize), c.base); put(buf, x, fy, inner_w, &text, c.accent); }+ (None, Some(keys)) => { put(buf, x, fy, inner_w, keys, c.muted); }+ (None, None) => {}+ }+ (Some(cursor), shown)+}++/// The menus, whose footer says their keys (the other lists give that row to their rows).+fn keyed(kind: &PickerKind) -> bool { matches!(kind, PickerKind::Theme | PickerKind::Commands) }++/// The panel's title: the list's own name (the launcher's for its lists, else what opened it).+fn title(app: &App, kind: &PickerKind, picker: &Picker) -> String {+ match kind {+ PickerKind::Theme => "Appearance".into(),+ PickerKind::Commands => "Commands".into(),+ PickerKind::Devices(view) => view.title().into(),+ k if crate::modal::is_launcher(k) => capital(&crate::modal::launcher_title(app, k).0),+ _ => capital(&picker.heading.clone().unwrap_or_else(|| picker.title.clone())),+ }+}++fn capital(t: &str) -> String { let mut c = t.chars(); c.next().map(|f| f.to_uppercase().chain(c).collect()).unwrap_or_default() }++pub fn section_title(section: &str) -> &'static str {+ match section {+ "status" => "Pane titles", "focus" => "Focus",+ "split" => "Split direction", "layout" => "Layout", "theme" => "Theme",+ // ── status bar ──+ "bar" => "Status bar", "boxes" => "Borders",+ _ => "",+ }+}++/// The rows, top-down, the cursor's row marked as the New Harness chooser marks its own.+pub fn list(buf: &mut Buffer, picker: &mut Picker, r: Rect, c: &Chrome, details: bool) { list_from(buf, picker, r, c, details, false) }++/// [list], [bottom_up]: the first row at the bottom, by the query under it, the rest going up+/// (fzf's way, for the launcher's lists) — a group's heading over its rows still.+pub fn list_from(buf: &mut Buffer, picker: &mut Picker, r: Rect, c: &Chrome, details: bool, bottom_up: bool) {+ picker.list_area.set(r);+ let mut row_at = Vec::new();+ let n = r.height as usize;+ if n == 0 { picker.row_at = row_at; return }+ if picker.visible.is_empty() {+ // (A list says what its emptiness means — "no harnesses yet" — where it can.)+ let empty = if picker.empty.is_empty() || !picker.query.is_empty() { "Nothing matches".to_string() } else { picker.empty.clone() };+ put(buf, r.x + 2, if bottom_up { r.bottom() - 1 } else { r.y }, r.width.saturating_sub(2), &empty, c.muted);+ picker.row_at = row_at;+ return;+ }+ // The lines as drawn: each row, and a titled heading (a blank line before it) wherever the+ // group changes — as opencode's palette groups its commands. The scroll counts lines.+ let mut lines: Vec<Option<usize>> = Vec::new();+ let mut titles: Vec<(usize, String)> = Vec::new();+ let mut last: Option<&str> = None;+ // (While typing, the best matches come first, untitled — as opencode's search reads.)+ // (A launcher's scope character alone — `:` — is no search yet: its list keeps its headings.)+ let grouped = picker.query.is_empty() || (picker.prefixed && crate::picker::scope_of(&picker.query).is_some() && picker.query.trim().chars().count() == 1);+ if !bottom_up {+ for vi in 0..picker.visible.len() {+ let group = picker.rows[picker.visible[vi].0].group.as_deref().filter(|_| grouped);+ if group.is_some() && group != last {+ if !lines.is_empty() { lines.push(None) }+ titles.push((lines.len(), group.unwrap_or_default().to_string()));+ lines.push(None);+ }+ last = group;+ lines.push(Some(vi));+ }+ } else {+ // Bottom up: a group's rows, then its heading (drawn over them), then a blank.+ let mut pending: Option<String> = None;+ for vi in 0..picker.visible.len() {+ let group = picker.rows[picker.visible[vi].0].group.as_deref().filter(|_| grouped);+ if group != last {+ if let Some(title) = pending.take() { titles.push((lines.len(), title)); lines.push(None); lines.push(None) }+ pending = group.map(str::to_string);+ }+ last = group;+ lines.push(Some(vi));+ }+ if let Some(title) = pending { titles.push((lines.len(), title)); lines.push(None) }+ }+ let at_line = lines.iter().position(|l| *l == Some(picker.cursor)).unwrap_or(0);+ // (The cursor's heading comes into view with it.)+ let top = if !bottom_up && at_line >= 1 && titles.iter().any(|(i, _)| *i + 1 == at_line) { at_line - 1 } else { at_line };+ if top < picker.scroll { picker.scroll = top }+ if at_line >= picker.scroll + n { picker.scroll = at_line + 1 - n }+ picker.scroll = picker.scroll.min(lines.len().saturating_sub(n));+ for (slot, line) in lines.iter().enumerate().skip(picker.scroll).take(n).map(|(i, l)| (i - picker.scroll, (i, *l))) {+ let y = if bottom_up { r.bottom() - 1 - slot as u16 } else { r.y + slot as u16 };+ let (li, Some(vi)) = line else {+ if let Some((_, title)) = titles.iter().find(|(i, _)| *i == line.0) { put(buf, r.x + 2, y, r.width.saturating_sub(2), title, c.muted.add_modifier(Modifier::BOLD)); }+ continue;+ };+ let _ = li;+ let row = &picker.rows[picker.visible[vi].0];+ let here = vi == picker.cursor;+ let style = if here { c.selected } else { c.base };+ if here { for x in r.x..r.right() { if let Some(cell) = buf.cell_mut((x, y)) { cell.set_style(style); } } }+ put(buf, r.x, y, 1, if here { "›" } else { " " }, if here { c.selected } else { c.accent });+ // Marked with Tab (several at once): a dot beside the pointer.+ if picker.marked.contains(&row.id) { put(buf, r.x + 1, y, 1, "•", if here { c.selected } else { c.accent }); }+ let mut at = r.x + 2;+ for span in &row.lead {+ let s = if here { style.patch(Style::default().fg(span.style.fg.unwrap_or(Color::Reset))) } else { c.base.patch(span.style) };+ at += put(buf, at, y, r.right().saturating_sub(at), &span.content, s);+ }+ // The right column as the row has it for this width (its short form in a narrow list:+ // a harness's age, not its project and machine), and never more than a third of the+ // row — so it can not run off the panel or over the name.+ let right_text = row.right_at(r.width as usize);+ let right_w = (right_text.width() as u16).min(r.width / 3);+ // (The last column is the scroll mark's, with a blank before it.)+ let end = r.right().saturating_sub(if right_w > 0 { right_w + 3 } else { 2 });+ // The hint after the name, in a column of its own, where there is room for both.+ let hint: String = if details { row.detail.iter().map(|s| s.content.as_ref()).collect() } else { String::new() };+ let hx = at + 28;+ let with_hint = !hint.is_empty() && hx + 8 < end;+ at += put(buf, at, y, if with_hint { 26 } else { end.saturating_sub(at) }, &row.label, style);+ if with_hint { put(buf, hx.max(at + 2), y, end - hx.max(at + 2), &hint, if here { style.remove_modifier(Modifier::BOLD) } else { c.muted }); }+ if right_w > 0 { put(buf, r.right().saturating_sub(right_w + 2), y, right_w, right_text, if here { style } else { c.muted }); }+ row_at.push((y, vi));+ }+ // (No scrollbar: the list follows the cursor, the wheel scrolls it.)+ picker.row_at = row_at;+}++// ── the preview: a small hn with the whole look applied ─────────────────────────────++/// Every setting the panel covers, as the preview draws it.+#[derive(Clone, Debug)]+pub struct Look {+ pub status: String,+ pub indicators: String,+ pub lines: String,+ pub surface: bool,+ pub split: String,+ pub layout: String,+ pub theme: Option<&'static TerminalTheme>,+ // ── status bar ──+ /// Where the status bar is (bottom, top, left, right), and box panes.+ pub bar: String,+ pub boxes: bool,+}++impl Look {+ /// The look as the options hold it now.+ pub fn of(app: &App) -> Look {+ let o = &app.options;+ let get = |k: &str, d: &str| o.get(k, "", None).unwrap_or_else(|| d.to_string());+ let theme = o.get("@hn-theme", "", None).and_then(|n| TERMINAL_THEMES.iter().find(|t| t.name == n));+ Look {+ status: get("pane-border-status", "top"),+ indicators: get("pane-border-indicators", "colour"),+ lines: get("pane-border-lines", "single"),+ surface: o.focus_style() == "surface",+ split: o.look_orientation().to_string(),+ layout: get("@hn-layout-preset", "auto"),+ theme,+ // ── status bar ──+ bar: match o.status_bar() { "bottom" if app.status_top => "top".into(), b => b.into() },+ boxes: o.get("@hn-border", "", None).as_deref() != Some("line"),+ }+ }++ /// The look with the row under the cursor (`knob:value`) in effect — what choosing it would do.+ pub fn with(mut self, row: Option<&str>) -> Look {+ let Some((knob, value)) = row.and_then(|r| r.split_once(':')) else { return self };+ match knob {+ "border_status" => self.status = value.into(),+ "border_indicators" => self.indicators = value.into(),+ "border_lines" => self.lines = value.into(),+ "focus" => self.surface = value == "surface",+ "layout_orientation" => self.split = value.into(),+ "layout_preset" => self.layout = value.into(),+ "theme" => self.theme = TERMINAL_THEMES.iter().find(|t| t.name == value),+ // ── status bar ──+ "status_bar" => self.bar = value.into(),+ "border_style" => self.boxes = value == "box",+ _ => {}+ }+ self+ }+}++fn rgb(c: [u8; 3]) -> Color { theme::depth_fit(Color::Rgb(c[0], c[1], c[2])) }++/// hn's own accent on the terminal's own colours (no theme's): its teal, for light or dark.+fn native_accent() -> Color {+ let light = crate::term_out::native_terminal_colours().and_then(|(bg, _)| crate::tmuxconf::colour(&bg)).is_some_and(|c| matches!(c, Color::Rgb(r, g, b) if 299 * r as u32 + 587 * g as u32 + 114 * b as u32 > 128_000));+ if light { Color::Rgb(0, 100, 120) } else { Color::Rgb(95, 215, 230) }+}++/// The panes a layout makes of [r], the first the active one: tmux's presets with three panes,+/// `auto` two split the way the split direction says (left|right when it is free to choose here).+pub fn tiles(r: Rect, layout: &str, split: &str) -> Vec<Rect> {+ let cols = |r: Rect, n: u16| -> Vec<Rect> {+ let w = r.width.saturating_sub(n - 1) / n;+ (0..n).map(|i| { let x = r.x + i * (w + 1); Rect::new(x, r.y, if i + 1 == n { r.right().saturating_sub(x) } else { w }, r.height) }).collect()+ };+ let rows = |r: Rect, n: u16| -> Vec<Rect> {+ let h = r.height.saturating_sub(n - 1) / n;+ (0..n).map(|i| { let y = r.y + i * (h + 1); Rect::new(r.x, y, r.width, if i + 1 == n { r.bottom().saturating_sub(y) } else { h }) }).collect()+ };+ match layout {+ "even-horizontal" => cols(r, 3),+ "even-vertical" => rows(r, 3),+ "main-horizontal" => {+ let h = (r.height * 3 / 5).max(1);+ let mut v = vec![Rect::new(r.x, r.y, r.width, h)];+ v.extend(cols(Rect::new(r.x, r.y + h + 1, r.width, r.height.saturating_sub(h + 1)), 2));+ v+ }+ "main-vertical" => {+ let w = (r.width * 3 / 5).max(1);+ let mut v = vec![Rect::new(r.x, r.y, w, r.height)];+ v.extend(rows(Rect::new(r.x + w + 1, r.y, r.width.saturating_sub(w + 1), r.height), 2));+ v+ }+ "tiled" => {+ let halves = rows(r, 2);+ let mut v = cols(halves[0], 2);+ v.push(halves[1]);+ v+ }+ // (Horizontal is a left|right split, as `smart_dir` splits a wide pane.)+ _ => if split == "vertical" { rows(r, 2) } else { cols(r, 2) },+ }+}++/// A border cell's glyph from the border cells around it — the lines join as tmux's do.+pub(crate) fn joint(lines: &str, up: bool, down: bool, left: bool, right: bool) -> &'static str {+ let set: [&str; 11] = match lines {+ "double" => ["═", "║", "╔", "╗", "╚", "╝", "╠", "╣", "╦", "╩", "╬"],+ "heavy" => ["━", "┃", "┏", "┓", "┗", "┛", "┣", "┫", "┳", "┻", "╋"],+ "simple" => ["-", "|", "+", "+", "+", "+", "+", "+", "+", "+", "+"],+ _ => ["─", "│", "┌", "┐", "└", "┘", "├", "┤", "┬", "┴", "┼"],+ };+ match (up, down, left, right) {+ (true, true, true, true) => set[10],+ (true, true, false, true) => set[6],+ (true, true, true, false) => set[7],+ (false, true, true, true) => set[8],+ (true, false, true, true) => set[9],+ (false, true, false, true) => set[2],+ (false, true, true, false) => set[3],+ (true, false, false, true) => set[4],+ (true, false, true, false) => set[5],+ (true, _, false, false) | (_, true, false, false) => set[1],+ _ => set[0],+ }+}++/// The preview: a label, then a small hn — its panes in the layout, their borders, title rows and+/// focus, drawn in the theme's colours, with the status line under them.+pub fn preview(buf: &mut Buffer, r: Rect, look: &Look, c: &Chrome) {+ if r.width < 16 || r.height < 6 { return }+ // Everything in it — the status bar and borders too — from the theme it shows.+ let (pal, accent) = match look.theme {+ Some(t) => (theme::pane_palette_of(t.background, t.foreground), rgb(theme::theme_accent_rgb(t))),+ None => (theme::native_pane_palette(), native_accent()),+ };+ let (bg, fg) = (pal.surface, pal.foreground);+ let name = look.theme.map(|t| t.name).unwrap_or("your terminal's colours");+ let at = r.x + put(buf, r.x, r.y, r.width, "Preview · ", c.muted);+ put(buf, at, r.y, r.right().saturating_sub(at), name, c.base);++ let screen = Rect::new(r.x, r.y + 2, r.width, r.height.saturating_sub(2).min(18));+ // ── status bar ──+ // The status line at the bottom or the top, or the bar down a side.+ let (body, status_row, side) = match look.bar.as_str() {+ "top" => (Rect::new(screen.x, screen.y + 1, screen.width, screen.height - 1), Some(screen.y), None),+ "left" | "right" => {+ let w = (screen.width / 4).clamp(10, 16);+ let bar = Rect::new(if look.bar == "left" { screen.x } else { screen.right() - w }, screen.y, w, screen.height);+ (Rect::new(if look.bar == "left" { screen.x + w } else { screen.x }, screen.y, screen.width - w, screen.height), None, Some(bar))+ }+ _ => (Rect::new(screen.x, screen.y, screen.width, screen.height - 1), Some(screen.bottom() - 1), None),+ };+ let boxed = look.boxes && !look.surface;+ let canvas = if look.surface { pal.canvas } else { bg };+ for y in body.y..body.bottom() { for x in body.x..body.right() { if let Some(cell) = buf.cell_mut((x, y)) { cell.reset(); cell.set_style(Style::default().bg(canvas)); } } }++ let panes = tiles(body, &look.layout, &look.split);+ let names = ["claude", "codex", "shell"];+ let inside = |x: u16, y: u16| panes.iter().any(|p| x >= p.x && x < p.right() && y >= p.y && y < p.bottom());+ let border = |x: u16, y: u16| x >= body.x && x < body.right() && y >= body.y && y < body.bottom() && !inside(x, y);+ let active = panes[0];+ // Next to the active pane: its borders take the indicator (a colour, arrows, or both).+ let touches = |x: u16, y: u16| x + 1 >= active.x && x <= active.right() && y + 1 >= active.y && y <= active.bottom();+ let colour = matches!(look.indicators.as_str(), "colour" | "both");+ let arrows = matches!(look.indicators.as_str(), "arrows" | "both");+ if !look.surface && !boxed {+ for y in body.y..body.bottom() {+ for x in body.x..body.right() {+ if !border(x, y) { continue }+ let g = joint(&look.lines, y > body.y && border(x, y - 1), border(x, y + 1), x > body.x && border(x - 1, y), border(x + 1, y));+ let style = if colour && touches(x, y) { Style::default().fg(accent).bg(bg) } else { Style::default().fg(pal.border).bg(bg) };+ buf.set_string(x, y, g, style);+ }+ }+ if arrows {+ // One arrow on each border beside the active pane, pointing into it.+ let style = Style::default().fg(accent).bg(bg).add_modifier(Modifier::BOLD);+ let mid_y = active.y + active.height / 2;+ let mid_x = active.x + active.width / 2;+ if border(active.right(), mid_y) { buf.set_string(active.right(), mid_y, "◀", style) }+ if active.x > body.x && border(active.x - 1, mid_y) { buf.set_string(active.x - 1, mid_y, "▶", style) }+ if border(mid_x, active.bottom()) { buf.set_string(mid_x, active.bottom(), "▲", style) }+ }+ }++ let lines: [&[(&str, bool)]; 3] = [+ &[("❯ ", true), ("fix the login bug", false)],+ &[("⠹ ", true), ("Reading src/auth.rs", false)],+ &[("$ ", true), ("cargo test", false)],+ ];+ for (i, p) in panes.iter().enumerate() {+ let here = i == 0;+ let (pbg, pfg) = if look.surface && !here { (pal.inactive_surface, pal.inactive_foreground) } else { (bg, fg) };+ for y in p.y..p.bottom() { for x in p.x..p.right() { if let Some(cell) = buf.cell_mut((x, y)) { cell.reset(); cell.set_style(Style::default().bg(pbg)); } } }+ let mut content = *p;+ // ── status bar ──+ // A box: the focused pane's frame in the accent, the next one's as a harness waiting on+ // you draws it, the rest quiet; the title in the frame's top or bottom line.+ if boxed && p.width >= 3 && p.height >= 3 {+ let frame = Style::default().fg(if here { accent } else if i == 1 { theme::paint(theme::ATTENTION) } else { pal.border }).bg(pbg);+ let (x1, y1) = (p.right() - 1, p.bottom() - 1);+ for x in p.x + 1..x1 { buf.set_string(x, p.y, joint(&look.lines, false, false, true, true), frame); buf.set_string(x, y1, joint(&look.lines, false, false, true, true), frame) }+ for y in p.y + 1..y1 { buf.set_string(p.x, y, joint(&look.lines, true, true, false, false), frame); buf.set_string(x1, y, joint(&look.lines, true, true, false, false), frame) }+ for (x, y, g) in [(p.x, p.y, joint(&look.lines, false, true, false, true)), (x1, p.y, joint(&look.lines, false, true, true, false)), (p.x, y1, joint(&look.lines, true, false, false, true)), (x1, y1, joint(&look.lines, true, false, true, false))] { buf.set_string(x, y, g, frame) }+ if look.status != "off" {+ let ty = if look.status == "bottom" { y1 } else { p.y };+ let ls = if here { frame.add_modifier(Modifier::BOLD) } else if i == 1 { frame } else { Style::default().fg(pfg).bg(pbg) };+ put(buf, p.x + 1, ty, p.width.saturating_sub(2), &format!(" {} {} ", i + 1, names[i]), ls);+ }+ content = Rect::new(p.x, p.y + 1, p.width, p.height - 2);+ } else if look.status != "off" && p.height >= 3 {+ // The title row, above or below the pane, as pane-border-status puts it.+ let ty = if look.status == "bottom" { p.bottom() - 1 } else { p.y };+ let rule = if look.surface { " " } else { joint(&look.lines, false, false, true, true) };+ let tstyle = if colour && here { Style::default().fg(accent).bg(pbg) } else { Style::default().fg(pal.border).bg(pbg) };+ for x in p.x..p.right() { buf.set_string(x, ty, rule, tstyle) }+ let label = format!(" {} {} ", i + 1, names[i]);+ let ls = if here { Style::default().fg(accent).bg(pbg).add_modifier(Modifier::BOLD) } else { Style::default().fg(pfg).bg(pbg) };+ put(buf, p.x + 1, ty, p.width.saturating_sub(2), &label, ls);+ content = if look.status == "bottom" { Rect::new(p.x, p.y, p.width, p.height - 1) } else { Rect::new(p.x, p.y + 1, p.width, p.height - 1) };+ }+ let inner = Rect::new(content.x + 1, content.y, content.width.saturating_sub(2), content.height);+ for (row, segs) in lines.iter().enumerate() {+ let y = inner.y + row as u16;+ if y >= inner.bottom() { break }+ let mut x = inner.x;+ for (text, lead) in segs.iter() {+ let s = Style::default().fg(if *lead { accent } else { pfg }).bg(pbg);+ x += put(buf, x, y, inner.right().saturating_sub(x), text, s);+ }+ }+ // The theme's sixteen colours, in the first pane where it has room.+ if let (Some(t), true) = (look.theme, here) {+ let y = inner.y + lines.len() as u16 + 1;+ if y < inner.bottom() && inner.width >= 8 {+ for (k, col) in t.palette.iter().take((inner.width as usize / 2).min(16)).enumerate() {+ buf.set_string(inner.x + k as u16 * 2, y, "██", Style::default().fg(rgb(*col)).bg(pbg));+ }+ }+ }+ }++ // The status line, as hn's own sits under the panes (or over them).+ if let Some(status_row) = status_row {+ let sstyle = Style::default().fg(pal.status_foreground).bg(pal.status);+ for x in screen.x..screen.right() { buf.set_string(x, status_row, " ", sstyle) }+ let mut x = screen.x + 1;+ for (i, n) in names.iter().take(panes.len()).enumerate() {+ let s = if i == 0 { sstyle.fg(accent).add_modifier(Modifier::BOLD) } else { sstyle };+ x += put(buf, x, status_row, screen.right().saturating_sub(x), &format!("{}:{}{} ", i, n, if i == 0 { "*" } else { "" }), s);+ }+ put(buf, screen.right().saturating_sub(7), status_row, 6, "studio", sstyle);+ }+ // ── status bar ──+ if let Some(bar) = side { preview_bar(buf, bar, look.bar == "left", &pal, accent, &names[..panes.len().min(2)]) }+}++/// The status bar down a side, small: the windows, the current one with its panes under it (the+/// first focused, each with its repo), a rule, the machine with its window, and the separator+/// facing the panes.+fn preview_bar(buf: &mut Buffer, bar: Rect, left: bool, pal: &theme::PanePalette, accent: Color, names: &[&str]) {+ let (bg, fg) = (pal.surface, pal.foreground);+ for y in bar.y..bar.bottom() { for x in bar.x..bar.right() { if let Some(cell) = buf.cell_mut((x, y)) { cell.reset(); cell.set_style(Style::default().bg(bg)); } } }+ let sx = if left { bar.right() - 1 } else { bar.x };+ for y in bar.y..bar.bottom() { buf.set_string(sx, y, "│", Style::default().fg(pal.border).bg(bg)) }+ let x = if left { bar.x } else { bar.x + 1 };+ let w = bar.width - 1;+ let row = theme::depth_fit(mix(bg, fg, 12));+ let header = Style::default().fg(pal.muted).bg(bg).add_modifier(Modifier::BOLD);+ let mut y = bar.y;+ let line = |buf: &mut Buffer, y: &mut u16, spans: &[(&str, Style)], fill: Option<Color>| {+ if *y >= bar.bottom() { return }+ if let Some(f) = fill { for cx in x..x + w { buf.set_string(cx, *y, " ", Style::default().bg(f)) } }+ let mut at = x;+ for (t, s) in spans { let s = match fill { Some(f) => s.bg(f), None => *s }; at += put(buf, at, *y, (x + w).saturating_sub(at), t, s) }+ *y += 1;+ };+ let dim = Style::default().fg(pal.muted);+ // (The marks the bar gives: the harnesses' own — a spinner working, `?` waiting, `·` idle — and+ // `✓` for a connected machine; no round ones.)+ line(buf, &mut y, &[(" ", header), ("✓", Style::default().fg(theme::paint(theme::ONLINE))), (" studio", header)], None);+ y += 1;+ let count = format!(" {}", names.len());+ line(buf, &mut y, &[(" ", header), ("?", Style::default().fg(theme::paint(theme::ATTENTION))), (" 0:claude", Style::default().fg(fg).add_modifier(Modifier::BOLD)), (&count, dim)], Some(row));+ for (i, n) in names.iter().enumerate() {+ let (here, last) = (i == 0, i + 1 == names.len());+ let fill = here.then_some(row);+ let (glyph, gc) = if here { (theme::spinner(0), theme::paint(theme::ACCENT_SOFT)) } else { ("?", theme::paint(theme::ATTENTION)) };+ let name = if here { Style::default().fg(fg).add_modifier(Modifier::BOLD) } else { Style::default().fg(pal.inactive_foreground) };+ line(buf, &mut y, &[(if last { " └─ " } else { " ├─ " }, dim), (glyph, Style::default().fg(gc)), (" ", name), (n, name)], fill);+ line(buf, &mut y, &[(if last { " " } else { " │ " }, dim), ("autonomous-harness · main", Style::default().fg(if here { accent } else { pal.muted }))], fill);+ }+ line(buf, &mut y, &[(" ", header), ("·", Style::default().fg(pal.muted)), (" 1:ops", Style::default().fg(pal.inactive_foreground))], None);+ let rule = "─".repeat(w as usize);+ line(buf, &mut y, &[(&rule, Style::default().fg(pal.border))], None);+ line(buf, &mut y, &[(" machines", header)], None);+ y += 1;+ line(buf, &mut y, &[(" ", header), ("✓", Style::default().fg(theme::paint(theme::ONLINE))), (" studio", Style::default().fg(fg).add_modifier(Modifier::BOLD))], None);+ line(buf, &mut y, &[(" └─ ", Style::default().fg(pal.muted)), ("?", Style::default().fg(theme::paint(theme::ATTENTION))), (" 0:claude", Style::default().fg(fg).add_modifier(Modifier::BOLD))], Some(row));+}++#[cfg(test)]+mod tests {+ use super::*;+ use crate::modal;++ fn app(size: (u16, u16)) -> App {+ let (sink, _) = tokio::sync::mpsc::unbounded_channel();+ let mut app = App::new(19789, sink, size);+ app.fleet.local_id = "local".into();+ app.fleet.machines.push(crate::fleet::Machine { id: "local".into(), name: "studio".into(), local: true, status: "online".into(), reach: crate::fleet::Reach::Ready });+ app+ }++ fn text(buf: &Buffer) -> String {+ let a = buf.area;+ (a.y..a.bottom()).map(|y| (a.x..a.right()).map(|x| buf[(x, y)].symbol().to_string()).collect::<String>()).collect::<Vec<_>>().join("\n")+ }++ fn open(app: &App, section: Option<&str>) -> Picker {+ let mut p = Picker::new("t", "Search settings");+ p.keep_order = true;+ match section {+ Some(s) => { p.theme_in = Some(s.into()); p.set_rows(modal::theme_options(app, s)) }+ None => p.set_rows(modal::theme_sections(app)),+ }+ p+ }++ /// The panel stays where it is, the same size, whether it shows the sections or one section's+ /// options — and draws at every size without a panic.+ #[test]+ fn the_panel_does_not_move_when_a_section_opens() {+ let app = app((150, 42));+ let body = Rect::new(0, 0, 150, 41);+ let mut a = open(&app, None);+ let mut b = open(&app, Some("status"));+ let mut buf = Buffer::empty(body);+ draw(&mut buf, &app, body, &PickerKind::Theme, &mut a);+ let mut buf2 = Buffer::empty(body);+ draw(&mut buf2, &app, body, &PickerKind::Theme, &mut b);+ assert_eq!(a.screen_area.get(), b.screen_area.get());+ assert_eq!(a.list_area.get(), b.list_area.get());+ for w in [10, 24, 40, 80, 150] { for h in [3, 8, 12, 24, 42] {+ let r = Rect::new(0, 0, w, h);+ for section in [None, Some("theme"), Some("layout")] {+ let mut p = open(&app, section);+ draw(&mut Buffer::empty(r), &app, r, &PickerKind::Theme, &mut p);+ }+ }}+ }++ /// Inside a section its options are listed, and the panel has no border line around it.+ #[test]+ fn a_section_lists_its_options_without_a_border() {+ let app = app((150, 42));+ let body = Rect::new(0, 0, 150, 41);+ let mut p = open(&app, Some("status"));+ let mut buf = Buffer::empty(body);+ draw(&mut buf, &app, body, &PickerKind::Theme, &mut p);+ let s = text(&buf);+ for v in ["off", "top", "bottom"] { assert!(s.contains(v), "{v} missing:\n{s}") }+ assert!(s.contains("Appearance") && s.contains("Pane titles"));+ let r = p.screen_area.get();+ for x in r.x..r.right() { assert!(!["─", "╭", "╮", "┌"].contains(&buf[(x, r.y)].symbol()), "a border on the panel's top row") }+ }++ /// The preview shows every section at once, and a hovered option changes only its own part.+ #[test]+ fn the_preview_is_the_whole_look_and_follows_the_cursor() {+ let app = app((150, 42));+ let look = Look::of(&app);+ assert_eq!(look.clone().with(Some("border_lines:double")).lines, "double");+ assert_eq!(look.clone().with(Some("border_lines:double")).status, look.status);+ assert_eq!(look.clone().with(Some("layout_preset:tiled")).layout, "tiled");+ assert!(look.clone().with(Some("theme:Adwaita")).theme.is_some());+ let r = Rect::new(0, 0, 60, 24);+ let mut buf = Buffer::empty(r);+ preview(&mut buf, r, &look.clone().with(Some("border_lines:double")), &chrome());+ let s = text(&buf);+ assert!(s.contains('║') || s.contains('═'), "double lines drawn:\n{s}");+ assert!(s.contains("claude") && s.contains("codex"), "the status line names the windows:\n{s}");+ let mut buf = Buffer::empty(r);+ preview(&mut buf, r, &look.clone().with(Some("border_status:top")), &chrome());+ assert!(text(&buf).contains("1 claude"), "title rows drawn");+ }++ /// The panel takes the theme's colours: two themes, two panels; a light theme a light panel.+ #[test]+ fn the_panel_follows_the_theme() {+ let theme = |n: &str| TERMINAL_THEMES.iter().find(|t| t.name == n).unwrap();+ let (dark, light) = (theme("Atom One Dark"), theme("Adwaita"));+ let a = chrome_for(theme::pane_palette_of(dark.background, dark.foreground));+ let b = chrome_for(theme::pane_palette_of(light.background, light.foreground));+ assert_ne!(a.base.bg, b.base.bg);+ let lum = |s: Style| match s.bg { Some(Color::Rgb(r, g, b)) => 299 * r as u32 + 587 * g as u32 + 114 * b as u32, _ => 0 };+ assert!(lum(b.base) > lum(a.base), "a light theme gives a light panel");+ assert_ne!(a.base.bg, a.backdrop.bg, "the panel stands out from its backdrop");+ assert_ne!(a.base.bg, a.selected.bg, "the cursor's row stands out");+ }++ #[test]+ fn every_layout_tiles_the_screen_without_overlap() {+ let r = Rect::new(0, 0, 50, 16);+ for layout in ["auto", "even-horizontal", "even-vertical", "main-horizontal", "main-vertical", "tiled"] {+ let t = tiles(r, layout, "auto");+ assert!(t.len() >= 2, "{layout}");+ for (i, a) in t.iter().enumerate() { for b in &t[i + 1..] { assert!(a.intersection(*b).area() == 0, "{layout} overlaps") } }+ }+ assert!(tiles(r, "auto", "vertical")[1].y > 0, "vertical stacks");+ assert!(tiles(r, "auto", "horizontal")[1].x > 0, "horizontal is left|right");+ }++ // ── status bar ──++ /// The preview draws where the status bar goes — the line at the bottom or top, or the bar+ /// down a side: the windows with the current one's panes and their repos, then the machines —+ /// and the panes as boxes: the focused one's frame in the accent, one waiting on you in the+ /// attention colour.+ #[test]+ fn the_preview_draws_the_status_bar_where_it_goes_and_the_boxes_in_their_colours() {+ let app = app((150, 42));+ let look = Look::of(&app);+ assert_eq!((look.bar.as_str(), look.boxes), ("bottom", true));+ let r = Rect::new(0, 0, 64, 20);+ let draw = |look: &Look| { let mut buf = Buffer::empty(r); preview(&mut buf, r, look, &chrome()); buf };+ let row = |buf: &Buffer, y: u16| (0..r.width).map(|x| buf[(x, y)].symbol().to_string()).collect::<String>();+ // (The preview's screen: rows 2 to 19.)+ let bottom = draw(&look);+ assert!(row(&bottom, 19).contains("0:claude*"), "{}", text(&bottom));+ let top = draw(&look.clone().with(Some("status_bar:top")));+ assert!(row(&top, 2).contains("0:claude*") && !row(&top, 19).contains("0:claude*"), "{}", text(&top));+ let left = draw(&look.clone().with(Some("status_bar:left")));+ let s = text(&left);+ assert!(row(&left, 2).starts_with(" ✓ studio") && row(&left, 4).starts_with(" ? 0:claude 2"), "{s}");+ assert!(row(&left, 5).starts_with(" ├─ ") && row(&left, 5).contains(" claude") && row(&left, 6).starts_with(" │ autonom") && row(&left, 7).starts_with(" └─ ? codex"), "{s}");+ assert!(row(&left, 9).starts_with(" · 1:ops") && s.contains(" machines") && s.contains("└─ ? 0:claude"), "{s}");+ assert!(!s.contains('●') && !s.contains('○'), "no round marks:\n{s}");+ assert_eq!(left[(15, 2)].symbol(), "│", "the separator faces the panes:\n{s}");+ // No tabs over the panes: the window starts at the screen's first row, beside the bar.+ assert_eq!(left[(16, 2)].symbol(), "┌", "{s}");+ let right = draw(&look.clone().with(Some("status_bar:right")));+ assert_eq!(right[(64 - 16, 5)].symbol(), "│");+ // Boxes: each pane its own frame; the focused one's in the accent, the next the attention colour.+ // (The accent as this draw had it: the current window's name on the status line.)+ let accent = bottom[(1, 19)].fg;+ let panes = tiles(Rect::new(0, 2, 64, 17), &look.layout, &look.split);+ assert_eq!(bottom[(panes[0].x, panes[0].y)].symbol(), "┌");+ assert_eq!(bottom[(panes[1].x, panes[1].y)].symbol(), "┌");+ assert_eq!(bottom[(panes[0].x, panes[0].y)].fg, accent);+ assert_ne!(accent, bottom[(panes[1].x, panes[1].y)].fg);+ assert_eq!(bottom[(panes[1].x, panes[1].y)].fg, theme::paint(theme::ATTENTION));+ let line = draw(&look.clone().with(Some("border_style:line")));+ assert_ne!(line[(panes[1].x, panes[1].y)].symbol(), "┌", "tmux's shared lines");+ }+}diff --git a/tui/src/term_input.rs b/tui/src/term_input.rsindex 63157d9ad..28b417194 100644--- a/tui/src/term_input.rs+++ b/tui/src/term_input.rs@@ -11,7 +11,7 @@ mod parse;enum InternalEvent { Event(Event), CursorPosition(u16, u16), KeyboardEnhancementFlags(KeyboardEnhancementFlags), PrimaryDeviceAttributes }#[derive(Debug, PartialEq)]-enum Item { Input(Event), Terminal(Option<String>), Foreground(Option<String>), Background(Option<String>) }+enum Item { Input(Event), Terminal(Option<String>), Foreground(Option<String>), Background(Option<String>), Palette(u8, Option<String>) }#[derive(Default)]struct Decoder { pending: Vec<u8> }@@ -46,6 +46,19 @@ impl Decoder {if let Some(end) = end { out.push(Item::Background(parse_osc11(&String::from_utf8_lossy(&p[5..end])))); self.pending.clear(); }continue;}+ // OSC 4 palette answer from `ask_terminal`, `\x1b]4;N;rgb:…\x07`: one of the terminal's+ // own sixteen colours, from which hn's accent is picked when no theme is chosen. The+ // same hold-till-terminator rule as OSC 10/11.+ if b"\x1b]4;".starts_with(p) { continue }+ if p.starts_with(b"\x1b]4;") && p.len() < 4096 {+ let end = if p.ends_with(b"\x1b\\") { Some(p.len() - 2) } else if p.ends_with(b"\x07") { Some(p.len() - 1) } else { None };+ if let Some(end) = end {+ let body = String::from_utf8_lossy(&p[4..end]).into_owned();+ if let Some((n, colour)) = body.split_once(';').and_then(|(n, c)| Some((n.parse::<u8>().ok()?, c))) { out.push(Item::Palette(n, parse_osc11(colour))) }+ self.pending.clear();+ }+ continue;+ }// If the apparent XDA prefix turned out to be Alt-P, replay through the exact// byte decoder rather than letting its first event discard the following bytes.if p.starts_with(b"\x1bP") {@@ -148,6 +161,10 @@ pub fn read(keys: tokio::sync::mpsc::UnboundedSender<crate::event::Event>) {crate::term_out::set_terminal_colours(bg, None);crate::event::Event::Apply(Box::new(|app| { app.push_theme(); app.redraw_all = true; }))}+ Item::Palette(n, colour) => {+ crate::term_out::set_palette_colour(n, colour);+ crate::event::Event::Apply(Box::new(|app| app.redraw_all = true))+ }};if keys.send(event).is_err() { return }}diff --git a/tui/src/term_out.rs b/tui/src/term_out.rsindex 78a47cf01..c4586140f 100644--- a/tui/src/term_out.rs+++ b/tui/src/term_out.rs@@ -198,13 +198,36 @@ static TERMINAL_ANSWERED: std::sync::atomic::AtomicBool = std::sync::atomic::Ato/// OSC 11 (default background) is asked, and now OSC 10 (default foreground) too: hn reports/// them to each machine's daemon (`theme_set`) so agent panes are painted to match, exactly as/// the desktop app does. Asking OSC 10 is what keeps hn's chrome on the terminal's own-/// foreground (an ivory/cream), not a white computed from the background.+/// foreground (an ivory/cream), not a white computed from the background. OSC 4 asks the terminal's+/// own colours 1-7 too: with no theme chosen, hn's accent is one of them (`native_accent`), so the+/// focused pane, the current tab and the panels' marks are in the terminal's theme, not a fixed teal.pub fn ask_terminal() {let mut out = io::stdout();- let _ = out.write_all(b"\x1b[>q\x1b[c\x1b]11;?\x07\x1b]10;?\x07");+ let _ = out.write_all(b"\x1b[>q\x1b[c\x1b]11;?\x07\x1b]10;?\x07\x1b]4;1;?\x07\x1b]4;2;?\x07\x1b]4;3;?\x07\x1b]4;4;?\x07\x1b]4;5;?\x07\x1b]4;6;?\x07\x1b]4;7;?\x07");let _ = out.flush();}+/// The terminal's colours 1-7 as it answered OSC 4 (`#rrggbb`), where it did.+static PALETTE: std::sync::RwLock<[Option<[u8; 3]>; 8]> = std::sync::RwLock::new([None; 8]);++/// Record an OSC 4 answer for colour [n] (1-7 are kept; the rest are not asked).+pub fn set_palette_colour(n: u8, colour: Option<String>) {+ let Some((r, g, b)) = colour.as_deref().and_then(hex_rgb) else { return };+ if (1..8).contains(&n) { if let Ok(mut p) = PALETTE.write() { p[n as usize] = Some([r, g, b]) } }+}++/// The accent the terminal's own theme gives, when it answered its colours and its background:+/// picked from colours 1-7 as a bundled theme's is (`theme::accent_of`).+pub fn native_accent() -> Option<[u8; 3]> {+ let (bg, _) = native_terminal_colours()?;+ let (r, g, b) = hex_rgb(&bg)?;+ let p = PALETTE.read().ok()?;+ let colours: Vec<(usize, [u8; 3])> = (1..8).filter_map(|i| p[i].map(|c| (i, c))).collect();+ // (Most of them, or it is not the terminal's palette speaking.)+ if colours.len() < 5 { return None }+ Some(crate::theme::accent_of([r, g, b], &colours))+}+pub fn terminal_answer(answer: Option<String>) -> bool {let first = !TERMINAL_ANSWERED.swap(true, std::sync::atomic::Ordering::Relaxed);answer.map(|name| TERMINAL.set(name).is_ok()).unwrap_or(false) || first@@ -249,10 +272,71 @@ fn companion_fg(bg: &str) -> String {}/// What the terminal answered for its default colours, (bg, fg) hex, when it answered.+/// A theme chosen in the settings (`@hn-theme`) stands in for them: hn's chrome, and the panes the+/// daemon paints, take the theme's background and foreground.pub fn terminal_colours() -> Option<(String, String)> {+ if let Some(theme) = THEME_COLOURS.read().ok().and_then(|g| g.clone()) { return Some(theme) }TERMINAL_FG_BG.read().ok()?.as_ref().map(|c| (c.bg.clone(), c.fg.clone()))}+/// The terminal's own answer, whatever theme is chosen (the settings' "Terminal default").+pub fn native_terminal_colours() -> Option<(String, String)> {+ TERMINAL_FG_BG.read().ok()?.as_ref().map(|c| (c.bg.clone(), c.fg.clone()))+}++/// The chosen theme's (background, foreground) as `#rrggbb`; None: the terminal's own.+static THEME_COLOURS: std::sync::RwLock<Option<(String, String)>> = std::sync::RwLock::new(None);++/// Tests that set hn's colours (a theme, an accent) or read them back hold this, one at a time:+/// the colours are one for the whole process, and tests run side by side.+#[cfg(test)]+pub fn colours_lock() -> std::sync::MutexGuard<'static, ()> {+ static LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());+ LOCK.lock().unwrap_or_else(|e| e.into_inner())+}++/// Whether a theme's colours stand in for the terminal's now.+pub fn theme_chosen() -> bool { THEME_COLOURS.read().ok().is_some_and(|g| g.is_some()) }++/// Draw with a theme's colours (or, None, the terminal's again). True when that changed them.+pub fn set_theme_colours(colours: Option<(String, String)>) -> bool {+ let Ok(mut g) = THEME_COLOURS.write() else { return false };+ let changed = *g != colours;+ *g = colours;+ changed+}++/// The `[look]` accent (`@hn-accent`, a `#rrggbb`) to draw hn's chrome with, when the look names+/// one. Kept separate from the terminal palette because an accent is a choice, not a terminal+/// answer; `theme::accent()` consults it first and falls back to the derived teal.+static ACCENT_OVERRIDE: std::sync::RwLock<Option<String>> = std::sync::RwLock::new(None);++pub fn set_accent_override(hex: Option<String>) {+ if let Ok(mut g) = ACCENT_OVERRIDE.write() { *g = hex.map(normalise_hex_short) }+}++pub fn accent_override() -> Option<String> { ACCENT_OVERRIDE.read().ok()?.clone() }++/// Accept `#rgb` too (shorthand) by expanding it to `#rrggbb`, the form hn parses.+fn normalise_hex_short(hex: String) -> String {+ let h = hex.trim_start_matches('#');+ if h.len() == 3 { format!("#{}{}{}{}{}{}", &h[0..1], &h[0..1], &h[1..2], &h[1..2], &h[2..3], &h[2..3]) } else { hex }+}++#[cfg(test)]+mod accent_override_tests {+ use super::*;+ #[test]+ fn shorthand_accent_is_expanded_and_roundtrips() {+ let _colours = colours_lock();+ set_accent_override(Some("#7aa".into()));+ assert_eq!(normalise_hex_short("#7aa".into()), "#77aaaa");+ assert_eq!(accent_override().as_deref(), Some("#77aaaa"));+ set_accent_override(None);+ assert_eq!(accent_override(), None);+ }+}+/// Record an OSC 10/11 answer. A half left blank keeps the other (a terminal may answer bg only);/// a missing foreground is chosen for contrast on the background.pub fn set_terminal_colours(bg: Option<String>, fg: Option<String>) {diff --git a/tui/src/terminal_themes.rs b/tui/src/terminal_themes.rsnew file mode 100644index 000000000..97f5ee101--- /dev/null+++ b/tui/src/terminal_themes.rs@@ -0,0 +1,10685 @@+//! hn's bundled terminal colour themes. Each theme is a terminal's 16-colour+//! palette plus its background and foreground, used by the `hn theme` picker.+//!+//! Generated by scripts/gen_terminal_themes.py — do not hand-edit.++/// One bundled terminal theme.+#[derive(Clone, Copy, Debug)]+pub struct TerminalTheme {+ pub name: &'static str,+ pub background: [u8; 3],+ pub foreground: [u8; 3],+ /// ANSI 0-15, in palette order.+ pub palette: [[u8; 3]; 16],+}++/// Every bundled theme, sorted by name.+pub static TERMINAL_THEMES: &[TerminalTheme] = &[+ TerminalTheme {+ name: "0x96f",+ background: [38, 36, 39],+ foreground: [252, 252, 250],+ palette: [+ [38, 36, 39],+ [255, 102, 109],+ [179, 224, 58],+ [255, 199, 57],+ [0, 205, 232],+ [163, 146, 232],+ [157, 234, 246],+ [252, 252, 250],+ [84, 84, 82],+ [255, 126, 131],+ [190, 229, 94],+ [255, 208, 94],+ [27, 213, 235],+ [176, 163, 235],+ [172, 237, 248],+ [252, 252, 250],+ ],+ },+ TerminalTheme {+ name: "12-bit Rainbow",+ background: [4, 4, 4],+ foreground: [254, 255, 255],+ palette: [+ [0, 0, 0],+ [160, 48, 80],+ [64, 208, 128],+ [224, 144, 64],+ [48, 96, 176],+ [96, 48, 144],+ [0, 144, 192],+ [219, 222, 216],+ [104, 86, 86],+ [192, 96, 96],+ [144, 208, 80],+ [224, 208, 0],+ [0, 176, 192],+ [128, 16, 112],+ [32, 176, 192],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "3024 Day",+ background: [247, 247, 247],+ foreground: [74, 69, 67],+ palette: [+ [9, 3, 0],+ [219, 45, 32],+ [1, 162, 82],+ [202, 186, 0],+ [1, 160, 228],+ [161, 106, 148],+ [143, 190, 206],+ [165, 162, 162],+ [92, 88, 85],+ [219, 174, 195],+ [58, 52, 50],+ [74, 69, 67],+ [128, 125, 124],+ [188, 187, 186],+ [205, 171, 83],+ [247, 247, 247],+ ],+ },+ TerminalTheme {+ name: "3024 Night",+ background: [9, 3, 0],+ foreground: [165, 162, 162],+ palette: [+ [9, 3, 0],+ [219, 45, 32],+ [1, 162, 82],+ [253, 237, 2],+ [1, 160, 228],+ [161, 106, 148],+ [181, 228, 244],+ [165, 162, 162],+ [92, 88, 85],+ [232, 187, 208],+ [71, 65, 63],+ [74, 69, 67],+ [128, 125, 124],+ [214, 213, 212],+ [205, 171, 83],+ [247, 247, 247],+ ],+ },+ TerminalTheme {+ name: "Aardvark Blue",+ background: [16, 32, 64],+ foreground: [221, 221, 221],+ palette: [+ [25, 25, 25],+ [170, 52, 46],+ [75, 140, 15],+ [219, 186, 0],+ [19, 112, 211],+ [196, 58, 195],+ [0, 142, 176],+ [190, 190, 190],+ [82, 82, 82],+ [240, 91, 80],+ [149, 220, 85],+ [255, 231, 99],+ [96, 164, 236],+ [226, 107, 226],+ [96, 182, 203],+ [247, 247, 247],+ ],+ },+ TerminalTheme {+ name: "Abernathy",+ background: [17, 20, 22],+ foreground: [238, 238, 236],+ palette: [+ [0, 0, 0],+ [205, 0, 0],+ [0, 205, 0],+ [205, 205, 0],+ [16, 147, 245],+ [205, 0, 205],+ [0, 205, 205],+ [250, 235, 215],+ [64, 64, 64],+ [255, 0, 0],+ [0, 255, 0],+ [255, 255, 0],+ [17, 181, 246],+ [255, 0, 255],+ [0, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Adventure",+ background: [4, 4, 4],+ foreground: [254, 255, 255],+ palette: [+ [4, 4, 4],+ [216, 74, 51],+ [93, 166, 2],+ [238, 187, 110],+ [65, 122, 179],+ [229, 196, 153],+ [189, 207, 229],+ [219, 222, 216],+ [104, 86, 86],+ [215, 107, 66],+ [153, 181, 44],+ [255, 182, 112],+ [151, 215, 239],+ [170, 121, 0],+ [189, 207, 229],+ [228, 213, 199],+ ],+ },+ TerminalTheme {+ name: "Adventure Time",+ background: [31, 29, 69],+ foreground: [248, 220, 192],+ palette: [+ [5, 4, 4],+ [189, 0, 19],+ [74, 177, 24],+ [231, 116, 30],+ [15, 74, 198],+ [102, 89, 147],+ [112, 165, 152],+ [248, 220, 192],+ [78, 124, 191],+ [252, 95, 90],+ [158, 255, 110],+ [239, 193, 26],+ [25, 151, 198],+ [155, 89, 83],+ [200, 250, 244],+ [246, 245, 251],+ ],+ },+ TerminalTheme {+ name: "Adwaita",+ background: [255, 255, 255],+ foreground: [0, 0, 0],+ palette: [+ [36, 31, 49],+ [192, 28, 40],+ [46, 194, 126],+ [232, 181, 4],+ [30, 120, 228],+ [152, 65, 187],+ [10, 185, 220],+ [192, 191, 188],+ [94, 92, 100],+ [237, 51, 59],+ [74, 214, 124],+ [210, 190, 54],+ [81, 161, 255],+ [192, 97, 203],+ [79, 210, 253],+ [246, 245, 244],+ ],+ },+ TerminalTheme {+ name: "Adwaita Dark",+ background: [29, 29, 32],+ foreground: [255, 255, 255],+ palette: [+ [36, 31, 49],+ [192, 28, 40],+ [46, 194, 126],+ [245, 194, 17],+ [30, 120, 228],+ [152, 65, 187],+ [10, 185, 220],+ [192, 191, 188],+ [94, 92, 100],+ [237, 51, 59],+ [87, 227, 137],+ [248, 228, 92],+ [81, 161, 255],+ [192, 97, 203],+ [79, 210, 253],+ [246, 245, 244],+ ],+ },+ TerminalTheme {+ name: "Afterglow",+ background: [33, 33, 33],+ foreground: [208, 208, 208],+ palette: [+ [21, 21, 21],+ [172, 65, 66],+ [126, 142, 80],+ [229, 181, 103],+ [108, 153, 187],+ [159, 78, 133],+ [125, 214, 207],+ [208, 208, 208],+ [80, 80, 80],+ [172, 65, 66],+ [126, 142, 80],+ [229, 181, 103],+ [108, 153, 187],+ [159, 78, 133],+ [125, 214, 207],+ [245, 245, 245],+ ],+ },+ TerminalTheme {+ name: "Aizen Dark",+ background: [26, 26, 26],+ foreground: [208, 214, 240],+ palette: [+ [26, 26, 26],+ [240, 136, 152],+ [164, 224, 156],+ [245, 222, 164],+ [132, 180, 248],+ [200, 162, 244],+ [144, 220, 208],+ [208, 214, 240],+ [68, 68, 68],+ [240, 136, 152],+ [164, 224, 156],+ [245, 222, 164],+ [132, 180, 248],+ [200, 162, 244],+ [144, 220, 208],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Aizen Light",+ background: [240, 242, 246],+ foreground: [74, 77, 102],+ palette: [+ [240, 242, 246],+ [208, 12, 54],+ [62, 158, 40],+ [221, 140, 26],+ [28, 100, 242],+ [134, 54, 236],+ [21, 144, 150],+ [74, 77, 102],+ [173, 178, 188],+ [208, 12, 54],+ [62, 158, 40],+ [221, 140, 26],+ [28, 100, 242],+ [134, 54, 236],+ [21, 144, 150],+ [74, 77, 102],+ ],+ },+ TerminalTheme {+ name: "Alabaster",+ background: [247, 247, 247],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [170, 55, 49],+ [68, 140, 39],+ [203, 144, 0],+ [50, 92, 192],+ [122, 62, 157],+ [0, 131, 178],+ [183, 183, 183],+ [119, 119, 119],+ [240, 80, 80],+ [96, 203, 0],+ [242, 175, 80],+ [0, 122, 204],+ [230, 76, 230],+ [0, 170, 203],+ [247, 247, 247],+ ],+ },+ TerminalTheme {+ name: "Alien Blood",+ background: [15, 22, 16],+ foreground: [99, 125, 117],+ palette: [+ [17, 38, 22],+ [127, 43, 39],+ [47, 126, 37],+ [113, 127, 36],+ [47, 106, 127],+ [71, 88, 127],+ [50, 127, 119],+ [100, 125, 117],+ [60, 72, 18],+ [224, 128, 9],+ [24, 224, 0],+ [189, 224, 0],+ [0, 170, 224],+ [0, 88, 224],+ [0, 224, 196],+ [115, 250, 145],+ ],+ },+ TerminalTheme {+ name: "Andromeda",+ background: [38, 42, 51],+ foreground: [229, 229, 229],+ palette: [+ [0, 0, 0],+ [205, 49, 49],+ [5, 188, 121],+ [229, 229, 18],+ [36, 114, 200],+ [188, 63, 188],+ [15, 168, 205],+ [229, 229, 229],+ [102, 102, 102],+ [205, 49, 49],+ [5, 188, 121],+ [229, 229, 18],+ [36, 114, 200],+ [188, 63, 188],+ [15, 168, 205],+ [229, 229, 229],+ ],+ },+ TerminalTheme {+ name: "Apple Classic",+ background: [44, 43, 43],+ foreground: [213, 162, 0],+ palette: [+ [0, 0, 0],+ [201, 27, 0],+ [0, 194, 0],+ [199, 196, 0],+ [28, 63, 225],+ [202, 48, 199],+ [0, 197, 199],+ [199, 199, 199],+ [104, 104, 104],+ [255, 110, 103],+ [95, 250, 104],+ [255, 252, 103],+ [104, 113, 255],+ [255, 119, 255],+ [96, 253, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Apple System Colors",+ background: [30, 30, 30],+ foreground: [255, 255, 255],+ palette: [+ [26, 26, 26],+ [204, 55, 46],+ [38, 164, 57],+ [205, 172, 8],+ [8, 105, 203],+ [150, 71, 191],+ [71, 158, 194],+ [152, 152, 157],+ [70, 70, 70],+ [255, 69, 58],+ [50, 215, 75],+ [255, 214, 10],+ [10, 132, 255],+ [191, 90, 242],+ [118, 214, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Apple System Colors Light",+ background: [254, 255, 255],+ foreground: [0, 0, 0],+ palette: [+ [26, 26, 26],+ [204, 55, 46],+ [38, 164, 57],+ [205, 172, 8],+ [8, 105, 203],+ [150, 71, 191],+ [71, 158, 194],+ [152, 152, 157],+ [70, 70, 70],+ [255, 69, 58],+ [50, 215, 75],+ [229, 188, 0],+ [10, 132, 255],+ [191, 90, 242],+ [105, 201, 242],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Arcoiris",+ background: [32, 31, 30],+ foreground: [238, 228, 217],+ palette: [+ [51, 51, 51],+ [218, 39, 0],+ [18, 194, 88],+ [255, 198, 86],+ [81, 139, 252],+ [227, 123, 217],+ [99, 250, 213],+ [186, 178, 178],+ [119, 119, 119],+ [255, 185, 185],+ [227, 246, 170],+ [255, 221, 170],+ [179, 232, 243],+ [203, 186, 249],+ [188, 255, 199],+ [239, 239, 239],+ ],+ },+ TerminalTheme {+ name: "Ardoise",+ background: [30, 30, 30],+ foreground: [234, 234, 234],+ palette: [+ [44, 44, 44],+ [211, 50, 45],+ [88, 139, 53],+ [252, 169, 58],+ [36, 101, 194],+ [115, 50, 180],+ [100, 225, 184],+ [247, 247, 247],+ [83, 83, 83],+ [250, 88, 82],+ [141, 194, 82],+ [255, 234, 81],+ [106, 181, 248],+ [190, 104, 202],+ [137, 255, 219],+ [254, 254, 254],+ ],+ },+ TerminalTheme {+ name: "Argonaut",+ background: [14, 16, 25],+ foreground: [255, 250, 244],+ palette: [+ [35, 35, 35],+ [255, 0, 15],+ [140, 225, 11],+ [255, 185, 0],+ [0, 141, 248],+ [109, 67, 166],+ [0, 216, 235],+ [255, 255, 255],+ [68, 68, 68],+ [255, 39, 64],+ [171, 225, 91],+ [255, 210, 66],+ [0, 146, 255],+ [154, 95, 235],+ [103, 255, 240],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Arthur",+ background: [28, 28, 28],+ foreground: [221, 238, 221],+ palette: [+ [61, 53, 42],+ [205, 92, 92],+ [134, 175, 128],+ [232, 174, 91],+ [100, 149, 237],+ [222, 184, 135],+ [176, 196, 222],+ [187, 170, 153],+ [85, 68, 68],+ [204, 85, 51],+ [136, 170, 34],+ [255, 167, 93],+ [135, 206, 235],+ [153, 102, 0],+ [176, 196, 222],+ [221, 204, 187],+ ],+ },+ TerminalTheme {+ name: "Atelier Sulphurpool",+ background: [32, 39, 70],+ foreground: [151, 157, 180],+ palette: [+ [32, 39, 70],+ [201, 73, 34],+ [172, 151, 57],+ [192, 139, 48],+ [61, 143, 209],+ [102, 121, 204],+ [34, 162, 201],+ [151, 157, 180],+ [107, 115, 148],+ [199, 107, 41],+ [79, 88, 124],+ [94, 102, 135],+ [137, 142, 164],+ [223, 226, 241],+ [156, 99, 122],+ [245, 247, 255],+ ],+ },+ TerminalTheme {+ name: "Atom",+ background: [22, 23, 25],+ foreground: [197, 200, 198],+ palette: [+ [0, 0, 0],+ [253, 95, 241],+ [135, 195, 138],+ [255, 215, 177],+ [133, 190, 253],+ [185, 182, 252],+ [133, 190, 253],+ [224, 224, 224],+ [76, 76, 76],+ [253, 95, 241],+ [148, 250, 54],+ [245, 255, 168],+ [150, 203, 254],+ [185, 182, 252],+ [133, 190, 253],+ [224, 224, 224],+ ],+ },+ TerminalTheme {+ name: "Atom One Dark",+ background: [33, 37, 43],+ foreground: [171, 178, 191],+ palette: [+ [33, 37, 43],+ [224, 108, 117],+ [152, 195, 121],+ [229, 192, 123],+ [97, 175, 239],+ [198, 120, 221],+ [86, 182, 194],+ [171, 178, 191],+ [118, 118, 118],+ [224, 108, 117],+ [152, 195, 121],+ [229, 192, 123],+ [97, 175, 239],+ [198, 120, 221],+ [86, 182, 194],+ [171, 178, 191],+ ],+ },+ TerminalTheme {+ name: "Atom One Light",+ background: [249, 249, 249],+ foreground: [42, 44, 51],+ palette: [+ [0, 0, 0],+ [222, 62, 53],+ [63, 149, 58],+ [210, 182, 124],+ [47, 90, 243],+ [149, 0, 149],+ [63, 149, 58],+ [187, 187, 187],+ [0, 0, 0],+ [222, 62, 53],+ [63, 149, 58],+ [210, 182, 124],+ [47, 90, 243],+ [160, 0, 149],+ [63, 149, 58],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Aura",+ background: [21, 20, 27],+ foreground: [237, 236, 238],+ palette: [+ [17, 15, 24],+ [255, 103, 103],+ [97, 255, 202],+ [255, 202, 133],+ [162, 119, 255],+ [162, 119, 255],+ [97, 255, 202],+ [237, 236, 238],+ [77, 77, 77],+ [255, 202, 133],+ [162, 119, 255],+ [255, 202, 133],+ [162, 119, 255],+ [162, 119, 255],+ [97, 255, 202],+ [237, 236, 238],+ ],+ },+ TerminalTheme {+ name: "Aurora",+ background: [35, 38, 46],+ foreground: [255, 202, 40],+ palette: [+ [35, 38, 46],+ [240, 38, 111],+ [143, 212, 109],+ [255, 230, 109],+ [16, 46, 228],+ [238, 93, 67],+ [3, 214, 184],+ [199, 77, 237],+ [79, 84, 94],+ [249, 38, 114],+ [143, 212, 109],+ [255, 230, 109],+ [3, 214, 184],+ [238, 93, 67],+ [3, 214, 184],+ [199, 77, 237],+ ],+ },+ TerminalTheme {+ name: "Ayu",+ background: [11, 14, 20],+ foreground: [191, 189, 182],+ palette: [+ [17, 21, 28],+ [234, 108, 115],+ [127, 217, 98],+ [249, 175, 79],+ [83, 189, 250],+ [205, 161, 250],+ [144, 225, 198],+ [199, 199, 199],+ [104, 104, 104],+ [240, 113, 120],+ [170, 217, 76],+ [255, 180, 84],+ [89, 194, 255],+ [210, 166, 255],+ [149, 230, 203],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Ayu Light",+ background: [248, 249, 250],+ foreground: [92, 97, 102],+ palette: [+ [0, 0, 0],+ [234, 108, 109],+ [108, 191, 67],+ [236, 169, 68],+ [49, 153, 225],+ [158, 117, 199],+ [70, 186, 148],+ [186, 186, 186],+ [104, 104, 104],+ [240, 113, 113],+ [134, 179, 0],+ [242, 174, 73],+ [57, 158, 230],+ [163, 122, 204],+ [76, 191, 153],+ [209, 209, 209],+ ],+ },+ TerminalTheme {+ name: "Ayu Mirage",+ background: [31, 36, 48],+ foreground: [204, 202, 194],+ palette: [+ [23, 27, 36],+ [237, 130, 116],+ [135, 217, 108],+ [250, 204, 110],+ [109, 203, 250],+ [218, 186, 250],+ [144, 225, 198],+ [199, 199, 199],+ [104, 104, 104],+ [242, 135, 121],+ [213, 255, 128],+ [255, 209, 115],+ [115, 208, 255],+ [223, 191, 255],+ [149, 230, 203],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Banana Blueberry",+ background: [25, 19, 35],+ foreground: [204, 204, 204],+ palette: [+ [23, 20, 31],+ [255, 107, 127],+ [0, 189, 156],+ [230, 198, 47],+ [34, 232, 223],+ [220, 57, 106],+ [86, 182, 194],+ [241, 241, 241],+ [73, 81, 98],+ [254, 158, 161],+ [152, 195, 121],+ [249, 228, 107],+ [145, 255, 244],+ [218, 112, 214],+ [188, 243, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Batman",+ background: [27, 29, 30],+ foreground: [111, 111, 111],+ palette: [+ [27, 29, 30],+ [230, 220, 68],+ [200, 190, 70],+ [244, 253, 34],+ [115, 113, 116],+ [116, 114, 113],+ [98, 96, 95],+ [198, 197, 191],+ [80, 83, 84],+ [255, 247, 142],+ [255, 242, 125],+ [254, 237, 108],+ [145, 148, 149],+ [154, 154, 157],+ [163, 163, 166],+ [218, 219, 214],+ ],+ },+ TerminalTheme {+ name: "Belafonte Day",+ background: [213, 204, 186],+ foreground: [69, 55, 60],+ palette: [+ [32, 17, 27],+ [190, 16, 14],+ [133, 129, 98],+ [208, 139, 48],+ [66, 106, 121],+ [151, 82, 44],+ [152, 154, 156],+ [150, 140, 131],+ [94, 82, 82],+ [190, 16, 14],+ [133, 129, 98],+ [208, 139, 48],+ [66, 106, 121],+ [151, 82, 44],+ [152, 154, 156],+ [213, 204, 186],+ ],+ },+ TerminalTheme {+ name: "Belafonte Night",+ background: [32, 17, 27],+ foreground: [150, 140, 131],+ palette: [+ [32, 17, 27],+ [190, 16, 14],+ [133, 129, 98],+ [234, 165, 73],+ [66, 106, 121],+ [151, 82, 44],+ [152, 154, 156],+ [150, 140, 131],+ [94, 82, 82],+ [190, 16, 14],+ [133, 129, 98],+ [234, 165, 73],+ [66, 106, 121],+ [151, 82, 44],+ [152, 154, 156],+ [213, 204, 186],+ ],+ },+ TerminalTheme {+ name: "Birds Of Paradise",+ background: [42, 31, 29],+ foreground: [224, 219, 183],+ palette: [+ [87, 61, 38],+ [190, 45, 38],+ [107, 161, 138],+ [233, 157, 42],+ [90, 134, 173],+ [172, 128, 166],+ [116, 166, 173],+ [224, 219, 183],+ [155, 108, 74],+ [232, 70, 39],+ [149, 216, 186],+ [208, 209, 80],+ [184, 211, 237],+ [209, 158, 203],+ [147, 207, 215],+ [255, 249, 213],+ ],+ },+ TerminalTheme {+ name: "Black Metal",+ background: [0, 0, 0],+ foreground: [193, 193, 193],+ palette: [+ [0, 0, 0],+ [72, 110, 111],+ [221, 153, 153],+ [160, 102, 102],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ [64, 64, 64],+ [72, 110, 111],+ [221, 153, 153],+ [160, 102, 102],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ ],+ },+ TerminalTheme {+ name: "Black Metal (Bathory)",+ background: [0, 0, 0],+ foreground: [193, 193, 193],+ palette: [+ [0, 0, 0],+ [95, 135, 135],+ [251, 203, 151],+ [231, 138, 83],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ [64, 64, 64],+ [95, 135, 135],+ [251, 203, 151],+ [231, 138, 83],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ ],+ },+ TerminalTheme {+ name: "Black Metal (Burzum)",+ background: [0, 0, 0],+ foreground: [193, 193, 193],+ palette: [+ [0, 0, 0],+ [95, 135, 135],+ [221, 238, 204],+ [153, 187, 170],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ [64, 64, 64],+ [95, 135, 135],+ [221, 238, 204],+ [153, 187, 170],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ ],+ },+ TerminalTheme {+ name: "Black Metal (Dark Funeral)",+ background: [0, 0, 0],+ foreground: [193, 193, 193],+ palette: [+ [0, 0, 0],+ [95, 135, 135],+ [208, 223, 238],+ [95, 129, 165],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ [64, 64, 64],+ [95, 135, 135],+ [208, 223, 238],+ [95, 129, 165],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ ],+ },+ TerminalTheme {+ name: "Black Metal (Gorgoroth)",+ background: [0, 0, 0],+ foreground: [193, 193, 193],+ palette: [+ [0, 0, 0],+ [95, 135, 135],+ [155, 141, 127],+ [140, 127, 112],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ [64, 64, 64],+ [95, 135, 135],+ [155, 141, 127],+ [140, 127, 112],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ ],+ },+ TerminalTheme {+ name: "Black Metal (Immortal)",+ background: [0, 0, 0],+ foreground: [193, 193, 193],+ palette: [+ [0, 0, 0],+ [95, 135, 135],+ [119, 153, 187],+ [85, 102, 119],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ [64, 64, 64],+ [95, 135, 135],+ [119, 153, 187],+ [85, 102, 119],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ ],+ },+ TerminalTheme {+ name: "Black Metal (Khold)",+ background: [0, 0, 0],+ foreground: [193, 193, 193],+ palette: [+ [0, 0, 0],+ [95, 135, 135],+ [236, 238, 227],+ [151, 75, 70],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ [64, 64, 64],+ [95, 135, 135],+ [236, 238, 227],+ [151, 75, 70],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ ],+ },+ TerminalTheme {+ name: "Black Metal (Marduk)",+ background: [0, 0, 0],+ foreground: [193, 193, 193],+ palette: [+ [0, 0, 0],+ [95, 135, 135],+ [165, 170, 167],+ [98, 107, 103],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ [64, 64, 64],+ [95, 135, 135],+ [165, 170, 167],+ [98, 107, 103],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ ],+ },+ TerminalTheme {+ name: "Black Metal (Mayhem)",+ background: [0, 0, 0],+ foreground: [193, 193, 193],+ palette: [+ [0, 0, 0],+ [95, 135, 135],+ [243, 236, 212],+ [238, 204, 108],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ [64, 64, 64],+ [95, 135, 135],+ [243, 236, 212],+ [238, 204, 108],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ ],+ },+ TerminalTheme {+ name: "Black Metal (Nile)",+ background: [0, 0, 0],+ foreground: [193, 193, 193],+ palette: [+ [0, 0, 0],+ [95, 135, 135],+ [170, 153, 136],+ [119, 119, 85],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ [64, 64, 64],+ [95, 135, 135],+ [170, 153, 136],+ [119, 119, 85],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ ],+ },+ TerminalTheme {+ name: "Black Metal (Venom)",+ background: [0, 0, 0],+ foreground: [193, 193, 193],+ palette: [+ [0, 0, 0],+ [95, 135, 135],+ [248, 247, 242],+ [121, 36, 31],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ [64, 64, 64],+ [95, 135, 135],+ [248, 247, 242],+ [121, 36, 31],+ [136, 136, 136],+ [153, 153, 153],+ [170, 170, 170],+ [193, 193, 193],+ ],+ },+ TerminalTheme {+ name: "Blazer",+ background: [13, 25, 38],+ foreground: [217, 230, 242],+ palette: [+ [0, 0, 0],+ [184, 122, 122],+ [122, 184, 122],+ [184, 184, 122],+ [122, 122, 184],+ [184, 122, 184],+ [122, 184, 184],+ [217, 217, 217],+ [76, 76, 76],+ [219, 189, 189],+ [189, 219, 189],+ [219, 219, 189],+ [189, 189, 219],+ [219, 189, 219],+ [189, 219, 219],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Blue Berry Pie",+ background: [28, 12, 40],+ foreground: [186, 186, 185],+ palette: [+ [10, 76, 98],+ [153, 36, 110],+ [92, 177, 179],+ [234, 185, 168],+ [144, 165, 189],+ [157, 84, 167],+ [126, 131, 204],+ [240, 232, 214],+ [70, 60, 93],+ [200, 114, 114],+ [10, 108, 126],+ [122, 49, 136],+ [95, 61, 99],+ [188, 148, 183],+ [94, 96, 113],+ [10, 108, 126],+ ],+ },+ TerminalTheme {+ name: "Blue Dolphin",+ background: [0, 105, 132],+ foreground: [197, 242, 255],+ palette: [+ [41, 45, 62],+ [255, 130, 136],+ [180, 232, 141],+ [244, 214, 159],+ [130, 170, 255],+ [233, 193, 255],+ [137, 235, 255],+ [208, 208, 208],+ [144, 148, 164],+ [255, 139, 146],+ [221, 255, 167],+ [255, 229, 133],+ [156, 196, 255],+ [221, 176, 246],+ [163, 247, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Blue Matrix",+ background: [16, 17, 22],+ foreground: [0, 162, 255],+ palette: [+ [16, 17, 22],+ [255, 86, 128],+ [0, 255, 156],+ [255, 252, 88],+ [0, 176, 255],+ [213, 123, 255],+ [118, 193, 255],+ [199, 199, 199],+ [104, 104, 104],+ [255, 110, 103],+ [95, 250, 104],+ [255, 252, 103],+ [104, 113, 255],+ [214, 130, 236],+ [96, 253, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Bluloco Dark",+ background: [40, 44, 52],+ foreground: [185, 192, 203],+ palette: [+ [65, 68, 77],+ [252, 47, 82],+ [37, 164, 92],+ [255, 147, 106],+ [52, 118, 255],+ [122, 130, 218],+ [68, 131, 170],+ [205, 212, 224],+ [143, 154, 174],+ [255, 100, 128],+ [63, 197, 107],+ [249, 200, 89],+ [16, 177, 254],+ [255, 120, 248],+ [95, 185, 188],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Bluloco Light",+ background: [249, 249, 249],+ foreground: [55, 58, 65],+ palette: [+ [55, 58, 65],+ [213, 39, 83],+ [35, 151, 74],+ [223, 99, 28],+ [39, 95, 228],+ [130, 63, 241],+ [39, 97, 141],+ [186, 187, 194],+ [103, 106, 119],+ [255, 100, 128],+ [60, 188, 102],+ [197, 163, 50],+ [0, 153, 225],+ [206, 51, 192],+ [109, 147, 187],+ [211, 211, 211],+ ],+ },+ TerminalTheme {+ name: "Borland",+ background: [0, 0, 164],+ foreground: [255, 255, 78],+ palette: [+ [79, 79, 79],+ [255, 108, 96],+ [168, 255, 96],+ [255, 255, 182],+ [150, 203, 254],+ [255, 115, 253],+ [198, 197, 254],+ [238, 238, 238],+ [124, 124, 124],+ [255, 182, 176],+ [206, 255, 172],+ [255, 255, 204],+ [181, 220, 255],+ [255, 156, 254],+ [223, 223, 254],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Box",+ background: [20, 29, 43],+ foreground: [159, 239, 0],+ palette: [+ [0, 0, 0],+ [204, 4, 3],+ [25, 203, 0],+ [206, 203, 0],+ [13, 115, 204],+ [203, 30, 209],+ [13, 205, 205],+ [221, 221, 221],+ [118, 118, 118],+ [242, 32, 31],+ [35, 253, 0],+ [255, 253, 0],+ [26, 143, 255],+ [253, 40, 255],+ [20, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Breadog",+ background: [241, 235, 230],+ foreground: [54, 44, 36],+ palette: [+ [54, 44, 36],+ [177, 11, 0],+ [0, 114, 50],+ [139, 76, 0],+ [0, 92, 180],+ [155, 0, 151],+ [0, 106, 120],+ [186, 169, 157],+ [81, 67, 55],+ [222, 17, 0],+ [0, 143, 64],+ [174, 96, 0],+ [0, 116, 225],+ [195, 0, 189],+ [0, 134, 151],+ [234, 225, 218],+ ],+ },+ TerminalTheme {+ name: "Breeze",+ background: [49, 54, 59],+ foreground: [239, 240, 241],+ palette: [+ [49, 54, 59],+ [237, 21, 21],+ [17, 209, 22],+ [246, 116, 0],+ [29, 153, 243],+ [155, 89, 182],+ [26, 188, 156],+ [239, 240, 241],+ [127, 140, 141],+ [192, 57, 43],+ [28, 220, 154],+ [253, 188, 75],+ [61, 174, 233],+ [142, 68, 173],+ [22, 160, 133],+ [252, 252, 252],+ ],+ },+ TerminalTheme {+ name: "Bright Lights",+ background: [25, 25, 25],+ foreground: [179, 201, 215],+ palette: [+ [25, 25, 25],+ [255, 53, 91],+ [183, 232, 118],+ [255, 194, 81],+ [118, 212, 255],+ [186, 118, 231],+ [108, 191, 181],+ [194, 200, 215],+ [76, 76, 76],+ [255, 53, 91],+ [183, 232, 118],+ [255, 194, 81],+ [118, 213, 255],+ [186, 118, 231],+ [108, 191, 181],+ [194, 200, 215],+ ],+ },+ TerminalTheme {+ name: "Broadcast",+ background: [43, 43, 43],+ foreground: [230, 225, 220],+ palette: [+ [0, 0, 0],+ [218, 73, 57],+ [81, 159, 80],+ [255, 210, 74],+ [109, 156, 190],+ [208, 208, 255],+ [110, 156, 190],+ [255, 255, 255],+ [88, 88, 88],+ [255, 123, 107],+ [131, 209, 130],+ [255, 255, 124],+ [159, 206, 240],+ [255, 255, 255],+ [160, 206, 240],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Brogrammer",+ background: [19, 19, 19],+ foreground: [214, 219, 229],+ palette: [+ [31, 31, 31],+ [248, 17, 24],+ [45, 197, 94],+ [236, 186, 15],+ [42, 132, 210],+ [78, 90, 183],+ [16, 129, 214],+ [214, 219, 229],+ [214, 219, 229],+ [222, 53, 46],+ [29, 211, 97],+ [243, 189, 9],+ [16, 129, 214],+ [83, 80, 185],+ [15, 125, 219],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Builtin Dark",+ background: [0, 0, 0],+ foreground: [187, 187, 187],+ palette: [+ [0, 0, 0],+ [187, 0, 0],+ [0, 187, 0],+ [187, 187, 0],+ [13, 13, 200],+ [187, 0, 187],+ [0, 187, 187],+ [187, 187, 187],+ [85, 85, 85],+ [255, 85, 85],+ [85, 255, 85],+ [255, 255, 85],+ [85, 85, 255],+ [255, 85, 255],+ [85, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Builtin Light",+ background: [255, 255, 255],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [187, 0, 0],+ [0, 187, 0],+ [187, 187, 0],+ [0, 0, 187],+ [187, 0, 187],+ [0, 187, 187],+ [187, 187, 187],+ [85, 85, 85],+ [255, 85, 85],+ [47, 217, 47],+ [191, 191, 21],+ [85, 85, 255],+ [255, 85, 255],+ [34, 204, 204],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Builtin Pastel Dark",+ background: [0, 0, 0],+ foreground: [187, 187, 187],+ palette: [+ [79, 79, 79],+ [255, 108, 96],+ [168, 255, 96],+ [255, 255, 182],+ [150, 203, 254],+ [255, 115, 253],+ [198, 197, 254],+ [238, 238, 238],+ [124, 124, 124],+ [255, 182, 176],+ [206, 255, 172],+ [255, 255, 204],+ [181, 220, 255],+ [255, 156, 254],+ [223, 223, 254],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Builtin Tango Dark",+ background: [0, 0, 0],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [204, 0, 0],+ [78, 154, 6],+ [196, 160, 0],+ [52, 101, 164],+ [117, 80, 123],+ [6, 152, 154],+ [211, 215, 207],+ [85, 87, 83],+ [239, 41, 41],+ [138, 226, 52],+ [252, 233, 79],+ [114, 159, 207],+ [173, 127, 168],+ [52, 226, 226],+ [238, 238, 236],+ ],+ },+ TerminalTheme {+ name: "Builtin Tango Light",+ background: [255, 255, 255],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [204, 0, 0],+ [78, 154, 6],+ [196, 160, 0],+ [52, 101, 164],+ [117, 80, 123],+ [6, 152, 154],+ [185, 189, 181],+ [85, 87, 83],+ [239, 41, 41],+ [125, 213, 39],+ [214, 195, 41],+ [114, 159, 207],+ [173, 127, 168],+ [39, 213, 213],+ [238, 238, 236],+ ],+ },+ TerminalTheme {+ name: "C64",+ background: [64, 49, 141],+ foreground: [120, 105, 196],+ palette: [+ [9, 3, 0],+ [162, 82, 76],+ [85, 160, 73],+ [191, 206, 114],+ [102, 87, 179],+ [152, 76, 163],+ [103, 182, 189],+ [255, 255, 255],+ [0, 0, 0],+ [162, 82, 76],+ [85, 160, 73],+ [191, 206, 114],+ [102, 87, 179],+ [152, 76, 163],+ [103, 182, 189],+ [247, 247, 247],+ ],+ },+ TerminalTheme {+ name: "CGA",+ background: [0, 0, 0],+ foreground: [170, 170, 170],+ palette: [+ [0, 0, 0],+ [170, 0, 0],+ [0, 170, 0],+ [170, 85, 0],+ [13, 13, 183],+ [170, 0, 170],+ [0, 170, 170],+ [170, 170, 170],+ [85, 85, 85],+ [255, 85, 85],+ [85, 255, 85],+ [255, 255, 85],+ [85, 85, 255],+ [255, 85, 255],+ [85, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "CLRS",+ background: [255, 255, 255],+ foreground: [38, 38, 38],+ palette: [+ [0, 0, 0],+ [248, 40, 42],+ [50, 138, 93],+ [250, 112, 29],+ [19, 92, 208],+ [159, 0, 189],+ [51, 195, 193],+ [179, 179, 179],+ [85, 87, 83],+ [251, 4, 22],+ [44, 198, 49],+ [227, 189, 14],+ [22, 112, 255],+ [233, 0, 176],+ [58, 213, 206],+ [238, 238, 236],+ ],+ },+ TerminalTheme {+ name: "Calamity",+ background: [47, 40, 51],+ foreground: [213, 206, 217],+ palette: [+ [47, 40, 51],+ [252, 100, 77],+ [165, 246, 156],+ [233, 215, 165],+ [59, 121, 199],+ [249, 38, 114],+ [116, 211, 222],+ [213, 206, 217],+ [126, 108, 136],+ [252, 100, 77],+ [165, 246, 156],+ [233, 215, 165],+ [59, 121, 199],+ [249, 38, 114],+ [116, 211, 222],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Carbonfox",+ background: [22, 22, 22],+ foreground: [242, 244, 248],+ palette: [+ [40, 40, 40],+ [238, 83, 150],+ [37, 190, 106],+ [8, 189, 186],+ [120, 169, 255],+ [190, 149, 255],+ [51, 177, 255],+ [223, 223, 224],+ [72, 72, 72],+ [241, 109, 166],+ [70, 200, 128],+ [45, 199, 196],+ [140, 182, 255],+ [200, 165, 255],+ [82, 189, 255],+ [228, 228, 229],+ ],+ },+ TerminalTheme {+ name: "Catppuccin Frappe",+ background: [48, 52, 70],+ foreground: [198, 208, 245],+ palette: [+ [81, 87, 109],+ [231, 130, 132],+ [166, 209, 137],+ [229, 200, 144],+ [140, 170, 238],+ [244, 184, 228],+ [129, 200, 190],+ [165, 173, 206],+ [98, 104, 128],+ [230, 113, 114],+ [142, 199, 114],+ [217, 186, 115],+ [123, 158, 240],+ [242, 164, 219],+ [90, 191, 181],+ [181, 191, 226],+ ],+ },+ TerminalTheme {+ name: "Catppuccin Latte",+ background: [239, 241, 245],+ foreground: [76, 79, 105],+ palette: [+ [92, 95, 119],+ [210, 15, 57],+ [64, 160, 43],+ [223, 142, 29],+ [30, 102, 245],+ [234, 118, 203],+ [23, 146, 153],+ [172, 176, 190],+ [108, 111, 133],+ [222, 41, 62],+ [73, 175, 61],+ [238, 160, 45],+ [69, 110, 255],+ [254, 133, 216],+ [45, 159, 168],+ [188, 192, 204],+ ],+ },+ TerminalTheme {+ name: "Catppuccin Macchiato",+ background: [36, 39, 58],+ foreground: [202, 211, 245],+ palette: [+ [73, 77, 100],+ [237, 135, 150],+ [166, 218, 149],+ [238, 212, 159],+ [138, 173, 244],+ [245, 189, 230],+ [139, 213, 202],+ [165, 173, 203],+ [91, 96, 120],+ [236, 116, 134],+ [140, 207, 127],+ [225, 198, 130],+ [120, 161, 246],+ [242, 169, 221],+ [99, 203, 192],+ [184, 192, 224],+ ],+ },+ TerminalTheme {+ name: "Catppuccin Mocha",+ background: [30, 30, 46],+ foreground: [205, 214, 244],+ palette: [+ [69, 71, 90],+ [243, 139, 168],+ [166, 227, 161],+ [249, 226, 175],+ [137, 180, 250],+ [245, 194, 231],+ [148, 226, 213],+ [166, 173, 200],+ [88, 91, 112],+ [243, 119, 153],+ [137, 216, 139],+ [235, 211, 145],+ [116, 168, 252],+ [242, 174, 222],+ [107, 215, 202],+ [186, 194, 222],+ ],+ },+ TerminalTheme {+ name: "Chalk",+ background: [43, 45, 46],+ foreground: [210, 216, 217],+ palette: [+ [125, 139, 143],+ [178, 58, 82],+ [120, 155, 106],+ [185, 172, 74],+ [42, 127, 172],+ [189, 79, 90],+ [68, 167, 153],+ [210, 216, 217],+ [136, 136, 136],+ [242, 72, 64],+ [128, 196, 112],+ [255, 235, 98],+ [65, 150, 255],+ [252, 82, 117],+ [83, 205, 189],+ [210, 216, 217],+ ],+ },+ TerminalTheme {+ name: "Chalkboard",+ background: [41, 38, 47],+ foreground: [217, 230, 242],+ palette: [+ [0, 0, 0],+ [195, 115, 114],+ [114, 195, 115],+ [194, 195, 114],+ [115, 114, 195],+ [195, 114, 194],+ [114, 194, 195],+ [217, 217, 217],+ [88, 88, 88],+ [219, 170, 170],+ [170, 219, 170],+ [218, 219, 170],+ [170, 170, 219],+ [219, 170, 218],+ [170, 218, 219],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Challenger Deep",+ background: [30, 28, 49],+ foreground: [203, 225, 231],+ palette: [+ [20, 18, 40],+ [255, 84, 88],+ [98, 209, 150],+ [255, 179, 120],+ [101, 178, 255],+ [144, 108, 255],+ [99, 242, 241],+ [166, 179, 204],+ [86, 85, 117],+ [255, 128, 128],+ [149, 255, 164],+ [255, 233, 170],+ [145, 221, 255],+ [201, 145, 225],+ [170, 255, 228],+ [203, 227, 231],+ ],+ },+ TerminalTheme {+ name: "Chester",+ background: [44, 54, 67],+ foreground: [255, 255, 255],+ palette: [+ [8, 2, 0],+ [250, 94, 91],+ [22, 201, 141],+ [255, 200, 63],+ [40, 138, 214],+ [211, 69, 144],+ [40, 221, 222],+ [231, 231, 231],+ [111, 107, 104],+ [250, 94, 91],+ [22, 201, 141],+ [254, 239, 109],+ [39, 138, 214],+ [211, 69, 144],+ [39, 222, 222],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Ciapre",+ background: [25, 28, 39],+ foreground: [174, 164, 122],+ palette: [+ [24, 24, 24],+ [142, 13, 22],+ [72, 81, 59],+ [204, 139, 63],+ [87, 109, 140],+ [114, 77, 124],+ [92, 79, 75],+ [174, 164, 127],+ [85, 85, 85],+ [172, 56, 53],+ [166, 167, 93],+ [220, 223, 124],+ [48, 151, 198],+ [211, 48, 97],+ [243, 219, 178],+ [244, 244, 244],+ ],+ },+ TerminalTheme {+ name: "Citruszest",+ background: [18, 18, 18],+ foreground: [191, 191, 191],+ palette: [+ [64, 64, 64],+ [255, 84, 84],+ [0, 204, 122],+ [255, 212, 0],+ [0, 191, 255],+ [255, 144, 254],+ [72, 209, 204],+ [191, 191, 191],+ [128, 128, 128],+ [255, 26, 117],+ [26, 255, 163],+ [255, 255, 0],+ [51, 207, 255],+ [255, 178, 254],+ [0, 255, 242],+ [249, 249, 249],+ ],+ },+ TerminalTheme {+ name: "Cobalt Neon",+ background: [20, 40, 56],+ foreground: [143, 245, 134],+ palette: [+ [20, 38, 49],+ [255, 35, 32],+ [59, 165, 255],+ [233, 231, 92],+ [143, 245, 134],+ [120, 26, 160],+ [143, 245, 134],+ [186, 70, 178],+ [255, 246, 136],+ [212, 49, 46],+ [143, 245, 134],+ [233, 240, 109],+ [60, 125, 210],+ [130, 48, 167],+ [108, 188, 103],+ [143, 245, 134],+ ],+ },+ TerminalTheme {+ name: "Cobalt Next",+ background: [22, 44, 53],+ foreground: [215, 222, 234],+ palette: [+ [0, 0, 0],+ [255, 82, 123],+ [140, 201, 143],+ [255, 198, 76],+ [64, 157, 212],+ [203, 163, 199],+ [55, 181, 180],+ [215, 222, 234],+ [98, 116, 127],+ [228, 126, 139],+ [186, 221, 187],+ [255, 220, 145],+ [122, 192, 235],+ [243, 204, 239],+ [132, 228, 227],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Cobalt Next Dark",+ background: [11, 28, 36],+ foreground: [215, 222, 234],+ palette: [+ [38, 47, 55],+ [249, 73, 103],+ [140, 201, 143],+ [255, 198, 76],+ [64, 157, 212],+ [203, 163, 199],+ [55, 181, 180],+ [215, 222, 234],+ [98, 116, 127],+ [228, 126, 139],+ [186, 221, 187],+ [255, 220, 145],+ [122, 192, 235],+ [243, 204, 239],+ [132, 228, 227],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Cobalt Next Minimal",+ background: [11, 28, 36],+ foreground: [215, 222, 234],+ palette: [+ [50, 61, 71],+ [255, 101, 122],+ [140, 201, 143],+ [255, 198, 76],+ [64, 157, 212],+ [203, 163, 199],+ [55, 181, 180],+ [215, 222, 234],+ [98, 116, 127],+ [228, 126, 139],+ [186, 221, 187],+ [255, 220, 145],+ [122, 192, 235],+ [243, 204, 239],+ [132, 228, 227],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Cobalt2",+ background: [19, 39, 56],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [255, 0, 0],+ [56, 222, 33],+ [255, 229, 10],+ [20, 96, 210],+ [255, 0, 93],+ [0, 187, 187],+ [187, 187, 187],+ [85, 85, 85],+ [244, 14, 23],+ [59, 208, 29],+ [237, 200, 9],+ [85, 85, 255],+ [255, 85, 255],+ [106, 227, 250],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Coffee Theme",+ background: [245, 222, 179],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [201, 27, 0],+ [0, 194, 0],+ [173, 170, 0],+ [2, 37, 199],+ [202, 48, 199],+ [0, 184, 186],+ [161, 161, 161],+ [104, 104, 104],+ [255, 110, 103],+ [31, 186, 40],+ [178, 175, 27],+ [104, 113, 255],+ [242, 106, 242],+ [32, 189, 191],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Crayon Pony Fish",+ background: [21, 7, 7],+ foreground: [104, 82, 90],+ palette: [+ [43, 27, 29],+ [145, 0, 43],+ [87, 149, 36],+ [171, 49, 27],+ [140, 135, 176],+ [105, 47, 80],+ [232, 168, 102],+ [104, 82, 90],+ [74, 56, 59],+ [197, 37, 93],+ [141, 255, 87],+ [200, 56, 29],+ [207, 201, 255],+ [252, 108, 186],+ [255, 206, 175],+ [176, 148, 157],+ ],+ },+ TerminalTheme {+ name: "Cursor Dark",+ background: [20, 20, 20],+ foreground: [255, 255, 255],+ palette: [+ [42, 42, 42],+ [191, 97, 106],+ [163, 190, 140],+ [235, 203, 139],+ [129, 161, 193],+ [180, 142, 173],+ [136, 192, 208],+ [216, 222, 233],+ [80, 80, 80],+ [191, 97, 106],+ [163, 190, 140],+ [235, 203, 139],+ [129, 161, 193],+ [180, 142, 173],+ [136, 192, 208],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Cutie Pro",+ background: [24, 24, 24],+ foreground: [213, 208, 201],+ palette: [+ [0, 0, 0],+ [245, 110, 127],+ [190, 201, 117],+ [245, 134, 105],+ [66, 217, 197],+ [210, 134, 183],+ [55, 203, 138],+ [213, 195, 195],+ [136, 132, 127],+ [229, 161, 163],+ [232, 214, 167],+ [241, 187, 121],+ [128, 197, 222],+ [178, 148, 187],+ [157, 204, 187],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Cyberdyne",+ background: [21, 17, 68],+ foreground: [0, 255, 146],+ palette: [+ [8, 8, 8],+ [255, 131, 115],+ [0, 193, 114],+ [210, 167, 0],+ [0, 113, 207],+ [255, 144, 254],+ [107, 255, 221],+ [241, 241, 241],+ [72, 72, 72],+ [255, 196, 190],+ [214, 252, 186],+ [255, 254, 213],+ [194, 227, 255],+ [255, 178, 254],+ [230, 231, 254],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Cyberpunk",+ background: [51, 42, 87],+ foreground: [229, 229, 229],+ palette: [+ [0, 0, 0],+ [255, 112, 146],+ [0, 251, 172],+ [255, 250, 106],+ [0, 191, 255],+ [223, 149, 255],+ [134, 203, 254],+ [255, 255, 255],+ [89, 89, 89],+ [255, 138, 164],+ [33, 246, 188],+ [255, 247, 135],+ [27, 204, 253],+ [230, 174, 254],+ [153, 214, 252],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Cyberpunk Scarlet Protocol",+ background: [16, 17, 22],+ foreground: [228, 25, 81],+ palette: [+ [16, 17, 22],+ [255, 0, 81],+ [1, 220, 132],+ [250, 249, 69],+ [2, 113, 182],+ [201, 48, 199],+ [0, 197, 199],+ [199, 199, 199],+ [104, 104, 104],+ [255, 110, 103],+ [96, 250, 104],+ [255, 252, 103],+ [104, 113, 255],+ [189, 53, 236],+ [96, 253, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Dark Modern",+ background: [31, 31, 31],+ foreground: [204, 204, 204],+ palette: [+ [39, 39, 39],+ [247, 73, 73],+ [46, 160, 67],+ [158, 106, 3],+ [0, 120, 212],+ [208, 18, 115],+ [29, 180, 214],+ [204, 204, 204],+ [93, 93, 93],+ [220, 84, 82],+ [35, 209, 139],+ [245, 245, 67],+ [59, 142, 234],+ [214, 112, 214],+ [41, 184, 219],+ [229, 229, 229],+ ],+ },+ TerminalTheme {+ name: "Dark Pastel",+ background: [0, 0, 0],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [255, 85, 85],+ [85, 255, 85],+ [255, 255, 85],+ [85, 85, 255],+ [255, 85, 255],+ [85, 255, 255],+ [187, 187, 187],+ [85, 85, 85],+ [255, 85, 85],+ [85, 255, 85],+ [255, 255, 85],+ [85, 85, 255],+ [255, 85, 255],+ [85, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Dark+",+ background: [30, 30, 30],+ foreground: [204, 204, 204],+ palette: [+ [0, 0, 0],+ [205, 49, 49],+ [13, 188, 121],+ [229, 229, 16],+ [36, 114, 200],+ [188, 63, 188],+ [17, 168, 205],+ [229, 229, 229],+ [102, 102, 102],+ [241, 76, 76],+ [35, 209, 139],+ [245, 245, 67],+ [59, 142, 234],+ [214, 112, 214],+ [41, 184, 219],+ [229, 229, 229],+ ],+ },+ TerminalTheme {+ name: "Darkermatrix",+ background: [7, 12, 14],+ foreground: [53, 69, 26],+ palette: [+ [9, 16, 19],+ [26, 72, 49],+ [111, 166, 76],+ [89, 89, 0],+ [0, 203, 107],+ [78, 55, 90],+ [18, 84, 89],+ [26, 72, 51],+ [64, 64, 64],+ [13, 69, 42],+ [144, 215, 98],+ [226, 229, 0],+ [0, 255, 135],+ [78, 55, 90],+ [23, 108, 115],+ [0, 56, 30],+ ],+ },+ TerminalTheme {+ name: "Darkmatrix",+ background: [7, 12, 14],+ foreground: [62, 87, 21],+ palette: [+ [9, 16, 19],+ [0, 101, 54],+ [111, 166, 76],+ [126, 128, 0],+ [44, 154, 132],+ [82, 58, 96],+ [17, 77, 83],+ [0, 101, 54],+ [64, 64, 64],+ [0, 115, 61],+ [144, 215, 98],+ [226, 229, 0],+ [70, 216, 184],+ [87, 61, 102],+ [18, 84, 90],+ [0, 101, 54],+ ],+ },+ TerminalTheme {+ name: "Darkside",+ background: [34, 35, 36],+ foreground: [186, 186, 186],+ palette: [+ [0, 0, 0],+ [232, 52, 28],+ [104, 194, 86],+ [242, 212, 44],+ [28, 152, 232],+ [142, 105, 201],+ [28, 152, 232],+ [186, 186, 186],+ [76, 76, 76],+ [224, 90, 79],+ [119, 184, 105],+ [239, 214, 75],+ [56, 124, 211],+ [149, 123, 190],+ [61, 151, 226],+ [186, 186, 186],+ ],+ },+ TerminalTheme {+ name: "Dawnfox",+ background: [250, 244, 237],+ foreground: [87, 82, 121],+ palette: [+ [87, 82, 121],+ [180, 99, 122],+ [97, 135, 116],+ [234, 157, 52],+ [40, 105, 131],+ [144, 122, 169],+ [86, 148, 159],+ [178, 182, 189],+ [95, 86, 149],+ [194, 109, 133],+ [98, 159, 129],+ [238, 168, 70],+ [45, 129, 163],+ [154, 128, 185],+ [92, 167, 180],+ [230, 235, 243],+ ],+ },+ TerminalTheme {+ name: "Dayfox",+ background: [246, 242, 238],+ foreground: [61, 43, 90],+ palette: [+ [53, 44, 36],+ [165, 34, 47],+ [57, 104, 71],+ [172, 84, 2],+ [40, 72, 169],+ [110, 51, 206],+ [40, 121, 128],+ [191, 182, 174],+ [83, 76, 69],+ [179, 67, 78],+ [87, 127, 99],+ [184, 110, 40],+ [72, 99, 182],+ [132, 82, 213],+ [72, 141, 147],+ [244, 236, 230],+ ],+ },+ TerminalTheme {+ name: "Deep",+ background: [9, 9, 9],+ foreground: [205, 205, 205],+ palette: [+ [0, 0, 0],+ [215, 0, 5],+ [28, 217, 21],+ [217, 189, 38],+ [86, 101, 255],+ [176, 82, 218],+ [80, 210, 218],+ [224, 224, 224],+ [83, 83, 83],+ [251, 0, 7],+ [34, 255, 24],+ [254, 220, 43],+ [159, 169, 255],+ [224, 154, 255],+ [141, 249, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Desert",+ background: [51, 51, 51],+ foreground: [255, 255, 255],+ palette: [+ [77, 77, 77],+ [255, 43, 43],+ [152, 251, 152],+ [240, 230, 140],+ [205, 133, 63],+ [255, 222, 173],+ [255, 160, 160],+ [245, 222, 179],+ [98, 98, 98],+ [255, 85, 85],+ [85, 255, 85],+ [255, 255, 85],+ [135, 206, 255],+ [255, 85, 255],+ [255, 215, 0],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Detuned",+ background: [0, 0, 0],+ foreground: [199, 199, 199],+ palette: [+ [23, 23, 23],+ [254, 67, 134],+ [166, 227, 45],+ [230, 218, 115],+ [0, 148, 217],+ [155, 55, 255],+ [80, 183, 217],+ [199, 199, 199],+ [104, 104, 104],+ [250, 128, 172],+ [189, 227, 113],+ [255, 242, 127],+ [0, 190, 255],+ [190, 158, 255],+ [94, 215, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Dimidium",+ background: [20, 20, 20],+ foreground: [186, 183, 182],+ palette: [+ [0, 0, 0],+ [207, 73, 76],+ [96, 180, 66],+ [219, 156, 17],+ [5, 117, 216],+ [175, 94, 210],+ [29, 182, 187],+ [186, 183, 182],+ [129, 126, 126],+ [255, 100, 59],+ [55, 229, 123],+ [252, 205, 26],+ [104, 141, 253],+ [237, 111, 233],+ [50, 224, 251],+ [222, 227, 228],+ ],+ },+ TerminalTheme {+ name: "Dimmed Monokai",+ background: [31, 31, 31],+ foreground: [185, 188, 186],+ palette: [+ [58, 61, 67],+ [190, 63, 72],+ [135, 154, 59],+ [197, 166, 53],+ [79, 118, 161],+ [133, 92, 141],+ [87, 143, 164],+ [185, 188, 186],+ [136, 137, 135],+ [251, 0, 31],+ [15, 114, 47],+ [196, 112, 51],+ [24, 109, 227],+ [251, 0, 103],+ [46, 112, 109],+ [253, 255, 185],+ ],+ },+ TerminalTheme {+ name: "Django",+ background: [11, 47, 32],+ foreground: [248, 248, 248],+ palette: [+ [0, 0, 0],+ [253, 98, 9],+ [65, 168, 62],+ [255, 232, 98],+ [49, 93, 63],+ [248, 248, 248],+ [157, 243, 159],+ [255, 255, 255],+ [88, 88, 88],+ [255, 148, 59],+ [115, 218, 112],+ [255, 255, 148],+ [86, 130, 100],+ [255, 255, 255],+ [207, 255, 209],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Django Reborn Again",+ background: [5, 31, 20],+ foreground: [218, 222, 220],+ palette: [+ [0, 0, 0],+ [253, 98, 9],+ [65, 168, 62],+ [255, 232, 98],+ [36, 80, 50],+ [248, 248, 248],+ [157, 243, 159],+ [255, 255, 255],+ [76, 76, 76],+ [255, 148, 59],+ [115, 218, 112],+ [255, 255, 148],+ [86, 130, 100],+ [255, 255, 255],+ [207, 255, 209],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Django Smooth",+ background: [36, 80, 50],+ foreground: [248, 248, 248],+ palette: [+ [0, 0, 0],+ [253, 98, 9],+ [65, 168, 62],+ [255, 232, 98],+ [152, 152, 152],+ [248, 248, 248],+ [157, 243, 159],+ [232, 232, 231],+ [114, 114, 114],+ [255, 148, 59],+ [115, 218, 112],+ [255, 255, 148],+ [202, 202, 202],+ [255, 255, 255],+ [207, 255, 209],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Doom One",+ background: [40, 44, 52],+ foreground: [187, 194, 207],+ palette: [+ [0, 0, 0],+ [255, 108, 107],+ [152, 190, 101],+ [236, 190, 123],+ [169, 161, 225],+ [198, 120, 221],+ [81, 175, 239],+ [187, 194, 207],+ [89, 89, 89],+ [255, 102, 85],+ [153, 187, 102],+ [236, 190, 123],+ [169, 161, 225],+ [198, 120, 221],+ [81, 175, 239],+ [191, 191, 191],+ ],+ },+ TerminalTheme {+ name: "Doom Peacock",+ background: [43, 42, 39],+ foreground: [237, 224, 206],+ palette: [+ [28, 31, 36],+ [203, 75, 22],+ [38, 166, 166],+ [188, 212, 42],+ [42, 108, 198],+ [169, 161, 225],+ [86, 153, 175],+ [237, 224, 206],+ [81, 80, 77],+ [255, 93, 56],+ [152, 190, 101],+ [230, 249, 114],+ [81, 175, 239],+ [198, 120, 221],+ [70, 217, 255],+ [223, 223, 223],+ ],+ },+ TerminalTheme {+ name: "Dot Gov",+ background: [38, 44, 53],+ foreground: [235, 235, 235],+ palette: [+ [25, 25, 25],+ [191, 9, 29],+ [61, 151, 81],+ [246, 187, 52],+ [23, 178, 224],+ [120, 48, 176],+ [139, 210, 237],+ [255, 255, 255],+ [89, 89, 89],+ [191, 9, 29],+ [61, 151, 81],+ [246, 187, 52],+ [23, 178, 224],+ [120, 48, 176],+ [139, 210, 237],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Dracula",+ background: [40, 42, 54],+ foreground: [248, 248, 242],+ palette: [+ [33, 34, 44],+ [255, 85, 85],+ [80, 250, 123],+ [241, 250, 140],+ [189, 147, 249],+ [255, 121, 198],+ [139, 233, 253],+ [248, 248, 242],+ [98, 114, 164],+ [255, 110, 110],+ [105, 255, 148],+ [255, 255, 165],+ [214, 172, 255],+ [255, 146, 223],+ [164, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Dracula+",+ background: [33, 33, 33],+ foreground: [248, 248, 242],+ palette: [+ [33, 34, 44],+ [255, 85, 85],+ [80, 250, 123],+ [255, 203, 107],+ [130, 170, 255],+ [199, 146, 234],+ [139, 233, 253],+ [248, 248, 242],+ [84, 84, 84],+ [255, 110, 110],+ [105, 255, 148],+ [255, 203, 107],+ [214, 172, 255],+ [255, 146, 223],+ [164, 255, 255],+ [248, 248, 242],+ ],+ },+ TerminalTheme {+ name: "Duckbones",+ background: [14, 16, 26],+ foreground: [235, 239, 192],+ palette: [+ [14, 16, 26],+ [224, 54, 0],+ [93, 205, 151],+ [227, 149, 0],+ [0, 163, 203],+ [121, 92, 204],+ [0, 163, 203],+ [235, 239, 192],+ [68, 72, 96],+ [255, 72, 33],+ [88, 219, 158],+ [246, 161, 0],+ [0, 180, 224],+ [179, 161, 230],+ [0, 180, 224],+ [179, 182, 146],+ ],+ },+ TerminalTheme {+ name: "Duotone Dark",+ background: [31, 29, 39],+ foreground: [183, 161, 255],+ palette: [+ [31, 29, 39],+ [217, 57, 62],+ [45, 205, 115],+ [217, 183, 110],+ [255, 194, 132],+ [222, 141, 64],+ [36, 136, 255],+ [183, 161, 255],+ [78, 74, 96],+ [217, 57, 62],+ [45, 205, 115],+ [217, 183, 110],+ [255, 194, 132],+ [222, 141, 64],+ [36, 136, 255],+ [234, 229, 255],+ ],+ },+ TerminalTheme {+ name: "Duskfox",+ background: [35, 33, 54],+ foreground: [224, 222, 244],+ palette: [+ [57, 53, 82],+ [235, 111, 146],+ [163, 190, 140],+ [246, 193, 119],+ [86, 159, 186],+ [196, 167, 231],+ [156, 207, 216],+ [224, 222, 244],+ [84, 77, 138],+ [240, 131, 162],+ [177, 209, 150],+ [249, 203, 140],+ [101, 177, 205],+ [204, 177, 237],+ [166, 218, 227],+ [226, 224, 247],+ ],+ },+ TerminalTheme {+ name: "ENCOM",+ background: [0, 0, 0],+ foreground: [0, 165, 149],+ palette: [+ [0, 0, 0],+ [159, 0, 0],+ [0, 139, 0],+ [255, 208, 0],+ [0, 129, 255],+ [188, 0, 202],+ [0, 139, 139],+ [187, 187, 187],+ [85, 85, 85],+ [255, 0, 0],+ [0, 238, 0],+ [255, 255, 0],+ [0, 0, 255],+ [255, 0, 255],+ [0, 205, 205],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Earthsong",+ background: [41, 37, 32],+ foreground: [229, 199, 169],+ palette: [+ [18, 20, 24],+ [201, 66, 52],+ [133, 197, 76],+ [245, 174, 46],+ [19, 152, 185],+ [208, 99, 61],+ [80, 149, 82],+ [229, 198, 170],+ [103, 95, 84],+ [255, 100, 90],+ [152, 224, 54],+ [224, 213, 97],+ [95, 218, 255],+ [255, 146, 105],+ [132, 240, 136],+ [246, 247, 236],+ ],+ },+ TerminalTheme {+ name: "Electron Highlighter",+ background: [35, 40, 61],+ foreground: [165, 182, 212],+ palette: [+ [21, 22, 31],+ [255, 108, 141],+ [0, 255, 195],+ [255, 215, 169],+ [119, 171, 255],+ [218, 164, 244],+ [0, 253, 255],+ [119, 143, 175],+ [74, 103, 137],+ [255, 108, 141],+ [0, 255, 195],+ [255, 215, 169],+ [119, 171, 255],+ [218, 164, 244],+ [0, 253, 255],+ [195, 206, 226],+ ],+ },+ TerminalTheme {+ name: "Elegant",+ background: [41, 43, 49],+ foreground: [206, 210, 214],+ palette: [+ [10, 18, 34],+ [255, 2, 87],+ [133, 204, 149],+ [255, 203, 139],+ [141, 171, 225],+ [199, 146, 235],+ [120, 204, 240],+ [255, 255, 255],+ [87, 86, 86],+ [255, 0, 87],+ [133, 204, 149],+ [255, 203, 139],+ [141, 171, 225],+ [199, 146, 235],+ [63, 172, 239],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Elemental",+ background: [34, 33, 29],+ foreground: [128, 122, 116],+ palette: [+ [60, 60, 48],+ [152, 41, 15],+ [71, 154, 67],+ [127, 113, 17],+ [73, 127, 125],+ [127, 78, 47],+ [56, 127, 88],+ [128, 121, 116],+ [85, 84, 69],+ [224, 80, 42],+ [97, 224, 112],+ [214, 153, 39],+ [121, 217, 217],+ [205, 124, 84],+ [89, 213, 153],+ [255, 241, 233],+ ],+ },+ TerminalTheme {+ name: "Elementary",+ background: [24, 24, 24],+ foreground: [239, 239, 239],+ palette: [+ [36, 36, 36],+ [215, 28, 21],+ [90, 165, 19],+ [253, 180, 12],+ [19, 72, 153],+ [228, 0, 56],+ [37, 149, 225],+ [239, 239, 239],+ [75, 75, 75],+ [252, 28, 24],+ [107, 194, 25],+ [254, 200, 14],+ [9, 85, 255],+ [251, 0, 80],+ [62, 168, 252],+ [140, 0, 236],+ ],+ },+ TerminalTheme {+ name: "Embark",+ background: [30, 28, 49],+ foreground: [238, 255, 255],+ palette: [+ [30, 28, 49],+ [240, 113, 155],+ [161, 239, 211],+ [255, 233, 170],+ [87, 199, 255],+ [199, 146, 234],+ [135, 223, 235],+ [248, 248, 242],+ [88, 82, 115],+ [240, 46, 110],+ [44, 229, 146],+ [255, 179, 120],+ [29, 160, 226],+ [167, 66, 234],+ [99, 242, 241],+ [166, 179, 204],+ ],+ },+ TerminalTheme {+ name: "Embers Dark",+ background: [22, 19, 15],+ foreground: [163, 154, 144],+ palette: [+ [22, 19, 15],+ [130, 109, 87],+ [87, 130, 109],+ [109, 130, 87],+ [109, 87, 130],+ [130, 87, 109],+ [87, 109, 130],+ [163, 154, 144],+ [90, 80, 71],+ [130, 130, 87],+ [70, 64, 57],+ [80, 72, 63],+ [138, 128, 117],+ [190, 182, 174],+ [130, 87, 87],+ [219, 214, 209],+ ],+ },+ TerminalTheme {+ name: "Espresso",+ background: [50, 50, 50],+ foreground: [255, 255, 255],+ palette: [+ [53, 53, 53],+ [210, 82, 82],+ [165, 194, 97],+ [255, 198, 109],+ [108, 153, 187],+ [209, 151, 217],+ [190, 214, 255],+ [238, 238, 236],+ [96, 96, 96],+ [240, 12, 12],+ [194, 224, 117],+ [225, 228, 139],+ [138, 183, 217],+ [239, 181, 247],+ [220, 244, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Espresso Libre",+ background: [42, 33, 28],+ foreground: [184, 168, 152],+ palette: [+ [0, 0, 0],+ [204, 0, 0],+ [26, 146, 28],+ [240, 229, 58],+ [0, 102, 255],+ [197, 101, 107],+ [6, 152, 154],+ [211, 215, 207],+ [85, 87, 83],+ [239, 41, 41],+ [154, 255, 135],+ [255, 251, 92],+ [67, 168, 237],+ [255, 129, 138],+ [52, 226, 226],+ [238, 238, 236],+ ],+ },+ TerminalTheme {+ name: "Everblush",+ background: [20, 27, 30],+ foreground: [218, 218, 218],+ palette: [+ [35, 42, 45],+ [229, 116, 116],+ [140, 207, 126],+ [229, 199, 107],+ [103, 176, 232],+ [196, 127, 213],+ [108, 191, 191],+ [179, 185, 184],+ [70, 78, 80],+ [239, 126, 126],+ [150, 217, 136],+ [244, 214, 122],+ [113, 186, 242],+ [206, 137, 223],+ [103, 203, 231],+ [189, 195, 194],+ ],+ },+ TerminalTheme {+ name: "Everforest Dark Hard",+ background: [30, 35, 38],+ foreground: [211, 198, 170],+ palette: [+ [122, 132, 120],+ [230, 126, 128],+ [167, 192, 128],+ [219, 188, 127],+ [127, 187, 179],+ [214, 153, 182],+ [131, 192, 146],+ [242, 239, 223],+ [166, 176, 160],+ [248, 85, 82],+ [141, 161, 1],+ [223, 160, 0],+ [58, 148, 197],+ [223, 105, 186],+ [53, 167, 124],+ [255, 251, 239],+ ],+ },+ TerminalTheme {+ name: "Everforest Light Med",+ background: [239, 235, 212],+ foreground: [92, 106, 114],+ palette: [+ [122, 132, 120],+ [230, 126, 128],+ [154, 179, 115],+ [193, 162, 102],+ [127, 187, 179],+ [214, 153, 182],+ [131, 192, 146],+ [178, 175, 159],+ [166, 176, 160],+ [248, 85, 82],+ [141, 161, 1],+ [223, 160, 0],+ [58, 148, 197],+ [223, 105, 186],+ [53, 167, 124],+ [255, 251, 239],+ ],+ },+ TerminalTheme {+ name: "Fahrenheit",+ background: [0, 0, 0],+ foreground: [255, 255, 206],+ palette: [+ [29, 29, 29],+ [205, 160, 116],+ [158, 116, 77],+ [254, 207, 117],+ [127, 14, 15],+ [115, 76, 77],+ [151, 151, 151],+ [255, 255, 206],+ [64, 64, 64],+ [254, 206, 160],+ [204, 115, 77],+ [253, 159, 77],+ [203, 74, 5],+ [78, 115, 159],+ [254, 208, 77],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Fairyfloss",+ background: [90, 84, 117],+ foreground: [248, 248, 242],+ palette: [+ [4, 3, 3],+ [249, 38, 114],+ [194, 255, 223],+ [230, 192, 0],+ [194, 255, 223],+ [255, 184, 209],+ [197, 163, 255],+ [248, 248, 240],+ [96, 144, 203],+ [255, 133, 127],+ [194, 255, 223],+ [255, 234, 0],+ [194, 255, 223],+ [255, 184, 209],+ [197, 163, 255],+ [248, 248, 240],+ ],+ },+ TerminalTheme {+ name: "Farmhouse Dark",+ background: [29, 32, 39],+ foreground: [232, 228, 225],+ palette: [+ [29, 32, 39],+ [186, 0, 4],+ [84, 157, 0],+ [200, 115, 0],+ [0, 73, 230],+ [159, 27, 97],+ [31, 182, 92],+ [232, 228, 225],+ [70, 77, 84],+ [235, 0, 9],+ [122, 193, 0],+ [234, 154, 0],+ [0, 110, 254],+ [191, 59, 127],+ [25, 224, 98],+ [244, 238, 240],+ ],+ },+ TerminalTheme {+ name: "Farmhouse Light",+ background: [232, 228, 225],+ foreground: [29, 32, 39],+ palette: [+ [29, 32, 39],+ [141, 0, 3],+ [58, 125, 0],+ [169, 86, 0],+ [9, 44, 205],+ [130, 0, 70],+ [34, 146, 86],+ [168, 164, 161],+ [57, 64, 71],+ [235, 0, 9],+ [122, 193, 0],+ [234, 154, 0],+ [0, 110, 254],+ [191, 59, 127],+ [0, 198, 73],+ [244, 238, 240],+ ],+ },+ TerminalTheme {+ name: "Fideloper",+ background: [41, 47, 51],+ foreground: [219, 218, 224],+ palette: [+ [41, 47, 51],+ [203, 30, 45],+ [237, 184, 172],+ [183, 171, 155],+ [46, 120, 194],+ [192, 35, 111],+ [48, 145, 134],+ [234, 227, 206],+ [73, 96, 104],+ [212, 96, 90],+ [212, 96, 90],+ [168, 102, 113],+ [124, 133, 196],+ [92, 93, 178],+ [129, 144, 144],+ [252, 244, 223],+ ],+ },+ TerminalTheme {+ name: "Firefly Traditional",+ background: [0, 0, 0],+ foreground: [245, 245, 245],+ palette: [+ [0, 0, 0],+ [194, 55, 32],+ [51, 188, 38],+ [175, 173, 36],+ [90, 99, 255],+ [213, 58, 210],+ [51, 187, 199],+ [204, 204, 204],+ [130, 130, 130],+ [255, 59, 30],+ [46, 231, 32],+ [236, 236, 22],+ [131, 141, 255],+ [255, 92, 254],+ [41, 240, 240],+ [235, 235, 235],+ ],+ },+ TerminalTheme {+ name: "Firefox Dev",+ background: [14, 16, 17],+ foreground: [124, 143, 164],+ palette: [+ [0, 40, 49],+ [230, 56, 83],+ [94, 184, 60],+ [165, 119, 6],+ [53, 157, 223],+ [215, 92, 255],+ [75, 115, 162],+ [220, 220, 220],+ [38, 68, 77],+ [225, 0, 63],+ [29, 144, 0],+ [205, 148, 9],+ [0, 111, 192],+ [162, 0, 218],+ [0, 87, 148],+ [226, 226, 226],+ ],+ },+ TerminalTheme {+ name: "Firewatch",+ background: [30, 32, 39],+ foreground: [155, 162, 178],+ palette: [+ [88, 95, 109],+ [217, 83, 96],+ [90, 185, 119],+ [223, 181, 99],+ [77, 137, 196],+ [213, 81, 25],+ [68, 168, 182],+ [230, 229, 255],+ [88, 95, 109],+ [217, 83, 96],+ [90, 185, 119],+ [223, 181, 99],+ [76, 137, 197],+ [213, 81, 25],+ [68, 168, 182],+ [230, 229, 255],+ ],+ },+ TerminalTheme {+ name: "Fish Tank",+ background: [35, 37, 55],+ foreground: [236, 240, 254],+ palette: [+ [3, 7, 60],+ [198, 0, 74],+ [172, 241, 87],+ [254, 205, 94],+ [82, 95, 184],+ [152, 111, 130],+ [150, 135, 99],+ [236, 240, 252],+ [108, 91, 48],+ [218, 75, 138],+ [219, 255, 169],+ [254, 230, 169],+ [178, 190, 250],+ [253, 165, 205],+ [165, 189, 134],+ [246, 255, 236],+ ],+ },+ TerminalTheme {+ name: "Flat",+ background: [0, 34, 64],+ foreground: [44, 197, 93],+ palette: [+ [34, 45, 63],+ [168, 35, 32],+ [50, 165, 72],+ [229, 141, 17],+ [49, 103, 172],+ [120, 26, 160],+ [44, 147, 112],+ [176, 182, 186],+ [71, 82, 98],+ [212, 49, 46],+ [45, 148, 64],+ [229, 190, 12],+ [60, 125, 210],+ [130, 48, 167],+ [53, 179, 135],+ [231, 236, 237],+ ],+ },+ TerminalTheme {+ name: "Flatland",+ background: [29, 31, 33],+ foreground: [184, 219, 239],+ palette: [+ [29, 29, 25],+ [241, 131, 57],+ [159, 211, 100],+ [244, 239, 109],+ [80, 150, 190],+ [105, 90, 188],+ [214, 56, 101],+ [255, 255, 255],+ [80, 80, 76],+ [210, 42, 36],+ [167, 212, 44],+ [255, 137, 73],+ [97, 185, 208],+ [105, 90, 188],+ [214, 56, 101],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Flexoki Dark",+ background: [16, 15, 15],+ foreground: [206, 205, 195],+ palette: [+ [16, 15, 15],+ [209, 77, 65],+ [135, 154, 57],+ [208, 162, 21],+ [67, 133, 190],+ [206, 93, 151],+ [58, 169, 159],+ [135, 133, 128],+ [87, 86, 83],+ [175, 48, 41],+ [102, 128, 11],+ [173, 131, 1],+ [32, 94, 166],+ [160, 47, 111],+ [36, 131, 123],+ [206, 205, 195],+ ],+ },+ TerminalTheme {+ name: "Flexoki Light",+ background: [255, 252, 240],+ foreground: [16, 15, 15],+ palette: [+ [16, 15, 15],+ [175, 48, 41],+ [102, 128, 11],+ [173, 131, 1],+ [32, 94, 166],+ [160, 47, 111],+ [36, 131, 123],+ [111, 110, 105],+ [183, 181, 172],+ [209, 77, 65],+ [135, 154, 57],+ [208, 162, 21],+ [67, 133, 190],+ [206, 93, 151],+ [58, 169, 159],+ [206, 205, 195],+ ],+ },+ TerminalTheme {+ name: "Floraverse",+ background: [14, 13, 21],+ foreground: [219, 209, 185],+ palette: [+ [8, 0, 46],+ [126, 26, 70],+ [93, 115, 26],+ [205, 117, 28],+ [29, 109, 161],+ [183, 7, 126],+ [66, 163, 140],+ [243, 224, 184],+ [76, 56, 102],+ [208, 32, 99],+ [180, 206, 89],+ [250, 195, 87],+ [64, 164, 207],+ [241, 42, 174],+ [98, 202, 168],+ [255, 245, 219],+ ],+ },+ TerminalTheme {+ name: "Forest Blue",+ background: [5, 21, 25],+ foreground: [226, 216, 205],+ palette: [+ [51, 51, 51],+ [248, 129, 142],+ [146, 211, 162],+ [26, 142, 99],+ [142, 208, 206],+ [94, 70, 140],+ [49, 101, 140],+ [226, 216, 205],+ [74, 74, 74],+ [251, 61, 102],+ [107, 180, 141],+ [48, 200, 90],+ [57, 167, 162],+ [126, 98, 179],+ [96, 150, 191],+ [226, 216, 205],+ ],+ },+ TerminalTheme {+ name: "Framer",+ background: [17, 17, 17],+ foreground: [119, 119, 119],+ palette: [+ [20, 20, 20],+ [255, 85, 85],+ [152, 236, 101],+ [255, 204, 51],+ [0, 170, 255],+ [170, 136, 255],+ [136, 221, 255],+ [204, 204, 204],+ [65, 65, 65],+ [255, 136, 136],+ [182, 242, 146],+ [255, 217, 102],+ [51, 187, 255],+ [206, 187, 255],+ [187, 236, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Front End Delight",+ background: [27, 28, 29],+ foreground: [173, 173, 173],+ palette: [+ [36, 37, 38],+ [248, 81, 27],+ [86, 87, 71],+ [250, 119, 29],+ [44, 112, 183],+ [240, 46, 79],+ [60, 161, 166],+ [173, 173, 173],+ [95, 172, 109],+ [247, 67, 25],+ [116, 236, 76],+ [253, 195, 37],+ [51, 147, 202],+ [231, 94, 79],+ [79, 188, 230],+ [140, 115, 91],+ ],+ },+ TerminalTheme {+ name: "Fun Forrest",+ background: [37, 18, 0],+ foreground: [222, 193, 101],+ palette: [+ [0, 0, 0],+ [214, 38, 43],+ [145, 156, 0],+ [190, 138, 19],+ [70, 153, 163],+ [141, 67, 49],+ [218, 130, 19],+ [221, 194, 101],+ [127, 106, 85],+ [229, 90, 28],+ [191, 198, 90],+ [255, 203, 27],+ [124, 201, 207],+ [210, 99, 73],+ [230, 169, 107],+ [255, 234, 163],+ ],+ },+ TerminalTheme {+ name: "Galaxy",+ background: [29, 40, 55],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [249, 85, 95],+ [33, 176, 137],+ [254, 240, 42],+ [88, 157, 246],+ [148, 77, 149],+ [31, 158, 231],+ [187, 187, 187],+ [85, 85, 85],+ [250, 140, 143],+ [53, 187, 154],+ [255, 255, 85],+ [88, 157, 246],+ [231, 86, 153],+ [57, 121, 188],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Galizur",+ background: [7, 19, 23],+ foreground: [221, 238, 255],+ palette: [+ [34, 51, 68],+ [170, 17, 34],+ [51, 170, 17],+ [204, 170, 34],+ [34, 85, 204],+ [119, 85, 170],+ [34, 187, 221],+ [136, 153, 170],+ [85, 102, 119],+ [255, 17, 51],+ [51, 255, 17],+ [255, 221, 51],+ [51, 119, 255],+ [170, 119, 255],+ [51, 221, 255],+ [187, 204, 221],+ ],+ },+ TerminalTheme {+ name: "Ghostty Default Style Dark",+ background: [40, 44, 52],+ foreground: [255, 255, 255],+ palette: [+ [29, 31, 33],+ [204, 101, 102],+ [182, 189, 104],+ [240, 198, 116],+ [130, 162, 190],+ [178, 148, 187],+ [138, 190, 183],+ [196, 200, 198],+ [102, 102, 102],+ [213, 78, 83],+ [185, 202, 75],+ [231, 197, 71],+ [122, 166, 218],+ [195, 151, 216],+ [112, 192, 177],+ [234, 234, 234],+ ],+ },+ TerminalTheme {+ name: "GitHub",+ background: [244, 244, 244],+ foreground: [62, 62, 62],+ palette: [+ [62, 62, 62],+ [151, 11, 22],+ [7, 150, 42],+ [197, 187, 148],+ [0, 62, 138],+ [233, 70, 145],+ [124, 196, 223],+ [178, 178, 178],+ [102, 102, 102],+ [222, 0, 0],+ [122, 200, 149],+ [215, 182, 0],+ [46, 108, 186],+ [242, 149, 146],+ [0, 199, 203],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "GitHub Dark",+ background: [16, 18, 22],+ foreground: [139, 148, 158],+ palette: [+ [0, 0, 0],+ [247, 129, 102],+ [86, 211, 100],+ [227, 179, 65],+ [108, 164, 248],+ [219, 97, 162],+ [43, 116, 137],+ [255, 255, 255],+ [77, 77, 77],+ [247, 129, 102],+ [86, 211, 100],+ [227, 179, 65],+ [108, 164, 248],+ [219, 97, 162],+ [43, 116, 137],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "GitHub Dark Colorblind",+ background: [13, 17, 23],+ foreground: [201, 209, 217],+ palette: [+ [72, 79, 88],+ [236, 142, 44],+ [88, 166, 255],+ [210, 153, 34],+ [88, 166, 255],+ [188, 140, 255],+ [57, 197, 207],+ [177, 186, 196],+ [110, 118, 129],+ [253, 172, 84],+ [121, 192, 255],+ [227, 179, 65],+ [121, 192, 255],+ [210, 168, 255],+ [86, 212, 221],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "GitHub Dark Default",+ background: [13, 17, 23],+ foreground: [230, 237, 243],+ palette: [+ [72, 79, 88],+ [255, 123, 114],+ [63, 185, 80],+ [210, 153, 34],+ [88, 166, 255],+ [188, 140, 255],+ [57, 197, 207],+ [177, 186, 196],+ [110, 118, 129],+ [255, 161, 152],+ [86, 211, 100],+ [227, 179, 65],+ [121, 192, 255],+ [210, 168, 255],+ [86, 212, 221],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "GitHub Dark Dimmed",+ background: [34, 39, 46],+ foreground: [173, 186, 199],+ palette: [+ [84, 93, 104],+ [244, 112, 103],+ [87, 171, 90],+ [198, 144, 38],+ [83, 155, 245],+ [176, 131, 240],+ [57, 197, 207],+ [144, 157, 171],+ [99, 110, 123],+ [255, 147, 138],+ [107, 196, 109],+ [218, 170, 63],+ [108, 182, 255],+ [220, 189, 251],+ [86, 212, 221],+ [205, 217, 229],+ ],+ },+ TerminalTheme {+ name: "GitHub Dark High Contrast",+ background: [10, 12, 16],+ foreground: [240, 243, 246],+ palette: [+ [122, 130, 142],+ [255, 148, 146],+ [38, 205, 77],+ [240, 183, 47],+ [113, 183, 255],+ [203, 158, 255],+ [57, 197, 207],+ [217, 222, 227],+ [158, 167, 179],+ [255, 177, 175],+ [74, 225, 104],+ [247, 200, 67],+ [145, 203, 255],+ [219, 183, 255],+ [86, 212, 221],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "GitHub Light Colorblind",+ background: [255, 255, 255],+ foreground: [36, 41, 47],+ palette: [+ [36, 41, 47],+ [179, 89, 0],+ [5, 80, 174],+ [77, 45, 0],+ [9, 105, 218],+ [130, 80, 223],+ [27, 124, 131],+ [110, 119, 129],+ [87, 96, 106],+ [138, 70, 0],+ [9, 105, 218],+ [99, 60, 1],+ [33, 139, 255],+ [164, 117, 249],+ [49, 146, 170],+ [140, 149, 159],+ ],+ },+ TerminalTheme {+ name: "GitHub Light Default",+ background: [255, 255, 255],+ foreground: [31, 35, 40],+ palette: [+ [36, 41, 47],+ [207, 34, 46],+ [17, 99, 41],+ [77, 45, 0],+ [9, 105, 218],+ [130, 80, 223],+ [27, 124, 131],+ [110, 119, 129],+ [87, 96, 106],+ [164, 14, 38],+ [26, 127, 55],+ [99, 60, 1],+ [33, 139, 255],+ [164, 117, 249],+ [49, 146, 170],+ [140, 149, 159],+ ],+ },+ TerminalTheme {+ name: "GitHub Light High Contrast",+ background: [255, 255, 255],+ foreground: [14, 17, 22],+ palette: [+ [14, 17, 22],+ [160, 17, 31],+ [2, 76, 26],+ [63, 34, 0],+ [3, 73, 180],+ [98, 44, 188],+ [27, 124, 131],+ [102, 112, 123],+ [75, 83, 93],+ [134, 6, 29],+ [5, 93, 32],+ [78, 44, 0],+ [17, 104, 227],+ [132, 74, 231],+ [49, 146, 170],+ [136, 146, 157],+ ],+ },+ TerminalTheme {+ name: "GitLab Dark",+ background: [40, 38, 43],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [245, 127, 108],+ [82, 184, 122],+ [217, 149, 48],+ [127, 182, 237],+ [248, 138, 175],+ [50, 197, 210],+ [255, 255, 255],+ [102, 102, 102],+ [252, 181, 170],+ [145, 212, 168],+ [233, 190, 116],+ [73, 141, 209],+ [252, 172, 197],+ [94, 222, 227],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "GitLab Dark Grey",+ background: [34, 34, 34],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [245, 127, 108],+ [82, 184, 122],+ [217, 149, 48],+ [127, 182, 237],+ [248, 138, 175],+ [50, 197, 210],+ [255, 255, 255],+ [102, 102, 102],+ [252, 181, 170],+ [145, 212, 168],+ [233, 190, 116],+ [73, 141, 209],+ [252, 172, 197],+ [94, 222, 227],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "GitLab Light",+ background: [250, 250, 255],+ foreground: [48, 48, 48],+ palette: [+ [48, 48, 48],+ [163, 23, 0],+ [10, 127, 61],+ [175, 85, 29],+ [0, 108, 216],+ [88, 60, 172],+ [0, 121, 138],+ [48, 48, 48],+ [48, 48, 48],+ [163, 23, 0],+ [10, 127, 61],+ [175, 85, 29],+ [0, 108, 216],+ [88, 60, 172],+ [0, 121, 138],+ [48, 48, 48],+ ],+ },+ TerminalTheme {+ name: "Glacier",+ background: [12, 17, 21],+ foreground: [255, 255, 255],+ palette: [+ [46, 52, 60],+ [189, 15, 47],+ [53, 167, 112],+ [251, 148, 53],+ [31, 88, 114],+ [189, 37, 35],+ [119, 131, 151],+ [255, 255, 255],+ [64, 74, 85],+ [189, 15, 47],+ [73, 233, 152],+ [253, 223, 110],+ [42, 139, 193],+ [234, 71, 39],+ [160, 182, 211],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Grape",+ background: [23, 20, 35],+ foreground: [159, 159, 161],+ palette: [+ [45, 40, 63],+ [237, 34, 97],+ [31, 169, 27],+ [141, 220, 32],+ [72, 125, 244],+ [141, 53, 201],+ [59, 222, 237],+ [158, 158, 160],+ [89, 81, 106],+ [240, 114, 154],+ [83, 170, 94],+ [178, 220, 135],+ [169, 188, 236],+ [173, 129, 194],+ [157, 227, 235],+ [162, 136, 247],+ ],+ },+ TerminalTheme {+ name: "Grass",+ background: [19, 119, 61],+ foreground: [255, 240, 165],+ palette: [+ [0, 0, 0],+ [255, 89, 89],+ [0, 187, 0],+ [231, 176, 0],+ [0, 0, 163],+ [238, 89, 187],+ [0, 187, 187],+ [187, 187, 187],+ [149, 149, 149],+ [255, 89, 89],+ [0, 187, 0],+ [231, 176, 0],+ [0, 0, 187],+ [255, 85, 255],+ [85, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Grey Green",+ background: [0, 42, 26],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [254, 20, 20],+ [116, 255, 0],+ [241, 255, 1],+ [0, 222, 255],+ [255, 0, 240],+ [0, 255, 188],+ [255, 255, 255],+ [102, 102, 102],+ [255, 57, 57],+ [0, 255, 68],+ [255, 209, 0],+ [0, 175, 255],+ [255, 0, 138],+ [0, 255, 211],+ [245, 236, 236],+ ],+ },+ TerminalTheme {+ name: "Gruber Darker",+ background: [24, 24, 24],+ foreground: [228, 228, 228],+ palette: [+ [24, 24, 24],+ [255, 10, 54],+ [66, 220, 0],+ [255, 219, 0],+ [146, 167, 203],+ [160, 149, 203],+ [144, 170, 158],+ [228, 228, 228],+ [84, 73, 78],+ [255, 56, 81],+ [66, 220, 0],+ [255, 219, 0],+ [146, 167, 203],+ [175, 175, 218],+ [144, 170, 158],+ [245, 245, 245],+ ],+ },+ TerminalTheme {+ name: "Gruvbox Dark",+ background: [40, 40, 40],+ foreground: [235, 219, 178],+ palette: [+ [40, 40, 40],+ [204, 36, 29],+ [152, 151, 26],+ [215, 153, 33],+ [69, 133, 136],+ [177, 98, 134],+ [104, 157, 106],+ [168, 153, 132],+ [146, 131, 116],+ [251, 73, 52],+ [184, 187, 38],+ [250, 189, 47],+ [131, 165, 152],+ [211, 134, 155],+ [142, 192, 124],+ [235, 219, 178],+ ],+ },+ TerminalTheme {+ name: "Gruvbox Dark Hard",+ background: [29, 32, 33],+ foreground: [235, 219, 178],+ palette: [+ [29, 32, 33],+ [204, 36, 29],+ [152, 151, 26],+ [215, 153, 33],+ [69, 133, 136],+ [177, 98, 134],+ [104, 157, 106],+ [168, 153, 132],+ [146, 131, 116],+ [251, 73, 52],+ [184, 187, 38],+ [250, 189, 47],+ [131, 165, 152],+ [211, 134, 155],+ [142, 192, 124],+ [235, 219, 178],+ ],+ },+ TerminalTheme {+ name: "Gruvbox Light",+ background: [251, 241, 199],+ foreground: [60, 56, 54],+ palette: [+ [251, 241, 199],+ [204, 36, 29],+ [152, 151, 26],+ [215, 153, 33],+ [69, 133, 136],+ [177, 98, 134],+ [104, 157, 106],+ [124, 111, 100],+ [146, 131, 116],+ [157, 0, 6],+ [121, 116, 14],+ [181, 118, 20],+ [7, 102, 120],+ [143, 63, 113],+ [66, 123, 88],+ [60, 56, 54],+ ],+ },+ TerminalTheme {+ name: "Gruvbox Light Hard",+ background: [249, 245, 215],+ foreground: [60, 56, 54],+ palette: [+ [249, 245, 215],+ [204, 36, 29],+ [152, 151, 26],+ [215, 153, 33],+ [69, 133, 136],+ [177, 98, 134],+ [104, 157, 106],+ [124, 111, 100],+ [146, 131, 116],+ [157, 0, 6],+ [121, 116, 14],+ [181, 118, 20],+ [7, 102, 120],+ [143, 63, 113],+ [66, 123, 88],+ [60, 56, 54],+ ],+ },+ TerminalTheme {+ name: "Gruvbox Material",+ background: [29, 32, 33],+ foreground: [212, 190, 152],+ palette: [+ [20, 22, 23],+ [234, 105, 38],+ [193, 208, 65],+ [238, 207, 117],+ [109, 163, 236],+ [253, 155, 193],+ [254, 157, 110],+ [255, 255, 255],+ [76, 76, 76],+ [211, 87, 59],+ [193, 208, 65],+ [238, 207, 117],+ [44, 134, 255],+ [253, 155, 193],+ [146, 165, 223],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Gruvbox Material Dark",+ background: [40, 40, 40],+ foreground: [212, 190, 152],+ palette: [+ [40, 40, 40],+ [234, 105, 98],+ [169, 182, 101],+ [216, 166, 87],+ [125, 174, 163],+ [211, 134, 155],+ [137, 180, 130],+ [212, 190, 152],+ [124, 111, 100],+ [234, 105, 98],+ [169, 182, 101],+ [216, 166, 87],+ [125, 174, 163],+ [211, 134, 155],+ [137, 180, 130],+ [221, 199, 161],+ ],+ },+ TerminalTheme {+ name: "Gruvbox Material Light",+ background: [251, 241, 199],+ foreground: [101, 71, 53],+ palette: [+ [251, 241, 199],+ [193, 74, 74],+ [108, 120, 46],+ [180, 113, 9],+ [69, 112, 122],+ [148, 94, 128],+ [76, 122, 93],+ [101, 71, 53],+ [168, 153, 132],+ [193, 74, 74],+ [108, 120, 46],+ [180, 113, 9],+ [69, 112, 122],+ [148, 94, 128],+ [76, 122, 93],+ [79, 56, 41],+ ],+ },+ TerminalTheme {+ name: "Guezwhoz",+ background: [29, 29, 29],+ foreground: [217, 217, 217],+ palette: [+ [51, 51, 51],+ [232, 81, 129],+ [122, 214, 148],+ [183, 208, 116],+ [90, 160, 214],+ [154, 144, 224],+ [88, 214, 206],+ [217, 217, 217],+ [128, 128, 128],+ [232, 81, 129],+ [175, 215, 175],+ [209, 237, 133],+ [100, 178, 237],+ [163, 152, 237],+ [97, 237, 228],+ [237, 237, 237],+ ],+ },+ TerminalTheme {+ name: "HaX0R Blue",+ background: [1, 5, 21],+ foreground: [17, 183, 255],+ palette: [+ [1, 9, 33],+ [16, 182, 255],+ [16, 182, 255],+ [16, 182, 255],+ [16, 182, 255],+ [16, 182, 255],+ [16, 182, 255],+ [250, 250, 250],+ [72, 65, 87],+ [0, 179, 247],+ [0, 179, 247],+ [0, 179, 247],+ [0, 179, 247],+ [0, 179, 247],+ [0, 179, 247],+ [254, 254, 254],+ ],+ },+ TerminalTheme {+ name: "HaX0R Gr33N",+ background: [2, 15, 1],+ foreground: [22, 177, 14],+ palette: [+ [0, 31, 11],+ [21, 208, 13],+ [21, 208, 13],+ [21, 208, 13],+ [21, 208, 13],+ [21, 208, 13],+ [21, 208, 13],+ [250, 250, 250],+ [51, 72, 67],+ [25, 226, 14],+ [25, 226, 14],+ [25, 226, 14],+ [25, 226, 14],+ [25, 226, 14],+ [25, 226, 14],+ [254, 254, 254],+ ],+ },+ TerminalTheme {+ name: "HaX0R R3D",+ background: [32, 1, 1],+ foreground: [177, 14, 14],+ palette: [+ [31, 0, 0],+ [176, 13, 13],+ [176, 13, 13],+ [176, 13, 13],+ [176, 13, 13],+ [176, 13, 13],+ [176, 13, 13],+ [250, 250, 250],+ [85, 64, 64],+ [255, 17, 17],+ [255, 16, 16],+ [255, 16, 16],+ [255, 16, 16],+ [255, 16, 16],+ [255, 16, 16],+ [254, 254, 254],+ ],+ },+ TerminalTheme {+ name: "Hacktober",+ background: [20, 20, 20],+ foreground: [201, 201, 201],+ palette: [+ [25, 25, 24],+ [179, 69, 56],+ [88, 119, 68],+ [208, 137, 73],+ [32, 110, 197],+ [134, 70, 81],+ [172, 145, 102],+ [241, 238, 231],+ [70, 68, 68],+ [179, 51, 35],+ [66, 130, 74],+ [199, 90, 34],+ [83, 137, 197],+ [231, 149, 165],+ [235, 197, 135],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Hardcore",+ background: [18, 18, 18],+ foreground: [160, 160, 160],+ palette: [+ [27, 29, 30],+ [249, 38, 114],+ [166, 226, 46],+ [253, 151, 31],+ [102, 217, 239],+ [158, 111, 254],+ [94, 113, 117],+ [204, 204, 198],+ [80, 83, 84],+ [255, 102, 157],+ [190, 237, 95],+ [230, 219, 116],+ [102, 217, 239],+ [158, 111, 254],+ [163, 186, 191],+ [248, 248, 242],+ ],+ },+ TerminalTheme {+ name: "Harper",+ background: [1, 1, 1],+ foreground: [168, 164, 157],+ palette: [+ [1, 1, 1],+ [248, 182, 63],+ [127, 181, 225],+ [214, 218, 37],+ [72, 158, 72],+ [178, 150, 198],+ [245, 191, 215],+ [168, 164, 157],+ [114, 110, 106],+ [248, 182, 63],+ [127, 181, 225],+ [214, 218, 37],+ [72, 158, 72],+ [178, 150, 198],+ [245, 191, 215],+ [254, 251, 234],+ ],+ },+ TerminalTheme {+ name: "Havn Daggry",+ background: [248, 249, 251],+ foreground: [59, 74, 122],+ palette: [+ [31, 40, 66],+ [152, 82, 72],+ [87, 113, 89],+ [190, 107, 0],+ [58, 87, 125],+ [124, 92, 151],+ [146, 87, 128],+ [176, 181, 197],+ [31, 40, 66],+ [204, 74, 53],+ [113, 150, 121],+ [241, 165, 39],+ [96, 137, 192],+ [125, 115, 150],+ [170, 134, 157],+ [214, 219, 235],+ ],+ },+ TerminalTheme {+ name: "Havn Skumring",+ background: [17, 21, 34],+ foreground: [214, 219, 235],+ palette: [+ [37, 44, 71],+ [234, 86, 62],+ [110, 173, 123],+ [248, 179, 48],+ [89, 108, 247],+ [124, 113, 158],+ [213, 136, 193],+ [220, 224, 238],+ [56, 66, 92],+ [209, 114, 100],+ [140, 158, 143],+ [234, 197, 140],+ [81, 134, 203],+ [155, 124, 238],+ [209, 122, 182],+ [255, 246, 225],+ ],+ },+ TerminalTheme {+ name: "Heeler",+ background: [33, 31, 70],+ foreground: [253, 253, 253],+ palette: [+ [0, 0, 0],+ [228, 76, 46],+ [189, 209, 0],+ [244, 206, 101],+ [91, 165, 242],+ [255, 149, 194],+ [255, 151, 99],+ [255, 255, 255],+ [76, 76, 76],+ [228, 76, 46],+ [189, 209, 0],+ [244, 206, 101],+ [0, 136, 255],+ [255, 149, 194],+ [141, 166, 228],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Highway",+ background: [34, 34, 37],+ foreground: [237, 237, 237],+ palette: [+ [0, 0, 0],+ [208, 14, 24],+ [19, 128, 52],+ [255, 203, 62],+ [0, 107, 179],+ [120, 52, 130],+ [69, 82, 113],+ [237, 237, 237],+ [93, 80, 74],+ [240, 126, 24],+ [177, 209, 48],+ [255, 241, 32],+ [79, 194, 253],+ [222, 0, 113],+ [93, 80, 74],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Hipster Green",+ background: [16, 11, 5],+ foreground: [132, 193, 56],+ palette: [+ [0, 0, 0],+ [182, 33, 74],+ [0, 166, 0],+ [191, 191, 0],+ [36, 110, 178],+ [178, 0, 178],+ [0, 166, 178],+ [191, 191, 191],+ [102, 102, 102],+ [229, 0, 0],+ [134, 169, 62],+ [229, 229, 0],+ [0, 0, 255],+ [229, 0, 229],+ [0, 229, 229],+ [229, 229, 229],+ ],+ },+ TerminalTheme {+ name: "Hivacruz",+ background: [19, 38, 56],+ foreground: [237, 228, 228],+ palette: [+ [32, 39, 70],+ [201, 73, 34],+ [172, 151, 57],+ [192, 139, 48],+ [61, 143, 209],+ [102, 121, 204],+ [34, 162, 201],+ [151, 157, 180],+ [107, 115, 148],+ [199, 107, 41],+ [115, 173, 67],+ [94, 102, 135],+ [137, 142, 164],+ [223, 226, 241],+ [156, 99, 122],+ [245, 247, 255],+ ],+ },+ TerminalTheme {+ name: "Homebrew",+ background: [0, 0, 0],+ foreground: [0, 255, 0],+ palette: [+ [0, 0, 0],+ [153, 0, 0],+ [0, 166, 0],+ [153, 153, 0],+ [13, 13, 191],+ [178, 0, 178],+ [0, 166, 178],+ [191, 191, 191],+ [102, 102, 102],+ [229, 0, 0],+ [0, 217, 0],+ [229, 229, 0],+ [0, 0, 255],+ [229, 0, 229],+ [0, 229, 229],+ [229, 229, 229],+ ],+ },+ TerminalTheme {+ name: "Hopscotch",+ background: [50, 41, 49],+ foreground: [185, 181, 184],+ palette: [+ [50, 41, 49],+ [221, 70, 76],+ [143, 193, 62],+ [253, 204, 89],+ [18, 144, 191],+ [200, 94, 124],+ [20, 155, 147],+ [185, 181, 184],+ [121, 115, 121],+ [253, 139, 25],+ [92, 84, 92],+ [92, 84, 91],+ [152, 148, 152],+ [213, 211, 213],+ [179, 53, 8],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Hopscotch.256",+ background: [50, 41, 49],+ foreground: [185, 181, 184],+ palette: [+ [50, 41, 49],+ [221, 70, 76],+ [143, 193, 62],+ [253, 204, 89],+ [18, 144, 191],+ [200, 94, 124],+ [20, 155, 147],+ [185, 181, 184],+ [121, 115, 121],+ [221, 70, 76],+ [143, 193, 62],+ [253, 204, 89],+ [18, 144, 191],+ [200, 94, 124],+ [20, 155, 147],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Horizon",+ background: [28, 30, 38],+ foreground: [213, 216, 218],+ palette: [+ [0, 0, 0],+ [233, 86, 120],+ [41, 211, 152],+ [250, 183, 149],+ [38, 187, 217],+ [238, 100, 172],+ [89, 225, 227],+ [229, 229, 229],+ [102, 102, 102],+ [236, 106, 136],+ [63, 218, 164],+ [251, 195, 167],+ [63, 196, 222],+ [240, 117, 181],+ [107, 228, 230],+ [229, 229, 229],+ ],+ },+ TerminalTheme {+ name: "Horizon Bright",+ background: [253, 240, 237],+ foreground: [22, 22, 29],+ palette: [+ [22, 22, 29],+ [252, 71, 119],+ [0, 202, 134],+ [242, 166, 130],+ [0, 190, 221],+ [255, 88, 177],+ [0, 205, 203],+ [191, 175, 172],+ [26, 28, 36],+ [254, 95, 135],+ [0, 209, 147],+ [229, 166, 136],+ [0, 201, 226],+ [255, 108, 186],+ [0, 195, 194],+ [255, 242, 239],+ ],+ },+ TerminalTheme {+ name: "Hot Dog Stand",+ background: [234, 51, 35],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [255, 255, 84],+ [255, 255, 84],+ [255, 255, 84],+ [0, 0, 0],+ [255, 255, 84],+ [255, 255, 255],+ [198, 198, 198],+ [0, 0, 0],+ [255, 255, 84],+ [255, 255, 84],+ [255, 255, 84],+ [0, 0, 0],+ [255, 255, 84],+ [255, 255, 255],+ [198, 198, 198],+ ],+ },+ TerminalTheme {+ name: "Hot Dog Stand (Mustard)",+ background: [255, 255, 84],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [234, 51, 35],+ [234, 51, 35],+ [234, 51, 35],+ [0, 0, 0],+ [234, 51, 35],+ [0, 0, 0],+ [185, 185, 185],+ [0, 0, 0],+ [234, 51, 35],+ [234, 51, 35],+ [234, 51, 35],+ [0, 0, 0],+ [234, 51, 35],+ [0, 0, 0],+ [198, 198, 198],+ ],+ },+ TerminalTheme {+ name: "Hurtado",+ background: [0, 0, 0],+ foreground: [219, 219, 219],+ palette: [+ [87, 87, 87],+ [255, 27, 0],+ [165, 224, 85],+ [251, 231, 74],+ [73, 100, 135],+ [253, 95, 241],+ [134, 233, 254],+ [203, 204, 203],+ [64, 64, 64],+ [213, 29, 0],+ [165, 223, 85],+ [251, 232, 74],+ [137, 190, 255],+ [192, 1, 193],+ [134, 234, 254],+ [219, 219, 219],+ ],+ },+ TerminalTheme {+ name: "Hybrid",+ background: [22, 23, 25],+ foreground: [183, 188, 186],+ palette: [+ [42, 46, 51],+ [184, 77, 81],+ [179, 191, 90],+ [228, 181, 94],+ [110, 144, 176],+ [161, 126, 172],+ [127, 191, 180],+ [181, 185, 182],+ [67, 69, 72],+ [141, 46, 50],+ [121, 132, 49],+ [229, 138, 80],+ [75, 107, 136],+ [110, 80, 121],+ [77, 123, 116],+ [90, 98, 106],+ ],+ },+ TerminalTheme {+ name: "IBM 5153 CGA",+ background: [20, 20, 20],+ foreground: [206, 206, 206],+ palette: [+ [20, 20, 20],+ [208, 51, 51],+ [27, 208, 27],+ [208, 140, 27],+ [27, 27, 208],+ [208, 27, 208],+ [27, 208, 208],+ [206, 206, 206],+ [78, 78, 78],+ [220, 78, 78],+ [78, 220, 78],+ [243, 243, 78],+ [78, 78, 220],+ [243, 78, 243],+ [78, 243, 243],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "IBM 5153 CGA (Black)",+ background: [0, 0, 0],+ foreground: [196, 196, 196],+ palette: [+ [0, 0, 0],+ [196, 0, 0],+ [0, 196, 0],+ [196, 126, 0],+ [0, 0, 196],+ [196, 0, 196],+ [0, 196, 196],+ [196, 196, 196],+ [78, 78, 78],+ [220, 78, 78],+ [78, 220, 78],+ [243, 243, 78],+ [78, 78, 220],+ [243, 78, 243],+ [78, 243, 243],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "IC Green PPL",+ background: [44, 44, 44],+ foreground: [224, 241, 220],+ palette: [+ [1, 68, 1],+ [255, 39, 54],+ [65, 166, 56],+ [118, 168, 49],+ [46, 195, 185],+ [80, 160, 150],+ [60, 160, 120],+ [230, 254, 242],+ [16, 105, 16],+ [180, 250, 92],+ [174, 251, 134],+ [218, 250, 135],+ [46, 250, 235],+ [80, 250, 250],+ [60, 250, 200],+ [224, 241, 220],+ ],+ },+ TerminalTheme {+ name: "IC Orange PPL",+ background: [38, 38, 38],+ foreground: [255, 203, 131],+ palette: [+ [0, 0, 0],+ [193, 57, 0],+ [164, 169, 0],+ [202, 175, 0],+ [189, 109, 0],+ [252, 94, 0],+ [247, 149, 0],+ [255, 200, 138],+ [106, 79, 42],+ [255, 140, 104],+ [246, 255, 64],+ [255, 227, 110],+ [255, 190, 85],+ [252, 135, 79],+ [198, 151, 82],+ [250, 250, 255],+ ],+ },+ TerminalTheme {+ name: "IR Black",+ background: [0, 0, 0],+ foreground: [241, 241, 241],+ palette: [+ [79, 79, 79],+ [250, 108, 96],+ [168, 255, 96],+ [255, 254, 183],+ [150, 202, 254],+ [250, 115, 253],+ [198, 197, 254],+ [239, 237, 239],+ [123, 123, 123],+ [252, 182, 176],+ [207, 255, 171],+ [255, 255, 204],+ [181, 220, 255],+ [251, 156, 254],+ [224, 224, 254],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "IRIX Console",+ background: [12, 12, 12],+ foreground: [242, 242, 242],+ palette: [+ [26, 25, 25],+ [212, 36, 38],+ [55, 163, 39],+ [194, 157, 40],+ [7, 57, 226],+ [145, 31, 156],+ [68, 151, 223],+ [204, 204, 204],+ [118, 118, 118],+ [243, 79, 89],+ [69, 199, 49],+ [249, 242, 167],+ [64, 121, 255],+ [195, 27, 162],+ [110, 215, 215],+ [242, 242, 242],+ ],+ },+ TerminalTheme {+ name: "IRIX Terminal",+ background: [0, 0, 67],+ foreground: [242, 242, 242],+ palette: [+ [26, 25, 25],+ [255, 43, 30],+ [87, 255, 61],+ [255, 255, 68],+ [0, 4, 255],+ [255, 44, 255],+ [86, 255, 255],+ [255, 255, 255],+ [255, 255, 68],+ [255, 255, 68],+ [255, 255, 68],+ [255, 252, 114],+ [255, 255, 68],+ [255, 255, 68],+ [255, 255, 68],+ [255, 255, 68],+ ],+ },+ TerminalTheme {+ name: "Iceberg Dark",+ background: [22, 24, 33],+ foreground: [198, 200, 209],+ palette: [+ [30, 33, 50],+ [226, 120, 120],+ [180, 190, 130],+ [226, 164, 120],+ [132, 160, 198],+ [160, 147, 199],+ [137, 184, 194],+ [198, 200, 209],+ [107, 112, 137],+ [233, 137, 137],+ [192, 202, 142],+ [233, 177, 137],+ [145, 172, 209],+ [173, 160, 211],+ [149, 196, 206],+ [210, 212, 222],+ ],+ },+ TerminalTheme {+ name: "Iceberg Light",+ background: [232, 233, 236],+ foreground: [51, 55, 76],+ palette: [+ [220, 223, 231],+ [204, 81, 122],+ [102, 142, 61],+ [197, 115, 57],+ [45, 83, 158],+ [119, 89, 180],+ [63, 131, 166],+ [51, 55, 76],+ [131, 137, 163],+ [204, 55, 104],+ [89, 128, 48],+ [182, 102, 45],+ [34, 71, 142],+ [104, 69, 173],+ [50, 118, 152],+ [38, 42, 63],+ ],+ },+ TerminalTheme {+ name: "Idea",+ background: [32, 32, 32],+ foreground: [173, 173, 173],+ palette: [+ [173, 173, 173],+ [252, 82, 86],+ [152, 182, 28],+ [204, 180, 68],+ [67, 126, 231],+ [157, 116, 176],+ [36, 136, 135],+ [75, 75, 75],+ [255, 255, 255],+ [252, 112, 114],+ [152, 182, 28],+ [255, 255, 11],+ [108, 156, 237],+ [252, 126, 255],+ [36, 136, 135],+ [24, 24, 24],+ ],+ },+ TerminalTheme {+ name: "Idle Toes",+ background: [50, 50, 50],+ foreground: [255, 255, 255],+ palette: [+ [50, 50, 50],+ [210, 82, 82],+ [127, 225, 115],+ [255, 198, 109],+ [64, 153, 255],+ [246, 128, 255],+ [190, 214, 255],+ [238, 238, 236],+ [96, 96, 96],+ [240, 112, 112],+ [157, 255, 145],+ [255, 228, 139],+ [94, 183, 247],+ [255, 157, 255],+ [220, 244, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Jackie Brown",+ background: [44, 29, 22],+ foreground: [255, 204, 47],+ palette: [+ [44, 29, 22],+ [239, 87, 52],+ [43, 175, 43],+ [190, 191, 0],+ [36, 110, 178],+ [208, 94, 193],+ [0, 172, 238],+ [191, 191, 191],+ [102, 102, 102],+ [229, 0, 0],+ [134, 169, 62],+ [229, 229, 0],+ [0, 0, 255],+ [229, 0, 229],+ [0, 229, 229],+ [229, 229, 229],+ ],+ },+ TerminalTheme {+ name: "Japanesque",+ background: [30, 30, 30],+ foreground: [247, 246, 236],+ palette: [+ [52, 57, 53],+ [207, 63, 97],+ [123, 183, 91],+ [233, 179, 42],+ [76, 154, 212],+ [165, 127, 196],+ [56, 154, 173],+ [250, 250, 246],+ [89, 91, 89],+ [209, 143, 166],+ [118, 127, 44],+ [120, 89, 47],+ [19, 89, 121],+ [96, 66, 145],+ [118, 187, 202],+ [178, 181, 174],+ ],+ },+ TerminalTheme {+ name: "Jellybeans",+ background: [18, 18, 18],+ foreground: [222, 222, 222],+ palette: [+ [146, 146, 146],+ [226, 115, 115],+ [148, 185, 121],+ [255, 186, 123],+ [151, 190, 220],+ [225, 192, 250],+ [0, 152, 142],+ [222, 222, 222],+ [189, 189, 189],+ [255, 161, 161],+ [189, 222, 171],+ [255, 220, 160],+ [177, 216, 246],+ [251, 218, 255],+ [26, 178, 168],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "JetBrains Darcula",+ background: [32, 32, 32],+ foreground: [173, 173, 173],+ palette: [+ [0, 0, 0],+ [250, 83, 85],+ [18, 110, 0],+ [194, 195, 0],+ [69, 129, 235],+ [250, 84, 255],+ [51, 194, 193],+ [173, 173, 173],+ [85, 85, 85],+ [251, 113, 114],+ [103, 255, 79],+ [255, 255, 0],+ [109, 157, 241],+ [251, 130, 255],+ [96, 211, 209],+ [238, 238, 238],+ ],+ },+ TerminalTheme {+ name: "Jubi",+ background: [38, 43, 51],+ foreground: [195, 211, 222],+ palette: [+ [59, 55, 80],+ [207, 123, 152],+ [144, 169, 75],+ [110, 191, 192],+ [87, 110, 166],+ [188, 79, 104],+ [117, 167, 210],+ [195, 211, 222],+ [168, 116, 206],+ [222, 144, 171],+ [188, 221, 97],+ [135, 233, 234],+ [140, 159, 205],+ [225, 108, 135],+ [183, 201, 239],+ [213, 229, 241],+ ],+ },+ TerminalTheme {+ name: "Kanagawa Dragon",+ background: [24, 22, 22],+ foreground: [197, 201, 197],+ palette: [+ [13, 12, 12],+ [196, 116, 110],+ [138, 154, 123],+ [196, 178, 138],+ [139, 164, 176],+ [162, 146, 163],+ [142, 164, 162],+ [200, 192, 147],+ [166, 166, 156],+ [228, 104, 118],+ [135, 169, 135],+ [230, 195, 132],+ [127, 180, 202],+ [147, 138, 169],+ [122, 168, 159],+ [197, 201, 197],+ ],+ },+ TerminalTheme {+ name: "Kanagawa Lotus",+ background: [242, 236, 188],+ foreground: [84, 84, 100],+ palette: [+ [31, 31, 40],+ [200, 64, 83],+ [111, 137, 78],+ [119, 113, 63],+ [77, 105, 155],+ [179, 91, 121],+ [89, 123, 117],+ [84, 84, 100],+ [138, 137, 128],+ [215, 71, 75],+ [110, 145, 95],+ [131, 111, 74],+ [102, 147, 191],+ [98, 76, 131],+ [94, 133, 122],+ [67, 67, 108],+ ],+ },+ TerminalTheme {+ name: "Kanagawa Wave",+ background: [31, 31, 40],+ foreground: [220, 215, 186],+ palette: [+ [9, 6, 24],+ [195, 64, 67],+ [118, 148, 106],+ [192, 163, 110],+ [126, 156, 216],+ [149, 127, 184],+ [106, 149, 137],+ [200, 192, 147],+ [114, 113, 105],+ [232, 36, 36],+ [152, 187, 108],+ [230, 195, 132],+ [127, 180, 202],+ [147, 138, 169],+ [122, 168, 159],+ [220, 215, 186],+ ],+ },+ TerminalTheme {+ name: "Kanagawabones",+ background: [31, 31, 40],+ foreground: [221, 216, 187],+ palette: [+ [31, 31, 40],+ [228, 106, 120],+ [152, 188, 109],+ [229, 194, 131],+ [126, 179, 201],+ [149, 127, 184],+ [126, 179, 201],+ [221, 216, 187],+ [73, 73, 94],+ [236, 129, 140],+ [158, 201, 103],+ [241, 201, 130],+ [123, 194, 223],+ [169, 143, 210],+ [123, 194, 223],+ [168, 164, 141],+ ],+ },+ TerminalTheme {+ name: "Kanso Ink",+ background: [20, 23, 29],+ foreground: [197, 201, 199],+ palette: [+ [20, 23, 29],+ [196, 116, 110],+ [138, 154, 123],+ [196, 178, 138],+ [139, 164, 176],+ [162, 146, 163],+ [142, 164, 162],+ [200, 192, 147],+ [164, 167, 164],+ [228, 104, 118],+ [135, 169, 135],+ [230, 195, 132],+ [127, 180, 202],+ [147, 138, 169],+ [122, 168, 159],+ [197, 201, 199],+ ],+ },+ TerminalTheme {+ name: "Kanso Mist",+ background: [34, 38, 45],+ foreground: [197, 201, 199],+ palette: [+ [34, 38, 45],+ [196, 116, 110],+ [138, 154, 123],+ [196, 178, 138],+ [139, 164, 176],+ [162, 146, 163],+ [142, 164, 162],+ [164, 167, 164],+ [92, 96, 102],+ [228, 104, 118],+ [135, 169, 135],+ [230, 195, 132],+ [127, 180, 202],+ [147, 138, 169],+ [122, 168, 159],+ [197, 201, 199],+ ],+ },+ TerminalTheme {+ name: "Kanso Pearl",+ background: [242, 241, 239],+ foreground: [34, 38, 45],+ palette: [+ [34, 38, 45],+ [200, 64, 83],+ [111, 137, 78],+ [119, 113, 63],+ [77, 105, 155],+ [179, 91, 121],+ [89, 123, 117],+ [84, 84, 100],+ [109, 111, 110],+ [215, 71, 75],+ [110, 145, 95],+ [131, 111, 74],+ [102, 147, 191],+ [98, 76, 131],+ [94, 133, 122],+ [67, 67, 108],+ ],+ },+ TerminalTheme {+ name: "Kanso Zen",+ background: [9, 14, 19],+ foreground: [197, 201, 199],+ palette: [+ [13, 12, 12],+ [196, 116, 110],+ [138, 154, 123],+ [196, 178, 138],+ [139, 164, 176],+ [162, 146, 163],+ [142, 164, 162],+ [200, 192, 147],+ [164, 167, 164],+ [228, 104, 118],+ [135, 169, 135],+ [230, 195, 132],+ [127, 180, 202],+ [147, 138, 169],+ [122, 168, 159],+ [197, 201, 199],+ ],+ },+ TerminalTheme {+ name: "Kibble",+ background: [14, 16, 10],+ foreground: [247, 247, 247],+ palette: [+ [77, 77, 77],+ [199, 0, 49],+ [41, 207, 19],+ [216, 227, 14],+ [52, 73, 209],+ [132, 0, 255],+ [7, 152, 171],+ [226, 209, 227],+ [90, 90, 90],+ [240, 21, 120],+ [108, 224, 92],+ [243, 247, 158],+ [151, 164, 247],+ [196, 149, 240],+ [104, 242, 224],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Kitty Default",+ background: [0, 0, 0],+ foreground: [221, 221, 221],+ palette: [+ [0, 0, 0],+ [204, 4, 3],+ [25, 203, 0],+ [206, 203, 0],+ [13, 115, 204],+ [203, 30, 209],+ [13, 205, 205],+ [221, 221, 221],+ [118, 118, 118],+ [242, 32, 31],+ [35, 253, 0],+ [255, 253, 0],+ [26, 143, 255],+ [253, 40, 255],+ [20, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Kitty Low Contrast",+ background: [51, 51, 51],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [204, 4, 3],+ [25, 203, 0],+ [206, 203, 0],+ [13, 115, 204],+ [203, 30, 209],+ [13, 205, 205],+ [221, 221, 221],+ [118, 118, 118],+ [242, 32, 31],+ [35, 253, 0],+ [255, 253, 0],+ [26, 143, 255],+ [253, 40, 255],+ [20, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Kolorit",+ background: [29, 26, 30],+ foreground: [239, 236, 236],+ palette: [+ [29, 26, 30],+ [255, 91, 130],+ [71, 215, 161],+ [232, 229, 98],+ [93, 180, 238],+ [218, 108, 218],+ [87, 233, 235],+ [237, 237, 237],+ [80, 77, 81],+ [255, 91, 130],+ [71, 215, 161],+ [232, 229, 98],+ [93, 180, 238],+ [218, 108, 218],+ [87, 233, 235],+ [237, 237, 237],+ ],+ },+ TerminalTheme {+ name: "Konsolas",+ background: [6, 6, 6],+ foreground: [200, 193, 193],+ palette: [+ [0, 0, 0],+ [170, 23, 23],+ [24, 178, 24],+ [235, 174, 31],+ [35, 35, 165],+ [173, 30, 220],+ [66, 176, 200],+ [200, 193, 193],+ [123, 113, 110],+ [255, 65, 65],+ [95, 255, 95],+ [255, 255, 85],+ [75, 75, 255],+ [255, 84, 255],+ [105, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Kurokula",+ background: [20, 21, 21],+ foreground: [224, 207, 194],+ palette: [+ [51, 51, 51],+ [195, 90, 82],+ [120, 179, 169],+ [225, 185, 23],+ [92, 145, 221],+ [139, 121, 166],+ [134, 114, 104],+ [224, 207, 194],+ [81, 81, 81],+ [255, 195, 76],+ [175, 255, 165],+ [255, 247, 0],+ [144, 219, 255],+ [173, 147, 255],+ [255, 205, 182],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Lab Fox",+ background: [46, 46, 46],+ foreground: [255, 255, 255],+ palette: [+ [46, 46, 46],+ [252, 109, 38],+ [62, 179, 131],+ [252, 161, 33],+ [219, 59, 33],+ [107, 64, 168],+ [110, 73, 203],+ [255, 255, 255],+ [83, 83, 83],+ [255, 101, 23],+ [83, 234, 168],+ [252, 160, 19],+ [219, 80, 31],+ [106, 54, 182],+ [125, 83, 231],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Laser",+ background: [3, 13, 24],+ foreground: [241, 6, 227],+ palette: [+ [98, 98, 98],+ [255, 131, 115],+ [180, 251, 115],+ [9, 180, 189],+ [254, 211, 0],+ [255, 144, 254],+ [209, 209, 254],+ [241, 241, 241],+ [143, 143, 143],+ [255, 196, 190],+ [214, 252, 186],+ [255, 254, 213],+ [249, 40, 131],+ [255, 178, 254],+ [230, 231, 254],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Later This Evening",+ background: [34, 34, 34],+ foreground: [149, 149, 149],+ palette: [+ [43, 43, 43],+ [212, 90, 96],+ [175, 186, 103],+ [229, 210, 137],+ [160, 186, 214],+ [192, 146, 214],+ [145, 191, 183],+ [73, 74, 74],+ [82, 84, 84],+ [211, 35, 47],+ [170, 187, 57],+ [229, 190, 57],+ [102, 153, 214],+ [171, 83, 214],+ [95, 192, 174],+ [193, 194, 194],+ ],+ },+ TerminalTheme {+ name: "Lavandula",+ background: [5, 0, 20],+ foreground: [115, 110, 125],+ palette: [+ [35, 0, 70],+ [125, 22, 37],+ [51, 126, 111],+ [127, 111, 73],+ [79, 74, 127],+ [90, 63, 127],+ [88, 119, 127],+ [115, 110, 125],+ [68, 58, 83],+ [224, 81, 103],+ [82, 224, 196],+ [224, 195, 134],+ [142, 135, 224],+ [167, 118, 224],+ [154, 212, 224],+ [140, 145, 250],+ ],+ },+ TerminalTheme {+ name: "Light Owl",+ background: [251, 251, 251],+ foreground: [64, 63, 83],+ palette: [+ [64, 63, 83],+ [222, 61, 59],+ [8, 145, 106],+ [224, 175, 2],+ [40, 142, 215],+ [214, 67, 138],+ [42, 162, 152],+ [189, 189, 189],+ [152, 159, 177],+ [222, 61, 59],+ [8, 145, 106],+ [218, 170, 1],+ [40, 142, 215],+ [214, 67, 138],+ [42, 162, 152],+ [240, 240, 240],+ ],+ },+ TerminalTheme {+ name: "Liquid Carbon",+ background: [48, 48, 48],+ foreground: [175, 194, 194],+ palette: [+ [0, 0, 0],+ [255, 48, 48],+ [85, 154, 112],+ [204, 172, 0],+ [0, 153, 204],+ [204, 105, 200],+ [122, 196, 204],+ [188, 204, 204],+ [89, 89, 89],+ [255, 48, 48],+ [85, 154, 112],+ [204, 172, 0],+ [0, 153, 204],+ [204, 105, 200],+ [122, 196, 204],+ [188, 204, 204],+ ],+ },+ TerminalTheme {+ name: "Liquid Carbon Transparent",+ background: [0, 0, 0],+ foreground: [175, 194, 194],+ palette: [+ [0, 0, 0],+ [255, 48, 48],+ [85, 154, 112],+ [204, 172, 0],+ [0, 153, 204],+ [204, 105, 200],+ [122, 196, 204],+ [188, 204, 204],+ [64, 64, 64],+ [255, 48, 48],+ [85, 154, 112],+ [204, 172, 0],+ [0, 153, 204],+ [204, 105, 200],+ [122, 196, 204],+ [188, 204, 204],+ ],+ },+ TerminalTheme {+ name: "Lovelace",+ background: [29, 31, 40],+ foreground: [253, 253, 253],+ palette: [+ [40, 42, 54],+ [243, 127, 151],+ [90, 222, 205],+ [242, 162, 114],+ [136, 151, 244],+ [197, 116, 221],+ [121, 230, 243],+ [253, 253, 253],+ [78, 81, 101],+ [255, 73, 113],+ [24, 227, 200],+ [255, 128, 55],+ [85, 111, 255],+ [176, 67, 209],+ [63, 220, 238],+ [190, 190, 193],+ ],+ },+ TerminalTheme {+ name: "Man Page",+ background: [254, 244, 156],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [204, 0, 0],+ [0, 166, 0],+ [153, 153, 0],+ [0, 0, 178],+ [178, 0, 178],+ [0, 166, 178],+ [178, 178, 178],+ [102, 102, 102],+ [229, 0, 0],+ [0, 204, 0],+ [191, 191, 0],+ [0, 0, 255],+ [229, 0, 229],+ [0, 203, 203],+ [229, 229, 229],+ ],+ },+ TerminalTheme {+ name: "Mariana",+ background: [52, 61, 70],+ foreground: [216, 222, 233],+ palette: [+ [0, 0, 0],+ [236, 95, 102],+ [153, 199, 148],+ [249, 174, 88],+ [102, 153, 204],+ [198, 149, 198],+ [95, 180, 180],+ [247, 247, 247],+ [102, 102, 102],+ [249, 123, 88],+ [172, 209, 168],+ [250, 199, 97],+ [133, 173, 214],+ [216, 182, 216],+ [130, 196, 196],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Material",+ background: [234, 234, 234],+ foreground: [35, 35, 34],+ palette: [+ [33, 33, 33],+ [183, 20, 31],+ [69, 123, 36],+ [246, 152, 30],+ [19, 78, 178],+ [86, 0, 136],+ [14, 113, 124],+ [175, 175, 175],+ [66, 66, 66],+ [232, 59, 63],+ [122, 186, 58],+ [191, 170, 0],+ [84, 164, 243],+ [170, 77, 188],+ [38, 187, 209],+ [217, 217, 217],+ ],+ },+ TerminalTheme {+ name: "Material Dark",+ background: [35, 35, 34],+ foreground: [229, 229, 229],+ palette: [+ [33, 33, 33],+ [183, 20, 31],+ [69, 123, 36],+ [246, 152, 30],+ [19, 78, 178],+ [112, 26, 162],+ [14, 113, 124],+ [239, 239, 239],+ [79, 79, 79],+ [232, 59, 63],+ [122, 186, 58],+ [255, 234, 46],+ [84, 164, 243],+ [170, 77, 188],+ [38, 187, 209],+ [217, 217, 217],+ ],+ },+ TerminalTheme {+ name: "Material Darker",+ background: [33, 33, 33],+ foreground: [238, 255, 255],+ palette: [+ [0, 0, 0],+ [255, 83, 112],+ [195, 232, 141],+ [255, 203, 107],+ [130, 170, 255],+ [199, 146, 234],+ [137, 221, 255],+ [255, 255, 255],+ [84, 84, 84],+ [255, 83, 112],+ [195, 232, 141],+ [255, 203, 107],+ [130, 170, 255],+ [199, 146, 234],+ [137, 221, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Material Design Colors",+ background: [29, 38, 42],+ foreground: [231, 235, 237],+ palette: [+ [67, 91, 103],+ [252, 56, 65],+ [92, 241, 158],+ [254, 208, 50],+ [55, 182, 255],+ [252, 34, 110],+ [89, 255, 209],+ [255, 255, 255],+ [161, 176, 184],+ [252, 116, 109],+ [173, 247, 190],+ [254, 225, 108],+ [112, 207, 255],+ [252, 102, 155],+ [154, 255, 230],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Material Ocean",+ background: [15, 17, 26],+ foreground: [143, 147, 162],+ palette: [+ [84, 110, 122],+ [255, 83, 112],+ [195, 232, 141],+ [255, 203, 107],+ [130, 170, 255],+ [199, 146, 234],+ [137, 221, 255],+ [255, 255, 255],+ [84, 110, 122],+ [255, 83, 112],+ [195, 232, 141],+ [255, 203, 107],+ [130, 170, 255],+ [199, 146, 234],+ [137, 221, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Mathias",+ background: [0, 0, 0],+ foreground: [187, 187, 187],+ palette: [+ [0, 0, 0],+ [229, 34, 34],+ [166, 227, 45],+ [252, 149, 30],+ [196, 141, 255],+ [250, 37, 115],+ [103, 217, 240],+ [242, 242, 242],+ [85, 85, 85],+ [255, 85, 85],+ [85, 255, 85],+ [255, 255, 85],+ [85, 85, 255],+ [255, 85, 255],+ [85, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Matrix",+ background: [15, 25, 28],+ foreground: [66, 102, 68],+ palette: [+ [15, 25, 28],+ [35, 117, 90],+ [130, 217, 103],+ [255, 215, 0],+ [63, 82, 66],+ [64, 153, 49],+ [80, 180, 90],+ [80, 115, 80],+ [104, 128, 96],+ [47, 192, 121],+ [144, 215, 98],+ [250, 255, 0],+ [79, 126, 126],+ [17, 255, 37],+ [193, 255, 138],+ [103, 140, 97],+ ],+ },+ TerminalTheme {+ name: "Matte Black",+ background: [18, 18, 18],+ foreground: [190, 190, 190],+ palette: [+ [51, 51, 51],+ [211, 95, 95],+ [255, 193, 7],+ [185, 28, 28],+ [230, 142, 13],+ [211, 95, 95],+ [190, 190, 190],+ [190, 190, 190],+ [138, 138, 141],+ [137, 28, 28],+ [255, 193, 7],+ [185, 10, 10],+ [245, 158, 11],+ [185, 28, 28],+ [234, 234, 234],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Medallion",+ background: [29, 25, 8],+ foreground: [202, 194, 150],+ palette: [+ [0, 0, 0],+ [182, 76, 0],+ [124, 139, 22],+ [211, 189, 38],+ [97, 107, 176],+ [140, 90, 144],+ [145, 108, 37],+ [202, 194, 154],+ [94, 82, 25],+ [255, 145, 73],+ [178, 202, 59],+ [255, 229, 74],+ [172, 184, 255],+ [255, 160, 255],+ [255, 188, 81],+ [254, 214, 152],+ ],+ },+ TerminalTheme {+ name: "Melange Dark",+ background: [41, 37, 34],+ foreground: [236, 225, 215],+ palette: [+ [52, 48, 44],+ [189, 129, 131],+ [120, 153, 122],+ [228, 155, 93],+ [127, 145, 178],+ [179, 128, 176],+ [123, 150, 149],+ [193, 167, 142],+ [134, 116, 98],+ [212, 119, 102],+ [133, 182, 149],+ [235, 192, 109],+ [163, 169, 206],+ [207, 155, 194],+ [137, 179, 182],+ [236, 225, 215],+ ],+ },+ TerminalTheme {+ name: "Melange Light",+ background: [241, 241, 241],+ foreground: [84, 67, 58],+ palette: [+ [233, 225, 219],+ [199, 123, 139],+ [110, 155, 114],+ [188, 92, 0],+ [120, 146, 189],+ [190, 121, 187],+ [115, 151, 151],+ [125, 102, 88],+ [169, 138, 120],+ [191, 0, 33],+ [58, 104, 74],+ [160, 109, 0],+ [70, 90, 164],+ [144, 65, 128],+ [61, 101, 104],+ [84, 67, 58],+ ],+ },+ TerminalTheme {+ name: "Mellifluous",+ background: [26, 26, 26],+ foreground: [218, 218, 218],+ palette: [+ [26, 26, 26],+ [210, 147, 147],+ [179, 179, 147],+ [203, 170, 137],+ [168, 161, 190],+ [179, 159, 176],+ [192, 175, 140],+ [218, 218, 218],+ [91, 91, 91],+ [201, 89, 84],+ [130, 128, 64],+ [166, 121, 76],+ [90, 101, 153],+ [156, 105, 149],+ [116, 163, 158],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Mellow",+ background: [22, 22, 23],+ foreground: [201, 199, 205],+ palette: [+ [39, 39, 42],+ [245, 161, 145],+ [144, 185, 159],+ [230, 185, 157],+ [172, 161, 207],+ [226, 158, 202],+ [234, 131, 165],+ [193, 192, 212],+ [66, 66, 70],+ [255, 174, 159],+ [157, 198, 172],+ [240, 197, 169],+ [185, 174, 218],+ [236, 170, 214],+ [245, 145, 178],+ [202, 201, 221],+ ],+ },+ TerminalTheme {+ name: "Miasma",+ background: [34, 34, 34],+ foreground: [194, 194, 176],+ palette: [+ [0, 0, 0],+ [104, 87, 66],+ [95, 135, 95],+ [179, 109, 67],+ [120, 130, 75],+ [187, 119, 68],+ [201, 165, 84],+ [215, 196, 131],+ [102, 102, 102],+ [104, 87, 66],+ [95, 135, 95],+ [179, 109, 67],+ [120, 130, 75],+ [187, 119, 68],+ [201, 165, 84],+ [215, 196, 131],+ ],+ },+ TerminalTheme {+ name: "Midnight In Mojave",+ background: [30, 30, 30],+ foreground: [255, 255, 255],+ palette: [+ [30, 30, 30],+ [255, 69, 58],+ [50, 215, 75],+ [255, 214, 10],+ [10, 132, 255],+ [191, 90, 242],+ [90, 200, 250],+ [255, 255, 255],+ [81, 81, 81],+ [255, 69, 58],+ [50, 215, 75],+ [255, 214, 10],+ [10, 132, 255],+ [191, 90, 242],+ [90, 200, 250],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Mirage",+ background: [27, 39, 56],+ foreground: [166, 178, 192],+ palette: [+ [1, 22, 39],+ [255, 153, 153],+ [133, 204, 149],+ [255, 215, 0],+ [127, 181, 255],+ [221, 179, 255],+ [33, 199, 168],+ [255, 255, 255],+ [87, 86, 86],+ [255, 153, 153],+ [133, 204, 149],+ [255, 215, 0],+ [127, 181, 255],+ [221, 179, 255],+ [133, 204, 149],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Misterioso",+ background: [45, 55, 67],+ foreground: [225, 225, 224],+ palette: [+ [0, 0, 0],+ [255, 66, 66],+ [116, 175, 104],+ [255, 173, 41],+ [51, 143, 134],+ [148, 20, 230],+ [35, 215, 215],+ [225, 225, 224],+ [98, 98, 98],+ [255, 50, 66],+ [116, 205, 104],+ [255, 185, 41],+ [35, 215, 215],+ [255, 55, 255],+ [0, 237, 225],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Modus Operandi",+ background: [255, 255, 255],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [166, 0, 0],+ [0, 104, 0],+ [111, 85, 0],+ [0, 49, 169],+ [114, 16, 69],+ [0, 94, 139],+ [166, 166, 166],+ [89, 89, 89],+ [151, 37, 0],+ [0, 102, 63],+ [136, 73, 0],+ [53, 72, 207],+ [83, 26, 182],+ [0, 95, 95],+ [89, 89, 89],+ ],+ },+ TerminalTheme {+ name: "Modus Operandi Tinted",+ background: [251, 247, 240],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [166, 0, 0],+ [0, 104, 0],+ [111, 85, 0],+ [0, 49, 169],+ [114, 16, 69],+ [0, 94, 139],+ [166, 166, 166],+ [89, 89, 89],+ [151, 37, 0],+ [0, 102, 63],+ [136, 73, 0],+ [53, 72, 207],+ [83, 26, 182],+ [0, 95, 95],+ [89, 89, 89],+ ],+ },+ TerminalTheme {+ name: "Modus Vivendi",+ background: [0, 0, 0],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [255, 95, 89],+ [68, 188, 68],+ [208, 188, 0],+ [47, 175, 255],+ [254, 172, 208],+ [0, 211, 208],+ [166, 166, 166],+ [89, 89, 89],+ [255, 127, 159],+ [0, 192, 111],+ [254, 196, 63],+ [121, 168, 255],+ [182, 160, 255],+ [106, 228, 185],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Modus Vivendi Tinted",+ background: [13, 14, 28],+ foreground: [255, 255, 255],+ palette: [+ [13, 14, 28],+ [255, 95, 89],+ [68, 188, 68],+ [208, 188, 0],+ [47, 175, 255],+ [254, 172, 208],+ [0, 211, 208],+ [166, 166, 166],+ [89, 89, 89],+ [255, 107, 85],+ [0, 192, 111],+ [254, 196, 63],+ [121, 168, 255],+ [182, 160, 255],+ [106, 228, 185],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Molokai",+ background: [18, 18, 18],+ foreground: [187, 187, 187],+ palette: [+ [18, 18, 18],+ [250, 37, 115],+ [152, 225, 35],+ [223, 212, 96],+ [16, 128, 208],+ [135, 0, 255],+ [67, 168, 208],+ [187, 187, 187],+ [85, 85, 85],+ [246, 102, 157],+ [177, 224, 95],+ [255, 242, 109],+ [0, 175, 255],+ [175, 135, 255],+ [81, 206, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Mona Lisa",+ background: [18, 11, 13],+ foreground: [247, 214, 106],+ palette: [+ [53, 27, 14],+ [155, 41, 28],+ [99, 98, 50],+ [195, 110, 40],+ [81, 92, 93],+ [155, 29, 41],+ [88, 128, 86],+ [247, 215, 92],+ [135, 66, 40],+ [255, 67, 49],+ [180, 178, 100],+ [255, 149, 102],+ [158, 178, 180],+ [255, 91, 106],+ [138, 205, 143],+ [255, 229, 152],+ ],+ },+ TerminalTheme {+ name: "Monokai Classic",+ background: [39, 40, 34],+ foreground: [253, 255, 241],+ palette: [+ [39, 40, 34],+ [249, 38, 114],+ [166, 226, 46],+ [230, 219, 116],+ [253, 151, 31],+ [174, 129, 255],+ [102, 217, 239],+ [253, 255, 241],+ [110, 112, 102],+ [249, 38, 114],+ [166, 226, 46],+ [230, 219, 116],+ [253, 151, 31],+ [174, 129, 255],+ [102, 217, 239],+ [253, 255, 241],+ ],+ },+ TerminalTheme {+ name: "Monokai Pro",+ background: [45, 42, 46],+ foreground: [252, 252, 250],+ palette: [+ [45, 42, 46],+ [255, 97, 136],+ [169, 220, 118],+ [255, 216, 102],+ [252, 152, 103],+ [171, 157, 242],+ [120, 220, 232],+ [252, 252, 250],+ [114, 112, 114],+ [255, 97, 136],+ [169, 220, 118],+ [255, 216, 102],+ [252, 152, 103],+ [171, 157, 242],+ [120, 220, 232],+ [252, 252, 250],+ ],+ },+ TerminalTheme {+ name: "Monokai Pro Light",+ background: [250, 244, 242],+ foreground: [41, 36, 42],+ palette: [+ [250, 244, 242],+ [225, 71, 117],+ [38, 157, 105],+ [204, 122, 10],+ [225, 96, 50],+ [112, 88, 190],+ [28, 140, 168],+ [41, 36, 42],+ [165, 159, 160],+ [225, 71, 117],+ [38, 157, 105],+ [204, 122, 10],+ [225, 96, 50],+ [112, 88, 190],+ [28, 140, 168],+ [41, 36, 42],+ ],+ },+ TerminalTheme {+ name: "Monokai Pro Light Sun",+ background: [248, 239, 231],+ foreground: [44, 35, 46],+ palette: [+ [248, 239, 231],+ [206, 71, 112],+ [33, 136, 113],+ [177, 104, 3],+ [212, 87, 43],+ [104, 81, 162],+ [36, 115, 182],+ [44, 35, 46],+ [165, 156, 156],+ [206, 71, 112],+ [33, 136, 113],+ [177, 104, 3],+ [212, 87, 43],+ [104, 81, 162],+ [36, 115, 182],+ [44, 35, 46],+ ],+ },+ TerminalTheme {+ name: "Monokai Pro Machine",+ background: [39, 49, 54],+ foreground: [242, 255, 252],+ palette: [+ [39, 49, 54],+ [255, 109, 126],+ [162, 229, 123],+ [255, 237, 114],+ [255, 178, 112],+ [186, 160, 248],+ [124, 213, 241],+ [242, 255, 252],+ [107, 118, 120],+ [255, 109, 126],+ [162, 229, 123],+ [255, 237, 114],+ [255, 178, 112],+ [186, 160, 248],+ [124, 213, 241],+ [242, 255, 252],+ ],+ },+ TerminalTheme {+ name: "Monokai Pro Octagon",+ background: [40, 42, 58],+ foreground: [234, 242, 241],+ palette: [+ [40, 42, 58],+ [255, 101, 122],+ [186, 215, 97],+ [255, 215, 109],+ [255, 155, 94],+ [195, 154, 201],+ [156, 209, 187],+ [234, 242, 241],+ [105, 109, 119],+ [255, 101, 122],+ [186, 215, 97],+ [255, 215, 109],+ [255, 155, 94],+ [195, 154, 201],+ [156, 209, 187],+ [234, 242, 241],+ ],+ },+ TerminalTheme {+ name: "Monokai Pro Ristretto",+ background: [44, 37, 37],+ foreground: [255, 241, 243],+ palette: [+ [44, 37, 37],+ [253, 104, 131],+ [173, 218, 120],+ [249, 204, 108],+ [243, 141, 112],+ [168, 169, 235],+ [133, 218, 204],+ [255, 241, 243],+ [114, 105, 106],+ [253, 104, 131],+ [173, 218, 120],+ [249, 204, 108],+ [243, 141, 112],+ [168, 169, 235],+ [133, 218, 204],+ [255, 241, 243],+ ],+ },+ TerminalTheme {+ name: "Monokai Pro Spectrum",+ background: [34, 34, 34],+ foreground: [247, 241, 255],+ palette: [+ [34, 34, 34],+ [252, 97, 141],+ [123, 216, 143],+ [252, 229, 102],+ [253, 147, 83],+ [148, 138, 227],+ [90, 212, 230],+ [247, 241, 255],+ [105, 103, 108],+ [252, 97, 141],+ [123, 216, 143],+ [252, 229, 102],+ [253, 147, 83],+ [148, 138, 227],+ [90, 212, 230],+ [247, 241, 255],+ ],+ },+ TerminalTheme {+ name: "Monokai Remastered",+ background: [12, 12, 12],+ foreground: [217, 217, 217],+ palette: [+ [26, 26, 26],+ [244, 0, 95],+ [152, 224, 36],+ [253, 151, 31],+ [157, 101, 255],+ [244, 0, 95],+ [88, 209, 235],+ [196, 197, 181],+ [98, 94, 76],+ [244, 0, 95],+ [152, 224, 36],+ [224, 213, 97],+ [157, 101, 255],+ [244, 0, 95],+ [88, 209, 235],+ [246, 246, 239],+ ],+ },+ TerminalTheme {+ name: "Monokai Soda",+ background: [26, 26, 26],+ foreground: [196, 197, 181],+ palette: [+ [26, 26, 26],+ [244, 0, 95],+ [152, 224, 36],+ [250, 132, 25],+ [157, 101, 255],+ [244, 0, 95],+ [88, 209, 235],+ [196, 197, 181],+ [98, 94, 76],+ [244, 0, 95],+ [152, 224, 36],+ [224, 213, 97],+ [157, 101, 255],+ [244, 0, 95],+ [88, 209, 235],+ [246, 246, 239],+ ],+ },+ TerminalTheme {+ name: "Monokai Vivid",+ background: [18, 18, 18],+ foreground: [249, 249, 249],+ palette: [+ [18, 18, 18],+ [250, 41, 52],+ [152, 225, 35],+ [255, 243, 10],+ [4, 67, 255],+ [248, 0, 248],+ [1, 182, 237],+ [255, 255, 255],+ [131, 131, 131],+ [246, 102, 157],+ [177, 224, 95],+ [255, 242, 109],+ [4, 67, 255],+ [242, 0, 246],+ [81, 206, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Moonfly",+ background: [8, 8, 8],+ foreground: [189, 189, 189],+ palette: [+ [50, 52, 55],+ [255, 84, 84],+ [140, 200, 95],+ [227, 199, 138],+ [128, 160, 255],+ [207, 135, 232],+ [121, 218, 200],+ [198, 198, 198],+ [148, 148, 148],+ [255, 81, 137],+ [54, 198, 146],+ [198, 198, 132],+ [116, 178, 255],+ [174, 129, 255],+ [133, 220, 133],+ [228, 228, 228],+ ],+ },+ TerminalTheme {+ name: "N0Tch2K",+ background: [34, 34, 34],+ foreground: [160, 160, 160],+ palette: [+ [56, 56, 56],+ [169, 85, 81],+ [102, 102, 102],+ [169, 128, 81],+ [101, 125, 62],+ [118, 118, 118],+ [201, 201, 201],+ [208, 184, 163],+ [84, 84, 84],+ [169, 119, 117],+ [140, 140, 140],+ [169, 145, 117],+ [152, 189, 94],+ [163, 163, 163],+ [220, 220, 220],+ [216, 200, 187],+ ],+ },+ TerminalTheme {+ name: "Neobones Dark",+ background: [15, 25, 31],+ foreground: [198, 213, 207],+ palette: [+ [15, 25, 31],+ [222, 110, 124],+ [144, 255, 107],+ [183, 126, 100],+ [129, 144, 212],+ [178, 121, 167],+ [102, 165, 173],+ [198, 213, 207],+ [51, 70, 82],+ [232, 131, 143],+ [160, 255, 133],+ [214, 140, 103],+ [146, 160, 226],+ [207, 134, 193],+ [101, 184, 193],+ [152, 163, 158],+ ],+ },+ TerminalTheme {+ name: "Neobones Light",+ background: [229, 237, 230],+ foreground: [32, 46, 24],+ palette: [+ [229, 237, 230],+ [168, 51, 76],+ [86, 122, 48],+ [148, 73, 39],+ [40, 100, 134],+ [136, 80, 125],+ [59, 137, 146],+ [32, 46, 24],+ [153, 172, 156],+ [148, 37, 62],+ [63, 90, 34],+ [128, 61, 28],+ [29, 85, 115],+ [123, 59, 112],+ [43, 116, 124],+ [65, 89, 52],+ ],+ },+ TerminalTheme {+ name: "Neon",+ background: [20, 22, 26],+ foreground: [0, 255, 252],+ palette: [+ [0, 0, 0],+ [255, 48, 69],+ [95, 250, 116],+ [255, 252, 126],+ [15, 21, 216],+ [249, 36, 231],+ [0, 255, 252],+ [199, 199, 199],+ [104, 104, 104],+ [255, 90, 90],+ [117, 255, 136],+ [255, 253, 150],+ [60, 64, 203],+ [241, 91, 229],+ [136, 255, 254],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Neopolitan",+ background: [39, 31, 25],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [154, 26, 26],+ [97, 206, 60],+ [251, 222, 45],+ [50, 72, 131],+ [255, 0, 128],+ [141, 166, 206],+ [248, 248, 248],+ [76, 76, 76],+ [154, 26, 26],+ [97, 206, 60],+ [251, 222, 45],+ [50, 72, 131],+ [255, 0, 128],+ [141, 166, 206],+ [248, 248, 248],+ ],+ },+ TerminalTheme {+ name: "Neutron",+ background: [28, 30, 34],+ foreground: [230, 232, 239],+ palette: [+ [35, 37, 43],+ [181, 64, 54],+ [90, 185, 119],+ [222, 181, 102],+ [106, 124, 147],+ [164, 121, 157],+ [63, 148, 168],+ [230, 232, 239],+ [73, 75, 81],+ [181, 64, 54],+ [90, 185, 119],+ [222, 181, 102],+ [106, 124, 147],+ [164, 121, 157],+ [63, 148, 168],+ [235, 237, 242],+ ],+ },+ TerminalTheme {+ name: "Night Lion V1",+ background: [0, 0, 0],+ foreground: [187, 187, 187],+ palette: [+ [76, 76, 76],+ [187, 0, 0],+ [95, 222, 143],+ [243, 241, 103],+ [39, 107, 216],+ [187, 0, 187],+ [0, 218, 223],+ [187, 187, 187],+ [85, 85, 85],+ [255, 85, 85],+ [85, 255, 85],+ [255, 255, 85],+ [85, 85, 255],+ [255, 85, 255],+ [85, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Night Lion V2",+ background: [23, 23, 23],+ foreground: [187, 187, 187],+ palette: [+ [76, 76, 76],+ [187, 0, 0],+ [4, 246, 35],+ [243, 241, 103],+ [100, 208, 240],+ [206, 111, 219],+ [0, 218, 223],+ [187, 187, 187],+ [85, 85, 85],+ [255, 85, 85],+ [125, 247, 29],+ [255, 255, 85],+ [98, 203, 232],+ [255, 155, 245],+ [0, 204, 216],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Night Owl",+ background: [1, 22, 39],+ foreground: [214, 222, 235],+ palette: [+ [1, 22, 39],+ [239, 83, 80],+ [34, 218, 110],+ [173, 219, 103],+ [130, 170, 255],+ [199, 146, 234],+ [33, 199, 168],+ [255, 255, 255],+ [87, 86, 86],+ [239, 83, 80],+ [34, 218, 110],+ [255, 235, 149],+ [130, 170, 255],+ [199, 146, 234],+ [127, 219, 202],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Night Owlish Light",+ background: [255, 255, 255],+ foreground: [64, 63, 83],+ palette: [+ [1, 22, 39],+ [211, 66, 62],+ [42, 162, 152],+ [218, 170, 1],+ [72, 118, 214],+ [64, 63, 83],+ [8, 145, 106],+ [122, 129, 129],+ [122, 129, 129],+ [247, 110, 110],+ [73, 208, 197],+ [218, 194, 107],+ [92, 167, 228],+ [105, 112, 152],+ [0, 201, 144],+ [152, 159, 177],+ ],+ },+ TerminalTheme {+ name: "Nightfox",+ background: [25, 35, 48],+ foreground: [205, 206, 207],+ palette: [+ [57, 59, 68],+ [201, 79, 109],+ [129, 178, 154],+ [219, 192, 116],+ [113, 156, 214],+ [157, 121, 214],+ [99, 205, 207],+ [223, 223, 224],+ [87, 88, 96],+ [209, 105, 131],+ [142, 186, 164],+ [224, 201, 137],+ [134, 171, 220],+ [186, 161, 226],+ [122, 213, 214],+ [228, 228, 229],+ ],+ },+ TerminalTheme {+ name: "Niji",+ background: [20, 21, 21],+ foreground: [255, 255, 255],+ palette: [+ [51, 51, 51],+ [210, 62, 8],+ [84, 202, 116],+ [255, 247, 0],+ [42, 185, 255],+ [255, 80, 218],+ [30, 249, 245],+ [221, 208, 196],+ [81, 81, 81],+ [255, 183, 183],+ [193, 255, 174],+ [252, 255, 184],+ [142, 255, 243],+ [255, 162, 237],+ [188, 255, 199],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "No Clown Fiesta",+ background: [16, 16, 16],+ foreground: [224, 225, 228],+ palette: [+ [21, 21, 21],+ [180, 105, 88],+ [144, 169, 89],+ [244, 191, 117],+ [186, 215, 255],+ [170, 117, 159],+ [136, 175, 162],+ [225, 225, 225],+ [114, 114, 114],+ [126, 151, 171],+ [144, 169, 89],+ [244, 191, 117],+ [186, 215, 255],+ [170, 117, 159],+ [136, 175, 162],+ [175, 175, 175],+ ],+ },+ TerminalTheme {+ name: "No Clown Fiesta Light",+ background: [225, 225, 225],+ foreground: [21, 21, 21],+ palette: [+ [214, 214, 214],+ [135, 78, 66],+ [103, 121, 64],+ [184, 144, 88],+ [139, 161, 191],+ [170, 117, 159],+ [62, 95, 102],+ [21, 21, 21],+ [43, 43, 43],+ [99, 119, 134],+ [103, 121, 64],+ [184, 144, 88],+ [147, 162, 171],+ [170, 117, 159],+ [153, 171, 147],+ [55, 55, 55],+ ],+ },+ TerminalTheme {+ name: "Nocturnal Winter",+ background: [13, 13, 23],+ foreground: [230, 229, 229],+ palette: [+ [77, 77, 77],+ [241, 45, 82],+ [9, 205, 126],+ [245, 241, 122],+ [49, 130, 224],+ [255, 43, 109],+ [9, 200, 122],+ [252, 252, 252],+ [128, 128, 128],+ [241, 109, 134],+ [10, 231, 141],+ [255, 252, 103],+ [96, 150, 255],+ [255, 120, 162],+ [10, 231, 141],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Nord",+ background: [46, 52, 64],+ foreground: [216, 222, 233],+ palette: [+ [59, 66, 82],+ [191, 97, 106],+ [163, 190, 140],+ [235, 203, 139],+ [129, 161, 193],+ [180, 142, 173],+ [136, 192, 208],+ [229, 233, 240],+ [89, 99, 119],+ [191, 97, 106],+ [163, 190, 140],+ [235, 203, 139],+ [129, 161, 193],+ [180, 142, 173],+ [143, 188, 187],+ [236, 239, 244],+ ],+ },+ TerminalTheme {+ name: "Nord Light",+ background: [229, 233, 240],+ foreground: [65, 72, 88],+ palette: [+ [59, 66, 82],+ [191, 97, 106],+ [150, 177, 127],+ [197, 165, 101],+ [129, 161, 193],+ [180, 142, 173],+ [123, 179, 195],+ [165, 171, 182],+ [76, 86, 106],+ [191, 97, 106],+ [150, 177, 127],+ [197, 165, 101],+ [129, 161, 193],+ [180, 142, 173],+ [130, 175, 174],+ [236, 239, 244],+ ],+ },+ TerminalTheme {+ name: "Nord Wave",+ background: [33, 33, 33],+ foreground: [216, 222, 233],+ palette: [+ [59, 66, 82],+ [191, 97, 106],+ [163, 190, 140],+ [235, 203, 139],+ [129, 161, 193],+ [180, 142, 173],+ [136, 192, 208],+ [229, 233, 240],+ [76, 86, 106],+ [191, 97, 106],+ [163, 190, 140],+ [235, 203, 139],+ [129, 161, 193],+ [180, 142, 173],+ [143, 188, 187],+ [236, 239, 244],+ ],+ },+ TerminalTheme {+ name: "Nordfox",+ background: [46, 52, 64],+ foreground: [205, 206, 207],+ palette: [+ [59, 66, 82],+ [191, 97, 106],+ [163, 190, 140],+ [235, 203, 139],+ [129, 161, 193],+ [180, 142, 173],+ [136, 192, 208],+ [229, 233, 240],+ [83, 100, 141],+ [208, 111, 121],+ [177, 209, 150],+ [240, 211, 153],+ [140, 175, 210],+ [200, 149, 191],+ [147, 204, 220],+ [231, 236, 244],+ ],+ },+ TerminalTheme {+ name: "Novel",+ background: [223, 219, 195],+ foreground: [59, 35, 34],+ palette: [+ [0, 0, 0],+ [204, 0, 0],+ [0, 150, 0],+ [208, 107, 0],+ [0, 0, 204],+ [204, 0, 204],+ [0, 135, 204],+ [166, 166, 166],+ [128, 128, 128],+ [204, 0, 0],+ [0, 150, 0],+ [208, 107, 0],+ [0, 0, 204],+ [204, 0, 204],+ [0, 135, 204],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Nvim Dark",+ background: [20, 22, 27],+ foreground: [224, 226, 234],+ palette: [+ [7, 8, 13],+ [255, 192, 185],+ [179, 246, 192],+ [252, 224, 148],+ [166, 219, 255],+ [255, 202, 255],+ [140, 248, 247],+ [238, 241, 248],+ [79, 82, 88],+ [255, 192, 185],+ [179, 246, 192],+ [252, 224, 148],+ [166, 219, 255],+ [255, 202, 255],+ [140, 248, 247],+ [238, 241, 248],+ ],+ },+ TerminalTheme {+ name: "Nvim Light",+ background: [224, 226, 234],+ foreground: [20, 22, 27],+ palette: [+ [7, 8, 13],+ [89, 0, 8],+ [0, 85, 35],+ [107, 83, 0],+ [0, 76, 115],+ [71, 0, 69],+ [0, 115, 115],+ [161, 164, 171],+ [79, 82, 88],+ [89, 0, 8],+ [0, 85, 35],+ [107, 83, 0],+ [0, 76, 115],+ [71, 0, 69],+ [0, 115, 115],+ [238, 241, 248],+ ],+ },+ TerminalTheme {+ name: "Obsidian",+ background: [40, 48, 51],+ foreground: [205, 205, 205],+ palette: [+ [0, 0, 0],+ [179, 13, 14],+ [0, 187, 0],+ [254, 205, 34],+ [58, 155, 219],+ [187, 0, 187],+ [0, 187, 187],+ [187, 187, 187],+ [85, 85, 85],+ [255, 0, 3],+ [147, 200, 99],+ [254, 248, 116],+ [161, 215, 255],+ [255, 85, 255],+ [85, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Ocean",+ background: [34, 79, 188],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [230, 76, 76],+ [0, 166, 0],+ [153, 153, 0],+ [0, 0, 178],+ [216, 38, 216],+ [0, 166, 178],+ [191, 191, 191],+ [128, 128, 128],+ [255, 26, 26],+ [0, 217, 0],+ [229, 229, 0],+ [115, 115, 255],+ [229, 0, 229],+ [0, 229, 229],+ [229, 229, 229],+ ],+ },+ TerminalTheme {+ name: "Oceanic Material",+ background: [28, 38, 43],+ foreground: [194, 200, 215],+ palette: [+ [0, 0, 0],+ [238, 43, 42],+ [64, 163, 63],+ [255, 234, 46],+ [30, 128, 240],+ [136, 0, 160],+ [22, 175, 202],+ [164, 164, 164],+ [119, 119, 119],+ [220, 92, 96],+ [112, 190, 113],+ [255, 241, 99],+ [84, 164, 243],+ [170, 77, 188],+ [66, 199, 218],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Oceanic Next",+ background: [22, 44, 53],+ foreground: [192, 197, 206],+ palette: [+ [22, 44, 53],+ [236, 95, 103],+ [153, 199, 148],+ [250, 200, 99],+ [102, 153, 204],+ [197, 148, 197],+ [95, 179, 179],+ [255, 255, 255],+ [101, 115, 126],+ [236, 95, 103],+ [153, 199, 148],+ [250, 200, 99],+ [102, 153, 204],+ [197, 148, 197],+ [95, 179, 179],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Ollie",+ background: [34, 33, 37],+ foreground: [138, 141, 174],+ palette: [+ [0, 0, 0],+ [172, 46, 49],+ [49, 172, 97],+ [172, 67, 0],+ [45, 87, 172],+ [176, 133, 40],+ [31, 166, 172],+ [138, 142, 172],+ [104, 68, 50],+ [255, 61, 72],+ [59, 255, 153],+ [255, 94, 30],+ [68, 136, 255],+ [255, 194, 29],+ [31, 250, 255],+ [91, 110, 167],+ ],+ },+ TerminalTheme {+ name: "One Dark Two",+ background: [33, 37, 43],+ foreground: [230, 230, 230],+ palette: [+ [29, 31, 35],+ [226, 120, 129],+ [152, 195, 121],+ [234, 199, 134],+ [113, 185, 244],+ [200, 139, 218],+ [98, 186, 198],+ [201, 204, 211],+ [74, 80, 90],+ [230, 137, 145],+ [168, 204, 142],+ [237, 207, 151],+ [141, 199, 246],+ [211, 162, 226],+ [120, 196, 206],+ [230, 230, 230],+ ],+ },+ TerminalTheme {+ name: "One Double Dark",+ background: [40, 44, 52],+ foreground: [219, 223, 229],+ palette: [+ [61, 68, 82],+ [241, 99, 114],+ [140, 197, 112],+ [236, 190, 112],+ [63, 177, 245],+ [211, 115, 227],+ [23, 185, 196],+ [219, 223, 229],+ [82, 93, 111],+ [255, 119, 123],+ [130, 216, 130],+ [245, 192, 101],+ [109, 202, 255],+ [255, 123, 244],+ [0, 229, 251],+ [247, 249, 252],+ ],+ },+ TerminalTheme {+ name: "One Double Light",+ background: [250, 250, 250],+ foreground: [56, 58, 67],+ palette: [+ [69, 75, 88],+ [247, 72, 64],+ [37, 163, 67],+ [204, 129, 0],+ [0, 135, 193],+ [181, 13, 169],+ [0, 154, 183],+ [197, 178, 179],+ [14, 19, 31],+ [255, 55, 17],+ [0, 185, 14],+ [236, 153, 0],+ [16, 101, 222],+ [229, 0, 216],+ [0, 180, 221],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "One Half Dark",+ background: [40, 44, 52],+ foreground: [220, 223, 228],+ palette: [+ [40, 44, 52],+ [224, 108, 117],+ [152, 195, 121],+ [229, 192, 123],+ [97, 175, 239],+ [198, 120, 221],+ [86, 182, 194],+ [220, 223, 228],+ [93, 103, 122],+ [224, 108, 117],+ [152, 195, 121],+ [229, 192, 123],+ [97, 175, 239],+ [198, 120, 221],+ [86, 182, 194],+ [220, 223, 228],+ ],+ },+ TerminalTheme {+ name: "One Half Light",+ background: [250, 250, 250],+ foreground: [56, 58, 66],+ palette: [+ [56, 58, 66],+ [228, 86, 73],+ [80, 161, 79],+ [193, 132, 1],+ [1, 132, 188],+ [166, 38, 164],+ [9, 151, 179],+ [186, 186, 186],+ [79, 82, 94],+ [224, 108, 117],+ [152, 195, 121],+ [216, 179, 110],+ [97, 175, 239],+ [198, 120, 221],+ [86, 182, 194],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Onenord",+ background: [46, 52, 64],+ foreground: [229, 233, 240],+ palette: [+ [59, 66, 82],+ [224, 108, 117],+ [158, 193, 131],+ [235, 203, 139],+ [129, 161, 193],+ [185, 136, 176],+ [136, 192, 208],+ [229, 233, 240],+ [89, 99, 119],+ [224, 108, 117],+ [158, 193, 131],+ [235, 203, 139],+ [129, 161, 193],+ [185, 136, 176],+ [143, 188, 187],+ [236, 239, 244],+ ],+ },+ TerminalTheme {+ name: "Onenord Light",+ background: [247, 248, 250],+ foreground: [46, 52, 64],+ palette: [+ [46, 52, 64],+ [203, 79, 83],+ [72, 165, 61],+ [238, 94, 37],+ [56, 121, 197],+ [159, 74, 202],+ [62, 161, 173],+ [178, 182, 189],+ [100, 106, 118],+ [209, 99, 102],+ [95, 158, 157],+ [186, 121, 62],+ [27, 64, 166],+ [150, 101, 175],+ [143, 188, 187],+ [236, 239, 244],+ ],+ },+ TerminalTheme {+ name: "Operator Mono Dark",+ background: [25, 25, 25],+ foreground: [195, 202, 194],+ palette: [+ [90, 90, 90],+ [202, 55, 45],+ [77, 123, 58],+ [212, 214, 151],+ [67, 135, 207],+ [184, 108, 180],+ [114, 213, 198],+ [206, 212, 205],+ [154, 155, 153],+ [195, 125, 98],+ [131, 208, 162],+ [253, 253, 197],+ [137, 211, 246],+ [255, 44, 122],+ [130, 234, 218],+ [253, 253, 246],+ ],+ },+ TerminalTheme {+ name: "Overnight Slumber",+ background: [14, 23, 41],+ foreground: [206, 210, 214],+ palette: [+ [10, 18, 34],+ [255, 167, 196],+ [133, 204, 149],+ [255, 203, 139],+ [141, 171, 225],+ [199, 146, 235],+ [120, 204, 240],+ [255, 255, 255],+ [87, 86, 86],+ [255, 167, 196],+ [133, 204, 149],+ [255, 203, 139],+ [141, 171, 225],+ [199, 146, 235],+ [255, 167, 196],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Oxocarbon",+ background: [22, 22, 22],+ foreground: [242, 244, 248],+ palette: [+ [22, 22, 22],+ [0, 223, 219],+ [0, 180, 255],+ [255, 66, 151],+ [0, 193, 90],+ [198, 147, 255],+ [255, 116, 184],+ [242, 244, 248],+ [88, 88, 88],+ [0, 223, 219],+ [0, 180, 255],+ [255, 66, 151],+ [0, 193, 90],+ [198, 147, 255],+ [255, 116, 184],+ [242, 244, 248],+ ],+ },+ TerminalTheme {+ name: "Pale Night Hc",+ background: [62, 66, 81],+ foreground: [204, 204, 204],+ palette: [+ [0, 0, 0],+ [240, 113, 120],+ [195, 232, 141],+ [255, 203, 107],+ [130, 170, 255],+ [199, 146, 234],+ [137, 221, 255],+ [255, 255, 255],+ [115, 115, 115],+ [246, 169, 174],+ [219, 241, 186],+ [255, 223, 166],+ [180, 204, 255],+ [221, 189, 242],+ [184, 234, 255],+ [153, 153, 153],+ ],+ },+ TerminalTheme {+ name: "Pandora",+ background: [20, 30, 67],+ foreground: [225, 225, 225],+ palette: [+ [0, 0, 0],+ [255, 66, 66],+ [116, 175, 104],+ [255, 173, 41],+ [51, 143, 134],+ [148, 20, 230],+ [35, 215, 215],+ [226, 226, 226],+ [63, 86, 72],+ [255, 50, 66],+ [116, 205, 104],+ [255, 185, 41],+ [35, 215, 215],+ [255, 55, 255],+ [0, 237, 225],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Paraiso Dark",+ background: [47, 30, 46],+ foreground: [163, 158, 155],+ palette: [+ [47, 30, 46],+ [239, 97, 85],+ [72, 182, 133],+ [254, 196, 24],+ [6, 182, 239],+ [129, 91, 164],+ [91, 196, 191],+ [163, 158, 155],+ [119, 110, 113],+ [239, 97, 85],+ [72, 182, 133],+ [254, 196, 24],+ [6, 182, 239],+ [129, 91, 164],+ [91, 196, 191],+ [231, 233, 219],+ ],+ },+ TerminalTheme {+ name: "Paul Millr",+ background: [0, 0, 0],+ foreground: [242, 242, 242],+ palette: [+ [42, 42, 42],+ [255, 0, 0],+ [121, 255, 15],+ [231, 191, 0],+ [57, 107, 215],+ [180, 73, 190],+ [102, 204, 255],+ [187, 187, 187],+ [102, 102, 102],+ [255, 0, 128],+ [102, 255, 102],+ [243, 214, 78],+ [112, 154, 237],+ [219, 103, 230],+ [122, 223, 242],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Pencil Dark",+ background: [33, 33, 33],+ foreground: [241, 241, 241],+ palette: [+ [33, 33, 33],+ [195, 7, 113],+ [16, 167, 120],+ [168, 156, 20],+ [0, 142, 196],+ [95, 73, 134],+ [32, 165, 186],+ [217, 217, 217],+ [79, 79, 79],+ [251, 0, 122],+ [95, 215, 175],+ [243, 228, 48],+ [32, 187, 252],+ [104, 85, 222],+ [79, 184, 204],+ [241, 241, 241],+ ],+ },+ TerminalTheme {+ name: "Pencil Light",+ background: [241, 241, 241],+ foreground: [66, 66, 66],+ palette: [+ [33, 33, 33],+ [195, 7, 113],+ [16, 167, 120],+ [168, 156, 20],+ [0, 142, 196],+ [82, 60, 121],+ [32, 165, 186],+ [179, 179, 179],+ [66, 66, 66],+ [251, 0, 122],+ [82, 202, 162],+ [192, 177, 0],+ [32, 187, 252],+ [104, 85, 222],+ [79, 184, 204],+ [241, 241, 241],+ ],+ },+ TerminalTheme {+ name: "Peppermint",+ background: [0, 0, 0],+ foreground: [200, 200, 200],+ palette: [+ [53, 53, 53],+ [231, 70, 105],+ [137, 210, 135],+ [218, 184, 83],+ [68, 159, 208],+ [218, 98, 220],+ [101, 170, 175],+ [180, 180, 180],+ [83, 83, 83],+ [228, 133, 155],+ [163, 204, 162],+ [225, 228, 135],+ [111, 188, 226],+ [229, 134, 231],+ [150, 220, 219],+ [223, 223, 223],+ ],+ },+ TerminalTheme {+ name: "Phala Green Dark",+ background: [0, 0, 0],+ foreground: [193, 252, 3],+ palette: [+ [0, 0, 0],+ [171, 21, 0],+ [0, 177, 0],+ [169, 167, 0],+ [2, 35, 192],+ [194, 46, 192],+ [0, 180, 192],+ [203, 203, 203],+ [121, 121, 121],+ [237, 34, 0],+ [0, 219, 0],+ [234, 231, 0],+ [4, 51, 255],+ [237, 58, 234],+ [0, 232, 234],+ [234, 234, 234],+ ],+ },+ TerminalTheme {+ name: "Piatto Light",+ background: [255, 255, 255],+ foreground: [65, 65, 65],+ palette: [+ [65, 65, 65],+ [178, 55, 113],+ [102, 120, 30],+ [205, 111, 52],+ [60, 94, 168],+ [164, 84, 178],+ [102, 120, 30],+ [191, 191, 191],+ [63, 63, 63],+ [219, 51, 101],+ [130, 148, 41],+ [205, 111, 52],+ [60, 94, 168],+ [164, 84, 178],+ [130, 148, 41],+ [242, 242, 242],+ ],+ },+ TerminalTheme {+ name: "Pnevma",+ background: [28, 28, 28],+ foreground: [208, 208, 208],+ palette: [+ [47, 46, 45],+ [163, 102, 102],+ [144, 165, 125],+ [215, 175, 135],+ [127, 165, 189],+ [199, 158, 196],+ [138, 219, 180],+ [208, 208, 208],+ [74, 72, 69],+ [215, 135, 135],+ [175, 190, 162],+ [228, 201, 175],+ [161, 189, 206],+ [215, 190, 218],+ [177, 231, 221],+ [239, 239, 239],+ ],+ },+ TerminalTheme {+ name: "Poimandres",+ background: [26, 30, 40],+ foreground: [166, 172, 205],+ palette: [+ [26, 30, 40],+ [208, 103, 157],+ [93, 228, 199],+ [255, 250, 194],+ [137, 221, 255],+ [252, 197, 233],+ [173, 215, 255],+ [255, 255, 255],+ [166, 172, 205],+ [208, 103, 157],+ [93, 228, 199],+ [255, 250, 194],+ [173, 215, 255],+ [250, 228, 252],+ [137, 221, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Poimandres Darker",+ background: [22, 22, 30],+ foreground: [166, 172, 205],+ palette: [+ [22, 22, 30],+ [208, 103, 157],+ [93, 228, 199],+ [255, 250, 194],+ [137, 221, 255],+ [252, 197, 233],+ [173, 215, 255],+ [255, 255, 255],+ [166, 172, 205],+ [208, 103, 157],+ [93, 228, 199],+ [255, 250, 194],+ [173, 215, 255],+ [250, 228, 252],+ [137, 221, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Poimandres Storm",+ background: [37, 43, 55],+ foreground: [166, 172, 205],+ palette: [+ [37, 43, 55],+ [208, 103, 157],+ [93, 228, 199],+ [255, 250, 194],+ [137, 221, 255],+ [240, 135, 189],+ [137, 221, 255],+ [255, 255, 255],+ [166, 172, 205],+ [208, 103, 157],+ [93, 228, 199],+ [255, 250, 194],+ [173, 215, 255],+ [240, 135, 189],+ [173, 215, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Poimandres White",+ background: [254, 254, 255],+ foreground: [150, 156, 189],+ palette: [+ [254, 254, 255],+ [255, 32, 144],+ [1, 218, 178],+ [229, 186, 78],+ [138, 186, 205],+ [235, 131, 148],+ [138, 186, 205],+ [0, 0, 0],+ [150, 156, 189],+ [255, 32, 144],+ [1, 218, 178],+ [229, 186, 78],+ [14, 191, 255],+ [235, 131, 148],+ [14, 191, 255],+ [0, 0, 0],+ ],+ },+ TerminalTheme {+ name: "Popping And Locking",+ background: [24, 25, 33],+ foreground: [235, 219, 178],+ palette: [+ [29, 32, 33],+ [204, 36, 29],+ [152, 151, 26],+ [215, 153, 33],+ [69, 133, 136],+ [177, 98, 134],+ [104, 157, 106],+ [168, 153, 132],+ [146, 131, 116],+ [244, 44, 62],+ [184, 187, 38],+ [250, 189, 47],+ [153, 198, 202],+ [211, 134, 155],+ [126, 193, 110],+ [235, 219, 178],+ ],+ },+ TerminalTheme {+ name: "Powershell",+ background: [5, 36, 84],+ foreground: [246, 246, 247],+ palette: [+ [0, 0, 0],+ [152, 26, 34],+ [9, 128, 3],+ [196, 160, 0],+ [65, 64, 195],+ [211, 54, 130],+ [14, 128, 127],+ [127, 124, 127],+ [128, 128, 128],+ [239, 41, 41],+ [28, 254, 60],+ [254, 254, 69],+ [38, 138, 210],+ [254, 19, 250],+ [41, 255, 254],+ [194, 193, 195],+ ],+ },+ TerminalTheme {+ name: "Primary",+ background: [255, 255, 255],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [219, 68, 55],+ [15, 157, 88],+ [244, 180, 0],+ [66, 133, 244],+ [219, 68, 55],+ [66, 133, 244],+ [191, 191, 191],+ [0, 0, 0],+ [219, 68, 55],+ [15, 157, 88],+ [244, 180, 0],+ [66, 133, 244],+ [66, 133, 244],+ [15, 157, 88],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Pro",+ background: [0, 0, 0],+ foreground: [242, 242, 242],+ palette: [+ [0, 0, 0],+ [153, 0, 0],+ [0, 166, 0],+ [153, 153, 0],+ [32, 9, 219],+ [178, 0, 178],+ [0, 166, 178],+ [191, 191, 191],+ [102, 102, 102],+ [229, 0, 0],+ [0, 217, 0],+ [229, 229, 0],+ [0, 0, 255],+ [229, 0, 229],+ [0, 229, 229],+ [229, 229, 229],+ ],+ },+ TerminalTheme {+ name: "Pro Light",+ background: [255, 255, 255],+ foreground: [25, 25, 25],+ palette: [+ [0, 0, 0],+ [229, 73, 43],+ [80, 209, 72],+ [198, 196, 64],+ [59, 117, 255],+ [237, 102, 232],+ [78, 210, 222],+ [194, 194, 194],+ [159, 159, 159],+ [255, 102, 64],+ [72, 213, 62],+ [191, 190, 35],+ [0, 130, 255],+ [255, 126, 255],+ [59, 209, 210],+ [242, 242, 242],+ ],+ },+ TerminalTheme {+ name: "Purple Rain",+ background: [33, 8, 74],+ foreground: [255, 251, 246],+ palette: [+ [0, 0, 0],+ [255, 38, 14],+ [155, 226, 5],+ [255, 196, 0],+ [0, 162, 250],+ [129, 91, 181],+ [0, 222, 239],+ [255, 255, 255],+ [86, 86, 86],+ [255, 66, 80],+ [184, 227, 110],+ [255, 216, 82],+ [0, 166, 255],+ [172, 123, 240],+ [116, 253, 243],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Purplepeter",+ background: [42, 26, 74],+ foreground: [236, 231, 250],+ palette: [+ [10, 5, 32],+ [255, 121, 109],+ [153, 180, 129],+ [239, 223, 172],+ [102, 217, 239],+ [231, 143, 205],+ [186, 140, 255],+ [255, 186, 129],+ [80, 75, 99],+ [249, 159, 146],+ [180, 190, 143],+ [242, 233, 191],+ [121, 218, 237],+ [186, 145, 212],+ [160, 160, 214],+ [185, 174, 211],+ ],+ },+ TerminalTheme {+ name: "Rapture",+ background: [17, 30, 42],+ foreground: [192, 201, 229],+ palette: [+ [0, 0, 0],+ [252, 100, 77],+ [122, 253, 225],+ [255, 240, 155],+ [108, 155, 245],+ [255, 79, 161],+ [100, 224, 255],+ [192, 201, 229],+ [48, 75, 102],+ [252, 100, 77],+ [122, 253, 225],+ [255, 240, 155],+ [108, 155, 245],+ [255, 79, 161],+ [100, 224, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Raycast Dark",+ background: [26, 26, 26],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [255, 83, 96],+ [89, 212, 153],+ [255, 197, 49],+ [86, 194, 255],+ [207, 47, 152],+ [82, 238, 229],+ [255, 255, 255],+ [76, 76, 76],+ [255, 99, 99],+ [89, 212, 153],+ [255, 197, 49],+ [86, 194, 255],+ [207, 47, 152],+ [82, 238, 229],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Raycast Light",+ background: [255, 255, 255],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [177, 36, 36],+ [0, 107, 79],+ [248, 163, 0],+ [19, 138, 242],+ [154, 27, 110],+ [62, 184, 191],+ [191, 191, 191],+ [0, 0, 0],+ [177, 36, 36],+ [0, 107, 79],+ [248, 163, 0],+ [19, 138, 242],+ [154, 27, 110],+ [62, 184, 191],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Rebecca",+ background: [41, 42, 68],+ foreground: [232, 230, 237],+ palette: [+ [18, 19, 30],+ [221, 119, 85],+ [4, 219, 181],+ [242, 231, 183],+ [122, 165, 255],+ [191, 156, 249],+ [86, 211, 194],+ [228, 227, 233],+ [102, 102, 153],+ [255, 146, 205],+ [1, 234, 192],+ [255, 252, 168],+ [105, 192, 250],+ [193, 127, 248],+ [139, 253, 225],+ [244, 242, 249],+ ],+ },+ TerminalTheme {+ name: "Red Alert",+ background: [118, 36, 35],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [214, 46, 78],+ [113, 190, 107],+ [190, 184, 107],+ [72, 155, 238],+ [233, 121, 215],+ [107, 190, 184],+ [214, 214, 214],+ [102, 102, 102],+ [224, 37, 83],+ [175, 240, 140],+ [223, 221, 183],+ [101, 170, 241],+ [221, 183, 223],+ [183, 223, 221],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Red Planet",+ background: [34, 34, 34],+ foreground: [194, 183, 144],+ palette: [+ [32, 32, 32],+ [140, 52, 50],+ [114, 130, 113],+ [232, 191, 106],+ [105, 129, 158],+ [137, 100, 146],+ [91, 131, 144],+ [185, 170, 153],+ [103, 103, 103],+ [181, 82, 66],+ [134, 153, 133],+ [235, 235, 145],+ [96, 130, 126],+ [222, 73, 116],+ [56, 173, 216],+ [214, 191, 184],+ ],+ },+ TerminalTheme {+ name: "Red Sands",+ background: [122, 37, 30],+ foreground: [215, 201, 167],+ palette: [+ [0, 0, 0],+ [255, 63, 0],+ [0, 187, 0],+ [231, 176, 0],+ [0, 114, 255],+ [187, 0, 187],+ [0, 187, 187],+ [187, 187, 187],+ [110, 110, 110],+ [212, 26, 26],+ [0, 187, 0],+ [231, 176, 0],+ [0, 114, 174],+ [255, 85, 255],+ [85, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Relaxed",+ background: [53, 58, 68],+ foreground: [217, 217, 217],+ palette: [+ [21, 21, 21],+ [188, 86, 83],+ [144, 157, 99],+ [235, 193, 122],+ [106, 135, 153],+ [176, 102, 152],+ [201, 223, 255],+ [217, 217, 217],+ [99, 99, 99],+ [188, 86, 83],+ [160, 172, 119],+ [235, 193, 122],+ [126, 170, 199],+ [176, 102, 152],+ [172, 187, 208],+ [247, 247, 247],+ ],+ },+ TerminalTheme {+ name: "Retro",+ background: [0, 0, 0],+ foreground: [19, 161, 14],+ palette: [+ [19, 161, 14],+ [19, 161, 14],+ [19, 161, 14],+ [19, 161, 14],+ [19, 161, 14],+ [19, 161, 14],+ [19, 161, 14],+ [19, 161, 14],+ [22, 186, 16],+ [22, 186, 16],+ [22, 186, 16],+ [22, 186, 16],+ [22, 186, 16],+ [22, 186, 16],+ [22, 186, 16],+ [22, 186, 16],+ ],+ },+ TerminalTheme {+ name: "Retro Legends",+ background: [13, 13, 13],+ foreground: [69, 235, 69],+ palette: [+ [38, 38, 38],+ [222, 84, 84],+ [69, 235, 69],+ [247, 191, 43],+ [64, 102, 242],+ [191, 76, 242],+ [64, 217, 230],+ [191, 230, 191],+ [76, 89, 76],+ [255, 102, 102],+ [89, 255, 89],+ [255, 217, 51],+ [76, 128, 255],+ [230, 102, 255],+ [89, 230, 255],+ [242, 255, 242],+ ],+ },+ TerminalTheme {+ name: "Rippedcasts",+ background: [43, 43, 43],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [205, 175, 149],+ [168, 255, 96],+ [191, 187, 31],+ [117, 165, 176],+ [255, 115, 253],+ [90, 100, 126],+ [191, 191, 191],+ [102, 102, 102],+ [238, 203, 173],+ [188, 238, 104],+ [229, 229, 0],+ [134, 189, 201],+ [229, 0, 229],+ [140, 155, 196],+ [229, 229, 229],+ ],+ },+ TerminalTheme {+ name: "Rose Pine",+ background: [25, 23, 36],+ foreground: [224, 222, 244],+ palette: [+ [38, 35, 58],+ [235, 111, 146],+ [49, 116, 143],+ [246, 193, 119],+ [156, 207, 216],+ [196, 167, 231],+ [235, 188, 186],+ [224, 222, 244],+ [110, 106, 134],+ [235, 111, 146],+ [49, 116, 143],+ [246, 193, 119],+ [156, 207, 216],+ [196, 167, 231],+ [235, 188, 186],+ [224, 222, 244],+ ],+ },+ TerminalTheme {+ name: "Rose Pine Dawn",+ background: [250, 244, 237],+ foreground: [87, 82, 121],+ palette: [+ [242, 233, 225],+ [180, 99, 122],+ [40, 105, 131],+ [234, 157, 52],+ [86, 148, 159],+ [144, 122, 169],+ [215, 130, 126],+ [87, 82, 121],+ [152, 147, 165],+ [180, 99, 122],+ [40, 105, 131],+ [234, 157, 52],+ [86, 148, 159],+ [144, 122, 169],+ [215, 130, 126],+ [87, 82, 121],+ ],+ },+ TerminalTheme {+ name: "Rose Pine Moon",+ background: [35, 33, 54],+ foreground: [224, 222, 244],+ palette: [+ [57, 53, 82],+ [235, 111, 146],+ [62, 143, 176],+ [246, 193, 119],+ [156, 207, 216],+ [196, 167, 231],+ [234, 154, 151],+ [224, 222, 244],+ [110, 106, 134],+ [235, 111, 146],+ [62, 143, 176],+ [246, 193, 119],+ [156, 207, 216],+ [196, 167, 231],+ [234, 154, 151],+ [224, 222, 244],+ ],+ },+ TerminalTheme {+ name: "Rouge 2",+ background: [23, 24, 43],+ foreground: [162, 163, 170],+ palette: [+ [93, 93, 107],+ [198, 121, 126],+ [150, 158, 146],+ [219, 205, 171],+ [110, 148, 185],+ [76, 78, 120],+ [138, 182, 193],+ [232, 232, 234],+ [97, 98, 116],+ [198, 121, 126],+ [230, 220, 196],+ [230, 220, 196],+ [152, 179, 205],+ [130, 131, 161],+ [171, 203, 211],+ [232, 232, 234],+ ],+ },+ TerminalTheme {+ name: "Royal",+ background: [16, 8, 21],+ foreground: [81, 73, 104],+ palette: [+ [36, 31, 43],+ [145, 40, 76],+ [35, 128, 28],+ [180, 157, 39],+ [101, 128, 176],+ [103, 77, 150],+ [138, 170, 190],+ [82, 73, 102],+ [62, 58, 74],+ [213, 53, 108],+ [44, 217, 70],+ [253, 232, 59],+ [144, 186, 249],+ [164, 121, 227],+ [172, 212, 235],+ [158, 140, 189],+ ],+ },+ TerminalTheme {+ name: "Ryuuko",+ background: [44, 57, 65],+ foreground: [236, 236, 236],+ palette: [+ [44, 57, 65],+ [134, 95, 91],+ [102, 144, 125],+ [177, 169, 144],+ [106, 142, 149],+ [177, 138, 115],+ [136, 178, 172],+ [236, 236, 236],+ [93, 112, 121],+ [134, 95, 91],+ [102, 144, 125],+ [177, 169, 144],+ [106, 142, 149],+ [177, 138, 115],+ [136, 178, 172],+ [236, 236, 236],+ ],+ },+ TerminalTheme {+ name: "Sakura",+ background: [24, 19, 30],+ foreground: [221, 123, 220],+ palette: [+ [0, 0, 0],+ [213, 35, 112],+ [65, 175, 26],+ [188, 112, 83],+ [105, 100, 171],+ [199, 31, 191],+ [147, 147, 147],+ [153, 142, 172],+ [120, 109, 105],+ [244, 29, 153],+ [34, 229, 41],+ [245, 149, 116],+ [152, 146, 241],+ [233, 12, 221],+ [238, 238, 238],+ [203, 182, 255],+ ],+ },+ TerminalTheme {+ name: "Scarlet Protocol",+ background: [28, 21, 61],+ foreground: [228, 25, 81],+ palette: [+ [16, 17, 22],+ [255, 0, 81],+ [0, 220, 132],+ [250, 249, 69],+ [2, 113, 182],+ [202, 48, 199],+ [0, 197, 199],+ [199, 199, 199],+ [104, 104, 104],+ [255, 110, 103],+ [95, 250, 104],+ [255, 252, 103],+ [104, 113, 255],+ [189, 53, 236],+ [96, 253, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Sea Shells",+ background: [9, 20, 27],+ foreground: [222, 184, 141],+ palette: [+ [23, 56, 76],+ [209, 81, 35],+ [2, 124, 155],+ [252, 160, 47],+ [30, 73, 80],+ [104, 212, 241],+ [80, 163, 181],+ [222, 184, 141],+ [67, 75, 83],+ [212, 134, 120],+ [98, 141, 152],+ [253, 211, 159],+ [27, 188, 221],+ [187, 227, 238],+ [135, 172, 180],+ [254, 228, 206],+ ],+ },+ TerminalTheme {+ name: "Seafoam Pastel",+ background: [36, 52, 53],+ foreground: [212, 231, 212],+ palette: [+ [117, 117, 117],+ [130, 93, 77],+ [114, 140, 98],+ [173, 161, 109],+ [77, 123, 130],+ [138, 114, 103],+ [114, 148, 148],+ [224, 224, 224],+ [138, 138, 138],+ [207, 147, 122],+ [152, 217, 170],+ [250, 231, 157],+ [122, 195, 207],+ [214, 178, 161],+ [173, 224, 224],+ [224, 224, 224],+ ],+ },+ TerminalTheme {+ name: "Selenized Black",+ background: [24, 24, 24],+ foreground: [185, 185, 185],+ palette: [+ [37, 37, 37],+ [237, 74, 70],+ [112, 180, 51],+ [219, 179, 45],+ [54, 138, 235],+ [235, 110, 183],+ [63, 197, 183],+ [185, 185, 185],+ [119, 119, 119],+ [255, 94, 86],+ [131, 199, 70],+ [239, 197, 65],+ [79, 156, 254],+ [255, 129, 202],+ [86, 216, 201],+ [222, 222, 222],+ ],+ },+ TerminalTheme {+ name: "Selenized Dark",+ background: [16, 60, 72],+ foreground: [173, 188, 188],+ palette: [+ [24, 73, 86],+ [250, 87, 80],+ [117, 185, 56],+ [219, 179, 45],+ [70, 149, 247],+ [242, 117, 190],+ [65, 199, 185],+ [173, 188, 188],+ [114, 137, 143],+ [255, 102, 92],+ [132, 199, 71],+ [235, 193, 61],+ [88, 163, 255],+ [255, 132, 205],+ [83, 214, 199],+ [202, 216, 217],+ ],+ },+ TerminalTheme {+ name: "Selenized Light",+ background: [251, 243, 219],+ foreground: [83, 103, 109],+ palette: [+ [236, 227, 204],+ [210, 33, 45],+ [72, 145, 0],+ [173, 137, 0],+ [0, 114, 212],+ [202, 72, 152],+ [0, 156, 143],+ [83, 103, 109],+ [144, 153, 149],+ [204, 23, 41],+ [66, 139, 0],+ [167, 131, 0],+ [0, 109, 206],+ [196, 67, 146],+ [0, 151, 138],+ [58, 77, 83],+ ],+ },+ TerminalTheme {+ name: "Seoulbones Dark",+ background: [75, 75, 75],+ foreground: [221, 221, 221],+ palette: [+ [75, 75, 75],+ [227, 136, 163],+ [152, 189, 153],+ [255, 223, 155],+ [151, 189, 222],+ [165, 166, 197],+ [111, 189, 190],+ [221, 221, 221],+ [121, 113, 114],+ [235, 153, 177],+ [143, 205, 146],+ [255, 229, 179],+ [162, 200, 233],+ [178, 179, 218],+ [107, 202, 203],+ [168, 168, 168],+ ],+ },+ TerminalTheme {+ name: "Seoulbones Light",+ background: [226, 226, 226],+ foreground: [85, 85, 85],+ palette: [+ [226, 226, 226],+ [220, 82, 132],+ [98, 133, 98],+ [196, 133, 98],+ [0, 132, 163],+ [137, 103, 136],+ [0, 133, 134],+ [85, 85, 85],+ [165, 160, 161],+ [190, 60, 109],+ [72, 114, 73],+ [167, 107, 72],+ [0, 111, 137],+ [127, 76, 126],+ [0, 111, 112],+ [119, 119, 119],+ ],+ },+ TerminalTheme {+ name: "Seti",+ background: [17, 18, 19],+ foreground: [202, 206, 205],+ palette: [+ [50, 50, 50],+ [194, 40, 50],+ [142, 196, 61],+ [224, 198, 79],+ [67, 165, 213],+ [139, 87, 181],+ [142, 196, 61],+ [238, 238, 238],+ [63, 63, 63],+ [194, 40, 50],+ [142, 196, 61],+ [224, 198, 79],+ [67, 165, 213],+ [139, 87, 181],+ [142, 196, 61],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Shades Of Purple",+ background: [30, 29, 64],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [217, 4, 41],+ [58, 217, 0],+ [255, 231, 0],+ [105, 67, 255],+ [255, 44, 112],+ [0, 197, 199],+ [199, 199, 199],+ [104, 104, 104],+ [249, 42, 28],+ [67, 212, 38],+ [241, 208, 0],+ [104, 113, 255],+ [255, 119, 255],+ [121, 232, 251],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Shaman",+ background: [0, 16, 21],+ foreground: [64, 85, 85],+ palette: [+ [1, 32, 38],+ [178, 48, 45],+ [0, 169, 65],+ [94, 139, 170],+ [68, 154, 134],+ [0, 89, 157],+ [93, 126, 25],+ [64, 85, 85],+ [56, 68, 81],+ [255, 66, 66],+ [42, 234, 94],+ [142, 212, 253],+ [97, 213, 186],+ [18, 152, 255],+ [152, 208, 40],+ [88, 251, 214],+ ],+ },+ TerminalTheme {+ name: "Slate",+ background: [34, 34, 34],+ foreground: [53, 177, 210],+ palette: [+ [34, 34, 34],+ [226, 168, 191],+ [129, 215, 120],+ [196, 201, 192],+ [51, 88, 86],+ [164, 129, 211],+ [21, 171, 156],+ [2, 197, 224],+ [255, 255, 255],+ [255, 205, 217],+ [190, 255, 168],+ [208, 204, 202],+ [122, 176, 210],+ [197, 167, 217],+ [140, 223, 224],+ [224, 224, 224],+ ],+ },+ TerminalTheme {+ name: "Sleepy Hollow",+ background: [18, 18, 20],+ foreground: [175, 154, 145],+ palette: [+ [87, 33, 0],+ [186, 57, 52],+ [145, 119, 63],+ [181, 86, 0],+ [95, 99, 180],+ [161, 124, 123],+ [143, 174, 169],+ [175, 154, 145],+ [78, 75, 97],+ [217, 68, 63],+ [214, 176, 78],+ [246, 104, 19],+ [128, 134, 239],+ [226, 194, 187],+ [164, 220, 231],+ [210, 199, 169],+ ],+ },+ TerminalTheme {+ name: "Smyck",+ background: [27, 27, 27],+ foreground: [247, 247, 247],+ palette: [+ [0, 0, 0],+ [184, 65, 49],+ [125, 169, 0],+ [196, 165, 0],+ [98, 163, 196],+ [186, 138, 204],+ [32, 115, 131],+ [161, 161, 161],+ [122, 122, 122],+ [214, 131, 124],+ [196, 241, 55],+ [254, 225, 77],+ [141, 207, 240],+ [247, 154, 255],+ [106, 217, 207],+ [247, 247, 247],+ ],+ },+ TerminalTheme {+ name: "Snazzy",+ background: [30, 31, 41],+ foreground: [235, 236, 230],+ palette: [+ [0, 0, 0],+ [252, 67, 70],+ [80, 251, 124],+ [240, 251, 140],+ [73, 186, 255],+ [252, 76, 180],+ [139, 233, 254],+ [237, 237, 236],+ [85, 85, 85],+ [252, 67, 70],+ [80, 251, 124],+ [240, 251, 140],+ [73, 186, 255],+ [252, 76, 180],+ [139, 233, 254],+ [237, 237, 236],+ ],+ },+ TerminalTheme {+ name: "Snazzy Soft",+ background: [40, 42, 54],+ foreground: [239, 240, 235],+ palette: [+ [0, 0, 0],+ [255, 92, 87],+ [90, 247, 142],+ [243, 249, 157],+ [87, 199, 255],+ [255, 106, 193],+ [154, 237, 254],+ [241, 241, 240],+ [104, 104, 104],+ [255, 92, 87],+ [90, 247, 142],+ [243, 249, 157],+ [87, 199, 255],+ [255, 106, 193],+ [154, 237, 254],+ [241, 241, 240],+ ],+ },+ TerminalTheme {+ name: "Soft Server",+ background: [36, 38, 38],+ foreground: [153, 163, 162],+ palette: [+ [0, 0, 0],+ [162, 104, 106],+ [154, 165, 106],+ [163, 144, 106],+ [107, 143, 163],+ [106, 113, 163],+ [107, 165, 143],+ [153, 163, 162],+ [102, 108, 108],+ [221, 92, 96],+ [191, 223, 85],+ [222, 179, 96],+ [98, 177, 223],+ [96, 110, 223],+ [100, 227, 156],+ [210, 224, 222],+ ],+ },+ TerminalTheme {+ name: "Solarized Darcula",+ background: [61, 63, 65],+ foreground: [210, 216, 217],+ palette: [+ [37, 41, 42],+ [242, 72, 64],+ [98, 150, 85],+ [182, 136, 0],+ [32, 117, 199],+ [121, 127, 212],+ [21, 150, 141],+ [210, 216, 217],+ [101, 105, 106],+ [242, 72, 64],+ [98, 150, 85],+ [182, 136, 0],+ [32, 117, 199],+ [121, 127, 212],+ [21, 150, 141],+ [210, 216, 217],+ ],+ },+ TerminalTheme {+ name: "Solarized Dark Higher Contrast",+ background: [0, 30, 39],+ foreground: [156, 194, 195],+ palette: [+ [0, 40, 49],+ [209, 28, 36],+ [108, 190, 108],+ [165, 119, 6],+ [33, 118, 199],+ [198, 28, 111],+ [37, 146, 134],+ [234, 227, 203],+ [0, 100, 136],+ [245, 22, 59],+ [81, 239, 132],+ [178, 126, 40],+ [23, 142, 200],+ [226, 77, 142],+ [0, 179, 158],+ [252, 244, 220],+ ],+ },+ TerminalTheme {+ name: "Solarized Dark Patched",+ background: [0, 30, 39],+ foreground: [112, 130, 132],+ palette: [+ [0, 40, 49],+ [209, 28, 36],+ [115, 138, 5],+ [165, 119, 6],+ [33, 118, 199],+ [198, 28, 111],+ [37, 146, 134],+ [234, 227, 203],+ [71, 91, 98],+ [189, 54, 19],+ [71, 91, 98],+ [83, 104, 112],+ [112, 130, 132],+ [89, 86, 186],+ [129, 144, 144],+ [252, 244, 220],+ ],+ },+ TerminalTheme {+ name: "Solarized Osaka Night",+ background: [26, 27, 38],+ foreground: [192, 202, 245],+ palette: [+ [21, 22, 30],+ [247, 118, 142],+ [158, 206, 106],+ [224, 175, 104],+ [122, 162, 247],+ [187, 154, 247],+ [125, 207, 255],+ [169, 177, 214],+ [65, 72, 104],+ [247, 118, 142],+ [158, 206, 106],+ [224, 175, 104],+ [122, 162, 247],+ [187, 154, 247],+ [125, 207, 255],+ [192, 202, 245],+ ],+ },+ TerminalTheme {+ name: "Sonokai",+ background: [44, 46, 52],+ foreground: [226, 226, 227],+ palette: [+ [24, 24, 25],+ [252, 93, 124],+ [158, 208, 114],+ [231, 198, 100],+ [118, 204, 224],+ [179, 157, 243],+ [243, 150, 96],+ [226, 226, 227],+ [127, 132, 144],+ [252, 93, 124],+ [158, 208, 114],+ [231, 198, 100],+ [118, 204, 224],+ [179, 157, 243],+ [243, 150, 96],+ [226, 226, 227],+ ],+ },+ TerminalTheme {+ name: "Spacedust",+ background: [10, 30, 36],+ foreground: [236, 240, 193],+ palette: [+ [110, 83, 70],+ [227, 91, 0],+ [92, 171, 150],+ [227, 205, 123],+ [15, 84, 139],+ [227, 91, 0],+ [6, 175, 199],+ [240, 241, 206],+ [104, 76, 49],+ [255, 138, 58],+ [174, 202, 184],+ [255, 200, 120],+ [103, 160, 206],+ [255, 138, 58],+ [131, 167, 180],+ [254, 255, 241],+ ],+ },+ TerminalTheme {+ name: "Spacegray",+ background: [32, 36, 45],+ foreground: [179, 184, 195],+ palette: [+ [0, 0, 0],+ [176, 75, 87],+ [135, 179, 121],+ [229, 193, 121],+ [125, 143, 164],+ [164, 121, 150],+ [133, 167, 165],+ [179, 184, 195],+ [76, 76, 76],+ [176, 75, 87],+ [135, 179, 121],+ [229, 193, 121],+ [125, 143, 164],+ [164, 121, 150],+ [133, 167, 165],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Spacegray Bright",+ background: [42, 46, 58],+ foreground: [243, 243, 243],+ palette: [+ [8, 8, 8],+ [188, 85, 83],+ [160, 181, 108],+ [246, 201, 135],+ [123, 174, 193],+ [185, 138, 174],+ [133, 201, 184],+ [216, 216, 216],+ [98, 98, 98],+ [188, 85, 83],+ [160, 181, 108],+ [246, 201, 135],+ [123, 174, 193],+ [185, 138, 174],+ [133, 201, 184],+ [247, 247, 247],+ ],+ },+ TerminalTheme {+ name: "Spacegray Eighties",+ background: [34, 34, 34],+ foreground: [189, 186, 174],+ palette: [+ [21, 23, 28],+ [236, 95, 103],+ [129, 167, 100],+ [254, 194, 84],+ [84, 134, 192],+ [191, 131, 193],+ [87, 194, 193],+ [239, 236, 231],+ [85, 85, 85],+ [255, 105, 115],+ [147, 212, 147],+ [255, 210, 86],+ [77, 132, 209],+ [255, 85, 255],+ [131, 233, 228],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Spacegray Eighties Dull",+ background: [34, 34, 34],+ foreground: [201, 198, 188],+ palette: [+ [21, 23, 28],+ [178, 74, 86],+ [146, 180, 119],+ [198, 115, 90],+ [124, 143, 165],+ [165, 120, 158],+ [128, 205, 203],+ [179, 184, 195],+ [85, 85, 85],+ [236, 95, 103],+ [137, 233, 134],+ [254, 194, 84],+ [84, 134, 192],+ [191, 131, 193],+ [88, 194, 193],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Spiderman",+ background: [27, 29, 30],+ foreground: [227, 227, 227],+ palette: [+ [27, 29, 30],+ [230, 8, 19],+ [226, 41, 40],+ [226, 71, 86],+ [44, 63, 255],+ [36, 53, 219],+ [50, 86, 255],+ [255, 254, 246],+ [80, 83, 84],+ [255, 3, 37],+ [255, 51, 56],+ [254, 58, 53],+ [29, 80, 255],+ [116, 124, 255],+ [97, 132, 255],+ [255, 255, 249],+ ],+ },+ TerminalTheme {+ name: "Spring",+ background: [255, 255, 255],+ foreground: [77, 77, 76],+ palette: [+ [0, 0, 0],+ [255, 77, 131],+ [31, 140, 59],+ [31, 201, 91],+ [29, 211, 238],+ [137, 89, 168],+ [62, 153, 159],+ [191, 191, 191],+ [0, 0, 0],+ [255, 0, 33],+ [31, 194, 49],+ [213, 184, 7],+ [21, 169, 253],+ [137, 89, 168],+ [62, 153, 159],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Square",+ background: [26, 26, 26],+ foreground: [172, 172, 171],+ palette: [+ [5, 5, 5],+ [233, 137, 124],+ [182, 55, 125],+ [236, 235, 190],+ [169, 205, 235],+ [117, 80, 123],+ [201, 202, 236],+ [242, 242, 242],+ [71, 71, 71],+ [249, 146, 134],+ [195, 247, 134],+ [252, 251, 204],+ [182, 222, 251],+ [173, 127, 168],+ [215, 217, 252],+ [226, 226, 226],+ ],+ },+ TerminalTheme {+ name: "Squirrelsong Dark",+ background: [55, 41, 32],+ foreground: [177, 155, 137],+ palette: [+ [55, 41, 32],+ [186, 65, 56],+ [70, 131, 54],+ [212, 177, 57],+ [67, 149, 198],+ [133, 95, 184],+ [47, 151, 148],+ [211, 185, 162],+ [112, 79, 57],+ [223, 77, 67],+ [101, 154, 76],+ [232, 194, 63],+ [76, 164, 219],+ [157, 112, 218],+ [96, 172, 169],+ [242, 212, 187],+ ],+ },+ TerminalTheme {+ name: "Srcery",+ background: [28, 27, 25],+ foreground: [252, 232, 195],+ palette: [+ [28, 27, 25],+ [239, 47, 39],+ [81, 159, 80],+ [251, 184, 41],+ [44, 120, 191],+ [224, 44, 109],+ [10, 174, 179],+ [186, 166, 127],+ [145, 129, 117],+ [247, 83, 65],+ [152, 188, 55],+ [254, 208, 110],+ [104, 168, 228],+ [255, 92, 143],+ [43, 228, 208],+ [252, 232, 195],+ ],+ },+ TerminalTheme {+ name: "Starlight",+ background: [36, 36, 36],+ foreground: [255, 255, 255],+ palette: [+ [36, 36, 36],+ [246, 43, 90],+ [71, 180, 19],+ [227, 196, 1],+ [36, 172, 212],+ [242, 175, 253],+ [19, 194, 153],+ [230, 230, 230],+ [97, 97, 97],+ [255, 77, 81],+ [53, 212, 80],+ [233, 232, 54],+ [93, 197, 248],+ [254, 171, 242],+ [36, 223, 196],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Sublette",+ background: [32, 37, 53],+ foreground: [204, 206, 208],+ palette: [+ [37, 48, 69],+ [238, 85, 119],+ [85, 238, 119],+ [255, 221, 136],+ [85, 136, 255],+ [255, 119, 204],+ [68, 238, 238],+ [245, 245, 218],+ [64, 85, 112],+ [238, 102, 85],+ [153, 238, 119],+ [255, 255, 119],+ [119, 187, 255],+ [170, 136, 255],+ [85, 255, 187],+ [255, 255, 238],+ ],+ },+ TerminalTheme {+ name: "Subliminal",+ background: [40, 44, 53],+ foreground: [212, 212, 212],+ palette: [+ [127, 127, 127],+ [225, 90, 96],+ [169, 207, 164],+ [255, 226, 169],+ [102, 153, 204],+ [241, 165, 171],+ [95, 179, 179],+ [212, 212, 212],+ [127, 127, 127],+ [225, 90, 96],+ [169, 207, 164],+ [255, 226, 169],+ [102, 153, 204],+ [241, 165, 171],+ [95, 179, 179],+ [212, 212, 212],+ ],+ },+ TerminalTheme {+ name: "Sugarplum",+ background: [17, 17, 71],+ foreground: [219, 125, 221],+ palette: [+ [17, 17, 71],+ [92, 168, 220],+ [83, 179, 151],+ [36, 154, 132],+ [219, 125, 221],+ [208, 190, 238],+ [249, 243, 249],+ [161, 117, 212],+ [68, 68, 122],+ [92, 181, 220],+ [82, 222, 181],+ [1, 245, 199],+ [250, 93, 253],+ [198, 165, 253],+ [255, 255, 255],+ [181, 119, 253],+ ],+ },+ TerminalTheme {+ name: "Sundried",+ background: [26, 24, 24],+ foreground: [201, 201, 201],+ palette: [+ [48, 43, 42],+ [167, 70, 61],+ [88, 119, 68],+ [157, 96, 42],+ [72, 91, 152],+ [134, 70, 81],+ [156, 129, 79],+ [201, 201, 201],+ [77, 78, 72],+ [170, 0, 12],+ [18, 140, 33],+ [252, 106, 33],+ [121, 153, 247],+ [253, 138, 161],+ [250, 212, 132],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Sunset Drive",+ background: [15, 15, 26],+ foreground: [237, 237, 254],+ palette: [+ [10, 10, 19],+ [255, 0, 99],+ [0, 249, 146],+ [255, 233, 0],+ [0, 164, 255],+ [255, 87, 253],+ [0, 255, 237],+ [237, 237, 255],+ [62, 62, 75],+ [255, 148, 139],+ [0, 252, 185],+ [255, 255, 104],+ [62, 160, 255],+ [255, 147, 255],+ [56, 255, 255],+ [248, 248, 255],+ ],+ },+ TerminalTheme {+ name: "Symfonic",+ background: [0, 0, 0],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [220, 50, 47],+ [86, 219, 58],+ [255, 132, 0],+ [0, 132, 212],+ [183, 41, 217],+ [204, 204, 255],+ [255, 255, 255],+ [65, 67, 71],+ [220, 50, 47],+ [86, 219, 58],+ [255, 132, 0],+ [0, 132, 212],+ [183, 41, 217],+ [204, 204, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Synthwave",+ background: [0, 0, 0],+ foreground: [218, 217, 199],+ palette: [+ [0, 0, 0],+ [246, 24, 143],+ [30, 187, 43],+ [253, 248, 52],+ [33, 134, 236],+ [248, 90, 33],+ [18, 195, 226],+ [255, 255, 255],+ [127, 112, 148],+ [248, 65, 160],+ [37, 193, 65],+ [253, 244, 84],+ [47, 157, 237],+ [249, 113, 55],+ [25, 205, 230],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Synthwave Alpha",+ background: [36, 27, 48],+ foreground: [242, 242, 227],+ palette: [+ [36, 27, 48],+ [230, 10, 112],+ [0, 152, 108],+ [173, 173, 62],+ [110, 41, 173],+ [179, 0, 173],+ [0, 176, 177],+ [185, 177, 188],+ [127, 112, 148],+ [230, 10, 112],+ [10, 228, 164],+ [249, 249, 114],+ [170, 84, 249],+ [255, 0, 246],+ [0, 251, 253],+ [242, 242, 227],+ ],+ },+ TerminalTheme {+ name: "Synthwave Everything",+ background: [42, 33, 57],+ foreground: [240, 239, 241],+ palette: [+ [254, 254, 254],+ [249, 126, 114],+ [114, 241, 184],+ [254, 222, 93],+ [109, 119, 179],+ [199, 146, 234],+ [247, 114, 224],+ [254, 254, 254],+ [254, 254, 254],+ [248, 132, 20],+ [114, 241, 184],+ [255, 249, 81],+ [54, 249, 246],+ [225, 172, 255],+ [249, 42, 173],+ [254, 254, 254],+ ],+ },+ TerminalTheme {+ name: "Tango Adapted",+ background: [255, 255, 255],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [255, 0, 0],+ [89, 214, 0],+ [227, 190, 0],+ [0, 162, 255],+ [193, 126, 204],+ [0, 208, 214],+ [192, 197, 187],+ [143, 146, 139],+ [255, 0, 19],+ [109, 217, 0],+ [204, 190, 0],+ [136, 201, 255],+ [233, 167, 225],+ [0, 216, 217],+ [246, 246, 244],+ ],+ },+ TerminalTheme {+ name: "Tango Half Adapted",+ background: [255, 255, 255],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [255, 0, 0],+ [76, 195, 0],+ [226, 192, 0],+ [0, 142, 246],+ [169, 108, 179],+ [0, 189, 195],+ [186, 191, 181],+ [121, 125, 118],+ [255, 0, 19],+ [112, 220, 0],+ [217, 198, 0],+ [118, 191, 255],+ [216, 152, 209],+ [0, 208, 212],+ [244, 244, 242],+ ],+ },+ TerminalTheme {+ name: "Tearout",+ background: [52, 57, 45],+ foreground: [244, 210, 174],+ palette: [+ [104, 87, 66],+ [204, 150, 123],+ [151, 151, 109],+ [108, 152, 97],+ [181, 149, 94],+ [201, 165, 84],+ [215, 196, 131],+ [181, 149, 94],+ [117, 100, 79],+ [204, 150, 123],+ [151, 151, 109],+ [108, 152, 97],+ [181, 149, 94],+ [201, 165, 84],+ [215, 196, 131],+ [181, 149, 94],+ ],+ },+ TerminalTheme {+ name: "Teerb",+ background: [38, 38, 38],+ foreground: [208, 208, 208],+ palette: [+ [28, 28, 28],+ [214, 134, 134],+ [174, 214, 134],+ [215, 175, 135],+ [134, 174, 214],+ [214, 174, 214],+ [138, 219, 180],+ [208, 208, 208],+ [79, 79, 79],+ [214, 134, 134],+ [174, 214, 134],+ [228, 201, 175],+ [134, 174, 214],+ [214, 174, 214],+ [177, 231, 221],+ [239, 239, 239],+ ],+ },+ TerminalTheme {+ name: "Terafox",+ background: [21, 37, 40],+ foreground: [230, 234, 234],+ palette: [+ [47, 50, 57],+ [232, 92, 81],+ [122, 164, 161],+ [253, 164, 127],+ [90, 147, 170],+ [173, 92, 124],+ [161, 205, 216],+ [235, 235, 235],+ [78, 81, 87],+ [235, 116, 107],+ [142, 178, 175],+ [253, 178, 146],+ [115, 163, 183],+ [185, 116, 144],+ [175, 212, 222],+ [238, 238, 238],+ ],+ },+ TerminalTheme {+ name: "Terminal Basic",+ background: [255, 255, 255],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [153, 0, 0],+ [0, 166, 0],+ [153, 153, 0],+ [0, 0, 178],+ [178, 0, 178],+ [0, 166, 178],+ [191, 191, 191],+ [102, 102, 102],+ [229, 0, 0],+ [0, 217, 0],+ [191, 191, 0],+ [0, 0, 255],+ [229, 0, 229],+ [0, 216, 216],+ [229, 229, 229],+ ],+ },+ TerminalTheme {+ name: "Terminal Basic Dark",+ background: [29, 30, 29],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [198, 83, 57],+ [106, 196, 75],+ [184, 183, 74],+ [100, 68, 237],+ [211, 87, 219],+ [105, 193, 207],+ [209, 209, 209],+ [144, 144, 144],+ [235, 90, 58],+ [119, 234, 81],+ [239, 239, 83],+ [208, 154, 249],+ [235, 90, 247],+ [120, 241, 242],+ [237, 237, 237],+ ],+ },+ TerminalTheme {+ name: "Thayer Bright",+ background: [27, 29, 30],+ foreground: [248, 248, 248],+ palette: [+ [27, 29, 30],+ [249, 38, 114],+ [77, 248, 64],+ [244, 253, 34],+ [39, 87, 214],+ [140, 84, 254],+ [56, 200, 181],+ [204, 204, 198],+ [80, 83, 84],+ [255, 89, 149],+ [182, 227, 84],+ [254, 237, 108],+ [63, 120, 255],+ [158, 111, 254],+ [35, 207, 213],+ [248, 248, 242],+ ],+ },+ TerminalTheme {+ name: "The Hulk",+ background: [27, 29, 30],+ foreground: [181, 181, 181],+ palette: [+ [27, 29, 30],+ [38, 157, 27],+ [19, 206, 48],+ [99, 228, 87],+ [37, 37, 245],+ [113, 44, 129],+ [55, 140, 169],+ [217, 216, 209],+ [80, 83, 84],+ [141, 255, 42],+ [72, 255, 119],+ [58, 254, 22],+ [80, 107, 149],+ [114, 88, 157],+ [64, 133, 166],+ [229, 230, 225],+ ],+ },+ TerminalTheme {+ name: "Tinacious Design Dark",+ background: [29, 29, 38],+ foreground: [203, 203, 240],+ palette: [+ [29, 29, 38],+ [255, 51, 153],+ [0, 211, 100],+ [255, 204, 102],+ [0, 203, 255],+ [204, 102, 255],+ [0, 206, 202],+ [203, 203, 240],+ [99, 102, 103],+ [255, 47, 146],+ [0, 211, 100],+ [255, 212, 121],+ [0, 203, 255],+ [215, 131, 255],+ [0, 213, 212],+ [213, 214, 243],+ ],+ },+ TerminalTheme {+ name: "Tinacious Design Light",+ background: [248, 248, 255],+ foreground: [29, 29, 38],+ palette: [+ [29, 29, 38],+ [255, 51, 153],+ [0, 211, 100],+ [229, 178, 77],+ [0, 203, 255],+ [204, 102, 255],+ [0, 206, 202],+ [177, 177, 214],+ [99, 102, 103],+ [255, 47, 146],+ [0, 211, 100],+ [217, 174, 83],+ [0, 203, 255],+ [215, 131, 255],+ [0, 200, 199],+ [213, 214, 243],+ ],+ },+ TerminalTheme {+ name: "TokyoNight",+ background: [26, 27, 38],+ foreground: [192, 202, 245],+ palette: [+ [21, 22, 30],+ [247, 118, 142],+ [158, 206, 106],+ [224, 175, 104],+ [122, 162, 247],+ [187, 154, 247],+ [125, 207, 255],+ [169, 177, 214],+ [65, 72, 104],+ [247, 118, 142],+ [158, 206, 106],+ [224, 175, 104],+ [122, 162, 247],+ [187, 154, 247],+ [125, 207, 255],+ [192, 202, 245],+ ],+ },+ TerminalTheme {+ name: "TokyoNight Day",+ background: [225, 226, 231],+ foreground: [55, 96, 191],+ palette: [+ [233, 233, 237],+ [245, 42, 101],+ [88, 117, 57],+ [140, 108, 62],+ [46, 125, 233],+ [152, 84, 241],+ [0, 113, 151],+ [97, 114, 176],+ [161, 166, 197],+ [245, 42, 101],+ [88, 117, 57],+ [140, 108, 62],+ [46, 125, 233],+ [152, 84, 241],+ [0, 113, 151],+ [55, 96, 191],+ ],+ },+ TerminalTheme {+ name: "TokyoNight Moon",+ background: [34, 36, 54],+ foreground: [200, 211, 245],+ palette: [+ [27, 29, 43],+ [255, 117, 127],+ [195, 232, 141],+ [255, 199, 119],+ [130, 170, 255],+ [192, 153, 255],+ [134, 225, 252],+ [130, 139, 184],+ [68, 74, 115],+ [255, 117, 127],+ [195, 232, 141],+ [255, 199, 119],+ [130, 170, 255],+ [192, 153, 255],+ [134, 225, 252],+ [200, 211, 245],+ ],+ },+ TerminalTheme {+ name: "TokyoNight Night",+ background: [26, 27, 38],+ foreground: [192, 202, 245],+ palette: [+ [21, 22, 30],+ [247, 118, 142],+ [158, 206, 106],+ [224, 175, 104],+ [122, 162, 247],+ [187, 154, 247],+ [125, 207, 255],+ [169, 177, 214],+ [65, 72, 104],+ [247, 118, 142],+ [158, 206, 106],+ [224, 175, 104],+ [122, 162, 247],+ [187, 154, 247],+ [125, 207, 255],+ [192, 202, 245],+ ],+ },+ TerminalTheme {+ name: "TokyoNight Storm",+ background: [36, 40, 59],+ foreground: [192, 202, 245],+ palette: [+ [29, 32, 47],+ [247, 118, 142],+ [158, 206, 106],+ [224, 175, 104],+ [122, 162, 247],+ [187, 154, 247],+ [125, 207, 255],+ [169, 177, 214],+ [78, 85, 117],+ [247, 118, 142],+ [158, 206, 106],+ [224, 175, 104],+ [122, 162, 247],+ [187, 154, 247],+ [125, 207, 255],+ [192, 202, 245],+ ],+ },+ TerminalTheme {+ name: "Tomorrow",+ background: [255, 255, 255],+ foreground: [77, 77, 76],+ palette: [+ [0, 0, 0],+ [200, 40, 41],+ [113, 140, 0],+ [234, 183, 0],+ [66, 113, 174],+ [137, 89, 168],+ [62, 153, 159],+ [191, 191, 191],+ [0, 0, 0],+ [200, 40, 41],+ [113, 140, 0],+ [234, 183, 0],+ [66, 113, 174],+ [137, 89, 168],+ [62, 153, 159],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Tomorrow Night",+ background: [29, 31, 33],+ foreground: [197, 200, 198],+ palette: [+ [0, 0, 0],+ [204, 102, 102],+ [181, 189, 104],+ [240, 198, 116],+ [129, 162, 190],+ [178, 148, 187],+ [138, 190, 183],+ [255, 255, 255],+ [76, 76, 76],+ [204, 102, 102],+ [181, 189, 104],+ [240, 198, 116],+ [129, 162, 190],+ [178, 148, 187],+ [138, 190, 183],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Tomorrow Night Blue",+ background: [0, 36, 81],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [255, 157, 164],+ [209, 241, 169],+ [255, 238, 173],+ [187, 218, 255],+ [235, 187, 255],+ [153, 255, 255],+ [255, 255, 255],+ [76, 76, 76],+ [255, 157, 164],+ [209, 241, 169],+ [255, 238, 173],+ [187, 218, 255],+ [235, 187, 255],+ [153, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Tomorrow Night Bright",+ background: [0, 0, 0],+ foreground: [234, 234, 234],+ palette: [+ [0, 0, 0],+ [213, 78, 83],+ [185, 202, 74],+ [231, 197, 71],+ [122, 166, 218],+ [195, 151, 216],+ [112, 192, 177],+ [255, 255, 255],+ [64, 64, 64],+ [213, 78, 83],+ [185, 202, 74],+ [231, 197, 71],+ [122, 166, 218],+ [195, 151, 216],+ [112, 192, 177],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Tomorrow Night Burns",+ background: [21, 21, 21],+ foreground: [161, 176, 184],+ palette: [+ [37, 37, 37],+ [131, 46, 49],+ [166, 60, 64],+ [211, 73, 78],+ [252, 89, 95],+ [223, 147, 149],+ [186, 133, 134],+ [245, 245, 245],+ [93, 111, 113],+ [131, 46, 49],+ [166, 60, 64],+ [210, 73, 78],+ [252, 89, 95],+ [223, 147, 149],+ [186, 133, 134],+ [245, 245, 245],+ ],+ },+ TerminalTheme {+ name: "Tomorrow Night Eighties",+ background: [45, 45, 45],+ foreground: [204, 204, 204],+ palette: [+ [0, 0, 0],+ [242, 119, 122],+ [153, 204, 153],+ [255, 204, 102],+ [102, 153, 204],+ [204, 153, 204],+ [102, 204, 204],+ [255, 255, 255],+ [89, 89, 89],+ [242, 119, 122],+ [153, 204, 153],+ [255, 204, 102],+ [102, 153, 204],+ [204, 153, 204],+ [102, 204, 204],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Toy Chest",+ background: [36, 54, 75],+ foreground: [49, 208, 123],+ palette: [+ [44, 63, 88],+ [190, 45, 38],+ [26, 145, 114],+ [219, 142, 39],+ [50, 93, 150],+ [138, 94, 220],+ [53, 160, 143],+ [35, 209, 131],+ [51, 104, 137],+ [221, 89, 68],+ [49, 208, 123],+ [231, 216, 75],+ [52, 166, 218],+ [174, 107, 220],+ [66, 195, 174],+ [213, 213, 213],+ ],+ },+ TerminalTheme {+ name: "Treehouse",+ background: [25, 25, 25],+ foreground: [120, 107, 83],+ palette: [+ [50, 19, 0],+ [178, 39, 14],+ [68, 169, 0],+ [170, 130, 12],+ [88, 133, 154],+ [151, 54, 61],+ [178, 90, 30],+ [120, 107, 83],+ [80, 67, 51],+ [237, 93, 32],+ [85, 242, 56],+ [242, 183, 50],+ [133, 207, 237],+ [225, 76, 90],+ [240, 125, 20],+ [255, 200, 0],+ ],+ },+ TerminalTheme {+ name: "Twilight",+ background: [20, 20, 20],+ foreground: [255, 255, 212],+ palette: [+ [20, 20, 20],+ [192, 109, 68],+ [175, 185, 122],+ [194, 168, 108],+ [68, 71, 74],+ [180, 190, 124],+ [119, 131, 133],+ [255, 255, 212],+ [64, 64, 64],+ [222, 124, 76],+ [204, 216, 140],+ [226, 196, 126],+ [90, 94, 98],+ [208, 220, 142],+ [138, 152, 155],+ [255, 255, 212],+ ],+ },+ TerminalTheme {+ name: "Ubuntu",+ background: [48, 10, 36],+ foreground: [238, 238, 236],+ palette: [+ [46, 52, 54],+ [204, 0, 0],+ [78, 154, 6],+ [196, 160, 0],+ [52, 101, 164],+ [117, 80, 123],+ [6, 152, 154],+ [211, 215, 207],+ [85, 87, 83],+ [239, 41, 41],+ [138, 226, 52],+ [252, 233, 79],+ [114, 159, 207],+ [173, 127, 168],+ [52, 226, 226],+ [238, 238, 236],+ ],+ },+ TerminalTheme {+ name: "Ultra Dark",+ background: [0, 0, 0],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [240, 113, 120],+ [195, 232, 141],+ [255, 203, 107],+ [130, 170, 255],+ [199, 146, 234],+ [137, 221, 255],+ [204, 204, 204],+ [64, 64, 64],+ [246, 169, 174],+ [219, 241, 186],+ [255, 223, 166],+ [180, 204, 255],+ [221, 189, 242],+ [184, 234, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Ultra Violent",+ background: [36, 39, 40],+ foreground: [193, 193, 193],+ palette: [+ [36, 39, 40],+ [255, 0, 144],+ [182, 255, 0],+ [255, 247, 39],+ [71, 224, 251],+ [215, 49, 255],+ [14, 255, 187],+ [225, 225, 225],+ [99, 102, 103],+ [251, 88, 180],+ [222, 255, 140],+ [235, 224, 135],+ [127, 236, 255],+ [230, 129, 255],+ [105, 252, 211],+ [249, 249, 245],+ ],+ },+ TerminalTheme {+ name: "Under The Sea",+ background: [1, 17, 22],+ foreground: [255, 255, 255],+ palette: [+ [2, 32, 38],+ [178, 48, 45],+ [0, 169, 65],+ [89, 129, 156],+ [69, 154, 134],+ [0, 89, 157],+ [93, 126, 25],+ [64, 85, 85],+ [56, 68, 81],+ [255, 66, 66],+ [42, 234, 94],+ [142, 212, 253],+ [97, 213, 186],+ [18, 152, 255],+ [152, 208, 40],+ [88, 251, 214],+ ],+ },+ TerminalTheme {+ name: "Unikitty",+ background: [255, 140, 217],+ foreground: [11, 11, 11],+ palette: [+ [12, 12, 12],+ [168, 15, 32],+ [199, 255, 152],+ [255, 249, 100],+ [20, 95, 205],+ [255, 233, 255],+ [158, 255, 239],+ [252, 241, 251],+ [67, 67, 67],+ [217, 19, 41],+ [211, 255, 175],+ [255, 239, 80],+ [0, 117, 234],+ [255, 239, 255],+ [147, 255, 239],+ [255, 243, 254],+ ],+ },+ TerminalTheme {+ name: "Urple",+ background: [27, 27, 35],+ foreground: [135, 122, 155],+ palette: [+ [0, 0, 0],+ [176, 66, 91],+ [55, 164, 21],+ [173, 92, 66],+ [86, 77, 155],+ [108, 60, 161],+ [128, 128, 128],+ [135, 121, 156],+ [106, 63, 50],+ [255, 99, 136],+ [41, 230, 32],+ [240, 129, 97],+ [134, 122, 237],+ [160, 94, 238],+ [234, 234, 234],+ [191, 163, 255],+ ],+ },+ TerminalTheme {+ name: "Vague",+ background: [20, 20, 21],+ foreground: [205, 205, 205],+ palette: [+ [37, 37, 48],+ [216, 100, 126],+ [127, 165, 99],+ [243, 190, 124],+ [110, 148, 178],+ [187, 157, 189],+ [174, 174, 209],+ [205, 205, 205],+ [96, 96, 121],+ [224, 131, 152],+ [153, 183, 130],+ [245, 203, 150],+ [139, 169, 193],+ [201, 177, 202],+ [190, 190, 218],+ [215, 215, 215],+ ],+ },+ TerminalTheme {+ name: "Vaughn",+ background: [37, 35, 79],+ foreground: [220, 220, 204],+ palette: [+ [37, 35, 79],+ [112, 80, 80],+ [96, 180, 138],+ [223, 175, 143],+ [85, 85, 255],+ [240, 140, 195],+ [140, 208, 211],+ [112, 144, 128],+ [112, 144, 128],+ [220, 163, 163],+ [96, 180, 138],+ [240, 223, 175],+ [85, 85, 255],+ [236, 147, 211],+ [147, 224, 227],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Vercel",+ background: [16, 16, 16],+ foreground: [250, 250, 250],+ palette: [+ [0, 0, 0],+ [252, 0, 54],+ [41, 169, 72],+ [255, 174, 0],+ [0, 106, 255],+ [243, 40, 130],+ [0, 172, 150],+ [254, 255, 255],+ [168, 168, 168],+ [255, 128, 128],+ [75, 225, 93],+ [255, 174, 0],+ [73, 174, 255],+ [249, 126, 168],+ [0, 228, 196],+ [254, 254, 254],+ ],+ },+ TerminalTheme {+ name: "Vesper",+ background: [16, 16, 16],+ foreground: [255, 255, 255],+ palette: [+ [16, 16, 16],+ [245, 161, 145],+ [144, 185, 159],+ [230, 185, 157],+ [172, 161, 207],+ [226, 158, 202],+ [234, 131, 165],+ [160, 160, 160],+ [126, 126, 126],+ [255, 128, 128],+ [153, 255, 228],+ [255, 199, 153],+ [185, 174, 218],+ [236, 170, 214],+ [245, 145, 178],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Vibrant Ink",+ background: [0, 0, 0],+ foreground: [255, 255, 255],+ palette: [+ [135, 135, 135],+ [255, 102, 0],+ [204, 255, 4],+ [255, 204, 0],+ [68, 180, 204],+ [153, 51, 204],+ [68, 180, 204],+ [245, 245, 245],+ [85, 85, 85],+ [255, 0, 0],+ [0, 255, 0],+ [255, 255, 0],+ [0, 0, 255],+ [255, 0, 255],+ [0, 255, 255],+ [229, 229, 229],+ ],+ },+ TerminalTheme {+ name: "Vimbones",+ background: [240, 240, 202],+ foreground: [53, 53, 53],+ palette: [+ [240, 240, 202],+ [168, 51, 76],+ [79, 108, 49],+ [148, 73, 39],+ [40, 100, 134],+ [136, 80, 125],+ [59, 137, 146],+ [53, 53, 53],+ [172, 172, 137],+ [148, 37, 62],+ [63, 90, 34],+ [128, 61, 28],+ [29, 85, 115],+ [123, 59, 112],+ [43, 116, 124],+ [92, 92, 92],+ ],+ },+ TerminalTheme {+ name: "Violet Dark",+ background: [28, 29, 31],+ foreground: [112, 130, 132],+ palette: [+ [86, 89, 92],+ [201, 76, 34],+ [133, 152, 28],+ [180, 136, 29],+ [46, 139, 206],+ [209, 58, 130],+ [50, 161, 152],+ [201, 198, 189],+ [69, 72, 75],+ [189, 54, 19],+ [115, 138, 4],+ [165, 119, 5],+ [33, 118, 199],+ [198, 28, 111],+ [37, 146, 134],+ [201, 198, 189],+ ],+ },+ TerminalTheme {+ name: "Violet Light",+ background: [252, 244, 220],+ foreground: [83, 104, 112],+ palette: [+ [86, 89, 92],+ [201, 76, 34],+ [133, 152, 28],+ [180, 136, 29],+ [46, 139, 206],+ [209, 58, 130],+ [50, 161, 152],+ [185, 182, 175],+ [69, 72, 75],+ [189, 54, 19],+ [115, 138, 4],+ [165, 119, 5],+ [33, 118, 199],+ [198, 28, 111],+ [37, 146, 134],+ [201, 198, 189],+ ],+ },+ TerminalTheme {+ name: "Violite",+ background: [36, 28, 54],+ foreground: [238, 244, 246],+ palette: [+ [36, 28, 54],+ [236, 121, 121],+ [121, 236, 179],+ [236, 226, 121],+ [169, 121, 236],+ [236, 121, 236],+ [121, 236, 236],+ [238, 244, 246],+ [86, 68, 122],+ [239, 143, 143],+ [159, 239, 191],+ [239, 231, 143],+ [183, 143, 239],+ [239, 143, 207],+ [159, 239, 239],+ [248, 250, 252],+ ],+ },+ TerminalTheme {+ name: "Warm Neon",+ background: [64, 64, 64],+ foreground: [175, 218, 182],+ palette: [+ [0, 0, 0],+ [226, 67, 70],+ [57, 177, 58],+ [218, 225, 69],+ [66, 97, 197],+ [249, 32, 251],+ [42, 187, 212],+ [208, 184, 163],+ [254, 252, 252],+ [233, 112, 113],+ [156, 192, 144],+ [221, 218, 122],+ [123, 145, 214],+ [246, 116, 186],+ [94, 209, 229],+ [216, 200, 187],+ ],+ },+ TerminalTheme {+ name: "Wez",+ background: [0, 0, 0],+ foreground: [179, 179, 179],+ palette: [+ [0, 0, 0],+ [204, 85, 85],+ [85, 204, 85],+ [205, 205, 85],+ [85, 85, 204],+ [204, 85, 204],+ [122, 202, 202],+ [204, 204, 204],+ [85, 85, 85],+ [255, 85, 85],+ [85, 255, 85],+ [255, 255, 85],+ [85, 85, 255],+ [255, 85, 255],+ [85, 255, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Whimsy",+ background: [41, 40, 59],+ foreground: [179, 176, 214],+ palette: [+ [83, 81, 120],+ [239, 100, 135],+ [94, 202, 137],+ [253, 216, 119],+ [101, 174, 247],+ [170, 127, 240],+ [67, 193, 190],+ [255, 255, 255],+ [83, 81, 120],+ [239, 100, 135],+ [94, 202, 137],+ [253, 216, 119],+ [101, 174, 247],+ [170, 127, 240],+ [67, 193, 190],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Wild Cherry",+ background: [31, 23, 38],+ foreground: [218, 250, 255],+ palette: [+ [0, 5, 7],+ [217, 64, 133],+ [42, 178, 80],+ [255, 209, 111],+ [136, 60, 220],+ [236, 236, 236],+ [193, 184, 183],+ [255, 248, 222],+ [0, 156, 201],+ [218, 107, 172],+ [244, 220, 165],+ [234, 192, 102],+ [48, 140, 186],+ [174, 99, 107],+ [255, 145, 157],+ [228, 131, 141],+ ],+ },+ TerminalTheme {+ name: "Wilmersdorf",+ background: [40, 43, 51],+ foreground: [198, 198, 198],+ palette: [+ [52, 55, 62],+ [224, 99, 131],+ [126, 190, 189],+ [204, 204, 204],+ [166, 193, 224],+ [225, 193, 238],+ [91, 148, 171],+ [171, 171, 171],+ [80, 84, 93],+ [250, 113, 147],+ [143, 215, 214],+ [209, 223, 255],+ [178, 207, 240],+ [239, 204, 253],+ [105, 171, 197],+ [211, 211, 211],+ ],+ },+ TerminalTheme {+ name: "Wombat",+ background: [23, 23, 23],+ foreground: [222, 218, 207],+ palette: [+ [0, 0, 0],+ [255, 97, 90],+ [177, 233, 105],+ [235, 217, 156],+ [93, 169, 246],+ [232, 106, 255],+ [130, 255, 247],+ [222, 218, 207],+ [74, 74, 74],+ [245, 140, 128],+ [221, 248, 143],+ [238, 229, 178],+ [165, 199, 255],+ [221, 170, 255],+ [183, 255, 249],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Wryan",+ background: [16, 16, 16],+ foreground: [153, 153, 147],+ palette: [+ [51, 51, 51],+ [140, 70, 101],+ [40, 115, 115],+ [124, 124, 153],+ [57, 85, 115],+ [94, 70, 140],+ [49, 101, 140],+ [137, 156, 161],+ [61, 61, 61],+ [191, 77, 128],+ [83, 166, 166],+ [158, 158, 203],+ [71, 122, 179],+ [126, 98, 179],+ [96, 150, 191],+ [192, 192, 192],+ ],+ },+ TerminalTheme {+ name: "Xcode Dark",+ background: [41, 42, 48],+ foreground: [223, 223, 224],+ palette: [+ [65, 68, 83],+ [255, 129, 112],+ [120, 194, 179],+ [217, 201, 124],+ [78, 176, 204],+ [255, 122, 178],+ [178, 129, 235],+ [223, 223, 224],+ [127, 140, 152],+ [255, 129, 112],+ [172, 242, 228],+ [255, 161, 79],+ [107, 223, 255],+ [255, 122, 178],+ [218, 186, 255],+ [223, 223, 224],+ ],+ },+ TerminalTheme {+ name: "Xcode Dark hc",+ background: [31, 31, 36],+ foreground: [255, 255, 255],+ palette: [+ [67, 69, 75],+ [255, 138, 122],+ [131, 201, 188],+ [217, 198, 104],+ [78, 196, 230],+ [255, 133, 184],+ [205, 161, 255],+ [255, 255, 255],+ [131, 137, 145],+ [255, 138, 122],+ [177, 250, 235],+ [255, 161, 79],+ [107, 223, 255],+ [255, 133, 184],+ [229, 207, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Xcode Light",+ background: [255, 255, 255],+ foreground: [38, 38, 38],+ palette: [+ [180, 216, 253],+ [209, 47, 27],+ [62, 128, 135],+ [120, 73, 42],+ [15, 104, 160],+ [173, 61, 164],+ [128, 79, 184],+ [38, 38, 38],+ [138, 153, 166],+ [209, 47, 27],+ [35, 87, 92],+ [120, 73, 42],+ [11, 79, 121],+ [173, 61, 164],+ [75, 33, 176],+ [38, 38, 38],+ ],+ },+ TerminalTheme {+ name: "Xcode Light hc",+ background: [255, 255, 255],+ foreground: [0, 0, 0],+ palette: [+ [180, 216, 253],+ [173, 24, 5],+ [53, 93, 97],+ [120, 73, 42],+ [0, 88, 161],+ [156, 33, 145],+ [112, 61, 170],+ [0, 0, 0],+ [138, 153, 166],+ [173, 24, 5],+ [23, 65, 69],+ [120, 73, 42],+ [0, 63, 115],+ [156, 33, 145],+ [68, 30, 161],+ [0, 0, 0],+ ],+ },+ TerminalTheme {+ name: "Xcode WWDC",+ background: [41, 44, 54],+ foreground: [231, 232, 235],+ palette: [+ [73, 77, 92],+ [187, 56, 58],+ [148, 198, 110],+ [210, 142, 93],+ [136, 132, 197],+ [183, 57, 153],+ [0, 171, 164],+ [231, 232, 235],+ [127, 134, 158],+ [187, 56, 58],+ [148, 198, 110],+ [210, 142, 93],+ [136, 132, 197],+ [183, 57, 153],+ [0, 171, 164],+ [231, 232, 235],+ ],+ },+ TerminalTheme {+ name: "Zenbones",+ background: [240, 237, 236],+ foreground: [44, 54, 60],+ palette: [+ [240, 237, 236],+ [168, 51, 76],+ [79, 108, 49],+ [148, 73, 39],+ [40, 100, 134],+ [136, 80, 125],+ [59, 137, 146],+ [44, 54, 60],+ [181, 167, 160],+ [148, 37, 62],+ [63, 90, 34],+ [128, 61, 28],+ [29, 85, 115],+ [123, 59, 112],+ [43, 116, 124],+ [79, 94, 104],+ ],+ },+ TerminalTheme {+ name: "Zenbones Dark",+ background: [28, 25, 23],+ foreground: [180, 189, 195],+ palette: [+ [28, 25, 23],+ [222, 110, 124],+ [129, 155, 105],+ [183, 126, 100],+ [96, 153, 192],+ [178, 121, 167],+ [102, 165, 173],+ [180, 189, 195],+ [77, 69, 64],+ [232, 131, 143],+ [139, 174, 104],+ [214, 140, 103],+ [97, 171, 218],+ [207, 134, 193],+ [101, 184, 193],+ [136, 143, 148],+ ],+ },+ TerminalTheme {+ name: "Zenbones Light",+ background: [240, 237, 236],+ foreground: [44, 54, 60],+ palette: [+ [240, 237, 236],+ [168, 51, 76],+ [79, 108, 49],+ [148, 73, 39],+ [40, 100, 134],+ [136, 80, 125],+ [59, 137, 146],+ [44, 54, 60],+ [181, 167, 160],+ [148, 37, 62],+ [63, 90, 34],+ [128, 61, 28],+ [29, 85, 115],+ [123, 59, 112],+ [43, 116, 124],+ [79, 94, 104],+ ],+ },+ TerminalTheme {+ name: "Zenburn",+ background: [63, 63, 63],+ foreground: [220, 220, 204],+ palette: [+ [77, 77, 77],+ [125, 93, 93],+ [96, 180, 138],+ [240, 223, 175],+ [93, 109, 125],+ [220, 140, 195],+ [140, 208, 211],+ [220, 220, 204],+ [112, 144, 128],+ [220, 163, 163],+ [195, 191, 159],+ [224, 207, 159],+ [148, 191, 243],+ [236, 147, 211],+ [147, 224, 227],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "Zenburned",+ background: [64, 64, 64],+ foreground: [240, 228, 207],+ palette: [+ [64, 64, 64],+ [227, 113, 110],+ [129, 155, 105],+ [183, 126, 100],+ [96, 153, 192],+ [178, 121, 167],+ [102, 165, 173],+ [240, 228, 207],+ [111, 103, 104],+ [236, 134, 133],+ [139, 174, 104],+ [214, 140, 103],+ [97, 171, 218],+ [207, 134, 193],+ [101, 184, 193],+ [192, 171, 134],+ ],+ },+ TerminalTheme {+ name: "Zenwritten Dark",+ background: [25, 25, 25],+ foreground: [187, 187, 187],+ palette: [+ [25, 25, 25],+ [222, 110, 124],+ [129, 155, 105],+ [183, 126, 100],+ [96, 153, 192],+ [178, 121, 167],+ [102, 165, 173],+ [187, 187, 187],+ [74, 69, 70],+ [232, 131, 143],+ [139, 174, 104],+ [214, 140, 103],+ [97, 171, 218],+ [207, 134, 193],+ [101, 184, 193],+ [142, 142, 142],+ ],+ },+ TerminalTheme {+ name: "Zenwritten Light",+ background: [238, 238, 238],+ foreground: [53, 53, 53],+ palette: [+ [238, 238, 238],+ [168, 51, 76],+ [79, 108, 49],+ [148, 73, 39],+ [40, 100, 134],+ [136, 80, 125],+ [59, 137, 146],+ [53, 53, 53],+ [172, 169, 169],+ [148, 37, 62],+ [63, 90, 34],+ [128, 61, 28],+ [29, 85, 115],+ [123, 59, 112],+ [43, 116, 124],+ [92, 92, 92],+ ],+ },+ TerminalTheme {+ name: "branch",+ background: [50, 34, 26],+ foreground: [207, 193, 169],+ palette: [+ [53, 36, 28],+ [194, 86, 45],+ [150, 166, 94],+ [210, 155, 90],+ [59, 142, 140],+ [196, 126, 91],+ [99, 154, 144],+ [207, 193, 169],+ [86, 74, 69],+ [194, 86, 45],+ [150, 166, 94],+ [210, 155, 90],+ [59, 142, 140],+ [196, 126, 91],+ [99, 154, 144],+ [207, 193, 169],+ ],+ },+ TerminalTheme {+ name: "iTerm2 Dark Background",+ background: [0, 0, 0],+ foreground: [199, 199, 199],+ palette: [+ [0, 0, 0],+ [201, 27, 0],+ [0, 194, 0],+ [199, 196, 0],+ [2, 37, 199],+ [202, 48, 199],+ [0, 197, 199],+ [199, 199, 199],+ [104, 104, 104],+ [255, 110, 103],+ [95, 250, 104],+ [255, 252, 103],+ [104, 113, 255],+ [255, 119, 255],+ [96, 253, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "iTerm2 Default",+ background: [0, 0, 0],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [201, 27, 0],+ [0, 194, 0],+ [199, 196, 0],+ [34, 37, 196],+ [202, 48, 199],+ [0, 197, 199],+ [255, 255, 255],+ [104, 104, 104],+ [255, 110, 103],+ [95, 250, 104],+ [255, 252, 103],+ [104, 113, 255],+ [255, 119, 255],+ [96, 253, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "iTerm2 Light Background",+ background: [255, 255, 255],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [201, 27, 0],+ [0, 194, 0],+ [199, 196, 0],+ [2, 37, 199],+ [202, 48, 199],+ [0, 197, 199],+ [186, 186, 186],+ [104, 104, 104],+ [255, 110, 103],+ [57, 212, 66],+ [204, 201, 52],+ [104, 113, 255],+ [255, 119, 255],+ [58, 215, 217],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "iTerm2 Pastel Dark Background",+ background: [0, 0, 0],+ foreground: [199, 199, 199],+ palette: [+ [98, 98, 98],+ [255, 131, 115],+ [180, 251, 115],+ [255, 253, 195],+ [165, 213, 254],+ [255, 144, 254],+ [209, 209, 254],+ [241, 241, 241],+ [143, 143, 143],+ [255, 196, 190],+ [214, 252, 186],+ [255, 254, 213],+ [194, 227, 255],+ [255, 178, 254],+ [230, 230, 254],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "iTerm2 Smoooooth",+ background: [21, 25, 31],+ foreground: [220, 220, 220],+ palette: [+ [20, 25, 30],+ [180, 60, 42],+ [0, 194, 0],+ [199, 196, 0],+ [39, 68, 199],+ [192, 64, 190],+ [0, 197, 199],+ [199, 199, 199],+ [104, 104, 104],+ [221, 121, 117],+ [88, 231, 144],+ [236, 225, 0],+ [167, 171, 242],+ [225, 126, 225],+ [96, 253, 255],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "iTerm2 Solarized Dark",+ background: [0, 43, 54],+ foreground: [131, 148, 150],+ palette: [+ [7, 54, 66],+ [220, 50, 47],+ [133, 153, 0],+ [181, 137, 0],+ [38, 139, 210],+ [211, 54, 130],+ [42, 161, 152],+ [238, 232, 213],+ [51, 94, 105],+ [203, 75, 22],+ [88, 110, 117],+ [101, 123, 131],+ [131, 148, 150],+ [108, 113, 196],+ [147, 161, 161],+ [253, 246, 227],+ ],+ },+ TerminalTheme {+ name: "iTerm2 Solarized Light",+ background: [253, 246, 227],+ foreground: [101, 123, 131],+ palette: [+ [7, 54, 66],+ [220, 50, 47],+ [133, 153, 0],+ [181, 137, 0],+ [38, 139, 210],+ [211, 54, 130],+ [42, 161, 152],+ [187, 181, 162],+ [0, 43, 54],+ [203, 75, 22],+ [88, 110, 117],+ [101, 123, 131],+ [131, 148, 150],+ [108, 113, 196],+ [147, 161, 161],+ [253, 246, 227],+ ],+ },+ TerminalTheme {+ name: "iTerm2 Tango Dark",+ background: [0, 0, 0],+ foreground: [255, 255, 255],+ palette: [+ [0, 0, 0],+ [216, 30, 0],+ [94, 167, 2],+ [207, 174, 0],+ [66, 122, 179],+ [137, 101, 142],+ [0, 167, 170],+ [219, 222, 216],+ [104, 106, 102],+ [245, 66, 53],+ [153, 227, 67],+ [253, 235, 97],+ [132, 176, 216],+ [188, 148, 183],+ [55, 230, 232],+ [241, 241, 240],+ ],+ },+ TerminalTheme {+ name: "iTerm2 Tango Light",+ background: [255, 255, 255],+ foreground: [0, 0, 0],+ palette: [+ [0, 0, 0],+ [216, 30, 0],+ [94, 167, 2],+ [207, 174, 0],+ [66, 122, 179],+ [137, 101, 142],+ [0, 167, 170],+ [193, 196, 190],+ [104, 106, 102],+ [245, 66, 53],+ [140, 214, 54],+ [215, 197, 59],+ [132, 176, 216],+ [188, 148, 183],+ [30, 204, 206],+ [241, 241, 240],+ ],+ },+ TerminalTheme {+ name: "novmbr",+ background: [36, 29, 26],+ foreground: [199, 184, 172],+ palette: [+ [40, 42, 46],+ [159, 100, 52],+ [157, 172, 95],+ [204, 167, 95],+ [47, 125, 124],+ [181, 137, 110],+ [82, 135, 127],+ [199, 184, 172],+ [93, 78, 71],+ [159, 100, 52],+ [157, 172, 95],+ [204, 167, 95],+ [47, 125, 124],+ [181, 137, 110],+ [82, 135, 127],+ [199, 184, 172],+ ],+ },+ TerminalTheme {+ name: "owl",+ background: [47, 43, 44],+ foreground: [222, 222, 222],+ palette: [+ [48, 44, 44],+ [90, 90, 90],+ [152, 152, 152],+ [202, 202, 202],+ [101, 101, 101],+ [177, 177, 177],+ [127, 127, 127],+ [222, 222, 222],+ [93, 89, 91],+ [218, 91, 44],+ [152, 152, 152],+ [202, 202, 202],+ [101, 101, 101],+ [177, 177, 177],+ [127, 127, 127],+ [255, 255, 255],+ ],+ },+ TerminalTheme {+ name: "traffic",+ background: [39, 44, 48],+ foreground: [207, 185, 168],+ palette: [+ [40, 45, 49],+ [147, 78, 70],+ [99, 114, 104],+ [199, 158, 132],+ [81, 94, 103],+ [113, 95, 94],+ [92, 111, 125],+ [207, 185, 168],+ [78, 87, 94],+ [147, 78, 70],+ [99, 114, 112],+ [199, 158, 132],+ [81, 94, 103],+ [113, 95, 94],+ [92, 111, 125],+ [221, 206, 194],+ ],+ },+ TerminalTheme {+ name: "urban",+ background: [49, 46, 57],+ foreground: [192, 167, 154],+ palette: [+ [51, 48, 59],+ [135, 64, 79],+ [116, 147, 78],+ [174, 131, 90],+ [97, 87, 114],+ [133, 75, 100],+ [98, 84, 100],+ [192, 167, 154],+ [92, 88, 101],+ [135, 64, 79],+ [116, 147, 78],+ [174, 131, 90],+ [97, 87, 114],+ [133, 75, 100],+ [98, 84, 100],+ [192, 167, 154],+ ],+ },+];++#[cfg(test)]+mod tests {+ use super::*;+ #[test]+ fn terminal_themes_are_parseable_and_nonempty() {+ assert!(TERMINAL_THEMES.len() > 400);+ for t in TERMINAL_THEMES {+ assert!(!t.name.is_empty());+ }+ }+ #[test]+ fn palette_has_16_entries() {+ for t in TERMINAL_THEMES {+ assert_eq!(t.palette.len(), 16);+ }+ }+}diff --git a/tui/src/theme.rs b/tui/src/theme.rsindex 2da663b6c..f3e8102cb 100644--- a/tui/src/theme.rs+++ b/tui/src/theme.rs@@ -397,9 +397,54 @@ pub mod fzfcolor {/// Readable accent for hn controls. ANSI blue can be nearly black in terminal themes./// Keep engine branding and explicitly configured tmux colors separate from chrome.+/// A `[look]` accent (`@hn-accent`, a chosen theme's) wins; with none, the terminal's own palette+/// gives it (its colours 1-7, as it answered OSC 4), so the chrome is in the terminal's theme; a+/// terminal that did not answer, hn's teal.pub fn accent() -> Color {+ if let Some(hex) = crate::term_out::accent_override() {+ if let Some(c) = crate::tmuxconf::colour(&hex) { return c }+ }+ if let Some([r, g, b]) = crate::term_out::native_accent() { return Color::Rgb(r, g, b) }if palette().2 { Color::Rgb(0, 100, 120) } else { Color::Rgb(95, 215, 230) }}++/// The signature colour of a terminal theme, as `#rrggbb` for `@hn-accent`: the palette slot (1-7)+/// that contrasts most with the theme's background while staying saturated. So choosing a theme in+/// `hn theme` tints hn's chrome with it, even though the terminal keeps drawing the background and+/// foreground.+pub fn theme_accent_hex(name: &str) -> Option<String> {+ use crate::terminal_themes::TERMINAL_THEMES;+ TERMINAL_THEMES.iter().find(|t| t.name == name).map(|t| {+ let c = theme_accent_rgb(t);+ format!("#{:02x}{:02x}{:02x}", c[0], c[1], c[2])+ })+}++/// The vivid color of a theme: see [`theme_accent_hex`].+pub fn theme_accent_rgb(t: &crate::terminal_themes::TerminalTheme) -> [u8; 3] {+ let colours: Vec<(usize, [u8; 3])> = (1..=7).map(|i| (i, t.palette[i])).collect();+ accent_of(t.background, &colours)+}++/// The accent a palette gives on [bg]: of its colours 1-7 ([colours], by number), the one that+/// stands out most from the background while staying a colour — for a bundled theme, and for the+/// terminal's own palette when no theme is chosen.+pub fn accent_of(bg: [u8; 3], colours: &[(usize, [u8; 3])]) -> [u8; 3] {+ let lum = |c: [u8; 3]| 0.299 * c[0] as f64 + 0.587 * c[1] as f64 + 0.114 * c[2] as f64;+ let chroma = |c: [u8; 3]| {+ let mx = c[0].max(c[1]).max(c[2]) as f64;+ let mn = c[0].min(c[1]).min(c[2]) as f64;+ if mx == 0.0 { 0.0 } else { (mx - mn) / mx }+ };+ let bg_lum = lum(bg);+ let mut best = colours.iter().find(|(i, _)| *i == 6).or(colours.first()).map(|(_, c)| *c).unwrap_or([95, 215, 230]);+ let mut best_score = f64::MIN;+ for (_, p) in colours {+ let score = (lum(*p) - bg_lum).abs() * 0.7 + chroma(*p) * 0.3;+ if score > best_score { best_score = score; best = *p; }+ }+ best+}// Semantic status colors use the terminal palette. SOFT and MUTED represent emphasis;// `fg` applies it to the theme's foreground.pub const ACCENT_SOFT: Color = Color::Cyan;@@ -441,6 +486,18 @@ pub fn pane_palette() -> PanePalette {pane_palette_for(native)}+/// The surfaces the terminal's own colours make, whatever theme is chosen.+pub fn native_pane_palette() -> PanePalette {+ let native = crate::term_out::native_terminal_colours().and_then(|(bg, fg)|+ Some((crate::tmuxconf::colour(&bg)?, crate::tmuxconf::colour(&fg)?)));+ pane_palette_for(native)+}++/// The surfaces a theme's own background and foreground make — what choosing it would draw.+pub fn pane_palette_of(bg: [u8; 3], fg: [u8; 3]) -> PanePalette {+ pane_palette_for(Some((Color::Rgb(bg[0], bg[1], bg[2]), Color::Rgb(fg[0], fg[1], fg[2]))))+}+fn pane_palette_for(native: Option<(Color, Color)>) -> PanePalette {let (bg, foreground) = native.unwrap_or((Color::Rgb(28, 31, 36), Color::Rgb(220, 225, 231)));let Color::Rgb(r, g, b) = bg else { unreachable!("terminal background is RGB") };@@ -1177,7 +1234,22 @@ fn engine_mark_raw(engine: &str) -> (&'static str, Color) {"muse" => ("♪", ATTENTION),"agy" => ("◈", Color::Rgb(0x42, 0x85, 0xF4)),"terminal" => ("❯", SOFT),- _ => ("●", SOFT),+ _ => ("▸", SOFT),+ }+}++/// A machine at a glance, in the harnesses' marks (no round ones): `✓` this computer or+/// connected, a spinner connecting, `?` waiting to be linked, `✗` an error, `·` online but not+/// connected (soft) or offline (muted).+pub fn machine_mark(reach: &crate::fleet::Reach, online: bool, tick: u64) -> (&'static str, Color) {+ use crate::fleet::Reach;+ match reach {+ Reach::Ready => ("✓", paint(ONLINE)),+ Reach::Connecting => (spinner(tick), paint(WARN)),+ Reach::NeedsLink => ("?", paint(ATTENTION)),+ Reach::Error(_) => ("✗", paint(DANGER)),+ _ if online => ("·", paint(SOFT)),+ _ => ("·", MUTED),}}@@ -1191,8 +1263,9 @@ pub fn engine_label(engine: &str) -> &str {}/// A harness's state at a glance, the same everywhere hn shows one (pane titles, the window list,-/// the lists), in Orca's set: a spinner working, `?` needs you, `✓` done and not looked at yet, `·`-/// idle, `✗` failed; hn adds `◌` starting, `‖` paused and `○` offline. [tick] turns the spinner.+/// the lists, the side bar), in Orca's set: a spinner working (and starting, in its own colour),+/// `?` needs you, `✓` done and not looked at yet, `·` idle, `✗` failed; hn adds `‖` paused and a+/// muted `·` offline — no round marks. [tick] turns the spinner.pub fn state_mark(state: State, tick: u64) -> (&'static str, &'static str, Color) {let (dot, word, color) = state_mark_raw(state, tick);(dot, word, if color == MUTED { color } else { paint(color) })@@ -1204,10 +1277,10 @@ fn state_mark_raw(state: State, tick: u64) -> (&'static str, &'static str, ColorState::Working => (spinner(tick), "working", ACCENT_SOFT),State::Done => ("✓", "done", ONLINE),State::Ready => ("·", "idle", MUTED),- State::Starting => ("◌", "starting", WARN),+ State::Starting => (spinner(tick), "starting", WARN),State::Failed => ("✗", "failed", DANGER),State::Paused => ("‖", "paused", MUTED),- State::Offline => ("○", "offline", MUTED),+ State::Offline => ("·", "offline", MUTED),}}@@ -1327,3 +1400,32 @@ mod palette_tests {assert!(light, "a light background reads as light");}}++#[cfg(test)]+mod accent_theme_tests {+ use super::* ;+ use crate::term_out;++ #[test]+ fn accent_honours_the_look_override_and_falls_back() {+ let _colours = term_out::colours_lock();+ term_out::set_accent_override(Some("#123456".into()));+ assert_eq!(accent(), Color::Rgb(0x12, 0x34, 0x56));+ term_out::set_accent_override(Some("#0f0".into()));+ assert_eq!(accent(), Color::Rgb(0, 0xff, 0));+ // A blank override falls back to the derived chrome teal, not the last override.+ term_out::set_accent_override(None);+ let c = accent();+ assert_ne!(c, Color::Rgb(0x12, 0x34, 0x56));+ assert_ne!(c, Color::Rgb(0, 0xff, 0));+ }++ #[test]+ fn theme_accent_hex_is_stable_and_theme_specific() {+ assert_eq!(theme_accent_hex("definitely-not-a-theme"), None);+ let a = theme_accent_hex("Atom One Dark").expect("known theme has an accent");+ assert!(a.len() == 7 && a.starts_with('#'));+ let b = theme_accent_hex("Gruvbox Dark").expect("known theme has an accent");+ assert_ne!(a, b);+ }+}diff --git a/tui/src/ui.rs b/tui/src/ui.rsindex fa72fd114..77671c124 100644--- a/tui/src/ui.rs+++ b/tui/src/ui.rs@@ -58,7 +58,8 @@ pub fn draw(frame: &mut Frame, app: &mut App) {let buf = frame.buffer_mut();let mut cursor: Option<Position> = None;// A list takes the window (with --height, only its bottom rows: the panes stay in view).- let full_screen = matches!(app.modal, Some(Modal::Picker { .. }) if theme::fzf_opts().height.is_none());+ // (The settings panel is not one: it floats over the panes, as the New Harness form does.)+ let full_screen = matches!(&app.modal, Some(Modal::Picker { kind, .. }) if theme::fzf_opts().height.is_none() && !crate::settings::is_panel(kind));if !full_screen {if app.tab().home || app.tab().root.is_none() { empty_window(buf, app, body) }else { cursor = window(buf, app, body) }@@ -68,11 +69,21 @@ pub fn draw(frame: &mut Frame, app: &mut App) {let clocks: Vec<Rect> = app.rects.iter().filter(|(id, _)| app.panes.get(id).map(|p| p.clock).unwrap_or(false)).map(|(id, r)| { if Some(*id) == app.focused() { cursor = None } app.content_of(app.tab(), *r) }).collect();for rect in clocks { clock(buf, app, rect) }}+ // ── status bar ──+ // The status bar down a side, and the tabs over the panes beside it.+ crate::bar::draw(buf, app);if let Some(Modal::DisplayPanes { .. }) = &app.modal { display_panes(buf, app) }let search_busy = app.said_due.is_some() || app.said_pending > 0;let msg_style = app.message_style();+ if let Some(Modal::Picker { kind, mut picker }) = app.modal.take_if(|m| matches!(m, Modal::Picker { kind, .. } if crate::settings::is_panel(kind))) {+ let (at, shown) = crate::settings::draw(buf, app, body, &kind, &mut picker);+ cursor = at;+ if let Some(rect) = shown { panel_preview(buf, app, &kind, &picker, rect) }+ app.modal = Some(Modal::Picker { kind, picker });+ }if let Some(modal) = &mut app.modal {match modal {+ Modal::Picker { kind, .. } if crate::settings::is_panel(kind) => {}// (--no-input: no prompt, no cursor.)// (Too small to hold a list — a window being dragged, a drop-down terminal opening: none// drawn until it has the room, as fzf clamps and tmux draws what fits; never a crash.)@@ -81,7 +92,7 @@ pub fn draw(frame: &mut Frame, app: &mut App) {}}// The picker drew with a placeholder preview; a live pane preview needs the whole app.- if let Some(Modal::Picker { kind, picker }) = app.modal.as_ref().filter(|_| body.height >= 1 && body.width >= 2) {+ if let Some(Modal::Picker { kind, picker }) = app.modal.as_ref().filter(|m| body.height >= 1 && body.width >= 2 && !matches!(m, Modal::Picker { kind, .. } if crate::settings::is_panel(kind))) {if let (_, Some(pbox), _) = fzf_split(fzf_frame(body, picker).inner, picker) { preview(buf, app, kind, picker, &pbox) }}let popup = match &app.modal { Some(Modal::Popup { pane, x, y, width, height, border, title, look }) => Some((*pane, *x, *y, *width, *height, *border, title.clone(), look.clone())), _ => None };@@ -200,15 +211,19 @@ fn which_key(buf: &mut Buffer, app: &App, body: Rect) {// (A third of the window at most: the panes stay in view above it.)let height = (rows_needed as u16 + 2).min((body.height / 3).max(4)).min(body.height);let area = Rect::new(body.x, body.y + body.height - height, body.width, height);+ // The shortcut box takes hn's chrome colours (the terminal's surfaces), so it sits with the+ // status line and pane surfaces rather than floating in the terminal's default colours.+ let pal = theme::pane_palette();+ let panel = Style::default().bg(pal.surface);+ let border = Style::default().fg(pal.border).bg(pal.surface);crate::term_out::clear_extras(area);- for y in area.y..area.y + area.height { for x in area.x..area.x + area.width { if let Some(c) = buf.cell_mut((x, y)) { c.reset(); } } }- let border = Style::default();+ for y in area.y..area.y + area.height { for x in area.x..area.x + area.width { if let Some(c) = buf.cell_mut((x, y)) { c.reset(); c.set_style(panel); } } }for x in area.x..area.x + area.width { buf.set_string(x, area.y, "─", border); buf.set_string(x, area.y + area.height - 1, "─", border) }for y in area.y..area.y + area.height { buf.set_string(area.x, y, "│", border); buf.set_string(area.x + area.width - 1, y, "│", border) }buf.set_string(area.x, area.y, "┌", border); buf.set_string(area.x + area.width - 1, area.y, "┐", border);buf.set_string(area.x, area.y + area.height - 1, "└", border); buf.set_string(area.x + area.width - 1, area.y + area.height - 1, "┘", border);let title = format!(" {} ", crate::keys::name(&app.keymap.prefix));- buf.set_string(area.x + 2, area.y, &title, Style::default().add_modifier(Modifier::BOLD));+ buf.set_string(area.x + 2, area.y, &title, Style::default().fg(pal.foreground).bg(pal.surface).add_modifier(Modifier::BOLD));let inner_rows = area.height.saturating_sub(2) as usize;// Column-major, like ls: read down, then across.let fits = cols * inner_rows.max(1);@@ -216,16 +231,16 @@ fn which_key(buf: &mut Buffer, app: &App, body: Rect) {// Say there is more, bottom right of the box (C-b ? has them all).let more = format!(" +{} more — {} ? ", items.len() - fits + 1, crate::keys::name(&app.keymap.prefix));let mx = (area.x + area.width).saturating_sub(more.width() as u16 + 2);- buf.set_string(mx, area.y + area.height - 1, &more, Style::default().add_modifier(Modifier::DIM));+ buf.set_string(mx, area.y + area.height - 1, &more, Style::default().fg(pal.muted).bg(pal.surface).add_modifier(Modifier::DIM));}for (i, (key, what)) in items.iter().enumerate() {let (col, row) = (i / inner_rows.max(1), i % inner_rows.max(1));if col >= cols || (items.len() > fits && i + 1 >= fits) { break }let x = area.x + 2 + (col * col_w) as u16;let y = area.y + 1 + row as u16;- buf.set_string(x, y, format!("{key:>key_w$}"), bold(theme::accent()));+ buf.set_string(x, y, format!("{key:>key_w$}"), Style::default().fg(theme::accent()).bg(pal.surface).add_modifier(Modifier::BOLD));let room = col_w - key_w - 3;- buf.set_stringn(x + key_w as u16 + 1, y, clip(what, room), room, Style::default());+ buf.set_stringn(x + key_w as u16 + 1, y, clip(what, room), room, Style::default().fg(pal.foreground).bg(pal.surface));}}@@ -252,7 +267,7 @@ fn window(buf: &mut Buffer, app: &mut App, body: Rect) -> Option<Position> {let (a, w) = (app.style_of("window-active-style", app.active, Some(*id)), app.style_of("window-style", app.active, Some(*id)));let window = if active { (a.fg.or(w.fg), a.bg.or(w.bg)) } else { (w.fg, w.bg) };if surfaces {- let f = crate::pane_frame::frame(*rect, app.window_area(app.tab()), app.pane_status(app.tab()));+ let f = crate::pane_frame::frame(*rect, app.window_area(app.tab()), app.box_inner(app.tab()), app.pane_status(app.tab()));// A single or zoomed pane keeps the same surface and surrounding canvas.buf.set_style(f.surface, Style::default().fg(window.0.unwrap_or(Color::Reset)).bg(window.1.unwrap_or(Color::Reset)));}@@ -278,16 +293,16 @@ fn window(buf: &mut Buffer, app: &mut App, body: Rect) -> Option<Position> {pane.dirty = false;}}- if surfaces { pane_chrome(buf, app); } else { borders(buf, app, body); }+ if surfaces { pane_chrome(buf, app); } else if app.options.box_panes() { boxes(buf, app); } else { borders(buf, app, body); }if app.modal.is_some() && !matches!(app.modal, Some(Modal::Copy { .. })) { None } else { cursor }}/// Integrated titles on borderless pane surfaces. Background contrast identifies focus./// Program cells retain their ANSI colours; moving focus changes no content dimensions or mouse coordinates.fn pane_chrome(buf: &mut Buffer, app: &App) {- let canvas = app.window_area(app.tab());+ let (canvas, inner) = (app.window_area(app.tab()), app.box_inner(app.tab()));for (id, rect) in &app.rects {- let f = crate::pane_frame::frame(*rect, canvas, app.pane_status(app.tab()));+ let f = crate::pane_frame::frame(*rect, canvas, inner, app.pane_status(app.tab()));let active = Some(*id) == app.focused();let style_name = if active { "pane-active-border-style" } else { "pane-border-style" };let style = app.style_of(style_name, app.active, Some(*id));@@ -369,6 +384,65 @@ fn title_line(buf: &mut Buffer, app: &App, id: u64, area: Rect, style: Style) {}}+// ── box panes ──++/// Box panes (`@hn-border box`, the default): every pane its own frame in pane-border-lines' box+/// lines — the accent around the focused one, the attention colour around one whose harness waits+/// on you (a question, a permission, its input), as the app colours its line; the quiet border+/// colour elsewhere (or your pane-border-style / pane-active-border-style). The pane's title is+/// drawn into the frame's top or bottom line as ` title `, in the accent and bold when focused.+fn boxes(buf: &mut Buffer, app: &App) {+ let tab = app.tab();+ let (canvas, status) = (app.window_area(tab), app.pane_status(tab));+ let lines = app.options.get("pane-border-lines", &tab.id, None).unwrap_or_default();+ let hz = box_set(&lines).4;+ let inner = app.box_inner(tab);+ let frames: Vec<(u64, crate::pane_frame::Frame)> = app.rects.iter().map(|(id, r)| (*id, crate::pane_frame::boxed_in(*r, canvas, inner, status))).filter(|(_, f)| f.content != f.surface).collect();+ // The lines, each cell with the pane it is drawn for: neighbours share a line, which takes+ // the colour of the one that matters most — the focused pane's, else one that waits on you.+ let rank = |id: u64| if Some(id) == app.focused() { 2 } else { u8::from(app.pane_state(id) == Some(crate::fleet::State::NeedsInput)) };+ let mut cells: std::collections::HashMap<(u16, u16), u64> = std::collections::HashMap::new();+ for (id, f) in &frames {+ let r = f.surface;+ let edge = (r.x..r.right()).flat_map(|x| [(x, r.y), (x, r.bottom() - 1)]).chain((r.y..r.bottom()).flat_map(|y| [(r.x, y), (r.right() - 1, y)]));+ for p in edge { let owner = cells.entry(p).or_insert(*id); if rank(*id) > rank(*owner) { *owner = *id } }+ }+ for (&(x, y), &id) in &cells {+ let on = |dx: i32, dy: i32| cells.contains_key(&((x as i32 + dx) as u16, (y as i32 + dy) as u16));+ let g = crate::settings::joint(&lines, y > 0 && on(0, -1), on(0, 1), x > 0 && on(-1, 0), on(1, 0));+ if let Some(c) = buf.cell_mut((x, y)) { c.set_symbol(g).set_style(box_style(app, id)); }+ }+ for (id, f) in &frames {+ let (id, style) = (*id, box_style(app, *id));+ let active = Some(id) == app.focused();+ let Some(t) = f.title else { continue };+ // (Its own colour for the words: the frame's when it waits on you, else a quieter one.)+ let words = if active { style.add_modifier(Modifier::BOLD) } else if app.pane_state(id) == Some(crate::fleet::State::NeedsInput) { style } else { style.fg(theme::paint(theme::pane_palette().muted)) };+ let Some(fmt) = app.options.get("pane-border-format", &tab.id, Some(id)) else { continue };+ let expanded = crate::format::expand(app, &fmt, app.active, Some(id), true);+ let cells = crate::draw::format_draw_over(&expanded, words, t.width.saturating_sub(1));+ // ` title `: a blank after the words where the line would run on.+ let end = cells.iter().position(|c| c.is_none()).unwrap_or(cells.len());+ for (i, cell) in cells.into_iter().enumerate() {+ if let Some((ch, cs)) = cell { if let Some(c) = buf.cell_mut((t.x + i as u16, t.y)) { c.set_symbol(if ch.is_empty() { " " } else { &ch }); c.set_style(cs); } }+ }+ if end > 0 { if let Some(c) = buf.cell_mut((t.x + end as u16, t.y)) { if c.symbol() == hz { c.set_symbol(" ").set_style(words); } } }+ }+}++/// A box's frame colour: focused → the accent, waiting on you → the attention colour, else the+/// quiet border colour; your own pane-(active-)border-style where you set one (and tmux's own+/// under `@hn-look tmux`, which draws no boxes). The marked pane's frame is bold.+fn box_style(app: &App, id: u64) -> Style {+ let active = Some(id) == app.focused();+ let own = if active { app.look.active_border.is_some() } else { app.look.border.is_some() };+ let style = if own { border_style(app, active) }+ else if active { Style::default().fg(theme::paint(theme::accent())).add_modifier(if theme::no_color() { Modifier::BOLD } else { Modifier::empty() }) }+ else if app.pane_state(id) == Some(crate::fleet::State::NeedsInput) { Style::default().fg(theme::paint(theme::ATTENTION)) }+ else { Style::default().fg(theme::paint(theme::pane_palette().border)) };+ if app.marked == Some(id) { style.add_modifier(Modifier::BOLD) } else { style }+}+/// A window with no harness in it: the harnesses you were just with, one key away.const WORDMARK: [&str; 2] = ["█ █ ▄▀█ █▀█ █▄ █ █▀▀ █▀ █▀", "█▀█ █▀█ █▀▄ █ ▀█ ██▄ ▄█ ▄█"];@@ -468,6 +542,23 @@ fn empty_window(buf: &mut Buffer, app: &App, area: Rect) {let x = if index < centered { area.x + area.width.saturating_sub(w) / 2 } else { left };buf.set_line(x, y, line, area.width.saturating_sub(x - area.x));}+ themed_home(buf, area);+}++/// With a theme chosen (Settings → Theme), the home screen stands on the theme's background where+/// the terminal's showed — as the panes the daemon paints and the status line already do. (Its+/// text is the theme's already: `fg` dims the theme's own foreground.) Without one, as the+/// terminal has it.+fn themed_home(buf: &mut Buffer, area: Rect) {+ if !crate::term_out::theme_chosen() || theme::no_color() { return }+ let pal = theme::pane_palette();+ for y in area.y..area.bottom() {+ for x in area.x..area.right() {+ let Some(c) = buf.cell_mut((x, y)) else { continue };+ if matches!(c.bg, Color::Reset) { c.bg = theme::depth_fit(pal.surface) }+ if matches!(c.fg, Color::Reset) { c.fg = theme::depth_fit(pal.foreground) }+ }+ }}@@ -919,6 +1010,28 @@ fn fzf_border(buf: &mut Buffer, body: Rect) {/// its scrollbar.pub struct PreviewBox { pub rect: Rect, pub shape: String, pub inner: Rect, pub bar_x: u16, pub opts: theme::PreviewWindow }+/// A list's preview inside the settings panel: the same preview fzf's window shows (a harness's+/// live screen, a machine's notes…), without a box, on the panel's own surface.+fn panel_preview(buf: &mut Buffer, app: &App, kind: &PickerKind, picker: &Picker, rect: Rect) {+ let opts = picker.preview_window.clone().unwrap_or_else(|| theme::fzf_opts().preview_window.clone());+ let inner = Rect::new(rect.x, rect.y, rect.width.saturating_sub(1), rect.height);+ let pb = PreviewBox { rect, shape: "none".into(), inner, bar_x: rect.right().saturating_sub(1), opts };+ preview(buf, app, kind, picker, &pb);+ // What the preview left in the terminal's colours takes the panel's; its scrollbar's column+ // is left blank (the panel draws no scrollbars: the wheel and the keys scroll it).+ let base = crate::settings::chrome().base;+ picker.preview_bar.set(None);+ for y in rect.y..rect.bottom() { if let Some(c) = buf.cell_mut((pb.bar_x, y)) { c.set_symbol(" ").set_style(base); } }+ for y in rect.y..rect.bottom() {+ for x in rect.x..rect.right() {+ if let Some(c) = buf.cell_mut((x, y)) {+ if matches!(c.bg, Color::Reset) { c.bg = base.bg.unwrap_or(Color::Reset) }+ if matches!(c.fg, Color::Reset) { c.fg = base.fg.unwrap_or(Color::Reset) }+ }+ }+ }+}+/// A border shape's sides: top, right, bottom, left.fn shape_sides(shape: &str) -> (bool, bool, bool, bool) {match shape {@@ -2593,3 +2706,226 @@ mod fzf_list_tests {assert!(!screen(&mut p).contains("(empty)"));}}++#[cfg(test)]+mod theme_render_tests {+ use super::*;+ use crate::app::App;+ use crate::modal;++ fn app() -> App {+ let (sink, _) = tokio::sync::mpsc::unbounded_channel();+ let mut app = App::new(19789, sink, (150, 42));+ app.fleet.local_id = "local".into();+ app.fleet.machines.push(crate::fleet::Machine {+ id: "local".into(), name: "studio".into(), local: true, status: "online".into(), reach: crate::fleet::Reach::Ready,+ });+ app.homes.insert("local".into(), "/home/dev".into());+ app+ }++ fn screen(app: &mut App) -> String {+ let mut term = ratatui::Terminal::new(ratatui::backend::TestBackend::new(150, 42)).unwrap();+ term.draw(|f| draw(f, app)).unwrap();+ let buf = term.backend().buffer().clone();+ (0..42).map(|y| (0..150).map(|x| buf[(x, y)].symbol().to_string()).collect::<String>()).collect::<Vec<_>>().join("\n")+ }++ /// `theme` opens the settings panel over the window (not fzf's full-screen list), and a key+ /// into a section shows that section's options — which a fleet refresh leaves open.+ #[test]+ fn theme_draws_the_settings_panel_and_a_refresh_keeps_its_section() {+ let mut app = app();+ crate::input::run(&mut app, "theme");+ let s = screen(&mut app);+ assert!(s.contains("Appearance") && s.contains("Pane titles") && s.contains("Preview"), "{s}");+ crate::input::modal_key(&mut app, crossterm::event::KeyEvent::new(crossterm::event::KeyCode::Enter, crossterm::event::KeyModifiers::NONE));+ crate::input::refill(&mut app);+ let s = screen(&mut app);+ for v in ["off", "top", "bottom"] { assert!(s.contains(v), "{v} missing after a refresh:\n{s}") }+ let Some(Modal::Picker { picker, .. }) = &app.modal else { panic!("closed") };+ assert_eq!(picker.theme_in.as_deref(), Some("status"));+ let _ = modal::theme_sections(&app);+ }++ /// The launcher with long rows — harnesses in several projects on several machines, whose+ /// right column (project, machine, age) is wider than the list — stays inside its panel, before+ /// and after `@` then ⌫; `@` lands on the machine you are on, its preview beside it.+ #[test]+ fn long_rows_stay_in_the_panel_and_at_lands_on_this_machine() {+ use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};+ let rt = tokio::runtime::Runtime::new().unwrap();+ let _in = rt.enter();+ let mut app = app();+ app.fleet.machines.push(crate::fleet::Machine { id: "far".into(), name: "Macbooks-MacBook-Pro-5.local".into(), local: false, status: "online".into(), reach: crate::fleet::Reach::Ready });+ for (i, (name, project, m)) in [("autonomous-harness", "autonomous-harness", "far"), ("grid-mac-lmstudio3", "autonomous-grid", "far"), ("grid-mac-ollama", "autonomous-grid", "local")].iter().enumerate() {+ let a = crate::fleet::agent_from(m, &serde_json::json!({"id": format!("a{i}"), "name": name, "engine": "claude", "state": "idle", "cwd": format!("/home/dev/{project}"), "project": {"name": project}}), None);+ app.fleet.agents.insert((m.to_string(), format!("a{i}")), a);+ }+ let outside = |app: &mut App| -> Vec<String> {+ let s = screen(app);+ let Some(Modal::Picker { picker, .. }) = &app.modal else { panic!("closed") };+ let r = picker.screen_area.get();+ s.lines().enumerate().filter(|(y, _)| *y as u16 >= r.y && (*y as u16) < r.bottom())+ .filter_map(|(_, l)| { let left: String = l.chars().take(r.x as usize).collect(); let right: String = l.chars().skip(r.right() as usize).collect(); (!left.trim().is_empty() || !right.trim().is_empty()).then(|| l.to_string()) })+ .collect()+ };+ crate::commands::execute_bound(&mut app, "choose-tree -Zs");+ assert!(outside(&mut app).is_empty(), "{:?}", outside(&mut app));+ crate::input::modal_key(&mut app, KeyEvent::new(KeyCode::Char('@'), KeyModifiers::NONE));+ assert!(outside(&mut app).is_empty());+ {+ let Some(Modal::Picker { picker, .. }) = &app.modal else { panic!("closed") };+ assert_eq!(picker.current_id().as_deref(), Some("local"), "on the machine you are on");+ assert!(picker.preview_area.get().is_some());+ }+ crate::input::modal_key(&mut app, KeyEvent::new(KeyCode::Backspace, KeyModifiers::NONE));+ assert!(outside(&mut app).is_empty(), "{:?}", outside(&mut app));+ }++ /// The home screen follows a chosen theme: the wordmark in its accent, the screen on its+ /// background; with no theme, the terminal's own background stays.+ #[test]+ fn the_home_screen_follows_the_theme() {+ let _colours = crate::term_out::colours_lock();+ let mut app = app();+ let bg_at = |app: &mut App| {+ let mut term = ratatui::Terminal::new(ratatui::backend::TestBackend::new(150, 42)).unwrap();+ term.draw(|f| draw(f, app)).unwrap();+ let buf = term.backend().buffer().clone();+ (buf[(1, 1)].bg, (0..42).flat_map(|y| (0..150).map(move |x| (x, y))).find(|p| buf[*p].symbol() == "█").map(|p| buf[p].fg))+ };+ let (plain, _) = bg_at(&mut app);+ assert_eq!(plain, Color::Reset, "no theme: the terminal's own background");+ let _ = app.set_look("theme", "Adwaita Dark");+ let t = crate::terminal_themes::TERMINAL_THEMES.iter().find(|t| t.name == "Adwaita Dark").unwrap();+ let (themed, logo) = bg_at(&mut app);+ assert_eq!(themed, theme::depth_fit(Color::Rgb(t.background[0], t.background[1], t.background[2])));+ assert_eq!(logo, Some(theme::depth_fit(theme::accent())), "the wordmark in the theme's accent");+ let _ = app.set_look("theme", "");+ }++ /// C-b s opens the launcher in the panel (over the window, not full screen), with the scopes+ /// it switches between; typing `@` switches to the machines in the same place, with the+ /// row's preview beside the list; `>` to the commands.+ #[test]+ fn the_launcher_and_its_scopes_are_panels_with_previews() {+ use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};+ // (Switching lists asks machines for theirs, in the background.)+ let rt = tokio::runtime::Runtime::new().unwrap();+ let _in = rt.enter();+ let mut app = app();+ crate::commands::execute_bound(&mut app, "choose-tree -Zs");+ let s = screen(&mut app);+ assert!(s.contains("Harnesses") && s.contains("> commands") && s.contains("@ machines") && s.contains("? help"), "{s}");+ let (at, kind0) = match &app.modal { Some(Modal::Picker { picker, kind }) => (picker.screen_area.get(), std::mem::discriminant(kind)), _ => panic!("no panel") };+ assert!(at.width < 150, "a panel, not the whole screen");+ crate::input::modal_key(&mut app, KeyEvent::new(KeyCode::Char('@'), KeyModifiers::NONE));+ let s = screen(&mut app);+ let Some(Modal::Picker { picker, kind }) = &app.modal else { panic!("closed") };+ assert!(matches!(kind, PickerKind::Machines) && std::mem::discriminant(kind) != kind0);+ assert_eq!(picker.screen_area.get(), at, "same place");+ assert!(s.contains("Machines") && s.contains("studio"), "{s}");+ assert!(picker.preview_area.get().is_some(), "the machine's preview beside the list");+ crate::input::modal_key(&mut app, KeyEvent::new(KeyCode::Backspace, KeyModifiers::NONE));+ crate::input::modal_key(&mut app, KeyEvent::new(KeyCode::Char('>'), KeyModifiers::NONE));+ let _ = screen(&mut app);+ let Some(Modal::Picker { kind, .. }) = &app.modal else { panic!("closed") };+ assert!(matches!(kind, PickerKind::Palette));+ }++ /// Typing in a section puts the cursor on the best match, not where the current value was;+ /// hn's own commands show the key that runs them.+ #[test]+ fn typing_goes_to_the_best_match_and_commands_show_their_keys() {+ use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};+ let _colours = crate::term_out::colours_lock();+ let mut app = app();+ let _ = app.set_look("theme", "Aizen Dark");+ crate::input::run(&mut app, "theme");+ // (Theme is the fifth section: Pane titles, Focus, Split direction, Layout, Theme.)+ for code in [KeyCode::Down, KeyCode::Down, KeyCode::Down, KeyCode::Down, KeyCode::Right] { crate::input::modal_key(&mut app, KeyEvent::new(code, KeyModifiers::NONE)) }+ {+ let Some(Modal::Picker { picker, .. }) = &app.modal else { panic!("closed") };+ assert_eq!(picker.current_id().as_deref(), Some("theme:Aizen Dark"), "a section opens on the value in use");+ }+ for c in "adwaita".chars() { crate::input::modal_key(&mut app, KeyEvent::new(KeyCode::Char(c), KeyModifiers::NONE)) }+ let Some(Modal::Picker { picker, .. }) = &app.modal else { panic!("closed") };+ assert_eq!(picker.current_id().as_deref(), Some("theme:Adwaita"));+ let _ = app.set_look("theme", "");+ let rows = modal::command_rows(&app);+ let key = |id: &str| rows.iter().find(|r| r.id == id).map(|r| r.right.clone()).unwrap_or_default();+ assert_eq!(key("cmd:new"), "C-b N");+ assert_eq!(key("cmd:theme"), "C-b Enter");+ assert_eq!(key("cmd:split-right"), "C-b %");+ }++ /// C-b Enter lists commands in the same panel; typing narrows it, Enter on Settings turns the+ /// panel into the settings (same place), and Esc steps back to the commands. C-b Space stays+ /// tmux's next-layout.+ #[test]+ fn enter_opens_commands_and_settings_open_in_place() {+ use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};+ let mut app = app();+ let bound = |code: KeyCode| app.keymap.prefix_table.iter().find(|b| b.chord.code == code).map(|b| b.command.clone());+ assert_eq!(bound(KeyCode::Enter).as_deref(), Some("choose-command"));+ assert_eq!(bound(KeyCode::Char(' ')).as_deref(), Some("next-layout"));+ crate::commands::execute_bound(&mut app, "choose-command");+ let s = screen(&mut app);+ assert!(s.contains("Commands") && s.contains("New Harness"), "{s}");+ let at = match &app.modal { Some(Modal::Picker { picker, .. }) => picker.screen_area.get(), _ => panic!("no panel") };+ // (A few letters are enough: the best match comes first.)+ for c in "appe".chars() { crate::input::modal_key(&mut app, KeyEvent::new(KeyCode::Char(c), KeyModifiers::NONE)) }+ let Some(Modal::Picker { picker, .. }) = &app.modal else { panic!("closed") };+ assert_eq!(picker.current_id().as_deref(), Some("cmd:theme"), "Appearance ranks first for `appe`");+ crate::input::modal_key(&mut app, KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));+ let s = screen(&mut app);+ assert!(s.contains("Pane titles") && s.contains("Preview"), "{s}");+ let Some(Modal::Picker { kind, picker }) = &app.modal else { panic!("closed") };+ assert!(matches!(kind, PickerKind::Theme) && picker.from_commands);+ assert_eq!(picker.screen_area.get(), at, "the panel stayed where it was");+ crate::input::modal_key(&mut app, KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE));+ let Some(Modal::Picker { kind, picker }) = &app.modal else { panic!("Esc closed it") };+ assert!(matches!(kind, PickerKind::Commands));+ assert_eq!(picker.current_id().as_deref(), Some("cmd:theme"));+ }+}++#[cfg(test)]+mod which_key_tests {+ use super::*;+ use crate::app::App;++ fn app() -> App {+ let (sink, _) = tokio::sync::mpsc::unbounded_channel();+ let mut app = App::new(19789, sink, (150, 42));+ app.fleet.local_id = "local".into();+ app.fleet.machines.push(crate::fleet::Machine {+ id: "local".into(), name: "studio".into(), local: true, status: "online".into(), reach: crate::fleet::Reach::Ready,+ });+ app.homes.insert("local".into(), "/home/dev".into());+ app+ }++ /// The shortcut box (the prefix hint) must not panic and must draw on the themed pane surface,+ /// so it matches hn's chrome instead of floating in the terminal's default colours.+ #[test]+ fn shortcut_box_uses_the_themed_surface() {+ let _colours = crate::term_out::colours_lock();+ let mut app = app();+ app.prefix = true;+ app.prefix_at = Some(std::time::Instant::now() - std::time::Duration::from_secs(10));+ for w in [16, 40, 80, 150] {+ for h in [4, 10, 24] {+ let area = Rect::new(0, 0, w, h);+ let mut buf = Buffer::empty(area);+ which_key(&mut buf, &app, area);+ // Its panel cells take the pane surface colour.+ let surface = theme::pane_palette().surface;+ let mut any = false;+ for y in area.y..area.y + area.height { for x in area.x..area.x + area.width { if buf[(x, y)].style().bg == Some(surface) { any = true } } }+ assert!(any, "the shortcut box should draw on the themed pane surface ({w}x{h})");+ }+ }+ }+}