Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apps/desktop/src/renderer/lib/agent-launch-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { joinCommandArgs } from "./argv";

/**
* Build the shell command string used to launch an agent without a prompt
* (e.g. when triggered from a v2 terminal preset). Includes always-on `args`
* but omits `promptArgs` and `promptTransport` — those only apply when a
* prompt is being delivered. Mirrors the launch resolution documented in
* `packages/shared/src/host-agent-presets.ts`.
*/
export function buildAgentLaunchCommand(agent: {
command: string;
args: string[];
}): string {
return joinCommandArgs(agent.command, agent.args);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { toast } from "@superset/ui/sonner";
import { useLiveQuery } from "@tanstack/react-db";
import { useCallback, useMemo } from "react";
import { useV2AgentConfigs } from "renderer/hooks/useV2AgentConfigs";
import { buildAgentLaunchCommand } from "renderer/lib/agent-launch-command";
import { useWorkspace } from "renderer/routes/_authenticated/_dashboard/v2-workspace/providers/WorkspaceProvider";
import { useCollections } from "renderer/routes/_authenticated/providers/CollectionsProvider";
import type { V2TerminalPresetRow } from "renderer/routes/_authenticated/providers/CollectionsProvider/dashboardSidebarLocal";
Expand Down Expand Up @@ -58,7 +59,7 @@ export function useV2PresetExecution({ store }: UseV2PresetExecutionArgs) {
for (const agent of agents) {
if (agent.command.trim().length === 0) continue;
if (map.has(agent.presetId)) continue;
map.set(agent.presetId, agent.command);
map.set(agent.presetId, buildAgentLaunchCommand(agent));
}
return map;
}, [agents]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import {
getPresetIcon,
useIsDarkTheme,
} from "renderer/assets/app-icons/preset-icons";
import { getHostServiceClientByUrl } from "renderer/lib/host-service-client";
import { useLocalHostService } from "renderer/routes/_authenticated/providers/LocalHostServiceProvider";
import {
joinArgs,
joinCommandArgs,
parseArgs,
parseCommandString,
} from "../../utils/argv";
} from "renderer/lib/argv";
import { getHostServiceClientByUrl } from "renderer/lib/host-service-client";
import { useLocalHostService } from "renderer/routes/_authenticated/providers/LocalHostServiceProvider";

interface AgentDetailProps {
config: HostAgentConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { Link } from "@tanstack/react-router";
import { ExternalLink, Trash2 } from "lucide-react";
import { useMemo } from "react";
import { HiExclamationTriangle, HiOutlineFolderOpen } from "react-icons/hi2";
import { buildAgentLaunchCommand } from "renderer/lib/agent-launch-command";
import { electronTrpc } from "renderer/lib/electron-trpc";
import type { PresetColumnKey } from "renderer/routes/_authenticated/settings/presets/types";
import { useSettingsOriginRoute } from "renderer/stores/settings-state";
Expand Down Expand Up @@ -194,7 +195,7 @@ export function PresetEditorDialog({
const linkedAgentId = (preset as PresetWithAgent | null)?.agentId;
const isLinked = !!linkedAgentId;
const liveCommands = linkedAgent
? [linkedAgent.command]
? [buildAgentLaunchCommand(linkedAgent)]
: (preset?.commands ?? []);
const selectDirectory = electronTrpc.window.selectDirectory.useMutation();
const originRoute = useSettingsOriginRoute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { HiOutlinePlus } from "react-icons/hi2";
import { useIsDarkTheme } from "renderer/assets/app-icons/preset-icons";
import { useV2AgentConfigs } from "renderer/hooks/useV2AgentConfigs";
import { buildAgentLaunchCommand } from "renderer/lib/agent-launch-command";
import { useMigrateV1PresetsToV2 } from "renderer/routes/_authenticated/hooks/useMigrateV1PresetsToV2";
import { useCollections } from "renderer/routes/_authenticated/providers/CollectionsProvider";
import type { V2TerminalPresetRow } from "renderer/routes/_authenticated/providers/CollectionsProvider/dashboardSidebarLocal";
Expand Down Expand Up @@ -203,7 +204,7 @@ export function V2PresetsSection({
label: agent.label,
description:
AGENT_PRESET_DESCRIPTIONS[agent.presetId as AgentType] ?? "",
commands: [agent.command],
commands: [buildAgentLaunchCommand(agent)],
});
}
return pills;
Expand Down
Loading