Skip to content

Conversation

@ivandevp
Copy link
Collaborator

@ivandevp ivandevp commented Feb 4, 2026

Description

Add comprehensive support for UUID types (UUID, LegacyJavaUUID, LegacyCSharpUUID, LegacyPythonUUID) in MongoDB Compass's document editing interface.

edit-uuid-support.mov

Changes

hadron-type-checker:

  • Add 4 new types to TypeCastMap: UUID, LegacyJavaUUID, LegacyCSharpUUID, LegacyPythonUUID
  • Export UUID_REGEX for validation
  • Implement casting functions with proper byte-order conversions for legacy UUID formats
  • Modify type() method to accept optional legacyUUIDEncoding parameter

hadron-document:

  • Add UUID_TYPES constant and UUIDType type to Element
  • Implement UUIDEditor for editing UUID values as strings with validation
  • Modify changeType() to explicitly set currentType for UUID types
  • Update isValueEditable() to allow UUID editing
  • Convert Binary subtype 04 to $uuid format in JSON view for better readability

compass-components:

  • Add display components: UUIDValue, LegacyJavaUUIDValue, LegacyCSharpUUIDValue, LegacyPythonUUIDValue

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
  • If this change could impact the load on the MongoDB cluster, please describe the expected and worst case impact
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

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)

…10194

Add comprehensive support for UUID types (UUID, LegacyJavaUUID, LegacyCSharpUUID,
LegacyPythonUUID) in the document editing interface.

Changes include:
- Add UUID types to type dropdown menu in document editor
- Implement UUIDEditor for editing UUID values as strings
- Add byte-order conversion for legacy UUID formats
- Display UUID (subtype 4) as $uuid format in JSON view
- Standardize on single quotes for UUID display consistency
- Pass legacyUUIDDisplayEncoding preference to table view
@ivandevp ivandevp requested a review from a team as a code owner February 4, 2026 13:39
@ivandevp ivandevp requested review from Anemy and Copilot February 4, 2026 13:39
@github-actions github-actions bot added the feat label Feb 4, 2026
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 adds comprehensive support for UUID types (UUID, LegacyJavaUUID, LegacyCSharpUUID, LegacyPythonUUID) in MongoDB Compass's document editing interface, enabling users to view and edit both standard UUID (Binary subtype 4) and legacy UUID formats (Binary subtype 3) with proper byte-order handling.

Changes:

  • Added four new UUID types to the type system with proper casting and validation
  • Implemented UUID-specific editor and display components with appropriate byte-order conversions
  • Added context-aware UUID display based on legacy encoding preferences

Reviewed changes

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

Show a summary per file
File Description
packages/hadron-type-checker/src/type-checker.ts Added UUID types to TypeCastMap, implemented casting functions with byte-order conversions, and extended type() method to accept legacyUUIDEncoding parameter
packages/hadron-type-checker/src/index.ts Exported UUID_REGEX for validation
packages/hadron-type-checker/test/type-checker.test.ts Updated tests to include new UUID types in expected type lists
packages/hadron-document/src/element.ts Added UUID_TYPES constant, modified changeType() and isValueEditable() to handle UUID types
packages/hadron-document/src/editor/uuid.ts Implemented UUIDEditor with byte-order conversion logic for all UUID formats
packages/hadron-document/src/editor/index.ts Integrated UUIDEditor into the editor system
packages/hadron-document/src/utils.ts Added base64 to UUID string conversion for JSON view
packages/hadron-document/test/editor/uuid.spec.ts Added comprehensive tests for UUID editor functionality
packages/compass-components/src/components/bson-value.tsx Added display components for all UUID types and updated quote style from double to single
packages/compass-components/src/components/bson-value.spec.tsx Updated test expectations for quote style change
packages/compass-components/src/components/document-list/element.tsx Added getDisplayType() function to determine UUID display type based on context
packages/compass-components/src/components/document-list/element-editors.tsx Added UUID-specific input editor with validation styling
packages/compass-components/src/components/document-list/index.ts Exported LegacyUUIDDisplayContext
packages/compass-crud/src/components/document-list.tsx Added legacyUUIDDisplayEncoding preference to document list
packages/compass-crud/src/components/table-view/document-table-view.tsx Propagated legacyUUIDDisplayEncoding to table cells
packages/compass-crud/src/components/table-view/cell-renderer.tsx Added LegacyUUIDDisplayContext.Provider to cell renderer

@codeowners-service-app
Copy link

Assigned mabaasit for team compass-developers because Anemy is out of office.

@ivandevp ivandevp added the no release notes Fix or feature not for release notes label Feb 4, 2026
ivandevp and others added 9 commits February 4, 2026 11:08
Address code review feedback by extracting duplicated byte reversal logic
into shared utility functions in hadron-type-checker:
- uuidHexToString: converts hex string to UUID format with hyphens
- reverseJavaUUIDBytes: reverses byte order for Java legacy UUID format
- reverseCSharpUUIDBytes: reverses byte order for C# legacy UUID format

These utilities are now used in both type-checker.ts and uuid.ts,
eliminating code duplication and improving maintainability.
Address code review feedback by using useMemo for the UUID input style
object instead of creating it inline on every render.
When changing from one UUID type to another (e.g., LegacyCSharpUUID to
LegacyJavaUUID), the system was producing corrupted data because toString()
was being called on Binary objects.

This fix:
- Adds convertBinaryUUID() function that properly handles encoding/decoding
- Updates changeType() to detect UUID-to-UUID conversions and use the special
  conversion function
- Ensures the Binary is first decoded using the source encoding, then
  re-encoded using the target encoding
…value.tsx

Removes duplicated byte reversal logic (toUUIDWithHyphens, toLegacyJavaUUID,
toLegacyCSharpUUID, toLegacyPythonUUID) and uses the shared utilities
(uuidHexToString, reverseJavaUUIDBytes, reverseCSharpUUIDBytes) from
hadron-type-checker instead.
- Modified isValueEditable() in element.ts to allow editing Binary UUIDs (subtype 3 and 4)
- Updated useElementEditor() in element.tsx to use display type for editor selection
- Updated UUIDEditor constructor to accept displayType parameter
- Modified UUIDEditor start() and complete() methods to preserve UUID type during editing
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.

1 participant