Skip to content

feat(core): use schema preview selection for search#12925

Open
pedrobonamin wants to merge 1 commit into
mainfrom
sapp-3606
Open

feat(core): use schema preview selection for search#12925
pedrobonamin wants to merge 1 commit into
mainfrom
sapp-3606

Conversation

@pedrobonamin

@pedrobonamin pedrobonamin commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #4775

Fields shown in a list item via a reference (e.g. subtitle: 'author.name') were visible in previews but not searchable — issue #4775. Weight derivation skips references: in getLeafWeights (deriveSearchWeightsFromType.ts) the object-field recursion is gated by !ignoredBuiltInObjectTypes.includes(t.name), and reference is in ignoredBuiltInObjectTypes, so author.name never became a search path — and the query never dereferenced it either.

Now preview select paths that traverse references are resolved to their searchable leaf and compiled to author->name in the query (reusing the same compileFieldPath that orderings use).

Example in books, now search by author.name returns the results because author.name and author.bestFriend.name is part of the book preview select https://github.com/sanity-io/sanity/blob/main/dev/test-studio/schema/book.ts#L169

Screen.Recording.2026-06-03.at.15.56.45.mov

What to review

Testing

Notes for release

@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
auth-test-studio Ready Ready Preview, Comment Jun 3, 2026 2:14pm
page-building-studio Ready Ready Preview, Comment Jun 3, 2026 2:14pm
test-studio Ready Ready Preview, Comment Jun 3, 2026 2:14pm

Request Review

Copilot AI review requested due to automatic review settings June 2, 2026 15:42
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — sanity

Compared against main (163d020a) · v5.30.0 (npm)

sanity

Metric Value vs main (163d020) vs v5.30.0
Internal (raw) 4.55 MB +2.9 KB, +0.1% +3.3 KB, +0.1%
Internal (gzip) 1.05 MB +568 B, +0.1% +659 B, +0.1%
Bundled (raw) 12.24 MB +2.9 KB, +0.0% -91.6 KB, -0.7%
Bundled (gzip) 2.75 MB +549 B, +0.0% -19.7 KB, -0.7%
Import time 1.58s -16ms, -1.0% +53ms, +3.5%

bin:sanity

Metric Value vs main (163d020) vs v5.30.0
Internal (raw) 7.1 KB - -
Internal (gzip) 2.9 KB - -
Bundled (raw) 7.1 KB - -
Bundled (gzip) 2.8 KB - -
Import time 5ms -0ms, -1.9% +0ms, +6.3%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

📚 TypeDoc Generation Result

TypeDoc generated successfully!

  • File size: 8.2M
  • Total exports: 1067
  • Artifact: sanity-typedoc-29d9d50d04424caa13a3ed72836423f978c98c7a

The TypeDoc JSON file has been generated and validated. All documentation scripts completed successfully.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

⚡️ Editor Performance Report

