Skip to content

armgit / andee

Public Imported from GitHub
0

Andee lives on your phone or Mac and uses any app like you do—no integrations, no root, any model; memory and passwords never leave your device | Andee 住进你的手机或 Mac,像你一样操作任何 App——无需集成、无需 Root、支持任意模型,记忆和密码绝不离开设备。

fix(mac): a refused voice handshake reads as a scrollback error, not a silent tap

booboosui2aa1f354203b
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt
index acafd92..cf190a8 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/ChatScreen.kt
@@ -165,6 +165,11 @@ fun ChatScreen(onOpenArtifacts: () -> Unit, onOpenTopic: (Long) -> Unit = {}, on
heard = ""
Thread { Assistant.say(said) }.start()
}
+ net.kuafuai.andee.desktop.voice.MacVoice.onError = { msg ->
+ // The phone's `svc_voice_error_line` row: a red bubble in the scrollback, so a
+ // refused handshake (a dead key, a closed service) is said instead of swallowed.
+ Scrollback.add(Scrollback.Role.ERROR, (if (Strings.lang() == "zh") "语音:" else "Voice: ") + msg)
+ }
}
LaunchedEffect(Unit) { pending = Assistant.pending }
// A message that arrives while the page is open scrolls into view smoothly. The first run is skipped: the
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/voice/MacVoice.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/voice/MacVoice.kt
index 9237b0c..1e1f90d 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/voice/MacVoice.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/voice/MacVoice.kt
@@ -33,6 +33,13 @@ object MacVoice {
@Volatile var onPartial: (String) -> Unit = {}
@Volatile var onFinal: (String) -> Unit = {}
@Volatile var onState: (State) -> Unit = {}
+ /**
+ * Fired when a turn could not be heard — the engine failed to start, or the
+ * server refused the handshake. The window puts it in the scrollback as an
+ * error row, the same place the phone's `reportVoiceFailure` leaves it, so a
+ * dead voice key reads as a message instead of a tap that did nothing.
+ */
+ @Volatile var onError: (String) -> Unit = {}
enum class State { IDLE, LISTENING, SPEAKING }
@@ -227,6 +234,8 @@ object MacVoice {
listening.set(false)
Log.w(TAG, "asr: $msg")
onPartial.invoke("")
+ // `onError` alone resolves to this very method, so name the object.
}
override fun onClosed() { disarmWatchdog(); listening.set(false) }
}