diff --git a/runner/hello.txt b/runner/hello.txt new file mode 100644 index 0000000..6f83d0f --- /dev/null +++ b/runner/hello.txt @@ -0,0 +1,2 @@ +lkjdfslka + diff --git a/runner/jt.sh b/runner/jt.sh index d326df1..279eb35 100755 --- a/runner/jt.sh +++ b/runner/jt.sh @@ -7,7 +7,7 @@ # ) JSON=$(cat <<'EOF' -{"command":"nano","args":["-w","./hello.txt"],"ssh":{"host":"localhost","user":"j","key":"auto"},"options":{"interactive":true},"env":{"TERM":"xterm-256color"}} +{"command":"nano","args":["-w","./hello.txt"],"options":{"interactive":true}} EOF ) diff --git a/runner/src/runner.cpp b/runner/src/runner.cpp index 1e9bfa6..bdb25e9 100644 --- a/runner/src/runner.cpp +++ b/runner/src/runner.cpp @@ -356,6 +356,10 @@ int Runner::execute_ssh( ssh_options_set(session, SSH_OPTIONS_PORT, &port); ssh_options_set(session, SSH_OPTIONS_USER, user.c_str()); + // Set pseudo-terminal flag (equivalent to ssh -tt) + int flag = 1; + ssh_options_set(session, SSH_OPTIONS_STRICTHOSTKEYCHECK, &flag); + // Connect to server int rc = ssh_connect(session); if (rc != SSH_OK) { @@ -426,19 +430,28 @@ int Runner::execute_ssh( if (interactive) { // Request a pseudo-terminal for interactive commands with specific term type const char* term_type = "xterm-256color"; + + // Force PTY allocation first with basic settings + rc = ssh_channel_request_pty(channel); + if (rc != SSH_OK) { + std::cerr << "Error requesting basic PTY: " << ssh_get_error(session) << std::endl; + ssh_channel_close(channel); + ssh_channel_free(channel); + ssh_disconnect(session); + ssh_free(session); + return -1; + } + + // Then set the size and term type rc = ssh_channel_request_pty_size(channel, term_type, 80, 24); if (rc != SSH_OK) { - // Fallback to basic PTY request - std::cerr << "Warning: Could not set PTY with size, falling back to basic PTY" << std::endl; - rc = ssh_channel_request_pty(channel); - if (rc != SSH_OK) { - std::cerr << "Error requesting PTY: " << ssh_get_error(session) << std::endl; - ssh_channel_close(channel); - ssh_channel_free(channel); - ssh_disconnect(session); - ssh_free(session); - return -1; - } + std::cerr << "Warning: Could not set PTY size, but continuing anyway" << std::endl; + } + + // Set up terminal mode to be more raw (important for full-screen apps) + if (env.find("TERM") == env.end()) { + // Add TERM environment if not present + cmd_stream << "export TERM=\"" << term_type << "\"; "; } }