Skip to content

Docs: the embed widget does not share booking-logic.js - #24

Open
distronode-com wants to merge 1 commit into
Calnode:mainfrom
distronode-com:docs/embed-does-not-share-booking-logic
Open

Docs: the embed widget does not share booking-logic.js#24
distronode-com wants to merge 1 commit into
Calnode:mainfrom
distronode-com:docs/embed-does-not-share-booking-logic

Conversation

@distronode-com

Copy link
Copy Markdown

CLAUDE.md tells an agent the embed widget shares booking-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 need
there rather than writing it three times."

Following that and calling BookingLogic from embed.js throws a ReferenceError on the
customer's site, where nothing in this repo would catch it. We came close to shipping
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 already says the widget "doesn't import that module", and it
    carries local dowLabels, dayKey, timeLabel, shortDay and ymd for that reason.

The change

CLAUDE.md only, 11 lines. The entry now names the two surfaces that 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.

docs/ARCHITECTURE.md §8 and the module's own header make the same claim. Those are
corrected 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).

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.

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

Reviewed changes Docs-only correction to the booking-calendar agent notes in CLAUDE.md.

  • Clarify booking-logic.js load sites — States the module is inlined into book.html and manage.html only, not all three surfaces.
  • Document embed isolation — Explains that EmbedJS serves standalone embed.js, so BookingLogic is 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.

Pullfrog  | View workflow run | Using Grok𝕏

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