Skip to content

Commit abbec51

Browse files
meganroggeCopilot
andcommitted
sessions: test workspace picker setting migration
Extract the unified workspace picker migration and cover application scope, legacy value removal, value copying, and preservation of an explicit replacement value. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5115190 commit abbec51

3 files changed

Lines changed: 60 additions & 13 deletions

File tree

‎src/vs/sessions/contrib/chat/browser/chat.contribution.ts‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { IFileDialogService } from '../../../../platform/dialogs/common/dialogs.
1717
import { IQuickInputService, IQuickPickItem, QuickPickInput } from '../../../../platform/quickinput/common/quickInput.js';
1818
import product from '../../../../platform/product/common/product.js';
1919
import { Registry } from '../../../../platform/registry/common/platform.js';
20-
import { type ConfigurationKeyValuePairs, Extensions as WorkbenchConfigurationExtensions, IConfigurationMigrationRegistry } from '../../../../workbench/common/configuration.js';
20+
import { Extensions as WorkbenchConfigurationExtensions, IConfigurationMigrationRegistry } from '../../../../workbench/common/configuration.js';
2121
import { registerWorkbenchContribution2, WorkbenchPhase } from '../../../../workbench/common/contributions.js';
2222
import { ISessionsService } from '../../../services/sessions/browser/sessionsService.js';
2323
import { ISessionsManagementService, inheritableSessionTarget } from '../../../services/sessions/common/sessionsManagement.js';
@@ -57,12 +57,12 @@ import { SessionsChatResponseFileChangesService } from './sessionTurnChanges.js'
5757
import { IChatResponseFileChangesService } from '../../../../workbench/contrib/chat/browser/chatResponseFileChangesService.js';
5858
import { SessionsChatPetAchievementContribution } from './chatPetAchievements.js';
5959
import { AGENT_SESSIONS_CHAT_BACKGROUND_CODICONS_PRESET, AGENT_SESSIONS_PREFERRED_DARK_CHAT_BACKGROUND_IMAGE_LAYOUT_SETTING, AGENT_SESSIONS_PREFERRED_DARK_CHAT_BACKGROUND_IMAGE_SETTING, AGENT_SESSIONS_PREFERRED_LIGHT_CHAT_BACKGROUND_IMAGE_LAYOUT_SETTING, AGENT_SESSIONS_PREFERRED_LIGHT_CHAT_BACKGROUND_IMAGE_SETTING, chatBackgroundImageLayoutValues, ChatBackgroundImageLayout, ISessionsChatBackgroundService, SessionsChatBackgroundService } from '../../../services/chatBackground/browser/chatBackgroundService.js';
60+
import { LEGACY_UNIFIED_WORKSPACE_PICKER_SETTING, unifiedWorkspacePickerConfigurationMigration } from './unifiedWorkspacePickerConfiguration.js';
6061

6162
const CHANGE_AGENT_SESSIONS_CHAT_BACKGROUND_COMMAND_ID = 'workbench.action.chat.changeAgentSessionsBackground';
6263
const CHANGE_AGENT_SESSIONS_CHAT_BACKGROUND_LAYOUT_COMMAND_ID = 'workbench.action.chat.changeAgentSessionsBackgroundLayout';
6364
const CHANGE_AGENT_SESSIONS_CHAT_BACKGROUND_WHEN = ContextKeyExpr.and(IsSessionsWindowContext, SessionsChatBackgroundAvailableContext);
6465
const CHANGE_AGENT_SESSIONS_CHAT_BACKGROUND_LAYOUT_WHEN = ContextKeyExpr.and(CHANGE_AGENT_SESSIONS_CHAT_BACKGROUND_WHEN, SessionsChatBackgroundImageConfiguredContext);
65-
const LEGACY_UNIFIED_WORKSPACE_PICKER_SETTING = 'chat.agentSessions.consolidatedRemoteWorkspaces';
6666

