Skip to content

feat(remote): support path-prefixed direct pairing - #5115

Draft
HamedMP wants to merge 7 commits into
pingdotgg:mainfrom
HamedMP:codex/matrix-os-connect
Draft

feat(remote): support path-prefixed direct pairing#5115
HamedMP wants to merge 7 commits into
pingdotgg:mainfrom
HamedMP:codex/matrix-os-connect

Conversation

@HamedMP

@HamedMP HamedMP commented Jul 31, 2026

Copy link
Copy Markdown

Problem

T3's direct remote-environment flow assumed that a server lived at the root of an origin. Matrix OS safely exposes a user's loopback T3 server below an owner-scoped path, so pairing URLs, OAuth/DPoP requests, assets, discovery, and WebSocket connections lost that prefix. The previous Matrix setup also sent users through T3 Connect, which required a T3 account and Clerk.

Solution

  • add --pairing-base-url to t3 serve and t3 pair so a trusted reverse proxy can advertise its public URL
  • accept only HTTP(S) public bases, normalize directory semantics, persist the running server's effective base, and reject mismatched t3 pair requests
  • preserve path prefixes throughout environment resolution, OAuth, HTTP RPC, assets, and WebSocket setup
  • verify both token exchange and authenticated-request DPoP proofs against the configured public URL instead of trusting forwarded headers
  • emit a hosted app.t3.codes/pair?host=... link for externally hosted direct environments
  • keep the Matrix OS setup entry points in desktop/web and mobile, now documented as direct pairing rather than T3 Connect discovery
  • refresh and save the resulting environment through T3's normal pairing/session model; no Matrix-specific auth or transport is added

User story

The user selects Set up Matrix OS, approves setup in Matrix, then scans or pastes the one-time pairing link into the normal T3 desktop, web, or mobile client. The Matrix computer appears as a standard remote environment. No T3 Connect toggle, T3 account, Clerk session, managed relay, or forked T3 client is required.

Tests

  • all 15 touched test files pass: 215 tests
  • targeted typechecks pass for mobile, web, client-runtime, and shared
  • server typecheck reaches one unrelated existing HttpResponseCompression.ts BodyInit error; no changed-file type errors remain
  • targeted lint and changed-file formatting checks pass
  • Macroscope correctness and Effect service-convention checks pass

Security notes

  • --pairing-base-url is operator-owned CLI configuration, not derived from request headers
  • the running server's public URL is persisted and must match later pairing requests
  • T3 remains the authority for one-time pairing credentials, DPoP-bound access tokens, API scopes, and WebSocket tickets
  • Matrix receives no T3 account token because this route does not use a T3 account

Rollout dependency

Test plan

  1. Start T3 behind a reverse proxy with a path-prefixed --pairing-base-url.
  2. Open the emitted app.t3.codes/pair?host=... link in web/desktop or scan it on mobile.
  3. Verify the environment is saved with its complete path prefix.
  4. Open a project and verify OAuth/DPoP, HTTP RPC, assets, and WebSocket traffic use the prefixed URL.
  5. Use Set up Matrix OS and verify the same direct flow works without T3 Connect sign-in.

Implemented with Codex desktop (GPT-5).

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3cb0590d-0be5-4ef7-a909-42abdf010231

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jul 31, 2026
Comment thread apps/web/src/localApi.ts Outdated
HamedMP added 5 commits August 3, 2026 09:52
Summary:
- add Matrix OS to web and desktop connection settings
- add the same setup action to the mobile environment screen
- share one bounded handoff URL and document the flow

Rationale:
- make a persistent Matrix OS environment discoverable through T3 Connect
- reuse existing external-link and T3 authentication infrastructure

Tests:
- shared package tests (319 passed)
- web package tests (1703 passed)
- mobile package tests (590 passed)
- shared, web, and mobile typechecks
- focused lint and format checks
Summary:
- distinguish blocked popups without relying on noopener return values
- sever the opener before navigation and retain noreferrer behavior
- cover the successful secure browser launch contract

Tests:
- apps/web LocalApi suite
- full shared, web, and mobile unit suites
- shared, web, and mobile typechecks
- targeted lint and formatting
Summary:
- label Matrix OS entry points as setup actions on web and mobile
- explain that online computers appear under Remote environments
- share and test the cross-platform setup copy

Rationale:
- the entry point launches onboarding and does not represent live status
- explicit copy avoids implying an already-connected desktop application

Tests:
- pnpm exec vp test run src/matrixOsConnect.test.ts
- shared, web, and mobile typechecks
Summary:
- refresh the relay environment catalog on application-active wakeups
- cover the resume behavior and document the Matrix OS handoff

Rationale:
- Matrix OS links asynchronously in an external window, so the one-time
  Settings refresh could leave the environment list stale
- reuse lifecycle wakeups instead of adding continuous relay polling

Tests:
- pnpm exec vp test run packages/client-runtime/src/relay/discovery.test.ts
- pnpm exec vp run --filter @t3tools/client-runtime typecheck
- pnpm exec vp lint packages/client-runtime/src/relay/discovery.ts packages/client-runtime/src/relay/discovery.test.ts
- pnpm exec vp fmt --check packages/client-runtime/src/relay/discovery.ts packages/client-runtime/src/relay/discovery.test.ts
@HamedMP
HamedMP force-pushed the codex/matrix-os-connect branch from c08c0ca to 1faf1ad Compare August 3, 2026 07:53
@HamedMP HamedMP changed the title feat(connections): add Matrix OS setup feat(remote): support path-prefixed direct pairing Aug 3, 2026
Comment thread apps/server/src/cli/config.ts
Comment thread apps/server/src/cli/config.ts
Comment thread apps/server/src/cli/pair.ts Outdated
Comment thread packages/client-runtime/src/environment/endpoint.ts

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One finding: a semantically distinct failure is being expressed by stuffing prose into a structured error attribute instead of its own error class. Everything else in the touched Effect code (namespace import of ServerConfig plus yield* ServerConfig.ServerConfig in EnvironmentAuth.make, pure-config threading of pairingBaseUrl into verifyRequestDpopProof, the new Schema.TaggedErrorClass with an attribute-derived message, no new Layer.succeed/ManagedRuntime/runPromise in service code) follows the conventions.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/src/cli/pair.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant