AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
fix: hide absent local agents and simplify the agent selector
tianma-ife43b4ab4e3ed
diff --git a/apps/web/src/components/ai-sidebar/AiAgentSelector.tsx b/apps/web/src/components/ai-sidebar/AiAgentSelector.tsxindex f2791d95..3c917c3b 100644--- a/apps/web/src/components/ai-sidebar/AiAgentSelector.tsx+++ b/apps/web/src/components/ai-sidebar/AiAgentSelector.tsx@@ -10,14 +10,14 @@ import {} from "@/components/ui/dropdown-menu";import { api } from "@/lib/api";import {- AI_SIDEBAR_ADAPTER_PATH_KEY, desktopAcpAutomaticProbeInput,+ AI_SIDEBAR_ADAPTER_PATH_KEY, desktopAcpAutomaticProbeInput, desktopAcpSelectorVisible,desktopAcpAvailable, listDesktopAcpAdapters, probeDesktopAcpAdapter, selectAiSidebarAgent,type AiSidebarSource, type DesktopAcpAdapterId,} from "@/lib/desktop-acp";import { aiErrorMessage, formatProviderOrdinal, isLegacyProviderDisplayName } from "../settings/ai-provider-options";import { resolveBuiltinAgentModel } from "./builtin-agent-model";-export function AiAgentSelector({ source, adapterId, disabled, onPendingChange, noteContext = false }: {+export function AiAgentSelector({ source, adapterId, disabled, onPendingChange }: {source: AiSidebarSource;adapterId: DesktopAcpAdapterId | null;disabled: boolean;@@ -37,7 +37,7 @@ export function AiAgentSelector({ source, adapterId, disabled, onPendingChange,staleTime: 0,});const customPath = desktop && open ? window.localStorage.getItem(AI_SIDEBAR_ADAPTER_PATH_KEY) ?? "" : "";- const listedAgents = agents.data ?? [];+ const listedAgents = (agents.data ?? []).filter((agent) => desktopAcpSelectorVisible(agent, customPath));const probeInputs = listedAgents.map((agent) => desktopAcpAutomaticProbeInput(agent, customPath));const probes = useQueries({queries: listedAgents.map((agent, index) => ({@@ -80,7 +80,6 @@ export function AiAgentSelector({ source, adapterId, disabled, onPendingChange,? (adapterId ? t(`aiAssistant.agentSource.${adapterId}`) : t("aiAssistant.agentSource.local")): `${t("aiAssistant.agentSource.builtin")} · ${modelLabel}`;const buttonLabel = source === "local" ? label : builtin?.label ?? t("aiModel.noDefaultModel");- const localHint = t(noteContext ? "aiAssistant.agentSource.switchNoteAgentHint" : "aiAssistant.agentSource.newAgentThread");const selected = source === "local" ? `agent:${adapterId}` : settings.data?.defaultModelId ? `model:${settings.data.defaultModelId}` : "builtin";const providers = (settings.data?.providers ?? []).map((provider, index) => {const name = !provider.displayName || isLegacyProviderDisplayName(provider.displayName, provider.provider)@@ -129,12 +128,11 @@ export function AiAgentSelector({ source, adapterId, disabled, onPendingChange,{desktop ? <><DropdownMenuSeparator /><DropdownMenuLabel>{t("aiAssistant.agentSource.local")}</DropdownMenuLabel>- <p className="px-2 pb-1 text-[11px] text-slate-500">{localHint}</p>{agents.isPending ? <p className="px-2 py-2 text-xs">{t("common.loading")}</p> : null}{agents.isError ? <p role="alert" className="px-2 py-2 text-xs text-rose-600">{t("aiAssistant.agentSource.switchUnavailable")}</p> : null}- {localAgents.map((agent, index) => <DropdownMenuRadioItem key={agent.id} value={`agent:${agent.id}`} disabled={mutation.isPending || (probeInputs[index] !== null && probes[index].isFetching) || agent.state !== "available"} onSelect={(event) => event.preventDefault()}>+ {localAgents.map((agent, index) => desktopAcpSelectorVisible(agent, customPath) ? <DropdownMenuRadioItem key={agent.id} value={`agent:${agent.id}`} disabled={mutation.isPending || (probeInputs[index] !== null && probes[index].isFetching) || agent.state !== "available"} onSelect={(event) => event.preventDefault()}><span className="flex min-w-0 flex-1 flex-wrap justify-between gap-x-2"><span>{t(`aiAssistant.agentSource.${agent.id}`)}</span><span className="text-[10px] text-slate-500">{probeInputs[index] !== null && probes[index].isFetching ? t("aiAssistant.agentSource.probing") : t(`aiAssistant.agentSource.states.${agent.state}`)}</span></span>- </DropdownMenuRadioItem>)}+ </DropdownMenuRadioItem> : null)}{!agents.isPending && !agents.isError && !localAgents.length ? <p className="px-2 py-2 text-xs text-slate-500">{t("aiAssistant.agentSource.switchUnavailable")}</p> : null}</> : null}</DropdownMenuRadioGroup>diff --git a/apps/web/src/lib/desktop-acp.test.mjs b/apps/web/src/lib/desktop-acp.test.mjsindex f1f12e2f..40907650 100644--- a/apps/web/src/lib/desktop-acp.test.mjs+++ b/apps/web/src/lib/desktop-acp.test.mjs@@ -105,3 +105,16 @@ test("automatic checks skip missing, installing, ready and login-required agentsexpect(desktopAcpAutomaticProbeInput(antigravity, " /custom/agy ")).toEqual({ id: "antigravity", path: "/custom/agy" });expect(desktopAcpAutomaticProbeInput({ ...antigravity, state: "installing" }, "/custom/agy")).toBeNull();});++test("the quick selector hides absent connectors while keeping detected agents and custom Antigravity paths", async () => {+ const { desktopAcpSelectorVisible } = await import("./desktop-acp.ts");+ const absent = { id: "claudeCode", label: "Claude Code", state: "not_installed" };+ expect(desktopAcpSelectorVisible(absent, "")).toBe(false);+ expect(desktopAcpSelectorVisible(absent, "/custom/agy")).toBe(false);+ for (const state of ["not_probed", "installing", "needs_login", "available", "failed"]) {+ expect(desktopAcpSelectorVisible({ ...absent, state }, "")).toBe(true);+ }+ const custom = { ...absent, id: "antigravity" };+ expect(desktopAcpSelectorVisible(custom, " /custom/agy ")).toBe(true);+ expect(desktopAcpSelectorVisible(custom, " ")).toBe(false);+});diff --git a/apps/web/src/lib/desktop-acp.ts b/apps/web/src/lib/desktop-acp.tsindex ea760465..f45ac0e2 100644--- a/apps/web/src/lib/desktop-acp.ts+++ b/apps/web/src/lib/desktop-acp.ts@@ -37,6 +37,10 @@ export const displayedDesktopAcpAdapter = ({return checked ?? current;};+export const desktopAcpSelectorVisible = (adapter: DesktopAcpAdapter, customPath: string) => (+ adapter.state !== "not_installed" || (adapter.id === "antigravity" && Boolean(customPath.trim()))+);+export const desktopAcpAutomaticProbeInput = (adapter: DesktopAcpAdapter, customPath: string) => {if (adapter.state === "installing") return null;if (adapter.id === "antigravity" && customPath.trim()) return { id: adapter.id, path: customPath.trim() };