diff --git a/apps/zbugs-gpui/src/app.rs b/apps/zbugs-gpui/src/app.rs index c209e52f73..3f6a7e17a5 100644 --- a/apps/zbugs-gpui/src/app.rs +++ b/apps/zbugs-gpui/src/app.rs @@ -331,6 +331,8 @@ pub struct ZbugsApp { error: Option, /// Marks the selected issue viewed after a second (`mark_viewed`). view_timer: Option<(String, Task<()>)>, + /// The window's title, as zbugs' page titles (`window_title`). + title: String, seen: Option, _unsubscribe: Box, _tasks: Vec>, @@ -449,6 +451,7 @@ impl ZbugsApp { connection, error: None, view_timer: None, + title: String::new(), seen: None, _unsubscribe: unsubscribe, _tasks: vec![watch], @@ -1287,6 +1290,32 @@ impl ZbugsApp { }); } + /// "Zero Bugs → " and the shown issue's title, or the list's, as + /// zbugs' issue and list pages title themselves. + fn window_title(&self) -> String { + let issue = self + .detail + .as_ref() + .and_then(|d| d.snapshot().value.clone().flatten()); + let f = &self.filters; + let shown = match issue { + Some(issue) => issue.title, + None if f.creator.is_some() + || f.assignee.is_some() + || !f.labels.is_empty() + || !f.text.is_empty() => + { + "Filtered Issues".into() + } + None => match f.status { + Status::Open => "Open Issues".into(), + Status::Closed => "Closed Issues".into(), + Status::All => "All Issues".into(), + }, + }; + format!("Zero Bugs → {shown}") + } + /// Marks the selected issue viewed once it has been on screen for a /// second, if it changed since the user last viewed it, as the web /// app's issue page does. The list shows the others as unread. @@ -2559,6 +2588,11 @@ impl Render for ZbugsApp { } self.keep_scroll_anchor(); self.notice_activity(window, cx); + let title = self.window_title(); + if title != self.title { + window.set_window_title(&title); + self.title = title; + } h_flex() .size_full() .bg(cx.theme().background)