List<Object?> toJson() => [ type, 'tabId', tabId, 'newState', newState, if (reason != null) ...['reason', reason], ];