Skip to content

Commit ed9ec5e

Browse files
committed
fix: align agent cli detection and counts
1 parent 55a0117 commit ed9ec5e

8 files changed

Lines changed: 74 additions & 27 deletions

File tree

β€Žinternal/agent/chat_generic_cli.goβ€Ž

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,7 @@ func newCodexChatProvider(binPath string, prepareImage PrepareImageFunc) *CLICha
191191

192192
func newAntigravityChatProvider(binPath string, prepareImage PrepareImageFunc) *CLIChatProvider {
193193
return newCLIChatProvider(binPath, "antigravity", prepareImage, func(req ChatRequest) []string {
194-
args := []string{"--output-format", "text", "--yolo"}
195-
if req.Model != "" {
196-
args = append(args, "--model", req.Model)
197-
}
198-
return args
194+
return []string{"--print", "--dangerously-skip-permissions"}
199195
})
200196
}
201197

β€Žinternal/agent/chat_test.goβ€Ž

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ func TestNewChatProvider_Unsupported(t *testing.T) {
6565
}
6666
}
6767

68+
func TestAntigravityChatProviderUsesAgyPrintMode(t *testing.T) {
69+
p := newAntigravityChatProvider("/usr/bin/agy", nil)
70+
args := p.buildArgs(ChatRequest{Model: "ignored"})
71+
want := []string{"--print", "--dangerously-skip-permissions"}
72+
if strings.Join(args, "\x00") != strings.Join(want, "\x00") {
73+
t.Fatalf("args = %#v, want %#v", args, want)
74+
}
75+
}
76+
6877
func TestLocalLLMChatBatch(t *testing.T) {
6978
called := 0
7079
mp := &mockProvider{

β€Žinternal/agent/detect.goβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var defaultAdapters = []Adapter{
99
&CLIAdapter{AdapterCodex, "Codex CLI", "codex"},
1010
&CLIAdapter{AdapterClaude, "Claude Code", "claude"},
1111
&CLIAdapter{AdapterCursorAgent, "Cursor Agent", "cursor-agent"},
12-
&CLIAdapter{AdapterAntigravity, "Antigravity 2.0", "antigravity"},
12+
&CLIAdapter{AdapterAntigravity, "Antigravity 2.0", "agy"},
1313
&CLIAdapter{AdapterCopilot, "Copilot CLI", "copilot"},
1414
&CLIAdapter{AdapterPi, "Pi", "pi"},
1515
}

β€Žinternal/agent/detect_test.goβ€Ž

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ func TestBuildRuntimeStatus(t *testing.T) {
6464
}
6565
}
6666

67+
func TestDefaultAntigravityAdapterUsesAgyCLI(t *testing.T) {
68+
for _, adapter := range defaultAdapters {
69+
cli, ok := adapter.(*CLIAdapter)
70+
if !ok || cli.id != AdapterAntigravity {
71+
continue
72+
}
73+
if cli.bin != "agy" {
74+
t.Fatalf("expected Antigravity CLI binary agy, got %s", cli.bin)
75+
}
76+
return
77+
}
78+
t.Fatal("expected Antigravity adapter")
79+
}
80+
6781
func TestLocalLLMDetect_Enabled(t *testing.T) {
6882
a := NewLocalLLMAdapter(LLMInfo{Enabled: true, Provider: "ollama", Model: "llava:7b"})
6983
info, err := a.Detect(context.Background())

β€Žui/src/features/settings/AISettingsCard.tsxβ€Ž

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ import {
4848
import type { Mode } from "@/ui";
4949
import { FieldRow } from "./index";
5050
import type { SettingsDraft } from "./types";
51-
import { deriveHost, sortedTranslationLocales } from "./aiSectionUtils";
51+
import {
52+
agentCliAdapters,
53+
deriveHost,
54+
sortedTranslationLocales,
55+
} from "./aiSectionUtils";
5256

5357
type AISettingsCardProps = {
5458
draft: SettingsDraft;
@@ -83,6 +87,7 @@ export function AISettingsCard({
8387
"local" | "agent" | "backend" | "prompts" | "search"
8488
>("local");
8589

90+
const agentAdapters = agentCliAdapters(settings?.agentRuntime?.adapters);
8691
const host = deriveHost(settings?.llmEndpoint);
8792
const defaultEndpoints: Record<string, string> = {
8893
ollama: `http://${host}:11434`,
@@ -171,10 +176,8 @@ export function AISettingsCard({
171176
value: "agent" as const,
172177
label: t("settings.aiTabAgent"),
173178
icon: <Bot />,
174-
badge: settings?.agentRuntime?.adapters?.length ? (
175-
<Badge tone="green">
176-
{settings.agentRuntime.adapters.length}
177-
</Badge>
179+
badge: agentAdapters.length ? (
180+
<Badge tone="green">{agentAdapters.length}</Badge>
178181
) : undefined,
179182
},
180183
{
@@ -454,20 +457,18 @@ export function AISettingsCard({
454457
<FieldRow
455458
label={t("settings.agentAvailable")}
456459
description={
457-
settings?.agentRuntime?.adapters?.length
460+
agentAdapters.length
458461
? undefined
459462
: t("settings.agentNoneDetected")
460463
}
461464
>
462465
<div className="flex flex-wrap items-center gap-1.5">
463-
{settings?.agentRuntime?.adapters
464-
?.filter((a) => a.id !== "local-llm")
465-
.map((a) => (
466-
<Badge key={a.id} tone="green">
467-
{a.name}
468-
{a.version ? ` ${a.version}` : ""}
469-
</Badge>
470-
))}
466+
{agentAdapters.map((a) => (
467+
<Badge key={a.id} tone="green">
468+
{a.name}
469+
{a.version ? ` ${a.version}` : ""}
470+
</Badge>
471+
))}
471472
<Tooltip label={t("settings.agentDetectTooltip")}>
472473
<IconButton
473474
size="sm"
@@ -476,10 +477,9 @@ export function AISettingsCard({
476477
onClick={() =>
477478
detectMutation.mutate(undefined, {
478479
onSuccess: (data) => {
479-
const count =
480-
data.settings.agentRuntime?.adapters?.filter(
481-
(a) => a.id !== "local-llm",
482-
).length ?? 0;
480+
const count = agentCliAdapters(
481+
data.settings.agentRuntime?.adapters,
482+
).length;
483483
toast.success(
484484
t("settings.agentDetectDone", { count }),
485485
);

β€Žui/src/features/settings/VLMBackendSelect.tsxβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next";
44
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
55
import { Badge, TextInput } from "@/components/ui";
66
import type { AgentRuntime, LLMModel, LLMRuntime } from "@/types";
7+
import { agentCliAdapters } from "./aiSectionUtils";
78

89
type ParsedBackend =
910
| { type: "inherit" }
@@ -76,8 +77,7 @@ export function VLMBackendSelect({
7677
setAgentModel(agentModelFromValue);
7778
}
7879

79-
const adapters =
80-
agentRuntime?.adapters?.filter((a) => a.id !== "local-llm") ?? [];
80+
const adapters = agentCliAdapters(agentRuntime?.adapters);
8181
const localModels = Array.isArray(models) ? models : [];
8282
const isConnected = !!llmRuntime?.connected;
8383
const hasLocalGroup = localModels.length > 0 || isConnected;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { describe, expect, it } from "vitest";
2+
import { agentCliAdapters } from "./aiSectionUtils";
3+
import type { AgentAdapterInfo } from "@/types";
4+
5+
describe("agentCliAdapters", () => {
6+
it("excludes Local LLM from Agent CLI counts and lists", () => {
7+
const adapters: AgentAdapterInfo[] = [
8+
{ id: "codex", name: "Codex CLI", version: "0.1.0", path: "/bin/codex" },
9+
{ id: "local-llm", name: "Local LLM", version: "ollama/llava", path: "" },
10+
{ id: "pi", name: "Pi", version: "", path: "/bin/pi" },
11+
];
12+
13+
expect(agentCliAdapters(adapters).map((adapter) => adapter.id)).toEqual([
14+
"codex",
15+
"pi",
16+
]);
17+
});
18+
19+
it("returns an empty list when no adapters were reported", () => {
20+
expect(agentCliAdapters(undefined)).toEqual([]);
21+
});
22+
});

β€Žui/src/features/settings/aiSectionUtils.tsβ€Ž

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ReactNode } from "react";
22
import type { AITagActivityState } from "@/activity/aiTagActivity";
33
import type { VLMOcrActivityState } from "@/activity/vlmOcrActivity";
44
import type { EmbedActivityState } from "@/activity/embedActivity";
5-
import type { SettingsInfo, Workspace } from "@/types";
5+
import type { AgentAdapterInfo, SettingsInfo, Workspace } from "@/types";
66
import type { Mode } from "@/ui";
77
import type { ScopeProject } from "./AIScopePicker";
88
import type { SettingsDraft } from "./types";
@@ -107,6 +107,12 @@ export function deriveHost(endpoint: string | undefined): string {
107107
}
108108
}
109109

110+
export function agentCliAdapters(
111+
adapters: AgentAdapterInfo[] | undefined,
112+
): AgentAdapterInfo[] {
113+
return adapters?.filter((adapter) => adapter.id !== "local-llm") ?? [];
114+
}
115+
110116
// ── Locale helpers ─────────────────────────────────────────────────
111117

112118
export const ALL_TRANSLATION_LOCALES = [

0 commit comments

Comments
Β (0)