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" && ( -
-
- Cloud Workspaces +
+ setTitle(e.target.value)} + /> + +
+
+ + + + Cloud workspace powered by remote development +
-

Coming soon

+ +
)}
diff --git a/apps/desktop/src/renderer/screens/main/components/TopBar/index.tsx b/apps/desktop/src/renderer/screens/main/components/TopBar/index.tsx index 9e36080cd8c..080885ff62e 100644 --- a/apps/desktop/src/renderer/screens/main/components/TopBar/index.tsx +++ b/apps/desktop/src/renderer/screens/main/components/TopBar/index.tsx @@ -1,4 +1,6 @@ +import { Tooltip, TooltipContent, TooltipTrigger } from "@superset/ui/tooltip"; import { useParams } from "@tanstack/react-router"; +import { LuCloud } from "react-icons/lu"; import { electronTrpc } from "renderer/lib/electron-trpc"; import { OpenInMenuButton } from "./OpenInMenuButton"; import { OrganizationDropdown } from "./OrganizationDropdown"; @@ -13,6 +15,7 @@ export function TopBar() { ); // Default to Mac layout while loading to avoid overlap with traffic lights const isMac = platform === undefined || platform === "darwin"; + const isCloudWorkspace = workspace?.type === "cloud"; return (
@@ -21,7 +24,21 @@ export function TopBar() { style={{ paddingLeft: isMac ? "88px" : "16px", }} - /> + > + {isCloudWorkspace && ( + + +
+ + Cloud +
+
+ +

Cloud workspace - hosted remotely

+
+
+ )} +
diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/ProjectSection/ProjectSection.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/ProjectSection/ProjectSection.tsx index 3a28eac2a80..7da88620aa9 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/ProjectSection/ProjectSection.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/ProjectSection/ProjectSection.tsx @@ -15,7 +15,7 @@ interface Workspace { id: string; projectId: string; worktreePath: string; - type: "worktree" | "branch"; + type: "worktree" | "branch" | "cloud"; branch: string; name: string; tabOrder: number; diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx index 5b361dc4a87..10dc8b47564 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx @@ -63,7 +63,7 @@ interface WorkspaceListItemProps { worktreePath: string; name: string; branch: string; - type: "worktree" | "branch"; + type: "worktree" | "branch" | "cloud"; isUnread?: boolean; index: number; shortcutIndex?: number; @@ -84,6 +84,7 @@ export function WorkspaceListItem({ isCollapsed = false, }: WorkspaceListItemProps) { const isBranchWorkspace = type === "branch"; + const isCloudWorkspace = type === "cloud"; const navigate = useNavigate(); const matchRoute = useMatchRoute(); const reorderWorkspaces = useReorderWorkspaces(); @@ -308,6 +309,21 @@ export function WorkspaceListItem({ ); } + // Cloud workspaces get a simple tooltip + if (isCloudWorkspace) { + return ( + + {collapsedButton} + + {name || branch} + + Cloud workspace + + + + ); + } + // Worktree workspaces get the full hover card with context menu return ( <> @@ -414,7 +430,14 @@ export function WorkspaceListItem({
- {isBranchWorkspace ? ( + {isCloudWorkspace ? ( + <> +

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 ( @@ -120,8 +121,9 @@ export function DeleteWorkspaceDialog({

- This will close the workspace and kill any active terminals. - Your branch and commits will remain in the repository. + {isCloud + ? "This will disconnect from the cloud workspace and kill any active terminals." + : "This will close the workspace and kill any active terminals. Your branch and commits will remain in the repository."}
diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspacesListView/WorkspaceRow/WorkspaceRow.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspacesListView/WorkspaceRow/WorkspaceRow.tsx index 2f529e3978a..b42e63c093c 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspacesListView/WorkspaceRow/WorkspaceRow.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspacesListView/WorkspaceRow/WorkspaceRow.tsx @@ -37,6 +37,7 @@ export function WorkspaceRow({ isOpening, }: WorkspaceRowProps) { const isBranch = workspace.type === "branch"; + const isCloud = workspace.type === "cloud"; const [hasHovered, setHasHovered] = useState(false); const { showDeleteDialog, setShowDeleteDialog, handleDeleteClick } = useWorkspaceDeleteHandler(); @@ -104,7 +105,14 @@ export function WorkspaceRow({
- {isBranch ? ( + {isCloud ? ( + <> +

Cloud workspace

+

+ Hosted in the cloud for remote development +

+ + ) : isBranch ? ( <>

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; /** * Workspace type + * - worktree: Git worktree-based workspace (isolated copy) + * - branch: Branch-based workspace (main repo) + * - cloud: Cloud-hosted workspace */ -export const workspaceTypeSchema = z.enum(["worktree", "branch"]); +export const workspaceTypeSchema = z.enum(["worktree", "branch", "cloud"]); export type WorkspaceType = z.infer;