Repository navigation
feat(sandbox): activate T3 Connect relay on Docker Sandbox registration - #1
mdelapenya wants to merge 0 commit into
Conversation
Plan: Sandbox Inspect UI Surface
Plan: Sandbox Inspect UI SurfaceGoalExpose the output of Why this mattersToday Architecture layersThe change follows the existing Step 1 — CLI command shape (
|
| Section | Data source | Fields shown |
|---|---|---|
| Overview | DesktopSbxInspectResult |
name, agent, image, status badge, createdAt (relative), cpu/memory limits |
| Ports | ports[] |
Table: Host port → Container port · protocol. Empty state: "No ports exposed." |
| Secrets | secrets[] |
Badge list: name (kind). Empty state: "No secrets mounted." |
| Network policy | networkPolicy |
Isolation level badge + allowed egress list (truncated to 10, "+ N more" disclosure). Section hidden when networkPolicy is null. Empty state when networkPolicy.allowedEgress is empty. |
| Kits | kits[] |
Badge list of kit references. Resolves against SBX_OPTIONAL_KITS for human-readable labels when matched. |
| Workspaces | workspaces[] |
Monospace path list. Empty state: "No workspace mounted." |
Loading & error states:
- While
isPending: skeleton rows inside each section (same ghost pattern as
PullRequestGhosts). - On error: inline
AlertDestructivewith the error message + a Retry button
that callsrefresh(). - The Details button itself is hidden in
SbxSandboxRowwhen the bridge is
unavailable; the drawer assumesbridge.inspectSbxSandboxis defined when
open.
Refresh: A refresh icon button in the drawer header calls the component-local
refresh callback (see Step 5). No auto-refresh — inspect is a point-in-time
snapshot.
SbxSandboxRow — add Details trigger
desktopBridge is not currently in scope inside SbxSandboxRow. Two
options; the plan chooses option B to avoid prop-drilling:
- A: Pass
showDetails: booleanas a prop fromDockerSandboxModeBody
(wheredesktopBridgeis already accessed). Caller computes
showDetails={!!desktopBridge?.inspectSbxSandbox}. - B: Read
window.desktopBridgedirectly inside the component. This is
already done elsewhere inConnectionsSettings.tsx(e.g.handleInstall
accessesdesktopBridge?.installSbx). BecauseSbxSandboxRowis amemo
component, the bridge check is O(1) and stable across renders.
// Inside SbxSandboxRow
const desktopBridge = window.desktopBridge;
const [inspectOpen, setInspectOpen] = useState(false);
// In the button row:
{desktopBridge?.inspectSbxSandbox ? (
<Button size="xs" variant="ghost" onClick={() => setInspectOpen(true)}>
Details
</Button>
) : null}
<SandboxInspectDrawer
name={sandbox.name}
open={inspectOpen}
onOpenChange={setInspectOpen}
/>Step 7 — Tests
DesktopSbxCli.test.ts — parser tests
Add describe("parseSbxInspectOutput") cases:
- Full valid JSON → all fields populated
- Missing optional fields →
nulldefaults applied, no throw - Port with unknown protocol → passed through as-is
- Secret with value field present → value field not included in result
- Unknown top-level key → silently ignored
- Malformed JSON → returns
null
DesktopSbxEnvironment.ts — layerTest stub
When inspect is added to the DesktopSbxEnvironment service interface,
layerTest must include an inspect stub to keep the existing test helper
valid:
export interface DesktopSbxEnvironmentTestStub {
// ... existing fields ...
readonly inspectResult?: DesktopSbxInspectResult | DesktopSbxCommandError;
}
// In layerTest:
inspect: (name) =>
stub.inspectResult !== undefined && isDesktopSbxCommandError(stub.inspectResult)
? Effect.fail(stub.inspectResult)
: stub.inspectResult !== undefined
? Effect.succeed(stub.inspectResult)
: Effect.fail(new DesktopSbxCommandError({ reason: `No inspect stub for "${name}"` })),SbxSandboxRow — component tests
desktopBridge.inspectSbxSandboxdefined → Details button rendereddesktopBridge.inspectSbxSandboxabsent → Details button not rendered- Clicking Details button → drawer opens
SandboxInspectDrawer — component tests
Test the drawer in isolation with vi.stubGlobal("desktopBridge", ...):
open=true, bridge returns result → all sections render populated dataopen=true, bridge throws → error message + Retry button rendered- Retry button triggers a second
inspectSbxSandboxcall opentransitions from false → true → fetch is triggered exactly once
Rollout / feature gating
No feature flag needed. The Details button is conditionally rendered only
when window.desktopBridge?.inspectSbxSandbox is defined (desktop-app
context). Users on older desktop versions where inspectSbxSandbox is absent
see the existing SbxSandboxRow unchanged — perfect backward compatibility.
Out of scope for this issue
- Live tail / auto-refresh of inspect data (future: polling atom variant)
- Port-forward shortcut ("open in browser" for exposed HTTP ports) — needs
separate user intent model - Writing to sandbox config (secrets, network policy changes) — read-only surface only
- Mobile / React Native surface — desktop-only bridge method, irrelevant on mobile
There was a problem hiding this comment.
🟡 Changes recommended
The provisioning token lacks relay-write access, and the managed tunnel uses the desktop-side forwarded port rather than the sandbox server port.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds automatic T3 Connect relay activation when registering Docker Sandbox environments over SSH.
Changes:
- Returns sandbox endpoint credentials after SSH registration.
- Adds bearer-authenticated sandbox relay linking.
- Integrates relay activation and outcome messaging into sandbox settings.
File summaries
| File | Description |
|---|---|
packages/client-runtime/src/connection/onboarding.ts |
Returns SSH endpoint and bearer details. |
packages/client-runtime/src/connection/onboarding.test.ts |
Tests prepared SSH endpoint details. |
packages/client-runtime/src/connection/index.ts |
Exports the registration result type. |
apps/web/src/connection/onboarding.ts |
Adds sandbox registration and relay linking command. |
apps/web/src/components/settings/ConnectionsSettings.tsx |
Uses the new sandbox flow and updates toasts. |
apps/web/src/cloud/linkEnvironment.ts |
Implements sandbox-specific managed relay activation. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 6
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| wsBaseUrl: input.target.wsBaseUrl, | ||
| providerKind: MANAGED_ENDPOINT_PROVIDER_KIND, | ||
| }, | ||
| origin: endpointOrigin(input.target.httpBaseUrl), |
| yield* linkSandboxEnvironmentToCloud({ | ||
| target, | ||
| clerkToken: input.clerkToken, | ||
| bearerToken: registration.bearerToken, | ||
| }).pipe( |
| * - Uses a plain fetch HTTP layer (no desktop bearer middleware) since auth is | ||
| * embedded in the `authorization` header per request. | ||
| */ | ||
| export function linkSandboxEnvironmentToCloud(input: { |
f058a3e to
ecd584e
Compare
6256850 to
e401c10
Compare
f26f8e9 to
0133ed1
Compare
ce65bea to
b826a2c
Compare
0133ed1 to
78ff59a
Compare
Thread transfer impact
This comment will update automatically after the next completed run. |
b826a2c to
6a613b0
Compare
78ff59a to
d00428b
Compare
6a613b0 to
0528fd1
Compare
|
Merged into |
Summary
packages/client-runtime—registerSshConnectionnow returnsSshRegistrationResult(addshttpBaseUrl,wsBaseUrl,bearerToken) instead of justEnvironmentId, so callers can make authenticated API calls to the sandbox server immediately after registration.apps/web/cloud— newlinkSandboxEnvironmentToCloudfunction: a trimmed-down relay activation path that uses the SSH provisioning bearer token per-request (no desktop auth middleware), skips the cloudflared WS readiness check (sandbox kit pre-installs it), and always uses managed tunnel mode.apps/web/connection— newconnectAndLinkSandboxEnvironmentruntime command: registers SSH → fires relay activation as a non-fatal side-effect (failure is logged as a warning, registration is not rolled back).apps/web/settings—DockerSandboxModeBodynow useshandleConnectSandboxHost, which fetches the Clerk token and calls the new command. Toast describes relay outcome ("with T3 Connect relay" vs "over SSH").Design decisions
remoteHttpClientLayer(globalThis.fetch)is used instead of the primary environment HTTP layer to avoid injecting the desktop bearer token into sandbox requests.ensureRelayClientAvailable: the sandbox kit is expected to pre-install cloudflared, so no WS check is needed before pushing relay config.satisfies SshRegistrationResulton the return literal (not an explicitEffect.Effect<…>annotation) to preserve correct type inference insideEffect.fn.Test plan