Skip to content

Commit 91c455b

Browse files
committed
Add day timeline and availability/proximity views to meeting picker
1 parent 351b36f commit 91c455b

8 files changed

Lines changed: 594 additions & 96 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## Unreleased
44

5+
- Open meeting availability on the original day with consecutive, duration-preserving
6+
slots. Add availability and proximity rankings, local previous/next-day navigation,
7+
full time intervals, and aligned participant gutters. Unknown schedules never count
8+
as free; day/view changes reuse the loaded schedules.
9+
510
- Anchor every inbox column boundary, including exactly full and truncated
611
cells, and widen meeting-column separators to keep unread bold rows aligned.
712

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test: test-elisp test-python
88
test-elisp:
99
$(EMACS) -Q --batch -L . -L tests \
1010
-l tests/teams4e-tests.el -l tests/teams4e-companion-tests.el \
11-
-l tests/teams4e-compose-tests.el \
11+
-l tests/teams4e-compose-tests.el -l tests/teams4e-availability-tests.el \
1212
-f ert-run-tests-batch-and-exit
1313

1414
test-python:

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ suit your setup. mu4e, Evil, Spacemacs, and AI services are not required.
2727
message navigation, and optional rich rendering, link-hint, and
2828
expand-region integration.
2929
- A meeting view with start times, intervals, participants, location, RSVP,
30-
joining, and an availability workspace for proposing another time.
30+
joining, and an availability workspace for proposing another time: a daily
31+
timeline, availability and proximity rankings, and participant calendar blocks.
3132
- Optional Agent Shell commands for analysing an exported thread or discussing
3233
outstanding requests. These run only when invoked.
3334

‎USAGE.md‎

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,39 @@ older messages while the request is pending keeps your reading position.
238238
Message links still select their target. Existing Customize or init-file
239239
values override these defaults; remove or update older overrides to adopt them.
240240

241-
In the availability buffer, `j`/`k` select an interval and `RET`
242-
proposes it. Use `s`/`b` for suggestions/calendar blocks, `r` to
243-
change the range, `w` to cycle work/personal/unrestricted hours, and
244-
`m` for an exact manual start.
241+
The availability workspace opens on the original meeting's day, near its
242+
original time. It shows consecutive slots, including busy and unknown ones,
243+
rather than only Outlook's short list of recommendations.
244+
245+
| Default key | Availability view/action |
246+
| --- | --- |
247+
| `d` | Day timeline: consecutive slots, grouped under a full date heading |
248+
| `a` (also `s`) | Best availability across the loaded range; ties prefer the original time |
249+
| `c` | Closest to the original start; ties prefer better availability |
250+
| `[` / `]` | Previous/next calendar day |
251+
| `=` | Return to the original meeting day |
252+
| `b` | Calendar blocks, with privacy-aware details |
253+
| `j` / `k`, `RET` | Select a slot, propose it |
254+
| `r`, `g`, `m` | Change loaded range, refresh, enter an exact manual start |
255+
256+
These bindings are customizable in `teams4e-availability-mode-map`.
257+
Time intervals are never shortened with an ellipsis; participant columns have
258+
explicit alignment gutters and full names on hover. Cross-midnight intervals
259+
show a day offset. All times are local.
260+
261+
Slots keep the meeting's exact duration and advance by
262+
`teams4e-meeting-availability-interval` (30 minutes by default). All hours are
263+
shown, not only work hours. The Free percentage is the number of participants
264+
confirmed free for the **whole** slot divided by all participants; it is not
265+
Outlook's recommendation confidence. Missing/denied/truncated schedule data
266+
stays Unknown and never counts as free. Availability is a snapshot, not a
267+
reservation; refresh before sending when necessary.
268+
269+
Changing views or days inside the loaded range uses the existing schedules.
270+
Crossing its boundary fetches a new window; `r` sets an explicit range.
271+
The older prompt-based proposal flow still uses Outlook recommendations and
272+
`teams4e-meeting-proposal-activity-domain`; the consecutive-slot views do not
273+
hide nights, weekends, conflicts, or unknowns based on that setting.
245274

246275
Private calendar blocks never expose returned subject or location through this
247276
UI. Advanced event creation, recurrence, organizer moves, and cancellation

‎teams4e-meetings.el‎

