fix(orgs): own messages stay quiet in every org, desktop toasts without actions
- Org watcher reads the own object id per tenant via Graph when the tenant list has none (home org while a guest org is open) - Freedesktop toasts from an org that is not open offer no mark read or reply; a click switches org Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -116,11 +116,14 @@ pub fn message_payload(
116
116
} else {
117
117
Urgency::Normal
118
118
};
119
let mut actions = vec![DesktopAction {
120
id: action::MARK_READ,
121
label: labels.mark_read.clone(),
122
}];
123
if model.agent.is_none() && !model.status_change {
119
let mut actions = Vec::new();
120
if model.org.is_none() {
121
actions.push(DesktopAction {
122
id: action::MARK_READ,
123
label: labels.mark_read.clone(),
124
});
125
}
126
if model.agent.is_none() && !model.status_change && model.org.is_none() {
124
127
actions.push(DesktopAction {
125
128
id: action::REPLY,
126
129
label: labels.reply.clone(),
@@ -260,6 +263,7 @@ mod tests {
260
263
agent: None,
261
264
status_change: false,
262
265
urgent,
266
org: None,
263
267
}
264
268
}
265
269
@@ -286,6 +290,21 @@ mod tests {
286
290
assert_eq!(payload.urgency, Urgency::Critical);
287
291
}
288
292
293
#[test]
294
fn a_message_from_another_org_offers_no_actions() {
295
let mut model = toast(false, false, Preview::Text("hi".into()));
296
model.org = Some(app_base::orgs::Org {
297
id: "guest".into(),
298
name: "Guest Org".into(),
299
guest: true,
300
});
301
assert!(
302
message_payload(&model, true, &message_labels())
303
.actions
304
.is_empty()
305
);
306
}
307
289
308
#[test]
290
309
fn message_offers_mark_read_and_reply() {
291
310
let model = toast(false, false, Preview::Text("hi".into()));
@@ -116,11 +116,14 @@ pub fn message_payload(116
} else {116
} else {117
Urgency::Normal117
Urgency::Normal118
};118
};119
let mut actions = vec![DesktopAction {119
let mut actions = Vec::new();120
id: action::MARK_READ,120
if model.org.is_none() {121
label: labels.mark_read.clone(),121
actions.push(DesktopAction {122
}];122
id: action::MARK_READ,123
if model.agent.is_none() && !model.status_change {123
label: labels.mark_read.clone(),124
});125
}126
if model.agent.is_none() && !model.status_change && model.org.is_none() {124
actions.push(DesktopAction {127
actions.push(DesktopAction {125
id: action::REPLY,128
id: action::REPLY,126
label: labels.reply.clone(),129
label: labels.reply.clone(),@@ -260,6 +263,7 @@ mod tests {260
agent: None,263
agent: None,261
status_change: false,264
status_change: false,262
urgent,265
urgent,266
org: None,263
}267
}264
}268
}265
269
@@ -286,6 +290,21 @@ mod tests {286
assert_eq!(payload.urgency, Urgency::Critical);290
assert_eq!(payload.urgency, Urgency::Critical);287
}291
}288
292
293
#[test]294
fn a_message_from_another_org_offers_no_actions() {295
let mut model = toast(false, false, Preview::Text("hi".into()));296
model.org = Some(app_base::orgs::Org {297
id: "guest".into(),298
name: "Guest Org".into(),299
guest: true,300
});301
assert!(302
message_payload(&model, true, &message_labels())303
.actions304
.is_empty()305
);306
}307
289
#[test]308
#[test]290
fn message_offers_mark_read_and_reply() {309
fn message_offers_mark_read_and_reply() {291
let model = toast(false, false, Preview::Text("hi".into()));310
let model = toast(false, false, Preview::Text("hi".into()));@@ -35,6 +35,10 @@ pub(crate) async fn watch(
35
35
me: Option<String>,
36
36
events: mpsc::UnboundedSender<BackendEvent>,
37
37
) {
38
let me = match me {
39
Some(me) => Some(me),
40
None => own_object_id(&session).await,
41
};
38
42
let listing = ChatListing::new(&session);
39
43
let conversations = Conversations::new(&session);
40
44
let mut muted: HashMap<String, bool> = HashMap::new();
@@ -88,6 +92,16 @@ pub(crate) async fn watch(
88
92
}
89
93
}
90
94
95
async fn own_object_id(session: &Session) -> Option<String> {
96
match graph::Graph::new(session.clone()).me().await {
97
Ok(user) => Some(user.id.to_ascii_lowercase()),
98
Err(error) => {
99
crate::diagnostics::record(format!("orgs: own id in another org not read: {error}"));
100
None
101
}
102
}
103
}
104
91
105
fn is_chat(conversation_id: &str) -> bool {
92
106
!conversation_id.starts_with(SYSTEM_PREFIX) && !conversation_id.ends_with(CHANNEL_SUFFIX)
93
107
}
@@ -35,6 +35,10 @@ pub(crate) async fn watch(35
me: Option<String>,35
me: Option<String>,36
events: mpsc::UnboundedSender<BackendEvent>,36
events: mpsc::UnboundedSender<BackendEvent>,37
) {37
) {38
let me = match me {39
Some(me) => Some(me),40
None => own_object_id(&session).await,41
};38
let listing = ChatListing::new(&session);42
let listing = ChatListing::new(&session);39
let conversations = Conversations::new(&session);43
let conversations = Conversations::new(&session);40
let mut muted: HashMap<String, bool> = HashMap::new();44
let mut muted: HashMap<String, bool> = HashMap::new();@@ -88,6 +92,16 @@ pub(crate) async fn watch(88
}92
}89
}93
}90
94
95
async fn own_object_id(session: &Session) -> Option<String> {96
match graph::Graph::new(session.clone()).me().await {97
Ok(user) => Some(user.id.to_ascii_lowercase()),98
Err(error) => {99
crate::diagnostics::record(format!("orgs: own id in another org not read: {error}"));100
None101
}102
}103
}104
91
fn is_chat(conversation_id: &str) -> bool {105
fn is_chat(conversation_id: &str) -> bool {92
!conversation_id.starts_with(SYSTEM_PREFIX) && !conversation_id.ends_with(CHANNEL_SUFFIX)106
!conversation_id.starts_with(SYSTEM_PREFIX) && !conversation_id.ends_with(CHANNEL_SUFFIX)93
}107
}