diff --git a/maestro-cli/src/main/java/maestro/cli/report/TestDebugReporter.kt b/maestro-cli/src/main/java/maestro/cli/report/TestDebugReporter.kt index 35f6352533..b1d01c2db1 100644 --- a/maestro-cli/src/main/java/maestro/cli/report/TestDebugReporter.kt +++ b/maestro-cli/src/main/java/maestro/cli/report/TestDebugReporter.kt @@ -57,7 +57,8 @@ object TestDebugReporter { if (commandMetadata.isNotEmpty()) { val commandsFilename = "commands-(${flowName.replace("/", "_")}).json" val file = File(path.absolutePathString(), commandsFilename) - commandMetadata.map { CommandDebugWrapper(it.key, it.value) }.let { + commandMetadata.map { + CommandDebugWrapper(it.key, it.value) }.let { mapper.writeValue(file, it) } } diff --git a/maestro-cli/src/main/java/maestro/cli/runner/MaestroCommandRunner.kt b/maestro-cli/src/main/java/maestro/cli/runner/MaestroCommandRunner.kt index 02a4d8d746..cdf9878304 100644 --- a/maestro-cli/src/main/java/maestro/cli/runner/MaestroCommandRunner.kt +++ b/maestro-cli/src/main/java/maestro/cli/runner/MaestroCommandRunner.kt @@ -187,12 +187,12 @@ object MaestroCommandRunner { refreshUi() }, onCommandGeneratedOutput = { command, defects, screenshot -> - logger.info("${command.description()} OUTPUTTED") + logger.info("${command.description()} generated output") val screenshotPath = writeAIscreenshot(screenshot) aiOutput.outputs.add( AIOutput( screenshotPath = screenshotPath, - defects = defects + defects = defects, ) ) } diff --git a/maestro-cli/src/main/java/maestro/cli/runner/TestSuiteInteractor.kt b/maestro-cli/src/main/java/maestro/cli/runner/TestSuiteInteractor.kt index 970ec175ed..57e8114c0c 100644 --- a/maestro-cli/src/main/java/maestro/cli/runner/TestSuiteInteractor.kt +++ b/maestro-cli/src/main/java/maestro/cli/runner/TestSuiteInteractor.kt @@ -21,6 +21,7 @@ import maestro.orchestra.Orchestra import maestro.orchestra.util.Env.withEnv import maestro.orchestra.workspace.WorkspaceExecutionPlanner import maestro.orchestra.yaml.YamlCommandReader +import okio.Buffer import okio.Sink import org.slf4j.LoggerFactory import java.io.File @@ -136,9 +137,11 @@ class TestSuiteInteractor( var flowStatus: FlowStatus var errorMessage: String? = null - // debug val debugOutput = FlowDebugOutput() - val aiOutput: FlowAIOutput? = null + val aiOutput = FlowAIOutput( + flowName = flowFile.nameWithoutExtension, + flowFilePath = flowFile.absolutePath, + ) fun takeDebugScreenshot(status: CommandStatus): File? { val containsFailed = debugOutput.screenshots.any { it.status == CommandStatus.FAILED } @@ -165,6 +168,14 @@ class TestSuiteInteractor( return result.getOrNull() } + fun writeAIscreenshot(buffer: Buffer): File { + val out = File + .createTempFile("ai-screenshot-${System.currentTimeMillis()}", ".png") + .also { it.deleteOnExit() } + out.outputStream().use { it.write(buffer.readByteArray()) } + return out + } + val flowTimeMillis = measureTimeMillis { try { val commands = YamlCommandReader @@ -215,10 +226,11 @@ class TestSuiteInteractor( }, // another name idea: onCommandFoundDefects onCommandGeneratedOutput = { command, defects, screenshot -> - logger.info("${command.description()} OUTPUTTED") - aiOutput?.outputs?.add( + logger.info("${command.description()} generated output") + val screenshotPath = writeAIscreenshot(screenshot) + aiOutput.outputs.add( AIOutput( - screenshotPath = File("TODO"), // TODO + screenshotPath = screenshotPath, defects = defects, ) )