Skip to content

Web: allow SolveSpace HTML build to open a model from URL query param at launch#1721

Open
Copilot wants to merge 3 commits into
masterfrom
copilot/add-url-file-opening
Open

Web: allow SolveSpace HTML build to open a model from URL query param at launch#1721
Copilot wants to merge 3 commits into
masterfrom
copilot/add-url-file-opening

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 21, 2026

The web build could only open local/uploaded files after launch, which made forum/shared .slvs links cumbersome to inspect. This change adds launch-time URL ingestion so the app can start directly with a remote file.

  • Startup URL parameter handling

    • src/platform/guihtml.cpp now reads window.location.search for url or file.
    • This is wired into Platform::InitGui(...), so it plugs into the existing startup file-open path (no new load flow).
  • Remote file staging into Emscripten FS

    • If a launch URL is provided and no CLI file arg is already present, the file is fetched via emscripten_fetch.
    • The fetched bytes are written to /data/<filename> and that path is appended to startup args, allowing normal SS.Load(...) behavior.
  • Path/filename hardening and portability

    • Filename derivation from URL pathname is constrained (rejects unsafe names like ./.. and path separators).
    • Logging and byte-count checks were tightened for cross-platform correctness (PRIu64, safe type comparison).
// Launch URL support in InitGui():
std::string launchFileUrl = GetLaunchFileUrl();
if(args.size() < 2 && !launchFileUrl.empty()) {
    std::string launchFileName = GetFilenameFromUrl(launchFileUrl);
    std::string launchFilePath = Path::From(basePathInFilesystem).Join(launchFileName).raw;
    if(DownloadFileToFilesystem(launchFileUrl, launchFilePath)) {
        args.push_back(launchFilePath);
    }
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • gitlab.com
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue May 21, 2026 that may be closed by this pull request
@phkahler phkahler marked this pull request as ready for review May 21, 2026 14:03
Copilot AI and others added 2 commits May 21, 2026 14:11
Copilot AI changed the title [WIP] Allow web version to open files via URL Web: allow SolveSpace HTML build to open a model from URL query param at launch May 21, 2026
Copilot AI requested a review from phkahler May 21, 2026 14:18
@phkahler
Copy link
Copy Markdown
Member

Looking for testers... Can someone check if this actually works?

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.

Suggestion: Allow web version to open files via URL

2 participants