import { useRef, useState } from "react"; import { Button, ChatComposer, type ChatComposerHandle, ProjectPicker, serialize, type SessionSidebarRepo, } from "@ace/ui"; import { IconChevronDown, IconHash, IconPlus } from "@ace/ui/icons"; import type { Listing } from "@ace/host/protocol"; import type { AppProject } from "./projects"; const MODES = [{ id: "ace", name: "Ace", placeholder: "Start a new channel" }]; export function Dashboard( { project, repos, channels, local, connected, onProject, onOpen, onChannel, onCreate }: { project: AppProject; repos: SessionSidebarRepo[]; channels: Listing[]; local: boolean; connected: boolean; onProject: (id: string) => void; onOpen: () => void; onChannel: (channel: Listing) => void; onCreate: (text?: string, onCreated?: () => void) => Promise; }, ) { const composer = useRef(null); const [busy, setBusy] = useState(false); const active = channels.filter((channel) => channel.state !== "archived") .sort((a, b) => b.created - a.created); const hour = new Date().getHours(); const greeting = hour < 12 ? "Good morning" : hour < 18 ? "Good afternoon" : "Good evening"; async function start(text?: string) { if (busy) return; setBusy(true); try { await onCreate(text, () => { const input = composer.current; const doc = input?.get(); if (input && doc && serialize(doc) === text) input.clear(); }); } finally { setBusy(false); } } return (
onProject(repo.id)} onAddRepo={connected ? onOpen : undefined} trigger={
{local && (
void start(serialize(doc))} />
)}

{active.length ? "Pick back up" : "Channels"}

{local && ( )}
{active.length ? (
{active.map((channel) => ( ))}
) : (

Your channels in this project will appear here.

)}
); }