Skip to content

authentication: remove unused service APIs and their tests - #351262

Open
Dmitriy Vasyura (dmitrivMS) wants to merge 3 commits into
mainfrom
agents/remove-dead-code-authentication
Open

Dmitriy Vasyura (dmitrivMS) wants to merge 3 commits into
mainfrom
agents/remove-dead-code-authentication

Conversation

@dmitrivMS

Copy link
Copy Markdown
Collaborator

Removes about 2,100 lines of dead code from the workbench authentication services (15 files, +60/−2,119: about 1,300 lines of production code, 100 of them commented out, and about 800 lines of tests and mocks). Nothing observable changes: every removed member had no remaining caller, and the one side effect that goes away is described under the evidence below. Members that were only referenced from tests count as dead, so those tests and mocks are removed with them.

The branch has three commits that can be reviewed, or dropped, independently:

  1. authentication: remove unused service APIs and their tests is the bulk of the change.
  2. authentication: remove disabled cleanup contributions deletes 100 lines of commented-out code.
  3. authentication: remove orphan stubs from TestAuthenticationService deletes 5 mock members that no interface declares.

What is removed

All paths are under src/vs/workbench/.

Query facade (services/authentication/common/authenticationQuery.ts −226, services/authentication/browser/authenticationQueryService.ts −441)

  • The IAuthenticationUsageStats and IActiveEntities types.
  • Unused members of the account-first extension and MCP server queries: remove, addUsage, removeUsage, setAsPreferred, isPreferred, allowAccess, removeAccess, forEach, hasAnyUsage and removeAllAccess, plus isAccessAllowed() on a single extension entity and isTrusted() on MCP server entities.
  • Unused provider-first members: removeAccountPreference, getLastUsedAccount, getUsedAccounts, getActiveEntities, getAccountNames, getUsageStats and forEachAccount, plus the provider(...) accessors on IExtensionQuery and IMcpServerQuery.
  • Unused service-level members: onDidChangePreferences, onDidChangeAccess, getProviderIds and clearAllData.
  • What remains is the surface that has production callers: setAccessAllowed and getUsage on both entity kinds, isAccessAllowed on MCP server entities, isTrusted on extension entities (used by getAllowedExtensions), getAllowedExtensions, getAllowedMcpServers, getEntityCount, getPreferredAccount, setPreferredAccount, getProvidersWithAccess and getAllAccountPreferences.

MCP service (services/authentication/browser/authenticationMcpService.ts −371)

  • The session request, badge and dialog machinery: requestSessionAccess, requestNewSession, updateNewSessionRequests, updateAccessRequests, updateBadgeCount, removeAccessRequest, showGetSessionPrompt, completeSessionAccessRequest and the listener registration behind them.
  • onDidChangeAccountPreference, removeAccountPreference, getSessionPreference and removeSessionPreference from the interface and the implementation. The extensions service keeps its own onDidChangeAccountPreference and removeAccountPreference, which are still used.
  • The IActivityService, IDialogService and IAuthenticationMcpUsageService dependencies, and the 6 localized strings that only the removed code used.

Other services

  • authenticationMcpUsageService.ts (−74): initializeUsageCache, hasUsedAuth and removeAccountUsage, the cache they maintained, and the provider registration listener that filled it. The extension usage service's removeAccountUsage is still used and stays.
  • authenticationMcpAccessService.ts (−13): the onDidChangeMcpSessionAccess event and removeAllowedMcpServers.
  • authenticationExtensionsService.ts (−28) and common/authentication.ts (−44): getSessionPreference and removeSessionPreference, the unreferenced isAuthenticationSession type guard and a stale doc comment.
  • dynamicAuthenticationProviderStorageService.ts (−7): getClientId, which isn't on the interface either.
  • contrib/authentication/browser/actions/ (−1 each): an unused lastUsed property on a local quick pick item type in two actions.
  • contrib/authentication/browser/authentication.contribution.ts (−100): the commented-out AuthenticationExtensionsContribution and AuthenticationMcpContribution classes and their registrations.

Tests and mocks

  • authenticationQueryService.test.ts (49 → 24 tests): the tests of removed members are gone, and the rest now run against the surface that still exists.
  • authenticationMcpAccessService.test.ts (43 → 36 tests) and authenticationMcpService.test.ts (−8 lines of setup for the removed dependencies).
  • authenticationQueryServiceMocks.ts (−44): the stubs for the removed interface members, plus 5 members of TestAuthenticationService (manageTrustedExtensionsForAccount, removeAccountSessions, requestNewSession, getSession and supportsHeimdallConnection) that IAuthenticationService doesn't declare and nothing calls.

Evidence that these were dead

  • A static, member-level reachability analysis of main, with references from tests not counted as callers, flagged these members as unreferenced. After the change it finds nothing in this area that newly became unreferenced.
  • Static analysis can't see any-typed or string-keyed uses, so a repo-wide git grep -w for the removed names backs it up. It finds no remaining reference. The only names that still appear are same-named members of other live code, such as requestSessionAccess, requestNewSession and removeAccountPreference on IAuthenticationExtensionsService, which are kept.
  • Every member left on IAuthenticationQueryService has a production caller: the manage* actions in contrib/authentication, mcpCommands.ts, mcpServerActions.ts, mainThreadAuthentication.ts and mainThreadGitHub.ts.
  • The commented-out contributions (commit 2) were added in Authentication polish around account access #252452 to clean up account access state when an extension or MCP server is uninstalled, and were switched off in Remove bad contribution for now #253810 ("Remove bad contribution for now"). They call APIs that this PR removes (getProviderIds, forEachAccount, removeUsage, entity forEach), so they couldn't be re-enabled as they are. Git history keeps them.
  • The orphan stubs (commit 3): the only importer of the mocks module is authenticationQueryService.test.ts, which calls just registerAuthenticationProvider and addAccounts on the mock and reaches everything else through IAuthenticationService, which doesn't declare these members. manageTrustedExtensionsForAccount and removeAccountSessions left the interface in Tear down the Authentication monolith #206495.
  • One side effect goes away: on every provider registration the MCP usage service called getAccounts to warm its cache. The cache's only reader, hasUsedAuth, had no callers, so nothing depends on it.

