feat: close disconnected etterminal sessions after a timeout - #855
Merged
Merged
Conversation
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
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 on lines
+526
to
+527
| if (disconnectDeadlineReached(&disconnectedSince, time(NULL), | ||
| stillConnected, disconnectTimeoutSec)) { |
Comment on lines
+97
to
+98
| inline bool disconnectDeadlineReached(time_t* disconnectedSince, time_t now, | ||
| bool connected, int timeoutSec) { |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
etserver --disconnect-timeout MINUTEScloses anetterminalsession that stays disconnected longer than that.0, the default, leaves the session up so reconnects still work.disconnect_timeoutunder[Networking]inet.cfg. The command-line flag wins when both are set.TERMINAL_CLOSEon 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 elapsescovers disabled, first observation, expiry, and reconnect resetDisconnect timeout closes the terminal sessionuses a 1 second deadline and checks the terminal receivesTERMINAL_CLOSEDisconnected sessions retain their router until terminal EOFstill passes with the default of no timeoutMade with Cursor