Skip to content

refactor: move add-resource flow into AddResourceWizard - #853

Merged
nabalone merged 10 commits into
developfrom
upload-pipeline-use-media-upload_2
Nov 12, 2026
Merged

nabalone merged 10 commits into
developfrom
upload-pipeline-use-media-upload_2

Conversation

@nabalone

@nabalone nabalone commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator
  • Extracts the add/edit-resource flow (upload → select sections → configure) out of PassageDetailArtifacts and PassageDetailsArtifactsMobile into a shared AddResourceWizard component + useAddResourceWizard hook, removing ~1,600 duplicated lines from the two views.
  • Adds ResourceUploadStep, useResourceArtifactTypes, and PassageRecordPanel (replaces PassageRecordDlg).
  • Slims Uploader / MediaRecord / MediaUploadContent now that the wizard owns step state; drops the unused localization string.

Test plan

  • npm run typecheck (passes locally)
  • Jest: AddResourceWizard.test.tsx, ResourceUploadStep.test.tsx, useResourceArtifactTypes.test.ts, PassageDetailArtifacts.test.tsx
  • Manual: add passage / section / general audio resource (upload + record), Back between steps, edit an existing general resource, desktop and mobile views

🤖 Generated with Claude Code

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.

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟡 Changes recommended

A critical functional issue remains in the edit flow where visual general resources are forced into an audio/segment-based Configure step that can prevent completion, alongside smaller standards and styling nits that still need addressing.

3 open issues
What changed in this PR

Refactors the add/edit resource workflow by consolidating the duplicated desktop/mobile “upload → select sections → configure” flow into a shared wizard + hook, and simplifying related upload/record components to match the new ownership model.

Changes:

  • Introduces AddResourceWizard + useAddResourceWizard to unify add/edit general-resource flows across desktop and mobile artifact views.
  • Adds new step/components and helpers (ResourceUploadStep, PassageRecordPanel, useResourceArtifactTypes) and removes legacy dialog code/tests.
  • Streamlines upload/record plumbing (Uploader, MediaUploadContent, MediaRecord, useMediaUpload) and removes an unused localization key.
