Added automatic screenshot generation when creating a task. - #117
Added automatic screenshot generation when creating a task.#117veronika-tseleva-cleantalk wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an automatic screenshot capture step during task creation so that newly created “spots” can include a screenshot attachment without requiring a separate user action.
Changes:
- Trigger
fileUploader.makeScreenshot()automatically when submitting the create-task form. - Gracefully handle screenshot capture failures (log and continue creating the task).
- Apply the same change to the built distribution bundle.
Reviewed changes
Copilot reviewed 1 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| js/src/widget.js | Adds an awaited auto-screenshot step prior to building/submitting task payload. |
| dist/doboard-widget-bundle.js | Updates the compiled bundle to include the same auto-screenshot behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (3)
js/src/fileuploader.js:415
makeScreenshot()usesconsole.logfor a condition that is effectively a warning/skip path, while the rest of this module usesconsole.warn/console.error. Keeping log levels consistent also makes it easier to filter production logs.
if (this.files.length >= this.maxFiles || this.getTotalSize() >= this.maxTotalSize) {
console.log('SpotFix: File count or total size limit reached. Automatic screenshot cancelled.');
return;
js/src/fileuploader.js:510
- The
elsebranch assumesvalidateFile()failed due to total-size, butvalidateFile()can also fail due to per-file size or type; additionally it callsshowError(), which may display an unexpected UI error for an automatic screenshot. Consider doing a silent constraint check for automatic screenshots instead of callingvalidateFile(), and use a generic warning if you still want a console message.
if (this.validateFile(file)) {
if (this.uploaderWrapper && this.uploaderWrapper.style.display !== 'block') {
this.uploaderWrapper.style.display = 'block';
}
this.clearError();
this.addFile(file);
} else {
console.warn('SpotFix: Automatic screenshot was not added because the total file size would exceed the limit.');
}
js/src/widget.js:271
- This new
await makeScreenshot()call means task creation now depends on screenshot capture completing first. SincemakeScreenshot()may dynamically loaddom-to-image-morefrom a third-party CDN, task creation can be delayed or fail in environments that block CDN traffic. Consider preloading/bundling the dependency, or making automatic screenshots use only already-bundled code paths (e.g., the html2canvas fallback) to reduce runtime network dependencies.
if (this.fileUploader && typeof this.fileUploader.makeScreenshot === 'function') {
try {
await this.fileUploader.makeScreenshot();
} catch (screenshotError) {
console.error('Failed to capture automatic screenshot:', screenshotError);
}
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
js/src/widget.js:954
- The widget is hidden and screenshot capture is awaited during create-task initialization. Since makeScreenshot() can fetch a screenshot library from a CDN, this can keep the widget invisible (and delay editor setup) for an unpredictable amount of time on first open. Consider running screenshot capture in the background and relying on makeScreenshot()'s existing ignore/filter logic instead of hiding the widget container.
try {
await this.fileUploader.makeScreenshot();
} catch (screenshotError) {
console.error('SpotFix: Failed to capture automatic screenshot on open:', screenshotError);
} finally {
js/src/fileuploader.js:509
- This warning message is misleading: validateFile(file) can fail because the screenshot file itself exceeds maxFileSize (not just total size). Either make the message generic or mention both limits so logs match the actual validation outcome.
} else {
console.warn('SpotFix: Automatic screenshot was not added because the total file size would exceed the limit.');
}
https://app.doboard.com/1/task/53214