close
Skip to content

Don't auto-load Web Workflow on bare localhost#480

Merged
makermelissa merged 2 commits intocircuitpython:mainfrom
makermelissa-piclaw:fix/no-web-workflow-on-bare-localhost
Apr 29, 2026
Merged

Don't auto-load Web Workflow on bare localhost#480
makermelissa merged 2 commits intocircuitpython:mainfrom
makermelissa-piclaw:fix/no-web-workflow-on-bare-localhost

Conversation

@makermelissa-piclaw
Copy link
Copy Markdown
Contributor

Problem

Visiting the editor at bare http://localhost/ (i.e. running it locally for development with no ?backend= and no ?host= URL params) silently auto-selects the Web Workflow. WebWorkflow.parseParams() then sees isTestHost() is true with no host= supplied and returns:

You are connected with localhost, but didn't supply the device hostname.

The user never reaches the connect dialog, so they can't pick BLE / Serial / USB instead.

Cause

getBackend() in js/script.js falls through to Web Workflow whenever isLocal() is true:

} else if (isLocal()) {
    return getBackendWorkflow("web");
}

isLocal() returns true for bare localhost (no path constraint on the localhost branch), so Web Workflow is auto-loaded even when there's no plausible Web Workflow target.

Fix

Only auto-pick Web Workflow when there's actually a target for it:

  • an mdns hostname (*.local)
  • an IP-address hostname
  • or an explicit host= URL param

Otherwise return null so script.js falls through to the connect dialog and lets the user choose.

} else if (isLocal()) {
    if (isMdns() || isIp() || getUrlParam("host", false)) {
        return getBackendWorkflow("web");
    }
}

Risk / compatibility

Small surface change. The only behaviour difference is on bare localhost with no URL hints — previously it auto-picked Web Workflow (and immediately errored), now it falls through to the connect dialog. Any URL that previously connected successfully (mdns, IP, or ?host=) still does.

Testing

Verified locally on a dev server: bare http://localhost:PORT/ now shows the connect dialog instead of the "didn't supply the device hostname" error, and BLE / Serial / USB selections work as expected. Web Workflow paths (mdns / IP / ?host=) unchanged.

getBackend() previously fell through to Web Workflow whenever isLocal()
was true. On bare http://localhost/ that meant Web Workflow was loaded
without a target, which then triggered the "You are connected with
localhost, but didn't supply the device hostname." error before the
user ever saw the connect dialog.

Restrict the auto-pick to cases where there is actually a Web Workflow
target: an mdns or IP hostname, or a host= URL parameter. On bare
localhost with no hint, return null so the connect dialog can prompt
for BLE / Serial / USB instead.
…-on-bare-localhost

# Conflicts:
#	js/script.js
@makermelissa makermelissa merged commit 18b505a into circuitpython:main Apr 29, 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.

2 participants