Lines changed: 374 additions & 89 deletions
Large diffs are not rendered by default.
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
;;; teams4e-availability-tests.el --- Availability picker tests -*- lexical-binding: t; -*-
2+
(unless (fboundp 'teams4e-test-availability-context)
3+
(load "teams4e-tests" nil t))
4+
5+
(defmacro teams4e-test-with-availability (&rest body)
6+
"Run BODY in a synthetic availability workspace with a three-day window."
7+
(declare (indent 0))
8+
`(let ((process-environment (copy-sequence process-environment))
9+
(teams4e-meeting-availability-interval 30))
10+
(setenv "TZ" "UTC")
11+
(with-temp-buffer
12+
(teams4e-availability-mode)
13+
(let ((context (teams4e-test-availability-context)))
14+
(setq teams4e-availability--chat (teams4e--get context 'chat)
15+
teams4e-availability--event-id "event-availability"
16+
teams4e-availability--payload (teams4e--get context 'payload)
17+
teams4e-availability--window
18+
(list (date-to-time "2099-08-10T00:00:00Z")
19+
(date-to-time "2099-08-13T00:00:00Z"))))
20+
,@body)))
21+
22+
(ert-deftest teams4e-availability-continuous-day-preserves-duration ()
23+
(teams4e-test-with-availability
24+
(should (eq teams4e-availability--view 'timeline))
25+
(let ((slots (teams4e-availability--suggestions)) previous)
26+
(should (= 48 (length slots)))
27+
(dolist (entry slots)
28+
(let* ((slot (teams4e--get entry 'meetingTimeSlot))
29+
(start (teams4e-availability--time slot 'start))
30+
(end (teams4e-availability--time slot 'end)))
31+
(should (= 2700 (float-time (time-subtract end start))))
32+
(when previous
33+
(should (= 1800 (float-time (time-subtract start previous)))))
34+
(setq previous start))))
35+
(teams4e-availability--render)
36+
(should (equal "09:00 - 09:45"
37+
(teams4e-availability--time-label
38+
(teams4e--get (teams4e-availability--selected-suggestion)
39+
'meetingTimeSlot))))
40+
(teams4e-availability-next)
41+
(should (equal teams4e-availability--selected-id
42+
(get-text-property (point) 'teams4e-availability-id)))
43+
(should (string-match-p "09:30 - 10:15" (thing-at-point 'line t)))))
44+
45+
(ert-deftest teams4e-availability-day-navigation-is-local-and-reversible ()
46+
(teams4e-test-with-availability
47+
(cl-letf (((symbol-function 'teams4e--run-json)
48+
(lambda (&rest _) (ert-fail "Unexpected network request"))))
49+
(teams4e-availability-next-day)
50+
(should (equal "2099-08-11"
51+
(format-time-string "%F" teams4e-availability--day)))
52+
(should (equal "09:00 - 09:45"
53+
(teams4e-availability--time-label
54+
(teams4e--get (teams4e-availability--selected-suggestion)
55+
'meetingTimeSlot))))
56+
(teams4e-availability-previous-day)
57+
(should (equal "2099-08-10"
58+
(format-time-string "%F" teams4e-availability--day)))
59+
(teams4e-availability-next-day 2)
60+
(teams4e-availability-original-day)
61+
(should (equal "2099-08-10"
62+
(format-time-string "%F" teams4e-availability--day))))
63+
(let (requested)
64+
(cl-letf (((symbol-function 'teams4e-availability--request)
65+
(lambda () (setq requested t))))
66+
(teams4e-availability-previous-day)
67+
(should requested)
68+
(should (equal teams4e-availability--day
69+
(car teams4e-availability--window)))))))
70+
71+
(ert-deftest teams4e-availability-rankings-have-different-stable-orders ()
72+
(teams4e-test-with-availability
73+
(teams4e-availability-show-proximity)
74+
(let* ((slots (teams4e-availability--suggestions))
75+
(first (teams4e--get (car slots) 'meetingTimeSlot))
76+
(original (teams4e-availability--original-time)))
77+
(should (equal original (teams4e-availability--time first 'start)))
78+
(let ((previous -1))
79+
(dolist (entry slots)
80+
(let ((distance
81+
(abs (float-time
82+
(time-subtract
83+
(teams4e-availability--time
84+
(teams4e--get entry 'meetingTimeSlot) 'start)
85+
original)))))
86+
(should (>= distance previous))
87+
(setq previous distance)))))
88+
(teams4e-availability-show-suggestions)
89+
(let ((previous 101))
90+
(dolist (entry (teams4e-availability--suggestions))
91+
(let ((score (teams4e--get entry 'confidence)))
92+
(should (<= score previous))
93+
(setq previous score))))
94+
(should (string-match-p "09:00 - 09:45" (buffer-string)))
95+
(teams4e-availability-show-timeline)
96+
(should (= 48 (length teams4e-availability--row-ids)))))
97+
98+
(ert-deftest teams4e-availability-checks-whole-slot-and-missing-data ()
99+
(teams4e-test-with-availability
100+
(teams4e-availability-next-day)
101+
(let* ((participant (cadr (teams4e-availability--participants)))
102+
(slot (teams4e--get
103+
(nth 19 (teams4e-availability--suggestions)) 'meetingTimeSlot))
104+
(schedule (teams4e-availability--schedule participant)))
105+
(nconc schedule '((error) (availabilityView)))
106+
;; 09:30-10:15 overlaps the 10:00 busy block.
107+
(should (equal "busy" (teams4e-availability--slot-status participant slot)))
108+
(setf (alist-get 'error schedule) '((message . "Denied")))
109+
(should (equal "unknown" (teams4e-availability--slot-status participant slot)))
110+
(setf (alist-get 'error schedule) nil
111+
(alist-get 'scheduleItems schedule) nil
112+
(alist-get 'availabilityView schedule) (make-string 144 ?0))
113+
(aset (alist-get 'availabilityView schedule) (+ 48 20) ?2)
114+
(should (equal "busy" (teams4e-availability--slot-status participant slot)))
115+
(setf (alist-get 'availabilityView schedule) "0")
116+
(should (equal "unknown" (teams4e-availability--slot-status participant slot)))
117+
(setf (alist-get 'schedules teams4e-availability--payload) nil)
118+
(should (equal "unknown" (teams4e-availability--slot-status participant slot))))))
119+
120+
(ert-deftest teams4e-availability-local-days-handle-dst ()
121+
(let ((process-environment (copy-sequence process-environment)))
122+
(setenv "TZ" "America/New_York")
123+
(let* ((start (encode-time 0 0 0 8 3 2026))
124+
(end (teams4e-availability--midnight start 1)))
125+
(should (= (* 23 3600) (float-time (time-subtract end start)))))
126+
(let* ((start (encode-time 0 0 0 1 11 2026))
127+
(end (teams4e-availability--midnight start 1)))
128+
(should (= (* 25 3600) (float-time (time-subtract end start)))))))
129+
130+
(ert-deftest teams4e-availability-proposes-from-each-time-view ()
131+
(teams4e-test-with-availability
132+
(dolist (view '(timeline availability proximity))
133+
(teams4e-availability-set-view view)
134+
(let (sent)
135+
(cl-letf (((symbol-function 'teams4e--proposal-send)
136+
(lambda (_chat _event-id slot &rest _)
137+
(setq sent slot))))
138+
(teams4e-availability-choose))
139+
(should sent)
140+
(should (= 2700 (float-time
141+
(time-subtract
142+
(teams4e-availability--time sent 'end)
143+
(teams4e-availability--time sent 'start)))))))
144+
(teams4e-availability-show-blocks)
145+
(should-error (teams4e-availability-choose) :type 'user-error)))
146+
147+
(provide 'teams4e-availability-tests)
148+
;;; teams4e-availability-tests.el ends here

‎tests/teams4e-tests.el‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1664,14 +1664,15 @@
16641664
(teams4e-availability-mode)
16651665
(setq teams4e-availability--chat chat
16661666
teams4e-availability--event-id "event-availability"
1667+
teams4e-availability--view 'suggestions
16671668
teams4e-availability--payload payload
16681669
teams4e-availability--window
16691670
(list (date-to-time "2099-08-11T00:00:00Z")
16701671
(date-to-time "2099-08-12T00:00:00Z")))
16711672
(teams4e-availability--render)
16721673
(should (= 2 (length teams4e-availability--row-ids)))
16731674
(should (string-match-p "Architecture review" (buffer-string)))
1674-
(should (string-match-p "100% confidence" (buffer-string)))
1675+
(should (string-match-p "100% confirmed free" (buffer-string)))
16751676
(should (string-match-p "Everyone is available" (buffer-string)))
16761677
(should (string-match-p "Ada Lovelace" (buffer-string)))
16771678
(teams4e-availability-next)

‎tools/capture-demo.el‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,35 @@
175175
(goto-char (point-min))
176176
(search-forward "Video room 4" nil t))))))
177177
(teams4e-capture-frame "meetings.png")
178+
(teams4e-meeting-availability
179+
(teams4e--find-chat "mock-chat-future-meeting"))
180+
(teams4e-capture-wait
181+
(lambda ()
182+
(with-current-buffer teams4e--availability-buffer-name
183+
teams4e-availability--payload)))
184+
(switch-to-buffer teams4e--availability-buffer-name)
185+
;; Keep seven synthetic participants visible to exercise a crowded matrix.
186+
(cl-loop for name in '("Katherine Johnson" "Alan Turing"
187+
"Margaret Hamilton" "Edsger Dijkstra"
188+
"Barbara Liskov" "Donald Knuth")
189+
for index from 0
190+
while (< (length (teams4e-availability--participants)) 7)
191+
do
192+
(let ((email (format "capture-%s@example.test" index)))
193+
(setf (alist-get 'participants teams4e-availability--payload)
194+
(append (teams4e-availability--participants)
195+
(list `((email . ,email) (name . ,name))))
196+
(alist-get 'schedules teams4e-availability--payload)
197+
(append (teams4e-availability--schedules)
198+
(list `((scheduleId . ,email) (scheduleItems)))))))
199+
(dolist (width '(180 130))
200+
(set-frame-size nil width 44)
201+
(dolist (view '(timeline availability proximity))
202+
(teams4e-availability-set-view view)
203+
(unless (> (length teams4e-availability--row-ids) 20)
204+
(error "Availability matrix has no continuous slots"))
205+
(teams4e-capture-frame
206+
(format "availability-%s-%s.png" view width))))
178207
(with-temp-file (expand-file-name "capture.json" teams4e-capture-output)
179208
(insert (json-serialize
180209
`((emacs . ,emacs-version)

0 commit comments

Comments
 (0)