Skip to content

TT 7363 pending resource audio - #565

Draft
gtryus wants to merge 4 commits into
developfrom
TT-7363-pending-audio
Draft

TT 7363 pending resource audio#565
gtryus wants to merge 4 commits into
developfrom
TT-7363-pending-audio

Conversation

@gtryus

@gtryus gtryus commented Sep 1, 2026

Copy link
Copy Markdown
Contributor
  • 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.

@gtryus
gtryus marked this pull request as draft September 1, 2026 18:58
@gtryus
gtryus requested a balanced review from Copilot September 2, 2026 19:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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, Uploader retains only successful media IDs and afterUpload assigns those compact sequence numbers; if the first file fails and the second succeeds, both the pending metadata and the successful resource use rowData.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}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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();
Greg Trihus added 4 commits September 3, 2026 12:10
- 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 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 beforeUpload into useMediaUpload, which now invokes it before staging, but a successful recording then returns through Uploader.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 in useMediaUpload, 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

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