Вот мой код:
```js
import { showDialog, closeDialog } from './dialogManager.js';
import {
    containerSelectors,
    showLoadingOverlay,
    hideLoadingOverlay,
    deleteContainer,
    executeDockerCommand,
    uploadContainer,
    pullDockerImage
} 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>Environment Variables:</label>
                <button id="add-env-var">+ Add Environment Variable</button>
            </div>

            <div id="env-vars-container">
                <!-- Environment variable rows will be added here -->
            </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">
                <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">- Remove</button>
                </div>
            `;
            $('#env-vars-container').append(newRow);
        }

        function getRunContainerOptions() {
            const containerName = $('#container-name').val();
            const ports = $('#ports').val();
            const volumes = $('#volumes').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) {
                    // Include value only if it's provided
                    const envVar = value ? `${key}=${value}` : key;
                    envVars.push(envVar);
                }
            });

            return {
                containerName,
                ports,
                volumes,
                envVars,
                command,
                additionalParams,
                interactive,
                detached
            };
        }

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

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

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

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

            // Initialize with one empty environment variable row
            addEnvVarRow();

            // 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(','));
            $('#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

            if (options.envVars && options.envVars.length > 0) {
                options.envVars.forEach(envVar => {
                    const parts = envVar.split('=');
                    let key = parts[0];
                    let value = parts.slice(1).join('='); // Handle '=' 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) {
            // Start with the base command
            let cmdParts = ['docker run'];

            // Flags
            if (options.detached) {
                cmdParts.push('-d');
            }

            if (options.interactive) {
                cmdParts.push('-i');
            }

            // Name
            if (options.containerName) {
                cmdParts.push(`--name ${options.containerName}`);
            }

            // Ports
            if (options.ports) {
                options.ports.split(',').forEach(port => {
                    cmdParts.push(`-p ${port.trim()}`);
                });
            }

            // Volumes
            if (options.volumes) {
                options.volumes.split(',').forEach(volume => {
                    cmdParts.push(`-v ${volume.trim()}`);
                });
            }

            // Environment variables
            if (options.envVars && options.envVars.length > 0) {
                options.envVars.forEach(envVar => {
                    cmdParts.push(`-e ${envVar.trim()}`);
                });
            }

            // Additional params
            if (options.additionalParams) {
                cmdParts.push(options.additionalParams);
            }

            // Image ID
            if (imageId) {
                cmdParts.push(`${imageId}`);
            }

            // Command
            if (options.command) {
                cmdParts.push(`${options.command}`);
            }

            // Now, format the command with line breaks and backslashes
            let cmd = cmdParts[0]; // Start with 'docker run'

            for (let i = 1; i < cmdParts.length; i++) {
                cmd += ' \\\n  ' + cmdParts[i];
            }

            return cmd;
        }

        function parseCommandLine(commandLine) {
            const args = [];
            let currentArg = '';
            let inSingleQuote = false;
            let inDoubleQuote = false;
            let escaped = false;

            for (let i = 0; i < commandLine.length; i++) {
                const char = commandLine[i];

                if (escaped) {
                    currentArg += char;
                    escaped = false;
                } else if (char === '\\') {
                    // Check if next character is a newline for line continuation
                    if (commandLine[i + 1] === '\n') {
                        i++; // Skip the newline character
                    } else {
                        escaped = true;
                    }
                } else if (char === "'" && !inDoubleQuote) {
                    inSingleQuote = !inSingleQuote;
                } else if (char === '"' && !inSingleQuote) {
                    inDoubleQuote = !inDoubleQuote;
                } else if (/\s/.test(char) && !inSingleQuote && !inDoubleQuote) {
                    if (currentArg.length > 0) {
                        args.push(currentArg);
                        currentArg = '';
                    }
                } else {
                    currentArg += char;
                }
            }
            if (currentArg.length > 0) {
                args.push(currentArg);
            }
            return args;
        }

        function preprocessCommand(commandString) {
            // Remove backslashes followed by line breaks
            commandString = commandString.replace(/\\\s*\n/g, ' ');

            // Replace multiple whitespace characters with a single space
            commandString = commandString.replace(/\s+/g, ' ').trim();

            return commandString;
        }

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

            // Preprocess the command string
            commandString = preprocessCommand(commandString);

            // Convert command string to array of arguments
            const args = parseCommandLine(commandString);

            // Remove the 'docker' and 'run' commands at the start
            let i = 0;
            if (args[i] === 'docker') i++;
            if (args[i] === 'run') i++;

            // Parse the arguments
            while (i < args.length) {
                const arg = args[i];

                switch (arg) {
                    case '-d':
                        options.detached = true;
                        break;
                    case '-i':
                        options.interactive = true;
                        break;
                    case '-p':
                        i++;
                        if (i < args.length) {
                            options.ports.push(args[i]);
                        }
                        break;
                    case '-v':
                        i++;
                        if (i < args.length) {
                            options.volumes.push(args[i]);
                        }
                        break;
                    case '-e':
                        i++;
                        if (i < args.length) {
                            options.envVars.push(args[i]);
                        }
                        break;
                    case '--name':
                        i++;
                        if (i < args.length) {
                            options.containerName = args[i];
                        }
                        break;
                    default:
                        if (arg.startsWith('-p')) {
                            options.ports.push(arg.substring(2));
                        } else if (arg.startsWith('-v')) {
                            options.volumes.push(arg.substring(2));
                        } else if (arg.startsWith('-e')) {
                            options.envVars.push(arg.substring(2));
                        } else if (arg.startsWith('--name=')) {
                            options.containerName = arg.substring(7);
                        } else if (arg.startsWith('-')) {
                            options.additionalParams.push(arg);
                        } else if (!options.imageId) {
                            options.imageId = arg;
                        } else {
                            // Collect the rest as command and its arguments
                            if (options.command) {
                                options.command += ' ' + arg;
                            } else {
                                options.command = arg;
                            }
                        }
                }

                i++;
            }

            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 to the dialog content
        $('.custom-dialog .dialog-content').off('click', '#upload-container-button').on('click', '#upload-container-button', function () {
            uploadContainer();
            closeDialog();
        });

        $('.custom-dialog .dialog-content').off('click', '#pull-docker-image-button').on('click', '#pull-docker-image-button', function () {
            pullDockerImage();
            closeDialog();
        });
    });
}
```
Убери генерацию предпросмотра команды, т.к. самой команды не отправляется. Просто сделай это только через интерфейс.

Приведи полный обновленный код