From 105b038b8110e25271c8ee9c6cbefad8c033671a Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Tue, 19 Aug 2025 13:30:04 -0700 Subject: [PATCH] Fix to prevent multiple shell startup prompts --- .../terminal/shellStartupSetupHandlers.ts | 4 +--- .../terminal/shells/common/shellUtils.ts | 2 +- src/features/terminal/terminalManager.ts | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/features/terminal/shellStartupSetupHandlers.ts b/src/features/terminal/shellStartupSetupHandlers.ts index 30ced7fc..b9da1e8d 100644 --- a/src/features/terminal/shellStartupSetupHandlers.ts +++ b/src/features/terminal/shellStartupSetupHandlers.ts @@ -11,9 +11,7 @@ export async function handleSettingUpShellProfile( callback: (provider: ShellStartupScriptProvider, result: boolean) => void, ): Promise { const shells = providers.map((p) => p.shellType).join(', '); - // TODO: Get opinions on potentially modifying the prompt - // - If shell integration is active, we won't need to modify user's shell profile, init scripts. - // - Current prompt we have below may not be the most accurate description. + // Only show prompt when shell integration is not available, or disabled. const response = await showInformationMessage( l10n.t( 'To enable "{0}" activation, your shell profile(s) may need to be updated to include the necessary startup scripts. Would you like to proceed with these changes?', diff --git a/src/features/terminal/shells/common/shellUtils.ts b/src/features/terminal/shells/common/shellUtils.ts index 8c45e210..95e6f71a 100644 --- a/src/features/terminal/shells/common/shellUtils.ts +++ b/src/features/terminal/shells/common/shellUtils.ts @@ -98,7 +98,7 @@ export function extractProfilePath(content: string): string | undefined { return undefined; } -export function shellIntegrationForActiveTerminal(name: string, profile: string): boolean { +export function shellIntegrationForActiveTerminal(name: string, profile?: string): boolean { const hasShellIntegration = activeTerminalShellIntegration(); if (hasShellIntegration) { diff --git a/src/features/terminal/terminalManager.ts b/src/features/terminal/terminalManager.ts index bb912647..a985c079 100644 --- a/src/features/terminal/terminalManager.ts +++ b/src/features/terminal/terminalManager.ts @@ -16,6 +16,7 @@ import { getConfiguration, onDidChangeConfiguration } from '../../common/workspa import { isActivatableEnvironment } from '../common/activation'; import { identifyTerminalShell } from '../common/shellDetector'; import { getPythonApi } from '../pythonApi'; +import { shellIntegrationForActiveTerminal } from './shells/common/shellUtils'; import { ShellEnvsProvider, ShellSetupState, ShellStartupScriptProvider } from './shells/startupProvider'; import { handleSettingUpShellProfile } from './shellStartupSetupHandlers'; import { @@ -153,9 +154,20 @@ export class TerminalManagerImpl implements TerminalManager { traceVerbose(`Checking shell profile for ${p.shellType}.`); const state = await p.isSetup(); if (state === ShellSetupState.NotSetup) { - this.shellSetup.set(p.shellType, false); - shellsToSetup.push(p); - traceVerbose(`Shell profile for ${p.shellType} is not setup.`); + // Check if shell integration is available before marking for setup + if (shellIntegrationForActiveTerminal(p.name)) { + this.shellSetup.set(p.shellType, true); + traceVerbose( + `Shell integration available for ${p.shellType}, skipping prompt, and profile modification.`, + ); + } else { + // No shell integration, mark for setup + this.shellSetup.set(p.shellType, false); + shellsToSetup.push(p); + traceVerbose( + `Shell integration is NOT avaoiable. Shell profile for ${p.shellType} is not setup.`, + ); + } } else if (state === ShellSetupState.Setup) { this.shellSetup.set(p.shellType, true); traceVerbose(`Shell profile for ${p.shellType} is setup.`);