Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion server.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,15 @@ function startServer() {
}
}

sendPortUpdates();
async function init() {
if (process.env["XTERM_CONFIRM_BROWSER_EXIT"] === "true") {
ws.send(JSON.stringify({ action: "confirmExit" }));
}

sendPortUpdates();
}

init();
});

let clientForExternalMessages = null;
Expand Down
7 changes: 7 additions & 0 deletions src/lib/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ export const initiateRemoteCommunicationChannelSocket = async (protocol: string)
output(`Port ${port} has been opened`, { formActions: [openUrlButton], reason: "info" });
break;
}
case "confirmExit": {
// Ask for confirmation before closing the current terminal session
window.onbeforeunload = (e: BeforeUnloadEvent) => {
e.preventDefault();
e.returnValue = "Are you sure you want to close the terminal?";
};
}
default:
console.debug("Unhandled message", messageData);
}
Expand Down