open-swe/apps/web/src/components/task-list.tsx
Brace Sproul 8afe1e6803
feat: Update chat UI to be Open SWE specific (#76) (#91)
* init repo-selector

* add branch selector UI, extend GH hook w branch info

* add   reconnectOnMount: true resumeStream, remove repo description from selector, fix styling

* styling repo + branch

* udpate getBranch calls to include targetRepo arg

* format

* add search to repo + branch selectors

* add settings icon link to /github for dev convenience

* add default branch selection

* format

* minor cleanup

* init task list UI demo

* individual task component

* tasks real data

* task visual improvement

* persisting tasks, navigate to thread onClick

* task UI

* TaskSidebar, Navigate to tasks

* org tasks by thread

* group by thread

* improve sidebar, task-list, rm github modal on refresh

* collapse sidebar works when viewing a thread

* remove micro-tasks expansion from threads component, change taskId to taskIndex for persistence + simplicity

* init config sidebar ui

* open and close config sidebar

* add ref for getAllTasks + add graph_id metadata

* format

* create threadItem component

* format

* add threadUtils

* centralize + refactor types

* format

* improve thread status, realtime updates

* fix scroll issue

* remove temperature from config-sidebar

* Change model via sidebar

* fix flashing on updates

* init plan UI

* centralize types

* self CR: refactoring, cleanup, remove comments, add todos

* CR: clean comments + logs, fix repo selector bug

* fix: Update example env file in web (#77)

* disable auto scroll on pageload

* reposelector: use default branch not main master

* remove archived tab temp, default branch listed first in branchSelector dropdown

* auto select first repo

* improve status indicator

* refactor status indicator

* simplify status implementation to use Langgraph

* util moved from provider to thread-utils

* linting, improve task completion logic

* feat: Support followup requests (#60)

* feat: Support followup requests

* cr

* cr

* fix

* account for pr already exists

* remove task provider

* fix: Better prompting and context provided for codebase structure awareness (#85)

* fix: Better prompting and context provided for codebase structure awareness

* cr

* linting + skeleton loader

* fix: branch selector, add github api pagination

* small branch update

* update task completion status realtime

* threadItem stream remove flashing/polling

* feat: Create a shared package (#89)

* feat: Create a shared package

* formatting

* fix: drop passing target repo to getBranchName

* drop docs

* use shared package for config fields in config sidebar

* fix: styling and structure for repo/branch selectors

* fix: use shared types/objects for config fields

* default key for configs

* fix: improved styling for threads

* fix renering num tasks

* disable repo branch selector when chat started

* cr

* cr

* bump deps

* fix: rendering plan in interrupt

* cr

* cr

---------

Co-authored-by: Dylan Boudro <121908331+starmorph@users.noreply.github.com>
2025-06-09 00:29:40 +00:00

102 lines
3.6 KiB
TypeScript

"use client";
import { Archive, ChevronLeft, ChevronRight } from "lucide-react";
import { Button } from "@/components/ui/button";
import { useThreads, ThreadWithTasks } from "@/providers/Thread";
import { useQueryState, parseAsString } from "nuqs";
import { useState } from "react";
import { ThreadItem } from "./thread-item";
const THREADS_PER_PAGE = 5;
export default function TaskList() {
const [taskId, setTaskId] = useQueryState("taskId", parseAsString);
const [_threadId, setThreadId] = useQueryState("threadId", parseAsString);
const [currentPage, setCurrentPage] = useState(0);
const { threads, threadsLoading } = useThreads();
const isDashboardMode = !taskId;
const handleThreadClick = (thread: ThreadWithTasks) => {
setThreadId(thread.thread_id);
setTaskId(null);
};
if (!isDashboardMode) {
return null;
}
// Threads are already sorted by creation date in ThreadProvider
const sortedThreads = threads;
const totalThreads = sortedThreads.length;
const totalPages = Math.ceil(totalThreads / THREADS_PER_PAGE);
const startIndex = currentPage * THREADS_PER_PAGE;
const endIndex = startIndex + THREADS_PER_PAGE;
const paginatedThreads = sortedThreads.slice(startIndex, endIndex);
return (
<div className="flex h-full w-full max-w-3xl flex-col gap-2">
<p className="text-sm text-gray-500">Threads ({totalThreads})</p>
<div>
{threadsLoading ? (
<div className="flex h-full items-center justify-center">
<div className="text-center text-gray-500">
<Archive className="mx-auto mb-2 h-6 w-6 animate-pulse opacity-50" />
<p className="text-sm">Loading threads...</p>
</div>
</div>
) : paginatedThreads.length > 0 ? (
<div className="space-y-2">
{paginatedThreads.map((thread) => (
<ThreadItem
key={thread.thread_id}
thread={thread}
onClick={handleThreadClick}
variant="dashboard"
/>
))}
{/* Pagination Controls */}
{totalPages > 1 && (
<div className="flex items-center justify-between border-t pt-4">
<div className="text-sm text-gray-500">
Showing {startIndex + 1}-{Math.min(endIndex, totalThreads)} of{" "}
{totalThreads} threads
</div>
<div className="flex items-center space-x-2">
<Button
variant="outline"
size="sm"
onClick={() => setCurrentPage(Math.max(0, currentPage - 1))}
disabled={currentPage === 0}
>
<ChevronLeft className="h-4 w-4" />
Previous
</Button>
<Button
variant="outline"
size="sm"
onClick={() =>
setCurrentPage(Math.min(totalPages - 1, currentPage + 1))
}
disabled={currentPage === totalPages - 1}
>
Next
<ChevronRight className="h-4 w-4" />
</Button>
</div>
</div>
)}
</div>
) : (
<div className="flex h-full items-center justify-center">
<div className="text-center text-gray-500">
<Archive className="mx-auto mb-2 h-6 w-6 opacity-50" />
<p className="text-sm">No threads found</p>
</div>
</div>
)}
</div>
</div>
);
}