Skip to content

feat(ui): modernize frontend UI/UX, theming, frequency caps, and single-use links - #256

Closed
bheem1224 wants to merge 15 commits into
Calnode:mainfrom
bheem1224:pr/ui-ux-enhancements
Closed

bheem1224 wants to merge 15 commits into
Calnode:mainfrom
bheem1224:pr/ui-ux-enhancements

Conversation

@bheem1224

Copy link
Copy Markdown

Hey! I've been using Calnode and really like the core scheduling engine, so I spent some time modernizing the UI/UX and adding a few quality-of-life features in my fork. I wanted to contribute these improvements upstream so everyone can benefit.

I'm also planning a few larger backend features on my fork next (such as team/holiday OOO, dynamic group links, scheduled timezone changes, per-link webhooks, and admin user impersonation). If any of those align with your roadmap, I'd be happy to open separate PRs for them later, just let me know!

Summary of Changes

  1. Frontend UI/UX & Theme Overhaul (frontend/)
  • Theme & Layout: Added light/dark/system theme support (app.css, app.html, theme.svelte.ts, +layout.svelte, vite.config.ts).

  • Event Types & Editor:

    • Added a primary visibility toggle and overflow menu on the event types list (event-types/+page.svelte).
    • Reorganized the event editor (event-types/[slug]/+page.svelte, BookingPreviewCard.svelte, QuestionsPanel.svelte) with a dedicated Limits & Buffers submenu, per-row frequency limit dropdowns, notification tooltips, an interactive Add Question modal, and a live booking form preview (hidden on mobile to avoid cramping).
  • Core Pages: Updated availability, bookings, calendar, and login pages.

  • Settings: Improved mobile responsiveness (settings/+layout.svelte), fixed wrapping status badges (ai, branding, payments, storage, video, zoom), and simplified Google OAuth redirect URIs with Copy buttons (settings/google/+page.svelte).

  1. Public Booking Page UX (internal/handler/templates/)
  • Updated _shared.html, book.html, booking.css, directory.html, and manage.html for dark-theme consistency, clearer available/selected date states, slide-out time slots, and a full-card confirmation view.
  1. Additive Backend Features & Migrations (internal/)
  • Booking Frequency Caps: Simultaneous per-day and per-week booking caps (caps.go, 00072_event_type_frequency_caps.sql, service.go, slots_handler.go, event_type.go, mcp.go) with unit tests (service_test.go).

  • Single-Use Booking Links: Native ephemeral single-use links (single_use_handler.go, 00073_single_use_tokens.sql, book.go, booking_handler.go) with tests (single_use_test.go).

  • Microsoft OAuth Admin Settings: Admin UI (settings/microsoft/+page.svelte) and backend configuration (microsoft_settings.go, 00074_microsoft_oauth_settings.sql, auth_oauth.go, auth_microsoft.go, config.go, server.go) with tests.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

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

@bheem1224

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 15, 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.

Caution

The embedded booking widget is broken by the new booking.css layout, the single-use prefill path ships a failing test, and Microsoft SSO/JIT provisioning needs a security decision before merge. Details below.

Reviewed changes

  • Theming — new theme.svelte.ts store (fp-theme, light/dark/system), pre-paint script in app.html, dark variant rewritten to &:where(.dark, .dark *), hard-coded hex palette in app.css replacing most oklch tokens, switchers in the sidebar and on public routes.
  • Admin restyle/rework — event-types list rebuilt as cards with an overflow menu and 1-time-link actions; the event-type editor was rewritten end-to-end (Limits & Buffers panel with per-row day/week caps, BookingPreviewCard live preview, QuestionsPanel with drag reorder + add-question dialog); bookings gains list/calendar views and client-side sorting; availability gains a day toggle, copy-hours and a bulk date-override modal; calendar gains per-sub-calendar conflict switches.
  • Public booking surfaces — themeHead/themeSwitcher shared templates, a dark palette in booking.css, a right column that collapses until .card.has-day/.is-confirm, and ?name/?email/?dealId prefill plus single_use_token plumbing in book.html.
  • Frequency caps (new) — caps.go (ISO-week bucketing, CountFrequencyBookings, enforceFrequencyCaps) called from Service.Create, max_per_day/max_per_week columns (migration 00072), nullableInt PATCH semantics, slot filtering in computeSlots, exposure in MCP/assistant.
  • Single-use links (new) — migration 00073, create/list/revoke handlers, GET /t/{token}, token burn inside the booking transaction, private event types bookable when a token is presented.
  • Microsoft OAuth settings (new) — migration 00074, microsoft_settings.go GET/PUT/PATCH, DB-over-env boot load, SetAllowedSignupDomains and JIT member provisioning in finishOAuthLogin, new settings page and nav entry.

