Skip to content

Open in Audiotool: one click signed in, sound kept through sign-up and sign-in - #6

Open
Que2039 wants to merge 1 commit into
mainfrom
cursor/open-in-audiotool-sign-in-8101
Open

Que2039 wants to merge 1 commit into
mainfrom
cursor/open-in-audiotool-sign-in-8101

Conversation

@Que2039

@Que2039 Que2039 commented Dec 2, 2026

Copy link
Copy Markdown

Workstream 3 of the UX work plan (review issues 1 and 2): make "Open in Audiotool" as smooth as possible, and keep the visitor's sound through sign-up and sign-in.

What changes for the visitor

Where the OAuth sign-in works (LOGIN_ORIGINS):

  • Signed in (tokens in this browser): one click opens a new tab, and that tab ends in Studio with the device as the visitor set it. No dialog. "Add to project" is one click away, as before.
  • Signed out: the device's snapshot (values and custom state) is saved to localStorage before anything leaves the page. The OAuth sign-in then opens in a new tab. Audiotool's sign-in form has a "Sign up" link, and that link keeps the OAuth flow going (checked: it carries the login_challenge). The tab comes back to the a-plugins start page with ?code. That page stores the tokens, builds the project from the saved snapshot, and moves on to Studio. The page the visitor played on is not touched.
    • On www.audiotool.com/a-plugins/ a tiny dialog comes first: "Open DUCKquack in Audiotool", the line "Your sound comes along.", and two buttons, Create free account and Sign in. "Create free account" goes to Audiotool's signup page with return_to set to the same a-plugins page. That page then goes on to consent and finishes the open automatically.
    • On audiotool.github.io there is no dialog. Audiotool's accounts reject return_to addresses on github.io, so the button goes straight to sign-in, whose form links to sign-up.
    • If pop-ups are blocked, the same steps run in the current tab. If the visitor comes back to the device page before the open finishes (reload, or the back button), their saved sound is put back on the device.
    • "Add to project" uses the same redirect-based sign-in (with "Create free account" on www). The dialog text is now just the buttons.
  • No caption. The button label and the returning flow carry it.

Until the live redirect URIs are registered (today's live site): the button still links to the device's template, or to its plugin page where there is no template. On the first click, the tiny dialog sends the visitor to accounts.audiotool.com/signup?return_to=<that link> or .../login?return_to=<that link>, which is Tribe's signup-first routing (buildStudioEntryHref). The visitor's UTM tags are copied onto the signup URL. After that first choice, clicks go straight to the link. "Add to project" stays hidden. Embedded players never show the dialog.

Registration needed (outside this repo)

On Audiotool's OAuth server (Ory Hydra at oauth.audiotool.com), add these redirect URIs to client 83100fb3-489d-48db-ada2-16884a65473b:

  • https://www.audiotool.com/a-plugins/
  • https://audiotool.github.io/a-plugins/

Each must match exactly, including the trailing slash. Today Hydra rejects both with "redirect_uri does not match any of the OAuth 2.0 Client's pre-registered redirect urls"; http://127.0.0.1:<port>/ already works. Scope: project:write.

Once they are registered:

  1. Try it before rebuilding: open any device page on the live site with ?at-login=1. That switches the full flow on for that tab.
  2. Switch it on: in scripts/data.mjs, set LOGIN_ORIGINS = ["http://127.0.0.1", ...LIVE_ORIGINS] (or add one origin at a time), then rebuild with node scripts/build.mjs --pages.

Optional: if the Audiotool accounts team adds https://audiotool.github.io to the allowed return_to URLs, add it to SIGNUP_ORIGINS and github.io gets the "Create free account" choice too.

Code

  • player/auth.js (new): PKCE, the token store, and pending records keyed by OAuth state (TTL one hour). Also builds the signup, login and resume URLs, and finishSignIn() for the redirect page.
  • player/open.js: decides the route for each click, shows the handoff dialog, finishes a returning ?code or ?at-resume, and puts a saved sound back.
  • player/studio.js: replaces cross-tab polling with the redirect flow, adds finishOpen(rec), and adds the two sign-in buttons to Add to project.
  • player/main.js: player.restore(snapshot) applies the saved values and state before the interface and DSP start.
  • scripts/data.mjs, scripts/pages.mjs: LIVE_ORIGINS, SIGNUP_ORIGINS, and data-signup-origins on every player.
  • site/: rebuilt with A_PLUGINS_DATE=2026-11-30 node scripts/build.mjs --pages. The only differences are version hashes, the new attribute, the bundles and the CSS.

Verification

  • --pages build: 118 device pages, the same as before. It ran in a scratch copy because ../native-nxs isn't available on the build machine; the generated site/ diff was checked to contain only the changes above.
  • esbuild bundles build without warnings.
  • auth.js was exercised in Node with mocked localStorage, location and fetch: the pending round trip, PKCE state and verifier, signup and resume URLs with UTM tags, code exchange, refusal, unknown state, and expiry.
  • The repo has no lint or test suite. No browser click-through was done.

Human checklist

Run locally with npm run serve and open http://127.0.0.1:8095/ (the full flow is on there), and also check the live origins.

  • Signed in (after one successful open): on a plugin page, turn a knob and click Open in Audiotool. A new tab opens and lands in Studio with that knob setting, with no dialog. Add to project lists your projects, and a pick opens that project.
  • Signed out, new user (clear site data): change the sound and click Open. The tab shows Audiotool sign-in; use "Sign up" there. After signup and consent, the tab lands in Studio with your sound, and the original tab is unchanged. On www.audiotool.com (after registration): the dialog appears, "Create free account" leads to signup, and the tab returns to the same a-plugins page and goes on to Studio.
  • Signed out, existing user: same as above with "Sign in". The sound is kept.
  • Pop-ups blocked: the flow runs in the same tab and ends in Studio. Going back to the device page shows your sound.
  • Plugin with a template (e.g. DUCKquack) and without one (e.g. a generated registry page): with the flow on, both open a project with the device. On today's live site, the dialog sends you to signup or login and you return to the template or the plugin page. A second click goes straight there.
  • Native device (e.g. Heisenberg): the open places the native device with its patterns.
  • Phone width: the dialog fits, and both buttons wrap cleanly.
  • Consent refused: the sign-in tab closes, and the original page is unchanged.
Open in Web Open in Cursor 

… saved before Audiotool's sign-up or sign-in and the returning tab finishes the open (player/auth.js); until the live redirect URIs are registered, sign-up or sign-in with return_to the template

Co-authored-by: David Querg <Que2039@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

2 participants