mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-17 17:41:24 -07:00
Refactor: Migrate CLI appEvents to Core coreEvents (#15737)
This commit is contained in:
@@ -10,13 +10,13 @@ import { appEvents, AppEvent } from './events.js';
|
||||
describe('events', () => {
|
||||
it('should allow registering and emitting events', () => {
|
||||
const callback = vi.fn();
|
||||
appEvents.on(AppEvent.OauthDisplayMessage, callback);
|
||||
appEvents.on(AppEvent.SelectionWarning, callback);
|
||||
|
||||
appEvents.emit(AppEvent.OauthDisplayMessage, 'test message');
|
||||
appEvents.emit(AppEvent.SelectionWarning);
|
||||
|
||||
expect(callback).toHaveBeenCalledWith('test message');
|
||||
expect(callback).toHaveBeenCalled();
|
||||
|
||||
appEvents.off(AppEvent.OauthDisplayMessage, callback);
|
||||
appEvents.off(AppEvent.SelectionWarning, callback);
|
||||
});
|
||||
|
||||
it('should work with events without data', () => {
|
||||
|
||||
@@ -4,23 +4,18 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import type { ExtensionEvents, McpClient } from '@google/gemini-cli-core';
|
||||
import { EventEmitter } from 'node:events';
|
||||
|
||||
export enum AppEvent {
|
||||
OpenDebugConsole = 'open-debug-console',
|
||||
OauthDisplayMessage = 'oauth-display-message',
|
||||
Flicker = 'flicker',
|
||||
McpClientUpdate = 'mcp-client-update',
|
||||
SelectionWarning = 'selection-warning',
|
||||
PasteTimeout = 'paste-timeout',
|
||||
}
|
||||
|
||||
export interface AppEvents extends ExtensionEvents {
|
||||
export interface AppEvents {
|
||||
[AppEvent.OpenDebugConsole]: never[];
|
||||
[AppEvent.OauthDisplayMessage]: string[];
|
||||
[AppEvent.Flicker]: never[];
|
||||
[AppEvent.McpClientUpdate]: Array<Map<string, McpClient> | never>;
|
||||
[AppEvent.SelectionWarning]: never[];
|
||||
[AppEvent.PasteTimeout]: never[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user