feat(right-click): copy element and document as shell syntax COMPASS-10041#8245
Open
mabaasit wants to merge 10 commits into
Open
feat(right-click): copy element and document as shell syntax COMPASS-10041#8245mabaasit wants to merge 10 commits into
mabaasit wants to merge 10 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds “shell syntax” serialization/copying for documents and elements (intended for right-click / context-menu copy flows) and wires the chosen copy format into telemetry.
Changes:
- Add
toShellSyntax()serialization forDocument/Elementand use it for “copy as shell syntax” flows. - Extend document context menus to offer “Copy document as Shell Syntax” vs “Copy document as EJSON”, and record
formatin the “Document Copied” telemetry event. - Add/adjust unit tests for the new serialization and updated UI copy actions.
Code quality / risk notes (high level):
- There are a couple of API/type-surface changes that can unintentionally break callers (Element serializer API parity,
copyToClipboardtyping) and should be addressed before merge. - Serializer fallback behavior should be consistent with existing
toJSString()usage patterns in the repo to avoid returning/copying an empty string.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/hadron-document/test/element.test.ts | Replaces element serialization tests with toShellSyntax coverage. |
| packages/hadron-document/test/document.test.ts | Adds Document#toShellSyntax tests. |
| packages/hadron-document/src/utils.ts | Introduces shell-syntax options type. |
| packages/hadron-document/src/element.ts | Adds element shell-syntax serialization via toJSString. |
| packages/hadron-document/src/document.ts | Adds document shell-syntax serialization via toJSString. |
| packages/hadron-document/package.json | Adds mongodb-query-parser dependency for shell-syntax serialization. |
| packages/compass-telemetry/src/telemetry-events.ts | Adds format field to “Document Copied” event schema. |
| packages/compass-crud/src/stores/crud-store.ts | Updates clipboard copy action to support format + telemetry. |
| packages/compass-crud/src/stores/crud-store.spec.ts | Adds tests for EJSON vs shell-syntax clipboard output. |
| packages/compass-crud/src/components/use-document-item-context-menu.tsx | Adds context menu actions for copying as EJSON vs shell syntax. |
| packages/compass-crud/src/components/use-document-item-context-menu.spec.tsx | Updates context menu tests for new copy items and format args. |
| packages/compass-crud/src/components/json-editor.tsx | Updates copy behavior to explicitly copy as EJSON. |
| packages/compass-crud/src/components/editable-document.tsx | Updates copy behavior to explicitly copy as EJSON. |
| packages/compass-crud/src/components/document-list-view-item.spec.tsx | Updates expectations for new copy context menu labels. |
| packages/compass-crud/src/components/document-json-view-item.spec.tsx | Updates expectations for new copy context menu labels. |
| packages/compass-components/src/components/document-list/element.tsx | Adds “Copy value” and switches copy output to shell syntax. |
| packages/compass-components/src/components/document-list/element.spec.tsx | Adds test for “Copy value” and updates quoting expectations. |
| packages/compass-components/src/components/context-menu.tsx | Adjusts menu sizing to accommodate updated menu item labels. |
Comment on lines
19
to
24
| import type { | ||
| BSONArray, | ||
| BSONObject, | ||
| BSONValue, | ||
| HadronEJSONOptions, | ||
| HadronShellSyntaxOptions, | ||
| } from './utils'; |
Comment on lines
419
to
433
| /** | ||
| * Generate the Extended JSON string representation of this element. | ||
| * Generate the Shell Syntax string representation of this element. | ||
| * | ||
| * @returns The Extended JSON string. | ||
| * @returns The Shell Syntax string. | ||
| */ | ||
| toEJSON( | ||
| toShellSyntax( | ||
| source: 'original' | 'current' = 'current', | ||
| options: HadronEJSONOptions = {} | ||
| options: HadronShellSyntaxOptions = {} | ||
| ): string { | ||
| const generated = | ||
| source === 'original' | ||
| ? this.generateOriginalObject() | ||
| : this.generateObject(); | ||
| return objectToIdiomaticEJSON(generated, options); | ||
| return toJSString(generated, options.indent) ?? '{}'; | ||
| } |
…d-document-right-click
mabaasit
force-pushed
the
crud-document-right-click
branch
from
July 16, 2026 11:25
5e160b9 to
b3acf77
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Would be merged after Rhys's refactor PR is merged.
Description
Checklist
Motivation and Context
Open Questions
Dependents
Types of changes