lisa/fix-screenshots-only-as-image-types#233
Closed
gusfcarvalho wants to merge 1 commit into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens “screenshot” evidence handling so that screenshot uploads are restricted to image formats (and properly labeled as images), aligning UI validation with downstream rendering expectations (e.g., image-only rendering for base64 resources).
Changes:
- Make the file input
acceptlist and help text dependent on the selected evidence type (document vs screenshot). - Add client-side validation to reject disallowed file types for the chosen evidence type.
- Improve workflow evidence
mediaTypeinference (including adding WebP support) and add unit tests for the new validation behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/views/workflow-executions/partials/EvidenceSubmissionForm.vue | Dynamically sets accepted file types/help text and validates uploaded files by evidence type. |
| src/views/workflow-executions/partials/tests/EvidenceSubmissionForm.spec.ts | Adds tests to confirm screenshot is image-only, document keeps doc+image support, and WebP is accepted. |
| src/composables/workflows/useStepExecutions.ts | Adjusts evidence mediaType inference to prefer the file MIME type and adds WebP mapping. |
Comments suppressed due to low confidence (1)
src/views/workflow-executions/partials/EvidenceSubmissionForm.vue:245
- In the oversized-files branch you clear
selectedFilesbut you don't clear the underlying<input type="file">value. That can prevent users from re-selecting the same file (the change event may not fire) and leaves the invalid selection in the control. Consider resettingtarget.value = ''here as well (similar to the invalid-type branch).
// Validate each file size (10MB max)
const oversizedFiles = files.filter((file) => file.size > 10 * 1024 * 1024);
if (oversizedFiles.length > 0) {
submitError.value = `The following files exceed 10MB limit: ${oversizedFiles.map((f) => f.name).join(', ')}`;
selectedFiles.value = [];
return;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+260
to
+265
| function isAllowedFileType(file: File): boolean { | ||
| const config = fileTypeConfig.value; | ||
| if (!config) return false; | ||
|
|
||
| const ext = file.name.split('.').pop()?.toLowerCase(); | ||
| return !!ext && config.extensions.includes(ext); |
Comment on lines
+224
to
+231
| watch( | ||
| () => evidenceForm.value.type, | ||
| () => { | ||
| selectedFiles.value = []; | ||
| submitError.value = ''; | ||
| const fileInput = document.getElementById('file') as HTMLInputElement; | ||
| if (fileInput) fileInput.value = ''; | ||
| }, |
Comment on lines
148
to
156
| // Determine media type based on evidence type or file | ||
| let mediaType = 'application/octet-stream'; | ||
| if (ev.evidenceType === 'screenshot') { | ||
| mediaType = 'image/png'; | ||
| } else if (ev.file?.type) { | ||
| if (ev.file?.type) { | ||
| mediaType = ev.file.type; | ||
| } else if (ev.evidenceType === 'screenshot') { | ||
| mediaType = 'image/png'; | ||
| } else if (ev.fileName) { | ||
| // Guess from extension | ||
| const ext = ev.fileName.split('.').pop()?.toLowerCase(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
automated implementation by lisa.