File Description
web/​src/​store/​upload/​actions.tsx Adjusts upload retry/queue behavior around pending uploads to better align with general/project resource handling.
web/​src/​store/​localization/​reducers.tsx Removes an unused localization string key from the runtime localization state.
web/​src/​store/​localization/​model.tsx Updates localization typings to remove the deleted/unused string key.
web/​src/​crud/​useMediaUpload.ts Aligns media upload behavior with the renamed non-file upload type constant and related versioning logic.
web/​src/​control/​ActionRow.tsx Updates ActionRow layout/styling behavior to better support wizard footers and caller-provided sx.
web/​src/​components/​useRecordSave.ts Removes the deferred “stage file instead of upload” path now superseded by the wizard flow.
web/​src/​components/​UploadType.ts Renames the constant for non-file upload types (NO_LIST_TYPES → NON_FILE_UPLOAD_TYPES).
web/​src/​components/​Uploader.tsx Simplifies Uploader into an upload-only dialog now that recording and step state live in the wizard.
web/​src/​components/​Uploader.test.tsx Removes tests tied to the legacy record/defer behavior that was deleted from Uploader.
web/​src/​components/​TitleUploader.tsx Updates TitleUploader to match the revised MediaUploadContent API (including boolean ready and renamed button text prop).
web/​src/​components/​Sheet/​ScriptureTable.tsx Updates ScriptureTable’s Uploader usage to match the simplified Uploader props surface.
web/​src/​components/​PassageRecordPanel.tsx Adds a new embedded record/upload panel component used by the wizard’s first step UI.
web/​src/​components/​PassageRecordDlg.tsx Removes the legacy combined record/upload dialog in favor of the new panel + wizard approach.
web/​src/​components/​PassageRecordDlg.test.tsx Removes tests that were specific to the deleted legacy record dialog component.
web/​src/​components/​PassageDetail/​Internalization/​useResourceArtifactTypes.ts Adds a shared hook for resolving resource artifact types consistently across add/edit flows.
web/​src/​components/​PassageDetail/​Internalization/​useResourceArtifactTypes.test.ts Adds unit tests covering the shared artifact-type resolution behavior.
web/​src/​components/​PassageDetail/​Internalization/​useAddResourceWizard.ts Introduces the wizard state machine/hook that owns step transitions and deferred upload behavior for add/edit flows.
web/​src/​components/​PassageDetail/​Internalization/​UploadRecordToggle.tsx Updates the upload/record toggle to use an enum-based mode representation and wiring aligned to the wizard flow.
web/​src/​components/​PassageDetail/​Internalization/​SelectSections.tsx Refactors the section selection UI to work cleanly within the wizard and remain stable across step navigation.
web/​src/​components/​PassageDetail/​Internalization/​ResourceUploadStep.tsx Adds a new wizard step component that embeds upload/record UI and wires it to useMediaUpload.
web/​src/​components/​PassageDetail/​Internalization/​ResourceUploadStep.test.tsx Adds tests for the new upload step’s wiring and behavior (including defaulting and finish behavior).
web/​src/​components/​PassageDetail/​Internalization/​ResourceData.tsx Updates resource metadata form behavior and checks to align with wizard usage and non-file upload type handling.
web/​src/​components/​PassageDetail/​Internalization/​ProjectResourceConfigure.tsx Adjusts configure-step behaviors (save/copy/back gating) to match the wizard-driven flow.
web/​src/​components/​PassageDetail/​Internalization/​PassageDetailsArtifactsMobile.tsx Replaces the mobile artifacts view’s duplicated add/edit flow with launching the shared wizard.
web/​src/​components/​PassageDetail/​Internalization/​PassageDetailArtifacts.tsx Replaces the desktop artifacts view’s duplicated add/edit flow with launching the shared wizard.
web/​src/​components/​PassageDetail/​Internalization/​PassageDetailArtifacts.test.tsx Updates tests to assert wizard launching behavior instead of the legacy upload dialog flow.
web/​src/​components/​PassageDetail/​Internalization/​AddResourceWizard.tsx Adds the unified wizard dialog that composes upload/select/configure steps under one component.
web/​src/​components/​PassageDetail/​Internalization/​AddResourceWizard.test.tsx Adds wizard-level tests for step transitions, deferred upload, and close/back rules.
web/​src/​components/​MediaUploadDialog.tsx Simplifies MediaUploadDialog’s API to match updated ready handling and removes unused props.
web/​src/​components/​MediaUploadContent.tsx Refines MediaUploadContent to support wizard-driven “Next” behavior, updated button labeling, and boolean ready gating.
web/​src/​components/​MediaRecord.tsx Updates MediaRecord to remove staging behavior and add state reporting needed for wizard navigation.
web/​src/​components/​MediaRecord.test.tsx Removes tests tied to the deleted staging pathway in MediaRecord.
web/​src/​components/​GraphicUploader.tsx Refactors GraphicUploader to use the updated MediaUploadContent API and align ready handling.
web/​src/​__tests__/​ProjectResourceConfigure.test.tsx Updates tests to reflect the removed localization key and configure-step changes.
localization/​TranscriberAdmin-en.xlf Removes the now-unused translation unit corresponding to the deleted localization key.
localization/​TranscriberAdmin-en-1.2.xliff Removes the now-unused translation unit corresponding to the deleted localization key.

Review effort: Balanced

Base automatically changed from upload-pipeline-use-media-upload to develop November 10, 2026 19:53
nabalone and others added 6 commits November 10, 2026 15:33
General resources are no longer queued for pending-upload retry, so remove
the now-dead restore/resume chain (projectresource restore kind,
pendingProjectResourceConfig, useResumePendingProjectResourceConfig).
Fix the no-op gutterBottom CSS key in PassageRecordPanel, add a cleanup
TODO for MediaRecord's setHasTake effect, and clarify that unfinished
wizard work is dropped on save-all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nabalone

Copy link
Copy Markdown
Collaborator Author

Moving props into contexts and the SonarQube fixes will be done in a future PR.

