fix(android): add screenHash to screen responses, handle goal_failed

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sanju Sivalingam
2026-02-17 18:17:48 +05:30
parent 4e9f0e14ae
commit 61fcecd021
2 changed files with 11 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import android.util.Base64
import android.util.Log
import com.thisux.droidclaw.accessibility.DroidClawAccessibilityService
import com.thisux.droidclaw.accessibility.GestureExecutor
import com.thisux.droidclaw.accessibility.ScreenTreeBuilder
import com.thisux.droidclaw.capture.ScreenCaptureManager
import com.thisux.droidclaw.model.AgentStep
import com.thisux.droidclaw.model.GoalStatus
@@ -65,6 +66,10 @@ class CommandRouter(
currentGoalStatus.value = if (msg.success == true) GoalStatus.Completed else GoalStatus.Failed
Log.i(TAG, "Goal completed: success=${msg.success}, steps=${msg.stepsUsed}")
}
"goal_failed" -> {
currentGoalStatus.value = GoalStatus.Failed
Log.i(TAG, "Goal failed: ${msg.message}")
}
else -> Log.w(TAG, "Unknown message type: ${msg.type}")
}
@@ -86,9 +91,14 @@ class CommandRouter(
}
}
val screenHash = if (elements.isNotEmpty()) {
ScreenTreeBuilder.computeScreenHash(elements)
} else null
val response = ScreenResponse(
requestId = requestId,
elements = elements,
screenHash = screenHash,
screenshot = screenshot,
packageName = packageName
)

View File

@@ -23,6 +23,7 @@ data class ScreenResponse(
val type: String = "screen",
val requestId: String,
val elements: List<UIElement>,
val screenHash: String? = null,
val screenshot: String? = null,
val packageName: String? = null
)