Verification I ran: go build ./... clean; go test ./internal/booking ./internal/config ./internal/db pass; go test ./internal/handler fails only on TestSingleUseLinks_lifecycleBookReplayAndManageReschedule; pnpm check (svelte-check) reports 0 errors; pnpm check:i18n passes. Note that frontend/src/routes/event-types/[slug]/+page.svelte (~3.8k lines changed) renders as “binary file or no changes” in the generated diff and had to be reviewed separately.

ℹ️ New admin UI text bypasses the i18n catalogue

The admin app has an en + fr catalogue with a source-level guard (pnpm check:i18n), but most of the new strings are hardcoded English, and one existing translated string was replaced outright, so French users now get a mixed UI. The guard passes because it only validates keys that are used, not strings that skip the catalogue.

Technical details
# New user-facing strings are not in the catalogue

## Affected sites
- `frontend/src/routes/calendar/+page.svelte:389` — `$t('calendar.addBookingsHere')` replaced by the
  hardcoded "Primary Booking Target"; `:398` "Toggle the calendars you want to check for
  conflicts:"; `:410` "Adding events to"; the `calendar.footer.manageHint` / `calendar.hint.multiCalendar`
  blocks were deleted rather than reworded.
- `frontend/src/routes/event-types/+page.svelte:266,307,313,321` — "+ New event type", "Hidden",
  "Disabled", "Public"/"Hidden" labels.
- `frontend/src/routes/bookings/+page.svelte:496,509` — "Canceled", "Soonest"/"Latest"/"Name (asc)";
  the whole new calendar toolbar ("Today", "Week", "Month", "No bookings").
- `frontend/src/routes/availability/+page.svelte` — "Unavailable", "Copied hours to selected days",
  "Date override saved", "Select at least one date.".
- `frontend/src/routes/settings/microsoft/+page.svelte` — the entire page, plus the nav entry
  `'Microsoft OAuth'` in `settings/+layout.svelte:16`.
- `frontend/src/routes/event-types/[slug]/+page.svelte` — "Max bookings per day cannot be negative.",
  the Limits & Buffers dropdown labels (`BUFFER_OPTIONS`, `NOTICE_OPTIONS`), and
  `QuestionsPanel.svelte:601` "Required"/"Optional".

## Required outcome
- New operator-visible strings go through `$t`/`tr` with entries in both `en.json` and `fr.json`;
  do not replace already-translated strings with literals.
- Keep the existing catalogue entries referenced or remove them deliberately (dead keys are not
  detected by `check-i18n.mjs`).

## Open questions for the human
- Is French coverage expected for these new screens now, or explicitly deferred? Either is fine,
  but the current mix is accidental rather than chosen.

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

Comment thread internal/handler/templates/booking.css Resolved
Comment thread internal/handler/single_use_handler.go Resolved
Comment thread internal/handler/microsoft_settings.go Resolved
Comment thread internal/handler/auth_oauth.go Resolved
Comment thread internal/handler/auth_oauth.go Resolved
Comment thread internal/booking/caps.go Resolved

@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.

Caution

The fix commit closes most of the previous review, but the booking.css right-column rewrite still leaves one of the three booking surfaces broken: /manage/{token} renders its entire action pane — the scheduled time, Reschedule, Cancel, and the cancelled/expired state messages — at width:0; opacity:0. Two smaller regressions came out of the same commit: the Microsoft identity switch changes which string is used for account lookup, and reschedule cap rejections surface as 500s.

Reviewed changes

  • Reworked the add-question dialog so addQuestion returns a success flag and the dialog closes only after a successful POST.
  • Made copy-hours create the new rules before deleting the old ones, rolling back the partial create on failure, and kept failed deletes in day.blocks on the day toggle.
  • Added CountFrequencyBookingsExcluding and enforced frequency caps in Service.Reschedule, excluding the booking being moved.
  • Switched Microsoft sign-in identity from Graph mail to userPrincipalName, rejecting #ext# guest UPNs, and made an empty client ID or secret store a nil OAuth config.
  • Blocked JIT member provisioning while the instance is unclaimed so /v1/auth/claim stays available, with a test for it.
  • Moved single-use prefill to ?name/?email query params and dropped the request fields the create endpoint never decoded.
  • Taught the embed widget to add has-day/is-confirm in applyStep, and let .card.step-right reveal the right column.

