Add virtual network access in templates for MarkdownField#5131
Add virtual network access in templates for MarkdownField#5131backspace wants to merge 1 commit into
MarkdownField#5131Conversation
Preview deploymentsHost Test Results 1 files 1 suites 1h 51m 27s ⏱️ Results for commit 83d2c13. Realm Server Test Results 1 files ±0 1 suites ±0 8m 50s ⏱️ - 6m 9s Results for commit 83d2c13. ± Comparison against earlier commit 00f5249. |
| return trimJsonExtension( | ||
| virtualNetwork.resolveURL(raw, baseUrl || undefined).href, | ||
| ); |
0eba1c7 to
70424d7
Compare
MarkdownField.embedded / MarkdownField.atom render BFM markdown with `<MarkdownTemplate @content={{@model}} />`. The field templates only receive the field's primitive @model (a string), with no path to the owning card — so before this change they couldn't supply a VN to MarkdownTemplate, and prefix-form BFM pill refs (e.g. `@cardstack/catalog/foo`) couldn't be resolved at render time. Pick design option 2 from CS-11375: wrap MarkdownField's defaults in `<CardContextConsumer as |context|>` and pass `@cardReferenceVirtualNetwork={{context.store.virtualNetwork}}`. Adding `virtualNetwork: VirtualNetwork` to the Store interface (and exposing it as a getter on host StoreService that delegates to `this.network.virtualNetwork`) makes the context.store path supply VN without changing the field-render protocol — touches MarkdownField specifically rather than every field template. With every MarkdownTemplate call site now threading VN, `cardReferenceVirtualNetwork` becomes required on the component arg and the `resolveUrl` helper's no-VN branch deletes. markdown-file-def and rich-markdown's `virtualNetwork` getters tighten to `VirtualNetwork` with a `?? new VirtualNetwork()` fallback for detached models (preserves the no-throw behavior we already accept for static parsers). Adds a new `markdown-field-test.gts` covering MarkdownField.embedded and .atom rendering BFM pills, including a prefix-form ref that exercises the consumer plumbing end-to-end. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
00f5249 to
83d2c13
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 83d2c13ddb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
lukemelia
left a comment
There was a problem hiding this comment.
Can we come up with a design that does not initiate a pattern of cards and/or card components interacting directly with VirtualNetwork instances? The possibilities for abuse are myriad. What capabilities do cards need that they don't have, and can we narrowly expose that ability?
This is a small continuation from 5109, which changed all
VirtualNetworkparameters to be required but one:MarkdownField, which needs one to resolve@cardstack/whatever-style card references in markdown.The CI failure about the title is because of rebasing, this doesn’t have anything to do with Boxel CLI.