🐛 fix(orgs): no calendar in a guest org (#77)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@@ -15,6 +15,7 @@ use super::image_scale::downscale;
15
15
use crate::backend::Engine;
16
16
17
17
const IMAGE_WAIT: Duration = Duration::from_secs(10);
18
const GUEST_ORG_NO_CALENDAR: &str = "the calendar is not available while a guest org is open";
18
19
19
20
pub struct AppSource {
20
21
store: Arc<Store>,
@@ -36,6 +37,15 @@ impl AppSource {
36
37
fn engine(&self) -> Result<&Arc<Engine>, SourceError> {
37
38
self.engine.get().ok_or(SourceError::NotConnected)
38
39
}
40
41
/// The Outlook calendar of the open org. A guest has no mailbox there, so a guest org has none.
42
fn calendar_api(&self) -> Result<Calendar, SourceError> {
43
let session = self.engine()?.remote().session();
44
if session.tenant().is_some() {
45
return Err(SourceError::Failed(GUEST_ORG_NO_CALENDAR.to_owned()));
46
}
47
Ok(Calendar::new(session))
48
}
39
49
}
40
50
41
51
impl TeamsSource for AppSource {
@@ -152,8 +162,8 @@ impl TeamsSource for AppSource {
152
162
153
163
fn calendar(&self, start: DateTime<Utc>, end: DateTime<Utc>) -> SourceFuture<'_, Vec<Meeting>> {
154
164
Box::pin(async move {
155
let engine = self.engine()?;
156
let events = Calendar::new(engine.remote().session())
165
let events = self
166
.calendar_api()?
157
167
.calendar_view(start, end)
158
168
.await
159
169
.map_err(|error| SourceError::Failed(error.to_string()))?;
@@ -180,8 +190,8 @@ impl TeamsSource for AppSource {
180
190
end: DateTime<Utc>,
181
191
) -> SourceFuture<'_, Vec<PersonAvailability>> {
182
192
Box::pin(async move {
183
let engine = self.engine()?;
184
let schedules = Calendar::new(engine.remote().session())
193
let schedules = self
194
.calendar_api()?
185
195
.schedules(&emails, start, end)
186
196
.await
187
197
.map_err(|error| SourceError::Failed(error.to_string()))?;
@@ -206,13 +216,14 @@ impl TeamsSource for AppSource {
206
216
207
217
fn create_meeting(&self, draft: MeetingDraft) -> SourceFuture<'_, CreatedMeeting> {
208
218
Box::pin(async move {
219
let calendar = self.calendar_api()?;
209
220
let engine = self.engine()?;
210
221
let mut names = Vec::with_capacity(draft.attendees.len());
211
222
for address in &draft.attendees {
212
223
let users = engine.search_people(address).await.unwrap_or_default();
213
224
names.push(users.into_iter().find_map(|user| user.display_name));
214
225
}
215
let created = Calendar::new(engine.remote().session())
226
let created = calendar
216
227
.create_event(&new_event(draft, names))
217
228
.await
218
229
.map_err(|error| SourceError::Failed(error.to_string()))?;
@@ -15,6 +15,7 @@ use super::image_scale::downscale;15
use crate::backend::Engine;15
use crate::backend::Engine;16
16
17
const IMAGE_WAIT: Duration = Duration::from_secs(10);17
const IMAGE_WAIT: Duration = Duration::from_secs(10);18
const GUEST_ORG_NO_CALENDAR: &str = "the calendar is not available while a guest org is open";18
19
19
pub struct AppSource {20
pub struct AppSource {20
store: Arc<Store>,21
store: Arc<Store>,@@ -36,6 +37,15 @@ impl AppSource {36
fn engine(&self) -> Result<&Arc<Engine>, SourceError> {37
fn engine(&self) -> Result<&Arc<Engine>, SourceError> {37
self.engine.get().ok_or(SourceError::NotConnected)38
self.engine.get().ok_or(SourceError::NotConnected)38
}39
}40
41
/// The Outlook calendar of the open org. A guest has no mailbox there, so a guest org has none.42
fn calendar_api(&self) -> Result<Calendar, SourceError> {43
let session = self.engine()?.remote().session();44
if session.tenant().is_some() {45
return Err(SourceError::Failed(GUEST_ORG_NO_CALENDAR.to_owned()));46
}47
Ok(Calendar::new(session))48
}39
}49
}40
50
41
impl TeamsSource for AppSource {51
impl TeamsSource for AppSource {@@ -152,8 +162,8 @@ impl TeamsSource for AppSource {152
162
153
fn calendar(&self, start: DateTime<Utc>, end: DateTime<Utc>) -> SourceFuture<'_, Vec<Meeting>> {163
fn calendar(&self, start: DateTime<Utc>, end: DateTime<Utc>) -> SourceFuture<'_, Vec<Meeting>> {154
Box::pin(async move {164
Box::pin(async move {155
let engine = self.engine()?;165
let events = self156
let events = Calendar::new(engine.remote().session())166
.calendar_api()?157
.calendar_view(start, end)167
.calendar_view(start, end)158
.await168
.await159
.map_err(|error| SourceError::Failed(error.to_string()))?;169
.map_err(|error| SourceError::Failed(error.to_string()))?;@@ -180,8 +190,8 @@ impl TeamsSource for AppSource {180
end: DateTime<Utc>,190
end: DateTime<Utc>,181
) -> SourceFuture<'_, Vec<PersonAvailability>> {191
) -> SourceFuture<'_, Vec<PersonAvailability>> {182
Box::pin(async move {192
Box::pin(async move {183
let engine = self.engine()?;193
let schedules = self184
let schedules = Calendar::new(engine.remote().session())194
.calendar_api()?185
.schedules(&emails, start, end)195
.schedules(&emails, start, end)186
.await196
.await187
.map_err(|error| SourceError::Failed(error.to_string()))?;197
.map_err(|error| SourceError::Failed(error.to_string()))?;@@ -206,13 +216,14 @@ impl TeamsSource for AppSource {206
216
207
fn create_meeting(&self, draft: MeetingDraft) -> SourceFuture<'_, CreatedMeeting> {217
fn create_meeting(&self, draft: MeetingDraft) -> SourceFuture<'_, CreatedMeeting> {208
Box::pin(async move {218
Box::pin(async move {219
let calendar = self.calendar_api()?;209
let engine = self.engine()?;220
let engine = self.engine()?;210
let mut names = Vec::with_capacity(draft.attendees.len());221
let mut names = Vec::with_capacity(draft.attendees.len());211
for address in &draft.attendees {222
for address in &draft.attendees {212
let users = engine.search_people(address).await.unwrap_or_default();223
let users = engine.search_people(address).await.unwrap_or_default();213
names.push(users.into_iter().find_map(|user| user.display_name));224
names.push(users.into_iter().find_map(|user| user.display_name));214
}225
}215
let created = Calendar::new(engine.remote().session())226
let created = calendar216
.create_event(&new_event(draft, names))227
.create_event(&new_event(draft, names))217
.await228
.await218
.map_err(|error| SourceError::Failed(error.to_string()))?;229
.map_err(|error| SourceError::Failed(error.to_string()))?;@@ -191,7 +191,7 @@ async fn supervise(
191
191
// Calls stay on the home tenant's registration, like rings for the home org while a guest org is open.
192
192
let session = match &guest_tenant {
193
193
Some(tenant) => home.in_tenant(tenant),
194
None => home,
194
None => home.clone(),
195
195
};
196
196
let build = || {
197
197
SyncEngine::new(Graph::new(session.clone()), store.clone())
@@ -227,11 +227,8 @@ async fn supervise(
227
227
link,
228
228
live_retry,
229
229
));
230
tokio::spawn(calendar_loop(
231
session.clone(),
232
store.clone(),
233
events.clone(),
234
));
230
// A guest has no mailbox in the org it visits, so Outlook is read from the home tenant.
231
tokio::spawn(calendar_loop(home, store.clone(), events.clone()));
235
232
tokio::spawn(pins_loop(session, events.clone()));
236
233
tokio::spawn(presence_resubscribe_loop(engine.clone()));
237
234
refresh_loop(engine, events, nudges).await;
@@ -191,7 +191,7 @@ async fn supervise(191
// Calls stay on the home tenant's registration, like rings for the home org while a guest org is open.191
// Calls stay on the home tenant's registration, like rings for the home org while a guest org is open.192
let session = match &guest_tenant {192
let session = match &guest_tenant {193
Some(tenant) => home.in_tenant(tenant),193
Some(tenant) => home.in_tenant(tenant),194
None => home,194
None => home.clone(),195
};195
};196
let build = || {196
let build = || {197
SyncEngine::new(Graph::new(session.clone()), store.clone())197
SyncEngine::new(Graph::new(session.clone()), store.clone())@@ -227,11 +227,8 @@ async fn supervise(227
link,227
link,228
live_retry,228
live_retry,229
));229
));230
tokio::spawn(calendar_loop(230
// A guest has no mailbox in the org it visits, so Outlook is read from the home tenant.231
session.clone(),231
tokio::spawn(calendar_loop(home, store.clone(), events.clone()));232
store.clone(),233
events.clone(),234
));235
tokio::spawn(pins_loop(session, events.clone()));232
tokio::spawn(pins_loop(session, events.clone()));236
tokio::spawn(presence_resubscribe_loop(engine.clone()));233
tokio::spawn(presence_resubscribe_loop(engine.clone()));237
refresh_loop(engine, events, nudges).await;234
refresh_loop(engine, events, nudges).await;@@ -84,6 +84,9 @@ impl AppState {
84
84
}
85
85
86
86
pub fn open_calendar(&mut self, cx: &mut Context<Self>) {
87
if !self.calendar_available() {
88
return;
89
}
87
90
self.calendar_week.visible = true;
88
91
self.calendar_week.start = Some(self.calendar_start());
89
92
self.request_calendar_scroll_to_now(cx);
@@ -204,6 +207,9 @@ impl AppState {
204
207
}
205
208
206
209
pub(crate) fn load_calendar_week(&mut self, cx: &mut Context<Self>) {
210
if !self.calendar_available() {
211
return;
212
}
207
213
let start = self.calendar_start();
208
214
let offset = Local::now().offset().fix();
209
215
let (from, to) = dates_range(&self.calendar_dates(), offset);
@@ -607,6 +613,28 @@ mod tests {
607
613
});
608
614
}
609
615
616
#[gpui_kit::test]
617
fn a_guest_org_neither_opens_nor_loads_the_calendar(cx: &mut TestAppContext) {
618
cx.update(gpui_kit::init);
619
let store = Arc::new(Store::open_in_memory().unwrap());
620
let app = cx.update(|cx| cx.new(|_| AppState::new(store, Mode::default())));
621
cx.update(|cx| {
622
app.update(cx, |state, cx| {
623
let guest = "11111111-2222-3333-4444-555555555555";
624
state.orgs.active = Some(guest.into());
625
state.orgs.list.push(app_base::orgs::Org {
626
id: guest.into(),
627
name: "Contoso".into(),
628
guest: true,
629
});
630
state.open_calendar(cx);
631
state.retry_calendar_week(cx);
632
assert!(!state.calendar_week.visible);
633
assert!(!state.calendar_week.take_pending());
634
})
635
});
636
}
637
610
638
#[gpui_kit::test]
611
639
fn a_poll_reloads_the_grid_only_while_the_calendar_is_shown(cx: &mut TestAppContext) {
612
640
cx.update(gpui_kit::init);
@@ -84,6 +84,9 @@ impl AppState {84
}84
}85
85
86
pub fn open_calendar(&mut self, cx: &mut Context<Self>) {86
pub fn open_calendar(&mut self, cx: &mut Context<Self>) {87
if !self.calendar_available() {88
return;89
}87
self.calendar_week.visible = true;90
self.calendar_week.visible = true;88
self.calendar_week.start = Some(self.calendar_start());91
self.calendar_week.start = Some(self.calendar_start());89
self.request_calendar_scroll_to_now(cx);92
self.request_calendar_scroll_to_now(cx);@@ -204,6 +207,9 @@ impl AppState {204
}207
}205
208
206
pub(crate) fn load_calendar_week(&mut self, cx: &mut Context<Self>) {209
pub(crate) fn load_calendar_week(&mut self, cx: &mut Context<Self>) {210
if !self.calendar_available() {211
return;212
}207
let start = self.calendar_start();213
let start = self.calendar_start();208
let offset = Local::now().offset().fix();214
let offset = Local::now().offset().fix();209
let (from, to) = dates_range(&self.calendar_dates(), offset);215
let (from, to) = dates_range(&self.calendar_dates(), offset);@@ -607,6 +613,28 @@ mod tests {607
});613
});608
}614
}609
615
616
#[gpui_kit::test]617
fn a_guest_org_neither_opens_nor_loads_the_calendar(cx: &mut TestAppContext) {618
cx.update(gpui_kit::init);619
let store = Arc::new(Store::open_in_memory().unwrap());620
let app = cx.update(|cx| cx.new(|_| AppState::new(store, Mode::default())));621
cx.update(|cx| {622
app.update(cx, |state, cx| {623
let guest = "11111111-2222-3333-4444-555555555555";624
state.orgs.active = Some(guest.into());625
state.orgs.list.push(app_base::orgs::Org {626
id: guest.into(),627
name: "Contoso".into(),628
guest: true,629
});630
state.open_calendar(cx);631
state.retry_calendar_week(cx);632
assert!(!state.calendar_week.visible);633
assert!(!state.calendar_week.take_pending());634
})635
});636
}637
610
#[gpui_kit::test]638
#[gpui_kit::test]611
fn a_poll_reloads_the_grid_only_while_the_calendar_is_shown(cx: &mut TestAppContext) {639
fn a_poll_reloads_the_grid_only_while_the_calendar_is_shown(cx: &mut TestAppContext) {612
cx.update(gpui_kit::init);640
cx.update(gpui_kit::init);@@ -12,6 +12,11 @@ impl AppState {
12
12
self.save_orgs(&self.orgs);
13
13
}
14
14
15
/// A guest org has no calendar for the account, like in Teams.
16
pub fn calendar_available(&self) -> bool {
17
self.orgs.active_guest().is_none()
18
}
19
15
20
/// Orgs to offer in the account menu; a single org needs no switcher, like Teams.
16
21
pub fn switchable_orgs(&self) -> &[Org] {
17
22
if self.orgs.list.len() > 1 {
@@ -12,6 +12,11 @@ impl AppState {12
self.save_orgs(&self.orgs);12
self.save_orgs(&self.orgs);13
}13
}14
14
15
/// A guest org has no calendar for the account, like in Teams.16
pub fn calendar_available(&self) -> bool {17
self.orgs.active_guest().is_none()18
}19
15
/// Orgs to offer in the account menu; a single org needs no switcher, like Teams.20
/// Orgs to offer in the account menu; a single org needs no switcher, like Teams.16
pub fn switchable_orgs(&self) -> &[Org] {21
pub fn switchable_orgs(&self) -> &[Org] {17
if self.orgs.list.len() > 1 {22
if self.orgs.list.len() > 1 {@@ -46,6 +46,7 @@ fn rail_items(
46
46
activity_unread: usize,
47
47
unread_chats: usize,
48
48
channel_dot: bool,
49
calendar: bool,
49
50
agents_running: Option<usize>,
50
51
) -> Vec<RailItem> {
51
52
let mut items = vec![
@@ -89,6 +90,9 @@ fn rail_items(
89
90
badge: RailBadge::None,
90
91
},
91
92
];
93
if !calendar {
94
items.retain(|item| item.tab != SidebarTab::Calendar);
95
}
92
96
if let Some(running) = agents_running {
93
97
items.push(RailItem {
94
98
tab: SidebarTab::Agents,
@@ -226,17 +230,19 @@ impl Render for RailView {
226
230
let active = self.sidebar.read(cx).tab();
227
231
let activity_unread = self.activity.read(cx).feed().bell_count()
228
232
+ crate::agent_api::unseen_proposal_count(cx);
229
let (unread_chats, channel_dot) = {
233
let (unread_chats, channel_dot, calendar) = {
230
234
let state = self.state.read(cx);
231
235
(
232
236
unread_chat_count(&state.sidebar.chats),
233
237
any_unread_channel(&state.sidebar),
238
state.calendar_available(),
234
239
)
235
240
};
236
241
let items = rail_items(
237
242
activity_unread,
238
243
unread_chats as usize,
239
244
channel_dot,
245
calendar,
240
246
self.agents_running(cx),
241
247
);
242
248
v_flex()
@@ -262,7 +268,7 @@ mod tests {
262
268
#[test]
263
269
fn items_follow_the_spec_order() {
264
270
apply_locale("en");
265
let tabs: Vec<SidebarTab> = rail_items(0, 0, false, None)
271
let tabs: Vec<SidebarTab> = rail_items(0, 0, false, true, None)
266
272
.iter()
267
273
.map(|item| item.tab)
268
274
.collect();
@@ -278,28 +284,42 @@ mod tests {
278
284
);
279
285
}
280
286
287
#[test]
288
fn calendar_is_left_out_when_unavailable() {
289
apply_locale("en");
290
let tabs: Vec<SidebarTab> = rail_items(0, 0, false, false, None)
291
.iter()
292
.map(|item| item.tab)
293
.collect();
294
assert!(!tabs.contains(&SidebarTab::Calendar));
295
assert_eq!(tabs.len(), 4);
296
}
297
281
298
#[test]
282
299
fn agents_comes_last_and_only_when_actions_exist() {
283
300
apply_locale("en");
284
assert_eq!(rail_items(0, 0, false, None).len(), 5);
285
let with_agents = rail_items(0, 0, false, Some(2));
301
assert_eq!(rail_items(0, 0, false, true, None).len(), 5);
302
let with_agents = rail_items(0, 0, false, true, Some(2));
286
303
assert_eq!(with_agents.len(), 6);
287
304
assert_eq!(with_agents[5].tab, SidebarTab::Agents);
288
305
assert_eq!(with_agents[5].label, tr("rail.agents"));
289
306
assert_eq!(with_agents[5].badge, RailBadge::Count(2));
290
assert_eq!(rail_items(0, 0, false, Some(0))[5].badge, RailBadge::None);
307
assert_eq!(
308
rail_items(0, 0, false, true, Some(0))[5].badge,
309
RailBadge::None
310
);
291
311
}
292
312
293
313
#[test]
294
314
fn badges_follow_the_unread_inputs() {
295
315
apply_locale("en");
296
let items = rail_items(3, 5, true, None);
316
let items = rail_items(3, 5, true, true, None);
297
317
assert_eq!(items[0].badge, RailBadge::Count(3));
298
318
assert_eq!(items[1].badge, RailBadge::Count(5));
299
319
assert_eq!(items[2].badge, RailBadge::Dot);
300
320
assert_eq!(items[3].badge, RailBadge::None);
301
321
assert_eq!(items[4].badge, RailBadge::None);
302
let quiet = rail_items(0, 0, false, None);
322
let quiet = rail_items(0, 0, false, true, None);
303
323
assert!(quiet.iter().all(|item| item.badge == RailBadge::None));
304
324
assert_eq!(count_badge_for(usize::MAX), RailBadge::Count(u32::MAX));
305
325
}
@@ -308,7 +328,7 @@ mod tests {
308
328
#[test]
309
329
fn every_item_shows_its_shortcut_in_the_tooltip() {
310
330
apply_locale("en");
311
let items = rail_items(0, 0, false, None);
331
let items = rail_items(0, 0, false, true, None);
312
332
assert_eq!(tooltip_text(&items[0]), "Activity (Ctrl+1)");
313
333
assert!(items.iter().all(|item| tooltip_text(item).ends_with(')')));
314
334
}
@@ -46,6 +46,7 @@ fn rail_items(46
activity_unread: usize,46
activity_unread: usize,47
unread_chats: usize,47
unread_chats: usize,48
channel_dot: bool,48
channel_dot: bool,49
calendar: bool,49
agents_running: Option<usize>,50
agents_running: Option<usize>,50
) -> Vec<RailItem> {51
) -> Vec<RailItem> {51
let mut items = vec![52
let mut items = vec![@@ -89,6 +90,9 @@ fn rail_items(89
badge: RailBadge::None,90
badge: RailBadge::None,90
},91
},91
];92
];93
if !calendar {94
items.retain(|item| item.tab != SidebarTab::Calendar);95
}92
if let Some(running) = agents_running {96
if let Some(running) = agents_running {93
items.push(RailItem {97
items.push(RailItem {94
tab: SidebarTab::Agents,98
tab: SidebarTab::Agents,@@ -226,17 +230,19 @@ impl Render for RailView {226
let active = self.sidebar.read(cx).tab();230
let active = self.sidebar.read(cx).tab();227
let activity_unread = self.activity.read(cx).feed().bell_count()231
let activity_unread = self.activity.read(cx).feed().bell_count()228
+ crate::agent_api::unseen_proposal_count(cx);232
+ crate::agent_api::unseen_proposal_count(cx);229
let (unread_chats, channel_dot) = {233
let (unread_chats, channel_dot, calendar) = {230
let state = self.state.read(cx);234
let state = self.state.read(cx);231
(235
(232
unread_chat_count(&state.sidebar.chats),236
unread_chat_count(&state.sidebar.chats),233
any_unread_channel(&state.sidebar),237
any_unread_channel(&state.sidebar),238
state.calendar_available(),234
)239
)235
};240
};236
let items = rail_items(241
let items = rail_items(237
activity_unread,242
activity_unread,238
unread_chats as usize,243
unread_chats as usize,239
channel_dot,244
channel_dot,245
calendar,240
self.agents_running(cx),246
self.agents_running(cx),241
);247
);242
v_flex()248
v_flex()@@ -262,7 +268,7 @@ mod tests {262
#[test]268
#[test]263
fn items_follow_the_spec_order() {269
fn items_follow_the_spec_order() {264
apply_locale("en");270
apply_locale("en");265
let tabs: Vec<SidebarTab> = rail_items(0, 0, false, None)271
let tabs: Vec<SidebarTab> = rail_items(0, 0, false, true, None)266
.iter()272
.iter()267
.map(|item| item.tab)273
.map(|item| item.tab)268
.collect();274
.collect();@@ -278,28 +284,42 @@ mod tests {278
);284
);279
}285
}280
286
287
#[test]288
fn calendar_is_left_out_when_unavailable() {289
apply_locale("en");290
let tabs: Vec<SidebarTab> = rail_items(0, 0, false, false, None)291
.iter()292
.map(|item| item.tab)293
.collect();294
assert!(!tabs.contains(&SidebarTab::Calendar));295
assert_eq!(tabs.len(), 4);296
}297
281
#[test]298
#[test]282
fn agents_comes_last_and_only_when_actions_exist() {299
fn agents_comes_last_and_only_when_actions_exist() {283
apply_locale("en");300
apply_locale("en");284
assert_eq!(rail_items(0, 0, false, None).len(), 5);301
assert_eq!(rail_items(0, 0, false, true, None).len(), 5);285
let with_agents = rail_items(0, 0, false, Some(2));302
let with_agents = rail_items(0, 0, false, true, Some(2));286
assert_eq!(with_agents.len(), 6);303
assert_eq!(with_agents.len(), 6);287
assert_eq!(with_agents[5].tab, SidebarTab::Agents);304
assert_eq!(with_agents[5].tab, SidebarTab::Agents);288
assert_eq!(with_agents[5].label, tr("rail.agents"));305
assert_eq!(with_agents[5].label, tr("rail.agents"));289
assert_eq!(with_agents[5].badge, RailBadge::Count(2));306
assert_eq!(with_agents[5].badge, RailBadge::Count(2));290
assert_eq!(rail_items(0, 0, false, Some(0))[5].badge, RailBadge::None);307
assert_eq!(308
rail_items(0, 0, false, true, Some(0))[5].badge,309
RailBadge::None310
);291
}311
}292
312
293
#[test]313
#[test]294
fn badges_follow_the_unread_inputs() {314
fn badges_follow_the_unread_inputs() {295
apply_locale("en");315
apply_locale("en");296
let items = rail_items(3, 5, true, None);316
let items = rail_items(3, 5, true, true, None);297
assert_eq!(items[0].badge, RailBadge::Count(3));317
assert_eq!(items[0].badge, RailBadge::Count(3));298
assert_eq!(items[1].badge, RailBadge::Count(5));318
assert_eq!(items[1].badge, RailBadge::Count(5));299
assert_eq!(items[2].badge, RailBadge::Dot);319
assert_eq!(items[2].badge, RailBadge::Dot);300
assert_eq!(items[3].badge, RailBadge::None);320
assert_eq!(items[3].badge, RailBadge::None);301
assert_eq!(items[4].badge, RailBadge::None);321
assert_eq!(items[4].badge, RailBadge::None);302
let quiet = rail_items(0, 0, false, None);322
let quiet = rail_items(0, 0, false, true, None);303
assert!(quiet.iter().all(|item| item.badge == RailBadge::None));323
assert!(quiet.iter().all(|item| item.badge == RailBadge::None));304
assert_eq!(count_badge_for(usize::MAX), RailBadge::Count(u32::MAX));324
assert_eq!(count_badge_for(usize::MAX), RailBadge::Count(u32::MAX));305
}325
}@@ -308,7 +328,7 @@ mod tests {308
#[test]328
#[test]309
fn every_item_shows_its_shortcut_in_the_tooltip() {329
fn every_item_shows_its_shortcut_in_the_tooltip() {310
apply_locale("en");330
apply_locale("en");311
let items = rail_items(0, 0, false, None);331
let items = rail_items(0, 0, false, true, None);312
assert_eq!(tooltip_text(&items[0]), "Activity (Ctrl+1)");332
assert_eq!(tooltip_text(&items[0]), "Activity (Ctrl+1)");313
assert!(items.iter().all(|item| tooltip_text(item).ends_with(')')));333
assert!(items.iter().all(|item| tooltip_text(item).ends_with(')')));314
}334
}@@ -527,6 +527,9 @@ impl SidebarView {
527
527
if tab == SidebarTab::Agents && !crate::agents::agents_enabled(cx) {
528
528
return;
529
529
}
530
if tab == SidebarTab::Calendar && !self.state.read(cx).calendar_available() {
531
return;
532
}
530
533
let changed = self.tab != tab;
531
534
self.tab = tab;
532
535
if changed {
@@ -527,6 +527,9 @@ impl SidebarView {527
if tab == SidebarTab::Agents && !crate::agents::agents_enabled(cx) {527
if tab == SidebarTab::Agents && !crate::agents::agents_enabled(cx) {528
return;528
return;529
}529
}530
if tab == SidebarTab::Calendar && !self.state.read(cx).calendar_available() {531
return;532
}530
let changed = self.tab != tab;533
let changed = self.tab != tab;531
self.tab = tab;534
self.tab = tab;532
if changed {535
if changed {