Skip to content

Harden HTM sessions, add Windows support, and raise Unix coverage - #801

Merged
MisterTea merged 10 commits into
masterfrom
htm_improvements
Sep 1, 2026
Merged

Harden HTM sessions, add Windows support, and raise Unix coverage#801
MisterTea merged 10 commits into
masterfrom
htm_improvements

Conversation

@MisterTea

Copy link
Copy Markdown
Owner

Summary

  • Fix HTM disconnect races: 1-byte SESSION_END, ignore unknown headers instead of parsing a length, and do not abort htmd when the client hangs up.
  • Add Windows HTM via ConPTY and a detached htmd, and build htm/htmd on all platforms from HtmCommon.
  • Add Catch2 tests for IPC, multiplexer state, server/client protocol, and PTY lifecycle, plus PTY/iTerm2/Ghostty-style e2e coverage.
  • Repair the Codecov job for lcov 2.x, count src/htm, flush gcov from forked HtmClient tests, and fail coverage.sh if Unix HTM line coverage is under 80% (Windows/ConPTY branches are not compiled on that job).

Test plan

  • pushd build; ninja && ctest --parallel --output-on-failure; popd (or ./et-test '[Htm]')
  • bash coverage.sh and confirm HTM Unix line coverage ≥ 80%
  • Smoke htm -x on macOS/Linux: split, new tab, type into a pane, close a pane, disconnect with Escape, shut down with x
  • On Windows (if available): htm/htmd start a ConPTY session and survive client disconnect

Made with Cursor

MisterTea and others added 6 commits August 30, 2026 22:51
Disconnects no longer hang or abort the daemon: SESSION_END is a 1-byte
packet, unknown headers drop the connection instead of parsing a length,
and closeEndpoint ignores write failures on a dead pipe. Unix pane
shutdown closes the PTY master before reaping the child so a blocked
shell cannot stall waitpid.

Build htm/htmd on Windows with ConPTY and a detached htmd process, and
link tests against HtmCommon. Add Catch2 coverage for IPC, multiplexer
state, server/client protocol, and PTY lifecycle, plus PTY and iTerm2
end-to-end scripts.

Fix the Codecov job for lcov 2.x, flush gcov from forked HtmClient
tests, stop ignoring src/htm, and fail coverage.sh when Unix HTM line
coverage is under 80%.

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

HtmClient used to block in writeAll on a backed-up leader PTY, so stdin
(INSERT_KEYS) stalled and Hyper/iTerm dropped the session. Unix htm now
queues daemon output and keystrokes, writes when the fds are writable,
and treats SESSION_END as a packet-boundary 'D' so Base64 payloads cannot
look like a close.

Default ctest / ./et-test no longer run iTerm2, Ghostty, or Hyper e2e
until those terminals' HTM PRs land. Invoke them by name:

  ./et-test ghostty
  python3 test/system_tests/iterm2_htm_e2e.py
  npm run test:system   # hyper-htm repo

Protocol coverage (htm_pty/features/stress e2e and Catch2 HtmClient/
HtmServer tests) still runs by default.

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

Co-authored-by: Cursor <cursoragent@cursor.com>
…n/sh in tests.

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

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

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 49.62921% with 883 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.28%. Comparing base (b74a12e) to head (170720a).

Files with missing lines Patch % Lines
test/unit_tests/HtmGhosttyE2eTest.cpp 0.00% 728 Missing ⚠️
src/htm/HtmClient.cpp 66.66% 19 Missing and 13 partials ⚠️
src/htm/TerminalHandler.cpp 66.31% 18 Missing and 14 partials ⚠️
test/unit_tests/HtmServerClientTest.cpp 92.43% 15 Missing and 16 partials ⚠️
test/unit_tests/HtmTestHelpers.hpp 79.81% 11 Missing and 11 partials ⚠️
src/htm/HtmServer.cpp 69.23% 15 Missing and 1 partial ⚠️
test/Main.cpp 50.00% 6 Missing and 4 partials ⚠️
src/htm/IpcPairEndpoint.hpp 63.63% 2 Missing and 2 partials ⚠️
src/htm/MultiplexerState.cpp 75.00% 0 Missing and 2 partials ⚠️
test/TestHeaders.hpp 33.33% 1 Missing and 1 partial ⚠️
... and 3 more
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #801       +/-   ##
===========================================
- Coverage   87.14%   73.28%   -13.86%     
===========================================
  Files          75       94       +19     
  Lines        6462     8614     +2152     
  Branches      610     5701     +5091     
===========================================
+ Hits         5631     6313      +682     
- Misses        831     1705      +874     
- Partials        0      596      +596     

☔ 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.

MisterTea and others added 4 commits August 31, 2026 19:08
… Debian.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ll GCC via apt under act.

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

ThreadSanitizer aborts after Catch2 reports those tests passed because forkpty runs on a worker thread. Fedora/Arch e2e crashed when pgrep was not installed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@MisterTea
MisterTea merged commit fcce839 into master Sep 1, 2026
31 of 32 checks passed
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.

1 participant