feat(calendar): drag over empty slots to create a meeting (#91)
Co-authored-by: Fülöp Márk <mark.fulop@blackcell.io> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@@ -205,7 +205,7 @@ Feature parity with the Microsoft Teams desktop client.
205
205
| Answer meeting invitations | Partial | Upcoming rows of invited meetings show Accepted / Tentative / Declined / Respond as a menu with "Send a response" (default on); own meetings say Organizer. Outlook: Graph `accept` / `tentativelyAccept` / `decline` (+ iCalUId fallback). Google: Calendar API attendee `responseStatus` patch with `sendUpdates`. Source shown on calendar blocks |
206
206
| Meeting start reminder | Partial | Toast 5 min before the start of an Upcoming meeting: title, time, Join, Snooze (back at the start or first join). Corner X dismisses for good. Outlook: Snooze and X go to Graph snoozeReminder / dismissReminder; reminderView every 60 s near a meeting. Google: snooze/dismiss stay local only. Live state (green dot) from polled live-meeting state. One chime at the start or first join; quiet with sound off and during Do not disturb or a call. Ctrl+Shift+J joins from the latest. Driven by the polled calendar (Outlook + optional Google merge); push event 128 not wired |
207
207
| Google Calendar accounts | Partial | Settings > Calendar: Connect Google (OAuth Desktop + PKCE; release builds ship the project client, no user env). Waiting row while the browser finishes (reopen / copy link / cancel). List calendars, home calendar, extra write targets. Poll merges with Outlook by iCal UID / Teams join URL. Disconnect clears tokens. Manual smoke still needed against a real Google account |
208
| Calendar view | Partial | Day, Work week, Week, Month like Teams. Settings > Calendar: default view (Last used by default, the span survives a restart), first day of week (mailbox language region as in Outlook, override), work days and hours read from and saved to the Outlook mailbox, time scale 15/30/60 min, this or next week on a day off. Grid: day number over the weekday name, hour and lighter minor lines, off-hours shaded, now line across the week, title and organizer on one line, series icon, calendar colours. Calendar list pane: mini month, Add calendar, collapsible groups with group check box, Show all. Loads through the sign-in session (no wait for the calling engine), refreshes on the calendar poll, shows loading and a Retry notice per failed source. Demo and unit tested; live check against a real account still open |
208
| Calendar view | Partial | Day, Work week, Week, Month like Teams. Settings > Calendar: default view (Last used by default, the span survives a restart), first day of week (mailbox language region as in Outlook, override), work days and hours read from and saved to the Outlook mailbox, time scale 15/30/60 min, this or next week on a day off. Grid: day number over the weekday name, hour and lighter minor lines, off-hours shaded, now line across the week, title and organizer on one line, series icon, calendar colours. Drag down a day to pick a block (snaps to the time scale), right-click it for New meeting with that time; right-click an empty slot picks it, double-click opens New meeting there, Escape drops the block. Calendar list pane: mini month, Add calendar, collapsible groups with group check box, Show all. Loads through the sign-in session (no wait for the calling engine), refreshes on the calendar poll, shows loading and a Retry notice per failed source. Demo and unit tested; live check against a real account still open |
209
209
| Pre-join screen | Partial | Join from Upcoming, chat, Join with ID, link or reminder opens a screen in the chat pane: camera preview, camera and mic switches, background menu, camera, microphone and speaker selects, "Computer audio" or "Don't use audio" (audio off in both directions), Join now, Cancel. Camera, mic and devices remembered. 1:1 calls and Meet now skip it. Checked in the demo only |
210
210
| Narrow windows in a call | Done | Controls that do not fit move into "..." (View, Reactions, Raise hand, People, Chat; mic, camera, share, "..." and Leave always stay). Below 960 px, or when a side panel would leave the call under 720 px, the chat list hides; still too narrow, the panel overlays the call. Layout guard checks 640x480, 1280x800, 1920x1080 |
211
211
| Give and take control | Missing | Protocol known (main-channel data channel, action codes 0-11); needs a second person and a security review |
@@ -205,7 +205,7 @@ Feature parity with the Microsoft Teams desktop client.205
| Answer meeting invitations | Partial | Upcoming rows of invited meetings show Accepted / Tentative / Declined / Respond as a menu with "Send a response" (default on); own meetings say Organizer. Outlook: Graph `accept` / `tentativelyAccept` / `decline` (+ iCalUId fallback). Google: Calendar API attendee `responseStatus` patch with `sendUpdates`. Source shown on calendar blocks |205
| Answer meeting invitations | Partial | Upcoming rows of invited meetings show Accepted / Tentative / Declined / Respond as a menu with "Send a response" (default on); own meetings say Organizer. Outlook: Graph `accept` / `tentativelyAccept` / `decline` (+ iCalUId fallback). Google: Calendar API attendee `responseStatus` patch with `sendUpdates`. Source shown on calendar blocks |206
| Meeting start reminder | Partial | Toast 5 min before the start of an Upcoming meeting: title, time, Join, Snooze (back at the start or first join). Corner X dismisses for good. Outlook: Snooze and X go to Graph snoozeReminder / dismissReminder; reminderView every 60 s near a meeting. Google: snooze/dismiss stay local only. Live state (green dot) from polled live-meeting state. One chime at the start or first join; quiet with sound off and during Do not disturb or a call. Ctrl+Shift+J joins from the latest. Driven by the polled calendar (Outlook + optional Google merge); push event 128 not wired |206
| Meeting start reminder | Partial | Toast 5 min before the start of an Upcoming meeting: title, time, Join, Snooze (back at the start or first join). Corner X dismisses for good. Outlook: Snooze and X go to Graph snoozeReminder / dismissReminder; reminderView every 60 s near a meeting. Google: snooze/dismiss stay local only. Live state (green dot) from polled live-meeting state. One chime at the start or first join; quiet with sound off and during Do not disturb or a call. Ctrl+Shift+J joins from the latest. Driven by the polled calendar (Outlook + optional Google merge); push event 128 not wired |207
| Google Calendar accounts | Partial | Settings > Calendar: Connect Google (OAuth Desktop + PKCE; release builds ship the project client, no user env). Waiting row while the browser finishes (reopen / copy link / cancel). List calendars, home calendar, extra write targets. Poll merges with Outlook by iCal UID / Teams join URL. Disconnect clears tokens. Manual smoke still needed against a real Google account |207
| Google Calendar accounts | Partial | Settings > Calendar: Connect Google (OAuth Desktop + PKCE; release builds ship the project client, no user env). Waiting row while the browser finishes (reopen / copy link / cancel). List calendars, home calendar, extra write targets. Poll merges with Outlook by iCal UID / Teams join URL. Disconnect clears tokens. Manual smoke still needed against a real Google account |208
| Calendar view | Partial | Day, Work week, Week, Month like Teams. Settings > Calendar: default view (Last used by default, the span survives a restart), first day of week (mailbox language region as in Outlook, override), work days and hours read from and saved to the Outlook mailbox, time scale 15/30/60 min, this or next week on a day off. Grid: day number over the weekday name, hour and lighter minor lines, off-hours shaded, now line across the week, title and organizer on one line, series icon, calendar colours. Calendar list pane: mini month, Add calendar, collapsible groups with group check box, Show all. Loads through the sign-in session (no wait for the calling engine), refreshes on the calendar poll, shows loading and a Retry notice per failed source. Demo and unit tested; live check against a real account still open |208
| Calendar view | Partial | Day, Work week, Week, Month like Teams. Settings > Calendar: default view (Last used by default, the span survives a restart), first day of week (mailbox language region as in Outlook, override), work days and hours read from and saved to the Outlook mailbox, time scale 15/30/60 min, this or next week on a day off. Grid: day number over the weekday name, hour and lighter minor lines, off-hours shaded, now line across the week, title and organizer on one line, series icon, calendar colours. Drag down a day to pick a block (snaps to the time scale), right-click it for New meeting with that time; right-click an empty slot picks it, double-click opens New meeting there, Escape drops the block. Calendar list pane: mini month, Add calendar, collapsible groups with group check box, Show all. Loads through the sign-in session (no wait for the calling engine), refreshes on the calendar poll, shows loading and a Retry notice per failed source. Demo and unit tested; live check against a real account still open |209
| Pre-join screen | Partial | Join from Upcoming, chat, Join with ID, link or reminder opens a screen in the chat pane: camera preview, camera and mic switches, background menu, camera, microphone and speaker selects, "Computer audio" or "Don't use audio" (audio off in both directions), Join now, Cancel. Camera, mic and devices remembered. 1:1 calls and Meet now skip it. Checked in the demo only |209
| Pre-join screen | Partial | Join from Upcoming, chat, Join with ID, link or reminder opens a screen in the chat pane: camera preview, camera and mic switches, background menu, camera, microphone and speaker selects, "Computer audio" or "Don't use audio" (audio off in both directions), Join now, Cancel. Camera, mic and devices remembered. 1:1 calls and Meet now skip it. Checked in the demo only |210
| Narrow windows in a call | Done | Controls that do not fit move into "..." (View, Reactions, Raise hand, People, Chat; mic, camera, share, "..." and Leave always stay). Below 960 px, or when a side panel would leave the call under 720 px, the chat list hides; still too narrow, the panel overlays the call. Layout guard checks 640x480, 1280x800, 1920x1080 |210
| Narrow windows in a call | Done | Controls that do not fit move into "..." (View, Reactions, Raise hand, People, Chat; mic, camera, share, "..." and Leave always stay). Below 960 px, or when a side panel would leave the call under 720 px, the chat list hides; still too narrow, the panel overlays the call. Layout guard checks 640x480, 1280x800, 1920x1080 |211
| Give and take control | Missing | Protocol known (main-channel data channel, action codes 0-11); needs a second person and a security review |211
| Give and take control | Missing | Protocol known (main-channel data channel, action codes 0-11); needs a second person and a security review |@@ -23,6 +23,7 @@ pub mod recording_menu;
23
23
pub mod report;
24
24
pub mod ring;
25
25
pub mod share_view;
26
pub mod slot_select;
26
27
pub mod stage_layout;
27
28
pub mod stage_split;
28
29
pub mod transcript;
@@ -23,6 +23,7 @@ pub mod recording_menu;23
pub mod report;23
pub mod report;24
pub mod ring;24
pub mod ring;25
pub mod share_view;25
pub mod share_view;26
pub mod slot_select;26
pub mod stage_layout;27
pub mod stage_layout;27
pub mod stage_split;28
pub mod stage_split;28
pub mod transcript;29
pub mod transcript;@@ -0,0 +1,244 @@
1
//! Picking a time block on the calendar's hour grid by dragging over empty slots.
2
//!
3
//! The grid snaps to its time scale (15, 30 or 60 minutes); a selection stays in one
4
//! day because the meeting form has a single date. See ADR 0023.
5
6
use chrono::{Duration, FixedOffset, NaiveDate, NaiveTime, TimeZone};
7
8
use crate::week_grid::{MINUTES_PER_DAY, local_midnight};
9
10
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11
pub struct SlotSelection {
12
pub date: NaiveDate,
13
/// Minutes after the grid's midnight, snapped to the grid step.
14
pub start_minute: i64,
15
/// Exclusive end; at most a whole day (24:00).
16
pub end_minute: i64,
17
}
18
19
/// What the meeting form gets from a picked block, in the zone's wall clock.
20
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
21
pub struct FormTimes {
22
pub date: NaiveDate,
23
pub start: NaiveTime,
24
pub end: NaiveTime,
25
}
26
27
impl FormTimes {
28
pub fn label(&self, clock_format: &str) -> String {
29
format!(
30
"{} - {}",
31
self.start.format(clock_format),
32
self.end.format(clock_format)
33
)
34
}
35
}
36
37
impl SlotSelection {
38
/// The block from where the press started to where the pointer is now.
39
pub fn between(date: NaiveDate, anchor: i64, current: i64, step: i64) -> Self {
40
let (start_minute, end_minute) = span_between(anchor, current, step);
41
SlotSelection {
42
date,
43
start_minute,
44
end_minute,
45
}
46
}
47
48
/// A meeting of `length` minutes from `minute`, cut at the end of the day.
49
pub fn starting_at(date: NaiveDate, minute: i64, length: i64) -> Self {
50
SlotSelection {
51
date,
52
start_minute: minute,
53
end_minute: (minute + length.max(1)).min(MINUTES_PER_DAY),
54
}
55
}
56
57
pub fn contains(&self, date: NaiveDate, minute: i64) -> bool {
58
self.date == date && (self.start_minute..self.end_minute).contains(&minute)
59
}
60
61
/// Whether the block still belongs on a grid showing `dates` at `step` minutes;
62
/// a block from another range or another time scale is dropped.
63
pub fn fits(&self, dates: &[NaiveDate], step: i64) -> bool {
64
let step = step.max(1);
65
dates.contains(&self.date)
66
&& self.start_minute % step == 0
67
&& (self.end_minute - self.start_minute) % step == 0
68
}
69
70
/// Date, start and end for the meeting form.
71
///
72
/// The grid draws every day with one fixed `offset` (today's), so on the other
73
/// side of a daylight saving switch a row is an hour away from its wall-clock
74
/// time. Going through that origin puts the meeting where it was dragged. A block
75
/// that runs past the form date's midnight ends at 23:59, since the form keeps
76
/// start and end on one date.
77
pub fn form_times<Tz: TimeZone>(&self, offset: FixedOffset, zone: &Tz) -> FormTimes {
78
let origin = local_midnight(self.date, offset);
79
let wall = |minute: i64| {
80
(origin + Duration::minutes(minute))
81
.with_timezone(zone)
82
.naive_local()
83
};
84
let (start, end) = (wall(self.start_minute), wall(self.end_minute));
85
let end = if end.date() == start.date() {
86
end.time()
87
} else {
88
NaiveTime::from_hms_opt(23, 59, 0).unwrap_or_default()
89
};
90
FormTimes {
91
date: start.date(),
92
start: start.time(),
93
end,
94
}
95
}
96
}
97
98
/// The grid step a pixel offset inside a day column falls in, as its starting minute.
99
pub fn minute_at(y: f32, hour_height: f32, step: i64) -> i64 {
100
let step = step.max(1);
101
if hour_height <= 0. {
102
return 0;
103
}
104
let minute = (y / hour_height * 60.).floor() as i64;
105
(minute.div_euclid(step) * step).clamp(0, MINUTES_PER_DAY - step)
106
}
107
108
/// Both grid steps and everything between them, whichever way the pointer moved.
109
fn span_between(anchor: i64, current: i64, step: i64) -> (i64, i64) {
110
let step = step.max(1);
111
(
112
anchor.min(current),
113
(anchor.max(current) + step).min(MINUTES_PER_DAY),
114
)
115
}
116
117
#[cfg(test)]
118
mod tests {
119
use super::*;
120
121
const HOUR: f32 = 48.;
122
123
fn day() -> NaiveDate {
124
NaiveDate::from_ymd_opt(2026, 11, 24).unwrap()
125
}
126
127
fn hours(hours: i32) -> FixedOffset {
128
FixedOffset::east_opt(hours * 3600).unwrap()
129
}
130
131
fn time(hour: u32, minute: u32) -> NaiveTime {
132
NaiveTime::from_hms_opt(hour, minute, 0).unwrap()
133
}
134
135
#[test]
136
fn a_press_snaps_to_the_grid_step_it_lands_in() {
137
// 10:40 on a 48px-per-hour grid.
138
let y = 10. * HOUR + 40. / 60. * HOUR;
139
assert_eq!(minute_at(y, HOUR, 15), 10 * 60 + 30);
140
assert_eq!(minute_at(y, HOUR, 30), 10 * 60 + 30);
141
assert_eq!(minute_at(y, HOUR, 60), 10 * 60);
142
}
143
144
#[test]
145
fn presses_outside_the_column_stay_within_the_day() {
146
assert_eq!(minute_at(-20., HOUR, 30), 0);
147
assert_eq!(minute_at(25. * HOUR, HOUR, 30), 23 * 60 + 30);
148
assert_eq!(minute_at(25. * HOUR, HOUR, 15), 23 * 60 + 45);
149
}
150
151
#[test]
152
fn a_grid_without_height_or_step_does_not_panic() {
153
assert_eq!(minute_at(300., 0., 30), 0);
154
assert_eq!(minute_at(10. * HOUR, HOUR, 0), 600);
155
assert_eq!(span_between(600, 600, 0), (600, 601));
156
}
157
158
#[test]
159
fn dragging_down_or_up_selects_the_same_block() {
160
let down = SlotSelection::between(day(), 600, 630, 30);
161
let up = SlotSelection::between(day(), 630, 600, 30);
162
assert_eq!(down, up);
163
assert_eq!((down.start_minute, down.end_minute), (600, 660));
164
}
165
166
#[test]
167
fn a_click_selects_one_step() {
168
assert_eq!(span_between(600, 600, 15), (600, 615));
169
assert_eq!(span_between(600, 600, 60), (600, 660));
170
}
171
172
#[test]
173
fn an_hour_and_a_half_gives_the_form_its_times() {
174
let selection = SlotSelection::between(day(), 600, 660, 30);
175
let form = selection.form_times(hours(1), &hours(1));
176
assert_eq!(
177
form,
178
FormTimes {
179
date: day(),
180
start: time(10, 0),
181
end: time(11, 30),
182
}
183
);
184
assert_eq!(form.label("%H:%M"), "10:00 - 11:30");
185
assert_eq!(form.label("%-I:%M %p"), "10:00 AM - 11:30 AM");
186
}
187
188
#[test]
189
fn a_block_to_midnight_ends_at_23_59_in_the_form_and_the_label() {
190
let selection = SlotSelection::between(day(), 23 * 60, 23 * 60 + 30, 30);
191
assert_eq!(selection.end_minute, MINUTES_PER_DAY);
192
let form = selection.form_times(hours(1), &hours(1));
193
assert_eq!(form.end, time(23, 59));
194
assert_eq!(form.label("%H:%M"), "23:00 - 23:59");
195
}
196
197
#[test]
198
fn across_a_dst_switch_the_meeting_lands_where_it_was_dragged() {
199
// Grid laid out with today's +01:00; the shown day is on +02:00 summer time.
200
// The 09:00 row there holds 10:00 wall-clock meetings, so a block dragged
201
// in it must become a 10:00 meeting.
202
let selection = SlotSelection::between(day(), 9 * 60, 9 * 60 + 30, 30);
203
let form = selection.form_times(hours(1), &hours(2));
204
assert_eq!(
205
(form.date, form.start, form.end),
206
(day(), time(10, 0), time(11, 0))
207
);
208
}
209
210
#[test]
211
fn a_double_click_meeting_has_the_default_length_from_its_slot() {
212
// 13:45 on a 15-minute grid, inside or outside a picked block alike.
213
let meeting = SlotSelection::starting_at(day(), 13 * 60 + 45, 30);
214
let form = meeting.form_times(hours(1), &hours(1));
215
assert_eq!((form.start, form.end), (time(13, 45), time(14, 15)));
216
// On an hour grid the meeting is still half an hour.
217
let hourly = SlotSelection::starting_at(day(), 13 * 60, 30);
218
assert_eq!(hourly.form_times(hours(1), &hours(1)).end, time(13, 30));
219
// At the end of the day it stops at midnight, which the form shows as 23:59.
220
let late = SlotSelection::starting_at(day(), 23 * 60 + 45, 30);
221
assert_eq!(late.end_minute, MINUTES_PER_DAY);
222
assert_eq!(late.form_times(hours(1), &hours(1)).end, time(23, 59));
223
}
224
225
#[test]
226
fn contains_checks_day_and_minute() {
227
let selection = SlotSelection::between(day(), 600, 660, 30);
228
assert!(selection.contains(day(), 600));
229
assert!(selection.contains(day(), 689));
230
assert!(!selection.contains(day(), 690));
231
assert!(!selection.contains(day().succ_opt().unwrap(), 620));
232
}
233
234
#[test]
235
fn a_block_leaves_with_its_range_or_its_time_scale() {
236
let selection = SlotSelection::between(day(), 615, 615, 15);
237
let shown = [day()];
238
assert!(selection.fits(&shown, 15));
239
assert!(!selection.fits(&shown, 30));
240
assert!(!selection.fits(&[day().succ_opt().unwrap()], 15));
241
// A half-hour block still lines up on a 15-minute grid.
242
assert!(SlotSelection::between(day(), 600, 630, 30).fits(&shown, 15));
243
}
244
}
@@ -0,0 +1,244 @@1
//! Picking a time block on the calendar's hour grid by dragging over empty slots.2
//!3
//! The grid snaps to its time scale (15, 30 or 60 minutes); a selection stays in one4
//! day because the meeting form has a single date. See ADR 0023.5
6
use chrono::{Duration, FixedOffset, NaiveDate, NaiveTime, TimeZone};7
8
use crate::week_grid::{MINUTES_PER_DAY, local_midnight};9
10
#[derive(Debug, Clone, Copy, PartialEq, Eq)]11
pub struct SlotSelection {12
pub date: NaiveDate,13
/// Minutes after the grid's midnight, snapped to the grid step.14
pub start_minute: i64,15
/// Exclusive end; at most a whole day (24:00).16
pub end_minute: i64,17
}18
19
/// What the meeting form gets from a picked block, in the zone's wall clock.20
#[derive(Debug, Clone, Copy, PartialEq, Eq)]21
pub struct FormTimes {22
pub date: NaiveDate,23
pub start: NaiveTime,24
pub end: NaiveTime,25
}26
27
impl FormTimes {28
pub fn label(&self, clock_format: &str) -> String {29
format!(30
"{} - {}",31
self.start.format(clock_format),32
self.end.format(clock_format)33
)34
}35
}36
37
impl SlotSelection {38
/// The block from where the press started to where the pointer is now.39
pub fn between(date: NaiveDate, anchor: i64, current: i64, step: i64) -> Self {40
let (start_minute, end_minute) = span_between(anchor, current, step);41
SlotSelection {42
date,43
start_minute,44
end_minute,45
}46
}47
48
/// A meeting of `length` minutes from `minute`, cut at the end of the day.49
pub fn starting_at(date: NaiveDate, minute: i64, length: i64) -> Self {50
SlotSelection {51
date,52
start_minute: minute,53
end_minute: (minute + length.max(1)).min(MINUTES_PER_DAY),54
}55
}56
57
pub fn contains(&self, date: NaiveDate, minute: i64) -> bool {58
self.date == date && (self.start_minute..self.end_minute).contains(&minute)59
}60
61
/// Whether the block still belongs on a grid showing `dates` at `step` minutes;62
/// a block from another range or another time scale is dropped.63
pub fn fits(&self, dates: &[NaiveDate], step: i64) -> bool {64
let step = step.max(1);65
dates.contains(&self.date)66
&& self.start_minute % step == 067
&& (self.end_minute - self.start_minute) % step == 068
}69
70
/// Date, start and end for the meeting form.71
///72
/// The grid draws every day with one fixed `offset` (today's), so on the other73
/// side of a daylight saving switch a row is an hour away from its wall-clock74
/// time. Going through that origin puts the meeting where it was dragged. A block75
/// that runs past the form date's midnight ends at 23:59, since the form keeps76
/// start and end on one date.77
pub fn form_times<Tz: TimeZone>(&self, offset: FixedOffset, zone: &Tz) -> FormTimes {78
let origin = local_midnight(self.date, offset);79
let wall = |minute: i64| {80
(origin + Duration::minutes(minute))81
.with_timezone(zone)82
.naive_local()83
};84
let (start, end) = (wall(self.start_minute), wall(self.end_minute));85
let end = if end.date() == start.date() {86
end.time()87
} else {88
NaiveTime::from_hms_opt(23, 59, 0).unwrap_or_default()89
};90
FormTimes {91
date: start.date(),92
start: start.time(),93
end,94
}95
}96
}97
98
/// The grid step a pixel offset inside a day column falls in, as its starting minute.99
pub fn minute_at(y: f32, hour_height: f32, step: i64) -> i64 {100
let step = step.max(1);101
if hour_height <= 0. {102
return 0;103
}104
let minute = (y / hour_height * 60.).floor() as i64;105
(minute.div_euclid(step) * step).clamp(0, MINUTES_PER_DAY - step)106
}107
108
/// Both grid steps and everything between them, whichever way the pointer moved.109
fn span_between(anchor: i64, current: i64, step: i64) -> (i64, i64) {110
let step = step.max(1);111
(112
anchor.min(current),113
(anchor.max(current) + step).min(MINUTES_PER_DAY),114
)115
}116
117
#[cfg(test)]118
mod tests {119
use super::*;120
121
const HOUR: f32 = 48.;122
123
fn day() -> NaiveDate {124
NaiveDate::from_ymd_opt(2026, 11, 24).unwrap()125
}126
127
fn hours(hours: i32) -> FixedOffset {128
FixedOffset::east_opt(hours * 3600).unwrap()129
}130
131
fn time(hour: u32, minute: u32) -> NaiveTime {132
NaiveTime::from_hms_opt(hour, minute, 0).unwrap()133
}134
135
#[test]136
fn a_press_snaps_to_the_grid_step_it_lands_in() {137
// 10:40 on a 48px-per-hour grid.138
let y = 10. * HOUR + 40. / 60. * HOUR;139
assert_eq!(minute_at(y, HOUR, 15), 10 * 60 + 30);140
assert_eq!(minute_at(y, HOUR, 30), 10 * 60 + 30);141
assert_eq!(minute_at(y, HOUR, 60), 10 * 60);142
}143
144
#[test]145
fn presses_outside_the_column_stay_within_the_day() {146
assert_eq!(minute_at(-20., HOUR, 30), 0);147
assert_eq!(minute_at(25. * HOUR, HOUR, 30), 23 * 60 + 30);148
assert_eq!(minute_at(25. * HOUR, HOUR, 15), 23 * 60 + 45);149
}150
151
#[test]152
fn a_grid_without_height_or_step_does_not_panic() {153
assert_eq!(minute_at(300., 0., 30), 0);154
assert_eq!(minute_at(10. * HOUR, HOUR, 0), 600);155
assert_eq!(span_between(600, 600, 0), (600, 601));156
}157
158
#[test]159
fn dragging_down_or_up_selects_the_same_block() {160
let down = SlotSelection::between(day(), 600, 630, 30);161
let up = SlotSelection::between(day(), 630, 600, 30);162
assert_eq!(down, up);163
assert_eq!((down.start_minute, down.end_minute), (600, 660));164
}165
166
#[test]167
fn a_click_selects_one_step() {168
assert_eq!(span_between(600, 600, 15), (600, 615));169
assert_eq!(span_between(600, 600, 60), (600, 660));170
}171
172
#[test]173
fn an_hour_and_a_half_gives_the_form_its_times() {174
let selection = SlotSelection::between(day(), 600, 660, 30);175
let form = selection.form_times(hours(1), &hours(1));176
assert_eq!(177
form,178
FormTimes {179
date: day(),180
start: time(10, 0),181
end: time(11, 30),182
}183
);184
assert_eq!(form.label("%H:%M"), "10:00 - 11:30");185
assert_eq!(form.label("%-I:%M %p"), "10:00 AM - 11:30 AM");186
}187
188
#[test]189
fn a_block_to_midnight_ends_at_23_59_in_the_form_and_the_label() {190
let selection = SlotSelection::between(day(), 23 * 60, 23 * 60 + 30, 30);191
assert_eq!(selection.end_minute, MINUTES_PER_DAY);192
let form = selection.form_times(hours(1), &hours(1));193
assert_eq!(form.end, time(23, 59));194
assert_eq!(form.label("%H:%M"), "23:00 - 23:59");195
}196
197
#[test]198
fn across_a_dst_switch_the_meeting_lands_where_it_was_dragged() {199
// Grid laid out with today's +01:00; the shown day is on +02:00 summer time.200
// The 09:00 row there holds 10:00 wall-clock meetings, so a block dragged201
// in it must become a 10:00 meeting.202
let selection = SlotSelection::between(day(), 9 * 60, 9 * 60 + 30, 30);203
let form = selection.form_times(hours(1), &hours(2));204
assert_eq!(205
(form.date, form.start, form.end),206
(day(), time(10, 0), time(11, 0))207
);208
}209
210
#[test]211
fn a_double_click_meeting_has_the_default_length_from_its_slot() {212
// 13:45 on a 15-minute grid, inside or outside a picked block alike.213
let meeting = SlotSelection::starting_at(day(), 13 * 60 + 45, 30);214
let form = meeting.form_times(hours(1), &hours(1));215
assert_eq!((form.start, form.end), (time(13, 45), time(14, 15)));216
// On an hour grid the meeting is still half an hour.217
let hourly = SlotSelection::starting_at(day(), 13 * 60, 30);218
assert_eq!(hourly.form_times(hours(1), &hours(1)).end, time(13, 30));219
// At the end of the day it stops at midnight, which the form shows as 23:59.220
let late = SlotSelection::starting_at(day(), 23 * 60 + 45, 30);221
assert_eq!(late.end_minute, MINUTES_PER_DAY);222
assert_eq!(late.form_times(hours(1), &hours(1)).end, time(23, 59));223
}224
225
#[test]226
fn contains_checks_day_and_minute() {227
let selection = SlotSelection::between(day(), 600, 660, 30);228
assert!(selection.contains(day(), 600));229
assert!(selection.contains(day(), 689));230
assert!(!selection.contains(day(), 690));231
assert!(!selection.contains(day().succ_opt().unwrap(), 620));232
}233
234
#[test]235
fn a_block_leaves_with_its_range_or_its_time_scale() {236
let selection = SlotSelection::between(day(), 615, 615, 15);237
let shown = [day()];238
assert!(selection.fits(&shown, 15));239
assert!(!selection.fits(&shown, 30));240
assert!(!selection.fits(&[day().succ_opt().unwrap()], 15));241
// A half-hour block still lines up on a 15-minute grid.242
assert!(SlotSelection::between(day(), 600, 630, 30).fits(&shown, 15));243
}244
}@@ -27,8 +27,8 @@ pub mod week;
27
27
pub use app_call_model::{
28
28
agenda, background, bubbles, calendar_list, calendar_now, calendar_prefs, caption_style, demo,
29
29
end_screen, fullscreen, health, media, mic, model, options_dialog, people, preview,
30
record_rights, recording_menu, report, ring, share_view, stage_layout, stage_split, transcript,
31
view_settings, week_grid,
30
record_rights, recording_menu, report, ring, share_view, slot_select, stage_layout,
31
stage_split, transcript, view_settings, week_grid,
32
32
};
33
33
34
34
pub use actions::{
@@ -27,8 +27,8 @@ pub mod week;27
pub use app_call_model::{27
pub use app_call_model::{28
agenda, background, bubbles, calendar_list, calendar_now, calendar_prefs, caption_style, demo,28
agenda, background, bubbles, calendar_list, calendar_now, calendar_prefs, caption_style, demo,29
end_screen, fullscreen, health, media, mic, model, options_dialog, people, preview,29
end_screen, fullscreen, health, media, mic, model, options_dialog, people, preview,30
record_rights, recording_menu, report, ring, share_view, stage_layout, stage_split, transcript,30
record_rights, recording_menu, report, ring, share_view, slot_select, stage_layout,31
view_settings, week_grid,31
stage_split, transcript, view_settings, week_grid,32
};32
};33
33
34
pub use actions::{34
pub use actions::{@@ -10,7 +10,8 @@ use crate::runtime;
10
10
11
11
const AGENDA_KEYS: [&str; 4] = ["body", "bodyContent", "bodyContentType", "bodyPreview"];
12
12
const HALF_HOUR_MINUTES: i64 = 30;
13
const DEFAULT_LENGTH_MINUTES: i64 = 30;
13
/// Length of a new meeting when nothing else sets it (Teams: 30 minutes).
14
pub const DEFAULT_LENGTH_MINUTES: i64 = 30;
14
15
const READ_ONLY_MESSAGE: &str = "Meetings cannot be scheduled in read-only mode.";
15
16
const RESPONSE_FAILED_NOTICE: &str = "Could not send your response";
16
17
const DELETE_FAILED_NOTICE: &str = "Could not delete the meeting";
@@ -10,7 +10,8 @@ use crate::runtime;10
10
11
const AGENDA_KEYS: [&str; 4] = ["body", "bodyContent", "bodyContentType", "bodyPreview"];11
const AGENDA_KEYS: [&str; 4] = ["body", "bodyContent", "bodyContentType", "bodyPreview"];12
const HALF_HOUR_MINUTES: i64 = 30;12
const HALF_HOUR_MINUTES: i64 = 30;13
const DEFAULT_LENGTH_MINUTES: i64 = 30;13
/// Length of a new meeting when nothing else sets it (Teams: 30 minutes).14
pub const DEFAULT_LENGTH_MINUTES: i64 = 30;14
const READ_ONLY_MESSAGE: &str = "Meetings cannot be scheduled in read-only mode.";15
const READ_ONLY_MESSAGE: &str = "Meetings cannot be scheduled in read-only mode.";15
const RESPONSE_FAILED_NOTICE: &str = "Could not send your response";16
const RESPONSE_FAILED_NOTICE: &str = "Could not send your response";16
const DELETE_FAILED_NOTICE: &str = "Could not delete the meeting";17
const DELETE_FAILED_NOTICE: &str = "Could not delete the meeting";@@ -2,7 +2,7 @@ use std::time::Duration;
2
2
3
3
use app_base::format::{self, WeekdayWidth, clock_format, weekday_name};
4
4
use chatsvc::{CalendarEvent, ResponseType, join_info_text};
5
use chrono::{DateTime, Datelike, Local, NaiveDate, Offset, Timelike, Utc};
5
use chrono::{DateTime, Datelike, FixedOffset, Local, NaiveDate, Offset, Timelike, Utc};
6
6
use gpui_kit::assets::IconName;
7
7
use gpui_kit::component::Sizable as _;
8
8
use gpui_kit::component::button::{Button, ButtonVariants as _};
@@ -17,7 +17,7 @@ use super::calendar_month::month_grid;
17
17
use super::calendar_picker;
18
18
use super::join_dialog::open_join_with_id;
19
19
use super::meeting_proposal_card::meeting_proposal_cards;
20
use super::new_meeting_dialog::open_new_meeting;
20
use super::new_meeting_dialog::{open_new_meeting, open_new_meeting_at};
21
21
use super::rsvp_menu::rsvp_menu;
22
22
use super::scroll_edge::scroll_offset;
23
23
use crate::app_state::AppState;
@@ -25,6 +25,8 @@ use crate::call::calendar_now::{
25
25
DEFAULT_GRID_VIEWPORT, FollowNow, MANUAL_SCROLL_EPSILON, NOW_BIAS_FRACTION, hour_height,
26
26
now_scroll_offset_y, offset_differs, shows_hour_grid, work_start_scroll_offset_y,
27
27
};
28
use crate::call::schedule::DEFAULT_LENGTH_MINUTES;
29
use crate::call::slot_select::{SlotSelection, minute_at};
28
30
use crate::call::week::CalendarLoadFailure;
29
31
use crate::call::week_grid::{
30
32
CalendarSpan, EventLook, WeekBlock, WeekDay, WeekLayout, calendar_index, event_look,
@@ -75,6 +77,16 @@ const TODAY_MARK_HEIGHT: f32 = 3.;
75
77
const NOW_DOT_SIZE: f32 = 8.;
76
78
const CLOCK_TICK: Duration = Duration::from_secs(30);
77
79
const CHROME_HEIGHT: f32 = HEADER_HEIGHT + DAY_HEADER_HEIGHT + ALL_DAY_HEIGHT;
80
const SELECTION_FILL_OPACITY: f32 = 0.24;
81
/// Height below which the picked block drops its time label.
82
const SELECTION_LABEL_HEIGHT: f32 = 18.;
83
84
/// A left press on an empty slot that is still held; the block grows from `anchor`.
85
#[derive(Debug, Clone, Copy)]
86
struct SlotDrag {
87
date: NaiveDate,
88
anchor: i64,
89
}
78
90
79
91
pub struct CalendarView {
80
92
state: Entity<AppState>,
@@ -87,6 +99,11 @@ pub struct CalendarView {
87
99
/// Row height of one hour and minor lines per hour, from the time scale.
88
100
hour_height: f32,
89
101
steps_per_hour: usize,
102
/// Block of empty slots picked on the hour grid for a new meeting.
103
slot_selection: Option<SlotSelection>,
104
slot_drag: Option<SlotDrag>,
105
/// Focus for the hour grid, so Escape can drop the picked block.
106
grid_focus: FocusHandle,
90
107
_observation: Subscription,
91
108
_agent_observation: Option<Subscription>,
92
109
}
@@ -106,6 +123,9 @@ impl CalendarView {
106
123
clock_running: false,
107
124
hour_height: hour_height(Default::default()),
108
125
steps_per_hour: 2,
126
slot_selection: None,
127
slot_drag: None,
128
grid_focus: cx.focus_handle(),
109
129
_observation: observation,
110
130
_agent_observation: agent_observation,
111
131
}
@@ -221,13 +241,234 @@ impl CalendarView {
221
241
fn on_grid_scroll_wheel(
222
242
&mut self,
223
243
_event: &ScrollWheelEvent,
224
_window: &mut Window,
244
window: &mut Window,
225
245
cx: &mut Context<Self>,
226
246
) {
227
247
self.follow_now.note_manual_scroll();
248
if self.slot_drag.is_some() {
249
// A wheel turn moves the grid under a still pointer; follow it once the
250
// new offset is in.
251
cx.on_next_frame(window, |view, window, cx| {
252
view.drag_slot_to(window.mouse_position(), cx)
253
});
254
}
228
255
cx.notify();
229
256
}
230
257
258
fn step_minutes(&self) -> i64 {
259
60 / self.steps_per_hour.max(1) as i64
260
}
261
262
/// Grid step under a window position; the day's columns scroll together, so the
263
/// scroll container's top plus its offset is where midnight sits.
264
fn minute_at_position(&self, position: Point<Pixels>) -> i64 {
265
let content_top =
266
f32::from(self.scroll.bounds().top()) + f32::from(scroll_offset(&self.scroll).y);
267
minute_at(
268
f32::from(position.y) - content_top,
269
self.hour_height,
270
self.step_minutes(),
271
)
272
}
273
274
fn one_slot(&self, date: NaiveDate, position: Point<Pixels>) -> SlotSelection {
275
let minute = self.minute_at_position(position);
276
SlotSelection::between(date, minute, minute, self.step_minutes())
277
}
278
279
/// Left press on an empty slot: start picking a block, or a double click opens
280
/// New meeting at that slot with the default meeting length, as Teams does.
281
fn press_slot(
282
&mut self,
283
date: NaiveDate,
284
event: &MouseDownEvent,
285
window: &mut Window,
286
cx: &mut Context<Self>,
287
) {
288
let slot = self.one_slot(date, event.position);
289
if event.click_count >= 2 {
290
self.clear_slot_selection(cx);
291
let meeting =
292
SlotSelection::starting_at(date, slot.start_minute, DEFAULT_LENGTH_MINUTES);
293
open_meeting_for(self.state.clone(), meeting, window, cx);
294
return;
295
}
296
self.slot_drag = Some(SlotDrag {
297
date,
298
anchor: slot.start_minute,
299
});
300
self.slot_selection = Some(slot);
301
cx.notify();
302
}
303
304
fn drag_slot_to(&mut self, position: Point<Pixels>, cx: &mut Context<Self>) {
305
let Some(drag) = self.slot_drag else {
306
return;
307
};
308
let minute = self.minute_at_position(position);
309
let selection = SlotSelection::between(drag.date, drag.anchor, minute, self.step_minutes());
310
if self.slot_selection != Some(selection) {
311
self.slot_selection = Some(selection);
312
cx.notify();
313
}
314
}
315
316
fn end_slot_drag(&mut self, cx: &mut Context<Self>) {
317
if self.slot_drag.take().is_some() {
318
cx.notify();
319
}
320
}
321
322
/// Right press on an empty slot: keep the picked block when the press is inside
323
/// it, otherwise pick just that slot, so the menu always has a block to use.
324
fn right_press_slot(
325
&mut self,
326
date: NaiveDate,
327
event: &MouseDownEvent,
328
cx: &mut Context<Self>,
329
) {
330
self.slot_drag = None;
331
let minute = self.minute_at_position(event.position);
332
if !self
333
.slot_selection
334
.is_some_and(|selection| selection.contains(date, minute))
335
{
336
self.slot_selection = Some(self.one_slot(date, event.position));
337
}
338
cx.notify();
339
}
340
341
fn clear_slot_selection(&mut self, cx: &mut Context<Self>) {
342
self.slot_drag = None;
343
if self.slot_selection.take().is_some() {
344
cx.notify();
345
}
346
}
347
348
/// While a block is being picked, follow the pointer outside the grid and over
349
/// meetings too. Releases are caught on the grid itself (see `grid`), whose
350
/// listeners already exist when the press lands.
351
fn slot_drag_listener(&self, cx: &Context<Self>) -> impl IntoElement {
352
let view = cx.entity().downgrade();
353
canvas(
354
|_, _, _| {},
355
move |_, _, window, _| {
356
let moved = view.clone();
357
window.on_mouse_event(move |event: &MouseMoveEvent, phase, _, cx| {
358
if !phase.bubble() {
359
return;
360
}
361
let held = event.pressed_button == Some(MouseButton::Left);
362
moved
363
.update(cx, |view, cx| {
364
if held {
365
view.drag_slot_to(event.position, cx);
366
} else {
367
view.end_slot_drag(cx);
368
}
369
})
370
.ok();
371
});
372
},
373
)
374
.absolute()
375
.size_full()
376
}
377
378
/// Invisible layer under a day's meetings that takes presses on empty slots.
379
fn slot_layer(&self, date: NaiveDate, cx: &Context<Self>) -> impl IntoElement {
380
let (menu_view, menu_state) = (cx.entity().downgrade(), self.state.clone());
381
div()
382
.id(SharedString::from(format!("calendar-slots-{date}")))
383
.absolute()
384
.top_0()
385
.left_0()
386
.size_full()
387
// Capture runs before the context menu notes which element to give focus
388
// back to, so Escape reaches the grid after the menu closes.
389
.capture_any_mouse_down(cx.listener(|view, _: &MouseDownEvent, window, cx| {
390
window.focus(&view.grid_focus, cx)
391
}))
392
.on_mouse_down(
393
MouseButton::Left,
394
cx.listener(move |view, event: &MouseDownEvent, window, cx| {
395
view.press_slot(date, event, window, cx)
396
}),
397
)
398
.on_mouse_down(
399
MouseButton::Right,
400
cx.listener(move |view, event: &MouseDownEvent, _, cx| {
401
view.right_press_slot(date, event, cx)
402
}),
403
)
404
.context_menu(move |menu, _, _| {
405
let (view, state) = (menu_view.clone(), menu_state.clone());
406
menu.item(
407
PopupMenuItem::new(tr("calendar.view.new_meeting"))
408
.icon(IconName::Plus)
409
.on_click(move |_, window, cx| {
410
let picked = view
411
.update(cx, |view, cx| {
412
let picked = view.slot_selection;
413
view.clear_slot_selection(cx);
414
picked
415
})
416
.ok()
417
.flatten();
418
match picked {
419
Some(picked) => open_meeting_for(state.clone(), picked, window, cx),
420
None => open_new_meeting(state.clone(), window, cx),
421
}
422
}),
423
)
424
})
425
}
426
427
/// The picked block: an accent fill and bar, with its times when there is room.
428
fn selection_block(&self, selection: &SlotSelection) -> Div {
429
let row = self.hour_height;
430
let top = selection.start_minute as f32 / 60. * row;
431
let height = (selection.end_minute - selection.start_minute) as f32 / 60. * row;
432
// The times New meeting will open with, so the label and the form agree.
433
let label = selection
434
.form_times(grid_offset(), &Local)
435
.label(clock_format());
436
div()
437
.absolute()
438
.top(px(top))
439
.h(px(height))
440
.left_0()
441
.right_0()
442
.px(px(BLOCK_GAP))
443
.child(
444
h_flex()
445
.size_full()
446
.items_start()
447
.overflow_hidden()
448
.rounded(px(6.))
449
.bg(theme::accent().opacity(SELECTION_FILL_OPACITY))
450
.child(
451
div()
452
.flex_none()
453
.w(px(STATUS_BAR_WIDTH))
454
.h_full()
455
.bg(theme::accent()),
456
)
457
.child(
458
div()
459
.flex_1()
460
.min_w_0()
461
.pl(px(5.))
462
.pr(px(4.))
463
.text_size(px(11.))
464
.line_height(px(16.))
465
.text_color(theme::accent_text())
466
.truncate()
467
.when(height >= SELECTION_LABEL_HEIGHT, |text| text.child(label)),
468
),
469
)
470
}
471
231
472
fn header(
232
473
&self,
233
474
start: NaiveDate,
@@ -536,6 +777,8 @@ impl CalendarView {
536
777
"calendar-event-{}-{}",
537
778
event.object_id, day
538
779
)))
780
// Presses on a meeting must not reach the empty-slot layer under it.
781
.block_mouse_except_scroll()
539
782
.absolute()
540
783
.top(px(top))
541
784
.h(px(height))
@@ -631,13 +874,33 @@ impl CalendarView {
631
874
let now_top = now_minute as f32 / 60. * row;
632
875
let today_shown = days.iter().any(|day| day.date == today);
633
876
let minute_y = |minute: i64| minute as f32 / 60. * row;
877
let selection = self.slot_selection;
878
let dragging = self.slot_drag.is_some();
634
879
div()
635
880
.id("calendar-grid")
636
881
.flex_1()
637
882
.min_h_0()
638
883
.overflow_y_scroll()
639
884
.track_scroll(&self.scroll)
885
.track_focus(&self.grid_focus)
886
.on_key_down(cx.listener(|view, event: &KeyDownEvent, _, cx| {
887
if event.keystroke.key == "escape" && view.slot_selection.is_some() {
888
view.clear_slot_selection(cx);
889
cx.stop_propagation();
890
}
891
}))
640
892
.on_scroll_wheel(cx.listener(Self::on_grid_scroll_wheel))
893
// Inside the grid, or outside it and over meetings (whose hitboxes block
894
// the grid's): either way a left release ends the drag.
895
.on_mouse_up(
896
MouseButton::Left,
897
cx.listener(|view, _: &MouseUpEvent, _, cx| view.end_slot_drag(cx)),
898
)
899
.on_mouse_up_out(
900
MouseButton::Left,
901
cx.listener(|view, _: &MouseUpEvent, _, cx| view.end_slot_drag(cx)),
902
)
903
.when(dragging, |grid| grid.child(self.slot_drag_listener(cx)))
641
904
.child(
642
905
h_flex()
643
906
.h(px(total_height))
@@ -687,6 +950,7 @@ impl CalendarView {
687
950
.h_full()
688
951
.border_l_1()
689
952
.border_color(theme::border())
953
.child(self.slot_layer(day.date, cx))
690
954
.children(shading)
691
955
.children((1..24 * steps).map(|step| {
692
956
let line = div()
@@ -701,6 +965,11 @@ impl CalendarView {
701
965
line.bg(theme::border().opacity(MINOR_LINE_OPACITY))
702
966
}
703
967
}))
968
.children(
969
selection
970
.filter(|selection| selection.date == day.date)
971
.map(|selection| self.selection_block(&selection)),
972
)
704
973
.children(day.blocks.iter().map(|block| {
705
974
self.event_block(
706
975
block,
@@ -747,6 +1016,22 @@ impl CalendarView {
747
1016
}
748
1017
}
749
1018
1019
/// The one UTC offset the hour grid lays every shown day out with.
1020
fn grid_offset() -> FixedOffset {
1021
Local::now().offset().fix()
1022
}
1023
1024
/// New meeting for a block picked on the grid.
1025
fn open_meeting_for(
1026
state: Entity<AppState>,
1027
picked: SlotSelection,
1028
window: &mut Window,
1029
cx: &mut App,
1030
) {
1031
let form = picked.form_times(grid_offset(), &Local);
1032
open_new_meeting_at(state, form.date, form.start, form.end, window, cx);
1033
}
1034
750
1035
/// Loading line and one notice per failed source, under the calendar header.
751
1036
fn load_notices(
752
1037
state: &Entity<AppState>,
@@ -958,11 +1243,18 @@ impl Render for CalendarView {
958
1243
let send_response = state.rsvp_send_response;
959
1244
let failures = state.calendar_week.failures.clone();
960
1245
let loading = state.calendar_week.loading && events.is_empty();
961
let offset = Local::now().offset().fix();
1246
let offset = grid_offset();
962
1247
let span = state.calendar_week.span;
963
1248
let layout = state.calendar_layout();
964
1249
let dates = state.calendar_dates();
965
1250
let days = week_days(&events, &dates, offset);
1251
// A picked block goes away once its day scrolls out of view or Month shows.
1252
if self.slot_selection.is_some_and(|picked| {
1253
span == CalendarSpan::Month || !picked.fits(&dates, self.step_minutes())
1254
}) {
1255
self.slot_selection = None;
1256
self.slot_drag = None;
1257
}
966
1258
let today = Local::now().date_naive();
967
1259
let now = Utc::now();
968
1260
let accounts = state.calendar_accounts();
@@ -2,7 +2,7 @@ use std::time::Duration;2
2
3
use app_base::format::{self, WeekdayWidth, clock_format, weekday_name};3
use app_base::format::{self, WeekdayWidth, clock_format, weekday_name};4
use chatsvc::{CalendarEvent, ResponseType, join_info_text};4
use chatsvc::{CalendarEvent, ResponseType, join_info_text};5
use chrono::{DateTime, Datelike, Local, NaiveDate, Offset, Timelike, Utc};5
use chrono::{DateTime, Datelike, FixedOffset, Local, NaiveDate, Offset, Timelike, Utc};6
use gpui_kit::assets::IconName;6
use gpui_kit::assets::IconName;7
use gpui_kit::component::Sizable as _;7
use gpui_kit::component::Sizable as _;8
use gpui_kit::component::button::{Button, ButtonVariants as _};8
use gpui_kit::component::button::{Button, ButtonVariants as _};@@ -17,7 +17,7 @@ use super::calendar_month::month_grid;17
use super::calendar_picker;17
use super::calendar_picker;18
use super::join_dialog::open_join_with_id;18
use super::join_dialog::open_join_with_id;19
use super::meeting_proposal_card::meeting_proposal_cards;19
use super::meeting_proposal_card::meeting_proposal_cards;20
use super::new_meeting_dialog::open_new_meeting;20
use super::new_meeting_dialog::{open_new_meeting, open_new_meeting_at};21
use super::rsvp_menu::rsvp_menu;21
use super::rsvp_menu::rsvp_menu;22
use super::scroll_edge::scroll_offset;22
use super::scroll_edge::scroll_offset;23
use crate::app_state::AppState;23
use crate::app_state::AppState;@@ -25,6 +25,8 @@ use crate::call::calendar_now::{25
DEFAULT_GRID_VIEWPORT, FollowNow, MANUAL_SCROLL_EPSILON, NOW_BIAS_FRACTION, hour_height,25
DEFAULT_GRID_VIEWPORT, FollowNow, MANUAL_SCROLL_EPSILON, NOW_BIAS_FRACTION, hour_height,26
now_scroll_offset_y, offset_differs, shows_hour_grid, work_start_scroll_offset_y,26
now_scroll_offset_y, offset_differs, shows_hour_grid, work_start_scroll_offset_y,27
};27
};28
use crate::call::schedule::DEFAULT_LENGTH_MINUTES;29
use crate::call::slot_select::{SlotSelection, minute_at};28
use crate::call::week::CalendarLoadFailure;30
use crate::call::week::CalendarLoadFailure;29
use crate::call::week_grid::{31
use crate::call::week_grid::{30
CalendarSpan, EventLook, WeekBlock, WeekDay, WeekLayout, calendar_index, event_look,32
CalendarSpan, EventLook, WeekBlock, WeekDay, WeekLayout, calendar_index, event_look,@@ -75,6 +77,16 @@ const TODAY_MARK_HEIGHT: f32 = 3.;75
const NOW_DOT_SIZE: f32 = 8.;77
const NOW_DOT_SIZE: f32 = 8.;76
const CLOCK_TICK: Duration = Duration::from_secs(30);78
const CLOCK_TICK: Duration = Duration::from_secs(30);77
const CHROME_HEIGHT: f32 = HEADER_HEIGHT + DAY_HEADER_HEIGHT + ALL_DAY_HEIGHT;79
const CHROME_HEIGHT: f32 = HEADER_HEIGHT + DAY_HEADER_HEIGHT + ALL_DAY_HEIGHT;80
const SELECTION_FILL_OPACITY: f32 = 0.24;81
/// Height below which the picked block drops its time label.82
const SELECTION_LABEL_HEIGHT: f32 = 18.;83
84
/// A left press on an empty slot that is still held; the block grows from `anchor`.85
#[derive(Debug, Clone, Copy)]86
struct SlotDrag {87
date: NaiveDate,88
anchor: i64,89
}78
90
79
pub struct CalendarView {91
pub struct CalendarView {80
state: Entity<AppState>,92
state: Entity<AppState>,@@ -87,6 +99,11 @@ pub struct CalendarView {87
/// Row height of one hour and minor lines per hour, from the time scale.99
/// Row height of one hour and minor lines per hour, from the time scale.88
hour_height: f32,100
hour_height: f32,89
steps_per_hour: usize,101
steps_per_hour: usize,102
/// Block of empty slots picked on the hour grid for a new meeting.103
slot_selection: Option<SlotSelection>,104
slot_drag: Option<SlotDrag>,105
/// Focus for the hour grid, so Escape can drop the picked block.106
grid_focus: FocusHandle,90
_observation: Subscription,107
_observation: Subscription,91
_agent_observation: Option<Subscription>,108
_agent_observation: Option<Subscription>,92
}109
}@@ -106,6 +123,9 @@ impl CalendarView {106
clock_running: false,123
clock_running: false,107
hour_height: hour_height(Default::default()),124
hour_height: hour_height(Default::default()),108
steps_per_hour: 2,125
steps_per_hour: 2,126
slot_selection: None,127
slot_drag: None,128
grid_focus: cx.focus_handle(),109
_observation: observation,129
_observation: observation,110
_agent_observation: agent_observation,130
_agent_observation: agent_observation,111
}131
}@@ -221,13 +241,234 @@ impl CalendarView {221
fn on_grid_scroll_wheel(241
fn on_grid_scroll_wheel(222
&mut self,242
&mut self,223
_event: &ScrollWheelEvent,243
_event: &ScrollWheelEvent,224
_window: &mut Window,244
window: &mut Window,225
cx: &mut Context<Self>,245
cx: &mut Context<Self>,226
) {246
) {227
self.follow_now.note_manual_scroll();247
self.follow_now.note_manual_scroll();248
if self.slot_drag.is_some() {249
// A wheel turn moves the grid under a still pointer; follow it once the250
// new offset is in.251
cx.on_next_frame(window, |view, window, cx| {252
view.drag_slot_to(window.mouse_position(), cx)253
});254
}228
cx.notify();255
cx.notify();229
}256
}230
257
258
fn step_minutes(&self) -> i64 {259
60 / self.steps_per_hour.max(1) as i64260
}261
262
/// Grid step under a window position; the day's columns scroll together, so the263
/// scroll container's top plus its offset is where midnight sits.264
fn minute_at_position(&self, position: Point<Pixels>) -> i64 {265
let content_top =266
f32::from(self.scroll.bounds().top()) + f32::from(scroll_offset(&self.scroll).y);267
minute_at(268
f32::from(position.y) - content_top,269
self.hour_height,270
self.step_minutes(),271
)272
}273
274
fn one_slot(&self, date: NaiveDate, position: Point<Pixels>) -> SlotSelection {275
let minute = self.minute_at_position(position);276
SlotSelection::between(date, minute, minute, self.step_minutes())277
}278
279
/// Left press on an empty slot: start picking a block, or a double click opens280
/// New meeting at that slot with the default meeting length, as Teams does.281
fn press_slot(282
&mut self,283
date: NaiveDate,284
event: &MouseDownEvent,285
window: &mut Window,286
cx: &mut Context<Self>,287
) {288
let slot = self.one_slot(date, event.position);289
if event.click_count >= 2 {290
self.clear_slot_selection(cx);291
let meeting =292
SlotSelection::starting_at(date, slot.start_minute, DEFAULT_LENGTH_MINUTES);293
open_meeting_for(self.state.clone(), meeting, window, cx);294
return;295
}296
self.slot_drag = Some(SlotDrag {297
date,298
anchor: slot.start_minute,299
});300
self.slot_selection = Some(slot);301
cx.notify();302
}303
304
fn drag_slot_to(&mut self, position: Point<Pixels>, cx: &mut Context<Self>) {305
let Some(drag) = self.slot_drag else {306
return;307
};308
let minute = self.minute_at_position(position);309
let selection = SlotSelection::between(drag.date, drag.anchor, minute, self.step_minutes());310
if self.slot_selection != Some(selection) {311
self.slot_selection = Some(selection);312
cx.notify();313
}314
}315
316
fn end_slot_drag(&mut self, cx: &mut Context<Self>) {317
if self.slot_drag.take().is_some() {318
cx.notify();319
}320
}321
322
/// Right press on an empty slot: keep the picked block when the press is inside323
/// it, otherwise pick just that slot, so the menu always has a block to use.324
fn right_press_slot(325
&mut self,326
date: NaiveDate,327
event: &MouseDownEvent,328
cx: &mut Context<Self>,329
) {330
self.slot_drag = None;331
let minute = self.minute_at_position(event.position);332
if !self333
.slot_selection334
.is_some_and(|selection| selection.contains(date, minute))335
{336
self.slot_selection = Some(self.one_slot(date, event.position));337
}338
cx.notify();339
}340
341
fn clear_slot_selection(&mut self, cx: &mut Context<Self>) {342
self.slot_drag = None;343
if self.slot_selection.take().is_some() {344
cx.notify();345
}346
}347
348
/// While a block is being picked, follow the pointer outside the grid and over349
/// meetings too. Releases are caught on the grid itself (see `grid`), whose350
/// listeners already exist when the press lands.351
fn slot_drag_listener(&self, cx: &Context<Self>) -> impl IntoElement {352
let view = cx.entity().downgrade();353
canvas(354
|_, _, _| {},355
move |_, _, window, _| {356
let moved = view.clone();357
window.on_mouse_event(move |event: &MouseMoveEvent, phase, _, cx| {358
if !phase.bubble() {359
return;360
}361
let held = event.pressed_button == Some(MouseButton::Left);362
moved363
.update(cx, |view, cx| {364
if held {365
view.drag_slot_to(event.position, cx);366
} else {367
view.end_slot_drag(cx);368
}369
})370
.ok();371
});372
},373
)374
.absolute()375
.size_full()376
}377
378
/// Invisible layer under a day's meetings that takes presses on empty slots.379
fn slot_layer(&self, date: NaiveDate, cx: &Context<Self>) -> impl IntoElement {380
let (menu_view, menu_state) = (cx.entity().downgrade(), self.state.clone());381
div()382
.id(SharedString::from(format!("calendar-slots-{date}")))383
.absolute()384
.top_0()385
.left_0()386
.size_full()387
// Capture runs before the context menu notes which element to give focus388
// back to, so Escape reaches the grid after the menu closes.389
.capture_any_mouse_down(cx.listener(|view, _: &MouseDownEvent, window, cx| {390
window.focus(&view.grid_focus, cx)391
}))392
.on_mouse_down(393
MouseButton::Left,394
cx.listener(move |view, event: &MouseDownEvent, window, cx| {395
view.press_slot(date, event, window, cx)396
}),397
)398
.on_mouse_down(399
MouseButton::Right,400
cx.listener(move |view, event: &MouseDownEvent, _, cx| {401
view.right_press_slot(date, event, cx)402
}),403
)404
.context_menu(move |menu, _, _| {405
let (view, state) = (menu_view.clone(), menu_state.clone());406
menu.item(407
PopupMenuItem::new(tr("calendar.view.new_meeting"))408
.icon(IconName::Plus)409
.on_click(move |_, window, cx| {410
let picked = view411
.update(cx, |view, cx| {412
let picked = view.slot_selection;413
view.clear_slot_selection(cx);414
picked415
})416
.ok()417
.flatten();418
match picked {419
Some(picked) => open_meeting_for(state.clone(), picked, window, cx),420
None => open_new_meeting(state.clone(), window, cx),421
}422
}),423
)424
})425
}426
427
/// The picked block: an accent fill and bar, with its times when there is room.428
fn selection_block(&self, selection: &SlotSelection) -> Div {429
let row = self.hour_height;430
let top = selection.start_minute as f32 / 60. * row;431
let height = (selection.end_minute - selection.start_minute) as f32 / 60. * row;432
// The times New meeting will open with, so the label and the form agree.433
let label = selection434
.form_times(grid_offset(), &Local)435
.label(clock_format());436
div()437
.absolute()438
.top(px(top))439
.h(px(height))440
.left_0()441
.right_0()442
.px(px(BLOCK_GAP))443
.child(444
h_flex()445
.size_full()446
.items_start()447
.overflow_hidden()448
.rounded(px(6.))449
.bg(theme::accent().opacity(SELECTION_FILL_OPACITY))450
.child(451
div()452
.flex_none()453
.w(px(STATUS_BAR_WIDTH))454
.h_full()455
.bg(theme::accent()),456
)457
.child(458
div()459
.flex_1()460
.min_w_0()461
.pl(px(5.))462
.pr(px(4.))463
.text_size(px(11.))464
.line_height(px(16.))465
.text_color(theme::accent_text())466
.truncate()467
.when(height >= SELECTION_LABEL_HEIGHT, |text| text.child(label)),468
),469
)470
}471
231
fn header(472
fn header(232
&self,473
&self,233
start: NaiveDate,474
start: NaiveDate,@@ -536,6 +777,8 @@ impl CalendarView {536
"calendar-event-{}-{}",777
"calendar-event-{}-{}",537
event.object_id, day778
event.object_id, day538
)))779
)))780
// Presses on a meeting must not reach the empty-slot layer under it.781
.block_mouse_except_scroll()539
.absolute()782
.absolute()540
.top(px(top))783
.top(px(top))541
.h(px(height))784
.h(px(height))@@ -631,13 +874,33 @@ impl CalendarView {631
let now_top = now_minute as f32 / 60. * row;874
let now_top = now_minute as f32 / 60. * row;632
let today_shown = days.iter().any(|day| day.date == today);875
let today_shown = days.iter().any(|day| day.date == today);633
let minute_y = |minute: i64| minute as f32 / 60. * row;876
let minute_y = |minute: i64| minute as f32 / 60. * row;877
let selection = self.slot_selection;878
let dragging = self.slot_drag.is_some();634
div()879
div()635
.id("calendar-grid")880
.id("calendar-grid")636
.flex_1()881
.flex_1()637
.min_h_0()882
.min_h_0()638
.overflow_y_scroll()883
.overflow_y_scroll()639
.track_scroll(&self.scroll)884
.track_scroll(&self.scroll)885
.track_focus(&self.grid_focus)886
.on_key_down(cx.listener(|view, event: &KeyDownEvent, _, cx| {887
if event.keystroke.key == "escape" && view.slot_selection.is_some() {888
view.clear_slot_selection(cx);889
cx.stop_propagation();890
}891
}))640
.on_scroll_wheel(cx.listener(Self::on_grid_scroll_wheel))892
.on_scroll_wheel(cx.listener(Self::on_grid_scroll_wheel))893
// Inside the grid, or outside it and over meetings (whose hitboxes block894
// the grid's): either way a left release ends the drag.895
.on_mouse_up(896
MouseButton::Left,897
cx.listener(|view, _: &MouseUpEvent, _, cx| view.end_slot_drag(cx)),898
)899
.on_mouse_up_out(900
MouseButton::Left,901
cx.listener(|view, _: &MouseUpEvent, _, cx| view.end_slot_drag(cx)),902
)903
.when(dragging, |grid| grid.child(self.slot_drag_listener(cx)))641
.child(904
.child(642
h_flex()905
h_flex()643
.h(px(total_height))906
.h(px(total_height))@@ -687,6 +950,7 @@ impl CalendarView {687
.h_full()950
.h_full()688
.border_l_1()951
.border_l_1()689
.border_color(theme::border())952
.border_color(theme::border())953
.child(self.slot_layer(day.date, cx))690
.children(shading)954
.children(shading)691
.children((1..24 * steps).map(|step| {955
.children((1..24 * steps).map(|step| {692
let line = div()956
let line = div()@@ -701,6 +965,11 @@ impl CalendarView {701
line.bg(theme::border().opacity(MINOR_LINE_OPACITY))965
line.bg(theme::border().opacity(MINOR_LINE_OPACITY))702
}966
}703
}))967
}))968
.children(969
selection970
.filter(|selection| selection.date == day.date)971
.map(|selection| self.selection_block(&selection)),972
)704
.children(day.blocks.iter().map(|block| {973
.children(day.blocks.iter().map(|block| {705
self.event_block(974
self.event_block(706
block,975
block,@@ -747,6 +1016,22 @@ impl CalendarView {747
}1016
}748
}1017
}749
1018
1019
/// The one UTC offset the hour grid lays every shown day out with.1020
fn grid_offset() -> FixedOffset {1021
Local::now().offset().fix()1022
}1023
1024
/// New meeting for a block picked on the grid.1025
fn open_meeting_for(1026
state: Entity<AppState>,1027
picked: SlotSelection,1028
window: &mut Window,1029
cx: &mut App,1030
) {1031
let form = picked.form_times(grid_offset(), &Local);1032
open_new_meeting_at(state, form.date, form.start, form.end, window, cx);1033
}1034
750
/// Loading line and one notice per failed source, under the calendar header.1035
/// Loading line and one notice per failed source, under the calendar header.751
fn load_notices(1036
fn load_notices(752
state: &Entity<AppState>,1037
state: &Entity<AppState>,@@ -958,11 +1243,18 @@ impl Render for CalendarView {958
let send_response = state.rsvp_send_response;1243
let send_response = state.rsvp_send_response;959
let failures = state.calendar_week.failures.clone();1244
let failures = state.calendar_week.failures.clone();960
let loading = state.calendar_week.loading && events.is_empty();1245
let loading = state.calendar_week.loading && events.is_empty();961
let offset = Local::now().offset().fix();1246
let offset = grid_offset();962
let span = state.calendar_week.span;1247
let span = state.calendar_week.span;963
let layout = state.calendar_layout();1248
let layout = state.calendar_layout();964
let dates = state.calendar_dates();1249
let dates = state.calendar_dates();965
let days = week_days(&events, &dates, offset);1250
let days = week_days(&events, &dates, offset);1251
// A picked block goes away once its day scrolls out of view or Month shows.1252
if self.slot_selection.is_some_and(|picked| {1253
span == CalendarSpan::Month || !picked.fits(&dates, self.step_minutes())1254
}) {1255
self.slot_selection = None;1256
self.slot_drag = None;1257
}966
let today = Local::now().date_naive();1258
let today = Local::now().date_naive();967
let now = Utc::now();1259
let now = Utc::now();968
let accounts = state.calendar_accounts();1260
let accounts = state.calendar_accounts();@@ -1,5 +1,5 @@
1
1
use chatsvc::Repeat;
2
use chrono::{Local, Utc};
2
use chrono::{Local, NaiveDate, NaiveDateTime, NaiveTime, Utc};
3
3
use gpui_kit::assets::IconName;
4
4
use gpui_kit::component::button::{Button, ButtonVariants as _};
5
5
use gpui_kit::component::date_picker::DatePicker;
@@ -43,8 +43,13 @@ struct MeetingForm {
43
43
}
44
44
45
45
impl MeetingForm {
46
fn new(state: Entity<AppState>, window: &mut Window, cx: &mut Context<Self>) -> Self {
47
let (start_moment, end_moment) = default_window(Utc::now(), &Local);
46
fn new(
47
state: Entity<AppState>,
48
when: Option<(NaiveDateTime, NaiveDateTime)>,
49
window: &mut Window,
50
cx: &mut Context<Self>,
51
) -> Self {
52
let (start_moment, end_moment) = when.unwrap_or_else(|| default_window(Utc::now(), &Local));
48
53
let title = cx.new(|cx| {
49
54
InputState::new(window, cx).placeholder(tr("calls.meeting.title_placeholder"))
50
55
});
@@ -244,13 +249,36 @@ pub fn open_new_meeting(state: Entity<AppState>, window: &mut Window, cx: &mut A
244
249
open_new_meeting_with(state, Vec::new(), window, cx);
245
250
}
246
251
252
/// New meeting with the date and times already set, e.g. from a block picked on the grid.
253
pub fn open_new_meeting_at(
254
state: Entity<AppState>,
255
date: NaiveDate,
256
start: NaiveTime,
257
end: NaiveTime,
258
window: &mut Window,
259
cx: &mut App,
260
) {
261
let when = (date.and_time(start), date.and_time(end));
262
open_meeting_form(state, Vec::new(), Some(when), window, cx);
263
}
264
247
265
pub fn open_new_meeting_with(
248
266
state: Entity<AppState>,
249
267
people: Vec<Pick>,
250
268
window: &mut Window,
251
269
cx: &mut App,
252
270
) {
253
let form = cx.new(|cx| MeetingForm::new(state, window, cx));
271
open_meeting_form(state, people, None, window, cx);
272
}
273
274
fn open_meeting_form(
275
state: Entity<AppState>,
276
people: Vec<Pick>,
277
when: Option<(NaiveDateTime, NaiveDateTime)>,
278
window: &mut Window,
279
cx: &mut App,
280
) {
281
let form = cx.new(|cx| MeetingForm::new(state, when, window, cx));
254
282
if !people.is_empty() {
255
283
let draft = form.read(cx).people.clone();
256
284
draft.update(cx, |draft, cx| draft.set_chips(people, cx));
@@ -1,5 +1,5 @@1
use chatsvc::Repeat;1
use chatsvc::Repeat;2
use chrono::{Local, Utc};2
use chrono::{Local, NaiveDate, NaiveDateTime, NaiveTime, Utc};3
use gpui_kit::assets::IconName;3
use gpui_kit::assets::IconName;4
use gpui_kit::component::button::{Button, ButtonVariants as _};4
use gpui_kit::component::button::{Button, ButtonVariants as _};5
use gpui_kit::component::date_picker::DatePicker;5
use gpui_kit::component::date_picker::DatePicker;@@ -43,8 +43,13 @@ struct MeetingForm {43
}43
}44
44
45
impl MeetingForm {45
impl MeetingForm {46
fn new(state: Entity<AppState>, window: &mut Window, cx: &mut Context<Self>) -> Self {46
fn new(47
let (start_moment, end_moment) = default_window(Utc::now(), &Local);47
state: Entity<AppState>,48
when: Option<(NaiveDateTime, NaiveDateTime)>,49
window: &mut Window,50
cx: &mut Context<Self>,51
) -> Self {52
let (start_moment, end_moment) = when.unwrap_or_else(|| default_window(Utc::now(), &Local));48
let title = cx.new(|cx| {53
let title = cx.new(|cx| {49
InputState::new(window, cx).placeholder(tr("calls.meeting.title_placeholder"))54
InputState::new(window, cx).placeholder(tr("calls.meeting.title_placeholder"))50
});55
});@@ -244,13 +249,36 @@ pub fn open_new_meeting(state: Entity<AppState>, window: &mut Window, cx: &mut A244
open_new_meeting_with(state, Vec::new(), window, cx);249
open_new_meeting_with(state, Vec::new(), window, cx);245
}250
}246
251
252
/// New meeting with the date and times already set, e.g. from a block picked on the grid.253
pub fn open_new_meeting_at(254
state: Entity<AppState>,255
date: NaiveDate,256
start: NaiveTime,257
end: NaiveTime,258
window: &mut Window,259
cx: &mut App,260
) {261
let when = (date.and_time(start), date.and_time(end));262
open_meeting_form(state, Vec::new(), Some(when), window, cx);263
}264
247
pub fn open_new_meeting_with(265
pub fn open_new_meeting_with(248
state: Entity<AppState>,266
state: Entity<AppState>,249
people: Vec<Pick>,267
people: Vec<Pick>,250
window: &mut Window,268
window: &mut Window,251
cx: &mut App,269
cx: &mut App,252
) {270
) {253
let form = cx.new(|cx| MeetingForm::new(state, window, cx));271
open_meeting_form(state, people, None, window, cx);272
}273
274
fn open_meeting_form(275
state: Entity<AppState>,276
people: Vec<Pick>,277
when: Option<(NaiveDateTime, NaiveDateTime)>,278
window: &mut Window,279
cx: &mut App,280
) {281
let form = cx.new(|cx| MeetingForm::new(state, when, window, cx));254
if !people.is_empty() {282
if !people.is_empty() {255
let draft = form.read(cx).people.clone();283
let draft = form.read(cx).people.clone();256
draft.update(cx, |draft, cx| draft.set_chips(people, cx));284
draft.update(cx, |draft, cx| draft.set_chips(people, cx));@@ -0,0 +1,29 @@
1
---
2
status: proposed
3
date: 2026-11-25
4
---
5
6
# ADR 0023: Picking empty calendar slots for a new meeting
7
8
## Context
9
10
Teams creates a meeting from the calendar grid: select a time range by dragging over empty slots, then New meeting, and the form opens on that range. Microsoft's help only says "Select a timeslot on the calendar or select New". The drag and right-click flow comes from the Teams desktop client and was checked against the Teams web client in review of #91. A few details had more than one reasonable answer:
11
12
- what releasing the drag does: open the form at once, or keep the block for a right-click menu;
13
- whether a block may run across days;
14
- how a block that ends at midnight goes into the form;
15
- which clock a dragged row stands for when the grid draws a day across a daylight saving switch with today's offset.
16
17
## Decision
18
19
- Releasing the drag keeps the block. Right-click on it shows New meeting. Right-click on an empty slot outside it picks that one slot first. Double-click on an empty slot opens New meeting at once, starting at that slot with the default meeting length (30 minutes), inside a picked block too. This matches the Teams web client.
20
- A block snaps to the time scale and stays in the day the drag started. The New meeting form has one date.
21
- A block that ends at 24:00 goes into the form as 23:59 and is labelled that way.
22
- The form gets the wall-clock times of the instants the dragged rows stand for on the grid (grid midnight plus minutes, converted to local time), so the meeting lands where it was dragged, also on the far side of a daylight saving switch.
23
- The block goes away on Escape, when New meeting opens, when its day leaves the view, in Month view, and when the time scale changes.
24
25
## Consequences
26
27
- The picking logic is plain functions in `app-call-model::slot_select`, unit tested apart from the view.
28
- No multi-day blocks and no auto-scroll while dragging past the grid edge. Picking a slot needs a mouse; the New meeting button stays the keyboard path.
29
- The grid itself still lays every shown day out with today's offset. Fixing that is a separate change, and `SlotSelection::form_times` must then take the same per-day origin as the grid.
@@ -0,0 +1,29 @@1
---2
status: proposed3
date: 2026-11-254
---5
6
# ADR 0023: Picking empty calendar slots for a new meeting7
8
## Context9
10
Teams creates a meeting from the calendar grid: select a time range by dragging over empty slots, then New meeting, and the form opens on that range. Microsoft's help only says "Select a timeslot on the calendar or select New". The drag and right-click flow comes from the Teams desktop client and was checked against the Teams web client in review of #91. A few details had more than one reasonable answer:11
12
- what releasing the drag does: open the form at once, or keep the block for a right-click menu;13
- whether a block may run across days;14
- how a block that ends at midnight goes into the form;15
- which clock a dragged row stands for when the grid draws a day across a daylight saving switch with today's offset.16
17
## Decision18
19
- Releasing the drag keeps the block. Right-click on it shows New meeting. Right-click on an empty slot outside it picks that one slot first. Double-click on an empty slot opens New meeting at once, starting at that slot with the default meeting length (30 minutes), inside a picked block too. This matches the Teams web client.20
- A block snaps to the time scale and stays in the day the drag started. The New meeting form has one date.21
- A block that ends at 24:00 goes into the form as 23:59 and is labelled that way.22
- The form gets the wall-clock times of the instants the dragged rows stand for on the grid (grid midnight plus minutes, converted to local time), so the meeting lands where it was dragged, also on the far side of a daylight saving switch.23
- The block goes away on Escape, when New meeting opens, when its day leaves the view, in Month view, and when the time scale changes.24
25
## Consequences26
27
- The picking logic is plain functions in `app-call-model::slot_select`, unit tested apart from the view.28
- No multi-day blocks and no auto-scroll while dragging past the grid edge. Picking a slot needs a mouse; the New meeting button stays the keyboard path.29
- The grid itself still lays every shown day out with today's offset. Fixing that is a separate change, and `SlotSelection::form_times` must then take the same per-day origin as the grid.@@ -38,5 +38,6 @@ Statuses: `proposed`, `accepted`, `superseded`.
38
38
| [0020](0020-macos-tray-and-close-to-tray.md) | macOS tray and close-to-tray match Linux |
39
39
| [0021](0021-linux-packages.md) | Linux releases also ship an AppImage, a deb and an rpm |
40
40
| [0022](0022-linux-parks-the-idle-teams-tab.md) | Linux parks the idle Teams tab in a Chromium browser |
41
| [0023](0023-calendar-slot-selection-for-new-meetings.md) | Picking empty calendar slots for a new meeting |
41
42
42
43
Records `0001` to `0021` are the decisions already shipped. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.
@@ -38,5 +38,6 @@ Statuses: `proposed`, `accepted`, `superseded`.38
| [0020](0020-macos-tray-and-close-to-tray.md) | macOS tray and close-to-tray match Linux |38
| [0020](0020-macos-tray-and-close-to-tray.md) | macOS tray and close-to-tray match Linux |39
| [0021](0021-linux-packages.md) | Linux releases also ship an AppImage, a deb and an rpm |39
| [0021](0021-linux-packages.md) | Linux releases also ship an AppImage, a deb and an rpm |40
| [0022](0022-linux-parks-the-idle-teams-tab.md) | Linux parks the idle Teams tab in a Chromium browser |40
| [0022](0022-linux-parks-the-idle-teams-tab.md) | Linux parks the idle Teams tab in a Chromium browser |41
| [0023](0023-calendar-slot-selection-for-new-meetings.md) | Picking empty calendar slots for a new meeting |41
42
42
Records `0001` to `0021` are the decisions already shipped. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.43
Records `0001` to `0021` are the decisions already shipped. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.