Skip to content

feat: raw command channel for et - #854

Merged
MisterTea merged 10 commits into
masterfrom
feat/raw-command-channel
Sep 23, 2026
Merged

MisterTea merged 10 commits into
masterfrom
feat/raw-command-channel

Conversation

@MisterTea

Copy link
Copy Markdown
Owner

Summary

  • Run -T remote commands on pipes instead of a pty: binary stdin/stdout, separate stderr, no motd, and no shell ; exit injection.
  • Interactive sessions stay on the existing pty path.

Test plan

  • ctest --test-dir build --output-on-failure --parallel
  • -T -c command: stdout and stderr are distinct and binary-safe
  • A session without -T still allocates a pty

Made with Cursor

jasongauci-webai and others added 5 commits September 22, 2026 17:42
Cursor needs a non-pty command channel with binary stdio and separate stderr.

Co-authored-by: Cursor <cursoragent@cursor.com>
Hold stdout/stderr write ends until after child dup2 via a ready pipe, and
switch tests to octal escapes that dash and FreeBSD sh honor.

Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid the stdio stderr macro clash that breaks OpenWrt cross-compiles of
generated ETerminal.pb.h accessors.

Co-authored-by: Cursor <cursoragent@cursor.com>
PipeUserTerminalWindows socketpair helper was resolving bind to std::bind
and failing the Windows vcpkg matrix (which then cancelled sibling jobs).

Co-authored-by: Cursor <cursoragent@cursor.com>
FreeBSD sh execs `cat >file` as the last -c command, closing the pipe write
end while cat still reads stdin. Close stdin on stdout EOF and end the test
command with `true` so waitid cannot hang.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.71006% with 99 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.29%. Comparing base (a836741) to head (447191d).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/terminal/PipeUserTerminalUnix.hpp 70.11% 12 Missing and 14 partials ⚠️
src/terminal/TerminalServer.cpp 59.64% 13 Missing and 10 partials ⚠️
src/terminal/UserTerminalHandlerUnix.cpp 68.75% 9 Missing and 6 partials ⚠️
test/integration_tests/RawCommandChannelTest.cpp 87.61% 5 Missing and 9 partials ⚠️
src/terminal/BinaryStdioConsole.hpp 0.00% 13 Missing ⚠️
src/terminal/TerminalClient.cpp 58.82% 2 Missing and 5 partials ⚠️
src/terminal/UserTerminal.hpp 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #854      +/-   ##
==========================================
- Coverage   79.35%   79.29%   -0.06%     
==========================================
  Files         121      125       +4     
  Lines       12769    13090     +321     
  Branches     8219     8441     +222     
==========================================
+ Hits        10133    10380     +247     
- Misses       1568     1614      +46     
- Partials     1068     1096      +28     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

jasongauci-webai and others added 5 commits September 23, 2026 01:07
Gate POSIX headers and use io.h/_fileno so the vcpkg Windows matrix can
compile TerminalClientMain with et -T.

Co-authored-by: Cursor <cursoragent@cursor.com>
echo OUT exited before FakeConsole connected, so the handler tore down
and the collector FATAL'd on an invalid socket. Mirror Unix cat with
findstr waiting for EOF.

Co-authored-by: Cursor <cursoragent@cursor.com>
cmd /c treats ^ as an escape, so findstr \"^\" never behaved as intended
and the integration test hung until the 600s ctest timeout.

Co-authored-by: Cursor <cursoragent@cursor.com>
Close bridge sockets before joining threads so recv cannot hang, and
terminate a stubborn child after a short wait so uth join cannot stall
the raw-command integration test for 600s.

Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid LOG(FATAL) on an invalid socket when the Windows session ends
before the collector starts draining stdout.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The cross-platform process, pipe, buffering, and protocol lifecycle changes require final human validation.

Review effort: Balanced
Findings: None

What changed in this PR

Adds a raw command channel for et -T -c, using pipes rather than a PTY while preserving the existing interactive path.

Changes:

  • Adds no_pty, command, and stderr metadata to the protocol.
  • Introduces Unix/Windows pipe-backed terminals and binary stdio handling.
  • Routes stdout/stderr separately and adds integration coverage.
File Description
proto/​ETerminal.proto Adds raw-command and stderr protocol fields.
src/​terminal/​BinaryStdioConsole.hpp Adds binary local stdio console.
src/​terminal/​ParseConfigFile.hpp Marks header-defined functions inline.
src/​terminal/​PipeUserTerminal.hpp Selects the platform implementation.
src/​terminal/​PipeUserTerminalUnix.hpp Implements Unix child pipes.
src/​terminal/​PipeUserTerminalWindows.hpp Implements Windows pipes and socket bridges.
src/​terminal/​TerminalClient.cpp Sends raw-mode metadata and separates output streams.
src/​terminal/​TerminalClient.hpp Extends client state and constructor.
src/​terminal/​TerminalClientMain.cpp Adds -T and selects binary stdio.
src/​terminal/​TerminalServer.cpp Relays packet-framed raw streams.
src/​terminal/​UserTerminal.hpp Generalizes terminal input/stderr descriptors.
src/​terminal/​UserTerminalHandler.hpp Adds raw-mode state and forwarding helper.
src/​terminal/​UserTerminalHandlerUnix.cpp Pumps Unix stdin/stdout/stderr pipes.
src/​terminal/​UserTerminalHandlerWindows.cpp Pumps Windows bridge sockets.
test/​integration_tests/​RawCommandChannelTest.cpp Tests binary stream separation and command handling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@MisterTea
MisterTea merged commit 34b1948 into master Sep 23, 2026
38 checks passed
@MisterTea
MisterTea deleted the feat/raw-command-channel branch September 23, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants