2026-03-31 20:21:13 +01:00
|
|
|
import { useState, useMemo } from "react";
|
2026-03-07 08:26:49 -06:00
|
|
|
import { useQuery } from "@tanstack/react-query";
|
2026-03-02 16:44:03 -06:00
|
|
|
import { useNavigate } from "@/lib/router";
|
Build out agent management UI: detail page, create dialog, list view
Add NewAgentDialog for creating agents with adapter config. Expand
AgentDetail page with tabbed view (overview, runs, config, logs),
run history timeline, and live status. Enhance Agents list page with
richer cards and filtering. Update AgentProperties panel, API client,
query keys, and utility helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:33:04 -06:00
|
|
|
import { useDialog } from "../context/DialogContext";
|
|
|
|
|
import { useCompany } from "../context/CompanyContext";
|
|
|
|
|
import { agentsApi } from "../api/agents";
|
2026-03-31 20:21:13 +01:00
|
|
|
import { adaptersApi } from "../api/adapters";
|
|
|
|
|
import { queryKeys } from "@/lib/queryKeys";
|
Build out agent management UI: detail page, create dialog, list view
Add NewAgentDialog for creating agents with adapter config. Expand
AgentDetail page with tabbed view (overview, runs, config, logs),
run history timeline, and live status. Enhance Agents list page with
richer cards and filtering. Update AgentProperties panel, API client,
query keys, and utility helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:33:04 -06:00
|
|
|
import {
|
|
|
|
|
Dialog,
|
|
|
|
|
DialogContent,
|
|
|
|
|
} from "@/components/ui/dialog";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
2026-03-07 18:19:06 -06:00
|
|
|
import {
|
|
|
|
|
ArrowLeft,
|
|
|
|
|
Bot,
|
|
|
|
|
} from "lucide-react";
|
|
|
|
|
import { cn } from "@/lib/utils";
|
2026-03-31 20:21:13 +01:00
|
|
|
import { listUIAdapters } from "../adapters";
|
|
|
|
|
import { getAdapterDisplay } from "../adapters/adapter-display-registry";
|
|
|
|
|
import { useDisabledAdaptersSync } from "../adapters/use-disabled-adapters";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adapter types that are suitable for agent creation (excludes internal
|
|
|
|
|
* system adapters like "process" and "http").
|
|
|
|
|
*/
|
|
|
|
|
const SYSTEM_ADAPTER_TYPES = new Set(["process", "http"]);
|
|
|
|
|
|
|
|
|
|
function isAgentAdapterType(type: string): boolean {
|
|
|
|
|
return !SYSTEM_ADAPTER_TYPES.has(type);
|
|
|
|
|
}
|
2026-02-18 13:02:23 -06:00
|
|
|
|
Build out agent management UI: detail page, create dialog, list view
Add NewAgentDialog for creating agents with adapter config. Expand
AgentDetail page with tabbed view (overview, runs, config, logs),
run history timeline, and live status. Enhance Agents list page with
richer cards and filtering. Update AgentProperties panel, API client,
query keys, and utility helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:33:04 -06:00
|
|
|
export function NewAgentDialog() {
|
2026-03-07 08:26:49 -06:00
|
|
|
const { newAgentOpen, closeNewAgent, openNewIssue } = useDialog();
|
|
|
|
|
const { selectedCompanyId } = useCompany();
|
Build out agent management UI: detail page, create dialog, list view
Add NewAgentDialog for creating agents with adapter config. Expand
AgentDetail page with tabbed view (overview, runs, config, logs),
run history timeline, and live status. Enhance Agents list page with
richer cards and filtering. Update AgentProperties panel, API client,
query keys, and utility helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:33:04 -06:00
|
|
|
const navigate = useNavigate();
|
2026-03-07 18:19:06 -06:00
|
|
|
const [showAdvancedCards, setShowAdvancedCards] = useState(false);
|
2026-03-31 20:21:13 +01:00
|
|
|
const disabledTypes = useDisabledAdaptersSync();
|
Build out agent management UI: detail page, create dialog, list view
Add NewAgentDialog for creating agents with adapter config. Expand
AgentDetail page with tabbed view (overview, runs, config, logs),
run history timeline, and live status. Enhance Agents list page with
richer cards and filtering. Update AgentProperties panel, API client,
query keys, and utility helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:33:04 -06:00
|
|
|
|
2026-03-31 20:21:13 +01:00
|
|
|
// Fetch registered adapters from server (syncs disabled store + provides data)
|
|
|
|
|
const { data: serverAdapters } = useQuery({
|
|
|
|
|
queryKey: queryKeys.adapters.all,
|
|
|
|
|
queryFn: () => adaptersApi.list(),
|
|
|
|
|
staleTime: 5 * 60 * 1000,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Fetch existing agents for the "Ask CEO" flow
|
Build out agent management UI: detail page, create dialog, list view
Add NewAgentDialog for creating agents with adapter config. Expand
AgentDetail page with tabbed view (overview, runs, config, logs),
run history timeline, and live status. Enhance Agents list page with
richer cards and filtering. Update AgentProperties panel, API client,
query keys, and utility helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:33:04 -06:00
|
|
|
const { data: agents } = useQuery({
|
|
|
|
|
queryKey: queryKeys.agents.list(selectedCompanyId!),
|
|
|
|
|
queryFn: () => agentsApi.list(selectedCompanyId!),
|
|
|
|
|
enabled: !!selectedCompanyId && newAgentOpen,
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-07 08:26:49 -06:00
|
|
|
const ceoAgent = (agents ?? []).find((a) => a.role === "ceo");
|
2026-02-17 13:24:33 -06:00
|
|
|
|
2026-03-31 20:21:13 +01:00
|
|
|
// Build the adapter grid from the UI registry merged with display metadata.
|
|
|
|
|
// This automatically includes external/plugin adapters.
|
|
|
|
|
const adapterGrid = useMemo(() => {
|
|
|
|
|
const registered = listUIAdapters()
|
|
|
|
|
.filter((a) => isAgentAdapterType(a.type) && !disabledTypes.has(a.type));
|
|
|
|
|
|
|
|
|
|
// Sort: recommended first, then alphabetical
|
|
|
|
|
return registered
|
|
|
|
|
.map((a) => {
|
|
|
|
|
const display = getAdapterDisplay(a.type);
|
|
|
|
|
return {
|
|
|
|
|
value: a.type,
|
|
|
|
|
label: display.label,
|
|
|
|
|
desc: display.description,
|
|
|
|
|
icon: display.icon,
|
|
|
|
|
recommended: display.recommended,
|
|
|
|
|
comingSoon: display.comingSoon,
|
|
|
|
|
disabledLabel: display.disabledLabel,
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
.sort((a, b) => {
|
|
|
|
|
if (a.recommended && !b.recommended) return -1;
|
|
|
|
|
if (!a.recommended && b.recommended) return 1;
|
|
|
|
|
return a.label.localeCompare(b.label);
|
|
|
|
|
});
|
|
|
|
|
}, [disabledTypes, serverAdapters]);
|
|
|
|
|
|
2026-03-07 08:26:49 -06:00
|
|
|
function handleAskCeo() {
|
|
|
|
|
closeNewAgent();
|
|
|
|
|
openNewIssue({
|
|
|
|
|
assigneeAgentId: ceoAgent?.id,
|
|
|
|
|
title: "Create a new agent",
|
|
|
|
|
description: "(type in what kind of agent you want here)",
|
Build out agent management UI: detail page, create dialog, list view
Add NewAgentDialog for creating agents with adapter config. Expand
AgentDetail page with tabbed view (overview, runs, config, logs),
run history timeline, and live status. Enhance Agents list page with
richer cards and filtering. Update AgentProperties panel, API client,
query keys, and utility helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:33:04 -06:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-07 08:26:49 -06:00
|
|
|
function handleAdvancedConfig() {
|
2026-03-07 18:19:06 -06:00
|
|
|
setShowAdvancedCards(true);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-31 20:21:13 +01:00
|
|
|
function handleAdvancedAdapterPick(adapterType: string) {
|
2026-03-07 08:26:49 -06:00
|
|
|
closeNewAgent();
|
2026-03-07 18:19:06 -06:00
|
|
|
setShowAdvancedCards(false);
|
|
|
|
|
navigate(`/agents/new?adapterType=${encodeURIComponent(adapterType)}`);
|
Build out agent management UI: detail page, create dialog, list view
Add NewAgentDialog for creating agents with adapter config. Expand
AgentDetail page with tabbed view (overview, runs, config, logs),
run history timeline, and live status. Enhance Agents list page with
richer cards and filtering. Update AgentProperties panel, API client,
query keys, and utility helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:33:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Dialog
|
|
|
|
|
open={newAgentOpen}
|
|
|
|
|
onOpenChange={(open) => {
|
2026-03-07 18:19:06 -06:00
|
|
|
if (!open) {
|
|
|
|
|
setShowAdvancedCards(false);
|
|
|
|
|
closeNewAgent();
|
|
|
|
|
}
|
Build out agent management UI: detail page, create dialog, list view
Add NewAgentDialog for creating agents with adapter config. Expand
AgentDetail page with tabbed view (overview, runs, config, logs),
run history timeline, and live status. Enhance Agents list page with
richer cards and filtering. Update AgentProperties panel, API client,
query keys, and utility helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:33:04 -06:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<DialogContent
|
|
|
|
|
showCloseButton={false}
|
2026-03-07 08:26:49 -06:00
|
|
|
className="sm:max-w-md p-0 gap-0 overflow-hidden"
|
Build out agent management UI: detail page, create dialog, list view
Add NewAgentDialog for creating agents with adapter config. Expand
AgentDetail page with tabbed view (overview, runs, config, logs),
run history timeline, and live status. Enhance Agents list page with
richer cards and filtering. Update AgentProperties panel, API client,
query keys, and utility helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:33:04 -06:00
|
|
|
>
|
|
|
|
|
{/* Header */}
|
|
|
|
|
<div className="flex items-center justify-between px-4 py-2.5 border-b border-border">
|
2026-03-07 08:26:49 -06:00
|
|
|
<span className="text-sm text-muted-foreground">Add a new agent</span>
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="icon-xs"
|
|
|
|
|
className="text-muted-foreground"
|
2026-03-07 18:19:06 -06:00
|
|
|
onClick={() => {
|
|
|
|
|
setShowAdvancedCards(false);
|
|
|
|
|
closeNewAgent();
|
|
|
|
|
}}
|
2026-03-07 08:26:49 -06:00
|
|
|
>
|
|
|
|
|
<span className="text-lg leading-none">×</span>
|
|
|
|
|
</Button>
|
Build out agent management UI: detail page, create dialog, list view
Add NewAgentDialog for creating agents with adapter config. Expand
AgentDetail page with tabbed view (overview, runs, config, logs),
run history timeline, and live status. Enhance Agents list page with
richer cards and filtering. Update AgentProperties panel, API client,
query keys, and utility helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:33:04 -06:00
|
|
|
</div>
|
|
|
|
|
|
2026-03-07 08:26:49 -06:00
|
|
|
<div className="p-6 space-y-6">
|
2026-03-07 18:19:06 -06:00
|
|
|
{!showAdvancedCards ? (
|
|
|
|
|
<>
|
|
|
|
|
{/* Recommendation */}
|
|
|
|
|
<div className="text-center space-y-3">
|
|
|
|
|
<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-accent">
|
2026-03-31 20:21:13 +01:00
|
|
|
<Bot className="h-6 w-6 text-foreground" />
|
2026-03-07 18:19:06 -06:00
|
|
|
</div>
|
|
|
|
|
<p className="text-sm text-muted-foreground">
|
|
|
|
|
We recommend letting your CEO handle agent setup — they know the
|
|
|
|
|
org structure and can configure reporting, permissions, and
|
|
|
|
|
adapters.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
Build out agent management UI: detail page, create dialog, list view
Add NewAgentDialog for creating agents with adapter config. Expand
AgentDetail page with tabbed view (overview, runs, config, logs),
run history timeline, and live status. Enhance Agents list page with
richer cards and filtering. Update AgentProperties panel, API client,
query keys, and utility helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:33:04 -06:00
|
|
|
|
2026-03-07 18:19:06 -06:00
|
|
|
<Button className="w-full" size="lg" onClick={handleAskCeo}>
|
|
|
|
|
<Bot className="h-4 w-4 mr-2" />
|
|
|
|
|
Ask the CEO to create a new agent
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
{/* Advanced link */}
|
|
|
|
|
<div className="text-center">
|
|
|
|
|
<button
|
|
|
|
|
className="text-xs text-muted-foreground hover:text-foreground underline underline-offset-2 transition-colors"
|
|
|
|
|
onClick={handleAdvancedConfig}
|
|
|
|
|
>
|
|
|
|
|
I want advanced configuration myself
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
<button
|
|
|
|
|
className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
|
|
|
|
|
onClick={() => setShowAdvancedCards(false)}
|
|
|
|
|
>
|
|
|
|
|
<ArrowLeft className="h-3.5 w-3.5" />
|
|
|
|
|
Back
|
|
|
|
|
</button>
|
|
|
|
|
<p className="text-sm text-muted-foreground">
|
|
|
|
|
Choose your adapter type for advanced setup.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
Build out agent management UI: detail page, create dialog, list view
Add NewAgentDialog for creating agents with adapter config. Expand
AgentDetail page with tabbed view (overview, runs, config, logs),
run history timeline, and live status. Enhance Agents list page with
richer cards and filtering. Update AgentProperties panel, API client,
query keys, and utility helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:33:04 -06:00
|
|
|
|
2026-03-07 18:19:06 -06:00
|
|
|
<div className="grid grid-cols-2 gap-2">
|
2026-03-31 20:21:13 +01:00
|
|
|
{adapterGrid.map((opt) => (
|
2026-03-07 18:19:06 -06:00
|
|
|
<button
|
|
|
|
|
key={opt.value}
|
|
|
|
|
className={cn(
|
2026-03-31 20:21:13 +01:00
|
|
|
"flex flex-col items-center gap-1.5 rounded-md border border-border p-3 text-xs transition-colors hover:bg-accent/50 relative",
|
|
|
|
|
opt.comingSoon && "opacity-40 cursor-not-allowed",
|
2026-03-07 18:19:06 -06:00
|
|
|
)}
|
2026-03-31 20:21:13 +01:00
|
|
|
disabled={!!opt.comingSoon}
|
|
|
|
|
title={opt.comingSoon ? opt.disabledLabel : undefined}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
if (!opt.comingSoon) handleAdvancedAdapterPick(opt.value);
|
|
|
|
|
}}
|
2026-03-07 18:19:06 -06:00
|
|
|
>
|
|
|
|
|
{opt.recommended && (
|
|
|
|
|
<span className="absolute -top-1.5 right-1.5 bg-green-500 text-white text-[9px] font-semibold px-1.5 py-0.5 rounded-full leading-none">
|
|
|
|
|
Recommended
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
<opt.icon className="h-4 w-4" />
|
|
|
|
|
<span className="font-medium">{opt.label}</span>
|
|
|
|
|
<span className="text-muted-foreground text-[10px]">
|
|
|
|
|
{opt.desc}
|
|
|
|
|
</span>
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
Build out agent management UI: detail page, create dialog, list view
Add NewAgentDialog for creating agents with adapter config. Expand
AgentDetail page with tabbed view (overview, runs, config, logs),
run history timeline, and live status. Enhance Agents list page with
richer cards and filtering. Update AgentProperties panel, API client,
query keys, and utility helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 12:33:04 -06:00
|
|
|
</div>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
|
|
|
|
);
|
|
|
|
|
}
|