Files
orca/mobile/package.json
T
JinjingandOrca 2e48495273 Prevent mobile screen locking during voice dictation. (#7746)
* Prevent mobile screen locking during voice dictation

Integrate expo-keep-awake to prevent the mobile device from locking or
sleeping while a voice dictation session is active.

- Modularize useMobileDictation logic into separate helper files for
  keep-awake, audio chunking, session state, and desktop startup.
- Acquire keep-awake lock only after successfully establishing a
  desktop session to avoid locking on stale start attempts.
- Release the keep-awake lock on all completion, cancellation, error,
  and unmount paths.
- Add source invariant unit tests to verify keep-awake ownership and
  strict cleanup ordering.

* serialize keep-awake operations and avoid stale dictation start races

- Implement a global execution queue and tag tracking for keep-awake
  operations to prevent concurrent races and stale deactivations.
- Track failed native deactivations and retry them when a replacement
  hook owner mounts or starts a new dictation session.
- Ensure stale or canceled desktop dictation starts do not reset the
  UI state or propagate outdated start/keep-awake failures.
- Reuse the audio chunk queue wiring in useMobileDictation to avoid
  allocating new closure objects on the high-frequency microphone path.
- Add comprehensive unit tests for the keep-awake and desktop start hooks.

* Commit native recording during dictation session startup

Commit native recording in the same continuation as the final session
stale check. This prevents a queued cancellation from resurrecting the
microphone recording after cleanup has already run. If microphone
initialization fails or throws, acquired resources (like keep-awake
locks and the remote desktop session) are properly rolled back.

* Make keep-awake acquisition best-effort with a bounded startup timeout

- Recording start no longer blocks (or fails) on keep-awake acquisition:
  a hung or failing native call is capped at a short budget and logged
  instead of delaying or aborting dictation.
- Add native-call timeouts, orphan-tag tracking, and reacquire/drain
  logic in mobile-dictation-keep-awake.ts so Activity recreation on
  Android and stale tags no longer wedge the keep-awake queue.
- Add useMobileDictationForegroundKeepAwake to refresh the wake tag on
  Android foreground and retry failed refreshes/deactivations.
- Hold the wake tag through chunk drain and the finish RPC so a screen
  lock can't suspend the app before the transcript arrives, and keep
  cleanup running even if native recording shutdown throws.
- Loosen expo-keep-awake to a caret range to unblock the patch pulling
  in these native fixes.

* Fix cancellation races in mobile dictation keep-awake handling

- Run wake-lock release and dictation cancel concurrently on stale
  starts so a hung acquisition no longer delays the native cancel
- Guard foreground reacquire retries with a run token so a stale
  retry chain can't deactivate a wake lock reacquired by a newer
  AppState transition

* Update source invariant test for concurrent stale-start cleanup

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Orca <help@stably.ai>
2026-07-10 23:31:56 -07:00

87 lines
2.7 KiB
JSON

{
"name": "orca-mobile",
"version": "0.0.1",
"private": true,
"main": "expo-router/entry",
"scripts": {
"start": "node scripts/start-expo.mjs",
"android": "expo run:android",
"ios": "expo run:ios",
"postinstall": "node scripts/build-terminal-webview-engine.mjs",
"test": "vitest run",
"lint": "oxlint",
"format": "oxfmt --write .",
"format:check": "oxfmt --check .",
"mock-server": "npx tsx scripts/mock-server.ts",
"repro:workspace-picker-lag": "npx tsx scripts/repro-workspace-picker-lag.ts",
"start:emulator": "node scripts/start-emulator.mjs"
},
"dependencies": {
"@orca/expo-two-way-audio": "file:./packages/expo-two-way-audio",
"@react-native-async-storage/async-storage": "^2.2.0",
"@xterm/addon-unicode11": "0.10.0-beta.285",
"@xterm/addon-webgl": "0.20.0-beta.284",
"@xterm/xterm": "6.1.0-beta.285",
"buffer": "^6.0.3",
"expo": "^55.0.27",
"expo-build-properties": "^55.0.13",
"expo-camera": "^55.0.18",
"expo-clipboard": "^55.0.13",
"expo-constants": "^55.0.16",
"expo-crypto": "^55.0.14",
"expo-dev-client": "~55.0.35",
"expo-document-picker": "^55.0.13",
"expo-file-system": "55.0.19",
"expo-haptics": "^55.0.14",
"expo-image-manipulator": "^55.0.17",
"expo-image-picker": "^55.0.20",
"expo-keep-awake": "~55.0.8",
"expo-linking": "^55.0.15",
"expo-modules-core": "~55.0.25",
"expo-network": "~55.0.14",
"expo-notifications": "^55.0.22",
"expo-router": "^55.0.14",
"expo-secure-store": "^55.0.13",
"expo-splash-screen": "^55.0.20",
"expo-status-bar": "^55.0.6",
"lowlight": "^3.3.0",
"lucide-react-native": "^1.14.0",
"react": "^19.2.6",
"react-dom": "19.2.6",
"react-native": "^0.83.9",
"react-native-gesture-handler": "^2.31.2",
"react-native-reanimated": "^4.3.0",
"react-native-safe-area-context": "^5.7.0",
"react-native-screens": "^4.24.0",
"react-native-svg": "^15.15.4",
"react-native-web": "^0.21.2",
"react-native-webview": "^13.16.1",
"react-native-worklets": "^0.8.3",
"tweetnacl": "^1.0.3",
"ws": "^8.21.0",
"zod": "~4.4.3",
"zustand": "^5.0.13"
},
"devDependencies": {
"@types/react": "^19.2.14",
"@types/react-native": "^0.73.0",
"@types/react-test-renderer": "19.1.0",
"@types/ws": "^8.18.1",
"acorn": "8.15.0",
"esbuild": "0.25.4",
"expo-module-scripts": "^55.0.2",
"oxfmt": "^0.52.0",
"oxlint": "^1.71.0",
"react-test-renderer": "19.2.6",
"tsx": "^4.22.4",
"typescript": "^7.0.2",
"vite": "^8.0.16",
"vitest": "^4.1.9"
},
"pnpm": {
"overrides": {
"xcode>uuid": "11.1.1"
}
}
}