Skip to content

Fix Rich Markdown embeds becoming broken links in isolated view after save#5588

Draft
FadhlanR wants to merge 1 commit into
mainfrom
cs-12111-embeds-render-in-edit-view-but-become-broken-links-in
Draft

Fix Rich Markdown embeds becoming broken links in isolated view after save#5588
FadhlanR wants to merge 1 commit into
mainfrom
cs-12111-embeds-render-in-edit-view-but-become-broken-links-in

Conversation

@FadhlanR

Copy link
Copy Markdown
Contributor

Background and Goal

A card/file embed inserted into a RichMarkdownField previews correctly in the compose editor but renders as a broken link in the saved isolated/embedded view (CS-12111). This fixes that so a just-added embed resolves in the saved view exactly as it did in compose.

Where to start

  • packages/base/query-field-support.tsensureQueryFieldSearchResource. The reuse branch now rebuilds an inert cached resource; provenance is recorded at creation.
  • packages/base/card-api.gtsFallbackCardStore gains an isFallbackCardStore brand so the query-field layer can recognize the storeless fallback.

Key decisions and non-obvious mechanics

  • Root cause: the compose editor resolves refs via a live getCards search, while the saved isolated view resolves only through the query-backed linkedCards / linkedFiles relationships. That query field's search resource is cached per field-instance and reused unconditionally. When the field is first read in edit mode, getStore returns a FallbackCardStore whose getSearchResource hands back a permanently-empty, non-updating resource (and a just-created card's refs aren't resolved yet). The isolated render then reuses that inert resource → broken link.
  • Fix: record whether a resource was built against the fallback store or before its $this.* query resolved, and rebuild it once a real store / resolvable query is available. It's a one-shot transition — it never fires while still on the fallback store (no loop), and the prerender seed path is untouched.
  • Verified in-app on the dev stack: edit a card with a Rich Markdown body → insert :card[...] → save → isolated now renders the embed resolved (no broken-link box). Regression test added at packages/host/tests/acceptance/markdown-embed-save-isolated-test.gts covering both card and file embeds.

🤖 Generated with Claude Code

… save

A card/file embed inserted into a RichMarkdownField previewed correctly in
the compose editor but rendered as a broken link in the saved isolated view.

The compose editor resolves refs via a live getCards search, while the saved
isolated/embedded view resolves only through the query-backed linkedCards /
linkedFiles relationships. That query field's search resource is cached per
field-instance and reused unconditionally. When the field is first read in
edit mode, getStore returns a FallbackCardStore whose getSearchResource hands
back a permanently-empty, non-updating resource (and a just-created card's
refs aren't resolved yet). The isolated render then reuses that inert resource
and shows the embed as broken.

ensureQueryFieldSearchResource now records whether a resource was built against
the fallback store or before its query resolved, and rebuilds it once a real
store / resolvable query is available. This is a one-shot transition that never
fires while still on the fallback store (no loop) and leaves the prerender seed
path untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Preview deployments

Host Test Results

    1 files      1 suites   2h 44m 54s ⏱️
3 597 tests 3 580 ✅ 15 💤 0 ❌ 2 🔥
3 616 runs  3 597 ✅ 15 💤 2 ❌ 2 🔥

Results for commit 073989e.

For more details on these errors, see this check.

Realm Server Test Results

    1 files      1 suites   15m 1s ⏱️
1 933 tests 1 932 ✅ 0 💤 1 ❌
2 012 runs  2 011 ✅ 0 💤 1 ❌

Results for commit 073989e.

For more details on these errors, see this check.

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.

1 participant