Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(app): handle web basic auth startup credentials - #1

Open
n3crosis with Copilot wants to merge 27 commits into
devfrom
copilot/fix-useglobal-sync-error
Open

n3crosis with Copilot wants to merge 27 commits into
devfrom
copilot/fix-useglobal-sync-error

Conversation

Copilot AI commented May 15, 2026

Copy link
Copy Markdown

Issue for this PR

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When the web app is opened with HTTP Basic credentials in the URL, the app reads those credentials into the startup server connection while continuing to use a credential-free server URL. This lets SDK requests include the expected Basic Authorization header and avoids startup failures around the global sync provider.

The app now also removes startup credentials from the browser URL/history after extracting them, and terminal WebSocket fallback auth treats an empty password as valid Basic Auth instead of omitting auth.

Added focused coverage for parsing credentials from URLs and terminal auth token handling.

How did you verify your code works?

  • oxlint packages/app/src/entry.tsx packages/app/src/utils/server.ts packages/app/src/utils/server.test.ts packages/app/src/utils/terminal-websocket-url.ts packages/app/src/utils/terminal-websocket-url.test.ts
  • Attempted bun typecheck, but it is blocked because dependency install failed and tsgo is unavailable.
  • Attempted targeted Bun tests, but they are blocked because dependency install failed and @happy-dom/global-registrator is unavailable.
  • Attempted bun install --frozen-lockfile, but GitHub returned 403 for anomalyco/ghostty-web.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

Copilot AI requested a review from n3crosis May 15, 2026 06:25
@n3crosis
n3crosis marked this pull request as ready for review May 17, 2026 10:43
Copilot AI review requested due to automatic review settings May 17, 2026 10:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates web startup authentication so Basic credentials embedded in the page URL are parsed into the initial HTTP server connection while keeping the server URL credential-free.

Changes:

  • Adds authFromUrl for parsing Basic auth userinfo from URLs.
  • Allows empty-string passwords to still generate Basic Authorization headers.
  • Adds focused tests for URL credential parsing cases.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/app/src/utils/server.ts Adds URL auth parsing and changes SDK auth header generation for empty passwords.
packages/app/src/utils/server.test.ts Adds coverage for parsing credentials from URLs.
packages/app/src/entry.tsx Wires URL-derived credentials into the startup server connection.
Comments suppressed due to low confidence (1)

packages/app/src/utils/server.ts:42

  • The changed behavior that sends Basic auth when password is an empty string is not covered by the existing server utility tests. Add coverage for createSdkForServer (or equivalent request construction) so username-only credentials continue to produce an Authorization header instead of regressing to the old falsy-password behavior.
    if (server.password === undefined) return undefined
    return {
      Authorization: `Basic ${authTokenFromCredentials({ username: server.username, password: server.password })}`,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/app/src/entry.tsx Outdated
if (root instanceof HTMLElement) {
const auth = authFromToken(new URLSearchParams(location.search).get("auth_token"))
const auth = authFromToken(new URLSearchParams(location.search).get("auth_token")) ?? authFromUrl(location.href)
clearAuthToken()
Comment thread packages/app/src/utils/server.ts Outdated
if (!url.username && url.password === "") return undefined
return {
username: url.username ? decodeURIComponent(url.username) : "opencode",
password: url.password ? decodeURIComponent(url.password) : "",
@n3crosis

Copy link
Copy Markdown
Owner

@copilot sync to the latest branch and modify the pull request according to contribution md again

Copilot AI commented May 17, 2026

Copy link
Copy Markdown
Author

@copilot sync to the latest branch and modify the pull request according to contribution md again

Synced the branch with latest dev, updated the PR description to match CONTRIBUTING.md, and addressed the startup auth cleanup/terminal auth follow-ups. Final addressing commit: 263bc2b.

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:

  • https://api.github.com/repos/anomalyco/ghostty-web/tarball/main
    • Triggering command: /usr/local/bin/bun bun install --frozen-lockfile (http block)

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

Copilot AI changed the title Fix web basic auth startup credentials fix(app): handle web basic auth startup credentials May 17, 2026
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.

10 participants