Skip to content

feat(broadcast): migrate recipe apps to Subscribe(SelfTopic())+Publish#24

Merged
adnaan merged 2 commits into
mainfrom
broadcast-phase-5-migration
May 20, 2026
Merged

feat(broadcast): migrate recipe apps to Subscribe(SelfTopic())+Publish#24
adnaan merged 2 commits into
mainfrom
broadcast-phase-5-migration

Conversation

@adnaan
Copy link
Copy Markdown
Contributor

@adnaan adnaan commented May 20, 2026

Phase 5 of the broadcast-action-redesign proposal removes ctx.BroadcastAction from livetemplate in v0.10.0. This PR migrates every recipe app's Go code and the docs-site embed wiring to the new opt-in peer-fanout pattern:

  • Mount: ctx.Subscribe(ctx.SelfTopic())
  • Actions: ctx.Publish(ctx.SelfTopic(), "ActionName", data)

Bumps livetemplate pin v0.9.0 → v0.9.2 in both go.mod and e2e/go.mod (Subscribe / Publish / SelfTopic already ship in v0.9.2 via Phase 1).

Migrated recipes

Recipe Sites Notes
counter/_app/counter.go 2 Increment / Decrement; new Mount method added
patterns/_app/handlers_realtime.go 4 MultiUserSync.RefreshCounter, Broadcasting.NewMessage, Presence.PresenceChanged × 2
shared-notepad/_app/controller.go 1 Refresh
todos/_app/controller.go 4 RefreshTodos × 4

Comment-level rewording (no behavior change)

  • cmd/site/main.go — shared-notepad embed-wiring comment
  • content/recipes/shared-notepad/_app/handler.go — package doc + NewDemoBasicAuth + Handler godoc
  • content/recipes/patterns/_app/data.go — pattern-catalog descriptions
  • content/recipes/patterns/_app/handlers_lists.goSortableController godoc
  • e2e/shared-notepad/notepad_test.go — package-doc test list
  • e2e/patterns/patterns_test.go — multi-tab test prose

Verification

  • go build ./... — clean (both root + e2e/ modules)
  • go vet ./... — clean
  • ✅ Substring grep across *.go for BroadcastAction returns zero matches

Out of scope — follow-up PR

The recipe markdown files still teach BroadcastAction nomenclature:

  • content/index.md
  • content/recipes/architecture-flow.md
  • content/recipes/broadcasting.md
  • content/recipes/sync-and-broadcast.md
  • content/recipes/counter/index.md
  • content/recipes/shared-notepad/index.md
  • content/recipes/todos/index.md
  • content/recipes/progressive-enhancement/index.md

These are conceptual recipe content that needs deliberate rewriting against the new Subscribe / Publish primitives — not a mechanical search-replace. Will follow as a separate docs: migrate recipe pages to Subscribe/Publish nomenclature PR.

The content/{reference,guides,client,contributing}/ pages are upstream-synced from livetemplate — those will pick up the new API via the livetemplate v0.10.0 sync wave automatically (no edits in this repo).

Ordering

This PR is intentionally landed before livetemplate v0.10.0:

  • The migrated code uses Subscribe / Publish / SelfTopic which are already in v0.9.2
  • Once livetemplate v0.10.0 ships, no further changes needed here
  • This PR's merge unblocks the cross-repo CI on livetemplate#429 (which fails on Test Docs Todos / Shared Notepad / Patterns against Core Changes because the current docs/main builds against the open Phase-5 livetemplate worktree, which has BroadcastAction removed)

Refs livetemplate#415 (broadcast-action-redesign proposal)
Refs livetemplate#429 (Phase 5 livetemplate-side PR)

🤖 Generated with Claude Code

adnaan added 2 commits May 20, 2026 19:56
Phase 5 of the broadcast-action-redesign proposal removes ctx.BroadcastAction
from livetemplate in v0.10.0. This PR migrates every recipe app (Go) and the
docs-site embed wiring to the new opt-in peer-fanout pattern:

  - Mount:    ctx.Subscribe(ctx.SelfTopic())
  - Actions:  ctx.Publish(ctx.SelfTopic(), "ActionName", data)

Bumps the livetemplate pin v0.9.0 → v0.9.2 in both go.mod and e2e/go.mod
(Subscribe / Publish / SelfTopic shipped via Phase 1).

Migrated 4 recipe controllers (11 BroadcastAction call sites total):
  - content/recipes/counter/_app/counter.go            (Increment / Decrement; new Mount)
  - content/recipes/patterns/_app/handlers_realtime.go (MultiUserSync / Broadcasting / Presence — 4 sites)
  - content/recipes/shared-notepad/_app/controller.go  (Refresh)
  - content/recipes/todos/_app/controller.go           (RefreshTodos × 4)

Also reworded comment-level references in:
  - cmd/site/main.go                                          (shared-notepad embed wiring comment)
  - content/recipes/shared-notepad/_app/handler.go             (package doc + NewDemoBasicAuth + Handler godoc)
  - content/recipes/patterns/_app/data.go                      (pattern catalog descriptions)
  - content/recipes/patterns/_app/handlers_lists.go            (SortableController godoc)
  - e2e/shared-notepad/notepad_test.go                         (package doc test list)
  - e2e/patterns/patterns_test.go                              (multi-tab test prose)

Substring grep across the repo for "BroadcastAction" in *.go returns zero
matches.

**Out of scope (follow-up PR):** the recipe markdown files
(content/recipes/{counter,broadcasting,sync-and-broadcast,shared-notepad/index,
counter/index,architecture-flow,progressive-enhancement/index,todos/index,
broadcasting}.md and content/index.md) still teach BroadcastAction nomenclature.
These are conceptual recipe content that needs deliberate rewriting against
the new Subscribe / Publish primitives, not a mechanical search-replace. The
content/{reference,guides}/ pages are upstream-synced from livetemplate
(see `feedback_sync_pr_edits` memory) — those will follow the livetemplate
v0.10.0 sync wave automatically.

Lands BEFORE livetemplate v0.10.0 — the migrated code uses Subscribe / Publish /
SelfTopic which already ship in v0.9.2, so this PR builds and tests cleanly
against the current published library.

Refs livetemplate#415 (broadcast-action-redesign proposal)
Refs livetemplate#429 (Phase 5 livetemplate-side PR)
Anticipating the same partial-mutation concern the claude-review raised
on the examples#102 companion PR: the propagation of Publish errors as
`return state, err` is intentional under the new Subscribe/Publish
primitive. The only errors Publish can actually return are programmer
errors (empty SelfTopic from a misconfigured Authenticator, or
MaxPublishesPerAction cap exceeded). Surfacing these loudly is a
feature — the alternative (log-and-swallow) hides real configuration
bugs that would otherwise silently break multi-tab sync.

Added a comment at content/recipes/shared-notepad/_app/controller.go's
Save site explaining the rationale; the same propagation pattern is
intentional at every other Publish site in the recipes.

No behavior change; comment-only.

Refs livetemplate#415 (broadcast-action-redesign proposal)
Refs livetemplate#429 (Phase 5 livetemplate-side PR)
@adnaan adnaan merged commit 22a8b2d into main May 20, 2026
2 checks passed
@adnaan adnaan deleted the broadcast-phase-5-migration branch May 20, 2026 20:49
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