"use client"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { Archive, ListChecks } from "lucide-react"; import { useRouter } from "next/navigation"; import { TerminalInput } from "./terminal-input"; import { useFileUpload } from "@/hooks/useFileUpload"; import { cn } from "@/lib/utils"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "../ui/tooltip"; import { ContentBlocksPreview } from "../thread/ContentBlocksPreview"; import { ThemeToggle } from "../theme-toggle"; import { ThreadCard, ThreadCardLoading } from "./thread-card"; import { GitHubInstallationBanner } from "../github/installation-banner"; import { ApiKeyBanner } from "../api-key-banner"; import { IssuesRequiredBanner } from "../github/forked-repository-banner"; import { QuickActions } from "./quick-actions"; import { DraftsSection } from "./drafts-section"; import { MANAGER_GRAPH_ID } from "@open-swe/shared/constants"; import { TooltipIconButton } from "../ui/tooltip-icon-button"; import { UserPopover } from "../user-popover"; 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, BookOpen } from "lucide-react"; import NextLink from "next/link"; import { OpenSWELogoSVG } from "../icons/openswe"; function OpenSettingsButton() { return ( Open Settings ); } const DOCUMENTATION_URL = "https://docs.langchain.com/labs/swe"; function OpenDocumentationButton() { return ( Open Documentation ); } 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, 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 */}
ready
{/* Main Content */}
{/* Terminal Chat Input */}
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 */}
); }