Skip to content

feat: close disconnected etterminal sessions after a timeout - #855

Merged
MisterTea merged 4 commits into
masterfrom
feat/disconnect-timeout
Sep 23, 2026
Merged

MisterTea merged 4 commits into
masterfrom
feat/disconnect-timeout

Conversation

@MisterTea

Copy link
Copy Markdown
Owner

Summary

  • etserver --disconnect-timeout MINUTES closes an etterminal session that stays disconnected longer than that. 0, the default, leaves the session up so reconnects still work.
  • The same value can be set as disconnect_timeout under [Networking] in et.cfg. The command-line flag wins when both are set.
  • etserver sends TERMINAL_CLOSE on the terminal socket and drops the session, which is the same path a client close already uses.

Test plan

  • disconnect deadline stays idle until the timeout elapses covers disabled, first observation, expiry, and reconnect reset
  • Disconnect timeout closes the terminal session uses a 1 second deadline and checks the terminal receives TERMINAL_CLOSE
  • Disconnected sessions retain their router until terminal EOF still passes with the default of no timeout
  • CI

Made with Cursor

jasongauci-webai and others added 2 commits September 22, 2026 21:45
Abandoned shells otherwise live until they exit on their own. etserver can now close one after a configured number of minutes, and the default remains no timeout.

Co-authored-by: Cursor <cursoragent@cursor.com>
ProxyJumpTest and RelativeIncludeTest both include the header, so non-inline definitions duplicated symbols when linking et-test on clang/lld and coverage builds.

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

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.35%. Comparing base (34b1948) to head (dcd9da4).

Files with missing lines Patch % Lines
src/terminal/TerminalServer.cpp 71.42% 3 Missing and 1 partial ⚠️
src/base/Connection.cpp 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #855      +/-   ##
==========================================
+ Coverage   79.28%   79.35%   +0.07%     
==========================================
  Files         125      125              
  Lines       13090    13168      +78     
  Branches     8441     8486      +45     
==========================================
+ Hits        10378    10450      +72     
- Misses       1613     1618       +5     
- Partials     1099     1100       +1     

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

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

🟡 Changes recommended

Timeout expiry can race with reconnection, and elapsed time uses a non-monotonic clock.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Adds configurable cleanup of disconnected terminal sessions while preserving indefinite reconnects by default.

Changes:

  • Adds CLI/config timeout settings and documentation.
  • Enforces session expiry and sends TERMINAL_CLOSE.
  • Adds lifecycle/deadline tests and resolves header linkage issues.
File Description
src/​terminal/​TerminalServerMain.cpp Parses and applies the timeout.
src/​terminal/​TerminalServer.hpp Defines timeout state and deadline logic.
src/​terminal/​TerminalServer.cpp Closes expired disconnected sessions.
test/​unit_tests/​TerminalServerLifecycleTest.cpp Tests expiry and session cleanup.
src/​terminal/​ParseConfigFile.hpp Marks header-defined functions inline.
etc/​et.cfg Documents the configuration option.
docs/​protocol.md Documents timeout behavior.

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

Comment thread src/terminal/TerminalServer.cpp Outdated
Comment on lines +526 to +527
if (disconnectDeadlineReached(&disconnectedSince, time(NULL),
stillConnected, disconnectTimeoutSec)) {
Comment thread src/terminal/TerminalServer.hpp Outdated
Comment on lines +97 to +98
inline bool disconnectDeadlineReached(time_t* disconnectedSince, time_t now,
bool connected, int timeoutSec) {
jasongauci-webai and others added 2 commits September 23, 2026 11:20
A reconnect that lands after a stale socket snapshot no longer loses the
session, and the deadline follows steady time instead of the wall clock.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@MisterTea
MisterTea merged commit bb4701d into master Sep 23, 2026
37 checks passed
@MisterTea
MisterTea deleted the feat/disconnect-timeout branch September 24, 2026 18:09
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