Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.
Merge branch 'development' into opencode/issue25-20260806051738
Rishabh Bajpaid4d29a2a90f6
diff --cc CHANGELOG.mdindex 177e74b,f66155d..8e6d0c4--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -4,21 -4,28 +4,43 @@@ All notable changes to Gotcha are docum## [Unreleased]+### Changed — Wake word & call-mode feel (#25)++- **The wake-word acknowledgment is now one short word.** Saying "Hey Gotcha"+ used to reply with the full "Call started. I'm ready when you are." sentence,+ which made the wake word feel ignored and delayed the mic opening. It now+ answers with a single "Yes?" (translated per language) and the mic opens+ sooner. Normal long-press calls get a tighter "Call started. Go ahead."+- **The ball now visibly reacts when the wake word fires.** It gives a quick+ scale bounce while an accent ring radiates from it on its own overlay window,+ so the pulse still plays after the ball is hidden by the call window. Respects+ the system "remove animations" preference.+- **Long-press to start a call is 1 second instead of 2.** The hold-to-call+ gesture on the floating ball was reduced from 2000 ms to 1000 ms; the+ expanding ring that previews it stays in sync.++ ### Fixed — Call mode no longer swallows STT/TTS failures (#23)++ - **A failed mic tap is now visible.** When `startMic` can't start the+ recognizer (busy, MediaRecorder failure, provider unavailable), the call shows+ "Couldn't start the microphone — tap again to retry." instead of silently doing+ nothing; the mic stays ready for another tap.+ - **Hands-free STT failures are no longer mistaken for silence.** The wake-word+ listen loop now tells a real recognition failure apart from "No speech+ detected": genuine errors (network, permissions, recognizer busy, ...) are+ surfaced with the existing error card + vibration and end the call with an+ explanation, while silence keeps its quiet retry-and-auto-end behaviour. Only+ silence counts toward the auto-end strikes.+ - **Tool-progress narration TTS failures surface too.** A failed narration shows+ the shared "Couldn't play voice audio — check your Text-to-Speech settings."+ card once per call (repeats are logged), instead of being fire-and-forget.+ - **In-call error line.** The two floating call buttons now show a transient+ error line above them, so an in-call error is visible right where the user's+ eyes are even when the overlay card is off-screen. The overlay card remains+ the persistent mid-call surface.+ - Hands-free loop also hands control back to the pre-listen state after a blank+ listen, so retry (and answering an agent question in place) works as intended.+### Fixed — Malformed tool call no longer bricks the chat (#13)- **A tool call with invalid `arguments` JSON can no longer poison a chat.** Whendiff --cc app/src/main/java/com/gotcha/service/CallSessionController.ktindex 390b451,8bfee52..0b916a3--- a/app/src/main/java/com/gotcha/service/CallSessionController.kt+++ b/app/src/main/java/com/gotcha/service/CallSessionController.kt@@@ -254,45 -244,60 +263,56 @@@ class CallSessionControllerhandsFreeAutoListen?.cancel()handsFreeAutoListen = scope.launch {var silentStrikes = 0-- while (isActive && handsFree && [email protected]()) {-- if (awaitHandsFreeInput()) {- // Remember why the mic opened so a blank listen can hand- // control back to the same place (fresh turn vs. a pending- // agent question) and the loop can listen again.- val listeningFrom = _state.value-- _state.value = CallState.LISTENING-- val s = settingsRepository.load()-- val outcome = sttEngine.listenForUtterance(-- provider = s.sttProvider,-- model = s.sttApiModel,-- language = currentLanguage(),-- silenceTimeoutMs = if (s.sttProvider == AudioProvider.ANDROID) {-- ANDROID_SILENCE_MS-- } else {-- HANDS_FREE_SILENCE_MS-- }-- )-- val text = outcome.getOrNull().orEmpty()- if (text.isBlank()) {- // Silence or a transient STT error is normal while the- // user is quiet; retry a couple of times, then end.- silentStrikes++- if (silentStrikes >= HANDS_FREE_SILENT_STRIKES) {- endCall()- break- if (text.isNotBlank()) {- silentStrikes = 0- if (listeningFrom == CallState.WAITING_USER) {- // The agent is awaiting an answer: complete its gate in- // place without touching the running turn job.- finishTurn(text)- } else {- // Fresh turn: run it in its own job so this loop stays- // free to re-listen if the agent asks a question.- questionGate = null // drop any stale gate from a timed-out question- currentTurnJob?.cancel()- currentTurnJob = scope.launch { finishTurn(text) }-- }- continue++ while (isActive && handsFree && [email protected]() && awaitHandsFreeInput()) {++ // Remember why the mic opened so a blank listen can hand++ // control back to the same place (fresh turn vs. a pending++ // agent question) and the loop can listen again.++ val listeningFrom = _state.value++ _state.value = CallState.LISTENING++ val s = settingsRepository.load()++ val outcome = sttEngine.listenForUtterance(++ provider = s.sttProvider,++ model = s.sttApiModel,++ language = currentLanguage(),++ silenceTimeoutMs = if (s.sttProvider == AudioProvider.ANDROID) {++ ANDROID_SILENCE_MS+ } else {- // Distinguish a real STT failure from plain silence. Only- // silence counts toward the auto-end strikes and stays- // quiet; genuine failures are surfaced and end the call- // with an explanation instead of looking like the user- // never spoke.- val error = outcome.exceptionOrNull()- if (error != null && !SttEngine.isBenignSttError(error)) {- reportError(friendlyAgentError(error as? Exception ?: Exception(error.message)))- endCall()- break- }- silentStrikes++- _state.value = listeningFrom- if (silentStrikes >= HANDS_FREE_SILENT_STRIKES) {- endCall()- break- }- continue++ HANDS_FREE_SILENCE_MS+ }++ )++ val text = outcome.getOrNull().orEmpty()++ if (text.isNotBlank()) {+ silentStrikes = 0- if (_state.value == CallState.WAITING_USER) {++ if (listeningFrom == CallState.WAITING_USER) {+ // The agent is awaiting an answer: complete its gate in+ // place without touching the running turn job.+ finishTurn(text)+ } else {+ // Fresh turn: run it in its own job so this loop stays+ // free to re-listen if the agent asks a question.+ questionGate = null // drop any stale gate from a timed-out question+ currentTurnJob?.cancel()+ currentTurnJob = scope.launch { finishTurn(text) }}} else {-- break++ // Distinguish a real STT failure from plain silence. Only++ // silence counts toward the auto-end strikes and stays++ // quiet; genuine failures are surfaced and end the call++ // with an explanation instead of looking like the user++ // never spoke.++ val error = outcome.exceptionOrNull()++ if (error != null && !SttEngine.isBenignSttError(error)) {++ reportError(friendlyAgentError(error as? Exception ?: Exception(error.message)))++ endCall()++ break++ }++ silentStrikes++++ _state.value = listeningFrom++ if (silentStrikes >= HANDS_FREE_SILENT_STRIKES) {++ endCall()++ break++ }++ continue}}handsFreeAutoListen = nulldiff --cc app/src/main/java/com/gotcha/ui/CallChatWindow.ktindex 325e4c6,a880454..9ca6260--- a/app/src/main/java/com/gotcha/ui/CallChatWindow.kt+++ b/app/src/main/java/com/gotcha/ui/CallChatWindow.kt@@@ -58,8 -59,28 +60,29 @@@ class CallChatWindow(context: Context)private var actionBtn: View? = nullprivate var endBtn: View? = nullprivate var endWrapper: View? = null+ private var statusPill: View? = null+ /** The horizontal button row (action + end), kept so touch hit-tests don't+ * have to walk the root's children (the error label lives above it). */+ private var buttonsRow: LinearLayout? = null++ /** Transient error line shown above the buttons while an in-call error is fresh. */+ private var errorLabel: TextView? = null+ private var errorAnimator: ViewPropertyAnimator? = null+ private val errorLabelHideRunnable = Runnable {+ val label = errorLabel ?: return@Runnable+ errorAnimator?.cancel()+ errorAnimator = label.animate()+ .alpha(0f)+ .translationY(label.translationY - dp(6f))+ .setDuration(200L)+ .setInterpolator(AccelerateDecelerateInterpolator())+ .withEndAction {+ label.visibility = View.GONE+ }+ errorAnimator?.start()+ }+// Ring as a separate overlay window (not inside the layout)private var ringOverlayView: View? = nullprivate var ringOverlayAnimator: ValueAnimator? = null@@@ -136,7 -160,8 +162,9 @@@actionBtn = nullendBtn = nullendWrapper = null+ statusPill = null+ buttonsRow = null+ errorLabel = null}}@@@ -169,6 -194,55 +197,60 @@@}}+ /**+ * Minimal in-call text error surface: a transient glass card floating above the+ * buttons so a failure stays visible even if the user isn't looking at the+ * overlay card. Auto-hides after [ERROR_LABEL_SHOW_MS]. No-op when the window+ * isn't showing (e.g. start-call failures that fire before the buttons appear).+ */+ fun showError(message: String) {+ mainHandler.post {+ if (rootView == null) return@post+ val label = errorLabel ?: return@post+ val row = buttonsRow ?: return@post++ mainHandler.removeCallbacks(errorLabelHideRunnable)+ errorAnimator?.cancel()++ val formatted = if (message.startsWith("⚠️") || message.startsWith("❌")) message else "⚠️ $message"+ label.text = formatted++ val widthSpec = View.MeasureSpec.makeMeasureSpec(dp(240f), View.MeasureSpec.AT_MOST)+ val heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)+ label.measure(widthSpec, heightSpec)++ val labelWidth = label.measuredWidth+ val labelHeight = label.measuredHeight+ val rowWidth = if (row.width > 0) row.width else dp(BTN_SIZE_DP * 2f + 22f)+- val targetX = (rowWidth - labelWidth) / 2f- val targetY = -labelHeight.toFloat() - dp(8f)++ // The row no longer sits at the window origin: the status pill above++ // it shifts it down, and horizontal centering in the container shifts++ // it right. Anchor the label to the row's real position (the container++ // itself is at (0,0)), so it floats just above the buttons, clear of++ // the pill.++ val targetX = row.left + (rowWidth - labelWidth) / 2f++ val targetY = -(row.top + labelHeight.toFloat() + dp(8f))++ label.translationX = targetX++ val isAlreadyVisible = label.visibility == View.VISIBLE && label.alpha > 0f+ if (!isAlreadyVisible) {+ label.alpha = 0f+ label.translationY = targetY + dp(6f)+ label.visibility = View.VISIBLE+ }++ errorAnimator = label.animate()+ .alpha(1f)+ .translationY(targetY)+ .setDuration(220L)+ .setInterpolator(DecelerateInterpolator())+ errorAnimator?.start()++ mainHandler.postDelayed(errorLabelHideRunnable, ERROR_LABEL_SHOW_MS)+ }+ }+// ---- Rendering ----/** (emoji, glass tint) for the action button in a given call state. */@@@ -389,36 -430,40 +471,75 @@@actionBtn?.let { row.addView(it) }(actionBtn?.layoutParams as? LinearLayout.LayoutParams)?.setMargins(0, 0, (6 * density).toInt(), 0)row.addView(wrapper)+ buttonsRow = row+ val pill = TextView(appContext).apply {+ textSize = 12f+ setTypeface(null, Typeface.BOLD)+ setTextColor(Color.WHITE)+ gravity = Gravity.CENTER+ setPadding((12 * density).toInt(), (5 * density).toInt(), (12 * density).toInt(), (5 * density).toInt())+ background = GradientDrawable().apply {+ shape = GradientDrawable.RECTANGLE+ cornerRadius = 16f * density+ setColor(ColorUtils.setAlphaComponent(Color.BLACK, 175))+ setStroke((1 * density).toInt(), ColorUtils.setAlphaComponent(Color.WHITE, 45))+ }+ visibility = View.INVISIBLE+ }+ statusPill = pill++ val container = LinearLayout(appContext).apply {+ orientation = LinearLayout.VERTICAL+ gravity = Gravity.CENTER_HORIZONTAL+ setOnTouchListener(containerTouchListener())+ addView(pill)+ (pill.layoutParams as? LinearLayout.LayoutParams)?.setMargins(0, 0, 0, (6 * density).toInt())+ addView(row)+ addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ ->+ followRootWithActionRing()+ }+ }+- return container+ errorLabel = TextView(appContext).apply {+ visibility = View.GONE+ textSize = 12f+ gravity = Gravity.CENTER+ setTextColor(Color.WHITE)+ maxWidth = dp(240f)+ setPadding(dp(12f), dp(7f), dp(12f), dp(7f))+ setShadowLayer(4f * density, 0f, 1f * density, Color.parseColor("#80000000"))+ background = GradientDrawable().apply {+ shape = GradientDrawable.RECTANGLE+ cornerRadius = 14f * density+ setColor(Color.parseColor("#E6181820"))+ setStroke((1f * density).toInt(), Color.parseColor("#40E5544B"))+ }+ }+- // FrameLayout wrapper: buttons row stays fixed at origin (0,0), while- // errorLabel floats above it via negative translationY. clipChildren = false- // allows errorLabel to draw cleanly outside the window bounds without- // shifting hit-test coordinates or dragging the buttons.++ // FrameLayout wrapper: the pill + buttons stay in a vertical container at++ // origin (0,0), while errorLabel floats above the buttons via negative++ // translationY. clipChildren = false allows errorLabel to draw cleanly++ // outside the window bounds without shifting hit-test coordinates or++ // dragging the control.+ return FrameLayout(appContext).apply {+ clipChildren = false+ clipToPadding = false- addView(row, FrameLayout.LayoutParams(- FrameLayout.LayoutParams.WRAP_CONTENT,- FrameLayout.LayoutParams.WRAP_CONTENT- ))- addView(errorLabel, FrameLayout.LayoutParams(- FrameLayout.LayoutParams.WRAP_CONTENT,- FrameLayout.LayoutParams.WRAP_CONTENT- ))++ addView(++ container,++ FrameLayout.LayoutParams(++ FrameLayout.LayoutParams.WRAP_CONTENT,++ FrameLayout.LayoutParams.WRAP_CONTENT++ )++ )++ addView(++ errorLabel,++ FrameLayout.LayoutParams(++ FrameLayout.LayoutParams.WRAP_CONTENT,++ FrameLayout.LayoutParams.WRAP_CONTENT++ )++ )+ }}private fun glassButton(emoji: String, size: Int, isEnd: Boolean): View {