Validation

All run on the final commit.

  • pnpm run typecheck-client: 26 errors, all in src/vs/platform/agentHost/, which this PR doesn't touch (SDK type mismatches such as a missing fusion property, from an out-of-date local @microsoft/copilot-sdk). None anywhere else.
  • node build/oxlint.ts <the 15 changed files>: 15 files checked, no problems.
  • git diff --check: clean.
  • pnpm run transpile-client, then .\scripts\test.bat --reporter dot --run <file> [--run <file> ...] for these 10 files: 312 passing.
    • src/vs/workbench/services/authentication/test/browser/: authenticationQueryService, authenticationMcpAccessService, authenticationMcpService, authenticationAccessService and authenticationService
    • src/vs/workbench/api/test/browser/: mainThreadAuthentication, extHostAuthentication and mainThreadMcp
    • src/vs/workbench/services/accounts/test/browser/defaultAccount.test.ts
    • src/vs/workbench/services/github/test/browser/githubService.test.ts

Not run: the *.integrationTest.ts files (they are only type-checked, and the stubs in them are unchanged) and the full unit and integration suites.

Removes about 2,000 lines of dead code from the workbench authentication services. Every removed member had no remaining references, and code that was only referenced from tests counts as dead, so those tests and mocks are removed with it.

Co-authored-by: Copilot <[email protected]>
Delete the commented-out `AuthenticationExtensionsContribution` and `AuthenticationMcpContribution` classes and their registrations. They were disabled in #253810 and were the only remaining references to the query service methods removed in the previous commit (`getProviderIds`, `forEachAccount`, `removeUsage`), so they could no longer be re-enabled as written.

Co-authored-by: Copilot <[email protected]>
TestAuthenticationService implements IAuthenticationService, which no longer declares manageTrustedExtensionsForAccount, removeAccountSessions, requestNewSession, getSession or supportsHeimdallConnection. The only test that uses the mock reaches it through the interface, so these stubs can never be called.

Co-authored-by: Copilot <[email protected]>
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added debt Code quality issues authentication Issues with the Authentication platform labels Nov 30, 2026
Copilot AI balanced review requested due to automatic review settings November 30, 2026 17:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the authentication-service API cleanup.

No open issues 🎉

What changed in this PR

This PR reduces the workbench authentication services to APIs with production callers, removing unused implementations and their tests without intending to change user-facing behavior.

Changes:

  • Removes unused query APIs, MCP session-request machinery, events, and usage-cache initialization.
  • Deletes previously commented-out cleanup contributions and obsolete helper members.
  • Updates retained tests and mocks to use the remaining service interfaces.
File Description
src/​vs/​workbench/​services/​authentication/​test/​browser/​authenticationQueryServiceMocks.ts Removes obsolete mock members and call-tracking helpers.
src/​vs/​workbench/​services/​authentication/​test/​browser/​authenticationQueryService.test.ts Removes tests of deleted APIs and adapts retained coverage.
src/​vs/​workbench/​services/​authentication/​test/​browser/​authenticationMcpService.test.ts Removes setup for deleted service dependencies.
src/​vs/​workbench/​services/​authentication/​test/​browser/​authenticationMcpAccessService.test.ts Removes event and bulk-removal tests.
src/​vs/​workbench/​services/​authentication/​common/​authenticationQuery.ts Narrows query interfaces to the retained API surface.
src/​vs/​workbench/​services/​authentication/​common/​authentication.ts Removes an unused type guard and session-preference APIs.
src/​vs/​workbench/​services/​authentication/​browser/​dynamicAuthenticationProviderStorageService.ts Removes the unused getClientId helper.
src/​vs/​workbench/​services/​authentication/​browser/​authenticationQueryService.ts Deletes unused query implementations and event forwarding.
src/​vs/​workbench/​services/​authentication/​browser/​authenticationMcpUsageService.ts Removes the unused cache, initialization listener, and removal API.
src/​vs/​workbench/​services/​authentication/​browser/​authenticationMcpService.ts Removes unused session-request machinery and preference APIs.
src/​vs/​workbench/​services/​authentication/​browser/​authenticationMcpAccessService.ts Removes unused access-change events and bulk removal.
src/​vs/​workbench/​services/​authentication/​browser/​authenticationExtensionsService.ts Removes unused session-preference readers and removal methods.
src/​vs/​workbench/​contrib/​authentication/​browser/​authentication.contribution.ts Deletes commented-out cleanup contributions and registrations.
src/​vs/​workbench/​contrib/​authentication/​browser/​actions/​manageTrustedMcpServersForAccountAction.ts Removes an unused quick-pick type property.
src/​vs/​workbench/​contrib/​authentication/​browser/​actions/​manageTrustedExtensionsForAccountAction.ts Removes an unused quick-pick type property.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

authentication Issues with the Authentication platform debt Code quality issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants