Skip to content

Connect: Close terminal tab if last input was Ctrl+D, even on non-zero exit code#59836

Merged
ravicious merged 3 commits intomasterfrom
r7s/ctrl-d
Oct 14, 2025
Merged

Connect: Close terminal tab if last input was Ctrl+D, even on non-zero exit code#59836
ravicious merged 3 commits intomasterfrom
r7s/ctrl-d

Conversation

@ravicious
Copy link
Copy Markdown
Member

@ravicious ravicious commented Oct 1, 2025

Closes #57232.

This is based on how VSCode solves this issue (see #57232 (comment)). We store the last input and always close the tab if the last input was Ctrl+D, even if the exit code was non-zero.

I tried to fix it in the Web UI too, but I didn't have enough time to figure out how terminal sessions work there. Connect controls the PTY process directly, whereas the Web UI depends on a stream from the proxy service, so I couldn't quite find its onExit equivalent. There's TermEvent.CLOSE, but there's also TermEvent.CONN_CLOSE.

When backporting this PR to other branches, I'll not backport #59832, I'll just modify the protos under the old location.

changelog: Fixed an issue where Teleport Connect would not close a terminal tab when Ctrl+D was issued after a command with non-zero exit status

});
});

if (process.platform !== 'win32') {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Kinda cowboyish way to avoid running this test on Windows. cmd.exe doesn't have its Ctrl+D equivalent and even if sh.exe is installed, it doesn't seem to work the same way on Windows.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Kinda cowboyish way to avoid running this test on Windows

Yeah, looks like there's no cleaner way to skip a test conditionally.

@ravicious ravicious marked this pull request as ready for review October 7, 2025 12:49
@ravicious ravicious requested a review from avatus October 7, 2025 12:49
@github-actions github-actions bot requested a review from kimlisa October 7, 2025 12:50
@ravicious ravicious removed the request for review from kimlisa October 7, 2025 12:50
@ravicious ravicious changed the base branch from r7s/base/ctrl-d to master October 14, 2025 10:42
@ravicious ravicious enabled auto-merge October 14, 2025 10:42
@ravicious ravicious added this pull request to the merge queue Oct 14, 2025
Merged via the queue into master with commit 51a2d41 Oct 14, 2025
80 checks passed
@ravicious ravicious deleted the r7s/ctrl-d branch October 14, 2025 11:19
@backport-bot-workflows
Copy link
Copy Markdown
Contributor

@ravicious See the table below for backport results.

Branch Result
branch/v16 Failed
branch/v17 Failed
branch/v18 Failed

mmcallister pushed a commit that referenced this pull request Nov 6, 2025
…o exit code (#59836)

* Include the last input in the exit event

* Close terminal tab if last input was Ctrl+D

* Remove use of create functions
rhammonds-teleport pushed a commit that referenced this pull request Nov 6, 2025
…o exit code (#59836)

* Include the last input in the exit event

* Close terminal tab if last input was Ctrl+D

* Remove use of create functions
mmcallister pushed a commit that referenced this pull request Nov 19, 2025
…o exit code (#59836)

* Include the last input in the exit event

* Close terminal tab if last input was Ctrl+D

* Remove use of create functions
mmcallister pushed a commit that referenced this pull request Nov 20, 2025
…o exit code (#59836)

* Include the last input in the exit event

* Close terminal tab if last input was Ctrl+D

* Remove use of create functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Teleport Connect breaks if CTRL+D issued immediately after CTRL+C

3 participants