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): show a program without a logo with its tab's icon

RoversXc875a5148872
diff --git a/thinkterm-web/src/agents.rs b/thinkterm-web/src/agents.rs
index 821d0f8f..ae9df798 100644
--- a/thinkterm-web/src/agents.rs
+++ b/thinkterm-web/src/agents.rs
@@ -24,6 +24,9 @@ pub struct AgentRow {
pub place: String,
/// The brand or fallback icon the page draws.
pub icon: &'static str,
+ /// For a program with no logo: the card its tab shows, which the page
+ /// draws instead of the fallback, as the desktop does.
+ pub card: Option<String>,
/// What the program said about itself (OSC 7501): what it waits for,
/// what it is doing or why it stopped, how far it got, its sub-tasks.
pub kind: Option<String>,
@@ -226,10 +229,13 @@ pub fn icon(agent_id: &str) -> &'static str {
"cursor" => "brand-cursor",
"opencode" => "brand-opencode",
"pi" | "omp" => "brand-pi",
- _ => "bot",
+ _ => FALLBACK_ICON,
}
}
+/// What `icon` gives a program with no logo of its own.
+const FALLBACK_ICON: &str = "bot";
+
fn state_key(state: AgentState) -> (&'static str, &'static str) {
match state {
AgentState::Working => ("working", "right-agents-state-working"),
@@ -247,6 +253,7 @@ pub fn rows(
tree: &TreeModel,
current_window: WindowId,
title_of: impl Fn(PaneId) -> Option<String>,
+ card_of: impl Fn(PaneId) -> Option<String>,
open: impl Fn(PaneId) -> bool,
) -> Vec<AgentRow> {
let mut rows: Vec<AgentRow> = tree
@@ -272,6 +279,7 @@ pub fn rows(
state_label: tr(state_label),
place,
icon: icon(agent_id),
+ card: if icon(agent_id) == FALLBACK_ICON { card_of(pane) } else { None },
agent_id: agent_id.to_string(),
kind: report.and_then(|r| r.kind).map(kind_label),
said: report.and_then(|r| r.msg.clone()),
@@ -359,6 +367,7 @@ mod tests {
state_label: String::new(),
place: place.into(),
icon: icon(agent),
+ card: None,
kind: None,
said: None,
progress: None,
@@ -419,18 +428,45 @@ mod tests {
}),
);
- let folded = rows(&tree, 1, |_| None, |_| false).remove(0);
+ let folded = rows(&tree, 1, |_| None, |_| None, |_| false).remove(0);
assert!(!folded.subtasks_open);
assert!(folded.subtasks.is_empty() && folded.more_subtasks == 0);
let line = &folded.subtasks_summary;
assert!(line.contains('7') && line.contains('5'), "{line}");
- let open = rows(&tree, 1, |_| None, |pane| pane == 5).remove(0);
+ let open = rows(&tree, 1, |_| None, |_| None, |pane| pane == 5).remove(0);
assert!(open.subtasks_open);
assert_eq!((open.subtasks.len(), open.more_subtasks), (5, 2));
assert_eq!(open.subtasks_summary, folded.subtasks_summary);
}
+ /// A program with no logo is drawn with its tab's card; one with a
+ /// logo keeps it.
+ #[test]
+ fn a_program_without_a_logo_takes_its_tab_s_card() {
+ use thinkterm_proto::{AgentEvidence, AgentStatus};
+ let mut tree = TreeModel::default();
+ for (pane, agent) in [(5, "claude"), (7, "terraform")] {
+ tree.apply_agent(
+ pane,
+ Some(&AgentStatus {
+ agent_id: agent.into(),
+ state: AgentState::Working,
+ evidence: AgentEvidence::Report,
+ session_id: None,
+ since_unix: 0,
+ ended: false,
+ report: None,
+ }),
+ );
+ }
+
+ let rows = rows(&tree, 1, |_| None, |pane| Some(format!("card-{pane}")), |_| false);
+ let card = |agent: &str| rows.iter().find(|r| r.agent_id == agent).unwrap().card.clone();
+ assert_eq!(card("claude"), None);
+ assert_eq!(card("terraform").as_deref(), Some("card-7"));
+ }
+
#[test]
fn the_summary_counts_like_the_desktop() {
assert_eq!(summary(&[]), "No agents detected");
diff --git a/thinkterm-web/src/app.rs b/thinkterm-web/src/app.rs
index 6f8bbbec..f89381ee 100644
--- a/thinkterm-web/src/app.rs
+++ b/thinkterm-web/src/app.rs
@@ -4648,11 +4648,13 @@ impl<P: Platform, L: Link> App<P, L> {
inner
.open_subtasks
.retain(|pane| tree.agent_report(*pane).is_some_and(|r| !r.children.is_empty()));
+ let shared: &Inner<P, L> = inner;
let rows = crate::agents::rows(
- &inner.tree,
- inner.window_id,
- |pane| inner.panes.get(&pane).map(|c| crate::navbar::display_title(&c.title).0),
- |pane| inner.open_subtasks.contains(&pane),
+ &shared.tree,
+ shared.window_id,
+ |pane| shared.panes.get(&pane).map(|c| crate::navbar::display_title(&c.title).0),
+ |pane| Self::pane_icon(shared, pane),
+ |pane| shared.open_subtasks.contains(&pane),
);
let summary = crate::agents::summary(&rows);
let tabs = Self::panel_tabs(&inner);
diff --git a/thinkterm-web/ui/src/AgentsPanel.svelte b/thinkterm-web/ui/src/AgentsPanel.svelte
index d2dc8388..8558c67d 100644
--- a/thinkterm-web/ui/src/AgentsPanel.svelte
+++ b/thinkterm-web/ui/src/AgentsPanel.svelte
@@ -12,6 +12,7 @@
import SnippetsList from './SnippetsList.svelte';
import { handle } from './client';
import { refreshViews, s, sCount, views } from './client.svelte';
+ import { iconClass } from './tabicons.svelte';
import {
agentIcon,
chevronDown,
@@ -229,7 +230,7 @@
<div class="list">
{#each rows as row (row.pane)}
<div class="ag" class:elsewhere={!row.here} data-pane={row.pane} title={row.place}>
- <span class="ic">{@html agentIcon(row.icon)}</span>
+ <span class="ic">{#if iconClass(row.card)}<span class="ticon {iconClass(row.card)}"><i></i></span>{:else}{@html agentIcon(row.icon)}{/if}</span>
<span class="tx">
<span class="n">{row.name}{#if row.title !== ''}<span class="d"> · {row.title}</span>{/if}</span>
<span class="p">{row.state_label}{#if row.place !== ''} · {row.place}{/if}</span>
diff --git a/thinkterm-web/ui/src/model.ts b/thinkterm-web/ui/src/model.ts
index a2b303d6..bfc11da5 100644
--- a/thinkterm-web/ui/src/model.ts
+++ b/thinkterm-web/ui/src/model.ts
@@ -192,6 +192,8 @@ export type AgentRow = {
place: string;
/** `brand-<agent>` for an agent with a logo (agents.rs `icon`), else `bot`. */
icon: string;
+ /** For a program with no logo: the card its tab shows, drawn instead of `bot`. */
+ card: string | null;
/** What the program said about itself (OSC 7501), when it did. */
kind: string | null;
said: string | null;
diff --git a/thinkterm-web/ui/src/tokens.css b/thinkterm-web/ui/src/tokens.css
index 05f626a0..7dbccf3f 100644
--- a/thinkterm-web/ui/src/tokens.css
+++ b/thinkterm-web/ui/src/tokens.css
@@ -263,6 +263,7 @@ body[data-side=off]:not([data-mobile]) #side .list { top: var(--tabs); }
#agents .ag.elsewhere { opacity: .62; }
#agents .ic { display: inline-flex; width: 20px; height: 20px; flex: none; align-items: center; justify-content: center; color: var(--text2); }
#agents .ic svg { width: 20px; height: 20px; }
+#agents .ic .ticon { height: 100%; margin-left: 0; }
/* Kimi's mark per theme (icons.ts): coloured on dark, single-colour on light. */
#agents .ic .dark-only, #agents .ic .light-only { display: inline-flex; }
[data-theme=light] #agents .ic .dark-only, :root:not([data-theme=light]) #agents .ic .light-only { display: none; }
diff --git a/wezterm-gui/src/termwindow/render/hover.rs b/wezterm-gui/src/termwindow/render/hover.rs
index e629cf63..9bd92b37 100644
--- a/wezterm-gui/src/termwindow/render/hover.rs
+++ b/wezterm-gui/src/termwindow/render/hover.rs
@@ -580,7 +580,7 @@ impl TermWindow {
let brand = brand_of(agent);
self.paint_agent_mark(
&mut layers,
- brand,
+ agent,
(x + pad_x).round() as usize,
cy.round() as usize,
mark.round() as usize,
@@ -780,7 +780,7 @@ impl TermWindow {
let mut cy = y + pad_y;
self.paint_agent_mark(
&mut layers,
- brand_of(agent),
+ agent,
left.round() as usize,
cy.round() as usize,
mark.round() as usize,
diff --git a/wezterm-gui/src/termwindow/ui/agent_panel.rs b/wezterm-gui/src/termwindow/ui/agent_panel.rs
index eaa3b355..3fdfe272 100644
--- a/wezterm-gui/src/termwindow/ui/agent_panel.rs
+++ b/wezterm-gui/src/termwindow/ui/agent_panel.rs
@@ -5,13 +5,16 @@
//! probes.
use crate::agent_status::{self, AgentIcon, AgentPanelAction, ProgramReport, ProgramReportState};
+use crate::tab_icons::RgbExt as _;
use crate::native_settings::NativeThreadStatus;
use crate::quad::TripleLayerQuadAllocator;
use crate::termwindow::ui::icons::SvgIcon;
use crate::termwindow::ui::right_sidebar::{
right_sidebar_file_row_metrics, sidebar_row_element_visible, FILE_SCROLL_FADE_HEIGHT,
};
-use crate::termwindow::ui::tokens::{SIDEBAR_ICON_GAP, SIDEBAR_INSET, SIDEBAR_ROW_RADIUS};
+use crate::termwindow::ui::tokens::{
+ SIDEBAR_ICON_GAP, SIDEBAR_INSET, SIDEBAR_ROW_RADIUS, TAB_ICON_GLYPH_RATIO,
+};
use crate::termwindow::{TermWindow, TermWindowNotif, UIItem, UIItemType};
use crate::ui::UiPalette;
use crate::utilsprites::RenderMetrics;
@@ -522,7 +525,7 @@ impl TermWindow {
let icon_y = title_mid.saturating_sub(icon_size / 2);
let brand = brand_of(agent);
if visible(icon_y, icon_size) {
- self.paint_agent_mark(layers, brand, icon_x, icon_y, icon_size, muted_fg)?;
+ self.paint_agent_mark(layers, agent, icon_x, icon_y, icon_size, muted_fg)?;
}
let shown = agent.shown_state();
@@ -1100,25 +1103,68 @@ impl TermWindow {
Ok(fitted)
}
- /// An agent's mark: its brand's when it has one, a robot when not.
+ /// A program's mark: its brand's when it has one, otherwise the card its
+ /// pane's tab shows, so a program reporting its status without a logo of
+ /// its own -- a build, a download -- looks the same in both places.
pub(crate) fn paint_agent_mark(
&self,
layers: &mut TripleLayerQuadAllocator,
- brand: Option<AgentIcon>,
+ agent: &agent_status::AgentPaneStatus,
x: usize,
y: usize,
size: usize,
mono: LinearRgba,
) -> anyhow::Result<()> {
- match brand {
+ match brand_of(agent) {
Some(AgentIcon::Color(brand)) => {
self.paint_sidebar_brand_icon(layers, brand, x, y, size)
}
Some(AgentIcon::Mono(icon)) => self.paint_sidebar_icon(layers, icon, x, y, size, mono),
- None => self.paint_sidebar_icon(layers, SvgIcon::Bot, x, y, size, mono),
+ None => self.paint_pane_card(layers, agent.pane_id, x, y, size),
}
}
+ /// The card `pane_id`'s tab shows, `size` pixels square: the terminal's
+ /// when the pane is not in this process.
+ fn paint_pane_card(
+ &self,
+ layers: &mut TripleLayerQuadAllocator,
+ pane_id: PaneId,
+ x: usize,
+ y: usize,
+ size: usize,
+ ) -> anyhow::Result<()> {
+ let icon = Mux::get()
+ .get_pane(pane_id)
+ .map(|pane| crate::tab_icons::resolve(pane.as_ref()))
+ .unwrap_or_else(|| crate::tab_icons::catalog().terminal_card().resolved());
+ let gl_state = self.render_state.as_ref().unwrap();
+ let ctx = crate::ui::draw::DrawContext::new(gl_state, self.dimensions, &self.render_metrics);
+ crate::tab_icons::draw_plate(
+ &ctx,
+ layers,
+ 1,
+ x as f32,
+ y as f32,
+ size as f32,
+ icon.circle,
+ self.chrome().is_dark(),
+ )
+ .context("program card")?;
+ let glyph = ((size as f32 * TAB_ICON_GLYPH_RATIO).round() as usize).clamp(1, size.max(1));
+ crate::tab_icons::draw_glyph(
+ &ctx,
+ layers,
+ 2,
+ &icon.glyph,
+ (x + (size - glyph) / 2) as f32,
+ (y + (size - glyph) / 2) as f32,
+ glyph as f32,
+ icon.glyph_color.linear(),
+ )
+ .context("program card glyph")
+ }
+
/// A progress bar: its track, and the share done over it once that is
/// wide enough to show its rounded ends.
pub(crate) fn paint_agent_progress(