Verification I ran: go build ./... and go vet ./internal/booking ./internal/handler clean; go test ./internal/booking and go test ./internal/handler both pass now, including TestSingleUseLinks_lifecycleBookReplayAndManageReschedule. The manage-card computed styles below were measured in headless Chromium against the real booking.css at 1280px and 390px.

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

Comment thread internal/handler/templates/booking.css Resolved
Comment thread internal/handler/auth_microsoft.go Outdated
Comment on lines 115 to 122
upn := strings.ToLower(strings.TrimSpace(info.UserPrincipalName))
if strings.Contains(upn, "#ext#") {
return "", fmt.Errorf("auth: Microsoft account is a B2B guest identity, not a verifiable email")
}
email := upn
if email == "" {
upn := strings.ToLower(strings.TrimSpace(info.UserPrincipalName))
if strings.Contains(upn, "#ext#") {
return "", fmt.Errorf("auth: Microsoft account is a B2B guest identity, not a verifiable email")
}
email = upn
email = strings.ToLower(strings.TrimSpace(info.Mail))
}

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.

Switching the identity to userPrincipalName closes the unverified-mail hole, but it also changes the key used for both the users.email lookup and the allowed_signup_domains check. Calnode accounts are created from the operator-typed mailbox address, while Entra keeps many UPNs on *.onmicrosoft.com even when the mailbox is on the custom domain — those users now get a 403 (or, if the onmicrosoft.com suffix is also allowlisted, a second is_admin=0 member row) instead of signing in. Microsoft's own guidance says not to use UPN to identify a user or make authorization decisions.

Technical details
# UPN replaces the mailbox address as the account identity

## Affected sites
- `internal/handler/auth_microsoft.go:115-122` — `email := upn` with `mail` used only when UPN is empty.
- `internal/handler/auth_oauth.go:61-62` — exact-match lookup on `users.email` (created from operator input in `claim.go`/`invites.go`, i.e. the mailbox domain); there is no alias match.
- `internal/handler/auth_oauth.go:83-86` — `emailDomainAllowed` is evaluated on that same value before JIT provisioning.
- `frontend/src/routes/settings/microsoft/+page.svelte` — the field is documented as "email domains", and the same value is shared with Google sign-in, where it does mean the mailbox domain.

## Evidence
- Entra Connect: "If the UPN suffix of John, for example contoso.com, doesn't match a verified domain in Microsoft Entra ID, then Microsoft Entra ID replaces the UPN suffix with contoso.onmicrosoft.com" — https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/plan-connect-design-concepts
- "Also don't use the `upn` claim for authorization. While the UPN is unique, it often changes over the lifetime of a user principal" — https://learn.microsoft.com/en-us/entra/identity-platform/claims-validation

## Required outcome
- An existing user still signs in when their Entra UPN and mailbox differ, and the domain allowlist is still evaluated on a tenant-verified domain (never on `mail`).

## Suggested approach
- Keep the verified UPN for the allowlist decision but accept either candidate when resolving the existing `users.email` (UPN first, then `mail`, both with the `#ext#` rejection); or bind the account to `tid`+`oid` as Microsoft recommends.
- Note that the `#ext#` filter also rejects guests invited into the operator's own tenant, who resolved by `mail` before this change.

Comment thread internal/booking/service.go Resolved

@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.

Caution

The fix for the manage page's collapsed action pane trades one break for another: is-confirm also hides #cal-col, which is that page's reschedule date picker, so /manage/{token} can no longer reschedule a booking. The second commit also puts Microsoft identity back on mail, which re-opens the new JIT signup allowlist to an attribute the signing-in tenant controls.

