Problem
The "Indexes" folder node in the tree view shows no indication of how many indexes a collection has. Users must expand the node to see its contents.
Current:
▼ my-collection
▶ Documents
▶ Indexes <-- no count
Expected:
▼ my-collection
▶ Documents
▶ Indexes (5 indexes)
Expected Behavior
After the IndexesItem node is rendered, it should show the index count as its description. Since the index list is fetched when the node is expanded (in getChildren()), the count can be updated after the first expansion, or loaded lazily in the background.
Development Hints
Since this is a good first issue, here are some hints on where to start:
Pattern to follow: src/tree/documentdb/CollectionItem.ts
CollectionItem implements a lazy loading pattern for document count that you can replicate. The approach uses:
- A cached count field with three states:
undefined (not loaded), number (loaded), null (failed)
- A boolean guard to prevent duplicate fetches
- A fire-and-forget method that loads the count and calls
ext.state.notifyChildrenChanged(this.id) to refresh the tree item
Important consideration: Unlike document counts, the index list is already fetched when the user expands the IndexesItem node (via getChildren() which calls ClustersClient.listIndexes()). You should investigate whether the count can be derived from that existing fetch rather than making an extra API call. Possible approaches:
- After-expansion update: Cache the count after
getChildren() runs and refresh the tree item to show it. This means the count appears after the first expansion.
- Lazy background loading: Replicate the
CollectionItem pattern with a separate background fetch. This shows the count before expansion but makes an extra API call.
Evaluate which approach makes more sense. Copying the lazy loading code from CollectionItem is fine for this issue. We can create a follow-up refactoring issue to deduplicate the pattern later. The focus here is the feature, not code reuse.
File to modify: src/tree/documentdb/IndexesItem.ts
In getTreeItem(), add:
description: typeof this.indexCount === 'number'
? (this.indexCount === 1 ? l10n.t('1 index') : l10n.t('{0} indexes', this.indexCount))
: undefined
The parent that creates IndexesItem is CollectionItem.getChildren() in src/tree/documentdb/CollectionItem.ts.
Files to Modify
| File |
Change |
src/tree/documentdb/IndexesItem.ts |
Add count tracking and description in getTreeItem() |
src/tree/documentdb/CollectionItem.ts |
Optionally trigger lazy count loading when creating IndexesItem |
Acceptance Criteria
Problem
The "Indexes" folder node in the tree view shows no indication of how many indexes a collection has. Users must expand the node to see its contents.
Expected Behavior
After the
IndexesItemnode is rendered, it should show the index count as itsdescription. Since the index list is fetched when the node is expanded (ingetChildren()), the count can be updated after the first expansion, or loaded lazily in the background.Development Hints
Since this is a
good first issue, here are some hints on where to start:Pattern to follow:
src/tree/documentdb/CollectionItem.tsCollectionItemimplements a lazy loading pattern for document count that you can replicate. The approach uses:undefined(not loaded),number(loaded),null(failed)ext.state.notifyChildrenChanged(this.id)to refresh the tree itemImportant consideration: Unlike document counts, the index list is already fetched when the user expands the
IndexesItemnode (viagetChildren()which callsClustersClient.listIndexes()). You should investigate whether the count can be derived from that existing fetch rather than making an extra API call. Possible approaches:getChildren()runs and refresh the tree item to show it. This means the count appears after the first expansion.CollectionItempattern with a separate background fetch. This shows the count before expansion but makes an extra API call.Evaluate which approach makes more sense. Copying the lazy loading code from
CollectionItemis fine for this issue. We can create a follow-up refactoring issue to deduplicate the pattern later. The focus here is the feature, not code reuse.File to modify:
src/tree/documentdb/IndexesItem.tsIn
getTreeItem(), add:The parent that creates
IndexesItemisCollectionItem.getChildren()insrc/tree/documentdb/CollectionItem.ts.Files to Modify
src/tree/documentdb/IndexesItem.tsdescriptioningetTreeItem()src/tree/documentdb/CollectionItem.tsIndexesItemAcceptance Criteria
IndexesItemshows index count as description (e.g.,5 indexesor1 index)