Repository navigation
fix(booking): a confirmed booking is a final state on all three surfaces (#268) - #284
dominik-myszkowski wants to merge 2 commits into
Conversation
…ces (Calnode#268) book.html left its calendar clickable after confirming and re-enabled the submit button, inviting a second booking under a different email, which max_active_bookings cannot catch. - book.html: finalize() on success and on the Stripe return disables the calendar, month navigation, timezone and submit and resets the form; every handler checks the flag. A submitting flag drops a second submit while the first is in flight. "Book another time" is a fresh load without the Stripe return parameters. - embed.js: the calendar renders disabled in the confirm view and a second submit is refused. "Book another time" resets the widget's own state and reloads the month; it never navigates the host page. - manage.html: the rescheduled and cancelled views are final; showView no longer leaves them and neither action can be sent again. New booker key book_another_time in every locale. TestBookPage_confirmationIsFinal runs book.html's real page script under node against a small fake DOM and checks that a second submit sends nothing; the widget and manage page are pinned at source level.
There was a problem hiding this comment.
Important
One user-facing regression in the mobile Stripe-return path: the confirmation is hidden and the page is inert. Details inline.
Approach: sound — the guard lives in each surface's own script (finalized / submitting / state.view === 'confirm') rather than only in markup, so every handler is covered, and the book.html half is exercised by running the real rendered script under node instead of asserting on source strings. The one gap is where the page's step-flow and the new final state disagree.
Reviewed changes
book.html—finalize()runs on the free submit success path and on the?paid=1return: calendar, month nav, timezone and submit are disabled, the form is reset, the card getsis-final, and every handler early-returns onfinalized. Asubmittingflag drops a double submit while the first request is in flight (the success path no longer re-enables the button), and "Book another time" is a fresh load that keeps other query params but dropspaid/session_id.embed.js—state.view === 'confirm'renders days, prev and next disabled,nav()and the submit handler refuse, and "Book another time" resets the widget in place and reloads the month instead of navigating the host page.manage.html— the rescheduled and cancelled views are terminal:showViewwill not leave them and neither confirm handler can send twice.booking.css/ i18n — one shared.book-anotherstyle for the page link and the widget button,.card.is-finaldimming, andbook_another_timein all 12 booker locales.- Tests / docs —
TestBookPage_confirmationIsFinaldrives the real page script through thesubmitandpaidscenarios against a fake DOM; the widget and manage halves are pinned at source level. ARCHITECTURE §9 and the CHANGELOG entry describe the new invariant.
ℹ️ A booking made through the assistant still leaves the page fully live
Both surfaces gained a "confirmed is final" state, but the conversational path that also creates bookings never enters it. After the assistant reports done with a booking (book.html:976, embed.js:415), only the chat transcript and the analytics event change — the calendar, slots and form stay interactive, so the visitor can still book again from the page the PR just declared final. That is the same duplicate-under-a-different-email hazard, reachable through a different entry point on the same screen. Worth deciding explicitly: call finalize() on the done booking in book.html (and set the widget's view accordingly) or record why the chat is allowed to stay live.
Technical details
# Assistant bookings bypass the final state
## Affected sites
- `internal/handler/templates/book.html:976` — `obj.type === 'done'` only stores `booking`; nothing touches `finalized` or the views.
- `internal/handler/templates/book.html:1006` — the only post-booking side effect is the dataLayer push.
- `internal/handler/embed.js:415` — the widget's `done` handler likewise only records `booking`; the form path (`embed.js:699`) sets `state.view = 'confirm'`, the assistant path does not.
## Required outcome
- Either a booking completed in chat puts its surface into the same final state as the form path, or the deferral is deliberate and documented (ARCHITECTURE §9 / the assistant section), so the next person does not read "final on all three surfaces" as covering every booking route.
## Suggested approach (optional)
- `book.html`: on `done` with a booking, set `#confirm-time` from the booking and call `finalize()`.
- `embed.js`: the assistant drawer lives inside the widget, so switching to `confirm` needs a slot to render; the returned booking carries `start_at`, or fall back to leaving the chat as the deliberate "book again" path and say so.deepseek-v4.1-flash | 𝕏
On the return from Stripe Checkout finalize() shows the confirmation, but the step-flow init then set the calendar step, which on a narrow viewport hides the right pane: a disabled calendar and no confirmation. The init now opens a final page on the right pane.
event_types.redirect_url and redirect_with_booking_id (migration 00077): where the booker goes once a booking is confirmed, typically the operator's thank-you page, optionally with ?booking_id= appended (off by default; the booking id is a lookup key). The value is an open-redirect surface, so it is checked three times: validRedirectURL on save (absolute https, a host, no credentials, no whitespace or control characters, <= 2000 chars), servedRedirectURL when a page or the widget is given it (an invalid stored value is served as none and logged), and BookingLogic.redirectTarget in the browser before use, mirrored in embed.js. - book.html: finalize() shows "Continue" and navigates after 1.5 s, leaving time for the conversion push. Covers the Stripe return too: the success URL now carries booking_id. - embed.js: never navigates the host page; "Continue" opens the redirect in a new tab (noopener). - manage.html: no redirect; a reschedule or cancel is not a conversion. - Admin: URL field and booking-id checkbox in the General tab (en/fr). - New booker key "continue" in every locale. Builds on the final confirmation state from the previous commit (Calnode#284).
There was a problem hiding this comment.
✅ No new issues found.
Approach: right — the init step-flow is guarded on finalized rather than calling setStep() from the paid IIFE, which keeps cardEl out of the TDZ.
Reviewed changes
- Guarded the mobile step-flow so a page that is already final opens on the right pane: the init call is now
setStep(finalized ? 'right' : 'cal')(book.html:444), replacing the unconditionalsetStep('cal')that left the Stripe return on the calendar step where.card.m-cal .right-col { display: none }hid#confirm-view. - Extended the node
paidscenario intestdata/book_final_state.jsto assert the card carriesm-rightand notm-cal, so the CSS-driven regression is now covered rather than only thehiddenclass.
The inline thread on the mobile Stripe return is addressed by 0b24ebf and has been resolved. TestBookPage_confirmationIsFinal (both scenarios), TestManagePage_successIsFinal and TestEmbedJS_confirmationIsFinal pass locally with node 24 and go 1.26.
deepseek-v4.1-flash | 𝕏

The bug half of #268, on all three surfaces as you asked. After a booking is confirmed, the confirmation is a final state: nothing leads back into the form, and "Book another time" starts over cleanly. The
redirect_urlhalf will follow as its own PR.Booking page (
book.html)finalize()runs on success and on the return from Stripe Checkout (?paid=1).finalizedflag, rather than relying on the markup alone.submittingflag also drops a second submit while the first request is in flight (double click, Enter).paid/session_idbut keeping other params such aslang. A reload is the only reset where no picked day, slot or host state can survive.Embed widget (
embed.js)is-final.Manage page (
manage.html)You flagged this one, and here is how I read it. Its success views (rescheduled, cancelled) were already almost final: the calendar column hides, and the views have no buttons. What was missing was a guard. The page's
CURRENT_ISOand picked slot describe the booking as it was, so acting on them again would be wrong. Now:showViewno longer leaves a success view;I deliberately did not add a "book another time" link here: in a reschedule context there is nothing sensible for it to mean, and a reload shows the booking as it now is.
Shared bits
booking.css:.book-another, styled once for the page link and the widget button, plus.card.is-final .cal-col { opacity: .5 }.book_another_timein all 12 locale files (the non-English ones are drafts, like the rest).Fixedentry.Tests
TestBookPage_confirmationIsFinalis the "second submit is refused" test you asked for. It renders the realbook.html, extracts the page script, and runs it under node against a small fake DOM (testdata/book_final_state.js). It skips without node, like the CLDR cross-check, and node is in the CI job. Two scenarios:submit: pick a day and slot, double-submit while the request is in flight (one POST), confirm, then try a calendar day, a slot and another submit (still one POST, nothing reopens). It also checks that the form is reset and that the "Book another time" href is clean.paid: land on?paid=1&session_id=…&lang=pl. The page is final with zero POSTs, and the link drops the Stripe params but keepslang.main. Removing only thefinalizedguard from the submit handler fails it too.TestEmbedJS_confirmationIsFinalandTestManagePage_successIsFinalpin the widget and manage guards at source level, the same way as the other widget tests. The widget test also checks thatbookAnothernever toucheslocation.gofmt,go vet ./...,go build ./...,go test ./...,go run ./cmd/i18n-coverageandmake buildpass locally.I also checked against a running binary in Chromium (Playwright) at 1280×800 and 390×844, plus the widget on a page served from another origin. On each, a double-click on submit sent one POST. After confirmation, no day button was enabled, and a forced day click and a scripted
requestSubmit()changed nothing. "Book another time" restored a working calendar, and the widget never changed the host page's URL. I did not exercise the manage page in a browser.