feat: add confirmation prompt before closing active session tabs (#793)

Shows a toast confirmation when closing terminal, RDP, VNC or telnet
tabs to prevent accidental session loss from misclicks.
This commit is contained in:
ZacharyZcR
2026-05-18 05:53:15 +08:00
committed by GitHub
parent 3d42642e94
commit 63c8d601b5
3 changed files with 28 additions and 1 deletions
+22 -1
View File
@@ -383,7 +383,9 @@ export function AppShell({
setActiveTabId(id);
}
function closeTab(id: string) {
const SESSION_TAB_TYPES: TabType[] = ["terminal", "rdp", "vnc", "telnet"];
function doCloseTab(id: string) {
terminalRefs.current.delete(id);
setTabs((prev) => {
const next = prev.filter((t) => t.id !== id);
@@ -392,6 +394,25 @@ export function AppShell({
});
}
function closeTab(id: string) {
const tab = tabs.find((t) => t.id === id);
if (tab && SESSION_TAB_TYPES.includes(tab.type)) {
toast(t("nav.confirmClose"), {
duration: 5000,
action: {
label: t("nav.close"),
onClick: () => doCloseTab(id),
},
cancel: {
label: t("nav.cancel"),
onClick: () => {},
},
});
return;
}
doCloseTab(id);
}
// ─── Rail / sidebar ──────────────────────────────────────────────────────
function handleRailClick(view: RailView) {
+3
View File
@@ -385,6 +385,9 @@
"newTab": "New Tab",
"splitScreen": "Split Screen",
"closeTab": "Close Tab",
"confirmClose": "Close this active session?",
"close": "Close",
"cancel": "Cancel",
"sshManager": "SSH Manager",
"hostManager": "Host Manager",
"cannotSplitTab": "Cannot split this tab",
+3
View File
@@ -555,6 +555,9 @@
"newTab": "新选项卡",
"splitScreen": "分屏",
"closeTab": "关闭选项卡",
"confirmClose": "确定关闭当前活跃会话?",
"close": "关闭",
"cancel": "取消",
"sshManager": "SSH 管理器",
"hostManager": "主机管理器",
"cannotSplitTab": "无法拆分此选项卡",