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
23 changes: 22 additions & 1 deletion src/ui/AppShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
}
return root;
}
export { tabIcon, renderTabContent } from "@/shell/tabUtils";

Check warning on line 112 in src/ui/AppShell.tsx

View workflow job for this annotation

GitHub Actions / lint-and-build

Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components

Check warning on line 112 in src/ui/AppShell.tsx

View workflow job for this annotation

GitHub Actions / lint-and-build

Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components
import { renderTabContent } from "@/shell/tabUtils";

const DASHBOARD_TAB: Tab = {
Expand Down Expand Up @@ -221,7 +221,7 @@
cancelAnimationFrame(outerRafId);
cancelAnimationFrame(innerRafId);
};
}, [activeTabId]);

Check warning on line 224 in src/ui/AppShell.tsx

View workflow job for this annotation

GitHub Actions / lint-and-build

React Hook useEffect has a missing dependency: 'tabs'. Either include it or remove the dependency array

useEffect(() => {
const handleDegraded = () => {
Expand Down Expand Up @@ -292,7 +292,7 @@
};
window.addEventListener("termix:open-tab", handle);
return () => window.removeEventListener("termix:open-tab", handle);
}, [tabs, allHosts]);

Check warning on line 295 in src/ui/AppShell.tsx

View workflow job for this annotation

GitHub Actions / lint-and-build

React Hook useEffect has a missing dependency: 'connectHost'. Either include it or remove the dependency array

// ─── Tab management ──────────────────────────────────────────────────────

Expand Down Expand Up @@ -383,7 +383,9 @@
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);
Expand All @@ -392,6 +394,25 @@
});
}

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) {
Expand Down Expand Up @@ -432,7 +453,7 @@
[sidebarWidth],
);

const activeTab = tabs.find((t) => t.id === activeTabId)!;

Check warning on line 456 in src/ui/AppShell.tsx

View workflow job for this annotation

GitHub Actions / lint-and-build

'activeTab' is assigned a value but never used. Allowed unused vars must match /^_/u
const isSplit = splitMode !== "none";
const terminalTabs = tabs.filter((t) => t.type === "terminal");

Expand Down
3 changes: 3 additions & 0 deletions src/ui/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions src/ui/locales/translated/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,9 @@
"newTab": "新选项卡",
"splitScreen": "分屏",
"closeTab": "关闭选项卡",
"confirmClose": "确定关闭当前活跃会话?",
"close": "关闭",
"cancel": "取消",
"sshManager": "SSH 管理器",
"hostManager": "主机管理器",
"cannotSplitTab": "无法拆分此选项卡",
Expand Down
Loading