Docs: the embed widget does not share booking-logic.js - #24
Open
distronode-com wants to merge 1 commit into
Open
Docs: the embed widget does not share booking-logic.js#24distronode-com wants to merge 1 commit into
distronode-com wants to merge 1 commit into
Conversation
The booking-calendar section told an agent that shared slot logic "lives in internal/handler/assets/booking-logic.js ... not per-surface", listing the embed widget as one of the three surfaces. Following that instruction and calling BookingLogic from embed.js ships a ReferenceError to the customer's site, where no test in this repo would see it. We came close to doing exactly that. Checked rather than assumed: - embed_handler.go embeds embed.js with //go:embed and serves the bytes unmodified (http.ServeContent over bytes.NewReader(embedJS)). Nothing prepends the module. - bookingLogicJS is referenced only by book.go and manage_handler.go, which inline it into their templates. - embed.js's own comment at line 42 already says the widget "doesn't import that module", and it carries local dowLabels, dayKey, timeLabel, shortDay and ymd for that reason. So the entry now says which two surfaces load the module, states plainly that BookingLogic is undefined in the widget and why (standalone file, Shadow-DOM component on a third-party page, no build step), and gives the rule: put shared page logic in booking-logic.js, and mirror it into the widget deliberately when the widget needs it too. CLAUDE.md only. docs/ARCHITECTURE.md §8 and the module's own header make the same claim and are corrected in the branch behind PR Calnode#23, so this one stays out of their way.
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Docs-only correction to the booking-calendar agent notes in CLAUDE.md.
- Clarify
booking-logic.jsload sites — States the module is inlined intobook.htmlandmanage.htmlonly, not all three surfaces. - Document embed isolation — Explains that
EmbedJSserves standaloneembed.js, soBookingLogicis undefined in the widget and helpers must be mirrored deliberately.
Verified against book.go / manage_handler.go (only bookingLogicJS consumers), embed_handler.go (unmodified //go:embed serve), and the local helpers in embed.js. Leaving ARCHITECTURE.md §8 and the booking-logic.js header to #23 is intentional and merge-order-safe.
Grok | 𝕏
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.

CLAUDE.mdtells an agent the embed widget sharesbooking-logic.js. It does not.The booking-calendar section lists three surfaces and then says shared slot logic "lives in
internal/handler/assets/booking-logic.js… not per-surface: … Put anything all three needthere rather than writing it three times."
Following that and calling
BookingLogicfromembed.jsthrows aReferenceErroron thecustomer's site, where nothing in this repo would catch it. We came close to shipping
exactly that.
Checked rather than assumed:
embed_handler.goembedsembed.jswith//go:embedand serves the bytes unmodified(
http.ServeContentoverbytes.NewReader(embedJS)). Nothing prepends the module.bookingLogicJSis referenced only bybook.goandmanage_handler.go, which inline itinto their templates.
embed.js's own comment already says the widget "doesn't import that module", and itcarries local
dowLabels,dayKey,timeLabel,shortDayandymdfor that reason.The change
CLAUDE.mdonly, 11 lines. The entry now names the two surfaces that load the module,states plainly that
BookingLogicis undefined in the widget and why (standalone file,Shadow-DOM component on a third-party page, no build step), and gives the rule: put shared
page logic in
booking-logic.js, and mirror it into the widget deliberately when the widgetneeds it too.
docs/ARCHITECTURE.md§8 and the module's own header make the same claim. Those arecorrected in the branch behind #23, so this PR deliberately stays out of their way and
touches neither — the two can merge in either order.
go test ./...green,gofmt -l .empty,go vet ./...clean (nothing executable changed).