Skip to content

Basic ability to choose a file for a linksTo(FileDef) field#3876

Closed
lukemelia wants to merge 4 commits intomainfrom
cs-8391-deal-with-new-case-upload-ui-needs-to-plugin-where-card
Closed

Basic ability to choose a file for a linksTo(FileDef) field#3876
lukemelia wants to merge 4 commits intomainfrom
cs-8391-deal-with-new-case-upload-ui-needs-to-plugin-where-card

Conversation

@lukemelia
Copy link
Contributor

@lukemelia lukemelia commented Jan 20, 2026

Screen.Recording.2026-01-20.at.7.50.42.PM.mov

@github-actions
Copy link

github-actions bot commented Jan 20, 2026

@github-actions
Copy link

github-actions bot commented Jan 20, 2026

Host Test Results

    1 files  ±0      1 suites  ±0   1h 39m 51s ⏱️ - 1m 21s
1 846 tests +2  1 832 ✅ +1  13 💤 ±0  0 ❌ ±0  1 🔥 +1 
1 861 runs  +2  1 846 ✅ ±0  13 💤 ±0  1 ❌ +1  1 🔥 +1 

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.

@lukemelia lukemelia force-pushed the cs-8391-deal-with-new-case-upload-ui-needs-to-plugin-where-card branch 3 times, most recently from 07b9eb7 to e8c540e Compare January 21, 2026 04:46
@habdelra habdelra requested a review from Copilot January 21, 2026 14:06
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 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 getFileMeta method to the Store interface and service to load file metadata
  • Enabled editor controls for linksTo(FileDef) and linksToMany(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.

Comment on lines 80 to 84
throw new Error(
`choose-file-modal: failed to load file meta for ${fileURL.href}`,
);
}
this.deferred.fulfill(file);
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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);
}

Copilot uses AI. Check for mistakes.
@lukemelia lukemelia force-pushed the cs-8391-deal-with-new-case-upload-ui-needs-to-plugin-where-card branch from e8c540e to 3e9b246 Compare January 21, 2026 19:33
@lukemelia lukemelia marked this pull request as draft January 22, 2026 16:14
@lukemelia lukemelia force-pushed the cs-8391-deal-with-new-case-upload-ui-needs-to-plugin-where-card branch 2 times, most recently from 18f0e79 to 9e7da2f Compare February 12, 2026 23:47
lukemelia and others added 3 commits February 16, 2026 15:24
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>
@lukemelia lukemelia force-pushed the cs-8391-deal-with-new-case-upload-ui-needs-to-plugin-where-card branch from 9575d34 to bbf956c Compare February 16, 2026 20:24
…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>
@lukemelia lukemelia closed this Feb 16, 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.

2 participants