fix: 6 connection/auth/diagnostics bugs on the first-run path (retention)#131
Merged
Conversation
1. buildRequestHeaders: UTF-8-encode Basic-auth credentials before btoa() so non-ASCII usernames/passwords don't throw (Hermes' btoa is Latin1-only and the throw was an unhandled rejection that hung the connect spinner). 2. diagnostics classify(): check root.ok (server reachable) before !internet.ok, so a reachable-but-failing server (e.g. wrong auth) is no longer misdiagnosed as "no internet" just because the public-internet probe also failed (captive portal, Tailscale-only network, etc). 3. sdk.ts createClient: strip trailing slashes from baseUrl once, so a trailing-slash URL from Advanced mode / Edit screen doesn't produce a double slash on every request path. 4. add.tsx / [id].tsx: wrap addConnection/updateConnection in try/catch so a SecureStore failure after a successful test resets the spinner and shows an alert instead of hanging forever. Adds connection.shared.alerts.saveFailedTitle/saveFailedMessage (en + zh-Hans). 5. add.tsx / [id].tsx: build the diagnostics probe's auth with buildAuth() instead of a hand-rolled expression, so the probe reproduces the real request's credentials (previously Quick Connect's password-only case sent no auth to the probe at all). 6. add.tsx handleQuickConnect: stop sending the shared `username` state, which could carry a stray value typed earlier in Advanced mode and silently override the "opencode" default after "Back to Quick". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T12AhSnQVrSxNnvwfCx2z6
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.
Six verified correctness bugs in the connect + failure-diagnosis flow — the exact path where a new user connects or churns. Confirmed against code (and the opencode server's auth middleware); typecheck clean, 197 tests pass.
High impact
btoais Latin1-only and throws on any non-ASCII char, so a server with a non-ASCII username/password could never connect, and the throw became an unhandled rejection that spun the Connect button forever. Now UTF-8-safe base64 (RFC 7617). ASCII byte-identical. +3 tests.no-internetbefore checking whether the user's own server was reachable — so a Tailscale user with a wrong password (LAN reachable, no WAN) was told to check their network instead of their password. Now checksroot.okfirst. +1 test.host:4096//global/healthon every call; the probe reconstructed a clean URL and reported success.createClientnow strips the trailing slash.Medium
4. SecureStore failure after a successful test hung the UI (no try/catch) → now caught + alerted.
5. Diagnostics probe used different credentials than the real request (Quick Connect probed with no auth) → now uses
buildAuth.6. A username typed in Advanced mode leaked into Quick Connect, silently overriding the
opencodedefault → Quick Connect no longer reads that state.i18n en+zh in parity.
🤖 Generated with Claude Code
https://claude.ai/code/session_01T12AhSnQVrSxNnvwfCx2z6