Reviewed changes

  • Restored the manage page's right-hand action pane by adding is-confirm to both manage cards (scheduled time, Reschedule/Cancel, and the cancelled/expired state pages).
  • Switched Microsoft sign-in identity from userPrincipalName back to Graph mail (UPN as fallback) and documented the specific-tenant requirement in a code comment.
  • Made copy-hours diff-based: blocks are keyed by start_time-end_time, existing ones are reused, and only blocks absent from the template are deleted.
  • Mapped ErrFrequencyCapReached to a 409 with a readable message in both RescheduleByToken and RescheduleBooking.
  • Removed the dead dealId/PrefillDealID prefill plumbing from book.go and book.html, trimming ?name/?email on the way in.
  • Genericized test domains and base URLs from formaprime.vc to example.com.

Verification I ran: go build ./... and go vet ./internal/booking ./internal/handler ./internal/config clean; go test ./internal/booking ./internal/config pass and the full go test ./internal/handler (51s) passes. The .cal-col computed style below was measured in headless Chromium against the real booking.css.

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

Comment thread internal/handler/templates/manage.html Outdated

{{else}}
<div class="card">
<div class="card is-confirm">

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.

is-confirm brings the action pane back, but it is the same class that removes the date picker: .card.is-confirm .cal-col { display: none } (booking.css:38), and this card is the one that owns #cal-col. showView('reschedule-view') un-hides #cal-col into that cascade, so the invitee gets the slots pane, the "pick a day" hint, and no calendar — rescheduling is unusable on desktop and on the mobile m-rcal step. Measured display: none in headless Chromium against the real stylesheet; the right column itself now computes correctly (490px, opacity: 1).

Technical details
# `is-confirm` hides the manage page's reschedule calendar

## Affected sites
- `internal/handler/templates/manage.html:131` — the main card is now `class="card is-confirm"`.
- `internal/handler/templates/booking.css:38` — `.card.is-confirm .cal-col { display: none; }` (specificity 0,3,0).
- `internal/handler/templates/manage.html:167` — `#cal-col` is the date picker rendered inside that card.
- `internal/handler/templates/manage.html:319` — `showView()` toggles `hidden` on `#cal-col` for `reschedule-view`.
- `internal/handler/templates/manage.html:95` — the mobile `.cal-col` rule sets no `display`, so nothing restores it there either.

## Required outcome
- `/manage/{token}` shows the calendar when the invitee starts a reschedule, on desktop and mobile, while the scheduled time / Reschedule / Cancel pane stays visible.

