Skip to content

feat(booking): optional next available time above the slot picker (#254) - #275

Open
KishenG wants to merge 3 commits into
Calnode:mainfrom
KishenG:next-available
Open

KishenG wants to merge 3 commits into
Calnode:mainfrom
KishenG:next-available

Conversation

@KishenG

@KishenG KishenG commented Nov 25, 2026

Copy link
Copy Markdown

Adds an opt-in show_next_available event type setting, default off. When on, a button above the time list shows the soonest free time, such as "Next available: Wed, Dec 9, 10:00 AM", and opens that day when clicked. This is the change agreed in #254.

How it follows the points raised there:

  • Setting: migration 00073 follows 00057. Column, JSON field, create and PATCH handlers, the select lists, event_type_duplicate.go, and a checkbox in the event type editor next to the booked-times one.
  • Free times only: it never reads the merged free and taken view, so it cannot advertise a struck-through time.
  • Empty months: it walks forward month by month and stops at maxDate, so it cannot run past max_future_days.
  • Failed or degraded checks: a failed request or a degraded response shows nothing.
  • Timezone: the server already applies it to /slots. The page only formats, with the existing formatters. A timezone change restarts the search.
  • Markup: a real <button>, styled like a time button in booking.css.
  • Logic: earliestFreeSlot and monthsToProbe are in booking-logic.js with unit tests.
  • i18n: one English key, next_available_hint. The admin strings are en and fr.
  • Both pages: book.html and manage.html change together. On the reschedule page the booking's own current time is left out, so it offers the next time the booking could move to.
  • Embed widget: left for a follow-up PR, as you suggested. It does not load booking-logic.js, so it needs its own mirrored copy.

On narrow screens the calendar step hides the right column, so a second copy of the button sits above the calendar there, and booking.css shows one at a time.

ARCHITECTURE.md has a new subsection beside the booked-times one, and the CHANGELOG has an entry.

Checked:

  • go test ./..., go vet ./... and gofmt -l . are clean.
  • node --test internal/handler/assets/booking-logic.test.js: 20 pass.
  • Admin: pnpm check, pnpm check:i18n and pnpm build pass.
  • Chromium, booking and reschedule pages at desktop width and 390 px: the button shows, opens the right day, is hidden when the slots response is degraded, and there are no page errors.
  • Not run: pnpm test:visual (no change to the ui components, app.css or the theme) and the embed widget (untouched).
next-available-reschedule next-available-slot

…lnode#254)

A per-event-type setting, off by default, adds a button above the time list that opens the soonest free day. Worked out from the free slots only, bounded by max_future_days, and silent on a failed or degraded check. Shown on the booking and reschedule pages; the embed widget is left for a follow-up.
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@KishenG

KishenG commented Nov 25, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Nov 25, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new button's label renders as the literal string next_available_hint on every non-English locale. t() on both pages is I18N[key] || key, and I18N is loc.JSON() — the resolved locale's strings only, with no English merge — so the missing key surfaces on the page instead of falling back to English.

Approach: sound — one opt-in column threaded through create/PATCH/duplicate and both server-rendered surfaces, with the search itself in the shared, unit-tested booking-logic.js rather than reimplemented per page, and the embed widget deferred until it can load that module.

Reviewed changes

  • Setting and API — migration 00073 (DEFAULT 0, mirroring 00057), the shared column list and row scan, create and PATCH, the duplicate copy, and the admin type/checkbox with en/fr copy.
  • Booking and reschedule pages — loadNextAvailable on both surfaces, the desktop/mobile pair of buttons, booking.css, and the one new public i18n key.
  • Shared helpers and tests — earliestFreeSlot, monthsToProbe and six node tests, plus Go tests for the opt-in round-trip and for both pages' markup.
  • Docs — CHANGELOG entry and the ARCHITECTURE subsection beside the booked-times one.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash | 𝕏

Comment thread internal/i18n/locales/en.json Resolved
Comment thread internal/handler/templates/book.html Resolved
- Add next_available_hint to every locale. The pages' client-side t() reads the
  locale's own strings with no English merge, so a locale without the key showed
  the raw key name.
- Drop the booking's own slot by instant rather than by string. /slots spells
  starts in the requested timezone, so outside UTC the string never matched.
- Share one in-flight /slots request per month and timezone between the calendar
  and the next-available search, so opting in no longer doubles the first request.
Call it a button throughout, match the admin hint examples to the page label, and drop a stray blank line.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: unchanged — the follow-ups fix the three review points inside the existing design (shared booking-logic.js helper, one opt-in column, both server-rendered pages) without broadening scope.

Reviewed changes

Reviewed the two commits since the prior pullfrog review (4f47a01, 167dda5):

  • Locale coverage — next_available_hint is now in all 11 non-English catalogues, so the client-side I18N[key] || key fallback can no longer render the raw key.
  • Instant-based slot exclusion — earliestFreeSlot compares Date.parsed starts, with a regression test covering Z vs +02:00 spellings.
  • Shared slots request — both pages route /slots through a per-URL in-flight promise, so the calendar and the next-available probe share the visible month's response instead of fetching it twice.
  • Copy and comments — example dates in the CHANGELOG and admin hint, the migration comment, and the test names were tidied.

Verified locally: go test ./internal/i18n/, node --test internal/handler/assets/booking-logic.test.js (21 pass), and the targeted next-available/duplicate handler tests all pass.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash | 𝕏

@KishenG

KishenG commented Nov 28, 2026

Copy link
Copy Markdown
Author

Thanks for the review. All three points were right, and the fixes are in the second commit (the third only tidies wording):

  • next_available_hint on other locales: added to all 11 files, with the %[1]s, %[2]s order kept. The key is read client-side, where t() has no English fallback. That also means any key a partial locale lacks would show its name on the page. I have not changed that here because it affects every public-surface key.
  • Excluding the booking's own slot: earliestFreeSlot now compares instants, and a test uses mixed Z and +02:00 spellings. groupSlotsByDay has the same string comparison for the calendar. I left it alone as it is outside this change.
  • Duplicate /slots request: both pages now share one in-flight request per month and timezone. The calendar and the search no longer fetch the same month twice, and nothing is cached after the response arrives.

Checked again in Chromium on both pages: one /slots request on load, the French label renders, and the reschedule page skips the booking's own time in a non-UTC timezone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant