feat(demo): shareable URL state — ?source=<url>&q=<preset>&f=<format>#8
Closed
klappy wants to merge 1 commit into
Closed
feat(demo): shareable URL state — ?source=<url>&q=<preset>&f=<format>#8klappy wants to merge 1 commit into
klappy wants to merge 1 commit into
Conversation
The demo page now reads its state from the URL query string and writes it back when controls change. Anyone (Aquifer, an LLM, a person) can deep-link to a specific view of a specific source image: /?source=https://aquifer.klappy.dev/api/images/abc123 /?source=https://example.com/photo.jpg&q=high&f=avif The page URL itself becomes the shareable state. A Share-link button copies the current URL to the clipboard with a toast confirmation, using the modern Clipboard API with execCommand fallback and prompt as a last resort. Round-trip works correctly with source URLs that contain their own query strings (Unsplash ?w=2000, signed URLs, etc.) because URLSearchParams handles the nested encoding cleanly. Implementation: - readUrlState() parses source/q/f from window.location.search - writeUrlState() rebuilds the query string from current control state and uses history.replaceState (not pushState) so the back button still works as expected - applyUrlState() runs on load: if the source matches a dropdown option exactly, it'\''s selected; otherwise it goes in the custom URL field. Quality and format are restored if present. - writeUrlState() runs after every control change and once after initial load (so defaults like q=medium don'\''t pollute the URL) - Share-link button copies current URL with clipboard API + fallbacks The placeholder on the custom URL field now mentions the ?source= shortcut so users discover the feature. No proxy changes. Tests still 29/29.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
transcode-mcp | 95431f6 | Commit Preview URL Branch Preview URL |
May 27 2026, 09:54 PM |
This was referenced May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The demo page is genuinely useful when someone — a person, Aquifer, an LLM, an integration partner — can deep-link to it with their own image. Right now you have to load the page and paste a URL. With this change, the page reads its source from
?source=<url>and any external system can produce shareable links like:The page URL itself becomes the shareable state. Round-trips work even when the source URL has its own query string (Unsplash
?w=2000, signed URLs, etc.).How It Works
?source=,?q=,?f=from the page URL and populate the controls. If the source matches one of the dropdown options exactly, it gets selected; otherwise it goes in the custom URL field. The page then loads the grid with that source.history.replaceState(notpushState, so the back button still works normally — no per-change history pollution).execCommandthen towindow.promptfor environments where clipboard access is blocked. Shows a toast confirmation either way.q=mediumandf=autodon't get written to the URL because they're the defaults — keeps shared links short and human-readable.Aquifer integration
This enables the use case you mentioned: Aquifer or any system pointing at a UBSImages-style image catalog can construct a transcode-mcp link by URL-encoding the source URL into
?source=. The Cloudflare worker's URL parser (fixed in PR #7 for embedded query strings) handles the resulting nested encoding correctly.Branch base
This PR branches off
feat/click-to-zoom-modal(PR #7) because it depends on the demo page changes there. After PR #7 merges, GitHub will auto-update this PR's base to main.Tests
No new tests — this is pure frontend state plumbing. Round-trip verification done via Node script:
Existing 29/29 tests still pass. Typecheck clean.
Note
Low Risk
Frontend-only demo HTML/JS with no server, auth, or data-path changes.
Overview
Adds shareable URL state to the demo page so
?source=,?q=, and?f=deep-link to the same source, quality, and format as the controls. On load, query params populate the dropdown or custom URL field; on control changes,history.replaceStatekeeps the address bar in sync (defaultmedium/autoare omitted from the URL).A Share link secondary button syncs state, copies the current page URL via the Clipboard API with
execCommand/promptfallbacks, and shows a toast for confirmation. Styling addsbtn-secondaryand toast visibility transitions; the custom URL placeholder notes the?source=option.Reviewed by Cursor Bugbot for commit 95431f6. Bugbot is set up for automated code reviews on this repo. Configure here.