Files
tty7/crates/tty7-cli/src/testbed.rs
T
l0ng-aiandl0ng-ai 100904a313 fix(switcher): name another workspace's tabs from their terminal titles (#558)
A window names its own tabs from its live terminals' OSC titles; every
other workspace it lists it reads out of the machine tree, which recorded
each pane's foreground process name and never its title. So the naming
fell through to the agent, and switching workspaces — which happens in
place and drops the terminals the window was reading — turned the tabs of
the workspace just left into a column of identical "Claude Code" rows.

The daemon now sniffs OSC 0/2 and records the title beside the pane's cwd,
capped at 256 characters, and `TabLabel` ranks it second only to a name
someone gave the tab. The switcher puts it through the same abbreviation
the tab strip uses, so a shell's `user@host:~/dir` reads `…/dir` in both
places, and in a split the pane running an agent names the tab rather than
whichever shell happens to be first. `tty7 tab ls` and workspaces on a
remote machine were reading the same missing field and are named the same
way now.

Co-authored-by: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com>
2026-08-12 13:52:17 +08:00

64 lines
1.8 KiB
Rust

use tty7_core::core::machine::{Axis, Machine, PaneNode, PaneRecord, Tab, TabId, Workspace};
use tty7_core::core::session::WorkspaceId;
pub fn two_workspace_machine() -> Machine {
let api = Workspace {
id: WorkspaceId::new(),
name: Some("api".into()),
last_active: 0,
tabs: vec![
Tab {
id: TabId::new(),
name: Some("build".into()),
sidebar_group: None,
root: PaneNode::Leaf { pane: 1 },
},
Tab {
id: TabId::new(),
name: None,
sidebar_group: None,
root: PaneNode::Split {
axis: Axis::Horizontal,
ratio: 0.5,
a: Box::new(PaneNode::Leaf { pane: 2 }),
b: Box::new(PaneNode::Leaf { pane: 3 }),
},
},
],
active_tab: None,
attachment: None,
};
let web = Workspace {
id: WorkspaceId::new(),
name: Some("web".into()),
last_active: 0,
tabs: vec![Tab {
id: TabId::new(),
name: None,
sidebar_group: None,
root: PaneNode::Leaf { pane: 5 },
}],
active_tab: None,
attachment: None,
};
let record = |id: u64, cwd: &str| PaneRecord {
id,
cwd: Some(cwd.to_string()),
title: String::new(),
osc_title: None,
ssh_spec: None,
agent: None,
shell: None,
live: true,
};
Machine {
workspaces: vec![api, web],
panes: vec![
record(1, "C:\\proj"),
record(2, "C:\\proj"),
record(3, "C:\\proj\\sub"),
record(5, "C:\\web"),
],
}
}