TT 7363 pending resource audio - #565
Conversation
gtryus
commented
Sep 1, 2026
- Added pendingRestore prop to PassageRecordDlg, Uploader, LwcTranslationControls, and PassageDetail components to support restoration of media uploads.
- Implemented resourcePendingRestore logic in PassageDetailArtifacts and PassageDetailArtifactsMobile to manage section resource restoration.
- Updated pendingMediaUploads type definitions to include new sectionresource kind for better handling of pending uploads.
- Enhanced restoreAfterPendingUpload function to process sectionresource restoration, ensuring correct linking to sections and media files.
- Improved unit tests for pending upload scenarios to validate new restoration logic and ensure reliability.
There was a problem hiding this comment.
🟡 Changes recommended
Retry restoration can lose metadata and create duplicate resource sequence numbers.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds pending-upload restoration for section resources and LWC source-media relationships.
Changes:
- Adds resource and source-media restoration metadata.
- Propagates restoration through upload and recording flows.
- Adds restoration tests.
File summaries
| File | Description |
|---|---|
restoreAfterPendingUpload.ts |
Restores resource and source-media links. |
pendingUploadRetryGaps.test.ts |
Tests new restoration cases. |
pendingMediaUploads.ts |
Adds restoration metadata types. |
Uploader.tsx |
Forwards restoration metadata. |
PassageRecordDlg.tsx |
Passes metadata to recording. |
PassageDetailLwcTranslation.tsx |
Captures LWC source media. |
LwcTranslationControls.tsx |
Propagates LWC restoration metadata. |
PassageDetailsArtifactsMobile.tsx |
Captures responsive resource metadata. |
PassageDetailArtifacts.tsx |
Captures resource restoration metadata. |
Review details
Suppressed comments (1)
src/renderer/src/store/upload/restoreAfterPendingUpload.ts:305
- This persists a stale sequence number and can create duplicate ordering values. In a multi-file batch,
Uploaderretains only successful media IDs andafterUploadassigns those compact sequence numbers; if the first file fails and the second succeeds, both the pending metadata and the successful resource userowData.length + 1. The same collision occurs when resources are added before a delayed retry. Compute the next available sequence from the section’s current resources during restoration, or reserve/resequence entries explicitly.
sequenceNum: restore.sequenceNum,
- Files reviewed: 9/9 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| }); | ||
| return; | ||
| case 'sectionresource': | ||
| await restoreSectionResource({ |
| multiple={multiple} | ||
| inValue={inValue} | ||
| onNonAudio={onNonAudio} | ||
| pendingRestore={pendingRestore} |
8197a60 to
4fa18f9
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Successful recordings invoke the pre-upload callback twice, potentially repeating metadata commits.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 12/12 changed files
- Comments generated: 1
- Review effort level: Balanced
| ? remoteIdNum('plan', planId, memory?.keyMap as RecordKeyMap) || | ||
| void (async () => { | ||
| try { | ||
| if (beforeUpload) await beforeUpload(); |
- Introduced a new test file for validating the behavior of pending upload retries, focusing on the restoration of section resources and linking to media files and workflow steps. - Implemented tests to ensure correct linking of section resources to sections, media files, and organization workflow steps during the restoration process. - Enhanced test coverage for linking passages when restore metadata includes passage IDs, ensuring accurate functionality in various scenarios. - Established a memory source setup for testing, including necessary records and relationships to simulate real-world conditions for pending uploads.
- Added `pendingRestore` prop to `PassageRecordDlg`, `Uploader`, `LwcTranslationControls`, and `PassageDetail` components to support restoration of media uploads. - Implemented `resourcePendingRestore` logic in `PassageDetailArtifacts` and `PassageDetailArtifactsMobile` to manage section resource restoration. - Updated `pendingMediaUploads` type definitions to include new `sectionresource` kind for better handling of pending uploads. - Enhanced `restoreAfterPendingUpload` function to process `sectionresource` restoration, ensuring correct linking to sections and media files. - Improved unit tests for pending upload scenarios to validate new restoration logic and ensure reliability.
…numbers - Added a new test case to validate that the restoration process avoids duplicate sequence numbers when a section already has that sequence. - Updated the `restoreAfterPendingUpload` function to ensure that if a sequence number is already in use, the next available sequence number is assigned. - Improved unit tests for pending upload scenarios to ensure the reliability of the restoration logic and correct linking of section resources.
- Introduced a new `beforeUpload` prop across `MediaRecord`, `PassageRecordDlg`, and `Uploader` components to allow committing deferred metadata before staging uploads. - Updated `useMediaUpload` hook to handle the `beforeUpload` logic, ensuring that newly created category IDs are included in the `pendingRestore` metadata. - Added unit tests to validate the behavior of `beforeUpload`, ensuring it is called prior to capturing `pendingRestore` during upload processes. - Improved overall handling of pending uploads to prevent issues with missing metadata during restoration.
4fa18f9 to
8ab3434
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Successful recorded uploads invoke beforeUpload twice, potentially repeating metadata side effects.
Review details
Suppressed comments (1)
src/renderer/src/components/Uploader.tsx:514
- This forwards
beforeUploadintouseMediaUpload, which now invokes it before staging, but a successful recording then returns throughUploader.afterUploadCb, where the same callback is invoked again (line 167). This violates the existing “awaited once” contract and can repeat non-idempotent metadata commits. Keep the pre-staging call inuseMediaUpload, and remove or otherwise suppress the later invocation for the recorded path.
beforeUpload={beforeUpload}
- Files reviewed: 12/12 changed files
- Comments generated: 0 new
- Review effort level: Balanced