Вот мой код:
```js
import {showDialog, closeDialog} from './dialogManager.js';
import {
    containerSelectors,
    showLoadingOverlay,
    hideLoadingOverlay,
    deleteContainer,
    executeDockerCommand,
    uploadContainer
} from './utils.js';

export let currentLogContainerId = null;

export function initUIHandlers(socket) {
    $('.sidebar .tab-btn').click(function () {
        $('.sidebar .tab-btn').removeClass('active');
        $(this).addClass('active');
        $('.tab-content').removeClass('active');
        $(`#${$(this).data('target')}`).addClass('active');
    });


    $(containerSelectors.running).on('click', '.output-button', function () {
        const containerId = $(this).closest('.docker-container-tile').data('container-id');
        currentLogContainerId = containerId;
        $('#console-title').text(`Logs for Container: ${containerId}`);
        $(containerSelectors.console).empty();
        socket.emit('start_container_logs', {container_id: containerId});
        $(containerSelectors.containerConsole).show();
    });

    $(containerSelectors.running).on('click', '.stop-button', function (event) {
        event.stopPropagation();
        const containerId = $(this).closest('.docker-container-tile').data('container-id');
        showLoadingOverlay(containerId);
        socket.emit('stop_container', containerId);
    });

    $(containerSelectors.running).on('click', '.restart-button', function (event) {
        event.stopPropagation();
        const containerId = $(this).closest('.docker-container-tile').data('container-id');
        showLoadingOverlay(containerId);
        socket.emit('restart_container', containerId);
    });

    $(containerSelectors.running).on('click', '.delete-button', function (event) {
        event.stopPropagation();
        const containerId = $(this).closest('.docker-container-tile').data('container-id');
        showDialog("Confirm Delete", "Are you sure you want to delete this container?", function () {
            showLoadingOverlay(containerId);
            deleteContainer(containerId, socket);
        });
    });

    $(containerSelectors.saved).on('click', '.run-button', function () {
        const imageId = $(this).closest('.docker-container-tile').data('image-id');

        const dialogContent = `
            <div class="dialog-line">
                <label for="container-name">Container Name:</label>
                <input type="text" id="container-name" placeholder="Container Name">
            </div>
            <div class="dialog-line">
                <label for="ports">Ports (format: hostPort:containerPort):</label>
                <input type="text" id="ports" placeholder="e.g., 8080:80,8443:443">
            </div>
            <div class="dialog-line">
                <label for="volumes">Volumes (format: hostPath:containerPath):</label>
                <input type="text" id="volumes" placeholder="e.g., /host/path:/container/path">
            </div>
            <div class="dialog-line">
                <label for="env-vars">Environment Variables (format: VAR=value):</label>
                <input type="text" id="env-vars" placeholder="e.g., ENV=production,DEBUG=1">
            </div>
            <div class="dialog-line">
                <label for="command">Command:</label>
                <input type="text" id="command" placeholder="e.g., /bin/bash">
            </div>
            <div class="dialog-line">
                <label for="additional-params">Additional Params:</label>
                <input type="text" id="additional-params" placeholder="e.g., --rm">
            </div>
            <div class="dialog-line">
                <label for="interactive">Interactive:</label>
                <input type="checkbox" id="interactive">
            </div>
            <div class="dialog-line">
                <label for="detached">Detached:</label>
                <input type="checkbox" id="detached" checked>
            </div>
            <div class="dialog-line">
               <button id="add-env-var">+</button>
            </div>
        
            <div id="env-vars-container">
            </div>
        
            <div class="dialog-line">
                <label for="generated-command">Generated Command:</label>
                <textarea id="generated-command"></textarea>
            </div>
        `;

        showDialog("Run Container", dialogContent, function () {
            // On confirm
            const options = getRunContainerOptions();
            socket.emit('run_container', {imageId, options});
        });

        // Initialize event handlers for inputs
        initRunContainerDialogHandlers();

        function addEnvVarRow(key = "", value = "") {
            const newRow = `
                <div class="env-var-row dialog-line">
                    <input type="text" class="env-var-key" placeholder="KEY" value="${key}">
                    <input type="text" class="env-var-value" placeholder="VALUE" value="${value}">
                    <button class="remove-env-var">-</button>
                </div>
            `;
            $('#env-vars-container').append(newRow);
        }


        function getRunContainerOptions() {
            const containerName = $('#container-name').val();
            const ports = $('#ports').val();
            const volumes = $('#volumes').val();
            //const envVars = $('#env-vars').val();
            const command = $('#command').val();
            const additionalParams = $('#additional-params').val();
            const interactive = $('#interactive').is(':checked');
            const detached = $('#detached').is(':checked');

            const envVars = [];
            $('.env-var-row').each(function () {
                const key = $(this).find('.env-var-key').val().trim();
                const value = $(this).find('.env-var-value').val().trim();
                if (key && value) {
                    envVars.push(`${key}=${value}`);
                }
            });

            return {
                containerName,
                ports,
                volumes,
                envVars: envVars.join(','),
                command,
                additionalParams,
                interactive,
                detached
            };
        }

        function initRunContainerDialogHandlers() {
            // Update generated command when inputs change
            $('.custom-dialog .dialog-content input, .custom-dialog .dialog-content select').on('input change', function () {
                updateGeneratedCommand();
            });

            // Update inputs when generated command changes
            $('#generated-command').on('input', function () {
                parseGeneratedCommand();
            });

            // Add Env Var button
            $('#add-env-var').on('click', function () {
                addEnvVarRow();
                updateGeneratedCommand(); // Update the command after adding a row
            });

            // Remove Env Var button dynamic handler
            $(document).on('click', '.remove-env-var', function () {
                $(this).closest('.env-var-row').remove();
                updateGeneratedCommand(); // Update the command after removing a row
            });

            // Initialize the generated command
            updateGeneratedCommand();
        }


        function parseGeneratedCommand() {
            const commandString = $('#generated-command').val();
            const options = parseDockerRunCommand(commandString);

            // Update inputs based on parsed options
            $('#container-name').val(options.containerName);
            $('#ports').val(options.ports.join(','));
            $('#volumes').val(options.volumes.join(','));
            $('#env-vars').val(options.envVars.join(','));
            $('#command').val(options.command);
            $('#additional-params').val(options.additionalParams.join(' '));
            $('#interactive').prop('checked', options.interactive);
            $('#detached').prop('checked', options.detached);

            // Parse and add environment variables
            $('#env-vars-container').empty(); // Clear existing rows

            console.log("options.envVars = ", options.envVars)
            if (options.envVars && options.envVars.length > 0) {  // Correct condition here!
                options.envVars.forEach(envVar => {
                    const parts = envVar.split('=');
                    console.log("NEW ROW - ", parts)
                    let key = "";
                    let value = "";
                    if(parts.length > 0) key = parts[0];
                    if(parts.length > 1) value = parts.slice(1).join("="); // handle cases with = in value


                    addEnvVarRow(key, value);
                });
            } else {
                // Add at least one default row if no environment vars in command
                addEnvVarRow();
            }
        }

        function updateGeneratedCommand() {
            const options = getRunContainerOptions();
            const commandString = buildDockerRunCommand(imageId, options);
            $('#generated-command').val(commandString);
        }

        function buildDockerRunCommand(imageId, options) {
            let cmd = `docker run`;

            if (options.detached) {
                cmd += ' -d';
            }

            if (options.interactive) {
                cmd += ' -i';
            }

            if (options.containerName) {
                cmd += ` --name ${options.containerName}`;
            }

            if (options.ports) {
                options.ports.split(',').forEach(port => {
                    cmd += ` -p ${port.trim()}`;
                });
            }

            if (options.volumes) {
                options.volumes.split(',').forEach(volume => {
                    cmd += ` -v ${volume.trim()}`;
                });
            }

            if (options.envVars) {
                options.envVars.split(',').forEach(envVar => {
                    cmd += ` -e ${envVar.trim()}`;
                });
            }

            if (options.additionalParams) {
                cmd += ` ${options.additionalParams}`;
            }

            cmd += ` ${imageId}`;

            if (options.command) {
                cmd += ` ${options.command}`;
            }

            return cmd;
        }

        function parseDockerRunCommand(commandString) {
            const options = {
                containerName: null,
                ports: [],
                volumes: [],
                envVars: [],
                command: null,
                additionalParams: [],
                interactive: false,
                detached: false
            };

            const regex = /(-d)|(-i)|(-p\s+(\S+))|(-v\s+(\S+))|(-e\s+([^=]+)=(.*?)(?=\s-[a-z]|$))|(--name\s+(\S+))|((?:[^-]|\-(?![divp]))+)|(\S+)/g;

            let match;
            let lastParam = null;

            while ((match = regex.exec(commandString)) !== null) {
                if (match[1]) options.detached = true;         // -d
                else if (match[2]) options.interactive = true;   // -i
                else if (match[3]) options.ports.push(match[4]);  // -p
                else if (match[5]) options.volumes.push(match[6]); // -v
                else if (match[7]) { // -e KEY=VALUE
                    options.envVars.push(`${match[8]}=${match[9].trim()}`); //correctly format env vars
                }
                else if (match[9]) options.containerName = match[10]; // --name
                else if (match[11]) lastParam = match[11].trim();
                else if (match[12] && lastParam === null) options.imageId = match[12];
                else if (match[12]) options.command = match[12];

                if (match[11] && lastParam === null && match[11].includes('-')) {
                    options.additionalParams = options.additionalParams.concat(match[11].trim().split(" ").filter(Boolean));
                }
            }


            return options;
        }
    });

    $(containerSelectors.saved).on('click', '.delete-button', function () {
        const imageId = $(this).closest('.docker-container-tile').data('image-id');
        showDialog("Confirm Delete", "Are you sure you want to delete this image?", function () {
            socket.emit('delete_image', imageId);
        });
    });

    $(document).on('click', containerSelectors.executeDockerCommandButton, function () {
        executeDockerCommand()
    });
    $(containerSelectors.closeConsole).click(() => {
        $(containerSelectors.containerConsole).hide();
        if (currentLogContainerId) {
            socket.emit('stop_container_logs', {container_id: currentLogContainerId});
            currentLogContainerId = null;
        }
    });

    $(containerSelectors.clearConsole).click(() => $(containerSelectors.console).empty());

    $(containerSelectors.addContainerButton).on('click', function () {
        const dialogContent = `
            <div class="dialog-line">
                <h3>Upload Image File</h3>
                <label for="container-file">Select Container File:</label>
                <input type="file" name="file" id="container-file"/>
                <button id="upload-container-button">Upload</button>
            </div>
            <hr>
            <div class="dialog-line">
                <h3>Pull Image from DockerHub</h3>
                <label for="docker-image-name">Docker Image Name:</label>
                <input type="text" name="docker_image_name" id="docker-image-name" placeholder="e.g., ubuntu:latest"/>
                <label for="docker-username">Username (if private):</label>
                <input type="text" name="docker_username" id="docker-username" placeholder="Username">
                <label for="docker-password">Password (if private):</label>
                <input type="password" name="docker_password" id="docker-password" placeholder="Password">
                <button id="pull-docker-image-button">Pull Image</button>
            </div>
        `;
        showDialog("Add Container", dialogContent);

        // Bind event handlers
        $(document).on('click', '#upload-container-button', function () {
            uploadContainer();
            closeDialog();
        });

        $(document).on('click', '#pull-docker-image-button', function () {
            pullDockerImage();
            closeDialog();
        });
    });

    $(document).on('click', '#upload-container-button', function () {
        uploadContainer();
        closeDialog();
    });
}
```
Он неправильно преобразует введенную docker run команду в части интерфейса.
Я ввожу:
```
docker run -d -p 5011:5011 \
  -e SECRET_KEY='your_secret_key' \
  -e ADMIN_PASSWORD='your_admin_password' \
  --name darkvpn_server \
```
а `options.envVars` равно [].

Можешь также проверить на наличие других ошибок.