Skip to content

Comments

Direct FileDef instance fetching in render-store context#4033

Merged
lukemelia merged 2 commits intomainfrom
invalidations-sort
Feb 20, 2026
Merged

Direct FileDef instance fetching in render-store context#4033
lukemelia merged 2 commits intomainfrom
invalidations-sort

Conversation

@lukemelia
Copy link
Contributor

@lukemelia lukemelia commented Feb 19, 2026

Summary

  • Fetch FileDef instances directly in the render-store context when a card references files that haven't been indexed yet — bypasses the index, fetches raw file bytes from the realm server, and runs extractAttributes on the fly to produce full subclass attributes (width/height for images, title/content for markdown)
  • Extract shared utilities: resolveFileDefCodeRef to runtime-common/file-def-code-ref.ts and FileDefAttributesExtractor to host/app/utils/file-def-attributes-extractor.ts for reuse across the index runner, file-extract route, and store service

Test plan

  • Tweaked existing 'includes FileDef resources for file links in included payload' test to write images to disk before indexing the card, exercising the extractFileMetaDirectly path where images are on disk but not yet indexed during card prerendering
  • Verify existing prerendering tests pass (file-extract route still works with extracted FileDefAttributesExtractor)
  • Verify indexing tests pass (no regressions from resolveFileDefCodeRef extraction)

🤖 Generated with Claude Code

@lukemelia lukemelia changed the title CS-10223: Direct FileDef instance fetching in render-store context Direct FileDef instance fetching in render-store context Feb 19, 2026
@lukemelia lukemelia requested review from a team, Copilot, ef4 and habdelra February 19, 2026 22:42
Copy link
Contributor

Copilot AI left a comment

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 enables the render-store to fetch FileDef instances directly when a card references files that haven't been indexed yet, bypassing the need to wait for indexing. It also refactors shared utilities to improve code reuse.

Changes:

  • Extracts resolveFileDefCodeRef function to runtime-common/file-def-code-ref.ts for reuse across index runner, file-extract route, and store service
  • Extracts FileDefAttributesExtractor class to host/app/utils/file-def-attributes-extractor.ts for reuse across file-extract route and store service
  • Adds extractFileMetaDirectly method in store service that fetches raw file bytes and runs extractAttributes on the fly during render context

Reviewed changes

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

Show a summary per file
File Description
packages/runtime-common/index.ts Exports the new file-def-code-ref module
packages/runtime-common/file-def-code-ref.ts New file containing extracted resolveFileDefCodeRef function and file extension mappings
packages/runtime-common/index-runner.ts Updated to import and use extracted resolveFileDefCodeRef function and baseFileRef constant
packages/host/app/utils/file-def-attributes-extractor.ts New file containing extracted FileDefAttributesExtractor class and helper functions
packages/host/app/routes/render/file-extract.ts Simplified by importing and using extracted FileDefAttributesExtractor class
packages/host/app/services/store.ts Adds extractFileMetaDirectly method to fetch FileDef instances directly when in render context
packages/realm-server/tests/card-endpoints-test.ts Modified test to write images to disk before indexing to exercise the new direct fetch path

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

@github-actions
Copy link

Preview deployments

@github-actions
Copy link

github-actions bot commented Feb 19, 2026

Host Test Results

    1 files  ±    0      1 suites  ±0   3h 25m 49s ⏱️ + 1h 41m 36s
1 856 tests ±    0  1 841 ✅  -     1  14 💤 ± 0  0 ❌ ±0  1 🔥 +1 
3 742 runs  +1 871  3 712 ✅ +1 855  28 💤 +14  1 ❌ +1  1 🔥 +1 

For more details on these errors, see this check.

Results for commit 21ad360. ± Comparison against base commit 82e0e25.

♻️ This comment has been updated with latest results.

lukemelia and others added 2 commits February 19, 2026 22:11
When prerendering a card that references files (e.g., images via
linksTo(FileDef)), the render store now bypasses the index and fetches
file bytes directly from the realm server, running extractAttributes
on the fly. This ensures subclass-specific attributes (width/height
for images, title/content for markdown) are available even when the
referenced file hasn't been indexed yet.

- Extract resolveFileDefCodeRef to shared runtime-common module
- Extract FileDefAttributesExtractor to shared host utility
- Add extractFileMetaDirectly render-store path in getFileMetaInstance
- Update test to exercise card-before-file indexing order

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lukemelia lukemelia merged commit a700abb into main Feb 20, 2026
196 of 200 checks passed
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.

2 participants