From f9834c81c947315ebe2527135e6df4bdc4da37c7 Mon Sep 17 00:00:00 2001 From: Tam Nhu Tran Date: Thu, 12 Feb 2026 07:55:35 +0700 Subject: [PATCH] fix(cursor): add enabled field to tests, simplify cursor routing - Add missing enabled field to CursorConfig in test assertions - Consolidate duplicate dynamic import in ccs.ts cursor routing --- src/ccs.ts | 11 +++-------- tests/unit/web-server/cursor-settings-routes.test.ts | 10 +++++++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/ccs.ts b/src/ccs.ts index d50d57a8..f21776d1 100644 --- a/src/ccs.ts +++ b/src/ccs.ts @@ -558,15 +558,10 @@ async function main(): Promise { // Note: cursor does not have enable/disable — it uses daemon start/stop instead const CURSOR_SUBCOMMANDS = ['auth', 'status', 'models', 'start', 'stop', 'help', '--help', '-h']; if (firstArg === 'cursor') { - if (args.length > 1 && CURSOR_SUBCOMMANDS.includes(args[1])) { - // `ccs cursor ` - route to cursor command handler - const { handleCursorCommand } = await import('./commands/cursor-command'); - const exitCode = await handleCursorCommand(args.slice(1)); - process.exit(exitCode); - } - // Bare `ccs cursor` - show help instead of reserved-name error const { handleCursorCommand } = await import('./commands/cursor-command'); - const exitCode = await handleCursorCommand([]); + const exitCode = await handleCursorCommand( + args.length > 1 && CURSOR_SUBCOMMANDS.includes(args[1]) ? args.slice(1) : [] + ); process.exit(exitCode); } diff --git a/tests/unit/web-server/cursor-settings-routes.test.ts b/tests/unit/web-server/cursor-settings-routes.test.ts index fbace9f6..13a05dfa 100644 --- a/tests/unit/web-server/cursor-settings-routes.test.ts +++ b/tests/unit/web-server/cursor-settings-routes.test.ts @@ -124,6 +124,7 @@ describe('Cursor Settings Routes Logic', () => { // Simulate the whitelist merge from the route const cursorConfig: CursorConfig = { + enabled: updates.enabled ?? config.cursor?.enabled ?? false, port: updates.port ?? config.cursor?.port ?? 3000, auto_start: updates.auto_start ?? config.cursor?.auto_start ?? false, ghost_mode: updates.ghost_mode ?? config.cursor?.ghost_mode ?? false, @@ -136,11 +137,12 @@ describe('Cursor Settings Routes Logic', () => { it('updates port only', () => { const config = loadOrCreateUnifiedConfig(); - config.cursor = { port: 3000, auto_start: false, ghost_mode: false }; + config.cursor = { enabled: false, port: 3000, auto_start: false, ghost_mode: false }; saveUnifiedConfig(config); const updates = { port: 4000 }; const cursorConfig: CursorConfig = { + enabled: updates.enabled ?? config.cursor?.enabled ?? false, port: updates.port ?? config.cursor?.port ?? 3000, auto_start: updates.auto_start ?? config.cursor?.auto_start ?? false, ghost_mode: updates.ghost_mode ?? config.cursor?.ghost_mode ?? false, @@ -153,11 +155,12 @@ describe('Cursor Settings Routes Logic', () => { it('updates auto_start only', () => { const config = loadOrCreateUnifiedConfig(); - config.cursor = { port: 3000, auto_start: false, ghost_mode: false }; + config.cursor = { enabled: false, port: 3000, auto_start: false, ghost_mode: false }; saveUnifiedConfig(config); const updates = { auto_start: true }; const cursorConfig: CursorConfig = { + enabled: updates.enabled ?? config.cursor?.enabled ?? false, port: updates.port ?? config.cursor?.port ?? 3000, auto_start: updates.auto_start ?? config.cursor?.auto_start ?? false, ghost_mode: updates.ghost_mode ?? config.cursor?.ghost_mode ?? false, @@ -170,11 +173,12 @@ describe('Cursor Settings Routes Logic', () => { it('updates ghost_mode only', () => { const config = loadOrCreateUnifiedConfig(); - config.cursor = { port: 3000, auto_start: false, ghost_mode: false }; + config.cursor = { enabled: false, port: 3000, auto_start: false, ghost_mode: false }; saveUnifiedConfig(config); const updates = { ghost_mode: true }; const cursorConfig: CursorConfig = { + enabled: updates.enabled ?? config.cursor?.enabled ?? false, port: updates.port ?? config.cursor?.port ?? 3000, auto_start: updates.auto_start ?? config.cursor?.auto_start ?? false, ghost_mode: updates.ghost_mode ?? config.cursor?.ghost_mode ?? false,