Files
hapi/web/src/lib/cursorPickerUiSim.test.ts
T
3a8693f380 feat(cursor): migrate remote sessions to ACP with model/variant pickers (#799)
* feat(cli,web,hub): migrate Cursor remote sessions to ACP with model/effort pickers

Move stream-json remote launcher to legacy path and add ACP launcher with
set_config_option model/mode sync, optimistic keepalive on config changes, and
shared catalog caching. Web gets dual base/effort Cursor pickers for session and
new-session flows; hide composer status bar when Cursor sends no usage_update.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(cli,web,shared): Cursor model picker — ACP wires + CLI sku variants

Enrich the web/mobile picker with agent --list-models SKUs grouped under
ACP wire bases, fix session-open base highlight, and keep catalog discovery
safe while the ACP transport holds the CLI lock.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(cursor-acp): apply ACP default model when web resets to Default

Web sends model: null for Default; push session/set_config_option with the
ACP default[] wire so Cursor backend matches hub state. Regression tests
for setModel(null) and applyModelConfig(null).

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(acp): clear stale agent-acp lock when owning process is gone

Check lock pid with signal 0; remove orphaned lock dirs after SIGKILL or
crash so listCursorModels can run cold probes again. Regression tests for
guard and catalog discovery.

Co-authored-by: Cursor <cursoragent@cursor.com>

* test(cursor): use live pid for ACP lock handler tests

Stale-lock cleanup clears dead pids; handler tests must simulate an
active lock with the current process pid to avoid cold probes/timeouts.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(acp): scope agent CLI lock guard to Cursor agent command only

Gemini/OpenCode/Kimi ACP sessions must not register agent-acp-active;
that blocked listCursorModels while unrelated backends were running.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(hub,web): reject Cursor model changes for local sessions

Hub returns 409 when controlledByUser is set, matching Codex. Web hides
model and variant pickers for local Cursor sessions so users do not hit
a dead RPC path. Document pre-push-review in AGENTS.md.

Verified: bun typecheck; bun run test (919 cli + 243 hub + 768 web + 46 shared).
Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(web): send stable ids for Cursor ask_question replies

Parse and submit question.id and option.id so ACP receives keys like
{ approach: ['a'] } instead of index/label. Verified: bun typecheck && bun run test.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-06 19:51:35 +08:00

92 lines
3.6 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { getModelOptionsForFlavor } from '@/components/AssistantChat/modelOptions'
import {
buildCursorCatalogFromSources,
buildCursorPickerState
} from '@/lib/cursorPickerState'
import {
resolveSessionCursorBaseSelectValue,
resolveSessionCursorModelChange
} from '@/lib/sessionChatCursorModel'
const liveModels = [
{ modelId: 'default[]', name: 'Auto' },
{ modelId: 'composer-2.5[fast=true]', name: 'composer-2.5' },
{ modelId: 'gpt-5.5[context=272k,reasoning=medium,fast=false]', name: 'gpt-5.5' },
{ modelId: 'claude-opus-4-8[thinking=true,context=300k,effort=high,fast=false]', name: 'claude-opus-4-8' }
] as const
describe('cursor picker UI simulation (no browser)', () => {
it('flat model list shows one row per ACP wire with variant suffix in the label', () => {
const wire = 'gpt-5.5[context=272k,reasoning=medium,fast=false]'
const picker = buildCursorPickerState({
catalog: buildCursorCatalogFromSources({ sessionModels: liveModels, defaultValue: null }),
currentWireId: wire,
defaultValue: null
})
expect(picker.mode).toBe('flat')
const rendered = getModelOptionsForFlavor('cursor', wire, picker.modelOptions)
expect(rendered).toHaveLength(4)
expect(rendered.some((row) => row.value === wire)).toBe(true)
expect(rendered.find((row) => row.value === wire)?.label).toContain('reasoning=medium')
})
it('clicking a base key in dual-style handler still resolves the sole wire for that base', () => {
const picker = buildCursorPickerState({
catalog: buildCursorCatalogFromSources({ sessionModels: liveModels, defaultValue: null }),
currentWireId: 'composer-2.5[fast=true]',
defaultValue: null
})
const plan = resolveSessionCursorModelChange({
picker,
sessionModel: 'composer-2.5[fast=true]',
cursorSelectedBase: 'composer-2.5',
kind: 'base',
value: 'gpt-5.5'
})
expect(plan).toEqual({
ok: true,
wireId: 'gpt-5.5[context=272k,reasoning=medium,fast=false]',
nextSelectedBase: 'gpt-5.5',
shouldApply: true
})
})
it('flat wire selection applies the exact wire id', () => {
const picker = buildCursorPickerState({
catalog: buildCursorCatalogFromSources({ sessionModels: liveModels, defaultValue: null }),
currentWireId: 'composer-2.5[fast=true]',
defaultValue: null
})
const plan = resolveSessionCursorModelChange({
picker,
sessionModel: 'composer-2.5[fast=true]',
cursorSelectedBase: 'auto',
kind: 'flat',
value: 'gpt-5.5[context=272k,reasoning=medium,fast=false]'
})
expect(plan).toMatchObject({
ok: true,
wireId: 'gpt-5.5[context=272k,reasoning=medium,fast=false]',
shouldApply: true
})
})
it('highlights session base in dual mode while local base state is still auto', () => {
const catalog = buildCursorCatalogFromSources({
sessionModels: [
...liveModels,
{ modelId: 'composer-2.5[fast=false]', name: 'composer-2.5' }
],
defaultValue: null
})
const picker = buildCursorPickerState({
catalog,
currentWireId: 'composer-2.5[fast=true]',
defaultValue: null
})
expect(picker.mode).toBe('dual')
expect(resolveSessionCursorBaseSelectValue(picker, 'auto')).toBe('composer-2.5')
})
})