Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

feat(gui): lift the current agent's card

RoversX7f202978015e
diff --git a/wezterm-gui/src/termwindow/ui/agent_panel.rs b/wezterm-gui/src/termwindow/ui/agent_panel.rs
index 54adb08d..80b360f8 100644
--- a/wezterm-gui/src/termwindow/ui/agent_panel.rs
+++ b/wezterm-gui/src/termwindow/ui/agent_panel.rs
@@ -45,6 +45,10 @@ const AGENT_ROW_GAP: usize = 10;
const AGENT_ROW_EXTRA_INSET: usize = 6;
/// Sub-task lines a row shows before it says how many more there are.
const AGENT_SUBTASKS_SHOWN: usize = 5;
+/// How much lighter than the panel the row of the agent in the active pane
+/// is, in perceived lightness (OkLab L): a card lifted a little, on any
+/// theme.
+const AGENT_ACTIVE_ROW_STEP: f32 = 0.075;
impl TermWindow {
/// The strip above the list: one row holding the status line and the
@@ -247,11 +251,23 @@ impl TermWindow {
// Between rows of a group: plain enough to stay out of the way, but
// a shade firmer than the separator token, which vanished here.
let divider = muted_fg.mul_alpha(0.22);
- // The agent in the pane this window is on lies on a faint tint of
- // the accent, so the list shows where you are; a hover still shows
- // through it.
+ // The agent in the pane this window is on lies on the panel's ground
+ // a step lighter, a card lifted off it, so the list shows where you
+ // are. A step of perceived lightness looks the same in every theme
+ // and keeps a scheme's tint: a grey at a fixed alpha was plain on
+ // dark and all but gone on light, darker read as pressed there, and
+ // the accent, a different colour in every theme, looked muddy. Only
+ // a ground too light to lift (near white) takes the step darker.
let active_pane_id = self.get_active_pane_no_overlay().map(|pane| pane.pane_id());
- let active_tint = chrome.accent.mul_alpha(0.14);
+ let active_fill = self.chrome_surface(crate::ui::color::lifted(
+ chrome.workspace_sidebar_bg,
+ AGENT_ACTIVE_ROW_STEP,
+ ));
+ // A hover is drawn over it: on a light theme a thin grey rather than
+ // the palette's near-white, which is what the current row is there.
+ let hover_fill = chrome.hover_fill(chrome.sidebar_button_hover_bg);
+ // Both fills a little rounder than the snippet cards they started as.
+ let row_radius = self.ui_f32(SIDEBAR_ROW_RADIUS + 3.0) + 10.0;
// A working description shimmers from the quieter grey up to white
// (black on a light theme): from the brighter grey the light that
// passed was too close to the text to see.
@@ -460,7 +476,7 @@ impl TermWindow {
content_width,
band.visible_height,
);
- if hovered {
+ if Some(agent.pane_id) == active_pane_id {
self.fill_rounded_rectangle(
layers,
1,
@@ -470,12 +486,12 @@ impl TermWindow {
content_width as f32,
band.visible_height as f32,
),
- chrome.sidebar_button_hover_bg,
- self.ui_f32(SIDEBAR_ROW_RADIUS) + 10.0,
+ active_fill,
+ row_radius,
)
- .context("agent row hover")?;
+ .context("active agent row")?;
}
- if Some(agent.pane_id) == active_pane_id {
+ if hovered {
self.fill_rounded_rectangle(
layers,
1,
@@ -485,10 +501,10 @@ impl TermWindow {
content_width as f32,
band.visible_height as f32,
),
- active_tint,
- self.ui_f32(SIDEBAR_ROW_RADIUS) + 10.0,
+ hover_fill,
+ row_radius,
)
- .context("active agent row")?;
+ .context("agent row hover")?;
}
let in_this_window = agent.window_id == Some(self.mux_window_id);
self.ui_items.push(UIItem {
diff --git a/wezterm-gui/src/ui/color.rs b/wezterm-gui/src/ui/color.rs
index ca9d7ab6..62d8de41 100644
--- a/wezterm-gui/src/ui/color.rs
+++ b/wezterm-gui/src/ui/color.rs
@@ -20,6 +20,35 @@ pub(crate) fn mix(from: LinearRgba, to: LinearRgba, t: f32) -> LinearRgba {
)
}
+/// `ground` moved `step` of perceived lightness (OkLab L; a negative step
+/// darkens), keeping its tint. A step reads the same on any ground, where a
+/// grey laid over it at a fixed alpha is plain on a dark one and all but
+/// lost on a light one.
+pub(crate) fn lightness_step(ground: LinearRgba, step: f32) -> LinearRgba {
+ let [l, a, b, alpha] = ground.to_oklaba();
+ from_oklab_clamped(l + step, a, b, alpha)
+}
+
+/// `ground` a `step` lighter, a card lifted off it -- or, where it is too
+/// light for that to show (a near-white ground has no room above it), the
+/// same step darker.
+pub(crate) fn lifted(ground: LinearRgba, step: f32) -> LinearRgba {
+ let l = ground.to_oklaba()[0];
+ lightness_step(ground, if l + step <= 1.0 { step } else { -step })
+}
+
+/// The colour of perceived lightness `l` (OkLab L, kept within 0..=1) with
+/// the tint `a`, `b`, clamped into what a screen shows.
+pub(crate) fn from_oklab_clamped(l: f32, a: f32, b: f32, alpha: f32) -> LinearRgba {
+ let out = LinearRgba::from_oklaba(l.clamp(0.0, 1.0), a, b, alpha);
+ LinearRgba::with_components(
+ out.0.clamp(0.0, 1.0),
+ out.1.clamp(0.0, 1.0),
+ out.2.clamp(0.0, 1.0),
+ alpha,
+ )
+}
+
// The standard sRGB transfer function, written out rather than reached for on
// `LinearRgba`/`SrgbaTuple`: those two use different curves (one exact, one a
// gamma-2.2 approximation) and so do not round-trip. These are exact inverses,
@@ -67,4 +96,27 @@ mod tests {
assert!((mix(clear, solid, 0.5).3 - 0.6).abs() < 1e-6);
assert_eq!(mix(clear, clear, 0.7).3, 0.2);
}
+
+ #[test]
+ fn a_lightness_step_is_the_same_on_dark_and_light_and_keeps_the_tint() {
+ let l = |c: LinearRgba| c.to_oklaba()[0];
+ let dark = LinearRgba::with_srgba(18, 18, 20, 255);
+ let light = LinearRgba::with_srgba(226, 226, 232, 255);
+ assert!((l(lightness_step(dark, 0.075)) - l(dark) - 0.075).abs() < 1e-3);
+ let darker = lightness_step(light, -0.075);
+ assert!((l(light) - l(darker) - 0.075).abs() < 1e-3);
+ // A blue-grey ground steps to a blue-grey.
+ assert!(darker.2 > darker.0);
+ assert_eq!(darker.3, 1.0);
+ }
+
+ #[test]
+ fn a_lift_shows_even_on_a_near_white_ground() {
+ let l = |c: LinearRgba| c.to_oklaba()[0];
+ let dark = LinearRgba::with_srgba(18, 18, 20, 255);
+ assert!((l(lifted(dark, 0.075)) - l(dark) - 0.075).abs() < 1e-3);
+ // No room above white: a step down instead of none at all.
+ let white = LinearRgba::with_srgba(252, 252, 253, 255);
+ assert!((l(white) - l(lifted(white, 0.075)) - 0.075).abs() < 1e-3);
+ }
}
diff --git a/wezterm-gui/src/ui/tokens.rs b/wezterm-gui/src/ui/tokens.rs
index 9956acaa..385a936f 100644
--- a/wezterm-gui/src/ui/tokens.rs
+++ b/wezterm-gui/src/ui/tokens.rs
@@ -173,12 +173,10 @@ impl UiPalette {
};
let moved = |color: LinearRgba| -> LinearRgba {
let [l, _, _, alpha] = color.to_oklaba();
- let shifted = (ground_l + fit + (l - base_l)).clamp(0.0, 1.0);
- let out = LinearRgba::from_oklaba(shifted, ground_a, ground_b, alpha);
- LinearRgba::with_components(
- out.0.clamp(0.0, 1.0),
- out.1.clamp(0.0, 1.0),
- out.2.clamp(0.0, 1.0),
+ crate::ui::color::from_oklab_clamped(
+ ground_l + fit + (l - base_l),
+ ground_a,
+ ground_b,
alpha,
)
};