Skip to content

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.

fix(hn): synchronize pane order and refine status surfaces (#474)

Deea9d64584ee4a
diff --git a/docs/research/2026-09-29-hn-layout-sync.md b/docs/research/2026-09-29-hn-layout-sync.md
index 7f8239e04..72bedbd3c 100644
--- a/docs/research/2026-09-29-hn-layout-sync.md
+++ b/docs/research/2026-09-29-hn-layout-sync.md
@@ -61,3 +61,26 @@ The regression covers modern and legacy schemas, read-only mode, and real two-pa
The isolated real daemon/backend test also drops native geometry as desktop serialization does,
then verifies both preservation and a deliberate subsequent remote change. All 148 Rust tests,
the layout suite, pane UI, local shell lifecycle, complete e2e and real-stack checks pass locally.
+
+## Shared pane order
+
+A desktop drag can change `tabs[].panes` without changing membership or geometry. hn previously
+compared only membership, so those reorders were ignored; insertions were appended after existing
+panes. A saved native layout could also retain an obsolete order through its numeric pane IDs,
+which are local to an hn server rather than portable harness identities.
+
+The shared pane sequence now defines placement in screen order: across the top, then down.
+Reordering an existing window relabels its layout slots while preserving unequal dividers and
+focused harness identity. Insertions use their shared index. Loading native geometry retains its
+split sizes but uses the desk identities for placement. Local swaps, rotations and mirrored
+layouts publish the matching `pane.move` operations with their geometry. Unchanged desk snapshots
+and replies arriving before queued keyboard edits are sent do not revert those edits.
+
+Five unit regressions cover live reorders, combined order/layout changes, stale native IDs,
+queued local rotation and the difference between spatial order and tree traversal. The real-PTY
+layout fixture also checks desktop-style moves, insertion at the front, focus and divider
+preservation, keyboard rotation and swaps, fresh clients, legacy schemas and read-only mode.
+
+The isolated real-stack test also passes desktop-to-hn reordering and hn-to-desktop swaps
+through the real daemon/backend on one Mac, checking pane identities, focused harness and
+unequal divider preservation. OAuth and model execution remain fixtures.
diff --git a/docs/research/2026-09-29-hn-pane-ui-columns.png b/docs/research/2026-09-29-hn-pane-ui-columns.png
index 4da0dc5d5..dfd92d9ad 100644
Binary files a/docs/research/2026-09-29-hn-pane-ui-columns.png and b/docs/research/2026-09-29-hn-pane-ui-columns.png differ
diff --git a/docs/research/2026-09-29-hn-pane-ui-light.png b/docs/research/2026-09-29-hn-pane-ui-light.png
index 47af5f996..e01f20c90 100644
Binary files a/docs/research/2026-09-29-hn-pane-ui-light.png and b/docs/research/2026-09-29-hn-pane-ui-light.png differ
diff --git a/docs/research/2026-09-29-hn-pane-ui-rows.png b/docs/research/2026-09-29-hn-pane-ui-rows.png
index 55186b04c..dcd23add7 100644
Binary files a/docs/research/2026-09-29-hn-pane-ui-rows.png and b/docs/research/2026-09-29-hn-pane-ui-rows.png differ
diff --git a/docs/research/2026-09-29-hn-pane-ui.md b/docs/research/2026-09-29-hn-pane-ui.md
index 9776382ab..b3d730daa 100644
--- a/docs/research/2026-09-29-hn-pane-ui.md
+++ b/docs/research/2026-09-29-hn-pane-ui.md
@@ -1,16 +1,21 @@
# hn pane surfaces
hn now presents terminal panes as quiet surfaces with space between them. Each pane has
-an integrated title, its own outline, and inset content. Focus uses a thin, bright border;
-the other outlines stay thin and muted. The status line stays
+an integrated title and inset content, without drawn borders. Background contrast identifies
+the focused pane. The status line stays
at the bottom in muted green, with tabs ordered `number:name* status`. Pane headers put the
name before the state too: `hn ⋮` on the left, with `project ⑂ branch #123` aligned to the
right. Long names shorten in the middle so their state and distinguishing suffix remain visible.
Watcher details shorten when needed; raw `pane_title` values stay complete.
-Quota text is compact: `Claude 100%`, with amber or red only on the percentage. The branch
-appears only in pane headers; the
-bottom right keeps the familiar `machine:folder` location cue. Status-bar groups have two spaces
-between them. Working and waiting indicators remain visible; idle dots are hidden in tabs and
+Quota text is compact: `Claude 0% Codex 89%` remaining, with amber at 20% left and red at
+0% only on the percentage. All subscriptions with reported quota appear, even when healthy.
+Each account uses its tightest limit; shared account keys appear once across machines. Different
+accounts remain separate, with remote machine labels when needed. Claude and Codex are currently
+supported; other providers need a quota reader before they can appear. The branch appears only
+in pane headers; the bottom right keeps the familiar `machine:folder` location cue. Status-bar
+groups have two spaces between them, with one space at each outer edge aligned to the pane
+surfaces. The left session label always stays visible. The desk uses the local machine name, so switching windows or focusing a remote pane does not shift the tab list. Custom session
+names, explicit status formats and the prefix cue remain supported. Working and waiting indicators remain visible; idle dots are hidden in tabs and
pane headers. Attention markers, prefix cues, inbox rows, connection notices, preview counters
and marked tree rows use text, symbols and emphasis instead of inverted badges. Cursor and
selection highlights, explicit user styles and program ANSI remain supported. Unread and bell
@@ -40,27 +45,25 @@ the appearance cannot move the split boundaries. The original divider cells are
and still support mouse dragging.
At normal sizes there is a one-cell gap around the pane surfaces and between adjacent panes,
-one column of content padding on each side, and vertical padding where space permits. Small
+inset titles and terminal content, and vertical padding where space permits. Small
panes automatically give these cells back to the program. A one-cell terminal remains responsive
and survives resizing.
The focused pane keeps the terminal's native background and full text contrast throughout
-its filled interior and border cells, so there is no canvas-colored strip inside the outline.
-The terminal draws the thin line within its character cell; its pane-colored background fills
-that whole cell. Other panes use `rgb(64, 64, 64)` surfaces in dark
-terminals, with softer text. Each pane owns a complete outline inside its tile; a dark one-cell
-gap separates neighboring outlines. All outlines use thin box-drawing characters. The focused outline uses a brighter neutral
-color; inactive outlines use a muted gray. Explicit
-border styles and line choices override these defaults. The bottom status bar keeps its own
-color.
-
-Light terminals retain a light surface counterpart. A lone or zoomed pane uses its own
-background throughout, without a focus outline. Focus changes alter border color
-without resizing program content or changing its mouse coordinates. Compact panes give border
-and padding cells back to the program. Surface colors follow the terminal's native light/dark
+its surface, including the title and padding. Other panes use `rgb(64, 64, 64)` surfaces in dark
+terminals, with softer text. A dark one-cell gap separates neighboring surfaces. The former
+outline cells are now filled padding, so content coordinates and PTY dimensions stay unchanged.
+The bottom status bar keeps its own color.
+
+Light terminals retain a light surface counterpart. A lone or zoomed pane keeps its focused
+background within the same surrounding canvas, so its presentation matches a multi-pane window.
+Focus changes alter the surface palette
+without resizing program content or changing its mouse coordinates. Compact panes give
+padding cells back to the program. Surface colors follow the terminal's native light/dark
theme and update when it changes. The daemon receives those colors so its programs agree with
their surrounding padding. Program ANSI foregrounds, backgrounds and attributes remain intact;
only default colors inherit the pane surface palette. Explicit title formats still override the
-default heading. `pane_heading` fits the displayed name, state and watcher label to the title
+default heading. Explicit pane-border styles still customize titles; border line choices
+apply in classic and tmux appearances. `pane_heading` fits the displayed name, state and watcher label to the title
row; scripts and custom formats can continue using the complete `pane_title`.
The default is `set -g @hn-look panes`. `set -g @hn-look classic` selects the previous hn line
@@ -68,7 +71,7 @@ borders. `set -g @hn-look tmux` selects tmux's appearance and unpadded content g
## Verification
-The release build passes 150 Rust tests, including rectangle containment and usable minimum
+The release build passes 158 Rust tests, including rectangle containment and usable minimum
sizes, adjacent surfaces, user style overrides, light/dark contrast, foreground inference and
malformed OSC color replies. The new `tui/tests/pane-ui.py`
exercises the running application with actual keys and SGR mouse input:
@@ -77,17 +80,19 @@ exercises the running application with actual keys and SGR mouse input:
- All seven layouts and eight position targets with top, bottom and disabled pane titles.
- Identical split structure across appearances, including percentage splits on both axes.
- Application mouse coordinates after padding and after adding two status rows at the top.
-- Independent outlines, dark gutters, exact border colors, and focus brightness through keyboard and mouse selection.
-- Explicit border colors and line styles, and long titles retaining their suffix and waiting mark.
-- Borderless single and zoomed panes, right-aligned branch context, and hidden idle indicators.
+- Borderless surfaces, dark gutters, exact background fills through the outer padding, and focus contrast through keyboard and mouse selection.
+- Explicit title colors, classic border line styles, and long titles retaining their suffix and waiting mark.
+- Single and zoomed panes, right-aligned branch context, hidden idle indicators, a stable local-machine label across every window and local/remote pane, custom session names and the prefix cue.
+- One outer space on each status edge, multiple subscription allowances, shared-account deduplication, and quota text without filled badges.
- Live light/dark theme changes, custom style overrides in active and inactive panes, and reported option defaults.
- Explicit program foreground/background colors; 80x24, 24x8, 6x4 and 1x1 terminals.
-The main e2e suite, layout synchronization suite, local shell lifecycle suite, native terminal
-suite, and terminal attribute comparisons against real tmux also passed on macOS. The full
-isolated real-stack suite passed all ten checks: real daemon, backend, MongoDB, Redis, tmux and
-Chrome, including viewer input, browser reconnect, terminal lease recovery and C-b Space
-persistence. OAuth and model execution are fixtures. No production account, live user pane,
+The preceding pane-order revision (`dc204d59`) passed the main e2e and layout synchronization
+suites on macOS. Earlier iterations also passed the local shell lifecycle suite, native terminal
+suite, and terminal attribute comparisons against real tmux. The pane-order revision also passed
+all eleven isolated real-stack checks: real daemon, backend, MongoDB, Redis, tmux and
+Chrome, including viewer input, browser reconnect, terminal lease recovery, C-b Space
+persistence, desktop pane reordering and terminal swaps with focus and divider preservation. OAuth and model execution are fixtures. No production account, live user pane,
installed hn binary or release was changed.
The full-flow test also exposed a delayed picker refresh consuming a subsequently opened
diff --git a/tui/README.md b/tui/README.md
index d8ec3f4e8..187969dcd 100644
--- a/tui/README.md
+++ b/tui/README.md
@@ -71,16 +71,17 @@ never a tmux server you have running.
Splits, `resize-pane`, the seven layouts, `swap-pane`, `rotate-window`, `join-pane`, `break-pane`
and `select-pane` are tmux 3.5a's own arithmetic (layout.c, window.c): the same split sizes, the same
pane numbers and the same active pane after each. hn draws these layouts as pane surfaces
-with one-cell gaps, inset terminal content and an outline around each pane. The focused
-outline is thin and bright; other outlines are equally thin and muted. The surfaces follow the
-terminal's light/dark theme: focus keeps the native background throughout the filled interior.
-Border cells share the pane background, so the fill reaches the outline without an inner gap.
-Inactive dark panes use `rgb(64, 64, 64)` with softer text, separated by dark gaps.
-A lone or zoomed pane has no focus outline or gray surround. Light terminals keep a light
-counterpart. Explicit border colors and line choices override the automatic appearance.
+with one-cell gaps and inset terminal content. Panes have no drawn borders: background
+contrast identifies focus. The focused pane keeps the terminal's native background across the
+whole surface. Inactive dark panes use `rgb(64, 64, 64)` with softer text, separated by dark gaps.
+A lone or zoomed pane keeps the same focused surface and surrounding canvas. Light terminals
+keep a light counterpart.
+Explicit pane-border styles still customize the title; border line choices apply in classic and
+tmux appearances.
Explicit program colors and user styles stay intact. The muted green status bar has a continuous
background, with tabs ordered `number:name* status` (previous window: `number:name- status`).
-Quota warnings read `Claude 100%`, with amber or red only on the percentage. Padding
+Subscription allowances read `Claude 0% Codex 89%` **remaining**, with amber at 20% or less
+and red at 0% only on the percentage. Padding
shrinks automatically in small panes. The space between panes remains a resize handle; mouse
coordinates, copy selection and PTY dimensions follow the inset content. `window_layout` keeps
the original split structure. Use `set -g @hn-animations off` to keep
@@ -95,7 +96,10 @@ each window's most urgent harness state follows its name and tmux marker; idle d
in tabs and pane headers. Connection, quota,
fleet counts, `machine:folder` and clock sit on the right. The git branch stays in its pane
header, aligned to the right with its PR and written `⑂ branch` without redundant punctuation.
-Status-bar groups are separated by two spaces.
+Status-bar groups are separated by two spaces, with one space at each outer edge to align
+with the pane surfaces. The left session label always stays visible: the
+desk uses the local machine name, independent of the focused pane's machine on the right.
+Custom session names and the prefix cue remain supported.
One key differs on purpose: ⇧⏎
reaches the pane as `CSI 13;2u` (a new line in an agent's prompt; tmux, without `extended-keys`,
sends a plain Enter).
@@ -214,9 +218,17 @@ and `#{fleet_tokens}` (what it, and all of them, have used: `1.2M`), `#{pane_lin
`#{pane_asked}` and `#{pane_did}` (what it was last asked, and what its last turn came to),
`#{pane_todos}` (its plan's progress, `3/7`) and `#{pane_subagents}` (how many it has running),
`#{usage}` (the agent accounts' rate limits on the focused pane's machine: `claude 5h 42% week
-18% · codex 5h 3%`) and `#{usage_high}` (the one nearest its limit, from 80%). The status line uses
-`#{usage_high_mark}`: `Claude 80%`, with amber on the percentage from 80%, red from 100%.
-The raw `usage` and `usage_high` formats retain the reset window. Other formats:
+18% · codex 5h 3%`) and `#{usage_high}` (the one nearest its limit, from 80% used).
+The status line uses `#{usage_remaining_mark}`: `Claude 0% Codex 89%`, showing **remaining**
+allowance for every subscription with quota data, even when healthy. Each figure is the lowest
+remaining percentage across that account's reported windows. Amber starts at 20% left, red at
+0%; a nonzero allowance below 1% reads `<1%`. Shared account keys appear once across machines,
+with the local reading preferred; different or unknown accounts stay separate. When a provider
+has multiple accounts, extra remote accounts say `Claude@studio 20%` to distinguish them.
+`#{usage_remaining}` provides the same figures without color. The daemon currently reads Claude
+and Codex; Grok and other providers are not listed until a quota source is available. Existing
+`usage`, `usage_high` and `usage_high_mark` formats retain their used-quota meaning for custom
+configurations. Other formats:
`#{pane_machine}`, `#{pane_far}` (another machine's), `#{pane_watched}` and `#{pane_watcher}`
(another window has the pane to type in, and who), and `#{waiting}` (the harnesses waiting on
you).
diff --git a/tui/src/app.rs b/tui/src/app.rs
index c68a72108..68b1e770b 100644
--- a/tui/src/app.rs
+++ b/tui/src/app.rs
@@ -318,6 +318,8 @@ pub struct Tab {
pub layout: Value,
/// Last layout observed on the desk, separate from the local edit awaiting its reply.
pub desk_layout: Value,
+ /// Last pane sequence received from the desk, independent of local tmux numbering.
+ desk_panes: Vec<(String, String)>,
/// A named choice awaiting publication, separate from the last observed desk document.
desk_preset: Option<(usize, &'static str)>,
}
@@ -331,7 +333,7 @@ impl Tab {
pub fn home() -> Tab { Tab::with_wid("home", NO_WID) }
/// A window with the id it had (a session another client kept, the desk's).
pub fn with_wid(name: &str, wid: u64) -> Tab {
- Tab { id: Uuid::new_v4().simple().to_string(), wid: std::cell::Cell::new(wid), size: None, name: name.to_string(), named: false, home: false, root: None, focus: None, zoomed: false, last: Vec::new(), order: Vec::new(), points: HashMap::new(), alerts: 0, last_output: Instant::now(), activity: crate::format::now_secs(), layout_at: None, on_desk: false, sync: false, first_named: false, layout: json!({}), desk_layout: json!({}), desk_preset: None }
+ Tab { id: Uuid::new_v4().simple().to_string(), wid: std::cell::Cell::new(wid), size: None, name: name.to_string(), named: false, home: false, root: None, focus: None, zoomed: false, last: Vec::new(), order: Vec::new(), points: HashMap::new(), alerts: 0, last_output: Instant::now(), activity: crate::format::now_secs(), layout_at: None, on_desk: false, sync: false, first_named: false, layout: json!({}), desk_layout: json!({}), desk_panes: Vec::new(), desk_preset: None }
}
/// Its @N, numbered now if it has none yet.
pub fn wid(&self) -> u64 {
@@ -4500,6 +4502,7 @@ impl App {
/// The desk windows whose layout changed here: their tmux layout to the desk (tab.layout).
pub fn send_desk_layouts(&mut self) {
if self.desk_layouts.is_empty() || !self.session_desk { return }
+ let mut ops = Vec::new();
for id in std::mem::take(&mut self.desk_layouts) {
let Some(tab) = self.tabs.iter_mut().find(|t| t.id == id) else { continue };
let Some(root) = tab.root.as_ref() else { continue };
@@ -4512,10 +4515,19 @@ impl App {
if !tab.layout.get("presets").map(Value::is_object).unwrap_or(false) { tab.layout["presets"] = json!({}) }
tab.layout["presets"][count.to_string()] = json!(preset);
}
- if tab.layout == before { continue }
- let op = json!({ "op": "tab.layout", "id": tab.id, "layout": tab.layout });
- self.desk_op(op);
+ if tab.layout != before { ops.push(json!({ "op": "tab.layout", "id": tab.id, "layout": tab.layout })); }
+ // Desktop uses the shared list in screen order, not our stable pane numbers.
+ // Publish both together, including swaps, rotations and mirrored layouts.
+ let panes: Vec<_> = desk_pane_ids(root).iter().filter_map(|id| self.panes.get(id))
+ .filter(|p| !crate::local::is_local(&p.machine_id))
+ .map(|p| (p.machine_id.clone(), p.agent_id.clone())).collect();
+ if panes != tab.desk_panes {
+ for (index, (machine, agent)) in panes.iter().enumerate() {
+ ops.push(json!({ "op": "pane.move", "tabId": tab.id, "machineId": machine, "agentId": agent, "index": index }));
+ }
+ }
}
+ self.desk_ops(ops);
}
/// window_pane_update_focus: [pane] is focused when it is the current window's active pane,
@@ -4963,6 +4975,7 @@ impl App {
tab.zoomed &= keep_zoom;
self.sync_titles();
self.fit_panes();
+ self.layout_changed(w);
}
/// next-layout / previous-layout (layout_set_next/previous): tmux's seven named layouts in its
@@ -5077,30 +5090,43 @@ impl App {
&& desk_layout_changed(&tab.layout, &layout_doc, panes.len())
&& acknowledged.get(&id) != Some(&layout_doc)
&& !self.desk_layouts.contains(&id);
+ let reordered = tab.desk_panes != panes && !self.desk_layouts.contains(&id);
+ tab.desk_panes = panes.clone();
tab.desk_layout = layout_doc.clone();
tab.layout = layout_doc;
- if relayout && missing_is_empty(&tab.panes(), &panes, &self.panes) {
- let ids = tab.panes();
- let (w, h) = (self.size.0, self.size.1.saturating_sub(2));
- tab.root = desk_root(&tab.layout, preset, &ids, w, h);
+ let have: Vec<(u64, (String, String))> = tab.panes().into_iter().filter_map(|pid| self.panes.get(&pid).map(|p| (pid, (p.machine_id.clone(), p.agent_id.clone())))).collect();
+ let missing = panes.iter().any(|want| !have.iter().any(|(_, key)| key == want));
+ let extra: Vec<u64> = have.iter().filter(|(_, key)| !panes.contains(key)).map(|(pid, _)| *pid).collect();
+ if !missing && extra.is_empty() {
+ let ids: Vec<u64> = panes.iter().filter_map(|key| have.iter().find(|(_, k)| k == key).map(|(id, _)| *id)).collect();
+ if relayout {
+ let (w, h) = (self.size.0, self.size.1.saturating_sub(2));
+ tab.root = desk_root(&tab.layout, preset, &ids, w, h);
+ if reordered { tab.order = ids; }
+ } else if reordered {
+ // A desktop drag changes only the sequence. Keep our exact
+ // split sizes and the focused harness while changing places.
+ if let Some(root) = &mut tab.root {
+ if desk_pane_ids(root) != ids { desk_reorder(root, &ids); tab.order = ids; }
+ }
+ }
continue;
}
- let have: Vec<(u64, (String, String))> = tab.panes().into_iter().filter_map(|pid| self.panes.get(&pid).map(|p| (pid, (p.machine_id.clone(), p.agent_id.clone())))).collect();
- let missing: Vec<&(String, String)> = panes.iter().filter(|want| !have.iter().any(|(_, k)| k == *want)).collect();
- let extra: Vec<u64> = have.iter().filter(|(_, k)| !panes.contains(k)).map(|(pid, _)| *pid).collect();
- if missing.is_empty() && extra.is_empty() { continue }
for pid in &extra {
let tab = &mut self.tabs[index];
tab.root = tab.root.take().and_then(|r| r.remove(*pid));
self.drop_pane(*pid);
}
- let mut new_ids = Vec::new();
- for (m, a) in missing { new_ids.push(self.new_pane_as(m, a, Some(crate::ids::desk(crate::ids::Kind::Pane, &format!("{m}:{a}"))))) }
+ // Insertions belong at their shared index, including before an existing
+ // pane. Never append all new panes after the old local sequence.
+ let ids: Vec<u64> = panes.iter().map(|(m, a)| {
+ have.iter().find(|(_, key)| &key.0 == m && &key.1 == a).map(|(id, _)| *id)
+ .unwrap_or_else(|| self.new_pane_as(m, a, Some(crate::ids::desk(crate::ids::Kind::Pane, &format!("{m}:{a}")))))
+ }).collect();
let tab = &mut self.tabs[index];
- let mut ids = tab.panes();
- ids.extend(new_ids.iter().copied());
let (w, h) = (self.size.0, self.size.1.saturating_sub(2));
tab.root = desk_root(&tab.layout, preset, &ids, w, h);
+ tab.order = ids.clone();
if tab.focus.map(|f| !ids.contains(&f)).unwrap_or(true) { tab.focus = ids.first().copied() }
}
// The same window another session has (link-window, a group), already read: that
@@ -5109,6 +5135,14 @@ impl App {
let Some(mut tab) = self.sessions.iter().flat_map(|s| s.tabs.iter()).find(|t| t.id == id && t.root.is_some()).cloned() else { continue };
tab.alerts = 0;
tab.on_desk = true;
+ let have = tab.panes();
+ let ids: Vec<_> = panes.iter().filter_map(|(m, a)| have.iter().copied().find(|id|
+ self.panes.get(id).is_some_and(|p| &p.machine_id == m && &p.agent_id == a))).collect();
+ if ids.len() == have.len() && ids.len() == panes.len() {
+ if let Some(root) = &mut tab.root { desk_reorder(root, &ids); }
+ tab.order = ids;
+ }
+ tab.desk_panes = panes.clone();
tab.desk_layout = layout_doc.clone();
tab.layout = layout_doc;
if named { tab.name = name; tab.named = true }
@@ -5123,10 +5157,12 @@ impl App {
tab.id = id;
tab.named = named;
tab.on_desk = true;
+ tab.desk_panes = panes.clone();
tab.desk_layout = layout_doc.clone();
tab.layout = layout_doc;
let (w, h) = (self.size.0, self.size.1.saturating_sub(2));
tab.root = desk_root(&tab.layout, preset, &ids, w, h);
+ tab.order = ids.clone();
tab.focus = ids.first().copied();
let at = rows.iter().position(|r| r.get("id").and_then(Value::as_str) == Some(tab.id.as_str())).unwrap_or(self.tabs.len()).min(self.tabs.len());
self.tabs.insert(at, tab);
@@ -5528,8 +5564,28 @@ pub const DESK_MAIN: (&str, &str) = ("50%", "50%");
/// A desk tab's panes laid out: as another terminal left them (its tmux layout, fitted to this
/// one's size), else its preset for that many panes.
fn desk_root(doc: &Value, preset: Preset, ids: &[u64], w: u16, h: u16) -> Option<Node> {
- doc.get("tmux").and_then(Value::as_str).and_then(|l| Node::from_tmux(l, ids, w, h))
- .or_else(|| layout::arrange(layout::Named::of(preset), ids, w, h, layout::Status::Top, DESK_MAIN, ("0", "0")))
+ let mut root = doc.get("tmux").and_then(Value::as_str).and_then(|l| Node::from_tmux(l, ids, w, h))
+ .or_else(|| layout::arrange(layout::Named::of(preset), ids, w, h, layout::Status::Top, DESK_MAIN, ("0", "0")))?;
+ // Numeric pane IDs belong to one hn server. The desk's ordered identities are
+ // authoritative even if a saved native layout has stale or coincidentally matching IDs.
+ desk_reorder(&mut root, ids);
+ Some(root)
+}
+
+/// Desktop numbers its tiles across the top, then down; tmux tree traversal and
+/// pane numbering can differ (a mirrored layout, or columns containing stacks).
+fn desk_pane_ids(root: &Node) -> Vec<u64> {
+ let (w, h) = root.size();
+ let mut rects = Vec::new();
+ root.rects(Rect::new(0, 0, w, h), &mut rects);
+ rects.sort_by_key(|(_, r)| (r.y, r.x));
+ rects.into_iter().map(|(id, _)| id).collect()
+}
+
+fn desk_reorder(root: &mut Node, ids: &[u64]) {
+ let before = desk_pane_ids(root);
+ if before.len() != ids.len() { return }
+ root.relabel(&mut |old| before.iter().position(|p| *p == old).map(|i| ids[i]).unwrap_or(old));
}
fn preset_from_desk(id: &str, count: usize) -> Preset {
@@ -5578,11 +5634,6 @@ fn named_to_desk(named: layout::Named, count: usize) -> Option<&'static str> {
})
}
-/// Whether a tab already shows exactly the desk's panes (only the layout changed).
-fn missing_is_empty(have: &[u64], want: &[(String, String)], panes: &HashMap<u64, Pane>) -> bool {
- have.len() == want.len() && have.iter().all(|id| panes.get(id).map(|p| want.contains(&(p.machine_id.clone(), p.agent_id.clone()))).unwrap_or(false))
-}
-
/// split-window's: where the new pane goes — beside a pane of a window (-t), before it (-b), across
/// the whole window (-f), its size (-l: cells, or a percentage), and whether it is gone to (-d).
#[derive(Clone, PartialEq, Debug)]
@@ -5755,6 +5806,7 @@ mod desk_layout_tests {
tab.on_desk = true;
tab.layout = json!({"presets":{"3":"columns"}});
tab.desk_layout = tab.layout.clone();
+ tab.desk_panes = (1..=3).map(|id| ("layout-peer".into(), format!("agent-{id}"))).collect();
tab.root = layout::arrange(layout::Named::MainHorizontal, &[1, 2, 3], 120, 35, layout::Status::Top, ("80", "12"), ("0", "0"));
tab.focus = Some(1);
for id in 1..=3 {
@@ -5774,6 +5826,78 @@ mod desk_layout_tests {
fn geometry(app: &App) -> String { app.tabs[0].root.as_ref().unwrap().to_tmux() }
+ #[test]
+ fn remote_pane_reorder_keeps_dividers_and_focused_identity() {
+ let mut app = fixture();
+ app.tabs[0].order = vec![1, 2, 3];
+ app.tabs[0].focus = Some(2);
+ let mut expected = app.tabs[0].root.clone().unwrap();
+ expected.relabel(&mut |id| match id { 1 => 3, 2 => 1, 3 => 2, _ => id });
+ let mut update = desk(2, app.tabs[0].layout.clone());
+ update["tabs"][0]["panes"].as_array_mut().unwrap().rotate_right(1);
+ app.apply_desk(&update);
+ assert_eq!(geometry(&app), expected.to_tmux());
+ assert_eq!(app.tabs[0].panes(), vec![3, 1, 2]);
+ assert_eq!(app.tabs[0].focus, Some(2));
+ assert_eq!(app.panes.len(), 3);
+ assert!(app.panes.values().all(|p| matches!(p.phase, Phase::Live)));
+ update["revision"] = json!(3);
+ app.apply_desk(&update);
+ assert_eq!(geometry(&app), expected.to_tmux());
+ }
+
+ #[test]
+ fn remote_order_and_layout_change_apply_together() {
+ let mut app = fixture();
+ let mut update = desk(2, json!({"presets":{"3":"rows"}}));
+ update["tabs"][0]["panes"].as_array_mut().unwrap().rotate_right(1);
+ app.apply_desk(&update);
+ assert_eq!(app.tabs[0].root.as_ref().unwrap().leaves(), vec![3, 1, 2]);
+ assert_eq!(app.tabs[0].panes(), vec![3, 1, 2]);
+ assert_eq!(app.tabs[0].focus, Some(1));
+ }
+
+ #[test]
+ fn saved_native_layout_uses_desk_order_instead_of_old_pane_numbers() {
+ let native = layout::arrange(layout::Named::EvenHorizontal, &[29, 31, 13], 120, 35,
+ layout::Status::Top, DESK_MAIN, ("0", "0")).unwrap();
+ let root = desk_root(&json!({"tmux": native.to_tmux()}), Preset::Columns,
+ &[31, 13, 29], 120, 35).unwrap();
+ assert_eq!(root.leaves(), vec![31, 13, 29]);
+ }
+
+ #[test]
+ fn queued_local_rotation_survives_an_older_desk_snapshot() {
+ let mut app = fixture();
+ app.desk_mode = DeskMode::Read;
+ app.tabs[0].order = vec![1, 2, 3];
+ app.rotate(0, 1, false);
+ let chosen = geometry(&app);
+ let mut update = desk(2, app.tabs[0].layout.clone());
+ update["tabs"][0]["panes"].as_array_mut().unwrap().swap(0, 1);
+ app.apply_desk(&update);
+ assert_eq!(geometry(&app), chosen);
+ app.send_desk_layouts();
+ assert_eq!(geometry(&app), chosen);
+ // Once observed, the same snapshot is metadata, not a fresh reorder.
+ update["revision"] = json!(3);
+ app.apply_desk(&update);
+ assert_eq!(geometry(&app), chosen);
+ update["revision"] = json!(4);
+ update["tabs"][0]["panes"].as_array_mut().unwrap().rotate_right(1);
+ app.apply_desk(&update);
+ assert_eq!(desk_pane_ids(app.tabs[0].root.as_ref().unwrap()), vec![3, 2, 1]);
+ }
+
+ #[test]
+ fn shared_pane_sequence_is_spatial_not_tree_or_tmux_number_order() {
+ let mut root = layout::arrange(layout::Named::MainVerticalMirrored, &[1, 2, 3], 120, 35,
+ layout::Status::Top, DESK_MAIN, ("0", "0")).unwrap();
+ assert_eq!(desk_pane_ids(&root), vec![2, 1, 3]);
+ desk_reorder(&mut root, &[3, 1, 2]);
+ assert_eq!(desk_pane_ids(&root), vec![3, 1, 2]);
+ }
+
#[test]
fn unchanged_remote_layout_does_not_undo_an_unsaved_local_edit() {
let mut app = fixture();
diff --git a/tui/src/format.rs b/tui/src/format.rs
index e0413264a..031c242fb 100644
--- a/tui/src/format.rs
+++ b/tui/src/format.rs
@@ -1004,6 +1004,41 @@ 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 {
+ 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();
+ readings.retain(|(_, u)| u.account.as_deref().filter(|a| !a.is_empty()).map(|a| seen.insert((u.provider.as_str(), a))).unwrap_or(true));
+ readings.iter().filter_map(|(machine, u)| {
+ let used = u.windows.iter().map(|w| w.used).filter(|u| u.is_finite()).reduce(f64::max)?.clamp(0.0, 100.0);
+ let 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);
+ if *machine != local && readings.iter().filter(|(_, other)| other.provider == u.provider).count() > 1 {
+ label.push('@'); label.push_str(&clip_middle(&machine_name(machine), 12));
+ }
+ if marked && used >= 80.0 && !crate::theme::no_color() {
+ Some(format!("{label} #[fg={}]{number}#[fg=default]", quota_color(used)))
+ } else { Some(format!("{label} {number}")) }
+ }).collect::<Vec<_>>().join(" ")
+}
+
+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()
+}
+
+fn quota_color(used: f64) -> &'static str {
+ match (crate::term_out::terminal_is_light().unwrap_or(false), used >= 100.0) {
+ (false, false) => "#f3cc76", (false, true) => "#ff9b8e",
+ (true, false) => "#875600", (true, true) => "#a53028",
+ }
+}
+
/// Compact quota warning: provider plus percentage, with color only on the number.
/// The raw format retains the reset window for scripts and custom status lines.
fn quota_warning<'a>(readings: impl Iterator<Item = &'a crate::fleet::Usage>, marked: bool) -> String {
@@ -1013,12 +1048,8 @@ fn quota_warning<'a>(readings: impl Iterator<Item = &'a crate::fleet::Usage>, ma
} }
let Some((u, w)) = worst else { return String::new() };
if !marked { return format!("{} {} {:.0}%", u.provider, w.label, w.used) }
- let provider = match u.provider.as_str() { "claude" => "Claude", "codex" => "Codex", p => p };
- let light = crate::term_out::terminal_is_light().unwrap_or(false);
- let color = match (light, w.used >= 100.0) {
- (false, false) => "#f3cc76", (false, true) => "#ff9b8e",
- (true, false) => "#875600", (true, true) => "#a53028",
- };
+ let provider = quota_provider(&u.provider);
+ let color = quota_color(w.used);
format!("{provider} #[fg={color}]{:.0}%#[fg=default]", w.used)
}
@@ -1332,6 +1363,10 @@ fn table(app: &App, name: &str, window: usize, pane_id: Option<u64>) -> Option<V
let m = pane.map(|p| p.machine_id.clone()).unwrap_or_else(|| app.fleet.local_id.clone());
app.usage.get(&m).map(|u| u.iter().map(|x| x.line()).collect::<Vec<_>>().join(" · ")).unwrap_or_default()
}
+ // 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"),
"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(),
@@ -1654,6 +1689,49 @@ mod tests {
assert!(wide.contains("[watching — another terminal has it]"));
}
+ fn quota(provider: &str, account: Option<&str>, used: &[f64]) -> crate::fleet::Usage {
+ crate::fleet::Usage { provider: provider.into(), account: account.map(str::to_string),
+ windows: used.iter().map(|used| crate::fleet::Window { label: "limit".into(), used: *used, resets: None }).collect() }
+ }
+
+ #[test]
+ fn remaining_quota_shows_all_subscriptions_and_the_tightest_window() {
+ let claude = quota("claude", Some("a"), &[42.0, 18.0]);
+ let codex = quota("codex", Some("b"), &[3.0, 11.0]);
+ 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), "");
+ // The existing per-window format continues reporting used quota for custom configs.
+ assert_eq!(claude.line(), "claude limit 42% limit 18%");
+ }
+
+ #[test]
+ fn remaining_quota_groups_shared_accounts_but_keeps_distinct_and_unknown_accounts() {
+ let local = quota("claude", Some("a"), &[42.0]);
+ let shared = quota("claude", Some("a"), &[40.0]);
+ let distinct = quota("claude", Some("b"), &[80.0]);
+ 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);
+ }
+
+ #[test]
+ fn remaining_quota_is_plain_until_low_and_does_not_round_to_exhausted() {
+ 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);
+ 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="));
+ }
+ }
+
#[test]
fn quota_warning_marks_only_high_usage_without_reversing_text() {
let mut u = crate::fleet::Usage { provider: "claude".into(), account: None,
diff --git a/tui/src/options/mod.rs b/tui/src/options/mod.rs
index 858ecbb40..b0069b3e7 100644
--- a/tui/src/options/mod.rs
+++ b/tui/src/options/mod.rs
@@ -94,9 +94,12 @@ pub fn defaults() -> &'static BTreeMap<String, String> {
// where there is room. Git context stays here; the status bar keeps the location cue.
m.insert("pane-border-format".into(), " #{pane_heading}#{?pane_where,#[align=right] #[dim]#{pane_where} #[nodim],}".into());
// Session and window navigation on the left; connection, quota, fleet, location and
- // clock on the right. A leading space keeps a full window list from running into it.
- m.insert("status-left".into(), "#{?client_prefix,#[bold],}[#{session_name}]#{?client_prefix, ›#[nobold],} ".into());
- m.insert("status-right".into(), " #{?daemon_down,#[bold]daemon down#[nobold] ,}#{?usage_high,#{usage_high_mark} ,}#{?fleet,#{s/ / /:fleet} ,}#{?pane_watching,[watching] ,}#{?pane_machine,#{=/12/…:pane_machine},#{host_short}}#{?pane_current_path,:#{=/18/…:#{b:pane_current_path}},#{?pane_project,:#{=/18/…:pane_project},}} %H:%M".into());
+ // clock on the right. Always show the desk's local machine/session label so
+ // changing the focused machine or window does not shift the tab list.
+ // One cell at each outer edge aligns status text with the pane surfaces.
+ // Two spaces separate the window list from the information on the right.
+ m.insert("status-left".into(), " #{?client_prefix,#[bold],}[#{session_name}]#{?client_prefix, ›#[nobold],} ".into());
+ m.insert("status-right".into(), " #{?daemon_down,#[bold]daemon down#[nobold] ,}#{?usage_remaining,#{usage_remaining_mark} ,}#{?fleet,#{s/ / /:fleet} ,}#{?pane_watching,[watching] ,}#{?pane_machine,#{=/12/…:pane_machine},#{host_short}}#{?pane_current_path,:#{=/18/…:#{b:pane_current_path}},#{?pane_project,:#{=/18/…:pane_project},}} %H:%M ".into());
// Each window's most urgent harness at a glance (the symbol its pane titles show) and its
// name in a few whole words (#{window_short_name}): a harness is named for its task.
// Keep tmux's familiar current/previous markers beside the name, then any other
@@ -116,7 +119,8 @@ pub fn defaults() -> &'static BTreeMap<String, String> {
m.insert("set-titles-string".into(), "#{?fleet_needs,?#{fleet_needs} ,}#{pane_title}#{?pane_agent_state, (#{pane_agent_state}),} — Harness".into());
// A session is a machine, named as the machine is (tmux's are 0, 1, …): room for its name.
m.insert("status-left-length".into(), "24".into());
- m.insert("status-right-length".into(), "72".into());
+ // Room for both subscription allowances without cutting off location and time.
+ m.insert("status-right-length".into(), "96".into());
// Agents print a lot: ten thousand lines of scrollback (tmux keeps two).
m.insert("history-limit".into(), "10000".into());
// A harness's name is its pane's title; a program's own (OSC 2) only if you say so.
@@ -665,7 +669,7 @@ mod tests {
for name in defaults().keys() { assert!(find(name).is_some(), "{name}") }
// tmux's own default, in the fixture; hn's status-left adds emphasis and a prefix cue.
assert!(include_str!("../../tests/fixtures/tmux-3.5a-options.txt").contains("session status-left \"[#{session_name}] \""));
- assert_eq!(defaults().get("status-left").map(String::as_str), Some("#{?client_prefix,#[bold],}[#{session_name}]#{?client_prefix, ›#[nobold],} "));
+ assert_eq!(defaults().get("status-left").map(String::as_str), Some(" #{?client_prefix,#[bold],}[#{session_name}]#{?client_prefix, ›#[nobold],} "));
assert_eq!(defaults().get("status-interval").map(String::as_str), Some("15"));
}
diff --git a/tui/src/pane_frame.rs b/tui/src/pane_frame.rs
index 6aad6270b..a8580be22 100644
--- a/tui/src/pane_frame.rs
+++ b/tui/src/pane_frame.rs
@@ -5,7 +5,7 @@ use ratatui::layout::Rect;
use crate::layout::Status;
#[derive(Clone, Copy, Debug)]
-pub struct Frame { pub surface: Rect, pub content: Rect, pub title: Option<Rect>, pub outline: Option<Rect> }
+pub struct Frame { pub surface: Rect, pub content: Rect, pub title: Option<Rect> }
pub fn frame(tile: Rect, canvas: Rect, status: Status) -> Frame {
let mut outer = tile;
@@ -20,23 +20,24 @@ pub fn frame(tile: Rect, canvas: Rect, status: Status) -> Frame {
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); }
}
- // Each normal-sized tile owns its outline; the layout's divider remains a gap.
- // A lone or zoomed pane, and compact panes, keep their content space instead.
- let outline = (tile != canvas && tile.width >= 12 && canvas.width >= 40
- && tile.height >= 8 && canvas.height >= 12).then_some(outer);
- let surface = if outline.is_some() {
- Rect::new(outer.x + 1, outer.y + 1, outer.width - 2, outer.height - 2)
- } else { outer };
- let title = (surface.height > 1 && status != Status::Off).then(|| Rect::new(surface.x,
- if status == Status::Bottom { surface.bottom() - 1 } else { surface.y }, surface.width, 1));
- let mut content = surface;
+ // 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, outline }
+ Frame { surface, content, title }
}
#[cfg(test)]
@@ -53,11 +54,7 @@ mod tests {
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); }
- if let Some(outline) = f.outline {
- assert_eq!(outline.intersection(tile), outline);
- assert!(outline.x < f.surface.x && outline.y < f.surface.y);
- assert!(outline.right() > f.surface.right() && outline.bottom() > f.surface.bottom());
- }
+
} } }
}
@@ -66,19 +63,17 @@ mod tests {
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.outline.unwrap().x - left.outline.unwrap().right(), 1);
- assert_eq!(left.outline.unwrap().intersection(right.outline.unwrap()).width, 0);
- assert_eq!(left.outline.unwrap().intersection(right.surface).width, 0);
- assert_eq!(right.outline.unwrap().intersection(left.surface).width, 0);
+ 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.outline.unwrap().y - top.outline.unwrap().bottom(), 1);
- assert_eq!(top.outline.unwrap().intersection(bottom.outline.unwrap()).height, 0);
- assert_eq!(top.outline.unwrap().intersection(bottom.surface).height, 0);
- assert_eq!(bottom.outline.unwrap().intersection(top.surface).height, 0);
+ 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);
- assert!(frame(canvas, canvas, Status::Top).outline.is_none());
- // Short inner tiles share a title row without the normal outer gutter.
- assert!(frame(Rect::new(20, 20, 40, 5), canvas, Status::Top).outline.is_none());
+ 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);
}
}
diff --git a/tui/src/ui.rs b/tui/src/ui.rs
index 0ad5c82c0..8f7a1e67d 100644
--- a/tui/src/ui.rs
+++ b/tui/src/ui.rs
@@ -252,9 +252,8 @@ fn window(buf: &mut Buffer, app: &mut App, body: Rect) -> Option<Position> {
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()));
- // A lone or zoomed pane needs no focus treatment, including in its outer space.
- let surface = if rects.len() == 1 { body } else { f.surface };
- buf.set_style(surface, Style::default().fg(window.0.unwrap_or(Color::Reset)).bg(window.1.unwrap_or(Color::Reset)));
+ // 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)));
}
// choose-tree's tree, over the pane.
if app.panes.get(id).map(|p| p.tree_top()).unwrap_or(false) {
@@ -282,7 +281,7 @@ fn window(buf: &mut Buffer, app: &mut App, body: Rect) -> Option<Position> {
if app.modal.is_some() && !matches!(app.modal, Some(Modal::Copy { .. })) { None } else { cursor }
}
-/// Integrated titles and thin outlines: bright for focus, muted otherwise.
+/// 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());
@@ -297,20 +296,6 @@ fn pane_chrome(buf: &mut Buffer, app: &App) {
let pane_bg = if active { a.bg.or(w.bg) } else { w.bg };
let bg = if own(style_name) { style.bg.or(pane_bg) } else { pane_bg };
let style = style.bg(bg.unwrap_or(Color::Reset));
- if let Some(outline) = f.outline.filter(|_| app.rects.len() > 1) {
- let lines = app.options.get("pane-border-lines", &app.tab().id, Some(*id)).unwrap_or_default();
- let (tl, tr, bl, br, hz, vt, _, _) = box_set(&lines);
- // Border glyphs share the pane's fill: a canvas-colored border cell would
- // leave a visible half-cell gap between the outline and its interior.
- let put = |buf: &mut Buffer, x, y, glyph| {
- if let Some(cell) = buf.cell_mut((x, y)) { cell.set_symbol(glyph).set_style(style); }
- };
- let (right, bottom) = (outline.right() - 1, outline.bottom() - 1);
- for x in outline.x + 1..right { put(buf, x, outline.y, hz); put(buf, x, bottom, hz); }
- for y in outline.y + 1..bottom { put(buf, outline.x, y, vt); put(buf, right, y, vt); }
- put(buf, outline.x, outline.y, tl); put(buf, right, outline.y, tr);
- put(buf, outline.x, bottom, bl); put(buf, right, bottom, br);
- }
let Some(title) = f.title else { continue };
let style = if own(style_name) { style } else {
let palette = theme::pane_palette();
diff --git a/tui/tests/layout-sync.py b/tui/tests/layout-sync.py
index 64c61edbe..1651e3081 100644
--- a/tui/tests/layout-sync.py
+++ b/tui/tests/layout-sync.py
@@ -85,6 +85,17 @@ def scenario(mode, port, read_only=False):
def layout(peer=False):
return hn('display-message', '-p', '#{window_layout}', peer=peer)
+ def placed(peer=False):
+ cells = [r.split('|') for r in hn('list-panes', '-F',
+ '#{pane_id}|#{pane_title}|#{pane_left}|#{pane_top}|#{pane_width}|#{pane_height}', peer=peer).splitlines()]
+ return sorted(cells, key=lambda r: (int(r[3]), int(r[2])))
+
+ def names(peer=False):
+ return [r[1] for r in placed(peer)]
+
+ def desk_names():
+ return [titles[(p['machineId'], p['agentId'])] for p in api()['tabs'][0]['panes']]
+
def columns(peer=False):
rows = [row.split() for row in hn('list-panes', '-F', '#{pane_left} #{pane_top}', peer=peer).splitlines()]
return len(rows) == 3 and len({r[0] for r in rows}) == 3 and len({r[1] for r in rows}) == 1
@@ -122,6 +133,9 @@ def scenario(mode, port, read_only=False):
raise AssertionError('mock startup timeout')
started = True
start()
+ initial = api()['tabs'][0]['panes']
+ titles = {(p['machineId'], p['agentId']): row[1] for p, row in zip(initial, placed())}
+ assert len(titles) == 3
before = layout()
tmux('send-keys', '-t', 'main', 'C-b', 'Space')
wait(columns, 'C-b Space must select even-horizontal and keep it')
@@ -144,6 +158,7 @@ def scenario(mode, port, read_only=False):
stable(chosen, .25)
wait(lambda: api()['tabs'][0]['layout'].get('presets', {}).get('3') == desktop_preset,
f'{name} publishes a desktop-compatible preset')
+ wait(lambda: names() == desk_names(), f'{name} shares the same pane order as desktop')
print(f'PASS {mode}: all seven named layouts survive acknowledgements and share their presets', flush=True)
# The server delays the first save. Without serialization the newer save wins
@@ -224,6 +239,63 @@ def scenario(mode, port, read_only=False):
stable(layout(), .3)
print(f'PASS {mode}: deliberate remote preset still applies', flush=True)
+ # Desktop's drag sends pane.move without replacing the layout. This must
+ # change the order, not rebuild equal dividers or change the focused harness.
+ first, second = placed()[:2]
+ hn('select-pane', '-t', second[0])
+ hn('resize-pane', '-t', first[0], '-D', '2')
+ time.sleep(.4)
+ slots = [r[2:] for r in placed()]
+ focused = hn('display-message', '-p', '#{pane_id}')
+ moved = api()['tabs'][0]['panes'][-1]
+ before_names = names()
+ api('/api/desk/ops', {'ops': [{'op': 'pane.move', 'tabId': 'demo-1', **moved, 'index': 0}]})
+ wait(lambda: names() == desk_names() and names() != before_names, 'remote pane order must follow desktop')
+ assert [r[2:] for r in placed()] == slots, 'reordering changed divider sizes'
+ assert hn('display-message', '-p', '#{pane_id}') == focused, 'reordering moved focus to a different harness'
+ chosen = layout()
+ unrelated_update()
+ stable(chosen, .4)
+ print(f'PASS {mode}: desktop reorder keeps unequal dividers, pane identities and focus', flush=True)
+
+ # A simultaneous geometry change must use the new shared sequence too.
+ moved = api()['tabs'][0]['panes'][-1]
+ api('/api/desk/ops', {'ops': [
+ {'op': 'pane.move', 'tabId': 'demo-1', **moved, 'index': 0},
+ {'op': 'tab.layout', 'id': 'demo-1', 'layout': {'presets': {'3': 'cols3'}}}]})
+ wait(lambda: columns() and names() == desk_names(), 'remote geometry and order apply together')
+
+ # A removed/reopened harness can be inserted at the front rather than appended.
+ removed = api()['tabs'][0]['panes'][-1]
+ api('/api/desk/ops', {'ops': [{'op': 'pane.remove', 'tabId': 'demo-1', **removed}]})
+ wait(lambda: hn('display-message', '-p', '#{window_panes}') == '2', 'pane removed before reinsertion')
+ api('/api/desk/ops', {'ops': [{'op': 'pane.add', 'tabId': 'demo-1', **removed, 'index': 0}]})
+ wait(lambda: len(names()) == 3 and names() == desk_names(), 'reopened pane appears at the shared index')
+ print(f'PASS {mode}: simultaneous order/layout changes and insertion at the front', flush=True)
+
+ # Keyboard reordering travels in the other direction without bouncing back.
+ before_names = names()
+ tmux('send-keys', '-t', 'main', 'C-b', 'C-o')
+ wait(lambda: names() != before_names, 'C-b C-o rotates the panes')
+ chosen = layout()
+ if not read_only:
+ wait(lambda: names() == desk_names(), 'keyboard rotation publishes pane order')
+ unrelated_update()
+ stable(chosen, .5)
+ if not read_only:
+ source, target = [r[0] for r in placed()[:2]]
+ hn('swap-pane', '-s', source, '-t', target, '-d')
+ wait(lambda: names() == desk_names(), 'pane swap publishes pane order')
+ print(f'PASS {mode}: keyboard rotation and swaps preserve the shared sequence', flush=True)
+
+ if mode == 'normal' and not read_only:
+ # A fresh client may reuse numeric pane IDs in a different sequence.
+ # The shared identities, not the saved tmux IDs, decide placement.
+ start(peer=True)
+ wait(lambda: names(peer=True) == desk_names(), 'reopened client follows shared order')
+ hn('kill-server', peer=True, ok=False)
+ print('PASS normal: fresh client agrees with desktop after reorder', flush=True)
+
# The reported case: a two-pane window, with the desktop serializing only
# presets/sizes and dropping hn's native geometry a few seconds later.
removed = api()['tabs'][0]['panes'][-1]
diff --git a/tui/tests/mock-daemon.mjs b/tui/tests/mock-daemon.mjs
index 25499b344..2c6faf274 100644
--- a/tui/tests/mock-daemon.mjs
+++ b/tui/tests/mock-daemon.mjs
@@ -265,6 +265,7 @@ const server = http.createServer((req, res) => {
if (op.op === 'tab.rename') { const t = tab(op.id); if (t) { t.name = op.name; t.nameIsCustom = !!op.nameIsCustom } }
if (op.op === 'tab.layout') { const t = tab(op.id); if (t) t.layout = op.layout }
if (op.op === 'pane.add') { const t = tab(op.tabId); if (t && !t.panes.some((p) => p.agentId === op.agentId)) t.panes.splice(Math.min(op.index ?? t.panes.length, t.panes.length), 0, { machineId: op.machineId, agentId: op.agentId }) }
+ if (op.op === 'pane.move') { const t = tab(op.tabId); const at = t?.panes.findIndex((p) => p.machineId === op.machineId && p.agentId === op.agentId) ?? -1; if (at >= 0) { const [p] = t.panes.splice(at, 1); t.panes.splice(Math.max(0, Math.min(op.index, t.panes.length)), 0, p) } }
if (op.op === 'pane.remove') { const t = tab(op.tabId); if (t) t.panes = t.panes.filter((p) => p.agentId !== op.agentId) }
}
desk.revision++
diff --git a/tui/tests/pane-ui.py b/tui/tests/pane-ui.py
index 0d131ff29..8a12c2022 100644
--- a/tui/tests/pane-ui.py
+++ b/tui/tests/pane-ui.py
@@ -31,19 +31,19 @@ ENV.update(HOME=str(BASE), HN_TMPDIR=str(BASE), HN_SOCKET_NAME=PREFIX, PORT=str(
TERM='xterm-256color', COLORTERM='truecolor', SHELL='/bin/sh', HARNESS_TUI_DESK='sync',
HARNESS_TUI_NOTIFY='off', HN_DESKTOP='off', MOCK_DEMO='1', MOCK_RECONNECT='1', MOCK_USAGE='100')
CONF = BASE / 'tmux.conf'
-CONF.write_text('set -g automatic-rename off\nset -g status-right "#{usage_high_mark} #{s/ / /:fleet} #{pane_machine}:#{b:pane_current_path} 20:41 "\n')
+CONF.write_text('set -g automatic-rename off\nset -g status-right " #{usage_remaining_mark} #{s/ / /:fleet} #{pane_machine}:#{b:pane_current_path} 20:41 "\n')
OUTPUT = Path(os.environ['HN_PANE_UI_OUTPUT']) if os.environ.get('HN_PANE_UI_OUTPUT') else None
if OUTPUT:
OUTPUT.mkdir(parents=True, exist_ok=True)
-def hn(*args, ok=True):
+def hn(*args, ok=True, strip=True):
assert 19783 <= PORT <= 19789 and PREFIX.startswith('hn-pane-ui-')
p = subprocess.run([str(HN), '-L', PREFIX, '--port', str(PORT), '-f', str(CONF), *args], env=ENV,
cwd=BASE, text=True, capture_output=True, timeout=12)
if ok:
assert p.returncode == 0, (args, p.stdout, p.stderr)
- return p.stdout.strip()
+ return p.stdout.strip() if strip else p.stdout.rstrip('\n')
def tmux(*args, ok=True):
@@ -120,7 +120,9 @@ def background(hex_value):
def pane_edge_background(pane, colour):
x, y, w, h = map(int, value('#{pane_left} #{pane_top} #{pane_width} #{pane_height}', pane).split())
points = ((x - 1, y - 2), (x + w, y - 2), (x - 1, y + h),
- (x + w, y + h), (x - 1, y - 1), (x + w, y + h // 2))
+ (x + w, y + h), (x - 1, y - 1), (x + w, y + h // 2),
+ (x - 2, y - 3), (x + w + 1, y - 3), (x - 2, y + h + 1),
+ (x + w + 1, y + h + 1), (x + w // 2, y - 3), (x - 2, y + h // 2))
return all(background_at(col, row) == colour for col, row in points)
@@ -139,9 +141,9 @@ def pane_outline(pane, kind=None):
for glyphs in ([styles[kind]] if kind else styles.values()))
-def pane_outline_color(pane, foreground=True):
+def pane_title_color(pane, foreground=True):
x, y = map(int, value('#{pane_left} #{pane_top}', pane).split())
- return color_at(x - 2, y - 3, foreground=foreground)
+ return color_at(x - 1, y - 2, foreground=foreground)
def snapshot(name):
@@ -188,15 +190,11 @@ try:
inactive_bg = hn('show', '-gwv', 'window-style').split('bg=')[1]
assert active_bg != inactive_bg
assert active_bg == '#000000' and inactive_bg == '#404040'
- wait(lambda: pane_outline(first, 'thin') and pane_outline(second, 'thin') and pane_outline(third, 'thin'), 'separate thin outlines')
+ wait(lambda: not any(pane_outline(p) for p in (first, second, third)), 'pane backgrounds without outlines')
wait(lambda: pane_background(first) == active_bg and pane_background(second) == inactive_bg, 'whole-pane focus contrast')
assert background_at(149, 0) == '#202020', 'dark backdrop surrounds the pane cards'
- wait(lambda: pane_edge_background(first, active_bg), 'focused background fills the area inside its outline')
- assert background_at(49, 20) == background_at(99, 20) == '#202020', 'dark gaps separate independent outlines'
- assert pane_outline_color(first) == '#e2e6eb'
- assert pane_outline_color(second) == '#646464'
- assert pane_outline_color(first, foreground=False) == active_bg
- assert pane_outline_color(second, foreground=False) == inactive_bg
+ wait(lambda: pane_edge_background(first, active_bg), 'focused background fills through the pane edges')
+ assert background_at(49, 20) == background_at(99, 20) == '#202020', 'dark gaps separate pane backgrounds'
assert pane_edge_background(second, inactive_bg)
tab = value(hn('show', '-gwv', 'window-status-current-format'))
label = value('#{window_index}:#{window_short_name}')
@@ -215,34 +213,70 @@ try:
assert 'reverse' not in value('#{fleet}')
assert 'reverse' not in value('#{tree_mode_format}')
assert 'reverse' not in value('#{pane_agent_mark}', second)
- custom_status = hn('show', '-gv', 'status-right')
+ custom_status = hn('show', '-gv', 'status-right', strip=False)
assert 'reverse' not in custom_status
title = value('#{pane_title}', first)
header = value(hn('show', '-gwv', 'pane-border-format'), first)
plain_header = re.sub(r'#\[[^]]*\]', '', header).strip()
assert plain_header.startswith(title + ' '), (title, plain_header)
hn('set', '-gu', 'status-right')
- default_status = hn('show', '-gv', 'status-right')
+ default_status = hn('show', '-gv', 'status-right', strip=False)
assert all(part not in default_status for part in ('pane_branch', 'pane_where', 'git:'))
location = value('#{pane_machine}:#{b:pane_current_path}')
assert location in value(default_status), (location, value(default_status))
wait(lambda: location in tmux('capture-pane', '-p', '-t', 'test').splitlines()[-1], 'bottom right shows the focused machine and folder')
+ def aligned_status_edges():
+ line = tmux('capture-pane', '-p', '-t', 'test').splitlines()[-1]
+ return line.startswith(' [') and len(line.rstrip()) == 149
+ wait(lambda: 'Claude 0% Codex 89%' in tmux('capture-pane', '-p', '-t', 'test').splitlines()[-1], 'default status includes both subscription allowances')
+ wait(aligned_status_edges, 'default status text has one outer space matching the pane margins')
hn('set', '-g', 'status-right', custom_status)
+ default_left = hn('show', '-gv', 'status-left', strip=False)
+ session = value('#{session_name}')
+ assert session == value('#{pane_machine}'), 'desk session is named for the local machine'
+ for target in (third, second, first):
+ hn('select-pane', '-t', target)
+ assert value(default_left).strip() == '[' + session + ']'
+ wait(lambda: tmux('capture-pane', '-p', '-t', 'test').splitlines()[-1].startswith(' [' + session + ']'), 'local machine label stays visible across local and remote panes')
+ for window in hn('list-windows', '-F', '#{window_id}').splitlines():
+ hn('select-window', '-t', window)
+ assert value(default_left).strip() == '[' + session + ']'
+ wait(lambda: tmux('capture-pane', '-p', '-t', 'test').splitlines()[-1].startswith(' [' + session + ']'), 'local machine label stays visible in every window')
+ hn('select-window', '-t', current)
+ hn('select-pane', '-t', first)
+ keys('C-b')
+ wait(lambda: '[' + session + '] ›' in tmux('capture-pane', '-p', '-t', 'test').splitlines()[-1], 'prefix cue stays beside the local machine label')
+ keys('Escape')
+ hn('rename-session', 'work-review')
+ assert value(default_left).strip() == '[work-review]', 'distinct session labels remain visible'
+ hn('set', '-g', 'status-left', '[custom] ')
+ assert value(hn('show', '-gv', 'status-left')).strip() == '[custom]'
+ hn('set', '-gu', 'status-left')
+ hn('rename-session', session)
for option in ('window-status-activity-style', 'window-status-bell-style'):
assert hn('show', '-gwv', option) == 'bold'
assert 'reverse' not in hn('show', '-gv', 'status-format[1]')
- wait(lambda: 'Claude 100%' in tmux('capture-pane', '-p', '-t', 'test').splitlines()[-1], 'plain quota warning reaches the status row')
+ wait(lambda: 'Claude 0% Codex 89%' in tmux('capture-pane', '-p', '-t', 'test').splitlines()[-1], 'all subscription allowances reach the status row, even below the warning threshold')
+ assert value('#{usage_remaining}') == 'Claude 0% Codex 89%', 'accounts shared across fixture machines appear once'
+ assert value('#{usage_high}') == 'claude 5h 100%', 'existing custom used-quota format is preserved'
+ row = tmux('capture-pane', '-p', '-t', 'test').splitlines()[-1]
+ assert color_at(row.index('0%'), 41, foreground=True) == '#ff9b8e', 'exhausted allowance uses red text'
+ assert color_at(row.index('89%'), 41, foreground=True) == color_at(row.index('Codex'), 41, foreground=True), 'healthy allowance has no warning styling'
+ assert background_at(row.index('0%'), 41) == background_at(row.index('Codex'), 41), 'subscription text keeps the continuous status background'
hn('set', '-gw', 'pane-border-lines', 'double')
- wait(lambda: pane_outline(first, 'double') and pane_outline(second, 'double'), 'explicit border line choice overrides thin default')
+ wait(lambda: not pane_outline(first) and not pane_outline(second), 'border line options do not draw outlines in pane appearance')
+ hn('set', '-g', '@hn-look', 'classic')
+ wait(lambda: '║' in tmux('capture-pane', '-p', '-t', 'test'), 'classic appearance keeps explicit border lines')
+ hn('set', '-g', '@hn-look', 'panes')
hn('set', '-gwu', 'pane-border-lines')
hn('set', '-w', 'pane-active-border-style', 'fg=#aabbcc,bg=#123456')
hn('set', '-w', 'pane-border-style', 'fg=#778899,bg=#654321')
- wait(lambda: pane_outline_color(first) == '#aabbcc' and pane_outline_color(second) == '#778899', 'window border colors override the palette')
- assert pane_outline_color(first, foreground=False) == '#123456'
- assert pane_outline_color(second, foreground=False) == '#654321'
+ wait(lambda: pane_title_color(first) == '#aabbcc' and pane_title_color(second) == '#778899', 'window border styles still customize pane titles')
+ assert pane_title_color(first, foreground=False) == '#123456'
+ assert pane_title_color(second, foreground=False) == '#654321'
hn('set', '-wu', 'pane-active-border-style')
hn('set', '-wu', 'pane-border-style')
- wait(lambda: pane_outline(first, 'thin') and pane_outline(second, 'thin') and pane_outline_color(first) == '#e2e6eb', 'automatic border appearance restored')
+ wait(lambda: not pane_outline(first) and not pane_outline(second) and pane_edge_background(first, active_bg), 'borderless pane appearance restored')
snapshot('panes-columns')
print('PASS pane UI: whole-pane focus contrast, name before status, compact quota and location', flush=True)
@@ -262,8 +296,8 @@ try:
keys('C-b', 'Right')
wait(lambda: value('#{pane_id}') == second, 'C-b Right with insets')
wait(lambda: pane_background(second) == active_bg and pane_background(first) == inactive_bg, 'keyboard focus moves pane contrast')
- wait(lambda: pane_outline(second, 'thin') and pane_outline(first, 'thin') and pane_outline_color(second) == '#e2e6eb' and pane_outline_color(first) == '#646464', 'keyboard focus moves border brightness without stale borders')
- wait(lambda: pane_edge_background(second, active_bg) and pane_outline_color(second, foreground=False) == active_bg and pane_outline_color(first, foreground=False) == inactive_bg, 'focused fill reaches the border after keyboard selection')
+ wait(lambda: not pane_outline(second) and not pane_outline(first), 'keyboard focus leaves no outlines')
+ wait(lambda: pane_edge_background(second, active_bg) and pane_edge_background(first, inactive_bg), 'background focus reaches all pane edges after keyboard selection')
keys('C-b', 'Right')
wait(lambda: value('#{pane_id}') == third, 'second C-b Right')
keys('C-b', 'Right')
@@ -273,8 +307,10 @@ try:
branch_context = value('#{pane_where}')
assert '⑂ ' + value('#{pane_branch}') in branch_context, branch_context
assert 'git:(' not in branch_context
- wait(lambda: not pane_outline(first) and background_at(0, 0) == active_bg, 'zoomed pane has no border or gray surround')
- assert background_at(0, 41) == normal_bg, 'status bar keeps its own color'
+ wait(lambda: not pane_outline(first) and background_at(1, 1) == active_bg
+ and background_at(0, 0) == background_at(149, 40) == '#202020',
+ 'zoomed pane keeps its focused surface inside the canvas')
+ wait(lambda: background_at(0, 41) == normal_bg, 'status bar keeps its own color after transient completion notices')
x, y, w = map(int, value('#{pane_left} #{pane_top} #{pane_width}', first).split())
wait(lambda: tmux('capture-pane', '-p', '-t', 'test').splitlines()[y - 2][x:x + w].rstrip().endswith(branch_context), 'branch and PR align to the right edge')
snapshot('panes-zoomed')
@@ -307,7 +343,7 @@ try:
mouse(0, second_x, second_y - 2, release=True)
wait(lambda: value('#{pane_id}') == second, 'click the pane header')
wait(lambda: pane_background(second) == active_bg and pane_background(first) == inactive_bg, 'mouse focus moves pane contrast')
- wait(lambda: pane_outline(second, 'thin') and pane_outline(first, 'thin') and pane_outline_color(second) == '#e2e6eb' and pane_outline_color(first) == '#646464', 'mouse focus moves border brightness')
+ wait(lambda: not pane_outline(second) and not pane_outline(first), 'mouse focus leaves no outlines')
assert len(api()['inputs']) == before, api()['inputs'][before:]
mouse(0, border, 10)
mouse(32, border + 3, 10)
@@ -385,7 +421,7 @@ try:
background('#f7f7f7')
wait(lambda: hn('show', '-gwv', 'window-active-style') == 'fg=#1a1a1a,bg=#f7f7f7', 'light surface defaults')
wait(lambda: pane_background(first) == '#f7f7f7' and pane_background(second) == '#e5e5e5', 'light focus contrast')
- wait(lambda: pane_edge_background(first, '#f7f7f7') and pane_outline_color(first, foreground=False) == '#f7f7f7', 'light surface fills the focused pane through its border')
+ wait(lambda: pane_edge_background(first, '#f7f7f7') and pane_title_color(first, foreground=False) == '#f7f7f7', 'light surface fills the focused pane through its padding')
light_status = hn('show', '-gv', 'status-style')
assert value('#{window_layout}') == layout_before_theme
snapshot('panes-light')
@@ -395,7 +431,7 @@ try:
assert hn('show', '-gwv', 'window-style') == 'fg=red,bg=blue'
assert hn('show', '-gwv', 'window-active-style') == 'default'
wait(lambda: pane_background(first) == 'colour4' and pane_background(second) == 'colour4', 'custom backgrounds win on active and inactive panes')
- wait(lambda: pane_edge_background(first, 'colour4') and pane_outline_color(first, foreground=False) == 'colour4', 'custom pane background fills the focused pane through its border')
+ wait(lambda: pane_edge_background(first, 'colour4') and pane_title_color(first, foreground=False) == 'colour4', 'custom pane background fills the focused pane through its padding')
assert len(api()['inputs']) == before, 'terminal query replies reached an application'
hn('set', '-gwu', 'window-style')
assert hn('show', '-gwv', 'window-active-style').startswith('fg=#f5f5f5,')
@@ -416,11 +452,13 @@ try:
single = hn('new-window', '-n', 'single', '-P', '-F', '#{pane_id}', '/bin/sh')
wait(lambda: value('#{pane_id}') == single and value('#{window_panes}') == '1', 'single-pane window')
- wait(lambda: not pane_outline(single) and background_at(0, 0) == '#101010', 'single pane has no outline or gray surround')
+ wait(lambda: not pane_outline(single) and background_at(1, 1) == '#101010'
+ and background_at(0, 0) == background_at(149, 40) == '#202020',
+ 'single pane keeps its focused surface inside the canvas')
snapshot('panes-single')
hn('kill-window')
wait(lambda: value('#{window_id}') == current, 'return from single-pane window')
- print('PASS pane UI: independent pane cards, right-aligned context and single-pane presentation', flush=True)
+ print('PASS pane UI: borderless pane surfaces, right-aligned context and single-pane presentation', flush=True)
finally:
if started:
if OUTPUT:
diff --git a/tui/tests/viewer-live.mjs b/tui/tests/viewer-live.mjs
index eac387c4c..6baec1a98 100644
--- a/tui/tests/viewer-live.mjs
+++ b/tui/tests/viewer-live.mjs
@@ -390,6 +390,25 @@ try {
})
assert.equal((await layoutHn('list-panes', '-F', '#{pane_id}')).stdout, paneIds)
pass('real C-b Space survives desktop serialization; deliberate remote changes still apply without replacing panes')
+ // Reordering from desktop uses the same real desk API as the UI. Keep the
+ // unequal slots and focused harness, then exercise the reverse direction.
+ const placed = async () => (await layoutHn('list-panes', '-F',
+ '#{pane_id}|#{pane_left}|#{pane_top}|#{pane_width}|#{pane_height}')).stdout.trim().split('\n')
+ .map(row => row.split('|')).sort((a, b) => Number(a[2]) - Number(b[2]) || Number(a[1]) - Number(b[1]))
+ const initial = await placed()
+ await layoutHn('select-pane', '-t', initial[1][0])
+ await layoutHn('resize-pane', '-t', initial[0][0], '-D', '2')
+ const resized = (await layoutHn('display-message', '-p', '#{window_layout}')).stdout.trim()
+ await until('real divider saved before reorder', async () => (await desk()).tabs.find(t => t.id === layoutTab)?.layout?.tmux === resized)
+ const slots = (await placed()).map(row => row.slice(1))
+ await desk([{ op: 'pane.move', tabId: layoutTab, machineId, agentId: controlsId, index: 0 }])
+ await until('real desktop reorder reaches hn', async () => (await placed())[0][0] === initial[1][0])
+ assert.deepEqual((await placed()).map(row => row.slice(1)), slots)
+ assert.equal((await layoutHn('display-message', '-p', '#{pane_id}')).stdout.trim(), initial[1][0])
+ await layoutHn('swap-pane', '-s', initial[0][0], '-t', initial[1][0], '-d')
+ await until('real terminal swap reaches desktop', async () => (await desk()).tabs.find(t => t.id === layoutTab).panes[0].agentId === agentId)
+ assert.deepEqual((await placed()).map(row => row[0]), initial.map(row => row[0]))
+ pass('desktop reorder and terminal swap share pane order through the real backend, preserving focus and dividers')
await layoutHn('kill-server')
await owner.rpc('agent_delete', { agentId: controlsId }); controlsId = null