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

feat(core): only use vX client if strictly necessary #8466

Merged
merged 12 commits into from
Feb 3, 2025

Conversation

pedrobonamin
Copy link
Contributor

@pedrobonamin pedrobonamin commented Jan 31, 2025

Description

In the initial implementation of content releases we modified the default studio client to use vX this was needed because all the new functions and versions documents checks are only available in vX for now.

Now, we are aiming to merge this to next in the coming week, given that we don't want to use the vX client everywhere because of the risk this involves we are adding this changes in which the client will use vX only if it is strictly necessary.
This will be when a user is doing actions over a version document or is using anything inside the releases plugin.

This PR has been divided in logical pieces and will probably be easier to review commit per commit.

Changes in presentation tool

I've added the checks where I noticed that we are using perspectives and could lead to errors if the client is not using the releases client (vX for now) in this commit
I've left out the following files, which I think don't require this.

  • packages/sanity/src/presentation/useMainDocument.ts
  • packages/sanity/src/presentation/usePreviewUrl.ts
  • packages/sanity/src/presentation/useVercelBypassSecret.ts
  • packages/sanity/src/presentation/preview/SharePreviewMenu.tsx

What to review

Testing

vX client should only be used when a perspective is defined or when operating in a version document.
This can be verified by opening a document in draft and doing edits, the changes should be done using the 2024 client.
If you switch to a version now the client should use vX
The same with search.

Notes for release

@pedrobonamin pedrobonamin requested a review from a team as a code owner January 31, 2025 13:21
@pedrobonamin pedrobonamin requested review from cngonzalez and removed request for a team January 31, 2025 13:21
Copy link

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

@pedrobonamin pedrobonamin requested review from bjoerge and juice49 and removed request for cngonzalez January 31, 2025 13:21
Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Jan 31, 2025

Component Testing Report Updated Feb 3, 2025 1:29 PM (UTC)

❌ Failed Tests (2) -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 1m 8s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 13s 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) 52s 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) 27s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 1m 8s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 33s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 2m 4s 21 0 0
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 31, 2025

⚡️ Editor Performance Report

Updated Mon, 03 Feb 2025 13:31:00 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 27.8 efps (36ms) 24.7 efps (41ms) +5ms (+12.5%)
article (body) 67.6 efps (15ms) 67.6 efps (15ms) +0ms (-/-%)
article (string inside object) 27.0 efps (37ms) 25.6 efps (39ms) +2ms (+5.4%)
article (string inside array) 24.4 efps (41ms) 22.5 efps (45ms) +4ms (+8.5%)
recipe (name) 50.0 efps (20ms) 47.6 efps (21ms) +1ms (+5.0%)
recipe (description) 55.6 efps (18ms) 52.6 efps (19ms) +1ms (+5.6%)
recipe (instructions) 99.9+ efps (5ms) 99.9+ efps (6ms) +1ms (-/-%)
synthetic (title) 18.5 efps (54ms) 17.7 efps (57ms) +3ms (+4.6%)
synthetic (string inside object) 18.9 efps (53ms) 18.9 efps (53ms) +0ms (-/-%)

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) 36ms 39ms 54ms 191ms 180ms 11.2s
article (body) 15ms 17ms 31ms 152ms 204ms 5.2s
article (string inside object) 37ms 41ms 47ms 149ms 297ms 7.3s
article (string inside array) 41ms 45ms 50ms 309ms 384ms 7.0s
recipe (name) 20ms 21ms 24ms 47ms 0ms 7.5s
recipe (description) 18ms 19ms 21ms 36ms 0ms 4.5s
recipe (instructions) 5ms 7ms 9ms 18ms 0ms 3.2s
synthetic (title) 54ms 57ms 61ms 299ms 966ms 12.8s
synthetic (string inside object) 53ms 60ms 85ms 647ms 1531ms 9.1s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 41ms 44ms 53ms 388ms 864ms 11.6s
article (body) 15ms 19ms 30ms 114ms 449ms 5.7s
article (string inside object) 39ms 41ms 46ms 229ms 328ms 6.9s
article (string inside array) 45ms 47ms 53ms 78ms 290ms 7.3s
recipe (name) 21ms 23ms 25ms 45ms 0ms 7.1s
recipe (description) 19ms 20ms 21ms 36ms 0ms 4.6s
recipe (instructions) 6ms 7ms 8ms 17ms 0ms 3.1s
synthetic (title) 57ms 60ms 80ms 362ms 1091ms 13.4s
synthetic (string inside object) 53ms 58ms 86ms 648ms 1593ms 9.0s

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

options: {
// how to insert new document ids. Defaults to `sorted`
insert?: 'sorted' | 'prepend' | 'append'
} = {},
Copy link
Member

Choose a reason for hiding this comment

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

thoughts on making apiVersion part of options here?

apiVersion: 'vX',
})
.fetch<SanityDocumentLike[]>(query, params, options)
const apiVersion = isReleasePerspective(options?.perspective as string | string[] | undefined)
Copy link
Member

Choose a reason for hiding this comment

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

Nice way of feature-detecting what version to use!

Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a //todo: remove once releases is opt-out?

@@ -20,7 +20,7 @@ export const publish: OperationImpl<[], DisabledReason> = {
throw new Error('cannot execute "publish" when draft is missing')
}

return actionsApiClient(client).observable.action(
return actionsApiClient(client, idPair).observable.action(
Copy link
Member

Choose a reason for hiding this comment

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

I think we should make a note to remove these added params after backend APIs stabilize

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a TODO, thanks!

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.

None yet

2 participants