6767
type RecentChatBackgroundTypeItem = IQuickPickItem & {
6868
readonly kind: 'recentImage';
@@ -436,14 +436,4 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
436436
},
437437
});
438438

439-
Registry.as<IConfigurationMigrationRegistry>(WorkbenchConfigurationExtensions.ConfigurationMigration).registerConfigurationMigrations([{
440-
key: LEGACY_UNIFIED_WORKSPACE_PICKER_SETTING,
441-
includeApplication: true,
442-
migrateFn: (value, accessor) => {
443-
const pairs: ConfigurationKeyValuePairs = [[LEGACY_UNIFIED_WORKSPACE_PICKER_SETTING, { value: undefined }]];
444-
if (accessor(UNIFIED_WORKSPACE_PICKER_SETTING) === undefined) {
445-
pairs.push([UNIFIED_WORKSPACE_PICKER_SETTING, { value }]);
446-
}
447-
return pairs;
448-
},
449-
}]);
439+
Registry.as<IConfigurationMigrationRegistry>(WorkbenchConfigurationExtensions.ConfigurationMigration).registerConfigurationMigrations([unifiedWorkspacePickerConfigurationMigration]);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { ConfigurationKeyValuePairs, ConfigurationMigration } from '../../../../workbench/common/configuration.js';
7+
import { UNIFIED_WORKSPACE_PICKER_SETTING } from '../common/constants.js';
8+
9+
export const LEGACY_UNIFIED_WORKSPACE_PICKER_SETTING = 'chat.agentSessions.consolidatedRemoteWorkspaces';
10+
11+
export const unifiedWorkspacePickerConfigurationMigration: ConfigurationMigration = {
12+
key: LEGACY_UNIFIED_WORKSPACE_PICKER_SETTING,
13+
includeApplication: true,
14+
migrateFn: (value, accessor) => {
15+
const pairs: ConfigurationKeyValuePairs = [[LEGACY_UNIFIED_WORKSPACE_PICKER_SETTING, { value: undefined }]];
16+
if (accessor(UNIFIED_WORKSPACE_PICKER_SETTING) === undefined) {
17+
pairs.push([UNIFIED_WORKSPACE_PICKER_SETTING, { value }]);
18+
}
19+
return pairs;
20+
},
21+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import assert from 'assert';
7+
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js';
8+
import { LEGACY_UNIFIED_WORKSPACE_PICKER_SETTING, unifiedWorkspacePickerConfigurationMigration } from '../../browser/unifiedWorkspacePickerConfiguration.js';
9+
import { UNIFIED_WORKSPACE_PICKER_SETTING } from '../../common/constants.js';
10+
11+
suite('UnifiedWorkspacePickerConfiguration', () => {
12+
13+
ensureNoDisposablesAreLeakedInTestSuite();
14+
15+
test('migrates application values without overwriting the new setting', async () => {
16+
const copiedValue = await unifiedWorkspacePickerConfigurationMigration.migrateFn(true, () => undefined);
17+
const preservedValue = await unifiedWorkspacePickerConfigurationMigration.migrateFn(false, key => key === UNIFIED_WORKSPACE_PICKER_SETTING ? true : undefined);
18+
19+
assert.deepStrictEqual({
20+
key: unifiedWorkspacePickerConfigurationMigration.key,
21+
includeApplication: unifiedWorkspacePickerConfigurationMigration.includeApplication,
22+
copiedValue,
23+
preservedValue,
24+
}, {
25+
key: LEGACY_UNIFIED_WORKSPACE_PICKER_SETTING,
26+
includeApplication: true,
27+
copiedValue: [
28+
[LEGACY_UNIFIED_WORKSPACE_PICKER_SETTING, { value: undefined }],
29+
[UNIFIED_WORKSPACE_PICKER_SETTING, { value: true }],
30+
],
31+
preservedValue: [
32+
[LEGACY_UNIFIED_WORKSPACE_PICKER_SETTING, { value: undefined }],
33+
],
34+
});
35+
});
36+
});

0 commit comments

Comments
 (0)