Compare commits
4 Commits
feat/ms23-
...
feat/ms23-
| Author | SHA1 | Date | |
|---|---|---|---|
| adef5bdbb2 | |||
| 2c36569f85 | |||
| 7c086db7e4 | |||
| 577e6141e0 |
@@ -1,15 +1,259 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo, useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import type { AgentSession } from "@mosaic/shared";
|
||||
import { ChevronRight, Loader2, X } from "lucide-react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import type { BadgeVariant } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Collapsible } from "@/components/ui/collapsible";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { apiGet, apiPost } from "@/lib/api/client";
|
||||
|
||||
const SESSIONS_QUERY_KEY = ["mission-control", "sessions"] as const;
|
||||
const SESSIONS_POLL_INTERVAL_MS = 5_000;
|
||||
|
||||
type MissionControlSessionStatus = AgentSession["status"] | "killed";
|
||||
|
||||
interface MissionControlSession extends Omit<AgentSession, "status" | "createdAt" | "updatedAt"> {
|
||||
status: MissionControlSessionStatus;
|
||||
createdAt: string | Date;
|
||||
updatedAt: string | Date;
|
||||
}
|
||||
|
||||
interface SessionsPayload {
|
||||
sessions: MissionControlSession[];
|
||||
}
|
||||
|
||||
interface ProviderSessionGroup {
|
||||
providerId: string;
|
||||
providerType: string;
|
||||
sessions: MissionControlSession[];
|
||||
}
|
||||
|
||||
export interface GlobalAgentRosterProps {
|
||||
onSelectSession?: (sessionId: string) => void;
|
||||
selectedSessionId?: string | undefined;
|
||||
}
|
||||
|
||||
function getStatusVariant(status: MissionControlSessionStatus): BadgeVariant {
|
||||
switch (status) {
|
||||
case "active":
|
||||
return "status-success";
|
||||
case "paused":
|
||||
return "status-warning";
|
||||
case "killed":
|
||||
return "status-error";
|
||||
default:
|
||||
return "status-neutral";
|
||||
}
|
||||
}
|
||||
|
||||
function truncateSessionId(sessionId: string): string {
|
||||
return sessionId.slice(0, 8);
|
||||
}
|
||||
|
||||
function resolveProviderName(providerId: string, providerType: string): string {
|
||||
return providerId === providerType ? providerId : `${providerId} (${providerType})`;
|
||||
}
|
||||
|
||||
function groupByProvider(sessions: MissionControlSession[]): ProviderSessionGroup[] {
|
||||
const grouped = new Map<string, ProviderSessionGroup>();
|
||||
|
||||
for (const session of sessions) {
|
||||
const existing = grouped.get(session.providerId);
|
||||
if (existing) {
|
||||
existing.sessions.push(session);
|
||||
continue;
|
||||
}
|
||||
|
||||
grouped.set(session.providerId, {
|
||||
providerId: session.providerId,
|
||||
providerType: session.providerType,
|
||||
sessions: [session],
|
||||
});
|
||||
}
|
||||
|
||||
return Array.from(grouped.values()).sort((a, b) => a.providerId.localeCompare(b.providerId));
|
||||
}
|
||||
|
||||
async function fetchSessions(): Promise<MissionControlSession[]> {
|
||||
const payload = await apiGet<MissionControlSession[] | SessionsPayload>(
|
||||
"/api/mission-control/sessions"
|
||||
);
|
||||
return Array.isArray(payload) ? payload : payload.sessions;
|
||||
}
|
||||
|
||||
export function GlobalAgentRoster({
|
||||
onSelectSession,
|
||||
selectedSessionId,
|
||||
}: GlobalAgentRosterProps): React.JSX.Element {
|
||||
const queryClient = useQueryClient();
|
||||
const [openProviders, setOpenProviders] = useState<Record<string, boolean>>({});
|
||||
|
||||
const sessionsQuery = useQuery<MissionControlSession[]>({
|
||||
queryKey: SESSIONS_QUERY_KEY,
|
||||
queryFn: fetchSessions,
|
||||
refetchInterval: SESSIONS_POLL_INTERVAL_MS,
|
||||
});
|
||||
|
||||
const killMutation = useMutation({
|
||||
mutationFn: async (sessionId: string): Promise<string> => {
|
||||
await apiPost<{ message: string }>(`/api/mission-control/sessions/${sessionId}/kill`, {
|
||||
force: false,
|
||||
});
|
||||
return sessionId;
|
||||
},
|
||||
onSuccess: (): void => {
|
||||
void queryClient.invalidateQueries({ queryKey: SESSIONS_QUERY_KEY });
|
||||
},
|
||||
});
|
||||
|
||||
const groupedSessions = useMemo(
|
||||
() => groupByProvider(sessionsQuery.data ?? []),
|
||||
[sessionsQuery.data]
|
||||
);
|
||||
|
||||
const pendingKillSessionId = killMutation.isPending ? killMutation.variables : undefined;
|
||||
|
||||
const toggleProvider = (providerId: string): void => {
|
||||
setOpenProviders((prev) => ({
|
||||
...prev,
|
||||
[providerId]: !(prev[providerId] ?? true),
|
||||
}));
|
||||
};
|
||||
|
||||
const isProviderOpen = (providerId: string): boolean => openProviders[providerId] ?? true;
|
||||
|
||||
export function GlobalAgentRoster(): React.JSX.Element {
|
||||
return (
|
||||
<Card className="flex h-full min-h-0 flex-col">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">Agent Roster</CardTitle>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="flex items-center justify-between text-base">
|
||||
<span>Agent Roster</span>
|
||||
{sessionsQuery.isFetching && !sessionsQuery.isLoading ? (
|
||||
<Loader2 className="h-4 w-4 animate-spin text-muted-foreground" aria-hidden="true" />
|
||||
) : null}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="flex flex-1 items-center justify-center text-sm text-muted-foreground">
|
||||
No active agents
|
||||
<CardContent className="min-h-0 flex-1 px-3 pb-3">
|
||||
{sessionsQuery.isLoading ? (
|
||||
<ScrollArea className="h-full">
|
||||
<div className="space-y-2 pr-1">
|
||||
{Array.from({ length: 6 }).map((_, index) => (
|
||||
<Skeleton key={`roster-skeleton-${String(index)}`} className="h-10 w-full" />
|
||||
))}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
) : sessionsQuery.error ? (
|
||||
<div className="flex h-full items-center justify-center text-center text-sm text-red-500">
|
||||
Failed to load agents: {sessionsQuery.error.message}
|
||||
</div>
|
||||
) : groupedSessions.length === 0 ? (
|
||||
<div className="flex h-full items-center justify-center text-sm text-muted-foreground">
|
||||
No active agents
|
||||
</div>
|
||||
) : (
|
||||
<ScrollArea className="h-full">
|
||||
<div className="space-y-3 pr-1">
|
||||
{groupedSessions.map((group) => {
|
||||
const providerOpen = isProviderOpen(group.providerId);
|
||||
|
||||
return (
|
||||
<Collapsible key={group.providerId} open={providerOpen} className="space-y-1">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
toggleProvider(group.providerId);
|
||||
}}
|
||||
className="flex w-full items-center gap-2 rounded-md px-1 py-1 text-left text-sm hover:bg-muted/40"
|
||||
aria-expanded={providerOpen}
|
||||
>
|
||||
<ChevronRight
|
||||
className={`h-4 w-4 text-muted-foreground transition-transform ${providerOpen ? "rotate-90" : ""}`}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span className="font-medium">
|
||||
{resolveProviderName(group.providerId, group.providerType)}
|
||||
</span>
|
||||
<span className="ml-auto text-xs text-muted-foreground">
|
||||
{group.sessions.length}
|
||||
</span>
|
||||
</button>
|
||||
{providerOpen ? (
|
||||
<div className="space-y-1 pl-2">
|
||||
{group.sessions.map((session) => {
|
||||
const isSelected = selectedSessionId === session.id;
|
||||
const isKilling = pendingKillSessionId === session.id;
|
||||
|
||||
return (
|
||||
<div
|
||||
key={session.id}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onClick={() => {
|
||||
onSelectSession?.(session.id);
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === "Enter" || event.key === " ") {
|
||||
event.preventDefault();
|
||||
onSelectSession?.(session.id);
|
||||
}
|
||||
}}
|
||||
className="flex items-center justify-between gap-2 rounded-md border border-transparent px-2 py-1.5 transition-colors hover:bg-muted/40"
|
||||
style={
|
||||
isSelected
|
||||
? {
|
||||
borderColor: "rgba(47, 128, 255, 0.35)",
|
||||
backgroundColor: "rgba(47, 128, 255, 0.08)",
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<span className="font-mono text-xs" title={session.id}>
|
||||
{truncateSessionId(session.id)}
|
||||
</span>
|
||||
<Badge
|
||||
variant={getStatusVariant(session.status)}
|
||||
className="capitalize"
|
||||
>
|
||||
{session.status}
|
||||
</Badge>
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-7 min-h-7 w-7 min-w-7 p-0"
|
||||
disabled={isKilling}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
killMutation.mutate(session.id);
|
||||
}}
|
||||
aria-label={`Kill session ${truncateSessionId(session.id)}`}
|
||||
>
|
||||
{isKilling ? (
|
||||
<Loader2
|
||||
className="h-3.5 w-3.5 animate-spin"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
) : (
|
||||
<X className="h-3.5 w-3.5" aria-hidden="true" />
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : null}
|
||||
</Collapsible>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { GlobalAgentRoster } from "@/components/mission-control/GlobalAgentRoster";
|
||||
import { MissionControlPanel } from "@/components/mission-control/MissionControlPanel";
|
||||
import { useSessions } from "@/hooks/useMissionControl";
|
||||
@@ -8,14 +9,20 @@ const DEFAULT_PANEL_SLOTS = ["panel-1", "panel-2", "panel-3", "panel-4"] as cons
|
||||
|
||||
export function MissionControlLayout(): React.JSX.Element {
|
||||
const { sessions } = useSessions();
|
||||
const [selectedSessionId, setSelectedSessionId] = useState<string>();
|
||||
|
||||
const panelSessionIds = [sessions[0]?.id, undefined, undefined, undefined] as const;
|
||||
// First panel: selected session (from roster click) or first available session
|
||||
const firstPanelSessionId = selectedSessionId ?? sessions[0]?.id;
|
||||
const panelSessionIds = [firstPanelSessionId, undefined, undefined, undefined] as const;
|
||||
|
||||
return (
|
||||
<section className="h-full min-h-0 overflow-hidden" aria-label="Mission Control">
|
||||
<div className="grid h-full min-h-0 gap-4 xl:grid-cols-[280px_minmax(0,1fr)]">
|
||||
<aside className="h-full min-h-0">
|
||||
<GlobalAgentRoster />
|
||||
<GlobalAgentRoster
|
||||
onSelectSession={setSelectedSessionId}
|
||||
selectedSessionId={selectedSessionId}
|
||||
/>
|
||||
</aside>
|
||||
<main className="h-full min-h-0 overflow-hidden">
|
||||
<MissionControlPanel panels={DEFAULT_PANEL_SLOTS} panelSessionIds={panelSessionIds} />
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { formatDistanceToNow } from "date-fns";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import type { BadgeVariant } from "@/components/ui/badge";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { PanelControls } from "@/components/mission-control/PanelControls";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import {
|
||||
useSessionStream,
|
||||
useSessions,
|
||||
type MissionControlConnectionStatus,
|
||||
type MissionControlMessageRole,
|
||||
} from "@/hooks/useMissionControl";
|
||||
@@ -46,12 +48,21 @@ function formatRelativeTimestamp(timestamp: string): string {
|
||||
|
||||
export function OrchestratorPanel({ sessionId }: OrchestratorPanelProps): React.JSX.Element {
|
||||
const { messages, status, error } = useSessionStream(sessionId ?? "");
|
||||
const { sessions } = useSessions();
|
||||
const bottomAnchorRef = useRef<HTMLDivElement | null>(null);
|
||||
const [optimisticStatus, setOptimisticStatus] = useState<string | null>(null);
|
||||
|
||||
const selectedSessionStatus = sessions.find((session) => session.id === sessionId)?.status;
|
||||
const controlsStatus = optimisticStatus ?? selectedSessionStatus ?? "unknown";
|
||||
|
||||
useEffect(() => {
|
||||
bottomAnchorRef.current?.scrollIntoView({ block: "end" });
|
||||
}, [messages.length]);
|
||||
|
||||
useEffect(() => {
|
||||
setOptimisticStatus(null);
|
||||
}, [sessionId, selectedSessionStatus]);
|
||||
|
||||
if (!sessionId) {
|
||||
return (
|
||||
<Card className="flex h-full min-h-[220px] flex-col">
|
||||
@@ -68,16 +79,23 @@ export function OrchestratorPanel({ sessionId }: OrchestratorPanelProps): React.
|
||||
return (
|
||||
<Card className="flex h-full min-h-[220px] flex-col">
|
||||
<CardHeader className="space-y-2">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between">
|
||||
<CardTitle className="text-base">Orchestrator Panel</CardTitle>
|
||||
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||
<span
|
||||
className={`h-2.5 w-2.5 rounded-full ${CONNECTION_DOT_CLASS[status]} ${
|
||||
status === "connecting" ? "animate-pulse" : ""
|
||||
}`}
|
||||
aria-hidden="true"
|
||||
<div className="flex flex-col items-start gap-2 sm:items-end">
|
||||
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||
<span
|
||||
className={`h-2.5 w-2.5 rounded-full ${CONNECTION_DOT_CLASS[status]} ${
|
||||
status === "connecting" ? "animate-pulse" : ""
|
||||
}`}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span>{CONNECTION_TEXT[status]}</span>
|
||||
</div>
|
||||
<PanelControls
|
||||
sessionId={sessionId}
|
||||
status={controlsStatus}
|
||||
onStatusChange={setOptimisticStatus}
|
||||
/>
|
||||
<span>{CONNECTION_TEXT[status]}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p className="truncate text-xs text-muted-foreground">Session: {sessionId}</p>
|
||||
|
||||
259
apps/web/src/components/mission-control/PanelControls.tsx
Normal file
259
apps/web/src/components/mission-control/PanelControls.tsx
Normal file
@@ -0,0 +1,259 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { apiPost } from "@/lib/api/client";
|
||||
|
||||
const SESSIONS_QUERY_KEY = ["mission-control", "sessions"] as const;
|
||||
|
||||
type PanelAction = "pause" | "resume" | "graceful-kill" | "force-kill";
|
||||
type KillConfirmationState = "graceful" | "force" | null;
|
||||
|
||||
interface PanelActionResult {
|
||||
nextStatus: string;
|
||||
}
|
||||
|
||||
export interface PanelControlsProps {
|
||||
sessionId: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
||||
status: "active" | "paused" | "killed" | string;
|
||||
onStatusChange?: (newStatus: string) => void;
|
||||
}
|
||||
|
||||
function getErrorMessage(error: unknown): string {
|
||||
if (error instanceof Error && error.message.trim().length > 0) {
|
||||
return error.message;
|
||||
}
|
||||
|
||||
return "Failed to update agent session.";
|
||||
}
|
||||
|
||||
export function PanelControls({
|
||||
sessionId,
|
||||
status,
|
||||
onStatusChange,
|
||||
}: PanelControlsProps): React.JSX.Element {
|
||||
const queryClient = useQueryClient();
|
||||
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
||||
const [confirmingKill, setConfirmingKill] = useState<KillConfirmationState>(null);
|
||||
|
||||
useEffect(() => {
|
||||
setErrorMessage(null);
|
||||
setConfirmingKill(null);
|
||||
}, [sessionId]);
|
||||
|
||||
const controlMutation = useMutation({
|
||||
mutationFn: async (action: PanelAction): Promise<PanelActionResult> => {
|
||||
switch (action) {
|
||||
case "pause":
|
||||
await apiPost<{ message: string }>(
|
||||
`/api/mission-control/sessions/${encodeURIComponent(sessionId)}/pause`
|
||||
);
|
||||
return { nextStatus: "paused" };
|
||||
case "resume":
|
||||
await apiPost<{ message: string }>(
|
||||
`/api/mission-control/sessions/${encodeURIComponent(sessionId)}/resume`
|
||||
);
|
||||
return { nextStatus: "active" };
|
||||
case "graceful-kill":
|
||||
await apiPost<{ message: string }>(
|
||||
`/api/mission-control/sessions/${encodeURIComponent(sessionId)}/kill`,
|
||||
{ force: false }
|
||||
);
|
||||
return { nextStatus: "killed" };
|
||||
case "force-kill":
|
||||
await apiPost<{ message: string }>(
|
||||
`/api/mission-control/sessions/${encodeURIComponent(sessionId)}/kill`,
|
||||
{ force: true }
|
||||
);
|
||||
return { nextStatus: "killed" };
|
||||
}
|
||||
},
|
||||
onSuccess: ({ nextStatus }): void => {
|
||||
setErrorMessage(null);
|
||||
setConfirmingKill(null);
|
||||
onStatusChange?.(nextStatus);
|
||||
void queryClient.invalidateQueries({ queryKey: SESSIONS_QUERY_KEY });
|
||||
},
|
||||
onError: (error: unknown): void => {
|
||||
setConfirmingKill(null);
|
||||
setErrorMessage(getErrorMessage(error));
|
||||
},
|
||||
});
|
||||
|
||||
const normalizedStatus = status.toLowerCase();
|
||||
const isKilled = normalizedStatus === "killed";
|
||||
const isBusy = controlMutation.isPending;
|
||||
const pendingAction = isBusy ? controlMutation.variables : undefined;
|
||||
|
||||
const submitAction = (action: PanelAction): void => {
|
||||
setErrorMessage(null);
|
||||
controlMutation.mutate(action);
|
||||
};
|
||||
|
||||
const pauseDisabled = isBusy || normalizedStatus === "paused" || isKilled;
|
||||
const resumeDisabled = isBusy || normalizedStatus === "active" || isKilled;
|
||||
const gracefulKillDisabled = isBusy || isKilled;
|
||||
const forceKillDisabled = isBusy || isKilled;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-end gap-2">
|
||||
<div className="flex flex-wrap items-center justify-end gap-1.5">
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => {
|
||||
submitAction("pause");
|
||||
}}
|
||||
disabled={pauseDisabled}
|
||||
aria-label="Pause session"
|
||||
>
|
||||
{pendingAction === "pause" ? (
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden="true" />
|
||||
) : (
|
||||
<span aria-hidden="true">⏸</span>
|
||||
)}
|
||||
<span>Pause</span>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => {
|
||||
submitAction("resume");
|
||||
}}
|
||||
disabled={resumeDisabled}
|
||||
aria-label="Resume session"
|
||||
>
|
||||
{pendingAction === "resume" ? (
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden="true" />
|
||||
) : (
|
||||
<span aria-hidden="true">▶</span>
|
||||
)}
|
||||
<span>Resume</span>
|
||||
</Button>
|
||||
|
||||
<div className="relative">
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => {
|
||||
setErrorMessage(null);
|
||||
setConfirmingKill((current) => (current === "graceful" ? null : "graceful"));
|
||||
}}
|
||||
disabled={gracefulKillDisabled}
|
||||
aria-label="Gracefully kill session"
|
||||
>
|
||||
{pendingAction === "graceful-kill" ? (
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden="true" />
|
||||
) : (
|
||||
<span aria-hidden="true">⏹</span>
|
||||
)}
|
||||
<span>Graceful Kill</span>
|
||||
</Button>
|
||||
{confirmingKill === "graceful" ? (
|
||||
<div className="absolute right-0 top-[calc(100%+0.375rem)] z-20 w-72 rounded-md border border-border bg-card p-2 shadow-lg">
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Gracefully stop this agent after it finishes the current step?
|
||||
</p>
|
||||
<div className="mt-2 flex justify-end gap-1.5">
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
setConfirmingKill(null);
|
||||
}}
|
||||
disabled={isBusy}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => {
|
||||
submitAction("graceful-kill");
|
||||
}}
|
||||
disabled={isBusy}
|
||||
>
|
||||
{pendingAction === "graceful-kill" ? (
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden="true" />
|
||||
) : null}
|
||||
<span>Confirm</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className="relative">
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="danger"
|
||||
onClick={() => {
|
||||
setErrorMessage(null);
|
||||
setConfirmingKill((current) => (current === "force" ? null : "force"));
|
||||
}}
|
||||
disabled={forceKillDisabled}
|
||||
aria-label="Force kill session"
|
||||
>
|
||||
{pendingAction === "force-kill" ? (
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden="true" />
|
||||
) : (
|
||||
<span aria-hidden="true">💀</span>
|
||||
)}
|
||||
<span>Force Kill</span>
|
||||
</Button>
|
||||
{confirmingKill === "force" ? (
|
||||
<div className="absolute right-0 top-[calc(100%+0.375rem)] z-20 w-72 rounded-md border border-border bg-card p-2 shadow-lg">
|
||||
<p className="text-xs text-muted-foreground">
|
||||
This will hard-kill the agent immediately.
|
||||
</p>
|
||||
<div className="mt-2 flex justify-end gap-1.5">
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
setConfirmingKill(null);
|
||||
}}
|
||||
disabled={isBusy}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="danger"
|
||||
onClick={() => {
|
||||
submitAction("force-kill");
|
||||
}}
|
||||
disabled={isBusy}
|
||||
>
|
||||
{pendingAction === "force-kill" ? (
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden="true" />
|
||||
) : null}
|
||||
<span>Confirm</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{errorMessage ? (
|
||||
<Badge variant="status-error" className="max-w-[32rem] whitespace-normal text-xs">
|
||||
{errorMessage}
|
||||
</Badge>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
13
apps/web/src/components/ui/collapsible.tsx
Normal file
13
apps/web/src/components/ui/collapsible.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import * as React from "react";
|
||||
|
||||
export interface CollapsibleProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
open?: boolean;
|
||||
}
|
||||
|
||||
export function Collapsible({
|
||||
open = true,
|
||||
className = "",
|
||||
...props
|
||||
}: CollapsibleProps): React.JSX.Element {
|
||||
return <div data-state={open ? "open" : "closed"} className={className} {...props} />;
|
||||
}
|
||||
15
apps/web/src/components/ui/skeleton.tsx
Normal file
15
apps/web/src/components/ui/skeleton.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as React from "react";
|
||||
|
||||
export type SkeletonProps = React.HTMLAttributes<HTMLDivElement>;
|
||||
|
||||
export const Skeleton = React.forwardRef<HTMLDivElement, SkeletonProps>(
|
||||
({ className = "", ...props }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
className={`animate-pulse rounded-md bg-[rgb(var(--surface-2))] ${className}`}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
);
|
||||
|
||||
Skeleton.displayName = "Skeleton";
|
||||
Reference in New Issue
Block a user