The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): bot-workspace tiles drop the whole ambient composer selection; live Electron proof
teknium189f277020cb1
diff --git a/apps/desktop/e2e/bot-tile-ignores-ambient-composer-model.spec.ts b/apps/desktop/e2e/bot-tile-ignores-ambient-composer-model.spec.tsnew file mode 100644index 00000000000..5f1a95fc896--- /dev/null+++ b/apps/desktop/e2e/bot-tile-ignores-ambient-composer-model.spec.ts@@ -0,0 +1,169 @@+import fs from 'node:fs'+import path from 'node:path'++import {+ buildAppEnv,+ createSandbox,+ launchDesktop,+ type MockBackendFixture,+ waitForAppReady,+ writeEnvFile,+ writeMockProviderConfig+} from './fixtures'+import { MOCK_REPLY, startMockServer } from '../../../tests-js/scripts/mock-server'+import { RealSessionBuilder } from './real-session-builder'+import { expect, test } from './test'++// A manual model pick in the composer is sticky for ordinary new chats. A `+`+// chat opened beside a bot in Bot Mode targets that bot's profile without+// switching the window's ambient composer, so a pick made for some other open+// session must NOT ride into the bot's session.create: the bot profile's+// configured default model is what the new chat's inference request carries+// (#95264).++type Page = MockBackendFixture['page']++const AMBIENT_PICK = 'ambient-pick-model'++let fixture: MockBackendFixture | null = null++async function openBots(page: Page): Promise<void> {+ const tab = page+ .getByRole('button', { name: 'Bots', exact: true })+ .or(page.getByRole('tab', { name: 'Bots', exact: true }))+ .first()++ await tab.click()+ await expect(page.getByRole('button', { name: 'New bot or group chat' })).toBeVisible()+}++async function settle(page: Page, timeout = 90_000): Promise<void> {+ await page+ .getByText(/Waking up/i)+ .first()+ .waitFor({ state: 'hidden', timeout })+ .catch(() => undefined)+ await page.waitForTimeout(500)+}++async function openUntil(action: () => Promise<void>, expected: () => Promise<void>, attempts = 3): Promise<void> {+ for (let attempt = 1; ; attempt += 1) {+ await action()++ try {+ await expected()++ return+ } catch (error) {+ if (attempt >= attempts) {+ throw error+ }+ }+ }+}++async function seedBot(hermesHome: string, mockUrl: string, name: string): Promise<void> {+ const dir = path.join(hermesHome, 'profiles', name)+ fs.mkdirSync(dir, { recursive: true })+ writeMockProviderConfig(dir, mockUrl)+ writeEnvFile(dir)++ const builder = await RealSessionBuilder.start(dir)++ try {+ await builder.createSession({ title: 'Bot Chat', turns: [`Hello ${name}`] })+ } finally {+ await builder.close()+ }+}++test.beforeAll(async () => {+ const mock = await startMockServer({ extraModels: [AMBIENT_PICK] })+ const sandbox = createSandbox('bot-tile-model')+ writeMockProviderConfig(sandbox.hermesHome, mock.url)+ writeEnvFile(sandbox.hermesHome)+ await seedBot(sandbox.hermesHome, mock.url, 'alpha')++ const { app, page } = await launchDesktop(buildAppEnv(sandbox))++ fixture = {+ app,+ page,+ mock,+ mockUrl: mock.url,+ sandbox,+ cleanup: async () => {+ await app.close().catch(() => undefined)+ await mock.close()+ sandbox.cleanup()+ }+ }+ await waitForAppReady(fixture, 120_000)+})++test.afterAll(async () => {+ await fixture?.cleanup()+ fixture = null+})++test("a bot's `+` chat runs on the bot profile's model, not the ambient composer pick", async ({}, testInfo) => {+ test.setTimeout(300_000)+ const page = fixture!.page+ const mock = fixture!.mock++ await openBots(page)++ const alphaRow = page+ .getByRole('button', { name: /^alpha\b/i })+ .filter({ visible: true })+ .first()+ await expect(alphaRow).toBeVisible({ timeout: 30_000 })+ await openUntil(+ () => alphaRow.click(),+ () =>+ expect(page.getByText('Hello alpha', { exact: true }).filter({ visible: true }).first()).toBeVisible({+ timeout: 45_000+ })+ )++ await settle(page, 15_000)++ // A manual pick while the bot's canonical chat is open: the window's ambient+ // composer now holds a model that is NOT the profile default. Rows are+ // hover-submenu triggers (reasoning/fast edit); Enter on the row commits.+ await page+ .getByRole('button', { name: /^Model ·/ })+ .first()+ .click()+ await page.getByRole('textbox', { name: 'Search models' }).fill('ambient pick')+ const row = page.getByRole('menuitem', { name: /^Ambient Pick Model/ }).first()+ await expect(row).toBeVisible()+ await row.focus()+ await page.keyboard.press('Enter')+ await expect(page.getByRole('button', { name: /^Model ·/ }).first()).toHaveAccessibleName(new RegExp(AMBIENT_PICK), {+ timeout: 15_000+ })+ await page.screenshot({ path: testInfo.outputPath('bot-chat-manual-pick.png') })++ // `+` beside the bot: a fresh bots-workspace tile for alpha.+ const before = mock.receivedModels.length+ await page.keyboard.press('Control+t')+ await settle(page)+ const composer = page+ .locator('[data-slot="composer-root"] [contenteditable="true"]')+ .filter({ visible: true })+ .first()+ await expect(composer).toBeVisible({ timeout: 15_000 })+ await composer.click()+ await composer.fill('hello alpha thread')+ await page.keyboard.press('Enter')+ await expect(page.getByText(MOCK_REPLY).filter({ visible: true }).first()).toBeVisible({ timeout: 60_000 })+ await page.screenshot({ path: testInfo.outputPath('bot-tile-after-turn.png') })++ await expect.poll(() => mock.receivedModels.length, { timeout: 15_000 }).toBeGreaterThan(before)+ const models = mock.receivedModels.slice(before)+ // The bot profile's configured default (config.yaml `model.default`), never+ // the window's manual composer pick.+ expect(models).not.toContain(AMBIENT_PICK)+ expect(models).toContain('mock-model')+})diff --git a/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx b/apps/desktop/src/app/session/hooks/use-session-actions.test.tsxindex deab6cc9c1b..8036fedfb7e 100644--- a/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx+++ b/apps/desktop/src/app/session/hooks/use-session-actions.test.tsx@@ -4538,10 +4538,12 @@ describe('openNewSessionTile workspace target', () => {expect(createParams).not.toHaveProperty('cwd')})- it('omits the manual ambient composer model from a Bot-workspace tile so the bot profile default applies', async () => {+ it('omits the manual ambient composer selection from a Bot-workspace tile so the bot profile defaults apply', async () => {setCurrentModel('ambient-model')setCurrentProvider('ambient-provider')setCurrentModelSource('manual')+ setCurrentReasoningEffort('high')+ setCurrentFastMode(true)let createParams: Record<string, unknown> | undefined@@ -4576,11 +4578,20 @@ describe('openNewSessionTile workspace target', () => {})} finally {setCurrentModelSource('')+ setCurrentModel('')+ setCurrentProvider('')+ setCurrentReasoningEffort('')+ setCurrentFastMode(false)+ // The hoisted agent-route mock keeps its call log across tests (restoreAllMocks only+ // restores spies); the next test asserts it was never called.+ vi.mocked(requestGatewayForAgent).mockReset()}expect(createParams).toMatchObject({ hidden: true, profile: 'writer' })expect(createParams).not.toHaveProperty('model')expect(createParams).not.toHaveProperty('provider')+ expect(createParams).not.toHaveProperty('reasoning_effort')+ expect(createParams).not.toHaveProperty('fast')})it('keeps an unlisted named local legacy-profile tile owned by its bare profile', async () => {diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/index.ts b/apps/desktop/src/app/session/hooks/use-session-actions/index.tsindex 8ac03353895..a67815115e8 100644--- a/apps/desktop/src/app/session/hooks/use-session-actions/index.ts+++ b/apps/desktop/src/app/session/hooks/use-session-actions/index.ts@@ -297,7 +297,7 @@ async function desktopSessionCreateParams(capturedRoute = resolveNewChatOwnerRoute(),requestedProfile?: string,legacyProfileIntent = false,- includeComposerModel = true+ includeComposerSelection = true): Promise<Record<string, unknown>> {// Treat Send as the linearization point for the visible selector state. The// profile handshake below can yield long enough for background config/model@@ -332,11 +332,15 @@ async function desktopSessionCreateParams(source: 'desktop',...(cwd && { cwd }),...(profile ? { profile: capturedRoute?.targetProfile || profile } : {}),- ...(includeComposerModel && selection.model- ? { model: selection.model, ...(selection.provider ? { provider: selection.provider } : {}) }- : {}),- ...(selection.effort ? { reasoning_effort: selection.effort } : {}),- fast: selection.fast+ ...(includeComposerSelection+ ? {+ ...(selection.model+ ? { model: selection.model, ...(selection.provider ? { provider: selection.provider } : {}) }+ : {}),+ ...(selection.effort ? { reasoning_effort: selection.effort } : {}),+ fast: selection.fast+ }+ : {})}}@@ -844,9 +848,10 @@ export function useSessionActions({// Bot-workspace tabs target an agent profile without switching the// window's ambient composer. Do not leak that unrelated session's- // manual model/provider into the bot's chat; omitting both lets the- // selected profile supply its configured default. Ordinary Sessions- // tiles keep the sticky composer override.+ // composer selection (manual model/provider, reasoning effort, fast+ // flag) into the bot's chat; omitting them lets the selected profile+ // supply its configured defaults. Ordinary Sessions tiles keep the+ // sticky composer override.const params = {...(await desktopSessionCreateParams(cwd,diff --git a/tests-js/scripts/mock-server.ts b/tests-js/scripts/mock-server.tsindex cf9b34e8797..c02d71a3b7b 100644--- a/tests-js/scripts/mock-server.ts+++ b/tests-js/scripts/mock-server.ts@@ -34,6 +34,9 @@ export interface MockServerOptions {/** Choose distinct replies from the latest input without replaying history. */replyForPrompt?: (prompt: string) => string+ /** Extra ids listed by GET /v1/models beside `mock-model` (a pickable second model). */+ extraModels?: string[]+/** Pause the matching stream after its first token for session-switch E2E coverage. */holdFirstStreamForPrompt?: string/** Pause the first completion whose request JSON contains this text. */@@ -54,6 +57,8 @@ export interface MockServer {port: numberurl: stringreceivedPrompts: string[]+ /** The `model` field of every chat completion request, in arrival order. */+ receivedModels: string[]waitForHeldStream: () => Promise<void>waitForHeldCompletion: () => Promise<void>releaseHeldStream: () => void@@ -437,6 +442,7 @@ function includesBlockingClarifyTrigger(value: unknown): boolean {export function startMockServer(options: MockServerOptions = {}): Promise<MockServer> {return new Promise((resolve, reject) => {const receivedPrompts: string[] = []+ const receivedModels: string[] = []let resolveHeldStreamStarted: (() => void) | null = nulllet releaseHeldStream: (() => void) | null = nulllet heldCompletionCount = 0@@ -469,14 +475,12 @@ export function startMockServer(options: MockServerOptions = {}): Promise<MockSeres.end(JSON.stringify({object: 'list',- data: [- {- id: 'mock-model',- object: 'model',- created: 0,- owned_by: 'mock',- },- ],+ data: ['mock-model', ...(options.extraModels ?? [])].map(id => ({+ id,+ object: 'model',+ created: 0,+ owned_by: 'mock',+ })),}),)@@ -510,6 +514,7 @@ export function startMockServer(options: MockServerOptions = {}): Promise<MockSeconst stream = parsed.stream === trueconst model = parsed.model || 'mock-model'+ receivedModels.push(model)const holdThisCompletion = Boolean(options.holdFirstCompletionContaining &&@@ -754,6 +759,7 @@ export function startMockServer(options: MockServerOptions = {}): Promise<MockSeport,url,receivedPrompts,+ receivedModels,waitForHeldStream: () => heldStreamStarted,waitForHeldCompletion: () => heldStreamStarted,releaseHeldStream: () => releaseHeldStream?.(),