Android: drop screen.* invoke aliases

This commit is contained in:
Peter Steinberger
2025-12-18 02:17:35 +00:00
parent 57ee34839d
commit f2d503ad04
3 changed files with 11 additions and 62 deletions

View File

@@ -19,7 +19,6 @@ import com.steipete.clawdis.node.node.CanvasController
import com.steipete.clawdis.node.protocol.ClawdisCapability
import com.steipete.clawdis.node.protocol.ClawdisCameraCommand
import com.steipete.clawdis.node.protocol.ClawdisCanvasCommand
import com.steipete.clawdis.node.protocol.ClawdisInvokeCommandAliases
import com.steipete.clawdis.node.voice.VoiceWakeManager
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -446,12 +445,9 @@ class NodeRuntime(context: Context) {
}
private suspend fun handleInvoke(command: String, paramsJson: String?): BridgeSession.InvokeResult {
// Back-compat: accept screen.* commands and map them to canvas.*.
val canonicalCommand = ClawdisInvokeCommandAliases.canonicalizeScreenToCanvas(command)
if (
canonicalCommand.startsWith(ClawdisCanvasCommand.NamespacePrefix) ||
canonicalCommand.startsWith(ClawdisCameraCommand.NamespacePrefix)
command.startsWith(ClawdisCanvasCommand.NamespacePrefix) ||
command.startsWith(ClawdisCameraCommand.NamespacePrefix)
) {
if (!isForeground.value) {
return BridgeSession.InvokeResult.error(
@@ -460,14 +456,14 @@ class NodeRuntime(context: Context) {
)
}
}
if (canonicalCommand.startsWith(ClawdisCameraCommand.NamespacePrefix) && !cameraEnabled.value) {
if (command.startsWith(ClawdisCameraCommand.NamespacePrefix) && !cameraEnabled.value) {
return BridgeSession.InvokeResult.error(
code = "CAMERA_DISABLED",
message = "CAMERA_DISABLED: enable Camera in Settings",
)
}
return when (canonicalCommand) {
return when (command) {
ClawdisCanvasCommand.Show.rawValue -> BridgeSession.InvokeResult.ok(null)
ClawdisCanvasCommand.Hide.rawValue -> BridgeSession.InvokeResult.ok(null)
ClawdisCanvasCommand.SetMode.rawValue -> {

View File

@@ -6,20 +6,6 @@ enum class ClawdisCapability(val rawValue: String) {
VoiceWake("voiceWake"),
}
enum class ClawdisScreenCommand(val rawValue: String) {
Show("screen.show"),
Hide("screen.hide"),
SetMode("screen.setMode"),
Navigate("screen.navigate"),
Eval("screen.eval"),
Snapshot("screen.snapshot"),
;
companion object {
const val NamespacePrefix: String = "screen."
}
}
enum class ClawdisCanvasCommand(val rawValue: String) {
Show("canvas.show"),
Hide("canvas.hide"),
@@ -43,13 +29,3 @@ enum class ClawdisCameraCommand(val rawValue: String) {
const val NamespacePrefix: String = "camera."
}
}
object ClawdisInvokeCommandAliases {
fun canonicalizeScreenToCanvas(command: String): String {
if (command.startsWith(ClawdisScreenCommand.NamespacePrefix)) {
return ClawdisCanvasCommand.NamespacePrefix +
command.removePrefix(ClawdisScreenCommand.NamespacePrefix)
}
return command
}
}