feat(activity): agent proposals in Activity and as toasts
- Activity: "Agent proposals" group on top, one row per pending reply or reaction proposal (agent, chat, preview, time); click opens the chat (reaction: jumps to the message)
- Unseen proposals count into the Activity rail badge and the taskbar badge until clicked, the chat is opened, or "Mark all as read"; seen ids kept in local meta
- New proposal shows a toast in the agent toast style ("Claude proposes a reply", chat name, preview, Review); respects DND, focus assist, mute in calls, chat desktop notifications off and the open+focused chat
- Single source: AgentApi proposals/reactions via agent_api::pending; toast drops once the proposal is resolved or seen
- Own feature, no Teams counterpart, nothing sent to the server
- layout_guard: proposal group stays inside the sidebar island
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -9,7 +9,7 @@ use crate::notify::Preview;
9
9
10
10
const IMAGE_LABEL: &str = "Image";
11
11
12
fn preview_label(preview: &Preview) -> String {
12
pub(crate) fn preview_label(preview: &Preview) -> String {
13
13
match preview {
14
14
Preview::Text(text) => text.clone(),
15
15
Preview::Image => IMAGE_LABEL.to_owned(),
@@ -9,7 +9,7 @@ use crate::notify::Preview;9
9
10
const IMAGE_LABEL: &str = "Image";10
const IMAGE_LABEL: &str = "Image";11
11
12
fn preview_label(preview: &Preview) -> String {12
pub(crate) fn preview_label(preview: &Preview) -> String {13
match preview {13
match preview {14
Preview::Text(text) => text.clone(),14
Preview::Text(text) => text.clone(),15
Preview::Image => IMAGE_LABEL.to_owned(),15
Preview::Image => IMAGE_LABEL.to_owned(),@@ -6,6 +6,7 @@ use gpui_kit::*;
6
6
use super::feed::{Actor, Entry, Feed, RETENTION_DAYS, ReactedMessage, start_time};
7
7
use super::preview_label;
8
8
use super::reactions::reacted_messages;
9
use crate::agent_api;
9
10
use crate::app_state::{AppEvent, AppState};
10
11
use crate::call::MissedCall;
11
12
use crate::demo;
@@ -22,6 +23,7 @@ pub struct ActivityCenter {
22
23
tracker: IncomingTracker,
23
24
cutoff: DateTime<Utc>,
24
25
_subscription: Subscription,
26
_proposal_observation: Option<Subscription>,
25
27
}
26
28
27
29
impl ActivityCenter {
@@ -40,6 +42,8 @@ impl ActivityCenter {
40
42
let subscription = cx.subscribe(&app, |this, _, event: &AppEvent, cx| {
41
43
this.on_app_event(event, cx);
42
44
});
45
let proposal_observation =
46
agent_api::handle(cx).map(|api| cx.observe(&api, |this, _, cx| this.on_proposals(cx)));
43
47
let mut center = ActivityCenter {
44
48
app,
45
49
main_window: window.window_handle(),
@@ -47,6 +51,7 @@ impl ActivityCenter {
47
51
tracker: IncomingTracker::new(cutoff),
48
52
cutoff,
49
53
_subscription: subscription,
54
_proposal_observation: proposal_observation,
50
55
};
51
56
center.flush(cx);
52
57
center
@@ -63,6 +68,7 @@ impl ActivityCenter {
63
68
}
64
69
65
70
pub fn mark_all_read(&mut self, cx: &mut Context<Self>) {
71
agent_api::mark_all_proposals_seen(cx);
66
72
if self.feed.mark_all_read() {
67
73
self.flush(cx);
68
74
}
@@ -97,6 +103,22 @@ impl ActivityCenter {
97
103
}
98
104
99
105
fn on_selection(&mut self, cx: &mut Context<Self>) {
106
let selected = self
107
.app
108
.read(cx)
109
.selection
110
.as_ref()
111
.map(|selection| selection.conversation_id().to_owned());
112
let Some(conversation_id) = selected else {
113
return;
114
};
115
agent_api::mark_conversation_proposals_seen(&conversation_id, cx);
116
if self.feed.mark_conversation_read(&conversation_id) {
117
self.flush(cx);
118
}
119
}
120
121
fn on_proposals(&mut self, cx: &mut Context<Self>) {
100
122
let selected = self
101
123
.app
102
124
.read(cx)
@@ -104,10 +126,11 @@ impl ActivityCenter {
104
126
.as_ref()
105
127
.map(|selection| selection.conversation_id().to_owned());
106
128
if let Some(conversation_id) = selected
107
&& self.feed.mark_conversation_read(&conversation_id)
129
&& self.in_foreground(&conversation_id, cx)
108
130
{
109
self.flush(cx);
131
agent_api::mark_conversation_proposals_seen(&conversation_id, cx);
110
132
}
133
cx.notify();
111
134
}
112
135
113
136
fn on_sidebar(&mut self, cx: &mut Context<Self>) {
@@ -6,6 +6,7 @@ use gpui_kit::*;6
use super::feed::{Actor, Entry, Feed, RETENTION_DAYS, ReactedMessage, start_time};6
use super::feed::{Actor, Entry, Feed, RETENTION_DAYS, ReactedMessage, start_time};7
use super::preview_label;7
use super::preview_label;8
use super::reactions::reacted_messages;8
use super::reactions::reacted_messages;9
use crate::agent_api;9
use crate::app_state::{AppEvent, AppState};10
use crate::app_state::{AppEvent, AppState};10
use crate::call::MissedCall;11
use crate::call::MissedCall;11
use crate::demo;12
use crate::demo;@@ -22,6 +23,7 @@ pub struct ActivityCenter {22
tracker: IncomingTracker,23
tracker: IncomingTracker,23
cutoff: DateTime<Utc>,24
cutoff: DateTime<Utc>,24
_subscription: Subscription,25
_subscription: Subscription,26
_proposal_observation: Option<Subscription>,25
}27
}26
28
27
impl ActivityCenter {29
impl ActivityCenter {@@ -40,6 +42,8 @@ impl ActivityCenter {40
let subscription = cx.subscribe(&app, |this, _, event: &AppEvent, cx| {42
let subscription = cx.subscribe(&app, |this, _, event: &AppEvent, cx| {41
this.on_app_event(event, cx);43
this.on_app_event(event, cx);42
});44
});45
let proposal_observation =46
agent_api::handle(cx).map(|api| cx.observe(&api, |this, _, cx| this.on_proposals(cx)));43
let mut center = ActivityCenter {47
let mut center = ActivityCenter {44
app,48
app,45
main_window: window.window_handle(),49
main_window: window.window_handle(),@@ -47,6 +51,7 @@ impl ActivityCenter {47
tracker: IncomingTracker::new(cutoff),51
tracker: IncomingTracker::new(cutoff),48
cutoff,52
cutoff,49
_subscription: subscription,53
_subscription: subscription,54
_proposal_observation: proposal_observation,50
};55
};51
center.flush(cx);56
center.flush(cx);52
center57
center@@ -63,6 +68,7 @@ impl ActivityCenter {63
}68
}64
69
65
pub fn mark_all_read(&mut self, cx: &mut Context<Self>) {70
pub fn mark_all_read(&mut self, cx: &mut Context<Self>) {71
agent_api::mark_all_proposals_seen(cx);66
if self.feed.mark_all_read() {72
if self.feed.mark_all_read() {67
self.flush(cx);73
self.flush(cx);68
}74
}@@ -97,6 +103,22 @@ impl ActivityCenter {97
}103
}98
104
99
fn on_selection(&mut self, cx: &mut Context<Self>) {105
fn on_selection(&mut self, cx: &mut Context<Self>) {106
let selected = self107
.app108
.read(cx)109
.selection110
.as_ref()111
.map(|selection| selection.conversation_id().to_owned());112
let Some(conversation_id) = selected else {113
return;114
};115
agent_api::mark_conversation_proposals_seen(&conversation_id, cx);116
if self.feed.mark_conversation_read(&conversation_id) {117
self.flush(cx);118
}119
}120
121
fn on_proposals(&mut self, cx: &mut Context<Self>) {100
let selected = self122
let selected = self101
.app123
.app102
.read(cx)124
.read(cx)@@ -104,10 +126,11 @@ impl ActivityCenter {104
.as_ref()126
.as_ref()105
.map(|selection| selection.conversation_id().to_owned());127
.map(|selection| selection.conversation_id().to_owned());106
if let Some(conversation_id) = selected128
if let Some(conversation_id) = selected107
&& self.feed.mark_conversation_read(&conversation_id)129
&& self.in_foreground(&conversation_id, cx)108
{130
{109
self.flush(cx);131
agent_api::mark_conversation_proposals_seen(&conversation_id, cx);110
}132
}133
cx.notify();111
}134
}112
135
113
fn on_sidebar(&mut self, cx: &mut Context<Self>) {136
fn on_sidebar(&mut self, cx: &mut Context<Self>) {@@ -1,8 +1,9 @@
1
1
pub mod bridge;
2
2
pub mod body;
3
pub mod pending;
3
4
pub mod source;
4
5
5
use std::collections::{BTreeSet, HashMap};
6
use std::collections::{BTreeSet, HashMap, HashSet};
6
7
use std::sync::Arc;
7
8
8
9
use chrono::{DateTime, Local};
@@ -17,6 +18,7 @@ use app_base::agent_api::{extras, image_scale};
17
18
18
19
use crate::backend::Engine;
19
20
use crate::runtime;
21
use pending::PendingProposal;
20
22
use source::AppSource;
21
23
22
24
#[derive(Debug, Clone, PartialEq)]
@@ -64,6 +66,8 @@ pub struct AgentApi {
64
66
token: String,
65
67
proposals: HashMap<String, ProposalEntry>,
66
68
reactions: HashMap<(String, String), ReactionProposal>,
69
reaction_excerpts: HashMap<String, String>,
70
seen_proposals: HashSet<String>,
67
71
server: Option<ServerHandle>,
68
72
status: ServerStatus,
69
73
generation: u64,
@@ -76,6 +80,7 @@ struct AgentApiHandle(Entity<AgentApi>);
76
80
impl Global for AgentApiHandle {}
77
81
78
82
const DEMO_PORT_ENV: &str = "RUSTY_TEAMS_MCP_PORT";
83
const SEEN_PROPOSALS_KEY: &str = "activity_seen_proposals";
79
84
80
85
pub fn endpoint_url(port: u16) -> String {
81
86
format!("http://127.0.0.1:{port}/mcp")
@@ -128,6 +133,7 @@ pub fn init(store: Arc<Store>, demo: bool, cx: &mut App) {
128
133
let hub = AgentHub::new(store.clone(), policy, ui);
129
134
let token = mcp::load_or_create_token(&store).unwrap_or_default();
130
135
let source = Arc::new(AppSource::new(store.clone()));
136
let seen_proposals = pending::decode_seen(store.meta(SEEN_PROPOSALS_KEY).ok().flatten());
131
137
let api = cx.new(|_| AgentApi {
132
138
hub,
133
139
source,
@@ -135,6 +141,8 @@ pub fn init(store: Arc<Store>, demo: bool, cx: &mut App) {
135
141
token,
136
142
proposals: HashMap::new(),
137
143
reactions: HashMap::new(),
144
reaction_excerpts: HashMap::new(),
145
seen_proposals,
138
146
server: None,
139
147
status: ServerStatus::Off,
140
148
generation: 0,
@@ -280,6 +288,46 @@ pub fn pending_agents(cx: &App) -> HashMap<String, &'static str> {
280
288
.collect()
281
289
}
282
290
291
pub fn pending_proposals(cx: &App) -> Vec<PendingProposal> {
292
handle(cx).map_or_else(Vec::new, |api| api.read(cx).pending_proposals())
293
}
294
295
pub fn unseen_proposal_count(cx: &App) -> usize {
296
pending_proposals(cx)
297
.iter()
298
.filter(|pending| !pending.seen)
299
.count()
300
}
301
302
pub fn mark_proposal_seen(proposal_id: &str, cx: &mut App) {
303
mark_proposals_seen(cx, |pending| pending.id == proposal_id);
304
}
305
306
pub fn mark_conversation_proposals_seen(conversation_id: &str, cx: &mut App) {
307
mark_proposals_seen(cx, |pending| pending.conversation_id == conversation_id);
308
}
309
310
pub fn mark_all_proposals_seen(cx: &mut App) {
311
mark_proposals_seen(cx, |_| true);
312
}
313
314
fn mark_proposals_seen(cx: &mut App, matches: impl Fn(&PendingProposal) -> bool) {
315
let Some(api) = handle(cx) else {
316
return;
317
};
318
let fresh: Vec<String> = api
319
.read(cx)
320
.pending_proposals()
321
.into_iter()
322
.filter(|pending| !pending.seen && matches(pending))
323
.map(|pending| pending.id)
324
.collect();
325
if fresh.is_empty() {
326
return;
327
}
328
api.update(cx, |api, cx| api.mark_seen(fresh, cx));
329
}
330
283
331
pub fn resolve_proposal(conversation_id: &str, outcome: Outcome, cx: &mut App) {
284
332
if let Some(api) = handle(cx) {
285
333
api.update(cx, |api, cx| api.resolve(conversation_id, outcome, cx));
@@ -346,6 +394,30 @@ impl AgentApi {
346
394
}
347
395
}
348
396
397
pub fn pending_proposals(&self) -> Vec<PendingProposal> {
398
pending::collect(
399
&self.proposals,
400
&self.reactions,
401
&self.reaction_excerpts,
402
&self.seen_proposals,
403
)
404
}
405
406
fn mark_seen(&mut self, proposal_ids: Vec<String>, cx: &mut Context<Self>) {
407
self.seen_proposals.extend(proposal_ids);
408
let pending: HashSet<String> = self
409
.pending_proposals()
410
.into_iter()
411
.map(|pending| pending.id)
412
.collect();
413
self.seen_proposals.retain(|id| pending.contains(id));
414
let _ = self.store.set_meta(
415
SEEN_PROPOSALS_KEY,
416
&pending::encode_seen(&self.seen_proposals),
417
);
418
cx.notify();
419
}
420
349
421
pub fn reinstall_note(&self) -> Option<&str> {
350
422
self.reinstall_note.as_deref()
351
423
}
@@ -394,6 +466,15 @@ impl AgentApi {
394
466
pictures: Vec<ProposalPicture>,
395
467
cx: &mut Context<Self>,
396
468
) {
469
if let mcp::UiEvent::ReactionProposalChanged(reaction) = &event
470
&& let Some(excerpt) = pending::reacted_excerpt(
471
&self.store,
472
&reaction.conversation_id,
473
&reaction.message_id,
474
)
475
{
476
self.reaction_excerpts.insert(reaction.id.clone(), excerpt);
477
}
397
478
bridge::apply(
398
479
&mut self.proposals,
399
480
&mut self.reactions,
@@ -401,6 +482,9 @@ impl AgentApi {
401
482
pictures,
402
483
&self.store,
403
484
);
485
let reactions = &self.reactions;
486
self.reaction_excerpts
487
.retain(|id, _| reactions.values().any(|reaction| &reaction.id == id));
404
488
cx.notify();
405
489
}
406
490
@@ -1,8 +1,9 @@1
pub mod bridge;1
pub mod bridge;2
pub mod body;2
pub mod body;3
pub mod pending;3
pub mod source;4
pub mod source;4
5
5
use std::collections::{BTreeSet, HashMap};6
use std::collections::{BTreeSet, HashMap, HashSet};6
use std::sync::Arc;7
use std::sync::Arc;7
8
8
use chrono::{DateTime, Local};9
use chrono::{DateTime, Local};@@ -17,6 +18,7 @@ use app_base::agent_api::{extras, image_scale};17
18
18
use crate::backend::Engine;19
use crate::backend::Engine;19
use crate::runtime;20
use crate::runtime;21
use pending::PendingProposal;20
use source::AppSource;22
use source::AppSource;21
23
22
#[derive(Debug, Clone, PartialEq)]24
#[derive(Debug, Clone, PartialEq)]@@ -64,6 +66,8 @@ pub struct AgentApi {64
token: String,66
token: String,65
proposals: HashMap<String, ProposalEntry>,67
proposals: HashMap<String, ProposalEntry>,66
reactions: HashMap<(String, String), ReactionProposal>,68
reactions: HashMap<(String, String), ReactionProposal>,69
reaction_excerpts: HashMap<String, String>,70
seen_proposals: HashSet<String>,67
server: Option<ServerHandle>,71
server: Option<ServerHandle>,68
status: ServerStatus,72
status: ServerStatus,69
generation: u64,73
generation: u64,@@ -76,6 +80,7 @@ struct AgentApiHandle(Entity<AgentApi>);76
impl Global for AgentApiHandle {}80
impl Global for AgentApiHandle {}77
81
78
const DEMO_PORT_ENV: &str = "RUSTY_TEAMS_MCP_PORT";82
const DEMO_PORT_ENV: &str = "RUSTY_TEAMS_MCP_PORT";83
const SEEN_PROPOSALS_KEY: &str = "activity_seen_proposals";79
84
80
pub fn endpoint_url(port: u16) -> String {85
pub fn endpoint_url(port: u16) -> String {81
format!("http://127.0.0.1:{port}/mcp")86
format!("http://127.0.0.1:{port}/mcp")@@ -128,6 +133,7 @@ pub fn init(store: Arc<Store>, demo: bool, cx: &mut App) {128
let hub = AgentHub::new(store.clone(), policy, ui);133
let hub = AgentHub::new(store.clone(), policy, ui);129
let token = mcp::load_or_create_token(&store).unwrap_or_default();134
let token = mcp::load_or_create_token(&store).unwrap_or_default();130
let source = Arc::new(AppSource::new(store.clone()));135
let source = Arc::new(AppSource::new(store.clone()));136
let seen_proposals = pending::decode_seen(store.meta(SEEN_PROPOSALS_KEY).ok().flatten());131
let api = cx.new(|_| AgentApi {137
let api = cx.new(|_| AgentApi {132
hub,138
hub,133
source,139
source,@@ -135,6 +141,8 @@ pub fn init(store: Arc<Store>, demo: bool, cx: &mut App) {135
token,141
token,136
proposals: HashMap::new(),142
proposals: HashMap::new(),137
reactions: HashMap::new(),143
reactions: HashMap::new(),144
reaction_excerpts: HashMap::new(),145
seen_proposals,138
server: None,146
server: None,139
status: ServerStatus::Off,147
status: ServerStatus::Off,140
generation: 0,148
generation: 0,@@ -280,6 +288,46 @@ pub fn pending_agents(cx: &App) -> HashMap<String, &'static str> {280
.collect()288
.collect()281
}289
}282
290
291
pub fn pending_proposals(cx: &App) -> Vec<PendingProposal> {292
handle(cx).map_or_else(Vec::new, |api| api.read(cx).pending_proposals())293
}294
295
pub fn unseen_proposal_count(cx: &App) -> usize {296
pending_proposals(cx)297
.iter()298
.filter(|pending| !pending.seen)299
.count()300
}301
302
pub fn mark_proposal_seen(proposal_id: &str, cx: &mut App) {303
mark_proposals_seen(cx, |pending| pending.id == proposal_id);304
}305
306
pub fn mark_conversation_proposals_seen(conversation_id: &str, cx: &mut App) {307
mark_proposals_seen(cx, |pending| pending.conversation_id == conversation_id);308
}309
310
pub fn mark_all_proposals_seen(cx: &mut App) {311
mark_proposals_seen(cx, |_| true);312
}313
314
fn mark_proposals_seen(cx: &mut App, matches: impl Fn(&PendingProposal) -> bool) {315
let Some(api) = handle(cx) else {316
return;317
};318
let fresh: Vec<String> = api319
.read(cx)320
.pending_proposals()321
.into_iter()322
.filter(|pending| !pending.seen && matches(pending))323
.map(|pending| pending.id)324
.collect();325
if fresh.is_empty() {326
return;327
}328
api.update(cx, |api, cx| api.mark_seen(fresh, cx));329
}330
283
pub fn resolve_proposal(conversation_id: &str, outcome: Outcome, cx: &mut App) {331
pub fn resolve_proposal(conversation_id: &str, outcome: Outcome, cx: &mut App) {284
if let Some(api) = handle(cx) {332
if let Some(api) = handle(cx) {285
api.update(cx, |api, cx| api.resolve(conversation_id, outcome, cx));333
api.update(cx, |api, cx| api.resolve(conversation_id, outcome, cx));@@ -346,6 +394,30 @@ impl AgentApi {346
}394
}347
}395
}348
396
397
pub fn pending_proposals(&self) -> Vec<PendingProposal> {398
pending::collect(399
&self.proposals,400
&self.reactions,401
&self.reaction_excerpts,402
&self.seen_proposals,403
)404
}405
406
fn mark_seen(&mut self, proposal_ids: Vec<String>, cx: &mut Context<Self>) {407
self.seen_proposals.extend(proposal_ids);408
let pending: HashSet<String> = self409
.pending_proposals()410
.into_iter()411
.map(|pending| pending.id)412
.collect();413
self.seen_proposals.retain(|id| pending.contains(id));414
let _ = self.store.set_meta(415
SEEN_PROPOSALS_KEY,416
&pending::encode_seen(&self.seen_proposals),417
);418
cx.notify();419
}420
349
pub fn reinstall_note(&self) -> Option<&str> {421
pub fn reinstall_note(&self) -> Option<&str> {350
self.reinstall_note.as_deref()422
self.reinstall_note.as_deref()351
}423
}@@ -394,6 +466,15 @@ impl AgentApi {394
pictures: Vec<ProposalPicture>,466
pictures: Vec<ProposalPicture>,395
cx: &mut Context<Self>,467
cx: &mut Context<Self>,396
) {468
) {469
if let mcp::UiEvent::ReactionProposalChanged(reaction) = &event470
&& let Some(excerpt) = pending::reacted_excerpt(471
&self.store,472
&reaction.conversation_id,473
&reaction.message_id,474
)475
{476
self.reaction_excerpts.insert(reaction.id.clone(), excerpt);477
}397
bridge::apply(478
bridge::apply(398
&mut self.proposals,479
&mut self.proposals,399
&mut self.reactions,480
&mut self.reactions,@@ -401,6 +482,9 @@ impl AgentApi {401
pictures,482
pictures,402
&self.store,483
&self.store,403
);484
);485
let reactions = &self.reactions;486
self.reaction_excerpts487
.retain(|id, _| reactions.values().any(|reaction| &reaction.id == id));404
cx.notify();488
cx.notify();405
}489
}406
490
@@ -0,0 +1,247 @@
1
use std::collections::{HashMap, HashSet};
2
3
use chrono::{DateTime, Utc};
4
use mcp::ReactionProposal;
5
use store::{Sidebar, Store};
6
7
use super::{ProposalEntry, ProposalStatus, agent_label};
8
use crate::activity::preview_label;
9
use crate::app_state::chat_title;
10
use crate::notify::preview_of;
11
use crate::rows::reaction_glyph;
12
13
const EXCERPT_CHARACTERS: usize = 120;
14
15
#[derive(Debug, Clone, PartialEq)]
16
pub enum PendingKind {
17
Reply {
18
text: String,
19
},
20
Reaction {
21
glyph: String,
22
message_id: String,
23
excerpt: Option<String>,
24
},
25
}
26
27
#[derive(Debug, Clone, PartialEq)]
28
pub struct PendingProposal {
29
pub id: String,
30
pub conversation_id: String,
31
pub agent: &'static str,
32
pub kind: PendingKind,
33
pub created_at: DateTime<Utc>,
34
pub seen: bool,
35
}
36
37
impl PendingProposal {
38
pub fn title(&self) -> String {
39
let what = match self.kind {
40
PendingKind::Reply { .. } => "a reply",
41
PendingKind::Reaction { .. } => "a reaction",
42
};
43
format!("{} proposes {what}", self.agent)
44
}
45
46
pub fn headline(&self, conversation: Option<&str>) -> String {
47
match conversation {
48
Some(conversation) => format!("{} in {conversation}", self.title()),
49
None => self.title(),
50
}
51
}
52
53
pub fn detail(&self) -> String {
54
match &self.kind {
55
PendingKind::Reply { text } => single_line(text),
56
PendingKind::Reaction {
57
glyph,
58
excerpt: Some(excerpt),
59
..
60
} => format!("{glyph} to: {excerpt}"),
61
PendingKind::Reaction { glyph, .. } => glyph.clone(),
62
}
63
}
64
65
pub fn jump_message_id(&self) -> &str {
66
match &self.kind {
67
PendingKind::Reply { .. } => "",
68
PendingKind::Reaction { message_id, .. } => message_id,
69
}
70
}
71
}
72
73
fn single_line(text: &str) -> String {
74
text.split_whitespace().collect::<Vec<_>>().join(" ")
75
}
76
77
pub fn collect(
78
proposals: &HashMap<String, ProposalEntry>,
79
reactions: &HashMap<(String, String), ReactionProposal>,
80
excerpts: &HashMap<String, String>,
81
seen: &HashSet<String>,
82
) -> Vec<PendingProposal> {
83
let replies = proposals
84
.values()
85
.filter(|entry| !matches!(entry.status, ProposalStatus::Stale { .. }))
86
.map(|entry| PendingProposal {
87
id: entry.proposal.id.clone(),
88
conversation_id: entry.proposal.conversation_id.clone(),
89
agent: agent_label(entry.proposal.agent.as_deref()),
90
kind: PendingKind::Reply {
91
text: entry.proposal.text.clone(),
92
},
93
created_at: entry.proposal.created_at,
94
seen: seen.contains(&entry.proposal.id),
95
});
96
let reacts = reactions.values().map(|reaction| PendingProposal {
97
id: reaction.id.clone(),
98
conversation_id: reaction.conversation_id.clone(),
99
agent: agent_label(reaction.agent.as_deref()),
100
kind: PendingKind::Reaction {
101
glyph: reaction_glyph(&reaction.emoji),
102
message_id: reaction.message_id.clone(),
103
excerpt: excerpts.get(&reaction.id).cloned(),
104
},
105
created_at: reaction.created_at,
106
seen: seen.contains(&reaction.id),
107
});
108
let mut pending: Vec<PendingProposal> = replies.chain(reacts).collect();
109
pending.sort_by(|left, right| {
110
right
111
.created_at
112
.cmp(&left.created_at)
113
.then_with(|| left.id.cmp(&right.id))
114
});
115
pending
116
}
117
118
pub fn conversation_label(sidebar: &Sidebar, conversation_id: &str) -> Option<String> {
119
if let Some(chat) = sidebar.chats.iter().find(|chat| chat.id == conversation_id) {
120
return Some(chat_title(chat));
121
}
122
sidebar.teams.iter().find_map(|team| {
123
team.channels
124
.iter()
125
.find(|channel| channel.id == conversation_id)
126
.map(|channel| format!("{} > {}", team.team.name, channel.name))
127
})
128
}
129
130
pub fn reacted_excerpt(store: &Store, conversation_id: &str, message_id: &str) -> Option<String> {
131
let records = store
132
.messages_by_id(conversation_id, &[message_id.to_owned()])
133
.ok()?;
134
let record = records.get(message_id)?;
135
let text = single_line(&preview_label(&preview_of(record)));
136
Some(text.chars().take(EXCERPT_CHARACTERS).collect())
137
}
138
139
pub fn decode_seen(saved: Option<String>) -> HashSet<String> {
140
saved
141
.unwrap_or_default()
142
.lines()
143
.filter(|line| !line.is_empty())
144
.map(str::to_owned)
145
.collect()
146
}
147
148
pub fn encode_seen(seen: &HashSet<String>) -> String {
149
let mut ids: Vec<&str> = seen.iter().map(String::as_str).collect();
150
ids.sort_unstable();
151
ids.join("\n")
152
}
153
154
#[cfg(test)]
155
mod tests {
156
use std::collections::{HashMap, HashSet};
157
use std::sync::Arc;
158
159
use chrono::{Local, TimeZone, Utc};
160
use mcp::{Proposal, ReactionProposal};
161
162
use super::*;
163
164
fn reply(
165
conversation_id: &str,
166
id: &str,
167
minute: u32,
168
status: ProposalStatus,
169
) -> ProposalEntry {
170
ProposalEntry {
171
proposal: Proposal {
172
id: id.into(),
173
conversation_id: conversation_id.into(),
174
reply_to_message_id: None,
175
text: "Looks\n good to me".into(),
176
mentions: Vec::new(),
177
images: Vec::new(),
178
agent: Some("claude".into()),
179
session_id: None,
180
created_at: Utc.with_ymd_and_hms(2026, 10, 18, 9, minute, 0).unwrap(),
181
},
182
body: Arc::new(Vec::new()),
183
mention_labels: Vec::new(),
184
images: Vec::new(),
185
status,
186
}
187
}
188
189
fn reaction(id: &str, minute: u32) -> ReactionProposal {
190
ReactionProposal {
191
id: id.into(),
192
conversation_id: "chat-b".into(),
193
message_id: "m7".into(),
194
emoji: "like".into(),
195
agent: Some("copilot".into()),
196
session_id: None,
197
created_at: Utc.with_ymd_and_hms(2026, 10, 18, 9, minute, 0).unwrap(),
198
}
199
}
200
201
#[test]
202
fn collect_lists_pending_replies_and_reactions_newest_first() {
203
let proposals = HashMap::from([
204
(
205
"chat-a".to_owned(),
206
reply("chat-a", "p1", 5, ProposalStatus::Pending),
207
),
208
(
209
"chat-c".to_owned(),
210
reply(
211
"chat-c",
212
"p2",
213
9,
214
ProposalStatus::Stale {
215
answered_at: Local::now(),
216
},
217
),
218
),
219
]);
220
let reactions =
221
HashMap::from([(("chat-b".to_owned(), "m7".to_owned()), reaction("r1", 7))]);
222
let excerpts = HashMap::from([("r1".to_owned(), "Ship it?".to_owned())]);
223
let seen = HashSet::from(["p1".to_owned()]);
224
let pending = collect(&proposals, &reactions, &excerpts, &seen);
225
let ids: Vec<&str> = pending.iter().map(|item| item.id.as_str()).collect();
226
assert_eq!(ids, ["r1", "p1"]);
227
assert!(!pending[0].seen);
228
assert!(pending[1].seen);
229
assert_eq!(pending[0].title(), "Copilot proposes a reaction");
230
assert_eq!(pending[0].jump_message_id(), "m7");
231
assert_eq!(pending[1].jump_message_id(), "");
232
assert_eq!(
233
pending[1].headline(Some("Release planning")),
234
"Claude proposes a reply in Release planning"
235
);
236
assert_eq!(pending[1].detail(), "Looks good to me");
237
assert!(pending[0].detail().ends_with(" to: Ship it?"));
238
}
239
240
#[test]
241
fn seen_ids_round_trip() {
242
let seen = HashSet::from(["b".to_owned(), "a".to_owned()]);
243
assert_eq!(encode_seen(&seen), "a\nb");
244
assert_eq!(decode_seen(Some(encode_seen(&seen))), seen);
245
assert!(decode_seen(None).is_empty());
246
}
247
}
@@ -0,0 +1,247 @@1
use std::collections::{HashMap, HashSet};2
3
use chrono::{DateTime, Utc};4
use mcp::ReactionProposal;5
use store::{Sidebar, Store};6
7
use super::{ProposalEntry, ProposalStatus, agent_label};8
use crate::activity::preview_label;9
use crate::app_state::chat_title;10
use crate::notify::preview_of;11
use crate::rows::reaction_glyph;12
13
const EXCERPT_CHARACTERS: usize = 120;14
15
#[derive(Debug, Clone, PartialEq)]16
pub enum PendingKind {17
Reply {18
text: String,19
},20
Reaction {21
glyph: String,22
message_id: String,23
excerpt: Option<String>,24
},25
}26
27
#[derive(Debug, Clone, PartialEq)]28
pub struct PendingProposal {29
pub id: String,30
pub conversation_id: String,31
pub agent: &'static str,32
pub kind: PendingKind,33
pub created_at: DateTime<Utc>,34
pub seen: bool,35
}36
37
impl PendingProposal {38
pub fn title(&self) -> String {39
let what = match self.kind {40
PendingKind::Reply { .. } => "a reply",41
PendingKind::Reaction { .. } => "a reaction",42
};43
format!("{} proposes {what}", self.agent)44
}45
46
pub fn headline(&self, conversation: Option<&str>) -> String {47
match conversation {48
Some(conversation) => format!("{} in {conversation}", self.title()),49
None => self.title(),50
}51
}52
53
pub fn detail(&self) -> String {54
match &self.kind {55
PendingKind::Reply { text } => single_line(text),56
PendingKind::Reaction {57
glyph,58
excerpt: Some(excerpt),59
..60
} => format!("{glyph} to: {excerpt}"),61
PendingKind::Reaction { glyph, .. } => glyph.clone(),62
}63
}64
65
pub fn jump_message_id(&self) -> &str {66
match &self.kind {67
PendingKind::Reply { .. } => "",68
PendingKind::Reaction { message_id, .. } => message_id,69
}70
}71
}72
73
fn single_line(text: &str) -> String {74
text.split_whitespace().collect::<Vec<_>>().join(" ")75
}76
77
pub fn collect(78
proposals: &HashMap<String, ProposalEntry>,79
reactions: &HashMap<(String, String), ReactionProposal>,80
excerpts: &HashMap<String, String>,81
seen: &HashSet<String>,82
) -> Vec<PendingProposal> {83
let replies = proposals84
.values()85
.filter(|entry| !matches!(entry.status, ProposalStatus::Stale { .. }))86
.map(|entry| PendingProposal {87
id: entry.proposal.id.clone(),88
conversation_id: entry.proposal.conversation_id.clone(),89
agent: agent_label(entry.proposal.agent.as_deref()),90
kind: PendingKind::Reply {91
text: entry.proposal.text.clone(),92
},93
created_at: entry.proposal.created_at,94
seen: seen.contains(&entry.proposal.id),95
});96
let reacts = reactions.values().map(|reaction| PendingProposal {97
id: reaction.id.clone(),98
conversation_id: reaction.conversation_id.clone(),99
agent: agent_label(reaction.agent.as_deref()),100
kind: PendingKind::Reaction {101
glyph: reaction_glyph(&reaction.emoji),102
message_id: reaction.message_id.clone(),103
excerpt: excerpts.get(&reaction.id).cloned(),104
},105
created_at: reaction.created_at,106
seen: seen.contains(&reaction.id),107
});108
let mut pending: Vec<PendingProposal> = replies.chain(reacts).collect();109
pending.sort_by(|left, right| {110
right111
.created_at112
.cmp(&left.created_at)113
.then_with(|| left.id.cmp(&right.id))114
});115
pending116
}117
118
pub fn conversation_label(sidebar: &Sidebar, conversation_id: &str) -> Option<String> {119
if let Some(chat) = sidebar.chats.iter().find(|chat| chat.id == conversation_id) {120
return Some(chat_title(chat));121
}122
sidebar.teams.iter().find_map(|team| {123
team.channels124
.iter()125
.find(|channel| channel.id == conversation_id)126
.map(|channel| format!("{} > {}", team.team.name, channel.name))127
})128
}129
130
pub fn reacted_excerpt(store: &Store, conversation_id: &str, message_id: &str) -> Option<String> {131
let records = store132
.messages_by_id(conversation_id, &[message_id.to_owned()])133
.ok()?;134
let record = records.get(message_id)?;135
let text = single_line(&preview_label(&preview_of(record)));136
Some(text.chars().take(EXCERPT_CHARACTERS).collect())137
}138
139
pub fn decode_seen(saved: Option<String>) -> HashSet<String> {140
saved141
.unwrap_or_default()142
.lines()143
.filter(|line| !line.is_empty())144
.map(str::to_owned)145
.collect()146
}147
148
pub fn encode_seen(seen: &HashSet<String>) -> String {149
let mut ids: Vec<&str> = seen.iter().map(String::as_str).collect();150
ids.sort_unstable();151
ids.join("\n")152
}153
154
#[cfg(test)]155
mod tests {156
use std::collections::{HashMap, HashSet};157
use std::sync::Arc;158
159
use chrono::{Local, TimeZone, Utc};160
use mcp::{Proposal, ReactionProposal};161
162
use super::*;163
164
fn reply(165
conversation_id: &str,166
id: &str,167
minute: u32,168
status: ProposalStatus,169
) -> ProposalEntry {170
ProposalEntry {171
proposal: Proposal {172
id: id.into(),173
conversation_id: conversation_id.into(),174
reply_to_message_id: None,175
text: "Looks\n good to me".into(),176
mentions: Vec::new(),177
images: Vec::new(),178
agent: Some("claude".into()),179
session_id: None,180
created_at: Utc.with_ymd_and_hms(2026, 10, 18, 9, minute, 0).unwrap(),181
},182
body: Arc::new(Vec::new()),183
mention_labels: Vec::new(),184
images: Vec::new(),185
status,186
}187
}188
189
fn reaction(id: &str, minute: u32) -> ReactionProposal {190
ReactionProposal {191
id: id.into(),192
conversation_id: "chat-b".into(),193
message_id: "m7".into(),194
emoji: "like".into(),195
agent: Some("copilot".into()),196
session_id: None,197
created_at: Utc.with_ymd_and_hms(2026, 10, 18, 9, minute, 0).unwrap(),198
}199
}200
201
#[test]202
fn collect_lists_pending_replies_and_reactions_newest_first() {203
let proposals = HashMap::from([204
(205
"chat-a".to_owned(),206
reply("chat-a", "p1", 5, ProposalStatus::Pending),207
),208
(209
"chat-c".to_owned(),210
reply(211
"chat-c",212
"p2",213
9,214
ProposalStatus::Stale {215
answered_at: Local::now(),216
},217
),218
),219
]);220
let reactions =221
HashMap::from([(("chat-b".to_owned(), "m7".to_owned()), reaction("r1", 7))]);222
let excerpts = HashMap::from([("r1".to_owned(), "Ship it?".to_owned())]);223
let seen = HashSet::from(["p1".to_owned()]);224
let pending = collect(&proposals, &reactions, &excerpts, &seen);225
let ids: Vec<&str> = pending.iter().map(|item| item.id.as_str()).collect();226
assert_eq!(ids, ["r1", "p1"]);227
assert!(!pending[0].seen);228
assert!(pending[1].seen);229
assert_eq!(pending[0].title(), "Copilot proposes a reaction");230
assert_eq!(pending[0].jump_message_id(), "m7");231
assert_eq!(pending[1].jump_message_id(), "");232
assert_eq!(233
pending[1].headline(Some("Release planning")),234
"Claude proposes a reply in Release planning"235
);236
assert_eq!(pending[1].detail(), "Looks good to me");237
assert!(pending[0].detail().ends_with(" to: Ship it?"));238
}239
240
#[test]241
fn seen_ids_round_trip() {242
let seen = HashSet::from(["b".to_owned(), "a".to_owned()]);243
assert_eq!(encode_seen(&seen), "a\nb");244
assert_eq!(decode_seen(Some(encode_seen(&seen))), seen);245
assert!(decode_seen(None).is_empty());246
}247
}@@ -207,12 +207,12 @@ mod tests {
207
207
assert_eq!(toast_height(&model("Hi"), 0), 112.);
208
208
let mut agent = model("Hi");
209
209
agent.agent = Some(super::super::stack::AgentToast {
210
run_id: 1,
211
session_id: String::new(),
210
kind: super::super::stack::AgentToastKind::Proposal {
211
proposal_id: "p".into(),
212
},
212
213
header: String::new(),
213
214
title: String::new(),
214
215
body: "Hi".into(),
215
failed: false,
216
216
});
217
217
assert_eq!(toast_height(&agent, 1), 134.);
218
218
assert_eq!(toast_height(&agent, 2), 152.);
@@ -207,12 +207,12 @@ mod tests {207
assert_eq!(toast_height(&model("Hi"), 0), 112.);207
assert_eq!(toast_height(&model("Hi"), 0), 112.);208
let mut agent = model("Hi");208
let mut agent = model("Hi");209
agent.agent = Some(super::super::stack::AgentToast {209
agent.agent = Some(super::super::stack::AgentToast {210
run_id: 1,210
kind: super::super::stack::AgentToastKind::Proposal {211
session_id: String::new(),211
proposal_id: "p".into(),212
},212
header: String::new(),213
header: String::new(),213
title: String::new(),214
title: String::new(),214
body: "Hi".into(),215
body: "Hi".into(),215
failed: false,216
});216
});217
assert_eq!(toast_height(&agent, 1), 134.);217
assert_eq!(toast_height(&agent, 1), 134.);218
assert_eq!(toast_height(&agent, 2), 152.);218
assert_eq!(toast_height(&agent, 2), 152.);@@ -264,6 +264,27 @@ pub fn decide(settings: &Settings, incoming: &Incoming, environment: Environment
264
264
}
265
265
}
266
266
267
pub fn decide_proposal(
268
settings: &Settings,
269
desktop: DesktopNotifications,
270
environment: Environment,
271
) -> Decision {
272
let suppressed = desktop == DesktopNotifications::Off
273
|| environment.chat_in_foreground
274
|| environment.system_quiet
275
|| environment.own_do_not_disturb
276
|| settings.do_not_disturb
277
|| (settings.mute_in_calls && environment.in_call);
278
if suppressed {
279
return SILENT;
280
}
281
Decision {
282
toast: true,
283
sound: settings.sounds.notification_sound
284
&& (settings.sounds.sound_when_busy || !environment.busy()),
285
}
286
}
287
267
288
fn busy_allows_sound(settings: &Settings, busy: bool) -> bool {
268
289
!busy || settings.sounds.sound_when_busy
269
290
}
@@ -350,6 +371,52 @@ mod tests {
350
371
);
351
372
}
352
373
374
#[test]
375
fn proposals_toast_like_messages_but_ignore_chat_mute() {
376
let settings = Settings::default();
377
let shown = decide_proposal(
378
&settings,
379
DesktopNotifications::default(),
380
Environment::default(),
381
);
382
assert!(shown.toast && shown.sound);
383
for environment in [
384
Environment {
385
chat_in_foreground: true,
386
..Default::default()
387
},
388
Environment {
389
own_do_not_disturb: true,
390
..Default::default()
391
},
392
Environment {
393
system_quiet: true,
394
..Default::default()
395
},
396
] {
397
assert_eq!(
398
decide_proposal(&settings, DesktopNotifications::default(), environment),
399
SILENT
400
);
401
}
402
assert_eq!(
403
decide_proposal(&settings, DesktopNotifications::Off, Environment::default()),
404
SILENT
405
);
406
let quiet = Settings {
407
do_not_disturb: true,
408
..Default::default()
409
};
410
assert_eq!(
411
decide_proposal(
412
&quiet,
413
DesktopNotifications::default(),
414
Environment::default()
415
),
416
SILENT
417
);
418
}
419
353
420
#[test]
354
421
fn foreground_chat_is_silent() {
355
422
let environment = Environment {
@@ -264,6 +264,27 @@ pub fn decide(settings: &Settings, incoming: &Incoming, environment: Environment264
}264
}265
}265
}266
266
267
pub fn decide_proposal(268
settings: &Settings,269
desktop: DesktopNotifications,270
environment: Environment,271
) -> Decision {272
let suppressed = desktop == DesktopNotifications::Off273
|| environment.chat_in_foreground274
|| environment.system_quiet275
|| environment.own_do_not_disturb276
|| settings.do_not_disturb277
|| (settings.mute_in_calls && environment.in_call);278
if suppressed {279
return SILENT;280
}281
Decision {282
toast: true,283
sound: settings.sounds.notification_sound284
&& (settings.sounds.sound_when_busy || !environment.busy()),285
}286
}287
267
fn busy_allows_sound(settings: &Settings, busy: bool) -> bool {288
fn busy_allows_sound(settings: &Settings, busy: bool) -> bool {268
!busy || settings.sounds.sound_when_busy289
!busy || settings.sounds.sound_when_busy269
}290
}@@ -350,6 +371,52 @@ mod tests {350
);371
);351
}372
}352
373
374
#[test]375
fn proposals_toast_like_messages_but_ignore_chat_mute() {376
let settings = Settings::default();377
let shown = decide_proposal(378
&settings,379
DesktopNotifications::default(),380
Environment::default(),381
);382
assert!(shown.toast && shown.sound);383
for environment in [384
Environment {385
chat_in_foreground: true,386
..Default::default()387
},388
Environment {389
own_do_not_disturb: true,390
..Default::default()391
},392
Environment {393
system_quiet: true,394
..Default::default()395
},396
] {397
assert_eq!(398
decide_proposal(&settings, DesktopNotifications::default(), environment),399
SILENT400
);401
}402
assert_eq!(403
decide_proposal(&settings, DesktopNotifications::Off, Environment::default()),404
SILENT405
);406
let quiet = Settings {407
do_not_disturb: true,408
..Default::default()409
};410
assert_eq!(411
decide_proposal(412
&quiet,413
DesktopNotifications::default(),414
Environment::default()415
),416
SILENT417
);418
}419
353
#[test]420
#[test]354
fn foreground_chat_is_silent() {421
fn foreground_chat_is_silent() {355
let environment = Environment {422
let environment = Environment {@@ -140,14 +140,37 @@ pub enum ReplyState {
140
140
Failed,
141
141
}
142
142
143
#[derive(Debug, Clone, PartialEq, Eq)]
144
pub enum AgentToastKind {
145
Run {
146
run_id: u64,
147
session_id: String,
148
failed: bool,
149
},
150
Proposal {
151
proposal_id: String,
152
},
153
}
154
143
155
#[derive(Debug, Clone, PartialEq, Eq)]
144
156
pub struct AgentToast {
145
pub run_id: u64,
146
pub session_id: String,
157
pub kind: AgentToastKind,
147
158
pub header: String,
148
159
pub title: String,
149
160
pub body: String,
150
pub failed: bool,
161
}
162
163
impl AgentToast {
164
pub fn failed(&self) -> bool {
165
matches!(self.kind, AgentToastKind::Run { failed: true, .. })
166
}
167
168
pub fn proposal_id(&self) -> Option<&str> {
169
match &self.kind {
170
AgentToastKind::Proposal { proposal_id } => Some(proposal_id),
171
AgentToastKind::Run { .. } => None,
172
}
173
}
151
174
}
152
175
153
176
#[derive(Debug, Clone)]
@@ -619,12 +642,14 @@ mod tests {
619
642
620
643
fn agent_toast() -> AgentToast {
621
644
AgentToast {
622
run_id: 7,
623
session_id: "s".into(),
645
kind: AgentToastKind::Run {
646
run_id: 7,
647
session_id: "s".into(),
648
failed: false,
649
},
624
650
header: "Answer this - Claude - 1:02".into(),
625
651
title: "Claude finished: Answer this for Mara".into(),
626
652
body: "Done".into(),
627
failed: false,
628
653
}
629
654
}
630
655
@@ -140,14 +140,37 @@ pub enum ReplyState {140
Failed,140
Failed,141
}141
}142
142
143
#[derive(Debug, Clone, PartialEq, Eq)]144
pub enum AgentToastKind {145
Run {146
run_id: u64,147
session_id: String,148
failed: bool,149
},150
Proposal {151
proposal_id: String,152
},153
}154
143
#[derive(Debug, Clone, PartialEq, Eq)]155
#[derive(Debug, Clone, PartialEq, Eq)]144
pub struct AgentToast {156
pub struct AgentToast {145
pub run_id: u64,157
pub kind: AgentToastKind,146
pub session_id: String,147
pub header: String,158
pub header: String,148
pub title: String,159
pub title: String,149
pub body: String,160
pub body: String,150
pub failed: bool,161
}162
163
impl AgentToast {164
pub fn failed(&self) -> bool {165
matches!(self.kind, AgentToastKind::Run { failed: true, .. })166
}167
168
pub fn proposal_id(&self) -> Option<&str> {169
match &self.kind {170
AgentToastKind::Proposal { proposal_id } => Some(proposal_id),171
AgentToastKind::Run { .. } => None,172
}173
}151
}174
}152
175
153
#[derive(Debug, Clone)]176
#[derive(Debug, Clone)]@@ -619,12 +642,14 @@ mod tests {619
642
620
fn agent_toast() -> AgentToast {643
fn agent_toast() -> AgentToast {621
AgentToast {644
AgentToast {622
run_id: 7,645
kind: AgentToastKind::Run {623
session_id: "s".into(),646
run_id: 7,647
session_id: "s".into(),648
failed: false,649
},624
header: "Answer this - Claude - 1:02".into(),650
header: "Answer this - Claude - 1:02".into(),625
title: "Claude finished: Answer this for Mara".into(),651
title: "Claude finished: Answer this for Mara".into(),626
body: "Done".into(),652
body: "Done".into(),627
failed: false,628
}653
}629
}654
}630
655
@@ -191,6 +191,7 @@ mod frames {
191
191
};
192
192
use crate::views::message_row::BUBBLE_TAGS;
193
193
use crate::views::pin_banner::{BANNER_INSET, PIN_BANNER_TAG};
194
use crate::views::activity_panel::ACTIVITY_PROPOSALS_TAG;
194
195
use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};
195
196
use crate::views::reaction_proposal_pill::REACTION_PILL;
196
197
use crate::views::recap_tab::RECAP_REGION;
@@ -596,6 +597,7 @@ mod frames {
596
597
.chain(SHARE_GUARDED)
597
598
.chain(CONSULT_GUARDED)
598
599
.chain([
600
&ACTIVITY_PROPOSALS_TAG,
599
601
&AGENTS_LIST,
600
602
&CALL_TRANSCRIPT,
601
603
&MENU,
@@ -2064,6 +2066,28 @@ mod frames {
2064
2066
}
2065
2067
}
2066
2068
2069
#[gpui_kit::test]
2070
fn agent_proposals_in_activity_stay_inside_the_sidebar(cx: &mut TestAppContext) {
2071
let (handle, _) = mount_with(cx, true);
2072
let mut visual = VisualTestContext::from_window(handle, cx);
2073
visual.dispatch_action(OpenActivity);
2074
for (width, height) in SIZES {
2075
visual.simulate_resize(size(px(width), px(height)));
2076
let window = Bounds {
2077
origin: point(px(0.), px(0.)),
2078
size: size(px(width), px(height)),
2079
};
2080
let tags = collect(&mut visual, Some(ACTIVITY_PROPOSALS_TAG));
2081
let mut expected = GUARDED.to_vec();
2082
expected.push(ACTIVITY_PROPOSALS_TAG);
2083
let found: Vec<String> = violations(&tags, window, &expected)
2084
.into_iter()
2085
.map(|(key, message)| format!("{width}x{height}:{key}: {message}"))
2086
.collect();
2087
assert!(found.is_empty(), "{}", found.join("\n"));
2088
}
2089
}
2090
2067
2091
#[gpui_kit::test]
2068
2092
fn agent_proposals_stay_inside_the_main_island(cx: &mut TestAppContext) {
2069
2093
let (handle, state) = mount_with(cx, true);
@@ -191,6 +191,7 @@ mod frames {191
};191
};192
use crate::views::message_row::BUBBLE_TAGS;192
use crate::views::message_row::BUBBLE_TAGS;193
use crate::views::pin_banner::{BANNER_INSET, PIN_BANNER_TAG};193
use crate::views::pin_banner::{BANNER_INSET, PIN_BANNER_TAG};194
use crate::views::activity_panel::ACTIVITY_PROPOSALS_TAG;194
use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};195
use crate::views::proposal_card::{PROPOSAL_BUTTONS, PROPOSAL_CARD, PROPOSAL_THUMBNAILS};195
use crate::views::reaction_proposal_pill::REACTION_PILL;196
use crate::views::reaction_proposal_pill::REACTION_PILL;196
use crate::views::recap_tab::RECAP_REGION;197
use crate::views::recap_tab::RECAP_REGION;@@ -596,6 +597,7 @@ mod frames {596
.chain(SHARE_GUARDED)597
.chain(SHARE_GUARDED)597
.chain(CONSULT_GUARDED)598
.chain(CONSULT_GUARDED)598
.chain([599
.chain([600
&ACTIVITY_PROPOSALS_TAG,599
&AGENTS_LIST,601
&AGENTS_LIST,600
&CALL_TRANSCRIPT,602
&CALL_TRANSCRIPT,601
&MENU,603
&MENU,@@ -2064,6 +2066,28 @@ mod frames {2064
}2066
}2065
}2067
}2066
2068
2069
#[gpui_kit::test]2070
fn agent_proposals_in_activity_stay_inside_the_sidebar(cx: &mut TestAppContext) {2071
let (handle, _) = mount_with(cx, true);2072
let mut visual = VisualTestContext::from_window(handle, cx);2073
visual.dispatch_action(OpenActivity);2074
for (width, height) in SIZES {2075
visual.simulate_resize(size(px(width), px(height)));2076
let window = Bounds {2077
origin: point(px(0.), px(0.)),2078
size: size(px(width), px(height)),2079
};2080
let tags = collect(&mut visual, Some(ACTIVITY_PROPOSALS_TAG));2081
let mut expected = GUARDED.to_vec();2082
expected.push(ACTIVITY_PROPOSALS_TAG);2083
let found: Vec<String> = violations(&tags, window, &expected)2084
.into_iter()2085
.map(|(key, message)| format!("{width}x{height}:{key}: {message}"))2086
.collect();2087
assert!(found.is_empty(), "{}", found.join("\n"));2088
}2089
}2090
2067
#[gpui_kit::test]2091
#[gpui_kit::test]2068
fn agent_proposals_stay_inside_the_main_island(cx: &mut TestAppContext) {2092
fn agent_proposals_stay_inside_the_main_island(cx: &mut TestAppContext) {2069
let (handle, state) = mount_with(cx, true);2093
let (handle, state) = mount_with(cx, true);@@ -5,7 +5,7 @@ use gpui_kit::*;
5
5
6
6
use super::center::NotificationCenter;
7
7
use super::layout::{PREVIEW_MAX_LINES, PREVIEW_SIZE};
8
use super::stack::AgentToast;
8
use super::stack::{AgentToast, AgentToastKind};
9
9
use crate::theme;
10
10
use crate::views::widgets::{icon, symbol};
11
11
@@ -45,12 +45,16 @@ pub(super) fn agent_toast_content(
45
45
) -> Div {
46
46
let (open_chat_center, follow_up_center, close_center) =
47
47
(center.clone(), center.clone(), center.clone());
48
let follow_up_label = if agent.failed {
49
"Retry"
50
} else {
51
"Open session"
48
let follow_up_label = match agent.kind {
49
AgentToastKind::Run { failed: true, .. } => Some("Retry"),
50
AgentToastKind::Run { .. } => Some("Open session"),
51
AgentToastKind::Proposal { .. } => None,
52
};
53
let open_label = match agent.kind {
54
AgentToastKind::Run { .. } => "Open chat",
55
AgentToastKind::Proposal { .. } => "Review",
52
56
};
53
let tint = if agent.failed {
57
let tint = if agent.failed() {
54
58
theme::red_soft()
55
59
} else {
56
60
theme::accent_text()
@@ -118,20 +122,18 @@ pub(super) fn agent_toast_content(
118
122
.child(
119
123
h_flex()
120
124
.gap(px(6.))
121
.child(button("agent-toast-open-chat", "Open chat", true).on_click(
125
.child(button("agent-toast-open-chat", open_label, true).on_click(
122
126
move |_, _, cx| {
123
127
cx.stop_propagation();
124
128
open_chat_center.update(cx, |center, cx| center.activate(id, cx));
125
129
},
126
130
))
127
.child(
128
button("agent-toast-follow-up", follow_up_label, false).on_click(
129
move |_, _, cx| {
130
cx.stop_propagation();
131
follow_up_center
132
.update(cx, |center, cx| center.agent_toast_follow_up(id, cx));
133
},
134
),
135
),
131
.children(follow_up_label.map(|label| {
132
button("agent-toast-follow-up", label, false).on_click(move |_, _, cx| {
133
cx.stop_propagation();
134
follow_up_center
135
.update(cx, |center, cx| center.agent_toast_follow_up(id, cx));
136
})
137
})),
136
138
)
137
139
}
@@ -5,7 +5,7 @@ use gpui_kit::*;5
5
6
use super::center::NotificationCenter;6
use super::center::NotificationCenter;7
use super::layout::{PREVIEW_MAX_LINES, PREVIEW_SIZE};7
use super::layout::{PREVIEW_MAX_LINES, PREVIEW_SIZE};8
use super::stack::AgentToast;8
use super::stack::{AgentToast, AgentToastKind};9
use crate::theme;9
use crate::theme;10
use crate::views::widgets::{icon, symbol};10
use crate::views::widgets::{icon, symbol};11
11
@@ -45,12 +45,16 @@ pub(super) fn agent_toast_content(45
) -> Div {45
) -> Div {46
let (open_chat_center, follow_up_center, close_center) =46
let (open_chat_center, follow_up_center, close_center) =47
(center.clone(), center.clone(), center.clone());47
(center.clone(), center.clone(), center.clone());48
let follow_up_label = if agent.failed {48
let follow_up_label = match agent.kind {49
"Retry"49
AgentToastKind::Run { failed: true, .. } => Some("Retry"),50
} else {50
AgentToastKind::Run { .. } => Some("Open session"),51
"Open session"51
AgentToastKind::Proposal { .. } => None,52
};53
let open_label = match agent.kind {54
AgentToastKind::Run { .. } => "Open chat",55
AgentToastKind::Proposal { .. } => "Review",52
};56
};53
let tint = if agent.failed {57
let tint = if agent.failed() {54
theme::red_soft()58
theme::red_soft()55
} else {59
} else {56
theme::accent_text()60
theme::accent_text()@@ -118,20 +122,18 @@ pub(super) fn agent_toast_content(118
.child(122
.child(119
h_flex()123
h_flex()120
.gap(px(6.))124
.gap(px(6.))121
.child(button("agent-toast-open-chat", "Open chat", true).on_click(125
.child(button("agent-toast-open-chat", open_label, true).on_click(122
move |_, _, cx| {126
move |_, _, cx| {123
cx.stop_propagation();127
cx.stop_propagation();124
open_chat_center.update(cx, |center, cx| center.activate(id, cx));128
open_chat_center.update(cx, |center, cx| center.activate(id, cx));125
},129
},126
))130
))127
.child(131
.children(follow_up_label.map(|label| {128
button("agent-toast-follow-up", follow_up_label, false).on_click(132
button("agent-toast-follow-up", label, false).on_click(move |_, _, cx| {129
move |_, _, cx| {133
cx.stop_propagation();130
cx.stop_propagation();134
follow_up_center131
follow_up_center135
.update(cx, |center, cx| center.agent_toast_follow_up(id, cx));132
.update(cx, |center, cx| center.agent_toast_follow_up(id, cx));136
})133
},137
})),134
),135
),136
)138
)137
}139
}@@ -1,7 +1,7 @@
1
1
use std::collections::{HashMap, HashSet};
2
2
use std::time::{Duration, Instant};
3
3
4
use chrono::Utc;
4
use chrono::{DateTime, Utc};
5
5
use gpui_kit::*;
6
6
use store::Sidebar;
7
7
@@ -12,20 +12,23 @@ use super::meeting_view::MeetingToastView;
12
12
use super::platform::{self, NativeHandle, Tray, TrayCommand, WorkArea};
13
13
use super::ring_view::RingView;
14
14
use super::rules::{
15
ChatKind, Decision, Environment, Incoming, Preview, Settings, SoundThrottle, decide, in_call,
16
meeting_start_sound, ringtone_for, should_flash, should_ringback, shows_preview,
15
ChatKind, Decision, Environment, Incoming, Preview, Settings, SoundThrottle, decide,
16
decide_proposal, in_call, meeting_start_sound, ringtone_for, should_flash, should_ringback,
17
shows_preview,
17
18
};
18
19
use super::settings;
19
20
use super::sound_cache::{self, SoundHandle};
20
21
use super::sounds::{CallTone, Ringtone};
21
22
use super::stack::{
22
AgentToast, FADE_IN, FAST_FADE, ReplyState, SENT_DURATION, SLOW_FADE, ToastModel, ToastStack,
23
AgentToast, AgentToastKind, FADE_IN, FAST_FADE, ReplyState, SENT_DURATION, SLOW_FADE,
24
ToastModel, ToastStack,
23
25
};
24
26
use super::taskbar::taskbar_badge_count;
25
27
use super::text::describe;
26
28
use super::toast::{PillView, ToastView};
27
29
use crate::active_appearance::{self, ActiveAppearance};
28
30
use crate::activity::ActivityCenter;
31
use crate::agent_api::{self, pending::PendingProposal};
29
32
use crate::agents::{AgentRun, AgentRunsEvent, RunState};
30
33
use crate::app_state::{AppEvent, AppState, selection_for};
31
34
use crate::appearance::AppIcon;
@@ -97,6 +100,9 @@ pub struct NotificationCenter {
97
100
_activity_observation: Subscription,
98
101
_appearance_observation: Subscription,
99
102
_agent_subscription: Option<Subscription>,
103
started_at: DateTime<Utc>,
104
known_proposals: HashSet<String>,
105
_proposal_observation: Option<Subscription>,
100
106
}
101
107
102
108
impl NotificationCenter {
@@ -135,7 +141,12 @@ impl NotificationCenter {
135
141
}
136
142
})
137
143
});
144
let proposal_observation =
145
agent_api::handle(cx).map(|api| cx.observe(&api, |this, _, cx| this.on_proposals(cx)));
138
146
let center = NotificationCenter {
147
started_at: Utc::now(),
148
known_proposals: HashSet::new(),
149
_proposal_observation: proposal_observation,
139
150
main_window: window.window_handle(),
140
151
main_native: platform::native_handle(window),
141
152
settings,
@@ -460,8 +471,11 @@ impl NotificationCenter {
460
471
first_lines(&run.final_text, AGENT_BODY_LINES)
461
472
};
462
473
let toast = AgentToast {
463
run_id: run.id,
464
session_id: run.session_id.clone(),
474
kind: AgentToastKind::Run {
475
run_id: run.id,
476
session_id: run.session_id.clone(),
477
failed,
478
},
465
479
header: format!(
466
480
"{} - {} - {}",
467
481
run.action_label,
@@ -477,7 +491,6 @@ impl NotificationCenter {
477
491
} else {
478
492
body
479
493
},
480
failed,
481
494
};
482
495
let now = Instant::now();
483
496
let id = self
@@ -498,11 +511,90 @@ impl NotificationCenter {
498
511
return;
499
512
};
500
513
self.drop_toast(id, cx);
501
if agent.failed {
502
crate::agents::retry_run(agent.run_id, cx);
503
} else {
504
crate::agents::open_session(&agent.session_id, cx);
514
match agent.kind {
515
AgentToastKind::Run {
516
run_id,
517
failed: true,
518
..
519
} => crate::agents::retry_run(run_id, cx),
520
AgentToastKind::Run { session_id, .. } => crate::agents::open_session(&session_id, cx),
521
AgentToastKind::Proposal { .. } => {}
522
}
523
}
524
525
fn on_proposals(&mut self, cx: &mut Context<Self>) {
526
let pending = agent_api::pending_proposals(cx);
527
let unseen: HashSet<&str> = pending
528
.iter()
529
.filter(|proposal| !proposal.seen)
530
.map(|proposal| proposal.id.as_str())
531
.collect();
532
let resolved: Vec<u64> = self
533
.stack
534
.ids()
535
.into_iter()
536
.filter(|id| {
537
self.stack
538
.get(*id)
539
.and_then(|toast| toast.agent.as_ref()?.proposal_id())
540
.is_some_and(|proposal_id| !unseen.contains(proposal_id))
541
})
542
.collect();
543
for id in resolved {
544
self.drop_toast(id, cx);
545
}
546
let arrived: Vec<PendingProposal> = pending
547
.iter()
548
.filter(|proposal| {
549
!self.known_proposals.contains(&proposal.id)
550
&& !proposal.seen
551
&& proposal.created_at >= self.started_at
552
})
553
.cloned()
554
.collect();
555
self.known_proposals = pending.into_iter().map(|proposal| proposal.id).collect();
556
for proposal in arrived {
557
self.present_proposal(&proposal, cx);
558
}
559
self.refresh_badge(cx);
560
}
561
562
fn present_proposal(&mut self, proposal: &PendingProposal, cx: &mut Context<Self>) {
563
let state = self.app.read(cx);
564
let desktop = state.chat_desktop_notifications(&proposal.conversation_id);
565
let conversation =
566
agent_api::pending::conversation_label(&state.sidebar, &proposal.conversation_id);
567
let environment = self.environment(&proposal.conversation_id, cx);
568
let decision = decide_proposal(&self.settings, desktop, environment);
569
if !decision.toast {
570
return;
571
}
572
let toast = AgentToast {
573
kind: AgentToastKind::Proposal {
574
proposal_id: proposal.id.clone(),
575
},
576
header: conversation.unwrap_or_else(|| proposal.agent.to_owned()),
577
title: proposal.title(),
578
body: proposal.detail(),
579
};
580
let id = self.stack.push_agent(
581
toast,
582
&proposal.conversation_id,
583
proposal.jump_message_id(),
584
Instant::now(),
585
);
586
if let Some(model) = self.stack.get_mut(id) {
587
model.time = chrono::Local::now().format("%H:%M").to_string();
505
588
}
589
if decision.sound && !self.demo_mode {
590
self.play_notification_sound(cx);
591
}
592
if should_flash(&self.settings, decision.toast, self.main_window_active(cx))
593
&& let Some(native) = self.main_native
594
{
595
platform::flash(native);
596
}
597
self.sync_windows(cx);
506
598
}
507
599
508
600
fn visible_ids(&self) -> Vec<u64> {
@@ -967,7 +1059,7 @@ impl NotificationCenter {
967
1059
&state.sidebar,
968
1060
self.activity.read(cx).feed(),
969
1061
state.directory.section_settings.adaptive_rail(),
970
);
1062
) + crate::agent_api::unseen_proposal_count(cx);
971
1063
let still_unread = unread_conversation_ids(&state.sidebar);
972
1064
self.unread_mentions
973
1065
.retain(|conversation_id| still_unread.contains(conversation_id.as_str()));
@@ -1108,19 +1200,31 @@ impl NotificationCenter {
1108
1200
if self.is_dismissed(id) {
1109
1201
return;
1110
1202
}
1111
let Some((conversation_id, message_id)) = self
1112
.stack
1113
.get(id)
1114
.map(|toast| (toast.conversation_id.clone(), toast.message_id.clone()))
1115
else {
1203
let Some((conversation_id, message_id, proposal_id)) = self.stack.get(id).map(|toast| {
1204
(
1205
toast.conversation_id.clone(),
1206
toast.message_id.clone(),
1207
toast
1208
.agent
1209
.as_ref()
1210
.and_then(|agent| agent.proposal_id().map(str::to_owned)),
1211
)
1212
}) else {
1116
1213
return;
1117
1214
};
1118
1215
self.drop_toast(id, cx);
1216
if let Some(proposal_id) = proposal_id {
1217
agent_api::mark_proposal_seen(&proposal_id, cx);
1218
}
1119
1219
self.raise_main_window(cx);
1120
1220
let selection = selection_for(&self.app.read(cx).sidebar, &conversation_id);
1121
1221
if let Some(selection) = selection {
1122
1222
self.app.update(cx, |state, cx| {
1123
state.jump_to_message(selection, message_id, cx)
1223
if message_id.is_empty() {
1224
state.select(selection, cx)
1225
} else {
1226
state.jump_to_message(selection, message_id, cx)
1227
}
1124
1228
});
1125
1229
}
1126
1230
}
@@ -1,7 +1,7 @@1
use std::collections::{HashMap, HashSet};1
use std::collections::{HashMap, HashSet};2
use std::time::{Duration, Instant};2
use std::time::{Duration, Instant};3
3
4
use chrono::Utc;4
use chrono::{DateTime, Utc};5
use gpui_kit::*;5
use gpui_kit::*;6
use store::Sidebar;6
use store::Sidebar;7
7
@@ -12,20 +12,23 @@ use super::meeting_view::MeetingToastView;12
use super::platform::{self, NativeHandle, Tray, TrayCommand, WorkArea};12
use super::platform::{self, NativeHandle, Tray, TrayCommand, WorkArea};13
use super::ring_view::RingView;13
use super::ring_view::RingView;14
use super::rules::{14
use super::rules::{15
ChatKind, Decision, Environment, Incoming, Preview, Settings, SoundThrottle, decide, in_call,15
ChatKind, Decision, Environment, Incoming, Preview, Settings, SoundThrottle, decide,16
meeting_start_sound, ringtone_for, should_flash, should_ringback, shows_preview,16
decide_proposal, in_call, meeting_start_sound, ringtone_for, should_flash, should_ringback,17
shows_preview,17
};18
};18
use super::settings;19
use super::settings;19
use super::sound_cache::{self, SoundHandle};20
use super::sound_cache::{self, SoundHandle};20
use super::sounds::{CallTone, Ringtone};21
use super::sounds::{CallTone, Ringtone};21
use super::stack::{22
use super::stack::{22
AgentToast, FADE_IN, FAST_FADE, ReplyState, SENT_DURATION, SLOW_FADE, ToastModel, ToastStack,23
AgentToast, AgentToastKind, FADE_IN, FAST_FADE, ReplyState, SENT_DURATION, SLOW_FADE,24
ToastModel, ToastStack,23
};25
};24
use super::taskbar::taskbar_badge_count;26
use super::taskbar::taskbar_badge_count;25
use super::text::describe;27
use super::text::describe;26
use super::toast::{PillView, ToastView};28
use super::toast::{PillView, ToastView};27
use crate::active_appearance::{self, ActiveAppearance};29
use crate::active_appearance::{self, ActiveAppearance};28
use crate::activity::ActivityCenter;30
use crate::activity::ActivityCenter;31
use crate::agent_api::{self, pending::PendingProposal};29
use crate::agents::{AgentRun, AgentRunsEvent, RunState};32
use crate::agents::{AgentRun, AgentRunsEvent, RunState};30
use crate::app_state::{AppEvent, AppState, selection_for};33
use crate::app_state::{AppEvent, AppState, selection_for};31
use crate::appearance::AppIcon;34
use crate::appearance::AppIcon;@@ -97,6 +100,9 @@ pub struct NotificationCenter {97
_activity_observation: Subscription,100
_activity_observation: Subscription,98
_appearance_observation: Subscription,101
_appearance_observation: Subscription,99
_agent_subscription: Option<Subscription>,102
_agent_subscription: Option<Subscription>,103
started_at: DateTime<Utc>,104
known_proposals: HashSet<String>,105
_proposal_observation: Option<Subscription>,100
}106
}101
107
102
impl NotificationCenter {108
impl NotificationCenter {@@ -135,7 +141,12 @@ impl NotificationCenter {135
}141
}136
})142
})137
});143
});144
let proposal_observation =145
agent_api::handle(cx).map(|api| cx.observe(&api, |this, _, cx| this.on_proposals(cx)));138
let center = NotificationCenter {146
let center = NotificationCenter {147
started_at: Utc::now(),148
known_proposals: HashSet::new(),149
_proposal_observation: proposal_observation,139
main_window: window.window_handle(),150
main_window: window.window_handle(),140
main_native: platform::native_handle(window),151
main_native: platform::native_handle(window),141
settings,152
settings,@@ -460,8 +471,11 @@ impl NotificationCenter {460
first_lines(&run.final_text, AGENT_BODY_LINES)471
first_lines(&run.final_text, AGENT_BODY_LINES)461
};472
};462
let toast = AgentToast {473
let toast = AgentToast {463
run_id: run.id,474
kind: AgentToastKind::Run {464
session_id: run.session_id.clone(),475
run_id: run.id,476
session_id: run.session_id.clone(),477
failed,478
},465
header: format!(479
header: format!(466
"{} - {} - {}",480
"{} - {} - {}",467
run.action_label,481
run.action_label,@@ -477,7 +491,6 @@ impl NotificationCenter {477
} else {491
} else {478
body492
body479
},493
},480
failed,481
};494
};482
let now = Instant::now();495
let now = Instant::now();483
let id = self496
let id = self@@ -498,11 +511,90 @@ impl NotificationCenter {498
return;511
return;499
};512
};500
self.drop_toast(id, cx);513
self.drop_toast(id, cx);501
if agent.failed {514
match agent.kind {502
crate::agents::retry_run(agent.run_id, cx);515
AgentToastKind::Run {503
} else {516
run_id,504
crate::agents::open_session(&agent.session_id, cx);517
failed: true,518
..519
} => crate::agents::retry_run(run_id, cx),520
AgentToastKind::Run { session_id, .. } => crate::agents::open_session(&session_id, cx),521
AgentToastKind::Proposal { .. } => {}522
}523
}524
525
fn on_proposals(&mut self, cx: &mut Context<Self>) {526
let pending = agent_api::pending_proposals(cx);527
let unseen: HashSet<&str> = pending528
.iter()529
.filter(|proposal| !proposal.seen)530
.map(|proposal| proposal.id.as_str())531
.collect();532
let resolved: Vec<u64> = self533
.stack534
.ids()535
.into_iter()536
.filter(|id| {537
self.stack538
.get(*id)539
.and_then(|toast| toast.agent.as_ref()?.proposal_id())540
.is_some_and(|proposal_id| !unseen.contains(proposal_id))541
})542
.collect();543
for id in resolved {544
self.drop_toast(id, cx);545
}546
let arrived: Vec<PendingProposal> = pending547
.iter()548
.filter(|proposal| {549
!self.known_proposals.contains(&proposal.id)550
&& !proposal.seen551
&& proposal.created_at >= self.started_at552
})553
.cloned()554
.collect();555
self.known_proposals = pending.into_iter().map(|proposal| proposal.id).collect();556
for proposal in arrived {557
self.present_proposal(&proposal, cx);558
}559
self.refresh_badge(cx);560
}561
562
fn present_proposal(&mut self, proposal: &PendingProposal, cx: &mut Context<Self>) {563
let state = self.app.read(cx);564
let desktop = state.chat_desktop_notifications(&proposal.conversation_id);565
let conversation =566
agent_api::pending::conversation_label(&state.sidebar, &proposal.conversation_id);567
let environment = self.environment(&proposal.conversation_id, cx);568
let decision = decide_proposal(&self.settings, desktop, environment);569
if !decision.toast {570
return;571
}572
let toast = AgentToast {573
kind: AgentToastKind::Proposal {574
proposal_id: proposal.id.clone(),575
},576
header: conversation.unwrap_or_else(|| proposal.agent.to_owned()),577
title: proposal.title(),578
body: proposal.detail(),579
};580
let id = self.stack.push_agent(581
toast,582
&proposal.conversation_id,583
proposal.jump_message_id(),584
Instant::now(),585
);586
if let Some(model) = self.stack.get_mut(id) {587
model.time = chrono::Local::now().format("%H:%M").to_string();505
}588
}589
if decision.sound && !self.demo_mode {590
self.play_notification_sound(cx);591
}592
if should_flash(&self.settings, decision.toast, self.main_window_active(cx))593
&& let Some(native) = self.main_native594
{595
platform::flash(native);596
}597
self.sync_windows(cx);506
}598
}507
599
508
fn visible_ids(&self) -> Vec<u64> {600
fn visible_ids(&self) -> Vec<u64> {@@ -967,7 +1059,7 @@ impl NotificationCenter {967
&state.sidebar,1059
&state.sidebar,968
self.activity.read(cx).feed(),1060
self.activity.read(cx).feed(),969
state.directory.section_settings.adaptive_rail(),1061
state.directory.section_settings.adaptive_rail(),970
);1062
) + crate::agent_api::unseen_proposal_count(cx);971
let still_unread = unread_conversation_ids(&state.sidebar);1063
let still_unread = unread_conversation_ids(&state.sidebar);972
self.unread_mentions1064
self.unread_mentions973
.retain(|conversation_id| still_unread.contains(conversation_id.as_str()));1065
.retain(|conversation_id| still_unread.contains(conversation_id.as_str()));@@ -1108,19 +1200,31 @@ impl NotificationCenter {1108
if self.is_dismissed(id) {1200
if self.is_dismissed(id) {1109
return;1201
return;1110
}1202
}1111
let Some((conversation_id, message_id)) = self1203
let Some((conversation_id, message_id, proposal_id)) = self.stack.get(id).map(|toast| {1112
.stack1204
(1113
.get(id)1205
toast.conversation_id.clone(),1114
.map(|toast| (toast.conversation_id.clone(), toast.message_id.clone()))1206
toast.message_id.clone(),1115
else {1207
toast1208
.agent1209
.as_ref()1210
.and_then(|agent| agent.proposal_id().map(str::to_owned)),1211
)1212
}) else {1116
return;1213
return;1117
};1214
};1118
self.drop_toast(id, cx);1215
self.drop_toast(id, cx);1216
if let Some(proposal_id) = proposal_id {1217
agent_api::mark_proposal_seen(&proposal_id, cx);1218
}1119
self.raise_main_window(cx);1219
self.raise_main_window(cx);1120
let selection = selection_for(&self.app.read(cx).sidebar, &conversation_id);1220
let selection = selection_for(&self.app.read(cx).sidebar, &conversation_id);1121
if let Some(selection) = selection {1221
if let Some(selection) = selection {1122
self.app.update(cx, |state, cx| {1222
self.app.update(cx, |state, cx| {1123
state.jump_to_message(selection, message_id, cx)1223
if message_id.is_empty() {1224
state.select(selection, cx)1225
} else {1226
state.jump_to_message(selection, message_id, cx)1227
}1124
});1228
});1125
}1229
}1126
}1230
}@@ -1,4 +1,5 @@
1
1
use std::collections::{HashMap, HashSet};
2
use std::rc::Rc;
2
3
3
4
use chrono::{DateTime, Local, NaiveDate, Offset};
4
5
use gpui_kit::assets::IconName;
@@ -12,6 +13,10 @@ use super::scroll_edge::with_top_edge;
12
13
use super::sidebar::SIDEBAR_SCROLL_DIVIDER;
13
14
use super::widgets::{Corner, corner_badge, dot, icon};
14
15
use crate::activity::{ActivityCenter, Entry, Filter, Kind};
16
use crate::agent_api::{
17
self,
18
pending::{PendingKind, PendingProposal, conversation_label as proposal_conversation_label},
19
};
15
20
use crate::app_state::{AppState, chat_title};
16
21
use crate::data::is_one_on_one;
17
22
use crate::format;
@@ -23,6 +28,8 @@ const KIND_MARKER_SIZE: f32 = 16.;
23
28
const BUTTON_SIZE: f32 = 32.;
24
29
const MARK_READ_SIZE: f32 = 20.;
25
30
const FILTER_KEY: &str = "activity_filter";
31
const PROPOSALS_LABEL: &str = "Agent proposals";
32
pub const ACTIVITY_PROPOSALS_TAG: &str = "shell/islands/sidebar/activity-proposals";
26
33
27
34
pub enum ActivityPanelEvent {
28
35
OpenSettings,
@@ -185,92 +192,181 @@ impl ActivityPanel {
185
192
) -> AnyElement {
186
193
let activity = self.activity.clone();
187
194
let id = entry.id;
188
let resolved_names = &self.resolved_names;
189
let unread = !entry.read;
190
195
let actor = entry.latest_actor();
191
196
let avatar = person_avatar(
192
197
directory,
193
198
actor.and_then(|actor| actor.user_id.as_deref()),
194
actor.map_or("", |actor| actor.display_name(resolved_names)),
199
actor.map_or("", |actor| actor.display_name(&self.resolved_names)),
195
200
AVATAR_SIZE,
196
201
);
197
202
let group = SharedString::from(format!("activity-row-group-{id}"));
198
h_flex()
199
.id(ElementId::Name(format!("activity-row-{id}").into()))
200
.debug_selector(|| format!("activity-row-{id}"))
201
.group(group.clone())
202
.mx(px(6.))
203
.px(px(10.))
204
.py(px(8.))
205
.gap(px(12.))
206
.items_start()
207
.rounded(px(8.))
208
.cursor_pointer()
209
.hover(|row| row.bg(theme::row_hover()))
210
.child(
211
div()
212
.relative()
213
.flex_none()
214
.size(px(AVATAR_SIZE))
215
.child(avatar)
216
.child(kind_marker(entry, group.clone())),
217
)
218
.child(
219
v_flex()
220
.flex_1()
221
.min_w_0()
222
.gap(px(2.))
223
.child(
224
div()
225
.truncate()
226
.text_size(px(13.))
227
.font_weight(if unread {
228
FontWeight::SEMIBOLD
229
} else {
230
FontWeight::NORMAL
231
})
232
.text_color(if unread {
233
theme::text()
234
} else {
235
theme::text_soft()
236
})
237
.child(headline(entry, sidebar, resolved_names)),
238
)
239
.child(
240
div()
241
.truncate()
242
.text_size(px(12.))
243
.text_color(if unread {
244
theme::text_soft()
245
} else {
246
theme::text_muted()
247
})
248
.child(detail(entry)),
249
),
250
)
251
.child(
252
v_flex()
253
.flex_none()
254
.items_end()
255
.child(
256
div()
257
.text_size(px(11.))
258
.text_color(theme::text_muted())
259
.child(format::list_time_label(entry.updated_at, today, offset)),
260
)
261
.child(status_slot(id, unread, group, activity)),
262
)
263
.on_click(move |_, _, cx| panel.update(cx, |this, cx| this.open(id, cx)))
264
.into_any_element()
203
row_frame(RowParts {
204
element_id: format!("activity-row-{id}"),
205
avatar: avatar.into_any_element(),
206
marker: kind_marker(entry, group.clone()),
207
group,
208
headline: headline(entry, sidebar, &self.resolved_names),
209
detail: detail(entry),
210
unread: !entry.read,
211
time: format::list_time_label(entry.updated_at, today, offset),
212
mark_read: Rc::new(move |cx: &mut App| {
213
activity.update(cx, |activity, cx| activity.mark_read(id, cx))
214
}),
215
})
216
.on_click(move |_, _, cx| panel.update(cx, |this, cx| this.open(id, cx)))
217
.into_any_element()
218
}
219
220
fn proposal_row(
221
&self,
222
pending: &PendingProposal,
223
sidebar: &Sidebar,
224
today: NaiveDate,
225
offset: chrono::FixedOffset,
226
panel: Entity<ActivityPanel>,
227
) -> AnyElement {
228
let group = SharedString::from(format!("activity-proposal-group-{}", pending.id));
229
let label = proposal_conversation_label(sidebar, &pending.conversation_id);
230
let proposal_id = pending.id.clone();
231
let opened = pending.clone();
232
row_frame(RowParts {
233
element_id: format!("activity-proposal-{}", pending.id),
234
avatar: agent_avatar().into_any_element(),
235
marker: proposal_marker(pending, group.clone()),
236
group,
237
headline: pending.headline(label.as_deref()),
238
detail: pending.detail(),
239
unread: !pending.seen,
240
time: format::list_time_label(pending.created_at, today, offset),
241
mark_read: Rc::new(move |cx: &mut App| agent_api::mark_proposal_seen(&proposal_id, cx)),
242
})
243
.on_click(move |_, _, cx| panel.update(cx, |this, cx| this.open_proposal(&opened, cx)))
244
.into_any_element()
245
}
246
247
fn open_proposal(&mut self, pending: &PendingProposal, cx: &mut Context<Self>) {
248
agent_api::mark_proposal_seen(&pending.id, cx);
249
cx.emit(ActivityPanelEvent::Open {
250
conversation_id: pending.conversation_id.clone(),
251
message_id: pending.jump_message_id().to_owned(),
252
});
265
253
}
266
254
}
267
255
268
fn status_slot(
269
id: i64,
270
unread: bool,
256
struct RowParts {
257
element_id: String,
271
258
group: SharedString,
272
activity: Entity<ActivityCenter>,
273
) -> Div {
259
avatar: AnyElement,
260
marker: Div,
261
headline: String,
262
detail: String,
263
unread: bool,
264
time: String,
265
mark_read: MarkRead,
266
}
267
268
type MarkRead = Rc<dyn Fn(&mut App)>;
269
270
fn row_frame(parts: RowParts) -> Stateful<Div> {
271
let RowParts {
272
element_id,
273
group,
274
avatar,
275
marker,
276
headline,
277
detail,
278
unread,
279
time,
280
mark_read,
281
} = parts;
282
let selector = element_id.clone();
283
h_flex()
284
.id(ElementId::Name(element_id.clone().into()))
285
.debug_selector(move || selector)
286
.group(group.clone())
287
.mx(px(6.))
288
.px(px(10.))
289
.py(px(8.))
290
.gap(px(12.))
291
.items_start()
292
.rounded(px(8.))
293
.cursor_pointer()
294
.hover(|row| row.bg(theme::row_hover()))
295
.child(
296
div()
297
.relative()
298
.flex_none()
299
.size(px(AVATAR_SIZE))
300
.child(avatar)
301
.child(marker),
302
)
303
.child(
304
v_flex()
305
.flex_1()
306
.min_w_0()
307
.gap(px(2.))
308
.child(
309
div()
310
.truncate()
311
.text_size(px(13.))
312
.font_weight(if unread {
313
FontWeight::SEMIBOLD
314
} else {
315
FontWeight::NORMAL
316
})
317
.text_color(if unread {
318
theme::text()
319
} else {
320
theme::text_soft()
321
})
322
.child(headline),
323
)
324
.child(
325
div()
326
.truncate()
327
.text_size(px(12.))
328
.text_color(if unread {
329
theme::text_soft()
330
} else {
331
theme::text_muted()
332
})
333
.child(detail),
334
),
335
)
336
.child(
337
v_flex()
338
.flex_none()
339
.items_end()
340
.child(
341
div()
342
.text_size(px(11.))
343
.text_color(theme::text_muted())
344
.child(time),
345
)
346
.child(status_slot(element_id, unread, group, mark_read)),
347
)
348
}
349
350
fn agent_avatar() -> Div {
351
div()
352
.size(px(AVATAR_SIZE))
353
.flex()
354
.items_center()
355
.justify_center()
356
.rounded_full()
357
.bg(theme::accent_soft())
358
.child(icon(IconName::Bot, 16., theme::accent_text()))
359
}
360
361
fn admits_proposal(filter: Filter, pending: &PendingProposal) -> bool {
362
match filter {
363
Filter::All => true,
364
Filter::Mentions => false,
365
Filter::Unread => !pending.seen,
366
}
367
}
368
369
fn status_slot(element_id: String, unread: bool, group: SharedString, mark_read: MarkRead) -> Div {
274
370
let slot = div()
275
371
.h(px(MARK_READ_SIZE))
276
372
.flex()
@@ -292,7 +388,7 @@ fn status_slot(
292
388
)
293
389
.child(
294
390
div()
295
.id(ElementId::Name(format!("activity-mark-read-{id}").into()))
391
.id(ElementId::Name(format!("{element_id}-mark-read").into()))
296
392
.absolute()
297
393
.top_0()
298
394
.right_0()
@@ -309,13 +405,13 @@ fn status_slot(
309
405
.tooltip(|window, cx| Tooltip::new("Mark as read").build(window, cx))
310
406
.on_click(move |_, _, cx| {
311
407
cx.stop_propagation();
312
activity.update(cx, |activity, cx| activity.mark_read(id, cx));
408
mark_read(cx);
313
409
}),
314
410
)
315
411
}
316
412
317
fn kind_marker(entry: &Entry, row_group: SharedString) -> Div {
318
let marker = corner_badge(Corner::BottomRight, 4.)
413
fn marker_frame(row_group: SharedString) -> Div {
414
corner_badge(Corner::BottomRight, 4.)
319
415
.size(px(KIND_MARKER_SIZE))
320
416
.flex()
321
417
.items_center()
@@ -325,7 +421,21 @@ fn kind_marker(entry: &Entry, row_group: SharedString) -> Div {
325
421
.border_color(theme::surface())
326
422
.group_hover(row_group, |marker| marker.border_color(theme::row_hover()))
327
423
.bg(theme::surface_raised())
328
.text_size(px(10.));
424
.text_size(px(10.))
425
}
426
427
fn proposal_marker(pending: &PendingProposal, row_group: SharedString) -> Div {
428
let marker = marker_frame(row_group);
429
match &pending.kind {
430
PendingKind::Reply { .. } => {
431
marker.child(icon(IconName::MessageCircle, 10., theme::text_muted()))
432
}
433
PendingKind::Reaction { glyph, .. } => marker.child(glyph.clone()),
434
}
435
}
436
437
fn kind_marker(entry: &Entry, row_group: SharedString) -> Div {
438
let marker = marker_frame(row_group);
329
439
match entry.kind {
330
440
Kind::Messages => marker.child(icon(IconName::MessageCircle, 10., theme::text_muted())),
331
441
Kind::Mention => marker
@@ -374,7 +484,7 @@ fn conversation_label(sidebar: &Sidebar, conversation_id: &str) -> Option<String
374
484
})
375
485
}
376
486
377
fn date_header(label: &'static str) -> AnyElement {
487
fn group_header(label: &'static str) -> Div {
378
488
div()
379
489
.h(px(26.))
380
490
.mt(px(4.))
@@ -386,7 +496,6 @@ fn date_header(label: &'static str) -> AnyElement {
386
496
.font_weight(FontWeight::SEMIBOLD)
387
497
.text_color(theme::text_muted())
388
498
.child(label)
389
.into_any_element()
390
499
}
391
500
392
501
impl Render for ActivityPanel {
@@ -414,8 +523,22 @@ impl Render for ActivityPanel {
414
523
.extend(resolve_names(state, &unresolved));
415
524
}
416
525
let mut rows: Vec<AnyElement> = Vec::new();
526
let proposal_rows: Vec<AnyElement> = agent_api::pending_proposals(cx)
527
.iter()
528
.filter(|pending| admits_proposal(self.filter, pending))
529
.map(|pending| self.proposal_row(pending, &state.sidebar, today, offset, panel.clone()))
530
.collect();
531
if !proposal_rows.is_empty() {
532
rows.push(
533
v_flex()
534
.debug_selector(|| ACTIVITY_PROPOSALS_TAG.into())
535
.child(group_header(PROPOSALS_LABEL))
536
.children(proposal_rows)
537
.into_any_element(),
538
);
539
}
417
540
for section in sections {
418
rows.push(date_header(section.bucket.label()));
541
rows.push(group_header(section.bucket.label()).into_any_element());
419
542
for entry in section.entries {
420
543
rows.push(self.row(
421
544
entry,
@@ -1,4 +1,5 @@1
use std::collections::{HashMap, HashSet};1
use std::collections::{HashMap, HashSet};2
use std::rc::Rc;2
3
3
use chrono::{DateTime, Local, NaiveDate, Offset};4
use chrono::{DateTime, Local, NaiveDate, Offset};4
use gpui_kit::assets::IconName;5
use gpui_kit::assets::IconName;@@ -12,6 +13,10 @@ use super::scroll_edge::with_top_edge;12
use super::sidebar::SIDEBAR_SCROLL_DIVIDER;13
use super::sidebar::SIDEBAR_SCROLL_DIVIDER;13
use super::widgets::{Corner, corner_badge, dot, icon};14
use super::widgets::{Corner, corner_badge, dot, icon};14
use crate::activity::{ActivityCenter, Entry, Filter, Kind};15
use crate::activity::{ActivityCenter, Entry, Filter, Kind};16
use crate::agent_api::{17
self,18
pending::{PendingKind, PendingProposal, conversation_label as proposal_conversation_label},19
};15
use crate::app_state::{AppState, chat_title};20
use crate::app_state::{AppState, chat_title};16
use crate::data::is_one_on_one;21
use crate::data::is_one_on_one;17
use crate::format;22
use crate::format;@@ -23,6 +28,8 @@ const KIND_MARKER_SIZE: f32 = 16.;23
const BUTTON_SIZE: f32 = 32.;28
const BUTTON_SIZE: f32 = 32.;24
const MARK_READ_SIZE: f32 = 20.;29
const MARK_READ_SIZE: f32 = 20.;25
const FILTER_KEY: &str = "activity_filter";30
const FILTER_KEY: &str = "activity_filter";31
const PROPOSALS_LABEL: &str = "Agent proposals";32
pub const ACTIVITY_PROPOSALS_TAG: &str = "shell/islands/sidebar/activity-proposals";26
33
27
pub enum ActivityPanelEvent {34
pub enum ActivityPanelEvent {28
OpenSettings,35
OpenSettings,@@ -185,92 +192,181 @@ impl ActivityPanel {185
) -> AnyElement {192
) -> AnyElement {186
let activity = self.activity.clone();193
let activity = self.activity.clone();187
let id = entry.id;194
let id = entry.id;188
let resolved_names = &self.resolved_names;189
let unread = !entry.read;190
let actor = entry.latest_actor();195
let actor = entry.latest_actor();191
let avatar = person_avatar(196
let avatar = person_avatar(192
directory,197
directory,193
actor.and_then(|actor| actor.user_id.as_deref()),198
actor.and_then(|actor| actor.user_id.as_deref()),194
actor.map_or("", |actor| actor.display_name(resolved_names)),199
actor.map_or("", |actor| actor.display_name(&self.resolved_names)),195
AVATAR_SIZE,200
AVATAR_SIZE,196
);201
);197
let group = SharedString::from(format!("activity-row-group-{id}"));202
let group = SharedString::from(format!("activity-row-group-{id}"));198
h_flex()203
row_frame(RowParts {199
.id(ElementId::Name(format!("activity-row-{id}").into()))204
element_id: format!("activity-row-{id}"),200
.debug_selector(|| format!("activity-row-{id}"))205
avatar: avatar.into_any_element(),201
.group(group.clone())206
marker: kind_marker(entry, group.clone()),202
.mx(px(6.))207
group,203
.px(px(10.))208
headline: headline(entry, sidebar, &self.resolved_names),204
.py(px(8.))209
detail: detail(entry),205
.gap(px(12.))210
unread: !entry.read,206
.items_start()211
time: format::list_time_label(entry.updated_at, today, offset),207
.rounded(px(8.))212
mark_read: Rc::new(move |cx: &mut App| {208
.cursor_pointer()213
activity.update(cx, |activity, cx| activity.mark_read(id, cx))209
.hover(|row| row.bg(theme::row_hover()))214
}),210
.child(215
})211
div()216
.on_click(move |_, _, cx| panel.update(cx, |this, cx| this.open(id, cx)))212
.relative()217
.into_any_element()213
.flex_none()218
}214
.size(px(AVATAR_SIZE))219
215
.child(avatar)220
fn proposal_row(216
.child(kind_marker(entry, group.clone())),221
&self,217
)222
pending: &PendingProposal,218
.child(223
sidebar: &Sidebar,219
v_flex()224
today: NaiveDate,220
.flex_1()225
offset: chrono::FixedOffset,221
.min_w_0()226
panel: Entity<ActivityPanel>,222
.gap(px(2.))227
) -> AnyElement {223
.child(228
let group = SharedString::from(format!("activity-proposal-group-{}", pending.id));224
div()229
let label = proposal_conversation_label(sidebar, &pending.conversation_id);225
.truncate()230
let proposal_id = pending.id.clone();226
.text_size(px(13.))231
let opened = pending.clone();227
.font_weight(if unread {232
row_frame(RowParts {228
FontWeight::SEMIBOLD233
element_id: format!("activity-proposal-{}", pending.id),229
} else {234
avatar: agent_avatar().into_any_element(),230
FontWeight::NORMAL235
marker: proposal_marker(pending, group.clone()),231
})236
group,232
.text_color(if unread {237
headline: pending.headline(label.as_deref()),233
theme::text()238
detail: pending.detail(),234
} else {239
unread: !pending.seen,235
theme::text_soft()240
time: format::list_time_label(pending.created_at, today, offset),236
})241
mark_read: Rc::new(move |cx: &mut App| agent_api::mark_proposal_seen(&proposal_id, cx)),237
.child(headline(entry, sidebar, resolved_names)),242
})238
)243
.on_click(move |_, _, cx| panel.update(cx, |this, cx| this.open_proposal(&opened, cx)))239
.child(244
.into_any_element()240
div()245
}241
.truncate()246
242
.text_size(px(12.))247
fn open_proposal(&mut self, pending: &PendingProposal, cx: &mut Context<Self>) {243
.text_color(if unread {248
agent_api::mark_proposal_seen(&pending.id, cx);244
theme::text_soft()249
cx.emit(ActivityPanelEvent::Open {245
} else {250
conversation_id: pending.conversation_id.clone(),246
theme::text_muted()251
message_id: pending.jump_message_id().to_owned(),247
})252
});248
.child(detail(entry)),249
),250
)251
.child(252
v_flex()253
.flex_none()254
.items_end()255
.child(256
div()257
.text_size(px(11.))258
.text_color(theme::text_muted())259
.child(format::list_time_label(entry.updated_at, today, offset)),260
)261
.child(status_slot(id, unread, group, activity)),262
)263
.on_click(move |_, _, cx| panel.update(cx, |this, cx| this.open(id, cx)))264
.into_any_element()265
}253
}266
}254
}267
255
268
fn status_slot(256
struct RowParts {269
id: i64,257
element_id: String,270
unread: bool,271
group: SharedString,258
group: SharedString,272
activity: Entity<ActivityCenter>,259
avatar: AnyElement,273
) -> Div {260
marker: Div,261
headline: String,262
detail: String,263
unread: bool,264
time: String,265
mark_read: MarkRead,266
}267
268
type MarkRead = Rc<dyn Fn(&mut App)>;269
270
fn row_frame(parts: RowParts) -> Stateful<Div> {271
let RowParts {272
element_id,273
group,274
avatar,275
marker,276
headline,277
detail,278
unread,279
time,280
mark_read,281
} = parts;282
let selector = element_id.clone();283
h_flex()284
.id(ElementId::Name(element_id.clone().into()))285
.debug_selector(move || selector)286
.group(group.clone())287
.mx(px(6.))288
.px(px(10.))289
.py(px(8.))290
.gap(px(12.))291
.items_start()292
.rounded(px(8.))293
.cursor_pointer()294
.hover(|row| row.bg(theme::row_hover()))295
.child(296
div()297
.relative()298
.flex_none()299
.size(px(AVATAR_SIZE))300
.child(avatar)301
.child(marker),302
)303
.child(304
v_flex()305
.flex_1()306
.min_w_0()307
.gap(px(2.))308
.child(309
div()310
.truncate()311
.text_size(px(13.))312
.font_weight(if unread {313
FontWeight::SEMIBOLD314
} else {315
FontWeight::NORMAL316
})317
.text_color(if unread {318
theme::text()319
} else {320
theme::text_soft()321
})322
.child(headline),323
)324
.child(325
div()326
.truncate()327
.text_size(px(12.))328
.text_color(if unread {329
theme::text_soft()330
} else {331
theme::text_muted()332
})333
.child(detail),334
),335
)336
.child(337
v_flex()338
.flex_none()339
.items_end()340
.child(341
div()342
.text_size(px(11.))343
.text_color(theme::text_muted())344
.child(time),345
)346
.child(status_slot(element_id, unread, group, mark_read)),347
)348
}349
350
fn agent_avatar() -> Div {351
div()352
.size(px(AVATAR_SIZE))353
.flex()354
.items_center()355
.justify_center()356
.rounded_full()357
.bg(theme::accent_soft())358
.child(icon(IconName::Bot, 16., theme::accent_text()))359
}360
361
fn admits_proposal(filter: Filter, pending: &PendingProposal) -> bool {362
match filter {363
Filter::All => true,364
Filter::Mentions => false,365
Filter::Unread => !pending.seen,366
}367
}368
369
fn status_slot(element_id: String, unread: bool, group: SharedString, mark_read: MarkRead) -> Div {274
let slot = div()370
let slot = div()275
.h(px(MARK_READ_SIZE))371
.h(px(MARK_READ_SIZE))276
.flex()372
.flex()@@ -292,7 +388,7 @@ fn status_slot(292
)388
)293
.child(389
.child(294
div()390
div()295
.id(ElementId::Name(format!("activity-mark-read-{id}").into()))391
.id(ElementId::Name(format!("{element_id}-mark-read").into()))296
.absolute()392
.absolute()297
.top_0()393
.top_0()298
.right_0()394
.right_0()@@ -309,13 +405,13 @@ fn status_slot(309
.tooltip(|window, cx| Tooltip::new("Mark as read").build(window, cx))405
.tooltip(|window, cx| Tooltip::new("Mark as read").build(window, cx))310
.on_click(move |_, _, cx| {406
.on_click(move |_, _, cx| {311
cx.stop_propagation();407
cx.stop_propagation();312
activity.update(cx, |activity, cx| activity.mark_read(id, cx));408
mark_read(cx);313
}),409
}),314
)410
)315
}411
}316
412
317
fn kind_marker(entry: &Entry, row_group: SharedString) -> Div {413
fn marker_frame(row_group: SharedString) -> Div {318
let marker = corner_badge(Corner::BottomRight, 4.)414
corner_badge(Corner::BottomRight, 4.)319
.size(px(KIND_MARKER_SIZE))415
.size(px(KIND_MARKER_SIZE))320
.flex()416
.flex()321
.items_center()417
.items_center()@@ -325,7 +421,21 @@ fn kind_marker(entry: &Entry, row_group: SharedString) -> Div {325
.border_color(theme::surface())421
.border_color(theme::surface())326
.group_hover(row_group, |marker| marker.border_color(theme::row_hover()))422
.group_hover(row_group, |marker| marker.border_color(theme::row_hover()))327
.bg(theme::surface_raised())423
.bg(theme::surface_raised())328
.text_size(px(10.));424
.text_size(px(10.))425
}426
427
fn proposal_marker(pending: &PendingProposal, row_group: SharedString) -> Div {428
let marker = marker_frame(row_group);429
match &pending.kind {430
PendingKind::Reply { .. } => {431
marker.child(icon(IconName::MessageCircle, 10., theme::text_muted()))432
}433
PendingKind::Reaction { glyph, .. } => marker.child(glyph.clone()),434
}435
}436
437
fn kind_marker(entry: &Entry, row_group: SharedString) -> Div {438
let marker = marker_frame(row_group);329
match entry.kind {439
match entry.kind {330
Kind::Messages => marker.child(icon(IconName::MessageCircle, 10., theme::text_muted())),440
Kind::Messages => marker.child(icon(IconName::MessageCircle, 10., theme::text_muted())),331
Kind::Mention => marker441
Kind::Mention => marker@@ -374,7 +484,7 @@ fn conversation_label(sidebar: &Sidebar, conversation_id: &str) -> Option<String374
})484
})375
}485
}376
486
377
fn date_header(label: &'static str) -> AnyElement {487
fn group_header(label: &'static str) -> Div {378
div()488
div()379
.h(px(26.))489
.h(px(26.))380
.mt(px(4.))490
.mt(px(4.))@@ -386,7 +496,6 @@ fn date_header(label: &'static str) -> AnyElement {386
.font_weight(FontWeight::SEMIBOLD)496
.font_weight(FontWeight::SEMIBOLD)387
.text_color(theme::text_muted())497
.text_color(theme::text_muted())388
.child(label)498
.child(label)389
.into_any_element()390
}499
}391
500
392
impl Render for ActivityPanel {501
impl Render for ActivityPanel {@@ -414,8 +523,22 @@ impl Render for ActivityPanel {414
.extend(resolve_names(state, &unresolved));523
.extend(resolve_names(state, &unresolved));415
}524
}416
let mut rows: Vec<AnyElement> = Vec::new();525
let mut rows: Vec<AnyElement> = Vec::new();526
let proposal_rows: Vec<AnyElement> = agent_api::pending_proposals(cx)527
.iter()528
.filter(|pending| admits_proposal(self.filter, pending))529
.map(|pending| self.proposal_row(pending, &state.sidebar, today, offset, panel.clone()))530
.collect();531
if !proposal_rows.is_empty() {532
rows.push(533
v_flex()534
.debug_selector(|| ACTIVITY_PROPOSALS_TAG.into())535
.child(group_header(PROPOSALS_LABEL))536
.children(proposal_rows)537
.into_any_element(),538
);539
}417
for section in sections {540
for section in sections {418
rows.push(date_header(section.bucket.label()));541
rows.push(group_header(section.bucket.label()).into_any_element());419
for entry in section.entries {542
for entry in section.entries {420
rows.push(self.row(543
rows.push(self.row(421
entry,544
entry,@@ -219,7 +219,8 @@ fn badge(badge: RailBadge) -> Option<Div> {
219
219
impl Render for RailView {
220
220
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
221
221
let active = self.sidebar.read(cx).tab();
222
let activity_unread = self.activity.read(cx).feed().unread_count();
222
let activity_unread = self.activity.read(cx).feed().unread_count()
223
+ crate::agent_api::unseen_proposal_count(cx);
223
224
let (unread_chats, channel_dot) = {
224
225
let state = self.state.read(cx);
225
226
(
@@ -219,7 +219,8 @@ fn badge(badge: RailBadge) -> Option<Div> {219
impl Render for RailView {219
impl Render for RailView {220
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {220
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {221
let active = self.sidebar.read(cx).tab();221
let active = self.sidebar.read(cx).tab();222
let activity_unread = self.activity.read(cx).feed().unread_count();222
let activity_unread = self.activity.read(cx).feed().unread_count()223
+ crate::agent_api::unseen_proposal_count(cx);223
let (unread_chats, channel_dot) = {224
let (unread_chats, channel_dot) = {224
let state = self.state.read(cx);225
let state = self.state.read(cx);225
(226
(