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(sanity): editing version document using Actions API #8302

Merged
merged 3 commits into from
Jan 17, 2025

Conversation

juice49
Copy link
Contributor

@juice49 juice49 commented Jan 16, 2025

Description

This branch fixes version editing when using the Actions API, and enables the Actions API in the default workspace in Test Studio.

When using the Actions API to edit a version document, the draftId option must refer to the version id. Previously, the draft document would be patched instead, which is incorrect.

This branch also temporarily changes the API version to vX when executing Actions API actions. At this point in time, the Actions API can only execute certain actions for version documents (e.g. sanity.action.document.edit) in vX.

What to review

Editing a version document successfully calls the edit action for the version document. The draft and published documents must not be affected.

Testing

Added unit test in packages/sanity/src/core/store/_legacy/document/document-pair/serverOperations/patch.test.ts.

Copy link

vercel bot commented Jan 16, 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 17, 2025 0:26am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2025 0:26am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2025 0:26am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Jan 17, 2025 0:26am
test-next-studio ⬜️ Ignored (Inspect) Jan 17, 2025 0:26am

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Jan 16, 2025

Component Testing Report Updated Jan 17, 2025 12:30 AM (UTC)

❌ Failed Tests (2) -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 1m 3s 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) 50s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 26s 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 7s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 28s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 2m 1s 21 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 12s 3 9 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 1m 42s 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 16, 2025

⚡️ Editor Performance Report

Updated Fri, 17 Jan 2025 00:31:21 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 27.0 efps (37ms) 29.0 efps (35ms) -3ms (-6.8%)
article (body) 67.8 efps (15ms) 71.9 efps (14ms) -1ms (-/-%)
article (string inside object) 27.0 efps (37ms) 29.4 efps (34ms) -3ms (-8.1%)
article (string inside array) 25.6 efps (39ms) 27.8 efps (36ms) -3ms (-7.7%)
recipe (name) 50.0 efps (20ms) 62.5 efps (16ms) -4ms (-20.0%)
recipe (description) 58.8 efps (17ms) 62.5 efps (16ms) -1ms (-5.9%)
recipe (instructions) 99.9+ efps (5ms) 99.9+ efps (5ms) +0ms (-/-%)
synthetic (title) 18.5 efps (54ms) 20.4 efps (49ms) -5ms (-9.3%)
synthetic (string inside object) 19.0 efps (53ms) 20.2 efps (50ms) -3ms (-5.7%)

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) 37ms 40ms 69ms 358ms 171ms 10.3s
article (body) 15ms 16ms 32ms 153ms 223ms 5.3s
article (string inside object) 37ms 38ms 46ms 181ms 152ms 6.7s
article (string inside array) 39ms 41ms 44ms 64ms 131ms 6.7s
recipe (name) 20ms 22ms 24ms 40ms 0ms 7.1s
recipe (description) 17ms 18ms 21ms 36ms 0ms 4.4s
recipe (instructions) 5ms 7ms 9ms 11ms 0ms 3.0s
synthetic (title) 54ms 59ms 64ms 320ms 1076ms 13.5s
synthetic (string inside object) 53ms 55ms 62ms 443ms 1044ms 8.2s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 35ms 62ms 77ms 527ms 1026ms 11.8s
article (body) 14ms 16ms 22ms 187ms 256ms 5.2s
article (string inside object) 34ms 36ms 39ms 69ms 126ms 6.5s
article (string inside array) 36ms 38ms 44ms 137ms 0ms 6.5s
recipe (name) 16ms 18ms 20ms 38ms 0ms 6.9s
recipe (description) 16ms 18ms 19ms 39ms 0ms 4.6s
recipe (instructions) 5ms 7ms 8ms 26ms 0ms 3.1s
synthetic (title) 49ms 50ms 55ms 127ms 562ms 12.4s
synthetic (string inside object) 50ms 55ms 61ms 534ms 1196ms 8.9s

📚 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.

At this point in time, the Actions API can only execute certain actions
for version documents (e.g. `sanity.action.document.edit`) in `vX`.
When using the Actions API to edit a version document, the `draftId`
option must refer to the version id.

Previously, the draft document would be patched instead, which is
incorrect.
@juice49 juice49 requested review from cngonzalez and pedrobonamin and removed request for cngonzalez January 17, 2025 00:29
Copy link
Contributor

@pedrobonamin pedrobonamin left a comment

Choose a reason for hiding this comment

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

Tested it and it looks good to me, thanks for working this out @juice49 !
Great work!

@juice49 juice49 merged commit edbb298 into corel Jan 17, 2025
53 of 55 checks passed
@juice49 juice49 deleted the fix/sapp-2021/actions-api-for-versions branch January 17, 2025 17:38
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