From dba8c8f79c34239dd1d95f570ce0e74a58492675 Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi <17528887+harshithmullapudi@users.noreply.github.com> Date: Wed, 11 Nov 2026 15:30:43 +0000 Subject: [PATCH 1/2] fix(chat): start new-workspace chats on the picked reasoning effort The New Workspace picker sent the model with a chat launch but dropped the effort: the host treated a chat launch with an effort as a terminal launch, so the desktop stripped it to stay on chat. The chat then opened on Default. - host: chatLaunchTarget accepts and validates an effort, and createChatSession forwards it as effortId. sessions.create and the cloud sandbox chat launch carry it too. - shared: hostLaunchesChatWithEffort (2.0.9+) gates the field, because an older host would still open a terminal. - desktop: the new-workspace submit sends the effort for chat launches to a host that applies it (the bundled local host always does), and pending cloud chat panes keep it like they keep the model. --- .../v2-workspace/$workspaceId/types.ts | 1 + .../useSubmitWorkspace/useSubmitWorkspace.ts | 9 ++++- .../utils/launchEffort/index.ts | 1 + .../utils/launchEffort/launchEffort.test.ts | 40 +++++++++++++++++++ .../utils/launchEffort/launchEffort.ts | 7 ++++ .../NewWorkspaceScreen/NewWorkspaceScreen.tsx | 5 +++ .../pendingCloudChat/pendingCloudChat.ts | 4 ++ .../sandbox-self-seed/sandbox-self-seed.ts | 2 + .../src/trpc/router/agents/agents.test.ts | 24 +++++++++-- .../src/trpc/router/agents/agents.ts | 7 +++- .../router/sessions/create-chat-session.ts | 1 + .../trpc/router/sessions/session-service.ts | 3 ++ .../src/trpc/router/sessions/sessions.test.ts | 26 +++++++++++- packages/shared/src/host-version.test.ts | 12 ++++++ packages/shared/src/host-version.ts | 13 ++++++ 15 files changed, 149 insertions(+), 6 deletions(-) create mode 100644 apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/utils/launchEffort/index.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/utils/launchEffort/launchEffort.test.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/utils/launchEffort/launchEffort.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/types.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/types.ts index 9d94cd09959..42c0d7c5dc4 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/types.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/types.ts @@ -99,6 +99,7 @@ export interface PendingCloudChatPaneData { launchPrompt?: string; queuedPrompts?: UserContent[][]; chatModelId?: string; + chatEffortId?: string; chatModeId?: string; } diff --git a/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/useSubmitWorkspace.ts b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/useSubmitWorkspace.ts index 46f16a22d12..c0496148dc1 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/useSubmitWorkspace.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/useSubmitWorkspace.ts @@ -24,6 +24,7 @@ import { useDashboardNewWorkspaceDraft } from "../../../../../DashboardNewWorksp import type { WorkspaceCreateAgent } from "../../types"; import type { UseUploadAttachmentsApi } from "../useUploadAttachments"; import { resolveNames } from "./resolveNames"; +import { launchEffort } from "./utils/launchEffort"; /** * Submits a workspace create against the new `workspaces.create` host @@ -44,6 +45,7 @@ export function useSubmitWorkspace( cloudMachineSize: MachineSize | null = null, hostId: string | null = null, isSession = false, + hostLaunchesChatWithEffort = false, ) { const { t } = useLingui(); const navigate = useNavigate(); @@ -204,6 +206,7 @@ export function useSubmitWorkspace( launch: initialLaunch, prompt: prompt.trim(), modelId: selectedModel, + effortId: selectedEffort, modeId: selectedMode, }); } @@ -291,7 +294,10 @@ export function useSubmitWorkspace( prompt: finalPrompt ?? "", attachmentIds: attachmentIds.length > 0 ? attachmentIds : undefined, model: selectedModel ?? undefined, - effort: openAsChat ? undefined : (selectedEffort ?? undefined), + effort: launchEffort(selectedEffort, { + openAsChat, + hostLaunchesChatWithEffort, + }), mode: selectedMode ?? undefined, ...(openAsChat ? { surface: "chat" as const } : {}), }, @@ -421,6 +427,7 @@ export function useSubmitWorkspace( utils, cloudEnvironmentId, cloudMachineSize, + hostLaunchesChatWithEffort, ]); const submitWorkspace = useCallback(async () => { diff --git a/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/utils/launchEffort/index.ts b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/utils/launchEffort/index.ts new file mode 100644 index 00000000000..1058c7ef884 --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/utils/launchEffort/index.ts @@ -0,0 +1 @@ +export { launchEffort } from "./launchEffort"; diff --git a/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/utils/launchEffort/launchEffort.test.ts b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/utils/launchEffort/launchEffort.test.ts new file mode 100644 index 00000000000..ccac13062ef --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/utils/launchEffort/launchEffort.test.ts @@ -0,0 +1,40 @@ +import { describe, expect, test } from "bun:test"; +import { launchEffort } from "./launchEffort"; + +describe("launchEffort", () => { + test("a chat launch carries the picked effort to a host that applies it", () => { + expect( + launchEffort("high", { + openAsChat: true, + hostLaunchesChatWithEffort: true, + }), + ).toBe("high"); + }); + + test("a chat launch drops the effort for an older host, which would open a terminal", () => { + expect( + launchEffort("high", { + openAsChat: true, + hostLaunchesChatWithEffort: false, + }), + ).toBeUndefined(); + }); + + test("a terminal launch always carries the effort", () => { + expect( + launchEffort("max", { + openAsChat: false, + hostLaunchesChatWithEffort: false, + }), + ).toBe("max"); + }); + + test("no pick sends no effort", () => { + expect( + launchEffort(null, { + openAsChat: true, + hostLaunchesChatWithEffort: true, + }), + ).toBeUndefined(); + }); +}); diff --git a/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/utils/launchEffort/launchEffort.ts b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/utils/launchEffort/launchEffort.ts new file mode 100644 index 00000000000..b510317e847 --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/utils/launchEffort/launchEffort.ts @@ -0,0 +1,7 @@ +export function launchEffort( + selectedEffort: string | null, + launch: { openAsChat: boolean; hostLaunchesChatWithEffort: boolean }, +): string | undefined { + if (launch.openAsChat && !launch.hostLaunchesChatWithEffort) return undefined; + return selectedEffort ?? undefined; +} diff --git a/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/NewWorkspaceScreen.tsx b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/NewWorkspaceScreen.tsx index 84d67406978..5f6493db0a1 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/NewWorkspaceScreen.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/NewWorkspaceScreen.tsx @@ -12,6 +12,7 @@ import type { MachineSize } from "@superset/shared/billing"; import { startableCloudEnvironments } from "@superset/shared/cloud-environments"; import { FEATURE_FLAGS } from "@superset/shared/constants"; import { CLOUD_HOST_ID } from "@superset/shared/host-routing"; +import { hostLaunchesChatWithEffort } from "@superset/shared/host-version"; import { Button } from "@superset/ui/button"; import { isEnterSubmit } from "@superset/ui/lib/keyboard"; import { toast } from "@superset/ui/sonner"; @@ -770,6 +771,10 @@ export function NewWorkspaceScreen({ isCloudHost ? cloudSelection.machineSize : null, hostId, isSession, + hostId === machineId || + hostLaunchesChatWithEffort( + otherHosts.find((host) => host.id === hostId)?.version, + ), ); const submitBlocker = useMemo(() => { diff --git a/apps/desktop/src/renderer/stores/workspace-creates/pendingCloudChat/pendingCloudChat.ts b/apps/desktop/src/renderer/stores/workspace-creates/pendingCloudChat/pendingCloudChat.ts index bcbd674232b..bf4fe2b5605 100644 --- a/apps/desktop/src/renderer/stores/workspace-creates/pendingCloudChat/pendingCloudChat.ts +++ b/apps/desktop/src/renderer/stores/workspace-creates/pendingCloudChat/pendingCloudChat.ts @@ -34,6 +34,7 @@ export function seedPendingCloudChat({ launch, prompt, modelId, + effortId, modeId, }: { collections: AppCollections; @@ -41,6 +42,7 @@ export function seedPendingCloudChat({ launch: CloudAgentLaunchDescriptor | null | undefined; prompt?: string; modelId?: string | null; + effortId?: string | null; modeId?: string | null; }): void { if (launch?.surface !== "chat" || !launch.terminalId) return; @@ -70,6 +72,7 @@ export function seedPendingCloudChat({ terminalId: launch.terminalId, ...(prompt ? { launchPrompt: prompt } : {}), ...(modelId ? { chatModelId: modelId } : {}), + ...(effortId ? { chatEffortId: effortId } : {}), ...(modeId ? { chatModeId: modeId } : {}), } satisfies PendingCloudChatPaneData, }, @@ -112,6 +115,7 @@ function carriedOver(data: PendingCloudChatPaneData) { draftId: data.draftId, ...(data.queuedPrompts ? { queuedPrompts: data.queuedPrompts } : {}), ...(data.chatModelId ? { chatModelId: data.chatModelId } : {}), + ...(data.chatEffortId ? { chatEffortId: data.chatEffortId } : {}), ...(data.chatModeId ? { chatModeId: data.chatModeId } : {}), }; } diff --git a/packages/host-service/src/runtime/sandbox-self-seed/sandbox-self-seed.ts b/packages/host-service/src/runtime/sandbox-self-seed/sandbox-self-seed.ts index 6b217c2ad7e..39e747583e4 100644 --- a/packages/host-service/src/runtime/sandbox-self-seed/sandbox-self-seed.ts +++ b/packages/host-service/src/runtime/sandbox-self-seed/sandbox-self-seed.ts @@ -374,6 +374,7 @@ export async function launchSandboxAgentOnce( agent, prompt, model, + effort, attachmentIds, surface: "chat", }) @@ -388,6 +389,7 @@ export async function launchSandboxAgentOnce( agent, prompt, model, + effort, mode, ...(attachmentIds?.length ? { attachmentIds } : {}), }, diff --git a/packages/host-service/src/trpc/router/agents/agents.test.ts b/packages/host-service/src/trpc/router/agents/agents.test.ts index 4a46ded1116..64031ad1a7b 100644 --- a/packages/host-service/src/trpc/router/agents/agents.test.ts +++ b/packages/host-service/src/trpc/router/agents/agents.test.ts @@ -1184,9 +1184,27 @@ describe("continuationTarget", () => { attachments: [], }); expect(chatLaunchTarget(db, launch)).toBeNull(); - expect( - chatLaunchTarget(db, { ...launch, surface: "chat", effort: "high" }), - ).toBeNull(); + }); + + it("keeps a chat launch a chat when it asks for an effort", () => { + const db = createTestDb(); + seedClaude(db); + const launch = { + workspaceId, + agent: "claude", + prompt: "go", + surface: "chat" as const, + }; + + expect(chatLaunchTarget(db, { ...launch, effort: "high" })).toEqual({ + harness: "claude-acp", + label: "Claude", + agentConfigId: "00000000-0000-0000-0000-00000000000a", + attachments: [], + }); + expect(() => + chatLaunchTarget(db, { ...launch, effort: "ludicrous" }), + ).toThrow(TRPCError); }); it("chats as a custom agent that runs the claude or codex CLI", () => { diff --git a/packages/host-service/src/trpc/router/agents/agents.ts b/packages/host-service/src/trpc/router/agents/agents.ts index 713bf39fa48..1f119b5fb77 100644 --- a/packages/host-service/src/trpc/router/agents/agents.ts +++ b/packages/host-service/src/trpc/router/agents/agents.ts @@ -673,7 +673,6 @@ export function chatLaunchTarget( } | null { if ( input.surface !== "chat" || - input.effort || input.resumeSessionId || input.forkSessionId ) { @@ -697,6 +696,12 @@ export function chatLaunchTarget( const harness = acpHarnessForPreset(launchPresetId); if (!harness) return null; validateAgentModelSelection(launchPresetId, config.label, input.model); + validateAgentEffortSelection( + launchPresetId, + config.label, + input.effort, + input.model, + ); validateAgentModeSelection(launchPresetId, config.label, input.mode, "chat"); return { harness, diff --git a/packages/host-service/src/trpc/router/sessions/create-chat-session.ts b/packages/host-service/src/trpc/router/sessions/create-chat-session.ts index d485bf981d6..601fd827e12 100644 --- a/packages/host-service/src/trpc/router/sessions/create-chat-session.ts +++ b/packages/host-service/src/trpc/router/sessions/create-chat-session.ts @@ -31,6 +31,7 @@ export function createChatSession( : {}), terminalId, ...(input.model ? { modelId: input.model } : {}), + ...(input.effort ? { effortId: input.effort } : {}), ...(input.mode ? { modeId: input.mode } : {}), ...(input.resumeSessionId ? { resume: { harnessSessionId: input.resumeSessionId } } diff --git a/packages/host-service/src/trpc/router/sessions/session-service.ts b/packages/host-service/src/trpc/router/sessions/session-service.ts index 08c789a8cfd..6d9aa706884 100644 --- a/packages/host-service/src/trpc/router/sessions/session-service.ts +++ b/packages/host-service/src/trpc/router/sessions/session-service.ts @@ -17,6 +17,7 @@ export const createChatSessionSchema = z agent: z.string().min(1), prompt: z.string().default(""), model: z.string().min(1).optional(), + effort: z.string().min(1).optional(), mode: z.string().min(1).optional(), resumeSessionId: z.string().min(1).optional(), continueSessionId: z.string().min(1).optional(), @@ -105,6 +106,7 @@ export async function createChatSessionInWorkspace( prompt: input.prompt, surface: "chat", model: input.model, + effort: input.effort, attachmentIds: input.attachmentIds, }); const target = @@ -126,6 +128,7 @@ export async function createChatSessionInWorkspace( if ( input.continueSessionId && !input.model && + !input.effort && !input.mode && !input.attachmentIds?.length ) { diff --git a/packages/host-service/src/trpc/router/sessions/sessions.test.ts b/packages/host-service/src/trpc/router/sessions/sessions.test.ts index 98496cbc6d0..b69468083a0 100644 --- a/packages/host-service/src/trpc/router/sessions/sessions.test.ts +++ b/packages/host-service/src/trpc/router/sessions/sessions.test.ts @@ -5,6 +5,7 @@ import { type ChatRuntime, FakeHarness, type HarnessFactoryOptions, + type HarnessStartOptions, } from "@superset/chat-runtime"; import { createTestRuntime, waitFor } from "@superset/chat-runtime/testing"; import { eq } from "drizzle-orm"; @@ -23,12 +24,14 @@ let runtime: ChatRuntime; let db: HostDb; let startDead: boolean; let launches: HarnessFactoryOptions[]; +let starts: HarnessStartOptions[]; let caller: ReturnType; let ctx: HostServiceContext; beforeEach(() => { startDead = false; launches = []; + starts = []; const sqlite = new Database(":memory:"); db = drizzle(sqlite, { schema }) as unknown as HostDb; migrate(db as never, { @@ -77,7 +80,7 @@ beforeEach(() => { "claude-acp", (options: HarnessFactoryOptions) => { launches.push(options); - return new FakeHarness({ + const harness = new FakeHarness({ start: [ { kind: "session", @@ -91,6 +94,12 @@ beforeEach(() => { ], turns: [[], []], }); + const start = harness.start.bind(harness); + harness.start = (startOptions) => { + starts.push(startOptions); + return start(startOptions); + }; + return harness; }, ], ]), @@ -207,6 +216,21 @@ describe("sessions router", () => { ).toHaveLength(1); }); + test("starts the chat on the model and effort the launch picked", async () => { + await createChatSessionInWorkspace(ctx, { + workspaceId: WORKSPACE, + agent: "claude", + prompt: "go", + model: "claude-opus-5-5", + effort: "high", + }); + await waitFor(() => starts.length === 1); + expect(starts[0]).toMatchObject({ + modelId: "claude-opus-5-5", + effortId: "high", + }); + }); + test("launches under the terminal id a cloud launch was promised", async () => { const terminalId = crypto.randomUUID(); const created = await createChatSessionInWorkspace( diff --git a/packages/shared/src/host-version.test.ts b/packages/shared/src/host-version.test.ts index 636ce6669ca..1d73e19f035 100644 --- a/packages/shared/src/host-version.test.ts +++ b/packages/shared/src/host-version.test.ts @@ -1,8 +1,10 @@ import { describe, expect, test } from "bun:test"; import { ATTACHMENT_PARTS_MIN_HOST_VERSION } from "./attachment-limits"; import { + CHAT_LAUNCH_EFFORT_MIN_HOST_VERSION, CHAT_SELECTIONS_MIN_HOST_VERSION, deriveHostVersionState, + hostLaunchesChatWithEffort, hostNeedsUpdate, hostReadsAttachmentParts, hostRemembersChatSelections, @@ -106,3 +108,13 @@ describe("hostRemembersChatSelections", () => { expect(hostRemembersChatSelections(undefined)).toBe(false); }); }); + +describe("hostLaunchesChatWithEffort", () => { + test("a host at or above the floor starts a chat on its effort; an older or unknown one does not", () => { + expect( + hostLaunchesChatWithEffort(CHAT_LAUNCH_EFFORT_MIN_HOST_VERSION), + ).toBe(true); + expect(hostLaunchesChatWithEffort("2.0.8")).toBe(false); + expect(hostLaunchesChatWithEffort(null)).toBe(false); + }); +}); diff --git a/packages/shared/src/host-version.ts b/packages/shared/src/host-version.ts index 33cb72913d0..e5164fb5b76 100644 --- a/packages/shared/src/host-version.ts +++ b/packages/shared/src/host-version.ts @@ -121,6 +121,19 @@ export function hostReadsAttachmentParts( ); } +/** The first host that starts a chat on the effort a launch asks for. Older hosts open a terminal instead. */ +export const CHAT_LAUNCH_EFFORT_MIN_HOST_VERSION = "2.0.9"; + +/** Whether a chat launch can carry an effort without the host falling back to a terminal. */ +export function hostLaunchesChatWithEffort( + hostVersion: string | null | undefined, +): boolean { + const version = semver.coerce(hostVersion ?? ""); + return ( + version !== null && semver.gte(version, CHAT_LAUNCH_EFFORT_MIN_HOST_VERSION) + ); +} + /** The first host that remembers the model, effort and mode a user picks in a chat. */ export const CHAT_SELECTIONS_MIN_HOST_VERSION = "2.0.6"; From 90ede9970356e6da86f6ffbc7818dcaa53505825 Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi <17528887+harshithmullapudi@users.noreply.github.com> Date: Wed, 11 Nov 2026 15:49:41 +0000 Subject: [PATCH 2/2] fix(desktop): check the live host version before sending chat effort The desktop can adopt a local host-service started by another app instance, and that host may predate chat effort. Ask the host which version it runs (useHostServiceInfo) for local and remote hosts alike: a host on this app's own build applies the effort, and any other host must meet the 2.0.9 floor. --- .../NewWorkspaceScreen/NewWorkspaceScreen.tsx | 11 +++++---- .../hostAppliesChatEffort.test.ts | 23 +++++++++++++++++++ .../hostAppliesChatEffort.ts | 17 ++++++++++++++ .../utils/hostAppliesChatEffort/index.ts | 1 + 4 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/utils/hostAppliesChatEffort/hostAppliesChatEffort.test.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/utils/hostAppliesChatEffort/hostAppliesChatEffort.ts create mode 100644 apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/utils/hostAppliesChatEffort/index.ts diff --git a/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/NewWorkspaceScreen.tsx b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/NewWorkspaceScreen.tsx index 5f6493db0a1..d081ad0a80b 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/NewWorkspaceScreen.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/NewWorkspaceScreen.tsx @@ -12,7 +12,6 @@ import type { MachineSize } from "@superset/shared/billing"; import { startableCloudEnvironments } from "@superset/shared/cloud-environments"; import { FEATURE_FLAGS } from "@superset/shared/constants"; import { CLOUD_HOST_ID } from "@superset/shared/host-routing"; -import { hostLaunchesChatWithEffort } from "@superset/shared/host-version"; import { Button } from "@superset/ui/button"; import { isEnterSubmit } from "@superset/ui/lib/keyboard"; import { toast } from "@superset/ui/sonner"; @@ -26,7 +25,9 @@ import { LuGitPullRequest } from "react-icons/lu"; import type { AgentSelectAgent } from "renderer/components/AgentSelect"; import { GitHubStarPill } from "renderer/components/GitHubStarPill"; import { useHostProjects } from "renderer/hooks/host-projects/useHostProjects"; +import { useHostServiceInfo } from "renderer/hooks/host-service/useHostServiceInfo"; import { resolveHostUrl } from "renderer/hooks/host-service/useHostTargetUrl"; +import { useAppVersion } from "renderer/hooks/host-version/useHostVersionState"; import { useAcpChatEnabled } from "renderer/hooks/useAcpChatEnabled"; import { useActiveOrganizationId } from "renderer/hooks/useActiveOrganizationId"; import { useAgentEffortPreference } from "renderer/hooks/useAgentEffortPreference"; @@ -93,6 +94,7 @@ import { useGitHubRepositoryProjects } from "./hooks/useGitHubRepositoryProjects import { useLinkedIssueNaming } from "./hooks/useLinkedIssueNaming"; import { useSamplePromptSelection } from "./hooks/useSamplePromptSelection"; import { useWorkspaceSettingMentionProviders } from "./hooks/useWorkspaceSettingMentionProviders"; +import { hostAppliesChatEffort } from "./utils/hostAppliesChatEffort"; import { AGENT_DEFAULT_OPTION_ID, LAUNCH_EFFORT_OPTION_ID, @@ -463,6 +465,8 @@ export function NewWorkspaceScreen({ }) ?? null ); }, [hostId, machineId, activeHostUrl, activeOrganizationId, relayUrl]); + const launchHostInfo = useHostServiceInfo(isCloudHost ? null : launchHostUrl); + const appVersion = useAppVersion(); const githubProviders = useGitHubMentionProviders( useMemo( () => @@ -771,10 +775,7 @@ export function NewWorkspaceScreen({ isCloudHost ? cloudSelection.machineSize : null, hostId, isSession, - hostId === machineId || - hostLaunchesChatWithEffort( - otherHosts.find((host) => host.id === hostId)?.version, - ), + hostAppliesChatEffort(launchHostInfo.data?.version, appVersion), ); const submitBlocker = useMemo(() => { diff --git a/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/utils/hostAppliesChatEffort/hostAppliesChatEffort.test.ts b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/utils/hostAppliesChatEffort/hostAppliesChatEffort.test.ts new file mode 100644 index 00000000000..a697c6ed70d --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/utils/hostAppliesChatEffort/hostAppliesChatEffort.test.ts @@ -0,0 +1,23 @@ +import { describe, expect, test } from "bun:test"; +import { CHAT_LAUNCH_EFFORT_MIN_HOST_VERSION } from "@superset/shared/host-version"; +import { hostAppliesChatEffort } from "./hostAppliesChatEffort"; + +describe("hostAppliesChatEffort", () => { + test("a host on this app's build applies it, even before the release that sets the floor", () => { + expect(hostAppliesChatEffort("2.0.8", "2.0.8")).toBe(true); + }); + + test("an older adopted host below the floor does not", () => { + expect(hostAppliesChatEffort("2.0.7", "2.0.9")).toBe(false); + }); + + test("a host at the floor does, whatever this app's version", () => { + expect( + hostAppliesChatEffort(CHAT_LAUNCH_EFFORT_MIN_HOST_VERSION, "2.1.0"), + ).toBe(true); + }); + + test("an unknown host version does not", () => { + expect(hostAppliesChatEffort(undefined, "2.0.9")).toBe(false); + }); +}); diff --git a/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/utils/hostAppliesChatEffort/hostAppliesChatEffort.ts b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/utils/hostAppliesChatEffort/hostAppliesChatEffort.ts new file mode 100644 index 00000000000..ae34f485427 --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/utils/hostAppliesChatEffort/hostAppliesChatEffort.ts @@ -0,0 +1,17 @@ +import { hostLaunchesChatWithEffort } from "@superset/shared/host-version"; +import semver from "semver"; + +/** + * Whether the host serving this launch starts a chat on its effort. A host on + * this app's own build always does, released or not; an older one, such as a + * local host adopted from another app instance, must meet the floor. + */ +export function hostAppliesChatEffort( + hostVersion: string | null | undefined, + appVersion: string, +): boolean { + const host = semver.coerce(hostVersion ?? ""); + const app = semver.coerce(appVersion); + if (host && app && semver.eq(host, app)) return true; + return hostLaunchesChatWithEffort(hostVersion); +} diff --git a/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/utils/hostAppliesChatEffort/index.ts b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/utils/hostAppliesChatEffort/index.ts new file mode 100644 index 00000000000..1f1f5ab428a --- /dev/null +++ b/apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/NewWorkspaceScreen/utils/hostAppliesChatEffort/index.ts @@ -0,0 +1 @@ +export { hostAppliesChatEffort } from "./hostAppliesChatEffort";