Skip to content

feat: local-first Sketchflow, GitHub sign-in optional - #6

Merged
playlikeboy merged 3 commits into
mainfrom
feat/local-first-guest-mode
Nov 12, 2026
Merged

playlikeboy merged 3 commits into
mainfrom
feat/local-first-guest-mode

Conversation

@playlikeboy

Copy link
Copy Markdown
Owner

What changes for users

Sketchflow now works fully without an account.

  • Signed out: the app opens on a workspace called This device. Projects, sketches and notes are saved in the browser. Nothing redirects to sign-in.
  • GitHub is optional: signing in adds repository workspaces. A sync panel then offers to copy projects from this device into a repository. The user picks which ones; nothing uploads on its own.
  • Sharing needs a repository, so share, embed and fork prompt for sign-in instead of redirecting.
  • /try now opens the app. An existing try sketch becomes a device project once.

How it works

  • Guest data always lives under the local storage scope, including after sign-in, so signing in or out never hides or purges it.
  • Sync writes one commit per project through the existing authenticated commit route. Project ids are renamed on collision, each commit names the branch head it was built on, and the device copy is removed only after its commit succeeds.
  • No server routes or database tables changed.

Also in this branch

  • Fixes a console error: the editor updated the Excalidraw scene before the canvas had mounted.
  • After a security review: the offline fallback to the last signed-in user applies only when the browser is offline, and sync refuses to run without a known branch head.

Known limits

  • Work on this device is not backed up until it is synced; clearing site data removes it.
  • If a device project is open in a second tab while it is being synced, edits made in that tab after the sync are not carried over.
  • Live collaboration is not part of this change.

Test plan

  • 97 unit tests (bun run test), including 16 for sync: file building, id collisions, a failed commit keeping the device copy, expired session, conflict, missing branch head
  • Typecheck, lint (no new warnings), production build
  • 15 browser tests (bun run test:e2e): app opens signed out with no authenticated API calls, a guest project survives a reload, sharing prompts, /try opens the app, device projects sync after sign-in, existing signed-in editor flows
  • Manual: sign in on production and sync a real device project into a repository

The excalidrawAPI callback runs before Excalidraw's own component has
mounted, so calling updateScene there logged a setState-on-unmounted
warning. The theme effect already applies the same colours after mount.

Also adds the guest-workspace contract for local-first mode:
src/lib/local-workspace.ts, useAppIdentity, and the LocalSyncPanel
props.
The whole app now works without signing in. Projects made signed out live
in the browser under a "This device" workspace; nothing redirects to
sign-in on its own.

- App pages (projects, recent, notes, templates, workspaces) show the
  guest workspace when signed out and add repository workspaces after
  sign-in. /try redirects to /app and an existing try sketch becomes a
  guest project once.
- The editor opens guest projects from local drafts only, never calls
  the server for them, and replaces the commit controls with "Saved on
  this device" and "Back up to GitHub".
- After sign-in, a sync panel offers to copy guest projects into a
  repository: one commit per project, renamed on id collisions, removed
  from the device only after the commit succeeds.
- Sharing and forking need a repository and prompt for sign-in instead
  of redirecting.
- Guest data always uses the "local" storage scope, so signing in or
  out never hides or purges it.
- The offline fallback to the last signed-in user now applies only when
  the browser reports no connection, so a server error or an expired
  session cannot show a previous user's cached repositories.
- Sync refuses to run when the repository's latest commit is unknown,
  because every commit relies on that head to avoid overwriting changes.
- Sketch links encode each id as one path segment.
- New end-to-end tests: the app opens signed out, a guest project
  survives a reload, sharing prompts instead of redirecting, /try opens
  the app, and device projects sync into a repository after sign-in.
@playlikeboy
playlikeboy merged commit e2cfd17 into main Nov 12, 2026
1 check passed
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