Change:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Read our guide about submitting issues: --<!-- Search existing issues to avoid creating duplicates. --<!-- Test using the latest Insiders build to see if your issue has already been fixed: --<!-- Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. --<!-- Launch with to check. --Does this issue occur when all extensions are disabled?: No <!-- If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. --<!-- Issues caused by an extension need to be reported directly to the extension publisher. The 'Help Report Issue' dialog can assist with this. --- VS Code Version: 1.86 OS Version: macOS 14.3 Steps to Reproduce: run profile programmatically with isDefault = false seems to restore the previously selected state "isDefault", or if there is none, makes the first profile "Default". behavior works for me. But unfortunately after the profile is created and before its state is changed manually in the UI, it reports isDefault = false. Expected: isDefault matches the UI state at all times. //
Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.86.2. Please try upgrading to the latest version and checking whether this issue remains. Happy Coding!
This works for me, but note that the synchronization of the new profile is asynchronous after its creation. This is intentional because it's common for extensions to create a profile and then set its properties, like we don't want to cause that to override what the user previously set (especially since making isDefault a 'live' property was a later addition to the API). For me, adding a listener like triggers shortly after its creation
Fascinating! I can't reproduce this bug today.
It seems like there is some inconsistency here
A simple snippet like this surfaces the issue for me: The console is saying And the GUI has run 1 as (Default)
Looks like this is working now:

Discussion:
import { LiveTestResult } from 'vs/workbench/contrib/testing/common/testResult'; import { ITestResultService } from 'vs/workbench/contrib/testing/common/testResultService'; import { IMainThreadTestController, ITestRootProvider, ITestService } from 'vs/workbench/contrib/testing/common/testService'; <del> import { CoverageDetails, ExtensionRunTestsRequest, IFileCoverage, ITestItem, ITestMessage, ITestRunProfile, ITestRunTask, ResolvedTestRunRequest, TestResultState, TestsDiffOp } from 'vs/workbench/contrib/testing/common/testTypes'; </del> <ins> import { CoverageDetails, ExtensionRunTestsRequest, IFileCoverage, ITestItem, ITestMessage, ITestRunProfile, ITestRunTask, ResolvedTestRunRequest, TestResultState, TestRunProfileBitset, TestsDiffOp } from 'vs/workbench/contrib/testing/common/testTypes'; </ins> import { IExtHostContext, extHostNamedCustomer } from 'vs/workbench/services/extensions/common/extHostCustomers'; import { ExtHostContext, ExtHostTestingShape, ILocationDto, ITestControllerPatch, MainContext, MainThreadTestingShape } from '../common/extHost.protocol';

this._register(Event.debounce(testProfiles.onDidChange, (_last, e) => e)(() => { const obj: Record</* controller id */string, /* profile id */ number[]> = {}; <del> for (const { controller, profiles } of this.testProfiles.all()) { obj[controller.id] = profiles.filter(p => p.isDefault).map(p => p.profileId); </del> <ins> for (const group of [TestRunProfileBitset.Run, TestRunProfileBitset.Debug, TestRunProfileBitset.Coverage]) { for (const profile of this.testProfiles.getGroupDefaultProfiles(group)) { obj[profile.controllerId] ??= []; obj[profile.controllerId].push(profile.profileId); } </ins> } this.proxy.$setDefaultRunProfiles(obj);