Skip to content

Fix bookmarks tree view registration error#4685

Open
hanniavalera wants to merge 3 commits intomainfrom
dev/hanniavalera/bookmarksIdBug
Open

Fix bookmarks tree view registration error#4685
hanniavalera wants to merge 3 commits intomainfrom
dev/hanniavalera/bookmarksIdBug

Conversation

@hanniavalera
Copy link
Contributor

This change addresses item #4683

This changes visible behavior

The following changes are proposed:

  • Make the bookmarks tree view lazily initialized instead of eagerly created in the ExtensionManager constructor
  • Create the bookmarks tree view only when cmake:enableFullFeatureSet becomes true
  • Dispose of the bookmarks tree view when the full feature set is disabled
  • Add defensive try/catch around tree view creation to gracefully handle edge cases
  • Add a check to verify the view contribution exists before attempting to create the tree view

The purpose of this change

After the bookmarks feature was introduced in #4539, users reported seeing the error:

No view is registered with id: cmake.bookmarks

This occurred because the cmake.bookmarks view is contributed with "when": "cmake:enableFullFeatureSet" in package.json, meaning VS Code only registers the view container when that context is true. However, the tree view was being created eagerly in the ExtensionManager constructor before the context value was set, causing a race condition where vscode.window.createTreeView() was called before VS Code had registered the view.

The fix defers tree view creation until enableFullFeatureSet(true) is called, ensuring the view container is properly registered by VS Code before we attempt to create the tree view.

Other Notes/Information

  • The exact repro conditions are unclear as they depend on timing/race conditions during extension activation
  • A unit test is difficult to create for this fix since it involves VS Code's internal view registration behavior which cannot be easily mocked
  • The fix is defensive in nature with multiple safeguards:
    • Idempotency check (early return if already created)
    • Package.json contribution check via isBookmarksViewContributed()
    • Try/catch wrapper with error logging

@hanniavalera
Copy link
Contributor Author

@sean-mcmanus Hi! Thanks for filing #4683 - if you have time, I would appreciate if you can check if this approach fixes your issue, thanks!

Copy link

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 pull request fixes a race condition error where the bookmarks tree view was being created before VS Code had properly registered the view contribution. The error "No view is registered with id: cmake.bookmarks" occurred because the view is conditionally contributed based on cmake:enableFullFeatureSet context, but the tree view was being eagerly created before this context was set to true.

Changes:

  • Converted bookmarks tree view from eager initialization to lazy initialization
  • Added lifecycle management to create the tree view only when the full feature set is enabled
  • Added proper disposal when the feature set is disabled
  • Implemented defensive checks including try-catch error handling and package.json contribution verification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sean-mcmanus
Copy link
Contributor

@hanniavalera I don't know what the repro is. I hit it a couple times.

@hanniavalera
Copy link
Contributor Author

@sean-mcmanus No worries, thank you for getting back to me so promptly!

@hanniavalera hanniavalera force-pushed the dev/hanniavalera/bookmarksIdBug branch from d0a038f to 90dec50 Compare February 3, 2026 16:32
Copilot AI added a commit that referenced this pull request Feb 3, 2026
Co-authored-by: snehara99 <113148726+snehara99@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] notificationsAlerts.ts:42 No view is registered with id: cmake.bookmarks

2 participants