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): allow discovery of all document versions using groq2024 search #8775

Merged
merged 3 commits into from
Mar 7, 2025

Conversation

juice49
Copy link
Contributor

@juice49 juice49 commented Feb 26, 2025

Description

The groq2024 search strategy currently relies on Content Lake perspectives to collate documents. This means global search is unable to discover document versions outside of the selected perspective.

This branch changes back to the raw perspective and returns to client-side collation in order to make all document versions discoverable via global search, regardless of the selected perspective.

What to review

Global search: discoverability of versions outside the selected perspective.
Document lists: should be unchanged.

Testing

Updated unit tests and tested manually.

Copy link

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

@juice49 juice49 marked this pull request as ready for review February 27, 2025 09:20
@juice49 juice49 requested a review from a team as a code owner February 27, 2025 09:20
@juice49 juice49 requested review from bjoerge and removed request for a team February 27, 2025 09:20
@juice49 juice49 marked this pull request as draft February 27, 2025 09:20
@juice49 juice49 force-pushed the fix/groq-2024-search-versions branch from f8dbf32 to a80672c Compare February 27, 2025 09:21
@juice49 juice49 changed the title fix(sanity): collate versions separately to draft fix(sanity): allow discovery of all document versions using groq2024 search Feb 27, 2025
Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Feb 27, 2025

Component Testing Report Updated Mar 6, 2025 4:04 PM (UTC)

❌ Failed Tests (3) -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 1m 10s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 13s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ❌ Failed (Inspect) 1m 57s 4 0 2
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 39s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 23s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 13s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 25s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 1m 3s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 34s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ❌ Failed (Inspect) 2m 22s 20 0 1
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 11s 3 9 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 23s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 1m 30s 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 Feb 27, 2025

⚡️ Editor Performance Report

Updated Thu, 06 Mar 2025 16:02:57 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 23.8 efps (42ms) 21.3 efps (47ms) +5ms (+11.9%)
article (body) 63.7 efps (16ms) 63.3 efps (16ms) +0ms (-/-%)
article (string inside object) 25.6 efps (39ms) 23.5 efps (43ms) +4ms (+9.0%)
article (string inside array) 21.7 efps (46ms) 21.7 efps (46ms) +0ms (-/-%)
recipe (name) 47.6 efps (21ms) 45.5 efps (22ms) +1ms (+4.8%)
recipe (description) 50.0 efps (20ms) 50.0 efps (20ms) +0ms (-/-%)
recipe (instructions) 99.9+ efps (6ms) 99.9+ efps (6ms) +0ms (-/-%)
synthetic (title) 20.0 efps (50ms) 16.1 efps (62ms) +12ms (+24.0%) 🔴
synthetic (string inside object) 20.0 efps (50ms) 16.8 efps (60ms) +10ms (+19.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) 42ms 47ms 70ms 319ms 437ms 10.6s
article (body) 16ms 18ms 24ms 244ms 297ms 6.1s
article (string inside object) 39ms 41ms 45ms 176ms 128ms 6.9s
article (string inside array) 46ms 48ms 52ms 302ms 387ms 7.6s
recipe (name) 21ms 24ms 29ms 51ms 6ms 8.2s
recipe (description) 20ms 20ms 22ms 26ms 0ms 4.6s
recipe (instructions) 6ms 8ms 9ms 11ms 0ms 3.4s
synthetic (title) 50ms 54ms 62ms 196ms 652ms 12.1s
synthetic (string inside object) 50ms 52ms 57ms 254ms 702ms 7.8s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 47ms 60ms 91ms 305ms 715ms 11.8s
article (body) 16ms 19ms 42ms 185ms 359ms 6.1s
article (string inside object) 43ms 45ms 48ms 172ms 470ms 7.6s
article (string inside array) 46ms 49ms 53ms 64ms 394ms 7.7s
recipe (name) 22ms 23ms 30ms 66ms 7ms 7.9s
recipe (description) 20ms 21ms 22ms 28ms 0ms 4.7s
recipe (instructions) 6ms 7ms 9ms 36ms 0ms 3.4s
synthetic (title) 62ms 67ms 78ms 119ms 1650ms 14.8s
synthetic (string inside object) 60ms 62ms 67ms 428ms 1740ms 9.4s

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

