feat(calendar): Teams spacing and free, tentative, busy looks
- 120 px per hour with quarter-hour lines, 24h or 12h hour labels per locale - day header with short weekday and a today mark, accent now line with dot - read showAs: busy gets a solid status bar, tentative a hatched one, free none and a darker fill - organizer on the second line, titles wrap to two lines like Teams Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -167,6 +167,7 @@ pub fn demo_events(now: DateTime<Utc>) -> Vec<CalendarEvent> {
167
167
organizer_name: Some(organizer.to_owned()),
168
168
organizer_address: None,
169
169
ical_uid: None,
170
show_as: Default::default(),
170
171
response,
171
172
};
172
173
vec![
@@ -242,6 +243,7 @@ mod tests {
242
243
organizer_name: Some("Mara".into()),
243
244
organizer_address: None,
244
245
ical_uid: None,
246
show_as: Default::default(),
245
247
response: ResponseType::Accepted,
246
248
}
247
249
}
@@ -167,6 +167,7 @@ pub fn demo_events(now: DateTime<Utc>) -> Vec<CalendarEvent> {167
organizer_name: Some(organizer.to_owned()),167
organizer_name: Some(organizer.to_owned()),168
organizer_address: None,168
organizer_address: None,169
ical_uid: None,169
ical_uid: None,170
show_as: Default::default(),170
response,171
response,171
};172
};172
vec![173
vec![@@ -242,6 +243,7 @@ mod tests {242
organizer_name: Some("Mara".into()),243
organizer_name: Some("Mara".into()),243
organizer_address: None,244
organizer_address: None,244
ical_uid: None,245
ical_uid: None,246
show_as: Default::default(),245
response: ResponseType::Accepted,247
response: ResponseType::Accepted,246
}248
}247
}249
}@@ -1,4 +1,4 @@
1
use chatsvc::{CalendarEvent, ResponseType};
1
use chatsvc::{CalendarEvent, ResponseType, ShowAs};
2
2
use chrono::{DateTime, Datelike, Duration, FixedOffset, NaiveDate, Utc, Weekday};
3
3
4
4
pub const WORK_WEEK_DAYS: i64 = 5;
@@ -186,7 +186,25 @@ pub fn range_label(start: NaiveDate, days: i64) -> String {
186
186
}
187
187
}
188
188
189
pub fn hour_label(hour: u32) -> String {
189
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
190
pub enum EventLook {
191
Busy,
192
Free,
193
Tentative,
194
}
195
196
pub fn event_look(event: &CalendarEvent) -> EventLook {
197
match event.show_as {
198
ShowAs::Free => EventLook::Free,
199
ShowAs::Tentative => EventLook::Tentative,
200
ShowAs::Busy | ShowAs::OutOfOffice | ShowAs::WorkingElsewhere => EventLook::Busy,
201
}
202
}
203
204
pub fn hour_label(hour: u32, twelve_hour: bool) -> String {
205
if !twelve_hour {
206
return hour.to_string();
207
}
190
208
match hour {
191
209
0 => "12 AM".to_owned(),
192
210
12 => "12 PM".to_owned(),
@@ -218,6 +236,7 @@ mod tests {
218
236
organizer_name: None,
219
237
organizer_address: None,
220
238
ical_uid: None,
239
show_as: Default::default(),
221
240
response: ResponseType::Accepted,
222
241
}
223
242
}
@@ -305,7 +324,23 @@ mod tests {
305
324
range_label(NaiveDate::from_ymd_opt(2026, 11, 9).unwrap(), 5),
306
325
"November 2026"
307
326
);
308
assert_eq!(hour_label(0), "12 AM");
309
assert_eq!(hour_label(13), "1 PM");
327
assert_eq!(hour_label(0, true), "12 AM");
328
assert_eq!(hour_label(13, true), "1 PM");
329
assert_eq!(hour_label(13, false), "13");
330
}
331
332
#[test]
333
fn free_and_tentative_meetings_look_like_teams() {
334
let mut following = event(9, 0, 30);
335
following.show_as = ShowAs::Free;
336
following.response = ResponseType::Tentative;
337
let mut tentative = event(9, 0, 30);
338
tentative.show_as = ShowAs::Tentative;
339
let mut away = event(9, 0, 30);
340
away.show_as = ShowAs::OutOfOffice;
341
assert_eq!(event_look(&following), EventLook::Free);
342
assert_eq!(event_look(&tentative), EventLook::Tentative);
343
assert_eq!(event_look(&away), EventLook::Busy);
344
assert_eq!(event_look(&event(9, 0, 30)), EventLook::Busy);
310
345
}
311
346
}
@@ -1,4 +1,4 @@1
use chatsvc::{CalendarEvent, ResponseType};1
use chatsvc::{CalendarEvent, ResponseType, ShowAs};2
use chrono::{DateTime, Datelike, Duration, FixedOffset, NaiveDate, Utc, Weekday};2
use chrono::{DateTime, Datelike, Duration, FixedOffset, NaiveDate, Utc, Weekday};3
3
4
pub const WORK_WEEK_DAYS: i64 = 5;4
pub const WORK_WEEK_DAYS: i64 = 5;@@ -186,7 +186,25 @@ pub fn range_label(start: NaiveDate, days: i64) -> String {186
}186
}187
}187
}188
188
189
pub fn hour_label(hour: u32) -> String {189
#[derive(Debug, Clone, Copy, PartialEq, Eq)]190
pub enum EventLook {191
Busy,192
Free,193
Tentative,194
}195
196
pub fn event_look(event: &CalendarEvent) -> EventLook {197
match event.show_as {198
ShowAs::Free => EventLook::Free,199
ShowAs::Tentative => EventLook::Tentative,200
ShowAs::Busy | ShowAs::OutOfOffice | ShowAs::WorkingElsewhere => EventLook::Busy,201
}202
}203
204
pub fn hour_label(hour: u32, twelve_hour: bool) -> String {205
if !twelve_hour {206
return hour.to_string();207
}190
match hour {208
match hour {191
0 => "12 AM".to_owned(),209
0 => "12 AM".to_owned(),192
12 => "12 PM".to_owned(),210
12 => "12 PM".to_owned(),@@ -218,6 +236,7 @@ mod tests {218
organizer_name: None,236
organizer_name: None,219
organizer_address: None,237
organizer_address: None,220
ical_uid: None,238
ical_uid: None,239
show_as: Default::default(),221
response: ResponseType::Accepted,240
response: ResponseType::Accepted,222
}241
}223
}242
}@@ -305,7 +324,23 @@ mod tests {305
range_label(NaiveDate::from_ymd_opt(2026, 11, 9).unwrap(), 5),324
range_label(NaiveDate::from_ymd_opt(2026, 11, 9).unwrap(), 5),306
"November 2026"325
"November 2026"307
);326
);308
assert_eq!(hour_label(0), "12 AM");327
assert_eq!(hour_label(0, true), "12 AM");309
assert_eq!(hour_label(13), "1 PM");328
assert_eq!(hour_label(13, true), "1 PM");329
assert_eq!(hour_label(13, false), "13");330
}331
332
#[test]333
fn free_and_tentative_meetings_look_like_teams() {334
let mut following = event(9, 0, 30);335
following.show_as = ShowAs::Free;336
following.response = ResponseType::Tentative;337
let mut tentative = event(9, 0, 30);338
tentative.show_as = ShowAs::Tentative;339
let mut away = event(9, 0, 30);340
away.show_as = ShowAs::OutOfOffice;341
assert_eq!(event_look(&following), EventLook::Free);342
assert_eq!(event_look(&tentative), EventLook::Tentative);343
assert_eq!(event_look(&away), EventLook::Busy);344
assert_eq!(event_look(&event(9, 0, 30)), EventLook::Busy);310
}345
}311
}346
}@@ -252,6 +252,7 @@ mod tests {
252
252
organizer_name: None,
253
253
organizer_address: None,
254
254
ical_uid: None,
255
show_as: Default::default(),
255
256
response: ResponseType::Accepted,
256
257
}
257
258
}
@@ -252,6 +252,7 @@ mod tests {252
organizer_name: None,252
organizer_name: None,253
organizer_address: None,253
organizer_address: None,254
ical_uid: None,254
ical_uid: None,255
show_as: Default::default(),255
response: ResponseType::Accepted,256
response: ResponseType::Accepted,256
}257
}257
}258
}@@ -189,6 +189,7 @@ mod tests {
189
189
organizer_name: None,
190
190
organizer_address: None,
191
191
ical_uid: None,
192
show_as: Default::default(),
192
193
response: ResponseType::Accepted,
193
194
}
194
195
}
@@ -189,6 +189,7 @@ mod tests {189
organizer_name: None,189
organizer_name: None,190
organizer_address: None,190
organizer_address: None,191
ical_uid: None,191
ical_uid: None,192
show_as: Default::default(),192
response: ResponseType::Accepted,193
response: ResponseType::Accepted,193
}194
}194
}195
}@@ -343,6 +343,7 @@ mod tests {
343
343
organizer_name: Some("Mara".into()),
344
344
organizer_address: None,
345
345
ical_uid: None,
346
show_as: Default::default(),
346
347
response: ResponseType::Accepted,
347
348
}
348
349
}
@@ -343,6 +343,7 @@ mod tests {343
organizer_name: Some("Mara".into()),343
organizer_name: Some("Mara".into()),344
organizer_address: None,344
organizer_address: None,345
ical_uid: None,345
ical_uid: None,346
show_as: Default::default(),346
response: ResponseType::Accepted,347
response: ResponseType::Accepted,347
}348
}348
}349
}@@ -126,6 +126,7 @@ fn demo_event(draft: &MeetingDraft, serial: u64) -> CalendarEvent {
126
126
organizer_name: Some("You".to_owned()),
127
127
organizer_address: None,
128
128
ical_uid: None,
129
show_as: Default::default(),
129
130
response: ResponseType::Organizer,
130
131
}
131
132
}
@@ -126,6 +126,7 @@ fn demo_event(draft: &MeetingDraft, serial: u64) -> CalendarEvent {126
organizer_name: Some("You".to_owned()),126
organizer_name: Some("You".to_owned()),127
organizer_address: None,127
organizer_address: None,128
ical_uid: None,128
ical_uid: None,129
show_as: Default::default(),129
response: ResponseType::Organizer,130
response: ResponseType::Organizer,130
}131
}131
}132
}@@ -1,4 +1,4 @@
1
use chatsvc::{CalendarEvent, ResponseType};
1
use chatsvc::{CalendarEvent, ResponseType, ShowAs};
2
2
use chrono::{Duration, FixedOffset, Local, NaiveDate, Offset};
3
3
use gpui_kit::Context;
4
4
@@ -92,8 +92,16 @@ impl AppState {
92
92
}
93
93
}
94
94
95
fn demo_show_as(subject: &str, response: ResponseType) -> ShowAs {
96
match response {
97
_ if subject.starts_with("Following: ") => ShowAs::Free,
98
ResponseType::Tentative | ResponseType::NotResponded => ShowAs::Tentative,
99
_ => ShowAs::Busy,
100
}
101
}
102
95
103
fn demo_week(monday: NaiveDate, offset: FixedOffset) -> Vec<CalendarEvent> {
96
let slots: [(&str, &str, i64, i64, i64, ResponseType); 7] = [
104
let slots: [(&str, &str, i64, i64, i64, ResponseType); 8] = [
97
105
(
98
106
"Team standup",
99
107
"Mara Lindqvist",
@@ -142,6 +150,14 @@ fn demo_week(monday: NaiveDate, offset: FixedOffset) -> Vec<CalendarEvent> {
142
150
30,
143
151
ResponseType::Accepted,
144
152
),
153
(
154
"Following: Design office hours",
155
"Lena Brandt",
156
3,
157
13 * 60,
158
60,
159
ResponseType::Tentative,
160
),
145
161
(
146
162
"Sprint retro",
147
163
"Mara Lindqvist",
@@ -172,6 +188,7 @@ fn demo_week(monday: NaiveDate, offset: FixedOffset) -> Vec<CalendarEvent> {
172
188
organizer_name: Some((*organizer).to_owned()),
173
189
organizer_address: None,
174
190
ical_uid: None,
191
show_as: demo_show_as(subject, *response),
175
192
response: *response,
176
193
}
177
194
})
@@ -1,4 +1,4 @@1
use chatsvc::{CalendarEvent, ResponseType};1
use chatsvc::{CalendarEvent, ResponseType, ShowAs};2
use chrono::{Duration, FixedOffset, Local, NaiveDate, Offset};2
use chrono::{Duration, FixedOffset, Local, NaiveDate, Offset};3
use gpui_kit::Context;3
use gpui_kit::Context;4
4
@@ -92,8 +92,16 @@ impl AppState {92
}92
}93
}93
}94
94
95
fn demo_show_as(subject: &str, response: ResponseType) -> ShowAs {96
match response {97
_ if subject.starts_with("Following: ") => ShowAs::Free,98
ResponseType::Tentative | ResponseType::NotResponded => ShowAs::Tentative,99
_ => ShowAs::Busy,100
}101
}102
95
fn demo_week(monday: NaiveDate, offset: FixedOffset) -> Vec<CalendarEvent> {103
fn demo_week(monday: NaiveDate, offset: FixedOffset) -> Vec<CalendarEvent> {96
let slots: [(&str, &str, i64, i64, i64, ResponseType); 7] = [104
let slots: [(&str, &str, i64, i64, i64, ResponseType); 8] = [97
(105
(98
"Team standup",106
"Team standup",99
"Mara Lindqvist",107
"Mara Lindqvist",@@ -142,6 +150,14 @@ fn demo_week(monday: NaiveDate, offset: FixedOffset) -> Vec<CalendarEvent> {142
30,150
30,143
ResponseType::Accepted,151
ResponseType::Accepted,144
),152
),153
(154
"Following: Design office hours",155
"Lena Brandt",156
3,157
13 * 60,158
60,159
ResponseType::Tentative,160
),145
(161
(146
"Sprint retro",162
"Sprint retro",147
"Mara Lindqvist",163
"Mara Lindqvist",@@ -172,6 +188,7 @@ fn demo_week(monday: NaiveDate, offset: FixedOffset) -> Vec<CalendarEvent> {172
organizer_name: Some((*organizer).to_owned()),188
organizer_name: Some((*organizer).to_owned()),173
organizer_address: None,189
organizer_address: None,174
ical_uid: None,190
ical_uid: None,191
show_as: demo_show_as(subject, *response),175
response: *response,192
response: *response,176
}193
}177
})194
})@@ -1,3 +1,4 @@
1
use app_base::format::clock_format;
1
2
use chatsvc::{CalendarEvent, ResponseType};
2
3
use chrono::{DateTime, Local, NaiveDate, Offset, Timelike, Utc};
3
4
use gpui_kit::assets::IconName;
@@ -14,12 +15,14 @@ use super::new_meeting_dialog::open_new_meeting;
14
15
use crate::app_state::AppState;
15
16
use crate::call::join_available;
16
17
use crate::call::week_grid::{
17
CalendarSpan, WeekBlock, WeekDay, hour_label, range_label, week_days,
18
CalendarSpan, EventLook, WeekBlock, WeekDay, event_look, hour_label, range_label, week_days,
18
19
};
19
20
use crate::theme;
20
21
21
const HOUR_HEIGHT: f32 = 48.;
22
const GUTTER_WIDTH: f32 = 64.;
22
const HOUR_HEIGHT: f32 = 120.;
23
const QUARTERS_PER_HOUR: usize = 4;
24
const QUARTER_LINE_OPACITY: f32 = 0.45;
25
const GUTTER_WIDTH: f32 = 50.;
23
26
const HEADER_HEIGHT: f32 = 52.;
24
27
const DAY_HEADER_HEIGHT: f32 = 56.;
25
28
const ALL_DAY_HEIGHT: f32 = 26.;
@@ -27,7 +30,14 @@ const BLOCK_GAP: f32 = 2.;
27
30
const FIRST_VISIBLE_HOUR: f32 = 8.;
28
31
const CANCELED_PREFIX: &str = "Canceled: ";
29
32
const COMPACT_HEADER_WIDTH: f32 = 960.;
30
const EVENT_FILL_OPACITY: f32 = 0.28;
33
const BUSY_FILL_OPACITY: f32 = 0.28;
34
const FREE_FILL_OPACITY: f32 = 0.12;
35
const STATUS_BAR_WIDTH: f32 = 4.;
36
const HATCH_STRIPE: f32 = 1.5;
37
const HATCH_GAP: f32 = 2.5;
38
const SMALL_TITLE_HEIGHT: f32 = 20.;
39
const TODAY_MARK_HEIGHT: f32 = 3.;
40
const NOW_DOT_SIZE: f32 = 8.;
31
41
32
42
pub struct CalendarView {
33
43
state: Entity<AppState>,
@@ -184,17 +194,29 @@ impl CalendarView {
184
194
theme::text_soft()
185
195
};
186
196
v_flex()
197
.relative()
187
198
.flex_1()
188
199
.min_w_0()
189
200
.h_full()
190
201
.justify_center()
191
.px(px(8.))
202
.px(px(12.))
192
203
.border_l_1()
193
204
.border_color(theme::border())
205
.when(is_today, |header| {
206
header.child(
207
div()
208
.absolute()
209
.top_0()
210
.left_0()
211
.right_0()
212
.h(px(TODAY_MARK_HEIGHT))
213
.bg(theme::accent()),
214
)
215
})
194
216
.child(
195
217
div()
196
218
.text_size(px(20.))
197
.font_weight(FontWeight::SEMIBOLD)
219
.line_height(px(24.))
198
220
.text_color(color)
199
221
.child(day.date.format("%d").to_string()),
200
222
)
@@ -202,7 +224,7 @@ impl CalendarView {
202
224
div()
203
225
.text_size(px(12.))
204
226
.text_color(color)
205
.child(day.date.format("%A").to_string()),
227
.child(day.date.format("%a").to_string()),
206
228
)
207
229
}))
208
230
}
@@ -232,7 +254,7 @@ impl CalendarView {
232
254
.flex()
233
255
.items_center()
234
256
.rounded(px(4.))
235
.bg(event_fill(events[index].response))
257
.bg(event_fill(event_look(&events[index])))
236
258
.text_size(px(12.))
237
259
.truncate()
238
260
.child(event_title(&events[index]))
@@ -254,15 +276,12 @@ impl CalendarView {
254
276
.max(14.);
255
277
let width = 1. / block.lanes as f32;
256
278
let compact = height < 36.;
279
let small = height < SMALL_TITLE_HEIGHT;
280
let look = event_look(event);
257
281
let can_join = event.online
258
282
&& !event.cancelled
259
283
&& event.join_url.is_some()
260
284
&& join_available(event.start, event.end, now);
261
let time = format!(
262
"{} - {}",
263
event.start.with_timezone(&Local).format("%-I:%M %p"),
264
event.end.with_timezone(&Local).format("%-I:%M %p")
265
);
266
285
let (open_state, thread_id) = (self.state.clone(), event.thread_id.clone());
267
286
let (menu_state, menu_event) = (self.state.clone(), event.clone());
268
287
let (join_state, join_url, subject) = (
@@ -270,6 +289,10 @@ impl CalendarView {
270
289
event.join_url.clone(),
271
290
event.subject.clone(),
272
291
);
292
let (title_color, detail_color) = match look {
293
EventLook::Busy => (theme::text(), theme::text_soft()),
294
EventLook::Free | EventLook::Tentative => (theme::text_soft(), theme::text_muted()),
295
};
273
296
div()
274
297
.id(SharedString::from(format!(
275
298
"calendar-event-{}",
@@ -280,41 +303,45 @@ impl CalendarView {
280
303
.h(px(height))
281
304
.left(relative(width * block.lane as f32))
282
305
.w(relative(width))
283
.pr(px(BLOCK_GAP))
306
.px(px(BLOCK_GAP))
284
307
.child(
285
308
h_flex()
286
309
.size_full()
310
.items_start()
287
311
.overflow_hidden()
288
312
.rounded(px(4.))
289
.bg(event_fill(event.response))
290
.border_l_2()
291
.border_color(theme::accent())
313
.bg(event_fill(look))
292
314
.when(event.cancelled, |block| block.opacity(0.6))
293
315
.cursor_pointer()
316
.children(status_bar(look))
294
317
.child(
295
318
v_flex()
296
319
.flex_1()
297
320
.min_w_0()
298
.px(px(6.))
321
.pl(px(5.))
322
.pr(px(4.))
323
.h_full()
299
324
.py(px(if compact { 1. } else { 4. }))
325
.when(compact, |body| body.justify_center())
300
326
.child(
301
327
div()
302
.text_size(px(12.))
328
.text_size(px(if small { 10. } else { 12. }))
329
.line_height(px(if small { 13. } else { 16. }))
303
330
.font_weight(FontWeight::SEMIBOLD)
304
.truncate()
331
.text_color(title_color)
332
.when(compact, |title| title.truncate())
333
.when(!compact, |title| title.line_clamp(2))
305
334
.child(event_title(event)),
306
335
)
307
336
.when(!compact, |body| {
308
body.child(
337
body.children(event.organizer_name.clone().map(|organizer| {
309
338
div()
310
.text_size(px(11.))
311
.text_color(theme::text_soft())
339
.text_size(px(12.))
340
.line_height(px(16.))
341
.text_color(detail_color)
312
342
.truncate()
313
.child(match &event.organizer_name {
314
Some(organizer) => format!("{time} {organizer}"),
315
None => time,
316
}),
317
)
343
.child(organizer)
344
}))
318
345
}),
319
346
)
320
347
.when(can_join, |block| {
@@ -360,6 +387,7 @@ impl CalendarView {
360
387
send_response: bool,
361
388
) -> impl IntoElement {
362
389
let total_height = 24. * HOUR_HEIGHT;
390
let twelve_hour = clock_format().contains("%p") || clock_format().contains("%P");
363
391
let now_minute = {
364
392
let local = now.with_timezone(&Local);
365
393
local.hour() * 60 + local.minute()
@@ -381,12 +409,14 @@ impl CalendarView {
381
409
.children((0..24).map(|hour| {
382
410
div()
383
411
.h(px(HOUR_HEIGHT))
384
.pr(px(8.))
412
.pt(px(4.))
385
413
.flex()
386
.justify_end()
387
.text_size(px(11.))
388
.text_color(theme::text_muted())
389
.when(hour > 0, |label| label.child(hour_label(hour)))
414
.justify_center()
415
.text_size(px(12.))
416
.text_color(theme::text_soft())
417
.when(hour > 0, |label| {
418
label.child(hour_label(hour, twelve_hour))
419
})
390
420
})),
391
421
)
392
422
.children(days.iter().map(|day| {
@@ -397,14 +427,20 @@ impl CalendarView {
397
427
.h_full()
398
428
.border_l_1()
399
429
.border_color(theme::border())
400
.children((1..24).map(|hour| {
401
div()
430
.children((1..24 * QUARTERS_PER_HOUR).map(|quarter| {
431
let line = div()
402
432
.absolute()
403
.top(px(hour as f32 * HOUR_HEIGHT))
433
.top(
434
px(quarter as f32 * HOUR_HEIGHT / QUARTERS_PER_HOUR as f32),
435
)
404
436
.left_0()
405
.right_0()
406
.h(px(1.))
407
.bg(theme::border())
437
.right_0();
438
if quarter % QUARTERS_PER_HOUR == 0 {
439
line.h(px(1.)).bg(theme::border())
440
} else {
441
line.h(px(1.))
442
.bg(theme::border().opacity(QUARTER_LINE_OPACITY))
443
}
408
444
}))
409
445
.children(day.blocks.iter().map(|block| {
410
446
self.event_block(
@@ -415,15 +451,26 @@ impl CalendarView {
415
451
)
416
452
}))
417
453
.when(day.date == today, |column| {
418
column.child(
419
div()
420
.absolute()
421
.top(px(now_minute as f32 / 60. * HOUR_HEIGHT))
422
.left_0()
423
.right_0()
424
.h(px(2.))
425
.bg(theme::red()),
426
)
454
let now_top = now_minute as f32 / 60. * HOUR_HEIGHT;
455
column
456
.child(
457
div()
458
.absolute()
459
.top(px(now_top - 1.))
460
.left_0()
461
.right_0()
462
.h(px(2.))
463
.bg(theme::accent()),
464
)
465
.child(
466
div()
467
.absolute()
468
.top(px(now_top - NOW_DOT_SIZE / 2.))
469
.left(px(-NOW_DOT_SIZE / 2.))
470
.size(px(NOW_DOT_SIZE))
471
.rounded_full()
472
.bg(theme::accent()),
473
)
427
474
})
428
475
})),
429
476
)
@@ -475,11 +522,23 @@ fn event_menu(
475
522
)
476
523
}
477
524
478
fn event_fill(response: ResponseType) -> Hsla {
479
match response {
480
ResponseType::NotResponded => theme::surface_raised(),
481
ResponseType::Tentative => theme::accent().opacity(EVENT_FILL_OPACITY / 2.),
482
_ => theme::accent().opacity(EVENT_FILL_OPACITY),
525
fn event_fill(look: EventLook) -> Hsla {
526
match look {
527
EventLook::Busy => theme::accent().opacity(BUSY_FILL_OPACITY),
528
EventLook::Free | EventLook::Tentative => theme::accent().opacity(FREE_FILL_OPACITY),
529
}
530
}
531
532
fn status_bar(look: EventLook) -> Option<Div> {
533
let bar = div().flex_none().w(px(STATUS_BAR_WIDTH)).h_full();
534
match look {
535
EventLook::Busy => Some(bar.bg(theme::accent())),
536
EventLook::Tentative => Some(
537
bar.border_1()
538
.border_color(theme::accent())
539
.bg(pattern_slash(theme::accent(), HATCH_STRIPE, HATCH_GAP)),
540
),
541
EventLook::Free => None,
483
542
}
484
543
}
485
544
@@ -1,3 +1,4 @@1
use app_base::format::clock_format;1
use chatsvc::{CalendarEvent, ResponseType};2
use chatsvc::{CalendarEvent, ResponseType};2
use chrono::{DateTime, Local, NaiveDate, Offset, Timelike, Utc};3
use chrono::{DateTime, Local, NaiveDate, Offset, Timelike, Utc};3
use gpui_kit::assets::IconName;4
use gpui_kit::assets::IconName;@@ -14,12 +15,14 @@ use super::new_meeting_dialog::open_new_meeting;14
use crate::app_state::AppState;15
use crate::app_state::AppState;15
use crate::call::join_available;16
use crate::call::join_available;16
use crate::call::week_grid::{17
use crate::call::week_grid::{17
CalendarSpan, WeekBlock, WeekDay, hour_label, range_label, week_days,18
CalendarSpan, EventLook, WeekBlock, WeekDay, event_look, hour_label, range_label, week_days,18
};19
};19
use crate::theme;20
use crate::theme;20
21
21
const HOUR_HEIGHT: f32 = 48.;22
const HOUR_HEIGHT: f32 = 120.;22
const GUTTER_WIDTH: f32 = 64.;23
const QUARTERS_PER_HOUR: usize = 4;24
const QUARTER_LINE_OPACITY: f32 = 0.45;25
const GUTTER_WIDTH: f32 = 50.;23
const HEADER_HEIGHT: f32 = 52.;26
const HEADER_HEIGHT: f32 = 52.;24
const DAY_HEADER_HEIGHT: f32 = 56.;27
const DAY_HEADER_HEIGHT: f32 = 56.;25
const ALL_DAY_HEIGHT: f32 = 26.;28
const ALL_DAY_HEIGHT: f32 = 26.;@@ -27,7 +30,14 @@ const BLOCK_GAP: f32 = 2.;27
const FIRST_VISIBLE_HOUR: f32 = 8.;30
const FIRST_VISIBLE_HOUR: f32 = 8.;28
const CANCELED_PREFIX: &str = "Canceled: ";31
const CANCELED_PREFIX: &str = "Canceled: ";29
const COMPACT_HEADER_WIDTH: f32 = 960.;32
const COMPACT_HEADER_WIDTH: f32 = 960.;30
const EVENT_FILL_OPACITY: f32 = 0.28;33
const BUSY_FILL_OPACITY: f32 = 0.28;34
const FREE_FILL_OPACITY: f32 = 0.12;35
const STATUS_BAR_WIDTH: f32 = 4.;36
const HATCH_STRIPE: f32 = 1.5;37
const HATCH_GAP: f32 = 2.5;38
const SMALL_TITLE_HEIGHT: f32 = 20.;39
const TODAY_MARK_HEIGHT: f32 = 3.;40
const NOW_DOT_SIZE: f32 = 8.;31
41
32
pub struct CalendarView {42
pub struct CalendarView {33
state: Entity<AppState>,43
state: Entity<AppState>,@@ -184,17 +194,29 @@ impl CalendarView {184
theme::text_soft()194
theme::text_soft()185
};195
};186
v_flex()196
v_flex()197
.relative()187
.flex_1()198
.flex_1()188
.min_w_0()199
.min_w_0()189
.h_full()200
.h_full()190
.justify_center()201
.justify_center()191
.px(px(8.))202
.px(px(12.))192
.border_l_1()203
.border_l_1()193
.border_color(theme::border())204
.border_color(theme::border())205
.when(is_today, |header| {206
header.child(207
div()208
.absolute()209
.top_0()210
.left_0()211
.right_0()212
.h(px(TODAY_MARK_HEIGHT))213
.bg(theme::accent()),214
)215
})194
.child(216
.child(195
div()217
div()196
.text_size(px(20.))218
.text_size(px(20.))197
.font_weight(FontWeight::SEMIBOLD)219
.line_height(px(24.))198
.text_color(color)220
.text_color(color)199
.child(day.date.format("%d").to_string()),221
.child(day.date.format("%d").to_string()),200
)222
)@@ -202,7 +224,7 @@ impl CalendarView {202
div()224
div()203
.text_size(px(12.))225
.text_size(px(12.))204
.text_color(color)226
.text_color(color)205
.child(day.date.format("%A").to_string()),227
.child(day.date.format("%a").to_string()),206
)228
)207
}))229
}))208
}230
}@@ -232,7 +254,7 @@ impl CalendarView {232
.flex()254
.flex()233
.items_center()255
.items_center()234
.rounded(px(4.))256
.rounded(px(4.))235
.bg(event_fill(events[index].response))257
.bg(event_fill(event_look(&events[index])))236
.text_size(px(12.))258
.text_size(px(12.))237
.truncate()259
.truncate()238
.child(event_title(&events[index]))260
.child(event_title(&events[index]))@@ -254,15 +276,12 @@ impl CalendarView {254
.max(14.);276
.max(14.);255
let width = 1. / block.lanes as f32;277
let width = 1. / block.lanes as f32;256
let compact = height < 36.;278
let compact = height < 36.;279
let small = height < SMALL_TITLE_HEIGHT;280
let look = event_look(event);257
let can_join = event.online281
let can_join = event.online258
&& !event.cancelled282
&& !event.cancelled259
&& event.join_url.is_some()283
&& event.join_url.is_some()260
&& join_available(event.start, event.end, now);284
&& join_available(event.start, event.end, now);261
let time = format!(262
"{} - {}",263
event.start.with_timezone(&Local).format("%-I:%M %p"),264
event.end.with_timezone(&Local).format("%-I:%M %p")265
);266
let (open_state, thread_id) = (self.state.clone(), event.thread_id.clone());285
let (open_state, thread_id) = (self.state.clone(), event.thread_id.clone());267
let (menu_state, menu_event) = (self.state.clone(), event.clone());286
let (menu_state, menu_event) = (self.state.clone(), event.clone());268
let (join_state, join_url, subject) = (287
let (join_state, join_url, subject) = (@@ -270,6 +289,10 @@ impl CalendarView {270
event.join_url.clone(),289
event.join_url.clone(),271
event.subject.clone(),290
event.subject.clone(),272
);291
);292
let (title_color, detail_color) = match look {293
EventLook::Busy => (theme::text(), theme::text_soft()),294
EventLook::Free | EventLook::Tentative => (theme::text_soft(), theme::text_muted()),295
};273
div()296
div()274
.id(SharedString::from(format!(297
.id(SharedString::from(format!(275
"calendar-event-{}",298
"calendar-event-{}",@@ -280,41 +303,45 @@ impl CalendarView {280
.h(px(height))303
.h(px(height))281
.left(relative(width * block.lane as f32))304
.left(relative(width * block.lane as f32))282
.w(relative(width))305
.w(relative(width))283
.pr(px(BLOCK_GAP))306
.px(px(BLOCK_GAP))284
.child(307
.child(285
h_flex()308
h_flex()286
.size_full()309
.size_full()310
.items_start()287
.overflow_hidden()311
.overflow_hidden()288
.rounded(px(4.))312
.rounded(px(4.))289
.bg(event_fill(event.response))313
.bg(event_fill(look))290
.border_l_2()291
.border_color(theme::accent())292
.when(event.cancelled, |block| block.opacity(0.6))314
.when(event.cancelled, |block| block.opacity(0.6))293
.cursor_pointer()315
.cursor_pointer()316
.children(status_bar(look))294
.child(317
.child(295
v_flex()318
v_flex()296
.flex_1()319
.flex_1()297
.min_w_0()320
.min_w_0()298
.px(px(6.))321
.pl(px(5.))322
.pr(px(4.))323
.h_full()299
.py(px(if compact { 1. } else { 4. }))324
.py(px(if compact { 1. } else { 4. }))325
.when(compact, |body| body.justify_center())300
.child(326
.child(301
div()327
div()302
.text_size(px(12.))328
.text_size(px(if small { 10. } else { 12. }))329
.line_height(px(if small { 13. } else { 16. }))303
.font_weight(FontWeight::SEMIBOLD)330
.font_weight(FontWeight::SEMIBOLD)304
.truncate()331
.text_color(title_color)332
.when(compact, |title| title.truncate())333
.when(!compact, |title| title.line_clamp(2))305
.child(event_title(event)),334
.child(event_title(event)),306
)335
)307
.when(!compact, |body| {336
.when(!compact, |body| {308
body.child(337
body.children(event.organizer_name.clone().map(|organizer| {309
div()338
div()310
.text_size(px(11.))339
.text_size(px(12.))311
.text_color(theme::text_soft())340
.line_height(px(16.))341
.text_color(detail_color)312
.truncate()342
.truncate()313
.child(match &event.organizer_name {343
.child(organizer)314
Some(organizer) => format!("{time} {organizer}"),344
}))315
None => time,316
}),317
)318
}),345
}),319
)346
)320
.when(can_join, |block| {347
.when(can_join, |block| {@@ -360,6 +387,7 @@ impl CalendarView {360
send_response: bool,387
send_response: bool,361
) -> impl IntoElement {388
) -> impl IntoElement {362
let total_height = 24. * HOUR_HEIGHT;389
let total_height = 24. * HOUR_HEIGHT;390
let twelve_hour = clock_format().contains("%p") || clock_format().contains("%P");363
let now_minute = {391
let now_minute = {364
let local = now.with_timezone(&Local);392
let local = now.with_timezone(&Local);365
local.hour() * 60 + local.minute()393
local.hour() * 60 + local.minute()@@ -381,12 +409,14 @@ impl CalendarView {381
.children((0..24).map(|hour| {409
.children((0..24).map(|hour| {382
div()410
div()383
.h(px(HOUR_HEIGHT))411
.h(px(HOUR_HEIGHT))384
.pr(px(8.))412
.pt(px(4.))385
.flex()413
.flex()386
.justify_end()414
.justify_center()387
.text_size(px(11.))415
.text_size(px(12.))388
.text_color(theme::text_muted())416
.text_color(theme::text_soft())389
.when(hour > 0, |label| label.child(hour_label(hour)))417
.when(hour > 0, |label| {418
label.child(hour_label(hour, twelve_hour))419
})390
})),420
})),391
)421
)392
.children(days.iter().map(|day| {422
.children(days.iter().map(|day| {@@ -397,14 +427,20 @@ impl CalendarView {397
.h_full()427
.h_full()398
.border_l_1()428
.border_l_1()399
.border_color(theme::border())429
.border_color(theme::border())400
.children((1..24).map(|hour| {430
.children((1..24 * QUARTERS_PER_HOUR).map(|quarter| {401
div()431
let line = div()402
.absolute()432
.absolute()403
.top(px(hour as f32 * HOUR_HEIGHT))433
.top(434
px(quarter as f32 * HOUR_HEIGHT / QUARTERS_PER_HOUR as f32),435
)404
.left_0()436
.left_0()405
.right_0()437
.right_0();406
.h(px(1.))438
if quarter % QUARTERS_PER_HOUR == 0 {407
.bg(theme::border())439
line.h(px(1.)).bg(theme::border())440
} else {441
line.h(px(1.))442
.bg(theme::border().opacity(QUARTER_LINE_OPACITY))443
}408
}))444
}))409
.children(day.blocks.iter().map(|block| {445
.children(day.blocks.iter().map(|block| {410
self.event_block(446
self.event_block(@@ -415,15 +451,26 @@ impl CalendarView {415
)451
)416
}))452
}))417
.when(day.date == today, |column| {453
.when(day.date == today, |column| {418
column.child(454
let now_top = now_minute as f32 / 60. * HOUR_HEIGHT;419
div()455
column420
.absolute()456
.child(421
.top(px(now_minute as f32 / 60. * HOUR_HEIGHT))457
div()422
.left_0()458
.absolute()423
.right_0()459
.top(px(now_top - 1.))424
.h(px(2.))460
.left_0()425
.bg(theme::red()),461
.right_0()426
)462
.h(px(2.))463
.bg(theme::accent()),464
)465
.child(466
div()467
.absolute()468
.top(px(now_top - NOW_DOT_SIZE / 2.))469
.left(px(-NOW_DOT_SIZE / 2.))470
.size(px(NOW_DOT_SIZE))471
.rounded_full()472
.bg(theme::accent()),473
)427
})474
})428
})),475
})),429
)476
)@@ -475,11 +522,23 @@ fn event_menu(475
)522
)476
}523
}477
524
478
fn event_fill(response: ResponseType) -> Hsla {525
fn event_fill(look: EventLook) -> Hsla {479
match response {526
match look {480
ResponseType::NotResponded => theme::surface_raised(),527
EventLook::Busy => theme::accent().opacity(BUSY_FILL_OPACITY),481
ResponseType::Tentative => theme::accent().opacity(EVENT_FILL_OPACITY / 2.),528
EventLook::Free | EventLook::Tentative => theme::accent().opacity(FREE_FILL_OPACITY),482
_ => theme::accent().opacity(EVENT_FILL_OPACITY),529
}530
}531
532
fn status_bar(look: EventLook) -> Option<Div> {533
let bar = div().flex_none().w(px(STATUS_BAR_WIDTH)).h_full();534
match look {535
EventLook::Busy => Some(bar.bg(theme::accent())),536
EventLook::Tentative => Some(537
bar.border_1()538
.border_color(theme::accent())539
.bg(pattern_slash(theme::accent(), HATCH_STRIPE, HATCH_GAP)),540
),541
EventLook::Free => None,483
}542
}484
}543
}485
544
@@ -26,6 +26,16 @@ pub enum ResponseType {
26
26
NotResponded,
27
27
}
28
28
29
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
30
pub enum ShowAs {
31
Free,
32
Tentative,
33
#[default]
34
Busy,
35
OutOfOffice,
36
WorkingElsewhere,
37
}
38
29
39
#[derive(Debug, Clone, PartialEq, Eq)]
30
40
pub struct CalendarEvent {
31
41
pub object_id: String,
@@ -41,6 +51,7 @@ pub struct CalendarEvent {
41
51
pub organizer_address: Option<String>,
42
52
pub ical_uid: Option<String>,
43
53
pub response: ResponseType,
54
pub show_as: ShowAs,
44
55
}
45
56
46
57
pub struct Calendar<T: CardTransport = SessionCardTransport> {
@@ -201,6 +212,16 @@ fn response_type(entry: &Value) -> ResponseType {
201
212
}
202
213
}
203
214
215
fn show_as(entry: &Value) -> ShowAs {
216
match text(entry, "showAs").as_deref() {
217
Some("Free") => ShowAs::Free,
218
Some("Tentative") => ShowAs::Tentative,
219
Some("Oof") => ShowAs::OutOfOffice,
220
Some("WorkingElsewhere") => ShowAs::WorkingElsewhere,
221
_ => ShowAs::Busy,
222
}
223
}
224
204
225
fn parse_event(entry: &Value) -> Option<CalendarEvent> {
205
226
let join_url = text(entry, "skypeTeamsMeetingUrl").or_else(|| text(entry, "joinUrl"));
206
227
Some(CalendarEvent {
@@ -217,6 +238,7 @@ fn parse_event(entry: &Value) -> Option<CalendarEvent> {
217
238
organizer_address: text(entry, "organizerAddress"),
218
239
ical_uid: text(entry, "iCalUid").or_else(|| text(entry, "iCalUId")),
219
240
response: response_type(entry),
241
show_as: show_as(entry),
220
242
})
221
243
}
222
244
@@ -322,6 +344,27 @@ mod tests {
322
344
assert_eq!(events[0].ical_uid.as_deref(), Some("uid-a"));
323
345
}
324
346
347
#[test]
348
fn the_free_busy_status_is_read_and_defaults_to_busy() {
349
let entry = |show_as: &str| {
350
serde_json::json!({
351
"objectId": show_as,
352
"startTime": "2026-10-12T08:30:00Z",
353
"endTime": "2026-10-12T09:00:00Z",
354
"showAs": show_as
355
})
356
};
357
let body = serde_json::json!({"value": [entry("Free"), entry("Tentative"), entry("Oof"), entry("Unknown")]});
358
let statuses: Vec<ShowAs> = parse_calendar_events(&body)
359
.iter()
360
.map(|event| event.show_as)
361
.collect();
362
assert_eq!(
363
statuses,
364
[ShowAs::Free, ShowAs::Tentative, ShowAs::OutOfOffice, ShowAs::Busy]
365
);
366
}
367
325
368
#[test]
326
369
fn entries_without_an_id_or_times_are_skipped() {
327
370
let body =
@@ -26,6 +26,16 @@ pub enum ResponseType {26
NotResponded,26
NotResponded,27
}27
}28
28
29
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]30
pub enum ShowAs {31
Free,32
Tentative,33
#[default]34
Busy,35
OutOfOffice,36
WorkingElsewhere,37
}38
29
#[derive(Debug, Clone, PartialEq, Eq)]39
#[derive(Debug, Clone, PartialEq, Eq)]30
pub struct CalendarEvent {40
pub struct CalendarEvent {31
pub object_id: String,41
pub object_id: String,@@ -41,6 +51,7 @@ pub struct CalendarEvent {41
pub organizer_address: Option<String>,51
pub organizer_address: Option<String>,42
pub ical_uid: Option<String>,52
pub ical_uid: Option<String>,43
pub response: ResponseType,53
pub response: ResponseType,54
pub show_as: ShowAs,44
}55
}45
56
46
pub struct Calendar<T: CardTransport = SessionCardTransport> {57
pub struct Calendar<T: CardTransport = SessionCardTransport> {@@ -201,6 +212,16 @@ fn response_type(entry: &Value) -> ResponseType {201
}212
}202
}213
}203
214
215
fn show_as(entry: &Value) -> ShowAs {216
match text(entry, "showAs").as_deref() {217
Some("Free") => ShowAs::Free,218
Some("Tentative") => ShowAs::Tentative,219
Some("Oof") => ShowAs::OutOfOffice,220
Some("WorkingElsewhere") => ShowAs::WorkingElsewhere,221
_ => ShowAs::Busy,222
}223
}224
204
fn parse_event(entry: &Value) -> Option<CalendarEvent> {225
fn parse_event(entry: &Value) -> Option<CalendarEvent> {205
let join_url = text(entry, "skypeTeamsMeetingUrl").or_else(|| text(entry, "joinUrl"));226
let join_url = text(entry, "skypeTeamsMeetingUrl").or_else(|| text(entry, "joinUrl"));206
Some(CalendarEvent {227
Some(CalendarEvent {@@ -217,6 +238,7 @@ fn parse_event(entry: &Value) -> Option<CalendarEvent> {217
organizer_address: text(entry, "organizerAddress"),238
organizer_address: text(entry, "organizerAddress"),218
ical_uid: text(entry, "iCalUid").or_else(|| text(entry, "iCalUId")),239
ical_uid: text(entry, "iCalUid").or_else(|| text(entry, "iCalUId")),219
response: response_type(entry),240
response: response_type(entry),241
show_as: show_as(entry),220
})242
})221
}243
}222
244
@@ -322,6 +344,27 @@ mod tests {322
assert_eq!(events[0].ical_uid.as_deref(), Some("uid-a"));344
assert_eq!(events[0].ical_uid.as_deref(), Some("uid-a"));323
}345
}324
346
347
#[test]348
fn the_free_busy_status_is_read_and_defaults_to_busy() {349
let entry = |show_as: &str| {350
serde_json::json!({351
"objectId": show_as,352
"startTime": "2026-10-12T08:30:00Z",353
"endTime": "2026-10-12T09:00:00Z",354
"showAs": show_as355
})356
};357
let body = serde_json::json!({"value": [entry("Free"), entry("Tentative"), entry("Oof"), entry("Unknown")]});358
let statuses: Vec<ShowAs> = parse_calendar_events(&body)359
.iter()360
.map(|event| event.show_as)361
.collect();362
assert_eq!(363
statuses,364
[ShowAs::Free, ShowAs::Tentative, ShowAs::OutOfOffice, ShowAs::Busy]365
);366
}367
325
#[test]368
#[test]326
fn entries_without_an_id_or_times_are_skipped() {369
fn entries_without_an_id_or_times_are_skipped() {327
let body =370
let body =@@ -49,7 +49,7 @@ pub use activity_mentions::{MentionActivity, MentionKind, mentions_of};
49
49
pub use bot_profiles::{BotProfile, BotProfiles, parse_bot_profiles};
50
50
pub use calendar::{
51
51
Attendee, Calendar, CalendarEvent, CreatedEvent, NewEvent, Reminder, Repeat, Reply,
52
ResponseType, meet_now_join_url, new_event_body, parse_calendar_events, parse_created_event,
52
ResponseType, ShowAs, meet_now_join_url, new_event_body, parse_calendar_events, parse_created_event,
53
53
};
54
54
pub use calllog::{CallDirection, CallLogEntry, CallOutcome};
55
55
pub use cards::{
@@ -49,7 +49,7 @@ pub use activity_mentions::{MentionActivity, MentionKind, mentions_of};49
pub use bot_profiles::{BotProfile, BotProfiles, parse_bot_profiles};49
pub use bot_profiles::{BotProfile, BotProfiles, parse_bot_profiles};50
pub use calendar::{50
pub use calendar::{51
Attendee, Calendar, CalendarEvent, CreatedEvent, NewEvent, Reminder, Repeat, Reply,51
Attendee, Calendar, CalendarEvent, CreatedEvent, NewEvent, Reminder, Repeat, Reply,52
ResponseType, meet_now_join_url, new_event_body, parse_calendar_events, parse_created_event,52
ResponseType, ShowAs, meet_now_join_url, new_event_body, parse_calendar_events, parse_created_event,53
};53
};54
pub use calllog::{CallDirection, CallLogEntry, CallOutcome};54
pub use calllog::{CallDirection, CallLogEntry, CallOutcome};55
pub use cards::{55
pub use cards::{