Skip to content

Comments

CmdPal: Migrate bookmarks manually#42814

Merged
michaeljolley merged 2 commits intomicrosoft:mainfrom
jiripolasek:feature/42796-cmdpal-upgrade-old-bookmarks-manually
Oct 23, 2025
Merged

CmdPal: Migrate bookmarks manually#42814
michaeljolley merged 2 commits intomicrosoft:mainfrom
jiripolasek:feature/42796-cmdpal-upgrade-old-bookmarks-manually

Conversation

@jiripolasek
Copy link
Collaborator

Summary of the Pull Request

This PR fixes the migration of bookmarks from versions prior to 0.95, resolving an issue where hotkeys and aliases wouldn’t persist on bookmarks created with Command Palette 0.94 or earlier.

It removes ID auto-fixing from BookmarkData in favor of an explicit migration step handled by BookmarkManager.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Stop being clever—do the hard work properly. Remove ID auto-fixing from BookmarkData and add an explicit migration step to BookmarkManager. That “save after load” must have been a mistake… right?
Adds a new unit test that verifies generated IDs are correctly persisted and can be reloaded.
Copy link
Contributor

@michaeljolley michaeljolley left a comment

Choose a reason for hiding this comment

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

Good stuff!

@michaeljolley michaeljolley merged commit cd5f753 into microsoft:main Oct 23, 2025
10 checks passed
@jiripolasek
Copy link
Collaborator Author

image

@yeelam-gordon yeelam-gordon requested a review from Copilot November 7, 2025 01:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a migration path for legacy bookmark data from pre-0.95 versions that lacked ID fields. The migration ensures that bookmarks receive persistent IDs that are preserved across application restarts, which is critical for maintaining associations with hotkeys and aliases.

Key Changes

  • Removed automatic ID generation from BookmarkData constructor when Guid.Empty is provided, shifting migration responsibility to the manager layer
  • Added migration logic in BookmarksManager.LoadBookmarksFromFile() to detect and upgrade legacy bookmarks
  • Enhanced test infrastructure with save tracking to verify persistence behavior

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Persistence/BookmarkData.cs Simplified 3-parameter constructor to directly assign ID without fallback generation
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarksManager.cs Added legacy data upgrade logic that generates and persists IDs for bookmarks with Guid.Empty
src/modules/cmdpal/Tests/Microsoft.CmdPal.Ext.Bookmarks.UnitTests/MockBookmarkDataSource.cs Added save tracking with SaveCount property and WaitForSave method for deterministic async testing
src/modules/cmdpal/Tests/Microsoft.CmdPal.Ext.Bookmarks.UnitTests/BookmarkManagerTests.cs Added test verifying that generated IDs persist correctly across manager instantiations

mirmirmirr pushed a commit to mirmirmirr/PowerToys that referenced this pull request Nov 9, 2025
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

This PR fixes the migration of bookmarks from versions prior to 0.95,
resolving an issue where hotkeys and aliases wouldn’t persist on
bookmarks created with Command Palette 0.94 or earlier.

It removes ID auto-fixing from `BookmarkData` in favor of an explicit
migration step handled by `BookmarkManager`.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: microsoft#42796
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
@yeelam-gordon yeelam-gordon added the Product-Command Palette Refers to the Command Palette utility label Nov 11, 2025
@yeelam-gordon yeelam-gordon added this to the PowerToys 0.96 milestone Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Command Palette Refers to the Command Palette utility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CmdPal Bookmark Shortcuts reset on every Restart

3 participants