mirror of
https://github.com/l0ng-ai/tty7.git
synced 2026-09-22 08:02:24 +00:00
fix(ui): keep workspace titles derived from workspace context
This commit is contained in:
@@ -257,9 +257,6 @@ pub fn display_name_of(ws: &Workspace, panes: &[PaneRecord]) -> String {
|
||||
if let Some(name) = ws.name.as_deref().map(str::trim).filter(|n| !n.is_empty()) {
|
||||
return name.to_string();
|
||||
}
|
||||
if let Some(title) = pane_title_of(ws, panes) {
|
||||
return title.to_string();
|
||||
}
|
||||
subject_path_of(ws, panes)
|
||||
.and_then(|path| {
|
||||
std::path::Path::new(&path)
|
||||
@@ -270,15 +267,6 @@ pub fn display_name_of(ws: &Workspace, panes: &[PaneRecord]) -> String {
|
||||
.unwrap_or_else(|| "Untitled".to_string())
|
||||
}
|
||||
|
||||
fn pane_title_of<'a>(ws: &Workspace, panes: &'a [PaneRecord]) -> Option<&'a str> {
|
||||
ws.tabs
|
||||
.iter()
|
||||
.flat_map(|t| t.root.pane_ids())
|
||||
.filter_map(|id| panes.iter().find(|p| p.id == id))
|
||||
.map(|p| p.title.trim())
|
||||
.find(|title| !title.is_empty() && !tty7_core::core::shells::is_bare_shell_name(title))
|
||||
}
|
||||
|
||||
pub fn subject_path_of(ws: &Workspace, panes: &[PaneRecord]) -> Option<String> {
|
||||
let mut counts: Vec<(&str, usize)> = Vec::new();
|
||||
for group in ws.tabs.iter().filter_map(|t| t.sidebar_group.as_deref()) {
|
||||
@@ -521,20 +509,17 @@ mod tests {
|
||||
assert_eq!(display_name_of(&ws, &panes), "scratch");
|
||||
|
||||
panes[0].title = "nvim".into();
|
||||
assert_eq!(display_name_of(&ws, &panes), "nvim");
|
||||
assert_eq!(
|
||||
display_name_of(&ws, &panes),
|
||||
"scratch",
|
||||
"a pane's process title must not rename its workspace"
|
||||
);
|
||||
|
||||
ws.tabs[0].sidebar_group = Some("/repo/tty7".into());
|
||||
assert_eq!(
|
||||
display_name_of(&ws, &panes),
|
||||
"nvim",
|
||||
"a live process name is more distinctive than the cwd group"
|
||||
);
|
||||
|
||||
panes[0].title = "zsh".into();
|
||||
assert_eq!(
|
||||
display_name_of(&ws, &panes),
|
||||
"tty7",
|
||||
"an idle shell prompt is not distinctive — cwd/repo name should win"
|
||||
"the repo group wins over the raw cwd"
|
||||
);
|
||||
|
||||
ws.name = Some(" Release prep ".into());
|
||||
|
||||
+1
-18
@@ -232,11 +232,7 @@ impl Tty7App {
|
||||
}
|
||||
|
||||
crate::terminal::pane_liveness::sweep(cx);
|
||||
let current = self
|
||||
.tabs
|
||||
.get(self.active)
|
||||
.and_then(|tab| workspace_osc_title(tab, cx).or_else(|| workspace_agent_title(tab, cx)))
|
||||
.or_else(|| crate::ui::machine_mirror::display_name_for(cx, self.workspace))
|
||||
let current = crate::ui::machine_mirror::display_name_for(cx, self.workspace)
|
||||
.unwrap_or_else(|| "tty7".to_string());
|
||||
let monogram: String = current
|
||||
.chars()
|
||||
@@ -1086,19 +1082,6 @@ impl Tty7App {
|
||||
}
|
||||
}
|
||||
|
||||
fn workspace_osc_title(tab: &Tab, cx: &App) -> Option<String> {
|
||||
let title = tab.leaf_title(None, cx);
|
||||
let title = title.trim();
|
||||
if title.is_empty() || title == "tty7" || title.starts_with("tty7 — ") {
|
||||
return None;
|
||||
}
|
||||
Some(title.to_string())
|
||||
}
|
||||
|
||||
fn workspace_agent_title(tab: &Tab, cx: &App) -> Option<String> {
|
||||
tab.agent(cx).map(|agent| agent.display_name().to_string())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user