fix: display shard key in collection tooltip#670
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Exposes sharding metadata in the DocumentDB tree UI by preserving the shard key from listCollections() and rendering it in the collection tooltip.
Changes:
- Extend
CollectionItemModelwith an optionalshardKeyproperty populated fromlistCollections()results. - Update
CollectionItemtooltip to conditionally display shard key details when present. - Add localization string for “Shard Key”.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/tree/documentdb/CollectionItem.ts | Adds shard key section to the collection tooltip. |
| src/documentdb/ClustersClient.ts | Extracts and stores shard key from listCollections() into the collection model. |
| l10n/bundle.l10n.json | Adds localized string entry for “Shard Key”. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@lte-z Thank you for your contribution and for addressing Copilot review. I'll review your PR tomorrow. |
Previously all entries were joined into a single backtick code span with escapeMarkdown applied to each key and value. Markdown escaping inside a code span is a no-op visually, so characters like underscores were rendered with a literal backslash (e.g. user\_id). Each entry is now its own inline code span, e.g.: Shard Key: `userId: 1`, `tenantId: "hashed"` This avoids the escaping issue and makes multi-key shard keys easier to read in the tooltip.
|
I pushed one follow-up commit on top of yours. What changed: The shard key entries are now each wrapped in their own inline code span instead of being joined into a single one. So a two-key shard key renders as:
Why: The original code applied |
|
Thank you so much for the warm welcome and for merging this! I also appreciate the follow-up commit and the explanation about the inline code spans. That makes sense to me now, especially for shard keys with underscores or multiple fields. And thank you for the kind words about the three PRs. I’m really glad they were helpful, and I’d be happy to keep contributing to vscode-documentdb 🙂 |

Fixes #661
Changes
This PR exposes shard key information for sharded collections in the tree view tooltip.
CollectionItemModelto include optionalshardKeyfieldlistCollections()response inClustersClientCollectionItemtooltip when presentBehavior
Notes
1) and hashed shard key formats