From e88b9362dcd1092de01ce8efa413b5acd89ee620 Mon Sep 17 00:00:00 2001 From: Ben Guo <36952867+HunDun0Ben@users.noreply.github.com> Date: Wed, 16 Jul 2025 08:47:56 +0800 Subject: refactor: Optimize the display information of "/chat list" and "/chat resume" (#2857) Co-authored-by: Ben Guo --- packages/cli/src/services/CommandService.test.ts | 13 +++++++++---- packages/cli/src/services/CommandService.ts | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'packages/cli/src/services') diff --git a/packages/cli/src/services/CommandService.test.ts b/packages/cli/src/services/CommandService.test.ts index c309da34..b1f6e496 100644 --- a/packages/cli/src/services/CommandService.test.ts +++ b/packages/cli/src/services/CommandService.test.ts @@ -10,6 +10,7 @@ import { type SlashCommand } from '../ui/commands/types.js'; import { memoryCommand } from '../ui/commands/memoryCommand.js'; import { helpCommand } from '../ui/commands/helpCommand.js'; import { clearCommand } from '../ui/commands/clearCommand.js'; +import { chatCommand } from '../ui/commands/chatCommand.js'; import { authCommand } from '../ui/commands/authCommand.js'; import { themeCommand } from '../ui/commands/themeCommand.js'; import { statsCommand } from '../ui/commands/statsCommand.js'; @@ -47,6 +48,8 @@ vi.mock('../ui/commands/extensionsCommand.js', () => ({ })); describe('CommandService', () => { + const subCommandLen = 10; + describe('when using default production loader', () => { let commandService: CommandService; @@ -70,13 +73,14 @@ describe('CommandService', () => { const tree = commandService.getCommands(); // Post-condition assertions - expect(tree.length).toBe(9); + expect(tree.length).toBe(subCommandLen); const commandNames = tree.map((cmd) => cmd.name); expect(commandNames).toContain('auth'); expect(commandNames).toContain('memory'); expect(commandNames).toContain('help'); expect(commandNames).toContain('clear'); + expect(commandNames).toContain('chat'); expect(commandNames).toContain('theme'); expect(commandNames).toContain('stats'); expect(commandNames).toContain('privacy'); @@ -87,14 +91,14 @@ describe('CommandService', () => { it('should overwrite any existing commands when called again', async () => { // Load once await commandService.loadCommands(); - expect(commandService.getCommands().length).toBe(9); + expect(commandService.getCommands().length).toBe(subCommandLen); // Load again await commandService.loadCommands(); const tree = commandService.getCommands(); // Should not append, but overwrite - expect(tree.length).toBe(9); + expect(tree.length).toBe(subCommandLen); }); }); @@ -106,10 +110,11 @@ describe('CommandService', () => { await commandService.loadCommands(); const loadedTree = commandService.getCommands(); - expect(loadedTree.length).toBe(9); + expect(loadedTree.length).toBe(subCommandLen); expect(loadedTree).toEqual([ aboutCommand, authCommand, + chatCommand, clearCommand, extensionsCommand, helpCommand, diff --git a/packages/cli/src/services/CommandService.ts b/packages/cli/src/services/CommandService.ts index 379d0638..50f2c63a 100644 --- a/packages/cli/src/services/CommandService.ts +++ b/packages/cli/src/services/CommandService.ts @@ -10,6 +10,7 @@ import { helpCommand } from '../ui/commands/helpCommand.js'; import { clearCommand } from '../ui/commands/clearCommand.js'; import { authCommand } from '../ui/commands/authCommand.js'; import { themeCommand } from '../ui/commands/themeCommand.js'; +import { chatCommand } from '../ui/commands/chatCommand.js'; import { statsCommand } from '../ui/commands/statsCommand.js'; import { privacyCommand } from '../ui/commands/privacyCommand.js'; import { aboutCommand } from '../ui/commands/aboutCommand.js'; @@ -18,6 +19,7 @@ import { extensionsCommand } from '../ui/commands/extensionsCommand.js'; const loadBuiltInCommands = async (): Promise => [ aboutCommand, authCommand, + chatCommand, clearCommand, extensionsCommand, helpCommand, -- cgit v1.2.3