Skip to content

Conversation

@nbbeeken
Copy link
Collaborator

@nbbeeken nbbeeken commented Nov 7, 2025

Description

We now use the same user data string for filesystem and atlas this makes it easier in the future to add data types that should "automatically" work with just additionally support added to the backend.

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
  • Dependency update
  • Misc

Open Questions

I needed to do the work of https://jira.mongodb.org/browse/COMPASS-7080 and add a migration for the existing folder. This is a bit more than expected but didn't feel like the most complex addition to this work. I can break this out to its own change that we merge first if we'd like that.

Dependencies

CCS must support the new endpoints before we ship these changes

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)

@github-actions github-actions bot added the fix label Nov 7, 2025
@nbbeeken nbbeeken added the no release notes Fix or feature not for release notes label Nov 7, 2025
@nbbeeken nbbeeken marked this pull request as ready for review November 7, 2025 22:21
@nbbeeken nbbeeken requested a review from a team as a code owner November 7, 2025 22:21
@nbbeeken nbbeeken requested review from Copilot and tculig and removed request for Copilot November 7, 2025 22:21
Copy link
Member

@Anemy Anemy left a comment

Choose a reason for hiding this comment

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

Nice, changes look good, left 2 questions, not blockers.

Copilot AI review requested due to automatic review settings November 10, 2025 17:12
Copy link
Contributor

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 standardizes user data type strings across filesystem and Atlas implementations by migrating from camelCase to PascalCase naming (e.g., favoriteQueriesFavoriteQueries). This unification simplifies future additions of new data types by ensuring consistent handling between storage backends.

Key changes:

  • Introduced a typed UserDataType union with validation to enforce valid data type strings
  • Added migration support in FileUserData to preserve existing user data during the naming transition
  • Updated all storage factory functions and Atlas service endpoints to use the new PascalCase naming

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/my-queries-storage/src/storage-factories.ts Updated storage factory functions to use PascalCase data types
packages/compass-web/src/entrypoint.tsx Replaced hardcoded type union with assertsUserDataType validation
packages/compass-web/package.json Added compass-user-data dependency
packages/compass-user-data/src/user-data.ts Added UserDataType enum, validation function, and migration support
packages/compass-user-data/src/user-data.spec.ts Added comprehensive migration tests and updated existing tests for new naming
packages/compass-user-data/src/index.ts Exported new UserDataType and assertsUserDataType
packages/compass-shell/src/modules/history-storage.ts Migrated from app-name-based folder to ShellHistory with migration support
packages/compass-shell/src/modules/history-storage.spec.ts Updated test file path to reflect new folder structure
packages/compass-data-modeling/src/services/data-model-storage-web.tsx Updated to use PascalCase DataModelDescriptions
packages/atlas-service/src/atlas-service.ts Replaced inline type union with UserDataType

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

Comment on lines 25 to 28
const oldAppName = getAppName();
if (oldAppName && oldAppName !== 'ShellHistory') {
await this.userData.migrateFromOldFolder(oldAppName);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure what this condition is checking. This will always be true, appName is never going to be ShellHistory

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, was thinking very birds eye view of the file rename process, you're correct!

Copy link
Member

Choose a reason for hiding this comment

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

How do you feel about instead throwing if the appName isn't present and a variable rename? A nit, not a blocker

Suggested change
const oldAppName = getAppName();
if (oldAppName && oldAppName !== 'ShellHistory') {
await this.userData.migrateFromOldFolder(oldAppName);
}
const appName = getAppName();
if (!appName) {
throw new Error('Cannot initialize shell history storage without app name');
}
// We used to store the shell-history in a folder like `MongoDB Compass/shell-history.json`.
await this.userData.migrateFromOldFolder(appName);

@nbbeeken nbbeeken requested a review from Anemy November 10, 2025 18:08
Copy link
Member

@Anemy Anemy left a comment

Choose a reason for hiding this comment

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

lgtm! nice.

One suggestion would be to also include the migration for the Import log path while we're at it so we can mark the COMPASS-7080 ticket done.

compass/packages/compass-import-export/src/utils/get-user-data-file-path.ts

@nbbeeken nbbeeken added release notes and removed no release notes Fix or feature not for release notes labels Nov 10, 2025
@nbbeeken
Copy link
Collaborator Author

TY all for the reviews. This is not mergable until we've put the new endpoints in prod, because I don't want compass-web to be in a state where updating it would break. I will merge this when we've shipped the BE changes.

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.

4 participants