Unified search: shared render-type resolution rule#5152
Conversation
A single pure render-type resolver (Decision #1) shared by the server (HTML column selection + meta.renderType echo) and the host (live CardRenderer @CodeRef) so both pick the same type: - an explicit renderType CodeRef wins; - the "native" escape valve resolves to the result's own most-derived type (types[0]); - omitted resolves to the query's filter.on (the common ancestor searched on), falling back to the most-derived type when the query has no filter.on. Governs only the prefer-HTML path; dataOnly results are the actual types (nothing renders), so the request carries no render spec to resolve. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
If you are only testing on the realm server, then don't put teh test in common. that pattern is only used for tests that need to execute in both host and realm -server |
There was a problem hiding this comment.
Pull request overview
This PR introduces a shared, pure “render-type resolution” rule in @cardstack/runtime-common so both the realm-server and host can resolve renderType consistently for unified search (prefer-HTML) results, and adds shared contract tests to lock the behavior down.
Changes:
- Added
resolveRenderType({ renderType, filterOn, types })topackages/runtime-common/search-utils.ts. - Added runtime-common shared contract tests covering the resolution matrix and the
dataOnly“no render spec” invariant. - Wired the new shared tests into the realm-server test runner.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/runtime-common/tests/render-type-resolution-test.ts | Adds shared contract tests for resolveRenderType and verifies dataOnly requests omit render. |
| packages/runtime-common/search-utils.ts | Adds the shared resolveRenderType rule used to pick a rendering CodeRef consistently across server/host. |
| packages/realm-server/tests/render-type-resolution-test.ts | Executes the shared contract tests via runSharedTest in realm-server. |
| packages/realm-server/tests/index.ts | Registers the new realm-server test module so it runs in CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…edicates' into cs-11430-unified-search-render-type-resolution-rule-default-filteron
resolveRenderType is pure runtime-common logic tested only on the realm server, so the tests live directly in packages/realm-server/tests as a self-contained qunit module importing from @cardstack/runtime-common, rather than via the runtime-common/tests + consumer SharedTests indirection (which is reserved for suites that run in both host and realm-server). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Host Test Results 1 files ±0 1 suites ±0 1h 51m 23s ⏱️ -53s Results for commit 1528dda. ± Comparison against earlier commit 2f27551. Realm Server Test Results 1 files ±0 1 suites ±0 10m 28s ⏱️ -16s Results for commit 1528dda. ± Comparison against earlier commit 2f27551. |
| }; | ||
| } | ||
|
|
||
| // The single render-type resolution rule (Decision #1), shared by the server |
There was a problem hiding this comment.
Is this “Decision #1” reference something we want in the comments forever?
There was a problem hiding this comment.
[Claude Code 🤖] Agreed — no, it should not live in the comment forever. Removed in 1528dda; the rule itself stays documented, just without the decision-number reference (comments describe the enduring contract, not the rollout). Swept the same kind of reference (a CS-11433 mention) out of the stacked #5157 too.
Code comments describe the enduring contract, not the rollout/decision history.
Phase 0 of Unify prerendered-card-search and card-search — the single, pure render-type resolution rule (Decision #1) that the server and host both call so they pick the same type. Additive; no behavior change on existing paths.
The rule —
resolveRenderType({ renderType, filterOn, types })(runtime-commonsearch-utils)renderTypeCodeRef → use it;"native"escape valve → the result's own most-derived type (types[0]);filter.on(the common ancestor searched on); when the query has nofilter.on, fall back to the most-derived type.It returns the
CodeRefused both to select the HTML column and echometa.renderType(server, CS-11433) and to drive the liveCardRenderer @codeRef(host, CS-11434). The default isfilter.on— an intended change from today's silenttypes[0]that only takes effect on the unified path; the legacy compat shim (CS-11433) preserves today'stypes[0]-unless-renderTypebehavior until callers migrate. The rule governs only the prefer-HTML path;dataOnlyresults are the actual types, so the request carries no render spec to resolve.Tests
Shared contract tests run via the realm-server runner (5 cases): explicit CodeRef wins;
"native"→types[0]; omitted →filter.on; the missing-filter.onfallback; and that adataOnlyrequest carries norender(so the rule is inapplicable).🤖 Generated with Claude Code