mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
* 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>
139 lines
5.6 KiB
TypeScript
139 lines
5.6 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
buildCursorCatalogFromSources,
|
|
buildCursorPickerState,
|
|
mergeCursorModelSummaries,
|
|
resolveWireIdForBaseChange
|
|
} from '@/lib/cursorPickerState'
|
|
|
|
describe('mergeCursorModelSummaries', () => {
|
|
it('keeps session wire rows first and ignores duplicate machine rows', () => {
|
|
const merged = mergeCursorModelSummaries(
|
|
[{ modelId: 'composer-2.5[fast=false]', name: 'Composer 2.5' }],
|
|
[
|
|
{ modelId: 'composer-2.5[fast=true]', name: 'Composer 2.5 Fast' },
|
|
{ modelId: 'composer-2.5[fast=false]', name: 'raw-id' }
|
|
]
|
|
)
|
|
expect(merged.map((entry) => entry.modelId)).toEqual([
|
|
'composer-2.5[fast=false]',
|
|
'composer-2.5[fast=true]',
|
|
])
|
|
const slow = merged.find((entry) => entry.modelId === 'composer-2.5[fast=false]')
|
|
expect(slow?.name).toBe('Composer 2.5')
|
|
})
|
|
|
|
it('injects current wire when missing from both lists', () => {
|
|
const merged = mergeCursorModelSummaries([], [], 'claude-opus-4-8[effort=high,fast=false]')
|
|
expect(merged).toEqual([
|
|
{ modelId: 'claude-opus-4-8[effort=high,fast=false]' }
|
|
])
|
|
})
|
|
|
|
it('drops CLI probe slugs without bracket wire params', () => {
|
|
const merged = mergeCursorModelSummaries(
|
|
[{ modelId: 'gpt-5.5[context=272k,reasoning=medium,fast=false]', name: 'gpt-5.5' }],
|
|
[
|
|
{ modelId: 'gpt-5.5-high-fast', name: 'GPT-5.5 High Fast' },
|
|
{ modelId: 'composer-2.5', name: 'Composer 2.5' }
|
|
]
|
|
)
|
|
expect(merged.map((entry) => entry.modelId)).toEqual([
|
|
'gpt-5.5[context=272k,reasoning=medium,fast=false]'
|
|
])
|
|
})
|
|
})
|
|
|
|
describe('buildCursorPickerState', () => {
|
|
const dualModels = [
|
|
{ modelId: 'composer-2.5[fast=true]', name: 'Composer 2.5' },
|
|
{ modelId: 'composer-2.5[fast=false]', name: 'Composer 2.5' }
|
|
] as const
|
|
|
|
it('uses dual mode with raw variant labels for current base', () => {
|
|
const catalog = buildCursorCatalogFromSources({
|
|
sessionModels: dualModels,
|
|
machineModels: [],
|
|
currentWireId: 'composer-2.5[fast=false]',
|
|
defaultValue: 'auto'
|
|
})
|
|
const picker = buildCursorPickerState({
|
|
catalog,
|
|
currentWireId: 'composer-2.5[fast=false]',
|
|
defaultValue: 'auto'
|
|
})
|
|
expect(picker.mode).toBe('dual')
|
|
expect(picker.showEffortPicker).toBe(true)
|
|
expect(picker.effortOptions.map((row) => row.label)).toEqual(['fast=true', 'fast=false'])
|
|
})
|
|
|
|
it('uses flat mode when each base has only one ACP wire', () => {
|
|
const catalog = buildCursorCatalogFromSources({
|
|
sessionModels: [
|
|
{ modelId: 'gpt-5.5[context=272k,reasoning=medium,fast=false]', name: 'gpt-5.5' },
|
|
{ modelId: 'composer-2.5[fast=true]', name: 'composer-2.5' }
|
|
],
|
|
defaultValue: null
|
|
})
|
|
const picker = buildCursorPickerState({
|
|
catalog,
|
|
currentWireId: 'gpt-5.5[context=272k,reasoning=medium,fast=false]',
|
|
defaultValue: null
|
|
})
|
|
expect(picker.mode).toBe('flat')
|
|
expect(picker.showEffortPicker).toBe(false)
|
|
expect(picker.effortOptions).toEqual([])
|
|
expect(picker.modelOptions).toHaveLength(3)
|
|
expect(picker.modelOptions.map((row) => row.value).sort()).toEqual([
|
|
'auto',
|
|
'composer-2.5[fast=true]',
|
|
'gpt-5.5[context=272k,reasoning=medium,fast=false]'
|
|
].sort())
|
|
})
|
|
|
|
it('shows variant picker for current base when only that base has variants', () => {
|
|
const catalog = buildCursorCatalogFromSources({
|
|
sessionModels: [
|
|
{ modelId: 'claude-opus-4-7[thinking=true,context=300k,effort=xhigh,fast=false]', name: 'Claude Opus 4.7' },
|
|
...dualModels
|
|
],
|
|
defaultValue: null
|
|
})
|
|
const picker = buildCursorPickerState({
|
|
catalog,
|
|
currentWireId: 'composer-2.5[fast=true]',
|
|
defaultValue: null
|
|
})
|
|
expect(picker.showEffortPicker).toBe(true)
|
|
expect(picker.baseKey).toBe('composer-2.5')
|
|
})
|
|
})
|
|
|
|
describe('resolveWireIdForBaseChange', () => {
|
|
it('does not guess when switching to a base with multiple variants', () => {
|
|
const catalog = buildCursorCatalogFromSources({
|
|
sessionModels: [
|
|
{ modelId: 'claude-opus-4-8[thinking=true,context=300k,effort=high,fast=false]', name: 'Opus 4.8' },
|
|
{ modelId: 'claude-opus-4-8[thinking=true,context=300k,effort=low,fast=false]', name: 'Opus 4.8' },
|
|
{ modelId: 'claude-opus-4-7[thinking=true,context=300k,effort=high,fast=false]', name: 'Opus 4.7' },
|
|
{ modelId: 'claude-opus-4-7[thinking=true,context=300k,effort=low,fast=false]', name: 'Opus 4.7' }
|
|
]
|
|
})
|
|
expect(resolveWireIdForBaseChange(
|
|
'claude-opus-4-7',
|
|
catalog,
|
|
'claude-opus-4-8[thinking=true,context=300k,effort=high,fast=false]'
|
|
)).toBeNull()
|
|
})
|
|
|
|
it('applies the only exact wire when a base has one variant', () => {
|
|
const catalog = buildCursorCatalogFromSources({
|
|
sessionModels: [
|
|
{ modelId: 'composer-2.5[fast=true]', name: 'Composer 2.5' },
|
|
]
|
|
})
|
|
expect(resolveWireIdForBaseChange('composer-2.5', catalog)).toBe('composer-2.5[fast=true]')
|
|
expect(resolveWireIdForBaseChange('auto', catalog)).toBe('auto')
|
|
})
|
|
})
|