Intelligence Modes
PaneLayoutIntelligenceMode is a coarse-grained preset that tells the
layout planner what the user is trying to do right now. It is not a
theme or a skin — it changes the math that decides which pane shrinks
first, which splits are collapsible, and how aggressively the planner
normalizes ratios.
The four modes
pub enum PaneLayoutIntelligenceMode {
Focus,
Compare,
Monitor,
Compact,
}| Mode | What it optimizes for |
|---|---|
Focus | One pane is active; everything else yields space to it. |
Compare | Two panes side-by-side at equal size; ratios are aggressively normalized. |
Monitor | A thin strip at the top for live data; the rest is a primary viewport. |
Compact | Minimum widths everywhere; aggressive ellipsis, collapsible secondary panes. |
Where modes live in the stack
User presses the cycle key / right-clicks the pane header
│
▼
runtime layer picks a new mode
│
▼
PaneTree::plan_intelligence_mode(mode, anchor_id)
│
▼
returns Vec<PaneOperation> — usually
a sequence of SetSplitRatio + NormalizeRatios
│
▼
caller applies each op through the journaler
│
▼
tree reshapes; timeline records the reshapeThe planner returns operations, not rectangles. This preserves the invariant that every layout change is a journaled operation — modes are not a “secret mutation” channel.
Right-click cycling
The showcase and reference UIs bind the intelligence mode to a right-
click on the pane title bar (or a keybind like Ctrl-Shift-M). Cycling
order is the declaration order above: Focus → Compare → Monitor → Compact → Focus …. Each transition runs plan_intelligence_mode with
the currently-focused pane as the anchor.
What each mode actually does
Focus
The anchor pane grows to take as much space as its constraints allow.
Siblings contract to their minimums. If sibling constraints have
collapsible = true, they are candidates for removal in a subsequent
normalization pass.
Before (equal thirds): After Focus on middle:
┌───┬───┬───┐ ┌─┬───────┬─┐
│ A │ B │ C │ │A│ B │C│
└───┴───┴───┘ └─┴───────┴─┘Compare
The anchor pane and its immediate sibling are resized to a 50/50 split; all other ratios are normalized to reduced form. Useful for diff views and A/B comparisons.
Before: After Compare on B:
┌───┬─┬───────┐ ┌─────┬─────┐
│ A │B│ C │ │ A │ B │
└───┴─┴───────┘ └─────┴─────┘
(C may close if collapsible)Monitor
Reserves the top of the layout for a strip pane (a ticker, a live
metric, a log tail) and gives the rest of the vertical budget to the
main content. The anchor is the “main content” pane; the strip is the
ancestor split at axis Horizontal if present.
┌────────────────────────┐ ← ticker strip, minimum height
├────────────────────────┤
│ │
│ primary viewport │ ← anchor; grows to fill
│ │
└────────────────────────┘Compact
Lowers all minimums to the smallest render-safe value, enables the
collapsible flag on non-anchor panes, and normalizes ratios. Used on
very narrow terminals or when the user signals “give me more of
something I care about.”
Worked example
use ftui_layout::pane::{PaneLayoutIntelligenceMode, PaneTree};
let mut tree = /* build some tree */;
let anchor = tree.focused_leaf().unwrap();
let ops = tree.plan_intelligence_mode(
PaneLayoutIntelligenceMode::Focus,
anchor,
);
for (i, op) in ops.into_iter().enumerate() {
tree.apply_operation((i as u64) + 1, op)?;
}The planner can return zero operations if the tree is already in the shape the mode wants. That’s a valid outcome — the caller should not fabricate a cosmetic operation just to have something to journal.
When is each mode actually useful?
Focus — deep work
You’re writing code in pane B and you want panes A and C to get out of the way. Hit the mode cycle, keep typing. Hit it again to recover the balanced view.
Compare — diff reviews and A/B
Two terminals side-by-side, or a diff view. 50/50 is what you want; nothing else.
Monitor — dashboards
A Grafana-style TUI with a ticker, a chart, and a log. The chart is the anchor; the ticker never grows past a few lines.
Compact — narrow windows
On an 80-column terminal or a half-screen split, Compact hides
non-essential panes rather than crushing everything into illegibility.
Pitfalls
Modes reshape; they don’t remember. Switching to Compare discards
the previous ratios. If the user wants them back, they must undo or
switch back explicitly. Modes are not checkpoints.
An anchor must be a leaf. plan_intelligence_mode is not defined
for a split node anchor in every mode. If you’re not sure which node
has focus, pick the last-focused leaf from your focus manager.
Modes emit operations, not effects. They land in the timeline just like user actions. Undo undoes the mode change, op by op.
Where to go next
How the emitted ops are journaled and undone.
Operations and timelineThe complementary user-driven mechanism for reshaping.
Magnetic dockingcollapsible and other per-node constraints the modes read.
How right-click cycling enters the pane layer.
Events and input (core)How this piece fits in panes.
Panes overview