2026-03-07 18:19:06 -06:00
|
|
|
import { useState, type ComponentType } 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";
|
|
|
|
|
import { queryKeys } from "../lib/queryKeys";
|
|
|
|
|
import {
|
|
|
|
|
Dialog,
|
|
|
|
|
DialogContent,
|
|
|
|
|
} from "@/components/ui/dialog";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
2026-03-07 18:19:06 -06:00
|
|
|
import {
|
|
|
|
|
ArrowLeft,
|
|
|
|
|
Bot,
|
|
|
|
|
Code,
|
2026-03-08 16:43:34 +05:30
|
|
|
Gem,
|
2026-03-07 18:19:06 -06:00
|
|
|
MousePointer2,
|
|
|
|
|
Sparkles,
|
|
|
|
|
Terminal,
|
|
|
|
|
} from "lucide-react";
|
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
import { OpenCodeLogoIcon } from "./OpenCodeLogoIcon";
|
|
|
|
|
|
|
|
|
|
type AdvancedAdapterType =
|
|
|
|
|
| "claude_local"
|
|
|
|
|
| "codex_local"
|
2026-03-08 16:43:34 +05:30
|
|
|
| "gemini_local"
|
2026-03-07 18:19:06 -06:00
|
|
|
| "opencode_local"
|
|
|
|
|
| "pi_local"
|
|
|
|
|
| "cursor"
|
|
|
|
|
| "openclaw_gateway";
|
|
|
|
|
|
|
|
|
|
const ADVANCED_ADAPTER_OPTIONS: Array<{
|
|
|
|
|
value: AdvancedAdapterType;
|
|
|
|
|
label: string;
|
|
|
|
|
desc: string;
|
|
|
|
|
icon: ComponentType<{ className?: string }>;
|
|
|
|
|
recommended?: boolean;
|
|
|
|
|
}> = [
|
|
|
|
|
{
|
|
|
|
|
value: "claude_local",
|
|
|
|
|
label: "Claude Code",
|
|
|
|
|
icon: Sparkles,
|
|
|
|
|
desc: "Local Claude agent",
|
|
|
|
|
recommended: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: "codex_local",
|
|
|
|
|
label: "Codex",
|
|
|
|
|
icon: Code,
|
|
|
|
|
desc: "Local Codex agent",
|
|
|
|
|
recommended: true,
|
|
|
|
|
},
|
2026-03-08 16:43:34 +05:30
|
|
|
{
|
|
|
|
|
value: "gemini_local",
|
|
|
|
|
label: "Gemini CLI",
|
|
|
|
|
icon: Gem,
|
|
|
|
|
desc: "Local Gemini agent",
|
|
|
|
|
},
|
2026-03-07 18:19:06 -06:00
|
|
|
{
|
|
|
|
|
value: "opencode_local",
|
|
|
|
|
label: "OpenCode",
|
|
|
|
|
icon: OpenCodeLogoIcon,
|
|
|
|
|
desc: "Local multi-provider agent",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: "pi_local",
|
|
|
|
|
label: "Pi",
|
|
|
|
|
icon: Terminal,
|
|
|
|
|
desc: "Local Pi agent",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: "cursor",
|
|
|
|
|
label: "Cursor",
|
|
|
|
|
icon: MousePointer2,
|
|
|
|
|
desc: "Local Cursor agent",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: "openclaw_gateway",
|
|
|
|
|
label: "OpenClaw Gateway",
|
|
|
|
|
icon: Bot,
|
|
|
|
|
desc: "Invoke OpenClaw via gateway protocol",
|
|
|
|
|
},
|
|
|
|
|
];
|
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);
|
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-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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleAdvancedAdapterPick(adapterType: AdvancedAdapterType) {
|
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">
|
|
|
|
|
<Sparkles className="h-6 w-6 text-foreground" />
|
|
|
|
|
</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">
|
|
|
|
|
{ADVANCED_ADAPTER_OPTIONS.map((opt) => (
|
|
|
|
|
<button
|
|
|
|
|
key={opt.value}
|
|
|
|
|
className={cn(
|
|
|
|
|
"flex flex-col items-center gap-1.5 rounded-md border border-border p-3 text-xs transition-colors hover:bg-accent/50 relative"
|
|
|
|
|
)}
|
|
|
|
|
onClick={() => handleAdvancedAdapterPick(opt.value)}
|
|
|
|
|
>
|
|
|
|
|
{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>
|
|
|
|
|
);
|
|
|
|
|
}
|