"use client"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { FilePlus2, Archive, Zap } from "lucide-react"; import { useRouter } from "next/navigation"; import { ThreadMetadata } 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"; import { ThemeToggle } from "../theme-toggle"; import { ThreadCard, ThreadCardLoading } from "./thread-card"; import { GitHubInstallationBanner } from "../github/installation-banner"; import { QuickActions } from "./quick-actions"; import { DraftsSection } from "./drafts-section"; import { GitHubLogoutButton } from "../github/github-oauth-button"; import { MANAGER_GRAPH_ID } from "@open-swe/shared/constants"; import { TooltipIconButton } from "../ui/tooltip-icon-button"; import { InstallationSelector } from "../github/installation-selector"; import { useThreadsStatus } from "@/hooks/useThreadsStatus"; import { Thread } from "@langchain/langgraph-sdk"; import { ManagerGraphState } from "@open-swe/shared/open-swe/manager/types"; import { useState, useMemo } from "react"; import { threadsToMetadata } from "@/lib/thread-utils"; import { Settings } from "lucide-react"; import NextLink from "next/link"; function OpenSettingsButton() { return ( Open Settings ); } interface DefaultViewProps { threads: Thread[]; threadsLoading: boolean; } export function DefaultView({ threads, threadsLoading }: DefaultViewProps) { const router = useRouter(); const [quickActionPrompt, setQuickActionPrompt] = useState(""); const apiUrl: string | undefined = process.env.NEXT_PUBLIC_API_URL ?? ""; const [draftToLoad, setDraftToLoad] = useState(""); const assistantId: string | undefined = MANAGER_GRAPH_ID; const { contentBlocks, setContentBlocks, handleFileUpload, dropRef, removeBlock, dragOver, handlePaste, } = useFileUpload(); const [autoAccept, setAutoAccept] = useState(false); const threadsMetadata = useMemo(() => threadsToMetadata(threads), [threads]); const displayThreads = threadsMetadata.slice(0, 4); const displayThreadIds = displayThreads.map((thread) => thread.id); const { statusMap, taskPlanMap, isLoading: statusLoading, } = useThreadsStatus(displayThreadIds, threads); const handleLoadDraft = (content: string) => { setDraftToLoad(content); }; if (!apiUrl) { return
Missing API URL environment variable
; } return (
{/* Header */}
Open SWE
ready
{/* Main Content */}
{/* Terminal Chat Input */}
Attach files setAutoAccept((prev) => !prev)} side="bottom" >
{/* Recent & Running Threads */}

Recent & Running Threads

{threadsLoading || threads.length ? (
{threadsLoading && threads.length === 0 && ( <> )} {displayThreads.map((thread) => ( ))}
) : (
No threads found
)}
{/* TODO: Better multiple draft handling. Not actually used right now */}
); }