diff --git a/packages/app/e2e/browser/onboarding.spec.ts b/packages/app/e2e/browser/onboarding.spec.ts index a1edf20c22..acaafe8977 100644 --- a/packages/app/e2e/browser/onboarding.spec.ts +++ b/packages/app/e2e/browser/onboarding.spec.ts @@ -428,7 +428,7 @@ test("setup choices carry over to Settings and the phone step pairs over relay", } }); -test("Continue on Orchestration keeps the host's tool groups", async ({ page }) => { +test("setup offers only Enable tools and keeps the host's tool groups", async ({ page }) => { const host = await startSetupHost("tool-groups"); try { @@ -438,6 +438,10 @@ test("Continue on Orchestration keeps the host's tool groups", async ({ page }) await goToSetupStep(page, "Orchestration"); await expectSetupStep(page, "Let agents use Paseo"); await expect(paseoToolsSwitch(setupModal(page))).toBeChecked(); + // Setup offers only the main switch; tool groups live in Settings. + await expect( + setupModal(page).getByRole("switch", { name: "Browser", exact: true }), + ).toHaveCount(0); await continueSetup(page); await expectSetupStep(page, "Take your agents with you"); diff --git a/packages/app/src/onboarding/internal/orchestration-setup.ts b/packages/app/src/onboarding/internal/orchestration-setup.ts index f6a3698422..1c13f49109 100644 --- a/packages/app/src/onboarding/internal/orchestration-setup.ts +++ b/packages/app/src/onboarding/internal/orchestration-setup.ts @@ -12,10 +12,7 @@ import { useDaemonConfig } from "@/hooks/use-daemon-config"; import { useHostFeature } from "@/runtime/host-features"; import { createOnboardingAgentToolsPatch, - DEFAULT_AGENT_TOOL_GROUPS, - resolveAgentToolsState, - type AgentToolGroupId, - type AgentToolGroupsState, + isHostAgentToolsEnabled, } from "@/screens/settings/agent-tools-config"; export type OrchestrationChoice = "tools" | "skills" | "cli"; @@ -25,10 +22,7 @@ const ALL_ON: Choices = { tools: true, skills: true, cli: true }; export interface OrchestrationSetupController { choices: Choices; - toolGroups: AgentToolGroupsState; - supportsToolGroups: boolean; setChoice: (choice: OrchestrationChoice, on: boolean) => void; - setToolGroup: (group: AgentToolGroupId, on: boolean) => void; /** Only the choices this host and app can act on: skills need host support, the CLI the desktop app. */ offered: Choices; /** The skills row's picker and Update act on the host directly, through this. */ @@ -50,10 +44,9 @@ export function useOrchestrationSetup(serverId: string): OrchestrationSetupContr const toast = useToast(); const skills = useAgentSkills(serverId); const cli = useCliInstall(); - const supportsToolGroups = useHostFeature(serverId, "daemonToolsConfig"); + const supportsToolsConfig = useHostFeature(serverId, "daemonToolsConfig"); const { config, patchConfig } = useDaemonConfig(serverId); const [chosen, setChosen] = useState(ALL_ON); - const [changedToolGroups, setChangedToolGroups] = useState>({}); // With nothing picked there is nothing to install, so skills read as off, as they do in Settings. const skillsSelected = skills.status === null || hasSelectedSkills(skills.status); const choices = useMemo( @@ -71,21 +64,9 @@ export function useOrchestrationSetup(serverId: string): OrchestrationSetupContr setChosen((current) => ({ ...current, [choice]: on })); }, []); - const setToolGroup = useCallback((group: AgentToolGroupId, on: boolean) => { - setChangedToolGroups((current) => ({ ...current, [group]: on })); - }, []); - // What the host and this computer have now, or null while it is still being read. A choice is // skipped only when it is known to match; an unknown state is always written. - const currentToolsState = useMemo( - () => - config ? resolveAgentToolsState({ config, supportsToolsConfig: supportsToolGroups }) : null, - [config, supportsToolGroups], - ); - const toolGroups = useMemo( - () => ({ ...(currentToolsState?.groups ?? DEFAULT_AGENT_TOOL_GROUPS), ...changedToolGroups }), - [currentToolsState, changedToolGroups], - ); + const toolsEnabled = config ? isHostAgentToolsEnabled(config) : null; const skillsInstalled = skills.status ? areSkillsInstalled(skills.status) : null; const cliInstalled = cli.status ? cli.status.installed : null; const { reconcile, uninstall } = skills; @@ -96,9 +77,8 @@ export function useOrchestrationSetup(serverId: string): OrchestrationSetupContr const applyTools = useCallback(() => { const patch = createOnboardingAgentToolsPatch({ enabled: choices.tools, - changedGroups: changedToolGroups, - current: currentToolsState, - supportsToolsConfig: supportsToolGroups, + currentEnabled: toolsEnabled, + supportsToolsConfig, }); if (!patch) return Promise.resolve(true); return patchConfig(patch) @@ -107,15 +87,7 @@ export function useOrchestrationSetup(serverId: string): OrchestrationSetupContr if (!done) toast.error(t("settings.host.orchestration.enableTools.updateFailed")); return done; }); - }, [ - changedToolGroups, - choices.tools, - currentToolsState, - patchConfig, - supportsToolGroups, - t, - toast, - ]); + }, [choices.tools, toolsEnabled, patchConfig, supportsToolsConfig, t, toast]); const setSkillsInstalled = useCallback( (on: boolean) => (on ? reconcile() : uninstall()), @@ -150,10 +122,7 @@ export function useOrchestrationSetup(serverId: string): OrchestrationSetupContr return { choices, - toolGroups, - supportsToolGroups, setChoice, - setToolGroup, offered, skills, isApplying, diff --git a/packages/app/src/onboarding/internal/steps/orchestration-step.tsx b/packages/app/src/onboarding/internal/steps/orchestration-step.tsx index c023573ee4..07a281212c 100644 --- a/packages/app/src/onboarding/internal/steps/orchestration-step.tsx +++ b/packages/app/src/onboarding/internal/steps/orchestration-step.tsx @@ -2,26 +2,18 @@ import { useCallback } from "react"; import { AgentSkillsRow } from "@/agent-skills"; import { SettingsCard } from "@/components/settings"; import { CommandLineRow } from "@/desktop/components/integrations-section"; -import { AgentToolsRow } from "@/screens/settings/agent-tools-row"; +import { EnableToolsSwitchRow } from "@/screens/settings/agent-tools-row"; import type { OrchestrationSetupController } from "../orchestration-setup"; /** Three switches, all on to start; Continue applies them. */ export function OrchestrationStep({ setup }: { setup: OrchestrationSetupController }) { - const { choices, toolGroups, supportsToolGroups, setChoice, setToolGroup, offered, isApplying } = - setup; + const { choices, setChoice, offered, isApplying } = setup; const setTools = useCallback((on: boolean) => setChoice("tools", on), [setChoice]); const setSkills = useCallback((on: boolean) => setChoice("skills", on), [setChoice]); const setCli = useCallback((on: boolean) => setChoice("cli", on), [setChoice]); return ( - + {offered.skills ? ( { ).toBeNull(); }); - it("creates minimal onboarding patches for modern and legacy daemons", () => { - const current = { - enabled: true, - groups: { ...DEFAULT_AGENT_TOOL_GROUPS }, - }; - + it("setup writes only the main switch, and only when it differs from the host", () => { expect( createOnboardingAgentToolsPatch({ enabled: true, - changedGroups: {}, - current, + currentEnabled: true, supportsToolsConfig: true, }), ).toBeNull(); @@ -153,57 +147,26 @@ describe("agent tools UI state and legacy daemon compatibility", () => { expect( createOnboardingAgentToolsPatch({ enabled: true, - changedGroups: { schedules: false, browser: true }, - current, + currentEnabled: false, supportsToolsConfig: true, }), - ).toEqual({ - tools: { - groups: { - schedules: false, - browser: true, - }, - }, - }); - - expect( - createOnboardingAgentToolsPatch({ - enabled: false, - changedGroups: { browser: true }, - current, - supportsToolsConfig: false, - }), - ).toEqual({ - mcp: { injectIntoAgents: false }, - browserTools: { enabled: true }, - }); - }); - - it("keeps the host's tool groups when setup continues without changing them", () => { - const current = { - enabled: true, - groups: { ...DEFAULT_AGENT_TOOL_GROUPS, schedules: false, browser: true }, - }; - - for (const supportsToolsConfig of [true, false]) { - expect( - createOnboardingAgentToolsPatch({ - enabled: true, - changedGroups: {}, - current, - supportsToolsConfig, - }), - ).toBeNull(); - } + ).toEqual({ tools: { enabled: true } }); expect( createOnboardingAgentToolsPatch({ enabled: true, - changedGroups: {}, - current: { ...current, enabled: false }, + currentEnabled: null, supportsToolsConfig: true, }), ).toEqual({ tools: { enabled: true } }); + + expect( + createOnboardingAgentToolsPatch({ + enabled: false, + currentEnabled: true, + supportsToolsConfig: false, + }), + ).toEqual({ mcp: { injectIntoAgents: false } }); }); it("reports whether host agent tools are enabled for Voice UI checks", () => { diff --git a/packages/app/src/screens/settings/agent-tools-config.ts b/packages/app/src/screens/settings/agent-tools-config.ts index 7d3d7d3126..92729309e3 100644 --- a/packages/app/src/screens/settings/agent-tools-config.ts +++ b/packages/app/src/screens/settings/agent-tools-config.ts @@ -72,41 +72,14 @@ export function createAgentToolGroupPatch(input: { } /** - * Writes the main switch when it differs from the host, and only the groups the user changed. The - * groups sit in a collapsed row, so a group the user never touched keeps the host's value. + * Setup only sets the main switch. It never writes tool groups, so the host keeps the groups saved + * in Settings. An unknown host state is always written. */ export function createOnboardingAgentToolsPatch(input: { enabled: boolean; - changedGroups: Partial; - current: { enabled: boolean; groups: AgentToolGroupsState } | null; + currentEnabled: boolean | null; supportsToolsConfig: boolean; }): MutableDaemonConfigPatch | null { - const { enabled, changedGroups, current, supportsToolsConfig } = input; - const writesEnabled = current === null || current.enabled !== enabled; - const groups: Partial = {}; - for (const group of AGENT_TOOL_GROUP_ORDER) { - const value = changedGroups[group]; - if (value !== undefined && (current === null || current.groups[group] !== value)) { - groups[group] = value; - } - } - const writesGroups = Object.keys(groups).length > 0; - if (supportsToolsConfig) { - if (!writesEnabled && !writesGroups) return null; - return { - tools: { - ...(writesEnabled ? { enabled } : {}), - ...(writesGroups ? { groups } : {}), - }, - }; - } - // COMPAT(daemonToolsConfig): added in v0.18.2, remove after 2027-06-01. - const patch: MutableDaemonConfigPatch = {}; - if (writesEnabled) { - patch.mcp = { injectIntoAgents: enabled }; - } - if (groups.browser !== undefined) { - patch.browserTools = { enabled: groups.browser }; - } - return Object.keys(patch).length > 0 ? patch : null; + if (input.currentEnabled === input.enabled) return null; + return createAgentToolsMasterPatch(input); } diff --git a/packages/app/src/screens/settings/agent-tools-row.tsx b/packages/app/src/screens/settings/agent-tools-row.tsx index d3b868fe77..6bd078478c 100644 --- a/packages/app/src/screens/settings/agent-tools-row.tsx +++ b/packages/app/src/screens/settings/agent-tools-row.tsx @@ -117,7 +117,33 @@ export function HostAgentToolsRow({ serverId }: { serverId: string }) { ); } -/** Expandable "Enable tools" row on its own, for callers that control the state (Settings & Onboarding). */ +/** Plain "Enable tools" switch with no group controls, for setup. Groups stay in Settings. */ +export function EnableToolsSwitchRow({ + value, + onValueChange, + disabled, +}: { + value: boolean; + onValueChange: (enabled: boolean) => void; + disabled?: boolean; +}) { + const { t } = useTranslation(); + return ( + + + + ); +} + +/** Expandable "Enable tools" row on its own, for callers that control the state. */ export function AgentToolsRow({ enabled, groups,