Skip to content

Conversation

kpamaran
Copy link
Collaborator

@kpamaran kpamaran commented Sep 9, 2025

Description

Jira: https://jira.mongodb.org/browse/CLOUDP-333852
Figma (link)

The confirmation screen allows the user to preview and confirm to the contents sent to the LLM, which respects the setting for whether Generative AI features should send sample data.

Edit: New screenshots using compass Document component instead of leafygreen Code. The result is closer to the Figma

Sample Documents Variant

chat-sample-doc-component-sample-doc-expanded

Schema-only Variant

chat-sample-doc-component-schema-only-collapsed

You will notice that there is no syntax highlighting based on the mongo type in the schema-only variant. That may be viable with the customKeywords prop on the leafygreen Code component, but that requires 4 major version upgrades and may introduce breaking changes.

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

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)

@kpamaran kpamaran requested review from ncarbon and jcobis September 9, 2025 18:47
@kpamaran kpamaran requested a review from a team as a code owner September 9, 2025 18:47
@kpamaran kpamaran added the no release notes Fix or feature not for release notes label Sep 9, 2025
@github-actions github-actions bot added the feat label Sep 9, 2025
? 'A sample of document values from your collection will be sent to an LLM for processing.'
: 'We have identified the following schema from your documents. This schema will be sent to an LLM for processing.';

// todo: should establish if unfinished schema analysis edge case should be handled within the modal or
Copy link
Collaborator

@jcobis jcobis Sep 9, 2025

Choose a reason for hiding this comment

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

Alternatively, we could just disabled button

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I lean towards disabling the button plus updating the hover tooltip. It would be awkward to have a modal open and the user isn't able to act on anything but wait

Copy link
Collaborator

Choose a reason for hiding this comment

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

Feel free to go ahead and do so. We can make the tooltip copy "Schema analysis in progress" for now

Copy link
Collaborator Author

@kpamaran kpamaran Sep 9, 2025

Choose a reason for hiding this comment

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

Net diffs is high in this PR. I think I can weave the tooltip into CLOUDP-333853 which is already small in scope

Copy link
Collaborator

@jcobis jcobis left a comment

Choose a reason for hiding this comment

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

Looks great Kevin! My one note is to perhaps add unit tests for RawSchemaConfirmationScreen

@kpamaran
Copy link
Collaborator Author

kpamaran commented Sep 9, 2025

perhaps add unit tests for RawSchemaConfirmationScreen

@jcobis I made another diff test to organize the confirmation tests better. Can you re-review the test suite under on the schema confirmation step? They test the component's actual connection to redux and props usage; testing it as an unconnected unit would not provide additional coverage

@kpamaran kpamaran requested a review from jcobis September 9, 2025 19:47
: 'Document Schema Identified';

const descriptionText = enableSampleDocumentPassing
? 'A sample of document values from your collection will be sent to an LLM for processing.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I realize this is from Figma, but just going to say, the wording here seems odd, "document value" is somewhat clear but it's definitely not standard terminology. Can this be

Suggested change
? 'A sample of document values from your collection will be sent to an LLM for processing.'
? 'A sample of documens from your collection will be sent to an LLM for processing.'

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Certainly

<Body className={descriptionStyles}>{descriptionText}</Body>
<Code language="javascript" copyable={false} className={codeStyles}>
{enableSampleDocumentPassing
? JSON.stringify(schemaAnalysis.sampleDocument, null, 4)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens with types that are not representible in JSON?

The Figma designs seem to be aiming for something like our DocumentListView component rather than JSON

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to the Document component. I don't think there should be any more representation issues on the schema-only or sample-doc variants

}

