Skip to content
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

fix(core): duplicate should work with version documents #8323

Merged
merged 2 commits into from
Jan 20, 2025

Conversation

pedrobonamin
Copy link
Contributor

Description

Duplicate action should work with versions.
This PR updates how the id is created for the new document created by the duplicate action, if it's a version id it will preserve the version and it won't create a draft document.

What to review

Is this correct?

Testing

Open a version document.
Click on duplicate, it should create a new document in the same release.

Non version documents should continue being created as draft or live documents.

Notes for release

@pedrobonamin pedrobonamin requested a review from a team as a code owner January 18, 2025 14:48
@pedrobonamin pedrobonamin requested review from juice49 and removed request for a team January 18, 2025 14:48
Copy link

vercel bot commented Jan 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 20, 2025 10:36am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 20, 2025 10:36am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 20, 2025 10:36am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Jan 20, 2025 10:36am
test-next-studio ⬜️ Ignored (Inspect) Jan 20, 2025 10:36am

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Jan 18, 2025

Component Testing Report Updated Jan 20, 2025 10:47 AM (UTC)

❌ Failed Tests (3) -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 1m 4s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 12s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ❌ Failed (Inspect) 2m 0s 4 0 2
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 51s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 25s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 14s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 1m 6s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 31s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ❌ Failed (Inspect) 2m 40s 20 0 1
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 13s 3 9 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 1m 43s 21 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

Copy link
Contributor

github-actions bot commented Jan 18, 2025

⚡️ Editor Performance Report

Updated Mon, 20 Jan 2025 10:46:11 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 24.1 efps (42ms) 27.4 efps (37ms) -5ms (-12.0%)
article (body) 69.9 efps (14ms) 67.6 efps (15ms) +0ms (-/-%)
article (string inside object) 27.0 efps (37ms) 29.4 efps (34ms) -3ms (-8.1%)
article (string inside array) 23.8 efps (42ms) 25.6 efps (39ms) -3ms (-7.1%)
recipe (name) 52.6 efps (19ms) 62.5 efps (16ms) -3ms (-15.8%)
recipe (description) 58.8 efps (17ms) 66.7 efps (15ms) -2ms (-11.8%)
recipe (instructions) 99.9+ efps (5ms) 99.9+ efps (5ms) +0ms (-/-%)
synthetic (title) 18.5 efps (54ms) 20.0 efps (50ms) -4ms (-7.4%)
synthetic (string inside object) 18.3 efps (55ms) 20.0 efps (50ms) -5ms (-8.3%)

efps — editor "frames per second". The number of updates assumed to be possible within a second.

Derived from input latency. efps = 1000 / input_latency

Detailed information

🏠 Reference result

The performance result of sanity@latest

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 42ms 51ms 75ms 454ms 882ms 11.2s
article (body) 14ms 17ms 19ms 184ms 220ms 5.5s
article (string inside object) 37ms 41ms 44ms 99ms 146ms 6.6s
article (string inside array) 42ms 44ms 52ms 67ms 142ms 6.8s
recipe (name) 19ms 22ms 25ms 40ms 0ms 6.8s
recipe (description) 17ms 19ms 21ms 50ms 0ms 4.4s
recipe (instructions) 5ms 7ms 9ms 11ms 0ms 3.1s
synthetic (title) 54ms 56ms 59ms 97ms 566ms 13.0s
synthetic (string inside object) 55ms 57ms 65ms 337ms 901ms 8.2s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 37ms 64ms 81ms 424ms 861ms 11.1s
article (body) 15ms 17ms 21ms 117ms 248ms 5.4s
article (string inside object) 34ms 36ms 43ms 191ms 153ms 6.8s
article (string inside array) 39ms 41ms 47ms 187ms 181ms 6.8s
recipe (name) 16ms 17ms 20ms 35ms 0ms 6.9s
recipe (description) 15ms 16ms 18ms 38ms 0ms 4.3s
recipe (instructions) 5ms 7ms 8ms 10ms 0ms 3.0s
synthetic (title) 50ms 52ms 57ms 238ms 658ms 13.7s
synthetic (string inside object) 50ms 52ms 69ms 487ms 997ms 8.7s

📚 Glossary

column definitions

  • benchmark — the name of the test, e.g. "article", followed by the label of the field being measured, e.g. "(title)".
  • latency — the time between when a key was pressed and when it was rendered. derived from a set of samples. the median (p50) is shown to show the most common latency.
  • p75 — the 75th percentile of the input latency in the test run. 75% of the sampled inputs in this benchmark were processed faster than this value. this provides insight into the upper range of typical performance.
  • p90 — the 90th percentile of the input latency in the test run. 90% of the sampled inputs were faster than this. this metric helps identify slower interactions that occurred less frequently during the benchmark.
  • p99 — the 99th percentile of the input latency in the test run. only 1% of sampled inputs were slower than this. this represents the worst-case scenarios encountered during the benchmark, useful for identifying potential performance outliers.
  • blocking time — the total time during which the main thread was blocked, preventing user input and UI updates. this metric helps identify performance bottlenecks that may cause the interface to feel unresponsive.
  • test duration — how long the test run took to complete.

@@ -17,10 +20,19 @@ export const duplicate: OperationImpl<[baseDocumentId: string], 'NOTHING_TO_DUPL
throw new Error('cannot execute on empty document')
}

// When duplicating a version document we need to create it with a version id
const versionId = snapshots.version?._id ? getVersionFromId(snapshots.version._id) : null
Copy link
Contributor

Choose a reason for hiding this comment

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

This process looks good, but it could be nice to get rid of that nested ternary 😅.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed, I think we will need to update the function getVersionFromId name to something like getReleaseIdFromDocumentId it can be confusing with the getVersionId function

Copy link
Contributor

@juice49 juice49 Jan 20, 2025

Choose a reason for hiding this comment

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

Nice. That's a good point. I was also thinking that if getVersionFromId and isVersionId could accept undefined as a parameter, this automatically becomes simpler:

- const versionId = snapshots.version?._id ? getVersionFromId(snapshots.version._id) : null
+ const versionId = getVersionFromId(snapshots.version?._id) ?? null
- release: idPair.versionId ? getVersionFromId(idPair.versionId) : undefined,
+ release: getVersionFromId(idPair.versionId),

(Not a recommended change for this PR, just a thought).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be, I like this simplicity but I also think there is something nice about making the check explicit in the consumers.

Copy link
Contributor

@juice49 juice49 left a comment

Choose a reason for hiding this comment

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

Nice! Looks good to me!

@pedrobonamin pedrobonamin merged commit 6379767 into corel Jan 20, 2025
56 checks passed
@pedrobonamin pedrobonamin deleted the fix-duplicate-action branch January 20, 2025 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants