From 14219bb57d7d865b284047b05a9e93d70f61af9b Mon Sep 17 00:00:00 2001 From: Sandy Tao Date: Mon, 9 Feb 2026 15:01:23 -0800 Subject: [PATCH] chore: remove unused exports and redundant hook files (#18681) --- .../src/ui/hooks/useRefreshMemoryCommand.ts | 7 -- .../cli/src/ui/hooks/useShowMemoryCommand.ts | 76 ------------------- packages/cli/src/ui/themes/semantic-tokens.ts | 34 +-------- packages/cli/src/ui/utils/textUtils.ts | 7 -- packages/core/src/utils/testUtils.ts | 19 ----- 5 files changed, 1 insertion(+), 142 deletions(-) delete mode 100644 packages/cli/src/ui/hooks/useRefreshMemoryCommand.ts delete mode 100644 packages/cli/src/ui/hooks/useShowMemoryCommand.ts diff --git a/packages/cli/src/ui/hooks/useRefreshMemoryCommand.ts b/packages/cli/src/ui/hooks/useRefreshMemoryCommand.ts deleted file mode 100644 index 025eb9a05e..0000000000 --- a/packages/cli/src/ui/hooks/useRefreshMemoryCommand.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @license - * Copyright 2025 Google LLC - * SPDX-License-Identifier: Apache-2.0 - */ - -export const REFRESH_MEMORY_COMMAND_NAME = '/refreshmemory'; diff --git a/packages/cli/src/ui/hooks/useShowMemoryCommand.ts b/packages/cli/src/ui/hooks/useShowMemoryCommand.ts deleted file mode 100644 index d9c105d279..0000000000 --- a/packages/cli/src/ui/hooks/useShowMemoryCommand.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @license - * Copyright 2025 Google LLC - * SPDX-License-Identifier: Apache-2.0 - */ - -import type { Message } from '../types.js'; -import { MessageType } from '../types.js'; -import { debugLogger, type Config } from '@google/gemini-cli-core'; -import type { LoadedSettings } from '../../config/settings.js'; - -export function createShowMemoryAction( - config: Config | null, - settings: LoadedSettings, - addMessage: (message: Message) => void, -) { - return async () => { - if (!config) { - addMessage({ - type: MessageType.ERROR, - content: 'Configuration not available. Cannot show memory.', - timestamp: new Date(), - }); - return; - } - - const debugMode = config.getDebugMode(); - - if (debugMode) { - debugLogger.log('[DEBUG] Show Memory command invoked.'); - } - - const currentMemory = config.getUserMemory(); - const fileCount = config.getGeminiMdFileCount(); - const contextFileName = settings.merged.context.fileName; - const contextFileNames = Array.isArray(contextFileName) - ? contextFileName - : [contextFileName]; - - if (debugMode) { - debugLogger.log( - `[DEBUG] Showing memory. Content from config.getUserMemory() (first 200 chars): ${currentMemory.substring(0, 200)}...`, - ); - debugLogger.log(`[DEBUG] Number of context files loaded: ${fileCount}`); - } - - if (fileCount > 0) { - const allNamesTheSame = new Set(contextFileNames).size < 2; - const name = allNamesTheSame ? contextFileNames[0] : 'context'; - addMessage({ - type: MessageType.INFO, - content: `Loaded memory from ${fileCount} ${name} file${ - fileCount > 1 ? 's' : '' - }.`, - timestamp: new Date(), - }); - } - - if (currentMemory && currentMemory.trim().length > 0) { - addMessage({ - type: MessageType.INFO, - content: `Current combined memory content:\n\`\`\`markdown\n${currentMemory}\n\`\`\``, - timestamp: new Date(), - }); - } else { - addMessage({ - type: MessageType.INFO, - content: - fileCount > 0 - ? 'Hierarchical memory (GEMINI.md or other context files) is loaded but content is empty.' - : 'No hierarchical memory (GEMINI.md or other context files) is currently loaded.', - timestamp: new Date(), - }); - } - }; -} diff --git a/packages/cli/src/ui/themes/semantic-tokens.ts b/packages/cli/src/ui/themes/semantic-tokens.ts index 794ce745b6..3e95aee188 100644 --- a/packages/cli/src/ui/themes/semantic-tokens.ts +++ b/packages/cli/src/ui/themes/semantic-tokens.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { lightTheme, darkTheme, ansiTheme } from './theme.js'; +import { lightTheme, darkTheme } from './theme.js'; export interface SemanticColors { text: { @@ -101,35 +101,3 @@ export const darkSemanticColors: SemanticColors = { warning: darkTheme.AccentYellow, }, }; - -export const ansiSemanticColors: SemanticColors = { - text: { - primary: ansiTheme.Foreground, - secondary: ansiTheme.Gray, - link: ansiTheme.AccentBlue, - accent: ansiTheme.AccentPurple, - response: ansiTheme.Foreground, - }, - background: { - primary: ansiTheme.Background, - diff: { - added: ansiTheme.DiffAdded, - removed: ansiTheme.DiffRemoved, - }, - }, - border: { - default: ansiTheme.Gray, - focused: ansiTheme.AccentBlue, - }, - ui: { - comment: ansiTheme.Comment, - symbol: ansiTheme.Gray, - dark: ansiTheme.DarkGray, - gradient: ansiTheme.GradientColors, - }, - status: { - error: ansiTheme.AccentRed, - success: ansiTheme.AccentGreen, - warning: ansiTheme.AccentYellow, - }, -}; diff --git a/packages/cli/src/ui/utils/textUtils.ts b/packages/cli/src/ui/utils/textUtils.ts index b99a38c20f..63ca672989 100644 --- a/packages/cli/src/ui/utils/textUtils.ts +++ b/packages/cli/src/ui/utils/textUtils.ts @@ -179,13 +179,6 @@ export const getCachedStringWidth = (str: string): number => { return width; }; -/** - * Clear the string width cache - */ -export const clearStringWidthCache = (): void => { - stringWidthCache.clear(); -}; - const regex = ansiRegex(); /* Recursively traverses a JSON-like structure (objects, arrays, primitives) diff --git a/packages/core/src/utils/testUtils.ts b/packages/core/src/utils/testUtils.ts index a0010b105d..c5ba1ac470 100644 --- a/packages/core/src/utils/testUtils.ts +++ b/packages/core/src/utils/testUtils.ts @@ -52,25 +52,6 @@ export function disableSimulationAfterFallback(): void { fallbackOccurred = true; } -/** - * Create a simulated 429 error response - */ -export function createSimulated429Error(): Error { - const error = new Error('Rate limit exceeded (simulated)') as Error & { - status: number; - }; - error.status = 429; - return error; -} - -/** - * Reset simulation state when switching auth methods - */ -export function resetSimulationState(): void { - fallbackOccurred = false; - resetRequestCounter(); -} - /** * Enable/disable 429 simulation programmatically (for tests) */