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
This commit is contained in:
Tam Nhu Tran
2026-02-12 07:55:35 +07:00
parent 6af718626f
commit f9834c81c9
2 changed files with 10 additions and 11 deletions
+3 -8
View File
@@ -558,15 +558,10 @@ async function main(): Promise<void> {
// 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 <subcommand>` - 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);
}
@@ -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,