Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

141 changes: 82 additions & 59 deletions apps/desktop/src/renderer/screens/main/components/StartView/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { cn } from "@superset/ui/utils";
import { useNavigate } from "@tanstack/react-router";
import { useCallback, useEffect, useState } from "react";
import { LuFolderOpen, LuX } from "react-icons/lu";
import { LuFolderGit, LuFolderOpen, LuX } from "react-icons/lu";
import { useOpenFromPath, useOpenNew } from "renderer/react-query/projects";
import { SupersetLogo } from "renderer/routes/sign-in/components/SupersetLogo";
import { CloneRepoDialog } from "./CloneRepoDialog";
import { InitGitDialog } from "./InitGitDialog";
import { StartTopBar } from "./StartTopBar";

export function StartView() {
const navigate = useNavigate();
Expand All @@ -16,18 +16,17 @@ export function StartView() {
isOpen: boolean;
selectedPath: string;
}>({ isOpen: false, selectedPath: "" });
const [isCloneDialogOpen, setIsCloneDialogOpen] = useState(false);
const [isDragOver, setIsDragOver] = useState(false);

const isLoading = openNew.isPending || openFromPath.isPending;

// Auto-dismiss error after 5 seconds
useEffect(() => {
if (!error) return;
const timer = setTimeout(() => setError(null), 5000);
return () => clearTimeout(timer);
}, [error]);

// Clear drag state when drag ends anywhere
useEffect(() => {
const handleWindowDragEnd = () => setIsDragOver(false);
const handleWindowDrop = () => setIsDragOver(false);
Expand All @@ -42,6 +41,7 @@ export function StartView() {
}, []);

const handleOpenProject = () => {
if (isDragOver) return;
setError(null);
openNew.mutate(undefined, {
onSuccess: (result) => {
Expand All @@ -62,7 +62,6 @@ export function StartView() {
return;
}

// Navigate to project view
if ("project" in result && result.project) {
navigate({
to: "/project/$projectId",
Expand Down Expand Up @@ -151,7 +150,6 @@ export function StartView() {
return;
}

// Navigate to project view
if ("project" in result && result.project) {
navigate({
to: "/project/$projectId",
Expand All @@ -168,83 +166,102 @@ export function StartView() {
[openFromPath, isLoading, navigate],
);

const handleCloneError = (errorMessage: string) => {
setError(errorMessage);
};
Comment on lines +169 to +171

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Log clone errors with context before surfacing to UI.
Please add a prefixed log so we don’t lose debugging context.

✅ Suggested change
 const handleCloneError = (errorMessage: string) => {
+	console.error(`[start-view/clone] ${errorMessage}`);
 	setError(errorMessage);
 };

As per coding guidelines, never swallow errors silently; at minimum log them with context, and use prefixed console logging with pattern [domain/operation] message for all logging.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleCloneError = (errorMessage: string) => {
setError(errorMessage);
};
const handleCloneError = (errorMessage: string) => {
console.error(`[start-view/clone] ${errorMessage}`);
setError(errorMessage);
};
🤖 Prompt for AI Agents
In `@apps/desktop/src/renderer/screens/main/components/StartView/index.tsx` around
lines 169 - 171, handleCloneError currently only calls setError and swallows
context; update the StartView.handleCloneError implementation to first log the
error with a prefixed console error (use the pattern "[clone/repo] ...")
including the errorMessage (and the raw error object if you change the
signature), then call setError(errorMessage); reference the function name
handleCloneError and state setter setError when making the change.


return (
<div className="flex flex-col h-full w-full relative overflow-hidden bg-background">
<StartTopBar />
{/* biome-ignore lint/a11y/noStaticElementInteractions: Drop zone for external files */}
<div
className="relative flex flex-1 items-center justify-center px-8 py-12"
className="relative flex flex-1 items-center justify-center"
onDragOver={handleDragOver}
onDragLeave={handleDragLeave}
onDrop={handleDrop}
>
<div className="w-full max-w-md flex flex-col items-center gap-12">
<div className="flex flex-col items-center gap-3 text-center">
<span className="text-sm text-muted-foreground font-mono uppercase tracking-widest">
Welcome to
</span>
<SupersetLogo className="h-12 w-auto" />
</div>
<div className="flex flex-col items-center w-full max-w-xs px-4">
<SupersetLogo
className={cn(
"h-8 w-auto mb-6 transition-opacity duration-200",
isDragOver && "opacity-0",
)}
/>

<div className="w-full items-center flex flex-col gap-3">
<h4 className="scroll-m-20 text-xl font-semibold tracking-tight">
Open a Project
</h4>
<div className="w-full flex flex-col gap-2">
<div>
<button
type="button"
onClick={handleOpenProject}
disabled={isLoading}
className={cn(
"w-full rounded border border-dashed transition-colors",
"focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
"disabled:opacity-50 disabled:pointer-events-none",
isDragOver
? "border-foreground/40 bg-accent/50 py-16"
: "border-border bg-card px-4 py-7 hover:bg-accent",
)}
>
{isDragOver ? (
<div className="flex flex-col items-center gap-1">
<LuFolderGit className="w-5 h-5 text-foreground" />
<span className="text-sm text-foreground">
Drop git project
</span>
</div>
) : (
<div className="flex-1 text-left">
<LuFolderOpen className="w-4 h-4 text-muted-foreground" />
<div className="text-sm pt-1 text-foreground">
Open Project
</div>
<div className="text-xs pt-0.5 text-muted-foreground">
Drag git folder or click to browse
</div>
</div>
)}
</button>
<p
className={cn(
"mt-1.5 text-xs text-muted-foreground/60 text-center transition-opacity",
isDragOver && "opacity-0",
)}
>
Any folder with a .git directory
</p>
</div>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

<button
type="button"
onClick={handleOpenProject}
onClick={() => setIsCloneDialogOpen(true)}
disabled={isLoading || isDragOver}
className={cn(
"w-full rounded-xl bg-card border border-dashed",
"flex flex-col items-center justify-center gap-5 px-8 py-16",
"transition-colors duration-200",
"focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
isDragOver ? "border-primary bg-primary/5" : "border-border",
"w-full rounded border border-border bg-transparent px-3 py-2",
"transition-colors hover:bg-accent",
"focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
"disabled:opacity-50 disabled:pointer-events-none",
isDragOver && "opacity-0",
)}
>
<div
className={cn(
"rounded-2xl p-5",
isDragOver
? "bg-primary/10"
: "bg-gradient-to-br from-muted to-muted/50",
)}
>
<LuFolderOpen
className={cn(
"h-12 w-12",
isDragOver ? "text-primary" : "text-foreground",
)}
/>
</div>
<div className="text-center">
<p
className={cn(
"text-sm font-medium",
isDragOver ? "text-primary" : "text-foreground",
)}
>
{isDragOver
? "Drop to open"
: "Drag and drop a git folder to open"}
</p>
<p className="text-xs text-muted-foreground mt-1">
Any folder with a .git directory
</p>
<div className="flex items-center gap-3">
<LuFolderGit className="w-4 h-4 text-muted-foreground" />
<span className="text-sm text-muted-foreground">
Clone Repository
</span>
</div>
</button>
</div>

{error && (
<div className="w-full flex items-start gap-2 rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2 text-destructive">
<span className="flex-1 text-xs">{error}</span>
{error && !isDragOver && (
<div className="mt-4 w-full flex items-start gap-2 rounded-md px-3 py-2 bg-destructive/10 border border-destructive/20">
<span className="flex-1 text-xs text-destructive">{error}</span>
<button
type="button"
onClick={() => setError(null)}
className="shrink-0 rounded p-0.5 hover:bg-destructive/20"
className="shrink-0 rounded p-0.5 text-destructive/70 hover:text-destructive transition-colors"
aria-label="Dismiss error"
>
<LuX className="h-3.5 w-3.5" />
<LuX className="h-3 w-3" />
</button>
</div>
)}
Expand All @@ -257,6 +274,12 @@ export function StartView() {
onClose={() => setInitGitDialog({ isOpen: false, selectedPath: "" })}
onError={setError}
/>

<CloneRepoDialog
isOpen={isCloneDialogOpen}
onClose={() => setIsCloneDialogOpen(false)}
onError={handleCloneError}
/>
</div>
);
}
Loading