Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(ui): auto-activate newly created agent

Naiyuan Qing94f32701c7d3
diff --git a/apps/web/app/components/hub-sidebar.tsx b/apps/web/app/components/hub-sidebar.tsx
index 87e3bc3516..72687f6d7b 100644
--- a/apps/web/app/components/hub-sidebar.tsx
+++ b/apps/web/app/components/hub-sidebar.tsx
@@ -10,7 +10,7 @@ import {
} from "@multica/ui/components/ui/sidebar"
import { Button } from "@multica/ui/components/ui/button"
import { HugeiconsIcon } from "@hugeicons/react"
-import { PlusSignIcon, Delete02Icon, Loading03Icon } from "@hugeicons/core-free-icons"
+import { PlusSignIcon, Delete02Icon } from "@hugeicons/core-free-icons"
import { useHub } from "../hooks/use-hub"
import { useActiveAgent } from "../hooks/use-active-agent"
@@ -60,10 +60,13 @@ export function HubSidebar() {
{status === "connected" && (
<SidebarGroup>
<SidebarGroupLabel>Agents</SidebarGroupLabel>
- <SidebarGroupAction onClick={createAgent} title="Create agent">
+ <SidebarGroupAction onClick={async () => {
+ const id = await createAgent()
+ if (id) setActiveAgentId(id)
+ }} title="Create agent">
<HugeiconsIcon icon={PlusSignIcon} strokeWidth={2} className="size-4" />
</SidebarGroupAction>
- <SidebarGroupContent>
+ <SidebarGroupContent className="flex flex-col gap-1">
<SidebarMenu>
{agents.length === 0 && (
<div className="px-2 py-2 text-xs text-muted-foreground/60">
diff --git a/apps/web/app/hooks/use-hub.ts b/apps/web/app/hooks/use-hub.ts
index b49df592ac..3f9f0c2e6c 100644
--- a/apps/web/app/hooks/use-hub.ts
+++ b/apps/web/app/hooks/use-hub.ts
@@ -41,9 +41,12 @@ export function useHub() {
} catch { /* silent */ }
}, [])
- const createAgent = useCallback(async () => {
- await fetch(`${CONSOLE_URL}/api/agents`, { method: "POST" })
+ const createAgent = useCallback(async (): Promise<string | null> => {
+ const res = await fetch(`${CONSOLE_URL}/api/agents`, { method: "POST" })
await fetchAgents()
+ if (!res.ok) return null
+ const data = await res.json()
+ return data.id ?? null
}, [fetchAgents])
const deleteAgent = useCallback(async (id: string) => {