Skip to content

feat(native): add T3 Connect sign-in and account listing - #97

Merged
rynfar merged 3 commits into
nativefrom
nw/93-relay
Nov 3, 2026
Merged

rynfar merged 3 commits into
nativefrom
nw/93-relay

Conversation

@rynfar

@rynfar rynfar commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Native users could not sign in to T3 Connect or list their published environments. This first CN-RELAY slice ports the CLI authorization-code/PKCE loopback flow, private credential persistence/refresh, sign-out, and OAuth-compatible account listing.

Relay connections and health checks are unavailable with native CLI OAuth sign-in. The UI says so explicitly, disables the connection action, and offers pairing links or SSH instead. No relay/server code is changed. Live Clerk sign-in and listing remain pending coordination with Trevor; no real window or browser has been launched.

Review findings

  1. Confirmed OAuth/DPoP incompatibility. infra/relay/src/http/Api.ts:1069 calls verifyClerkBearerToken and requires the relay audience. The OAuth fallback in verifyRelayClientBearerToken is used by bearer-client middleware, including listing, but not by that exchange. infra/relay/src/http/Api.test.ts:416-439 tests the helper fallback, not OAuth acceptance by the exchange. No alternate OAuth-authorized relay-session endpoint exists. The CLI's apps/server/src/cli/connect.ts links/publishes the local host; it does not establish a remote client session. Native now makes only the supported account-list request, and no longer attempts JWT-only status/connect exchanges.
  2. The saved relay-record kind and every consumer are removed. Startup and onboarding only see known direct/SSH saved records. Unsupported or malformed records are skipped individually without discarding valid pairings; no relay migration is added. Account sign-in/sign-out never edits the saved-environment catalog. The disabled explanation has no action handler or always-error upsert path.
  3. Removed stale bootstrap pinning with the unsupported transport. The unusable DPoP bootstrap/session implementation and its credential/socket adapters were removed. No saved discovery endpoint is used for a connection. Each account-list refresh accepts the latest endpoint metadata; a regression covers reallocation. A future connection implementation must use the fresh bootstrap endpoint after descriptor environment-ID validation and update its route without replacing other credentials.

The unused health model, endpoint health validation, and associated tests have been removed; only OAuth lifecycle, account listing, listing errors, and the disabled explanation remain.

Required upstream change

In infra/relay/src/http/Api.ts, layerTokenApi.exchangeDpopAccessToken needs an OAuth-aware subject-token verification path using the verified OAuth user identity (the existing verifyRelayClientBearerToken fallback is the relevant authentication behavior). Retain issuer/resource, allowed client/scopes, DPoP proof, and replay checks when issuing the bound relay token. The request contract in packages/contracts/src/relay.ts should accept an appropriate OAuth access-token subject type rather than declaring opaque OAuth access tokens to be JWTs. Add endpoint-level tests proving OAuth exchange works and invalid credentials/proofs remain rejected, while retaining the relay-audience JWT path. No environment-server authentication change is needed for the already-supported downstream DPoP flow. These upstream files are read-only for this worker.

Verification

  • Failing-before-fix regressions reproduced both unexpected JWT-only exchange after OAuth listing and destructive direct-route replacement.
  • A failing-before-fix catalog regression verifies unknown or malformed saved records are skipped individually while retaining valid credentials. Account-change invalidation and refreshed listing metadata remain covered.
  • cargo clippy --workspace --all-targets -- -D warnings and vp run check:changed passed.
  • cargo test --workspace -- --test-threads=1: all 1,013 tests passed. cargo build -p t3-native --features snapshot passed. Offscreen captures verify the signed-out screen and honest unavailable connection state.
  • Theme generation, parity tests (42 passed), and TypeScript conformance checks passed.
  • Previous read-only smoke probe: Connecting → Connected → shell synchronized, 2 projects and 17 threads. No provider turns were sent.

Local PNG evidence

Local files only; no browser automation or GitHub web uploads:

  • Before this PR: /tmp/t3-93-baseline.png
  • Before review correction: /tmp/t3-93-cloud-final.png
  • Corrected signed-out screen: /tmp/t3-93-review-signed-out.png
  • Corrected signed-in account listing and connection limitation: /tmp/t3-93-cleanup-listing.png

Remaining parity gaps

CN-RELAY remains partial (#93). OAuth-aware upstream relay exchange is required before native can support relay health checks/connections. Onboarding, host linking/unlinking, multiple-route fallback, socket renewal, and discovery wakeup/polling integration remain unported.

Sign out removes the worktree's .t3/native/cloud-oauth.json. OAuth refresh is serialized and completes rotation/persistence even when the requesting discovery is cancelled. Credentials use native's existing owner-only atomic file storage.

Built with GPT-6.1 Sol in Codex

@rynfar rynfar changed the title feat(native): add T3 Connect sign-in and relay environments feat(native): add T3 Connect sign-in and account listing Nov 3, 2026
@rynfar rynfar mentioned this pull request Nov 3, 2026
@rynfar
rynfar merged commit 405a637 into native Nov 3, 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.

1 participant