Skip to content

fix: audit batch 2 — correctness bugs + Android robustness#696

Merged
appergb merged 7 commits into
betafrom
fix/audit-batch2-bugs
Jun 17, 2026
Merged

fix: audit batch 2 — correctness bugs + Android robustness#696
appergb merged 7 commits into
betafrom
fix/audit-batch2-bugs

Conversation

@appergb

@appergb appergb commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

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: set voice_agent=true inside the lock before the async ASR handshake (was set after pending_stop could fire).
  • Volcengine/Bailian ASR error path: call asr.cancel() on Ok(Err) to avoid leaking the WebSocket.

Robustness

  • Store init no longer panics on I/O failure at startup — falls back to a temp-dir-backed store; normal startup unchanged.

Android (Rust CI-verified; Kotlin needs a real Android build)

  • OVERLAY_VISIBLE desync: reset to false when the overlay service is destroyed (incl. OS kill) — Rust export + OpenLessOverlayService.onDestroy() wiring.
  • JNI: null-check the raw context pointer before JObject::from_raw.
  • Accessibility paste: save/restore the user clipboard around the paste fallback.

Verification (macOS host)

  • cargo test --lib: 446 passed, 0 failed; cargo check/clippy clean; npx tsc --noEmit clean; npm run build clean.
  • Android Rust compiles via the Android cargo-check CI job. The Kotlin onDestroy wiring 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

Relevant files
Bug fix
6 files
insert.rs
Save and restore clipboard during accessibility paste       
+24/-1   
native_bridge.rs
Add overlay destroy notification to sync state                     
+18/-0   
dictation.rs
Fix ASR resource leaks and add voice_agent flag during session start
+16/-0   
hotkey_loops.rs
Fix voice_agent race by setting it before ASR handshake   
+6/-4     
persistence.rs
Add store fallbacks and fix timestamp parsing fallback     
+47/-1   
OpenLessOverlayService.kt
Call overlay destroy notification on service destruction 
+2/-0     
Enhancement
2 files
jni.rs
Add clipboard functions and null-check for Android context
+78/-1   
OpenLessNative.kt
Declare native overlay destroy function                                   
+2/-0     
Error handling
1 files
coordinator.rs
Fallback store initialization to avoid panics                       
+38/-14 

sim and others added 7 commits June 17, 2026 11:24
…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]
@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

@appergb appergb merged commit 5aed1e4 into beta Jun 17, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant