Skip to content

feat(collectionView): add Index Management tab#732

Open
khelanmodi wants to merge 1 commit into
mainfrom
dev/khelanmodi/index-management-ui
Open

feat(collectionView): add Index Management tab#732
khelanmodi wants to merge 1 commit into
mainfrom
dev/khelanmodi/index-management-ui

Conversation

@khelanmodi

@khelanmodi khelanmodi commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

feat(collectionView): Index Management tab

image image

Summary

Adds an Indexes tab inside the existing CollectionView (between
Results and Query Insights) for managing collection indexes from the
extension. This PR contains the UI / front-end scaffold. The tRPC
router that brokers calls to ClustersClient is in place, but every
integration point is annotated for the backend engineer to validate
end-to-end against the real cluster surface.

What ships in this PR (UI only)

  • Indexes tab in CollectionView (no new webview, no new command,
    no new context-menu entry). Renders when selectedTab === 'tab_indexes'.
  • Top-toolbar Create Index button — the CollectionView primary
    toolbar swaps its Find Query action for Create Index while on the
    Indexes tab. Triggered via a documentdb:openCreateIndex custom event
    so the toolbar stays decoupled from the tab internals.
  • Find Query editor (the multiline query input) is hidden on the
    Indexes tab; visible on Results / Query Insights as before.
  • Index table — Name, Type (color-coded pill), Fields, Memory, Usage
    (with tooltip showing the time window), Created, Notes, Actions
    (Delete, Hide/Unhide). The pencil/Edit action has been removed for
    this iteration — see follow-ups below.
  • Create Index dialog — field picker (populated from SchemaStore),
    per-field asc/desc, type selector (Single Field / TTL / Geospatial /
    Text) with type-specific options (unique + sparse for single-field,
    expiry for TTL), optional name + notes, ≥1-field / ≥1-type validation,
    and the large-collection warning banner (>
    LARGE_COLLECTION_THRESHOLD_DOCS = 1,000,000 documents).
  • Footer bar — total indexes / total memory / total usage.
  • ConfirmDialog wrapper used for the destructive delete confirmation.
  • Reuses existing Fluent UI v9 primitives and the project's theme tokens
    — no new colors, fonts, spacing units, or runtime dependencies.

Backend integration surface — for the backend engineer

All UI ↔ backend traffic flows through one file:

src/webviews/documentdb/indexView/indexViewRouter.ts

The top of the file has a BACKEND INTEGRATION SURFACE banner and
every procedure is preceded by a // BACKEND INTEGRATION POINT — <procedureName> block that documents:

  • what the UI expects back,
  • which ClustersClient method is currently called,
  • known edge cases / TODOs.

Search the file for BACKEND INTEGRATION POINT to walk through them.

Procedure inventory

Procedure UI surface Currently calls
getInfo tab header / dialog titles (pure context read, no backend call)
listIndexes main table ClustersClient.listIndexes + getCollectionStats + getIndexStats
getCollectionDocumentCount large-collection warning banner ClustersClient.getCollectionStats
getFieldSuggestions Create Index field picker SchemaStore.getInstance().getKnownFields (in-process; no backend call)
createIndex Create Index dialog submit ClustersClient.createIndex
dropIndex Delete confirm dialog ClustersClient.dropIndex
hideIndex / unhideIndex Hide/Unhide action button ClustersClient.{hide,unhide}Index

All of the above ClustersClient methods already exist; the router calls
them through their existing signatures and shapes the response into the
view-model types in ./types.ts. If you need to change the underlying
transport (capability gating, batching, caching, server-side endpoint),
do it inside the procedure — the webview never needs to know.

Known follow-ups (not blocking this PR)

  1. dropIndex against in-progress build — confirm DocumentDB
    behaviour and surface a better error if the index is mid-build.
  2. hideIndex capability gate — some cluster tiers / engine versions
    don't support collMod { hidden }. Return a typed error so the UI
    can disable the toggle proactively.
  3. IndexRow.notes persistence — the field is read-only today;
    wire up storage when product confirms scope.
  4. Search-index types ($search, vector) are intentionally not
    surfaced in v1 — confirm we want to keep them filtered out.
  5. Edit-then-recreate flow — the pencil/Edit action was removed for
    this PR. If product wants it back, the agreed pattern is "delete +
    open Create dialog pre-filled".

Files changed

File Purpose
src/webviews/documentdb/collectionView/CollectionView.tsx Adds the Indexes tab, the panel, and hides the Find Query editor on that tab.
src/webviews/documentdb/collectionView/components/toolbar/ToolbarMainView.tsx Swaps the primary toolbar button to Create Index on the Indexes tab.
src/webviews/documentdb/indexView/ (new folder) Tab component, table, dialogs, footer, types, constants, utils, router.
src/webviews/_integration/appRouter.ts Mounts mongoClusters.indexView.

Local testing

  1. npm run build
  2. F5 → Default: Launch Extension (webpack).
  3. Open any collection → click the Indexes tab.
  4. Create / delete / hide an index against a non-prod cluster.

Verification

  • npm run l10n
  • npm run prettier-fix
  • npm run lint
  • npx jest --no-coverage
  • npm run build
  • npm run package

@khelanmodi khelanmodi requested a review from a team as a code owner June 3, 2026 18:57
Copilot AI review requested due to automatic review settings June 3, 2026 18:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Indexes tab to the existing CollectionView webview, including a front-end scaffold for listing and managing collection indexes (create, delete, hide/unhide) backed by a new mongoClusters.indexView tRPC router.

