How can I listen - which cell is running right now ? I need to have their running order

Hi guys. I will be very grateful If someone help me.
I have implemented statuses for each of cell (“Running”, “Completed”); I have a button “Run”(for every cell). On click on this button I give to it html status block “Running”. And also I have this code -

NotebookActions.executed.connect((_, args) => {
    setCellState("");

    const { cell } = args;
    const cellRunningStatuses = window.document.getElementsByClassName(
        "jp-enh-cell-toolbar-direction-status-run"
    );
    const cellCompletedStatuses = window.document.getElementsByClassName(
        "jp-enh-cell-toolbar-direction-status-completed"
    );
    for (let status of cellRunningStatuses) {
      status.classList.add("run");
    }
    for (let status of cellCompletedStatuses) {
      status.classList.remove("active");
    }
    cell.node
      .getElementsByClassName("jp-enh-cell-toolbar-direction-status-run")[0]
      ?.classList?.remove("run");
    cell.node
      .getElementsByClassName(
        "jp-enh-cell-toolbar-direction-status-completed"
      )[0]
      ?.classList?.add("active");
  });

whick executes when cell running if completed. And in this place I change status “Running” → “Completed”.
But also I have “Run all” button which execute:

commands.execute("runmenu:run-all");

For now my sollution is - to give to all cells statuses - “Running”, and with the code above change executed cell status to “Complete” one by one.
But I need not to make “Running” to all cells but only to this cell which is runs in this moment.
Something like:
“Run all” → Cell1 “Running” → Cell1 “Completed” → Cell2 “Running” → Cell2 “Completed” → finish.
Is there such listener ?

Here are some thoughts:

It looks like you are working with the DOM directly. If that isn’t a requirement, you may want to add this information to the metadata of the cell. The cells are available from the NotebookPanel: NotebookPanel#content.widgets.

In recent versions of JupyterLab NotebookActions.executed we can easily detect when execution has started and finished:

export class NotebookActions {
  /**
   * A signal that emits whenever a cell completes execution.
   */
  static get executed(): ISignal<
    any,
    {
      notebook: Notebook;
      cell: Cell;
      success: boolean;
      error?: KernelError | null;
    }
  > {
    return Private.executed;
  }

  /**
   * A signal that emits whenever a cell execution is scheduled.
   */
  static get executionScheduled(): ISignal<
    any,
    { notebook: Notebook; cell: Cell }
  > {
    return Private.executionScheduled;
  }

  /**
   * A signal that emits when one notebook's cells are all executed.
   */
  static get selectionExecuted(): ISignal<
    any,
    { notebook: Notebook; lastCell: Cell }
  > {
    return Private.selectionExecuted;
  }