Add positron.workspace.registerConfigurationMigrations extension API#14298
Add positron.workspace.registerConfigurationMigrations extension API#14298samclark2015 wants to merge 4 commits into
Conversation
Exposes a settings migration capability to extensions via the Positron
API. Extensions call `positron.workspace.registerConfigurationMigrations`
with an array of `{ key, migrateTo }` specs; the main thread validates
ownership (source extension must match, or publisher must be in
`trustedExtensionPublishers`) and delegates to the existing
`ConfigurationMigrationRegistry`, which handles all scopes and language
overrides automatically.
Also fixes a latent bug where `ConfigurationMigrationRegistry` fired no
event after registering migrations, so `ConfigurationMigrationWorkbenchContribution`
never processed dynamically-registered migrations.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
E2E Tests 🚀 Note No feature tags detected. If this PR needs feature coverage, add the tag above and retrigger the workflow. |
PETE's assessment 🧪Verdict: 🟢 Adequate -- Every substantive source change is covered: the Mocha test exercises all five ownership branches of What changed
Tests in this PR
Existing coverageThe new tests are the primary coverage:
Suggested additionsNone. Deployment note (optional)N/A -- the change is platform-agnostic main-thread/ext-host logic with no PETE (Positron Extreme Test Experiment) - LLM-based test-coverage advisor, in pilot. Triggers on PR open and on |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Removes the IProductService dependency from registerConfigurationMigrations and hardcodes 'posit' as the trusted publisher rather than reading trustedExtensionPublishers from product.json. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
/repete |
| const configurationProperties = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).getConfigurationProperties(); | ||
| const normalizedExtensionId = extensionId.toLowerCase(); | ||
| const publisher = normalizedExtensionId.split('.')[0]; | ||
| const isTrusted = publisher === 'posit'; |
There was a problem hiding this comment.
Your PR description says this will be controlled by product.trustedExtensionPublishers, I'm curious what your reasoning was for removing that to hardcoding it? Can we also add rstudio as trusted - this is unfortunately still the publisher of the workbench extension.
There was a problem hiding this comment.
I had done this initially, but wound up hard-coding due to concerns about side effects. It looks like this will also suppress the “Do you trust publisher X?” for Posit & RStudio if we add this. That sounds reasonable to me, thoughts?
- Guard migrateFn against overwriting a destination key that already has a user-set value at the same config target (use accessor() per codebase pattern) - Detect policy conflicts at registration time: log per-key admin errors and show a single batched user notification when old keys are policy-enforced but new keys are not - Update positron.d.ts JSDoc to document both behaviors Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Adds
positron.workspace.registerConfigurationMigrationsto the Positron extension API, allowing extensions to declaratively migrate configuration keys they previously contributed.Each
ConfigurationMigrationSpecspecifies a source key and destination key. The main thread validates ownership — the requesting extension must have contributed the source key, unless its publisher appears inproduct.trustedExtensionPublishers— then registers the migration with the internalConfigurationMigrationRegistry, which handles user/workspace/folder scopes and language overrides automatically.Also fixes a latent bug:
ConfigurationMigrationRegistry.registerConfigurationMigrationswas not firing itsonDidRegisterConfigurationMigrationevent, soConfigurationMigrationWorkbenchContributionnever processed migrations registered after workbench init.Usage:
Release Notes
New Features
positron.workspace.registerConfigurationMigrationsAPI for extensions to migrate legacy configuration keys (Spike: Investigate extension API for migrating configuration keys #14299)Bug Fixes
Validation Steps
positron.workspace.registerConfigurationMigrations([{ key: 'old.key', migrateTo: 'new.key' }])old.keyto a non-default value in user settingsnew.keyandold.keyis cleared