mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
update /editor to new slash command arch (#4153)
Co-authored-by: Abhi <abhipatel@google.com>
This commit is contained in:
30
packages/cli/src/ui/commands/editorCommand.test.ts
Normal file
30
packages/cli/src/ui/commands/editorCommand.test.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { editorCommand } from './editorCommand.js';
|
||||
// 1. Import the mock context utility
|
||||
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
|
||||
|
||||
describe('editorCommand', () => {
|
||||
it('should return a dialog action to open the editor dialog', () => {
|
||||
if (!editorCommand.action) {
|
||||
throw new Error('The editor command must have an action.');
|
||||
}
|
||||
const mockContext = createMockCommandContext();
|
||||
const result = editorCommand.action(mockContext, '');
|
||||
|
||||
expect(result).toEqual({
|
||||
type: 'dialog',
|
||||
dialog: 'editor',
|
||||
});
|
||||
});
|
||||
|
||||
it('should have the correct name and description', () => {
|
||||
expect(editorCommand.name).toBe('editor');
|
||||
expect(editorCommand.description).toBe('set external editor preference');
|
||||
});
|
||||
});
|
||||
16
packages/cli/src/ui/commands/editorCommand.ts
Normal file
16
packages/cli/src/ui/commands/editorCommand.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { type OpenDialogActionReturn, type SlashCommand } from './types.js';
|
||||
|
||||
export const editorCommand: SlashCommand = {
|
||||
name: 'editor',
|
||||
description: 'set external editor preference',
|
||||
action: (): OpenDialogActionReturn => ({
|
||||
type: 'dialog',
|
||||
dialog: 'editor',
|
||||
}),
|
||||
};
|
||||
@@ -71,8 +71,7 @@ export interface MessageActionReturn {
|
||||
*/
|
||||
export interface OpenDialogActionReturn {
|
||||
type: 'dialog';
|
||||
// TODO: Add 'theme' | 'auth' | 'editor' | 'privacy' as migration happens.
|
||||
dialog: 'help' | 'auth' | 'theme' | 'privacy';
|
||||
dialog: 'help' | 'auth' | 'theme' | 'editor' | 'privacy';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user