Changes:

  • Introduces the new indexView/ webview area (tab component, table/footer, create + confirm dialogs, formatting/classification utils, constants, styling).
  • Adds an indexViewRouter tRPC router and mounts it under mongoClusters.indexView in the root webview appRouter.
  • Updates CollectionView + toolbar behavior to expose the Indexes tab, hide the query editor on that tab, and swap the primary toolbar action to “Create Index” via a custom window event.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/webviews/documentdb/indexView/utils/indexType.ts Classifies indexes into badge categories for the table “Type” column.
src/webviews/documentdb/indexView/utils/format.ts Adds formatting helpers for bytes, ops, and date/tooltip strings.
src/webviews/documentdb/indexView/types.ts Defines IndexRow view-model + create-index input types.
src/webviews/documentdb/indexView/indexViewRouter.ts New tRPC router implementing list/create/drop/hide/unhide and field suggestions.
src/webviews/documentdb/indexView/indexView.scss Styling for the Indexes tab layout, table, and dialog controls.
src/webviews/documentdb/indexView/IndexesTab.tsx Main Indexes tab component (fetching, dialogs, hide/unhide, delete flow).
src/webviews/documentdb/indexView/constants.ts Central constants (thresholds, directions, event name, id index name).
src/webviews/documentdb/indexView/components/IndexTypeBadgeView.tsx Renders Fluent UI badge for index type.
src/webviews/documentdb/indexView/components/IndexTable.tsx Renders the indexes table + action buttons and tooltips.
src/webviews/documentdb/indexView/components/IndexFooterBar.tsx Renders footer totals (indexes/memory/usage) as a live region.
src/webviews/documentdb/indexView/components/CreateIndexDialog.tsx Create Index dialog UI + validation and payload shaping.
src/webviews/documentdb/indexView/components/ConfirmDialog.tsx Reusable confirm dialog wrapper for destructive/caution actions.
src/webviews/documentdb/collectionView/components/toolbar/ToolbarMainView.tsx Switches primary toolbar action to “Create Index” when on Indexes tab.
src/webviews/documentdb/collectionView/CollectionView.tsx Adds Indexes tab, hides QueryEditor on Indexes, renders IndexesTab panel.
src/webviews/_integration/appRouter.ts Mounts mongoClusters.indexView router.
l10n/bundle.l10n.json Adds localization entries for newly introduced UI strings.

relationship="description"
withArrow
>
<span>{formatOps(idx.usageOps)}</span>
Comment on lines +87 to +94
<Button
appearance="subtle"
size="small"
icon={<DeleteRegular />}
aria-label={l10n.t('Delete index {0}', idx.name)}
disabled={isProtected}
onClick={() => onDelete(idx)}
/>
Comment on lines +107 to +118
<Button
appearance="subtle"
size="small"
icon={idx.hidden ? <EyeRegular /> : <EyeOffRegular />}
aria-label={
idx.hidden
? l10n.t('Unhide index {0}', idx.name)
: l10n.t('Hide index {0}', idx.name)
}
disabled={isProtected}
onClick={() => onToggleHidden(idx)}
/>
Comment on lines +72 to +75
</Tooltip>
</TableCell>
<TableCell>{formatDate(idx.usageSince)}</TableCell>
<TableCell>{idx.notes ?? ''}</TableCell>

return (
<div className="indexView">
{isLoading && <ProgressBar thickness="large" shape="square" className="progressBar" />}
: ASC_DIRECTION,
})
}
aria-label={l10n.t('Sort direction')}
// IndexesTab component listens for; this keeps the toolbar
// free of any direct coupling to the IndexesTab internals.
<ToolbarButton
aria-label={l10n.t('Create a new index')}
Comment on lines +353 to +357
.mutation(async ({ input, ctx }) => {
const myCtx = ctx as WithTelemetry<RouterContext>;
const client = await ClustersClient.getClient(myCtx.clusterId);
await client.unhideIndex(myCtx.databaseName, myCtx.collectionName, input.indexName);
return { ok: true };
Adds an Indexes tab inside the existing CollectionView (between Results and Query Insights) for managing collection indexes:

- Indexes tab in CollectionView (no new webview, no new command, no context-menu entry)

- Top-toolbar Create Index button (replaces Find Query on the Indexes tab)

- Find Query editor hidden on the Indexes tab

- Index table: Name, Type (color pill), Fields, Memory, Usage (tooltip), Created, Notes, Actions (Delete, Hide/Unhide)

- Create Index dialog: field picker (SchemaStore), per-field asc/desc, type selector with type-specific options, large-collection warning, validation

- Footer with totals; ConfirmDialog for destructive delete

- Reuses Fluent UI v9 + existing theme tokens; no new runtime dependencies

Backend integration: all UI <-> backend traffic flows through src/webviews/documentdb/indexView/indexViewRouter.ts. Every procedure has a BACKEND INTEGRATION POINT comment block for the backend engineer documenting expected shape, currently-called ClustersClient method, and follow-ups.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@khelanmodi khelanmodi force-pushed the dev/khelanmodi/index-management-ui branch from 98e708c to 72ddf92 Compare June 3, 2026 19:49
@khelanmodi khelanmodi requested a review from tnaum-ms June 3, 2026 19:51
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

✅ Code Quality Checks

Check Status How to fix
Localization (l10n) ✅ Passed
ESLint ✅ Passed
Prettier formatting ✅ Passed

This comment is updated automatically on each push.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

📦 Build Size Report

Metric Base (main) PR Delta
VSIX (vscode-documentdb-0.9.0-beta.vsix) 7.60 MB 7.62 MB ⬆️ +23 KB (+0.3%)
Webview bundle (views.js) 5.88 MB 5.97 MB ⬆️ +94 KB (+1.6%)

Download artifact · updated automatically on each push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants