Skip to content

feat(compass-indexes): add index build progress COMPASS-9495 #7200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

nbbeeken
Copy link
Contributor

@nbbeeken nbbeeken commented Aug 15, 2025

Description

Add a percentage to the index build row in the table if it is in progress.

https://jira.mongodb.org/browse/COMPASS-9495

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature - parity with legacy DE
  • Dependency update
  • Misc

Open Questions

For reviewers:

  • Did I make good use of hooks by writing useIndexProgress?
    • No 😅
  • The getInProgressIndexInfo used to just list stub indexes because even in progress ones would be listed as "ready" while they continued to build on the server. We now will list "real" indexes via this function. Is that the right approach?

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)
Screen.Recording.2025-08-15.at.2.29.25.PM.mov
index_finish.mov

@nbbeeken nbbeeken marked this pull request as ready for review August 15, 2025 19:18
@Copilot Copilot AI review requested due to automatic review settings August 15, 2025 19:18
@nbbeeken nbbeeken requested a review from a team as a code owner August 15, 2025 19:18
Copy link
Contributor

@Copilot 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 adds index build progress tracking to the MongoDB Compass indexes table, showing a percentage indicator when indexes are being built. The implementation introduces a new hook for polling index progress via currentOp command and updates the UI to display build progress and a spinner for in-progress indexes.

  • Adds useIndexProgress hook for tracking index build progress via polling
  • Updates Redux state to track progress percentage for in-progress indexes
  • Modifies UI components to display progress indicators and spinners for building indexes

Reviewed Changes

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

Show a summary per file
File Description
test/setup-store.ts Adds mock currentOp method to test data service
src/stores/store.ts Extends data service type to include currentOp for progress tracking
src/modules/regular-indexes.ts Adds progress tracking logic, new actions, and getIndexesProgress thunk
src/modules/regular-indexes.spec.ts Adds tests for index progress tracking functionality
src/hooks/use-index-progress.ts New custom hook for managing index build progress polling
src/components/regular-indexes-table/regular-indexes-table.tsx Integrates progress hook and updates index filtering logic
src/components/regular-indexes-table/regular-indexes-table.spec.tsx Updates tests to mock the progress hook
src/components/regular-indexes-table/regular-index-actions.tsx Adds progress display UI with spinner and percentage

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

};

const styles = css({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Super nit: it's a good practice to give this a more descriptive name, something like indexActionsContainerStyles

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

<div className={styles}>
{isBuilding && (
<>
<Body>Building... {progress | 0}%</Body>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit

Suggested change
<Body>Building... {progress | 0}%</Body>
<Body>Building {progress | 0}%</Body>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
gap: '8px',
Copy link
Collaborator

Choose a reason for hiding this comment

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

For spacing we always try to use the spacing export from compass-components / leafygreen if value is available

Suggested change
gap: '8px',
gap: spacing[200],

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
gap: '8px',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto spacing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

<>
<Body>Building... {progress | 0}%</Body>
<SpinLoader
size={16}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto spacing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

_id: '$command.indexes.name',
progress: { $first: '$progress' },
},
}, // group on index name
Copy link
Collaborator

@gribnoysup gribnoysup Aug 22, 2025

Choose a reason for hiding this comment

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

I guess you can just add something like { $project: { progress: { $floor: { $divide: ['$progress.done', '$progress.total'] } } } } here and leave all the work of calculating the values the server 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well I depend on the value not being floored but otherwise SGTM!

// only be possible in cases of "index with the same name already exists")
// Keep in-progress indexes that are still actively building, but remove:
// 1. Failed indexes (status: 'failed')
// 2. Completed indexes (real index exists and progress >= 100%)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see this filtering on progress value happening, seems like we're keeping them as regular ones at the moment, is this comment outdated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea let's just use the comments inside the filtering to reduce confusion

@@ -43,12 +56,27 @@ const IndexActions: React.FunctionComponent<IndexActionsProps> = ({
[onDeleteFailedIndexClick, index]
);

const progress = index.buildProgress * 100;
const isBuilding = progress > 0 && progress < 100;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure I follow this logic, we either have these in "in-progress" bucket or in "regular", how are we expecting this UI to show up for both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps I've over engineered a bit, and I can confirm this again. IIUC the inprogress state is a "fake" one to make the UI show the user's index in the table right away after they create it. It changes to "ready" as soon as we see the index in a listIndexes response. I think the progress logic is left over here from when I would show users 0% when we had a true 0 value. I think I can remove this.

@nbbeeken nbbeeken requested a review from gribnoysup August 22, 2025 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants