aboutsummaryrefslogtreecommitdiff
path: root/src/app/actions.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-28 15:22:12 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-28 15:23:04 +0300
commit28222b20890a1f6cd36fd477de8e9bc6e5537ff5 (patch)
tree75d54cf3a1d43f22b85adcfc6712b08cf31482a6 /src/app/actions.rs
parenta90c90aa4aa92142e4684a81dcb7c2cab9aaac6b (diff)
fix: use live workspace labels in notifications
refs #332
Diffstat (limited to 'src/app/actions.rs')
-rw-r--r--src/app/actions.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/app/actions.rs b/src/app/actions.rs
index c2329531..40c8e74c 100644
--- a/src/app/actions.rs
+++ b/src/app/actions.rs
@@ -73,10 +73,11 @@ fn toast_agent_label(agent_label: &str) -> &str {
pub fn notification_context(
ws: &crate::workspace::Workspace,
+ workspace_label: &str,
ws_idx: usize,
pane_id: PaneId,
) -> String {
- let mut context = format!("{} · {}", ws.display_name(), ws_idx + 1);
+ let mut context = format!("{} · {}", workspace_label, ws_idx + 1);
if ws.tabs.len() > 1 {
if let Some(tab_idx) = ws.find_tab_index_for_pane(pane_id) {
let tab = &ws.tabs[tab_idx];
@@ -2139,7 +2140,13 @@ impl AppState {
ToastKind::Finished => "finished",
ToastKind::UpdateInstalled => "updated",
};
- let context = notification_context(&self.workspaces[ws_idx], ws_idx, pane_id);
+ let workspace_label = self.workspaces[ws_idx].display_name();
+ let context = notification_context(
+ &self.workspaces[ws_idx],
+ &workspace_label,
+ ws_idx,
+ pane_id,
+ );
self.toast = Some(ToastNotification {
kind,
title: format!("{} {}", toast_agent_label(agent_label), event_text),
@@ -2244,6 +2251,17 @@ mod tests {
});
}
+ #[test]
+ fn notification_context_formats_resolved_workspace_label() {
+ let state = app_with_workspaces(&["stale"]);
+ let root = state.workspaces[0].tabs[0].root_pane;
+
+ assert_eq!(
+ notification_context(&state.workspaces[0], "__herdr_projects__", 0, root),
+ "__herdr_projects__ · 1"
+ );
+ }
+
fn selected_word(row: &str, col: u16) -> Option<String> {
let (start, end) = word_bounds_at_column(row, col)?;
Some(text_in_cell_range(row, start, end))