Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have window close upon disconnect #1156

Open
limetech opened this issue Jun 18, 2023 · 3 comments
Open

Have window close upon disconnect #1156

limetech opened this issue Jun 18, 2023 · 3 comments

Comments

@limetech
Copy link

Suppose a ttyd is started and executes the 'bash' command. When the user types 'exit' the connection closes and user is prompted to hit Enter to reconnect. Instead, when user types 'exit' the window should be closed - how to accomplish this?
thank you

@tsl0922
Copy link
Owner

tsl0922 commented Jun 19, 2023

It's not supported yet.

@limetech
Copy link
Author

limetech commented Jun 19, 2023

Ok thanks. What we do for now is apply this patch and then rebuild the 'html.h' file.

diff --git a/html/src/components/terminal/xterm/index.ts b/html/src/components/terminal/xterm/index.ts
index e6809e4..c7b377f 100644
--- a/html/src/components/terminal/xterm/index.ts
+++ b/html/src/components/terminal/xterm/index.ts
@@ -269,7 +269,9 @@ export class Xterm {
         this.dispose();

         // 1000: CLOSE_NORMAL
-        if (event.code !== 1000 && doReconnect) {
+        if (event.code === 1000 || event.code === 1006) {
+            window.close();
+        } else if (event.code !== 1000 && doReconnect) {
             overlayAddon.showOverlay('Reconnecting...');
             refreshToken().then(connect);
         } else {

This is from git checkout tags/1.7.3

btw: when we build 'ttyd' using latest code, the terminal does not accept any input, meaning anything you type just doesn't get sent.

@tsl0922
Copy link
Owner

tsl0922 commented Jun 22, 2023

btw: when we build 'ttyd' using latest code, the terminal does not accept any input, meaning anything you type just doesn't get sent.

Start ttyd with -W option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants