From 0ccd1c0ce83fe7abc474fd065b35e66a5c9b0684 Mon Sep 17 00:00:00 2001 From: Shivam Sharma <91240327+shivamhwp@users.noreply.github.com> Date: Wed, 5 Aug 2026 08:34:56 +0530 Subject: [PATCH] feat(web): add Render cloud setup page --- apps/web/src/components/CommandPalette.tsx | 6 +- .../settings/CloudEnvironmentsSettings.tsx | 255 ++++++++++++++++++ .../settings/ConnectionsSettings.tsx | 33 --- .../settings/SettingsSidebarNav.tsx | 2 + .../src/components/settings/settingsSearch.ts | 4 +- apps/web/src/routeTree.gen.ts | 22 ++ .../routes/settings.cloud-environments.tsx | 7 + docs/user/render.md | 13 +- 8 files changed, 301 insertions(+), 41 deletions(-) create mode 100644 apps/web/src/components/settings/CloudEnvironmentsSettings.tsx create mode 100644 apps/web/src/routes/settings.cloud-environments.tsx diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsx index db1c3d35ae..a35fd950ba 100644 --- a/apps/web/src/components/CommandPalette.tsx +++ b/apps/web/src/components/CommandPalette.tsx @@ -1294,6 +1294,10 @@ function OpenCommandPaletteDialog(props: { ), keepOpen: true, run: async () => { + if (option.cloudProvider) { + startAddProjectClone(option.environmentId, "url"); + return; + } await startAddProjectSourceSelection(option.environmentId); }, }); @@ -1324,7 +1328,7 @@ function OpenCommandPaletteDialog(props: { ] : []), ]; - }, [addProjectEnvironmentOptions, startAddProjectSourceSelection]); + }, [addProjectEnvironmentOptions, startAddProjectClone, startAddProjectSourceSelection]); const hasCloudAddProjectEnvironment = addProjectEnvironmentOptions.some( (option) => option.cloudProvider !== null, ); diff --git a/apps/web/src/components/settings/CloudEnvironmentsSettings.tsx b/apps/web/src/components/settings/CloudEnvironmentsSettings.tsx new file mode 100644 index 0000000000..4714d36799 --- /dev/null +++ b/apps/web/src/components/settings/CloudEnvironmentsSettings.tsx @@ -0,0 +1,255 @@ +import { CheckIcon, CloudIcon, CopyIcon, ExternalLinkIcon, LoaderCircleIcon } from "lucide-react"; +import { connectionStatusText } from "@t3tools/client-runtime/connection"; +import { + isAtomCommandInterrupted, + squashAtomCommandFailure, +} from "@t3tools/client-runtime/state/runtime"; +import type { EnvironmentId } from "@t3tools/contracts"; +import { useCallback, useMemo, useState } from "react"; + +import { cloudEnvironmentProvider } from "~/cloud/cloudEnvironment"; +import { openCommandPalette } from "~/commandPaletteBus"; +import { environmentCatalog } from "~/connection/catalog"; +import { connectPairing as connectPairingAtom } from "~/connection/onboarding"; +import { readHostedPairingRequest } from "~/hostedPairing"; +import { useCopyToClipboard } from "~/hooks/useCopyToClipboard"; +import { getPairingTokenFromUrl } from "~/pairingUrl"; +import { useAtomCommand } from "~/state/use-atom-command"; +import { type EnvironmentPresentation, useEnvironments } from "~/state/environments"; +import { Button } from "../ui/button"; +import { Input } from "../ui/input"; +import { stackedThreadToast, toastManager } from "../ui/toast"; +import { SettingsPageContainer, SettingsRow, SettingsSection } from "./settingsLayout"; +import { searchableSetting } from "./settingsSearch"; + +const RENDER_DEPLOY_URL = + "https://dashboard.render.com/blueprint/new?repo=https%3A%2F%2Fgithub.com%2Fpingdotgg%2Ft3code&branch=feat%2Frender-cloud-environment"; +const CODEX_LOGIN_COMMAND = "codex login --device-auth"; +const GITHUB_LOGIN_COMMAND = "gh auth login --web --git-protocol https"; +const SHARE_ACCESS_COMMAND = + 'node /app/apps/server/dist/bin.mjs auth pairing create --base-dir /data/t3 --label "Shared Render access" --ttl 24h --json | T3CODE_PUBLIC_URL="$RENDER_EXTERNAL_URL" node /app/infra/render/pair-url.mjs'; + +function pairingInput(value: string): { readonly host: string; readonly pairingCode: string } { + const url = new URL(value.trim()); + const hostedRequest = readHostedPairingRequest(url); + if (hostedRequest) { + return { host: hostedRequest.host, pairingCode: hostedRequest.token }; + } + const pairingCode = getPairingTokenFromUrl(url); + if (!pairingCode) { + throw new Error("Paste the full Pair URL from the Render logs."); + } + return { host: url.origin, pairingCode }; +} + +function CopyCommand({ command }: { readonly command: string }) { + const { copyToClipboard, isCopied } = useCopyToClipboard({ target: "command" }); + return ( +
+ {command} + +
+ ); +} + +function RenderEnvironmentRow({ + environment, + busyEnvironmentId, + onConnect, + onDisconnect, +}: { + readonly environment: EnvironmentPresentation; + readonly busyEnvironmentId: EnvironmentId | null; + readonly onConnect: (environmentId: EnvironmentId) => void; + readonly onDisconnect: (environmentId: EnvironmentId) => void; +}) { + const isConnected = environment.connection.phase === "connected"; + const isBusy = busyEnvironmentId === environment.environmentId; + return ( + + {isConnected ? ( + + ) : null} + + + } + /> + ); +} + +export function CloudEnvironmentsSettings() { + const { environments } = useEnvironments(); + const connectPairing = useAtomCommand(connectPairingAtom, { reportFailure: false }); + const retryEnvironment = useAtomCommand(environmentCatalog.retryNow, { reportFailure: false }); + const removeEnvironment = useAtomCommand(environmentCatalog.remove, { reportFailure: false }); + const [pairUrl, setPairUrl] = useState(""); + const [pairing, setPairing] = useState(false); + const [pairError, setPairError] = useState(null); + const [busyEnvironmentId, setBusyEnvironmentId] = useState(null); + const renderEnvironments = useMemo( + () => environments.filter((environment) => cloudEnvironmentProvider(environment) === "render"), + [environments], + ); + + const reportFailure = useCallback((title: string, description: string) => { + toastManager.add(stackedThreadToast({ type: "error", title, description })); + }, []); + + const handlePair = useCallback(async () => { + setPairError(null); + let input: ReturnType; + try { + input = pairingInput(pairUrl); + } catch (error) { + setPairError(error instanceof Error ? error.message : "Invalid Pair URL."); + return; + } + setPairing(true); + const result = await connectPairing(input); + setPairing(false); + if (result._tag === "Failure") { + if (!isAtomCommandInterrupted(result)) { + const failure = squashAtomCommandFailure(result); + setPairError(failure instanceof Error ? failure.message : "Could not pair environment."); + } + return; + } + setPairUrl(""); + toastManager.add({ type: "success", title: "Render environment connected" }); + }, [connectPairing, pairUrl]); + + const handleConnect = useCallback( + async (environmentId: EnvironmentId) => { + setBusyEnvironmentId(environmentId); + const result = await retryEnvironment(environmentId); + setBusyEnvironmentId(null); + if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) { + const failure = squashAtomCommandFailure(result); + reportFailure( + "Could not connect Render environment", + failure instanceof Error ? failure.message : "Could not connect Render environment.", + ); + } + }, + [reportFailure, retryEnvironment], + ); + + const handleDisconnect = useCallback( + async (environmentId: EnvironmentId) => { + setBusyEnvironmentId(environmentId); + const result = await removeEnvironment(environmentId); + setBusyEnvironmentId(null); + if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) { + const failure = squashAtomCommandFailure(result); + reportFailure( + "Could not disconnect Render environment", + failure instanceof Error ? failure.message : "Could not disconnect Render environment.", + ); + } + }, + [removeEnvironment, reportFailure], + ); + + return ( + + } + > + } + > + Deploy on Render + + + } + /> + + + + +
+ setPairUrl(event.target.value)} + placeholder="https://app.t3.codes/pair?host=..." + onKeyDown={(event) => { + if (event.key === "Enter") void handlePair(); + }} + /> + +
+ {pairError ?

{pairError}

: null} +
+ {renderEnvironments.map((environment) => ( + void handleConnect(environmentId)} + onDisconnect={(environmentId) => void handleDisconnect(environmentId)} + /> + ))} +
+ + + + + + + + + + + + +
+ ); +} diff --git a/apps/web/src/components/settings/ConnectionsSettings.tsx b/apps/web/src/components/settings/ConnectionsSettings.tsx index b6180e19c0..08a7380c52 100644 --- a/apps/web/src/components/settings/ConnectionsSettings.tsx +++ b/apps/web/src/components/settings/ConnectionsSettings.tsx @@ -1,6 +1,5 @@ import { ChevronsLeftRightEllipsisIcon, - CloudIcon, PlusIcon, QrCodeIcon, RefreshCwIcon, @@ -1746,11 +1745,6 @@ export function ConnectionsSettings() { .toSorted((left, right) => left.label.localeCompare(right.label)), [environments], ); - const renderCloudEnvironments = useMemo( - () => - savedEnvironments.filter((environment) => cloudEnvironmentProvider(environment) === "render"), - [savedEnvironments], - ); const savedNonCloudEnvironments = useMemo( () => savedEnvironments.filter((environment) => cloudEnvironmentProvider(environment) === null), [savedEnvironments], @@ -3357,33 +3351,6 @@ export function ConnectionsSettings() { )} - } - > - - {renderCloudEnvironments.length === 0 ? ( - - ) : ( - renderCloudEnvironments.map((environment) => ( - - )) - )} - - > = { "/settings/providers": "Providers", "/settings/source-control": "Source Control", "/settings/connections": "Connections", + "/settings/cloud-environments": "Cloud environments", "/settings/beta": "Beta", "/settings/archived": "Archive", }; @@ -169,7 +171,7 @@ export const SETTINGS_SEARCH_ITEMS = [ { id: "cloud-environments", title: "Cloud environments", - to: "/settings/connections", + to: "/settings/cloud-environments", }, { id: "remote-environments", diff --git a/apps/web/src/routeTree.gen.ts b/apps/web/src/routeTree.gen.ts index 58ab4c3a71..e932d58d61 100644 --- a/apps/web/src/routeTree.gen.ts +++ b/apps/web/src/routeTree.gen.ts @@ -20,6 +20,7 @@ import { Route as SettingsKeybindingsRouteImport } from './routes/settings.keybi import { Route as SettingsGeneralRouteImport } from './routes/settings.general' import { Route as SettingsDiagnosticsRouteImport } from './routes/settings.diagnostics' import { Route as SettingsConnectionsRouteImport } from './routes/settings.connections' +import { Route as SettingsCloudEnvironmentsRouteImport } from './routes/settings.cloud-environments' import { Route as SettingsBetaRouteImport } from './routes/settings.beta' import { Route as SettingsArchivedRouteImport } from './routes/settings.archived' import { Route as SettingsAppearanceRouteImport } from './routes/settings.appearance' @@ -81,6 +82,12 @@ const SettingsConnectionsRoute = SettingsConnectionsRouteImport.update({ path: '/connections', getParentRoute: () => SettingsRoute, } as any) +const SettingsCloudEnvironmentsRoute = + SettingsCloudEnvironmentsRouteImport.update({ + id: '/cloud-environments', + path: '/cloud-environments', + getParentRoute: () => SettingsRoute, + } as any) const SettingsBetaRoute = SettingsBetaRouteImport.update({ id: '/beta', path: '/beta', @@ -122,6 +129,7 @@ export interface FileRoutesByFullPath { '/settings/appearance': typeof SettingsAppearanceRoute '/settings/archived': typeof SettingsArchivedRoute '/settings/beta': typeof SettingsBetaRoute + '/settings/cloud-environments': typeof SettingsCloudEnvironmentsRoute '/settings/connections': typeof SettingsConnectionsRoute '/settings/diagnostics': typeof SettingsDiagnosticsRoute '/settings/general': typeof SettingsGeneralRoute @@ -139,6 +147,7 @@ export interface FileRoutesByTo { '/settings/appearance': typeof SettingsAppearanceRoute '/settings/archived': typeof SettingsArchivedRoute '/settings/beta': typeof SettingsBetaRoute + '/settings/cloud-environments': typeof SettingsCloudEnvironmentsRoute '/settings/connections': typeof SettingsConnectionsRoute '/settings/diagnostics': typeof SettingsDiagnosticsRoute '/settings/general': typeof SettingsGeneralRoute @@ -159,6 +168,7 @@ export interface FileRoutesById { '/settings/appearance': typeof SettingsAppearanceRoute '/settings/archived': typeof SettingsArchivedRoute '/settings/beta': typeof SettingsBetaRoute + '/settings/cloud-environments': typeof SettingsCloudEnvironmentsRoute '/settings/connections': typeof SettingsConnectionsRoute '/settings/diagnostics': typeof SettingsDiagnosticsRoute '/settings/general': typeof SettingsGeneralRoute @@ -180,6 +190,7 @@ export interface FileRouteTypes { | '/settings/appearance' | '/settings/archived' | '/settings/beta' + | '/settings/cloud-environments' | '/settings/connections' | '/settings/diagnostics' | '/settings/general' @@ -197,6 +208,7 @@ export interface FileRouteTypes { | '/settings/appearance' | '/settings/archived' | '/settings/beta' + | '/settings/cloud-environments' | '/settings/connections' | '/settings/diagnostics' | '/settings/general' @@ -216,6 +228,7 @@ export interface FileRouteTypes { | '/settings/appearance' | '/settings/archived' | '/settings/beta' + | '/settings/cloud-environments' | '/settings/connections' | '/settings/diagnostics' | '/settings/general' @@ -314,6 +327,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof SettingsConnectionsRouteImport parentRoute: typeof SettingsRoute } + '/settings/cloud-environments': { + id: '/settings/cloud-environments' + path: '/cloud-environments' + fullPath: '/settings/cloud-environments' + preLoaderRoute: typeof SettingsCloudEnvironmentsRouteImport + parentRoute: typeof SettingsRoute + } '/settings/beta': { id: '/settings/beta' path: '/beta' @@ -377,6 +397,7 @@ interface SettingsRouteChildren { SettingsAppearanceRoute: typeof SettingsAppearanceRoute SettingsArchivedRoute: typeof SettingsArchivedRoute SettingsBetaRoute: typeof SettingsBetaRoute + SettingsCloudEnvironmentsRoute: typeof SettingsCloudEnvironmentsRoute SettingsConnectionsRoute: typeof SettingsConnectionsRoute SettingsDiagnosticsRoute: typeof SettingsDiagnosticsRoute SettingsGeneralRoute: typeof SettingsGeneralRoute @@ -389,6 +410,7 @@ const SettingsRouteChildren: SettingsRouteChildren = { SettingsAppearanceRoute: SettingsAppearanceRoute, SettingsArchivedRoute: SettingsArchivedRoute, SettingsBetaRoute: SettingsBetaRoute, + SettingsCloudEnvironmentsRoute: SettingsCloudEnvironmentsRoute, SettingsConnectionsRoute: SettingsConnectionsRoute, SettingsDiagnosticsRoute: SettingsDiagnosticsRoute, SettingsGeneralRoute: SettingsGeneralRoute, diff --git a/apps/web/src/routes/settings.cloud-environments.tsx b/apps/web/src/routes/settings.cloud-environments.tsx new file mode 100644 index 0000000000..7bf40ceccb --- /dev/null +++ b/apps/web/src/routes/settings.cloud-environments.tsx @@ -0,0 +1,7 @@ +import { createFileRoute } from "@tanstack/react-router"; + +import { CloudEnvironmentsSettings } from "../components/settings/CloudEnvironmentsSettings"; + +export const Route = createFileRoute("/settings/cloud-environments")({ + component: CloudEnvironmentsSettings, +}); diff --git a/docs/user/render.md b/docs/user/render.md index 69d52d93d8..aeac9b342a 100644 --- a/docs/user/render.md +++ b/docs/user/render.md @@ -4,9 +4,9 @@ This experimental setup runs one T3 Code environment as a Render web service. Th the provider processes, repositories, worktrees, terminals, and T3 Code state. The web, desktop, and mobile clients connect to it over Render's public HTTPS and WebSocket endpoint. -This is a single-user deployment, not a multi-tenant hosted service. The attached persistent disk -also limits the service to one instance. Multiple agent threads can still run concurrently inside -that instance. +This is one shared environment, not a multi-tenant hosted service. Multiple trusted people can pair +to it and run agent threads concurrently. The attached persistent disk limits the service to one +instance. ## What the Blueprint Creates @@ -23,8 +23,7 @@ The root [`render.yaml`](../../render.yaml) creates: 3. Deploy the Blueprint and wait for the service health check to pass. 4. Open the service logs and copy the `Pair URL` printed during startup. Treat this URL like a password: it contains a one-time pairing credential. -5. Open the URL in a browser. The hosted T3 Code app pairs with the Render environment and saves it - under **Settings → Connections → Cloud environments**, labeled as powered by Render. +5. Open the URL in a browser, or paste it under **Settings → Cloud environments → Pair URL**. 6. Authenticate a provider and source control as described below. 7. Open the Command Palette and choose **Add Project → Cloud environments → Render cloud environment**. Select a GitHub repository, another supported source-control repository, or any @@ -71,13 +70,15 @@ or paste one into a project URL. T3 Connect is not required for this deployment. Render already gives the environment a public HTTPS and WebSocket endpoint, so the Pair URL registers it as a direct remote environment. Use its existing -Connect and Disconnect controls under **Settings → Connections**. T3 Connect remains useful for +Connect and Disconnect controls under **Settings → Cloud environments**. T3 Connect remains useful for machines that need its managed tunnel or account-level environment discovery. ## Operations - Each deploy prints a fresh pairing URL with a 24-hour lifetime. Existing paired browser sessions remain authenticated until revoked with `t3 auth`. +- To share the environment, use the copyable command under **Settings → Cloud environments → Give + someone access** and send that person the new one-time Pair URL. - Render terminates the previous instance before starting a new one because the service has a disk. Expect a short interruption during deploys. - Do not use this Blueprint for untrusted users or repositories. Coding agents can execute commands