Skip to repository content188 lines · 6.6 KB · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T06:49:25.797Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
collab_notification.rs
1use gpui::{AnyElement, SharedUri, prelude::*};
2use smallvec::SmallVec;
3
4use crate::{Avatar, prelude::*};
5
6#[derive(IntoElement, RegisterComponent)]
7pub struct CollabNotification {
8 avatar_uri: SharedUri,
9 accept_button: Button,
10 dismiss_button: Button,
11 children: SmallVec<[AnyElement; 2]>,
12}
13
14impl CollabNotification {
15 pub fn new(
16 avatar_uri: impl Into<SharedUri>,
17 accept_button: Button,
18 dismiss_button: Button,
19 ) -> Self {
20 Self {
21 avatar_uri: avatar_uri.into(),
22 accept_button,
23 dismiss_button,
24 children: SmallVec::new(),
25 }
26 }
27}
28
29impl ParentElement for CollabNotification {
30 fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
31 self.children.extend(elements)
32 }
33}
34
35impl RenderOnce for CollabNotification {
36 fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
37 h_flex()
38 .p_2()
39 .size_full()
40 .text_ui(cx)
41 .justify_between()
42 .overflow_hidden()
43 .elevation_3(cx)
44 .gap_1()
45 .child(
46 h_flex()
47 .min_w_0()
48 .gap_4()
49 .child(Avatar::new(self.avatar_uri).size(px(40.)))
50 .child(v_flex().truncate().children(self.children)),
51 )
52 .child(
53 v_flex()
54 .items_center()
55 .child(self.accept_button)
56 .child(self.dismiss_button),
57 )
58 }
59}
60
61impl Component for CollabNotification {
62 fn scope() -> ComponentScope {
63 ComponentScope::Collaboration
64 }
65
66 fn description() -> &'static str {
67 "A toast-style notification surface for collaboration events, \
68 such as incoming calls or shared project invites, with an accept and dismiss action."
69 }
70
71 fn preview(_window: &mut Window, _cx: &mut App) -> AnyElement {
72 let avatar = "https://avatars.githubusercontent.com/u/67129314?v=4";
73 let container = || div().h(px(72.)).w(px(400.)); // Size of the actual notification window
74
75 let call_examples = vec![
76 single_example(
77 "Incoming Call",
78 container()
79 .child(
80 CollabNotification::new(
81 avatar,
82 Button::new("accept", "Accept"),
83 Button::new("decline", "Decline"),
84 )
85 .child(Label::new("the user is inviting you to a call")),
86 )
87 .into_any_element(),
88 ),
89 single_example(
90 "Screen Share Request",
91 container()
92 .child(
93 CollabNotification::new(
94 avatar,
95 Button::new("accept", "View"),
96 Button::new("decline", "Ignore"),
97 )
98 .child(Label::new("the user is sharing their screen")),
99 )
100 .into_any_element(),
101 ),
102 single_example(
103 "Project Shared",
104 container()
105 .child(
106 CollabNotification::new(
107 avatar,
108 Button::new("accept", "Open"),
109 Button::new("decline", "Dismiss"),
110 )
111 .child(Label::new("the user is sharing a project"))
112 .child(Label::new("zed").color(Color::Muted)),
113 )
114 .into_any_element(),
115 ),
116 single_example(
117 "Overflowing Content",
118 container()
119 .child(
120 CollabNotification::new(
121 avatar,
122 Button::new("accept", "Accept"),
123 Button::new("decline", "Decline"),
124 )
125 .child(Label::new(
126 "a_very_long_username_that_might_overflow is sharing a project in Omega:",
127 ))
128 .child(
129 Label::new("omega-cloud, omega, edit-prediction-bench, openagents.com")
130 .color(Color::Muted),
131 ),
132 )
133 .into_any_element(),
134 ),
135 ];
136
137 let toast_examples = vec![
138 single_example(
139 "Contact Request",
140 container()
141 .child(
142 CollabNotification::new(
143 avatar,
144 Button::new("accept", "Accept"),
145 Button::new("decline", "Decline"),
146 )
147 .child(Label::new("maxbrunsfeld wants to add you as a contact")),
148 )
149 .into_any_element(),
150 ),
151 single_example(
152 "Contact Request Accepted",
153 container()
154 .child(
155 CollabNotification::new(
156 avatar,
157 Button::new("dismiss", "Dismiss"),
158 Button::new("close", "Close"),
159 )
160 .child(Label::new("maxbrunsfeld accepted your contact request")),
161 )
162 .into_any_element(),
163 ),
164 single_example(
165 "Channel Invitation",
166 container()
167 .child(
168 CollabNotification::new(
169 avatar,
170 Button::new("accept", "Accept"),
171 Button::new("decline", "Decline"),
172 )
173 .child(Label::new(
174 "maxbrunsfeld invited you to join the #omega channel",
175 )),
176 )
177 .into_any_element(),
178 ),
179 ];
180
181 v_flex()
182 .gap_6()
183 .child(example_group_with_title("Calls & Projects", call_examples).vertical())
184 .child(example_group_with_title("Contact & Channel Toasts", toast_examples).vertical())
185 .into_any_element()
186 }
187}
188