From b76d5e186519238ca84de03f12c11264b9bad6c3 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Fri, 16 Aug 2024 15:54:20 +0100 Subject: [PATCH] Orchestra; create sealed class CommandOutput --- .../java/maestro/cli/report/TestDebugReporter.kt | 3 ++- .../src/main/java/maestro/orchestra/Orchestra.kt | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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 b1d01c2db1..7b87133aaf 100644 --- a/maestro-cli/src/main/java/maestro/cli/report/TestDebugReporter.kt +++ b/maestro-cli/src/main/java/maestro/cli/report/TestDebugReporter.kt @@ -58,7 +58,8 @@ object TestDebugReporter { val commandsFilename = "commands-(${flowName.replace("/", "_")}).json" val file = File(path.absolutePathString(), commandsFilename) commandMetadata.map { - CommandDebugWrapper(it.key, it.value) }.let { + CommandDebugWrapper(it.key, it.value) + }.let { mapper.writeValue(file, it) } } diff --git a/maestro-orchestra/src/main/java/maestro/orchestra/Orchestra.kt b/maestro-orchestra/src/main/java/maestro/orchestra/Orchestra.kt index 1dcff74381..121ee80032 100644 --- a/maestro-orchestra/src/main/java/maestro/orchestra/Orchestra.kt +++ b/maestro-orchestra/src/main/java/maestro/orchestra/Orchestra.kt @@ -47,6 +47,18 @@ import java.io.File import java.lang.Long.max import java.nio.file.Files +// TODO(bartkepacia): Use this in onCommandGeneratedOutput. +// Caveat: +// Large files should not be held in memory, instead they should be directly written to a Buffer +// that is streamed to disk. +// Idea: +// Orchestra should expose a callback like "onResourceRequested: (Command, CommandOutputType)" +sealed class CommandOutput { + data class Screenshot(val screenshot: Buffer) : CommandOutput() + data class ScreenRecording(val screenRecording: Buffer) : CommandOutput() + data class AIDefects(val defects: List, val screenshot: Buffer) : CommandOutput() +} + class Orchestra( private val maestro: Maestro, private val stateDir: File? = null,