@juice49 juice49 force-pushed the fix/groq-2024-search-versions branch from a80672c to 3be2dc4 Compare February 27, 2025 09:44
juice49 added a commit that referenced this pull request Feb 27, 2025
The document collator currently inadvertently works for version
documents simply because it assigns them to the `draft` property.

This commit clarifies the situation by adding a dedicated `versions`
property to the collator.

In practice, Studio behaviour should be unchanged.
juice49 added a commit that referenced this pull request Feb 27, 2025
This property was unused, and computed incorrectly, referring to
`doc.id` instead of `doc._id`.
@juice49 juice49 force-pushed the fix/groq-2024-search-versions branch from 3be2dc4 to 21e7565 Compare February 27, 2025 09:49
Copy link
Contributor

github-actions bot commented Feb 27, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 42% 54258 / 129169
🔵 Statements 42% 54258 / 129169
🔵 Functions 46.87% 2722 / 5807
🔵 Branches 79.38% 10156 / 12793
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/sanity/src/core/search/groq2024/createGroq2024Search.ts 8% 100% 0% 8% 12-23, 32-77
packages/sanity/src/core/search/groq2024/createSearchQuery.ts 98.05% 83.72% 100% 98.05% 86-87
packages/sanity/src/core/studio/components/navbar/search/contexts/search/reducer.ts 89.01% 68.42% 100% 89.01% 164-165, 175-178, 239-247, 249-256, 366-373, 398-404, 492-502, 575
packages/sanity/src/core/util/draftUtils.ts 81.6% 97.36% 70.58% 81.6% 54-55, 133-136, 141-142, 177-181, 185-189, 193-197
packages/sanity/src/structure/panes/documentList/helpers.ts 80% 70.12% 75% 80% 18-19, 22-32, 68-69, 78-79, 92, 95-99, 106-107, 156-157, 182-183, 186-187, 193-194
packages/sanity/src/structure/panes/documentList/types.ts 0% 0% 0% 0%
Generated in workflow #31793 for commit 59a8a82 by the Vitest Coverage Report Action

juice49 added 3 commits March 6, 2025 15:17
The document collator currently inadvertently works for version
documents simply because it assigns them to the `draft` property.

This commit clarifies the situation by adding a dedicated `versions`
property to the collator.

In practice, Studio behaviour should be unchanged.
This property was unused, and computed incorrectly, referring to
`doc.id` instead of `doc._id`.
Copy link
Member

@bjoerge bjoerge left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @juice49

@@ -20,15 +20,13 @@ export function getDocumentKey(value: DocumentListPaneItem, index: number): stri

export function removePublishedWithDrafts(documents: SanityDocumentLike[]): DocumentListPaneItem[] {
return collate(documents).map((entry) => {
const doc = entry.draft || entry.published
const isVersion = doc?.id && isVersionId(doc._id)
const doc = entry.draft || entry.published || entry.versions[0]
Copy link
Member

Choose a reason for hiding this comment

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

we could perhaps consider adding a preference for what version to chose, but probably better to defer that to when we need it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that could be a good idea. Settled for this now just to make things a bit clearer.

@juice49 juice49 marked this pull request as ready for review March 7, 2025 09:27
@juice49 juice49 merged commit ab7c0f4 into next Mar 7, 2025
68 checks passed
juice49 added a commit that referenced this pull request Mar 7, 2025
The document collator currently inadvertently works for version
documents simply because it assigns them to the `draft` property.

This commit clarifies the situation by adding a dedicated `versions`
property to the collator.

In practice, Studio behaviour should be unchanged.
@juice49 juice49 deleted the fix/groq-2024-search-versions branch March 7, 2025 09:28
juice49 added a commit that referenced this pull request Mar 7, 2025
This property was unused, and computed incorrectly, referring to
`doc.id` instead of `doc._id`.
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