combineAttemptDiagnosticLogs function
Preserves console and API sidecars from every retry while retaining only the final attempt's other artifacts (such as its screenshot sheet).
Implementation
List<String> combineAttemptDiagnosticLogs(
List<String> finalAttemptLogs,
Iterable<List<String>> logsByAttempt,
) {
final diagnosticLogs = <String>[];
for (final logs in logsByAttempt) {
for (final log in logs) {
final separator = log.indexOf(':');
if (separator <= 0) continue;
final label = log.substring(0, separator).trim();
if (label == 'appLogs' || label == 'apiCalls') {
diagnosticLogs.add(log);
}
}
}
final finalLogs = finalAttemptLogs.where((log) {
final separator = log.indexOf(':');
if (separator <= 0) return true;
final label = log.substring(0, separator).trim();
return label != 'appLogs' && label != 'apiCalls';
});
return [...diagnosticLogs, ...finalLogs];
}