diff --git a/apps/desktop/src/lib/trpc/routers/workspaces/procedures/create.ts b/apps/desktop/src/lib/trpc/routers/workspaces/procedures/create.ts index 632f81b87ec..1c0a253b316 100644 --- a/apps/desktop/src/lib/trpc/routers/workspaces/procedures/create.ts +++ b/apps/desktop/src/lib/trpc/routers/workspaces/procedures/create.ts @@ -333,5 +333,52 @@ export const createCreateProcedures = () => { projectId: project.id, }; }), + + createCloudWorkspace: publicProcedure + .input( + z.object({ + projectId: z.string(), + name: z.string().optional(), + }), + ) + .mutation(async ({ input }) => { + const project = localDb + .select() + .from(projects) + .where(eq(projects.id, input.projectId)) + .get(); + if (!project) { + throw new Error(`Project ${input.projectId} not found`); + } + + const maxTabOrder = getMaxWorkspaceTabOrder(input.projectId); + const workspaceName = input.name?.trim() || "Cloud Workspace"; + + const workspace = localDb + .insert(workspaces) + .values({ + projectId: input.projectId, + type: "cloud", + branch: "cloud", + name: workspaceName, + tabOrder: maxTabOrder + 1, + }) + .returning() + .get(); + + setLastActiveWorkspace(workspace.id); + activateProject(project); + + track("workspace_created", { + workspace_id: workspace.id, + project_id: project.id, + type: "cloud", + }); + + return { + workspace, + projectId: project.id, + }; + }), }); }; diff --git a/apps/desktop/src/lib/trpc/routers/workspaces/procedures/query.ts b/apps/desktop/src/lib/trpc/routers/workspaces/procedures/query.ts index 86404e18a56..a7c8fd1f935 100644 --- a/apps/desktop/src/lib/trpc/routers/workspaces/procedures/query.ts +++ b/apps/desktop/src/lib/trpc/routers/workspaces/procedures/query.ts @@ -107,7 +107,7 @@ export const createQueryProcedures = () => { return { ...workspace, - type: workspace.type as "worktree" | "branch", + type: workspace.type as "worktree" | "branch" | "cloud", worktreePath: getWorkspacePath(workspace) ?? "", project: project ? { @@ -165,7 +165,7 @@ export const createQueryProcedures = () => { projectId: string; worktreeId: string | null; worktreePath: string; - type: "worktree" | "branch"; + type: "worktree" | "branch" | "cloud"; branch: string; name: string; tabOrder: number; @@ -206,13 +206,16 @@ export const createQueryProcedures = () => { let worktreePath = ""; if (workspace.type === "worktree" && workspace.worktreeId) { worktreePath = worktreePathMap.get(workspace.worktreeId) ?? ""; - } else if (workspace.type === "branch") { + } else if ( + workspace.type === "branch" || + workspace.type === "cloud" + ) { worktreePath = group.project.mainRepoPath; } group.workspaces.push({ ...workspace, - type: workspace.type as "worktree" | "branch", + type: workspace.type as "worktree" | "branch" | "cloud", worktreePath, isUnread: workspace.isUnread ?? false, }); diff --git a/apps/desktop/src/lib/trpc/routers/workspaces/utils/worktree.ts b/apps/desktop/src/lib/trpc/routers/workspaces/utils/worktree.ts index 0ecccdc326b..98628a3e024 100644 --- a/apps/desktop/src/lib/trpc/routers/workspaces/utils/worktree.ts +++ b/apps/desktop/src/lib/trpc/routers/workspaces/utils/worktree.ts @@ -17,10 +17,10 @@ export function getWorktreePath(worktreeId: string): string | undefined { /** * Gets the working directory path for a workspace. * For worktree workspaces: returns the worktree path - * For branch workspaces: returns the main repo path + * For branch/cloud workspaces: returns the main repo path */ export function getWorkspacePath(workspace: SelectWorkspace): string | null { - if (workspace.type === "branch") { + if (workspace.type === "branch" || workspace.type === "cloud") { const project = localDb .select() .from(projects) diff --git a/apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx b/apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx index 7112ce6500d..9f90f990ab1 100644 --- a/apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx +++ b/apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx @@ -28,7 +28,7 @@ import { } from "@superset/ui/select"; import { toast } from "@superset/ui/sonner"; import { useEffect, useMemo, useRef, useState } from "react"; -import { GoGitBranch } from "react-icons/go"; +import { GoCloud, GoGitBranch } from "react-icons/go"; import { HiCheck, HiChevronDown, HiChevronUpDown } from "react-icons/hi2"; import { electronTrpc } from "renderer/lib/electron-trpc"; import { formatRelativeTime } from "renderer/lib/formatRelativeTime"; @@ -83,6 +83,9 @@ export function NewWorkspaceModal() { { enabled: !!selectedProjectId }, ); const createWorkspace = useCreateWorkspace(); + const createCloudWorkspace = + electronTrpc.workspaces.createCloudWorkspace.useMutation(); + const utils = electronTrpc.useUtils(); // Filter branches based on search const filteredBranches = useMemo(() => { @@ -140,12 +143,17 @@ export function NewWorkspaceModal() { }, [isOpen, selectedProjectId, mode]); const handleKeyDown = (e: React.KeyboardEvent) => { + const isPending = + mode === "cloud" + ? createCloudWorkspace.isPending + : createWorkspace.isPending; + if ( e.key === "Enter" && !e.shiftKey && - mode === "new" && + (mode === "new" || mode === "cloud") && selectedProjectId && - !createWorkspace.isPending + !isPending ) { e.preventDefault(); handleCreateWorkspace(); @@ -169,6 +177,20 @@ export function NewWorkspaceModal() { const customBranchName = branchName.trim() || undefined; try { + if (mode === "cloud") { + await createCloudWorkspace.mutateAsync({ + projectId: selectedProjectId, + name: workspaceName, + }); + + // Invalidate workspace queries to refresh sidebar + await utils.workspaces.getAllGrouped.invalidate(); + + handleClose(); + toast.success("Cloud workspace created"); + return; + } + const result = await createWorkspace.mutateAsync({ projectId: selectedProjectId, name: workspaceName, @@ -431,11 +453,31 @@ export function NewWorkspaceModal() { /> )} {mode === "cloud" && ( -
Coming soon
+ +Cloud workspace - hosted remotely
+Cloud workspace
++ Hosted in the cloud for remote development +
+ > + ) : isBranchWorkspace ? ( <>Local workspace
diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/components/DeleteWorkspaceDialog/DeleteWorkspaceDialog.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/components/DeleteWorkspaceDialog/DeleteWorkspaceDialog.tsx
index 7398cb9933b..6d495dbd818 100644
--- a/apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/components/DeleteWorkspaceDialog/DeleteWorkspaceDialog.tsx
+++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/components/DeleteWorkspaceDialog/DeleteWorkspaceDialog.tsx
@@ -18,7 +18,7 @@ import {
interface DeleteWorkspaceDialogProps {
workspaceId: string;
workspaceName: string;
- workspaceType?: "worktree" | "branch";
+ workspaceType?: "worktree" | "branch" | "cloud";
open: boolean;
onOpenChange: (open: boolean) => void;
}
@@ -31,6 +31,7 @@ export function DeleteWorkspaceDialog({
onOpenChange,
}: DeleteWorkspaceDialogProps) {
const isBranch = workspaceType === "branch";
+ const isCloud = workspaceType === "cloud";
const deleteWorkspace = useDeleteWorkspace();
const closeWorkspace = useCloseWorkspace();
@@ -108,8 +109,8 @@ export function DeleteWorkspaceDialog({
const hasUnpushedCommits = canDeleteData?.hasUnpushedCommits ?? false;
const hasWarnings = hasChanges || hasUnpushedCommits;
- // For branch workspaces, use simplified dialog (only close option)
- if (isBranch) {
+ // For branch/cloud workspaces, use simplified dialog (only close option)
+ if (isBranch || isCloud) {
return (
Cloud workspace
+ Hosted in the cloud for remote development
+ Local workspace
@@ -181,11 +189,12 @@ export function WorkspaceRow({
// Determine the delete/close action label based on workspace type and state
const isOpenWorkspace = workspace.workspaceId !== null;
const isClosedWorktree = !isOpenWorkspace && workspace.worktreeId !== null;
- const actionLabel = isBranch
- ? "Close workspace"
- : isClosedWorktree
- ? "Delete worktree"
- : "Delete workspace";
+ const actionLabel =
+ isBranch || isCloud
+ ? "Close workspace"
+ : isClosedWorktree
+ ? "Delete worktree"
+ : "Delete workspace";
// Can delete open workspaces or closed worktrees
const canDelete = isOpenWorkspace || isClosedWorktree;
diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspacesListView/types.ts b/apps/desktop/src/renderer/screens/main/components/WorkspacesListView/types.ts
index 587000def29..8cef9352d69 100644
--- a/apps/desktop/src/renderer/screens/main/components/WorkspacesListView/types.ts
+++ b/apps/desktop/src/renderer/screens/main/components/WorkspacesListView/types.ts
@@ -8,7 +8,7 @@ export interface WorkspaceItem {
projectId: string;
projectName: string;
worktreePath: string;
- type: "worktree" | "branch";
+ type: "worktree" | "branch" | "cloud";
branch: string;
name: string;
lastOpenedAt: number;
diff --git a/packages/local-db/src/schema/zod.ts b/packages/local-db/src/schema/zod.ts
index 1aa69d75af2..2f5845aaded 100644
--- a/packages/local-db/src/schema/zod.ts
+++ b/packages/local-db/src/schema/zod.ts
@@ -63,8 +63,11 @@ export type TerminalPreset = z.infer