Conversation
When a LinksTo or LinksToMany field targets a specific FileDef subclass (e.g. ImageDef), pass that type to the file chooser so it filters the file tree to only show compatible files. The modal title also reflects the specific type (e.g. "Choose Image" instead of "Choose a File"). CS-10080 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Preview deployments |
There was a problem hiding this comment.
Pull request overview
Adds file-type-aware filtering and labeling to the file chooser when used from LinksTo/LinksToMany fields targeting specific FileDef subclasses (e.g. ImageDef), and covers this behavior with acceptance tests.
Changes:
- Extend
chooseFile()/FileChooserAPI to accept optional{ fileType, fileTypeName }and plumb this through the modal and indexed file tree. - Add
baseFileRefconstant and use it as the default type filter for indexed file search. - Add acceptance coverage and test-realm fixtures for ImageDef filtering vs FileDef showing all files.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/runtime-common/index.ts | Updates file chooser interface + chooseFile() helper to accept a file-type filter/name and forward to the environment chooser. |
| packages/runtime-common/constants.ts | Adds baseFileRef constant for FileDef code ref. |
| packages/base/links-to-editor.gts | Passes the field card’s CodeRef + displayName into chooseFile() for LinksTo(FileDef) fields. |
| packages/base/links-to-many-component.gts | Same as above for LinksToMany(FileDef) fields. |
| packages/host/app/components/operator-mode/choose-file-modal.gts | Accepts chooser options, updates modal title, and passes filter into IndexedFileTree. |
| packages/host/app/components/editor/indexed-file-tree.gts | Threads fileTypeFilter into fileTreeFromIndex(...). |
| packages/host/app/resources/file-tree-from-index.ts | Adds optional fileTypeFilter and uses it in the index search query (defaulting to baseFileRef). |
| packages/host/tests/helpers/interact-submode-setup.gts | Adds ImageLinkCard fixture and a minimal PNG file to the test realm. |
| packages/host/tests/acceptance/interact-submode-test.gts | Adds acceptance tests verifying filtering + modal title for ImageDef and unfiltered behavior for FileDef. |
| packages/experiments-realm/ImageDefPlayground/mango-demo.json | Updates demo instance JSON (appears to be fixture/data reshaping alongside this work). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Host Test Results 1 files ±0 1 suites ±0 1h 40m 14s ⏱️ -5s Results for commit 0bdab0c. ± Comparison against base commit d859f17. This pull request removes 2 and adds 4 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Address Copilot review: change generic constraint from FieldDef to FileDef and return type from Promise<undefined | any> to Promise<undefined | T> to match the FileChooser interface.
backspace
left a comment
There was a problem hiding this comment.
I tried this locally, much easier to work with now!
552069c to
0bdab0c
Compare
Summary
LinksToorLinksToManyfield targets a specificFileDefsubclass (e.g.ImageDef), the file chooser now filters the file tree to only show compatible filesCodeRefthroughchooseFile()→ChooseFileModal→IndexedFileTree→fileTreeFromIndexresource, which uses it as the search filter typeTest plan
ImageDefFileDef🤖 Generated with Claude Code