## Suggested approach
- Give the manage card its own marker (e.g. `card.reveal-right`) that restores `.right-col` without the `.cal-col` hiding, or scope the cal-col rule to the surfaces that need it (`book.html`'s form/confirm steps). `is-confirm` also pins `.info` to `290px` and the card to `780px`, which a manage-specific class avoids.
- Re-check all three surfaces at 1280px and 390px afterwards.

Comment thread internal/handler/auth_microsoft.go Resolved

@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 manage-card marker restores the manage page's action pane but caps the card at 780px, which leaves the reschedule slots pane 127px wide and makes the time-period labels overlap. The Microsoft JIT gate now uses the UPN, but only for the literal common authority — organizations, Microsoft's other multi-tenant authority, still falls back to the spoofable mail attribute.

Reviewed changes

  • Replaced the is-confirm marker on both manage cards with a new manage-card class that restores .right-col and the 780px card width without triggering the .card.is-confirm .cal-col hide, so the reschedule date picker is visible again.
  • Split Microsoft sign-in identity in two: fetchMicrosoftIdentity returns Graph mail (existing-user lookup) and userPrincipalName (domain-verified), rejecting #ext# guest UPNs.
  • Added finishOAuthLoginWithJITEmail so the lookup email and the JIT-provisioned email can differ, with the UPN substituted when the OAuth authority is common; Google keeps the previous single-email path.

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

Comment thread internal/handler/templates/booking.css Resolved
Comment thread internal/handler/auth_microsoft.go Resolved

@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 in this commit — both findings from the previous review are fixed, and the layout fix is confirmed by measurement.

Reviewed changes

  • Microsoft JIT gate covers every multi-tenant authority — the new isMultiTenantMicrosoftAuthority matches common, organizations and consumers case-insensitively, so the tenant-verified UPN gates JIT provisioning under any multi-tenant alias rather than only the literal common.
  • Manage page card restored to its pre-PR width — .card.manage-card now shares the 860px has-day width and the right-column reveal moved to a :where()-scoped rule at (0,1,0), so manage.html's own mobile padding applies again.

Measured against the real booking.css in headless Chromium: at 1280px the reschedule pane is 271px wide with 63.7px period buttons, a two-column slot grid and no label overflow (previously 127px content and one column); at 700px and 500px the right column takes the page's 16px gutters. go build ./..., go vet ./internal/handler and the Microsoft/OAuth handler tests are clean.

Submitted as a comment rather than an approval because the earlier thread on internal/handler/auth_microsoft.go:115-122 — lookup by Graph mail while JIT provisions on the UPN — is still open and unchanged by this commit.

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

@shockalotti

Copy link
Copy Markdown
Contributor

Thanks for the work, but I have to be straight with you: none of this was pre-approved. There is no issue or discussion asking for a UI overhaul, and this PR links none. The admin's current look is a deliberate choice rather than neglect, and a wholesale restyle is not a direction we are looking for.

That does not make the work worthless. It means a 58-file PR that mixes a restyle, three migrations and several new features cannot be reviewed, and would not be merged even if every part of it were good.

What I would take, as separate PRs, smallest first:

  1. Microsoft Entra tenant_id support alone: the backend field, the settings input, and its migration.
  2. Single-use tokens alone.
  3. Event type frequency caps alone.
  4. Specific UI fixes that make something clearer or faster to use, broken out individually with a before/after and a sentence on what was hard. Not a restyle.

Two specifics:

  • Call it microsoft_tenant_id, not tenant_id. Our audit guard fired on this PR with "a tenant/workspace column appeared, re-check the instance-per-tenant claim". The claim is still true, because an Entra tenant is an identity-provider concept and not a Calnode tenancy model, but the name should not be ambiguous. Renaming it makes the guard pass honestly rather than by annotating around it.
  • Migration numbers: start at 00073. The 00072 in this PR is about to be taken by another change that is already green, and yours would need to move anyway. More importantly, do not open a later PR with a number below the newest applied one: goose refuses to start with "found N missing migrations before current version X", so a low-numbered migration landing after a higher one is a boot failure, not a silent skip.

If you want to start with the smallest useful piece, the Entra tenant field is the one with the clearest standalone value: it lets an operator restrict SSO to their own directory, which is a real security improvement with a contained diff.

@shockalotti

Copy link
Copy Markdown
Contributor

Good news: the maintainer has looked at the pieces separately, so here is the actual priority order rather than my guess. Same rule applies to all of them: one concern per PR, migration numbers starting at 00073 (00072 is now taken).

1. Single-use booking links. Do this one first. This is the piece that is actually needed, so it is the one worth your time. Backend plus its migration plus the UI, as one PR.

2. Microsoft OAuth admin settings. Fine to proceed, provided the feature is genuinely needed rather than a nice-to-have — please say in the PR what breaks without it. Name the column microsoft_tenant_id, not tenant_id; that keeps the instance-per-tenant claim in audit/claims.yaml unambiguous and stops the audit guard flagging your PR.

3. Light/dark theming for the admin SPA. Welcome as its own PR. Scope it to the admin and leave the public booking pages alone.

4. Any change to the public booking or manage pages needs screenshots first. Before/after, at desktop and mobile widths. Those pages are what a customer sees, so we will look at them and decide, rather than approving a diff blind.

5. The rest is fine if it is done properly, each as its own PR with a short statement of what it fixes or enables. Nothing there is blocked in principle.

One practical note: your branch is currently a single commit series on top of an older main. Starting the single-use-link work as a fresh branch off current main will save you the rebase pain later.

@bheem1224

Copy link
Copy Markdown
Author

Yeah, no problem at all! I made most of these improvements for myself and my team, and I also added other Cal.com features my team had requested in my fork. I really appreciate the work you put into the original and thought I'd contribute what I had already written.

I'll close this PR out, start a fresh branch off current main, and open a focused PR just for single-use booking links (starting at 00073), then divide up the rest of my changes later.

Btw, in the future, if you want, you can take any of the code in my fork and incorporate it into your project. Just a fair warning that my current main branch isn't completely stable since it's an ongoing upgrade based on team requests. I created a few checkpoint branches that are in a better state if you do look through it (I'd avoid branches 3a and 3b, though, because they were a little ad-hoc to add the features and lack polish in the UI, which is what I'm currently working on fixing).

@bheem1224 bheem1224 closed this Nov 17, 2026
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.

2 participants