Files
Termix/src/ui/desktop/DesktopApp.tsx
T
2768f11dfc v2.2.0 (#738)
* Improve Docker container list UI

* Rework SSH tunnel forwarding

* Update macOS Electron packaging

* Optimize frontend bundle splitting

* Add beta version update status

* Add client tunnel preset management

* Secure cookie authentication flows

* Add client tunnel bridge support

* Preserve sessions on restart

* Update runtime to Node 24

* Add client remote tunnel support

* Fix stale frontend cache handling

* Fix Docker image platforms for Node 24

* Fix Electron packaging workflows

* Fix client auth cache after upgrades

* chore: cleanup files

* fix: npm i error

* Fix OIDC auth cookie readiness

* Fix Docker npm ci config

* Add react-is peer dependency

* Fix Electron auth and cache handling

* Improve terminal clipboard and refresh actions

* feat: add API keys

* feat: improve lazy loading with loading spinners

* feat: Introduce FolderTree component with lazy-loading and motion animations for improved file manager UX (#735)

* feat: integrate FolderTree component with lazy-loading for file manager sidebar

- Add motion animation library (v12.38.0) for smooth UI transitions
- Create new FolderTree component with advanced keyboard navigation support
- Refactor kbd component: introduce KbdKey and KbdSeparator subcomponents
- Implement lazy-loading strategy for directory tree in FileManagerSidebar
- Refactor FileManagerSidebar with improved code organization and better separation of concerns
- Update keyboard shortcut displays across CommandPalette, FileViewer, and Dashboard
- Change React/ReactDOM dependency flags from dev to devOptional in package-lock.json

BREAKING CHANGE: KbdGroup component has been replaced. Use <Kbd><KbdKey>...</KbdKey><KbdSeparator /></Kbd> instead.

- Improves UX with smooth animations and better folder navigation
- Reduces initial load time through lazy-loading subdirectories
- Enhances accessibility with ARIA labels and keyboard navigation
- Maintains dark mode support and proper styling

* fix: incorrect use of the theme system and linked file manger sidebar with current folder

---------

Co-authored-by: suryacagur <suryacagur.dev@gmail.com>
Co-authored-by: LukeGus <bugattiguy527@gmail.com>
Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com>

* Enhance VNC token generation to include optional username parameter and refactor username input handling in HostGeneralTab (#733)

* Fix Docker build info generation

* Remove unused node-fetch dependency

* feat: prompt user for SSH key passphrase on use (#715)

When an encrypted SSH key has no stored passphrase, show a lightweight
dialog prompting the user to enter it at connection time instead of
failing with a parse error. Supports both desktop and mobile terminals.

Closes Termix-SSH/Support#354

* fix: prevent session crash when uploading to permission-denied directory (#716)

- Wrap writeFile sftp.stat callback in try-catch to prevent uncaught
  exceptions from escaping the callback into the event loop
- Add missing stream.stderr error handler in writeFile fallback to
  prevent unhandled error events from crashing the process
- Remove bogus activeOperations decrement in both writeFile and
  uploadFile fallback methods (counter was never incremented)
- Add res.headersSent checks in fallback disconnect paths to prevent
  ERR_HTTP_HEADERS_SENT crashes

Closes Termix-SSH/Support#652

* feat: add LOG_TIMESTAMP_FORMAT env var for 24h/ISO log timestamps (#718)

Support LOG_TIMESTAMP_FORMAT environment variable with values:
- "24h": 24-hour format (14:58:45)
- "iso": ISO 8601 format (2026-04-25T14:58:45.000Z)
- default: locale format (2:58:45 PM)

Closes Termix-SSH/Support#650

* feat: open file manager at terminal current working directory (#719)

* feat: open file manager at terminal current working directory

When right-clicking in the terminal and selecting "Open File Manager
Here", query the current working directory via a separate SSH exec
channel and pass it as the initial path to the file manager tab.

Closes Termix-SSH/Support#649

* chore: sync package-lock.json with node-fetch and deps

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: remove undefined TerminalContextMenu from bad merge resolution

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: LukeGus <bugattiguy527@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com>

* fix: show reconnect overlay when SSH server reboots (#720)

When the remote server reboots, the SSH connection closes while the
stream is still active. The close handler only sent the "disconnected"
message when sshStream was null, so the frontend never received the
disconnect notification and hung with a blinking cursor.

Change the else-if condition to always send the "disconnected" message
regardless of stream state.

Closes Termix-SSH/Support#648

* feat: support read-only Docker container mode (#721)

Move nginx runtime files (config, pid, logs, temp dirs) from /app/nginx/
to /tmp/nginx/ so the container can run with read_only: true. Template
files remain in /app/nginx/ as read-only assets.

Users can now harden the container with:
  read_only: true
  tmpfs:
    - /tmp

Closes Termix-SSH/Support#647

* fix: allow editing host folder without re-entering password (#722)

When editing an existing host, the password field is stripped by the
backend for security. The form validation treated the empty password
as invalid, disabling the Update Host button even for non-auth changes
like folder assignment.

Use an "existing_password" sentinel (mirroring the existing
"existing_key" pattern) to represent an unchanged password during
editing, skip validation for it, and omit it from the update payload.

Closes Termix-SSH/Support#645

* fix: auto-close tab on graceful SSH disconnect (exit/Ctrl+D) (#723)

Distinguish between graceful shell exit and unexpected disconnection
using the stream close event's exit code. When the shell exits normally
(code != null), send "session_ended" instead of "disconnected". The
frontend auto-closes the tab on session_ended, and shows the reconnect
overlay only on unexpected disconnections.

Closes Termix-SSH/Support#643

* fix: reattach existing SSH session on WebSocket reconnect (#724)

WebSocket reconnection was always creating a new SSH connection with
full authentication instead of reattaching to the existing SSH session.
The condition `!isReconnectingRef.current` prevented session reattach
during reconnection, causing repeated password auth attempts that
trigger SSHGuard/fail2ban blocking.

Remove the guard so reconnection tries to reattach the persisted
session first. If the session has expired, the backend sends
sessionExpired and the frontend falls back to a new connection.

Closes Termix-SSH/Support#644

* fix: prevent browser crash when uploading large files (>100MB) (#725)

The file-to-base64 conversion used a byte-by-byte string concatenation
loop (String.fromCharCode + btoa), which allocated ~3x the file size
in intermediate strings, causing the browser tab to OOM on files over
~100MB.

Replace with FileReader.readAsDataURL which delegates base64 encoding
to the browser engine natively, avoiding the intermediate allocations.

Closes Termix-SSH/Support#577

* fix: support SSH multi-factor auth with publickey + password (#726)

When sshd requires AuthenticationMethods publickey,password, the
connection failed because the key auth branch only set privateKey
without also setting password. After publickey partial auth succeeded,
ssh2 sent keyboard-interactive (due to tryKeyboard:true) instead of
password, which the server rejected.

Pass the credential password alongside the private key so ssh2 can
complete the password step after publickey succeeds.

Closes Termix-SSH/Support#629

* feat(oidc): add OIDC_ALLOW_REGISTRATION env to bypass allow_registration for OIDC (#727)

The `allow_registration` setting blocks both password-based and OIDC user
creation. Admins who want to close password registration but still onboard
new users via a trusted IdP (with the existing `OIDC_ALLOWED_USERS` whitelist)
have no way to do that today.

Introduce an `OIDC_ALLOW_REGISTRATION` env var. When set to `true`, the OIDC
callback skips the `allow_registration` settings check while still honoring
the `OIDC_ALLOWED_USERS` whitelist. Password registration via `POST
/users/create` continues to respect `allow_registration`.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* perf: lazy load locales, file previews, and decouple startup imports (#729)

* perf: lazy load locale bundles

* perf: lazy load file preview modules

* perf: avoid eager api client load on startup

* chore: remove dead code, tighten types, fix lint warnings (#730)

* chore: clean up low-risk lint warnings

* chore: tighten utility types

* chore: preserve backend error causes

* chore: simplify command palette host state

* chore: remove unused frontend code

* chore: prune stale frontend state

* chore: trim unused navigation code

* chore: prune unused user settings props

* chore: trim unused sidebar state

* chore: remove stale host editor imports

* chore: tighten shared frontend types

* chore: narrow desktop helper types

* chore: type network topology data

* chore: type connection log errors

* chore: use typed tab context

* chore: type api client error metadata

* chore: tighten terminal config types

* chore: type host proxy chains

* chore: type host editor form data

* chore: use typed host viewer fields

* chore: format app builder patch script

* Fix client auth cache after upgrades

* chore: fix pr checks after dev merge

* fix: remove duplicate session-expired useEffect in FullScreenAppWrapper

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Xenthys <x@dis.gg>
Co-authored-by: LukeGus <bugattiguy527@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: npm package warnings

* feat: reconnect after file manager disconnects

* feat: add docs button in api keys

* feat: change colors for server tunnels

* fix: fetch password from API for Copy Password button (#736)

* chore: update readme's

* feat: improve c2s UI in user profile

* feat: improve ssh key detection and move open file manager at path for terminal button

* fix: restore missing getHostPassword import in Tab.tsx (#737)

* fix: security related fixes

* feat: improve alert code

* Fix Electron clipboard handling

* fix: untranslated alert text

---------

Co-authored-by: Xenthys <x@dis.gg>
Co-authored-by: PT Kelana Tech Solutions <ptkelanatechsolutions@gmail.com>
Co-authored-by: suryacagur <suryacagur.dev@gmail.com>
Co-authored-by: zimmra <28514085+zimmra@users.noreply.github.com>
Co-authored-by: ZacharyZcR <zacharyzcr1984@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Fuad <funtik1229@yandex.ru>
2026-05-06 15:12:07 -05:00

811 lines
26 KiB
TypeScript

import React, {
useCallback,
Component,
Suspense,
lazy,
type ReactNode,
useEffect,
useRef,
useState,
} from "react";
import { LeftSidebar } from "@/ui/desktop/navigation/LeftSidebar.tsx";
import { AppView } from "@/ui/desktop/navigation/AppView.tsx";
import {
TabProvider,
useTabs,
} from "@/ui/desktop/navigation/tabs/TabContext.tsx";
import { TopNavbar } from "@/ui/desktop/navigation/TopNavbar.tsx";
import { CommandHistoryProvider } from "@/ui/desktop/apps/features/terminal/command-history/CommandHistoryContext.tsx";
import { ServerStatusProvider } from "@/ui/contexts/ServerStatusContext";
import { Toaster } from "@/components/ui/sonner.tsx";
import { toast } from "sonner";
import {
getUserInfo,
logoutUser,
isCurrentAuthInvalidationError,
} from "@/ui/main-axios.ts";
import { useTheme } from "@/components/theme-provider";
import { dbHealthMonitor } from "@/lib/db-health-monitor.ts";
import { useTranslation } from "react-i18next";
import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
const Dashboard = lazy(() =>
import("@/ui/desktop/apps/dashboard/Dashboard.tsx").then((module) => ({
default: module.Dashboard,
})),
);
const HostManager = lazy(() =>
import("@/ui/desktop/apps/host-manager/hosts/HostManager.tsx").then(
(module) => ({
default: module.HostManager,
}),
),
);
const AdminSettings = lazy(() =>
import("@/ui/desktop/apps/admin/AdminSettings.tsx").then((module) => ({
default: module.AdminSettings,
})),
);
const UserProfile = lazy(() =>
import("@/ui/desktop/user/UserProfile.tsx").then((module) => ({
default: module.UserProfile,
})),
);
const CommandPalette = lazy(() =>
import("@/ui/desktop/apps/command-palette/CommandPalette.tsx").then(
(module) => ({
default: module.CommandPalette,
}),
),
);
function AppContent({
onAuthStateChange,
}: {
onAuthStateChange?: (isAuthenticated: boolean) => void;
}) {
const { t } = useTranslation();
const [isAuthenticated, setIsAuthenticated] = useState(false);
const [username, setUsername] = useState<string | null>(null);
const [isAdmin, setIsAdmin] = useState(false);
const [authLoading, setAuthLoading] = useState(true);
const [isTopbarOpen, setIsTopbarOpen] = useState<boolean>(() => {
const saved = localStorage.getItem("topNavbarOpen");
return saved !== null ? JSON.parse(saved) : true;
});
const [isTransitioning, setIsTransitioning] = useState(false);
const [transitionPhase, setTransitionPhase] = useState<
"idle" | "fadeOut" | "fadeIn"
>("idle");
const { currentTab, tabs, updateTab, addTab } = useTabs();
const [isCommandPaletteOpen, setIsCommandPaletteOpen] = useState(false);
const { theme, setTheme } = useTheme();
const [rightSidebarOpen, setRightSidebarOpen] = useState(false);
const [rightSidebarWidth, setRightSidebarWidth] = useState(400);
const isAuthenticatedRef = useRef(false);
const isDarkMode =
theme === "dark" ||
theme === "dracula" ||
theme === "gentlemansChoice" ||
theme === "midnightEspresso" ||
theme === "catppuccinMocha" ||
(theme === "system" &&
window.matchMedia("(prefers-color-scheme: dark)").matches);
const lineColor = isDarkMode ? "#151517" : "#f9f9f9";
const lastShiftPressTime = useRef(0);
const lastAltPressTime = useRef(0);
useEffect(() => {
const DEGRADED_TOAST_ID = "db-connection-degraded";
const handleDatabaseConnectionDegraded = () => {
// Non-blocking, non-dismissible status toast that stays visible until
// connectivity is recovered. A Reload action lets users force-refresh
// the page if they want to, but the app itself remains fully usable.
toast.loading(
t("common.connectionDegraded", "Server connection lost, recovering…"),
{
id: DEGRADED_TOAST_ID,
duration: Infinity,
dismissible: false,
closeButton: false,
action: {
label: t("common.reload", "Reload"),
onClick: () => window.location.reload(),
},
},
);
};
const handleDatabaseConnectionDegradedCleared = () => {
toast.dismiss(DEGRADED_TOAST_ID);
toast.success(t("common.backendReconnected"));
};
const handleSessionExpired = () => {
setIsAuthenticated(false);
setIsAdmin(false);
setUsername(null);
};
dbHealthMonitor.on(
"database-connection-degraded",
handleDatabaseConnectionDegraded,
);
dbHealthMonitor.on(
"database-connection-degraded-cleared",
handleDatabaseConnectionDegradedCleared,
);
dbHealthMonitor.on("session-expired", handleSessionExpired);
return () => {
dbHealthMonitor.off(
"database-connection-degraded",
handleDatabaseConnectionDegraded,
);
dbHealthMonitor.off(
"database-connection-degraded-cleared",
handleDatabaseConnectionDegradedCleared,
);
dbHealthMonitor.off("session-expired", handleSessionExpired);
toast.dismiss(DEGRADED_TOAST_ID);
};
}, [t]);
useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
if (event.code === "ShiftLeft") {
if (event.repeat) {
return;
}
const shortcutEnabled =
localStorage.getItem("commandPaletteShortcutEnabled") !== "false";
if (!shortcutEnabled) {
return;
}
const now = Date.now();
if (now - lastShiftPressTime.current < 300) {
setIsCommandPaletteOpen((isOpen) => !isOpen);
lastShiftPressTime.current = 0;
} else {
lastShiftPressTime.current = now;
}
}
if (event.code === "AltLeft" && !event.repeat) {
const now = Date.now();
if (now - lastAltPressTime.current < 300) {
const currentIsDark =
theme === "dark" ||
(theme === "system" &&
window.matchMedia("(prefers-color-scheme: dark)").matches);
const newTheme = currentIsDark ? "light" : "dark";
setTheme(newTheme);
lastAltPressTime.current = 0;
} else {
lastAltPressTime.current = now;
}
}
if (event.key === "Escape") {
setIsCommandPaletteOpen(false);
}
};
window.addEventListener("keydown", handleKeyDown);
return () => {
window.removeEventListener("keydown", handleKeyDown);
};
}, [theme, setTheme]);
useEffect(() => {
const path = window.location.pathname;
const terminalMatch = path.match(/^\/terminal\/([a-zA-Z0-9_-]+)$/);
const legacyMatch = path.match(/^\/hosts\/([a-zA-Z0-9_-]+)\/terminal$/);
const hostIdentifier = terminalMatch?.[1] || legacyMatch?.[1];
if (hostIdentifier) {
const openTerminal = async () => {
try {
const { getSSHHostById, getSSHHosts } =
await import("@/ui/main-axios.ts");
let host = null;
if (/^\d+$/.test(hostIdentifier)) {
host = await getSSHHostById(parseInt(hostIdentifier, 10));
} else {
const hosts = await getSSHHosts();
host =
hosts.find((h: { name?: string }) => h.name === hostIdentifier) ||
null;
}
if (host) {
addTab({
type: "terminal",
title: host.name || host.ip,
data: { host, initialCommand: "" },
});
window.history.replaceState({}, "", "/");
} else {
toast.error(`Host "${hostIdentifier}" not found`);
}
} catch (error) {
console.error("Failed to open terminal:", error);
toast.error("Failed to open terminal for host");
}
};
openTerminal();
}
}, [addTab]);
const isCheckingAuth = useRef(false);
const clientTunnelAutoStartStarted = useRef(false);
const startClientTunnelAutoStart = useCallback(() => {
if (
clientTunnelAutoStartStarted.current ||
!window.electronAPI?.isElectron
) {
return;
}
clientTunnelAutoStartStarted.current = true;
window.electronAPI.startC2SAutoStartTunnels?.().catch((error) => {
clientTunnelAutoStartStarted.current = false;
console.error("Failed to start client tunnel auto-start entries:", error);
});
}, []);
useEffect(() => {
const checkAuth = () => {
if (isCheckingAuth.current) return;
isCheckingAuth.current = true;
setAuthLoading(true);
getUserInfo()
.then((meRes) => {
if (typeof meRes === "string" || !meRes.username) {
setIsAuthenticated(false);
setIsAdmin(false);
setUsername(null);
} else {
setIsAuthenticated(true);
setIsAdmin(!!meRes.is_admin);
setUsername(meRes.username || null);
startClientTunnelAutoStart();
}
})
.catch((err) => {
if (isCurrentAuthInvalidationError(err)) {
setIsAuthenticated(false);
setIsAdmin(false);
setUsername(null);
console.warn("Session expired - please log in again");
return;
}
if (!isAuthenticatedRef.current) {
setIsAuthenticated(false);
setIsAdmin(false);
setUsername(null);
}
})
.finally(() => {
setAuthLoading(false);
isCheckingAuth.current = false;
});
};
checkAuth();
const handleStorageChange = () => checkAuth();
window.addEventListener("storage", handleStorageChange);
return () => window.removeEventListener("storage", handleStorageChange);
}, [startClientTunnelAutoStart]);
useEffect(() => {
localStorage.setItem("topNavbarOpen", JSON.stringify(isTopbarOpen));
}, [isTopbarOpen]);
useEffect(() => {
onAuthStateChange?.(isAuthenticated);
isAuthenticatedRef.current = isAuthenticated;
}, [isAuthenticated, onAuthStateChange]);
const handleAuthSuccess = useCallback(
(authData: {
isAdmin: boolean;
username: string | null;
userId: string | null;
}) => {
setIsTransitioning(true);
setTransitionPhase("fadeOut");
setTimeout(() => {
setIsAuthenticated(true);
setIsAdmin(authData.isAdmin);
setUsername(authData.username);
startClientTunnelAutoStart();
setTransitionPhase("fadeIn");
setTimeout(() => {
setIsTransitioning(false);
setTransitionPhase("idle");
}, 800);
}, 1200);
},
[startClientTunnelAutoStart],
);
const handleLogout = useCallback(async () => {
setIsTransitioning(true);
setTransitionPhase("fadeOut");
setTimeout(async () => {
try {
await logoutUser();
} catch (error) {
console.error("Logout failed:", error);
}
window.location.reload();
}, 1200);
}, []);
const currentTabData = tabs.find((tab) => tab.id === currentTab);
const showTerminalView =
currentTabData?.type === "terminal" ||
currentTabData?.type === "server_stats" ||
currentTabData?.type === "file_manager" ||
currentTabData?.type === "rdp" ||
currentTabData?.type === "vnc" ||
currentTabData?.type === "telnet" ||
currentTabData?.type === "tunnel" ||
currentTabData?.type === "docker" ||
currentTabData?.type === "network_graph";
const showHome = currentTabData?.type === "home";
const showSshManager = currentTabData?.type === "ssh_manager";
const showAdmin = currentTabData?.type === "admin";
const showProfile = currentTabData?.type === "user_profile";
if (authLoading) {
return (
<div
className="fixed inset-0 flex items-center justify-center"
style={{
background: "var(--bg-elevated)",
backgroundImage: `repeating-linear-gradient(
45deg,
transparent,
transparent 35px,
${lineColor} 35px,
${lineColor} 37px
)`,
}}
>
<div className="w-[420px] max-w-full p-8 flex flex-col backdrop-blur-sm bg-card/50 rounded-2xl shadow-xl border-2 border-edge overflow-y-auto thin-scrollbar my-2 animate-in fade-in zoom-in-95 duration-300">
<div className="flex items-center justify-center h-32">
<div className="text-center">
<div className="w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin mx-auto mb-4" />
<p className="text-muted-foreground">
{t("common.checkingAuthentication")}
</p>
</div>
</div>
</div>
</div>
);
}
return (
<div className="h-screen w-screen overflow-hidden bg-background">
<Suspense fallback={null}>
<CommandPalette
isOpen={isCommandPaletteOpen}
setIsOpen={setIsCommandPaletteOpen}
/>
</Suspense>
{!isAuthenticated && (
<div className="fixed inset-0 flex items-center justify-center z-[10000] bg-background">
<Suspense fallback={null}>
<Dashboard
isAuthenticated={isAuthenticated}
authLoading={authLoading}
onAuthSuccess={handleAuthSuccess}
isTopbarOpen={isTopbarOpen}
/>
</Suspense>
</div>
)}
{isAuthenticated && (
<LeftSidebar
disabled={!isAuthenticated || authLoading}
isAdmin={isAdmin}
username={username}
onLogout={handleLogout}
>
<div
className="h-screen w-full visible pointer-events-auto static overflow-hidden"
style={{ display: showTerminalView ? "block" : "none" }}
>
<AppView
isTopbarOpen={isTopbarOpen}
rightSidebarOpen={rightSidebarOpen}
rightSidebarWidth={rightSidebarWidth}
/>
</div>
{showHome && (
<div className="h-screen w-full visible pointer-events-auto static overflow-hidden">
<Suspense
fallback={
<div
className="bg-canvas rounded-lg border-2 border-edge relative"
style={{
margin: "74px 17px 8px 8px",
height: "calc(100vh - 82px)",
}}
>
<SimpleLoader
visible={true}
message={t("common.loading")}
/>
</div>
}
>
<Dashboard
isAuthenticated={isAuthenticated}
authLoading={authLoading}
onAuthSuccess={handleAuthSuccess}
isTopbarOpen={isTopbarOpen}
rightSidebarOpen={rightSidebarOpen}
rightSidebarWidth={rightSidebarWidth}
/>
</Suspense>
</div>
)}
{showSshManager && (
<div className="h-screen w-full visible pointer-events-auto static overflow-hidden">
<Suspense
fallback={
<div
className="bg-canvas rounded-lg border-2 border-edge relative"
style={{
margin: "74px 17px 8px 8px",
height: "calc(100vh - 82px)",
}}
>
<SimpleLoader
visible={true}
message={t("common.loading")}
/>
</div>
}
>
<HostManager
isTopbarOpen={isTopbarOpen}
initialTab={currentTabData?.initialTab}
hostConfig={currentTabData?.hostConfig}
_updateTimestamp={currentTabData?._updateTimestamp}
rightSidebarOpen={rightSidebarOpen}
rightSidebarWidth={rightSidebarWidth}
currentTabId={currentTab}
updateTab={updateTab}
/>
</Suspense>
</div>
)}
{showAdmin && (
<div className="h-screen w-full visible pointer-events-auto static overflow-hidden">
<Suspense
fallback={
<div
className="bg-canvas rounded-lg border-2 border-edge relative"
style={{
margin: "74px 17px 8px 8px",
height: "calc(100vh - 82px)",
}}
>
<SimpleLoader
visible={true}
message={t("common.loading")}
/>
</div>
}
>
<AdminSettings
isTopbarOpen={isTopbarOpen}
rightSidebarOpen={rightSidebarOpen}
rightSidebarWidth={rightSidebarWidth}
/>
</Suspense>
</div>
)}
{showProfile && (
<div className="h-screen w-full visible pointer-events-auto static overflow-auto thin-scrollbar">
<Suspense
fallback={
<div
className="bg-canvas rounded-lg border-2 border-edge relative"
style={{
margin: "74px 17px 8px 8px",
height: "calc(100vh - 82px)",
}}
>
<SimpleLoader
visible={true}
message={t("common.loading")}
/>
</div>
}
>
<UserProfile
isTopbarOpen={isTopbarOpen}
rightSidebarOpen={rightSidebarOpen}
rightSidebarWidth={rightSidebarWidth}
initialTab={currentTabData?.initialTab}
/>
</Suspense>
</div>
)}
<TopNavbar
isTopbarOpen={isTopbarOpen}
setIsTopbarOpen={setIsTopbarOpen}
onRightSidebarStateChange={(isOpen, width) => {
setRightSidebarOpen(isOpen);
setRightSidebarWidth(width);
}}
/>
</LeftSidebar>
)}
{isTransitioning && (
<div
className={`fixed inset-0 z-[20000] transition-opacity duration-700 ${
transitionPhase === "fadeOut" ? "opacity-100" : "opacity-0"
}`}
style={{
background: "var(--bg-elevated)",
backgroundImage: `repeating-linear-gradient(
45deg,
transparent,
transparent 35px,
${lineColor} 35px,
${lineColor} 37px
)`,
}}
>
{transitionPhase === "fadeOut" && (
<>
<div className="absolute inset-0 flex items-center justify-center overflow-hidden">
<div
className="absolute w-0 h-0 bg-primary/10 rounded-full"
style={{
animation:
"ripple 2.5s cubic-bezier(0.4, 0, 0.2, 1) forwards",
animationDelay: "0ms",
willChange: "width, height, opacity",
transform: "translateZ(0)",
}}
/>
<div
className="absolute w-0 h-0 bg-primary/7 rounded-full"
style={{
animation:
"ripple 2.5s cubic-bezier(0.4, 0, 0.2, 1) forwards",
animationDelay: "200ms",
willChange: "width, height, opacity",
transform: "translateZ(0)",
}}
/>
<div
className="absolute w-0 h-0 bg-primary/5 rounded-full"
style={{
animation:
"ripple 2.5s cubic-bezier(0.4, 0, 0.2, 1) forwards",
animationDelay: "400ms",
willChange: "width, height, opacity",
transform: "translateZ(0)",
}}
/>
<div
className="absolute w-0 h-0 bg-primary/3 rounded-full"
style={{
animation:
"ripple 2.5s cubic-bezier(0.4, 0, 0.2, 1) forwards",
animationDelay: "600ms",
willChange: "width, height, opacity",
transform: "translateZ(0)",
}}
/>
<div
className="relative z-10 text-center"
style={{
animation:
"logoFade 1.6s cubic-bezier(0.4, 0, 0.2, 1) forwards",
willChange: "opacity, transform",
}}
>
<div
className="text-7xl font-bold tracking-wider"
style={{
fontFamily:
"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
animation:
"logoGlow 1.6s cubic-bezier(0.4, 0, 0.2, 1) forwards",
willChange: "color, text-shadow",
}}
>
TERMIX
</div>
<div
className="text-sm text-muted-foreground mt-3 tracking-widest"
style={{
animation:
"subtitleFade 1.6s cubic-bezier(0.4, 0, 0.2, 1) forwards",
willChange: "opacity, transform",
}}
>
SSH SERVER MANAGER
</div>
</div>
</div>
<style>{`
@keyframes ripple {
0% {
width: 0;
height: 0;
opacity: 1;
}
30% {
opacity: 0.6;
}
70% {
opacity: 0.3;
}
100% {
width: 200vmax;
height: 200vmax;
opacity: 0;
}
}
@keyframes logoFade {
0% {
opacity: 0;
transform: scale(0.85) translateZ(0);
}
25% {
opacity: 1;
transform: scale(1) translateZ(0);
}
75% {
opacity: 1;
transform: scale(1) translateZ(0);
}
100% {
opacity: 0;
transform: scale(1.05) translateZ(0);
}
}
@keyframes logoGlow {
0% {
color: hsl(var(--primary));
text-shadow: none;
}
25% {
color: hsl(var(--primary));
text-shadow:
0 0 20px hsla(var(--primary), 0.3),
0 0 40px hsla(var(--primary), 0.2),
0 0 60px hsla(var(--primary), 0.1);
}
75% {
color: hsl(var(--primary));
text-shadow:
0 0 20px hsla(var(--primary), 0.3),
0 0 40px hsla(var(--primary), 0.2),
0 0 60px hsla(var(--primary), 0.1);
}
100% {
color: hsl(var(--primary));
text-shadow: none;
}
}
@keyframes subtitleFade {
0%, 30% {
opacity: 0;
transform: translateY(10px) translateZ(0);
}
50% {
opacity: 1;
transform: translateY(0) translateZ(0);
}
75% {
opacity: 1;
transform: translateY(0) translateZ(0);
}
100% {
opacity: 0;
transform: translateY(-5px) translateZ(0);
}
}
`}</style>
</>
)}
</div>
)}
<Toaster
position="bottom-right"
richColors={false}
closeButton
duration={5000}
offset={20}
/>
</div>
);
}
class TabErrorBoundary extends Component<
{ children: ReactNode },
{ hasError: boolean; errorCount: number }
> {
constructor(props: { children: ReactNode }) {
super(props);
this.state = { hasError: false, errorCount: 0 };
}
static getDerivedStateFromError(error: Error) {
if (error.message?.includes("useTabs must be used within a TabProvider")) {
return { hasError: true };
}
throw error;
}
componentDidCatch(error: Error, _errorInfo: ErrorInfo) {
if (error.message?.includes("useTabs must be used within a TabProvider")) {
console.warn(
"TabProvider mounting race condition detected, recovering...",
);
this.setState((prev) => ({ errorCount: prev.errorCount + 1 }));
setTimeout(() => {
this.setState({ hasError: false });
}, 0);
}
}
render() {
if (this.state.hasError) {
return null;
}
return this.props.children;
}
}
function DesktopApp() {
const [isAuthenticated, setIsAuthenticated] = useState(false);
return (
<TabProvider>
<TabErrorBoundary>
<ServerStatusProvider isAuthenticated={isAuthenticated}>
<CommandHistoryProvider>
<AppContent onAuthStateChange={setIsAuthenticated} />
</CommandHistoryProvider>
</ServerStatusProvider>
</TabErrorBoundary>
</TabProvider>
);
}
export default DesktopApp;