Skip to content

Show shared notes at once in both starters - #470

Merged
tnkuehne merged 1 commit into
mainfrom
starters-optimistic-notes
Nov 28, 2026
Merged

tnkuehne merged 1 commit into
mainfrom
starters-optimistic-notes

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Both starters now show a shared note immediately instead of waiting for the server.

  • SvelteKit reads and saves notes with remote functions (src/lib/notes.remote.ts): getNotes is rendered on the server, createNote adds the note through withOverride, and requested(getNotes, 1) returns the updated list with the same response. vite.config.ts enables experimental.remoteFunctions and Svelte's experimental.async, as the control plane does.
  • TanStack Start keeps notes in TanStack Query (@tanstack/react-query 5.107.1 with @tanstack/react-router-ssr-query 1.167.3). src/router.tsx creates one query client per router, the route loader fills it during server rendering, and the mutation adds the note in onMutate. saveNote returns the updated list.
  • In both, the note is marked Wird hochgeladen … until the server confirms it. If saving fails, the note disappears, its text and photo return to the form and a UI SDK toast explains why. After confirmation the note keeps showing the local photo until the uploaded copy has loaded, so the picture never goes blank.
  • Photos larger than 1600 pixels are reduced to JPEG in the browser before upload (JPEG because Safari on iOS cannot encode WebP from a canvas). Smaller pictures are uploaded unchanged.
  • Both starters get an app icon (static/favicon.svg, public/favicon.svg); tools/package-cli.ts now copies these folders into the CLI package. The title no longer comes from an APP_NAME variable.
  • Server-side saving is unchanged: the server still assigns the note ID, stores the photo and then the row.

Screenshots

The page at rest is unchanged; the difference is what happens when a note is shared. TanStack Start is shown with a delayed and then an aborted save; SvelteKit behaves the same way. (Before this change, SvelteKit submitted the form natively and reloaded the page.)

Before After
While saving
Saved
Save failed

Testing

  • pnpm check (root and both starters).
  • RUN_CAPTURE_TESTS=1 pnpm exec vitest run apps/control-plane/tests/runtime/error-capture.test.ts apps/control-plane/tests/runtime/tanstack-start.test.ts.
  • Both starters built and run on a local Worker with Chromium, with delayed and aborted saves: server-rendered name and notes; the note visible within 100 ms and marked until confirmed; one request per note; the photo going from the local copy straight to the loaded server copy; on failure the note removed, the draft back in the form and a toast; a 4032 × 3024 photo stored as a 223 KB JPEG and a small PNG stored byte for byte; all notes present after reload.
  • apps/control-plane/tests/local/quickstart.test.ts is updated for the new flow but was not run; it needs the full local stack.

The SvelteKit starter reads and saves notes with remote functions; the
TanStack Start starter keeps them in TanStack Query. A shared note appears
immediately, is marked until the server confirms it and returns to the form
with a toast if saving fails. The save response carries the updated list, and
the note keeps showing the local photo until the uploaded copy has loaded.

Photos larger than 1600 pixels are reduced to JPEG in the browser before
upload. Both starters get an app icon, which the CLI package now includes,
and the title no longer comes from an APP_NAME variable.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs af0bacd Nov 28 2026, 04:46 PM

@tnkuehne
tnkuehne merged commit e073296 into main Nov 28, 2026
14 of 15 checks passed
@tnkuehne
tnkuehne deleted the starters-optimistic-notes branch November 28, 2026 16:50
tnkuehne added a commit that referenced this pull request Nov 28, 2026
## Summary

Since #470 the SvelteKit starter saves notes with a remote form
(`createNote` in `notes.remote.ts`) instead of a page action. The
runtime deployment test still posted the note as a form to `/`, which
now returns 405, so `main-checks / rust-runtime` fails on `main` from
e073296 onward.

The test now reads the form's ID from the page's `action="?/remote=…"`,
posts the note and photo to `/_app/remote/<id>` with the field names the
form renders (`message/<id>`, `photo/<id>`), and checks that the result
has no validation issues. The existing checks that the page shows the
note and serves the photo byte for byte stay unchanged.

## Testing

- Built the SvelteKit starter and ran it with `wrangler dev` and local
D1/R2: `POST /` returns 405 (the CI failure); the new request returns
`{"type":"result"}` with the note ID, the page then lists the note, and
the stored photo is identical to the upload. An empty message returns a
result with `issues`.
- `oxfmt --check`, `oxlint --type-aware --deny-warnings` and
`svelte-check` for the changed file.
- The runtime suite itself runs in CI.
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