Skip to content

Add virtual network access in templates for MarkdownField#5131

Closed
backspace wants to merge 1 commit into
mainfrom
network-in-template-cs-11375
Closed

Add virtual network access in templates for MarkdownField#5131
backspace wants to merge 1 commit into
mainfrom
network-in-template-cs-11375

Conversation

@backspace

@backspace backspace commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

This is a small continuation from 5109, which changed all VirtualNetwork parameters 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.

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Preview deployments

Host Test Results

    1 files      1 suites   1h 51m 27s ⏱️
2 948 tests 2 933 ✅ 15 💤 0 ❌
2 967 runs  2 952 ✅ 15 💤 0 ❌

Results for commit 83d2c13.

Realm Server Test Results

    1 files  ±0      1 suites  ±0   8m 50s ⏱️ - 6m 9s
1 544 tests  - 4  1 544 ✅  - 4  0 💤 ±0  0 ❌ ±0 
1 635 runs   - 4  1 635 ✅  - 4  0 💤 ±0  0 ❌ ±0 

Results for commit 83d2c13. ± Comparison against earlier commit 00f5249.

Comment on lines +73 to +75
return trimJsonExtension(
virtualNetwork.resolveURL(raw, baseUrl || undefined).href,
);

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.

this seems fine to me

@backspace backspace force-pushed the require-virtual-network-cs-11374 branch from 0eba1c7 to 70424d7 Compare June 5, 2026 13:50
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>
@backspace backspace force-pushed the network-in-template-cs-11375 branch from 00f5249 to 83d2c13 Compare June 8, 2026 13:11
@backspace backspace changed the base branch from require-virtual-network-cs-11374 to main June 8, 2026 13:12
@backspace backspace marked this pull request as ready for review June 8, 2026 13:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread packages/base/card-api.gts
@backspace backspace requested a review from a team June 8, 2026 14:22

@lukemelia lukemelia 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.

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?

@backspace backspace closed this Jun 8, 2026
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.

3 participants