From 44e72258b1cda80a2665761e8b527bc5bda16755 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Mon, 9 Nov 2026 17:44:55 -0500 Subject: [PATCH] fix(agent): show why a setup check failed --- .../main/java/com/droiddeck/launcher/agent/AgentSetup.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt index ab34e6002..f682a8c27 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt @@ -50,7 +50,7 @@ object AgentSetup { Step.INSTALL -> set(step, if (AgentHost.guestFileExists(app, harness.binary)) Status.DONE else Status.TODO) Step.BUILD_TOOLS -> set(step, if (AgentHost.guestFileExists(app, "/root/aapt2/aapt2") && AgentHost.guestFileExists(app, "$CHECKOUT/.git")) Status.DONE else Status.TODO) - Step.CONNECTION -> probes += step to listOf("sh", "-c", "adb -s \"\$ADB_SERIAL\" get-state | grep -q device") + Step.CONNECTION -> probes += step to listOf("sh", "-c", "adb -s \"\$ADB_SERIAL\" get-state 2>&1 | tee /dev/stderr | grep -q device") Step.SIGN_IN -> if (AgentHost.guestFileExists(app, harness.binary)) probes += step to harness.signedIn else set(step, Status.TODO) Step.GITHUB -> probes += step to listOf("gh", "auth", "status") } @@ -100,14 +100,17 @@ object AgentSetup { } private fun probe(app: Context, step: Step, command: List) { + var output = "" val ok = runCatching { val child = AgentHost.guest(app, command, connectAdb = step == Step.CONNECTION).start() child.outputStream.close() - child.inputStream.readBytes() + output = child.inputStream.bufferedReader().readText() child.waitFor(60, TimeUnit.SECONDS) && child.exitValue() == 0 - }.getOrDefault(false) + }.onFailure { output = it.message.orEmpty() }.getOrDefault(false) main.post { if (status[step] != Status.WORKING) status[step] = if (ok) Status.DONE else Status.TODO + val last = output.lines().lastOrNull { it.isNotBlank() }?.trim()?.take(160) + if (!ok && step.required && last != null) detail[step] = last else if (ok) detail.remove(step) if (ready) AgentHost.prefs(app).edit().putBoolean(COMPLETED_KEY, true).apply() } }