Updated Wed, 03 Jun 2026 14:18:06 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
arrayI18n (simple-en) 55.6 efps (18ms) 52.6 efps (19ms) +1ms (+5.6%)
article (title) 35.1 efps (29ms) 36.4 efps (28ms) -1ms (-3.5%)
article (body) 50.5 efps (20ms) 50.5 efps (20ms) +0ms (-/-%)
article (string inside object) 46.5 efps (22ms) 45.5 efps (22ms) +1ms (+2.3%)
article (string inside array) 45.5 efps (22ms) 43.5 efps (23ms) +1ms (+4.5%)
recipe (name) 90.9 efps (11ms) 99.9+ efps (10ms) -1ms (-/-%)
recipe (description) 50.0 efps (20ms) 50.0 efps (20ms) +0ms (-/-%)
recipe (instructions) 99.9+ efps (10ms) 99.9+ efps (10ms) +0ms (-/-%)
singleString (stringField) 99.9+ efps (7ms) 99.9+ efps (8ms) +1ms (-/-%)
synthetic (title) 58.8 efps (17ms) 55.6 efps (18ms) +1ms (+5.9%)
synthetic (string inside object) 55.6 efps (18ms) 58.8 efps (17ms) -1ms (-5.6%)

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
arrayI18n (simple-en) 18ms 22ms 35ms 68ms 46ms 6.5s
article (title) 29ms 32ms 35ms 66ms 42ms 7.8s
article (body) 20ms 25ms 41ms 97ms 187ms 5.3s
article (string inside object) 22ms 25ms 30ms 55ms 28ms 6.5s
article (string inside array) 22ms 26ms 37ms 59ms 36ms 6.8s
recipe (name) 11ms 15ms 20ms 49ms 4ms 5.5s
recipe (description) 20ms 23ms 26ms 35ms 0ms 4.5s
recipe (instructions) 10ms 12ms 13ms 21ms 0ms 3.1s
singleString (stringField) 7ms 10ms 12ms 26ms 0ms 4.7s
synthetic (title) 17ms 19ms 21ms 103ms 1503ms 9.5s
synthetic (string inside object) 18ms 20ms 21ms 86ms 1181ms 9.2s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
arrayI18n (simple-en) 19ms 23ms 29ms 48ms 18ms 6.4s
article (title) 28ms 31ms 37ms 68ms 26ms 8.0s
article (body) 20ms 26ms 66ms 147ms 240ms 5.9s
article (string inside object) 22ms 25ms 35ms 55ms 28ms 6.6s
article (string inside array) 23ms 28ms 35ms 73ms 9ms 7.1s
recipe (name) 10ms 14ms 17ms 28ms 0ms 5.4s
recipe (description) 20ms 22ms 25ms 35ms 0ms 4.5s
recipe (instructions) 10ms 12ms 13ms 20ms 0ms 3.1s
singleString (stringField) 8ms 10ms 11ms 26ms 0ms 4.7s
synthetic (title) 18ms 20ms 22ms 93ms 1437ms 9.4s
synthetic (string inside object) 17ms 18ms 21ms 87ms 1096ms 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes search behavior where fields shown in list previews via reference traversal (eg subtitle: 'author.name') were displayed but not searchable, by deriving weights for preview select paths that traverse references and compiling those dotted paths into dereferenced GROQ (eg author->name) when building search queries (weighted + groq2024 strategies).

Changes:

  • Extend weight derivation to include preview select paths that traverse references (so they become searchable/boostable).
  • Compile preview-derived dotted paths against the schema into dereferenced GROQ field expressions when generating queries.
  • Add targeted tests covering reference-traversing preview selections for both search strategies.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/sanity/src/core/search/weighted/createSearchQuery.ts Compiles preview-selected dotted paths against schema so reference traversals become -> derefs in weighted search queries.
packages/sanity/src/core/search/weighted/createSearchQuery.test.ts Adds regression test asserting reference preview paths become searchable and number fields don’t become constraints.
packages/sanity/src/core/search/groq2024/createSearchQuery.ts Compiles paths used for scoring/boosting so preview-derived reference traversals are boosted via dereferenced GROQ.
packages/sanity/src/core/search/groq2024/createSearchQuery.test.ts Adds regression test asserting reference preview paths are boosted and non-searchable preview fields are excluded.
packages/sanity/src/core/search/common/deriveSearchWeightsFromType2024.ts Incorporates preview-selection reference traversal weights into the 2024 weight derivation flow.
packages/sanity/src/core/search/common/deriveSearchWeightsFromType.ts Adds getPreviewSelectionPathWeights + reference-following leaf resolution so preview select paths behind references get search weights.
packages/sanity/src/core/search/common/tests/deriveSearchWeightsFromType.test.ts Adds tests for reference preview selection weight derivation and for getPreviewSelectionPathWeights.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/sanity/src/core/search/weighted/createSearchQuery.ts Outdated
Comment thread packages/sanity/src/core/search/weighted/createSearchQuery.ts Outdated
Comment thread packages/sanity/src/core/search/groq2024/createSearchQuery.ts Outdated
Comment thread packages/sanity/src/core/search/groq2024/createSearchQuery.ts Outdated
Comment thread packages/sanity/src/core/search/common/deriveSearchWeightsFromType.ts Outdated
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 42.93% 29454 / 68609
🔵 Statements 35.74% 39640 / 110908
🔵 Functions 33.24% 6264 / 18841
🔵 Branches 26.78% 23848 / 89022
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/sanity/src/core/search/common/deriveSearchWeightsFromType.ts 97.05% 92.66% 100% 100% 78, 188, 191, 261
packages/sanity/src/core/search/common/deriveSearchWeightsFromType2024.ts 87.75% 78.26% 93.33% 93.02% 69, 86, 101-108, 137, 175, 254, 178-215
packages/sanity/src/core/search/groq2024/createSearchQuery.ts 100% 90.32% 100% 100%
packages/sanity/src/core/search/weighted/createSearchQuery.ts 98.43% 84.84% 100% 98.21% 159
Generated in workflow #56715 for commit ea90579 by the Vitest Coverage Report Action

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.

List Previews search ignores reference fields in subtitle section

2 participants