2025-06-18 11:03:39 -07:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
import {
|
|
|
|
|
Card,
|
|
|
|
|
CardContent,
|
|
|
|
|
CardDescription,
|
|
|
|
|
CardHeader,
|
|
|
|
|
CardTitle,
|
|
|
|
|
} from "@/components/ui/card";
|
|
|
|
|
import { Badge } from "@/components/ui/badge";
|
|
|
|
|
import {
|
|
|
|
|
CheckCircle,
|
|
|
|
|
XCircle,
|
|
|
|
|
Loader2,
|
|
|
|
|
GitBranch,
|
|
|
|
|
GitPullRequest,
|
|
|
|
|
Bug,
|
|
|
|
|
FilePlus2,
|
|
|
|
|
} from "lucide-react";
|
|
|
|
|
import { useRouter } from "next/navigation";
|
|
|
|
|
import { ThreadDisplayInfo } from "./types";
|
|
|
|
|
import { TerminalInput } from "./terminal-input";
|
|
|
|
|
import { useFileUpload } from "@/hooks/useFileUpload";
|
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
import {
|
|
|
|
|
Tooltip,
|
|
|
|
|
TooltipContent,
|
|
|
|
|
TooltipProvider,
|
|
|
|
|
TooltipTrigger,
|
|
|
|
|
} from "../ui/tooltip";
|
|
|
|
|
import { Label } from "../ui/label";
|
|
|
|
|
import { ContentBlocksPreview } from "../thread/ContentBlocksPreview";
|
2025-06-18 16:44:41 -07:00
|
|
|
import { TooltipIconButton } from "../ui/tooltip-icon-button";
|
|
|
|
|
import { ThemeToggle } from "../theme-toggle";
|
|
|
|
|
import { ThreadCard } from "./thread-card";
|
2025-06-18 11:03:39 -07:00
|
|
|
|
|
|
|
|
interface DefaultViewProps {
|
|
|
|
|
threads: ThreadDisplayInfo[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function DefaultView({ threads }: DefaultViewProps) {
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const apiUrl: string | undefined = process.env.NEXT_PUBLIC_API_URL ?? "";
|
|
|
|
|
const assistantId: string | undefined =
|
|
|
|
|
process.env.NEXT_PUBLIC_MANAGER_ASSISTANT_ID ?? "";
|
|
|
|
|
const {
|
|
|
|
|
contentBlocks,
|
|
|
|
|
setContentBlocks,
|
|
|
|
|
handleFileUpload,
|
|
|
|
|
dropRef,
|
|
|
|
|
removeBlock,
|
|
|
|
|
dragOver,
|
|
|
|
|
handlePaste,
|
|
|
|
|
} = useFileUpload();
|
|
|
|
|
|
|
|
|
|
if (!apiUrl || !assistantId) {
|
|
|
|
|
return <div>Missing API URL or Assistant ID</div>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex flex-1 flex-col">
|
|
|
|
|
{/* Header */}
|
2025-06-18 16:44:41 -07:00
|
|
|
<div className="border-border bg-card border-b px-4 py-2">
|
2025-06-18 11:03:39 -07:00
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
<div className="h-2 w-2 rounded-full bg-green-500"></div>
|
2025-06-18 16:44:41 -07:00
|
|
|
<span className="text-muted-foreground font-mono text-sm">
|
|
|
|
|
Open SWE
|
|
|
|
|
</span>
|
2025-06-18 11:03:39 -07:00
|
|
|
</div>
|
2025-06-18 16:44:41 -07:00
|
|
|
<div className="flex items-center gap-4">
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<span className="text-muted-foreground text-xs">ready</span>
|
|
|
|
|
<div className="bg-muted h-1 w-1 rounded-full"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<ThemeToggle />
|
2025-06-18 11:03:39 -07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Main Content */}
|
|
|
|
|
<div className="flex-1 overflow-auto">
|
|
|
|
|
<div className="mx-auto max-w-4xl space-y-6 p-4">
|
|
|
|
|
{/* Terminal Chat Input */}
|
|
|
|
|
<Card
|
|
|
|
|
className={cn(
|
2025-06-18 16:44:41 -07:00
|
|
|
"border-border bg-card py-0 dark:bg-gray-950",
|
2025-06-18 11:03:39 -07:00
|
|
|
dragOver
|
|
|
|
|
? "border-primary border-2 border-dotted"
|
|
|
|
|
: "border border-solid",
|
|
|
|
|
)}
|
|
|
|
|
ref={dropRef}
|
|
|
|
|
>
|
|
|
|
|
<CardContent className="p-4">
|
|
|
|
|
<ContentBlocksPreview
|
|
|
|
|
blocks={contentBlocks}
|
|
|
|
|
onRemove={removeBlock}
|
|
|
|
|
/>
|
|
|
|
|
<input
|
|
|
|
|
id="file-input"
|
|
|
|
|
type="file"
|
|
|
|
|
onChange={handleFileUpload}
|
|
|
|
|
multiple
|
|
|
|
|
accept="image/jpeg,image/png,image/gif,image/webp,application/pdf"
|
|
|
|
|
className="hidden"
|
|
|
|
|
/>
|
|
|
|
|
<div className="space-y-3">
|
|
|
|
|
<TerminalInput
|
|
|
|
|
placeholder="Describe your coding task or ask a question..."
|
|
|
|
|
apiUrl={apiUrl}
|
|
|
|
|
assistantId={assistantId}
|
|
|
|
|
contentBlocks={contentBlocks}
|
|
|
|
|
setContentBlocks={setContentBlocks}
|
|
|
|
|
onPaste={handlePaste}
|
|
|
|
|
/>
|
|
|
|
|
<div className="flex items-center gap-1">
|
|
|
|
|
<TooltipProvider>
|
|
|
|
|
<Tooltip>
|
|
|
|
|
<TooltipTrigger>
|
|
|
|
|
<Label
|
|
|
|
|
htmlFor="file-input"
|
2025-06-18 16:44:41 -07:00
|
|
|
className="text-muted-foreground hover:text-foreground flex cursor-pointer items-center justify-center rounded-full bg-inherit"
|
2025-06-18 11:03:39 -07:00
|
|
|
>
|
|
|
|
|
<FilePlus2 className="size-4" />
|
|
|
|
|
</Label>
|
|
|
|
|
</TooltipTrigger>
|
|
|
|
|
<TooltipContent>Attach files</TooltipContent>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</TooltipProvider>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
{/* Recent & Running Threads */}
|
|
|
|
|
<div>
|
|
|
|
|
<div className="mb-3 flex items-center justify-between">
|
2025-06-18 16:44:41 -07:00
|
|
|
<h2 className="text-foreground text-base font-semibold">
|
2025-06-18 11:03:39 -07:00
|
|
|
Recent & Running Threads
|
|
|
|
|
</h2>
|
|
|
|
|
<Button
|
|
|
|
|
variant="outline"
|
|
|
|
|
size="sm"
|
2025-06-18 16:44:41 -07:00
|
|
|
className="border-border text-muted-foreground hover:text-foreground h-7 text-xs"
|
2025-06-18 11:03:39 -07:00
|
|
|
onClick={() => router.push("/chat/threads")}
|
|
|
|
|
>
|
|
|
|
|
View All
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="grid gap-3 md:grid-cols-2">
|
|
|
|
|
{threads.slice(0, 4).map((thread) => (
|
2025-06-18 16:44:41 -07:00
|
|
|
<ThreadCard
|
2025-06-18 11:03:39 -07:00
|
|
|
key={thread.id}
|
2025-06-18 16:44:41 -07:00
|
|
|
thread={thread}
|
|
|
|
|
/>
|
2025-06-18 11:03:39 -07:00
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Quick Actions */}
|
|
|
|
|
<div>
|
2025-06-18 16:44:41 -07:00
|
|
|
<h2 className="text-foreground mb-3 text-base font-semibold">
|
2025-06-18 11:03:39 -07:00
|
|
|
Quick Actions
|
|
|
|
|
</h2>
|
|
|
|
|
<div className="grid gap-3 md:grid-cols-3">
|
2025-06-18 16:44:41 -07:00
|
|
|
<Card className="border-border bg-card hover:bg-muted cursor-pointer py-3 transition-shadow hover:shadow-lg dark:bg-gray-950">
|
2025-06-18 11:03:39 -07:00
|
|
|
<CardHeader className="px-3">
|
2025-06-18 16:44:41 -07:00
|
|
|
<CardTitle className="text-foreground text-sm">
|
2025-06-18 11:03:39 -07:00
|
|
|
Debug Code
|
|
|
|
|
</CardTitle>
|
2025-06-18 16:44:41 -07:00
|
|
|
<CardDescription className="text-muted-foreground text-xs">
|
2025-06-18 11:03:39 -07:00
|
|
|
Find and fix issues in your codebase
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
</Card>
|
2025-06-18 16:44:41 -07:00
|
|
|
<Card className="border-border bg-card hover:bg-muted cursor-pointer py-3 transition-shadow hover:shadow-lg dark:bg-gray-950">
|
2025-06-18 11:03:39 -07:00
|
|
|
<CardHeader className="px-3">
|
2025-06-18 16:44:41 -07:00
|
|
|
<CardTitle className="text-foreground text-sm">
|
2025-06-18 11:03:39 -07:00
|
|
|
Add Feature
|
|
|
|
|
</CardTitle>
|
2025-06-18 16:44:41 -07:00
|
|
|
<CardDescription className="text-muted-foreground text-xs">
|
2025-06-18 11:03:39 -07:00
|
|
|
Implement new functionality
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
</Card>
|
2025-06-18 16:44:41 -07:00
|
|
|
<Card className="border-border bg-card hover:bg-muted cursor-pointer py-3 transition-shadow hover:shadow-lg dark:bg-gray-950">
|
2025-06-18 11:03:39 -07:00
|
|
|
<CardHeader className="px-3">
|
2025-06-18 16:44:41 -07:00
|
|
|
<CardTitle className="text-foreground text-sm">
|
2025-06-18 11:03:39 -07:00
|
|
|
Refactor Code
|
|
|
|
|
</CardTitle>
|
2025-06-18 16:44:41 -07:00
|
|
|
<CardDescription className="text-muted-foreground text-xs">
|
2025-06-18 11:03:39 -07:00
|
|
|
Improve code structure and performance
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|