Skip to content

refactor: ResourceRecordPanel tracks an uploaded take instead of MediaRecord's setHasTake effect - #877

Draft
nabalone wants to merge 1 commit into
resource-upload-contextfrom
record-panel-had-take
Draft

nabalone wants to merge 1 commit into
resource-upload-contextfrom
record-panel-had-take

Conversation

@nabalone

Copy link
Copy Markdown
Collaborator

Stacked on #875 (resource-upload-context); retarget to develop once #875 merges.

Resolves the TODO cleanup in next PR on MediaRecord's setHasTake effect: it only copied a derived value up to the parent, which CODING_STANDARDS "Effects" calls a finding.

What changed

  • MediaRecord drops the setHasTake prop and the effect that fed it.
  • ResourceRecordPanel tracks hadTake itself: set from MediaRecord's afterUploadCb when an upload succeeds, cleared when a new recording starts or the Record tab is re-entered. The record button is enabled by canSave || (onNext && hadTake), so in the deferred (general-resource) wizard flow, Next still carries an already-uploaded take forward after Back. Outside the wizard, Save is still gated on unsaved changes only.
  • The TODO moves to MediaRecord's setCanSave effect, which follows the same pattern (left for a later PR).
  • New ResourceRecordPanel.test.tsx (4 tests): Next stays enabled after Back to an uploaded take; Next is disabled once a new recording starts; a failed upload doesn't count as a take; non-wizard Save is gated on unsaved changes only.

Test plan

  • npm run typecheck clean; prettier and eslint clean on changed files.
  • Jest: related tests pass (148 suites).
  • Manual: Add audio resource as a general resource → Record a take → Next → in Select Sections press Upload → Back to the Record step: Next is still enabled. Start a new recording: Next is disabled until the new take is ready.

🤖 Generated with Claude Code

…aRecord's setHasTake effect

MediaRecord's setHasTake effect only copied a derived value up to the
parent (a CODING_STANDARDS "Effects" finding). Drop the prop and effect;
ResourceRecordPanel now marks hadTake from afterUploadCb on a successful
upload and clears it when a new recording starts or the Record tab is
re-entered, so Next still carries an already-uploaded take forward after
Back. Adds ResourceRecordPanel tests for the Back cases.

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

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 still contains an active test issue where controlsRef is forcibly cast with as never, bypassing the intended RefObject<MediaUploadControlsRef> typing contract and conflicting with the project's typing standards, so the test setup should be corrected to provide a properly shaped controlsRef.current instead.

1 open issue
What changed in this PR

Refactors the add-resource wizard recording flow so ResourceRecordPanel owns the “uploaded take exists” state (hadTake) instead of relying on MediaRecord to push derived state upward via an effect.

Changes:

  • Removed setHasTake and its derived-state syncing effect from MediaRecord.
  • Added hadTake state to ResourceRecordPanel, set on successful upload and cleared when a new recording starts or when re-entering the record step.
  • Added Jest coverage to verify wizard Back/Next behavior after upload, handling of failed uploads, and non-wizard Save gating.
File Description
web/​src/​components/​PassageDetail/​Internalization/​ResourceRecordPanel.tsx Moves “uploaded take exists” tracking into the panel (hadTake) and updates button enablement logic to preserve wizard Next behavior after an upload while keeping non-wizard Save gated on unsaved changes.
web/​src/​components/​PassageDetail/​Internalization/​ResourceRecordPanel.test.tsx Adds tests covering Next/Save enablement across upload success/failure, Back navigation, and starting a new recording resetting the uploaded-take state.
web/​src/​components/​MediaRecord.tsx Removes the setHasTake prop and the effect that copied derived hasTake state upward, leaving the remaining setCanSave effect TODO for later cleanup.

Review effort: Balanced

Comment on lines +72 to +74
deferred: onNext
? { onNext, controlsRef: { current: {} } as never }
: undefined,
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