fix(chat): show the picked Cursor model's own Fast, not the running one's

A Fast value Cursor reported belongs to the model it ran, so a model pick
drops it on the client and the host reads it only for that model. The
config-folder test no longer depends on the runner's XDG_CONFIG_HOME.
This commit is contained in:
Kelvin Amoaba
2026-11-13 22:56:36 +00:00
parent 3ba49a337c
commit fb1b4ac29e
4 changed files with 40 additions and 2 deletions
@@ -1,5 +1,5 @@
import { join } from 'node:path'
import { afterEach, expect, it } from 'vitest'
import { afterEach, expect, it, onTestFinished, vi } from 'vitest'
import {
closeProviderTimelineRigs,
SESSION
@@ -317,6 +317,11 @@ it("drops Cursor's new-file markers from an edit's diff", () => {
})
it("pins Cursor's own config folder, following XDG_CONFIG_HOME as Cursor does", async () => {
vi.stubEnv('XDG_CONFIG_HOME', undefined)
vi.stubEnv('CURSOR_CONFIG_DIR', undefined)
onTestFinished(() => {
vi.unstubAllEnvs()
})
const stateDirectory = '/state'
expect(
await CURSOR.account.resolve({ launchEnv: { HOME: '/home/ada' }, stateDirectory })
@@ -167,7 +167,10 @@ export async function readStructuredAgentSessionOptions(
...options.current,
...(model !== undefined ? { model } : {}),
effort: saved.effort ?? options.current.effort,
fastMode: selected.current.fastMode ?? options.current.fastMode,
// A running model's Fast says nothing about another selected model, which keeps its own default.
fastMode:
selected.current.fastMode ??
(model === options.current.model ? options.current.fastMode : undefined),
// The saved tier as the shared speed rule runs it under the saved model.
...(context.deps.agents.definition(agent)?.restingOptions.acceptsKey('interactionMode')
? {
@@ -189,6 +189,31 @@ describe('a Claude chat on the model id an older host lists by alias', () => {
})
describe('what a send carries', () => {
it("shows the picked Cursor model's own Fast, not the running model's", () => {
const seed = structuredAgentSessionSeedCatalog('cursor')
const row = (id: string, defaultFastMode: boolean) => ({
id,
label: id,
isDefault: false,
efforts: [],
supportsFastMode: true,
defaultFastMode
})
const running = applyStructuredAgentSessionOptions(
createStructuredAgentSessionOptionState('cursor', seed),
seed,
{
models: [row('composer-2.5', true), row('claude-opus-4-8', false)],
fastModeSupport: { supported: true },
current: { model: 'composer-2.5', fastMode: true, confirmed: ['model', 'fastMode'] }
}
)
const picked = commitStructuredAgentSessionOption(running, 'model', 'claude-opus-4-8')
expect(
structuredAgentSessionOptionSnapshot(picked).find((option) => option.id === 'fastMode')?.kind
).toMatchObject({ type: 'boolean', currentValue: false })
})
it("shows and keeps a Cursor model's own Fast default until the person picks Fast", () => {
const seed = structuredAgentSessionSeedCatalog('cursor')
const composer = {
@@ -263,6 +263,11 @@ export function commitStructuredAgentSessionOption(
}
// Keep other picks after a model change; the host reconciles independent values.
state.record.values[id] = { value: decoded, source: 'dispatched' }
// A reported Fast was the old model's; the new one runs its own default until picked.
const staleFast = id === 'model' && state.record.values.fastMode?.source === 'reported'
if (staleFast && !unpickedFastModeIsOff(state.record.agent)) {
delete state.record.values.fastMode
}
return {
...state,
acceptedInputSources: