Suggest four times from the host's own free space - #39
Merged
Conversation
With a calendar connected, the create screen can now fill the poll in itself: "Suggest 4 times" reads the host's free/busy and proposes four candidate slots — weekdays only, between 10:00 and 16:00 in the poll's timezone, and at most one morning and one afternoon on any given day, so four options can't all be one Tuesday. The picking is a pure function (`suggestFreeSlots`, unit-tested) fed the same per-day busy segments the week grid shades from, so a suggestion lands exactly where the shading says the host is free. Spread beats density: one option per day first, alternating which half of the day it tries so the set isn't four identical 10am slots, doubling up only once the days run out. Afternoons prefer 13:00 onwards and drop into the lunch hour only when nothing later fits; starts snap to the same 30-minute grid a drawn slot does; slots the poll already has count as busy, so clicking again adds four more rather than four duplicates. The click reads the whole 21-day range itself rather than trusting whichever weeks the grid has loaded, and aborts if a connected provider's read fails — half a diary would propose times the host isn't free for. The grid then jumps to the week the first suggestion landed in, since slots off-screen look like nothing happened. `zonedDayAndMinute` moves into time.ts (it was hostCalendar's private `zonedParts`) so "now" and the busy segments are read in one frame, and `calendarWeekday` joins it for the Mon–Fri test. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4A85YwKbANRATBa496oug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With a calendar connected, the create screen can now fill the poll in itself. Beside the week view, "Suggest 4 times" reads the host's free/busy and proposes four candidate slots — weekdays only, between 10:00 and 16:00 in the poll's timezone, and at most one morning and one afternoon on any given day, so four options can't all be one Tuesday. They're ordinary slots once added: drag to move, click to remove, click the button again for four more.
How it picks
suggestFreeSlotsinsrc/lib/autoSlots.tsis a pure function fed the same per-day busy segments the week grid shades from, so a suggestion lands exactly where the shading says the host is free.Wiring
CreatePoll.suggestTimesfetches the whole 21-day scan range itself rather than trusting whichever weeks the grid happens to have loaded, and aborts if any connected provider's read fails — half a diary would propose times the host isn't actually free for. The grid then jumps to the week the first suggestion landed in (newfocusprop onCalendarWeekView), since slots off-screen look like nothing happened.hostCalendar's privatezonedPartsmoves intotime.tsaszonedDayAndMinute, so "now" and the busy segments are read in one frame;calendarWeekdayjoins it for the Mon–Fri test.Testing
npm test— 77 passed, 13 of them new: the 10–4 window, the weekend skip, the one-morning-one-afternoon rule, the lunch-hour fallback, existing-slot avoidance, partial results when the diary is full, and a timezone-frame test that fails if the busy data is read in UTC instead of the poll's zone.npm run typecheckandnpm run buildboth clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01W4A85YwKbANRATBa496oug
Generated by Claude Code