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(agents): show which machine each agent runs on

RoversXe12a45328d15
diff --git a/assets/ui/laptop-off.svg b/assets/ui/laptop-off.svg
new file mode 100644
index 00000000..210851a7
--- /dev/null
+++ b/assets/ui/laptop-off.svg
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M8.5 5H18a2 2 0 0 1 2 2v8.5" />
+ <path d="M16.5 20H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7.5" />
+ <path d="M12.5 15.987H3.946" />
+ <path d="m2 2 20 20" />
+</svg>
diff --git a/wezterm-gui/src/termwindow/ui/agent_panel.rs b/wezterm-gui/src/termwindow/ui/agent_panel.rs
index 3fdfe272..661380f1 100644
--- a/wezterm-gui/src/termwindow/ui/agent_panel.rs
+++ b/wezterm-gui/src/termwindow/ui/agent_panel.rs
@@ -22,7 +22,7 @@ use anyhow::Context;
use mux::pane::PaneId;
use mux::Mux;
use std::borrow::Borrow;
-use std::collections::HashSet;
+use std::collections::{HashMap, HashSet};
use std::rc::Rc;
use std::sync::Arc;
use wezterm_client::domain::FrontendRecoverySlot;
@@ -276,6 +276,11 @@ impl TermWindow {
};
// Its colours are blended once a frame, not once a glyph: steps this
// fine are closer than the eye tells apart across a band this narrow.
+ // How each server the agents run on is reached, asked once a frame.
+ let mut reach: HashMap<
+ mux::domain::DomainId,
+ crate::termwindow::ui::sidebar::SpaceConnectionState,
+ > = HashMap::new();
let shimmer_ramp: [LinearRgba; SHIMMER_RAMP_STEPS] = std::array::from_fn(|step| {
crate::ui::color::mix(
muted_fg,
@@ -383,6 +388,9 @@ impl TermWindow {
muted_fg,
)?;
}
+ // Grouped by state, the heading over a row already names its state.
+ let under_state_heading =
+ view.group_by() == crate::native_settings::AgentsGroupBy::State;
// The walk starts at the first entry that reaches into view and
// stops below it, so the rows above and below cost nothing.
let first = list.ends.partition_point(|&end| end as f32 <= scroll);
@@ -593,7 +601,8 @@ impl TermWindow {
// Under the title: what it is doing, then where. The state icon
// already says the state, so the words only stand in for it
// when there is no icon, or nothing else to put on the line --
- // and for Idle, whose check differs from Done's only in colour.
+ // and for Idle, whose check differs from Done's only in colour,
+ // unless the heading over it says Idle already.
let mut line_y = title_y + cell_height + line_gap;
if let Some(report) = agent.report.as_ref().filter(|_| layout.message) {
if visible(line_y, cell_height) {
@@ -649,7 +658,7 @@ impl TermWindow {
// The thread's human name, resolved once per snapshot -- never the
// internal workspace id, and never a per-frame store walk.
let place_line = if has_state_icon
- && shown != agent_status::ShownState::Idle
+ && (shown != agent_status::ShownState::Idle || under_state_heading)
&& !agent.place.is_empty()
{
agent.place.clone()
@@ -662,14 +671,77 @@ impl TermWindow {
}
};
if visible(line_y, cell_height) {
+ // Where it runs, before the words: this device or a server,
+ // with a light on it while that machine is reached -- green,
+ // or amber while it is being reached again -- and crossed
+ // out when it is not.
+ use crate::termwindow::ui::sidebar::SpaceConnectionState as Reach;
+ let local = agent.machine.is_empty();
+ let reached = Mux::get().get_pane(agent.pane_id).map(|pane| {
+ let domain_id = pane.domain_id();
+ *reach
+ .entry(domain_id)
+ .or_insert_with(|| self.machine_reach(domain_id))
+ });
+ let machine_icon = match (local, reached == Some(Reach::Disconnected)) {
+ (true, false) => SvgIcon::Laptop,
+ (true, true) => SvgIcon::LaptopOff,
+ (false, false) => SvgIcon::Server,
+ (false, true) => SvgIcon::ServerOff,
+ };
+ let machine_size = (cell_height * 4 / 5).max(1);
+ let machine_y = line_y + (cell_height - machine_size) / 2;
+ self.paint_sidebar_icon(
+ layers,
+ machine_icon,
+ text_x,
+ machine_y,
+ machine_size,
+ muted_fg,
+ )?;
+ let light = match reached {
+ Some(Reach::Connected) => Some(crate::thread_marks::FINISHED_COLOR),
+ Some(Reach::Connecting | Reach::Reconnecting) => {
+ Some(crate::thread_marks::WAITING_COLOR)
+ }
+ Some(Reach::Disconnected) | None => None,
+ };
+ if let Some(color) = light {
+ // On the drawing's own corner -- the laptop's screen, the
+ // server's top box -- as a light sits on a device; in
+ // 24ths of the icon, as lucide draws them.
+ let (corner_x, corner_y) = if local {
+ (19.5, 5.5)
+ } else {
+ (21.0, 3.0)
+ };
+ let dot = (machine_size * 2 / 5).max(3) as f32;
+ let center_x = text_x as f32 + machine_size as f32 * corner_x / 24.0;
+ let center_y = machine_y as f32 + machine_size as f32 * corner_y / 24.0;
+ self.fill_rounded_rectangle(
+ layers,
+ 2,
+ euclid::rect(
+ (center_x - dot / 2.0).round(),
+ (center_y - dot / 2.0).round(),
+ dot,
+ dot,
+ ),
+ color,
+ dot / 2.0,
+ )
+ .context("agent machine dot")?;
+ }
+ // A full gap: the dot stands out past the icon's edge.
+ let label_x = text_x + machine_size + metrics.icon_gap;
self.paint_agent_text(
layers,
ui_font,
ui_metrics,
&place_line,
- text_x,
+ label_x,
line_y,
- text_width,
+ text_right.saturating_sub(label_x),
muted_fg,
)?;
}
@@ -930,6 +1002,27 @@ impl TermWindow {
Ok(())
}
+ /// How the server a pane lives on is reached: a pane of this process
+ /// always is. Read as the panel paints, which asks for no frame of its
+ /// own: a light that changes shows at the next.
+ fn machine_reach(
+ &self,
+ domain_id: mux::domain::DomainId,
+ ) -> crate::termwindow::ui::sidebar::SpaceConnectionState {
+ use crate::termwindow::ui::sidebar::SpaceConnectionState;
+ let Some(domain) = Mux::get().get_domain(domain_id) else {
+ return SpaceConnectionState::Disconnected;
+ };
+ if domain
+ .downcast_ref::<wezterm_client::domain::ClientDomain>()
+ .is_none()
+ {
+ return SpaceConnectionState::Connected;
+ }
+ let remote = !crate::local_sessions::is_host_domain_id(domain_id);
+ self.domain_reach(domain.domain_name(), remote)
+ }
+
/// An open sub-task list lasts as long as its sub-tasks, so the next
/// batch starts folded, and an agent that has gone leaves nothing
/// behind. Only a new snapshot can change either.
diff --git a/wezterm-gui/src/termwindow/ui/icons.rs b/wezterm-gui/src/termwindow/ui/icons.rs
index 6586a2ff..25927577 100644
--- a/wezterm-gui/src/termwindow/ui/icons.rs
+++ b/wezterm-gui/src/termwindow/ui/icons.rs
@@ -121,6 +121,10 @@ pub enum SvgIcon {
Timer,
Type,
Laptop,
+ /// The laptop crossed out: a machine that cannot be reached now. Not in
+ /// lucide, which has the server's and the monitor's; drawn after them.
+ LaptopOff,
+ ServerOff,
KeyRound,
LogOut,
Monitor,
@@ -411,6 +415,10 @@ impl SvgIcon {
Self::Timer => include_bytes!("../../../../third_party/lucide/icons/timer.svg"),
Self::Type => include_bytes!("../../../../third_party/lucide/icons/type.svg"),
Self::Laptop => include_bytes!("../../../../third_party/lucide/icons/laptop.svg"),
+ Self::LaptopOff => include_bytes!("../../../../assets/ui/laptop-off.svg"),
+ Self::ServerOff => {
+ include_bytes!("../../../../third_party/lucide/icons/server-off.svg")
+ }
Self::KeyRound => include_bytes!("../../../../third_party/lucide/icons/key-round.svg"),
Self::LogOut => include_bytes!("../../../../third_party/lucide/icons/log-out.svg"),
Self::Monitor => include_bytes!("../../../../third_party/lucide/icons/monitor.svg"),
@@ -880,6 +888,8 @@ mod tests {
SvgIcon::BellRing,
SvgIcon::Braces,
SvgIcon::Server,
+ SvgIcon::ServerOff,
+ SvgIcon::LaptopOff,
SvgIcon::MuxServer,
SvgIcon::ExternalLink,
SvgIcon::ChevronDown,
diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rs
index 93362cd8..514c01fe 100644
--- a/wezterm-gui/src/termwindow/ui/sidebar.rs
+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs
@@ -629,19 +629,35 @@ impl crate::TermWindow {
/// host is checked by the status heartbeat instead (see
/// `watch_space_connection_state`), so idle local windows stay idle.
pub(crate) fn space_connection_state(&self, space_id: &str) -> SpaceConnectionState {
- const SUSTAINED_LAG_MS: u64 = 5000;
let remote = workspace_threads::client_domain_for_space(space_id);
let is_remote = remote.is_some();
let Some(domain_name) = remote.or_else(crate::local_sessions::host_domain_name) else {
return SpaceConnectionState::Connected;
};
+ self.domain_connection_state(&domain_name, is_remote)
+ }
+
+ /// How the link to the server `domain_name` stands; `is_remote` for one
+ /// on another machine, whose silence counts against it, and which the
+ /// indicator showing it looks at again each second.
+ pub(crate) fn domain_connection_state(
+ &self,
+ domain_name: &str,
+ is_remote: bool,
+ ) -> SpaceConnectionState {
if is_remote {
self.update_next_frame_time(Some(
std::time::Instant::now() + std::time::Duration::from_secs(1),
));
}
+ self.domain_reach(domain_name, is_remote)
+ }
+
+ /// `domain_connection_state`, asking for no frame.
+ pub(crate) fn domain_reach(&self, domain_name: &str, is_remote: bool) -> SpaceConnectionState {
+ const SUSTAINED_LAG_MS: u64 = 5000;
let mux = Mux::get();
- let Some(domain) = mux.get_domain_by_name(&domain_name) else {
+ let Some(domain) = mux.get_domain_by_name(domain_name) else {
// Not even registered: never connected in this session.
return SpaceConnectionState::Disconnected;
};