fix: audit batch 2 — correctness bugs + Android robustness#696
Merged
Conversation
…cent_within_minutes Replace unwrap_or(false) with unwrap_or(true) so a corrupt created_at field no longer silently truncates the take_while iteration. Aligns with the conservative policy already used by append_with_retention.
…d Bailian ASR Without cancel(), the streaming WebSocket connection leaked when await_final_result() returned an error (non-timeout path). Both Volcengine and Bailian streaming ASR now have symmetric cleanup between their error and timeout branches.
…handle_less_computer_pressed Add begin_session_as(inner, voice_agent) which stamps voice_agent into SessionState inside the same lock block as begin_session_state. This prevents the race where finish_starting_session processes a pending_stop (fast key-release during ASR handshake) before voice_agent is set, causing the transcript to silently route through normal dictation instead of run_voice_agent_transcript.
…verified-only] Add notify_overlay_destroyed() and the matching JNI export nativeNotifyOverlayDestroyed, which Kotlin must call from OpenLessOverlayService.onDestroy(). This clears the Rust-side OVERLAY_VISIBLE atomic so refresh_overlay_if_visible() does not dispatch REFRESH_LAYOUT commands to a dead service.
… in with_android_env [CI-verified-only] android_context().context() returns a *mut c_void that may be null if Tauri/tao has not yet initialized the Android context (early startup or process-restart edge cases). Calling JObject::from_raw(null) leads to misleading NullPointerException from later JNI calls. Fail early with a clear error message instead.
…ssibility [CI-verified-only] The accessibility insertion path wrote dictated text to the system clipboard but never restored what was there before. On Android 10+ we now save the primary clip before copy_fallback(), and restore it after a successful paste_via_accessibility() call. Adds get_primary_clip_text / set_primary_clip_text JNI helpers in jni.rs.
…ervice.onDestroy Completes the overlay-desync fix: the Rust export resets OVERLAY_VISIBLE=false, but nothing called it. onDestroy runs even when the OS kills the foreground service, so this prevents OVERLAY_VISIBLE from getting stuck true. [Kotlin — needs a real Android build to compile-verify; Android cargo check covers Rust only]
Contributor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
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.
User description
Summary
Batch 2 of the 1-app audit: 7 medium-severity correctness/robustness findings (3 bugs, 3 Android robustness, 1 startup-panic). Behavior-preserving defect fixes; no broad refactors.
Bugs
recent_within_minutes: a single unparseable timestamp no longer silently truncates the context window.handle_less_computer_pressed: setvoice_agent=trueinside the lock before the async ASR handshake (was set afterpending_stopcould fire).asr.cancel()onOk(Err)to avoid leaking the WebSocket.Robustness
Android (Rust CI-verified; Kotlin needs a real Android build)
OVERLAY_VISIBLEdesync: reset to false when the overlay service is destroyed (incl. OS kill) — Rust export +OpenLessOverlayService.onDestroy()wiring.JObject::from_raw.Verification (macOS host)
cargo test --lib: 446 passed, 0 failed;cargo check/clippyclean;npx tsc --noEmitclean;npm run buildclean.onDestroywiring is not compile-checked by CI (cargo only) — minimal pattern-matching change; confirm in a real Android build.🤖 Generated with Claude Code
PR Type
Bug fix, Enhancement
Description
Fix 3 correctness bugs (timestamp parse, ASR leak, voice_agent race)
Add store init fallback to avoid panics
Improve Android robustness (overlay sync, null check, clipboard restore)
File Walkthrough
6 files
Save and restore clipboard during accessibility pasteAdd overlay destroy notification to sync stateFix ASR resource leaks and add voice_agent flag during session startFix voice_agent race by setting it before ASR handshakeAdd store fallbacks and fix timestamp parsing fallbackCall overlay destroy notification on service destruction2 files
Add clipboard functions and null-check for Android contextDeclare native overlay destroy function1 files
Fallback store initialization to avoid panics