From f10e606e6fd1235b9d0f6ead8079c94b62b722da Mon Sep 17 00:00:00 2001 From: anthonykim1 Date: Mon, 8 Dec 2025 13:23:25 -0800 Subject: [PATCH 1/2] Try removing stale persistentState --- src/features/terminal/shells/common/shellUtils.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/features/terminal/shells/common/shellUtils.ts b/src/features/terminal/shells/common/shellUtils.ts index 1264c188..192072f1 100644 --- a/src/features/terminal/shells/common/shellUtils.ts +++ b/src/features/terminal/shells/common/shellUtils.ts @@ -1,6 +1,5 @@ import { PythonCommandRunConfiguration, PythonEnvironment } from '../../../../api'; import { traceInfo } from '../../../../common/logging'; -import { getGlobalPersistentState } from '../../../../common/persistentState'; import { timeout } from '../../../../common/utils/asyncUtils'; import { isWindows } from '../../../../common/utils/platformUtils'; import { activeTerminalShellIntegration } from '../../../../common/window.apis'; @@ -9,8 +8,6 @@ import { ShellConstants } from '../../../common/shellConstants'; import { quoteArgs } from '../../../execution/execUtils'; import { SHELL_INTEGRATION_POLL_INTERVAL, SHELL_INTEGRATION_TIMEOUT } from '../../utils'; -export const SHELL_INTEGRATION_STATE_KEY = 'shellIntegration.enabled'; - function getCommandAsString(command: PythonCommandRunConfiguration[], shell: string, delimiter: string): string { const parts = []; for (const cmd of command) { @@ -119,10 +116,6 @@ export async function shellIntegrationForActiveTerminal(name: string, profile?: `SHELL: Shell integration is available on your active terminal, with name ${name} and profile ${profile}. Python activate scripts will be evaluated at shell integration level, except in WSL.`, ); - // Update persistent storage to reflect that shell integration is available - const persistentState = await getGlobalPersistentState(); - await persistentState.set(SHELL_INTEGRATION_STATE_KEY, true); - return true; } return false; @@ -134,7 +127,6 @@ export function isWsl(): boolean { } export async function getShellIntegrationEnabledCache(): Promise { - const persistentState = await getGlobalPersistentState(); const shellIntegrationInspect = getConfiguration('terminal.integrated').inspect('shellIntegration.enabled'); @@ -158,7 +150,6 @@ export async function getShellIntegrationEnabledCache(): Promise { } } - await persistentState.set(SHELL_INTEGRATION_STATE_KEY, shellIntegrationEnabled); return shellIntegrationEnabled; } From 70cec082b2848f32c07f7305834ae13a618e2a7f Mon Sep 17 00:00:00 2001 From: anthonykim1 Date: Tue, 9 Dec 2025 13:04:42 -0800 Subject: [PATCH 2/2] Rename getShellIntegrationEnabledSetting --- src/features/terminal/shells/bash/bashStartup.ts | 4 ++-- src/features/terminal/shells/common/shellUtils.ts | 2 +- src/features/terminal/shells/fish/fishStartup.ts | 4 ++-- src/features/terminal/shells/pwsh/pwshStartup.ts | 4 ++-- src/features/terminal/terminalManager.ts | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/features/terminal/shells/bash/bashStartup.ts b/src/features/terminal/shells/bash/bashStartup.ts index db9be723..6e7059dd 100644 --- a/src/features/terminal/shells/bash/bashStartup.ts +++ b/src/features/terminal/shells/bash/bashStartup.ts @@ -5,7 +5,7 @@ import which from 'which'; import { traceError, traceInfo, traceVerbose } from '../../../../common/logging'; import { ShellConstants } from '../../../common/shellConstants'; import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils'; -import { getShellIntegrationEnabledCache, isWsl, shellIntegrationForActiveTerminal } from '../common/shellUtils'; +import { getShellIntegrationEnabledSetting, isWsl, shellIntegrationForActiveTerminal } from '../common/shellUtils'; import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider'; import { BASH_ENV_KEY, BASH_OLD_ENV_KEY, BASH_SCRIPT_VERSION, ZSH_ENV_KEY, ZSH_OLD_ENV_KEY } from './bashConstants'; @@ -69,7 +69,7 @@ async function isStartupSetup(profile: string, key: string): Promise { - const shellIntegrationEnabled = await getShellIntegrationEnabledCache(); + const shellIntegrationEnabled = await getShellIntegrationEnabledSetting(); if ((shellIntegrationEnabled || (await shellIntegrationForActiveTerminal(name, profile))) && !isWsl()) { removeStartup(profile, key); return true; diff --git a/src/features/terminal/shells/common/shellUtils.ts b/src/features/terminal/shells/common/shellUtils.ts index 192072f1..e05b87ed 100644 --- a/src/features/terminal/shells/common/shellUtils.ts +++ b/src/features/terminal/shells/common/shellUtils.ts @@ -126,7 +126,7 @@ export function isWsl(): boolean { return !!(process.env.WSL_DISTRO_NAME || process.env.WSL_INTEROP || process.env.WSLENV); } -export async function getShellIntegrationEnabledCache(): Promise { +export async function getShellIntegrationEnabledSetting(): Promise { const shellIntegrationInspect = getConfiguration('terminal.integrated').inspect('shellIntegration.enabled'); diff --git a/src/features/terminal/shells/fish/fishStartup.ts b/src/features/terminal/shells/fish/fishStartup.ts index 40de3e98..c188bd2d 100644 --- a/src/features/terminal/shells/fish/fishStartup.ts +++ b/src/features/terminal/shells/fish/fishStartup.ts @@ -6,7 +6,7 @@ import which from 'which'; import { traceError, traceInfo, traceVerbose } from '../../../../common/logging'; import { ShellConstants } from '../../../common/shellConstants'; import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils'; -import { getShellIntegrationEnabledCache, isWsl, shellIntegrationForActiveTerminal } from '../common/shellUtils'; +import { getShellIntegrationEnabledSetting, isWsl, shellIntegrationForActiveTerminal } from '../common/shellUtils'; import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider'; import { FISH_ENV_KEY, FISH_OLD_ENV_KEY, FISH_SCRIPT_VERSION } from './fishConstants'; @@ -58,7 +58,7 @@ async function isStartupSetup(profilePath: string, key: string): Promise { try { - const shellIntegrationEnabled = await getShellIntegrationEnabledCache(); + const shellIntegrationEnabled = await getShellIntegrationEnabledSetting(); if ((shellIntegrationEnabled || (await shellIntegrationForActiveTerminal('fish', profilePath))) && !isWsl()) { removeFishStartup(profilePath, key); return true; diff --git a/src/features/terminal/shells/pwsh/pwshStartup.ts b/src/features/terminal/shells/pwsh/pwshStartup.ts index 45bb33d5..510965d3 100644 --- a/src/features/terminal/shells/pwsh/pwshStartup.ts +++ b/src/features/terminal/shells/pwsh/pwshStartup.ts @@ -13,7 +13,7 @@ import { ShellConstants } from '../../../common/shellConstants'; import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils'; import { extractProfilePath, - getShellIntegrationEnabledCache, + getShellIntegrationEnabledSetting, isWsl, PROFILE_TAG_END, PROFILE_TAG_START, @@ -169,7 +169,7 @@ async function isPowerShellStartupSetup(shell: string, profile: string): Promise } async function setupPowerShellStartup(shell: string, profile: string): Promise { - const shellIntegrationEnabled = await getShellIntegrationEnabledCache(); + const shellIntegrationEnabled = await getShellIntegrationEnabledSetting(); if ((shellIntegrationEnabled || (await shellIntegrationForActiveTerminal(shell, profile))) && !isWsl()) { removePowerShellStartup(shell, profile, POWERSHELL_OLD_ENV_KEY); diff --git a/src/features/terminal/terminalManager.ts b/src/features/terminal/terminalManager.ts index 394cc8db..4044819d 100644 --- a/src/features/terminal/terminalManager.ts +++ b/src/features/terminal/terminalManager.ts @@ -17,7 +17,7 @@ import { isActivatableEnvironment } from '../common/activation'; import { identifyTerminalShell } from '../common/shellDetector'; import { getPythonApi } from '../pythonApi'; import { - getShellIntegrationEnabledCache, + getShellIntegrationEnabledSetting, isWsl, shellIntegrationForActiveTerminal, shouldUseProfileActivation, @@ -144,7 +144,7 @@ export class TerminalManagerImpl implements TerminalManager { } if (e.affectsConfiguration('terminal.integrated.shellIntegration.enabled')) { traceInfo('Shell integration setting changed, invalidating cache'); - const updatedShellIntegrationSetting = await getShellIntegrationEnabledCache(); + const updatedShellIntegrationSetting = await getShellIntegrationEnabledSetting(); if (!updatedShellIntegrationSetting) { const shells = new Set( terminals() @@ -171,7 +171,7 @@ export class TerminalManagerImpl implements TerminalManager { await Promise.all( providers.map(async (p) => { const state = await p.isSetup(); - const shellIntegrationEnabledSetting = await getShellIntegrationEnabledCache(); + const shellIntegrationEnabledSetting = await getShellIntegrationEnabledSetting(); const shellIntegrationActiveTerminal = await shellIntegrationForActiveTerminal(p.name); const shellIntegrationLikelyAvailable = shellIntegrationEnabledSetting || shellIntegrationActiveTerminal;