Skip to content

feat(atproto-comments): add no-JS hosted comments and CDN proxy#11

Merged
Theo-Steiner merged 7 commits into
mainfrom
fix/atproto-comments-dual-svelte-runtime
Jul 26, 2026
Merged

feat(atproto-comments): add no-JS hosted comments and CDN proxy#11
Theo-Steiner merged 7 commits into
mainfrom
fix/atproto-comments-dual-svelte-runtime

Conversation

@Theo-Steiner

Copy link
Copy Markdown
Contributor

What changed

  • keeps the hosted comments experience functional without client-side JavaScript
  • adds stable first-party CDN proxy routes and updates the public snippet to use them
  • improves the installation snippet design and component behavior
  • removes the vendored hydration host after adopting @svebcomponents/build 0.3.4
  • drops redundant build configuration and an unused client getter

Why

The initial Svelte-runtime hydration fix was merged in #8, but the follow-up work on this branch was never merged. These changes make the hosted component more resilient, simplify its build setup, and provide a stable first-party URL for CDN consumers.

Conflict resolution

Merged the latest main into the branch. The host-page conflict keeps the branch's first-party https://atproto.svebcomponents.dev/cdn URL. The modify/delete conflict keeps svebcomponents.config.ts deleted because build 0.3.4 now infers the equivalent configuration and includes the upstream hydration fixes.

Validation

  • pnpm check
  • pnpm test
  • pnpm build

All passed with the repository-declared pnpm 10.8.0.

Theo-Steiner and others added 7 commits July 25, 2026 01:53
…crash

The client build bundled its own Svelte runtime. In a SvelteKit/Vite app —
which has its own Svelte — that put two Svelte runtimes on the page, and under
`experimental.async` the app's async-boundary hydration would cross into the
component's separate runtime and dereference a null effect, crashing with
"Cannot read properties of null (reading 'f')" and wiping a correctly
server-rendered thread (#7).

Emit `dist/client-svelte`/`dist/server-svelte` (Svelte marked external) and
declare a `svelte` export condition pointing at them, so bundler consumers
dedupe the component onto the app's single Svelte runtime. The default
`dist/client` (Svelte bundled) is unchanged and still serves the CDN /
bare-`import` drop-in, which has no app Svelte to dedupe against. The vendored
direct-props HydrationHost is now applied to every build variant (matched by
outDir/entry rather than array index).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W9oixH2t2npbf9u3ara93J
The local copy of @svebcomponents/ssr's HydrationHost existed only to read
`props.__x` instead of destructuring `$props()`, which under an earlier ssr
release produced writable prop signals with no parent effect and broke
hydration before the user's component mounted.

That no longer reproduces on the current pin (svelte 5.56.4, ssr 0.3.1).
Verified by building against upstream's host and running the hydrate-in-place
e2e with the async SSR wrapper and `experimental.async` both off (the shipped
config) and both on (the config the workaround was written for): the SSR'd
shadow DOM is claimed in place either way, with no console or page errors.

Removing it also removes the build-config aliasing that kept every build
variant pointed at the local file, so the component tracks upstream's host
automatically from here on. Note the e2e only exercises the bundler path
(dist/client-svelte / dist/server-svelte); the bundled CDN build has no
coverage yet.

Also fix two bugs in the "stays reactive" e2e, which was failing on main:

- it asserted the reply button's visible text was "Reply", but the button
  renders the reply-count glyph ("↩ 3") and carries "Reply" as its accessible
  name. Assert the accessible name, which does not move with the live thread.
- it then checked `shadowRoot.querySelector("dialog")` — the first dialog in
  document order, belonging to the root post, not to the comment whose button
  it clicked. It was asserting `open: true` on a dialog nothing had touched.
  Resolve the clicked button's `commandfor` and assert against that dialog.
  The trailing Esc check had the same bug and was passing vacuously against an
  already-closed dialog; it now proves Esc closes the dialog that was open.

And reformat a code-snippet line in the host's landing page that prettier had
been failing on (whitespace inside a tag; no rendered change), so `pnpm -r
lint` is green again.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EpWk46Sjx5E5SR12MtBTKs
0.3.4 carries two upstream fixes this component needed
(svebcomponents/svebcomponents#126, #128): browser bundles now resolve
against the `production` export condition, so Svelte's dev-only error and
warning message texts no longer ship, and the `hydratable` wrapper is
bundled rather than left as a bare specifier the CDN drop-in could not
resolve. dist/client is 93.6 kB -> 83.4 kB raw and self-contained again.

svebcomponents.config.ts only restated what the CLI already infers from
package.json `exports` — inference produces byte-identical output, and
additionally threads svelte.config.js through, which the hand-written
config did not. rollup.config.js was dead; the CLI only ever looks for
`svebcomponents.config`.

Also drops ServiceClient's unused `hasToken` getter. Class members are
never tree-shaken, so it shipped in every bundle touching ServiceClient.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EpWk46Sjx5E5SR12MtBTKs
…dual-svelte-runtime

# Conflicts:
#	apps/host/src/routes/+page.svelte
#	components/atproto-comments/svebcomponents.config.ts
@Theo-Steiner
Theo-Steiner marked this pull request as ready for review July 26, 2026 03:06
@Theo-Steiner
Theo-Steiner merged commit 6b1769a into main Jul 26, 2026
1 check passed
@Theo-Steiner
Theo-Steiner deleted the fix/atproto-comments-dual-svelte-runtime branch July 26, 2026 03:09
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