From a392ee1f6513b59fbff71f53c0753353aca5b9df Mon Sep 17 00:00:00 2001 From: kenny lopez Date: Thu, 23 Jul 2026 15:14:28 -0700 Subject: [PATCH] Preserve hidden harness defaults when editing Signed-off-by: kenny lopez --- .../agents/ui/AddTeamToChannelDialog.tsx | 4 +-- .../agents/ui/useManagedAgentActions.ts | 4 +-- .../features/agents/useGlobalAgentConfig.ts | 35 +++++++++++++------ .../src/features/onboarding/welcomeKickoff.ts | 5 +-- .../features/profile/ui/UserProfilePanel.tsx | 4 +-- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/desktop/src/features/agents/ui/AddTeamToChannelDialog.tsx b/desktop/src/features/agents/ui/AddTeamToChannelDialog.tsx index 62475819a..552373743 100644 --- a/desktop/src/features/agents/ui/AddTeamToChannelDialog.tsx +++ b/desktop/src/features/agents/ui/AddTeamToChannelDialog.tsx @@ -5,7 +5,7 @@ import { useAvailableAcpRuntimes, useCreateChannelManagedAgentsMutation, } from "@/features/agents/hooks"; -import { useGlobalAgentConfig } from "@/features/agents/useGlobalAgentConfig"; +import { useImplicitGlobalAgentConfig } from "@/features/agents/useGlobalAgentConfig"; import type { CreateChannelManagedAgentsResult } from "@/features/agents/channelAgents"; import { emptyResolvedTeamPersonas, @@ -54,7 +54,7 @@ export function AddTeamToChannelDialog({ onOpenChange, onDeployed, }: AddTeamToChannelDialogProps) { - const { globalConfig } = useGlobalAgentConfig(); + const { globalConfig } = useImplicitGlobalAgentConfig(); const channelsQuery = useChannelsQuery(); const providersQuery = useAvailableAcpRuntimes(); const [channelId, setChannelId] = React.useState(""); diff --git a/desktop/src/features/agents/ui/useManagedAgentActions.ts b/desktop/src/features/agents/ui/useManagedAgentActions.ts index e1c2e9c9f..214926d7c 100644 --- a/desktop/src/features/agents/ui/useManagedAgentActions.ts +++ b/desktop/src/features/agents/ui/useManagedAgentActions.ts @@ -12,7 +12,7 @@ import { useStopManagedAgentMutation, useDeleteManagedAgentMutation, } from "@/features/agents/hooks"; -import { useGlobalAgentConfig } from "@/features/agents/useGlobalAgentConfig"; +import { useImplicitGlobalAgentConfig } from "@/features/agents/useGlobalAgentConfig"; import { useChannelsQuery } from "@/features/channels/hooks"; import { usePresenceQuery } from "@/features/presence/hooks"; import type { @@ -37,7 +37,7 @@ import { } from "../lib/instanceInputForDefinition"; export function useManagedAgentActions() { - const { globalConfig } = useGlobalAgentConfig(); + const { globalConfig } = useImplicitGlobalAgentConfig(); const relayAgentsQuery = useRelayAgentsQuery(); const managedAgentsQuery = useManagedAgentsQuery(); const [shouldLoadChannels, setShouldLoadChannels] = React.useState(false); diff --git a/desktop/src/features/agents/useGlobalAgentConfig.ts b/desktop/src/features/agents/useGlobalAgentConfig.ts index 054bfb7c2..7b5e09191 100644 --- a/desktop/src/features/agents/useGlobalAgentConfig.ts +++ b/desktop/src/features/agents/useGlobalAgentConfig.ts @@ -33,7 +33,6 @@ export function useGlobalAgentConfig(): { globalConfig: GlobalAgentConfig; isLoading: boolean; } { - const disabledRuntimeIds = useDisabledAcpRuntimeIds(); const { data, isPending } = useQuery({ queryKey: globalAgentConfigQueryKey, queryFn: getGlobalAgentConfig, @@ -43,17 +42,33 @@ export function useGlobalAgentConfig(): { // Never show a stale empty flash while a background refetch runs. placeholderData: EMPTY_CONFIG, }); - const globalConfig = React.useMemo( - () => - maskDisabledAcpRuntimePreference( - data ?? EMPTY_CONFIG, - disabledRuntimeIds, - ), - [data, disabledRuntimeIds], - ); return { - globalConfig, + globalConfig: data ?? EMPTY_CONFIG, isLoading: isPending, }; } + +/** + * Load global defaults for a new implicit runtime choice. + * + * Existing agent edit surfaces must use useGlobalAgentConfig so a hidden + * harness can still inherit its persisted provider and model. Start paths use + * this hook to ignore a hidden preferred harness and its dependent defaults. + */ +export function useImplicitGlobalAgentConfig(): { + globalConfig: GlobalAgentConfig; + isLoading: boolean; +} { + const { globalConfig, isLoading } = useGlobalAgentConfig(); + const disabledRuntimeIds = useDisabledAcpRuntimeIds(); + const implicitGlobalConfig = React.useMemo( + () => maskDisabledAcpRuntimePreference(globalConfig, disabledRuntimeIds), + [disabledRuntimeIds, globalConfig], + ); + + return { + globalConfig: implicitGlobalConfig, + isLoading, + }; +} diff --git a/desktop/src/features/onboarding/welcomeKickoff.ts b/desktop/src/features/onboarding/welcomeKickoff.ts index 57352b529..93a552001 100644 --- a/desktop/src/features/onboarding/welcomeKickoff.ts +++ b/desktop/src/features/onboarding/welcomeKickoff.ts @@ -5,8 +5,8 @@ import { useAcpRuntimesQuery, useManagedAgentsQuery, } from "@/features/agents/hooks"; -import { useGlobalAgentConfig } from "@/features/agents/useGlobalAgentConfig"; import { clearActiveTurnsForAgentOnStop } from "@/features/agents/managedAgentRuntimeHooks"; +import { useImplicitGlobalAgentConfig } from "@/features/agents/useGlobalAgentConfig"; import { useCommunities } from "@/features/communities/useCommunities"; import { welcomeKickoffMarker } from "@/features/onboarding/devFreshOnboarding"; import { resolveAgentReadiness } from "@/features/onboarding/ui/agentReadiness"; @@ -496,7 +496,8 @@ export function useWelcomeKickoff( const { activeCommunity } = useCommunities(); const runtimesQuery = useAcpRuntimesQuery(); const managedAgentsQuery = useManagedAgentsQuery(); - const { globalConfig, isLoading: configLoading } = useGlobalAgentConfig(); + const { globalConfig, isLoading: configLoading } = + useImplicitGlobalAgentConfig(); const channelId = activeChannel?.id ?? null; const isActiveWelcome = isWelcomeChannel(activeChannel); const focusedWelcomeChannelRef = React.useRef(null); diff --git a/desktop/src/features/profile/ui/UserProfilePanel.tsx b/desktop/src/features/profile/ui/UserProfilePanel.tsx index c1f713d23..4dfdaaafc 100644 --- a/desktop/src/features/profile/ui/UserProfilePanel.tsx +++ b/desktop/src/features/profile/ui/UserProfilePanel.tsx @@ -25,7 +25,7 @@ import { useUpdateManagedAgentMutation, useUpdatePersonaMutation, } from "@/features/agents/hooks"; -import { useGlobalAgentConfig } from "@/features/agents/useGlobalAgentConfig"; +import { useImplicitGlobalAgentConfig } from "@/features/agents/useGlobalAgentConfig"; import { AddAgentToChannelDialog } from "@/features/agents/ui/AddAgentToChannelDialog"; import { availableRuntimesForStart, @@ -122,7 +122,7 @@ export function UserProfilePanel({ widthPx, transparentChrome = false, }: UserProfilePanelProps) { - const { globalConfig } = useGlobalAgentConfig(); + const { globalConfig } = useImplicitGlobalAgentConfig(); const isOverlay = useIsThreadPanelOverlay(); const isSplitLayout = layout === "split"; useEscapeKey(onClose, isOverlay || isSinglePanelView);