feat(infra): present Render as a cloud device
This commit is contained in:
1 parent
35ebbc4026
commit
69fb1fc503
11 files changed
+462
-94
No files matched your search
@@ -5,6 +5,7 @@ import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as PlatformError from "effect/PlatformError";
|
||||
import * as Schema from "effect/Schema";
|
||||
import { HostProcessEnvironment } from "@t3tools/shared/hostProcess";
|
||||
|
||||
import * as ServerConfig from "../config.ts";
|
||||
import * as ServerEnvironment from "./ServerEnvironment.ts";
|
||||
@@ -73,6 +74,33 @@ it.layer(NodeServices.layer)("ServerEnvironmentLive", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("advertises a Render cloud workspace from the host environment", () =>
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const baseDir = yield* fileSystem.makeTempDirectoryScoped({
|
||||
prefix: "t3-server-render-environment-test-",
|
||||
});
|
||||
|
||||
const descriptor = yield* Effect.gen(function* () {
|
||||
const serverEnvironment = yield* ServerEnvironment.ServerEnvironment;
|
||||
return yield* serverEnvironment.getDescriptor;
|
||||
}).pipe(
|
||||
Effect.provide(makeServerEnvironmentLayer(baseDir)),
|
||||
Effect.provideService(HostProcessEnvironment, {
|
||||
T3CODE_CLOUD_PROVIDER: "render",
|
||||
T3CODE_ENVIRONMENT_LABEL: "Render cloud environment",
|
||||
T3CODE_WORKSPACE_DIR: "/data/workspace",
|
||||
}),
|
||||
);
|
||||
|
||||
expect(descriptor.label).toBe("Render cloud environment");
|
||||
expect(descriptor.cloud).toEqual({
|
||||
provider: "render",
|
||||
workspaceRoot: "/data/workspace",
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("structures persisted environment id filesystem failures", () =>
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { EnvironmentId, type ExecutionEnvironmentDescriptor } from "@t3tools/contracts";
|
||||
import { HostProcessArchitecture, HostProcessPlatform } from "@t3tools/shared/hostProcess";
|
||||
import {
|
||||
HostProcessArchitecture,
|
||||
HostProcessEnvironment,
|
||||
HostProcessPlatform,
|
||||
} from "@t3tools/shared/hostProcess";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
@@ -69,6 +73,7 @@ export const make = Effect.gen(function* () {
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const hostPlatform = yield* HostProcessPlatform;
|
||||
const hostArchitecture = yield* HostProcessArchitecture;
|
||||
const hostEnvironment = yield* HostProcessEnvironment;
|
||||
|
||||
const readPersistedEnvironmentId = Effect.gen(function* () {
|
||||
const exists = yield* fileSystem.exists(serverConfig.environmentIdPath).pipe(
|
||||
@@ -125,7 +130,16 @@ export const make = Effect.gen(function* () {
|
||||
|
||||
const environmentId = EnvironmentId.make(environmentIdRaw);
|
||||
const cwdBaseName = path.basename(serverConfig.cwd).trim();
|
||||
const label = yield* resolveServerEnvironmentLabel({ cwdBaseName });
|
||||
const configuredLabel = hostEnvironment.T3CODE_ENVIRONMENT_LABEL?.trim();
|
||||
const label = configuredLabel || (yield* resolveServerEnvironmentLabel({ cwdBaseName }));
|
||||
const cloudProvider = hostEnvironment.T3CODE_CLOUD_PROVIDER?.trim().toLowerCase();
|
||||
const cloud =
|
||||
cloudProvider === "render"
|
||||
? {
|
||||
provider: "render" as const,
|
||||
workspaceRoot: hostEnvironment.T3CODE_WORKSPACE_DIR?.trim() || serverConfig.cwd,
|
||||
}
|
||||
: undefined;
|
||||
const launcher = yield* resolveServiceLauncherMode();
|
||||
const serverSelfUpdate = resolveServerSelfUpdateCapability({
|
||||
desktopManaged: serverConfig.mode === "desktop",
|
||||
@@ -139,6 +153,7 @@ export const make = Effect.gen(function* () {
|
||||
os: platformOs(hostPlatform),
|
||||
arch: platformArch(hostArchitecture),
|
||||
},
|
||||
...(cloud ? { cloud } : {}),
|
||||
serverVersion: packageJson.version,
|
||||
capabilities: {
|
||||
repositoryIdentity: true,
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { cloudCloneDestination, cloudEnvironmentProvider } from "./cloudEnvironment";
|
||||
|
||||
describe("cloudEnvironmentProvider", () => {
|
||||
it("uses advertised Render metadata", () => {
|
||||
expect(
|
||||
cloudEnvironmentProvider({
|
||||
displayUrl: null,
|
||||
serverConfig: {
|
||||
environment: {
|
||||
environmentId: "environment-1",
|
||||
label: "Render cloud environment",
|
||||
platform: { os: "linux", arch: "x64" },
|
||||
cloud: { provider: "render", workspaceRoot: "/data/workspace" },
|
||||
serverVersion: "1.0.0",
|
||||
capabilities: { repositoryIdentity: true },
|
||||
},
|
||||
} as never,
|
||||
}),
|
||||
).toBe("render");
|
||||
});
|
||||
|
||||
it("recognizes disconnected onrender.com environments", () => {
|
||||
expect(
|
||||
cloudEnvironmentProvider({
|
||||
displayUrl: "https://t3code-cloud-demo.onrender.com",
|
||||
serverConfig: null,
|
||||
}),
|
||||
).toBe("render");
|
||||
});
|
||||
});
|
||||
|
||||
describe("cloudCloneDestination", () => {
|
||||
it("clones provider repositories under the cloud workspace root", () => {
|
||||
expect(
|
||||
cloudCloneDestination({
|
||||
workspaceRoot: "/data/workspace/",
|
||||
repository: {
|
||||
provider: "github",
|
||||
nameWithOwner: "shivamhwp/render-ad",
|
||||
url: "https://github.com/shivamhwp/render-ad",
|
||||
sshUrl: "[email protected]:shivamhwp/render-ad.git",
|
||||
},
|
||||
remoteUrl: "[email protected]:shivamhwp/render-ad.git",
|
||||
}),
|
||||
).toBe("/data/workspace/render-ad");
|
||||
});
|
||||
|
||||
it("derives a directory from arbitrary Git URLs", () => {
|
||||
expect(
|
||||
cloudCloneDestination({
|
||||
workspaceRoot: "/data/workspace",
|
||||
repository: null,
|
||||
remoteUrl: "https://example.com/team/project.git?ref=main",
|
||||
}),
|
||||
).toBe("/data/workspace/project");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,65 @@
|
||||
import type { ServerConfig, SourceControlRepositoryInfo } from "@t3tools/contracts";
|
||||
|
||||
export type CloudEnvironmentProvider = "render";
|
||||
|
||||
interface CloudEnvironmentLike {
|
||||
readonly displayUrl: string | null;
|
||||
readonly serverConfig: ServerConfig | null;
|
||||
}
|
||||
|
||||
function isRenderHostname(value: string): boolean {
|
||||
try {
|
||||
return new URL(value).hostname.toLowerCase().endsWith(".onrender.com");
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function cloudEnvironmentProvider(
|
||||
environment: CloudEnvironmentLike,
|
||||
): CloudEnvironmentProvider | null {
|
||||
const advertisedProvider = environment.serverConfig?.environment.cloud?.provider;
|
||||
if (advertisedProvider === "render") {
|
||||
return advertisedProvider;
|
||||
}
|
||||
return environment.displayUrl && isRenderHostname(environment.displayUrl) ? "render" : null;
|
||||
}
|
||||
|
||||
export function cloudEnvironmentWorkspaceRoot(environment: CloudEnvironmentLike): string | null {
|
||||
return environment.serverConfig?.environment.cloud?.workspaceRoot ?? null;
|
||||
}
|
||||
|
||||
export function cloudEnvironmentProviderLabel(provider: CloudEnvironmentProvider): string {
|
||||
switch (provider) {
|
||||
case "render":
|
||||
return "Render";
|
||||
}
|
||||
}
|
||||
|
||||
export function inferRepositoryDirectoryName(input: {
|
||||
readonly repository: SourceControlRepositoryInfo | null;
|
||||
readonly remoteUrl: string;
|
||||
}): string | null {
|
||||
const candidate = input.repository?.nameWithOwner ?? input.remoteUrl;
|
||||
const withoutQuery = candidate.split(/[?#]/, 1)[0]?.replace(/[\\/]+$/, "") ?? "";
|
||||
const segment =
|
||||
withoutQuery
|
||||
.split(/[\\/:]/)
|
||||
.at(-1)
|
||||
?.replace(/\.git$/i, "")
|
||||
.trim() ?? "";
|
||||
return segment.length > 0 && segment !== "." && segment !== ".." ? segment : null;
|
||||
}
|
||||
|
||||
export function cloudCloneDestination(input: {
|
||||
readonly workspaceRoot: string;
|
||||
readonly repository: SourceControlRepositoryInfo | null;
|
||||
readonly remoteUrl: string;
|
||||
}): string | null {
|
||||
const directoryName = inferRepositoryDirectoryName(input);
|
||||
if (!directoryName) {
|
||||
return null;
|
||||
}
|
||||
const workspaceRoot = input.workspaceRoot.trim().replace(/[\\/]+$/, "");
|
||||
return workspaceRoot.length > 0 ? `${workspaceRoot}/${directoryName}` : null;
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import { useNavigate, useParams } from "@tanstack/react-router";
|
||||
import * as Option from "effect/Option";
|
||||
import {
|
||||
ArrowLeftIcon,
|
||||
CloudIcon,
|
||||
CornerLeftUpIcon,
|
||||
FileSearchIcon,
|
||||
FolderIcon,
|
||||
@@ -134,6 +135,13 @@ import { ComposerHandleContext, useComposerHandleContext } from "../composerHand
|
||||
import type { ChatComposerHandle } from "./chat/ChatComposer";
|
||||
import { getProjectOrderKey, selectProjectGroupingSettings } from "../logicalProject";
|
||||
import { legacyProjectCwdPreferenceKey, useUiStateStore } from "../uiStateStore";
|
||||
import {
|
||||
cloudCloneDestination,
|
||||
cloudEnvironmentProvider,
|
||||
cloudEnvironmentProviderLabel,
|
||||
cloudEnvironmentWorkspaceRoot,
|
||||
type CloudEnvironmentProvider,
|
||||
} from "../cloud/cloudEnvironment";
|
||||
import {
|
||||
buildSidebarProjectPickerEntries,
|
||||
buildSidebarProjectSnapshots,
|
||||
@@ -170,6 +178,7 @@ interface AddProjectEnvironmentOption {
|
||||
readonly isPrimary: boolean;
|
||||
readonly isConnected: boolean;
|
||||
readonly status: string;
|
||||
readonly cloudProvider: CloudEnvironmentProvider | null;
|
||||
}
|
||||
|
||||
type AddProjectRemoteProviderKind = Extract<
|
||||
@@ -192,6 +201,7 @@ type AddProjectCloneFlow =
|
||||
readonly repository: SourceControlRepositoryInfo | null;
|
||||
readonly remoteUrl: string;
|
||||
};
|
||||
type AddProjectCloneConfirmation = Extract<AddProjectCloneFlow, { readonly step: "confirm" }>;
|
||||
|
||||
const REMOTE_PROJECT_SOURCES: ReadonlyArray<AddProjectRemoteSource> = [
|
||||
"url",
|
||||
@@ -540,6 +550,10 @@ function OpenCommandPaletteDialog(props: {
|
||||
const lookupRepository = useAtomQueryRunner(sourceControlEnvironment.repository, {
|
||||
reportFailure: false,
|
||||
});
|
||||
const loadSourceControlDiscovery = useAtomQueryRunner(sourceControlEnvironment.discovery, {
|
||||
reportFailure: false,
|
||||
reportDefect: false,
|
||||
});
|
||||
const loadBrowsePath = useAtomQueryRunner(filesystemEnvironment.browse, {
|
||||
reportFailure: false,
|
||||
reportDefect: false,
|
||||
@@ -695,6 +709,7 @@ function OpenCommandPaletteDialog(props: {
|
||||
isPrimary,
|
||||
isConnected: canCreateProjectInEnvironment(environment.connection.phase),
|
||||
status: connectionStatusText(environment.connection),
|
||||
cloudProvider: cloudEnvironmentProvider(environment),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1209,7 +1224,7 @@ function OpenCommandPaletteDialog(props: {
|
||||
);
|
||||
|
||||
const startAddProjectSourceSelection = useCallback(
|
||||
(environmentId: EnvironmentId): void => {
|
||||
async (environmentId: EnvironmentId): Promise<void> => {
|
||||
const environment = environments.find(
|
||||
(candidate) => candidate.environmentId === environmentId,
|
||||
);
|
||||
@@ -1225,13 +1240,21 @@ function OpenCommandPaletteDialog(props: {
|
||||
}
|
||||
setAddProjectEnvironmentId(environmentId);
|
||||
setAddProjectCloneFlow(null);
|
||||
let discovery = browseEnvironmentId === environmentId ? sourceControlDiscovery.data : null;
|
||||
if (discovery === null) {
|
||||
const discoveryResult = await loadSourceControlDiscovery({
|
||||
environmentId,
|
||||
input: {},
|
||||
});
|
||||
if (discoveryResult._tag === "Success") {
|
||||
discovery = discoveryResult.value;
|
||||
}
|
||||
}
|
||||
pushPaletteView({
|
||||
addonIcon: <FolderPlusIcon className={ADDON_ICON_CLASS} />,
|
||||
groups: buildAddProjectSourceGroups(
|
||||
environmentId,
|
||||
buildAddProjectRemoteSourceReadiness(
|
||||
browseEnvironmentId === environmentId ? sourceControlDiscovery.data : null,
|
||||
),
|
||||
buildAddProjectRemoteSourceReadiness(discovery),
|
||||
),
|
||||
});
|
||||
},
|
||||
@@ -1239,44 +1262,79 @@ function OpenCommandPaletteDialog(props: {
|
||||
browseEnvironmentId,
|
||||
buildAddProjectSourceGroups,
|
||||
environments,
|
||||
loadSourceControlDiscovery,
|
||||
pushPaletteView,
|
||||
sourceControlDiscovery.data,
|
||||
],
|
||||
);
|
||||
|
||||
const addProjectEnvironmentItems: CommandPaletteActionItem[] = addProjectEnvironmentOptions.map(
|
||||
(option) => ({
|
||||
const addProjectEnvironmentGroups = useMemo<CommandPaletteView["groups"]>(() => {
|
||||
const toItem = (option: AddProjectEnvironmentOption): CommandPaletteActionItem => ({
|
||||
kind: "action",
|
||||
value: `action:add-project:environment:${option.environmentId}`,
|
||||
searchTerms: [option.label, option.environmentId, option.isPrimary ? "this device" : ""],
|
||||
searchTerms: [
|
||||
option.label,
|
||||
option.environmentId,
|
||||
option.isPrimary ? "this device" : "",
|
||||
option.cloudProvider ? "cloud render" : "",
|
||||
],
|
||||
title: option.label,
|
||||
description: option.isConnected
|
||||
? option.isPrimary
|
||||
? "This device"
|
||||
: option.environmentId
|
||||
? option.cloudProvider
|
||||
? `Cloud workspace · Powered by ${cloudEnvironmentProviderLabel(option.cloudProvider)}`
|
||||
: option.isPrimary
|
||||
? "This device"
|
||||
: option.environmentId
|
||||
: option.status,
|
||||
disabled: !option.isConnected,
|
||||
icon: <FolderPlusIcon className={ITEM_ICON_CLASS} />,
|
||||
icon: option.cloudProvider ? (
|
||||
<CloudIcon className={ITEM_ICON_CLASS} />
|
||||
) : (
|
||||
<FolderPlusIcon className={ITEM_ICON_CLASS} />
|
||||
),
|
||||
keepOpen: true,
|
||||
run: async () => {
|
||||
startAddProjectSourceSelection(option.environmentId);
|
||||
await startAddProjectSourceSelection(option.environmentId);
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
const cloudItems = addProjectEnvironmentOptions
|
||||
.filter((option) => option.cloudProvider !== null)
|
||||
.map(toItem);
|
||||
const deviceItems = addProjectEnvironmentOptions
|
||||
.filter((option) => option.cloudProvider === null)
|
||||
.map(toItem);
|
||||
|
||||
const addProjectEnvironmentGroups = useMemo<CommandPaletteView["groups"]>(
|
||||
() => [
|
||||
{
|
||||
value: "environments",
|
||||
label: "Environments",
|
||||
items: addProjectEnvironmentItems,
|
||||
},
|
||||
],
|
||||
[addProjectEnvironmentItems],
|
||||
return [
|
||||
...(cloudItems.length > 0
|
||||
? [
|
||||
{
|
||||
value: "cloud-environments",
|
||||
label: "Cloud environments · Powered by Render",
|
||||
items: cloudItems,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(deviceItems.length > 0
|
||||
? [
|
||||
{
|
||||
value: "device-environments",
|
||||
label: "Devices",
|
||||
items: deviceItems,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}, [addProjectEnvironmentOptions, startAddProjectSourceSelection]);
|
||||
const hasCloudAddProjectEnvironment = addProjectEnvironmentOptions.some(
|
||||
(option) => option.cloudProvider !== null,
|
||||
);
|
||||
|
||||
const openAddProjectFlow = useCallback(() => {
|
||||
if (addProjectEnvironmentOptions.length > 1 || defaultAddProjectEnvironmentId === null) {
|
||||
if (
|
||||
hasCloudAddProjectEnvironment ||
|
||||
addProjectEnvironmentOptions.length > 1 ||
|
||||
defaultAddProjectEnvironmentId === null
|
||||
) {
|
||||
pushPaletteView({
|
||||
addonIcon: <FolderPlusIcon className={ADDON_ICON_CLASS} />,
|
||||
groups: addProjectEnvironmentGroups,
|
||||
@@ -1301,6 +1359,7 @@ function OpenCommandPaletteDialog(props: {
|
||||
addProjectEnvironmentGroups,
|
||||
addProjectEnvironmentOptions.length,
|
||||
defaultAddProjectEnvironmentId,
|
||||
hasCloudAddProjectEnvironment,
|
||||
pushPaletteView,
|
||||
startAddProjectSourceSelection,
|
||||
]);
|
||||
@@ -1664,6 +1723,119 @@ function OpenCommandPaletteDialog(props: {
|
||||
return getAddProjectInitialQueryForEnvironment(environmentId);
|
||||
}
|
||||
|
||||
function getCloudCloneDestination(flow: AddProjectCloneConfirmation): string | null | undefined {
|
||||
const environment = environments.find(
|
||||
(candidate) => candidate.environmentId === flow.environmentId,
|
||||
);
|
||||
if (!environment) {
|
||||
return undefined;
|
||||
}
|
||||
const workspaceRoot = cloudEnvironmentWorkspaceRoot(environment);
|
||||
if (!workspaceRoot) {
|
||||
return undefined;
|
||||
}
|
||||
return cloudCloneDestination({
|
||||
workspaceRoot,
|
||||
repository: flow.repository,
|
||||
remoteUrl: flow.remoteUrl,
|
||||
});
|
||||
}
|
||||
|
||||
async function cloneIntoCloudEnvironmentIfConfigured(
|
||||
flow: AddProjectCloneConfirmation,
|
||||
): Promise<boolean> {
|
||||
const destination = getCloudCloneDestination(flow);
|
||||
if (destination === undefined) {
|
||||
return false;
|
||||
}
|
||||
if (destination === null) {
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "error",
|
||||
title: "Unable to name cloud workspace",
|
||||
description: "Use a repository URL whose final path contains the repository name.",
|
||||
}),
|
||||
);
|
||||
return true;
|
||||
}
|
||||
await cloneAndAddRemoteProject(flow, destination);
|
||||
return true;
|
||||
}
|
||||
|
||||
async function cloneAndAddRemoteProject(
|
||||
flow: AddProjectCloneConfirmation,
|
||||
destinationPathInput: string,
|
||||
): Promise<void> {
|
||||
const rawDestination = destinationPathInput.trim();
|
||||
if (rawDestination.length === 0 || isRemoteProjectCloning) {
|
||||
return;
|
||||
}
|
||||
|
||||
const targetEnvironment = environments.find(
|
||||
(candidate) => candidate.environmentId === flow.environmentId,
|
||||
);
|
||||
const targetPlatform = getEnvironmentBrowsePlatform(
|
||||
targetEnvironment?.serverConfig?.environment.platform.os,
|
||||
);
|
||||
const targetCurrentProjectCwd =
|
||||
currentProjectEnvironmentId === flow.environmentId ? currentProjectCwd : null;
|
||||
|
||||
if (isUnsupportedWindowsProjectPath(rawDestination, targetPlatform)) {
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "error",
|
||||
title: "Clone failed",
|
||||
description: "Windows-style paths are only supported on Windows.",
|
||||
}),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isExplicitRelativeProjectPath(rawDestination) && !targetCurrentProjectCwd) {
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "error",
|
||||
title: "Clone failed",
|
||||
description: "Relative paths require an active project.",
|
||||
}),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const destinationPath = resolveProjectPathForDispatch(rawDestination, targetCurrentProjectCwd);
|
||||
if (destinationPath.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsRemoteProjectCloning(true);
|
||||
const cloneResult = await cloneRepository({
|
||||
environmentId: flow.environmentId,
|
||||
input: {
|
||||
remoteUrl: flow.remoteUrl,
|
||||
destinationPath,
|
||||
},
|
||||
});
|
||||
setIsRemoteProjectCloning(false);
|
||||
if (cloneResult._tag === "Failure") {
|
||||
if (!isAtomCommandInterrupted(cloneResult)) {
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "error",
|
||||
title: "Clone failed",
|
||||
description: errorMessage(squashAtomCommandFailure(cloneResult)),
|
||||
}),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
await handleAddProjectForEnvironment({
|
||||
environmentId: flow.environmentId,
|
||||
rawCwd: cloneResult.value.cwd,
|
||||
platform: targetPlatform,
|
||||
currentProjectCwd: targetCurrentProjectCwd,
|
||||
});
|
||||
}
|
||||
|
||||
async function submitAddProjectCloneFlow(destinationPathInput?: string): Promise<void> {
|
||||
if (!addProjectCloneFlow) {
|
||||
return;
|
||||
@@ -1687,15 +1859,19 @@ function OpenCommandPaletteDialog(props: {
|
||||
|
||||
const provider = remoteProjectSourceProvider(addProjectCloneFlow.source);
|
||||
if (!provider) {
|
||||
const destinationPath = getDefaultCloneParentPath(addProjectCloneFlow.environmentId);
|
||||
setAddProjectCloneFlow({
|
||||
const confirmation: AddProjectCloneConfirmation = {
|
||||
step: "confirm",
|
||||
environmentId: addProjectCloneFlow.environmentId,
|
||||
source: addProjectCloneFlow.source,
|
||||
repositoryInput: rawRepository,
|
||||
repository: null,
|
||||
remoteUrl: rawRepository,
|
||||
});
|
||||
};
|
||||
if (await cloneIntoCloudEnvironmentIfConfigured(confirmation)) {
|
||||
return;
|
||||
}
|
||||
const destinationPath = getDefaultCloneParentPath(addProjectCloneFlow.environmentId);
|
||||
setAddProjectCloneFlow(confirmation);
|
||||
setHighlightedItemValue(null);
|
||||
setQuery(destinationPath);
|
||||
setBrowseGeneration((generation) => generation + 1);
|
||||
@@ -1724,78 +1900,32 @@ function OpenCommandPaletteDialog(props: {
|
||||
return;
|
||||
}
|
||||
const repository = lookupResult.value;
|
||||
const destinationPath = getDefaultCloneParentPath(addProjectCloneFlow.environmentId);
|
||||
setAddProjectCloneFlow({
|
||||
const cloneEnvironment = environments.find(
|
||||
(environment) => environment.environmentId === addProjectCloneFlow.environmentId,
|
||||
);
|
||||
const confirmation: AddProjectCloneConfirmation = {
|
||||
step: "confirm",
|
||||
environmentId: addProjectCloneFlow.environmentId,
|
||||
source: addProjectCloneFlow.source,
|
||||
repositoryInput: rawRepository,
|
||||
repository,
|
||||
remoteUrl: repository.sshUrl,
|
||||
});
|
||||
remoteUrl:
|
||||
cloneEnvironment && cloudEnvironmentWorkspaceRoot(cloneEnvironment)
|
||||
? repository.url
|
||||
: repository.sshUrl,
|
||||
};
|
||||
if (await cloneIntoCloudEnvironmentIfConfigured(confirmation)) {
|
||||
return;
|
||||
}
|
||||
const destinationPath = getDefaultCloneParentPath(addProjectCloneFlow.environmentId);
|
||||
setAddProjectCloneFlow(confirmation);
|
||||
setHighlightedItemValue(null);
|
||||
setQuery(destinationPath);
|
||||
setBrowseGeneration((generation) => generation + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
const rawDestination = (destinationPathInput ?? query).trim();
|
||||
if (rawDestination.length === 0 || isRemoteProjectCloning) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isUnsupportedWindowsProjectPath(rawDestination, browseEnvironmentPlatform)) {
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "error",
|
||||
title: "Clone failed",
|
||||
description: "Windows-style paths are only supported on Windows.",
|
||||
}),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isExplicitRelativeProjectPath(rawDestination) && !currentProjectCwdForBrowse) {
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "error",
|
||||
title: "Clone failed",
|
||||
description: "Relative paths require an active project.",
|
||||
}),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const destinationPath = resolveProjectPathForDispatch(
|
||||
rawDestination,
|
||||
currentProjectCwdForBrowse,
|
||||
);
|
||||
if (destinationPath.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsRemoteProjectCloning(true);
|
||||
const cloneResult = await cloneRepository({
|
||||
environmentId: addProjectCloneFlow.environmentId,
|
||||
input: {
|
||||
remoteUrl: addProjectCloneFlow.remoteUrl,
|
||||
destinationPath,
|
||||
},
|
||||
});
|
||||
setIsRemoteProjectCloning(false);
|
||||
if (cloneResult._tag === "Failure") {
|
||||
if (!isAtomCommandInterrupted(cloneResult)) {
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "error",
|
||||
title: "Clone failed",
|
||||
description: errorMessage(squashAtomCommandFailure(cloneResult)),
|
||||
}),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
await handleAddProject(cloneResult.value.cwd);
|
||||
await cloneAndAddRemoteProject(addProjectCloneFlow, destinationPathInput ?? query);
|
||||
}
|
||||
|
||||
const browseTo = useCallback(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
ChevronsLeftRightEllipsisIcon,
|
||||
CloudIcon,
|
||||
PlusIcon,
|
||||
QrCodeIcon,
|
||||
RefreshCwIcon,
|
||||
@@ -131,6 +132,7 @@ import { ConnectionStatusDot } from "../ConnectionStatusDot";
|
||||
import { ServerUpdateAction, ServerUpdateProgress } from "../ServerUpdateAction";
|
||||
import { CloudEnvironmentConnectRows } from "../cloud/CloudEnvironmentConnectList";
|
||||
import { ITEM_ROW_CLASSNAME, ITEM_ROW_INNER_CLASSNAME } from "./itemRows";
|
||||
import { cloudEnvironmentProvider, cloudEnvironmentProviderLabel } from "~/cloud/cloudEnvironment";
|
||||
|
||||
const DEFAULT_TAILSCALE_SERVE_PORT = 443;
|
||||
const EMPTY_ADVERTISED_ENDPOINTS: ReadonlyArray<AdvertisedEndpoint> = [];
|
||||
@@ -1394,7 +1396,9 @@ function SavedBackendListRow({
|
||||
environment.entry.profile.value._tag === "SshConnectionProfile"
|
||||
? environment.entry.profile.value.target
|
||||
: null;
|
||||
const cloudProvider = cloudEnvironmentProvider(environment);
|
||||
const metadataBits = [
|
||||
cloudProvider ? `Powered by ${cloudEnvironmentProviderLabel(cloudProvider)}` : null,
|
||||
sshTarget ? `SSH ${formatDesktopSshTarget(sshTarget)}` : null,
|
||||
environment.relayManaged ? "T3 Connect" : null,
|
||||
].filter((value): value is string => value !== null);
|
||||
@@ -1742,6 +1746,15 @@ 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],
|
||||
);
|
||||
const savedDesktopSshEnvironmentsByAlias = useMemo(
|
||||
() =>
|
||||
savedEnvironments.reduce<Record<string, EnvironmentPresentation>>(
|
||||
@@ -3344,6 +3357,33 @@ export function ConnectionsSettings() {
|
||||
</SettingsSection>
|
||||
)}
|
||||
|
||||
<SettingsSection
|
||||
{...searchableSetting("cloud-environments")}
|
||||
icon={<CloudIcon className="size-4" />}
|
||||
>
|
||||
<SettingsRow
|
||||
title="Powered by Render"
|
||||
description="Run the normal T3 Code server as a persistent Render service. Pair it once, then clone repositories and run agents in its cloud workspace just like another device."
|
||||
status="Cloud repositories are stored on the Render disk under /data/workspace."
|
||||
/>
|
||||
{renderCloudEnvironments.length === 0 ? (
|
||||
<SettingsRow
|
||||
title="No Render environment paired"
|
||||
description="Deploy the Render Blueprint, copy the Pair URL from its service logs, and open it on this device. The environment will appear here automatically."
|
||||
/>
|
||||
) : (
|
||||
renderCloudEnvironments.map((environment) => (
|
||||
<SavedBackendListRow
|
||||
key={environment.environmentId}
|
||||
environment={environment}
|
||||
removingEnvironmentId={removingSavedEnvironmentId}
|
||||
onConnect={handleConnectSavedBackend}
|
||||
onRemove={handleRemoveSavedBackend}
|
||||
/>
|
||||
))
|
||||
)}
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection
|
||||
{...searchableSetting("remote-environments")}
|
||||
headerAction={
|
||||
@@ -3408,7 +3448,7 @@ export function ConnectionsSettings() {
|
||||
</Dialog>
|
||||
}
|
||||
>
|
||||
{savedEnvironments.map((environment) => (
|
||||
{savedNonCloudEnvironments.map((environment) => (
|
||||
<SavedBackendListRow
|
||||
key={environment.environmentId}
|
||||
environment={environment}
|
||||
|
||||
@@ -166,6 +166,11 @@ export const SETTINGS_SEARCH_ITEMS = [
|
||||
title: "Source control",
|
||||
to: "/settings/source-control",
|
||||
},
|
||||
{
|
||||
id: "cloud-environments",
|
||||
title: "Cloud environments",
|
||||
to: "/settings/connections",
|
||||
},
|
||||
{
|
||||
id: "remote-environments",
|
||||
title: "Remote environments",
|
||||
|
||||
+9
-3
@@ -24,15 +24,21 @@ The root [`render.yaml`](../../render.yaml) creates:
|
||||
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 → Remote environments**.
|
||||
under **Settings → Connections → Cloud environments**, labeled as powered by Render.
|
||||
6. Authenticate a provider and source control as described below.
|
||||
7. Open the Command Palette, choose **Add Project**, and select the Render environment. Clone a
|
||||
GitHub repository, another supported source-control repository, or any Git URL.
|
||||
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
|
||||
Git URL. T3 Code clones it directly into the Render workspace; there is no local destination
|
||||
picker.
|
||||
|
||||
Repositories are selected after pairing rather than baked into the Blueprint. Each clone is stored
|
||||
under `/data/workspace` and survives deploys. This keeps the public deployment configuration generic
|
||||
and lets each user bring repositories they already have access to.
|
||||
|
||||
The Render service advertises cloud metadata in its normal T3 environment descriptor. That is what
|
||||
lets clients present it as a cloud device and automatically route project cloning to its persistent
|
||||
workspace while leaving the existing local-device folder flow unchanged.
|
||||
|
||||
The demo Blueprint is pinned to `feat/render-cloud-environment` so it can deploy before the draft
|
||||
pull request is merged. Update the `branch` field in `render.yaml` if you rename or reuse the branch.
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@ pairing_ttl="${T3CODE_PAIRING_TTL:-24h}"
|
||||
|
||||
export CODEX_HOME="$codex_home"
|
||||
export CLAUDE_CONFIG_DIR="$claude_config_dir"
|
||||
export T3CODE_CLOUD_PROVIDER="${T3CODE_CLOUD_PROVIDER:-render}"
|
||||
export T3CODE_ENVIRONMENT_LABEL="${T3CODE_ENVIRONMENT_LABEL:-Render cloud environment}"
|
||||
export T3CODE_WORKSPACE_DIR="$workspace_dir"
|
||||
|
||||
mkdir -p "$t3_home" "$workspace_dir" "$codex_home" "$claude_config_dir"
|
||||
|
||||
|
||||
@@ -20,6 +20,16 @@ export const ExecutionEnvironmentPlatform = Schema.Struct({
|
||||
});
|
||||
export type ExecutionEnvironmentPlatform = typeof ExecutionEnvironmentPlatform.Type;
|
||||
|
||||
export const ExecutionEnvironmentCloudProvider = Schema.Literals(["render"]);
|
||||
export type ExecutionEnvironmentCloudProvider = typeof ExecutionEnvironmentCloudProvider.Type;
|
||||
|
||||
/** Metadata advertised by a backend whose workspace is hosted by a cloud provider. */
|
||||
export const ExecutionEnvironmentCloud = Schema.Struct({
|
||||
provider: ExecutionEnvironmentCloudProvider,
|
||||
workspaceRoot: TrimmedNonEmptyString,
|
||||
});
|
||||
export type ExecutionEnvironmentCloud = typeof ExecutionEnvironmentCloud.Type;
|
||||
|
||||
/** How a server can replace itself with another version when asked over RPC.
|
||||
New servers only advertise the stable launcher-backed "boot-service" path;
|
||||
"respawn" remains decodable for compatibility with older servers. */
|
||||
@@ -67,6 +77,7 @@ export const ExecutionEnvironmentDescriptor = Schema.Struct({
|
||||
environmentId: EnvironmentId,
|
||||
label: TrimmedNonEmptyString,
|
||||
platform: ExecutionEnvironmentPlatform,
|
||||
cloud: Schema.optionalKey(ExecutionEnvironmentCloud),
|
||||
serverVersion: TrimmedNonEmptyString,
|
||||
capabilities: ExecutionEnvironmentCapabilities,
|
||||
});
|
||||
|
||||
@@ -14,5 +14,11 @@ services:
|
||||
mountPath: /data
|
||||
sizeGB: 10
|
||||
envVars:
|
||||
- key: T3CODE_CLOUD_PROVIDER
|
||||
value: render
|
||||
- key: T3CODE_ENVIRONMENT_LABEL
|
||||
value: Render cloud environment
|
||||
- key: T3CODE_WORKSPACE_DIR
|
||||
value: /data/workspace
|
||||
- key: T3CODE_PAIRING_TTL
|
||||
value: 24h
|
||||
Reference in new issue
Block a user