if (part.replaceAll('[]', '') === '') {
throw Error("expected fieldPath to have a non-empty part before '[]'");
Copy link
Collaborator

Choose a reason for hiding this comment

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

The test is stricter than the error message here. Also, maybe not strictly necessary, but in JS you'd generally use

Suggested change
throw Error("expected fieldPath to have a non-empty part before '[]'");
throw new Error("expected fieldPath to have a non-empty part before '[]'");

* inputs are required to simulate these unlikely errors.
*/
function validateFieldPath(fieldPath: string) {
const parts = fieldPath.split('.');
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens if a field path element contains a .?

Copy link
Collaborator Author

@kpamaran kpamaran Sep 10, 2025

Choose a reason for hiding this comment

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

Discussed this with @jcobis. I acknowledge that this is possible even if the official docs actively discourage it. We're going to disable the "Generate Mock Data" button in this case with a corresponding tooltip and info-log for now

edit: we're still discussing (link) how to handle this across the whole flow (including the API)

Copy link
Collaborator

Choose a reason for hiding this comment

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

This also has me thinking about fields whose names specifically end in []. Another edge case to consider

Copy link
Collaborator

Choose a reason for hiding this comment

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

Started a Slack Thread

@gribnoysup
Copy link
Collaborator

gribnoysup commented Sep 10, 2025

You will notice that there is no syntax highlighting based on the mongo type in the schema-only variant. That may be viable with the customKeywords prop on the leafygreen Code component, but that requires 4 major version upgrades and may introduce breaking changes.

Any reason you are not using our code editor component in read only mode? It gives a better highlight, more performant, and visualizes large schemas in a more convenient way by collapsing most of the nested fields automatically. This is also more consistent with the rest of the application EDIT: Oh, Anna is right, what you have in the designs looks more like the Document component, not like a code view, but anyway not a leafygreen Code component

)
).to.exist;
// fragment from { "name": "John" }
expect(screen.queryByText('"John"')).to.exist;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use getBy* instead of queryBy* where we check that an element does exist? queryBy* will not throw an error if it doesn't find the element, potentially failing silently.

<div data-testid="raw-schema-confirmation">
{schemaAnalysis.status === 'complete' ? (
<>
<Body className={namespaceStyles}>{namespace}</Body>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like we want to show the namespace on all screens according to Figma. This should probably go in mock-data-generator-modal.tsx so it's shared between all the screens.

@kpamaran
Copy link
Collaborator Author

@addaleax @gribnoysup @ncarbon I addressed latest round of diffs and updated the screenshots. There is a separate thread (link) for any additional design feedback from Maria, which I consider to be a non-blocker and can be followed up on.

);
}

// Check that [] only appears as complete pairs and only at the end of the part
Copy link
Collaborator

Choose a reason for hiding this comment

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

This may be overly stringent actually.

Copy link
Collaborator Author

@kpamaran kpamaran Sep 10, 2025

Choose a reason for hiding this comment

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

Relating to this comment right? #7299 (comment)

I'll remove for now

@kpamaran
Copy link
Collaborator Author

kpamaran commented Sep 10, 2025

On the Evergreen failures. There's one cyclic dependency to resolve due to adding compass-crud as a dep to compass-collection for Document

  • @mongodb-js/compass-query-bar depends on @mongodb-js/compass-collection
  • @mongodb-js/compass-collection depends on @mongodb-js/compass-crud
  • @mongodb-js/compass-crud depends on @mongodb-js/compass-query-bar

The 1st dep is solely used to re-use a type. One naive way to resolve would be to delete the import and duplicate this type.

import type { CollectionTabPluginMetadata } from '@mongodb-js/compass-collection';

The 2nd dep was introduced this PR. Touching the 3rd dep is out of question. I reviewed Document's implementation and it's not quite something that can be moved to compass-components easily

Maybe there's a better alternative I'm not seeing.

@gribnoysup
Copy link
Collaborator

gribnoysup commented Sep 11, 2025

@kpamaran good catch, I'll open a ticket to move the document card completely out of crud, but in the meantime I think you should be able to use DocumentList.Document from @mongodb-js/compass-components instead, that's the main part that visualizes the document, everything else there is indeed actions that are mostly relevant for crud only (maybe with the exception of copy button that you can add with DocumentList.DocumentActionsGroup if you care about it)

@kpamaran kpamaran requested review from addaleax, ncarbon, jcobis and a team September 11, 2025 17:11
borderRadius: spacing[400],
});
// note: the "> div" selector works around the lack of a className prop on HadronDocument
const documentContainerStyles = css`
Copy link
Collaborator

Choose a reason for hiding this comment

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

We prefer object notation over template literals, do you mind changing this back? Also if you want to add a className prop support to the component, feel free to do so

Copy link
Collaborator Author

@kpamaran kpamaran Sep 12, 2025

Choose a reason for hiding this comment

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

went the className prop route

@kpamaran kpamaran requested a review from gribnoysup September 12, 2025 14:47
@kpamaran kpamaran requested a review from ncarbon September 12, 2025 19:28
Copy link
Collaborator

@jcobis jcobis left a comment

Choose a reason for hiding this comment

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

Great work Kevin!

Copy link
Collaborator

@gribnoysup gribnoysup left a comment

Choose a reason for hiding this comment

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

Let's remove unneeded branching logic in the action, otherwise LGTM

@kpamaran kpamaran merged commit 0626ec8 into main Sep 15, 2025
57 of 58 checks passed
@kpamaran kpamaran deleted the mock-data-generator-raw-schema-confirmation-screen branch September 15, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat no release notes Fix or feature not for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants