fix(android): retain action layer and idle rotation across turns

This commit is contained in:
zenord
2026-10-13 09:36:29 +08:00
parent 24ec3ab044
commit a68988e0ba
21 changed files with 554 additions and 58 deletions
+13 -4
View File
@@ -82,7 +82,7 @@ fun runChecks() {
event("auth"); check(socket.sent.size == 1)
event("hello")
check(statuses == listOf(ConnectionStatus.CONNECTED))
check(logs.filterNot { it.startsWith("listen ") || it.startsWith("ws control skipped") } == listOf("ws open", "auth ok", "hello sent", "hello received"))
check(logs.filterNot { it.startsWith("listen ") || it.startsWith("ws control skipped") } == listOf("ws open", "auth ok", "hello sent action_offer=none generation=0", "hello received action_pack=unknown generation=0"))
check(client.listen(true))
event("hello"); check(statuses.count { it == ConnectionStatus.CONNECTED } == 1)
event("history"); check(events.last() == EventKind.HISTORY)
@@ -96,9 +96,18 @@ fun runChecks() {
Handler.drain()
check(socket.sent == listOf("hello"))
check(statuses == listOf(ConnectionStatus.CONNECTED))
check(logs == listOf("auth ok", "hello sent", "ws open", "hello received"))
check(logs == listOf("auth ok", "hello sent action_offer=none generation=0", "ws open", "hello received action_pack=unknown generation=0"))
close()
}
for((hello,expected) in listOf("hello" to "unknown","hello available" to "accepted","hello unavailable" to "unavailable")) {
Fixture().apply {
event("auth");event(hello);check(client.actionNegotiation==expected)
// Old-generation HELLO cannot overwrite the negotiated connection.
client.callbacks(-1).onMessage(socket,"hello unavailable");Handler.drain()
check(client.actionNegotiation==expected)
close();check(client.actionNegotiation=="disconnected")
}
}
Fixture().apply {
event("hello"); check(statuses.isEmpty() && !client.listen(true))
handshake(); check(statuses.last() == ConnectionStatus.CONNECTED)
@@ -243,7 +252,7 @@ fun runChecks() {
check(states.last().connection == ConnectionStatus.CONNECTING)
cb.onMessage(current, "hello"); Handler.drain()
check(states.last().connection == ConnectionStatus.CONNECTED)
check(listOf("auth ok", "hello sent", "hello received").all { it in logs })
check(listOf("auth ok", "hello sent action_offer=none generation=1", "hello received action_pack=unknown generation=1").all { it in logs })
session.startVoice()
session.background(showDisconnectReason = true)
check(states.last().connection == ConnectionStatus.DISCONNECTED && !states.last().voiceActive)
@@ -471,7 +480,7 @@ fun runChecks() {
session.release(); barrier.countDown(); Handler.drain()
}
check(DebugLogUpload.records.any { it.first == "connect" && it.second.startsWith("state=connected reason=") })
check(DebugLogUpload.records.any { it == "auth" to "hello received" })
check(DebugLogUpload.records.any { it == "auth" to "hello received action_pack=unknown generation=0" })
check(DebugLogUpload.records.any { it == "ws" to "ws event=history" })
check(DebugLogUpload.records.none { (_, message) -> "auth_ready" in message })
check(DebugLogUpload.records.any { (_, message) -> "finish reason=control_send_failure stack=" in message })
+2
View File
@@ -24,6 +24,8 @@ object DialogueProtocol {
fun parseEvent(text: String) = when (text) {
"auth" -> ServerEvent("auth", EventKind.AUTH, Payload())
"auth failed" -> ServerEvent("auth", EventKind.AUTH, Payload(false))
"hello available" -> ServerEvent("hello", EventKind.HELLO, Payload(fields=mapOf("action_available" to true)))
"hello unavailable" -> ServerEvent("hello", EventKind.HELLO, Payload(fields=mapOf("action_available" to false)))
"hello" -> ServerEvent("hello", EventKind.HELLO, Payload())
"error" -> ServerEvent("error", EventKind.ERROR, Payload())
"unknown" -> ServerEvent("auth_ready", EventKind.UNKNOWN, Payload())