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

chore(core): refactor usePerspective hook #8029

Merged
merged 10 commits into from
Dec 13, 2024

Conversation

pedrobonamin
Copy link
Contributor

@pedrobonamin pedrobonamin commented Dec 13, 2024

Description

Refactors usePerspective hook by removing some ""almost"" duplicated values, which could be derived from the existing values.
Updates the ReleaseDocument interface to match the api
Remove name from ReleaseDocument given it is confusing and we want to enforce internally the use of the getReleaseIdFromReleaseDocumentId function.

What to review

Is something missing?
Could we make something more clear?

Testing

Existing tests have been update to match the new hook

Notes for release

Copy link

vercel bot commented Dec 13, 2024

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 Dec 13, 2024 3:27pm
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 3:27pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 3:27pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 3:27pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2024 3:27pm

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Dec 13, 2024

Component Testing Report Updated Dec 13, 2024 3:17 PM (UTC)

❌ Failed Tests (5) -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 1m 15s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 14s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 42s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 58s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 29s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 16s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ❌ Failed (Inspect) 3m 48s 1 0 5
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 1m 13s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 3m 0s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 52s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 14s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 43s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 29s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 1m 54s 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 Dec 13, 2024

⚡️ Editor Performance Report

Updated Fri, 13 Dec 2024 15:18:46 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 21.3 efps (47ms) 16.7 efps (60ms) +13ms (+27.7%) 🔴
article (body) 59.5 efps (17ms) 63.9 efps (16ms) -1ms (-6.8%)
article (string inside object) 21.3 efps (47ms) 17.5 efps (57ms) +10ms (+21.3%) 🔴
article (string inside array) 20.0 efps (50ms) 15.4 efps (65ms) +15ms (+30.0%) 🔴
recipe (name) 47.6 efps (21ms) 28.6 efps (35ms) +14ms (+66.7%) 🔴
recipe (description) 55.6 efps (18ms) 29.4 efps (34ms) +16ms (+88.9%) 🔴
recipe (instructions) 99.9+ efps (6ms) 99.9+ efps (5ms) -1ms (-/-%)
synthetic (title) 19.0 efps (53ms) 7.1 efps (141ms) +89ms (+168.6%) 🔴
synthetic (string inside object) 20.0 efps (50ms) 7.4 efps (135ms) +85ms (+170.0%) 🔴

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) 47ms 49ms 57ms 197ms 178ms 11.7s
article (body) 17ms 21ms 26ms 103ms 119ms 5.6s
article (string inside object) 47ms 51ms 56ms 177ms 146ms 7.5s
article (string inside array) 50ms 53ms 57ms 215ms 213ms 7.7s
recipe (name) 21ms 22ms 23ms 37ms 0ms 6.7s
recipe (description) 18ms 20ms 22ms 34ms 0ms 4.6s
recipe (instructions) 6ms 8ms 10ms 23ms 0ms 3.2s
synthetic (title) 53ms 56ms 65ms 241ms 523ms 13.8s
synthetic (string inside object) 50ms 54ms 62ms 270ms 799ms 8.2s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 60ms 63ms 73ms 226ms 1069ms 13.5s
article (body) 16ms 18ms 35ms 261ms 514ms 6.2s
article (string inside object) 57ms 63ms 83ms 242ms 1093ms 9.1s
article (string inside array) 65ms 69ms 81ms 281ms 1501ms 9.5s
recipe (name) 35ms 36ms 43ms 89ms 75ms 8.9s
recipe (description) 34ms 36ms 41ms 76ms 29ms 6.2s
recipe (instructions) 5ms 7ms 8ms 42ms 0ms 3.1s
synthetic (title) 141ms 150ms 170ms 610ms 7095ms 22.2s
synthetic (string inside object) 135ms 144ms 158ms 470ms 7118ms 16.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.

@pedrobonamin pedrobonamin force-pushed the corel-use-perspective-refactor branch from 736d1ab to 9175b4d Compare December 13, 2024 14:07
@@ -3,6 +3,7 @@

import {Box, Card, Flex, Text} from '@sanity/ui'
import {AnimatePresence, motion} from 'framer-motion'
import {getReleaseIdFromReleaseDocumentId} from 'sanity'
Copy link
Member

Choose a reason for hiding this comment

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

use '../../util/getReleaseIdFromReleaseDocumentId' instead of sanity alias

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh man, this is so easy to miss, fixed a bunch in a passed commit and it kicks again.
Will do a stab on enabling the eslint to warn us against that

(bundleId: string) => () => {
setPerspective(bundleId)
const handlePerspectiveChange = useCallback(
(perspective: Parameters<typeof setPerspective>[0]) => () => {
Copy link
Member

Choose a reason for hiding this comment

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

Parameters is cool!

Copy link
Member

@jordanl17 jordanl17 left a comment

Choose a reason for hiding this comment

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

Great to add this consistency

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