This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new f5048e61fd Issue #7011 : Collapse multi-copy transform metrics into a 
totals row (#9243)
f5048e61fd is described below

commit f5048e61fd951bc69ce9412e4a8398b1e663b0c2
Author: Matt Casters <[email protected]>
AuthorDate: Fri Nov 13 09:48:22 2026 +0100

    Issue #7011 : Collapse multi-copy transform metrics into a totals row 
(#9243)
    
    * Issue #7011 : Collapse multi-copy transform metrics into a totals row
    
    The pipeline Metrics tab showed one row per copy, so a transform running
    in parallel was hard to read. Group those copies under a collapsed row
    with the summed counters, and keep each copy available when the row is
    expanded.
    
    * Issue #7011 : Parse parent speed totals with the local number format
---
 .../delegates/PipelineMetricsTreeTest.java         | 164 +++++
 .../delegates/HopGuiPipelineGridDelegate.java      | 706 +++++++--------------
 .../pipeline/delegates/PipelineMetricsGrouper.java | 468 ++++++++++++++
 .../pipeline/delegates/PipelineMetricsNode.java    |  64 ++
 .../pipeline/delegates/PipelineMetricsTree.java    | 476 ++++++++++++++
 .../ui/hopgui/messages/messages_en_US.properties   |   2 +
 .../delegates/PipelineMetricsGrouperTest.java      | 354 +++++++++++
 7 files changed, 1771 insertions(+), 463 deletions(-)

diff --git 
a/rcp/src/test/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsTreeTest.java
 
b/rcp/src/test/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsTreeTest.java
new file mode 100644
index 0000000000..bd86eea169
--- /dev/null
+++ 
b/rcp/src/test/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsTreeTest.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.ui.hopgui.file.pipeline.delegates;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.hop.pipeline.Pipeline;
+import org.apache.hop.pipeline.engine.EngineComponent;
+import org.apache.hop.pipeline.engine.EngineMetrics;
+import org.apache.hop.pipeline.engine.IEngineComponent;
+import org.apache.hop.pipeline.engine.IEngineMetric;
+import org.apache.hop.ui.core.widget.TreeMemory;
+import org.apache.hop.ui.testing.SwtBotTestBase;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+/** The metrics tree starts collapsed and keeps an expanded transform across a 
refresh. */
+@Tag("uitest")
+class PipelineMetricsTreeTest extends SwtBotTestBase {
+
+  private static final String TREE_NAME = "PipelineMetricsTreeTest";
+  private static final List<IEngineMetric> METRICS =
+      List.of(Pipeline.METRIC_INPUT, Pipeline.METRIC_ERROR);
+
+  @Test
+  void multiCopyTransformIsCollapsedWithTotalsAndExpandSurvivesRefresh() {
+    AtomicReference<Tree> treeRef = new AtomicReference<>();
+    withScene(
+        shell -> {
+          shell.setLayout(new FillLayout());
+          TreeMemory.getInstance().clearTree(TREE_NAME);
+          Tree tree = new Tree(shell, SWT.BORDER | SWT.FULL_SELECTION | 
SWT.MULTI);
+          tree.setHeaderVisible(true);
+          int columns =
+              PipelineMetricsGrouper.LEADING_COLUMNS
+                  + METRICS.size()
+                  + PipelineMetricsGrouper.TRAILING_COLUMNS;
+          for (int i = 0; i < columns; i++) {
+            TreeColumn column = new TreeColumn(tree, SWT.LEFT);
+            column.setText("c" + i);
+            column.setWidth(80);
+          }
+          TreeMemory.addTreeListener(tree, TREE_NAME);
+          treeRef.set(tree);
+          PipelineMetricsTree.sync(tree, rows(10L), METRICS, false, TREE_NAME);
+        },
+        bot ->
+            display.syncExec(
+                () -> {
+                  Tree tree = treeRef.get();
+                  tree.getShell().layout(true, true);
+
+                  TreeItem before = tree.getItem(0);
+                  TreeItem rest = tree.getItem(1);
+                  TreeItem after = tree.getItem(2);
+                  assertEquals("Before", before.getText(0));
+                  assertEquals("After", after.getText(0));
+                  assertFalse(rest.getExpanded());
+                  assertEquals(4, rest.getItemCount());
+                  assertEquals("4", rest.getText(1));
+                  List<String> totals =
+                      PipelineMetricsTree.cellTexts(rows(10L).get(1), false, 
METRICS, false);
+                  assertEquals(totals.get(0), rest.getText(0));
+                  assertEquals(totals.get(2), rest.getText(2));
+                  for (int copy = 0; copy < 4; copy++) {
+                    assertEquals("copy " + copy, 
rest.getItem(copy).getText(0));
+                    assertEquals(Integer.toString(copy), 
rest.getItem(copy).getText(1));
+                  }
+                  
assertNotNull(rest.getData(PipelineMetricsTree.COPY_TOOLTIP_KEY));
+
+                  rest.setExpanded(true);
+                  Event expanded = new Event();
+                  expanded.item = rest;
+                  tree.notifyListeners(SWT.Expand, expanded);
+                  assertTrue(rest.getExpanded());
+
+                  PipelineMetricsTree.sync(tree, rows(25L), METRICS, false, 
TREE_NAME);
+                  rest = tree.getItem(1);
+                  assertTrue(
+                      rest.getExpanded(), "an expanded transform stays open on 
the next refresh");
+                  assertEquals(
+                      PipelineMetricsTree.cellTexts(rows(25L).get(1), false, 
METRICS, false).get(2),
+                      rest.getText(2));
+
+                  // A rebuilt tree (sort changed the parent order) still 
restores the open row.
+                  List<PipelineMetricsNode> reordered = new 
ArrayList<>(rows(25L));
+                  PipelineMetricsNode moved = reordered.remove(1);
+                  reordered.add(moved);
+                  PipelineMetricsTree.sync(tree, reordered, METRICS, false, 
TREE_NAME);
+                  TreeItem restored = tree.getItem(2);
+                  assertEquals("Rest", restored.getText(0));
+                  assertTrue(restored.getExpanded());
+
+                  TreeItem clearRow = tree.getItem(0);
+                  int clearHeight = clearRow.getBounds().height;
+                  int restHeight = restored.getBounds().height;
+                  int followingHeight = tree.getItem(1).getBounds().height;
+                  assertTrue(clearHeight > 0, "row has a height");
+                  assertTrue(
+                      restHeight < clearHeight * 2 + 8,
+                      "error row height " + restHeight + " vs " + clearHeight);
+                  assertTrue(
+                      followingHeight < clearHeight * 2 + 8,
+                      "row after an error row height " + followingHeight + " 
vs " + clearHeight);
+                }));
+  }
+
+  /**
+   * Before (no errors), Rest with four copies (errors on the total), After 
(no errors). The input
+   * value is the same on every Rest copy so the total is four times {@code 
perCopy}.
+   */
+  private static List<PipelineMetricsNode> rows(long perCopy) {
+    List<EngineComponent> copies = new ArrayList<>();
+    EngineMetrics metrics = new EngineMetrics();
+    for (int copy = 0; copy < 4; copy++) {
+      EngineComponent component = new EngineComponent("Rest", copy);
+      copies.add(component);
+      metrics.addComponent(component);
+      metrics.setComponentMetric(component, Pipeline.METRIC_INPUT, perCopy);
+      if (copy == 0) {
+        metrics.setComponentMetric(component, Pipeline.METRIC_ERROR, 2L);
+      }
+    }
+    EngineComponent before = new EngineComponent("Before", 0);
+    EngineComponent after = new EngineComponent("After", 0);
+    metrics.addComponent(before);
+    metrics.addComponent(after);
+    metrics.setComponentMetric(before, Pipeline.METRIC_INPUT, 1L);
+    metrics.setComponentMetric(after, Pipeline.METRIC_INPUT, 1L);
+
+    List<IEngineComponent> shown = new ArrayList<>();
+    shown.add(before);
+    shown.addAll(copies);
+    shown.add(after);
+    return PipelineMetricsGrouper.group(shown, metrics, METRICS, 0L);
+  }
+}
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/HopGuiPipelineGridDelegate.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/HopGuiPipelineGridDelegate.java
index f22b1aedaa..836fdaaa30 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/HopGuiPipelineGridDelegate.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/HopGuiPipelineGridDelegate.java
@@ -17,12 +17,8 @@
 
 package org.apache.hop.ui.hopgui.file.pipeline.delegates;
 
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -37,9 +33,6 @@ import org.apache.hop.core.Props;
 import org.apache.hop.core.config.HopConfig;
 import org.apache.hop.core.gui.plugin.GuiPlugin;
 import org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement;
-import org.apache.hop.core.row.IValueMeta;
-import org.apache.hop.core.row.value.ValueMetaInteger;
-import org.apache.hop.core.row.value.ValueMetaString;
 import org.apache.hop.core.util.ExecutorUtil;
 import org.apache.hop.core.util.Utils;
 import org.apache.hop.i18n.BaseMessages;
@@ -49,16 +42,16 @@ import org.apache.hop.pipeline.engine.EngineMetrics;
 import org.apache.hop.pipeline.engine.IEngineComponent;
 import org.apache.hop.pipeline.engine.IEngineMetric;
 import org.apache.hop.pipeline.engine.IPipelineEngine;
-import org.apache.hop.pipeline.transform.ITransform;
 import org.apache.hop.pipeline.transform.TransformMeta;
-import org.apache.hop.pipeline.transform.TransformStatus;
+import org.apache.hop.ui.core.ConstUi;
 import org.apache.hop.ui.core.PropsUi;
 import org.apache.hop.ui.core.gui.GuiResource;
 import org.apache.hop.ui.core.gui.GuiToolbarWidgets;
 import org.apache.hop.ui.core.gui.IToolbarContainer;
 import org.apache.hop.ui.core.widget.ColumnInfo;
-import org.apache.hop.ui.core.widget.TableView;
+import org.apache.hop.ui.core.widget.TreeMemory;
 import org.apache.hop.ui.hopgui.HopGui;
+import org.apache.hop.ui.hopgui.TextSizeUtilFacade;
 import org.apache.hop.ui.hopgui.ToolbarFacade;
 import org.apache.hop.ui.hopgui.file.IHopFileTypeHandler;
 import org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph;
@@ -67,7 +60,6 @@ import 
org.apache.hop.ui.hopgui.file.shared.ExecutionGuiSession;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.CLabel;
 import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.FormAttachment;
@@ -78,17 +70,18 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.swt.widgets.ToolBar;
 import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
 
 /**
- * Delegate for the pipeline execution metrics grid tab. Manages the table of 
transform metrics
- * (rows read/written, duration, etc.), toolbar actions (open transform, 
show/hide filters, copy),
- * sorting, and double-click / selection behaviour to open the transform 
configuration.
+ * Delegate for the pipeline execution metrics tab. Transforms that run in 
several copies are one
+ * collapsed row with the totals; expanding it shows each copy. A single copy 
stays one row. Toolbar
+ * actions (open transform, show/hide filters, copy), sorting, and 
double-click behaviour stay on
+ * this tab.
  */
 @GuiPlugin(description = "Pipeline Graph Grid Delegate")
 public class HopGuiPipelineGridDelegate {
@@ -105,14 +98,15 @@ public class HopGuiPipelineGridDelegate {
 
   public static final long UPDATE_TIME_VIEW = 1000L;
 
-  private static final int METRICS_TABLE_STYLE = SWT.BORDER | 
SWT.FULL_SELECTION | SWT.MULTI;
+  private static final int METRICS_TREE_STYLE =
+      SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | 
SWT.H_SCROLL;
 
   private final HopGui hopGui;
   private final HopGuiPipelineGraph pipelineGraph;
 
   @Getter private CTabItem pipelineGridTab;
 
-  private TableView pipelineGridView;
+  private Tree pipelineMetricsTree;
 
   private Control toolbar;
   private GuiToolbarWidgets toolbarWidget;
@@ -127,8 +121,11 @@ public class HopGuiPipelineGridDelegate {
 
   private Timer refreshMetricsTimer;
 
-  /** Last sort column/direction from user (column header click); we re-apply 
on each refresh. */
-  private int gridSortColumn = 0;
+  /**
+   * Last sort column from a header click. {@code -1} keeps pipeline order. 
Only parent rows are
+   * sorted; copies under a parent stay in copy-number order.
+   */
+  private int gridSortColumn = -1;
 
   private boolean gridSortDescending = false;
 
@@ -192,7 +189,7 @@ public class HopGuiPipelineGridDelegate {
     }
   }
 
-  /** Add a grid with the execution metrics per transform in a table view */
+  /** Add a grid with the execution metrics per transform. */
   public void addPipelineGrid() {
 
     // First, see if we need to add the extra view...
@@ -201,18 +198,21 @@ public class HopGuiPipelineGridDelegate {
       pipelineGraph.addExtraView();
     } else {
       if (pipelineGridTab != null && !pipelineGridTab.isDisposed()) {
-        // Reusing existing grid for a new run: reset sort to default and 
clear metrics cache
-        gridSortColumn = 0;
+        // Reusing existing grid for a new run: reset sort to default and 
clear metrics cache.
+        // Collapse groups so the new run starts with the totals, not the 
previous expansion.
+        gridSortColumn = -1;
         gridSortDescending = false;
         lastEngineMetrics = null;
         packColumnsOnNextRefresh = true;
+        collapseMetricsTree();
         startRefreshMetricsTimer();
         return;
       }
     }
 
-    gridSortColumn = 0;
+    gridSortColumn = -1;
     gridSortDescending = false;
+    TreeMemory.getInstance().clearTree(metricsTreeMemoryName());
     lastEngineMetrics = null;
     transformNameSearchText = "";
 
@@ -314,12 +314,11 @@ public class HopGuiPipelineGridDelegate {
     columns[12].setAlignment(SWT.RIGHT);
     columns[13].setAlignment(SWT.RIGHT);
 
-    pipelineGridView = createMetricsTableView(columns, 1);
+    pipelineMetricsTree = createMetricsTree(columns);
     metricsColumnKeys = placeholderColumnKeys();
     attachColumnWidthListeners();
-    attachMetricsTableListeners(pipelineGridView);
-    applyNumberColumnComparator();
-    previousRefreshColumns = Arrays.asList(columns);
+    attachMetricsTreeListeners(pipelineMetricsTree);
+    previousRefreshColumns = List.of(columns);
 
     startRefreshMetricsTimer();
     pipelineGridTab.addDisposeListener(disposeEvent -> 
stopRefreshMetricsTimer());
@@ -379,7 +378,7 @@ public class HopGuiPipelineGridDelegate {
     if (!showSelectedTransforms) {
       return;
     }
-    if (pipelineGridView == null || pipelineGridView.isDisposed()) {
+    if (pipelineMetricsTree == null || pipelineMetricsTree.isDisposed()) {
       return;
     }
     hopGui.getDisplay().asyncExec(this::refreshView);
@@ -666,24 +665,20 @@ public class HopGuiPipelineGridDelegate {
       image = "ui/images/copy.svg",
       separator = true)
   public void copyMetricsToClipboard() {
-    if (pipelineGridView == null || pipelineGridView.isDisposed()) {
+    if (pipelineMetricsTree == null || pipelineMetricsTree.isDisposed()) {
       return;
     }
-    Table table = pipelineGridView.table;
-    boolean hadSelection = table.getSelectionCount() > 0;
-    if (!hadSelection) {
-      table.selectAll();
-    }
-    pipelineGridView.clipSelected();
-    if (!hadSelection) {
-      table.deselectAll();
+    String clip = PipelineMetricsTree.copyText(pipelineMetricsTree);
+    if (Utils.isEmpty(clip)) {
+      return;
     }
+    GuiResource.getInstance().toClipboard(clip);
   }
 
   private void refreshView() {
     refreshViewLock.lock();
     try {
-      if (pipelineGridView == null || pipelineGridView.isDisposed()) {
+      if (pipelineMetricsTree == null || pipelineMetricsTree.isDisposed()) {
         return;
       }
 
@@ -703,40 +698,37 @@ public class HopGuiPipelineGridDelegate {
       List<IEngineMetric> usedMetrics = getUsedMetrics(engineMetrics);
       List<ColumnInfo> columns = buildColumnList(usedMetrics);
       applySavedColumnWidthsToColumnInfos(columns, usedMetrics);
-      List<List<String>> componentStringsList =
-          buildComponentStringsList(engineMetrics, shownComponents, 
usedMetrics);
 
-      boolean recreated =
-          recreateTableIfColumnsChanged(columns, shownComponents.size(), 
usedMetrics);
+      boolean recreated = recreateTreeIfColumnsChanged(columns, usedMetrics);
       boolean packColumns = packColumnsOnNextRefresh;
       packColumnsOnNextRefresh = false;
 
-      sortComponentStringsByColumn(componentStringsList, gridSortColumn, 
gridSortDescending);
-
-      Table table = pipelineGridView.table;
-      int topIndex = table.getTopIndex();
-      int[] selection = table.getSelectionIndices();
-
-      int errorCol = indexOfMetric(usedMetrics, Pipeline.METRIC_ERROR);
-      fillTableRows(componentStringsList, errorCol);
+      List<PipelineMetricsNode> nodes =
+          PipelineMetricsGrouper.group(shownComponents, engineMetrics, 
usedMetrics);
+      PipelineMetricsGrouper.sortParents(nodes, gridSortColumn, 
gridSortDescending, usedMetrics);
+      PipelineMetricsTree.sync(
+          pipelineMetricsTree,
+          nodes,
+          usedMetrics,
+          PropsUi.getInstance().isMetricsPanelShowUnits(),
+          metricsTreeMemoryName());
 
       setSortIndicator();
 
-      // Ignore resize events from optWidth / restore so we don't treat them 
as user drags.
+      // Ignore resize events from packing / restore so we don't treat them as 
user drags.
       restoringColumnWidths = true;
       try {
         if (packColumns && !recreated) {
-          pipelineGridView.optWidth(true);
+          packTreeColumns(false);
           restoreColumnWidths(usedMetrics);
-        } else if (PropsUi.getInstance().isMetricsPanelDynamicColumnResize()) {
-          // Recreate already packed in the constructor; timer ticks only grow 
auto-sized columns.
-          pipelineGridView.optWidth(true, 0, true);
+        } else if (recreated || 
PropsUi.getInstance().isMetricsPanelDynamicColumnResize()) {
+          // A fresh tree has no measured widths yet. Later ticks only grow 
auto-sized columns.
+          packTreeColumns(true);
         }
       } finally {
         restoringColumnWidths = false;
       }
       previousRefreshColumns = columns;
-      restoreTableViewport(table, topIndex, selection);
       updateEditButtonState();
     } finally {
       refreshViewLock.unlock();
@@ -856,37 +848,25 @@ public class HopGuiPipelineGridDelegate {
               metric.isNumeric(),
               true);
       column.setToolTip(metric.getTooltip());
-      IValueMeta stringMeta = new ValueMetaString(metric.getCode());
-      ValueMetaInteger valueMeta = new ValueMetaInteger(metric.getCode(), 15, 
0);
-      valueMeta.setConversionMask(METRICS_FORMAT);
-      stringMeta.setConversionMetadata(valueMeta);
-      column.setValueMeta(stringMeta);
       column.setAlignment(SWT.RIGHT);
       columns.add(column);
     }
 
-    IValueMeta stringMeta = new ValueMetaString("string");
-
     ColumnInfo durationColumn =
         new ColumnInfo(
             BaseMessages.getString(PKG, "PipelineLog.Column.Duration"),
             ColumnInfo.COLUMN_TYPE_TEXT,
             false,
             true);
-    durationColumn.setValueMeta(stringMeta);
     durationColumn.setAlignment(SWT.RIGHT);
     columns.add(durationColumn);
 
-    ValueMetaInteger speedMeta = new ValueMetaInteger("speed", 15, 0);
-    speedMeta.setConversionMask(" ###,###,###,##0");
-    stringMeta.setConversionMetadata(speedMeta);
     ColumnInfo speedColumn =
         new ColumnInfo(
             BaseMessages.getString(PKG, "PipelineLog.Column.Speed"),
             ColumnInfo.COLUMN_TYPE_TEXT,
             false,
             true);
-    speedColumn.setValueMeta(stringMeta);
     speedColumn.setAlignment(SWT.RIGHT);
     columns.add(speedColumn);
 
@@ -901,130 +881,83 @@ public class HopGuiPipelineGridDelegate {
   }
 
   /**
-   * Applies saved column widths to ColumnInfo so that TableView.optWidth() 
will use them instead of
-   * auto-sizing. Table column 0 is the "#" column (no ColumnInfo); indices 
1..n match our columns.
+   * Applies saved column widths to ColumnInfo so a rebuilt tree starts from 
the user's widths.
+   * Column 0 is the transform name.
    */
   private void applySavedColumnWidthsToColumnInfos(
       List<ColumnInfo> columns, List<IEngineMetric> usedMetrics) {
     List<String> keys = getColumnKeys(usedMetrics);
-    for (int i = 0; i < columns.size() && (i + 1) < keys.size(); i++) {
-      String key = keys.get(i + 1);
-      Integer w = metricsColumnWidths.get(key);
-      if (w != null && w > 0) {
-        columns.get(i).setWidth(w);
-      }
-    }
-  }
-
-  private List<List<String>> buildComponentStringsList(
-      EngineMetrics engineMetrics,
-      List<IEngineComponent> shownComponents,
-      List<IEngineMetric> usedMetrics) {
-    List<List<String>> componentStringsList = new ArrayList<>();
-    int rowNum = 1;
-    for (IEngineComponent component : shownComponents) {
-      List<String> componentStrings = new ArrayList<>();
-      componentStrings.add(Integer.toString(rowNum++));
-      componentStrings.add(Const.NVL(component.getName(), ""));
-      componentStrings.add(Integer.toString(component.getCopyNr()));
-
-      boolean showUnits = PropsUi.getInstance().isMetricsPanelShowUnits();
-      for (IEngineMetric metric : usedMetrics) {
-        Long value = engineMetrics.getComponentMetric(component, metric);
-        String cell;
-        if (Pipeline.METRIC_NAME_DATA_VOLUME.equals(metric.getCode())
-            || Pipeline.METRIC_NAME_DATA_VOLUME_IN.equals(metric.getCode())
-            || Pipeline.METRIC_NAME_DATA_VOLUME_OUT.equals(metric.getCode())) {
-          cell = value == null ? "" : 
PipelineMetricDisplayUtil.formatDataVolume(value);
-        } else {
-          String unit = showUnits ? 
PipelineMetricDisplayUtil.getUnitForMetricCell(metric) : null;
-          cell =
-              value == null
-                  ? ""
-                  : formatMetric(value) + (unit != null && !unit.isEmpty() ? " 
" + unit : "");
-        }
-        componentStrings.add(cell);
+    for (int i = 0; i < columns.size() && i < keys.size(); i++) {
+      Integer width = metricsColumnWidths.get(keys.get(i));
+      if (width != null && width > 0) {
+        columns.get(i).setWidth(width);
       }
-      String durationStr = calculateDuration(component);
-      componentStrings.add(
-          durationStr.isEmpty() ? "" : showUnits ? durationStr + " (h:m:s)" : 
durationStr);
-      String speedStr = engineMetrics.getComponentSpeedMap().get(component);
-      componentStrings.add(
-          speedStr == null || speedStr.isEmpty()
-              ? ""
-              : showUnits && !speedStr.trim().equals("-")
-                  ? speedStr.trim() + " rows/s"
-                  : speedStr.trim());
-      
componentStrings.add(Const.NVL(engineMetrics.getComponentStatusMap().get(component),
 ""));
-
-      componentStringsList.add(componentStrings);
     }
-    return componentStringsList;
   }
 
   /**
-   * Rebuilds the metrics {@link TableView} when the column set changes. 
Returns true when a new
-   * table was created (constructor already packed columns).
+   * Rebuilds the metrics tree when the column set changes. Returns true when 
a new tree was
+   * created.
    */
-  private boolean recreateTableIfColumnsChanged(
-      List<ColumnInfo> columns, int rowCount, List<IEngineMetric> usedMetrics) 
{
+  private boolean recreateTreeIfColumnsChanged(
+      List<ColumnInfo> columns, List<IEngineMetric> usedMetrics) {
     if (!haveColumnsChanged(columns)) {
       return false;
     }
     saveColumnWidths();
-    pipelineGridView.dispose();
-    pipelineGridView = createMetricsTableView(columns.toArray(new 
ColumnInfo[0]), rowCount);
+    if (pipelineMetricsTree != null && !pipelineMetricsTree.isDisposed()) {
+      pipelineMetricsTree.dispose();
+    }
+    pipelineMetricsTree = createMetricsTree(columns.toArray(new 
ColumnInfo[0]));
     metricsColumnKeys = getColumnKeys(usedMetrics);
-    applyNumberColumnComparator();
     attachColumnWidthListeners();
-    attachMetricsTableListeners(pipelineGridView);
+    attachMetricsTreeListeners(pipelineMetricsTree);
     pipelineGridComposite.layout(true, true);
     restoreColumnWidths(usedMetrics);
     return true;
   }
 
-  private TableView createMetricsTableView(ColumnInfo[] columns, int rowCount) 
{
-    TableView view =
-        new TableView(
-            pipelineGraph.getVariables(),
-            pipelineGridComposite,
-            METRICS_TABLE_STYLE,
-            columns,
-            Math.max(rowCount, 1),
-            true,
-            null,
-            hopGui.getProps(),
-            true,
-            null,
-            false,
-            false); // no TableView toolbar; copy/filter are on our toolbar
-    view.setSortable(true);
+  private Tree createMetricsTree(ColumnInfo[] columns) {
+    Tree tree = new Tree(pipelineGridComposite, METRICS_TREE_STYLE);
+    tree.setHeaderVisible(true);
+    PropsUi.setLook(tree);
+    TreeMemory.addTreeListener(tree, metricsTreeMemoryName());
+    PipelineMetricsTree.installCopyCountTooltip(tree);
+    for (int i = 0; i < columns.length; i++) {
+      ColumnInfo column = columns[i];
+      TreeColumn treeColumn = new TreeColumn(tree, column.getAlignment());
+      treeColumn.setText(column.getName() == null ? "" : column.getName());
+      if (!Utils.isEmpty(column.getToolTip())) {
+        treeColumn.setToolTipText(column.getToolTip());
+      }
+      int width = column.getWidth();
+      if (width <= 0) {
+        width = i == 0 ? 220 : 90;
+      }
+      treeColumn.setWidth(width);
+    }
+    if (tree.getColumnCount() > PipelineMetricsGrouper.COLUMN_COPY) {
+      TreeColumn copyColumn = 
tree.getColumn(PipelineMetricsGrouper.COLUMN_COPY);
+      if (Utils.isEmpty(copyColumn.getToolTipText())) {
+        copyColumn.setToolTipText(
+            BaseMessages.getString(PKG, "PipelineLog.Tree.CopyCount.Tooltip"));
+      }
+    }
     FormData fdView = new FormData();
     fdView.left = new FormAttachment(0, 0);
     fdView.right = new FormAttachment(100, 0);
     fdView.top = new FormAttachment(toolbar, 0);
     fdView.bottom = new FormAttachment(100, 0);
-    view.setLayoutData(fdView);
-    return view;
-  }
-
-  private void applyNumberColumnComparator() {
-    if (pipelineGridView == null || pipelineGridView.isDisposed()) {
-      return;
-    }
-    ColumnInfo numberColumn = pipelineGridView.getNumberColumn();
-    IValueMeta numberColumnValueMeta =
-        new ValueMetaString("#", 
HopGuiPipelineGridDelegate::subTransformCompare);
-    numberColumn.setValueMeta(numberColumnValueMeta);
+    tree.setLayoutData(fdView);
+    return tree;
   }
 
   /**
-   * Column keys used by the placeholder table created in {@link 
#addPipelineGrid()} before the
-   * first engine-metrics refresh rebuilds the real column set.
+   * Column keys used by the placeholder tree created in {@link 
#addPipelineGrid()} before the first
+   * engine-metrics refresh rebuilds the real column set.
    */
   private static List<String> placeholderColumnKeys() {
     List<String> keys = new ArrayList<>();
-    keys.add("#");
     keys.add("TransformName");
     keys.add("Copy");
     keys.add(Pipeline.METRIC_NAME_INPUT);
@@ -1042,29 +975,12 @@ public class HopGuiPipelineGridDelegate {
     return keys;
   }
 
-  private void restoreTableViewport(Table table, int topIndex, int[] 
selection) {
-    if (table == null || table.isDisposed()) {
-      return;
-    }
-    int itemCount = table.getItemCount();
-    if (selection != null && selection.length > 0) {
-      int[] valid = Arrays.stream(selection).filter(i -> i >= 0 && i < 
itemCount).toArray();
-      if (valid.length > 0) {
-        table.setSelection(valid);
-      }
-    }
-    if (topIndex >= 0 && topIndex < itemCount) {
-      table.setTopIndex(topIndex);
-    }
-  }
-
   /**
-   * Builds the list of column keys in table order (#, TransformName, Copy, 
metric codes, duration,
+   * Builds the list of column keys in tree order (TransformName, Copy, metric 
codes, duration,
    * speed, status).
    */
   private List<String> getColumnKeys(List<IEngineMetric> usedMetrics) {
     List<String> keys = new ArrayList<>();
-    keys.add("#");
     keys.add("TransformName");
     keys.add("Copy");
     for (IEngineMetric m : usedMetrics) {
@@ -1081,32 +997,28 @@ public class HopGuiPipelineGridDelegate {
    * stored so grow-only packing can still widen them as counts grow.
    */
   private void saveColumnWidths() {
-    if (pipelineGridView == null || pipelineGridView.isDisposed()) {
+    if (pipelineMetricsTree == null || pipelineMetricsTree.isDisposed()) {
       return;
     }
     if (metricsColumnKeys == null || metricsColumnKeys.isEmpty() || 
metricsColumnWidths.isEmpty()) {
       return;
     }
-    Table table = pipelineGridView.table;
-    int n = Math.min(table.getColumnCount(), metricsColumnKeys.size());
+    int n = Math.min(pipelineMetricsTree.getColumnCount(), 
metricsColumnKeys.size());
     for (int i = 0; i < n; i++) {
       String key = metricsColumnKeys.get(i);
       if (!metricsColumnWidths.containsKey(key)) {
         continue;
       }
-      int w = table.getColumn(i).getWidth();
-      if (w > 0) {
-        metricsColumnWidths.put(key, w);
+      int width = pipelineMetricsTree.getColumn(i).getWidth();
+      if (width > 0) {
+        metricsColumnWidths.put(key, width);
       }
     }
   }
 
-  /**
-   * Restores user-resized column widths from the session map onto the table. 
Needed for the "#"
-   * column (no data {@link ColumnInfo}) and after a table recreate.
-   */
+  /** Restores user-resized column widths from the session map onto the tree. 
*/
   private void restoreColumnWidths(List<IEngineMetric> usedMetrics) {
-    if (pipelineGridView == null || pipelineGridView.isDisposed()) {
+    if (pipelineMetricsTree == null || pipelineMetricsTree.isDisposed()) {
       return;
     }
     if (metricsColumnWidths.isEmpty()) {
@@ -1114,25 +1026,22 @@ public class HopGuiPipelineGridDelegate {
     }
     boolean nested = restoringColumnWidths;
     restoringColumnWidths = true;
-    Table table = pipelineGridView.table;
-    table.setRedraw(false);
+    pipelineMetricsTree.setRedraw(false);
     try {
       List<String> keys = getColumnKeys(usedMetrics);
-      int n = Math.min(table.getColumnCount(), keys.size());
+      int n = Math.min(pipelineMetricsTree.getColumnCount(), keys.size());
       for (int i = 0; i < n; i++) {
-        String key = keys.get(i);
-        Integer w = metricsColumnWidths.get(key);
-        if (w != null && w > 0) {
-          TableColumn tc = table.getColumn(i);
-          if (tc.getWidth() != w) {
-            tc.setWidth(w);
+        Integer width = metricsColumnWidths.get(keys.get(i));
+        if (width != null && width > 0) {
+          TreeColumn column = pipelineMetricsTree.getColumn(i);
+          if (column.getWidth() != width) {
+            column.setWidth(width);
           }
-          pipelineGridView.setPreferredColumnWidth(i, w);
         }
       }
     } finally {
-      if (!table.isDisposed()) {
-        table.setRedraw(true);
+      if (!pipelineMetricsTree.isDisposed()) {
+        pipelineMetricsTree.setRedraw(true);
       }
       if (!nested) {
         restoringColumnWidths = false;
@@ -1142,127 +1051,115 @@ public class HopGuiPipelineGridDelegate {
 
   /** Attach resize listeners so user column resizes are stored for the 
session. */
   private void attachColumnWidthListeners() {
-    if (pipelineGridView == null || pipelineGridView.isDisposed()) {
+    if (pipelineMetricsTree == null || pipelineMetricsTree.isDisposed()) {
       return;
     }
     if (metricsColumnKeys == null || metricsColumnKeys.isEmpty()) {
       return;
     }
-    Table table = pipelineGridView.table;
-    for (int i = 0; i < table.getColumnCount() && i < 
metricsColumnKeys.size(); i++) {
+    for (int i = 0; i < pipelineMetricsTree.getColumnCount() && i < 
metricsColumnKeys.size(); i++) {
       final String key = metricsColumnKeys.get(i);
-      final int columnIndex = i;
-      TableColumn col = table.getColumn(i);
-      col.addListener(
+      TreeColumn column = pipelineMetricsTree.getColumn(i);
+      column.addListener(
           SWT.Resize,
-          e -> {
-            if (restoringColumnWidths) {
+          event -> {
+            if (restoringColumnWidths || column.isDisposed()) {
               return;
             }
-            if (!col.isDisposed()) {
-              int w = col.getWidth();
-              if (w > 0) {
-                metricsColumnWidths.put(key, w);
-                pipelineGridView.setPreferredColumnWidth(columnIndex, w);
-              }
+            int width = column.getWidth();
+            if (width > 0) {
+              metricsColumnWidths.put(key, width);
             }
           });
     }
   }
 
-  private void fillTableRows(List<List<String>> componentStringsList, int 
errorColumnIndex) {
-    Table table = pipelineGridView.table;
-    table.setRedraw(false);
+  /**
+   * Sizes columns to the header and the visible cells. {@code growOnly} skips 
columns the user has
+   * resized and never shrinks a column.
+   */
+  private void packTreeColumns(boolean growOnly) {
+    if (pipelineMetricsTree == null || pipelineMetricsTree.isDisposed()) {
+      return;
+    }
+    int extra = columnWidthMargin();
+    pipelineMetricsTree.setRedraw(false);
     try {
-      while (table.getItemCount() > componentStringsList.size()) {
-        table.remove(table.getItemCount() - 1);
-      }
-      int errorsCol = 3 + errorColumnIndex; // row has #, name, copy, then 
metrics
-      Color errorBg = GuiResource.getInstance().getColorLightRed();
-      for (int row = 0; row < componentStringsList.size(); row++) {
-        List<String> componentStrings = componentStringsList.get(row);
-        TableItem item;
-        if (row < table.getItemCount()) {
-          item = table.getItem(row);
-        } else {
-          item = new TableItem(table, SWT.NONE);
+      for (int c = 0; c < pipelineMetricsTree.getColumnCount(); c++) {
+        String key =
+            metricsColumnKeys != null && c < metricsColumnKeys.size()
+                ? metricsColumnKeys.get(c)
+                : null;
+        if (growOnly && key != null && metricsColumnWidths.containsKey(key)) {
+          continue;
         }
-        applyRowTextsIfChanged(item, componentStrings);
-        if (errorColumnIndex >= 0 && errorsCol < componentStrings.size()) {
-          long err = parseFormattedLong(componentStrings.get(errorsCol));
-          boolean wantError = err > 0;
-          boolean hasError = errorBg.equals(item.getBackground());
-          if (wantError != hasError) {
-            item.setBackground(wantError ? errorBg : null);
-          }
+        TreeColumn column = pipelineMetricsTree.getColumn(c);
+        int max = TextSizeUtilFacade.textExtent(Const.NVL(column.getText(), 
"")).x + extra;
+        if (c == gridSortColumn) {
+          max += ConstUi.SMALL_ICON_SIZE;
+        }
+        if (c == 0) {
+          max += (int) (PropsUi.getNativeZoomFactor() * 24);
+        }
+        max = Math.max(max, widestVisibleCell(pipelineMetricsTree.getItems(), 
c, extra));
+        if (!growOnly || max > column.getWidth()) {
+          column.setWidth(Math.max(max, 20));
         }
       }
     } finally {
-      if (!table.isDisposed()) {
-        table.setRedraw(true);
+      if (!pipelineMetricsTree.isDisposed()) {
+        pipelineMetricsTree.setRedraw(true);
       }
     }
   }
 
-  /** Anti-flicker: only push cell text that actually changed. */
-  private static void applyRowTextsIfChanged(TableItem item, List<String> 
texts) {
-    for (int col = 0; col < texts.size(); col++) {
-      String next = Const.NVL(texts.get(col), "");
-      if (!next.equals(item.getText(col))) {
-        item.setText(col, next);
-      }
+  private static int columnWidthMargin() {
+    int extra;
+    if (Const.isWindows()) {
+      extra = (int) (PropsUi.getNativeZoomFactor() * 8);
+    } else {
+      extra = (int) (PropsUi.getNativeZoomFactor() * 5);
     }
+    extra +=
+        
Const.toInt(HopConfig.readStringVariable(Const.HOP_TABLE_VIEW_EXTRA_COLUMN_MARGIN,
 ""), 0);
+    return extra;
   }
 
-  private static int indexOfMetric(List<IEngineMetric> usedMetrics, 
IEngineMetric metric) {
-    for (int i = 0; i < usedMetrics.size(); i++) {
-      if (usedMetrics.get(i).getHeader().equals(metric.getHeader())) {
-        return i;
-      }
+  private static int widestVisibleCell(TreeItem[] items, int column, int 
extra) {
+    int max = 0;
+    if (items == null) {
+      return max;
     }
-    return -1;
-  }
-
-  /**
-   * Attaches all table listeners used by the metrics grid: sort capture, 
double-click to open
-   * transform, and edit toolbar button enable/disable. Call after creating or 
recreating the table.
-   */
-  private void attachMetricsTableListeners(TableView view) {
-    attachSortListener(view);
-    attachDoubleClickListener(view);
-    attachEditButtonStateListener(view);
-  }
-
-  /**
-   * Attach listener to column headers so we remember sort column/direction 
for the next refresh.
-   */
-  private void attachSortListener(TableView view) {
-    Table table = view.table;
-    for (int i = 0; i < table.getColumnCount(); i++) {
-      table.getColumn(i).addListener(SWT.Selection, e -> captureSortState());
+    for (TreeItem item : items) {
+      if (item == null || item.isDisposed()) {
+        continue;
+      }
+      String text = item.getText(column);
+      if (!Utils.isEmpty(text)) {
+        max = Math.max(max, TextSizeUtilFacade.textExtent(text).x + extra);
+      }
+      if (item.getExpanded() && item.getItemCount() > 0) {
+        max = Math.max(max, widestVisibleCell(item.getItems(), column, extra));
+      }
     }
-  }
-
-  /** On double-click, open the transform configuration for the selected row 
(by transform name). */
-  private void attachDoubleClickListener(TableView view) {
-    Table table = view.table;
-    table.addListener(SWT.DefaultSelection, e -> 
openTransformForSelectedRow());
+    return max;
   }
 
   /**
-   * Enable/disable the edit (open transform) toolbar button based on table 
row selection. TableView
-   * sets selection inside its MouseDown (editSelected -> setSelection); the 
Table often does not
-   * fire Selection until after mouse handling, so the first click does not 
run our Selection
-   * listener. We run updateEditButtonState on MouseDown via asyncExec so it 
runs after TableView
-   * has applied the selection.
+   * Attaches sort, double-click, and selection listeners. Call after creating 
or recreating the
+   * tree.
    */
-  private void attachEditButtonStateListener(TableView view) {
-    Table table = view.table;
-    table.addListener(SWT.Selection, e -> updateEditButtonState());
-    table.addListener(
+  private void attachMetricsTreeListeners(Tree tree) {
+    for (int i = 0; i < tree.getColumnCount(); i++) {
+      TreeColumn column = tree.getColumn(i);
+      column.addListener(SWT.Selection, event -> onSortColumnSelected(column));
+    }
+    tree.addListener(SWT.DefaultSelection, event -> 
openTransformForSelectedRow());
+    tree.addListener(SWT.Selection, event -> updateEditButtonState());
+    tree.addListener(
         SWT.MouseDown,
-        e -> {
-          if (table.isDisposed()) {
+        event -> {
+          if (tree.isDisposed()) {
             return;
           }
           hopGui.getDisplay().asyncExec(this::updateEditButtonState);
@@ -1270,134 +1167,102 @@ public class HopGuiPipelineGridDelegate {
     updateEditButtonState();
   }
 
+  private void onSortColumnSelected(TreeColumn column) {
+    if (pipelineMetricsTree == null || pipelineMetricsTree.isDisposed() || 
column.isDisposed()) {
+      return;
+    }
+    int index = pipelineMetricsTree.indexOf(column);
+    if (index < 0) {
+      return;
+    }
+    if (gridSortColumn == index) {
+      gridSortDescending = !gridSortDescending;
+    } else {
+      gridSortColumn = index;
+      gridSortDescending = false;
+    }
+    refreshView();
+  }
+
   /**
-   * Enables or disables the open-transform toolbar button based on whether a 
table row is selected.
+   * Enables or disables the open-transform toolbar button based on whether a 
tree row is selected.
    */
   private void updateEditButtonState() {
     if (toolbarWidget == null || toolbar == null || toolbar.isDisposed()) {
       return;
     }
     boolean linesSelected =
-        pipelineGridView != null
-            && !pipelineGridView.isDisposed()
-            && pipelineGridView.table.getSelectionCount() > 0;
+        pipelineMetricsTree != null
+            && !pipelineMetricsTree.isDisposed()
+            && pipelineMetricsTree.getSelectionCount() > 0;
     toolbarWidget.enableToolbarItem(TOOLBAR_ICON_OPEN_TRANSFORM, 
linesSelected);
   }
 
   /**
-   * Opens the transform configuration dialog for the selected table row. 
Reads the transform name
-   * from column 1 (see {@link #buildComponentStringsList}); finds the {@link 
TransformMeta} and
-   * calls {@link HopGuiPipelineGraph#editTransform(PipelineMeta, 
TransformMeta)}.
+   * Opens the transform configuration for the selected row. The row data 
holds the transform name,
+   * including on a {@code copy N} child.
    */
   private void openTransformForSelectedRow() {
-    if (pipelineGridView == null || pipelineGridView.isDisposed()) {
+    if (pipelineMetricsTree == null || pipelineMetricsTree.isDisposed()) {
       return;
     }
-    Table table = pipelineGridView.table;
-    TableItem[] selection = table.getSelection();
+    TreeItem[] selection = pipelineMetricsTree.getSelection();
     if (selection == null || selection.length == 0) {
       return;
     }
-    // Column 0 = #, column 1 = transform name (matches 
buildComponentStringsList)
-    String transformName = selection[0].getText(1);
-    if (Utils.isEmpty(transformName)) {
+    if (!(selection[0].getData() instanceof PipelineMetricsTree.RowKey key)) {
+      return;
+    }
+    if (Utils.isEmpty(key.transformName)) {
       return;
     }
     PipelineMeta pipelineMeta = pipelineGraph.getPipelineMeta();
     if (pipelineMeta == null) {
       return;
     }
-    TransformMeta transformMeta = pipelineMeta.findTransform(transformName);
+    TransformMeta transformMeta = 
pipelineMeta.findTransform(key.transformName);
     if (transformMeta == null) {
       return;
     }
     pipelineGraph.editTransform(pipelineMeta, transformMeta);
   }
 
-  private void captureSortState() {
-    if (pipelineGridView == null || pipelineGridView.isDisposed()) {
+  /** Update the header to show which column is sorted and in which direction. 
*/
+  private void setSortIndicator() {
+    if (pipelineMetricsTree == null || pipelineMetricsTree.isDisposed()) {
       return;
     }
-    hopGui
-        .getDisplay()
-        .asyncExec(
-            () -> {
-              if (pipelineGridView == null || pipelineGridView.isDisposed()) {
-                return;
-              }
-              Table table = pipelineGridView.table;
-              TableColumn sortCol = table.getSortColumn();
-              if (sortCol != null) {
-                gridSortColumn = table.indexOf(sortCol);
-                gridSortDescending = (table.getSortDirection() == SWT.DOWN);
-              }
-            });
-  }
-
-  /**
-   * Sort the row data by the given column and direction before writing to the 
table. Column index 0
-   * = #, 1 = name, 2 = copy, 3+ = metrics, then duration, speed, status. 
Numeric columns (formatted
-   * with commas) are compared as numbers; others as strings.
-   */
-  private void sortComponentStringsByColumn(
-      List<List<String>> rows, int sortColumn, boolean descending) {
-    if (sortColumn < 0 || rows.isEmpty()) {
+    if (gridSortColumn < 0 || gridSortColumn >= 
pipelineMetricsTree.getColumnCount()) {
+      pipelineMetricsTree.setSortColumn(null);
+      pipelineMetricsTree.setSortDirection(SWT.NONE);
       return;
     }
-    int col = sortColumn;
-    boolean desc = descending;
-    rows.sort(
-        (a, b) -> {
-          String sa = col < a.size() ? Const.NVL(a.get(col), "") : "";
-          String sb = col < b.size() ? Const.NVL(b.get(col), "") : "";
-          int c = compareCellValues(sa, sb);
-          return desc ? -c : c;
-        });
-  }
-
-  private int compareCellValues(String a, String b) {
-    String sa = a != null ? a : "";
-    String sb = b != null ? b : "";
-    try {
-      long na = parseFormattedLong(sa);
-      long nb = parseFormattedLong(sb);
-      return Long.compare(na, nb);
-    } catch (NumberFormatException e) {
-      // not both numeric, compare as strings
+    TreeColumn wanted = pipelineMetricsTree.getColumn(gridSortColumn);
+    int direction = gridSortDescending ? SWT.DOWN : SWT.UP;
+    if (pipelineMetricsTree.getSortColumn() != wanted) {
+      pipelineMetricsTree.setSortColumn(wanted);
+    }
+    if (pipelineMetricsTree.getSortDirection() != direction) {
+      pipelineMetricsTree.setSortDirection(direction);
     }
-    return sa.compareToIgnoreCase(sb);
   }
 
-  private static long parseFormattedLong(String s) {
-    if (s == null || s.isEmpty()) {
-      return 0L;
-    }
-    String trimmed = s.trim();
-    if (trimmed.isEmpty()) {
-      return 0L;
-    }
-    // Strip trailing unit suffix so we can parse the number (e.g. "1,234 
rows" or "1,234 r" ->
-    // 1234)
-    trimmed = trimmed.replaceAll("\\s+(rows|r|runs|flushes|rows/s)$", "");
-    return Long.parseLong(trimmed.replace(",", ""));
+  private String metricsTreeMemoryName() {
+    return "HopGuiPipelineGrid:" + System.identityHashCode(pipelineGraph);
   }
 
-  /** Update the table header to show which column is sorted and in which 
direction. */
-  private void setSortIndicator() {
-    if (pipelineGridView == null || pipelineGridView.isDisposed()) {
-      return;
-    }
-    Table table = pipelineGridView.table;
-    if (gridSortColumn < 0 || gridSortColumn >= table.getColumnCount()) {
+  /**
+   * Forgets remembered expansion and collapses every group so the next run 
starts on the totals.
+   */
+  private void collapseMetricsTree() {
+    TreeMemory.getInstance().clearTree(metricsTreeMemoryName());
+    if (pipelineMetricsTree == null || pipelineMetricsTree.isDisposed()) {
       return;
     }
-    TableColumn wanted = table.getColumn(gridSortColumn);
-    int direction = gridSortDescending ? SWT.DOWN : SWT.UP;
-    if (table.getSortColumn() != wanted) {
-      table.setSortColumn(wanted);
-    }
-    if (table.getSortDirection() != direction) {
-      table.setSortDirection(direction);
+    for (TreeItem item : pipelineMetricsTree.getItems()) {
+      if (!item.isDisposed() && item.getExpanded()) {
+        item.setExpanded(false);
+      }
     }
   }
 
@@ -1422,89 +1287,4 @@ public class HopGuiPipelineGridDelegate {
     }
     return false;
   }
-
-  private String calculateDuration(IEngineComponent component) {
-    String duration;
-    Date firstRowReadDate = component.getFirstRowReadDate();
-    if (firstRowReadDate != null) {
-      long durationMs;
-      if (component.getLastRowWrittenDate() == null) {
-        durationMs = System.currentTimeMillis() - firstRowReadDate.getTime();
-      } else {
-        durationMs = component.getLastRowWrittenDate().getTime() - 
firstRowReadDate.getTime();
-      }
-      duration = Utils.getDurationHMS(((double) durationMs) / 1000);
-    } else {
-      duration = "";
-    }
-    return duration;
-  }
-
-  private static final String METRICS_FORMAT = " ###,###,###,###";
-
-  private static NumberFormat metricFormat = new DecimalFormat(METRICS_FORMAT);
-
-  private String formatMetric(Long value) {
-    return metricFormat.format(value);
-  }
-
-  private void updateRowFromBaseTransform(ITransform baseTransform, TableItem 
row) {
-    // The row shows the numbers only; the log text would be the transform's 
whole log formatted
-    // once a second (issue #8435).
-    TransformStatus transformStatus = new TransformStatus(baseTransform, 
false);
-
-    String[] fields = transformStatus.getPipelineLogFields();
-
-    updateCellsIfChanged(fields, row);
-
-    if (baseTransform.getErrors() > 0) {
-      row.setBackground(GuiResource.getInstance().getColorLightRed());
-    } else {
-      row.setBackground(null);
-    }
-  }
-
-  /**
-   * Anti-flicker: if nothing has changed, don't change it on the screen!
-   *
-   * @param fields
-   * @param row
-   */
-  private void updateCellsIfChanged(String[] fields, TableItem row) {
-    for (int f = 1; f < fields.length; f++) {
-      if (!fields[f].equalsIgnoreCase(row.getText(f))) {
-        row.setText(f, fields[f]);
-      }
-    }
-  }
-
-  /**
-   * Sub Transform Compare
-   *
-   * <p>Note - nulls must be handled outside of this method
-   *
-   * @param o1 - First object to compare
-   * @param o2 - Second object to compare
-   * @return 0 if equal, integer greater than 0 if o1 > o2, integer less than 
0 if o2 > o1
-   */
-  static int subTransformCompare(Object o1, Object o2) {
-    final String[] string1 = o1.toString().split("\\.");
-    final String[] string2 = o2.toString().split("\\.");
-
-    // Compare the base transform first
-    int cmp = Integer.compare(Integer.parseInt(string1[0]), 
Integer.parseInt(string2[0]));
-
-    // if the base transform numbers are equal, then we need to compare the 
sub transform numbers
-    if (cmp == 0) {
-      if (string1.length == 2 && string2.length == 2) {
-        // compare the sub transform numbers
-        cmp = Integer.compare(Integer.parseInt(string1[1]), 
Integer.parseInt(string2[1]));
-      } else if (string1.length < string2.length) {
-        cmp = -1;
-      } else if (string2.length < string1.length) {
-        cmp = 1;
-      }
-    }
-    return cmp;
-  }
 }
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsGrouper.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsGrouper.java
new file mode 100644
index 0000000000..b1ba5b72aa
--- /dev/null
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsGrouper.java
@@ -0,0 +1,468 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.ui.hopgui.file.pipeline.delegates;
+
+import java.text.DecimalFormat;
+import java.text.ParsePosition;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.hop.pipeline.engine.EngineComponent.ComponentExecutionStatus;
+import org.apache.hop.pipeline.engine.EngineMetrics;
+import org.apache.hop.pipeline.engine.IEngineComponent;
+import org.apache.hop.pipeline.engine.IEngineMetric;
+
+/**
+ * Groups pipeline engine components into metrics-tree rows. Several copies of 
one transform become
+ * one aggregate parent plus a child per copy. A single copy stays a leaf. 
Numeric metrics are
+ * summed. Duration is the wall-clock span. Speed is the sum of the per-copy 
samples.
+ */
+final class PipelineMetricsGrouper {
+
+  static final int COLUMN_NAME = 0;
+  static final int COLUMN_COPY = 1;
+  static final int LEADING_COLUMNS = 2;
+  static final int TRAILING_COLUMNS = 3;
+
+  /**
+   * Same pattern {@code TransformStatus} uses ({@code new 
DecimalFormat("#,###,###,###,##0")}). The
+   * formatter itself supplies the desktop locale's grouping separator.
+   */
+  static final String SPEED_PATTERN = "#,###,###,###,##0";
+
+  /** No-break space. Some JDKs use this as the fr-FR grouping separator. */
+  private static final char NO_BREAK_SPACE = '\u00a0';
+
+  /** Narrow no-break space. Current JDKs use this as the fr-FR grouping 
separator. */
+  private static final char NARROW_NO_BREAK_SPACE = '\u202f';
+
+  private static final String SPEED_UNIT = 
"(?i)(?:rows/s|rows|runs|flushes|r)";
+
+  /**
+   * Highest priority first. A parent shows the first of these that any copy 
is in, so one halted
+   * copy is not hidden behind the copies that are still running.
+   */
+  private static final List<ComponentExecutionStatus> STATUS_PRIORITY =
+      List.of(
+          ComponentExecutionStatus.STATUS_HALTED,
+          ComponentExecutionStatus.STATUS_HALTING,
+          ComponentExecutionStatus.STATUS_STOPPED,
+          ComponentExecutionStatus.STATUS_PAUSED,
+          ComponentExecutionStatus.STATUS_RUNNING,
+          ComponentExecutionStatus.STATUS_IDLE,
+          ComponentExecutionStatus.STATUS_INIT,
+          ComponentExecutionStatus.STATUS_FINISHED,
+          ComponentExecutionStatus.STATUS_DISPOSED,
+          ComponentExecutionStatus.STATUS_EMPTY);
+
+  private PipelineMetricsGrouper() {}
+
+  static List<PipelineMetricsNode> group(
+      List<IEngineComponent> components,
+      EngineMetrics engineMetrics,
+      List<IEngineMetric> usedMetrics) {
+    return group(components, engineMetrics, usedMetrics, 
System.currentTimeMillis());
+  }
+
+  static List<PipelineMetricsNode> group(
+      List<IEngineComponent> components,
+      EngineMetrics engineMetrics,
+      List<IEngineMetric> usedMetrics,
+      long nowMs) {
+    Map<String, List<IEngineComponent>> groups = new LinkedHashMap<>();
+    if (components != null) {
+      for (IEngineComponent component : components) {
+        if (component == null) {
+          continue;
+        }
+        String name = component.getName() == null ? "" : component.getName();
+        groups.computeIfAbsent(name, key -> new ArrayList<>()).add(component);
+      }
+    }
+
+    List<IEngineMetric> metrics = usedMetrics == null ? List.of() : 
usedMetrics;
+    List<PipelineMetricsNode> nodes = new ArrayList<>();
+    for (Map.Entry<String, List<IEngineComponent>> entry : groups.entrySet()) {
+      List<IEngineComponent> copies = new ArrayList<>(entry.getValue());
+      copies.sort(Comparator.comparingInt(IEngineComponent::getCopyNr));
+      if (copies.size() == 1) {
+        nodes.add(leaf(copies.get(0), engineMetrics, metrics, nowMs));
+      } else {
+        List<PipelineMetricsNode> children = new ArrayList<>();
+        for (IEngineComponent copy : copies) {
+          children.add(leaf(copy, engineMetrics, metrics, nowMs));
+        }
+        nodes.add(parent(entry.getKey(), copies, children, engineMetrics, 
metrics, nowMs));
+      }
+    }
+    return nodes;
+  }
+
+  /**
+   * Sorts parent rows only. Children stay in copy-number order. Equal values 
keep pipeline order. A
+   * negative column leaves the list as it is.
+   */
+  static void sortParents(
+      List<PipelineMetricsNode> nodes,
+      int column,
+      boolean descending,
+      List<IEngineMetric> usedMetrics) {
+    if (column < 0 || nodes == null || nodes.size() < 2) {
+      return;
+    }
+    List<IEngineMetric> metrics = usedMetrics == null ? List.of() : 
usedMetrics;
+    nodes.sort(
+        (left, right) -> {
+          int compared = compare(left, right, column, metrics);
+          return descending ? -compared : compared;
+        });
+  }
+
+  static int durationColumn(List<IEngineMetric> usedMetrics) {
+    return LEADING_COLUMNS + (usedMetrics == null ? 0 : usedMetrics.size());
+  }
+
+  private static PipelineMetricsNode leaf(
+      IEngineComponent component,
+      EngineMetrics engineMetrics,
+      List<IEngineMetric> usedMetrics,
+      long nowMs) {
+    List<IEngineComponent> copies = List.of(component);
+    SpeedAggregate speed = speed(copies, engineMetrics);
+    String name = component.getName() == null ? "" : component.getName();
+    return new PipelineMetricsNode(
+        name,
+        component.getCopyNr(),
+        1,
+        false,
+        sumMetrics(copies, engineMetrics, usedMetrics),
+        durationMs(copies, nowMs),
+        speed.value,
+        speed.text,
+        statusText(engineMetrics, component),
+        List.of());
+  }
+
+  private static PipelineMetricsNode parent(
+      String name,
+      List<IEngineComponent> copies,
+      List<PipelineMetricsNode> children,
+      EngineMetrics engineMetrics,
+      List<IEngineMetric> usedMetrics,
+      long nowMs) {
+    SpeedAggregate speed = speed(copies, engineMetrics);
+    int firstCopy = copies.get(0).getCopyNr();
+    return new PipelineMetricsNode(
+        name,
+        firstCopy,
+        copies.size(),
+        true,
+        sumMetrics(copies, engineMetrics, usedMetrics),
+        durationMs(copies, nowMs),
+        speed.value,
+        speed.text,
+        aggregateStatus(statusTexts(copies, engineMetrics)),
+        children);
+  }
+
+  private static Map<String, Long> sumMetrics(
+      List<IEngineComponent> copies, EngineMetrics engineMetrics, 
List<IEngineMetric> usedMetrics) {
+    Map<String, Long> sums = new LinkedHashMap<>();
+    if (engineMetrics == null) {
+      return sums;
+    }
+    for (IEngineMetric metric : usedMetrics) {
+      if (metric == null || !metric.isNumeric() || metric.getCode() == null) {
+        continue;
+      }
+      long sum = 0L;
+      boolean any = false;
+      for (IEngineComponent component : copies) {
+        Long value = engineMetrics.getComponentMetric(component, metric);
+        if (value != null) {
+          any = true;
+          sum += value;
+        }
+      }
+      if (any) {
+        sums.put(metric.getCode(), sum);
+      }
+    }
+    return sums;
+  }
+
+  private static Long durationMs(List<IEngineComponent> copies, long nowMs) {
+    Date start = null;
+    Date end = null;
+    boolean stillOpen = false;
+    for (IEngineComponent component : copies) {
+      Date first = component.getFirstRowReadDate();
+      if (first == null) {
+        continue;
+      }
+      if (start == null || first.before(start)) {
+        start = first;
+      }
+      Date last = component.getLastRowWrittenDate();
+      if (last == null) {
+        stillOpen = true;
+      } else if (end == null || last.after(end)) {
+        end = last;
+      }
+    }
+    if (start == null) {
+      return null;
+    }
+    long endMs = stillOpen || end == null ? nowMs : end.getTime();
+    return Math.max(0L, endMs - start.getTime());
+  }
+
+  private static SpeedAggregate speed(List<IEngineComponent> copies, 
EngineMetrics engineMetrics) {
+    if (copies.size() == 1) {
+      String raw = speedRaw(engineMetrics, copies.get(0));
+      Double sample = parseSpeed(raw);
+      String text = raw == null || raw.isBlank() ? "" : raw.trim();
+      Long value = sample == null ? null : Math.round(sample);
+      return new SpeedAggregate(value, text);
+    }
+    double total = 0d;
+    boolean any = false;
+    for (IEngineComponent component : copies) {
+      Double sample = parseSpeed(speedRaw(engineMetrics, component));
+      if (sample != null) {
+        any = true;
+        total += sample;
+      }
+    }
+    if (!any) {
+      return new SpeedAggregate(null, "-");
+    }
+    long rounded = Math.round(total);
+    return new SpeedAggregate(rounded, new 
DecimalFormat(SPEED_PATTERN).format(rounded));
+  }
+
+  private static String speedRaw(EngineMetrics engineMetrics, IEngineComponent 
component) {
+    if (engineMetrics == null || engineMetrics.getComponentSpeedMap() == null) 
{
+      return null;
+    }
+    return engineMetrics.getComponentSpeedMap().get(component);
+  }
+
+  /**
+   * {@code -} and blank are "no sample", not zero. Grouped integers ({@code 
1,000}) and decimals
+   * are accepted. A trailing unit such as {@code rows/s} is ignored.
+   *
+   * <p>{@code TransformStatus} formats speed with {@code new 
DecimalFormat(SPEED_PATTERN)} in the
+   * desktop locale and prefixes a space. That form is parsed first. Padding 
is removed with the
+   * same character range as {@link String#trim()} ({@code <= ' '}), which 
drops that prefix and
+   * leaves a grouping separator of U+202F or U+00A0 in the number. Replacing 
either separator with
+   * a normal space would stop the parse after the first group.
+   */
+  static Double parseSpeed(String raw) {
+    if (raw == null) {
+      return null;
+    }
+    String rough = raw.trim();
+    if (rough.isEmpty() || "-".equals(rough)) {
+      return null;
+    }
+    DecimalFormat format = new DecimalFormat(SPEED_PATTERN);
+    char grouping = format.getDecimalFormatSymbols().getGroupingSeparator();
+    String trimmed = trimPadding(raw, grouping);
+    if (trimmed.isEmpty() || "-".equals(trimmed)) {
+      return null;
+    }
+    Double local = parseLocalSpeed(format, grouping, trimmed);
+    if (local != null) {
+      return local;
+    }
+    trimmed = trimmed.replace(",", "");
+    trimmed = trimmed.replaceAll("\\s+" + SPEED_UNIT + "$", "");
+    if (trimmed.isEmpty() || "-".equals(trimmed)) {
+      return null;
+    }
+    try {
+      return Double.parseDouble(trimmed);
+    } catch (NumberFormatException e) {
+      return null;
+    }
+  }
+
+  /**
+   * Parses text written by {@code new DecimalFormat(SPEED_PATTERN)} in the 
default locale. Returns
+   * null when {@code text} is not that form, so the caller can fall back to 
comma stripping.
+   */
+  private static Double parseLocalSpeed(DecimalFormat format, char grouping, 
String text) {
+    String normalized = text;
+    if (grouping != NO_BREAK_SPACE) {
+      normalized = normalized.replace(NO_BREAK_SPACE, grouping);
+    }
+    if (grouping != NARROW_NO_BREAK_SPACE) {
+      normalized = normalized.replace(NARROW_NO_BREAK_SPACE, grouping);
+    }
+    ParsePosition position = new ParsePosition(0);
+    Number parsed = format.parse(normalized, position);
+    if (parsed == null || position.getIndex() == 0) {
+      return null;
+    }
+    String remainder = normalized.substring(position.getIndex()).trim();
+    if (!remainder.isEmpty() && !remainder.matches(SPEED_UNIT)) {
+      return null;
+    }
+    return parsed.doubleValue();
+  }
+
+  /**
+   * Drops leading and trailing padding. Characters {@code <= ' '} always go, 
including the space
+   * {@code TransformStatus} prefixes. A grouping separator that is itself a 
Unicode space (U+202F
+   * or U+00A0) stays, including when it is the first character of the number.
+   */
+  private static String trimPadding(String raw, char grouping) {
+    int start = 0;
+    int end = raw.length();
+    while (start < end && isPadding(raw.charAt(start), grouping)) {
+      start++;
+    }
+    while (end > start && isPadding(raw.charAt(end - 1), grouping)) {
+      end--;
+    }
+    return raw.substring(start, end);
+  }
+
+  private static boolean isPadding(char c, char grouping) {
+    if (c <= ' ') {
+      return true;
+    }
+    return c != grouping && Character.isSpaceChar(c);
+  }
+
+  private static String statusText(EngineMetrics engineMetrics, 
IEngineComponent component) {
+    if (engineMetrics == null || engineMetrics.getComponentStatusMap() == 
null) {
+      return "";
+    }
+    String status = engineMetrics.getComponentStatusMap().get(component);
+    return status == null ? "" : status;
+  }
+
+  private static List<String> statusTexts(
+      List<IEngineComponent> copies, EngineMetrics engineMetrics) {
+    List<String> texts = new ArrayList<>();
+    for (IEngineComponent component : copies) {
+      texts.add(statusText(engineMetrics, component));
+    }
+    return texts;
+  }
+
+  static String aggregateStatus(List<String> descriptions) {
+    String bestText = null;
+    int bestRank = Integer.MAX_VALUE;
+    String firstUnknown = null;
+    int knownCount = 0;
+    if (descriptions != null) {
+      for (String description : descriptions) {
+        if (description == null || description.isEmpty()) {
+          continue;
+        }
+        ComponentExecutionStatus parsed =
+            ComponentExecutionStatus.getStatusFromDescription(description);
+        boolean known =
+            parsed.getDescription() != null
+                && parsed.getDescription().equalsIgnoreCase(description);
+        if (!known) {
+          if (firstUnknown == null) {
+            firstUnknown = description;
+          }
+          continue;
+        }
+        knownCount++;
+        int rank = STATUS_PRIORITY.indexOf(parsed);
+        if (rank >= 0 && rank < bestRank) {
+          bestRank = rank;
+          bestText = description;
+        }
+      }
+    }
+    if (knownCount > 0) {
+      return bestText == null ? "" : bestText;
+    }
+    return firstUnknown == null ? "" : firstUnknown;
+  }
+
+  private static int compare(
+      PipelineMetricsNode left,
+      PipelineMetricsNode right,
+      int column,
+      List<IEngineMetric> usedMetrics) {
+    if (column == COLUMN_NAME) {
+      return 
left.getTransformName().compareToIgnoreCase(right.getTransformName());
+    }
+    if (column == COLUMN_COPY) {
+      return Integer.compare(copySortKey(left), copySortKey(right));
+    }
+    int durationColumn = durationColumn(usedMetrics);
+    if (column == durationColumn) {
+      return Long.compare(durationSortKey(left), durationSortKey(right));
+    }
+    if (column == durationColumn + 1) {
+      return Long.compare(speedSortKey(left), speedSortKey(right));
+    }
+    if (column == durationColumn + 2) {
+      return left.getStatus().compareToIgnoreCase(right.getStatus());
+    }
+    int metricIndex = column - LEADING_COLUMNS;
+    if (metricIndex >= 0 && metricIndex < usedMetrics.size()) {
+      IEngineMetric metric = usedMetrics.get(metricIndex);
+      String code = metric == null ? null : metric.getCode();
+      return Long.compare(metricSortKey(left, code), metricSortKey(right, 
code));
+    }
+    return 0;
+  }
+
+  private static int copySortKey(PipelineMetricsNode node) {
+    return node.isAggregate() ? node.getCopyCount() : node.getCopyNr();
+  }
+
+  private static long durationSortKey(PipelineMetricsNode node) {
+    return node.getDurationMs() == null ? 0L : node.getDurationMs();
+  }
+
+  private static long speedSortKey(PipelineMetricsNode node) {
+    return node.getSpeedValue() == null ? 0L : node.getSpeedValue();
+  }
+
+  private static long metricSortKey(PipelineMetricsNode node, String code) {
+    if (code == null) {
+      return 0L;
+    }
+    Long value = node.getMetricSums().get(code);
+    return value == null ? 0L : value;
+  }
+
+  private static final class SpeedAggregate {
+    private final Long value;
+    private final String text;
+
+    private SpeedAggregate(Long value, String text) {
+      this.value = value;
+      this.text = text;
+    }
+  }
+}
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsNode.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsNode.java
new file mode 100644
index 0000000000..5a5394243f
--- /dev/null
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsNode.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.ui.hopgui.file.pipeline.delegates;
+
+import java.util.List;
+import java.util.Map;
+import lombok.Getter;
+
+/**
+ * One row in the pipeline metrics tree. A leaf is a single running copy. An 
aggregate is the
+ * collapsed parent of several copies; its children are those copies.
+ */
+@Getter
+final class PipelineMetricsNode {
+  private final String transformName;
+  private final int copyNr;
+  private final int copyCount;
+  private final boolean aggregate;
+  private final Map<String, Long> metricSums;
+  private final Long durationMs;
+  private final Long speedValue;
+  private final String speedText;
+  private final String status;
+  private final List<PipelineMetricsNode> children;
+
+  PipelineMetricsNode(
+      String transformName,
+      int copyNr,
+      int copyCount,
+      boolean aggregate,
+      Map<String, Long> metricSums,
+      Long durationMs,
+      Long speedValue,
+      String speedText,
+      String status,
+      List<PipelineMetricsNode> children) {
+    this.transformName = transformName == null ? "" : transformName;
+    this.copyNr = copyNr;
+    this.copyCount = copyCount;
+    this.aggregate = aggregate;
+    this.metricSums =
+        metricSums == null || metricSums.isEmpty() ? Map.of() : 
Map.copyOf(metricSums);
+    this.durationMs = durationMs;
+    this.speedValue = speedValue;
+    this.speedText = speedText == null ? "" : speedText;
+    this.status = status == null ? "" : status;
+    this.children = children == null || children.isEmpty() ? List.of() : 
List.copyOf(children);
+  }
+}
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsTree.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsTree.java
new file mode 100644
index 0000000000..aa1620ada5
--- /dev/null
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsTree.java
@@ -0,0 +1,476 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.ui.hopgui.file.pipeline.delegates;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.hop.core.Const;
+import org.apache.hop.core.util.Utils;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.Pipeline;
+import org.apache.hop.pipeline.engine.IEngineMetric;
+import org.apache.hop.ui.core.gui.GuiResource;
+import org.apache.hop.ui.core.widget.TreeMemory;
+import org.apache.hop.ui.hopgui.HopGui;
+import org.apache.hop.ui.hopgui.file.pipeline.PipelineMetricDisplayUtil;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+/** Fills the pipeline metrics tree from grouped rows and keeps expand state 
across refreshes. */
+final class PipelineMetricsTree {
+
+  private static final Class<?> PKG = HopGui.class;
+
+  private static final String METRICS_PATTERN = " ###,###,###,###";
+
+  /** Item data key for the "number of copies" tooltip shown on an aggregate 
row. */
+  static final String COPY_TOOLTIP_KEY = "pipelineMetricsCopyCountTooltip";
+
+  private static final String ERROR_PAINT_KEY = "pipelineMetricsErrorPaint";
+
+  private PipelineMetricsTree() {}
+
+  /**
+   * Identity of one tree row. A child carries the transform name so 
open-transform does not parse
+   * the label.
+   */
+  static final class RowKey {
+    final String transformName;
+    final int copyNr;
+    final boolean aggregate;
+
+    RowKey(String transformName, int copyNr, boolean aggregate) {
+      this.transformName = transformName == null ? "" : transformName;
+      this.copyNr = copyNr;
+      this.aggregate = aggregate;
+    }
+
+    boolean matches(RowKey other) {
+      return other != null
+          && aggregate == other.aggregate
+          && copyNr == other.copyNr
+          && transformName.equals(other.transformName);
+    }
+  }
+
+  /**
+   * Updates {@code tree} to show {@code nodes}. When the names and copy 
numbers already match, only
+   * changed cell text is written so the scroll position and which rows are 
expanded stay put.
+   * Otherwise the tree is rebuilt and expand state comes from {@link 
TreeMemory}. New parents stay
+   * collapsed.
+   */
+  static void sync(
+      Tree tree,
+      List<PipelineMetricsNode> nodes,
+      List<IEngineMetric> usedMetrics,
+      boolean showUnits,
+      String treeMemoryName) {
+    if (tree == null || tree.isDisposed()) {
+      return;
+    }
+    List<PipelineMetricsNode> rows = nodes == null ? List.of() : nodes;
+    List<IEngineMetric> metrics = usedMetrics == null ? List.of() : 
usedMetrics;
+    if (sameStructure(tree, rows)) {
+      tree.setRedraw(false);
+      try {
+        updateItems(tree.getItems(), rows, metrics, showUnits);
+      } finally {
+        if (!tree.isDisposed()) {
+          tree.setRedraw(true);
+        }
+      }
+      return;
+    }
+
+    List<RowKey> selected = captureSelection(tree);
+    RowKey top = captureTop(tree);
+    tree.setRedraw(false);
+    try {
+      tree.removeAll();
+      for (PipelineMetricsNode node : rows) {
+        TreeItem item = new TreeItem(tree, SWT.NONE);
+        fillItem(item, node, false, metrics, showUnits);
+        for (PipelineMetricsNode child : node.getChildren()) {
+          TreeItem childItem = new TreeItem(item, SWT.NONE);
+          fillItem(childItem, child, true, metrics, showUnits);
+        }
+      }
+      if (treeMemoryName != null) {
+        TreeMemory.setExpandedFromMemory(tree, treeMemoryName);
+      }
+      restoreSelection(tree, selected);
+      restoreTop(tree, top);
+    } finally {
+      if (!tree.isDisposed()) {
+        tree.setRedraw(true);
+      }
+    }
+  }
+
+  /**
+   * Header row plus one TSV line per selected item. With nothing selected, 
every row is included,
+   * collapsed children too.
+   */
+  static String copyText(Tree tree) {
+    if (tree == null || tree.isDisposed() || tree.getColumnCount() == 0) {
+      return null;
+    }
+    TreeItem[] selected = tree.getSelection();
+    List<TreeItem> items = new ArrayList<>();
+    if (selected == null || selected.length == 0) {
+      collect(tree.getItems(), items);
+    } else {
+      for (TreeItem item : selected) {
+        if (item != null && !item.isDisposed()) {
+          items.add(item);
+        }
+      }
+    }
+    StringBuilder text = new StringBuilder();
+    appendRow(text, header(tree));
+    for (TreeItem item : items) {
+      appendRow(text, itemTexts(item));
+    }
+    return text.toString();
+  }
+
+  static List<String> cellTexts(
+      PipelineMetricsNode node,
+      boolean childRow,
+      List<IEngineMetric> usedMetrics,
+      boolean showUnits) {
+    List<IEngineMetric> metrics = usedMetrics == null ? List.of() : 
usedMetrics;
+    List<String> cells = new ArrayList<>();
+    if (childRow) {
+      cells.add(BaseMessages.getString(PKG, "PipelineLog.Tree.Copy", 
node.getCopyNr()));
+    } else {
+      cells.add(node.getTransformName());
+    }
+    if (node.isAggregate()) {
+      cells.add(Integer.toString(node.getCopyCount()));
+    } else {
+      cells.add(Integer.toString(node.getCopyNr()));
+    }
+
+    DecimalFormat metricFormat = new DecimalFormat(METRICS_PATTERN);
+    for (IEngineMetric metric : metrics) {
+      String code = metric == null ? null : metric.getCode();
+      Long value = code == null ? null : node.getMetricSums().get(code);
+      cells.add(formatMetric(metric, value, metricFormat, showUnits));
+    }
+    cells.add(formatDuration(node.getDurationMs(), showUnits));
+    cells.add(formatSpeed(node.getSpeedText(), showUnits));
+    cells.add(node.getStatus());
+    return cells;
+  }
+
+  /** Shows the copy-count tooltip while the pointer is over that cell of an 
aggregate row. */
+  static void installCopyCountTooltip(Tree tree) {
+    tree.addListener(
+        SWT.MouseMove,
+        event -> {
+          if (tree.isDisposed()) {
+            return;
+          }
+          TreeItem item = tree.getItem(new Point(event.x, event.y));
+          String tooltip = null;
+          if (item != null && !item.isDisposed()) {
+            int column = columnAt(item, event.x);
+            if (column == PipelineMetricsGrouper.COLUMN_COPY) {
+              Object value = item.getData(COPY_TOOLTIP_KEY);
+              if (value instanceof String text && !text.isEmpty()) {
+                tooltip = text;
+              }
+            }
+          }
+          if ((tooltip == null && tree.getToolTipText() != null)
+              || (tooltip != null && !tooltip.equals(tree.getToolTipText()))) {
+            tree.setToolTipText(tooltip);
+          }
+        });
+    tree.addListener(
+        SWT.MouseExit,
+        event -> {
+          if (!tree.isDisposed() && tree.getToolTipText() != null) {
+            tree.setToolTipText(null);
+          }
+        });
+  }
+
+  private static boolean sameStructure(Tree tree, List<PipelineMetricsNode> 
nodes) {
+    TreeItem[] items = tree.getItems();
+    if (items.length != nodes.size()) {
+      return false;
+    }
+    for (int i = 0; i < nodes.size(); i++) {
+      if (!sameItem(items[i], nodes.get(i))) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  private static boolean sameItem(TreeItem item, PipelineMetricsNode node) {
+    if (!(item.getData() instanceof RowKey key) || !key.matches(rowKey(node))) 
{
+      return false;
+    }
+    TreeItem[] children = item.getItems();
+    List<PipelineMetricsNode> expected = node.getChildren();
+    if (children.length != expected.size()) {
+      return false;
+    }
+    for (int i = 0; i < expected.size(); i++) {
+      if (!(children[i].getData() instanceof RowKey childKey)
+          || !childKey.matches(rowKey(expected.get(i)))) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  private static void updateItems(
+      TreeItem[] items,
+      List<PipelineMetricsNode> nodes,
+      List<IEngineMetric> usedMetrics,
+      boolean showUnits) {
+    for (int i = 0; i < nodes.size(); i++) {
+      PipelineMetricsNode node = nodes.get(i);
+      fillItem(items[i], node, false, usedMetrics, showUnits);
+      List<PipelineMetricsNode> children = node.getChildren();
+      for (int c = 0; c < children.size(); c++) {
+        fillItem(items[i].getItem(c), children.get(c), true, usedMetrics, 
showUnits);
+      }
+    }
+  }
+
+  private static void fillItem(
+      TreeItem item,
+      PipelineMetricsNode node,
+      boolean childRow,
+      List<IEngineMetric> usedMetrics,
+      boolean showUnits) {
+    item.setData(rowKey(node));
+    if (node.isAggregate()) {
+      item.setData(
+          COPY_TOOLTIP_KEY, BaseMessages.getString(PKG, 
"PipelineLog.Tree.CopyCount.Tooltip"));
+    } else if (item.getData(COPY_TOOLTIP_KEY) != null) {
+      item.setData(COPY_TOOLTIP_KEY, null);
+    }
+    applyTexts(item, cellTexts(node, childRow, usedMetrics, showUnits));
+    paintError(item, node);
+  }
+
+  private static RowKey rowKey(PipelineMetricsNode node) {
+    return new RowKey(node.getTransformName(), node.getCopyNr(), 
node.isAggregate());
+  }
+
+  private static void applyTexts(TreeItem item, List<String> texts) {
+    Tree tree = item.getParent();
+    int columns = Math.min(texts.size(), tree.getColumnCount());
+    for (int column = 0; column < columns; column++) {
+      String next = Const.NVL(texts.get(column), "");
+      if (!next.equals(item.getText(column))) {
+        item.setText(column, next);
+      }
+    }
+  }
+
+  /**
+   * Whole-row background, the same light red the flat grid used. Per-cell 
{@code setBackground} on
+   * GTK installs a cell renderer that stretches later rows, so this stays on 
the item.
+   */
+  private static void paintError(TreeItem item, PipelineMetricsNode node) {
+    Long errors = node.getMetricSums().get(Pipeline.METRIC_NAME_ERROR);
+    boolean wantError = errors != null && errors > 0;
+    boolean painted = Boolean.TRUE.equals(item.getData(ERROR_PAINT_KEY));
+    if (wantError == painted) {
+      return;
+    }
+    if (wantError) {
+      item.setBackground(GuiResource.getInstance().getColorLightRed());
+    } else {
+      item.setBackground(null);
+    }
+    item.setData(ERROR_PAINT_KEY, wantError);
+  }
+
+  private static String formatMetric(
+      IEngineMetric metric, Long value, DecimalFormat metricFormat, boolean 
showUnits) {
+    if (metric == null) {
+      return "";
+    }
+    String code = metric.getCode();
+    if (Pipeline.METRIC_NAME_DATA_VOLUME.equals(code)
+        || Pipeline.METRIC_NAME_DATA_VOLUME_IN.equals(code)
+        || Pipeline.METRIC_NAME_DATA_VOLUME_OUT.equals(code)) {
+      return value == null ? "" : 
PipelineMetricDisplayUtil.formatDataVolume(value);
+    }
+    if (value == null) {
+      return "";
+    }
+    String unit = showUnits ? 
PipelineMetricDisplayUtil.getUnitForMetricCell(metric) : null;
+    String text = metricFormat.format(value);
+    if (unit != null && !unit.isEmpty()) {
+      text = text + " " + unit;
+    }
+    return text;
+  }
+
+  private static String formatDuration(Long durationMs, boolean showUnits) {
+    if (durationMs == null) {
+      return "";
+    }
+    String text = Utils.getDurationHMS(durationMs / 1000.0);
+    return showUnits ? text + " (h:m:s)" : text;
+  }
+
+  private static String formatSpeed(String speedText, boolean showUnits) {
+    if (speedText == null || speedText.isEmpty()) {
+      return "";
+    }
+    String trimmed = speedText.trim();
+    if (showUnits && !"-".equals(trimmed)) {
+      return trimmed + " rows/s";
+    }
+    return trimmed;
+  }
+
+  private static List<RowKey> captureSelection(Tree tree) {
+    List<RowKey> keys = new ArrayList<>();
+    TreeItem[] selection = tree.getSelection();
+    if (selection == null) {
+      return keys;
+    }
+    for (TreeItem item : selection) {
+      if (item.getData() instanceof RowKey key) {
+        keys.add(key);
+      }
+    }
+    return keys;
+  }
+
+  private static RowKey captureTop(Tree tree) {
+    TreeItem top = tree.getTopItem();
+    if (top != null && top.getData() instanceof RowKey key) {
+      return key;
+    }
+    return null;
+  }
+
+  private static void restoreSelection(Tree tree, List<RowKey> selected) {
+    if (selected.isEmpty()) {
+      return;
+    }
+    List<TreeItem> matches = new ArrayList<>();
+    collectMatching(tree.getItems(), selected, matches);
+    if (!matches.isEmpty()) {
+      tree.setSelection(matches.toArray(new TreeItem[0]));
+    }
+  }
+
+  private static void restoreTop(Tree tree, RowKey top) {
+    if (top == null) {
+      return;
+    }
+    TreeItem match = find(tree.getItems(), top);
+    if (match != null) {
+      tree.setTopItem(match);
+    }
+  }
+
+  private static void collectMatching(
+      TreeItem[] items, List<RowKey> selected, List<TreeItem> matches) {
+    for (TreeItem item : items) {
+      if (item.getData() instanceof RowKey key && contains(selected, key)) {
+        matches.add(item);
+      }
+      collectMatching(item.getItems(), selected, matches);
+    }
+  }
+
+  private static boolean contains(List<RowKey> selected, RowKey key) {
+    for (RowKey candidate : selected) {
+      if (candidate.matches(key)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  private static TreeItem find(TreeItem[] items, RowKey key) {
+    for (TreeItem item : items) {
+      if (item.getData() instanceof RowKey candidate && 
candidate.matches(key)) {
+        return item;
+      }
+      TreeItem nested = find(item.getItems(), key);
+      if (nested != null) {
+        return nested;
+      }
+    }
+    return null;
+  }
+
+  private static void collect(TreeItem[] items, List<TreeItem> into) {
+    for (TreeItem item : items) {
+      into.add(item);
+      collect(item.getItems(), into);
+    }
+  }
+
+  private static List<String> header(Tree tree) {
+    List<String> cells = new ArrayList<>();
+    for (int column = 0; column < tree.getColumnCount(); column++) {
+      cells.add(Const.NVL(tree.getColumn(column).getText(), ""));
+    }
+    return cells;
+  }
+
+  private static List<String> itemTexts(TreeItem item) {
+    List<String> cells = new ArrayList<>();
+    Tree tree = item.getParent();
+    for (int column = 0; column < tree.getColumnCount(); column++) {
+      cells.add(Const.NVL(item.getText(column), ""));
+    }
+    return cells;
+  }
+
+  private static void appendRow(StringBuilder text, List<String> cells) {
+    for (int column = 0; column < cells.size(); column++) {
+      if (column > 0) {
+        text.append('\t');
+      }
+      text.append(cells.get(column));
+    }
+    text.append(Const.CR);
+  }
+
+  private static int columnAt(TreeItem item, int x) {
+    Tree tree = item.getParent();
+    for (int column = 0; column < tree.getColumnCount(); column++) {
+      Rectangle bounds = item.getBounds(column);
+      if (x >= bounds.x && x < bounds.x + bounds.width) {
+        return column;
+      }
+    }
+    return -1;
+  }
+}
diff --git 
a/ui/src/main/resources/org/apache/hop/ui/hopgui/messages/messages_en_US.properties
 
b/ui/src/main/resources/org/apache/hop/ui/hopgui/messages/messages_en_US.properties
index 0036f97e8d..fbbaf445a6 100644
--- 
a/ui/src/main/resources/org/apache/hop/ui/hopgui/messages/messages_en_US.properties
+++ 
b/ui/src/main/resources/org/apache/hop/ui/hopgui/messages/messages_en_US.properties
@@ -313,6 +313,8 @@ PipelineLog.Column.Active=Active
 PipelineLog.Column.BuffersInput=Buffers Input (rows)
 PipelineLog.Column.BuffersOutput=Buffers Output (rows)
 PipelineLog.Column.Copynr=Copy
+PipelineLog.Tree.Copy=copy {0}
+PipelineLog.Tree.CopyCount.Tooltip=Number of copies
 PipelineLog.Column.Duration=Duration (h:m:s)
 PipelineLog.Column.DurationNoUnit=Duration
 PipelineLog.Column.SpeedNoUnit=Speed
diff --git 
a/ui/src/test/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsGrouperTest.java
 
b/ui/src/test/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsGrouperTest.java
new file mode 100644
index 0000000000..792f09472e
--- /dev/null
+++ 
b/ui/src/test/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/PipelineMetricsGrouperTest.java
@@ -0,0 +1,354 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.ui.hopgui.file.pipeline.delegates;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import org.apache.hop.pipeline.Pipeline;
+import org.apache.hop.pipeline.engine.EngineComponent;
+import org.apache.hop.pipeline.engine.EngineComponent.ComponentExecutionStatus;
+import org.apache.hop.pipeline.engine.EngineMetric;
+import org.apache.hop.pipeline.engine.EngineMetrics;
+import org.apache.hop.pipeline.engine.IEngineComponent;
+import org.apache.hop.pipeline.engine.IEngineMetric;
+import org.junit.jupiter.api.Test;
+
+class PipelineMetricsGrouperTest {
+
+  private static final IEngineMetric INPUT = Pipeline.METRIC_INPUT;
+  private static final IEngineMetric ERRORS = Pipeline.METRIC_ERROR;
+  private static final long NOW = 10_000L;
+
+  @Test
+  void singleCopyStaysALeaf() {
+    EngineComponent only = component("Read", 0);
+    EngineMetrics metrics = metrics(only, INPUT, 12L, "Running", " 40");
+
+    List<PipelineMetricsNode> nodes =
+        PipelineMetricsGrouper.group(List.of(only), metrics, List.of(INPUT), 
NOW);
+
+    assertEquals(1, nodes.size());
+    PipelineMetricsNode leaf = nodes.get(0);
+    assertFalse(leaf.isAggregate());
+    assertTrue(leaf.getChildren().isEmpty());
+    assertEquals(0, leaf.getCopyNr());
+    assertEquals(12L, leaf.getMetricSums().get(Pipeline.METRIC_NAME_INPUT));
+    assertEquals("40", leaf.getSpeedText());
+    assertEquals("Running", leaf.getStatus());
+  }
+
+  @Test
+  void severalCopiesCollapseToTotalsAndKeepPerCopyRows() {
+    EngineComponent second = component("Rest", 2);
+    EngineComponent first = component("Rest", 0);
+    EngineComponent third = component("Rest", 1);
+    EngineComponent fourth = component("Rest", 3);
+    EngineMetrics metrics = new EngineMetrics();
+    metric(metrics, second, INPUT, 5L);
+    metric(metrics, first, INPUT, 10L);
+    metric(metrics, fourth, INPUT, null);
+    metric(metrics, third, ERRORS, 2L);
+    metrics.setComponentSpeed(first, " 1,000");
+    metrics.setComponentSpeed(third, "-");
+    metrics.setComponentSpeed(second, "250");
+    metrics.setComponentSpeed(fourth, "500");
+    metrics.setComponentStatus(first, 
status(ComponentExecutionStatus.STATUS_FINISHED));
+    metrics.setComponentStatus(third, 
status(ComponentExecutionStatus.STATUS_RUNNING));
+    metrics.setComponentStatus(second, 
status(ComponentExecutionStatus.STATUS_FINISHED));
+    metrics.setComponentStatus(fourth, 
status(ComponentExecutionStatus.STATUS_FINISHED));
+
+    List<PipelineMetricsNode> nodes =
+        PipelineMetricsGrouper.group(
+            List.of(second, first, third, fourth), metrics, List.of(INPUT, 
ERRORS), NOW);
+
+    assertEquals(1, nodes.size());
+    PipelineMetricsNode parent = nodes.get(0);
+    assertTrue(parent.isAggregate());
+    assertEquals(4, parent.getCopyCount());
+    assertEquals(15L, parent.getMetricSums().get(Pipeline.METRIC_NAME_INPUT));
+    assertEquals(2L, parent.getMetricSums().get(Pipeline.METRIC_NAME_ERROR));
+    assertEquals(1750L, parent.getSpeedValue());
+    assertEquals(new DecimalFormat("#,###,###,###,##0").format(1750), 
parent.getSpeedText());
+    assertEquals(status(ComponentExecutionStatus.STATUS_RUNNING), 
parent.getStatus());
+
+    assertEquals(4, parent.getChildren().size());
+    for (int copy = 0; copy < 4; copy++) {
+      PipelineMetricsNode child = parent.getChildren().get(copy);
+      assertFalse(child.isAggregate());
+      assertEquals(copy, child.getCopyNr());
+      assertEquals("Rest", child.getTransformName());
+    }
+    
assertNull(parent.getChildren().get(3).getMetricSums().get(Pipeline.METRIC_NAME_INPUT));
+    assertFalse(parent.getMetricSums().containsKey("not-a-metric"));
+  }
+
+  @Test
+  void allMissingValuesStayBlankAndSpeedWithoutSamplesIsUnavailable() {
+    EngineComponent first = component("Rest", 0);
+    EngineComponent second = component("Rest", 1);
+    EngineMetrics metrics = new EngineMetrics();
+    metrics.setComponentSpeed(first, "-");
+    metrics.setComponentSpeed(second, " ");
+
+    List<PipelineMetricsNode> nodes =
+        PipelineMetricsGrouper.group(List.of(first, second), metrics, 
List.of(INPUT), NOW);
+
+    PipelineMetricsNode parent = nodes.get(0);
+    assertNull(parent.getMetricSums().get(Pipeline.METRIC_NAME_INPUT));
+    assertNull(parent.getSpeedValue());
+    assertEquals("-", parent.getSpeedText());
+    assertNull(parent.getDurationMs());
+  }
+
+  @Test
+  void durationUsesTheEarliestStartAndStaysOpenWhileACopyIsRunning() {
+    EngineComponent finished = component("Rest", 0);
+    finished.setFirstRowReadDate(new Date(1_000L));
+    finished.setLastRowWrittenDate(new Date(4_000L));
+    EngineComponent running = component("Rest", 1);
+    running.setFirstRowReadDate(new Date(2_000L));
+    EngineMetrics metrics = new EngineMetrics();
+
+    PipelineMetricsNode parent =
+        PipelineMetricsGrouper.group(List.of(finished, running), metrics, 
List.of(INPUT), NOW)
+            .get(0);
+
+    assertEquals(NOW - 1_000L, parent.getDurationMs());
+    assertEquals(3_000L, parent.getChildren().get(0).getDurationMs());
+    assertEquals(NOW - 2_000L, parent.getChildren().get(1).getDurationMs());
+  }
+
+  @Test
+  void durationUsesTheLatestFinishWhenEveryCopyHasClosed() {
+    EngineComponent first = component("Rest", 0);
+    first.setFirstRowReadDate(new Date(1_000L));
+    first.setLastRowWrittenDate(new Date(4_000L));
+    EngineComponent second = component("Rest", 1);
+    second.setFirstRowReadDate(new Date(500L));
+    second.setLastRowWrittenDate(new Date(8_000L));
+
+    PipelineMetricsNode parent =
+        PipelineMetricsGrouper.group(
+                List.of(first, second), new EngineMetrics(), List.of(INPUT), 
NOW)
+            .get(0);
+
+    assertEquals(7_500L, parent.getDurationMs());
+  }
+
+  @Test
+  void haltedBeatsRunningAndAnUnknownStatusIsKeptOnlyOnItsOwn() {
+    assertEquals(
+        status(ComponentExecutionStatus.STATUS_HALTED),
+        PipelineMetricsGrouper.aggregateStatus(
+            List.of(
+                status(ComponentExecutionStatus.STATUS_RUNNING),
+                status(ComponentExecutionStatus.STATUS_HALTED))));
+    assertEquals(
+        status(ComponentExecutionStatus.STATUS_FINISHED),
+        PipelineMetricsGrouper.aggregateStatus(
+            List.of(status(ComponentExecutionStatus.STATUS_FINISHED), 
"not-a-status")));
+    assertEquals("not-a-status", 
PipelineMetricsGrouper.aggregateStatus(List.of("not-a-status")));
+  }
+
+  @Test
+  void oneRemainingCopyIsALeaf() {
+    EngineComponent only = component("Rest", 3);
+    List<PipelineMetricsNode> nodes =
+        PipelineMetricsGrouper.group(List.of(only), new EngineMetrics(), 
List.of(INPUT), NOW);
+
+    assertEquals(1, nodes.size());
+    assertFalse(nodes.get(0).isAggregate());
+    assertEquals(3, nodes.get(0).getCopyNr());
+  }
+
+  @Test
+  void nonNumericMetricsAreNotSummed() {
+    IEngineMetric note = new EngineMetric("note", "Note", "", "999", false);
+    EngineComponent first = component("Rest", 0);
+    EngineComponent second = component("Rest", 1);
+    EngineMetrics metrics = new EngineMetrics();
+    metrics.setComponentMetric(first, note, 1L);
+    metrics.setComponentMetric(second, note, 1L);
+
+    PipelineMetricsNode parent =
+        PipelineMetricsGrouper.group(List.of(first, second), metrics, 
List.of(note), NOW).get(0);
+
+    assertTrue(parent.getMetricSums().isEmpty());
+  }
+
+  @Test
+  void parentSortDoesNotReorderChildrenAndKeepsPipelineOrderOnTies() {
+    EngineComponent beta = component("Beta", 0);
+    EngineComponent alphaHigh = component("Alpha", 1);
+    EngineComponent alphaLow = component("Alpha", 0);
+    EngineComponent gamma = component("Gamma", 2);
+    EngineMetrics metrics = new EngineMetrics();
+    metric(metrics, beta, INPUT, 5L);
+    metric(metrics, alphaHigh, INPUT, 5L);
+    metric(metrics, alphaLow, INPUT, 9L);
+    metric(metrics, gamma, INPUT, 5L);
+
+    List<PipelineMetricsNode> nodes =
+        new ArrayList<>(
+            PipelineMetricsGrouper.group(
+                List.of(beta, alphaHigh, alphaLow, gamma), metrics, 
List.of(INPUT), NOW));
+    assertEquals(List.of("Beta", "Alpha", "Gamma"), names(nodes));
+    assertEquals(List.of(0, 1), copyNumbers(nodes.get(1)));
+
+    PipelineMetricsGrouper.sortParents(
+        nodes, PipelineMetricsGrouper.COLUMN_NAME, true, List.of(INPUT));
+    assertEquals(List.of("Gamma", "Beta", "Alpha"), names(nodes));
+    assertEquals(List.of(0, 1), copyNumbers(nodes.get(2)));
+
+    List<PipelineMetricsNode> byInput =
+        new ArrayList<>(
+            PipelineMetricsGrouper.group(
+                List.of(beta, alphaHigh, alphaLow, gamma), metrics, 
List.of(INPUT), NOW));
+    PipelineMetricsGrouper.sortParents(
+        byInput, PipelineMetricsGrouper.LEADING_COLUMNS, false, 
List.of(INPUT));
+    // Beta and Gamma both total 5, so they stay in pipeline order ahead of 
Alpha's 14.
+    assertEquals(List.of("Beta", "Gamma", "Alpha"), names(byInput));
+    assertEquals(List.of(0, 1), copyNumbers(byInput.get(2)));
+  }
+
+  @Test
+  void childLabelAndCopyCountAreFormattedForTheTree() {
+    EngineComponent first = component("Rest", 0);
+    EngineComponent second = component("Rest", 1);
+    EngineMetrics metrics = new EngineMetrics();
+    metric(metrics, first, INPUT, 10L);
+    metric(metrics, second, INPUT, 20L);
+    PipelineMetricsNode parent =
+        PipelineMetricsGrouper.group(List.of(first, second), metrics, 
List.of(INPUT), NOW).get(0);
+
+    List<String> parentCells = PipelineMetricsTree.cellTexts(parent, false, 
List.of(INPUT), false);
+    List<String> childCells =
+        PipelineMetricsTree.cellTexts(parent.getChildren().get(0), true, 
List.of(INPUT), false);
+
+    assertEquals("Rest", parentCells.get(0));
+    assertEquals("2", parentCells.get(1));
+    assertEquals("copy 0", childCells.get(0));
+    assertEquals("0", childCells.get(1));
+    assertTrue(parentCells.get(2).replace(",", "").replace(" ", 
"").contains("30"));
+  }
+
+  @Test
+  void parentSpeedTotalUsesTheLocalNumberFormat() {
+    Locale previous = Locale.getDefault();
+    try {
+      for (Locale locale :
+          List.of(
+              Locale.US,
+              Locale.forLanguageTag("nl-BE"),
+              Locale.forLanguageTag("de-DE"),
+              Locale.forLanguageTag("fr-FR"))) {
+        assertParentSpeedTotal(locale);
+      }
+    } finally {
+      Locale.setDefault(previous);
+    }
+  }
+
+  /**
+   * Formats each copy the way {@code TransformStatus} does ({@code " " + 
decimalFormat}) and checks
+   * the parent total. Also repeats the number with U+202F and U+00A0 as the 
grouping separator, the
+   * two spaces fr-FR uses.
+   */
+  private static void assertParentSpeedTotal(Locale locale) {
+    Locale.setDefault(locale);
+    DecimalFormat format = new 
DecimalFormat(PipelineMetricsGrouper.SPEED_PATTERN);
+    String formatted = format.format(12_345);
+    char grouping = format.getDecimalFormatSymbols().getGroupingSeparator();
+    assertTrue(formatted.indexOf(grouping) >= 0, locale.toLanguageTag());
+
+    assertGroupedSpeedTotals(format, " " + formatted, locale.toLanguageTag());
+    if (grouping != '\u202f') {
+      assertGroupedSpeedTotals(
+          format, " " + formatted.replace(grouping, '\u202f'), 
locale.toLanguageTag() + " U+202F");
+    }
+    if (grouping != '\u00a0') {
+      assertGroupedSpeedTotals(
+          format, " " + formatted.replace(grouping, '\u00a0'), 
locale.toLanguageTag() + " U+00A0");
+    }
+  }
+
+  private static void assertGroupedSpeedTotals(DecimalFormat format, String 
speed, String label) {
+    EngineMetrics metrics = new EngineMetrics();
+    List<IEngineComponent> copies = new ArrayList<>();
+    for (int copy = 0; copy < 4; copy++) {
+      EngineComponent component = component("Read", copy);
+      copies.add(component);
+      metrics.setComponentSpeed(component, speed);
+    }
+
+    PipelineMetricsNode parent =
+        PipelineMetricsGrouper.group(copies, metrics, List.of(INPUT), 
NOW).get(0);
+
+    assertEquals(49_380L, parent.getSpeedValue(), label);
+    assertEquals(format.format(49_380), parent.getSpeedText(), label);
+  }
+
+  private static List<String> names(List<PipelineMetricsNode> nodes) {
+    List<String> names = new ArrayList<>();
+    for (PipelineMetricsNode node : nodes) {
+      names.add(node.getTransformName());
+    }
+    return names;
+  }
+
+  private static List<Integer> copyNumbers(PipelineMetricsNode node) {
+    List<Integer> copies = new ArrayList<>();
+    for (PipelineMetricsNode child : node.getChildren()) {
+      copies.add(child.getCopyNr());
+    }
+    return copies;
+  }
+
+  private static String status(ComponentExecutionStatus executionStatus) {
+    return executionStatus.getDescription();
+  }
+
+  private static EngineComponent component(String name, int copyNr) {
+    return new EngineComponent(name, copyNr);
+  }
+
+  private static EngineMetrics metrics(
+      EngineComponent component, IEngineMetric metric, long value, String 
status, String speed) {
+    EngineMetrics metrics = new EngineMetrics();
+    metric(metrics, component, metric, value);
+    metrics.setComponentStatus(component, status);
+    metrics.setComponentSpeed(component, speed);
+    return metrics;
+  }
+
+  private static void metric(
+      EngineMetrics metrics, IEngineComponent component, IEngineMetric metric, 
Long value) {
+    metrics.addComponent(component);
+    if (value != null) {
+      metrics.setComponentMetric(component, metric, value);
+    }
+  }
+}

Reply via email to