public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2] fix #6223: fit terminal after 'OK' message
Date: Mon,  7 Apr 2025 10:25:09 +0200	[thread overview]
Message-ID: <20250407082509.1990672-1-d.csapak@proxmox.com> (raw)

instead of simply waiting 250ms after we send the credentials, wait
until after the server responded with 'OK' to fit the terminal size.

Execute after the next frame, by using requestAnimationFrame twice. (One
for the current frame and one for the next), to show terminal content as
soon as possible.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
changes from v1:
* use requestAnimationFrame instead of setTimeout with arbitrary delay

 xterm.js/src/main.js | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/xterm.js/src/main.js b/xterm.js/src/main.js
index 289032c..902a1c3 100644
--- a/xterm.js/src/main.js
+++ b/xterm.js/src/main.js
@@ -222,6 +222,12 @@ function runTerminal() {
 	    if (answer[0] === 79 && answer[1] === 75) { // "OK"
 		updateState(states.connected);
 		term.write(answer.slice(2));
+
+		// delay initial focus and resize to after next frame
+		requestAnimationFrame(() => requestAnimationFrame(() => {
+		    term.focus();
+		    fitAddon.fit();
+		}));
 	    } else {
 		socket.close();
 	    }
@@ -247,12 +253,6 @@ function runTerminal() {
     });
 
     socket.send(PVE.UserName + ':' + ticket + "\n");
-
-    // initial focus and resize
-    setTimeout(function() {
-	term.focus();
-	fitAddon.fit();
-    }, 250);
 }
 
 function getLxcStatus(callback) {
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


             reply	other threads:[~2025-04-07  8:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-07  8:25 Dominik Csapak [this message]
2025-04-07 10:31 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250407082509.1990672-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal