1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-01 16:36:06 +00:00

fix(console): a console the server closes says Connection lost, not Disconnected

The VNC and serial pages showed "Disconnected", as if the user had ended
the session, when the VM stopped, was migrated or the console daemon
restarted: noVNC calls a close by the server clean, and the serial page
had a single text. "Disconnected" is now kept for the user's own
Disconnect; any other end of a working connection is "Connection lost"
(the serial terminal still prints the server's reason).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-10 18:58:20 +03:00
parent 450ffbba30
commit 16ad625cda
3 changed files with 8 additions and 3 deletions

View file

@ -58,13 +58,14 @@ socket.on('connect', () => {
socket.on('taken_over', (data) => {
takenBy = data.by;
});
socket.on('disconnect', () => {
socket.on('disconnect', (reason) => {
if (takenBy) {
const text = status.dataset.takenOver.replace('%(name)s', takenBy);
term.write('\r\n[' + text + ']\r\n');
showStatus(text, 'danger');
} else {
showStatus(status.dataset.disconnected, 'danger');
// the user's Disconnect, or the server's end (the terminal says why) or a lost connection
showStatus(reason === 'io client disconnect' ? status.dataset.disconnected : status.dataset.lost, 'danger');
}
});
// the server says why: serial console off, an expired link, the console open elsewhere