mirror of
https://github.com/getpaseo/paseo.git
synced 2026-12-01 04:36:26 +00:00
feat(app): show only the Enable tools switch in setup
Setup is for getting started, so the Orchestration step shows a plain Enable tools switch next to skills and the CLI. Tool groups stay in Settings > Tools & prompts. Setup writes only the main switch, so the groups a host already saved are never touched.
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
@@ -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<Choices>(ALL_ON);
|
||||
const [changedToolGroups, setChangedToolGroups] = useState<Partial<AgentToolGroupsState>>({});
|
||||
// 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<Choices>(
|
||||
@@ -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<AgentToolGroupsState>(
|
||||
() => ({ ...(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,
|
||||
|
||||
@@ -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 (
|
||||
<SettingsCard>
|
||||
<AgentToolsRow
|
||||
enabled={choices.tools}
|
||||
groups={toolGroups}
|
||||
supportsGroupControls={supportsToolGroups}
|
||||
onEnabledChange={setTools}
|
||||
onGroupChange={setToolGroup}
|
||||
disabled={isApplying}
|
||||
/>
|
||||
<EnableToolsSwitchRow value={choices.tools} onValueChange={setTools} disabled={isApplying} />
|
||||
{offered.skills ? (
|
||||
<AgentSkillsRow
|
||||
skills={setup.skills}
|
||||
|
||||
@@ -135,17 +135,11 @@ describe("agent tools UI state and legacy daemon compatibility", () => {
|
||||
).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", () => {
|
||||
|
||||
@@ -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<AgentToolGroupsState>;
|
||||
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<AgentToolGroupsState> = {};
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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 (
|
||||
<SettingsRow
|
||||
label={t("settings.host.orchestration.enableTools.title")}
|
||||
hint={t("settings.host.orchestration.enableTools.hint")}
|
||||
>
|
||||
<Switch
|
||||
value={value}
|
||||
onValueChange={onValueChange}
|
||||
disabled={disabled}
|
||||
accessibilityLabel={t("settings.host.orchestration.enableTools.accessibilityLabel")}
|
||||
/>
|
||||
</SettingsRow>
|
||||
);
|
||||
}
|
||||
|
||||
/** Expandable "Enable tools" row on its own, for callers that control the state. */
|
||||
export function AgentToolsRow({
|
||||
enabled,
|
||||
groups,
|
||||
|
||||
Reference in New Issue
Block a user