Repository navigation
refactor: ResourceRecordPanel tracks an uploaded take instead of MediaRecord's setHasTake effect - #877
Draft
nabalone wants to merge 1 commit into
Draft
refactor: ResourceRecordPanel tracks an uploaded take instead of MediaRecord's setHasTake effect#877nabalone wants to merge 1 commit into
nabalone wants to merge 1 commit into
Conversation
…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>
Contributor
There was a problem hiding this comment.
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
setHasTakeand its derived-state syncing effect fromMediaRecord. - Added
hadTakestate toResourceRecordPanel, 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Stacked on #875 (
resource-upload-context); retarget todeveloponce #875 merges.Resolves the
TODO cleanup in next PRon MediaRecord'ssetHasTakeeffect: it only copied a derived value up to the parent, which CODING_STANDARDS "Effects" calls a finding.What changed
MediaRecorddrops thesetHasTakeprop and the effect that fed it.ResourceRecordPaneltrackshadTakeitself: set from MediaRecord'safterUploadCbwhen an upload succeeds, cleared when a new recording starts or the Record tab is re-entered. The record button is enabled bycanSave || (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.setCanSaveeffect, which follows the same pattern (left for a later PR).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 typecheckclean; prettier and eslint clean on changed files.🤖 Generated with Claude Code