presentation property

ReplayEventPresentation get presentation

Shared presentation model for replay/debug consumers.

Implementation

ReplayEventPresentation get presentation {
  final summaryModel = payload.lastSnapshotSummary;
  final generation = summaryModel?.renderGeneration;
  final width = summaryModel?.width ?? payload.report.lastWidth;
  final height = summaryModel?.height ?? payload.report.lastHeight;
  final changes =
      summaryModel?.changeSummary ?? payload.stats.lastChangeSummary;

  final summaryParts = <String>['render capture'];
  if (generation != null) {
    summaryParts.add('g$generation');
  }
  if (width != null && height != null) {
    summaryParts.add('${width}x$height');
  }
  if (changes != null) {
    summaryParts.add('cells ${changes.changedCellCount}');
    summaryParts.add('spans ${changes.changedSpanCount}');
  }

  final statusParts = <String>['/replay'];
  if (generation != null) {
    statusParts.add('g$generation');
  }
  if (width != null && height != null) {
    statusParts.add('${width}x$height');
  }
  if (changes != null) {
    statusParts.add('c${changes.changedCellCount}');
    statusParts.add('s${changes.changedSpanCount}');
  }

  return ReplayEventPresentation(
    summary: summaryParts.join(' '),
    statusHint: statusParts.join(' '),
    fields: <String, Object?>{
      'type': event.type,
      if (recordType != null) 'recordType': recordType,
      if (decisionType != null) 'decisionType': decisionType,
      if (result != null) 'result': result,
      if (generation != null) 'renderGeneration': generation,
      if (width != null) 'width': width,
      if (height != null) 'height': height,
      if (changes != null) 'changeSummary': changes.toJson(),
    },
    detailLines: toLines(),
  );
}