Distinguish local and SSH tabs by color and hostname

Replace the window-wide connection badge with purple local tabs and teal SSH tabs. Show the SSH hostname below the remote tab title, including during tab renaming.
This commit is contained in:
James Magahern
2026-11-17 14:51:14 -08:00
parent d980799648
commit 57ec12d238
4 changed files with 96 additions and 47 deletions
+4 -3
View File
@@ -244,9 +244,10 @@ or the server stops.
## Appearance
The inset terminal surface and titlebar use the dark Sybil palette shared by
Huayra, Attractor, and Sybil. Tabs retain violet accents; pane headers use teal,
with a matching border around the active pane. The titlebar contains equal-width
tabs and connection/window controls. `src/chrome.rs` records the theme sources.
Huayra, Attractor, and Sybil. Local tabs have a purple accent. SSH tabs have a
teal accent and show the destination hostname beneath their title. Pane headers
use teal, with a matching border around the active pane.
`src/chrome.rs` records the theme sources.
Tab changes and new panes slide with Neovide's 150 ms exponential window-motion
curve. Outgoing content remains visible during the transition; only the incoming
+86 -33
View File
@@ -23,7 +23,6 @@ pub const BORDER: u32 = 0x282145;
pub const TEXT: u32 = 0xf3f1f8;
pub const MUTED: u32 = 0xa29fbc;
pub const ACCENT: u32 = 0x9858f9;
pub const CYAN: u32 = 0x4bdbf1;
// Huayra's Sybil green: hsl(163 72% 45%).
pub const PANE_FOCUS: u32 = 0x20c597;
pub const PANE_MUTED: u32 = 0x527f73;
@@ -34,6 +33,7 @@ pub const HEADER_HEIGHT: f32 = 44.;
pub struct ChromeTab {
pub id: u64,
pub label: SharedString,
pub remote: Option<String>,
pub active: bool,
pub editor: Option<Entity<RenameField>>,
}
@@ -41,7 +41,6 @@ pub struct ChromeTab {
/// An app-owned titlebar. Callbacks issue server commands; no tab state lives here.
/// The close callback should detach this GUI, leaving server sessions alive.
pub fn header(
connection: SharedString,
tabs: Vec<ChromeTab>,
reserve_traffic_lights: bool,
on_tab: impl Fn(u64, &mut Window, &mut App) + 'static,
@@ -61,41 +60,68 @@ pub fn header(
let on_tab = on_tab.clone();
let active = tab.active;
let id = tab.id;
let label = div()
let (accent, selected_bg, hover_bg, selected_border) = if tab.remote.is_some() {
(PANE_FOCUS, 0x102d28, 0x112720, 0x285749)
} else {
(ACCENT, ACTIVE_BACKGROUND, HOVER_BACKGROUND, BORDER)
};
let mut label = div()
.flex_1()
.min_w_0()
.h_full()
.flex()
.items_center()
.flex_col()
.justify_center()
.overflow_hidden();
let label = if let Some(editor) = tab.editor {
label.child(editor)
if let Some(editor) = tab.editor {
label = label.child(editor);
} else {
label.child(middle_label(tab.label))
};
label = label.child(
div()
.h(px(16.))
.line_height(px(16.))
.child(middle_label(tab.label)),
);
}
if let Some(destination) = tab.remote {
label = label.child(
div()
.h(px(12.))
.line_height(px(12.))
.text_size(px(10.))
.text_color(rgb(PANE_FOCUS))
.child(middle_label(
remote_hostname(&destination).to_owned().into(),
)),
);
}
tab_strip = tab_strip.child(
div()
.id(ElementId::Name(format!("tab-{id}").into()))
.flex()
.items_center()
.gap(px(7.))
.h(px(29.))
.h(px(38.))
.flex_basis(px(200.))
.flex_shrink()
.min_w_0()
.max_w(px(200.))
.px(px(10.))
.border_1()
.border_color(rgb(if active { BORDER } else { PANEL_BACKGROUND }))
.border_color(rgb(if active {
selected_border
} else {
PANEL_BACKGROUND
}))
.bg(rgb(if active {
ACTIVE_BACKGROUND
selected_bg
} else {
PANEL_BACKGROUND
}))
.text_color(rgb(if active { TEXT } else { MUTED }))
.text_size(px(11.))
.cursor_pointer()
.hover(|style| style.bg(rgb(HOVER_BACKGROUND)).text_color(rgb(TEXT)))
.hover(move |style| style.bg(rgb(hover_bg)).text_color(rgb(TEXT)))
.on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
.on_click(move |_, window, cx| {
cx.stop_propagation();
@@ -105,8 +131,8 @@ pub fn header(
div()
.w(px(3.))
.flex_shrink_0()
.h(px(12.))
.bg(rgb(if active { ACCENT } else { BORDER })),
.h(px(if active { 22. } else { 12. }))
.bg(rgb(accent)),
)
.child(label),
);
@@ -141,18 +167,6 @@ pub fn header(
}
})
.child(tab_strip)
.child(
div()
.flex()
.items_center()
.flex_shrink_0()
.gap(px(5.))
.max_w(px(170.))
.text_size(px(10.))
.text_color(rgb(MUTED))
.child(div().size(px(4.)).rounded_full().bg(rgb(CYAN)))
.child(div().text_ellipsis().child(connection)),
)
.child(control("new-tab", "+", false, on_new))
.when(!cfg!(target_os = "macos"), |row| {
row.child(control("detach-window", "×", true, on_close))
@@ -160,6 +174,22 @@ pub fn header(
)
}
/// Keep SSH aliases as entered, omitting user, URI port and IPv6 brackets.
fn remote_hostname(destination: &str) -> &str {
let uri = destination.strip_prefix("ssh://");
let address = uri.unwrap_or(destination).trim_end_matches('/');
let host = address.rsplit_once('@').map_or(address, |(_, host)| host);
if let Some((ipv6, _)) = host.strip_prefix('[').and_then(|s| s.split_once(']')) {
return ipv6;
}
if uri.is_some()
&& let Some((name, _)) = host.split_once(':')
{
return name;
}
host
}
fn control(
id: &'static str,
label: &'static str,
@@ -197,18 +227,41 @@ fn control(
mod tests {
use super::*;
#[test]
fn displays_hostnames_for_ssh_destinations() {
for (destination, hostname) in [
("workstation", "workstation"),
("alice@build.lan", "build.lan"),
("alice@2001:db8::1", "2001:db8::1"),
("[2001:db8::1]", "2001:db8::1"),
("ssh://alice@build.lan:2222", "build.lan"),
("ssh://alice@[2001:db8::1]:2222/", "2001:db8::1"),
] {
assert_eq!(remote_hostname(destination), hostname);
}
}
#[test]
fn header_constructs_each_control_without_duplicate_hover_styles() {
// GPUI rejects installing a hover style twice before the first window
// frame. Exercise the complete header, including its danger control.
let _ = header(
"Local".into(),
vec![ChromeTab {
id: 1,
label: "Shell".into(),
active: true,
editor: None,
}],
vec![
ChromeTab {
id: 1,
label: "Shell".into(),
remote: None,
active: true,
editor: None,
},
ChromeTab {
id: 2,
label: "Build".into(),
remote: Some("user@work".into()),
active: false,
editor: None,
},
],
cfg!(target_os = "macos"),
|_, _, _| {},
|_, _| {},
+1 -7
View File
@@ -212,10 +212,6 @@ pub(crate) fn run_gui(
session: SessionTarget,
) -> Result<()> {
let (client, updates) = client::Client::connect(&socket, remote.as_deref(), session)?;
let connection: SharedString = remote
.map(|host| format!("SSH · {host}"))
.unwrap_or_else(|| "Local".into())
.into();
Application::new().run(move |cx: &mut App| {
#[cfg(target_os = "macos")]
{
@@ -256,9 +252,7 @@ pub(crate) fn run_gui(
app_id: Some("dev.buzzert.psyterm".into()),
..Default::default()
},
move |window, cx| {
cx.new(|cx| terminal::Workspace::new(client, updates, connection, window, cx))
},
move |window, cx| cx.new(|cx| terminal::Workspace::new(client, updates, window, cx)),
)
.expect("could not open psyTerm window");
cx.activate(true);
+5 -4
View File
@@ -38,7 +38,6 @@ struct TabRename {
pub struct Workspace {
client: Client,
connection: SharedString,
font: TerminalFont,
snapshot: Option<Arc<Snapshot>>,
panes: HashMap<u64, Entity<TerminalPane>>,
@@ -328,7 +327,6 @@ impl Workspace {
pub fn new(
client: Client,
updates: Updates,
connection: SharedString,
window: &mut Window,
cx: &mut Context<Self>,
) -> Self {
@@ -479,7 +477,6 @@ impl Workspace {
});
Self {
client,
connection,
font,
snapshot: None,
panes: HashMap::new(),
@@ -529,6 +526,11 @@ impl Render for Workspace {
.map(|tab| chrome::ChromeTab {
id: tab.id,
label: tab.title.clone().into(),
remote: tab
.remote
.as_deref()
.or(self.client.remote())
.map(str::to_owned),
active: tab.id == s.active_tab,
editor: self
.tab_rename
@@ -542,7 +544,6 @@ impl Render for Workspace {
let client = self.client.clone();
let new_client = self.client.clone();
let header = chrome::header(
self.connection.clone(),
tabs,
cfg!(target_os = "macos") && !window.is_fullscreen(),
move |tab, _, _| {