From 173cb5664343966f13ba4f470c1da82c766c5d76 Mon Sep 17 00:00:00 2001 From: mkorwel Date: Thu, 19 Feb 2026 23:15:08 -0600 Subject: [PATCH] chore: fix tests and update documentation after merge --- .../scripts/fetch-pr-info.js | 3 +- docs/cli/settings.md | 1 + docs/reference/configuration.md | 5 ++ packages/cli/src/test-utils/AppRig.test.tsx | 8 +-- packages/cli/src/test-utils/AppRig.tsx | 51 +++++++----------- packages/cli/src/test-utils/settings.ts | 30 +++++++---- .../SettingsDialog.test.tsx.snap | 54 +++++++++---------- packages/core/src/core/client.test.ts | 1 + 8 files changed, 81 insertions(+), 72 deletions(-) diff --git a/.gemini/skills/pr-address-comments/scripts/fetch-pr-info.js b/.gemini/skills/pr-address-comments/scripts/fetch-pr-info.js index 772f8d18a4..de99def0ce 100755 --- a/.gemini/skills/pr-address-comments/scripts/fetch-pr-info.js +++ b/.gemini/skills/pr-address-comments/scripts/fetch-pr-info.js @@ -20,7 +20,8 @@ async function run(cmd) { stdio: ['pipe', 'pipe', 'ignore'], }); return stdout.trim(); - } catch (_e) { // eslint-disable-line @typescript-eslint/no-unused-vars + } catch (_e) { + // eslint-disable-line @typescript-eslint/no-unused-vars return null; } } diff --git a/docs/cli/settings.md b/docs/cli/settings.md index a7689fbcea..0db04fa5d2 100644 --- a/docs/cli/settings.md +++ b/docs/cli/settings.md @@ -30,6 +30,7 @@ they appear in the UI. | Enable Notifications | `general.enableNotifications` | Enable run-event notifications for action-required prompts and session completion. Currently macOS only. | `false` | | Plan Directory | `general.plan.directory` | The directory where planning artifacts are stored. If not specified, defaults to the system temporary directory. | `undefined` | | Enable Prompt Completion | `general.enablePromptCompletion` | Enable AI-powered prompt completion suggestions while typing. | `false` | +| Tool Preselection | `general.toolPreselection` | Exclude unneeded tools from context to save tokens and improve performance. | `true` | | Debug Keystroke Logging | `general.debugKeystrokeLogging` | Enable debug logging of keystrokes to the console. | `false` | | Enable Session Cleanup | `general.sessionRetention.enabled` | Enable automatic session cleanup | `false` | | Keep chat history | `general.sessionRetention.maxAge` | Automatically delete chats older than this time period (e.g., "30d", "7d", "24h", "1w") | `undefined` | diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index de639f95cf..bcd9e27642 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md @@ -148,6 +148,11 @@ their corresponding top-level category object in your `settings.json` file. request" errors. - **Default:** `false` +- **`general.toolPreselection`** (boolean): + - **Description:** Exclude unneeded tools from context to save tokens and + improve performance. + - **Default:** `true` + - **`general.debugKeystrokeLogging`** (boolean): - **Description:** Enable debug logging of keystrokes to the console. - **Default:** `false` diff --git a/packages/cli/src/test-utils/AppRig.test.tsx b/packages/cli/src/test-utils/AppRig.test.tsx index 76c0ddc522..3375503622 100644 --- a/packages/cli/src/test-utils/AppRig.test.tsx +++ b/packages/cli/src/test-utils/AppRig.test.tsx @@ -58,8 +58,8 @@ describe('AppRig', () => { // Resolve and finish. Also removes read_file breakpoint. await rig.resolveTool('read_file'); - await rig.waitForOutput('Task complete.', 100000); - }); + await rig.waitForOutput('Task complete.', 120000); + }, 120000); it('should render the app and handle a simple message', async () => { const fakeResponsesPath = path.join( @@ -83,6 +83,6 @@ describe('AppRig', () => { await rig.pressEnter(); // Wait for model response - await rig.waitForOutput('Hello! How can I help you today?'); - }); + await rig.waitForOutput('Hello! How can I help you today?', 30000); + }, 30000); }); diff --git a/packages/cli/src/test-utils/AppRig.tsx b/packages/cli/src/test-utils/AppRig.tsx index a0884ee024..9116ee30b9 100644 --- a/packages/cli/src/test-utils/AppRig.tsx +++ b/packages/cli/src/test-utils/AppRig.tsx @@ -139,6 +139,7 @@ export class AppRig { approvalMode, policyEngineConfig, enableEventDrivenScheduler: true, + toolPreselection: false, extensionLoader: new MockExtensionManager(), excludeTools: this.options.configOverrides?.excludeTools, ...this.options.configOverrides, @@ -178,41 +179,29 @@ export class AppRig { } private createRigSettings(): LoadedSettings { + const userSettings = { + security: { + auth: { + selectedType: AuthType.USE_GEMINI, + useExternal: true, + }, + folderTrust: { + enabled: true, + }, + }, + ide: { + enabled: false, + hasSeenNudge: true, + }, + }; + return createMockSettings({ user: { path: path.join(this.testDir, '.gemini', 'user_settings.json'), - settings: { - security: { - auth: { - selectedType: AuthType.USE_GEMINI, - useExternal: true, - }, - folderTrust: { - enabled: true, - }, - }, - ide: { - enabled: false, - hasSeenNudge: true, - }, - }, - originalSettings: {}, - }, - merged: { - security: { - auth: { - selectedType: AuthType.USE_GEMINI, - useExternal: true, - }, - folderTrust: { - enabled: true, - }, - }, - ide: { - enabled: false, - hasSeenNudge: true, - }, + settings: userSettings, + originalSettings: structuredClone(userSettings), }, + merged: userSettings, }); } diff --git a/packages/cli/src/test-utils/settings.ts b/packages/cli/src/test-utils/settings.ts index 77e8450a9c..384ec8bd98 100644 --- a/packages/cli/src/test-utils/settings.ts +++ b/packages/cli/src/test-utils/settings.ts @@ -52,17 +52,29 @@ export const createMockSettings = ( const loaded = new LoadedSettings( // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion - (system as any) || { path: '', settings: {}, originalSettings: {} }, - // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion - (systemDefaults as any) || { path: '', settings: {}, originalSettings: {} }, - // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion - (user as any) || { - path: '', - settings: settingsOverrides, - originalSettings: settingsOverrides, + (system as any) || { + path: '/tmp/gemini_system_settings.json', + settings: {}, + originalSettings: {}, }, // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion - (workspace as any) || { path: '', settings: {}, originalSettings: {} }, + (systemDefaults as any) || { + path: '/tmp/gemini_system_defaults.json', + settings: {}, + originalSettings: {}, + }, + // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion + (user as any) || { + path: '/tmp/gemini_user_settings.json', + settings: settingsOverrides, + originalSettings: structuredClone(settingsOverrides), + }, + // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion + (workspace as any) || { + path: '/tmp/gemini_workspace_settings.json', + settings: {}, + originalSettings: {}, + }, isTrusted ?? true, errors || [], ); diff --git a/packages/cli/src/ui/components/__snapshots__/SettingsDialog.test.tsx.snap b/packages/cli/src/ui/components/__snapshots__/SettingsDialog.test.tsx.snap index 3fec2244d7..eada85afc1 100644 --- a/packages/cli/src/ui/components/__snapshots__/SettingsDialog.test.tsx.snap +++ b/packages/cli/src/ui/components/__snapshots__/SettingsDialog.test.tsx.snap @@ -28,12 +28,12 @@ exports[`SettingsDialog > Initial Rendering > should render settings list with v │ Enable Prompt Completion false │ │ Enable AI-powered prompt completion suggestions while typing. │ │ │ +│ Tool Preselection true │ +│ Exclude unneeded tools from context to save tokens and improve performance. │ +│ │ │ Debug Keystroke Logging false │ │ Enable debug logging of keystrokes to the console. │ │ │ -│ Enable Session Cleanup false │ -│ Enable automatic session cleanup │ -│ │ │ ▼ │ │ │ │ Apply To │ @@ -75,12 +75,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'accessibility settings │ Enable Prompt Completion false │ │ Enable AI-powered prompt completion suggestions while typing. │ │ │ +│ Tool Preselection true │ +│ Exclude unneeded tools from context to save tokens and improve performance. │ +│ │ │ Debug Keystroke Logging false │ │ Enable debug logging of keystrokes to the console. │ │ │ -│ Enable Session Cleanup false │ -│ Enable automatic session cleanup │ -│ │ │ ▼ │ │ │ │ Apply To │ @@ -122,12 +122,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'all boolean settings d │ Enable Prompt Completion false* │ │ Enable AI-powered prompt completion suggestions while typing. │ │ │ +│ Tool Preselection true │ +│ Exclude unneeded tools from context to save tokens and improve performance. │ +│ │ │ Debug Keystroke Logging false* │ │ Enable debug logging of keystrokes to the console. │ │ │ -│ Enable Session Cleanup false │ -│ Enable automatic session cleanup │ -│ │ │ ▼ │ │ │ │ Apply To │ @@ -169,12 +169,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'default state' correct │ Enable Prompt Completion false │ │ Enable AI-powered prompt completion suggestions while typing. │ │ │ +│ Tool Preselection true │ +│ Exclude unneeded tools from context to save tokens and improve performance. │ +│ │ │ Debug Keystroke Logging false │ │ Enable debug logging of keystrokes to the console. │ │ │ -│ Enable Session Cleanup false │ -│ Enable automatic session cleanup │ -│ │ │ ▼ │ │ │ │ Apply To │ @@ -216,12 +216,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'file filtering setting │ Enable Prompt Completion false │ │ Enable AI-powered prompt completion suggestions while typing. │ │ │ +│ Tool Preselection true │ +│ Exclude unneeded tools from context to save tokens and improve performance. │ +│ │ │ Debug Keystroke Logging false │ │ Enable debug logging of keystrokes to the console. │ │ │ -│ Enable Session Cleanup false │ -│ Enable automatic session cleanup │ -│ │ │ ▼ │ │ │ │ Apply To │ @@ -263,12 +263,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'focused on scope selec │ Enable Prompt Completion false │ │ Enable AI-powered prompt completion suggestions while typing. │ │ │ +│ Tool Preselection true │ +│ Exclude unneeded tools from context to save tokens and improve performance. │ +│ │ │ Debug Keystroke Logging false │ │ Enable debug logging of keystrokes to the console. │ │ │ -│ Enable Session Cleanup false │ -│ Enable automatic session cleanup │ -│ │ │ ▼ │ │ │ │ > Apply To │ @@ -310,12 +310,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'mixed boolean and numb │ Enable Prompt Completion false │ │ Enable AI-powered prompt completion suggestions while typing. │ │ │ +│ Tool Preselection true │ +│ Exclude unneeded tools from context to save tokens and improve performance. │ +│ │ │ Debug Keystroke Logging false │ │ Enable debug logging of keystrokes to the console. │ │ │ -│ Enable Session Cleanup false │ -│ Enable automatic session cleanup │ -│ │ │ ▼ │ │ │ │ Apply To │ @@ -357,12 +357,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'tools and security set │ Enable Prompt Completion false │ │ Enable AI-powered prompt completion suggestions while typing. │ │ │ +│ Tool Preselection true │ +│ Exclude unneeded tools from context to save tokens and improve performance. │ +│ │ │ Debug Keystroke Logging false │ │ Enable debug logging of keystrokes to the console. │ │ │ -│ Enable Session Cleanup false │ -│ Enable automatic session cleanup │ -│ │ │ ▼ │ │ │ │ Apply To │ @@ -404,12 +404,12 @@ exports[`SettingsDialog > Snapshot Tests > should render 'various boolean settin │ Enable Prompt Completion true* │ │ Enable AI-powered prompt completion suggestions while typing. │ │ │ +│ Tool Preselection true │ +│ Exclude unneeded tools from context to save tokens and improve performance. │ +│ │ │ Debug Keystroke Logging true* │ │ Enable debug logging of keystrokes to the console. │ │ │ -│ Enable Session Cleanup false │ -│ Enable automatic session cleanup │ -│ │ │ ▼ │ │ │ │ Apply To │ diff --git a/packages/core/src/core/client.test.ts b/packages/core/src/core/client.test.ts index c910556ca8..146bbcbf0f 100644 --- a/packages/core/src/core/client.test.ts +++ b/packages/core/src/core/client.test.ts @@ -216,6 +216,7 @@ describe('Gemini Client (client.ts)', () => { isJitContextEnabled: vi.fn().mockReturnValue(false), getToolOutputMaskingEnabled: vi.fn().mockReturnValue(false), getDisableLoopDetection: vi.fn().mockReturnValue(false), + isToolPreselectionEnabled: vi.fn().mockReturnValue(false), getSessionId: vi.fn().mockReturnValue('test-session-id'), getProxy: vi.fn().mockReturnValue(undefined),