Commit Graph

10 Commits

Author SHA1 Message Date
Jeff Emmett a1b50eb0da fix: Automerge undefined rejection + thread not synced to server
- tweetImages and imageUrl set to null instead of undefined when empty
  (Automerge rejects undefined as invalid JSON)
- Updated ThreadData schema to allow null for optional fields
- This was the root cause of the 404 on image generation: saveDraft
  threw on undefined, so the thread never synced to the server, and
  the server-side route returned "Thread not found"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 17:14:06 -08:00
Jeff Emmett 1335c38d48 fix: thread builder offline runtime race + getDoc method name
Two bugs:
- subscribeOffline() bailed if runtime wasn't initialized yet (race with
  shell.ts init). Now waits for runtime to appear, then awaits init().
- getDoc() called runtime.getDoc() which doesn't exist — method is
  runtime.get(). Caused "e.getDoc is not a function" crash in listThreads.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 17:06:47 -08:00
Jeff Emmett ff5dd8c006 fix: await saveDraft/saveToAutomerge in all image and share handlers
All callers of saveDraft() and saveToAutomerge() in generateImage,
uploadImage, uploadTweetImage, generateTweetImage, removeTweetImage,
and share handler now properly await these async methods. Without await,
runtime.change() fires before the Automerge doc subscription resolves,
causing "Document not open" errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 16:58:04 -08:00
Jeff Emmett f4edf3b7ae fix: thread API calls 404 on subdomain routing (jeff.rspace.online)
basePath was always returning /{space}/rsocials/ which works for path-based
routing (rspace.online/jeff/rsocials/) but double-prefixes on subdomain
routing (jeff.rspace.online/jeff/rsocials/ → rewritten to /jeff/jeff/rsocials/).

Now detects subdomain hosts (*.rspace.online, *.rsocials.online) and returns
/rsocials/ without the space prefix, since the space is the subdomain.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 16:47:41 -08:00
Jeff Emmett 0abfce2991 fix: thread builder save crash — await Automerge doc open before write
Two bugs fixed:
- attachShadow called unconditionally in connectedCallback, crashing on
  re-insertion ("Shadow root cannot be created on a host which already
  hosts a shadow tree")
- saveToAutomerge/deleteFromAutomerge called runtime.change() before the
  async subscribeOffline() had resolved, causing "Document not open" errors

Now tracks the subscribe promise and awaits it before any write operation.
Also guards shadow root creation in gallery and campaign manager components.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 16:38:50 -08:00
Jeff Emmett 493ae2442c fix: replace broken Postiz reverse proxy with iframe embed
The reverse proxy couldn't work for a Next.js SPA — it caused double
space prefix in redirects and couldn't handle /_next/* static assets.
Switch to iframe approach with demo.rsocials.online directly. Fix
template literal bugs where getSchedulerUrl() was passed as a string
literal instead of being evaluated.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 10:20:19 -08:00
Jeff Emmett bb37727f18 feat: reverse-proxy Postiz at /rsocials/scheduler instead of iframe
The rSpace Traefik router catches demo.rsocials.online (priority 120)
before the Postiz container can serve it, making iframe embedding fail.

Replace the iframe approach with a reverse proxy: /rsocials/scheduler/*
proxies to the Postiz container (postiz:5000) on the Docker network.
Rewrites redirect headers to stay within the scheduler path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 21:36:03 -08:00
Jeff Emmett 2853e46037 fix: update Postiz URL from social.jeffemmett.com to demo.rsocials.online
The old domain had no DNS record. Postiz is served via Traefik at
demo.rsocials.online.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 21:26:35 -08:00
Jeff Emmett 831c8b1c24 feat: refactor rSocials from monolith to full rApp
Decompose the 2,116-line mod.ts into a canonical rApp matching the
rFlows/rBooks pattern with Automerge sync, web components, and
extracted CSS.

New files:
- schemas.ts: SocialsDoc, ThreadData, Campaign types + Automerge schema
- local-first-client.ts: browser-side sync client
- lib/types.ts: shared types, DEMO_FEED, PLATFORM_LIMITS
- lib/image-gen.ts: server-only fal.ai + file upload helpers
- components/folk-thread-builder.ts: compose/preview/readonly component
- components/folk-thread-gallery.ts: thread listing grid component
- components/folk-campaign-manager.ts: campaign viewer with import modal
- components/socials.css: all extracted CSS (~550 lines)

mod.ts slimmed to ~616 lines: ensureDoc, image APIs, page routes
injecting <folk-*> web components, file→Automerge migration, seed
template, and module export. Thread/campaign CRUD moved from REST
to Automerge local-first sync.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 20:42:18 -08:00
Jeff Emmett aa45cabc4e fix: add wasm plugin to folk-flows-app build + add missing rsocials components
The folk-flows-app sub-build imports Automerge which requires WASM support.
Added wasm() plugin, esnext target, and Automerge alias to the sub-build config.

Also adds folk-socials-canvas.ts and socials-canvas.css that were on the server
but missing from git, causing the vite build to fail.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 20:34:32 -08:00