refactor: Optimize the display information of "/chat list" and "/chat resume" (#2857)

Co-authored-by: Ben Guo <hundunben@gmail.com>
This commit is contained in:
Ben Guo
2025-07-16 08:47:56 +08:00
committed by GitHub
parent 1d67b41ccd
commit e88b9362dc
6 changed files with 510 additions and 161 deletions

View File

@@ -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,