-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix media selection in Aztec editor #22442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
Generated by 🚫 Danger |
|
| App Name | Jetpack | |
| Flavor | Jalapeno | |
| Build Type | Debug | |
| Version | pr22442-4883efd | |
| Commit | 4883efd | |
| Direct Download | jetpack-prototype-build-pr22442-4883efd.apk |
|
| App Name | WordPress | |
| Flavor | Jalapeno | |
| Build Type | Debug | |
| Version | pr22442-4883efd | |
| Commit | 4883efd | |
| Direct Download | wordpress-prototype-build-pr22442-4883efd.apk |
This comment was marked as outdated.
This comment was marked as outdated.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #22442 +/- ##
==========================================
+ Coverage 39.16% 39.21% +0.04%
==========================================
Files 2202 2203 +1
Lines 106560 106578 +18
Branches 15119 15123 +4
==========================================
+ Hits 41734 41794 +60
+ Misses 61328 61273 -55
- Partials 3498 3511 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@nbradbury when testing the prototype build from this PR, the first two of the three options in Aztec do not work for me; the second option causes the editor to crash. Aztec media crash recording
Screen_Recording_20251219_082405_Jetpack.Pre-Alpha.mp4 |
This comment was marked as resolved.
This comment was marked as resolved.
The test was verifying that launchCamera() is called when the implementation actually calls checkCameraPermissionAndLaunch(). This caused the tests to pass but runtime to fail because the mocked method didn't match the actual implementation. This fixes the issue where camera and gallery actions were not working in the Aztec editor. Co-authored-by: Nick Bradbury <[email protected]>
|
|
Claude finished @nbradbury's task in 2m 16s —— View job Code Review Complete
SummaryThis PR successfully restores media selection functionality in the Aztec editor by re-implementing However, I've identified a critical inconsistency that likely explains the crash @dcalhoun experienced. Critical Issue: Inconsistent Camera Permission HandlingLocation: Problem: The override fun onCapturePhotoClicked() {
if (WPMediaUtils.currentUserCanUploadMedia(siteModel)) {
launchCamera() // ❌ Missing permission check!
} else {
editorPhotoPicker?.showNoUploadPermissionSnackbar()
}
}Correct Implementation: The MediaToolbarAction.CAMERA -> {
if (WPMediaUtils.currentUserCanUploadMedia(siteModel)) {
editorMediaActions.checkCameraPermissionAndLaunch() // ✅ Proper permission handling
} else {
showNoUploadPermissionSnackbar()
}
}Impact: When camera permissions aren't granted, calling Recommendation: Change override fun onCapturePhotoClicked() {
if (WPMediaUtils.currentUserCanUploadMedia(siteModel)) {
checkCameraPermissionAndLaunch() // Use the permission-aware method
} else {
editorPhotoPicker?.showNoUploadPermissionSnackbar()
}
}Code Quality Issues1. Line Length Violation (EditorCameraHelper.kt:21-24)Line 120+ characters (violates project's 120-character limit from CLAUDE.md): if (PermissionUtils.checkAndRequestCameraAndStoragePermissions(
activity,
WPPermissionUtils.AZTEC_EDITOR_CAMERA_PERMISSION_REQUEST_CODE
)This is acceptable formatting for long function calls. 2. Documentation QualityThe 3. Naming ConsistencyThe interface name Security Considerations✅ Good:
Performance Implications✅ Good:
Note: The Test Coverage Analysis✅ Excellent test coverage in
Recommendation: Consider adding unit tests for @Test
fun `checkCameraPermissionAndLaunch calls launchCamera when permissions granted`() {
// Test the helper methods directly
}
@Test
fun `handlePermissionResult returns true for correct request code`() {
// Test the permission result handling
}Architecture & Design✅ Excellent refactoring:
Minor Suggestion: Consider adding Additional ObservationsEditorPhotoPicker.kt:125The conditional camera setup is correct: cameraSetup = if (showAztecEditor) CameraSetup.HIDDEN else CameraSetup.ENABLED,This properly hides the camera FAB in Aztec (since Aztec has toolbar buttons) and shows it in Gutenberg. WPPermissionUtils.java:38Good addition of the permission request code constant: public static final int AZTEC_EDITOR_CAMERA_PERMISSION_REQUEST_CODE = 42;Properly documented that these codes are reported to analytics. Recommendations Summary
Final VerdictThe PR successfully restores Aztec media selection functionality with well-structured code and good test coverage. However, the critical inconsistency in Once the camera permission handling is made consistent across all code paths, this will be a solid improvement to the codebase. |





As noted in this comment, this PR broke media selection in the Aztec editor. This PR restores it and updates the related tests.
@dcalhoun I've not added testing steps since you spotted the problem and are familiar with how to test it.