Fix/mobiles#102
Conversation
|
Warning Review limit reached
More reviews will be available in 38 minutes and 16 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (16)
📝 WalkthroughWalkthroughThis PR adds file cleanup for orphaned recordings, native file-operation methods on Android and iOS, a TypeScript wrapper for those methods, and refactors the ChangesRecording File Cleanup and AudioRecorder Refactor
Sequence Diagram(s)sequenceDiagram
participant TSUtil as deleteLocalRecordingFile (TypeScript)
participant Native as FileUploadModule (Native)
participant FS as File System
TSUtil->>Native: call deleteLocalFile(filePath)
Native->>FS: normalizePath / unlink
FS-->>Native: success / error
Native-->>TSUtil: resolve(null) / reject(DELETE_ERROR)
TSUtil->>Native: call localFileExists(filePath)
Native->>FS: normalizePath / stat
FS-->>Native: exists: boolean
Native-->>TSUtil: resolve(boolean)
sequenceDiagram
participant Store as Recordings Store
participant Hydration as rehydrate()
participant Cleanup as removeMissingLocalRecordingsAfterHydration
participant FileCheck as localFileExists()
participant Alert as MissingFilesAlertHandler / Alert
Hydration->>Store: restore persisted recordings
Hydration->>Cleanup: invoke after rehydrate
Cleanup->>FileCheck: check each recording file
FileCheck-->>Cleanup: exists: boolean[]
Cleanup->>Store: remove recordings with missing files
Cleanup->>Alert: set missingFilesPending (localized list)
Alert->>User: show alert on active app / mount
User-->>Alert: dismiss
stateDiagram-v2
[*] --> idle
idle --> loading: start requested
loading --> recording: permissions granted & session active
recording --> paused: pause requested
paused --> recording: resume requested
recording --> stopping: stop requested
paused --> stopping: stop requested
stopping --> idle: stop completed & cleanup done
loading --> idle: lifecycle invalidated or permissions denied
recording --> idle: lifecycle invalidated
paused --> idle: lifecycle invalidated
sequenceDiagram
participant UI as UI Press
participant Queue as enqueueRecorderAction
participant Lifecycle as beginLifecycleAction
participant Recorder as Recorder API
participant Storage as addRecording()
UI->>Queue: onStartRecord pressed
Queue->>Lifecycle: begin action with token
Lifecycle->>Recorder: requestAudioSession, startRecording
Recorder-->>Lifecycle: success
Lifecycle->>Lifecycle: setRecorderPhaseIfCurrent(recording)
UI->>Queue: onStopRecord pressed
Queue->>Lifecycle: begin action with token
Lifecycle->>Recorder: stopRecording
Recorder-->>Lifecycle: file path
Lifecycle->>Storage: addRecording(title, filePath)
Storage-->>Lifecycle: recording id
Lifecycle->>Lifecycle: setRecorderPhaseIfCurrent(idle)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/mobile/src/services/storage.ts`:
- Around line 70-73: The Alert.alert call inside
removeMissingLocalRecordingsAfterHydration (triggered from
useRecordingsStore.persist.onRehydrateStorage in storage.ts) must be removed and
replaced with a deferred notification mechanism: have
removeMissingLocalRecordingsAfterHydration record the removedFileList into a
persisted/in-memory flag or emit an app-level event (e.g., via an EventEmitter
or store flag like recordings.missingFilesPending) instead of calling
Alert.alert directly; then update the UI layer (a mounted screen or root
navigator) to listen for that flag/event and show Alert.alert only when the app
is foregrounded/active (AppState === 'active') or when a screen gains focus.
Ensure the unique symbols referenced are
removeMissingLocalRecordingsAfterHydration,
useRecordingsStore.persist.onRehydrateStorage, and the Alert.alert call in
storage.ts so reviewers can locate and remove the immediate alert invocation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 7eebd6e8-5956-428c-a93d-7ed67d9d2457
📒 Files selected for processing (11)
src/mobile/android/app/build.gradlesrc/mobile/android/app/src/main/java/fr/gouv/assistant_transcripts/FileUploadModule.ktsrc/mobile/ios/AssistantTranscripts.xcodeproj/project.pbxprojsrc/mobile/ios/FileUploadModule.msrc/mobile/ios/FileUploadModule.swiftsrc/mobile/package.jsonsrc/mobile/src/components/AudioRecorder.tsxsrc/mobile/src/i18n/locales/en.jsonsrc/mobile/src/i18n/locales/fr.jsonsrc/mobile/src/services/storage.tssrc/mobile/src/utils/deleteLocalRecordingFile.ts
The OS can clear the cache sometimes. This change makes it that now we store in the document directory and not the cache directory.
For some reason I forgot to code the delete audio files part. Sorry.
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/mobile/android/app/src/main/java/fr/gouv/assistant_transcripts/FileUploadModule.kt`:
- Around line 135-148: In deleteLocalFile, avoid deleting directories by
checking that the resolved File is a regular file before calling delete(): after
creating val file = File(normalizePath(filePath)) and verifying file.exists(),
add a guard using file.isFile (or !file.isDirectory) and if it’s not a file call
promise.reject("INVALID_TARGET", "Target is not a file") (or similar) and
return; only call file.delete() for actual files to prevent removing directories
outside the API contract.
In
`@src/mobile/android/app/src/main/java/fr/gouv/assistant_transcripts/MainActivity.kt`:
- Around line 30-32: Remove the commented deep-link debug lines or gate them
behind a debug flag: either delete the three commented Log/Uri lines in onCreate
and the corresponding ones in onNewIntent, or replace them with conditional
logging that runs only when BuildConfig.DEBUG is true; target the commented
blocks associated with onCreate and onNewIntent (the lines that reference
"DEEPLINK", Uri, and intent) so the deep-link debug output is either removed or
enabled only in debug builds.
In `@src/mobile/App.tsx`:
- Around line 43-46: The logout flow currently calls clearAuthState() without
awaiting it before calling resetNavigationHistory('Login'), so failures can
leave secrets persisted while the app navigates; update the handler that checks
params.logout to await clearAuthState() and only call
resetNavigationHistory('Login') after it resolves, wrapping the await in a
try/catch to handle and log any rejection (and optionally surface an error UI)
so failures aren't ignored; modify the block containing clearAuthState(),
resetNavigationHistory, and the params.logout check to implement this change.
In `@src/mobile/ios/FileUploadModule.swift`:
- Around line 116-126: The code currently allows deleting directories because it
only checks file existence; update both deletion sites in FileUploadModule.swift
to enforce "regular-file only" by using
FileManager.fileExists(atPath:isDirectory:) (or FileManager.attributesOfItem) to
ensure isDirectory is false before calling fileManager.removeItem(atPath:). If
the path is a directory, call rejecter with a suitable "DELETE_ERROR" message
(do not perform removeItem) and only call resolver(nil) after a successful
removal of a regular file; reference the existing symbols fileManager,
normalizedPath, resolver, and rejecter when making the changes.
In `@src/mobile/src/components/AudioRecorder.tsx`:
- Line 678: The callbacks handleStartRecording, onPauseRecord, and
onResumeRecord reference showRecordingNotification but do not include it in
their useCallback dependency arrays; add showRecordingNotification to each
callback's dependency array to silence lint warnings and avoid stale closures
(update the dependency lists for handleStartRecording, onPauseRecord, and
onResumeRecord to include showRecordingNotification alongside their existing
deps).
In `@src/mobile/src/features/auth/api/useUser.tsx`:
- Around line 80-83: The local auth cleanup call clearAuthState() is executed
before the guarded remote logout try block and can short-circuit the remote
logout and the finally cleanup if it rejects; move await clearAuthState() (and
any other pre-logout local cleanup such as clearCachedUser() if applicable)
inside the try that contains the remote logout so it executes under the same
error guard, and make the same change for the duplicated occurrence around the
final cleanup (the calls near clearCachedUser() / clearAuthState() at the end)
so both places run inside their respective try blocks and allow the finally
block to always execute.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1601b126-697b-4347-a849-e633507b468c
📒 Files selected for processing (16)
src/mobile/App.tsxsrc/mobile/android/app/build.gradlesrc/mobile/android/app/src/main/java/fr/gouv/assistant_transcripts/FileUploadModule.ktsrc/mobile/android/app/src/main/java/fr/gouv/assistant_transcripts/MainActivity.ktsrc/mobile/ios/AssistantTranscripts.xcodeproj/project.pbxprojsrc/mobile/ios/FileUploadModule.msrc/mobile/ios/FileUploadModule.swiftsrc/mobile/package.jsonsrc/mobile/src/components/AudioRecorder.tsxsrc/mobile/src/features/auth/api/useUser.tsxsrc/mobile/src/i18n/locales/en.jsonsrc/mobile/src/i18n/locales/fr.jsonsrc/mobile/src/navigation/types.tssrc/mobile/src/services/authService.tssrc/mobile/src/services/storage.tssrc/mobile/src/utils/deleteLocalRecordingFile.ts
…n't exist anymore
This caused some log error
This avoids some buggy behavior where the auth is not fully cleared When coming back from the in app browser.
For later if we implement it.
On android, sometimes coming back from the in app browser login process wouldn't do anything because the intent was lost before the react native part of the app would start. This is an attempt to fix it.
Fixes to make the Mobile App recording experience more robust.
Mostly the files were stored in cache and never deleted.
Summary by CodeRabbit
New Features
Improvements