chore: add channels command

This commit is contained in:
Jack Wotherspoon
2026-03-23 21:01:32 -07:00
parent 79225898c1
commit 4335517475
4 changed files with 59 additions and 1 deletions
+17
View File
@@ -68,6 +68,7 @@ import {
flattenMemory,
type MemoryChangedPayload,
type ChannelMessagePayload,
activeChannels,
writeToStdout,
disableMouseEvents,
enterAlternateScreen,
@@ -1241,6 +1242,22 @@ Logging in with Google... Restarting Gemini CLI to continue.
};
}, [channelsEnabled, addMessage]);
// Warn about requested channels whose MCP servers did not declare capability.
const channelWarningFired = useRef(false);
useEffect(() => {
if (!isMcpReady || !channelsEnabled || channelWarningFired.current) return;
channelWarningFired.current = true;
const requested = config.getChannels();
for (const name of requested) {
if (!activeChannels.has(name)) {
coreEvents.emitFeedback(
'warning',
`Channel "${name}" was requested but the MCP server did not declare channel capability.`,
);
}
}
}, [isMcpReady, channelsEnabled, config]);
cancelHandlerRef.current = useCallback(
(shouldRestorePrompt: boolean = true) => {
const pendingHistoryItems = [
@@ -0,0 +1,39 @@
/**
* @license
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import type { SlashCommand, CommandContext } from './types.js';
import { CommandKind } from './types.js';
import {
MessageType,
type ChannelInfo,
type HistoryItemChannelsList,
} from '../types.js';
import { activeChannels } from '@google/gemini-cli-core';
export const channelsCommand: SlashCommand = {
name: 'channels',
description: 'List active message channels from MCP servers',
kind: CommandKind.BUILT_IN,
autoExecute: true,
action: async (context: CommandContext) => {
const channels: ChannelInfo[] = Array.from(activeChannels.entries()).map(
([name, capability]) => ({
name,
displayName: capability.displayName,
supportsReply: capability.supportsReply,
}),
);
const channelsListItem: HistoryItemChannelsList = {
type: MessageType.CHANNELS_LIST,
channels,
};
context.ui.addItem(channelsListItem);
return;
},
};