Skip to content

Comments

Filter file chooser by type for LinksTo/LinksToMany fields (CS-10080)#3989

Merged
lukemelia merged 4 commits intomainfrom
cs-10080-update-filechooser-to-be-able-to-restrict-choices-to-certain
Feb 16, 2026
Merged

Filter file chooser by type for LinksTo/LinksToMany fields (CS-10080)#3989
lukemelia merged 4 commits intomainfrom
cs-10080-update-filechooser-to-be-able-to-restrict-choices-to-certain

Conversation

@lukemelia
Copy link
Contributor

Summary

  • When a LinksTo or LinksToMany field targets a specific FileDef subclass (e.g. ImageDef), the file chooser now filters the file tree to only show compatible files
  • The modal title dynamically reflects the file type (e.g. "Choose Image" instead of "Choose a File")
  • Passes the field's CodeRef through chooseFile()ChooseFileModalIndexedFileTreefileTreeFromIndex resource, which uses it as the search filter type

Test plan

  • Added acceptance test: file chooser filters by type when field is ImageDef
  • Added acceptance test: file chooser shows all files when field is FileDef
  • Manual test: open an edit view with an ImageDef LinksTo field, click add, verify only images appear
  • Manual test: open an edit view with a FileDef LinksTo field, click add, verify all files appear

🤖 Generated with Claude Code

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>
@github-actions
Copy link

Preview deployments

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

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() / FileChooser API to accept optional { fileType, fileTypeName } and plumb this through the modal and indexed file tree.
  • Add baseFileRef constant 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.

@github-actions
Copy link

github-actions bot commented Feb 12, 2026

Host Test Results

    1 files  ±0      1 suites  ±0   1h 40m 14s ⏱️ -5s
1 840 tests +2  1 827 ✅ +2  13 💤 ±0  0 ❌ ±0 
1 855 runs  +2  1 842 ✅ +2  13 💤 ±0  0 ❌ ±0 

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.
Chrome ‑ Acceptance | interact submode tests > 1 stack: can link a file via the chooser
Chrome ‑ Acceptance | interact submode tests > 1 stack: clicking a linked file opens it as a new isolated stack item
Chrome ‑ Acceptance | file chooser tests: can link a file via the chooser
Chrome ‑ Acceptance | file chooser tests: clicking a linked file opens it as a new isolated stack item
Chrome ‑ Acceptance | file chooser tests: file chooser filters by type when field is ImageDef
Chrome ‑ Acceptance | file chooser tests: file chooser shows all files when field is FileDef

♻️ This comment has been updated with latest results.

ylm added 2 commits February 12, 2026 15:00
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.
Copy link
Contributor

@backspace backspace left a comment

Choose a reason for hiding this comment

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

I tried this locally, much easier to work with now!

@lukemelia lukemelia force-pushed the cs-10080-update-filechooser-to-be-able-to-restrict-choices-to-certain branch from 552069c to 0bdab0c Compare February 12, 2026 23:40
@lukemelia lukemelia merged commit 84c3e36 into main Feb 16, 2026
171 of 174 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