@nabalone
nabalone force-pushed the upload-pipeline-use-media-upload_2 branch from ef7cd4a to 3bdc9cc Compare November 10, 2026 20:39
@nabalone
nabalone requested a balanced review from Copilot November 10, 2026 20:39

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.

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟡 Changes recommended

The change is blocked by unresolved critical and moderate findings, including a wizard flow that misroutes non-audio resources to an audio-only configuration step, an effect that mirrors derived state into parent state in a way that can create subtle loops, and removal of legacy pending-upload restore handling that could break retries for existing persisted rows.

3 open issues
2 resolved since last review

Review effort: Balanced

Comment thread web/src/components/MediaRecord.tsx Resolved

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.

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🔵 Needs a closer look

Approval is blocked by two critical unresolved issues: the new general-resource edit flow likely breaks visual media by forcing it through an audio/segment-based wizard, and ActionRow spreads sx in a way that will crash at runtime for valid array/function sx values.

1 open issue
2 previously missed issues

In code that hasn't changed since last review

High severity Visual general resources still need a non-config edit path

web/​src/​components/​PassageDetail/​Internalization/​PassageDetailsArtifactsMobile.tsx:360

General resources can be “visual” (see resourceRows.ts using isVisual(media)), but this edit path now routes every general resource into AddResourceWizard → ProjectResourceConfigure, which is explicitly audio/segment-based (e.g. it parses regions and says “Segment limits come from the audio”). That likely breaks editing visual general resources that previously skipped Configure (writeVisualResource). Consider either (1) preventing editGeneralResource for visual media and keeping the immediate-write flow, or (2) teaching the wizard to detect visual media and bypass Configure with an equivalent assignment write path.

High severity Spreading MUI sx can crash when callers pass arrays or functions

web/​src/​control/​ActionRow.tsx:13

sx in MUI can be an array or a function; spreading it (...sx) will throw at runtime when callers pass those valid forms. Compose the default styles with the caller-provided sx via an sx array instead.

2 resolved since last review

Review effort: Balanced

@nabalone

Copy link
Copy Markdown
Collaborator Author

Copilot keeps worrying about visual general resources. We already discussed that there's no such thing as non-audio general resources. No way to make them. We don't support

@nabalone
nabalone marked this pull request as ready for review November 11, 2026 00:47
nabalone added a commit that referenced this pull request Nov 11, 2026
Address SonarQube findings in files touched by the general resource refactor
(PR #853): mark intentionally-unawaited promises with void, reject upload
promises with an Error subclass (UploadFileReject), and prefer
Number.isNaN/Number.parseFloat. No behavior change intended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
UploadType.MarkDown,
UploadType.FaithbridgeLink,
].includes(uploadType ?? UploadType.Resource) && (
!NON_FILE_UPLOAD_TYPES.includes(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you add the visual types here to prevent copilot complaining about them?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

/** Which action opened the wizard (see PassageDetailArtifacts). */
export type WizardLaunch =
// Add menu: Audio / Pdf / Text / Link — enters at the upload step.
| { kind: 'add'; action: AddUploadAction }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can 'add', 'faithbridge','editGeneralResource' be made into a union type or an enum?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

sarahentzel pushed a commit that referenced this pull request Nov 11, 2026
)

* chore: Sonarqube changes adjacent to the general resource refactor

Address SonarQube findings in files touched by the general resource refactor
(PR #853): mark intentionally-unawaited promises with void, reject upload
promises with an Error subclass (UploadFileReject), and prefer
Number.isNaN/Number.parseFloat. No behavior change intended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: handle rejections of fire-and-forget promises

Per CODING_STANDARDS Async (Devin/Copilot review): Orbit writes in the
artifacts views now log and show failures; ScriptureTable save/publish waits
log or show their errors; the remaining void calls carry a comment saying
why they cannot reject.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@nabalone
nabalone merged commit 0ed15be into develop Nov 12, 2026
2 checks passed
@nabalone
nabalone deleted the upload-pipeline-use-media-upload_2 branch November 12, 2026 14:03
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.

3 participants