Basic ability to choose a file for a linksTo(FileDef) field#3876
Basic ability to choose a file for a linksTo(FileDef) field#3876
Conversation
Preview deployments |
Host Test Results 1 files ±0 1 suites ±0 1h 39m 51s ⏱️ - 1m 21s For more details on these errors, see this check. Results for commit 1111485. ± Comparison against base commit 84c3e36. ♻️ This comment has been updated with latest results. |
07b9eb7 to
e8c540e
Compare
There was a problem hiding this comment.
Pull request overview
This pull request enables users to choose files for linksTo(FileDef) fields through a file chooser modal interface, treating FileDef fields with the same editor controls as regular card fields.
Changes:
- Added
getFileMetamethod to the Store interface and service to load file metadata - Enabled editor controls for
linksTo(FileDef)andlinksToMany(FileDef)fields in edit format - Simplified realm routing patterns and removed restrictive checks that prevented file operations
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/runtime-common/realm.ts | Simplified DELETE route pattern and removed checks that prevented file metadata operations on .json files |
| packages/runtime-common/index.ts | Added getFileMeta method to Store interface for loading file metadata |
| packages/runtime-common/error.ts | Fixed isCardErrorJSONAPI to return proper boolean instead of truthy value |
| packages/host/tests/integration/store-test.gts | Added test for getFileMeta method |
| packages/host/tests/integration/realm-test.gts | Added test for deleting file assets via card source |
| packages/host/tests/integration/components/card-basics-test.gts | Updated tests to verify FileDef fields now show editor controls |
| packages/host/tests/helpers/interact-submode-setup.gts | Changed test fixtures from .txt to .md files and FileDef to MarkdownDef |
| packages/host/tests/acceptance/interact-submode-test.gts | Added comprehensive test for file linking via chooser modal |
| packages/host/app/services/store.ts | Implemented getFileMeta method to load file metadata documents |
| packages/host/app/components/operator-mode/choose-file-modal.gts | Changed from creating synthetic FileDef to loading actual file metadata |
| packages/base/links-to-many-component.gts | Removed isFileDef parameter from shouldRenderEditor to enable editor controls |
| packages/base/links-to-editor.gts | Added file chooser integration for FileDef fields |
| packages/base/card-api.gts | Removed isFileDef parameter from shouldRenderEditor to enable editor controls |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| throw new Error( | ||
| `choose-file-modal: failed to load file meta for ${fileURL.href}`, | ||
| ); | ||
| } | ||
| this.deferred.fulfill(file); |
There was a problem hiding this comment.
The error thrown here will result in an uncaught promise rejection if the user clicks the Add button while a file is selected but the file metadata fails to load. Consider handling this error more gracefully, such as displaying an error message to the user rather than throwing an uncaught exception.
| throw new Error( | |
| `choose-file-modal: failed to load file meta for ${fileURL.href}`, | |
| ); | |
| } | |
| this.deferred.fulfill(file); | |
| console.error( | |
| `choose-file-modal: failed to load file meta for ${fileURL.href}`, | |
| ); | |
| // Treat this as if no file was chosen so callers receive `undefined`. | |
| this.deferred.fulfill(undefined as unknown as FileDef); | |
| } else { | |
| this.deferred.fulfill(file); | |
| } |
e8c540e to
3e9b246
Compare
18f0e79 to
9e7da2f
Compare
Adds an Upload button to the file chooser modal so users can upload new files when linking to FileDef/ImageDef fields. The new FileUploadService is reusable across the app and supports concurrent uploads with reactive progress tracking. Also adds static acceptTypes to all FileDef subclasses so the native file picker filters by type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The upload flow involves a multi-step async process (file write to realm, indexing, modal dismiss) not tracked by Ember's run loop, so waitUntil is needed here unlike the other DOM-existence checks that were simplified. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9575d34 to
bbf956c
Compare
…ad states - Pass File directly as fetch body instead of buffering via arrayBuffer() - Use file's actual MIME type for Content-Type header - Include filename, realm URL, and JSON-API error detail in upload failures - Replace misleading progress bar (stuck at 0%) with indeterminate spinner - Show disabled "Choose a file…" button during native file picker - Add "Retry…" button after upload errors - Disable Add button during both picking and uploading states Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Screen.Recording.2026-01-20.at.7.50.42.PM.mov