Skip to content

Self-hosted, plugin-based server management.

feat: initial ui redesign from demo

LukeGus33dcde08270e
diff --git a/components.json b/components.json
index 8bfc737f9..26b31d574 100644
--- a/components.json
+++ b/components.json
@@ -1,15 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
- "style": "new-york",
+ "style": "radix-lyra",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "",
"css": "src/index.css",
- "baseColor": "zinc",
+ "baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
+ "iconLibrary": "lucide",
+ "rtl": false,
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
@@ -17,5 +19,7 @@
"lib": "@/lib",
"hooks": "@/hooks"
},
- "iconLibrary": "lucide"
+ "menuColor": "default",
+ "menuAccent": "subtle",
+ "registries": {}
}
diff --git a/docker/compose.dev.yml b/docker/compose-dev.yml
similarity index 100%
rename from docker/compose.dev.yml
rename to docker/compose-dev.yml
diff --git a/package-lock.json b/package-lock.json
index 87c0a9612..a2021ba06 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -48,6 +48,7 @@
"@electron/notarize": "^3.1.1",
"@electron/rebuild": "^4.0.4",
"@eslint/js": "^9.0.0",
+ "@fontsource-variable/jetbrains-mono": "^5.2.8",
"@hookform/resolvers": "^5.2.2",
"@monaco-editor/react": "^4.7.0",
"@radix-ui/react-accordion": "^1.2.12",
@@ -111,6 +112,7 @@
"lucide-react": "^1.11.0",
"next-themes": "^0.4.6",
"prettier": "3.8.3",
+ "radix-ui": "^1.4.3",
"react": "^19.2.5",
"react-cytoscapejs": "^2.0.0",
"react-dom": "^19.2.5",
@@ -128,12 +130,16 @@
"react-xtermjs": "^1.0.10",
"recharts": "^3.8.1",
"remark-gfm": "^4.0.1",
+ "shadcn": "^4.7.0",
+ "sharp": "^0.34.5",
"sonner": "^2.0.7",
"tailwind-merge": "^3.5.0",
"tailwindcss": "^4.2.4",
+ "tw-animate-css": "^1.4.0",
"typescript": "~6.0.3",
"typescript-eslint": "^8.59.0",
"vite": "^8.0.10",
+ "vite-plugin-svgr": "^5.2.0",
"zod": "^4.3.6"
},
"engines": {
@@ -276,6 +282,19 @@
"node": ">=6.9.0"
}
},
+ "node_modules/@babel/helper-annotate-as-pure": {
+ "version": "7.27.3",
+ "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.27.3.tgz",
+ "integrity": "sha512-fXSwMQqitTGeHLBC08Eq5yXz2m37E4pJX1qAU1+2cNedz/ifv/bVXft90VeSav5nFO61EcNgwr0aJxbyPaWBPg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/types": "^7.27.3"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
"node_modules/@babel/helper-compilation-targets": {
"version": "7.28.6",
"resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.28.6.tgz",
@@ -303,6 +322,38 @@
"semver": "bin/semver.js"
}
},
+ "node_modules/@babel/helper-create-class-features-plugin": {
+ "version": "7.29.3",
+ "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.29.3.tgz",
+ "integrity": "sha512-RpLYy2sb51oNLjuu1iD3bwBqCBWUzjO0ocp+iaCP/lJtb2CPLcnC2Fftw+4sAzaMELGeWTgExSKADbdo0GFVzA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/helper-annotate-as-pure": "^7.27.3",
+ "@babel/helper-member-expression-to-functions": "^7.28.5",
+ "@babel/helper-optimise-call-expression": "^7.27.1",
+ "@babel/helper-replace-supers": "^7.28.6",
+ "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1",
+ "@babel/traverse": "^7.29.0",
+ "semver": "^6.3.1"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0"
+ }
+ },
+ "node_modules/@babel/helper-create-class-features-plugin/node_modules/semver": {
+ "version": "6.3.1",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
+ "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
+ "dev": true,
+ "license": "ISC",
+ "bin": {
+ "semver": "bin/semver.js"
+ }
+ },
"node_modules/@babel/helper-globals": {
"version": "7.28.0",
"resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.28.0.tgz",
@@ -313,6 +364,20 @@
"node": ">=6.9.0"
}
},
+ "node_modules/@babel/helper-member-expression-to-functions": {
+ "version": "7.28.5",
+ "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.28.5.tgz",
+ "integrity": "sha512-cwM7SBRZcPCLgl8a7cY0soT1SptSzAlMH39vwiRpOQkJlh53r5hdHwLSCZpQdVLT39sZt+CRpNwYG4Y2v77atg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/traverse": "^7.28.5",
+ "@babel/types": "^7.28.5"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
"node_modules/@babel/helper-module-imports": {
"version": "7.28.6",
"resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.28.6.tgz",
@@ -345,6 +410,61 @@
"@babel/core": "^7.0.0"
}
},
+ "node_modules/@babel/helper-optimise-call-expression": {
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.27.1.tgz",
+ "integrity": "sha512-URMGH08NzYFhubNSGJrpUEphGKQwMQYBySzat5cAByY1/YgIRkULnIy3tAMeszlL/so2HbeilYloUmSpd7GdVw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/types": "^7.27.1"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
+ "node_modules/@babel/helper-plugin-utils": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.28.6.tgz",
+ "integrity": "sha512-S9gzZ/bz83GRysI7gAD4wPT/AI3uCnY+9xn+Mx/KPs2JwHJIz1W8PZkg2cqyt3RNOBM8ejcXhV6y8Og7ly/Dug==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
+ "node_modules/@babel/helper-replace-supers": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.28.6.tgz",
+ "integrity": "sha512-mq8e+laIk94/yFec3DxSjCRD2Z0TAjhVbEJY3UQrlwVo15Lmt7C2wAUbK4bjnTs4APkwsYLTahXRraQXhb1WCg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/helper-member-expression-to-functions": "^7.28.5",
+ "@babel/helper-optimise-call-expression": "^7.27.1",
+ "@babel/traverse": "^7.28.6"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0"
+ }
+ },
+ "node_modules/@babel/helper-skip-transparent-expression-wrappers": {
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.27.1.tgz",
+ "integrity": "sha512-Tub4ZKEXqbPjXgWLl2+3JpQAYBJ8+ikpQ2Ocj/q/r0LwE3UhENh7EUabyHjz2kCEsrRY83ew2DQdHluuiDQFzg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/traverse": "^7.27.1",
+ "@babel/types": "^7.27.1"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
"node_modules/@babel/helper-string-parser": {
"version": "7.27.1",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz",
@@ -405,6 +525,95 @@
"node": ">=6.0.0"
}
},
+ "node_modules/@babel/plugin-syntax-jsx": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.28.6.tgz",
+ "integrity": "sha512-wgEmr06G6sIpqr8YDwA2dSRTE3bJ+V0IfpzfSY3Lfgd7YWOaAdlykvJi13ZKBt8cZHfgH1IXN+CL656W3uUa4w==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/helper-plugin-utils": "^7.28.6"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
+ "node_modules/@babel/plugin-syntax-typescript": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.28.6.tgz",
+ "integrity": "sha512-+nDNmQye7nlnuuHDboPbGm00Vqg3oO8niRRL27/4LYHUsHYh0zJ1xWOz0uRwNFmM1Avzk8wZbc6rdiYhomzv/A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/helper-plugin-utils": "^7.28.6"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
+ "node_modules/@babel/plugin-transform-modules-commonjs": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.28.6.tgz",
+ "integrity": "sha512-jppVbf8IV9iWWwWTQIxJMAJCWBuuKx71475wHwYytrRGQ2CWiDvYlADQno3tcYpS/T2UUWFQp3nVtYfK/YBQrA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/helper-module-transforms": "^7.28.6",
+ "@babel/helper-plugin-utils": "^7.28.6"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
+ "node_modules/@babel/plugin-transform-typescript": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.28.6.tgz",
+ "integrity": "sha512-0YWL2RFxOqEm9Efk5PvreamxPME8OyY0wM5wh5lHjF+VtVhdneCWGzZeSqzOfiobVqQaNCd2z0tQvnI9DaPWPw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/helper-annotate-as-pure": "^7.27.3",
+ "@babel/helper-create-class-features-plugin": "^7.28.6",
+ "@babel/helper-plugin-utils": "^7.28.6",
+ "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1",
+ "@babel/plugin-syntax-typescript": "^7.28.6"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
+ "node_modules/@babel/preset-typescript": {
+ "version": "7.28.5",
+ "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.28.5.tgz",
+ "integrity": "sha512-+bQy5WOI2V6LJZpPVxY+yp66XdZ2yifu0Mc1aP5CQKgjn4QM5IN2i5fAZ4xKop47pr8rpVhiAeu+nDQa12C8+g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/helper-plugin-utils": "^7.27.1",
+ "@babel/helper-validator-option": "^7.27.1",
+ "@babel/plugin-syntax-jsx": "^7.27.1",
+ "@babel/plugin-transform-modules-commonjs": "^7.27.1",
+ "@babel/plugin-transform-typescript": "^7.28.5"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
"node_modules/@babel/runtime": {
"version": "7.29.2",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.2.tgz",
@@ -1225,6 +1434,188 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@dotenvx/dotenvx": {
+ "version": "1.65.0",
+ "resolved": "https://registry.npmjs.org/@dotenvx/dotenvx/-/dotenvx-1.65.0.tgz",
+ "integrity": "sha512-v4FA/Lw3pTEloLxBqTOaYDX6MNo0Jo7lGBsPZhwnJBqRJp0AzQg1ZZNxrFsh6HVC6QWeWrfIKLn0y2eyIXaVDg==",
+ "dev": true,
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "commander": "^11.1.0",
+ "dotenv": "^17.2.1",
+ "eciesjs": "^0.4.10",
+ "execa": "^5.1.1",
+ "fdir": "^6.2.0",
+ "ignore": "^5.3.0",
+ "object-treeify": "1.1.33",
+ "picomatch": "^4.0.4",
+ "which": "^4.0.0",
+ "yocto-spinner": "^1.1.0"
+ },
+ "bin": {
+ "dotenvx": "src/cli/dotenvx.js"
+ },
+ "funding": {
+ "url": "https://dotenvx.com"
+ }
+ },
+ "node_modules/@dotenvx/dotenvx/node_modules/commander": {
+ "version": "11.1.0",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
+ "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=16"
+ }
+ },
+ "node_modules/@dotenvx/dotenvx/node_modules/execa": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz",
+ "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "cross-spawn": "^7.0.3",
+ "get-stream": "^6.0.0",
+ "human-signals": "^2.1.0",
+ "is-stream": "^2.0.0",
+ "merge-stream": "^2.0.0",
+ "npm-run-path": "^4.0.1",
+ "onetime": "^5.1.2",
+ "signal-exit": "^3.0.3",
+ "strip-final-newline": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sindresorhus/execa?sponsor=1"
+ }
+ },
+ "node_modules/@dotenvx/dotenvx/node_modules/get-stream": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
+ "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/@dotenvx/dotenvx/node_modules/human-signals": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz",
+ "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=10.17.0"
+ }
+ },
+ "node_modules/@dotenvx/dotenvx/node_modules/is-stream": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz",
+ "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/@dotenvx/dotenvx/node_modules/isexe": {
+ "version": "3.1.5",
+ "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.5.tgz",
+ "integrity": "sha512-6B3tLtFqtQS4ekarvLVMZ+X+VlvQekbe4taUkf/rhVO3d/h0M2rfARm/pXLcPEsjjMsFgrFgSrhQIxcSVrBz8w==",
+ "dev": true,
+ "license": "BlueOak-1.0.0",
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@dotenvx/dotenvx/node_modules/npm-run-path": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz",
+ "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "path-key": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/@dotenvx/dotenvx/node_modules/onetime": {
+ "version": "5.1.2",
+ "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz",
+ "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "mimic-fn": "^2.1.0"
+ },
+ "engines": {
+ "node": ">=6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/@dotenvx/dotenvx/node_modules/signal-exit": {
+ "version": "3.0.7",
+ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
+ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==",
+ "dev": true,
+ "license": "ISC"
+ },
+ "node_modules/@dotenvx/dotenvx/node_modules/strip-final-newline": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz",
+ "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/@dotenvx/dotenvx/node_modules/which": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz",
+ "integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "isexe": "^3.1.1"
+ },
+ "bin": {
+ "node-which": "bin/which.js"
+ },
+ "engines": {
+ "node": "^16.13.0 || >=18.0.0"
+ }
+ },
+ "node_modules/@ecies/ciphers": {
+ "version": "0.2.6",
+ "resolved": "https://registry.npmjs.org/@ecies/ciphers/-/ciphers-0.2.6.tgz",
+ "integrity": "sha512-patgsRPKGkhhoBjETV4XxD0En4ui5fbX0hzayqI3M8tvNMGUoUvmyYAIWwlxBc1KX5cturfqByYdj5bYGRpN9g==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "bun": ">=1",
+ "deno": ">=2.7.10",
+ "node": ">=16"
+ },
+ "peerDependencies": {
+ "@noble/ciphers": "^1.0.0"
+ }
+ },
"node_modules/@electron/asar": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@electron/asar/-/asar-4.2.0.tgz",
@@ -1835,107 +2226,755 @@
"dev": true,
"license": "MIT"
},
- "node_modules/@hookform/resolvers": {
- "version": "5.2.2",
- "resolved": "https://registry.npmjs.org/@hookform/resolvers/-/resolvers-5.2.2.tgz",
- "integrity": "sha512-A/IxlMLShx3KjV/HeTcTfaMxdwy690+L/ZADoeaTltLx+CVuzkeVIPuybK3jrRfw7YZnmdKsVVHAlEPIAEUNlA==",
+ "node_modules/@fontsource-variable/jetbrains-mono": {
+ "version": "5.2.8",
+ "resolved": "https://registry.npmjs.org/@fontsource-variable/jetbrains-mono/-/jetbrains-mono-5.2.8.tgz",
+ "integrity": "sha512-WBA9elru6Jdp5df2mES55wuOO0WIrn3kpXnI4+W2ek5u3ZgLS9XS4gmIlcQhiZOWEKl95meYdvK7xI+ETLCq/Q==",
+ "dev": true,
+ "license": "OFL-1.1",
+ "funding": {
+ "url": "https://github.com/sponsors/ayuhito"
+ }
+ },
+ "node_modules/@hono/node-server": {
+ "version": "1.19.14",
+ "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.19.14.tgz",
+ "integrity": "sha512-GwtvgtXxnWsucXvbQXkRgqksiH2Qed37H9xHZocE5sA3N8O8O8/8FA3uclQXxXVzc9XBZuEOMK7+r02FmSpHtw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18.14.1"
+ },
+ "peerDependencies": {
+ "hono": "^4"
+ }
+ },
+ "node_modules/@hookform/resolvers": {
+ "version": "5.2.2",
+ "resolved": "https://registry.npmjs.org/@hookform/resolvers/-/resolvers-5.2.2.tgz",
+ "integrity": "sha512-A/IxlMLShx3KjV/HeTcTfaMxdwy690+L/ZADoeaTltLx+CVuzkeVIPuybK3jrRfw7YZnmdKsVVHAlEPIAEUNlA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@standard-schema/utils": "^0.3.0"
},
- "peerDependencies": {
- "react-hook-form": "^7.55.0"
+ "peerDependencies": {
+ "react-hook-form": "^7.55.0"
+ }
+ },
+ "node_modules/@humanfs/core": {
+ "version": "0.19.2",
+ "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz",
+ "integrity": "sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@humanfs/types": "^0.15.0"
+ },
+ "engines": {
+ "node": ">=18.18.0"
+ }
+ },
+ "node_modules/@humanfs/node": {
+ "version": "0.16.8",
+ "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.8.tgz",
+ "integrity": "sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@humanfs/core": "^0.19.2",
+ "@humanfs/types": "^0.15.0",
+ "@humanwhocodes/retry": "^0.4.0"
+ },
+ "engines": {
+ "node": ">=18.18.0"
+ }
+ },
+ "node_modules/@humanfs/types": {
+ "version": "0.15.0",
+ "resolved": "https://registry.npmjs.org/@humanfs/types/-/types-0.15.0.tgz",
+ "integrity": "sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=18.18.0"
+ }
+ },
+ "node_modules/@humanwhocodes/module-importer": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz",
+ "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=12.22"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/nzakas"
+ }
+ },
+ "node_modules/@humanwhocodes/retry": {
+ "version": "0.4.3",
+ "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz",
+ "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=18.18"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/nzakas"
+ }
+ },
+ "node_modules/@iconify/react": {
+ "version": "5.2.1",
+ "resolved": "https://registry.npmjs.org/@iconify/react/-/react-5.2.1.tgz",
+ "integrity": "sha512-37GDR3fYDZmnmUn9RagyaX+zca24jfVOMY8E1IXTqJuE8pxNtN51KWPQe3VODOWvuUurq7q9uUu3CFrpqj5Iqg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@iconify/types": "^2.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/cyberalien"
+ },
+ "peerDependencies": {
+ "react": ">=16"
+ }
+ },
+ "node_modules/@iconify/types": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0.tgz",
+ "integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@img/colour": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz",
+ "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@img/sharp-darwin-arm64": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.5.tgz",
+ "integrity": "sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-darwin-arm64": "1.2.4"
+ }
+ },
+ "node_modules/@img/sharp-darwin-x64": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.5.tgz",
+ "integrity": "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-darwin-x64": "1.2.4"
+ }
+ },
+ "node_modules/@img/sharp-libvips-darwin-arm64": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.4.tgz",
+ "integrity": "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-darwin-x64": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.4.tgz",
+ "integrity": "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-arm": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.4.tgz",
+ "integrity": "sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-arm64": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.4.tgz",
+ "integrity": "sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-ppc64": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.4.tgz",
+ "integrity": "sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-riscv64": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.2.4.tgz",
+ "integrity": "sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==",
+ "cpu": [
+ "riscv64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-s390x": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.4.tgz",
+ "integrity": "sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==",
+ "cpu": [
+ "s390x"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-x64": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.4.tgz",
+ "integrity": "sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linuxmusl-arm64": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.4.tgz",
+ "integrity": "sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "musl"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linuxmusl-x64": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.4.tgz",
+ "integrity": "sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "musl"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-linux-arm": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.5.tgz",
+ "integrity": "sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-arm": "1.2.4"
+ }
+ },
+ "node_modules/@img/sharp-linux-arm64": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.5.tgz",
+ "integrity": "sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-arm64": "1.2.4"
+ }
+ },
+ "node_modules/@img/sharp-linux-ppc64": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.5.tgz",
+ "integrity": "sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-ppc64": "1.2.4"
+ }
+ },
+ "node_modules/@img/sharp-linux-riscv64": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.34.5.tgz",
+ "integrity": "sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==",
+ "cpu": [
+ "riscv64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-riscv64": "1.2.4"
+ }
+ },
+ "node_modules/@img/sharp-linux-s390x": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.5.tgz",
+ "integrity": "sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==",
+ "cpu": [
+ "s390x"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-s390x": "1.2.4"
+ }
+ },
+ "node_modules/@img/sharp-linux-x64": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.5.tgz",
+ "integrity": "sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-x64": "1.2.4"
}
},
- "node_modules/@humanfs/core": {
- "version": "0.19.2",
- "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz",
- "integrity": "sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==",
+ "node_modules/@img/sharp-linuxmusl-arm64": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.5.tgz",
+ "integrity": "sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==",
+ "cpu": [
+ "arm64"
+ ],
"dev": true,
+ "libc": [
+ "musl"
+ ],
"license": "Apache-2.0",
- "dependencies": {
- "@humanfs/types": "^0.15.0"
- },
+ "optional": true,
+ "os": [
+ "linux"
+ ],
"engines": {
- "node": ">=18.18.0"
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linuxmusl-arm64": "1.2.4"
}
},
- "node_modules/@humanfs/node": {
- "version": "0.16.8",
- "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.8.tgz",
- "integrity": "sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==",
+ "node_modules/@img/sharp-linuxmusl-x64": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.5.tgz",
+ "integrity": "sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==",
+ "cpu": [
+ "x64"
+ ],
"dev": true,
+ "libc": [
+ "musl"
+ ],
"license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linuxmusl-x64": "1.2.4"
+ }
+ },
+ "node_modules/@img/sharp-wasm32": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.5.tgz",
+ "integrity": "sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==",
+ "cpu": [
+ "wasm32"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",
+ "optional": true,
"dependencies": {
- "@humanfs/core": "^0.19.2",
- "@humanfs/types": "^0.15.0",
- "@humanwhocodes/retry": "^0.4.0"
+ "@emnapi/runtime": "^1.7.0"
},
"engines": {
- "node": ">=18.18.0"
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
}
},
- "node_modules/@humanfs/types": {
- "version": "0.15.0",
- "resolved": "https://registry.npmjs.org/@humanfs/types/-/types-0.15.0.tgz",
- "integrity": "sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==",
+ "node_modules/@img/sharp-win32-arm64": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.5.tgz",
+ "integrity": "sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==",
+ "cpu": [
+ "arm64"
+ ],
"dev": true,
- "license": "Apache-2.0",
+ "license": "Apache-2.0 AND LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
"engines": {
- "node": ">=18.18.0"
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
}
},
- "node_modules/@humanwhocodes/module-importer": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz",
- "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==",
+ "node_modules/@img/sharp-win32-ia32": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.5.tgz",
+ "integrity": "sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==",
+ "cpu": [
+ "ia32"
+ ],
"dev": true,
- "license": "Apache-2.0",
+ "license": "Apache-2.0 AND LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
"engines": {
- "node": ">=12.22"
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
},
"funding": {
- "type": "github",
- "url": "https://github.com/sponsors/nzakas"
+ "url": "https://opencollective.com/libvips"
}
},
- "node_modules/@humanwhocodes/retry": {
- "version": "0.4.3",
- "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz",
- "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==",
+ "node_modules/@img/sharp-win32-x64": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.5.tgz",
+ "integrity": "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==",
+ "cpu": [
+ "x64"
+ ],
"dev": true,
- "license": "Apache-2.0",
+ "license": "Apache-2.0 AND LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
"engines": {
- "node": ">=18.18"
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
},
"funding": {
- "type": "github",
- "url": "https://github.com/sponsors/nzakas"
+ "url": "https://opencollective.com/libvips"
}
},
- "node_modules/@iconify/react": {
- "version": "5.2.1",
- "resolved": "https://registry.npmjs.org/@iconify/react/-/react-5.2.1.tgz",
- "integrity": "sha512-37GDR3fYDZmnmUn9RagyaX+zca24jfVOMY8E1IXTqJuE8pxNtN51KWPQe3VODOWvuUurq7q9uUu3CFrpqj5Iqg==",
+ "node_modules/@inquirer/ansi": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/@inquirer/ansi/-/ansi-2.0.5.tgz",
+ "integrity": "sha512-doc2sWgJpbFQ64UflSVd17ibMGDuxO1yKgOgLMwavzESnXjFWJqUeG8saYosqKpHp4kWiM5x1nXvEjbpx90gzw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0"
+ }
+ },
+ "node_modules/@inquirer/confirm": {
+ "version": "6.0.12",
+ "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-6.0.12.tgz",
+ "integrity": "sha512-h9FgGun3QwVYNj5TWIZZ+slii73bMoBFjPfVIGtnFuL4t8gBiNDV9PcSfIzkuxvgquJKt9nr1QzszpBzTbH8Og==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@iconify/types": "^2.0.0"
+ "@inquirer/core": "^11.1.9",
+ "@inquirer/type": "^4.0.5"
},
- "funding": {
- "url": "https://github.com/sponsors/cyberalien"
+ "engines": {
+ "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0"
},
"peerDependencies": {
- "react": ">=16"
+ "@types/node": ">=18"
+ },
+ "peerDependenciesMeta": {
+ "@types/node": {
+ "optional": true
+ }
}
},
- "node_modules/@iconify/types": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0.tgz",
- "integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==",
+ "node_modules/@inquirer/core": {
+ "version": "11.1.9",
+ "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-11.1.9.tgz",
+ "integrity": "sha512-BDE4fG22uYh1bGSifcj7JSx119TVYNViMhMu85usp4Fswrzh6M0DV3yld64jA98uOAa2GSQ4Bg4bZRm2d2cwSg==",
"dev": true,
- "license": "MIT"
+ "license": "MIT",
+ "dependencies": {
+ "@inquirer/ansi": "^2.0.5",
+ "@inquirer/figures": "^2.0.5",
+ "@inquirer/type": "^4.0.5",
+ "cli-width": "^4.1.0",
+ "fast-wrap-ansi": "^0.2.0",
+ "mute-stream": "^3.0.0",
+ "signal-exit": "^4.1.0"
+ },
+ "engines": {
+ "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0"
+ },
+ "peerDependencies": {
+ "@types/node": ">=18"
+ },
+ "peerDependenciesMeta": {
+ "@types/node": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@inquirer/figures": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-2.0.5.tgz",
+ "integrity": "sha512-NsSs4kzfm12lNetHwAn3GEuH317IzpwrMCbOuMIVytpjnJ90YYHNwdRgYGuKmVxwuIqSgqk3M5qqQt1cDk0tGQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0"
+ }
+ },
+ "node_modules/@inquirer/type": {
+ "version": "4.0.5",
+ "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-4.0.5.tgz",
+ "integrity": "sha512-aetVUNeKNc/VriqXlw1NRSW0zhMBB0W4bNbWRJgzRl/3d0QNDQFfk0GO5SDdtjMZVg6o8ZKEiadd7SCCzoOn5Q==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0"
+ },
+ "peerDependencies": {
+ "@types/node": ">=18"
+ },
+ "peerDependenciesMeta": {
+ "@types/node": {
+ "optional": true
+ }
+ }
},
"node_modules/@isaacs/cliui": {
"version": "9.0.0",
@@ -2266,6 +3305,47 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@modelcontextprotocol/sdk": {
+ "version": "1.29.0",
+ "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.29.0.tgz",
+ "integrity": "sha512-zo37mZA9hJWpULgkRpowewez1y6ML5GsXJPY8FI0tBBCd77HEvza4jDqRKOXgHNn867PVGCyTdzqpz0izu5ZjQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@hono/node-server": "^1.19.9",
+ "ajv": "^8.17.1",
+ "ajv-formats": "^3.0.1",
+ "content-type": "^1.0.5",
+ "cors": "^2.8.5",
+ "cross-spawn": "^7.0.5",
+ "eventsource": "^3.0.2",
+ "eventsource-parser": "^3.0.0",
+ "express": "^5.2.1",
+ "express-rate-limit": "^8.2.1",
+ "hono": "^4.11.4",
+ "jose": "^6.1.3",
+ "json-schema-typed": "^8.0.2",
+ "pkce-challenge": "^5.0.0",
+ "raw-body": "^3.0.0",
+ "zod": "^3.25 || ^4.0",
+ "zod-to-json-schema": "^3.25.1"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "peerDependencies": {
+ "@cfworker/json-schema": "^4.1.1",
+ "zod": "^3.25 || ^4.0"
+ },
+ "peerDependenciesMeta": {
+ "@cfworker/json-schema": {
+ "optional": true
+ },
+ "zod": {
+ "optional": false
+ }
+ }
+ },
"node_modules/@monaco-editor/loader": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/@monaco-editor/loader/-/loader-1.7.0.tgz",
@@ -2291,6 +3371,31 @@
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
}
},
+ "node_modules/@mswjs/interceptors": {
+ "version": "0.41.8",
+ "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.41.8.tgz",
+ "integrity": "sha512-pRLMNKTSGRoLq+KnEB/7OY5vijw1XmcheAAOiv6pj7W1FG32kAGqj1C/RK/cqxRGr1Fh+zBi8sDur8kj3EQv6A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@open-draft/deferred-promise": "^2.2.0",
+ "@open-draft/logger": "^0.3.0",
+ "@open-draft/until": "^2.0.0",
+ "is-node-process": "^1.2.0",
+ "outvariant": "^1.4.3",
+ "strict-event-emitter": "^0.5.1"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@mswjs/interceptors/node_modules/@open-draft/deferred-promise": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz",
+ "integrity": "sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@napi-rs/canvas": {
"version": "0.1.99",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas/-/canvas-0.1.99.tgz",
@@ -2572,6 +3677,111 @@
"@emnapi/runtime": "^1.7.1"
}
},
+ "node_modules/@noble/ciphers": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-1.3.0.tgz",
+ "integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": "^14.21.3 || >=16"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/@noble/curves": {
+ "version": "1.9.7",
+ "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz",
+ "integrity": "sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@noble/hashes": "1.8.0"
+ },
+ "engines": {
+ "node": "^14.21.3 || >=16"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/@noble/hashes": {
+ "version": "1.8.0",
+ "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz",
+ "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": "^14.21.3 || >=16"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/@nodelib/fs.scandir": {
+ "version": "2.1.5",
+ "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
+ "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@nodelib/fs.stat": "2.0.5",
+ "run-parallel": "^1.1.9"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/@nodelib/fs.stat": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz",
+ "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/@nodelib/fs.walk": {
+ "version": "1.2.8",
+ "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz",
+ "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@nodelib/fs.scandir": "2.1.5",
+ "fastq": "^1.6.0"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/@open-draft/deferred-promise": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-3.0.0.tgz",
+ "integrity": "sha512-XW375UK8/9SqUVNVa6M0yEy8+iTi4QN5VZ7aZuRFQmy76LRwI9wy5F4YIBU6T+eTe2/DNDo8tqu8RHlwLHM6RA==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@open-draft/logger": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/@open-draft/logger/-/logger-0.3.0.tgz",
+ "integrity": "sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "is-node-process": "^1.2.0",
+ "outvariant": "^1.4.0"
+ }
+ },
+ "node_modules/@open-draft/until": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz",
+ "integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@oxc-project/types": {
"version": "0.127.0",
"resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.127.0.tgz",
@@ -2596,6 +3806,30 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@radix-ui/react-accessible-icon": {
+ "version": "1.1.7",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-accessible-icon/-/react-accessible-icon-1.1.7.tgz",
+ "integrity": "sha512-XM+E4WXl0OqUJFovy6GjmxxFyx9opfCAIUku4dlKRd5YEPqt4kALOkQOp0Of6reHuUkJuiPBEc5k0o4z4lTC8A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-visually-hidden": "1.2.3"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@radix-ui/react-accordion": {
"version": "1.2.12",
"resolved": "https://registry.npmjs.org/@radix-ui/react-accordion/-/react-accordion-1.2.12.tgz",
@@ -2700,6 +3934,58 @@
}
}
},
+ "node_modules/@radix-ui/react-aspect-ratio": {
+ "version": "1.1.7",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-aspect-ratio/-/react-aspect-ratio-1.1.7.tgz",
+ "integrity": "sha512-Yq6lvO9HQyPwev1onK1daHCHqXVLzPhSVjmsNjCa2Zcxy2f7uJD2itDtxknv6FzAKCwD1qQkeVDmX/cev13n/g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-primitive": "2.1.3"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-avatar": {
+ "version": "1.1.10",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-avatar/-/react-avatar-1.1.10.tgz",
+ "integrity": "sha512-V8piFfWapM5OmNCXTzVQY+E1rDa53zY+MQ4Y7356v4fFz6vqCyUtIz2rUD44ZEdwg78/jKmMJHj07+C/Z/rcog==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-primitive": "2.1.3",
+ "@radix-ui/react-use-callback-ref": "1.1.1",
+ "@radix-ui/react-use-is-hydrated": "0.1.0",
+ "@radix-ui/react-use-layout-effect": "1.1.1"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@radix-ui/react-checkbox": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@radix-ui/react-checkbox/-/react-checkbox-1.3.3.tgz",
@@ -2840,6 +4126,35 @@
}
}
},
+ "node_modules/@radix-ui/react-context-menu": {
+ "version": "2.2.16",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-context-menu/-/react-context-menu-2.2.16.tgz",
+ "integrity": "sha512-O8morBEW+HsVG28gYDZPTrT9UUovQUlJue5YO836tiTJhuIWBm/zQHc7j388sHWtdH/xUZurK9olD2+pcqx5ww==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.3",
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-menu": "2.1.16",
+ "@radix-ui/react-primitive": "2.1.3",
+ "@radix-ui/react-use-callback-ref": "1.1.1",
+ "@radix-ui/react-use-controllable-state": "1.2.2"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@radix-ui/react-dialog": {
"version": "1.1.15",
"resolved": "https://registry.npmjs.org/@radix-ui/react-dialog/-/react-dialog-1.1.15.tgz",
@@ -2995,7 +4310,200 @@
"dependencies": {
"@radix-ui/react-compose-refs": "1.1.2",
"@radix-ui/react-primitive": "2.1.3",
- "@radix-ui/react-use-callback-ref": "1.1.1"
+ "@radix-ui/react-use-callback-ref": "1.1.1"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-form": {
+ "version": "0.1.8",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-form/-/react-form-0.1.8.tgz",
+ "integrity": "sha512-QM70k4Zwjttifr5a4sZFts9fn8FzHYvQ5PiB19O2HsYibaHSVt9fH9rzB0XZo/YcM+b7t/p7lYCT/F5eOeF5yQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.3",
+ "@radix-ui/react-compose-refs": "1.1.2",
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-id": "1.1.1",
+ "@radix-ui/react-label": "2.1.7",
+ "@radix-ui/react-primitive": "2.1.3"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-form/node_modules/@radix-ui/react-label": {
+ "version": "2.1.7",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-label/-/react-label-2.1.7.tgz",
+ "integrity": "sha512-YT1GqPSL8kJn20djelMX7/cTRp/Y9w5IZHvfxQTVHrOqa2yMl7i/UfMqKRU5V7mEyKTrUVgJXhNQPVCG8PBLoQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-primitive": "2.1.3"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-hover-card": {
+ "version": "1.1.15",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-hover-card/-/react-hover-card-1.1.15.tgz",
+ "integrity": "sha512-qgTkjNT1CfKMoP0rcasmlH2r1DAiYicWsDsufxl940sT2wHNEWWv6FMWIQXWhVdmC1d/HYfbhQx60KYyAtKxjg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.3",
+ "@radix-ui/react-compose-refs": "1.1.2",
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-dismissable-layer": "1.1.11",
+ "@radix-ui/react-popper": "1.2.8",
+ "@radix-ui/react-portal": "1.1.9",
+ "@radix-ui/react-presence": "1.1.5",
+ "@radix-ui/react-primitive": "2.1.3",
+ "@radix-ui/react-use-controllable-state": "1.2.2"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-id": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-id/-/react-id-1.1.1.tgz",
+ "integrity": "sha512-kGkGegYIdQsOb4XjsfM97rXsiHaBwco+hFI66oO4s9LU+PLAC5oJ7khdOVFxkhsmlbpUqDAvXw11CluXP+jkHg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-use-layout-effect": "1.1.1"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-label": {
+ "version": "2.1.8",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-label/-/react-label-2.1.8.tgz",
+ "integrity": "sha512-FmXs37I6hSBVDlO4y764TNz1rLgKwjJMQ0EGte6F3Cb3f4bIuHB/iLa/8I9VKkmOy+gNHq8rql3j686ACVV21A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-primitive": "2.1.4"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-label/node_modules/@radix-ui/react-primitive": {
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-primitive/-/react-primitive-2.1.4.tgz",
+ "integrity": "sha512-9hQc4+GNVtJAIEPEqlYqW5RiYdrr8ea5XQ0ZOnD6fgru+83kqT15mq2OCcbe8KnjRZl5vF3ks69AKz3kh1jrhg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-slot": "1.2.4"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-menu": {
+ "version": "2.1.16",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-menu/-/react-menu-2.1.16.tgz",
+ "integrity": "sha512-72F2T+PLlphrqLcAotYPp0uJMr5SjP5SL01wfEspJbru5Zs5vQaSHb4VB3ZMJPimgHHCHG7gMOeOB9H3Hdmtxg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.3",
+ "@radix-ui/react-collection": "1.1.7",
+ "@radix-ui/react-compose-refs": "1.1.2",
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-direction": "1.1.1",
+ "@radix-ui/react-dismissable-layer": "1.1.11",
+ "@radix-ui/react-focus-guards": "1.1.3",
+ "@radix-ui/react-focus-scope": "1.1.7",
+ "@radix-ui/react-id": "1.1.1",
+ "@radix-ui/react-popper": "1.2.8",
+ "@radix-ui/react-portal": "1.1.9",
+ "@radix-ui/react-presence": "1.1.5",
+ "@radix-ui/react-primitive": "2.1.3",
+ "@radix-ui/react-roving-focus": "1.1.11",
+ "@radix-ui/react-slot": "1.2.3",
+ "@radix-ui/react-use-callback-ref": "1.1.1",
+ "aria-hidden": "^1.2.4",
+ "react-remove-scroll": "^2.6.3"
},
"peerDependencies": {
"@types/react": "*",
@@ -3012,14 +4520,14 @@
}
}
},
- "node_modules/@radix-ui/react-id": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-id/-/react-id-1.1.1.tgz",
- "integrity": "sha512-kGkGegYIdQsOb4XjsfM97rXsiHaBwco+hFI66oO4s9LU+PLAC5oJ7khdOVFxkhsmlbpUqDAvXw11CluXP+jkHg==",
+ "node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-slot": {
+ "version": "1.2.3",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz",
+ "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@radix-ui/react-use-layout-effect": "1.1.1"
+ "@radix-ui/react-compose-refs": "1.1.2"
},
"peerDependencies": {
"@types/react": "*",
@@ -3031,14 +4539,23 @@
}
}
},
- "node_modules/@radix-ui/react-label": {
- "version": "2.1.8",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-label/-/react-label-2.1.8.tgz",
- "integrity": "sha512-FmXs37I6hSBVDlO4y764TNz1rLgKwjJMQ0EGte6F3Cb3f4bIuHB/iLa/8I9VKkmOy+gNHq8rql3j686ACVV21A==",
+ "node_modules/@radix-ui/react-menubar": {
+ "version": "1.1.16",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-menubar/-/react-menubar-1.1.16.tgz",
+ "integrity": "sha512-EB1FktTz5xRRi2Er974AUQZWg2yVBb1yjip38/lgwtCVRd3a+maUoGHN/xs9Yv8SY8QwbSEb+YrxGadVWbEutA==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@radix-ui/react-primitive": "2.1.4"
+ "@radix-ui/primitive": "1.1.3",
+ "@radix-ui/react-collection": "1.1.7",
+ "@radix-ui/react-compose-refs": "1.1.2",
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-direction": "1.1.1",
+ "@radix-ui/react-id": "1.1.1",
+ "@radix-ui/react-menu": "2.1.16",
+ "@radix-ui/react-primitive": "2.1.3",
+ "@radix-ui/react-roving-focus": "1.1.11",
+ "@radix-ui/react-use-controllable-state": "1.2.2"
},
"peerDependencies": {
"@types/react": "*",
@@ -3055,14 +4572,27 @@
}
}
},
- "node_modules/@radix-ui/react-label/node_modules/@radix-ui/react-primitive": {
- "version": "2.1.4",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-primitive/-/react-primitive-2.1.4.tgz",
- "integrity": "sha512-9hQc4+GNVtJAIEPEqlYqW5RiYdrr8ea5XQ0ZOnD6fgru+83kqT15mq2OCcbe8KnjRZl5vF3ks69AKz3kh1jrhg==",
+ "node_modules/@radix-ui/react-navigation-menu": {
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-navigation-menu/-/react-navigation-menu-1.2.14.tgz",
+ "integrity": "sha512-YB9mTFQvCOAQMHU+C/jVl96WmuWeltyUEpRJJky51huhds5W2FQr1J8D/16sQlf0ozxkPK8uF3niQMdUwZPv5w==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@radix-ui/react-slot": "1.2.4"
+ "@radix-ui/primitive": "1.1.3",
+ "@radix-ui/react-collection": "1.1.7",
+ "@radix-ui/react-compose-refs": "1.1.2",
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-direction": "1.1.1",
+ "@radix-ui/react-dismissable-layer": "1.1.11",
+ "@radix-ui/react-id": "1.1.1",
+ "@radix-ui/react-presence": "1.1.5",
+ "@radix-ui/react-primitive": "2.1.3",
+ "@radix-ui/react-use-callback-ref": "1.1.1",
+ "@radix-ui/react-use-controllable-state": "1.2.2",
+ "@radix-ui/react-use-layout-effect": "1.1.1",
+ "@radix-ui/react-use-previous": "1.1.1",
+ "@radix-ui/react-visually-hidden": "1.2.3"
},
"peerDependencies": {
"@types/react": "*",
@@ -3079,31 +4609,25 @@
}
}
},
- "node_modules/@radix-ui/react-menu": {
- "version": "2.1.16",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-menu/-/react-menu-2.1.16.tgz",
- "integrity": "sha512-72F2T+PLlphrqLcAotYPp0uJMr5SjP5SL01wfEspJbru5Zs5vQaSHb4VB3ZMJPimgHHCHG7gMOeOB9H3Hdmtxg==",
+ "node_modules/@radix-ui/react-one-time-password-field": {
+ "version": "0.1.8",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-one-time-password-field/-/react-one-time-password-field-0.1.8.tgz",
+ "integrity": "sha512-ycS4rbwURavDPVjCb5iS3aG4lURFDILi6sKI/WITUMZ13gMmn/xGjpLoqBAalhJaDk8I3UbCM5GzKHrnzwHbvg==",
"dev": true,
"license": "MIT",
"dependencies": {
+ "@radix-ui/number": "1.1.1",
"@radix-ui/primitive": "1.1.3",
"@radix-ui/react-collection": "1.1.7",
"@radix-ui/react-compose-refs": "1.1.2",
"@radix-ui/react-context": "1.1.2",
"@radix-ui/react-direction": "1.1.1",
- "@radix-ui/react-dismissable-layer": "1.1.11",
- "@radix-ui/react-focus-guards": "1.1.3",
- "@radix-ui/react-focus-scope": "1.1.7",
- "@radix-ui/react-id": "1.1.1",
- "@radix-ui/react-popper": "1.2.8",
- "@radix-ui/react-portal": "1.1.9",
- "@radix-ui/react-presence": "1.1.5",
"@radix-ui/react-primitive": "2.1.3",
"@radix-ui/react-roving-focus": "1.1.11",
- "@radix-ui/react-slot": "1.2.3",
- "@radix-ui/react-use-callback-ref": "1.1.1",
- "aria-hidden": "^1.2.4",
- "react-remove-scroll": "^2.6.3"
+ "@radix-ui/react-use-controllable-state": "1.2.2",
+ "@radix-ui/react-use-effect-event": "0.0.2",
+ "@radix-ui/react-use-is-hydrated": "0.1.0",
+ "@radix-ui/react-use-layout-effect": "1.1.1"
},
"peerDependencies": {
"@types/react": "*",
@@ -3120,22 +4644,34 @@
}
}
},
- "node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-slot": {
- "version": "1.2.3",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz",
- "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==",
+ "node_modules/@radix-ui/react-password-toggle-field": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-password-toggle-field/-/react-password-toggle-field-0.1.3.tgz",
+ "integrity": "sha512-/UuCrDBWravcaMix4TdT+qlNdVwOM1Nck9kWx/vafXsdfj1ChfhOdfi3cy9SGBpWgTXwYCuboT/oYpJy3clqfw==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@radix-ui/react-compose-refs": "1.1.2"
+ "@radix-ui/primitive": "1.1.3",
+ "@radix-ui/react-compose-refs": "1.1.2",
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-id": "1.1.1",
+ "@radix-ui/react-primitive": "2.1.3",
+ "@radix-ui/react-use-controllable-state": "1.2.2",
+ "@radix-ui/react-use-effect-event": "0.0.2",
+ "@radix-ui/react-use-is-hydrated": "0.1.0"
},
"peerDependencies": {
"@types/react": "*",
- "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
}
}
},
@@ -3387,6 +4923,39 @@
}
}
},
+ "node_modules/@radix-ui/react-radio-group": {
+ "version": "1.3.8",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-radio-group/-/react-radio-group-1.3.8.tgz",
+ "integrity": "sha512-VBKYIYImA5zsxACdisNQ3BjCBfmbGH3kQlnFVqlWU4tXwjy7cGX8ta80BcrO+WJXIn5iBylEH3K6ZTlee//lgQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.3",
+ "@radix-ui/react-compose-refs": "1.1.2",
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-direction": "1.1.1",
+ "@radix-ui/react-presence": "1.1.5",
+ "@radix-ui/react-primitive": "2.1.3",
+ "@radix-ui/react-roving-focus": "1.1.11",
+ "@radix-ui/react-use-controllable-state": "1.2.2",
+ "@radix-ui/react-use-previous": "1.1.1",
+ "@radix-ui/react-use-size": "1.1.1"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@radix-ui/react-roving-focus": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/@radix-ui/react-roving-focus/-/react-roving-focus-1.1.11.tgz",
@@ -3623,12 +5192,164 @@
"license": "MIT",
"dependencies": {
"@radix-ui/primitive": "1.1.3",
- "@radix-ui/react-compose-refs": "1.1.2",
+ "@radix-ui/react-compose-refs": "1.1.2",
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-primitive": "2.1.3",
+ "@radix-ui/react-use-controllable-state": "1.2.2",
+ "@radix-ui/react-use-previous": "1.1.1",
+ "@radix-ui/react-use-size": "1.1.1"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-tabs": {
+ "version": "1.1.13",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-tabs/-/react-tabs-1.1.13.tgz",
+ "integrity": "sha512-7xdcatg7/U+7+Udyoj2zodtI9H/IIopqo+YOIcZOq1nJwXWBZ9p8xiu5llXlekDbZkca79a/fozEYQXIA4sW6A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.3",
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-direction": "1.1.1",
+ "@radix-ui/react-id": "1.1.1",
+ "@radix-ui/react-presence": "1.1.5",
+ "@radix-ui/react-primitive": "2.1.3",
+ "@radix-ui/react-roving-focus": "1.1.11",
+ "@radix-ui/react-use-controllable-state": "1.2.2"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-toast": {
+ "version": "1.2.15",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-toast/-/react-toast-1.2.15.tgz",
+ "integrity": "sha512-3OSz3TacUWy4WtOXV38DggwxoqJK4+eDkNMl5Z/MJZaoUPaP4/9lf81xXMe1I2ReTAptverZUpbPY4wWwWyL5g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.3",
+ "@radix-ui/react-collection": "1.1.7",
+ "@radix-ui/react-compose-refs": "1.1.2",
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-dismissable-layer": "1.1.11",
+ "@radix-ui/react-portal": "1.1.9",
+ "@radix-ui/react-presence": "1.1.5",
+ "@radix-ui/react-primitive": "2.1.3",
+ "@radix-ui/react-use-callback-ref": "1.1.1",
+ "@radix-ui/react-use-controllable-state": "1.2.2",
+ "@radix-ui/react-use-layout-effect": "1.1.1",
+ "@radix-ui/react-visually-hidden": "1.2.3"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-toggle": {
+ "version": "1.1.10",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-toggle/-/react-toggle-1.1.10.tgz",
+ "integrity": "sha512-lS1odchhFTeZv3xwHH31YPObmJn8gOg7Lq12inrr0+BH/l3Tsq32VfjqH1oh80ARM3mlkfMic15n0kg4sD1poQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.3",
+ "@radix-ui/react-primitive": "2.1.3",
+ "@radix-ui/react-use-controllable-state": "1.2.2"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-toggle-group": {
+ "version": "1.1.11",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-toggle-group/-/react-toggle-group-1.1.11.tgz",
+ "integrity": "sha512-5umnS0T8JQzQT6HbPyO7Hh9dgd82NmS36DQr+X/YJ9ctFNCiiQd6IJAYYZ33LUwm8M+taCz5t2ui29fHZc4Y6Q==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.3",
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-direction": "1.1.1",
+ "@radix-ui/react-primitive": "2.1.3",
+ "@radix-ui/react-roving-focus": "1.1.11",
+ "@radix-ui/react-toggle": "1.1.10",
+ "@radix-ui/react-use-controllable-state": "1.2.2"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-toolbar": {
+ "version": "1.1.11",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-toolbar/-/react-toolbar-1.1.11.tgz",
+ "integrity": "sha512-4ol06/1bLoFu1nwUqzdD4Y5RZ9oDdKeiHIsntug54Hcr1pgaHiPqHFEaXI1IFP/EsOfROQZ8Mig9VTIRza6Tjg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.3",
"@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-direction": "1.1.1",
"@radix-ui/react-primitive": "2.1.3",
- "@radix-ui/react-use-controllable-state": "1.2.2",
- "@radix-ui/react-use-previous": "1.1.1",
- "@radix-ui/react-use-size": "1.1.1"
+ "@radix-ui/react-roving-focus": "1.1.11",
+ "@radix-ui/react-separator": "1.1.7",
+ "@radix-ui/react-toggle-group": "1.1.11"
},
"peerDependencies": {
"@types/react": "*",
@@ -3645,21 +5366,14 @@
}
}
},
- "node_modules/@radix-ui/react-tabs": {
- "version": "1.1.13",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-tabs/-/react-tabs-1.1.13.tgz",
- "integrity": "sha512-7xdcatg7/U+7+Udyoj2zodtI9H/IIopqo+YOIcZOq1nJwXWBZ9p8xiu5llXlekDbZkca79a/fozEYQXIA4sW6A==",
+ "node_modules/@radix-ui/react-toolbar/node_modules/@radix-ui/react-separator": {
+ "version": "1.1.7",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-separator/-/react-separator-1.1.7.tgz",
+ "integrity": "sha512-0HEb8R9E8A+jZjvmFCy/J4xhbXy3TV+9XSnGJ3KvTtjlIUy/YQ/p6UYZvi7YbeoeXdyU9+Y3scizK6hkY37baA==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@radix-ui/primitive": "1.1.3",
- "@radix-ui/react-context": "1.1.2",
- "@radix-ui/react-direction": "1.1.1",
- "@radix-ui/react-id": "1.1.1",
- "@radix-ui/react-presence": "1.1.5",
- "@radix-ui/react-primitive": "2.1.3",
- "@radix-ui/react-roving-focus": "1.1.11",
- "@radix-ui/react-use-controllable-state": "1.2.2"
+ "@radix-ui/react-primitive": "2.1.3"
},
"peerDependencies": {
"@types/react": "*",
@@ -3804,6 +5518,25 @@
}
}
},
+ "node_modules/@radix-ui/react-use-is-hydrated": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-use-is-hydrated/-/react-use-is-hydrated-0.1.0.tgz",
+ "integrity": "sha512-U+UORVEq+cTnRIaostJv9AGdV3G6Y+zbVd+12e18jQ5A3c0xL03IhnHuiU4UV69wolOQp5GfR58NW/EgdQhwOA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "use-sync-external-store": "^1.5.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@radix-ui/react-use-layout-effect": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-layout-effect/-/react-use-layout-effect-1.1.1.tgz",
@@ -4256,6 +5989,36 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@rollup/pluginutils": {
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.3.0.tgz",
+ "integrity": "sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/estree": "^1.0.0",
+ "estree-walker": "^2.0.2",
+ "picomatch": "^4.0.2"
+ },
+ "engines": {
+ "node": ">=14.0.0"
+ },
+ "peerDependencies": {
+ "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0"
+ },
+ "peerDependenciesMeta": {
+ "rollup": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@sec-ant/readable-stream": {
+ "version": "0.4.1",
+ "resolved": "https://registry.npmjs.org/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz",
+ "integrity": "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@simple-libs/child-process-utils": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@simple-libs/child-process-utils/-/child-process-utils-1.0.2.tgz",
@@ -4269,36 +6032,314 @@
"node": ">=18"
},
"funding": {
- "url": "https://ko-fi.com/dangreen"
+ "url": "https://ko-fi.com/dangreen"
+ }
+ },
+ "node_modules/@simple-libs/stream-utils": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/@simple-libs/stream-utils/-/stream-utils-1.2.0.tgz",
+ "integrity": "sha512-KxXvfapcixpz6rVEB6HPjOUZT22yN6v0vI0urQSk1L8MlEWPDFCZkhw2xmkyoTGYeFw7tWTZd7e3lVzRZRN/EA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://ko-fi.com/dangreen"
+ }
+ },
+ "node_modules/@sindresorhus/merge-streams": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-4.0.0.tgz",
+ "integrity": "sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/@standard-schema/spec": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz",
+ "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@standard-schema/utils": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/@standard-schema/utils/-/utils-0.3.0.tgz",
+ "integrity": "sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@svgr/babel-plugin-add-jsx-attribute": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-8.0.0.tgz",
+ "integrity": "sha512-b9MIk7yhdS1pMCZM8VeNfUlSKVRhsHZNMl5O9SfaX0l0t5wjdgu4IDzGB8bpnGBBOjGST3rRFVsaaEtI4W6f7g==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/gregberge"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
+ "node_modules/@svgr/babel-plugin-remove-jsx-attribute": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-remove-jsx-attribute/-/babel-plugin-remove-jsx-attribute-8.0.0.tgz",
+ "integrity": "sha512-BcCkm/STipKvbCl6b7QFrMh/vx00vIP63k2eM66MfHJzPr6O2U0jYEViXkHJWqXqQYjdeA9cuCl5KWmlwjDvbA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/gregberge"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
+ "node_modules/@svgr/babel-plugin-remove-jsx-empty-expression": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-remove-jsx-empty-expression/-/babel-plugin-remove-jsx-empty-expression-8.0.0.tgz",
+ "integrity": "sha512-5BcGCBfBxB5+XSDSWnhTThfI9jcO5f0Ai2V24gZpG+wXF14BzwxxdDb4g6trdOux0rhibGs385BeFMSmxtS3uA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/gregberge"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
+ "node_modules/@svgr/babel-plugin-replace-jsx-attribute-value": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-replace-jsx-attribute-value/-/babel-plugin-replace-jsx-attribute-value-8.0.0.tgz",
+ "integrity": "sha512-KVQ+PtIjb1BuYT3ht8M5KbzWBhdAjjUPdlMtpuw/VjT8coTrItWX6Qafl9+ji831JaJcu6PJNKCV0bp01lBNzQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/gregberge"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
+ "node_modules/@svgr/babel-plugin-svg-dynamic-title": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-svg-dynamic-title/-/babel-plugin-svg-dynamic-title-8.0.0.tgz",
+ "integrity": "sha512-omNiKqwjNmOQJ2v6ge4SErBbkooV2aAWwaPFs2vUY7p7GhVkzRkJ00kILXQvRhA6miHnNpXv7MRnnSjdRjK8og==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/gregberge"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
+ "node_modules/@svgr/babel-plugin-svg-em-dimensions": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-svg-em-dimensions/-/babel-plugin-svg-em-dimensions-8.0.0.tgz",
+ "integrity": "sha512-mURHYnu6Iw3UBTbhGwE/vsngtCIbHE43xCRK7kCw4t01xyGqb2Pd+WXekRRoFOBIY29ZoOhUCTEweDMdrjfi9g==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/gregberge"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
+ "node_modules/@svgr/babel-plugin-transform-react-native-svg": {
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-transform-react-native-svg/-/babel-plugin-transform-react-native-svg-8.1.0.tgz",
+ "integrity": "sha512-Tx8T58CHo+7nwJ+EhUwx3LfdNSG9R2OKfaIXXs5soiy5HtgoAEkDay9LIimLOcG8dJQH1wPZp/cnAv6S9CrR1Q==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/gregberge"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
+ "node_modules/@svgr/babel-plugin-transform-svg-component": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-transform-svg-component/-/babel-plugin-transform-svg-component-8.0.0.tgz",
+ "integrity": "sha512-DFx8xa3cZXTdb/k3kfPeaixecQLgKh5NVBMwD0AQxOzcZawK4oo1Jh9LbrcACUivsCA7TLG8eeWgrDXjTMhRmw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/gregberge"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
+ "node_modules/@svgr/babel-preset": {
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@svgr/babel-preset/-/babel-preset-8.1.0.tgz",
+ "integrity": "sha512-7EYDbHE7MxHpv4sxvnVPngw5fuR6pw79SkcrILHJ/iMpuKySNCl5W1qcwPEpU+LgyRXOaAFgH0KhwD18wwg6ug==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@svgr/babel-plugin-add-jsx-attribute": "8.0.0",
+ "@svgr/babel-plugin-remove-jsx-attribute": "8.0.0",
+ "@svgr/babel-plugin-remove-jsx-empty-expression": "8.0.0",
+ "@svgr/babel-plugin-replace-jsx-attribute-value": "8.0.0",
+ "@svgr/babel-plugin-svg-dynamic-title": "8.0.0",
+ "@svgr/babel-plugin-svg-em-dimensions": "8.0.0",
+ "@svgr/babel-plugin-transform-react-native-svg": "8.1.0",
+ "@svgr/babel-plugin-transform-svg-component": "8.0.0"
+ },
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/gregberge"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
+ "node_modules/@svgr/core": {
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@svgr/core/-/core-8.1.0.tgz",
+ "integrity": "sha512-8QqtOQT5ACVlmsvKOJNEaWmRPmcojMOzCz4Hs2BGG/toAp/K38LcsMRyLp349glq5AzJbCEeimEoxaX6v/fLrA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/core": "^7.21.3",
+ "@svgr/babel-preset": "8.1.0",
+ "camelcase": "^6.2.0",
+ "cosmiconfig": "^8.1.3",
+ "snake-case": "^3.0.4"
+ },
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/gregberge"
+ }
+ },
+ "node_modules/@svgr/core/node_modules/camelcase": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz",
+ "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/@svgr/core/node_modules/cosmiconfig": {
+ "version": "8.3.6",
+ "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.3.6.tgz",
+ "integrity": "sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "import-fresh": "^3.3.0",
+ "js-yaml": "^4.1.0",
+ "parse-json": "^5.2.0",
+ "path-type": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/d-fischer"
+ },
+ "peerDependencies": {
+ "typescript": ">=4.9.5"
+ },
+ "peerDependenciesMeta": {
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@svgr/hast-util-to-babel-ast": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@svgr/hast-util-to-babel-ast/-/hast-util-to-babel-ast-8.0.0.tgz",
+ "integrity": "sha512-EbDKwO9GpfWP4jN9sGdYwPBU0kdomaPIL2Eu4YwmgP+sJeXT+L7bMwJUBnhzfH8Q2qMBqZ4fJwpCyYsAN3mt2Q==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/types": "^7.21.3",
+ "entities": "^4.4.0"
+ },
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/gregberge"
}
},
- "node_modules/@simple-libs/stream-utils": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/@simple-libs/stream-utils/-/stream-utils-1.2.0.tgz",
- "integrity": "sha512-KxXvfapcixpz6rVEB6HPjOUZT22yN6v0vI0urQSk1L8MlEWPDFCZkhw2xmkyoTGYeFw7tWTZd7e3lVzRZRN/EA==",
+ "node_modules/@svgr/plugin-jsx": {
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/@svgr/plugin-jsx/-/plugin-jsx-8.1.0.tgz",
+ "integrity": "sha512-0xiIyBsLlr8quN+WyuxooNW9RJ0Dpr8uOnH/xrCVO8GLUcwHISwj1AG0k+LFzteTkAA0GbX0kj9q6Dk70PTiPA==",
"dev": true,
"license": "MIT",
+ "dependencies": {
+ "@babel/core": "^7.21.3",
+ "@svgr/babel-preset": "8.1.0",
+ "@svgr/hast-util-to-babel-ast": "8.0.0",
+ "svg-parser": "^2.0.4"
+ },
"engines": {
- "node": ">=18"
+ "node": ">=14"
},
"funding": {
- "url": "https://ko-fi.com/dangreen"
+ "type": "github",
+ "url": "https://github.com/sponsors/gregberge"
+ },
+ "peerDependencies": {
+ "@svgr/core": "*"
}
},
- "node_modules/@standard-schema/spec": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz",
- "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==",
- "dev": true,
- "license": "MIT"
- },
- "node_modules/@standard-schema/utils": {
- "version": "0.3.0",
- "resolved": "https://registry.npmjs.org/@standard-schema/utils/-/utils-0.3.0.tgz",
- "integrity": "sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==",
- "dev": true,
- "license": "MIT"
- },
"node_modules/@tailwindcss/node": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.2.4.tgz",
@@ -4571,6 +6612,18 @@
"vite": "^5.2.0 || ^6 || ^7 || ^8"
}
},
+ "node_modules/@ts-morph/common": {
+ "version": "0.27.0",
+ "resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.27.0.tgz",
+ "integrity": "sha512-Wf29UqxWDpc+i61k3oIOzcUfQt79PIT9y/MWfAGlrkjg6lBC1hwDECLXPVJAhWjiGbfBCxZd65F/LIZF3+jeJQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "fast-glob": "^3.3.3",
+ "minimatch": "^10.0.1",
+ "path-browserify": "^1.0.1"
+ }
+ },
"node_modules/@tybys/wasm-util": {
"version": "0.10.1",
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz",
@@ -4937,6 +6990,16 @@
"@types/node": "*"
}
},
+ "node_modules/@types/set-cookie-parser": {
+ "version": "2.4.10",
+ "resolved": "https://registry.npmjs.org/@types/set-cookie-parser/-/set-cookie-parser-2.4.10.tgz",
+ "integrity": "sha512-GGmQVGpQWUe5qglJozEjZV/5dyxbOOZ0LHe/lqyWssB88Y4svNfst0uqBVscdDeIKl5Jy5+aPSvy7mI9tYRguw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/node": "*"
+ }
+ },
"node_modules/@types/speakeasy": {
"version": "2.0.10",
"resolved": "https://registry.npmjs.org/@types/speakeasy/-/speakeasy-2.0.10.tgz",
@@ -4974,6 +7037,13 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@types/statuses": {
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/@types/statuses/-/statuses-2.0.6.tgz",
+ "integrity": "sha512-xMAgYwceFhRA2zY+XbEA7mxYbA093wdiW8Vu6gZPGWy9cmOyU9XesH1tNcEWsKFd5Vzrqx5T3D38PWx1FIIXkA==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@types/unist": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz",
@@ -4988,6 +7058,13 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@types/validate-npm-package-name": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/@types/validate-npm-package-name/-/validate-npm-package-name-4.0.2.tgz",
+ "integrity": "sha512-lrpDziQipxCEeK5kWxvljWYhUvOiB2A9izZd9B2AFarYAkqZshb4lPbRs7zKEic6eGtH8V/2qJW+dPp9OtF6bw==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@types/verror": {
"version": "1.10.11",
"resolved": "https://registry.npmjs.org/@types/verror/-/verror-1.10.11.tgz",
@@ -5573,6 +7650,24 @@
}
}
},
+ "node_modules/ajv-formats": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz",
+ "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ajv": "^8.0.0"
+ },
+ "peerDependencies": {
+ "ajv": "^8.0.0"
+ },
+ "peerDependenciesMeta": {
+ "ajv": {
+ "optional": true
+ }
+ }
+ },
"node_modules/ansi-escapes": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.3.0.tgz",
@@ -5814,6 +7909,19 @@
"node": ">=0.8"
}
},
+ "node_modules/ast-types": {
+ "version": "0.16.1",
+ "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.16.1.tgz",
+ "integrity": "sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "tslib": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
"node_modules/astral-regex": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz",
@@ -6113,6 +8221,19 @@
"node": "18 || 20 || >=22"
}
},
+ "node_modules/braces": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
+ "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "fill-range": "^7.1.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/browserslist": {
"version": "4.28.2",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.2.tgz",
@@ -6273,6 +8394,22 @@
"node": ">=8"
}
},
+ "node_modules/bundle-name": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.0.tgz",
+ "integrity": "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "run-applescript": "^7.0.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/busboy": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
@@ -6498,6 +8635,19 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/cli-spinners": {
+ "version": "2.9.2",
+ "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz",
+ "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/cli-truncate": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-2.1.0.tgz",
@@ -6516,6 +8666,16 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/cli-width": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz",
+ "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==",
+ "dev": true,
+ "license": "ISC",
+ "engines": {
+ "node": ">= 12"
+ }
+ },
"node_modules/cliui": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
@@ -6599,6 +8759,13 @@
"react-dom": "^18 || ^19 || ^19.0.0-rc"
}
},
+ "node_modules/code-block-writer": {
+ "version": "13.0.3",
+ "resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-13.0.3.tgz",
+ "integrity": "sha512-Oofo0pq3IKnsFtuHqSF7TqBfr71aeyZDVJ0HpmqB7FBM2qEigL0iPONSCZSO9pE9dZTAxANe5XHG9Uy0YMv8cg==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/codemirror": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.2.tgz",
@@ -7012,6 +9179,19 @@
"node": ">= 8"
}
},
+ "node_modules/cssesc": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz",
+ "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==",
+ "dev": true,
+ "license": "MIT",
+ "bin": {
+ "cssesc": "bin/cssesc"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
"node_modules/csstype": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
@@ -7161,6 +9341,16 @@
"node": ">=12"
}
},
+ "node_modules/data-uri-to-buffer": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
+ "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 12"
+ }
+ },
"node_modules/debug": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
@@ -7223,6 +9413,21 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/dedent": {
+ "version": "1.7.2",
+ "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.7.2.tgz",
+ "integrity": "sha512-WzMx3mW98SN+zn3hgemf4OzdmyNhhhKz5Ay0pUfQiMQ3e1g+xmTJWp/pKdwKVXhdSkAEGIIzqeuWrL3mV/AXbA==",
+ "dev": true,
+ "license": "MIT",
+ "peerDependencies": {
+ "babel-plugin-macros": "^3.1.0"
+ },
+ "peerDependenciesMeta": {
+ "babel-plugin-macros": {
+ "optional": true
+ }
+ }
+ },
"node_modules/deep-extend": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz",
@@ -7239,6 +9444,59 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/deepmerge": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
+ "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/default-browser": {
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.5.0.tgz",
+ "integrity": "sha512-H9LMLr5zwIbSxrmvikGuI/5KGhZ8E2zH3stkMgM5LpOWDutGM2JZaj460Udnf1a+946zc7YBgrqEWwbk7zHvGw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "bundle-name": "^4.1.0",
+ "default-browser-id": "^5.0.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/default-browser-id": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.1.tgz",
+ "integrity": "sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/define-lazy-prop": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz",
+ "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
@@ -7297,6 +9555,16 @@
"url": "https://github.com/sponsors/wooorm"
}
},
+ "node_modules/diff": {
+ "version": "8.0.4",
+ "resolved": "https://registry.npmjs.org/diff/-/diff-8.0.4.tgz",
+ "integrity": "sha512-DPi0FmjiSU5EvQV0++GFDOJ9ASQUVFh5kD+OzOnYdi7n3Wpm9hWWGfB/O2blfHcMVTL5WkQXSnRiK9makhrcnw==",
+ "dev": true,
+ "license": "BSD-3-Clause",
+ "engines": {
+ "node": ">=0.3.1"
+ }
+ },
"node_modules/dijkstrajs": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz",
@@ -7441,6 +9709,17 @@
"node": ">=6.0.0"
}
},
+ "node_modules/dot-case": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz",
+ "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "no-case": "^3.0.4",
+ "tslib": "^2.0.3"
+ }
+ },
"node_modules/dot-prop": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz",
@@ -7643,6 +9922,24 @@
"safe-buffer": "^5.0.1"
}
},
+ "node_modules/eciesjs": {
+ "version": "0.4.18",
+ "resolved": "https://registry.npmjs.org/eciesjs/-/eciesjs-0.4.18.tgz",
+ "integrity": "sha512-wG99Zcfcys9fZux7Cft8BAX/YrOJLJSZ3jyYPfhZHqN2E+Ffx+QXBDsv3gubEgPtV6dTzJMSQUwk1H98/t/0wQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@ecies/ciphers": "^0.2.5",
+ "@noble/ciphers": "^1.3.0",
+ "@noble/curves": "^1.9.7",
+ "@noble/hashes": "^1.8.0"
+ },
+ "engines": {
+ "bun": ">=1",
+ "deno": ">=2",
+ "node": ">=16"
+ }
+ },
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
@@ -7832,6 +10129,19 @@
"node": ">=10.13.0"
}
},
+ "node_modules/entities": {
+ "version": "4.5.0",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
+ "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "engines": {
+ "node": ">=0.12"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/entities?sponsor=1"
+ }
+ },
"node_modules/env-paths": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz",
@@ -8209,6 +10519,20 @@
"url": "https://opencollective.com/eslint"
}
},
+ "node_modules/esprima": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
+ "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "bin": {
+ "esparse": "bin/esparse.js",
+ "esvalidate": "bin/esvalidate.js"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
"node_modules/esquery": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz",
@@ -8256,6 +10580,13 @@
"url": "https://opencollective.com/unified"
}
},
+ "node_modules/estree-walker": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
+ "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/esutils": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
@@ -8275,20 +10606,87 @@
"node": ">= 0.6"
}
},
- "node_modules/eventemitter3": {
- "version": "5.0.4",
- "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.4.tgz",
- "integrity": "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw==",
+ "node_modules/eventemitter3": {
+ "version": "5.0.4",
+ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.4.tgz",
+ "integrity": "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/events-universal": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/events-universal/-/events-universal-1.0.1.tgz",
+ "integrity": "sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "bare-events": "^2.7.0"
+ }
+ },
+ "node_modules/eventsource": {
+ "version": "3.0.7",
+ "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz",
+ "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "eventsource-parser": "^3.0.1"
+ },
+ "engines": {
+ "node": ">=18.0.0"
+ }
+ },
+ "node_modules/eventsource-parser": {
+ "version": "3.0.8",
+ "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.8.tgz",
+ "integrity": "sha512-70QWGkr4snxr0OXLRWsFLeRBIRPuQOvt4s8QYjmUlmlkyTZkRqS7EDVRZtzU3TiyDbXSzaOeF0XUKy8PchzukQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18.0.0"
+ }
+ },
+ "node_modules/execa": {
+ "version": "9.6.1",
+ "resolved": "https://registry.npmjs.org/execa/-/execa-9.6.1.tgz",
+ "integrity": "sha512-9Be3ZoN4LmYR90tUoVu2te2BsbzHfhJyfEiAVfz7N5/zv+jduIfLrV2xdQXOHbaD6KgpGdO9PRPM1Y4Q9QkPkA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@sindresorhus/merge-streams": "^4.0.0",
+ "cross-spawn": "^7.0.6",
+ "figures": "^6.1.0",
+ "get-stream": "^9.0.0",
+ "human-signals": "^8.0.1",
+ "is-plain-obj": "^4.1.0",
+ "is-stream": "^4.0.1",
+ "npm-run-path": "^6.0.0",
+ "pretty-ms": "^9.2.0",
+ "signal-exit": "^4.1.0",
+ "strip-final-newline": "^4.0.0",
+ "yoctocolors": "^2.1.1"
+ },
+ "engines": {
+ "node": "^18.19.0 || >=20.5.0"
+ },
+ "funding": {
+ "url": "https://github.com/sindresorhus/execa?sponsor=1"
+ }
+ },
+ "node_modules/execa/node_modules/get-stream": {
+ "version": "9.0.1",
+ "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-9.0.1.tgz",
+ "integrity": "sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==",
"dev": true,
- "license": "MIT"
- },
- "node_modules/events-universal": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/events-universal/-/events-universal-1.0.1.tgz",
- "integrity": "sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==",
- "license": "Apache-2.0",
+ "license": "MIT",
"dependencies": {
- "bare-events": "^2.7.0"
+ "@sec-ant/readable-stream": "^0.4.1",
+ "is-stream": "^4.0.1"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/expand-template": {
@@ -8350,6 +10748,25 @@
"url": "https://opencollective.com/express"
}
},
+ "node_modules/express-rate-limit": {
+ "version": "8.5.1",
+ "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.5.1.tgz",
+ "integrity": "sha512-5O6KYmyJEpuPJV5hNTXKbAHWRqrzyu+OI3vUnSd2kXFubIVpG7ezpgxQy76Zo5GQZtrQBg86hF+CM/NX+cioiQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ip-address": "^10.2.0"
+ },
+ "engines": {
+ "node": ">= 16"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/express-rate-limit"
+ },
+ "peerDependencies": {
+ "express": ">= 4.11"
+ }
+ },
"node_modules/express/node_modules/cookie-signature": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",
@@ -8418,6 +10835,36 @@
"integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==",
"license": "MIT"
},
+ "node_modules/fast-glob": {
+ "version": "3.3.3",
+ "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz",
+ "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@nodelib/fs.stat": "^2.0.2",
+ "@nodelib/fs.walk": "^1.2.3",
+ "glob-parent": "^5.1.2",
+ "merge2": "^1.3.0",
+ "micromatch": "^4.0.8"
+ },
+ "engines": {
+ "node": ">=8.6.0"
+ }
+ },
+ "node_modules/fast-glob/node_modules/glob-parent": {
+ "version": "5.1.2",
+ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
+ "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "is-glob": "^4.0.1"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+ },
"node_modules/fast-json-stable-stringify": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
@@ -8432,6 +10879,23 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/fast-string-truncated-width": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/fast-string-truncated-width/-/fast-string-truncated-width-3.0.3.tgz",
+ "integrity": "sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/fast-string-width": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/fast-string-width/-/fast-string-width-3.0.2.tgz",
+ "integrity": "sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "fast-string-truncated-width": "^3.0.2"
+ }
+ },
"node_modules/fast-uri": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz",
@@ -8449,6 +10913,26 @@
],
"license": "BSD-3-Clause"
},
+ "node_modules/fast-wrap-ansi": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/fast-wrap-ansi/-/fast-wrap-ansi-0.2.0.tgz",
+ "integrity": "sha512-rLV8JHxTyhVmFYhBJuMujcrHqOT2cnO5Zxj37qROj23CP39GXubJRBUFF0z8KFK77Uc0SukZUf7JZhsVEQ6n8w==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "fast-string-width": "^3.0.2"
+ }
+ },
+ "node_modules/fastq": {
+ "version": "1.20.1",
+ "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz",
+ "integrity": "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "reusify": "^1.0.4"
+ }
+ },
"node_modules/fault": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/fault/-/fault-1.0.4.tgz",
@@ -8491,6 +10975,46 @@
}
}
},
+ "node_modules/fetch-blob": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
+ "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/jimmywarting"
+ },
+ {
+ "type": "paypal",
+ "url": "https://paypal.me/jimmywarting"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "node-domexception": "^1.0.0",
+ "web-streams-polyfill": "^3.0.3"
+ },
+ "engines": {
+ "node": "^12.20 || >= 14.13"
+ }
+ },
+ "node_modules/figures": {
+ "version": "6.1.0",
+ "resolved": "https://registry.npmjs.org/figures/-/figures-6.1.0.tgz",
+ "integrity": "sha512-d+l3qxjSesT4V7v2fh+QnmFnUWv9lSpjarhShNTgBOfA0ttejbQUAlHLitbjkoRiDulW0OPoQPYIGhIC8ohejg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "is-unicode-supported": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/file-entry-cache": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz",
@@ -8550,6 +11074,19 @@
"node": ">=10"
}
},
+ "node_modules/fill-range": {
+ "version": "7.1.1",
+ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
+ "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "to-regex-range": "^5.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/finalhandler": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz",
@@ -8692,6 +11229,19 @@
"node": ">=0.4.x"
}
},
+ "node_modules/formdata-polyfill": {
+ "version": "4.0.10",
+ "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
+ "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "fetch-blob": "^3.1.2"
+ },
+ "engines": {
+ "node": ">=12.20.0"
+ }
+ },
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
@@ -8776,6 +11326,13 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/fuzzysort": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/fuzzysort/-/fuzzysort-3.1.0.tgz",
+ "integrity": "sha512-sR9BNCjBg6LNgwvxlBd0sBABvQitkLzoVY9MYYROQVX/FvfJ4Mai9LsGhDgd8qYdds0bY77VzYd5iuB+v5rwQQ==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/gensync": {
"version": "1.0.0-beta.2",
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
@@ -8842,6 +11399,19 @@
"node": ">=6"
}
},
+ "node_modules/get-own-enumerable-keys": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/get-own-enumerable-keys/-/get-own-enumerable-keys-1.0.0.tgz",
+ "integrity": "sha512-PKsK2FSrQCyxcGHsGrLDcK0lx+0Ke+6e8KFFozA9/fIQLhQzPaRvJFdcz7+Axg3jUH/Mq+NI4xa5u/UT2tQskA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=14.16"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
@@ -8979,6 +11549,16 @@
"dev": true,
"license": "ISC"
},
+ "node_modules/graphql": {
+ "version": "16.14.0",
+ "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.14.0.tgz",
+ "integrity": "sha512-BBvQ/406p+4CZbTpCbVPSxfzrZrbnuWSP1ELYgyS6B+hNeKzgrdB4JczCa5VZUBQrDa9hUngm0KnexY6pJRN5Q==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0"
+ }
+ },
"node_modules/guacamole-common-js": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/guacamole-common-js/-/guacamole-common-js-1.5.0.tgz",
@@ -9122,6 +11702,17 @@
"url": "https://opencollective.com/unified"
}
},
+ "node_modules/headers-polyfill": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/headers-polyfill/-/headers-polyfill-5.0.1.tgz",
+ "integrity": "sha512-1TJ6Fih/b8h5TIcv+1+Hw0PDQWJTKDKzFZzcKOiW1wJza3XoAQlkCuXLbymPYB8+ZQyw8mHvdw560e8zVFIWyA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/set-cookie-parser": "^2.4.10",
+ "set-cookie-parser": "^3.0.1"
+ }
+ },
"node_modules/hermes-estree": {
"version": "0.25.1",
"resolved": "https://registry.npmjs.org/hermes-estree/-/hermes-estree-0.25.1.tgz",
@@ -9156,6 +11747,16 @@
"dev": true,
"license": "CC0-1.0"
},
+ "node_modules/hono": {
+ "version": "4.12.18",
+ "resolved": "https://registry.npmjs.org/hono/-/hono-4.12.18.tgz",
+ "integrity": "sha512-RWzP96k/yv0PQfyXnWjs6zot20TqfpfsNXhOnev8d1InAxubW93L11/oNUc3tQqn2G0bSdAOBpX+2uDFHV7kdQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=16.9.0"
+ }
+ },
"node_modules/hosted-git-info": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz",
@@ -9257,6 +11858,16 @@
"node": ">= 14"
}
},
+ "node_modules/human-signals": {
+ "version": "8.0.1",
+ "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-8.0.1.tgz",
+ "integrity": "sha512-eKCa6bwnJhvxj14kZk5NCPc6Hb6BdsU9DZcOnmQKSnO1VKrfV0zCvtttPZUsBvjmNDn8rpcJfpwSYnHBjc95MQ==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=18.18.0"
+ }
+ },
"node_modules/husky": {
"version": "9.1.7",
"resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz",
@@ -9477,9 +12088,9 @@
}
},
"node_modules/ip-address": {
- "version": "10.1.0",
- "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.1.0.tgz",
- "integrity": "sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==",
+ "version": "10.2.0",
+ "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.2.0.tgz",
+ "integrity": "sha512-/+S6j4E9AHvW9SWMSEY9Xfy66O5PWvVEJ08O0y5JGyEKQpojb0K0GKpz/v5HJ/G0vi3D2sjGK78119oXZeE0qA==",
"license": "MIT",
"engines": {
"node": ">= 12"
@@ -9538,6 +12149,22 @@
"url": "https://github.com/sponsors/wooorm"
}
},
+ "node_modules/is-docker": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz",
+ "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==",
+ "dev": true,
+ "license": "MIT",
+ "bin": {
+ "is-docker": "cli.js"
+ },
+ "engines": {
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@@ -9581,35 +12208,152 @@
"url": "https://github.com/sponsors/wooorm"
}
},
- "node_modules/is-obj": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz",
- "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==",
+ "node_modules/is-in-ssh": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-in-ssh/-/is-in-ssh-1.0.0.tgz",
+ "integrity": "sha512-jYa6Q9rH90kR1vKB6NM7qqd1mge3Fx4Dhw5TVlK1MUBqhEOuCagrEHMevNuCcbECmXZ0ThXkRm+Ymr51HwEPAw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=20"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/is-inside-container": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz",
+ "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "is-docker": "^3.0.0"
+ },
+ "bin": {
+ "is-inside-container": "cli.js"
+ },
+ "engines": {
+ "node": ">=14.16"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/is-interactive": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-2.0.0.tgz",
+ "integrity": "sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/is-node-process": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/is-node-process/-/is-node-process-1.2.0.tgz",
+ "integrity": "sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/is-number": {
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
+ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.12.0"
+ }
+ },
+ "node_modules/is-obj": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz",
+ "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/is-plain-obj": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz",
+ "integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/is-promise": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
+ "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==",
+ "license": "MIT"
+ },
+ "node_modules/is-regexp": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-3.1.0.tgz",
+ "integrity": "sha512-rbku49cWloU5bSMI+zaRaXdQHXnthP6DZ/vLnfdSKyL4zUzuWnomtOEiZZOd+ioQ+avFo/qau3KPTc7Fjy1uPA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/is-stream": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-4.0.1.tgz",
+ "integrity": "sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/is-unicode-supported": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz",
+ "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==",
"dev": true,
"license": "MIT",
"engines": {
- "node": ">=8"
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/is-plain-obj": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz",
- "integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==",
+ "node_modules/is-wsl": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.1.tgz",
+ "integrity": "sha512-e6rvdUCiQCAuumZslxRJWR/Doq4VpPR82kqclvcS0efgt430SlGIk05vdCN58+VrzgtIcfNODjozVielycD4Sw==",
"dev": true,
"license": "MIT",
+ "dependencies": {
+ "is-inside-container": "^1.0.0"
+ },
"engines": {
- "node": ">=12"
+ "node": ">=16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/is-promise": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
- "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==",
- "license": "MIT"
- },
"node_modules/isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
@@ -9749,6 +12493,13 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/json-schema-typed": {
+ "version": "8.0.2",
+ "resolved": "https://registry.npmjs.org/json-schema-typed/-/json-schema-typed-8.0.2.tgz",
+ "integrity": "sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA==",
+ "dev": true,
+ "license": "BSD-2-Clause"
+ },
"node_modules/json-stable-stringify-without-jsonify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
@@ -9847,6 +12598,16 @@
"json-buffer": "3.0.1"
}
},
+ "node_modules/kleur": {
+ "version": "4.1.5",
+ "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz",
+ "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/lazy-val": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/lazy-val/-/lazy-val-1.0.5.tgz",
@@ -10381,6 +13142,36 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/log-symbols": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-6.0.0.tgz",
+ "integrity": "sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "chalk": "^5.3.0",
+ "is-unicode-supported": "^1.3.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/log-symbols/node_modules/is-unicode-supported": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz",
+ "integrity": "sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/log-update": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/log-update/-/log-update-6.1.0.tgz",
@@ -10471,6 +13262,16 @@
"loose-envify": "cli.js"
}
},
+ "node_modules/lower-case": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz",
+ "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "tslib": "^2.0.3"
+ }
+ },
"node_modules/lowlight": {
"version": "1.20.0",
"resolved": "https://registry.npmjs.org/lowlight/-/lowlight-1.20.0.tgz",
@@ -10906,6 +13707,23 @@
}
}
},
+ "node_modules/merge-stream": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
+ "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/merge2": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
+ "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 8"
+ }
+ },
"node_modules/micromark": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz",
@@ -11497,6 +14315,33 @@
],
"license": "MIT"
},
+ "node_modules/micromatch": {
+ "version": "4.0.8",
+ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
+ "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "braces": "^3.0.3",
+ "picomatch": "^2.3.1"
+ },
+ "engines": {
+ "node": ">=8.6"
+ }
+ },
+ "node_modules/micromatch/node_modules/picomatch": {
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
+ "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8.6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/jonschlinkert"
+ }
+ },
"node_modules/mime": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz",
@@ -11535,6 +14380,16 @@
"url": "https://opencollective.com/express"
}
},
+ "node_modules/mimic-fn": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",
+ "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/mimic-function": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz",
@@ -11661,6 +14516,72 @@
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
+ "node_modules/msw": {
+ "version": "2.14.5",
+ "resolved": "https://registry.npmjs.org/msw/-/msw-2.14.5.tgz",
+ "integrity": "sha512-X6G05oX4x0e+CNI55KMdhMmwHCBKf2iwazGr+iwsdoJ94JA1ED7wSXb6V+lLPdqFkmIlPiGYvayqnaNcOzobDA==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "dependencies": {
+ "@inquirer/confirm": "^6.0.11",
+ "@mswjs/interceptors": "^0.41.3",
+ "@open-draft/deferred-promise": "^3.0.0",
+ "@types/statuses": "^2.0.6",
+ "cookie": "^1.1.1",
+ "graphql": "^16.13.2",
+ "headers-polyfill": "^5.0.1",
+ "is-node-process": "^1.2.0",
+ "outvariant": "^1.4.3",
+ "path-to-regexp": "^6.3.0",
+ "picocolors": "^1.1.1",
+ "rettime": "^0.11.11",
+ "statuses": "^2.0.2",
+ "strict-event-emitter": "^0.5.1",
+ "tough-cookie": "^6.0.1",
+ "type-fest": "^5.5.0",
+ "until-async": "^3.0.2",
+ "yargs": "^17.7.2"
+ },
+ "bin": {
+ "msw": "cli/index.js"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/mswjs"
+ },
+ "peerDependencies": {
+ "typescript": ">= 4.8.x"
+ },
+ "peerDependenciesMeta": {
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/msw/node_modules/cookie": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz",
+ "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/msw/node_modules/path-to-regexp": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz",
+ "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/multer": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/multer/-/multer-2.1.1.tgz",
@@ -11723,6 +14644,16 @@
"node": ">= 0.6"
}
},
+ "node_modules/mute-stream": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-3.0.0.tgz",
+ "integrity": "sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw==",
+ "dev": true,
+ "license": "ISC",
+ "engines": {
+ "node": "^20.17.0 || >=22.9.0"
+ }
+ },
"node_modules/nan": {
"version": "2.26.2",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.26.2.tgz",
@@ -11781,6 +14712,17 @@
"react-dom": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc"
}
},
+ "node_modules/no-case": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz",
+ "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "lower-case": "^2.0.2",
+ "tslib": "^2.0.3"
+ }
+ },
"node_modules/node-abi": {
"version": "4.28.0",
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-4.28.0.tgz",
@@ -11812,6 +14754,46 @@
"semver": "^7.3.5"
}
},
+ "node_modules/node-domexception": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
+ "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
+ "deprecated": "Use your platform's native DOMException instead",
+ "dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/jimmywarting"
+ },
+ {
+ "type": "github",
+ "url": "https://paypal.me/jimmywarting"
+ }
+ ],
+ "license": "MIT",
+ "engines": {
+ "node": ">=10.5.0"
+ }
+ },
+ "node_modules/node-fetch": {
+ "version": "3.3.2",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
+ "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "data-uri-to-buffer": "^4.0.0",
+ "fetch-blob": "^3.1.4",
+ "formdata-polyfill": "^4.0.10"
+ },
+ "engines": {
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/node-fetch"
+ }
+ },
"node_modules/node-gyp": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-12.3.0.tgz",
@@ -11896,6 +14878,36 @@
"node": "^20.17.0 || >=22.9.0"
}
},
+ "node_modules/npm-run-path": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-6.0.0.tgz",
+ "integrity": "sha512-9qny7Z9DsQU8Ou39ERsPU4OZQlSTP47ShQzuKZ6PRXpYLtIFgl/DEBYEXKlvcEa+9tHVcK8CF81Y2V72qaZhWA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "path-key": "^4.0.0",
+ "unicorn-magic": "^0.3.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/npm-run-path/node_modules/path-key": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz",
+ "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
@@ -11917,6 +14929,16 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/object-treeify": {
+ "version": "1.1.33",
+ "resolved": "https://registry.npmjs.org/object-treeify/-/object-treeify-1.1.33.tgz",
+ "integrity": "sha512-EFVjAYfzWqWsBMRHPMAXLCDIJnpMhdWAqR7xG6M6a2cs6PMFpl/+Z20w9zDW4vkxOFfddegBKq9Rehd0bxWE7A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 10"
+ }
+ },
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
@@ -11954,6 +14976,27 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/open": {
+ "version": "11.0.0",
+ "resolved": "https://registry.npmjs.org/open/-/open-11.0.0.tgz",
+ "integrity": "sha512-smsWv2LzFjP03xmvFoJ331ss6h+jixfA4UUV/Bsiyuu4YJPfN+FIQGOIiv4w9/+MoHkfkJ22UIaQWRVFRfH6Vw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "default-browser": "^5.4.0",
+ "define-lazy-prop": "^3.0.0",
+ "is-in-ssh": "^1.0.0",
+ "is-inside-container": "^1.0.0",
+ "powershell-utils": "^0.1.0",
+ "wsl-utils": "^0.3.0"
+ },
+ "engines": {
+ "node": ">=20"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/optionator": {
"version": "0.9.4",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
@@ -11972,6 +15015,62 @@
"node": ">= 0.8.0"
}
},
+ "node_modules/ora": {
+ "version": "8.2.0",
+ "resolved": "https://registry.npmjs.org/ora/-/ora-8.2.0.tgz",
+ "integrity": "sha512-weP+BZ8MVNnlCm8c0Qdc1WSWq4Qn7I+9CJGm7Qali6g44e/PUzbjNqJX5NJ9ljlNMosfJvg1fKEGILklK9cwnw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "chalk": "^5.3.0",
+ "cli-cursor": "^5.0.0",
+ "cli-spinners": "^2.9.2",
+ "is-interactive": "^2.0.0",
+ "is-unicode-supported": "^2.0.0",
+ "log-symbols": "^6.0.0",
+ "stdin-discarder": "^0.2.2",
+ "string-width": "^7.2.0",
+ "strip-ansi": "^7.1.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/ora/node_modules/emoji-regex": {
+ "version": "10.6.0",
+ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
+ "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/ora/node_modules/string-width": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
+ "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "emoji-regex": "^10.3.0",
+ "get-east-asian-width": "^1.0.0",
+ "strip-ansi": "^7.1.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/outvariant": {
+ "version": "1.4.3",
+ "resolved": "https://registry.npmjs.org/outvariant/-/outvariant-1.4.3.tgz",
+ "integrity": "sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/p-limit": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
@@ -12079,7 +15178,20 @@
"lines-and-columns": "^1.1.6"
},
"engines": {
- "node": ">=8"
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/parse-ms": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-4.0.0.tgz",
+ "integrity": "sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
@@ -12094,6 +15206,13 @@
"node": ">= 0.8"
}
},
+ "node_modules/path-browserify": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz",
+ "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
@@ -12150,6 +15269,16 @@
"url": "https://opencollective.com/express"
}
},
+ "node_modules/path-type": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
+ "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/pdfjs-dist": {
"version": "5.4.296",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-5.4.296.tgz",
@@ -12205,6 +15334,16 @@
"url": "https://github.com/sponsors/jonschlinkert"
}
},
+ "node_modules/pkce-challenge": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.1.tgz",
+ "integrity": "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=16.20.0"
+ }
+ },
"node_modules/plist": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/plist/-/plist-3.1.0.tgz",
@@ -12258,6 +15397,20 @@
"node": "^10 || ^12 || >=14"
}
},
+ "node_modules/postcss-selector-parser": {
+ "version": "7.1.1",
+ "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.1.tgz",
+ "integrity": "sha512-orRsuYpJVw8LdAwqqLykBj9ecS5/cRHlI5+nvTo8LcCKmzDmqVORXtOIYEEQuL9D4BxtA1lm5isAqzQZCoQ6Eg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "cssesc": "^3.0.0",
+ "util-deprecate": "^1.0.2"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
"node_modules/postcss/node_modules/nanoid": {
"version": "3.3.11",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz",
@@ -12277,6 +15430,19 @@
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
+ "node_modules/powershell-utils": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/powershell-utils/-/powershell-utils-0.1.0.tgz",
+ "integrity": "sha512-dM0jVuXJPsDN6DvRpea484tCUaMiXWjuCn++HGTqUWzGDjv5tZkEZldAJ/UMlqRYGFrD/etByo4/xOuC/snX2A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=20"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/prebuild-install": {
"name": "@mmomtchev/prebuild-install",
"version": "1.0.2",
@@ -12342,6 +15508,22 @@
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
+ "node_modules/pretty-ms": {
+ "version": "9.3.0",
+ "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-9.3.0.tgz",
+ "integrity": "sha512-gjVS5hOP+M3wMm5nmNOucbIrqudzs9v/57bWRHQWLYklXqoXKrVfYW2W9+glfGsqtPgpiz5WwyEEB+ksXIx3gQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "parse-ms": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/prismjs": {
"version": "1.30.0",
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.30.0.tgz",
@@ -12392,6 +15574,30 @@
"node": ">=10"
}
},
+ "node_modules/prompts": {
+ "version": "2.4.2",
+ "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz",
+ "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "kleur": "^3.0.3",
+ "sisteransi": "^1.0.5"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+ },
+ "node_modules/prompts/node_modules/kleur": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
+ "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/prop-types": {
"version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
@@ -12654,6 +15860,197 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/queue-microtask": {
+ "version": "1.2.3",
+ "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
+ "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/feross"
+ },
+ {
+ "type": "patreon",
+ "url": "https://www.patreon.com/feross"
+ },
+ {
+ "type": "consulting",
+ "url": "https://feross.org/support"
+ }
+ ],
+ "license": "MIT"
+ },
+ "node_modules/radix-ui": {
+ "version": "1.4.3",
+ "resolved": "https://registry.npmjs.org/radix-ui/-/radix-ui-1.4.3.tgz",
+ "integrity": "sha512-aWizCQiyeAenIdUbqEpXgRA1ya65P13NKn/W8rWkcN0OPkRDxdBVLWnIEDsS2RpwCK2nobI7oMUSmexzTDyAmA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.3",
+ "@radix-ui/react-accessible-icon": "1.1.7",
+ "@radix-ui/react-accordion": "1.2.12",
+ "@radix-ui/react-alert-dialog": "1.1.15",
+ "@radix-ui/react-arrow": "1.1.7",
+ "@radix-ui/react-aspect-ratio": "1.1.7",
+ "@radix-ui/react-avatar": "1.1.10",
+ "@radix-ui/react-checkbox": "1.3.3",
+ "@radix-ui/react-collapsible": "1.1.12",
+ "@radix-ui/react-collection": "1.1.7",
+ "@radix-ui/react-compose-refs": "1.1.2",
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-context-menu": "2.2.16",
+ "@radix-ui/react-dialog": "1.1.15",
+ "@radix-ui/react-direction": "1.1.1",
+ "@radix-ui/react-dismissable-layer": "1.1.11",
+ "@radix-ui/react-dropdown-menu": "2.1.16",
+ "@radix-ui/react-focus-guards": "1.1.3",
+ "@radix-ui/react-focus-scope": "1.1.7",
+ "@radix-ui/react-form": "0.1.8",
+ "@radix-ui/react-hover-card": "1.1.15",
+ "@radix-ui/react-label": "2.1.7",
+ "@radix-ui/react-menu": "2.1.16",
+ "@radix-ui/react-menubar": "1.1.16",
+ "@radix-ui/react-navigation-menu": "1.2.14",
+ "@radix-ui/react-one-time-password-field": "0.1.8",
+ "@radix-ui/react-password-toggle-field": "0.1.3",
+ "@radix-ui/react-popover": "1.1.15",
+ "@radix-ui/react-popper": "1.2.8",
+ "@radix-ui/react-portal": "1.1.9",
+ "@radix-ui/react-presence": "1.1.5",
+ "@radix-ui/react-primitive": "2.1.3",
+ "@radix-ui/react-progress": "1.1.7",
+ "@radix-ui/react-radio-group": "1.3.8",
+ "@radix-ui/react-roving-focus": "1.1.11",
+ "@radix-ui/react-scroll-area": "1.2.10",
+ "@radix-ui/react-select": "2.2.6",
+ "@radix-ui/react-separator": "1.1.7",
+ "@radix-ui/react-slider": "1.3.6",
+ "@radix-ui/react-slot": "1.2.3",
+ "@radix-ui/react-switch": "1.2.6",
+ "@radix-ui/react-tabs": "1.1.13",
+ "@radix-ui/react-toast": "1.2.15",
+ "@radix-ui/react-toggle": "1.1.10",
+ "@radix-ui/react-toggle-group": "1.1.11",
+ "@radix-ui/react-toolbar": "1.1.11",
+ "@radix-ui/react-tooltip": "1.2.8",
+ "@radix-ui/react-use-callback-ref": "1.1.1",
+ "@radix-ui/react-use-controllable-state": "1.2.2",
+ "@radix-ui/react-use-effect-event": "0.0.2",
+ "@radix-ui/react-use-escape-keydown": "1.1.1",
+ "@radix-ui/react-use-is-hydrated": "0.1.0",
+ "@radix-ui/react-use-layout-effect": "1.1.1",
+ "@radix-ui/react-use-size": "1.1.1",
+ "@radix-ui/react-visually-hidden": "1.2.3"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/radix-ui/node_modules/@radix-ui/react-label": {
+ "version": "2.1.7",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-label/-/react-label-2.1.7.tgz",
+ "integrity": "sha512-YT1GqPSL8kJn20djelMX7/cTRp/Y9w5IZHvfxQTVHrOqa2yMl7i/UfMqKRU5V7mEyKTrUVgJXhNQPVCG8PBLoQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-primitive": "2.1.3"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/radix-ui/node_modules/@radix-ui/react-progress": {
+ "version": "1.1.7",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-progress/-/react-progress-1.1.7.tgz",
+ "integrity": "sha512-vPdg/tF6YC/ynuBIJlk1mm7Le0VgW6ub6J2UWnTQ7/D23KXcPI1qy+0vBkgKgd38RCMJavBXpB83HPNFMTb0Fg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-context": "1.1.2",
+ "@radix-ui/react-primitive": "2.1.3"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/radix-ui/node_modules/@radix-ui/react-separator": {
+ "version": "1.1.7",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-separator/-/react-separator-1.1.7.tgz",
+ "integrity": "sha512-0HEb8R9E8A+jZjvmFCy/J4xhbXy3TV+9XSnGJ3KvTtjlIUy/YQ/p6UYZvi7YbeoeXdyU9+Y3scizK6hkY37baA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-primitive": "2.1.3"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/radix-ui/node_modules/@radix-ui/react-slot": {
+ "version": "1.2.3",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz",
+ "integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-compose-refs": "1.1.2"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
@@ -13116,6 +16513,23 @@
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"license": "MIT"
},
+ "node_modules/recast": {
+ "version": "0.23.11",
+ "resolved": "https://registry.npmjs.org/recast/-/recast-0.23.11.tgz",
+ "integrity": "sha512-YTUo+Flmw4ZXiWfQKGcwwc11KnoRAYgzAE2E7mXKCjSviTKShtxBsN6YUUBB2gtaBzKzeKunxhUwNHQuRryhWA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ast-types": "^0.16.1",
+ "esprima": "~4.0.0",
+ "source-map": "~0.6.1",
+ "tiny-invariant": "^1.3.3",
+ "tslib": "^2.0.1"
+ },
+ "engines": {
+ "node": ">= 4"
+ }
+ },
"node_modules/recharts": {
"version": "3.8.1",
"resolved": "https://registry.npmjs.org/recharts/-/recharts-3.8.1.tgz",
@@ -13345,6 +16759,24 @@
"node": ">= 4"
}
},
+ "node_modules/rettime": {
+ "version": "0.11.11",
+ "resolved": "https://registry.npmjs.org/rettime/-/rettime-0.11.11.tgz",
+ "integrity": "sha512-ILJRqVWBCTlg9r42fFgwVZx1gnFAcQF8mRoMkbgQfIrjEDf9nbBFDFx00oloOa+Q869FUtaYDXZvEfnecQSCoQ==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/reusify": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz",
+ "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "iojs": ">=1.0.0",
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/rfdc": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz",
@@ -13409,6 +16841,43 @@
"node": ">= 18"
}
},
+ "node_modules/run-applescript": {
+ "version": "7.1.0",
+ "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.1.0.tgz",
+ "integrity": "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/run-parallel": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
+ "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/feross"
+ },
+ {
+ "type": "patreon",
+ "url": "https://www.patreon.com/feross"
+ },
+ {
+ "type": "consulting",
+ "url": "https://feross.org/support"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "queue-microtask": "^1.2.2"
+ }
+ },
"node_modules/rxjs": {
"version": "7.8.2",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz",
@@ -13535,6 +17004,13 @@
"integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",
"license": "ISC"
},
+ "node_modules/set-cookie-parser": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-3.1.0.tgz",
+ "integrity": "sha512-kjnC1DXBHcxaOaOXBHBeRtltsDG2nUiUni+jP92M9gYdW12rsmx92UsfpH7o5tDRs7I1ZZPSQJQGv3UaRfCiuw==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/setimmediate": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
@@ -13547,6 +17023,122 @@
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
+ "node_modules/shadcn": {
+ "version": "4.7.0",
+ "resolved": "https://registry.npmjs.org/shadcn/-/shadcn-4.7.0.tgz",
+ "integrity": "sha512-70fwnesNrY1GgeD7Kdzn+3SsYeyfibm8immsA5L68+OusoPTvYF01oWExl8/latKpMpvVXcbgdbbE6VFBJQ38w==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/core": "^7.28.0",
+ "@babel/parser": "^7.28.0",
+ "@babel/plugin-transform-typescript": "^7.28.0",
+ "@babel/preset-typescript": "^7.27.1",
+ "@dotenvx/dotenvx": "^1.48.4",
+ "@modelcontextprotocol/sdk": "^1.26.0",
+ "@types/validate-npm-package-name": "^4.0.2",
+ "browserslist": "^4.26.2",
+ "commander": "^14.0.0",
+ "cosmiconfig": "^9.0.0",
+ "dedent": "^1.6.0",
+ "deepmerge": "^4.3.1",
+ "diff": "^8.0.2",
+ "execa": "^9.6.0",
+ "fast-glob": "^3.3.3",
+ "fs-extra": "^11.3.1",
+ "fuzzysort": "^3.1.0",
+ "https-proxy-agent": "^7.0.6",
+ "kleur": "^4.1.5",
+ "msw": "^2.10.4",
+ "node-fetch": "^3.3.2",
+ "open": "^11.0.0",
+ "ora": "^8.2.0",
+ "postcss": "^8.5.6",
+ "postcss-selector-parser": "^7.1.0",
+ "prompts": "^2.4.2",
+ "recast": "^0.23.11",
+ "stringify-object": "^5.0.0",
+ "tailwind-merge": "^3.0.1",
+ "ts-morph": "^26.0.0",
+ "tsconfig-paths": "^4.2.0",
+ "validate-npm-package-name": "^7.0.1",
+ "zod": "^3.24.1",
+ "zod-to-json-schema": "^3.24.6"
+ },
+ "bin": {
+ "shadcn": "dist/index.js"
+ }
+ },
+ "node_modules/shadcn/node_modules/fs-extra": {
+ "version": "11.3.5",
+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.5.tgz",
+ "integrity": "sha512-eKpRKAovdpZtR1WopLHxlBWvAgPny3c4gX1G5Jhwmmw4XJj0ifSD5qB5TOo8hmA0wlRKDAOAhEE1yVPgs6Fgcg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "graceful-fs": "^4.2.0",
+ "jsonfile": "^6.0.1",
+ "universalify": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=14.14"
+ }
+ },
+ "node_modules/shadcn/node_modules/zod": {
+ "version": "3.25.76",
+ "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
+ "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
+ "dev": true,
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/colinhacks"
+ }
+ },
+ "node_modules/sharp": {
+ "version": "0.34.5",
+ "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.5.tgz",
+ "integrity": "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@img/colour": "^1.0.0",
+ "detect-libc": "^2.1.2",
+ "semver": "^7.7.3"
+ },
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-darwin-arm64": "0.34.5",
+ "@img/sharp-darwin-x64": "0.34.5",
+ "@img/sharp-libvips-darwin-arm64": "1.2.4",
+ "@img/sharp-libvips-darwin-x64": "1.2.4",
+ "@img/sharp-libvips-linux-arm": "1.2.4",
+ "@img/sharp-libvips-linux-arm64": "1.2.4",
+ "@img/sharp-libvips-linux-ppc64": "1.2.4",
+ "@img/sharp-libvips-linux-riscv64": "1.2.4",
+ "@img/sharp-libvips-linux-s390x": "1.2.4",
+ "@img/sharp-libvips-linux-x64": "1.2.4",
+ "@img/sharp-libvips-linuxmusl-arm64": "1.2.4",
+ "@img/sharp-libvips-linuxmusl-x64": "1.2.4",
+ "@img/sharp-linux-arm": "0.34.5",
+ "@img/sharp-linux-arm64": "0.34.5",
+ "@img/sharp-linux-ppc64": "0.34.5",
+ "@img/sharp-linux-riscv64": "0.34.5",
+ "@img/sharp-linux-s390x": "0.34.5",
+ "@img/sharp-linux-x64": "0.34.5",
+ "@img/sharp-linuxmusl-arm64": "0.34.5",
+ "@img/sharp-linuxmusl-x64": "0.34.5",
+ "@img/sharp-wasm32": "0.34.5",
+ "@img/sharp-win32-arm64": "0.34.5",
+ "@img/sharp-win32-ia32": "0.34.5",
+ "@img/sharp-win32-x64": "0.34.5"
+ }
+ },
"node_modules/shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
@@ -13726,6 +17318,13 @@
"node": ">=10"
}
},
+ "node_modules/sisteransi": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz",
+ "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/slice-ansi": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-3.0.0.tgz",
@@ -13752,6 +17351,17 @@
"npm": ">= 3.0.0"
}
},
+ "node_modules/snake-case": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz",
+ "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "dot-case": "^3.0.4",
+ "tslib": "^2.0.3"
+ }
+ },
"node_modules/socks": {
"version": "2.8.7",
"resolved": "https://registry.npmjs.org/socks/-/socks-2.8.7.tgz",
@@ -13874,6 +17484,19 @@
"node": ">= 0.8"
}
},
+ "node_modules/stdin-discarder": {
+ "version": "0.2.2",
+ "resolved": "https://registry.npmjs.org/stdin-discarder/-/stdin-discarder-0.2.2.tgz",
+ "integrity": "sha512-UhDfHmA92YAlNnCfhmq0VeNL5bDbiZGg7sZ2IvPsXubGkiNa9EC+tUTsjBRsYUAz87btI6/1wf4XoVvQ3uRnmQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/streamsearch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
@@ -13893,6 +17516,13 @@
"text-decoder": "^1.1.0"
}
},
+ "node_modules/strict-event-emitter": {
+ "version": "0.5.1",
+ "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz",
+ "integrity": "sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
@@ -13968,6 +17598,37 @@
"url": "https://github.com/sponsors/wooorm"
}
},
+ "node_modules/stringify-object": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-5.0.0.tgz",
+ "integrity": "sha512-zaJYxz2FtcMb4f+g60KsRNFOpVMUyuJgA51Zi5Z1DOTC3S59+OQiVOzE9GZt0x72uBGWKsQIuBKeF9iusmKFsg==",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "dependencies": {
+ "get-own-enumerable-keys": "^1.0.0",
+ "is-obj": "^3.0.0",
+ "is-regexp": "^3.1.0"
+ },
+ "engines": {
+ "node": ">=14.16"
+ },
+ "funding": {
+ "url": "https://github.com/yeoman/stringify-object?sponsor=1"
+ }
+ },
+ "node_modules/stringify-object/node_modules/is-obj": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-3.0.0.tgz",
+ "integrity": "sha512-IlsXEHOjtKhpN8r/tRFj2nDyTmHvcfNeu/nrRIcXE17ROeatXchkojffa1SpdqW4cr/Fj6QkEf/Gn4zf6KKvEQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/strip-ansi": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz",
@@ -13984,6 +17645,29 @@
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
}
},
+ "node_modules/strip-bom": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
+ "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=4"
+ }
+ },
+ "node_modules/strip-final-newline": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-4.0.0.tgz",
+ "integrity": "sha512-aulFJcD6YK8V1G7iRB5tigAP4TsHBZZrOV8pjV++zdUwmeV8uzbY7yn6h9MswN62adStNZFuCIx4haBnRuMDaw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/strip-json-comments": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
@@ -14049,6 +17733,26 @@
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
+ "node_modules/svg-parser": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/svg-parser/-/svg-parser-2.0.4.tgz",
+ "integrity": "sha512-e4hG1hRwoOdRb37cIMSgzNsxyzKfayW6VOflrwvR+/bzrkyxY/31WkbgnQpgtrNp1SdpJvpUAGTa/ZoiPNDuRQ==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/tagged-tag": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/tagged-tag/-/tagged-tag-1.0.0.tgz",
+ "integrity": "sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=20"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/tailwind-merge": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.5.0.tgz",
@@ -14217,6 +17921,26 @@
"url": "https://github.com/sponsors/SuperchupuDev"
}
},
+ "node_modules/tldts": {
+ "version": "7.0.30",
+ "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.0.30.tgz",
+ "integrity": "sha512-ELrFxuqsDdHUwoh0XxDbxuLD3Wnz49Z57IFvTtvWy1hJdcMZjXLIuonjilCiWHlT2GbE4Wlv1wKVTzDFnXH1aw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "tldts-core": "^7.0.30"
+ },
+ "bin": {
+ "tldts": "bin/cli.js"
+ }
+ },
+ "node_modules/tldts-core": {
+ "version": "7.0.30",
+ "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.0.30.tgz",
+ "integrity": "sha512-uiHN8PIB1VmWyS98eZYja4xzlYqeFZVjb4OuYlJQnZAuJhMw4PbKQOKgHKhBdJR3FE/t5mUQ1Kd80++B+qhD1Q==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/tmp": {
"version": "0.2.5",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.5.tgz",
@@ -14237,6 +17961,19 @@
"tmp": "^0.2.0"
}
},
+ "node_modules/to-regex-range": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
+ "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "is-number": "^7.0.0"
+ },
+ "engines": {
+ "node": ">=8.0"
+ }
+ },
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
@@ -14246,6 +17983,19 @@
"node": ">=0.6"
}
},
+ "node_modules/tough-cookie": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.1.tgz",
+ "integrity": "sha512-LktZQb3IeoUWB9lqR5EWTHgW/VTITCXg4D21M+lvybRVdylLrRMnqaIONLVb5mav8vM19m44HIcGq4qASeu2Qw==",
+ "dev": true,
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "tldts": "^7.0.5"
+ },
+ "engines": {
+ "node": ">=16"
+ }
+ },
"node_modules/tree-kill": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
@@ -14301,6 +18051,32 @@
"typescript": ">=4.8.4"
}
},
+ "node_modules/ts-morph": {
+ "version": "26.0.0",
+ "resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-26.0.0.tgz",
+ "integrity": "sha512-ztMO++owQnz8c/gIENcM9XfCEzgoGphTv+nKpYNM1bgsdOVC/jRZuEBf6N+mLLDNg68Kl+GgUZfOySaRiG1/Ug==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@ts-morph/common": "~0.27.0",
+ "code-block-writer": "^13.0.3"
+ }
+ },
+ "node_modules/tsconfig-paths": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz",
+ "integrity": "sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "json5": "^2.2.2",
+ "minimist": "^1.2.6",
+ "strip-bom": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
@@ -14319,6 +18095,16 @@
"node": "*"
}
},
+ "node_modules/tw-animate-css": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/tw-animate-css/-/tw-animate-css-1.4.0.tgz",
+ "integrity": "sha512-7bziOlRqH0hJx80h/3mbicLW7o8qLsH5+RaLR2t+OHM3D0JlWGODQKQ4cxbK7WlvmUxpcj6Kgu6EKqjrGFe3QQ==",
+ "dev": true,
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/Wombosvideo"
+ }
+ },
"node_modules/tweetnacl": {
"version": "0.14.5",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
@@ -14338,6 +18124,22 @@
"node": ">= 0.8.0"
}
},
+ "node_modules/type-fest": {
+ "version": "5.6.0",
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-5.6.0.tgz",
+ "integrity": "sha512-8ZiHFm91orbSAe2PSAiSVBVko18pbhbiB3U9GglSzF/zCGkR+rxpHx6sEMCUm4kxY4LjDIUGgCfUMtwfZfjfUA==",
+ "dev": true,
+ "license": "(MIT OR CC0-1.0)",
+ "dependencies": {
+ "tagged-tag": "^1.0.0"
+ },
+ "engines": {
+ "node": ">=20"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/type-is": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz",
@@ -14412,6 +18214,19 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/unicorn-magic": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.3.0.tgz",
+ "integrity": "sha512-+QBBXBCvifc56fsbuxZQ6Sic3wqqc3WWaqxs58gvJrcOuN83HGTCwz3oS5phzU9LthRNE9VrJCFCLUgHeeFnfA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/unified": {
"version": "11.0.5",
"resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz",
@@ -14524,6 +18339,16 @@
"node": ">= 0.8"
}
},
+ "node_modules/until-async": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/until-async/-/until-async-3.0.2.tgz",
+ "integrity": "sha512-IiSk4HlzAMqTUseHHe3VhIGyuFmN90zMTpD3Z3y8jeQbzLIq500MVM7Jq2vUAnTKAFPJrqwkzr6PoTcPhGcOiw==",
+ "dev": true,
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/kettanaito"
+ }
+ },
"node_modules/update-browserslist-db": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz",
@@ -14633,6 +18458,16 @@
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
"license": "MIT"
},
+ "node_modules/validate-npm-package-name": {
+ "version": "7.0.2",
+ "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-7.0.2.tgz",
+ "integrity": "sha512-hVDIBwsRruT73PbK7uP5ebUt+ezEtCmzZz3F59BSr2F6OVFnJ/6h8liuvdLrQ88Xmnk6/+xGGuq+pG9WwTuy3A==",
+ "dev": true,
+ "license": "ISC",
+ "engines": {
+ "node": "^20.17.0 || >=22.9.0"
+ }
+ },
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
@@ -14797,6 +18632,21 @@
}
}
},
+ "node_modules/vite-plugin-svgr": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/vite-plugin-svgr/-/vite-plugin-svgr-5.2.0.tgz",
+ "integrity": "sha512-qj2eAKF8C6PZWemVTvQA0xgQIcP1hHU6Buh7fl6BhvayWwnuxE+z417miKxeDvRWbDrupQ1oK99hfxElopJ3sQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@rollup/pluginutils": "^5.3.0",
+ "@svgr/core": "^8.1.0",
+ "@svgr/plugin-jsx": "^8.1.0"
+ },
+ "peerDependencies": {
+ "vite": ">=3.0.0"
+ }
+ },
"node_modules/void-elements": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz",
@@ -14824,6 +18674,16 @@
"loose-envify": "^1.0.0"
}
},
+ "node_modules/web-streams-polyfill": {
+ "version": "3.3.3",
+ "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz",
+ "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 8"
+ }
+ },
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@@ -14939,6 +18799,23 @@
}
}
},
+ "node_modules/wsl-utils": {
+ "version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/wsl-utils/-/wsl-utils-0.3.1.tgz",
+ "integrity": "sha512-g/eziiSUNBSsdDJtCLB8bdYEUMj4jR7AGeUo96p/3dTafgjHhpF4RiCFPiRILwjQoDXx5MqkBr4fwWtR3Ky4Wg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "is-wsl": "^3.1.0",
+ "powershell-utils": "^0.1.0"
+ },
+ "engines": {
+ "node": ">=20"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/xmlbuilder": {
"version": "15.1.1",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-15.1.1.tgz",
@@ -15035,6 +18912,35 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/yocto-spinner": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/yocto-spinner/-/yocto-spinner-1.2.0.tgz",
+ "integrity": "sha512-Yw0hUB6UA3o4YUgKy3oSe9a4cxoaZ9sBfYDw+JSxo6Id0KoJGoxzPA24qqUXYKBWABs/zDSGTz9kww7t3F0XGw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "yoctocolors": "^2.1.1"
+ },
+ "engines": {
+ "node": ">=18.19"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/yoctocolors": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/yoctocolors/-/yoctocolors-2.1.2.tgz",
+ "integrity": "sha512-CzhO+pFNo8ajLM2d2IW/R93ipy99LWjtwblvC1RsoSUMZgyLbYFr221TnSNT7GjGdYui6P459mw9JH/g/zW2ug==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/zod": {
"version": "4.3.6",
"resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz",
@@ -15045,6 +18951,16 @@
"url": "https://github.com/sponsors/colinhacks"
}
},
+ "node_modules/zod-to-json-schema": {
+ "version": "3.25.2",
+ "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.2.tgz",
+ "integrity": "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==",
+ "dev": true,
+ "license": "ISC",
+ "peerDependencies": {
+ "zod": "^3.25.28 || ^4"
+ }
+ },
"node_modules/zod-validation-error": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/zod-validation-error/-/zod-validation-error-4.0.2.tgz",
diff --git a/package.json b/package.json
index aee21c22d..17e1f3e44 100644
--- a/package.json
+++ b/package.json
@@ -77,6 +77,7 @@
"@electron/notarize": "^3.1.1",
"@electron/rebuild": "^4.0.4",
"@eslint/js": "^9.0.0",
+ "@fontsource-variable/jetbrains-mono": "^5.2.8",
"@hookform/resolvers": "^5.2.2",
"@monaco-editor/react": "^4.7.0",
"@radix-ui/react-accordion": "^1.2.12",
@@ -140,6 +141,7 @@
"lucide-react": "^1.11.0",
"next-themes": "^0.4.6",
"prettier": "3.8.3",
+ "radix-ui": "^1.4.3",
"react": "^19.2.5",
"react-cytoscapejs": "^2.0.0",
"react-dom": "^19.2.5",
@@ -157,12 +159,16 @@
"react-xtermjs": "^1.0.10",
"recharts": "^3.8.1",
"remark-gfm": "^4.0.1",
+ "shadcn": "^4.7.0",
+ "sharp": "^0.34.5",
"sonner": "^2.0.7",
"tailwind-merge": "^3.5.0",
"tailwindcss": "^4.2.4",
+ "tw-animate-css": "^1.4.0",
"typescript": "~6.0.3",
"typescript-eslint": "^8.59.0",
"vite": "^8.0.10",
+ "vite-plugin-svgr": "^5.2.0",
"zod": "^4.3.6"
},
"lint-staged": {
diff --git a/public/favicon.ico b/public/favicon.ico
index 9b2703245..438484bb9 100644
Binary files a/public/favicon.ico and b/public/favicon.ico differ
diff --git a/public/full-icon.png b/public/full-icon.png
index bac3267a7..574578cc2 100644
Binary files a/public/full-icon.png and b/public/full-icon.png differ
diff --git a/public/icon-mac.png b/public/icon-mac.png
index 19f7681e8..56ae3e4a9 100644
Binary files a/public/icon-mac.png and b/public/icon-mac.png differ
diff --git a/public/icon.icns b/public/icon.icns
index 7e6b7329f..1a3cc8932 100644
Binary files a/public/icon.icns and b/public/icon.icns differ
diff --git a/public/icon.ico b/public/icon.ico
index 9b2703245..00594ef7a 100644
Binary files a/public/icon.ico and b/public/icon.ico differ
diff --git a/public/icon.png b/public/icon.png
index ecc08b71c..574578cc2 100644
Binary files a/public/icon.png and b/public/icon.png differ
diff --git a/public/icon.svg b/public/icon.svg
index 8ffb60cfb..4ee301a74 100644
--- a/public/icon.svg
+++ b/public/icon.svg
@@ -1,29 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="1024" height="1024">
-<path d="M0 0 C2.73400004 -0.002639 5.46799221 -0.00826382 8.20198786 -0.01373065 C14.12976744 -0.02399057 20.05751439 -0.02688145 25.98530197 -0.02481842 C34.80090688 -0.02175792 43.61647591 -0.03011562 52.43207382 -0.04056767 C69.09746094 -0.05987554 85.76283572 -0.06553472 102.42823271 -0.06668179 C115.30380751 -0.0676022 128.17937749 -0.07172576 141.05495071 -0.07808304 C144.76625176 -0.07987824 148.47755281 -0.08165787 152.18885386 -0.08343279 C153.11160075 -0.08387489 154.03434764 -0.08431699 154.98505655 -0.08477248 C180.92924305 -0.09707542 206.87342788 -0.10497418 232.81761742 -0.10408592 C233.79511593 -0.10405476 234.77261444 -0.10402361 235.77973412 -0.10399151 C240.73366138 -0.1038253 245.68758864 -0.10362722 250.6415159 -0.10342209 C251.6253128 -0.1033822 252.60910971 -0.10334231 253.62271865 -0.10330121 C255.61219571 -0.10322034 257.60167278 -0.10313674 259.59114985 -0.10305043 C290.52844692 -0.10182554 321.46570011 -0.11682888 352.40298462 -0.14419556 C387.19411554 -0.17495891 421.98521764 -0.19212546 456.77636302 -0.19026911 C460.49080761 -0.19011986 464.20525221 -0.19002244 467.91969681 -0.18996048 C469.29149007 -0.18992552 469.29149007 -0.18992552 470.69099632 -0.18988985 C485.3682461 -0.18982846 500.04545761 -0.20256613 514.72269603 -0.21982501 C529.49125025 -0.23683126 544.25974885 -0.23871645 559.02830748 -0.22560637 C567.78591009 -0.2182501 576.54334301 -0.2217749 585.30092741 -0.24149105 C591.16987765 -0.25357988 597.03870633 -0.25080234 602.90765122 -0.23655005 C606.23912509 -0.22886096 609.57001068 -0.22929279 612.90150099 -0.24346475 C669.26549491 -0.4671585 719.76924989 19.84001892 760.15640259 59.26742554 C772.42844891 71.50006259 782.52075649 85.25415658 791.15640259 100.26742554 C791.50912231 100.87183472 791.86184204 101.4762439 792.22525024 102.09896851 C811.88962254 136.11043906 817.64194919 173.04055363 817.54408264 211.76298523 C817.54660703 214.48240629 817.55362534 217.2018119 817.56040245 219.92122525 C817.57267741 225.79546941 817.57402194 231.66963359 817.56785202 237.54388618 C817.5587013 246.27976136 817.56684044 255.01556352 817.57814326 263.75143313 C817.59774407 279.36124531 817.60017028 294.97102417 817.59494806 310.58084573 C817.59037982 324.24363644 817.59100383 337.90641403 817.59678841 351.56920433 C817.59754529 353.40633989 817.59830127 355.24347545 817.59905635 357.08061102 C817.60020162 359.84946233 817.60135151 362.61831363 817.60251559 365.38716494 C817.61321044 391.1073786 817.61795627 416.82758792 817.61004543 442.54780293 C817.60959967 444.00013607 817.60959967 444.00013607 817.60914491 445.48180929 C817.60669631 453.34299581 817.60408455 461.20418229 817.60146077 469.06536876 C817.5913601 499.72185315 817.59971449 530.37828276 817.62295532 561.03475952 C817.64906362 595.52892829 817.6618664 630.02306408 817.65476757 664.51724309 C817.65405158 668.19956187 817.65337718 671.88188065 817.65272713 675.56419945 C817.65255732 676.47078703 817.65238751 677.37737461 817.65221255 678.31143455 C817.64991573 691.95846782 817.65785694 705.60547034 817.6710186 719.25249672 C817.685971 734.78338018 817.68671805 750.31419187 817.66894769 765.84507386 C817.65942821 774.52050334 817.66072981 783.19576513 817.67818238 791.8711832 C817.68875186 797.68511687 817.68446055 803.49892416 817.66870234 809.31284558 C817.66015583 812.61276916 817.65970357 815.91210367 817.67297166 819.21204952 C817.88436667 875.86359058 797.79480503 926.66414093 758.15640259 967.26742554 C745.93892953 979.52425902 732.17979891 989.68607442 717.15640259 998.26742554 C716.4925354 998.65253296 715.82866821 999.03764038 715.14468384 999.43441772 C695.23288262 1010.86828901 673.71271691 1018.1589933 651.15640259 1022.26742554 C650.28498416 1022.44004335 649.41356574 1022.61266116 648.51574069 1022.79050982 C635.90814607 1024.96518969 623.18430579 1024.55138623 610.43305969 1024.53485107 C607.6999227 1024.53748912 604.9667936 1024.54311399 602.233661 1024.54858172 C596.30466868 1024.55884731 590.375709 1024.56173152 584.44670868 1024.55966949 C575.62928442 1024.55661047 566.81189608 1024.5649635 557.99447882 1024.57541875 C541.32568596 1024.59473226 524.65690543 1024.60038602 507.9881027 1024.60153286 C495.10964357 1024.60245312 482.23118926 1024.60657588 469.3527317 1024.61293411 C465.64116775 1024.61472931 461.92960378 1024.61650893 458.21803981 1024.61828387 C457.29523567 1024.61872596 456.37243152 1024.61916806 455.42166361 1024.61962355 C429.47354925 1024.6319276 403.52543655 1024.63982514 377.57731915 1024.638937 C376.59955462 1024.63890584 375.62179009 1024.63887468 374.61439634 1024.63884258 C369.65907825 1024.63867637 364.70376016 1024.63847829 359.74844208 1024.63827316 C358.76436283 1024.63823327 357.78028358 1024.63819338 356.76638375 1024.63815228 C354.77633502 1024.63807141 352.78628628 1024.63798781 350.79623754 1024.6379015 C319.85239029 1024.63667671 288.9085869 1024.6516778 257.9647522 1024.67904663 C223.16886751 1024.70981007 188.37301164 1024.7269765 153.5771125 1024.72512019 C149.86209063 1024.72497094 146.14706876 1024.72487352 142.43204689 1024.72481155 C141.51737155 1024.72478825 140.60269621 1024.72476494 139.66030344 1024.72474092 C124.9802092 1024.72467953 110.30015323 1024.73741769 95.62007035 1024.75467608 C80.84803346 1024.77168253 66.07605218 1024.77356739 51.30401089 1024.76045744 C42.54419164 1024.75310113 33.78454202 1024.75662608 25.02474097 1024.77634212 C19.15427773 1024.78843094 13.28393602 1024.78565343 7.41347812 1024.77140112 C4.08112251 1024.76371198 0.74935502 1024.76414397 -2.58301703 1024.77831583 C-58.17948783 1024.99890318 -107.63682601 1005.62367608 -147.84359741 967.26742554 C-148.69566772 966.46820679 -149.54773804 965.66898804 -150.42562866 964.84555054 C-161.62210289 954.0546179 -170.61436374 941.40710729 -178.84359741 928.26742554 C-179.22225952 927.66801147 -179.60092163 927.06859741 -179.99105835 926.45101929 C-189.74850728 910.77816984 -196.55066499 893.25794086 -201.28109741 875.45492554 C-201.50370239 874.62275513 -201.72630737 873.79058472 -201.95565796 872.93319702 C-206.57232769 854.29052646 -207.27904072 835.90479501 -207.23127747 816.77786255 C-207.23379985 814.03470615 -207.24081768 811.29156511 -207.24759728 808.54841638 C-207.25988714 802.61614236 -207.26121016 796.68394752 -207.25504684 790.75166512 C-207.2459059 781.92952184 -207.25402759 773.10745099 -207.26533808 764.28531324 C-207.28495075 748.52217098 -207.28736278 732.7590617 -207.28214288 716.99591016 C-207.27757646 703.19839252 -207.27819639 689.40088789 -207.28398323 675.60337067 C-207.28474011 673.74884938 -207.28549609 671.89432809 -207.28625118 670.0398068 C-207.28739644 667.2448181 -207.28854632 664.4498294 -207.28971042 661.65484071 C-207.30040722 635.68742287 -207.30514913 609.72000934 -207.29724026 583.75259018 C-207.29694308 582.77481367 -207.29664591 581.79703716 -207.29633973 580.78963106 C-207.29389108 572.85064179 -207.29127935 564.91165257 -207.2886556 556.97266336 C-207.27855556 526.01441895 -207.2869073 495.05622879 -207.31015015 464.09799194 C-207.33625511 429.27167309 -207.34906203 394.44538689 -207.3419624 359.61905789 C-207.3412464 355.90161976 -207.340572 352.18418162 -207.33992195 348.46674347 C-207.33975214 347.55149656 -207.33958233 346.63624965 -207.33940738 345.69326798 C-207.33710991 331.91180969 -207.34505494 318.13038183 -207.35821342 304.34893036 C-207.37316185 288.66535722 -207.37391821 272.98185516 -207.35614251 257.29828349 C-207.34661866 248.53600496 -207.34793372 239.77389246 -207.3653772 231.01162522 C-207.37593906 225.14100592 -207.37166581 219.27051186 -207.35589717 213.39990471 C-207.34734263 210.06675089 -207.34691318 206.73418102 -207.36016648 203.40100488 C-207.56778181 147.1441485 -186.87401064 96.4167714 -147.28109741 56.45492554 C-141.76524049 50.99827426 -136.02853989 45.96221348 -129.84359741 41.26742554 C-129.28349976 40.83140015 -128.7234021 40.39537476 -128.14633179 39.94613647 C-90.51182464 10.86125152 -46.64951227 -0.06056457 0 0 Z " fill="#343434" transform="translate(206.84359741210938,-0.267425537109375)"/>
-<path d="M0 0 C1.40423182 0.00051035 1.40423182 0.00051035 2.83683196 0.00103101 C3.82595598 -0.0025196 4.81508001 -0.00607022 5.83417749 -0.00972843 C9.19305859 -0.02050902 12.55190967 -0.0240525 15.91080561 -0.02766219 C18.32564927 -0.0338193 20.74049189 -0.04039487 23.15533337 -0.04735598 C29.12496578 -0.0633399 35.09459078 -0.07451946 41.06423627 -0.08363459 C46.02947164 -0.09137043 50.99469774 -0.10144125 55.95992556 -0.11302939 C57.03288597 -0.1155315 57.03288597 -0.1155315 58.12752234 -0.11808417 C59.58627278 -0.12149296 61.04502321 -0.12490448 62.50377363 -0.12831869 C82.24770504 -0.17404715 101.99165615 -0.20448455 121.73561946 -0.23248091 C122.54409117 -0.2336359 123.35256289 -0.23479089 124.18553374 -0.23598088 C156.18819906 -0.28168636 188.19087249 -0.32132586 220.19355964 -0.34800582 C228.12660644 -0.35462936 236.05965303 -0.3615028 243.99269953 -0.36846724 C245.30758824 -0.36961202 245.30758824 -0.36961202 246.64904036 -0.37077993 C275.04965913 -0.39570526 303.45013113 -0.44916217 331.85067361 -0.51848551 C361.0453603 -0.58961736 390.23996808 -0.63467261 419.4347424 -0.64598659 C423.56094367 -0.64759145 427.68714476 -0.64947904 431.81334582 -0.65153113 C432.62541303 -0.65192401 433.43748025 -0.6523169 434.27415556 -0.65272169 C447.33054215 -0.65977305 460.38672234 -0.69395932 473.44302996 -0.73819214 C486.57766984 -0.78206641 499.71208526 -0.79644882 512.8467916 -0.78109888 C520.64442365 -0.77285756 528.4412709 -0.78672339 536.23877507 -0.83281821 C542.07168701 -0.86481521 547.90404453 -0.85466238 553.73700174 -0.8285531 C556.08920992 -0.82449162 558.44148962 -0.83384796 560.79357401 -0.8583189 C579.09200025 -1.03720424 592.84786818 2.26405378 606.57546321 15.14642534 C611.04162409 19.56596659 611.04162409 19.56596659 612.57546321 22.14642534 C612.57546321 23.46642534 612.57546321 24.78642534 612.57546321 26.14642534 C613.23546321 26.14642534 613.89546321 26.14642534 614.57546321 26.14642534 C619.06125557 33.80380806 619.31056144 41.10884428 619.26296321 49.83392534 C619.26159358 50.50217332 619.26022395 51.17042131 619.25881281 51.85891923 C619.18815119 62.55403817 618.32559764 70.52408381 611.57546321 79.14642534 C610.89226008 80.02943315 610.20905696 80.91244096 609.50515071 81.82220659 C604.63307267 87.62979771 599.46895511 91.97760101 592.57546321 95.20892534 C591.05952571 95.93789018 591.05952571 95.93789018 589.51296321 96.68158159 C576.2689793 101.93707205 563.08325643 101.55732802 549.06838313 101.48700151 C546.66384639 101.48608132 544.25930885 101.486485 541.85477248 101.48809728 C535.44511442 101.48877152 529.03562612 101.47144822 522.62600794 101.45026597 C516.60024343 101.43311673 510.57451914 101.43237312 504.54872981 101.43023881 C486.953452 101.41452862 469.35820543 101.3726449 451.76296321 101.33392534 C412.43108821 101.27205034 373.09921321 101.21017534 332.57546321 101.14642534 C332.57546321 234.13642534 332.57546321 367.12642534 332.57546321 504.14642534 C311.12546321 504.14642534 289.67546321 504.14642534 267.57546321 504.14642534 C267.90546321 537.47642534 268.23546321 570.80642534 268.57546321 605.14642534 C300.25546321 605.64142534 300.25546321 605.64142534 332.57546321 606.14642534 C332.67858821 613.61267534 332.78171321 621.07892534 332.88796321 628.77142534 C332.95624323 632.26083696 332.95624323 632.26083696 333.02590266 635.82074174 C333.20342124 651.39816119 331.30646416 663.44206298 321.57546321 676.14642534 C320.89483821 677.11580034 320.21421321 678.08517534 319.51296321 679.08392534 C317.34689201 681.38974306 315.57653653 682.22943071 312.57546321 683.14642534 C312.57546321 683.80642534 312.57546321 684.46642534 312.57546321 685.14642534 C311.91546321 685.14642534 311.25546321 685.14642534 310.57546321 685.14642534 C310.57546321 685.80642534 310.57546321 686.46642534 310.57546321 687.14642534 C309.20261164 687.67042924 309.20261164 687.67042924 307.80202571 688.20501909 C306.61351008 688.66005815 305.42499446 689.11509721 304.20046321 689.58392534 C303.01710383 690.03638627 301.83374446 690.48884721 300.61452571 690.95501909 C297.71510128 692.03914445 297.71510128 692.03914445 295.57546321 693.14642534 C285.24933309 693.80324905 276.05684124 693.82446208 266.57546321 689.14642534 C266.57546321 688.48642534 266.57546321 687.82642534 266.57546321 687.14642534 C265.51005305 687.04201127 265.51005305 687.04201127 264.42311946 686.93548784 C257.70869754 685.07497587 251.36435061 678.07379091 247.88796321 672.14642534 C246.57546321 669.14642534 246.57546321 669.14642534 246.57546321 667.14642534 C245.91546321 667.14642534 245.25546321 667.14642534 244.57546321 667.14642534 C241.81043885 659.58869209 241.42919517 652.37018368 241.45520869 644.4210988 C241.45392705 642.97880046 241.45392705 642.97880046 241.45261952 641.50736478 C241.45097643 638.295317 241.45646692 635.0833218 241.46193781 631.87127885 C241.46221996 629.56485695 241.46206141 627.25843496 241.46149531 624.95201311 C241.46120842 618.69642091 241.46708767 612.44084789 241.47406927 606.18526015 C241.48032082 599.6456184 241.48090803 593.10597622 241.48209468 586.56633195 C241.484683 575.59180566 241.49109564 564.61728609 241.50002375 553.64276323 C241.5092085 542.34100577 241.51628413 531.03925023 241.52053156 519.73748979 C241.52092565 518.69181294 241.52092565 518.69181294 241.5213277 517.6250113 C241.52263277 514.12763308 241.52389647 510.63025485 241.5251396 507.1328766 C241.53549942 478.13738828 241.55318111 449.1419069 241.57546321 420.14642534 C243.02952571 419.71330034 243.02952571 419.71330034 244.51296321 419.27142534 C247.68210524 418.50427852 247.68210524 418.50427852 248.57546321 416.14642534 C251.63693217 414.17833815 253.97711288 413.94651699 257.57546321 414.14642534 C257.57546321 413.48642534 257.57546321 412.82642534 257.57546321 412.14642534 C258.29991633 411.89248002 259.02436946 411.63853471 259.77077571 411.37689409 C265.85235678 409.22399523 265.85235678 409.22399523 271.70046321 406.52142534 C275.54248143 404.68393836 279.41159885 403.94245823 283.57546321 403.14642534 C284.58608821 402.94017534 285.59671321 402.73392534 286.63796321 402.52142534 C287.27733821 402.39767534 287.91671321 402.27392534 288.57546321 402.14642534 C288.57546321 401.48642534 288.57546321 400.82642534 288.57546321 400.14642534 C291.94643704 398.64821474 293.7798844 398.14642534 297.57546321 398.14642534 C297.57546321 397.48642534 297.57546321 396.82642534 297.57546321 396.14642534 C300.66356016 394.38179851 301.80858456 394.14642534 305.57546321 394.14642534 C305.08046321 346.13142534 305.08046321 346.13142534 304.57546321 297.14642534 C299.09563082 294.69140107 299.09563082 294.69140107 293.57546321 293.14642534 C293.57546321 292.48642534 293.57546321 291.82642534 293.57546321 291.14642534 C292.53518977 290.9724019 292.53518977 290.9724019 291.47390071 290.79486284 C288.22920215 290.06895993 285.29570136 288.98452343 282.20046321 287.77142534 C281.05835383 287.32412065 279.91624446 286.87681596 278.73952571 286.41595659 C275.32490212 285.04589157 271.94599691 283.62103383 268.57546321 282.14642534 C266.91124971 281.47365818 265.24559738 280.80435698 263.57546321 280.14642534 C263.57546321 279.48642534 263.57546321 278.82642534 263.57546321 278.14642534 C262.70147883 278.15996049 262.70147883 278.15996049 261.80983821 278.17376909 C254.02441654 277.89222082 247.20210248 275.69462839 241.57546321 270.14642534 C239.81945014 264.7348211 240.05358023 259.45101517 240.21315852 253.83807573 C240.21654601 252.17204226 240.21463827 250.50599089 240.20784846 248.83996782 C240.20441125 244.32861658 240.27484312 239.82111004 240.35873595 235.31065115 C240.43386221 230.59297706 240.44080895 225.87521016 240.45504084 221.15703019 C240.49230774 212.22804954 240.59073407 203.30083646 240.71123472 194.37263349 C240.84546431 184.20604674 240.91136676 174.03937459 240.97157994 163.87212202 C241.09694027 142.96257066 241.30794596 122.05460943 241.57546321 101.14642534 C239.71905081 101.15195609 239.71905081 101.15195609 237.82513514 101.15759858 C208.3908514 101.24438861 178.95659693 101.31026653 149.5222168 101.35068665 C145.8926672 101.35568897 142.26311787 101.36086631 138.63356867 101.3661519 C137.91104625 101.36720114 137.18852383 101.36825038 136.44410679 101.36933142 C124.77309362 101.38669653 113.10215994 101.41821252 101.4311938 101.45503652 C89.4394299 101.49255475 77.4477074 101.51468408 65.45588723 101.52277932 C58.7270936 101.52775649 51.99849078 101.54014547 45.26975337 101.56934556 C38.9266814 101.59664705 32.58386202 101.6048406 26.24073687 101.59885606 C23.92213589 101.59994973 21.6035258 101.60781507 19.28497592 101.62324724 C-8.1241533 101.79661708 -8.1241533 101.79661708 -19.42453679 96.14642534 C-19.42453679 95.48642534 -19.42453679 94.82642534 -19.42453679 94.14642534 C-20.16961492 94.04330034 -20.91469304 93.94017534 -21.68234929 93.83392534 C-30.16122094 91.70816834 -36.64753713 81.74605527 -40.93625554 74.64251909 C-45.09326558 67.22183929 -45.66991858 62.33100813 -45.71970281 53.72748002 C-45.73114038 52.35432764 -45.75145974 50.98121676 -45.78122625 49.6083394 C-45.96921564 40.93352147 -45.5065809 33.90680758 -41.42453679 26.14642534 C-40.76453679 26.14642534 -40.10453679 26.14642534 -39.42453679 26.14642534 C-39.28016179 25.36267534 -39.13578679 24.57892534 -38.98703679 23.77142534 C-38.42453679 21.14642534 -38.42453679 21.14642534 -37.42453679 19.14642534 C-36.76453679 19.14642534 -36.10453679 19.14642534 -35.42453679 19.14642534 C-35.15641179 18.54830034 -34.88828679 17.95017534 -34.61203679 17.33392534 C-33.42536273 15.1479468 -32.32854567 13.7330994 -30.42453679 12.14642534 C-29.76453679 12.14642534 -29.10453679 12.14642534 -28.42453679 12.14642534 C-28.42453679 11.48642534 -28.42453679 10.82642534 -28.42453679 10.14642534 C-26.59641179 8.70892534 -26.59641179 8.70892534 -24.17453679 7.14642534 C-23.38563054 6.63080034 -22.59672429 6.11517534 -21.78391179 5.58392534 C-18.20123684 3.40110351 -15.44769271 1.95522145 -11.23703679 1.58392534 C-7.16049343 1.11612528 -4.3214341 0.02208047 0 0 Z " fill="#E5E5E5" transform="translate(225.42453679442406,193.85357466340065)"/>
-<path d="M0 0 C1.65 0 3.3 0 5 0 C5 0.66 5 1.32 5 2 C5.9590625 2.1546875 5.9590625 2.1546875 6.9375 2.3125 C12.53190183 3.56838613 17.91521936 5.33654348 23 8 C23 8.66 23 9.32 23 10 C23.85851562 10.12246094 24.71703125 10.24492187 25.6015625 10.37109375 C29.00686898 11.00127116 32.10342101 11.93562279 35.375 13.0625 C36.43460937 13.42472656 37.49421875 13.78695313 38.5859375 14.16015625 C39.38257813 14.43730469 40.17921875 14.71445312 41 15 C41 15.66 41 16.32 41 17 C41.61488281 17.03738281 42.22976563 17.07476562 42.86328125 17.11328125 C43.67152344 17.17902344 44.47976563 17.24476563 45.3125 17.3125 C46.11300781 17.37050781 46.91351563 17.42851562 47.73828125 17.48828125 C50.43593563 18.09863138 51.10042243 19.06165554 53 21 C55.49018012 21.99988926 55.49018012 21.99988926 58.1875 22.6875 C59.08855469 22.93886719 59.98960937 23.19023437 60.91796875 23.44921875 C61.60503906 23.63097656 62.29210937 23.81273437 63 24 C63 24.66 63 25.32 63 26 C64.65 26 66.3 26 68 26 C68 26.66 68 27.32 68 28 C69.216875 28.12375 70.43375 28.2475 71.6875 28.375 C75.06479059 28.78891306 77.89756695 29.54573451 81 31 C81 31.66 81 32.32 81 33 C81.928125 33.0825 82.85625 33.165 83.8125 33.25 C89.12534498 33.98242925 94.02778798 36.06686151 99 38 C99 38.99 99 39.98 99 41 C101.97 41.33 104.94 41.66 108 42 C108 42.66 108 43.32 108 44 C109.216875 44.103125 110.43375 44.20625 111.6875 44.3125 C115.50184935 44.63574995 117.7522667 46.02730273 121 48 C123.14968745 48.8169898 125.31856158 49.58451998 127.5 50.3125 C133.53502516 52.40422076 139.22759376 54.89590242 145 57.640625 C148.92721265 59.42014323 152.8789933 60.74274372 157 62 C157 62.66 157 63.32 157 64 C158.010625 64.0825 159.02125 64.165 160.0625 64.25 C163.53239519 64.7397864 165.87249712 66.03039413 168.8515625 67.890625 C172.65571858 69.85495287 176.78979197 70.8552536 180.88671875 72.05078125 C184.4123549 73.12572427 187.6626102 74.44772568 191 76 C191 76.66 191 77.32 191 78 C191.71542969 77.95875 192.43085938 77.9175 193.16796875 77.875 C196.30819586 78.01360313 198.43211348 78.77103509 201.3125 80 C202.19550781 80.37125 203.07851563 80.7425 203.98828125 81.125 C204.65214844 81.41375 205.31601562 81.7025 206 82 C206 82.66 206 83.32 206 84 C208.64 84.33 211.28 84.66 214 85 C214 85.66 214 86.32 214 87 C215.2375 87.226875 216.475 87.45375 217.75 87.6875 C223.81734976 89.02193294 229.325946 91.5275072 235 94 C236.66414626 94.67293346 238.32999182 95.3417486 240 96 C240 96.66 240 97.32 240 98 C241.32 98.33 242.64 98.66 244 99 C244 99.66 244 100.32 244 101 C245.5159375 100.9071875 245.5159375 100.9071875 247.0625 100.8125 C251.39947898 101.01902281 254.07744088 102.21701858 258 104 C259.98821313 104.39764263 261.98732362 104.75455166 264 105 C264 105.66 264 106.32 264 107 C264.639375 107.0825 265.27875 107.165 265.9375 107.25 C268.50012926 107.87758268 270.44458009 108.59426495 272.8125 109.6875 C279.70969554 112.86630951 286.87764831 115.37827545 294 118 C294 118.66 294 119.32 294 120 C294.886875 120.12375 295.77375 120.2475 296.6875 120.375 C303.69767442 121.69767442 303.69767442 121.69767442 306 124 C306.09529612 127.01350238 306.12551904 130.00404106 306.11352539 133.01782227 C306.11367142 133.96406464 306.11381744 134.91030701 306.1139679 135.88522339 C306.11326836 139.02897392 306.10547409 142.17266601 306.09765625 145.31640625 C306.09579221 147.48974068 306.09436824 149.66307552 306.09336853 151.83641052 C306.08954221 157.56901195 306.07971097 163.30158823 306.06866455 169.03417969 C306.05845287 174.87890279 306.05387143 180.72362993 306.04882812 186.56835938 C306.0380888 198.045584 306.02101102 209.52278991 306 221 C303.09399739 222.25664978 301.20395416 223 298 223 C298 223.66 298 224.32 298 225 C295.03 225.66 292.06 226.32 289 227 C289 227.66 289 228.32 289 229 C285.26028463 230.44339892 281.62167556 231.83262581 277.75 232.875 C273.2496418 234.22510746 269.05993179 236.07094172 264.76953125 237.9765625 C262 239 262 239 258 239 C258 239.66 258 240.32 258 241 C257.1646875 241.27263672 257.1646875 241.27263672 256.3125 241.55078125 C248.58964059 244.09319952 248.58964059 244.09319952 241 247 C240.67 247.66 240.34 248.32 240 249 C238.11105677 249.74208484 236.21777695 250.47493307 234.3046875 251.15234375 C232.02624136 251.99034852 229.8353074 252.93460251 227.625 253.9375 C224.32911372 255.41693595 221.02373953 256.86357447 217.6875 258.25 C216.88699219 258.58515625 216.08648437 258.9203125 215.26171875 259.265625 C213 260 213 260 209 260 C209 260.66 209 261.32 209 262 C207.88625 262.4125 206.7725 262.825 205.625 263.25 C202.39899591 264.45832662 199.19572477 265.71379498 196 267 C193.01202799 268.20247654 190.01974967 269.37977028 187 270.5 C178.56870095 273.62992779 170.2626406 277.10032586 161.9375 280.5 C161.00873047 280.87769531 160.07996094 281.25539063 159.12304688 281.64453125 C154.04116178 283.72008011 148.99851079 285.85665669 143.99926758 288.12451172 C140.71811867 289.56134161 137.36265982 290.76702473 134 292 C133.113125 292.391875 132.22625 292.78375 131.3125 293.1875 C128.74398721 294.08995044 126.70278046 294.1544446 124 294 C124 294.66 124 295.32 124 296 C107.15078408 303.06393245 107.15078408 303.06393245 98.6640625 306.25390625 C97.51679688 306.68574219 96.36953125 307.11757813 95.1875 307.5625 C94.12917969 307.95566406 93.07085937 308.34882812 91.98046875 308.75390625 C89.12034494 309.9496854 86.64832421 311.40232244 84 313 C82.57965396 313.52784853 81.14110164 314.00965747 79.6875 314.4375 C76.69273431 315.38166258 74.00991172 316.44376342 71.25 317.9375 C66.80190204 320.2720882 62.12317921 321.51827502 57.31640625 322.921875 C54.1045132 323.96602398 51.1685277 325.23062567 48.125 326.6875 C43.97663407 328.66753996 40.577238 329.6948508 36 330 C36 330.66 36 331.32 36 332 C35.16339844 332.27972656 34.32679688 332.55945313 33.46484375 332.84765625 C26.14388104 335.36905094 19.14880224 338.16562701 12.23999023 341.67602539 C7.86068199 343.83391909 5.13771726 344.26604039 0 345 C0 299.79 0 254.58 0 208 C5.61 206.35 11.22 204.7 17 203 C21.43705593 201.0357755 21.43705593 201.0357755 25.80078125 198.91796875 C28 198 28 198 32 198 C32 197.34 32 196.68 32 196 C34.97 195.67 37.94 195.34 41 195 C41 194.34 41 193.68 41 193 C42.75763672 192.43732422 42.75763672 192.43732422 44.55078125 191.86328125 C52.53907483 189.2719775 60.31764639 186.67775944 67.8359375 182.8828125 C70 182 70 182 74 182 C74 181.34 74 180.68 74 180 C75.65 180 77.3 180 79 180 C79 179.34 79 178.68 79 178 C80.1446875 177.566875 80.1446875 177.566875 81.3125 177.125 C84.15029308 176.03730987 84.15029308 176.03730987 87 174 C88.32 174 89.64 174 91 174 C91 173.34 91 172.68 91 172 C90.071875 171.773125 89.14375 171.54625 88.1875 171.3125 C84.93993734 170.3901922 81.99087117 169.12384916 78.9375 167.6875 C74.63237512 165.67132581 70.30383623 163.99552242 65.8125 162.4375 C60.61254807 160.62832635 55.86341371 158.56434541 51 156 C47.33735686 154.42678416 43.64237815 153.28375014 39.8125 152.1875 C34.66670826 150.63273993 30.10338258 148.68749337 25.3671875 146.171875 C21.71420738 144.363469 17.9000148 143.15870005 14 142 C14 141.34 14 140.68 14 140 C13.01 139.814375 13.01 139.814375 12 139.625 C1.42105263 137.42105263 1.42105263 137.42105263 0 136 C-0.09632045 134.2410657 -0.1218751 132.47822841 -0.12025452 130.71665955 C-0.12162918 129.57095993 -0.12300385 128.42526031 -0.12442017 127.24484253 C-0.12082489 125.97673737 -0.11722961 124.7086322 -0.11352539 123.40209961 C-0.11324352 122.06206769 -0.11340125 120.72203561 -0.1139679 119.38200378 C-0.11425587 115.73340562 -0.1083592 112.08484005 -0.10139394 108.43624949 C-0.09516034 104.62722484 -0.0945566 100.8181995 -0.09336853 97.00917053 C-0.09025523 89.79142246 -0.08204186 82.57368946 -0.07201904 75.35594803 C-0.06085786 67.14084743 -0.05534744 58.92574612 -0.05032361 50.71063983 C-0.03985925 33.80708449 -0.02225983 16.90354384 0 0 Z " fill="#141A20" transform="translate(225,367)"/>
-<path d="M0 0 C1.32 0 2.64 0 4 0 C4 0.66 4 1.32 4 2 C4.59425781 2.17015625 5.18851562 2.3403125 5.80078125 2.515625 C14.03088043 4.92193705 22.0506053 7.78884415 30 11 C30 11.66 30 12.32 30 13 C30.763125 13.0825 31.52625 13.165 32.3125 13.25 C41.03712852 15.02450072 49.04834601 18.83619356 57.0546875 22.6328125 C61.74551929 24.81025431 65.8589058 26.28263802 71 27 C71 27.66 71 28.32 71 29 C71.5775 29.144375 72.155 29.28875 72.75 29.4375 C75.875 30.21875 75.875 30.21875 79 31 C79 31.66 79 32.32 79 33 C79.845625 33.0825 80.69125 33.165 81.5625 33.25 C84.94816006 33.98868947 87.1679512 35.23316228 90.08984375 37.03125 C92.20090329 38.1018896 94.05027523 38.51702804 96.375 38.9375 C100.78658503 39.76888529 104.00591761 41.5746091 107.8359375 43.8515625 C110.36891446 45.19577771 112.89143377 45.70830903 115.68359375 46.29296875 C118.75695192 47.23104266 121.40817621 48.6884795 124.25 50.1875 C130.92469726 53.70757728 137.81399628 56.18579238 144.98339844 58.5144043 C148.81489863 59.78075405 152.3200305 61.06832861 155.7890625 63.1484375 C158.76224988 64.86290321 160.59810208 65.53188262 163.9375 65.9375 C168.43366109 66.69933062 171.342726 68.21955324 175.07421875 70.76953125 C178.8471118 73.18020328 183.08817864 74.39052675 187.328125 75.7421875 C188.49601562 76.11730469 188.49601562 76.11730469 189.6875 76.5 C190.39261719 76.7165625 191.09773437 76.933125 191.82421875 77.15625 C194 78 194 78 196.37109375 79.43359375 C202.28631102 82.95811399 209.20600207 85.36493689 215.875 87.0625 C219 88 219 88 222.3125 89.9375 C226.84415671 92.6470648 226.84415671 92.6470648 236 95 C236 112.16 236 129.32 236 147 C228.13477975 151.49441157 228.13477975 151.49441157 224.3125 152.1875 C223.58675781 152.32542969 222.86101562 152.46335937 222.11328125 152.60546875 C220.67602299 152.87379238 219.23564618 153.12581399 217.79296875 153.36328125 C217.20128906 153.57339844 216.60960937 153.78351563 216 154 C215.67 154.99 215.34 155.98 215 157 C212.41796875 158.09765625 212.41796875 158.09765625 209.1875 159.0625 C205.59909404 160.15082288 202.32570343 161.27582837 199 163 C197.38773015 163.47024537 195.77452619 163.93757854 194.15625 164.38671875 C185.85630305 166.74739207 178.06683002 169.72029401 170.33984375 173.5378418 C167.30328348 175.0185775 164.37352911 176.23370456 161.11328125 177.0859375 C159.57220703 177.53839844 159.57220703 177.53839844 158 178 C157.67 178.66 157.34 179.32 157 180 C154.52984421 181.04037849 152.08512956 181.98065187 149.5625 182.875 C148.08819029 183.41049192 146.61423048 183.94694816 145.140625 184.484375 C144.42455078 184.74412109 143.70847656 185.00386719 142.97070312 185.27148438 C140.55887129 186.16307335 138.18543043 187.13496942 135.8125 188.125 C131.00122041 190.08696003 126.06950487 191.5404007 121.078125 192.97265625 C117.91500582 193.94520247 117.91500582 193.94520247 114.796875 195.62109375 C112 197 112 197 109 197 C108.67 197.99 108.34 198.98 108 200 C106.21484375 200.625 106.21484375 200.625 103.9375 201 C99.34708416 201.88135984 95.30113259 203.15665746 91 205 C90.67 205.66 90.34 206.32 90 207 C88.12988281 207.9296875 88.12988281 207.9296875 85.703125 208.875 C84.8265625 209.22046875 83.95 209.5659375 83.046875 209.921875 C82.12390625 210.27765625 81.2009375 210.6334375 80.25 211 C79.3425 211.35578125 78.435 211.7115625 77.5 212.078125 C75.79712731 212.74533243 74.09313765 213.40970098 72.38769531 214.0703125 C70.7198096 214.71973058 69.05809239 215.38511668 67.40136719 216.0625 C65 217 65 217 61.75 217.875 C57.96339034 219.0109829 54.57204208 220.49171411 51.015625 222.1953125 C49 223 49 223 46 223 C46 223.66 46 224.32 46 225 C25.78125 232.90625 25.78125 232.90625 19 234 C19 234.66 19 235.32 19 236 C17.15047952 236.82302143 15.29511436 237.63291366 13.4375 238.4375 C12.40496094 238.88996094 11.37242187 239.34242188 10.30859375 239.80859375 C6.84845419 241.0545708 3.63685493 241.5300587 0 242 C-0.06943556 234.21156603 -0.12277821 226.42320423 -0.15543652 218.63453865 C-0.17110901 215.0181296 -0.19237553 211.40193192 -0.22631836 207.78564453 C-0.25885631 204.29730012 -0.27684108 200.80915932 -0.28463173 197.3206749 C-0.29289269 195.33856231 -0.31632087 193.35653191 -0.33988953 191.37454224 C-0.34011612 190.17344818 -0.34034271 188.97235413 -0.34057617 187.73486328 C-0.34723801 186.67341095 -0.35389984 185.61195862 -0.36076355 184.51834106 C-0.24171158 183.68728851 -0.12265961 182.85623596 0 182 C3 180 3 180 6 180 C6 179.34 6 178.68 6 178 C7.32451172 177.65388672 7.32451172 177.65388672 8.67578125 177.30078125 C15.48290775 175.45093914 21.89314175 173.34586589 28.2734375 170.296875 C35.35610061 166.92804383 42.45740949 164.13469543 50 162 C52.31944799 160.97928402 54.60816608 159.91361012 56.88671875 158.8046875 C59 158 59 158 63 158 C63 157.34 63 156.68 63 156 C63.60328125 155.86722656 64.2065625 155.73445312 64.828125 155.59765625 C66.02695312 155.33275391 66.02695312 155.33275391 67.25 155.0625 C68.03890625 154.88847656 68.8278125 154.71445312 69.640625 154.53515625 C70.80851562 154.27025391 70.80851562 154.27025391 72 154 C72.73734375 153.87496094 73.4746875 153.74992188 74.234375 153.62109375 C74.81703125 153.41613281 75.3996875 153.21117187 76 153 C76.33 152.01 76.66 151.02 77 150 C79.52734375 149.11328125 79.52734375 149.11328125 82.9375 148.3125 C89.82648506 146.49516038 96.07136762 143.92258101 102.51733398 140.90551758 C106.92694908 138.85607652 111.3166145 137.13861119 115.95825195 135.68261719 C117.99482855 135.00172897 119.91729863 134.192584 121.875 133.3125 C125 132 125 132 128 132 C128 131.34 128 130.68 128 130 C128.76183594 129.82984375 129.52367187 129.6596875 130.30859375 129.484375 C136.25457491 128.08881388 141.68431834 126.49215457 147.16015625 123.76953125 C149 123 149 123 152 123 C152 122.01 152 121.02 152 120 C151.39671875 119.89042969 150.7934375 119.78085937 150.171875 119.66796875 C148.97304688 119.43013672 148.97304688 119.43013672 147.75 119.1875 C146.56664062 118.96126953 146.56664062 118.96126953 145.359375 118.73046875 C143 118 143 118 140.99609375 116.484375 C138.68593678 114.76645005 137.14006969 114.46773946 134.3125 114.0625 C129.07754362 113.13371742 124.76229345 111.29846802 120 109 C118.31483864 108.24476 116.62738685 107.49460639 114.9375 106.75 C113.625 106.16666667 112.3125 105.58333333 111 105 C111 104.34 111 103.68 111 103 C110.17371094 103.06832031 109.34742188 103.13664063 108.49609375 103.20703125 C104.11348973 102.94750274 100.99326283 101.53573948 97.0625 99.6875 C95.6993057 99.06621544 94.3360251 98.44512019 92.97265625 97.82421875 C92.30717773 97.51798584 91.64169922 97.21175293 90.95605469 96.89624023 C85.91347474 94.58579203 80.95683272 92.59622472 75.625 91.0625 C70.95085403 89.66347236 66.57511043 88.07525653 62.1953125 85.9296875 C59.89230118 84.89572873 59.89230118 84.89572873 56.91015625 84.1640625 C51.85026835 82.76995656 47.11387836 80.59453857 42.3125 78.5 C40.90774414 77.89478516 40.90774414 77.89478516 39.47460938 77.27734375 C32.54878746 74.28159209 32.54878746 74.28159209 29.88745117 72.91601562 C27.88421432 71.86588396 27.88421432 71.86588396 25.0625 71.25 C20.23082385 69.9587762 15.85248273 67.63312036 11.37890625 65.4375 C7.32904705 63.61039512 7.32904705 63.61039512 0 62 C0 41.54 0 21.08 0 0 Z " fill="#00BD62" transform="translate(260,418)"/>
-<path d="M0 0 C12.01719911 0.01365142 24.03440239 0.01874096 36.05160737 0.02450979 C54.80253918 0.03372043 73.55344276 0.05369526 92.30437303 0.07202661 C92.30437303 34.06202661 92.30437303 68.05202661 92.30437303 103.07202661 C51.07884714 103.11232964 51.07884714 103.11232964 33.31999803 103.12085474 C21.23047528 103.12670618 9.14095977 103.13347291 -2.94855666 103.14746606 C-74.27785064 103.22842372 -74.27785064 103.22842372 -103.14972854 102.84497583 C-103.88451289 102.83521793 -104.61929724 102.82546003 -105.37634778 102.81540644 C-119.81699678 102.61855942 -134.2560097 102.33467791 -148.69562697 102.07202661 C-148.69562697 68.74202661 -148.69562697 35.41202661 -148.69562697 1.07202661 C-114.45674119 0.44923393 -114.45674119 0.44923393 -103.14972854 0.29907739 C-102.35742103 0.28855474 -101.56511353 0.27803209 -100.7487967 0.26719058 C-67.16855577 -0.16690708 -33.58227694 -0.03887021 0 0 Z " fill="#14191F" transform="translate(641.6956269741058,696.9279733896255)"/>
-<path d="M0 0 C56.43 0 112.86 0 171 0 C171 10.56 171 21.12 171 32 C114.57 32 58.14 32 0 32 C0 21.44 0 10.88 0 0 Z " fill="#727272" transform="translate(528,733)"/>
-<path d="M0 0 C79.86 0 159.72 0 242 0 C242 0.33 242 0.66 242 1 C162.8 1 83.6 1 2 1 C2 133.99 2 266.98 2 404 C-19.45 404 -40.9 404 -63 404 C-62.67 437.33 -62.34 470.66 -62 505 C-30.32 505.495 -30.32 505.495 2 506 C2.04125 513.6725 2.0825 521.345 2.125 529.25 C2.14320801 531.66731445 2.16141602 534.08462891 2.18017578 536.57519531 C2.18601743 538.49283628 2.19111377 540.41047973 2.1953125 542.328125 C2.20554443 543.32247559 2.21577637 544.31682617 2.22631836 545.34130859 C2.22668091 546.77192627 2.22668091 546.77192627 2.22705078 548.23144531 C2.231492 549.05751282 2.23593323 549.88358032 2.24050903 550.73468018 C2 553 2 553 0 557 C0.33 540.5 0.66 524 1 507 C-20.45 507 -41.9 507 -64 507 C-64 472.35 -64 437.7 -64 402 C-42.88 402 -21.76 402 0 402 C0 269.34 0 136.68 0 0 Z " fill="#A0A0A1" transform="translate(556,294)"/>
-<path d="M0 0 C57.42 0 114.84 0 174 0 C174 11.55 174 23.1 174 35 C151.46087147 35.02254502 128.92175202 35.040978 106.38261509 35.05181217 C95.91807719 35.05697564 85.45354677 35.06401929 74.98901367 35.07543945 C65.87160565 35.08538476 56.75420304 35.09185306 47.63678974 35.09408849 C42.80606124 35.09539586 37.97534825 35.09848336 33.14462471 35.10573006 C28.60326313 35.11248785 24.06192353 35.11461746 19.5205574 35.11310768 C17.84875431 35.11338412 16.17695052 35.11539066 14.50515175 35.11920547 C12.23274147 35.12413898 9.96041554 35.12299958 7.68800354 35.12025452 C6.41316384 35.12117631 5.13832415 35.1220981 3.82485294 35.12304783 C1 35 1 35 0 34 C0 22.78 0 11.56 0 0 Z M2 1 C2 11.56 2 22.12 2 33 C58.43 33 114.86 33 173 33 C173 22.44 173 11.88 173 1 C116.57 1 60.14 1 2 1 Z " fill="#3D4044" transform="translate(526,732)"/>
-<path d="M0 0 C80.19 0 160.38 0 243 0 C243.33 55.77 243.66 111.54 244 169 C245.98 169.99 247.96 170.98 250 172 C250 172.33 250 172.66 250 173 C248.35 173 246.7 173 245 173 C245 172.34 245 171.68 245 171 C244.01 170.67 243.02 170.34 242 170 C242 114.23 242 58.46 242 1 C162.14 1 82.28 1 0 1 C0 0.67 0 0.34 0 0 Z " fill="#4B4B4B" transform="translate(224,295)"/>
-<path d="M0 0 C1.485 0.99 1.485 0.99 3 2 C3.25616216 5.05290084 3.31849805 7.89702233 3.2487793 10.94775391 C3.23946381 11.87463516 3.23014832 12.80151642 3.22055054 13.75648499 C3.1860853 16.83020963 3.13020737 19.90316065 3.07421875 22.9765625 C3.04619629 25.10361061 3.01950476 27.23067664 2.99409485 29.35775757 C2.9235311 34.96399488 2.83482971 40.56980591 2.74243164 46.17572021 C2.63537976 52.89774556 2.55071052 59.62008508 2.46231842 66.34237671 C2.32541953 76.56192943 2.15997827 86.78066503 2 97 C21.8 97 41.6 97 62 97 C62 97.33 62 97.66 62 98 C42.2 98 22.4 98 2 98 C2 98.66 2 99.32 2 100 C1.34 100 0.68 100 0 100 C0 67 0 34 0 0 Z " fill="#0A0E15" transform="translate(494,699)"/>
-<path d="M0 0 C0.33 0 0.66 0 1 0 C1.33 55.77 1.66 111.54 2 169 C3.98 169.99 5.96 170.98 8 172 C8 172.33 8 172.66 8 173 C6.35 173 4.7 173 3 173 C3 172.34 3 171.68 3 171 C2.01 170.67 1.02 170.34 0 170 C0 113.9 0 57.8 0 0 Z " fill="#717171" transform="translate(466,295)"/>
-<path d="M0 0 C0.66 0.33 1.32 0.66 2 1 C1.67 20.14 1.34 39.28 1 59 C3.64 58.01 6.28 57.02 9 56 C10.32 56.33 11.64 56.66 13 57 C11.23141309 57.67260351 9.46003984 58.33788395 7.6875 59 C6.70136719 59.37125 5.71523438 59.7425 4.69921875 60.125 C2 61 2 61 -1 61 C-1.02312792 53.19424805 -1.04091738 45.38850405 -1.05181217 37.58272648 C-1.05704002 33.9585404 -1.06413587 30.3343777 -1.07543945 26.71020508 C-1.08627184 23.21540025 -1.09227758 19.72061796 -1.09487724 16.22579765 C-1.09763551 14.23760611 -1.10544688 12.24942369 -1.11329651 10.26124573 C-1.11337204 9.06007614 -1.11344757 7.85890656 -1.11352539 6.62133789 C-1.115746 5.55766495 -1.11796661 4.493992 -1.12025452 3.39808655 C-1 1 -1 1 0 0 Z " fill="#049652" transform="translate(261,599)"/>
-<path d="M0 0 C1.32 0 2.64 0 4 0 C4 0.66 4 1.32 4 2 C4.66 2.33 5.32 2.66 6 3 C5.01 3.33 4.02 3.66 3 4 C2.67 23.14 2.34 42.28 2 62 C1.34 62 0.68 62 0 62 C0 41.54 0 21.08 0 0 Z " fill="#049853" transform="translate(260,418)"/>
-<path d="M0 0 C-1.65 0.33 -3.3 0.66 -5 1 C-5 1.66 -5 2.32 -5 3 C-6.65 3 -8.3 3 -10 3 C-10 3.66 -10 4.32 -10 5 C-10.9178125 5.32613281 -11.835625 5.65226563 -12.78125 5.98828125 C-14.62203125 6.64376953 -14.62203125 6.64376953 -16.5 7.3125 C-17.1384082 7.5396167 -17.77681641 7.7667334 -18.43457031 8.00073242 C-21.88861021 9.23312895 -25.32784181 10.49433536 -28.75 11.8125 C-32 13 -32 13 -34 13 C-34 12.34 -34 11.68 -34 11 C-32.58603098 10.49242138 -31.16868271 9.99425075 -29.75 9.5 C-28.96109375 9.2215625 -28.1721875 8.943125 -27.359375 8.65625 C-25 8 -25 8 -21 8 C-21 7.34 -21 6.68 -21 6 C-17.49223216 4.39644899 -14.85645121 3.77963136 -11 4 C-11 3.34 -11 2.68 -11 2 C-9.54494642 1.47007308 -8.08581873 0.9513211 -6.625 0.4375 C-5.81289063 0.14746094 -5.00078125 -0.14257812 -4.1640625 -0.44140625 C-2 -1 -2 -1 0 0 Z " fill="#25272A" transform="translate(309,544)"/>
-<path d="M0 0 C0 0.66 0 1.32 0 2 C-0.89460938 2.31453125 -1.78921875 2.6290625 -2.7109375 2.953125 C-8.35592004 4.95113588 -13.96926436 6.94975521 -19.5 9.25 C-22.98649532 10.67681657 -26.22664243 11.60280447 -30 12 C-30 11.34 -30 10.68 -30 10 C-28.60974609 9.58427734 -28.60974609 9.58427734 -27.19140625 9.16015625 C-25.99386719 8.79792969 -24.79632813 8.43570313 -23.5625 8.0625 C-21.77005859 7.52302734 -21.77005859 7.52302734 -19.94140625 6.97265625 C-17.14132455 6.29110858 -17.14132455 6.29110858 -16 5 C-14.33382885 4.95936168 -12.66611905 4.957279 -11 5 C-11 4.34 -11 3.68 -11 3 C-9.54293274 2.49632243 -8.08429904 1.99717444 -6.625 1.5 C-5.81289062 1.2215625 -5.00078125 0.943125 -4.1640625 0.65625 C-2 0 -2 0 0 0 Z " fill="#25272A" transform="translate(257,563)"/>
-<path d="M0 0 C0.66 0.33 1.32 0.66 2 1 C-2.99893918 3.7266941 -7.31292741 5.43542946 -12.89453125 6.4921875 C-15.28068151 6.98141752 -15.28068151 6.98141752 -18.3125 8.6875 C-21.33484121 10.1635271 -21.94813661 9.96956854 -25 9 C-17.71998049 6.15325357 -10.44504388 3.38499241 -3 1 C-2.01 0.67 -1.02 0.34 0 0 Z " fill="#087F48" transform="translate(394,606)"/>
-<path d="M0 0 C0.66 0.33 1.32 0.66 2 1 C1.360625 1.28875 0.72125 1.5775 0.0625 1.875 C-2.15206079 2.82823451 -2.15206079 2.82823451 -3 5 C-8.04706509 7.17545909 -12.5487185 8.43215818 -18 9 C-16.44464191 5.88928381 -13.88562714 5.66683615 -10.6875 4.5 C-6.10637354 2.84526208 -6.10637354 2.84526208 -1.70703125 0.78125 C-1.14371094 0.5234375 -0.58039063 0.265625 0 0 Z " fill="#0B5C3A" transform="translate(448,583)"/>
-<path d="M0 0 C0 0.66 0 1.32 0 2 C-1.65 2 -3.3 2 -5 2 C-5 2.66 -5 3.32 -5 4 C-6.4117783 4.53394179 -7.82970244 5.05165104 -9.25 5.5625 C-10.03890625 5.85253906 -10.8278125 6.14257812 -11.640625 6.44140625 C-14.19103452 7.04522837 -15.55322229 6.8473932 -18 6 C-12.33627962 2.96586408 -6.59531296 0 0 0 Z " fill="#087946" transform="translate(380,553)"/>
-<path d="M0 0 C1.98 0 3.96 0 6 0 C4.13497412 2.62799102 2.69589209 3.86365751 -0.4921875 4.48828125 C-2.9964272 4.72593573 -5.48653979 4.9040664 -8 5 C-5.08235 3.0549 -3.37462715 2.54723683 0 2 C0 1.34 0 0.68 0 0 Z " fill="#07834A" transform="translate(388,548)"/>
-<path d="M0 0 C2.0625 0.4375 2.0625 0.4375 4 1 C1.35261084 2.4606285 0.10551666 3 -3 3 C-3 3.66 -3 4.32 -3 5 C-6.4019487 7.09350689 -9.05272412 7.17942163 -13 7 C-9.84906684 4.24293349 -6.60395471 2.99320144 -2.70703125 1.6484375 C-0.99486039 1.13150184 -0.99486039 1.13150184 0 0 Z " fill="#0B623C" transform="translate(319,635)"/>
-<path d="M0 0 C-2.58411731 1.72274487 -4.54902656 2.68895522 -7.4375 3.6875 C-8.19933594 3.95949219 -8.96117187 4.23148438 -9.74609375 4.51171875 C-12.21829721 5.04729142 -13.62983284 4.80445309 -16 4 C-14.08959948 3.1319092 -12.17139263 2.28098217 -10.25 1.4375 C-9.18265625 0.96183594 -8.1153125 0.48617187 -7.015625 -0.00390625 C-4.01630163 -0.9946154 -2.86578759 -1.16161779 0 0 Z " fill="#24262A" transform="translate(295,685)"/>
-<path d="M0 0 C2.31 0.33 4.62 0.66 7 1 C7 1.66 7 2.32 7 3 C8.32 3 9.64 3 11 3 C11 3.66 11 4.32 11 5 C11.99 5.33 12.98 5.66 14 6 C9.50540476 5.29771949 5.09389959 3.99912387 1 2 C0.67 1.34 0.34 0.68 0 0 Z " fill="#0B5E3B" transform="translate(387,469)"/>
-<path d="M0 0 C-2.52480693 2.52480693 -4.13823034 2.55738633 -7.625 3.125 C-8.62789063 3.29257812 -9.63078125 3.46015625 -10.6640625 3.6328125 C-11.43492187 3.75398437 -12.20578125 3.87515625 -13 4 C-11.72807637 1.45615274 -10.80051531 1.30631844 -8.1875 0.3125 C-7.50042969 0.04050781 -6.81335938 -0.23148438 -6.10546875 -0.51171875 C-3.70623504 -1.06812731 -2.3105636 -0.77364938 0 0 Z " fill="#0A673F" transform="translate(363,620)"/>
-<path d="M0 0 C-1.24176695 0.70226141 -2.49385599 1.38629109 -3.75 2.0625 C-4.79414063 2.63677734 -4.79414063 2.63677734 -5.859375 3.22265625 C-8.36140628 4.1312406 -9.5332355 3.88336837 -12 3 C-9.84267191 0.84267191 -8.88177557 0.51705175 -6 -0.1875 C-5.29875 -0.36667969 -4.5975 -0.54585937 -3.875 -0.73046875 C-2 -1 -2 -1 0 0 Z " fill="#0D4E34" transform="translate(396,607)"/>
-<path d="M0 0 C9.71428571 1.71428571 9.71428571 1.71428571 13 5 C11.35 5 9.7 5 8 5 C8 4.34 8 3.68 8 3 C7.236875 2.87625 6.47375 2.7525 5.6875 2.625 C3 2 3 2 0 0 Z " fill="#0B623D" transform="translate(338,510)"/>
-<path d="M0 0 C-0.33 0.99 -0.66 1.98 -1 3 C-4.28976808 4.09658936 -5.71303767 3.79953138 -9 3 C-4.5 0 -4.5 0 0 0 Z " fill="#BEC0C1" transform="translate(523,592)"/>
+<path d="M0 0 C1.24605143 -0.00320648 2.49210286 -0.00641296 3.77591342 -0.0097166 C7.20551324 -0.01654213 10.63489336 -0.01454336 14.06448046 -0.00866088 C17.80678204 -0.00446316 21.54906441 -0.01190796 25.29136121 -0.01781338 C31.84084796 -0.02655123 38.39030342 -0.02789611 44.93979454 -0.02431011 C54.67961151 -0.01899148 64.41939833 -0.02511011 74.15921202 -0.03339304 C92.56926142 -0.04861937 110.97929706 -0.05033948 129.38935144 -0.04787002 C143.60890976 -0.04603597 157.82846357 -0.0477993 172.04802132 -0.05209446 C174.09235779 -0.05269687 176.13669427 -0.05329806 178.18103074 -0.05389806 C181.26182901 -0.05480534 184.34262728 -0.05571401 187.42342555 -0.05663041 C216.06152484 -0.06505806 244.69962243 -0.06939698 273.33772278 -0.06522369 C274.95656045 -0.06498913 274.95656045 -0.06498913 276.60810192 -0.06474983 C282.07778518 -0.06394407 287.54746842 -0.0630983 293.01715167 -0.06223653 C294.64653437 -0.06197989 294.64653437 -0.06197989 296.30883388 -0.06171808 C298.50550538 -0.06137142 300.70217687 -0.06102289 302.89884837 -0.06067249 C337.07170733 -0.05531644 371.24454049 -0.06324318 405.41739464 -0.08170605 C443.83052411 -0.10243565 482.24363759 -0.11314686 520.65677297 -0.10913056 C524.75506425 -0.10873523 528.85335552 -0.10837368 532.9516468 -0.10803318 C533.96071349 -0.10794245 534.96978018 -0.10785172 536.00942464 -0.10775824 C551.22334929 -0.10659366 566.43725776 -0.11323001 581.65117836 -0.1238451 C598.96103916 -0.13591042 616.2708644 -0.13744077 633.58072574 -0.12505493 C643.25916158 -0.11843905 652.93751231 -0.12002798 662.6159413 -0.13364345 C669.09234848 -0.1419165 675.56869223 -0.13915349 682.04509432 -0.12766818 C685.72751758 -0.12143989 689.40977538 -0.11973724 693.09218879 -0.13153151 C742.29620511 -0.27803261 783.72404367 14.44275388 819.33878136 49.25447559 C838.15454949 68.05987805 851.6807596 92.15656693 859.15128136 117.62947559 C859.50259117 118.81223072 859.50259117 118.81223072 859.86099815 120.01887989 C864.84716349 137.93439184 865.34131204 155.41560974 865.28668402 173.91294083 C865.27899556 177.65690687 865.28888432 181.40083665 865.29641402 185.14479738 C865.3071966 191.69097825 865.30695291 198.23708474 865.29927254 204.78326893 C865.2878824 214.51804038 865.2937484 224.25274959 865.30289746 233.98752068 C865.31866453 251.37833898 865.3173375 268.76912415 865.30866072 286.15994558 C865.30110466 301.37985494 865.29914832 316.59975219 865.30272865 331.81966305 C865.30295781 332.83047421 865.30318696 333.84128537 865.30342306 334.88272717 C865.30435713 338.98627537 865.30531233 343.08982357 865.30630235 347.19337176 C865.3154731 385.66415573 865.30716901 424.13491865 865.29101166 462.60569937 C865.27677663 496.7590625 865.27804855 530.91239206 865.29239464 565.06575489 C865.30847087 603.46608751 865.31482155 641.86640153 865.30555785 680.26673704 C865.30459574 684.36298215 865.30365722 688.45922726 865.30272865 692.55547237 C865.3023728 694.06829454 865.3023728 694.06829454 865.30200977 695.61167876 C865.29860234 710.81857886 865.3025789 726.02546547 865.31016731 741.2323637 C865.31875621 758.53008151 865.31657695 775.82776109 865.30032508 793.12547415 C865.29153676 802.79747308 865.2909114 812.46938917 865.3022636 822.1413859 C865.30901854 828.61208821 865.30475417 835.08272447 865.2917493 841.55341703 C865.28465281 845.23332826 865.2820887 848.9130756 865.29296724 852.59298133 C865.3442355 871.30113003 864.89727324 889.46647244 859.15128136 907.44197559 C858.89524132 908.2652837 858.63920128 909.0885918 858.37540245 909.93684864 C855.79685812 917.9856683 852.58102984 925.65348896 848.90128136 933.25447559 C848.61591515 933.86033497 848.33054893 934.46619434 848.03653526 935.09041309 C830.37472338 972.22703729 796.06237029 1001.64914703 757.52628136 1015.44197559 C741.01943895 1021.1452558 724.41526408 1024.57505987 706.89996243 1024.5117445 C705.65228729 1024.51525057 704.40461215 1024.51875665 703.11912867 1024.52236897 C699.68034267 1024.53174518 696.24166373 1024.52885318 692.80287276 1024.52381342 C689.05227316 1024.52052693 685.3016955 1024.52884577 681.55110306 1024.53563178 C674.98544107 1024.54591004 668.41980856 1024.54877936 661.85413933 1024.54671955 C652.09014292 1024.54366388 642.32617902 1024.55200613 632.56218895 1024.5624688 C614.10585117 1024.58179372 595.64952453 1024.58743648 577.19317783 1024.58858292 C562.93642719 1024.5895027 548.6796809 1024.59362298 534.42293167 1024.59998417 C530.31618419 1024.60177932 526.2094367 1024.60355895 522.10268921 1024.60533392 C521.08167553 1024.60577602 520.06066186 1024.60621812 519.00870837 1024.60667361 C490.29523693 1024.61897939 461.581767 1024.62687502 432.86829281 1024.62598705 C431.78608639 1024.6259559 430.70387998 1024.62592474 429.58887942 1024.62589264 C424.10406817 1024.62572643 418.61925692 1024.62552835 413.13444567 1024.62532322 C412.04518472 1024.62528333 410.95592376 1024.62524344 409.8336549 1024.62520234 C407.63090343 1024.62512147 405.42815196 1024.62503787 403.22540049 1024.62495156 C368.96540695 1024.62372645 334.70545302 1024.63873292 300.44547081 1024.66609669 C261.93454387 1024.69684321 223.42364296 1024.7140276 184.91270298 1024.71217024 C180.8031263 1024.71202099 176.69354962 1024.71192357 172.58397293 1024.71186161 C171.57212829 1024.7118383 170.56028365 1024.71181499 169.51777705 1024.71179098 C153.26096984 1024.71172953 137.00419713 1024.72448095 120.74740016 1024.74172614 C104.39692246 1024.75871146 88.046495 1024.76063382 71.69601334 1024.7475075 C61.99353772 1024.74013745 52.29121515 1024.74371788 42.58875587 1024.76339218 C36.09373793 1024.775445 29.59883011 1024.77274261 23.10381709 1024.75845118 C19.41234887 1024.75073256 15.72117545 1024.74900606 12.02972872 1024.76536588 C-16.2676811 1024.88241153 -42.64614383 1021.25992027 -68.09871864 1008.25447559 C-69.64366005 1007.48877247 -69.64366005 1007.48877247 -71.21981239 1006.70760059 C-85.10159384 999.57131148 -97.44555718 990.67520716 -108.56942177 979.74422169 C-110.06186213 978.29037892 -111.58284223 976.87401319 -113.11434364 975.46150684 C-137.58496206 952.51730518 -153.25381172 919.24789131 -158.09871864 886.25447559 C-158.27075648 885.12308039 -158.44279432 883.99168519 -158.62004542 882.82600528 C-159.31309182 877.19122907 -159.23888556 871.56072488 -159.23014641 865.89125061 C-159.23219904 864.65182265 -159.23425168 863.41239469 -159.23636651 862.13540831 C-159.24104507 858.69647863 -159.24126431 855.25760127 -159.23958892 851.81867229 C-159.23885626 848.07664176 -159.24388445 844.33461818 -159.24816394 840.59259063 C-159.25573616 833.17121551 -159.25793661 825.74984759 -159.25849299 818.32846901 C-159.25940741 809.43861122 -159.26607731 800.54876007 -159.27283982 791.65890514 C-159.28889484 770.1719996 -159.2948027 748.68509476 -159.29958857 727.19818429 C-159.30192518 717.03081268 -159.30552793 706.86344163 -159.30928394 696.69607045 C-159.3221195 661.88371774 -159.33283829 627.07136534 -159.33628654 592.25901031 C-159.33650818 590.07392871 -159.33672996 587.88884711 -159.3369519 585.7037655 C-159.33717254 583.51343883 -159.33739302 581.32311217 -159.33761334 579.1327855 C-159.33805589 574.73869717 -159.33850301 570.34460884 -159.33895302 565.95052052 C-159.33906241 564.86104318 -159.3391718 563.77156584 -159.33928451 562.64907403 C-159.34291419 527.33201027 -159.35883089 492.01496704 -159.38214338 456.69791114 C-159.40675244 419.34824546 -159.4204599 381.99859152 -159.42165446 344.6489175 C-159.42182591 340.54689967 -159.42204134 336.44488186 -159.42228889 332.34286404 C-159.42234466 331.33285092 -159.42240043 330.32283781 -159.42245789 329.28221824 C-159.42360745 313.04407575 -159.43462144 296.80595438 -159.44917595 280.56781901 C-159.46355917 264.23807488 -159.46676765 247.90835774 -159.45873597 231.57860901 C-159.4542882 221.88443886 -159.45810613 212.19035599 -159.47397448 202.49619735 C-159.4837569 196.01036972 -159.48251522 189.52460295 -159.47253825 183.03877582 C-159.46716963 179.3500427 -159.46635968 175.66147664 -159.47904697 171.97275766 C-159.54107461 152.73447558 -158.87227692 134.36380687 -153.03621864 115.87947559 C-152.74021767 114.92887257 -152.44421669 113.97826954 -152.13924599 112.99886036 C-147.05150492 97.33260929 -139.60825081 82.68358885 -130.09871864 69.25447559 C-129.38844521 68.22838184 -128.67817177 67.20228809 -127.94637489 66.14510059 C-106.37484727 36.49807801 -74.51616763 14.69605822 -39.09871864 5.25447559 C-38.11774208 4.97990528 -37.13676552 4.70533497 -36.12606239 4.42244434 C-24.19504123 1.23140706 -12.32715149 -0.04788128 0 0 Z " fill="#141513" transform="translate(159.09871864318848,-0.25447559356689453)"/>
+<path d="M0 0 C2.3607826 -0.00533069 4.7215618 -0.01239937 7.08233458 -0.02104706 C12.86781777 -0.03768809 18.65308544 -0.03586118 24.43857937 -0.02603391 C31.37506207 -0.01528955 38.31145513 -0.02784201 45.24792682 -0.04094901 C58.83711965 -0.06583655 72.42624267 -0.0677834 86.01545164 -0.0596749 C97.90842776 -0.05259347 109.80137684 -0.05255306 121.6943531 -0.05953789 C123.29160454 -0.06044923 124.88885599 -0.06135999 126.48610743 -0.06227018 C128.89321227 -0.06365335 131.3003171 -0.06504445 133.70742193 -0.06645631 C156.07605562 -0.07943052 178.44468029 -0.0845595 200.81331539 -0.07292271 C202.07720574 -0.07226575 202.07720574 -0.07226575 203.36662924 -0.07159552 C210.20845318 -0.06798894 217.05027701 -0.06415405 223.89210082 -0.06030459 C250.57968088 -0.04545695 277.26715859 -0.05423912 303.95472717 -0.08226013 C333.96091556 -0.11370558 363.96704337 -0.12865264 393.97324854 -0.11846012 C397.17413714 -0.11742339 400.37502576 -0.11643616 403.57591438 -0.11547661 C404.75806397 -0.11510328 404.75806397 -0.11510328 405.96409537 -0.11472241 C417.84673069 -0.11128624 429.72931241 -0.12057354 441.61193657 -0.13624763 C455.12861173 -0.15403651 468.64515667 -0.15411882 482.16182631 -0.13089598 C489.05584211 -0.11951551 495.94963463 -0.11592963 502.84363937 -0.13519669 C509.15952167 -0.15202846 515.47494573 -0.1456129 521.79079849 -0.1209799 C524.07057599 -0.11610521 526.35039063 -0.11958862 528.63013696 -0.13246734 C545.55919757 -0.22117063 559.49258132 1.40958132 573.70204163 11.5146637 C574.65143616 12.18948792 574.65143616 12.18948792 575.62001038 12.87794495 C584.56469704 19.88757798 591.37473569 31.41173592 593.70204163 42.5146637 C593.95009484 46.21967671 593.9332442 49.92717174 593.95204163 53.6396637 C593.98297913 55.13239807 593.98297913 55.13239807 594.01454163 56.6552887 C594.09018739 71.14145219 588.46971331 82.75864333 578.63954163 93.3271637 C572.7611904 98.9075711 566.35707715 102.79152692 558.70204163 105.5146637 C557.98319668 105.77360066 557.26435173 106.03253763 556.5237236 106.29932117 C545.67592079 109.56985516 534.52679546 108.91143924 523.30848694 108.85523987 C520.90407196 108.85431984 518.49965616 108.85472308 516.09524155 108.85633564 C509.68138016 108.85701034 503.26768815 108.83967715 496.85386658 108.81850433 C490.82587678 108.80136501 484.79792729 108.80061201 478.76991272 108.79847717 C461.16393343 108.7827621 443.55798536 108.74087841 425.95204163 108.7021637 C386.59954163 108.6402887 347.24704163 108.5784137 306.70204163 108.5146637 C306.70204163 227.6446637 306.70204163 346.7746637 306.70204163 469.5146637 C286.90204163 469.5146637 267.10204163 469.5146637 246.70204163 469.5146637 C246.70204163 513.4046637 246.70204163 557.2946637 246.70204163 602.5146637 C266.50204163 602.5146637 286.30204163 602.5146637 306.70204163 602.5146637 C306.79485413 611.0843512 306.79485413 611.0843512 306.88954163 619.8271637 C306.91685364 621.60647278 306.94416565 623.38578186 306.9723053 625.2190094 C307.11177013 640.67747815 304.32285969 652.54241746 293.63954163 664.2646637 C283.35164203 674.1494599 271.29383334 675.99381057 257.74501038 675.7881012 C245.19699202 675.32053069 236.72499202 668.99701836 228.38954163 660.0771637 C220.57277107 650.9239274 218.39160693 641.68285062 218.46153259 629.87820435 C218.45896932 628.28889812 218.45896932 628.28889812 218.45635426 626.6674847 C218.45306486 623.123718 218.46405419 619.58014142 218.47499084 616.03639221 C218.47555508 613.49352015 218.47523817 610.95064775 218.47410583 608.40777588 C218.47365067 602.93649447 218.47931674 597.46527407 218.49058151 591.9940052 C218.50685769 584.08354929 218.51204668 576.17311643 218.5145575 568.26264559 C218.51893128 555.42744908 218.53223178 542.59227803 218.55116272 529.75709534 C218.56952972 517.29127632 218.58368221 504.82546422 218.59217834 492.3596344 C218.59270379 491.5908286 218.59322924 490.82202281 218.59377061 490.02991987 C218.59638074 486.17292397 218.59890815 482.31592802 218.60139441 478.45893204 C218.62211705 446.47749075 218.65733395 414.49608076 218.70204163 382.5146637 C224.61760486 380.08952596 230.53376566 377.66585017 236.45030212 375.24308777 C238.45381022 374.42248424 240.45719208 373.60157242 242.46043396 372.78031921 C294.33562193 351.5146637 294.33562193 351.5146637 297.70204163 351.5146637 C297.70204163 313.8946637 297.70204163 276.2746637 297.70204163 237.5146637 C293.24704163 236.0296637 293.24704163 236.0296637 288.70204163 234.5146637 C286.21106492 233.56633242 283.72835319 232.59599737 281.25453186 231.60377502 C280.55959405 231.32587222 279.86465624 231.04796942 279.14865971 230.76164532 C276.93500856 229.87574275 274.72279495 228.98631453 272.51063538 228.09669495 C271.12991114 227.54352131 269.74909265 226.9905829 268.36817932 226.43788147 C263.29082801 224.40381573 258.21529078 222.36522413 253.13954163 220.3271637 C241.77516663 215.7690387 230.41079163 211.2109137 218.70204163 206.5146637 C218.70204163 174.1746637 218.70204163 141.8346637 218.70204163 108.5146637 C211.4392218 108.53561096 204.17640198 108.55655823 196.6934967 108.57814026 C173.42161151 108.64241991 150.14973147 108.68686768 126.8777815 108.71892501 C123.25938686 108.72392749 119.6409925 108.72910481 116.02259827 108.73439026 C114.94212016 108.73596412 114.94212016 108.73596412 113.83981421 108.73756978 C102.19587371 108.75494715 90.55201268 108.78647002 78.90811924 108.82327488 C66.94914019 108.86075877 54.99020259 108.88291524 43.03116721 108.89101768 C36.31867767 108.89600059 29.60637908 108.90842741 22.89394569 108.93758392 C16.56976071 108.96483022 10.24582891 108.97308996 3.92159081 108.96709442 C1.60656735 108.96819053 -0.70846499 108.97608905 -3.0234375 108.9914856 C-22.21272974 109.1127992 -38.45048222 107.21152463 -53.04795837 93.3896637 C-63.81830987 82.05002219 -68.90079896 69.74541111 -68.79795837 54.2021637 C-68.79223816 53.19250549 -68.78651794 52.18284729 -68.78062439 51.14259338 C-68.58557428 42.97019089 -67.30183494 36.7419143 -63.29795837 29.5146637 C-62.51872009 28.0586676 -62.51872009 28.0586676 -61.72373962 26.57325745 C-54.08809538 13.49120962 -42.12498732 5.30864116 -27.65612876 1.34271252 C-18.63655274 -0.61308454 -9.17442691 -0.03625075 0 0 Z " fill="#FEFEFE" transform="translate(249.29795837402344,174.48533630371094)"/>
+<path d="M0 0 C5.86817508 1.95605836 11.59073119 3.95365747 17.30737305 6.27001953 C18.09306325 6.58584142 18.87875345 6.9016633 19.68825245 7.22705555 C22.29709699 8.27645462 24.90439611 9.32963844 27.51171875 10.3828125 C29.39488199 11.14115547 31.2781448 11.89925122 33.16149902 12.65711975 C37.21264727 14.28789145 41.26312379 15.92031644 45.31307983 17.55404663 C51.7542863 20.15236465 58.19696081 22.74702807 64.63989258 25.34106445 C71.41130904 28.06755974 78.18261714 30.79432275 84.95341492 33.52235413 C108.15087431 42.86883922 131.35537268 52.19778488 154.5609436 61.52410889 C159.994401 63.70786608 165.42764165 65.89216193 170.86079502 68.07667542 C193.23239581 77.07158187 215.60890835 86.05370489 238 95 C238 116.12 238 137.24 238 159 C232.01359375 161.39185547 232.01359375 161.39185547 225.90625 163.83203125 C206.57998543 171.55973546 187.26934996 179.32631616 167.95794678 187.09106445 C161.36560101 189.74165676 154.77289802 192.39135988 148.18017578 195.04101562 C126.79552102 203.63604381 105.41240644 212.23486217 84.03399658 220.84541321 C75.73587703 224.18760199 67.43708216 227.52811242 59.13812637 230.86822414 C52.33470621 233.60660835 45.53222385 236.34730609 38.73039818 239.08964825 C34.51543173 240.78839672 30.29959748 242.48498283 26.08351517 244.1809597 C24.12464123 244.96946815 22.16613491 245.75889055 20.20801926 246.54928017 C17.53921709 247.62640467 14.86914587 248.70032007 12.19873047 249.7734375 C11.02965778 250.24663689 11.02965778 250.24663689 9.83696747 250.72939587 C6.56202144 252.04197447 3.43106937 253.14223266 0 254 C0 231.56 0 209.12 0 186 C21.85641702 177.6267728 43.73124762 169.30784563 65.63814926 161.06789398 C71.62769516 158.81489337 77.61678737 156.56068672 83.60580635 154.30628586 C85.09797285 153.74460399 86.5901539 153.18296077 88.08234978 152.62135696 C97.85972778 148.94125789 107.63197621 145.24805417 117.3984375 141.5390625 C119.52367608 140.73273275 121.64892001 139.92641707 123.77416992 139.12011719 C127.62723328 137.65810939 131.4786996 136.19199339 135.3293457 134.72363281 C137.01507528 134.08382248 138.70086226 133.44416335 140.38671875 132.8046875 C141.51894363 132.37079208 141.51894363 132.37079208 142.67404175 131.9281311 C147.77255889 130 147.77255889 130 150 130 C149.67 128.02 149.34 126.04 149 124 C147.88878784 123.58995728 147.88878784 123.58995728 146.75512695 123.17163086 C117.43275623 112.3398187 88.19328622 101.28796181 58.94955444 90.24617195 C50.58387921 87.08758433 42.21738212 83.93117504 33.85093689 80.77462769 C22.56697288 76.5172614 11.28352836 72.25852172 0 68 C0 45.56 0 23.12 0 0 Z " fill="#F39044" transform="translate(272,342)"/>
+<path d="M0 0 C81.84 0 163.68 0 248 0 C248 19.47 248 38.94 248 59 C166.16 59 84.32 59 0 59 C0 39.53 0 20.06 0 0 Z " fill="#F39044" transform="translate(533,681)"/>
</svg>
diff --git a/public/icons/1024x1024.png b/public/icons/1024x1024.png
index 1cfe9ddc0..574578cc2 100644
Binary files a/public/icons/1024x1024.png and b/public/icons/1024x1024.png differ
diff --git a/public/icons/128x128.png b/public/icons/128x128.png
index 250df98e7..ba734af53 100644
Binary files a/public/icons/128x128.png and b/public/icons/128x128.png differ
diff --git a/public/icons/16x16.png b/public/icons/16x16.png
index be5401098..553660bb2 100644
Binary files a/public/icons/16x16.png and b/public/icons/16x16.png differ
diff --git a/public/icons/24x24.png b/public/icons/24x24.png
index d34899699..6c083f00d 100644
Binary files a/public/icons/24x24.png and b/public/icons/24x24.png differ
diff --git a/public/icons/256x256.png b/public/icons/256x256.png
index f65773cce..756661100 100644
Binary files a/public/icons/256x256.png and b/public/icons/256x256.png differ
diff --git a/public/icons/32x32.png b/public/icons/32x32.png
index b112caf32..87ac371a1 100644
Binary files a/public/icons/32x32.png and b/public/icons/32x32.png differ
diff --git a/public/icons/48x48.png b/public/icons/48x48.png
index a8d6242b7..9730d5c0d 100644
Binary files a/public/icons/48x48.png and b/public/icons/48x48.png differ
diff --git a/public/icons/512x512.png b/public/icons/512x512.png
index cc7952993..56ae3e4a9 100644
Binary files a/public/icons/512x512.png and b/public/icons/512x512.png differ
diff --git a/public/icons/64x64.png b/public/icons/64x64.png
index 9fcfda6b8..5a5a1e86d 100644
Binary files a/public/icons/64x64.png and b/public/icons/64x64.png differ
diff --git a/public/icons/icon.icns b/public/icons/icon.icns
index b82c7ae71..1a3cc8932 100644
Binary files a/public/icons/icon.icns and b/public/icons/icon.icns differ
diff --git a/public/icons/icon.ico b/public/icons/icon.ico
index 9b2703245..00594ef7a 100644
Binary files a/public/icons/icon.ico and b/public/icons/icon.ico differ
diff --git a/repo-images/HeaderImage.png b/repo-images/HeaderImage.png
deleted file mode 100644
index 74892b03e..000000000
Binary files a/repo-images/HeaderImage.png and /dev/null differ
diff --git a/repo-images/Image 1.png b/repo-images/Image 1.png
deleted file mode 100644
index fea7eb760..000000000
Binary files a/repo-images/Image 1.png and /dev/null differ
diff --git a/repo-images/Image 10.png b/repo-images/Image 10.png
deleted file mode 100644
index efc0c012f..000000000
Binary files a/repo-images/Image 10.png and /dev/null differ
diff --git a/repo-images/Image 11.png b/repo-images/Image 11.png
deleted file mode 100644
index 3db821d8e..000000000
Binary files a/repo-images/Image 11.png and /dev/null differ
diff --git a/repo-images/Image 12.png b/repo-images/Image 12.png
deleted file mode 100644
index b79011b59..000000000
Binary files a/repo-images/Image 12.png and /dev/null differ
diff --git a/repo-images/Image 2.png b/repo-images/Image 2.png
deleted file mode 100644
index 9a47b3315..000000000
Binary files a/repo-images/Image 2.png and /dev/null differ
diff --git a/repo-images/Image 3.png b/repo-images/Image 3.png
deleted file mode 100644
index 4179a57a5..000000000
Binary files a/repo-images/Image 3.png and /dev/null differ
diff --git a/repo-images/Image 4.png b/repo-images/Image 4.png
deleted file mode 100644
index a47da14f6..000000000
Binary files a/repo-images/Image 4.png and /dev/null differ
diff --git a/repo-images/Image 5.png b/repo-images/Image 5.png
deleted file mode 100644
index e44011e0a..000000000
Binary files a/repo-images/Image 5.png and /dev/null differ
diff --git a/repo-images/Image 6.png b/repo-images/Image 6.png
deleted file mode 100644
index f6f70ba1c..000000000
Binary files a/repo-images/Image 6.png and /dev/null differ
diff --git a/repo-images/Image 7.png b/repo-images/Image 7.png
deleted file mode 100644
index f77d750e6..000000000
Binary files a/repo-images/Image 7.png and /dev/null differ
diff --git a/repo-images/Image 8.png b/repo-images/Image 8.png
deleted file mode 100644
index 03bf9daf2..000000000
Binary files a/repo-images/Image 8.png and /dev/null differ
diff --git a/repo-images/Image 9.png b/repo-images/Image 9.png
deleted file mode 100644
index 28d9e70f0..000000000
Binary files a/repo-images/Image 9.png and /dev/null differ
diff --git a/scripts/generate-icons.mjs b/scripts/generate-icons.mjs
new file mode 100644
index 000000000..0930b78ef
--- /dev/null
+++ b/scripts/generate-icons.mjs
@@ -0,0 +1,117 @@
+import sharp from 'sharp';
+import { readFileSync, writeFileSync, mkdirSync } from 'fs';
+import { join, dirname } from 'path';
+import { fileURLToPath } from 'url';
+
+const __dirname = dirname(fileURLToPath(import.meta.url));
+const root = join(__dirname, '..');
+const publicDir = join(root, 'public');
+const iconsDir = join(publicDir, 'icons');
+
+mkdirSync(iconsDir, { recursive: true });
+
+const svgBuffer = readFileSync(join(publicDir, 'icon.svg'));
+
+const pngSizes = [16, 24, 32, 48, 64, 128, 256, 512, 1024];
+
+console.log('Generating PNG icons...');
+await Promise.all(
+ pngSizes.map(size =>
+ sharp(svgBuffer)
+ .resize(size, size)
+ .png()
+ .toFile(join(iconsDir, `${size}x${size}.png`))
+ .then(() => console.log(` ✓ icons/${size}x${size}.png`))
+ )
+);
+
+// icon.png (1024x1024) for Linux electron-builder
+await sharp(svgBuffer).resize(1024, 1024).png().toFile(join(publicDir, 'icon.png'));
+console.log(' ✓ icon.png');
+
+// icon-mac.png (512x512) for macOS
+await sharp(svgBuffer).resize(512, 512).png().toFile(join(publicDir, 'icon-mac.png'));
+console.log(' ✓ icon-mac.png');
+
+// full-icon.png (1024x1024) used in app UI
+await sharp(svgBuffer).resize(1024, 1024).png().toFile(join(publicDir, 'full-icon.png'));
+console.log(' ✓ full-icon.png');
+
+// favicon.ico — embed 16, 32, 48 px layers
+console.log('Generating favicon.ico...');
+const icoSizes = [16, 32, 48];
+const icoBuffers = await Promise.all(
+ icoSizes.map(size =>
+ sharp(svgBuffer).resize(size, size).png().toBuffer()
+ )
+);
+writeFileSync(join(publicDir, 'favicon.ico'), buildIco(icoBuffers, icoSizes));
+console.log(' ✓ favicon.ico');
+
+// icon.ico — embed 16, 32, 48, 64, 128, 256 px layers
+console.log('Generating icon.ico...');
+const winSizes = [16, 32, 48, 64, 128, 256];
+const winBuffers = await Promise.all(
+ winSizes.map(size =>
+ sharp(svgBuffer).resize(size, size).png().toBuffer()
+ )
+);
+writeFileSync(join(publicDir, 'icon.ico'), buildIco(winBuffers, winSizes));
+console.log(' ✓ icon.ico');
+
+// icons/icon.ico and icons/icon.icns placeholders (stubs pointing to source)
+// electron-builder generates .icns; copy the 1024 PNG as icons/icon.png for reference
+await sharp(svgBuffer).resize(1024, 1024).png().toFile(join(iconsDir, 'icon.ico').replace('icon.ico', '1024x1024.png'));
+// Copy icon.ico and icon.icns into icons/ as well
+import { copyFileSync } from 'fs';
+copyFileSync(join(publicDir, 'icon.ico'), join(iconsDir, 'icon.ico'));
+console.log(' ✓ icons/icon.ico');
+
+console.log('\nDone! Note: icon.icns requires macOS tools (iconutil). Use electron-builder on macOS to generate it.');
+
+/**
+ * Builds a minimal ICO file from PNG buffers.
+ * @param {Buffer[]} pngBuffers
+ * @param {number[]} sizes
+ * @returns {Buffer}
+ */
+function buildIco(pngBuffers, sizes) {
+ const count = pngBuffers.length;
+ const headerSize = 6;
+ const dirEntrySize = 16;
+ const dirSize = headerSize + count * dirEntrySize;
+
+ let offset = dirSize;
+ const entries = pngBuffers.map((buf, i) => {
+ const size = sizes[i];
+ const entry = { size, width: size > 255 ? 0 : size, height: size > 255 ? 0 : size, buf, offset };
+ offset += buf.length;
+ return entry;
+ });
+
+ const totalSize = offset;
+ const ico = Buffer.alloc(totalSize);
+
+ // ICO header
+ ico.writeUInt16LE(0, 0); // reserved
+ ico.writeUInt16LE(1, 2); // type: 1 = ICO
+ ico.writeUInt16LE(count, 4); // image count
+
+ // Directory entries
+ entries.forEach((e, i) => {
+ const base = headerSize + i * dirEntrySize;
+ ico.writeUInt8(e.width, base); // width (0 = 256)
+ ico.writeUInt8(e.height, base + 1); // height (0 = 256)
+ ico.writeUInt8(0, base + 2); // color count
+ ico.writeUInt8(0, base + 3); // reserved
+ ico.writeUInt16LE(1, base + 4); // planes
+ ico.writeUInt16LE(32, base + 6); // bit count
+ ico.writeUInt32LE(e.buf.length, base + 8); // size of image data
+ ico.writeUInt32LE(e.offset, base + 12); // offset of image data
+ });
+
+ // Image data
+ entries.forEach(e => e.buf.copy(ico, e.offset));
+
+ return ico;
+}
diff --git a/src/backend/database/db/index.ts b/src/backend/database/db/index.ts
index 5acce909f..e158bc7ae 100644
--- a/src/backend/database/db/index.ts
+++ b/src/backend/database/db/index.ts
@@ -1044,6 +1044,23 @@ const migrateSchema = () => {
{ column: "host_key_changed_count", sql: "ALTER TABLE ssh_data ADD COLUMN host_key_changed_count INTEGER NOT NULL DEFAULT 0" },
{ column: "mac_address", sql: "ALTER TABLE ssh_data ADD COLUMN mac_address TEXT" },
{ column: "port_knock_sequence", sql: "ALTER TABLE ssh_data ADD COLUMN port_knock_sequence TEXT" },
+ { column: "enable_ssh", sql: "ALTER TABLE ssh_data ADD COLUMN enable_ssh INTEGER NOT NULL DEFAULT 1" },
+ { column: "enable_rdp", sql: "ALTER TABLE ssh_data ADD COLUMN enable_rdp INTEGER NOT NULL DEFAULT 0" },
+ { column: "enable_vnc", sql: "ALTER TABLE ssh_data ADD COLUMN enable_vnc INTEGER NOT NULL DEFAULT 0" },
+ { column: "enable_telnet", sql: "ALTER TABLE ssh_data ADD COLUMN enable_telnet INTEGER NOT NULL DEFAULT 0" },
+ { column: "ssh_port", sql: "ALTER TABLE ssh_data ADD COLUMN ssh_port INTEGER DEFAULT 22" },
+ { column: "rdp_port", sql: "ALTER TABLE ssh_data ADD COLUMN rdp_port INTEGER DEFAULT 3389" },
+ { column: "vnc_port", sql: "ALTER TABLE ssh_data ADD COLUMN vnc_port INTEGER DEFAULT 5900" },
+ { column: "telnet_port", sql: "ALTER TABLE ssh_data ADD COLUMN telnet_port INTEGER DEFAULT 23" },
+ { column: "rdp_user", sql: "ALTER TABLE ssh_data ADD COLUMN rdp_user TEXT" },
+ { column: "rdp_password", sql: "ALTER TABLE ssh_data ADD COLUMN rdp_password TEXT" },
+ { column: "rdp_domain", sql: "ALTER TABLE ssh_data ADD COLUMN rdp_domain TEXT" },
+ { column: "rdp_security", sql: "ALTER TABLE ssh_data ADD COLUMN rdp_security TEXT" },
+ { column: "rdp_ignore_cert", sql: "ALTER TABLE ssh_data ADD COLUMN rdp_ignore_cert INTEGER DEFAULT 0" },
+ { column: "vnc_password", sql: "ALTER TABLE ssh_data ADD COLUMN vnc_password TEXT" },
+ { column: "vnc_user", sql: "ALTER TABLE ssh_data ADD COLUMN vnc_user TEXT" },
+ { column: "telnet_user", sql: "ALTER TABLE ssh_data ADD COLUMN telnet_user TEXT" },
+ { column: "telnet_password", sql: "ALTER TABLE ssh_data ADD COLUMN telnet_password TEXT" },
];
for (const migration of sshDataMigrations) {
diff --git a/src/backend/database/db/schema.ts b/src/backend/database/db/schema.ts
index 0e0d89d97..072d9619b 100644
--- a/src/backend/database/db/schema.ts
+++ b/src/backend/database/db/schema.ts
@@ -129,6 +129,28 @@ export const hosts = sqliteTable("ssh_data", {
terminalConfig: text("terminal_config"),
quickActions: text("quick_actions"),
notes: text("notes"),
+ enableSsh: integer("enable_ssh", { mode: "boolean" }).notNull().default(true),
+ enableRdp: integer("enable_rdp", { mode: "boolean" }).notNull().default(false),
+ enableVnc: integer("enable_vnc", { mode: "boolean" }).notNull().default(false),
+ enableTelnet: integer("enable_telnet", { mode: "boolean" }).notNull().default(false),
+
+ sshPort: integer("ssh_port").default(22),
+ rdpPort: integer("rdp_port").default(3389),
+ vncPort: integer("vnc_port").default(5900),
+ telnetPort: integer("telnet_port").default(23),
+
+ rdpUser: text("rdp_user"),
+ rdpPassword: text("rdp_password"),
+ rdpDomain: text("rdp_domain"),
+ rdpSecurity: text("rdp_security"),
+ rdpIgnoreCert: integer("rdp_ignore_cert", { mode: "boolean" }).default(false),
+
+ vncPassword: text("vnc_password"),
+ vncUser: text("vnc_user"),
+
+ telnetUser: text("telnet_user"),
+ telnetPassword: text("telnet_password"),
+
domain: text("domain"),
security: text("security"),
ignoreCert: integer("ignore_cert", { mode: "boolean" }).default(false),
diff --git a/src/backend/database/routes/host.ts b/src/backend/database/routes/host.ts
index 5a5b371c3..8efb30887 100644
--- a/src/backend/database/routes/host.ts
+++ b/src/backend/database/routes/host.ts
@@ -252,6 +252,9 @@ const SENSITIVE_FIELDS = [
"autostartKey",
"autostartKeyPassword",
"socks5Password",
+ "rdpPassword",
+ "vncPassword",
+ "telnetPassword",
];
function stripSensitiveFields(
@@ -288,6 +291,23 @@ function transformHostResponse(
showTunnelInSidebar: !!host.showTunnelInSidebar,
showDockerInSidebar: !!host.showDockerInSidebar,
showServerStatsInSidebar: !!host.showServerStatsInSidebar,
+ enableSsh: host.enableSsh !== undefined ? !!host.enableSsh : true,
+ enableRdp: !!host.enableRdp,
+ enableVnc: !!host.enableVnc,
+ enableTelnet: !!host.enableTelnet,
+ sshPort: host.sshPort ?? host.port ?? 22,
+ rdpPort: host.rdpPort ?? 3389,
+ vncPort: host.vncPort ?? 5900,
+ telnetPort: host.telnetPort ?? 23,
+ rdpUser: host.rdpUser || undefined,
+ rdpDomain: host.rdpDomain || undefined,
+ rdpSecurity: host.rdpSecurity || undefined,
+ rdpIgnoreCert: !!host.rdpIgnoreCert,
+ vncUser: host.vncUser || undefined,
+ telnetUser: host.telnetUser || undefined,
+ hasRdpPassword: !!host.rdpPassword,
+ hasVncPassword: !!host.vncPassword,
+ hasTelnetPassword: !!host.telnetPassword,
tunnelConnections: host.tunnelConnections
? JSON.parse(host.tunnelConnections as string)
: [],
@@ -593,6 +613,23 @@ router.post(
portKnockSequence,
overrideCredentialUsername,
macAddress,
+ enableSsh,
+ enableRdp,
+ enableVnc,
+ enableTelnet,
+ sshPort,
+ rdpPort,
+ vncPort,
+ telnetPort,
+ rdpUser,
+ rdpPassword,
+ rdpDomain,
+ rdpSecurity,
+ rdpIgnoreCert,
+ vncPassword,
+ vncUser,
+ telnetUser,
+ telnetPassword,
} = hostData;
databaseLogger.info("Creating SSH host", {
operation: "host_create",
@@ -685,6 +722,20 @@ router.post(
portKnockSequence: portKnockSequence
? JSON.stringify(portKnockSequence)
: null,
+ enableSsh: enableSsh !== false ? 1 : 0,
+ enableRdp: enableRdp ? 1 : 0,
+ enableVnc: enableVnc ? 1 : 0,
+ enableTelnet: enableTelnet ? 1 : 0,
+ sshPort: sshPort || port || 22,
+ rdpPort: rdpPort || 3389,
+ vncPort: vncPort || 5900,
+ telnetPort: telnetPort || 23,
+ rdpUser: rdpUser || null,
+ rdpDomain: rdpDomain || null,
+ rdpSecurity: rdpSecurity || null,
+ rdpIgnoreCert: rdpIgnoreCert ? 1 : 0,
+ vncUser: vncUser || null,
+ telnetUser: telnetUser || null,
};
// For non-SSH hosts (RDP, VNC, Telnet), always save password if provided
@@ -743,6 +794,10 @@ router.post(
sshDataObj.keyType = null;
}
+ sshDataObj.rdpPassword = rdpPassword || null;
+ sshDataObj.vncPassword = vncPassword || null;
+ sshDataObj.telnetPassword = telnetPassword || null;
+
try {
const result = await SimpleDBOps.insert(
hosts,
@@ -1092,6 +1147,23 @@ router.put(
portKnockSequence,
overrideCredentialUsername,
macAddress,
+ enableSsh,
+ enableRdp,
+ enableVnc,
+ enableTelnet,
+ sshPort,
+ rdpPort,
+ vncPort,
+ telnetPort,
+ rdpUser,
+ rdpPassword,
+ rdpDomain,
+ rdpSecurity,
+ rdpIgnoreCert,
+ vncPassword,
+ vncUser,
+ telnetUser,
+ telnetPassword,
} = hostData;
databaseLogger.info("Updating SSH host", {
operation: "host_update",
@@ -1181,6 +1253,20 @@ router.put(
portKnockSequence: portKnockSequence
? JSON.stringify(portKnockSequence)
: null,
+ enableSsh: enableSsh !== false ? 1 : 0,
+ enableRdp: enableRdp ? 1 : 0,
+ enableVnc: enableVnc ? 1 : 0,
+ enableTelnet: enableTelnet ? 1 : 0,
+ sshPort: sshPort || port || 22,
+ rdpPort: rdpPort || 3389,
+ vncPort: vncPort || 5900,
+ telnetPort: telnetPort || 23,
+ rdpUser: rdpUser || null,
+ rdpDomain: rdpDomain || null,
+ rdpSecurity: rdpSecurity || null,
+ rdpIgnoreCert: rdpIgnoreCert ? 1 : 0,
+ vncUser: vncUser || null,
+ telnetUser: telnetUser || null,
};
// For non-SSH hosts (RDP, VNC, Telnet), always save password if provided
@@ -1249,6 +1335,11 @@ router.put(
sshDataObj.keyType = null;
}
+ if (rdpPassword !== undefined) sshDataObj.rdpPassword = rdpPassword || null;
+ if (vncPassword !== undefined) sshDataObj.vncPassword = vncPassword || null;
+ if (telnetPassword !== undefined)
+ sshDataObj.telnetPassword = telnetPassword || null;
+
try {
const accessInfo = await permissionManager.canAccessHost(
userId,
diff --git a/src/backend/ssh/server-stats.ts b/src/backend/ssh/server-stats.ts
index c0bf3805a..8700f4765 100644
--- a/src/backend/ssh/server-stats.ts
+++ b/src/backend/ssh/server-stats.ts
@@ -676,7 +676,18 @@ interface StatsConfig {
}
const DEFAULT_STATS_CONFIG: StatsConfig = {
- enabledWidgets: ["cpu", "memory", "disk", "network", "uptime", "system"],
+ enabledWidgets: [
+ "cpu",
+ "memory",
+ "disk",
+ "network",
+ "uptime",
+ "system",
+ "login_stats",
+ "processes",
+ "ports",
+ "firewall",
+ ],
statusCheckEnabled: true,
statusCheckInterval: 60,
metricsEnabled: true,
diff --git a/src/backend/swagger.ts b/src/backend/swagger.ts
deleted file mode 100644
index 8ed87a038..000000000
--- a/src/backend/swagger.ts
+++ /dev/null
@@ -1,161 +0,0 @@
-import swaggerJSDoc from "@deadendjs/swagger-jsdoc";
-import path from "path";
-import { fileURLToPath } from "url";
-import { promises as fs } from "fs";
-import { systemLogger } from "./utils/logger.js";
-
-interface SwaggerOptions {
- definition: object;
- apis: string[];
-}
-
-const __filename = fileURLToPath(import.meta.url);
-const __dirname = path.dirname(__filename);
-
-const projectRoot = path.join(__dirname, "..", "..", "..");
-
-const swaggerOptions: SwaggerOptions = {
- definition: {
- openapi: "3.0.3",
- info: {
- title: "Termix API",
- version: "0.0.0",
- description: "Termix Backend API Reference",
- },
- servers: [
- {
- url: "http://localhost:30001",
- description: "Main database and authentication server",
- },
- {
- url: "http://localhost:30003",
- description: "SSH tunnel management server",
- },
- {
- url: "http://localhost:30004",
- description: "SSH file manager server",
- },
- {
- url: "http://localhost:30005",
- description: "Server statistics and monitoring server",
- },
- {
- url: "http://localhost:30006",
- description: "Dashboard server",
- },
- {
- url: "http://localhost:30007",
- description: "Docker management server",
- },
- ],
- components: {
- securitySchemes: {
- bearerAuth: {
- type: "http",
- scheme: "bearer",
- bearerFormat: "JWT",
- },
- },
- schemas: {
- Error: {
- type: "object",
- properties: {
- error: { type: "string" },
- details: { type: "string" },
- },
- },
- },
- },
- security: [
- {
- bearerAuth: [],
- },
- ],
- tags: [
- {
- name: "Alerts",
- description: "System alerts and notifications management",
- },
- {
- name: "Credentials",
- description: "SSH credential management",
- },
- {
- name: "Network Topology",
- description: "Network topology visualization and management",
- },
- {
- name: "RBAC",
- description: "Role-based access control for host sharing",
- },
- {
- name: "Snippets",
- description: "Command snippet management",
- },
- {
- name: "Terminal",
- description: "Terminal command history",
- },
- {
- name: "Users",
- description: "User management and authentication",
- },
- {
- name: "Dashboard",
- description: "Dashboard statistics and activity",
- },
- {
- name: "Docker",
- description: "Docker container management",
- },
- {
- name: "SSH Tunnels",
- description: "SSH tunnel connection management",
- },
- {
- name: "Server Stats",
- description: "Server status monitoring and metrics collection",
- },
- {
- name: "File Manager",
- description: "SSH file management operations",
- },
- ],
- },
- apis: [
- path.join(projectRoot, "src", "backend", "database", "routes", "*.ts"),
- path.join(projectRoot, "src", "backend", "dashboard.ts"),
- path.join(projectRoot, "src", "backend", "ssh", "*.ts"),
- ],
-};
-
-async function generateOpenAPISpec() {
- try {
- systemLogger.info("Generating OpenAPI specification", {
- operation: "openapi_generate_start",
- });
-
- const swaggerSpec = await swaggerJSDoc(swaggerOptions);
-
- const outputPath = path.join(projectRoot, "openapi.json");
-
- await fs.writeFile(
- outputPath,
- JSON.stringify(swaggerSpec, null, 2),
- "utf-8",
- );
-
- systemLogger.success("OpenAPI specification generated", {
- operation: "openapi_generate_success",
- });
- } catch (error) {
- systemLogger.error("Failed to generate OpenAPI specification", error, {
- operation: "openapi_generation",
- });
- process.exit(1);
- }
-}
-
-generateOpenAPISpec();
-
-export { swaggerOptions, generateOpenAPISpec };
diff --git a/src/backend/utils/field-crypto.ts b/src/backend/utils/field-crypto.ts
index 52527597b..b3fbf50dd 100644
--- a/src/backend/utils/field-crypto.ts
+++ b/src/backend/utils/field-crypto.ts
@@ -30,6 +30,10 @@ class FieldCrypto {
"autostartPassword",
"autostartKey",
"autostartKeyPassword",
+ "socks5Password",
+ "rdpPassword",
+ "vncPassword",
+ "telnetPassword",
]),
ssh_credentials: new Set([
"password",
diff --git a/src/backend/utils/lazy-field-encryption.ts b/src/backend/utils/lazy-field-encryption.ts
index 5d59ba965..3103ad79a 100644
--- a/src/backend/utils/lazy-field-encryption.ts
+++ b/src/backend/utils/lazy-field-encryption.ts
@@ -267,6 +267,10 @@ export class LazyFieldEncryption {
autostartPassword: "autostart_password",
autostartKey: "autostart_key",
autostartKeyPassword: "autostart_key_password",
+ socks5Password: "socks5_password",
+ rdpPassword: "rdp_password",
+ vncPassword: "vnc_password",
+ telnetPassword: "telnet_password",
totpSecret: "totp_secret",
totpBackupCodes: "totp_backup_codes",
clientSecret: "client_secret",
diff --git a/src/backend/utils/user-data-import.ts b/src/backend/utils/user-data-import.ts
deleted file mode 100644
index 7ee07c49e..000000000
--- a/src/backend/utils/user-data-import.ts
+++ /dev/null
@@ -1,492 +0,0 @@
-import { getDb } from "../database/db/index.js";
-import {
- users,
- hosts,
- sshCredentials,
- fileManagerRecent,
- fileManagerPinned,
- fileManagerShortcuts,
- dismissedAlerts,
-} from "../database/db/schema.js";
-import { eq, and } from "drizzle-orm";
-import { DataCrypto } from "./data-crypto.js";
-import { UserDataExport, type UserExportData } from "./user-data-export.js";
-import { databaseLogger } from "./logger.js";
-
-interface ImportOptions {
- replaceExisting?: boolean;
- skipCredentials?: boolean;
- skipFileManagerData?: boolean;
- dryRun?: boolean;
-}
-
-interface ImportResult {
- success: boolean;
- summary: {
- sshHostsImported: number;
- sshCredentialsImported: number;
- fileManagerItemsImported: number;
- dismissedAlertsImported: number;
- skippedItems: number;
- errors: string[];
- };
- dryRun: boolean;
-}
-
-class UserDataImport {
- static async importUserData(
- targetUserId: string,
- exportData: UserExportData,
- options: ImportOptions = {},
- ): Promise<ImportResult> {
- const {
- replaceExisting = false,
- skipCredentials = false,
- skipFileManagerData = false,
- dryRun = false,
- } = options;
-
- try {
- const targetUser = await getDb()
- .select()
- .from(users)
- .where(eq(users.id, targetUserId));
- if (!targetUser || targetUser.length === 0) {
- throw new Error(`Target user not found: ${targetUserId}`);
- }
-
- const validation = UserDataExport.validateExportData(exportData);
- if (!validation.valid) {
- throw new Error(`Invalid export data: ${validation.errors.join(", ")}`);
- }
-
- let userDataKey: Buffer | null = null;
- if (exportData.metadata.encrypted) {
- userDataKey = DataCrypto.getUserDataKey(targetUserId);
- if (!userDataKey) {
- throw new Error(
- "Target user data not unlocked - password required for encrypted import",
- );
- }
- }
-
- const result: ImportResult = {
- success: false,
- summary: {
- sshHostsImported: 0,
- sshCredentialsImported: 0,
- fileManagerItemsImported: 0,
- dismissedAlertsImported: 0,
- skippedItems: 0,
- errors: [],
- },
- dryRun,
- };
-
- if (
- exportData.userData.sshHosts &&
- exportData.userData.sshHosts.length > 0
- ) {
- const importStats = await this.importSshHosts(
- targetUserId,
- exportData.userData.sshHosts as Record<string, unknown>[],
- { replaceExisting, dryRun, userDataKey },
- );
- result.summary.sshHostsImported = importStats.imported;
- result.summary.skippedItems += importStats.skipped;
- result.summary.errors.push(...importStats.errors);
- }
-
- if (
- !skipCredentials &&
- exportData.userData.sshCredentials &&
- exportData.userData.sshCredentials.length > 0
- ) {
- const importStats = await this.importSshCredentials(
- targetUserId,
- exportData.userData.sshCredentials as Record<string, unknown>[],
- { replaceExisting, dryRun, userDataKey },
- );
- result.summary.sshCredentialsImported = importStats.imported;
- result.summary.skippedItems += importStats.skipped;
- result.summary.errors.push(...importStats.errors);
- }
-
- if (!skipFileManagerData && exportData.userData.fileManagerData) {
- const importStats = await this.importFileManagerData(
- targetUserId,
- exportData.userData.fileManagerData,
- { replaceExisting, dryRun },
- );
- result.summary.fileManagerItemsImported = importStats.imported;
- result.summary.skippedItems += importStats.skipped;
- result.summary.errors.push(...importStats.errors);
- }
-
- if (
- exportData.userData.dismissedAlerts &&
- exportData.userData.dismissedAlerts.length > 0
- ) {
- const importStats = await this.importDismissedAlerts(
- targetUserId,
- exportData.userData.dismissedAlerts as Record<string, unknown>[],
- { replaceExisting, dryRun },
- );
- result.summary.dismissedAlertsImported = importStats.imported;
- result.summary.skippedItems += importStats.skipped;
- result.summary.errors.push(...importStats.errors);
- }
-
- result.success = result.summary.errors.length === 0;
-
- databaseLogger.success("User data import completed", {
- operation: "user_data_import_complete",
- targetUserId,
- dryRun,
- ...result.summary,
- });
-
- return result;
- } catch (error) {
- databaseLogger.error("User data import failed", error, {
- operation: "user_data_import_failed",
- targetUserId,
- dryRun,
- });
- throw error;
- }
- }
-
- private static async importSshHosts(
- targetUserId: string,
- sshHosts: Record<string, unknown>[],
- options: {
- replaceExisting: boolean;
- dryRun: boolean;
- userDataKey: Buffer | null;
- },
- ) {
- let imported = 0;
- let skipped = 0;
- const errors: string[] = [];
-
- for (const host of sshHosts) {
- try {
- if (options.dryRun) {
- imported++;
- continue;
- }
-
- const existing = await getDb()
- .select()
- .from(hosts)
- .where(
- and(
- eq(hosts.userId, targetUserId),
- eq(hosts.ip, host.ip as string),
- eq(hosts.port, host.port as number),
- eq(hosts.username, host.username as string),
- ),
- );
-
- if (existing.length > 0 && !options.replaceExisting) {
- skipped++;
- continue;
- }
-
- const newHostData: Record<string, unknown> = {
- ...host,
- userId: targetUserId,
- updatedAt: new Date().toISOString(),
- };
-
- if (existing.length === 0) {
- newHostData.createdAt = new Date().toISOString();
- }
-
- let processedHostData: Record<string, unknown> = newHostData;
- if (options.userDataKey) {
- processedHostData = DataCrypto.encryptRecord(
- "ssh_data",
- newHostData,
- targetUserId,
- options.userDataKey,
- ) as Record<string, unknown>;
- }
-
- delete processedHostData.id;
-
- if (existing.length > 0 && options.replaceExisting) {
- await getDb()
- .update(hosts)
- .set(processedHostData as unknown as typeof hosts.$inferInsert)
- .where(eq(hosts.id, existing[0].id));
- } else {
- await getDb()
- .insert(hosts)
- .values(processedHostData as unknown as typeof hosts.$inferInsert);
- }
- imported++;
- } catch (error) {
- errors.push(
- `SSH host import failed: ${error instanceof Error ? error.message : "Unknown error"}`,
- );
- skipped++;
- }
- }
-
- return { imported, skipped, errors };
- }
-
- private static async importSshCredentials(
- targetUserId: string,
- credentials: Record<string, unknown>[],
- options: {
- replaceExisting: boolean;
- dryRun: boolean;
- userDataKey: Buffer | null;
- },
- ) {
- let imported = 0;
- let skipped = 0;
- const errors: string[] = [];
-
- for (const credential of credentials) {
- try {
- if (options.dryRun) {
- imported++;
- continue;
- }
-
- const existing = await getDb()
- .select()
- .from(sshCredentials)
- .where(
- and(
- eq(sshCredentials.userId, targetUserId),
- eq(sshCredentials.name, credential.name as string),
- ),
- );
-
- if (existing.length > 0 && !options.replaceExisting) {
- skipped++;
- continue;
- }
-
- const newCredentialData: Record<string, unknown> = {
- ...credential,
- userId: targetUserId,
- updatedAt: new Date().toISOString(),
- };
-
- if (existing.length === 0) {
- newCredentialData.usageCount = 0;
- newCredentialData.lastUsed = null;
- newCredentialData.createdAt = new Date().toISOString();
- }
-
- let processedCredentialData: Record<string, unknown> =
- newCredentialData;
- if (options.userDataKey) {
- processedCredentialData = DataCrypto.encryptRecord(
- "ssh_credentials",
- newCredentialData,
- targetUserId,
- options.userDataKey,
- ) as Record<string, unknown>;
- }
-
- delete processedCredentialData.id;
-
- if (existing.length > 0 && options.replaceExisting) {
- await getDb()
- .update(sshCredentials)
- .set(
- processedCredentialData as unknown as typeof sshCredentials.$inferInsert,
- )
- .where(eq(sshCredentials.id, existing[0].id));
- } else {
- await getDb()
- .insert(sshCredentials)
- .values(
- processedCredentialData as unknown as typeof sshCredentials.$inferInsert,
- );
- }
- imported++;
- } catch (error) {
- errors.push(
- `SSH credential import failed: ${error instanceof Error ? error.message : "Unknown error"}`,
- );
- skipped++;
- }
- }
-
- return { imported, skipped, errors };
- }
-
- private static async importFileManagerData(
- targetUserId: string,
- fileManagerData: Record<string, unknown>,
- options: { replaceExisting: boolean; dryRun: boolean },
- ) {
- let imported = 0;
- let skipped = 0;
- const errors: string[] = [];
-
- try {
- if (fileManagerData.recent && Array.isArray(fileManagerData.recent)) {
- for (const item of fileManagerData.recent) {
- try {
- if (!options.dryRun) {
- const newItem = {
- ...item,
- id: undefined,
- userId: targetUserId,
- lastOpened: new Date().toISOString(),
- };
- await getDb().insert(fileManagerRecent).values(newItem);
- }
- imported++;
- } catch (error) {
- errors.push(
- `Recent file import failed: ${error instanceof Error ? error.message : "Unknown error"}`,
- );
- skipped++;
- }
- }
- }
-
- if (fileManagerData.pinned && Array.isArray(fileManagerData.pinned)) {
- for (const item of fileManagerData.pinned) {
- try {
- if (!options.dryRun) {
- const newItem = {
- ...item,
- id: undefined,
- userId: targetUserId,
- pinnedAt: new Date().toISOString(),
- };
- await getDb().insert(fileManagerPinned).values(newItem);
- }
- imported++;
- } catch (error) {
- errors.push(
- `Pinned file import failed: ${error instanceof Error ? error.message : "Unknown error"}`,
- );
- skipped++;
- }
- }
- }
-
- if (
- fileManagerData.shortcuts &&
- Array.isArray(fileManagerData.shortcuts)
- ) {
- for (const item of fileManagerData.shortcuts) {
- try {
- if (!options.dryRun) {
- const newItem = {
- ...item,
- id: undefined,
- userId: targetUserId,
- createdAt: new Date().toISOString(),
- };
- await getDb().insert(fileManagerShortcuts).values(newItem);
- }
- imported++;
- } catch (error) {
- errors.push(
- `Shortcut import failed: ${error instanceof Error ? error.message : "Unknown error"}`,
- );
- skipped++;
- }
- }
- }
- } catch (error) {
- errors.push(
- `File manager data import failed: ${error instanceof Error ? error.message : "Unknown error"}`,
- );
- }
-
- return { imported, skipped, errors };
- }
-
- private static async importDismissedAlerts(
- targetUserId: string,
- alerts: Record<string, unknown>[],
- options: { replaceExisting: boolean; dryRun: boolean },
- ) {
- let imported = 0;
- let skipped = 0;
- const errors: string[] = [];
-
- for (const alert of alerts) {
- try {
- if (options.dryRun) {
- imported++;
- continue;
- }
-
- const existing = await getDb()
- .select()
- .from(dismissedAlerts)
- .where(
- and(
- eq(dismissedAlerts.userId, targetUserId),
- eq(dismissedAlerts.alertId, alert.alertId as string),
- ),
- );
-
- if (existing.length > 0 && !options.replaceExisting) {
- skipped++;
- continue;
- }
-
- const newAlert = {
- ...alert,
- id: undefined,
- userId: targetUserId,
- dismissedAt: new Date().toISOString(),
- };
-
- if (existing.length > 0 && options.replaceExisting) {
- await getDb()
- .update(dismissedAlerts)
- .set(newAlert as typeof dismissedAlerts.$inferInsert)
- .where(eq(dismissedAlerts.id, existing[0].id));
- } else {
- await getDb()
- .insert(dismissedAlerts)
- .values(newAlert as typeof dismissedAlerts.$inferInsert);
- }
-
- imported++;
- } catch (error) {
- errors.push(
- `Dismissed alert import failed: ${error instanceof Error ? error.message : "Unknown error"}`,
- );
- skipped++;
- }
- }
-
- return { imported, skipped, errors };
- }
-
- static async importUserDataFromJSON(
- targetUserId: string,
- jsonData: string,
- options: ImportOptions = {},
- ): Promise<ImportResult> {
- try {
- const exportData: UserExportData = JSON.parse(jsonData);
- return await this.importUserData(targetUserId, exportData, options);
- } catch (error) {
- if (error instanceof SyntaxError) {
- throw new Error("Invalid JSON format in import data", { cause: error });
- }
- throw error;
- }
- }
-}
-
-export { UserDataImport, type ImportOptions, type ImportResult };
diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx
deleted file mode 100644
index aeaadfceb..000000000
--- a/src/components/ui/button.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-/* eslint-disable react-refresh/only-export-components */
-import * as React from "react";
-import { Slot } from "@radix-ui/react-slot";
-import { cva, type VariantProps } from "class-variance-authority";
-
-import { cn } from "@/lib/utils";
-
-const buttonVariants = cva(
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all duration-100 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive active:scale-95",
- {
- variants: {
- variant: {
- default:
- "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
- destructive:
- "bg-destructive text-foreground shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
- outline:
- "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
- secondary:
- "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
- ghost:
- "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
- link: "text-primary underline-offset-4 hover:underline",
- },
- size: {
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
- sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
- icon: "size-9",
- },
- },
- defaultVariants: {
- variant: "default",
- size: "default",
- },
- },
-);
-
-export interface ButtonProps
- extends React.ComponentProps<"button">, VariantProps<typeof buttonVariants> {
- asChild?: boolean;
-}
-
-function Button({
- className,
- variant,
- size,
- asChild = false,
- ...props
-}: ButtonProps) {
- const Comp = asChild ? Slot : "button";
-
- return (
- <Comp
- data-slot="button"
- className={cn(buttonVariants({ variant, size, className }))}
- {...props}
- />
- );
-}
-
-export { Button, buttonVariants, type ButtonProps };
diff --git a/src/components/ui/chart.tsx b/src/components/ui/chart.tsx
deleted file mode 100644
index c0479b5a4..000000000
--- a/src/components/ui/chart.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import * as React from "react";
-import * as RechartsPrimitive from "recharts";
-
-import { cn } from "@/lib/utils";
-
-// Chart Container
-const ChartContainer = React.forwardRef<
- HTMLDivElement,
- React.HTMLAttributes<HTMLDivElement>
->(({ className, ...props }, ref) => {
- return (
- <div
- ref={ref}
- className={cn(
- "flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",
- className,
- )}
- {...props}
- />
- );
-});
-ChartContainer.displayName = "ChartContainer";
-
-export { ChartContainer, RechartsPrimitive };
diff --git a/src/components/ui/command.tsx b/src/components/ui/command.tsx
deleted file mode 100644
index fb2656057..000000000
--- a/src/components/ui/command.tsx
+++ /dev/null
@@ -1,184 +0,0 @@
-"use client";
-
-import * as React from "react";
-import { Command as CommandPrimitive } from "cmdk";
-import { SearchIcon } from "lucide-react";
-
-import { cn } from "@/lib/utils";
-import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogHeader,
- DialogTitle,
-} from "@/components/ui/dialog";
-
-function Command({
- className,
- ...props
-}: React.ComponentProps<typeof CommandPrimitive>) {
- return (
- <CommandPrimitive
- data-slot="command"
- className={cn(
- "bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
- className,
- )}
- {...props}
- />
- );
-}
-
-function CommandDialog({
- title = "Command Palette",
- description = "Search for a command to run...",
- children,
- className,
- showCloseButton = true,
- ...props
-}: React.ComponentProps<typeof Dialog> & {
- title?: string;
- description?: string;
- className?: string;
- showCloseButton?: boolean;
-}) {
- return (
- <Dialog {...props}>
- <DialogHeader className="sr-only">
- <DialogTitle>{title}</DialogTitle>
- <DialogDescription>{description}</DialogDescription>
- </DialogHeader>
- <DialogContent
- className={cn("overflow-hidden p-0", className)}
- showCloseButton={showCloseButton}
- >
- <Command className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
- {children}
- </Command>
- </DialogContent>
- </Dialog>
- );
-}
-
-function CommandInput({
- className,
- ...props
-}: React.ComponentProps<typeof CommandPrimitive.Input>) {
- return (
- <div
- data-slot="command-input-wrapper"
- className="flex h-9 items-center gap-2 border-b px-3"
- >
- <SearchIcon className="size-4 shrink-0 opacity-50" />
- <CommandPrimitive.Input
- data-slot="command-input"
- className={cn(
- "placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
- className,
- )}
- {...props}
- />
- </div>
- );
-}
-
-function CommandList({
- className,
- ...props
-}: React.ComponentProps<typeof CommandPrimitive.List>) {
- return (
- <CommandPrimitive.List
- data-slot="command-list"
- className={cn(
- "max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto thin-scrollbar",
- className,
- )}
- {...props}
- />
- );
-}
-
-function CommandEmpty({
- ...props
-}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
- return (
- <CommandPrimitive.Empty
- data-slot="command-empty"
- className="py-6 text-center text-sm"
- {...props}
- />
- );
-}
-
-function CommandGroup({
- className,
- ...props
-}: React.ComponentProps<typeof CommandPrimitive.Group>) {
- return (
- <CommandPrimitive.Group
- data-slot="command-group"
- className={cn(
- "text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
- className,
- )}
- {...props}
- />
- );
-}
-
-function CommandSeparator({
- className,
- ...props
-}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
- return (
- <CommandPrimitive.Separator
- data-slot="command-separator"
- className={cn("bg-border -mx-1 h-px", className)}
- {...props}
- />
- );
-}
-
-function CommandItem({
- className,
- ...props
-}: React.ComponentProps<typeof CommandPrimitive.Item>) {
- return (
- <CommandPrimitive.Item
- data-slot="command-item"
- className={cn(
- "data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
- className,
- )}
- {...props}
- />
- );
-}
-
-function CommandShortcut({
- className,
- ...props
-}: React.ComponentProps<"span">) {
- return (
- <span
- data-slot="command-shortcut"
- className={cn(
- "text-muted-foreground ml-auto text-xs tracking-widest",
- className,
- )}
- {...props}
- />
- );
-}
-
-export {
- Command,
- CommandDialog,
- CommandInput,
- CommandList,
- CommandEmpty,
- CommandGroup,
- CommandItem,
- CommandShortcut,
- CommandSeparator,
-};
diff --git a/src/components/ui/dropdown-menu.tsx b/src/components/ui/dropdown-menu.tsx
deleted file mode 100644
index 61ab08e9d..000000000
--- a/src/components/ui/dropdown-menu.tsx
+++ /dev/null
@@ -1,198 +0,0 @@
-import * as React from "react";
-import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
-import { CheckIcon, ChevronRightIcon, Circle } from "lucide-react";
-
-import { cn } from "@/lib/utils";
-
-const DropdownMenu = DropdownMenuPrimitive.Root;
-
-const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
-
-const DropdownMenuGroup = DropdownMenuPrimitive.Group;
-
-const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
-
-const DropdownMenuSub = DropdownMenuPrimitive.Sub;
-
-const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
-
-const DropdownMenuSubTrigger = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
- inset?: boolean;
- }
->(({ className, inset, children, ...props }, ref) => (
- <DropdownMenuPrimitive.SubTrigger
- ref={ref}
- className={cn(
- "focus:bg-accent data-[state=open]:bg-accent flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",
- inset && "pl-8",
- className,
- )}
- {...props}
- >
- {children}
- <ChevronRightIcon className="ml-auto h-4 w-4" />
- </DropdownMenuPrimitive.SubTrigger>
-));
-DropdownMenuSubTrigger.displayName =
- DropdownMenuPrimitive.SubTrigger.displayName;
-
-const DropdownMenuSubContent = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
->(({ className, ...props }, ref) => (
- <DropdownMenuPrimitive.SubContent
- ref={ref}
- className={cn(
- "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg",
- className,
- )}
- {...props}
- />
-));
-DropdownMenuSubContent.displayName =
- DropdownMenuPrimitive.SubContent.displayName;
-
-const DropdownMenuContent = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
->(({ className, sideOffset = 4, ...props }, ref) => (
- <DropdownMenuPrimitive.Portal>
- <DropdownMenuPrimitive.Content
- ref={ref}
- sideOffset={sideOffset}
- className={cn(
- "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md",
- className,
- )}
- {...props}
- />
- </DropdownMenuPrimitive.Portal>
-));
-DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
-
-const DropdownMenuItem = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.Item>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
- inset?: boolean;
- }
->(({ className, inset, ...props }, ref) => (
- <DropdownMenuPrimitive.Item
- ref={ref}
- className={cn(
- "focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
- inset && "pl-8",
- className,
- )}
- {...props}
- />
-));
-DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
-
-const DropdownMenuCheckboxItem = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
->(({ className, children, checked, ...props }, ref) => (
- <DropdownMenuPrimitive.CheckboxItem
- ref={ref}
- className={cn(
- "focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
- className,
- )}
- checked={checked}
- {...props}
- >
- <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
- <DropdownMenuPrimitive.ItemIndicator>
- <CheckIcon className="h-4 w-4" />
- </DropdownMenuPrimitive.ItemIndicator>
- </span>
- {children}
- </DropdownMenuPrimitive.CheckboxItem>
-));
-DropdownMenuCheckboxItem.displayName =
- DropdownMenuPrimitive.CheckboxItem.displayName;
-
-const DropdownMenuRadioItem = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
->(({ className, children, ...props }, ref) => (
- <DropdownMenuPrimitive.RadioItem
- ref={ref}
- className={cn(
- "focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
- className,
- )}
- {...props}
- >
- <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
- <DropdownMenuPrimitive.ItemIndicator>
- <Circle className="h-4 w-4 fill-current" />
- </DropdownMenuPrimitive.ItemIndicator>
- </span>
- {children}
- </DropdownMenuPrimitive.RadioItem>
-));
-DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
-
-const DropdownMenuLabel = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.Label>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
- inset?: boolean;
- }
->(({ className, inset, ...props }, ref) => (
- <DropdownMenuPrimitive.Label
- ref={ref}
- className={cn(
- "px-2 py-1.5 text-sm font-semibold",
- inset && "pl-8",
- className,
- )}
- {...props}
- />
-));
-DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
-
-const DropdownMenuSeparator = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
->(({ className, ...props }, ref) => (
- <DropdownMenuPrimitive.Separator
- ref={ref}
- className={cn("bg-muted -mx-1 my-1 h-px", className)}
- {...props}
- />
-));
-DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
-
-const DropdownMenuShortcut = ({
- className,
- ...props
-}: React.HTMLAttributes<HTMLSpanElement>) => {
- return (
- <span
- className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
- {...props}
- />
- );
-};
-DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
-
-export {
- DropdownMenu,
- DropdownMenuTrigger,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuCheckboxItem,
- DropdownMenuRadioItem,
- DropdownMenuLabel,
- DropdownMenuSeparator,
- DropdownMenuShortcut,
- DropdownMenuGroup,
- DropdownMenuPortal,
- DropdownMenuSub,
- DropdownMenuSubContent,
- DropdownMenuSubTrigger,
- DropdownMenuRadioGroup,
-};
diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsx
deleted file mode 100644
index f7fb44e5e..000000000
--- a/src/components/ui/input.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import * as React from "react";
-
-import { cn } from "@/lib/utils";
-
-function Input({ className, type, ...props }: React.ComponentProps<"input">) {
- return (
- <input
- type={type}
- data-slot="input"
- className={cn(
- "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground bg-elevated dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border px-3 py-1 text-base shadow-xs transition-[color,box-shadow] duration-200 outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
- "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
- "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
- className,
- )}
- {...props}
- />
- );
-}
-
-export { Input };
diff --git a/src/components/ui/kbd.tsx b/src/components/ui/kbd.tsx
deleted file mode 100644
index ab78efd3b..000000000
--- a/src/components/ui/kbd.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import { type ComponentProps, type ReactNode } from "react";
-import { cn } from "@/lib/utils";
-
-export type KbdProps = ComponentProps<"span"> & {
- children: ReactNode;
-};
-
-export const Kbd = ({ className, children, ...props }: KbdProps) => (
- <span
- className={cn(
- "inline-flex select-none items-center rounded-md border px-2 py-1 text-[10px] font-mono font-medium relative",
- "bg-linear-to-b from-gray-100 to-gray-200 border-gray-300 shadow-[0_2px_0_#ccc,0_3px_2px_rgba(0,0,0,0.25)]",
- "dark:from-zinc-800 dark:to-zinc-900 dark:border-zinc-700 dark:shadow-[0_2px_0_#222,0_3px_2px_rgba(0,0,0,0.4)]",
- "dark:text-zinc-200",
- className,
- )}
- {...props}
- >
- {children}
- </span>
-);
-
-export type KbdKeyProps = ComponentProps<"span"> & {
- "aria-label"?: string;
- className?: string;
-};
-
-export const KbdKey = ({ className, children, ...props }: KbdKeyProps) => (
- <span
- className={cn(
- "px-1 py-px rounded-sm select-none text-[10px] font-mono font-medium bg-transparent",
- className,
- )}
- {...props}
- >
- {children}
- </span>
-);
-
-export type KbdSeparatorProps = ComponentProps<"span"> & {
- children?: ReactNode;
- className?: string;
-};
-
-export const KbdSeparator = ({
- className,
- children = "+",
- ...props
-}: KbdSeparatorProps) => (
- <span
- className={cn(
- "text-muted-foreground/70 text-[10px] mx-0.5 select-none pointer-events-none",
- className,
- )}
- {...props}
- >
- {children}
- </span>
-);
diff --git a/src/components/ui/progress.tsx b/src/components/ui/progress.tsx
deleted file mode 100644
index d683666ef..000000000
--- a/src/components/ui/progress.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import * as React from "react";
-import * as ProgressPrimitive from "@radix-ui/react-progress";
-
-import { cn } from "@/lib/utils";
-
-function Progress({
- className,
- value,
- ...props
-}: React.ComponentProps<typeof ProgressPrimitive.Root>) {
- return (
- <ProgressPrimitive.Root
- data-slot="progress"
- className={cn(
- "bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",
- className,
- )}
- {...props}
- >
- <ProgressPrimitive.Indicator
- data-slot="progress-indicator"
- className="bg-primary h-full w-full flex-1 transition-all"
- style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
- />
- </ProgressPrimitive.Root>
- );
-}
-
-export { Progress };
diff --git a/src/components/ui/resizable.tsx b/src/components/ui/resizable.tsx
deleted file mode 100644
index 6287ded15..000000000
--- a/src/components/ui/resizable.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import * as React from "react";
-import { GripVerticalIcon } from "lucide-react";
-import {
- Group as ResizableGroup,
- Panel as ResizablePrimitivePanel,
- Separator as ResizableSeparator,
-} from "react-resizable-panels";
-
-import { cn } from "@/lib/utils";
-
-function ResizablePanelGroup({
- className,
- ...props
-}: React.ComponentProps<typeof ResizableGroup>) {
- return (
- <ResizableGroup
- data-slot="resizable-panel-group"
- className={cn(
- "flex h-full w-full data-[panel-group-direction=vertical]:flex-col",
- className,
- )}
- {...props}
- />
- );
-}
-
-function ResizablePanel({
- ...props
-}: React.ComponentProps<typeof ResizablePrimitivePanel>) {
- return <ResizablePrimitivePanel data-slot="resizable-panel" {...props} />;
-}
-
-function ResizableHandle({
- withHandle,
- className,
- ...props
-}: React.ComponentProps<typeof ResizableSeparator> & {
- withHandle?: boolean;
-}) {
- return (
- <ResizableSeparator
- data-slot="resizable-handle"
- className={cn(
- "relative flex w-1 items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-1 data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90 bg-edge-hover hover:bg-interact active:bg-pressed transition-colors duration-150",
- className,
- )}
- {...props}
- >
- {withHandle && (
- <div className="bg-edge-hover hover:bg-interact active:bg-pressed z-10 flex h-4 w-3 items-center justify-center rounded-xs border transition-colors duration-150">
- <GripVerticalIcon className="size-2.5" />
- </div>
- )}
- </ResizableSeparator>
- );
-}
-
-export { ResizablePanelGroup, ResizablePanel, ResizableHandle };
diff --git a/src/components/ui/sonner.tsx b/src/components/ui/sonner.tsx
deleted file mode 100644
index 4c7e3c574..000000000
--- a/src/components/ui/sonner.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import { useTheme } from "@/components/theme-provider";
-import { Toaster as Sonner, type ToasterProps, toast } from "sonner";
-import { useRef } from "react";
-
-const Toaster = ({ ...props }: ToasterProps) => {
- const { theme = "system" } = useTheme();
- const lastToastRef = useRef<{ text: string; timestamp: number } | null>(null);
-
- const originalToast = toast;
-
- const rateLimitedToast = (
- message: string,
- options?: Record<string, unknown>,
- ) => {
- const now = Date.now();
- const lastToast = lastToastRef.current;
-
- if (
- lastToast &&
- lastToast.text === message &&
- now - lastToast.timestamp < 1000
- ) {
- return;
- }
-
- lastToastRef.current = { text: message, timestamp: now };
- return originalToast(message, options);
- };
-
- Object.assign(toast, {
- success: (message: string, options?: Record<string, unknown>) =>
- rateLimitedToast(message, { ...options, type: "success" }),
- error: (message: string, options?: Record<string, unknown>) =>
- rateLimitedToast(message, { ...options, type: "error" }),
- warning: (message: string, options?: Record<string, unknown>) =>
- rateLimitedToast(message, { ...options, type: "warning" }),
- info: (message: string, options?: Record<string, unknown>) =>
- rateLimitedToast(message, { ...options, type: "info" }),
- message: rateLimitedToast,
- });
-
- const darkCustomThemes = [
- "dracula",
- "gentlemansChoice",
- "midnightEspresso",
- "catppuccinMocha",
- ];
- const sonnerTheme: ToasterProps["theme"] = darkCustomThemes.includes(theme)
- ? "dark"
- : (theme as ToasterProps["theme"]);
-
- return (
- <Sonner
- theme={sonnerTheme}
- className="toaster group"
- style={
- {
- "--normal-bg": "var(--popover)",
- "--normal-text": "var(--popover-foreground)",
- "--normal-border": "var(--border)",
- } as React.CSSProperties
- }
- {...props}
- />
- );
-};
-
-export { Toaster };
diff --git a/src/components/ui/tooltip.tsx b/src/components/ui/tooltip.tsx
deleted file mode 100644
index 2ddbbdd7e..000000000
--- a/src/components/ui/tooltip.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-"use client";
-
-import * as React from "react";
-import * as TooltipPrimitive from "@radix-ui/react-tooltip";
-
-import { cn } from "@/lib/utils";
-
-function TooltipProvider({
- delayDuration = 0,
- ...props
-}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
- return (
- <TooltipPrimitive.Provider
- data-slot="tooltip-provider"
- delayDuration={delayDuration}
- {...props}
- />
- );
-}
-
-function Tooltip({
- ...props
-}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
- return (
- <TooltipProvider>
- <TooltipPrimitive.Root data-slot="tooltip" {...props} />
- </TooltipProvider>
- );
-}
-
-function TooltipTrigger({
- ...props
-}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
- return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
-}
-
-function TooltipContent({
- className,
- sideOffset = 4,
- children,
- ...props
-}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
- return (
- <TooltipPrimitive.Portal>
- <TooltipPrimitive.Content
- data-slot="tooltip-content"
- sideOffset={sideOffset}
- className={cn(
- "bg-elevated text-foreground border border-edge-medium shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
- className,
- )}
- {...props}
- >
- {children}
- </TooltipPrimitive.Content>
- </TooltipPrimitive.Portal>
- );
-}
-
-export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
diff --git a/src/index.css b/src/index.css
deleted file mode 100644
index 2e5cd2d23..000000000
--- a/src/index.css
+++ /dev/null
@@ -1,559 +0,0 @@
-@import "tailwindcss";
-
-@custom-variant dark (&:is(.dark *));
-
-:root {
- font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
- line-height: 1.5;
- font-weight: 400;
-
- color-scheme: light dark;
- color: var(--foreground);
- background-color: var(--bg-base);
-
- font-synthesis: none;
- text-rendering: optimizeLegibility;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- --radius: 0.625rem;
- --background: #ffffff;
- --foreground: #18181b;
- --card: #ffffff;
- --card-foreground: #18181b;
- --popover: #ffffff;
- --popover-foreground: #18181b;
- --primary: #27272a;
- --primary-foreground: #fafafa;
- --secondary: #f4f4f5;
- --secondary-foreground: #27272a;
- --muted: #f4f4f5;
- --muted-foreground: #71717a;
- --accent: #f4f4f5;
- --accent-foreground: #27272a;
- --destructive: #dc2626;
- --border: #e4e4e7;
- --input: #e4e4e7;
- --ring: #a1a1aa;
- --chart-1: #e76e50;
- --chart-2: #2a9d8f;
- --chart-3: #264653;
- --chart-4: #e9c46a;
- --chart-5: #f4a261;
- --sidebar: #f9f9f9;
- --sidebar-foreground: #18181b;
- --sidebar-primary: #27272a;
- --sidebar-primary-foreground: #fafafa;
- --sidebar-accent: #f4f4f5;
- --sidebar-accent-foreground: #27272a;
- --sidebar-border: #e4e4e7;
- --sidebar-ring: #a1a1aa;
-
- --bg-base: #fcfcfc;
- --bg-elevated: #ffffff;
- --bg-surface: #f3f4f6;
- --bg-surface-hover: #e5e7eb;
- --bg-input: #ffffff;
- --bg-deepest: #e5e7eb;
- --bg-header: #eeeeef;
- --bg-button: #f3f4f6;
- --bg-active: #e5e7eb;
- --bg-light: #fafafa;
- --bg-subtle: #f5f5f5;
- --bg-interact: #d1d5db;
- --border-base: #e5e7eb;
- --border-panel: #d1d5db;
- --border-subtle: #f3f4f6;
- --border-medium: #d1d5db;
- --bg-hover: #f3f4f6;
- --bg-hover-alt: #e5e7eb;
- --bg-pressed: #d1d5db;
- --border-hover: #d1d5db;
- --border-active: #9ca3af;
-
- --foreground-secondary: #334155;
- --foreground-subtle: #94a3b8;
-
- --scrollbar-thumb: #c1c1c3;
- --scrollbar-thumb-hover: #a1a1a3;
- --scrollbar-track: #f3f4f6;
-
- --bg-overlay: rgba(0, 0, 0, 0.5);
-}
-
-@theme inline {
- --radius-sm: calc(var(--radius) - 4px);
- --radius-md: calc(var(--radius) - 2px);
- --radius-lg: var(--radius);
- --radius-xl: calc(var(--radius) + 4px);
- --color-background: var(--background);
- --color-foreground: var(--foreground);
- --color-card: var(--card);
- --color-card-foreground: var(--card-foreground);
- --color-popover: var(--popover);
- --color-popover-foreground: var(--popover-foreground);
- --color-primary: var(--primary);
- --color-primary-foreground: var(--primary-foreground);
- --color-secondary: var(--secondary);
- --color-secondary-foreground: var(--secondary-foreground);
- --color-muted: var(--muted);
- --color-muted-foreground: var(--muted-foreground);
- --color-accent: var(--accent);
- --color-accent-foreground: var(--accent-foreground);
- --color-destructive: var(--destructive);
- --color-border: var(--border);
- --color-input: var(--input);
- --color-ring: var(--ring);
- --color-chart-1: var(--chart-1);
- --color-chart-2: var(--chart-2);
- --color-chart-3: var(--chart-3);
- --color-chart-4: var(--chart-4);
- --color-chart-5: var(--chart-5);
- --color-sidebar: var(--sidebar);
- --color-sidebar-foreground: var(--sidebar-foreground);
- --color-sidebar-primary: var(--sidebar-primary);
- --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
- --color-sidebar-accent: var(--sidebar-accent);
- --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
- --color-sidebar-border: var(--sidebar-border);
- --color-sidebar-ring: var(--sidebar-ring);
-
- --color-dark-bg: #18181b;
- --color-dark-bg-darker: #0e0e10;
- --color-dark-bg-darkest: #09090b;
- --color-dark-bg-input: #222225;
- --color-dark-bg-button: #23232a;
- --color-dark-bg-active: #1d1d1f;
- --color-dark-bg-header: #131316;
- --color-dark-border: #303032;
- --color-dark-border-active: #2d2d30;
- --color-dark-border-hover: #434345;
- --color-dark-hover: #2d2d30;
- --color-dark-active: #2a2a2c;
- --color-dark-pressed: #1a1a1c;
- --color-dark-hover-alt: #2a2a2d;
- --color-dark-border-light: #5a5a5d;
- --color-dark-bg-light: #141416;
- --color-dark-border-medium: #373739;
- --color-dark-bg-very-light: #101014;
- --color-dark-bg-panel: #1b1b1e;
- --color-dark-border-panel: #222224;
- --color-dark-bg-panel-hover: #232327;
-
- --color-canvas: var(--bg-base);
- --color-elevated: var(--bg-elevated);
- --color-surface: var(--bg-surface);
- --color-surface-hover: var(--bg-surface-hover);
- --color-field: var(--bg-input);
- --color-deepest: var(--bg-deepest);
- --color-header: var(--bg-header);
- --color-button: var(--bg-button);
- --color-active: var(--bg-active);
- --color-light: var(--bg-light);
- --color-subtle: var(--bg-subtle);
- --color-interact: var(--bg-interact);
- --color-hover: var(--bg-hover);
- --color-hover-alt: var(--bg-hover-alt);
- --color-pressed: var(--bg-pressed);
-
- --color-edge: var(--border-base);
- --color-edge-panel: var(--border-panel);
- --color-edge-subtle: var(--border-subtle);
- --color-edge-medium: var(--border-medium);
- --color-edge-hover: var(--border-hover);
- --color-edge-active: var(--border-active);
-
- --color-foreground-secondary: var(--foreground-secondary);
- --color-foreground-subtle: var(--foreground-subtle);
-
- --color-overlay: var(--bg-overlay);
-}
-
-.dark {
- --background: #09090b;
- --foreground: #fafafa;
- --card: #18181b;
- --card-foreground: #fafafa;
- --popover: #27272a;
- --popover-foreground: #fafafa;
- --primary: #e4e4e7;
- --primary-foreground: #27272a;
- --secondary: #3f3f46;
- --secondary-foreground: #fafafa;
- --muted: #27272a;
- --muted-foreground: #9ca3af;
- --accent: #3f3f46;
- --accent-foreground: #fafafa;
- --destructive: #f87171;
- --border: #ffffff1a;
- --input: #ffffff26;
- --ring: #71717a;
- --chart-1: #3b82f6;
- --chart-2: #34d399;
- --chart-3: #f4a261;
- --chart-4: #a855f7;
- --chart-5: #f43f5e;
- --sidebar: #18181b;
- --sidebar-foreground: #fafafa;
- --sidebar-primary: #3b82f6;
- --sidebar-primary-foreground: #fafafa;
- --sidebar-accent: #3f3f46;
- --sidebar-accent-foreground: #fafafa;
- --sidebar-border: #ffffff1a;
- --sidebar-ring: #71717a;
-
- --bg-base: #18181b;
- --bg-elevated: #0e0e10;
- --bg-surface: #1b1b1e;
- --bg-surface-hover: #232327;
- --bg-input: #222225;
- --bg-deepest: #09090b;
- --bg-header: #131316;
- --bg-button: #23232a;
- --bg-active: #1d1d1f;
- --bg-light: #141416;
- --bg-subtle: #101014;
- --bg-interact: #2a2a2c;
- --border-base: #303032;
- --border-panel: #222224;
- --border-subtle: #5a5a5d;
- --border-medium: #373739;
- --bg-hover: #2d2d30;
- --bg-hover-alt: #2a2a2d;
- --bg-pressed: #1a1a1c;
- --border-hover: #434345;
- --border-active: #2d2d30;
-
- --foreground-secondary: #d1d5db;
- --foreground-subtle: #6b7280;
-
- --scrollbar-thumb: #434345;
- --scrollbar-thumb-hover: #5a5a5d;
- --scrollbar-track: #18181b;
-
- --bg-overlay: rgba(0, 0, 0, 0.7);
-}
-
-.dracula {
- --background: #282a36;
- --foreground: #ffffff;
- --card: #343746;
- --card-foreground: #ffffff;
- --popover: #343746;
- --popover-foreground: #ffffff;
- --primary: #ffffff;
- --primary-foreground: #282a36;
- --secondary: #44475a;
- --secondary-foreground: #ffffff;
- --muted: #343746;
- --muted-foreground: #a6accd;
- --accent: #44475a;
- --accent-foreground: #ffffff;
- --destructive: #ff5555;
- --border: #44475a;
- --input: #343746;
- --ring: #8be9fd;
- --chart-1: #8be9fd;
- --chart-2: #50fa7b;
- --chart-3: #ffb86c;
- --chart-4: #bd93f9;
- --chart-5: #ff79c6;
- --sidebar: #1e1f29;
- --sidebar-foreground: #ffffff;
- --sidebar-primary: #8be9fd;
- --sidebar-primary-foreground: #1e1f29;
- --sidebar-accent: #44475a;
- --sidebar-accent-foreground: #ffffff;
- --sidebar-border: #44475a;
- --sidebar-ring: #8be9fd;
-
- --bg-base: #282a36;
- --bg-elevated: #343746;
- --bg-surface: #343746;
- --bg-surface-hover: #44475a;
- --bg-input: #343746;
- --bg-deepest: #1e1f29;
- --bg-header: #1e1f29;
- --bg-button: #343746;
- --bg-active: #44475a;
- --bg-light: #343746;
- --bg-subtle: #1e1f29;
- --bg-interact: #44475a;
- --border-base: #44475a;
- --border-panel: #1e1f29;
- --border-subtle: #44475a;
- --border-medium: #44475a;
- --bg-hover: #44475a;
- --bg-hover-alt: #44475a;
- --bg-pressed: #1e1f29;
- --border-hover: #6272a4;
- --border-active: #8be9fd;
-
- --foreground-secondary: #a6accd;
- --foreground-subtle: #6272a4;
-
- --scrollbar-thumb: #44475a;
- --scrollbar-thumb-hover: #6272a4;
- --scrollbar-track: #282a36;
-
- --bg-overlay: rgba(0, 0, 0, 0.8);
-}
-
-.gentlemansChoice {
- --background: #1a1c1a;
- --foreground: #d1c7a3;
- --card: #2a2c2a;
- --card-foreground: #d1c7a3;
- --popover: #2a2c2a;
- --popover-foreground: #d1c7a3;
- --primary: #d1c7a3;
- --primary-foreground: #1a1c1a;
- --secondary: #3e4437;
- --secondary-foreground: #d1c7a3;
- --muted: #2a2c2a;
- --muted-foreground: #8e8463;
- --accent: #3e4437;
- --accent-foreground: #d1c7a3;
- --destructive: #9d3a3a;
- --border: #3e4437;
- --input: #2a2c2a;
- --ring: #5a7a3a;
- --chart-1: #5a7a3a;
- --chart-2: #3a5a7a;
- --chart-3: #b39a3a;
- --chart-4: #7a3a5a;
- --chart-5: #3a7a7a;
- --sidebar: #151715;
- --sidebar-foreground: #d1c7a3;
- --sidebar-primary: #5a7a3a;
- --sidebar-primary-foreground: #151715;
- --sidebar-accent: #3e4437;
- --sidebar-accent-foreground: #d1c7a3;
- --sidebar-border: #3e4437;
- --sidebar-ring: #5a7a3a;
-
- --bg-base: #1a1c1a;
- --bg-elevated: #2a2c2a;
- --bg-surface: #2a2c2a;
- --bg-surface-hover: #3e4437;
- --bg-input: #2a2c2a;
- --bg-deepest: #151715;
- --bg-header: #151715;
- --bg-button: #2a2c2a;
- --bg-active: #3e4437;
- --bg-light: #2a2c2a;
- --bg-subtle: #151715;
- --bg-interact: #3e4437;
- --border-base: #3e4437;
- --border-panel: #151715;
- --border-subtle: #3e4437;
- --border-medium: #3e4437;
- --bg-hover: #3e4437;
- --bg-hover-alt: #3e4437;
- --bg-pressed: #151715;
- --border-hover: #5a7a3a;
- --border-active: #d1c7a3;
-
- --foreground-secondary: #8e8463;
- --foreground-subtle: #5e5841;
-
- --scrollbar-thumb: #3e4437;
- --scrollbar-thumb-hover: #5e5841;
- --scrollbar-track: #1a1c1a;
-
- --bg-overlay: rgba(0, 0, 0, 0.8);
-}
-
-.midnightEspresso {
- --background: #120f0d;
- --foreground: #ceb195;
- --card: #1f1a17;
- --card-foreground: #ceb195;
- --popover: #1f1a17;
- --popover-foreground: #ceb195;
- --primary: #ceb195;
- --primary-foreground: #120f0d;
- --secondary: #3d2b1f;
- --secondary-foreground: #ceb195;
- --muted: #1f1a17;
- --muted-foreground: #9a8a7a;
- --accent: #3d2b1f;
- --accent-foreground: #ceb195;
- --destructive: #a05a4a;
- --border: #3d2b1f;
- --input: #1f1a17;
- --ring: #7a8a5a;
- --chart-1: #7a8a5a;
- --chart-2: #5a7a9a;
- --chart-3: #b08a4a;
- --chart-4: #8a5a7a;
- --chart-5: #5a8a8a;
- --sidebar: #0d0b0a;
- --sidebar-foreground: #ceb195;
- --sidebar-primary: #7a8a5a;
- --sidebar-primary-foreground: #0d0b0a;
- --sidebar-accent: #3d2b1f;
- --sidebar-accent-foreground: #ceb195;
- --sidebar-border: #3d2b1f;
- --sidebar-ring: #7a8a5a;
-
- --bg-base: #120f0d;
- --bg-elevated: #1f1a17;
- --bg-surface: #1f1a17;
- --bg-surface-hover: #3d2b1f;
- --bg-input: #1f1a17;
- --bg-deepest: #0d0b0a;
- --bg-header: #0d0b0a;
- --bg-button: #1f1a17;
- --bg-active: #3d2b1f;
- --bg-light: #1f1a17;
- --bg-subtle: #0d0b0a;
- --bg-interact: #3d2b1f;
- --border-base: #3d2b1f;
- --border-panel: #0d0b0a;
- --border-subtle: #3d2b1f;
- --border-medium: #3d2b1f;
- --bg-hover: #3d2b1f;
- --bg-hover-alt: #3d2b1f;
- --bg-pressed: #0d0b0a;
- --border-hover: #7a8a5a;
- --border-active: #ceb195;
-
- --foreground-secondary: #9a8a7a;
- --foreground-subtle: #6a5a4a;
-
- --scrollbar-thumb: #3d2b1f;
- --scrollbar-thumb-hover: #6a5a4a;
- --scrollbar-track: #120f0d;
-
- --bg-overlay: rgba(0, 0, 0, 0.8);
-}
-
-.catppuccinMocha {
- --background: #1e1e2e;
- --foreground: #cdd6f4;
- --card: #181825;
- --card-foreground: #cdd6f4;
- --popover: #181825;
- --popover-foreground: #cdd6f4;
- --primary: #cdd6f4;
- --primary-foreground: #1e1e2e;
- --secondary: #313244;
- --secondary-foreground: #cdd6f4;
- --muted: #181825;
- --muted-foreground: #a6adc8;
- --accent: #313244;
- --accent-foreground: #cdd6f4;
- --destructive: #f38ba8;
- --border: #313244;
- --input: #181825;
- --ring: #89b4fa;
- --chart-1: #89b4fa;
- --chart-2: #a6e3a1;
- --chart-3: #f9e2af;
- --chart-4: #f5c2e7;
- --chart-5: #94e2d5;
- --sidebar: #11111b;
- --sidebar-foreground: #cdd6f4;
- --sidebar-primary: #89b4fa;
- --sidebar-primary-foreground: #11111b;
- --sidebar-accent: #313244;
- --sidebar-accent-foreground: #cdd6f4;
- --sidebar-border: #313244;
- --sidebar-ring: #89b4fa;
-
- --bg-base: #1e1e2e;
- --bg-elevated: #181825;
- --bg-surface: #181825;
- --bg-surface-hover: #313244;
- --bg-input: #181825;
- --bg-deepest: #11111b;
- --bg-header: #11111b;
- --bg-button: #181825;
- --bg-active: #313244;
- --bg-light: #181825;
- --bg-subtle: #11111b;
- --bg-interact: #313244;
- --border-base: #313244;
- --border-panel: #11111b;
- --border-subtle: #313244;
- --border-medium: #313244;
- --bg-hover: #313244;
- --bg-hover-alt: #313244;
- --bg-pressed: #11111b;
- --border-hover: #89b4fa;
- --border-active: #cdd6f4;
-
- --foreground-secondary: #a6adc8;
- --foreground-subtle: #7f849c;
-
- --scrollbar-thumb: #313244;
- --scrollbar-thumb-hover: #45475a;
- --scrollbar-track: #1e1e2e;
-
- --bg-overlay: rgba(0, 0, 0, 0.8);
-}
-
-@layer base {
- html,
- body {
- height: 100%;
- }
-
- * {
- @apply border-border outline-ring/50;
- }
-
- body {
- @apply bg-background text-foreground;
- }
-}
-
-.thin-scrollbar {
- scrollbar-width: thin;
- scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
-}
-
-.thin-scrollbar::-webkit-scrollbar {
- width: 6px;
- height: 6px;
-}
-
-.thin-scrollbar::-webkit-scrollbar-track {
- background: var(--scrollbar-track);
-}
-
-.thin-scrollbar::-webkit-scrollbar-thumb {
- background: var(--scrollbar-thumb);
- border-radius: 3px;
-}
-
-.thin-scrollbar::-webkit-scrollbar-thumb:hover {
- background: var(--scrollbar-thumb-hover);
-}
-
-.skinny-scrollbar {
- scrollbar-width: thin;
- scrollbar-color: var(--scrollbar-thumb) transparent;
-}
-
-.skinny-scrollbar::-webkit-scrollbar {
- width: 4px;
- height: 4px;
-}
-
-.skinny-scrollbar::-webkit-scrollbar-track {
- background: transparent;
-}
-
-.skinny-scrollbar::-webkit-scrollbar-thumb {
- background: var(--scrollbar-thumb);
- border-radius: 2px;
-}
-
-.skinny-scrollbar::-webkit-scrollbar-thumb:hover {
- background: var(--scrollbar-thumb-hover);
-}
-
-.h-fade {
- mask-image: linear-gradient(transparent, #000 6%, #000 94%, transparent);
-}
diff --git a/src/main.tsx b/src/main.tsx
index 4a30cbcdf..ff34a7ee0 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -1,72 +1,40 @@
/* eslint-disable react-refresh/only-export-components */
import { prepareClientCacheVersion } from "@/lib/client-cache-version";
-import { StrictMode, Suspense, lazy, useEffect, useState, useRef } from "react";
+import { StrictMode, Suspense, lazy, useState, useRef, useEffect } from "react";
import { createRoot } from "react-dom/client";
-import "./index.css";
+import "./ui/index.css";
import { ThemeProvider } from "@/components/theme-provider";
-import "./i18n/i18n";
+import "./ui/i18n/i18n";
import { isElectron } from "@/lib/electron";
+import { Toaster } from "@/components/sonner";
+import { Auth, getStoredAuth, clearStoredAuth } from "@/auth/Auth";
+import { applyAccentColor, applyFontSize } from "@/lib/theme";
+import type { FontSizeId } from "@/types/ui-types";
+import { useServiceWorker } from "@/hooks/use-service-worker";
-const DesktopApp = lazy(() => import("@/ui/desktop/DesktopApp.tsx"));
-const MobileApp = lazy(() =>
- import("@/ui/mobile/MobileApp.tsx").then((module) => ({
- default: module.MobileApp,
- })),
-);
-const HostManagerApp = lazy(
- () => import("./ui/desktop/apps/host-manager/HostManagerApp.tsx"),
-);
-const TerminalApp = lazy(
- () => import("./ui/desktop/apps/features/terminal/TerminalApp.tsx"),
+const AppShell = lazy(() =>
+ import("@/AppShell").then((m) => ({ default: m.AppShell })),
);
+
+// Full-screen apps opened via query params (e.g. from external links or Electron)
+const TerminalApp = lazy(() => import("@/features/terminal/TerminalApp"));
const FileManagerApp = lazy(
- () => import("./ui/desktop/apps/features/file-manager/FileManagerApp.tsx"),
-);
-const TunnelApp = lazy(
- () => import("./ui/desktop/apps/features/tunnel/TunnelApp.tsx"),
+ () => import("@/features/file-manager/FileManagerApp"),
);
+const TunnelApp = lazy(() => import("@/features/tunnel/TunnelApp"));
const ServerStatsApp = lazy(
- () => import("./ui/desktop/apps/features/server-stats/ServerStatsApp.tsx"),
-);
-const DockerApp = lazy(
- () => import("./ui/desktop/apps/features/docker/DockerApp.tsx"),
-);
-const GuacamoleApp = lazy(
- () => import("@/ui/desktop/apps/features/guacamole/GuacamoleApp.tsx"),
+ () => import("@/features/server-stats/ServerStatsApp"),
);
+const DockerApp = lazy(() => import("@/features/docker/DockerApp"));
+const GuacamoleApp = lazy(() => import("@/features/guacamole/GuacamoleApp"));
+
const ElectronVersionCheck = lazy(() =>
- import("@/ui/desktop/user/ElectronVersionCheck.tsx").then((module) => ({
+ import("@/user/ElectronVersionCheck").then((module) => ({
default: module.ElectronVersionCheck,
})),
);
-const FullscreenApp: React.FC = () => {
- const searchParams = new URLSearchParams(window.location.search);
- const view = searchParams.get("view");
- const hostId = searchParams.get("hostId");
-
- switch (view) {
- case "host-manager":
- return <HostManagerApp />;
- case "terminal":
- return <TerminalApp hostId={hostId || undefined} />;
- case "file-manager":
- return <FileManagerApp hostId={hostId || undefined} />;
- case "tunnel":
- return <TunnelApp hostId={hostId || undefined} />;
- case "server-stats":
- return <ServerStatsApp hostId={hostId || undefined} />;
- case "docker":
- return <DockerApp hostId={hostId || undefined} />;
- case "rdp":
- case "vnc":
- case "telnet":
- return <GuacamoleApp hostId={hostId || undefined} />;
- default:
- return <DesktopApp />;
- }
-};
-import { useServiceWorker } from "@/hooks/use-service-worker";
+type Phase = "idle-auth" | "fading-in" | "idle-app" | "fading-out";
function useWindowWidth() {
const [width, setWidth] = useState(window.innerWidth);
@@ -75,19 +43,17 @@ function useWindowWidth() {
const hasSwitchedOnce = useRef(false);
useEffect(() => {
- let timeoutId: NodeJS.Timeout;
+ let timeoutId: number;
const handleResize = () => {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
const newWidth = window.innerWidth;
const newIsMobile = newWidth < 768;
const now = Date.now();
-
if (hasSwitchedOnce.current && now - lastSwitchTime.current < 10000) {
setWidth(newWidth);
return;
}
-
if (
newIsMobile !== isCurrentlyMobile.current &&
now - lastSwitchTime.current > 5000
@@ -102,7 +68,6 @@ function useWindowWidth() {
}, 2000);
};
window.addEventListener("resize", handleResize);
-
return () => {
clearTimeout(timeoutId);
window.removeEventListener("resize", handleResize);
@@ -112,6 +77,106 @@ function useWindowWidth() {
return width;
}
+function FullscreenApp() {
+ const searchParams = new URLSearchParams(window.location.search);
+ const view = searchParams.get("view");
+ const hostId = searchParams.get("hostId");
+
+ switch (view) {
+ case "terminal":
+ return <TerminalApp hostId={hostId || undefined} />;
+ case "file-manager":
+ return <FileManagerApp hostId={hostId || undefined} />;
+ case "tunnel":
+ return <TunnelApp hostId={hostId || undefined} />;
+ case "server-stats":
+ return <ServerStatsApp hostId={hostId || undefined} />;
+ case "docker":
+ return <DockerApp hostId={hostId || undefined} />;
+ case "rdp":
+ case "vnc":
+ case "telnet":
+ return <GuacamoleApp hostId={hostId || undefined} />;
+ default:
+ return null;
+ }
+}
+
+function App() {
+ const stored = getStoredAuth();
+ const [phase, setPhase] = useState<Phase>(
+ stored?.loggedIn ? "idle-app" : "idle-auth",
+ );
+ const [authUsername, setAuthUsername] = useState(stored?.username ?? "");
+ const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
+
+ useEffect(() => {
+ const savedAccent = localStorage.getItem("termix-accent");
+ if (savedAccent) applyAccentColor(savedAccent);
+ const savedSize = localStorage.getItem(
+ "termix-font-size",
+ ) as FontSizeId | null;
+ applyFontSize(savedSize ?? "lg");
+ return () => {
+ if (timerRef.current) clearTimeout(timerRef.current);
+ };
+ }, []);
+
+ function handleLogin(u: string) {
+ setAuthUsername(u);
+ setPhase("fading-in");
+ timerRef.current = setTimeout(() => setPhase("idle-app"), 450);
+ }
+
+ function handleLogout() {
+ clearStoredAuth();
+ setPhase("fading-out");
+ timerRef.current = setTimeout(() => {
+ setAuthUsername("");
+ setPhase("idle-auth");
+ }, 450);
+ }
+
+ const showApp =
+ phase === "idle-app" || phase === "fading-in" || phase === "fading-out";
+ const showAuth =
+ phase === "idle-auth" || phase === "fading-in" || phase === "fading-out";
+ const appOpacity = phase === "idle-app" ? 1 : 0;
+ const authOpacity = phase === "idle-auth" ? 1 : 0;
+
+ return (
+ <>
+ {showApp && (
+ <div
+ className="fixed inset-0 z-0 transition-opacity duration-[450ms] ease-in-out"
+ style={{
+ opacity: appOpacity,
+ pointerEvents: phase === "idle-app" ? "auto" : "none",
+ }}
+ >
+ <Suspense fallback={null}>
+ <AppShell username={authUsername} onLogout={handleLogout} />
+ </Suspense>
+ </div>
+ )}
+
+ {showAuth && (
+ <div
+ className="fixed inset-0 z-10 transition-opacity duration-[450ms] ease-in-out"
+ style={{
+ opacity: authOpacity,
+ pointerEvents: phase === "idle-auth" ? "auto" : "none",
+ }}
+ >
+ <Auth onLogin={handleLogin} />
+ </div>
+ )}
+
+ <Toaster position="bottom-right" />
+ </>
+ );
+}
+
function RootApp() {
const width = useWindowWidth();
const isMobile = width < 768;
@@ -125,61 +190,26 @@ function RootApp() {
(window as Window & { opera?: string }).opera ||
"";
const isTermixMobile = /Termix-Mobile/.test(userAgent);
-
const searchParams = new URLSearchParams(window.location.search);
const isFullscreen = searchParams.has("view");
- const renderApp = () => {
- if (isFullscreen) {
- return <FullscreenApp />;
- }
-
- if (isElectron()) {
- return <DesktopApp />;
- }
-
- if (isTermixMobile) {
- return <MobileApp key="mobile" />;
- }
+ if (isFullscreen) {
+ return (
+ <Suspense fallback={null}>
+ <FullscreenApp />
+ </Suspense>
+ );
+ }
- return isMobile ? <MobileApp key="mobile" /> : <DesktopApp key="desktop" />;
- };
+ if (isElectron() && showVersionCheck) {
+ return (
+ <Suspense fallback={null}>
+ <ElectronVersionCheck onContinue={() => setShowVersionCheck(false)} />
+ </Suspense>
+ );
+ }
- return (
- <>
- {!isFullscreen && (
- <div
- className="fixed inset-0 pointer-events-none"
- style={{
- backgroundColor: "var(--bg-base)",
- backgroundImage: `linear-gradient(
- 135deg,
- transparent 0%,
- transparent 49%,
- rgba(128, 128, 128, 0.03) 49%,
- rgba(128, 128, 128, 0.03) 51%,
- transparent 51%,
- transparent 100%
- )`,
- backgroundSize: "80px 80px",
- zIndex: 0,
- }}
- />
- )}
- <div className="relative min-h-screen" style={{ zIndex: 1 }}>
- {isElectron() && showVersionCheck && !isFullscreen ? (
- <Suspense fallback={null}>
- <ElectronVersionCheck
- onContinue={() => setShowVersionCheck(false)}
- isAuthenticated={false}
- />
- </Suspense>
- ) : (
- <Suspense fallback={null}>{renderApp()}</Suspense>
- )}
- </div>
- </>
- );
+ return <App />;
}
prepareClientCacheVersion().finally(() => {
diff --git a/src/ui/AppShell.tsx b/src/ui/AppShell.tsx
new file mode 100644
index 000000000..6d620eef7
--- /dev/null
+++ b/src/ui/AppShell.tsx
@@ -0,0 +1,608 @@
+import { Separator } from "@/components/separator";
+import { Button } from "@/components/button";
+import { Sheet, SheetContent } from "@/components/sheet";
+import { ChevronLeft, ChevronRight, Maximize2 } from "lucide-react";
+import { useState, useRef, useCallback, useEffect } from "react";
+import { useIsMobile } from "@/hooks/use-mobile";
+import { MobileBottomBar } from "@/shell/MobileBottomBar";
+import { CommandPalette } from "@/shell/CommandPalette";
+import { AppRail } from "@/sidebar/AppRail";
+import type { RailView } from "@/sidebar/AppRail";
+import { HostsPanel } from "@/sidebar/HostsPanel";
+import { QuickConnectPanel } from "@/sidebar/QuickConnectPanel";
+import { SshToolsPanel } from "@/sidebar/SshToolsPanel";
+import { SnippetsPanel } from "@/sidebar/SnippetsPanel";
+import { HistoryPanel } from "@/sidebar/HistoryPanel";
+import { SplitScreenPanel } from "@/sidebar/SplitScreenPanel";
+import { UserProfilePanel } from "@/sidebar/UserProfilePanel";
+import { AdminSettingsPanel } from "@/sidebar/AdminSettingsPanel";
+import { SplitView } from "@/shell/SplitView";
+import { TabBar } from "@/shell/TabBar";
+import type {
+ Tab,
+ TabType,
+ Host,
+ SplitMode,
+ HostFolder,
+} from "@/types/ui-types";
+import { getSSHHosts } from "@/main-axios";
+import type { SSHHostWithStatus } from "@/main-axios";
+
+function sshHostToHost(h: SSHHostWithStatus): Host {
+ return {
+ id: String(h.id),
+ name: h.name,
+ username: h.username,
+ ip: h.ip,
+ port: h.port,
+ folder: h.folder ?? "",
+ online: h.status === "online",
+ cpu: 0,
+ ram: 0,
+ lastAccess: "",
+ tags: h.tags ?? [],
+ authType: h.authType,
+ password: h.password,
+ key: typeof h.key === "string" ? h.key : undefined,
+ keyPassword: h.keyPassword,
+ keyType: h.keyType,
+ credentialId: h.credentialId != null ? String(h.credentialId) : undefined,
+ notes: h.notes,
+ pin: h.pin ?? false,
+ macAddress: h.macAddress,
+ enableTerminal: h.enableTerminal ?? true,
+ enableTunnel: h.enableTunnel ?? false,
+ enableFileManager: h.enableFileManager ?? false,
+ enableDocker: h.enableDocker ?? false,
+ enableSsh: h.connectionType === "ssh" || !h.connectionType,
+ enableRdp: h.connectionType === "rdp",
+ enableVnc: h.connectionType === "vnc",
+ enableTelnet: h.connectionType === "telnet",
+ sshPort: h.port,
+ rdpPort: 3389,
+ vncPort: 5900,
+ telnetPort: 23,
+ quickActions: (h.quickActions ?? []).map((a) => ({
+ name: a.name,
+ snippetId: String(a.snippetId),
+ })),
+ serverTunnels: [],
+ defaultPath: h.defaultPath,
+ terminalConfig: h.terminalConfig as Host["terminalConfig"],
+ useSocks5: h.useSocks5,
+ socks5Host: h.socks5Host,
+ socks5Port: h.socks5Port,
+ socks5Username: h.socks5Username,
+ socks5Password: h.socks5Password,
+ };
+}
+
+function buildHostTree(hosts: SSHHostWithStatus[]): HostFolder {
+ const root: HostFolder = { name: "root", children: [] };
+ const folderMap = new Map<string, HostFolder>();
+ const getOrCreateFolder = (path: string): HostFolder => {
+ if (folderMap.has(path)) return folderMap.get(path)!;
+ const parts = path.split(" / ");
+ let current = root;
+ let accumulated = "";
+ for (const part of parts) {
+ accumulated = accumulated ? `${accumulated} / ${part}` : part;
+ if (!folderMap.has(accumulated)) {
+ const folder: HostFolder = { name: part, children: [] };
+ folderMap.set(accumulated, folder);
+ current.children.push(folder);
+ }
+ current = folderMap.get(accumulated)!;
+ }
+ return current;
+ };
+ for (const h of hosts) {
+ const host = sshHostToHost(h);
+ if (h.folder) {
+ getOrCreateFolder(h.folder).children.push(host);
+ } else {
+ root.children.push(host);
+ }
+ }
+ return root;
+}
+export { tabIcon, renderTabContent } from "@/shell/tabUtils";
+import { renderTabContent } from "@/shell/tabUtils";
+
+const DASHBOARD_TAB: Tab = {
+ id: "dashboard",
+ type: "dashboard",
+ label: "Dashboard",
+};
+
+const SINGLETON_TAB_LABELS: Partial<Record<TabType, string>> = {
+ "host-manager": "Host Manager",
+ docker: "Docker",
+ tunnel: "Tunnels",
+};
+
+// ─── AppShell ────────────────────────────────────────────────────────────────
+
+export function AppShell({
+ username,
+ onLogout,
+}: {
+ username: string;
+ onLogout: () => void;
+}) {
+ const [tabs, setTabs] = useState<Tab[]>([DASHBOARD_TAB]);
+ const [activeTabId, setActiveTabId] = useState("dashboard");
+ const [commandPaletteOpen, setCommandPaletteOpen] = useState(false);
+ const [splitMode, setSplitMode] = useState<SplitMode>("none");
+ const [paneTabIds, setPaneTabIds] = useState<(string | null)[]>(
+ Array(6).fill(null),
+ );
+ const [realHostTree, setRealHostTree] = useState<HostFolder | null>(null);
+ const [allHosts, setAllHosts] = useState<Host[]>([]);
+
+ const [sidebarOpen, setSidebarOpen] = useState(true);
+ const [railView, setRailView] = useState<RailView>("hosts");
+ const [profileDropdownOpen, setProfileDropdownOpen] = useState(false);
+ const [hostManagerExpanded, setHostManagerExpanded] = useState(false);
+ const [sidebarWidth, setSidebarWidth] = useState(256);
+ const [sidebarDragging, setSidebarDragging] = useState(false);
+
+ const isMobile = useIsMobile();
+
+ // Close the sidebar when switching to mobile (it becomes a sheet overlay)
+ useEffect(() => {
+ if (isMobile) setSidebarOpen(false);
+ }, [isMobile]);
+
+ const pendingHostManagerEditId = useRef<string | null>(null);
+ const pendingHostManagerAction = useRef<"add-host" | "add-credential" | null>(
+ null,
+ );
+ const lastShiftTime = useRef(0);
+
+ const sidebarTitle: Record<RailView, string> = {
+ hosts: "Hosts",
+ "quick-connect": "Quick Connect",
+ "ssh-tools": "SSH Tools",
+ snippets: "Snippets",
+ history: "History",
+ "split-screen": "Split Screen",
+ "user-profile": "User Profile",
+ "admin-settings": "Admin Settings",
+ };
+
+ // Double-shift opens command palette
+ useEffect(() => {
+ const handleKeyDown = (e: KeyboardEvent) => {
+ if (e.code === "ShiftLeft") {
+ const now = Date.now();
+ if (now - lastShiftTime.current < 300)
+ setCommandPaletteOpen((prev) => !prev);
+ lastShiftTime.current = now;
+ }
+ };
+ window.addEventListener("keydown", handleKeyDown);
+ return () => window.removeEventListener("keydown", handleKeyDown);
+ }, []);
+
+ useEffect(() => {
+ const handle = () => onLogout();
+ window.addEventListener("termix:logout", handle);
+ return () => window.removeEventListener("termix:logout", handle);
+ }, [onLogout]);
+
+ // Load real hosts from API
+ const loadHosts = useCallback(async () => {
+ try {
+ const raw = await getSSHHosts();
+ const converted = raw.map(sshHostToHost);
+ setAllHosts(converted);
+ setRealHostTree(buildHostTree(raw));
+ } catch {
+ // Keep empty state on error
+ }
+ }, []);
+
+ useEffect(() => {
+ loadHosts();
+ }, [loadHosts]);
+
+ // Sync tab host data when allHosts updates (e.g. after editing terminal theme in host settings)
+ useEffect(() => {
+ if (allHosts.length === 0) return;
+ setTabs((prev) =>
+ prev.map((t) =>
+ t.host
+ ? { ...t, host: allHosts.find((h) => h.id === t.host!.id) ?? t.host }
+ : t,
+ ),
+ );
+ }, [allHosts]);
+
+ // Let HostManager trigger tab opens via custom event
+ useEffect(() => {
+ const handle = (e: Event) => {
+ const { hostId, type } = (
+ e as CustomEvent<{ hostId: string; type?: TabType }>
+ ).detail;
+ const host = allHosts.find((h) => h.id === hostId);
+ if (host) connectHost(host, type);
+ };
+ window.addEventListener("termix:open-tab", handle);
+ return () => window.removeEventListener("termix:open-tab", handle);
+ }, [tabs, allHosts]);
+
+ // ─── Tab management ──────────────────────────────────────────────────────
+
+ function openTab(host: Host, type: TabType) {
+ setTabs((prev) => {
+ const same = prev.filter(
+ (t) =>
+ t.type === type && t.label.replace(/ \(\d+\)$/, "") === host.name,
+ );
+ if (same.length === 0) {
+ const tab = {
+ id: `${host.name}-${type}`,
+ type,
+ label: host.name,
+ host,
+ };
+ setActiveTabId(tab.id);
+ return [...prev, tab];
+ }
+ const next = prev.map((t) =>
+ t.id === same[0].id && !/\(\d+\)$/.test(t.label)
+ ? { ...t, label: `${host.name} (1)`, host }
+ : t,
+ );
+ const tab = {
+ id: `${host.name}-${type}-${Date.now()}`,
+ type,
+ label: `${host.name} (${same.length + 1})`,
+ host,
+ };
+ setActiveTabId(tab.id);
+ return [...next, tab];
+ });
+ }
+
+ function connectHost(host: Host, preferredType?: TabType) {
+ const type: TabType =
+ preferredType ??
+ (host.enableSsh
+ ? "terminal"
+ : host.enableRdp
+ ? "rdp"
+ : host.enableVnc
+ ? "vnc"
+ : host.enableTelnet
+ ? "telnet"
+ : "terminal");
+ openTab(host, type);
+ }
+
+ function openSingletonTab(type: TabType, pendingEvent?: string) {
+ if (type === "host-manager") {
+ if (pendingEvent === "host-manager:add-host")
+ pendingHostManagerAction.current = "add-host";
+ else if (pendingEvent === "host-manager:add-credential")
+ pendingHostManagerAction.current = "add-credential";
+
+ setHostManagerExpanded(true);
+ setSidebarOpen(true);
+ setRailView("hosts");
+
+ if (pendingEvent) {
+ // Use a small delay to ensure HostManager is mounted if it wasn't already,
+ // and to allow the current render cycle to complete.
+ setTimeout(() => {
+ window.dispatchEvent(new CustomEvent(pendingEvent));
+ }, 0);
+ }
+ return;
+ }
+ if (type === "user-profile" || type === "admin-settings") {
+ handleRailClick(type as RailView);
+ return;
+ }
+ const id = type;
+ setTabs((prev) => {
+ if (prev.find((t) => t.id === id)) return prev;
+ return [...prev, { id, type, label: SINGLETON_TAB_LABELS[type] ?? type }];
+ });
+ setActiveTabId(id);
+ }
+
+ function closeTab(id: string) {
+ setTabs((prev) => {
+ const next = prev.filter((t) => t.id !== id);
+ if (id === activeTabId) setActiveTabId(next[next.length - 1].id);
+ return next;
+ });
+ }
+
+ // ─── Rail / sidebar ──────────────────────────────────────────────────────
+
+ function handleRailClick(view: RailView) {
+ if (railView === view && sidebarOpen) {
+ setSidebarOpen(false);
+ } else {
+ setRailView(view);
+ setSidebarOpen(true);
+ }
+ }
+
+ function editHostInManager(host: Host) {
+ pendingHostManagerEditId.current = host.id;
+ setHostManagerExpanded(true);
+ setSidebarOpen(true);
+ setRailView("hosts");
+ }
+
+ const onSidebarMouseDown = useCallback(
+ (e: React.MouseEvent) => {
+ e.preventDefault();
+ setSidebarDragging(true);
+ const startX = e.clientX;
+ const startW = sidebarWidth;
+ function onMove(ev: MouseEvent) {
+ setSidebarWidth(
+ Math.max(160, Math.min(480, startW + ev.clientX - startX)),
+ );
+ }
+ function onUp() {
+ setSidebarDragging(false);
+ window.removeEventListener("mousemove", onMove);
+ window.removeEventListener("mouseup", onUp);
+ }
+ window.addEventListener("mousemove", onMove);
+ window.addEventListener("mouseup", onUp);
+ },
+ [sidebarWidth],
+ );
+
+ const activeTab = tabs.find((t) => t.id === activeTabId)!;
+ const isSplit = splitMode !== "none";
+ const terminalTabs = tabs.filter((t) => t.type === "terminal");
+
+ // Sidebar panel content — shared between desktop inline sidebar and mobile sheet
+ const sidebarPanelContent = (
+ <div className="flex flex-col flex-1 min-h-0 overflow-hidden">
+ {railView === "hosts" && (
+ <HostsPanel
+ expanded={hostManagerExpanded}
+ onExpand={() => setHostManagerExpanded(true)}
+ onCollapse={() => {
+ setHostManagerExpanded(false);
+ loadHosts();
+ }}
+ pendingEditId={pendingHostManagerEditId}
+ pendingAction={pendingHostManagerAction}
+ onOpenTab={(host, type) => {
+ connectHost(host, type);
+ if (isMobile) setSidebarOpen(false);
+ }}
+ onEditHost={editHostInManager}
+ hostTree={realHostTree ?? undefined}
+ />
+ )}
+
+ {railView === "quick-connect" && <QuickConnectPanel />}
+
+ {railView === "ssh-tools" && (
+ <div className="flex-1 min-h-0 overflow-y-auto">
+ <SshToolsPanel
+ terminalTabs={terminalTabs}
+ activeTabId={activeTabId}
+ />
+ </div>
+ )}
+
+ {railView === "snippets" && (
+ <div className="flex-1 min-h-0 overflow-y-auto">
+ <SnippetsPanel
+ terminalTabs={terminalTabs}
+ activeTabId={activeTabId}
+ />
+ </div>
+ )}
+
+ {railView === "history" && (
+ <div className="flex flex-col flex-1 min-h-0 overflow-y-auto">
+ <HistoryPanel terminalTabs={terminalTabs} activeTabId={activeTabId} />
+ </div>
+ )}
+
+ {railView === "split-screen" && (
+ <div className="flex-1 min-h-0 overflow-y-auto">
+ <SplitScreenPanel
+ tabs={tabs}
+ splitMode={splitMode}
+ setSplitMode={setSplitMode}
+ paneTabIds={paneTabIds}
+ setPaneTabIds={setPaneTabIds}
+ />
+ </div>
+ )}
+
+ {railView === "user-profile" && (
+ <div className="flex-1 min-h-0 overflow-y-auto">
+ <UserProfilePanel username={username} onLogout={onLogout} />
+ </div>
+ )}
+
+ {railView === "admin-settings" && (
+ <div className="flex-1 min-h-0 overflow-y-auto">
+ <AdminSettingsPanel />
+ </div>
+ )}
+ </div>
+ );
+
+ // Sidebar header — shared
+ const sidebarHeader = (
+ <div className="flex flex-row items-center border-b border-border h-12.5 shrink-0">
+ <span className="flex-1 text-base font-bold tracking-tight text-foreground px-3">
+ {sidebarTitle[railView]}
+ </span>
+ {!hostManagerExpanded && !isMobile && (
+ <>
+ <Separator orientation="vertical" />
+ <Button
+ variant="ghost"
+ size="icon"
+ className="h-full w-12.5 rounded-none text-muted-foreground hover:text-foreground"
+ title="Reset width"
+ onClick={() => setSidebarWidth(256)}
+ >
+ <Maximize2 className="size-3.5" />
+ </Button>
+ </>
+ )}
+ <Separator orientation="vertical" />
+ <Button
+ variant="ghost"
+ size="icon"
+ className="h-full w-12.5 rounded-none text-muted-foreground hover:text-foreground"
+ onClick={() => {
+ setSidebarOpen(false);
+ setHostManagerExpanded(false);
+ }}
+ >
+ <ChevronLeft className="size-4" />
+ </Button>
+ </div>
+ );
+
+ return (
+ <>
+ <div className="flex w-screen bg-background" style={{ height: "100dvh" }}>
+ {/* Skinny icon rail — desktop only, hidden on mobile */}
+ <AppRail
+ railView={railView}
+ sidebarOpen={sidebarOpen}
+ splitMode={splitMode}
+ username={username}
+ profileDropdownOpen={profileDropdownOpen}
+ onProfileDropdownChange={setProfileDropdownOpen}
+ onRailClick={handleRailClick}
+ onLogout={onLogout}
+ />
+
+ {/* Desktop: inline resizable sidebar */}
+ {!isMobile && (
+ <div
+ className={`relative flex flex-col bg-sidebar shrink-0 overflow-hidden ${sidebarOpen ? `border-r transition-colors ${sidebarDragging ? "border-accent-brand/60" : "border-border"}` : ""}`}
+ style={{
+ width: sidebarOpen
+ ? hostManagerExpanded && railView === "hosts"
+ ? 720
+ : sidebarWidth
+ : 0,
+ transition: sidebarDragging ? "none" : "width 0.2s",
+ }}
+ >
+ {sidebarHeader}
+ {sidebarPanelContent}
+
+ {sidebarOpen && !(hostManagerExpanded && railView === "hosts") && (
+ <div
+ onMouseDown={onSidebarMouseDown}
+ className={`absolute right-0 top-0 bottom-0 w-1 cursor-col-resize z-30 transition-colors ${sidebarDragging ? "bg-accent-brand/60" : "hover:bg-accent-brand/40"}`}
+ />
+ )}
+ </div>
+ )}
+
+ {/* Mobile: sidebar as overlay sheet */}
+ {isMobile && (
+ <Sheet
+ open={sidebarOpen}
+ onOpenChange={(open) => {
+ setSidebarOpen(open);
+ if (!open) setHostManagerExpanded(false);
+ }}
+ >
+ <SheetContent
+ side="left"
+ showCloseButton={false}
+ className="p-0 flex flex-col w-[min(85vw,360px)] max-w-full bg-sidebar border-r border-border gap-0"
+ style={{ height: "100dvh" }}
+ >
+ {sidebarHeader}
+ {sidebarPanelContent}
+ </SheetContent>
+ </Sheet>
+ )}
+
+ {/* Main content area */}
+ <div
+ className={`relative flex flex-col flex-1 min-w-0 overflow-hidden transition-all duration-200 ${!isMobile && !sidebarOpen ? "pl-6" : ""}`}
+ >
+ {!isMobile && !sidebarOpen && (
+ <button
+ onClick={() => setSidebarOpen(true)}
+ title="Open Sidebar"
+ className="absolute left-0 top-0 bottom-0 z-20 flex items-center justify-center w-6 bg-sidebar border-r border-border text-muted-foreground hover:text-accent-brand hover:bg-accent-brand/5 transition-colors"
+ >
+ <ChevronRight className="size-3.5" />
+ </button>
+ )}
+ <div className="flex flex-col flex-1 min-w-0 min-h-0 overflow-hidden">
+ <TabBar
+ tabs={tabs}
+ activeTabId={activeTabId}
+ onSetActiveTab={setActiveTabId}
+ onCloseTab={closeTab}
+ onReorderTabs={setTabs}
+ />
+ <div className="flex flex-col flex-1 min-h-0 overflow-hidden">
+ {isSplit && !isMobile ? (
+ <SplitView
+ tabs={tabs}
+ paneTabIds={paneTabIds}
+ splitMode={splitMode}
+ onOpenSingletonTab={openSingletonTab}
+ onOpenTab={openTab}
+ />
+ ) : activeTab ? (
+ renderTabContent(activeTab, openSingletonTab, openTab)
+ ) : null}
+ </div>
+ </div>
+
+ {/* Bottom nav bar — mobile only */}
+ <MobileBottomBar
+ railView={railView}
+ sidebarOpen={sidebarOpen}
+ splitMode={splitMode}
+ onRailClick={handleRailClick}
+ />
+ </div>
+ </div>
+
+ <CommandPalette
+ isOpen={commandPaletteOpen}
+ setIsOpen={setCommandPaletteOpen}
+ hosts={allHosts}
+ onOpenTab={(type, label, pendingEvent) => {
+ if (
+ [
+ "dashboard",
+ "host-manager",
+ "user-profile",
+ "admin-settings",
+ "docker",
+ "tunnel",
+ ].includes(type)
+ ) {
+ openSingletonTab(type, pendingEvent);
+ } else if (label) {
+ const host = allHosts.find((h) => h.name === label);
+ if (host) openTab(host, type);
+ }
+ }}
+ />
+ </>
+ );
+}
diff --git a/src/ui/desktop/apps/admin/AdminSettings.tsx b/src/ui/admin/AdminSettings.tsx
similarity index 94%
rename from src/ui/desktop/apps/admin/AdminSettings.tsx
rename to src/ui/admin/AdminSettings.tsx
index 6ac257e71..d1b8a511b 100644
--- a/src/ui/desktop/apps/admin/AdminSettings.tsx
+++ b/src/ui/admin/AdminSettings.tsx
@@ -1,12 +1,12 @@
import React from "react";
-import { useSidebar } from "@/components/ui/sidebar.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
+import { useSidebar } from "@/components/sidebar.tsx";
+import { Separator } from "@/components/separator.tsx";
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
-} from "@/components/ui/tabs.tsx";
+} from "@/components/tabs.tsx";
import { Shield, Users, Database, Clock, Key } from "lucide-react";
import { toast } from "sonner";
import { useTranslation } from "react-i18next";
@@ -21,15 +21,15 @@ import {
isElectron,
getSessions,
unlinkOIDCFromPasswordAccount,
-} from "@/ui/main-axios.ts";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
-import { RolesTab } from "@/ui/desktop/apps/admin/tabs/RolesTab.tsx";
-import { GeneralSettingsTab } from "@/ui/desktop/apps/admin/tabs/GeneralSettingsTab.tsx";
-import { OIDCSettingsTab } from "@/ui/desktop/apps/admin/tabs/OIDCSettingsTab.tsx";
-import { UserManagementTab } from "@/ui/desktop/apps/admin/tabs/UserManagementTab.tsx";
-import { SessionManagementTab } from "@/ui/desktop/apps/admin/tabs/SessionManagementTab.tsx";
-import { DatabaseSecurityTab } from "@/ui/desktop/apps/admin/tabs/DatabaseSecurityTab.tsx";
-import { ApiKeysTab } from "@/ui/desktop/apps/admin/tabs/ApiKeysTab.tsx";
+} from "@/main-axios.ts";
+import { SimpleLoader } from "@/lib/SimpleLoader.tsx";
+import { RolesTab } from "@/admin/tabs/RolesTab.tsx";
+import { GeneralSettingsTab } from "@/admin/tabs/GeneralSettingsTab.tsx";
+import { OIDCSettingsTab } from "@/admin/tabs/OIDCSettingsTab.tsx";
+import { UserManagementTab } from "@/admin/tabs/UserManagementTab.tsx";
+import { SessionManagementTab } from "@/admin/tabs/SessionManagementTab.tsx";
+import { DatabaseSecurityTab } from "@/admin/tabs/DatabaseSecurityTab.tsx";
+import { ApiKeysTab } from "@/admin/tabs/ApiKeysTab.tsx";
import { CreateUserDialog } from "./dialogs/CreateUserDialog.tsx";
import { UserEditDialog } from "./dialogs/UserEditDialog.tsx";
import { LinkAccountDialog } from "./dialogs/LinkAccountDialog.tsx";
diff --git a/src/ui/desktop/apps/admin/dialogs/CreateUserDialog.tsx b/src/ui/admin/dialogs/CreateUserDialog.tsx
similarity index 92%
rename from src/ui/desktop/apps/admin/dialogs/CreateUserDialog.tsx
rename to src/ui/admin/dialogs/CreateUserDialog.tsx
index 47e5cc22c..d713db7c8 100644
--- a/src/ui/desktop/apps/admin/dialogs/CreateUserDialog.tsx
+++ b/src/ui/admin/dialogs/CreateUserDialog.tsx
@@ -6,16 +6,16 @@ import {
DialogHeader,
DialogTitle,
DialogFooter,
-} from "@/components/ui/dialog.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
+} from "@/components/dialog.tsx";
+import { Button } from "@/components/button.tsx";
+import { Label } from "@/components/label.tsx";
+import { Input } from "@/components/input.tsx";
+import { PasswordInput } from "@/components/password-input.tsx";
+import { Alert, AlertDescription, AlertTitle } from "@/components/alert.tsx";
import { useTranslation } from "react-i18next";
import { UserPlus, AlertCircle } from "lucide-react";
import { toast } from "sonner";
-import { registerUser } from "@/ui/main-axios.ts";
+import { registerUser } from "@/main-axios.ts";
interface CreateUserDialogProps {
open: boolean;
diff --git a/src/ui/desktop/apps/admin/dialogs/LinkAccountDialog.tsx b/src/ui/admin/dialogs/LinkAccountDialog.tsx
similarity index 93%
rename from src/ui/desktop/apps/admin/dialogs/LinkAccountDialog.tsx
rename to src/ui/admin/dialogs/LinkAccountDialog.tsx
index b99b09509..4bbfd967a 100644
--- a/src/ui/desktop/apps/admin/dialogs/LinkAccountDialog.tsx
+++ b/src/ui/admin/dialogs/LinkAccountDialog.tsx
@@ -6,15 +6,15 @@ import {
DialogFooter,
DialogHeader,
DialogTitle,
-} from "@/components/ui/dialog.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
+} from "@/components/dialog.tsx";
+import { Button } from "@/components/button.tsx";
+import { Label } from "@/components/label.tsx";
+import { Input } from "@/components/input.tsx";
+import { Alert, AlertDescription, AlertTitle } from "@/components/alert.tsx";
import { useTranslation } from "react-i18next";
import { Link2 } from "lucide-react";
import { toast } from "sonner";
-import { linkOIDCToPasswordAccount } from "@/ui/main-axios.ts";
+import { linkOIDCToPasswordAccount } from "@/main-axios.ts";
interface LinkAccountDialogProps {
open: boolean;
diff --git a/src/ui/desktop/apps/admin/dialogs/UserEditDialog.tsx b/src/ui/admin/dialogs/UserEditDialog.tsx
similarity index 97%
rename from src/ui/desktop/apps/admin/dialogs/UserEditDialog.tsx
rename to src/ui/admin/dialogs/UserEditDialog.tsx
index b8b415899..0f81cc9d3 100644
--- a/src/ui/desktop/apps/admin/dialogs/UserEditDialog.tsx
+++ b/src/ui/admin/dialogs/UserEditDialog.tsx
@@ -5,13 +5,13 @@ import {
DialogDescription,
DialogHeader,
DialogTitle,
-} from "@/components/ui/dialog.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import { Badge } from "@/components/ui/badge.tsx";
-import { Switch } from "@/components/ui/switch.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
+} from "@/components/dialog.tsx";
+import { Button } from "@/components/button.tsx";
+import { Label } from "@/components/label.tsx";
+import { Badge } from "@/components/badge.tsx";
+import { Switch } from "@/components/switch.tsx";
+import { Separator } from "@/components/separator.tsx";
+import { Alert, AlertDescription, AlertTitle } from "@/components/alert.tsx";
import { useTranslation } from "react-i18next";
import {
UserCog,
@@ -34,7 +34,7 @@ import {
deleteUser,
type UserRole,
type Role,
-} from "@/ui/main-axios.ts";
+} from "@/main-axios.ts";
interface User {
id: string;
diff --git a/src/ui/desktop/apps/admin/tabs/ApiKeysTab.tsx b/src/ui/admin/tabs/ApiKeysTab.tsx
similarity index 97%
rename from src/ui/desktop/apps/admin/tabs/ApiKeysTab.tsx
rename to src/ui/admin/tabs/ApiKeysTab.tsx
index 8e5a4a872..9528bb616 100644
--- a/src/ui/desktop/apps/admin/tabs/ApiKeysTab.tsx
+++ b/src/ui/admin/tabs/ApiKeysTab.tsx
@@ -1,5 +1,5 @@
import React from "react";
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import {
Table,
TableBody,
@@ -7,7 +7,7 @@ import {
TableHead,
TableHeader,
TableRow,
-} from "@/components/ui/table.tsx";
+} from "@/components/table.tsx";
import {
Dialog,
DialogContent,
@@ -15,12 +15,12 @@ import {
DialogFooter,
DialogHeader,
DialogTitle,
-} from "@/components/ui/dialog.tsx";
+} from "@/components/dialog.tsx";
import {
Popover,
PopoverContent,
PopoverTrigger,
-} from "@/components/ui/popover.tsx";
+} from "@/components/popover.tsx";
import {
Command,
CommandEmpty,
@@ -28,11 +28,11 @@ import {
CommandInput,
CommandItem,
CommandList,
-} from "@/components/ui/command.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import { Badge } from "@/components/ui/badge.tsx";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
+} from "@/components/command.tsx";
+import { Input } from "@/components/input.tsx";
+import { Label } from "@/components/label.tsx";
+import { Badge } from "@/components/badge.tsx";
+import { Alert, AlertDescription, AlertTitle } from "@/components/alert.tsx";
import {
Key,
Plus,
@@ -54,7 +54,7 @@ import {
getUserList,
type ApiKey,
type CreatedApiKey,
-} from "@/ui/main-axios.ts";
+} from "@/main-axios.ts";
interface UserOption {
id: string;
diff --git a/src/ui/desktop/apps/admin/tabs/DatabaseSecurityTab.tsx b/src/ui/admin/tabs/DatabaseSecurityTab.tsx
similarity index 98%
rename from src/ui/desktop/apps/admin/tabs/DatabaseSecurityTab.tsx
rename to src/ui/admin/tabs/DatabaseSecurityTab.tsx
index 18bfe9f32..916f6eb72 100644
--- a/src/ui/desktop/apps/admin/tabs/DatabaseSecurityTab.tsx
+++ b/src/ui/admin/tabs/DatabaseSecurityTab.tsx
@@ -1,9 +1,9 @@
import React from "react";
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import { Download, Upload } from "lucide-react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
-import { isElectron } from "@/ui/main-axios.ts";
+import { isElectron } from "@/main-axios.ts";
import { getBasePath } from "@/lib/base-path";
export function DatabaseSecurityTab(): React.ReactElement {
diff --git a/src/ui/desktop/apps/admin/tabs/GeneralSettingsTab.tsx b/src/ui/admin/tabs/GeneralSettingsTab.tsx
similarity index 98%
rename from src/ui/desktop/apps/admin/tabs/GeneralSettingsTab.tsx
rename to src/ui/admin/tabs/GeneralSettingsTab.tsx
index cf4dcaacf..a1c9ddb0b 100644
--- a/src/ui/desktop/apps/admin/tabs/GeneralSettingsTab.tsx
+++ b/src/ui/admin/tabs/GeneralSettingsTab.tsx
@@ -1,13 +1,13 @@
import React from "react";
-import { Checkbox } from "@/components/ui/checkbox.tsx";
-import { Input } from "@/components/ui/input.tsx";
+import { Checkbox } from "@/components/checkbox.tsx";
+import { Input } from "@/components/input.tsx";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
-} from "@/components/ui/select.tsx";
+} from "@/components/select.tsx";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
import { useConfirmation } from "@/hooks/use-confirmation.ts";
@@ -23,8 +23,8 @@ import {
updateLogLevel,
getSessionTimeout,
updateSessionTimeout,
-} from "@/ui/main-axios.ts";
-import { Button } from "@/components/ui/button.tsx";
+} from "@/main-axios.ts";
+import { Button } from "@/components/button.tsx";
interface GeneralSettingsTabProps {
allowRegistration: boolean;
diff --git a/src/ui/desktop/apps/admin/tabs/OIDCSettingsTab.tsx b/src/ui/admin/tabs/OIDCSettingsTab.tsx
similarity index 96%
rename from src/ui/desktop/apps/admin/tabs/OIDCSettingsTab.tsx
rename to src/ui/admin/tabs/OIDCSettingsTab.tsx
index 5c27a2c4c..713182129 100644
--- a/src/ui/desktop/apps/admin/tabs/OIDCSettingsTab.tsx
+++ b/src/ui/admin/tabs/OIDCSettingsTab.tsx
@@ -1,14 +1,14 @@
import React from "react";
-import { Button } from "@/components/ui/button.tsx";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
-import { Label } from "@/components/ui/label.tsx";
+import { Button } from "@/components/button.tsx";
+import { Alert, AlertDescription, AlertTitle } from "@/components/alert.tsx";
+import { Input } from "@/components/input.tsx";
+import { PasswordInput } from "@/components/password-input.tsx";
+import { Label } from "@/components/label.tsx";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
import { useConfirmation } from "@/hooks/use-confirmation.ts";
-import { Textarea } from "@/components/ui/textarea.tsx";
-import { updateOIDCConfig, disableOIDCConfig } from "@/ui/main-axios.ts";
+import { Textarea } from "@/components/textarea.tsx";
+import { updateOIDCConfig, disableOIDCConfig } from "@/main-axios.ts";
interface OIDCSettingsTabProps {
allowPasswordLogin: boolean;
diff --git a/src/ui/desktop/apps/admin/tabs/RolesTab.tsx b/src/ui/admin/tabs/RolesTab.tsx
similarity index 96%
rename from src/ui/desktop/apps/admin/tabs/RolesTab.tsx
rename to src/ui/admin/tabs/RolesTab.tsx
index 148f21009..520153f54 100644
--- a/src/ui/desktop/apps/admin/tabs/RolesTab.tsx
+++ b/src/ui/admin/tabs/RolesTab.tsx
@@ -1,5 +1,5 @@
import React from "react";
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import {
Dialog,
DialogContent,
@@ -7,7 +7,7 @@ import {
DialogFooter,
DialogHeader,
DialogTitle,
-} from "@/components/ui/dialog.tsx";
+} from "@/components/dialog.tsx";
import {
Table,
TableBody,
@@ -15,11 +15,11 @@ import {
TableHead,
TableHeader,
TableRow,
-} from "@/components/ui/table.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import { Textarea } from "@/components/ui/textarea.tsx";
-import { Badge } from "@/components/ui/badge.tsx";
+} from "@/components/table.tsx";
+import { Input } from "@/components/input.tsx";
+import { Label } from "@/components/label.tsx";
+import { Textarea } from "@/components/textarea.tsx";
+import { Badge } from "@/components/badge.tsx";
import { Shield, Plus, Edit, Trash2 } from "lucide-react";
import { toast } from "sonner";
import { useTranslation } from "react-i18next";
@@ -30,7 +30,7 @@ import {
updateRole,
deleteRole,
type Role,
-} from "@/ui/main-axios.ts";
+} from "@/main-axios.ts";
export function RolesTab(): React.ReactElement {
const { t } = useTranslation();
diff --git a/src/ui/desktop/apps/admin/tabs/SessionManagementTab.tsx b/src/ui/admin/tabs/SessionManagementTab.tsx
similarity index 97%
rename from src/ui/desktop/apps/admin/tabs/SessionManagementTab.tsx
rename to src/ui/admin/tabs/SessionManagementTab.tsx
index 344badfcc..e2a93274f 100644
--- a/src/ui/desktop/apps/admin/tabs/SessionManagementTab.tsx
+++ b/src/ui/admin/tabs/SessionManagementTab.tsx
@@ -1,5 +1,5 @@
import React from "react";
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import {
Table,
TableBody,
@@ -7,12 +7,12 @@ import {
TableHead,
TableHeader,
TableRow,
-} from "@/components/ui/table.tsx";
+} from "@/components/table.tsx";
import { Monitor, Smartphone, Globe, Trash2 } from "lucide-react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
import { useConfirmation } from "@/hooks/use-confirmation.ts";
-import { revokeSession, revokeAllUserSessions } from "@/ui/main-axios.ts";
+import { revokeSession, revokeAllUserSessions } from "@/main-axios.ts";
interface Session {
id: string;
diff --git a/src/ui/desktop/apps/admin/tabs/UserManagementTab.tsx b/src/ui/admin/tabs/UserManagementTab.tsx
similarity index 97%
rename from src/ui/desktop/apps/admin/tabs/UserManagementTab.tsx
rename to src/ui/admin/tabs/UserManagementTab.tsx
index e229755d6..a1a82616e 100644
--- a/src/ui/desktop/apps/admin/tabs/UserManagementTab.tsx
+++ b/src/ui/admin/tabs/UserManagementTab.tsx
@@ -1,5 +1,5 @@
import React from "react";
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import {
Table,
TableBody,
@@ -7,12 +7,12 @@ import {
TableHead,
TableHeader,
TableRow,
-} from "@/components/ui/table.tsx";
+} from "@/components/table.tsx";
import { UserPlus, Edit, Trash2, Link2, Unlink } from "lucide-react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
import { useConfirmation } from "@/hooks/use-confirmation.ts";
-import { deleteUser } from "@/ui/main-axios.ts";
+import { deleteUser } from "@/main-axios.ts";
interface User {
id: string;
diff --git a/src/ui/auth/Auth.tsx b/src/ui/auth/Auth.tsx
new file mode 100644
index 000000000..9e5a717ea
--- /dev/null
+++ b/src/ui/auth/Auth.tsx
@@ -0,0 +1,1192 @@
+import { useState, useEffect, useCallback, useRef } from "react";
+import { Button } from "@/components/button";
+import { Input } from "@/components/input";
+import { Separator } from "@/components/separator";
+import { toast } from "sonner";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@/components/dropdown-menu";
+import {
+ Eye,
+ EyeOff,
+ User,
+ KeyRound,
+ ArrowLeft,
+ Shield,
+ CheckCircle2,
+ Globe,
+ ChevronDown,
+} from "lucide-react";
+import { useTranslation } from "react-i18next";
+import i18n from "@/i18n/i18n";
+import {
+ loginUser,
+ registerUser,
+ getUserInfo,
+ getRegistrationAllowed,
+ getPasswordLoginAllowed,
+ getOIDCConfig,
+ getSetupRequired,
+ initiatePasswordReset,
+ verifyPasswordResetCode,
+ completePasswordReset,
+ getOIDCAuthorizeUrl,
+ verifyTOTPLogin,
+ getServerConfig,
+ saveServerConfig,
+ isElectron,
+ getEmbeddedServerStatus,
+} from "@/main-axios";
+import { ElectronServerConfig as ServerConfigComponent } from "@/auth/ElectronServerConfig";
+import { ElectronLoginForm } from "@/auth/ElectronLoginForm";
+import { Checkbox } from "@/components/checkbox";
+
+const STORAGE_KEY = "termix_auth";
+
+export function getStoredAuth(): {
+ loggedIn: boolean;
+ username: string;
+} | null {
+ try {
+ const raw = localStorage.getItem(STORAGE_KEY);
+ if (!raw) return null;
+ return JSON.parse(raw);
+ } catch {
+ return null;
+ }
+}
+
+export function clearStoredAuth() {
+ localStorage.removeItem(STORAGE_KEY);
+}
+
+function storeAuth(username: string) {
+ localStorage.setItem(
+ STORAGE_KEY,
+ JSON.stringify({ loggedIn: true, username }),
+ );
+}
+
+type AuthView = "login" | "register" | "reset" | "totp" | "external";
+type ResetStep = "email" | "code" | "newpass";
+
+interface AuthProps {
+ onLogin: (username: string, userId?: string, isAdmin?: boolean) => void;
+}
+
+interface ExtendedWindow extends Window {
+ IS_ELECTRON_WEBVIEW?: boolean;
+}
+
+const isInElectronWebView = () => {
+ if ((window as ExtendedWindow).IS_ELECTRON_WEBVIEW) return true;
+ try {
+ if (window.self !== window.top) return true;
+ } catch {
+ return true;
+ }
+ return false;
+};
+
+const AVAILABLE_LANGUAGES = [
+ { code: "en", label: "English" },
+ { code: "es", label: "Español" },
+ { code: "fr", label: "Français" },
+ { code: "de", label: "Deutsch" },
+ { code: "zh", label: "中文" },
+ { code: "ja", label: "日本語" },
+ { code: "pt", label: "Português" },
+ { code: "ru", label: "Русский" },
+ { code: "ar", label: "العربية" },
+ { code: "ko", label: "한국어" },
+];
+
+function PasswordInput({
+ value,
+ onChange,
+ placeholder,
+ disabled,
+ id,
+}: {
+ value: string;
+ onChange: (v: string) => void;
+ placeholder?: string;
+ disabled?: boolean;
+ id?: string;
+}) {
+ const [show, setShow] = useState(false);
+ return (
+ <div className="relative">
+ <Input
+ id={id}
+ type={show ? "text" : "password"}
+ value={value}
+ onChange={(e) => onChange(e.target.value)}
+ placeholder={placeholder ?? "••••••••"}
+ disabled={disabled}
+ className="pr-9 font-mono"
+ />
+ <button
+ type="button"
+ tabIndex={-1}
+ onClick={() => setShow((o) => !o)}
+ className="absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors"
+ >
+ {show ? <EyeOff className="size-4" /> : <Eye className="size-4" />}
+ </button>
+ </div>
+ );
+}
+
+function FieldLabel({
+ htmlFor,
+ children,
+}: {
+ htmlFor?: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <label
+ htmlFor={htmlFor}
+ className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground"
+ >
+ {children}
+ </label>
+ );
+}
+
+function Field({
+ label,
+ htmlFor,
+ children,
+}: {
+ label: string;
+ htmlFor?: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <div className="flex flex-col gap-1.5">
+ <FieldLabel htmlFor={htmlFor}>{label}</FieldLabel>
+ {children}
+ </div>
+ );
+}
+
+export function Auth({ onLogin }: AuthProps) {
+ const { t } = useTranslation();
+ const [view, setView] = useState<AuthView>("login");
+ const [loading, setLoading] = useState(false);
+ const [oidcLoading, setOidcLoading] = useState(false);
+ const [currentLang, setCurrentLang] = useState(
+ AVAILABLE_LANGUAGES.find((l) => l.code === i18n.language) ??
+ AVAILABLE_LANGUAGES[0],
+ );
+
+ const [username, setUsername] = useState("");
+ const [password, setPassword] = useState("");
+ const [confirmPassword, setConfirmPassword] = useState("");
+ const [rememberMe, setRememberMe] = useState(() => {
+ try {
+ return localStorage.getItem("rememberMe") === "true";
+ } catch {
+ return false;
+ }
+ });
+
+ const [totpCode, setTotpCode] = useState("");
+ const [totpTempToken, setTotpTempToken] = useState("");
+ const totpInputRef = useRef<HTMLInputElement>(null);
+
+ const [resetStep, setResetStep] = useState<ResetStep>("email");
+ const [resetCode, setResetCode] = useState("");
+ const [newPassword, setNewPassword] = useState("");
+ const [confirmNewPassword, setConfirmNewPassword] = useState("");
+ const [resetTempToken, setResetTempToken] = useState("");
+
+ const [registrationAllowed, setRegistrationAllowed] = useState(true);
+ const [passwordLoginAllowed, setPasswordLoginAllowed] = useState(true);
+ const [oidcConfigured, setOidcConfigured] = useState(false);
+ const [firstUser, setFirstUser] = useState(false);
+ const [dbConnectionFailed, setDbConnectionFailed] = useState(false);
+ const [dbHealthChecking, setDbHealthChecking] = useState(true);
+
+ const [showServerConfig, setShowServerConfig] = useState<boolean | null>(
+ null,
+ );
+ const [currentServerUrl, setCurrentServerUrl] = useState("");
+ const [webviewAuthSuccess, setWebviewAuthSuccess] = useState(false);
+
+ useEffect(() => {
+ try {
+ localStorage.setItem("rememberMe", rememberMe.toString());
+ } catch {}
+ }, [rememberMe]);
+
+ useEffect(() => {
+ getRegistrationAllowed()
+ .then((res) => setRegistrationAllowed(res.allowed))
+ .catch(() => {});
+ getPasswordLoginAllowed()
+ .then((res) => setPasswordLoginAllowed(res.allowed))
+ .catch(() => {});
+ getOIDCConfig()
+ .then((res) => setOidcConfigured(!!res))
+ .catch(() => setOidcConfigured(false));
+ }, []);
+
+ useEffect(() => {
+ if (showServerConfig) return;
+ setDbHealthChecking(true);
+ getSetupRequired()
+ .then((res) => {
+ if (res.setup_required) {
+ setFirstUser(true);
+ setView("register");
+ }
+ setDbConnectionFailed(false);
+ })
+ .catch(() => setDbConnectionFailed(true))
+ .finally(() => setDbHealthChecking(false));
+ }, [showServerConfig]);
+
+ useEffect(() => {
+ const checkElectron = async () => {
+ if (isInElectronWebView()) {
+ setShowServerConfig(false);
+ return;
+ }
+ if (isElectron()) {
+ try {
+ const [config, status] = await Promise.all([
+ getServerConfig(),
+ getEmbeddedServerStatus(),
+ ]);
+ if (
+ status?.embedded &&
+ status?.running &&
+ config &&
+ !config.serverUrl
+ ) {
+ setShowServerConfig(false);
+ setCurrentServerUrl("");
+ return;
+ }
+ setCurrentServerUrl(config?.serverUrl || "");
+ setShowServerConfig(!config || !config.serverUrl);
+ } catch {
+ setShowServerConfig(true);
+ }
+ } else {
+ setShowServerConfig(false);
+ }
+ };
+ checkElectron();
+ }, []);
+
+ useEffect(() => {
+ if (view === "totp" && totpInputRef.current) totpInputRef.current.focus();
+ }, [view]);
+
+ useEffect(() => {
+ const urlParams = new URLSearchParams(window.location.search);
+ const success = urlParams.get("success");
+ const error = urlParams.get("error");
+ if (error) {
+ if (error === "registration_disabled")
+ toast.error(t("messages.registrationDisabled"));
+ else if (error === "user_not_allowed")
+ toast.error(t("messages.userNotAllowed"));
+ else toast.error(`${t("errors.oidcAuthFailed")}: ${error}`);
+ window.history.replaceState({}, document.title, window.location.pathname);
+ return;
+ }
+ if (success) {
+ if (isInElectronWebView()) {
+ window.parent.postMessage(
+ {
+ type: "AUTH_SUCCESS",
+ source: "oidc_callback",
+ platform: "desktop",
+ timestamp: Date.now(),
+ },
+ window.location.origin,
+ );
+ setWebviewAuthSuccess(true);
+ window.history.replaceState(
+ {},
+ document.title,
+ window.location.pathname,
+ );
+ return;
+ }
+ getUserInfo()
+ .then((meRes) => {
+ storeAuth(meRes.username || "");
+ onLogin(
+ meRes.username || "",
+ meRes.userId || undefined,
+ !!meRes.is_admin,
+ );
+ window.history.replaceState(
+ {},
+ document.title,
+ window.location.pathname,
+ );
+ })
+ .catch(() => {
+ toast.error(t("errors.failedUserInfo"));
+ });
+ }
+ }, [onLogin, t]);
+
+ const handleElectronAuthSuccess = useCallback(
+ async (previousJwt: string | null) => {
+ try {
+ const cookieReady = await window.electronAPI?.waitForSessionCookie?.(
+ "jwt",
+ currentServerUrl,
+ previousJwt,
+ 5000,
+ );
+ if (cookieReady && !cookieReady.success)
+ throw new Error(cookieReady.error || "Auth cookie not ready");
+ const meRes = await getUserInfo();
+ if (!meRes) throw new Error("Failed to get user info");
+ storeAuth(meRes.username || "");
+ onLogin(
+ meRes.username || "",
+ meRes.userId || undefined,
+ !!meRes.is_admin,
+ );
+ toast.success(t("messages.loginSuccess"));
+ } catch {
+ toast.error(t("errors.failedUserInfo"));
+ }
+ },
+ [onLogin, currentServerUrl, t],
+ );
+
+ function resetAll() {
+ setUsername("");
+ setPassword("");
+ setConfirmPassword("");
+ setResetStep("email");
+ setResetCode("");
+ setNewPassword("");
+ setConfirmNewPassword("");
+ setResetTempToken("");
+ setTotpCode("");
+ setTotpTempToken("");
+ }
+
+ function switchView(v: AuthView) {
+ resetAll();
+ setView(v);
+ }
+
+ async function handleLogin(e: React.FormEvent) {
+ e.preventDefault();
+ if (!username.trim()) {
+ toast.error(t("errors.requiredField"));
+ return;
+ }
+ setLoading(true);
+ try {
+ const res = await loginUser(username.trim(), password, rememberMe);
+ if (res.requires_totp) {
+ setTotpTempToken(res.temp_token);
+ setView("totp");
+ return;
+ }
+ if (!res?.success) throw new Error(t("errors.loginFailed"));
+ if (isInElectronWebView()) {
+ window.parent.postMessage(
+ {
+ type: "AUTH_SUCCESS",
+ source: "auth_component",
+ platform: "desktop",
+ timestamp: Date.now(),
+ },
+ window.location.origin,
+ );
+ setWebviewAuthSuccess(true);
+ return;
+ }
+ const meRes = await getUserInfo();
+ storeAuth(meRes.username || username.trim());
+ toast.success(t("messages.loginSuccess"));
+ onLogin(
+ meRes.username || username.trim(),
+ meRes.userId || undefined,
+ !!meRes.is_admin,
+ );
+ } catch (err: unknown) {
+ const error = err as {
+ message?: string;
+ response?: { data?: { error?: string } };
+ };
+ toast.error(
+ error?.response?.data?.error ||
+ error?.message ||
+ t("errors.unknownError"),
+ );
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ async function handleRegister(e: React.FormEvent) {
+ e.preventDefault();
+ if (!username.trim()) {
+ toast.error(t("errors.requiredField"));
+ return;
+ }
+ if (password.length < 6) {
+ toast.error(t("errors.minLength", { min: 6 }));
+ return;
+ }
+ if (password !== confirmPassword) {
+ toast.error(t("errors.passwordMismatch"));
+ return;
+ }
+ setLoading(true);
+ try {
+ await registerUser(username.trim(), password);
+ const res = await loginUser(username.trim(), password, rememberMe);
+ if (res.requires_totp) {
+ setTotpTempToken(res.temp_token);
+ setView("totp");
+ return;
+ }
+ const meRes = await getUserInfo();
+ storeAuth(meRes.username || username.trim());
+ toast.success(t("messages.registrationSuccess"));
+ onLogin(
+ meRes.username || username.trim(),
+ meRes.userId || undefined,
+ !!meRes.is_admin,
+ );
+ } catch (err: unknown) {
+ const error = err as {
+ message?: string;
+ response?: { data?: { error?: string } };
+ };
+ toast.error(
+ error?.response?.data?.error ||
+ error?.message ||
+ t("errors.unknownError"),
+ );
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ async function handleTOTP(e: React.FormEvent) {
+ e.preventDefault();
+ if (totpCode.length !== 6) {
+ toast.error(t("auth.enterCode"));
+ return;
+ }
+ setLoading(true);
+ try {
+ const res = await verifyTOTPLogin(totpTempToken, totpCode, rememberMe);
+ if (!res?.success) throw new Error(t("errors.loginFailed"));
+ if (isInElectronWebView()) {
+ window.parent.postMessage(
+ {
+ type: "AUTH_SUCCESS",
+ source: "totp_auth_component",
+ platform: "desktop",
+ timestamp: Date.now(),
+ },
+ window.location.origin,
+ );
+ setWebviewAuthSuccess(true);
+ return;
+ }
+ storeAuth(res.username || username);
+ toast.success(t("messages.loginSuccess"));
+ onLogin(
+ res.username || username,
+ res.userId || undefined,
+ !!res.is_admin,
+ );
+ } catch (err: unknown) {
+ const error = err as {
+ message?: string;
+ response?: { data?: { error?: string; code?: string } };
+ };
+ if (error?.response?.data?.code === "SESSION_EXPIRED") {
+ setView("login");
+ toast.error(t("errors.sessionExpired"));
+ return;
+ }
+ toast.error(
+ error?.response?.data?.error ||
+ error?.message ||
+ t("errors.invalidTotpCode"),
+ );
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ async function handleResetInitiate(e: React.FormEvent) {
+ e.preventDefault();
+ if (!username.trim()) {
+ toast.error(t("errors.requiredField"));
+ return;
+ }
+ setLoading(true);
+ try {
+ await initiatePasswordReset(username.trim());
+ setResetStep("code");
+ toast.success(t("messages.resetCodeSent"));
+ } catch (err: unknown) {
+ const error = err as {
+ message?: string;
+ response?: { data?: { error?: string } };
+ };
+ toast.error(
+ error?.response?.data?.error ||
+ error?.message ||
+ t("errors.failedPasswordReset"),
+ );
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ async function handleResetVerify(e: React.FormEvent) {
+ e.preventDefault();
+ setLoading(true);
+ try {
+ const res = await verifyPasswordResetCode(username.trim(), resetCode);
+ setResetTempToken(res.tempToken as string);
+ setResetStep("newpass");
+ toast.success(t("messages.codeVerified"));
+ } catch (err: unknown) {
+ const error = err as {
+ message?: string;
+ response?: { data?: { error?: string } };
+ };
+ toast.error(
+ error?.response?.data?.error ||
+ error?.message ||
+ t("errors.failedVerifyCode"),
+ );
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ async function handleResetComplete(e: React.FormEvent) {
+ e.preventDefault();
+ if (newPassword.length < 6) {
+ toast.error(t("errors.minLength", { min: 6 }));
+ return;
+ }
+ if (newPassword !== confirmNewPassword) {
+ toast.error(t("errors.passwordMismatch"));
+ return;
+ }
+ setLoading(true);
+ try {
+ await completePasswordReset(username.trim(), resetTempToken, newPassword);
+ toast.success(t("messages.passwordResetSuccess"));
+ switchView("login");
+ } catch (err: unknown) {
+ const error = err as {
+ message?: string;
+ response?: { data?: { error?: string } };
+ };
+ toast.error(
+ error?.response?.data?.error ||
+ error?.message ||
+ t("errors.failedCompleteReset"),
+ );
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ async function handleOIDCLogin() {
+ setOidcLoading(true);
+ try {
+ const authResponse = await getOIDCAuthorizeUrl(rememberMe);
+ const { auth_url: authUrl } = authResponse;
+ if (!authUrl || authUrl === "undefined")
+ throw new Error(t("errors.invalidAuthUrl"));
+ window.location.replace(authUrl);
+ } catch (err: unknown) {
+ const error = err as {
+ message?: string;
+ response?: { data?: { error?: string } };
+ };
+ toast.error(
+ error?.response?.data?.error ||
+ error?.message ||
+ t("errors.failedOidcLogin"),
+ );
+ setOidcLoading(false);
+ }
+ }
+
+ function changeLanguage(lang: (typeof AVAILABLE_LANGUAGES)[0]) {
+ setCurrentLang(lang);
+ i18n.changeLanguage(lang.code);
+ localStorage.setItem("termix-language", lang.code);
+ }
+
+ // Electron server config / webview auth success screens
+ if (isElectron() && !isInElectronWebView()) {
+ if (showServerConfig === null)
+ return (
+ <div className="fixed inset-0 flex items-center justify-center bg-background">
+ <div className="w-5 h-5 border-2 border-primary border-t-transparent rounded-full animate-spin" />
+ </div>
+ );
+ if (showServerConfig)
+ return (
+ <div className="fixed inset-0 flex items-center justify-center bg-background p-6">
+ <div className="w-full max-w-md">
+ <ServerConfigComponent
+ onServerConfigured={() => window.location.reload()}
+ onUseEmbedded={async () => {
+ await saveServerConfig({
+ serverUrl: "",
+ lastUpdated: new Date().toISOString(),
+ });
+ setShowServerConfig(false);
+ setCurrentServerUrl("");
+ }}
+ onCancel={() => setShowServerConfig(false)}
+ isFirstTime={!currentServerUrl}
+ />
+ </div>
+ </div>
+ );
+ if (currentServerUrl && !webviewAuthSuccess)
+ return (
+ <div className="w-full h-screen flex items-center justify-center p-4 bg-background">
+ <div className="w-full max-w-4xl h-[90vh]">
+ <ElectronLoginForm
+ serverUrl={currentServerUrl}
+ onAuthSuccess={handleElectronAuthSuccess}
+ onChangeServer={() => setShowServerConfig(true)}
+ />
+ </div>
+ </div>
+ );
+ }
+
+ if (webviewAuthSuccess || (isInElectronWebView() && webviewAuthSuccess))
+ return (
+ <div className="fixed inset-0 flex items-center justify-center bg-background">
+ <div className="text-center">
+ <CheckCircle2 className="size-12 text-accent-brand mx-auto mb-4" />
+ <p className="text-muted-foreground">{t("auth.redirectingToApp")}</p>
+ </div>
+ </div>
+ );
+
+ if (dbConnectionFailed)
+ return (
+ <div className="fixed inset-0 flex items-center justify-center bg-background p-6">
+ <div className="flex flex-col gap-4 p-6 border border-border bg-card max-w-sm w-full">
+ <p className="font-bold text-destructive">
+ {t("errors.databaseConnection")}
+ </p>
+ <p className="text-sm text-muted-foreground">
+ {t("messages.databaseConnectionFailed")}
+ </p>
+ <Button onClick={() => window.location.reload()}>
+ {t("common.refresh")}
+ </Button>
+ </div>
+ </div>
+ );
+
+ if (dbHealthChecking && showServerConfig === false)
+ return (
+ <div className="fixed inset-0 flex items-center justify-center bg-background">
+ <div className="w-5 h-5 border-2 border-primary border-t-transparent rounded-full animate-spin" />
+ </div>
+ );
+
+ const TAB_ITEMS: { id: AuthView; label: string; show: boolean }[] = [
+ {
+ id: "login",
+ label: t("common.login"),
+ show: passwordLoginAllowed && !firstUser,
+ },
+ {
+ id: "register",
+ label: t("common.register"),
+ show: (passwordLoginAllowed || firstUser) && registrationAllowed,
+ },
+ { id: "external", label: t("auth.external"), show: oidcConfigured },
+ ];
+
+ return (
+ <div className="fixed inset-0 flex bg-background overflow-hidden">
+ {/* Left decorative panel */}
+ <div className="hidden lg:flex flex-col w-[420px] shrink-0 bg-sidebar border-r border-border relative overflow-hidden select-none">
+ <div
+ className="absolute inset-0"
+ style={{
+ backgroundImage:
+ "radial-gradient(circle, color-mix(in oklch, var(--border) 80%, transparent) 1px, transparent 1px)",
+ backgroundSize: "24px 24px",
+ }}
+ />
+ <div className="absolute inset-0 flex flex-col items-center justify-center gap-3 z-10 px-12">
+ <span className="text-4xl font-bold tracking-[0.3em] font-mono">
+ TERMIX
+ </span>
+ <div className="w-8 h-px bg-accent-brand" />
+ <span className="text-[11px] font-mono text-muted-foreground uppercase tracking-[0.25em]">
+ {t("auth.tagline")}
+ </span>
+ </div>
+ </div>
+
+ {/* Right panel — auth form */}
+ <div className="flex flex-1 items-center justify-center p-6 overflow-y-auto relative">
+ {/* Language selector */}
+ <div className="absolute top-4 right-4">
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <button className="flex items-center gap-1.5 px-2.5 py-1.5 text-xs text-muted-foreground hover:text-foreground border border-border hover:border-border/80 bg-background hover:bg-muted transition-colors">
+ <Globe className="size-3.5" />
+ <span className="font-mono">{currentLang.label}</span>
+ <ChevronDown className="size-3" />
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-36">
+ {AVAILABLE_LANGUAGES.map((lang) => (
+ <DropdownMenuItem
+ key={lang.code}
+ onClick={() => changeLanguage(lang)}
+ className={`text-xs font-mono ${currentLang.code === lang.code ? "text-accent-brand" : ""}`}
+ >
+ {lang.label}
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+
+ <div className="w-full max-w-sm flex flex-col gap-6">
+ {/* TOTP view */}
+ {view === "totp" && (
+ <div className="flex flex-col gap-5">
+ <div className="flex flex-col gap-1">
+ <h1 className="text-xl font-bold">{t("auth.twoFactorAuth")}</h1>
+ <p className="text-xs text-muted-foreground">
+ {t("auth.enterCode")}
+ </p>
+ </div>
+ <form onSubmit={handleTOTP} className="flex flex-col gap-4">
+ <Field label={t("auth.verifyCode")} htmlFor="totp-code">
+ <Input
+ ref={totpInputRef}
+ id="totp-code"
+ type="text"
+ placeholder="000000"
+ maxLength={6}
+ value={totpCode}
+ onChange={(e) =>
+ setTotpCode(e.target.value.replace(/\D/g, ""))
+ }
+ disabled={loading}
+ className="text-center text-2xl tracking-widest font-mono"
+ autoComplete="one-time-code"
+ />
+ </Field>
+ <Button
+ type="submit"
+ className="w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold"
+ disabled={loading || totpCode.length !== 6}
+ >
+ {loading ? t("common.loading") : t("auth.verifyCode")}
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ className="w-full"
+ onClick={() => switchView("login")}
+ disabled={loading}
+ >
+ {t("common.cancel")}
+ </Button>
+ </form>
+ </div>
+ )}
+
+ {/* Reset password view */}
+ {view === "reset" && (
+ <div className="flex flex-col gap-5">
+ <button
+ onClick={() => switchView("login")}
+ className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors w-fit"
+ >
+ <ArrowLeft className="size-3.5" />
+ {t("common.back")}
+ </button>
+ <div className="flex flex-col gap-1">
+ <h1 className="text-xl font-bold">
+ {t("auth.forgotPassword")}
+ </h1>
+ <p className="text-xs text-muted-foreground">
+ {t("auth.resetCodeDesc")}
+ </p>
+ </div>
+ <div className="flex items-center gap-2">
+ {(["email", "code", "newpass"] as ResetStep[]).map(
+ (step, i) => {
+ const stepIdx = ["email", "code", "newpass"].indexOf(
+ resetStep,
+ );
+ const done = i < stepIdx;
+ const active = i === stepIdx;
+ return (
+ <div
+ key={step}
+ className="flex items-center gap-2 flex-1"
+ >
+ <div
+ className={`size-5 flex items-center justify-center text-[10px] font-bold border transition-colors ${done ? "bg-accent-brand border-accent-brand text-background" : active ? "border-accent-brand text-accent-brand" : "border-border text-muted-foreground"}`}
+ >
+ {done ? <CheckCircle2 className="size-3" /> : i + 1}
+ </div>
+ {i < 2 && (
+ <div
+ className={`h-px flex-1 transition-colors ${done ? "bg-accent-brand" : "bg-border"}`}
+ />
+ )}
+ </div>
+ );
+ },
+ )}
+ </div>
+ {resetStep === "email" && (
+ <form
+ onSubmit={handleResetInitiate}
+ className="flex flex-col gap-4"
+ >
+ <Field label={t("common.username")} htmlFor="reset-user">
+ <Input
+ id="reset-user"
+ value={username}
+ onChange={(e) => setUsername(e.target.value)}
+ placeholder="your_username"
+ disabled={loading}
+ />
+ </Field>
+ <Button
+ type="submit"
+ className="w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold"
+ disabled={loading}
+ >
+ {loading ? t("common.loading") : t("auth.sendResetCode")}
+ </Button>
+ </form>
+ )}
+ {resetStep === "code" && (
+ <form
+ onSubmit={handleResetVerify}
+ className="flex flex-col gap-4"
+ >
+ <Field label={t("auth.resetCode")} htmlFor="reset-code">
+ <Input
+ id="reset-code"
+ value={resetCode}
+ onChange={(e) =>
+ setResetCode(e.target.value.replace(/\D/g, ""))
+ }
+ placeholder="000000"
+ maxLength={6}
+ className="text-center font-mono text-lg tracking-widest"
+ disabled={loading}
+ />
+ </Field>
+ <Button
+ type="submit"
+ className="w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold"
+ disabled={loading || resetCode.length !== 6}
+ >
+ {loading ? t("common.loading") : t("auth.verifyCodeButton")}
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ className="w-full"
+ onClick={() => setResetStep("email")}
+ disabled={loading}
+ >
+ {t("common.back")}
+ </Button>
+ </form>
+ )}
+ {resetStep === "newpass" && (
+ <form
+ onSubmit={handleResetComplete}
+ className="flex flex-col gap-4"
+ >
+ <Field label={t("auth.newPassword")} htmlFor="new-pass">
+ <PasswordInput
+ id="new-pass"
+ value={newPassword}
+ onChange={setNewPassword}
+ disabled={loading}
+ />
+ </Field>
+ <Field
+ label={t("auth.confirmNewPassword")}
+ htmlFor="confirm-new-pass"
+ >
+ <PasswordInput
+ id="confirm-new-pass"
+ value={confirmNewPassword}
+ onChange={setConfirmNewPassword}
+ disabled={loading}
+ />
+ </Field>
+ <Button
+ type="submit"
+ className="w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold"
+ disabled={loading}
+ >
+ {loading
+ ? t("common.loading")
+ : t("auth.resetPasswordButton")}
+ </Button>
+ </form>
+ )}
+ </div>
+ )}
+
+ {/* Login / Register / External */}
+ {(view === "login" || view === "register" || view === "external") && (
+ <div className="flex flex-col gap-5">
+ <div className="flex border border-border overflow-hidden">
+ {TAB_ITEMS.filter((item) => item.show).map((item) => (
+ <button
+ key={item.id}
+ onClick={() => switchView(item.id)}
+ className={`flex-1 py-2.5 text-xs font-bold uppercase tracking-widest transition-colors ${view === item.id ? "bg-accent-brand text-background" : "text-muted-foreground hover:text-foreground hover:bg-muted"}`}
+ >
+ {item.label}
+ </button>
+ ))}
+ </div>
+
+ <div className="flex flex-col gap-1">
+ <h1 className="text-xl font-bold">
+ {view === "login"
+ ? t("auth.loginTitle")
+ : view === "register"
+ ? t("auth.registerTitle")
+ : t("auth.loginWithExternal")}
+ </h1>
+ <p className="text-xs text-muted-foreground">
+ {view === "login"
+ ? t("auth.loginSubtitle", "")
+ : view === "register"
+ ? t("auth.registerSubtitle", "")
+ : t("auth.loginWithExternalDesc")}
+ </p>
+ </div>
+
+ {view === "external" && (
+ <div className="flex flex-col gap-4">
+ {isElectron() ? (
+ <p className="text-xs text-muted-foreground text-center">
+ {t("auth.externalNotSupportedInElectron")}
+ </p>
+ ) : (
+ <>
+ <div className="flex items-center gap-2">
+ <Checkbox
+ id="rememberOIDC"
+ checked={rememberMe}
+ onCheckedChange={(v) => setRememberMe(v === true)}
+ />
+ <label
+ htmlFor="rememberOIDC"
+ className="text-xs text-muted-foreground cursor-pointer"
+ >
+ {t("auth.rememberMe")}
+ </label>
+ </div>
+ <Button
+ onClick={handleOIDCLogin}
+ disabled={oidcLoading}
+ className="w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold"
+ >
+ {oidcLoading
+ ? t("common.loading")
+ : t("auth.loginWithExternal")}
+ </Button>
+ </>
+ )}
+ </div>
+ )}
+
+ {view === "login" && (
+ <form onSubmit={handleLogin} className="flex flex-col gap-4">
+ <Field label={t("common.username")} htmlFor="login-user">
+ <div className="relative">
+ <User className="absolute left-2.5 top-1/2 -translate-y-1/2 size-4 text-muted-foreground pointer-events-none" />
+ <Input
+ id="login-user"
+ value={username}
+ onChange={(e) => setUsername(e.target.value)}
+ placeholder="username"
+ className="pl-8"
+ disabled={loading}
+ autoFocus
+ />
+ </div>
+ </Field>
+ <Field label={t("common.password")} htmlFor="login-pass">
+ <PasswordInput
+ id="login-pass"
+ value={password}
+ onChange={setPassword}
+ disabled={loading}
+ />
+ </Field>
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-2">
+ <Checkbox
+ id="rememberMe"
+ checked={rememberMe}
+ onCheckedChange={(v) => setRememberMe(v === true)}
+ disabled={loading}
+ />
+ <label
+ htmlFor="rememberMe"
+ className="text-xs text-muted-foreground cursor-pointer"
+ >
+ {t("auth.rememberMe")}
+ </label>
+ </div>
+ <button
+ type="button"
+ onClick={() => switchView("reset")}
+ className="text-xs text-muted-foreground hover:text-accent-brand transition-colors"
+ >
+ {t("auth.forgotPassword")}
+ </button>
+ </div>
+ <Button
+ type="submit"
+ className="w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold h-10"
+ disabled={loading}
+ >
+ {loading ? (
+ t("common.loading")
+ ) : (
+ <span className="flex items-center gap-2">
+ <KeyRound className="size-4" />
+ {t("common.login")}
+ </span>
+ )}
+ </Button>
+ </form>
+ )}
+
+ {view === "register" && (
+ <form onSubmit={handleRegister} className="flex flex-col gap-4">
+ <Field label={t("common.username")} htmlFor="reg-user">
+ <div className="relative">
+ <User className="absolute left-2.5 top-1/2 -translate-y-1/2 size-4 text-muted-foreground pointer-events-none" />
+ <Input
+ id="reg-user"
+ value={username}
+ onChange={(e) => setUsername(e.target.value)}
+ placeholder="choose_a_username"
+ className="pl-8"
+ disabled={loading}
+ autoFocus
+ />
+ </div>
+ </Field>
+ <Field label={t("common.password")} htmlFor="reg-pass">
+ <PasswordInput
+ id="reg-pass"
+ value={password}
+ onChange={setPassword}
+ placeholder={t("auth.minChars", {
+ min: 6,
+ defaultValue: "min. 6 characters",
+ })}
+ disabled={loading}
+ />
+ </Field>
+ <Field
+ label={t("common.confirmPassword")}
+ htmlFor="reg-confirm"
+ >
+ <PasswordInput
+ id="reg-confirm"
+ value={confirmPassword}
+ onChange={setConfirmPassword}
+ disabled={loading}
+ />
+ </Field>
+ <Button
+ type="submit"
+ className="w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold h-10"
+ disabled={loading}
+ >
+ {loading ? (
+ t("common.loading")
+ ) : (
+ <span className="flex items-center gap-2">
+ <Shield className="size-4" />
+ {t("auth.signUp")}
+ </span>
+ )}
+ </Button>
+ </form>
+ )}
+
+ <Separator />
+ <p className="text-center text-xs text-muted-foreground">
+ {view === "login" && registrationAllowed ? (
+ <>
+ {t("auth.noAccount", "Don't have an account?")}{" "}
+ <button
+ onClick={() => switchView("register")}
+ className="text-accent-brand hover:text-accent-brand/70 font-bold transition-colors"
+ >
+ {t("common.register")}
+ </button>
+ </>
+ ) : view === "register" &&
+ passwordLoginAllowed &&
+ !firstUser ? (
+ <>
+ {t("auth.hasAccount", "Already have an account?")}{" "}
+ <button
+ onClick={() => switchView("login")}
+ className="text-accent-brand hover:text-accent-brand/70 font-bold transition-colors"
+ >
+ {t("common.login")}
+ </button>
+ </>
+ ) : null}
+ </p>
+ </div>
+ )}
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/src/ui/desktop/authentication/ElectronLoginForm.tsx b/src/ui/auth/ElectronLoginForm.tsx
similarity index 99%
rename from src/ui/desktop/authentication/ElectronLoginForm.tsx
rename to src/ui/auth/ElectronLoginForm.tsx
index 81222ee99..e67853402 100644
--- a/src/ui/desktop/authentication/ElectronLoginForm.tsx
+++ b/src/ui/auth/ElectronLoginForm.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useRef, useCallback } from "react";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
+import { Alert, AlertDescription, AlertTitle } from "@/components/alert.tsx";
import { useTranslation } from "react-i18next";
import { AlertCircle, Loader2, ArrowLeft, RefreshCw } from "lucide-react";
diff --git a/src/ui/desktop/authentication/ElectronServerConfig.tsx b/src/ui/auth/ElectronServerConfig.tsx
similarity index 97%
rename from src/ui/desktop/authentication/ElectronServerConfig.tsx
rename to src/ui/auth/ElectronServerConfig.tsx
index 0c0033b82..06264c930 100644
--- a/src/ui/desktop/authentication/ElectronServerConfig.tsx
+++ b/src/ui/auth/ElectronServerConfig.tsx
@@ -1,8 +1,8 @@
import React, { useState, useEffect } from "react";
-import { Button } from "@/components/ui/button.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert.tsx";
+import { Button } from "@/components/button.tsx";
+import { Input } from "@/components/input.tsx";
+import { Label } from "@/components/label.tsx";
+import { Alert, AlertTitle, AlertDescription } from "@/components/alert.tsx";
import { useTranslation } from "react-i18next";
import {
getServerConfig,
@@ -10,7 +10,7 @@ import {
getEmbeddedServerStatus,
setEmbeddedMode,
type ServerConfig,
-} from "@/ui/main-axios.ts";
+} from "@/main-axios.ts";
import { Server, Monitor, Loader2 } from "lucide-react";
import { useTheme } from "@/components/theme-provider";
diff --git a/src/ui/desktop/authentication/Auth.tsx b/src/ui/auth/LoginPage.tsx
similarity index 98%
rename from src/ui/desktop/authentication/Auth.tsx
rename to src/ui/auth/LoginPage.tsx
index aa7e5d081..4818e3c55 100644
--- a/src/ui/desktop/authentication/Auth.tsx
+++ b/src/ui/auth/LoginPage.tsx
@@ -1,13 +1,13 @@
import React, { useState, useEffect, useCallback } from "react";
-import { Button } from "@/components/ui/button.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import { Checkbox } from "@/components/ui/checkbox.tsx";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
-import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs.tsx";
+import { Button } from "@/components/button.tsx";
+import { Input } from "@/components/input.tsx";
+import { PasswordInput } from "@/components/password-input.tsx";
+import { Label } from "@/components/label.tsx";
+import { Checkbox } from "@/components/checkbox.tsx";
+import { Alert, AlertDescription, AlertTitle } from "@/components/alert.tsx";
+import { Tabs, TabsList, TabsTrigger } from "@/components/tabs.tsx";
import { useTranslation } from "react-i18next";
-import { LanguageSwitcher } from "@/ui/desktop/user/LanguageSwitcher.tsx";
+import { LanguageSwitcher } from "@/user/LanguageSwitcher.tsx";
import { toast } from "sonner";
import { Sun, Moon, Monitor } from "lucide-react";
import { useTheme } from "@/components/theme-provider";
@@ -28,9 +28,9 @@ import {
saveServerConfig,
isElectron,
getEmbeddedServerStatus,
-} from "../../main-axios.ts";
-import { ElectronServerConfig as ServerConfigComponent } from "@/ui/desktop/authentication/ElectronServerConfig.tsx";
-import { ElectronLoginForm } from "@/ui/desktop/authentication/ElectronLoginForm.tsx";
+} from "@/main-axios";
+import { ElectronServerConfig as ServerConfigComponent } from "@/auth/ElectronServerConfig.tsx";
+import { ElectronLoginForm } from "@/auth/ElectronLoginForm.tsx";
function isMissingServerConfigError(error: unknown): boolean {
if (!(error instanceof Error)) {
diff --git a/src/components/ui/accordion.tsx b/src/ui/components/accordion.tsx
similarity index 100%
rename from src/components/ui/accordion.tsx
rename to src/ui/components/accordion.tsx
diff --git a/src/components/ui/alert-dialog.tsx b/src/ui/components/alert-dialog.tsx
similarity index 98%
rename from src/components/ui/alert-dialog.tsx
rename to src/ui/components/alert-dialog.tsx
index 1c3767398..dc04cf85b 100644
--- a/src/components/ui/alert-dialog.tsx
+++ b/src/ui/components/alert-dialog.tsx
@@ -2,7 +2,7 @@ import * as React from "react";
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
import { cn } from "@/lib/utils";
-import { buttonVariants } from "@/components/ui/button";
+import { buttonVariants } from "@/components/button";
function AlertDialog({
...props
diff --git a/src/components/ui/alert.tsx b/src/ui/components/alert.tsx
similarity index 100%
rename from src/components/ui/alert.tsx
rename to src/ui/components/alert.tsx
diff --git a/src/components/ui/badge.tsx b/src/ui/components/badge.tsx
similarity index 100%
rename from src/components/ui/badge.tsx
rename to src/ui/components/badge.tsx
diff --git a/src/components/ui/button-group.tsx b/src/ui/components/button-group.tsx
similarity index 90%
rename from src/components/ui/button-group.tsx
rename to src/ui/components/button-group.tsx
index 46f8cda3e..e742659db 100644
--- a/src/components/ui/button-group.tsx
+++ b/src/ui/components/button-group.tsx
@@ -1,6 +1,11 @@
-import { Children, ReactElement, cloneElement, isValidElement } from "react";
+import {
+ Children,
+ type ReactElement,
+ cloneElement,
+ isValidElement,
+} from "react";
-import { type ButtonProps } from "@/components/ui/button";
+import { type ButtonProps } from "@/components/button";
import { cn } from "@/lib/utils";
interface ButtonGroupProps {
diff --git a/src/ui/components/button.tsx b/src/ui/components/button.tsx
new file mode 100644
index 000000000..dd09238a1
--- /dev/null
+++ b/src/ui/components/button.tsx
@@ -0,0 +1,68 @@
+import * as React from "react";
+import { cva, type VariantProps } from "class-variance-authority";
+import { Slot } from "radix-ui";
+
+import { cn } from "@/lib/utils";
+
+const buttonVariants = cva(
+ "group/button inline-flex shrink-0 items-center justify-center rounded-none border border-transparent bg-clip-padding text-xs font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ {
+ variants: {
+ variant: {
+ default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
+ outline:
+ "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
+ secondary:
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
+ ghost:
+ "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
+ destructive:
+ "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
+ link: "text-primary underline-offset-4 hover:underline",
+ },
+ size: {
+ default:
+ "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
+ xs: "h-6 gap-1 rounded-none px-2 text-xs has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
+ sm: "h-7 gap-1 rounded-none px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
+ lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
+ icon: "size-8",
+ "icon-xs": "size-6 rounded-none [&_svg:not([class*='size-'])]:size-3",
+ "icon-sm": "size-7 rounded-none",
+ "icon-lg": "size-9",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ size: "default",
+ },
+ },
+);
+
+function Button({
+ className,
+ variant = "default",
+ size = "default",
+ asChild = false,
+ ...props
+}: React.ComponentProps<"button"> &
+ VariantProps<typeof buttonVariants> & {
+ asChild?: boolean;
+ }) {
+ const Comp = asChild ? Slot.Root : "button";
+
+ return (
+ <Comp
+ data-slot="button"
+ data-variant={variant}
+ data-size={size}
+ className={cn(buttonVariants({ variant, size, className }))}
+ {...props}
+ />
+ );
+}
+
+export type ButtonProps = React.ComponentProps<"button"> &
+ VariantProps<typeof buttonVariants> & { asChild?: boolean };
+
+export { Button, buttonVariants };
diff --git a/src/components/ui/card.tsx b/src/ui/components/card.tsx
similarity index 54%
rename from src/components/ui/card.tsx
rename to src/ui/components/card.tsx
index 5b8522b8a..2d30a89a9 100644
--- a/src/components/ui/card.tsx
+++ b/src/ui/components/card.tsx
@@ -2,12 +2,17 @@ import * as React from "react";
import { cn } from "@/lib/utils";
-function Card({ className, ...props }: React.ComponentProps<"div">) {
+function Card({
+ className,
+ size = "default",
+ ...props
+}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
return (
<div
data-slot="card"
+ data-size={size}
className={cn(
- "bg-elevated text-foreground flex flex-col gap-6 rounded-lg border-2 border-edge py-6 shadow-sm",
+ "group/card flex flex-col gap-4 overflow-hidden rounded-none bg-card py-4 text-xs/relaxed text-card-foreground border border-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-2 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-none *:[img:last-child]:rounded-none",
className,
)}
{...props}
@@ -20,7 +25,7 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
<div
data-slot="card-header"
className={cn(
- "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
+ "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-none px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",
className,
)}
{...props}
@@ -32,7 +37,10 @@ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-title"
- className={cn("leading-none font-semibold", className)}
+ className={cn(
+ "font-heading text-sm font-medium group-data-[size=sm]/card:text-sm",
+ className,
+ )}
{...props}
/>
);
@@ -42,7 +50,7 @@ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-description"
- className={cn("text-muted-foreground text-sm", className)}
+ className={cn("text-xs/relaxed text-muted-foreground", className)}
{...props}
/>
);
@@ -65,7 +73,7 @@ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-content"
- className={cn("px-6", className)}
+ className={cn("px-4 group-data-[size=sm]/card:px-3", className)}
{...props}
/>
);
@@ -75,7 +83,10 @@ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-footer"
- className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
+ className={cn(
+ "flex items-center rounded-none border-t p-4 group-data-[size=sm]/card:p-3",
+ className,
+ )}
{...props}
/>
);
diff --git a/src/components/ui/checkbox.tsx b/src/ui/components/checkbox.tsx
similarity index 100%
rename from src/components/ui/checkbox.tsx
rename to src/ui/components/checkbox.tsx
diff --git a/src/ui/components/command.tsx b/src/ui/components/command.tsx
new file mode 100644
index 000000000..a302540c2
--- /dev/null
+++ b/src/ui/components/command.tsx
@@ -0,0 +1,130 @@
+import * as React from "react";
+import { Search } from "lucide-react";
+import { cn } from "@/lib/utils";
+
+const Command = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn(
+ "flex h-full w-full flex-col overflow-hidden rounded-none bg-popover text-popover-foreground",
+ className,
+ )}
+ {...props}
+ />
+));
+Command.displayName = "Command";
+
+const CommandInput = React.forwardRef<
+ HTMLInputElement,
+ React.InputHTMLAttributes<HTMLInputElement>
+>(({ className, ...props }, ref) => (
+ <div
+ className="flex items-center border-b border-border px-3"
+ cm-input-wrapper=""
+ >
+ <Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
+ <input
+ ref={ref}
+ className={cn(
+ "flex h-11 w-full rounded-none bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
+ className,
+ )}
+ {...props}
+ />
+ </div>
+));
+CommandInput.displayName = "CommandInput";
+
+const CommandList = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
+ {...props}
+ />
+));
+CommandList.displayName = "CommandList";
+
+const CommandGroup = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement> & { heading?: string }
+>(({ className, heading, children, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn(
+ "overflow-hidden p-1 text-foreground [&_[cm-group-heading]]:px-2 [&_[cm-group-heading]]:py-1.5 [&_[cm-group-heading]]:text-xs [&_[cm-group-heading]]:font-medium [&_[cm-group-heading]]:text-muted-foreground",
+ className,
+ )}
+ {...props}
+ >
+ {heading && <div cm-group-heading="">{heading}</div>}
+ {children}
+ </div>
+));
+CommandGroup.displayName = "CommandGroup";
+
+const CommandSeparator = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div ref={ref} className={cn("-mx-1 h-px bg-border", className)} {...props} />
+));
+CommandSeparator.displayName = "CommandSeparator";
+
+const CommandItem = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement> & { onSelect?: () => void }
+>(({ className, onSelect, ...props }, ref) => (
+ <div
+ ref={ref}
+ onClick={onSelect}
+ className={cn(
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-muted hover:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 transition-colors",
+ className,
+ )}
+ {...props}
+ />
+));
+CommandItem.displayName = "CommandItem";
+
+const CommandEmpty = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn("py-6 text-center text-sm text-muted-foreground", className)}
+ {...props}
+ />
+));
+CommandEmpty.displayName = "CommandEmpty";
+
+const CommandShortcut = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLSpanElement>) => (
+ <span
+ className={cn(
+ "ml-auto text-xs tracking-widest text-muted-foreground",
+ className,
+ )}
+ {...props}
+ />
+);
+CommandShortcut.displayName = "CommandShortcut";
+
+export {
+ Command,
+ CommandInput,
+ CommandList,
+ CommandGroup,
+ CommandItem,
+ CommandSeparator,
+ CommandEmpty,
+ CommandShortcut,
+};
diff --git a/src/components/ui/dialog.tsx b/src/ui/components/dialog.tsx
similarity index 60%
rename from src/components/ui/dialog.tsx
rename to src/ui/components/dialog.tsx
index 64249170f..4493c20f8 100644
--- a/src/components/ui/dialog.tsx
+++ b/src/ui/components/dialog.tsx
@@ -1,8 +1,9 @@
import * as React from "react";
-import * as DialogPrimitive from "@radix-ui/react-dialog";
-import { XIcon } from "lucide-react";
+import { Dialog as DialogPrimitive } from "radix-ui";
import { cn } from "@/lib/utils";
+import { Button } from "@/components/button";
+import { XIcon } from "lucide-react";
function Dialog({
...props
@@ -36,7 +37,7 @@ function DialogOverlay({
<DialogPrimitive.Overlay
data-slot="dialog-overlay"
className={cn(
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-overlay",
+ "fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
className,
)}
{...props}
@@ -53,24 +54,27 @@ function DialogContent({
showCloseButton?: boolean;
}) {
return (
- <DialogPortal data-slot="dialog-portal">
+ <DialogPortal>
<DialogOverlay />
<DialogPrimitive.Content
data-slot="dialog-content"
className={cn(
- "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
+ "fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-none bg-popover p-4 text-xs/relaxed text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
className,
)}
{...props}
>
{children}
{showCloseButton && (
- <DialogPrimitive.Close
- data-slot="dialog-close"
- className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
- >
- <XIcon />
- <span className="sr-only">Close</span>
+ <DialogPrimitive.Close data-slot="dialog-close" asChild>
+ <Button
+ variant="ghost"
+ className="absolute top-2 right-2"
+ size="icon-sm"
+ >
+ <XIcon />
+ <span className="sr-only">Close</span>
+ </Button>
</DialogPrimitive.Close>
)}
</DialogPrimitive.Content>
@@ -82,13 +86,20 @@ function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="dialog-header"
- className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
+ className={cn("flex flex-col gap-1 text-left", className)}
{...props}
/>
);
}
-function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
+function DialogFooter({
+ className,
+ showCloseButton = false,
+ children,
+ ...props
+}: React.ComponentProps<"div"> & {
+ showCloseButton?: boolean;
+}) {
return (
<div
data-slot="dialog-footer"
@@ -97,7 +108,14 @@ function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
className,
)}
{...props}
- />
+ >
+ {children}
+ {showCloseButton && (
+ <DialogPrimitive.Close asChild>
+ <Button variant="outline">Close</Button>
+ </DialogPrimitive.Close>
+ )}
+ </div>
);
}
@@ -108,7 +126,7 @@ function DialogTitle({
return (
<DialogPrimitive.Title
data-slot="dialog-title"
- className={cn("text-lg leading-none font-semibold", className)}
+ className={cn("font-heading text-sm font-medium", className)}
{...props}
/>
);
@@ -121,7 +139,10 @@ function DialogDescription({
return (
<DialogPrimitive.Description
data-slot="dialog-description"
- className={cn("text-muted-foreground text-sm", className)}
+ className={cn(
+ "text-xs/relaxed text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
+ className,
+ )}
{...props}
/>
);
diff --git a/src/ui/components/dropdown-menu.tsx b/src/ui/components/dropdown-menu.tsx
new file mode 100644
index 000000000..c03b79876
--- /dev/null
+++ b/src/ui/components/dropdown-menu.tsx
@@ -0,0 +1,271 @@
+import * as React from "react";
+import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
+
+import { cn } from "@/lib/utils";
+import { CheckIcon, ChevronRightIcon } from "lucide-react";
+
+function DropdownMenu({
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
+ return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />;
+}
+
+function DropdownMenuPortal({
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
+ return (
+ <DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
+ );
+}
+
+function DropdownMenuTrigger({
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
+ return (
+ <DropdownMenuPrimitive.Trigger
+ data-slot="dropdown-menu-trigger"
+ {...props}
+ />
+ );
+}
+
+function DropdownMenuContent({
+ className,
+ align = "start",
+ sideOffset = 4,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
+ return (
+ <DropdownMenuPrimitive.Portal>
+ <DropdownMenuPrimitive.Content
+ data-slot="dropdown-menu-content"
+ sideOffset={sideOffset}
+ align={align}
+ className={cn(
+ "z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-none bg-popover text-popover-foreground shadow-md ring-1 ring-border duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
+ className,
+ )}
+ {...props}
+ />
+ </DropdownMenuPrimitive.Portal>
+ );
+}
+
+function DropdownMenuGroup({
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
+ return (
+ <DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
+ );
+}
+
+function DropdownMenuItem({
+ className,
+ inset,
+ variant = "default",
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
+ inset?: boolean;
+ variant?: "default" | "destructive";
+}) {
+ return (
+ <DropdownMenuPrimitive.Item
+ data-slot="dropdown-menu-item"
+ data-inset={inset}
+ data-variant={variant}
+ className={cn(
+ "group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-none px-2 py-2 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+function DropdownMenuCheckboxItem({
+ className,
+ children,
+ checked,
+ inset,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem> & {
+ inset?: boolean;
+}) {
+ return (
+ <DropdownMenuPrimitive.CheckboxItem
+ data-slot="dropdown-menu-checkbox-item"
+ data-inset={inset}
+ className={cn(
+ "relative flex cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ className,
+ )}
+ checked={checked}
+ {...props}
+ >
+ <span
+ className="pointer-events-none absolute right-2 flex items-center justify-center"
+ data-slot="dropdown-menu-checkbox-item-indicator"
+ >
+ <DropdownMenuPrimitive.ItemIndicator>
+ <CheckIcon />
+ </DropdownMenuPrimitive.ItemIndicator>
+ </span>
+ {children}
+ </DropdownMenuPrimitive.CheckboxItem>
+ );
+}
+
+function DropdownMenuRadioGroup({
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
+ return (
+ <DropdownMenuPrimitive.RadioGroup
+ data-slot="dropdown-menu-radio-group"
+ {...props}
+ />
+ );
+}
+
+function DropdownMenuRadioItem({
+ className,
+ children,
+ inset,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem> & {
+ inset?: boolean;
+}) {
+ return (
+ <DropdownMenuPrimitive.RadioItem
+ data-slot="dropdown-menu-radio-item"
+ data-inset={inset}
+ className={cn(
+ "relative flex cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ className,
+ )}
+ {...props}
+ >
+ <span
+ className="pointer-events-none absolute right-2 flex items-center justify-center"
+ data-slot="dropdown-menu-radio-item-indicator"
+ >
+ <DropdownMenuPrimitive.ItemIndicator>
+ <CheckIcon />
+ </DropdownMenuPrimitive.ItemIndicator>
+ </span>
+ {children}
+ </DropdownMenuPrimitive.RadioItem>
+ );
+}
+
+function DropdownMenuLabel({
+ className,
+ inset,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
+ inset?: boolean;
+}) {
+ return (
+ <DropdownMenuPrimitive.Label
+ data-slot="dropdown-menu-label"
+ data-inset={inset}
+ className={cn(
+ "px-2 py-2 text-xs text-muted-foreground data-inset:pl-7",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+function DropdownMenuSeparator({
+ className,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
+ return (
+ <DropdownMenuPrimitive.Separator
+ data-slot="dropdown-menu-separator"
+ className={cn("-mx-1 h-px bg-border", className)}
+ {...props}
+ />
+ );
+}
+
+function DropdownMenuShortcut({
+ className,
+ ...props
+}: React.ComponentProps<"span">) {
+ return (
+ <span
+ data-slot="dropdown-menu-shortcut"
+ className={cn(
+ "ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+function DropdownMenuSub({
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
+ return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />;
+}
+
+function DropdownMenuSubTrigger({
+ className,
+ inset,
+ children,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
+ inset?: boolean;
+}) {
+ return (
+ <DropdownMenuPrimitive.SubTrigger
+ data-slot="dropdown-menu-sub-trigger"
+ data-inset={inset}
+ className={cn(
+ "flex cursor-default items-center gap-2 rounded-none px-2 py-2 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ className,
+ )}
+ {...props}
+ >
+ {children}
+ <ChevronRightIcon className="ml-auto" />
+ </DropdownMenuPrimitive.SubTrigger>
+ );
+}
+
+function DropdownMenuSubContent({
+ className,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
+ return (
+ <DropdownMenuPrimitive.SubContent
+ data-slot="dropdown-menu-sub-content"
+ className={cn(
+ "z-50 min-w-[96px] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-none bg-popover text-popover-foreground shadow-lg ring-1 ring-border duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+export {
+ DropdownMenu,
+ DropdownMenuPortal,
+ DropdownMenuTrigger,
+ DropdownMenuContent,
+ DropdownMenuGroup,
+ DropdownMenuLabel,
+ DropdownMenuItem,
+ DropdownMenuCheckboxItem,
+ DropdownMenuRadioGroup,
+ DropdownMenuRadioItem,
+ DropdownMenuSeparator,
+ DropdownMenuShortcut,
+ DropdownMenuSub,
+ DropdownMenuSubTrigger,
+ DropdownMenuSubContent,
+};
diff --git a/src/components/ui/folder.tsx b/src/ui/components/folder.tsx
similarity index 100%
rename from src/components/ui/folder.tsx
rename to src/ui/components/folder.tsx
diff --git a/src/components/ui/form.tsx b/src/ui/components/form.tsx
similarity index 98%
rename from src/components/ui/form.tsx
rename to src/ui/components/form.tsx
index 50ee37c37..ca28b235d 100644
--- a/src/components/ui/form.tsx
+++ b/src/ui/components/form.tsx
@@ -13,7 +13,7 @@ import {
} from "react-hook-form";
import { cn } from "@/lib/utils";
-import { Label } from "@/components/ui/label";
+import { Label } from "@/components/label";
const Form = FormProvider;
diff --git a/src/ui/components/input.tsx b/src/ui/components/input.tsx
new file mode 100644
index 000000000..bc0898a24
--- /dev/null
+++ b/src/ui/components/input.tsx
@@ -0,0 +1,19 @@
+import * as React from "react";
+
+import { cn } from "@/lib/utils";
+
+function Input({ className, type, ...props }: React.ComponentProps<"input">) {
+ return (
+ <input
+ type={type}
+ data-slot="input"
+ className={cn(
+ "h-8 w-full min-w-0 rounded-none border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-xs file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 md:text-xs dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+export { Input };
diff --git a/src/ui/components/kbd.tsx b/src/ui/components/kbd.tsx
new file mode 100644
index 000000000..bd1726656
--- /dev/null
+++ b/src/ui/components/kbd.tsx
@@ -0,0 +1,40 @@
+import * as React from "react";
+import { cn } from "@/lib/utils";
+
+export interface KbdProps extends React.HTMLAttributes<HTMLElement> {}
+
+const Kbd = React.forwardRef<HTMLElement, KbdProps>(
+ ({ className, ...props }, ref) => {
+ return (
+ <kbd
+ ref={ref}
+ className={cn(
+ "pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded-none border border-border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100",
+ className,
+ )}
+ {...props}
+ />
+ );
+ },
+);
+Kbd.displayName = "Kbd";
+
+const KbdKey = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLSpanElement>) => (
+ <span className={cn("", className)} {...props} />
+);
+KbdKey.displayName = "KbdKey";
+
+const KbdSeparator = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLSpanElement>) => (
+ <span className={cn("text-muted-foreground/50", className)} {...props}>
+ +
+ </span>
+);
+KbdSeparator.displayName = "KbdSeparator";
+
+export { Kbd, KbdKey, KbdSeparator };
diff --git a/src/components/ui/label.tsx b/src/ui/components/label.tsx
similarity index 100%
rename from src/components/ui/label.tsx
rename to src/ui/components/label.tsx
diff --git a/src/components/ui/password-input.tsx b/src/ui/components/password-input.tsx
similarity index 96%
rename from src/components/ui/password-input.tsx
rename to src/ui/components/password-input.tsx
index 5eac52b5f..d8a57ff0e 100644
--- a/src/components/ui/password-input.tsx
+++ b/src/ui/components/password-input.tsx
@@ -2,7 +2,7 @@
import * as React from "react";
import { Eye, EyeOff } from "lucide-react";
-import { Input } from "@/components/ui/input";
+import { Input } from "@/components/input";
import { cn } from "@/lib/utils";
type PasswordInputProps = React.InputHTMLAttributes<HTMLInputElement>;
diff --git a/src/components/ui/popover.tsx b/src/ui/components/popover.tsx
similarity index 100%
rename from src/components/ui/popover.tsx
rename to src/ui/components/popover.tsx
diff --git a/src/components/ui/scroll-area.tsx b/src/ui/components/scroll-area.tsx
similarity index 100%
rename from src/components/ui/scroll-area.tsx
rename to src/ui/components/scroll-area.tsx
diff --git a/src/ui/components/section-card.tsx b/src/ui/components/section-card.tsx
new file mode 100644
index 000000000..a1622b960
--- /dev/null
+++ b/src/ui/components/section-card.tsx
@@ -0,0 +1,82 @@
+import { useState } from "react";
+import type React from "react";
+
+export function SectionCard({
+ title,
+ icon,
+ action,
+ children,
+}: {
+ title: string;
+ icon: React.ReactNode;
+ action?: React.ReactNode;
+ children: React.ReactNode;
+}) {
+ return (
+ <div className="flex flex-col border border-border bg-card">
+ <div className="flex items-center gap-2 px-4 py-2.5 border-b border-border shrink-0">
+ <span className="text-muted-foreground">{icon}</span>
+ <span className="text-xs font-semibold uppercase tracking-widest text-muted-foreground flex-1">
+ {title}
+ </span>
+ {action && <div className="ml-auto">{action}</div>}
+ </div>
+ <div className="px-3 md:px-4 py-1">{children}</div>
+ </div>
+ );
+}
+
+export function SettingRow({
+ label,
+ badge,
+ description,
+ children,
+}: {
+ label: string;
+ badge?: string;
+ description?: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <div className="flex items-center justify-between py-3 border-b border-border last:border-0">
+ <div className="flex flex-col gap-0.5">
+ <div className="flex items-center gap-1.5">
+ <span className="text-sm font-medium">{label}</span>
+ {badge && (
+ <span className="text-[10px] font-bold text-yellow-500 border border-yellow-500/40 px-1">
+ {badge}
+ </span>
+ )}
+ </div>
+ {description && (
+ <span className="text-xs text-muted-foreground">{description}</span>
+ )}
+ </div>
+ <div className="shrink-0 ml-4 md:ml-8">{children}</div>
+ </div>
+ );
+}
+
+export function FakeSwitch({
+ defaultChecked = false,
+ onChange,
+}: {
+ defaultChecked?: boolean;
+ onChange?: (v: boolean) => void;
+}) {
+ const [on, setOn] = useState(defaultChecked);
+ return (
+ <button
+ onClick={() => {
+ const next = !on;
+ setOn(next);
+ onChange?.(next);
+ }}
+ className={`relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center border-2 transition-colors ${on ? "bg-accent-brand border-accent-brand" : "bg-muted border-border"}`}
+ >
+ <span
+ className={`pointer-events-none inline-block h-3 w-3 bg-background shadow-sm transition-transform ${on ? "translate-x-4" : "translate-x-0.5"}`}
+ />
+ </button>
+ );
+}
diff --git a/src/components/ui/select.tsx b/src/ui/components/select.tsx
similarity index 100%
rename from src/components/ui/select.tsx
rename to src/ui/components/select.tsx
diff --git a/src/components/ui/separator.tsx b/src/ui/components/separator.tsx
similarity index 64%
rename from src/components/ui/separator.tsx
rename to src/ui/components/separator.tsx
index 72c18e33e..d7fc9faa5 100644
--- a/src/components/ui/separator.tsx
+++ b/src/ui/components/separator.tsx
@@ -1,7 +1,5 @@
-"use client";
-
import * as React from "react";
-import * as SeparatorPrimitive from "@radix-ui/react-separator";
+import { Separator as SeparatorPrimitive } from "radix-ui";
import { cn } from "@/lib/utils";
@@ -17,7 +15,7 @@ function Separator({
decorative={decorative}
orientation={orientation}
className={cn(
- "bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
+ "shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",
className,
)}
{...props}
diff --git a/src/components/ui/shadcn-io/status/index.tsx b/src/ui/components/shadcn-io/status/index.tsx
similarity index 97%
rename from src/components/ui/shadcn-io/status/index.tsx
rename to src/ui/components/shadcn-io/status/index.tsx
index 5131e84c1..0ee2b3671 100644
--- a/src/components/ui/shadcn-io/status/index.tsx
+++ b/src/ui/components/shadcn-io/status/index.tsx
@@ -1,5 +1,5 @@
import type { ComponentProps, HTMLAttributes } from "react";
-import { Badge } from "@/components/ui/badge";
+import { Badge } from "@/components/badge";
import { cn } from "@/lib/utils";
import { useTranslation } from "react-i18next";
diff --git a/src/components/ui/sheet.tsx b/src/ui/components/sheet.tsx
similarity index 52%
rename from src/components/ui/sheet.tsx
rename to src/ui/components/sheet.tsx
index f449ce91e..c4168fe81 100644
--- a/src/components/ui/sheet.tsx
+++ b/src/ui/components/sheet.tsx
@@ -1,8 +1,9 @@
import * as React from "react";
-import * as SheetPrimitive from "@radix-ui/react-dialog";
-import { XIcon } from "lucide-react";
+import { Dialog as SheetPrimitive } from "radix-ui";
import { cn } from "@/lib/utils";
+import { Button } from "@/components/button";
+import { XIcon } from "lucide-react";
function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {
return <SheetPrimitive.Root data-slot="sheet" {...props} />;
@@ -34,7 +35,7 @@ function SheetOverlay({
<SheetPrimitive.Overlay
data-slot="sheet-overlay"
className={cn(
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-overlay data-[state=closed]:pointer-events-none",
+ "fixed inset-0 z-50 bg-black/10 text-xs/relaxed duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
className,
)}
{...props}
@@ -46,34 +47,37 @@ function SheetContent({
className,
children,
side = "right",
+ showCloseButton = true,
...props
}: React.ComponentProps<typeof SheetPrimitive.Content> & {
side?: "top" | "right" | "bottom" | "left";
+ showCloseButton?: boolean;
}) {
return (
<SheetPortal>
<SheetOverlay />
<SheetPrimitive.Content
data-slot="sheet-content"
+ data-side={side}
className={cn(
- "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=closed]:pointer-events-none",
- side === "right" &&
- "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l",
- side === "left" &&
- "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r",
- side === "top" &&
- "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
- side === "bottom" &&
- "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
+ "fixed z-50 flex flex-col bg-popover bg-clip-padding text-xs/relaxed text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10",
className,
)}
{...props}
>
{children}
- <SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
- <XIcon className="size-4" />
- <span className="sr-only">Close</span>
- </SheetPrimitive.Close>
+ {showCloseButton && (
+ <SheetPrimitive.Close data-slot="sheet-close" asChild>
+ <Button
+ variant="ghost"
+ className="absolute top-3 right-3"
+ size="icon-sm"
+ >
+ <XIcon />
+ <span className="sr-only">Close</span>
+ </Button>
+ </SheetPrimitive.Close>
+ )}
</SheetPrimitive.Content>
</SheetPortal>
);
@@ -83,7 +87,7 @@ function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="sheet-header"
- className={cn("flex flex-col gap-1.5 p-4", className)}
+ className={cn("flex flex-col gap-0.5 p-4", className)}
{...props}
/>
);
@@ -106,7 +110,10 @@ function SheetTitle({
return (
<SheetPrimitive.Title
data-slot="sheet-title"
- className={cn("text-foreground font-semibold", className)}
+ className={cn(
+ "font-heading text-sm font-medium text-foreground",
+ className,
+ )}
{...props}
/>
);
@@ -119,7 +126,7 @@ function SheetDescription({
return (
<SheetPrimitive.Description
data-slot="sheet-description"
- className={cn("text-muted-foreground text-sm", className)}
+ className={cn("text-xs/relaxed text-muted-foreground", className)}
{...props}
/>
);
diff --git a/src/components/ui/sidebar.tsx b/src/ui/components/sidebar.tsx
similarity index 63%
rename from src/components/ui/sidebar.tsx
rename to src/ui/components/sidebar.tsx
index 8413b7122..d2deb02f5 100644
--- a/src/components/ui/sidebar.tsx
+++ b/src/ui/components/sidebar.tsx
@@ -1,25 +1,29 @@
-/* eslint-disable react-refresh/only-export-components */
+"use client";
+
import * as React from "react";
-import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";
-import { PanelLeftIcon } from "lucide-react";
+import { Slot } from "radix-ui";
import { useIsMobile } from "@/hooks/use-mobile";
import { cn } from "@/lib/utils";
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Separator } from "@/components/ui/separator";
-import { Skeleton } from "@/components/ui/skeleton";
+import { Button } from "@/components/button";
+import { Input } from "@/components/input";
+import { Separator } from "@/components/separator";
import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "@/components/ui/tooltip";
+ Sheet,
+ SheetContent,
+ SheetDescription,
+ SheetHeader,
+ SheetTitle,
+} from "@/components/sheet";
+import { Skeleton } from "@/components/skeleton";
+import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/tooltip";
+import { PanelLeftIcon } from "lucide-react";
const SIDEBAR_COOKIE_NAME = "sidebar_state";
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
const SIDEBAR_WIDTH = "16rem";
+const SIDEBAR_WIDTH_MOBILE = "18rem";
const SIDEBAR_WIDTH_ICON = "3rem";
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
@@ -119,25 +123,23 @@ function SidebarProvider({
return (
<SidebarContext.Provider value={contextValue}>
- <TooltipProvider delayDuration={0}>
- <div
- data-slot="sidebar-wrapper"
- style={
- {
- "--sidebar-width": SIDEBAR_WIDTH,
- "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
- ...style,
- } as React.CSSProperties
- }
- className={cn(
- "group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",
- className,
- )}
- {...props}
- >
- {children}
- </div>
- </TooltipProvider>
+ <div
+ data-slot="sidebar-wrapper"
+ style={
+ {
+ "--sidebar-width": SIDEBAR_WIDTH,
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
+ ...style,
+ } as React.CSSProperties
+ }
+ className={cn(
+ "group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
+ className,
+ )}
+ {...props}
+ >
+ {children}
+ </div>
</SidebarContext.Provider>
);
}
@@ -148,20 +150,21 @@ function Sidebar({
collapsible = "offcanvas",
className,
children,
+ dir,
...props
}: React.ComponentProps<"div"> & {
side?: "left" | "right";
variant?: "sidebar" | "floating" | "inset";
collapsible?: "offcanvas" | "icon" | "none";
}) {
- const { state } = useSidebar();
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
if (collapsible === "none") {
return (
<div
data-slot="sidebar"
className={cn(
- "bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",
+ "flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
className,
)}
{...props}
@@ -171,41 +174,42 @@ function Sidebar({
);
}
- // Commented out mobile behavior to keep sidebar always visible
- // if (isMobile) {
- // return (
- // <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
- // <SheetContent
- // data-sidebar="sidebar"
- // data-slot="sidebar"
- // data-mobile="true"
- // className="bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
- // style={
- // {
- // "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
- // } as React.CSSProperties
- // }
- // side={side}
- // >
- // <SheetHeader className="sr-only">
- // <SheetTitle>Sidebar</SheetTitle>
- // <SheetDescription>Displays the mobile sidebar.</SheetDescription>
- // </SheetHeader>
- // <div className="flex h-full w-full flex-col">{children}</div>
- // </SheetContent>
- // </Sheet>
- // )
- // }
+ if (isMobile) {
+ return (
+ <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
+ <SheetContent
+ dir={dir}
+ data-sidebar="sidebar"
+ data-slot="sidebar"
+ data-mobile="true"
+ className="w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
+ style={
+ {
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
+ } as React.CSSProperties
+ }
+ side={side}
+ >
+ <SheetHeader className="sr-only">
+ <SheetTitle>Sidebar</SheetTitle>
+ <SheetDescription>Displays the mobile sidebar.</SheetDescription>
+ </SheetHeader>
+ <div className="flex h-full w-full flex-col">{children}</div>
+ </SheetContent>
+ </Sheet>
+ );
+ }
return (
<div
- className="group peer text-sidebar-foreground block"
+ className="group peer hidden text-sidebar-foreground md:block"
data-state={state}
data-collapsible={state === "collapsed" ? collapsible : ""}
data-variant={variant}
data-side={side}
data-slot="sidebar"
>
+ {/* This is what handles the sidebar gap on desktop */}
<div
data-slot="sidebar-gap"
className={cn(
@@ -219,11 +223,9 @@ function Sidebar({
/>
<div
data-slot="sidebar-container"
+ data-side={side}
className={cn(
- "fixed inset-y-0 z-10 flex h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear",
- side === "left"
- ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
- : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
+ "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
// Adjust the padding for floating and inset variants.
variant === "floating" || variant === "inset"
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
@@ -235,7 +237,7 @@ function Sidebar({
<div
data-sidebar="sidebar"
data-slot="sidebar-inner"
- className="bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border-2 group-data-[variant=floating]:shadow-sm"
+ className="flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-none group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border"
>
{children}
</div>
@@ -256,8 +258,8 @@ function SidebarTrigger({
data-sidebar="trigger"
data-slot="sidebar-trigger"
variant="ghost"
- size="icon"
- className={cn("size-7", className)}
+ size="icon-sm"
+ className={cn(className)}
onClick={(event) => {
onClick?.(event);
toggleSidebar();
@@ -282,10 +284,10 @@ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
onClick={toggleSidebar}
title="Toggle Sidebar"
className={cn(
- "hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex",
+ "absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2",
"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
- "hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
+ "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar",
"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
className,
@@ -300,8 +302,7 @@ function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
<main
data-slot="sidebar-inset"
className={cn(
- "bg-background relative flex w-full flex-1 flex-col",
- "md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
+ "relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-none md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
className,
)}
{...props}
@@ -317,7 +318,7 @@ function SidebarInput({
<Input
data-slot="sidebar-input"
data-sidebar="input"
- className={cn("bg-background h-8 w-full shadow-none", className)}
+ className={cn("h-8 w-full bg-background shadow-none", className)}
{...props}
/>
);
@@ -353,7 +354,7 @@ function SidebarSeparator({
<Separator
data-slot="sidebar-separator"
data-sidebar="separator"
- className={cn("bg-sidebar-border mx-2 w-auto", className)}
+ className={cn("mx-2 w-auto bg-sidebar-border", className)}
{...props}
/>
);
@@ -365,7 +366,7 @@ function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
data-slot="sidebar-content"
data-sidebar="content"
className={cn(
- "flex min-h-0 flex-1 flex-col gap-2 overflow-auto thin-scrollbar group-data-[collapsible=icon]:overflow-hidden",
+ "no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
className,
)}
{...props}
@@ -389,15 +390,14 @@ function SidebarGroupLabel({
asChild = false,
...props
}: React.ComponentProps<"div"> & { asChild?: boolean }) {
- const Comp = asChild ? Slot : "div";
+ const Comp = asChild ? Slot.Root : "div";
return (
<Comp
data-slot="sidebar-group-label"
data-sidebar="group-label"
className={cn(
- "text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
- "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
+ "flex h-8 shrink-0 items-center rounded-none px-2 text-xs text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
className,
)}
{...props}
@@ -410,17 +410,14 @@ function SidebarGroupAction({
asChild = false,
...props
}: React.ComponentProps<"button"> & { asChild?: boolean }) {
- const Comp = asChild ? Slot : "button";
+ const Comp = asChild ? Slot.Root : "button";
return (
<Comp
data-slot="sidebar-group-action"
data-sidebar="group-action"
className={cn(
- "text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
- // Increases the hit area of the button on mobile.
- "after:absolute after:-inset-2 md:after:hidden",
- "group-data-[collapsible=icon]:hidden",
+ "absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-none p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
className,
)}
{...props}
@@ -436,7 +433,7 @@ function SidebarGroupContent({
<div
data-slot="sidebar-group-content"
data-sidebar="group-content"
- className={cn("w-full text-sm", className)}
+ className={cn("w-full text-xs", className)}
{...props}
/>
);
@@ -447,7 +444,7 @@ function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
<ul
data-slot="sidebar-menu"
data-sidebar="menu"
- className={cn("flex w-full min-w-0 flex-col gap-1", className)}
+ className={cn("flex w-full min-w-0 flex-col gap-0", className)}
{...props}
/>
);
@@ -465,7 +462,7 @@ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
}
const sidebarMenuButtonVariants = cva(
- "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
+ "peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-none p-2 text-left text-xs ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",
{
variants: {
variant: {
@@ -474,9 +471,9 @@ const sidebarMenuButtonVariants = cva(
"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",
},
size: {
- default: "h-8 text-sm",
+ default: "h-8 text-xs",
sm: "h-7 text-xs",
- lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
+ lg: "h-12 text-xs group-data-[collapsible=icon]:p-0!",
},
},
defaultVariants: {
@@ -499,7 +496,7 @@ function SidebarMenuButton({
isActive?: boolean;
tooltip?: string | React.ComponentProps<typeof TooltipContent>;
} & VariantProps<typeof sidebarMenuButtonVariants>) {
- const Comp = asChild ? Slot : "button";
+ const Comp = asChild ? Slot.Root : "button";
const { isMobile, state } = useSidebar();
const button = (
@@ -545,22 +542,16 @@ function SidebarMenuAction({
asChild?: boolean;
showOnHover?: boolean;
}) {
- const Comp = asChild ? Slot : "button";
+ const Comp = asChild ? Slot.Root : "button";
return (
<Comp
data-slot="sidebar-menu-action"
data-sidebar="menu-action"
className={cn(
- "text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
- // Increases the hit area of the button on mobile.
- "after:absolute after:-inset-2 md:after:hidden",
- "peer-data-[size=sm]/menu-button:top-1",
- "peer-data-[size=default]/menu-button:top-1.5",
- "peer-data-[size=lg]/menu-button:top-2.5",
- "group-data-[collapsible=icon]:hidden",
+ "absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-none p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
showOnHover &&
- "peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",
+ "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0",
className,
)}
{...props}
@@ -577,12 +568,7 @@ function SidebarMenuBadge({
data-slot="sidebar-menu-badge"
data-sidebar="menu-badge"
className={cn(
- "text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none",
- "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
- "peer-data-[size=sm]/menu-button:top-1",
- "peer-data-[size=default]/menu-button:top-1.5",
- "peer-data-[size=lg]/menu-button:top-2.5",
- "group-data-[collapsible=icon]:hidden",
+ "pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-none px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground",
className,
)}
{...props}
@@ -606,12 +592,12 @@ function SidebarMenuSkeleton({
<div
data-slot="sidebar-menu-skeleton"
data-sidebar="menu-skeleton"
- className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
+ className={cn("flex h-8 items-center gap-2 rounded-none px-2", className)}
{...props}
>
{showIcon && (
<Skeleton
- className="size-4 rounded-md"
+ className="size-4 rounded-none"
data-sidebar="menu-skeleton-icon"
/>
)}
@@ -634,8 +620,7 @@ function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
data-slot="sidebar-menu-sub"
data-sidebar="menu-sub"
className={cn(
- "border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5",
- "group-data-[collapsible=icon]:hidden",
+ "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",
className,
)}
{...props}
@@ -668,7 +653,7 @@ function SidebarMenuSubButton({
size?: "sm" | "md";
isActive?: boolean;
}) {
- const Comp = asChild ? Slot : "a";
+ const Comp = asChild ? Slot.Root : "a";
return (
<Comp
@@ -677,11 +662,7 @@ function SidebarMenuSubButton({
data-size={size}
data-active={isActive}
className={cn(
- "text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-hidden focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
- "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
- size === "sm" && "text-xs",
- size === "md" && "text-sm",
- "group-data-[collapsible=icon]:hidden",
+ "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-none px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-xs data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
className,
)}
{...props}
diff --git a/src/components/ui/skeleton.tsx b/src/ui/components/skeleton.tsx
similarity index 74%
rename from src/components/ui/skeleton.tsx
rename to src/ui/components/skeleton.tsx
index 01689981c..ac4620a7f 100644
--- a/src/components/ui/skeleton.tsx
+++ b/src/ui/components/skeleton.tsx
@@ -4,7 +4,7 @@ function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="skeleton"
- className={cn("bg-accent animate-pulse rounded-md", className)}
+ className={cn("animate-pulse rounded-none bg-muted", className)}
{...props}
/>
);
diff --git a/src/components/ui/slider.tsx b/src/ui/components/slider.tsx
similarity index 100%
rename from src/components/ui/slider.tsx
rename to src/ui/components/slider.tsx
diff --git a/src/ui/components/sonner.tsx b/src/ui/components/sonner.tsx
new file mode 100644
index 000000000..900e3bfe6
--- /dev/null
+++ b/src/ui/components/sonner.tsx
@@ -0,0 +1,53 @@
+"use client";
+
+import { useTheme } from "@/components/theme-provider";
+import { Toaster as Sonner } from "sonner";
+
+type ToasterProps = React.ComponentProps<typeof Sonner>;
+
+const Toaster = ({ ...props }: ToasterProps) => {
+ const { theme = "system" } = useTheme();
+
+ return (
+ <Sonner
+ theme={theme as ToasterProps["theme"]}
+ className="toaster group"
+ toastOptions={{
+ classNames: {
+ toast:
+ "group toast group-[.toaster]:bg-card group-[.toaster]:text-card-foreground group-[.toaster]:border-border group-[.toaster]:rounded-none! group-[.toaster]:shadow-lg group-[.toaster]:font-mono",
+ description: "group-[.toast]:text-muted-foreground",
+ actionButton:
+ "group-[.toast]:bg-accent-brand group-[.toast]:text-white group-[.toast]:font-semibold",
+ cancelButton:
+ "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
+ success:
+ "group-[.toast]:!text-accent-brand group-[.toast]:!border-accent-brand/30",
+ info: "group-[.toast]:!text-accent-brand group-[.toast]:!border-accent-brand/30",
+ error:
+ "group-[.toast]:!text-destructive group-[.toast]:!border-destructive/30",
+ },
+ }}
+ style={
+ {
+ "--radius": "0px",
+ "--normal-bg": "var(--card)",
+ "--normal-border": "var(--border)",
+ "--normal-text": "var(--card-foreground)",
+ "--success-bg": "var(--card)",
+ "--success-border": "var(--border)",
+ "--success-text": "var(--color-accent-brand)",
+ "--info-bg": "var(--card)",
+ "--info-border": "var(--border)",
+ "--info-text": "var(--color-accent-brand)",
+ "--error-bg": "var(--card)",
+ "--error-border": "var(--border)",
+ "--error-text": "var(--destructive)",
+ } as React.CSSProperties
+ }
+ {...props}
+ />
+ );
+};
+
+export { Toaster };
diff --git a/src/components/ui/switch.tsx b/src/ui/components/switch.tsx
similarity index 100%
rename from src/components/ui/switch.tsx
rename to src/ui/components/switch.tsx
diff --git a/src/components/ui/table.tsx b/src/ui/components/table.tsx
similarity index 100%
rename from src/components/ui/table.tsx
rename to src/ui/components/table.tsx
diff --git a/src/components/ui/tabs.tsx b/src/ui/components/tabs.tsx
similarity index 100%
rename from src/components/ui/tabs.tsx
rename to src/ui/components/tabs.tsx
diff --git a/src/components/ui/textarea.tsx b/src/ui/components/textarea.tsx
similarity index 95%
rename from src/components/ui/textarea.tsx
rename to src/ui/components/textarea.tsx
index a5c849261..2f68150ef 100644
--- a/src/components/ui/textarea.tsx
+++ b/src/ui/components/textarea.tsx
@@ -1,6 +1,6 @@
import * as React from "react";
-import { cn } from "../../lib/utils";
+import { cn } from "@/lib/utils";
export type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
diff --git a/src/components/theme-provider.tsx b/src/ui/components/theme-provider.tsx
similarity index 53%
rename from src/components/theme-provider.tsx
rename to src/ui/components/theme-provider.tsx
index ba8b8e244..efb4bd780 100644
--- a/src/components/theme-provider.tsx
+++ b/src/ui/components/theme-provider.tsx
@@ -1,29 +1,32 @@
-/* eslint-disable react-refresh/only-export-components */
import { createContext, useContext, useEffect, useState } from "react";
-
-type Theme =
- | "dark"
- | "light"
- | "system"
- | "dracula"
- | "gentlemansChoice"
- | "midnightEspresso"
- | "catppuccinMocha";
+import type { ThemeId } from "@/types/ui-types";
type ThemeProviderProps = {
children: React.ReactNode;
- defaultTheme?: Theme;
+ defaultTheme?: ThemeId;
storageKey?: string;
};
type ThemeProviderState = {
- theme: Theme;
- setTheme: (theme: Theme) => void;
- setThemePreview: (theme: Theme | null) => void;
+ theme: ThemeId;
+ setTheme: (theme: ThemeId) => void;
+ setThemePreview: (theme: ThemeId | null) => void;
};
+const ALL_THEME_CLASSES = [
+ "light",
+ "dark",
+ "dracula",
+ "catppuccin",
+ "nord",
+ "solarized",
+ "tokyo-night",
+ "one-dark",
+ "gruvbox",
+];
+
const initialState: ThemeProviderState = {
- theme: "system",
+ theme: "dark",
setTheme: () => null,
setThemePreview: () => null,
};
@@ -32,60 +35,41 @@ const ThemeProviderContext = createContext<ThemeProviderState>(initialState);
export function ThemeProvider({
children,
- defaultTheme = "system",
+ defaultTheme = "dark",
storageKey = "vite-ui-theme",
...props
}: ThemeProviderProps) {
- const [theme, setTheme] = useState<Theme>(
- () => (localStorage.getItem(storageKey) as Theme) || defaultTheme,
+ const [theme, setTheme] = useState<ThemeId>(
+ () => (localStorage.getItem(storageKey) as ThemeId) || defaultTheme,
);
- const [previewTheme, setPreviewTheme] = useState<Theme | null>(null);
+ const [previewTheme, setPreviewTheme] = useState<ThemeId | null>(null);
+
+ const activeTheme = previewTheme ?? theme;
useEffect(() => {
const root = window.document.documentElement;
-
- root.classList.remove(
- "light",
- "dark",
- "dracula",
- "gentlemansChoice",
- "midnightEspresso",
- "catppuccinMocha",
- );
-
- const activeTheme = previewTheme || theme;
+ root.classList.remove(...ALL_THEME_CLASSES);
if (activeTheme === "system") {
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)")
.matches
? "dark"
: "light";
-
root.classList.add(systemTheme);
return;
}
root.classList.add(activeTheme);
-
- const darkCustomThemes: Theme[] = [
- "dracula",
- "gentlemansChoice",
- "midnightEspresso",
- "catppuccinMocha",
- ];
- if (darkCustomThemes.includes(activeTheme)) {
- root.classList.add("dark");
- }
- }, [theme, previewTheme]);
+ }, [activeTheme]);
const value = {
theme,
- setTheme: (theme: Theme) => {
+ setTheme: (theme: ThemeId) => {
localStorage.setItem(storageKey, theme);
setTheme(theme);
},
- setThemePreview: (theme: Theme | null) => {
- setPreviewTheme(theme);
+ setThemePreview: (preview: ThemeId | null) => {
+ setPreviewTheme(preview);
},
};
@@ -98,9 +82,7 @@ export function ThemeProvider({
export const useTheme = () => {
const context = useContext(ThemeProviderContext);
-
if (context === undefined)
throw new Error("useTheme must be used within a ThemeProvider");
-
return context;
};
diff --git a/src/ui/components/tooltip.tsx b/src/ui/components/tooltip.tsx
new file mode 100644
index 000000000..71ebfff51
--- /dev/null
+++ b/src/ui/components/tooltip.tsx
@@ -0,0 +1,57 @@
+"use client";
+
+import * as React from "react";
+import { Tooltip as TooltipPrimitive } from "radix-ui";
+
+import { cn } from "@/lib/utils";
+
+function TooltipProvider({
+ delayDuration = 0,
+ ...props
+}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
+ return (
+ <TooltipPrimitive.Provider
+ data-slot="tooltip-provider"
+ delayDuration={delayDuration}
+ {...props}
+ />
+ );
+}
+
+function Tooltip({
+ ...props
+}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
+ return <TooltipPrimitive.Root data-slot="tooltip" {...props} />;
+}
+
+function TooltipTrigger({
+ ...props
+}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
+ return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
+}
+
+function TooltipContent({
+ className,
+ sideOffset = 0,
+ children,
+ ...props
+}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
+ return (
+ <TooltipPrimitive.Portal>
+ <TooltipPrimitive.Content
+ data-slot="tooltip-content"
+ sideOffset={sideOffset}
+ className={cn(
+ "z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-none bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-none data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
+ className,
+ )}
+ {...props}
+ >
+ {children}
+ <TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-none bg-foreground fill-foreground" />
+ </TooltipPrimitive.Content>
+ </TooltipPrimitive.Portal>
+ );
+}
+
+export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
diff --git a/src/components/ui/version-alert.tsx b/src/ui/components/version-alert.tsx
similarity index 98%
rename from src/components/ui/version-alert.tsx
rename to src/ui/components/version-alert.tsx
index 4493e749a..b4df3c326 100644
--- a/src/components/ui/version-alert.tsx
+++ b/src/ui/components/version-alert.tsx
@@ -1,6 +1,6 @@
import React from "react";
-import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert.tsx";
-import { Button } from "@/components/ui/button.tsx";
+import { Alert, AlertTitle, AlertDescription } from "@/components/alert.tsx";
+import { Button } from "@/components/button.tsx";
import { ExternalLink, Download, AlertTriangle, Info } from "lucide-react";
import { useTranslation } from "react-i18next";
diff --git a/src/ui/desktop/apps/dashboard/Dashboard.tsx b/src/ui/dashboard/Dashboard.tsx
similarity index 75%
rename from src/ui/desktop/apps/dashboard/Dashboard.tsx
rename to src/ui/dashboard/Dashboard.tsx
index 3727e5ebe..ebfec4f90 100644
--- a/src/ui/desktop/apps/dashboard/Dashboard.tsx
+++ b/src/ui/dashboard/Dashboard.tsx
@@ -1,7 +1,7 @@
-import React, { useEffect, useState } from "react";
-import { Auth } from "@/ui/desktop/authentication/Auth.tsx";
-import { AlertManager } from "@/ui/desktop/apps/dashboard/apps/alerts/AlertManager.tsx";
-import { Button } from "@/components/ui/button.tsx";
+import React, { useEffect, useState, useRef, useCallback } from "react";
+import { Auth } from "@/auth/LoginPage.tsx";
+import { AlertManager } from "@/dashboard/panels/alerts/AlertManager.tsx";
+import { Button } from "@/components/button.tsx";
import {
getUserInfo,
getDatabaseHealth,
@@ -19,21 +19,21 @@ import {
getGuacamoleTokenFromHost,
isCurrentAuthInvalidationError,
type RecentActivityItem,
-} from "@/ui/main-axios.ts";
-import { useSidebar } from "@/components/ui/sidebar.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
-import { Kbd } from "@/components/ui/kbd";
+} from "@/main-axios.ts";
+import { useSidebar } from "@/components/sidebar.tsx";
+import { Separator } from "@/components/separator.tsx";
+import { useTabs } from "@/shell/TabContext.tsx";
+import { Kbd } from "@/components/kbd";
import { useTranslation } from "react-i18next";
import { Settings as SettingsIcon } from "lucide-react";
-import { ServerOverviewCard } from "@/ui/desktop/apps/dashboard/cards/ServerOverviewCard";
-import { RecentActivityCard } from "@/ui/desktop/apps/dashboard/cards/RecentActivityCard";
-import { QuickActionsCard } from "@/ui/desktop/apps/dashboard/cards/QuickActionsCard";
-import { ServerStatsCard } from "@/ui/desktop/apps/dashboard/cards/ServerStatsCard";
-import { NetworkGraphCard } from "@/ui/desktop/apps/dashboard/cards/NetworkGraphCard";
-import { useDashboardPreferences } from "@/ui/desktop/apps/dashboard/hooks/useDashboardPreferences";
-import { DashboardSettingsDialog } from "@/ui/desktop/apps/dashboard/components/DashboardSettingsDialog";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader";
+import { ServerOverviewCard } from "@/dashboard/cards/ServerOverviewCard";
+import { RecentActivityCard } from "@/dashboard/cards/RecentActivityCard";
+import { QuickActionsCard } from "@/dashboard/cards/QuickActionsCard";
+import { ServerStatsCard } from "@/dashboard/cards/ServerStatsCard";
+import { NetworkGraphCard } from "@/dashboard/cards/NetworkGraphCard";
+import { useDashboardPreferences } from "@/dashboard/hooks/useDashboardPreferences";
+import { DashboardSettingsDialog } from "@/dashboard/components/DashboardSettingsDialog";
+import { SimpleLoader } from "@/lib/SimpleLoader";
interface DashboardProps {
onSelectView: (view: string) => void;
@@ -101,6 +101,34 @@ export function Dashboard({
resetLayout,
} = useDashboardPreferences(loggedIn);
+ const containerRef = useRef<HTMLDivElement>(null);
+ const mainWidthPct = layout?.mainWidthPct ?? 68;
+
+ const handleDividerMouseDown = useCallback(
+ (e: React.MouseEvent) => {
+ e.preventDefault();
+ const startX = e.clientX;
+ const startPct = mainWidthPct;
+ const onMove = (ev: MouseEvent) => {
+ if (!containerRef.current) return;
+ const totalW = containerRef.current.getBoundingClientRect().width;
+ const delta = ev.clientX - startX;
+ const newPct = Math.min(
+ 85,
+ Math.max(30, startPct + (delta / totalW) * 100),
+ );
+ if (layout) updateLayout({ ...layout, mainWidthPct: newPct });
+ };
+ const onUp = () => {
+ window.removeEventListener("mousemove", onMove);
+ window.removeEventListener("mouseup", onUp);
+ };
+ window.addEventListener("mousemove", onMove);
+ window.addEventListener("mouseup", onUp);
+ },
+ [mainWidthPct, layout, updateLayout],
+ );
+
let sidebarState: "expanded" | "collapsed" = "expanded";
try {
const sidebar = useSidebar();
@@ -683,79 +711,130 @@ export function Dashboard({
<Separator className="mt-3 p-0.25" />
- <div className="flex flex-col flex-1 my-5 mx-5 gap-4 min-h-0 min-w-0 overflow-auto">
- {!preferencesLoading && layout && (
- <div
- className="grid gap-4"
- style={{
- gridTemplateColumns: "repeat(auto-fit, minmax(540px, 1fr))",
- gridAutoRows: "minmax(300px, 1fr)",
- minHeight: "100%",
- }}
- >
- {layout.cards
+ <div
+ ref={containerRef}
+ className="flex flex-row flex-1 my-5 mx-5 gap-0 min-h-0 min-w-0 overflow-hidden"
+ >
+ {!preferencesLoading &&
+ layout &&
+ (() => {
+ const enabledCards = layout.cards
.filter((card) => card.enabled)
- .sort((a, b) => a.order - b.order)
- .map((card) => {
- if (card.id === "server_overview") {
- return (
- <ServerOverviewCard
- key={card.id}
- loggedIn={loggedIn}
- versionText={versionText}
- versionStatus={versionStatus}
- uptime={uptime}
- dbHealth={dbHealth}
- totalServers={totalServers}
- totalTunnels={totalTunnels}
- totalCredentials={totalCredentials}
- updateCheckDisabled={updateCheckDisabled}
- />
- );
- } else if (card.id === "recent_activity") {
- return (
- <RecentActivityCard
- key={card.id}
- activities={recentActivity}
- loading={recentActivityLoading}
- onReset={handleResetActivity}
- onActivityClick={handleActivityClick}
- />
- );
- } else if (card.id === "network_graph") {
- return (
- <NetworkGraphCard
- key={card.id}
- isTopbarOpen={isTopbarOpen}
- rightSidebarOpen={rightSidebarOpen}
- rightSidebarWidth={rightSidebarWidth}
- />
- );
- } else if (card.id === "quick_actions") {
- return (
- <QuickActionsCard
+ .sort((a, b) => a.order - b.order);
+
+ const mainCards = enabledCards.filter(
+ (c) => (c.panel ?? "main") === "main",
+ );
+ const sideCards = enabledCards.filter(
+ (c) => c.panel === "side",
+ );
+
+ const renderCard = (card: (typeof enabledCards)[0]) => {
+ if (card.id === "server_overview") {
+ return (
+ <ServerOverviewCard
+ key={card.id}
+ loggedIn={loggedIn}
+ versionText={versionText}
+ versionStatus={versionStatus}
+ uptime={uptime}
+ dbHealth={dbHealth}
+ totalServers={totalServers}
+ totalTunnels={totalTunnels}
+ totalCredentials={totalCredentials}
+ updateCheckDisabled={updateCheckDisabled}
+ />
+ );
+ } else if (card.id === "recent_activity") {
+ return (
+ <RecentActivityCard
+ key={card.id}
+ activities={recentActivity}
+ loading={recentActivityLoading}
+ onReset={handleResetActivity}
+ onActivityClick={handleActivityClick}
+ />
+ );
+ } else if (card.id === "network_graph") {
+ return (
+ <NetworkGraphCard
+ key={card.id}
+ isTopbarOpen={isTopbarOpen}
+ rightSidebarOpen={rightSidebarOpen}
+ rightSidebarWidth={rightSidebarWidth}
+ />
+ );
+ } else if (card.id === "quick_actions") {
+ return (
+ <QuickActionsCard
+ key={card.id}
+ isAdmin={isAdmin}
+ onAddHost={handleAddHost}
+ onAddCredential={handleAddCredential}
+ onOpenAdminSettings={handleOpenAdminSettings}
+ onOpenUserProfile={handleOpenUserProfile}
+ />
+ );
+ } else if (card.id === "server_stats") {
+ return (
+ <ServerStatsCard
+ key={card.id}
+ serverStats={serverStats}
+ loading={serverStatsLoading}
+ onServerClick={handleServerStatClick}
+ />
+ );
+ }
+ return null;
+ };
+
+ return (
+ <>
+ <div
+ className="flex flex-col gap-4 overflow-auto min-h-0"
+ style={{ width: `${mainWidthPct}%`, minWidth: 0 }}
+ >
+ {mainCards.map((card) => (
+ <div
key={card.id}
- isAdmin={isAdmin}
- onAddHost={handleAddHost}
- onAddCredential={handleAddCredential}
- onOpenAdminSettings={handleOpenAdminSettings}
- onOpenUserProfile={handleOpenUserProfile}
- />
- );
- } else if (card.id === "server_stats") {
- return (
- <ServerStatsCard
+ style={
+ card.height
+ ? { height: card.height, flexShrink: 0 }
+ : { flex: 1, minHeight: 280 }
+ }
+ >
+ {renderCard(card)}
+ </div>
+ ))}
+ </div>
+
+ <div
+ className="flex-shrink-0 w-2 mx-1.5 flex items-center justify-center cursor-col-resize group"
+ onMouseDown={handleDividerMouseDown}
+ >
+ <div className="w-0.5 h-16 rounded-full bg-border group-hover:bg-primary/50 transition-colors" />
+ </div>
+
+ <div
+ className="flex flex-col gap-4 overflow-auto min-h-0"
+ style={{ flex: 1, minWidth: 0 }}
+ >
+ {sideCards.map((card) => (
+ <div
key={card.id}
- serverStats={serverStats}
- loading={serverStatsLoading}
- onServerClick={handleServerStatClick}
- />
- );
- }
- return null;
- })}
- </div>
- )}
+ style={
+ card.height
+ ? { height: card.height, flexShrink: 0 }
+ : { flex: 1, minHeight: 280 }
+ }
+ >
+ {renderCard(card)}
+ </div>
+ ))}
+ </div>
+ </>
+ );
+ })()}
</div>
</div>
</div>
diff --git a/src/ui/dashboard/DashboardTab.tsx b/src/ui/dashboard/DashboardTab.tsx
new file mode 100644
index 000000000..ea3c8f7bb
--- /dev/null
+++ b/src/ui/dashboard/DashboardTab.tsx
@@ -0,0 +1,1471 @@
+import { useState, useRef, useCallback, useEffect } from "react";
+import { useIsMobile } from "@/hooks/use-mobile";
+import { Button } from "@/components/button";
+import { Card } from "@/components/card";
+import { Separator } from "@/components/separator";
+import {
+ Activity,
+ Database,
+ GripHorizontal,
+ GripVertical,
+ KeyRound,
+ LayoutDashboard,
+ Network,
+ Plus,
+ RefreshCw,
+ Server,
+ Settings,
+ Terminal,
+ Trash2,
+ User,
+ Zap,
+} from "lucide-react";
+import CytoscapeComponent from "react-cytoscapejs";
+import { Kbd } from "@/components/kbd";
+import { DASHBOARD_CARDS } from "@/lib/theme";
+import type { DashboardCardId, TabType, Host } from "@/types/ui-types";
+import {
+ getSSHHosts,
+ getUptime,
+ getRecentActivity,
+ getTunnelStatuses,
+ getCredentials,
+ resetRecentActivity,
+} from "@/main-axios";
+import type { RecentActivityItem, SSHHostWithStatus } from "@/main-axios";
+
+function sshHostToHost(h: SSHHostWithStatus): Host {
+ return {
+ id: String(h.id),
+ name: h.name,
+ user: h.username,
+ address: h.ip,
+ port: h.port,
+ folder: h.folder ?? "",
+ online: h.status === "online",
+ cpu: 0,
+ ram: 0,
+ lastAccess: "",
+ tags: h.tags ?? [],
+ authType: h.authType,
+ password: h.password,
+ key: typeof h.key === "string" ? h.key : undefined,
+ keyPassword: h.keyPassword,
+ keyType: h.keyType,
+ credentialId: h.credentialId != null ? String(h.credentialId) : undefined,
+ notes: h.notes,
+ pin: h.pin ?? false,
+ macAddress: h.macAddress,
+ enableTerminal: h.enableTerminal ?? true,
+ enableTunnel: h.enableTunnel ?? false,
+ enableFileManager: h.enableFileManager ?? false,
+ enableDocker: h.enableDocker ?? false,
+ enableSsh: h.connectionType === "ssh" || !h.connectionType,
+ enableRdp: h.connectionType === "rdp",
+ enableVnc: h.connectionType === "vnc",
+ enableTelnet: h.connectionType === "telnet",
+ sshPort: h.port,
+ rdpPort: 3389,
+ vncPort: 5900,
+ telnetPort: 23,
+ quickActions: (h.quickActions ?? []).map((a) => ({
+ name: a.name,
+ snippetId: String(a.snippetId),
+ })),
+ serverTunnels: [],
+ defaultPath: h.defaultPath,
+ terminalConfig: h.terminalConfig as Host["terminalConfig"],
+ useSocks5: h.useSocks5,
+ socks5Host: h.socks5Host,
+ socks5Port: h.socks5Port,
+ socks5Username: h.socks5Username,
+ socks5Password: h.socks5Password,
+ };
+}
+
+// ─── Types ────────────────────────────────────────────────────────────────────
+
+type PanelId = "main" | "side";
+
+type CardSlot = {
+ id: DashboardCardId;
+ panel: PanelId;
+ order: number;
+ height: number | null;
+};
+
+type DragState = {
+ id: DashboardCardId;
+ sourcePanel: PanelId;
+ sourceOrder: number;
+} | null;
+
+// ─── Default layout ───────────────────────────────────────────────────────────
+
+const DEFAULT_SLOTS: CardSlot[] = [
+ { id: "stats_bar", panel: "main", order: 0, height: 96 },
+ { id: "counters_bar", panel: "main", order: 1, height: 48 },
+ { id: "quick_actions", panel: "main", order: 2, height: 160 },
+ { id: "host_status", panel: "main", order: 3, height: null },
+ { id: "recent_activity", panel: "side", order: 0, height: null },
+];
+
+const CARD_META: Record<DashboardCardId, { label: string }> = {
+ stats_bar: { label: "Status Bar" },
+ counters_bar: { label: "Counters" },
+ quick_actions: { label: "Quick Actions" },
+ host_status: { label: "Host Status" },
+ recent_activity: { label: "Recent Activity" },
+ network_graph: { label: "Network Graph" },
+};
+
+// ─── useColumnResize ──────────────────────────────────────────────────────────
+
+function useColumnResize(
+ containerRef: React.RefObject<HTMLDivElement | null>,
+ mainWidthPct: number,
+ setMainWidthPct: (v: number) => void,
+) {
+ const dragging = useRef(false);
+ const startX = useRef(0);
+ const startPct = useRef(0);
+
+ const onMouseDown = useCallback(
+ (e: React.MouseEvent) => {
+ e.preventDefault();
+ dragging.current = true;
+ startX.current = e.clientX;
+ startPct.current = mainWidthPct;
+
+ const onMove = (ev: MouseEvent) => {
+ if (!dragging.current || !containerRef.current) return;
+ const totalW = containerRef.current.getBoundingClientRect().width;
+ const delta = ev.clientX - startX.current;
+ const newPct = Math.min(
+ 85,
+ Math.max(30, startPct.current + (delta / totalW) * 100),
+ );
+ setMainWidthPct(newPct);
+ };
+ const onUp = () => {
+ dragging.current = false;
+ window.removeEventListener("mousemove", onMove);
+ window.removeEventListener("mouseup", onUp);
+ };
+ window.addEventListener("mousemove", onMove);
+ window.addEventListener("mouseup", onUp);
+ },
+ [containerRef, mainWidthPct, setMainWidthPct],
+ );
+
+ return onMouseDown;
+}
+
+// ─── Card components ──────────────────────────────────────────────────────────
+
+function StatsBarCard({
+ hosts,
+ uptimeFormatted,
+}: {
+ hosts: Host[];
+ uptimeFormatted: string;
+}) {
+ const online = hosts.filter((h) => h.online).length;
+ return (
+ <Card className="grid grid-cols-4 divide-x divide-border overflow-hidden w-full h-full py-0 gap-0">
+ <div className="flex flex-col justify-center px-4 py-2 gap-1">
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold">
+ Version
+ </span>
+ <span className="text-xl font-bold text-accent-brand leading-none">
+ v2.2.0
+ </span>
+ <span className="text-[10px] bg-accent-brand/20 text-accent-brand px-1.5 py-0.5 w-fit font-semibold leading-none">
+ STABLE
+ </span>
+ </div>
+ <div className="flex flex-col justify-center px-4 py-2 gap-1">
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold">
+ Uptime
+ </span>
+ <span className="text-xl font-bold leading-none">
+ {uptimeFormatted || "—"}
+ </span>
+ </div>
+ <div className="flex flex-col justify-center px-4 py-2 gap-1">
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold">
+ Database
+ </span>
+ <span className="text-xl font-bold text-accent-brand leading-none">
+ Healthy
+ </span>
+ </div>
+ <div className="flex flex-col justify-center px-4 py-2 gap-1">
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold">
+ Hosts Online
+ </span>
+ <div className="flex items-baseline gap-1">
+ <span className="text-xl font-bold leading-none">{online}</span>
+ <span className="text-base text-muted-foreground leading-none">
+ /{hosts.length}
+ </span>
+ </div>
+ </div>
+ </Card>
+ );
+}
+
+function CountersBarCard({
+ hosts,
+ credentialCount,
+ activeTunnelCount,
+}: {
+ hosts: Host[];
+ credentialCount: number;
+ activeTunnelCount: number;
+}) {
+ return (
+ <Card className="grid grid-cols-3 divide-x divide-border overflow-hidden w-full h-full py-0 gap-0">
+ <div className="flex items-center gap-2.5 px-4 py-2.5">
+ <Server className="size-3.5 text-muted-foreground shrink-0" />
+ <span className="text-base font-bold">{hosts.length}</span>
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold">
+ Total Hosts
+ </span>
+ </div>
+ <div className="flex items-center gap-2.5 px-4 py-2.5">
+ <KeyRound className="size-3.5 text-muted-foreground shrink-0" />
+ <span className="text-base font-bold">{credentialCount}</span>
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold">
+ Credentials
+ </span>
+ </div>
+ <div className="flex items-center gap-2.5 px-4 py-2.5">
+ <Network className="size-3.5 text-muted-foreground shrink-0" />
+ <span className="text-base font-bold">{activeTunnelCount}</span>
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold">
+ Active Tunnels
+ </span>
+ </div>
+ </Card>
+ );
+}
+
+function QuickActionsCard({
+ onOpenSingletonTab,
+}: {
+ onOpenSingletonTab: (type: TabType, pendingEvent?: string) => void;
+}) {
+ return (
+ <Card className="flex flex-col overflow-hidden w-full h-full py-0 gap-0">
+ <div className="flex items-center gap-2 px-4 py-2.5 border-b border-border shrink-0">
+ <Zap className="size-3.5 text-muted-foreground" />
+ <span className="text-xs text-muted-foreground uppercase tracking-widest font-semibold">
+ Quick Actions
+ </span>
+ </div>
+ <div className="flex flex-1 min-h-0">
+ <div className="flex flex-col flex-1 border-r border-border">
+ <button
+ onClick={() =>
+ onOpenSingletonTab("host-manager", "host-manager:add-host")
+ }
+ className="group/btn flex items-center gap-2.5 px-4 py-2.5 hover:bg-muted transition-colors cursor-pointer border-b border-border flex-1"
+ >
+ <div className="size-7 border border-border bg-muted flex items-center justify-center shrink-0 group-hover/btn:bg-accent-brand/20 group-hover/btn:border-accent-brand/40 transition-colors">
+ <Plus className="size-3 text-accent-brand" />
+ </div>
+ <div className="flex flex-col items-start text-left">
+ <span className="text-xs font-semibold">Add Host</span>
+ <span className="text-[10px] text-muted-foreground">
+ Register a new server
+ </span>
+ </div>
+ </button>
+ <button
+ onClick={() =>
+ onOpenSingletonTab("host-manager", "host-manager:add-credential")
+ }
+ className="group/btn flex items-center gap-2.5 px-4 py-2.5 hover:bg-muted transition-colors cursor-pointer flex-1"
+ >
+ <div className="size-7 border border-border bg-muted flex items-center justify-center shrink-0 group-hover/btn:bg-accent-brand/20 group-hover/btn:border-accent-brand/40 transition-colors">
+ <KeyRound className="size-3 text-accent-brand" />
+ </div>
+ <div className="flex flex-col items-start text-left">
+ <span className="text-xs font-semibold">Add Credential</span>
+ <span className="text-[10px] text-muted-foreground">
+ Store SSH keys or passwords
+ </span>
+ </div>
+ </button>
+ </div>
+ <div className="flex flex-col flex-1">
+ <button
+ onClick={() => onOpenSingletonTab("admin-settings")}
+ className="group/btn flex items-center gap-2.5 px-4 py-2.5 hover:bg-muted transition-colors cursor-pointer border-b border-border flex-1"
+ >
+ <div className="size-7 border border-border bg-muted flex items-center justify-center shrink-0 group-hover/btn:bg-accent-brand/20 group-hover/btn:border-accent-brand/40 transition-colors">
+ <Settings className="size-3 text-accent-brand" />
+ </div>
+ <div className="flex flex-col items-start text-left">
+ <span className="text-xs font-semibold">Admin Settings</span>
+ <span className="text-[10px] text-muted-foreground">
+ Manage users and roles
+ </span>
+ </div>
+ </button>
+ <button
+ onClick={() => onOpenSingletonTab("user-profile")}
+ className="group/btn flex items-center gap-2.5 px-4 py-2.5 hover:bg-muted transition-colors cursor-pointer flex-1"
+ >
+ <div className="size-7 border border-border bg-muted flex items-center justify-center shrink-0 group-hover/btn:bg-accent-brand/20 group-hover/btn:border-accent-brand/40 transition-colors">
+ <User className="size-3 text-accent-brand" />
+ </div>
+ <div className="flex flex-col items-start text-left">
+ <span className="text-xs font-semibold">User Profile</span>
+ <span className="text-[10px] text-muted-foreground">
+ Manage your account
+ </span>
+ </div>
+ </button>
+ </div>
+ </div>
+ </Card>
+ );
+}
+
+function HostStatusCard({
+ hosts,
+ onOpenTab,
+}: {
+ hosts: Host[];
+ onOpenTab: (host: Host, type: TabType) => void;
+}) {
+ const online = hosts.filter((h) => h.online).length;
+ return (
+ <Card className="flex flex-col overflow-hidden w-full h-full py-0 gap-0">
+ <div className="flex items-center justify-between px-4 py-3 border-b border-border shrink-0">
+ <div className="flex items-center gap-2">
+ <Database className="size-3.5 text-muted-foreground" />
+ <span className="text-xs text-muted-foreground uppercase tracking-widest font-semibold">
+ Host Status
+ </span>
+ </div>
+ <span className="text-xs text-muted-foreground">
+ {online}/{hosts.length} online
+ </span>
+ </div>
+ <div className="flex flex-col overflow-auto flex-1">
+ {hosts.length === 0 && (
+ <div className="flex-1 flex items-center justify-center text-xs text-muted-foreground/40 py-8">
+ No hosts configured
+ </div>
+ )}
+ {hosts.map((host, i) => (
+ <div
+ key={i}
+ onClick={() => onOpenTab(host, "stats")}
+ className="flex items-center justify-between px-4 py-2.5 border-b border-border last:border-0 hover:bg-muted/50 cursor-pointer"
+ >
+ <div className="flex items-center gap-2.5">
+ <span
+ className={`size-1.5 rounded-full shrink-0 ${host.online ? "bg-accent-brand" : "bg-muted-foreground/40"}`}
+ />
+ <div className="flex flex-col">
+ <span className="text-xs font-semibold">{host.name}</span>
+ <span className="text-[10px] text-muted-foreground font-mono">
+ {host.ip}
+ </span>
+ </div>
+ </div>
+ <div className="flex items-center gap-3">
+ {host.online ? (
+ <div className="flex items-center gap-3">
+ <div className="flex flex-col gap-0.5 w-16">
+ <div className="flex items-center justify-between">
+ <span className="text-[10px] text-muted-foreground">
+ CPU
+ </span>
+ <span className="text-[10px] font-bold text-accent-brand">
+ {host.cpu ?? 0}%
+ </span>
+ </div>
+ <div className="h-0.5 bg-muted w-full">
+ <div
+ className="h-full bg-accent-brand"
+ style={{ width: `${host.cpu ?? 0}%` }}
+ />
+ </div>
+ </div>
+ <div className="flex flex-col gap-0.5 w-16">
+ <div className="flex items-center justify-between">
+ <span className="text-[10px] text-muted-foreground">
+ RAM
+ </span>
+ <span className="text-[10px] font-bold text-accent-brand">
+ {host.ram ?? 0}%
+ </span>
+ </div>
+ <div className="h-0.5 bg-muted w-full">
+ <div
+ className="h-full bg-accent-brand"
+ style={{ width: `${host.ram ?? 0}%` }}
+ />
+ </div>
+ </div>
+ </div>
+ ) : (
+ <div className="flex items-center gap-3">
+ <span className="text-[10px] text-muted-foreground w-16 text-center">
+ —
+ </span>
+ <span className="text-[10px] text-muted-foreground w-16 text-center">
+ —
+ </span>
+ </div>
+ )}
+ <span
+ className={`text-[10px] px-2 py-0.5 font-semibold border ${host.online ? "border-accent-brand/40 text-accent-brand bg-accent-brand/10" : "border-border text-muted-foreground"}`}
+ >
+ {host.online ? "ONLINE" : "OFFLINE"}
+ </span>
+ </div>
+ </div>
+ ))}
+ </div>
+ </Card>
+ );
+}
+
+function RecentActivityCard({
+ activity,
+ hosts,
+ onOpenTab,
+ onClear,
+}: {
+ activity: RecentActivityItem[];
+ hosts: Host[];
+ onOpenTab: (host: Host, type: TabType) => void;
+ onClear: () => void;
+}) {
+ const typeIcon: Record<RecentActivityItem["type"], React.ReactNode> = {
+ terminal: <Terminal className="size-2.5" />,
+ file_manager: <Server className="size-2.5" />,
+ server_stats: <Activity className="size-2.5" />,
+ tunnel: <Network className="size-2.5" />,
+ docker: <Server className="size-2.5" />,
+ rdp: <Server className="size-2.5" />,
+ vnc: <Server className="size-2.5" />,
+ telnet: <Terminal className="size-2.5" />,
+ };
+ const typeToTab: Record<RecentActivityItem["type"], TabType> = {
+ terminal: "terminal",
+ file_manager: "files",
+ server_stats: "stats",
+ tunnel: "tunnel",
+ docker: "docker",
+ rdp: "rdp",
+ vnc: "vnc",
+ telnet: "telnet",
+ };
+ function formatTime(ts: string) {
+ const diff = Math.floor((Date.now() - new Date(ts).getTime()) / 1000);
+ if (diff < 60) return `${diff}s ago`;
+ if (diff < 3600) return `${Math.floor(diff / 60)}m ago`;
+ if (diff < 86400) return `${Math.floor(diff / 3600)}h ago`;
+ return `${Math.floor(diff / 86400)}d ago`;
+ }
+ return (
+ <Card className="flex flex-col overflow-hidden w-full h-full py-0 gap-0">
+ <div className="flex items-center justify-between px-4 py-3 border-b border-border shrink-0">
+ <div className="flex items-center gap-2">
+ <Activity className="size-3.5 text-muted-foreground" />
+ <span className="text-xs text-muted-foreground uppercase tracking-widest font-semibold">
+ Recent Activity
+ </span>
+ </div>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-xs text-accent-brand h-auto py-0.5 px-2"
+ onClick={onClear}
+ >
+ Clear
+ </Button>
+ </div>
+ <div className="flex flex-col overflow-auto flex-1">
+ {activity.length === 0 && (
+ <div className="flex-1 flex items-center justify-center text-xs text-muted-foreground/40 py-8">
+ No recent activity
+ </div>
+ )}
+ {activity.map((item) => {
+ const host = hosts.find((h) => h.id === String(item.hostId));
+ return (
+ <div
+ key={item.id}
+ onClick={() => {
+ if (host) onOpenTab(host, typeToTab[item.type]);
+ }}
+ className="flex items-center justify-between px-4 py-2 border-b border-border last:border-0 hover:bg-muted/50 cursor-pointer"
+ >
+ <div className="flex items-center gap-2">
+ <span
+ className={`size-1.5 rounded-full shrink-0 ${host?.online ? "bg-accent-brand" : "bg-muted-foreground/40"}`}
+ />
+ <div className="flex flex-col">
+ <span className="text-xs font-semibold truncate max-w-24">
+ {item.hostName}
+ </span>
+ <div className="flex items-center gap-1 text-muted-foreground">
+ {typeIcon[item.type]}
+ <span className="text-[10px] capitalize">
+ {item.type.replace("_", " ")}
+ </span>
+ </div>
+ </div>
+ </div>
+ <span className="text-[10px] text-muted-foreground shrink-0">
+ {formatTime(item.timestamp)}
+ </span>
+ </div>
+ );
+ })}
+ </div>
+ </Card>
+ );
+}
+
+function NetworkGraphCard({ hosts }: { hosts: Host[] }) {
+ const cyRef = useRef<any>(null);
+ const [contextMenu, setContextMenu] = useState<{
+ visible: boolean;
+ x: number;
+ y: number;
+ node: any;
+ } | null>(null);
+ const contextMenuRef = useRef<HTMLDivElement>(null);
+
+ const elements = hosts.map((h, i) => ({
+ data: {
+ id: h.id,
+ label: h.name,
+ ip: `${h.ip}:${h.port ?? 22}`,
+ status: h.online ? "online" : "offline",
+ },
+ position: { x: 120 + (i % 4) * 160, y: 80 + Math.floor(i / 4) * 100 },
+ }));
+
+ const buildNodeStyle = useCallback((ele: any) => {
+ const isOnline = ele.data("status") === "online";
+ const name = ele.data("label") || "";
+ const ip = ele.data("ip") || "";
+ const statusColor = isOnline ? "rgb(251,146,60)" : "rgb(100,116,139)";
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="160" height="72" viewBox="0 0 160 72">
+ <defs><filter id="sh" x="-15%" y="-15%" width="130%" height="130%">
+ <feDropShadow dx="0" dy="2" stdDeviation="3" flood-color="#000" flood-opacity="0.4"/>
+ </filter></defs>
+ <rect x="2" y="2" width="156" height="68" rx="4" fill="#09090b" stroke="${statusColor}" stroke-width="1.5" filter="url(#sh)"/>
+ <circle cx="18" cy="36" r="4" fill="${statusColor}" opacity="0.9"/>
+ <text x="32" y="30" font-family="monospace" font-size="12" font-weight="700" fill="#f1f5f9">${name}</text>
+ <text x="32" y="48" font-family="monospace" font-size="10" fill="#64748b">${ip}</text>
+ </svg>`;
+ return "data:image/svg+xml;utf8," + encodeURIComponent(svg);
+ }, []);
+
+ const handleCyInit = useCallback(
+ (cy: any) => {
+ cyRef.current = cy;
+ cy.style()
+ .selector("node")
+ .style({
+ label: "",
+ width: "160px",
+ height: "72px",
+ shape: "round-rectangle",
+ "border-width": "0px",
+ "background-opacity": 0,
+ "background-image": buildNodeStyle,
+ "background-fit": "contain",
+ })
+ .selector("edge")
+ .style({
+ width: "1.5px",
+ "line-color": "#2a2a2c",
+ "curve-style": "bezier",
+ "target-arrow-shape": "none",
+ })
+ .selector("node:selected")
+ .style({
+ "overlay-color": "#fb923c",
+ "overlay-opacity": 0.08,
+ "overlay-padding": "4px",
+ })
+ .update();
+ cy.nodes().ungrabify();
+ cy.on("tap", (evt: any) => {
+ if (evt.target === cy) setContextMenu(null);
+ });
+ cy.on("cxttap tap", "node", (evt: any) => {
+ evt.stopPropagation();
+ const node = evt.target;
+ setContextMenu({
+ visible: true,
+ x: evt.originalEvent.clientX,
+ y: evt.originalEvent.clientY,
+ node: node.data(),
+ });
+ });
+ cy.on("zoom pan", () => setContextMenu(null));
+ },
+ [buildNodeStyle],
+ );
+
+ useEffect(() => {
+ const handler = (e: MouseEvent) => {
+ if (
+ contextMenuRef.current &&
+ !contextMenuRef.current.contains(e.target as Node)
+ )
+ setContextMenu(null);
+ };
+ document.addEventListener("mousedown", handler, true);
+ return () => document.removeEventListener("mousedown", handler, true);
+ }, []);
+
+ return (
+ <Card className="flex flex-col overflow-hidden w-full h-full py-0 gap-0">
+ <div className="flex items-center justify-between px-4 py-3 border-b border-border shrink-0">
+ <div className="flex items-center gap-2">
+ <Network className="size-3.5 text-muted-foreground" />
+ <span className="text-xs text-muted-foreground uppercase tracking-widest font-semibold">
+ Network Graph
+ </span>
+ </div>
+ <div className="flex items-center gap-2">
+ <span className="text-xs text-muted-foreground">
+ {hosts.length} nodes
+ </span>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-xs h-auto py-0.5 px-2"
+ onClick={() => cyRef.current?.fit()}
+ >
+ <RefreshCw className="size-3" />
+ </Button>
+ </div>
+ </div>
+ <div className="relative flex-1 min-h-0 overflow-hidden">
+ {contextMenu?.visible && (
+ <div
+ ref={contextMenuRef}
+ className="fixed z-[200] min-w-[160px] shadow-2xl p-1 flex flex-col gap-0.5 bg-card border border-border"
+ style={{ top: contextMenu.y, left: contextMenu.x }}
+ >
+ <div className="px-3 py-1.5 border-b border-border mb-0.5">
+ <span className="text-xs font-bold font-mono">
+ {contextMenu.node.label}
+ </span>
+ <span className="text-[10px] text-muted-foreground block">
+ {contextMenu.node.ip}
+ </span>
+ </div>
+ <button className="flex items-center gap-2 px-3 py-1.5 text-xs hover:bg-muted transition-colors text-left w-full">
+ <Terminal className="size-3" />
+ Terminal
+ </button>
+ <button className="flex items-center gap-2 px-3 py-1.5 text-xs hover:bg-muted transition-colors text-left w-full">
+ <Server className="size-3" />
+ Server Stats
+ </button>
+ </div>
+ )}
+ {hosts.length > 0 ? (
+ <CytoscapeComponent
+ elements={elements}
+ style={{ width: "100%", height: "100%" }}
+ layout={
+ { name: "grid", rows: Math.ceil(Math.sqrt(hosts.length)) } as any
+ }
+ cy={handleCyInit}
+ wheelSensitivity={1.5}
+ minZoom={0.3}
+ maxZoom={2.5}
+ />
+ ) : (
+ <div className="flex-1 flex items-center justify-center text-xs text-muted-foreground/40 h-full">
+ No hosts to display
+ </div>
+ )}
+ <div className="absolute bottom-2 left-3 flex items-center gap-3 pointer-events-none">
+ <div className="flex items-center gap-1.5">
+ <span className="size-1.5 rounded-full bg-accent-brand inline-block" />
+ <span className="text-[10px] text-muted-foreground font-mono">
+ Online
+ </span>
+ </div>
+ <div className="flex items-center gap-1.5">
+ <span className="size-1.5 rounded-full bg-muted-foreground/50 inline-block" />
+ <span className="text-[10px] text-muted-foreground font-mono">
+ Offline
+ </span>
+ </div>
+ </div>
+ </div>
+ </Card>
+ );
+}
+
+// ─── CardItem ─────────────────────────────────────────────────────────────────
+
+function CardItem({
+ slot,
+ editMode,
+ isDragging,
+ onDragStart,
+ onDrop,
+ onDragOver,
+ onRemove,
+ onHeightChange,
+ onOpenSingletonTab,
+ onOpenTab,
+ hosts,
+ uptimeFormatted,
+ credentialCount,
+ activeTunnelCount,
+ activity,
+ onClearActivity,
+}: {
+ slot: CardSlot;
+ editMode: boolean;
+ isDragging: boolean;
+ onDragStart: () => void;
+ onDrop: () => void;
+ onDragOver: (e: React.DragEvent) => void;
+ onRemove: () => void;
+ onHeightChange: (id: DashboardCardId, h: number) => void;
+ onOpenSingletonTab: (type: TabType, pendingEvent?: string) => void;
+ onOpenTab: (host: Host, type: TabType) => void;
+ hosts: Host[];
+ uptimeFormatted: string;
+ credentialCount: number;
+ activeTunnelCount: number;
+ activity: RecentActivityItem[];
+ onClearActivity: () => void;
+}) {
+ const cardRef = useRef<HTMLDivElement | null>(null);
+
+ const onResizeMouseDown = useCallback(
+ (e: React.MouseEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ const startY = e.clientY;
+ const startH = cardRef.current?.getBoundingClientRect().height ?? 100;
+ const onMove = (ev: MouseEvent) => {
+ onHeightChange(slot.id, Math.max(50, startH + (ev.clientY - startY)));
+ };
+ const onUp = () => {
+ window.removeEventListener("mousemove", onMove);
+ window.removeEventListener("mouseup", onUp);
+ };
+ window.addEventListener("mousemove", onMove);
+ window.addEventListener("mouseup", onUp);
+ },
+ [slot.id, onHeightChange],
+ );
+
+ const isFlex = slot.height === null;
+ const cardProps = {
+ hosts,
+ uptimeFormatted,
+ credentialCount,
+ activeTunnelCount,
+ activity,
+ onOpenTab,
+ onOpenSingletonTab,
+ };
+
+ return (
+ <div
+ ref={cardRef}
+ className={`relative flex flex-col transition-opacity select-none ${isDragging ? "opacity-40" : "opacity-100"} ${isFlex ? "flex-1 min-h-0" : "shrink-0"}`}
+ style={!isFlex ? { height: slot.height } : undefined}
+ draggable={editMode}
+ onDragStart={onDragStart}
+ onDrop={onDrop}
+ onDragOver={onDragOver}
+ >
+ {editMode && (
+ <div className="absolute inset-0 z-10 pointer-events-none border-2 border-dashed border-accent-brand/30" />
+ )}
+ {editMode && (
+ <div className="absolute top-2 right-2 z-20 flex items-center gap-1">
+ <div className="size-6 bg-card border border-border flex items-center justify-center cursor-grab active:cursor-grabbing pointer-events-auto">
+ <GripVertical className="size-3 text-muted-foreground" />
+ </div>
+ <button
+ onClick={onRemove}
+ className="size-6 bg-card border border-border flex items-center justify-center hover:bg-destructive/10 hover:border-destructive/40 transition-colors pointer-events-auto"
+ >
+ <Trash2 className="size-3 text-muted-foreground" />
+ </button>
+ </div>
+ )}
+ <div className="flex-1 min-h-0 overflow-hidden">
+ {slot.id === "stats_bar" && (
+ <StatsBarCard
+ hosts={cardProps.hosts}
+ uptimeFormatted={cardProps.uptimeFormatted}
+ />
+ )}
+ {slot.id === "counters_bar" && (
+ <CountersBarCard
+ hosts={cardProps.hosts}
+ credentialCount={cardProps.credentialCount}
+ activeTunnelCount={cardProps.activeTunnelCount}
+ />
+ )}
+ {slot.id === "quick_actions" && (
+ <QuickActionsCard onOpenSingletonTab={cardProps.onOpenSingletonTab} />
+ )}
+ {slot.id === "host_status" && (
+ <HostStatusCard
+ hosts={cardProps.hosts}
+ onOpenTab={cardProps.onOpenTab}
+ />
+ )}
+ {slot.id === "recent_activity" && (
+ <RecentActivityCard
+ activity={activity}
+ hosts={cardProps.hosts}
+ onOpenTab={cardProps.onOpenTab}
+ onClear={onClearActivity}
+ />
+ )}
+ {slot.id === "network_graph" && (
+ <NetworkGraphCard hosts={cardProps.hosts} />
+ )}
+ </div>
+ {editMode && !isFlex && (
+ <div
+ onMouseDown={onResizeMouseDown}
+ className="absolute bottom-0 left-0 right-0 h-2 z-20 flex items-center justify-center cursor-row-resize group/resize"
+ title="Drag to resize"
+ >
+ <div className="w-12 h-0.5 bg-border group-hover/resize:bg-accent-brand/60 transition-colors rounded-full" />
+ </div>
+ )}
+ </div>
+ );
+}
+
+// ─── DropZone ─────────────────────────────────────────────────────────────────
+
+function DropZone({
+ panel,
+ order,
+ onDrop,
+ onDragOver,
+ active,
+}: {
+ panel: PanelId;
+ order: number;
+ onDrop: (panel: PanelId, order: number) => void;
+ onDragOver: (e: React.DragEvent) => void;
+ active: boolean;
+}) {
+ const [over, setOver] = useState(false);
+ if (!active) return null;
+ return (
+ <div
+ className={`shrink-0 transition-all duration-150 ${over ? "h-10 border-2 border-dashed border-accent-brand/60 bg-accent-brand/5" : "h-2"}`}
+ onDragOver={(e) => {
+ onDragOver(e);
+ setOver(true);
+ }}
+ onDragLeave={() => setOver(false)}
+ onDrop={() => {
+ setOver(false);
+ onDrop(panel, order);
+ }}
+ />
+ );
+}
+
+// ─── AddCardTray ──────────────────────────────────────────────────────────────
+
+function AddCardTray({
+ activeIds,
+ onAdd,
+}: {
+ activeIds: DashboardCardId[];
+ onAdd: (id: DashboardCardId) => void;
+}) {
+ const available = DASHBOARD_CARDS.filter((c) => !activeIds.includes(c.id));
+ if (available.length === 0) return null;
+ return (
+ <div className="flex items-center gap-2 px-1 py-2 flex-wrap shrink-0">
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold shrink-0">
+ Add:
+ </span>
+ {available.map((card) => (
+ <button
+ key={card.id}
+ onClick={() => onAdd(card.id)}
+ className="flex items-center gap-1.5 px-2.5 py-1 border border-dashed border-border text-xs text-muted-foreground hover:text-foreground hover:border-accent-brand/60 hover:bg-accent-brand/5 transition-colors"
+ >
+ <Plus className="size-3 text-accent-brand" />
+ {CARD_META[card.id].label}
+ </button>
+ ))}
+ </div>
+ );
+}
+
+// ─── PanelColumn ─────────────────────────────────────────────────────────────
+
+type PanelColumnProps = {
+ panel: PanelId;
+ slots: CardSlot[];
+ editMode: boolean;
+ dragState: DragState;
+ onDragStart: (slot: CardSlot) => void;
+ onDrop: (targetPanel: PanelId, targetOrder: number) => void;
+ onDragOver: (e: React.DragEvent) => void;
+ onRemove: (id: DashboardCardId) => void;
+ onAdd: (id: DashboardCardId, panel: PanelId) => void;
+ onHeightChange: (id: DashboardCardId, h: number) => void;
+ onOpenSingletonTab: (type: TabType, pendingEvent?: string) => void;
+ onOpenTab: (host: Host, type: TabType) => void;
+ hosts: Host[];
+ uptimeFormatted: string;
+ credentialCount: number;
+ activeTunnelCount: number;
+ activity: RecentActivityItem[];
+ onClearActivity: () => void;
+};
+
+function PanelColumn({
+ panel,
+ slots,
+ editMode,
+ dragState,
+ onDragStart,
+ onDrop,
+ onDragOver,
+ onRemove,
+ onAdd,
+ onHeightChange,
+ onOpenSingletonTab,
+ onOpenTab,
+ hosts,
+ uptimeFormatted,
+ credentialCount,
+ activeTunnelCount,
+ activity,
+ onClearActivity,
+}: PanelColumnProps) {
+ const sorted = [...slots].sort((a, b) => a.order - b.order);
+ const allIds = slots.map((s) => s.id);
+
+ return (
+ <div className="flex flex-col flex-1 min-h-0">
+ <DropZone
+ panel={panel}
+ order={-1}
+ onDrop={onDrop}
+ onDragOver={onDragOver}
+ active={!!dragState}
+ />
+ {sorted.map((slot, idx) => (
+ <div
+ key={slot.id}
+ className={`flex flex-col min-h-0 ${slot.height === null ? "flex-1" : "shrink-0"}`}
+ >
+ {idx > 0 && (
+ <div className={editMode ? "" : "h-4 shrink-0"}>
+ <DropZone
+ panel={panel}
+ order={slot.order - 0.5}
+ onDrop={onDrop}
+ onDragOver={onDragOver}
+ active={!!dragState}
+ />
+ </div>
+ )}
+ <CardItem
+ slot={slot}
+ editMode={editMode}
+ isDragging={dragState?.id === slot.id}
+ onDragStart={() => onDragStart(slot)}
+ onDrop={() => onDrop(slot.panel, slot.order)}
+ onDragOver={onDragOver}
+ onRemove={() => onRemove(slot.id)}
+ onHeightChange={onHeightChange}
+ onOpenSingletonTab={onOpenSingletonTab}
+ onOpenTab={onOpenTab}
+ hosts={hosts}
+ uptimeFormatted={uptimeFormatted}
+ credentialCount={credentialCount}
+ activeTunnelCount={activeTunnelCount}
+ activity={activity}
+ onClearActivity={onClearActivity}
+ />
+ </div>
+ ))}
+ <DropZone
+ panel={panel}
+ order={sorted.length}
+ onDrop={onDrop}
+ onDragOver={onDragOver}
+ active={!!dragState}
+ />
+ {editMode && (
+ <AddCardTray activeIds={allIds} onAdd={(id) => onAdd(id, panel)} />
+ )}
+ {sorted.length === 0 && !editMode && (
+ <div className="flex-1 flex items-center justify-center text-muted-foreground/20 text-xs border border-dashed border-border/30">
+ Empty
+ </div>
+ )}
+ </div>
+ );
+}
+
+function ColumnDivider({
+ onMouseDown,
+}: {
+ onMouseDown: (e: React.MouseEvent) => void;
+}) {
+ return (
+ <div
+ onMouseDown={onMouseDown}
+ className="w-3 shrink-0 flex items-center justify-center cursor-col-resize group/divider self-stretch z-10"
+ title="Drag to resize columns"
+ >
+ <div className="w-px h-full bg-border group-hover/divider:bg-accent-brand/50 transition-colors" />
+ <div className="absolute size-4 flex items-center justify-center opacity-0 group-hover/divider:opacity-100 transition-opacity">
+ <GripHorizontal className="size-3 text-accent-brand" />
+ </div>
+ </div>
+ );
+}
+
+// ─── DashboardTab ─────────────────────────────────────────────────────────────
+
+export function DashboardTab({
+ onOpenSingletonTab,
+ onOpenTab,
+}: {
+ onOpenSingletonTab: (type: TabType, pendingEvent?: string) => void;
+ onOpenTab: (host: Host, type: TabType) => void;
+}) {
+ const [slots, setSlots] = useState<CardSlot[]>(DEFAULT_SLOTS);
+ const [editMode, setEditMode] = useState(false);
+ const [dragState, setDragState] = useState<DragState>(null);
+ const [mainWidthPct, setMainWidthPct] = useState(68);
+
+ const [hosts, setHosts] = useState<Host[]>([]);
+ const [uptimeFormatted, setUptimeFormatted] = useState("");
+ const [credentialCount, setCredentialCount] = useState(0);
+ const [activeTunnelCount, setActiveTunnelCount] = useState(0);
+ const [activity, setActivity] = useState<RecentActivityItem[]>([]);
+
+ useEffect(() => {
+ getSSHHosts()
+ .then((raw) => setHosts(raw.map(sshHostToHost)))
+ .catch(() => {});
+ getUptime()
+ .then((u) => setUptimeFormatted(u.formatted))
+ .catch(() => {});
+ getRecentActivity(50)
+ .then(setActivity)
+ .catch(() => {});
+ getCredentials()
+ .then((res: any) =>
+ setCredentialCount(
+ Array.isArray(res?.credentials) ? res.credentials.length : 0,
+ ),
+ )
+ .catch(() => {});
+ getTunnelStatuses()
+ .then((statuses) => {
+ const active = Object.values(statuses ?? {}).filter(
+ (s: any) => s?.status === "CONNECTED",
+ ).length;
+ setActiveTunnelCount(active);
+ })
+ .catch(() => {});
+ }, []);
+
+ const handleClearActivity = async () => {
+ try {
+ await resetRecentActivity();
+ setActivity([]);
+ } catch {
+ /* ignore */
+ }
+ };
+
+ const todayLabel = new Date().toLocaleDateString("en-US", {
+ weekday: "long",
+ month: "long",
+ day: "numeric",
+ year: "numeric",
+ });
+ const bodyRef = useRef<HTMLDivElement | null>(null);
+
+ const mainSlots = slots
+ .filter((s) => s.panel === "main")
+ .sort((a, b) => a.order - b.order);
+ const sideSlots = slots
+ .filter((s) => s.panel === "side")
+ .sort((a, b) => a.order - b.order);
+ const hasSide = sideSlots.length > 0;
+
+ const onColumnDividerMouseDown = useCallback(
+ (e: React.MouseEvent) => {
+ e.preventDefault();
+ const startX = e.clientX;
+ const startPct = mainWidthPct;
+ const onMove = (ev: MouseEvent) => {
+ if (!bodyRef.current) return;
+ const totalW = bodyRef.current.getBoundingClientRect().width;
+ setMainWidthPct(
+ Math.min(
+ 85,
+ Math.max(25, startPct + ((ev.clientX - startX) / totalW) * 100),
+ ),
+ );
+ };
+ const onUp = () => {
+ window.removeEventListener("mousemove", onMove);
+ window.removeEventListener("mouseup", onUp);
+ };
+ window.addEventListener("mousemove", onMove);
+ window.addEventListener("mouseup", onUp);
+ },
+ [mainWidthPct],
+ );
+
+ const handleDragStart = (slot: CardSlot) =>
+ setDragState({
+ id: slot.id,
+ sourcePanel: slot.panel,
+ sourceOrder: slot.order,
+ });
+ const handleDragOver = (e: React.DragEvent) => e.preventDefault();
+ const handleDrop = (targetPanel: PanelId, targetOrder: number) => {
+ if (!dragState) return;
+ setSlots((prev) => {
+ const without = prev.filter((s) => s.id !== dragState.id);
+ const panelSlots = without
+ .filter((s) => s.panel === targetPanel)
+ .sort((a, b) => a.order - b.order);
+ const others = without.filter((s) => s.panel !== targetPanel);
+ const insertIdx = panelSlots.findIndex((s) => s.order > targetOrder);
+ const insertAt = insertIdx === -1 ? panelSlots.length : insertIdx;
+ const newPanelSlots = [
+ ...panelSlots.slice(0, insertAt),
+ {
+ id: dragState.id,
+ panel: targetPanel,
+ order: 0,
+ height: prev.find((s) => s.id === dragState.id)?.height ?? null,
+ },
+ ...panelSlots.slice(insertAt),
+ ].map((s, i) => ({ ...s, order: i }));
+ return [...others, ...newPanelSlots];
+ });
+ setDragState(null);
+ };
+ const handleRemove = (id: DashboardCardId) =>
+ setSlots((prev) => prev.filter((s) => s.id !== id));
+ const handleAdd = (id: DashboardCardId, panel: PanelId) => {
+ setSlots((prev) => {
+ const panelSlots = prev.filter((s) => s.panel === panel);
+ const maxOrder =
+ panelSlots.length > 0
+ ? Math.max(...panelSlots.map((s) => s.order)) + 1
+ : 0;
+ const defaultHeight: number | null =
+ id === "host_status" ||
+ id === "recent_activity" ||
+ id === "network_graph"
+ ? null
+ : 150;
+ return [...prev, { id, panel, order: maxOrder, height: defaultHeight }];
+ });
+ };
+ const handleHeightChange = (id: DashboardCardId, h: number) =>
+ setSlots((prev) =>
+ prev.map((s) => (s.id === id ? { ...s, height: h } : s)),
+ );
+ const handleReset = () => {
+ setSlots(DEFAULT_SLOTS);
+ setMainWidthPct(72);
+ setEditMode(false);
+ };
+
+ const columnProps = {
+ hosts,
+ uptimeFormatted,
+ credentialCount,
+ activeTunnelCount,
+ activity,
+ onClearActivity: handleClearActivity,
+ onOpenSingletonTab,
+ onOpenTab,
+ };
+
+ const isMobile = useIsMobile();
+
+ if (isMobile) {
+ const allSlots = [...mainSlots, ...sideSlots];
+ return (
+ <div className="flex flex-col w-full h-full min-h-0 overflow-hidden">
+ <div className="flex-1 min-h-0 overflow-y-auto px-3 pb-3 pt-3 flex flex-col gap-3">
+ <Card className="flex-row items-center justify-between px-4 py-3 shrink-0 gap-0">
+ <div>
+ <h1 className="text-base font-bold leading-tight">Dashboard</h1>
+ <p className="text-xs text-muted-foreground">{todayLabel}</p>
+ </div>
+ <div className="flex items-center gap-1">
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-xs text-muted-foreground hover:text-foreground"
+ asChild
+ >
+ <a
+ href="https://github.com/Termix-SSH/Termix"
+ target="_blank"
+ rel="noreferrer"
+ >
+ GitHub
+ </a>
+ </Button>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-xs text-muted-foreground hover:text-foreground"
+ asChild
+ >
+ <a
+ href="https://github.com/Termix-SSH/Support"
+ target="_blank"
+ rel="noreferrer"
+ >
+ Support
+ </a>
+ </Button>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-xs text-muted-foreground hover:text-foreground"
+ asChild
+ >
+ <a
+ href="https://discord.com/invite/jVQGdvHDrf"
+ target="_blank"
+ rel="noreferrer"
+ >
+ Discord
+ </a>
+ </Button>
+ </div>
+ </Card>
+ {allSlots.map((slot) => (
+ <div
+ key={slot.id}
+ className={`shrink-0 ${slot.id === "host_status" || slot.id === "recent_activity" ? "max-h-72 flex flex-col overflow-hidden" : ""}`}
+ >
+ {slot.id === "stats_bar" && (
+ <StatsBarCard hosts={hosts} uptimeFormatted={uptimeFormatted} />
+ )}
+ {slot.id === "counters_bar" && (
+ <CountersBarCard
+ hosts={hosts}
+ credentialCount={credentialCount}
+ activeTunnelCount={activeTunnelCount}
+ />
+ )}
+ {slot.id === "quick_actions" && (
+ <QuickActionsCard onOpenSingletonTab={onOpenSingletonTab} />
+ )}
+ {slot.id === "host_status" && (
+ <HostStatusCard hosts={hosts} onOpenTab={onOpenTab} />
+ )}
+ {slot.id === "recent_activity" && (
+ <RecentActivityCard
+ activity={activity}
+ hosts={hosts}
+ onOpenTab={onOpenTab}
+ onClear={handleClearActivity}
+ />
+ )}
+ {slot.id === "network_graph" && (
+ <NetworkGraphCard hosts={hosts} />
+ )}
+ </div>
+ ))}
+ </div>
+ </div>
+ );
+ }
+
+ return (
+ <div className="flex flex-col w-full h-full min-h-0 overflow-hidden">
+ <Card className="flex-row items-center justify-between px-5 py-3 shrink-0 mx-5 mt-5 gap-0">
+ <div>
+ <h1 className="text-lg font-bold leading-tight">Dashboard</h1>
+ <p className="text-xs text-muted-foreground">{todayLabel}</p>
+ </div>
+ <div className="flex items-center gap-1">
+ <div className="hidden sm:flex items-center gap-2 mr-2 bg-muted/50 px-2.5 py-1 rounded-sm border border-border">
+ <span className="text-[10px] font-bold text-muted-foreground uppercase tracking-widest">
+ Command Palette
+ </span>
+ <div className="flex items-center gap-1">
+ <Kbd className="h-5 px-1.5 bg-background text-[10px]">Shift</Kbd>
+ <span className="text-[10px] text-muted-foreground">+</span>
+ <Kbd className="h-5 px-1.5 bg-background text-[10px]">Shift</Kbd>
+ </div>
+ </div>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-xs text-muted-foreground hover:text-foreground"
+ asChild
+ >
+ <a
+ href="https://github.com/Termix-SSH/Termix"
+ target="_blank"
+ rel="noreferrer"
+ >
+ GitHub
+ </a>
+ </Button>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-xs text-muted-foreground hover:text-foreground"
+ asChild
+ >
+ <a
+ href="https://github.com/Termix-SSH/Support"
+ target="_blank"
+ rel="noreferrer"
+ >
+ Support
+ </a>
+ </Button>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-xs text-muted-foreground hover:text-foreground"
+ asChild
+ >
+ <a
+ href="https://discord.com/invite/jVQGdvHDrf"
+ target="_blank"
+ rel="noreferrer"
+ >
+ Discord
+ </a>
+ </Button>
+ <Separator orientation="vertical" className="mx-1 h-5" />
+ {editMode ? (
+ <>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-xs text-muted-foreground"
+ onClick={handleReset}
+ >
+ Reset
+ </Button>
+ <Button
+ size="sm"
+ className="text-xs bg-accent-brand hover:bg-accent-brand/90 text-white"
+ onClick={() => setEditMode(false)}
+ >
+ Done
+ </Button>
+ </>
+ ) : (
+ <Button
+ variant="ghost"
+ size="icon"
+ onClick={() => setEditMode(true)}
+ title="Customize Dashboard"
+ >
+ <LayoutDashboard className="size-4 text-accent-brand" />
+ </Button>
+ )}
+ </div>
+ </Card>
+
+ {editMode && (
+ <div className="mx-5 mt-4 px-4 py-2 border border-dashed border-accent-brand/40 bg-accent-brand/5 shrink-0 flex items-center gap-2">
+ <LayoutDashboard className="size-3.5 text-accent-brand shrink-0" />
+ <span className="text-xs text-accent-brand font-semibold">
+ Drag cards to reorder · Drag the column divider to resize columns ·
+ Drag the bottom edge of a card to resize its height · Trash to
+ remove
+ </span>
+ </div>
+ )}
+
+ <div
+ ref={bodyRef}
+ className="flex flex-row flex-1 min-h-0 px-5 pb-5 pt-4 overflow-hidden"
+ >
+ <div
+ className="flex flex-col min-h-0"
+ style={{ width: hasSide || editMode ? `${mainWidthPct}%` : "100%" }}
+ >
+ <PanelColumn
+ panel="main"
+ slots={mainSlots}
+ editMode={editMode}
+ dragState={dragState}
+ onDragStart={handleDragStart}
+ onDrop={handleDrop}
+ onDragOver={handleDragOver}
+ onRemove={handleRemove}
+ onAdd={handleAdd}
+ onHeightChange={handleHeightChange}
+ {...columnProps}
+ />
+ </div>
+
+ {(hasSide || editMode) &&
+ (editMode ? (
+ <ColumnDivider onMouseDown={onColumnDividerMouseDown} />
+ ) : (
+ <div className="w-4 shrink-0" />
+ ))}
+
+ {(hasSide || editMode) && (
+ <div className="flex flex-col min-h-0 flex-1">
+ <PanelColumn
+ panel="side"
+ slots={sideSlots}
+ editMode={editMode}
+ dragState={dragState}
+ onDragStart={handleDragStart}
+ onDrop={handleDrop}
+ onDragOver={handleDragOver}
+ onRemove={handleRemove}
+ onAdd={handleAdd}
+ onHeightChange={handleHeightChange}
+ {...columnProps}
+ />
+ </div>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/src/ui/desktop/apps/dashboard/cards/NetworkGraphCard.tsx b/src/ui/dashboard/cards/NetworkGraphCard.tsx
similarity index 99%
rename from src/ui/desktop/apps/dashboard/cards/NetworkGraphCard.tsx
rename to src/ui/dashboard/cards/NetworkGraphCard.tsx
index 54434392d..9c29c7f90 100644
--- a/src/ui/desktop/apps/dashboard/cards/NetworkGraphCard.tsx
+++ b/src/ui/dashboard/cards/NetworkGraphCard.tsx
@@ -15,24 +15,24 @@ import {
type SSHHostWithStatus,
type NetworkTopologyEdge,
type NetworkTopologyNode,
-} from "@/ui/main-axios";
-import { Button } from "@/components/ui/button";
-import { Badge } from "@/components/ui/badge";
+} from "@/main-axios";
+import { Button } from "@/components/button";
+import { Badge } from "@/components/badge";
import {
AlertDialog,
AlertDialogContent,
AlertDialogDescription,
AlertDialogAction,
-} from "@/components/ui/alert-dialog";
+} from "@/components/alert-dialog";
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogFooter,
-} from "@/components/ui/dialog";
-import { Input } from "@/components/ui/input";
-import { Label } from "@/components/ui/label";
+} from "@/components/dialog";
+import { Input } from "@/components/input";
+import { Label } from "@/components/label";
import {
Plus,
Trash2,
@@ -58,21 +58,17 @@ import {
ArrowDownUp,
} from "lucide-react";
import { useTranslation } from "react-i18next";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext";
+import { useTabs } from "@/shell/TabContext";
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
-} from "@/components/ui/command";
-import {
- Popover,
- PopoverContent,
- PopoverTrigger,
-} from "@/components/ui/popover";
+} from "@/components/command";
+import { Popover, PopoverContent, PopoverTrigger } from "@/components/popover";
import { cn } from "@/lib/utils";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader";
+import { SimpleLoader } from "@/lib/SimpleLoader";
const AVAILABLE_COLORS = [
{ value: "#ef4444", label: "Red" },
diff --git a/src/ui/desktop/apps/dashboard/cards/QuickActionsCard.tsx b/src/ui/dashboard/cards/QuickActionsCard.tsx
similarity index 99%
rename from src/ui/desktop/apps/dashboard/cards/QuickActionsCard.tsx
rename to src/ui/dashboard/cards/QuickActionsCard.tsx
index 1bc1bccf4..1d2ce32b2 100644
--- a/src/ui/desktop/apps/dashboard/cards/QuickActionsCard.tsx
+++ b/src/ui/dashboard/cards/QuickActionsCard.tsx
@@ -1,7 +1,7 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { FastForward, Server, Key, Settings, User } from "lucide-react";
-import { Button } from "@/components/ui/button";
+import { Button } from "@/components/button";
interface QuickActionsCardProps {
isAdmin: boolean;
diff --git a/src/ui/desktop/apps/dashboard/cards/RecentActivityCard.tsx b/src/ui/dashboard/cards/RecentActivityCard.tsx
similarity index 97%
rename from src/ui/desktop/apps/dashboard/cards/RecentActivityCard.tsx
rename to src/ui/dashboard/cards/RecentActivityCard.tsx
index d030be153..80304b5fe 100644
--- a/src/ui/desktop/apps/dashboard/cards/RecentActivityCard.tsx
+++ b/src/ui/dashboard/cards/RecentActivityCard.tsx
@@ -12,8 +12,8 @@ import {
Eye,
MessagesSquare,
} from "lucide-react";
-import { Button } from "@/components/ui/button";
-import { type RecentActivityItem } from "@/ui/main-axios";
+import { Button } from "@/components/button";
+import { type RecentActivityItem } from "@/main-axios";
interface RecentActivityCardProps {
activities: RecentActivityItem[];
diff --git a/src/ui/desktop/apps/dashboard/cards/ServerOverviewCard.tsx b/src/ui/dashboard/cards/ServerOverviewCard.tsx
similarity index 97%
rename from src/ui/desktop/apps/dashboard/cards/ServerOverviewCard.tsx
rename to src/ui/dashboard/cards/ServerOverviewCard.tsx
index 4821e3054..775cd3b56 100644
--- a/src/ui/desktop/apps/dashboard/cards/ServerOverviewCard.tsx
+++ b/src/ui/dashboard/cards/ServerOverviewCard.tsx
@@ -8,8 +8,8 @@ import {
Key,
ArrowDownUp,
} from "lucide-react";
-import { Button } from "@/components/ui/button";
-import { UpdateLog } from "@/ui/desktop/apps/dashboard/apps/UpdateLog";
+import { Button } from "@/components/button";
+import { UpdateLog } from "@/dashboard/panels/UpdateLog";
interface ServerOverviewCardProps {
loggedIn: boolean;
diff --git a/src/ui/desktop/apps/dashboard/cards/ServerStatsCard.tsx b/src/ui/dashboard/cards/ServerStatsCard.tsx
similarity index 98%
rename from src/ui/desktop/apps/dashboard/cards/ServerStatsCard.tsx
rename to src/ui/dashboard/cards/ServerStatsCard.tsx
index 6e74dc0d4..662da0a93 100644
--- a/src/ui/desktop/apps/dashboard/cards/ServerStatsCard.tsx
+++ b/src/ui/dashboard/cards/ServerStatsCard.tsx
@@ -1,7 +1,7 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { ChartLine, Loader2, Server } from "lucide-react";
-import { Button } from "@/components/ui/button";
+import { Button } from "@/components/button";
interface ServerStat {
id: number;
diff --git a/src/ui/desktop/apps/dashboard/components/DashboardSettingsDialog.tsx b/src/ui/dashboard/components/DashboardSettingsDialog.tsx
similarity index 72%
rename from src/ui/desktop/apps/dashboard/components/DashboardSettingsDialog.tsx
rename to src/ui/dashboard/components/DashboardSettingsDialog.tsx
index 84da22396..8e89f81bc 100644
--- a/src/ui/desktop/apps/dashboard/components/DashboardSettingsDialog.tsx
+++ b/src/ui/dashboard/components/DashboardSettingsDialog.tsx
@@ -6,12 +6,19 @@ import {
DialogFooter,
DialogHeader,
DialogTitle,
-} from "@/components/ui/dialog";
-import { Button } from "@/components/ui/button";
-import { Label } from "@/components/ui/label";
-import { Checkbox } from "@/components/ui/checkbox";
+} from "@/components/dialog";
+import { Button } from "@/components/button";
+import { Label } from "@/components/label";
+import { Checkbox } from "@/components/checkbox";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/select";
import { useTranslation } from "react-i18next";
-import type { DashboardLayout } from "@/ui/main-axios";
+import type { DashboardLayout } from "@/main-axios";
interface DashboardSettingsDialogProps {
open: boolean;
@@ -44,6 +51,15 @@ export function DashboardSettingsDialog({
}));
};
+ const handleCardPanel = (cardId: string, panel: "main" | "side") => {
+ setLayout((prev) => ({
+ ...prev,
+ cards: prev.cards.map((card) =>
+ card.id === cardId ? { ...card, panel } : card,
+ ),
+ }));
+ };
+
const handleSave = () => {
onSave(layout);
onOpenChange(false);
@@ -96,6 +112,24 @@ export function DashboardSettingsDialog({
>
{cardLabels[card.id] || card.id}
</Label>
+ <Select
+ value={card.panel ?? "main"}
+ onValueChange={(v) =>
+ handleCardPanel(card.id, v as "main" | "side")
+ }
+ >
+ <SelectTrigger className="w-24 h-7 text-xs border-edge">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="main">
+ {t("dashboard.panelMain")}
+ </SelectItem>
+ <SelectItem value="side">
+ {t("dashboard.panelSide")}
+ </SelectItem>
+ </SelectContent>
+ </Select>
</div>
))}
</div>
diff --git a/src/ui/desktop/apps/dashboard/hooks/useDashboardPreferences.ts b/src/ui/dashboard/hooks/useDashboardPreferences.ts
similarity index 61%
rename from src/ui/desktop/apps/dashboard/hooks/useDashboardPreferences.ts
rename to src/ui/dashboard/hooks/useDashboardPreferences.ts
index f77578bfc..3b262d78f 100644
--- a/src/ui/desktop/apps/dashboard/hooks/useDashboardPreferences.ts
+++ b/src/ui/dashboard/hooks/useDashboardPreferences.ts
@@ -3,16 +3,17 @@ import {
getDashboardPreferences,
saveDashboardPreferences,
type DashboardLayout,
-} from "@/ui/main-axios";
+} from "@/main-axios";
const DEFAULT_LAYOUT: DashboardLayout = {
cards: [
- { id: "server_overview", enabled: true, order: 1 },
- { id: "recent_activity", enabled: true, order: 2 },
- { id: "network_graph", enabled: false, order: 3 },
- { id: "quick_actions", enabled: true, order: 4 },
- { id: "server_stats", enabled: true, order: 5 },
+ { id: "server_overview", enabled: true, order: 1, panel: "main" },
+ { id: "quick_actions", enabled: true, order: 2, panel: "main" },
+ { id: "server_stats", enabled: true, order: 3, panel: "main" },
+ { id: "network_graph", enabled: false, order: 4, panel: "main" },
+ { id: "recent_activity", enabled: true, order: 1, panel: "side" },
],
+ mainWidthPct: 68,
};
export function useDashboardPreferences(enabled: boolean = true) {
@@ -31,7 +32,25 @@ export function useDashboardPreferences(enabled: boolean = true) {
try {
const preferences = await getDashboardPreferences();
if (preferences?.cards && Array.isArray(preferences.cards)) {
- setLayout(preferences);
+ // Migrate old layouts that don't have panel assignments
+ const needsMigration = preferences.cards.some((c) => !c.panel);
+ if (needsMigration) {
+ const defaultCardMap = new Map(
+ DEFAULT_LAYOUT.cards.map((c) => [c.id, c]),
+ );
+ const migrated: DashboardLayout = {
+ ...preferences,
+ mainWidthPct:
+ preferences.mainWidthPct ?? DEFAULT_LAYOUT.mainWidthPct,
+ cards: preferences.cards.map((c) => ({
+ ...c,
+ panel: c.panel ?? defaultCardMap.get(c.id)?.panel ?? "main",
+ })),
+ };
+ setLayout(migrated);
+ } else {
+ setLayout(preferences);
+ }
} else {
setLayout(DEFAULT_LAYOUT);
}
diff --git a/src/ui/desktop/apps/dashboard/apps/UpdateLog.tsx b/src/ui/dashboard/panels/UpdateLog.tsx
similarity index 97%
rename from src/ui/desktop/apps/dashboard/apps/UpdateLog.tsx
rename to src/ui/dashboard/panels/UpdateLog.tsx
index ff54d5023..9531449f0 100644
--- a/src/ui/desktop/apps/dashboard/apps/UpdateLog.tsx
+++ b/src/ui/dashboard/panels/UpdateLog.tsx
@@ -1,8 +1,8 @@
import React, { useEffect, useState } from "react";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Sheet, SheetContent } from "@/components/ui/sheet.tsx";
-import { getReleasesRSS, getVersionInfo } from "@/ui/main-axios.ts";
+import { Alert, AlertDescription, AlertTitle } from "@/components/alert.tsx";
+import { Button } from "@/components/button.tsx";
+import { Sheet, SheetContent } from "@/components/sheet.tsx";
+import { getReleasesRSS, getVersionInfo } from "@/main-axios.ts";
import { useTranslation } from "react-i18next";
import { X } from "lucide-react";
diff --git a/src/ui/desktop/apps/dashboard/apps/alerts/AlertCard.tsx b/src/ui/dashboard/panels/alerts/AlertCard.tsx
similarity index 94%
rename from src/ui/desktop/apps/dashboard/apps/alerts/AlertCard.tsx
rename to src/ui/dashboard/panels/alerts/AlertCard.tsx
index eaaa30537..31faf754f 100644
--- a/src/ui/desktop/apps/dashboard/apps/alerts/AlertCard.tsx
+++ b/src/ui/dashboard/panels/alerts/AlertCard.tsx
@@ -5,9 +5,9 @@ import {
CardFooter,
CardHeader,
CardTitle,
-} from "@/components/ui/card.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Badge } from "@/components/ui/badge.tsx";
+} from "@/components/card.tsx";
+import { Button } from "@/components/button.tsx";
+import { Badge } from "@/components/badge.tsx";
import {
X,
ExternalLink,
@@ -17,7 +17,7 @@ import {
AlertCircle,
} from "lucide-react";
import { useTranslation } from "react-i18next";
-import type { TermixAlert } from "../../../../../../types";
+import type { TermixAlert } from "@/types";
interface AlertCardProps {
alert: TermixAlert;
diff --git a/src/ui/desktop/apps/dashboard/apps/alerts/AlertManager.tsx b/src/ui/dashboard/panels/alerts/AlertManager.tsx
similarity index 96%
rename from src/ui/desktop/apps/dashboard/apps/alerts/AlertManager.tsx
rename to src/ui/dashboard/panels/alerts/AlertManager.tsx
index 52b06104c..0d15c18ce 100644
--- a/src/ui/desktop/apps/dashboard/apps/alerts/AlertManager.tsx
+++ b/src/ui/dashboard/panels/alerts/AlertManager.tsx
@@ -1,9 +1,9 @@
import React, { useEffect, useState } from "react";
import { AlertCard } from "./AlertCard.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { getUserAlerts, dismissAlert } from "@/ui/main-axios.ts";
+import { Button } from "@/components/button.tsx";
+import { getUserAlerts, dismissAlert } from "@/main-axios.ts";
import { useTranslation } from "react-i18next";
-import type { TermixAlert } from "../../../../../../types";
+import type { TermixAlert } from "@/types";
import { toast } from "sonner";
interface AlertManagerProps {
diff --git a/src/ui/desktop/DesktopApp.tsx b/src/ui/desktop/DesktopApp.tsx
deleted file mode 100644
index 9ab6bca66..000000000
--- a/src/ui/desktop/DesktopApp.tsx
+++ /dev/null
@@ -1,810 +0,0 @@
-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;
diff --git a/src/ui/desktop/apps/command-palette/CommandPalette.tsx b/src/ui/desktop/apps/command-palette/CommandPalette.tsx
deleted file mode 100644
index fc11253a7..000000000
--- a/src/ui/desktop/apps/command-palette/CommandPalette.tsx
+++ /dev/null
@@ -1,700 +0,0 @@
-import {
- Command,
- CommandInput,
- CommandItem,
- CommandList,
- CommandGroup,
- CommandSeparator,
-} from "@/components/ui/command.tsx";
-import React, { useEffect, useRef, useState } from "react";
-import { cn } from "@/lib/utils";
-import { Kbd, KbdKey, KbdSeparator } from "@/components/ui/kbd";
-import {
- Key,
- Server,
- Settings,
- User,
- Terminal,
- Monitor,
- Eye,
- MessagesSquare,
- FolderOpen,
- Pencil,
- EllipsisVertical,
- ArrowDownUp,
- Container,
-} from "lucide-react";
-import { useTranslation } from "react-i18next";
-import { BiMoney, BiSupport } from "react-icons/bi";
-import { BsDiscord } from "react-icons/bs";
-import { FaGithub } from "react-icons/fa";
-import { GrUpdate } from "react-icons/gr";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
-import {
- getRecentActivity,
- getSSHHosts,
- getGuacamoleDpi,
- getGuacamoleTokenFromHost,
- logActivity,
-} from "@/ui/main-axios.ts";
-import type { RecentActivityItem } from "@/ui/main-axios.ts";
-import { DEFAULT_STATS_CONFIG } from "@/types/stats-widgets";
-import {
- DropdownMenu,
- DropdownMenuTrigger,
- DropdownMenuContent,
- DropdownMenuItem,
-} from "@/components/ui/dropdown-menu";
-import { Button } from "@/components/ui/button.tsx";
-import { ButtonGroup } from "@/components/ui/button-group.tsx";
-
-interface SSHHost {
- id: number;
- name: string;
- ip: string;
- port: number;
- username: string;
- folder: string;
- tags: string[];
- pin: boolean;
- authType: string;
- password?: string;
- key?: string;
- keyPassword?: string;
- keyType?: string;
- enableTerminal: boolean;
- enableTunnel: boolean;
- enableFileManager: boolean;
- enableDocker: boolean;
- defaultPath: string;
- tunnelConnections: unknown[];
- statsConfig?: string;
- createdAt: string;
- updatedAt: string;
- connectionType?: "ssh" | "rdp" | "vnc" | "telnet";
- domain?: string;
- security?: string;
- ignoreCert?: boolean;
- guacamoleConfig?: unknown;
- showTerminalInSidebar?: boolean;
- showFileManagerInSidebar?: boolean;
- showTunnelInSidebar?: boolean;
- showDockerInSidebar?: boolean;
- showServerStatsInSidebar?: boolean;
-}
-
-function shouldShowMetrics(host: SSHHost): boolean {
- try {
- const statsConfig = host.statsConfig
- ? JSON.parse(host.statsConfig)
- : DEFAULT_STATS_CONFIG;
- return statsConfig.metricsEnabled !== false;
- } catch {
- return true;
- }
-}
-
-function hasTunnelConnections(host: SSHHost): boolean {
- try {
- const tunnelConnections = Array.isArray(host.tunnelConnections)
- ? host.tunnelConnections
- : JSON.parse(host.tunnelConnections as string);
- return Array.isArray(tunnelConnections) && tunnelConnections.length > 0;
- } catch {
- return false;
- }
-}
-
-export function CommandPalette({
- isOpen,
- setIsOpen,
-}: {
- isOpen: boolean;
- setIsOpen: (isOpen: boolean) => void;
-}) {
- const { t } = useTranslation();
- const inputRef = useRef<HTMLInputElement>(null);
- const { addTab, setCurrentTab, tabs: tabList, updateTab } = useTabs();
- const [recentActivity, setRecentActivity] = useState<RecentActivityItem[]>(
- [],
- );
- const [hosts, setHosts] = useState<SSHHost[]>([]);
-
- useEffect(() => {
- if (isOpen) {
- inputRef.current?.focus();
- getRecentActivity(50).then((activity) => {
- setRecentActivity(activity.slice(0, 5));
- });
- getSSHHosts().then((allHosts) => {
- setHosts(allHosts);
- });
- }
- }, [isOpen]);
-
- const handleAddHost = () => {
- const sshManagerTab = tabList.find((t) => t.type === "ssh_manager");
- if (sshManagerTab) {
- updateTab(sshManagerTab.id, {
- initialTab: "add_host",
- hostConfig: undefined,
- });
- setCurrentTab(sshManagerTab.id);
- } else {
- const id = addTab({
- type: "ssh_manager",
- title: t("commandPalette.hostManager"),
- initialTab: "add_host",
- });
- setCurrentTab(id);
- }
- setIsOpen(false);
- };
-
- const handleAddCredential = () => {
- const sshManagerTab = tabList.find((t) => t.type === "ssh_manager");
- if (sshManagerTab) {
- updateTab(sshManagerTab.id, {
- initialTab: "add_credential",
- hostConfig: undefined,
- });
- setCurrentTab(sshManagerTab.id);
- } else {
- const id = addTab({
- type: "ssh_manager",
- title: t("commandPalette.hostManager"),
- initialTab: "add_credential",
- });
- setCurrentTab(id);
- }
- setIsOpen(false);
- };
-
- const handleOpenAdminSettings = () => {
- const adminTab = tabList.find((t) => t.type === "admin");
- if (adminTab) {
- setCurrentTab(adminTab.id);
- } else {
- const id = addTab({
- type: "admin",
- title: t("commandPalette.adminSettings"),
- });
- setCurrentTab(id);
- }
- setIsOpen(false);
- };
-
- const handleOpenUserProfile = () => {
- const userProfileTab = tabList.find((t) => t.type === "user_profile");
- if (userProfileTab) {
- setCurrentTab(userProfileTab.id);
- } else {
- const id = addTab({
- type: "user_profile",
- title: t("commandPalette.userProfile"),
- });
- setCurrentTab(id);
- }
- setIsOpen(false);
- };
-
- const handleOpenUpdateLog = () => {
- window.open("https://github.com/Termix-SSH/Termix/releases", "_blank");
- setIsOpen(false);
- };
-
- const handleGitHub = () => {
- window.open("https://github.com/Termix-SSH/Termix", "_blank");
- setIsOpen(false);
- };
-
- const handleSupport = () => {
- window.open("https://github.com/Termix-SSH/Support/issues/new", "_blank");
- setIsOpen(false);
- };
-
- const handleDiscord = () => {
- window.open("https://discord.com/invite/jVQGdvHDrf", "_blank");
- setIsOpen(false);
- };
-
- const handleDonate = () => {
- window.open("https://github.com/sponsors/LukeGus", "_blank");
- setIsOpen(false);
- };
-
- const handleActivityClick = (item: RecentActivityItem) => {
- getSSHHosts().then((hosts) => {
- const host = hosts.find((h: { id: number }) => h.id === item.hostId);
- if (!host) return;
-
- if (item.type === "terminal") {
- addTab({
- type: "terminal",
- title: item.hostName,
- hostConfig: host,
- });
- } else if (item.type === "file_manager") {
- addTab({
- type: "file_manager",
- title: item.hostName,
- hostConfig: host,
- });
- }
- });
- setIsOpen(false);
- };
-
- const handleHostTerminalClick = async (host: SSHHost) => {
- const title = host.name?.trim()
- ? host.name
- : `${host.username}@${host.ip}:${host.port}`;
-
- if (
- host.connectionType === "rdp" ||
- host.connectionType === "vnc" ||
- host.connectionType === "telnet"
- ) {
- try {
- const protocol = host.connectionType as "rdp" | "vnc" | "telnet";
- const result = await getGuacamoleTokenFromHost(host.id);
-
- addTab({
- type: protocol,
- title,
- hostConfig: host,
- connectionConfig: {
- token: result.token,
- protocol,
- type: protocol,
- hostname: host.ip,
- port: host.port,
- username: host.username,
- password: host.password,
- domain: host.domain,
- security: host.security,
- "ignore-cert": host.ignoreCert,
- dpi: getGuacamoleDpi(host),
- },
- });
-
- try {
- await logActivity(protocol, host.id, title);
- } catch (err) {
- console.warn(`Failed to log ${protocol} activity:`, err);
- }
- } catch (err) {
- console.error("Failed to get Guacamole token:", err);
- }
- setIsOpen(false);
- return;
- }
-
- addTab({ type: "terminal", title, hostConfig: host });
- setIsOpen(false);
- };
-
- const handleHostFileManagerClick = (host: SSHHost) => {
- const title = host.name?.trim()
- ? host.name
- : `${host.username}@${host.ip}:${host.port}`;
- addTab({ type: "file_manager", title, hostConfig: host });
- setIsOpen(false);
- };
-
- const handleHostServerDetailsClick = (host: SSHHost) => {
- const title = host.name?.trim()
- ? host.name
- : `${host.username}@${host.ip}:${host.port}`;
- addTab({ type: "server_stats", title, hostConfig: host });
- setIsOpen(false);
- };
-
- const handleHostTunnelClick = (host: SSHHost) => {
- const title = host.name?.trim()
- ? host.name
- : `${host.username}@${host.ip}:${host.port}`;
- addTab({ type: "tunnel", title, hostConfig: host });
- setIsOpen(false);
- };
-
- const handleHostDockerClick = (host: SSHHost) => {
- const title = host.name?.trim()
- ? host.name
- : `${host.username}@${host.ip}:${host.port}`;
- addTab({ type: "docker", title, hostConfig: host });
- setIsOpen(false);
- };
-
- const handleHostEditClick = (host: SSHHost) => {
- addTab({
- type: "ssh_manager",
- title: t("commandPalette.hostManager"),
- hostConfig: host,
- initialTab: "add_host",
- });
- setIsOpen(false);
- };
-
- return (
- <div
- className={cn(
- "fixed inset-0 z-50 flex items-center justify-center bg-black/30 transition-opacity duration-200",
- !isOpen && "opacity-0 pointer-events-none",
- )}
- onClick={() => setIsOpen(false)}
- >
- <Command
- className={cn(
- "w-3/4 max-w-2xl max-h-[60vh] rounded-lg border-2 border-edge shadow-md flex flex-col bg-elevated",
- "transition-all duration-200 ease-out",
- !isOpen && "scale-95 opacity-0",
- )}
- onClick={(e) => e.stopPropagation()}
- >
- <CommandInput
- ref={inputRef}
- placeholder={t("commandPalette.searchPlaceholder")}
- />
- <CommandList
- key={recentActivity.length}
- className="w-full h-auto flex-grow overflow-y-auto thin-scrollbar"
- style={{ maxHeight: "inherit" }}
- >
- {recentActivity.length > 0 && (
- <>
- <CommandGroup heading={t("commandPalette.recentActivity")}>
- {recentActivity.map((item, index) => (
- <CommandItem
- key={`recent-activity-${index}-${item.type}-${item.hostId}-${item.timestamp}`}
- value={`recent-activity-${index}-${item.hostName}-${item.type}`}
- onSelect={() => handleActivityClick(item)}
- >
- {item.type === "terminal" ? <Terminal /> : <FolderOpen />}
- <span>{item.hostName}</span>
- </CommandItem>
- ))}
- </CommandGroup>
- <CommandSeparator />
- </>
- )}
- <CommandGroup heading={t("commandPalette.navigation")}>
- <CommandItem onSelect={handleAddHost}>
- <Server />
- <span>{t("commandPalette.addHost")}</span>
- </CommandItem>
- <CommandItem onSelect={handleAddCredential}>
- <Key />
- <span>{t("commandPalette.addCredential")}</span>
- </CommandItem>
- <CommandItem onSelect={handleOpenAdminSettings}>
- <Settings />
- <span>{t("commandPalette.adminSettings")}</span>
- </CommandItem>
- <CommandItem onSelect={handleOpenUserProfile}>
- <User />
- <span>{t("commandPalette.userProfile")}</span>
- </CommandItem>
- <CommandItem onSelect={handleOpenUpdateLog}>
- <GrUpdate />
- <span>{t("commandPalette.updateLog")}</span>
- </CommandItem>
- </CommandGroup>
- <CommandSeparator />
- {hosts.length > 0 && (
- <>
- <CommandGroup heading={t("commandPalette.hosts")}>
- {hosts.map((host, index) => {
- const title = host.name?.trim()
- ? host.name
- : `${host.username}@${host.ip}:${host.port}`;
-
- const isSSH =
- !host.connectionType || host.connectionType === "ssh";
- const showMetrics = shouldShowMetrics(host);
- const hasTunnels = hasTunnelConnections(host);
-
- const visibleButtons = [
- host.enableTerminal && (host.showTerminalInSidebar ?? true),
- isSSH &&
- host.enableFileManager &&
- (host.showFileManagerInSidebar ?? false),
- isSSH &&
- host.enableTunnel &&
- hasTunnels &&
- (host.showTunnelInSidebar ?? false),
- isSSH &&
- host.enableDocker &&
- (host.showDockerInSidebar ?? false),
- isSSH &&
- showMetrics &&
- (host.showServerStatsInSidebar ?? false),
- ].filter(Boolean).length;
-
- return (
- <CommandItem
- key={`host-${index}-${host.id}`}
- value={`host-${index}-${title}-${host.id}`}
- onSelect={() => {
- if (host.enableTerminal) {
- handleHostTerminalClick(host);
- }
- }}
- className="flex items-center justify-between"
- >
- <div className="flex items-center gap-2 flex-1 min-w-0">
- <Server className="h-4 w-4 flex-shrink-0" />
- <span className="truncate">{title}</span>
- </div>
- <ButtonGroup
- className="flex-shrink-0"
- onClick={(e) => e.stopPropagation()}
- >
- {host.enableTerminal &&
- (host.showTerminalInSidebar ?? true) && (
- <Button
- variant="outline"
- className="!px-2 h-7 border-1 border-edge"
- onClick={(e) => {
- e.stopPropagation();
- handleHostTerminalClick(host);
- }}
- >
- {host.connectionType === "rdp" ? (
- <Monitor className="h-3 w-3" />
- ) : host.connectionType === "vnc" ? (
- <Eye className="h-3 w-3" />
- ) : host.connectionType === "telnet" ? (
- <MessagesSquare className="h-3 w-3" />
- ) : (
- <Terminal className="h-3 w-3" />
- )}
- </Button>
- )}
-
- {isSSH &&
- host.enableFileManager &&
- (host.showFileManagerInSidebar ?? false) && (
- <Button
- variant="outline"
- className="!px-2 h-7 border-1 border-edge"
- onClick={(e) => {
- e.stopPropagation();
- handleHostFileManagerClick(host);
- }}
- >
- <FolderOpen className="h-3 w-3" />
- </Button>
- )}
-
- {isSSH &&
- host.enableTunnel &&
- hasTunnels &&
- (host.showTunnelInSidebar ?? false) && (
- <Button
- variant="outline"
- className="!px-2 h-7 border-1 border-edge"
- onClick={(e) => {
- e.stopPropagation();
- handleHostTunnelClick(host);
- }}
- >
- <ArrowDownUp className="h-3 w-3" />
- </Button>
- )}
-
- {isSSH &&
- host.enableDocker &&
- (host.showDockerInSidebar ?? false) && (
- <Button
- variant="outline"
- className="!px-2 h-7 border-1 border-edge"
- onClick={(e) => {
- e.stopPropagation();
- handleHostDockerClick(host);
- }}
- >
- <Container className="h-3 w-3" />
- </Button>
- )}
-
- {isSSH &&
- showMetrics &&
- (host.showServerStatsInSidebar ?? false) && (
- <Button
- variant="outline"
- className="!px-2 h-7 border-1 border-edge"
- onClick={(e) => {
- e.stopPropagation();
- handleHostServerDetailsClick(host);
- }}
- >
- <Server className="h-3 w-3" />
- </Button>
- )}
-
- <DropdownMenu modal={false}>
- <DropdownMenuTrigger asChild>
- <Button
- variant="outline"
- className={cn(
- "!px-2 h-7 border-1 border-edge",
- visibleButtons > 0 &&
- "rounded-l-none border-l-0",
- )}
- onClick={(e) => e.stopPropagation()}
- >
- <EllipsisVertical className="h-3 w-3" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent
- align="end"
- side="right"
- className="w-56 bg-canvas border-edge text-foreground"
- >
- {host.enableTerminal &&
- !(host.showTerminalInSidebar ?? true) && (
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- handleHostTerminalClick(host);
- }}
- className="flex items-center gap-2 cursor-pointer px-3 py-2 hover:bg-hover text-foreground-secondary"
- >
- {host.connectionType === "rdp" ? (
- <Monitor className="h-4 w-4" />
- ) : host.connectionType === "vnc" ? (
- <Eye className="h-4 w-4" />
- ) : host.connectionType === "telnet" ? (
- <MessagesSquare className="h-4 w-4" />
- ) : (
- <Terminal className="h-4 w-4" />
- )}
- <span className="flex-1">
- {t("hosts.openTerminal")}
- </span>
- </DropdownMenuItem>
- )}
- {isSSH &&
- showMetrics &&
- !(host.showServerStatsInSidebar ?? false) && (
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- handleHostServerDetailsClick(host);
- }}
- className="flex items-center gap-2 cursor-pointer px-3 py-2 hover:bg-hover text-foreground-secondary"
- >
- <Server className="h-4 w-4" />
- <span className="flex-1">
- {t("hosts.openServerStats")}
- </span>
- </DropdownMenuItem>
- )}
- {isSSH &&
- host.enableFileManager &&
- !(host.showFileManagerInSidebar ?? false) && (
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- handleHostFileManagerClick(host);
- }}
- className="flex items-center gap-2 cursor-pointer px-3 py-2 hover:bg-hover text-foreground-secondary"
- >
- <FolderOpen className="h-4 w-4" />
- <span className="flex-1">
- {t("hosts.openFileManager")}
- </span>
- </DropdownMenuItem>
- )}
- {isSSH &&
- host.enableTunnel &&
- hasTunnels &&
- !(host.showTunnelInSidebar ?? false) && (
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- handleHostTunnelClick(host);
- }}
- className="flex items-center gap-2 cursor-pointer px-3 py-2 hover:bg-hover text-foreground-secondary"
- >
- <ArrowDownUp className="h-4 w-4" />
- <span className="flex-1">
- {t("hosts.openTunnels")}
- </span>
- </DropdownMenuItem>
- )}
- {isSSH &&
- host.enableDocker &&
- !(host.showDockerInSidebar ?? false) && (
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- handleHostDockerClick(host);
- }}
- className="flex items-center gap-2 cursor-pointer px-3 py-2 hover:bg-hover text-foreground-secondary"
- >
- <Container className="h-4 w-4" />
- <span className="flex-1">
- {t("hosts.openDocker")}
- </span>
- </DropdownMenuItem>
- )}
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- handleHostEditClick(host);
- }}
- className="flex items-center gap-2 cursor-pointer px-3 py-2 hover:bg-hover text-foreground-secondary"
- >
- <Pencil className="h-4 w-4" />
- <span className="flex-1">{t("common.edit")}</span>
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </ButtonGroup>
- </CommandItem>
- );
- })}
- </CommandGroup>
- <CommandSeparator />
- </>
- )}
- <CommandGroup heading={t("commandPalette.links")}>
- <CommandItem onSelect={handleGitHub}>
- <FaGithub />
- <span>{t("commandPalette.github")}</span>
- </CommandItem>
- <CommandItem onSelect={handleSupport}>
- <BiSupport />
- <span>{t("commandPalette.support")}</span>
- </CommandItem>
- <CommandItem onSelect={handleDiscord}>
- <BsDiscord />
- <span>{t("commandPalette.discord")}</span>
- </CommandItem>
- <CommandItem onSelect={handleDonate}>
- <BiMoney />
- <span>{t("commandPalette.donate")}</span>
- </CommandItem>
- </CommandGroup>
- </CommandList>
- <div className="border-t border-edge px-4 py-2 bg-hover/50 flex items-center justify-between text-xs text-muted-foreground">
- <div className="flex items-center gap-2">
- <span>{t("commandPalette.press")}</span>
- <Kbd>
- <KbdKey>Shift</KbdKey>
- <KbdSeparator />
- <KbdKey>Shift</KbdKey>
- </Kbd>
- <span>{t("commandPalette.toToggle")}</span>
- </div>
- <div className="flex items-center gap-2">
- <span>{t("commandPalette.close")}</span>
- <Kbd>Esc</Kbd>
- </div>
- </div>
- </Command>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/docker/components/ContainerCard.tsx b/src/ui/desktop/apps/features/docker/components/ContainerCard.tsx
deleted file mode 100644
index 49e3cb5d2..000000000
--- a/src/ui/desktop/apps/features/docker/components/ContainerCard.tsx
+++ /dev/null
@@ -1,432 +0,0 @@
-import React from "react";
-import {
- Card,
- CardContent,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Badge } from "@/components/ui/badge.tsx";
-import {
- Play,
- Square,
- RotateCw,
- Pause,
- Trash2,
- PlayCircle,
-} from "lucide-react";
-import { toast } from "sonner";
-import { useTranslation } from "react-i18next";
-import type { DockerContainer } from "@/types";
-import {
- startDockerContainer,
- stopDockerContainer,
- restartDockerContainer,
- pauseDockerContainer,
- unpauseDockerContainer,
- removeDockerContainer,
-} from "@/ui/main-axios.ts";
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "@/components/ui/tooltip.tsx";
-import { useConfirmation } from "@/hooks/use-confirmation.ts";
-
-interface ContainerCardProps {
- container: DockerContainer;
- sessionId: string;
- onSelect?: () => void;
- isSelected?: boolean;
- onRefresh?: () => void;
-}
-
-export function ContainerCard({
- container,
- sessionId,
- onSelect,
- isSelected = false,
- onRefresh,
-}: ContainerCardProps): React.ReactElement {
- const { t } = useTranslation();
- const { confirmWithToast } = useConfirmation();
- const [isStarting, setIsStarting] = React.useState(false);
- const [isStopping, setIsStopping] = React.useState(false);
- const [isRestarting, setIsRestarting] = React.useState(false);
- const [isPausing, setIsPausing] = React.useState(false);
- const [isRemoving, setIsRemoving] = React.useState(false);
-
- const statusColors = {
- running: {
- bg: "bg-green-500/10",
- border: "border-green-500/20",
- text: "text-green-400",
- badge: "bg-green-500/20 text-green-300 border-green-500/30",
- },
- exited: {
- bg: "bg-red-500/10",
- border: "border-red-500/20",
- text: "text-red-400",
- badge: "bg-red-500/20 text-red-300 border-red-500/30",
- },
- paused: {
- bg: "bg-yellow-500/10",
- border: "border-yellow-500/20",
- text: "text-yellow-400",
- badge: "bg-yellow-500/20 text-yellow-300 border-yellow-500/30",
- },
- created: {
- bg: "bg-blue-500/10",
- border: "border-blue-500/20",
- text: "text-blue-400",
- badge: "bg-blue-500/20 text-blue-300 border-blue-500/30",
- },
- restarting: {
- bg: "bg-orange-500/10",
- border: "border-orange-500/20",
- text: "text-orange-400",
- badge: "bg-orange-500/20 text-orange-300 border-orange-500/30",
- },
- removing: {
- bg: "bg-purple-500/10",
- border: "border-purple-500/20",
- text: "text-purple-400",
- badge: "bg-purple-500/20 text-purple-300 border-purple-500/30",
- },
- dead: {
- bg: "bg-muted/10",
- border: "border-muted/20",
- text: "text-muted-foreground",
- badge: "bg-muted/20 text-muted-foreground border-muted/30",
- },
- };
-
- const colors = statusColors[container.state] || statusColors.created;
-
- const handleStart = async (e: React.MouseEvent) => {
- e.stopPropagation();
- setIsStarting(true);
- try {
- await startDockerContainer(sessionId, container.id);
- toast.success(t("docker.containerStarted", { name: container.name }));
- onRefresh?.();
- } catch (error) {
- toast.error(
- t("docker.failedToStartContainer", {
- error: error instanceof Error ? error.message : "Unknown error",
- }),
- );
- } finally {
- setIsStarting(false);
- }
- };
-
- const handleStop = async (e: React.MouseEvent) => {
- e.stopPropagation();
- setIsStopping(true);
- try {
- await stopDockerContainer(sessionId, container.id);
- toast.success(t("docker.containerStopped", { name: container.name }));
- onRefresh?.();
- } catch (error) {
- toast.error(
- t("docker.failedToStopContainer", {
- error: error instanceof Error ? error.message : "Unknown error",
- }),
- );
- } finally {
- setIsStopping(false);
- }
- };
-
- const handleRestart = async (e: React.MouseEvent) => {
- e.stopPropagation();
- setIsRestarting(true);
- try {
- await restartDockerContainer(sessionId, container.id);
- toast.success(t("docker.containerRestarted", { name: container.name }));
- onRefresh?.();
- } catch (error) {
- toast.error(
- t("docker.failedToRestartContainer", {
- error: error instanceof Error ? error.message : "Unknown error",
- }),
- );
- } finally {
- setIsRestarting(false);
- }
- };
-
- const handlePause = async (e: React.MouseEvent) => {
- e.stopPropagation();
- setIsPausing(true);
- try {
- if (container.state === "paused") {
- await unpauseDockerContainer(sessionId, container.id);
- toast.success(t("docker.containerUnpaused", { name: container.name }));
- } else {
- await pauseDockerContainer(sessionId, container.id);
- toast.success(t("docker.containerPaused", { name: container.name }));
- }
- onRefresh?.();
- } catch (error) {
- toast.error(
- t("docker.failedToTogglePauseContainer", {
- action: container.state === "paused" ? "unpause" : "pause",
- error: error instanceof Error ? error.message : "Unknown error",
- }),
- );
- } finally {
- setIsPausing(false);
- }
- };
-
- const handleRemove = async (e: React.MouseEvent) => {
- e.stopPropagation();
- const containerName = container.name.startsWith("/")
- ? container.name.slice(1)
- : container.name;
-
- let confirmMessage = t("docker.confirmRemoveContainer", {
- name: containerName,
- });
-
- if (container.state === "running") {
- confirmMessage += " " + t("docker.runningContainerWarning");
- }
-
- confirmWithToast(
- confirmMessage,
- async () => {
- setIsRemoving(true);
- try {
- const force = container.state === "running";
- await removeDockerContainer(sessionId, container.id, force);
- toast.success(t("docker.containerRemoved", { name: containerName }));
- onRefresh?.();
- } catch (error) {
- toast.error(
- t("docker.failedToRemoveContainer", {
- error: error instanceof Error ? error.message : "Unknown error",
- }),
- );
- } finally {
- setIsRemoving(false);
- }
- },
- t("common.remove"),
- t("common.cancel"),
- );
- };
-
- const isLoading =
- isStarting || isStopping || isRestarting || isPausing || isRemoving;
-
- const formatCreatedDate = (dateStr: string): string => {
- try {
- const cleanDate = dateStr.replace(/\s*\+\d{4}\s*UTC\s*$/, "").trim();
- return cleanDate;
- } catch {
- return dateStr;
- }
- };
-
- const parsePorts = (portsStr: string | undefined): string[] => {
- if (!portsStr || portsStr.trim() === "") return [];
-
- return portsStr
- .split(",")
- .map((p) => p.trim())
- .filter((p) => p.length > 0);
- };
-
- const portsList = parsePorts(container.ports);
-
- return (
- <>
- <Card
- className={`cursor-pointer transition-all hover:shadow-lg overflow-hidden min-w-0 ${
- isSelected
- ? "ring-2 ring-primary border-primary"
- : `border-2 ${colors.border}`
- } ${colors.bg} pt-3 pb-0`}
- onClick={onSelect}
- >
- <CardHeader className="pb-2 px-4">
- <div className="flex items-start justify-between gap-2">
- <CardTitle className="text-base font-semibold truncate flex-1 min-w-0">
- {container.name.startsWith("/")
- ? container.name.slice(1)
- : container.name}
- </CardTitle>
- <Badge className={`${colors.badge} border shrink-0`}>
- {container.state}
- </Badge>
- </div>
- </CardHeader>
- <CardContent className="space-y-3 px-4 pb-3">
- <div className="space-y-2 text-sm">
- <div className="flex items-center gap-2 min-w-0">
- <span className="text-muted-foreground min-w-[50px] text-xs">
- {t("docker.image")}
- </span>
- <span className="flex-1 min-w-0 truncate text-foreground text-xs">
- {container.image}
- </span>
- </div>
- <div className="flex items-center gap-2 min-w-0">
- <span className="text-muted-foreground min-w-[50px] text-xs">
- {t("docker.idLabel")}
- </span>
- <span className="flex-1 min-w-0 truncate font-mono text-xs text-foreground">
- {container.id.substring(0, 12)}
- </span>
- </div>
- <div className="flex items-start gap-2 min-w-0">
- <span className="text-muted-foreground min-w-[50px] text-xs shrink-0">
- {t("docker.ports")}
- </span>
- <div className="flex flex-1 min-w-0 flex-wrap gap-1">
- {portsList.length > 0 ? (
- portsList.map((port, idx) => (
- <Badge
- key={idx}
- variant="outline"
- className="text-xs font-mono bg-muted/10 text-muted-foreground border-muted/30"
- >
- {port}
- </Badge>
- ))
- ) : (
- <Badge
- variant="outline"
- className="text-xs bg-muted/10 text-muted-foreground border-muted/30"
- >
- {t("docker.noPorts")}
- </Badge>
- )}
- </div>
- </div>
- <div className="flex items-center gap-2 min-w-0">
- <span className="text-muted-foreground min-w-[50px] text-xs">
- {t("docker.created")}
- </span>
- <span className="flex-1 min-w-0 truncate text-foreground text-xs">
- {formatCreatedDate(container.created)}
- </span>
- </div>
- </div>
-
- <div className="flex flex-wrap gap-2 pt-2 border-t border-edge-panel">
- <TooltipProvider>
- {container.state !== "running" && (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- className="h-8"
- onClick={handleStart}
- disabled={isLoading}
- >
- {isStarting ? (
- <div className="h-4 w-4 animate-spin rounded-full border-2 border-edge-hover border-t-transparent" />
- ) : (
- <Play className="h-4 w-4" />
- )}
- </Button>
- </TooltipTrigger>
- <TooltipContent>{t("docker.start")}</TooltipContent>
- </Tooltip>
- )}
-
- {container.state === "running" && (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- className="h-8"
- onClick={handleStop}
- disabled={isLoading}
- >
- {isStopping ? (
- <div className="h-4 w-4 animate-spin rounded-full border-2 border-edge-hover border-t-transparent" />
- ) : (
- <Square className="h-4 w-4" />
- )}
- </Button>
- </TooltipTrigger>
- <TooltipContent>{t("docker.stop")}</TooltipContent>
- </Tooltip>
- )}
-
- {(container.state === "running" ||
- container.state === "paused") && (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- className="h-8"
- onClick={handlePause}
- disabled={isLoading}
- >
- {isPausing ? (
- <div className="h-4 w-4 animate-spin rounded-full border-2 border-edge-hover border-t-transparent" />
- ) : container.state === "paused" ? (
- <PlayCircle className="h-4 w-4" />
- ) : (
- <Pause className="h-4 w-4" />
- )}
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- {container.state === "paused"
- ? t("docker.unpause")
- : t("docker.pause")}
- </TooltipContent>
- </Tooltip>
- )}
-
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- className="h-8"
- onClick={handleRestart}
- disabled={isLoading || container.state === "exited"}
- >
- {isRestarting ? (
- <div className="h-4 w-4 animate-spin rounded-full border-2 border-edge-hover border-t-transparent" />
- ) : (
- <RotateCw className="h-4 w-4" />
- )}
- </Button>
- </TooltipTrigger>
- <TooltipContent>{t("docker.restart")}</TooltipContent>{" "}
- </Tooltip>
-
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- className="h-8 text-red-400 hover:text-red-300 hover:bg-red-500/20"
- onClick={handleRemove}
- disabled={isLoading}
- >
- <Trash2 className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>{t("docker.remove")}</TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- </CardContent>
- </Card>
- </>
- );
-}
diff --git a/src/ui/desktop/apps/features/docker/components/ContainerDetail.tsx b/src/ui/desktop/apps/features/docker/components/ContainerDetail.tsx
deleted file mode 100644
index 101375fe5..000000000
--- a/src/ui/desktop/apps/features/docker/components/ContainerDetail.tsx
+++ /dev/null
@@ -1,123 +0,0 @@
-import React from "react";
-import { Button } from "@/components/ui/button.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
-import {
- Tabs,
- TabsContent,
- TabsList,
- TabsTrigger,
-} from "@/components/ui/tabs.tsx";
-import { ArrowLeft } from "lucide-react";
-import { useTranslation } from "react-i18next";
-import type { DockerContainer, SSHHost } from "@/types";
-import { LogViewer } from "./LogViewer.tsx";
-import { ContainerStats } from "./ContainerStats.tsx";
-import { ConsoleTerminal } from "./ConsoleTerminal.tsx";
-
-interface ContainerDetailProps {
- sessionId: string;
- containerId: string;
- containers: DockerContainer[];
- hostConfig: SSHHost;
- onBack: () => void;
-}
-
-export function ContainerDetail({
- sessionId,
- containerId,
- containers,
- hostConfig,
- onBack,
-}: ContainerDetailProps): React.ReactElement {
- const { t } = useTranslation();
- const [activeTab, setActiveTab] = React.useState("logs");
-
- const container = containers.find((c) => c.id === containerId);
-
- if (!container) {
- return (
- <div className="flex items-center justify-center h-full">
- <div className="text-center space-y-2">
- <p className="text-muted-foreground text-lg">
- {t("docker.containerNotFound")}
- </p>
- <Button onClick={onBack} variant="outline">
- <ArrowLeft className="h-4 w-4 mr-2" />
- {t("docker.backToList")}
- </Button>
- </div>
- </div>
- );
- }
-
- return (
- <div className="flex flex-col h-full">
- <div className="flex items-center gap-4 px-4 pt-3 pb-3">
- <Button variant="ghost" onClick={onBack} size="sm">
- <ArrowLeft className="h-4 w-4 mr-2" />
- {t("common.back")}
- </Button>
- <div className="min-w-0 flex-1">
- <h2 className="font-bold text-lg truncate">{container.name}</h2>
- <p className="text-sm text-muted-foreground truncate">
- {container.image}
- </p>
- </div>
- </div>
- <Separator className="p-0.25 w-full" />
-
- <div className="flex-1 overflow-hidden min-h-0">
- <Tabs
- value={activeTab}
- onValueChange={setActiveTab}
- className="h-full flex flex-col"
- >
- <div className="px-4 pt-2">
- <TabsList className="grid w-full grid-cols-3">
- <TabsTrigger value="logs">{t("docker.logs")}</TabsTrigger>
- <TabsTrigger value="stats">{t("docker.stats")}</TabsTrigger>
- <TabsTrigger value="console">
- {t("docker.consoleTab")}
- </TabsTrigger>
- </TabsList>
- </div>
-
- <TabsContent
- value="logs"
- className="flex-1 overflow-auto thin-scrollbar px-3 pb-3 mt-3"
- >
- <LogViewer
- sessionId={sessionId}
- containerId={containerId}
- containerName={container.name}
- />
- </TabsContent>
-
- <TabsContent
- value="stats"
- className="flex-1 overflow-auto thin-scrollbar px-3 pb-3 mt-3"
- >
- <ContainerStats
- sessionId={sessionId}
- containerId={containerId}
- containerName={container.name}
- containerState={container.state}
- />
- </TabsContent>
-
- <TabsContent
- value="console"
- className="flex-1 overflow-hidden px-3 pb-3 mt-3"
- >
- <ConsoleTerminal
- containerId={containerId}
- containerName={container.name}
- containerState={container.state}
- hostConfig={hostConfig}
- />
- </TabsContent>
- </Tabs>
- </div>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/docker/components/ContainerList.tsx b/src/ui/desktop/apps/features/docker/components/ContainerList.tsx
deleted file mode 100644
index 6c85e6e17..000000000
--- a/src/ui/desktop/apps/features/docker/components/ContainerList.tsx
+++ /dev/null
@@ -1,137 +0,0 @@
-import React from "react";
-import { Input } from "@/components/ui/input.tsx";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select.tsx";
-import { Search, Filter } from "lucide-react";
-import { useTranslation } from "react-i18next";
-import type { DockerContainer } from "@/types";
-import { ContainerCard } from "./ContainerCard.tsx";
-
-interface ContainerListProps {
- containers: DockerContainer[];
- sessionId: string;
- onSelectContainer: (containerId: string) => void;
- selectedContainerId?: string | null;
- onRefresh?: () => void;
-}
-
-export function ContainerList({
- containers,
- sessionId,
- onSelectContainer,
- selectedContainerId = null,
- onRefresh,
-}: ContainerListProps): React.ReactElement {
- const { t } = useTranslation();
- const [searchQuery, setSearchQuery] = React.useState("");
- const [statusFilter, setStatusFilter] = React.useState<string>("all");
-
- const filteredContainers = React.useMemo(() => {
- return containers.filter((container) => {
- const matchesSearch =
- container.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
- container.image.toLowerCase().includes(searchQuery.toLowerCase()) ||
- container.id.toLowerCase().includes(searchQuery.toLowerCase());
-
- const matchesStatus =
- statusFilter === "all" || container.state === statusFilter;
-
- return matchesSearch && matchesStatus;
- });
- }, [containers, searchQuery, statusFilter]);
-
- const statusCounts = React.useMemo(() => {
- const counts: Record<string, number> = {};
- containers.forEach((c) => {
- counts[c.state] = (counts[c.state] || 0) + 1;
- });
- return counts;
- }, [containers]);
-
- if (containers.length === 0) {
- return (
- <div className="flex items-center justify-center h-full min-h-0">
- <div className="text-center space-y-2">
- <p className="text-muted-foreground text-lg">
- {t("docker.noContainersFound")}
- </p>
- <p className="text-muted-foreground text-sm">
- {t("docker.noContainersFoundHint")}
- </p>
- </div>
- </div>
- );
- }
-
- return (
- <div className="flex flex-col h-full min-h-0">
- <div className="flex flex-col sm:flex-row gap-2">
- <div className="relative flex-1">
- <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
- <Input
- placeholder={t("docker.searchPlaceholder")}
- value={searchQuery}
- onChange={(e) => setSearchQuery(e.target.value)}
- className="pl-10"
- />
- </div>
- <div className="flex items-center gap-2 sm:min-w-[200px]">
- <Filter className="h-4 w-4 text-muted-foreground" />
- <Select value={statusFilter} onValueChange={setStatusFilter}>
- <SelectTrigger className="w-full">
- <SelectValue
- placeholder={t("docker.filterByStatusPlaceholder")}
- />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="all">
- {t("docker.allContainersCount", { count: containers.length })}
- </SelectItem>
- {Object.entries(statusCounts).map(([status, count]) => (
- <SelectItem key={status} value={status}>
- {t("docker.statusCount", {
- status: status.charAt(0).toUpperCase() + status.slice(1),
- count,
- })}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- </div>
- </div>
-
- {filteredContainers.length === 0 ? (
- <div className="flex items-center justify-center flex-1 min-h-0">
- <div className="text-center space-y-2">
- <p className="text-muted-foreground">
- {t("docker.noContainersMatchFilters")}
- </p>
- <p className="text-muted-foreground text-sm">
- {t("docker.noContainersMatchFiltersHint")}
- </p>
- </div>
- </div>
- ) : (
- <div className="min-h-0 flex-1 overflow-auto thin-scrollbar h-fade pr-1 pb-2 pt-4">
- <div className="grid grid-cols-[repeat(auto-fit,minmax(320px,1fr))] gap-3 auto-rows-min content-start w-full pb-2">
- {filteredContainers.map((container) => (
- <ContainerCard
- key={container.id}
- container={container}
- sessionId={sessionId}
- onSelect={() => onSelectContainer(container.id)}
- isSelected={selectedContainerId === container.id}
- onRefresh={onRefresh}
- />
- ))}
- </div>
- </div>
- )}
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/docker/components/ContainerStats.tsx b/src/ui/desktop/apps/features/docker/components/ContainerStats.tsx
deleted file mode 100644
index a57566ed6..000000000
--- a/src/ui/desktop/apps/features/docker/components/ContainerStats.tsx
+++ /dev/null
@@ -1,256 +0,0 @@
-import React from "react";
-import {
- Card,
- CardContent,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card.tsx";
-import { Progress } from "@/components/ui/progress.tsx";
-import { Cpu, MemoryStick, Network, HardDrive, Activity } from "lucide-react";
-import type { DockerStats } from "@/types";
-import { getContainerStats } from "@/ui/main-axios.ts";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
-import { useTranslation } from "react-i18next";
-
-interface ContainerStatsProps {
- sessionId: string;
- containerId: string;
- containerName: string;
- containerState: string;
-}
-
-export function ContainerStats({
- sessionId,
- containerId,
- containerName,
- containerState,
-}: ContainerStatsProps): React.ReactElement {
- const { t } = useTranslation();
- const [stats, setStats] = React.useState<DockerStats | null>(null);
- const [isLoading, setIsLoading] = React.useState(false);
- const [error, setError] = React.useState<string | null>(null);
-
- const fetchStats = React.useCallback(async () => {
- if (containerState !== "running") {
- setError(t("docker.containerMustBeRunningToViewStats"));
- return;
- }
-
- setIsLoading(true);
- setError(null);
- try {
- const data = await getContainerStats(sessionId, containerId);
- setStats(data);
- } catch (err) {
- setError(
- err instanceof Error ? err.message : t("docker.failedToFetchStats"),
- );
- } finally {
- setIsLoading(false);
- }
- }, [sessionId, containerId, containerState]);
-
- React.useEffect(() => {
- fetchStats();
-
- const interval = setInterval(fetchStats, 2000);
-
- return () => clearInterval(interval);
- }, [fetchStats]);
-
- if (containerState !== "running") {
- return (
- <div className="flex items-center justify-center h-full">
- <div className="text-center space-y-2">
- <Activity className="h-12 w-12 text-muted-foreground/50 mx-auto" />
- <p className="text-muted-foreground text-lg">
- {t("docker.containerNotRunning")}
- </p>
- <p className="text-muted-foreground text-sm">
- {t("docker.startContainerToViewStats")}
- </p>
- </div>
- </div>
- );
- }
-
- if (isLoading && !stats) {
- return (
- <div className="flex items-center justify-center h-full">
- <div className="text-center">
- <SimpleLoader size="lg" />
- <p className="text-muted-foreground mt-4">
- {t("docker.loadingStats")}
- </p>
- </div>
- </div>
- );
- }
-
- if (error) {
- return (
- <div className="flex items-center justify-center h-full">
- <div className="text-center space-y-2">
- <p className="text-red-400 text-lg">
- {t("docker.errorLoadingStats")}
- </p>
- <p className="text-muted-foreground text-sm">{error}</p>
- </div>
- </div>
- );
- }
-
- if (!stats) {
- return (
- <div className="flex items-center justify-center h-full">
- <p className="text-muted-foreground">{t("docker.noStatsAvailable")}</p>
- </div>
- );
- }
-
- const cpuPercent = parseFloat(stats.cpu) || 0;
- const memPercent = parseFloat(stats.memoryPercent) || 0;
-
- return (
- <div className="grid grid-cols-1 md:grid-cols-2 gap-3 h-full overflow-auto thin-scrollbar">
- <Card className="py-3">
- <CardHeader className="pb-2 px-4">
- <CardTitle className="text-base flex items-center gap-2">
- <Cpu className="h-5 w-5 text-blue-400" />
- {t("docker.cpuUsage")}
- </CardTitle>
- </CardHeader>
- <CardContent className="px-4 pb-3">
- <div className="space-y-2">
- <div className="flex justify-between items-center text-sm">
- <span className="text-muted-foreground">
- {t("docker.current")}
- </span>{" "}
- <span className="font-mono font-semibold text-blue-400">
- {stats.cpu}
- </span>
- </div>
- <Progress value={Math.min(cpuPercent, 100)} className="h-2" />
- </div>
- </CardContent>
- </Card>
-
- <Card className="py-3">
- <CardHeader className="pb-2 px-4">
- <CardTitle className="text-base flex items-center gap-2">
- <MemoryStick className="h-5 w-5 text-purple-400" />
- {t("docker.memoryUsage")}
- </CardTitle>
- </CardHeader>
- <CardContent className="px-4 pb-3">
- <div className="space-y-2">
- <div className="flex justify-between items-center text-sm">
- <span className="text-muted-foreground">
- {t("docker.usedLimit")}
- </span>
- <span className="font-mono font-semibold text-purple-400">
- {stats.memoryUsed} / {stats.memoryLimit}
- </span>
- </div>
- <div className="flex justify-between items-center text-sm">
- <span className="text-muted-foreground">
- {t("docker.percentage")}
- </span>
- <span className="font-mono text-purple-400">
- {stats.memoryPercent}
- </span>
- </div>
- <Progress value={Math.min(memPercent, 100)} className="h-2" />
- </div>
- </CardContent>
- </Card>
-
- <Card className="py-3">
- <CardHeader className="pb-2 px-4">
- <CardTitle className="text-base flex items-center gap-2">
- <Network className="h-5 w-5 text-green-400" />
- {t("docker.networkIo")}
- </CardTitle>
- </CardHeader>
- <CardContent className="px-4 pb-3">
- <div className="space-y-2">
- <div className="flex justify-between items-center text-sm">
- <span className="text-muted-foreground">{t("docker.input")}</span>
- <span className="font-mono text-green-400">{stats.netInput}</span>
- </div>
- <div className="flex justify-between items-center text-sm">
- <span className="text-muted-foreground">
- {t("docker.output")}
- </span>
- <span className="font-mono text-green-400">
- {stats.netOutput}
- </span>
- </div>
- </div>
- </CardContent>
- </Card>
-
- <Card className="py-3">
- <CardHeader className="pb-2 px-4">
- <CardTitle className="text-base flex items-center gap-2">
- <HardDrive className="h-5 w-5 text-orange-400" />
- {t("docker.blockIo")}
- </CardTitle>
- </CardHeader>
- <CardContent className="px-4 pb-3">
- <div className="space-y-2">
- <div className="flex justify-between items-center text-sm">
- <span className="text-muted-foreground">{t("docker.read")}</span>
- <span className="font-mono text-orange-400">
- {stats.blockRead}
- </span>
- </div>
- <div className="flex justify-between items-center text-sm">
- <span className="text-muted-foreground">{t("docker.write")}</span>
- <span className="font-mono text-orange-400">
- {stats.blockWrite}
- </span>
- </div>
- {stats.pids && (
- <div className="flex justify-between items-center text-sm">
- <span className="text-muted-foreground">
- {t("docker.pids")}
- </span>
- <span className="font-mono text-orange-400">{stats.pids}</span>
- </div>
- )}
- </div>
- </CardContent>
- </Card>
-
- <Card className="md:col-span-2 py-3">
- <CardHeader className="pb-2 px-4">
- <CardTitle className="text-base flex items-center gap-2">
- <Activity className="h-5 w-5 text-cyan-400" />
- {t("docker.containerInformation")}
- </CardTitle>
- </CardHeader>
- <CardContent className="px-4 pb-3">
- <div className="grid grid-cols-1 sm:grid-cols-3 gap-3 text-sm">
- <div className="flex justify-between items-center">
- <span className="text-muted-foreground">{t("docker.name")}</span>
- <span className="font-mono text-foreground">{containerName}</span>
- </div>
- <div className="flex justify-between items-center">
- <span className="text-muted-foreground">{t("docker.id")}</span>
- <span className="font-mono text-sm text-foreground">
- {containerId.substring(0, 12)}
- </span>
- </div>
- <div className="flex justify-between items-center">
- <span className="text-muted-foreground">{t("docker.state")}</span>
- <span className="font-semibold text-green-400 capitalize">
- {containerState}
- </span>
- </div>
- </div>
- </CardContent>
- </Card>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/docker/components/LogViewer.tsx b/src/ui/desktop/apps/features/docker/components/LogViewer.tsx
deleted file mode 100644
index 8d016c830..000000000
--- a/src/ui/desktop/apps/features/docker/components/LogViewer.tsx
+++ /dev/null
@@ -1,239 +0,0 @@
-import React from "react";
-import { Button } from "@/components/ui/button.tsx";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select.tsx";
-import { Card, CardContent } from "@/components/ui/card.tsx";
-import { Switch } from "@/components/ui/switch.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import { Download, RefreshCw, Filter } from "lucide-react";
-import { toast } from "sonner";
-import type { DockerLogOptions } from "@/types";
-import { getContainerLogs, downloadContainerLogs } from "@/ui/main-axios.ts";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
-
-interface LogViewerProps {
- sessionId: string;
- containerId: string;
- containerName: string;
-}
-
-export function LogViewer({
- sessionId,
- containerId,
- containerName,
-}: LogViewerProps): React.ReactElement {
- const [logs, setLogs] = React.useState<string>("");
- const [isLoading, setIsLoading] = React.useState(false);
- const [isDownloading, setIsDownloading] = React.useState(false);
- const [tailLines, setTailLines] = React.useState<string>("100");
- const [showTimestamps, setShowTimestamps] = React.useState(false);
- const [autoRefresh, setAutoRefresh] = React.useState(false);
- const [searchFilter, setSearchFilter] = React.useState("");
- const logsEndRef = React.useRef<HTMLDivElement>(null);
-
- const fetchLogs = React.useCallback(async () => {
- setIsLoading(true);
- try {
- const options: DockerLogOptions = {
- tail: tailLines === "all" ? undefined : parseInt(tailLines, 10),
- timestamps: showTimestamps,
- };
-
- const data = await getContainerLogs(sessionId, containerId, options);
- setLogs(data.logs);
- } catch (error) {
- toast.error(
- `Failed to fetch logs: ${error instanceof Error ? error.message : "Unknown error"}`,
- );
- } finally {
- setIsLoading(false);
- }
- }, [sessionId, containerId, tailLines, showTimestamps]);
-
- React.useEffect(() => {
- fetchLogs();
- }, [fetchLogs]);
-
- React.useEffect(() => {
- if (!autoRefresh) return;
-
- const interval = setInterval(() => {
- fetchLogs();
- }, 3000);
-
- return () => clearInterval(interval);
- }, [autoRefresh, fetchLogs]);
-
- React.useEffect(() => {
- if (autoRefresh && logsEndRef.current) {
- logsEndRef.current.scrollIntoView({ behavior: "smooth" });
- }
- }, [logs, autoRefresh]);
-
- const handleDownload = async () => {
- setIsDownloading(true);
- try {
- const options: DockerLogOptions = {
- timestamps: showTimestamps,
- };
-
- const blob = await downloadContainerLogs(sessionId, containerId, options);
- const url = window.URL.createObjectURL(blob);
- const a = document.createElement("a");
- a.href = url;
- a.download = `${containerName.replace(/[^a-z0-9]/gi, "_")}_logs.txt`;
- document.body.appendChild(a);
- a.click();
- window.URL.revokeObjectURL(url);
- document.body.removeChild(a);
-
- toast.success("Logs downloaded successfully");
- } catch (error) {
- toast.error(
- `Failed to download logs: ${error instanceof Error ? error.message : "Unknown error"}`,
- );
- } finally {
- setIsDownloading(false);
- }
- };
-
- const filteredLogs = React.useMemo(() => {
- if (!searchFilter.trim()) return logs;
-
- return logs
- .split("\n")
- .filter((line) => line.toLowerCase().includes(searchFilter.toLowerCase()))
- .join("\n");
- }, [logs, searchFilter]);
-
- return (
- <div className="flex flex-col h-full gap-3">
- <Card className="py-3">
- <CardContent className="px-3">
- <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3">
- <div className="flex flex-col">
- <Label htmlFor="tail-lines" className="mb-1">
- Lines to show
- </Label>
- <Select value={tailLines} onValueChange={setTailLines}>
- <SelectTrigger id="tail-lines">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="50">Last 50 lines</SelectItem>
- <SelectItem value="100">Last 100 lines</SelectItem>
- <SelectItem value="500">Last 500 lines</SelectItem>
- <SelectItem value="1000">Last 1000 lines</SelectItem>
- <SelectItem value="all">All logs</SelectItem>
- </SelectContent>
- </Select>
- </div>
-
- <div className="flex flex-col">
- <Label htmlFor="timestamps" className="mb-1">
- Show Timestamps
- </Label>
- <div className="flex items-center h-10 px-3 border rounded-md">
- <Switch
- id="timestamps"
- checked={showTimestamps}
- onCheckedChange={setShowTimestamps}
- />
- <span className="ml-2 text-sm">
- {showTimestamps ? "Enabled" : "Disabled"}
- </span>
- </div>
- </div>
-
- <div className="flex flex-col">
- <Label htmlFor="auto-refresh" className="mb-1">
- Auto Refresh
- </Label>
- <div className="flex items-center h-10 px-3 border rounded-md">
- <Switch
- id="auto-refresh"
- checked={autoRefresh}
- onCheckedChange={setAutoRefresh}
- />
- <span className="ml-2 text-sm">
- {autoRefresh ? "On" : "Off"}
- </span>
- </div>
- </div>
-
- <div className="flex flex-col">
- <Label className="mb-1">Actions</Label>
- <div className="flex gap-2 h-10">
- <Button
- size="sm"
- variant="outline"
- onClick={fetchLogs}
- disabled={isLoading}
- className="flex-1 h-full"
- >
- {isLoading ? (
- <div className="h-4 w-4 animate-spin rounded-full border-2 border-edge-hover border-t-transparent" />
- ) : (
- <RefreshCw className="h-4 w-4" />
- )}
- </Button>
- <Button
- size="sm"
- variant="outline"
- onClick={handleDownload}
- disabled={isDownloading}
- className="flex-1 h-full"
- >
- {isDownloading ? (
- <div className="h-4 w-4 animate-spin rounded-full border-2 border-edge-hover border-t-transparent" />
- ) : (
- <Download className="h-4 w-4" />
- )}
- </Button>
- </div>
- </div>
- </div>
-
- <div className="mt-2">
- <div className="relative">
- <Filter className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
- <input
- type="text"
- placeholder="Filter logs..."
- value={searchFilter}
- onChange={(e) => setSearchFilter(e.target.value)}
- className="w-full pl-10 pr-4 py-2 border border-input rounded-md text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-primary"
- />
- </div>
- </div>
- </CardContent>
- </Card>
-
- <Card className="flex-1 overflow-hidden py-0">
- <CardContent className="p-0 h-full">
- {isLoading && !logs ? (
- <div className="flex items-center justify-center h-full">
- <SimpleLoader size="lg" />
- </div>
- ) : (
- <div className="h-full overflow-auto thin-scrollbar">
- <pre className="p-4 text-xs font-mono whitespace-pre-wrap break-words text-foreground leading-relaxed">
- {filteredLogs || (
- <span className="text-muted-foreground">
- No logs available
- </span>
- )}
- <div ref={logsEndRef} />
- </pre>
- </div>
- )}
- </CardContent>
- </Card>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/file-manager/DragIndicator.tsx b/src/ui/desktop/apps/features/file-manager/DragIndicator.tsx
deleted file mode 100644
index 19c33e430..000000000
--- a/src/ui/desktop/apps/features/file-manager/DragIndicator.tsx
+++ /dev/null
@@ -1,143 +0,0 @@
-import React from "react";
-import { cn } from "@/lib/utils.ts";
-import { useTranslation } from "react-i18next";
-import {
- Download,
- FileDown,
- FolderDown,
- Loader2,
- CheckCircle,
- AlertCircle,
-} from "lucide-react";
-
-interface DragIndicatorProps {
- isVisible: boolean;
- isDragging: boolean;
- isDownloading: boolean;
- progress: number;
- fileName?: string;
- fileCount?: number;
- error?: string | null;
- className?: string;
-}
-
-export function DragIndicator({
- isVisible,
- isDragging,
- isDownloading,
- progress,
- fileName,
- fileCount = 1,
- error,
- className,
-}: DragIndicatorProps) {
- const { t } = useTranslation();
-
- if (!isVisible) return null;
-
- const getIcon = () => {
- if (error) {
- return <AlertCircle className="w-6 h-6 text-red-500" />;
- }
-
- if (isDragging) {
- return <CheckCircle className="w-6 h-6 text-green-500" />;
- }
-
- if (isDownloading) {
- return <Loader2 className="w-6 h-6 text-blue-500 animate-spin" />;
- }
-
- if (fileCount > 1) {
- return <FolderDown className="w-6 h-6 text-blue-500" />;
- }
-
- return <FileDown className="w-6 h-6 text-blue-500" />;
- };
-
- const getStatusText = () => {
- if (error) {
- return t("dragIndicator.error", { error });
- }
-
- if (isDragging) {
- return t("dragIndicator.dragging", { fileName: fileName || "" });
- }
-
- if (isDownloading) {
- return t("dragIndicator.preparing", { fileName: fileName || "" });
- }
-
- if (fileCount > 1) {
- return t("dragIndicator.readyMultiple", { count: fileCount });
- }
-
- return t("dragIndicator.readySingle", { fileName: fileName || "" });
- };
-
- return (
- <div
- className={cn(
- "fixed top-4 right-4 z-50 min-w-[300px] max-w-[400px]",
- "bg-canvas border border-edge rounded-lg shadow-lg",
- "p-4 transition-all duration-300 ease-in-out",
- isVisible ? "opacity-100 translate-x-0" : "opacity-0 translate-x-full",
- className,
- )}
- >
- <div className="flex items-start gap-3">
- <div className="flex-shrink-0 mt-0.5">{getIcon()}</div>
-
- <div className="flex-1 min-w-0">
- <div className="text-sm font-medium text-foreground mb-2">
- {fileCount > 1
- ? t("dragIndicator.batchDrag")
- : t("dragIndicator.dragToDesktop")}
- </div>
-
- <div
- className={cn(
- "text-xs mb-3",
- error
- ? "text-red-500"
- : isDragging
- ? "text-green-500"
- : "text-muted-foreground",
- )}
- >
- {getStatusText()}
- </div>
-
- {(isDownloading || isDragging) && !error && (
- <div className="w-full bg-border-base rounded-full h-2 mb-2">
- <div
- className={cn(
- "h-2 rounded-full transition-all duration-300",
- isDragging ? "bg-green-500" : "bg-blue-500",
- )}
- style={{ width: `${Math.max(5, progress)}%` }}
- />
- </div>
- )}
-
- {(isDownloading || isDragging) && !error && (
- <div className="text-xs text-muted-foreground">
- {progress.toFixed(0)}%
- </div>
- )}
-
- {isDragging && !error && (
- <div className="text-xs text-green-500 mt-2 flex items-center gap-1">
- <Download className="w-3 h-3" />
- {t("dragIndicator.canDragAnywhere")}
- </div>
- )}
- </div>
- </div>
-
- {isDragging && !error && (
- <div className="absolute inset-0 rounded-lg bg-green-500/5 animate-pulse" />
- )}
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/file-manager/components/PermissionsDialog.tsx b/src/ui/desktop/apps/features/file-manager/components/PermissionsDialog.tsx
deleted file mode 100644
index b5faa7abd..000000000
--- a/src/ui/desktop/apps/features/file-manager/components/PermissionsDialog.tsx
+++ /dev/null
@@ -1,317 +0,0 @@
-import React, { useState, useEffect } from "react";
-import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogHeader,
- DialogTitle,
- DialogFooter,
-} from "@/components/ui/dialog.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import { Checkbox } from "@/components/ui/checkbox.tsx";
-import { useTranslation } from "react-i18next";
-import { Shield } from "lucide-react";
-
-interface FileItem {
- name: string;
- type: "file" | "directory" | "link";
- path: string;
- permissions?: string;
- owner?: string;
- group?: string;
-}
-
-interface PermissionsDialogProps {
- file: FileItem | null;
- open: boolean;
- onOpenChange: (open: boolean) => void;
- onSave: (file: FileItem, permissions: string) => Promise<void>;
-}
-
-const parsePermissions = (
- perms: string,
-): { owner: number; group: number; other: number } => {
- if (!perms) {
- return { owner: 0, group: 0, other: 0 };
- }
-
- if (/^\d{3,4}$/.test(perms)) {
- const numStr = perms.slice(-3);
- return {
- owner: parseInt(numStr[0] || "0", 10),
- group: parseInt(numStr[1] || "0", 10),
- other: parseInt(numStr[2] || "0", 10),
- };
- }
- const cleanPerms = perms.replace(/^-/, "").substring(0, 9);
-
- const calcBits = (str: string): number => {
- let value = 0;
- if (str[0] === "r") value += 4;
- if (str[1] === "w") value += 2;
- if (str[2] === "x") value += 1;
- return value;
- };
-
- return {
- owner: calcBits(cleanPerms.substring(0, 3)),
- group: calcBits(cleanPerms.substring(3, 6)),
- other: calcBits(cleanPerms.substring(6, 9)),
- };
-};
-
-const toNumeric = (owner: number, group: number, other: number): string => {
- return `${owner}${group}${other}`;
-};
-
-export function PermissionsDialog({
- file,
- open,
- onOpenChange,
- onSave,
-}: PermissionsDialogProps) {
- const { t } = useTranslation();
- const [loading, setLoading] = useState(false);
-
- const initialPerms = parsePermissions(file?.permissions || "644");
- const [ownerRead, setOwnerRead] = useState((initialPerms.owner & 4) !== 0);
- const [ownerWrite, setOwnerWrite] = useState((initialPerms.owner & 2) !== 0);
- const [ownerExecute, setOwnerExecute] = useState(
- (initialPerms.owner & 1) !== 0,
- );
-
- const [groupRead, setGroupRead] = useState((initialPerms.group & 4) !== 0);
- const [groupWrite, setGroupWrite] = useState((initialPerms.group & 2) !== 0);
- const [groupExecute, setGroupExecute] = useState(
- (initialPerms.group & 1) !== 0,
- );
-
- const [otherRead, setOtherRead] = useState((initialPerms.other & 4) !== 0);
- const [otherWrite, setOtherWrite] = useState((initialPerms.other & 2) !== 0);
- const [otherExecute, setOtherExecute] = useState(
- (initialPerms.other & 1) !== 0,
- );
-
- useEffect(() => {
- if (file) {
- const perms = parsePermissions(file.permissions || "644");
- setOwnerRead((perms.owner & 4) !== 0);
- setOwnerWrite((perms.owner & 2) !== 0);
- setOwnerExecute((perms.owner & 1) !== 0);
- setGroupRead((perms.group & 4) !== 0);
- setGroupWrite((perms.group & 2) !== 0);
- setGroupExecute((perms.group & 1) !== 0);
- setOtherRead((perms.other & 4) !== 0);
- setOtherWrite((perms.other & 2) !== 0);
- setOtherExecute((perms.other & 1) !== 0);
- }
- }, [file]);
-
- const calculateOctal = (): string => {
- const owner =
- (ownerRead ? 4 : 0) + (ownerWrite ? 2 : 0) + (ownerExecute ? 1 : 0);
- const group =
- (groupRead ? 4 : 0) + (groupWrite ? 2 : 0) + (groupExecute ? 1 : 0);
- const other =
- (otherRead ? 4 : 0) + (otherWrite ? 2 : 0) + (otherExecute ? 1 : 0);
- return toNumeric(owner, group, other);
- };
-
- const handleSave = async () => {
- if (!file) return;
-
- setLoading(true);
- try {
- const permissions = calculateOctal();
- await onSave(file, permissions);
- onOpenChange(false);
- } catch (error) {
- console.error("Failed to update permissions:", error);
- } finally {
- setLoading(false);
- }
- };
-
- if (!file) return null;
-
- const octal = calculateOctal();
-
- return (
- <Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent className="sm:max-w-[500px] bg-canvas border-2 border-edge">
- <DialogHeader>
- <DialogTitle className="flex items-center gap-2">
- <Shield className="w-5 h-5" />
- {t("fileManager.changePermissions")}
- </DialogTitle>
- <DialogDescription className="text-muted-foreground">
- {t("fileManager.changePermissionsDesc")}:{" "}
- <span className="font-mono text-foreground">{file.name}</span>
- </DialogDescription>
- </DialogHeader>
-
- <div className="space-y-6 py-4">
- <div className="grid grid-cols-2 gap-4 text-sm">
- <div>
- <Label className="text-muted-foreground">
- {t("fileManager.currentPermissions")}
- </Label>
- <p className="font-mono text-lg mt-1">
- {file.permissions || "644"}
- </p>
- </div>
- <div>
- <Label className="text-muted-foreground">
- {t("fileManager.newPermissions")}
- </Label>
- <p className="font-mono text-lg mt-1">{octal}</p>
- </div>
- </div>
-
- <div className="space-y-3">
- <Label className="text-base font-semibold text-foreground">
- {t("fileManager.owner")} {file.owner && `(${file.owner})`}
- </Label>
- <div className="flex gap-6 ml-4">
- <div className="flex items-center space-x-2">
- <Checkbox
- id="owner-read"
- checked={ownerRead}
- onCheckedChange={(checked) => setOwnerRead(checked === true)}
- />
- <label htmlFor="owner-read" className="text-sm cursor-pointer">
- {t("fileManager.read")}
- </label>
- </div>
- <div className="flex items-center space-x-2">
- <Checkbox
- id="owner-write"
- checked={ownerWrite}
- onCheckedChange={(checked) => setOwnerWrite(checked === true)}
- />
- <label htmlFor="owner-write" className="text-sm cursor-pointer">
- {t("fileManager.write")}
- </label>
- </div>
- <div className="flex items-center space-x-2">
- <Checkbox
- id="owner-execute"
- checked={ownerExecute}
- onCheckedChange={(checked) =>
- setOwnerExecute(checked === true)
- }
- />
- <label
- htmlFor="owner-execute"
- className="text-sm cursor-pointer"
- >
- {t("fileManager.execute")}
- </label>
- </div>
- </div>
- </div>
-
- <div className="space-y-3">
- <Label className="text-base font-semibold text-foreground">
- {t("fileManager.group")} {file.group && `(${file.group})`}
- </Label>
- <div className="flex gap-6 ml-4">
- <div className="flex items-center space-x-2">
- <Checkbox
- id="group-read"
- checked={groupRead}
- onCheckedChange={(checked) => setGroupRead(checked === true)}
- />
- <label htmlFor="group-read" className="text-sm cursor-pointer">
- {t("fileManager.read")}
- </label>
- </div>
- <div className="flex items-center space-x-2">
- <Checkbox
- id="group-write"
- checked={groupWrite}
- onCheckedChange={(checked) => setGroupWrite(checked === true)}
- />
- <label htmlFor="group-write" className="text-sm cursor-pointer">
- {t("fileManager.write")}
- </label>
- </div>
- <div className="flex items-center space-x-2">
- <Checkbox
- id="group-execute"
- checked={groupExecute}
- onCheckedChange={(checked) =>
- setGroupExecute(checked === true)
- }
- />
- <label
- htmlFor="group-execute"
- className="text-sm cursor-pointer"
- >
- {t("fileManager.execute")}
- </label>
- </div>
- </div>
- </div>
-
- <div className="space-y-3">
- <Label className="text-base font-semibold text-foreground">
- {t("fileManager.others")}
- </Label>
- <div className="flex gap-6 ml-4">
- <div className="flex items-center space-x-2">
- <Checkbox
- id="other-read"
- checked={otherRead}
- onCheckedChange={(checked) => setOtherRead(checked === true)}
- />
- <label htmlFor="other-read" className="text-sm cursor-pointer">
- {t("fileManager.read")}
- </label>
- </div>
- <div className="flex items-center space-x-2">
- <Checkbox
- id="other-write"
- checked={otherWrite}
- onCheckedChange={(checked) => setOtherWrite(checked === true)}
- />
- <label htmlFor="other-write" className="text-sm cursor-pointer">
- {t("fileManager.write")}
- </label>
- </div>
- <div className="flex items-center space-x-2">
- <Checkbox
- id="other-execute"
- checked={otherExecute}
- onCheckedChange={(checked) =>
- setOtherExecute(checked === true)
- }
- />
- <label
- htmlFor="other-execute"
- className="text-sm cursor-pointer"
- >
- {t("fileManager.execute")}
- </label>
- </div>
- </div>
- </div>
- </div>
-
- <DialogFooter>
- <Button
- variant="outline"
- onClick={() => onOpenChange(false)}
- disabled={loading}
- >
- {t("common.cancel")}
- </Button>
- <Button onClick={handleSave} disabled={loading}>
- {loading ? t("common.saving") : t("common.save")}
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- );
-}
diff --git a/src/ui/desktop/apps/features/server-stats/widgets/CpuWidget.tsx b/src/ui/desktop/apps/features/server-stats/widgets/CpuWidget.tsx
deleted file mode 100644
index 151e6a538..000000000
--- a/src/ui/desktop/apps/features/server-stats/widgets/CpuWidget.tsx
+++ /dev/null
@@ -1,104 +0,0 @@
-import React from "react";
-import { Cpu } from "lucide-react";
-import { useTranslation } from "react-i18next";
-import type { ServerMetrics } from "@/ui/main-axios.ts";
-import { RechartsPrimitive } from "@/components/ui/chart.tsx";
-
-const {
- LineChart,
- Line,
- XAxis,
- YAxis,
- CartesianGrid,
- Tooltip,
- ResponsiveContainer,
-} = RechartsPrimitive;
-
-interface CpuWidgetProps {
- metrics: ServerMetrics | null;
- metricsHistory: ServerMetrics[];
-}
-
-export function CpuWidget({ metrics, metricsHistory }: CpuWidgetProps) {
- const { t } = useTranslation();
-
- const chartData = React.useMemo(() => {
- return metricsHistory.map((m, index) => ({
- index,
- cpu: m.cpu?.percent || 0,
- }));
- }, [metricsHistory]);
-
- return (
- <div className="h-full w-full p-4 rounded-lg bg-elevated border border-edge/50 hover:bg-elevated/70 flex flex-col overflow-hidden">
- <div className="flex items-center gap-2 flex-shrink-0 mb-3">
- <Cpu className="h-5 w-5 text-blue-400" />
- <h3 className="font-semibold text-lg text-foreground">
- {t("serverStats.cpuUsage")}
- </h3>
- </div>
-
- <div className="flex flex-col flex-1 min-h-0 gap-2">
- <div className="flex items-baseline gap-3 flex-shrink-0">
- <div className="text-2xl font-bold text-blue-400">
- {typeof metrics?.cpu?.percent === "number"
- ? `${metrics.cpu.percent}%`
- : "N/A"}
- </div>
- <div className="text-xs text-muted-foreground">
- {typeof metrics?.cpu?.cores === "number"
- ? t("serverStats.cpuCores", { count: metrics.cpu.cores })
- : t("serverStats.naCpus")}
- </div>
- </div>
- <div className="text-xs text-foreground-subtle flex-shrink-0">
- {metrics?.cpu?.load
- ? t("serverStats.loadAverage", {
- avg1: metrics.cpu.load[0].toFixed(2),
- avg5: metrics.cpu.load[1].toFixed(2),
- avg15: metrics.cpu.load[2].toFixed(2),
- })
- : t("serverStats.loadAverageNA")}
- </div>
- <div className="flex-1 min-h-0">
- <ResponsiveContainer width="100%" height="100%">
- <LineChart
- data={chartData}
- margin={{ top: 5, right: 5, left: -25, bottom: 5 }}
- >
- <CartesianGrid strokeDasharray="3 3" stroke="#374151" />
- <XAxis
- dataKey="index"
- stroke="#9ca3af"
- tick={{ fill: "#9ca3af" }}
- hide
- />
- <YAxis
- domain={[0, 100]}
- stroke="#9ca3af"
- tick={{ fill: "#9ca3af" }}
- />
- <Tooltip
- contentStyle={{
- backgroundColor: "#1f2937",
- border: "1px solid #374151",
- borderRadius: "6px",
- color: "#fff",
- }}
- formatter={(value: number) => [`${value.toFixed(1)}%`, "CPU"]}
- />
- <Line
- type="monotone"
- dataKey="cpu"
- stroke="#60a5fa"
- strokeWidth={2}
- dot={false}
- animationDuration={300}
- />
- </LineChart>
- </ResponsiveContainer>
- </div>
- </div>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/server-stats/widgets/DiskWidget.tsx b/src/ui/desktop/apps/features/server-stats/widgets/DiskWidget.tsx
deleted file mode 100644
index 78d1fd22b..000000000
--- a/src/ui/desktop/apps/features/server-stats/widgets/DiskWidget.tsx
+++ /dev/null
@@ -1,125 +0,0 @@
-import React from "react";
-import { HardDrive } from "lucide-react";
-import { useTranslation } from "react-i18next";
-import type { ServerMetrics } from "@/ui/main-axios.ts";
-import { RechartsPrimitive } from "@/components/ui/chart.tsx";
-
-const {
- AreaChart,
- Area,
- XAxis,
- YAxis,
- CartesianGrid,
- Tooltip,
- ResponsiveContainer,
-} = RechartsPrimitive;
-
-interface DiskWidgetProps {
- metrics: ServerMetrics | null;
- metricsHistory: ServerMetrics[];
-}
-
-export function DiskWidget({ metrics, metricsHistory }: DiskWidgetProps) {
- const { t } = useTranslation();
-
- const chartData = React.useMemo(() => {
- return metricsHistory.map((m, index) => ({
- index,
- disk: m.disk?.percent || 0,
- }));
- }, [metricsHistory]);
-
- return (
- <div className="h-full w-full p-4 rounded-lg bg-elevated border border-edge/50 hover:bg-elevated/70 flex flex-col overflow-hidden">
- <div className="flex items-center gap-2 flex-shrink-0 mb-3">
- <HardDrive className="h-5 w-5 text-orange-400" />
- <h3 className="font-semibold text-lg text-foreground">
- {t("serverStats.diskUsage")}
- </h3>
- </div>
-
- <div className="flex flex-col flex-1 min-h-0 gap-2">
- <div className="flex items-baseline gap-3 flex-shrink-0">
- <div className="text-2xl font-bold text-orange-400">
- {typeof metrics?.disk?.percent === "number"
- ? `${metrics.disk.percent}%`
- : "N/A"}
- </div>
- <div className="text-xs text-muted-foreground">
- {(() => {
- const used = metrics?.disk?.usedHuman;
- const total = metrics?.disk?.totalHuman;
- if (used && total) {
- return `${used} / ${total}`;
- }
- return "N/A";
- })()}
- </div>
- </div>
- <div className="text-xs text-foreground-subtle flex-shrink-0">
- {(() => {
- const available = metrics?.disk?.availableHuman;
- return available
- ? `${t("serverStats.available")}: ${available}`
- : `${t("serverStats.available")}: N/A`;
- })()}
- </div>
- <div className="flex-1 min-h-0">
- <ResponsiveContainer width="100%" height="100%">
- <AreaChart
- data={chartData}
- margin={{ top: 5, right: 5, left: -25, bottom: 5 }}
- >
- <defs>
- <linearGradient id="diskGradient" x1="0" y1="0" x2="0" y2="1">
- <stop offset="5%" stopColor="#fb923c" stopOpacity={0.8} />
- <stop offset="95%" stopColor="#fb923c" stopOpacity={0.1} />
- </linearGradient>
- </defs>
- <CartesianGrid strokeDasharray="3 3" stroke="#374151" />
- <XAxis
- dataKey="index"
- stroke="#9ca3af"
- tick={{ fill: "#9ca3af" }}
- hide
- />
- <YAxis
- domain={[0, 100]}
- stroke="#9ca3af"
- tick={{ fill: "#9ca3af" }}
- />
- <Tooltip
- contentStyle={{
- backgroundColor: "#1f2937",
- border: "1px solid #374151",
- borderRadius: "6px",
- color: "#fff",
- }}
- formatter={(value: number) => [`${value.toFixed(1)}%`, "Disk"]}
- cursor={{
- stroke: "#fb923c",
- strokeWidth: 1,
- strokeDasharray: "3 3",
- }}
- />
- <Area
- type="monotone"
- dataKey="disk"
- stroke="#fb923c"
- strokeWidth={2}
- fill="url(#diskGradient)"
- animationDuration={300}
- activeDot={{
- r: 4,
- fill: "#fb923c",
- stroke: "#fff",
- strokeWidth: 2,
- }}
- />
- </AreaChart>
- </ResponsiveContainer>
- </div>
- </div>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/server-stats/widgets/FirewallWidget.tsx b/src/ui/desktop/apps/features/server-stats/widgets/FirewallWidget.tsx
deleted file mode 100644
index 175715477..000000000
--- a/src/ui/desktop/apps/features/server-stats/widgets/FirewallWidget.tsx
+++ /dev/null
@@ -1,212 +0,0 @@
-import React from "react";
-import { Shield, ShieldOff, ShieldCheck, ChevronDown } from "lucide-react";
-import { useTranslation } from "react-i18next";
-import type { ServerMetrics } from "@/ui/main-axios.ts";
-import type {
- FirewallMetrics,
- FirewallChain,
- FirewallRule,
-} from "@/types/stats-widgets";
-
-interface FirewallWidgetProps {
- metrics: ServerMetrics | null;
- metricsHistory: ServerMetrics[];
-}
-
-function RuleRow({ rule }: { rule: FirewallRule }) {
- const { t } = useTranslation();
-
- const getTargetStyle = (target: string) => {
- switch (target.toUpperCase()) {
- case "ACCEPT":
- return "text-green-400";
- case "DROP":
- return "text-red-400";
- case "REJECT":
- return "text-orange-400";
- default:
- return "text-muted-foreground";
- }
- };
-
- const getTargetLabel = (target: string) => {
- switch (target.toUpperCase()) {
- case "ACCEPT":
- return t("serverStats.firewall.accept");
- case "DROP":
- return t("serverStats.firewall.drop");
- case "REJECT":
- return t("serverStats.firewall.reject");
- default:
- return target;
- }
- };
-
- const formatSource = () => {
- if (rule.interface) {
- return rule.interface;
- }
- if (rule.state) {
- return rule.state;
- }
- if (rule.source === "0.0.0.0/0") {
- return t("serverStats.firewall.anywhere");
- }
- return rule.source;
- };
-
- return (
- <div className="grid grid-cols-4 gap-2 text-xs py-1.5 border-b border-edge/30 last:border-0">
- <div className={`font-medium ${getTargetStyle(rule.target)}`}>
- {getTargetLabel(rule.target)}
- </div>
- <div className="text-foreground-subtle font-mono">
- {rule.protocol.toUpperCase()}
- </div>
- <div className="text-foreground-subtle font-mono">
- {rule.dport || "-"}
- </div>
- <div className="text-foreground-subtle truncate" title={formatSource()}>
- {formatSource()}
- </div>
- </div>
- );
-}
-
-function ChainSection({ chain }: { chain: FirewallChain }) {
- const { t } = useTranslation();
- const [isOpen, setIsOpen] = React.useState(true);
-
- const getPolicyStyle = (policy: string) => {
- switch (policy.toUpperCase()) {
- case "ACCEPT":
- return "text-green-400";
- case "DROP":
- return "text-red-400";
- case "REJECT":
- return "text-orange-400";
- default:
- return "text-muted-foreground";
- }
- };
-
- return (
- <div>
- <button
- type="button"
- onClick={() => setIsOpen(!isOpen)}
- className="flex items-center gap-2 w-full py-1.5 hover:bg-elevated/30 rounded px-1 -mx-1 text-left"
- >
- <ChevronDown
- className={`h-3 w-3 text-muted-foreground transition-transform ${
- isOpen ? "" : "-rotate-90"
- }`}
- />
- <span className="text-sm font-medium text-foreground">
- {chain.name}
- </span>
- <span className="text-xs text-muted-foreground">
- ({t("serverStats.firewall.policy")}:{" "}
- <span className={getPolicyStyle(chain.policy)}>{chain.policy}</span>)
- </span>
- <span className="text-xs text-muted-foreground ml-auto">
- {chain.rules.length} {t("serverStats.firewall.rules")}
- </span>
- </button>
- {isOpen && (
- <>
- {chain.rules.length > 0 ? (
- <div className="mt-2 ml-5">
- <div className="grid grid-cols-4 gap-2 text-xs text-muted-foreground border-b border-edge/50 pb-1 mb-1">
- <div>{t("serverStats.firewall.action")}</div>
- <div>{t("serverStats.firewall.protocol")}</div>
- <div>{t("serverStats.firewall.port")}</div>
- <div>{t("serverStats.firewall.source")}</div>
- </div>
- <div className="max-h-32 overflow-y-auto thin-scrollbar">
- {chain.rules.map((rule, idx) => (
- <RuleRow key={idx} rule={rule} />
- ))}
- </div>
- </div>
- ) : (
- <div className="text-xs text-muted-foreground ml-5 mt-1">
- {t("serverStats.firewall.noRules")}
- </div>
- )}
- </>
- )}
- </div>
- );
-}
-
-export function FirewallWidget({ metrics }: FirewallWidgetProps) {
- const { t } = useTranslation();
-
- const firewall = (metrics as ServerMetrics & { firewall?: FirewallMetrics })
- ?.firewall;
-
- const getStatusIcon = () => {
- if (!firewall || firewall.type === "none") {
- return <ShieldOff className="h-5 w-5 text-muted-foreground" />;
- }
- if (firewall.status === "active") {
- return <ShieldCheck className="h-5 w-5 text-green-400" />;
- }
- return <Shield className="h-5 w-5 text-orange-400" />;
- };
-
- const getStatusText = () => {
- if (!firewall || firewall.type === "none") {
- return t("serverStats.firewall.notDetected");
- }
- if (firewall.status === "active") {
- return t("serverStats.firewall.active");
- }
- return t("serverStats.firewall.inactive");
- };
-
- return (
- <div className="h-full w-full p-4 rounded-lg bg-elevated border border-edge/50 hover:bg-elevated/70 flex flex-col overflow-hidden">
- <div className="flex items-center gap-2 flex-shrink-0 mb-3">
- {getStatusIcon()}
- <h3 className="font-semibold text-lg text-foreground">
- {t("serverStats.firewall.title")}
- </h3>
- {firewall && firewall.type !== "none" && (
- <span className="text-xs text-muted-foreground ml-auto bg-elevated/50 px-2 py-0.5 rounded capitalize">
- {firewall.type}
- </span>
- )}
- </div>
-
- <div className="flex items-center gap-2 mb-3 flex-shrink-0">
- <span
- className={`text-sm font-medium ${
- firewall?.status === "active"
- ? "text-green-400"
- : firewall?.status === "inactive"
- ? "text-orange-400"
- : "text-muted-foreground"
- }`}
- >
- {getStatusText()}
- </span>
- </div>
-
- {firewall && firewall.chains.length > 0 ? (
- <div className="flex-1 overflow-y-auto thin-scrollbar space-y-2">
- {firewall.chains.map((chain) => (
- <ChainSection key={chain.name} chain={chain} />
- ))}
- </div>
- ) : (
- <div className="flex-1 flex items-center justify-center">
- <p className="text-sm text-muted-foreground">
- {t("serverStats.firewall.noData")}
- </p>
- </div>
- )}
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/server-stats/widgets/LoginStatsWidget.tsx b/src/ui/desktop/apps/features/server-stats/widgets/LoginStatsWidget.tsx
deleted file mode 100644
index fe2ea6986..000000000
--- a/src/ui/desktop/apps/features/server-stats/widgets/LoginStatsWidget.tsx
+++ /dev/null
@@ -1,142 +0,0 @@
-import React from "react";
-import { UserCheck, UserX, MapPin, Activity } from "lucide-react";
-import { useTranslation } from "react-i18next";
-
-interface LoginRecord {
- user: string;
- ip: string;
- time: string;
- status: "success" | "failed";
-}
-
-interface LoginStatsMetrics {
- recentLogins: LoginRecord[];
- failedLogins: LoginRecord[];
- totalLogins: number;
- uniqueIPs: number;
-}
-
-interface ServerMetrics {
- login_stats?: LoginStatsMetrics;
-}
-
-interface LoginStatsWidgetProps {
- metrics: ServerMetrics | null;
- metricsHistory: ServerMetrics[];
-}
-
-export function LoginStatsWidget({ metrics }: LoginStatsWidgetProps) {
- const { t } = useTranslation();
-
- const loginStats = metrics?.login_stats;
- const recentLogins = loginStats?.recentLogins || [];
- const failedLogins = loginStats?.failedLogins || [];
- const totalLogins = loginStats?.totalLogins || 0;
- const uniqueIPs = loginStats?.uniqueIPs || 0;
-
- return (
- <div className="h-full w-full p-4 rounded-lg bg-elevated border border-edge/50 hover:bg-elevated/70 flex flex-col overflow-hidden">
- <div className="flex items-center gap-2 flex-shrink-0 mb-3">
- <UserCheck className="h-5 w-5 text-green-400" />
- <h3 className="font-semibold text-lg text-foreground">
- {t("serverStats.loginStats")}
- </h3>
- </div>
-
- <div className="flex flex-col flex-1 min-h-0 gap-3">
- <div className="grid grid-cols-2 gap-2 flex-shrink-0">
- <div className="bg-canvas/40 p-2 rounded border border-edge/30 hover:bg-canvas/50">
- <div className="flex items-center gap-1 text-xs text-muted-foreground mb-1">
- <Activity className="h-3 w-3" />
- <span>{t("serverStats.totalLogins")}</span>
- </div>
- <div className="text-xl font-bold text-green-400">
- {totalLogins}
- </div>
- </div>
- <div className="bg-canvas/40 p-2 rounded border border-edge/30 hover:bg-canvas/50">
- <div className="flex items-center gap-1 text-xs text-muted-foreground mb-1">
- <MapPin className="h-3 w-3" />
- <span>{t("serverStats.uniqueIPs")}</span>
- </div>
- <div className="text-xl font-bold text-blue-400">{uniqueIPs}</div>
- </div>
- </div>
-
- <div className="flex-1 min-h-0 overflow-y-auto thin-scrollbar space-y-2">
- <div className="flex-shrink-0">
- <div className="flex items-center gap-2 mb-1">
- <UserCheck className="h-4 w-4 text-green-400" />
- <span className="text-sm font-semibold text-foreground-secondary">
- {t("serverStats.recentSuccessfulLogins")}
- </span>
- </div>
- {recentLogins.length === 0 ? (
- <div className="text-xs text-foreground-subtle italic p-2">
- {t("serverStats.noRecentLoginData")}
- </div>
- ) : (
- <div className="space-y-1">
- {recentLogins.slice(0, 5).map((login, idx) => (
- <div
- key={idx}
- className="text-xs bg-canvas/40 p-2 rounded border border-edge/30 hover:bg-canvas/50 flex justify-between items-center"
- >
- <div className="flex items-center gap-2 min-w-0">
- <span className="text-green-400 font-mono truncate">
- {login.user}
- </span>
- <span className="text-foreground-subtle">
- {t("serverStats.from")}
- </span>
- <span className="text-blue-400 font-mono truncate">
- {login.ip}
- </span>
- </div>
- <span className="text-foreground-subtle text-[10px] flex-shrink-0 ml-2">
- {new Date(login.time).toLocaleString()}
- </span>
- </div>
- ))}
- </div>
- )}
- </div>
-
- {failedLogins.length > 0 && (
- <div className="flex-shrink-0">
- <div className="flex items-center gap-2 mb-1">
- <UserX className="h-4 w-4 text-red-400" />
- <span className="text-sm font-semibold text-foreground-secondary">
- {t("serverStats.recentFailedAttempts")}
- </span>
- </div>
- <div className="space-y-1">
- {failedLogins.slice(0, 3).map((login) => (
- <div
- key={`failed-${login.user}-${login.time}-${login.ip || "unknown"}`}
- className="text-xs bg-red-900/20 p-2 rounded border border-red-500/30 flex justify-between items-center"
- >
- <div className="flex items-center gap-2 min-w-0">
- <span className="text-red-400 font-mono truncate">
- {login.user}
- </span>
- <span className="text-foreground-subtle">
- {t("serverStats.from")}
- </span>
- <span className="text-blue-400 font-mono truncate">
- {login.ip}
- </span>
- </div>
- <span className="text-foreground-subtle text-[10px] flex-shrink-0 ml-2">
- {new Date(login.time).toLocaleString()}
- </span>
- </div>
- ))}
- </div>
- </div>
- )}
- </div>
- </div>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/server-stats/widgets/MemoryWidget.tsx b/src/ui/desktop/apps/features/server-stats/widgets/MemoryWidget.tsx
deleted file mode 100644
index 55d95ea23..000000000
--- a/src/ui/desktop/apps/features/server-stats/widgets/MemoryWidget.tsx
+++ /dev/null
@@ -1,131 +0,0 @@
-import React from "react";
-import { MemoryStick } from "lucide-react";
-import { useTranslation } from "react-i18next";
-import type { ServerMetrics } from "@/ui/main-axios.ts";
-import { RechartsPrimitive } from "@/components/ui/chart.tsx";
-
-const {
- AreaChart,
- Area,
- XAxis,
- YAxis,
- CartesianGrid,
- Tooltip,
- ResponsiveContainer,
-} = RechartsPrimitive;
-
-interface MemoryWidgetProps {
- metrics: ServerMetrics | null;
- metricsHistory: ServerMetrics[];
-}
-
-export function MemoryWidget({ metrics, metricsHistory }: MemoryWidgetProps) {
- const { t } = useTranslation();
-
- const chartData = React.useMemo(() => {
- return metricsHistory.map((m, index) => ({
- index,
- memory: m.memory?.percent || 0,
- }));
- }, [metricsHistory]);
-
- return (
- <div className="h-full w-full p-4 rounded-lg bg-elevated border border-edge/50 hover:bg-elevated/70 flex flex-col overflow-hidden">
- <div className="flex items-center gap-2 flex-shrink-0 mb-3">
- <MemoryStick className="h-5 w-5 text-green-400" />
- <h3 className="font-semibold text-lg text-foreground">
- {t("serverStats.memoryUsage")}
- </h3>
- </div>
-
- <div className="flex flex-col flex-1 min-h-0 gap-2">
- <div className="flex items-baseline gap-3 flex-shrink-0">
- <div className="text-2xl font-bold text-green-400">
- {typeof metrics?.memory?.percent === "number"
- ? `${metrics.memory.percent}%`
- : "N/A"}
- </div>
- <div className="text-xs text-muted-foreground">
- {(() => {
- const used = metrics?.memory?.usedGiB;
- const total = metrics?.memory?.totalGiB;
- if (typeof used === "number" && typeof total === "number") {
- return `${used.toFixed(1)} / ${total.toFixed(1)} GiB`;
- }
- return "N/A";
- })()}
- </div>
- </div>
- <div className="text-xs text-foreground-subtle flex-shrink-0">
- {(() => {
- const used = metrics?.memory?.usedGiB;
- const total = metrics?.memory?.totalGiB;
- const free =
- typeof used === "number" && typeof total === "number"
- ? (total - used).toFixed(1)
- : "N/A";
- return `${t("serverStats.free")}: ${free} GiB`;
- })()}
- </div>
- <div className="flex-1 min-h-0">
- <ResponsiveContainer width="100%" height="100%">
- <AreaChart
- data={chartData}
- margin={{ top: 5, right: 5, left: -25, bottom: 5 }}
- >
- <defs>
- <linearGradient id="memoryGradient" x1="0" y1="0" x2="0" y2="1">
- <stop offset="5%" stopColor="#34d399" stopOpacity={0.8} />
- <stop offset="95%" stopColor="#34d399" stopOpacity={0.1} />
- </linearGradient>
- </defs>
- <CartesianGrid strokeDasharray="3 3" stroke="#374151" />
- <XAxis
- dataKey="index"
- stroke="#9ca3af"
- tick={{ fill: "#9ca3af" }}
- hide
- />
- <YAxis
- domain={[0, 100]}
- stroke="#9ca3af"
- tick={{ fill: "#9ca3af" }}
- />
- <Tooltip
- contentStyle={{
- backgroundColor: "#1f2937",
- border: "1px solid #374151",
- borderRadius: "6px",
- color: "#fff",
- }}
- formatter={(value: number) => [
- `${value.toFixed(1)}%`,
- "Memory",
- ]}
- cursor={{
- stroke: "#34d399",
- strokeWidth: 1,
- strokeDasharray: "3 3",
- }}
- />
- <Area
- type="monotone"
- dataKey="memory"
- stroke="#34d399"
- strokeWidth={2}
- fill="url(#memoryGradient)"
- animationDuration={300}
- activeDot={{
- r: 4,
- fill: "#34d399",
- stroke: "#fff",
- strokeWidth: 2,
- }}
- />
- </AreaChart>
- </ResponsiveContainer>
- </div>
- </div>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/server-stats/widgets/NetworkWidget.tsx b/src/ui/desktop/apps/features/server-stats/widgets/NetworkWidget.tsx
deleted file mode 100644
index 08eaf348e..000000000
--- a/src/ui/desktop/apps/features/server-stats/widgets/NetworkWidget.tsx
+++ /dev/null
@@ -1,75 +0,0 @@
-import React from "react";
-import { Network, Wifi, WifiOff } from "lucide-react";
-import { useTranslation } from "react-i18next";
-import type { ServerMetrics } from "@/ui/main-axios.ts";
-
-interface NetworkWidgetProps {
- metrics: ServerMetrics | null;
- metricsHistory: ServerMetrics[];
-}
-
-export function NetworkWidget({ metrics }: NetworkWidgetProps) {
- const { t } = useTranslation();
-
- const metricsWithNetwork = metrics as ServerMetrics & {
- network?: {
- interfaces?: Array<{
- name: string;
- state: string;
- ip: string;
- }>;
- };
- };
- const network = metricsWithNetwork?.network;
- const interfaces = network?.interfaces || [];
-
- return (
- <div className="h-full w-full p-4 rounded-lg bg-elevated border border-edge/50 hover:bg-elevated/70 flex flex-col overflow-hidden">
- <div className="flex items-center gap-2 flex-shrink-0 mb-3">
- <Network className="h-5 w-5 text-indigo-400" />
- <h3 className="font-semibold text-lg text-foreground">
- {t("serverStats.networkInterfaces")}
- </h3>
- </div>
-
- <div className="space-y-2.5 overflow-auto thin-scrollbar flex-1">
- {interfaces.length === 0 ? (
- <div className="flex flex-col items-center justify-center py-12 text-muted-foreground">
- <WifiOff className="h-10 w-10 mb-3 opacity-50" />
- <p className="text-sm">{t("serverStats.noInterfacesFound")}</p>
- </div>
- ) : (
- interfaces.map((iface, index: number) => (
- <div
- key={index}
- className="p-3 rounded-lg bg-canvas/40 border border-edge/30 hover:bg-canvas/50"
- >
- <div className="flex items-center justify-between mb-2">
- <div className="flex items-center gap-2">
- <Wifi
- className={`h-4 w-4 ${iface.state === "UP" ? "text-green-400" : "text-foreground-subtle"}`}
- />
- <span className="text-sm font-semibold text-foreground font-mono">
- {iface.name}
- </span>
- </div>
- <span
- className={`text-xs px-2.5 py-0.5 rounded-full font-medium ${
- iface.state === "UP"
- ? "bg-green-500/20 text-green-400"
- : "bg-surface text-foreground-subtle"
- }`}
- >
- {iface.state}
- </span>
- </div>
- <div className="text-xs text-muted-foreground font-mono font-medium">
- {iface.ip}
- </div>
- </div>
- ))
- )}
- </div>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/server-stats/widgets/PortsWidget.tsx b/src/ui/desktop/apps/features/server-stats/widgets/PortsWidget.tsx
deleted file mode 100644
index 6e3463105..000000000
--- a/src/ui/desktop/apps/features/server-stats/widgets/PortsWidget.tsx
+++ /dev/null
@@ -1,108 +0,0 @@
-import React from "react";
-import { Network } from "lucide-react";
-import { useTranslation } from "react-i18next";
-import type { ServerMetrics } from "@/ui/main-axios.ts";
-import type { PortsMetrics, ListeningPort } from "@/types/stats-widgets";
-
-interface PortsWidgetProps {
- metrics: ServerMetrics | null;
- metricsHistory: ServerMetrics[];
-}
-
-function PortRow({ port }: { port: ListeningPort }) {
- const formatAddress = (addr: string) => {
- if (addr === "0.0.0.0" || addr === "*" || addr === "::") {
- return "*";
- }
- return addr;
- };
-
- return (
- <div className="grid grid-cols-5 gap-2 text-xs py-1.5 border-b border-edge/30 last:border-0">
- <div className="font-mono text-foreground-subtle">
- {port.protocol.toUpperCase()}
- </div>
- <div className="font-mono text-foreground">{port.localPort}</div>
- <div
- className="font-mono text-foreground-subtle truncate"
- title={formatAddress(port.localAddress)}
- >
- {formatAddress(port.localAddress)}
- </div>
- <div className="text-foreground-subtle">{port.state || "-"}</div>
- <div
- className="text-foreground-subtle truncate"
- title={port.process || "-"}
- >
- {port.process || (port.pid ? `PID:${port.pid}` : "-")}
- </div>
- </div>
- );
-}
-
-export function PortsWidget({ metrics }: PortsWidgetProps) {
- const { t } = useTranslation();
-
- const portsData = (metrics as ServerMetrics & { ports?: PortsMetrics })
- ?.ports;
-
- const tcpPorts = portsData?.ports.filter((p) => p.protocol === "tcp") || [];
- const udpPorts = portsData?.ports.filter((p) => p.protocol === "udp") || [];
-
- return (
- <div className="h-full w-full p-4 rounded-lg bg-elevated border border-edge/50 hover:bg-elevated/70 flex flex-col overflow-hidden">
- <div className="flex items-center gap-2 flex-shrink-0 mb-3">
- <Network className="h-5 w-5 text-cyan-400" />
- <h3 className="font-semibold text-lg text-foreground">
- {t("serverStats.ports.title")}
- </h3>
- {portsData && portsData.source !== "none" && (
- <span className="text-xs text-muted-foreground ml-auto bg-elevated/50 px-2 py-0.5 rounded">
- {portsData.source === "ss"
- ? "Socket Stats"
- : portsData.source === "netstat"
- ? "Netstat"
- : portsData.source}
- </span>
- )}
- </div>
-
- <div className="flex items-center gap-4 mb-3 flex-shrink-0 text-sm">
- <span className="text-foreground-subtle">
- TCP:{" "}
- <span className="text-cyan-400 font-medium">{tcpPorts.length}</span>
- </span>
- <span className="text-foreground-subtle">
- UDP:{" "}
- <span className="text-cyan-400 font-medium">{udpPorts.length}</span>
- </span>
- </div>
-
- {portsData && portsData.ports.length > 0 ? (
- <div className="flex-1 overflow-hidden flex flex-col">
- <div className="grid grid-cols-5 gap-2 text-xs text-muted-foreground border-b border-edge/50 pb-1 mb-1 flex-shrink-0">
- <div>{t("serverStats.ports.protocol")}</div>
- <div>{t("serverStats.ports.port")}</div>
- <div>{t("serverStats.ports.address")}</div>
- <div>{t("serverStats.ports.state")}</div>
- <div>{t("serverStats.ports.process")}</div>
- </div>
- <div className="flex-1 overflow-y-auto thin-scrollbar">
- {portsData.ports.map((port, idx) => (
- <PortRow
- key={`${port.protocol}-${port.localPort}-${idx}`}
- port={port}
- />
- ))}
- </div>
- </div>
- ) : (
- <div className="flex-1 flex items-center justify-center">
- <p className="text-sm text-muted-foreground">
- {t("serverStats.ports.noData")}
- </p>
- </div>
- )}
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/server-stats/widgets/ProcessesWidget.tsx b/src/ui/desktop/apps/features/server-stats/widgets/ProcessesWidget.tsx
deleted file mode 100644
index 7b00d2a6f..000000000
--- a/src/ui/desktop/apps/features/server-stats/widgets/ProcessesWidget.tsx
+++ /dev/null
@@ -1,89 +0,0 @@
-import React from "react";
-import { List, Activity } from "lucide-react";
-import { useTranslation } from "react-i18next";
-import type { ServerMetrics } from "@/ui/main-axios.ts";
-
-interface ProcessesWidgetProps {
- metrics: ServerMetrics | null;
- metricsHistory: ServerMetrics[];
-}
-
-export function ProcessesWidget({ metrics }: ProcessesWidgetProps) {
- const { t } = useTranslation();
-
- const metricsWithProcesses = metrics as ServerMetrics & {
- processes?: {
- total?: number;
- running?: number;
- top?: Array<{
- pid: number;
- cpu: number;
- mem: number;
- command: string;
- user: string;
- }>;
- };
- };
- const processes = metricsWithProcesses?.processes;
- const topProcesses = processes?.top || [];
-
- return (
- <div className="h-full w-full p-4 rounded-lg bg-elevated border border-edge/50 hover:bg-elevated/70 flex flex-col overflow-hidden">
- <div className="flex items-center gap-2 flex-shrink-0 mb-3">
- <List className="h-5 w-5 text-yellow-400" />
- <h3 className="font-semibold text-lg text-foreground">
- {t("serverStats.processes")}
- </h3>
- </div>
-
- <div className="flex items-center justify-between mb-3 pb-2 border-b border-edge/30">
- <div className="text-sm text-muted-foreground">
- {t("serverStats.totalProcesses")}:{" "}
- <span className="text-foreground font-semibold">
- {processes?.total ?? "N/A"}
- </span>
- </div>
- <div className="text-sm text-muted-foreground">
- {t("serverStats.running")}:{" "}
- <span className="text-green-400 font-semibold">
- {processes?.running ?? "N/A"}
- </span>
- </div>
- </div>
-
- <div className="overflow-auto thin-scrollbar flex-1">
- {topProcesses.length === 0 ? (
- <div className="flex flex-col items-center justify-center py-12 text-muted-foreground">
- <Activity className="h-10 w-10 mb-3 opacity-50" />
- <p className="text-sm">{t("serverStats.noProcessesFound")}</p>
- </div>
- ) : (
- <div className="space-y-2">
- {topProcesses.map((proc, index) => (
- <div
- key={index}
- className="p-2.5 rounded-lg bg-canvas/40 hover:bg-canvas/50 border border-edge/30"
- >
- <div className="flex items-center justify-between mb-1.5">
- <span className="text-xs font-mono text-muted-foreground font-medium">
- PID: {proc.pid}
- </span>
- <div className="flex gap-3 text-xs font-medium">
- <span className="text-blue-400">CPU: {proc.cpu}%</span>
- <span className="text-green-400">MEM: {proc.mem}%</span>
- </div>
- </div>
- <div className="text-xs text-foreground font-mono truncate mb-1">
- {proc.command}
- </div>
- <div className="text-xs text-foreground-subtle">
- User: {proc.user}
- </div>
- </div>
- ))}
- </div>
- )}
- </div>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/server-stats/widgets/SystemWidget.tsx b/src/ui/desktop/apps/features/server-stats/widgets/SystemWidget.tsx
deleted file mode 100644
index 1f598484a..000000000
--- a/src/ui/desktop/apps/features/server-stats/widgets/SystemWidget.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-import React from "react";
-import { Server, Info } from "lucide-react";
-import { useTranslation } from "react-i18next";
-import type { ServerMetrics } from "@/ui/main-axios.ts";
-
-interface SystemWidgetProps {
- metrics: ServerMetrics | null;
- metricsHistory: ServerMetrics[];
-}
-
-export function SystemWidget({ metrics }: SystemWidgetProps) {
- const { t } = useTranslation();
-
- const metricsWithSystem = metrics as ServerMetrics & {
- system?: {
- hostname?: string;
- os?: string;
- kernel?: string;
- };
- };
- const system = metricsWithSystem?.system;
-
- return (
- <div className="h-full w-full p-4 rounded-lg bg-elevated border border-edge/50 hover:bg-elevated/70 flex flex-col overflow-hidden">
- <div className="flex items-center gap-2 flex-shrink-0 mb-3">
- <Server className="h-5 w-5 text-purple-400" />
- <h3 className="font-semibold text-lg text-foreground">
- {t("serverStats.systemInfo")}
- </h3>
- </div>
-
- <div className="space-y-4">
- <div className="flex items-start gap-3">
- <Info className="h-4 w-4 text-purple-400 mt-0.5 flex-shrink-0" />
- <div className="min-w-0 flex-1">
- <p className="text-xs text-muted-foreground mb-1.5">
- {t("serverStats.hostname")}
- </p>
- <p className="text-sm text-foreground font-mono truncate font-medium">
- {system?.hostname || "N/A"}
- </p>
- </div>
- </div>
-
- <div className="flex items-start gap-3">
- <Info className="h-4 w-4 text-purple-400 mt-0.5 flex-shrink-0" />
- <div className="min-w-0 flex-1">
- <p className="text-xs text-muted-foreground mb-1.5">
- {t("serverStats.operatingSystem")}
- </p>
- <p className="text-sm text-foreground font-mono truncate font-medium">
- {system?.os || "N/A"}
- </p>
- </div>
- </div>
-
- <div className="flex items-start gap-3">
- <Info className="h-4 w-4 text-purple-400 mt-0.5 flex-shrink-0" />
- <div className="min-w-0 flex-1">
- <p className="text-xs text-muted-foreground mb-1.5">
- {t("serverStats.kernel")}
- </p>
- <p className="text-sm text-foreground font-mono truncate font-medium">
- {system?.kernel || "N/A"}
- </p>
- </div>
- </div>
- </div>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/server-stats/widgets/UptimeWidget.tsx b/src/ui/desktop/apps/features/server-stats/widgets/UptimeWidget.tsx
deleted file mode 100644
index bb1bfdbf7..000000000
--- a/src/ui/desktop/apps/features/server-stats/widgets/UptimeWidget.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import React from "react";
-import { Clock, Activity } from "lucide-react";
-import { useTranslation } from "react-i18next";
-import type { ServerMetrics } from "@/ui/main-axios.ts";
-
-interface UptimeWidgetProps {
- metrics: ServerMetrics | null;
- metricsHistory: ServerMetrics[];
-}
-
-export function UptimeWidget({ metrics }: UptimeWidgetProps) {
- const { t } = useTranslation();
-
- const metricsWithUptime = metrics as ServerMetrics & {
- uptime?: {
- formatted?: string;
- seconds?: number;
- };
- };
- const uptime = metricsWithUptime?.uptime;
-
- return (
- <div className="h-full w-full p-4 rounded-lg bg-elevated border border-edge/50 hover:bg-elevated/70 flex flex-col overflow-hidden">
- <div className="flex items-center gap-2 flex-shrink-0 mb-3">
- <Clock className="h-5 w-5 text-cyan-400" />
- <h3 className="font-semibold text-lg text-foreground">
- {t("serverStats.uptime")}
- </h3>
- </div>
-
- <div className="flex flex-col items-center justify-center flex-1">
- <div className="relative mb-4">
- <div className="w-24 h-24 rounded-full bg-cyan-500/10 flex items-center justify-center">
- <Activity className="h-12 w-12 text-cyan-400" />
- </div>
- </div>
-
- <div className="text-center">
- <div className="text-3xl font-bold text-cyan-400 mb-2">
- {uptime?.formatted || "N/A"}
- </div>
- <div className="text-sm text-muted-foreground">
- {t("serverStats.totalUptime")}
- </div>
- {uptime?.seconds && (
- <div className="text-xs text-foreground-subtle mt-2">
- {Math.floor(uptime.seconds).toLocaleString()}{" "}
- {t("serverStats.seconds")}
- </div>
- )}
- </div>
- </div>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/features/terminal/SudoPasswordPopup.tsx b/src/ui/desktop/apps/features/terminal/SudoPasswordPopup.tsx
deleted file mode 100644
index f2dab957e..000000000
--- a/src/ui/desktop/apps/features/terminal/SudoPasswordPopup.tsx
+++ /dev/null
@@ -1,81 +0,0 @@
-import { useEffect } from "react";
-import { useTranslation } from "react-i18next";
-import { KeyRound } from "lucide-react";
-import { Button } from "@/components/ui/button.tsx";
-
-interface SudoPasswordPopupProps {
- isOpen: boolean;
- hostPassword: string;
- backgroundColor: string;
- onConfirm: (password: string) => void;
- onDismiss: () => void;
-}
-
-export function SudoPasswordPopup({
- isOpen,
- hostPassword,
- backgroundColor,
- onConfirm,
- onDismiss,
-}: SudoPasswordPopupProps) {
- const { t } = useTranslation();
-
- useEffect(() => {
- if (!isOpen) return;
-
- const handleKeyDown = (e: KeyboardEvent) => {
- if (e.key === "Enter") {
- e.preventDefault();
- e.stopPropagation();
- e.stopImmediatePropagation();
- onConfirm(hostPassword);
- } else if (e.key === "Escape") {
- e.preventDefault();
- e.stopPropagation();
- e.stopImmediatePropagation();
- onDismiss();
- }
- };
-
- window.addEventListener("keydown", handleKeyDown, true);
- return () => window.removeEventListener("keydown", handleKeyDown, true);
- }, [isOpen, onConfirm, onDismiss, hostPassword]);
-
- if (!isOpen) return null;
-
- return (
- <div
- className="absolute bottom-4 right-4 z-50 backdrop-blur-sm border border-border rounded-lg shadow-lg p-4 min-w-[280px]"
- style={{ backgroundColor: backgroundColor }}
- >
- <div className="flex items-center gap-3 mb-3">
- <div className="p-2 bg-primary/10 rounded-full">
- <KeyRound className="h-5 w-5 text-primary" />
- </div>
- <div>
- <h4 className="font-medium text-sm">
- {t("terminal.sudoPasswordPopupTitle", "Insert password?")}
- </h4>
- <p className="text-xs text-muted-foreground">
- {t(
- "terminal.sudoPasswordPopupHint",
- "Press Enter to insert, Esc to dismiss",
- )}
- </p>
- </div>
- </div>
- <div className="flex gap-2 justify-end">
- <Button variant="ghost" size="sm" onClick={onDismiss}>
- {t("terminal.sudoPasswordPopupDismiss", "Dismiss")}
- </Button>
- <Button
- variant="default"
- size="sm"
- onClick={() => onConfirm(hostPassword)}
- >
- {t("terminal.sudoPasswordPopupConfirm", "Insert")}
- </Button>
- </div>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/HostManagerApp.tsx b/src/ui/desktop/apps/host-manager/HostManagerApp.tsx
deleted file mode 100644
index 5d5e746fb..000000000
--- a/src/ui/desktop/apps/host-manager/HostManagerApp.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { HostManager } from "@/ui/desktop/apps/host-manager/hosts/HostManager.tsx";
-import React from "react";
-
-const HostManagerApp: React.FC = () => {
- return (
- <div className="w-full h-screen">
- <HostManager isTopbarOpen={false} onSelectView={() => {}} />
- </div>
- );
-};
-
-export default HostManagerApp;
diff --git a/src/ui/desktop/apps/host-manager/credentials/CredentialEditor.tsx b/src/ui/desktop/apps/host-manager/credentials/CredentialEditor.tsx
deleted file mode 100644
index a90349080..000000000
--- a/src/ui/desktop/apps/host-manager/credentials/CredentialEditor.tsx
+++ /dev/null
@@ -1,625 +0,0 @@
-import { zodResolver } from "@hookform/resolvers/zod";
-import { useForm } from "react-hook-form";
-import { z } from "zod";
-
-import { Button } from "@/components/ui/button.tsx";
-import { Form } from "@/components/ui/form.tsx";
-import { ScrollArea } from "@/components/ui/scroll-area.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
-import {
- Tabs,
- TabsContent,
- TabsList,
- TabsTrigger,
-} from "@/components/ui/tabs.tsx";
-import { Alert, AlertDescription } from "@/components/ui/alert.tsx";
-import React, { useEffect, useRef, useState } from "react";
-import { toast } from "sonner";
-import { ArrowLeft } from "lucide-react";
-import {
- createCredential,
- updateCredential,
- getCredentials,
- getCredentialDetails,
- detectKeyType,
- detectPublicKeyType,
-} from "@/ui/main-axios.ts";
-import { useTranslation } from "react-i18next";
-import { oneDark } from "@codemirror/theme-one-dark";
-import { githubLight } from "@uiw/codemirror-theme-github";
-import { useTheme } from "@/components/theme-provider.tsx";
-import type {
- Credential,
- CredentialEditorProps,
- CredentialData,
-} from "../../../../../types";
-import { CredentialGeneralTab } from "./tabs/CredentialGeneralTab";
-import { CredentialAuthenticationTab } from "./tabs/CredentialAuthenticationTab";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
-
-export function CredentialEditor({
- editingCredential,
- onFormSubmit,
- onBack,
-}: CredentialEditorProps) {
- const { t } = useTranslation();
- const { theme: appTheme } = useTheme();
-
- const isDarkMode =
- appTheme === "dark" ||
- (appTheme === "system" &&
- window.matchMedia("(prefers-color-scheme: dark)").matches);
- const editorTheme = isDarkMode ? oneDark : githubLight;
- const [, setCredentials] = useState<Credential[]>([]);
- const [folders, setFolders] = useState<string[]>([]);
- const [, setLoading] = useState(true);
- const [fullCredentialDetails, setFullCredentialDetails] =
- useState<Credential | null>(null);
-
- const [authTab, setAuthTab] = useState<"password" | "key">("password");
- const [detectedKeyType, setDetectedKeyType] = useState<string | null>(null);
- const [keyDetectionLoading, setKeyDetectionLoading] = useState(false);
- const keyDetectionTimeoutRef = useRef<NodeJS.Timeout | null>(null);
- const [activeTab, setActiveTab] = useState("general");
- const [formError, setFormError] = useState<string | null>(null);
- const [isSubmitting, setIsSubmitting] = useState(false);
-
- const [detectedPublicKeyType, setDetectedPublicKeyType] = useState<
- string | null
- >(null);
- const [publicKeyDetectionLoading, setPublicKeyDetectionLoading] =
- useState(false);
- const publicKeyDetectionTimeoutRef = useRef<NodeJS.Timeout | null>(null);
-
- useEffect(() => {
- setFormError(null);
- }, [activeTab]);
-
- useEffect(() => {
- const fetchData = async () => {
- try {
- setLoading(true);
- const credentialsData = await getCredentials();
- setCredentials(credentialsData);
-
- const uniqueFolders = [
- ...new Set(
- credentialsData
- .filter(
- (credential) =>
- credential.folder && credential.folder.trim() !== "",
- )
- .map((credential) => credential.folder!),
- ),
- ].sort() as string[];
-
- setFolders(uniqueFolders);
- } catch {
- // Keep the editor usable even if credentials cannot be loaded.
- } finally {
- setLoading(false);
- }
- };
-
- fetchData();
- }, []);
-
- useEffect(() => {
- const fetchCredentialDetails = async () => {
- if (editingCredential) {
- try {
- const fullDetails = await getCredentialDetails(editingCredential.id);
- setFullCredentialDetails(fullDetails);
- } catch {
- toast.error(t("credentials.failedToFetchCredentialDetails"));
- }
- } else {
- setFullCredentialDetails(null);
- }
- };
-
- fetchCredentialDetails();
- }, [editingCredential, t]);
-
- const formSchema = z
- .object({
- name: z.string().min(1),
- description: z.string().optional(),
- folder: z.string().optional(),
- tags: z.array(z.string().min(1)).default([]),
- authType: z.enum(["password", "key"]),
- username: z.string().optional(),
- password: z.string().optional(),
- key: z.any().optional().nullable(),
- publicKey: z.string().optional(),
- keyPassword: z.string().optional(),
- keyType: z
- .enum([
- "auto",
- "ssh-rsa",
- "ssh-ed25519",
- "ecdsa-sha2-nistp256",
- "ecdsa-sha2-nistp384",
- "ecdsa-sha2-nistp521",
- "ssh-dss",
- "ssh-rsa-sha2-256",
- "ssh-rsa-sha2-512",
- ])
- .optional(),
- })
- .superRefine((data, ctx) => {
- if (data.authType === "password") {
- if (!data.password || data.password.trim() === "") {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: t("credentials.passwordRequired"),
- path: ["password"],
- });
- }
- } else if (data.authType === "key") {
- if (!data.key && !editingCredential) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: t("credentials.sshKeyRequired"),
- path: ["key"],
- });
- }
- }
- });
-
- type FormData = z.infer<typeof formSchema>;
-
- const form = useForm<FormData>({
- resolver: zodResolver(formSchema) as unknown as Parameters<
- typeof useForm<FormData>
- >[0]["resolver"],
- mode: "all",
- defaultValues: {
- name: "",
- description: "",
- folder: "",
- tags: [],
- authType: "password",
- username: "",
- password: "",
- key: null,
- publicKey: "",
- keyPassword: "",
- keyType: "auto",
- },
- });
-
- const watchedFields = form.watch();
-
- const isFormValid = React.useMemo(() => {
- const values = form.getValues();
-
- if (!values.name) return false;
-
- if (authTab === "password") {
- return !!(values.password && values.password.trim() !== "");
- } else if (authTab === "key") {
- if (editingCredential) {
- return true;
- }
- return !!values.key;
- }
-
- return false;
- }, [watchedFields, authTab, editingCredential]);
-
- useEffect(() => {
- const updateAuthFields = async () => {
- form.setValue("authType", authTab, { shouldValidate: true });
-
- if (authTab === "password") {
- form.setValue("key", null, { shouldValidate: true });
- form.setValue("publicKey", "", { shouldValidate: true });
- form.setValue("keyPassword", "", { shouldValidate: true });
- form.setValue("keyType", "auto", { shouldValidate: true });
- } else if (authTab === "key") {
- form.setValue("password", "", { shouldValidate: true });
- }
-
- await form.trigger();
- };
-
- updateAuthFields();
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [authTab]);
-
- useEffect(() => {
- if (editingCredential && fullCredentialDetails) {
- const defaultAuthType = fullCredentialDetails.authType;
- setAuthTab(defaultAuthType);
-
- setTimeout(() => {
- const formData = {
- name: fullCredentialDetails.name || "",
- description: fullCredentialDetails.description || "",
- folder: fullCredentialDetails.folder || "",
- tags: fullCredentialDetails.tags || [],
- authType: defaultAuthType as "password" | "key",
- username: fullCredentialDetails.username || "",
- password: "",
- key: null,
- publicKey: "",
- keyPassword: "",
- keyType: "auto" as const,
- };
-
- if (defaultAuthType === "password") {
- formData.password = fullCredentialDetails.password || "";
- } else if (defaultAuthType === "key") {
- formData.key = fullCredentialDetails.key || "";
- formData.publicKey = fullCredentialDetails.publicKey || "";
- formData.keyPassword = fullCredentialDetails.keyPassword || "";
- formData.keyType =
- (fullCredentialDetails.keyType as string) || ("auto" as const);
- }
-
- form.reset(formData);
- setTagInput("");
- }, 100);
- } else if (!editingCredential) {
- setAuthTab("password");
- form.reset({
- name: "",
- description: "",
- folder: "",
- tags: [],
- authType: "password",
- username: "",
- password: "",
- key: null,
- publicKey: "",
- keyPassword: "",
- keyType: "auto",
- });
- setTagInput("");
- }
- }, [editingCredential?.id, fullCredentialDetails, form]);
-
- useEffect(() => {
- return () => {
- if (keyDetectionTimeoutRef.current) {
- clearTimeout(keyDetectionTimeoutRef.current);
- }
- if (publicKeyDetectionTimeoutRef.current) {
- clearTimeout(publicKeyDetectionTimeoutRef.current);
- }
- };
- }, []);
-
- const handleKeyTypeDetection = async (
- keyValue: string,
- keyPassword?: string,
- ) => {
- if (!keyValue || keyValue.trim() === "") {
- setDetectedKeyType(null);
- return;
- }
-
- setKeyDetectionLoading(true);
- try {
- const result = await detectKeyType(keyValue, keyPassword);
- if (result.success) {
- setDetectedKeyType(result.keyType);
- } else {
- setDetectedKeyType("invalid");
- }
- } catch (error) {
- setDetectedKeyType("error");
- console.error("Key type detection error:", error);
- } finally {
- setKeyDetectionLoading(false);
- }
- };
-
- const debouncedKeyDetection = (keyValue: string, keyPassword?: string) => {
- if (keyDetectionTimeoutRef.current) {
- clearTimeout(keyDetectionTimeoutRef.current);
- }
- keyDetectionTimeoutRef.current = setTimeout(() => {
- handleKeyTypeDetection(keyValue, keyPassword);
- }, 1000);
- };
-
- const handlePublicKeyTypeDetection = async (publicKeyValue: string) => {
- if (!publicKeyValue || publicKeyValue.trim() === "") {
- setDetectedPublicKeyType(null);
- return;
- }
-
- setPublicKeyDetectionLoading(true);
- try {
- const result = await detectPublicKeyType(publicKeyValue);
- if (result.success) {
- setDetectedPublicKeyType(result.keyType);
- } else {
- setDetectedPublicKeyType("invalid");
- console.warn("Public key detection failed:", result.error);
- }
- } catch (error) {
- setDetectedPublicKeyType("error");
- console.error("Public key type detection error:", error);
- } finally {
- setPublicKeyDetectionLoading(false);
- }
- };
-
- const debouncedPublicKeyDetection = (publicKeyValue: string) => {
- if (publicKeyDetectionTimeoutRef.current) {
- clearTimeout(publicKeyDetectionTimeoutRef.current);
- }
- publicKeyDetectionTimeoutRef.current = setTimeout(() => {
- handlePublicKeyTypeDetection(publicKeyValue);
- }, 1000);
- };
-
- const getFriendlyKeyTypeName = (keyType: string): string => {
- const keyTypeMap: Record<string, string> = {
- "ssh-rsa": t("credentials.keyTypeRSA"),
- "ssh-ed25519": t("credentials.keyTypeEd25519"),
- "ecdsa-sha2-nistp256": t("credentials.keyTypeEcdsaP256"),
- "ecdsa-sha2-nistp384": t("credentials.keyTypeEcdsaP384"),
- "ecdsa-sha2-nistp521": t("credentials.keyTypeEcdsaP521"),
- "ssh-dss": t("credentials.keyTypeDsa"),
- "rsa-sha2-256": t("credentials.keyTypeRsaSha256"),
- "rsa-sha2-512": t("credentials.keyTypeRsaSha512"),
- invalid: t("credentials.invalidKey"),
- error: t("credentials.detectionError"),
- unknown: t("credentials.unknown"),
- };
- return keyTypeMap[keyType] || keyType;
- };
-
- const onSubmit = async (data: FormData) => {
- try {
- setIsSubmitting(true);
- setFormError(null);
-
- if (!data.name || data.name.trim() === "") {
- data.name = data.username || "Unnamed Credential";
- }
-
- const submitData: CredentialData = {
- name: data.name,
- description: data.description,
- folder: data.folder,
- tags: data.tags,
- authType: data.authType,
- username: data.username || undefined,
- keyType: data.keyType,
- };
-
- submitData.password = null;
- submitData.key = null;
- submitData.publicKey = null;
- submitData.keyPassword = null;
- submitData.keyType = null;
-
- if (data.authType === "password") {
- submitData.password = data.password;
- } else if (data.authType === "key") {
- submitData.key = data.key;
- submitData.publicKey = data.publicKey;
- submitData.keyPassword = data.keyPassword;
- submitData.keyType = data.keyType;
- }
-
- if (editingCredential) {
- await updateCredential(editingCredential.id, submitData);
- toast.success(
- t("credentials.credentialUpdatedSuccessfully", { name: data.name }),
- );
- } else {
- await createCredential(submitData);
- toast.success(
- t("credentials.credentialAddedSuccessfully", { name: data.name }),
- );
- }
-
- if (onFormSubmit) {
- onFormSubmit();
- }
-
- window.dispatchEvent(new CustomEvent("credentials:changed"));
-
- form.reset();
- } catch (error) {
- console.error("Credential save error:", error);
- if (error instanceof Error) {
- toast.error(error.message);
- } else {
- toast.error(t("credentials.failedToSaveCredential"));
- }
- } finally {
- setIsSubmitting(false);
- }
- };
-
- const handleFormError = () => {
- const errors = form.formState.errors;
-
- if (
- errors.name ||
- errors.username ||
- errors.description ||
- errors.folder ||
- errors.tags
- ) {
- setActiveTab("general");
- } else if (
- errors.password ||
- errors.key ||
- errors.publicKey ||
- errors.keyPassword ||
- errors.keyType
- ) {
- setActiveTab("authentication");
- }
- };
-
- const [tagInput, setTagInput] = useState("");
-
- const [folderDropdownOpen, setFolderDropdownOpen] = useState(false);
- const folderInputRef = useRef<HTMLInputElement>(null);
- const folderDropdownRef = useRef<HTMLDivElement>(null);
-
- const folderValue = form.watch("folder");
- const filteredFolders = React.useMemo(() => {
- if (!folderValue) return folders;
- return folders.filter((f) =>
- f.toLowerCase().includes(folderValue.toLowerCase()),
- );
- }, [folderValue, folders]);
-
- const handleFolderClick = (folder: string) => {
- form.setValue("folder", folder);
- setFolderDropdownOpen(false);
- };
-
- useEffect(() => {
- function handleClickOutside(event: MouseEvent) {
- if (
- folderDropdownRef.current &&
- !folderDropdownRef.current.contains(event.target as Node) &&
- folderInputRef.current &&
- !folderInputRef.current.contains(event.target as Node)
- ) {
- setFolderDropdownOpen(false);
- }
- }
-
- if (folderDropdownOpen) {
- document.addEventListener("mousedown", handleClickOutside);
- } else {
- document.removeEventListener("mousedown", handleClickOutside);
- }
-
- return () => {
- document.removeEventListener("mousedown", handleClickOutside);
- };
- }, [folderDropdownOpen]);
-
- return (
- <div
- className="flex-1 flex flex-col h-full min-h-0 w-full relative"
- key={editingCredential?.id || "new"}
- >
- <SimpleLoader
- visible={isSubmitting}
- message={
- editingCredential
- ? t("credentials.updatingCredential")
- : t("credentials.savingCredential")
- }
- backgroundColor="var(--bg-base)"
- />
- <Form {...form}>
- <form
- onSubmit={form.handleSubmit(onSubmit, handleFormError)}
- className="flex flex-col flex-1 min-h-0 h-full"
- >
- <ScrollArea className="flex-1 min-h-0 w-full my-1 pb-2">
- {formError && (
- <Alert variant="destructive" className="mb-4">
- <AlertDescription>{formError}</AlertDescription>
- </Alert>
- )}
- <div className="flex items-center gap-2 mb-3">
- {onBack && (
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={onBack}
- className="flex-shrink-0"
- >
- <ArrowLeft className="h-4 w-4 mr-2" />
- {t("common.back")}
- </Button>
- )}
- <h3 className="text-lg font-semibold flex-shrink-0">
- {editingCredential
- ? t("credentials.editCredential")
- : t("credentials.addCredential")}
- </h3>
- </div>
- <Tabs
- value={activeTab}
- onValueChange={setActiveTab}
- className="w-full"
- >
- <TabsList className="bg-button border border-edge-medium">
- <TabsTrigger
- value="general"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- {t("credentials.general")}
- </TabsTrigger>
- <TabsTrigger
- value="authentication"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- {t("credentials.authentication")}
- </TabsTrigger>
- </TabsList>
- <TabsContent value="general" className="pt-2">
- <CredentialGeneralTab
- form={form}
- folders={folders}
- tagInput={tagInput}
- setTagInput={setTagInput}
- folderDropdownOpen={folderDropdownOpen}
- setFolderDropdownOpen={setFolderDropdownOpen}
- folderInputRef={folderInputRef}
- folderDropdownRef={folderDropdownRef}
- filteredFolders={filteredFolders}
- handleFolderClick={handleFolderClick}
- />
- </TabsContent>
- <TabsContent value="authentication">
- <CredentialAuthenticationTab
- form={form}
- authTab={authTab}
- setAuthTab={setAuthTab}
- detectedKeyType={detectedKeyType}
- setDetectedKeyType={setDetectedKeyType}
- keyDetectionLoading={keyDetectionLoading}
- setKeyDetectionLoading={setKeyDetectionLoading}
- detectedPublicKeyType={detectedPublicKeyType}
- setDetectedPublicKeyType={setDetectedPublicKeyType}
- publicKeyDetectionLoading={publicKeyDetectionLoading}
- setPublicKeyDetectionLoading={setPublicKeyDetectionLoading}
- keyDetectionTimeoutRef={keyDetectionTimeoutRef}
- publicKeyDetectionTimeoutRef={publicKeyDetectionTimeoutRef}
- editorTheme={editorTheme}
- debouncedKeyDetection={debouncedKeyDetection}
- debouncedPublicKeyDetection={debouncedPublicKeyDetection}
- getFriendlyKeyTypeName={getFriendlyKeyTypeName}
- />
- </TabsContent>
- </Tabs>
- </ScrollArea>
- <footer className="shrink-0 w-full pb-0">
- <Separator className="p-0.25" />
- {!isSubmitting && (
- <Button
- className="translate-y-2"
- type="submit"
- variant="outline"
- disabled={!isFormValid}
- >
- {editingCredential
- ? t("credentials.updateCredential")
- : t("credentials.addCredential")}
- </Button>
- )}
- </footer>
- </form>
- </Form>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/credentials/CredentialSelector.tsx b/src/ui/desktop/apps/host-manager/credentials/CredentialSelector.tsx
deleted file mode 100644
index fab271097..000000000
--- a/src/ui/desktop/apps/host-manager/credentials/CredentialSelector.tsx
+++ /dev/null
@@ -1,206 +0,0 @@
-import React, { useState, useEffect, useRef } from "react";
-import { Button } from "@/components/ui/button.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { FormControl, FormItem, FormLabel } from "@/components/ui/form.tsx";
-import { getCredentials } from "@/ui/main-axios.ts";
-import { useTranslation } from "react-i18next";
-import type { Credential } from "../../../../../types";
-import { toast } from "sonner";
-
-interface CredentialSelectorProps {
- value?: number | null;
- onValueChange: (credentialId: number | null) => void;
- onCredentialSelect?: (credential: Credential | null) => void;
-}
-
-export function CredentialSelector({
- value,
- onValueChange,
- onCredentialSelect,
-}: CredentialSelectorProps) {
- const { t } = useTranslation();
- const [credentials, setCredentials] = useState<Credential[]>([]);
- const [loading, setLoading] = useState(true);
- const [dropdownOpen, setDropdownOpen] = useState(false);
- const [searchQuery, setSearchQuery] = useState("");
-
- const buttonRef = useRef<HTMLButtonElement>(null);
- const dropdownRef = useRef<HTMLDivElement>(null);
-
- useEffect(() => {
- const fetchCredentials = async () => {
- try {
- setLoading(true);
- const data = await getCredentials();
- const credentialsArray = Array.isArray(data)
- ? data
- : data.credentials || data.data || [];
- setCredentials(credentialsArray);
- } catch {
- toast.error(t("credentials.failedToFetchCredentials"));
- setCredentials([]);
- } finally {
- setLoading(false);
- }
- };
-
- fetchCredentials();
- }, []);
-
- useEffect(() => {
- function handleClickOutside(event: MouseEvent) {
- if (
- dropdownRef.current &&
- !dropdownRef.current.contains(event.target as Node) &&
- buttonRef.current &&
- !buttonRef.current.contains(event.target as Node)
- ) {
- setDropdownOpen(false);
- }
- }
-
- if (dropdownOpen) {
- document.addEventListener("mousedown", handleClickOutside);
- } else {
- document.removeEventListener("mousedown", handleClickOutside);
- }
-
- return () => {
- document.removeEventListener("mousedown", handleClickOutside);
- };
- }, [dropdownOpen]);
-
- const selectedCredential = credentials.find((c) => c.id === value);
-
- const filteredCredentials = credentials.filter((credential) => {
- if (!searchQuery) return true;
- const searchLower = searchQuery.toLowerCase();
- return (
- credential.name.toLowerCase().includes(searchLower) ||
- credential.username.toLowerCase().includes(searchLower) ||
- (credential.folder &&
- credential.folder.toLowerCase().includes(searchLower))
- );
- });
-
- const handleCredentialSelect = (credential: Credential) => {
- onValueChange(credential.id);
- if (onCredentialSelect) {
- onCredentialSelect(credential);
- }
- setDropdownOpen(false);
- setSearchQuery("");
- };
-
- return (
- <FormItem>
- <FormLabel>{t("hosts.selectCredential")}</FormLabel>
- <FormControl>
- <div className="relative">
- <Button
- ref={buttonRef}
- type="button"
- variant="outline"
- className="w-full justify-between text-left rounded-lg px-3 py-2 bg-muted/50 focus:bg-background focus:ring-1 focus:ring-ring border border-border text-foreground transition-all duration-200"
- onClick={() => setDropdownOpen(!dropdownOpen)}
- >
- {loading ? (
- t("common.loading")
- ) : value === "existing_credential" ? (
- <div className="flex items-center justify-between w-full">
- <div>
- <span className="font-medium">
- {t("hosts.existingCredential")}
- </span>
- </div>
- </div>
- ) : selectedCredential ? (
- <div className="flex items-center justify-between w-full">
- <div>
- <span className="font-medium">{selectedCredential.name}</span>
- <span className="text-sm text-muted-foreground ml-2">
- ({selectedCredential.username} •{" "}
- {selectedCredential.authType})
- </span>
- </div>
- </div>
- ) : (
- t("hosts.selectCredentialPlaceholder")
- )}
- <svg
- className="h-4 w-4"
- fill="none"
- stroke="currentColor"
- viewBox="0 0 24 24"
- >
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth={2}
- d="M19 9l-7 7-7-7"
- />
- </svg>
- </Button>
-
- {dropdownOpen && (
- <div
- ref={dropdownRef}
- className="absolute top-full left-0 z-50 mt-1 w-full bg-card border border-border rounded-lg shadow-lg max-h-80 overflow-hidden backdrop-blur-sm"
- >
- <div className="p-2 border-b border-border">
- <Input
- placeholder={t("credentials.searchCredentials")}
- value={searchQuery}
- onChange={(e) => setSearchQuery(e.target.value)}
- className="h-8"
- />
- </div>
-
- <div className="max-h-60 overflow-y-auto thin-scrollbar p-2">
- {loading ? (
- <div className="p-3 text-center text-sm text-muted-foreground">
- {t("common.loading")}
- </div>
- ) : filteredCredentials.length === 0 ? (
- <div className="p-3 text-center text-sm text-muted-foreground">
- {searchQuery
- ? t("credentials.noCredentialsMatchFilters")
- : t("credentials.noCredentialsYet")}
- </div>
- ) : (
- <div className="grid grid-cols-1 gap-2.5">
- {filteredCredentials.map((credential) => (
- <Button
- key={credential.id}
- type="button"
- variant="ghost"
- size="sm"
- className={`w-full justify-start text-left rounded-lg px-3 py-7 hover:bg-muted focus:bg-muted focus:outline-none transition-colors duration-200 ${
- credential.id === value ? "bg-muted" : ""
- }`}
- onClick={() => handleCredentialSelect(credential)}
- >
- <div className="w-full">
- <div className="flex items-center justify-between">
- <span className="font-medium">
- {credential.name}
- </span>
- </div>
- <div className="text-xs text-muted-foreground mt-0.5">
- {credential.username} • {credential.authType}
- {credential.description &&
- ` • ${credential.description}`}
- </div>
- </div>
- </Button>
- ))}
- </div>
- )}
- </div>
- </div>
- )}
- </div>
- </FormControl>
- </FormItem>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/credentials/CredentialViewer.tsx b/src/ui/desktop/apps/host-manager/credentials/CredentialViewer.tsx
deleted file mode 100644
index 56032cd01..000000000
--- a/src/ui/desktop/apps/host-manager/credentials/CredentialViewer.tsx
+++ /dev/null
@@ -1,528 +0,0 @@
-import React, { useState, useEffect } from "react";
-import { Button } from "@/components/ui/button.tsx";
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card.tsx";
-import { Badge } from "@/components/ui/badge.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
-import { ScrollArea } from "@/components/ui/scroll-area.tsx";
-import {
- Sheet,
- SheetContent,
- SheetFooter,
- SheetHeader,
- SheetTitle,
-} from "@/components/ui/sheet.tsx";
-import {
- Key,
- User,
- Calendar,
- Hash,
- Folder,
- Edit3,
- Copy,
- Shield,
- Clock,
- Server,
- Eye,
- EyeOff,
- AlertTriangle,
- CheckCircle,
- FileText,
-} from "lucide-react";
-import { getCredentialDetails, getCredentialHosts } from "@/ui/main-axios.ts";
-import { toast } from "sonner";
-import { useTranslation } from "react-i18next";
-import type {
- Credential,
- HostInfo,
- CredentialViewerProps,
-} from "../../../types/index.js";
-
-const CredentialViewer: React.FC<CredentialViewerProps> = ({
- credential,
- onClose,
- onEdit,
-}) => {
- const { t } = useTranslation();
- const [credentialDetails, setCredentialDetails] = useState<Credential | null>(
- null,
- );
- const [hostsUsing, setHostsUsing] = useState<HostInfo[]>([]);
- const [loading, setLoading] = useState(true);
- const [showSensitive, setShowSensitive] = useState<Record<string, boolean>>(
- {},
- );
- const [activeTab, setActiveTab] = useState<"overview" | "security" | "usage">(
- "overview",
- );
-
- useEffect(() => {
- fetchCredentialDetails();
- fetchHostsUsing();
- }, [credential.id]);
-
- const fetchCredentialDetails = async () => {
- try {
- const response = await getCredentialDetails(credential.id);
- setCredentialDetails(response);
- } catch {
- toast.error(t("credentials.failedToFetchCredentialDetails"));
- }
- };
-
- const fetchHostsUsing = async () => {
- try {
- const response = await getCredentialHosts(credential.id);
- setHostsUsing(response);
- } catch {
- toast.error(t("credentials.failedToFetchHostsUsing"));
- } finally {
- setLoading(false);
- }
- };
-
- const toggleSensitiveVisibility = (field: string) => {
- setShowSensitive((prev) => ({
- ...prev,
- [field]: !prev[field],
- }));
- };
-
- const copyToClipboard = async (text: string, fieldName: string) => {
- try {
- await navigator.clipboard.writeText(text);
- toast.success(t("copiedToClipboard", { field: fieldName }));
- } catch {
- toast.error(t("credentials.failedToCopy"));
- }
- };
-
- const formatDate = (dateString: string) => {
- return new Date(dateString).toLocaleString();
- };
-
- const getAuthIcon = (authType: string) => {
- return authType === "password" ? (
- <Key className="h-5 w-5 text-foreground-subtle" />
- ) : (
- <Shield className="h-5 w-5 text-foreground-subtle" />
- );
- };
-
- const renderSensitiveField = (
- value: string | undefined,
- fieldName: string,
- label: string,
- isMultiline = false,
- ) => {
- if (!value) return null;
-
- const isVisible = showSensitive[fieldName];
-
- return (
- <div className="space-y-2">
- <div className="flex items-center justify-between">
- <label className="text-sm font-medium text-foreground-secondary">
- {label}
- </label>
- <div className="flex items-center space-x-2">
- <Button
- variant="ghost"
- size="sm"
- onClick={() => toggleSensitiveVisibility(fieldName)}
- >
- {isVisible ? (
- <EyeOff className="h-4 w-4" />
- ) : (
- <Eye className="h-4 w-4" />
- )}
- </Button>
- <Button
- variant="ghost"
- size="sm"
- onClick={() => copyToClipboard(value, label)}
- >
- <Copy className="h-4 w-4" />
- </Button>
- </div>
- </div>
- <div
- className={`p-3 rounded-md bg-surface ${isMultiline ? "" : "min-h-[2.5rem]"}`}
- >
- {isVisible ? (
- <pre
- className={`text-sm ${isMultiline ? "whitespace-pre-wrap" : "whitespace-nowrap"} font-mono`}
- >
- {value}
- </pre>
- ) : (
- <div className="text-sm text-foreground-subtle">
- {"•".repeat(isMultiline ? 50 : 20)}
- </div>
- )}
- </div>
- </div>
- );
- };
-
- if (loading || !credentialDetails) {
- return (
- <Sheet open={true} onOpenChange={onClose}>
- <SheetContent className="w-[600px] max-w-[50vw]">
- <div className="flex items-center justify-center h-64">
- <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-foreground-subtle"></div>
- </div>
- </SheetContent>
- </Sheet>
- );
- }
-
- return (
- <Sheet open={true} onOpenChange={onClose}>
- <SheetContent className="w-[600px] max-w-[50vw] overflow-y-auto thin-scrollbar">
- <SheetHeader className="space-y-6 pb-8">
- <SheetTitle className="flex items-center space-x-4">
- <div className="p-2 rounded-lg bg-surface">
- {getAuthIcon(credentialDetails.authType)}
- </div>
- <div className="flex-1">
- <div className="text-xl font-semibold">
- {credentialDetails.name}
- </div>
- <div className="text-sm font-normal text-foreground-subtle mt-1">
- {credentialDetails.description}
- </div>
- </div>
- <div className="flex items-center space-x-2">
- <Badge variant="outline" className="text-foreground-subtle">
- {credentialDetails.authType}
- </Badge>
- {credentialDetails.keyType && (
- <Badge
- variant="secondary"
- className="bg-surface text-foreground-secondary"
- >
- {credentialDetails.keyType}
- </Badge>
- )}
- </div>
- </SheetTitle>
- </SheetHeader>
-
- <div className="space-y-10">
- <div className="flex space-x-2 p-2 bg-surface border border-border rounded-lg">
- <Button
- variant={activeTab === "overview" ? "default" : "ghost"}
- size="sm"
- onClick={() => setActiveTab("overview")}
- className="flex-1 h-10"
- >
- <FileText className="h-4 w-4 mr-2" />
- {t("credentials.overview")}
- </Button>
- <Button
- variant={activeTab === "security" ? "default" : "ghost"}
- size="sm"
- onClick={() => setActiveTab("security")}
- className="flex-1 h-10"
- >
- <Shield className="h-4 w-4 mr-2" />
- {t("credentials.security")}
- </Button>
- <Button
- variant={activeTab === "usage" ? "default" : "ghost"}
- size="sm"
- onClick={() => setActiveTab("usage")}
- className="flex-1 h-10"
- >
- <Server className="h-4 w-4 mr-2" />
- {t("credentials.usage")}
- </Button>
- </div>
-
- {activeTab === "overview" && (
- <div className="grid gap-10 lg:grid-cols-2">
- <Card className="border-border">
- <CardHeader className="pb-8">
- <CardTitle className="text-lg font-semibold">
- {t("credentials.basicInformation")}
- </CardTitle>
- </CardHeader>
- <CardContent className="space-y-8">
- <div className="flex items-center space-x-5">
- <div className="p-2 rounded-lg bg-surface">
- <User className="h-4 w-4 text-foreground-subtle" />
- </div>
- <div>
- <div className="text-sm text-foreground-subtle">
- {t("common.username")}
- </div>
- <div className="font-medium text-foreground">
- {credentialDetails.username}
- </div>
- </div>
- </div>
-
- {credentialDetails.folder && (
- <div className="flex items-center space-x-4">
- <Folder className="h-4 w-4 text-foreground-subtle" />
- <div>
- <div className="text-sm text-foreground-subtle">
- {t("common.folder")}
- </div>
- <div className="font-medium">
- {credentialDetails.folder}
- </div>
- </div>
- </div>
- )}
-
- {credentialDetails.tags.length > 0 && (
- <div className="flex items-start space-x-4">
- <Hash className="h-4 w-4 text-foreground-subtle mt-1" />
- <div className="flex-1">
- <div className="text-sm text-foreground-subtle mb-3">
- {t("hosts.tags")}
- </div>
- <div className="flex flex-wrap gap-2">
- {credentialDetails.tags.map((tag, index) => (
- <Badge
- key={index}
- variant="outline"
- className="text-xs"
- >
- {tag}
- </Badge>
- ))}
- </div>
- </div>
- </div>
- )}
-
- <Separator />
-
- <div className="flex items-center space-x-4">
- <Calendar className="h-4 w-4 text-foreground-subtle" />
- <div>
- <div className="text-sm text-foreground-subtle">
- {t("credentials.created")}
- </div>
- <div className="font-medium">
- {formatDate(credentialDetails.createdAt)}
- </div>
- </div>
- </div>
-
- <div className="flex items-center space-x-4">
- <Calendar className="h-4 w-4 text-foreground-subtle" />
- <div>
- <div className="text-sm text-foreground-subtle">
- {t("credentials.lastModified")}
- </div>
- <div className="font-medium">
- {formatDate(credentialDetails.updatedAt)}
- </div>
- </div>
- </div>
- </CardContent>
- </Card>
-
- <Card>
- <CardHeader>
- <CardTitle className="text-lg">
- {t("credentials.usageStatistics")}
- </CardTitle>
- </CardHeader>
- <CardContent className="space-y-6">
- <div className="text-center p-6 bg-surface rounded-lg">
- <div className="text-3xl font-bold text-foreground-subtle">
- {credentialDetails.usageCount}
- </div>
- <div className="text-sm text-foreground-subtle">
- {t("credentials.timesUsed")}
- </div>
- </div>
-
- {credentialDetails.lastUsed && (
- <div className="flex items-center space-x-4 p-4 bg-surface rounded-lg">
- <Clock className="h-5 w-5 text-foreground-subtle" />
- <div>
- <div className="text-sm text-foreground-subtle">
- {t("credentials.lastUsed")}
- </div>
- <div className="font-medium">
- {formatDate(credentialDetails.lastUsed)}
- </div>
- </div>
- </div>
- )}
-
- <div className="flex items-center space-x-4 p-4 bg-surface rounded-lg">
- <Server className="h-5 w-5 text-foreground-subtle" />
- <div>
- <div className="text-sm text-foreground-subtle">
- {t("credentials.connectedHosts")}
- </div>
- <div className="font-medium">{hostsUsing.length}</div>
- </div>
- </div>
- </CardContent>
- </Card>
- </div>
- )}
-
- {activeTab === "security" && (
- <Card>
- <CardHeader>
- <CardTitle className="text-lg flex items-center space-x-2">
- <Shield className="h-5 w-5 text-foreground-subtle" />
- <span>{t("credentials.securityDetails")}</span>
- </CardTitle>
- <CardDescription>
- {t("credentials.securityDetailsDescription")}
- </CardDescription>
- </CardHeader>
- <CardContent className="space-y-6">
- <div className="flex items-center space-x-4 p-6 bg-surface rounded-lg">
- <CheckCircle className="h-6 w-6 text-foreground-subtle" />
- <div>
- <div className="font-medium text-foreground">
- {t("credentials.credentialSecured")}
- </div>
- <div className="text-sm text-foreground-secondary">
- {t("credentials.credentialSecuredDescription")}
- </div>
- </div>
- </div>
-
- {credentialDetails.authType === "password" && (
- <div>
- <h3 className="font-semibold mb-4">
- {t("credentials.passwordAuthentication")}
- </h3>
- {renderSensitiveField(
- credentialDetails.password,
- "password",
- t("common.password"),
- )}
- </div>
- )}
-
- {credentialDetails.authType === "key" && (
- <div className="space-y-6">
- <h3 className="font-semibold mb-2">
- {t("credentials.keyAuthentication")}
- </h3>
-
- <div className="grid gap-6 md:grid-cols-2">
- <div>
- <div className="text-sm font-medium text-foreground-secondary mb-3">
- {t("credentials.keyType")}
- </div>
- <Badge variant="outline" className="text-sm">
- {credentialDetails.keyType?.toUpperCase() ||
- t("unknown").toUpperCase()}
- </Badge>
- </div>
- </div>
-
- {renderSensitiveField(
- credentialDetails.key,
- "key",
- t("credentials.privateKey"),
- true,
- )}
-
- {credentialDetails.keyPassword &&
- renderSensitiveField(
- credentialDetails.keyPassword,
- "keyPassword",
- t("credentials.keyPassphrase"),
- )}
- </div>
- )}
-
- <div className="flex items-start space-x-4 p-6 bg-surface rounded-lg">
- <AlertTriangle className="h-5 w-5 text-foreground-subtle mt-0.5" />
- <div className="text-sm">
- <div className="font-medium text-foreground mb-2">
- {t("credentials.securityReminder")}
- </div>
- <div className="text-foreground-secondary">
- {t("credentials.securityReminderText")}
- </div>
- </div>
- </div>
- </CardContent>
- </Card>
- )}
-
- {activeTab === "usage" && (
- <Card>
- <CardHeader>
- <CardTitle className="text-lg flex items-center space-x-2">
- <Server className="h-5 w-5 text-foreground-subtle" />
- <span>{t("credentials.hostsUsingCredential")}</span>
- <Badge variant="secondary">{hostsUsing.length}</Badge>
- </CardTitle>
- </CardHeader>
- <CardContent>
- {hostsUsing.length === 0 ? (
- <div className="text-center py-10 text-foreground-subtle">
- <Server className="h-12 w-12 mx-auto mb-6 text-foreground-subtle" />
- <p>{t("credentials.noHostsUsingCredential")}</p>
- </div>
- ) : (
- <ScrollArea className="h-64">
- <div className="space-y-3">
- {hostsUsing.map((host) => (
- <div
- key={host.id}
- className="flex items-center justify-between p-4 border rounded-lg hover:bg-surface"
- >
- <div className="flex items-center space-x-3">
- <div className="p-2 bg-surface rounded">
- <Server className="h-4 w-4 text-foreground-subtle" />
- </div>
- <div>
- <div className="font-medium">
- {host.name || `${host.ip}:${host.port}`}
- </div>
- <div className="text-sm text-foreground-subtle">
- {host.ip}:{host.port}
- </div>
- </div>
- </div>
- <div className="text-right text-sm text-foreground-subtle">
- {formatDate(host.createdAt)}
- </div>
- </div>
- ))}
- </div>
- </ScrollArea>
- )}
- </CardContent>
- </Card>
- )}
- </div>
-
- <SheetFooter>
- <Button variant="outline" onClick={onClose}>
- {t("common.close")}
- </Button>
- <Button onClick={onEdit}>
- <Edit3 className="h-4 w-4 mr-2" />
- {t("credentials.editCredential")}
- </Button>
- </SheetFooter>
- </SheetContent>
- </Sheet>
- );
-};
-
-export default CredentialViewer;
diff --git a/src/ui/desktop/apps/host-manager/credentials/CredentialsManager.tsx b/src/ui/desktop/apps/host-manager/credentials/CredentialsManager.tsx
deleted file mode 100644
index f240e4455..000000000
--- a/src/ui/desktop/apps/host-manager/credentials/CredentialsManager.tsx
+++ /dev/null
@@ -1,1217 +0,0 @@
-import React, { useState, useEffect, useMemo, useRef } from "react";
-import { Button } from "@/components/ui/button.tsx";
-import { Badge } from "@/components/ui/badge.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { ScrollArea } from "@/components/ui/scroll-area.tsx";
-import {
- Accordion,
- AccordionContent,
- AccordionItem,
- AccordionTrigger,
-} from "@/components/ui/accordion.tsx";
-import { Sheet, SheetContent } from "@/components/ui/sheet.tsx";
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "@/components/ui/tooltip.tsx";
-import {
- Popover,
- PopoverContent,
- PopoverTrigger,
-} from "@/components/ui/popover.tsx";
-import {
- Command,
- CommandEmpty,
- CommandGroup,
- CommandInput,
- CommandItem,
-} from "@/components/ui/command.tsx";
-import {
- Search,
- Key,
- Folder,
- Edit,
- Trash2,
- Shield,
- Tag,
- Info,
- FolderMinus,
- Pencil,
- X,
- Check,
- Upload,
- Server,
- User,
- ChevronsUpDown,
- Terminal,
- Copy,
- Plus,
- RefreshCw,
-} from "lucide-react";
-import { cn } from "@/lib/utils.ts";
-import {
- getCredentials,
- deleteCredential,
- updateCredential,
- renameCredentialFolder,
- deployCredentialToHost,
- getSSHHosts,
-} from "@/ui/main-axios.ts";
-import { toast } from "sonner";
-import { useTranslation } from "react-i18next";
-import { useConfirmation } from "@/hooks/use-confirmation.ts";
-import CredentialViewer from "./CredentialViewer.tsx";
-import type { Credential, CredentialsManagerProps } from "../../../../../types";
-
-export function CredentialsManager({
- onEditCredential,
- onAddCredential,
-}: CredentialsManagerProps) {
- const { t } = useTranslation();
- const { confirmWithToast } = useConfirmation();
- const [credentials, setCredentials] = useState<Credential[]>([]);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState<string | null>(null);
- const [searchQuery, setSearchQuery] = useState("");
- const [showViewer, setShowViewer] = useState(false);
- const [viewingCredential] = useState<Credential | null>(null);
- const [draggedCredential, setDraggedCredential] = useState<Credential | null>(
- null,
- );
- const [dragOverFolder, setDragOverFolder] = useState<string | null>(null);
- const [editingFolder, setEditingFolder] = useState<string | null>(null);
- const [editingFolderName, setEditingFolderName] = useState("");
- const [operationLoading, setOperationLoading] = useState(false);
- const [showDeployDialog, setShowDeployDialog] = useState(false);
- const [deployingCredential, setDeployingCredential] =
- useState<Credential | null>(null);
- const [availableHosts, setAvailableHosts] = useState<
- Array<{
- id: number;
- name: string;
- ip: string;
- port: number;
- username: string;
- }>
- >([]);
- const [selectedHostId, setSelectedHostId] = useState<string>("");
- const [deployLoading, setDeployLoading] = useState(false);
- const [refreshing, setRefreshing] = useState(false);
- const [hostComboboxOpen, setHostComboboxOpen] = useState(false);
- const [showCopyCommandDialog, setShowCopyCommandDialog] = useState(false);
- const [copyCommandCredential, setCopyCommandCredential] =
- useState<Credential | null>(null);
- const dragCounter = useRef(0);
-
- useEffect(() => {
- fetchCredentials();
- fetchHosts();
- }, []);
-
- useEffect(() => {
- if (showDeployDialog) {
- setHostComboboxOpen(false);
- setSelectedHostId("");
- }
- }, [showDeployDialog]);
-
- const fetchHosts = async () => {
- try {
- const hosts = await getSSHHosts();
- setAvailableHosts(hosts);
- } catch (err) {
- console.error("Failed to fetch hosts:", err);
- }
- };
-
- const fetchCredentials = async (options: { showLoading?: boolean } = {}) => {
- const { showLoading = true } = options;
- try {
- if (showLoading) setLoading(true);
- const data = await getCredentials();
- setCredentials(data);
- setError(null);
- } catch {
- setError(t("credentials.failedToFetchCredentials"));
- } finally {
- if (showLoading) setLoading(false);
- }
- };
-
- const handleRefreshCredentials = async () => {
- setRefreshing(true);
- try {
- await Promise.all([
- fetchCredentials({ showLoading: false }),
- fetchHosts(),
- ]);
- } finally {
- setRefreshing(false);
- }
- };
-
- const handleEdit = (credential: Credential) => {
- if (onEditCredential) {
- onEditCredential(credential);
- }
- };
-
- const handleDeploy = (credential: Credential) => {
- if (credential.authType !== "key") {
- toast.error(t("credentials.keyBasedOnlyForDeployment"));
- return;
- }
- if (!credential.publicKey) {
- toast.error(t("credentials.publicKeyRequiredForDeployment"));
- return;
- }
- setDeployingCredential(credential);
- setSelectedHostId("");
- setHostComboboxOpen(false);
- setShowDeployDialog(true);
- };
-
- const handleCopyCommand = (credential: Credential) => {
- if (credential.authType !== "key") {
- toast.error(t("credentials.keyBasedOnlyForDeployment"));
- return;
- }
- if (!credential.publicKey) {
- toast.error(t("credentials.publicKeyRequiredForDeployment"));
- return;
- }
- setCopyCommandCredential(credential);
- setShowCopyCommandDialog(true);
- };
-
- const getDeployCommand = (credential: Credential): string => {
- const publicKey = credential.publicKey?.trim() || "";
- const comment = `${credential.name || credential.username}@Termix`;
- const keyWithComment = publicKey.includes(" ")
- ? `${publicKey.split(" ").slice(0, 2).join(" ")} ${comment}`
- : `${publicKey} ${comment}`;
- return `mkdir -p ~/.ssh && chmod 700 ~/.ssh && echo "${keyWithComment}" >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys`;
- };
-
- const copyDeployCommand = async () => {
- if (!copyCommandCredential) return;
- try {
- await navigator.clipboard.writeText(
- getDeployCommand(copyCommandCredential),
- );
- toast.success(t("credentials.deployCommandCopied"));
- } catch {
- toast.error(t("credentials.failedToCopy"));
- }
- };
-
- const performDeploy = async () => {
- if (!deployingCredential || !selectedHostId) {
- toast.error(t("credentials.selectTargetHost"));
- return;
- }
-
- setDeployLoading(true);
- try {
- const result = await deployCredentialToHost(
- deployingCredential.id,
- parseInt(selectedHostId),
- );
-
- if (result.success) {
- toast.success(result.message || "SSH key deployed successfully");
- setShowDeployDialog(false);
- setDeployingCredential(null);
- setSelectedHostId("");
- } else {
- toast.error(result.error || t("credentials.deploymentFailed"));
- }
- } catch (error) {
- console.error("Deployment error:", error);
- toast.error(t("credentials.failedToDeployKey"));
- } finally {
- setDeployLoading(false);
- }
- };
-
- const handleDelete = async (credentialId: number, credentialName: string) => {
- confirmWithToast(
- t("credentials.confirmDeleteCredential", { name: credentialName }),
- async () => {
- try {
- await deleteCredential(credentialId);
- toast.success(
- t("credentials.credentialDeletedSuccessfully", {
- name: credentialName,
- }),
- );
- await fetchCredentials();
- window.dispatchEvent(new CustomEvent("credentials:changed"));
- } catch (err: unknown) {
- const error = err as {
- response?: { data?: { error?: string; details?: string } };
- };
- if (error.response?.data?.details) {
- toast.error(
- `${error.response.data.error}\n${error.response.data.details}`,
- );
- } else {
- toast.error(t("credentials.failedToDeleteCredential"));
- }
- }
- },
- "destructive",
- );
- };
-
- const handleRemoveFromFolder = async (credential: Credential) => {
- confirmWithToast(
- t("credentials.confirmRemoveFromFolder", {
- name: credential.name || credential.username,
- folder: credential.folder,
- }),
- async () => {
- try {
- setOperationLoading(true);
- const updatedCredential = { ...credential, folder: "" };
- await updateCredential(credential.id, updatedCredential);
- toast.success(
- t("credentials.removedFromFolder", {
- name: credential.name || credential.username,
- }),
- );
- await fetchCredentials();
- window.dispatchEvent(new CustomEvent("credentials:changed"));
- } catch {
- toast.error(t("credentials.failedToRemoveFromFolder"));
- } finally {
- setOperationLoading(false);
- }
- },
- );
- };
-
- const handleFolderRename = async (oldName: string) => {
- if (!editingFolderName.trim() || editingFolderName === oldName) {
- setEditingFolder(null);
- setEditingFolderName("");
- return;
- }
-
- try {
- setOperationLoading(true);
- await renameCredentialFolder(oldName, editingFolderName.trim());
- toast.success(
- t("credentials.folderRenamed", {
- oldName,
- newName: editingFolderName.trim(),
- }),
- );
- await fetchCredentials();
- window.dispatchEvent(new CustomEvent("credentials:changed"));
- setEditingFolder(null);
- setEditingFolderName("");
- } catch {
- toast.error(t("credentials.failedToRenameFolder"));
- } finally {
- setOperationLoading(false);
- }
- };
-
- const startFolderEdit = (folderName: string) => {
- setEditingFolder(folderName);
- setEditingFolderName(folderName);
- };
-
- const cancelFolderEdit = () => {
- setEditingFolder(null);
- setEditingFolderName("");
- };
-
- const handleDragStart = (e: React.DragEvent, credential: Credential) => {
- setDraggedCredential(credential);
- e.dataTransfer.effectAllowed = "move";
- e.dataTransfer.setData("text/plain", "");
- };
-
- const handleDragEnd = () => {
- setDraggedCredential(null);
- setDragOverFolder(null);
- dragCounter.current = 0;
- };
-
- const handleDragOver = (e: React.DragEvent) => {
- e.preventDefault();
- e.dataTransfer.dropEffect = "move";
- };
-
- const handleDragEnter = (e: React.DragEvent, folderName: string) => {
- e.preventDefault();
- dragCounter.current++;
- setDragOverFolder(folderName);
- };
-
- const handleDragLeave = () => {
- dragCounter.current--;
- if (dragCounter.current === 0) {
- setDragOverFolder(null);
- }
- };
-
- const handleDrop = async (e: React.DragEvent, targetFolder: string) => {
- e.preventDefault();
- dragCounter.current = 0;
- setDragOverFolder(null);
-
- if (!draggedCredential) return;
-
- const newFolder =
- targetFolder === t("credentials.uncategorized") ? "" : targetFolder;
-
- if (draggedCredential.folder === newFolder) {
- setDraggedCredential(null);
- return;
- }
-
- try {
- setOperationLoading(true);
- const updatedCredential = { ...draggedCredential, folder: newFolder };
- await updateCredential(draggedCredential.id, updatedCredential);
- toast.success(
- t("credentials.movedToFolder", {
- name: draggedCredential.name || draggedCredential.username,
- folder: targetFolder,
- }),
- );
- await fetchCredentials();
- window.dispatchEvent(new CustomEvent("credentials:changed"));
- } catch {
- toast.error(t("credentials.failedToMoveToFolder"));
- } finally {
- setOperationLoading(false);
- setDraggedCredential(null);
- }
- };
-
- const filteredAndSortedCredentials = useMemo(() => {
- let filtered = credentials;
-
- if (searchQuery.trim()) {
- const query = searchQuery.toLowerCase();
- filtered = credentials.filter((credential) => {
- const searchableText = [
- credential.name || "",
- credential.username,
- credential.description || "",
- ...(credential.tags || []),
- credential.authType,
- credential.keyType || "",
- ]
- .join(" ")
- .toLowerCase();
- return searchableText.includes(query);
- });
- }
-
- return filtered.sort((a, b) => {
- const aName = a.name || a.username;
- const bName = b.name || b.username;
- return aName.localeCompare(bName);
- });
- }, [credentials, searchQuery]);
-
- const credentialsByFolder = useMemo(() => {
- const grouped: { [key: string]: Credential[] } = {};
-
- filteredAndSortedCredentials.forEach((credential) => {
- const folder = credential.folder || t("credentials.uncategorized");
- if (!grouped[folder]) {
- grouped[folder] = [];
- }
- grouped[folder].push(credential);
- });
-
- const sortedFolders = Object.keys(grouped).sort((a, b) => {
- if (a === t("credentials.uncategorized")) return -1;
- if (b === t("credentials.uncategorized")) return 1;
- return a.localeCompare(b);
- });
-
- const sortedGrouped: { [key: string]: Credential[] } = {};
- sortedFolders.forEach((folder) => {
- sortedGrouped[folder] = grouped[folder];
- });
-
- return sortedGrouped;
- }, [filteredAndSortedCredentials, t]);
-
- if (loading) {
- return (
- <div className="flex items-center justify-center h-full">
- <div className="text-center">
- <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-white mx-auto mb-2"></div>
- <p className="text-muted-foreground">
- {t("credentials.loadingCredentials")}
- </p>
- </div>
- </div>
- );
- }
-
- if (error) {
- return (
- <div className="flex items-center justify-center h-full">
- <div className="text-center">
- <p className="text-red-500 mb-4">{error}</p>
- <Button onClick={fetchCredentials} variant="outline">
- {t("credentials.retry")}
- </Button>
- </div>
- </div>
- );
- }
-
- if (credentials.length === 0) {
- return (
- <div className="flex flex-col h-full min-h-0">
- <div className="flex items-center justify-between mb-2">
- <div>
- <h2 className="text-xl font-semibold">
- {t("credentials.sshCredentials")}
- </h2>
- <p className="text-muted-foreground">
- {t("credentials.credentialsCount", { count: 0 })}
- </p>
- </div>
- <div className="flex items-center gap-2">
- <Button
- onClick={handleRefreshCredentials}
- variant="outline"
- size="sm"
- disabled={refreshing}
- >
- <RefreshCw
- className={`h-4 w-4 mr-2 ${refreshing ? "animate-spin" : ""}`}
- />
- {t("credentials.refresh")}
- </Button>
- </div>
- </div>
-
- <div className="flex gap-2 mb-3">
- <div className="relative flex-1">
- <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
- <Input
- placeholder={t("placeholders.searchCredentials")}
- value={searchQuery}
- onChange={(e) => setSearchQuery(e.target.value)}
- className="pl-10 h-9"
- disabled
- />
- </div>
- <Button variant="outline" className="h-9" onClick={onAddCredential}>
- <Plus className="h-4 w-4 mr-2" />
- {t("credentials.addCredential")}
- </Button>
- </div>
-
- <div className="flex items-center justify-center flex-1">
- <div className="text-center">
- <Key className="h-12 w-12 text-muted-foreground mx-auto mb-4" />
- <h3 className="text-lg font-semibold mb-2">
- {t("credentials.noCredentials")}
- </h3>
- <p className="text-muted-foreground mb-4">
- {t("credentials.noCredentialsMessage")}
- </p>
- </div>
- </div>
- </div>
- );
- }
-
- return (
- <div className="flex flex-col h-full min-h-0">
- <div className="flex items-center justify-between mb-2">
- <div>
- <h2 className="text-xl font-semibold">
- {t("credentials.sshCredentials")}
- </h2>
- <p className="text-muted-foreground">
- {t("credentials.credentialsCount", {
- count: filteredAndSortedCredentials.length,
- })}
- </p>
- </div>
- <div className="flex items-center gap-2">
- <Button
- onClick={handleRefreshCredentials}
- variant="outline"
- size="sm"
- disabled={refreshing}
- >
- <RefreshCw
- className={`h-4 w-4 mr-2 ${refreshing ? "animate-spin" : ""}`}
- />
- {t("credentials.refresh")}
- </Button>
- </div>
- </div>
-
- <div className="flex gap-2 mb-3">
- <div className="relative flex-1">
- <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
- <Input
- placeholder={t("placeholders.searchCredentials")}
- value={searchQuery}
- onChange={(e) => setSearchQuery(e.target.value)}
- className="pl-10 h-9"
- />
- </div>
- <Button variant="outline" className="h-9" onClick={onAddCredential}>
- <Plus className="h-4 w-4 mr-2" />
- {t("credentials.addCredential")}
- </Button>
- </div>
-
- <ScrollArea className="flex-1 min-h-0">
- <div className="space-y-2 pb-20">
- {Object.entries(credentialsByFolder).map(
- ([folder, folderCredentials]) => (
- <div
- key={folder}
- className={`border rounded-md transition-all duration-200 ${
- dragOverFolder === folder
- ? "border-blue-500 bg-blue-500/10"
- : ""
- }`}
- onDragOver={handleDragOver}
- onDragEnter={(e) => handleDragEnter(e, folder)}
- onDragLeave={handleDragLeave}
- onDrop={(e) => handleDrop(e, folder)}
- >
- <Accordion
- type="multiple"
- defaultValue={Object.keys(credentialsByFolder)}
- >
- <AccordionItem value={folder} className="border-none">
- <AccordionTrigger className="px-2 py-1 bg-muted/20 border-b hover:no-underline rounded-t-md">
- <div className="flex items-center gap-2 flex-1">
- <Folder className="h-4 w-4" />
- {editingFolder === folder ? (
- <div
- className="flex items-center gap-2"
- onClick={(e) => e.stopPropagation()}
- >
- <Input
- value={editingFolderName}
- onChange={(e) =>
- setEditingFolderName(e.target.value)
- }
- onKeyDown={(e) => {
- if (e.key === "Enter")
- handleFolderRename(folder);
- if (e.key === "Escape") cancelFolderEdit();
- }}
- className="h-6 text-sm px-2 flex-1"
- autoFocus
- disabled={operationLoading}
- />
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- handleFolderRename(folder);
- }}
- className="h-6 w-6 p-0"
- disabled={operationLoading}
- >
- <Check className="h-3 w-3" />
- </Button>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- cancelFolderEdit();
- }}
- className="h-6 w-6 p-0"
- disabled={operationLoading}
- >
- <X className="h-3 w-3" />
- </Button>
- </div>
- ) : (
- <>
- <span
- className="font-medium cursor-pointer hover:text-blue-400 transition-colors"
- onClick={(e) => {
- e.stopPropagation();
- if (folder !== t("credentials.uncategorized")) {
- startFolderEdit(folder);
- }
- }}
- title={
- folder !== t("credentials.uncategorized")
- ? t("credentials.clickToRenameFolder")
- : ""
- }
- >
- {folder}
- </span>
- {folder !== t("credentials.uncategorized") && (
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- startFolderEdit(folder);
- }}
- className="h-4 w-4 p-0 opacity-50 hover:opacity-100 transition-opacity"
- title={t("credentials.renameFolder")}
- >
- <Pencil className="h-3 w-3" />
- </Button>
- )}
- </>
- )}
- <Badge variant="secondary" className="text-xs">
- {folderCredentials.length}
- </Badge>
- </div>
- </AccordionTrigger>
- <AccordionContent className="p-2">
- <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2">
- {folderCredentials.map((credential) => (
- <TooltipProvider key={credential.id}>
- <Tooltip>
- <TooltipTrigger asChild>
- <div
- draggable
- onDragStart={(e) =>
- handleDragStart(e, credential)
- }
- onDragEnd={handleDragEnd}
- className={`bg-field border border-input rounded-lg cursor-pointer hover:shadow-lg hover:border-blue-400/50 hover:bg-hover-alt transition-all duration-200 p-3 group relative ${
- draggedCredential?.id === credential.id
- ? "opacity-50 scale-95"
- : ""
- }`}
- onClick={() => handleEdit(credential)}
- >
- <div className="flex items-start justify-between">
- <div className="flex-1 min-w-0">
- <div className="flex items-center gap-1">
- <h3 className="font-medium truncate text-sm">
- {credential.name ||
- `${credential.username}`}
- </h3>
- </div>
- <p className="text-xs text-muted-foreground truncate">
- {credential.username}
- </p>
- <p className="text-xs text-muted-foreground truncate">
- {t("credentials.idLabel")}{" "}
- {credential.id}
- </p>
- <p className="text-xs text-muted-foreground truncate">
- {credential.authType === "password"
- ? t("credentials.password")
- : t("credentials.sshKey")}
- </p>
- </div>
- <div className="flex gap-1 flex-shrink-0 ml-1">
- {credential.folder &&
- credential.folder !== "" && (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- handleRemoveFromFolder(
- credential,
- );
- }}
- className="h-5 w-5 p-0 text-orange-500 hover:text-orange-700 hover:bg-orange-500/10"
- disabled={operationLoading}
- >
- <FolderMinus className="h-3 w-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- Remove from folder "
- {credential.folder}"
- </p>
- </TooltipContent>
- </Tooltip>
- )}
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- handleEdit(credential);
- }}
- className="h-5 w-5 p-0 hover:bg-blue-500/10"
- >
- <Edit className="h-3 w-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Edit credential</p>
- </TooltipContent>
- </Tooltip>
- {credential.authType === "key" && (
- <>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- handleDeploy(credential);
- }}
- className="h-5 w-5 p-0 text-green-600 hover:text-green-700 hover:bg-green-500/10"
- >
- <Upload className="h-3 w-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Deploy SSH key to host</p>
- </TooltipContent>
- </Tooltip>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- handleCopyCommand(credential);
- }}
- className="h-5 w-5 p-0 text-cyan-600 hover:text-cyan-700 hover:bg-cyan-500/10"
- >
- <Terminal className="h-3 w-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {t(
- "credentials.copyDeployCommand",
- )}
- </p>
- </TooltipContent>
- </Tooltip>
- </>
- )}
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- handleDelete(
- credential.id,
- credential.name ||
- credential.username,
- );
- }}
- className="h-5 w-5 p-0 text-red-500 hover:text-red-700 hover:bg-red-500/10"
- >
- <Trash2 className="h-3 w-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>Delete credential</p>
- </TooltipContent>
- </Tooltip>
- </div>
- </div>
-
- <div className="mt-2 space-y-1">
- {credential.tags &&
- credential.tags.length > 0 && (
- <div className="flex flex-wrap gap-1">
- {credential.tags
- .slice(0, 6)
- .map((tag, index) => (
- <Badge
- key={index}
- variant="outline"
- className="text-xs px-1 py-0"
- >
- <Tag className="h-2 w-2 mr-0.5" />
- {tag}
- </Badge>
- ))}
- {credential.tags.length > 6 && (
- <Badge
- variant="outline"
- className="text-xs px-1 py-0"
- >
- +{credential.tags.length - 6}
- </Badge>
- )}
- </div>
- )}
-
- <div className="flex flex-wrap gap-1">
- <Badge
- variant="outline"
- className="text-xs px-1 py-0"
- >
- {credential.authType === "password" ? (
- <Key className="h-2 w-2 mr-0.5" />
- ) : (
- <Shield className="h-2 w-2 mr-0.5" />
- )}
- {credential.authType}
- </Badge>
- </div>
- </div>
- </div>
- </TooltipTrigger>
- <TooltipContent>
- <div className="text-center">
- <p className="font-medium">
- Click to edit credential
- </p>
- <p className="text-xs text-muted-foreground">
- Drag to move between folders
- </p>
- </div>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- ))}
- </div>
- </AccordionContent>
- </AccordionItem>
- </Accordion>
- </div>
- ),
- )}
- </div>
- </ScrollArea>
-
- {showViewer && viewingCredential && (
- <CredentialViewer
- credential={viewingCredential}
- onClose={() => setShowViewer(false)}
- onEdit={() => {
- setShowViewer(false);
- handleEdit(viewingCredential);
- }}
- />
- )}
-
- <Sheet open={showDeployDialog} onOpenChange={setShowDeployDialog}>
- <SheetContent className="w-[500px] max-w-[50vw] overflow-y-auto thin-scrollbar bg-canvas">
- <div className="px-4 py-4">
- <div className="space-y-3 pb-4">
- <div className="flex items-center space-x-3">
- <div className="flex-1">
- <div className="text-lg font-semibold">
- {t("credentials.deploySSHKey")}
- </div>
- <div className="text-sm text-muted-foreground">
- {t("credentials.deploySSHKeyDescription")}
- </div>
- </div>
- </div>
- </div>
-
- <div className="space-y-4">
- {deployingCredential && (
- <div className="border rounded-lg p-3 bg-muted/20">
- <h4 className="text-sm font-semibold mb-2 flex items-center">
- <Key className="h-4 w-4 mr-2 text-muted-foreground" />
- {t("credentials.sourceCredential")}
- </h4>
- <div className="space-y-2">
- <div className="flex items-center space-x-3 px-2 py-1">
- <div className="p-1.5 rounded bg-muted">
- <User className="h-3 w-3 text-muted-foreground" />
- </div>
- <div className="flex-1">
- <div className="text-xs text-muted-foreground">
- {t("common.name")}
- </div>
- <div className="text-sm font-medium">
- {deployingCredential.name ||
- deployingCredential.username}
- </div>
- </div>
- </div>
- <div className="flex items-center space-x-3 px-2 py-1">
- <div className="p-1.5 rounded bg-muted">
- <User className="h-3 w-3 text-muted-foreground" />
- </div>
- <div className="flex-1">
- <div className="text-xs text-muted-foreground">
- {t("common.username")}
- </div>
- <div className="text-sm font-medium">
- {deployingCredential.username}
- </div>
- </div>
- </div>
- <div className="flex items-center space-x-3 px-2 py-1">
- <div className="p-1.5 rounded bg-muted">
- <Key className="h-3 w-3 text-muted-foreground" />
- </div>
- <div className="flex-1">
- <div className="text-xs text-muted-foreground">
- {t("credentials.keyType")}
- </div>
- <div className="text-sm font-medium">
- {deployingCredential.keyType ||
- t("credentials.sshKey")}
- </div>
- </div>
- </div>
- </div>
- </div>
- )}
-
- <div className="space-y-2">
- <label className="text-sm font-semibold flex items-center">
- <Server className="h-4 w-4 mr-2 text-muted-foreground" />
- {t("credentials.targetHost")}
- </label>
- <Popover
- open={hostComboboxOpen}
- onOpenChange={setHostComboboxOpen}
- >
- <PopoverTrigger asChild>
- <Button
- variant="outline"
- role="combobox"
- aria-expanded={hostComboboxOpen}
- className="w-full justify-between"
- >
- {selectedHostId
- ? (() => {
- const host = availableHosts.find(
- (h) => h.id.toString() === selectedHostId,
- );
- return host
- ? `${host.name || host.ip}`
- : t("credentials.chooseHostToDeploy");
- })()
- : t("credentials.chooseHostToDeploy")}
- <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
- </Button>
- </PopoverTrigger>
- <PopoverContent
- className="p-0"
- style={{ width: "var(--radix-popover-trigger-width)" }}
- >
- <Command>
- <CommandInput
- placeholder={t("credentials.chooseHostToDeploy")}
- />
- <CommandEmpty>
- {availableHosts.length === 0
- ? t("credentials.noHostsAvailable")
- : t("credentials.noHostsMatchSearch")}
- </CommandEmpty>
- <CommandGroup className="max-h-[300px] overflow-y-auto thin-scrollbar">
- {availableHosts.map((host) => (
- <CommandItem
- key={host.id}
- value={`${host.name} ${host.ip} ${host.username} ${host.id}`}
- onSelect={() => {
- setSelectedHostId(host.id.toString());
- setHostComboboxOpen(false);
- }}
- >
- <Check
- className={cn(
- "mr-2 h-4 w-4",
- selectedHostId === host.id.toString()
- ? "opacity-100"
- : "opacity-0",
- )}
- />
- <div className="flex items-center gap-3">
- <div className="p-1.5 rounded bg-muted">
- <Server className="h-3 w-3 text-muted-foreground" />
- </div>
- <div className="flex-1">
- <div className="font-medium text-foreground">
- {host.name || host.ip}
- </div>
- <div className="text-xs text-muted-foreground">
- {host.username}@{host.ip}:{host.port}
- </div>
- </div>
- </div>
- </CommandItem>
- ))}
- </CommandGroup>
- </Command>
- </PopoverContent>
- </Popover>
- </div>
-
- <div className="border border-blue-200 dark:border-blue-800 rounded-lg p-3 bg-blue-50 dark:bg-blue-900/20">
- <div className="flex items-start space-x-2">
- <Info className="h-4 w-4 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0" />
- <div className="text-sm">
- <p className="font-medium text-blue-800 dark:text-blue-200 mb-1">
- {t("credentials.deploymentProcess")}
- </p>
- <p className="text-blue-700 dark:text-blue-300">
- {t("credentials.deploymentProcessDescription")}
- </p>
- </div>
- </div>
- </div>
-
- <div className="mt-4">
- <div className="flex gap-2">
- <Button
- variant="outline"
- onClick={() => setShowDeployDialog(false)}
- disabled={deployLoading}
- className="flex-1"
- >
- {t("common.cancel")}
- </Button>
- <Button
- onClick={performDeploy}
- disabled={!selectedHostId || deployLoading}
- className="flex-1"
- >
- {deployLoading ? (
- <div className="flex items-center">
- <div className="animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent mr-2"></div>
- {t("credentials.deploying")}
- </div>
- ) : (
- <div className="flex items-center">
- <Upload className="h-4 w-4 mr-2" />
- {t("credentials.deploySSHKey")}
- </div>
- )}
- </Button>
- </div>
- </div>
- </div>
- </div>
- </SheetContent>
- </Sheet>
-
- <Sheet
- open={showCopyCommandDialog}
- onOpenChange={setShowCopyCommandDialog}
- >
- <SheetContent className="w-[500px] max-w-[50vw] overflow-y-auto thin-scrollbar bg-canvas">
- <div className="px-4 py-4">
- <div className="space-y-3 pb-4">
- <div className="flex items-center space-x-3">
- <div className="flex-1">
- <div className="text-lg font-semibold">
- {t("credentials.copyDeployCommand")}
- </div>
- <div className="text-sm text-muted-foreground">
- {t("credentials.copyDeployCommandDescription")}
- </div>
- </div>
- </div>
- </div>
-
- <div className="space-y-4">
- {copyCommandCredential && (
- <>
- <div className="border rounded-lg p-3 bg-muted/20">
- <h4 className="text-sm font-semibold mb-2 flex items-center">
- <Key className="h-4 w-4 mr-2 text-muted-foreground" />
- {t("credentials.sourceCredential")}
- </h4>
- <div className="space-y-2">
- <div className="flex items-center space-x-3 px-2 py-1">
- <div className="p-1.5 rounded bg-muted">
- <User className="h-3 w-3 text-muted-foreground" />
- </div>
- <div className="flex-1">
- <div className="text-xs text-muted-foreground">
- {t("common.name")}
- </div>
- <div className="text-sm font-medium">
- {copyCommandCredential.name ||
- copyCommandCredential.username}
- </div>
- </div>
- </div>
- <div className="flex items-center space-x-3 px-2 py-1">
- <div className="p-1.5 rounded bg-muted">
- <Key className="h-3 w-3 text-muted-foreground" />
- </div>
- <div className="flex-1">
- <div className="text-xs text-muted-foreground">
- {t("credentials.keyType")}
- </div>
- <div className="text-sm font-medium">
- {copyCommandCredential.keyType ||
- t("credentials.sshKey")}
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <div className="space-y-2">
- <label className="text-sm font-semibold flex items-center">
- <Terminal className="h-4 w-4 mr-2 text-muted-foreground" />
- Command
- </label>
- <pre className="text-xs bg-muted rounded-lg p-3 overflow-x-auto whitespace-pre-wrap break-all select-all font-mono">
- {getDeployCommand(copyCommandCredential)}
- </pre>
- </div>
-
- <div className="border border-blue-200 dark:border-blue-800 rounded-lg p-3 bg-blue-50 dark:bg-blue-900/20">
- <div className="flex items-start space-x-2">
- <Info className="h-4 w-4 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0" />
- <p className="text-sm text-blue-700 dark:text-blue-300">
- {t("credentials.manualDeployInfo")}
- </p>
- </div>
- </div>
-
- <div className="mt-4">
- <div className="flex gap-2">
- <Button
- variant="outline"
- onClick={() => setShowCopyCommandDialog(false)}
- className="flex-1"
- >
- {t("common.cancel")}
- </Button>
- <Button onClick={copyDeployCommand} className="flex-1">
- <Copy className="h-4 w-4 mr-2" />
- {t("credentials.copyDeployCommand")}
- </Button>
- </div>
- </div>
- </>
- )}
- </div>
- </div>
- </SheetContent>
- </Sheet>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/credentials/tabs/CredentialAuthenticationTab.tsx b/src/ui/desktop/apps/host-manager/credentials/tabs/CredentialAuthenticationTab.tsx
deleted file mode 100644
index 7bb98fbd6..000000000
--- a/src/ui/desktop/apps/host-manager/credentials/tabs/CredentialAuthenticationTab.tsx
+++ /dev/null
@@ -1,514 +0,0 @@
-import {
- FormField,
- FormItem,
- FormLabel,
- FormControl,
-} from "@/components/ui/form.tsx";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import {
- Tabs,
- TabsContent,
- TabsList,
- TabsTrigger,
-} from "@/components/ui/tabs.tsx";
-import { Controller } from "react-hook-form";
-import CodeMirror from "@uiw/react-codemirror";
-import { EditorView } from "@codemirror/view";
-import React from "react";
-import { useTranslation } from "react-i18next";
-import { toast } from "sonner";
-import {
- generateKeyPair,
- generatePublicKeyFromPrivate,
-} from "@/ui/main-axios.ts";
-import type { CredentialAuthenticationTabProps } from "./shared/tab-types";
-
-export function CredentialAuthenticationTab({
- form,
- authTab,
- setAuthTab,
- detectedKeyType,
- detectedPublicKeyType,
- keyDetectionLoading,
- publicKeyDetectionLoading,
- editorTheme,
- debouncedKeyDetection,
- debouncedPublicKeyDetection,
- getFriendlyKeyTypeName,
-}: CredentialAuthenticationTabProps) {
- const { t } = useTranslation();
-
- return (
- <>
- <FormLabel className="mb-2 font-bold">
- {t("credentials.authentication")}
- </FormLabel>
- <Tabs
- value={authTab}
- onValueChange={(value) => {
- const newAuthType = value as "password" | "key";
- setAuthTab(newAuthType);
- form.setValue("authType", newAuthType);
-
- form.setValue("password", "");
- form.setValue("key", null);
- form.setValue("keyPassword", "");
- form.setValue("keyType", "auto");
- }}
- className="flex-1 flex flex-col h-full min-h-0"
- >
- <TabsList className="bg-button border border-edge-medium">
- <TabsTrigger
- value="password"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- {t("credentials.password")}
- </TabsTrigger>
- <TabsTrigger
- value="key"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- {t("credentials.key")}
- </TabsTrigger>
- </TabsList>
- <TabsContent value="password">
- <FormField
- control={form.control}
- name="password"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("credentials.password")}</FormLabel>
- <FormControl>
- <PasswordInput
- placeholder={t("placeholders.password")}
- {...field}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </TabsContent>
- <TabsContent value="key">
- <div className="mt-2">
- <div className="mb-3 p-3 border border-muted rounded-md">
- <FormLabel className="mb-2 font-bold block">
- {t("credentials.generateKeyPair")}
- </FormLabel>
-
- <div className="mb-2">
- <div className="text-sm text-muted-foreground">
- {t("credentials.generateKeyPairDescription")}
- </div>
- </div>
-
- <div className="flex gap-2 flex-wrap">
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={async () => {
- try {
- const currentKeyPassword = form.watch("keyPassword");
- const result = await generateKeyPair(
- "ssh-ed25519",
- undefined,
- currentKeyPassword,
- );
-
- if (result.success) {
- form.setValue("key", result.privateKey);
- form.setValue("publicKey", result.publicKey);
- debouncedKeyDetection(
- result.privateKey,
- currentKeyPassword,
- );
- debouncedPublicKeyDetection(result.publicKey);
- toast.success(
- t("credentials.keyPairGeneratedSuccessfully", {
- keyType: "Ed25519",
- }),
- );
- } else {
- toast.error(
- result.error ||
- t("credentials.failedToGenerateKeyPair"),
- );
- }
- } catch (error) {
- console.error(
- "Failed to generate Ed25519 key pair:",
- error,
- );
- toast.error(t("credentials.failedToGenerateKeyPair"));
- }
- }}
- >
- {t("credentials.generateEd25519")}
- </Button>
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={async () => {
- try {
- const currentKeyPassword = form.watch("keyPassword");
- const result = await generateKeyPair(
- "ecdsa-sha2-nistp256",
- undefined,
- currentKeyPassword,
- );
-
- if (result.success) {
- form.setValue("key", result.privateKey);
- form.setValue("publicKey", result.publicKey);
- debouncedKeyDetection(
- result.privateKey,
- currentKeyPassword,
- );
- debouncedPublicKeyDetection(result.publicKey);
- toast.success(
- t("credentials.keyPairGeneratedSuccessfully", {
- keyType: "ECDSA",
- }),
- );
- } else {
- toast.error(
- result.error ||
- t("credentials.failedToGenerateKeyPair"),
- );
- }
- } catch (error) {
- console.error(
- "Failed to generate ECDSA key pair:",
- error,
- );
- toast.error(t("credentials.failedToGenerateKeyPair"));
- }
- }}
- >
- {t("credentials.generateECDSA")}
- </Button>
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={async () => {
- try {
- const currentKeyPassword = form.watch("keyPassword");
- const result = await generateKeyPair(
- "ssh-rsa",
- 2048,
- currentKeyPassword,
- );
-
- if (result.success) {
- form.setValue("key", result.privateKey);
- form.setValue("publicKey", result.publicKey);
- debouncedKeyDetection(
- result.privateKey,
- currentKeyPassword,
- );
- debouncedPublicKeyDetection(result.publicKey);
- toast.success(
- t("credentials.keyPairGeneratedSuccessfully", {
- keyType: "RSA",
- }),
- );
- } else {
- toast.error(
- result.error ||
- t("credentials.failedToGenerateKeyPair"),
- );
- }
- } catch (error) {
- console.error("Failed to generate RSA key pair:", error);
- toast.error(t("credentials.failedToGenerateKeyPair"));
- }
- }}
- >
- {t("credentials.generateRSA")}
- </Button>
- </div>
- </div>
- <div className="grid grid-cols-2 gap-3 items-start">
- <Controller
- control={form.control}
- name="key"
- render={({ field }) => (
- <FormItem className="mb-3 flex flex-col">
- <FormLabel className="mb-1 min-h-[20px]">
- {t("credentials.sshPrivateKey")}
- </FormLabel>
- <div className="mb-1">
- <div className="relative inline-block w-full">
- <input
- id="key-upload"
- type="file"
- accept="*,.pem,.key,.txt,.ppk"
- onChange={async (e) => {
- const file = e.target.files?.[0];
- if (file) {
- try {
- const fileContent = await file.text();
- field.onChange(fileContent);
- debouncedKeyDetection(
- fileContent,
- form.watch("keyPassword"),
- );
- } catch (error) {
- console.error(
- "Failed to read uploaded file:",
- error,
- );
- }
- }
- }}
- className="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
- />
- <Button
- type="button"
- variant="outline"
- className="w-full justify-start text-left"
- >
- <span className="truncate">
- {t("credentials.uploadPrivateKeyFile")}
- </span>
- </Button>
- </div>
- </div>
- <FormControl>
- <CodeMirror
- value={
- typeof field.value === "string" ? field.value : ""
- }
- onChange={(value) => {
- field.onChange(value);
- debouncedKeyDetection(
- value,
- form.watch("keyPassword"),
- );
- }}
- placeholder={t("placeholders.pastePrivateKey")}
- theme={editorTheme}
- className="border border-input rounded-md overflow-hidden"
- minHeight="120px"
- basicSetup={{
- lineNumbers: true,
- foldGutter: false,
- dropCursor: false,
- allowMultipleSelections: false,
- highlightSelectionMatches: false,
- searchKeymap: false,
- scrollPastEnd: false,
- }}
- extensions={[
- EditorView.theme({
- ".cm-scroller": {
- overflow: "auto",
- scrollbarWidth: "thin",
- scrollbarColor:
- "var(--scrollbar-thumb) var(--scrollbar-track)",
- },
- }),
- ]}
- />
- </FormControl>
- {detectedKeyType && (
- <div className="text-sm mt-2">
- <span className="text-muted-foreground">
- {t("credentials.detectedKeyType")}:{" "}
- </span>
- <span
- className={`font-medium ${
- detectedKeyType === "invalid" ||
- detectedKeyType === "error"
- ? "text-destructive"
- : "text-green-600"
- }`}
- >
- {getFriendlyKeyTypeName(detectedKeyType)}
- </span>
- {keyDetectionLoading && (
- <span className="ml-2 text-muted-foreground">
- ({t("credentials.detectingKeyType")})
- </span>
- )}
- </div>
- )}
- </FormItem>
- )}
- />
- <Controller
- control={form.control}
- name="publicKey"
- render={({ field }) => (
- <FormItem className="mb-3 flex flex-col">
- <FormLabel className="mb-1 min-h-[20px]">
- {t("credentials.sshPublicKey")}
- </FormLabel>
- <div className="mb-1 flex gap-2">
- <div className="relative inline-block flex-1">
- <input
- id="public-key-upload"
- type="file"
- accept="*,.pub,.txt"
- onChange={async (e) => {
- const file = e.target.files?.[0];
- if (file) {
- try {
- const fileContent = await file.text();
- field.onChange(fileContent);
- debouncedPublicKeyDetection(fileContent);
- } catch (error) {
- console.error(
- "Failed to read uploaded public key file:",
- error,
- );
- }
- }
- }}
- className="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
- />
- <Button
- type="button"
- variant="outline"
- className="w-full justify-start text-left"
- >
- <span className="truncate">
- {t("credentials.uploadPublicKeyFile")}
- </span>
- </Button>
- </div>
- <Button
- type="button"
- variant="outline"
- className="flex-shrink-0"
- onClick={async () => {
- const privateKey = form.watch("key");
- if (
- !privateKey ||
- typeof privateKey !== "string" ||
- !privateKey.trim()
- ) {
- toast.error(
- t("credentials.privateKeyRequiredForGeneration"),
- );
- return;
- }
-
- try {
- const keyPassword = form.watch("keyPassword");
- const result = await generatePublicKeyFromPrivate(
- privateKey,
- keyPassword,
- );
-
- if (result.success && result.publicKey) {
- field.onChange(result.publicKey);
- debouncedPublicKeyDetection(result.publicKey);
-
- toast.success(
- t("credentials.publicKeyGeneratedSuccessfully"),
- );
- } else {
- toast.error(
- result.error ||
- t("credentials.failedToGeneratePublicKey"),
- );
- }
- } catch (error) {
- console.error(
- "Failed to generate public key:",
- error,
- );
- toast.error(
- t("credentials.failedToGeneratePublicKey"),
- );
- }
- }}
- >
- {t("credentials.generatePublicKey")}
- </Button>
- </div>
- <FormControl>
- <CodeMirror
- value={field.value || ""}
- onChange={(value) => {
- field.onChange(value);
- debouncedPublicKeyDetection(value);
- }}
- placeholder={t("placeholders.pastePublicKey")}
- theme={editorTheme}
- className="border border-input rounded-md overflow-hidden"
- minHeight="120px"
- basicSetup={{
- lineNumbers: true,
- foldGutter: false,
- dropCursor: false,
- allowMultipleSelections: false,
- highlightSelectionMatches: false,
- searchKeymap: false,
- scrollPastEnd: false,
- }}
- extensions={[
- EditorView.theme({
- ".cm-scroller": {
- overflow: "auto",
- scrollbarWidth: "thin",
- scrollbarColor:
- "var(--scrollbar-thumb) var(--scrollbar-track)",
- },
- }),
- ]}
- />
- </FormControl>
- {detectedPublicKeyType && field.value && (
- <div className="text-sm mt-2">
- <span className="text-muted-foreground">
- {t("credentials.detectedKeyType")}:{" "}
- </span>
- <span
- className={`font-medium ${
- detectedPublicKeyType === "invalid" ||
- detectedPublicKeyType === "error"
- ? "text-destructive"
- : "text-green-600"
- }`}
- >
- {getFriendlyKeyTypeName(detectedPublicKeyType)}
- </span>
- {publicKeyDetectionLoading && (
- <span className="ml-2 text-muted-foreground">
- ({t("credentials.detectingKeyType")})
- </span>
- )}
- </div>
- )}
- </FormItem>
- )}
- />
- </div>
- <div className="grid grid-cols-8 gap-3 mt-3">
- <FormField
- control={form.control}
- name="keyPassword"
- render={({ field }) => (
- <FormItem className="col-span-8">
- <FormLabel>{t("credentials.keyPassword")}</FormLabel>
- <FormControl>
- <PasswordInput
- placeholder={t("placeholders.keyPassword")}
- {...field}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </div>
- </div>
- </TabsContent>
- </Tabs>
- </>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/credentials/tabs/CredentialGeneralTab.tsx b/src/ui/desktop/apps/host-manager/credentials/tabs/CredentialGeneralTab.tsx
deleted file mode 100644
index 60833b3da..000000000
--- a/src/ui/desktop/apps/host-manager/credentials/tabs/CredentialGeneralTab.tsx
+++ /dev/null
@@ -1,192 +0,0 @@
-import {
- FormField,
- FormItem,
- FormLabel,
- FormControl,
-} from "@/components/ui/form.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import React from "react";
-import { useTranslation } from "react-i18next";
-import type { CredentialGeneralTabProps } from "./shared/tab-types";
-
-export function CredentialGeneralTab({
- form,
- tagInput,
- setTagInput,
- folderDropdownOpen,
- setFolderDropdownOpen,
- folderInputRef,
- folderDropdownRef,
- filteredFolders,
- handleFolderClick,
-}: CredentialGeneralTabProps) {
- const { t } = useTranslation();
-
- return (
- <>
- <FormLabel className="mb-2 font-bold">
- {t("credentials.basicInformation")}
- </FormLabel>
- <div className="grid grid-cols-12 gap-3">
- <FormField
- control={form.control}
- name="name"
- render={({ field }) => (
- <FormItem className="col-span-6">
- <FormLabel>{t("credentials.credentialName")}</FormLabel>
- <FormControl>
- <Input
- placeholder={t("placeholders.credentialName")}
- {...field}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="username"
- render={({ field }) => (
- <FormItem className="col-span-6">
- <FormLabel>{t("credentials.username")}</FormLabel>
- <FormControl>
- <Input placeholder={t("placeholders.username")} {...field} />
- </FormControl>
- </FormItem>
- )}
- />
- </div>
- <FormLabel className="mb-2 mt-4 font-bold">
- {t("credentials.organization")}
- </FormLabel>
- <div className="grid grid-cols-26 gap-3">
- <FormField
- control={form.control}
- name="description"
- render={({ field }) => (
- <FormItem className="col-span-10">
- <FormLabel>{t("credentials.description")}</FormLabel>
- <FormControl>
- <Input placeholder={t("placeholders.description")} {...field} />
- </FormControl>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="folder"
- render={({ field }) => (
- <FormItem className="col-span-10 relative">
- <FormLabel>{t("credentials.folder")}</FormLabel>
- <FormControl>
- <Input
- ref={folderInputRef}
- placeholder={t("placeholders.folder")}
- className="min-h-[40px]"
- autoComplete="off"
- value={field.value}
- onFocus={() => setFolderDropdownOpen(true)}
- onChange={(e) => {
- field.onChange(e);
- setFolderDropdownOpen(true);
- }}
- />
- </FormControl>
- {folderDropdownOpen && filteredFolders.length > 0 && (
- <div
- ref={folderDropdownRef}
- className="absolute top-full left-0 z-50 mt-1 w-full bg-canvas border border-input rounded-md shadow-lg max-h-40 overflow-y-auto thin-scrollbar p-1"
- >
- <div className="grid grid-cols-1 gap-1 p-0">
- {filteredFolders.map((folder) => (
- <Button
- key={folder}
- type="button"
- variant="ghost"
- size="sm"
- className="w-full justify-start text-left rounded px-2 py-1.5 hover:bg-white/15 focus:bg-white/20 focus:outline-none"
- onClick={() => handleFolderClick(folder)}
- >
- {folder}
- </Button>
- ))}
- </div>
- </div>
- )}
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="tags"
- render={({ field }) => (
- <FormItem className="col-span-10 overflow-visible">
- <FormLabel>{t("credentials.tags")}</FormLabel>
- <FormControl>
- <div className="flex flex-wrap items-center gap-1 border border-input rounded-md px-3 py-2 bg-field focus-within:ring-2 ring-ring min-h-[40px]">
- {(field.value || []).map((tag: string, idx: number) => (
- <span
- key={`${tag}-${idx}`}
- className="flex items-center bg-surface text-foreground rounded-full px-2 py-0.5 text-xs"
- >
- {tag}
- <button
- type="button"
- className="ml-1 text-foreground-subtle hover:text-red-500 focus:outline-none"
- onClick={(e) => {
- e.preventDefault();
- e.stopPropagation();
- const newTags = (field.value || []).filter(
- (_: string, i: number) => i !== idx,
- );
- field.onChange(newTags);
- }}
- >
- ×
- </button>
- </span>
- ))}
- <input
- type="text"
- className="flex-1 min-w-[60px] border-none outline-none bg-transparent text-foreground placeholder:text-muted-foreground p-0 h-6 text-sm"
- value={tagInput}
- onChange={(e) => setTagInput(e.target.value)}
- onKeyDown={(e) => {
- if (e.key === " " && tagInput.trim() !== "") {
- e.preventDefault();
- const currentTags = field.value || [];
- if (!currentTags.includes(tagInput.trim())) {
- field.onChange([...currentTags, tagInput.trim()]);
- }
- setTagInput("");
- } else if (e.key === "Enter" && tagInput.trim() !== "") {
- e.preventDefault();
- const currentTags = field.value || [];
- if (!currentTags.includes(tagInput.trim())) {
- field.onChange([...currentTags, tagInput.trim()]);
- }
- setTagInput("");
- } else if (
- e.key === "Backspace" &&
- tagInput === "" &&
- (field.value || []).length > 0
- ) {
- const currentTags = field.value || [];
- field.onChange(currentTags.slice(0, -1));
- }
- }}
- placeholder={t("credentials.addTagsSpaceToAdd")}
- />
- </div>
- </FormControl>
- </FormItem>
- )}
- />
- </div>
- </>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/credentials/tabs/shared/tab-types.ts b/src/ui/desktop/apps/host-manager/credentials/tabs/shared/tab-types.ts
deleted file mode 100644
index 2fb22ef63..000000000
--- a/src/ui/desktop/apps/host-manager/credentials/tabs/shared/tab-types.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import type { UseFormReturn } from "react-hook-form";
-import type React from "react";
-
-export interface CredentialGeneralTabProps {
- form: UseFormReturn<FormData>;
- folders: string[];
- tagInput: string;
- setTagInput: (value: string) => void;
- folderDropdownOpen: boolean;
- setFolderDropdownOpen: (value: boolean) => void;
- folderInputRef: React.RefObject<HTMLInputElement>;
- folderDropdownRef: React.RefObject<HTMLDivElement>;
- filteredFolders: string[];
- handleFolderClick: (folder: string) => void;
-}
-
-export interface CredentialAuthenticationTabProps {
- form: UseFormReturn<FormData>;
- authTab: "password" | "key";
- setAuthTab: (value: "password" | "key") => void;
- detectedKeyType: string | null;
- setDetectedKeyType: (value: string | null) => void;
- keyDetectionLoading: boolean;
- setKeyDetectionLoading: (value: boolean) => void;
- detectedPublicKeyType: string | null;
- setDetectedPublicKeyType: (value: string | null) => void;
- publicKeyDetectionLoading: boolean;
- setPublicKeyDetectionLoading: (value: boolean) => void;
- keyDetectionTimeoutRef: React.MutableRefObject<NodeJS.Timeout | null>;
- publicKeyDetectionTimeoutRef: React.MutableRefObject<NodeJS.Timeout | null>;
- editorTheme: unknown;
- debouncedKeyDetection: (keyValue: string, keyPassword?: string) => void;
- debouncedPublicKeyDetection: (publicKeyValue: string) => void;
- getFriendlyKeyTypeName: (keyType: string) => string;
-}
diff --git a/src/ui/desktop/apps/host-manager/dialogs/FolderEditDialog.tsx b/src/ui/desktop/apps/host-manager/dialogs/FolderEditDialog.tsx
deleted file mode 100644
index 6c559c732..000000000
--- a/src/ui/desktop/apps/host-manager/dialogs/FolderEditDialog.tsx
+++ /dev/null
@@ -1,191 +0,0 @@
-import React, { useState, useEffect } from "react";
-import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogHeader,
- DialogTitle,
- DialogFooter,
-} from "@/components/ui/dialog.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import { useTranslation } from "react-i18next";
-import {
- Folder,
- Server,
- Cloud,
- Database,
- Box,
- Package,
- Layers,
- Archive,
- HardDrive,
- Globe,
-} from "lucide-react";
-
-interface FolderEditDialogProps {
- folderName: string;
- currentColor?: string;
- currentIcon?: string;
- open: boolean;
- onOpenChange: (open: boolean) => void;
- onSave: (color: string, icon: string) => Promise<void>;
-}
-
-const AVAILABLE_COLORS = [
- { value: "#ef4444", label: "Red" },
- { value: "#f97316", label: "Orange" },
- { value: "#eab308", label: "Yellow" },
- { value: "#22c55e", label: "Green" },
- { value: "#3b82f6", label: "Blue" },
- { value: "#a855f7", label: "Purple" },
- { value: "#ec4899", label: "Pink" },
- { value: "#6b7280", label: "Gray" },
-];
-
-const AVAILABLE_ICONS = [
- { value: "Folder", label: "Folder", Icon: Folder },
- { value: "Server", label: "Server", Icon: Server },
- { value: "Cloud", label: "Cloud", Icon: Cloud },
- { value: "Database", label: "Database", Icon: Database },
- { value: "Box", label: "Box", Icon: Box },
- { value: "Package", label: "Package", Icon: Package },
- { value: "Layers", label: "Layers", Icon: Layers },
- { value: "Archive", label: "Archive", Icon: Archive },
- { value: "HardDrive", label: "HardDrive", Icon: HardDrive },
- { value: "Globe", label: "Globe", Icon: Globe },
-];
-
-export function FolderEditDialog({
- folderName,
- currentColor,
- currentIcon,
- open,
- onOpenChange,
- onSave,
-}: FolderEditDialogProps) {
- const { t } = useTranslation();
- const [selectedColor, setSelectedColor] = useState(
- currentColor || AVAILABLE_COLORS[0].value,
- );
- const [selectedIcon, setSelectedIcon] = useState(
- currentIcon || AVAILABLE_ICONS[0].value,
- );
- const [loading, setLoading] = useState(false);
-
- useEffect(() => {
- if (open) {
- setSelectedColor(currentColor || AVAILABLE_COLORS[0].value);
- setSelectedIcon(currentIcon || AVAILABLE_ICONS[0].value);
- }
- }, [open, currentColor, currentIcon]);
-
- const handleSave = async () => {
- setLoading(true);
- try {
- await onSave(selectedColor, selectedIcon);
- onOpenChange(false);
- } catch (error) {
- console.error("Failed to save folder metadata:", error);
- } finally {
- setLoading(false);
- }
- };
-
- return (
- <Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent className="sm:max-w-[500px] bg-canvas border-2 border-edge">
- <DialogHeader>
- <DialogTitle className="flex items-center gap-2">
- <Folder className="w-5 h-5" />
- {t("hosts.editFolderAppearance")}
- </DialogTitle>
- <DialogDescription className="text-muted-foreground">
- {t("hosts.editFolderAppearanceDesc")}:{" "}
- <span className="font-mono text-foreground">{folderName}</span>
- </DialogDescription>
- </DialogHeader>
-
- <div className="space-y-6 py-4">
- <div className="space-y-3">
- <Label className="text-base font-semibold text-foreground">
- {t("hosts.folderColor")}
- </Label>
- <div className="grid grid-cols-4 gap-3">
- {AVAILABLE_COLORS.map((color) => (
- <button
- key={color.value}
- type="button"
- className={`h-12 rounded-md border-2 transition-all hover:scale-105 ${
- selectedColor === color.value
- ? "border-white shadow-lg scale-105"
- : "border-edge"
- }`}
- style={{ backgroundColor: color.value }}
- onClick={() => setSelectedColor(color.value)}
- title={color.label}
- />
- ))}
- </div>
- </div>
-
- <div className="space-y-3">
- <Label className="text-base font-semibold text-foreground">
- {t("hosts.folderIcon")}
- </Label>
- <div className="grid grid-cols-5 gap-3">
- {AVAILABLE_ICONS.map(({ value, label, Icon }) => (
- <button
- key={value}
- type="button"
- className={`h-14 rounded-md border-2 transition-all hover:scale-105 flex items-center justify-center ${
- selectedIcon === value
- ? "border-primary bg-primary/10"
- : "border-edge bg-elevated"
- }`}
- onClick={() => setSelectedIcon(value)}
- title={label}
- >
- <Icon className="w-6 h-6" />
- </button>
- ))}
- </div>
- </div>
-
- <div className="space-y-3">
- <Label className="text-base font-semibold text-foreground">
- {t("hosts.preview")}
- </Label>
- <div className="flex items-center gap-3 p-4 rounded-md bg-elevated border border-edge">
- {(() => {
- const IconComponent =
- AVAILABLE_ICONS.find((i) => i.value === selectedIcon)?.Icon ||
- Folder;
- return (
- <IconComponent
- className="w-5 h-5"
- style={{ color: selectedColor }}
- />
- );
- })()}
- <span className="font-medium">{folderName}</span>
- </div>
- </div>
- </div>
-
- <DialogFooter>
- <Button
- variant="outline"
- onClick={() => onOpenChange(false)}
- disabled={loading}
- >
- {t("common.cancel")}
- </Button>
- <Button onClick={handleSave} disabled={loading}>
- {loading ? t("common.saving") : t("common.save")}
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/HostManager.tsx b/src/ui/desktop/apps/host-manager/hosts/HostManager.tsx
deleted file mode 100644
index 0545f8b6e..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/HostManager.tsx
+++ /dev/null
@@ -1,302 +0,0 @@
-import React, { useState, useEffect, useRef } from "react";
-import { HostManagerViewer } from "@/ui/desktop/apps/host-manager/hosts/HostManagerViewer.tsx";
-import {
- Tabs,
- TabsContent,
- TabsList,
- TabsTrigger,
-} from "@/components/ui/tabs.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
-import { HostManagerEditor } from "@/ui/desktop/apps/host-manager/hosts/HostManagerEditor.tsx";
-import { CredentialsManager } from "@/ui/desktop/apps/host-manager/credentials/CredentialsManager.tsx";
-import { CredentialEditor } from "@/ui/desktop/apps/host-manager/credentials/CredentialEditor.tsx";
-import { useSidebar } from "@/components/ui/sidebar.tsx";
-import { useTranslation } from "react-i18next";
-import { exportSSHHostWithCredentials } from "@/ui/main-axios.ts";
-import type { SSHHost, HostManagerProps } from "../../../types/index";
-
-export function HostManager({
- isTopbarOpen,
- initialTab = "hosts",
- hostConfig,
- _updateTimestamp,
- rightSidebarOpen = false,
- rightSidebarWidth = 400,
- currentTabId,
- updateTab,
-}: HostManagerProps): React.ReactElement {
- const { t } = useTranslation();
- const [activeTab, setActiveTab] = useState(
- initialTab === "host_viewer" || initialTab === "add_host"
- ? "hosts"
- : initialTab === "credentials" || initialTab === "add_credential"
- ? "credentials"
- : initialTab,
- );
- const [editingHost, setEditingHost] = useState<SSHHost | null>(
- hostConfig || null,
- );
- const [isAddingHost, setIsAddingHost] = useState(false);
- const [isAddingCredential, setIsAddingCredential] = useState(false);
-
- useEffect(() => {}, [editingHost]);
-
- const [editingCredential, setEditingCredential] = useState<{
- id: number;
- name?: string;
- username: string;
- } | null>(null);
- const { state: sidebarState } = useSidebar();
- const ignoreNextHostConfigChangeRef = useRef<boolean>(false);
- const lastProcessedHostIdRef = useRef<number | undefined>(undefined);
-
- useEffect(() => {
- const handleAddHostEvent = () => {
- setActiveTab("hosts");
- setEditingHost(null);
- setIsAddingHost(true);
- setIsAddingCredential(false);
- };
-
- const handleAddCredentialEvent = () => {
- setActiveTab("credentials");
- setEditingCredential(null);
- setIsAddingCredential(true);
- setIsAddingHost(false);
- };
-
- window.addEventListener("host-manager:add-host", handleAddHostEvent);
- window.addEventListener(
- "host-manager:add-credential",
- handleAddCredentialEvent,
- );
-
- return () => {
- window.removeEventListener("host-manager:add-host", handleAddHostEvent);
- window.removeEventListener(
- "host-manager:add-credential",
- handleAddCredentialEvent,
- );
- };
- }, []);
-
- useEffect(() => {
- if (_updateTimestamp !== undefined) {
- const normalizedTab =
- initialTab === "host_viewer" || initialTab === "add_host"
- ? "hosts"
- : initialTab === "credentials" || initialTab === "add_credential"
- ? "credentials"
- : initialTab;
-
- if (initialTab && normalizedTab !== activeTab) {
- setActiveTab(normalizedTab);
- }
-
- if (hostConfig && hostConfig.id !== lastProcessedHostIdRef.current) {
- lastProcessedHostIdRef.current = hostConfig.id;
- setIsAddingHost(false);
- exportSSHHostWithCredentials(hostConfig.id)
- .then((fullHost) =>
- setEditingHost({ ...hostConfig, ...fullHost } as SSHHost),
- )
- .catch(() => setEditingHost(hostConfig));
- } else if (!hostConfig && editingHost) {
- setEditingHost(null);
- setIsAddingHost(false);
- }
- } else {
- if (initialTab) {
- const normalizedTab =
- initialTab === "host_viewer" || initialTab === "add_host"
- ? "hosts"
- : initialTab === "credentials" || initialTab === "add_credential"
- ? "credentials"
- : initialTab;
- setActiveTab(normalizedTab);
- }
- if (hostConfig && hostConfig.id !== lastProcessedHostIdRef.current) {
- lastProcessedHostIdRef.current = hostConfig.id;
- setIsAddingHost(false);
- exportSSHHostWithCredentials(hostConfig.id)
- .then((fullHost) =>
- setEditingHost({ ...hostConfig, ...fullHost } as SSHHost),
- )
- .catch(() => setEditingHost(hostConfig));
- }
- }
- }, [_updateTimestamp, initialTab, hostConfig]);
-
- const handleEditHost = async (host: SSHHost) => {
- setIsAddingHost(false);
- lastProcessedHostIdRef.current = host.id;
- try {
- const fullHost = await exportSSHHostWithCredentials(host.id);
- setEditingHost({ ...host, ...fullHost } as SSHHost);
- } catch {
- setEditingHost(host);
- }
- };
-
- const handleAddHost = () => {
- setEditingHost(null);
- setIsAddingHost(true);
- lastProcessedHostIdRef.current = undefined;
- };
-
- const handleFormSubmit = (savedHost?: SSHHost) => {
- ignoreNextHostConfigChangeRef.current = true;
- const isUpdatingHost = Boolean(editingHost?.id && savedHost?.id);
-
- if (isUpdatingHost) {
- setEditingHost((current) => ({ ...current, ...savedHost }) as SSHHost);
- setIsAddingHost(false);
- lastProcessedHostIdRef.current = savedHost.id;
- if (updateTab && currentTabId !== undefined) {
- updateTab(currentTabId, { hostConfig: savedHost });
- }
- return;
- }
-
- const savedHostId = savedHost?.id || editingHost?.id;
- setEditingHost(null);
- setIsAddingHost(false);
- setTimeout(() => {
- lastProcessedHostIdRef.current = savedHostId;
- }, 500);
- };
-
- const handleEditCredential = (credential: {
- id: number;
- name?: string;
- username: string;
- }) => {
- setEditingCredential(credential);
- setIsAddingCredential(false);
- };
-
- const handleAddCredential = () => {
- setEditingCredential(null);
- setIsAddingCredential(true);
- };
-
- const handleCredentialFormSubmit = () => {
- setEditingCredential(null);
- setIsAddingCredential(false);
- };
-
- const handleTabChange = (value: string) => {
- if (activeTab !== value) {
- setEditingHost(null);
- setEditingCredential(null);
- setIsAddingHost(false);
- setIsAddingCredential(false);
- lastProcessedHostIdRef.current = undefined;
-
- if (updateTab && currentTabId !== undefined) {
- updateTab(currentTabId, { hostConfig: null });
- }
- }
-
- setActiveTab(value);
-
- if (updateTab && currentTabId !== undefined) {
- updateTab(currentTabId, { initialTab: value });
- }
- };
-
- const topMarginPx = isTopbarOpen ? 74 : 26;
- const leftMarginPx = sidebarState === "collapsed" ? 26 : 8;
- const bottomMarginPx = 8;
-
- return (
- <div>
- <div className="w-full">
- <div
- className="bg-canvas text-foreground p-4 pt-0 rounded-lg border-2 border-edge flex flex-col min-h-0 overflow-hidden"
- style={{
- marginLeft: leftMarginPx,
- marginRight: rightSidebarOpen
- ? `calc(var(--right-sidebar-width, ${rightSidebarWidth}px) + 8px)`
- : 17,
- marginTop: topMarginPx,
- marginBottom: bottomMarginPx,
- height: `calc(100vh - ${topMarginPx + bottomMarginPx}px)`,
- transition:
- "margin-left 200ms linear, margin-right 200ms linear, margin-top 200ms linear",
- }}
- >
- <Tabs
- value={activeTab}
- onValueChange={handleTabChange}
- className="flex-1 flex flex-col h-full min-h-0"
- >
- <TabsList className="bg-elevated border-2 border-edge mt-1.5">
- <TabsTrigger
- value="hosts"
- className="bg-elevated data-[state=active]:bg-button data-[state=active]:border data-[state=active]:border-edge"
- >
- {t("hosts.hosts")}
- </TabsTrigger>
- <TabsTrigger
- value="credentials"
- className="bg-elevated data-[state=active]:bg-button data-[state=active]:border data-[state=active]:border-edge"
- >
- {t("credentials.credentials")}
- </TabsTrigger>
- </TabsList>
- <TabsContent
- value="hosts"
- className="flex-1 flex flex-col h-full min-h-0"
- >
- <Separator className="p-0.25 -mt-0.5 mb-1" />
- {editingHost !== null || isAddingHost ? (
- <div className="flex flex-col h-full min-h-0">
- <HostManagerEditor
- editingHost={editingHost}
- onFormSubmit={handleFormSubmit}
- onBack={() => {
- setEditingHost(null);
- setIsAddingHost(false);
- lastProcessedHostIdRef.current = undefined;
- }}
- />
- </div>
- ) : (
- <HostManagerViewer
- onEditHost={handleEditHost}
- onAddHost={handleAddHost}
- />
- )}
- </TabsContent>
- <TabsContent
- value="credentials"
- className="flex-1 flex flex-col h-full min-h-0"
- >
- <Separator className="p-0.25 -mt-0.5 mb-1" />
- {editingCredential !== null || isAddingCredential ? (
- <div className="flex flex-col h-full min-h-0">
- <CredentialEditor
- editingCredential={editingCredential}
- onFormSubmit={handleCredentialFormSubmit}
- onBack={() => {
- setEditingCredential(null);
- setIsAddingCredential(false);
- }}
- />
- </div>
- ) : (
- <div className="flex flex-col h-full min-h-0 overflow-auto thin-scrollbar">
- <CredentialsManager
- onEditCredential={handleEditCredential}
- onAddCredential={handleAddCredential}
- />
- </div>
- )}
- </TabsContent>
- </Tabs>
- </div>
- </div>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/HostManagerEditor.tsx b/src/ui/desktop/apps/host-manager/hosts/HostManagerEditor.tsx
deleted file mode 100644
index caa159eba..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/HostManagerEditor.tsx
+++ /dev/null
@@ -1,1458 +0,0 @@
-import { zodResolver } from "@hookform/resolvers/zod";
-import { useForm, type Resolver } from "react-hook-form";
-import { z } from "zod";
-
-import { Button } from "@/components/ui/button.tsx";
-import {
- Form,
- FormControl,
- FormField,
- FormItem,
-} from "@/components/ui/form.tsx";
-
-import { ScrollArea } from "@/components/ui/scroll-area.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
-import {
- Tabs,
- TabsContent,
- TabsList,
- TabsTrigger,
-} from "@/components/ui/tabs.tsx";
-import React, { useEffect, useRef, useState } from "react";
-import { Alert, AlertDescription } from "@/components/ui/alert.tsx";
-import { toast } from "sonner";
-import {
- createSSHHost,
- getCredentials,
- getSSHHosts,
- updateSSHHost,
- enableAutoStart,
- disableAutoStart,
- getSnippets,
- getGuacamoleSettings,
-} from "@/ui/main-axios.ts";
-import { useTranslation } from "react-i18next";
-import { oneDark } from "@codemirror/theme-one-dark";
-import { githubLight } from "@uiw/codemirror-theme-github";
-import { useTheme } from "@/components/theme-provider.tsx";
-import type { StatsConfig } from "@/types/stats-widgets.ts";
-import { DEFAULT_STATS_CONFIG } from "@/types/stats-widgets.ts";
-
-import { DEFAULT_TERMINAL_CONFIG } from "@/constants/terminal-themes.ts";
-import type { SSHHost, SSHHostData, Credential } from "@/types";
-import { ArrowLeft } from "lucide-react";
-import { HostGeneralTab } from "./tabs/HostGeneralTab";
-import { HostTerminalTab } from "./tabs/HostTerminalTab";
-import { HostDockerTab } from "./tabs/HostDockerTab";
-import { HostTunnelTab } from "./tabs/HostTunnelTab";
-import { HostFileManagerTab } from "./tabs/HostFileManagerTab";
-import { HostStatisticsTab } from "./tabs/HostStatisticsTab";
-import { HostStatusTab } from "./tabs/HostStatusTab";
-import { HostSharingTab } from "./tabs/HostSharingTab";
-import { HostRemoteDesktopTab } from "./tabs/HostRemoteDesktopTab";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
-
-interface SSHManagerHostEditorProps {
- editingHost?: SSHHost | null;
- onFormSubmit?: (updatedHost?: SSHHost) => void;
- onBack?: () => void;
-}
-
-function isValidIPv4(value: string) {
- const parts = value.split(".");
- return (
- parts.length === 4 &&
- parts.every((part) => {
- if (!/^\d+$/.test(part)) return false;
- const parsed = Number(part);
- return parsed >= 0 && parsed <= 255;
- })
- );
-}
-
-export function HostManagerEditor({
- editingHost,
- onFormSubmit,
- onBack,
-}: SSHManagerHostEditorProps) {
- const { t } = useTranslation();
- const { theme: appTheme } = useTheme();
-
- const isDarkMode =
- appTheme === "dark" ||
- (appTheme === "system" &&
- window.matchMedia("(prefers-color-scheme: dark)").matches);
- const editorTheme = isDarkMode ? oneDark : githubLight;
- const [folders, setFolders] = useState<string[]>([]);
- const [hosts, setHosts] = useState<SSHHost[]>([]);
- const [credentials, setCredentials] = useState<Credential[]>([]);
- const [snippets, setSnippets] = useState<
- Array<{ id: number; name: string; content: string }>
- >([]);
- const [proxyMode, setProxyMode] = useState<"single" | "chain">("single");
-
- const [authTab, setAuthTab] = useState<
- "password" | "key" | "credential" | "none" | "opkssh"
- >("password");
- const [keyInputMethod, setKeyInputMethod] = useState<"upload" | "paste">(
- "upload",
- );
- const [isSubmitting, setIsSubmitting] = useState(false);
- const [activeTab, setActiveTab] = useState("general");
- const [formError, setFormError] = useState<string | null>(null);
- const [guacEnabled, setGuacEnabled] = useState(true);
-
- useEffect(() => {
- setFormError(null);
- }, [activeTab]);
-
- useEffect(() => {
- getGuacamoleSettings()
- .then((data) => setGuacEnabled(data.enabled))
- .catch(() => {});
- }, []);
-
- const [statusIntervalUnit, setStatusIntervalUnit] = useState<
- "seconds" | "minutes"
- >("seconds");
- const [metricsIntervalUnit, setMetricsIntervalUnit] = useState<
- "seconds" | "minutes"
- >("seconds");
-
- const ipInputRef = useRef<HTMLInputElement>(null);
-
- useEffect(() => {
- const fetchData = async () => {
- try {
- const [hostsData, credentialsData, snippetsData] = await Promise.all([
- getSSHHosts(),
- getCredentials(),
- getSnippets(),
- ]);
- setHosts(hostsData);
- setCredentials(credentialsData as Credential[]);
- setSnippets(Array.isArray(snippetsData) ? snippetsData : []);
-
- const uniqueFolders = [
- ...new Set(
- hostsData
- .filter((host) => host.folder && host.folder.trim() !== "")
- .map((host) => host.folder),
- ),
- ].sort();
-
- setFolders(uniqueFolders);
- } catch (error) {
- console.error("Host manager operation failed:", error);
- }
- };
-
- fetchData();
- }, []);
-
- useEffect(() => {
- const handleCredentialChange = async () => {
- try {
- const hostsData = await getSSHHosts();
-
- const uniqueFolders = [
- ...new Set(
- hostsData
- .filter((host) => host.folder && host.folder.trim() !== "")
- .map((host) => host.folder),
- ),
- ].sort();
-
- const uniqueConfigurations = [
- ...new Set(
- hostsData
- .filter((host) => host.name && host.name.trim() !== "")
- .map((host) => host.name),
- ),
- ].sort();
-
- setFolders(uniqueFolders);
- setSshConfigurations(uniqueConfigurations);
- } catch (error) {
- console.error("Host manager operation failed:", error);
- }
- };
-
- window.addEventListener("credentials:changed", handleCredentialChange);
-
- return () => {
- window.removeEventListener("credentials:changed", handleCredentialChange);
- };
- }, []);
-
- const tunnelConnectionSchema = z.object({
- scope: z.enum(["s2s", "c2s"]).default("s2s").optional(),
- mode: z.enum(["local", "remote", "dynamic"]).default("remote").optional(),
- tunnelType: z.enum(["local", "remote"]).default("remote").optional(),
- bindHost: z.string().optional(),
- sourcePort: z.coerce.number().min(1).max(65535),
- endpointPort: z.coerce.number().min(1).max(65535),
- endpointHost: z.string().optional(),
- targetHost: z.string().optional(),
- endpointPassword: z.string().optional(),
- endpointKey: z.string().optional(),
- endpointKeyPassword: z.string().optional(),
- endpointAuthType: z.string().optional(),
- endpointKeyType: z.string().optional(),
- maxRetries: z.coerce.number().min(0).max(100).default(3),
- retryInterval: z.coerce.number().min(1).max(3600).default(10),
- autoStart: z.boolean().default(false),
- });
-
- const formSchema = z
- .object({
- connectionType: z.enum(["ssh", "rdp", "vnc", "telnet"]).default("ssh"),
- name: z.string().optional(),
- ip: z.string().min(1, t("hosts.ipRequired", "IP address is required")),
- port: z.coerce.number().min(1).max(65535),
- username: z.string().optional(),
- folder: z.string().optional(),
- tags: z.array(z.string().min(1)).default([]),
- pin: z.boolean().default(false),
- authType: z.enum(["password", "key", "credential", "none", "opkssh"]),
- credentialId: z.number().optional().nullable(),
- overrideCredentialUsername: z.boolean().optional(),
- password: z.string().optional(),
- key: z.any().optional().nullable(),
- keyPassword: z.string().optional(),
- keyType: z
- .enum([
- "auto",
- "ssh-rsa",
- "ssh-ed25519",
- "ecdsa-sha2-nistp256",
- "ecdsa-sha2-nistp384",
- "ecdsa-sha2-nistp521",
- "ssh-dss",
- "ssh-rsa-sha2-256",
- "ssh-rsa-sha2-512",
- ])
- .optional(),
- enableTerminal: z.boolean().default(true),
- enableTunnel: z.boolean().default(true),
- tunnelConnections: z.array(tunnelConnectionSchema).default([]),
- serverTunnels: z.array(tunnelConnectionSchema).default([]),
- enableFileManager: z.boolean().default(true),
- defaultPath: z.string().optional(),
- statsConfig: z
- .object({
- enabledWidgets: z
- .array(
- z.enum([
- "cpu",
- "memory",
- "disk",
- "network",
- "uptime",
- "processes",
- "system",
- "login_stats",
- "ports",
- "firewall",
- ]),
- )
- .default([
- "cpu",
- "memory",
- "disk",
- "network",
- "uptime",
- "system",
- "login_stats",
- "ports",
- "firewall",
- ]),
- statusCheckEnabled: z.boolean().default(true),
- statusCheckInterval: z.number().min(5).max(3600).default(30),
- useGlobalStatusInterval: z.boolean().default(true),
- metricsEnabled: z.boolean().default(true),
- metricsInterval: z.number().min(5).max(3600).default(30),
- useGlobalMetricsInterval: z.boolean().default(true),
- disableTcpPing: z.boolean().default(false),
- })
- .default({
- enabledWidgets: [
- "cpu",
- "memory",
- "disk",
- "network",
- "uptime",
- "system",
- "login_stats",
- "ports",
- "firewall",
- ],
- statusCheckEnabled: true,
- statusCheckInterval: 30,
- useGlobalStatusInterval: true,
- metricsEnabled: true,
- metricsInterval: 30,
- useGlobalMetricsInterval: true,
- disableTcpPing: false,
- }),
- terminalConfig: z
- .object({
- cursorBlink: z.boolean(),
- cursorStyle: z.enum(["block", "underline", "bar"]),
- fontSize: z.number().min(8).max(24),
- fontFamily: z.string(),
- letterSpacing: z.number().min(-2).max(10),
- lineHeight: z.number().min(1.0).max(2.0),
- theme: z.string(),
- scrollback: z.number().min(1000).max(50000),
- bellStyle: z.enum(["none", "sound", "visual", "both"]),
- rightClickSelectsWord: z.boolean(),
- fastScrollModifier: z.enum(["alt", "ctrl", "shift"]),
- fastScrollSensitivity: z.number().min(1).max(10),
- minimumContrastRatio: z.number().min(1).max(21),
- backspaceMode: z.enum(["normal", "control-h"]),
- agentForwarding: z.boolean(),
- environmentVariables: z.array(
- z.object({
- key: z.string(),
- value: z.string(),
- }),
- ),
- startupSnippetId: z.number().nullable(),
- autoMosh: z.boolean(),
- moshCommand: z.string(),
- sudoPasswordAutoFill: z.boolean(),
- sudoPassword: z.string().optional(),
- keepaliveInterval: z.number().min(0).max(300000).optional(),
- keepaliveCountMax: z.number().min(0).max(100).optional(),
- autoTmux: z.boolean(),
- })
- .optional(),
- forceKeyboardInteractive: z.boolean().optional(),
- jumpHosts: z
- .array(
- z.object({
- hostId: z.number().min(1),
- }),
- )
- .default([]),
- quickActions: z
- .array(
- z.object({
- name: z.string().min(1),
- snippetId: z.number().min(1),
- }),
- )
- .default([]),
- notes: z.string().optional(),
- useSocks5: z.boolean().optional(),
- socks5Host: z.string().optional(),
- socks5Port: z.coerce.number().min(1).max(65535).optional(),
- socks5Username: z.string().optional(),
- socks5Password: z.string().optional(),
- socks5ProxyChain: z
- .array(
- z.object({
- host: z.string().min(1),
- port: z.number().min(1).max(65535),
- type: z.union([z.literal(4), z.literal(5)]),
- username: z.string().optional(),
- password: z.string().optional(),
- }),
- )
- .optional(),
- macAddress: z.string().optional(),
- portKnockSequence: z
- .array(
- z.object({
- port: z.coerce.number().min(1).max(65535),
- protocol: z.enum(["tcp", "udp"]).default("tcp"),
- delay: z.coerce.number().min(0).max(60000).default(100),
- }),
- )
- .optional(),
- enableDocker: z.boolean().default(false),
- domain: z.string().optional(),
- security: z.string().optional(),
- ignoreCert: z.boolean().default(true),
- guacamoleConfig: z.record(z.string(), z.unknown()).optional(),
- showTerminalInSidebar: z.boolean().default(true),
- showFileManagerInSidebar: z.boolean().default(false),
- showTunnelInSidebar: z.boolean().default(false),
- showDockerInSidebar: z.boolean().default(false),
- showServerStatsInSidebar: z.boolean().default(false),
- })
- .superRefine((data, ctx) => {
- if (data.connectionType !== "ssh") {
- return;
- }
-
- if (!data.username || data.username.trim() === "") {
- if (data.authType !== "credential") {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: t("hosts.usernameRequired", "Username is required"),
- path: ["username"],
- });
- }
- }
-
- const serverTunnels = data.serverTunnels;
-
- serverTunnels.forEach((tunnel, index) => {
- if (
- (tunnel.scope || "s2s") === "s2s" &&
- (!tunnel.endpointHost || tunnel.endpointHost.trim() === "")
- ) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: t(
- "tunnels.endpointSshConfigRequired",
- "Endpoint SSH configuration is required",
- ),
- path: ["serverTunnels", index, "endpointHost"],
- });
- }
-
- const currentHostIp =
- tunnel.mode === "remote" ? tunnel.targetHost : tunnel.bindHost;
- if (currentHostIp && !isValidIPv4(currentHostIp)) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: t("tunnels.invalidCurrentHostIp"),
- path: [
- "serverTunnels",
- index,
- tunnel.mode === "remote" ? "targetHost" : "bindHost",
- ],
- });
- }
- });
-
- if (data.authType === "none") {
- return;
- }
-
- if (data.authType === "opkssh") {
- return;
- }
-
- if (data.authType === "password") {
- if (
- !data.password ||
- (typeof data.password === "string" &&
- data.password.trim() === "" &&
- data.password !== "existing_password")
- ) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: t("hosts.passwordRequired", "Password is required"),
- path: ["password"],
- });
- }
- } else if (data.authType === "key") {
- if (
- !data.key ||
- (typeof data.key === "string" &&
- data.key.trim() === "" &&
- data.key !== "existing_key")
- ) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: t("hosts.sshKeyRequired", "SSH key is required"),
- path: ["key"],
- });
- }
- if (!data.keyType) {
- data.keyType = "auto";
- }
- } else if (data.authType === "credential") {
- if (!data.credentialId) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: t("hosts.credentialRequired", "Credential is required"),
- path: ["credentialId"],
- });
- }
- }
- });
-
- type FormData = z.infer<typeof formSchema>;
-
- const form = useForm<FormData>({
- resolver: zodResolver(formSchema) as unknown as Resolver<FormData>,
- mode: "all",
- defaultValues: {
- connectionType: "ssh" as const,
- name: "",
- ip: "",
- port: 22,
- username: "",
- folder: "",
- tags: [],
- pin: false,
- authType: "password" as const,
- credentialId: null,
- overrideCredentialUsername: false,
- password: "",
- key: null,
- keyPassword: "",
- keyType: "auto" as const,
- enableTerminal: true,
- enableTunnel: true,
- enableFileManager: true,
- showTerminalInSidebar: true,
- showFileManagerInSidebar: false,
- showTunnelInSidebar: false,
- showDockerInSidebar: false,
- showServerStatsInSidebar: false,
- defaultPath: "/",
- tunnelConnections: [],
- serverTunnels: [],
- jumpHosts: [],
- quickActions: [],
- statsConfig: DEFAULT_STATS_CONFIG,
- terminalConfig: DEFAULT_TERMINAL_CONFIG,
- forceKeyboardInteractive: false,
- notes: "",
- useSocks5: false,
- socks5Host: "",
- socks5Port: 1080,
- socks5Username: "",
- socks5Password: "",
- socks5ProxyChain: [],
- macAddress: "",
- portKnockSequence: [],
- enableDocker: false,
- domain: "",
- security: "any",
- ignoreCert: true,
- guacamoleConfig: {},
- },
- });
-
- const watchedFields = form.watch();
- const formState = form.formState;
- const watchedConnectionType = form.watch("connectionType") || "ssh";
-
- const prevConnectionTypeRef = useRef<string>("ssh");
- useEffect(() => {
- const prev = prevConnectionTypeRef.current;
- const current = watchedConnectionType;
- if (prev === current) return;
- prevConnectionTypeRef.current = current;
-
- const portDefaults: Record<string, number> = {
- ssh: 22,
- rdp: 3389,
- vnc: 5900,
- telnet: 23,
- };
- const currentPort = form.getValues("port");
- const oldDefault = portDefaults[prev] || 22;
- if (currentPort === oldDefault) {
- form.setValue("port", portDefaults[current] || 22);
- }
-
- if (current !== "ssh") {
- const currentStatsConfig = form.getValues("statsConfig");
- form.setValue("statsConfig", {
- ...currentStatsConfig,
- metricsEnabled: false,
- disableTcpPing: false,
- });
- }
-
- if (activeTab !== "general" && current !== "ssh") {
- setActiveTab("general");
- }
- }, [watchedConnectionType]);
-
- const isFormValid = React.useMemo(() => {
- const errors = formState.errors;
-
- if (!watchedFields.ip) return false;
-
- if (watchedFields.connectionType !== "ssh") {
- const port = Number(watchedFields.port);
- return !errors.ip && port >= 1 && port <= 65535;
- }
-
- if (!watchedFields.username || watchedFields.username.trim() === "")
- return false;
-
- if (authTab === "password") {
- if (
- !watchedFields.password ||
- (watchedFields.password !== "existing_password" &&
- watchedFields.password.trim() === "")
- )
- return false;
- } else if (authTab === "key") {
- if (!watchedFields.key || !watchedFields.keyType) return false;
- } else if (authTab === "credential") {
- if (!watchedFields.credentialId) return false;
- } else if (authTab === "none") {
- // No auth required
- } else if (authTab === "opkssh") {
- // No auth required
- } else {
- return false;
- }
-
- return Object.keys(errors).length === 0;
- }, [watchedFields, authTab, formState.errors]);
-
- useEffect(() => {
- const updateAuthFields = async () => {
- form.setValue("authType", authTab, { shouldValidate: true });
-
- if (authTab === "password") {
- form.setValue("key", null, { shouldValidate: true });
- form.setValue("keyPassword", "", { shouldValidate: true });
- form.setValue("keyType", "auto", { shouldValidate: true });
- form.setValue("credentialId", null, { shouldValidate: true });
- } else if (authTab === "key") {
- form.setValue("password", "", { shouldValidate: true });
- form.setValue("credentialId", null, { shouldValidate: true });
- } else if (authTab === "credential") {
- form.setValue("password", "", { shouldValidate: true });
- form.setValue("key", null, { shouldValidate: true });
- form.setValue("keyPassword", "", { shouldValidate: true });
- form.setValue("keyType", "auto", { shouldValidate: true });
-
- const currentCredentialId = form.getValues("credentialId");
- const overrideUsername = form.getValues("overrideCredentialUsername");
- if (currentCredentialId && !overrideUsername) {
- const selectedCredential = credentials.find(
- (c) => c.id === currentCredentialId,
- );
- if (selectedCredential?.username) {
- form.setValue("username", selectedCredential.username, {
- shouldValidate: true,
- });
- }
- }
- } else if (authTab === "none") {
- const connectionType = form.getValues("connectionType");
- if (connectionType === "ssh") {
- form.setValue("password", "", { shouldValidate: true });
- }
- form.setValue("key", null, { shouldValidate: true });
- form.setValue("keyPassword", "", { shouldValidate: true });
- form.setValue("keyType", "auto", { shouldValidate: true });
- form.setValue("credentialId", null, { shouldValidate: true });
- } else if (authTab === "opkssh") {
- form.setValue("password", "", { shouldValidate: true });
- form.setValue("key", null, { shouldValidate: true });
- form.setValue("keyPassword", "", { shouldValidate: true });
- form.setValue("keyType", "auto", { shouldValidate: true });
- form.setValue("credentialId", null, { shouldValidate: true });
- }
-
- await form.trigger();
- };
-
- updateAuthFields();
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [authTab, credentials]);
-
- useEffect(() => {
- if (editingHost) {
- const cleanedHost = { ...editingHost };
- if (cleanedHost.connectionType === "ssh") {
- if (cleanedHost.credentialId && cleanedHost.key) {
- cleanedHost.key = undefined;
- cleanedHost.keyPassword = undefined;
- cleanedHost.keyType = undefined;
- } else if (cleanedHost.credentialId && cleanedHost.password) {
- cleanedHost.password = undefined;
- } else if (cleanedHost.key && cleanedHost.password) {
- cleanedHost.password = undefined;
- }
- }
-
- const defaultAuthType = (cleanedHost.authType ||
- (cleanedHost.credentialId
- ? "credential"
- : cleanedHost.key
- ? "key"
- : cleanedHost.password
- ? "password"
- : "none")) as
- | "password"
- | "key"
- | "credential"
- | "none"
- | "opkssh";
-
- setAuthTab(defaultAuthType);
-
- let parsedStatsConfig: StatsConfig = DEFAULT_STATS_CONFIG;
- try {
- if (cleanedHost.statsConfig) {
- parsedStatsConfig =
- typeof cleanedHost.statsConfig === "string"
- ? JSON.parse(cleanedHost.statsConfig)
- : (cleanedHost.statsConfig as StatsConfig);
- }
- } catch (error) {
- console.error("Failed to parse statsConfig:", error);
- }
-
- parsedStatsConfig = { ...DEFAULT_STATS_CONFIG, ...parsedStatsConfig };
-
- const formData: Partial<FormData> = {
- connectionType: cleanedHost.connectionType || "ssh",
- name: cleanedHost.name || "",
- ip: cleanedHost.ip || "",
- port: cleanedHost.port || 22,
- username: cleanedHost.username || "",
- folder: cleanedHost.folder || "",
- tags: Array.isArray(cleanedHost.tags) ? cleanedHost.tags : [],
- pin: Boolean(cleanedHost.pin),
- authType: defaultAuthType as
- | "password"
- | "key"
- | "credential"
- | "none"
- | "opkssh",
- credentialId: cleanedHost.credentialId,
- overrideCredentialUsername: Boolean(
- cleanedHost.overrideCredentialUsername,
- ),
- password: "",
- key: null,
- keyPassword: "",
- keyType: "auto" as const,
- enableTerminal: Boolean(cleanedHost.enableTerminal),
- enableTunnel: Boolean(cleanedHost.enableTunnel),
- enableFileManager: Boolean(cleanedHost.enableFileManager),
- defaultPath: cleanedHost.defaultPath || "/",
- tunnelConnections: Array.isArray(cleanedHost.tunnelConnections)
- ? cleanedHost.tunnelConnections.map((conn) => ({
- ...conn,
- scope: conn.scope || "s2s",
- mode: conn.mode || conn.tunnelType || "remote",
- tunnelType: conn.tunnelType || "remote",
- }))
- : [],
- jumpHosts: Array.isArray(cleanedHost.jumpHosts)
- ? cleanedHost.jumpHosts
- : [],
- quickActions: Array.isArray(cleanedHost.quickActions)
- ? cleanedHost.quickActions
- : [],
- statsConfig: parsedStatsConfig,
- terminalConfig: {
- ...DEFAULT_TERMINAL_CONFIG,
- ...(cleanedHost.terminalConfig || {}),
- environmentVariables: Array.isArray(
- cleanedHost.terminalConfig?.environmentVariables,
- )
- ? cleanedHost.terminalConfig.environmentVariables
- : [],
- sudoPassword:
- cleanedHost.sudoPassword ||
- cleanedHost.terminalConfig?.sudoPassword ||
- "",
- sudoPasswordAutoFill:
- cleanedHost.terminalConfig?.sudoPasswordAutoFill ??
- Boolean(cleanedHost.sudoPassword),
- },
- forceKeyboardInteractive: Boolean(cleanedHost.forceKeyboardInteractive),
- notes: cleanedHost.notes || "",
- useSocks5: Boolean(cleanedHost.useSocks5),
- socks5Host: cleanedHost.socks5Host || "",
- socks5Port: cleanedHost.socks5Port || 1080,
- socks5Username: cleanedHost.socks5Username || "",
- socks5Password: cleanedHost.socks5Password || "",
- socks5ProxyChain: Array.isArray(cleanedHost.socks5ProxyChain)
- ? cleanedHost.socks5ProxyChain
- : [],
- macAddress: cleanedHost.macAddress || "",
- portKnockSequence: Array.isArray(cleanedHost.portKnockSequence)
- ? cleanedHost.portKnockSequence
- : [],
- enableDocker: Boolean(cleanedHost.enableDocker),
- domain: cleanedHost.domain || "",
- security: cleanedHost.security || "any",
- ignoreCert: cleanedHost.ignoreCert ?? true,
- guacamoleConfig: (() => {
- const cfg = cleanedHost.guacamoleConfig;
- if (!cfg) return {};
- if (typeof cfg === "string") {
- try {
- return JSON.parse(cfg);
- } catch {
- return {};
- }
- }
- return cfg;
- })(),
- showTerminalInSidebar: cleanedHost.showTerminalInSidebar ?? true,
- showFileManagerInSidebar: cleanedHost.showFileManagerInSidebar ?? false,
- showTunnelInSidebar: cleanedHost.showTunnelInSidebar ?? false,
- showDockerInSidebar: cleanedHost.showDockerInSidebar ?? false,
- showServerStatsInSidebar: cleanedHost.showServerStatsInSidebar ?? false,
- };
-
- if (
- Array.isArray(cleanedHost.socks5ProxyChain) &&
- cleanedHost.socks5ProxyChain.length > 0
- ) {
- setProxyMode("chain");
- } else {
- setProxyMode("single");
- }
-
- if (cleanedHost.connectionType !== "ssh") {
- if (cleanedHost.password) {
- formData.password = cleanedHost.password;
- }
- } else if (defaultAuthType === "password") {
- formData.password =
- cleanedHost.password || (editingHost.id ? "existing_password" : "");
- } else if (defaultAuthType === "key") {
- formData.key = editingHost.id ? "existing_key" : editingHost.key;
- formData.keyPassword = cleanedHost.keyPassword || "";
- formData.keyType =
- (cleanedHost.keyType as
- | "auto"
- | "ssh-rsa"
- | "ssh-ed25519"
- | "ecdsa-sha2-nistp256"
- | "ecdsa-sha2-nistp384"
- | "ecdsa-sha2-nistp521"
- | "ssh-dss"
- | "ssh-rsa-sha2-256"
- | "ssh-rsa-sha2-512") || "auto";
- } else if (defaultAuthType === "credential") {
- formData.credentialId = cleanedHost.credentialId;
- }
-
- const serverTunnels = Array.isArray(formData.tunnelConnections)
- ? formData.tunnelConnections.filter((tunnel) => tunnel.scope !== "c2s")
- : [];
- formData.serverTunnels = serverTunnels;
- form.reset(formData as FormData);
- } else {
- setAuthTab("password");
- const defaultFormData: Partial<FormData> = {
- connectionType: "ssh" as const,
- name: "",
- ip: "",
- port: 22,
- username: "",
- folder: "",
- tags: [],
- pin: false,
- authType: "password" as const,
- credentialId: null,
- overrideCredentialUsername: false,
- password: "",
- key: null,
- keyPassword: "",
- keyType: "auto" as const,
- enableTerminal: true,
- enableTunnel: true,
- enableFileManager: true,
- defaultPath: "/",
- tunnelConnections: [],
- serverTunnels: [],
- jumpHosts: [],
- quickActions: [],
- statsConfig: DEFAULT_STATS_CONFIG,
- terminalConfig: DEFAULT_TERMINAL_CONFIG,
- forceKeyboardInteractive: false,
- enableDocker: false,
- domain: "",
- security: "any",
- ignoreCert: true,
- guacamoleConfig: {},
- showTerminalInSidebar: true,
- showFileManagerInSidebar: false,
- showTunnelInSidebar: false,
- showDockerInSidebar: false,
- showServerStatsInSidebar: false,
- };
-
- form.reset(defaultFormData as FormData);
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [editingHost]);
-
- useEffect(() => {
- const focusTimer = setTimeout(() => {
- if (ipInputRef.current) {
- ipInputRef.current.focus();
- }
- }, 300);
-
- return () => clearTimeout(focusTimer);
- }, [editingHost]);
-
- const onSubmit = async (data: FormData) => {
- try {
- setIsSubmitting(true);
- setFormError(null);
-
- if (!data.name || data.name.trim() === "") {
- data.name = `${data.username}@${data.ip}`;
- }
-
- type SubmitHostData = SSHHostData & { serverTunnels?: unknown };
- const submitData: SubmitHostData = {
- ...data,
- };
- delete submitData.serverTunnels;
-
- const serverTunnels = Array.isArray(data.serverTunnels)
- ? data.serverTunnels
- : [];
- const serverTunnelConnections = serverTunnels.map((tunnel) => ({
- ...tunnel,
- scope: "s2s" as const,
- }));
-
- submitData.tunnelConnections = serverTunnelConnections;
-
- submitData.connectionType = data.connectionType;
- submitData.domain = data.domain;
- submitData.security = data.security;
- submitData.ignoreCert = data.ignoreCert;
- submitData.guacamoleConfig = data.guacamoleConfig;
-
- if (data.connectionType !== "ssh") {
- submitData.authType = "none";
- submitData.key = undefined;
- submitData.keyPassword = undefined;
- submitData.keyType = undefined;
- submitData.credentialId = undefined;
- submitData.tunnelConnections = [];
- submitData.jumpHosts = [];
- submitData.useSocks5 = false;
- submitData.socks5ProxyChain = [];
- submitData.forceKeyboardInteractive = false;
- submitData.enableTunnel = false;
- submitData.enableFileManager = false;
- submitData.enableDocker = false;
- submitData.enableTerminal = true;
- } else {
- if (
- data.terminalConfig?.sudoPasswordAutoFill &&
- data.terminalConfig?.sudoPassword
- ) {
- submitData.sudoPassword = data.terminalConfig.sudoPassword;
- }
-
- if (data.authType !== "credential") {
- submitData.credentialId = undefined;
- }
- if (data.authType !== "password") {
- submitData.password = undefined;
- }
- if (data.authType !== "key") {
- submitData.key = undefined;
- submitData.keyPassword = undefined;
- submitData.keyType = undefined;
- }
- }
-
- if (data.authType === "key") {
- if (data.key instanceof File) {
- submitData.key = await data.key.text();
- } else if (data.key === "existing_key") {
- delete submitData.key;
- }
- }
-
- if (
- data.authType === "password" &&
- data.password === "existing_password"
- ) {
- delete submitData.password;
- }
-
- let savedHost;
- if (editingHost && editingHost.id) {
- savedHost = await updateSSHHost(editingHost.id, submitData);
- toast.success(t("hosts.hostUpdatedSuccessfully", { name: data.name }));
- } else {
- savedHost = await createSSHHost(submitData);
- toast.success(t("hosts.hostAddedSuccessfully", { name: data.name }));
- }
-
- if (savedHost && savedHost.id && serverTunnelConnections) {
- const hasAutoStartTunnels = serverTunnelConnections.some(
- (tunnel) => tunnel.autoStart,
- );
-
- if (hasAutoStartTunnels) {
- try {
- await enableAutoStart(savedHost.id);
- } catch (error) {
- console.warn(
- `Failed to enable AutoStart plaintext cache for SSH host ${savedHost.id}:`,
- error,
- );
- toast.warning(
- t("tunnels.autoStartEnableFailed", { name: data.name }),
- );
- }
- } else {
- try {
- await disableAutoStart(savedHost.id);
- } catch (error) {
- console.warn(
- `Failed to disable AutoStart plaintext cache for SSH host ${savedHost.id}:`,
- error,
- );
- }
- }
- }
-
- if (onFormSubmit) {
- onFormSubmit(savedHost);
- }
-
- window.dispatchEvent(new CustomEvent("ssh-hosts:changed"));
- } catch (error) {
- const errorMessage =
- error instanceof Error ? error.message : String(error);
- toast.error(t("hosts.failedToSaveHost") + ": " + errorMessage);
- console.error("Failed to save host:", error);
- } finally {
- setIsSubmitting(false);
- }
- };
-
- const TAB_PRIORITY = [
- "general",
- "terminal",
- "tunnel",
- "file_manager",
- "docker",
- "statistics",
- ] as const;
-
- const FIELD_TO_TAB_MAP: Record<string, string> = {
- ip: "general",
- port: "general",
- username: "general",
- name: "general",
- folder: "general",
- tags: "general",
- pin: "general",
- password: "general",
- key: "general",
- keyPassword: "general",
- keyType: "general",
- credentialId: "general",
- overrideCredentialUsername: "general",
- forceKeyboardInteractive: "general",
- jumpHosts: "general",
- authType: "general",
- notes: "general",
- useSocks5: "general",
- socks5Host: "general",
- socks5Port: "general",
- socks5Username: "general",
- socks5Password: "general",
- socks5ProxyChain: "general",
- portKnockSequence: "general",
- quickActions: "general",
- enableTerminal: "terminal",
- terminalConfig: "terminal",
- enableDocker: "docker",
- domain: "general",
- security: "general",
- ignoreCert: "general",
- guacamoleConfig: "remote_desktop",
- connectionType: "general",
- enableTunnel: "tunnel",
- tunnelConnections: "tunnel",
- serverTunnels: "tunnel",
- enableFileManager: "file_manager",
- defaultPath: "file_manager",
- statsConfig: "statistics",
- };
-
- const handleFormError = async () => {
- await new Promise((resolve) => setTimeout(resolve, 0));
-
- const errors = form.formState.errors;
- const errorFields = Object.keys(errors);
-
- if (errorFields.length === 0) return;
-
- const firstErrorField = errorFields[0];
- const firstError = errors[firstErrorField as keyof typeof errors];
- const errorMessage =
- firstError && typeof firstError === "object" && "message" in firstError
- ? (firstError.message as string)
- : t("hosts.failedToSaveHost");
- toast.error(errorMessage);
-
- for (const tab of TAB_PRIORITY) {
- const hasErrorInTab = errorFields.some((field) => {
- const baseField = field.split(".")[0].split("[")[0];
- return FIELD_TO_TAB_MAP[baseField] === tab;
- });
-
- if (hasErrorInTab) {
- setActiveTab(tab);
- return;
- }
- }
- };
-
- const [tagInput, setTagInput] = useState("");
-
- const [folderDropdownOpen, setFolderDropdownOpen] = useState(false);
- const folderInputRef = useRef<HTMLInputElement>(null);
- const folderDropdownRef = useRef<HTMLDivElement>(null);
-
- const folderValue = form.watch("folder");
- const filteredFolders = React.useMemo(() => {
- if (!folderValue) return folders;
- return folders.filter((f) =>
- f.toLowerCase().includes(folderValue.toLowerCase()),
- );
- }, [folderValue, folders]);
-
- const handleFolderClick = (folder: string) => {
- form.setValue("folder", folder);
- setFolderDropdownOpen(false);
- };
-
- useEffect(() => {
- function handleClickOutside(event: MouseEvent) {
- if (
- folderDropdownRef.current &&
- !folderDropdownRef.current.contains(event.target as Node) &&
- folderInputRef.current &&
- !folderInputRef.current.contains(event.target as Node)
- ) {
- setFolderDropdownOpen(false);
- }
- }
-
- if (folderDropdownOpen) {
- document.addEventListener("mousedown", handleClickOutside);
- } else {
- document.removeEventListener("mousedown", handleClickOutside);
- }
-
- return () => {
- document.removeEventListener("mousedown", handleClickOutside);
- };
- }, [folderDropdownOpen]);
-
- const keyTypeOptions = [
- { value: "auto", label: t("hosts.autoDetect") },
- { value: "ssh-rsa", label: t("hosts.rsa") },
- { value: "ssh-ed25519", label: t("hosts.ed25519") },
- { value: "ecdsa-sha2-nistp256", label: t("hosts.ecdsaNistP256") },
- { value: "ecdsa-sha2-nistp384", label: t("hosts.ecdsaNistP384") },
- { value: "ecdsa-sha2-nistp521", label: t("hosts.ecdsaNistP521") },
- { value: "ssh-dss", label: t("hosts.dsa") },
- { value: "ssh-rsa-sha2-256", label: t("hosts.rsaSha2256") },
- { value: "ssh-rsa-sha2-512", label: t("hosts.rsaSha2512") },
- ];
-
- const [keyTypeDropdownOpen, setKeyTypeDropdownOpen] = useState(false);
- const keyTypeButtonRef = useRef<HTMLButtonElement>(null);
- const keyTypeDropdownRef = useRef<HTMLDivElement>(null);
-
- useEffect(() => {
- function onClickOutside(event: MouseEvent) {
- if (
- keyTypeDropdownOpen &&
- keyTypeDropdownRef.current &&
- !keyTypeDropdownRef.current.contains(event.target as Node) &&
- keyTypeButtonRef.current &&
- !keyTypeButtonRef.current.contains(event.target as Node)
- ) {
- setKeyTypeDropdownOpen(false);
- }
- }
-
- document.addEventListener("mousedown", onClickOutside);
- return () => document.removeEventListener("mousedown", onClickOutside);
- }, [keyTypeDropdownOpen]);
-
- return (
- <div className="flex-1 flex flex-col h-full min-h-0 w-full relative">
- <SimpleLoader
- visible={isSubmitting}
- message={
- editingHost?.id
- ? t("hosts.updatingHost")
- : editingHost
- ? t("hosts.cloningHost")
- : t("hosts.savingHost")
- }
- backgroundColor="var(--bg-base)"
- />
- <Form {...form}>
- <form
- onSubmit={form.handleSubmit(onSubmit, handleFormError)}
- className="flex flex-col flex-1 min-h-0 h-full"
- >
- <ScrollArea className="flex-1 min-h-0 w-full my-1 pb-2">
- <div className="pr-4">
- {formError && (
- <Alert variant="destructive" className="mb-4">
- <AlertDescription>{formError}</AlertDescription>
- </Alert>
- )}
- <div className="flex items-center gap-2 mb-3">
- {onBack && (
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={onBack}
- className="flex-shrink-0"
- >
- <ArrowLeft className="h-4 w-4 mr-2" />
- {t("common.back")}
- </Button>
- )}
- <h3 className="text-lg font-semibold flex-shrink-0">
- {editingHost
- ? editingHost.id
- ? t("hosts.editHost")
- : t("hosts.cloneHost")
- : t("hosts.addHost")}
- </h3>
- </div>
- {guacEnabled && (
- <FormField
- control={form.control}
- name="connectionType"
- render={({ field }) => (
- <FormItem className="mb-4">
- <FormControl>
- <Tabs
- value={field.value || "ssh"}
- onValueChange={field.onChange}
- className="w-full"
- >
- <TabsList className="bg-button border border-edge-medium">
- <TabsTrigger
- value="ssh"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- {t("hosts.ssh")}
- </TabsTrigger>
- <TabsTrigger
- value="rdp"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- {t("hosts.rdp")}
- </TabsTrigger>
- <TabsTrigger
- value="vnc"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- {t("hosts.vnc")}
- </TabsTrigger>
- <TabsTrigger
- value="telnet"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- {t("hosts.telnet")}
- </TabsTrigger>
- </TabsList>
- </Tabs>
- </FormControl>
- </FormItem>
- )}
- />
- )}
- <Tabs
- value={activeTab}
- onValueChange={setActiveTab}
- className="w-full"
- >
- <TabsList className="bg-button border border-edge-medium">
- <TabsTrigger
- value="general"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- {t("hosts.general")}
- </TabsTrigger>
- {watchedConnectionType === "ssh" && (
- <>
- <TabsTrigger
- value="terminal"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- {t("hosts.terminal")}
- </TabsTrigger>
- <TabsTrigger
- value="docker"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- Docker
- </TabsTrigger>
- <TabsTrigger
- value="tunnel"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- {t("hosts.tunnel")}
- </TabsTrigger>
- <TabsTrigger
- value="file_manager"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- {t("hosts.fileManager")}
- </TabsTrigger>
- </>
- )}
- <TabsTrigger
- value="statistics"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- {watchedConnectionType === "ssh"
- ? t("hosts.statistics")
- : t("hosts.status")}
- </TabsTrigger>
- {watchedConnectionType !== "ssh" && (
- <TabsTrigger
- value="remote_desktop"
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium"
- >
- {t("hosts.remoteDesktop")}
- </TabsTrigger>
- )}
- {watchedConnectionType === "ssh" &&
- !editingHost?.isShared && (
- <TabsTrigger value="sharing">
- {t("rbac.sharing")}
- </TabsTrigger>
- )}
- </TabsList>
- <TabsContent value="general" className="pt-2">
- <HostGeneralTab
- form={form}
- connectionType={
- watchedConnectionType as "ssh" | "rdp" | "vnc" | "telnet"
- }
- authTab={authTab}
- setAuthTab={setAuthTab}
- keyInputMethod={keyInputMethod}
- setKeyInputMethod={setKeyInputMethod}
- proxyMode={proxyMode}
- setProxyMode={setProxyMode}
- tagInput={tagInput}
- setTagInput={setTagInput}
- folderDropdownOpen={folderDropdownOpen}
- setFolderDropdownOpen={setFolderDropdownOpen}
- folderInputRef={folderInputRef}
- folderDropdownRef={folderDropdownRef}
- filteredFolders={filteredFolders}
- handleFolderClick={handleFolderClick}
- keyTypeDropdownOpen={keyTypeDropdownOpen}
- setKeyTypeDropdownOpen={setKeyTypeDropdownOpen}
- keyTypeButtonRef={keyTypeButtonRef}
- keyTypeDropdownRef={keyTypeDropdownRef}
- keyTypeOptions={keyTypeOptions}
- ipInputRef={ipInputRef}
- editorTheme={editorTheme}
- hosts={hosts}
- editingHost={editingHost}
- folders={folders}
- credentials={credentials}
- t={t}
- />
- </TabsContent>
- {watchedConnectionType === "ssh" && (
- <>
- <TabsContent value="terminal" className="space-y-1">
- <HostTerminalTab form={form} snippets={snippets} t={t} />
- </TabsContent>
- <TabsContent value="docker" className="space-y-4">
- <HostDockerTab form={form} t={t} />
- </TabsContent>
- <TabsContent value="tunnel">
- <HostTunnelTab
- form={form}
- hosts={hosts}
- editingHost={editingHost}
- t={t}
- />
- </TabsContent>
- <TabsContent value="file_manager">
- <HostFileManagerTab form={form} t={t} />
- </TabsContent>
- </>
- )}
- <TabsContent value="statistics" className="space-y-6">
- {watchedConnectionType === "ssh" ? (
- <HostStatisticsTab
- form={form}
- statusIntervalUnit={statusIntervalUnit}
- setStatusIntervalUnit={setStatusIntervalUnit}
- metricsIntervalUnit={metricsIntervalUnit}
- setMetricsIntervalUnit={setMetricsIntervalUnit}
- snippets={snippets}
- t={t}
- />
- ) : (
- <HostStatusTab
- form={form}
- statusIntervalUnit={statusIntervalUnit}
- setStatusIntervalUnit={setStatusIntervalUnit}
- t={t}
- />
- )}
- </TabsContent>
- {watchedConnectionType !== "ssh" && (
- <TabsContent value="remote_desktop" className="space-y-4">
- <HostRemoteDesktopTab
- form={form}
- connectionType={
- watchedConnectionType as "rdp" | "vnc" | "telnet"
- }
- t={t}
- />
- </TabsContent>
- )}
- {watchedConnectionType === "ssh" && (
- <TabsContent value="sharing" className="space-y-6">
- <HostSharingTab
- hostId={editingHost?.id}
- isNewHost={!editingHost}
- />
- </TabsContent>
- )}
- </Tabs>
- </div>
- </ScrollArea>
- <footer className="shrink-0 w-full pb-0">
- <Separator className="p-0.25" />
- {!editingHost?.isShared && !isSubmitting && (
- <div className="flex items-center gap-3 translate-y-2">
- <Button type="submit" variant="outline" disabled={!isFormValid}>
- {editingHost
- ? editingHost.id
- ? t("hosts.updateHost")
- : t("hosts.cloneHost")
- : t("hosts.addHost")}
- </Button>
- {form.formState.isDirty && (
- <span className="text-xs text-muted-foreground">
- {t("common.unsavedChanges")}
- </span>
- )}
- </div>
- )}
- </footer>
- </form>
- </Form>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/HostManagerViewer.tsx b/src/ui/desktop/apps/host-manager/hosts/HostManagerViewer.tsx
deleted file mode 100644
index 8bff0c751..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/HostManagerViewer.tsx
+++ /dev/null
@@ -1,2591 +0,0 @@
-import React, {
- useState,
- useEffect,
- useMemo,
- useRef,
- useCallback,
-} from "react";
-import { Button } from "@/components/ui/button.tsx";
-import { Badge } from "@/components/ui/badge.tsx";
-import { ScrollArea } from "@/components/ui/scroll-area.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import {
- Accordion,
- AccordionContent,
- AccordionItem,
- AccordionTrigger,
-} from "@/components/ui/accordion.tsx";
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "@/components/ui/tooltip.tsx";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu.tsx";
-import {
- getSSHHosts,
- deleteSSHHost,
- bulkImportSSHHosts,
- bulkUpdateSSHHosts,
- updateSSHHost,
- renameFolder,
- exportSSHHostWithCredentials,
- exportAllSSHHosts,
- getSSHFolders,
- updateFolderMetadata,
- deleteAllHostsInFolder,
- refreshServerPolling,
- isElectron,
- getConfiguredServerUrl,
- getGuacamoleDpi,
- getGuacamoleTokenFromHost,
- logActivity,
-} from "@/ui/main-axios.ts";
-import { useServerStatus } from "@/ui/contexts/ServerStatusContext";
-import { toast } from "sonner";
-import { useTranslation } from "react-i18next";
-import { useConfirmation } from "@/hooks/use-confirmation.ts";
-import { Status, StatusIndicator } from "@/components/ui/shadcn-io/status";
-import {
- Edit,
- Trash2,
- Server,
- Folder,
- Tag,
- Pin,
- Terminal,
- Network,
- FileEdit,
- Search,
- Upload,
- X,
- Check,
- Pencil,
- FolderMinus,
- Copy,
- Palette,
- Trash,
- Cloud,
- Database,
- Box,
- Package,
- Layers,
- Archive,
- HardDrive,
- Globe,
- FolderOpen,
- Share2,
- ArrowDownUp,
- Container,
- Link,
- Plus,
- ListChecks,
- ChevronDown,
- Monitor,
- MessagesSquare,
- Eye,
- ChevronsDownUp,
- ChevronsUpDown,
- RefreshCw,
-} from "lucide-react";
-import type {
- SSHHost,
- SSHFolder,
- SSHManagerHostViewerProps,
-} from "../../../../../types";
-import { DEFAULT_STATS_CONFIG } from "@/types/stats-widgets.ts";
-import { Checkbox } from "@/components/ui/checkbox.tsx";
-import { FolderEditDialog } from "@/ui/desktop/apps/host-manager/dialogs/FolderEditDialog.tsx";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
-
-const INITIAL_HOSTS_PER_FOLDER = 12;
-
-export function HostManagerViewer({
- onEditHost,
- onAddHost,
-}: SSHManagerHostViewerProps) {
- const { t } = useTranslation();
- const { confirmWithToast } = useConfirmation();
- const { addTab } = useTabs();
- const [hosts, setHosts] = useState<SSHHost[]>([]);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState<string | null>(null);
- const [searchQuery, setSearchQuery] = useState("");
- const [importing, setImporting] = useState(false);
- const overwriteRef = useRef(false);
- const [draggedHost, setDraggedHost] = useState<SSHHost | null>(null);
- const [dragOverFolder, setDragOverFolder] = useState<string | null>(null);
- const [editingFolder, setEditingFolder] = useState<string | null>(null);
- const [editingFolderName, setEditingFolderName] = useState("");
- const [operationLoading, setOperationLoading] = useState(false);
- const [refreshing, setRefreshing] = useState(false);
- const [folderMetadata, setFolderMetadata] = useState<Map<string, SSHFolder>>(
- new Map(),
- );
- const [editingFolderAppearance, setEditingFolderAppearance] = useState<
- string | null
- >(null);
- const [expandedFolders, setExpandedFolders] = useState<Set<string>>(
- new Set(),
- );
- const [openAccordions, setOpenAccordions] = useState<string[]>([]);
- const [selectionMode, setSelectionMode] = useState(false);
- const [selectedHostIds, setSelectedHostIds] = useState<Set<number>>(
- new Set(),
- );
- const [bulkUpdating, setBulkUpdating] = useState(false);
- const { getStatus, refreshStatuses } = useServerStatus();
- const dragCounter = useRef(0);
-
- useEffect(() => {
- fetchHosts();
- fetchFolderMetadata();
-
- const handleHostsRefresh = () => {
- fetchHosts();
- fetchFolderMetadata();
- };
-
- const handleFoldersRefresh = () => {
- fetchFolderMetadata();
- };
-
- window.addEventListener("hosts:refresh", handleHostsRefresh);
- window.addEventListener("ssh-hosts:changed", handleHostsRefresh);
- window.addEventListener("folders:changed", handleFoldersRefresh);
-
- return () => {
- window.removeEventListener("hosts:refresh", handleHostsRefresh);
- window.removeEventListener("ssh-hosts:changed", handleHostsRefresh);
- window.removeEventListener("folders:changed", handleFoldersRefresh);
- };
- }, []);
-
- const fetchHosts = async (options: { showLoading?: boolean } = {}) => {
- const { showLoading = true } = options;
- try {
- if (showLoading) setLoading(true);
- const data = await getSSHHosts();
-
- const cleanedHosts = data.map((host) => {
- const cleanedHost = { ...host };
- if (cleanedHost.credentialId && cleanedHost.key) {
- cleanedHost.key = undefined;
- cleanedHost.keyPassword = undefined;
- cleanedHost.keyType = undefined;
- cleanedHost.authType = "credential";
- } else if (cleanedHost.credentialId && cleanedHost.password) {
- cleanedHost.password = undefined;
- cleanedHost.authType = "credential";
- } else if (cleanedHost.key && cleanedHost.password) {
- cleanedHost.password = undefined;
- cleanedHost.authType = "key";
- }
- return cleanedHost;
- });
-
- setHosts(cleanedHosts);
- setError(null);
- } catch {
- setError(t("hosts.failedToLoadHosts"));
- } finally {
- if (showLoading) setLoading(false);
- }
- };
-
- const fetchFolderMetadata = async () => {
- try {
- const folders = await getSSHFolders();
- const metadataMap = new Map<string, SSHFolder>();
- folders.forEach((folder) => {
- metadataMap.set(folder.name, folder);
- });
- setFolderMetadata(metadataMap);
- } catch (error) {
- console.error("Failed to fetch folder metadata:", error);
- }
- };
-
- const handleRefreshHosts = async () => {
- setRefreshing(true);
- try {
- await Promise.all([
- fetchHosts({ showLoading: false }),
- fetchFolderMetadata(),
- refreshServerPolling(),
- refreshStatuses(),
- ]);
- } finally {
- setRefreshing(false);
- }
- };
-
- const handleSaveFolderAppearance = async (
- folderName: string,
- color: string,
- icon: string,
- ) => {
- try {
- await updateFolderMetadata(folderName, color, icon);
- toast.success(t("hosts.folderAppearanceUpdated"));
- await fetchFolderMetadata();
- window.dispatchEvent(new CustomEvent("folders:changed"));
- } catch (error) {
- console.error("Failed to update folder appearance:", error);
- toast.error(t("hosts.failedToUpdateFolderAppearance"));
- }
- };
-
- const handleDeleteAllHostsInFolder = async (folderName: string) => {
- const hostsInFolder = hostsByFolder[folderName] || [];
- confirmWithToast(
- t("hosts.confirmDeleteAllHostsInFolder", {
- folder: folderName,
- count: hostsInFolder.length,
- }),
- async () => {
- try {
- const result = await deleteAllHostsInFolder(folderName);
- toast.success(
- t("hosts.allHostsInFolderDeleted", {
- folder: folderName,
- count: result.deletedCount,
- }),
- );
- await fetchHosts();
- await fetchFolderMetadata();
- window.dispatchEvent(new CustomEvent("ssh-hosts:changed"));
- } catch (error) {
- console.error("Failed to delete hosts in folder:", error);
- toast.error(t("hosts.failedToDeleteHostsInFolder"));
- }
- },
- "destructive",
- );
- };
-
- const getFolderIcon = (folderName: string) => {
- const metadata = folderMetadata.get(folderName);
- if (!metadata?.icon) return Folder;
-
- const iconMap: Record<string, React.ComponentType> = {
- Folder,
- Server,
- Cloud,
- Database,
- Box,
- Package,
- Layers,
- Archive,
- HardDrive,
- Globe,
- };
-
- return iconMap[metadata.icon] || Folder;
- };
-
- const getFolderColor = (folderName: string) => {
- const metadata = folderMetadata.get(folderName);
- return metadata?.color;
- };
-
- const handleDelete = async (hostId: number, hostName: string) => {
- confirmWithToast(
- t("hosts.confirmDelete", { name: hostName }),
- async () => {
- try {
- await deleteSSHHost(hostId);
- toast.success(t("hosts.hostDeletedSuccessfully", { name: hostName }));
- await fetchHosts();
- window.dispatchEvent(new CustomEvent("ssh-hosts:changed"));
-
- refreshServerPolling();
- } catch {
- toast.error(t("hosts.failedToDeleteHost"));
- }
- },
- "destructive",
- );
- };
-
- const handleExport = (host: SSHHost) => {
- const actualAuthType = host.credentialId
- ? "credential"
- : host.key
- ? "key"
- : "password";
-
- if (actualAuthType === "credential") {
- const confirmMessage = t("hosts.exportCredentialWarning", {
- name: host.name || `${host.username}@${host.ip}`,
- });
-
- confirmWithToast(confirmMessage, () => {
- performExport(host);
- });
- return;
- } else if (actualAuthType === "password" || actualAuthType === "key") {
- const confirmMessage = t("hosts.exportSensitiveDataWarning", {
- name: host.name || `${host.username}@${host.ip}`,
- });
-
- confirmWithToast(confirmMessage, () => {
- performExport(host);
- });
- return;
- }
-
- performExport(host);
- };
-
- const performExport = async (host: SSHHost) => {
- try {
- const decryptedHost = await exportSSHHostWithCredentials(host.id);
-
- const cleanExportData = Object.fromEntries(
- Object.entries(decryptedHost).filter(
- ([, value]) => value !== undefined,
- ),
- );
-
- const exportFormat = {
- hosts: [cleanExportData],
- };
-
- const blob = new Blob([JSON.stringify(exportFormat, null, 2)], {
- type: "application/json",
- });
- const url = URL.createObjectURL(blob);
- const a = document.createElement("a");
- a.href = url;
- a.download = `${host.name || host.username + "@" + host.ip}-host-config.json`;
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
- URL.revokeObjectURL(url);
-
- toast.success(
- t("hosts.exportedHostConfig", {
- name: host.name || `${host.username}@${host.ip}`,
- }),
- );
- } catch {
- toast.error(t("hosts.failedToExportHost"));
- }
- };
-
- const handleEdit = (host: SSHHost) => {
- if (selectionMode) return;
- if (onEditHost) {
- onEditHost(host);
- }
- };
-
- const toggleHostSelection = (hostId: number) => {
- setSelectedHostIds((prev) => {
- const next = new Set(prev);
- if (next.has(hostId)) next.delete(hostId);
- else next.add(hostId);
- return next;
- });
- };
-
- const exitSelectionMode = () => {
- setSelectionMode(false);
- setSelectedHostIds(new Set());
- };
-
- const handleBulkUpdate = async (updates: Record<string, unknown>) => {
- if (selectedHostIds.size === 0) return;
- try {
- setBulkUpdating(true);
- const result = await bulkUpdateSSHHosts(
- Array.from(selectedHostIds),
- updates,
- );
- if (result.updated > 0) {
- toast.success(t("hosts.bulkUpdateSuccess", { count: result.updated }));
- }
- if (result.errors.length > 0) {
- toast.error(result.errors.join(", "));
- }
- await fetchHosts();
- window.dispatchEvent(new CustomEvent("ssh-hosts:changed"));
- } catch {
- toast.error(t("hosts.bulkUpdateFailed"));
- } finally {
- setBulkUpdating(false);
- }
- };
-
- const selectAllHosts = () => {
- const selectableIds = hosts.filter((h) => !h.isShared).map((h) => h.id);
- setSelectedHostIds(new Set(selectableIds));
- };
-
- const deselectAllHosts = () => {
- setSelectedHostIds(new Set());
- };
-
- const handleClone = (host: SSHHost) => {
- if (onEditHost) {
- const clonedHost = { ...host };
- delete clonedHost.id;
- onEditHost(clonedHost);
- }
- };
-
- const copyFullScreenUrl = (host: SSHHost, appType: string) => {
- const baseUrl = isElectron()
- ? getConfiguredServerUrl() || window.location.origin
- : window.location.origin;
- const url = `${baseUrl}?view=${appType}&hostId=${host.id}`;
-
- if (navigator.clipboard && window.isSecureContext) {
- navigator.clipboard.writeText(url).then(
- () => {
- toast.success(t("hosts.fullScreenUrlCopied"));
- },
- () => {
- fallbackCopyTextToClipboard(url);
- },
- );
- } else {
- fallbackCopyTextToClipboard(url);
- }
- };
-
- const fallbackCopyTextToClipboard = (text: string) => {
- const textArea = document.createElement("textarea");
- textArea.value = text;
- textArea.style.position = "fixed";
- textArea.style.left = "-999999px";
- textArea.style.top = "-999999px";
- document.body.appendChild(textArea);
- textArea.focus();
- textArea.select();
- try {
- document.execCommand("copy");
- toast.success(t("hosts.fullScreenUrlCopied"));
- } catch {
- toast.error(t("hosts.failedToCopyUrl"));
- }
- document.body.removeChild(textArea);
- };
-
- const handleRemoveFromFolder = async (host: SSHHost) => {
- confirmWithToast(
- t("hosts.confirmRemoveFromFolder", {
- name: host.name || `${host.username}@${host.ip}`,
- folder: host.folder,
- }),
- async () => {
- try {
- setOperationLoading(true);
- const updatedHost = { ...host, folder: "" };
- await updateSSHHost(host.id, updatedHost);
- toast.success(
- t("hosts.removedFromFolder", {
- name: host.name || `${host.username}@${host.ip}`,
- }),
- );
- await fetchHosts();
- window.dispatchEvent(new CustomEvent("ssh-hosts:changed"));
- } catch {
- toast.error(t("hosts.failedToRemoveFromFolder"));
- } finally {
- setOperationLoading(false);
- }
- },
- );
- };
-
- const handleFolderRename = async (oldName: string) => {
- if (!editingFolderName.trim() || editingFolderName === oldName) {
- setEditingFolder(null);
- setEditingFolderName("");
- return;
- }
-
- try {
- setOperationLoading(true);
- await renameFolder(oldName, editingFolderName.trim());
- toast.success(
- t("hosts.folderRenamed", {
- oldName,
- newName: editingFolderName.trim(),
- }),
- );
- await fetchHosts();
- window.dispatchEvent(new CustomEvent("ssh-hosts:changed"));
- setEditingFolder(null);
- setEditingFolderName("");
- } catch {
- toast.error(t("hosts.failedToRenameFolder"));
- } finally {
- setOperationLoading(false);
- }
- };
-
- const startFolderEdit = (folderName: string) => {
- setEditingFolder(folderName);
- setEditingFolderName(folderName);
- };
-
- const cancelFolderEdit = () => {
- setEditingFolder(null);
- setEditingFolderName("");
- };
-
- const handleDragStart = (e: React.DragEvent, host: SSHHost) => {
- setDraggedHost(host);
- e.dataTransfer.effectAllowed = "move";
- e.dataTransfer.setData("text/plain", "");
- };
-
- const handleDragEnd = () => {
- setDraggedHost(null);
- setDragOverFolder(null);
- dragCounter.current = 0;
- };
-
- const handleDragOver = (e: React.DragEvent) => {
- e.preventDefault();
- e.dataTransfer.dropEffect = "move";
- };
-
- const handleDragEnter = (e: React.DragEvent, folderName: string) => {
- e.preventDefault();
- dragCounter.current++;
- setDragOverFolder(folderName);
- };
-
- const handleDragLeave = () => {
- dragCounter.current--;
- if (dragCounter.current === 0) {
- setDragOverFolder(null);
- }
- };
-
- const handleDrop = async (e: React.DragEvent, targetFolder: string) => {
- e.preventDefault();
- dragCounter.current = 0;
- setDragOverFolder(null);
-
- if (!draggedHost) return;
-
- const newFolder =
- targetFolder === t("hosts.uncategorized") ? "" : targetFolder;
-
- if (draggedHost.folder === newFolder) {
- setDraggedHost(null);
- return;
- }
-
- try {
- setOperationLoading(true);
- const updatedHost = { ...draggedHost, folder: newFolder };
- await updateSSHHost(draggedHost.id, updatedHost);
- toast.success(
- t("hosts.movedToFolder", {
- name: draggedHost.name || `${draggedHost.username}@${draggedHost.ip}`,
- folder: targetFolder,
- }),
- );
- await fetchHosts();
- window.dispatchEvent(new CustomEvent("ssh-hosts:changed"));
- } catch {
- toast.error(t("hosts.failedToMoveToFolder"));
- } finally {
- setOperationLoading(false);
- setDraggedHost(null);
- }
- };
-
- const getSampleData = () => ({
- hosts: [
- {
- connectionType: "ssh",
- name: t("interface.webServerProduction"),
- ip: "192.168.1.100",
- port: 22,
- username: "admin",
- authType: "password",
- password: "your_secure_password_here",
- folder: t("interface.productionFolder"),
- tags: ["web", "production", "nginx"],
- pin: true,
- notes: "Main production web server running Nginx",
- enableTerminal: true,
- enableTunnel: false,
- enableFileManager: true,
- enableDocker: false,
- showTerminalInSidebar: true,
- showFileManagerInSidebar: true,
- showServerStatsInSidebar: true,
- defaultPath: "/var/www",
- },
- {
- connectionType: "ssh",
- name: t("interface.databaseServer"),
- ip: "192.168.1.101",
- port: 22,
- username: "dbadmin",
- authType: "key",
- key: "-----BEGIN OPENSSH PRIVATE KEY-----\\nYour SSH private key content here\\n-----END OPENSSH PRIVATE KEY-----",
- keyPassword: "optional_key_passphrase",
- keyType: "ssh-ed25519",
- folder: t("interface.productionFolder"),
- tags: ["database", "production", "postgresql"],
- pin: false,
- notes: "PostgreSQL production database",
- enableTerminal: true,
- enableTunnel: true,
- enableFileManager: false,
- enableDocker: false,
- showTerminalInSidebar: true,
- showTunnelInSidebar: true,
- showServerStatsInSidebar: true,
- tunnelConnections: [
- {
- sourcePort: 5432,
- endpointPort: 5432,
- endpointHost: t("interface.webServerProduction"),
- maxRetries: 3,
- retryInterval: 10,
- autoStart: true,
- },
- ],
- statsConfig: {
- enabledWidgets: ["cpu", "memory", "disk", "network", "uptime"],
- statusCheckEnabled: true,
- statusCheckInterval: 30,
- metricsEnabled: true,
- metricsInterval: 30,
- },
- },
- {
- connectionType: "ssh",
- name: t("interface.developmentServer"),
- ip: "192.168.1.102",
- port: 2222,
- username: "developer",
- authType: "credential",
- credentialId: 1,
- overrideCredentialUsername: false,
- folder: t("interface.developmentFolder"),
- tags: ["dev", "testing"],
- pin: false,
- notes: "Development environment for testing",
- enableTerminal: true,
- enableTunnel: false,
- enableFileManager: true,
- enableDocker: true,
- showTerminalInSidebar: true,
- showFileManagerInSidebar: true,
- showDockerInSidebar: true,
- defaultPath: "/home/developer",
- sudoPassword: "dev_sudo_password",
- },
- {
- connectionType: "rdp",
- name: "Windows Server 2022",
- ip: "192.168.1.200",
- port: 3389,
- username: "Administrator",
- password: "windows_password",
- domain: "COMPANY",
- security: "nla",
- ignoreCert: false,
- folder: "Remote Desktop",
- tags: ["rdp", "windows", "production"],
- pin: false,
- notes: "Production Windows Server with RDP access",
- guacamoleConfig: {
- "enable-drive": true,
- "drive-path": "/shared",
- "create-drive-path": true,
- "server-layout": "en-us-qwerty",
- "resize-method": "display-update",
- },
- },
- {
- connectionType: "vnc",
- name: "Ubuntu Desktop",
- ip: "192.168.1.201",
- port: 5900,
- username: "vncuser",
- password: "vnc_password",
- folder: "Remote Desktop",
- tags: ["vnc", "linux", "desktop"],
- pin: false,
- notes: "Ubuntu desktop with VNC server",
- guacamoleConfig: {
- "color-depth": 24,
- cursor: "remote",
- "read-only": false,
- "clipboard-encoding": "UTF-8",
- },
- },
- {
- connectionType: "telnet",
- name: "Network Switch",
- ip: "192.168.1.254",
- port: 23,
- username: "admin",
- password: "switch_password",
- folder: "Infrastructure",
- tags: ["telnet", "network", "switch"],
- pin: false,
- notes: "Legacy network switch with Telnet access",
- guacamoleConfig: {
- "color-scheme": "green-black",
- "font-name": "monospace",
- "font-size": 12,
- scrollback: 1024,
- backspace: 127,
- },
- },
- {
- connectionType: "ssh",
- name: "Jump Host Server",
- ip: "10.0.0.50",
- port: 22,
- username: "sysadmin",
- authType: "password",
- password: "secure_password",
- folder: "Infrastructure",
- tags: ["bastion", "jump-host"],
- notes: "Jump host for accessing internal network",
- enableTerminal: true,
- enableTunnel: true,
- enableFileManager: true,
- enableDocker: false,
- jumpHosts: [
- {
- hostId: 1,
- },
- ],
- quickActions: [
- {
- name: "System Update",
- snippetId: 5,
- },
- ],
- },
- {
- connectionType: "ssh",
- name: "Server with SOCKS5 Proxy",
- ip: "10.10.10.100",
- port: 22,
- username: "proxyuser",
- authType: "password",
- password: "secure_password",
- folder: "Proxied Hosts",
- tags: ["proxy", "socks5"],
- notes: "Accessible through SOCKS5 proxy",
- enableTerminal: true,
- enableTunnel: false,
- enableFileManager: true,
- enableDocker: false,
- useSocks5: true,
- socks5Host: "proxy.example.com",
- socks5Port: 1080,
- socks5Username: "proxyauth",
- socks5Password: "proxypass",
- },
- {
- connectionType: "ssh",
- name: "Customized Terminal Server",
- ip: "192.168.1.150",
- port: 22,
- username: "devops",
- authType: "password",
- password: "terminal_password",
- folder: t("interface.developmentFolder"),
- tags: ["custom", "terminal"],
- notes: "Server with custom terminal configuration",
- enableTerminal: true,
- enableTunnel: false,
- enableFileManager: true,
- enableDocker: false,
- defaultPath: "/opt/apps",
- terminalConfig: {
- cursorBlink: true,
- cursorStyle: "bar",
- fontSize: 16,
- fontFamily: "jetbrainsMono",
- letterSpacing: 0.5,
- lineHeight: 1.2,
- theme: "monokai",
- scrollback: 50000,
- bellStyle: "visual",
- rightClickSelectsWord: true,
- fastScrollModifier: "ctrl",
- fastScrollSensitivity: 7,
- minimumContrastRatio: 4,
- backspaceMode: "normal",
- agentForwarding: true,
- environmentVariables: [
- {
- key: "NODE_ENV",
- value: "development",
- },
- ],
- autoMosh: false,
- sudoPasswordAutoFill: true,
- sudoPassword: "sudo_password_here",
- },
- },
- ],
- });
-
- const handleDownloadSample = () => {
- const sampleData = getSampleData();
- const blob = new Blob([JSON.stringify(sampleData, null, 2)], {
- type: "application/json",
- });
- const url = URL.createObjectURL(blob);
- const a = document.createElement("a");
- a.href = url;
- a.download = "sample-ssh-hosts.json";
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
- URL.revokeObjectURL(url);
- };
-
- const [exporting, setExporting] = useState(false);
-
- const handleExportAll = () => {
- confirmWithToast(
- t("hosts.exportAllSensitiveWarning"),
- async () => {
- setExporting(true);
- try {
- const data = await exportAllSSHHosts();
- const blob = new Blob([JSON.stringify(data, null, 2)], {
- type: "application/json",
- });
- const url = URL.createObjectURL(blob);
- const a = document.createElement("a");
- a.href = url;
- a.download = `termix-hosts-export-${new Date().toISOString().slice(0, 10)}.json`;
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
- URL.revokeObjectURL(url);
- toast.success(
- t("hosts.exportedAllHosts", { count: data.hosts.length }),
- );
- } catch {
- toast.error(t("hosts.failedToExportAllHosts"));
- } finally {
- setExporting(false);
- }
- },
- "destructive",
- );
- };
-
- const handleJsonImport = async (
- event: React.ChangeEvent<HTMLInputElement>,
- ) => {
- const file = event.target.files?.[0];
- if (!file) return;
-
- try {
- setImporting(true);
- const text = await file.text();
- const data = JSON.parse(text);
-
- if (!Array.isArray(data.hosts) && !Array.isArray(data)) {
- throw new Error(t("hosts.jsonMustContainHosts"));
- }
-
- const hostsArray = Array.isArray(data.hosts) ? data.hosts : data;
-
- if (hostsArray.length === 0) {
- throw new Error(t("hosts.noHostsInJson"));
- }
-
- if (hostsArray.length > 100) {
- throw new Error(t("hosts.maxHostsAllowed"));
- }
-
- const result = await bulkImportSSHHosts(hostsArray, overwriteRef.current);
-
- if (result.success > 0 || result.updated > 0) {
- const parts: string[] = [];
- if (result.success > 0)
- parts.push(`${result.success} ${t("hosts.importCreated")}`);
- if (result.updated > 0)
- parts.push(`${result.updated} ${t("hosts.importUpdated")}`);
- if (result.failed > 0)
- parts.push(`${result.failed} ${t("hosts.importFailedCount")}`);
- toast.success(parts.join(", "));
- if (result.errors.length > 0) {
- toast.error(`Import errors: ${result.errors.join(", ")}`);
- }
- await fetchHosts();
- window.dispatchEvent(new CustomEvent("ssh-hosts:changed"));
- } else {
- toast.error(t("hosts.importFailed") + `: ${result.errors.join(", ")}`);
- }
- } catch (err) {
- const errorMessage =
- err instanceof Error ? err.message : t("hosts.failedToImportJson");
- toast.error(t("hosts.importError") + `: ${errorMessage}`);
- } finally {
- setImporting(false);
- event.target.value = "";
- }
- };
-
- const filteredAndSortedHosts = useMemo(() => {
- let filtered = hosts;
-
- if (searchQuery.trim()) {
- const query = searchQuery.toLowerCase();
- filtered = hosts.filter((host) => {
- const searchableText = [
- host.name || "",
- host.username,
- host.ip,
- host.folder || "",
- ...(host.tags || []),
- host.authType,
- host.defaultPath || "",
- ]
- .join(" ")
- .toLowerCase();
- return searchableText.includes(query);
- });
- }
-
- return filtered.sort((a, b) => {
- if (a.pin && !b.pin) return -1;
- if (!a.pin && b.pin) return 1;
-
- const aName = a.name || a.username;
- const bName = b.name || b.username;
- return aName.localeCompare(bName);
- });
- }, [hosts, searchQuery]);
-
- const hostsByFolder = useMemo(() => {
- const grouped: { [key: string]: SSHHost[] } = {};
-
- filteredAndSortedHosts.forEach((host) => {
- const folder = host.folder || t("hosts.uncategorized");
- if (!grouped[folder]) {
- grouped[folder] = [];
- }
- grouped[folder].push(host);
- });
-
- const sortedFolders = Object.keys(grouped).sort((a, b) => {
- if (a === t("hosts.uncategorized")) return -1;
- if (b === t("hosts.uncategorized")) return 1;
- return a.localeCompare(b);
- });
-
- const sortedGrouped: { [key: string]: SSHHost[] } = {};
- sortedFolders.forEach((folder) => {
- sortedGrouped[folder] = grouped[folder];
- });
-
- return sortedGrouped;
- }, [filteredAndSortedHosts]);
-
- const folderKeys = useMemo(() => Object.keys(hostsByFolder), [hostsByFolder]);
- const folderKeysString = useMemo(() => folderKeys.join(","), [folderKeys]);
-
- useEffect(() => {
- setOpenAccordions((prev) => {
- if (prev.length === 0 && folderKeys.length > 0) {
- return folderKeys;
- }
- const existingFolders = prev.filter((folder) =>
- folderKeys.includes(folder),
- );
- const newFolders = folderKeys.filter((folder) => !prev.includes(folder));
- return [...existingFolders, ...newFolders];
- });
- }, [folderKeysString]);
-
- const toggleFolderExpansion = useCallback((folderName: string) => {
- setExpandedFolders((prev) => {
- const next = new Set(prev);
- if (next.has(folderName)) {
- next.delete(folderName);
- } else {
- next.add(folderName);
- }
- return next;
- });
- }, []);
-
- const getVisibleHosts = useCallback(
- (folderName: string, allHosts: SSHHost[]) => {
- if (
- expandedFolders.has(folderName) ||
- allHosts.length <= INITIAL_HOSTS_PER_FOLDER
- ) {
- return allHosts;
- }
- return allHosts.slice(0, INITIAL_HOSTS_PER_FOLDER);
- },
- [expandedFolders],
- );
-
- if (loading) {
- return <SimpleLoader visible={true} message={t("hosts.loadingHosts")} />;
- }
-
- if (error) {
- return (
- <div className="flex items-center justify-center h-full">
- <div className="text-center">
- <p className="text-red-500 mb-4">{error}</p>
- <Button onClick={fetchHosts} variant="outline">
- {t("hosts.retry")}
- </Button>
- </div>
- </div>
- );
- }
-
- if (hosts.length === 0) {
- return (
- <TooltipProvider>
- <div className="flex flex-col h-full min-h-0">
- <div className="flex items-center justify-between mb-2">
- <div>
- <h2 className="text-xl font-semibold">{t("hosts.sshHosts")}</h2>
- <p className="text-muted-foreground">
- {t("hosts.hostsCount", { count: 0 })}
- </p>
- </div>
- <div className="flex items-center gap-2">
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="outline" size="sm" disabled={importing}>
- {importing ? t("hosts.importing") : t("hosts.importJson")}
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuItem
- onClick={() => {
- overwriteRef.current = false;
- document.getElementById("json-import-input")?.click();
- }}
- >
- {t("hosts.importSkipExisting")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onClick={() => {
- overwriteRef.current = true;
- document.getElementById("json-import-input")?.click();
- }}
- >
- {t("hosts.importOverwriteExisting")}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
-
- <Button
- variant="outline"
- size="sm"
- onClick={handleDownloadSample}
- >
- {t("hosts.downloadSample")}
- </Button>
-
- <Button
- variant="outline"
- size="sm"
- onClick={() => {
- window.open("https://docs.termix.site/json-import", "_blank");
- }}
- >
- {t("hosts.formatGuide")}
- </Button>
-
- <div className="w-px h-6 bg-border mx-2" />
-
- <Button
- onClick={handleRefreshHosts}
- variant="outline"
- size="sm"
- disabled={refreshing}
- >
- <RefreshCw
- className={`h-4 w-4 mr-2 ${refreshing ? "animate-spin" : ""}`}
- />
- {t("hosts.refresh")}
- </Button>
- </div>
- </div>
-
- <input
- id="json-import-input"
- type="file"
- accept=".json"
- onChange={handleJsonImport}
- className="hidden"
- />
-
- <div className="flex gap-2 mb-3">
- <div className="relative flex-1">
- <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
- <Input
- placeholder={t("placeholders.searchHosts")}
- value={searchQuery}
- onChange={(e) => setSearchQuery(e.target.value)}
- className="pl-10 h-9"
- disabled
- />
- </div>
- <Button variant="outline" className="h-9" onClick={onAddHost}>
- <Plus className="h-4 w-4 mr-2" />
- {t("hosts.addHost")}
- </Button>
- </div>
-
- <div className="flex items-center justify-center flex-1">
- <div className="text-center">
- <Server className="h-12 w-12 text-muted-foreground mx-auto mb-4" />
- <h3 className="text-lg font-semibold mb-2">
- {t("hosts.noHosts")}
- </h3>
- <p className="text-muted-foreground mb-4">
- {t("hosts.noHostsMessage")}
- </p>
- </div>
- </div>
- </div>
- </TooltipProvider>
- );
- }
-
- return (
- <TooltipProvider>
- <div className="flex flex-col h-full min-h-0">
- <div className="flex items-center justify-between mb-2">
- <div>
- <h2 className="text-xl font-semibold">{t("hosts.sshHosts")}</h2>
- <p className="text-muted-foreground">
- {t("hosts.hostsCount", { count: filteredAndSortedHosts.length })}
- </p>
- </div>
- <div className="flex items-center gap-2">
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="outline" size="sm" disabled={importing}>
- {importing ? t("hosts.importing") : t("hosts.importJson")}
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuItem
- onClick={() => {
- overwriteRef.current = false;
- document.getElementById("json-import-input")?.click();
- }}
- >
- {t("hosts.importSkipExisting")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onClick={() => {
- overwriteRef.current = true;
- document.getElementById("json-import-input")?.click();
- }}
- >
- {t("hosts.importOverwriteExisting")}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
-
- <Button
- variant="outline"
- size="sm"
- disabled={exporting || hosts.length === 0}
- onClick={handleExportAll}
- >
- {exporting ? t("hosts.exporting") : t("hosts.exportAllJson")}
- </Button>
-
- <Button variant="outline" size="sm" onClick={handleDownloadSample}>
- {t("hosts.downloadSample")}
- </Button>
-
- <Button
- variant="outline"
- size="sm"
- onClick={() => {
- window.open("https://docs.termix.site/json-import", "_blank");
- }}
- >
- {t("hosts.formatGuide")}
- </Button>
-
- <div className="w-px h-6 bg-border mx-2" />
-
- <Button
- onClick={handleRefreshHosts}
- variant="outline"
- size="sm"
- disabled={refreshing}
- >
- <RefreshCw
- className={`h-4 w-4 mr-2 ${refreshing ? "animate-spin" : ""}`}
- />
- {t("hosts.refresh")}
- </Button>
- </div>
- </div>
-
- <input
- id="json-import-input"
- type="file"
- accept=".json"
- onChange={handleJsonImport}
- className="hidden"
- />
-
- <div className="flex gap-2 mb-3">
- <div className="relative flex-1">
- <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
- <Input
- placeholder={t("placeholders.searchHosts")}
- value={searchQuery}
- onChange={(e) => setSearchQuery(e.target.value)}
- className="pl-10 h-9"
- />
- </div>
- <Button variant="outline" className="h-9" onClick={onAddHost}>
- <Plus className="h-4 w-4 mr-2" />
- {t("hosts.addHost")}
- </Button>
- <Button
- variant={selectionMode ? "default" : "outline"}
- className="h-9"
- onClick={() => {
- if (selectionMode) exitSelectionMode();
- else setSelectionMode(true);
- }}
- >
- <ListChecks className="h-4 w-4 mr-2" />
- {selectionMode ? t("hosts.exitSelectMode") : t("hosts.selectMode")}
- </Button>
- <Button
- variant="outline"
- className="h-9"
- onClick={() => {
- if (openAccordions.length > 0) {
- setOpenAccordions([]);
- } else {
- setOpenAccordions(folderKeys);
- }
- }}
- title={
- openAccordions.length > 0
- ? t("hosts.collapseAll", "Collapse All")
- : t("hosts.expandAll", "Expand All")
- }
- >
- {openAccordions.length > 0 ? (
- <ChevronsDownUp className="h-4 w-4" />
- ) : (
- <ChevronsUpDown className="h-4 w-4" />
- )}
- </Button>
- </div>
-
- <ScrollArea className="flex-1 min-h-0">
- <div className="space-y-2 pb-20">
- {Object.entries(hostsByFolder).map(([folder, folderHosts]) => (
- <div
- key={folder}
- className={`border rounded-md transition-all duration-200 ${
- dragOverFolder === folder
- ? "border-blue-500 bg-blue-500/10"
- : ""
- }`}
- onDragOver={handleDragOver}
- onDragEnter={(e) => handleDragEnter(e, folder)}
- onDragLeave={handleDragLeave}
- onDrop={(e) => handleDrop(e, folder)}
- >
- <Accordion
- type="multiple"
- value={openAccordions}
- onValueChange={setOpenAccordions}
- >
- <AccordionItem value={folder} className="border-none">
- <AccordionTrigger className="px-2 py-1 bg-muted/20 border-b hover:no-underline rounded-t-md">
- <div className="flex items-center gap-2 flex-1">
- {(() => {
- const FolderIcon = getFolderIcon(folder);
- const folderColor = getFolderColor(folder);
- return (
- <FolderIcon
- className="h-4 w-4"
- style={
- folderColor ? { color: folderColor } : undefined
- }
- />
- );
- })()}
- {editingFolder === folder ? (
- <div
- className="flex items-center gap-2"
- onClick={(e) => e.stopPropagation()}
- >
- <Input
- value={editingFolderName}
- onChange={(e) =>
- setEditingFolderName(e.target.value)
- }
- onKeyDown={(e) => {
- if (e.key === "Enter")
- handleFolderRename(folder);
- if (e.key === "Escape") cancelFolderEdit();
- }}
- className="h-6 text-sm px-2 flex-1"
- autoFocus
- disabled={operationLoading}
- />
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- handleFolderRename(folder);
- }}
- className="h-6 w-6 p-0"
- disabled={operationLoading}
- >
- <Check className="h-3 w-3" />
- </Button>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- cancelFolderEdit();
- }}
- className="h-6 w-6 p-0"
- disabled={operationLoading}
- >
- <X className="h-3 w-3" />
- </Button>
- </div>
- ) : (
- <>
- <span
- className="font-medium cursor-pointer hover:text-blue-400 transition-colors"
- onClick={(e) => {
- e.stopPropagation();
- if (folder !== t("hosts.uncategorized")) {
- startFolderEdit(folder);
- }
- }}
- title={
- folder !== t("hosts.uncategorized")
- ? t("hosts.clickToRenameFolder")
- : ""
- }
- >
- {folder}
- </span>
- {folder !== t("hosts.uncategorized") && (
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- startFolderEdit(folder);
- }}
- className="h-4 w-4 p-0 opacity-50 hover:opacity-100 transition-opacity"
- title={t("hosts.renameFolder")}
- >
- <Pencil className="h-3 w-3" />
- </Button>
- )}
- </>
- )}
- <Badge variant="secondary" className="text-xs">
- {folderHosts.length}
- </Badge>
- {selectionMode &&
- (() => {
- const selectableIds = folderHosts
- .filter((h) => !h.isShared)
- .map((h) => h.id);
- const allSelected =
- selectableIds.length > 0 &&
- selectableIds.every((id) =>
- selectedHostIds.has(id),
- );
- return (
- <Checkbox
- checked={allSelected}
- onCheckedChange={(checked) => {
- setSelectedHostIds((prev) => {
- const next = new Set(prev);
- if (checked) {
- selectableIds.forEach((id) =>
- next.add(id),
- );
- } else {
- selectableIds.forEach((id) =>
- next.delete(id),
- );
- }
- return next;
- });
- }}
- onClick={(e) => e.stopPropagation()}
- className="ml-1"
- />
- );
- })()}
- {folder !== t("hosts.uncategorized") && (
- <div className="flex items-center gap-1 ml-auto">
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- setEditingFolderAppearance(folder);
- }}
- className="h-6 w-6 p-0 opacity-50 hover:opacity-100 transition-opacity"
- >
- <Palette className="h-3 w-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- {t("hosts.editFolderAppearance")}
- </TooltipContent>
- </Tooltip>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- handleDeleteAllHostsInFolder(folder);
- }}
- className="h-6 w-6 p-0 opacity-50 hover:opacity-100 hover:text-red-400 transition-all"
- >
- <Trash className="h-3 w-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- {t("hosts.deleteAllHostsInFolder")}
- </TooltipContent>
- </Tooltip>
- </div>
- )}
- </div>
- </AccordionTrigger>
- <AccordionContent className="p-2">
- <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2">
- {getVisibleHosts(folder, folderHosts).map((host) => (
- <Tooltip key={host.id}>
- <TooltipTrigger asChild>
- <div
- draggable={!selectionMode}
- onDragStart={(e) => handleDragStart(e, host)}
- onDragEnd={handleDragEnd}
- className={`bg-field border rounded-lg cursor-pointer hover:shadow-lg hover:bg-hover-alt transition-all duration-200 p-3 group relative ${
- draggedHost?.id === host.id
- ? "opacity-50 scale-95"
- : ""
- } ${
- selectionMode && selectedHostIds.has(host.id)
- ? "ring-2 ring-blue-500 border-blue-500"
- : "border-input hover:border-blue-400/50"
- } ${
- selectionMode && host.isShared
- ? "opacity-50 pointer-events-none"
- : ""
- }`}
- onClick={() => {
- if (selectionMode && !host.isShared) {
- toggleHostSelection(host.id);
- } else {
- handleEdit(host);
- }
- }}
- >
- <div className="flex items-start justify-between">
- <div className="flex-1 min-w-0">
- <div className="flex items-center gap-1">
- {selectionMode && !host.isShared && (
- <Checkbox
- checked={selectedHostIds.has(host.id)}
- onCheckedChange={() =>
- toggleHostSelection(host.id)
- }
- onClick={(e) => e.stopPropagation()}
- className="bg-background border-2 mr-1 flex-shrink-0"
- />
- )}
- {(() => {
- const statsConfig = (() => {
- if (!host.statsConfig) {
- return DEFAULT_STATS_CONFIG;
- }
- if (
- typeof host.statsConfig === "object"
- ) {
- return host.statsConfig;
- }
- try {
- return JSON.parse(host.statsConfig);
- } catch {
- return DEFAULT_STATS_CONFIG;
- }
- })();
- const shouldShowStatus = ![
- false,
- "false",
- ].includes(
- statsConfig.statusCheckEnabled,
- );
-
- if (!shouldShowStatus) return null;
-
- const serverStatus = getStatus(host.id);
- return (
- <Status
- status={serverStatus}
- className="!bg-transparent !p-0.75 flex-shrink-0"
- >
- <StatusIndicator />
- </Status>
- );
- })()}
- {host.pin && (
- <Pin className="h-3 w-3 text-yellow-500 flex-shrink-0" />
- )}
- <h3 className="font-medium truncate text-sm">
- {host.name ||
- (host.username
- ? `${host.username}@${host.ip}`
- : host.ip)}
- </h3>
- {host.isShared && (
- <Badge
- variant="outline"
- className="text-xs px-1 py-0 text-violet-500 border-violet-500/50"
- >
- {t("rbac.shared")}
- </Badge>
- )}
- </div>
- <p className="text-xs text-muted-foreground truncate">
- {host.ip}:{host.port}
- </p>
- {host.username && (
- <p className="text-xs text-muted-foreground truncate">
- {host.username}
- </p>
- )}
- <p className="text-xs text-muted-foreground truncate">
- ID: {host.id}
- </p>
- </div>
- <div className="flex gap-1 flex-shrink-0 ml-1">
- {!host.isShared &&
- host.folder &&
- host.folder !== "" && (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- handleRemoveFromFolder(host);
- }}
- className="h-5 w-5 p-0 text-orange-500 hover:text-orange-700 hover:bg-orange-500/10"
- disabled={operationLoading}
- >
- <FolderMinus className="h-3 w-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {t("hosts.removeFromFolder", {
- folder: host.folder,
- })}
- </p>
- </TooltipContent>
- </Tooltip>
- )}
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- handleEdit(host);
- }}
- className="h-5 w-5 p-0 hover:bg-blue-500/10"
- >
- <Edit className="h-3 w-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>{t("hosts.editHostTooltip")}</p>
- </TooltipContent>
- </Tooltip>
- {!host.isShared && (
- <>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- handleDelete(
- host.id,
- host.name ||
- `${host.username}@${host.ip}`,
- );
- }}
- className="h-5 w-5 p-0 text-red-500 hover:text-red-700 hover:bg-red-500/10"
- >
- <Trash2 className="h-3 w-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {t("hosts.deleteHostTooltip")}
- </p>
- </TooltipContent>
- </Tooltip>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- handleExport(host);
- }}
- className="h-5 w-5 p-0 text-blue-500 hover:text-blue-700 hover:bg-blue-500/10"
- >
- <Upload className="h-3 w-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {t("hosts.exportHostTooltip")}
- </p>
- </TooltipContent>
- </Tooltip>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- handleClone(host);
- }}
- className="h-5 w-5 p-0 text-emerald-500 hover:text-emerald-700 hover:bg-emerald-500/10"
- >
- <Copy className="h-3 w-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>{t("hosts.cloneHostTooltip")}</p>
- </TooltipContent>
- </Tooltip>
- <DropdownMenu>
- <Tooltip>
- <TooltipTrigger asChild>
- <DropdownMenuTrigger asChild>
- <Button
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- }}
- className="h-5 w-5 p-0 text-indigo-500 hover:text-indigo-700 hover:bg-indigo-500/10"
- >
- <Link className="h-3 w-3" />
- </Button>
- </DropdownMenuTrigger>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {t("hosts.copyFullScreenUrl")}
- </p>
- </TooltipContent>
- </Tooltip>
- <DropdownMenuContent align="end">
- {(() => {
- const connType =
- host.connectionType;
- const isRemoteDesktop =
- connType === "rdp" ||
- connType === "vnc" ||
- connType === "telnet";
-
- if (isRemoteDesktop) {
- return (
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- copyFullScreenUrl(
- host,
- connType,
- );
- }}
- >
- {connType === "rdp" ? (
- <Monitor className="h-4 w-4 mr-2" />
- ) : connType === "vnc" ? (
- <Eye className="h-4 w-4 mr-2" />
- ) : (
- <MessagesSquare className="h-4 w-4 mr-2" />
- )}
- {t(
- "hosts.copyRemoteDesktopUrl",
- )}
- </DropdownMenuItem>
- );
- }
-
- return (
- <>
- {host.enableTerminal && (
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- copyFullScreenUrl(
- host,
- "terminal",
- );
- }}
- >
- <Terminal className="h-4 w-4 mr-2" />
- {t(
- "hosts.copyTerminalUrl",
- )}
- </DropdownMenuItem>
- )}
- {host.enableFileManager && (
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- copyFullScreenUrl(
- host,
- "file-manager",
- );
- }}
- >
- <FolderOpen className="h-4 w-4 mr-2" />
- {t(
- "hosts.copyFileManagerUrl",
- )}
- </DropdownMenuItem>
- )}
- {host.enableTunnel && (
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- copyFullScreenUrl(
- host,
- "tunnel",
- );
- }}
- >
- <ArrowDownUp className="h-4 w-4 mr-2" />
- {t("hosts.copyTunnelUrl")}
- </DropdownMenuItem>
- )}
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- copyFullScreenUrl(
- host,
- "server-stats",
- );
- }}
- >
- <Server className="h-4 w-4 mr-2" />
- {t(
- "hosts.copyServerStatsUrl",
- )}
- </DropdownMenuItem>
- {host.enableDocker && (
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- copyFullScreenUrl(
- host,
- "docker",
- );
- }}
- >
- <Container className="h-4 w-4 mr-2" />
- {t("hosts.copyDockerUrl")}
- </DropdownMenuItem>
- )}
- </>
- );
- })()}
- </DropdownMenuContent>
- </DropdownMenu>
- </>
- )}
- </div>
- </div>
-
- <div className="mt-2 space-y-1">
- {host.tags && host.tags.length > 0 && (
- <div className="flex flex-wrap gap-1">
- {host.tags
- .slice(0, 6)
- .map((tag, index) => (
- <Badge
- key={index}
- variant="outline"
- className="text-xs px-1 py-0"
- >
- <Tag className="h-2 w-2 mr-0.5" />
- {tag}
- </Badge>
- ))}
- {host.tags.length > 6 && (
- <Badge
- variant="outline"
- className="text-xs px-1 py-0"
- >
- +{host.tags.length - 6}
- </Badge>
- )}
- </div>
- )}
-
- <div className="flex flex-wrap gap-1">
- {(() => {
- const connType = host.connectionType;
- if (connType === "rdp") {
- return (
- <Badge
- variant="outline"
- className="text-xs px-1 py-0"
- >
- <Monitor className="h-2 w-2 mr-0.5" />
- {t("hosts.rdp")}
- </Badge>
- );
- }
- if (connType === "vnc") {
- return (
- <Badge
- variant="outline"
- className="text-xs px-1 py-0"
- >
- <Eye className="h-2 w-2 mr-0.5" />
- {t("hosts.vnc")}
- </Badge>
- );
- }
- if (connType === "telnet") {
- return (
- <Badge
- variant="outline"
- className="text-xs px-1 py-0"
- >
- <MessagesSquare className="h-2 w-2 mr-0.5" />
- {t("hosts.telnet")}
- </Badge>
- );
- }
- return (
- <>
- {host.enableTerminal && (
- <Badge
- variant="outline"
- className="text-xs px-1 py-0"
- >
- <Terminal className="h-2 w-2 mr-0.5" />
- {t("hosts.terminalBadge")}
- </Badge>
- )}
- {host.enableTunnel && (
- <Badge
- variant="outline"
- className="text-xs px-1 py-0"
- >
- <Network className="h-2 w-2 mr-0.5" />
- {t("hosts.tunnelBadge")}
- {host.tunnelConnections &&
- host.tunnelConnections.length >
- 0 && (
- <span className="ml-0.5">
- (
- {
- host.tunnelConnections
- .length
- }
- )
- </span>
- )}
- </Badge>
- )}
- {host.enableFileManager && (
- <Badge
- variant="outline"
- className="text-xs px-1 py-0"
- >
- <FileEdit className="h-2 w-2 mr-0.5" />
- {t("hosts.fileManagerBadge")}
- </Badge>
- )}
- {host.enableDocker && (
- <Badge
- variant="outline"
- className="text-xs px-1 py-0"
- >
- <Container className="h-2 w-2 mr-0.5" />
- {t("hosts.docker")}
- </Badge>
- )}
- </>
- );
- })()}
- </div>
- </div>
-
- <div className="mt-3 pt-3 border-t border-border/50 flex items-center justify-center gap-1">
- {(() => {
- const connType = host.connectionType;
- const isRemoteDesktop =
- connType === "rdp" ||
- connType === "vnc" ||
- connType === "telnet";
-
- if (isRemoteDesktop) {
- return (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- onClick={async (e) => {
- e.stopPropagation();
- const title = host.name?.trim()
- ? host.name
- : `${host.ip}:${host.port}`;
-
- try {
- const protocol = connType as
- | "rdp"
- | "vnc"
- | "telnet";
- const result =
- await getGuacamoleTokenFromHost(
- host.id,
- );
-
- addTab({
- type: protocol,
- title,
- hostConfig: host,
- connectionConfig: {
- token: result.token,
- protocol,
- type: protocol,
- hostname: host.ip,
- port: host.port,
- username: host.username,
- password: host.password,
- domain: host.domain,
- security: host.security,
- "ignore-cert":
- host.ignoreCert,
- dpi: getGuacamoleDpi(
- host,
- ),
- },
- });
-
- try {
- await logActivity(
- protocol,
- host.id,
- title,
- );
- } catch (err) {
- console.warn(
- `Failed to log ${protocol} activity:`,
- err,
- );
- }
- } catch (error) {
- toast.error(
- `Failed to connect: ${error instanceof Error ? error.message : "Unknown error"}`,
- );
- }
- }}
- className="h-7 px-2 hover:bg-indigo-500/10 hover:border-indigo-500/50 flex-1"
- >
- {connType === "rdp" ? (
- <Monitor className="h-3.5 w-3.5" />
- ) : connType === "vnc" ? (
- <Eye className="h-3.5 w-3.5" />
- ) : (
- <MessagesSquare className="h-3.5 w-3.5" />
- )}
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>{t("hosts.remoteDesktop")}</p>
- </TooltipContent>
- </Tooltip>
- );
- }
-
- return (
- <>
- {host.enableTerminal && (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- onClick={(e) => {
- e.stopPropagation();
- const title =
- host.name?.trim()
- ? host.name
- : `${host.username}@${host.ip}:${host.port}`;
- addTab({
- type: "terminal",
- title,
- hostConfig: host,
- });
- }}
- className="h-7 px-2 hover:bg-blue-500/10 hover:border-blue-500/50 flex-1"
- >
- <Terminal className="h-3.5 w-3.5" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>{t("hosts.openTerminal")}</p>
- </TooltipContent>
- </Tooltip>
- )}
- {host.enableFileManager && (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- onClick={(e) => {
- e.stopPropagation();
- const title =
- host.name?.trim()
- ? host.name
- : `${host.username}@${host.ip}:${host.port}`;
- addTab({
- type: "file_manager",
- title,
- hostConfig: host,
- });
- }}
- className="h-7 px-2 hover:bg-emerald-500/10 hover:border-emerald-500/50 flex-1"
- >
- <FolderOpen className="h-3.5 w-3.5" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {t("hosts.openFileManager")}
- </p>
- </TooltipContent>
- </Tooltip>
- )}
- {host.enableTunnel && (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- onClick={(e) => {
- e.stopPropagation();
- const title =
- host.name?.trim()
- ? host.name
- : `${host.username}@${host.ip}:${host.port}`;
- addTab({
- type: "tunnel",
- title,
- hostConfig: host,
- });
- }}
- className="h-7 px-2 hover:bg-orange-500/10 hover:border-orange-500/50 flex-1"
- >
- <ArrowDownUp className="h-3.5 w-3.5" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>{t("hosts.openTunnels")}</p>
- </TooltipContent>
- </Tooltip>
- )}
- {host.enableDocker && (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- onClick={(e) => {
- e.stopPropagation();
- const title =
- host.name?.trim()
- ? host.name
- : `${host.username}@${host.ip}:${host.port}`;
- addTab({
- type: "docker",
- title,
- hostConfig: host,
- });
- }}
- className="h-7 px-2 hover:bg-cyan-500/10 hover:border-cyan-500/50 flex-1"
- >
- <Container className="h-3.5 w-3.5" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>{t("hosts.openDocker")}</p>
- </TooltipContent>
- </Tooltip>
- )}
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- onClick={(e) => {
- e.stopPropagation();
- const title = host.name?.trim()
- ? host.name
- : `${host.username}@${host.ip}:${host.port}`;
- addTab({
- type: "server_stats",
- title,
- hostConfig: host,
- });
- }}
- className="h-7 px-2 hover:bg-purple-500/10 hover:border-purple-500/50 flex-1"
- >
- <Server className="h-3.5 w-3.5" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>{t("hosts.openServerStats")}</p>
- </TooltipContent>
- </Tooltip>
- </>
- );
- })()}
- </div>
- </div>
- </TooltipTrigger>
- <TooltipContent>
- <div className="text-center">
- <p className="font-medium">
- {t("hosts.clickToEditHost")}
- </p>
- <p className="text-xs text-muted-foreground">
- {t("hosts.dragToMoveBetweenFolders")}
- </p>
- </div>
- </TooltipContent>
- </Tooltip>
- ))}
- </div>
- {folderHosts.length > INITIAL_HOSTS_PER_FOLDER && (
- <div className="flex justify-center mt-3">
- <Button
- variant="outline"
- size="sm"
- onClick={() => toggleFolderExpansion(folder)}
- className="text-xs"
- >
- {expandedFolders.has(folder)
- ? t("common.showLess")
- : t("common.showMore", {
- count:
- folderHosts.length -
- INITIAL_HOSTS_PER_FOLDER,
- })}
- </Button>
- </div>
- )}
- </AccordionContent>
- </AccordionItem>
- </Accordion>
- </div>
- ))}
- </div>
- </ScrollArea>
-
- {editingFolderAppearance && (
- <FolderEditDialog
- folderName={editingFolderAppearance}
- currentColor={getFolderColor(editingFolderAppearance)}
- currentIcon={folderMetadata.get(editingFolderAppearance)?.icon}
- open={editingFolderAppearance !== null}
- onOpenChange={(open) => {
- if (!open) setEditingFolderAppearance(null);
- }}
- onSave={async (color, icon) => {
- await handleSaveFolderAppearance(
- editingFolderAppearance,
- color,
- icon,
- );
- setEditingFolderAppearance(null);
- }}
- />
- )}
-
- {selectionMode && (
- <div className="fixed bottom-6 left-1/2 -translate-x-1/2 z-50 bg-popover border border-border rounded-lg shadow-xl px-4 py-3 flex items-center gap-2 max-w-[90vw]">
- <span className="text-sm font-medium whitespace-nowrap">
- {t("hosts.selectedCount", { count: selectedHostIds.size })}
- </span>
- <div className="w-px h-6 bg-border" />
-
- <Button
- variant="outline"
- size="sm"
- onClick={
- selectedHostIds.size === hosts.filter((h) => !h.isShared).length
- ? deselectAllHosts
- : selectAllHosts
- }
- >
- {selectedHostIds.size === hosts.filter((h) => !h.isShared).length
- ? t("hosts.deselectAll")
- : t("hosts.selectAll")}
- </Button>
-
- <div className="w-px h-6 bg-border" />
-
- <DropdownMenu modal={false}>
- <DropdownMenuTrigger asChild>
- <Button
- variant="outline"
- size="sm"
- disabled={bulkUpdating || selectedHostIds.size === 0}
- >
- <Share2 className="h-3.5 w-3.5 mr-1.5" />
- {t("hosts.bulkMonitoring")}
- <ChevronDown className="h-3 w-3 ml-1.5" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="center">
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({
- statsConfig: { statusCheckEnabled: true },
- });
- }}
- >
- <Check className="h-3.5 w-3.5 mr-2 text-green-500" />
- {t("hosts.enableStatusCheck")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({
- statsConfig: { statusCheckEnabled: false },
- });
- }}
- >
- <X className="h-3.5 w-3.5 mr-2 text-red-500" />
- {t("hosts.disableStatusCheck")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({
- statsConfig: { useGlobalStatusInterval: true },
- });
- }}
- >
- <Globe className="h-3.5 w-3.5 mr-2 text-blue-500" />
- {t("hosts.useGlobalStatusDefault")}
- </DropdownMenuItem>
- <div className="h-px bg-border my-1" />
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({ statsConfig: { metricsEnabled: true } });
- }}
- >
- <Check className="h-3.5 w-3.5 mr-2 text-green-500" />
- {t("hosts.enableMetrics")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({
- statsConfig: { metricsEnabled: false },
- });
- }}
- >
- <X className="h-3.5 w-3.5 mr-2 text-red-500" />
- {t("hosts.disableMetrics")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({
- statsConfig: { useGlobalMetricsInterval: true },
- });
- }}
- >
- <Globe className="h-3.5 w-3.5 mr-2 text-blue-500" />
- {t("hosts.useGlobalMetricsDefault")}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
-
- <DropdownMenu modal={false}>
- <DropdownMenuTrigger asChild>
- <Button
- variant="outline"
- size="sm"
- disabled={bulkUpdating || selectedHostIds.size === 0}
- >
- <Layers className="h-3.5 w-3.5 mr-1.5" />
- {t("hosts.bulkFeatures")}
- <ChevronDown className="h-3 w-3 ml-1.5" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="center">
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({
- enableTerminal: true,
- enableFileManager: true,
- enableTunnel: true,
- enableDocker: true,
- });
- }}
- >
- <Check className="h-3.5 w-3.5 mr-2 text-green-500" />
- {t("hosts.enableAllFeatures")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({
- enableTerminal: false,
- enableFileManager: false,
- enableTunnel: false,
- enableDocker: false,
- });
- }}
- >
- <X className="h-3.5 w-3.5 mr-2 text-red-500" />
- {t("hosts.disableAllFeatures")}
- </DropdownMenuItem>
- <div className="h-px bg-border my-1" />
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({ enableTerminal: true });
- }}
- >
- <Terminal className="h-3.5 w-3.5 mr-2" />
- {t("hosts.bulkEnableTerminal")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({ enableTerminal: false });
- }}
- >
- <Terminal className="h-3.5 w-3.5 mr-2 opacity-30" />
- {t("hosts.bulkDisableTerminal")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({ enableFileManager: true });
- }}
- >
- <FolderOpen className="h-3.5 w-3.5 mr-2" />
- {t("hosts.bulkEnableFileManager")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({ enableFileManager: false });
- }}
- >
- <FolderOpen className="h-3.5 w-3.5 mr-2 opacity-30" />
- {t("hosts.bulkDisableFileManager")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({ enableTunnel: true });
- }}
- >
- <Network className="h-3.5 w-3.5 mr-2" />
- {t("hosts.bulkEnableTunnel")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({ enableTunnel: false });
- }}
- >
- <Network className="h-3.5 w-3.5 mr-2 opacity-30" />
- {t("hosts.bulkDisableTunnel")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({ enableDocker: true });
- }}
- >
- <Container className="h-3.5 w-3.5 mr-2" />
- {t("hosts.bulkEnableDocker")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({ enableDocker: false });
- }}
- >
- <Container className="h-3.5 w-3.5 mr-2 opacity-30" />
- {t("hosts.bulkDisableDocker")}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
-
- <DropdownMenu modal={false}>
- <DropdownMenuTrigger asChild>
- <Button
- variant="outline"
- size="sm"
- disabled={bulkUpdating || selectedHostIds.size === 0}
- >
- <Folder className="h-3.5 w-3.5 mr-1.5" />
- {t("hosts.bulkMoveFolder")}
- <ChevronDown className="h-3 w-3 ml-1.5" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent
- align="center"
- className="max-h-[300px] overflow-y-auto"
- >
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({ folder: "" });
- }}
- >
- <FolderOpen className="h-3.5 w-3.5 mr-2" />
- {t("hosts.uncategorized")}
- </DropdownMenuItem>
- {Object.keys(hostsByFolder)
- .filter((f) => f !== t("hosts.uncategorized"))
- .map((f) => {
- const FolderIcon = getFolderIcon(f);
- const folderColor = getFolderColor(f);
- return (
- <DropdownMenuItem
- key={f}
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({ folder: f });
- }}
- >
- <FolderIcon
- className="h-3.5 w-3.5 mr-2"
- style={
- folderColor ? { color: folderColor } : undefined
- }
- />
- {f}
- </DropdownMenuItem>
- );
- })}
- </DropdownMenuContent>
- </DropdownMenu>
-
- <DropdownMenu modal={false}>
- <DropdownMenuTrigger asChild>
- <Button
- variant="outline"
- size="sm"
- disabled={bulkUpdating || selectedHostIds.size === 0}
- >
- <Pin className="h-3.5 w-3.5 mr-1.5" />
- {t("hosts.pin")}
- <ChevronDown className="h-3 w-3 ml-1.5" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="center">
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({ pin: true });
- }}
- >
- <Pin className="h-3.5 w-3.5 mr-2 text-yellow-500" />
- {t("hosts.bulkPin")}
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={(e) => {
- e.preventDefault();
- handleBulkUpdate({ pin: false });
- }}
- >
- <Pin className="h-3.5 w-3.5 mr-2 opacity-30" />
- {t("hosts.bulkUnpin")}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
-
- <div className="w-px h-6 bg-border" />
- <Button variant="ghost" size="sm" onClick={exitSelectionMode}>
- <X className="h-4 w-4 mr-1" />
- {t("hosts.exitSelectMode")}
- </Button>
- </div>
- )}
- </div>
- </TooltipProvider>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/tabs/HostDockerTab.tsx b/src/ui/desktop/apps/host-manager/hosts/tabs/HostDockerTab.tsx
deleted file mode 100644
index 610bc1805..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/tabs/HostDockerTab.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import {
- FormControl,
- FormDescription,
- FormField,
- FormItem,
- FormLabel,
-} from "@/components/ui/form.tsx";
-import { Switch } from "@/components/ui/switch.tsx";
-import type { HostDockerTabProps } from "./shared/tab-types";
-import { Button } from "@/components/ui/button.tsx";
-
-export function HostDockerTab({ form, t }: HostDockerTabProps) {
- return (
- <div className="space-y-2">
- <Button
- variant="outline"
- size="sm"
- className="h-8 px-3 text-xs"
- onClick={() => window.open("https://docs.termix.site/docker", "_blank")}
- >
- {t("common.documentation")}
- </Button>
- <FormField
- control={form.control}
- name="enableDocker"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.enableDocker")}</FormLabel>
- <FormControl>
- <Switch checked={field.value} onCheckedChange={field.onChange} />
- </FormControl>
- <FormDescription>{t("hosts.enableDockerDesc")}</FormDescription>
- </FormItem>
- )}
- />
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/tabs/HostFileManagerTab.tsx b/src/ui/desktop/apps/host-manager/hosts/tabs/HostFileManagerTab.tsx
deleted file mode 100644
index dbc679410..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/tabs/HostFileManagerTab.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import {
- FormControl,
- FormDescription,
- FormField,
- FormItem,
- FormLabel,
-} from "@/components/ui/form.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Switch } from "@/components/ui/switch.tsx";
-import type { HostFileManagerTabProps } from "./shared/tab-types";
-
-export function HostFileManagerTab({ form, t }: HostFileManagerTabProps) {
- return (
- <div>
- <FormField
- control={form.control}
- name="enableFileManager"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.enableFileManager")}</FormLabel>
- <FormControl>
- <Switch checked={field.value} onCheckedChange={field.onChange} />
- </FormControl>
- <FormDescription>
- {t("hosts.enableFileManagerDesc")}
- </FormDescription>
- </FormItem>
- )}
- />
-
- {form.watch("enableFileManager") && (
- <div className="mt-4">
- <FormField
- control={form.control}
- name="defaultPath"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.defaultPath")}</FormLabel>
- <FormControl>
- <Input
- placeholder={t("placeholders.homePath")}
- {...field}
- onBlur={(e) => {
- field.onChange(e.target.value.trim());
- field.onBlur();
- }}
- />
- </FormControl>
- <FormDescription>{t("hosts.defaultPathDesc")}</FormDescription>
- </FormItem>
- )}
- />
- </div>
- )}
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/tabs/HostGeneralTab.tsx b/src/ui/desktop/apps/host-manager/hosts/tabs/HostGeneralTab.tsx
deleted file mode 100644
index d8a199822..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/tabs/HostGeneralTab.tsx
+++ /dev/null
@@ -1,1602 +0,0 @@
-import React, { useState } from "react";
-import { Controller } from "react-hook-form";
-import { cn } from "@/lib/utils.ts";
-import { Button } from "@/components/ui/button.tsx";
-import {
- FormControl,
- FormDescription,
- FormField,
- FormItem,
- FormLabel,
-} from "@/components/ui/form.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
-import { Textarea } from "@/components/ui/textarea.tsx";
-import { Switch } from "@/components/ui/switch.tsx";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select.tsx";
-import {
- Tabs,
- TabsContent,
- TabsList,
- TabsTrigger,
-} from "@/components/ui/tabs.tsx";
-import {
- Accordion,
- AccordionContent,
- AccordionItem,
- AccordionTrigger,
-} from "@/components/ui/accordion.tsx";
-import { Alert, AlertDescription } from "@/components/ui/alert.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
-import { CredentialSelector } from "@/ui/desktop/apps/host-manager/credentials/CredentialSelector.tsx";
-import CodeMirror from "@uiw/react-codemirror";
-import { EditorView } from "@codemirror/view";
-import { Plus, X, ArrowRight, Loader2 } from "lucide-react";
-import type { HostGeneralTabProps } from "./shared/tab-types";
-import { JumpHostItem } from "./shared/JumpHostItem";
-import { testProxyConnection } from "@/ui/main-axios";
-import { toast } from "sonner";
-import type { ProxyNode } from "@/types";
-
-type JumpHostSelection = { hostId: number };
-
-export function HostGeneralTab({
- form,
- connectionType,
- authTab,
- setAuthTab,
- keyInputMethod,
- setKeyInputMethod,
- proxyMode,
- setProxyMode,
- tagInput,
- setTagInput,
- folderDropdownOpen,
- setFolderDropdownOpen,
- folderInputRef,
- folderDropdownRef,
- filteredFolders,
- handleFolderClick,
- keyTypeDropdownOpen,
- setKeyTypeDropdownOpen,
- keyTypeButtonRef,
- keyTypeDropdownRef,
- keyTypeOptions,
- ipInputRef,
- editorTheme,
- hosts,
- editingHost,
- credentials,
- t,
-}: HostGeneralTabProps) {
- const [proxyTesting, setProxyTesting] = useState(false);
-
- const handleTestProxy = async () => {
- setProxyTesting(true);
- try {
- const chain = form.watch("socks5ProxyChain") || [];
- const host = form.watch("socks5Host");
- const port = form.watch("socks5Port");
-
- let result;
- if (proxyMode === "chain" && chain.length > 0) {
- result = await testProxyConnection({ proxyChain: chain });
- } else if (host) {
- result = await testProxyConnection({
- singleProxy: {
- host,
- port: port || 1080,
- type: 5,
- username: form.watch("socks5Username") || undefined,
- password: form.watch("socks5Password") || undefined,
- },
- });
- } else {
- toast.error(
- t("hosts.proxyTestFailed", { error: "No proxy configured" }),
- );
- setProxyTesting(false);
- return;
- }
-
- if (result.success) {
- toast.success(
- t("hosts.proxyTestSuccess", { latency: result.latencyMs ?? 0 }),
- );
- } else {
- toast.error(
- t("hosts.proxyTestFailed", {
- error: result.error || "Unknown error",
- }),
- );
- }
- } catch (err) {
- toast.error(
- t("hosts.proxyTestFailed", {
- error: err instanceof Error ? err.message : "Unknown error",
- }),
- );
- } finally {
- setProxyTesting(false);
- }
- };
-
- // Build connection path for visualization
- const buildConnectionPath = () => {
- const parts: string[] = [
- t("hosts.connectionPath") === "Connection Path" ? "You" : "You",
- ];
- const useSocks5 = form.watch("useSocks5");
- const jumpHosts = (form.watch("jumpHosts") || []) as JumpHostSelection[];
-
- if (useSocks5) {
- if (proxyMode === "chain") {
- const chain = (form.watch("socks5ProxyChain") || []) as ProxyNode[];
- chain.forEach((node) => {
- if (node.host) {
- const typeLabel =
- node.type === "http" ? "HTTP" : `SOCKS${node.type}`;
- parts.push(`${typeLabel} ${node.host}:${node.port}`);
- }
- });
- } else {
- const host = form.watch("socks5Host");
- const port = form.watch("socks5Port") || 1080;
- if (host) {
- parts.push(`SOCKS5 ${host}:${port}`);
- }
- }
- }
-
- if (jumpHosts.length > 0 && hosts) {
- jumpHosts.forEach((jh) => {
- const found = hosts.find((h) => h.id === jh.hostId);
- if (found) {
- parts.push(`Jump: ${found.name || found.ip}`);
- }
- });
- }
-
- const ip = form.watch("ip");
- const port = form.watch("port");
- if (ip) {
- parts.push(`${ip}:${port || 22}`);
- }
-
- return parts;
- };
-
- const socks5ProxyChain = (form.watch("socks5ProxyChain") ||
- []) as ProxyNode[];
-
- return (
- <div className="pt-2">
- <FormLabel className="mb-3 font-bold">
- {t("hosts.connectionDetails")}
- </FormLabel>
- <div className="grid grid-cols-12 gap-4">
- <FormField
- control={form.control}
- name="ip"
- render={({ field }) => (
- <FormItem className="col-span-5">
- <FormLabel>{t("hosts.ipAddress")}</FormLabel>
- <FormControl>
- <Input
- placeholder={t("placeholders.ipAddress")}
- {...field}
- ref={(e) => {
- field.ref(e);
- ipInputRef.current = e;
- }}
- onBlur={(e) => {
- field.onChange(e.target.value.trim());
- field.onBlur();
- }}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="port"
- render={({ field }) => (
- <FormItem className="col-span-1">
- <FormLabel>{t("hosts.port")}</FormLabel>
- <FormControl>
- <Input
- type="number"
- placeholder={t("placeholders.port")}
- {...field}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="username"
- render={({ field }) => {
- const isCredentialAuth = authTab === "credential";
- const credentialId = form.watch("credentialId");
- const overrideEnabled = form.watch("overrideCredentialUsername");
- const selectedCredential = credentials.find(
- (c) => c.id === credentialId,
- );
- const shouldDisable =
- isCredentialAuth &&
- selectedCredential?.username &&
- !overrideEnabled;
-
- return (
- <FormItem className="col-span-6">
- <FormLabel>{t("hosts.username")}</FormLabel>
- <FormControl>
- <Input
- placeholder={t("placeholders.username")}
- disabled={shouldDisable}
- {...field}
- onChange={(e) => {
- field.onChange(e.target.value);
- if (
- isCredentialAuth &&
- selectedCredential &&
- !selectedCredential.username &&
- e.target.value.trim() !== ""
- ) {
- form.setValue("overrideCredentialUsername", true);
- }
- }}
- onBlur={(e) => {
- field.onChange(e.target.value.trim());
- field.onBlur();
- }}
- />
- </FormControl>
- </FormItem>
- );
- }}
- />
- </div>
- <div className="grid grid-cols-12 gap-4 mt-3">
- <FormField
- control={form.control}
- name="macAddress"
- render={({ field }) => (
- <FormItem className="col-span-5">
- <FormLabel>{t("hosts.macAddress")}</FormLabel>
- <FormControl>
- <Input
- placeholder="AA:BB:CC:DD:EE:FF"
- {...field}
- onBlur={(e) => {
- field.onChange(e.target.value.trim());
- field.onBlur();
- }}
- />
- </FormControl>
- <FormDescription>{t("hosts.macAddressDesc")}</FormDescription>
- </FormItem>
- )}
- />
- </div>
- <FormLabel className="mb-3 mt-3 font-bold">
- {t("hosts.organization")}
- </FormLabel>
- <div className="grid grid-cols-26 gap-4">
- <FormField
- control={form.control}
- name="name"
- render={({ field }) => (
- <FormItem className="col-span-10">
- <FormLabel>{t("hosts.name")}</FormLabel>
- <FormControl>
- <Input
- placeholder={t("placeholders.hostname")}
- {...field}
- onBlur={(e) => {
- field.onChange(e.target.value.trim());
- field.onBlur();
- }}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="folder"
- render={({ field }) => (
- <FormItem className="col-span-10 relative">
- <FormLabel>{t("hosts.folder")}</FormLabel>
- <FormControl>
- <Input
- ref={folderInputRef}
- placeholder={t("placeholders.folder")}
- className="min-h-[40px]"
- autoComplete="off"
- value={field.value}
- onFocus={() => setFolderDropdownOpen(true)}
- onChange={(e) => {
- field.onChange(e);
- setFolderDropdownOpen(true);
- }}
- onBlur={(e) => {
- field.onChange(e.target.value.trim());
- field.onBlur();
- }}
- />
- </FormControl>
- {folderDropdownOpen && filteredFolders.length > 0 && (
- <div
- ref={folderDropdownRef}
- className="absolute top-full left-0 z-50 mt-1 w-full bg-canvas border border-input rounded-md shadow-lg max-h-40 overflow-y-auto thin-scrollbar p-1"
- >
- <div className="grid grid-cols-1 gap-1 p-0">
- {filteredFolders.map((folder) => (
- <Button
- key={folder}
- type="button"
- variant="ghost"
- size="sm"
- className="w-full justify-start text-left rounded px-2 py-1.5 hover:bg-surface-hover focus:bg-surface-hover focus:outline-none"
- onClick={() => handleFolderClick(folder)}
- >
- {folder}
- </Button>
- ))}
- </div>
- </div>
- )}
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="tags"
- render={({ field }) => (
- <FormItem className="col-span-10 overflow-visible">
- <FormLabel>{t("hosts.tags")}</FormLabel>
- <FormControl>
- <div className="flex flex-wrap items-center gap-1 border border-input rounded-md px-3 py-2 bg-field focus-within:ring-2 ring-ring min-h-[40px]">
- {field.value.map((tag: string, idx: number) => (
- <span
- key={tag + idx}
- className="flex items-center bg-surface text-foreground rounded-full px-2 py-0.5 text-xs"
- >
- {tag}
- <button
- type="button"
- className="ml-1 text-foreground-subtle hover:text-red-500 focus:outline-none"
- onClick={() => {
- const newTags = field.value.filter(
- (_: string, i: number) => i !== idx,
- );
- field.onChange(newTags);
- }}
- >
- ×
- </button>
- </span>
- ))}
- <input
- type="text"
- className="flex-1 min-w-[60px] border-none outline-none bg-transparent text-foreground placeholder:text-muted-foreground p-0 h-6"
- value={tagInput}
- onChange={(e) => setTagInput(e.target.value)}
- onKeyDown={(e) => {
- if (e.key === " " && tagInput.trim() !== "") {
- e.preventDefault();
- if (!field.value.includes(tagInput.trim())) {
- field.onChange([...field.value, tagInput.trim()]);
- }
- setTagInput("");
- } else if (
- e.key === "Backspace" &&
- tagInput === "" &&
- field.value.length > 0
- ) {
- field.onChange(field.value.slice(0, -1));
- }
- }}
- placeholder={t("hosts.addTagsSpaceToAdd")}
- />
- </div>
- </FormControl>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="pin"
- render={({ field }) => (
- <FormItem className="col-span-6">
- <FormLabel>{t("hosts.pin")}</FormLabel>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="notes"
- render={({ field }) => (
- <FormItem className="col-span-26">
- <FormLabel>{t("hosts.notes")}</FormLabel>
- <FormControl>
- <Textarea
- placeholder={t("placeholders.notes")}
- className="resize-none"
- rows={3}
- value={field.value || ""}
- onChange={field.onChange}
- onBlur={field.onBlur}
- name={field.name}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </div>
- {connectionType === "ssh" && (
- <>
- <FormLabel className="mb-3 mt-3 font-bold">
- {t("hosts.authentication")}
- </FormLabel>
- <Tabs
- value={authTab}
- onValueChange={(value) => {
- if (editingHost?.isShared) return;
- const newAuthType = value as
- | "password"
- | "key"
- | "credential"
- | "none"
- | "opkssh";
- setAuthTab(newAuthType);
- form.setValue("authType", newAuthType);
- }}
- className="flex-1 flex flex-col h-full min-h-0"
- >
- <TabsList className="bg-button border border-edge-medium">
- <TabsTrigger
- value="password"
- disabled={editingHost?.isShared}
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium disabled:opacity-50 disabled:cursor-not-allowed"
- >
- {t("hosts.password")}
- </TabsTrigger>
- <TabsTrigger
- value="key"
- disabled={editingHost?.isShared}
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium disabled:opacity-50 disabled:cursor-not-allowed"
- >
- {t("hosts.key")}
- </TabsTrigger>
- <TabsTrigger
- value="credential"
- disabled={editingHost?.isShared}
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium disabled:opacity-50 disabled:cursor-not-allowed"
- >
- {t("hosts.credential")}
- </TabsTrigger>
- <TabsTrigger
- value="none"
- disabled={editingHost?.isShared}
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium disabled:opacity-50 disabled:cursor-not-allowed"
- >
- {t("hosts.none")}
- </TabsTrigger>
- <TabsTrigger
- value="opkssh"
- disabled={editingHost?.isShared}
- className="bg-button data-[state=active]:bg-elevated data-[state=active]:border data-[state=active]:border-edge-medium disabled:opacity-50 disabled:cursor-not-allowed"
- >
- {t("hosts.opkssh")}
- </TabsTrigger>
- </TabsList>
- <TabsContent value="password">
- <FormField
- control={form.control}
- name="password"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.password")}</FormLabel>
- <FormControl>
- <PasswordInput
- placeholder={t("placeholders.password")}
- {...field}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </TabsContent>
- <TabsContent value="key">
- <Tabs
- value={keyInputMethod}
- onValueChange={(value) => {
- setKeyInputMethod(value as "upload" | "paste");
- if (value === "upload") {
- form.setValue("key", null);
- } else {
- form.setValue("key", "");
- }
- }}
- className="w-full"
- >
- <TabsList className="inline-flex items-center justify-center rounded-md bg-muted p-1 text-muted-foreground">
- <TabsTrigger value="upload">
- {t("hosts.uploadFile")}
- </TabsTrigger>
- <TabsTrigger value="paste">{t("hosts.pasteKey")}</TabsTrigger>
- </TabsList>
- <TabsContent value="upload" className="mt-4">
- <Controller
- control={form.control}
- name="key"
- render={({ field }) => (
- <FormItem className="mb-4">
- <FormLabel>{t("hosts.sshPrivateKey")}</FormLabel>
- <FormControl>
- <div className="relative inline-block">
- <input
- id="key-upload"
- type="file"
- accept=".pem,.key,.txt,.ppk"
- onChange={(e) => {
- const file = e.target.files?.[0];
- field.onChange(file || null);
- }}
- className="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
- />
- <Button
- type="button"
- variant="outline"
- className="justify-start text-left"
- >
- <span
- className="truncate"
- title={
- (field.value as File)?.name ||
- t("hosts.upload")
- }
- >
- {field.value === "existing_key"
- ? t("hosts.existingKey")
- : field.value
- ? editingHost
- ? t("hosts.updateKey")
- : (field.value as File).name
- : t("hosts.upload")}
- </span>
- </Button>
- </div>
- </FormControl>
- </FormItem>
- )}
- />
- </TabsContent>
- <TabsContent value="paste" className="mt-4">
- <Controller
- control={form.control}
- name="key"
- render={({ field }) => (
- <FormItem className="mb-4">
- <FormLabel>{t("hosts.sshPrivateKey")}</FormLabel>
- <FormControl>
- <CodeMirror
- value={
- typeof field.value === "string" ? field.value : ""
- }
- onChange={(value) => field.onChange(value)}
- placeholder={t("placeholders.pastePrivateKey")}
- theme={editorTheme}
- className="border border-input rounded-md overflow-hidden"
- minHeight="120px"
- basicSetup={{
- lineNumbers: true,
- foldGutter: false,
- dropCursor: false,
- allowMultipleSelections: false,
- highlightSelectionMatches: false,
- }}
- extensions={[
- EditorView.theme({
- ".cm-scroller": {
- overflow: "auto",
- scrollbarWidth: "thin",
- scrollbarColor:
- "var(--scrollbar-thumb) var(--scrollbar-track)",
- },
- }),
- ]}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </TabsContent>
- </Tabs>
- <div className="grid grid-cols-15 gap-4 mt-4">
- <FormField
- control={form.control}
- name="keyPassword"
- render={({ field }) => (
- <FormItem className="col-span-8">
- <FormLabel>{t("hosts.keyPassword")}</FormLabel>
- <FormControl>
- <PasswordInput
- placeholder={t("placeholders.keyPassword")}
- {...field}
- />
- </FormControl>
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name="keyType"
- render={({ field }) => (
- <FormItem className="relative col-span-3">
- <FormLabel>{t("hosts.keyType")}</FormLabel>
- <FormControl>
- <div className="relative">
- <Button
- ref={keyTypeButtonRef}
- type="button"
- variant="outline"
- className="w-full justify-start text-left rounded-md px-2 py-2 bg-canvas border border-input text-foreground"
- onClick={() =>
- setKeyTypeDropdownOpen((open) => !open)
- }
- >
- {keyTypeOptions.find(
- (opt) => opt.value === field.value,
- )?.label || t("hosts.autoDetect")}
- </Button>
- {keyTypeDropdownOpen && (
- <div
- ref={keyTypeDropdownRef}
- className="absolute bottom-full left-0 z-50 mb-1 w-full bg-canvas border border-input rounded-md shadow-lg max-h-40 overflow-y-auto thin-scrollbar p-1"
- >
- <div className="grid grid-cols-1 gap-1 p-0">
- {keyTypeOptions.map((opt) => (
- <Button
- key={opt.value}
- type="button"
- variant="ghost"
- size="sm"
- className="w-full justify-start text-left rounded-md px-2 py-1.5 bg-canvas text-foreground hover:bg-surface-hover focus:bg-surface-hover focus:outline-none"
- onClick={() => {
- field.onChange(opt.value);
- setKeyTypeDropdownOpen(false);
- }}
- >
- {opt.label}
- </Button>
- ))}
- </div>
- </div>
- )}
- </div>
- </FormControl>
- </FormItem>
- )}
- />
- </div>
- </TabsContent>
- <TabsContent value="credential">
- <div className="space-y-4">
- <FormField
- control={form.control}
- name="credentialId"
- render={({ field }) => (
- <FormItem>
- {editingHost?.isShared ? (
- <div className="text-sm text-muted-foreground p-3 bg-base border border-edge-medium rounded-md">
- {t("hosts.cannotChangeAuthAsSharedUser")}
- </div>
- ) : (
- <CredentialSelector
- value={field.value}
- onValueChange={field.onChange}
- onCredentialSelect={(credential) => {
- if (
- credential &&
- credential.username &&
- !form.getValues("overrideCredentialUsername")
- ) {
- form.setValue("username", credential.username);
- }
- }}
- />
- )}
- {!editingHost?.isShared && (
- <FormDescription>
- {t("hosts.credentialDescription")}
- </FormDescription>
- )}
- </FormItem>
- )}
- />
- {form.watch("credentialId") &&
- (() => {
- const selectedCredential = credentials.find(
- (c) => c.id === form.watch("credentialId"),
- );
- return selectedCredential?.username ? (
- <FormField
- control={form.control}
- name="overrideCredentialUsername"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>
- {t("hosts.overrideCredentialUsername")}
- </FormLabel>
- <FormDescription>
- {t("hosts.overrideCredentialUsernameDesc")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
- ) : null;
- })()}
- </div>
- </TabsContent>
- <TabsContent value="none">
- <Alert className="mt-2">
- <AlertDescription>
- <strong>{t("hosts.noneAuthTitle")}</strong>
- <div className="mt-2">{t("hosts.noneAuthDescription")}</div>
- <div className="mt-2 text-sm">
- {t("hosts.noneAuthDetails")}
- </div>
- </AlertDescription>
- </Alert>
- </TabsContent>
- <TabsContent value="opkssh">
- <Alert className="mt-2">
- <AlertDescription>
- <strong>{t("hosts.opksshAuthTitle")}</strong>
- <div className="mt-2">{t("hosts.opksshAuthDescription")}</div>
- <Button
- variant="outline"
- size="sm"
- className="h-8 px-3 text-xs"
- onClick={() =>
- window.open("https://docs.termix.site/opkssh", "_blank")
- }
- >
- {t("common.documentation")}
- </Button>
- </AlertDescription>
- </Alert>
- </TabsContent>
- </Tabs>
- <Separator className="my-6" />
- <Accordion type="multiple" className="w-full">
- <AccordionItem value="sidebar-customization">
- <AccordionTrigger>
- {t("hosts.sidebarCustomization")}
- </AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <Alert>
- <AlertDescription>
- {t("hosts.sidebarCustomizationDesc")}
- </AlertDescription>
- </Alert>
-
- {form.watch("enableTerminal") && (
- <FormField
- control={form.control}
- name="showTerminalInSidebar"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>
- {t("hosts.showTerminalInSidebar")}
- </FormLabel>
- <FormDescription>
- {t("hosts.showTerminalInSidebarDesc")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
- )}
-
- {form.watch("enableFileManager") && (
- <FormField
- control={form.control}
- name="showFileManagerInSidebar"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>
- {t("hosts.showFileManagerInSidebar")}
- </FormLabel>
- <FormDescription>
- {t("hosts.showFileManagerInSidebarDesc")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
- )}
-
- {form.watch("enableTunnel") && (
- <FormField
- control={form.control}
- name="showTunnelInSidebar"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>
- {t("hosts.showTunnelInSidebar")}
- </FormLabel>
- <FormDescription>
- {t("hosts.showTunnelInSidebarDesc")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
- )}
-
- {form.watch("enableDocker") && (
- <FormField
- control={form.control}
- name="showDockerInSidebar"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>
- {t("hosts.showDockerInSidebar")}
- </FormLabel>
- <FormDescription>
- {t("hosts.showDockerInSidebarDesc")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
- )}
-
- <FormField
- control={form.control}
- name="showServerStatsInSidebar"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>
- {t("hosts.showServerStatsInSidebar")}
- </FormLabel>
- <FormDescription>
- {t("hosts.showServerStatsInSidebarDesc")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </AccordionContent>
- </AccordionItem>
-
- <AccordionItem value="advanced-auth">
- <AccordionTrigger>
- {t("hosts.advancedAuthSettings")}
- </AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <FormField
- control={form.control}
- name="forceKeyboardInteractive"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>
- {t("hosts.forceKeyboardInteractive")}
- </FormLabel>
- <FormDescription>
- {t("hosts.forceKeyboardInteractiveDesc")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </AccordionContent>
- </AccordionItem>
-
- <AccordionItem value="jump-hosts">
- <AccordionTrigger>{t("hosts.jumpHosts")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <Alert>
- <AlertDescription>
- {t("hosts.jumpHostsDescription")}
- </AlertDescription>
- </Alert>
- <FormField
- control={form.control}
- name="jumpHosts"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.jumpHostChain")}</FormLabel>
- <FormControl>
- <div className="space-y-3">
- {field.value.map((jumpHost, index) => (
- <JumpHostItem
- key={index}
- jumpHost={jumpHost}
- index={index}
- hosts={hosts}
- editingHost={editingHost}
- onUpdate={(hostId) => {
- const newJumpHosts = [...field.value];
- newJumpHosts[index] = { hostId };
- field.onChange(newJumpHosts);
- }}
- onRemove={() => {
- const newJumpHosts = field.value.filter(
- (_, i) => i !== index,
- );
- field.onChange(newJumpHosts);
- }}
- t={t}
- />
- ))}
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={() => {
- field.onChange([...field.value, { hostId: 0 }]);
- }}
- >
- <Plus className="h-4 w-4 mr-2" />
- {t("hosts.addJumpHost")}
- </Button>
- </div>
- </FormControl>
- <FormDescription>
- {t("hosts.jumpHostsOrder")}
- </FormDescription>
- </FormItem>
- )}
- />
- </AccordionContent>
- </AccordionItem>
-
- <AccordionItem value="socks5">
- <AccordionTrigger>{t("hosts.socks5Proxy")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <Alert>
- <AlertDescription>
- {t("hosts.socks5Description")}
- </AlertDescription>
- </Alert>
-
- <FormField
- control={form.control}
- name="useSocks5"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>{t("hosts.enableSocks5")}</FormLabel>
- <FormDescription>
- {t("hosts.enableSocks5Description")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- {form.watch("useSocks5") && (
- <div className="space-y-4">
- <div className="space-y-2">
- <FormLabel>{t("hosts.socks5ProxyMode")}</FormLabel>
- <div className="flex gap-2">
- <Button
- type="button"
- variant={
- proxyMode === "single" ? "default" : "outline"
- }
- onClick={() => setProxyMode("single")}
- className="flex-1"
- >
- {t("hosts.socks5UseSingleProxy")}
- </Button>
- <Button
- type="button"
- variant={
- proxyMode === "chain" ? "default" : "outline"
- }
- onClick={() => setProxyMode("chain")}
- className="flex-1"
- >
- {t("hosts.socks5UseProxyChain")}
- </Button>
- </div>
- </div>
-
- {proxyMode === "single" && (
- <div className="space-y-4 p-4 border rounded-lg">
- <FormField
- control={form.control}
- name="socks5Host"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.socks5Host")}</FormLabel>
- <FormControl>
- <Input
- placeholder={t("placeholders.socks5Host")}
- {...field}
- onBlur={(e) => {
- field.onChange(e.target.value.trim());
- field.onBlur();
- }}
- />
- </FormControl>
- <FormDescription>
- {t("hosts.socks5HostDescription")}
- </FormDescription>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="socks5Port"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.socks5Port")}</FormLabel>
- <FormControl>
- <Input
- type="number"
- placeholder={t("placeholders.socks5Port")}
- {...field}
- onChange={(e) =>
- field.onChange(
- parseInt(e.target.value) || 1080,
- )
- }
- />
- </FormControl>
- <FormDescription>
- {t("hosts.socks5PortDescription")}
- </FormDescription>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="socks5Username"
- render={({ field }) => (
- <FormItem>
- <FormLabel>
- {t("hosts.socks5Username")}{" "}
- {t("hosts.optional")}
- </FormLabel>
- <FormControl>
- <Input
- placeholder={t("hosts.username")}
- {...field}
- onBlur={(e) => {
- field.onChange(e.target.value.trim());
- field.onBlur();
- }}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="socks5Password"
- render={({ field }) => (
- <FormItem>
- <FormLabel>
- {t("hosts.socks5Password")}{" "}
- {t("hosts.optional")}
- </FormLabel>
- <FormControl>
- <PasswordInput
- placeholder={t("hosts.password")}
- {...field}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </div>
- )}
-
- {proxyMode === "chain" && (
- <div className="space-y-4">
- <div className="flex items-center justify-between">
- <FormLabel>{t("hosts.socks5ProxyChain")}</FormLabel>
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={() => {
- const currentChain =
- form.watch("socks5ProxyChain") || [];
- form.setValue("socks5ProxyChain", [
- ...currentChain,
- {
- host: "",
- port: 1080,
- type: 5 as 4 | 5 | "http",
- username: "",
- password: "",
- },
- ]);
- }}
- >
- <Plus className="h-4 w-4 mr-2" />
- {t("hosts.addProxyNode")}
- </Button>
- </div>
-
- {socks5ProxyChain.length === 0 && (
- <div className="text-sm text-muted-foreground text-center p-4 border rounded-lg border-dashed">
- {t("hosts.noProxyNodes")}
- </div>
- )}
-
- {socks5ProxyChain.map((node, index) => (
- <div
- key={index}
- className="p-4 border rounded-lg space-y-3 relative"
- >
- <div className="flex items-center justify-between mb-2">
- <span className="text-sm font-medium">
- {t("hosts.proxyNode")} {index + 1}
- </span>
- <Button
- type="button"
- variant="ghost"
- size="icon"
- onClick={() => {
- const currentChain =
- form.watch("socks5ProxyChain") || [];
- form.setValue(
- "socks5ProxyChain",
- currentChain.filter(
- (_node: ProxyNode, i: number) =>
- i !== index,
- ),
- );
- }}
- >
- <X className="h-4 w-4" />
- </Button>
- </div>
-
- <div className="grid grid-cols-2 gap-3">
- <div className="space-y-2">
- <FormLabel>{t("hosts.socks5Host")}</FormLabel>
- <Input
- placeholder={t("placeholders.socks5Host")}
- value={node.host}
- onChange={(e) => {
- const currentChain =
- form.watch("socks5ProxyChain") || [];
- const newChain = [...currentChain];
- newChain[index] = {
- ...newChain[index],
- host: e.target.value,
- };
- form.setValue("socks5ProxyChain", newChain);
- }}
- onBlur={(e) => {
- const currentChain =
- form.watch("socks5ProxyChain") || [];
- const newChain = [...currentChain];
- newChain[index] = {
- ...newChain[index],
- host: e.target.value.trim(),
- };
- form.setValue("socks5ProxyChain", newChain);
- }}
- />
- </div>
-
- <div className="space-y-2">
- <FormLabel>{t("hosts.socks5Port")}</FormLabel>
- <Input
- type="number"
- placeholder={t("placeholders.socks5Port")}
- value={node.port}
- onChange={(e) => {
- const currentChain =
- form.watch("socks5ProxyChain") || [];
- const newChain = [...currentChain];
- newChain[index] = {
- ...newChain[index],
- port: parseInt(e.target.value) || 1080,
- };
- form.setValue("socks5ProxyChain", newChain);
- }}
- />
- </div>
- </div>
-
- <div className="space-y-2">
- <FormLabel>{t("hosts.proxyType")}</FormLabel>
- <Select
- value={String(node.type)}
- onValueChange={(value) => {
- const currentChain =
- form.watch("socks5ProxyChain") || [];
- const newChain = [...currentChain];
- newChain[index] = {
- ...newChain[index],
- type:
- value === "http"
- ? ("http" as const)
- : (parseInt(value) as 4 | 5),
- };
- form.setValue("socks5ProxyChain", newChain);
- }}
- >
- <SelectTrigger>
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="4">
- {t("hosts.socks4")}
- </SelectItem>
- <SelectItem value="5">
- {t("hosts.socks5")}
- </SelectItem>
- <SelectItem value="http">
- {t("hosts.httpConnect")}
- </SelectItem>
- </SelectContent>
- </Select>
- </div>
-
- <div className="grid grid-cols-2 gap-3">
- <div className="space-y-2">
- <FormLabel>
- {t("hosts.socks5Username")}{" "}
- {t("hosts.optional")}
- </FormLabel>
- <Input
- placeholder={t("hosts.username")}
- value={node.username || ""}
- onChange={(e) => {
- const currentChain =
- form.watch("socks5ProxyChain") || [];
- const newChain = [...currentChain];
- newChain[index] = {
- ...newChain[index],
- username: e.target.value,
- };
- form.setValue("socks5ProxyChain", newChain);
- }}
- onBlur={(e) => {
- const currentChain =
- form.watch("socks5ProxyChain") || [];
- const newChain = [...currentChain];
- newChain[index] = {
- ...newChain[index],
- username: e.target.value.trim(),
- };
- form.setValue("socks5ProxyChain", newChain);
- }}
- />
- </div>
-
- <div className="space-y-2">
- <FormLabel>
- {t("hosts.socks5Password")}{" "}
- {t("hosts.optional")}
- </FormLabel>
- <PasswordInput
- placeholder={t("hosts.password")}
- value={node.password || ""}
- onChange={(e) => {
- const currentChain =
- form.watch("socks5ProxyChain") || [];
- const newChain = [...currentChain];
- newChain[index] = {
- ...newChain[index],
- password: e.target.value,
- };
- form.setValue("socks5ProxyChain", newChain);
- }}
- />
- </div>
- </div>
- </div>
- ))}
- </div>
- )}
-
- <Separator className="my-2" />
-
- <Button
- type="button"
- variant="outline"
- size="sm"
- disabled={proxyTesting}
- onClick={handleTestProxy}
- >
- {proxyTesting ? (
- <>
- <Loader2 className="h-4 w-4 mr-2 animate-spin" />
- {t("hosts.testingProxy")}
- </>
- ) : (
- t("hosts.testProxy")
- )}
- </Button>
-
- {(() => {
- const path = buildConnectionPath();
- if (path.length <= 2) return null;
- return (
- <div className="mt-3 p-3 border rounded-lg bg-muted/30">
- <FormLabel className="text-xs text-muted-foreground mb-2 block">
- {t("hosts.connectionPath")}
- </FormLabel>
- <div className="flex items-center flex-wrap gap-1 text-xs">
- {path.map((part, i) => (
- <React.Fragment key={i}>
- {i > 0 && (
- <ArrowRight className="h-3 w-3 text-muted-foreground shrink-0" />
- )}
- <span
- className={cn(
- "px-2 py-0.5 rounded",
- i === 0
- ? "bg-primary/10 text-primary"
- : i === path.length - 1
- ? "bg-green-500/10 text-green-600 dark:text-green-400"
- : "bg-muted text-muted-foreground",
- )}
- >
- {part}
- </span>
- </React.Fragment>
- ))}
- </div>
- </div>
- );
- })()}
- </div>
- )}
- </AccordionContent>
- </AccordionItem>
-
- <AccordionItem value="port-knocking">
- <AccordionTrigger>{t("hosts.portKnocking")}</AccordionTrigger>
- <AccordionContent className="space-y-3 pt-2">
- <p className="text-sm text-muted-foreground">
- {t("hosts.portKnockingDesc")}
- </p>
- <Controller
- control={form.control}
- name="portKnockSequence"
- render={({ field }) => {
- const sequence = field.value || [];
- return (
- <div className="space-y-2">
- {sequence.map(
- (
- knock: {
- port: number;
- protocol?: string;
- delay?: number;
- },
- index: number,
- ) => (
- <div
- key={index}
- className="flex items-center gap-2"
- >
- <Input
- type="number"
- placeholder={t("hosts.port")}
- value={knock.port || ""}
- onChange={(e) => {
- const updated = [...sequence];
- updated[index] = {
- ...updated[index],
- port: parseInt(e.target.value) || 0,
- };
- field.onChange(updated);
- }}
- className="w-24"
- />
- <Select
- value={knock.protocol || "tcp"}
- onValueChange={(v) => {
- const updated = [...sequence];
- updated[index] = {
- ...updated[index],
- protocol: v,
- };
- field.onChange(updated);
- }}
- >
- <SelectTrigger className="w-20">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="tcp">TCP</SelectItem>
- <SelectItem value="udp">UDP</SelectItem>
- </SelectContent>
- </Select>
- <Input
- type="number"
- placeholder={t("hosts.delayMs")}
- value={knock.delay ?? 100}
- onChange={(e) => {
- const updated = [...sequence];
- updated[index] = {
- ...updated[index],
- delay: parseInt(e.target.value) || 0,
- };
- field.onChange(updated);
- }}
- className="w-20"
- />
- <span className="text-xs text-muted-foreground">
- ms
- </span>
- <Button
- type="button"
- variant="ghost"
- size="sm"
- onClick={() => {
- field.onChange(
- sequence.filter(
- (_: unknown, i: number) => i !== index,
- ),
- );
- }}
- >
- <X className="h-4 w-4" />
- </Button>
- </div>
- ),
- )}
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={() => {
- field.onChange([
- ...sequence,
- { port: 0, protocol: "tcp", delay: 100 },
- ]);
- }}
- >
- <Plus className="h-4 w-4 mr-1" />
- {t("hosts.addKnock")}
- </Button>
- </div>
- );
- }}
- />
- </AccordionContent>
- </AccordionItem>
- </Accordion>
- </>
- )}
-
- {/* Simple password field for RDP/VNC/Telnet */}
- {connectionType !== "ssh" && (
- <div className="mt-3 space-y-4">
- <FormLabel className="font-bold">
- {t("hosts.authentication")}
- </FormLabel>
- <FormField
- control={form.control}
- name="password"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.password")}</FormLabel>
- <FormControl>
- <PasswordInput
- placeholder={t("placeholders.password")}
- {...field}
- />
- </FormControl>
- </FormItem>
- )}
- />
- {connectionType === "rdp" && (
- <FormField
- control={form.control}
- name="domain"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.domain")}</FormLabel>
- <FormControl>
- <Input
- placeholder={t("hosts.domain")}
- value={field.value || ""}
- onChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
- )}
- </div>
- )}
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/tabs/HostRemoteDesktopTab.tsx b/src/ui/desktop/apps/host-manager/hosts/tabs/HostRemoteDesktopTab.tsx
deleted file mode 100644
index 43ac6068f..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/tabs/HostRemoteDesktopTab.tsx
+++ /dev/null
@@ -1,744 +0,0 @@
-import {
- FormControl,
- FormDescription,
- FormField,
- FormItem,
- FormLabel,
-} from "@/components/ui/form.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Switch } from "@/components/ui/switch.tsx";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select.tsx";
-import {
- Accordion,
- AccordionContent,
- AccordionItem,
- AccordionTrigger,
-} from "@/components/ui/accordion.tsx";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
-import type { HostRemoteDesktopTabProps } from "./shared/tab-types";
-
-type RemoteDesktopForm = HostRemoteDesktopTabProps["form"];
-
-function GuacField({
- form,
- path,
- label,
- description,
- type = "text",
-}: {
- form: RemoteDesktopForm;
- path: string;
- label: string;
- description?: string;
- type?: "text" | "number" | "password" | "switch";
-}) {
- const fieldName = `guacamoleConfig.${path}` as never;
-
- if (type === "switch") {
- return (
- <FormField
- control={form.control}
- name={fieldName}
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>{label}</FormLabel>
- {description && <FormDescription>{description}</FormDescription>}
- </div>
- <FormControl>
- <Switch
- checked={!!field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
- );
- }
-
- if (type === "password") {
- return (
- <FormField
- control={form.control}
- name={fieldName}
- render={({ field }) => (
- <FormItem>
- <FormLabel>{label}</FormLabel>
- <FormControl>
- <PasswordInput
- value={field.value || ""}
- onChange={field.onChange}
- />
- </FormControl>
- {description && <FormDescription>{description}</FormDescription>}
- </FormItem>
- )}
- />
- );
- }
-
- return (
- <FormField
- control={form.control}
- name={fieldName}
- render={({ field }) => (
- <FormItem>
- <FormLabel>{label}</FormLabel>
- <FormControl>
- <Input
- type={type}
- value={field.value ?? ""}
- onChange={(e) =>
- field.onChange(
- type === "number"
- ? e.target.value === ""
- ? undefined
- : parseInt(e.target.value)
- : e.target.value,
- )
- }
- />
- </FormControl>
- {description && <FormDescription>{description}</FormDescription>}
- </FormItem>
- )}
- />
- );
-}
-
-function GuacSelect({
- form,
- path,
- label,
- options,
- placeholder,
-}: {
- form: RemoteDesktopForm;
- path: string;
- label: string;
- options: { value: string; label: string }[];
- placeholder?: string;
-}) {
- const fieldName = `guacamoleConfig.${path}` as never;
-
- return (
- <FormField
- control={form.control}
- name={fieldName}
- render={({ field }) => (
- <FormItem>
- <FormLabel>{label}</FormLabel>
- <Select
- value={field.value || "auto"}
- onValueChange={(v) => field.onChange(v === "auto" ? "" : v)}
- >
- <FormControl>
- <SelectTrigger>
- <SelectValue placeholder={placeholder || label} />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- {options.map((opt) => (
- <SelectItem key={opt.value} value={opt.value}>
- {opt.label}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- </FormItem>
- )}
- />
- );
-}
-
-export function HostRemoteDesktopTab({
- form,
- connectionType,
- t,
-}: HostRemoteDesktopTabProps) {
- const isRDP = connectionType === "rdp";
- const isVNC = connectionType === "vnc";
- const isTelnet = connectionType === "telnet";
-
- return (
- <div className="pt-2 space-y-4">
- <Accordion
- type="multiple"
- defaultValue={["connection", "display"]}
- className="w-full"
- >
- {/* Connection Settings */}
- {isRDP && (
- <AccordionItem value="connection">
- <AccordionTrigger>{t("hosts.connectionSettings")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <FormField
- control={form.control}
- name="security"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.securityMode")}</FormLabel>
- <Select
- value={field.value || "any"}
- onValueChange={field.onChange}
- >
- <FormControl>
- <SelectTrigger>
- <SelectValue />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- <SelectItem value="any">Any</SelectItem>
- <SelectItem value="nla">NLA</SelectItem>
- <SelectItem value="nla-ext">NLA Extended</SelectItem>
- <SelectItem value="tls">TLS</SelectItem>
- <SelectItem value="vmconnect">VMConnect</SelectItem>
- <SelectItem value="rdp">RDP</SelectItem>
- </SelectContent>
- </Select>
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name="ignoreCert"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>{t("hosts.ignoreCert")}</FormLabel>
- <FormDescription>
- {t("hosts.ignoreCertDesc")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={!!field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </AccordionContent>
- </AccordionItem>
- )}
-
- {/* Display Settings */}
- <AccordionItem value="display">
- <AccordionTrigger>{t("hosts.displaySettings")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- {!isTelnet && (
- <GuacSelect
- form={form}
- path="color-depth"
- label={t("hosts.colorDepth")}
- options={[
- { value: "auto", label: "Auto" },
- { value: "8", label: "8-bit" },
- { value: "16", label: "16-bit" },
- { value: "24", label: "24-bit" },
- { value: "32", label: "32-bit" },
- ]}
- />
- )}
- <div className="grid grid-cols-2 gap-4">
- <GuacField
- form={form}
- path="width"
- label={t("hosts.width")}
- type="number"
- />
- <GuacField
- form={form}
- path="height"
- label={t("hosts.height")}
- type="number"
- />
- </div>
- {!isTelnet && (
- <>
- <GuacField
- form={form}
- path="dpi"
- label={t("hosts.dpi")}
- type="number"
- />
- <GuacSelect
- form={form}
- path="resize-method"
- label={t("hosts.resizeMethod")}
- options={[
- { value: "auto", label: "Auto" },
- { value: "display-update", label: "Display Update" },
- { value: "reconnect", label: "Reconnect" },
- ]}
- />
- <GuacField
- form={form}
- path="force-lossless"
- label={t("hosts.forceLossless")}
- type="switch"
- />
- </>
- )}
- </AccordionContent>
- </AccordionItem>
-
- {/* Telnet Terminal Settings */}
- {isTelnet && (
- <AccordionItem value="telnet-terminal">
- <AccordionTrigger>
- {t("hosts.telnetTerminalSettings")}
- </AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <GuacSelect
- form={form}
- path="terminal-type"
- label={t("hosts.terminalType")}
- options={[
- { value: "auto", label: "Auto" },
- { value: "xterm", label: "xterm" },
- { value: "xterm-256color", label: "xterm-256color" },
- { value: "vt100", label: "VT100" },
- { value: "vt220", label: "VT220" },
- ]}
- />
- <GuacField
- form={form}
- path="font-name"
- label={t("hosts.guacFontName")}
- />
- <GuacField
- form={form}
- path="font-size"
- label={t("hosts.guacFontSize")}
- type="number"
- />
- <GuacSelect
- form={form}
- path="color-scheme"
- label={t("hosts.guacColorScheme")}
- options={[
- { value: "auto", label: "Auto" },
- { value: "black-white", label: "Black on White" },
- { value: "white-black", label: "White on Black" },
- { value: "gray-black", label: "Gray on Black" },
- { value: "green-black", label: "Green on Black" },
- ]}
- />
- <GuacSelect
- form={form}
- path="backspace"
- label={t("hosts.guacBackspaceKey")}
- options={[
- { value: "auto", label: "Auto" },
- { value: "127", label: "DEL (127)" },
- { value: "8", label: "BS (8)" },
- ]}
- />
- </AccordionContent>
- </AccordionItem>
- )}
-
- {/* Audio Settings */}
- {(isRDP || isVNC) && (
- <AccordionItem value="audio">
- <AccordionTrigger>{t("hosts.audioSettings")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <GuacField
- form={form}
- path="disable-audio"
- label={t("hosts.disableAudio")}
- type="switch"
- />
- {isRDP && (
- <GuacField
- form={form}
- path="enable-audio-input"
- label={t("hosts.enableAudioInput")}
- type="switch"
- />
- )}
- </AccordionContent>
- </AccordionItem>
- )}
-
- {/* RDP Performance */}
- {isRDP && (
- <AccordionItem value="performance">
- <AccordionTrigger>{t("hosts.rdpPerformance")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <GuacField
- form={form}
- path="enable-wallpaper"
- label={t("hosts.enableWallpaper")}
- type="switch"
- />
- <GuacField
- form={form}
- path="enable-theming"
- label={t("hosts.enableTheming")}
- type="switch"
- />
- <GuacField
- form={form}
- path="enable-font-smoothing"
- label={t("hosts.enableFontSmoothing")}
- type="switch"
- />
- <GuacField
- form={form}
- path="enable-full-window-drag"
- label={t("hosts.enableFullWindowDrag")}
- type="switch"
- />
- <GuacField
- form={form}
- path="enable-desktop-composition"
- label={t("hosts.enableDesktopComposition")}
- type="switch"
- />
- <GuacField
- form={form}
- path="enable-menu-animations"
- label={t("hosts.enableMenuAnimations")}
- type="switch"
- />
- <GuacField
- form={form}
- path="disable-bitmap-caching"
- label={t("hosts.disableBitmapCaching")}
- type="switch"
- />
- <GuacField
- form={form}
- path="disable-offscreen-caching"
- label={t("hosts.disableOffscreenCaching")}
- type="switch"
- />
- <GuacField
- form={form}
- path="disable-glyph-caching"
- label={t("hosts.disableGlyphCaching")}
- type="switch"
- />
- <GuacField
- form={form}
- path="enable-gfx"
- label={t("hosts.enableGfx")}
- type="switch"
- />
- </AccordionContent>
- </AccordionItem>
- )}
-
- {/* RDP Device Redirection */}
- {isRDP && (
- <AccordionItem value="device-redirection">
- <AccordionTrigger>{t("hosts.deviceRedirection")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <GuacField
- form={form}
- path="enable-printing"
- label={t("hosts.enablePrinting")}
- type="switch"
- />
- <GuacField
- form={form}
- path="enable-drive"
- label={t("hosts.enableDrive")}
- type="switch"
- />
- <GuacField
- form={form}
- path="drive-name"
- label={t("hosts.driveName")}
- />
- <GuacField
- form={form}
- path="drive-path"
- label={t("hosts.drivePath")}
- />
- <GuacField
- form={form}
- path="create-drive-path"
- label={t("hosts.createDrivePath")}
- type="switch"
- />
- <GuacField
- form={form}
- path="disable-download"
- label={t("hosts.disableDownload")}
- type="switch"
- />
- <GuacField
- form={form}
- path="disable-upload"
- label={t("hosts.disableUpload")}
- type="switch"
- />
- <GuacField
- form={form}
- path="enable-touch"
- label={t("hosts.enableTouch")}
- type="switch"
- />
- </AccordionContent>
- </AccordionItem>
- )}
-
- {/* RDP Session */}
- {isRDP && (
- <AccordionItem value="session">
- <AccordionTrigger>{t("hosts.rdpSession")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <GuacField
- form={form}
- path="client-name"
- label={t("hosts.clientName")}
- />
- <GuacField
- form={form}
- path="console"
- label={t("hosts.consoleSession")}
- type="switch"
- />
- <GuacField
- form={form}
- path="initial-program"
- label={t("hosts.initialProgram")}
- />
- <GuacSelect
- form={form}
- path="server-layout"
- label={t("hosts.serverLayout")}
- options={[
- { value: "auto", label: "Auto" },
- { value: "en-us-qwerty", label: "English (US) QWERTY" },
- { value: "en-gb-qwerty", label: "English (UK) QWERTY" },
- { value: "de-de-qwertz", label: "German QWERTZ" },
- { value: "fr-fr-azerty", label: "French AZERTY" },
- { value: "it-it-qwerty", label: "Italian QWERTY" },
- { value: "sv-se-qwerty", label: "Swedish QWERTY" },
- { value: "ja-jp-qwerty", label: "Japanese QWERTY" },
- { value: "pt-br-qwerty", label: "Portuguese (BR) QWERTY" },
- { value: "es-es-qwerty", label: "Spanish QWERTY" },
- { value: "failsafe", label: "Failsafe (Unicode)" },
- ]}
- />
- <GuacField
- form={form}
- path="timezone"
- label={t("hosts.timezone")}
- />
- </AccordionContent>
- </AccordionItem>
- )}
-
- {/* RDP Gateway */}
- {isRDP && (
- <AccordionItem value="gateway">
- <AccordionTrigger>{t("hosts.gatewaySettings")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <GuacField
- form={form}
- path="gateway-hostname"
- label={t("hosts.gatewayHostname")}
- />
- <GuacField
- form={form}
- path="gateway-port"
- label={t("hosts.gatewayPort")}
- type="number"
- />
- <GuacField
- form={form}
- path="gateway-username"
- label={t("hosts.gatewayUsername")}
- />
- <GuacField
- form={form}
- path="gateway-password"
- label={t("hosts.gatewayPassword")}
- type="password"
- />
- <GuacField
- form={form}
- path="gateway-domain"
- label={t("hosts.gatewayDomain")}
- />
- </AccordionContent>
- </AccordionItem>
- )}
-
- {/* RDP RemoteApp */}
- {isRDP && (
- <AccordionItem value="remoteapp">
- <AccordionTrigger>{t("hosts.remoteApp")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <GuacField
- form={form}
- path="remote-app"
- label={t("hosts.remoteAppProgram")}
- />
- <GuacField
- form={form}
- path="remote-app-dir"
- label={t("hosts.remoteAppDir")}
- />
- <GuacField
- form={form}
- path="remote-app-args"
- label={t("hosts.remoteAppArgs")}
- />
- </AccordionContent>
- </AccordionItem>
- )}
-
- {/* Clipboard */}
- <AccordionItem value="clipboard">
- <AccordionTrigger>{t("hosts.clipboardSettings")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <GuacSelect
- form={form}
- path="normalize-clipboard"
- label={t("hosts.normalizeClipboard")}
- options={[
- { value: "auto", label: "Auto" },
- { value: "preserve", label: "Preserve" },
- { value: "unix", label: "Unix (LF)" },
- { value: "windows", label: "Windows (CRLF)" },
- ]}
- />
- <GuacField
- form={form}
- path="disable-copy"
- label={t("hosts.disableCopy")}
- type="switch"
- />
- <GuacField
- form={form}
- path="disable-paste"
- label={t("hosts.disablePaste")}
- type="switch"
- />
- </AccordionContent>
- </AccordionItem>
-
- {/* VNC Specific */}
- {isVNC && (
- <AccordionItem value="vnc-specific">
- <AccordionTrigger>{t("hosts.vncSettings")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <GuacSelect
- form={form}
- path="cursor"
- label={t("hosts.cursorMode")}
- options={[
- { value: "auto", label: "Auto" },
- { value: "local", label: "Local" },
- { value: "remote", label: "Remote" },
- ]}
- />
- <GuacField
- form={form}
- path="swap-red-blue"
- label={t("hosts.swapRedBlue")}
- type="switch"
- />
- <GuacField
- form={form}
- path="read-only"
- label={t("hosts.readOnly")}
- type="switch"
- />
- </AccordionContent>
- </AccordionItem>
- )}
-
- {/* Recording */}
- <AccordionItem value="recording">
- <AccordionTrigger>{t("hosts.recordingSettings")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <GuacField
- form={form}
- path="recording-path"
- label={t("hosts.recordingPath")}
- />
- <GuacField
- form={form}
- path="recording-name"
- label={t("hosts.recordingName")}
- />
- <GuacField
- form={form}
- path="create-recording-path"
- label={t("hosts.createRecordingPath")}
- type="switch"
- />
- <GuacField
- form={form}
- path="recording-exclude-output"
- label={t("hosts.excludeOutput")}
- type="switch"
- />
- <GuacField
- form={form}
- path="recording-exclude-mouse"
- label={t("hosts.excludeMouse")}
- type="switch"
- />
- <GuacField
- form={form}
- path="recording-include-keys"
- label={t("hosts.includeKeys")}
- type="switch"
- />
- </AccordionContent>
- </AccordionItem>
-
- {/* Wake-on-LAN */}
- <AccordionItem value="wol">
- <AccordionTrigger>{t("hosts.wakeOnLan")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <GuacField
- form={form}
- path="wol-send-packet"
- label={t("hosts.sendWolPacket")}
- type="switch"
- />
- <GuacField
- form={form}
- path="wol-mac-addr"
- label={t("hosts.wolMacAddr")}
- />
- <GuacField
- form={form}
- path="wol-broadcast-addr"
- label={t("hosts.wolBroadcastAddr")}
- />
- <GuacField
- form={form}
- path="wol-udp-port"
- label={t("hosts.wolUdpPort")}
- type="number"
- />
- <GuacField
- form={form}
- path="wol-wait-time"
- label={t("hosts.wolWaitTime")}
- type="number"
- />
- </AccordionContent>
- </AccordionItem>
- </Accordion>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/tabs/HostSharingTab.tsx b/src/ui/desktop/apps/host-manager/hosts/tabs/HostSharingTab.tsx
deleted file mode 100644
index 0dd0fff56..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/tabs/HostSharingTab.tsx
+++ /dev/null
@@ -1,565 +0,0 @@
-import React from "react";
-import { cn } from "@/lib/utils.ts";
-import { Button } from "@/components/ui/button.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Badge } from "@/components/ui/badge.tsx";
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/components/ui/table.tsx";
-import {
- Tabs,
- TabsContent,
- TabsList,
- TabsTrigger,
-} from "@/components/ui/tabs.tsx";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
-import { toast } from "sonner";
-import { useConfirmation } from "@/hooks/use-confirmation.ts";
-import {
- getRoles,
- getUserList,
- getUserInfo,
- shareHost,
- getHostAccess,
- revokeHostAccess,
- getSSHHostById,
- type Role,
- type AccessRecord,
-} from "@/ui/main-axios.ts";
-import { useTranslation } from "react-i18next";
-import {
- Command,
- CommandEmpty,
- CommandGroup,
- CommandInput,
- CommandItem,
-} from "@/components/ui/command.tsx";
-import {
- Popover,
- PopoverContent,
- PopoverTrigger,
-} from "@/components/ui/popover.tsx";
-import {
- Plus,
- Check,
- ChevronsUpDown,
- AlertCircle,
- Trash2,
- Users,
- Shield,
- Clock,
- UserCircle,
-} from "lucide-react";
-import type { SSHHost } from "@/types";
-
-interface User {
- id: string;
- username: string;
- is_admin: boolean;
-}
-
-export function HostSharingTab({
- hostId,
- isNewHost,
-}: HostSharingTabProps): React.ReactElement {
- const { t } = useTranslation();
- const { confirmWithToast } = useConfirmation();
-
- const [shareType, setShareType] = React.useState<"user" | "role">("user");
- const [selectedUserId, setSelectedUserId] = React.useState<string>("");
- const [selectedRoleId, setSelectedRoleId] = React.useState<number | null>(
- null,
- );
- const permissionLevel = "view";
- const [expiresInHours, setExpiresInHours] = React.useState<string>("");
-
- const [roles, setRoles] = React.useState<Role[]>([]);
- const [users, setUsers] = React.useState<User[]>([]);
- const [accessList, setAccessList] = React.useState<AccessRecord[]>([]);
- const [loading, setLoading] = React.useState(false);
- const [currentUserId, setCurrentUserId] = React.useState<string>("");
- const [hostData, setHostData] = React.useState<SSHHost | null>(null);
-
- const [userComboOpen, setUserComboOpen] = React.useState(false);
- const [roleComboOpen, setRoleComboOpen] = React.useState(false);
-
- const loadRoles = React.useCallback(async () => {
- try {
- const response = await getRoles();
- setRoles(response.roles || []);
- } catch (error) {
- console.error("Failed to load roles:", error);
- setRoles([]);
- }
- }, []);
-
- const loadUsers = React.useCallback(async () => {
- try {
- const response = await getUserList();
- const mappedUsers = (response.users || []).map((user) => ({
- id: user.id,
- username: user.username,
- is_admin: user.is_admin,
- }));
- setUsers(mappedUsers);
- } catch (error) {
- console.error("Failed to load users:", error);
- setUsers([]);
- }
- }, []);
-
- const loadAccessList = React.useCallback(async () => {
- if (!hostId) return;
-
- setLoading(true);
- try {
- const response = await getHostAccess(hostId);
- setAccessList(response.accessList || []);
- } catch (error) {
- console.error("Failed to load access list:", error);
- setAccessList([]);
- } finally {
- setLoading(false);
- }
- }, [hostId]);
-
- const loadHostData = React.useCallback(async () => {
- if (!hostId) return;
-
- try {
- const host = await getSSHHostById(hostId);
- setHostData(host);
- } catch (error) {
- console.error("Failed to load host data:", error);
- setHostData(null);
- }
- }, [hostId]);
-
- React.useEffect(() => {
- loadRoles();
- loadUsers();
- if (!isNewHost) {
- loadAccessList();
- loadHostData();
- }
- }, [loadRoles, loadUsers, loadAccessList, loadHostData, isNewHost]);
-
- React.useEffect(() => {
- const fetchCurrentUser = async () => {
- try {
- const userInfo = await getUserInfo();
- setCurrentUserId(userInfo.userId);
- } catch (error) {
- console.error("Failed to load current user:", error);
- }
- };
- fetchCurrentUser();
- }, []);
-
- const handleShare = async () => {
- if (!hostId) {
- toast.error(t("rbac.saveHostFirst"));
- return;
- }
-
- if (shareType === "user" && !selectedUserId) {
- toast.error(t("rbac.selectUser"));
- return;
- }
-
- if (shareType === "role" && !selectedRoleId) {
- toast.error(t("rbac.selectRole"));
- return;
- }
-
- if (shareType === "user" && selectedUserId === currentUserId) {
- toast.error(t("rbac.cannotShareWithSelf"));
- return;
- }
-
- try {
- await shareHost(hostId, {
- targetType: shareType,
- targetUserId: shareType === "user" ? selectedUserId : undefined,
- targetRoleId: shareType === "role" ? selectedRoleId : undefined,
- permissionLevel,
- durationHours: expiresInHours
- ? parseInt(expiresInHours, 10)
- : undefined,
- });
-
- toast.success(t("rbac.sharedSuccessfully"));
- setSelectedUserId("");
- setSelectedRoleId(null);
- setExpiresInHours("");
- loadAccessList();
- } catch {
- toast.error(t("rbac.failedToShare"));
- }
- };
-
- const handleRevoke = async (accessId: number) => {
- if (!hostId) return;
-
- const confirmed = await confirmWithToast({
- title: t("rbac.confirmRevokeAccess"),
- description: t("rbac.confirmRevokeAccessDescription"),
- confirmText: t("common.revoke"),
- cancelText: t("common.cancel"),
- });
-
- if (!confirmed) return;
-
- try {
- await revokeHostAccess(hostId, accessId);
- toast.success(t("rbac.accessRevokedSuccessfully"));
- loadAccessList();
- } catch {
- toast.error(t("rbac.failedToRevokeAccess"));
- }
- };
-
- const formatDate = (dateString: string | null) => {
- if (!dateString) return "-";
- return new Date(dateString).toLocaleString();
- };
-
- const isExpired = (expiresAt: string | null) => {
- if (!expiresAt) return false;
- return new Date(expiresAt) < new Date();
- };
-
- const availableUsers = React.useMemo(() => {
- return users.filter((user) => user.id !== currentUserId);
- }, [users, currentUserId]);
-
- const selectedUser = availableUsers.find((u) => u.id === selectedUserId);
- const selectedRole = roles.find((r) => r.id === selectedRoleId);
-
- if (isNewHost) {
- return (
- <Alert>
- <AlertCircle className="h-4 w-4" />
- <AlertTitle>{t("rbac.saveHostFirst")}</AlertTitle>
- <AlertDescription>
- {t("rbac.saveHostFirstDescription")}
- </AlertDescription>
- </Alert>
- );
- }
-
- return (
- <div className="space-y-6">
- {!hostData?.credentialId && (
- <Alert variant="destructive">
- <AlertCircle className="h-4 w-4" />
- <AlertTitle>{t("rbac.credentialRequired")}</AlertTitle>
- <AlertDescription>
- {t("rbac.credentialRequiredDescription")}
- </AlertDescription>
- </Alert>
- )}
-
- {hostData?.credentialId && (
- <>
- <div className="space-y-4 border rounded-lg p-4">
- <h3 className="text-lg font-semibold flex items-center gap-2">
- <Plus className="h-5 w-5" />
- {t("rbac.shareHost")}
- </h3>
-
- <Button
- variant="outline"
- size="sm"
- className="h-8 px-3 text-xs"
- onClick={() =>
- window.open("https://docs.termix.site/rbac", "_blank")
- }
- >
- {t("common.documentation")}
- </Button>
-
- <Tabs
- value={shareType}
- onValueChange={(v) => setShareType(v as "user" | "role")}
- >
- <TabsList className="grid w-full grid-cols-2">
- <TabsTrigger value="user" className="flex items-center gap-2">
- <UserCircle className="h-4 w-4" />
- {t("rbac.shareWithUser")}
- </TabsTrigger>
- <TabsTrigger value="role" className="flex items-center gap-2">
- <Shield className="h-4 w-4" />
- {t("rbac.shareWithRole")}
- </TabsTrigger>
- </TabsList>
-
- <TabsContent value="user" className="space-y-4">
- <div className="space-y-2">
- <label htmlFor="user-select">{t("rbac.selectUser")}</label>
- <Popover open={userComboOpen} onOpenChange={setUserComboOpen}>
- <PopoverTrigger asChild>
- <Button
- variant="outline"
- role="combobox"
- aria-expanded={userComboOpen}
- className="w-full justify-between"
- >
- {selectedUser
- ? `${selectedUser.username}${selectedUser.is_admin ? " (Admin)" : ""}`
- : t("rbac.selectUserPlaceholder")}
- <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
- </Button>
- </PopoverTrigger>
- <PopoverContent
- className="p-0"
- style={{ width: "var(--radix-popover-trigger-width)" }}
- >
- <Command>
- <CommandInput placeholder={t("rbac.searchUsers")} />
- <CommandEmpty>{t("rbac.noUserFound")}</CommandEmpty>
- <CommandGroup className="max-h-[300px] overflow-y-auto thin-scrollbar">
- {availableUsers.map((user) => (
- <CommandItem
- key={user.id}
- value={`${user.username} ${user.id}`}
- onSelect={() => {
- setSelectedUserId(user.id);
- setUserComboOpen(false);
- }}
- >
- <Check
- className={cn(
- "mr-2 h-4 w-4",
- selectedUserId === user.id
- ? "opacity-100"
- : "opacity-0",
- )}
- />
- {user.username}
- {user.is_admin ? " (Admin)" : ""}
- </CommandItem>
- ))}
- </CommandGroup>
- </Command>
- </PopoverContent>
- </Popover>
- </div>
- </TabsContent>
-
- <TabsContent value="role" className="space-y-4">
- <div className="space-y-2">
- <label htmlFor="role-select">{t("rbac.selectRole")}</label>
- <Popover open={roleComboOpen} onOpenChange={setRoleComboOpen}>
- <PopoverTrigger asChild>
- <Button
- variant="outline"
- role="combobox"
- aria-expanded={roleComboOpen}
- className="w-full justify-between"
- >
- {selectedRole
- ? `${t(selectedRole.displayName)}${selectedRole.isSystem ? ` (${t("rbac.systemRole")})` : ""}`
- : t("rbac.selectRolePlaceholder")}
- <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
- </Button>
- </PopoverTrigger>
- <PopoverContent
- className="p-0"
- style={{ width: "var(--radix-popover-trigger-width)" }}
- >
- <Command>
- <CommandInput placeholder={t("rbac.searchRoles")} />
- <CommandEmpty>{t("rbac.noRoleFound")}</CommandEmpty>
- <CommandGroup className="max-h-[300px] overflow-y-auto thin-scrollbar">
- {roles.map((role) => (
- <CommandItem
- key={role.id}
- value={`${role.displayName} ${role.name} ${role.id}`}
- onSelect={() => {
- setSelectedRoleId(role.id);
- setRoleComboOpen(false);
- }}
- >
- <Check
- className={cn(
- "mr-2 h-4 w-4",
- selectedRoleId === role.id
- ? "opacity-100"
- : "opacity-0",
- )}
- />
- {t(role.displayName)}
- {role.isSystem
- ? ` (${t("rbac.systemRole")})`
- : ""}
- </CommandItem>
- ))}
- </CommandGroup>
- </Command>
- </PopoverContent>
- </Popover>
- </div>
- </TabsContent>
- </Tabs>
-
- <div className="space-y-2">
- <label>{t("rbac.permissionLevel")}</label>
- <div className="text-sm text-muted-foreground">
- {t("rbac.view")} - {t("rbac.viewDesc")}
- </div>
- </div>
-
- <div className="space-y-2">
- <label htmlFor="expires-in">{t("rbac.durationHours")}</label>
- <Input
- id="expires-in"
- type="number"
- value={expiresInHours}
- onChange={(e) => {
- const value = e.target.value;
- if (value === "" || /^\d+$/.test(value)) {
- setExpiresInHours(value);
- }
- }}
- placeholder={t("rbac.neverExpires")}
- min="1"
- />
- </div>
-
- <Button
- type="button"
- onClick={handleShare}
- className="w-full"
- disabled={!hostData?.credentialId}
- >
- <Plus className="h-4 w-4 mr-2" />
- {t("rbac.share")}
- </Button>
- </div>
-
- <div className="space-y-4">
- <h3 className="text-lg font-semibold flex items-center gap-2">
- <Users className="h-5 w-5" />
- {t("rbac.accessList")}
- </h3>
-
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead>{t("rbac.type")}</TableHead>
- <TableHead>{t("rbac.target")}</TableHead>
- <TableHead>{t("rbac.permissionLevel")}</TableHead>
- <TableHead>{t("rbac.grantedBy")}</TableHead>
- <TableHead>{t("rbac.expires")}</TableHead>
- <TableHead className="text-right">
- {t("common.actions")}
- </TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {loading ? (
- <TableRow>
- <TableCell
- colSpan={6}
- className="text-center text-muted-foreground"
- >
- {t("common.loading")}
- </TableCell>
- </TableRow>
- ) : accessList.length === 0 ? (
- <TableRow>
- <TableCell
- colSpan={6}
- className="text-center text-muted-foreground"
- >
- {t("rbac.noAccessRecords")}
- </TableCell>
- </TableRow>
- ) : (
- accessList.map((access) => (
- <TableRow
- key={access.id}
- className={
- isExpired(access.expiresAt) ? "opacity-50" : ""
- }
- >
- <TableCell>
- {access.targetType === "user" ? (
- <Badge
- variant="outline"
- className="flex items-center gap-1 w-fit"
- >
- <UserCircle className="h-3 w-3" />
- {t("rbac.user")}
- </Badge>
- ) : (
- <Badge
- variant="outline"
- className="flex items-center gap-1 w-fit"
- >
- <Shield className="h-3 w-3" />
- {t("rbac.role")}
- </Badge>
- )}
- </TableCell>
- <TableCell>
- {access.targetType === "user"
- ? access.username
- : t(access.roleDisplayName || access.roleName || "")}
- </TableCell>
- <TableCell>
- <Badge variant="secondary">
- {access.permissionLevel}
- </Badge>
- </TableCell>
- <TableCell>{access.grantedByUsername}</TableCell>
- <TableCell>
- {access.expiresAt ? (
- <div className="flex items-center gap-2">
- <Clock className="h-3 w-3" />
- <span
- className={
- isExpired(access.expiresAt)
- ? "text-red-500"
- : ""
- }
- >
- {formatDate(access.expiresAt)}
- {isExpired(access.expiresAt) && (
- <span className="ml-2">
- ({t("rbac.expired")})
- </span>
- )}
- </span>
- </div>
- ) : (
- t("rbac.never")
- )}
- </TableCell>
- <TableCell className="text-right">
- <Button
- type="button"
- size="sm"
- variant="ghost"
- onClick={() => handleRevoke(access.id)}
- >
- <Trash2 className="h-4 w-4" />
- </Button>
- </TableCell>
- </TableRow>
- ))
- )}
- </TableBody>
- </Table>
- </div>
- </>
- )}
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/tabs/HostStatisticsTab.tsx b/src/ui/desktop/apps/host-manager/hosts/tabs/HostStatisticsTab.tsx
deleted file mode 100644
index a10a659e1..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/tabs/HostStatisticsTab.tsx
+++ /dev/null
@@ -1,393 +0,0 @@
-import {
- FormControl,
- FormDescription,
- FormField,
- FormItem,
- FormLabel,
-} from "@/components/ui/form.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Switch } from "@/components/ui/switch.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Checkbox } from "@/components/ui/checkbox.tsx";
-import { Alert, AlertDescription } from "@/components/ui/alert.tsx";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select.tsx";
-import { Plus } from "lucide-react";
-import type { HostStatisticsTabProps } from "./shared/tab-types";
-import { QuickActionItem } from "./shared/QuickActionItem";
-
-export function HostStatisticsTab({
- form,
- statusIntervalUnit,
- setStatusIntervalUnit,
- metricsIntervalUnit,
- setMetricsIntervalUnit,
- snippets,
- t,
-}: HostStatisticsTabProps) {
- return (
- <div className="space-y-6">
- <div className="space-y-4">
- <div className="space-y-3">
- <Button
- variant="outline"
- size="sm"
- className="h-8 px-3 text-xs"
- onClick={() =>
- window.open("https://docs.termix.site/server-stats", "_blank")
- }
- >
- {t("common.documentation")}
- </Button>
-
- <FormField
- control={form.control}
- name="statsConfig.statusCheckEnabled"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>{t("hosts.statusCheckEnabled")}</FormLabel>
- <FormDescription>
- {t("hosts.statusCheckEnabledDesc")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- {form.watch("statsConfig.statusCheckEnabled") && (
- <>
- <FormField
- control={form.control}
- name="statsConfig.useGlobalStatusInterval"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center gap-2 space-y-0">
- <FormControl>
- <Switch
- checked={field.value ?? true}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- <FormLabel className="font-normal">
- {t("hosts.useGlobalStatusInterval")}
- </FormLabel>
- </FormItem>
- )}
- />
- {form.watch("statsConfig.useGlobalStatusInterval") === false && (
- <FormField
- control={form.control}
- name="statsConfig.statusCheckInterval"
- render={({ field }) => {
- const displayValue =
- statusIntervalUnit === "minutes"
- ? Math.round((field.value || 30) / 60)
- : field.value || 30;
-
- const handleIntervalChange = (value: string) => {
- const numValue = parseInt(value) || 0;
- const seconds =
- statusIntervalUnit === "minutes"
- ? numValue * 60
- : numValue;
- field.onChange(seconds);
- };
-
- return (
- <FormItem>
- <FormLabel>{t("hosts.statusCheckInterval")}</FormLabel>
- <div className="flex gap-2">
- <FormControl>
- <Input
- type="number"
- value={displayValue}
- onChange={(e) =>
- handleIntervalChange(e.target.value)
- }
- className="flex-1"
- />
- </FormControl>
- <Select
- value={statusIntervalUnit}
- onValueChange={(value: "seconds" | "minutes") => {
- setStatusIntervalUnit(value);
- const currentSeconds = field.value || 30;
- if (value === "minutes") {
- const minutes = Math.round(currentSeconds / 60);
- field.onChange(minutes * 60);
- }
- }}
- >
- <SelectTrigger className="w-[120px]">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="seconds">
- {t("hosts.intervalSeconds")}
- </SelectItem>
- <SelectItem value="minutes">
- {t("hosts.intervalMinutes")}
- </SelectItem>
- </SelectContent>
- </Select>
- </div>
- <FormDescription>
- {t("hosts.statusCheckIntervalDesc")}
- </FormDescription>
- </FormItem>
- );
- }}
- />
- )}
- </>
- )}
- </div>
-
- <div className="space-y-3">
- <FormField
- control={form.control}
- name="statsConfig.metricsEnabled"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>{t("hosts.metricsEnabled")}</FormLabel>
- <FormDescription>
- {t("hosts.metricsEnabledDesc")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- {form.watch("statsConfig.metricsEnabled") && (
- <>
- <FormField
- control={form.control}
- name="statsConfig.useGlobalMetricsInterval"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center gap-2 space-y-0">
- <FormControl>
- <Switch
- checked={field.value ?? true}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- <FormLabel className="font-normal">
- {t("hosts.useGlobalMetricsInterval")}
- </FormLabel>
- </FormItem>
- )}
- />
- {form.watch("statsConfig.useGlobalMetricsInterval") === false && (
- <FormField
- control={form.control}
- name="statsConfig.metricsInterval"
- render={({ field }) => {
- const displayValue =
- metricsIntervalUnit === "minutes"
- ? Math.round((field.value || 30) / 60)
- : field.value || 30;
-
- const handleIntervalChange = (value: string) => {
- const numValue = parseInt(value) || 0;
- const seconds =
- metricsIntervalUnit === "minutes"
- ? numValue * 60
- : numValue;
- field.onChange(seconds);
- };
-
- return (
- <FormItem>
- <FormLabel>{t("hosts.metricsInterval")}</FormLabel>
- <div className="flex gap-2">
- <FormControl>
- <Input
- type="number"
- value={displayValue}
- onChange={(e) =>
- handleIntervalChange(e.target.value)
- }
- className="flex-1"
- />
- </FormControl>
- <Select
- value={metricsIntervalUnit}
- onValueChange={(value: "seconds" | "minutes") => {
- setMetricsIntervalUnit(value);
- const currentSeconds = field.value || 30;
- if (value === "minutes") {
- const minutes = Math.round(currentSeconds / 60);
- field.onChange(minutes * 60);
- }
- }}
- >
- <SelectTrigger className="w-[120px]">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="seconds">
- {t("hosts.intervalSeconds")}
- </SelectItem>
- <SelectItem value="minutes">
- {t("hosts.intervalMinutes")}
- </SelectItem>
- </SelectContent>
- </Select>
- </div>
- <FormDescription>
- {t("hosts.metricsIntervalDesc")}
- </FormDescription>
- </FormItem>
- );
- }}
- />
- )}
- </>
- )}
- </div>
- </div>
-
- {form.watch("statsConfig.metricsEnabled") && (
- <>
- <FormField
- control={form.control}
- name="statsConfig.enabledWidgets"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.enabledWidgets")}</FormLabel>
- <FormDescription>
- {t("hosts.enabledWidgetsDesc")}
- </FormDescription>
- <div className="space-y-3 mt-3">
- {(
- [
- "cpu",
- "memory",
- "disk",
- "network",
- "uptime",
- "processes",
- "system",
- "login_stats",
- "ports",
- "firewall",
- ] as const
- ).map((widget) => (
- <div key={widget} className="flex items-center space-x-2">
- <Checkbox
- checked={field.value?.includes(widget)}
- onCheckedChange={(checked) => {
- const currentWidgets = field.value || [];
- if (checked) {
- field.onChange([...currentWidgets, widget]);
- } else {
- field.onChange(
- currentWidgets.filter((w) => w !== widget),
- );
- }
- }}
- />
- <label className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
- {widget === "cpu" && t("serverStats.cpuUsage")}
- {widget === "memory" && t("serverStats.memoryUsage")}
- {widget === "disk" && t("serverStats.diskUsage")}
- {widget === "network" &&
- t("serverStats.networkInterfaces")}
- {widget === "uptime" && t("serverStats.uptime")}
- {widget === "processes" && t("serverStats.processes")}
- {widget === "system" && t("serverStats.systemInfo")}
- {widget === "login_stats" &&
- t("serverStats.loginStats")}
- {widget === "ports" && t("serverStats.ports.title")}
- {widget === "firewall" &&
- t("serverStats.firewall.title")}
- </label>
- </div>
- ))}
- </div>
- </FormItem>
- )}
- />
- </>
- )}
-
- <div className="space-y-4">
- <h3 className="text-lg font-semibold">{t("hosts.quickActions")}</h3>
- <Alert>
- <AlertDescription>
- {t("hosts.quickActionsDescription")}
- </AlertDescription>
- </Alert>
- <FormField
- control={form.control}
- name="quickActions"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.quickActionsList")}</FormLabel>
- <FormControl>
- <div className="space-y-3">
- {field.value.map((quickAction, index) => (
- <QuickActionItem
- key={index}
- quickAction={quickAction}
- index={index}
- snippets={snippets}
- onUpdate={(name, snippetId) => {
- const newQuickActions = [...field.value];
- newQuickActions[index] = {
- name,
- snippetId,
- };
- field.onChange(newQuickActions);
- }}
- onRemove={() => {
- const newQuickActions = field.value.filter(
- (_, i) => i !== index,
- );
- field.onChange(newQuickActions);
- }}
- t={t}
- />
- ))}
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={() => {
- field.onChange([
- ...field.value,
- { name: "", snippetId: 0 },
- ]);
- }}
- >
- <Plus className="h-4 w-4 mr-2" />
- {t("hosts.addQuickAction")}
- </Button>
- </div>
- </FormControl>
- <FormDescription>{t("hosts.quickActionsOrder")}</FormDescription>
- </FormItem>
- )}
- />
- </div>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/tabs/HostStatusTab.tsx b/src/ui/desktop/apps/host-manager/hosts/tabs/HostStatusTab.tsx
deleted file mode 100644
index 543dc4adb..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/tabs/HostStatusTab.tsx
+++ /dev/null
@@ -1,143 +0,0 @@
-import {
- FormControl,
- FormDescription,
- FormField,
- FormItem,
- FormLabel,
-} from "@/components/ui/form.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Switch } from "@/components/ui/switch.tsx";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select.tsx";
-import type { HostStatisticsTabProps } from "./shared/tab-types";
-
-export function HostStatusTab({
- form,
- statusIntervalUnit,
- setStatusIntervalUnit,
- t,
-}: Pick<
- HostStatisticsTabProps,
- "form" | "statusIntervalUnit" | "setStatusIntervalUnit" | "t"
->) {
- return (
- <div className="space-y-6">
- <div className="space-y-4">
- <div className="space-y-3">
- <FormField
- control={form.control}
- name="statsConfig.statusCheckEnabled"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>{t("hosts.statusCheckEnabled")}</FormLabel>
- <FormDescription>
- {t("hosts.statusCheckEnabledDesc")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- {form.watch("statsConfig.statusCheckEnabled") && (
- <>
- <FormField
- control={form.control}
- name="statsConfig.useGlobalStatusInterval"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center gap-2 space-y-0">
- <FormControl>
- <Switch
- checked={field.value ?? true}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- <FormLabel className="font-normal">
- {t("hosts.useGlobalStatusInterval")}
- </FormLabel>
- </FormItem>
- )}
- />
- {form.watch("statsConfig.useGlobalStatusInterval") === false && (
- <FormField
- control={form.control}
- name="statsConfig.statusCheckInterval"
- render={({ field }) => {
- const displayValue =
- statusIntervalUnit === "minutes"
- ? Math.round((field.value || 30) / 60)
- : field.value || 30;
-
- const handleIntervalChange = (value: string) => {
- const numValue = parseInt(value) || 0;
- const seconds =
- statusIntervalUnit === "minutes"
- ? numValue * 60
- : numValue;
- field.onChange(seconds);
- };
-
- return (
- <FormItem>
- <FormLabel>{t("hosts.statusCheckInterval")}</FormLabel>
- <div className="flex gap-2">
- <FormControl>
- <Input
- type="number"
- value={displayValue}
- onChange={(e) =>
- handleIntervalChange(e.target.value)
- }
- className="flex-1"
- />
- </FormControl>
- <Select
- value={statusIntervalUnit}
- onValueChange={(value: "seconds" | "minutes") => {
- setStatusIntervalUnit(value);
- const currentSeconds = field.value || 30;
- if (value === "minutes") {
- const minutes = Math.round(currentSeconds / 60);
- field.onChange(minutes * 60);
- }
- }}
- >
- <SelectTrigger className="w-[120px]">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="seconds">
- {t("hosts.intervalSeconds")}
- </SelectItem>
- <SelectItem value="minutes">
- {t("hosts.intervalMinutes")}
- </SelectItem>
- </SelectContent>
- </Select>
- </div>
- <FormDescription>
- {t("hosts.statusCheckIntervalDesc")}
- </FormDescription>
- </FormItem>
- );
- }}
- />
- )}
- </>
- )}
- </div>
- </div>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/tabs/HostTerminalTab.tsx b/src/ui/desktop/apps/host-manager/hosts/tabs/HostTerminalTab.tsx
deleted file mode 100644
index 5abf83b42..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/tabs/HostTerminalTab.tsx
+++ /dev/null
@@ -1,858 +0,0 @@
-import {
- FormControl,
- FormDescription,
- FormField,
- FormItem,
- FormLabel,
-} from "@/components/ui/form.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Switch } from "@/components/ui/switch.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select.tsx";
-import {
- Accordion,
- AccordionContent,
- AccordionItem,
- AccordionTrigger,
-} from "@/components/ui/accordion.tsx";
-import {
- Popover,
- PopoverContent,
- PopoverTrigger,
-} from "@/components/ui/popover.tsx";
-import {
- Command,
- CommandEmpty,
- CommandGroup,
- CommandInput,
- CommandItem,
-} from "@/components/ui/command.tsx";
-import { Slider } from "@/components/ui/slider.tsx";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
-import { Check, ChevronsUpDown, Plus, X } from "lucide-react";
-import { cn } from "@/lib/utils.ts";
-import {
- TERMINAL_THEMES,
- TERMINAL_FONTS,
-} from "@/constants/terminal-themes.ts";
-import { TerminalPreview } from "@/ui/desktop/apps/features/terminal/TerminalPreview.tsx";
-import type { HostTerminalTabProps } from "./shared/tab-types";
-import React from "react";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
-
-export function HostTerminalTab({ form, snippets, t }: HostTerminalTabProps) {
- const [snippetPopoverOpen, setSnippetPopoverOpen] = React.useState(false);
- const { setPreviewTerminalTheme } = useTabs();
- return (
- <div className="space-y-1">
- <FormField
- control={form.control}
- name="enableTerminal"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.enableTerminal")}</FormLabel>
- <FormControl>
- <Switch checked={field.value} onCheckedChange={field.onChange} />
- </FormControl>
- <FormDescription>{t("hosts.enableTerminalDesc")}</FormDescription>
- </FormItem>
- )}
- />
- <h1 className="text-xl font-semibold mt-7">
- {t("hosts.terminalCustomization")}
- </h1>
- <Accordion
- type="multiple"
- className="w-full"
- defaultValue={["appearance", "behavior", "advanced"]}
- >
- <AccordionItem value="appearance">
- <AccordionTrigger>{t("hosts.appearance")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <div className="space-y-2">
- <label className="text-sm font-medium">
- {t("hosts.themePreview")}
- </label>
- <TerminalPreview
- theme={form.watch("terminalConfig.theme")}
- fontSize={form.watch("terminalConfig.fontSize")}
- fontFamily={form.watch("terminalConfig.fontFamily")}
- cursorStyle={form.watch("terminalConfig.cursorStyle")}
- cursorBlink={form.watch("terminalConfig.cursorBlink")}
- letterSpacing={form.watch("terminalConfig.letterSpacing")}
- lineHeight={form.watch("terminalConfig.lineHeight")}
- />
- </div>
-
- <FormField
- control={form.control}
- name="terminalConfig.theme"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.theme")}</FormLabel>
- <Select onValueChange={field.onChange} value={field.value}>
- <FormControl>
- <SelectTrigger>
- <SelectValue placeholder={t("hosts.selectTheme")} />
- </SelectTrigger>
- </FormControl>
- <SelectContent
- onMouseLeave={() => setPreviewTerminalTheme(null)}
- >
- {Object.entries(TERMINAL_THEMES).map(([key, theme]) => (
- <SelectItem
- key={key}
- value={key}
- onMouseEnter={() => setPreviewTerminalTheme(key)}
- >
- {theme.name}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- <FormDescription>
- {t("hosts.chooseColorTheme")}
- </FormDescription>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.fontFamily"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.fontFamily")}</FormLabel>
- <Select onValueChange={field.onChange} value={field.value}>
- <FormControl>
- <SelectTrigger>
- <SelectValue placeholder={t("hosts.selectFont")} />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- {TERMINAL_FONTS.map((font) => (
- <SelectItem key={font.value} value={font.value}>
- {font.label}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- <FormDescription>{t("hosts.selectFontDesc")}</FormDescription>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.fontSize"
- render={({ field }) => (
- <FormItem>
- <FormLabel>
- {t("hosts.fontSizeValue", {
- value: field.value,
- })}
- </FormLabel>
- <FormControl>
- <Slider
- min={8}
- max={24}
- step={1}
- value={[field.value]}
- onValueChange={([value]) => field.onChange(value)}
- />
- </FormControl>
- <FormDescription>{t("hosts.adjustFontSize")}</FormDescription>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.letterSpacing"
- render={({ field }) => (
- <FormItem>
- <FormLabel>
- {t("hosts.letterSpacingValue", {
- value: field.value,
- })}
- </FormLabel>
- <FormControl>
- <Slider
- min={-2}
- max={10}
- step={0.5}
- value={[field.value]}
- onValueChange={([value]) => field.onChange(value)}
- />
- </FormControl>
- <FormDescription>
- {t("hosts.adjustLetterSpacing")}
- </FormDescription>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.lineHeight"
- render={({ field }) => (
- <FormItem>
- <FormLabel>
- {t("hosts.lineHeightValue", {
- value: field.value,
- })}
- </FormLabel>
- <FormControl>
- <Slider
- min={1}
- max={2}
- step={0.1}
- value={[field.value]}
- onValueChange={([value]) => field.onChange(value)}
- />
- </FormControl>
- <FormDescription>
- {t("hosts.adjustLineHeight")}
- </FormDescription>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.cursorStyle"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.cursorStyle")}</FormLabel>
- <Select onValueChange={field.onChange} value={field.value}>
- <FormControl>
- <SelectTrigger>
- <SelectValue
- placeholder={t("hosts.selectCursorStyle")}
- />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- <SelectItem value="block">
- {t("hosts.cursorStyleBlock")}
- </SelectItem>
- <SelectItem value="underline">
- {t("hosts.cursorStyleUnderline")}
- </SelectItem>
- <SelectItem value="bar">
- {t("hosts.cursorStyleBar")}
- </SelectItem>
- </SelectContent>
- </Select>
- <FormDescription>
- {t("hosts.chooseCursorAppearance")}
- </FormDescription>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.cursorBlink"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>{t("hosts.cursorBlink")}</FormLabel>
- <FormDescription>
- {t("hosts.enableCursorBlink")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </AccordionContent>
- </AccordionItem>
-
- <AccordionItem value="behavior">
- <AccordionTrigger>{t("hosts.behavior")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <FormField
- control={form.control}
- name="terminalConfig.scrollback"
- render={({ field }) => (
- <FormItem>
- <FormLabel>
- {t("hosts.scrollbackBufferValue", {
- value: field.value,
- })}
- </FormLabel>
- <FormControl>
- <Slider
- min={1000}
- max={100000}
- step={1000}
- value={[field.value]}
- onValueChange={([value]) => field.onChange(value)}
- />
- </FormControl>
- <FormDescription>
- {t("hosts.scrollbackBufferDesc")}
- </FormDescription>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.bellStyle"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.bellStyle")}</FormLabel>
- <Select onValueChange={field.onChange} value={field.value}>
- <FormControl>
- <SelectTrigger>
- <SelectValue placeholder={t("hosts.selectBellStyle")} />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- <SelectItem value="none">
- {t("hosts.bellStyleNone")}
- </SelectItem>
- <SelectItem value="sound">
- {t("hosts.bellStyleSound")}
- </SelectItem>
- <SelectItem value="visual">
- {t("hosts.bellStyleVisual")}
- </SelectItem>
- <SelectItem value="both">
- {t("hosts.bellStyleBoth")}
- </SelectItem>
- </SelectContent>
- </Select>
- <FormDescription>{t("hosts.bellStyleDesc")}</FormDescription>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.rightClickSelectsWord"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>{t("hosts.rightClickSelectsWord")}</FormLabel>
- <FormDescription>
- {t("hosts.rightClickSelectsWordDesc")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.fastScrollModifier"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.fastScrollModifier")}</FormLabel>
- <Select onValueChange={field.onChange} value={field.value}>
- <FormControl>
- <SelectTrigger>
- <SelectValue placeholder={t("hosts.selectModifier")} />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- <SelectItem value="alt">
- {t("hosts.modifierAlt")}
- </SelectItem>
- <SelectItem value="ctrl">
- {t("hosts.modifierCtrl")}
- </SelectItem>
- <SelectItem value="shift">
- {t("hosts.modifierShift")}
- </SelectItem>
- </SelectContent>
- </Select>
- <FormDescription>
- {t("hosts.fastScrollModifierDesc")}
- </FormDescription>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.fastScrollSensitivity"
- render={({ field }) => (
- <FormItem>
- <FormLabel>
- {t("hosts.fastScrollSensitivityValue", {
- value: field.value,
- })}
- </FormLabel>
- <FormControl>
- <Slider
- min={1}
- max={10}
- step={1}
- value={[field.value]}
- onValueChange={([value]) => field.onChange(value)}
- />
- </FormControl>
- <FormDescription>
- {t("hosts.fastScrollSensitivityDesc")}
- </FormDescription>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.minimumContrastRatio"
- render={({ field }) => (
- <FormItem>
- <FormLabel>
- {t("hosts.minimumContrastRatioValue", {
- value: field.value,
- })}
- </FormLabel>
- <FormControl>
- <Slider
- min={1}
- max={21}
- step={1}
- value={[field.value]}
- onValueChange={([value]) => field.onChange(value)}
- />
- </FormControl>
- <FormDescription>
- {t("hosts.minimumContrastRatioDesc")}
- </FormDescription>
- </FormItem>
- )}
- />
- </AccordionContent>
- </AccordionItem>
-
- <AccordionItem value="advanced">
- <AccordionTrigger>{t("hosts.advanced")}</AccordionTrigger>
- <AccordionContent className="space-y-4 pt-4">
- <FormField
- control={form.control}
- name="terminalConfig.agentForwarding"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>{t("hosts.sshAgentForwarding")}</FormLabel>
- <FormDescription>
- {t("hosts.sshAgentForwardingDesc")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.backspaceMode"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.backspaceMode")}</FormLabel>
- <Select onValueChange={field.onChange} value={field.value}>
- <FormControl>
- <SelectTrigger>
- <SelectValue
- placeholder={t("hosts.selectBackspaceMode")}
- />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- <SelectItem value="normal">
- {t("hosts.backspaceModeNormal")}
- </SelectItem>
- <SelectItem value="control-h">
- {t("hosts.backspaceModeControlH")}
- </SelectItem>
- </SelectContent>
- </Select>
- <FormDescription>
- {t("hosts.backspaceModeDesc")}
- </FormDescription>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.startupSnippetId"
- render={({ field }) => {
- const open = snippetPopoverOpen;
- const setOpen = setSnippetPopoverOpen;
- const selectedSnippet = snippets.find(
- (s) => s.id === field.value,
- );
-
- return (
- <FormItem>
- <FormLabel>{t("hosts.startupSnippet")}</FormLabel>
- <Popover open={open} onOpenChange={setOpen}>
- <PopoverTrigger asChild>
- <FormControl>
- <Button
- variant="outline"
- role="combobox"
- aria-expanded={open}
- className="w-full justify-between"
- >
- {selectedSnippet
- ? selectedSnippet.name
- : t("hosts.selectSnippet")}
- <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
- </Button>
- </FormControl>
- </PopoverTrigger>
- <PopoverContent
- className="p-0"
- style={{
- width: "var(--radix-popover-trigger-width)",
- }}
- >
- <Command>
- <CommandInput
- placeholder={t("hosts.searchSnippets")}
- />
- <CommandEmpty>
- {t("hosts.noSnippetFound")}
- </CommandEmpty>
- <CommandGroup className="max-h-[300px] overflow-y-auto thin-scrollbar">
- <CommandItem
- value="none"
- onSelect={() => {
- field.onChange(null);
- setOpen(false);
- }}
- >
- <Check
- className={cn(
- "mr-2 h-4 w-4",
- !field.value ? "opacity-100" : "opacity-0",
- )}
- />
- {t("hosts.snippetNone")}
- </CommandItem>
- {snippets.map((snippet) => (
- <CommandItem
- key={snippet.id}
- value={`${snippet.name} ${snippet.content} ${snippet.id}`}
- onSelect={() => {
- field.onChange(snippet.id);
- setOpen(false);
- }}
- >
- <Check
- className={cn(
- "mr-2 h-4 w-4",
- field.value === snippet.id
- ? "opacity-100"
- : "opacity-0",
- )}
- />
- <div className="flex flex-col">
- <span className="font-medium">
- {snippet.name}
- </span>
- <span className="text-xs text-muted-foreground truncate max-w-[350px]">
- {snippet.content}
- </span>
- </div>
- </CommandItem>
- ))}
- </CommandGroup>
- </Command>
- </PopoverContent>
- </Popover>
- <FormDescription>
- {t("hosts.executeSnippetOnConnect")}
- </FormDescription>
- </FormItem>
- );
- }}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.autoMosh"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>{t("hosts.autoMosh")}</FormLabel>
- <FormDescription>{t("hosts.autoMoshDesc")}</FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- {form.watch("terminalConfig.autoMosh") && (
- <FormField
- control={form.control}
- name="terminalConfig.moshCommand"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.moshCommand")}</FormLabel>
- <FormControl>
- <Input
- placeholder={t("placeholders.moshCommand")}
- {...field}
- onBlur={(e) => {
- field.onChange(e.target.value.trim());
- field.onBlur();
- }}
- />
- </FormControl>
- <FormDescription>
- {t("hosts.moshCommandDesc")}
- </FormDescription>
- </FormItem>
- )}
- />
- )}
-
- <FormField
- control={form.control}
- name="terminalConfig.autoTmux"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>{t("hosts.autoTmux")}</FormLabel>
- <FormDescription>{t("hosts.autoTmuxDesc")}</FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="terminalConfig.sudoPasswordAutoFill"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>{t("hosts.sudoPasswordAutoFill")}</FormLabel>
- <FormDescription>
- {t("hosts.sudoPasswordAutoFillDesc")}
- </FormDescription>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- {form.watch("terminalConfig.sudoPasswordAutoFill") && (
- <FormField
- control={form.control}
- name="terminalConfig.sudoPassword"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.sudoPassword")}</FormLabel>
- <FormControl>
- <PasswordInput
- placeholder={t("placeholders.sudoPassword")}
- {...field}
- />
- </FormControl>
- <FormDescription>
- {t("hosts.sudoPasswordDesc")}
- </FormDescription>
- </FormItem>
- )}
- />
- )}
-
- <div className="space-y-2">
- <label className="text-sm font-medium">
- {t("hosts.environmentVariables")}
- </label>
- <FormDescription>
- {t("hosts.environmentVariablesDesc")}
- </FormDescription>
- {form
- .watch("terminalConfig.environmentVariables")
- ?.map((_, index) => (
- <div key={index} className="flex gap-2">
- <FormField
- control={form.control}
- name={`terminalConfig.environmentVariables.${index}.key`}
- render={({ field }) => (
- <FormItem className="flex-1">
- <FormControl>
- <Input
- placeholder={t("hosts.variableName")}
- {...field}
- onBlur={(e) => {
- field.onChange(e.target.value.trim());
- field.onBlur();
- }}
- />
- </FormControl>
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name={`terminalConfig.environmentVariables.${index}.value`}
- render={({ field }) => (
- <FormItem className="flex-1">
- <FormControl>
- <Input
- placeholder={t("hosts.variableValue")}
- {...field}
- onBlur={(e) => {
- field.onChange(e.target.value.trim());
- field.onBlur();
- }}
- />
- </FormControl>
- </FormItem>
- )}
- />
- <Button
- type="button"
- variant="outline"
- size="icon"
- onClick={() => {
- const current = form.getValues(
- "terminalConfig.environmentVariables",
- );
- form.setValue(
- "terminalConfig.environmentVariables",
- current.filter((_, i) => i !== index),
- );
- }}
- >
- <X className="h-4 w-4" />
- </Button>
- </div>
- ))}
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={() => {
- const current =
- form.getValues("terminalConfig.environmentVariables") || [];
- form.setValue("terminalConfig.environmentVariables", [
- ...current,
- { key: "", value: "" },
- ]);
- }}
- >
- <Plus className="h-4 w-4 mr-2" />
- {t("hosts.addVariable")}
- </Button>
- </div>
-
- <div className="space-y-4 pt-4 border-t">
- <label className="text-sm font-medium">
- {t("hosts.keepaliveSettings")}
- </label>
- <FormDescription>
- {t("hosts.keepaliveSettingsDesc")}
- </FormDescription>
- <div className="grid grid-cols-2 gap-4">
- <FormField
- control={form.control}
- name="terminalConfig.keepaliveInterval"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.keepaliveInterval")}</FormLabel>
- <FormControl>
- <Input
- type="number"
- min={0}
- max={300000}
- placeholder="30000"
- value={field.value ?? ""}
- onChange={(e) => {
- const val = e.target.value;
- field.onChange(
- val === "" ? undefined : Number(val),
- );
- }}
- />
- </FormControl>
- <FormDescription>
- {t("hosts.keepaliveIntervalDesc")}
- </FormDescription>
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name="terminalConfig.keepaliveCountMax"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.keepaliveCountMax")}</FormLabel>
- <FormControl>
- <Input
- type="number"
- min={0}
- max={100}
- placeholder="3"
- value={field.value ?? ""}
- onChange={(e) => {
- const val = e.target.value;
- field.onChange(
- val === "" ? undefined : Number(val),
- );
- }}
- />
- </FormControl>
- <FormDescription>
- {t("hosts.keepaliveCountMaxDesc")}
- </FormDescription>
- </FormItem>
- )}
- />
- </div>
- </div>
- </AccordionContent>
- </AccordionItem>
- </Accordion>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/tabs/HostTunnelTab.tsx b/src/ui/desktop/apps/host-manager/hosts/tabs/HostTunnelTab.tsx
deleted file mode 100644
index a63bf36d3..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/tabs/HostTunnelTab.tsx
+++ /dev/null
@@ -1,720 +0,0 @@
-import {
- FormControl,
- FormDescription,
- FormField,
- FormItem,
- FormLabel,
-} from "@/components/ui/form.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Switch } from "@/components/ui/switch.tsx";
-import { Alert, AlertDescription } from "@/components/ui/alert.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select.tsx";
-import { TunnelInlineControls } from "@/ui/desktop/apps/features/tunnel/TunnelInlineControls.tsx";
-import { TunnelModeSelector } from "@/ui/desktop/apps/features/tunnel/TunnelModeSelector.tsx";
-import {
- getTunnelModeDescription,
- getTunnelPortLabels,
- getTunnelTypeForMode,
-} from "@/ui/desktop/apps/features/tunnel/tunnel-form-utils.ts";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
-import {
- connectTunnel,
- disconnectTunnel,
- subscribeTunnelStatuses,
-} from "@/ui/main-axios.ts";
-import type { SSHHost, TunnelConfig, TunnelStatus } from "@/types/index.js";
-import { useEffect, useRef, useState } from "react";
-import { toast } from "sonner";
-import type { HostTunnelTabProps } from "./shared/tab-types";
-
-export function HostTunnelTab({
- form,
- hosts,
- editingHost,
- t,
-}: HostTunnelTabProps) {
- const { tabs, addTab, setCurrentTab, updateTab } = useTabs();
- const [tunnelStatuses, setTunnelStatuses] = useState<
- Record<string, TunnelStatus>
- >({});
- const [tunnelActions, setTunnelActions] = useState<Record<string, boolean>>(
- {},
- );
- const previousTunnelStatusesRef = useRef<Record<string, TunnelStatus>>({});
- const supportsC2S =
- typeof window !== "undefined" && window.electronAPI?.isElectron === true;
-
- useEffect(() => {
- return subscribeTunnelStatuses(setTunnelStatuses, () => {
- // The form should stay usable if the tunnel status stream reconnects.
- });
- }, []);
-
- useEffect(() => {
- const previousStatuses = previousTunnelStatusesRef.current;
-
- for (const [tunnelName, status] of Object.entries(tunnelStatuses)) {
- const previous = previousStatuses[tunnelName];
- const statusChanged =
- previous?.status !== status.status ||
- previous?.reason !== status.reason ||
- previous?.retryCount !== status.retryCount ||
- previous?.nextRetryIn !== status.nextRetryIn;
-
- if (!statusChanged) continue;
-
- console.info("[tunnels] Server tunnel status changed", {
- tunnelName,
- status,
- });
-
- const statusValue = status.status?.toUpperCase();
- const hasFailureDetail =
- statusValue === "ERROR" ||
- statusValue === "FAILED" ||
- (Boolean(status.errorType) &&
- Boolean(status.reason) &&
- previous?.reason !== status.reason);
-
- if (hasFailureDetail) {
- const message = status.reason || t("tunnels.manualControlError");
- console.error("[tunnels] Server tunnel failed", {
- tunnelName,
- status,
- });
- toast.error(message, {
- id: `server-tunnel-error-${tunnelName}`,
- });
- }
- }
-
- previousTunnelStatusesRef.current = tunnelStatuses;
- }, [t, tunnelStatuses]);
-
- const openC2SPresets = () => {
- const profileTab = tabs.find((tab) => tab.type === "user_profile");
- if (profileTab) {
- updateTab(profileTab.id, {
- initialTab: "c2s-tunnels",
- _updateTimestamp: Date.now(),
- });
- setCurrentTab(profileTab.id);
- return;
- }
-
- const id = addTab({
- type: "user_profile",
- title: t("profile.title"),
- initialTab: "c2s-tunnels",
- });
- setCurrentTab(id);
- };
-
- const getCurrentHost = (): SSHHost | null => {
- if (!editingHost?.id) return null;
- return hosts.find((host) => host.id === editingHost.id) || editingHost;
- };
-
- const getTunnelName = (host: SSHHost, index: number) => {
- const tunnel = form.getValues(`serverTunnels.${index}`);
- return `${host.id}::${index}::${host.name || `${host.username}@${host.ip}`}::${tunnel.sourcePort}::${tunnel.endpointHost}::${tunnel.endpointPort}`;
- };
-
- const handleServerTunnelAction = async (
- action: "connect" | "disconnect",
- index: number,
- ) => {
- const host = getCurrentHost();
- if (!host?.id) {
- toast.error(t("tunnels.saveHostBeforeManualControl"));
- return;
- }
-
- const tunnel = form.getValues(`serverTunnels.${index}`);
- const tunnelName = getTunnelName(host, index);
- setTunnelActions((current) => ({ ...current, [tunnelName]: true }));
- console.info(`[tunnels] ${action} server tunnel`, {
- tunnelName,
- tunnel,
- });
-
- try {
- if (action === "connect") {
- const endpointHost = hosts.find(
- (item) =>
- item.name === tunnel.endpointHost ||
- `${item.username}@${item.ip}` === tunnel.endpointHost,
- );
- const tunnelConfig: TunnelConfig = {
- name: tunnelName,
- scope: "s2s",
- mode: tunnel.mode || tunnel.tunnelType || "remote",
- bindHost: tunnel.bindHost,
- targetHost: tunnel.targetHost,
- tunnelType:
- tunnel.tunnelType ||
- (tunnel.mode === "local" || tunnel.mode === "remote"
- ? tunnel.mode
- : "remote"),
- sourceHostId: host.id,
- tunnelIndex: index,
- hostName: host.name || `${host.username}@${host.ip}`,
- sourceIP: host.ip,
- sourceSSHPort: host.port,
- sourceUsername: host.username,
- sourcePassword:
- host.authType === "password" ? host.password : undefined,
- sourceAuthMethod: host.authType,
- sourceSSHKey: host.authType === "key" ? host.key : undefined,
- sourceKeyPassword:
- host.authType === "key" ? host.keyPassword : undefined,
- sourceKeyType: host.authType === "key" ? host.keyType : undefined,
- sourceCredentialId: host.credentialId,
- sourceUserId: host.userId,
- endpointHost: tunnel.endpointHost,
- endpointIP: endpointHost?.ip,
- endpointSSHPort: endpointHost?.port,
- endpointUsername: endpointHost?.username,
- endpointPassword:
- endpointHost?.authType === "password"
- ? endpointHost.password
- : undefined,
- endpointAuthMethod: endpointHost?.authType,
- endpointSSHKey:
- endpointHost?.authType === "key" ? endpointHost.key : undefined,
- endpointKeyPassword:
- endpointHost?.authType === "key"
- ? endpointHost.keyPassword
- : undefined,
- endpointKeyType:
- endpointHost?.authType === "key" ? endpointHost.keyType : undefined,
- endpointCredentialId: endpointHost?.credentialId,
- endpointUserId: endpointHost?.userId,
- sourcePort: tunnel.sourcePort,
- endpointPort: tunnel.endpointPort,
- maxRetries: tunnel.maxRetries,
- retryInterval: tunnel.retryInterval * 1000,
- autoStart: tunnel.autoStart,
- isPinned: host.pin,
- useSocks5: host.useSocks5,
- socks5Host: host.socks5Host,
- socks5Port: host.socks5Port,
- socks5Username: host.socks5Username,
- socks5Password: host.socks5Password,
- socks5ProxyChain: host.socks5ProxyChain,
- };
- await connectTunnel(tunnelConfig);
- } else {
- await disconnectTunnel(tunnelName);
- }
- } catch (error) {
- console.error(`[tunnels] Failed to ${action} server tunnel`, {
- tunnelName,
- error,
- });
- toast.error(
- error instanceof Error
- ? error.message
- : t("tunnels.manualControlError"),
- );
- } finally {
- setTunnelActions((current) => ({ ...current, [tunnelName]: false }));
- }
- };
-
- return (
- <div>
- <FormField
- control={form.control}
- name="enableTunnel"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("hosts.enableTunnel")}</FormLabel>
- <FormControl>
- <Switch checked={field.value} onCheckedChange={field.onChange} />
- </FormControl>
- <FormDescription>{t("hosts.enableTunnelDesc")}</FormDescription>
- </FormItem>
- )}
- />
- {form.watch("enableTunnel") && (
- <>
- <Alert className="mt-4">
- <AlertDescription>
- <strong>{t("hosts.sshpassRequired")}</strong>
- <div>
- {t("hosts.sshpassRequiredDesc")}{" "}
- <code className="bg-muted px-1 rounded inline">
- sudo apt install sshpass
- </code>{" "}
- {t("hosts.debianUbuntuEquivalent")}
- </div>
- <div className="mt-2">
- <strong>{t("hosts.otherInstallMethods")}</strong>
- <div>
- • {t("hosts.centosRhelFedora")}{" "}
- <code className="bg-muted px-1 rounded inline">
- sudo yum install sshpass
- </code>{" "}
- {t("hosts.or")}{" "}
- <code className="bg-muted px-1 rounded inline">
- sudo dnf install sshpass
- </code>
- </div>
- <div>
- • {t("hosts.macos")}{" "}
- <code className="bg-muted px-1 rounded inline">
- brew install hudochenkov/sshpass/sshpass
- </code>
- </div>
- <div>
- • {t("hosts.windows")}{" "}
- <code className="bg-muted px-1 rounded inline">
- sudo apt install sshpass
- </code>
- </div>
- </div>
- </AlertDescription>
- </Alert>
-
- <Alert className="mt-4">
- <AlertDescription>
- <strong>{t("hosts.sshServerConfigRequired")}</strong>
- <div>{t("hosts.sshServerConfigDesc")}</div>
- <div>
- •{" "}
- <code className="bg-muted px-1 rounded inline">
- GatewayPorts yes
- </code>{" "}
- {t("hosts.gatewayPortsYes")}
- </div>
- <div>
- •{" "}
- <code className="bg-muted px-1 rounded inline">
- AllowTcpForwarding yes
- </code>{" "}
- {t("hosts.allowTcpForwardingYes")}
- </div>
- <div>
- •{" "}
- <code className="bg-muted px-1 rounded inline">
- PermitRootLogin yes
- </code>{" "}
- {t("hosts.permitRootLoginYes")}
- </div>
- <div className="mt-2">
- {t("hosts.editSshConfig")}{" "}
- <code className="bg-muted px-1 rounded inline">
- {t("hosts.sshConfigPath")}
- </code>
- </div>
- <div className="mt-2">
- {t("hosts.restartSshService")}{" "}
- <code className="bg-muted px-1 rounded inline">
- {t("hosts.restartSshCommand")}
- </code>
- </div>
- </AlertDescription>
- </Alert>
- <div className="mt-3 flex flex-wrap items-center gap-2 justify-between">
- <Button
- variant="outline"
- size="sm"
- className="h-8 px-3 text-xs"
- onClick={() =>
- window.open("https://docs.termix.site/tunnels", "_blank")
- }
- >
- {t("common.documentation")}
- </Button>
- <Button
- type="button"
- variant="outline"
- size="sm"
- className="h-8 px-3 text-xs"
- onClick={openC2SPresets}
- disabled={!supportsC2S}
- title={
- supportsC2S ? undefined : t("tunnels.clientTunnelsUnavailable")
- }
- >
- {t("tunnels.manageClientTunnels")}
- </Button>
- </div>
- {!supportsC2S && (
- <p className="mt-2 text-xs text-muted-foreground">
- {t("tunnels.clientTunnelsUnavailable")}
- </p>
- )}
- {(() => {
- type TunnelFieldName = "serverTunnels";
-
- const removeTunnel = (
- fieldName: TunnelFieldName,
- tunnels: unknown[],
- index: number,
- ) => {
- form.setValue(
- fieldName,
- tunnels.filter((_, i) => i !== index),
- { shouldDirty: true, shouldValidate: true },
- );
- };
-
- const addServerTunnel = (tunnels: unknown[]) => {
- form.setValue(
- "serverTunnels",
- [
- ...tunnels,
- {
- scope: "s2s",
- mode: "remote",
- tunnelType: "remote",
- bindHost: "",
- targetHost: "",
- sourcePort: 22,
- endpointPort: 224,
- endpointHost: "",
- maxRetries: 3,
- retryInterval: 10,
- autoStart: false,
- },
- ],
- { shouldDirty: true, shouldValidate: true },
- );
- };
-
- const renderTunnelCard = (
- fieldName: TunnelFieldName,
- index: number,
- displayIndex: number,
- tunnels: unknown[],
- ) => {
- const scope = form.watch(`${fieldName}.${index}.scope`) || "s2s";
- const mode = form.watch(`${fieldName}.${index}.mode`) || "remote";
- const isC2S = scope === "c2s";
- const currentHost = getCurrentHost();
- const endpointConfigOptions = hosts
- .filter(
- (item) =>
- item.id !== currentHost?.id &&
- (item.connectionType || "ssh") === "ssh",
- )
- .map((item) => item.name || `${item.username}@${item.ip}`)
- .sort((a, b) => a.localeCompare(b));
- const tunnelName = currentHost
- ? getTunnelName(currentHost, index)
- : "";
- const tunnelStatus = tunnelName
- ? tunnelStatuses[tunnelName]
- : undefined;
- const isTunnelActionLoading = tunnelName
- ? Boolean(tunnelActions[tunnelName])
- : false;
- const formScope = isC2S ? "client" : "server";
- const { sourcePortLabel, endpointPortLabel } =
- getTunnelPortLabels(formScope, mode, t);
- const modeDescription = getTunnelModeDescription(
- formScope,
- mode,
- {
- sourcePort:
- form.watch(`${fieldName}.${index}.sourcePort`) || "22",
- endpointPort:
- form.watch(`${fieldName}.${index}.endpointPort`) || "22",
- },
- t,
- );
-
- return (
- <div key={index} className="p-4 border rounded-lg bg-muted/50">
- <div className="flex items-center justify-between mb-3">
- <h4 className="text-sm font-bold">
- {isC2S
- ? t("tunnels.clientTunnel")
- : t("tunnels.serverTunnel")}{" "}
- {displayIndex + 1}
- </h4>
- <div className="flex flex-wrap items-center justify-end gap-2">
- <TunnelInlineControls
- status={tunnelStatus}
- loading={isTunnelActionLoading}
- onStart={() =>
- handleServerTunnelAction("connect", index)
- }
- onStop={() =>
- handleServerTunnelAction("disconnect", index)
- }
- startDisabled={!currentHost}
- startDisabledReason={t(
- "tunnels.saveHostBeforeManualControl",
- )}
- />
- <Button
- type="button"
- variant="ghost"
- size="sm"
- onClick={() => removeTunnel(fieldName, tunnels, index)}
- >
- {t("common.delete")}
- </Button>
- </div>
- </div>
- <div className="grid gap-4 mb-4">
- <FormField
- control={form.control}
- name={`${fieldName}.${index}.mode`}
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("tunnels.type")}</FormLabel>
- <FormControl>
- <TunnelModeSelector
- mode={field.value || "remote"}
- scope={isC2S ? "client" : "server"}
- onChange={(nextMode) => {
- field.onChange(nextMode);
- form.setValue(
- `${fieldName}.${index}.tunnelType`,
- getTunnelTypeForMode(nextMode),
- {
- shouldDirty: true,
- shouldValidate: true,
- },
- );
- }}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </div>
- <div className="grid grid-cols-12 gap-4">
- {!isC2S && (
- <FormField
- control={form.control}
- name={`${fieldName}.${index}.endpointHost`}
- render={({ field: endpointHostField }) => (
- <FormItem className="col-span-12 md:col-span-6">
- <FormLabel>
- {t("tunnels.endpointSshConfig")}
- </FormLabel>
- <FormControl>
- <Select
- value={endpointHostField.value || ""}
- onValueChange={endpointHostField.onChange}
- >
- <SelectTrigger>
- <SelectValue
- placeholder={t("placeholders.sshConfig")}
- />
- </SelectTrigger>
- <SelectContent>
- {endpointConfigOptions.map((config) => (
- <SelectItem key={config} value={config}>
- {config}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- </FormControl>
- </FormItem>
- )}
- />
- )}
- {mode !== "dynamic" && (
- <FormField
- control={form.control}
- name={`${fieldName}.${index}.endpointPort`}
- render={({ field: endpointPortField }) => (
- <FormItem className="col-span-12 md:col-span-6">
- <FormLabel>{endpointPortLabel}</FormLabel>
- <FormControl>
- <Input
- placeholder={t(
- "placeholders.defaultEndpointPort",
- )}
- {...endpointPortField}
- />
- </FormControl>
- </FormItem>
- )}
- />
- )}
- {mode === "dynamic" && (
- <div className="hidden md:block md:col-span-6" />
- )}
- {!isC2S && (
- <FormField
- control={form.control}
- name={
- mode === "remote"
- ? `${fieldName}.${index}.targetHost`
- : `${fieldName}.${index}.bindHost`
- }
- render={({ field: currentHostIpField }) => (
- <FormItem className="col-span-12 md:col-span-6">
- <FormLabel>{t("tunnels.currentHostIp")}</FormLabel>
- <FormControl>
- <Input
- placeholder={t("placeholders.bindLocalhost")}
- {...currentHostIpField}
- />
- </FormControl>
- </FormItem>
- )}
- />
- )}
- <FormField
- control={form.control}
- name={`${fieldName}.${index}.sourcePort`}
- render={({ field: sourcePortField }) => (
- <FormItem className="col-span-12 md:col-span-6">
- <FormLabel>{sourcePortLabel}</FormLabel>
- <FormControl>
- <Input
- placeholder={t("placeholders.defaultPort")}
- {...sourcePortField}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </div>
-
- <p className="text-sm text-muted-foreground mt-2">
- {modeDescription}
- </p>
-
- <div className="grid grid-cols-12 gap-4 mt-4">
- <FormField
- control={form.control}
- name={`${fieldName}.${index}.maxRetries`}
- render={({ field: maxRetriesField }) => (
- <FormItem className="col-span-12 md:col-span-6">
- <FormLabel>{t("tunnels.maxRetries")}</FormLabel>
- <FormControl>
- <Input
- placeholder={t("placeholders.maxRetries")}
- {...maxRetriesField}
- />
- </FormControl>
- <FormDescription>
- {t("tunnels.maxRetriesDescription")}
- </FormDescription>
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name={`${fieldName}.${index}.retryInterval`}
- render={({ field: retryIntervalField }) => (
- <FormItem className="col-span-12 md:col-span-6">
- <FormLabel>{t("tunnels.retryInterval")}</FormLabel>
- <FormControl>
- <Input
- placeholder={t("placeholders.retryInterval")}
- {...retryIntervalField}
- />
- </FormControl>
- <FormDescription>
- {t("tunnels.retryIntervalDescription")}
- </FormDescription>
- </FormItem>
- )}
- />
- {!isC2S && (
- <FormField
- control={form.control}
- name={`${fieldName}.${index}.autoStart`}
- render={({ field }) => (
- <FormItem className="col-span-12">
- <FormControl>
- <div className="flex items-center justify-between gap-3 rounded-md border bg-card p-3">
- <FormLabel>
- {t("tunnels.autoStartContainer")}
- </FormLabel>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </div>
- </FormControl>
- <FormDescription>
- {t("tunnels.autoStartContainerDesc")}
- </FormDescription>
- </FormItem>
- )}
- />
- )}
- </div>
- </div>
- );
- };
-
- return (
- <div className="mt-4 space-y-6">
- <FormField
- control={form.control}
- name="serverTunnels"
- render={({ field }) => {
- const serverTunnels = field.value || [];
-
- return (
- <FormItem>
- <div className="flex flex-wrap items-center justify-between gap-3">
- <div>
- <FormLabel className="text-sm">
- {t("tunnels.serverTunnels")}
- </FormLabel>
- <p className="text-xs text-muted-foreground">
- {t("tunnels.serverTunnelsDesc")}
- </p>
- </div>
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={() => addServerTunnel(serverTunnels)}
- >
- {t("tunnels.addServerTunnel")}
- </Button>
- </div>
- <FormControl>
- <div>
- {serverTunnels.length > 0 ? (
- <div className="space-y-4">
- {serverTunnels.map((_, index) =>
- renderTunnelCard(
- "serverTunnels",
- index,
- index,
- serverTunnels,
- ),
- )}
- </div>
- ) : (
- <p className="text-sm text-muted-foreground rounded-md border border-dashed p-3">
- {t("tunnels.noServerTunnels")}
- </p>
- )}
- </div>
- </FormControl>
- </FormItem>
- );
- }}
- />
- </div>
- );
- })()}
- </>
- )}
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/tabs/shared/JumpHostItem.tsx b/src/ui/desktop/apps/host-manager/hosts/tabs/shared/JumpHostItem.tsx
deleted file mode 100644
index c677bfbea..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/tabs/shared/JumpHostItem.tsx
+++ /dev/null
@@ -1,104 +0,0 @@
-import React from "react";
-import { cn } from "@/lib/utils.ts";
-import { Button } from "@/components/ui/button.tsx";
-import {
- Popover,
- PopoverContent,
- PopoverTrigger,
-} from "@/components/ui/popover.tsx";
-import {
- Command,
- CommandEmpty,
- CommandGroup,
- CommandInput,
- CommandItem,
-} from "@/components/ui/command.tsx";
-import { Check, ChevronsUpDown, X } from "lucide-react";
-import type { JumpHostItemProps } from "./tab-types";
-
-export function JumpHostItem({
- jumpHost,
- index,
- hosts,
- editingHost,
- onUpdate,
- onRemove,
- t,
-}: JumpHostItemProps) {
- const [open, setOpen] = React.useState(false);
- const selectedHost = hosts.find((h) => h.id === jumpHost.hostId);
-
- return (
- <div className="flex items-center gap-2 p-3 border rounded-lg bg-muted/30">
- <div className="flex items-center gap-2 flex-1">
- <span className="text-sm font-medium text-muted-foreground">
- {index + 1}.
- </span>
- <Popover open={open} onOpenChange={setOpen}>
- <PopoverTrigger asChild className="flex-1">
- <Button
- variant="outline"
- role="combobox"
- aria-expanded={open}
- className="w-full justify-between"
- >
- {selectedHost
- ? `${selectedHost.name || `${selectedHost.username}@${selectedHost.ip}`}`
- : t("hosts.selectServer")}
- <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
- </Button>
- </PopoverTrigger>
- <PopoverContent
- className="p-0"
- style={{ width: "var(--radix-popover-trigger-width)" }}
- >
- <Command>
- <CommandInput placeholder={t("hosts.searchServers")} />
- <CommandEmpty>{t("hosts.noServerFound")}</CommandEmpty>
- <CommandGroup className="max-h-[300px] overflow-y-auto thin-scrollbar">
- {hosts
- .filter((h) => !editingHost || h.id !== editingHost.id)
- .map((host) => (
- <CommandItem
- key={host.id}
- value={`${host.name} ${host.ip} ${host.username} ${host.id}`}
- onSelect={() => {
- onUpdate(host.id);
- setOpen(false);
- }}
- >
- <Check
- className={cn(
- "mr-2 h-4 w-4",
- jumpHost.hostId === host.id
- ? "opacity-100"
- : "opacity-0",
- )}
- />
- <div className="flex flex-col">
- <span className="font-medium">
- {host.name || `${host.username}@${host.ip}`}
- </span>
- <span className="text-xs text-muted-foreground">
- {host.username}@{host.ip}:{host.port}
- </span>
- </div>
- </CommandItem>
- ))}
- </CommandGroup>
- </Command>
- </PopoverContent>
- </Popover>
- </div>
- <Button
- type="button"
- variant="ghost"
- size="icon"
- onClick={onRemove}
- className="ml-2"
- >
- <X className="h-4 w-4" />
- </Button>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/tabs/shared/QuickActionItem.tsx b/src/ui/desktop/apps/host-manager/hosts/tabs/shared/QuickActionItem.tsx
deleted file mode 100644
index 5d31a4e1a..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/tabs/shared/QuickActionItem.tsx
+++ /dev/null
@@ -1,111 +0,0 @@
-import React from "react";
-import { cn } from "@/lib/utils.ts";
-import { Button } from "@/components/ui/button.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import {
- Popover,
- PopoverContent,
- PopoverTrigger,
-} from "@/components/ui/popover.tsx";
-import {
- Command,
- CommandEmpty,
- CommandGroup,
- CommandInput,
- CommandItem,
-} from "@/components/ui/command.tsx";
-import { Check, ChevronsUpDown, X } from "lucide-react";
-import type { QuickActionItemProps } from "./tab-types";
-
-export function QuickActionItem({
- quickAction,
- index,
- snippets,
- onUpdate,
- onRemove,
- t,
-}: QuickActionItemProps) {
- const [open, setOpen] = React.useState(false);
- const selectedSnippet = snippets.find((s) => s.id === quickAction.snippetId);
-
- return (
- <div className="flex items-center gap-2 p-3 border rounded-lg bg-muted/30">
- <div className="flex flex-col gap-2 flex-1">
- <div className="flex items-center gap-2">
- <span className="text-sm font-medium text-muted-foreground">
- {index + 1}.
- </span>
- <Input
- placeholder={t("hosts.quickActionName")}
- value={quickAction.name}
- onChange={(e) => onUpdate(e.target.value, quickAction.snippetId)}
- onBlur={(e) =>
- onUpdate(e.target.value.trim(), quickAction.snippetId)
- }
- className="flex-1"
- />
- </div>
- <Popover open={open} onOpenChange={setOpen}>
- <PopoverTrigger asChild className="w-full">
- <Button
- variant="outline"
- role="combobox"
- aria-expanded={open}
- className="w-full justify-between"
- >
- {selectedSnippet
- ? selectedSnippet.name
- : t("hosts.selectSnippet")}
- <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
- </Button>
- </PopoverTrigger>
- <PopoverContent
- className="p-0"
- style={{ width: "var(--radix-popover-trigger-width)" }}
- >
- <Command>
- <CommandInput placeholder={t("hosts.searchSnippets")} />
- <CommandEmpty>{t("hosts.noSnippetFound")}</CommandEmpty>
- <CommandGroup className="max-h-[300px] overflow-y-auto thin-scrollbar">
- {snippets.map((snippet) => (
- <CommandItem
- key={snippet.id}
- value={`${snippet.name} ${snippet.content} ${snippet.id}`}
- onSelect={() => {
- onUpdate(quickAction.name, snippet.id);
- setOpen(false);
- }}
- >
- <Check
- className={cn(
- "mr-2 h-4 w-4",
- quickAction.snippetId === snippet.id
- ? "opacity-100"
- : "opacity-0",
- )}
- />
- <div className="flex flex-col">
- <span className="font-medium">{snippet.name}</span>
- <span className="text-xs text-muted-foreground truncate max-w-[350px]">
- {snippet.content}
- </span>
- </div>
- </CommandItem>
- ))}
- </CommandGroup>
- </Command>
- </PopoverContent>
- </Popover>
- </div>
- <Button
- type="button"
- variant="ghost"
- size="icon"
- onClick={onRemove}
- className="ml-2"
- >
- <X className="h-4 w-4" />
- </Button>
- </div>
- );
-}
diff --git a/src/ui/desktop/apps/host-manager/hosts/tabs/shared/tab-types.ts b/src/ui/desktop/apps/host-manager/hosts/tabs/shared/tab-types.ts
deleted file mode 100644
index eb60cdc31..000000000
--- a/src/ui/desktop/apps/host-manager/hosts/tabs/shared/tab-types.ts
+++ /dev/null
@@ -1,97 +0,0 @@
-import type { UseFormReturn } from "react-hook-form";
-import type React from "react";
-import type { SSHHost, Credential } from "@/types";
-
-export interface HostGeneralTabProps {
- form: UseFormReturn<FormData>;
- connectionType: "ssh" | "rdp" | "vnc" | "telnet";
- authTab: "password" | "key" | "credential" | "none";
- setAuthTab: (value: "password" | "key" | "credential" | "none") => void;
- keyInputMethod: "upload" | "paste";
- setKeyInputMethod: (value: "upload" | "paste") => void;
- proxyMode: "single" | "chain";
- setProxyMode: (value: "single" | "chain") => void;
- tagInput: string;
- setTagInput: (value: string) => void;
- folderDropdownOpen: boolean;
- setFolderDropdownOpen: (value: boolean) => void;
- folderInputRef: React.RefObject<HTMLInputElement>;
- folderDropdownRef: React.RefObject<HTMLDivElement>;
- filteredFolders: string[];
- handleFolderClick: (folder: string) => void;
- keyTypeDropdownOpen: boolean;
- setKeyTypeDropdownOpen: (value: boolean) => void;
- keyTypeButtonRef: React.RefObject<HTMLButtonElement>;
- keyTypeDropdownRef: React.RefObject<HTMLDivElement>;
- keyTypeOptions: Array<{ value: string; label: string }>;
- ipInputRef: React.RefObject<HTMLInputElement>;
- editorTheme: unknown;
- hosts: SSHHost[];
- editingHost?: SSHHost | null;
- folders: string[];
- credentials: Credential[];
- t: (key: string) => string;
-}
-
-export interface HostTerminalTabProps {
- form: UseFormReturn<FormData>;
- snippets: Array<{ id: number; name: string; content: string }>;
- t: (key: string, options?: unknown) => string;
-}
-
-export interface HostDockerTabProps {
- form: UseFormReturn<FormData>;
- t: (key: string) => string;
-}
-
-export interface HostTunnelTabProps {
- form: UseFormReturn<FormData>;
- hosts: SSHHost[];
- editingHost?: SSHHost | null;
- t: (key: string) => string;
-}
-
-export interface HostFileManagerTabProps {
- form: UseFormReturn<FormData>;
- t: (key: string) => string;
-}
-
-export interface HostStatisticsTabProps {
- form: UseFormReturn<FormData>;
- statusIntervalUnit: "seconds" | "minutes";
- setStatusIntervalUnit: (value: "seconds" | "minutes") => void;
- metricsIntervalUnit: "seconds" | "minutes";
- setMetricsIntervalUnit: (value: "seconds" | "minutes") => void;
- snippets: Array<{ id: number; name: string; content: string }>;
- t: (key: string) => string;
-}
-
-export interface HostRemoteDesktopTabProps {
- form: UseFormReturn<FormData>;
- connectionType: "rdp" | "vnc" | "telnet";
- t: (key: string) => string;
-}
-
-export interface HostSharingTabProps {
- hostId: number | undefined;
- isNewHost: boolean;
-}
-
-export interface JumpHostItemProps {
- jumpHost: { hostId: number };
- index: number;
- hosts: SSHHost[];
- editingHost?: SSHHost | null;
- onUpdate: (hostId: number) => void;
- onRemove: () => void;
- t: (key: string) => string;
-}
-
-export interface QuickActionItemProps {
- quickAction: { name: string; snippetId: number };
- index: number;
- snippets: Array<{ id: number; name: string; content: string }>;
- onUpdate: (name: string, snippetId: number) => void;
- onRemove: () => void;
- t: (key: string) => string;
-}
diff --git a/src/ui/desktop/apps/tools/SSHToolsSidebar.tsx b/src/ui/desktop/apps/tools/SSHToolsSidebar.tsx
deleted file mode 100644
index f2c30dc52..000000000
--- a/src/ui/desktop/apps/tools/SSHToolsSidebar.tsx
+++ /dev/null
@@ -1,2601 +0,0 @@
-import React, { useState, useEffect } from "react";
-import { Button } from "@/components/ui/button.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Textarea } from "@/components/ui/textarea.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
-import { Checkbox } from "@/components/ui/checkbox.tsx";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import {
- Tabs,
- TabsList,
- TabsTrigger,
- TabsContent,
-} from "@/components/ui/tabs.tsx";
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "@/components/ui/tooltip.tsx";
-import {
- Sidebar,
- SidebarContent,
- SidebarHeader,
- SidebarProvider,
- SidebarGroupLabel,
-} from "@/components/ui/sidebar.tsx";
-import {
- Plus,
- Play,
- Edit,
- Trash2,
- Copy,
- X,
- Search,
- Loader2,
- Terminal,
- LayoutGrid,
- Folder,
- ChevronDown,
- ChevronRight,
- GripVertical,
- FolderPlus,
- Settings,
- Server,
- Cloud,
- Database,
- Box,
- Package,
- Layers,
- Archive,
- HardDrive,
- Globe,
- Share2,
-} from "lucide-react";
-import { toast } from "sonner";
-import { useTranslation } from "react-i18next";
-import { useConfirmation } from "@/hooks/use-confirmation.ts";
-import {
- getSnippets,
- createSnippet,
- updateSnippet,
- deleteSnippet,
- getCookie,
- setCookie,
- getCommandHistory,
- deleteCommandFromHistory,
- getSnippetFolders,
- createSnippetFolder,
- updateSnippetFolderMetadata,
- renameSnippetFolder,
- deleteSnippetFolder,
- reorderSnippets,
- getSharedSnippets,
- shareSnippet,
- getSnippetAccess,
- revokeSnippetAccess,
- getRoles,
- getUserList,
- type AccessRecord,
-} from "@/ui/main-axios.ts";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
-import type { Snippet, SnippetData, SnippetFolder } from "../../../../types";
-
-interface TabData {
- id: number;
- type: string;
- title: string;
- terminalRef?: {
- current?: {
- sendInput?: (data: string) => void;
- };
- };
- hostConfig?: {
- id: number;
- };
- isActive?: boolean;
- [key: string]: unknown;
-}
-
-interface SSHToolsSidebarProps {
- isOpen: boolean;
- onClose: () => void;
- onSnippetExecute: (content: string) => void;
- sidebarWidth: number;
- setSidebarWidth: (width: number) => void;
- initialTab?: string;
- onTabChange?: () => void;
-}
-
-const AVAILABLE_COLORS = [
- { value: "#ef4444", label: "Red" },
- { value: "#f97316", label: "Orange" },
- { value: "#eab308", label: "Yellow" },
- { value: "#22c55e", label: "Green" },
- { value: "#3b82f6", label: "Blue" },
- { value: "#a855f7", label: "Purple" },
- { value: "#ec4899", label: "Pink" },
- { value: "#6b7280", label: "Gray" },
-];
-
-const AVAILABLE_ICONS = [
- { value: "Folder", label: "Folder", Icon: Folder },
- { value: "Server", label: "Server", Icon: Server },
- { value: "Cloud", label: "Cloud", Icon: Cloud },
- { value: "Database", label: "Database", Icon: Database },
- { value: "Box", label: "Box", Icon: Box },
- { value: "Package", label: "Package", Icon: Package },
- { value: "Layers", label: "Layers", Icon: Layers },
- { value: "Archive", label: "Archive", Icon: Archive },
- { value: "HardDrive", label: "HardDrive", Icon: HardDrive },
- { value: "Globe", label: "Globe", Icon: Globe },
-];
-
-export function SSHToolsSidebar({
- isOpen,
- onClose,
- onSnippetExecute,
- sidebarWidth,
- setSidebarWidth,
- initialTab,
- onTabChange,
-}: SSHToolsSidebarProps) {
- const { t } = useTranslation();
- const { confirmWithToast } = useConfirmation();
- const {
- tabs,
- currentTab,
- allSplitScreenTab,
- setSplitScreenTab,
- setCurrentTab,
- } = useTabs() as {
- tabs: TabData[];
- currentTab: number | null;
- allSplitScreenTab: number[];
- setSplitScreenTab: (tabId: number) => void;
- setCurrentTab: (tabId: number) => void;
- };
- const [activeTab, setActiveTab] = useState(initialTab || "ssh-tools");
-
- useEffect(() => {
- if (initialTab && isOpen) {
- setActiveTab(initialTab);
- }
- }, [initialTab, isOpen]);
-
- const handleTabChange = (tab: string) => {
- setActiveTab(tab);
- if (onTabChange) {
- onTabChange();
- }
- };
-
- const [isRecording, setIsRecording] = useState(false);
- const [selectedTabIds, setSelectedTabIds] = useState<number[]>([]);
- const [rightClickCopyPaste, setRightClickCopyPaste] = useState<boolean>(
- () => getCookie("rightClickCopyPaste") !== "false",
- );
-
- const [snippets, setSnippets] = useState<Snippet[]>([]);
- const [snippetFolders, setSnippetFolders] = useState<SnippetFolder[]>([]);
- const [sharedSnippetsList, setSharedSnippetsList] = useState<
- Array<{
- id: number;
- name: string;
- content: string;
- description: string | null;
- folder: string | null;
- ownerUsername: string;
- }>
- >([]);
- const [shareDialogSnippet, setShareDialogSnippet] = useState<Snippet | null>(
- null,
- );
- const [shareTargetType, setShareTargetType] = useState<"user" | "role">(
- "user",
- );
- const [shareUsers, setShareUsers] = useState<
- Array<{ id: string; username: string }>
- >([]);
- const [shareRoles, setShareRoles] = useState<
- Array<{ id: number; name: string; displayName?: string }>
- >([]);
- const [shareTargetId, setShareTargetId] = useState("");
- const [shareAccessList, setShareAccessList] = useState<AccessRecord[]>([]);
- const [loading, setLoading] = useState(true);
- const [showDialog, setShowDialog] = useState(false);
- const [editingSnippet, setEditingSnippet] = useState<Snippet | null>(null);
- const [formData, setFormData] = useState<SnippetData>({
- name: "",
- content: "",
- description: "",
- });
- const [formErrors, setFormErrors] = useState({
- name: false,
- content: false,
- });
- const [selectedSnippetTabIds, setSelectedSnippetTabIds] = useState<number[]>(
- [],
- );
- const [draggedSnippet, setDraggedSnippet] = useState<Snippet | null>(null);
- const [collapsedFolders, setCollapsedFolders] = useState<Set<string>>(() => {
- const shouldCollapse =
- localStorage.getItem("defaultSnippetFoldersCollapsed") !== "false";
- return shouldCollapse ? new Set() : new Set();
- });
- const [snippetSearchQuery, setSnippetSearchQuery] = useState("");
- const [showFolderDialog, setShowFolderDialog] = useState(false);
- const [editingFolder, setEditingFolder] = useState<SnippetFolder | null>(
- null,
- );
- const [folderFormData, setFolderFormData] = useState({
- name: "",
- color: "",
- icon: "",
- });
- const [folderFormErrors, setFolderFormErrors] = useState({
- name: false,
- });
-
- const [commandHistory, setCommandHistory] = useState<string[]>([]);
- const [isHistoryLoading, setIsHistoryLoading] = useState(false);
- const [historyError, setHistoryError] = useState<string | null>(null);
- const [searchQuery, setSearchQuery] = useState("");
- const [historyRefreshCounter, setHistoryRefreshCounter] = useState(0);
- const commandHistoryScrollRef = React.useRef<HTMLDivElement>(null);
- const [commandHistoryEnabled, setCommandHistoryEnabled] = useState<boolean>(
- () => localStorage.getItem("commandHistoryTracking") === "true",
- );
-
- const [splitMode, setSplitMode] = useState<
- "none" | "2" | "3" | "4" | "5" | "6"
- >("none");
- const [splitAssignments, setSplitAssignments] = useState<Map<number, number>>(
- new Map(),
- );
- const [, setPreviewKey] = useState(0);
- const [draggedTabId, setDraggedTabId] = useState<number | null>(null);
- const [dragOverCellIndex, setDragOverCellIndex] = useState<number | null>(
- null,
- );
-
- const [isResizing, setIsResizing] = useState(false);
- const startXRef = React.useRef<number | null>(null);
- const startWidthRef = React.useRef<number>(sidebarWidth);
-
- const terminalTabs = tabs.filter((tab: TabData) => tab.type === "terminal");
-
- useEffect(() => {
- const terminalIds = new Set(terminalTabs.map((t) => t.id));
- setSelectedSnippetTabIds((prev) =>
- prev.filter((id) => terminalIds.has(id)),
- );
- }, [terminalTabs.length]);
-
- const activeUiTab = tabs.find((tab) => tab.id === currentTab);
- const activeTerminal =
- activeUiTab?.type === "terminal" ? activeUiTab : undefined;
- const activeTerminalHostId = activeTerminal?.hostConfig?.id;
-
- const splittableTabs = tabs.filter(
- (tab: TabData) =>
- tab.type === "terminal" ||
- tab.type === "server_stats" ||
- tab.type === "file_manager" ||
- tab.type === "tunnel" ||
- tab.type === "docker" ||
- tab.type === "rdp" ||
- tab.type === "vnc" ||
- tab.type === "telnet",
- );
-
- useEffect(() => {
- let cancelled = false;
-
- if (isOpen && activeTab === "command-history") {
- if (activeTerminalHostId) {
- const scrollTop = commandHistoryScrollRef.current?.scrollTop || 0;
- setIsHistoryLoading(true);
- setHistoryError(null);
-
- getCommandHistory(activeTerminalHostId)
- .then((history) => {
- if (cancelled) return;
-
- setCommandHistory((prevHistory) => {
- const newHistory = Array.isArray(history) ? history : [];
- if (JSON.stringify(prevHistory) !== JSON.stringify(newHistory)) {
- requestAnimationFrame(() => {
- if (commandHistoryScrollRef.current) {
- commandHistoryScrollRef.current.scrollTop = scrollTop;
- }
- });
- return newHistory;
- }
- return prevHistory;
- });
- setIsHistoryLoading(false);
- })
- .catch((err) => {
- if (cancelled) return;
-
- console.error("Failed to fetch command history", err);
- const errorMessage =
- err?.response?.status === 401
- ? t("commandHistory.authRequiredRefresh")
- : err?.response?.status === 403
- ? t("commandHistory.dataAccessLockedReauth")
- : err?.message || "Failed to load command history";
-
- setHistoryError(errorMessage);
- setCommandHistory([]);
- setIsHistoryLoading(false);
- });
- } else {
- setCommandHistory([]);
- setHistoryError(null);
- setIsHistoryLoading(false);
- }
- }
-
- return () => {
- cancelled = true;
- };
- }, [
- isOpen,
- activeTab,
- activeTerminalHostId,
- currentTab,
- historyRefreshCounter,
- ]);
-
- useEffect(() => {
- if (isOpen && activeTab === "command-history" && activeTerminalHostId) {
- const refreshInterval = setInterval(() => {
- setHistoryRefreshCounter((prev) => prev + 1);
- }, 2000);
-
- return () => clearInterval(refreshInterval);
- }
- }, [isOpen, activeTab, activeTerminalHostId]);
-
- useEffect(() => {
- const handleChange = () => {
- setCommandHistoryEnabled(
- localStorage.getItem("commandHistoryTracking") === "true",
- );
- };
- window.addEventListener("commandHistoryTrackingChanged", handleChange);
- return () =>
- window.removeEventListener("commandHistoryTrackingChanged", handleChange);
- }, []);
-
- const filteredCommands = searchQuery
- ? commandHistory.filter((cmd) =>
- cmd.toLowerCase().includes(searchQuery.toLowerCase()),
- )
- : commandHistory;
-
- useEffect(() => {
- document.documentElement.style.setProperty(
- "--right-sidebar-width",
- `${sidebarWidth}px`,
- );
- }, [sidebarWidth]);
-
- useEffect(() => {
- const handleResize = () => {
- const minWidth = Math.min(300, Math.floor(window.innerWidth * 0.2));
- const maxWidth = Math.floor(window.innerWidth * 0.3);
- if (sidebarWidth > maxWidth) {
- setSidebarWidth(Math.max(minWidth, maxWidth));
- } else if (sidebarWidth < minWidth) {
- setSidebarWidth(minWidth);
- }
- };
- window.addEventListener("resize", handleResize);
- return () => window.removeEventListener("resize", handleResize);
- }, [sidebarWidth, setSidebarWidth]);
-
- useEffect(() => {
- if (isOpen && activeTab === "snippets") {
- fetchSnippets();
- }
- }, [isOpen, activeTab]);
-
- useEffect(() => {
- if (snippetFolders.length > 0) {
- const shouldCollapse =
- localStorage.getItem("defaultSnippetFoldersCollapsed") !== "false";
- if (shouldCollapse) {
- const allFolderNames = new Set(snippetFolders.map((f) => f.name));
- const uncategorizedSnippets = snippets.filter(
- (s) => !s.folder || s.folder === "",
- );
- if (uncategorizedSnippets.length > 0) {
- allFolderNames.add("");
- }
- setCollapsedFolders(allFolderNames);
- } else {
- setCollapsedFolders(new Set());
- }
- }
- }, [snippetFolders, snippets]);
-
- useEffect(() => {
- const handleSettingChange = () => {
- const shouldCollapse =
- localStorage.getItem("defaultSnippetFoldersCollapsed") !== "false";
- if (shouldCollapse) {
- const allFolderNames = new Set(snippetFolders.map((f) => f.name));
- const uncategorizedSnippets = snippets.filter(
- (s) => !s.folder || s.folder === "",
- );
- if (uncategorizedSnippets.length > 0) {
- allFolderNames.add("");
- }
- setCollapsedFolders(allFolderNames);
- } else {
- setCollapsedFolders(new Set());
- }
- };
-
- window.addEventListener(
- "defaultSnippetFoldersCollapsedChanged",
- handleSettingChange,
- );
- return () => {
- window.removeEventListener(
- "defaultSnippetFoldersCollapsedChanged",
- handleSettingChange,
- );
- };
- }, [snippetFolders, snippets]);
-
- const handleMouseDown = (e: React.MouseEvent) => {
- e.preventDefault();
- setIsResizing(true);
- startXRef.current = e.clientX;
- startWidthRef.current = sidebarWidth;
- };
-
- React.useEffect(() => {
- if (!isResizing) return;
-
- const handleMouseMove = (e: MouseEvent) => {
- if (startXRef.current == null) return;
- const dx = startXRef.current - e.clientX;
- const newWidth = Math.round(startWidthRef.current + dx);
- const minWidth = Math.min(300, Math.floor(window.innerWidth * 0.2));
- const maxWidth = Math.round(window.innerWidth * 0.3);
-
- let finalWidth = newWidth;
- if (newWidth < minWidth) {
- finalWidth = minWidth;
- } else if (newWidth > maxWidth) {
- finalWidth = maxWidth;
- }
-
- document.documentElement.style.setProperty(
- "--right-sidebar-width",
- `${finalWidth}px`,
- );
-
- setSidebarWidth(finalWidth);
- };
-
- const handleMouseUp = () => {
- setIsResizing(false);
- startXRef.current = null;
- };
-
- document.addEventListener("mousemove", handleMouseMove);
- document.addEventListener("mouseup", handleMouseUp);
- document.body.style.cursor = "col-resize";
- document.body.style.userSelect = "none";
-
- return () => {
- document.removeEventListener("mousemove", handleMouseMove);
- document.removeEventListener("mouseup", handleMouseUp);
- document.body.style.cursor = "";
- document.body.style.userSelect = "";
- };
- }, [isResizing]);
-
- const handleTabToggle = (tabId: number) => {
- setSelectedTabIds((prev) =>
- prev.includes(tabId)
- ? prev.filter((id) => id !== tabId)
- : [...prev, tabId],
- );
- };
-
- const handleStartRecording = () => {
- setIsRecording(true);
- setTimeout(() => {
- const input = document.getElementById(
- "ssh-tools-input",
- ) as HTMLInputElement;
- if (input) input.focus();
- }, 100);
- };
-
- const handleStopRecording = () => {
- setIsRecording(false);
- setSelectedTabIds([]);
- };
-
- const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
- if (selectedTabIds.length === 0) return;
-
- let commandToSend = "";
-
- if (e.ctrlKey || e.metaKey) {
- if (e.key === "c") {
- commandToSend = "\x03";
- e.preventDefault();
- } else if (e.key === "d") {
- commandToSend = "\x04";
- e.preventDefault();
- } else if (e.key === "l") {
- commandToSend = "\x0c";
- e.preventDefault();
- } else if (e.key === "u") {
- commandToSend = "\x15";
- e.preventDefault();
- } else if (e.key === "k") {
- commandToSend = "\x0b";
- e.preventDefault();
- } else if (e.key === "a") {
- commandToSend = "\x01";
- e.preventDefault();
- } else if (e.key === "e") {
- commandToSend = "\x05";
- e.preventDefault();
- } else if (e.key === "w") {
- commandToSend = "\x17";
- e.preventDefault();
- }
- } else if (e.key === "Enter") {
- commandToSend = "\n";
- e.preventDefault();
- } else if (e.key === "Backspace") {
- commandToSend = "\x08";
- e.preventDefault();
- } else if (e.key === "Delete") {
- commandToSend = "\x7f";
- e.preventDefault();
- } else if (e.key === "Tab") {
- commandToSend = "\x09";
- e.preventDefault();
- } else if (e.key === "Escape") {
- commandToSend = "\x1b";
- e.preventDefault();
- } else if (e.key === "ArrowUp") {
- commandToSend = "\x1b[A";
- e.preventDefault();
- } else if (e.key === "ArrowDown") {
- commandToSend = "\x1b[B";
- e.preventDefault();
- } else if (e.key === "ArrowLeft") {
- commandToSend = "\x1b[D";
- e.preventDefault();
- } else if (e.key === "ArrowRight") {
- commandToSend = "\x1b[C";
- e.preventDefault();
- } else if (e.key === "Home") {
- commandToSend = "\x1b[H";
- e.preventDefault();
- } else if (e.key === "End") {
- commandToSend = "\x1b[F";
- e.preventDefault();
- } else if (e.key === "PageUp") {
- commandToSend = "\x1b[5~";
- e.preventDefault();
- } else if (e.key === "PageDown") {
- commandToSend = "\x1b[6~";
- e.preventDefault();
- } else if (e.key === "Insert") {
- commandToSend = "\x1b[2~";
- e.preventDefault();
- } else if (e.key === "F1") {
- commandToSend = "\x1bOP";
- e.preventDefault();
- } else if (e.key === "F2") {
- commandToSend = "\x1bOQ";
- e.preventDefault();
- } else if (e.key === "F3") {
- commandToSend = "\x1bOR";
- e.preventDefault();
- } else if (e.key === "F4") {
- commandToSend = "\x1bOS";
- e.preventDefault();
- } else if (e.key === "F5") {
- commandToSend = "\x1b[15~";
- e.preventDefault();
- } else if (e.key === "F6") {
- commandToSend = "\x1b[17~";
- e.preventDefault();
- } else if (e.key === "F7") {
- commandToSend = "\x1b[18~";
- e.preventDefault();
- } else if (e.key === "F8") {
- commandToSend = "\x1b[19~";
- e.preventDefault();
- } else if (e.key === "F9") {
- commandToSend = "\x1b[20~";
- e.preventDefault();
- } else if (e.key === "F10") {
- commandToSend = "\x1b[21~";
- e.preventDefault();
- } else if (e.key === "F11") {
- commandToSend = "\x1b[23~";
- e.preventDefault();
- } else if (e.key === "F12") {
- commandToSend = "\x1b[24~";
- e.preventDefault();
- }
-
- if (commandToSend) {
- selectedTabIds.forEach((tabId) => {
- const tab = tabs.find((t: TabData) => t.id === tabId);
- if (tab?.terminalRef?.current?.sendInput) {
- tab.terminalRef.current.sendInput(commandToSend);
- }
- });
- }
- };
-
- const handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {
- if (selectedTabIds.length === 0) return;
-
- if (e.key.length === 1 && !e.ctrlKey && !e.metaKey) {
- const char = e.key;
- selectedTabIds.forEach((tabId) => {
- const tab = tabs.find((t: TabData) => t.id === tabId);
- if (tab?.terminalRef?.current?.sendInput) {
- tab.terminalRef.current.sendInput(char);
- }
- });
- }
- };
-
- const updateRightClickCopyPaste = (checked: boolean) => {
- setCookie("rightClickCopyPaste", checked.toString());
- setRightClickCopyPaste(checked);
- };
-
- const fetchSnippets = async () => {
- try {
- setLoading(true);
- const [snippetsData, foldersData, sharedData] = await Promise.all([
- getSnippets(),
- getSnippetFolders(),
- getSharedSnippets().catch(() => ({ sharedSnippets: [] })),
- ]);
- setSnippets(Array.isArray(snippetsData) ? snippetsData : []);
- setSnippetFolders(Array.isArray(foldersData) ? foldersData : []);
- setSharedSnippetsList(sharedData.sharedSnippets || []);
- } catch {
- toast.error(t("snippets.failedToFetch"));
- setSnippets([]);
- setSnippetFolders([]);
- setSharedSnippetsList([]);
- } finally {
- setLoading(false);
- }
- };
-
- const handleCreate = () => {
- setEditingSnippet(null);
- setFormData({ name: "", content: "", description: "" });
- setFormErrors({ name: false, content: false });
- setShowDialog(true);
- };
-
- const handleEdit = (snippet: Snippet) => {
- setEditingSnippet(snippet);
- setFormData({
- name: snippet.name,
- content: snippet.content,
- description: snippet.description || "",
- folder: snippet.folder,
- });
- setFormErrors({ name: false, content: false });
- setShowDialog(true);
- };
-
- const handleDelete = (snippet: Snippet) => {
- confirmWithToast(
- t("snippets.deleteConfirmDescription", { name: snippet.name }),
- async () => {
- try {
- await deleteSnippet(snippet.id);
- toast.success(t("snippets.deleteSuccess"));
- fetchSnippets();
- } catch {
- toast.error(t("snippets.deleteFailed"));
- }
- },
- "destructive",
- );
- };
-
- const handleOpenShareDialog = async (snippet: Snippet) => {
- setShareDialogSnippet(snippet);
- setShareTargetId("");
- setShareTargetType("user");
- try {
- const [usersData, rolesData, accessData] = await Promise.all([
- getUserList(),
- getRoles(),
- getSnippetAccess(snippet.id),
- ]);
- setShareUsers(
- (usersData?.users || []).map((u: Record<string, unknown>) => ({
- id: u.id as string,
- username: u.username as string,
- })),
- );
- setShareRoles(
- (rolesData?.roles || []).map(
- (r: { id: number; name: string; displayName?: string }) => r,
- ),
- );
- setShareAccessList(accessData.accessList || []);
- } catch {
- toast.error(t("snippets.failedToLoadShareData"));
- }
- };
-
- const handleShare = async () => {
- if (!shareDialogSnippet || !shareTargetId) return;
- try {
- await shareSnippet(shareDialogSnippet.id, {
- targetType: shareTargetType,
- targetUserId: shareTargetType === "user" ? shareTargetId : undefined,
- targetRoleId:
- shareTargetType === "role" ? parseInt(shareTargetId) : undefined,
- });
- toast.success(t("snippets.shareSuccess"));
- const accessData = await getSnippetAccess(shareDialogSnippet.id);
- setShareAccessList(accessData.accessList || []);
- setShareTargetId("");
- } catch {
- toast.error(t("snippets.shareFailed"));
- }
- };
-
- const handleRevokeSnippetAccess = async (accessId: number) => {
- if (!shareDialogSnippet) return;
- try {
- await revokeSnippetAccess(shareDialogSnippet.id, accessId);
- toast.success(t("snippets.revokeSuccess"));
- const accessData = await getSnippetAccess(shareDialogSnippet.id);
- setShareAccessList(accessData.accessList || []);
- } catch {
- toast.error(t("snippets.revokeFailed"));
- }
- };
-
- const handleSubmit = async () => {
- const errors = {
- name: !formData.name.trim(),
- content: !formData.content.trim(),
- };
-
- setFormErrors(errors);
-
- if (errors.name || errors.content) {
- return;
- }
-
- try {
- if (editingSnippet) {
- await updateSnippet(editingSnippet.id, formData);
- toast.success(t("snippets.updateSuccess"));
- } else {
- await createSnippet(formData);
- toast.success(t("snippets.createSuccess"));
- }
- setShowDialog(false);
- fetchSnippets();
- } catch {
- toast.error(
- editingSnippet
- ? t("snippets.updateFailed")
- : t("snippets.createFailed"),
- );
- }
- };
-
- const handleSnippetTabToggle = (tabId: number) => {
- setSelectedSnippetTabIds((prev) =>
- prev.includes(tabId)
- ? prev.filter((id) => id !== tabId)
- : [...prev, tabId],
- );
- };
-
- const handleExecute = async (snippet: Snippet) => {
- const confirmEnabled =
- localStorage.getItem("confirmSnippetExecution") === "true";
-
- if (confirmEnabled) {
- const confirmed = await confirmWithToast(
- t("snippets.confirmExecution", { name: snippet.name }),
- undefined,
- "default",
- t("common.cancel"),
- { confirmOnEnter: true, duration: 8000 },
- );
-
- if (!confirmed) {
- return;
- }
- }
-
- if (selectedSnippetTabIds.length > 0) {
- selectedSnippetTabIds.forEach((tabId) => {
- const tab = tabs.find((t: TabData) => t.id === tabId);
- if (tab?.terminalRef?.current?.sendInput) {
- tab.terminalRef.current.sendInput(snippet.content + "\r");
- }
- });
- toast.success(
- t("snippets.executeSuccess", {
- name: snippet.name,
- count: selectedSnippetTabIds.length,
- }),
- );
- } else {
- onSnippetExecute(snippet.content);
- toast.success(t("snippets.executeSuccess", { name: snippet.name }));
- }
-
- if (document.activeElement instanceof HTMLElement) {
- document.activeElement.blur();
- }
- };
-
- const handleCopy = (snippet: Snippet) => {
- navigator.clipboard.writeText(snippet.content);
- toast.success(t("snippets.copySuccess", { name: snippet.name }));
- };
-
- const toggleFolder = (folderName: string) => {
- setCollapsedFolders((prev) => {
- const next = new Set(prev);
- if (next.has(folderName)) {
- next.delete(folderName);
- } else {
- next.add(folderName);
- }
- return next;
- });
- };
-
- const getFolderIcon = (folderName: string) => {
- const metadata = snippetFolders.find((f) => f.name === folderName);
- if (!metadata?.icon) return Folder;
-
- const iconData = AVAILABLE_ICONS.find((i) => i.value === metadata.icon);
- return iconData?.Icon || Folder;
- };
-
- const getFolderColor = (folderName: string) => {
- const metadata = snippetFolders.find((f) => f.name === folderName);
- return metadata?.color;
- };
-
- const groupSnippetsByFolder = () => {
- const grouped = new Map<string, Snippet[]>();
-
- snippetFolders.forEach((folder) => {
- if (!grouped.has(folder.name)) {
- grouped.set(folder.name, []);
- }
- });
-
- const filteredSnippets = snippetSearchQuery
- ? snippets.filter(
- (snippet) =>
- snippet.name
- .toLowerCase()
- .includes(snippetSearchQuery.toLowerCase()) ||
- snippet.content
- .toLowerCase()
- .includes(snippetSearchQuery.toLowerCase()) ||
- snippet.description
- ?.toLowerCase()
- .includes(snippetSearchQuery.toLowerCase()),
- )
- : snippets;
-
- filteredSnippets.forEach((snippet) => {
- const folderName = snippet.folder || "";
- if (!grouped.has(folderName)) {
- grouped.set(folderName, []);
- }
- grouped.get(folderName)!.push(snippet);
- });
-
- return grouped;
- };
-
- const handleDragStart = (e: React.DragEvent, snippet: Snippet) => {
- setDraggedSnippet(snippet);
- e.dataTransfer.effectAllowed = "move";
- };
-
- const handleDragOver = (e: React.DragEvent) => {
- e.preventDefault();
- e.dataTransfer.dropEffect = "move";
- };
-
- const handleDrop = async (e: React.DragEvent, targetSnippet: Snippet) => {
- e.preventDefault();
-
- if (!draggedSnippet || draggedSnippet.id === targetSnippet.id) {
- setDraggedSnippet(null);
- return;
- }
-
- const sourceFolder = draggedSnippet.folder || "";
- const targetFolder = targetSnippet.folder || "";
-
- if (sourceFolder !== targetFolder) {
- toast.error(t("snippets.reorderSameFolder"));
- setDraggedSnippet(null);
- return;
- }
-
- const folderSnippets = snippets.filter(
- (s) => (s.folder || "") === targetFolder,
- );
-
- const draggedIndex = folderSnippets.findIndex(
- (s) => s.id === draggedSnippet.id,
- );
- const targetIndex = folderSnippets.findIndex(
- (s) => s.id === targetSnippet.id,
- );
-
- if (draggedIndex === -1 || targetIndex === -1) {
- setDraggedSnippet(null);
- return;
- }
-
- const reorderedSnippets = [...folderSnippets];
- reorderedSnippets.splice(draggedIndex, 1);
- reorderedSnippets.splice(targetIndex, 0, draggedSnippet);
-
- const updates = reorderedSnippets.map((snippet, index) => ({
- id: snippet.id,
- order: index,
- folder: targetFolder || undefined,
- }));
-
- try {
- await reorderSnippets(updates);
- toast.success(t("snippets.reorderSuccess"));
- fetchSnippets();
- } catch {
- toast.error(t("snippets.reorderFailed"));
- }
-
- setDraggedSnippet(null);
- };
-
- const handleDragEnd = () => {
- setDraggedSnippet(null);
- };
-
- const handleCreateFolder = () => {
- setEditingFolder(null);
- setFolderFormData({
- name: "",
- color: AVAILABLE_COLORS[0].value,
- icon: AVAILABLE_ICONS[0].value,
- });
- setFolderFormErrors({ name: false });
- setShowFolderDialog(true);
- };
-
- const handleEditFolder = (folder: SnippetFolder) => {
- setEditingFolder(folder);
- setFolderFormData({
- name: folder.name,
- color: folder.color || AVAILABLE_COLORS[0].value,
- icon: folder.icon || AVAILABLE_ICONS[0].value,
- });
- setFolderFormErrors({ name: false });
- setShowFolderDialog(true);
- };
-
- const handleDeleteFolder = (folderName: string) => {
- confirmWithToast(
- t("snippets.deleteFolderConfirm", {
- name: folderName,
- }),
- async () => {
- try {
- await deleteSnippetFolder(folderName);
- toast.success(t("snippets.deleteFolderSuccess"));
- fetchSnippets();
- } catch {
- toast.error(t("snippets.deleteFolderFailed"));
- }
- },
- "destructive",
- );
- };
-
- const handleFolderSubmit = async () => {
- const errors = {
- name: !folderFormData.name.trim(),
- };
-
- setFolderFormErrors(errors);
-
- if (errors.name) {
- return;
- }
-
- try {
- if (editingFolder) {
- if (editingFolder.name !== folderFormData.name) {
- await renameSnippetFolder(editingFolder.name, folderFormData.name);
- }
- await updateSnippetFolderMetadata(folderFormData.name, {
- color: folderFormData.color || undefined,
- icon: folderFormData.icon || undefined,
- });
- toast.success(t("snippets.updateFolderSuccess"));
- } else {
- await createSnippetFolder({
- name: folderFormData.name,
- color: folderFormData.color || undefined,
- icon: folderFormData.icon || undefined,
- });
- toast.success(t("snippets.createFolderSuccess"));
- }
-
- setShowFolderDialog(false);
- fetchSnippets();
- } catch {
- toast.error(
- editingFolder
- ? t("snippets.updateFolderFailed")
- : t("snippets.createFolderFailed"),
- );
- }
- };
-
- const handleSplitModeChange = (
- mode: "none" | "2" | "3" | "4" | "5" | "6",
- ) => {
- setSplitMode(mode);
-
- if (mode === "none") {
- handleClearSplit();
- } else {
- setSplitAssignments(new Map());
- setPreviewKey((prev) => prev + 1);
- }
- };
-
- const handleTabDragStart = (tabId: number) => {
- setDraggedTabId(tabId);
- };
-
- const handleTabDragEnd = () => {
- setDraggedTabId(null);
- setDragOverCellIndex(null);
- };
-
- const handleTabDragOver = (e: React.DragEvent, cellIndex: number) => {
- e.preventDefault();
- setDragOverCellIndex(cellIndex);
- };
-
- const handleTabDragLeave = () => {
- setDragOverCellIndex(null);
- };
-
- const handleTabDrop = (cellIndex: number) => {
- if (draggedTabId === null) return;
-
- setSplitAssignments((prev) => {
- const newMap = new Map(prev);
- Array.from(newMap.entries()).forEach(([idx, id]) => {
- if (id === draggedTabId && idx !== cellIndex) {
- newMap.delete(idx);
- }
- });
- newMap.set(cellIndex, draggedTabId);
- return newMap;
- });
-
- setDraggedTabId(null);
- setDragOverCellIndex(null);
- setPreviewKey((prev) => prev + 1);
- };
-
- const handleRemoveFromCell = (cellIndex: number) => {
- setSplitAssignments((prev) => {
- const newMap = new Map(prev);
- newMap.delete(cellIndex);
- setPreviewKey((prev) => prev + 1);
- return newMap;
- });
- };
-
- const handleApplySplit = () => {
- if (splitMode === "none") {
- handleClearSplit();
- return;
- }
-
- if (splitAssignments.size === 0) {
- toast.error(t("splitScreen.error.noAssignments"));
- return;
- }
-
- const requiredSlots = parseInt(splitMode);
-
- if (splitAssignments.size < requiredSlots) {
- toast.error(
- t("splitScreen.error.fillAllSlots", {
- count: requiredSlots,
- }),
- );
- return;
- }
-
- const orderedTabIds: number[] = [];
- for (let i = 0; i < requiredSlots; i++) {
- const tabId = splitAssignments.get(i);
- if (tabId !== undefined) {
- orderedTabIds.push(tabId);
- }
- }
-
- const currentSplits = [...allSplitScreenTab];
- currentSplits.forEach((tabId) => {
- setSplitScreenTab(tabId);
- });
-
- orderedTabIds.forEach((tabId) => {
- setSplitScreenTab(tabId);
- });
-
- if (!orderedTabIds.includes(currentTab ?? 0)) {
- setCurrentTab(orderedTabIds[0]);
- }
-
- toast.success(t("splitScreen.success"));
- };
-
- const handleClearSplit = () => {
- allSplitScreenTab.forEach((tabId) => {
- setSplitScreenTab(tabId);
- });
-
- setSplitMode("none");
- setSplitAssignments(new Map());
- setPreviewKey((prev) => prev + 1);
-
- toast.success(t("splitScreen.cleared"));
- };
-
- const handleCommandSelect = (command: string) => {
- if (activeTerminal?.terminalRef?.current?.sendInput) {
- activeTerminal.terminalRef.current.sendInput(command);
- }
- };
-
- const handleCommandDelete = async (command: string) => {
- if (activeTerminalHostId) {
- try {
- await deleteCommandFromHistory(activeTerminalHostId, command);
- setCommandHistory((prev) => prev.filter((c) => c !== command));
- toast.success(t("commandHistory.deleteSuccess"));
- } catch {
- toast.error(t("commandHistory.deleteFailed"));
- }
- }
- };
-
- return (
- <>
- {isOpen && (
- <div className="fixed top-0 right-0 h-0 w-0 pointer-events-none">
- <SidebarProvider
- open={isOpen}
- style={
- { "--sidebar-width": `${sidebarWidth}px` } as React.CSSProperties
- }
- className="!min-h-0 !h-0 !w-0"
- >
- <Sidebar
- variant="floating"
- side="right"
- className="pointer-events-auto"
- >
- <SidebarHeader>
- <SidebarGroupLabel className="text-lg font-bold text-foreground">
- {t("nav.tools")}
- <div className="absolute right-5 flex gap-1">
- <Button
- variant="outline"
- onClick={onClose}
- className="w-[28px] h-[28px]"
- title={t("common.close")}
- >
- <X className="h-4 w-4" />
- </Button>
- </div>
- </SidebarGroupLabel>
- </SidebarHeader>
- <Separator className="p-0.25" />
- <SidebarContent className="p-4 flex flex-col overflow-hidden">
- <Tabs
- value={activeTab}
- onValueChange={handleTabChange}
- className="flex flex-col h-full overflow-hidden"
- >
- <TabsList className="w-full grid grid-cols-4 mb-4 flex-shrink-0">
- <TabsTrigger value="ssh-tools">
- {t("sshTools.title")}
- </TabsTrigger>
- <TabsTrigger value="snippets">
- {t("snippets.title")}
- </TabsTrigger>
- <TabsTrigger value="command-history">
- {t("commandHistory.title")}
- </TabsTrigger>
- <TabsTrigger value="split-screen">
- {t("splitScreen.title")}
- </TabsTrigger>
- </TabsList>
-
- <TabsContent value="ssh-tools" className="space-y-4">
- <h3 className="font-semibold text-foreground">
- {t("sshTools.keyRecording")}
- </h3>
-
- <div className="space-y-4">
- <div className="flex gap-2">
- {!isRecording ? (
- <Button
- onClick={handleStartRecording}
- className="flex-1"
- variant="outline"
- >
- {t("sshTools.startKeyRecording")}
- </Button>
- ) : (
- <Button
- onClick={handleStopRecording}
- className="flex-1"
- variant="destructive"
- >
- {t("sshTools.stopKeyRecording")}
- </Button>
- )}
- </div>
-
- {isRecording && (
- <>
- <div className="space-y-2">
- <label className="text-sm font-medium text-foreground">
- {t("sshTools.selectTerminals")}
- </label>
- <div className="flex flex-wrap gap-2 max-h-32 overflow-y-auto thin-scrollbar">
- {terminalTabs.map((tab) => (
- <Button
- key={tab.id}
- type="button"
- variant="outline"
- size="sm"
- className={`rounded-full px-3 py-1 text-xs flex items-center gap-1 ${
- selectedTabIds.includes(tab.id)
- ? "text-foreground bg-surface"
- : "text-foreground-subtle"
- }`}
- onClick={() => handleTabToggle(tab.id)}
- >
- {tab.title}
- </Button>
- ))}
- </div>
- </div>
-
- <div className="space-y-2">
- <label className="text-sm font-medium text-foreground">
- {t("sshTools.typeCommands")}
- </label>
- <Input
- id="ssh-tools-input"
- placeholder={t("placeholders.typeHere")}
- onKeyDown={handleKeyDown}
- onKeyPress={handleKeyPress}
- className="font-mono"
- disabled={selectedTabIds.length === 0}
- readOnly
- />
- <p className="text-xs text-muted-foreground">
- {t("sshTools.commandsWillBeSent", {
- count: selectedTabIds.length,
- })}
- </p>
- </div>
- </>
- )}
- </div>
-
- <Separator />
-
- <h3 className="font-semibold text-foreground">
- {t("sshTools.settings")}
- </h3>
-
- <div className="flex items-center space-x-2">
- <Checkbox
- id="enable-copy-paste"
- onCheckedChange={updateRightClickCopyPaste}
- checked={rightClickCopyPaste}
- />
- <label
- htmlFor="enable-copy-paste"
- className="text-sm font-medium leading-none text-foreground cursor-pointer"
- >
- {t("sshTools.enableRightClickCopyPaste")}
- </label>
- </div>
- </TabsContent>
-
- <TabsContent
- value="snippets"
- className="space-y-4 flex flex-col flex-1 overflow-hidden"
- >
- <div className="flex-shrink-0 space-y-4">
- {terminalTabs.length > 0 && (
- <>
- <div className="space-y-2">
- <label className="text-sm font-medium text-foreground">
- {t("snippets.selectTerminals")}
- </label>
- <p className="text-xs text-muted-foreground">
- {selectedSnippetTabIds.length > 0
- ? t("snippets.executeOnSelected", {
- count: selectedSnippetTabIds.length,
- })
- : t("snippets.executeOnCurrent")}
- </p>
- <div className="flex gap-2 mb-1">
- <Button
- type="button"
- variant="ghost"
- size="sm"
- className="text-xs h-6 px-2"
- onClick={() =>
- setSelectedSnippetTabIds(
- terminalTabs.map((t) => t.id),
- )
- }
- >
- {t("snippets.selectAll", "Select All")}
- </Button>
- <Button
- type="button"
- variant="ghost"
- size="sm"
- className="text-xs h-6 px-2"
- onClick={() => setSelectedSnippetTabIds([])}
- >
- {t("snippets.deselectAll", "Deselect All")}
- </Button>
- </div>
- <div className="flex flex-wrap gap-2 max-h-32 overflow-y-auto thin-scrollbar">
- {terminalTabs.map((tab) => (
- <Button
- key={tab.id}
- type="button"
- variant="outline"
- size="sm"
- className={`rounded-full px-3 py-1 text-xs flex items-center gap-1 ${
- selectedSnippetTabIds.includes(tab.id)
- ? "text-foreground bg-surface"
- : "text-foreground-subtle"
- }`}
- onClick={() => handleSnippetTabToggle(tab.id)}
- >
- {tab.title}
- </Button>
- ))}
- </div>
- </div>
- <Separator />
- </>
- )}
-
- <div className="relative">
- <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
- <Input
- placeholder={t("snippets.searchSnippets")}
- value={snippetSearchQuery}
- onChange={(e) => {
- setSnippetSearchQuery(e.target.value);
- }}
- className="pl-10 pr-10"
- />
- {snippetSearchQuery && (
- <Button
- variant="ghost"
- size="sm"
- className="absolute right-1 top-1/2 transform -translate-y-1/2 h-7 w-7 p-0"
- onClick={() => setSnippetSearchQuery("")}
- >
- <X className="h-4 w-4" />
- </Button>
- )}
- </div>
-
- <div className="flex gap-2">
- <Button
- onClick={handleCreate}
- className="flex-1"
- variant="outline"
- >
- <Plus className="w-4 h-4 mr-2" />
- {t("snippets.new")}
- </Button>
- <Button
- onClick={handleCreateFolder}
- className="flex-1"
- variant="outline"
- >
- <FolderPlus className="w-4 h-4 mr-2" />
- {t("snippets.newFolder")}
- </Button>
- </div>
- </div>
-
- {loading ? (
- <div className="text-center text-muted-foreground py-8 flex-1">
- <p>{t("common.loading")}</p>
- </div>
- ) : snippets.length === 0 && snippetFolders.length === 0 ? (
- <div className="text-center text-muted-foreground py-8 flex-1">
- <p className="mb-2 font-medium">
- {t("snippets.empty")}
- </p>
- <p className="text-sm">{t("snippets.emptyHint")}</p>
- </div>
- ) : (
- <TooltipProvider>
- <div className="space-y-3 overflow-y-auto flex-1 min-h-0 thin-scrollbar">
- {sharedSnippetsList.length > 0 &&
- (() => {
- const isCollapsed =
- collapsedFolders.has("__shared__");
- const FolderIcon = getFolderIcon("__shared__");
- return (
- <div key="__shared__">
- <div className="flex items-center gap-2 mb-2 hover:bg-hover-alt p-2 rounded-lg transition-colors group/folder">
- <div
- className="flex items-center gap-2 flex-1 cursor-pointer"
- onClick={() => toggleFolder("__shared__")}
- >
- {isCollapsed ? (
- <ChevronRight className="h-4 w-4 text-muted-foreground" />
- ) : (
- <ChevronDown className="h-4 w-4 text-muted-foreground" />
- )}
- <FolderIcon className="h-4 w-4" />
- <span className="text-sm font-semibold">
- {t("snippets.sharedWithYou")}
- </span>
- <span className="text-xs text-muted-foreground ml-auto">
- {sharedSnippetsList.length}
- </span>
- </div>
- <div className="flex items-center gap-1 opacity-0 pointer-events-none">
- <div className="h-6 w-6" />
- <div className="h-6 w-6" />
- </div>
- </div>
- {!isCollapsed && (
- <div className="space-y-2 ml-6">
- {sharedSnippetsList.map((snippet) => (
- <div
- key={`shared-${snippet.id}`}
- className="bg-field border border-input rounded-lg hover:shadow-lg hover:border-edge-hover hover:bg-hover-alt transition-all duration-200 p-3 group"
- >
- <div className="mb-2 flex items-center gap-2">
- <div className="flex-1 min-w-0">
- <h3 className="text-sm font-medium text-foreground mb-1">
- {snippet.name}
- </h3>
- {snippet.description && (
- <p className="text-xs text-muted-foreground">
- {snippet.description}
- </p>
- )}
- <p className="text-xs text-muted-foreground mt-1">
- {t("snippets.sharedBy", {
- username:
- snippet.ownerUsername,
- })}
- </p>
- </div>
- </div>
- <div className="bg-muted/30 rounded p-2 mb-3">
- <code className="text-xs font-mono break-all line-clamp-2 text-muted-foreground">
- {snippet.content}
- </code>
- </div>
- <div className="flex items-center gap-2">
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="default"
- className="flex-1"
- onClick={() =>
- handleExecute(
- snippet as unknown as Snippet,
- )
- }
- >
- <Play className="w-3 h-3 mr-1" />
- {t("snippets.run")}
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {t("snippets.runTooltip")}
- </p>
- </TooltipContent>
- </Tooltip>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- onClick={() =>
- handleCopy(
- snippet as unknown as Snippet,
- )
- }
- >
- <Copy className="w-3 h-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {t("snippets.copyTooltip")}
- </p>
- </TooltipContent>
- </Tooltip>
- </div>
- </div>
- ))}
- </div>
- )}
- </div>
- );
- })()}
-
- {Array.from(groupSnippetsByFolder()).map(
- ([folderName, folderSnippets]) => {
- const folderMetadata = snippetFolders.find(
- (f) => f.name === folderName,
- );
- const isCollapsed =
- collapsedFolders.has(folderName);
-
- return (
- <div key={folderName || "uncategorized"}>
- <div className="flex items-center gap-2 mb-2 hover:bg-hover-alt p-2 rounded-lg transition-colors group/folder">
- <div
- className="flex items-center gap-2 flex-1 cursor-pointer"
- onClick={() => toggleFolder(folderName)}
- >
- {isCollapsed ? (
- <ChevronRight className="h-4 w-4 text-muted-foreground" />
- ) : (
- <ChevronDown className="h-4 w-4 text-muted-foreground" />
- )}
- {(() => {
- const FolderIcon =
- getFolderIcon(folderName);
- const folderColor =
- getFolderColor(folderName);
- return (
- <FolderIcon
- className="h-4 w-4"
- style={{
- color: folderColor || undefined,
- }}
- />
- );
- })()}
- <span
- className="text-sm font-semibold"
- style={{
- color:
- getFolderColor(folderName) ||
- undefined,
- }}
- >
- {folderName ||
- t("snippets.uncategorized", {
- defaultValue: "Uncategorized",
- })}
- </span>
- <span className="text-xs text-muted-foreground ml-auto">
- {folderSnippets.length}
- </span>
- </div>
- {folderName && (
- <div className="flex items-center gap-1 opacity-0 group-hover/folder:opacity-100 transition-opacity">
- <Button
- size="sm"
- variant="ghost"
- className="h-6 w-6 p-0"
- onClick={(e) => {
- e.stopPropagation();
- handleEditFolder(
- folderMetadata || {
- id: 0,
- userId: "",
- name: folderName,
- createdAt: "",
- updatedAt: "",
- },
- );
- }}
- >
- <Settings className="h-3 w-3" />
- </Button>
- <Button
- size="sm"
- variant="ghost"
- className="h-6 w-6 p-0 hover:bg-destructive hover:text-destructive-foreground"
- onClick={(e) => {
- e.stopPropagation();
- handleDeleteFolder(folderName);
- }}
- >
- <Trash2 className="h-3 w-3" />
- </Button>
- </div>
- )}
- </div>
-
- {!isCollapsed && (
- <div className="space-y-2 ml-6">
- {folderSnippets.map((snippet) => (
- <div
- key={snippet.id}
- draggable
- onDragStart={(e) =>
- handleDragStart(e, snippet)
- }
- onDragOver={handleDragOver}
- onDrop={(e) => handleDrop(e, snippet)}
- onDragEnd={handleDragEnd}
- className={`bg-field border border-input rounded-lg cursor-move hover:shadow-lg hover:border-edge-hover hover:bg-hover-alt transition-all duration-200 p-3 group ${
- draggedSnippet?.id === snippet.id
- ? "opacity-50"
- : ""
- }`}
- >
- <div className="mb-2 flex items-center gap-2">
- <GripVertical className="h-4 w-4 text-muted-foreground flex-shrink-0 opacity-50 group-hover:opacity-100 transition-opacity" />
- <div className="flex-1 min-w-0">
- <h3 className="text-sm font-medium text-foreground mb-1">
- {snippet.name}
- </h3>
- {snippet.description && (
- <p className="text-xs text-muted-foreground">
- {snippet.description}
- </p>
- )}
- <p className="text-xs text-muted-foreground mt-1">
- ID: {snippet.id}
- </p>
- </div>
- </div>
-
- <div className="bg-muted/30 rounded p-2 mb-3">
- <code className="text-xs font-mono break-all line-clamp-2 text-muted-foreground">
- {snippet.content}
- </code>
- </div>
-
- <div className="flex items-center gap-2">
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="default"
- className="flex-1"
- onClick={() =>
- handleExecute(snippet)
- }
- >
- <Play className="w-3 h-3 mr-1" />
- {t("snippets.run")}
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {t("snippets.runTooltip")}
- </p>
- </TooltipContent>
- </Tooltip>
-
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- onClick={() =>
- handleCopy(snippet)
- }
- >
- <Copy className="w-3 h-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {t("snippets.copyTooltip")}
- </p>
- </TooltipContent>
- </Tooltip>
-
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- onClick={() =>
- handleEdit(snippet)
- }
- >
- <Edit className="w-3 h-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {t("snippets.editTooltip")}
- </p>
- </TooltipContent>
- </Tooltip>
-
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- onClick={() =>
- handleDelete(snippet)
- }
- className="hover:bg-destructive hover:text-destructive-foreground"
- >
- <Trash2 className="w-3 h-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {t("snippets.deleteTooltip")}
- </p>
- </TooltipContent>
- </Tooltip>
-
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- size="sm"
- variant="outline"
- onClick={() =>
- handleOpenShareDialog(
- snippet,
- )
- }
- >
- <Share2 className="w-3 h-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>
- {t("snippets.shareTooltip")}
- </p>
- </TooltipContent>
- </Tooltip>
- </div>
- </div>
- ))}
- </div>
- )}
- </div>
- );
- },
- )}
- </div>
- </TooltipProvider>
- )}
- </TabsContent>
-
- <TabsContent
- value="command-history"
- className="flex flex-col flex-1 overflow-hidden"
- >
- {!commandHistoryEnabled ? (
- <div className="flex flex-col items-center justify-center flex-1 py-8 text-center px-4">
- <div className="bg-muted/40 border rounded-lg p-5 space-y-2">
- <p className="font-medium text-sm">
- {t("commandHistory.disabledTitle")}
- </p>
- <p className="text-xs text-muted-foreground">
- {t("commandHistory.disabledDescription")}
- </p>
- </div>
- </div>
- ) : (
- <>
- <div className="space-y-2 flex-shrink-0 mb-4">
- <div className="relative">
- <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
- <Input
- placeholder={t(
- "commandHistory.searchPlaceholder",
- )}
- value={searchQuery}
- onChange={(e) => {
- setSearchQuery(e.target.value);
- }}
- className="pl-10 pr-10"
- />
- {searchQuery && (
- <Button
- variant="ghost"
- size="sm"
- className="absolute right-1 top-1/2 transform -translate-y-1/2 h-7 w-7 p-0"
- onClick={() => setSearchQuery("")}
- >
- <X className="h-4 w-4" />
- </Button>
- )}
- </div>
- <p className="text-xs text-muted-foreground bg-muted/30 px-2 py-1.5 rounded">
- {t("commandHistory.tabHint")}
- </p>
- </div>
-
- <div className="flex-1 overflow-hidden min-h-0">
- {historyError ? (
- <div className="text-center py-8">
- <div className="bg-destructive/10 border border-destructive/20 rounded-lg p-4 mb-4">
- <p className="text-destructive font-medium mb-2">
- {t("commandHistory.error")}
- </p>
- <p className="text-sm text-muted-foreground">
- {historyError}
- </p>
- </div>
- <Button
- onClick={() =>
- setHistoryRefreshCounter((prev) => prev + 1)
- }
- variant="outline"
- >
- {t("common.retry")}
- </Button>
- </div>
- ) : !activeTerminal ? (
- <div className="text-center text-muted-foreground py-8">
- <Terminal className="h-12 w-12 mb-4 opacity-20 mx-auto" />
- <p className="mb-2 font-medium">
- {t("commandHistory.noTerminal")}{" "}
- </p>
- <p className="text-sm">
- {t("commandHistory.noTerminalHint")}
- </p>
- </div>
- ) : isHistoryLoading &&
- commandHistory.length === 0 ? (
- <div className="text-center text-muted-foreground py-8">
- <Loader2 className="h-12 w-12 mb-4 opacity-20 mx-auto animate-spin" />
- <p className="mb-2 font-medium">
- {t("commandHistory.loading")}{" "}
- </p>
- </div>
- ) : filteredCommands.length === 0 ? (
- <div className="text-center text-muted-foreground py-8">
- {searchQuery ? (
- <>
- <Search className="h-12 w-12 mb-2 opacity-20 mx-auto" />
- <p className="mb-2 font-medium">
- {t("commandHistory.noResults")}
- </p>
- <p className="text-sm">
- {t("commandHistory.noResultsHint", {
- query: searchQuery,
- })}
- </p>
- </>
- ) : (
- <>
- <p className="mb-2 font-medium">
- {t("commandHistory.empty")}
- </p>
- <p className="text-sm">
- {t("commandHistory.emptyHint")}
- </p>
- </>
- )}
- </div>
- ) : (
- <div
- ref={commandHistoryScrollRef}
- className="space-y-2 overflow-y-auto h-full thin-scrollbar"
- >
- {filteredCommands.map((command, index) => (
- <div
- key={index}
- className="bg-canvas border-2 border-edge rounded-md px-3 py-2.5 hover:bg-hover-alt hover:border-edge-hover transition-all duration-200 group h-12 flex items-center"
- >
- <div className="flex items-center justify-between gap-2 w-full min-w-0">
- <span
- className="flex-1 font-mono text-sm cursor-pointer text-foreground truncate"
- onClick={() =>
- handleCommandSelect(command)
- }
- title={command}
- >
- {command}
- </span>
- <Button
- variant="ghost"
- size="sm"
- className="h-6 w-6 p-0 opacity-0 group-hover:opacity-100 hover:bg-red-500/20 hover:text-red-400 flex-shrink-0"
- onClick={(e) => {
- e.stopPropagation();
- handleCommandDelete(command);
- }}
- title={t("commandHistory.deleteTooltip")}
- >
- <Trash2 className="h-3.5 w-3.5" />
- </Button>
- </div>
- </div>
- ))}
- </div>
- )}
- </div>
- </>
- )}
- </TabsContent>
-
- <TabsContent
- value="split-screen"
- className="flex flex-col flex-1 overflow-hidden"
- >
- <div className="space-y-4 flex-1 overflow-y-auto overflow-x-hidden pb-4 thin-scrollbar">
- <Tabs
- value={splitMode}
- onValueChange={(value) =>
- handleSplitModeChange(
- value as "none" | "2" | "3" | "4" | "5" | "6",
- )
- }
- className="w-full"
- >
- <TabsList className="w-full grid grid-cols-3 grid-rows-2 h-auto gap-2 p-2">
- <TabsTrigger value="none" className="h-10">
- {t("splitScreen.none")}
- </TabsTrigger>
- <TabsTrigger value="2" className="h-10">
- {t("splitScreen.twoSplit")}
- </TabsTrigger>
- <TabsTrigger value="3" className="h-10">
- {t("splitScreen.threeSplit")}
- </TabsTrigger>
- <TabsTrigger value="4" className="h-10">
- {t("splitScreen.fourSplit")}
- </TabsTrigger>
- <TabsTrigger value="5" className="h-10">
- {t("splitScreen.fiveSplit")}
- </TabsTrigger>
- <TabsTrigger value="6" className="h-10">
- {t("splitScreen.sixSplit")}
- </TabsTrigger>
- </TabsList>
- </Tabs>
-
- {splitMode !== "none" && (
- <>
- <Separator />
-
- <div className="space-y-2">
- <label className="text-sm font-medium text-foreground">
- {t("splitScreen.availableTabs")}
- </label>
- <p className="text-xs text-muted-foreground mb-2">
- {t("splitScreen.dragTabsHint")}
- </p>
- <div className="space-y-1 max-h-[200px] overflow-y-auto thin-scrollbar">
- {splittableTabs.map((tab) => {
- const isAssigned = Array.from(
- splitAssignments.values(),
- ).includes(tab.id);
- const isDragging = draggedTabId === tab.id;
-
- return (
- <div
- key={tab.id}
- draggable={!isAssigned}
- onDragStart={() =>
- handleTabDragStart(tab.id)
- }
- onDragEnd={handleTabDragEnd}
- className={`
- px-3 py-2 rounded-md text-sm cursor-move transition-all
- ${
- isAssigned
- ? "bg-canvas/50 text-muted-foreground cursor-not-allowed opacity-50"
- : "bg-canvas border border-edge hover:border-edge-hover hover:bg-field"
- }
- ${isDragging ? "opacity-50" : ""}
- `}
- >
- <span className="truncate">
- {tab.title}
- </span>
- </div>
- );
- })}
- </div>
- </div>
-
- <Separator />
-
- <div className="space-y-2">
- <label className="text-sm font-medium text-foreground">
- {t("splitScreen.layout")}
- </label>
- <div
- className={`grid gap-2 mt-2 ${
- splitMode === "2"
- ? "grid-cols-2"
- : splitMode === "5" || splitMode === "6"
- ? "grid-cols-3 grid-rows-2"
- : "grid-cols-2 grid-rows-2"
- }`}
- >
- {Array.from(
- { length: parseInt(splitMode) },
- (_, idx) => {
- const assignedTabId =
- splitAssignments.get(idx);
- const assignedTab = assignedTabId
- ? splittableTabs.find(
- (t) => t.id === assignedTabId,
- )
- : null;
- const isHovered = dragOverCellIndex === idx;
- const isEmpty = !assignedTabId;
-
- return (
- <div
- key={idx}
- onDragOver={(e) =>
- handleTabDragOver(e, idx)
- }
- onDragLeave={handleTabDragLeave}
- onDrop={() => handleTabDrop(idx)}
- className={`
- relative bg-canvas border-2 rounded-md p-3 min-h-[100px]
- flex flex-col items-center justify-center transition-all
- ${splitMode === "3" && idx === 2 ? "col-span-2" : ""}
- ${
- isEmpty
- ? "border-dashed border-edge"
- : "border-solid border-edge-hover bg-surface"
- }
- ${
- isHovered && draggedTabId
- ? "border-edge-hover bg-surface ring-2 ring-edge-hover"
- : ""
- }
- `}
- >
- {assignedTab ? (
- <>
- <span className="text-sm text-foreground truncate w-full text-center mb-2">
- {assignedTab.title}
- </span>
- <Button
- variant="ghost"
- size="sm"
- onClick={() =>
- handleRemoveFromCell(idx)
- }
- className="h-6 text-xs hover:bg-red-500/20"
- >
- {t("common.remove")}
- </Button>
- </>
- ) : (
- <span className="text-xs text-muted-foreground">
- {t("splitScreen.dropHere")}
- </span>
- )}
- </div>
- );
- },
- )}
- </div>
- </div>
-
- <div className="flex gap-2 pt-2">
- <Button
- onClick={handleApplySplit}
- className="flex-1"
- disabled={splitAssignments.size === 0}
- >
- {t("splitScreen.apply")}
- </Button>
- <Button
- variant="outline"
- onClick={handleClearSplit}
- className="flex-1"
- >
- {t("splitScreen.clear")}
- </Button>
- </div>
- </>
- )}
-
- {splitMode === "none" && (
- <div className="text-center py-8">
- <LayoutGrid className="h-12 w-12 mb-4 opacity-20 mx-auto" />
- <p className="text-sm text-muted-foreground mb-2">
- {t("splitScreen.selectMode")}
- </p>
- <p className="text-xs text-muted-foreground">
- {t("splitScreen.helpText")}
- </p>
- </div>
- )}
- </div>
- </TabsContent>
- </Tabs>
- </SidebarContent>
- {isOpen && (
- <div
- className="absolute top-0 h-full cursor-col-resize z-[60]"
- onMouseDown={handleMouseDown}
- style={{
- left: "-4px",
- width: "8px",
- backgroundColor: isResizing
- ? "var(--bg-active)"
- : "transparent",
- }}
- onMouseEnter={(e) => {
- if (!isResizing) {
- e.currentTarget.style.backgroundColor =
- "var(--border-hover)";
- }
- }}
- onMouseLeave={(e) => {
- if (!isResizing) {
- e.currentTarget.style.backgroundColor = "transparent";
- }
- }}
- title={t("common.dragToResizeSidebar")}
- />
- )}
- </Sidebar>
- </SidebarProvider>
- </div>
- )}
-
- {showDialog && (
- <div
- className="fixed inset-0 flex items-center justify-center z-[9999999] bg-black/50 backdrop-blur-sm"
- onClick={() => setShowDialog(false)}
- >
- <div
- className="bg-canvas border-2 border-edge rounded-lg p-6 max-w-2xl w-full mx-4 max-h-[90vh] overflow-y-auto thin-scrollbar"
- onClick={(e) => e.stopPropagation()}
- >
- <div className="mb-6">
- <h2 className="text-xl font-semibold text-foreground">
- {editingSnippet ? t("snippets.edit") : t("snippets.create")}
- </h2>
- <p className="text-sm text-muted-foreground mt-1">
- {editingSnippet
- ? t("snippets.editDescription")
- : t("snippets.createDescription")}
- </p>
- </div>
-
- <div className="space-y-5">
- <div className="space-y-2">
- <label className="text-sm font-medium text-foreground flex items-center gap-1">
- {t("snippets.name")}
- <span className="text-destructive">*</span>
- </label>
- <Input
- value={formData.name}
- onChange={(e) =>
- setFormData({ ...formData, name: e.target.value })
- }
- placeholder={t("snippets.namePlaceholder")}
- className={`${formErrors.name ? "border-destructive focus-visible:ring-destructive" : ""}`}
- autoFocus
- />
- {formErrors.name && (
- <p className="text-xs text-destructive mt-1">
- {t("snippets.nameRequired")}
- </p>
- )}
- </div>
-
- <div className="space-y-2">
- <label className="text-sm font-medium text-foreground">
- {t("snippets.description")}
- <span className="text-muted-foreground ml-1">
- ({t("common.optional")})
- </span>
- </label>
- <Input
- value={formData.description}
- onChange={(e) =>
- setFormData({ ...formData, description: e.target.value })
- }
- placeholder={t("snippets.descriptionPlaceholder")}
- />
- </div>
-
- <div className="space-y-2">
- <label className="text-sm font-medium text-foreground flex items-center gap-2">
- <Folder className="h-4 w-4" />
- {t("snippets.folder")}
- <span className="text-muted-foreground">
- ({t("common.optional")})
- </span>
- </label>
- <Select
- value={formData.folder || "__no_folder__"}
- onValueChange={(value) =>
- setFormData({
- ...formData,
- folder: value === "__no_folder__" ? undefined : value,
- })
- }
- >
- <SelectTrigger>
- <SelectValue placeholder={t("snippets.selectFolder")} />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="__no_folder__">
- {t("snippets.noFolder")}
- </SelectItem>
- {snippetFolders.map((folder) => {
- const FolderIcon = getFolderIcon(folder.name);
- return (
- <SelectItem key={folder.id} value={folder.name}>
- <div className="flex items-center gap-2">
- <FolderIcon
- className="h-4 w-4"
- style={{
- color: folder.color || undefined,
- }}
- />
- <span>{folder.name}</span>
- </div>
- </SelectItem>
- );
- })}
- </SelectContent>
- </Select>
- </div>
-
- <div className="space-y-2">
- <label className="text-sm font-medium text-foreground flex items-center gap-1">
- {t("snippets.content")}
- <span className="text-destructive">*</span>
- </label>
- <Textarea
- value={formData.content}
- onChange={(e) =>
- setFormData({ ...formData, content: e.target.value })
- }
- placeholder={t("snippets.contentPlaceholder")}
- className={`font-mono text-sm ${formErrors.content ? "border-destructive focus-visible:ring-destructive" : ""}`}
- rows={10}
- />
- {formErrors.content && (
- <p className="text-xs text-destructive mt-1">
- {t("snippets.contentRequired")}
- </p>
- )}
- </div>
- </div>
-
- <Separator className="my-6" />
-
- <div className="flex gap-3">
- <Button
- variant="outline"
- onClick={() => setShowDialog(false)}
- className="flex-1"
- >
- {t("common.cancel")}
- </Button>
- <Button onClick={handleSubmit} className="flex-1">
- {editingSnippet ? t("snippets.edit") : t("snippets.create")}
- </Button>
- </div>
- </div>
- </div>
- )}
-
- {showFolderDialog && (
- <div
- className="fixed inset-0 flex items-center justify-center z-[9999999] bg-black/50 backdrop-blur-sm"
- onClick={() => setShowFolderDialog(false)}
- >
- <div
- className="bg-canvas border-2 border-edge rounded-lg p-6 max-w-lg w-full mx-4"
- onClick={(e) => e.stopPropagation()}
- >
- <div className="mb-6">
- <h2 className="text-xl font-semibold text-foreground">
- {editingFolder
- ? t("snippets.editFolder")
- : t("snippets.createFolder")}
- </h2>
- <p className="text-sm text-muted-foreground mt-1">
- {editingFolder
- ? t("snippets.editFolderDescription")
- : t("snippets.createFolderDescription")}
- </p>
- </div>
-
- <div className="space-y-5">
- <div className="space-y-2">
- <label className="text-sm font-medium text-foreground flex items-center gap-1">
- {t("snippets.folderName")}
- <span className="text-destructive">*</span>
- </label>
- <Input
- value={folderFormData.name}
- onChange={(e) =>
- setFolderFormData({
- ...folderFormData,
- name: e.target.value,
- })
- }
- placeholder={t("sshTools.scripts.inputPlaceholder")}
- className={`${folderFormErrors.name ? "border-destructive focus-visible:ring-destructive" : ""}`}
- autoFocus
- />
- {folderFormErrors.name && (
- <p className="text-xs text-destructive mt-1">
- {t("snippets.folderNameRequired")}
- </p>
- )}
- </div>
-
- <div className="space-y-3">
- <Label className="text-base font-semibold text-foreground">
- {t("snippets.folderColor")}
- </Label>
- <div className="grid grid-cols-4 gap-3">
- {AVAILABLE_COLORS.map((color) => (
- <button
- key={color.value}
- type="button"
- className={`h-12 rounded-md border-2 transition-all hover:scale-105 ${
- folderFormData.color === color.value
- ? "border-white shadow-lg scale-105"
- : "border-edge"
- }`}
- style={{ backgroundColor: color.value }}
- onClick={() =>
- setFolderFormData({
- ...folderFormData,
- color: color.value,
- })
- }
- title={color.label}
- />
- ))}
- </div>
- </div>
-
- <div className="space-y-3">
- <Label className="text-base font-semibold text-foreground">
- {t("snippets.folderIcon")}
- </Label>
- <div className="grid grid-cols-5 gap-3">
- {AVAILABLE_ICONS.map(({ value, label, Icon }) => (
- <button
- key={value}
- type="button"
- className={`h-14 rounded-md border-2 transition-all hover:scale-105 flex items-center justify-center ${
- folderFormData.icon === value
- ? "border-primary bg-primary/10"
- : "border-edge bg-elevated"
- }`}
- onClick={() =>
- setFolderFormData({ ...folderFormData, icon: value })
- }
- title={label}
- >
- <Icon className="w-6 h-6" />
- </button>
- ))}
- </div>
- </div>
-
- <div className="space-y-3">
- <Label className="text-base font-semibold text-foreground">
- {t("snippets.preview")}
- </Label>
- <div className="flex items-center gap-3 p-4 rounded-md bg-elevated border border-edge">
- {(() => {
- const IconComponent =
- AVAILABLE_ICONS.find(
- (i) => i.value === folderFormData.icon,
- )?.Icon || Folder;
- return (
- <IconComponent
- className="w-5 h-5"
- style={{ color: folderFormData.color }}
- />
- );
- })()}
- <span className="font-medium">
- {folderFormData.name || t("snippets.folderName")}
- </span>
- </div>
- </div>
- </div>
-
- <Separator className="my-6" />
-
- <div className="flex gap-3">
- <Button
- variant="outline"
- onClick={() => setShowFolderDialog(false)}
- className="flex-1"
- >
- {t("common.cancel")}
- </Button>
- <Button onClick={handleFolderSubmit} className="flex-1">
- {editingFolder
- ? t("snippets.updateFolder")
- : t("snippets.createFolder")}
- </Button>
- </div>
- </div>
- </div>
- )}
-
- {shareDialogSnippet && (
- <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60">
- <div className="bg-card border-2 border-border rounded-lg p-6 w-full max-w-md space-y-4 max-h-[80vh] overflow-auto">
- <div className="flex items-center justify-between">
- <h3 className="text-lg font-semibold">
- {t("snippets.shareSnippet")}
- </h3>
- <Button
- size="sm"
- variant="ghost"
- onClick={() => setShareDialogSnippet(null)}
- >
- <X className="w-4 h-4" />
- </Button>
- </div>
-
- <p className="text-sm text-muted-foreground">
- {shareDialogSnippet.name}
- </p>
-
- <div className="space-y-3">
- <div className="flex gap-2">
- <Select
- value={shareTargetType}
- onValueChange={(v: "user" | "role") => {
- setShareTargetType(v);
- setShareTargetId("");
- }}
- >
- <SelectTrigger className="w-[100px]">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="user">{t("snippets.user")}</SelectItem>
- <SelectItem value="role">{t("snippets.role")}</SelectItem>
- </SelectContent>
- </Select>
-
- <Select value={shareTargetId} onValueChange={setShareTargetId}>
- <SelectTrigger className="flex-1">
- <SelectValue placeholder={t("snippets.selectTarget")} />
- </SelectTrigger>
- <SelectContent>
- {shareTargetType === "user"
- ? shareUsers.map((u) => (
- <SelectItem key={u.id} value={u.id}>
- {u.username}
- </SelectItem>
- ))
- : shareRoles.map((r) => (
- <SelectItem key={r.id} value={String(r.id)}>
- {r.displayName || r.name}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
-
- <Button
- onClick={handleShare}
- disabled={!shareTargetId}
- size="sm"
- >
- <Share2 className="w-4 h-4" />
- </Button>
- </div>
- </div>
-
- {shareAccessList.length > 0 && (
- <div className="space-y-2">
- <span className="text-sm font-semibold">
- {t("snippets.currentAccess")}
- </span>
- {shareAccessList.map((access) => (
- <div
- key={access.id}
- className="flex items-center justify-between rounded-md border p-2 text-sm"
- >
- <span>
- {access.username ||
- access.roleDisplayName ||
- access.roleName}
- </span>
- <Button
- size="sm"
- variant="ghost"
- className="hover:bg-destructive hover:text-destructive-foreground"
- onClick={() => handleRevokeSnippetAccess(access.id)}
- >
- <Trash2 className="w-3 h-3" />
- </Button>
- </div>
- ))}
- </div>
- )}
- </div>
- </div>
- )}
- </>
- );
-}
diff --git a/src/ui/desktop/navigation/AppView.tsx b/src/ui/desktop/navigation/AppView.tsx
deleted file mode 100644
index e077a82d5..000000000
--- a/src/ui/desktop/navigation/AppView.tsx
+++ /dev/null
@@ -1,809 +0,0 @@
-import React, {
- Component,
- type ErrorInfo,
- Suspense,
- lazy,
- useEffect,
- useRef,
- useState,
- useMemo,
-} from "react";
-import type { GuacamoleConnectionConfig } from "@/ui/desktop/apps/features/guacamole/GuacamoleDisplay.tsx";
-import type { SSHHost } from "@/types";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
-import {
- ResizablePanelGroup,
- ResizablePanel,
- ResizableHandle,
-} from "@/components/ui/resizable.tsx";
-import { useSidebar } from "@/components/ui/sidebar.tsx";
-import { RefreshCcw } from "lucide-react";
-import { toast } from "sonner";
-import { Button } from "@/components/ui/button.tsx";
-import {
- TERMINAL_THEMES,
- DEFAULT_TERMINAL_CONFIG,
-} from "@/constants/terminal-themes";
-import { useTheme } from "@/components/theme-provider";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
-import { useTranslation } from "react-i18next";
-
-class ChunkErrorBoundaryInner extends Component<
- { children: React.ReactNode; message: string; buttonLabel: string },
- { hasChunkError: boolean }
-> {
- constructor(props: {
- children: React.ReactNode;
- message: string;
- buttonLabel: string;
- }) {
- super(props);
- this.state = { hasChunkError: false };
- }
-
- static getDerivedStateFromError(error: Error) {
- const isChunkError =
- error.name === "ChunkLoadError" ||
- /Loading chunk \d+ failed/i.test(error.message) ||
- /Failed to fetch dynamically imported module/i.test(error.message) ||
- /error loading dynamically imported module/i.test(error.message);
- if (isChunkError) return { hasChunkError: true };
- throw error;
- }
-
- componentDidCatch(_error: Error, _info: ErrorInfo) {}
-
- render() {
- if (this.state.hasChunkError) {
- return (
- <div className="flex flex-col items-center justify-center h-full gap-3 text-sm text-[var(--text-secondary)]">
- <span>{this.props.message}</span>
- <button
- className="px-3 py-1.5 rounded bg-[var(--bg-secondary)] hover:bg-[var(--bg-tertiary)] text-[var(--text-primary)] transition-colors"
- onClick={() => window.location.reload()}
- >
- {this.props.buttonLabel}
- </button>
- </div>
- );
- }
- return this.props.children;
- }
-}
-
-function ChunkErrorBoundary({ children }: { children: React.ReactNode }) {
- const { t } = useTranslation();
- return (
- <ChunkErrorBoundaryInner
- message={t("common.pageOutdated")}
- buttonLabel={t("common.refreshPage")}
- >
- {children}
- </ChunkErrorBoundaryInner>
- );
-}
-
-const Terminal = lazy(() =>
- import("@/ui/desktop/apps/features/terminal/Terminal.tsx").then((module) => ({
- default: module.Terminal,
- })),
-);
-const ServerView = lazy(() =>
- import("@/ui/desktop/apps/features/server-stats/ServerStats.tsx").then(
- (module) => ({
- default: module.ServerStats,
- }),
- ),
-);
-const FileManager = lazy(() =>
- import("@/ui/desktop/apps/features/file-manager/FileManager.tsx").then(
- (module) => ({
- default: module.FileManager,
- }),
- ),
-);
-const GuacamoleDisplay = lazy(() =>
- import("@/ui/desktop/apps/features/guacamole/GuacamoleDisplay.tsx").then(
- (module) => ({
- default: module.GuacamoleDisplay,
- }),
- ),
-);
-const TunnelManager = lazy(() =>
- import("@/ui/desktop/apps/features/tunnel/TunnelManager.tsx").then(
- (module) => ({
- default: module.TunnelManager,
- }),
- ),
-);
-const DockerManager = lazy(() =>
- import("@/ui/desktop/apps/features/docker/DockerManager.tsx").then(
- (module) => ({
- default: module.DockerManager,
- }),
- ),
-);
-const NetworkGraphCard = lazy(() =>
- import("@/ui/desktop/apps/dashboard/cards/NetworkGraphCard").then(
- (module) => ({
- default: module.NetworkGraphCard,
- }),
- ),
-);
-
-interface TabData {
- id: number;
- type: string;
- title: string;
- terminalRef?: {
- current?: {
- fit?: () => void;
- notifyResize?: () => void;
- refresh?: () => void;
- };
- };
- hostConfig?: SSHHost;
- connectionConfig?: GuacamoleConnectionConfig;
- [key: string]: unknown;
-}
-
-type LayoutNode =
- | number // leaf: index into layoutTabs[]
- | { direction: "horizontal" | "vertical"; children: LayoutNode[] };
-
-const SPLIT_LAYOUTS: Record<number, LayoutNode> = {
- 2: { direction: "horizontal", children: [0, 1] },
- 3: {
- direction: "vertical",
- children: [{ direction: "horizontal", children: [0, 1] }, 2],
- },
- 4: {
- direction: "vertical",
- children: [
- { direction: "horizontal", children: [0, 1] },
- { direction: "horizontal", children: [2, 3] },
- ],
- },
- 5: {
- direction: "vertical",
- children: [
- { direction: "horizontal", children: [0, 1] },
- { direction: "horizontal", children: [2, 3, 4] },
- ],
- },
- 6: {
- direction: "vertical",
- children: [
- { direction: "horizontal", children: [0, 1, 2] },
- { direction: "horizontal", children: [3, 4, 5] },
- ],
- },
-};
-
-interface TerminalViewProps {
- isTopbarOpen?: boolean;
- rightSidebarOpen?: boolean;
- rightSidebarWidth?: number;
-}
-
-export function AppView({
- isTopbarOpen = true,
- rightSidebarOpen = false,
- rightSidebarWidth = 400,
-}: TerminalViewProps): React.ReactElement {
- const {
- tabs,
- currentTab,
- allSplitScreenTab,
- removeTab,
- updateTab,
- addTab,
- previewTerminalTheme,
- } = useTabs() as {
- tabs: TabData[];
- currentTab: number;
- allSplitScreenTab: number[];
- removeTab: (id: number) => void;
- updateTab: (tabId: number, updates: Partial<Omit<TabData, "id">>) => void;
- addTab: (tab: Omit<TabData, "id">) => number;
- previewTerminalTheme: string | null;
- };
- const { state: sidebarState } = useSidebar();
- const { theme: appTheme } = useTheme();
- const { t: translate } = useTranslation();
-
- const isDarkMode = useMemo(() => {
- if (appTheme === "dark") return true;
- if (appTheme === "dracula") return true;
- if (appTheme === "gentlemansChoice") return true;
- if (appTheme === "midnightEspresso") return true;
- if (appTheme === "catppuccinMocha") return true;
- if (appTheme === "light") return false;
-
- return window.matchMedia("(prefers-color-scheme: dark)").matches;
- }, [appTheme]);
-
- const terminalTabs = useMemo(
- () =>
- tabs.filter(
- (tab: TabData) =>
- tab.type === "terminal" ||
- tab.type === "server_stats" ||
- tab.type === "file_manager" ||
- tab.type === "rdp" ||
- tab.type === "vnc" ||
- tab.type === "telnet" ||
- tab.type === "tunnel" ||
- tab.type === "docker" ||
- tab.type === "network_graph",
- ),
- [tabs],
- );
-
- const containerRef = useRef<HTMLDivElement | null>(null);
- const panelRefs = useRef<Record<string, HTMLDivElement | null>>({});
- const [panelRects, setPanelRects] = useState<Record<string, DOMRect | null>>(
- {},
- );
- const [resetKey, setResetKey] = useState<number>(0);
- const previousStylesRef = useRef<Record<number, React.CSSProperties>>({});
-
- const updatePanelRects = React.useCallback(() => {
- const next: Record<string, DOMRect | null> = {};
- Object.entries(panelRefs.current).forEach(([id, el]) => {
- if (el) next[id] = el.getBoundingClientRect();
- });
- setPanelRects(next);
- }, []);
-
- const fitActiveAndNotify = React.useCallback(() => {
- const visibleIds: number[] = [];
- if (allSplitScreenTab.length === 0) {
- if (currentTab) visibleIds.push(currentTab);
- } else {
- const splitIds = allSplitScreenTab as number[];
- visibleIds.push(currentTab, ...splitIds.filter((i) => i !== currentTab));
- }
-
- const operations = terminalTabs
- .filter((t: TabData) => visibleIds.includes(t.id))
- .map((t: TabData) => t.terminalRef?.current)
- .filter((ref) => ref?.fit);
-
- requestAnimationFrame(() => {
- operations.forEach((ref) => {
- ref.fit?.();
- ref.notifyResize?.();
- ref.refresh?.();
- });
- });
- }, [allSplitScreenTab, currentTab, terminalTabs]);
-
- const layoutScheduleRef = useRef<number | null>(null);
- const scheduleMeasureAndFit = React.useCallback(() => {
- if (layoutScheduleRef.current)
- cancelAnimationFrame(layoutScheduleRef.current);
- layoutScheduleRef.current = requestAnimationFrame(() => {
- updatePanelRects();
- fitActiveAndNotify();
- });
- }, [updatePanelRects, fitActiveAndNotify]);
-
- const hideThenFit = React.useCallback(() => {
- requestAnimationFrame(() => {
- updatePanelRects();
- fitActiveAndNotify();
- });
- }, [updatePanelRects, fitActiveAndNotify]);
-
- const prevStateRef = useRef({
- terminalTabsLength: terminalTabs.length,
- currentTab,
- splitScreenTabsStr: allSplitScreenTab.join(","),
- terminalTabIds: terminalTabs.map((t) => t.id).join(","),
- });
-
- useEffect(() => {
- const prev = prevStateRef.current;
- const currentTabIds = terminalTabs.map((t) => t.id).join(",");
-
- const lengthChanged = prev.terminalTabsLength !== terminalTabs.length;
- const currentTabChanged = prev.currentTab !== currentTab;
- const splitChanged =
- prev.splitScreenTabsStr !== allSplitScreenTab.join(",");
- const tabIdsChanged = prev.terminalTabIds !== currentTabIds;
-
- const isJustReorder =
- !lengthChanged && tabIdsChanged && !currentTabChanged && !splitChanged;
-
- if (
- (lengthChanged || currentTabChanged || splitChanged) &&
- !isJustReorder
- ) {
- hideThenFit();
- }
-
- prevStateRef.current = {
- terminalTabsLength: terminalTabs.length,
- currentTab,
- splitScreenTabsStr: allSplitScreenTab.join(","),
- terminalTabIds: currentTabIds,
- };
- }, [
- currentTab,
- terminalTabs.length,
- allSplitScreenTab.join(","),
- terminalTabs,
- hideThenFit,
- ]);
-
- useEffect(() => {
- scheduleMeasureAndFit();
- }, [
- scheduleMeasureAndFit,
- allSplitScreenTab.length,
- isTopbarOpen,
- sidebarState,
- resetKey,
- rightSidebarOpen,
- rightSidebarWidth,
- ]);
-
- useEffect(() => {
- const roContainer = containerRef.current
- ? new ResizeObserver(() => {
- updatePanelRects();
- fitActiveAndNotify();
- })
- : null;
- if (containerRef.current && roContainer)
- roContainer.observe(containerRef.current);
- return () => roContainer?.disconnect();
- }, [updatePanelRects, fitActiveAndNotify]);
-
- useEffect(() => {
- const onWinResize = () => {
- updatePanelRects();
- fitActiveAndNotify();
- };
- window.addEventListener("resize", onWinResize);
- return () => window.removeEventListener("resize", onWinResize);
- }, [updatePanelRects, fitActiveAndNotify]);
-
- const HEADER_H = 28;
-
- const terminalIdMapRef = useRef<Set<number>>(new Set());
-
- useEffect(() => {
- terminalTabs.forEach((t) => terminalIdMapRef.current.add(t.id));
- }, [terminalTabs]);
-
- const renderTerminalsLayer = () => {
- const styles: Record<number, React.CSSProperties> = {};
- const layoutTabs = allSplitScreenTab
- .map((tabId) => terminalTabs.find((tab: TabData) => tab.id === tabId))
- .filter((t): t is TabData => t !== null && t !== undefined);
-
- const mainTab = terminalTabs.find((tab: TabData) => tab.id === currentTab);
-
- if (allSplitScreenTab.length === 0 && mainTab) {
- const isFileManagerTab =
- mainTab.type === "file_manager" ||
- mainTab.type === "tunnel" ||
- mainTab.type === "docker" ||
- mainTab.type === "network_graph";
- const newStyle = {
- position: "absolute" as const,
- top: isFileManagerTab ? 0 : 4,
- left: isFileManagerTab ? 0 : 4,
- right: isFileManagerTab ? 0 : 4,
- bottom: isFileManagerTab ? 0 : 4,
- zIndex: 20,
- display: "block" as const,
- pointerEvents: "auto" as const,
- opacity: 1,
- };
- styles[mainTab.id] = newStyle;
- previousStylesRef.current[mainTab.id] = newStyle;
- } else {
- layoutTabs.forEach((t: TabData) => {
- const rect = panelRects[String(t.id)];
- const parentRect = containerRef.current?.getBoundingClientRect();
- if (rect && parentRect) {
- const newStyle = {
- position: "absolute" as const,
- top: rect.top - parentRect.top + HEADER_H + 4,
- left: rect.left - parentRect.left + 4,
- width: rect.width - 8,
- height: rect.height - HEADER_H - 8,
- zIndex: 20,
- display: "block" as const,
- pointerEvents: "auto" as const,
- opacity: 1,
- };
- styles[t.id] = newStyle;
- previousStylesRef.current[t.id] = newStyle;
- }
- });
- }
-
- const sortedTerminalTabs = [...terminalTabs].sort((a, b) => a.id - b.id);
-
- return (
- <div className="absolute inset-0 z-[1]">
- {sortedTerminalTabs.map((t: TabData) => {
- const hasStyle = !!styles[t.id];
- const isVisible =
- hasStyle || (allSplitScreenTab.length === 0 && t.id === currentTab);
-
- const effectiveVisible = isVisible;
-
- const previousStyle = previousStylesRef.current[t.id];
-
- const isFileManagerTab =
- t.type === "file_manager" ||
- t.type === "tunnel" ||
- t.type === "docker" ||
- t.type === "network_graph";
- const standardStyle = {
- position: "absolute" as const,
- top: isFileManagerTab ? 0 : 4,
- left: isFileManagerTab ? 0 : 4,
- right: isFileManagerTab ? 0 : 4,
- bottom: isFileManagerTab ? 0 : 4,
- };
-
- const finalStyle: React.CSSProperties = hasStyle
- ? { ...styles[t.id], overflow: "hidden" }
- : effectiveVisible
- ? {
- ...(previousStyle || standardStyle),
- opacity: 1,
- pointerEvents: "auto",
- zIndex: 20,
- display: "block",
- overflow: "hidden",
- }
- : ({
- ...(previousStyle || standardStyle),
- opacity: 0,
- pointerEvents: "none",
- zIndex: 0,
- display: "none",
- overflow: "hidden",
- } as React.CSSProperties);
-
- const isTerminal = t.type === "terminal";
- const terminalConfig = {
- ...DEFAULT_TERMINAL_CONFIG,
- ...t.hostConfig?.terminalConfig,
- };
-
- let themeColors;
- const activeTerminalTheme =
- t.id === currentTab && previewTerminalTheme
- ? previewTerminalTheme
- : terminalConfig.theme;
-
- if (activeTerminalTheme === "termix") {
- themeColors = isDarkMode
- ? TERMINAL_THEMES.termixDark.colors
- : TERMINAL_THEMES.termixLight.colors;
- } else {
- themeColors =
- TERMINAL_THEMES[activeTerminalTheme]?.colors ||
- TERMINAL_THEMES.termixDark.colors;
- }
- const backgroundColor = themeColors.background;
-
- return (
- <div key={t.id} style={finalStyle}>
- <div
- className="absolute inset-0 rounded-md overflow-hidden"
- style={{
- backgroundColor: isTerminal
- ? backgroundColor
- : "var(--bg-base)",
- }}
- >
- <ChunkErrorBoundary>
- <Suspense
- fallback={
- <SimpleLoader
- visible={true}
- message={translate("common.loading")}
- backgroundColor={
- isTerminal ? backgroundColor : "var(--bg-base)"
- }
- />
- }
- >
- {t.type === "terminal" ? (
- <Terminal
- key={`term-${t.id}-${t.instanceId || ""}`}
- ref={t.terminalRef}
- hostConfig={t.hostConfig}
- isVisible={effectiveVisible}
- title={t.title}
- showTitle={false}
- splitScreen={allSplitScreenTab.length > 0}
- onClose={() => removeTab(t.id)}
- onTitleChange={(title) => updateTab(t.id, { title })}
- onOpenFileManager={
- (t.hostConfig as any)?.enableFileManager
- ? (path?: string) =>
- addTab({
- type: "file_manager",
- title: t.title,
- hostConfig: path
- ? {
- ...t.hostConfig!,
- defaultPath: path,
- }
- : t.hostConfig,
- })
- : undefined
- }
- previewTheme={
- t.id === currentTab ? previewTerminalTheme : null
- }
- />
- ) : t.type === "server_stats" ? (
- <ServerView
- key={`stats-${t.id}-${t.instanceId || ""}`}
- hostConfig={t.hostConfig}
- title={t.title}
- isVisible={effectiveVisible}
- isTopbarOpen={isTopbarOpen}
- embedded
- />
- ) : t.type === "rdp" ||
- t.type === "vnc" ||
- t.type === "telnet" ? (
- t.connectionConfig ? (
- <GuacamoleDisplay
- key={`guac-${t.id}-${t.instanceId || ""}`}
- connectionConfig={t.connectionConfig}
- isVisible={effectiveVisible}
- onDisconnect={() => removeTab(t.id)}
- onError={(err) => {
- toast.error(err);
- removeTab(t.id);
- }}
- />
- ) : (
- <div className="flex items-center justify-center h-full text-red-500">
- Missing connection configuration
- </div>
- )
- ) : t.type === "network_graph" ? (
- <NetworkGraphCard
- key={`netgraph-${t.id}-${t.instanceId || ""}`}
- isTopbarOpen={isTopbarOpen}
- rightSidebarOpen={rightSidebarOpen}
- rightSidebarWidth={rightSidebarWidth}
- embedded={false}
- />
- ) : t.type === "tunnel" ? (
- <TunnelManager
- key={`tunnel-${t.id}-${t.instanceId || ""}`}
- hostConfig={t.hostConfig}
- title={t.title}
- isVisible={effectiveVisible}
- isTopbarOpen={isTopbarOpen}
- embedded
- />
- ) : t.type === "docker" ? (
- <DockerManager
- key={`docker-${t.id}-${t.instanceId || ""}`}
- hostConfig={t.hostConfig}
- title={t.title}
- isVisible={effectiveVisible}
- isTopbarOpen={isTopbarOpen}
- embedded
- onClose={() => removeTab(t.id)}
- />
- ) : (
- <FileManager
- key={`filemgr-${t.id}-${t.instanceId || ""}`}
- embedded
- initialHost={t.hostConfig}
- onClose={() => removeTab(t.id)}
- />
- )}
- </Suspense>
- </ChunkErrorBoundary>
- </div>
- </div>
- );
- })}
- </div>
- );
- };
-
- const ResetButton = ({ onClick }: { onClick: () => void }) => (
- <Button
- type="button"
- variant="ghost"
- onClick={onClick}
- aria-label="Reset split sizes"
- className="absolute top-0 right-0 h-[28px] w-[28px] !rounded-none border-l-1 border-b-1 border-edge-panel bg-surface hover:bg-surface-hover text-foreground flex items-center justify-center p-0"
- >
- <RefreshCcw className="h-4 w-4" />
- </Button>
- );
-
- const handleReset = () => {
- setResetKey((k) => k + 1);
- requestAnimationFrame(() => scheduleMeasureAndFit());
- };
-
- const renderSplitOverlays = () => {
- const layoutTabs = allSplitScreenTab
- .map((tabId) => terminalTabs.find((tab: TabData) => tab.id === tabId))
- .filter((t): t is TabData => t !== null && t !== undefined);
- if (allSplitScreenTab.length === 0) return null;
-
- const layout = SPLIT_LAYOUTS[layoutTabs.length];
- if (!layout) return null;
-
- const handleStyle = {
- pointerEvents: "auto",
- zIndex: 12,
- background: "var(--border-base)",
- } as React.CSSProperties;
- const commonGroupProps: {
- onLayout: () => void;
- onResize: () => void;
- } = {
- onLayout: scheduleMeasureAndFit,
- onResize: scheduleMeasureAndFit,
- };
-
- const renderNode = (
- node: LayoutNode,
- path: string,
- siblingCount: number,
- orderIndex: number,
- isRoot: boolean,
- ): React.ReactNode => {
- const defaultSize = Math.round(100 / siblingCount);
-
- if (typeof node === "number") {
- const tab = layoutTabs[node];
- if (!tab) return null;
- return (
- <ResizablePanel
- key={`panel-${tab.id}`}
- id={`panel-${tab.id}`}
- defaultSize={defaultSize}
- minSize={20}
- className="!overflow-hidden h-full w-full"
- order={orderIndex}
- >
- <div
- ref={(el) => {
- panelRefs.current[String(tab.id)] = el;
- }}
- className="h-full w-full flex flex-col relative"
- >
- <div className="bg-surface text-foreground text-[13px] h-[28px] leading-[28px] px-[10px] border-b border-edge-panel tracking-[1px] m-0 pointer-events-auto z-[11] relative">
- {tab.title}
- {node === 1 && <ResetButton onClick={handleReset} />}
- </div>
- </div>
- </ResizablePanel>
- );
- }
-
- const groupKey = isRoot ? String(resetKey) : `${path}-${resetKey}`;
- const groupId = isRoot ? `main-${node.direction}` : `group-${path}`;
-
- const groupContent = (
- <ResizablePanelGroup
- key={groupKey}
- direction={node.direction}
- className="h-full w-full"
- id={groupId}
- {...commonGroupProps}
- >
- {node.children.flatMap((child, i) => {
- const childPath = isRoot ? String(i) : `${path}-${i}`;
- const panel = renderNode(
- child,
- childPath,
- node.children.length,
- i + 1,
- false,
- );
- if (i === 0) return [panel];
- return [
- <ResizableHandle
- key={`handle-${childPath}`}
- style={handleStyle}
- />,
- panel,
- ];
- })}
- </ResizablePanelGroup>
- );
-
- if (isRoot) return groupContent;
-
- return (
- <ResizablePanel
- key={`container-${path}`}
- id={`container-${path}`}
- defaultSize={defaultSize}
- minSize={20}
- className="!overflow-hidden h-full w-full"
- order={orderIndex}
- >
- {groupContent}
- </ResizablePanel>
- );
- };
-
- return (
- <div className="absolute inset-0 z-[10] pointer-events-none">
- {renderNode(layout, "", 1, 1, true)}
- </div>
- );
- };
-
- const currentTabData = tabs.find((tab: TabData) => tab.id === currentTab);
- const isFileManager = currentTabData?.type === "file_manager";
- const isTunnel = currentTabData?.type === "tunnel";
- const isDocker = currentTabData?.type === "docker";
- const isTerminal = currentTabData?.type === "terminal";
- const isSplitScreen = allSplitScreenTab.length > 0;
-
- const terminalConfig = {
- ...DEFAULT_TERMINAL_CONFIG,
- ...currentTabData?.hostConfig?.terminalConfig,
- };
- let containerThemeColors;
- if (terminalConfig.theme === "termix") {
- containerThemeColors = isDarkMode
- ? TERMINAL_THEMES.termixDark.colors
- : TERMINAL_THEMES.termixLight.colors;
- } else {
- containerThemeColors =
- TERMINAL_THEMES[terminalConfig.theme]?.colors ||
- TERMINAL_THEMES.termixDark.colors;
- }
- const terminalBackgroundColor = containerThemeColors.background;
-
- const topMarginPx = isTopbarOpen ? 74 : 26;
- const leftMarginPx = sidebarState === "collapsed" ? 26 : 8;
- const bottomMarginPx = 8;
-
- let containerBackground = "var(--color-canvas)";
- if ((isFileManager || isTunnel || isDocker) && !isSplitScreen) {
- containerBackground = "var(--color-deepest)";
- } else if (isTerminal) {
- containerBackground = terminalBackgroundColor;
- }
-
- return (
- <div
- ref={containerRef}
- className="border-2 border-edge rounded-lg overflow-hidden overflow-x-hidden relative"
- style={{
- background: containerBackground,
- marginLeft: leftMarginPx,
- marginRight: rightSidebarOpen
- ? `calc(var(--right-sidebar-width, ${rightSidebarWidth}px) + 8px)`
- : 17,
- marginTop: topMarginPx,
- marginBottom: bottomMarginPx,
- height: `calc(100vh - ${topMarginPx + bottomMarginPx}px)`,
- transition:
- "margin-left 200ms linear, margin-right 200ms linear, margin-top 200ms linear",
- }}
- >
- {renderTerminalsLayer()}
- {renderSplitOverlays()}
- </div>
- );
-}
diff --git a/src/ui/desktop/navigation/LeftSidebar.tsx b/src/ui/desktop/navigation/LeftSidebar.tsx
deleted file mode 100644
index b9de884de..000000000
--- a/src/ui/desktop/navigation/LeftSidebar.tsx
+++ /dev/null
@@ -1,635 +0,0 @@
-import React, { useState } from "react";
-import {
- ChevronUp,
- User2,
- HardDrive,
- Menu,
- ChevronRight,
- RotateCcw,
-} from "lucide-react";
-import { useTranslation } from "react-i18next";
-import { logoutUser } from "@/ui/main-axios.ts";
-
-import {
- Sidebar,
- SidebarContent,
- SidebarFooter,
- SidebarGroup,
- SidebarGroupLabel,
- SidebarMenu,
- SidebarMenuButton,
- SidebarMenuItem,
- SidebarProvider,
- SidebarInset,
- SidebarHeader,
-} from "@/components/ui/sidebar.tsx";
-
-import { Separator } from "@/components/ui/separator.tsx";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from "@radix-ui/react-dropdown-menu";
-import { Input } from "@/components/ui/input.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { FolderCard } from "@/ui/desktop/navigation/hosts/FolderCard.tsx";
-import { getSSHHosts, getSSHFolders } from "@/ui/main-axios.ts";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
-import type { SSHFolder, SSHHost } from "@/types/index.ts";
-
-interface SidebarProps {
- disabled?: boolean;
- isAdmin?: boolean;
- username?: string | null;
- children?: React.ReactNode;
- onLogout?: () => void;
-}
-
-async function handleLogout() {
- try {
- await logoutUser();
-
- window.location.reload();
- } catch (error) {
- console.error("Logout failed:", error);
- window.location.reload();
- }
-}
-
-export function LeftSidebar({
- disabled,
- isAdmin,
- username,
- children,
- onLogout,
-}: SidebarProps): React.ReactElement {
- const { t } = useTranslation();
-
- const [isSidebarOpen, setIsSidebarOpen] = useState<boolean>(() => {
- const saved = localStorage.getItem("leftSidebarOpen");
- return saved !== null ? JSON.parse(saved) : true;
- });
-
- const {
- tabs: tabList,
- addTab,
- setCurrentTab,
- allSplitScreenTab,
- } = useTabs() as {
- tabs: Array<{ id: number; type: string; [key: string]: unknown }>;
- addTab: (tab: { type: string; [key: string]: unknown }) => number;
- setCurrentTab: (id: number) => void;
- allSplitScreenTab: number[];
- };
- const isSplitScreenActive =
- Array.isArray(allSplitScreenTab) && allSplitScreenTab.length > 0;
- const sshManagerTab = tabList.find((t) => t.type === "ssh_manager");
- const openSshManagerTab = () => {
- if (isSplitScreenActive) return;
- if (sshManagerTab) {
- setCurrentTab(sshManagerTab.id);
- return;
- }
- const id = addTab({ type: "ssh_manager", title: t("nav.hostManager") });
- setCurrentTab(id);
- };
- const adminTab = tabList.find((t) => t.type === "admin");
- const openAdminTab = () => {
- if (isSplitScreenActive) return;
- if (adminTab) {
- setCurrentTab(adminTab.id);
- return;
- }
- const id = addTab({ type: "admin" });
- setCurrentTab(id);
- };
- const userProfileTab = tabList.find((t) => t.type === "user_profile");
- const openUserProfileTab = () => {
- if (isSplitScreenActive) return;
- if (userProfileTab) {
- setCurrentTab(userProfileTab.id);
- return;
- }
- const id = addTab({ type: "user_profile" });
- setCurrentTab(id);
- };
-
- const [hosts, setHosts] = useState<SSHHost[]>([]);
- const [hostsLoading] = useState(false);
- const [hostsError, setHostsError] = useState<string | null>(null);
- const prevHostsRef = React.useRef<SSHHost[]>([]);
- const [search, setSearch] = useState("");
- const [debouncedSearch, setDebouncedSearch] = useState("");
- const [folderMetadata, setFolderMetadata] = useState<Map<string, SSHFolder>>(
- new Map(),
- );
-
- const fetchFolderMetadata = React.useCallback(async () => {
- try {
- const folders = await getSSHFolders();
- const metadataMap = new Map<string, SSHFolder>();
- folders.forEach((folder) => {
- metadataMap.set(folder.name, folder);
- });
- setFolderMetadata(metadataMap);
- } catch (error) {
- console.error("Failed to fetch folder metadata:", error);
- }
- }, []);
-
- const fetchHosts = React.useCallback(async () => {
- try {
- const newHosts = await getSSHHosts();
- const prevHosts = prevHostsRef.current;
-
- const existingHostsMap = new Map(prevHosts.map((h) => [h.id, h]));
- const newHostsMap = new Map(newHosts.map((h) => [h.id, h]));
-
- let hasChanges = false;
-
- if (newHosts.length !== prevHosts.length) {
- hasChanges = true;
- } else {
- for (const [id, newHost] of newHostsMap) {
- const existingHost = existingHostsMap.get(id);
- if (!existingHost) {
- hasChanges = true;
- break;
- }
-
- if (
- newHost.name !== existingHost.name ||
- newHost.folder !== existingHost.folder ||
- newHost.ip !== existingHost.ip ||
- newHost.port !== existingHost.port ||
- newHost.username !== existingHost.username ||
- newHost.pin !== existingHost.pin ||
- newHost.enableTerminal !== existingHost.enableTerminal ||
- newHost.enableTunnel !== existingHost.enableTunnel ||
- newHost.enableFileManager !== existingHost.enableFileManager ||
- newHost.authType !== existingHost.authType ||
- newHost.password !== existingHost.password ||
- newHost.key !== existingHost.key ||
- newHost.keyPassword !== existingHost.keyPassword ||
- newHost.keyType !== existingHost.keyType ||
- newHost.defaultPath !== existingHost.defaultPath ||
- JSON.stringify(newHost.tags) !==
- JSON.stringify(existingHost.tags) ||
- JSON.stringify(newHost.tunnelConnections) !==
- JSON.stringify(existingHost.tunnelConnections)
- ) {
- hasChanges = true;
- break;
- }
- }
- }
-
- if (hasChanges) {
- setTimeout(() => {
- setHosts(newHosts);
- prevHostsRef.current = newHosts;
- }, 50);
- }
- } catch {
- setHostsError(t("leftSidebar.failedToLoadHosts"));
- }
- }, [t]);
-
- const fetchHostsRef = React.useRef(fetchHosts);
- const fetchFolderMetadataRef = React.useRef(fetchFolderMetadata);
-
- React.useEffect(() => {
- fetchHostsRef.current = fetchHosts;
- fetchFolderMetadataRef.current = fetchFolderMetadata;
- });
-
- React.useEffect(() => {
- fetchHostsRef.current();
- fetchFolderMetadataRef.current();
- const interval = setInterval(() => {
- fetchHostsRef.current();
- fetchFolderMetadataRef.current();
- }, 300000);
- return () => clearInterval(interval);
- }, []);
-
- React.useEffect(() => {
- const handleHostsChanged = () => {
- fetchHostsRef.current();
- fetchFolderMetadataRef.current();
- };
- const handleCredentialsChanged = () => {
- fetchHostsRef.current();
- };
- const handleFoldersChanged = () => {
- fetchFolderMetadataRef.current();
- };
- window.addEventListener(
- "ssh-hosts:changed",
- handleHostsChanged as EventListener,
- );
- window.addEventListener(
- "credentials:changed",
- handleCredentialsChanged as EventListener,
- );
- window.addEventListener(
- "folders:changed",
- handleFoldersChanged as EventListener,
- );
- return () => {
- window.removeEventListener(
- "ssh-hosts:changed",
- handleHostsChanged as EventListener,
- );
- window.removeEventListener(
- "credentials:changed",
- handleCredentialsChanged as EventListener,
- );
- window.removeEventListener(
- "folders:changed",
- handleFoldersChanged as EventListener,
- );
- };
- }, []);
-
- React.useEffect(() => {
- const handler = setTimeout(() => setDebouncedSearch(search), 200);
- return () => clearTimeout(handler);
- }, [search]);
-
- React.useEffect(() => {
- localStorage.setItem("leftSidebarOpen", JSON.stringify(isSidebarOpen));
- }, [isSidebarOpen]);
-
- const [sidebarWidth, setSidebarWidth] = useState<number>(() => {
- const saved = localStorage.getItem("leftSidebarWidth");
- const defaultWidth = 250;
- const savedWidth = saved !== null ? parseInt(saved, 10) : defaultWidth;
- const minWidth = Math.min(200, Math.floor(window.innerWidth * 0.15));
- const maxWidth = Math.floor(window.innerWidth * 0.3);
- return Math.min(savedWidth, Math.max(minWidth, maxWidth));
- });
-
- const [isResizing, setIsResizing] = useState(false);
- const startXRef = React.useRef<number | null>(null);
- const startWidthRef = React.useRef<number>(sidebarWidth);
-
- React.useEffect(() => {
- localStorage.setItem("leftSidebarWidth", String(sidebarWidth));
- }, [sidebarWidth]);
-
- React.useEffect(() => {
- const handleResize = () => {
- const minWidth = Math.min(200, Math.floor(window.innerWidth * 0.15));
- const maxWidth = Math.floor(window.innerWidth * 0.3);
- if (sidebarWidth > maxWidth) {
- setSidebarWidth(Math.max(minWidth, maxWidth));
- } else if (sidebarWidth < minWidth) {
- setSidebarWidth(minWidth);
- }
- };
- window.addEventListener("resize", handleResize);
- return () => window.removeEventListener("resize", handleResize);
- }, [sidebarWidth]);
-
- const handleMouseDown = (e: React.MouseEvent) => {
- e.preventDefault();
- setIsResizing(true);
- startXRef.current = e.clientX;
- startWidthRef.current = sidebarWidth;
- };
-
- React.useEffect(() => {
- if (!isResizing) return;
-
- const handleMouseMove = (e: MouseEvent) => {
- if (startXRef.current == null) return;
- const dx = e.clientX - startXRef.current;
- const newWidth = Math.round(startWidthRef.current + dx);
- const minWidth = Math.min(200, Math.floor(window.innerWidth * 0.15));
- const maxWidth = Math.round(window.innerWidth * 0.3);
- if (newWidth >= minWidth && newWidth <= maxWidth) {
- setSidebarWidth(newWidth);
- } else if (newWidth < minWidth) {
- setSidebarWidth(minWidth);
- } else if (newWidth > maxWidth) {
- setSidebarWidth(maxWidth);
- }
- };
-
- const handleMouseUp = () => {
- setIsResizing(false);
- startXRef.current = null;
- };
-
- document.addEventListener("mousemove", handleMouseMove);
- document.addEventListener("mouseup", handleMouseUp);
- document.body.style.cursor = "col-resize";
- document.body.style.userSelect = "none";
-
- return () => {
- document.removeEventListener("mousemove", handleMouseMove);
- document.removeEventListener("mouseup", handleMouseUp);
- document.body.style.cursor = "";
- document.body.style.userSelect = "";
- };
- }, [isResizing]);
-
- const filteredHosts = React.useMemo(() => {
- if (!debouncedSearch.trim()) return hosts;
- const searchQuery = debouncedSearch.trim().toLowerCase();
-
- return hosts.filter((h) => {
- const fieldMatches: Record<string, string> = {};
- let remainingQuery = searchQuery;
-
- const fieldPattern = /(\w+):([^\s]+)/g;
- let match;
- while ((match = fieldPattern.exec(searchQuery)) !== null) {
- const [fullMatch, field, value] = match;
- fieldMatches[field] = value;
- remainingQuery = remainingQuery.replace(fullMatch, "").trim();
- }
-
- for (const [field, value] of Object.entries(fieldMatches)) {
- switch (field) {
- case "tag":
- case "tags": {
- const tags = Array.isArray(h.tags) ? h.tags : [];
- const hasMatchingTag = tags.some((tag) =>
- tag.toLowerCase().includes(value),
- );
- if (!hasMatchingTag) return false;
- break;
- }
- case "name":
- if (!(h.name || "").toLowerCase().includes(value)) return false;
- break;
- case "user":
- case "username":
- if (!h.username.toLowerCase().includes(value)) return false;
- break;
- case "ip":
- case "host":
- if (!h.ip.toLowerCase().includes(value)) return false;
- break;
- case "port":
- if (!String(h.port).includes(value)) return false;
- break;
- case "folder":
- if (!(h.folder || "").toLowerCase().includes(value)) return false;
- break;
- case "auth":
- case "authtype":
- if (!h.authType.toLowerCase().includes(value)) return false;
- break;
- case "path":
- if (!(h.defaultPath || "").toLowerCase().includes(value))
- return false;
- break;
- }
- }
-
- if (remainingQuery) {
- const searchableText = [
- h.name || "",
- h.username,
- h.ip,
- h.folder || "",
- ...(h.tags || []),
- h.authType,
- h.defaultPath || "",
- ]
- .join(" ")
- .toLowerCase();
- if (!searchableText.includes(remainingQuery)) return false;
- }
-
- return true;
- });
- }, [hosts, debouncedSearch]);
-
- const hostsByFolder = React.useMemo(() => {
- const map: Record<string, SSHHost[]> = {};
- filteredHosts.forEach((h) => {
- const folder =
- h.folder && h.folder.trim() ? h.folder : t("leftSidebar.noFolder");
- if (!map[folder]) map[folder] = [];
- map[folder].push(h);
- });
- return map;
- }, [filteredHosts]);
-
- const sortedFolders = React.useMemo(() => {
- const folders = Object.keys(hostsByFolder);
- folders.sort((a, b) => {
- if (a === t("leftSidebar.noFolder")) return -1;
- if (b === t("leftSidebar.noFolder")) return 1;
- return a.localeCompare(b);
- });
- return folders;
- }, [hostsByFolder]);
-
- const getSortedHosts = React.useCallback((arr: SSHHost[]) => {
- const pinned = arr
- .filter((h) => h.pin)
- .sort((a, b) => (a.name || "").localeCompare(b.name || ""));
- const rest = arr
- .filter((h) => !h.pin)
- .sort((a, b) => (a.name || "").localeCompare(b.name || ""));
- return [...pinned, ...rest];
- }, []);
-
- return (
- <div className="h-screen w-screen overflow-hidden">
- <SidebarProvider
- open={isSidebarOpen}
- style={
- { "--sidebar-width": `${sidebarWidth}px` } as React.CSSProperties
- }
- >
- <div className="flex h-screen w-screen overflow-hidden">
- <Sidebar variant="floating">
- <SidebarHeader>
- <SidebarGroupLabel className="text-lg font-bold text-foreground">
- {t("common.appName")}
- <div className="absolute right-5 flex gap-1">
- <Button
- variant="outline"
- onClick={() => setSidebarWidth(250)}
- className="w-[28px] h-[28px]"
- title={t("common.resetSidebarWidth")}
- >
- <RotateCcw className="h-4 w-4" />
- </Button>
- <Button
- variant="outline"
- onClick={() => setIsSidebarOpen(!isSidebarOpen)}
- className="w-[28px] h-[28px]"
- title={t("common.toggleSidebar")}
- >
- <Menu className="h-4 w-4" />
- </Button>
- </div>
- </SidebarGroupLabel>
- </SidebarHeader>
- <Separator className="p-0.25" />
- <SidebarContent>
- <SidebarGroup className="!m-0 !p-0 !-mb-2">
- <Button
- className="m-2 flex flex-row font-semibold border-2 !border-edge"
- variant="outline"
- onClick={openSshManagerTab}
- disabled={isSplitScreenActive}
- title={
- isSplitScreenActive
- ? t("interface.disabledDuringSplitScreen")
- : undefined
- }
- >
- <HardDrive strokeWidth="2.5" />
- {t("nav.hostManager")}
- </Button>
- </SidebarGroup>
- <Separator className="p-0.25" />
- <SidebarGroup className="flex flex-col gap-y-2 !-mt-2">
- <div className="!bg-field rounded-lg">
- <Input
- value={search}
- onChange={(e) => setSearch(e.target.value)}
- placeholder={t("placeholders.searchHostsAny")}
- className="w-full h-8 text-sm border-2 !bg-field border-edge rounded-md"
- autoComplete="off"
- />
- </div>
-
- {hostsError && (
- <div className="!bg-field rounded-lg">
- <div className="w-full h-8 text-sm border-2 !bg-field border-edge rounded-md px-3 py-1.5 flex items-center text-red-500">
- {t("leftSidebar.failedToLoadHosts")}
- </div>
- </div>
- )}
-
- {hostsLoading && (
- <div className="px-4 pb-2">
- <div className="text-xs text-muted-foreground text-center">
- {t("hosts.loadingHosts")}
- </div>
- </div>
- )}
-
- {sortedFolders.map((folder, idx) => {
- const metadata = folderMetadata.get(folder);
- return (
- <FolderCard
- key={`folder-${folder}`}
- folderName={folder}
- hosts={getSortedHosts(hostsByFolder[folder])}
- isFirst={idx === 0}
- isLast={idx === sortedFolders.length - 1}
- folderColor={metadata?.color}
- folderIcon={metadata?.icon}
- />
- );
- })}
- </SidebarGroup>
- </SidebarContent>
- <Separator className="p-0.25 mt-1 mb-1" />
- <SidebarFooter>
- <SidebarMenu>
- <SidebarMenuItem>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <SidebarMenuButton
- className="data-[state=open]:opacity-90 w-full"
- disabled={disabled}
- >
- <User2 /> {username ? username : t("common.logout")}
- <ChevronUp className="ml-auto" />
- </SidebarMenuButton>
- </DropdownMenuTrigger>
- <DropdownMenuContent
- side="top"
- align="start"
- sideOffset={6}
- className="min-w-[var(--radix-popper-anchor-width)] bg-sidebar-accent text-sidebar-accent-foreground border border-border rounded-md shadow-2xl p-1"
- >
- <DropdownMenuItem
- className="rounded px-2 py-1.5 hover:bg-surface-hover hover:text-accent-foreground focus:bg-surface-hover focus:text-accent-foreground cursor-pointer focus:outline-none"
- onClick={() => {
- openUserProfileTab();
- }}
- >
- <span>{t("profile.title")}</span>
- </DropdownMenuItem>
- {isAdmin && (
- <DropdownMenuItem
- className="rounded px-2 py-1.5 hover:bg-surface-hover hover:text-accent-foreground focus:bg-surface-hover focus:text-accent-foreground cursor-pointer focus:outline-none"
- onClick={() => {
- if (isAdmin) openAdminTab();
- }}
- >
- <span>{t("admin.title")}</span>
- </DropdownMenuItem>
- )}
- <DropdownMenuItem
- className="rounded px-2 py-1.5 hover:bg-surface-hover hover:text-accent-foreground focus:bg-surface-hover focus:text-accent-foreground cursor-pointer focus:outline-none"
- onClick={onLogout || handleLogout}
- >
- <span>{t("common.logout")}</span>
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </SidebarMenuItem>
- </SidebarMenu>
- </SidebarFooter>
- {isSidebarOpen && (
- <div
- className="absolute top-0 h-full cursor-col-resize z-[60]"
- onMouseDown={handleMouseDown}
- style={{
- right: "-4px",
- width: "8px",
- backgroundColor: isResizing
- ? "var(--bg-interact)"
- : "transparent",
- }}
- onMouseEnter={(e) => {
- if (!isResizing) {
- e.currentTarget.style.backgroundColor =
- "var(--border-hover)";
- }
- }}
- onMouseLeave={(e) => {
- if (!isResizing) {
- e.currentTarget.style.backgroundColor = "transparent";
- }
- }}
- title={t("common.dragToResizeSidebar")}
- />
- )}
- </Sidebar>
-
- <SidebarInset>{children}</SidebarInset>
- </div>
- </SidebarProvider>
-
- {!isSidebarOpen && (
- <div
- onClick={() => setIsSidebarOpen(true)}
- className="fixed top-0 left-0 w-[10px] h-full cursor-pointer flex items-center justify-center rounded-tr-md rounded-br-md"
- style={{
- zIndex: 9999,
- backgroundColor: "var(--bg-base)",
- border: "2px solid var(--border-base)",
- borderLeft: "none",
- }}
- >
- <ChevronRight size={10} />
- </div>
- )}
- </div>
- );
-}
diff --git a/src/ui/desktop/navigation/TopNavbar.tsx b/src/ui/desktop/navigation/TopNavbar.tsx
deleted file mode 100644
index 7da1a49e9..000000000
--- a/src/ui/desktop/navigation/TopNavbar.tsx
+++ /dev/null
@@ -1,590 +0,0 @@
-import React, { useState } from "react";
-import { flushSync } from "react-dom";
-import { useSidebar } from "@/components/ui/sidebar.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { ChevronDown, ChevronUpIcon, Hammer, Zap } from "lucide-react";
-import { Tab } from "@/ui/desktop/navigation/tabs/Tab.tsx";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
-import { useTranslation } from "react-i18next";
-import { TabDropdown } from "@/ui/desktop/navigation/tabs/TabDropdown.tsx";
-import { SSHToolsSidebar } from "@/ui/desktop/apps/tools/SSHToolsSidebar.tsx";
-import { useCommandHistory } from "@/ui/desktop/apps/features/terminal/command-history/CommandHistoryContext.tsx";
-import { QuickConnectDialog } from "@/ui/desktop/navigation/dialogs/QuickConnectDialog.tsx";
-
-import type { TabContextTab } from "@/types";
-
-type TabData = TabContextTab;
-
-interface TopNavbarProps {
- isTopbarOpen: boolean;
- setIsTopbarOpen: (open: boolean) => void;
- onRightSidebarStateChange?: (isOpen: boolean, width: number) => void;
-}
-
-export function TopNavbar({
- isTopbarOpen,
- setIsTopbarOpen,
- onRightSidebarStateChange,
-}: TopNavbarProps): React.ReactElement {
- const { state } = useSidebar();
- const {
- tabs,
- currentTab,
- setCurrentTab,
- removeTab,
- allSplitScreenTab,
- reorderTabs,
- updateTab,
- setPreviewTerminalTheme,
- } = useTabs();
- const leftPosition =
- state === "collapsed" ? "26px" : "calc(var(--sidebar-width) + 8px)";
- const { t } = useTranslation();
- const commandHistory = useCommandHistory();
-
- const [toolsSidebarOpen, setToolsSidebarOpen] = useState(false);
- const [commandHistoryTabActive, setCommandHistoryTabActive] = useState(false);
- const [splitScreenTabActive, setSplitScreenTabActive] = useState(false);
- const [quickConnectOpen, setQuickConnectOpen] = useState(false);
- const [rightSidebarWidth, setRightSidebarWidth] = useState<number>(() => {
- const saved = localStorage.getItem("rightSidebarWidth");
- const defaultWidth = 400;
- const savedWidth = saved !== null ? parseInt(saved, 10) : defaultWidth;
- const minWidth = Math.min(300, Math.floor(window.innerWidth * 0.2));
- const maxWidth = Math.floor(window.innerWidth * 0.3);
- return Math.min(savedWidth, Math.max(minWidth, maxWidth));
- });
-
- React.useEffect(() => {
- localStorage.setItem("rightSidebarWidth", String(rightSidebarWidth));
- }, [rightSidebarWidth]);
-
- React.useEffect(() => {
- const handleResize = () => {
- const minWidth = Math.min(300, Math.floor(window.innerWidth * 0.2));
- const maxWidth = Math.floor(window.innerWidth * 0.3);
- if (rightSidebarWidth > maxWidth) {
- setRightSidebarWidth(Math.max(minWidth, maxWidth));
- } else if (rightSidebarWidth < minWidth) {
- setRightSidebarWidth(minWidth);
- }
- };
- window.addEventListener("resize", handleResize);
- return () => window.removeEventListener("resize", handleResize);
- }, [rightSidebarWidth]);
-
- React.useEffect(() => {
- if (onRightSidebarStateChange) {
- onRightSidebarStateChange(toolsSidebarOpen, rightSidebarWidth);
- }
- }, [toolsSidebarOpen, rightSidebarWidth, onRightSidebarStateChange]);
-
- const openCommandHistorySidebar = React.useCallback(() => {
- setToolsSidebarOpen(true);
- setCommandHistoryTabActive(true);
- }, []);
-
- React.useEffect(() => {
- commandHistory.setOpenCommandHistory(openCommandHistorySidebar);
- }, [commandHistory, openCommandHistorySidebar]);
-
- const rightPosition = toolsSidebarOpen
- ? `calc(var(--right-sidebar-width, ${rightSidebarWidth}px) + 8px)`
- : "17px";
- const [justDroppedTabId, setJustDroppedTabId] = useState<number | null>(null);
- const [isInDropAnimation, setIsInDropAnimation] = useState(false);
- const [dragState, setDragState] = useState<{
- draggedId: number | null;
- draggedIndex: number | null;
- currentX: number;
- startX: number;
- targetIndex: number | null;
- }>({
- draggedId: null,
- draggedIndex: null,
- currentX: 0,
- startX: 0,
- targetIndex: null,
- });
- const containerRef = React.useRef<HTMLDivElement | null>(null);
- const tabRefs = React.useRef<Map<number, HTMLDivElement>>(new Map());
- const isProcessingDropRef = React.useRef(false);
-
- const prevTabsRef = React.useRef<TabData[]>([]);
-
- const handleTabActivate = (tabId: number) => {
- setCurrentTab(tabId);
- };
-
- const handleTabSplit = () => {
- setToolsSidebarOpen(true);
- setCommandHistoryTabActive(false);
- setSplitScreenTabActive(true);
- };
-
- const handleTabClose = (tabId: number) => {
- removeTab(tabId);
- };
-
- const handleSnippetExecute = (content: string) => {
- const tab = tabs.find((t: TabData) => t.id === currentTab);
- if (tab?.terminalRef?.current?.sendInput) {
- tab.terminalRef.current.sendInput(content + "\r");
- }
- };
-
- React.useEffect(() => {
- if (prevTabsRef.current.length > 0 && tabs !== prevTabsRef.current) {
- prevTabsRef.current = [];
- }
- }, [tabs]);
-
- React.useEffect(() => {
- if (justDroppedTabId !== null) {
- const timer = setTimeout(() => setJustDroppedTabId(null), 50);
- return () => clearTimeout(timer);
- }
- }, [justDroppedTabId]);
-
- const handleDragStart = (e: React.DragEvent, index: number) => {
- const img = new Image();
- img.src =
- "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
- e.dataTransfer.setDragImage(img, 0, 0);
-
- setDragState({
- draggedId: tabs[index].id,
- draggedIndex: index,
- startX: e.clientX,
- currentX: e.clientX,
- targetIndex: index,
- });
- };
-
- const handleDrag = (e: React.DragEvent) => {
- if (e.clientX === 0) return;
- if (dragState.draggedIndex === null) return;
-
- setDragState((prev) => ({
- ...prev,
- currentX: e.clientX,
- }));
- };
-
- const calculateTargetIndex = () => {
- if (!containerRef.current || dragState.draggedIndex === null) return null;
-
- const draggedIndex = dragState.draggedIndex;
-
- const tabBoundaries: {
- index: number;
- start: number;
- end: number;
- mid: number;
- }[] = [];
- let accumulatedX = 0;
-
- tabs.forEach((tab, i) => {
- const tabEl = tabRefs.current.get(i);
- if (!tabEl) return;
-
- const tabWidth = tabEl.getBoundingClientRect().width;
- tabBoundaries.push({
- index: i,
- start: accumulatedX,
- end: accumulatedX + tabWidth,
- mid: accumulatedX + tabWidth / 2,
- });
- accumulatedX += tabWidth + 4;
- });
-
- if (tabBoundaries.length === 0) return null;
-
- const containerRect = containerRef.current.getBoundingClientRect();
- const draggedTab = tabBoundaries[draggedIndex];
- const currentX = dragState.currentX - containerRect.left;
- const startX = dragState.startX - containerRect.left;
- const offset = currentX - startX;
- const draggedCenter = draggedTab.mid + offset;
-
- let newTargetIndex = draggedIndex;
-
- if (offset < 0) {
- for (let i = draggedIndex - 1; i >= 0; i--) {
- if (draggedCenter < tabBoundaries[i].mid) {
- newTargetIndex = i;
- } else {
- break;
- }
- }
- } else if (offset > 0) {
- for (let i = draggedIndex + 1; i < tabBoundaries.length; i++) {
- if (draggedCenter > tabBoundaries[i].mid) {
- newTargetIndex = i;
- } else {
- break;
- }
- }
- const lastTabIndex = tabBoundaries.length - 1;
- if (lastTabIndex >= 0) {
- const lastTabEl = tabRefs.current.get(lastTabIndex);
- if (lastTabEl) {
- const lastTabRect = lastTabEl.getBoundingClientRect();
- const containerRect = containerRef.current.getBoundingClientRect();
- const lastTabEndInContainer = lastTabRect.right - containerRect.left;
- if (currentX > lastTabEndInContainer) {
- newTargetIndex = lastTabIndex;
- }
- }
- }
- }
-
- return newTargetIndex;
- };
-
- const handleDragOver = (e: React.DragEvent) => {
- e.preventDefault();
-
- if (dragState.draggedIndex === null) return;
-
- const containerRect = containerRef.current?.getBoundingClientRect();
- if (!containerRect) return;
-
- if (e.clientX !== 0) {
- setDragState((prev) => ({
- ...prev,
- currentX: e.clientX,
- }));
- }
-
- const newTargetIndex = calculateTargetIndex();
- if (newTargetIndex !== null && newTargetIndex !== dragState.targetIndex) {
- setDragState((prev) => ({
- ...prev,
- targetIndex: newTargetIndex,
- }));
- }
- };
-
- const handleDrop = (e: React.DragEvent) => {
- e.preventDefault();
-
- if (isProcessingDropRef.current) return;
- isProcessingDropRef.current = true;
-
- const fromIndex = dragState.draggedIndex;
- const toIndex = dragState.targetIndex;
- const draggedId = dragState.draggedId;
-
- if (fromIndex !== null && toIndex !== null && fromIndex !== toIndex) {
- prevTabsRef.current = tabs;
-
- flushSync(() => {
- setIsInDropAnimation(true);
- setDragState({
- draggedId: null,
- draggedIndex: null,
- startX: 0,
- currentX: 0,
- targetIndex: null,
- });
- });
-
- reorderTabs(fromIndex, toIndex);
-
- if (draggedId !== null) {
- setJustDroppedTabId(draggedId);
- }
- } else {
- setDragState({
- draggedId: null,
- draggedIndex: null,
- startX: 0,
- currentX: 0,
- targetIndex: null,
- });
- }
-
- setTimeout(() => {
- isProcessingDropRef.current = false;
- setIsInDropAnimation(false);
- }, 50);
- };
-
- const handleDragEnd = () => {
- setIsInDropAnimation(false);
- setDragState({
- draggedId: null,
- draggedIndex: null,
- startX: 0,
- currentX: 0,
- targetIndex: null,
- });
- };
-
- const isSplitScreenActive =
- Array.isArray(allSplitScreenTab) && allSplitScreenTab.length > 0;
- return (
- <div>
- <div
- className="fixed z-10 h-[50px] border-2 border-edge rounded-lg flex flex-row transform-none m-0 p-0"
- style={{
- top: isTopbarOpen ? "0.5rem" : "-3rem",
- left: leftPosition,
- right: rightPosition,
- backgroundColor: "var(--bg-base)",
- transition: "top 200ms linear, left 200ms linear, right 200ms linear",
- }}
- >
- <div
- ref={containerRef}
- className="h-full p-1 pr-2 border-r-2 border-edge w-[calc(100%-6rem)] flex items-center overflow-x-auto overflow-y-hidden skinny-scrollbar gap-1"
- >
- {tabs.map((tab: TabData, index: number) => {
- const isActive = tab.id === currentTab;
- const isSplit =
- Array.isArray(allSplitScreenTab) &&
- allSplitScreenTab.includes(tab.id);
- const isTerminal = tab.type === "terminal";
- const isServer = tab.type === "server_stats";
- const isFileManager = tab.type === "file_manager";
- const isTunnel = tab.type === "tunnel";
- const isDocker = tab.type === "docker";
- const isSshManager = tab.type === "ssh_manager";
- const isAdmin = tab.type === "admin";
- const isUserProfile = tab.type === "user_profile";
- const isRdp = tab.type === "rdp";
- const isVnc = tab.type === "vnc";
- const isTelnet = tab.type === "telnet";
- const isSplittable =
- isTerminal || isServer || isFileManager || isTunnel || isDocker;
- const disableSplit = !isSplittable;
- const disableActivate =
- isSplit ||
- ((tab.type === "home" ||
- tab.type === "ssh_manager" ||
- tab.type === "admin" ||
- tab.type === "user_profile" ||
- tab.type === "network_graph") &&
- isSplitScreenActive);
- const isHome = tab.type === "home";
- const disableClose = isHome;
-
- const isDraggingThisTab = dragState.draggedIndex === index;
- const isDroppedAndSnapping = tab.id === justDroppedTabId;
- const dragOffset = isDraggingThisTab
- ? dragState.currentX - dragState.startX
- : 0;
-
- let transform = "";
-
- if (!isInDropAnimation) {
- if (isDraggingThisTab) {
- transform = `translateX(${dragOffset}px)`;
- } else if (
- dragState.draggedIndex !== null &&
- dragState.targetIndex !== null
- ) {
- const draggedOriginalIndex = dragState.draggedIndex;
- const currentTargetIndex = dragState.targetIndex;
-
- if (
- draggedOriginalIndex < currentTargetIndex &&
- index > draggedOriginalIndex &&
- index <= currentTargetIndex
- ) {
- const draggedTabWidth =
- tabRefs.current
- .get(draggedOriginalIndex)
- ?.getBoundingClientRect().width || 0;
- const gap = 4;
- transform = `translateX(-${draggedTabWidth + gap}px)`;
- } else if (
- draggedOriginalIndex > currentTargetIndex &&
- index >= currentTargetIndex &&
- index < draggedOriginalIndex
- ) {
- const draggedTabWidth =
- tabRefs.current
- .get(draggedOriginalIndex)
- ?.getBoundingClientRect().width || 0;
- const gap = 4;
- transform = `translateX(${draggedTabWidth + gap}px)`;
- }
- }
- }
-
- return (
- <div
- key={tab.id}
- ref={(el) => {
- if (el) {
- tabRefs.current.set(index, el);
- } else {
- tabRefs.current.delete(index);
- }
- }}
- draggable={true}
- onDragStart={(e) => {
- e.stopPropagation();
- handleDragStart(e, index);
- }}
- onDrag={handleDrag}
- onDragOver={handleDragOver}
- onDrop={handleDrop}
- onDragEnd={handleDragEnd}
- onMouseDown={(e) => {
- if (e.button === 1 && !disableClose) {
- e.preventDefault();
- handleTabClose(tab.id);
- }
- }}
- style={{
- transform,
- transition:
- isDraggingThisTab ||
- isDroppedAndSnapping ||
- isInDropAnimation
- ? "none"
- : "transform 200ms ease-out",
- zIndex: isDraggingThisTab ? 1000 : 1,
- position: "relative",
- cursor: isDraggingThisTab ? "grabbing" : "grab",
- userSelect: "none",
- WebkitUserSelect: "none",
- flex: tab.type === "home" ? "0 0 auto" : "1 1 150px",
- minWidth: tab.type === "home" ? "auto" : "150px",
- maxWidth: tab.type === "home" ? "auto" : "450px",
- display: "flex",
- }}
- >
- <Tab
- tabType={tab.type}
- title={tab.title}
- isActive={isActive}
- isSplit={isSplit}
- onActivate={() => handleTabActivate(tab.id)}
- onClose={
- isTerminal ||
- isServer ||
- isFileManager ||
- isTunnel ||
- isDocker ||
- isSshManager ||
- isAdmin ||
- isUserProfile ||
- isRdp ||
- isVnc ||
- isTelnet ||
- tab.type === "network_graph"
- ? () => handleTabClose(tab.id)
- : undefined
- }
- onSplit={isSplittable ? handleTabSplit : undefined}
- canSplit={isSplittable}
- canClose={
- isTerminal ||
- isServer ||
- isFileManager ||
- isTunnel ||
- isDocker ||
- isSshManager ||
- isAdmin ||
- isUserProfile ||
- isRdp ||
- isVnc ||
- isTelnet ||
- tab.type === "network_graph"
- }
- disableActivate={disableActivate}
- disableSplit={disableSplit}
- disableClose={disableClose}
- isDragging={isDraggingThisTab}
- isDragOver={false}
- hostConfig={tab.hostConfig}
- onOpenFileManager={
- isTerminal && (tab.hostConfig as any)?.enableFileManager
- ? () => tab.terminalRef?.current?.openFileManager?.()
- : undefined
- }
- />
- </div>
- );
- })}
- </div>
-
- <div className="flex items-center justify-center gap-2 flex-1 px-2">
- <TabDropdown />
-
- <Button
- variant="outline"
- onClick={() => setToolsSidebarOpen(!toolsSidebarOpen)}
- className="w-[30px] h-[30px] border-edge"
- title={t("nav.tools")}
- >
- <Hammer className="h-4 w-4" />
- </Button>
-
- <Button
- variant="outline"
- onClick={() => setQuickConnectOpen(true)}
- className="w-[30px] h-[30px] border-edge"
- title={t("quickConnect.title")}
- >
- <Zap className="h-4 w-4" />
- </Button>
-
- <Button
- variant="outline"
- onClick={() => setIsTopbarOpen(false)}
- className="w-[30px] h-[30px]"
- >
- <ChevronUpIcon />
- </Button>
- </div>
- </div>
-
- {!isTopbarOpen && (
- <div
- onClick={() => setIsTopbarOpen(true)}
- className="fixed top-0 cursor-pointer flex items-center justify-center rounded-bl-md rounded-br-md"
- style={{
- left: leftPosition,
- right: rightPosition,
- height: "10px",
- zIndex: 9999,
- backgroundColor: "var(--bg-base)",
- border: "2px solid var(--border-base)",
- borderTop: "none",
- }}
- >
- <ChevronDown size={10} />
- </div>
- )}
-
- <SSHToolsSidebar
- isOpen={toolsSidebarOpen}
- onClose={() => setToolsSidebarOpen(false)}
- onSnippetExecute={handleSnippetExecute}
- sidebarWidth={rightSidebarWidth}
- setSidebarWidth={setRightSidebarWidth}
- initialTab={
- commandHistoryTabActive
- ? "command-history"
- : splitScreenTabActive
- ? "split-screen"
- : undefined
- }
- onTabChange={() => {
- setCommandHistoryTabActive(false);
- setSplitScreenTabActive(false);
- }}
- />
-
- <QuickConnectDialog
- open={quickConnectOpen}
- onOpenChange={setQuickConnectOpen}
- />
- </div>
- );
-}
diff --git a/src/ui/desktop/navigation/dialogs/QuickConnectDialog.tsx b/src/ui/desktop/navigation/dialogs/QuickConnectDialog.tsx
deleted file mode 100644
index fc926e168..000000000
--- a/src/ui/desktop/navigation/dialogs/QuickConnectDialog.tsx
+++ /dev/null
@@ -1,648 +0,0 @@
-import React, { useState, useEffect, useRef } from "react";
-import { useForm, Controller, type Resolver } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { z } from "zod";
-import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogFooter,
- DialogHeader,
- DialogTitle,
-} from "@/components/ui/dialog.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import {
- Form,
- FormControl,
- FormField,
- FormItem,
- FormLabel,
-} from "@/components/ui/form.tsx";
-import {
- Tabs,
- TabsContent,
- TabsList,
- TabsTrigger,
-} from "@/components/ui/tabs.tsx";
-import { Switch } from "@/components/ui/switch.tsx";
-import { CredentialSelector } from "@/ui/desktop/apps/host-manager/credentials/CredentialSelector.tsx";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
-import { quickConnect } from "@/ui/main-axios.ts";
-import { useTranslation } from "react-i18next";
-import { toast } from "sonner";
-import CodeMirror from "@uiw/react-codemirror";
-import { oneDark } from "@codemirror/theme-one-dark";
-import { githubLight } from "@uiw/codemirror-theme-github";
-import { EditorView } from "@codemirror/view";
-import { useTheme } from "@/components/theme-provider.tsx";
-import type { SSHHost } from "@/types";
-
-interface QuickConnectDialogProps {
- open: boolean;
- onOpenChange: (open: boolean) => void;
-}
-
-const keyTypeOptions = [
- { value: "auto", label: "Auto Detect" },
- { value: "ssh-rsa", label: "RSA" },
- { value: "ssh-ed25519", label: "Ed25519" },
- { value: "ecdsa-sha2-nistp256", label: "ECDSA NIST P-256" },
- { value: "ecdsa-sha2-nistp384", label: "ECDSA NIST P-384" },
- { value: "ecdsa-sha2-nistp521", label: "ECDSA NIST P-521" },
- { value: "ssh-dss", label: "DSA" },
- { value: "ssh-rsa-sha2-256", label: "RSA SHA2-256" },
- { value: "ssh-rsa-sha2-512", label: "RSA SHA2-512" },
-];
-
-export function QuickConnectDialog({
- open,
- onOpenChange,
-}: QuickConnectDialogProps) {
- const { t } = useTranslation();
- const { theme: appTheme } = useTheme();
- const { addTab, setCurrentTab } = useTabs();
- const [authTab, setAuthTab] = useState<"password" | "key" | "credential">(
- "password",
- );
- const [keyInputMethod, setKeyInputMethod] = useState<"upload" | "paste">(
- "upload",
- );
- const [keyTypeDropdownOpen, setKeyTypeDropdownOpen] = useState(false);
- const keyTypeButtonRef = useRef<HTMLButtonElement>(null);
- const keyTypeDropdownRef = useRef<HTMLDivElement>(null);
- const [isConnecting, setIsConnecting] = useState(false);
-
- const isDarkMode =
- appTheme === "dark" ||
- (appTheme === "system" &&
- window.matchMedia("(prefers-color-scheme: dark)").matches);
- const editorTheme = isDarkMode ? oneDark : githubLight;
-
- const formSchema = z
- .object({
- ip: z.string().min(1, t("quickConnect.ipAddress")),
- port: z.coerce.number().min(1).max(65535).default(22),
- username: z.string().min(1, t("quickConnect.username")),
- authType: z.enum(["password", "key", "credential"]),
- password: z.string().optional(),
- key: z.any().optional(),
- keyPassword: z.string().optional(),
- keyType: z
- .enum([
- "auto",
- "ssh-rsa",
- "ssh-ed25519",
- "ecdsa-sha2-nistp256",
- "ecdsa-sha2-nistp384",
- "ecdsa-sha2-nistp521",
- "ssh-dss",
- "ssh-rsa-sha2-256",
- "ssh-rsa-sha2-512",
- ])
- .optional(),
- credentialId: z.number().optional().nullable(),
- overrideCredentialUsername: z.boolean().optional(),
- })
- .superRefine((data, ctx) => {
- if (data.authType === "password") {
- if (
- !data.password ||
- (typeof data.password === "string" && data.password.trim() === "")
- ) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: t("quickConnect.passwordRequired"),
- path: ["password"],
- });
- }
- } else if (data.authType === "key") {
- if (
- !data.key ||
- (typeof data.key === "string" && data.key.trim() === "")
- ) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: t("quickConnect.keyRequired"),
- path: ["key"],
- });
- }
- if (!data.keyType) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: t("hosts.keyTypeRequired"),
- path: ["keyType"],
- });
- }
- } else if (data.authType === "credential") {
- if (!data.credentialId) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: t("quickConnect.credentialRequired"),
- path: ["credentialId"],
- });
- }
- }
- });
-
- type FormData = z.infer<typeof formSchema>;
-
- const form = useForm<FormData>({
- resolver: zodResolver(formSchema) as unknown as Resolver<FormData>,
- mode: "all",
- defaultValues: {
- ip: "",
- port: 22,
- username: "",
- authType: "password" as const,
- password: "",
- key: null,
- keyPassword: "",
- keyType: "auto" as const,
- credentialId: null,
- overrideCredentialUsername: false,
- },
- });
-
- useEffect(() => {
- form.setValue("authType", authTab, { shouldValidate: true });
-
- if (authTab === "password") {
- form.setValue("key", null, { shouldValidate: true });
- form.setValue("keyPassword", "", { shouldValidate: true });
- form.setValue("keyType", "auto", { shouldValidate: true });
- form.setValue("credentialId", null, { shouldValidate: true });
- } else if (authTab === "key") {
- form.setValue("password", "", { shouldValidate: true });
- form.setValue("credentialId", null, { shouldValidate: true });
- } else if (authTab === "credential") {
- form.setValue("password", "", { shouldValidate: true });
- form.setValue("key", null, { shouldValidate: true });
- form.setValue("keyPassword", "", { shouldValidate: true });
- form.setValue("keyType", "auto", { shouldValidate: true });
- }
- }, [authTab, form]);
-
- useEffect(() => {
- function onClickOutside(event: MouseEvent) {
- if (
- keyTypeDropdownOpen &&
- keyTypeDropdownRef.current &&
- !keyTypeDropdownRef.current.contains(event.target as Node) &&
- keyTypeButtonRef.current &&
- !keyTypeButtonRef.current.contains(event.target as Node)
- ) {
- setKeyTypeDropdownOpen(false);
- }
- }
-
- document.addEventListener("mousedown", onClickOutside);
- return () => document.removeEventListener("mousedown", onClickOutside);
- }, [keyTypeDropdownOpen]);
-
- const handleConnect = async (connectionType: "terminal" | "file_manager") => {
- const formData = form.getValues();
-
- const isValid = await form.trigger();
- if (!isValid) {
- return;
- }
-
- setIsConnecting(true);
-
- try {
- let keyContent: string | undefined;
- if (formData.authType === "key" && formData.key) {
- if (formData.key instanceof File) {
- keyContent = await formData.key.text();
- } else if (typeof formData.key === "string") {
- keyContent = formData.key;
- }
- }
-
- const hostConfig = await quickConnect({
- ip: formData.ip,
- port: formData.port,
- username: formData.username,
- authType: formData.authType,
- password:
- formData.authType === "password" ? formData.password : undefined,
- key: formData.authType === "key" ? keyContent : undefined,
- keyPassword:
- formData.authType === "key" ? formData.keyPassword : undefined,
- keyType: formData.authType === "key" ? formData.keyType : undefined,
- credentialId:
- formData.authType === "credential"
- ? formData.credentialId
- : undefined,
- overrideCredentialUsername:
- formData.authType === "credential"
- ? formData.overrideCredentialUsername
- : undefined,
- });
-
- const tabId = addTab({
- type: connectionType,
- title: `${formData.username}@${formData.ip}:${formData.port}`,
- hostConfig: hostConfig as SSHHost,
- });
- setCurrentTab(tabId);
-
- form.reset();
- setAuthTab("password");
- setKeyInputMethod("upload");
- onOpenChange(false);
- } catch (error) {
- console.error("Quick connect failed:", error);
- toast.error(
- t("quickConnect.connectionFailed") +
- ": " +
- (error instanceof Error ? error.message : String(error)),
- );
- } finally {
- setIsConnecting(false);
- }
- };
-
- return (
- <Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent className="sm:max-w-[600px] bg-canvas border-2 border-edge max-h-[90vh] overflow-y-auto">
- <DialogHeader>
- <DialogTitle>{t("quickConnect.title")}</DialogTitle>
- <DialogDescription className="text-muted-foreground">
- {t("quickConnect.description")}
- </DialogDescription>
- </DialogHeader>
-
- <Form {...form}>
- <div className="space-y-4 py-4">
- <div className="grid grid-cols-12 gap-4">
- <FormField
- control={form.control}
- name="ip"
- render={({ field }) => (
- <FormItem className="col-span-8">
- <FormLabel className="text-base font-semibold text-foreground">
- {t("quickConnect.ipAddress")}
- </FormLabel>
- <FormControl>
- <Input
- placeholder={t("placeholders.ipAddress")}
- {...field}
- onBlur={(e) => {
- field.onChange(e.target.value.trim());
- field.onBlur();
- }}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="port"
- render={({ field }) => (
- <FormItem className="col-span-4">
- <FormLabel className="text-base font-semibold text-foreground">
- {t("quickConnect.port")}
- </FormLabel>
- <FormControl>
- <Input
- type="number"
- placeholder={t("placeholders.port")}
- {...field}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </div>
-
- <FormField
- control={form.control}
- name="username"
- render={({ field }) => {
- const isCredentialAuth = authTab === "credential";
- const hasCredential = !!form.watch("credentialId");
- const overrideEnabled = !!form.watch(
- "overrideCredentialUsername",
- );
- const shouldDisable =
- isCredentialAuth && hasCredential && !overrideEnabled;
-
- return (
- <FormItem>
- <FormLabel className="text-base font-semibold text-foreground">
- {t("quickConnect.username")}
- </FormLabel>
- <FormControl>
- <Input
- placeholder={t("placeholders.username")}
- disabled={shouldDisable}
- {...field}
- onBlur={(e) => {
- field.onChange(e.target.value.trim());
- field.onBlur();
- }}
- />
- </FormControl>
- </FormItem>
- );
- }}
- />
-
- <div className="space-y-3">
- <Label className="text-base font-semibold text-foreground">
- {t("quickConnect.authentication")}
- </Label>
- <Tabs
- value={authTab}
- onValueChange={(value) =>
- setAuthTab(value as "password" | "key" | "credential")
- }
- className="w-full"
- >
- <TabsList className="inline-flex items-center justify-center rounded-md bg-muted p-1 text-muted-foreground">
- <TabsTrigger value="password">
- {t("hosts.password")}
- </TabsTrigger>
- <TabsTrigger value="key">{t("hosts.key")}</TabsTrigger>
- <TabsTrigger value="credential">
- {t("quickConnect.credential")}
- </TabsTrigger>
- </TabsList>
-
- <TabsContent value="password" className="mt-4">
- <FormField
- control={form.control}
- name="password"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("quickConnect.password")}</FormLabel>
- <FormControl>
- <PasswordInput
- placeholder={t("placeholders.password")}
- {...field}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </TabsContent>
-
- <TabsContent value="key" className="mt-4">
- <Tabs
- value={keyInputMethod}
- onValueChange={(value) =>
- setKeyInputMethod(value as "upload" | "paste")
- }
- className="w-full"
- >
- <TabsList className="inline-flex items-center justify-center rounded-md bg-muted p-1 text-muted-foreground">
- <TabsTrigger value="upload">
- {t("quickConnect.uploadFile")}
- </TabsTrigger>
- <TabsTrigger value="paste">
- {t("quickConnect.pasteKey")}
- </TabsTrigger>
- </TabsList>
-
- <TabsContent value="upload" className="mt-4">
- <Controller
- control={form.control}
- name="key"
- render={({ field }) => (
- <FormItem className="mb-4">
- <FormLabel>{t("quickConnect.key")}</FormLabel>
- <FormControl>
- <div className="relative inline-block">
- <input
- id="key-upload"
- type="file"
- accept=".pem,.key,.txt,.ppk"
- onChange={(e) => {
- const file = e.target.files?.[0];
- field.onChange(file || null);
- }}
- className="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
- />
- <Button
- type="button"
- variant="outline"
- className="justify-start text-left"
- >
- <span
- className="truncate"
- title={
- (field.value as File)?.name ||
- t("hosts.upload")
- }
- >
- {field.value
- ? (field.value as File).name
- : t("hosts.upload")}
- </span>
- </Button>
- </div>
- </FormControl>
- </FormItem>
- )}
- />
- </TabsContent>
-
- <TabsContent value="paste" className="mt-4">
- <Controller
- control={form.control}
- name="key"
- render={({ field }) => (
- <FormItem className="mb-4">
- <FormLabel>{t("quickConnect.key")}</FormLabel>
- <FormControl>
- <CodeMirror
- value={
- typeof field.value === "string"
- ? field.value
- : ""
- }
- onChange={(value) => field.onChange(value)}
- placeholder={t("placeholders.pastePrivateKey")}
- theme={editorTheme}
- className="border border-input rounded-md overflow-hidden"
- minHeight="120px"
- basicSetup={{
- lineNumbers: true,
- foldGutter: false,
- dropCursor: false,
- allowMultipleSelections: false,
- highlightSelectionMatches: false,
- }}
- extensions={[
- EditorView.theme({
- ".cm-scroller": {
- overflow: "auto",
- scrollbarWidth: "thin",
- scrollbarColor:
- "var(--scrollbar-thumb) var(--scrollbar-track)",
- },
- }),
- ]}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </TabsContent>
- </Tabs>
-
- <div className="grid grid-cols-2 gap-4 mt-4">
- <FormField
- control={form.control}
- name="keyPassword"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t("quickConnect.keyPassword")}</FormLabel>
- <FormControl>
- <PasswordInput
- placeholder={t("placeholders.keyPassword")}
- {...field}
- />
- </FormControl>
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="keyType"
- render={({ field }) => (
- <FormItem className="relative">
- <FormLabel>{t("quickConnect.keyType")}</FormLabel>
- <FormControl>
- <div className="relative">
- <Button
- ref={keyTypeButtonRef}
- type="button"
- variant="outline"
- className="w-full justify-start text-left rounded-md px-2 py-2 bg-canvas border border-input text-foreground"
- onClick={() =>
- setKeyTypeDropdownOpen((open) => !open)
- }
- >
- {keyTypeOptions.find(
- (opt) => opt.value === field.value,
- )?.label || t("quickConnect.autoDetect")}
- </Button>
- {keyTypeDropdownOpen && (
- <div
- ref={keyTypeDropdownRef}
- className="absolute bottom-full left-0 z-50 mb-1 w-full bg-canvas border border-input rounded-md shadow-lg max-h-40 overflow-y-auto thin-scrollbar p-1"
- >
- <div className="grid grid-cols-1 gap-1 p-0">
- {keyTypeOptions.map((opt) => (
- <Button
- key={opt.value}
- type="button"
- variant="ghost"
- size="sm"
- className="w-full justify-start text-left rounded-md px-2 py-1.5 bg-canvas text-foreground hover:bg-surface-hover focus:bg-surface-hover focus:outline-none"
- onClick={() => {
- field.onChange(opt.value);
- setKeyTypeDropdownOpen(false);
- }}
- >
- {opt.label}
- </Button>
- ))}
- </div>
- </div>
- )}
- </div>
- </FormControl>
- </FormItem>
- )}
- />
- </div>
- </TabsContent>
-
- <TabsContent value="credential" className="mt-4">
- <div className="space-y-4">
- <FormField
- control={form.control}
- name="credentialId"
- render={({ field }) => (
- <FormItem>
- <CredentialSelector
- value={field.value}
- onValueChange={field.onChange}
- onCredentialSelect={(credential) => {
- if (
- credential &&
- !form.getValues("overrideCredentialUsername")
- ) {
- form.setValue("username", credential.username);
- }
- }}
- />
- </FormItem>
- )}
- />
-
- {form.watch("credentialId") && (
- <FormField
- control={form.control}
- name="overrideCredentialUsername"
- render={({ field }) => (
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 bg-elevated dark:bg-input/30">
- <div className="space-y-0.5">
- <FormLabel>
- {t("quickConnect.overrideUsername")}
- </FormLabel>
- <p className="text-sm text-muted-foreground">
- {t("quickConnect.overrideUsernameDesc")}
- </p>
- </div>
- <FormControl>
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- </FormControl>
- </FormItem>
- )}
- />
- )}
- </div>
- </TabsContent>
- </Tabs>
- </div>
- </div>
-
- <DialogFooter>
- <Button
- variant="outline"
- onClick={() => onOpenChange(false)}
- disabled={isConnecting}
- >
- {t("common.cancel")}
- </Button>
- <Button
- onClick={() => handleConnect("terminal")}
- disabled={isConnecting}
- >
- {t("quickConnect.connectTerminal")}
- </Button>
- <Button
- onClick={() => handleConnect("file_manager")}
- disabled={isConnecting}
- >
- {t("quickConnect.connectFileManager")}
- </Button>
- </DialogFooter>
- </Form>
- </DialogContent>
- </Dialog>
- );
-}
diff --git a/src/ui/desktop/navigation/hosts/FolderCard.tsx b/src/ui/desktop/navigation/hosts/FolderCard.tsx
deleted file mode 100644
index 9d21f199a..000000000
--- a/src/ui/desktop/navigation/hosts/FolderCard.tsx
+++ /dev/null
@@ -1,142 +0,0 @@
-import React, { useState } from "react";
-import { CardTitle } from "@/components/ui/card.tsx";
-import {
- ChevronDown,
- Folder,
- Server,
- Cloud,
- Database,
- Box,
- Package,
- Layers,
- Archive,
- HardDrive,
- Globe,
-} from "lucide-react";
-import { Button } from "@/components/ui/button.tsx";
-import { Host } from "@/ui/desktop/navigation/hosts/Host.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
-
-interface SSHHost {
- id: number;
- name: string;
- ip: string;
- port: number;
- username: string;
- folder: string;
- tags: string[];
- pin: boolean;
- authType: string;
- password?: string;
- key?: string;
- keyPassword?: string;
- keyType?: string;
- enableTerminal: boolean;
- enableTunnel: boolean;
- enableFileManager: boolean;
- defaultPath: string;
- tunnelConnections: Array<{
- sourcePort: number;
- endpointPort: number;
- endpointHost: string;
- maxRetries: number;
- retryInterval: number;
- autoStart: boolean;
- }>;
- createdAt: string;
- updatedAt: string;
-}
-
-interface FolderCardProps {
- folderName: string;
- hosts: SSHHost[];
- isFirst: boolean;
- isLast: boolean;
- folderColor?: string;
- folderIcon?: string;
-}
-
-export function FolderCard({
- folderName,
- hosts,
- folderColor,
- folderIcon,
-}: FolderCardProps): React.ReactElement {
- const [isExpanded, setIsExpanded] = useState(true);
-
- const toggleExpanded = () => {
- setIsExpanded(!isExpanded);
- };
-
- const iconMap: Record<
- string,
- React.ComponentType<{
- size?: number;
- strokeWidth?: number;
- className?: string;
- style?: React.CSSProperties;
- }>
- > = {
- Folder,
- Server,
- Cloud,
- Database,
- Box,
- Package,
- Layers,
- Archive,
- HardDrive,
- Globe,
- };
-
- const FolderIcon =
- folderIcon && iconMap[folderIcon] ? iconMap[folderIcon] : Folder;
-
- return (
- <div className="bg-elevated border-2 border-edge rounded-lg overflow-hidden p-0 m-0">
- <div
- className={`px-4 py-3 relative ${isExpanded ? "border-b-2" : ""} bg-header`}
- >
- <div className="flex gap-2 pr-10">
- <div className="flex-shrink-0 flex items-center">
- <FolderIcon
- size={16}
- strokeWidth={3}
- style={folderColor ? { color: folderColor } : undefined}
- />
- </div>
- <div className="flex-1 min-w-0">
- <CardTitle className="mb-0 leading-tight break-words text-md">
- {folderName}
- </CardTitle>
- </div>
- </div>
- <Button
- variant="outline"
- className="w-[28px] h-[28px] absolute right-4 top-1/2 -translate-y-1/2 flex-shrink-0"
- onClick={toggleExpanded}
- >
- <ChevronDown
- className={`h-4 w-4 transition-transform ${isExpanded ? "" : "rotate-180"}`}
- />
- </Button>
- </div>
- {isExpanded && (
- <div className="flex flex-col p-2 gap-y-3">
- {hosts.map((host, index) => (
- <React.Fragment
- key={`${folderName}-host-${host.id}-${host.name || host.ip}`}
- >
- <Host host={host} />
- {index < hosts.length - 1 && (
- <div className="relative -mx-2">
- <Separator className="p-0.25 absolute inset-x-0" />
- </div>
- )}
- </React.Fragment>
- ))}
- </div>
- )}
- </div>
- );
-}
diff --git a/src/ui/desktop/navigation/tabs/TabDropdown.tsx b/src/ui/desktop/navigation/tabs/TabDropdown.tsx
deleted file mode 100644
index 321f0c0e0..000000000
--- a/src/ui/desktop/navigation/tabs/TabDropdown.tsx
+++ /dev/null
@@ -1,142 +0,0 @@
-import React from "react";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import {
- ChevronDown,
- Home,
- Terminal as TerminalIcon,
- Server as ServerIcon,
- Folder as FolderIcon,
- ArrowDownUp as TunnelIcon,
- Container as DockerIcon,
- Shield as AdminIcon,
- Network as SshManagerIcon,
- User as UserIcon,
- Network,
- X,
-} from "lucide-react";
-import { useTabs, type Tab } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
-import { useTranslation } from "react-i18next";
-
-export function TabDropdown(): React.ReactElement {
- const { tabs, currentTab, setCurrentTab, removeTab } = useTabs();
- const { t } = useTranslation();
-
- const getTabIcon = (tabType: Tab["type"]) => {
- switch (tabType) {
- case "home":
- return <Home className="h-4 w-4" />;
- case "terminal":
- return <TerminalIcon className="h-4 w-4" />;
- case "server_stats":
- return <ServerIcon className="h-4 w-4" />;
- case "file_manager":
- return <FolderIcon className="h-4 w-4" />;
- case "tunnel":
- return <TunnelIcon className="h-4 w-4" />;
- case "docker":
- return <DockerIcon className="h-4 w-4" />;
- case "user_profile":
- return <UserIcon className="h-4 w-4" />;
- case "ssh_manager":
- return <SshManagerIcon className="h-4 w-4" />;
- case "admin":
- return <AdminIcon className="h-4 w-4" />;
- case "network_graph":
- return <Network className="h-4 w-4" />;
- default:
- return <TerminalIcon className="h-4 w-4" />;
- }
- };
-
- const getTabDisplayTitle = (tab: Tab) => {
- switch (tab.type) {
- case "home":
- return t("nav.home");
- case "server_stats":
- return tab.title || t("nav.serverStats");
- case "file_manager":
- return tab.title || t("nav.fileManager");
- case "tunnel":
- return tab.title || t("nav.tunnels");
- case "docker":
- return tab.title || t("nav.docker");
- case "user_profile":
- return tab.title || t("nav.userProfile");
- case "ssh_manager":
- return tab.title || t("nav.sshManager");
- case "admin":
- return tab.title || t("nav.admin");
- case "network_graph":
- return tab.title || t("dashboard.networkGraph");
- case "terminal":
- default:
- return tab.title || t("nav.terminal");
- }
- };
-
- const handleTabSwitch = (tabId: number) => {
- setCurrentTab(tabId);
- };
-
- const handleCloseTab = (
- e: React.MouseEvent,
- tabId: number,
- tabType: Tab["type"],
- ) => {
- e.stopPropagation();
- if (tabType === "home") return;
- removeTab(tabId);
- };
-
- return (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- variant="outline"
- className="w-[30px] h-[30px] border-edge"
- title={t("nav.tabNavigation", { defaultValue: "Tab Navigation" })}
- >
- <ChevronDown className="h-4 w-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent
- align="end"
- className="w-56 bg-canvas border-edge text-foreground"
- >
- {tabs.map((tab) => {
- const isActive = tab.id === currentTab;
- const canClose = tab.type !== "home";
- return (
- <DropdownMenuItem
- key={tab.id}
- onClick={() => handleTabSwitch(tab.id)}
- className={`flex items-center gap-2 cursor-pointer px-3 py-2 ${
- isActive
- ? "bg-active text-foreground"
- : "hover:bg-hover text-foreground-secondary"
- }`}
- >
- {getTabIcon(tab.type)}
- <span className="flex-1 truncate">{getTabDisplayTitle(tab)}</span>
- {canClose && (
- <button
- onClick={(e) => handleCloseTab(e, tab.id, tab.type)}
- className="ml-1 p-0.5 rounded hover:bg-hover-secondary flex-shrink-0 transition-colors"
- title={t("nav.closeTab", { defaultValue: "Close tab" })}
- >
- <X className="h-3.5 w-3.5" />
- </button>
- )}
- </DropdownMenuItem>
- );
- })}
- </DropdownMenuContent>
- </DropdownMenu>
- );
-}
diff --git a/src/ui/desktop/apps/FullScreenAppWrapper.tsx b/src/ui/features/FullScreenAppWrapper.tsx
similarity index 89%
rename from src/ui/desktop/apps/FullScreenAppWrapper.tsx
rename to src/ui/features/FullScreenAppWrapper.tsx
index 3834349bc..2ca547b0f 100644
--- a/src/ui/desktop/apps/FullScreenAppWrapper.tsx
+++ b/src/ui/features/FullScreenAppWrapper.tsx
@@ -1,11 +1,11 @@
import React, { useEffect, useState } from "react";
-import { TabProvider } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
-import { CommandHistoryProvider } from "@/ui/desktop/apps/features/terminal/command-history/CommandHistoryContext.tsx";
-import { SidebarProvider } from "@/components/ui/sidebar.tsx";
-import { getSSHHosts, getUserInfo } from "@/ui/main-axios.ts";
+import { TabProvider } from "@/shell/TabContext.tsx";
+import { CommandHistoryProvider } from "@/features/terminal/command-history/CommandHistoryContext.tsx";
+import { SidebarProvider } from "@/components/sidebar.tsx";
+import { getSSHHosts, getUserInfo } from "@/main-axios.ts";
import type { SSHHost } from "@/types";
-import { Dashboard } from "@/ui/desktop/apps/dashboard/Dashboard.tsx";
-import { Toaster } from "@/components/ui/sonner.tsx";
+import { Dashboard } from "@/dashboard/Dashboard.tsx";
+import { Toaster } from "@/components/sonner.tsx";
import { dbHealthMonitor } from "@/lib/db-health-monitor.ts";
interface FullScreenAppWrapperProps {
diff --git a/src/ui/desktop/apps/features/docker/DockerApp.tsx b/src/ui/features/docker/DockerApp.tsx
similarity index 88%
rename from src/ui/desktop/apps/features/docker/DockerApp.tsx
rename to src/ui/features/docker/DockerApp.tsx
index 8e98e2d53..a8fa14df9 100644
--- a/src/ui/desktop/apps/features/docker/DockerApp.tsx
+++ b/src/ui/features/docker/DockerApp.tsx
@@ -1,6 +1,6 @@
import React from "react";
-import { DockerManager } from "@/ui/desktop/apps/features/docker/DockerManager.tsx";
-import { FullScreenAppWrapper } from "@/ui/desktop/apps/FullScreenAppWrapper.tsx";
+import { DockerManager } from "@/features/docker/DockerManager.tsx";
+import { FullScreenAppWrapper } from "@/features/FullScreenAppWrapper.tsx";
interface DockerAppProps {
hostId?: string;
diff --git a/src/ui/desktop/apps/features/docker/DockerManager.tsx b/src/ui/features/docker/DockerManager.tsx
similarity index 76%
rename from src/ui/desktop/apps/features/docker/DockerManager.tsx
rename to src/ui/features/docker/DockerManager.tsx
index 80ec4d53e..923c42b49 100644
--- a/src/ui/desktop/apps/features/docker/DockerManager.tsx
+++ b/src/ui/features/docker/DockerManager.tsx
@@ -1,6 +1,10 @@
import React from "react";
-import { useSidebar } from "@/components/ui/sidebar.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
+import { Separator } from "@/components/separator.tsx";
+import { Alert, AlertDescription } from "@/components/alert.tsx";
+import { Button } from "@/components/button.tsx";
+import { Card } from "@/components/card.tsx";
+import { Input } from "@/components/input.tsx";
+import { AlertCircle, Box, RefreshCw, Search, Settings } from "lucide-react";
import { useTranslation } from "react-i18next";
import type { SSHHost, DockerContainer, DockerValidation } from "@/types";
@@ -14,19 +18,19 @@ import {
verifyDockerWarpgate,
logActivity,
getSSHHosts,
-} from "@/ui/main-axios.ts";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
+} from "@/main-axios.ts";
+import { SimpleLoader } from "@/lib/SimpleLoader.tsx";
import { ContainerList } from "./components/ContainerList.tsx";
import { ContainerDetail } from "./components/ContainerDetail.tsx";
-import { TOTPDialog } from "@/ui/desktop/navigation/dialogs/TOTPDialog.tsx";
-import { SSHAuthDialog } from "@/ui/desktop/navigation/dialogs/SSHAuthDialog.tsx";
-import { WarpgateDialog } from "@/ui/desktop/navigation/dialogs/WarpgateDialog.tsx";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
+import { TOTPDialog } from "@/ssh/dialogs/TOTPDialog.tsx";
+import { SSHAuthDialog } from "@/ssh/dialogs/SSHAuthDialog.tsx";
+import { WarpgateDialog } from "@/ssh/dialogs/WarpgateDialog.tsx";
+import { useTabsSafe } from "@/shell/TabContext.tsx";
import {
ConnectionLogProvider,
useConnectionLog,
-} from "@/ui/desktop/navigation/connection-log/ConnectionLogContext.tsx";
-import { ConnectionLog } from "@/ui/desktop/navigation/connection-log/ConnectionLog.tsx";
+} from "@/ssh/connection-log/ConnectionLogContext.tsx";
+import { ConnectionLog } from "@/ssh/connection-log/ConnectionLog.tsx";
import type { LogEntry } from "@/types/connection-log.ts";
interface DockerManagerProps {
@@ -54,17 +58,13 @@ function DockerManagerInner({
onClose,
}: DockerManagerProps): React.ReactElement {
const { t } = useTranslation();
- const { state: sidebarState } = useSidebar();
const {
addLog,
setLogs,
clearLogs,
isExpanded: isConnectionLogExpanded,
} = useConnectionLog();
- const { currentTab, removeTab } = useTabs() as {
- currentTab: number | null;
- removeTab: (tabId: number) => void;
- };
+ const { currentTab, removeTab } = useTabsSafe();
const [currentHostConfig, setCurrentHostConfig] = React.useState(hostConfig);
const [sessionId, setSessionId] = React.useState<string | null>(null);
const [containers, setContainers] = React.useState<DockerContainer[]>([]);
@@ -92,6 +92,8 @@ function DockerManagerInner({
"no_keyboard" | "auth_failed" | "timeout"
>("no_keyboard");
const [hasConnectionError, setHasConnectionError] = React.useState(false);
+ const [search, setSearch] = React.useState("");
+ const [statusFilter, setStatusFilter] = React.useState("all");
const activityLoggedRef = React.useRef(false);
const activityLoggingRef = React.useRef(false);
@@ -538,7 +540,7 @@ function DockerManagerInner({
};
const topMarginPx = isTopbarOpen ? 74 : 16;
- const leftMarginPx = sidebarState === "collapsed" ? 16 : 8;
+ const leftMarginPx = 8;
const bottomMarginPx = 8;
const wrapperStyle: React.CSSProperties = embedded
@@ -559,19 +561,21 @@ function DockerManagerInner({
if (!currentHostConfig?.enableDocker) {
return (
<div style={wrapperStyle} className={`${containerClass} relative`}>
- <div className="h-full w-full flex flex-col">
- <div className="flex flex-col sm:flex-row sm:items-center justify-between px-4 pt-3 pb-3 gap-3">
- <div className="flex items-center gap-4 min-w-0">
- <div className="min-w-0">
- <h1 className="font-bold text-lg truncate">
- {currentHostConfig?.folder} / {title}
- </h1>
+ <div className="h-full w-full flex flex-col flex-1 min-h-0 overflow-hidden">
+ <div className="flex-1 overflow-y-auto px-3 py-3 flex flex-col gap-3">
+ <Card className="flex-row items-center justify-between px-3 py-3 shrink-0 gap-0">
+ <div className="flex items-center gap-3">
+ <div className="size-10 border border-border bg-muted flex items-center justify-center shrink-0">
+ <Box className="size-5 text-accent-brand" />
+ </div>
+ <div>
+ <h1 className="text-2xl font-bold">{title}</h1>
+ <span className="text-xs text-muted-foreground uppercase tracking-widest font-semibold">
+ {t("docker.manager")}
+ </span>
+ </div>
</div>
- </div>
- </div>
- <Separator className="p-0.25 w-full" />
-
- <div className="flex-1 overflow-hidden min-h-0 p-4">
+ </Card>
<Alert variant="destructive">
<AlertCircle className="h-4 w-4" />
<AlertDescription>{t("docker.notEnabled")}</AlertDescription>
@@ -629,7 +633,7 @@ function DockerManagerInner({
return (
<div style={wrapperStyle} className={`${containerClass} relative`}>
<div
- className="h-full w-full flex flex-col"
+ className="h-full w-full flex flex-col flex-1 min-h-0 overflow-hidden"
style={{
visibility:
(hasConnectionError ||
@@ -639,65 +643,103 @@ function DockerManagerInner({
: "visible",
}}
>
- <div className="flex flex-col sm:flex-row sm:items-center justify-between px-4 pt-3 pb-3 gap-3">
- <div className="flex items-center gap-4 min-w-0">
- <div className="min-w-0">
- <h1 className="font-bold text-lg truncate">
- {currentHostConfig?.folder} / {title}
- </h1>
- {dockerValidation?.version && (
- <p className="text-xs text-muted-foreground">
- {t("docker.version", { version: dockerValidation.version })}
- </p>
- )}
- </div>
- </div>
- </div>
- <Separator className="p-0.25 w-full" />
-
- <div className="flex-1 overflow-hidden min-h-0 relative">
- {viewMode === "list" ? (
- <div className="h-full min-h-0 px-4 pt-4">
- {sessionId ? (
- isLoadingContainers && containers.length === 0 ? (
- <SimpleLoader
- visible={true}
- message={t("docker.loadingContainers")}
+ {viewMode === "detail" &&
+ sessionId &&
+ selectedContainer &&
+ currentHostConfig ? (
+ <ContainerDetail
+ sessionId={sessionId}
+ containerId={selectedContainer}
+ containers={containers}
+ hostConfig={currentHostConfig}
+ onBack={handleBack}
+ />
+ ) : (
+ <div className="flex-1 overflow-y-auto px-3 py-3 flex flex-col gap-3">
+ <Card className="flex-row items-center justify-between px-3 py-3 shrink-0 gap-0">
+ <div className="flex items-center gap-3">
+ <div className="size-10 border border-border bg-muted flex items-center justify-center shrink-0">
+ <Box className="size-5 text-accent-brand" />
+ </div>
+ <div>
+ <h1 className="text-2xl font-bold">{title}</h1>
+ <div className="flex items-center gap-2">
+ <span className="size-2 rounded-full bg-accent-brand" />
+ <span className="text-xs text-muted-foreground uppercase tracking-widest font-semibold">
+ {dockerValidation?.version
+ ? t("docker.version", {
+ version: dockerValidation.version,
+ })
+ : t("docker.manager")}
+ </span>
+ </div>
+ </div>
+ </div>
+ <div className="flex items-center gap-2">
+ <div className="relative w-56">
+ <Search className="absolute left-2.5 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground" />
+ <Input
+ placeholder={t("docker.searchPlaceholder")}
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ className="pl-8 h-8"
/>
- ) : (
- <ContainerList
- containers={containers}
- sessionId={sessionId}
- onSelectContainer={(id) => {
- setSelectedContainer(id);
- setViewMode("detail");
- }}
- selectedContainerId={selectedContainer}
- onRefresh={refreshContainers}
+ </div>
+ <select
+ value={statusFilter}
+ onChange={(e) => setStatusFilter(e.target.value)}
+ className="h-8 px-2 text-xs bg-background border border-border text-foreground outline-none focus:ring-1 focus:ring-ring"
+ >
+ <option value="all">{t("docker.allStatuses")}</option>
+ <option value="running">{t("docker.stateRunning")}</option>
+ <option value="paused">{t("docker.statePaused")}</option>
+ <option value="exited">{t("docker.stateExited")}</option>
+ <option value="restarting">
+ {t("docker.stateRestarting")}
+ </option>
+ </select>
+ <Separator orientation="vertical" className="h-8 mx-1" />
+ <Button
+ variant="ghost"
+ size="icon"
+ onClick={refreshContainers}
+ disabled={isLoadingContainers}
+ >
+ <RefreshCw
+ className={`size-4 text-accent-brand ${isLoadingContainers ? "animate-spin" : ""}`}
/>
- )
- ) : (
- <div className="text-center py-8">
- <p className="text-muted-foreground">No session available</p>
+ </Button>
+ <Button variant="ghost" size="icon">
+ <Settings className="size-4 text-accent-brand" />
+ </Button>
+ </div>
+ </Card>
+
+ {sessionId ? (
+ isLoadingContainers && containers.length === 0 ? (
+ <div className="flex flex-col items-center justify-center h-full opacity-40 py-20">
+ <RefreshCw className="size-8 animate-spin mb-4" />
+ <span className="text-sm font-semibold">
+ {t("docker.loadingContainers")}
+ </span>
</div>
- )}
- </div>
- ) : sessionId && selectedContainer && currentHostConfig ? (
- <ContainerDetail
- sessionId={sessionId}
- containerId={selectedContainer}
- containers={containers}
- hostConfig={currentHostConfig}
- onBack={handleBack}
- />
- ) : (
- <div className="text-center py-8">
- <p className="text-muted-foreground">
- Select a container to view details
- </p>
- </div>
- )}
- </div>
+ ) : (
+ <ContainerList
+ containers={containers}
+ sessionId={sessionId}
+ onSelectContainer={(id) => {
+ setSelectedContainer(id);
+ setViewMode("detail");
+ }}
+ selectedContainerId={selectedContainer}
+ onRefresh={refreshContainers}
+ search={search}
+ statusFilter={statusFilter}
+ />
+ )
+ ) : null}
+ </div>
+ )}
</div>
<TOTPDialog
isOpen={totpRequired}
diff --git a/src/ui/desktop/apps/features/docker/components/ConsoleTerminal.tsx b/src/ui/features/docker/components/ConsoleTerminal.tsx
similarity index 98%
rename from src/ui/desktop/apps/features/docker/components/ConsoleTerminal.tsx
rename to src/ui/features/docker/components/ConsoleTerminal.tsx
index 8841c6cab..7b166fc05 100644
--- a/src/ui/desktop/apps/features/docker/components/ConsoleTerminal.tsx
+++ b/src/ui/features/docker/components/ConsoleTerminal.tsx
@@ -4,21 +4,21 @@ import { FitAddon } from "@xterm/addon-fit";
import { ClipboardAddon } from "@xterm/addon-clipboard";
import { RobustClipboardProvider } from "@/lib/clipboard-provider";
import { WebLinksAddon } from "@xterm/addon-web-links";
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
-} from "@/components/ui/select.tsx";
-import { Card, CardContent } from "@/components/ui/card.tsx";
+} from "@/components/select.tsx";
+import { Card, CardContent } from "@/components/card.tsx";
import { getBasePath } from "@/lib/base-path";
import { Terminal as TerminalIcon, Power, PowerOff } from "lucide-react";
import { toast } from "sonner";
import type { SSHHost } from "@/types";
-import { isElectron } from "@/ui/main-axios.ts";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
+import { isElectron } from "@/main-axios.ts";
+import { SimpleLoader } from "@/lib/SimpleLoader.tsx";
import { useTranslation } from "react-i18next";
interface ConsoleTerminalProps {
diff --git a/src/ui/features/docker/components/ContainerCard.tsx b/src/ui/features/docker/components/ContainerCard.tsx
new file mode 100644
index 000000000..8888d5df2
--- /dev/null
+++ b/src/ui/features/docker/components/ContainerCard.tsx
@@ -0,0 +1,311 @@
+import React from "react";
+import { Card } from "@/components/card.tsx";
+import { Button } from "@/components/button.tsx";
+import {
+ Box,
+ Play,
+ Square,
+ RotateCw,
+ Pause,
+ PlayCircle,
+ Trash2,
+ RefreshCw,
+} from "lucide-react";
+import { toast } from "sonner";
+import { useTranslation } from "react-i18next";
+import type { DockerContainer } from "@/types";
+import {
+ startDockerContainer,
+ stopDockerContainer,
+ restartDockerContainer,
+ pauseDockerContainer,
+ unpauseDockerContainer,
+ removeDockerContainer,
+} from "@/main-axios.ts";
+import { useConfirmation } from "@/hooks/use-confirmation.ts";
+
+interface ContainerCardProps {
+ container: DockerContainer;
+ sessionId: string;
+ onSelect?: () => void;
+ isSelected?: boolean;
+ onRefresh?: () => void;
+}
+
+export function DockerBadge({ state }: { state: DockerContainer["state"] }) {
+ let colorClass = "border-border text-muted-foreground";
+ if (state === "running")
+ colorClass = "border-accent-brand/40 text-accent-brand bg-accent-brand/10";
+ if (state === "paused")
+ colorClass = "border-yellow-500/40 text-yellow-500 bg-yellow-500/10";
+ if (state === "exited")
+ colorClass = "border-destructive/40 text-destructive bg-destructive/5";
+ if (state === "restarting")
+ colorClass = "border-blue-400/40 text-blue-400 bg-blue-400/10";
+ return (
+ <span
+ className={`text-[10px] font-bold px-1.5 py-0.5 border uppercase tracking-wider ${colorClass}`}
+ >
+ {state}
+ </span>
+ );
+}
+
+export function ContainerCard({
+ container,
+ sessionId,
+ onSelect,
+ isSelected = false,
+ onRefresh,
+}: ContainerCardProps): React.ReactElement {
+ const { t } = useTranslation();
+ const { confirmWithToast } = useConfirmation();
+ const [isStarting, setIsStarting] = React.useState(false);
+ const [isStopping, setIsStopping] = React.useState(false);
+ const [isRestarting, setIsRestarting] = React.useState(false);
+ const [isPausing, setIsPausing] = React.useState(false);
+ const [isRemoving, setIsRemoving] = React.useState(false);
+
+ const isLoading =
+ isStarting || isStopping || isRestarting || isPausing || isRemoving;
+
+ const containerName = container.name.startsWith("/")
+ ? container.name.slice(1)
+ : container.name;
+ const portsList = (container.ports ?? "")
+ .split(",")
+ .map((p) => p.trim())
+ .filter(Boolean);
+
+ const handleStart = async (e: React.MouseEvent) => {
+ e.stopPropagation();
+ setIsStarting(true);
+ try {
+ await startDockerContainer(sessionId, container.id);
+ toast.success(t("docker.containerStarted", { name: containerName }));
+ onRefresh?.();
+ } catch (err) {
+ toast.error(
+ t("docker.failedToStartContainer", {
+ error: err instanceof Error ? err.message : "Unknown error",
+ }),
+ );
+ } finally {
+ setIsStarting(false);
+ }
+ };
+
+ const handleStop = async (e: React.MouseEvent) => {
+ e.stopPropagation();
+ setIsStopping(true);
+ try {
+ await stopDockerContainer(sessionId, container.id);
+ toast.success(t("docker.containerStopped", { name: containerName }));
+ onRefresh?.();
+ } catch (err) {
+ toast.error(
+ t("docker.failedToStopContainer", {
+ error: err instanceof Error ? err.message : "Unknown error",
+ }),
+ );
+ } finally {
+ setIsStopping(false);
+ }
+ };
+
+ const handleRestart = async (e: React.MouseEvent) => {
+ e.stopPropagation();
+ setIsRestarting(true);
+ try {
+ await restartDockerContainer(sessionId, container.id);
+ toast.success(t("docker.containerRestarted", { name: containerName }));
+ onRefresh?.();
+ } catch (err) {
+ toast.error(
+ t("docker.failedToRestartContainer", {
+ error: err instanceof Error ? err.message : "Unknown error",
+ }),
+ );
+ } finally {
+ setIsRestarting(false);
+ }
+ };
+
+ const handlePause = async (e: React.MouseEvent) => {
+ e.stopPropagation();
+ setIsPausing(true);
+ try {
+ if (container.state === "paused") {
+ await unpauseDockerContainer(sessionId, container.id);
+ toast.success(t("docker.containerUnpaused", { name: containerName }));
+ } else {
+ await pauseDockerContainer(sessionId, container.id);
+ toast.success(t("docker.containerPaused", { name: containerName }));
+ }
+ onRefresh?.();
+ } catch (err) {
+ toast.error(
+ t("docker.failedToTogglePauseContainer", {
+ action: container.state === "paused" ? "unpause" : "pause",
+ error: err instanceof Error ? err.message : "Unknown error",
+ }),
+ );
+ } finally {
+ setIsPausing(false);
+ }
+ };
+
+ const handleRemove = async (e: React.MouseEvent) => {
+ e.stopPropagation();
+ confirmWithToast(
+ t("docker.confirmRemoveContainer", { name: containerName }) +
+ (container.state === "running"
+ ? " " + t("docker.runningContainerWarning")
+ : ""),
+ async () => {
+ setIsRemoving(true);
+ try {
+ await removeDockerContainer(
+ sessionId,
+ container.id,
+ container.state === "running",
+ );
+ toast.success(t("docker.containerRemoved", { name: containerName }));
+ onRefresh?.();
+ } catch (err) {
+ toast.error(
+ t("docker.failedToRemoveContainer", {
+ error: err instanceof Error ? err.message : "Unknown error",
+ }),
+ );
+ } finally {
+ setIsRemoving(false);
+ }
+ },
+ t("common.remove"),
+ t("common.cancel"),
+ );
+ };
+
+ return (
+ <Card
+ className={`flex flex-col overflow-hidden p-0 gap-0 group hover:border-accent-brand/40 transition-colors cursor-pointer ${isSelected ? "border-accent-brand/60 bg-accent-brand/5" : ""}`}
+ onClick={onSelect}
+ >
+ <div className="flex items-center justify-between px-4 py-2.5 border-b border-border bg-muted/10">
+ <div className="flex items-center gap-2 min-w-0">
+ <Box
+ className={`size-3.5 ${container.state === "running" ? "text-accent-brand" : "text-muted-foreground"}`}
+ />
+ <span className="text-sm font-bold truncate">{containerName}</span>
+ </div>
+ <DockerBadge state={container.state} />
+ </div>
+ <div className="px-4 py-3 flex flex-col gap-2">
+ <div className="flex flex-col gap-0.5">
+ <span className="text-[10px] text-muted-foreground uppercase font-bold tracking-widest">
+ {t("docker.image")}
+ </span>
+ <span className="text-xs font-mono truncate text-foreground/80">
+ {container.image}
+ </span>
+ </div>
+ <div className="flex flex-col gap-0.5 mt-1">
+ <span className="text-[10px] text-muted-foreground uppercase font-bold tracking-widest">
+ {t("docker.ports")}
+ </span>
+ <div className="flex flex-wrap gap-1 mt-0.5">
+ {portsList.length > 0 ? (
+ portsList.slice(0, 3).map((p) => (
+ <span
+ key={p}
+ className="text-[10px] font-mono px-1 border border-border bg-muted/30"
+ >
+ {p}
+ </span>
+ ))
+ ) : (
+ <span className="text-[10px] text-muted-foreground italic">
+ {t("docker.noPorts")}
+ </span>
+ )}
+ </div>
+ </div>
+ </div>
+ <div className="px-4 py-2 border-t border-border bg-muted/5 flex items-center justify-between opacity-0 group-hover:opacity-100 transition-opacity">
+ <span className="text-[10px] text-muted-foreground italic">
+ {container.id.substring(0, 12)}
+ </span>
+ <div className="flex items-center gap-1">
+ {container.state !== "running" && (
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ className="text-accent-brand"
+ disabled={isLoading}
+ onClick={handleStart}
+ >
+ {isStarting ? (
+ <RefreshCw className="size-3 animate-spin" />
+ ) : (
+ <Play className="size-3" />
+ )}
+ </Button>
+ )}
+ {container.state === "running" && (
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ className="text-destructive"
+ disabled={isLoading}
+ onClick={handleStop}
+ >
+ {isStopping ? (
+ <RefreshCw className="size-3 animate-spin" />
+ ) : (
+ <Square className="size-3" />
+ )}
+ </Button>
+ )}
+ {(container.state === "running" || container.state === "paused") && (
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ disabled={isLoading}
+ onClick={handlePause}
+ >
+ {isPausing ? (
+ <RefreshCw className="size-3 animate-spin" />
+ ) : container.state === "paused" ? (
+ <PlayCircle className="size-3" />
+ ) : (
+ <Pause className="size-3" />
+ )}
+ </Button>
+ )}
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ disabled={isLoading || container.state === "exited"}
+ onClick={handleRestart}
+ >
+ {isRestarting ? (
+ <RefreshCw className="size-3 animate-spin" />
+ ) : (
+ <RotateCw className="size-3" />
+ )}
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ className="text-destructive"
+ disabled={isLoading}
+ onClick={handleRemove}
+ >
+ <Trash2 className="size-3" />
+ </Button>
+ </div>
+ </div>
+ </Card>
+ );
+}
diff --git a/src/ui/features/docker/components/ContainerDetail.tsx b/src/ui/features/docker/components/ContainerDetail.tsx
new file mode 100644
index 000000000..39786c00c
--- /dev/null
+++ b/src/ui/features/docker/components/ContainerDetail.tsx
@@ -0,0 +1,161 @@
+import React from "react";
+import { Button } from "@/components/button.tsx";
+import { Card } from "@/components/card.tsx";
+import { Separator } from "@/components/separator.tsx";
+import {
+ Activity,
+ ArrowLeft,
+ Box,
+ Info,
+ List,
+ Settings,
+ Terminal,
+} from "lucide-react";
+import { useTranslation } from "react-i18next";
+import type { DockerContainer, SSHHost } from "@/types";
+import { LogViewer } from "./LogViewer.tsx";
+import { ContainerStats } from "./ContainerStats.tsx";
+import { ConsoleTerminal } from "./ConsoleTerminal.tsx";
+import { DockerBadge } from "./ContainerCard.tsx";
+
+interface ContainerDetailProps {
+ sessionId: string;
+ containerId: string;
+ containers: DockerContainer[];
+ hostConfig: SSHHost;
+ onBack: () => void;
+}
+
+type DetailTab = "logs" | "stats" | "console";
+
+export function ContainerDetail({
+ sessionId,
+ containerId,
+ containers,
+ hostConfig,
+ onBack,
+}: ContainerDetailProps): React.ReactElement {
+ const { t } = useTranslation();
+ const [activeTab, setActiveTab] = React.useState<DetailTab>("logs");
+
+ const container = containers.find((c) => c.id === containerId);
+ const containerName = container
+ ? container.name.startsWith("/")
+ ? container.name.slice(1)
+ : container.name
+ : "";
+
+ if (!container) {
+ return (
+ <div className="flex items-center justify-center h-full">
+ <div className="text-center flex flex-col gap-3">
+ <p className="text-muted-foreground">
+ {t("docker.containerNotFound")}
+ </p>
+ <Button onClick={onBack} variant="outline" size="sm">
+ <ArrowLeft className="size-4 mr-2" />
+ {t("docker.backToList")}
+ </Button>
+ </div>
+ </div>
+ );
+ }
+
+ const tabs: { id: DetailTab; label: string; icon: React.ReactNode }[] = [
+ {
+ id: "logs",
+ label: t("docker.logs"),
+ icon: <List className="size-3.5" />,
+ },
+ {
+ id: "stats",
+ label: t("docker.stats"),
+ icon: <Activity className="size-3.5" />,
+ },
+ {
+ id: "console",
+ label: t("docker.consoleTab"),
+ icon: <Terminal className="size-3.5" />,
+ },
+ ];
+
+ return (
+ <div className="flex flex-col flex-1 min-h-0 overflow-hidden">
+ <div className="flex flex-col flex-1 min-h-0 overflow-y-auto px-3 py-3 gap-3">
+ <Card className="flex-row items-center justify-between px-3 py-3 shrink-0 gap-0">
+ <div className="flex items-center gap-3">
+ <Button
+ variant="ghost"
+ size="icon"
+ onClick={onBack}
+ className="size-8 text-muted-foreground hover:text-foreground"
+ >
+ <ArrowLeft className="size-4" />
+ </Button>
+ <div className="size-10 border border-border bg-muted flex items-center justify-center shrink-0">
+ <Box className="size-5 text-accent-brand" />
+ </div>
+ <div>
+ <h1 className="text-2xl font-bold">{containerName}</h1>
+ <span className="text-xs text-muted-foreground font-mono">
+ {container.image}
+ </span>
+ </div>
+ </div>
+ <div className="flex items-center gap-2">
+ <DockerBadge state={container.state} />
+ <Separator orientation="vertical" className="h-8 mx-2" />
+ <Button variant="ghost" size="icon">
+ <Settings className="size-4 text-accent-brand" />
+ </Button>
+ </div>
+ </Card>
+
+ <div className="flex flex-col flex-1 min-h-0 gap-3">
+ <div className="flex gap-1 border-b border-border shrink-0">
+ {tabs.map((tab) => (
+ <button
+ key={tab.id}
+ onClick={() => setActiveTab(tab.id)}
+ className={`flex items-center gap-2 px-4 py-2 text-sm font-semibold border-b-2 transition-colors ${
+ activeTab === tab.id
+ ? "border-b-accent-brand text-foreground bg-accent-brand/5"
+ : "border-b-transparent text-muted-foreground hover:text-foreground hover:bg-muted"
+ }`}
+ >
+ {tab.icon}
+ {tab.label}
+ </button>
+ ))}
+ </div>
+
+ <div className="flex-1 min-h-0 flex flex-col">
+ {activeTab === "logs" && (
+ <LogViewer
+ sessionId={sessionId}
+ containerId={containerId}
+ containerName={containerName}
+ />
+ )}
+ {activeTab === "stats" && (
+ <ContainerStats
+ sessionId={sessionId}
+ containerId={containerId}
+ containerName={containerName}
+ containerState={container.state}
+ />
+ )}
+ {activeTab === "console" && (
+ <ConsoleTerminal
+ containerId={containerId}
+ containerName={containerName}
+ containerState={container.state}
+ hostConfig={hostConfig}
+ />
+ )}
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/src/ui/features/docker/components/ContainerList.tsx b/src/ui/features/docker/components/ContainerList.tsx
new file mode 100644
index 000000000..e6886838a
--- /dev/null
+++ b/src/ui/features/docker/components/ContainerList.tsx
@@ -0,0 +1,83 @@
+import React from "react";
+import { Box } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import type { DockerContainer } from "@/types";
+import { ContainerCard } from "./ContainerCard.tsx";
+
+interface ContainerListProps {
+ containers: DockerContainer[];
+ sessionId: string;
+ onSelectContainer: (containerId: string) => void;
+ selectedContainerId?: string | null;
+ onRefresh?: () => void;
+ search?: string;
+ statusFilter?: string;
+}
+
+export function ContainerList({
+ containers,
+ sessionId,
+ onSelectContainer,
+ selectedContainerId = null,
+ onRefresh,
+ search = "",
+ statusFilter = "all",
+}: ContainerListProps): React.ReactElement {
+ const { t } = useTranslation();
+
+ const filtered = React.useMemo(() => {
+ return containers.filter((c) => {
+ const name = c.name.startsWith("/") ? c.name.slice(1) : c.name;
+ const matchesSearch =
+ name.toLowerCase().includes(search.toLowerCase()) ||
+ c.image.toLowerCase().includes(search.toLowerCase()) ||
+ c.id.toLowerCase().includes(search.toLowerCase());
+ return (
+ matchesSearch && (statusFilter === "all" || c.state === statusFilter)
+ );
+ });
+ }, [containers, search, statusFilter]);
+
+ if (containers.length === 0) {
+ return (
+ <div className="flex flex-col items-center justify-center h-full opacity-20 py-20">
+ <Box className="size-16 mb-4" />
+ <span className="text-xl font-bold uppercase tracking-widest">
+ {t("docker.noContainersFound")}
+ </span>
+ <span className="text-xs font-semibold">
+ {t("docker.noContainersFoundHint")}
+ </span>
+ </div>
+ );
+ }
+
+ if (filtered.length === 0) {
+ return (
+ <div className="flex flex-col items-center justify-center h-full opacity-20 py-20">
+ <Box className="size-16 mb-4" />
+ <span className="text-xl font-bold uppercase tracking-widest">
+ {t("docker.noContainersMatchFilters")}
+ </span>
+ <span className="text-xs font-semibold">
+ {t("docker.noContainersMatchFiltersHint")}
+ </span>
+ </div>
+ );
+ }
+
+ return (
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3">
+ {filtered.map((container) => (
+ <ContainerCard
+ key={container.id}
+ container={container}
+ sessionId={sessionId}
+ onSelect={() => onSelectContainer(container.id)}
+ isSelected={selectedContainerId === container.id}
+ onRefresh={onRefresh}
+ />
+ ))}
+ </div>
+ );
+}
diff --git a/src/ui/features/docker/components/ContainerStats.tsx b/src/ui/features/docker/components/ContainerStats.tsx
new file mode 100644
index 000000000..6aac7f583
--- /dev/null
+++ b/src/ui/features/docker/components/ContainerStats.tsx
@@ -0,0 +1,240 @@
+import React from "react";
+import {
+ Activity,
+ Cpu,
+ HardDrive,
+ Info,
+ MemoryStick,
+ Network,
+ RefreshCw,
+} from "lucide-react";
+import type { DockerStats } from "@/types";
+import { getContainerStats } from "@/main-axios.ts";
+import { useTranslation } from "react-i18next";
+import { SectionCard } from "@/components/section-card";
+import { DockerBadge } from "./ContainerCard.tsx";
+
+interface ContainerStatsProps {
+ sessionId: string;
+ containerId: string;
+ containerName: string;
+ containerState: string;
+}
+
+export function ContainerStats({
+ sessionId,
+ containerId,
+ containerName,
+ containerState,
+}: ContainerStatsProps): React.ReactElement {
+ const { t } = useTranslation();
+ const [stats, setStats] = React.useState<DockerStats | null>(null);
+ const [isLoading, setIsLoading] = React.useState(false);
+ const [error, setError] = React.useState<string | null>(null);
+
+ const fetchStats = React.useCallback(async () => {
+ if (containerState !== "running") return;
+ setIsLoading(true);
+ setError(null);
+ try {
+ const data = await getContainerStats(sessionId, containerId);
+ setStats(data);
+ } catch (err) {
+ setError(
+ err instanceof Error ? err.message : t("docker.failedToFetchStats"),
+ );
+ } finally {
+ setIsLoading(false);
+ }
+ }, [sessionId, containerId, containerState]);
+
+ React.useEffect(() => {
+ fetchStats();
+ const interval = setInterval(fetchStats, 2000);
+ return () => clearInterval(interval);
+ }, [fetchStats]);
+
+ if (containerState !== "running") {
+ return (
+ <div className="flex flex-col items-center justify-center h-full opacity-20 py-20">
+ <Activity className="size-16 mb-4" />
+ <span className="text-xl font-bold uppercase tracking-widest">
+ {t("docker.containerNotRunning")}
+ </span>
+ <span className="text-xs font-semibold">
+ {t("docker.startContainerToViewStats")}
+ </span>
+ </div>
+ );
+ }
+
+ if (isLoading && !stats) {
+ return (
+ <div className="flex flex-col items-center justify-center h-full opacity-40 py-20">
+ <RefreshCw className="size-8 animate-spin mb-4" />
+ <span className="text-sm font-semibold">
+ {t("docker.loadingStats")}
+ </span>
+ </div>
+ );
+ }
+
+ if (error) {
+ return (
+ <div className="flex flex-col items-center justify-center h-full opacity-40 py-20">
+ <Activity className="size-8 mb-4" />
+ <span className="text-sm font-semibold text-destructive">
+ {t("docker.errorLoadingStats")}
+ </span>
+ <span className="text-xs text-muted-foreground mt-1">{error}</span>
+ </div>
+ );
+ }
+
+ if (!stats) {
+ return (
+ <div className="flex flex-col items-center justify-center h-full opacity-20 py-20">
+ <span className="text-sm font-semibold">
+ {t("docker.noStatsAvailable")}
+ </span>
+ </div>
+ );
+ }
+
+ const cpuPercent = parseFloat(stats.cpu) || 0;
+ const memPercent = parseFloat(stats.memoryPercent) || 0;
+
+ return (
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3">
+ <SectionCard
+ title={t("docker.cpuUsage")}
+ icon={<Cpu className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-3 py-2">
+ <div className="flex items-end justify-between">
+ <span className="text-3xl font-bold text-accent-brand">
+ {stats.cpu}
+ </span>
+ <span className="text-[10px] text-muted-foreground uppercase font-bold">
+ {t("docker.current")}
+ </span>
+ </div>
+ <div className="h-1.5 bg-muted w-full overflow-hidden">
+ <div
+ className="h-full bg-accent-brand transition-all duration-500"
+ style={{ width: `${Math.min(cpuPercent, 100)}%` }}
+ />
+ </div>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title={t("docker.memoryUsage")}
+ icon={<MemoryStick className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-3 py-2">
+ <div className="flex items-end justify-between">
+ <span className="text-3xl font-bold text-accent-brand">
+ {stats.memoryPercent}
+ </span>
+ <span className="text-[10px] text-muted-foreground uppercase font-bold">
+ {stats.memoryUsed} / {stats.memoryLimit}
+ </span>
+ </div>
+ <div className="h-1.5 bg-muted w-full overflow-hidden">
+ <div
+ className="h-full bg-accent-brand transition-all duration-500"
+ style={{ width: `${Math.min(memPercent, 100)}%` }}
+ />
+ </div>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title={t("docker.networkIo")}
+ icon={<Network className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-1 py-1">
+ <div className="flex justify-between items-center py-1">
+ <span className="text-xs text-muted-foreground font-semibold">
+ {t("docker.input")}
+ </span>
+ <span className="text-sm font-mono font-bold">
+ {stats.netInput}
+ </span>
+ </div>
+ <div className="flex justify-between items-center py-1">
+ <span className="text-xs text-muted-foreground font-semibold">
+ {t("docker.output")}
+ </span>
+ <span className="text-sm font-mono font-bold text-accent-brand">
+ {stats.netOutput}
+ </span>
+ </div>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title={t("docker.blockIo")}
+ icon={<HardDrive className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-1 py-1">
+ <div className="flex justify-between items-center py-1">
+ <span className="text-xs text-muted-foreground font-semibold">
+ {t("docker.read")}
+ </span>
+ <span className="text-sm font-mono font-bold">
+ {stats.blockRead}
+ </span>
+ </div>
+ <div className="flex justify-between items-center py-1">
+ <span className="text-xs text-muted-foreground font-semibold">
+ {t("docker.write")}
+ </span>
+ <span className="text-sm font-mono font-bold text-accent-brand">
+ {stats.blockWrite}
+ </span>
+ </div>
+ {stats.pids && (
+ <div className="flex justify-between items-center py-1">
+ <span className="text-xs text-muted-foreground font-semibold">
+ {t("docker.pids")}
+ </span>
+ <span className="text-sm font-mono font-bold">{stats.pids}</span>
+ </div>
+ )}
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title={t("docker.containerInformation")}
+ icon={<Info className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-1.5 py-1">
+ <div className="flex justify-between items-center text-xs py-1 border-b border-border/50">
+ <span className="text-muted-foreground font-semibold">
+ {t("docker.name")}
+ </span>
+ <span className="font-mono">{containerName}</span>
+ </div>
+ <div className="flex justify-between items-center text-xs py-1 border-b border-border/50">
+ <span className="text-muted-foreground font-semibold">
+ {t("docker.id")}
+ </span>
+ <span className="font-mono">{containerId.substring(0, 12)}</span>
+ </div>
+ <div className="flex justify-between items-center text-xs py-1">
+ <span className="text-muted-foreground font-semibold">
+ {t("docker.state")}
+ </span>
+ <DockerBadge
+ state={
+ containerState as import("@/types").DockerContainer["state"]
+ }
+ />
+ </div>
+ </div>
+ </SectionCard>
+ </div>
+ );
+}
diff --git a/src/ui/features/docker/components/LogViewer.tsx b/src/ui/features/docker/components/LogViewer.tsx
new file mode 100644
index 000000000..81cc4c2b5
--- /dev/null
+++ b/src/ui/features/docker/components/LogViewer.tsx
@@ -0,0 +1,233 @@
+import React from "react";
+import { Button } from "@/components/button.tsx";
+import { Input } from "@/components/input.tsx";
+import { Separator } from "@/components/separator.tsx";
+import { Download, RefreshCw, Search, Trash2 } from "lucide-react";
+import { toast } from "sonner";
+import { useTranslation } from "react-i18next";
+import type { DockerLogOptions } from "@/types";
+import { getContainerLogs, downloadContainerLogs } from "@/main-axios.ts";
+
+interface LogViewerProps {
+ sessionId: string;
+ containerId: string;
+ containerName: string;
+}
+
+function AdminToggle({
+ on,
+ onToggle,
+ label,
+}: {
+ on: boolean;
+ onToggle: () => void;
+ label: string;
+}) {
+ return (
+ <div className="flex items-center gap-2">
+ <span className="text-[10px] text-muted-foreground uppercase font-bold">
+ {label}
+ </span>
+ <button
+ type="button"
+ onClick={onToggle}
+ className={`relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center border-2 transition-colors ${on ? "bg-accent-brand border-accent-brand" : "bg-muted border-border"}`}
+ >
+ <span
+ className={`pointer-events-none inline-block h-3 w-3 bg-background shadow-sm transition-transform ${on ? "translate-x-4" : "translate-x-0.5"}`}
+ />
+ </button>
+ </div>
+ );
+}
+
+function getLogColor(line: string): string {
+ if (line.includes(" WARN") || line.includes(" warn"))
+ return "text-yellow-400/90";
+ if (line.includes(" ERROR") || line.includes(" error"))
+ return "text-destructive";
+ if (line.includes(" DEBUG") || line.includes(" debug"))
+ return "text-muted-foreground/60";
+ return "text-foreground/90";
+}
+
+export function LogViewer({
+ sessionId,
+ containerId,
+ containerName,
+}: LogViewerProps): React.ReactElement {
+ const { t } = useTranslation();
+ const [rawLogs, setRawLogs] = React.useState<string[]>([]);
+ const [isLoading, setIsLoading] = React.useState(false);
+ const [isDownloading, setIsDownloading] = React.useState(false);
+ const [tailLines, setTailLines] = React.useState("100");
+ const [showTimestamps, setShowTimestamps] = React.useState(false);
+ const [autoRefresh, setAutoRefresh] = React.useState(false);
+ const [logSearch, setLogSearch] = React.useState("");
+ const logsEndRef = React.useRef<HTMLDivElement>(null);
+
+ const fetchLogs = React.useCallback(async () => {
+ setIsLoading(true);
+ try {
+ const options: DockerLogOptions = {
+ tail: tailLines === "all" ? undefined : parseInt(tailLines, 10),
+ timestamps: showTimestamps,
+ };
+ const data = await getContainerLogs(sessionId, containerId, options);
+ setRawLogs(data.logs.split("\n").filter(Boolean));
+ } catch (error) {
+ toast.error(
+ `Failed to fetch logs: ${error instanceof Error ? error.message : "Unknown error"}`,
+ );
+ } finally {
+ setIsLoading(false);
+ }
+ }, [sessionId, containerId, tailLines, showTimestamps]);
+
+ React.useEffect(() => {
+ fetchLogs();
+ }, [fetchLogs]);
+
+ React.useEffect(() => {
+ if (!autoRefresh) return;
+ const interval = setInterval(fetchLogs, 3000);
+ return () => clearInterval(interval);
+ }, [autoRefresh, fetchLogs]);
+
+ React.useEffect(() => {
+ if (autoRefresh && logsEndRef.current) {
+ logsEndRef.current.scrollIntoView({ behavior: "smooth" });
+ }
+ }, [rawLogs, autoRefresh]);
+
+ const handleDownload = async () => {
+ setIsDownloading(true);
+ try {
+ const blob = await downloadContainerLogs(sessionId, containerId, {
+ timestamps: showTimestamps,
+ });
+ const url = window.URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = `${containerName.replace(/[^a-z0-9]/gi, "_")}_logs.txt`;
+ document.body.appendChild(a);
+ a.click();
+ window.URL.revokeObjectURL(url);
+ document.body.removeChild(a);
+ toast.success(t("docker.logsDownloaded"));
+ } catch (error) {
+ toast.error(
+ `Failed to download logs: ${error instanceof Error ? error.message : "Unknown error"}`,
+ );
+ } finally {
+ setIsDownloading(false);
+ }
+ };
+
+ const filteredLogs = logSearch
+ ? rawLogs.filter((l) => l.toLowerCase().includes(logSearch.toLowerCase()))
+ : rawLogs;
+
+ return (
+ <div className="flex flex-col flex-1 min-h-0 gap-3">
+ <div className="flex items-center justify-between bg-card border border-border px-3 py-2 gap-3 flex-wrap">
+ <div className="flex items-center gap-3 shrink-0 flex-wrap">
+ <AdminToggle
+ on={autoRefresh}
+ onToggle={() => setAutoRefresh(!autoRefresh)}
+ label={t("docker.autoRefresh")}
+ />
+ <Separator orientation="vertical" className="h-4" />
+ <AdminToggle
+ on={showTimestamps}
+ onToggle={() => setShowTimestamps(!showTimestamps)}
+ label={t("docker.timestamps")}
+ />
+ <Separator orientation="vertical" className="h-4" />
+ <select
+ value={tailLines}
+ onChange={(e) => setTailLines(e.target.value)}
+ className="h-7 px-2 text-[10px] bg-background border border-border text-foreground outline-none uppercase font-bold"
+ >
+ <option value="50">{t("docker.last50")}</option>
+ <option value="100">{t("docker.last100")}</option>
+ <option value="500">{t("docker.last500")}</option>
+ <option value="1000">{t("docker.last1000")}</option>
+ <option value="all">{t("docker.allLogs")}</option>
+ </select>
+ <Separator orientation="vertical" className="h-4" />
+ <span className="text-[10px] text-muted-foreground uppercase font-bold tracking-widest">
+ {filteredLogs.length}/{rawLogs.length} {t("docker.lines")}
+ </span>
+ </div>
+ <div className="flex items-center gap-2">
+ <div className="relative flex-1 max-w-64">
+ <Search className="absolute left-2.5 top-1/2 -translate-y-1/2 size-3 text-muted-foreground" />
+ <Input
+ placeholder={t("docker.filterLogs")}
+ value={logSearch}
+ onChange={(e) => setLogSearch(e.target.value)}
+ className="pl-7 h-7 text-xs bg-background border-border rounded-none"
+ />
+ </div>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-7 text-xs gap-1.5"
+ onClick={fetchLogs}
+ disabled={isLoading}
+ >
+ <RefreshCw
+ className={`size-3 ${isLoading ? "animate-spin" : ""}`}
+ />
+ {t("docker.refresh")}
+ </Button>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-7 text-xs gap-1.5"
+ onClick={handleDownload}
+ disabled={isDownloading}
+ >
+ <Download className="size-3" />
+ {t("docker.download")}
+ </Button>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-7 text-xs gap-1.5"
+ onClick={() => setRawLogs([])}
+ >
+ <Trash2 className="size-3" />
+ {t("docker.clear")}
+ </Button>
+ </div>
+ </div>
+
+ <div className="flex-1 bg-[#111210] border border-border p-3 overflow-auto font-mono text-xs leading-relaxed scrollbar-thin min-h-0">
+ {filteredLogs.length > 0 ? (
+ filteredLogs.map((line, i) => {
+ const tsEnd = line.indexOf(" ", 1);
+ const maybeTs = tsEnd > 10 ? line.substring(0, tsEnd) : null;
+ const rest = maybeTs ? line.substring(tsEnd) : line;
+ return (
+ <div key={i} className="whitespace-pre-wrap break-all">
+ {maybeTs && (
+ <span className="text-accent-brand/50">{maybeTs}</span>
+ )}
+ <span className={getLogColor(rest)}>{rest}</span>
+ </div>
+ );
+ })
+ ) : (
+ <span className="text-muted-foreground italic">
+ {logSearch
+ ? t("docker.noLogsMatching", { query: logSearch })
+ : t("docker.noLogsAvailable")}
+ </span>
+ )}
+ <div ref={logsEndRef} />
+ </div>
+ </div>
+ );
+}
diff --git a/src/ui/desktop/apps/features/file-manager/FileManager.tsx b/src/ui/features/file-manager/FileManager.tsx
similarity index 80%
rename from src/ui/desktop/apps/features/file-manager/FileManager.tsx
rename to src/ui/features/file-manager/FileManager.tsx
index 57c7bffc7..c2a4fdb08 100644
--- a/src/ui/desktop/apps/features/file-manager/FileManager.tsx
+++ b/src/ui/features/file-manager/FileManager.tsx
@@ -5,6 +5,7 @@ import React, {
useCallback,
useMemo,
} from "react";
+import { cn } from "@/lib/utils.ts";
import { FileManagerGrid } from "./FileManagerGrid.tsx";
import { FileManagerSidebar } from "./FileManagerSidebar.tsx";
import { FileManagerContextMenu } from "./FileManagerContextMenu.tsx";
@@ -16,16 +17,16 @@ import {
} from "./components/WindowManager.tsx";
import { FileWindow } from "./components/FileWindow.tsx";
import { DiffWindow } from "./components/DiffWindow.tsx";
-import { useDragToDesktop } from "../../../../hooks/useDragToDesktop.ts";
-import { useDragToSystemDesktop } from "../../../../hooks/useDragToSystemDesktop.ts";
+import { useDragToDesktop } from "@/features/file-manager/hooks/useDragToDesktop";
+import { useDragToSystemDesktop } from "@/features/file-manager/hooks/useDragToSystemDesktop";
import { useConfirmation } from "@/hooks/use-confirmation.ts";
-import { Button } from "@/components/ui/button.tsx";
-import { Input } from "@/components/ui/input.tsx";
+import { Button } from "@/components/button.tsx";
+import { Input } from "@/components/input.tsx";
import { toast } from "sonner";
import { useTranslation } from "react-i18next";
-import { TOTPDialog } from "@/ui/desktop/navigation/dialogs/TOTPDialog.tsx";
-import { SSHAuthDialog } from "@/ui/desktop/navigation/dialogs/SSHAuthDialog.tsx";
-import { WarpgateDialog } from "@/ui/desktop/navigation/dialogs/WarpgateDialog.tsx";
+import { TOTPDialog } from "@/ssh/dialogs/TOTPDialog.tsx";
+import { SSHAuthDialog } from "@/ssh/dialogs/SSHAuthDialog.tsx";
+import { WarpgateDialog } from "@/ssh/dialogs/WarpgateDialog.tsx";
import { PermissionsDialog } from "./components/PermissionsDialog.tsx";
import { CompressDialog } from "./components/CompressDialog.tsx";
import { SudoPasswordDialog } from "./SudoPasswordDialog.tsx";
@@ -38,24 +39,36 @@ import {
Grid3X3,
List,
ArrowUpDown,
+ ChevronLeft,
+ ChevronRight,
+ ArrowUp,
+ Plus,
+ Folder,
+ Trash2,
+ Copy,
+ Layout,
} from "lucide-react";
+import { Card } from "@/components/card.tsx";
+import { Separator } from "@/components/separator.tsx";
import {
DropdownMenu,
DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu.tsx";
+} from "@/components/dropdown-menu.tsx";
import { TerminalWindow } from "./components/TerminalWindow.tsx";
-import type { SSHHost, FileItem } from "../../../types/index.js";
+import type { SSHHost, FileItem } from "@/types/index";
import {
ConnectionLogProvider,
useConnectionLog,
-} from "@/ui/desktop/navigation/connection-log/ConnectionLogContext.tsx";
-import { ConnectionLog } from "@/ui/desktop/navigation/connection-log/ConnectionLog.tsx";
+} from "@/ssh/connection-log/ConnectionLogContext.tsx";
+import { ConnectionLog } from "@/ssh/connection-log/ConnectionLog.tsx";
import type { LogEntry } from "@/types/connection-log.ts";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
+import { SimpleLoader } from "@/lib/SimpleLoader.tsx";
import {
listSSHFiles,
resolveSSHPath,
@@ -84,7 +97,8 @@ import {
extractSSHArchive,
compressSSHFiles,
setSudoPassword,
-} from "@/ui/main-axios.ts";
+ getServerMetricsById,
+} from "@/main-axios.ts";
import type { SidebarItem } from "./FileManagerSidebar.tsx";
interface FileManagerProps {
@@ -145,6 +159,10 @@ function FileManagerContent({ initialHost, onClose }: FileManagerProps) {
const [currentPath, setCurrentPath] = useState(
initialHost?.defaultPath || "/",
);
+ const [navHistory, setNavHistory] = useState<string[]>([
+ initialHost?.defaultPath || "/",
+ ]);
+ const [navIndex, setNavIndex] = useState(0);
const [files, setFiles] = useState<FileItem[]>([]);
const [isLoading, setIsLoading] = useState(false);
const [sshSessionId, setSshSessionId] = useState<string | null>(null);
@@ -181,6 +199,12 @@ function FileManagerContent({ initialHost, onClose }: FileManagerProps) {
const [pinnedFiles, setPinnedFiles] = useState<Set<string>>(new Set());
const [sidebarRefreshTrigger, setSidebarRefreshTrigger] = useState(0);
const [hasConnectionError, setHasConnectionError] = useState<boolean>(false);
+ const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false);
+ const [diskInfo, setDiskInfo] = useState<{
+ usedHuman: string;
+ totalHuman: string;
+ percent: number;
+ } | null>(null);
const [contextMenu, setContextMenu] = useState<{
x: number;
@@ -669,6 +693,41 @@ function FileManagerContent({ initialHost, onClose }: FileManagerProps) {
[sshSessionId, loadDirectory],
);
+ const navigateTo = useCallback(
+ (path: string) => {
+ setCurrentPath(path);
+ setNavHistory((prev) => {
+ const next = [...prev.slice(0, navIndex + 1), path];
+ setNavIndex(next.length - 1);
+ return next;
+ });
+ },
+ [navIndex],
+ );
+
+ const goBack = useCallback(() => {
+ if (navIndex > 0) {
+ const newIndex = navIndex - 1;
+ setNavIndex(newIndex);
+ setCurrentPath(navHistory[newIndex]);
+ }
+ }, [navIndex, navHistory]);
+
+ const goForward = useCallback(() => {
+ if (navIndex < navHistory.length - 1) {
+ const newIndex = navIndex + 1;
+ setNavIndex(newIndex);
+ setCurrentPath(navHistory[newIndex]);
+ }
+ }, [navIndex, navHistory]);
+
+ const goUp = useCallback(() => {
+ if (currentPath === "/") return;
+ const parent =
+ currentPath.substring(0, currentPath.lastIndexOf("/")) || "/";
+ navigateTo(parent);
+ }, [currentPath, navigateTo]);
+
useEffect(() => {
if (sshSessionId && currentPath) {
if (!initialLoadDoneRef.current) {
@@ -2234,6 +2293,21 @@ function FileManagerContent({ initialHost, onClose }: FileManagerProps) {
useEffect(() => {
if (currentHost?.id) {
loadPinnedFiles();
+ getServerMetricsById(currentHost.id)
+ .then((metrics) => {
+ if (
+ metrics?.disk?.percent != null &&
+ metrics.disk.usedHuman &&
+ metrics.disk.totalHuman
+ ) {
+ setDiskInfo({
+ usedHuman: metrics.disk.usedHuman,
+ totalHuman: metrics.disk.totalHuman,
+ percent: metrics.disk.percent,
+ });
+ }
+ })
+ .catch(() => {});
}
}, [currentHost?.id]);
@@ -2289,74 +2363,222 @@ function FileManagerContent({ initialHost, onClose }: FileManagerProps) {
}
return (
- <div className="h-full flex flex-col bg-canvas relative">
+ <div className="h-full flex flex-col bg-background relative">
<div
className="h-full w-full flex flex-col"
style={{
visibility: isConnectionLogExpanded ? "hidden" : "visible",
}}
>
- <div className="flex-shrink-0 border-b border-edge">
- <div className="flex items-center justify-between p-3">
- <div className="flex items-center gap-2">
- <h2 className="font-semibold text-foreground">
- {currentHost.name}
- </h2>
- <span className="text-sm text-muted-foreground">
- {currentHost.ip}:{currentHost.port}
- </span>
+ <Card className="flex flex-col shrink-0 mx-3 mt-3 rounded-none shadow-none border-border">
+ <div className="flex flex-row items-center justify-between px-3 py-2 gap-2">
+ <div className="flex items-center gap-1">
+ <Button
+ variant="ghost"
+ size="icon"
+ onClick={() => setMobileSidebarOpen((o) => !o)}
+ className="md:hidden size-8 rounded-none"
+ title={t("fileManager.toggleSidebar")}
+ >
+ <Layout className="size-4" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ onClick={goBack}
+ disabled={navIndex <= 0}
+ className="size-8 rounded-none"
+ >
+ <ChevronLeft className="size-4" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ onClick={goForward}
+ disabled={navIndex >= navHistory.length - 1}
+ className="size-8 rounded-none"
+ >
+ <ChevronRight className="size-4" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ onClick={goUp}
+ disabled={currentPath === "/"}
+ className="size-8 rounded-none"
+ >
+ <ArrowUp className="size-4" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ onClick={handleRefreshDirectory}
+ disabled={isLoading}
+ className="size-8 rounded-none"
+ >
+ <RefreshCw
+ className={`size-4 ${isLoading ? "animate-spin" : ""}`}
+ />
+ </Button>
+ </div>
+
+ <div className="hidden md:flex flex-1 items-center px-3 h-8 bg-muted/50 border border-border rounded-none gap-2 overflow-hidden">
+ <Folder className="size-3.5 text-accent-brand shrink-0" />
+ <div className="flex items-center gap-1 overflow-x-auto scrollbar-none text-[10px] font-bold uppercase tracking-widest whitespace-nowrap">
+ {currentPath.split("/").map((part, i, arr) => (
+ <React.Fragment key={i}>
+ {part === "" && i === 0 ? (
+ <button
+ onClick={() => navigateTo("/")}
+ className="hover:text-accent-brand transition-colors"
+ >
+ {t("fileManager.root")}
+ </button>
+ ) : part !== "" ? (
+ <button
+ onClick={() =>
+ navigateTo(arr.slice(0, i + 1).join("/") || "/")
+ }
+ className="hover:text-accent-brand transition-colors"
+ >
+ {part}
+ </button>
+ ) : null}
+ {i < arr.length - 1 && part !== "" && (
+ <ChevronRight className="size-3 text-muted-foreground shrink-0" />
+ )}
+ {i === 0 && arr.length > 1 && part === "" && (
+ <ChevronRight className="size-3 text-muted-foreground shrink-0" />
+ )}
+ </React.Fragment>
+ ))}
+ </div>
</div>
<div className="flex items-center gap-2">
- <div className="relative">
- <Search className="absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" />
+ {selectedFiles.length > 0 && (
+ <div className="flex items-center gap-1 px-2 py-1 bg-accent-brand/10 border border-accent-brand/20 text-accent-brand text-[10px] font-black uppercase tracking-tighter">
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-accent-brand hover:bg-accent-brand/20 rounded-none"
+ onClick={() => handleDeleteFiles(selectedFiles)}
+ >
+ <Trash2 className="size-3.5" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-accent-brand hover:bg-accent-brand/20 rounded-none"
+ onClick={() => handleCopyFiles(selectedFiles)}
+ >
+ <Copy className="size-3.5" />
+ </Button>
+ </div>
+ )}
+
+ <div className="relative w-28 md:w-48">
+ <Search className="absolute left-2.5 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground" />
<Input
placeholder={t("fileManager.searchFiles")}
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
- className="pl-8 w-48 h-9 bg-button border-edge"
+ className="h-8 pl-8 text-xs bg-muted/50 border-border rounded-none focus:ring-1 focus:ring-accent-brand/50"
/>
</div>
- <div className="flex border border-edge rounded-md">
+ <div className="flex items-center border border-border rounded-none overflow-hidden">
<Button
- variant={viewMode === "grid" ? "default" : "ghost"}
- size="sm"
+ variant={viewMode === "grid" ? "secondary" : "ghost"}
+ size="icon"
onClick={() => setViewMode("grid")}
- className="rounded-r-none h-9"
+ className={`size-8 rounded-none border-y-0 border-l-0 border-r border-border ${viewMode === "grid" ? "bg-accent-brand/10 text-accent-brand" : ""}`}
>
- <Grid3X3 className="w-4 h-4" />
+ <Grid3X3 className="size-4" />
</Button>
<Button
- variant={viewMode === "list" ? "default" : "ghost"}
- size="sm"
+ variant={viewMode === "list" ? "secondary" : "ghost"}
+ size="icon"
onClick={() => setViewMode("list")}
- className="rounded-l-none h-9"
+ className={`size-8 rounded-none border-y-0 border-r-0 border-border ${viewMode === "list" ? "bg-accent-brand/10 text-accent-brand" : ""}`}
>
- <List className="w-4 h-4" />
+ <List className="size-4" />
</Button>
</div>
+ <label
+ className="hidden md:block cursor-pointer"
+ title={t("fileManager.upload")}
+ >
+ <input
+ type="file"
+ multiple
+ className="hidden"
+ onChange={(e) => {
+ const files = e.target.files;
+ if (files) handleFilesDropped(files);
+ }}
+ />
+ <div className="h-8 px-3 flex items-center gap-1.5 border border-border hover:bg-muted text-muted-foreground hover:text-foreground transition-colors text-[10px] font-bold uppercase tracking-widest">
+ <Upload className="size-3.5" /> {t("fileManager.upload")}
+ </div>
+ </label>
+
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button variant="outline" size="sm" className="h-9">
- <ArrowUpDown className="w-4 h-4" />
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-8 gap-1.5 border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 rounded-none font-bold uppercase tracking-widest text-[10px]"
+ >
+ <Plus className="size-3.5" />
+ {t("fileManager.new")}
</Button>
</DropdownMenuTrigger>
- <DropdownMenuContent align="end">
+ <DropdownMenuContent
+ align="end"
+ className="w-44 rounded-none border-border bg-card"
+ >
+ <DropdownMenuItem
+ onClick={handleCreateNewFolder}
+ className="rounded-none text-xs font-semibold gap-2 focus:bg-accent-brand/10 focus:text-accent-brand"
+ >
+ <FolderPlus className="size-4 text-accent-brand" />
+ {t("fileManager.newFolder")}
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={handleCreateNewFile}
+ className="rounded-none text-xs font-semibold gap-2 focus:bg-accent-brand/10 focus:text-accent-brand"
+ >
+ <FilePlus className="size-4 text-muted-foreground" />
+ {t("fileManager.newFile")}
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuLabel className="text-[10px] uppercase tracking-widest text-muted-foreground py-1">
+ {t("fileManager.sortBy")}
+ </DropdownMenuLabel>
<DropdownMenuRadioGroup
value={sortBy}
onValueChange={(v) =>
setSortBy(v as "name" | "modified" | "size")
}
>
- <DropdownMenuRadioItem value="name">
+ <DropdownMenuRadioItem
+ value="name"
+ className="rounded-none text-xs"
+ >
{t("fileManager.sortByName")}
</DropdownMenuRadioItem>
- <DropdownMenuRadioItem value="modified">
+ <DropdownMenuRadioItem
+ value="modified"
+ className="rounded-none text-xs"
+ >
{t("fileManager.sortByDate")}
</DropdownMenuRadioItem>
- <DropdownMenuRadioItem value="size">
+ <DropdownMenuRadioItem
+ value="size"
+ className="rounded-none text-xs"
+ >
{t("fileManager.sortBySize")}
</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
@@ -2365,20 +2587,159 @@ function FileManagerContent({ initialHost, onClose }: FileManagerProps) {
value={sortOrder}
onValueChange={(v) => setSortOrder(v as "asc" | "desc")}
>
- <DropdownMenuRadioItem value="asc">
+ <DropdownMenuRadioItem
+ value="asc"
+ className="rounded-none text-xs"
+ >
{t("fileManager.ascending")}
</DropdownMenuRadioItem>
- <DropdownMenuRadioItem value="desc">
+ <DropdownMenuRadioItem
+ value="desc"
+ className="rounded-none text-xs"
+ >
{t("fileManager.descending")}
</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
+ </div>
+ </div>
- <Button
- variant="outline"
- size="sm"
- onClick={() => {
+ {/* Mobile breadcrumb row */}
+ <div className="md:hidden flex items-center px-3 pb-2 gap-2">
+ <div className="flex-1 flex items-center px-3 h-8 bg-muted/50 border border-border gap-2 overflow-hidden">
+ <Folder className="size-3.5 text-accent-brand shrink-0" />
+ <div className="flex items-center gap-1 overflow-x-auto scrollbar-none text-[10px] font-bold uppercase tracking-widest whitespace-nowrap">
+ {currentPath.split("/").map((part, i, arr) => (
+ <React.Fragment key={i}>
+ {part === "" && i === 0 ? (
+ <button
+ onClick={() => navigateTo("/")}
+ className="hover:text-accent-brand transition-colors"
+ >
+ {t("fileManager.root")}
+ </button>
+ ) : part !== "" ? (
+ <button
+ onClick={() =>
+ navigateTo(arr.slice(0, i + 1).join("/") || "/")
+ }
+ className="hover:text-accent-brand transition-colors"
+ >
+ {part}
+ </button>
+ ) : null}
+ {i < arr.length - 1 && part !== "" && (
+ <ChevronRight className="size-3 text-muted-foreground shrink-0" />
+ )}
+ {i === 0 && arr.length > 1 && part === "" && (
+ <ChevronRight className="size-3 text-muted-foreground shrink-0" />
+ )}
+ </React.Fragment>
+ ))}
+ </div>
+ </div>
+ </div>
+ </Card>
+
+ <div
+ className="flex-1 flex px-3 pb-3 pt-2 gap-3 min-h-0 relative"
+ {...dragHandlers}
+ >
+ {/* Mobile sidebar backdrop */}
+ {mobileSidebarOpen && (
+ <div
+ className="fixed inset-0 z-20 bg-black/40 md:hidden"
+ onClick={() => setMobileSidebarOpen(false)}
+ />
+ )}
+
+ {/* Sidebar — fixed overlay on mobile, static on desktop */}
+ <div
+ className={cn(
+ "w-56 flex-shrink-0 h-full flex flex-col",
+ "md:flex",
+ mobileSidebarOpen
+ ? "fixed left-0 top-0 bottom-0 w-64 z-30 flex"
+ : "hidden md:flex",
+ )}
+ >
+ <Card className="flex-1 flex flex-col rounded-none shadow-none p-0 gap-0 overflow-hidden border-border">
+ <FileManagerSidebar
+ currentHost={currentHost}
+ currentPath={currentPath}
+ onPathChange={navigateTo}
+ onLoadDirectory={loadDirectory}
+ onFileOpen={handleSidebarFileOpen}
+ sshSessionId={sshSessionId}
+ refreshTrigger={sidebarRefreshTrigger}
+ diskInfo={diskInfo ?? undefined}
+ />
+ </Card>
+ </div>
+
+ <Card className="flex-1 relative overflow-hidden rounded-none shadow-none p-0 gap-0 min-h-0 flex flex-col border-border">
+ <div className="flex-1 relative min-h-0 h-full">
+ <FileManagerGrid
+ files={filteredFiles}
+ selectedFiles={selectedFiles}
+ onFileSelect={() => {}}
+ onFileOpen={handleFileOpen}
+ onSelectionChange={setSelection}
+ currentPath={currentPath}
+ isLoading={isLoading}
+ onPathChange={navigateTo}
+ onRefresh={handleRefreshDirectory}
+ onUpload={handleFilesDropped}
+ sortBy={sortBy}
+ sortOrder={sortOrder}
+ onSortChange={(field) => {
+ if (field === sortBy) {
+ setSortOrder(sortOrder === "asc" ? "desc" : "asc");
+ } else {
+ setSortBy(field);
+ setSortOrder("asc");
+ }
+ }}
+ onDownload={(files) => files.forEach(handleDownloadFile)}
+ onContextMenu={handleContextMenu}
+ viewMode={viewMode}
+ onRename={handleRenameConfirm}
+ editingFile={editingFile}
+ onStartEdit={handleStartEdit}
+ onCancelEdit={handleCancelEdit}
+ onDelete={handleDeleteFiles}
+ onCopy={handleCopyFiles}
+ onCut={handleCutFiles}
+ onPaste={handlePasteFiles}
+ onUndo={handleUndo}
+ hasClipboard={!!clipboard}
+ onFileDrop={handleFileDrop}
+ onFileDiff={handleFileDiff}
+ onSystemDragStart={handleFileDragStart}
+ onSystemDragEnd={handleFileDragEnd}
+ createIntent={createIntent}
+ onConfirmCreate={handleConfirmCreate}
+ onCancelCreate={handleCancelCreate}
+ onNewFile={handleCreateNewFile}
+ onNewFolder={handleCreateNewFolder}
+ />
+
+ <FileManagerContextMenu
+ x={contextMenu.x}
+ y={contextMenu.y}
+ files={contextMenu.files}
+ isVisible={contextMenu.isVisible}
+ onClose={() =>
+ setContextMenu((prev) => ({ ...prev, isVisible: false }))
+ }
+ onDownload={(files) => files.forEach(handleDownloadFile)}
+ onRename={handleRenameFile}
+ onCopy={handleCopyFiles}
+ onCut={handleCutFiles}
+ onPaste={handlePasteFiles}
+ onDelete={handleDeleteFiles}
+ onUpload={() => {
const input = document.createElement("input");
input.type = "file";
input.multiple = true;
@@ -2388,145 +2749,25 @@ function FileManagerContent({ initialHost, onClose }: FileManagerProps) {
};
input.click();
}}
- className="h-9"
- >
- <Upload className="w-4 h-4 mr-2" />
- {t("fileManager.upload")}
- </Button>
-
- <Button
- variant="outline"
- size="sm"
- onClick={handleCreateNewFolder}
- className="h-9"
- >
- <FolderPlus className="w-4 h-4 mr-2" />
- {t("fileManager.newFolder")}
- </Button>
-
- <Button
- variant="outline"
- size="sm"
- onClick={handleCreateNewFile}
- className="h-9"
- >
- <FilePlus className="w-4 h-4 mr-2" />
- {t("fileManager.newFile")}
- </Button>
-
- <Button
- variant="outline"
- size="sm"
- onClick={handleRefreshDirectory}
- className="h-9"
- >
- <RefreshCw className="w-4 h-4" />
- </Button>
+ onNewFolder={handleCreateNewFolder}
+ onNewFile={handleCreateNewFile}
+ onRefresh={handleRefreshDirectory}
+ hasClipboard={!!clipboard}
+ onDragToDesktop={() => handleDragToDesktop(contextMenu.files)}
+ onOpenTerminal={(path) => handleOpenTerminal(path)}
+ onRunExecutable={(file) => handleRunExecutable(file)}
+ onPinFile={handlePinFile}
+ onUnpinFile={handleUnpinFile}
+ onAddShortcut={handleAddShortcut}
+ isPinned={isPinnedFile}
+ currentPath={currentPath}
+ onProperties={handleOpenPermissionsDialog}
+ onExtractArchive={handleExtractArchive}
+ onCompress={handleOpenCompressDialog}
+ onCopyPath={handleCopyPath}
+ />
</div>
- </div>
- </div>
-
- <div className="flex-1 flex" {...dragHandlers}>
- <div className="w-64 flex-shrink-0 h-full">
- <FileManagerSidebar
- currentHost={currentHost}
- currentPath={currentPath}
- onPathChange={setCurrentPath}
- onLoadDirectory={loadDirectory}
- onFileOpen={handleSidebarFileOpen}
- sshSessionId={sshSessionId}
- refreshTrigger={sidebarRefreshTrigger}
- />
- </div>
-
- <div className="flex-1 relative">
- <FileManagerGrid
- files={filteredFiles}
- selectedFiles={selectedFiles}
- onFileSelect={() => {}}
- onFileOpen={handleFileOpen}
- onSelectionChange={setSelection}
- currentPath={currentPath}
- isLoading={isLoading}
- onPathChange={setCurrentPath}
- onRefresh={handleRefreshDirectory}
- onUpload={handleFilesDropped}
- sortBy={sortBy}
- sortOrder={sortOrder}
- onSortChange={(field) => {
- if (field === sortBy) {
- setSortOrder(sortOrder === "asc" ? "desc" : "asc");
- } else {
- setSortBy(field);
- setSortOrder("asc");
- }
- }}
- onDownload={(files) => files.forEach(handleDownloadFile)}
- onContextMenu={handleContextMenu}
- viewMode={viewMode}
- onRename={handleRenameConfirm}
- editingFile={editingFile}
- onStartEdit={handleStartEdit}
- onCancelEdit={handleCancelEdit}
- onDelete={handleDeleteFiles}
- onCopy={handleCopyFiles}
- onCut={handleCutFiles}
- onPaste={handlePasteFiles}
- onUndo={handleUndo}
- hasClipboard={!!clipboard}
- onFileDrop={handleFileDrop}
- onFileDiff={handleFileDiff}
- onSystemDragStart={handleFileDragStart}
- onSystemDragEnd={handleFileDragEnd}
- createIntent={createIntent}
- onConfirmCreate={handleConfirmCreate}
- onCancelCreate={handleCancelCreate}
- onNewFile={handleCreateNewFile}
- onNewFolder={handleCreateNewFolder}
- />
-
- <FileManagerContextMenu
- x={contextMenu.x}
- y={contextMenu.y}
- files={contextMenu.files}
- isVisible={contextMenu.isVisible}
- onClose={() =>
- setContextMenu((prev) => ({ ...prev, isVisible: false }))
- }
- onDownload={(files) => files.forEach(handleDownloadFile)}
- onRename={handleRenameFile}
- onCopy={handleCopyFiles}
- onCut={handleCutFiles}
- onPaste={handlePasteFiles}
- onDelete={handleDeleteFiles}
- onUpload={() => {
- const input = document.createElement("input");
- input.type = "file";
- input.multiple = true;
- input.onchange = (e) => {
- const files = (e.target as HTMLInputElement).files;
- if (files) handleFilesDropped(files);
- };
- input.click();
- }}
- onNewFolder={handleCreateNewFolder}
- onNewFile={handleCreateNewFile}
- onRefresh={handleRefreshDirectory}
- hasClipboard={!!clipboard}
- onDragToDesktop={() => handleDragToDesktop(contextMenu.files)}
- onOpenTerminal={(path) => handleOpenTerminal(path)}
- onRunExecutable={(file) => handleRunExecutable(file)}
- onPinFile={handlePinFile}
- onUnpinFile={handleUnpinFile}
- onAddShortcut={handleAddShortcut}
- isPinned={isPinnedFile}
- currentPath={currentPath}
- onProperties={handleOpenPermissionsDialog}
- onExtractArchive={handleExtractArchive}
- onCompress={handleOpenCompressDialog}
- onCopyPath={handleCopyPath}
- />
- </div>
+ </Card>
</div>
</div>
diff --git a/src/ui/desktop/apps/features/file-manager/FileManagerApp.tsx b/src/ui/features/file-manager/FileManagerApp.tsx
similarity index 87%
rename from src/ui/desktop/apps/features/file-manager/FileManagerApp.tsx
rename to src/ui/features/file-manager/FileManagerApp.tsx
index ee0f1fecb..98ecc6429 100644
--- a/src/ui/desktop/apps/features/file-manager/FileManagerApp.tsx
+++ b/src/ui/features/file-manager/FileManagerApp.tsx
@@ -1,6 +1,6 @@
import React from "react";
-import { FileManager } from "@/ui/desktop/apps/features/file-manager/FileManager.tsx";
-import { FullScreenAppWrapper } from "@/ui/desktop/apps/FullScreenAppWrapper.tsx";
+import { FileManager } from "@/features/file-manager/FileManager.tsx";
+import { FullScreenAppWrapper } from "@/features/FullScreenAppWrapper.tsx";
interface FileManagerAppProps {
hostId?: string;
diff --git a/src/ui/desktop/apps/features/file-manager/FileManagerContextMenu.tsx b/src/ui/features/file-manager/FileManagerContextMenu.tsx
similarity index 88%
rename from src/ui/desktop/apps/features/file-manager/FileManagerContextMenu.tsx
rename to src/ui/features/file-manager/FileManagerContextMenu.tsx
index f300c89d1..12eb7a2da 100644
--- a/src/ui/desktop/apps/features/file-manager/FileManagerContextMenu.tsx
+++ b/src/ui/features/file-manager/FileManagerContextMenu.tsx
@@ -20,7 +20,7 @@ import {
FileArchive,
} from "lucide-react";
import { useTranslation } from "react-i18next";
-import { Kbd, KbdKey, KbdSeparator } from "@/components/ui/kbd.tsx";
+import { Kbd, KbdKey, KbdSeparator } from "@/components/kbd.tsx";
interface FileItem {
name: string;
@@ -225,7 +225,7 @@ export function FileManagerContextMenu({
: files[0].path.substring(0, files[0].path.lastIndexOf("/"));
menuItems.push({
- icon: <Terminal className="w-4 h-4" />,
+ icon: <Terminal className="size-3.5" />,
label:
files[0].type === "directory"
? t("fileManager.openTerminalInFolder")
@@ -237,7 +237,7 @@ export function FileManagerContextMenu({
if (isSingleFile && hasExecutableFiles && onRunExecutable) {
menuItems.push({
- icon: <Play className="w-4 h-4" />,
+ icon: <Play className="size-3.5" />,
label: t("fileManager.run"),
action: () => onRunExecutable(files[0]),
shortcut: "Enter",
@@ -253,7 +253,7 @@ export function FileManagerContextMenu({
if (hasFiles && onPreview) {
menuItems.push({
- icon: <Eye className="w-4 h-4" />,
+ icon: <Eye className="size-3.5" />,
label: t("fileManager.preview"),
action: () => onPreview(files[0]),
disabled: !isSingleFile || files[0].type !== "file",
@@ -262,7 +262,7 @@ export function FileManagerContextMenu({
if (hasFiles && onDownload) {
menuItems.push({
- icon: <Download className="w-4 h-4" />,
+ icon: <Download className="size-3.5" />,
label: isMultipleFiles
? t("fileManager.downloadFiles", { count: files.length })
: t("fileManager.downloadFile"),
@@ -289,7 +289,7 @@ export function FileManagerContextMenu({
if (isArchive) {
menuItems.push({
- icon: <FileArchive className="w-4 h-4" />,
+ icon: <FileArchive className="size-3.5" />,
label: t("fileManager.extractArchive"),
action: () => onExtractArchive(files[0]),
shortcut: "Ctrl+E",
@@ -299,7 +299,7 @@ export function FileManagerContextMenu({
if (isFileContext && onCompress) {
menuItems.push({
- icon: <FileArchive className="w-4 h-4" />,
+ icon: <FileArchive className="size-3.5" />,
label: isMultipleFiles
? t("fileManager.compressFiles")
: t("fileManager.compressFile"),
@@ -313,13 +313,15 @@ export function FileManagerContextMenu({
if (isCurrentlyPinned && onUnpinFile) {
menuItems.push({
- icon: <Star className="w-4 h-4 fill-yellow-400" />,
+ icon: (
+ <Star className="size-3.5 fill-accent-brand text-accent-brand" />
+ ),
label: t("fileManager.unpinFile"),
action: () => onUnpinFile(files[0]),
});
} else if (!isCurrentlyPinned && onPinFile) {
menuItems.push({
- icon: <Star className="w-4 h-4" />,
+ icon: <Star className="size-3.5" />,
label: t("fileManager.pinFile"),
action: () => onPinFile(files[0]),
});
@@ -328,7 +330,7 @@ export function FileManagerContextMenu({
if (isSingleFile && files[0].type === "directory" && onAddShortcut) {
menuItems.push({
- icon: <Bookmark className="w-4 h-4" />,
+ icon: <Bookmark className="size-3.5" />,
label: t("fileManager.addToShortcuts"),
action: () => onAddShortcut(files[0].path),
});
@@ -346,7 +348,7 @@ export function FileManagerContextMenu({
if (isSingleFile && onRename) {
menuItems.push({
- icon: <Edit3 className="w-4 h-4" />,
+ icon: <Edit3 className="size-3.5" />,
label: t("fileManager.rename"),
action: () => onRename(files[0]),
shortcut: "F6",
@@ -355,7 +357,7 @@ export function FileManagerContextMenu({
if (onCopy) {
menuItems.push({
- icon: <Copy className="w-4 h-4" />,
+ icon: <Copy className="size-3.5" />,
label: isMultipleFiles
? t("fileManager.copyFiles", { count: files.length })
: t("fileManager.copy"),
@@ -366,7 +368,7 @@ export function FileManagerContextMenu({
if (onCut) {
menuItems.push({
- icon: <Scissors className="w-4 h-4" />,
+ icon: <Scissors className="size-3.5" />,
label: isMultipleFiles
? t("fileManager.cutFiles", { count: files.length })
: t("fileManager.cut"),
@@ -377,7 +379,7 @@ export function FileManagerContextMenu({
if (onCopyPath) {
menuItems.push({
- icon: <Clipboard className="w-4 h-4" />,
+ icon: <Clipboard className="size-3.5" />,
label: isMultipleFiles
? t("fileManager.copyPaths")
: t("fileManager.copyPath"),
@@ -392,7 +394,7 @@ export function FileManagerContextMenu({
if (isSingleFile && onProperties) {
menuItems.push({
- icon: <Info className="w-4 h-4" />,
+ icon: <Info className="size-3.5" />,
label: t("fileManager.properties"),
action: () => onProperties(files[0]),
});
@@ -404,7 +406,7 @@ export function FileManagerContextMenu({
if (onDelete) {
menuItems.push({
- icon: <Trash2 className="w-4 h-4" />,
+ icon: <Trash2 className="size-3.5" />,
label: isMultipleFiles
? t("fileManager.deleteFiles", { count: files.length })
: t("fileManager.delete"),
@@ -416,7 +418,7 @@ export function FileManagerContextMenu({
} else {
if (onOpenTerminal && currentPath) {
menuItems.push({
- icon: <Terminal className="w-4 h-4" />,
+ icon: <Terminal className="size-3.5" />,
label: t("fileManager.openTerminalHere"),
action: () => onOpenTerminal(currentPath),
shortcut: "Ctrl+Shift+T",
@@ -425,7 +427,7 @@ export function FileManagerContextMenu({
if (onUpload) {
menuItems.push({
- icon: <Upload className="w-4 h-4" />,
+ icon: <Upload className="size-3.5" />,
label: t("fileManager.uploadFile"),
action: onUpload,
shortcut: "Ctrl+U",
@@ -438,7 +440,7 @@ export function FileManagerContextMenu({
if (onNewFolder) {
menuItems.push({
- icon: <FolderPlus className="w-4 h-4" />,
+ icon: <FolderPlus className="size-3.5" />,
label: t("fileManager.newFolder"),
action: onNewFolder,
shortcut: "Ctrl+Shift+N",
@@ -447,7 +449,7 @@ export function FileManagerContextMenu({
if (onNewFile) {
menuItems.push({
- icon: <FilePlus className="w-4 h-4" />,
+ icon: <FilePlus className="size-3.5" />,
label: t("fileManager.newFile"),
action: onNewFile,
shortcut: "Ctrl+N",
@@ -460,7 +462,7 @@ export function FileManagerContextMenu({
if (onRefresh) {
menuItems.push({
- icon: <RefreshCw className="w-4 h-4" />,
+ icon: <RefreshCw className="size-3.5" />,
label: t("fileManager.refresh"),
action: onRefresh,
shortcut: "Ctrl+Y",
@@ -469,7 +471,7 @@ export function FileManagerContextMenu({
if (hasClipboard && onPaste) {
menuItems.push({
- icon: <Clipboard className="w-4 h-4" />,
+ icon: <Clipboard className="size-3.5" />,
label: t("fileManager.paste"),
action: onPaste,
shortcut: "Ctrl+V",
@@ -526,6 +528,7 @@ export function FileManagerContextMenu({
<div
ref={menuRef}
data-context-menu
+<<<<<<< HEAD:src/ui/desktop/apps/features/file-manager/FileManagerContextMenu.tsx
className={cn(
"fixed bg-canvas border border-edge rounded-lg shadow-xl min-w-[180px] max-w-[250px] z-[99995] overflow-x-hidden overflow-y-auto",
)}
@@ -540,7 +543,7 @@ export function FileManagerContextMenu({
return (
<div
key={`separator-${index}`}
- className="border-t border-edge"
+ className="border-t border-border"
/>
);
}
@@ -549,11 +552,12 @@ export function FileManagerContextMenu({
<button
key={index}
className={cn(
- "w-full px-3 py-2 text-left text-sm flex items-center justify-between",
- "hover:bg-hover transition-colors",
- "first:rounded-t-lg last:rounded-b-lg",
- item.disabled && "opacity-50 cursor-not-allowed",
- item.danger && "text-red-400 hover:bg-red-500/10",
+ "w-full px-3 h-9 text-left text-[10px] font-bold uppercase tracking-widest flex items-center justify-between",
+ "hover:bg-accent-brand/10 hover:text-accent-brand transition-colors cursor-pointer rounded-none",
+ item.disabled &&
+ "opacity-50 cursor-not-allowed hover:bg-transparent hover:text-current",
+ item.danger &&
+ "text-destructive hover:bg-destructive/10 hover:text-destructive",
)}
onClick={() => {
if (!item.disabled) {
@@ -563,9 +567,9 @@ export function FileManagerContextMenu({
}}
disabled={item.disabled}
>
- <div className="flex items-center gap-3 flex-1 min-w-0">
+ <div className="flex items-center gap-2.5 flex-1 min-w-0">
<div className="flex-shrink-0">{item.icon}</div>
- <span className="flex-1">{item.label}</span>
+ <span className="flex-1 truncate">{item.label}</span>
</div>
{item.shortcut && (
<div className="ml-2 flex-shrink-0">
diff --git a/src/ui/desktop/apps/features/file-manager/FileManagerGrid.tsx b/src/ui/features/file-manager/FileManagerGrid.tsx
similarity index 71%
rename from src/ui/desktop/apps/features/file-manager/FileManagerGrid.tsx
rename to src/ui/features/file-manager/FileManagerGrid.tsx
index e8e6f9be0..5f0db67a6 100644
--- a/src/ui/desktop/apps/features/file-manager/FileManagerGrid.tsx
+++ b/src/ui/features/file-manager/FileManagerGrid.tsx
@@ -24,8 +24,8 @@ import {
Edit,
} from "lucide-react";
import { useTranslation } from "react-i18next";
-import type { FileItem } from "../../../types/index.js";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
+import type { FileItem } from "@/types/index";
+import { SimpleLoader } from "@/lib/SimpleLoader.tsx";
interface CreateIntent {
id: string;
@@ -884,116 +884,7 @@ export function FileManagerGrid({
]);
return (
- <div className="h-full flex flex-col bg-canvas overflow-hidden relative">
- <div className="flex-shrink-0 border-b border-edge">
- <div className="flex items-center gap-1 p-2 border-b border-edge">
- <button
- onClick={goBack}
- disabled={historyIndex <= 0}
- className={cn(
- "p-1 rounded hover:bg-hover",
- historyIndex <= 0 && "opacity-50 cursor-not-allowed",
- )}
- title={t("common.back")}
- >
- <ChevronLeft className="w-4 h-4" />
- </button>
- <button
- onClick={goForward}
- disabled={historyIndex >= navigationHistory.length - 1}
- className={cn(
- "p-1 rounded hover:bg-hover",
- historyIndex >= navigationHistory.length - 1 &&
- "opacity-50 cursor-not-allowed",
- )}
- title={t("common.forward")}
- >
- <ChevronRight className="w-4 h-4" />
- </button>
- <button
- onClick={goUp}
- disabled={currentPath === "/"}
- className={cn(
- "p-1 rounded hover:bg-hover",
- currentPath === "/" && "opacity-50 cursor-not-allowed",
- )}
- title={t("fileManager.parentDirectory")}
- >
- <ArrowUp className="w-4 h-4" />
- </button>
- <button
- onClick={onRefresh}
- className="p-1 rounded hover:bg-hover"
- title={t("common.refresh")}
- >
- <RefreshCw className="w-4 h-4" />
- </button>
- </div>
-
- <div className="flex items-center px-3 py-2 text-sm">
- {isEditingPath ? (
- <div className="flex-1 flex items-center gap-2">
- <input
- type="text"
- value={editPathValue}
- onChange={(e) => setEditPathValue(e.target.value)}
- onKeyDown={(e) => {
- if (e.key === "Enter") {
- confirmEditingPath();
- } else if (e.key === "Escape") {
- cancelEditingPath();
- }
- }}
- className="flex-1 px-2 py-1 bg-hover border border-edge rounded text-sm focus:outline-none focus:ring-1 focus:ring-primary"
- placeholder={t("fileManager.enterPath")}
- autoFocus
- />
- <button
- onClick={confirmEditingPath}
- className="px-2 py-1 bg-primary text-primary-foreground rounded text-sm hover:bg-primary/80"
- >
- {t("fileManager.confirm")}
- </button>
- <button
- onClick={cancelEditingPath}
- className="px-2 py-1 bg-secondary text-secondary-foreground rounded text-sm hover:bg-secondary/80"
- >
- {t("fileManager.cancel")}
- </button>
- </div>
- ) : (
- <>
- <button
- onClick={() => navigateToPath(-1)}
- className="hover:text-primary hover:underline mr-1"
- >
- /
- </button>
- {pathParts.map((part, index) => (
- <React.Fragment key={index}>
- <button
- onClick={() => navigateToPath(index)}
- className="hover:text-primary hover:underline"
- >
- {part}
- </button>
- {index < pathParts.length - 1 && (
- <span className="mx-1 text-muted-foreground">/</span>
- )}
- </React.Fragment>
- ))}
- <button
- onClick={startEditingPath}
- className="ml-2 p-1 rounded hover:bg-hover opacity-60 hover:opacity-100 flex items-center justify-center"
- title={t("fileManager.editPath")}
- >
- <Edit className="w-3 h-3" />
- </button>
- </>
- )}
- </div>
- </div>
-
+ <div className="h-full flex flex-col bg-card overflow-hidden relative">
<div className="flex-1 relative overflow-hidden">
<div
ref={gridRef}
@@ -1015,37 +906,22 @@ export function FileManagerGrid({
tabIndex={0}
>
{dragState.type === "external" && (
- <div className="absolute inset-0 flex items-center justify-center bg-background/50 backdrop-blur-sm z-10 pointer-events-none">
- <div className="text-center p-8 bg-background/95 border-2 border-dashed border-primary rounded-lg shadow-lg">
- <Upload className="w-16 h-16 mx-auto mb-4 text-primary" />
- <p className="text-xl font-semibold text-foreground mb-2">
+ <div className="absolute inset-0 flex items-center justify-center bg-background/50 z-10 pointer-events-none">
+ <div className="text-center p-8 bg-card/95 border border-accent-brand/40 flex flex-col items-center gap-4">
+ <Upload className="size-12 text-accent-brand" />
+ <p className="text-[10px] font-bold uppercase tracking-widest text-accent-brand">
{t("fileManager.dragFilesToUpload")}
</p>
- <p className="text-sm text-muted-foreground">
- {t("fileManager.dragSystemFilesToUpload")}
- </p>
</div>
</div>
)}
{files.length === 0 && !createIntent ? (
- <div className="h-full flex items-center justify-center p-8">
- <div className="text-center">
- <Folder className="w-16 h-16 mx-auto mb-4 text-muted-foreground/50" />
- <p className="text-lg font-medium text-foreground mb-4">
- {t("fileManager.emptyFolder")}
- </p>
- <div className="space-y-3">
- <div className="flex items-center justify-center gap-2 text-sm text-muted-foreground bg-muted/50 rounded-md px-3 py-2">
- <Upload className="w-4 h-4" />
- {t("fileManager.dragSystemFilesToUpload")}
- </div>
- <div className="flex items-center justify-center gap-2 text-sm text-muted-foreground bg-muted/50 rounded-md px-3 py-2">
- <Download className="w-4 h-4" />
- {t("fileManager.dragFilesToWindowToDownload")}
- </div>
- </div>
- </div>
+ <div className="h-full flex flex-col items-center justify-center text-muted-foreground opacity-10 gap-4 select-none pointer-events-none">
+ <Folder className="size-32" strokeWidth={1} />
+ <span className="text-2xl font-black uppercase tracking-[0.2em]">
+ {t("fileManager.emptyFolder")}
+ </span>
</div>
) : viewMode === "grid" ? (
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-4">
@@ -1067,16 +943,14 @@ export function FileManagerGrid({
data-file-path={file.path}
draggable={true}
className={cn(
- "group p-3 rounded-lg cursor-pointer",
- "hover:bg-accent hover:text-accent-foreground hover:scale-[1.02] border-2 border-transparent",
- isSelected &&
- "bg-primary/20 border-primary ring-2 ring-primary/20",
+ "group flex flex-col items-center p-3 rounded-none border-2 border-transparent transition-all cursor-pointer hover:bg-muted/50 select-none",
+ isSelected && "bg-accent-brand/10 border-accent-brand/40",
dragState.target?.path === file.path &&
- "bg-muted border-primary border-dashed relative z-10",
+ "bg-accent-brand/20 border-accent-brand border-dashed",
dragState.files.some((f) => f.path === file.path) &&
"opacity-50",
)}
- title={`${file.name} - Selected: ${isSelected} - SelectedCount: ${selectedFiles.length}`}
+ title={file.name}
onClick={(e) => handleFileClick(file, e)}
onContextMenu={(e) => {
e.preventDefault();
@@ -1089,100 +963,91 @@ export function FileManagerGrid({
onDrop={(e) => handleFileDrop(e, file)}
onDragEnd={handleFileDragEnd}
>
- <div className="flex flex-col items-center text-center">
- <div className="mb-2">{getFileIcon(file, viewMode)}</div>
-
- <div className="w-full flex flex-col items-center">
- {editingFile?.path === file.path ? (
- <input
- ref={editInputRef}
- type="text"
- value={editingName}
- onChange={(e) => setEditingName(e.target.value)}
- onKeyDown={handleEditKeyDown}
- onBlur={handleEditConfirm}
- className={cn(
- "max-w-[120px] min-w-[60px] w-fit rounded-md border border-edge bg-elevated px-2 py-1 text-xs shadow-xs transition-[color,box-shadow] outline-none",
- "text-center text-foreground placeholder:text-muted-foreground",
- "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[2px]",
- )}
- onClick={(e) => e.stopPropagation()}
- />
- ) : (
- <p
- className="text-xs text-foreground break-words px-1 py-0.5 rounded text-center leading-tight w-full"
- title={file.name}
- >
- {file.name}
- </p>
- )}
- {file.type === "file" &&
- file.size !== undefined &&
- file.size !== null && (
- <p className="text-xs text-muted-foreground mt-1">
- {formatFileSize(file.size)}
- </p>
- )}
- {file.type === "link" && file.linkTarget && (
- <p
- className="text-xs text-primary mt-1 break-words w-full leading-tight"
- title={file.linkTarget}
- >
- → {file.linkTarget}
+ <div className="relative mb-2 pointer-events-none">
+ {getFileIcon(file, viewMode)}
+ </div>
+
+ <div className="w-full flex flex-col items-center pointer-events-none">
+ {editingFile?.path === file.path ? (
+ <input
+ ref={editInputRef}
+ type="text"
+ value={editingName}
+ onChange={(e) => setEditingName(e.target.value)}
+ onKeyDown={handleEditKeyDown}
+ onBlur={handleEditConfirm}
+ className="max-w-[120px] min-w-[60px] w-fit border border-accent-brand/60 bg-card px-2 py-1 text-xs rounded-none outline-none focus:ring-1 focus:ring-accent-brand/50 text-center pointer-events-auto"
+ onClick={(e) => e.stopPropagation()}
+ />
+ ) : (
+ <p
+ className="text-[11px] font-bold uppercase tracking-tight text-center truncate w-full px-1"
+ title={file.name}
+ >
+ {file.name}
+ </p>
+ )}
+ {file.type === "file" &&
+ file.size !== undefined &&
+ file.size !== null && (
+ <p className="text-[10px] font-medium text-muted-foreground/60 mt-0.5">
+ {formatFileSize(file.size)}
</p>
)}
- </div>
+ {file.type === "link" && file.linkTarget && (
+ <p
+ className="text-[10px] text-accent-brand mt-0.5 truncate w-full text-center"
+ title={file.linkTarget}
+ >
+ → {file.linkTarget}
+ </p>
+ )}
</div>
</div>
);
})}
</div>
) : (
- <div className="space-y-1">
- <div className="flex items-center gap-3 p-2 border-b border-edge text-xs text-muted-foreground font-medium sticky top-0 bg-card z-10">
- <div className="flex-shrink-0 w-5" />
+ <div className="flex flex-col">
+ <div className="grid grid-cols-[1fr_120px_150px_80px_90px] gap-2 px-4 py-2 text-[10px] font-bold uppercase tracking-widest text-muted-foreground border-b border-border sticky top-0 bg-card z-10">
<div
- className="flex-1 min-w-0 flex items-center gap-1 cursor-pointer hover:text-foreground"
+ className="flex items-center gap-1 cursor-pointer hover:text-accent-brand transition-colors"
onClick={() => onSortChange?.("name")}
>
{t("fileManager.name")}
{sortBy === "name" &&
(sortOrder === "asc" ? (
- <ArrowUp className="w-3 h-3" />
+ <ArrowUp className="size-3" />
) : (
- <ArrowDown className="w-3 h-3" />
+ <ArrowDown className="size-3" />
))}
</div>
<div
- className="flex-shrink-0 w-32 flex items-center gap-1 cursor-pointer hover:text-foreground"
+ className="flex items-center gap-1 cursor-pointer hover:text-accent-brand transition-colors"
onClick={() => onSortChange?.("modified")}
>
{t("fileManager.modified")}
{sortBy === "modified" &&
(sortOrder === "asc" ? (
- <ArrowUp className="w-3 h-3" />
+ <ArrowUp className="size-3" />
) : (
- <ArrowDown className="w-3 h-3" />
+ <ArrowDown className="size-3" />
))}
</div>
+ <div className="hidden md:block" />
<div
- className="flex-shrink-0 w-16 flex items-center gap-1 cursor-pointer hover:text-foreground justify-end"
+ className="flex items-center gap-1 cursor-pointer hover:text-accent-brand transition-colors justify-end"
onClick={() => onSortChange?.("size")}
>
{t("fileManager.size")}
{sortBy === "size" &&
(sortOrder === "asc" ? (
- <ArrowUp className="w-3 h-3" />
+ <ArrowUp className="size-3" />
) : (
- <ArrowDown className="w-3 h-3" />
+ <ArrowDown className="size-3" />
))}
</div>
- <div className="flex-shrink-0 w-24 text-right hidden md:block">
- {t("fileManager.owner", "Owner")}
- </div>
- <div className="flex-shrink-0 w-20 text-right">
- {t("fileManager.permissions")}
- </div>
+ <div className="text-right">{t("fileManager.permissions")}</div>
</div>
{createIntent && (
<CreateIntentListItem
@@ -1202,11 +1067,10 @@ export function FileManagerGrid({
data-file-path={file.path}
draggable={true}
className={cn(
- "flex items-center gap-3 p-2 rounded cursor-pointer",
- "hover:bg-accent hover:text-accent-foreground",
- isSelected && "bg-primary/20 ring-2 ring-primary/20",
+ "grid grid-cols-[1fr_120px_150px_80px_90px] gap-2 px-4 py-2 items-center text-xs cursor-pointer border-b border-border hover:bg-muted/50 last:border-0 rounded-none select-none transition-colors",
+ isSelected && "bg-accent-brand/10",
dragState.target?.path === file.path &&
- "bg-muted border-primary border-dashed relative z-10",
+ "bg-accent-brand/20 border-accent-brand border-dashed",
dragState.files.some((f) => f.path === file.path) &&
"opacity-50",
)}
@@ -1222,11 +1086,10 @@ export function FileManagerGrid({
onDrop={(e) => handleFileDrop(e, file)}
onDragEnd={handleFileDragEnd}
>
- <div className="flex-shrink-0">
- {getFileIcon(file, viewMode)}
- </div>
-
- <div className="flex-1 min-w-0">
+ <div className="flex items-center gap-3 overflow-hidden pointer-events-none">
+ <div className="shrink-0">
+ {getFileIcon(file, viewMode)}
+ </div>
{editingFile?.path === file.path ? (
<input
ref={editInputRef}
@@ -1235,64 +1098,45 @@ export function FileManagerGrid({
onChange={(e) => setEditingName(e.target.value)}
onKeyDown={handleEditKeyDown}
onBlur={handleEditConfirm}
- className={cn(
- "flex-1 min-w-0 max-w-[200px] rounded-md border border-edge bg-elevated px-2 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none",
- "text-foreground placeholder:text-muted-foreground",
- "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[2px]",
- )}
+ className="flex-1 min-w-0 max-w-[200px] border border-accent-brand/60 bg-card px-2 py-1 text-xs rounded-none outline-none focus:ring-1 focus:ring-accent-brand/50 pointer-events-auto"
onClick={(e) => e.stopPropagation()}
/>
) : (
- <p
- className="text-sm text-foreground break-words px-1 py-0.5 rounded leading-tight"
+ <span
+ className="font-bold truncate uppercase tracking-tight"
title={file.name}
>
{file.name}
- </p>
- )}
- {file.type === "link" && file.linkTarget && (
- <p
- className="text-xs text-primary break-words leading-tight"
- title={file.linkTarget}
- >
- → {file.linkTarget}
- </p>
+ {file.type === "link" && file.linkTarget && (
+ <span className="text-accent-brand ml-1 normal-case font-normal">
+ → {file.linkTarget}
+ </span>
+ )}
+ </span>
)}
</div>
- <div className="flex-shrink-0 w-32">
- {file.modified && (
- <p className="text-xs text-muted-foreground">
- {file.modified}
- </p>
- )}
- </div>
+ <span className="text-[10px] text-muted-foreground pointer-events-none">
+ {file.modified || "—"}
+ </span>
- <div className="flex-shrink-0 w-16 text-right">
+ <span className="text-[10px] text-muted-foreground truncate hidden md:block pointer-events-none">
+ {file.owner
+ ? `${file.owner}${file.group ? `:${file.group}` : ""}`
+ : "—"}
+ </span>
+
+ <span className="text-[10px] text-right text-muted-foreground tabular-nums pointer-events-none">
{file.type === "file" &&
- file.size !== undefined &&
- file.size !== null && (
- <p className="text-xs text-muted-foreground">
- {formatFileSize(file.size)}
- </p>
- )}
- </div>
+ file.size !== undefined &&
+ file.size !== null
+ ? formatFileSize(file.size)
+ : "—"}
+ </span>
- <div className="flex-shrink-0 text-right w-24 hidden md:block">
- {file.owner && (
- <p className="text-xs text-muted-foreground truncate">
- {file.owner}
- {file.group ? `:${file.group}` : ""}
- </p>
- )}
- </div>
- <div className="flex-shrink-0 text-right w-20">
- {file.permissions && (
- <p className="text-xs text-muted-foreground font-mono">
- {file.permissions}
- </p>
- )}
- </div>
+ <span className="text-[10px] text-right font-mono text-muted-foreground/60 pointer-events-none">
+ {file.permissions || "—"}
+ </span>
</div>
);
})}
@@ -1301,7 +1145,7 @@ export function FileManagerGrid({
{isSelecting && selectionRect && (
<div
- className="absolute pointer-events-none border-2 border-primary bg-primary/10 z-50"
+ className="absolute border border-accent-brand bg-accent-brand/10 pointer-events-none z-50"
style={{
left: selectionRect.x,
top: selectionRect.y,
@@ -1313,15 +1157,15 @@ export function FileManagerGrid({
</div>
</div>
- <div className="flex-shrink-0 border-t border-edge px-4 py-2 text-xs text-muted-foreground">
- <div className="flex justify-between items-center">
- <span>{t("fileManager.itemCount", { count: files.length })}</span>
- {selectedFiles.length > 0 && (
- <span>
- {t("fileManager.selectedCount", { count: selectedFiles.length })}
- </span>
- )}
- </div>
+ <div className="px-4 py-1.5 bg-muted/30 border-t border-border flex items-center justify-between text-[10px] font-bold uppercase tracking-widest text-muted-foreground shrink-0">
+ <span>
+ {files.length} {t("fileManager.items")}
+ </span>
+ {selectedFiles.length > 0 && (
+ <span className="text-accent-brand">
+ {selectedFiles.length} {t("fileManager.selected")}
+ </span>
+ )}
</div>
{dragState.type === "internal" &&
@@ -1345,7 +1189,7 @@ export function FileManagerGrid({
zIndex: 999999,
}}
>
- <div className="bg-background border border-border rounded-md shadow-md px-3 py-2 flex items-center gap-2">
+ <div className="bg-card border border-border rounded-none shadow-md px-3 py-2 flex items-center gap-2">
{(() => {
const files =
dragState.files.length > 0
@@ -1354,8 +1198,8 @@ export function FileManagerGrid({
return dragState.target ? (
dragState.target.type === "directory" ? (
<>
- <Move className="w-4 h-4 text-blue-500" />
- <span className="text-sm font-medium text-foreground">
+ <Move className="size-3.5 text-accent-brand" />
+ <span className="text-[10px] font-bold uppercase tracking-widest text-foreground">
{t("fileManager.moveTo", {
name: dragState.target.name,
})}
@@ -1363,8 +1207,8 @@ export function FileManagerGrid({
</>
) : (
<>
- <GitCompare className="w-4 h-4 text-purple-500" />
- <span className="text-sm font-medium text-foreground">
+ <GitCompare className="size-3.5 text-accent-brand" />
+ <span className="text-[10px] font-bold uppercase tracking-widest text-foreground">
{t("fileManager.diffCompareWith", {
name: dragState.target.name,
})}
@@ -1373,8 +1217,8 @@ export function FileManagerGrid({
)
) : (
<>
- <Download className="w-4 h-4 text-green-500" />
- <span className="text-sm font-medium text-foreground">
+ <Download className="size-3.5 text-accent-brand" />
+ <span className="text-[10px] font-bold uppercase tracking-widest text-foreground">
{t("fileManager.dragOutsideToDownload", {
count: files.length,
})}
@@ -1421,30 +1265,28 @@ function CreateIntentGridItem({
};
return (
- <div className="group p-3 rounded-lg border-2 border-dashed border-primary bg-primary/10">
- <div className="flex flex-col items-center text-center">
- <div className="mb-2">
- {intent.type === "directory" ? (
- <Folder className="w-8 h-8 text-primary" />
- ) : (
- <File className="w-8 h-8 text-primary" />
- )}
- </div>
- <input
- ref={inputRef}
- type="text"
- value={inputName}
- onChange={(e) => setInputName(e.target.value)}
- onKeyDown={handleKeyDown}
- onBlur={() => onConfirm?.(inputName.trim())}
- className="w-full max-w-[120px] rounded-md border border-edge bg-elevated px-2 py-1 text-xs text-center text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[2px] outline-none"
- placeholder={
- intent.type === "directory"
- ? t("fileManager.folderName")
- : t("fileManager.fileName")
- }
- />
+ <div className="group flex flex-col items-center p-3 rounded-none border-2 border-dashed border-accent-brand/60 bg-accent-brand/5">
+ <div className="mb-2">
+ {intent.type === "directory" ? (
+ <Folder className="size-10 text-accent-brand" />
+ ) : (
+ <File className="size-10 text-accent-brand" />
+ )}
</div>
+ <input
+ ref={inputRef}
+ type="text"
+ value={inputName}
+ onChange={(e) => setInputName(e.target.value)}
+ onKeyDown={handleKeyDown}
+ onBlur={() => onConfirm?.(inputName.trim())}
+ className="w-full max-w-[120px] border border-accent-brand/60 bg-card px-2 py-1 text-xs text-center rounded-none outline-none focus:ring-1 focus:ring-accent-brand/50"
+ placeholder={
+ intent.type === "directory"
+ ? t("fileManager.folderName")
+ : t("fileManager.fileName")
+ }
+ />
</div>
);
}
@@ -1478,28 +1320,30 @@ function CreateIntentListItem({
};
return (
- <div className="flex items-center gap-3 p-2 rounded border-2 border-dashed border-primary bg-primary/10">
- <div className="flex-shrink-0">
- {intent.type === "directory" ? (
- <Folder className="w-6 h-6 text-primary" />
- ) : (
- <File className="w-6 h-6 text-primary" />
- )}
+ <div className="grid grid-cols-[1fr_120px_150px_80px_90px] gap-2 px-4 py-2 items-center border-b border-accent-brand/30 bg-accent-brand/5 rounded-none">
+ <div className="flex items-center gap-3">
+ <div className="shrink-0">
+ {intent.type === "directory" ? (
+ <Folder className="size-4 text-accent-brand" />
+ ) : (
+ <File className="size-4 text-accent-brand" />
+ )}
+ </div>
+ <input
+ ref={inputRef}
+ type="text"
+ value={inputName}
+ onChange={(e) => setInputName(e.target.value)}
+ onKeyDown={handleKeyDown}
+ onBlur={() => onConfirm?.(inputName.trim())}
+ className="flex-1 min-w-0 max-w-[200px] border border-accent-brand/60 bg-card px-2 py-1 text-xs rounded-none outline-none focus:ring-1 focus:ring-accent-brand/50"
+ placeholder={
+ intent.type === "directory"
+ ? t("fileManager.folderName")
+ : t("fileManager.fileName")
+ }
+ />
</div>
- <input
- ref={inputRef}
- type="text"
- value={inputName}
- onChange={(e) => setInputName(e.target.value)}
- onKeyDown={handleKeyDown}
- onBlur={() => onConfirm?.(inputName.trim())}
- className="flex-1 min-w-0 max-w-[200px] rounded-md border border-edge bg-elevated px-2 py-1 text-sm text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[2px] outline-none"
- placeholder={
- intent.type === "directory"
- ? t("fileManager.folderName")
- : t("fileManager.fileName")
- }
- />
</div>
);
}
diff --git a/src/ui/desktop/apps/features/file-manager/FileManagerSidebar.tsx b/src/ui/features/file-manager/FileManagerSidebar.tsx
similarity index 73%
rename from src/ui/desktop/apps/features/file-manager/FileManagerSidebar.tsx
rename to src/ui/features/file-manager/FileManagerSidebar.tsx
index 46431f424..162c6d7c9 100644
--- a/src/ui/desktop/apps/features/file-manager/FileManagerSidebar.tsx
+++ b/src/ui/features/file-manager/FileManagerSidebar.tsx
@@ -17,9 +17,9 @@ import {
removeRecentFile,
removePinnedFile,
removeFolderShortcut,
-} from "@/ui/main-axios.ts";
+} from "@/main-axios.ts";
import { toast } from "sonner";
-import FolderTree from "@/components/ui/folder.tsx";
+import FolderTree from "@/components/folder.tsx";
// ─── Interfaces ────────────────────────────────────────────────────────────────
@@ -69,6 +69,7 @@ interface FileManagerSidebarProps {
onFileOpen?: (file: SidebarItem) => void;
sshSessionId?: string;
refreshTrigger?: number;
+ diskInfo?: { usedHuman: string; totalHuman: string; percent: number };
}
// ─── Component ─────────────────────────────────────────────────────────────────
@@ -80,6 +81,7 @@ export function FileManagerSidebar({
onFileOpen,
sshSessionId,
refreshTrigger,
+ diskInfo,
}: FileManagerSidebarProps) {
const { t } = useTranslation();
@@ -496,10 +498,6 @@ export function FileManagerSidebar({
</FolderTree.Item>
);
- /**
- * Styled quick-access row (recent / pinned / shortcut).
- * Mirrors FolderTree.Item's visual language but adds onContextMenu support.
- */
const renderQuickAccessItem = (item: SidebarItem, icon: React.ReactNode) => {
const dirPath =
item.type === "shortcut"
@@ -508,44 +506,38 @@ export function FileManagerSidebar({
const isActive = currentPath === dirPath;
return (
- <div
+ <button
key={item.id}
className={cn(
- "flex items-center gap-2 py-1.5 pl-8 pr-3 text-sm cursor-pointer select-none transition-colors",
+ "w-full flex items-center gap-2.5 px-3 py-1.5 text-[11px] font-bold uppercase tracking-wider transition-colors text-left border-l-2",
isActive
- ? "bg-blue-50 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400 border-r-2 border-blue-600"
- : "hover:bg-gray-100 dark:hover:bg-slate-700/50 text-foreground",
+ ? "bg-accent-brand/10 text-accent-brand border-accent-brand"
+ : "text-muted-foreground hover:text-foreground hover:bg-muted border-transparent",
)}
onClick={() => handleQuickAccessClick(item)}
onContextMenu={(e) => handleContextMenu(e, item)}
title={item.path}
>
- {/* indent spacer matching FolderTree level-1 padding */}
- <span className="w-3 shrink-0" aria-hidden="true" />
- {icon}
+ <div className="shrink-0">{icon}</div>
<span className="flex-1 truncate">{item.name}</span>
- </div>
+ </button>
);
};
- /**
- * Section header + items list.
- * Returns null when items is empty so empty sections are hidden.
- */
const renderSection = (
title: string,
- headerIcon: React.ReactNode,
items: SidebarItem[],
renderItem: (item: SidebarItem) => React.ReactNode,
) => {
if (items.length === 0) return null;
return (
- <div className="mb-4">
- <div className="flex items-center gap-2 px-3 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wider">
- {headerIcon}
- {title}
+ <div>
+ <div className="px-3 py-1.5">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ {title}
+ </span>
</div>
- <div className="mt-0.5">{items.map((item) => renderItem(item))}</div>
+ {items.map((item) => renderItem(item))}
</div>
);
};
@@ -555,134 +547,158 @@ export function FileManagerSidebar({
// ─── Render ───────────────────────────────────────────────────────────────────
+ const storageUsedPct = diskInfo?.percent ?? null;
+
return (
<>
- <div className="h-full flex flex-col bg-canvas border-r border-edge">
- <div className="flex-1 relative overflow-hidden">
- <div className="absolute inset-1.5 overflow-y-auto thin-scrollbar space-y-1">
- {/* ── Recent files ──────────────────────────────────────── */}
- {renderSection(
- t("fileManager.recent"),
- <Clock className="w-3 h-3" />,
- recentItems,
- (item) =>
- renderQuickAccessItem(
- item,
- <File
- size={15}
- className={cn(
- "shrink-0",
- currentPath ===
- (item.path.substring(0, item.path.lastIndexOf("/")) ||
- "/")
- ? "text-blue-600 dark:text-blue-400"
- : "text-gray-500 dark:text-gray-400",
- )}
- />,
- ),
- )}
-
- {/* ── Pinned files ───────────────────────────────────────── */}
- {renderSection(
- t("fileManager.pinned"),
- <Star className="w-3 h-3" />,
- pinnedItems,
- (item) =>
- renderQuickAccessItem(
- item,
- <File
- size={15}
- className={cn(
- "shrink-0",
- currentPath ===
- (item.path.substring(0, item.path.lastIndexOf("/")) ||
- "/")
- ? "text-blue-600 dark:text-blue-400"
- : "text-gray-500 dark:text-gray-400",
- )}
- />,
- ),
- )}
+ <div className="h-full flex flex-col bg-card border-r border-border overflow-hidden">
+ <div className="flex-1 overflow-y-auto thin-scrollbar">
+ {/* ── Recent files ──────────────────────────────────────── */}
+ {renderSection(t("fileManager.recent"), recentItems, (item) =>
+ renderQuickAccessItem(
+ item,
+ <File
+ className={cn(
+ "size-3.5 shrink-0",
+ currentPath ===
+ (item.path.substring(0, item.path.lastIndexOf("/")) || "/")
+ ? "text-accent-brand"
+ : "text-muted-foreground/60",
+ )}
+ />,
+ ),
+ )}
+
+ {/* ── Pinned files ───────────────────────────────────────── */}
+ {renderSection(t("fileManager.pinned"), pinnedItems, (item) =>
+ renderQuickAccessItem(
+ item,
+ <Star
+ className={cn(
+ "size-3.5 shrink-0",
+ currentPath ===
+ (item.path.substring(0, item.path.lastIndexOf("/")) || "/")
+ ? "text-accent-brand fill-accent-brand"
+ : "text-muted-foreground/60",
+ )}
+ />,
+ ),
+ )}
+
+ {/* ── Folder shortcuts ───────────────────────────────────── */}
+ {renderSection(t("fileManager.folderShortcuts"), shortcuts, (item) =>
+ renderQuickAccessItem(
+ item,
+ <Folder
+ className={cn(
+ "size-3.5 shrink-0",
+ currentPath === item.path
+ ? "text-accent-brand"
+ : "text-muted-foreground/60",
+ )}
+ />,
+ ),
+ )}
- {/* ── Folder shortcuts ───────────────────────────────────── */}
- {renderSection(
- t("fileManager.folderShortcuts"),
- <Bookmark className="w-3 h-3" />,
- shortcuts,
- (item) =>
- renderQuickAccessItem(
- item,
- <Folder
- size={15}
- className={cn(
- "shrink-0",
- currentPath === item.path
- ? "text-blue-600 dark:text-blue-400"
- : "text-blue-500 dark:text-blue-400",
- )}
- />,
- ),
+ {/* ── Directory tree ─────────────────────────────────────── */}
+ <div
+ className={cn(
+ hasQuickAccessItems && "border-t border-border mt-1 pt-1",
)}
-
- {/* ── Directory tree ─────────────────────────────────────── */}
- <div
- className={cn(hasQuickAccessItems && "pt-3 border-t border-edge")}
- >
- <div className="flex items-center gap-2 px-3 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wider">
- <Folder className="w-3 h-3" />
+ >
+ <div className="px-3 py-1.5">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
{t("fileManager.directories")}
- </div>
+ </span>
+ </div>
+ <div className="px-1">
+ <FolderTree.Root
+ id="sidebar-directory-tree"
+ defaultExpanded={["root"]}
+ selectedId={selectedTreeId}
+ expandedIds={ancestorIds}
+ onSelect={(id) => handleDirectorySelect(id)}
+ className="bg-transparent border-0 rounded-none shadow-none"
+ >
+ {directoryTree.map((item) => renderFolderTreeItem(item))}
+ </FolderTree.Root>
+ </div>
+ </div>
- <div className="mt-1">
- {/*
- * FolderTree.Root manages its own expansion state internally.
- * We pass `onSelect` to be notified of clicks so we can:
- * 1. Navigate to the selected path (onPathChange)
- * 2. Lazy-load subdirectory children on first expand
- *
- * The root "/" folder is pre-expanded via defaultExpanded.
- *
- * className overrides strip the default card styling so the
- * tree blends seamlessly into the sidebar panel.
- */}
- <FolderTree.Root
- id="sidebar-directory-tree"
- defaultExpanded={["root"]}
- selectedId={selectedTreeId}
- expandedIds={ancestorIds}
- onSelect={(id) => handleDirectorySelect(id)}
- className="bg-transparent border-0 rounded-none shadow-none"
- >
- {directoryTree.map((item) => renderFolderTreeItem(item))}
- </FolderTree.Root>
+ {/* ── Storage — mobile only (inside scroll) ──────────────── */}
+ {diskInfo && storageUsedPct !== null && (
+ <div className="md:hidden">
+ <div className="border-t border-border mx-0 my-2" />
+ <div className="px-3 py-1.5">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ {t("fileManager.storage")}
+ </span>
+ </div>
+ <div className="px-3 pb-3 flex flex-col gap-2">
+ <div className="flex items-center justify-between text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ <span>{t("fileManager.disk")}</span>
+ <span className="text-accent-brand">
+ {storageUsedPct}% {t("fileManager.used")}
+ </span>
+ </div>
+ <div className="h-1.5 bg-muted rounded-none overflow-hidden border border-border">
+ <div
+ className="h-full bg-accent-brand"
+ style={{ width: `${storageUsedPct}%` }}
+ />
+ </div>
+ <span className="text-[10px] font-bold text-muted-foreground/60 tracking-tight">
+ {diskInfo.usedHuman} {t("fileManager.of")}{" "}
+ {diskInfo.totalHuman} {t("fileManager.used").toLowerCase()}
+ </span>
</div>
</div>
- </div>
+ )}
</div>
+
+ {/* ── Storage — desktop only (bottom of sidebar) ──────────── */}
+ {diskInfo && storageUsedPct !== null && (
+ <div className="hidden md:flex flex-col p-3 gap-2 border-t border-border shrink-0">
+ <div className="flex items-center justify-between text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ <span>{t("fileManager.storage")}</span>
+ <span className="text-accent-brand">
+ {storageUsedPct}% {t("fileManager.used")}
+ </span>
+ </div>
+ <div className="h-1.5 bg-muted rounded-none overflow-hidden border border-border">
+ <div
+ className="h-full bg-accent-brand"
+ style={{ width: `${storageUsedPct}%` }}
+ />
+ </div>
+ <span className="text-[10px] font-bold text-muted-foreground/60 tracking-tight">
+ {diskInfo.usedHuman} {t("fileManager.of")} {diskInfo.totalHuman}{" "}
+ {t("fileManager.used").toLowerCase()}
+ </span>
+ </div>
+ )}
</div>
{/* ── Context menu ─────────────────────────────────────────────── */}
{contextMenu.isVisible && contextMenu.item && (
<>
- {/* Transparent backdrop to capture outside clicks */}
<div className="fixed inset-0 z-40" />
<div
data-sidebar-context-menu
- className="fixed bg-canvas border border-edge rounded-lg shadow-xl min-w-[160px] z-50 overflow-hidden"
+ className="fixed bg-card border border-border rounded-none shadow-xl min-w-[180px] z-50 overflow-hidden"
style={{ left: contextMenu.x, top: contextMenu.y }}
>
- {/* Recent item actions */}
{contextMenu.item.type === "recent" && (
<>
<button
- className="w-full px-3 py-2 text-left text-sm flex items-center gap-3 hover:bg-hover text-foreground first:rounded-t-lg last:rounded-b-lg"
+ className="w-full px-3 h-9 text-left text-[10px] font-bold uppercase tracking-widest flex items-center gap-2.5 hover:bg-accent-brand/10 hover:text-accent-brand text-muted-foreground transition-colors"
onClick={() => {
handleRemoveRecentFile(contextMenu.item!);
closeContextMenu();
}}
>
- <Clock className="w-4 h-4 shrink-0" />
+ <Clock className="size-3.5 shrink-0" />
<span className="flex-1">
{t("fileManager.removeFromRecentFiles")}
</span>
@@ -690,15 +706,15 @@ export function FileManagerSidebar({
{recentItems.length > 1 && (
<>
- <div className="border-t border-edge" />
+ <div className="border-t border-border" />
<button
- className="w-full px-3 py-2 text-left text-sm flex items-center gap-3 hover:bg-red-500/10 text-red-400 first:rounded-t-lg last:rounded-b-lg"
+ className="w-full px-3 h-9 text-left text-[10px] font-bold uppercase tracking-widest flex items-center gap-2.5 text-destructive hover:bg-destructive/10 transition-colors"
onClick={() => {
handleClearAllRecent();
closeContextMenu();
}}
>
- <Clock className="w-4 h-4 shrink-0" />
+ <Clock className="size-3.5 shrink-0" />
<span className="flex-1">
{t("fileManager.clearAllRecentFiles")}
</span>
@@ -708,30 +724,28 @@ export function FileManagerSidebar({
</>
)}
- {/* Pinned item actions */}
{contextMenu.item.type === "pinned" && (
<button
- className="w-full px-3 py-2 text-left text-sm flex items-center gap-3 hover:bg-hover text-foreground first:rounded-t-lg last:rounded-b-lg"
+ className="w-full px-3 h-9 text-left text-[10px] font-bold uppercase tracking-widest flex items-center gap-2.5 hover:bg-accent-brand/10 hover:text-accent-brand text-muted-foreground transition-colors"
onClick={() => {
handleUnpinFile(contextMenu.item!);
closeContextMenu();
}}
>
- <Star className="w-4 h-4 shrink-0" />
+ <Star className="size-3.5 shrink-0" />
<span className="flex-1">{t("fileManager.unpinFile")}</span>
</button>
)}
- {/* Shortcut item actions */}
{contextMenu.item.type === "shortcut" && (
<button
- className="w-full px-3 py-2 text-left text-sm flex items-center gap-3 hover:bg-hover text-foreground first:rounded-t-lg last:rounded-b-lg"
+ className="w-full px-3 h-9 text-left text-[10px] font-bold uppercase tracking-widest flex items-center gap-2.5 hover:bg-accent-brand/10 hover:text-accent-brand text-muted-foreground transition-colors"
onClick={() => {
handleRemoveShortcut(contextMenu.item!);
closeContextMenu();
}}
>
- <Bookmark className="w-4 h-4 shrink-0" />
+ <Bookmark className="size-3.5 shrink-0" />
<span className="flex-1">
{t("fileManager.removeShortcut")}
</span>
diff --git a/src/ui/desktop/apps/features/file-manager/SudoPasswordDialog.tsx b/src/ui/features/file-manager/SudoPasswordDialog.tsx
similarity index 52%
rename from src/ui/desktop/apps/features/file-manager/SudoPasswordDialog.tsx
rename to src/ui/features/file-manager/SudoPasswordDialog.tsx
index 8aaef9f8e..0554cf006 100644
--- a/src/ui/desktop/apps/features/file-manager/SudoPasswordDialog.tsx
+++ b/src/ui/features/file-manager/SudoPasswordDialog.tsx
@@ -6,9 +6,10 @@ import {
DialogHeader,
DialogTitle,
DialogFooter,
-} from "@/components/ui/dialog.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
+} from "@/components/dialog.tsx";
+import { Button } from "@/components/button.tsx";
+import { PasswordInput } from "@/components/password-input.tsx";
+import { Shield } from "lucide-react";
import { useTranslation } from "react-i18next";
interface SudoPasswordDialogProps {
@@ -48,37 +49,45 @@ export function SudoPasswordDialog({
return (
<Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent className="sm:max-w-[500px] bg-canvas border-2 border-edge">
+ <DialogContent className="w-[calc(100vw-2rem)] sm:max-w-md rounded-none border-border bg-card">
<form onSubmit={handleSubmit}>
<DialogHeader>
- <DialogTitle>{t("fileManager.sudoPasswordRequired")}</DialogTitle>
- <DialogDescription className="text-muted-foreground">
+ <DialogTitle className="text-xs font-bold uppercase tracking-widest flex items-center gap-2">
+ <Shield className="size-4 text-accent-brand" />
+ {t("fileManager.sudoPasswordRequired")}
+ </DialogTitle>
+ <DialogDescription className="text-[10px] font-bold uppercase tracking-tight text-muted-foreground">
{t("fileManager.enterSudoPassword")}
</DialogDescription>
</DialogHeader>
- <div className="space-y-6 py-4">
- <div className="space-y-3">
- <PasswordInput
- value={password}
- onChange={(e) => setPassword(e.target.value)}
- placeholder={t("fileManager.sudoPassword")}
- autoFocus
- disabled={loading}
- />
- </div>
+ <div className="py-4">
+ <PasswordInput
+ value={password}
+ onChange={(e) => setPassword(e.target.value)}
+ placeholder={t("fileManager.sudoPassword")}
+ className="rounded-none bg-muted/50 border-border text-xs focus:ring-1 focus:ring-accent-brand/50"
+ autoFocus
+ disabled={loading}
+ />
</div>
<DialogFooter>
<Button
type="button"
- variant="outline"
+ variant="ghost"
onClick={() => onOpenChange(false)}
disabled={loading}
+ className="rounded-none text-[10px] font-bold uppercase tracking-widest"
>
{t("common.cancel")}
</Button>
- <Button type="submit" disabled={!password.trim() || loading}>
+ <Button
+ type="submit"
+ disabled={!password.trim() || loading}
+ variant="outline"
+ className="border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 rounded-none text-[10px] font-bold uppercase tracking-widest"
+ >
{loading ? t("common.loading") : t("common.confirm")}
</Button>
</DialogFooter>
diff --git a/src/ui/desktop/apps/features/file-manager/components/AudioPreview.tsx b/src/ui/features/file-manager/components/AudioPreview.tsx
similarity index 100%
rename from src/ui/desktop/apps/features/file-manager/components/AudioPreview.tsx
rename to src/ui/features/file-manager/components/AudioPreview.tsx
diff --git a/src/ui/desktop/apps/features/file-manager/components/CodeEditor.tsx b/src/ui/features/file-manager/components/CodeEditor.tsx
similarity index 100%
rename from src/ui/desktop/apps/features/file-manager/components/CodeEditor.tsx
rename to src/ui/features/file-manager/components/CodeEditor.tsx
diff --git a/src/ui/desktop/apps/features/file-manager/components/CompressDialog.tsx b/src/ui/features/file-manager/components/CompressDialog.tsx
similarity index 51%
rename from src/ui/desktop/apps/features/file-manager/components/CompressDialog.tsx
rename to src/ui/features/file-manager/components/CompressDialog.tsx
index 8f3bd88cc..4e4a879d4 100644
--- a/src/ui/desktop/apps/features/file-manager/components/CompressDialog.tsx
+++ b/src/ui/features/file-manager/components/CompressDialog.tsx
@@ -6,17 +6,11 @@ import {
DialogFooter,
DialogHeader,
DialogTitle,
-} from "@/components/ui/dialog.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select.tsx";
+} from "@/components/dialog.tsx";
+import { Button } from "@/components/button.tsx";
+import { Input } from "@/components/input.tsx";
+import { Label } from "@/components/label.tsx";
+import { Package } from "lucide-react";
import { useTranslation } from "react-i18next";
interface CompressDialogProps {
@@ -69,20 +63,25 @@ export function CompressDialog({
onOpenChange(false);
};
+ const formats = ["zip", "tar.gz", "tar.bz2", "tar.xz", "tar", "7z"] as const;
+
return (
<Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent className="sm:max-w-[500px] bg-canvas border-2 border-edge">
+ <DialogContent className="w-[calc(100vw-2rem)] sm:max-w-md rounded-none border-border bg-card">
<DialogHeader>
- <DialogTitle>{t("fileManager.compressFiles")}</DialogTitle>
- <DialogDescription className="text-muted-foreground">
+ <DialogTitle className="text-xs font-bold uppercase tracking-widest flex items-center gap-2">
+ <Package className="size-4 text-accent-brand" />
+ {t("fileManager.compressFiles")}
+ </DialogTitle>
+ <DialogDescription className="text-[10px] font-bold uppercase tracking-tight text-muted-foreground">
{t("fileManager.compressFilesDesc", { count: fileNames.length })}
</DialogDescription>
</DialogHeader>
- <div className="space-y-6 py-4">
- <div className="space-y-3">
+ <div className="py-4 flex flex-col gap-4">
+ <div className="flex flex-col gap-1.5">
<Label
- className="text-base font-semibold text-foreground"
+ className="text-xs font-bold uppercase tracking-widest text-muted-foreground"
htmlFor="archiveName"
>
{t("fileManager.archiveName")}
@@ -92,6 +91,7 @@ export function CompressDialog({
value={archiveName}
onChange={(e) => setArchiveName(e.target.value)}
placeholder={t("fileManager.enterArchiveName")}
+ className="rounded-none bg-muted/50 border-border text-xs"
onKeyDown={(e) => {
if (e.key === "Enter") {
e.preventDefault();
@@ -101,40 +101,42 @@ export function CompressDialog({
/>
</div>
- <div className="space-y-3">
- <Label
- className="text-base font-semibold text-foreground"
- htmlFor="format"
- >
+ <div className="flex flex-col gap-1.5">
+ <Label className="text-xs font-bold uppercase tracking-widest text-muted-foreground">
{t("fileManager.compressionFormat")}
</Label>
- <Select value={format} onValueChange={setFormat}>
- <SelectTrigger id="format">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="zip">ZIP (.zip)</SelectItem>
- <SelectItem value="tar.gz">TAR.GZ (.tar.gz)</SelectItem>
- <SelectItem value="tar.bz2">TAR.BZ2 (.tar.bz2)</SelectItem>
- <SelectItem value="tar.xz">TAR.XZ (.tar.xz)</SelectItem>
- <SelectItem value="tar">TAR (.tar)</SelectItem>
- <SelectItem value="7z">7-Zip (.7z)</SelectItem>
- </SelectContent>
- </Select>
+ <div className="grid grid-cols-3 gap-1">
+ {formats.map((f) => (
+ <button
+ key={f}
+ onClick={() => setFormat(f)}
+ className={`py-2 text-xs font-bold uppercase tracking-widest border transition-colors ${
+ format === f
+ ? "border-accent-brand/40 bg-accent-brand/10 text-accent-brand"
+ : "border-border text-muted-foreground hover:text-foreground hover:bg-muted"
+ }`}
+ >
+ .{f}
+ </button>
+ ))}
+ </div>
</div>
- <div className="rounded-md bg-hover/50 border border-edge p-3">
- <p className="text-sm text-muted-foreground mb-2">
+ <div className="rounded-none bg-muted/10 border border-border p-3">
+ <p className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground mb-2">
{t("fileManager.selectedFiles")}:
</p>
- <ul className="text-sm space-y-1">
+ <ul className="text-xs space-y-1">
{fileNames.slice(0, 5).map((name, index) => (
- <li key={index} className="truncate text-foreground">
+ <li
+ key={index}
+ className="truncate text-foreground font-medium"
+ >
• {name}
</li>
))}
{fileNames.length > 5 && (
- <li className="text-muted-foreground italic">
+ <li className="text-muted-foreground">
{t("fileManager.andMoreFiles", {
count: fileNames.length - 5,
})}
@@ -145,10 +147,20 @@ export function CompressDialog({
</div>
<DialogFooter>
- <Button variant="outline" onClick={() => onOpenChange(false)}>
+ <Button
+ variant="ghost"
+ onClick={() => onOpenChange(false)}
+ className="rounded-none text-[10px] font-bold uppercase tracking-widest"
+ >
{t("common.cancel")}
</Button>
- <Button onClick={handleCompress} disabled={!archiveName.trim()}>
+ <Button
+ variant="outline"
+ onClick={handleCompress}
+ disabled={!archiveName.trim()}
+ className="border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 rounded-none text-[10px] font-bold uppercase tracking-widest"
+ >
+ <Package className="size-3.5 mr-1" />
{t("fileManager.compress")}
</Button>
</DialogFooter>
diff --git a/src/ui/desktop/apps/features/file-manager/components/DiffViewer.tsx b/src/ui/features/file-manager/components/DiffViewer.tsx
similarity index 97%
rename from src/ui/desktop/apps/features/file-manager/components/DiffViewer.tsx
rename to src/ui/features/file-manager/components/DiffViewer.tsx
index 8d7126c9a..05ffbd582 100644
--- a/src/ui/desktop/apps/features/file-manager/components/DiffViewer.tsx
+++ b/src/ui/features/file-manager/components/DiffViewer.tsx
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from "react";
import { DiffEditor } from "@monaco-editor/react";
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import { toast } from "sonner";
import { useTranslation } from "react-i18next";
import {
@@ -16,7 +16,7 @@ import {
downloadSSHFile,
getSSHStatus,
connectSSH,
-} from "@/ui/main-axios.ts";
+} from "@/main-axios.ts";
import type { FileItem, SSHHost } from "@/types";
interface DiffViewerProps {
@@ -210,7 +210,7 @@ export function DiffViewer({
if (isLoading) {
return (
- <div className="h-full flex items-center justify-center bg-canvas">
+ <div className="h-full flex items-center justify-center bg-card">
<div className="text-center">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto mb-2"></div>
<p className="text-sm text-muted-foreground">
@@ -223,7 +223,7 @@ export function DiffViewer({
if (error) {
return (
- <div className="h-full flex items-center justify-center bg-canvas">
+ <div className="h-full flex items-center justify-center bg-card">
<div className="text-center max-w-md">
<FileText className="w-16 h-16 mx-auto mb-4 text-red-500 opacity-50" />
<p className="text-red-500 mb-4">{error}</p>
@@ -237,8 +237,8 @@ export function DiffViewer({
}
return (
- <div className="h-full flex flex-col bg-canvas">
- <div className="flex-shrink-0 border-b border-edge p-3">
+ <div className="h-full flex flex-col bg-card">
+ <div className="flex-shrink-0 border-b border-border p-3">
<div className="flex items-center justify-between">
<div className="flex items-center gap-4">
<div className="text-sm">
diff --git a/src/ui/desktop/apps/features/file-manager/components/DiffWindow.tsx b/src/ui/features/file-manager/components/DiffWindow.tsx
similarity index 95%
rename from src/ui/desktop/apps/features/file-manager/components/DiffWindow.tsx
rename to src/ui/features/file-manager/components/DiffWindow.tsx
index f1931e7a6..dfc358793 100644
--- a/src/ui/desktop/apps/features/file-manager/components/DiffWindow.tsx
+++ b/src/ui/features/file-manager/components/DiffWindow.tsx
@@ -3,7 +3,7 @@ import { DraggableWindow } from "./DraggableWindow.tsx";
import { DiffViewer } from "./DiffViewer.tsx";
import { useWindowManager } from "./WindowManager.tsx";
import { useTranslation } from "react-i18next";
-import type { FileItem, SSHHost } from "../../../../types/index.js";
+import type { FileItem, SSHHost } from "@/types/index";
interface DiffWindowProps {
windowId: string;
diff --git a/src/ui/desktop/apps/features/file-manager/components/DraggableWindow.tsx b/src/ui/features/file-manager/components/DraggableWindow.tsx
similarity index 87%
rename from src/ui/desktop/apps/features/file-manager/components/DraggableWindow.tsx
rename to src/ui/features/file-manager/components/DraggableWindow.tsx
index f3b5e0546..1f65a6df7 100644
--- a/src/ui/desktop/apps/features/file-manager/components/DraggableWindow.tsx
+++ b/src/ui/features/file-manager/components/DraggableWindow.tsx
@@ -267,8 +267,8 @@ export function DraggableWindow({
<div
ref={windowRef}
className={cn(
- "absolute bg-card border border-border rounded-lg shadow-2xl",
- "select-none overflow-hidden",
+ "absolute bg-[#0d0e0c] border border-border rounded-none shadow-2xl",
+ "select-none overflow-hidden flex flex-col",
isMaximized ? "inset-0" : "",
)}
style={{
@@ -282,35 +282,37 @@ export function DraggableWindow({
>
<div
ref={titleBarRef}
- className={cn(
- "flex items-center justify-between px-3 py-2",
- "bg-muted/50 text-foreground border-b border-border",
- "cursor-grab active:cursor-grabbing",
- )}
+ className="flex items-center justify-between px-4 py-2 bg-muted/30 border-b border-border shrink-0 cursor-grab active:cursor-grabbing"
onMouseDown={handleMouseDown}
onDoubleClick={handleTitleDoubleClick}
>
- <div className="flex items-center gap-2 flex-1">
- <span className="text-sm font-medium truncate">{title}</span>
+ <div className="flex items-center gap-3 flex-1 overflow-hidden">
+ <span className="text-[10px] font-bold uppercase tracking-[0.2em] text-accent-brand shrink-0">
+ {t("fileManager.editor")}
+ </span>
+ <div className="h-4 w-px bg-border/50 shrink-0" />
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground truncate">
+ {title}
+ </span>
</div>
- <div className="flex items-center gap-1">
+ <div className="flex items-center gap-0.5">
{onMinimize && (
<button
- className="w-8 h-6 flex items-center justify-center rounded hover:bg-accent transition-colors"
+ className="size-6 flex items-center justify-center rounded-none hover:bg-accent-brand/10 hover:text-accent-brand text-muted-foreground transition-colors"
onClick={(e) => {
e.stopPropagation();
onMinimize();
}}
title={t("common.minimize")}
>
- <Minus className="w-4 h-4" />
+ <Minus className="size-3.5" />
</button>
)}
{onMaximize && (
<button
- className="w-8 h-6 flex items-center justify-center rounded hover:bg-accent transition-colors"
+ className="size-6 flex items-center justify-center rounded-none hover:bg-accent-brand/10 hover:text-accent-brand text-muted-foreground transition-colors"
onClick={(e) => {
e.stopPropagation();
onMaximize();
@@ -318,32 +320,27 @@ export function DraggableWindow({
title={isMaximized ? t("common.restore") : t("common.maximize")}
>
{isMaximized ? (
- <Minimize2 className="w-4 h-4" />
+ <Minimize2 className="size-3.5" />
) : (
- <Maximize2 className="w-4 h-4" />
+ <Maximize2 className="size-3.5" />
)}
</button>
)}
<button
- className="w-8 h-6 flex items-center justify-center rounded hover:bg-destructive hover:text-destructive-foreground transition-colors"
+ className="size-6 flex items-center justify-center rounded-none hover:bg-accent-brand/10 hover:text-accent-brand text-muted-foreground transition-colors"
onClick={(e) => {
e.stopPropagation();
onClose();
}}
title={t("common.close")}
>
- <X className="w-4 h-4" />
+ <X className="size-3.5" />
</button>
</div>
</div>
- <div
- className="flex-1 overflow-hidden"
- style={{ height: "calc(100% - 40px)" }}
- >
- {children}
- </div>
+ <div className="flex-1 overflow-hidden">{children}</div>
{!isMaximized && (
<>
diff --git a/src/ui/desktop/apps/features/file-manager/components/FileViewer.tsx b/src/ui/features/file-manager/components/FileViewer.tsx
similarity index 99%
rename from src/ui/desktop/apps/features/file-manager/components/FileViewer.tsx
rename to src/ui/features/file-manager/components/FileViewer.tsx
index e15c7150a..b7712ae5c 100644
--- a/src/ui/desktop/apps/features/file-manager/components/FileViewer.tsx
+++ b/src/ui/features/file-manager/components/FileViewer.tsx
@@ -37,7 +37,7 @@ import {
SiMysql,
SiDocker,
} from "react-icons/si";
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import type { CodeEditorHandle } from "./CodeEditor.tsx";
const CodeEditor = lazy(() =>
diff --git a/src/ui/desktop/apps/features/file-manager/components/FileWindow.tsx b/src/ui/features/file-manager/components/FileWindow.tsx
similarity index 99%
rename from src/ui/desktop/apps/features/file-manager/components/FileWindow.tsx
rename to src/ui/features/file-manager/components/FileWindow.tsx
index 9cf7f25c0..3571bc4e2 100644
--- a/src/ui/desktop/apps/features/file-manager/components/FileWindow.tsx
+++ b/src/ui/features/file-manager/components/FileWindow.tsx
@@ -8,7 +8,7 @@ import {
writeSSHFile,
getSSHStatus,
connectSSH,
-} from "@/ui/main-axios.ts";
+} from "@/main-axios.ts";
import { toast } from "sonner";
import { useTranslation } from "react-i18next";
diff --git a/src/ui/desktop/apps/features/file-manager/components/ImagePreview.tsx b/src/ui/features/file-manager/components/ImagePreview.tsx
similarity index 98%
rename from src/ui/desktop/apps/features/file-manager/components/ImagePreview.tsx
rename to src/ui/features/file-manager/components/ImagePreview.tsx
index 8a43c921d..0bd0cb0b0 100644
--- a/src/ui/desktop/apps/features/file-manager/components/ImagePreview.tsx
+++ b/src/ui/features/file-manager/components/ImagePreview.tsx
@@ -2,7 +2,7 @@ import React, { useState } from "react";
import { PhotoProvider, PhotoView } from "react-photo-view";
import "react-photo-view/dist/react-photo-view.css";
import { AlertCircle, Download } from "lucide-react";
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import { useTranslation } from "react-i18next";
interface ImagePreviewProps {
diff --git a/src/ui/desktop/apps/features/file-manager/components/MarkdownRenderer.tsx b/src/ui/features/file-manager/components/MarkdownRenderer.tsx
similarity index 100%
rename from src/ui/desktop/apps/features/file-manager/components/MarkdownRenderer.tsx
rename to src/ui/features/file-manager/components/MarkdownRenderer.tsx
diff --git a/src/ui/desktop/apps/features/file-manager/components/PdfPreview.tsx b/src/ui/features/file-manager/components/PdfPreview.tsx
similarity index 98%
rename from src/ui/desktop/apps/features/file-manager/components/PdfPreview.tsx
rename to src/ui/features/file-manager/components/PdfPreview.tsx
index e16949db6..b13ec2ef1 100644
--- a/src/ui/desktop/apps/features/file-manager/components/PdfPreview.tsx
+++ b/src/ui/features/file-manager/components/PdfPreview.tsx
@@ -1,7 +1,7 @@
import React, { useState } from "react";
import { Document, Page, pdfjs } from "react-pdf";
import { AlertCircle, Download } from "lucide-react";
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import { useTranslation } from "react-i18next";
pdfjs.GlobalWorkerOptions.workerSrc = "/pdf.worker.min.js";
diff --git a/src/ui/features/file-manager/components/PermissionsDialog.tsx b/src/ui/features/file-manager/components/PermissionsDialog.tsx
new file mode 100644
index 000000000..b9899c06f
--- /dev/null
+++ b/src/ui/features/file-manager/components/PermissionsDialog.tsx
@@ -0,0 +1,260 @@
+import React, { useState, useEffect } from "react";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogHeader,
+ DialogTitle,
+ DialogFooter,
+} from "@/components/dialog.tsx";
+import { Button } from "@/components/button.tsx";
+import { Input } from "@/components/input.tsx";
+import { useTranslation } from "react-i18next";
+import { Lock } from "lucide-react";
+
+interface FileItem {
+ name: string;
+ type: "file" | "directory" | "link";
+ path: string;
+ permissions?: string;
+ owner?: string;
+ group?: string;
+}
+
+interface PermissionsDialogProps {
+ file: FileItem | null;
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ onSave: (file: FileItem, permissions: string) => Promise<void>;
+}
+
+const parsePermissions = (
+ perms: string,
+): { owner: number; group: number; other: number } => {
+ if (!perms) {
+ return { owner: 0, group: 0, other: 0 };
+ }
+
+ if (/^\d{3,4}$/.test(perms)) {
+ const numStr = perms.slice(-3);
+ return {
+ owner: parseInt(numStr[0] || "0", 10),
+ group: parseInt(numStr[1] || "0", 10),
+ other: parseInt(numStr[2] || "0", 10),
+ };
+ }
+ const cleanPerms = perms.replace(/^-/, "").substring(0, 9);
+
+ const calcBits = (str: string): number => {
+ let value = 0;
+ if (str[0] === "r") value += 4;
+ if (str[1] === "w") value += 2;
+ if (str[2] === "x") value += 1;
+ return value;
+ };
+
+ return {
+ owner: calcBits(cleanPerms.substring(0, 3)),
+ group: calcBits(cleanPerms.substring(3, 6)),
+ other: calcBits(cleanPerms.substring(6, 9)),
+ };
+};
+
+const toNumeric = (owner: number, group: number, other: number): string => {
+ return `${owner}${group}${other}`;
+};
+
+export function PermissionsDialog({
+ file,
+ open,
+ onOpenChange,
+ onSave,
+}: PermissionsDialogProps) {
+ const { t } = useTranslation();
+ const [loading, setLoading] = useState(false);
+
+ const initialPerms = parsePermissions(file?.permissions || "644");
+ const [ownerRead, setOwnerRead] = useState((initialPerms.owner & 4) !== 0);
+ const [ownerWrite, setOwnerWrite] = useState((initialPerms.owner & 2) !== 0);
+ const [ownerExecute, setOwnerExecute] = useState(
+ (initialPerms.owner & 1) !== 0,
+ );
+
+ const [groupRead, setGroupRead] = useState((initialPerms.group & 4) !== 0);
+ const [groupWrite, setGroupWrite] = useState((initialPerms.group & 2) !== 0);
+ const [groupExecute, setGroupExecute] = useState(
+ (initialPerms.group & 1) !== 0,
+ );
+
+ const [otherRead, setOtherRead] = useState((initialPerms.other & 4) !== 0);
+ const [otherWrite, setOtherWrite] = useState((initialPerms.other & 2) !== 0);
+ const [otherExecute, setOtherExecute] = useState(
+ (initialPerms.other & 1) !== 0,
+ );
+
+ useEffect(() => {
+ if (file) {
+ const perms = parsePermissions(file.permissions || "644");
+ setOwnerRead((perms.owner & 4) !== 0);
+ setOwnerWrite((perms.owner & 2) !== 0);
+ setOwnerExecute((perms.owner & 1) !== 0);
+ setGroupRead((perms.group & 4) !== 0);
+ setGroupWrite((perms.group & 2) !== 0);
+ setGroupExecute((perms.group & 1) !== 0);
+ setOtherRead((perms.other & 4) !== 0);
+ setOtherWrite((perms.other & 2) !== 0);
+ setOtherExecute((perms.other & 1) !== 0);
+ }
+ }, [file]);
+
+ const calculateOctal = (): string => {
+ const owner =
+ (ownerRead ? 4 : 0) + (ownerWrite ? 2 : 0) + (ownerExecute ? 1 : 0);
+ const group =
+ (groupRead ? 4 : 0) + (groupWrite ? 2 : 0) + (groupExecute ? 1 : 0);
+ const other =
+ (otherRead ? 4 : 0) + (otherWrite ? 2 : 0) + (otherExecute ? 1 : 0);
+ return toNumeric(owner, group, other);
+ };
+
+ const handleSave = async () => {
+ if (!file) return;
+
+ setLoading(true);
+ try {
+ const permissions = calculateOctal();
+ await onSave(file, permissions);
+ onOpenChange(false);
+ } catch (error) {
+ console.error("Failed to update permissions:", error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ if (!file) return null;
+
+ const octal = calculateOctal();
+
+ const rows = [
+ {
+ label: `${t("fileManager.owner")}${file.owner ? ` (${file.owner})` : ""}`,
+ read: ownerRead,
+ setRead: setOwnerRead,
+ write: ownerWrite,
+ setWrite: setOwnerWrite,
+ execute: ownerExecute,
+ setExecute: setOwnerExecute,
+ },
+ {
+ label: `${t("fileManager.group")}${file.group ? ` (${file.group})` : ""}`,
+ read: groupRead,
+ setRead: setGroupRead,
+ write: groupWrite,
+ setWrite: setGroupWrite,
+ execute: groupExecute,
+ setExecute: setGroupExecute,
+ },
+ {
+ label: t("fileManager.others"),
+ read: otherRead,
+ setRead: setOtherRead,
+ write: otherWrite,
+ setWrite: setOtherWrite,
+ execute: otherExecute,
+ setExecute: setOtherExecute,
+ },
+ ];
+
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent className="w-[calc(100vw-2rem)] sm:max-w-md rounded-none border-border bg-card">
+ <DialogHeader>
+ <DialogTitle className="text-xs font-bold uppercase tracking-widest flex items-center gap-2">
+ <Lock className="size-4 text-accent-brand" />
+ {t("fileManager.changePermissions")}
+ </DialogTitle>
+ <DialogDescription className="text-[10px] font-bold uppercase tracking-tight text-muted-foreground font-mono">
+ {file.path}
+ </DialogDescription>
+ </DialogHeader>
+
+ <div className="py-3 flex flex-col gap-4">
+ <div className="grid grid-cols-4 gap-0 border border-border overflow-hidden">
+ <div className="px-3 py-2 bg-muted/50 border-b border-r border-border text-[10px] font-bold uppercase tracking-widest text-muted-foreground" />
+ {[
+ t("fileManager.read"),
+ t("fileManager.write"),
+ t("fileManager.execute"),
+ ].map((h) => (
+ <div
+ key={h}
+ className="px-3 py-2 bg-muted/50 border-b border-r border-border last:border-r-0 text-[10px] font-bold uppercase tracking-widest text-muted-foreground text-center"
+ >
+ {h}
+ </div>
+ ))}
+ {rows.map((row, i) => (
+ <React.Fragment key={i}>
+ <div className="px-3 py-2.5 border-b border-r border-border last:border-b-0 text-xs font-semibold truncate">
+ {row.label}
+ </div>
+ {[
+ { val: row.read, set: row.setRead },
+ { val: row.write, set: row.setWrite },
+ { val: row.execute, set: row.setExecute },
+ ].map((perm, j) => (
+ <div
+ key={j}
+ className="flex items-center justify-center border-b border-r border-border last:border-r-0 py-2.5"
+ >
+ <input
+ type="checkbox"
+ checked={perm.val}
+ onChange={(e) => perm.set(e.target.checked)}
+ className="accent-[var(--accent-brand)] size-3.5 cursor-pointer"
+ />
+ </div>
+ ))}
+ </React.Fragment>
+ ))}
+ </div>
+
+ <div className="flex items-center gap-3">
+ <span className="text-xs font-bold uppercase tracking-widest text-muted-foreground">
+ {t("fileManager.octal")}
+ </span>
+ <Input
+ value={octal}
+ readOnly
+ className="w-20 rounded-none bg-muted/50 border-border text-xs font-mono text-center h-8"
+ maxLength={3}
+ />
+ <span className="text-[10px] text-muted-foreground font-mono">
+ {t("fileManager.currentPermissions")}: {file.permissions || "—"}
+ </span>
+ </div>
+ </div>
+
+ <DialogFooter>
+ <Button
+ variant="ghost"
+ onClick={() => onOpenChange(false)}
+ disabled={loading}
+ className="rounded-none text-[10px] font-bold uppercase tracking-widest"
+ >
+ {t("common.cancel")}
+ </Button>
+ <Button
+ variant="outline"
+ onClick={handleSave}
+ disabled={loading}
+ className="border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 rounded-none text-[10px] font-bold uppercase tracking-widest"
+ >
+ {loading ? t("common.saving") : t("common.save")}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+}
diff --git a/src/ui/desktop/apps/features/file-manager/components/TerminalWindow.tsx b/src/ui/features/file-manager/components/TerminalWindow.tsx
similarity index 97%
rename from src/ui/desktop/apps/features/file-manager/components/TerminalWindow.tsx
rename to src/ui/features/file-manager/components/TerminalWindow.tsx
index 1d45f851f..e4666b7fa 100644
--- a/src/ui/desktop/apps/features/file-manager/components/TerminalWindow.tsx
+++ b/src/ui/features/file-manager/components/TerminalWindow.tsx
@@ -1,6 +1,6 @@
import React from "react";
import { DraggableWindow } from "./DraggableWindow.tsx";
-import { Terminal } from "@/ui/desktop/apps/features/terminal/Terminal.tsx";
+import { Terminal } from "@/features/terminal/Terminal.tsx";
import { useWindowManager } from "./WindowManager.tsx";
import { useTranslation } from "react-i18next";
diff --git a/src/ui/desktop/apps/features/file-manager/components/WindowManager.tsx b/src/ui/features/file-manager/components/WindowManager.tsx
similarity index 100%
rename from src/ui/desktop/apps/features/file-manager/components/WindowManager.tsx
rename to src/ui/features/file-manager/components/WindowManager.tsx
diff --git a/src/ui/desktop/apps/features/file-manager/hooks/useDragAndDrop.ts b/src/ui/features/file-manager/hooks/useDragAndDrop.ts
similarity index 100%
rename from src/ui/desktop/apps/features/file-manager/hooks/useDragAndDrop.ts
rename to src/ui/features/file-manager/hooks/useDragAndDrop.ts
diff --git a/src/ui/hooks/useDragToDesktop.ts b/src/ui/features/file-manager/hooks/useDragToDesktop.ts
similarity index 98%
rename from src/ui/hooks/useDragToDesktop.ts
rename to src/ui/features/file-manager/hooks/useDragToDesktop.ts
index 932ffe7b3..925bc2aa6 100644
--- a/src/ui/hooks/useDragToDesktop.ts
+++ b/src/ui/features/file-manager/hooks/useDragToDesktop.ts
@@ -1,7 +1,7 @@
import { useState, useCallback } from "react";
import { toast } from "sonner";
-import { downloadSSHFile } from "@/ui/main-axios";
-import type { FileItem, SSHHost } from "../../types/index.js";
+import { downloadSSHFile } from "@/main-axios";
+import type { FileItem, SSHHost } from "@/types/index.js";
interface DragToDesktopState {
isDragging: boolean;
diff --git a/src/ui/hooks/useDragToSystemDesktop.ts b/src/ui/features/file-manager/hooks/useDragToSystemDesktop.ts
similarity index 98%
rename from src/ui/hooks/useDragToSystemDesktop.ts
rename to src/ui/features/file-manager/hooks/useDragToSystemDesktop.ts
index 3fff9239b..04277cf8b 100644
--- a/src/ui/hooks/useDragToSystemDesktop.ts
+++ b/src/ui/features/file-manager/hooks/useDragToSystemDesktop.ts
@@ -1,7 +1,7 @@
import { useState, useCallback, useRef } from "react";
import { toast } from "sonner";
-import { downloadSSHFile } from "@/ui/main-axios";
-import type { FileItem, SSHHost } from "../../types/index.js";
+import { downloadSSHFile } from "@/main-axios";
+import type { FileItem, SSHHost } from "@/types/index.js";
interface DragToSystemState {
isDragging: boolean;
diff --git a/src/ui/desktop/apps/features/file-manager/hooks/useFileSelection.ts b/src/ui/features/file-manager/hooks/useFileSelection.ts
similarity index 100%
rename from src/ui/desktop/apps/features/file-manager/hooks/useFileSelection.ts
rename to src/ui/features/file-manager/hooks/useFileSelection.ts
diff --git a/src/ui/desktop/apps/features/guacamole/GuacamoleApp.tsx b/src/ui/features/guacamole/GuacamoleApp.tsx
similarity index 52%
rename from src/ui/desktop/apps/features/guacamole/GuacamoleApp.tsx
rename to src/ui/features/guacamole/GuacamoleApp.tsx
index 67c8f9559..4b5aed0b4 100644
--- a/src/ui/desktop/apps/features/guacamole/GuacamoleApp.tsx
+++ b/src/ui/features/guacamole/GuacamoleApp.tsx
@@ -1,8 +1,9 @@
import React, { useState, useEffect } from "react";
-import { GuacamoleDisplay } from "@/ui/desktop/apps/features/guacamole/GuacamoleDisplay.tsx";
-import { FullScreenAppWrapper } from "@/ui/desktop/apps/FullScreenAppWrapper.tsx";
-import { getGuacamoleTokenFromHost } from "@/ui/main-axios.ts";
+import { GuacamoleDisplay } from "@/features/guacamole/GuacamoleDisplay.tsx";
+import { FullScreenAppWrapper } from "@/features/FullScreenAppWrapper.tsx";
+import { getGuacamoleTokenFromHost } from "@/main-axios.ts";
import { useTranslation } from "react-i18next";
+import { AlertCircle, RefreshCw } from "lucide-react";
import type { SSHHost } from "@/types";
interface GuacamoleAppProps {
@@ -10,26 +11,29 @@ interface GuacamoleAppProps {
}
const GuacamoleApp: React.FC<GuacamoleAppProps> = ({ hostId }) => {
+ const { t } = useTranslation();
+
return (
<FullScreenAppWrapper hostId={hostId}>
{(hostConfig, loading) => {
if (loading) {
return (
- <div className="flex items-center justify-center h-full">
- <div className="text-center">
- <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-white mx-auto mb-2"></div>
- <p className="text-muted-foreground">Loading host...</p>
- </div>
+ <div className="flex flex-col items-center justify-center h-full opacity-40 gap-4">
+ <RefreshCw className="size-8 animate-spin" />
+ <span className="text-sm font-semibold uppercase tracking-widest">
+ {t("common.loading")}
+ </span>
</div>
);
}
if (!hostConfig) {
return (
- <div className="flex items-center justify-center h-full">
- <div className="text-center">
- <p className="text-red-500 mb-4">Host not found</p>
- </div>
+ <div className="flex flex-col items-center justify-center h-full opacity-40 gap-4">
+ <AlertCircle className="size-8 text-destructive" />
+ <span className="text-sm font-semibold text-destructive">
+ {t("guacamole.hostNotFound")}
+ </span>
</div>
);
}
@@ -66,25 +70,22 @@ const GuacamoleAppInner: React.FC<GuacamoleAppInnerProps> = ({
if (error) {
return (
- <div className="flex items-center justify-center h-full">
- <div className="text-center">
- <p className="text-red-500 mb-4">{error}</p>
- </div>
+ <div className="flex flex-col items-center justify-center h-full opacity-40 gap-4">
+ <AlertCircle className="size-8 text-destructive" />
+ <span className="text-sm font-semibold text-destructive">{error}</span>
</div>
);
}
if (!token) {
return (
- <div className="flex items-center justify-center h-full">
- <div className="text-center">
- <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-white mx-auto mb-2"></div>
- <p className="text-muted-foreground">
- {t("guacamole.connecting", {
- type: (hostConfig.connectionType || "remote").toUpperCase(),
- })}
- </p>
- </div>
+ <div className="flex flex-col items-center justify-center h-full opacity-40 gap-4">
+ <RefreshCw className="size-8 animate-spin" />
+ <span className="text-sm font-semibold uppercase tracking-widest">
+ {t("guacamole.connecting", {
+ type: (hostConfig.connectionType || "remote").toUpperCase(),
+ })}
+ </span>
</div>
);
}
diff --git a/src/ui/desktop/apps/features/guacamole/GuacamoleDisplay.tsx b/src/ui/features/guacamole/GuacamoleDisplay.tsx
similarity index 98%
rename from src/ui/desktop/apps/features/guacamole/GuacamoleDisplay.tsx
rename to src/ui/features/guacamole/GuacamoleDisplay.tsx
index 6da710ab3..09eebe903 100644
--- a/src/ui/desktop/apps/features/guacamole/GuacamoleDisplay.tsx
+++ b/src/ui/features/guacamole/GuacamoleDisplay.tsx
@@ -8,12 +8,8 @@ import {
} from "react";
import Guacamole from "guacamole-common-js";
import { useTranslation } from "react-i18next";
-import {
- getGuacamoleToken,
- isElectron,
- isEmbeddedMode,
-} from "@/ui/main-axios.ts";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
+import { getGuacamoleToken, isElectron, isEmbeddedMode } from "@/main-axios.ts";
+import { SimpleLoader } from "@/lib/SimpleLoader.tsx";
export type GuacamoleConnectionType = "rdp" | "vnc" | "telnet";
diff --git a/src/ui/desktop/apps/features/server-stats/ServerStats.tsx b/src/ui/features/server-stats/ServerStats.tsx
similarity index 59%
rename from src/ui/desktop/apps/features/server-stats/ServerStats.tsx
rename to src/ui/features/server-stats/ServerStats.tsx
index c9b082f33..71710fc21 100644
--- a/src/ui/desktop/apps/features/server-stats/ServerStats.tsx
+++ b/src/ui/features/server-stats/ServerStats.tsx
@@ -1,8 +1,6 @@
import React from "react";
-import { useSidebar } from "@/components/ui/sidebar.tsx";
-import { Status, StatusIndicator } from "@/components/ui/shadcn-io/status";
-import { Separator } from "@/components/ui/separator.tsx";
-import { Button } from "@/components/ui/button.tsx";
+import { Separator } from "@/components/separator.tsx";
+import { Button } from "@/components/button.tsx";
import {
getServerStatusById,
getServerMetricsById,
@@ -14,9 +12,9 @@ import {
sendMetricsHeartbeat,
getSSHHosts,
type ServerMetrics,
-} from "@/ui/main-axios.ts";
-import { TOTPDialog } from "@/ui/desktop/navigation/dialogs/TOTPDialog.tsx";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
+} from "@/main-axios.ts";
+import { TOTPDialog } from "@/ssh/dialogs/TOTPDialog.tsx";
+import { useTabsSafe } from "@/shell/TabContext.tsx";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
import {
@@ -36,13 +34,13 @@ import {
PortsWidget,
FirewallWidget,
} from "./widgets";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
-import { RefreshCw } from "lucide-react";
+import { SimpleLoader } from "@/lib/SimpleLoader.tsx";
+import { RefreshCw, Server } from "lucide-react";
import {
ConnectionLogProvider,
useConnectionLog,
-} from "@/ui/desktop/navigation/connection-log/ConnectionLogContext.tsx";
-import { ConnectionLog } from "@/ui/desktop/navigation/connection-log/ConnectionLog.tsx";
+} from "@/ssh/connection-log/ConnectionLogContext.tsx";
+import { ConnectionLog } from "@/ssh/connection-log/ConnectionLog.tsx";
import type { LogEntry } from "@/types/connection-log.ts";
interface QuickAction {
@@ -85,16 +83,12 @@ function ServerStatsInner({
embedded = false,
}: ServerProps): React.ReactElement {
const { t } = useTranslation();
- const { state: sidebarState } = useSidebar();
const {
addLog,
clearLogs,
isExpanded: isConnectionLogExpanded,
} = useConnectionLog();
- const { currentTab, removeTab } = useTabs() as {
- currentTab: number | null;
- removeTab: (tabId: number) => void;
- };
+ const { currentTab, removeTab } = useTabsSafe();
const [serverStatus, setServerStatus] = React.useState<"online" | "offline">(
"offline",
);
@@ -563,29 +557,39 @@ function ServerStatsInner({
hasConnectionError,
]);
- const topMarginPx = isTopbarOpen ? 74 : 16;
- const leftMarginPx = sidebarState === "collapsed" ? 16 : 8;
- const bottomMarginPx = 8;
-
const wrapperStyle: React.CSSProperties = embedded
? { opacity: isVisible ? 1 : 0, height: "100%", width: "100%" }
: {
opacity: isVisible ? 1 : 0,
- marginLeft: leftMarginPx,
- marginRight: 17,
- marginTop: topMarginPx,
- marginBottom: bottomMarginPx,
- height: `calc(100vh - ${topMarginPx + bottomMarginPx}px)`,
+ margin: isTopbarOpen ? "74px 17px 8px 8px" : "16px 17px 8px 8px",
+ height: isTopbarOpen ? "calc(100vh - 82px)" : "calc(100vh - 24px)",
};
- const containerClass = embedded
- ? "h-full w-full text-foreground overflow-hidden bg-transparent"
- : "bg-canvas text-foreground rounded-lg border-2 border-edge overflow-hidden";
+ const handleRefresh = async () => {
+ if (!currentHostConfig?.id) return;
+ try {
+ setIsRefreshing(true);
+ const res = await getServerStatusById(currentHostConfig.id);
+ setServerStatus(res?.status === "online" ? "online" : "offline");
+ const data = await getServerMetricsById(currentHostConfig.id);
+ if (data) setMetrics(data);
+ setShowStatsUI(true);
+ } catch {
+ setServerStatus("offline");
+ setMetrics(null);
+ setShowStatsUI(false);
+ } finally {
+ setIsRefreshing(false);
+ }
+ };
return (
- <div style={wrapperStyle} className={`${containerClass} relative`}>
+ <div
+ style={wrapperStyle}
+ className="relative overflow-hidden flex flex-col"
+ >
<div
- className="h-full w-full flex flex-col"
+ className="flex flex-col flex-1 min-h-0 overflow-hidden"
style={{
visibility:
hasConnectionError && isConnectionLogExpanded
@@ -593,256 +597,175 @@ function ServerStatsInner({
: "visible",
}}
>
- {!totpRequired && !isLoadingMetrics && (
- <div className="flex flex-col sm:flex-row sm:items-center justify-between px-4 pt-3 pb-3 gap-3">
- <div className="flex items-center gap-4 min-w-0">
- <div className="min-w-0">
- <h1 className="font-bold text-lg truncate">
- {currentHostConfig?.folder} / {title}
- </h1>
- </div>
- {statusCheckEnabled && (
- <Status
- status={serverStatus}
- className="!bg-transparent !p-0.75 flex-shrink-0"
- >
- <StatusIndicator />
- </Status>
- )}
- </div>
- <div className="flex items-center gap-2 flex-wrap">
- <Button
- variant="outline"
- disabled={isRefreshing}
- className="font-semibold"
- onClick={async () => {
- if (currentHostConfig?.id) {
- try {
- setIsRefreshing(true);
- const res = await getServerStatusById(
- currentHostConfig.id,
- );
- setServerStatus(
- res?.status === "online" ? "online" : "offline",
- );
- const data = await getServerMetricsById(
- currentHostConfig.id,
- );
- if (data) {
- setMetrics(data);
- }
- setShowStatsUI(true);
- } catch (error: unknown) {
- const err = error as {
- code?: string;
- status?: number;
- response?: {
- status?: number;
- data?: { error?: string };
- };
- };
- if (
- err?.code === "TOTP_REQUIRED" ||
- (err?.response?.status === 403 &&
- err?.response?.data?.error === "TOTP_REQUIRED")
- ) {
- toast.error(t("serverStats.totpUnavailable"));
- setMetrics(null);
- setShowStatsUI(false);
- } else if (
- err?.response?.status === 503 ||
- err?.status === 503
- ) {
- setServerStatus("offline");
- setMetrics(null);
- setShowStatsUI(false);
- } else if (
- err?.response?.status === 504 ||
- err?.status === 504
- ) {
- setServerStatus("offline");
- setMetrics(null);
- setShowStatsUI(false);
- } else if (
- err?.response?.status === 404 ||
- err?.status === 404
- ) {
- setServerStatus("offline");
- setMetrics(null);
- setShowStatsUI(false);
- } else {
- setServerStatus("offline");
- setMetrics(null);
- setShowStatsUI(false);
- }
- } finally {
- setIsRefreshing(false);
- }
- }
- }}
- title={t("serverStats.refreshStatusAndMetrics")}
- >
- {isRefreshing ? (
+ <div className="flex-1 overflow-y-auto overflow-x-hidden flex flex-col">
+ {!totpRequired && !isLoadingMetrics && (
+ <div className="mx-3 mt-3 flex items-center justify-between border border-border bg-card px-3 py-3 shrink-0">
+ <div className="flex items-center gap-3">
+ <div className="size-10 border border-border bg-muted flex items-center justify-center shrink-0">
+ <Server className="size-5 text-accent-brand" />
+ </div>
+ <div>
+ <h1 className="text-lg md:text-2xl font-bold">{title}</h1>
<div className="flex items-center gap-2">
- <RefreshCw className="animate-spin" />
+ <span
+ className={`size-2 rounded-full ${serverStatus === "online" ? "bg-accent-brand" : "bg-destructive"}`}
+ />
+ <span className="text-xs text-muted-foreground uppercase tracking-widest font-semibold">
+ {serverStatus === "online"
+ ? t("serverStats.online")
+ : t("serverStats.offline")}
+ </span>
</div>
- ) : (
- <RefreshCw />
- )}
- </Button>
- </div>
- </div>
- )}
- {!totpRequired && !isLoadingMetrics && (
- <Separator className="p-0.25 w-full" />
- )}
-
- <div className="flex-1 overflow-y-auto min-h-0 thin-scrollbar relative">
- {(metricsEnabled && showStatsUI) ||
- (currentHostConfig?.quickActions &&
- currentHostConfig.quickActions.length > 0) ? (
- <div className="border-edge m-1 p-2 overflow-y-auto thin-scrollbar flex-1 flex flex-col">
- {currentHostConfig?.quickActions &&
- currentHostConfig.quickActions.length > 0 && (
- <div className={metricsEnabled && showStatsUI ? "mb-4" : ""}>
- <h3 className="text-sm font-semibold text-muted-foreground mb-2">
- {t("serverStats.quickActions")}
- </h3>
- <div className="flex flex-wrap gap-2">
- {currentHostConfig.quickActions.map((action, index) => {
- const isExecuting = executingActions.has(
- action.snippetId,
- );
- return (
- <Button
- key={index}
- variant="outline"
- size="sm"
- className="font-semibold"
- disabled={isExecuting}
- onClick={async () => {
- if (!currentHostConfig) return;
-
- setExecutingActions((prev) =>
- new Set(prev).add(action.snippetId),
- );
- toast.loading(
- t("serverStats.executingQuickAction", {
- name: action.name,
- }),
- { id: `quick-action-${action.snippetId}` },
- );
-
- try {
- const result = await executeSnippet(
- action.snippetId,
- currentHostConfig.id,
+ </div>
+ </div>
+ <div className="flex items-center gap-0">
+ {currentHostConfig?.quickActions &&
+ currentHostConfig.quickActions.length > 0 && (
+ <>
+ <div className="flex flex-wrap gap-2 mr-3">
+ {currentHostConfig.quickActions.map((action, index) => {
+ const isExecuting = executingActions.has(
+ action.snippetId,
+ );
+ return (
+ <Button
+ key={index}
+ variant="outline"
+ size="sm"
+ className="h-8 text-xs font-semibold"
+ disabled={isExecuting}
+ onClick={async () => {
+ if (!currentHostConfig) return;
+ setExecutingActions((prev) =>
+ new Set(prev).add(action.snippetId),
);
-
- if (result.success) {
- toast.success(
- t("serverStats.quickActionSuccess", {
- name: action.name,
- }),
- {
- id: `quick-action-${action.snippetId}`,
- description: result.output
- ? result.output.substring(0, 200)
- : undefined,
- duration: 5000,
- },
+ toast.loading(
+ t("serverStats.executingQuickAction", {
+ name: action.name,
+ }),
+ { id: `quick-action-${action.snippetId}` },
+ );
+ try {
+ const result = await executeSnippet(
+ action.snippetId,
+ currentHostConfig.id,
);
- } else {
+ if (result.success) {
+ toast.success(
+ t("serverStats.quickActionSuccess", {
+ name: action.name,
+ }),
+ {
+ id: `quick-action-${action.snippetId}`,
+ description: result.output?.substring(
+ 0,
+ 200,
+ ),
+ duration: 5000,
+ },
+ );
+ } else {
+ toast.error(
+ t("serverStats.quickActionFailed", {
+ name: action.name,
+ }),
+ {
+ id: `quick-action-${action.snippetId}`,
+ description:
+ result.error || result.output,
+ duration: 5000,
+ },
+ );
+ }
+ } catch (error) {
toast.error(
- t("serverStats.quickActionFailed", {
+ t("serverStats.quickActionError", {
name: action.name,
}),
{
id: `quick-action-${action.snippetId}`,
description:
- result.error ||
- result.output ||
- undefined,
+ error instanceof Error
+ ? error.message
+ : "Unknown error",
duration: 5000,
},
);
+ } finally {
+ setExecutingActions((prev) => {
+ const next = new Set(prev);
+ next.delete(action.snippetId);
+ return next;
+ });
}
- } catch (error: unknown) {
- toast.error(
- t("serverStats.quickActionError", {
- name: action.name,
- }),
- {
- id: `quick-action-${action.snippetId}`,
- description:
- error instanceof Error
- ? error.message
- : "Unknown error",
- duration: 5000,
- },
- );
- } finally {
- setExecutingActions((prev) => {
- const next = new Set(prev);
- next.delete(action.snippetId);
- return next;
- });
- }
- }}
- title={t("serverStats.executeQuickAction", {
- name: action.name,
- })}
- >
- {isExecuting ? (
- <div className="flex items-center gap-2">
- <div className="w-3 h-3 border-2 border-foreground-secondary border-t-transparent rounded-full animate-spin"></div>
- {action.name}
- </div>
- ) : (
- action.name
- )}
- </Button>
- );
- })}
- </div>
- </div>
- )}
- {metricsEnabled &&
- showStatsUI &&
- !isLoadingMetrics &&
- (!metrics && serverStatus === "offline" ? (
- <div className="flex items-center justify-center py-8">
- <div className="text-center">
- <div className="w-12 h-12 mx-auto mb-3 rounded-full bg-red-500/20 flex items-center justify-center">
- <div className="w-6 h-6 border-2 border-red-400 rounded-full"></div>
+ }}
+ >
+ {isExecuting ? (
+ <>
+ <RefreshCw className="size-3 animate-spin mr-1" />
+ {action.name}
+ </>
+ ) : (
+ action.name
+ )}
+ </Button>
+ );
+ })}
</div>
- <p className="text-foreground-secondary mb-1">
- {t("serverStats.serverOffline")}
- </p>
- <p className="text-sm text-foreground-subtle">
- {t("serverStats.cannotFetchMetrics")}
- </p>
- </div>
- </div>
- ) : metrics ? (
- <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
- {enabledWidgets.map((widgetType) => (
- <div key={widgetType} className="h-[280px]">
- {renderWidget(widgetType)}
- </div>
- ))}
- </div>
- ) : null)}
+ <Separator orientation="vertical" className="h-8 mx-3" />
+ </>
+ )}
+ <Button
+ variant="outline"
+ size="default"
+ onClick={handleRefresh}
+ disabled={isRefreshing}
+ className="gap-2 font-semibold"
+ >
+ <RefreshCw
+ className={`size-3.5 ${isRefreshing ? "animate-spin" : ""}`}
+ />
+ {t("serverStats.refresh")}
+ </Button>
+ </div>
</div>
- ) : null}
+ )}
- {metricsEnabled && (
- <SimpleLoader
- visible={isLoadingMetrics && !metrics && !isConnectionLogExpanded}
- message={t("serverStats.connecting")}
- />
+ {metricsEnabled &&
+ showStatsUI &&
+ !isLoadingMetrics &&
+ !metrics &&
+ serverStatus === "offline" && (
+ <div className="flex-1 flex items-center justify-center py-20">
+ <div className="text-center opacity-40">
+ <Server className="size-16 mx-auto mb-4" />
+ <p className="text-xl font-bold uppercase tracking-widest">
+ {t("serverStats.serverOffline")}
+ </p>
+ <p className="text-sm font-semibold">
+ {t("serverStats.cannotFetchMetrics")}
+ </p>
+ </div>
+ </div>
+ )}
+
+ {metricsEnabled && showStatsUI && !isLoadingMetrics && metrics && (
+ <div className="px-3 pt-3 pb-3 columns-1 md:columns-2 lg:columns-3 gap-3">
+ {enabledWidgets.map((widgetType) => (
+ <div key={widgetType} className="break-inside-avoid mb-3">
+ {renderWidget(widgetType)}
+ </div>
+ ))}
+ </div>
)}
</div>
+
+ {metricsEnabled && (
+ <SimpleLoader
+ visible={isLoadingMetrics && !metrics && !isConnectionLogExpanded}
+ message={t("serverStats.connecting")}
+ />
+ )}
</div>
<TOTPDialog
diff --git a/src/ui/desktop/apps/features/server-stats/ServerStatsApp.tsx b/src/ui/features/server-stats/ServerStatsApp.tsx
similarity index 88%
rename from src/ui/desktop/apps/features/server-stats/ServerStatsApp.tsx
rename to src/ui/features/server-stats/ServerStatsApp.tsx
index 79c6c920f..b9b70e2fa 100644
--- a/src/ui/desktop/apps/features/server-stats/ServerStatsApp.tsx
+++ b/src/ui/features/server-stats/ServerStatsApp.tsx
@@ -1,6 +1,6 @@
import React from "react";
-import { ServerStats } from "@/ui/desktop/apps/features/server-stats/ServerStats.tsx";
-import { FullScreenAppWrapper } from "@/ui/desktop/apps/FullScreenAppWrapper.tsx";
+import { ServerStats } from "@/features/server-stats/ServerStats.tsx";
+import { FullScreenAppWrapper } from "@/features/FullScreenAppWrapper.tsx";
interface ServerStatsAppProps {
hostId?: string;
diff --git a/src/ui/features/server-stats/widgets/CpuWidget.tsx b/src/ui/features/server-stats/widgets/CpuWidget.tsx
new file mode 100644
index 000000000..18fd1dd17
--- /dev/null
+++ b/src/ui/features/server-stats/widgets/CpuWidget.tsx
@@ -0,0 +1,103 @@
+import React from "react";
+import { Cpu } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import type { ServerMetrics } from "@/main-axios.ts";
+import { SectionCard } from "@/components/section-card";
+
+interface CpuWidgetProps {
+ metrics: ServerMetrics | null;
+ metricsHistory: ServerMetrics[];
+}
+
+function Sparkline({
+ history,
+ current,
+}: {
+ history: ServerMetrics[];
+ current: number | null;
+}) {
+ const points = [
+ ...history.map((m) => m?.cpu?.percent ?? 0),
+ current ?? 0,
+ ].slice(-20);
+
+ if (points.length < 2) return null;
+
+ const w = 300;
+ const h = 48;
+ const max = Math.max(...points, 1);
+ const coords = points.map((v, i) => {
+ const x = (i / (points.length - 1)) * w;
+ const y = h - (v / max) * h;
+ return `${x},${y}`;
+ });
+
+ const d = `M ${coords.join(" L ")}`;
+ const fill = `M 0,${h} L ${coords.join(" L ")} L ${w},${h} Z`;
+
+ return (
+ <div className="h-12 md:h-16 w-full mt-2 bg-muted/20 border border-border/50 relative overflow-hidden">
+ <svg
+ className="absolute inset-0 h-full w-full"
+ viewBox={`0 0 ${w} ${h}`}
+ preserveAspectRatio="none"
+ >
+ <path d={fill} fill="currentColor" className="text-accent-brand/10" />
+ <path
+ d={d}
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ className="text-accent-brand/60"
+ />
+ </svg>
+ </div>
+ );
+}
+
+export function CpuWidget({ metrics, metricsHistory }: CpuWidgetProps) {
+ const { t } = useTranslation();
+ const percent = metrics?.cpu?.percent ?? null;
+ const cores = metrics?.cpu?.cores ?? null;
+ const load = metrics?.cpu?.load ?? null;
+
+ return (
+ <SectionCard
+ title={t("serverStats.cpuUsage")}
+ icon={<Cpu className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-2">
+ <div className="flex items-end justify-between">
+ <div className="flex flex-col">
+ <span className="text-xl md:text-3xl font-bold text-accent-brand">
+ {percent !== null ? `${percent.toFixed(1)}%` : "N/A"}
+ </span>
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-bold">
+ {cores !== null
+ ? t("serverStats.cpuCores", { count: cores })
+ : t("serverStats.naCpus")}
+ </span>
+ </div>
+ {load && (
+ <div className="text-right">
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-bold">
+ {t("serverStats.loadAvg")}
+ </span>
+ <div className="text-xs font-mono">
+ {load[0].toFixed(2)}&nbsp;&nbsp;{load[1].toFixed(2)}&nbsp;&nbsp;
+ {load[2].toFixed(2)}
+ </div>
+ </div>
+ )}
+ </div>
+ <div className="h-2 bg-muted w-full overflow-hidden">
+ <div
+ className="h-full bg-accent-brand transition-all duration-500"
+ style={{ width: `${percent ?? 0}%` }}
+ />
+ </div>
+ <Sparkline history={metricsHistory} current={percent} />
+ </div>
+ </SectionCard>
+ );
+}
diff --git a/src/ui/features/server-stats/widgets/DiskWidget.tsx b/src/ui/features/server-stats/widgets/DiskWidget.tsx
new file mode 100644
index 000000000..50c0e6807
--- /dev/null
+++ b/src/ui/features/server-stats/widgets/DiskWidget.tsx
@@ -0,0 +1,98 @@
+import { HardDrive } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import type { ServerMetrics } from "@/main-axios.ts";
+import { SectionCard } from "@/components/section-card";
+
+interface DiskWidgetProps {
+ metrics: ServerMetrics | null;
+ metricsHistory: ServerMetrics[];
+}
+
+function Sparkline({
+ history,
+ current,
+}: {
+ history: ServerMetrics[];
+ current: number | null;
+}) {
+ const points = [
+ ...history.map((m) => m?.disk?.percent ?? 0),
+ current ?? 0,
+ ].slice(-20);
+
+ if (points.length < 2) return null;
+
+ const w = 300;
+ const h = 48;
+ const max = Math.max(...points, 1);
+ const coords = points.map((v, i) => {
+ const x = (i / (points.length - 1)) * w;
+ const y = h - (v / max) * h;
+ return `${x},${y}`;
+ });
+
+ const d = `M ${coords.join(" L ")}`;
+ const fill = `M 0,${h} L ${coords.join(" L ")} L ${w},${h} Z`;
+
+ return (
+ <div className="h-12 md:h-16 w-full mt-2 bg-muted/20 border border-border/50 relative overflow-hidden">
+ <svg
+ className="absolute inset-0 h-full w-full"
+ viewBox={`0 0 ${w} ${h}`}
+ preserveAspectRatio="none"
+ >
+ <path d={fill} fill="currentColor" className="text-accent-brand/10" />
+ <path
+ d={d}
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ className="text-accent-brand/60"
+ />
+ </svg>
+ </div>
+ );
+}
+
+export function DiskWidget({ metrics, metricsHistory }: DiskWidgetProps) {
+ const { t } = useTranslation();
+ const percent = metrics?.disk?.percent ?? null;
+ const usedHuman = metrics?.disk?.usedHuman ?? null;
+ const totalHuman = metrics?.disk?.totalHuman ?? null;
+ const availableHuman = metrics?.disk?.availableHuman ?? null;
+
+ return (
+ <SectionCard
+ title={t("serverStats.diskUsage")}
+ icon={<HardDrive className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-2">
+ <div className="flex items-end justify-between">
+ <div className="flex flex-col">
+ <span className="text-xl md:text-3xl font-bold text-accent-brand">
+ {percent !== null ? `${percent}%` : "N/A"}
+ </span>
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-bold">
+ {usedHuman && totalHuman ? `${usedHuman} / ${totalHuman}` : "N/A"}
+ </span>
+ </div>
+ </div>
+ <div className="h-2 bg-muted w-full overflow-hidden">
+ <div
+ className="h-full bg-accent-brand transition-all duration-500"
+ style={{ width: `${percent ?? 0}%` }}
+ />
+ </div>
+ <div className="flex flex-col gap-1">
+ <div className="flex items-center justify-between text-xs">
+ <span className="text-muted-foreground font-semibold">
+ {t("serverStats.available")}
+ </span>
+ <span className="font-mono">{availableHuman ?? "N/A"}</span>
+ </div>
+ </div>
+ <Sparkline history={metricsHistory} current={percent} />
+ </div>
+ </SectionCard>
+ );
+}
diff --git a/src/ui/features/server-stats/widgets/FirewallWidget.tsx b/src/ui/features/server-stats/widgets/FirewallWidget.tsx
new file mode 100644
index 000000000..4a71d2b52
--- /dev/null
+++ b/src/ui/features/server-stats/widgets/FirewallWidget.tsx
@@ -0,0 +1,148 @@
+import React from "react";
+import { Shield, ShieldOff, ShieldCheck, ChevronDown } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import type { ServerMetrics } from "@/main-axios.ts";
+import type {
+ FirewallMetrics,
+ FirewallChain,
+ FirewallRule,
+} from "@/types/stats-widgets";
+import { SectionCard } from "@/components/section-card";
+
+interface FirewallWidgetProps {
+ metrics: ServerMetrics | null;
+ metricsHistory: ServerMetrics[];
+}
+
+function RuleRow({ rule }: { rule: FirewallRule }) {
+ const { t } = useTranslation();
+ const targetClass =
+ rule.target.toUpperCase() === "ACCEPT"
+ ? "text-accent-brand"
+ : rule.target.toUpperCase() === "DROP"
+ ? "text-destructive"
+ : rule.target.toUpperCase() === "REJECT"
+ ? "text-yellow-500"
+ : "text-muted-foreground";
+
+ const src =
+ rule.interface ??
+ rule.state ??
+ (rule.source === "0.0.0.0/0"
+ ? t("serverStats.firewall.anywhere")
+ : rule.source);
+
+ return (
+ <div className="grid grid-cols-4 gap-2 text-xs font-mono py-1 border-b border-border/50 last:border-0">
+ <span className={`font-bold ${targetClass}`}>{rule.target}</span>
+ <span className="text-muted-foreground">
+ {rule.protocol.toUpperCase()}
+ </span>
+ <span>{rule.dport ?? "—"}</span>
+ <span className="truncate text-muted-foreground" title={src}>
+ {src}
+ </span>
+ </div>
+ );
+}
+
+function ChainSection({ chain }: { chain: FirewallChain }) {
+ const { t } = useTranslation();
+ const [open, setOpen] = React.useState(true);
+ const policyClass =
+ chain.policy.toUpperCase() === "ACCEPT"
+ ? "text-accent-brand"
+ : chain.policy.toUpperCase() === "DROP"
+ ? "text-destructive"
+ : "text-yellow-500";
+
+ return (
+ <div>
+ <button
+ type="button"
+ onClick={() => setOpen((o) => !o)}
+ className="flex items-center gap-2 w-full py-1.5 hover:bg-muted/30 text-left"
+ >
+ <ChevronDown
+ className={`size-3 text-muted-foreground transition-transform ${open ? "" : "-rotate-90"}`}
+ />
+ <span className="text-xs font-bold">{chain.name}</span>
+ <span className="text-[10px] text-muted-foreground">
+ ({t("serverStats.firewall.policy")}:{" "}
+ <span className={policyClass}>{chain.policy}</span>)
+ </span>
+ <span className="text-[10px] text-muted-foreground ml-auto">
+ {chain.rules.length} {t("serverStats.firewall.rules")}
+ </span>
+ </button>
+ {open && chain.rules.length > 0 && (
+ <div className="ml-5">
+ <div className="grid grid-cols-4 gap-2 text-[10px] text-muted-foreground font-bold uppercase pb-1 border-b border-border">
+ <span>{t("serverStats.firewall.action")}</span>
+ <span>{t("serverStats.firewall.protocol")}</span>
+ <span>{t("serverStats.firewall.port")}</span>
+ <span>{t("serverStats.firewall.source")}</span>
+ </div>
+ {chain.rules.map((rule, i) => (
+ <RuleRow key={i} rule={rule} />
+ ))}
+ </div>
+ )}
+ </div>
+ );
+}
+
+export function FirewallWidget({ metrics }: FirewallWidgetProps) {
+ const { t } = useTranslation();
+ const firewall = (metrics as ServerMetrics & { firewall?: FirewallMetrics })
+ ?.firewall;
+
+ const statusIcon =
+ !firewall || firewall.type === "none" ? (
+ <ShieldOff className="size-3.5 text-muted-foreground" />
+ ) : firewall.status === "active" ? (
+ <ShieldCheck className="size-3.5 text-accent-brand" />
+ ) : (
+ <Shield className="size-3.5 text-yellow-500" />
+ );
+
+ const statusBadge =
+ firewall?.status === "active" ? (
+ <span className="flex items-center gap-1.5 px-2 py-0.5 border border-accent-brand/40 bg-accent-brand/10 text-accent-brand text-[10px] font-bold">
+ <ShieldCheck className="size-3" /> ACTIVE
+ </span>
+ ) : (
+ <span className="flex items-center gap-1.5 px-2 py-0.5 border border-border text-muted-foreground text-[10px] font-bold">
+ {t("serverStats.firewall.inactive").toUpperCase()}
+ </span>
+ );
+
+ return (
+ <SectionCard title={t("serverStats.firewall.title")} icon={statusIcon}>
+ <div className="flex flex-col gap-3 py-1">
+ <div className="flex items-center justify-between">
+ <span className="text-sm font-semibold">
+ {t("serverStats.firewall.title")}
+ </span>
+ {statusBadge}
+ </div>
+ {firewall?.type && firewall.type !== "none" && (
+ <span className="text-[10px] text-muted-foreground uppercase font-bold">
+ {firewall.type}
+ </span>
+ )}
+ {firewall && firewall.chains.length > 0 ? (
+ <div className="flex flex-col gap-1">
+ {firewall.chains.map((chain) => (
+ <ChainSection key={chain.name} chain={chain} />
+ ))}
+ </div>
+ ) : (
+ <span className="text-xs text-muted-foreground">
+ {t("serverStats.firewall.noData")}
+ </span>
+ )}
+ </div>
+ </SectionCard>
+ );
+}
diff --git a/src/ui/features/server-stats/widgets/LoginStatsWidget.tsx b/src/ui/features/server-stats/widgets/LoginStatsWidget.tsx
new file mode 100644
index 000000000..c1a184d59
--- /dev/null
+++ b/src/ui/features/server-stats/widgets/LoginStatsWidget.tsx
@@ -0,0 +1,87 @@
+import { UserCheck, UserX } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import { SectionCard } from "@/components/section-card";
+
+interface LoginRecord {
+ user: string;
+ ip: string;
+ time: string;
+ status: "success" | "failed";
+}
+
+interface LoginStatsMetrics {
+ recentLogins: LoginRecord[];
+ failedLogins: LoginRecord[];
+ totalLogins: number;
+ uniqueIPs: number;
+}
+
+interface LoginStatsWidgetProps {
+ metrics: { login_stats?: LoginStatsMetrics } | null;
+ metricsHistory: unknown[];
+}
+
+export function LoginStatsWidget({ metrics }: LoginStatsWidgetProps) {
+ const { t } = useTranslation();
+
+ const loginStats = metrics?.login_stats;
+ const recentLogins = loginStats?.recentLogins ?? [];
+ const failedLogins = loginStats?.failedLogins ?? [];
+
+ const allLogins = [
+ ...recentLogins.map((l) => ({ ...l, status: "success" as const })),
+ ...failedLogins.map((l) => ({ ...l, status: "failed" as const })),
+ ]
+ .sort((a, b) => new Date(b.time).getTime() - new Date(a.time).getTime())
+ .slice(0, 6);
+
+ return (
+ <SectionCard
+ title={t("serverStats.loginStats")}
+ icon={<UserCheck className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-2 py-1">
+ {allLogins.length === 0 ? (
+ <span className="text-xs text-muted-foreground italic py-2">
+ {t("serverStats.noRecentLoginData")}
+ </span>
+ ) : (
+ allLogins.map((login, i) => (
+ <div
+ key={i}
+ className={`flex items-center justify-between p-2 border ${login.status === "success" ? "border-border bg-muted/30" : "border-destructive/30 bg-destructive/5"}`}
+ >
+ <div className="flex flex-col">
+ <div className="flex items-center gap-1.5">
+ {login.status === "failed" ? (
+ <UserX className="size-3 text-destructive" />
+ ) : (
+ <UserCheck className="size-3 text-accent-brand" />
+ )}
+ <span
+ className={`text-xs font-bold ${login.status === "failed" ? "text-destructive" : ""}`}
+ >
+ {login.user}
+ </span>
+ </div>
+ <span className="text-[10px] text-muted-foreground font-mono">
+ {login.ip}
+ </span>
+ </div>
+ <div className="flex flex-col items-end gap-1">
+ <span
+ className={`text-[9px] font-bold uppercase px-1.5 py-px border ${login.status === "success" ? "border-accent-brand/40 text-accent-brand bg-accent-brand/10" : "border-destructive/40 text-destructive"}`}
+ >
+ {login.status}
+ </span>
+ <span className="text-[10px] text-muted-foreground">
+ {new Date(login.time).toLocaleTimeString()}
+ </span>
+ </div>
+ </div>
+ ))
+ )}
+ </div>
+ </SectionCard>
+ );
+}
diff --git a/src/ui/features/server-stats/widgets/MemoryWidget.tsx b/src/ui/features/server-stats/widgets/MemoryWidget.tsx
new file mode 100644
index 000000000..4b86d2d01
--- /dev/null
+++ b/src/ui/features/server-stats/widgets/MemoryWidget.tsx
@@ -0,0 +1,109 @@
+import { MemoryStick } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import type { ServerMetrics } from "@/main-axios.ts";
+import { SectionCard } from "@/components/section-card";
+
+interface MemoryWidgetProps {
+ metrics: ServerMetrics | null;
+ metricsHistory: ServerMetrics[];
+}
+
+function Sparkline({
+ history,
+ current,
+}: {
+ history: ServerMetrics[];
+ current: number | null;
+}) {
+ const points = [
+ ...history.map((m) => m?.memory?.percent ?? 0),
+ current ?? 0,
+ ].slice(-20);
+
+ if (points.length < 2) return null;
+
+ const w = 300;
+ const h = 48;
+ const max = Math.max(...points, 1);
+ const coords = points.map((v, i) => {
+ const x = (i / (points.length - 1)) * w;
+ const y = h - (v / max) * h;
+ return `${x},${y}`;
+ });
+
+ const d = `M ${coords.join(" L ")}`;
+ const fill = `M 0,${h} L ${coords.join(" L ")} L ${w},${h} Z`;
+
+ return (
+ <div className="h-12 md:h-16 w-full mt-2 bg-muted/20 border border-border/50 relative overflow-hidden">
+ <svg
+ className="absolute inset-0 h-full w-full"
+ viewBox={`0 0 ${w} ${h}`}
+ preserveAspectRatio="none"
+ >
+ <path d={fill} fill="currentColor" className="text-accent-brand/10" />
+ <path
+ d={d}
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ className="text-accent-brand/60"
+ />
+ </svg>
+ </div>
+ );
+}
+
+export function MemoryWidget({ metrics, metricsHistory }: MemoryWidgetProps) {
+ const { t } = useTranslation();
+ const percent = metrics?.memory?.percent ?? null;
+ const usedGiB = metrics?.memory?.usedGiB ?? null;
+ const totalGiB = metrics?.memory?.totalGiB ?? null;
+
+ return (
+ <SectionCard
+ title={t("serverStats.memoryUsage")}
+ icon={<MemoryStick className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-2">
+ <div className="flex items-end justify-between">
+ <div className="flex flex-col">
+ <span className="text-xl md:text-3xl font-bold text-accent-brand">
+ {percent !== null ? `${percent.toFixed(1)}%` : "N/A"}
+ </span>
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-bold">
+ {usedGiB !== null && totalGiB !== null
+ ? `${usedGiB.toFixed(1)} / ${totalGiB.toFixed(1)} GiB`
+ : "N/A"}
+ </span>
+ </div>
+ </div>
+ <div className="h-2 bg-muted w-full overflow-hidden">
+ <div
+ className="h-full bg-accent-brand transition-all duration-500"
+ style={{ width: `${percent ?? 0}%` }}
+ />
+ </div>
+ <div className="grid grid-cols-2 gap-2">
+ <div className="flex flex-col p-2 bg-muted/30 border border-border">
+ <span className="text-[10px] text-muted-foreground uppercase font-bold">
+ {t("serverStats.swap")}
+ </span>
+ <span className="text-xs font-semibold">N/A</span>
+ </div>
+ <div className="flex flex-col p-2 bg-muted/30 border border-border">
+ <span className="text-[10px] text-muted-foreground uppercase font-bold">
+ {t("serverStats.free")}
+ </span>
+ <span className="text-xs font-semibold">
+ {usedGiB !== null && totalGiB !== null
+ ? `${(totalGiB - usedGiB).toFixed(1)} GiB`
+ : "N/A"}
+ </span>
+ </div>
+ </div>
+ <Sparkline history={metricsHistory} current={percent} />
+ </div>
+ </SectionCard>
+ );
+}
diff --git a/src/ui/features/server-stats/widgets/NetworkWidget.tsx b/src/ui/features/server-stats/widgets/NetworkWidget.tsx
new file mode 100644
index 000000000..607d10598
--- /dev/null
+++ b/src/ui/features/server-stats/widgets/NetworkWidget.tsx
@@ -0,0 +1,73 @@
+import { Network, WifiOff } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import type { ServerMetrics } from "@/main-axios.ts";
+import { SectionCard } from "@/components/section-card";
+
+interface NetworkWidgetProps {
+ metrics: ServerMetrics | null;
+ metricsHistory: ServerMetrics[];
+}
+
+export function NetworkWidget({ metrics }: NetworkWidgetProps) {
+ const { t } = useTranslation();
+
+ const metricsWithNetwork = metrics as ServerMetrics & {
+ network?: {
+ interfaces?: Array<{
+ name: string;
+ state: string;
+ ip: string;
+ rx?: string;
+ tx?: string;
+ }>;
+ };
+ };
+ const interfaces = metricsWithNetwork?.network?.interfaces ?? [];
+
+ return (
+ <SectionCard
+ title={t("serverStats.networkInterfaces")}
+ icon={<Network className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-2 py-1">
+ {interfaces.length === 0 ? (
+ <div className="flex flex-col items-center justify-center py-6 text-muted-foreground gap-2">
+ <WifiOff className="size-6 opacity-40" />
+ <span className="text-xs">
+ {t("serverStats.noInterfacesFound")}
+ </span>
+ </div>
+ ) : (
+ interfaces.map((iface, i) => (
+ <div
+ key={i}
+ className="flex flex-col p-2 border border-border bg-muted/30 gap-1"
+ >
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-2">
+ <div
+ className={`size-1.5 rounded-full ${iface.state === "UP" ? "bg-accent-brand" : "bg-muted-foreground"}`}
+ />
+ <span className="text-sm font-bold font-mono">
+ {iface.name}
+ </span>
+ </div>
+ <span className="text-[10px] font-semibold px-1.5 py-px border border-border text-muted-foreground uppercase">
+ {iface.state}
+ </span>
+ </div>
+ <div className="flex justify-between text-[10px] font-mono text-muted-foreground">
+ <span>{iface.ip}</span>
+ {(iface.rx || iface.tx) && (
+ <span>
+ ↓ {iface.rx ?? "—"} / ↑ {iface.tx ?? "—"}
+ </span>
+ )}
+ </div>
+ </div>
+ ))
+ )}
+ </div>
+ </SectionCard>
+ );
+}
diff --git a/src/ui/features/server-stats/widgets/PortsWidget.tsx b/src/ui/features/server-stats/widgets/PortsWidget.tsx
new file mode 100644
index 000000000..9b6a24879
--- /dev/null
+++ b/src/ui/features/server-stats/widgets/PortsWidget.tsx
@@ -0,0 +1,66 @@
+import { Unplug } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import type { ServerMetrics } from "@/main-axios.ts";
+import type { PortsMetrics, ListeningPort } from "@/types/stats-widgets";
+import { SectionCard } from "@/components/section-card";
+
+interface PortsWidgetProps {
+ metrics: ServerMetrics | null;
+ metricsHistory: ServerMetrics[];
+}
+
+function PortRow({ port }: { port: ListeningPort }) {
+ const formatAddress = (addr: string) =>
+ addr === "0.0.0.0" || addr === "*" || addr === "::" ? "*" : addr;
+
+ return (
+ <div className="grid grid-cols-4 text-xs font-mono py-1 border-b border-border/50 last:border-0 min-w-0">
+ <span className="text-accent-brand font-bold">{port.localPort}</span>
+ <span className="text-muted-foreground">
+ {port.protocol.toUpperCase()}
+ </span>
+ <span className="font-semibold truncate">
+ {port.process ?? (port.pid ? `PID:${port.pid}` : "—")}
+ </span>
+ <span className="text-right text-muted-foreground">
+ {formatAddress(port.localAddress)}
+ </span>
+ </div>
+ );
+}
+
+export function PortsWidget({ metrics }: PortsWidgetProps) {
+ const { t } = useTranslation();
+
+ const portsData = (metrics as ServerMetrics & { ports?: PortsMetrics })
+ ?.ports;
+ const ports = portsData?.ports ?? [];
+
+ return (
+ <SectionCard
+ title={t("serverStats.ports.title")}
+ icon={<Unplug className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-1.5 py-1">
+ <div className="grid grid-cols-4 text-[10px] text-muted-foreground font-bold uppercase pb-1 border-b border-border min-w-0">
+ <span>{t("serverStats.ports.port")}</span>
+ <span>{t("serverStats.ports.protocol")}</span>
+ <span>{t("serverStats.ports.process")}</span>
+ <span className="text-right">{t("serverStats.ports.address")}</span>
+ </div>
+ {ports.length === 0 ? (
+ <span className="text-xs text-muted-foreground italic py-2">
+ {t("serverStats.ports.noData")}
+ </span>
+ ) : (
+ ports.map((port, i) => (
+ <PortRow
+ key={`${port.protocol}-${port.localPort}-${i}`}
+ port={port}
+ />
+ ))
+ )}
+ </div>
+ </SectionCard>
+ );
+}
diff --git a/src/ui/features/server-stats/widgets/ProcessesWidget.tsx b/src/ui/features/server-stats/widgets/ProcessesWidget.tsx
new file mode 100644
index 000000000..fb3abf141
--- /dev/null
+++ b/src/ui/features/server-stats/widgets/ProcessesWidget.tsx
@@ -0,0 +1,65 @@
+import { List, Activity } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import type { ServerMetrics } from "@/main-axios.ts";
+import { SectionCard } from "@/components/section-card";
+
+interface ProcessesWidgetProps {
+ metrics: ServerMetrics | null;
+ metricsHistory: ServerMetrics[];
+}
+
+export function ProcessesWidget({ metrics }: ProcessesWidgetProps) {
+ const { t } = useTranslation();
+
+ const metricsWithProcesses = metrics as ServerMetrics & {
+ processes?: {
+ total?: number;
+ running?: number;
+ top?: Array<{
+ pid: number;
+ cpu: number;
+ mem: number;
+ command: string;
+ user: string;
+ }>;
+ };
+ };
+ const processes = metricsWithProcesses?.processes;
+ const topProcesses = processes?.top ?? [];
+
+ return (
+ <SectionCard
+ title={t("serverStats.processes")}
+ icon={<List className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-1.5 py-1">
+ <div className="grid grid-cols-4 text-[10px] text-muted-foreground font-bold uppercase tracking-wider pb-1 border-b border-border min-w-0">
+ <span>PID</span>
+ <span>CPU</span>
+ <span>MEM</span>
+ <span>CMD</span>
+ </div>
+ {topProcesses.length === 0 ? (
+ <div className="flex flex-col items-center justify-center py-6 text-muted-foreground gap-2">
+ <Activity className="size-6 opacity-40" />
+ <span className="text-xs">{t("serverStats.noProcessesFound")}</span>
+ </div>
+ ) : (
+ topProcesses.map((proc, i) => (
+ <div
+ key={i}
+ className="grid grid-cols-4 text-xs font-mono py-1 border-b border-border/50 last:border-0 min-w-0"
+ >
+ <span className="text-muted-foreground">{proc.pid}</span>
+ <span className="text-accent-brand font-bold">{proc.cpu}%</span>
+ <span>{proc.mem}%</span>
+ <span className="truncate font-semibold" title={proc.command}>
+ {proc.command.split("/").pop()}
+ </span>
+ </div>
+ ))
+ )}
+ </div>
+ </SectionCard>
+ );
+}
diff --git a/src/ui/features/server-stats/widgets/SystemWidget.tsx b/src/ui/features/server-stats/widgets/SystemWidget.tsx
new file mode 100644
index 000000000..dfacdbdf1
--- /dev/null
+++ b/src/ui/features/server-stats/widgets/SystemWidget.tsx
@@ -0,0 +1,51 @@
+import { Server } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import type { ServerMetrics } from "@/main-axios.ts";
+import { SectionCard } from "@/components/section-card";
+
+interface SystemWidgetProps {
+ metrics: ServerMetrics | null;
+ metricsHistory: ServerMetrics[];
+}
+
+export function SystemWidget({ metrics }: SystemWidgetProps) {
+ const { t } = useTranslation();
+
+ const metricsWithSystem = metrics as ServerMetrics & {
+ system?: { hostname?: string; os?: string; kernel?: string; arch?: string };
+ uptime?: { formatted?: string };
+ };
+ const system = metricsWithSystem?.system;
+ const uptime = metricsWithSystem?.uptime;
+
+ const rows = [
+ { label: t("serverStats.hostname"), value: system?.hostname },
+ { label: t("serverStats.operatingSystem"), value: system?.os },
+ { label: t("serverStats.kernel"), value: system?.kernel },
+ { label: t("serverStats.architecture"), value: system?.arch },
+ { label: t("serverStats.uptime"), value: uptime?.formatted },
+ ].filter((r) => r.value);
+
+ return (
+ <SectionCard
+ title={t("serverStats.systemInfo")}
+ icon={<Server className="size-3.5" />}
+ >
+ <div className="grid grid-cols-1 gap-y-3 py-2">
+ {rows.map(({ label, value }) => (
+ <div key={label} className="flex flex-col">
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-bold">
+ {label}
+ </span>
+ <span className="text-sm font-mono font-semibold truncate">
+ {value}
+ </span>
+ </div>
+ ))}
+ {rows.length === 0 && (
+ <span className="text-xs text-muted-foreground">N/A</span>
+ )}
+ </div>
+ </SectionCard>
+ );
+}
diff --git a/src/ui/features/server-stats/widgets/UptimeWidget.tsx b/src/ui/features/server-stats/widgets/UptimeWidget.tsx
new file mode 100644
index 000000000..9850fa0cb
--- /dev/null
+++ b/src/ui/features/server-stats/widgets/UptimeWidget.tsx
@@ -0,0 +1,37 @@
+import { Clock } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import type { ServerMetrics } from "@/main-axios.ts";
+import { SectionCard } from "@/components/section-card";
+
+interface UptimeWidgetProps {
+ metrics: ServerMetrics | null;
+ metricsHistory: ServerMetrics[];
+}
+
+export function UptimeWidget({ metrics }: UptimeWidgetProps) {
+ const { t } = useTranslation();
+
+ const metricsWithUptime = metrics as ServerMetrics & {
+ uptime?: { formatted?: string; seconds?: number };
+ };
+ const uptime = metricsWithUptime?.uptime;
+
+ return (
+ <SectionCard
+ title={t("serverStats.uptime")}
+ icon={<Clock className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-3 py-2">
+ <span className="text-xl md:text-3xl font-bold text-accent-brand">
+ {uptime?.formatted ?? "N/A"}
+ </span>
+ {uptime?.seconds && (
+ <span className="text-xs text-muted-foreground font-mono">
+ {Math.floor(uptime.seconds).toLocaleString()}{" "}
+ {t("serverStats.seconds")}
+ </span>
+ )}
+ </div>
+ </SectionCard>
+ );
+}
diff --git a/src/ui/desktop/apps/features/server-stats/widgets/index.ts b/src/ui/features/server-stats/widgets/index.ts
similarity index 100%
rename from src/ui/desktop/apps/features/server-stats/widgets/index.ts
rename to src/ui/features/server-stats/widgets/index.ts
diff --git a/src/ui/desktop/apps/features/terminal/Terminal.tsx b/src/ui/features/terminal/Terminal.tsx
similarity index 98%
rename from src/ui/desktop/apps/features/terminal/Terminal.tsx
rename to src/ui/features/terminal/Terminal.tsx
index 1e3524fd5..901bb2cd6 100644
--- a/src/ui/desktop/apps/features/terminal/Terminal.tsx
+++ b/src/ui/features/terminal/Terminal.tsx
@@ -24,34 +24,34 @@ import {
getCommandHistory,
getHostPassword,
getServerConfig,
-} from "@/ui/main-axios.ts";
-import { TOTPDialog } from "@/ui/desktop/navigation/dialogs/TOTPDialog.tsx";
-import { SSHAuthDialog } from "@/ui/desktop/navigation/dialogs/SSHAuthDialog.tsx";
-import { PassphraseDialog } from "@/ui/desktop/navigation/dialogs/PassphraseDialog.tsx";
-import { WarpgateDialog } from "@/ui/desktop/navigation/dialogs/WarpgateDialog.tsx";
-import { OPKSSHDialog } from "@/ui/desktop/navigation/dialogs/OPKSSHDialog.tsx";
-import { HostKeyVerificationDialog } from "@/ui/desktop/navigation/dialogs/HostKeyVerificationDialog.tsx";
-import { TmuxSessionPicker } from "@/ui/desktop/navigation/dialogs/TmuxSessionPicker.tsx";
+} from "@/main-axios.ts";
+import { TOTPDialog } from "@/ssh/dialogs/TOTPDialog.tsx";
+import { SSHAuthDialog } from "@/ssh/dialogs/SSHAuthDialog.tsx";
+import { PassphraseDialog } from "@/ssh/dialogs/PassphraseDialog.tsx";
+import { WarpgateDialog } from "@/ssh/dialogs/WarpgateDialog.tsx";
+import { OPKSSHDialog } from "@/ssh/dialogs/OPKSSHDialog.tsx";
+import { HostKeyVerificationDialog } from "@/ssh/dialogs/HostKeyVerificationDialog.tsx";
+import { TmuxSessionPicker } from "@/ssh/dialogs/TmuxSessionPicker.tsx";
import {
TERMINAL_THEMES,
DEFAULT_TERMINAL_CONFIG,
TERMINAL_FONTS,
-} from "@/constants/terminal-themes.ts";
+} from "@/lib/terminal-themes.ts";
import type { TerminalConfig } from "@/types";
import { useTheme } from "@/components/theme-provider.tsx";
-import { useCommandTracker } from "@/ui/hooks/useCommandTracker.ts";
+import { useCommandTracker } from "@/features/terminal/command-history/useCommandTracker.ts";
import { highlightTerminalOutput } from "@/lib/terminal-syntax-highlighter.ts";
-import { useCommandHistory } from "@/ui/desktop/apps/features/terminal/command-history/CommandHistoryContext.tsx";
+import { useCommandHistory } from "@/features/terminal/command-history/CommandHistoryContext.tsx";
import { CommandAutocomplete } from "./command-history/CommandAutocomplete.tsx";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
+import { SimpleLoader } from "@/lib/SimpleLoader.tsx";
import { useConfirmation } from "@/hooks/use-confirmation.ts";
import {
ConnectionLogProvider,
useConnectionLog,
-} from "@/ui/desktop/navigation/connection-log/ConnectionLogContext.tsx";
-import { ConnectionLog } from "@/ui/desktop/navigation/connection-log/ConnectionLog.tsx";
+} from "@/ssh/connection-log/ConnectionLogContext.tsx";
+import { ConnectionLog } from "@/ssh/connection-log/ConnectionLog.tsx";
import { toast } from "sonner";
-import { Button } from "@/components/ui/button";
+import { Button } from "@/components/button";
interface HostConfig {
id?: number;
@@ -464,25 +464,23 @@ const TerminalInner = forwardRef<TerminalHandle, SSHTerminalProps>(
return;
}
- const lastSize = lastFittedSizeRef.current;
- if (
- lastSize &&
- lastSize.cols === terminal.cols &&
- lastSize.rows === terminal.rows
- ) {
- return;
- }
-
isFittingRef.current = true;
try {
- fitAddonRef.current?.fit();
+ fitAddonRef.current.fit();
if (terminal && terminal.cols > 0 && terminal.rows > 0) {
- scheduleNotify(terminal.cols, terminal.rows);
- lastFittedSizeRef.current = {
- cols: terminal.cols,
- rows: terminal.rows,
- };
+ const lastSize = lastFittedSizeRef.current;
+ if (
+ !lastSize ||
+ lastSize.cols !== terminal.cols ||
+ lastSize.rows !== terminal.rows
+ ) {
+ scheduleNotify(terminal.cols, terminal.rows);
+ lastFittedSizeRef.current = {
+ cols: terminal.cols,
+ rows: terminal.rows,
+ };
+ }
}
setIsFitted(true);
} finally {
@@ -2043,13 +2041,14 @@ const TerminalInner = forwardRef<TerminalHandle, SSHTerminalProps>(
const resizeObserver = new ResizeObserver(() => {
if (resizeTimeout.current) clearTimeout(resizeTimeout.current);
resizeTimeout.current = setTimeout(() => {
- if (isVisible && terminal?.cols > 0) {
+ if (isVisible) {
performFit();
}
}, 50);
});
- resizeObserver.observe(xtermRef.current);
+ const observeTarget = xtermRef.current.parentElement ?? xtermRef.current;
+ resizeObserver.observe(observeTarget);
return () => {
isFittingRef.current = false;
diff --git a/src/ui/desktop/apps/features/terminal/TerminalApp.tsx b/src/ui/features/terminal/TerminalApp.tsx
similarity index 89%
rename from src/ui/desktop/apps/features/terminal/TerminalApp.tsx
rename to src/ui/features/terminal/TerminalApp.tsx
index 78cdaf334..94575fa48 100644
--- a/src/ui/desktop/apps/features/terminal/TerminalApp.tsx
+++ b/src/ui/features/terminal/TerminalApp.tsx
@@ -1,6 +1,6 @@
import React from "react";
-import { Terminal } from "@/ui/desktop/apps/features/terminal/Terminal.tsx";
-import { FullScreenAppWrapper } from "@/ui/desktop/apps/FullScreenAppWrapper.tsx";
+import { Terminal } from "@/features/terminal/Terminal.tsx";
+import { FullScreenAppWrapper } from "@/features/FullScreenAppWrapper.tsx";
interface TerminalAppProps {
hostId?: string;
diff --git a/src/ui/desktop/apps/features/terminal/TerminalPreview.tsx b/src/ui/features/terminal/TerminalPreview.tsx
similarity index 97%
rename from src/ui/desktop/apps/features/terminal/TerminalPreview.tsx
rename to src/ui/features/terminal/TerminalPreview.tsx
index 9559e0e80..987e631c9 100644
--- a/src/ui/desktop/apps/features/terminal/TerminalPreview.tsx
+++ b/src/ui/features/terminal/TerminalPreview.tsx
@@ -1,7 +1,4 @@
-import {
- TERMINAL_THEMES,
- TERMINAL_FONTS,
-} from "@/constants/terminal-themes.ts";
+import { TERMINAL_THEMES, TERMINAL_FONTS } from "@/lib/terminal-themes.ts";
import { useTheme } from "@/components/theme-provider.tsx";
interface TerminalPreviewProps {
diff --git a/src/ui/desktop/apps/features/terminal/command-history/CommandAutocomplete.tsx b/src/ui/features/terminal/command-history/CommandAutocomplete.tsx
similarity index 100%
rename from src/ui/desktop/apps/features/terminal/command-history/CommandAutocomplete.tsx
rename to src/ui/features/terminal/command-history/CommandAutocomplete.tsx
diff --git a/src/ui/desktop/apps/features/terminal/command-history/CommandHistoryContext.tsx b/src/ui/features/terminal/command-history/CommandHistoryContext.tsx
similarity index 100%
rename from src/ui/desktop/apps/features/terminal/command-history/CommandHistoryContext.tsx
rename to src/ui/features/terminal/command-history/CommandHistoryContext.tsx
diff --git a/src/ui/hooks/useCommandHistory.ts b/src/ui/features/terminal/command-history/useCommandHistory.ts
similarity index 97%
rename from src/ui/hooks/useCommandHistory.ts
rename to src/ui/features/terminal/command-history/useCommandHistory.ts
index 93c647f69..60ffef072 100644
--- a/src/ui/hooks/useCommandHistory.ts
+++ b/src/ui/features/terminal/command-history/useCommandHistory.ts
@@ -1,5 +1,5 @@
import { useState, useEffect, useCallback, useRef } from "react";
-import { getCommandHistory, saveCommandToHistory } from "@/ui/main-axios.ts";
+import { getCommandHistory, saveCommandToHistory } from "@/main-axios.ts";
interface UseCommandHistoryOptions {
hostId?: number;
diff --git a/src/ui/hooks/useCommandTracker.ts b/src/ui/features/terminal/command-history/useCommandTracker.ts
similarity index 98%
rename from src/ui/hooks/useCommandTracker.ts
rename to src/ui/features/terminal/command-history/useCommandTracker.ts
index 2ae0f3783..eb4e64d99 100644
--- a/src/ui/hooks/useCommandTracker.ts
+++ b/src/ui/features/terminal/command-history/useCommandTracker.ts
@@ -1,5 +1,5 @@
import { useRef, useCallback } from "react";
-import { saveCommandToHistory } from "@/ui/main-axios.ts";
+import { saveCommandToHistory } from "@/main-axios.ts";
const SENSITIVE_PATTERNS = [
/\bpassw(or)?d\b/i,
diff --git a/src/ui/desktop/apps/features/tunnel/Tunnel.tsx b/src/ui/features/tunnel/Tunnel.tsx
similarity index 98%
rename from src/ui/desktop/apps/features/tunnel/Tunnel.tsx
rename to src/ui/features/tunnel/Tunnel.tsx
index 0de2bd7a1..8843d60cf 100644
--- a/src/ui/desktop/apps/features/tunnel/Tunnel.tsx
+++ b/src/ui/features/tunnel/Tunnel.tsx
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useCallback } from "react";
-import { TunnelViewer } from "@/ui/desktop/apps/features/tunnel/TunnelViewer.tsx";
+import { TunnelViewer } from "@/features/tunnel/TunnelViewer.tsx";
import {
getSSHHosts,
subscribeTunnelStatuses,
@@ -7,13 +7,13 @@ import {
disconnectTunnel,
cancelTunnel,
logActivity,
-} from "@/ui/main-axios.ts";
+} from "@/main-axios.ts";
import type {
SSHHost,
TunnelConnection,
TunnelStatus,
SSHTunnelProps,
-} from "../../../types/index.js";
+} from "@/types/index";
export function Tunnel({ filterHostKey }: SSHTunnelProps): React.ReactElement {
const [allHosts, setAllHosts] = useState<SSHHost[]>([]);
diff --git a/src/ui/desktop/apps/features/tunnel/TunnelApp.tsx b/src/ui/features/tunnel/TunnelApp.tsx
similarity index 88%
rename from src/ui/desktop/apps/features/tunnel/TunnelApp.tsx
rename to src/ui/features/tunnel/TunnelApp.tsx
index d464954d1..c5c16bef3 100644
--- a/src/ui/desktop/apps/features/tunnel/TunnelApp.tsx
+++ b/src/ui/features/tunnel/TunnelApp.tsx
@@ -1,6 +1,6 @@
import React from "react";
-import { TunnelManager } from "@/ui/desktop/apps/features/tunnel/TunnelManager.tsx";
-import { FullScreenAppWrapper } from "@/ui/desktop/apps/FullScreenAppWrapper.tsx";
+import { TunnelManager } from "@/features/tunnel/TunnelManager.tsx";
+import { FullScreenAppWrapper } from "@/features/FullScreenAppWrapper.tsx";
interface TunnelAppProps {
hostId?: string;
diff --git a/src/ui/desktop/apps/features/tunnel/TunnelInlineControls.tsx b/src/ui/features/tunnel/TunnelInlineControls.tsx
similarity index 98%
rename from src/ui/desktop/apps/features/tunnel/TunnelInlineControls.tsx
rename to src/ui/features/tunnel/TunnelInlineControls.tsx
index 14b503f9b..9b062fa94 100644
--- a/src/ui/desktop/apps/features/tunnel/TunnelInlineControls.tsx
+++ b/src/ui/features/tunnel/TunnelInlineControls.tsx
@@ -1,4 +1,4 @@
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import type { TunnelStatus } from "@/types/index.js";
import {
AlertCircle,
diff --git a/src/ui/desktop/apps/features/tunnel/TunnelManager.tsx b/src/ui/features/tunnel/TunnelManager.tsx
similarity index 90%
rename from src/ui/desktop/apps/features/tunnel/TunnelManager.tsx
rename to src/ui/features/tunnel/TunnelManager.tsx
index bbde6bae7..8ba47f38b 100644
--- a/src/ui/desktop/apps/features/tunnel/TunnelManager.tsx
+++ b/src/ui/features/tunnel/TunnelManager.tsx
@@ -1,11 +1,10 @@
import React from "react";
-import { useSidebar } from "@/components/ui/sidebar.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Tunnel } from "@/ui/desktop/apps/features/tunnel/Tunnel.tsx";
+import { Separator } from "@/components/separator.tsx";
+import { Button } from "@/components/button.tsx";
+import { Tunnel } from "@/features/tunnel/Tunnel.tsx";
import { useTranslation } from "react-i18next";
-import { getSSHHosts } from "@/ui/main-axios.ts";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext.tsx";
+import { getSSHHosts } from "@/main-axios.ts";
+import { useTabsSafe } from "@/shell/TabContext.tsx";
interface HostConfig {
id: number;
@@ -34,8 +33,7 @@ export function TunnelManager({
embedded = false,
}: TunnelManagerProps): React.ReactElement {
const { t } = useTranslation();
- const { state: sidebarState } = useSidebar();
- const { tabs, addTab, setCurrentTab, updateTab } = useTabs();
+ const { tabs, addTab, setCurrentTab, updateTab } = useTabsSafe();
const [currentHostConfig, setCurrentHostConfig] = React.useState(hostConfig);
const isElectron =
typeof window !== "undefined" && window.electronAPI?.isElectron === true;
@@ -102,7 +100,7 @@ export function TunnelManager({
}, [hostConfig?.id]);
const topMarginPx = isTopbarOpen ? 74 : 16;
- const leftMarginPx = sidebarState === "collapsed" ? 16 : 8;
+ const leftMarginPx = 8;
const bottomMarginPx = 8;
const wrapperStyle: React.CSSProperties = embedded
diff --git a/src/ui/desktop/apps/features/tunnel/TunnelModeSelector.tsx b/src/ui/features/tunnel/TunnelModeSelector.tsx
similarity index 100%
rename from src/ui/desktop/apps/features/tunnel/TunnelModeSelector.tsx
rename to src/ui/features/tunnel/TunnelModeSelector.tsx
diff --git a/src/ui/desktop/apps/features/tunnel/TunnelObject.tsx b/src/ui/features/tunnel/TunnelObject.tsx
similarity index 98%
rename from src/ui/desktop/apps/features/tunnel/TunnelObject.tsx
rename to src/ui/features/tunnel/TunnelObject.tsx
index 65bd25ddd..6d985e62d 100644
--- a/src/ui/desktop/apps/features/tunnel/TunnelObject.tsx
+++ b/src/ui/features/tunnel/TunnelObject.tsx
@@ -1,7 +1,7 @@
import React from "react";
-import { Button } from "@/components/ui/button.tsx";
-import { Card } from "@/components/ui/card.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
+import { Button } from "@/components/button.tsx";
+import { Card } from "@/components/card.tsx";
+import { Separator } from "@/components/separator.tsx";
import { useTranslation } from "react-i18next";
import {
Loader2,
@@ -16,11 +16,8 @@ import {
WifiOff,
X,
} from "lucide-react";
-import { Badge } from "@/components/ui/badge.tsx";
-import type {
- TunnelStatus,
- SSHTunnelObjectProps,
-} from "../../../types/index.js";
+import { Badge } from "@/components/badge.tsx";
+import type { TunnelStatus, SSHTunnelObjectProps } from "@/types/index";
export function TunnelObject({
host,
diff --git a/src/ui/features/tunnel/TunnelTab.tsx b/src/ui/features/tunnel/TunnelTab.tsx
new file mode 100644
index 000000000..5d6879b76
--- /dev/null
+++ b/src/ui/features/tunnel/TunnelTab.tsx
@@ -0,0 +1,473 @@
+import React, { useCallback, useEffect, useState } from "react";
+import { Button } from "@/components/button";
+import { Card } from "@/components/card";
+import { Input } from "@/components/input";
+import { Separator } from "@/components/separator";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "@/components/dialog";
+import {
+ AlertCircle,
+ Clock,
+ Network,
+ Play,
+ Plus,
+ RefreshCw,
+ Settings,
+ Square,
+ Trash2,
+ Wifi,
+ WifiOff,
+} from "lucide-react";
+import { toast } from "sonner";
+import { useTranslation } from "react-i18next";
+import {
+ getSSHHosts,
+ subscribeTunnelStatuses,
+ connectTunnel,
+ disconnectTunnel,
+ cancelTunnel,
+ logActivity,
+} from "@/main-axios";
+import type { Host as DemoHost } from "@/types/ui-types";
+import type { SSHHost, TunnelConnection, TunnelStatus } from "@/types";
+
+function tunnelName(
+ host: SSHHost,
+ index: number,
+ tunnel: TunnelConnection,
+): string {
+ const hostKey = host.name || `${host.username}@${host.ip}`;
+ return `${host.id}::${index}::${hostKey}::${tunnel.sourcePort}::${tunnel.endpointHost}::${tunnel.endpointPort}`;
+}
+
+function statusLabel(status: TunnelStatus | undefined): string {
+ if (!status) return "DISCONNECTED";
+ const s = status.status?.toUpperCase();
+ if (s === "CONNECTED") return "CONNECTED";
+ if (s === "CONNECTING" || s === "VERIFYING") return "CONNECTING";
+ if (s === "FAILED") return "ERROR";
+ if (s === "RETRYING" || s === "WAITING") return "WAITING";
+ if (s === "DISCONNECTING") return "DISCONNECTED";
+ return "DISCONNECTED";
+}
+
+function TunnelCard({
+ host,
+ index,
+ tunnel,
+ status,
+ isActing,
+ onAction,
+}: {
+ host: SSHHost;
+ index: number;
+ tunnel: TunnelConnection;
+ status: TunnelStatus | undefined;
+ isActing: boolean;
+ onAction: (action: "connect" | "disconnect" | "cancel") => void;
+}) {
+ const { t } = useTranslation();
+ const [showSettings, setShowSettings] = useState(false);
+ const label = statusLabel(status);
+ const isConnected = label === "CONNECTED";
+ const isConnecting = label === "CONNECTING";
+ const isError = label === "ERROR";
+ const isWaiting = label === "WAITING";
+
+ let statusColor = "text-muted-foreground border-border bg-muted/30";
+ if (isConnected)
+ statusColor = "text-accent-brand border-accent-brand/40 bg-accent-brand/10";
+ if (isConnecting)
+ statusColor = "text-blue-400 border-blue-400/40 bg-blue-400/10";
+ if (isError)
+ statusColor = "text-destructive border-destructive/40 bg-destructive/10";
+ if (isWaiting)
+ statusColor = "text-yellow-500 border-yellow-500/40 bg-yellow-500/10";
+
+ const mode = tunnel.mode ?? (tunnel.tunnelType as string) ?? "local";
+ const destination =
+ mode === "dynamic"
+ ? "SOCKS5 Proxy"
+ : `${tunnel.endpointHost ?? ""}:${tunnel.endpointPort}`;
+
+ return (
+ <Card className="flex flex-col overflow-hidden p-0 gap-0">
+ <div className="flex items-center justify-between px-4 py-2.5 border-b border-border bg-muted/10">
+ <div className="flex items-center gap-2">
+ <Network className="size-3.5 text-muted-foreground" />
+ <span className="text-xs font-bold uppercase tracking-widest text-muted-foreground">
+ {t("tunnels.port")} {tunnel.sourcePort}
+ </span>
+ </div>
+ <div
+ className={`flex items-center gap-1.5 px-2 py-0.5 border text-[10px] font-bold ${statusColor}`}
+ >
+ {isConnecting || isActing ? (
+ <RefreshCw className="size-3 animate-spin" />
+ ) : isConnected ? (
+ <Wifi className="size-3" />
+ ) : isError ? (
+ <AlertCircle className="size-3" />
+ ) : isWaiting ? (
+ <Clock className="size-3" />
+ ) : (
+ <WifiOff className="size-3" />
+ )}
+ {isActing ? t("tunnels.working") : label}
+ </div>
+ </div>
+ <div className="px-4 py-4 flex flex-col gap-3">
+ <div className="flex flex-col gap-1">
+ <span className="text-[10px] text-muted-foreground uppercase font-bold tracking-wider">
+ {t("tunnels.destination")}
+ </span>
+ <span
+ className="text-sm font-mono font-semibold truncate"
+ title={destination}
+ >
+ {destination}
+ </span>
+ <div className="flex items-center gap-1.5 mt-1">
+ <span className="text-[10px] font-semibold px-1.5 py-px border border-border text-muted-foreground uppercase">
+ {mode}
+ </span>
+ <span className="text-[10px] text-muted-foreground">
+ → localhost:{tunnel.sourcePort}
+ </span>
+ </div>
+ </div>
+
+ {isError && status?.reason && (
+ <div className="flex items-start gap-2 p-2 bg-destructive/5 border border-destructive/20 text-destructive text-[10px]">
+ <AlertCircle className="size-3 mt-0.5 shrink-0" />
+ <span>{status.reason}</span>
+ </div>
+ )}
+
+ {showSettings && (
+ <div className="border border-border bg-muted/20 p-3 flex flex-col gap-2 text-xs">
+ <div className="flex justify-between items-center">
+ <span className="text-muted-foreground font-semibold">
+ {t("tunnels.host")}
+ </span>
+ <span className="font-mono">
+ {host.name || `${host.username}@${host.ip}`}
+ </span>
+ </div>
+ <div className="flex justify-between items-center">
+ <span className="text-muted-foreground font-semibold">
+ {t("tunnels.mode")}
+ </span>
+ <span className="uppercase font-bold">{mode}</span>
+ </div>
+ <div className="flex justify-between items-center">
+ <span className="text-muted-foreground font-semibold">
+ {t("tunnels.localPort")}
+ </span>
+ <span className="font-mono">{tunnel.sourcePort}</span>
+ </div>
+ {mode !== "dynamic" && (
+ <>
+ <div className="flex justify-between items-center">
+ <span className="text-muted-foreground font-semibold">
+ {t("tunnels.remoteHost")}
+ </span>
+ <span className="font-mono">{tunnel.endpointHost}</span>
+ </div>
+ <div className="flex justify-between items-center">
+ <span className="text-muted-foreground font-semibold">
+ {t("tunnels.remotePort")}
+ </span>
+ <span className="font-mono">{tunnel.endpointPort}</span>
+ </div>
+ </>
+ )}
+ <div className="flex justify-between items-center">
+ <span className="text-muted-foreground font-semibold">
+ {t("tunnels.maxRetries")}
+ </span>
+ <span className="font-mono">{tunnel.maxRetries}</span>
+ </div>
+ </div>
+ )}
+
+ <div className="flex gap-2 mt-1">
+ {isConnected ? (
+ <Button
+ variant="outline"
+ size="sm"
+ className="flex-1 h-8 text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive gap-1.5"
+ disabled={isActing}
+ onClick={() => onAction("disconnect")}
+ >
+ <Square className="size-3" />
+ {t("tunnels.stop")}
+ </Button>
+ ) : isConnecting || isWaiting ? (
+ <Button
+ variant="outline"
+ size="sm"
+ className="flex-1 h-8 text-yellow-500 border-yellow-500/40 hover:bg-yellow-500/10 hover:text-yellow-500 gap-1.5"
+ disabled={isActing}
+ onClick={() => onAction("cancel")}
+ >
+ <Square className="size-3" />
+ {t("tunnels.cancel")}
+ </Button>
+ ) : (
+ <Button
+ variant="outline"
+ size="sm"
+ className="flex-1 h-8 text-accent-brand border-accent-brand/40 hover:bg-accent-brand/10 hover:text-accent-brand gap-1.5"
+ disabled={isActing}
+ onClick={() => onAction("connect")}
+ >
+ {isActing ? (
+ <RefreshCw className="size-3 animate-spin" />
+ ) : (
+ <Play className="size-3" />
+ )}
+ {t("tunnels.start")}
+ </Button>
+ )}
+ <Button
+ variant={showSettings ? "secondary" : "ghost"}
+ size="icon"
+ className={`h-8 w-8 ${showSettings ? "bg-accent-brand/10 text-accent-brand" : "text-muted-foreground hover:text-foreground"}`}
+ onClick={() => setShowSettings((s) => !s)}
+ >
+ <Settings className="size-3.5" />
+ </Button>
+ </div>
+ </div>
+ </Card>
+ );
+}
+
+export function TunnelTab({ host }: { label: string; host?: DemoHost }) {
+ const { t } = useTranslation();
+ const [sshHost, setSshHost] = useState<SSHHost | null>(null);
+ const [tunnelStatuses, setTunnelStatuses] = useState<
+ Record<string, TunnelStatus>
+ >({});
+ const [tunnelActions, setTunnelActions] = useState<Record<string, boolean>>(
+ {},
+ );
+ const activityLoggedRef = React.useRef(false);
+
+ const fetchHost = useCallback(async () => {
+ if (!host) return;
+ try {
+ const hosts = await getSSHHosts();
+ const found = hosts.find(
+ (h) => String(h.id) === host.id || h.name === host.name,
+ );
+ if (found) setSshHost(found);
+ } catch {
+ /* ignore */
+ }
+ }, [host?.id]);
+
+ useEffect(() => {
+ fetchHost();
+ const interval = setInterval(fetchHost, 5000);
+ window.addEventListener("ssh-hosts:changed", fetchHost);
+ return () => {
+ clearInterval(interval);
+ window.removeEventListener("ssh-hosts:changed", fetchHost);
+ };
+ }, [fetchHost]);
+
+ useEffect(() => {
+ return subscribeTunnelStatuses(setTunnelStatuses, () => {});
+ }, []);
+
+ useEffect(() => {
+ if (!sshHost || activityLoggedRef.current) return;
+ activityLoggedRef.current = true;
+ const name = sshHost.name || `${sshHost.username}@${sshHost.ip}`;
+ logActivity("tunnel", sshHost.id, name).catch(() => {
+ activityLoggedRef.current = false;
+ });
+ }, [sshHost?.id]);
+
+ const handleAction = async (
+ action: "connect" | "disconnect" | "cancel",
+ index: number,
+ ) => {
+ if (!sshHost) return;
+ const tunnel = sshHost.tunnelConnections[index];
+ if (!tunnel) return;
+ const name = tunnelName(sshHost, index, tunnel);
+
+ setTunnelActions((prev) => ({ ...prev, [name]: true }));
+ try {
+ if (action === "connect") {
+ const allHosts = await getSSHHosts();
+ const endpointSsh = allHosts.find(
+ (h) =>
+ h.name === tunnel.endpointHost ||
+ `${h.username}@${h.ip}` === tunnel.endpointHost,
+ );
+ await connectTunnel({
+ name,
+ scope: tunnel.scope ?? "s2s",
+ mode:
+ tunnel.mode ??
+ (tunnel.tunnelType as "local" | "remote" | "dynamic") ??
+ "remote",
+ tunnelType:
+ tunnel.tunnelType ??
+ (tunnel.mode === "local" || tunnel.mode === "remote"
+ ? tunnel.mode
+ : "remote"),
+ bindHost: tunnel.bindHost,
+ targetHost: tunnel.targetHost,
+ sourceHostId: sshHost.id,
+ tunnelIndex: index,
+ hostName: sshHost.name || `${sshHost.username}@${sshHost.ip}`,
+ sourceIP: sshHost.ip,
+ sourceSSHPort: sshHost.port,
+ sourceUsername: sshHost.username,
+ sourcePassword:
+ sshHost.authType === "password" ? sshHost.password : undefined,
+ sourceAuthMethod: sshHost.authType,
+ sourceSSHKey: sshHost.authType === "key" ? sshHost.key : undefined,
+ sourceKeyPassword:
+ sshHost.authType === "key" ? sshHost.keyPassword : undefined,
+ sourceKeyType:
+ sshHost.authType === "key" ? sshHost.keyType : undefined,
+ sourceCredentialId: sshHost.credentialId,
+ endpointHost: tunnel.endpointHost ?? "",
+ endpointIP: endpointSsh?.ip ?? tunnel.endpointHost ?? "",
+ endpointSSHPort: endpointSsh?.port ?? 22,
+ endpointUsername: endpointSsh?.username ?? "",
+ endpointPassword:
+ endpointSsh?.authType === "password"
+ ? endpointSsh.password
+ : undefined,
+ endpointAuthMethod: endpointSsh?.authType ?? "password",
+ endpointSSHKey:
+ endpointSsh?.authType === "key" ? endpointSsh.key : undefined,
+ endpointKeyPassword:
+ endpointSsh?.authType === "key"
+ ? endpointSsh.keyPassword
+ : undefined,
+ endpointKeyType:
+ endpointSsh?.authType === "key" ? endpointSsh.keyType : undefined,
+ endpointCredentialId: endpointSsh?.credentialId,
+ sourcePort: tunnel.sourcePort,
+ endpointPort: tunnel.endpointPort,
+ maxRetries: tunnel.maxRetries,
+ retryInterval: tunnel.retryInterval * 1000,
+ autoStart: tunnel.autoStart,
+ isPinned: sshHost.pin,
+ useSocks5: sshHost.useSocks5,
+ socks5Host: sshHost.socks5Host,
+ socks5Port: sshHost.socks5Port,
+ socks5Username: sshHost.socks5Username,
+ socks5Password: sshHost.socks5Password,
+ });
+ toast.success(t("tunnels.clientTunnelStarted"));
+ } else if (action === "disconnect") {
+ await disconnectTunnel(name);
+ toast.info(t("tunnels.clientTunnelStopped"));
+ } else {
+ await cancelTunnel(name);
+ toast.info(t("tunnels.canceling"));
+ }
+ } catch (err) {
+ toast.error(t("tunnels.manualControlError"));
+ console.error("Tunnel action failed:", err);
+ } finally {
+ setTunnelActions((prev) => ({ ...prev, [name]: false }));
+ }
+ };
+
+ if (!host) {
+ return (
+ <div className="flex flex-col items-center justify-center flex-1 gap-3 p-6 text-center">
+ <div className="size-10 rounded-full bg-muted/40 flex items-center justify-center">
+ <Network className="size-5 text-muted-foreground/30" />
+ </div>
+ <span className="text-sm font-semibold text-muted-foreground/60">
+ {t("tunnels.noHostSelected")}
+ </span>
+ </div>
+ );
+ }
+
+ const tunnels = sshHost?.tunnelConnections ?? [];
+ const connectedCount = tunnels.filter((t, i) => {
+ if (!sshHost) return false;
+ const name = tunnelName(sshHost, i, t);
+ return tunnelStatuses[name]?.connected;
+ }).length;
+
+ return (
+ <div className="flex flex-col flex-1 min-h-0 overflow-hidden">
+ <div className="flex-1 overflow-y-auto px-3 py-3 flex flex-col gap-3">
+ <Card className="flex-row items-center justify-between px-3 py-3 shrink-0 gap-0">
+ <div className="flex items-center gap-3">
+ <div className="size-10 border border-border bg-muted flex items-center justify-center shrink-0">
+ <Network className="size-5 text-accent-brand" />
+ </div>
+ <div>
+ <h1 className="text-2xl font-bold">{host.name}</h1>
+ <div className="flex items-center gap-2">
+ <span className="size-2 rounded-full bg-accent-brand" />
+ <span className="text-xs text-muted-foreground uppercase tracking-widest font-semibold">
+ {connectedCount}/{tunnels.length} {t("tunnels.active")}
+ </span>
+ </div>
+ </div>
+ </div>
+ <div className="flex items-center gap-0">
+ <Separator orientation="vertical" className="h-8 mx-3" />
+ <Button variant="ghost" size="icon">
+ <Settings className="size-4 text-accent-brand" />
+ </Button>
+ </div>
+ </Card>
+
+ {tunnels.length > 0 ? (
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3">
+ {tunnels.map((tunnel, index) => {
+ if (!sshHost) return null;
+ const name = tunnelName(sshHost, index, tunnel);
+ return (
+ <TunnelCard
+ key={name}
+ host={sshHost}
+ index={index}
+ tunnel={tunnel}
+ status={tunnelStatuses[name]}
+ isActing={tunnelActions[name] ?? false}
+ onAction={(action) => handleAction(action, index)}
+ />
+ );
+ })}
+ </div>
+ ) : (
+ <div className="flex flex-col items-center justify-center h-full gap-4 py-20">
+ <div className="opacity-10 flex flex-col items-center gap-4">
+ <Network className="size-16" />
+ <span className="text-xl font-bold uppercase tracking-widest">
+ {t("tunnels.noSshTunnels")}
+ </span>
+ </div>
+ <p className="text-sm text-muted-foreground text-center max-w-sm">
+ {t("tunnels.createFirstTunnelMessage")}
+ </p>
+ </div>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/src/ui/desktop/apps/features/tunnel/TunnelViewer.tsx b/src/ui/features/tunnel/TunnelViewer.tsx
similarity index 96%
rename from src/ui/desktop/apps/features/tunnel/TunnelViewer.tsx
rename to src/ui/features/tunnel/TunnelViewer.tsx
index f63324b95..86e2d1d8c 100644
--- a/src/ui/desktop/apps/features/tunnel/TunnelViewer.tsx
+++ b/src/ui/features/tunnel/TunnelViewer.tsx
@@ -1,7 +1,7 @@
import React from "react";
import { TunnelObject } from "./TunnelObject.tsx";
import { useTranslation } from "react-i18next";
-import type { SSHHost, TunnelStatus } from "../../../types/index.js";
+import type { SSHHost, TunnelStatus } from "@/types/index";
interface SSHTunnelViewerProps {
hosts: SSHHost[];
diff --git a/src/ui/desktop/apps/features/tunnel/tunnel-form-utils.ts b/src/ui/features/tunnel/tunnel-form-utils.ts
similarity index 100%
rename from src/ui/desktop/apps/features/tunnel/tunnel-form-utils.ts
rename to src/ui/features/tunnel/tunnel-form-utils.ts
diff --git a/src/hooks/use-confirmation.ts b/src/ui/hooks/use-confirmation.ts
similarity index 100%
rename from src/hooks/use-confirmation.ts
rename to src/ui/hooks/use-confirmation.ts
diff --git a/src/hooks/use-mobile.ts b/src/ui/hooks/use-mobile.ts
similarity index 71%
rename from src/hooks/use-mobile.ts
rename to src/ui/hooks/use-mobile.ts
index ae226bd0c..a93d58393 100644
--- a/src/hooks/use-mobile.ts
+++ b/src/ui/hooks/use-mobile.ts
@@ -3,9 +3,8 @@ import * as React from "react";
const MOBILE_BREAKPOINT = 768;
export function useIsMobile() {
- const [isMobile, setIsMobile] = React.useState<boolean>(
- () =>
- typeof window !== "undefined" && window.innerWidth < MOBILE_BREAKPOINT,
+ const [isMobile, setIsMobile] = React.useState<boolean | undefined>(
+ undefined,
);
React.useEffect(() => {
@@ -14,8 +13,9 @@ export function useIsMobile() {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
};
mql.addEventListener("change", onChange);
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
return () => mql.removeEventListener("change", onChange);
}, []);
- return isMobile;
+ return !!isMobile;
}
diff --git a/src/hooks/use-service-worker.ts b/src/ui/hooks/use-service-worker.ts
similarity index 100%
rename from src/hooks/use-service-worker.ts
rename to src/ui/hooks/use-service-worker.ts
diff --git a/src/i18n/i18n.ts b/src/ui/i18n/i18n.ts
similarity index 100%
rename from src/i18n/i18n.ts
rename to src/ui/i18n/i18n.ts
diff --git a/src/ui/index.css b/src/ui/index.css
new file mode 100644
index 000000000..c2ae92d3f
--- /dev/null
+++ b/src/ui/index.css
@@ -0,0 +1,480 @@
+@import "tailwindcss";
+@import "tw-animate-css";
+@import "shadcn/tailwind.css";
+@import "@fontsource-variable/jetbrains-mono";
+
+@custom-variant dark (&:is(.dark *));
+@custom-variant dracula (&:is(.dracula *));
+@custom-variant catppuccin (&:is(.catppuccin *));
+@custom-variant nord (&:is(.nord *));
+@custom-variant solarized (&:is(.solarized *));
+@custom-variant tokyo-night (&:is(.tokyo-night *));
+@custom-variant one-dark (&:is(.one-dark *));
+@custom-variant gruvbox (&:is(.gruvbox *));
+
+@theme inline {
+ --font-heading: var(--font-mono);
+ --font-mono: "JetBrains Mono Variable", monospace;
+ --color-accent-brand: var(--accent-brand);
+ --color-sidebar-ring: var(--sidebar-ring);
+ --color-sidebar-border: var(--sidebar-border);
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
+ --color-sidebar-accent: var(--sidebar-accent);
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
+ --color-sidebar-primary: var(--sidebar-primary);
+ --color-sidebar-foreground: var(--sidebar-foreground);
+ --color-sidebar: var(--sidebar);
+ --color-chart-5: var(--chart-5);
+ --color-chart-4: var(--chart-4);
+ --color-chart-3: var(--chart-3);
+ --color-chart-2: var(--chart-2);
+ --color-chart-1: var(--chart-1);
+ --color-ring: var(--ring);
+ --color-input: var(--input);
+ --color-border: var(--border);
+ --color-destructive: var(--destructive);
+ --color-accent-foreground: var(--accent-foreground);
+ --color-accent: var(--accent);
+ --color-muted-foreground: var(--muted-foreground);
+ --color-muted: var(--muted);
+ --color-secondary-foreground: var(--secondary-foreground);
+ --color-secondary: var(--secondary);
+ --color-primary-foreground: var(--primary-foreground);
+ --color-primary: var(--primary);
+ --color-popover-foreground: var(--popover-foreground);
+ --color-popover: var(--popover);
+ --color-card-foreground: var(--card-foreground);
+ --color-card: var(--card);
+ --color-foreground: var(--foreground);
+ --color-background: var(--background);
+ --color-surface: var(--surface);
+ --color-surface-dim: var(--surface-dim);
+ --radius-sm: calc(var(--radius) * 0.6);
+ --radius-md: calc(var(--radius) * 0.8);
+ --radius-lg: var(--radius);
+ --radius-xl: calc(var(--radius) * 1.4);
+ --radius-2xl: calc(var(--radius) * 1.8);
+ --radius-3xl: calc(var(--radius) * 2.2);
+ --radius-4xl: calc(var(--radius) * 2.6);
+}
+
+:root {
+ --accent-brand: #f59145;
+ --background: oklch(1 0 0);
+ --foreground: oklch(0.1802 0.0043 128.73);
+ --card: oklch(1 0 0);
+ --card-foreground: oklch(0.1802 0.0043 128.73);
+ --popover: oklch(1 0 0);
+ --popover-foreground: oklch(0.1802 0.0043 128.73);
+ --primary: oklch(0.2115 0.0042 128.68);
+ --primary-foreground: oklch(0.985 0 0);
+ --secondary: oklch(0.97 0 0);
+ --secondary-foreground: oklch(0.2115 0.0042 128.68);
+ --muted: oklch(0.97 0 0);
+ --muted-foreground: oklch(0.556 0 0);
+ --accent: oklch(0.97 0 0);
+ --accent-foreground: oklch(0.2115 0.0042 128.68);
+ --destructive: oklch(0.577 0.245 27.325);
+ --border: oklch(0.922 0 0);
+ --input: oklch(0.922 0 0);
+ --ring: oklch(0.708 0 0);
+ --chart-1: oklch(0.87 0 0);
+ --chart-2: oklch(0.556 0 0);
+ --chart-3: oklch(0.439 0 0);
+ --chart-4: oklch(0.371 0 0);
+ --chart-5: oklch(0.269 0 0);
+ --radius: 0.625rem;
+ --surface: oklch(0.97 0 0);
+ --sidebar: oklch(0.985 0 0);
+ --sidebar-foreground: oklch(0.1802 0.0043 128.73);
+ --sidebar-primary: oklch(0.2115 0.0042 128.68);
+ --sidebar-primary-foreground: oklch(0.985 0 0);
+ --sidebar-accent: oklch(0.97 0 0);
+ --sidebar-accent-foreground: oklch(0.2115 0.0042 128.68);
+ --sidebar-border: oklch(0.922 0 0);
+ --sidebar-ring: oklch(0.708 0 0);
+}
+
+.dark {
+ --background: oklch(0.155 0.004 128.73);
+ --foreground: oklch(0.985 0 0);
+ --card: oklch(0.21 0.004 128.68);
+ --card-foreground: oklch(0.985 0 0);
+ --popover: oklch(0.21 0.004 128.68);
+ --popover-foreground: oklch(0.985 0 0);
+ --primary: oklch(0.922 0 0);
+ --primary-foreground: oklch(0.2115 0.0042 128.68);
+ --secondary: oklch(0.269 0 0);
+ --secondary-foreground: oklch(0.985 0 0);
+ --surface: oklch(0.185 0.004 128.73);
+ --surface-dim: oklch(0.165 0.003 128.73);
+ --muted: oklch(0.255 0 0);
+ --muted-foreground: oklch(0.72 0 0);
+ --accent: oklch(0.255 0 0);
+ --accent-foreground: oklch(0.985 0 0);
+ --destructive: oklch(0.704 0.191 22.216);
+ --border: oklch(1 0 0 / 12%);
+ --input: oklch(1 0 0 / 15%);
+ --ring: oklch(0.556 0 0);
+ --chart-1: oklch(0.87 0 0);
+ --chart-2: oklch(0.556 0 0);
+ --chart-3: oklch(0.439 0 0);
+ --chart-4: oklch(0.371 0 0);
+ --chart-5: oklch(0.269 0 0);
+ --sidebar: oklch(0.195 0.004 128.68);
+ --sidebar-foreground: oklch(0.985 0 0);
+ --sidebar-primary: oklch(0.488 0.243 264.376);
+ --sidebar-primary-foreground: oklch(0.985 0 0);
+ --sidebar-accent: oklch(0.255 0 0);
+ --sidebar-accent-foreground: oklch(0.985 0 0);
+ --sidebar-border: oklch(1 0 0 / 12%);
+ --sidebar-ring: oklch(0.556 0 0);
+}
+
+/* ── Dracula ────────────────────────────────────────────────── */
+.dracula {
+ --background: #282a36;
+ --foreground: #f8f8f2;
+ --card: #21222c;
+ --card-foreground: #f8f8f2;
+ --popover: #21222c;
+ --popover-foreground: #f8f8f2;
+ --primary: #f8f8f2;
+ --primary-foreground: #282a36;
+ --secondary: #44475a;
+ --secondary-foreground: #f8f8f2;
+ --surface: #21222c;
+ --surface-dim: #191a21;
+ --muted: #44475a;
+ --muted-foreground: #6272a4;
+ --accent: #44475a;
+ --accent-foreground: #f8f8f2;
+ --destructive: #ff5555;
+ --border: rgba(98, 114, 164, 0.25);
+ --input: rgba(98, 114, 164, 0.2);
+ --ring: #6272a4;
+ --chart-1: #ff79c6;
+ --chart-2: #8be9fd;
+ --chart-3: #50fa7b;
+ --chart-4: #ffb86c;
+ --chart-5: #bd93f9;
+ --radius: 0.625rem;
+ --sidebar: #21222c;
+ --sidebar-foreground: #f8f8f2;
+ --sidebar-primary: #bd93f9;
+ --sidebar-primary-foreground: #282a36;
+ --sidebar-accent: #44475a;
+ --sidebar-accent-foreground: #f8f8f2;
+ --sidebar-border: rgba(98, 114, 164, 0.25);
+ --sidebar-ring: #6272a4;
+}
+
+/* ── Catppuccin Mocha ───────────────────────────────────────── */
+.catppuccin {
+ --background: #1e1e2e;
+ --foreground: #cdd6f4;
+ --card: #181825;
+ --card-foreground: #cdd6f4;
+ --popover: #181825;
+ --popover-foreground: #cdd6f4;
+ --primary: #cdd6f4;
+ --primary-foreground: #1e1e2e;
+ --secondary: #313244;
+ --secondary-foreground: #cdd6f4;
+ --surface: #181825;
+ --surface-dim: #11111b;
+ --muted: #313244;
+ --muted-foreground: #6c7086;
+ --accent: #313244;
+ --accent-foreground: #cdd6f4;
+ --destructive: #f38ba8;
+ --border: rgba(108, 112, 134, 0.25);
+ --input: rgba(108, 112, 134, 0.2);
+ --ring: #6c7086;
+ --chart-1: #f38ba8;
+ --chart-2: #89dceb;
+ --chart-3: #a6e3a1;
+ --chart-4: #fab387;
+ --chart-5: #cba6f7;
+ --radius: 0.625rem;
+ --sidebar: #181825;
+ --sidebar-foreground: #cdd6f4;
+ --sidebar-primary: #cba6f7;
+ --sidebar-primary-foreground: #1e1e2e;
+ --sidebar-accent: #313244;
+ --sidebar-accent-foreground: #cdd6f4;
+ --sidebar-border: rgba(108, 112, 134, 0.25);
+ --sidebar-ring: #6c7086;
+}
+
+/* ── Nord ───────────────────────────────────────────────────── */
+.nord {
+ --background: #2e3440;
+ --foreground: #eceff4;
+ --card: #272c36;
+ --card-foreground: #eceff4;
+ --popover: #272c36;
+ --popover-foreground: #eceff4;
+ --primary: #eceff4;
+ --primary-foreground: #2e3440;
+ --secondary: #3b4252;
+ --secondary-foreground: #eceff4;
+ --surface: #272c36;
+ --surface-dim: #22262e;
+ --muted: #3b4252;
+ --muted-foreground: #4c566a;
+ --accent: #3b4252;
+ --accent-foreground: #eceff4;
+ --destructive: #bf616a;
+ --border: rgba(76, 86, 106, 0.35);
+ --input: rgba(76, 86, 106, 0.3);
+ --ring: #4c566a;
+ --chart-1: #bf616a;
+ --chart-2: #88c0d0;
+ --chart-3: #a3be8c;
+ --chart-4: #ebcb8b;
+ --chart-5: #b48ead;
+ --radius: 0.625rem;
+ --sidebar: #272c36;
+ --sidebar-foreground: #eceff4;
+ --sidebar-primary: #88c0d0;
+ --sidebar-primary-foreground: #2e3440;
+ --sidebar-accent: #3b4252;
+ --sidebar-accent-foreground: #eceff4;
+ --sidebar-border: rgba(76, 86, 106, 0.35);
+ --sidebar-ring: #4c566a;
+}
+
+/* ── Solarized Dark ─────────────────────────────────────────── */
+.solarized {
+ --background: #002b36;
+ --foreground: #839496;
+ --card: #073642;
+ --card-foreground: #93a1a1;
+ --popover: #073642;
+ --popover-foreground: #93a1a1;
+ --primary: #93a1a1;
+ --primary-foreground: #002b36;
+ --secondary: #073642;
+ --secondary-foreground: #839496;
+ --surface: #073642;
+ --surface-dim: #00212b;
+ --muted: #073642;
+ --muted-foreground: #586e75;
+ --accent: #073642;
+ --accent-foreground: #93a1a1;
+ --destructive: #dc322f;
+ --border: rgba(88, 110, 117, 0.3);
+ --input: rgba(88, 110, 117, 0.25);
+ --ring: #586e75;
+ --chart-1: #dc322f;
+ --chart-2: #2aa198;
+ --chart-3: #859900;
+ --chart-4: #b58900;
+ --chart-5: #6c71c4;
+ --radius: 0.625rem;
+ --sidebar: #073642;
+ --sidebar-foreground: #93a1a1;
+ --sidebar-primary: #268bd2;
+ --sidebar-primary-foreground: #002b36;
+ --sidebar-accent: #073642;
+ --sidebar-accent-foreground: #93a1a1;
+ --sidebar-border: rgba(88, 110, 117, 0.3);
+ --sidebar-ring: #586e75;
+}
+
+/* ── Tokyo Night ────────────────────────────────────────────── */
+.tokyo-night {
+ --background: #1a1b26;
+ --foreground: #a9b1d6;
+ --card: #16161e;
+ --card-foreground: #a9b1d6;
+ --popover: #16161e;
+ --popover-foreground: #a9b1d6;
+ --primary: #a9b1d6;
+ --primary-foreground: #1a1b26;
+ --secondary: #24283b;
+ --secondary-foreground: #a9b1d6;
+ --surface: #16161e;
+ --surface-dim: #13131a;
+ --muted: #24283b;
+ --muted-foreground: #565f89;
+ --accent: #24283b;
+ --accent-foreground: #a9b1d6;
+ --destructive: #f7768e;
+ --border: rgba(86, 95, 137, 0.25);
+ --input: rgba(86, 95, 137, 0.2);
+ --ring: #565f89;
+ --chart-1: #f7768e;
+ --chart-2: #7dcfff;
+ --chart-3: #9ece6a;
+ --chart-4: #e0af68;
+ --chart-5: #bb9af7;
+ --radius: 0.625rem;
+ --sidebar: #16161e;
+ --sidebar-foreground: #a9b1d6;
+ --sidebar-primary: #7aa2f7;
+ --sidebar-primary-foreground: #1a1b26;
+ --sidebar-accent: #24283b;
+ --sidebar-accent-foreground: #a9b1d6;
+ --sidebar-border: rgba(86, 95, 137, 0.25);
+ --sidebar-ring: #565f89;
+}
+
+/* ── One Dark ───────────────────────────────────────────────── */
+.one-dark {
+ --background: #282c34;
+ --foreground: #abb2bf;
+ --card: #21252b;
+ --card-foreground: #abb2bf;
+ --popover: #21252b;
+ --popover-foreground: #abb2bf;
+ --primary: #abb2bf;
+ --primary-foreground: #282c34;
+ --secondary: #2c313a;
+ --secondary-foreground: #abb2bf;
+ --surface: #21252b;
+ --surface-dim: #1b1f23;
+ --muted: #2c313a;
+ --muted-foreground: #5c6370;
+ --accent: #2c313a;
+ --accent-foreground: #abb2bf;
+ --destructive: #e06c75;
+ --border: rgba(92, 99, 112, 0.25);
+ --input: rgba(92, 99, 112, 0.2);
+ --ring: #5c6370;
+ --chart-1: #e06c75;
+ --chart-2: #56b6c2;
+ --chart-3: #98c379;
+ --chart-4: #e5c07b;
+ --chart-5: #c678dd;
+ --radius: 0.625rem;
+ --sidebar: #21252b;
+ --sidebar-foreground: #abb2bf;
+ --sidebar-primary: #61afef;
+ --sidebar-primary-foreground: #282c34;
+ --sidebar-accent: #2c313a;
+ --sidebar-accent-foreground: #abb2bf;
+ --sidebar-border: rgba(92, 99, 112, 0.25);
+ --sidebar-ring: #5c6370;
+}
+
+/* ── Gruvbox Dark ───────────────────────────────────────────── */
+.gruvbox {
+ --background: #282828;
+ --foreground: #ebdbb2;
+ --card: #1d2021;
+ --card-foreground: #ebdbb2;
+ --popover: #1d2021;
+ --popover-foreground: #ebdbb2;
+ --primary: #ebdbb2;
+ --primary-foreground: #282828;
+ --secondary: #3c3836;
+ --secondary-foreground: #ebdbb2;
+ --surface: #1d2021;
+ --surface-dim: #181a1a;
+ --muted: #3c3836;
+ --muted-foreground: #928374;
+ --accent: #3c3836;
+ --accent-foreground: #ebdbb2;
+ --destructive: #cc241d;
+ --border: rgba(146, 131, 116, 0.2);
+ --input: rgba(146, 131, 116, 0.15);
+ --ring: #928374;
+ --chart-1: #cc241d;
+ --chart-2: #689d6a;
+ --chart-3: #98971a;
+ --chart-4: #d79921;
+ --chart-5: #b16286;
+ --radius: 0.625rem;
+ --sidebar: #1d2021;
+ --sidebar-foreground: #ebdbb2;
+ --sidebar-primary: #fabd2f;
+ --sidebar-primary-foreground: #282828;
+ --sidebar-accent: #3c3836;
+ --sidebar-accent-foreground: #ebdbb2;
+ --sidebar-border: rgba(146, 131, 116, 0.2);
+ --sidebar-ring: #928374;
+}
+
+@layer base {
+ * {
+ @apply outline-none;
+ scrollbar-width: thin;
+ scrollbar-color: oklch(1 0 0 / 20%) transparent;
+ }
+ *::-webkit-scrollbar {
+ width: 6px;
+ height: 6px;
+ }
+ *::-webkit-scrollbar-track {
+ background: transparent;
+ }
+ *::-webkit-scrollbar-thumb {
+ background: oklch(1 0 0 / 20%);
+ border-radius: 3px;
+ }
+ *::-webkit-scrollbar-thumb:hover {
+ background: oklch(1 0 0 / 35%);
+ }
+ *::-webkit-scrollbar-corner {
+ background: transparent;
+ }
+ html,
+ body,
+ #root {
+ height: 100dvh;
+ @apply overflow-hidden;
+ }
+ body {
+ @apply bg-background text-foreground font-mono;
+ }
+ html {
+ @apply font-mono;
+ }
+}
+
+/* Font size scale applied to html element */
+html.fs-xs {
+ font-size: 11px;
+}
+html.fs-sm {
+ font-size: 12px;
+}
+html.fs-md {
+ font-size: 14px;
+}
+html.fs-lg {
+ font-size: 16px;
+}
+html.fs-xl {
+ font-size: 18px;
+}
+
+@supports (padding-bottom: env(safe-area-inset-bottom)) {
+ .safe-bottom {
+ padding-bottom: env(safe-area-inset-bottom);
+ }
+}
+
+@utility scrollbar-none {
+ scrollbar-width: none;
+ &::-webkit-scrollbar {
+ display: none;
+ }
+}
+
+@utility thin-scrollbar {
+ scrollbar-width: thin;
+ scrollbar-color: oklch(1 0 0 / 15%) transparent;
+ &::-webkit-scrollbar {
+ width: 4px;
+ }
+ &::-webkit-scrollbar-track {
+ background: transparent;
+ }
+ &::-webkit-scrollbar-thumb {
+ background: oklch(1 0 0 / 15%);
+ border-radius: 2px;
+ }
+}
diff --git a/src/ui/contexts/ServerStatusContext.tsx b/src/ui/lib/ServerStatusContext.tsx
similarity index 98%
rename from src/ui/contexts/ServerStatusContext.tsx
rename to src/ui/lib/ServerStatusContext.tsx
index 3535f0dbc..6131730dd 100644
--- a/src/ui/contexts/ServerStatusContext.tsx
+++ b/src/ui/lib/ServerStatusContext.tsx
@@ -7,7 +7,7 @@ import React, {
useRef,
useMemo,
} from "react";
-import { getAllServerStatuses, getSSHHosts } from "@/ui/main-axios";
+import { getAllServerStatuses, getSSHHosts } from "@/main-axios";
import { DEFAULT_STATS_CONFIG } from "@/types/stats-widgets";
type StatusValue = "online" | "offline" | "degraded";
diff --git a/src/ui/desktop/navigation/animations/SimpleLoader.tsx b/src/ui/lib/SimpleLoader.tsx
similarity index 100%
rename from src/ui/desktop/navigation/animations/SimpleLoader.tsx
rename to src/ui/lib/SimpleLoader.tsx
diff --git a/src/lib/base-path.ts b/src/ui/lib/base-path.ts
similarity index 100%
rename from src/lib/base-path.ts
rename to src/ui/lib/base-path.ts
diff --git a/src/lib/client-cache-version.ts b/src/ui/lib/client-cache-version.ts
similarity index 100%
rename from src/lib/client-cache-version.ts
rename to src/ui/lib/client-cache-version.ts
diff --git a/src/lib/clipboard-provider.ts b/src/ui/lib/clipboard-provider.ts
similarity index 100%
rename from src/lib/clipboard-provider.ts
rename to src/ui/lib/clipboard-provider.ts
diff --git a/src/lib/db-health-monitor.ts b/src/ui/lib/db-health-monitor.ts
similarity index 100%
rename from src/lib/db-health-monitor.ts
rename to src/ui/lib/db-health-monitor.ts
diff --git a/src/lib/electron.ts b/src/ui/lib/electron.ts
similarity index 100%
rename from src/lib/electron.ts
rename to src/ui/lib/electron.ts
diff --git a/src/lib/frontend-logger.ts b/src/ui/lib/frontend-logger.ts
similarity index 100%
rename from src/lib/frontend-logger.ts
rename to src/ui/lib/frontend-logger.ts
diff --git a/src/ui/lib/splitDragging.ts b/src/ui/lib/splitDragging.ts
new file mode 100644
index 000000000..7fc969a6b
--- /dev/null
+++ b/src/ui/lib/splitDragging.ts
@@ -0,0 +1,15 @@
+// Module-level flag: true while a split pane divider is being dragged.
+// TerminalTab reads this to suppress fit() calls during drag.
+export const splitDragState = { active: false };
+
+// Callbacks registered by terminal instances to trigger a fit after drag ends.
+const fitCallbacks = new Set<() => void>();
+
+export function registerFitCallback(fn: () => void) {
+ fitCallbacks.add(fn);
+ return () => fitCallbacks.delete(fn);
+}
+
+export function notifyDragEnd() {
+ for (const fn of fitCallbacks) fn();
+}
diff --git a/src/lib/terminal-syntax-highlighter.ts b/src/ui/lib/terminal-syntax-highlighter.ts
similarity index 100%
rename from src/lib/terminal-syntax-highlighter.ts
rename to src/ui/lib/terminal-syntax-highlighter.ts
diff --git a/src/constants/terminal-themes.ts b/src/ui/lib/terminal-themes.ts
similarity index 99%
rename from src/constants/terminal-themes.ts
rename to src/ui/lib/terminal-themes.ts
index 348e074a8..7bfcdcfff 100644
--- a/src/constants/terminal-themes.ts
+++ b/src/ui/lib/terminal-themes.ts
@@ -32,10 +32,10 @@ export const TERMINAL_THEMES: Record<string, TerminalTheme> = {
name: "Termix Default",
category: "dark",
colors: {
- background: "#18181b",
+ background: "#0c0d0b",
foreground: "#f7f7f7",
- cursor: "#f7f7f7",
- cursorAccent: "#18181b",
+ cursor: "#fb923c",
+ cursorAccent: "#0c0d0b",
selectionBackground: "#3a3a3d",
black: "#2e3436",
red: "#cc0000",
@@ -60,10 +60,10 @@ export const TERMINAL_THEMES: Record<string, TerminalTheme> = {
name: "Termix Dark",
category: "dark",
colors: {
- background: "#18181b",
+ background: "#0c0d0b",
foreground: "#f7f7f7",
- cursor: "#f7f7f7",
- cursorAccent: "#18181b",
+ cursor: "#fb923c",
+ cursorAccent: "#0c0d0b",
selectionBackground: "#3a3a3d",
black: "#2e3436",
red: "#cc0000",
diff --git a/src/ui/lib/theme.ts b/src/ui/lib/theme.ts
new file mode 100644
index 000000000..1d4200fc8
--- /dev/null
+++ b/src/ui/lib/theme.ts
@@ -0,0 +1,123 @@
+import type {
+ AccentColorId,
+ DashboardCardConfig,
+ FontSizeId,
+ SplitMode,
+} from "./types";
+
+export const DASHBOARD_CARDS: DashboardCardConfig[] = [
+ {
+ id: "stats_bar",
+ label: "Status Bar",
+ description: "Version, uptime, database health, hosts online",
+ defaultEnabled: true,
+ },
+ {
+ id: "counters_bar",
+ label: "Counters Bar",
+ description: "Total hosts, credentials, and tunnels count",
+ defaultEnabled: true,
+ },
+ {
+ id: "quick_actions",
+ label: "Quick Actions",
+ description: "Shortcuts to add hosts, credentials, settings",
+ defaultEnabled: true,
+ },
+ {
+ id: "host_status",
+ label: "Host Status",
+ description: "Live status list with CPU/RAM per host",
+ defaultEnabled: true,
+ },
+ {
+ id: "recent_activity",
+ label: "Recent Activity",
+ description: "Feed of recent connection events",
+ defaultEnabled: true,
+ },
+ {
+ id: "network_graph",
+ label: "Network Graph",
+ description: "Visual map of host network topology",
+ defaultEnabled: false,
+ },
+];
+
+export const ACCENT_PRESET_COLORS = [
+ { label: "Orange", value: "#f59145" },
+ { label: "Blue", value: "#3b82f6" },
+ { label: "Green", value: "#22c55e" },
+ { label: "Purple", value: "#a855f7" },
+ { label: "Pink", value: "#ec4899" },
+ { label: "Cyan", value: "#06b6d4" },
+ { label: "Red", value: "#ef4444" },
+ { label: "Yellow", value: "#eab308" },
+ { label: "Teal", value: "#14b8a6" },
+ { label: "Indigo", value: "#6366f1" },
+ { label: "Rose", value: "#f43f5e" },
+ { label: "Lime", value: "#84cc16" },
+];
+
+export const ACCENT_COLORS = ACCENT_PRESET_COLORS.map((c) => ({
+ id: c.label.toLowerCase() as AccentColorId,
+ label: c.label,
+ value: c.value,
+}));
+
+export function applyAccentColor(colorValue: string) {
+ document.documentElement.style.setProperty("--accent-brand", colorValue);
+}
+
+export const FONT_SIZES: { id: FontSizeId; label: string }[] = [
+ { id: "xs", label: "XS" },
+ { id: "sm", label: "Small" },
+ { id: "md", label: "Normal" },
+ { id: "lg", label: "Large" },
+ { id: "xl", label: "XL" },
+];
+
+export function applyFontSize(id: FontSizeId) {
+ const root = document.documentElement;
+ root.classList.remove("fs-xs", "fs-sm", "fs-md", "fs-lg", "fs-xl");
+ root.classList.add(`fs-${id}`);
+ localStorage.setItem("termix-font-size", id);
+}
+
+export const FOLDER_COLORS = [
+ "#ef4444",
+ "#f97316",
+ "#eab308",
+ "#22c55e",
+ "#3b82f6",
+ "#a855f7",
+ "#ec4899",
+ "#6b7280",
+];
+
+export const SPLIT_MODES: { id: SplitMode; label: string }[] = [
+ { id: "none", label: "None" },
+ { id: "2-way", label: "2-Way" },
+ { id: "3-way", label: "3-Way" },
+ { id: "4-way", label: "4-Way" },
+ { id: "5-way", label: "5-Way" },
+ { id: "6-way", label: "6-Way" },
+];
+
+export const PANE_COUNTS: Record<SplitMode, number> = {
+ none: 0,
+ "2-way": 2,
+ "3-way": 3,
+ "4-way": 4,
+ "5-way": 5,
+ "6-way": 6,
+};
+
+export const PANE_LAYOUTS: Record<SplitMode, string> = {
+ none: "",
+ "2-way": "grid-cols-2 grid-rows-1",
+ "3-way": "grid-cols-2 grid-rows-2",
+ "4-way": "grid-cols-2 grid-rows-2",
+ "5-way": "grid-cols-3 grid-rows-2",
+ "6-way": "grid-cols-3 grid-rows-2",
+};
diff --git a/src/lib/utils.ts b/src/ui/lib/utils.ts
similarity index 100%
rename from src/lib/utils.ts
rename to src/ui/lib/utils.ts
diff --git a/src/locales/README.md b/src/ui/locales/README.md
similarity index 100%
rename from src/locales/README.md
rename to src/ui/locales/README.md
diff --git a/src/locales/en.json b/src/ui/locales/en.json
similarity index 94%
rename from src/locales/en.json
rename to src/ui/locales/en.json
index aa4b82e22..a6728d9d2 100644
--- a/src/locales/en.json
+++ b/src/ui/locales/en.json
@@ -332,6 +332,10 @@
"deleteSuccess": "Command deleted from history",
"deleteFailed": "Failed to delete command.",
"deleteTooltip": "Delete command",
+ "clearAll": "Clear all history",
+ "clearConfirm": "Clear all command history for this host?",
+ "clearSuccess": "Command history cleared",
+ "clearFailed": "Failed to clear command history",
"tabHint": "Use Tab in Terminal to autocomplete from command history if enabled in User Profile",
"authRequiredRefresh": "Authentication required. Please refresh the page.",
"dataAccessLockedReauth": "Data access locked. Please re-authenticate.",
@@ -1558,7 +1562,9 @@
"telnetConnecting": "Connecting to Telnet server...",
"connectionError": "Connection error",
"connectionFailed": "Connection failed",
- "failedToConnect": "Failed to get connection token"
+ "failedToConnect": "Failed to get connection token",
+ "hostNotFound": "Host not found",
+ "noHostSelected": "No host selected"
},
"terminal": {
"title": "Split Screen",
@@ -1612,6 +1618,7 @@
"messageParseError": "Failed to parse server message",
"websocketError": "WebSocket connection error",
"connecting": "Connecting...",
+ "noHostSelected": "No host selected",
"reconnecting": "Reconnecting... ({{attempt}}/{{max}})",
"reconnected": "Reconnected successfully",
"tmuxSessionCreated": "tmux session created: {{name}}",
@@ -1689,6 +1696,7 @@
},
"fileManager": {
"title": "File Manager",
+ "noHostSelected": "No host selected",
"file": "File",
"folder": "Folder",
"connectToSsh": "Connect to SSH to use file operations",
@@ -1984,21 +1992,6 @@
"warpgateVerificationFailed": "Warpgate authentication failed",
"authenticationFailed": "Authentication failed",
"verificationCodePrompt": "Verification code:",
- "newFolderDefault": "NewFolder",
- "newFileDefault": "NewFile.txt",
- "successfullyMovedItems": "Successfully moved {{count}} items to {{target}}",
- "move": "Move",
- "searchInFile": "Search in file (Ctrl+F)",
- "showKeyboardShortcuts": "Show keyboard shortcuts",
- "startWritingMarkdown": "Start writing your markdown content...",
- "loadingFileComparison": "Loading file comparison...",
- "reload": "Reload",
- "compare": "Compare",
- "sideBySide": "Side by Side",
- "inline": "Inline",
- "fileComparison": "File Comparison: {{file1}} vs {{file2}}",
- "fileTooLarge": "File too large: {{error}}",
- "connectedSuccessfully": "Connected successfully",
"changePermissions": "Change Permissions",
"changePermissionsDesc": "Modify file permissions for",
"currentPermissions": "Current Permissions",
@@ -2016,7 +2009,19 @@
"sortByDate": "Date Modified",
"sortBySize": "Size",
"ascending": "Ascending",
- "descending": "Descending"
+ "descending": "Descending",
+ "root": "Root",
+ "new": "New",
+ "sortBy": "Sort By",
+ "items": "Items",
+ "selected": "Selected",
+ "editor": "Editor",
+ "octal": "Octal",
+ "storage": "Storage",
+ "disk": "Disk",
+ "used": "Used",
+ "of": "of",
+ "toggleSidebar": "Toggle Sidebar"
},
"tunnels": {
"title": "SSH Tunnels",
@@ -2144,7 +2149,12 @@
"endpointHostNotFound": "Endpoint host not found",
"discord": "Discord",
"githubIssue": "GitHub issue",
- "forHelp": "for help"
+ "forHelp": "for help",
+ "destination": "Destination",
+ "host": "Host",
+ "mode": "Mode",
+ "noHostSelected": "No host selected",
+ "working": "Working..."
},
"serverStats": {
"title": "Server Statistics",
@@ -2253,7 +2263,14 @@
"drop": "DROP",
"reject": "REJECT",
"anywhere": "Anywhere"
- }
+ },
+ "loadAvg": "Load Avg",
+ "swap": "Swap",
+ "architecture": "Architecture",
+ "refresh": "Refresh",
+ "online": "Online",
+ "offline": "Offline",
+ "liveMetrics": "Live Metrics"
},
"auth": {
"tagline": "SSH SERVER MANAGER",
@@ -2506,6 +2523,10 @@
"themeDark": "Dark",
"themeSystem": "System",
"appearanceDesc": "Select the color theme for the application",
+ "accentColor": "Accent Color",
+ "customColor": "Custom:",
+ "fontSize": "Font Size",
+ "fontSizeDesc": "Adjust the base font size across the application",
"terminalSyntaxHighlightingDesc": "Automatically highlight commands, paths, IPs, and log levels in terminal output",
"enableCommandPaletteShortcut": "Enable Command Palette Shortcut",
"enableCommandPaletteShortcutDesc": "Double-tap left Shift to open the Command Palette for quick access to hosts",
@@ -2751,7 +2772,9 @@
"networkGraphCard": "Network Graph",
"networkGraph": "Network Graph",
"quickActionsCard": "Quick Actions",
- "serverStatsCard": "Server Stats"
+ "serverStatsCard": "Server Stats",
+ "panelMain": "Main",
+ "panelSide": "Side"
},
"networkGraph": {
"title": "Network Graph",
@@ -3020,10 +3043,6 @@
"errorCode": "Error code: {{code}}",
"version": "Docker {{version}}",
"connectionFailed": "Failed to connect to Docker",
- "totpVerificationFailed": "TOTP verification failed",
- "warpgateVerificationFailed": "Warpgate verification failed",
- "verificationCodePrompt": "Enter verification code",
- "loadingContainers": "Loading containers...",
"containerStarted": "Container {{name}} started",
"failedToStartContainer": "Failed to start container {{name}}",
"containerStopped": "Container {{name}} stopped",
@@ -3051,10 +3070,31 @@
"runningContainerWarning": "Warning: This container is currently running. Removing it will stop the container first.",
"removing": "Removing...",
"loadingContainers": "Loading containers...",
+ "manager": "Docker Manager",
+ "autoRefresh": "Auto Refresh",
+ "timestamps": "Timestamps",
+ "lines": "Lines",
+ "filterLogs": "Filter logs...",
+ "refresh": "Refresh",
+ "download": "Download",
+ "clear": "Clear",
+ "logsDownloaded": "Logs downloaded successfully",
+ "last50": "Last 50",
+ "last100": "Last 100",
+ "last500": "Last 500",
+ "last1000": "Last 1000",
+ "allLogs": "All Logs",
+ "noLogsMatching": "No logs matching \"{{query}}\"",
+ "noLogsAvailable": "No logs available",
"noContainersFound": "No containers found",
"noContainersFoundHint": "No Docker containers are available on this host",
"searchPlaceholder": "Search containers...",
"filterByStatusPlaceholder": "Filter by status",
+ "allStatuses": "All Statuses",
+ "stateRunning": "Running",
+ "statePaused": "Paused",
+ "stateExited": "Exited",
+ "stateRestarting": "Restarting",
"allContainersCount": "All ({{count}})",
"statusCount": "{{status}} ({{count}})",
"noContainersMatchFilters": "No containers match your filters",
@@ -3158,5 +3198,174 @@
"theme": {
"switchToLight": "Switch to Light",
"switchToDark": "Switch to Dark"
+ },
+ "newUi": {
+ "sidebar": {
+ "quickConnect": {
+ "hostLabel": "Host",
+ "hostPlaceholder": "192.168.1.1 or example.com",
+ "portLabel": "Port",
+ "portPlaceholder": "22",
+ "usernameLabel": "Username",
+ "usernamePlaceholder": "username",
+ "authLabel": "Auth",
+ "passwordLabel": "Password",
+ "passwordPlaceholder": "password",
+ "privateKeyLabel": "Private Key",
+ "privateKeyPlaceholder": "Paste private key...",
+ "credentialLabel": "Credential",
+ "credentialPlaceholder": "Select a saved credential",
+ "connectToTerminal": "Connect to Terminal",
+ "connectToFiles": "Connect to Files"
+ },
+ "history": {
+ "noTerminalSelected": "No terminal selected",
+ "noTerminalSelectedHint": "Open an SSH terminal tab to view its command history",
+ "searchPlaceholder": "Search history...",
+ "clearAll": "Clear All",
+ "noHistoryEntries": "No history entries"
+ },
+ "sshTools": {
+ "keyRecordingTitle": "Key Recording",
+ "recordToTerminals": "Record to terminals",
+ "selectAll": "All",
+ "selectNone": "None",
+ "noTerminalTabsOpen": "No terminal tabs open",
+ "selectTerminalsAbove": "Select terminals above",
+ "settingsTitle": "Settings",
+ "enableRightClickCopyPaste": "Enable right-click copy/paste"
+ },
+ "splitScreen": {
+ "layoutTitle": "Layout",
+ "selectLayoutAbove": "Select a layout above",
+ "selectLayoutHint": "Choose how many panes to display",
+ "panesTitle": "Panes",
+ "openTabsTitle": "Open Tabs",
+ "dragTabsHint": "Drag tabs into panes above",
+ "dropHere": "Drop here",
+ "emptyPane": "Empty",
+ "dashboard": "Dashboard",
+ "clearSplitScreen": "Clear Split Screen"
+ },
+ "snippets": {
+ "createSnippetTitle": "Create Snippet",
+ "createSnippetDescription": "Create a new command snippet for quick execution",
+ "nameLabel": "Name",
+ "namePlaceholder": "e.g., Restart Nginx",
+ "descriptionLabel": "Description",
+ "descriptionPlaceholder": "Optional description",
+ "optional": "Optional",
+ "folderLabel": "Folder",
+ "noFolder": "No folder (Uncategorized)",
+ "commandLabel": "Command",
+ "commandPlaceholder": "e.g., sudo systemctl restart nginx",
+ "cancel": "Cancel",
+ "createSnippetButton": "Create Snippet",
+ "createFolderTitle": "Create Folder",
+ "createFolderDescription": "Organize your snippets into folders",
+ "folderNameLabel": "Folder Name",
+ "folderNamePlaceholder": "e.g., System Commands, Docker Scripts",
+ "folderColorLabel": "Folder Color",
+ "folderIconLabel": "Folder Icon",
+ "previewLabel": "Preview",
+ "folderNameFallback": "Folder Name",
+ "createFolderButton": "Create Folder",
+ "targetTerminals": "Target Terminals",
+ "selectAll": "All",
+ "selectNone": "None",
+ "noTerminalTabsOpen": "No terminal tabs open",
+ "searchPlaceholder": "Search snippets...",
+ "newSnippet": "New Snippet",
+ "newFolder": "New Folder",
+ "run": "Run",
+ "noSnippetsInFolder": "No snippets in this folder"
+ },
+ "userProfile": {
+ "sectionAccount": "Account",
+ "sectionAppearance": "Appearance",
+ "sectionSecurity": "Security",
+ "sectionApiKeys": "API Keys",
+ "sectionC2sTunnels": "C2S Tunnels",
+ "usernameLabel": "Username",
+ "roleLabel": "Role",
+ "roleAdministrator": "Administrator",
+ "authMethodLabel": "Auth Method",
+ "authMethodLocal": "Local",
+ "twoFaLabel": "2FA",
+ "twoFaOn": "On",
+ "twoFaOff": "Off",
+ "versionLabel": "Version",
+ "versionStable": "stable",
+ "upToDate": "Up to date",
+ "deleteAccount": "Delete Account",
+ "deleteAccountDescription": "Permanently delete your account",
+ "deleteButton": "Delete",
+ "deleteAccountPermanent": "This action is permanent and cannot be undone.",
+ "deleteAccountWarning": "All sessions, hosts, credentials, and settings will be permanently deleted.",
+ "confirmPasswordDeletePlaceholder": "Enter your password to confirm",
+ "languageLabel": "Language",
+ "themeLabel": "Theme",
+ "fontSizeLabel": "Font Size",
+ "accentColorLabel": "Accent Color",
+ "settingsFileManager": "File Manager",
+ "fileColorCoding": "File Color Coding",
+ "fileColorCodingDesc": "Color-code files by type",
+ "settingsTerminal": "Terminal",
+ "commandAutocomplete": "Command Autocomplete",
+ "commandAutocompleteDesc": "Show autocomplete while typing",
+ "historyTracking": "History Tracking",
+ "historyTrackingDesc": "Track terminal commands",
+ "syntaxHighlighting": "Syntax Highlighting",
+ "syntaxHighlightingDesc": "Highlight terminal output",
+ "commandPalette": "Command Palette",
+ "commandPaletteDesc": "Enable keyboard shortcut",
+ "sessionPersistence": "Session Persistence",
+ "sessionPersistenceDesc": "Keep sessions between reconnects",
+ "settingsSidebar": "Sidebar",
+ "showHostTags": "Show Host Tags",
+ "showHostTagsDesc": "Display tags in host list",
+ "settingsSnippets": "Snippets",
+ "foldersCollapsed": "Folders Collapsed",
+ "foldersCollapsedDesc": "Collapse folders by default",
+ "confirmExecution": "Confirm Execution",
+ "confirmExecutionDesc": "Confirm before running snippets",
+ "settingsUpdates": "Updates",
+ "disableUpdateChecks": "Disable Update Checks",
+ "disableUpdateChecksDesc": "Stop checking for updates",
+ "totpAuthenticator": "TOTP Authenticator",
+ "totpEnabled": "2FA is enabled",
+ "totpDisabled": "Add extra login security",
+ "disable": "Disable",
+ "enable": "Enable",
+ "setupTotp": "Setup TOTP",
+ "qrCode": "QR Code",
+ "totpInstructions": "Scan QR code or enter secret in your authenticator app, then enter the 6-digit code",
+ "totpCodePlaceholder": "000000",
+ "verify": "Verify",
+ "changePassword": "Change Password",
+ "currentPasswordLabel": "Current Password",
+ "currentPasswordPlaceholder": "Current password",
+ "newPasswordLabel": "New Password",
+ "newPasswordPlaceholder": "New password",
+ "confirmPasswordLabel": "Confirm New Password",
+ "confirmPasswordPlaceholder": "Confirm new password",
+ "updatePassword": "Update Password",
+ "createApiKeyTitle": "Create API Key",
+ "createApiKeyDescription": "Generate a new API key for programmatic access.",
+ "apiKeyNameLabel": "Name",
+ "apiKeyNamePlaceholder": "e.g. CI Pipeline",
+ "expiryDateLabel": "Expiry Date",
+ "optional": "optional",
+ "cancel": "Cancel",
+ "createKey": "Create Key",
+ "apiKeyCount": "{{count}} keys",
+ "newKey": "New Key",
+ "noApiKeys": "No API keys yet.",
+ "apiKeyActive": "Active",
+ "apiKeyUsageHint": "Include your key in the",
+ "apiKeyUsageHintHeader": "header.",
+ "apiKeyPermissionsHint": "Keys inherit the permissions of the creating user."
+ }
+ }
}
}
diff --git a/src/locales/translated/af_ZA.json b/src/ui/locales/translated/af_ZA.json
similarity index 100%
rename from src/locales/translated/af_ZA.json
rename to src/ui/locales/translated/af_ZA.json
diff --git a/src/locales/translated/ar_SA.json b/src/ui/locales/translated/ar_SA.json
similarity index 100%
rename from src/locales/translated/ar_SA.json
rename to src/ui/locales/translated/ar_SA.json
diff --git a/src/locales/translated/bg_BG.json b/src/ui/locales/translated/bg_BG.json
similarity index 100%
rename from src/locales/translated/bg_BG.json
rename to src/ui/locales/translated/bg_BG.json
diff --git a/src/locales/translated/bn_BD.json b/src/ui/locales/translated/bn_BD.json
similarity index 100%
rename from src/locales/translated/bn_BD.json
rename to src/ui/locales/translated/bn_BD.json
diff --git a/src/locales/translated/ca_ES.json b/src/ui/locales/translated/ca_ES.json
similarity index 100%
rename from src/locales/translated/ca_ES.json
rename to src/ui/locales/translated/ca_ES.json
diff --git a/src/locales/translated/cs_CZ.json b/src/ui/locales/translated/cs_CZ.json
similarity index 100%
rename from src/locales/translated/cs_CZ.json
rename to src/ui/locales/translated/cs_CZ.json
diff --git a/src/locales/translated/da_DK.json b/src/ui/locales/translated/da_DK.json
similarity index 100%
rename from src/locales/translated/da_DK.json
rename to src/ui/locales/translated/da_DK.json
diff --git a/src/locales/translated/de_DE.json b/src/ui/locales/translated/de_DE.json
similarity index 100%
rename from src/locales/translated/de_DE.json
rename to src/ui/locales/translated/de_DE.json
diff --git a/src/locales/translated/el_GR.json b/src/ui/locales/translated/el_GR.json
similarity index 100%
rename from src/locales/translated/el_GR.json
rename to src/ui/locales/translated/el_GR.json
diff --git a/src/locales/translated/es_ES.json b/src/ui/locales/translated/es_ES.json
similarity index 100%
rename from src/locales/translated/es_ES.json
rename to src/ui/locales/translated/es_ES.json
diff --git a/src/locales/translated/fi_FI.json b/src/ui/locales/translated/fi_FI.json
similarity index 100%
rename from src/locales/translated/fi_FI.json
rename to src/ui/locales/translated/fi_FI.json
diff --git a/src/locales/translated/fr_FR.json b/src/ui/locales/translated/fr_FR.json
similarity index 100%
rename from src/locales/translated/fr_FR.json
rename to src/ui/locales/translated/fr_FR.json
diff --git a/src/locales/translated/he_IL.json b/src/ui/locales/translated/he_IL.json
similarity index 100%
rename from src/locales/translated/he_IL.json
rename to src/ui/locales/translated/he_IL.json
diff --git a/src/locales/translated/hi_IN.json b/src/ui/locales/translated/hi_IN.json
similarity index 100%
rename from src/locales/translated/hi_IN.json
rename to src/ui/locales/translated/hi_IN.json
diff --git a/src/locales/translated/hu_HU.json b/src/ui/locales/translated/hu_HU.json
similarity index 100%
rename from src/locales/translated/hu_HU.json
rename to src/ui/locales/translated/hu_HU.json
diff --git a/src/locales/translated/id_ID.json b/src/ui/locales/translated/id_ID.json
similarity index 100%
rename from src/locales/translated/id_ID.json
rename to src/ui/locales/translated/id_ID.json
diff --git a/src/locales/translated/it_IT.json b/src/ui/locales/translated/it_IT.json
similarity index 100%
rename from src/locales/translated/it_IT.json
rename to src/ui/locales/translated/it_IT.json
diff --git a/src/locales/translated/ja_JP.json b/src/ui/locales/translated/ja_JP.json
similarity index 100%
rename from src/locales/translated/ja_JP.json
rename to src/ui/locales/translated/ja_JP.json
diff --git a/src/locales/translated/ko_KR.json b/src/ui/locales/translated/ko_KR.json
similarity index 100%
rename from src/locales/translated/ko_KR.json
rename to src/ui/locales/translated/ko_KR.json
diff --git a/src/locales/translated/nl_NL.json b/src/ui/locales/translated/nl_NL.json
similarity index 100%
rename from src/locales/translated/nl_NL.json
rename to src/ui/locales/translated/nl_NL.json
diff --git a/src/locales/translated/no_NO.json b/src/ui/locales/translated/no_NO.json
similarity index 100%
rename from src/locales/translated/no_NO.json
rename to src/ui/locales/translated/no_NO.json
diff --git a/src/locales/translated/pl_PL.json b/src/ui/locales/translated/pl_PL.json
similarity index 100%
rename from src/locales/translated/pl_PL.json
rename to src/ui/locales/translated/pl_PL.json
diff --git a/src/locales/translated/pt_BR.json b/src/ui/locales/translated/pt_BR.json
similarity index 100%
rename from src/locales/translated/pt_BR.json
rename to src/ui/locales/translated/pt_BR.json
diff --git a/src/locales/translated/pt_PT.json b/src/ui/locales/translated/pt_PT.json
similarity index 100%
rename from src/locales/translated/pt_PT.json
rename to src/ui/locales/translated/pt_PT.json
diff --git a/src/locales/translated/ro_RO.json b/src/ui/locales/translated/ro_RO.json
similarity index 100%
rename from src/locales/translated/ro_RO.json
rename to src/ui/locales/translated/ro_RO.json
diff --git a/src/locales/translated/ru_RU.json b/src/ui/locales/translated/ru_RU.json
similarity index 100%
rename from src/locales/translated/ru_RU.json
rename to src/ui/locales/translated/ru_RU.json
diff --git a/src/locales/translated/sr_SP.json b/src/ui/locales/translated/sr_SP.json
similarity index 100%
rename from src/locales/translated/sr_SP.json
rename to src/ui/locales/translated/sr_SP.json
diff --git a/src/locales/translated/sv_SE.json b/src/ui/locales/translated/sv_SE.json
similarity index 100%
rename from src/locales/translated/sv_SE.json
rename to src/ui/locales/translated/sv_SE.json
diff --git a/src/locales/translated/th_TH.json b/src/ui/locales/translated/th_TH.json
similarity index 100%
rename from src/locales/translated/th_TH.json
rename to src/ui/locales/translated/th_TH.json
diff --git a/src/locales/translated/tr_TR.json b/src/ui/locales/translated/tr_TR.json
similarity index 100%
rename from src/locales/translated/tr_TR.json
rename to src/ui/locales/translated/tr_TR.json
diff --git a/src/locales/translated/uk_UA.json b/src/ui/locales/translated/uk_UA.json
similarity index 100%
rename from src/locales/translated/uk_UA.json
rename to src/ui/locales/translated/uk_UA.json
diff --git a/src/locales/translated/vi_VN.json b/src/ui/locales/translated/vi_VN.json
similarity index 100%
rename from src/locales/translated/vi_VN.json
rename to src/ui/locales/translated/vi_VN.json
diff --git a/src/locales/translated/zh_CN.json b/src/ui/locales/translated/zh_CN.json
similarity index 100%
rename from src/locales/translated/zh_CN.json
rename to src/ui/locales/translated/zh_CN.json
diff --git a/src/locales/translated/zh_TW.json b/src/ui/locales/translated/zh_TW.json
similarity index 100%
rename from src/locales/translated/zh_TW.json
rename to src/ui/locales/translated/zh_TW.json
diff --git a/src/ui/main-axios.ts b/src/ui/main-axios.ts
index 2cd42b64b..04010ac8f 100644
--- a/src/ui/main-axios.ts
+++ b/src/ui/main-axios.ts
@@ -2,7 +2,7 @@ import axios, { AxiosError, type AxiosInstance } from "axios";
import { toast } from "sonner";
import { getBasePath } from "@/lib/base-path";
import { isElectron } from "@/lib/electron";
-import { clearTermixSessionStorage } from "@/ui/desktop/navigation/tabs/TabContext";
+import { clearTermixSessionStorage } from "@/shell/TabContext";
import type {
SSHHost,
SSHHostData,
@@ -18,7 +18,7 @@ import type {
DockerLogOptions,
DockerValidation,
ProxyNode,
-} from "../types/index.js";
+} from "@/types/index";
// ============================================================================
// RBAC TYPE DEFINITIONS
@@ -69,8 +69,8 @@ import {
systemLogger,
dashboardLogger,
type LogContext,
-} from "../lib/frontend-logger.js";
-import { dbHealthMonitor } from "../lib/db-health-monitor.js";
+} from "@/lib/frontend-logger";
+import { dbHealthMonitor } from "@/lib/db-health-monitor";
interface FileManagerOperation {
name: string;
@@ -1160,6 +1160,23 @@ export async function createSSHHost(hostData: SSHHostData): Promise<SSHHost> {
socks5ProxyChain: hostData.socks5ProxyChain || null,
macAddress: hostData.macAddress || null,
portKnockSequence: hostData.portKnockSequence || null,
+ enableSsh: hostData.enableSsh !== false,
+ enableRdp: Boolean(hostData.enableRdp),
+ enableVnc: Boolean(hostData.enableVnc),
+ enableTelnet: Boolean(hostData.enableTelnet),
+ sshPort: hostData.sshPort || hostData.port || 22,
+ rdpPort: hostData.rdpPort || 3389,
+ vncPort: hostData.vncPort || 5900,
+ telnetPort: hostData.telnetPort || 23,
+ rdpUser: hostData.rdpUser || null,
+ rdpPassword: hostData.rdpPassword || null,
+ rdpDomain: hostData.rdpDomain || null,
+ rdpSecurity: hostData.rdpSecurity || null,
+ rdpIgnoreCert: Boolean(hostData.rdpIgnoreCert),
+ vncPassword: hostData.vncPassword || null,
+ vncUser: hostData.vncUser || null,
+ telnetUser: hostData.telnetUser || null,
+ telnetPassword: hostData.telnetPassword || null,
};
if (!submitData.enableTunnel) {
@@ -1249,6 +1266,23 @@ export async function updateSSHHost(
socks5ProxyChain: hostData.socks5ProxyChain || null,
macAddress: hostData.macAddress || null,
portKnockSequence: hostData.portKnockSequence || null,
+ enableSsh: hostData.enableSsh !== false,
+ enableRdp: Boolean(hostData.enableRdp),
+ enableVnc: Boolean(hostData.enableVnc),
+ enableTelnet: Boolean(hostData.enableTelnet),
+ sshPort: hostData.sshPort || hostData.port || 22,
+ rdpPort: hostData.rdpPort || 3389,
+ vncPort: hostData.vncPort || 5900,
+ telnetPort: hostData.telnetPort || 23,
+ rdpUser: hostData.rdpUser || null,
+ rdpPassword: hostData.rdpPassword || null,
+ rdpDomain: hostData.rdpDomain || null,
+ rdpSecurity: hostData.rdpSecurity || null,
+ rdpIgnoreCert: Boolean(hostData.rdpIgnoreCert),
+ vncPassword: hostData.vncPassword || null,
+ vncUser: hostData.vncUser || null,
+ telnetUser: hostData.telnetUser || null,
+ telnetPassword: hostData.telnetPassword || null,
};
if (!submitData.enableTunnel) {
@@ -4974,7 +5008,14 @@ export async function getContainerStats(
}
export interface DashboardLayout {
- cards: Array<{ id: string; enabled: boolean; order: number }>;
+ cards: Array<{
+ id: string;
+ enabled: boolean;
+ order: number;
+ panel?: "main" | "side";
+ height?: number | null;
+ }>;
+ mainWidthPct?: number;
}
export async function getDashboardPreferences(): Promise<DashboardLayout> {
diff --git a/src/ui/mobile/MobileApp.tsx b/src/ui/mobile/MobileApp.tsx
deleted file mode 100644
index fd3a1862f..000000000
--- a/src/ui/mobile/MobileApp.tsx
+++ /dev/null
@@ -1,310 +0,0 @@
-import React, {
- useState,
- useEffect,
- Component,
- type FC,
- type ReactNode,
-} from "react";
-import { Terminal } from "@/ui/mobile/apps/terminal/Terminal.tsx";
-import { TerminalKeyboard } from "@/ui/mobile/apps/terminal/TerminalKeyboard.tsx";
-import { BottomNavbar } from "@/ui/mobile/navigation/BottomNavbar.tsx";
-import { LeftSidebar } from "@/ui/mobile/navigation/LeftSidebar.tsx";
-import {
- TabProvider,
- useTabs,
-} from "@/ui/mobile/navigation/tabs/TabContext.tsx";
-import {
- getUserInfo,
- isCurrentAuthInvalidationError,
-} from "@/ui/main-axios.ts";
-import { Auth } from "@/ui/mobile/authentication/Auth.tsx";
-import { useTranslation } from "react-i18next";
-import { Toaster } from "@/components/ui/sonner.tsx";
-import { dbHealthMonitor } from "@/lib/db-health-monitor.ts";
-
-type ReactNativeWindow = Window & {
- ReactNativeWebView?: {
- postMessage: (message: string) => void;
- };
-};
-
-function isReactNativeWebView(): boolean {
- return (
- typeof window !== "undefined" &&
- !!(window as ReactNativeWindow).ReactNativeWebView
- );
-}
-
-const AppContent: FC = () => {
- const { t } = useTranslation();
- const { tabs, currentTab, getTab } = useTabs();
- const [isSidebarOpen, setIsSidebarOpen] = React.useState(true);
- const [ready, setReady] = React.useState(true);
-
- const [isAuthenticated, setIsAuthenticated] = useState(false);
- const [username, setUsername] = useState<string | null>(null);
- const [, setIsAdmin] = useState(false);
- const [authLoading, setAuthLoading] = useState(true);
- const isAuthenticatedRef = React.useRef(false);
-
- useEffect(() => {
- isAuthenticatedRef.current = isAuthenticated;
- }, [isAuthenticated]);
-
- useEffect(() => {
- const handleSessionExpired = () => {
- setIsAuthenticated(false);
- setIsAdmin(false);
- setUsername(null);
- };
-
- dbHealthMonitor.on("session-expired", handleSessionExpired);
- return () => dbHealthMonitor.off("session-expired", handleSessionExpired);
- }, []);
-
- useEffect(() => {
- const checkAuth = () => {
- 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);
- }
- })
- .catch((err) => {
- if (isCurrentAuthInvalidationError(err)) {
- setIsAuthenticated(false);
- setIsAdmin(false);
- setUsername(null);
- console.warn(t("errors.sessionExpired"));
- return;
- }
-
- if (!isAuthenticatedRef.current) {
- setIsAuthenticated(false);
- setIsAdmin(false);
- setUsername(null);
- }
- })
- .finally(() => setAuthLoading(false));
- };
-
- checkAuth();
-
- const handleStorageChange = () => checkAuth();
- window.addEventListener("storage", handleStorageChange);
-
- return () => window.removeEventListener("storage", handleStorageChange);
- }, []);
-
- useEffect(() => {
- const interval = setInterval(() => {
- fitCurrentTerminal();
- }, 2000);
-
- return () => clearInterval(interval);
- }, []);
-
- const handleAuthSuccess = (authData: {
- isAdmin: boolean;
- username: string | null;
- userId: string | null;
- }) => {
- setIsAuthenticated(true);
- setIsAdmin(authData.isAdmin);
- setUsername(authData.username);
- };
-
- const fitCurrentTerminal = () => {
- const tab = getTab(currentTab as number);
- if (tab && tab.terminalRef?.current?.fit) {
- tab.terminalRef.current.fit();
- }
- };
-
- React.useEffect(() => {
- if (tabs.length > 0) {
- setReady(false);
- requestAnimationFrame(() => {
- requestAnimationFrame(() => {
- fitCurrentTerminal();
- setReady(true);
- });
- });
- }
- }, [currentTab]);
-
- const closeSidebar = () => setIsSidebarOpen(false);
-
- const handleKeyboardLayoutChange = () => {
- fitCurrentTerminal();
- };
-
- function handleKeyboardInput(input: string) {
- const currentTerminalTab = getTab(currentTab as number);
- if (
- currentTerminalTab &&
- currentTerminalTab.terminalRef?.current?.sendInput
- ) {
- currentTerminalTab.terminalRef.current.sendInput(input);
- }
- }
-
- if (authLoading) {
- return (
- <div className="h-screen w-screen flex items-center justify-center bg-canvas">
- <div className="text-center">
- <div className="w-16 h-16 border-4 border-primary border-t-transparent rounded-full animate-spin mx-auto mb-4" />
- <p className="text-muted-foreground">{t("common.loading")}</p>
- </div>
- </div>
- );
- }
-
- if (!isAuthenticated || isReactNativeWebView()) {
- return (
- <div className="h-screen w-screen flex items-center justify-center bg-canvas p-4">
- <Auth
- setLoggedIn={setIsAuthenticated}
- setIsAdmin={setIsAdmin}
- setUsername={setUsername}
- setUserId={() => {}}
- loggedIn={isAuthenticated}
- authLoading={authLoading}
- dbError={null}
- setDbError={() => {}}
- onAuthSuccess={handleAuthSuccess}
- />
- </div>
- );
- }
-
- return (
- <div className="h-screen w-screen flex flex-col bg-deepest overflow-y-hidden overflow-x-hidden relative">
- <div className="flex-1 min-h-0 relative">
- {tabs.map((tab) => (
- <div
- key={tab.id}
- className={`absolute inset-0 mb-2 bg-elevated ${tab.id === currentTab ? "visible" : "invisible"} ${ready ? "opacity-100" : "opacity-0"}`}
- >
- <Terminal
- ref={tab.terminalRef}
- hostConfig={tab.hostConfig}
- isVisible={tab.id === currentTab}
- />
- </div>
- ))}
- {tabs.length === 0 && (
- <div className="flex flex-col items-center justify-center h-full text-foreground gap-3 px-4 text-center">
- <h1 className="text-lg font-semibold">
- {t("mobile.selectHostToStart")}
- </h1>
- <p className="text-sm text-foreground-secondary max-w-xs">
- {t("mobile.limitedSupportMessage")}
- </p>
- <button
- className="mt-4 px-6 py-3 bg-primary text-primary-foreground rounded-lg font-semibold hover:bg-primary/90 transition-colors"
- onClick={() =>
- window.open("https://docs.termix.site/install", "_blank")
- }
- >
- {t("mobile.viewMobileAppDocs")}
- </button>
- </div>
- )}
- </div>
- {currentTab && (
- <div className="mb-1 z-10">
- <TerminalKeyboard
- onSendInput={handleKeyboardInput}
- onLayoutChange={handleKeyboardLayoutChange}
- />
- </div>
- )}
- <BottomNavbar onSidebarOpenClick={() => setIsSidebarOpen(true)} />
-
- {isSidebarOpen && (
- <div
- className="absolute inset-0 bg-black/30 backdrop-blur-sm z-10"
- onClick={() => setIsSidebarOpen(false)}
- />
- )}
-
- <div className="absolute top-0 left-0 h-full z-20 pointer-events-none">
- <div
- onClick={(e) => {
- e.stopPropagation();
- }}
- className="pointer-events-auto"
- >
- <LeftSidebar
- isSidebarOpen={isSidebarOpen}
- setIsSidebarOpen={setIsSidebarOpen}
- onHostConnect={closeSidebar}
- disabled={!isAuthenticated || authLoading}
- username={username}
- />
- </div>
- </div>
- <Toaster
- position="bottom-center"
- 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) {
- 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;
- }
-}
-
-export const MobileApp: FC = () => {
- return (
- <TabProvider>
- <TabErrorBoundary>
- <AppContent />
- </TabErrorBoundary>
- </TabProvider>
- );
-};
diff --git a/src/ui/mobile/apps/navigation/BottomNavbar.tsx b/src/ui/mobile/apps/navigation/BottomNavbar.tsx
deleted file mode 100644
index ab969565b..000000000
--- a/src/ui/mobile/apps/navigation/BottomNavbar.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import { Button } from "@/components/ui/button";
-import { Menu, X, Terminal as TerminalIcon } from "lucide-react";
-import { useTabs } from "@/ui/mobile/apps/navigation/tabs/TabContext.tsx";
-import { cn } from "@/lib/utils.ts";
-
-interface MenuProps {
- onSidebarOpenClick?: () => void;
-}
-
-export function BottomNavbar({ onSidebarOpenClick }: MenuProps) {
- const { tabs, currentTab, setCurrentTab, removeTab } = useTabs();
-
- return (
- <div className="w-full h-[80px] bg-canvas flex items-center p-2 gap-2">
- <Button
- className="w-[40px] h-[40px] flex-shrink-0"
- variant="outline"
- onClick={onSidebarOpenClick}
- >
- <Menu />
- </Button>
- <div className="flex-1 overflow-x-auto whitespace-nowrap thin-scrollbar">
- <div className="inline-flex gap-2">
- {tabs.map((tab) => (
- <div
- key={tab.id}
- className="inline-flex rounded-md shadow-sm"
- role="group"
- >
- <Button
- variant="outline"
- className={cn(
- "h-10 rounded-r-none !px-3 border-1 border-edge",
- tab.id === currentTab && "!bg-deepest !text-foreground",
- )}
- onClick={() => setCurrentTab(tab.id)}
- >
- <TerminalIcon className="mr-1 h-4 w-4" />
- {tab.title}
- </Button>
- <Button
- variant="outline"
- className="h-10 rounded-l-none !px-2 border-1 border-edge"
- onClick={() => removeTab(tab.id)}
- >
- <X className="h-4 w-4" />
- </Button>
- </div>
- ))}
- </div>
- </div>
- </div>
- );
-}
diff --git a/src/ui/mobile/apps/navigation/LeftSidebar.tsx b/src/ui/mobile/apps/navigation/LeftSidebar.tsx
deleted file mode 100644
index d85e4b1e0..000000000
--- a/src/ui/mobile/apps/navigation/LeftSidebar.tsx
+++ /dev/null
@@ -1,267 +0,0 @@
-import {
- Sidebar,
- SidebarContent,
- SidebarFooter,
- SidebarGroupLabel,
- SidebarHeader,
- SidebarMenu,
- SidebarMenuButton,
- SidebarMenuItem,
- SidebarProvider,
-} from "@/components/ui/sidebar.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { ChevronUp, Menu, User2 } from "lucide-react";
-import React, { useState, useEffect, useMemo, useCallback } from "react";
-import { Separator } from "@/components/ui/separator.tsx";
-import { FolderCard } from "@/ui/mobile/apps/navigation/hosts/FolderCard.tsx";
-import { getSSHHosts, logoutUser } from "@/ui/main-axios.ts";
-import { useTranslation } from "react-i18next";
-import { Input } from "@/components/ui/input.tsx";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from "@radix-ui/react-dropdown-menu";
-
-interface SSHHost {
- id: number;
- name: string;
- ip: string;
- port: number;
- username: string;
- folder: string;
- tags: string[];
- pin: boolean;
- authType: string;
- password?: string;
- key?: string;
- keyPassword?: string;
- keyType?: string;
- enableTerminal: boolean;
- enableTunnel: boolean;
- enableFileManager: boolean;
- defaultPath: string;
- tunnelConnections: Array<{
- sourcePort: number;
- endpointPort: number;
- endpointHost: string;
- maxRetries: number;
- retryInterval: number;
- autoStart: boolean;
- }>;
- createdAt: string;
- updatedAt: string;
-}
-
-interface LeftSidebarProps {
- isSidebarOpen: boolean;
- setIsSidebarOpen: (type: boolean) => void;
- onHostConnect: () => void;
- disabled?: boolean;
- username?: string | null;
-}
-
-async function handleLogout() {
- try {
- await logoutUser();
-
- window.location.reload();
- } catch (error) {
- console.error("Logout failed:", error);
- window.location.reload();
- }
-}
-
-export function LeftSidebar({
- isSidebarOpen,
- setIsSidebarOpen,
- onHostConnect,
- disabled,
- username,
-}: LeftSidebarProps) {
- const { t } = useTranslation();
- const [hosts, setHosts] = useState<SSHHost[]>([]);
- const [hostsLoading] = useState(false);
- const [hostsError, setHostsError] = useState<string | null>(null);
- const prevHostsRef = React.useRef<SSHHost[]>([]);
- const [search, setSearch] = useState("");
- const [debouncedSearch, setDebouncedSearch] = useState("");
-
- const fetchHosts = useCallback(async () => {
- try {
- const newHosts = await getSSHHosts();
- const prevHosts = prevHostsRef.current;
-
- if (JSON.stringify(newHosts) !== JSON.stringify(prevHosts)) {
- setHosts(newHosts);
- prevHostsRef.current = newHosts;
- }
- } catch {
- setHostsError(t("leftSidebar.failedToLoadHosts"));
- }
- }, [t]);
-
- useEffect(() => {
- fetchHosts();
- const interval = setInterval(fetchHosts, 300000);
- return () => clearInterval(interval);
- }, [fetchHosts]);
-
- useEffect(() => {
- const handleHostsChanged = () => {
- fetchHosts();
- };
- window.addEventListener(
- "ssh-hosts:changed",
- handleHostsChanged as EventListener,
- );
- return () =>
- window.removeEventListener(
- "ssh-hosts:changed",
- handleHostsChanged as EventListener,
- );
- }, [fetchHosts]);
-
- useEffect(() => {
- const handler = setTimeout(() => setDebouncedSearch(search), 200);
- return () => clearTimeout(handler);
- }, [search]);
-
- const filteredHosts = useMemo(() => {
- if (!debouncedSearch.trim()) return hosts;
- const q = debouncedSearch.trim().toLowerCase();
- return hosts.filter((h) => {
- const searchableText = [
- h.name || "",
- h.username,
- h.ip,
- h.folder || "",
- ...(h.tags || []),
- ]
- .join(" ")
- .toLowerCase();
- return searchableText.includes(q);
- });
- }, [hosts, debouncedSearch]);
-
- const hostsByFolder = useMemo(() => {
- const map: Record<string, SSHHost[]> = {};
- filteredHosts.forEach((h) => {
- const folder =
- h.folder && h.folder.trim() ? h.folder : t("leftSidebar.noFolder");
- if (!map[folder]) map[folder] = [];
- map[folder].push(h);
- });
- return map;
- }, [filteredHosts, t]);
-
- const sortedFolders = useMemo(() => {
- const folders = Object.keys(hostsByFolder);
- folders.sort((a, b) => {
- if (a === t("leftSidebar.noFolder")) return 1;
- if (b === t("leftSidebar.noFolder")) return -1;
- return a.localeCompare(b);
- });
- return folders;
- }, [hostsByFolder, t]);
-
- const getSortedHosts = useCallback((arr: SSHHost[]) => {
- const pinned = arr
- .filter((h) => h.pin)
- .sort((a, b) => (a.name || "").localeCompare(b.name || ""));
- const rest = arr
- .filter((h) => !h.pin)
- .sort((a, b) => (a.name || "").localeCompare(b.name || ""));
- return [...pinned, ...rest];
- }, []);
-
- return (
- <div className="">
- <SidebarProvider open={isSidebarOpen}>
- <Sidebar>
- <SidebarHeader>
- <SidebarGroupLabel className="text-lg font-bold text-foreground">
- Termix
- <Button
- variant="outline"
- onClick={() => setIsSidebarOpen(!isSidebarOpen)}
- className="w-[28px] h-[28px] absolute right-5"
- >
- <Menu className="h-4 w-4" />
- </Button>
- </SidebarGroupLabel>
- </SidebarHeader>
- <Separator />
- <SidebarContent className="px-2 py-2">
- <div className="!bg-field rounded-lg mb-2">
- <Input
- value={search}
- onChange={(e) => setSearch(e.target.value)}
- placeholder={t("placeholders.searchHostsAny")}
- className="w-full h-8 text-sm border-2 !bg-field border-edge rounded-md"
- autoComplete="off"
- />
- </div>
-
- {hostsError && (
- <div className="px-1">
- <div className="text-xs text-red-500 bg-red-500/10 rounded-lg px-2 py-1 border w-full">
- {t("leftSidebar.failedToLoadHosts")}
- </div>
- </div>
- )}
-
- {hostsLoading && (
- <div className="px-4 pb-2">
- <div className="text-xs text-muted-foreground text-center">
- {t("hosts.loadingHosts")}
- </div>
- </div>
- )}
-
- {sortedFolders.map((folder) => (
- <FolderCard
- key={`folder-${folder}`}
- folderName={folder}
- hosts={getSortedHosts(hostsByFolder[folder])}
- onHostConnect={onHostConnect}
- />
- ))}
- </SidebarContent>
- <Separator className="mt-1" />
- <SidebarFooter>
- <SidebarMenu>
- <SidebarMenuItem>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <SidebarMenuButton
- className="data-[state=open]:opacity-90 w-full"
- disabled={disabled}
- >
- <User2 /> {username ? username : t("common.logout")}
- <ChevronUp className="ml-auto" />
- </SidebarMenuButton>
- </DropdownMenuTrigger>
- <DropdownMenuContent
- side="top"
- align="start"
- sideOffset={6}
- className="min-w-[var(--radix-popper-anchor-width)] bg-sidebar-accent text-sidebar-accent-foreground border border-border rounded-md shadow-2xl p-1"
- >
- <DropdownMenuItem
- className="rounded px-2 py-1.5 hover:bg-white/15 hover:text-accent-foreground focus:bg-white/20 focus:text-accent-foreground cursor-pointer focus:outline-none"
- onClick={handleLogout}
- >
- <span>{t("common.logout")}</span>
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </SidebarMenuItem>
- </SidebarMenu>
- </SidebarFooter>
- </Sidebar>
- </SidebarProvider>
- </div>
- );
-}
diff --git a/src/ui/mobile/apps/navigation/hosts/FolderCard.tsx b/src/ui/mobile/apps/navigation/hosts/FolderCard.tsx
deleted file mode 100644
index 452137e78..000000000
--- a/src/ui/mobile/apps/navigation/hosts/FolderCard.tsx
+++ /dev/null
@@ -1,99 +0,0 @@
-import React, { useState } from "react";
-import { CardTitle } from "@/components/ui/card.tsx";
-import { ChevronDown, Folder } from "lucide-react";
-import { Button } from "@/components/ui/button.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
-import { Host } from "@/ui/mobile/apps/navigation/hosts/Host.tsx";
-
-interface SSHHost {
- id: number;
- name: string;
- ip: string;
- port: number;
- username: string;
- folder: string;
- tags: string[];
- pin: boolean;
- authType: string;
- password?: string;
- key?: string;
- keyPassword?: string;
- keyType?: string;
- enableTerminal: boolean;
- enableTunnel: boolean;
- enableFileManager: boolean;
- defaultPath: string;
- tunnelConnections: Array<{
- sourcePort: number;
- endpointPort: number;
- endpointHost: string;
- maxRetries: number;
- retryInterval: number;
- autoStart: boolean;
- }>;
- createdAt: string;
- updatedAt: string;
-}
-
-interface FolderCardProps {
- folderName: string;
- hosts: SSHHost[];
- onHostConnect: () => void;
-}
-
-export function FolderCard({
- folderName,
- hosts,
- onHostConnect,
-}: FolderCardProps): React.ReactElement {
- const [isExpanded, setIsExpanded] = useState(true);
-
- const toggleExpanded = () => {
- setIsExpanded(!isExpanded);
- };
-
- return (
- <div className="bg-elevated border-2 border-edge rounded-lg overflow-hidden p-0 m-0">
- <div
- className={`px-4 py-3 relative ${isExpanded ? "border-b-2" : ""} bg-header`}
- >
- <div className="flex gap-2 pr-10">
- <div className="flex-shrink-0 flex items-center">
- <Folder size={16} strokeWidth={3} />
- </div>
- <div className="flex-1 min-w-0">
- <CardTitle className="mb-0 leading-tight break-words text-md">
- {folderName}
- </CardTitle>
- </div>
- </div>
- <Button
- variant="outline"
- className="w-[28px] h-[28px] absolute right-4 top-1/2 -translate-y-1/2 flex-shrink-0"
- onClick={toggleExpanded}
- >
- <ChevronDown
- className={`h-4 w-4 transition-transform ${isExpanded ? "" : "rotate-180"}`}
- />
- </Button>
- </div>
- {isExpanded && (
- <div className="flex flex-col p-2 gap-y-3">
- {hosts.map((host, index) => (
- <React.Fragment
- key={`${folderName}-host-${host.id}-${host.name || host.ip}`}
- >
- <Host host={host} onHostConnect={onHostConnect} />
-
- {index < hosts.length - 1 && (
- <div className="relative -mx-2">
- <Separator className="p-0.25 absolute inset-x-0" />
- </div>
- )}
- </React.Fragment>
- ))}
- </div>
- )}
- </div>
- );
-}
diff --git a/src/ui/mobile/apps/navigation/hosts/Host.tsx b/src/ui/mobile/apps/navigation/hosts/Host.tsx
deleted file mode 100644
index 986fd9ec2..000000000
--- a/src/ui/mobile/apps/navigation/hosts/Host.tsx
+++ /dev/null
@@ -1,100 +0,0 @@
-import React, { useEffect, useState } from "react";
-import { Status, StatusIndicator } from "@/components/ui/shadcn-io/status";
-import { Button } from "@/components/ui/button.tsx";
-import { ButtonGroup } from "@/components/ui/button-group.tsx";
-import { Terminal } from "lucide-react";
-import { getServerStatusById } from "@/ui/main-axios.ts";
-import { useTabs } from "@/ui/mobile/apps/navigation/tabs/TabContext.tsx";
-import type { HostProps } from "../../../../../types/index.js";
-
-export function Host({ host, onHostConnect }: HostProps): React.ReactElement {
- const { addTab } = useTabs();
- const [serverStatus, setServerStatus] = useState<
- "online" | "offline" | "degraded"
- >("degraded");
- const tags = Array.isArray(host.tags) ? host.tags : [];
- const hasTags = tags.length > 0;
-
- const title = host.name?.trim()
- ? host.name
- : `${host.username}@${host.ip}:${host.port}`;
-
- useEffect(() => {
- let cancelled = false;
-
- const fetchStatus = async () => {
- try {
- const res = await getServerStatusById(host.id);
- if (!cancelled) {
- setServerStatus(res?.status === "online" ? "online" : "offline");
- }
- } catch (error: unknown) {
- if (!cancelled) {
- const err = error as { response?: { status?: number } };
- if (err?.response?.status === 503) {
- setServerStatus("offline");
- } else if (err?.response?.status === 504) {
- setServerStatus("degraded");
- } else if (err?.response?.status === 404) {
- setServerStatus("offline");
- } else {
- setServerStatus("offline");
- }
- }
- }
- };
-
- fetchStatus();
-
- const intervalId = window.setInterval(fetchStatus, 30000);
-
- return () => {
- cancelled = true;
- if (intervalId) window.clearInterval(intervalId);
- };
- }, [host.id]);
-
- const handleTerminalClick = () => {
- addTab({ type: "terminal", title, hostConfig: host });
- onHostConnect();
- };
-
- return (
- <div>
- <div className="flex items-center gap-2">
- <Status
- status={serverStatus}
- className="!bg-transparent !p-0.75 flex-shrink-0"
- >
- <StatusIndicator />
- </Status>
- <p className="font-semibold flex-1 min-w-0 break-words text-sm">
- {host.name || host.ip}
- </p>
- <ButtonGroup className="flex-shrink-0">
- {host.enableTerminal && (
- <Button
- variant="outline"
- className="!px-2 border-1 w-[60px] border-edge"
- onClick={handleTerminalClick}
- >
- <Terminal />
- </Button>
- )}
- </ButtonGroup>
- </div>
- {hasTags && (
- <div className="flex flex-wrap items-center gap-2 mt-1">
- {tags.map((tag: string) => (
- <div
- key={tag}
- className="bg-canvas border-1 border-edge pl-2 pr-2 rounded-[10px]"
- >
- <p className="text-sm">{tag}</p>
- </div>
- ))}
- </div>
- )}
- </div>
- );
-}
diff --git a/src/ui/mobile/apps/navigation/tabs/TabContext.tsx b/src/ui/mobile/apps/navigation/tabs/TabContext.tsx
deleted file mode 100644
index 45186e86e..000000000
--- a/src/ui/mobile/apps/navigation/tabs/TabContext.tsx
+++ /dev/null
@@ -1,101 +0,0 @@
-import React, {
- createContext,
- useContext,
- useState,
- useRef,
- type ReactNode,
-} from "react";
-import type { TabContextTab } from "../../../../types/index.js";
-
-export type Tab = TabContextTab;
-
-interface TabContextType {
- tabs: Tab[];
- currentTab: number | null;
- addTab: (tab: Omit<Tab, "id">) => number;
- removeTab: (tabId: number) => void;
- setCurrentTab: (tabId: number) => void;
- getTab: (tabId: number) => Tab | undefined;
-}
-
-const TabContext = createContext<TabContextType | undefined>(undefined);
-
-export function useTabs() {
- const context = useContext(TabContext);
- if (context === undefined) {
- throw new Error("useTabs must be used within a TabProvider");
- }
- return context;
-}
-
-interface TabProviderProps {
- children: ReactNode;
-}
-
-export function TabProvider({ children }: TabProviderProps) {
- const [tabs, setTabs] = useState<Tab[]>([]);
- const [currentTab, setCurrentTab] = useState<number | null>(null);
- const nextTabId = useRef(1);
-
- function computeUniqueTitle(desiredTitle: string | undefined): string {
- const baseTitle = (desiredTitle || "Terminal").trim();
- const existingTitles = tabs.map((t) => t.title);
- if (!existingTitles.includes(baseTitle)) {
- return baseTitle;
- }
- let i = 2;
- while (existingTitles.includes(`${baseTitle} (${i})`)) {
- i++;
- }
- return `${baseTitle} (${i})`;
- }
-
- const addTab = (tabData: Omit<Tab, "id">): number => {
- const id = nextTabId.current++;
- const newTab: Tab = {
- ...tabData,
- id,
- title: computeUniqueTitle(tabData.title),
- terminalRef: React.createRef<{ disconnect?: () => void }>(),
- };
- setTabs((prev) => [...prev, newTab]);
- setCurrentTab(id);
- return id;
- };
-
- const removeTab = (tabId: number) => {
- const tab = tabs.find((t) => t.id === tabId);
- if (
- tab &&
- tab.terminalRef?.current &&
- typeof tab.terminalRef.current.disconnect === "function"
- ) {
- tab.terminalRef.current.disconnect();
- }
-
- setTabs((prev) => {
- const newTabs = prev.filter((tab) => tab.id !== tabId);
- if (currentTab === tabId) {
- setCurrentTab(
- newTabs.length > 0 ? newTabs[newTabs.length - 1].id : null,
- );
- }
- return newTabs;
- });
- };
-
- const getTab = (tabId: number) => {
- return tabs.find((tab) => tab.id === tabId);
- };
-
- const value: TabContextType = {
- tabs,
- currentTab,
- addTab,
- removeTab,
- setCurrentTab,
- getTab,
- };
-
- return <TabContext.Provider value={value}>{children}</TabContext.Provider>;
-}
diff --git a/src/ui/mobile/apps/terminal/Terminal.tsx b/src/ui/mobile/apps/terminal/Terminal.tsx
deleted file mode 100644
index b9e89a2ca..000000000
--- a/src/ui/mobile/apps/terminal/Terminal.tsx
+++ /dev/null
@@ -1,1316 +0,0 @@
-import {
- useEffect,
- useRef,
- useState,
- useImperativeHandle,
- forwardRef,
- useCallback,
-} from "react";
-import { useXTerm } from "react-xtermjs";
-import { FitAddon } from "@xterm/addon-fit";
-import { ClipboardAddon } from "@xterm/addon-clipboard";
-import { RobustClipboardProvider } from "@/lib/clipboard-provider";
-import { Unicode11Addon } from "@xterm/addon-unicode11";
-import { WebLinksAddon } from "@xterm/addon-web-links";
-import { useTranslation } from "react-i18next";
-import { toast } from "sonner";
-import { isElectron, isEmbeddedMode, getSnippets } from "@/ui/main-axios.ts";
-import { getBasePath } from "@/lib/base-path";
-import { useTheme } from "@/components/theme-provider";
-import {
- TERMINAL_THEMES,
- DEFAULT_TERMINAL_CONFIG,
- TERMINAL_FONTS,
-} from "@/constants/terminal-themes.ts";
-import type { TerminalConfig } from "@/types";
-import { TOTPDialog } from "@/ui/desktop/navigation/dialogs/TOTPDialog.tsx";
-import { SSHAuthDialog } from "@/ui/desktop/navigation/dialogs/SSHAuthDialog.tsx";
-import { PassphraseDialog } from "@/ui/desktop/navigation/dialogs/PassphraseDialog.tsx";
-import { WarpgateDialog } from "@/ui/desktop/navigation/dialogs/WarpgateDialog.tsx";
-import {
- ConnectionLogProvider,
- useConnectionLog,
-} from "@/ui/desktop/navigation/connection-log/ConnectionLogContext.tsx";
-import { ConnectionLog } from "@/ui/desktop/navigation/connection-log/ConnectionLog.tsx";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
-
-interface HostConfig {
- id?: number;
- ip: string;
- port: number;
- username: string;
- password?: string;
- key?: string;
- keyPassword?: string;
- keyType?: string;
- authType?: string;
- credentialId?: number;
- terminalConfig?: TerminalConfig;
- name?: string;
- [key: string]: unknown;
-}
-
-interface TerminalHandle {
- disconnect: () => void;
- fit: () => void;
- sendInput: (data: string) => void;
- notifyResize: () => void;
- refresh: () => void;
-}
-
-interface SSHTerminalProps {
- hostConfig: HostConfig;
- isVisible: boolean;
- title?: string;
-}
-
-const TerminalInner = forwardRef<TerminalHandle, SSHTerminalProps>(
- function SSHTerminal({ hostConfig, isVisible }, ref) {
- const { t } = useTranslation();
- const { instance: terminal, ref: xtermRef } = useXTerm();
- const { theme: appTheme } = useTheme();
- const { addLog, isExpanded: isConnectionLogExpanded } = useConnectionLog();
-
- const config = { ...DEFAULT_TERMINAL_CONFIG, ...hostConfig.terminalConfig };
-
- const isDarkMode =
- appTheme === "dark" ||
- (appTheme === "system" &&
- window.matchMedia("(prefers-color-scheme: dark)").matches);
-
- let themeColors;
- if (config.theme === "termix") {
- themeColors = isDarkMode
- ? TERMINAL_THEMES.termixDark.colors
- : TERMINAL_THEMES.termixLight.colors;
- } else {
- themeColors =
- TERMINAL_THEMES[config.theme]?.colors ||
- TERMINAL_THEMES.termixDark.colors;
- }
- const backgroundColor = themeColors.background;
-
- const fitAddonRef = useRef<FitAddon | null>(null);
- const webSocketRef = useRef<WebSocket | null>(null);
- const resizeTimeout = useRef<NodeJS.Timeout | null>(null);
- const wasDisconnectedBySSH = useRef(false);
- const pingIntervalRef = useRef<NodeJS.Timeout | null>(null);
- const [, setVisible] = useState(false);
- const [isReady, setIsReady] = useState(false);
- const [isConnected, setIsConnected] = useState(false);
- const [isConnecting, setIsConnecting] = useState(false);
- const [connectionError, setConnectionError] = useState<string | null>(null);
- const connectionErrorRef = useRef<string | null>(null);
-
- const updateConnectionError = useCallback((error: string | null) => {
- connectionErrorRef.current = error;
- setConnectionError(error);
- }, []);
-
- const [isAuthenticated, setIsAuthenticated] = useState(false);
- const [totpRequired, setTotpRequired] = useState(false);
- const [totpPrompt, setTotpPrompt] = useState<string>("");
- const [isPasswordPrompt, setIsPasswordPrompt] = useState(false);
- const [showAuthDialog, setShowAuthDialog] = useState(false);
- const [authDialogReason, setAuthDialogReason] = useState<
- "no_keyboard" | "auth_failed" | "timeout"
- >("no_keyboard");
- const [showPassphraseDialog, setShowPassphraseDialog] = useState(false);
- const [warpgateAuthRequired, setWarpgateAuthRequired] = useState(false);
- const [warpgateAuthUrl, setWarpgateAuthUrl] = useState<string>("");
- const [warpgateSecurityKey, setWarpgateSecurityKey] = useState<string>("");
-
- const isVisibleRef = useRef<boolean>(false);
- const isFittingRef = useRef(false);
- const reconnectTimeoutRef = useRef<NodeJS.Timeout | null>(null);
- const reconnectAttempts = useRef(0);
- const maxReconnectAttempts = 8;
- const isUnmountingRef = useRef(false);
- const shouldNotReconnectRef = useRef(false);
- const isReconnectingRef = useRef(false);
- const isConnectingRef = useRef(false);
- const connectionAttemptIdRef = useRef(0);
- const totpTimeoutRef = useRef<NodeJS.Timeout | null>(null);
- const connectionTimeoutRef = useRef<NodeJS.Timeout | null>(null);
- const warpgateTimeoutRef = useRef<NodeJS.Timeout | null>(null);
-
- const lastSentSizeRef = useRef<{ cols: number; rows: number } | null>(null);
- const pendingSizeRef = useRef<{ cols: number; rows: number } | null>(null);
- const notifyTimerRef = useRef<NodeJS.Timeout | null>(null);
- const DEBOUNCE_MS = 140;
-
- useEffect(() => {
- isUnmountingRef.current = false;
- shouldNotReconnectRef.current = false;
- isReconnectingRef.current = false;
- isConnectingRef.current = false;
- reconnectAttempts.current = 0;
-
- return () => {};
- }, [hostConfig.id]);
-
- useEffect(() => {
- isVisibleRef.current = isVisible;
- }, [isVisible]);
-
- useEffect(() => {
- const checkAuth = () => {
- setIsAuthenticated((prev) => {
- if (!prev) {
- return true;
- }
- return prev;
- });
- };
-
- checkAuth();
-
- const authCheckInterval = setInterval(checkAuth, 5000);
-
- return () => clearInterval(authCheckInterval);
- }, []);
-
- function hardRefresh() {
- try {
- if (
- terminal &&
- typeof (
- terminal as { refresh?: (start: number, end: number) => void }
- ).refresh === "function"
- ) {
- (
- terminal as { refresh?: (start: number, end: number) => void }
- ).refresh(0, terminal.rows - 1);
- }
- } catch (error) {
- console.error("Terminal operation failed:", error);
- }
- }
-
- function performFit() {
- if (
- !fitAddonRef.current ||
- !terminal ||
- !isVisibleRef.current ||
- isFittingRef.current
- ) {
- return;
- }
-
- isFittingRef.current = true;
-
- requestAnimationFrame(() => {
- try {
- fitAddonRef.current?.fit();
- if (terminal && terminal.cols > 0 && terminal.rows > 0) {
- scheduleNotify(terminal.cols, terminal.rows);
- }
- hardRefresh();
- } finally {
- isFittingRef.current = false;
- }
- });
- }
-
- function scheduleNotify(cols: number, rows: number) {
- if (!(cols > 0 && rows > 0)) return;
- pendingSizeRef.current = { cols, rows };
- if (notifyTimerRef.current) clearTimeout(notifyTimerRef.current);
- notifyTimerRef.current = setTimeout(() => {
- const next = pendingSizeRef.current;
- const last = lastSentSizeRef.current;
- if (!next) return;
- if (last && last.cols === next.cols && last.rows === next.rows) return;
- if (webSocketRef.current?.readyState === WebSocket.OPEN) {
- webSocketRef.current.send(
- JSON.stringify({ type: "resize", data: next }),
- );
- lastSentSizeRef.current = next;
- }
- }, DEBOUNCE_MS);
- }
-
- function handleTotpSubmit(code: string) {
- if (webSocketRef.current && code) {
- if (totpTimeoutRef.current) {
- clearTimeout(totpTimeoutRef.current);
- totpTimeoutRef.current = null;
- }
- webSocketRef.current.send(
- JSON.stringify({
- type: isPasswordPrompt ? "password_response" : "totp_response",
- data: { code },
- }),
- );
- setTotpRequired(false);
- setTotpPrompt("");
- setIsPasswordPrompt(false);
- }
- }
-
- function handleTotpCancel() {
- if (totpTimeoutRef.current) {
- clearTimeout(totpTimeoutRef.current);
- totpTimeoutRef.current = null;
- }
- setTotpRequired(false);
- setTotpPrompt("");
- webSocketRef.current?.close();
- }
-
- function handleWarpgateContinue() {
- if (webSocketRef.current) {
- if (warpgateTimeoutRef.current) {
- clearTimeout(warpgateTimeoutRef.current);
- warpgateTimeoutRef.current = null;
- }
- webSocketRef.current.send(
- JSON.stringify({
- type: "warpgate_auth_continue",
- data: {},
- }),
- );
- setWarpgateAuthRequired(false);
- setWarpgateAuthUrl("");
- setWarpgateSecurityKey("");
- }
- }
-
- function handleWarpgateCancel() {
- if (warpgateTimeoutRef.current) {
- clearTimeout(warpgateTimeoutRef.current);
- warpgateTimeoutRef.current = null;
- }
- setWarpgateAuthRequired(false);
- setWarpgateAuthUrl("");
- setWarpgateSecurityKey("");
- webSocketRef.current?.close();
- }
-
- function handleWarpgateOpenUrl() {
- if (warpgateAuthUrl) {
- window.open(warpgateAuthUrl, "_blank", "noopener,noreferrer");
- }
- }
-
- function handleAuthDialogSubmit(credentials: {
- password?: string;
- sshKey?: string;
- keyPassword?: string;
- }) {
- if (webSocketRef.current && terminal) {
- webSocketRef.current.send(
- JSON.stringify({
- type: "reconnect_with_credentials",
- data: {
- cols: terminal.cols,
- rows: terminal.rows,
- password: credentials.password,
- sshKey: credentials.sshKey,
- keyPassword: credentials.keyPassword,
- hostConfig: {
- ...hostConfig,
- password: credentials.password,
- key: credentials.sshKey,
- keyPassword: credentials.keyPassword,
- },
- },
- }),
- );
- setShowAuthDialog(false);
- setIsConnecting(true);
- }
- }
-
- function handleAuthDialogCancel() {
- setShowAuthDialog(false);
- webSocketRef.current?.close();
- }
-
- function handlePassphraseSubmit(passphrase: string) {
- if (webSocketRef.current && terminal) {
- webSocketRef.current.send(
- JSON.stringify({
- type: "reconnect_with_credentials",
- data: {
- cols: terminal.cols,
- rows: terminal.rows,
- keyPassword: passphrase,
- hostConfig: {
- ...hostConfig,
- keyPassword: passphrase,
- },
- },
- }),
- );
- setShowPassphraseDialog(false);
- setIsConnecting(true);
- }
- }
-
- function handlePassphraseCancel() {
- setShowPassphraseDialog(false);
- webSocketRef.current?.close();
- }
-
- useImperativeHandle(
- ref,
- () => ({
- disconnect: () => {
- isUnmountingRef.current = true;
- shouldNotReconnectRef.current = true;
- isReconnectingRef.current = false;
- if (pingIntervalRef.current) {
- clearInterval(pingIntervalRef.current);
- pingIntervalRef.current = null;
- }
- if (reconnectTimeoutRef.current) {
- clearTimeout(reconnectTimeoutRef.current);
- reconnectTimeoutRef.current = null;
- }
- if (connectionTimeoutRef.current) {
- clearTimeout(connectionTimeoutRef.current);
- connectionTimeoutRef.current = null;
- }
- if (totpTimeoutRef.current) {
- clearTimeout(totpTimeoutRef.current);
- totpTimeoutRef.current = null;
- }
- if (warpgateTimeoutRef.current) {
- clearTimeout(warpgateTimeoutRef.current);
- warpgateTimeoutRef.current = null;
- }
- webSocketRef.current?.close();
- },
- fit: () => {
- fitAddonRef.current?.fit();
- if (terminal) scheduleNotify(terminal.cols, terminal.rows);
- hardRefresh();
- },
- sendInput: (data: string) => {
- if (webSocketRef.current?.readyState === 1) {
- webSocketRef.current.send(JSON.stringify({ type: "input", data }));
- }
- },
- notifyResize: () => {
- try {
- const cols = terminal?.cols ?? undefined;
- const rows = terminal?.rows ?? undefined;
- if (typeof cols === "number" && typeof rows === "number") {
- scheduleNotify(cols, rows);
- hardRefresh();
- }
- } catch (error) {
- console.error("Terminal operation failed:", error);
- }
- },
- refresh: () => hardRefresh(),
- }),
- [terminal],
- );
-
- function attemptReconnection() {
- if (
- isUnmountingRef.current ||
- shouldNotReconnectRef.current ||
- isReconnectingRef.current ||
- isConnectingRef.current ||
- wasDisconnectedBySSH.current ||
- reconnectTimeoutRef.current !== null
- ) {
- return;
- }
-
- if (reconnectAttempts.current >= maxReconnectAttempts) {
- updateConnectionError(t("terminal.maxReconnectAttemptsReached"));
- setIsConnecting(false);
- shouldNotReconnectRef.current = true;
- addLog({
- type: "error",
- stage: "connection",
- message: t("terminal.maxReconnectAttemptsReached"),
- });
- return;
- }
-
- isReconnectingRef.current = true;
-
- if (terminal) {
- terminal.clear();
- }
-
- reconnectAttempts.current++;
-
- addLog({
- type: "info",
- stage: "connection",
- message: t("terminal.reconnecting", {
- attempt: reconnectAttempts.current,
- max: maxReconnectAttempts,
- }),
- });
-
- const delay = Math.min(
- 2000 * Math.pow(2, reconnectAttempts.current - 1),
- 8000,
- );
-
- reconnectTimeoutRef.current = setTimeout(() => {
- reconnectTimeoutRef.current = null;
-
- if (
- isUnmountingRef.current ||
- shouldNotReconnectRef.current ||
- wasDisconnectedBySSH.current
- ) {
- isReconnectingRef.current = false;
- return;
- }
-
- if (reconnectAttempts.current > maxReconnectAttempts) {
- isReconnectingRef.current = false;
- return;
- }
-
- if (terminal && hostConfig) {
- terminal.clear();
- const cols = terminal.cols;
- const rows = terminal.rows;
- connectToHost(cols, rows);
- }
-
- isReconnectingRef.current = false;
- }, delay);
- }
-
- function connectToHost(cols: number, rows: number) {
- if (isConnectingRef.current) {
- return;
- }
-
- isConnectingRef.current = true;
- connectionAttemptIdRef.current++;
-
- if (!isReconnectingRef.current) {
- reconnectAttempts.current = 0;
- shouldNotReconnectRef.current = false;
- }
-
- const isDev =
- process.env.NODE_ENV === "development" &&
- (window.location.port === "3000" ||
- window.location.port === "5173" ||
- window.location.port === "");
-
- const baseWsUrl = isDev
- ? `${window.location.protocol === "https:" ? "wss" : "ws"}://localhost:30002`
- : isElectron()
- ? (() => {
- const configuredUrl = (window as { configuredServerUrl?: string })
- .configuredServerUrl;
- if (isEmbeddedMode() || !configuredUrl) {
- return "ws://127.0.0.1:30002";
- }
- const wsProtocol = configuredUrl.startsWith("https://")
- ? "wss://"
- : "ws://";
- const wsHost = configuredUrl
- .replace(/^https?:\/\//, "")
- .replace(/\/$/, "");
- return `${wsProtocol}${wsHost}/ssh/websocket/`;
- })()
- : `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.host}${getBasePath()}/ssh/websocket/`;
-
- if (
- webSocketRef.current &&
- webSocketRef.current.readyState !== WebSocket.CLOSED
- ) {
- webSocketRef.current.close();
- }
-
- if (pingIntervalRef.current) {
- clearInterval(pingIntervalRef.current);
- pingIntervalRef.current = null;
- }
- if (connectionTimeoutRef.current) {
- clearTimeout(connectionTimeoutRef.current);
- connectionTimeoutRef.current = null;
- }
-
- const ws = new WebSocket(baseWsUrl);
- webSocketRef.current = ws;
- wasDisconnectedBySSH.current = false;
- updateConnectionError(null);
- shouldNotReconnectRef.current = false;
- isReconnectingRef.current = false;
- setIsConnecting(true);
-
- setupWebSocketListeners(ws, cols, rows);
- }
-
- function setupWebSocketListeners(
- ws: WebSocket,
- cols: number,
- rows: number,
- ) {
- ws.addEventListener("open", () => {
- connectionTimeoutRef.current = setTimeout(() => {
- if (
- !isConnected &&
- !totpRequired &&
- !isPasswordPrompt &&
- !connectionErrorRef.current
- ) {
- if (terminal) {
- terminal.clear();
- }
- const timeoutMessage = t("terminal.connectionTimeout");
- updateConnectionError(timeoutMessage);
- addLog({
- type: "error",
- stage: "connection",
- message: timeoutMessage,
- });
- if (webSocketRef.current) {
- webSocketRef.current.close();
- }
- if (reconnectAttempts.current > 0) {
- attemptReconnection();
- } else {
- setIsConnecting(false);
- shouldNotReconnectRef.current = true;
- }
- }
- }, 35000);
-
- ws.send(
- JSON.stringify({
- type: "connectToHost",
- data: { cols, rows, hostConfig },
- }),
- );
- terminal.onData((data) => {
- ws.send(JSON.stringify({ type: "input", data }));
- });
-
- pingIntervalRef.current = setInterval(() => {
- if (ws.readyState === WebSocket.OPEN) {
- ws.send(JSON.stringify({ type: "ping" }));
- }
- }, 30000);
- });
-
- ws.addEventListener("message", (event) => {
- try {
- const msg = JSON.parse(event.data);
- if (msg.type === "data") {
- if (typeof msg.data === "string") {
- terminal.write(msg.data);
- } else {
- terminal.write(String(msg.data));
- }
- } else if (msg.type === "error") {
- const errorMessage = msg.message || t("terminal.unknownError");
-
- addLog({
- type: "error",
- stage: "connection",
- message: errorMessage,
- });
-
- if (
- errorMessage.toLowerCase().includes("connection") ||
- errorMessage.toLowerCase().includes("timeout") ||
- errorMessage.toLowerCase().includes("network")
- ) {
- updateConnectionError(errorMessage);
- setIsConnected(false);
- if (terminal) {
- terminal.clear();
- }
- setIsConnecting(false);
- wasDisconnectedBySSH.current = false;
- return;
- }
-
- if (
- (errorMessage.toLowerCase().includes("auth") &&
- errorMessage.toLowerCase().includes("failed")) ||
- errorMessage.toLowerCase().includes("permission denied") ||
- (errorMessage.toLowerCase().includes("invalid") &&
- (errorMessage.toLowerCase().includes("password") ||
- errorMessage.toLowerCase().includes("key"))) ||
- errorMessage.toLowerCase().includes("incorrect password")
- ) {
- updateConnectionError(errorMessage);
- setIsConnecting(false);
- shouldNotReconnectRef.current = true;
- if (webSocketRef.current) {
- webSocketRef.current.close();
- }
- return;
- }
-
- updateConnectionError(errorMessage);
- setIsConnecting(false);
- } else if (msg.type === "connected") {
- setIsConnected(true);
- setIsConnecting(false);
- isConnectingRef.current = false;
- updateConnectionError(null);
- if (connectionTimeoutRef.current) {
- clearTimeout(connectionTimeoutRef.current);
- connectionTimeoutRef.current = null;
- }
- if (reconnectAttempts.current > 0) {
- addLog({
- type: "success",
- stage: "connection",
- message: t("terminal.reconnected"),
- });
- } else {
- addLog({
- type: "success",
- stage: "connection",
- message: t("terminal.connected"),
- });
- }
- reconnectAttempts.current = 0;
- isReconnectingRef.current = false;
-
- setTimeout(async () => {
- const terminalConfig = {
- ...DEFAULT_TERMINAL_CONFIG,
- ...hostConfig.terminalConfig,
- };
-
- if (
- terminalConfig.environmentVariables &&
- terminalConfig.environmentVariables.length > 0
- ) {
- for (const envVar of terminalConfig.environmentVariables) {
- if (envVar.key && envVar.value && ws.readyState === 1) {
- ws.send(
- JSON.stringify({
- type: "input",
- data: `export ${envVar.key}="${envVar.value}"\n`,
- }),
- );
- }
- }
- }
-
- if (terminalConfig.startupSnippetId) {
- try {
- const snippets = await getSnippets();
- const snippet = snippets.find(
- (s: { id: number }) =>
- s.id === terminalConfig.startupSnippetId,
- );
- if (snippet && ws.readyState === 1) {
- ws.send(
- JSON.stringify({
- type: "input",
- data: snippet.content + "\r",
- }),
- );
- }
- } catch (err) {
- console.warn("Failed to execute startup snippet:", err);
- }
- }
-
- if (terminalConfig.autoMosh && ws.readyState === 1) {
- ws.send(
- JSON.stringify({
- type: "input",
- data: terminalConfig.moshCommand + "\n",
- }),
- );
- }
- }, 100);
- } else if (msg.type === "session_ended") {
- wasDisconnectedBySSH.current = true;
- shouldNotReconnectRef.current = true;
- isConnectingRef.current = false;
- setIsConnected(false);
- setIsConnecting(false);
- updateConnectionError(t("terminal.sessionEnded"));
- } else if (msg.type === "disconnected") {
- wasDisconnectedBySSH.current = true;
- isConnectingRef.current = false;
- setIsConnected(false);
- if (terminal) {
- terminal.clear();
- }
- setIsConnecting(false);
- } else if (msg.type === "totp_required") {
- setTotpRequired(true);
- setTotpPrompt(msg.prompt || t("terminal.totpCodeLabel"));
- setIsPasswordPrompt(false);
- if (connectionTimeoutRef.current) {
- clearTimeout(connectionTimeoutRef.current);
- connectionTimeoutRef.current = null;
- }
- if (totpTimeoutRef.current) {
- clearTimeout(totpTimeoutRef.current);
- }
- totpTimeoutRef.current = setTimeout(() => {
- setTotpRequired(false);
- if (webSocketRef.current) {
- webSocketRef.current.close();
- }
- }, 180000);
- } else if (msg.type === "password_required") {
- setTotpRequired(true);
- setTotpPrompt(msg.prompt || t("common.password"));
- setIsPasswordPrompt(true);
- if (connectionTimeoutRef.current) {
- clearTimeout(connectionTimeoutRef.current);
- connectionTimeoutRef.current = null;
- }
- if (totpTimeoutRef.current) {
- clearTimeout(totpTimeoutRef.current);
- }
- totpTimeoutRef.current = setTimeout(() => {
- setTotpRequired(false);
- if (webSocketRef.current) {
- webSocketRef.current.close();
- }
- }, 180000);
- } else if (msg.type === "warpgate_auth_required") {
- setWarpgateAuthRequired(true);
- setWarpgateAuthUrl(msg.url || "");
- setWarpgateSecurityKey(msg.securityKey || "N/A");
- if (connectionTimeoutRef.current) {
- clearTimeout(connectionTimeoutRef.current);
- connectionTimeoutRef.current = null;
- }
- if (warpgateTimeoutRef.current) {
- clearTimeout(warpgateTimeoutRef.current);
- }
- warpgateTimeoutRef.current = setTimeout(() => {
- setWarpgateAuthRequired(false);
- if (webSocketRef.current) {
- webSocketRef.current.close();
- }
- }, 300000);
- } else if (msg.type === "keyboard_interactive_available") {
- setIsConnecting(false);
- if (connectionTimeoutRef.current) {
- clearTimeout(connectionTimeoutRef.current);
- connectionTimeoutRef.current = null;
- }
- } else if (msg.type === "auth_method_not_available") {
- setAuthDialogReason("no_keyboard");
- setShowAuthDialog(true);
- setIsConnecting(false);
- if (connectionTimeoutRef.current) {
- clearTimeout(connectionTimeoutRef.current);
- connectionTimeoutRef.current = null;
- }
- } else if (msg.type === "passphrase_required") {
- setShowPassphraseDialog(true);
- setIsConnecting(false);
- if (connectionTimeoutRef.current) {
- clearTimeout(connectionTimeoutRef.current);
- connectionTimeoutRef.current = null;
- }
- } else if (msg.type === "tmux_sessions_available") {
- // On mobile, auto-attach to the first available session
- const sessions = msg.sessions as Array<{ name: string }>;
- if (sessions.length > 0 && ws.readyState === 1) {
- ws.send(
- JSON.stringify({
- type: "tmux_attach",
- data: { sessionName: sessions[0].name },
- }),
- );
- }
- } else if (
- msg.type === "tmux_session_created" ||
- msg.type === "tmux_session_attached"
- ) {
- const sessionName =
- typeof msg.sessionName === "string" ? msg.sessionName : "";
- addLog({
- type: "info",
- stage: "connection",
- message:
- msg.type === "tmux_session_created"
- ? t("terminal.tmuxSessionCreated", {
- name: sessionName || "new",
- })
- : t("terminal.tmuxSessionAttached", {
- name: sessionName,
- }),
- });
- } else if (msg.type === "tmux_unavailable") {
- setTimeout(() => {
- toast.warning(t("terminal.tmuxUnavailable"), {
- duration: 8000,
- });
- }, 500);
- addLog({
- type: "warning",
- stage: "connection",
- message: t("terminal.tmuxUnavailable"),
- });
- } else if (msg.type === "connection_log") {
- if (msg.data) {
- addLog({
- type: msg.data.level || "info",
- stage: msg.data.stage || "auth",
- message: msg.data.message,
- details: msg.data.details,
- });
- }
- }
- } catch (error) {
- console.error("Terminal operation failed:", error);
- }
- });
-
- const currentAttemptId = connectionAttemptIdRef.current;
-
- ws.addEventListener("close", (event) => {
- if (currentAttemptId !== connectionAttemptIdRef.current) {
- return;
- }
-
- setIsConnected(false);
- isConnectingRef.current = false;
- if (terminal) {
- terminal.clear();
- }
-
- if (totpTimeoutRef.current) {
- clearTimeout(totpTimeoutRef.current);
- totpTimeoutRef.current = null;
- }
-
- if (event.code === 1006) {
- console.warn(
- "[WebSocket] Abnormal closure detected - attempting reconnection",
- );
- addLog({
- type: "warning",
- stage: "connection",
- message: t("terminal.websocketAbnormalClose"),
- });
-
- if (wasConnectedRef.current) {
- attemptReconnection();
- } else {
- updateConnectionError(t("terminal.websocketAbnormalClose"));
- setIsConnecting(false);
- }
- return;
- }
-
- if (event.code === 1008) {
- console.error("WebSocket authentication failed:", event.reason);
- addLog({
- type: "error",
- stage: "auth",
- message: "Authentication failed - please re-login",
- });
- updateConnectionError("Authentication failed - please re-login");
- setIsConnecting(false);
- shouldNotReconnectRef.current = true;
-
- return;
- }
-
- if (
- !isConnected &&
- event.wasClean &&
- (event.code === 1005 || event.code === 1000)
- ) {
- console.error("[WebSocket] Connection rejected by server");
- addLog({
- type: "error",
- stage: "connection",
- message: t("terminal.connectionRejected"),
- });
- updateConnectionError(t("terminal.connectionRejected"));
- setIsConnecting(false);
- shouldNotReconnectRef.current = true;
- return;
- }
-
- const shouldAttemptReconnection =
- !wasDisconnectedBySSH.current &&
- !isUnmountingRef.current &&
- !shouldNotReconnectRef.current &&
- !isConnectingRef.current;
-
- if (shouldAttemptReconnection) {
- wasDisconnectedBySSH.current = false;
- attemptReconnection();
- } else {
- setIsConnecting(false);
- }
- });
-
- ws.addEventListener("error", (event) => {
- if (currentAttemptId !== connectionAttemptIdRef.current) {
- return;
- }
-
- console.error("[WebSocket] Error:", event);
-
- setIsConnected(false);
- isConnectingRef.current = false;
- updateConnectionError(t("terminal.websocketError"));
- if (terminal) {
- terminal.clear();
- }
- setIsConnecting(false);
-
- if (totpTimeoutRef.current) {
- clearTimeout(totpTimeoutRef.current);
- totpTimeoutRef.current = null;
- }
- });
- }
-
- useEffect(() => {
- if (!terminal || !xtermRef.current || !hostConfig) return;
-
- if (!isAuthenticated) {
- return;
- }
-
- const fontConfig = TERMINAL_FONTS.find(
- (f) => f.value === config.fontFamily,
- );
- const fontFamily = fontConfig?.fallback || TERMINAL_FONTS[0].fallback;
-
- terminal.options = {
- cursorBlink: config.cursorBlink,
- cursorStyle: config.cursorStyle,
- scrollback: config.scrollback,
- fontSize: config.fontSize,
- fontFamily,
- allowTransparency: true,
- convertEol: false,
- windowsMode: false,
- macOptionIsMeta: false,
- macOptionClickForcesSelection: false,
- rightClickSelectsWord: config.rightClickSelectsWord,
- fastScrollModifier: config.fastScrollModifier,
- fastScrollSensitivity: config.fastScrollSensitivity,
- allowProposedApi: true,
- minimumContrastRatio: config.minimumContrastRatio,
- letterSpacing: config.letterSpacing,
- lineHeight: config.lineHeight,
- bellStyle: config.bellStyle as "none" | "sound" | "visual" | "both",
- theme: {
- background: themeColors.background,
- foreground: themeColors.foreground,
- cursor: themeColors.cursor,
- cursorAccent: themeColors.cursorAccent,
- selectionBackground: themeColors.selectionBackground,
- selectionForeground: themeColors.selectionForeground,
- black: themeColors.black,
- red: themeColors.red,
- green: themeColors.green,
- yellow: themeColors.yellow,
- blue: themeColors.blue,
- magenta: themeColors.magenta,
- cyan: themeColors.cyan,
- white: themeColors.white,
- brightBlack: themeColors.brightBlack,
- brightRed: themeColors.brightRed,
- brightGreen: themeColors.brightGreen,
- brightYellow: themeColors.brightYellow,
- brightBlue: themeColors.brightBlue,
- brightMagenta: themeColors.brightMagenta,
- brightCyan: themeColors.brightCyan,
- brightWhite: themeColors.brightWhite,
- },
- };
-
- const fitAddon = new FitAddon();
- const clipboardProvider = new RobustClipboardProvider();
- const clipboardAddon = new ClipboardAddon(undefined, clipboardProvider);
- const unicode11Addon = new Unicode11Addon();
- const webLinksAddon = new WebLinksAddon();
-
- fitAddonRef.current = fitAddon;
- terminal.loadAddon(fitAddon);
- terminal.loadAddon(clipboardAddon);
- terminal.loadAddon(unicode11Addon);
- terminal.loadAddon(webLinksAddon);
-
- terminal.unicode.activeVersion = "11";
-
- terminal.open(xtermRef.current);
-
- const handlePaste = (e: ClipboardEvent) => {
- const text = e.clipboardData?.getData("text");
- if (text) {
- e.preventDefault();
- e.stopPropagation();
- terminal.paste(text);
- }
- };
- xtermRef.current.addEventListener("paste", handlePaste);
-
- const resizeObserver = new ResizeObserver(() => {
- if (resizeTimeout.current) clearTimeout(resizeTimeout.current);
- resizeTimeout.current = setTimeout(() => {
- if (!isVisibleRef.current || !isReady) return;
- performFit();
- }, 150);
- });
-
- resizeObserver.observe(xtermRef.current);
-
- const readyFonts =
- (document as { fonts?: { ready?: Promise<unknown> } }).fonts
- ?.ready instanceof Promise
- ? (document as { fonts?: { ready?: Promise<unknown> } }).fonts.ready
- : Promise.resolve();
-
- readyFonts.then(() => {
- requestAnimationFrame(() => {
- fitAddon.fit();
- if (terminal && terminal.cols > 0 && terminal.rows > 0) {
- scheduleNotify(terminal.cols, terminal.rows);
- }
- hardRefresh();
-
- const cols = terminal.cols;
- const rows = terminal.rows;
-
- if (isConnectingRef.current) {
- setVisible(true);
- setIsReady(true);
- return;
- }
-
- if (terminal.cols > 0 && terminal.rows > 0) {
- connectToHost(cols, rows);
- }
-
- setVisible(true);
- setIsReady(true);
- });
- });
-
- const currentElement = xtermRef.current;
-
- return () => {
- resizeObserver.disconnect();
- clipboardProvider.dispose();
- currentElement?.removeEventListener("paste", handlePaste);
- if (notifyTimerRef.current) clearTimeout(notifyTimerRef.current);
- if (resizeTimeout.current) clearTimeout(resizeTimeout.current);
- if (pingIntervalRef.current) {
- clearInterval(pingIntervalRef.current);
- pingIntervalRef.current = null;
- }
- webSocketRef.current?.close();
- setVisible(false);
- setIsReady(false);
- isFittingRef.current = false;
- };
- }, [xtermRef, terminal, hostConfig, isAuthenticated, isDarkMode]);
-
- useEffect(() => {
- return () => {
- isUnmountingRef.current = true;
- shouldNotReconnectRef.current = true;
- isReconnectingRef.current = false;
- setIsConnecting(false);
- if (reconnectTimeoutRef.current)
- clearTimeout(reconnectTimeoutRef.current);
- if (connectionTimeoutRef.current)
- clearTimeout(connectionTimeoutRef.current);
- if (totpTimeoutRef.current) clearTimeout(totpTimeoutRef.current);
- if (warpgateTimeoutRef.current)
- clearTimeout(warpgateTimeoutRef.current);
- if (pingIntervalRef.current) {
- clearInterval(pingIntervalRef.current);
- pingIntervalRef.current = null;
- }
- webSocketRef.current?.close();
- };
- }, []);
-
- useEffect(() => {
- if (!isVisible || !isReady || !fitAddonRef.current || !terminal) {
- return;
- }
-
- const fitTimeout = setTimeout(() => {
- performFit();
- }, 100);
-
- return () => clearTimeout(fitTimeout);
- }, [isVisible, isReady, terminal]);
-
- const hasConnectionError = !!connectionError;
-
- return (
- <div className="h-full w-full relative" style={{ backgroundColor }}>
- <div
- ref={xtermRef}
- className="h-full w-full m-1 overflow-hidden"
- style={{
- visibility:
- isConnected && isReady && !connectionError ? "visible" : "hidden",
- }}
- />
-
- <SimpleLoader
- visible={isConnecting && !isConnectionLogExpanded}
- message={t("terminal.connecting")}
- backgroundColor={backgroundColor}
- />
-
- <ConnectionLog
- isConnecting={isConnecting}
- isConnected={isConnected}
- hasConnectionError={hasConnectionError}
- position={hasConnectionError ? "top" : "bottom"}
- />
-
- <TOTPDialog
- isOpen={totpRequired}
- prompt={totpPrompt}
- onSubmit={handleTotpSubmit}
- onCancel={handleTotpCancel}
- backgroundColor={backgroundColor}
- />
-
- <SSHAuthDialog
- isOpen={showAuthDialog}
- reason={authDialogReason}
- onSubmit={handleAuthDialogSubmit}
- onCancel={handleAuthDialogCancel}
- hostInfo={{
- ip: hostConfig.ip,
- port: hostConfig.port,
- username: hostConfig.username,
- name: hostConfig.name,
- }}
- backgroundColor={backgroundColor}
- />
-
- <PassphraseDialog
- isOpen={showPassphraseDialog}
- onSubmit={handlePassphraseSubmit}
- onCancel={handlePassphraseCancel}
- hostInfo={{
- ip: hostConfig.ip,
- port: hostConfig.port,
- username: hostConfig.username,
- name: hostConfig.name,
- }}
- backgroundColor={backgroundColor}
- />
-
- <WarpgateDialog
- isOpen={warpgateAuthRequired}
- url={warpgateAuthUrl}
- securityKey={warpgateSecurityKey}
- onContinue={handleWarpgateContinue}
- onCancel={handleWarpgateCancel}
- onOpenUrl={handleWarpgateOpenUrl}
- backgroundColor={backgroundColor}
- />
- </div>
- );
- },
-);
-
-export const Terminal = forwardRef<TerminalHandle, SSHTerminalProps>(
- function Terminal(props, ref) {
- return (
- <ConnectionLogProvider>
- <TerminalInner {...props} ref={ref} />
- </ConnectionLogProvider>
- );
- },
-);
-
-const style = document.createElement("style");
-style.innerHTML = `
-@font-face {
- font-family: 'Caskaydia Cove Nerd Font Mono';
- src: url('./fonts/CaskaydiaCoveNerdFontMono-Regular.ttf') format('truetype');
- font-weight: normal;
- font-style: normal;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Caskaydia Cove Nerd Font Mono';
- src: url('./fonts/CaskaydiaCoveNerdFontMono-Bold.ttf') format('truetype');
- font-weight: bold;
- font-style: normal;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Caskaydia Cove Nerd Font Mono';
- src: url('./fonts/CaskaydiaCoveNerdFontMono-Italic.ttf') format('truetype');
- font-weight: normal;
- font-style: italic;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Caskaydia Cove Nerd Font Mono';
- src: url('./fonts/CaskaydiaCoveNerdFontMono-BoldItalic.ttf') format('truetype');
- font-weight: bold;
- font-style: italic;
- font-display: swap;
-}
-
-.xterm .xterm-viewport::-webkit-scrollbar {
- width: 8px;
- background: transparent;
-}
-.xterm .xterm-viewport::-webkit-scrollbar-thumb {
- background: rgba(0,0,0,0.3);
- border-radius: 4px;
-}
-.xterm .xterm-viewport::-webkit-scrollbar-thumb:hover {
- background: rgba(0,0,0,0.5);
-}
-.xterm .xterm-viewport {
- scrollbar-width: thin;
- scrollbar-color: rgba(0,0,0,0.3) transparent;
-}
-
-.dark .xterm .xterm-viewport::-webkit-scrollbar-thumb {
- background: rgba(255,255,255,0.3);
-}
-.dark .xterm .xterm-viewport::-webkit-scrollbar-thumb:hover {
- background: rgba(255,255,255,0.5);
-}
-.dark .xterm .xterm-viewport {
- scrollbar-color: rgba(255,255,255,0.3) transparent;
-}
-
-.xterm {
- font-feature-settings: "liga" 0, "calt" 0;
- text-rendering: optimizeLegibility;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
-}
-
-.xterm .xterm-screen {
- font-family: 'Caskaydia Cove Nerd Font Mono', 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace !important;
- font-variant-ligatures: none;
-}
-
-.xterm .xterm-screen .xterm-char {
- font-feature-settings: "liga" 0, "calt" 0;
-}
-`;
-document.head.appendChild(style);
diff --git a/src/ui/mobile/apps/terminal/TerminalKeyboard.tsx b/src/ui/mobile/apps/terminal/TerminalKeyboard.tsx
deleted file mode 100644
index b34388264..000000000
--- a/src/ui/mobile/apps/terminal/TerminalKeyboard.tsx
+++ /dev/null
@@ -1,213 +0,0 @@
-import React, { useState, useCallback, useEffect } from "react";
-import Keyboard from "react-simple-keyboard";
-import "react-simple-keyboard/build/css/index.css";
-import "./kb-dark-theme.css";
-import "./kb-light-theme.css";
-import { useTheme } from "@/components/theme-provider";
-
-interface TerminalKeyboardProps {
- onSendInput: (input: string) => void;
- onLayoutChange: () => void;
-}
-
-export function TerminalKeyboard({
- onSendInput,
- onLayoutChange,
-}: TerminalKeyboardProps) {
- const [layoutName, setLayoutName] = useState("default");
- const [isCtrl, setIsCtrl] = useState(false);
- const [isAlt, setIsAlt] = useState(false);
- const { theme: appTheme } = useTheme();
-
- const isDarkMode =
- appTheme === "dark" ||
- (appTheme === "system" &&
- window.matchMedia("(prefers-color-scheme: dark)").matches);
-
- useEffect(() => {
- if (onLayoutChange) {
- const timeoutId = setTimeout(() => onLayoutChange(), 100);
- return () => clearTimeout(timeoutId);
- }
- }, [layoutName, onLayoutChange]);
-
- const onKeyPress = useCallback(
- (button: string) => {
- if (button === "{shift}") {
- setLayoutName("shift");
- return;
- }
- if (button === "{unshift}") {
- setLayoutName("default");
- return;
- }
- if (button === "{more}") {
- setLayoutName("more");
- return;
- }
- if (button === "{less}") {
- setLayoutName("default");
- return;
- }
- if (button === "{hide}") {
- setLayoutName("hide");
- return;
- }
- if (button === "{unhide}") {
- setLayoutName("default");
- return;
- }
-
- if (button === "{ctrl}") {
- setIsCtrl((prev) => !prev);
- return;
- }
- if (button === "{alt}") {
- setIsAlt((prev) => !prev);
- return;
- }
-
- let input = button;
-
- const specialKeyMap: { [key: string]: string } = {
- "{esc}": "\x1b",
- "{enter}": "\r",
- "{tab}": "\t",
- "{backspace}": "\x7f",
- "{arrowUp}": "\x1b[A",
- "{arrowDown}": "\x1b[B",
- "{arrowRight}": "\x1b[C",
- "{arrowLeft}": "\x1b[D",
- "{home}": "\x1b[H",
- "{end}": "\x1b[F",
- "{pgUp}": "\x1b[5~",
- "{pgDn}": "\x1b[6~",
- F1: "\x1bOP",
- F2: "\x1bOQ",
- F3: "\x1bOR",
- F4: "\x1bOS",
- F5: "\x1b[15~",
- F6: "\x1b[17~",
- F7: "\x1b[18~",
- F8: "\x1b[19~",
- F9: "\x1b[20~",
- F10: "\x1b[21~",
- F11: "\x1b[23~",
- F12: "\x1b[24~",
- "{space}": " ",
- };
-
- if (specialKeyMap[input]) {
- input = specialKeyMap[input];
- }
-
- if (isCtrl) {
- if (input.length === 1) {
- const charCode = input.toUpperCase().charCodeAt(0);
- if (charCode >= 64 && charCode <= 95) {
- input = String.fromCharCode(charCode - 64);
- }
- }
- }
-
- if (isAlt) {
- input = `\x1b${input}`;
- }
-
- try {
- if (navigator.vibrate) {
- navigator.vibrate(20);
- }
- } catch (error) {
- console.error("Keyboard operation failed:", error);
- }
-
- onSendInput(input);
- },
- [onSendInput, isCtrl, isAlt],
- );
-
- const buttonTheme = [
- {
- class: "hg-space-big",
- buttons: "{space}",
- },
- {
- class: "hg-space-medium",
- buttons: "{enter} {backspace}",
- },
- {
- class: "hg-space-small",
- buttons: "{hide} {unhide} {less} {more}",
- },
- ];
-
- if (isCtrl) {
- buttonTheme.push({ class: "key-active", buttons: "{ctrl}" });
- }
- if (isAlt) {
- buttonTheme.push({ class: "key-active", buttons: "{alt}" });
- }
-
- return (
- <div className="z-10">
- <Keyboard
- layout={{
- default: [
- "{esc} {tab} {ctrl} {alt} {arrowLeft} {arrowRight} {arrowUp} {arrowDown}",
- "q w e r t y u i o p",
- "a s d f g h j k l",
- "{shift} z x c v b n m {backspace}",
- "{hide} {more} {space} {enter}",
- ],
- shift: [
- "{esc} {tab} {ctrl} {alt} {arrowLeft} {arrowRight} {arrowUp} {arrowDown}",
- "Q W E R T Y U I O P",
- "A S D F G H J K L",
- "{unshift} Z X C V B N M {backspace}",
- "{hide} {more} {space} {enter}",
- ],
- more: [
- "{esc} {tab} {ctrl} {alt} {end} {home} {pgUp} {pgDn}",
- "1 2 3 4 5 6 7 8 9 0",
- "! @ # $ % ^ & * ( ) _ + -",
- "[ ] { } | \\ ; : ' \" , . / < >",
- "F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12",
- "{arrowLeft} {arrowRight} {arrowUp} {arrowDown} {backspace}",
- "{hide} {less} {space} {enter}",
- ],
- hide: ["{unhide}"],
- }}
- layoutName={layoutName}
- onKeyPress={onKeyPress}
- display={{
- "{shift}": "up",
- "{unshift}": "dn",
- "{backspace}": "back",
- "{more}": "more",
- "{less}": "less",
- "{space}": "space",
- "{enter}": "enter",
- "{arrowLeft}": "←",
- "{arrowRight}": "→",
- "{arrowUp}": "↑",
- "{arrowDown}": "↓",
- "{hide}": "hide",
- "{unhide}": "unhide",
- "{esc}": "esc",
- "{tab}": "tab",
- "{ctrl}": "ctrl",
- "{alt}": "alt",
- "{end}": "end",
- "{home}": "home",
- "{pgUp}": "pgUp",
- "{pgDn}": "pgDn",
- }}
- theme={`hg-theme-default ${isDarkMode ? "dark-theme" : "light-theme"}`}
- useTouchEvents={true}
- disableButtonHold={true}
- buttonTheme={buttonTheme}
- />
- </div>
- );
-}
diff --git a/src/ui/mobile/apps/terminal/kb-dark-theme.css b/src/ui/mobile/apps/terminal/kb-dark-theme.css
deleted file mode 100644
index d102e2341..000000000
--- a/src/ui/mobile/apps/terminal/kb-dark-theme.css
+++ /dev/null
@@ -1,40 +0,0 @@
-.simple-keyboard.dark-theme {
- background-color: rgb(24, 24, 27);
- border-radius: 0;
-}
-
-.simple-keyboard.dark-theme .hg-button {
- height: 50px;
- display: flex;
- justify-content: center;
- align-items: center;
- background: rgba(0, 0, 0, 0.5);
- color: #bfbfbf;
- border-bottom-color: rgb(122, 122, 122);
-}
-
-.simple-keyboard.dark-theme .hg-button:active {
- background: rgba(83, 83, 83, 0.5);
- color: #bfbfbf;
-}
-
-#root .simple-keyboard.dark-theme + .simple-keyboard-preview {
- background: rgba(83, 83, 83, 0.5);
-}
-
-.dark-theme .hg-button.key-active {
- background: rgba(126, 126, 126, 0.5);
- color: white;
-}
-
-.hg-space-big {
- width: 100px;
-}
-
-.hg-space-medium {
- width: 70px;
-}
-
-.hg-space-small {
- width: 1px;
-}
diff --git a/src/ui/mobile/apps/terminal/kb-light-theme.css b/src/ui/mobile/apps/terminal/kb-light-theme.css
deleted file mode 100644
index c5101d600..000000000
--- a/src/ui/mobile/apps/terminal/kb-light-theme.css
+++ /dev/null
@@ -1,29 +0,0 @@
-.simple-keyboard.light-theme {
- background-color: #f3f4f6;
- border-radius: 0;
-}
-
-.simple-keyboard.light-theme .hg-button {
- height: 50px;
- display: flex;
- justify-content: center;
- align-items: center;
- background: #ffffff;
- color: #18181b;
- border-bottom-color: #d1d5db;
- border: 1px solid #e5e7eb;
-}
-
-.simple-keyboard.light-theme .hg-button:active {
- background: #e5e7eb;
- color: #18181b;
-}
-
-#root .simple-keyboard.light-theme + .simple-keyboard-preview {
- background: #e5e7eb;
-}
-
-.light-theme .hg-button.key-active {
- background: #d1d5db;
- color: #18181b;
-}
diff --git a/src/ui/mobile/authentication/Auth.tsx b/src/ui/mobile/authentication/Auth.tsx
deleted file mode 100644
index 405d48172..000000000
--- a/src/ui/mobile/authentication/Auth.tsx
+++ /dev/null
@@ -1,1247 +0,0 @@
-import React, { useState, useEffect } from "react";
-import { cn } from "@/lib/utils.ts";
-import { Button } from "@/components/ui/button.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import { Checkbox } from "@/components/ui/checkbox.tsx";
-import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert.tsx";
-import { useTranslation } from "react-i18next";
-import { LanguageSwitcher } from "@/ui/desktop/user/LanguageSwitcher.tsx";
-import { toast } from "sonner";
-import { Smartphone } from "lucide-react";
-import {
- registerUser,
- loginUser,
- getUserInfo,
- getRegistrationAllowed,
- getPasswordLoginAllowed,
- getOIDCConfig,
- getSetupRequired,
- initiatePasswordReset,
- verifyPasswordResetCode,
- completePasswordReset,
- getOIDCAuthorizeUrl,
- verifyTOTPLogin,
- getCookie,
- getCurrentToken,
-} from "@/ui/main-axios.ts";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
-
-type ReactNativeWindow = Window & {
- ReactNativeWebView?: {
- postMessage: (message: string) => void;
- };
-};
-
-function isReactNativeWebView(): boolean {
- return (
- typeof window !== "undefined" &&
- !!(window as ReactNativeWindow).ReactNativeWebView
- );
-}
-
-async function postAuthSuccessToWebView() {
- if (!isReactNativeWebView()) {
- return;
- }
-
- try {
- // HTTP-only cookies can't be read via JS — fetch token from the API
- let token = getCookie("jwt") || localStorage.getItem("jwt");
- if (!token) {
- token = await getCurrentToken();
- }
- (window as ReactNativeWindow).ReactNativeWebView?.postMessage(
- JSON.stringify({
- type: "AUTH_SUCCESS",
- token,
- source: "explicit",
- platform: "mobile",
- timestamp: Date.now(),
- }),
- );
- } catch (error) {
- console.error("Auth operation failed:", error);
- }
-}
-
-interface AuthProps extends React.ComponentProps<"div"> {
- setLoggedIn: (loggedIn: boolean) => void;
- setIsAdmin: (isAdmin: boolean) => void;
- setUsername: (username: string | null) => void;
- setUserId: (userId: string | null) => void;
- loggedIn: boolean;
- authLoading: boolean;
- dbError: string | null;
- setDbError: (error: string | null) => void;
- onAuthSuccess: (authData: {
- isAdmin: boolean;
- username: string | null;
- userId: string | null;
- }) => void;
-}
-
-export function Auth({
- className,
- setLoggedIn,
- setIsAdmin,
- setUsername,
- setUserId,
- loggedIn,
- authLoading,
- dbError,
- setDbError,
- onAuthSuccess,
- ...props
-}: AuthProps) {
- const { t } = useTranslation();
- const [tab, setTab] = useState<"login" | "signup" | "external" | "reset">(
- "login",
- );
- const [localUsername, setLocalUsername] = useState("");
- const [password, setPassword] = useState("");
- const [signupConfirmPassword, setSignupConfirmPassword] = useState("");
- const [rememberMe, setRememberMe] = useState(() => {
- try {
- const saved = localStorage.getItem("rememberMe");
- return saved === "true";
- } catch {
- return false;
- }
- });
- const [loading, setLoading] = useState(false);
- const [oidcLoading, setOidcLoading] = useState(false);
- const [error, setError] = useState<string | null>(null);
- const [internalLoggedIn, setInternalLoggedIn] = useState(false);
- const [firstUser, setFirstUser] = useState(false);
- const [firstUserToastShown, setFirstUserToastShown] = useState(false);
- const [registrationAllowed, setRegistrationAllowed] = useState(true);
- const [passwordLoginAllowed, setPasswordLoginAllowed] = useState(true);
- const [oidcConfigured, setOidcConfigured] = useState(false);
-
- const [resetStep, setResetStep] = useState<
- "initiate" | "verify" | "newPassword"
- >("initiate");
- const [resetCode, setResetCode] = useState("");
- const [newPassword, setNewPassword] = useState("");
- const [confirmPassword, setConfirmPassword] = useState("");
- const [tempToken, setTempToken] = useState("");
- const [resetLoading, setResetLoading] = useState(false);
- const [resetSuccess, setResetSuccess] = useState(false);
-
- const [totpRequired, setTotpRequired] = useState(false);
- const [totpCode, setTotpCode] = useState("");
- const [totpTempToken, setTotpTempToken] = useState("");
- const [totpLoading, setTotpLoading] = useState(false);
- const [mobileAuthSuccess, setMobileAuthSuccess] = useState(false);
- const totpInputRef = React.useRef<HTMLInputElement>(null);
-
- useEffect(() => {
- setInternalLoggedIn(loggedIn);
- if (loggedIn && !mobileAuthSuccess) {
- // React Native may not have injected ReactNativeWebView yet — poll briefly
- const tryPostAuth = (attemptsLeft: number) => {
- if (isReactNativeWebView()) {
- postAuthSuccessToWebView();
- setMobileAuthSuccess(true);
- } else if (attemptsLeft > 0) {
- setTimeout(() => tryPostAuth(attemptsLeft - 1), 100);
- }
- };
- tryPostAuth(10);
- }
- }, [loggedIn, mobileAuthSuccess]);
-
- useEffect(() => {
- if (totpRequired && totpInputRef.current) {
- totpInputRef.current.focus();
- }
- }, [totpRequired]);
-
- useEffect(() => {
- try {
- localStorage.setItem("rememberMe", rememberMe.toString());
- } catch {
- // expected - localStorage might not be available
- }
- }, [rememberMe]);
-
- useEffect(() => {
- getRegistrationAllowed().then((res) => {
- setRegistrationAllowed(res.allowed);
- });
- }, []);
-
- useEffect(() => {
- getPasswordLoginAllowed()
- .then((res) => {
- setPasswordLoginAllowed(res.allowed);
- })
- .catch((err) => {
- if (err.code !== "NO_SERVER_CONFIGURED") {
- console.error("Failed to fetch password login status:", err);
- }
- });
- }, []);
-
- useEffect(() => {
- if (!passwordLoginAllowed && oidcConfigured && tab !== "external") {
- setTab("external");
- }
- }, [passwordLoginAllowed, oidcConfigured, tab]);
-
- useEffect(() => {
- getOIDCConfig()
- .then((response) => {
- if (response) {
- setOidcConfigured(true);
- } else {
- setOidcConfigured(false);
- }
- })
- .catch((error) => {
- if (error.response?.status === 404) {
- setOidcConfigured(false);
- } else {
- setOidcConfigured(false);
- }
- });
- }, []);
-
- useEffect(() => {
- getSetupRequired()
- .then((res) => {
- if (res.setup_required) {
- setFirstUser(true);
- setTab("signup");
- if (!firstUserToastShown) {
- toast.info(t("auth.firstUserMessage"));
- setFirstUserToastShown(true);
- }
- } else {
- setFirstUser(false);
- }
- setDbError(null);
- })
- .catch(() => {
- setDbError(t("errors.databaseConnection"));
- });
- }, [setDbError, firstUserToastShown]);
-
- async function handleSubmit(e: React.FormEvent) {
- e.preventDefault();
- setError(null);
- setLoading(true);
-
- if (!localUsername.trim()) {
- toast.error(t("errors.requiredField"));
- setLoading(false);
- return;
- }
-
- if (!passwordLoginAllowed && !firstUser) {
- toast.error(t("errors.passwordLoginDisabled"));
- setLoading(false);
- return;
- }
-
- try {
- let res;
- if (tab === "login") {
- res = await loginUser(localUsername, password, rememberMe);
- } else {
- if (password !== signupConfirmPassword) {
- toast.error(t("errors.passwordMismatch"));
- setLoading(false);
- return;
- }
- if (password.length < 6) {
- toast.error(t("errors.minLength", { min: 6 }));
- setLoading(false);
- return;
- }
-
- await registerUser(localUsername, password);
- res = await loginUser(localUsername, password, rememberMe);
- }
-
- if (res.requires_totp) {
- setTotpRequired(true);
- setTotpTempToken(res.temp_token);
- setLoading(false);
- return;
- }
-
- if (!res || !res.success) {
- throw new Error(t("errors.loginFailed"));
- }
-
- const [meRes] = await Promise.all([getUserInfo()]);
-
- setIsAdmin(!!meRes.is_admin);
- setUsername(meRes.username || null);
- setUserId(meRes.userId || null);
- setDbError(null);
- postAuthSuccessToWebView();
-
- if (isReactNativeWebView()) {
- setMobileAuthSuccess(true);
- setLoading(false);
- return;
- }
-
- setLoggedIn(true);
- onAuthSuccess({
- isAdmin: !!meRes.is_admin,
- username: meRes.username || null,
- userId: meRes.userId || null,
- });
-
- setInternalLoggedIn(true);
- if (tab === "signup") {
- setSignupConfirmPassword("");
- toast.success(t("messages.registrationSuccess"));
- } else {
- toast.success(t("messages.loginSuccess"));
- }
- setTotpRequired(false);
- setTotpCode("");
- setTotpTempToken("");
- } catch (err: unknown) {
- const error = err as {
- message?: string;
- response?: { data?: { error?: string } };
- };
- const errorMessage =
- error?.response?.data?.error ||
- error?.message ||
- t("errors.unknownError");
- setError(errorMessage);
- setInternalLoggedIn(false);
- setLoggedIn(false);
- setIsAdmin(false);
- setUsername(null);
- setUserId(null);
- if (error?.response?.data?.error?.includes("Database")) {
- setDbError(t("errors.databaseConnection"));
- } else {
- setDbError(null);
- }
- } finally {
- setLoading(false);
- }
- }
-
- async function handleInitiatePasswordReset() {
- setError(null);
- setResetLoading(true);
- try {
- await initiatePasswordReset(localUsername);
- setResetStep("verify");
- toast.success(t("messages.resetCodeSent"));
- } catch (err: unknown) {
- const error = err as {
- message?: string;
- response?: { data?: { error?: string } };
- };
- const errorMessage =
- error?.response?.data?.error ||
- error?.message ||
- t("errors.failedPasswordReset");
- setError(errorMessage);
- } finally {
- setResetLoading(false);
- }
- }
-
- async function handleVerifyResetCode() {
- setError(null);
- setResetLoading(true);
- try {
- const response = await verifyPasswordResetCode(localUsername, resetCode);
- setTempToken(response.tempToken);
- setResetStep("newPassword");
- toast.success(t("messages.codeVerified"));
- } catch (err: unknown) {
- const error = err as {
- response?: {
- data?: {
- error?: string;
- code?: string;
- remainingTime?: number;
- remainingAttempts?: number;
- };
- };
- };
- const errorCode = error?.response?.data?.code;
- const remainingTime = error?.response?.data?.remainingTime;
- const remainingAttempts = error?.response?.data?.remainingAttempts;
-
- let errorMessage =
- error?.response?.data?.error || t("errors.failedVerifyCode");
-
- if (errorCode === "RESET_CODE_RATE_LIMITED") {
- if (remainingTime) {
- errorMessage = t("errors.resetCodeRateLimitedWithTime", {
- time: remainingTime,
- });
- } else {
- errorMessage = t("errors.resetCodeRateLimited");
- }
- toast.error(errorMessage);
- } else if (
- remainingAttempts !== undefined &&
- remainingAttempts <= 2 &&
- remainingAttempts > 0
- ) {
- errorMessage = `${errorMessage} (${remainingAttempts} ${t("auth.attemptsRemaining")})`;
- }
-
- setError(errorMessage);
- } finally {
- setResetLoading(false);
- }
- }
-
- async function handleCompletePasswordReset() {
- setError(null);
- setResetLoading(true);
-
- if (newPassword !== confirmPassword) {
- toast.error(t("errors.passwordMismatch"));
- setResetLoading(false);
- return;
- }
-
- if (newPassword.length < 6) {
- toast.error(t("errors.minLength", { min: 6 }));
- setResetLoading(false);
- return;
- }
-
- try {
- await completePasswordReset(localUsername, tempToken, newPassword);
-
- setResetStep("initiate");
- setResetCode("");
- setNewPassword("");
- setConfirmPassword("");
- setTempToken("");
- setError(null);
-
- setResetSuccess(true);
- toast.success(t("messages.passwordResetSuccess"));
-
- setTab("login");
- resetPasswordState();
- } catch (err: unknown) {
- const error = err as { response?: { data?: { error?: string } } };
- const errorMessage =
- error?.response?.data?.error || t("errors.failedCompleteReset");
- setError(errorMessage);
- } finally {
- setResetLoading(false);
- }
- }
-
- function resetPasswordState() {
- setResetStep("initiate");
- setResetCode("");
- setNewPassword("");
- setConfirmPassword("");
- setTempToken("");
- setError(null);
- setResetSuccess(false);
- setSignupConfirmPassword("");
- }
-
- function clearFormFields() {
- setPassword("");
- setSignupConfirmPassword("");
- setError(null);
- }
-
- async function handleTOTPVerification() {
- if (totpCode.length !== 6) {
- toast.error(t("auth.enterCode"));
- return;
- }
-
- setError(null);
- setTotpLoading(true);
-
- try {
- const res = await verifyTOTPLogin(totpTempToken, totpCode, rememberMe);
-
- if (!res || !res.success) {
- throw new Error(t("errors.loginFailed"));
- }
-
- setIsAdmin(!!res.is_admin);
- setUsername(res.username || null);
- setUserId(res.userId || null);
- setDbError(null);
-
- postAuthSuccessToWebView();
-
- if (isReactNativeWebView()) {
- setMobileAuthSuccess(true);
- setTotpLoading(false);
- return;
- }
-
- setLoggedIn(true);
- onAuthSuccess({
- isAdmin: !!res.is_admin,
- username: res.username || null,
- userId: res.userId || null,
- });
-
- setInternalLoggedIn(true);
- setTotpRequired(false);
- setTotpCode("");
- setTotpTempToken("");
- toast.success(t("messages.loginSuccess"));
- } catch (err: unknown) {
- const error = err as {
- message?: string;
- response?: {
- data?: {
- code?: string;
- error?: string;
- remainingTime?: number;
- remainingAttempts?: number;
- };
- };
- };
- const errorCode = error?.response?.data?.code;
- const remainingTime = error?.response?.data?.remainingTime;
- const remainingAttempts = error?.response?.data?.remainingAttempts;
-
- let errorMessage =
- error?.response?.data?.error ||
- error?.message ||
- t("errors.invalidTotpCode");
-
- if (errorCode === "SESSION_EXPIRED") {
- setTotpRequired(false);
- setTotpCode("");
- setTotpTempToken("");
- setTab("login");
- toast.error(t("errors.sessionExpired"));
- } else if (errorCode === "TOTP_RATE_LIMITED") {
- if (remainingTime) {
- errorMessage = t("errors.totpRateLimitedWithTime", {
- time: remainingTime,
- });
- } else {
- errorMessage = t("errors.totpRateLimited");
- }
- setError(errorMessage);
- toast.error(errorMessage);
- } else {
- if (
- remainingAttempts !== undefined &&
- remainingAttempts <= 2 &&
- remainingAttempts > 0
- ) {
- errorMessage = `${errorMessage} (${remainingAttempts} ${t("auth.attemptsRemaining")})`;
- }
- setError(errorMessage);
- }
- } finally {
- setTotpLoading(false);
- }
- }
-
- async function handleOIDCLogin() {
- setError(null);
- setOidcLoading(true);
- try {
- const authResponse = await getOIDCAuthorizeUrl(rememberMe);
- const { auth_url: authUrl } = authResponse;
-
- if (!authUrl || authUrl === "undefined") {
- throw new Error(t("errors.invalidAuthUrl"));
- }
-
- window.location.replace(authUrl);
- } catch (err: unknown) {
- const error = err as {
- message?: string;
- response?: { data?: { error?: string } };
- };
- const errorMessage =
- error?.response?.data?.error ||
- error?.message ||
- t("errors.failedOidcLogin");
- setError(errorMessage);
- setOidcLoading(false);
- }
- }
-
- useEffect(() => {
- const urlParams = new URLSearchParams(window.location.search);
- const success = urlParams.get("success");
- const error = urlParams.get("error");
-
- if (error) {
- let errorMessage: string;
- if (error === "registration_disabled") {
- errorMessage = t("messages.registrationDisabled");
- } else if (error === "user_not_allowed") {
- errorMessage = t("messages.userNotAllowed");
- } else {
- errorMessage = `${t("errors.oidcAuthFailed")}: ${error}`;
- }
- setError(errorMessage);
- setOidcLoading(false);
- window.history.replaceState({}, document.title, window.location.pathname);
- return;
- }
-
- if (success) {
- setOidcLoading(true);
- setError(null);
-
- window.history.replaceState({}, document.title, window.location.pathname);
-
- if (isReactNativeWebView()) {
- postAuthSuccessToWebView();
- setMobileAuthSuccess(true);
- setOidcLoading(false);
- return;
- }
-
- getUserInfo()
- .then((meRes) => {
- setIsAdmin(!!meRes.is_admin);
- setUsername(meRes.username || null);
- setUserId(meRes.userId || null);
- setDbError(null);
-
- setLoggedIn(true);
- onAuthSuccess({
- isAdmin: !!meRes.is_admin,
- username: meRes.username || null,
- userId: meRes.userId || null,
- });
-
- setInternalLoggedIn(true);
- })
- .catch((err) => {
- console.error("Failed to get user info after OIDC callback:", err);
- setError(t("errors.failedUserInfo"));
- setInternalLoggedIn(false);
- setLoggedIn(false);
- setIsAdmin(false);
- setUsername(null);
- setUserId(null);
- })
- .finally(() => {
- setOidcLoading(false);
- });
- }
- }, []);
-
- const Spinner = (
- <svg
- className="animate-spin mr-2 h-4 w-4 text-foreground inline-block"
- viewBox="0 0 24 24"
- >
- <circle
- className="opacity-25"
- cx="12"
- cy="12"
- r="10"
- stroke="currentColor"
- strokeWidth="4"
- fill="none"
- />
- <path
- className="opacity-75"
- fill="currentColor"
- d="M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"
- />
- </svg>
- );
-
- if (isReactNativeWebView() && mobileAuthSuccess) {
- return (
- <div
- className={`w-full max-w-md flex flex-col bg-canvas overflow-y-auto thin-scrollbar my-2 ${className || ""}`}
- style={{ maxHeight: "calc(100vh - 1rem)" }}
- {...props}
- >
- <div className="flex flex-col items-center justify-center min-h-[400px] gap-4 px-4">
- <div className="w-16 h-16 rounded-full bg-green-500/20 flex items-center justify-center">
- <svg
- className="w-10 h-10 text-green-500"
- fill="none"
- stroke="currentColor"
- viewBox="0 0 24 24"
- >
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth={2}
- d="M5 13l4 4L19 7"
- />
- </svg>
- </div>
- <div className="text-center">
- <h2 className="text-xl font-bold mb-2">
- {t("messages.loginSuccess")}
- </h2>
- <p className="text-muted-foreground">
- {t("auth.redirectingToApp")}
- </p>
- </div>
- </div>
- </div>
- );
- }
-
- return (
- <div
- className={`w-full max-w-md flex flex-col bg-canvas overflow-y-auto thin-scrollbar my-2 ${className || ""}`}
- style={{ maxHeight: "calc(100vh - 1rem)" }}
- {...props}
- >
- {isReactNativeWebView() && !mobileAuthSuccess && (
- <Alert className="mb-4 border-blue-500 bg-blue-500/10">
- <Smartphone className="h-4 w-4" />
- <AlertTitle>{t("auth.mobileApp")}</AlertTitle>
- <AlertDescription>{t("auth.loggingInToMobileApp")}</AlertDescription>
- </Alert>
- )}
- {!mobileAuthSuccess && error && (
- <Alert variant="destructive" className="mb-4">
- <AlertTitle>{t("common.error", "Error")}</AlertTitle>
- <AlertDescription>{error}</AlertDescription>
- </Alert>
- )}
- {!mobileAuthSuccess && dbError && (
- <Alert variant="destructive" className="mb-4">
- <AlertTitle>Error</AlertTitle>
- <AlertDescription>{dbError}</AlertDescription>
- </Alert>
- )}
- {!mobileAuthSuccess && totpRequired && (
- <div className="flex flex-col gap-5">
- <div className="mb-6 text-center">
- <h2 className="text-xl font-bold mb-1">
- {t("auth.twoFactorAuth")}
- </h2>
- <p className="text-muted-foreground">{t("auth.enterCode")}</p>
- </div>
-
- <div className="flex flex-col gap-2">
- <Label htmlFor="totp-code">{t("auth.verifyCode")}</Label>
- <Input
- ref={totpInputRef}
- id="totp-code"
- name="totp"
- type="text"
- inputMode="numeric"
- pattern="[0-9]*"
- placeholder="000000"
- maxLength={6}
- value={totpCode}
- onChange={(e) => setTotpCode(e.target.value.replace(/\D/g, ""))}
- disabled={totpLoading}
- className="text-center text-2xl tracking-widest font-mono"
- autoComplete="one-time-code"
- />
- <p className="text-xs text-muted-foreground text-center">
- {t("auth.backupCode")}
- </p>
- </div>
-
- <Button
- type="button"
- className="w-full h-11 text-base font-semibold"
- disabled={totpLoading || totpCode.length < 6}
- onClick={handleTOTPVerification}
- >
- {totpLoading ? Spinner : t("auth.verifyCode")}
- </Button>
-
- <Button
- type="button"
- variant="outline"
- className="w-full h-11 text-base font-semibold"
- disabled={totpLoading}
- onClick={() => {
- setTotpRequired(false);
- setTotpCode("");
- setTotpTempToken("");
- setError(null);
- }}
- >
- {t("common.cancel")}
- </Button>
- </div>
- )}
-
- {!mobileAuthSuccess && internalLoggedIn && !authLoading && (
- <div className="flex flex-col gap-5">
- <div className="mb-6 text-center">
- <h2 className="text-xl font-bold mb-1">
- {t("homepage.loggedInTitle")}
- </h2>
- <p className="text-muted-foreground">
- {t("mobile.mobileAppInProgressDesc")}
- </p>
- </div>
-
- <Button
- type="button"
- variant="outline"
- className="w-full h-11 text-base font-semibold"
- onClick={() =>
- window.open("https://docs.termix.site/install", "_blank")
- }
- >
- {t("mobile.viewMobileAppDocs")}
- </Button>
- </div>
- )}
-
- {!mobileAuthSuccess &&
- !internalLoggedIn &&
- !authLoading &&
- !totpRequired && (
- <>
- {(() => {
- const hasLogin = passwordLoginAllowed && !firstUser;
- const hasSignup =
- (passwordLoginAllowed || firstUser) && registrationAllowed;
- const hasOIDC = oidcConfigured;
- const hasAnyAuth = hasLogin || hasSignup || hasOIDC;
-
- if (!hasAnyAuth) {
- return (
- <div className="text-center">
- <h2 className="text-xl font-bold mb-1">
- {t("auth.authenticationDisabled")}
- </h2>
- <p className="text-muted-foreground">
- {t("auth.authenticationDisabledDesc")}
- </p>
- </div>
- );
- }
-
- return (
- <>
- <div className="flex gap-2 mb-6">
- {passwordLoginAllowed && (
- <button
- type="button"
- className={cn(
- "flex-1 py-2 text-base font-medium rounded-md transition-all",
- tab === "login"
- ? "bg-primary text-primary-foreground shadow"
- : "bg-muted text-muted-foreground hover:bg-accent",
- )}
- onClick={() => {
- setTab("login");
- if (tab === "reset") resetPasswordState();
- if (tab === "signup") clearFormFields();
- }}
- aria-selected={tab === "login"}
- disabled={loading || firstUser}
- >
- {t("common.login")}
- </button>
- )}
- {(passwordLoginAllowed || firstUser) &&
- registrationAllowed && (
- <button
- type="button"
- className={cn(
- "flex-1 py-2 text-base font-medium rounded-md transition-all",
- tab === "signup"
- ? "bg-primary text-primary-foreground shadow"
- : "bg-muted text-muted-foreground hover:bg-accent",
- )}
- onClick={() => {
- setTab("signup");
- if (tab === "reset") resetPasswordState();
- if (tab === "login") clearFormFields();
- }}
- aria-selected={tab === "signup"}
- disabled={loading}
- >
- {t("common.register")}
- </button>
- )}
- {oidcConfigured && (
- <button
- type="button"
- className={cn(
- "flex-1 py-2 text-base font-medium rounded-md transition-all",
- tab === "external"
- ? "bg-primary text-primary-foreground shadow"
- : "bg-muted text-muted-foreground hover:bg-accent",
- )}
- onClick={() => {
- setTab("external");
- if (tab === "reset") resetPasswordState();
- if (tab === "login" || tab === "signup")
- clearFormFields();
- }}
- aria-selected={tab === "external"}
- disabled={oidcLoading}
- >
- {t("auth.external")}
- </button>
- )}
- </div>
- <div className="mb-6 text-center">
- <h2 className="text-xl font-bold mb-1">
- {tab === "login"
- ? t("auth.loginTitle")
- : tab === "signup"
- ? t("auth.registerTitle")
- : tab === "external"
- ? t("auth.loginWithExternal")
- : t("auth.forgotPassword")}
- </h2>
- </div>
-
- {tab === "external" || tab === "reset" ? (
- <div className="flex flex-col gap-5">
- {tab === "external" && (
- <>
- <div className="text-center text-muted-foreground mb-4">
- <p>{t("auth.loginWithExternalDesc")}</p>
- </div>
- <div className="flex items-center gap-2">
- <Checkbox
- id="rememberMeOIDC"
- checked={rememberMe}
- onCheckedChange={(checked) =>
- setRememberMe(checked === true)
- }
- />
- <Label htmlFor="rememberMeOIDC">
- {t("auth.rememberMe")}
- </Label>
- </div>
- <Button
- type="button"
- className="w-full h-11 mt-2 text-base font-semibold"
- disabled={oidcLoading}
- onClick={handleOIDCLogin}
- >
- {oidcLoading
- ? Spinner
- : t("auth.loginWithExternal")}
- </Button>
- </>
- )}
- {tab === "reset" && (
- <>
- {resetStep === "initiate" && (
- <>
- <Alert variant="destructive" className="mb-4">
- <AlertTitle>{t("common.warning")}</AlertTitle>
- <AlertDescription>
- {t("auth.dataLossWarning")}
- </AlertDescription>
- </Alert>
- <div className="text-center text-muted-foreground mb-4">
- <p>{t("auth.resetCodeDesc")}</p>
- </div>
- <div className="flex flex-col gap-4">
- <div className="flex flex-col gap-2">
- <Label htmlFor="reset-username">
- {t("common.username")}
- </Label>
- <Input
- id="reset-username"
- type="text"
- required
- className="h-11 text-base"
- value={localUsername}
- onChange={(e) =>
- setLocalUsername(e.target.value)
- }
- disabled={resetLoading}
- />
- </div>
- <Button
- type="button"
- className="w-full h-11 text-base font-semibold"
- disabled={
- resetLoading || !localUsername.trim()
- }
- onClick={handleInitiatePasswordReset}
- >
- {resetLoading
- ? Spinner
- : t("auth.sendResetCode")}
- </Button>
- </div>
- </>
- )}
-
- {resetStep === "verify" && (
- <>
- <div className="text-center text-muted-foreground mb-4">
- <p>
- {t("auth.enterResetCode")}{" "}
- <strong>{localUsername}</strong>
- </p>
- </div>
- <div className="flex flex-col gap-4">
- <div className="flex flex-col gap-2">
- <Label htmlFor="reset-code">
- {t("auth.resetCode")}
- </Label>
- <Input
- id="reset-code"
- type="text"
- required
- maxLength={6}
- className="h-11 text-base text-center text-lg tracking-widest"
- value={resetCode}
- onChange={(e) =>
- setResetCode(
- e.target.value.replace(/\D/g, ""),
- )
- }
- disabled={resetLoading}
- placeholder="000000"
- />
- </div>
- <Button
- type="button"
- className="w-full h-11 text-base font-semibold"
- disabled={
- resetLoading || resetCode.length !== 6
- }
- onClick={handleVerifyResetCode}
- >
- {resetLoading
- ? Spinner
- : t("auth.verifyCodeButton")}
- </Button>
- <Button
- type="button"
- variant="outline"
- className="w-full h-11 text-base font-semibold"
- disabled={resetLoading}
- onClick={() => {
- setResetStep("initiate");
- setResetCode("");
- }}
- >
- {t("common.back")}
- </Button>
- </div>
- </>
- )}
-
- {resetStep === "newPassword" && !resetSuccess && (
- <>
- <div className="text-center text-muted-foreground mb-4">
- <p>
- {t("auth.enterNewPassword")}{" "}
- <strong>{localUsername}</strong>
- </p>
- </div>
- <div className="flex flex-col gap-5">
- <div className="flex flex-col gap-2">
- <Label htmlFor="new-password">
- {t("auth.newPassword")}
- </Label>
- <PasswordInput
- id="new-password"
- required
- className="h-11 text-base focus:ring-2 focus:ring-primary/50 transition-all duration-200"
- value={newPassword}
- onChange={(e) =>
- setNewPassword(e.target.value)
- }
- disabled={resetLoading}
- autoComplete="new-password"
- />
- </div>
- <div className="flex flex-col gap-2">
- <Label htmlFor="confirm-password">
- {t("auth.confirmNewPassword")}
- </Label>
- <PasswordInput
- id="confirm-password"
- required
- className="h-11 text-base focus:ring-2 focus:ring-primary/50 transition-all duration-200"
- value={confirmPassword}
- onChange={(e) =>
- setConfirmPassword(e.target.value)
- }
- disabled={resetLoading}
- autoComplete="new-password"
- />
- </div>
- <Button
- type="button"
- className="w-full h-11 text-base font-semibold"
- disabled={
- resetLoading ||
- !newPassword ||
- !confirmPassword
- }
- onClick={handleCompletePasswordReset}
- >
- {resetLoading
- ? Spinner
- : t("auth.resetPasswordButton")}
- </Button>
- <Button
- type="button"
- variant="outline"
- className="w-full h-11 text-base font-semibold"
- disabled={resetLoading}
- onClick={() => {
- setResetStep("verify");
- setNewPassword("");
- setConfirmPassword("");
- }}
- >
- {t("common.back")}
- </Button>
- </div>
- </>
- )}
- </>
- )}
- </div>
- ) : (
- <form
- className="flex flex-col gap-5"
- onSubmit={handleSubmit}
- >
- <div className="flex flex-col gap-2">
- <Label htmlFor="username">{t("common.username")}</Label>
- <Input
- id="username"
- type="text"
- required
- className="h-11 text-base"
- value={localUsername}
- onChange={(e) => setLocalUsername(e.target.value)}
- disabled={loading || internalLoggedIn}
- />
- </div>
- <div className="flex flex-col gap-2">
- <Label htmlFor="password">{t("common.password")}</Label>
- <PasswordInput
- id="password"
- required
- className="h-11 text-base"
- value={password}
- onChange={(e) => setPassword(e.target.value)}
- disabled={loading || internalLoggedIn}
- />
- </div>
- {tab === "login" && (
- <div className="flex items-center gap-2">
- <Checkbox
- id="rememberMe"
- checked={rememberMe}
- onCheckedChange={(checked) =>
- setRememberMe(checked === true)
- }
- disabled={loading || internalLoggedIn}
- />
- <Label
- htmlFor="rememberMe"
- className="text-sm font-normal cursor-pointer"
- >
- {t("auth.rememberMe")}
- </Label>
- </div>
- )}
- {tab === "signup" && (
- <div className="flex flex-col gap-2">
- <Label htmlFor="signup-confirm-password">
- {t("common.confirmPassword")}
- </Label>
- <PasswordInput
- id="signup-confirm-password"
- required
- className="h-11 text-base"
- value={signupConfirmPassword}
- onChange={(e) =>
- setSignupConfirmPassword(e.target.value)
- }
- disabled={loading || internalLoggedIn}
- />
- </div>
- )}
- <Button
- type="submit"
- className="w-full h-11 mt-2 text-base font-semibold"
- disabled={loading || internalLoggedIn}
- >
- {loading
- ? Spinner
- : tab === "login"
- ? t("common.login")
- : t("auth.signUp")}
- </Button>
- {tab === "login" && (
- <Button
- type="button"
- variant="outline"
- className="w-full h-11 text-base font-semibold"
- disabled={loading || internalLoggedIn}
- onClick={() => {
- setTab("reset");
- resetPasswordState();
- clearFormFields();
- }}
- >
- {t("auth.resetPasswordButton")}
- </Button>
- )}
- </form>
- )}
-
- <div className="mt-6 pt-4 border-t border-edge">
- <div className="flex items-center justify-between">
- <div>
- <Label className="text-sm text-muted-foreground">
- {t("common.language")}
- </Label>
- </div>
- <LanguageSwitcher />
- </div>
- </div>
-
- <div className="mt-4">
- <Button
- type="button"
- variant="outline"
- className="w-full h-11 text-base font-semibold"
- onClick={() =>
- window.open(
- "https://docs.termix.site/install",
- "_blank",
- )
- }
- >
- {t("mobile.viewMobileAppDocs")}
- </Button>
- </div>
- </>
- );
- })()}
- </>
- )}
- </div>
- );
-}
diff --git a/src/ui/mobile/navigation/BottomNavbar.tsx b/src/ui/mobile/navigation/BottomNavbar.tsx
deleted file mode 100644
index 7e9968866..000000000
--- a/src/ui/mobile/navigation/BottomNavbar.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-import { Button } from "@/components/ui/button.tsx";
-import { Menu, X, Terminal as TerminalIcon } from "lucide-react";
-import { useTabs } from "@/ui/mobile/navigation/tabs/TabContext.tsx";
-import { cn } from "@/lib/utils.ts";
-
-interface MenuProps {
- onSidebarOpenClick?: () => void;
-}
-
-export function BottomNavbar({ onSidebarOpenClick }: MenuProps) {
- const { tabs, currentTab, setCurrentTab, removeTab } = useTabs();
-
- return (
- <div className="w-full h-[50px] bg-canvas items-center p-1">
- <div className="flex gap-2 !mb-0.5">
- <Button
- className="w-[40px] h-[40px] flex-shrink-0"
- variant="outline"
- onClick={onSidebarOpenClick}
- >
- <Menu />
- </Button>
- <div className="flex-1 overflow-x-auto whitespace-nowrap thin-scrollbar">
- <div className="inline-flex gap-2">
- {tabs.map((tab) => (
- <div
- key={tab.id}
- className="inline-flex rounded-md shadow-sm"
- role="group"
- >
- <Button
- variant="outline"
- className={cn(
- "h-10 rounded-r-none !px-3 border-1 border-edge",
- tab.id === currentTab && "!bg-deepest !text-foreground",
- )}
- onClick={() => setCurrentTab(tab.id)}
- >
- <TerminalIcon className="mr-1 h-4 w-4" />
- {tab.title}
- </Button>
- <Button
- variant="outline"
- className="h-10 rounded-l-none !px-2 border-1 border-edge"
- onClick={() => removeTab(tab.id)}
- >
- <X className="h-4 w-4" />
- </Button>
- </div>
- ))}
- </div>
- </div>
- </div>
- </div>
- );
-}
diff --git a/src/ui/mobile/navigation/LeftSidebar.tsx b/src/ui/mobile/navigation/LeftSidebar.tsx
deleted file mode 100644
index 8ef272ad7..000000000
--- a/src/ui/mobile/navigation/LeftSidebar.tsx
+++ /dev/null
@@ -1,289 +0,0 @@
-import {
- Sidebar,
- SidebarContent,
- SidebarFooter,
- SidebarGroup,
- SidebarGroupLabel,
- SidebarHeader,
- SidebarMenu,
- SidebarMenuButton,
- SidebarMenuItem,
- SidebarProvider,
-} from "@/components/ui/sidebar.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { ChevronUp, Menu, User2 } from "lucide-react";
-import React, { useState, useEffect, useMemo, useCallback } from "react";
-import { Separator } from "@/components/ui/separator.tsx";
-import { FolderCard } from "@/ui/mobile/navigation/hosts/FolderCard.tsx";
-import { getSSHHosts, logoutUser } from "@/ui/main-axios.ts";
-import { useTranslation } from "react-i18next";
-import { useTheme } from "@/components/theme-provider";
-import { Input } from "@/components/ui/input.tsx";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from "@radix-ui/react-dropdown-menu";
-
-interface SSHHost {
- id: number;
- name: string;
- ip: string;
- port: number;
- username: string;
- folder: string;
- tags: string[];
- pin: boolean;
- authType: string;
- connectionType: string;
- password?: string;
- key?: string;
- keyPassword?: string;
- keyType?: string;
- enableTerminal: boolean;
- enableTunnel: boolean;
- enableFileManager: boolean;
- defaultPath: string;
- tunnelConnections: Array<{
- sourcePort: number;
- endpointPort: number;
- endpointHost: string;
- maxRetries: number;
- retryInterval: number;
- autoStart: boolean;
- }>;
- createdAt: string;
- updatedAt: string;
-}
-
-interface LeftSidebarProps {
- isSidebarOpen: boolean;
- setIsSidebarOpen: (type: boolean) => void;
- onHostConnect: () => void;
- disabled?: boolean;
- username?: string | null;
-}
-
-async function handleLogout() {
- try {
- await logoutUser();
- window.location.reload();
- } catch (error) {
- console.error("Logout failed:", error);
- window.location.reload();
- }
-}
-
-export function LeftSidebar({
- isSidebarOpen,
- setIsSidebarOpen,
- onHostConnect,
- disabled,
- username,
-}: LeftSidebarProps) {
- const { t } = useTranslation();
- const { theme, setTheme } = useTheme();
- const [hosts, setHosts] = useState<SSHHost[]>([]);
- const [hostsLoading] = useState(false);
- const [hostsError, setHostsError] = useState<string | null>(null);
- const prevHostsRef = React.useRef<SSHHost[]>([]);
- const [search, setSearch] = useState("");
- const [debouncedSearch, setDebouncedSearch] = useState("");
-
- const fetchHosts = useCallback(async () => {
- try {
- const newHosts = await getSSHHosts();
- const prevHosts = prevHostsRef.current;
-
- if (JSON.stringify(newHosts) !== JSON.stringify(prevHosts)) {
- setHosts(newHosts);
- prevHostsRef.current = newHosts;
- }
- } catch {
- setHostsError(t("leftSidebar.failedToLoadHosts"));
- }
- }, [t]);
-
- useEffect(() => {
- fetchHosts();
- const interval = setInterval(fetchHosts, 300000);
- return () => clearInterval(interval);
- }, [fetchHosts]);
-
- useEffect(() => {
- const handleHostsChanged = () => {
- fetchHosts();
- };
- window.addEventListener(
- "ssh-hosts:changed",
- handleHostsChanged as EventListener,
- );
- return () =>
- window.removeEventListener(
- "ssh-hosts:changed",
- handleHostsChanged as EventListener,
- );
- }, [fetchHosts]);
-
- useEffect(() => {
- const handler = setTimeout(() => setDebouncedSearch(search), 200);
- return () => clearTimeout(handler);
- }, [search]);
-
- const filteredHosts = useMemo(() => {
- const sshOnlyHosts = hosts.filter((h) => h.connectionType === "ssh");
- if (!debouncedSearch.trim()) return sshOnlyHosts;
- const q = debouncedSearch.trim().toLowerCase();
- return sshOnlyHosts.filter((h) => {
- const searchableText = [
- h.name || "",
- h.username,
- h.ip,
- h.folder || "",
- ...(h.tags || []),
- ]
- .join(" ")
- .toLowerCase();
- return searchableText.includes(q);
- });
- }, [hosts, debouncedSearch]);
-
- const hostsByFolder = useMemo(() => {
- const map: Record<string, SSHHost[]> = {};
- filteredHosts.forEach((h) => {
- const folder =
- h.folder && h.folder.trim() ? h.folder : t("leftSidebar.noFolder");
- if (!map[folder]) map[folder] = [];
- map[folder].push(h);
- });
- return map;
- }, [filteredHosts, t]);
-
- const sortedFolders = useMemo(() => {
- const folders = Object.keys(hostsByFolder);
- folders.sort((a, b) => {
- if (a === t("leftSidebar.noFolder")) return 1;
- if (b === t("leftSidebar.noFolder")) return -1;
- return a.localeCompare(b);
- });
- return folders;
- }, [hostsByFolder, t]);
-
- const getSortedHosts = useCallback((arr: SSHHost[]) => {
- const pinned = arr
- .filter((h) => h.pin)
- .sort((a, b) => (a.name || "").localeCompare(b.name || ""));
- const rest = arr
- .filter((h) => !h.pin)
- .sort((a, b) => (a.name || "").localeCompare(b.name || ""));
- return [...pinned, ...rest];
- }, []);
-
- return (
- <div className="">
- <SidebarProvider open={isSidebarOpen}>
- <Sidebar>
- <SidebarHeader>
- <SidebarGroupLabel className="text-lg font-bold text-foreground">
- Termix
- <Button
- variant="outline"
- onClick={() => setIsSidebarOpen(!isSidebarOpen)}
- className="w-[28px] h-[28px] absolute right-5"
- >
- <Menu className="h-4 w-4" />
- </Button>
- </SidebarGroupLabel>
- </SidebarHeader>
- <Separator />
- <SidebarContent>
- <SidebarGroup className="flex flex-col gap-y-2">
- <div className="!bg-field rounded-lg">
- <Input
- value={search}
- onChange={(e) => setSearch(e.target.value)}
- placeholder={t("placeholders.searchHostsAny")}
- className="w-full h-8 text-sm border-2 !bg-field border-edge rounded-md"
- autoComplete="off"
- />
- </div>
-
- {hostsError && (
- <div className="px-1">
- <div className="text-xs text-red-500 bg-red-500/10 rounded-lg px-2 py-1 border w-full">
- {t("leftSidebar.failedToLoadHosts")}
- </div>
- </div>
- )}
-
- {hostsLoading && (
- <div className="px-4 pb-2">
- <div className="text-xs text-muted-foreground text-center">
- {t("hosts.loadingHosts")}
- </div>
- </div>
- )}
-
- {sortedFolders.map((folder) => (
- <FolderCard
- key={`folder-${folder}`}
- folderName={folder}
- hosts={getSortedHosts(hostsByFolder[folder])}
- onHostConnect={onHostConnect}
- />
- ))}
- </SidebarGroup>
- </SidebarContent>
- <Separator className="mt-1" />
- <SidebarFooter>
- <SidebarMenu>
- <SidebarMenuItem>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <SidebarMenuButton
- className="data-[state=open]:opacity-90 w-full"
- disabled={disabled}
- >
- <User2 /> {username ? username : t("common.logout")}
- <ChevronUp className="ml-auto" />
- </SidebarMenuButton>
- </DropdownMenuTrigger>
- <DropdownMenuContent
- side="top"
- align="start"
- sideOffset={6}
- className="min-w-[var(--radix-popper-anchor-width)] bg-sidebar-accent text-sidebar-accent-foreground border border-border rounded-md shadow-2xl p-1"
- >
- <DropdownMenuItem
- className="rounded px-2 py-1.5 hover:bg-surface-hover hover:text-accent-foreground focus:bg-surface-hover focus:text-accent-foreground cursor-pointer focus:outline-none"
- onClick={() =>
- setTheme(theme === "dark" ? "light" : "dark")
- }
- >
- {theme === "dark" ? (
- <>
- <span>{t("theme.switchToLight")}</span>
- </>
- ) : (
- <>
- <span>{t("theme.switchToDark")}</span>
- </>
- )}
- </DropdownMenuItem>
- <DropdownMenuItem
- className="rounded px-2 py-1.5 hover:bg-surface-hover hover:text-accent-foreground focus:bg-surface-hover focus:text-accent-foreground cursor-pointer focus:outline-none"
- onClick={handleLogout}
- >
- <span>{t("common.logout")}</span>
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </SidebarMenuItem>
- </SidebarMenu>
- </SidebarFooter>
- </Sidebar>
- </SidebarProvider>
- </div>
- );
-}
diff --git a/src/ui/mobile/navigation/hosts/FolderCard.tsx b/src/ui/mobile/navigation/hosts/FolderCard.tsx
deleted file mode 100644
index 85f0cdca1..000000000
--- a/src/ui/mobile/navigation/hosts/FolderCard.tsx
+++ /dev/null
@@ -1,99 +0,0 @@
-import React, { useState } from "react";
-import { CardTitle } from "@/components/ui/card.tsx";
-import { ChevronDown, Folder } from "lucide-react";
-import { Button } from "@/components/ui/button.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
-import { Host } from "@/ui/mobile/navigation/hosts/Host.tsx";
-
-interface SSHHost {
- id: number;
- name: string;
- ip: string;
- port: number;
- username: string;
- folder: string;
- tags: string[];
- pin: boolean;
- authType: string;
- password?: string;
- key?: string;
- keyPassword?: string;
- keyType?: string;
- enableTerminal: boolean;
- enableTunnel: boolean;
- enableFileManager: boolean;
- defaultPath: string;
- tunnelConnections: Array<{
- sourcePort: number;
- endpointPort: number;
- endpointHost: string;
- maxRetries: number;
- retryInterval: number;
- autoStart: boolean;
- }>;
- createdAt: string;
- updatedAt: string;
-}
-
-interface FolderCardProps {
- folderName: string;
- hosts: SSHHost[];
- onHostConnect: () => void;
-}
-
-export function FolderCard({
- folderName,
- hosts,
- onHostConnect,
-}: FolderCardProps): React.ReactElement {
- const [isExpanded, setIsExpanded] = useState(true);
-
- const toggleExpanded = () => {
- setIsExpanded(!isExpanded);
- };
-
- return (
- <div className="bg-elevated border-2 border-edge rounded-lg overflow-hidden p-0 m-0">
- <div
- className={`px-4 py-3 relative ${isExpanded ? "border-b-2" : ""} bg-header`}
- >
- <div className="flex gap-2 pr-10">
- <div className="flex-shrink-0 flex items-center">
- <Folder size={16} strokeWidth={3} />
- </div>
- <div className="flex-1 min-w-0">
- <CardTitle className="mb-0 leading-tight break-words text-md">
- {folderName}
- </CardTitle>
- </div>
- </div>
- <Button
- variant="outline"
- className="w-[28px] h-[28px] absolute right-4 top-1/2 -translate-y-1/2 flex-shrink-0"
- onClick={toggleExpanded}
- >
- <ChevronDown
- className={`h-4 w-4 transition-transform ${isExpanded ? "" : "rotate-180"}`}
- />
- </Button>
- </div>
- {isExpanded && (
- <div className="flex flex-col p-2 gap-y-3">
- {hosts.map((host, index) => (
- <React.Fragment
- key={`${folderName}-host-${host.id}-${host.name || host.ip}`}
- >
- <Host host={host} onHostConnect={onHostConnect} />
-
- {index < hosts.length - 1 && (
- <div className="relative -mx-2">
- <Separator className="p-0.25 absolute inset-x-0" />
- </div>
- )}
- </React.Fragment>
- ))}
- </div>
- )}
- </div>
- );
-}
diff --git a/src/ui/mobile/navigation/hosts/Host.tsx b/src/ui/mobile/navigation/hosts/Host.tsx
deleted file mode 100644
index 1ac23ef12..000000000
--- a/src/ui/mobile/navigation/hosts/Host.tsx
+++ /dev/null
@@ -1,120 +0,0 @@
-import React, { useEffect, useState, useMemo } from "react";
-import { Status, StatusIndicator } from "@/components/ui/shadcn-io/status";
-import { Button } from "@/components/ui/button.tsx";
-import { ButtonGroup } from "@/components/ui/button-group.tsx";
-import { Terminal } from "lucide-react";
-import { getServerStatusById } from "@/ui/main-axios.ts";
-import { useTabs } from "@/ui/mobile/navigation/tabs/TabContext.tsx";
-import type { HostProps } from "../../../../types/index.js";
-import { DEFAULT_STATS_CONFIG } from "@/types/stats-widgets";
-
-export function Host({ host, onHostConnect }: HostProps): React.ReactElement {
- const { addTab } = useTabs();
- const [serverStatus, setServerStatus] = useState<
- "online" | "offline" | "degraded"
- >("degraded");
- const tags = Array.isArray(host.tags) ? host.tags : [];
- const hasTags = tags.length > 0;
-
- const title = host.name?.trim()
- ? host.name
- : `${host.username}@${host.ip}:${host.port}`;
-
- const statsConfig = useMemo(() => {
- try {
- return host.statsConfig
- ? JSON.parse(host.statsConfig)
- : DEFAULT_STATS_CONFIG;
- } catch {
- return DEFAULT_STATS_CONFIG;
- }
- }, [host.statsConfig]);
-
- const shouldShowStatus = statsConfig.statusCheckEnabled !== false;
-
- useEffect(() => {
- if (!shouldShowStatus) {
- setServerStatus("offline");
- return;
- }
-
- let cancelled = false;
-
- const fetchStatus = async () => {
- try {
- const res = await getServerStatusById(host.id);
- if (!cancelled) {
- setServerStatus(res?.status === "online" ? "online" : "offline");
- }
- } catch (error: unknown) {
- if (!cancelled) {
- const err = error as { response?: { status?: number } };
- if (err?.response?.status === 503) {
- setServerStatus("offline");
- } else if (err?.response?.status === 504) {
- setServerStatus("degraded");
- } else if (err?.response?.status === 404) {
- setServerStatus("offline");
- } else {
- setServerStatus("offline");
- }
- }
- }
- };
-
- fetchStatus();
-
- const intervalId = window.setInterval(fetchStatus, 10000);
-
- return () => {
- cancelled = true;
- if (intervalId) window.clearInterval(intervalId);
- };
- }, [host.id, shouldShowStatus]);
-
- const handleTerminalClick = () => {
- addTab({ type: "terminal", title, hostConfig: host });
- onHostConnect();
- };
-
- return (
- <div>
- <div className="flex items-center gap-2">
- {shouldShowStatus && (
- <Status
- status={serverStatus}
- className="!bg-transparent !p-0.75 flex-shrink-0"
- >
- <StatusIndicator />
- </Status>
- )}
- <p className="font-semibold flex-1 min-w-0 break-words text-sm">
- {host.name || host.ip}
- </p>
- <ButtonGroup className="flex-shrink-0">
- {host.enableTerminal && (
- <Button
- variant="outline"
- className="!px-2 border-1 w-[60px] border-edge"
- onClick={handleTerminalClick}
- >
- <Terminal />
- </Button>
- )}
- </ButtonGroup>
- </div>
- {hasTags && (
- <div className="flex flex-wrap items-center gap-2 mt-1">
- {tags.map((tag: string) => (
- <div
- key={tag}
- className="bg-canvas border-1 border-edge pl-2 pr-2 rounded-[10px]"
- >
- <p className="text-sm">{tag}</p>
- </div>
- ))}
- </div>
- )}
- </div>
- );
-}
diff --git a/src/ui/mobile/navigation/tabs/TabContext.tsx b/src/ui/mobile/navigation/tabs/TabContext.tsx
deleted file mode 100644
index 6c181570e..000000000
--- a/src/ui/mobile/navigation/tabs/TabContext.tsx
+++ /dev/null
@@ -1,101 +0,0 @@
-import React, {
- createContext,
- useContext,
- useState,
- useRef,
- type ReactNode,
-} from "react";
-import type { TabContextTab } from "../../../types/index.js";
-
-export type Tab = TabContextTab;
-
-interface TabContextType {
- tabs: Tab[];
- currentTab: number | null;
- addTab: (tab: Omit<Tab, "id">) => number;
- removeTab: (tabId: number) => void;
- setCurrentTab: (tabId: number) => void;
- getTab: (tabId: number) => Tab | undefined;
-}
-
-const TabContext = createContext<TabContextType | undefined>(undefined);
-
-export function useTabs() {
- const context = useContext(TabContext);
- if (!context) {
- throw new Error("useTabs must be used within a TabProvider");
- }
- return context;
-}
-
-interface TabProviderProps {
- children: ReactNode;
-}
-
-export function TabProvider({ children }: TabProviderProps) {
- const [tabs, setTabs] = useState<Tab[]>([]);
- const [currentTab, setCurrentTab] = useState<number | null>(null);
- const nextTabId = useRef(1);
-
- function computeUniqueTitle(desiredTitle: string | undefined): string {
- const baseTitle = (desiredTitle || "Terminal").trim();
- const existingTitles = tabs.map((t) => t.title);
- if (!existingTitles.includes(baseTitle)) {
- return baseTitle;
- }
- let i = 2;
- while (existingTitles.includes(`${baseTitle} (${i})`)) {
- i++;
- }
- return `${baseTitle} (${i})`;
- }
-
- const addTab = (tabData: Omit<Tab, "id">): number => {
- const id = nextTabId.current++;
- const newTab: Tab = {
- ...tabData,
- id,
- title: computeUniqueTitle(tabData.title),
- terminalRef: React.createRef<{ disconnect?: () => void }>(),
- };
- setTabs((prev) => [...prev, newTab]);
- setCurrentTab(id);
- return id;
- };
-
- const removeTab = (tabId: number) => {
- const tab = tabs.find((t) => t.id === tabId);
- if (
- tab &&
- tab.terminalRef?.current &&
- typeof tab.terminalRef.current.disconnect === "function"
- ) {
- tab.terminalRef.current.disconnect();
- }
-
- setTabs((prev) => {
- const newTabs = prev.filter((tab) => tab.id !== tabId);
- if (currentTab === tabId) {
- setCurrentTab(
- newTabs.length > 0 ? newTabs[newTabs.length - 1].id : null,
- );
- }
- return newTabs;
- });
- };
-
- const getTab = (tabId: number) => {
- return tabs.find((tab) => tab.id === tabId);
- };
-
- const value: TabContextType = {
- tabs,
- currentTab,
- addTab,
- removeTab,
- setCurrentTab,
- getTab,
- };
-
- return <TabContext.Provider value={value}>{children}</TabContext.Provider>;
-}
diff --git a/src/ui/shell/CommandPalette.tsx b/src/ui/shell/CommandPalette.tsx
new file mode 100644
index 000000000..76b20a26a
--- /dev/null
+++ b/src/ui/shell/CommandPalette.tsx
@@ -0,0 +1,395 @@
+import React, { useEffect, useRef, useState } from "react";
+import { cn } from "@/lib/utils";
+import { Kbd } from "@/components/kbd";
+import {
+ Command,
+ CommandInput,
+ CommandItem,
+ CommandList,
+ CommandGroup,
+ CommandSeparator,
+} from "@/components/command";
+import {
+ Server,
+ Settings,
+ Terminal,
+ FolderOpen,
+ Box,
+ Globe,
+ Plus,
+ MessagesSquare,
+ LifeBuoy,
+ DollarSign,
+ Search,
+ Activity,
+ Network,
+ MoreHorizontal,
+ Edit3,
+ User,
+ KeyRound,
+ LayoutDashboard,
+} from "lucide-react";
+import { Button } from "@/components/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@/components/dropdown-menu";
+
+type Host = {
+ name: string;
+ user: string;
+ address: string;
+ online: boolean;
+ cpu: number;
+ ram: number;
+ lastAccess: string;
+ tags?: string[];
+ enableTerminal?: boolean;
+ enableFileManager?: boolean;
+ enableDocker?: boolean;
+ enableTunnel?: boolean;
+};
+
+interface CommandPaletteProps {
+ isOpen: boolean;
+ setIsOpen: (isOpen: boolean) => void;
+ hosts: Host[];
+ onOpenTab: (type: any, label?: string, pendingEvent?: string) => void;
+}
+
+const ACTION_ICONS: Record<string, React.ReactNode> = {
+ Terminal: <Terminal className="size-3" />,
+ Files: <FolderOpen className="size-3" />,
+ Docker: <Box className="size-3" />,
+ Stats: <Activity className="size-3" />,
+ Tunnels: <Network className="size-3" />,
+};
+
+const ACTION_TAB_TYPE: Record<string, string> = {
+ Terminal: "terminal",
+ Files: "files",
+ Docker: "docker",
+ Stats: "stats",
+ Tunnels: "tunnel",
+};
+
+export function CommandPalette({
+ isOpen,
+ setIsOpen,
+ hosts,
+ onOpenTab,
+}: CommandPaletteProps) {
+ const inputRef = useRef<HTMLInputElement>(null);
+ const [search, setSearch] = useState("");
+
+ useEffect(() => {
+ if (isOpen) {
+ setTimeout(() => inputRef.current?.focus(), 50);
+ setSearch("");
+ }
+ }, [isOpen]);
+
+ useEffect(() => {
+ const handleKeyDown = (e: KeyboardEvent) => {
+ if (e.key === "Escape") {
+ setIsOpen(false);
+ }
+ };
+ window.addEventListener("keydown", handleKeyDown);
+ return () => window.removeEventListener("keydown", handleKeyDown);
+ }, [setIsOpen]);
+
+ const filteredHosts = hosts.filter(
+ (h) =>
+ h.name.toLowerCase().includes(search.toLowerCase()) ||
+ h.ip.toLowerCase().includes(search.toLowerCase()),
+ );
+
+ const handleAction = (action: () => void) => {
+ action();
+ setIsOpen(false);
+ };
+
+ if (!isOpen) return null;
+
+ return (
+ <div
+ className={cn(
+ "fixed inset-0 z-[100] flex items-start justify-center pt-[15vh] bg-background/40 backdrop-blur-sm transition-all duration-200 animate-in fade-in",
+ )}
+ onClick={() => setIsOpen(false)}
+ >
+ <div
+ className={cn(
+ "w-full max-w-2xl mx-4 overflow-hidden rounded-none border border-border bg-card shadow-2xl animate-in zoom-in-95 duration-200",
+ )}
+ onClick={(e) => e.stopPropagation()}
+ >
+ <Command className="rounded-none">
+ <div className="flex items-center border-b border-border px-4 py-1">
+ <Search className="size-4 text-muted-foreground mr-3" />
+ <input
+ ref={inputRef}
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ placeholder="Search hosts, commands, or settings..."
+ className="flex-1 h-12 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
+ />
+ <div className="flex items-center gap-1.5 ml-2">
+ <Kbd className="bg-muted/50 border-none h-6 px-2 text-[11px] rounded-none">
+ ESC
+ </Kbd>
+ </div>
+ </div>
+
+ <CommandList className="max-h-[60vh] thin-scrollbar">
+ <CommandGroup heading="Quick Actions" className="px-2">
+ <CommandItem
+ onSelect={() => handleAction(() => onOpenTab("host-manager"))}
+ className="group flex items-center gap-3 px-3 py-2.5 rounded-none hover:bg-accent-brand/10 cursor-pointer"
+ >
+ <div className="size-8 rounded-none bg-muted flex items-center justify-center group-hover:bg-accent-brand/20 transition-colors">
+ <LayoutDashboard className="size-4 text-accent-brand" />
+ </div>
+ <div className="flex flex-col flex-1">
+ <span className="text-sm font-semibold">Host Manager</span>
+ <span className="text-xs text-muted-foreground">
+ Manage, add, or edit hosts
+ </span>
+ </div>
+ </CommandItem>
+
+ <CommandItem
+ onSelect={() =>
+ handleAction(() =>
+ onOpenTab(
+ "host-manager",
+ undefined,
+ "host-manager:add-host",
+ ),
+ )
+ }
+ className="group flex items-center gap-3 px-3 py-2.5 rounded-none hover:bg-accent-brand/10 cursor-pointer"
+ >
+ <div className="size-8 rounded-none bg-muted flex items-center justify-center group-hover:bg-accent-brand/20 transition-colors">
+ <Plus className="size-4 text-accent-brand" />
+ </div>
+ <div className="flex flex-col flex-1">
+ <span className="text-sm font-semibold">Add New Host</span>
+ <span className="text-xs text-muted-foreground">
+ Register a new host
+ </span>
+ </div>
+ </CommandItem>
+
+ <CommandItem
+ onSelect={() => handleAction(() => onOpenTab("admin-settings"))}
+ className="group flex items-center gap-3 px-3 py-2.5 rounded-none hover:bg-accent-brand/10 cursor-pointer"
+ >
+ <div className="size-8 rounded-none bg-muted flex items-center justify-center group-hover:bg-accent-brand/20 transition-colors">
+ <Settings className="size-4 text-accent-brand" />
+ </div>
+ <div className="flex flex-col flex-1">
+ <span className="text-sm font-semibold">Admin Settings</span>
+ <span className="text-xs text-muted-foreground">
+ Configure system preferences and users
+ </span>
+ </div>
+ </CommandItem>
+
+ <CommandItem
+ onSelect={() => handleAction(() => onOpenTab("user-profile"))}
+ className="group flex items-center gap-3 px-3 py-2.5 rounded-none hover:bg-accent-brand/10 cursor-pointer"
+ >
+ <div className="size-8 rounded-none bg-muted flex items-center justify-center group-hover:bg-accent-brand/20 transition-colors">
+ <User className="size-4 text-accent-brand" />
+ </div>
+ <div className="flex flex-col flex-1">
+ <span className="text-sm font-semibold">User Profile</span>
+ <span className="text-xs text-muted-foreground">
+ Manage your account and preferences
+ </span>
+ </div>
+ </CommandItem>
+
+ <CommandItem
+ onSelect={() =>
+ handleAction(() =>
+ onOpenTab(
+ "host-manager",
+ undefined,
+ "host-manager:add-credential",
+ ),
+ )
+ }
+ className="group flex items-center gap-3 px-3 py-2.5 rounded-none hover:bg-accent-brand/10 cursor-pointer"
+ >
+ <div className="size-8 rounded-none bg-muted flex items-center justify-center group-hover:bg-accent-brand/20 transition-colors">
+ <KeyRound className="size-4 text-accent-brand" />
+ </div>
+ <div className="flex flex-col flex-1">
+ <span className="text-sm font-semibold">Add Credential</span>
+ <span className="text-xs text-muted-foreground">
+ Store SSH keys or passwords
+ </span>
+ </div>
+ </CommandItem>
+ </CommandGroup>
+
+ <CommandSeparator className="my-2" />
+
+ <CommandGroup heading="Servers & Hosts" className="px-2">
+ {filteredHosts.length > 0 ? (
+ filteredHosts.map((host, i) => {
+ const actions = [
+ host.enableTerminal !== false && "Terminal",
+ host.enableFileManager !== false && "Files",
+ host.enableDocker && "Docker",
+ host.enableTunnel && "Tunnels",
+ "Stats",
+ ].filter(Boolean) as string[];
+
+ return (
+ <CommandItem
+ key={i}
+ onSelect={() =>
+ handleAction(() => onOpenTab("terminal", host.name))
+ }
+ className="group flex items-center gap-3 px-3 py-2.5 rounded-none hover:bg-accent-brand/10 cursor-pointer"
+ >
+ <div className="size-8 rounded-none bg-muted flex items-center justify-center group-hover:bg-accent-brand/20 transition-colors shrink-0">
+ <Server
+ className={cn(
+ "size-4",
+ host.online
+ ? "text-accent-brand"
+ : "text-muted-foreground",
+ )}
+ />
+ </div>
+ <div className="flex flex-col flex-1 min-w-0">
+ <div className="flex items-center gap-2">
+ <span className="text-sm font-semibold truncate">
+ {host.name}
+ </span>
+ {host.online && (
+ <span className="size-1.5 rounded-full bg-accent-brand animate-pulse shrink-0" />
+ )}
+ </div>
+ <span className="text-xs text-muted-foreground font-mono">
+ {host.ip}
+ </span>
+ </div>
+ <div className="flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity">
+ {actions.map((action) => (
+ <Button
+ key={action}
+ variant="ghost"
+ size="icon"
+ title={action}
+ className="size-7 rounded-none hover:bg-accent-brand/20 hover:text-accent-brand"
+ onClick={(e) => {
+ e.stopPropagation();
+ handleAction(() =>
+ onOpenTab(
+ ACTION_TAB_TYPE[action] as any,
+ host.name,
+ ),
+ );
+ }}
+ >
+ {ACTION_ICONS[action]}
+ </Button>
+ ))}
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-7 rounded-none hover:bg-muted"
+ onClick={(e) => e.stopPropagation()}
+ >
+ <MoreHorizontal className="size-3" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ align="end"
+ className="rounded-none border-border bg-card w-40"
+ >
+ <DropdownMenuItem
+ className="rounded-none text-xs font-semibold hover:bg-accent-brand/10 hover:text-accent-brand cursor-pointer"
+ onClick={(e) => {
+ e.stopPropagation();
+ handleAction(() => onOpenTab("host-manager"));
+ }}
+ >
+ <Edit3 className="size-3.5 mr-2" /> Edit Host
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </CommandItem>
+ );
+ })
+ ) : (
+ <div className="py-6 text-center text-sm text-muted-foreground">
+ No hosts found matching "{search}"
+ </div>
+ )}
+ </CommandGroup>
+
+ <CommandSeparator className="my-2" />
+
+ <CommandGroup heading="Links" className="px-2">
+ <div className="grid grid-cols-2 gap-1">
+ <CommandItem
+ onSelect={() => window.open("https://github.com", "_blank")}
+ className="flex items-center gap-3 px-3 py-2 rounded-none hover:bg-accent-brand/10 cursor-pointer"
+ >
+ <Globe className="size-4 text-muted-foreground" />
+ <span className="text-sm font-medium">GitHub</span>
+ </CommandItem>
+ <CommandItem
+ onSelect={() => window.open("https://discord.com", "_blank")}
+ className="flex items-center gap-3 px-3 py-2 rounded-none hover:bg-accent-brand/10 cursor-pointer"
+ >
+ <MessagesSquare className="size-4 text-muted-foreground" />
+ <span className="text-sm font-medium">Discord</span>
+ </CommandItem>
+ <CommandItem className="flex items-center gap-3 px-3 py-2 rounded-none hover:bg-accent-brand/10 cursor-pointer">
+ <LifeBuoy className="size-4 text-muted-foreground" />
+ <span className="text-sm font-medium">Support</span>
+ </CommandItem>
+ <CommandItem className="flex items-center gap-3 px-3 py-2 rounded-none hover:bg-accent-brand/10 cursor-pointer">
+ <DollarSign className="size-4 text-muted-foreground" />
+ <span className="text-sm font-medium">Donate</span>
+ </CommandItem>
+ </div>
+ </CommandGroup>
+ </CommandList>
+
+ <div className="border-t border-border px-4 py-3 bg-muted/30 flex items-center justify-between text-[11px] text-muted-foreground">
+ <div className="flex items-center gap-3">
+ <div className="flex items-center gap-1">
+ <Kbd className="h-5 px-1 bg-background rounded-none">↑↓</Kbd>
+ <span>Navigate</span>
+ </div>
+ <div className="flex items-center gap-1">
+ <Kbd className="h-5 px-1 bg-background rounded-none">ENTER</Kbd>
+ <span>Select</span>
+ </div>
+ </div>
+ <div className="flex items-center gap-1">
+ <span>Toggle with</span>
+ <Kbd className="h-5 px-1.5 bg-background rounded-none">Shift</Kbd>
+ <span>+</span>
+ <Kbd className="h-5 px-1.5 bg-background rounded-none">Shift</Kbd>
+ </div>
+ </div>
+ </Command>
+ </div>
+ </div>
+ );
+}
diff --git a/src/ui/shell/MobileBottomBar.tsx b/src/ui/shell/MobileBottomBar.tsx
new file mode 100644
index 000000000..a25d33ff2
--- /dev/null
+++ b/src/ui/shell/MobileBottomBar.tsx
@@ -0,0 +1,149 @@
+import React, { useState } from "react";
+import {
+ Clock,
+ Hammer,
+ KeyRound,
+ LayoutPanelLeft,
+ MoreHorizontal,
+ Play,
+ Server,
+ Settings,
+ User,
+ Zap,
+} from "lucide-react";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ DropdownMenuSeparator,
+} from "@/components/dropdown-menu";
+import type { RailView } from "@/sidebar/AppRail";
+import type { SplitMode } from "@/types/ui-types";
+
+const PRIMARY_ITEMS: {
+ view: RailView;
+ icon: React.ReactNode;
+ title: string;
+}[] = [
+ { view: "hosts", icon: <Server className="size-5" />, title: "Hosts" },
+ { view: "quick-connect", icon: <Zap className="size-5" />, title: "Connect" },
+ {
+ view: "ssh-tools",
+ icon: <Hammer className="size-5" />,
+ title: "SSH Tools",
+ },
+ { view: "snippets", icon: <Play className="size-5" />, title: "Snippets" },
+];
+
+const MORE_ITEMS: { view: RailView; icon: React.ReactNode; title: string }[] = [
+ { view: "history", icon: <Clock className="size-4" />, title: "History" },
+ {
+ view: "split-screen",
+ icon: <LayoutPanelLeft className="size-4" />,
+ title: "Split Screen",
+ },
+ { view: "user-profile", icon: <User className="size-4" />, title: "Profile" },
+ {
+ view: "admin-settings",
+ icon: <Settings className="size-4" />,
+ title: "Admin",
+ },
+];
+
+export function MobileBottomBar({
+ railView,
+ sidebarOpen,
+ splitMode,
+ onRailClick,
+}: {
+ railView: RailView;
+ sidebarOpen: boolean;
+ splitMode: SplitMode;
+ onRailClick: (view: RailView) => void;
+}) {
+ const [moreOpen, setMoreOpen] = useState(false);
+ const moreActive = MORE_ITEMS.some((i) => i.view === railView) && sidebarOpen;
+
+ return (
+ <div className="md:hidden flex items-stretch shrink-0 bg-sidebar border-t border-border safe-bottom">
+ {PRIMARY_ITEMS.map((item) => {
+ const active = sidebarOpen && railView === item.view;
+ const hasDot = item.view === "split-screen" && splitMode !== "none";
+ return (
+ <button
+ key={item.view}
+ onClick={() => onRailClick(item.view)}
+ className={`relative flex flex-col items-center justify-center flex-1 gap-0.5 py-2 min-h-[56px] transition-colors text-[10px] font-medium
+ ${active ? "text-accent-brand" : "text-muted-foreground"}`}
+ >
+ {item.icon}
+ <span>{item.title}</span>
+ {hasDot && (
+ <span className="absolute top-1.5 right-[calc(50%-10px)] size-1.5 rounded-full bg-accent-brand" />
+ )}
+ </button>
+ );
+ })}
+
+ <DropdownMenu open={moreOpen} onOpenChange={setMoreOpen}>
+ <DropdownMenuTrigger asChild>
+ <button
+ className={`relative flex flex-col items-center justify-center flex-1 gap-0.5 py-2 min-h-[56px] transition-colors text-[10px] font-medium
+ ${moreActive ? "text-accent-brand" : "text-muted-foreground"}`}
+ >
+ <MoreHorizontal className="size-5" />
+ <span>More</span>
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ side="top"
+ align="end"
+ className="mb-1 min-w-[180px]"
+ >
+ {MORE_ITEMS.map((item, i) => {
+ const active = sidebarOpen && railView === item.view;
+ if (item.view === "user-profile" && i > 0) {
+ return (
+ <React.Fragment key={item.view}>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ onClick={() => {
+ onRailClick(item.view);
+ setMoreOpen(false);
+ }}
+ className={active ? "text-accent-brand" : ""}
+ >
+ {item.icon}
+ {item.title}
+ </DropdownMenuItem>
+ </React.Fragment>
+ );
+ }
+ return (
+ <DropdownMenuItem
+ key={item.view}
+ onClick={() => {
+ onRailClick(item.view);
+ setMoreOpen(false);
+ }}
+ className={active ? "text-accent-brand" : ""}
+ >
+ {item.icon}
+ {item.title}
+ </DropdownMenuItem>
+ );
+ })}
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ variant="destructive"
+ onClick={() => window.dispatchEvent(new Event("termix:logout"))}
+ >
+ <KeyRound className="size-4" />
+ Logout
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ );
+}
diff --git a/src/ui/shell/SplitView.tsx b/src/ui/shell/SplitView.tsx
new file mode 100644
index 000000000..ed5ee89b5
--- /dev/null
+++ b/src/ui/shell/SplitView.tsx
@@ -0,0 +1,477 @@
+import { useState, useRef, useEffect } from "react";
+import { splitDragState, notifyDragEnd } from "@/lib/splitDragging";
+import { renderTabContent, tabIcon } from "@/shell/tabUtils";
+import type { Tab, TabType, Host, SplitMode } from "@/types/ui-types";
+
+// ─── Types ────────────────────────────────────────────────────────────────────
+
+type RowColSizes = number[][];
+
+// ─── useSplitSizes ────────────────────────────────────────────────────────────
+
+function defaultSizes(mode: SplitMode): {
+ rowSizes: number[];
+ rowColSizes: RowColSizes;
+} {
+ switch (mode) {
+ case "2-way":
+ return { rowSizes: [100], rowColSizes: [[50, 50]] };
+ case "3-way":
+ return { rowSizes: [50, 50], rowColSizes: [[50, 50], [100]] };
+ case "4-way":
+ return {
+ rowSizes: [50, 50],
+ rowColSizes: [
+ [50, 50],
+ [50, 50],
+ ],
+ };
+ case "5-way":
+ return {
+ rowSizes: [50, 50],
+ rowColSizes: [
+ [33.3, 33.3, 33.4],
+ [33.3, 66.7],
+ ],
+ };
+ case "6-way":
+ return {
+ rowSizes: [50, 50],
+ rowColSizes: [
+ [33.3, 33.3, 33.4],
+ [33.3, 33.3, 33.4],
+ ],
+ };
+ default:
+ return { rowSizes: [100], rowColSizes: [[100]] };
+ }
+}
+
+function useSplitSizes(splitMode: SplitMode) {
+ const init = defaultSizes(splitMode);
+ const [rowSizes, setRowSizes] = useState(init.rowSizes);
+ const [rowColSizes, setRowColSizes] = useState<RowColSizes>(init.rowColSizes);
+ const [isDragging, setIsDragging] = useState(false);
+ const containerRef = useRef<HTMLDivElement>(null);
+
+ useEffect(() => {
+ const d = defaultSizes(splitMode);
+ setRowSizes(d.rowSizes);
+ setRowColSizes(d.rowColSizes);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [splitMode]);
+
+ function reset() {
+ const d = defaultSizes(splitMode);
+ setRowSizes(d.rowSizes);
+ setRowColSizes(d.rowColSizes);
+ }
+
+ function startDrag() {
+ splitDragState.active = true;
+ setIsDragging(true);
+ }
+
+ function endDrag() {
+ splitDragState.active = false;
+ setIsDragging(false);
+ notifyDragEnd();
+ }
+
+ function onRowDivider(e: React.MouseEvent, rowIdx: number) {
+ e.preventDefault();
+ const container = containerRef.current;
+ if (!container) return;
+ startDrag();
+ const totalH = container.getBoundingClientRect().height;
+ const startY = e.clientY;
+ const a = rowSizes[rowIdx];
+ const b = rowSizes[rowIdx + 1];
+ function onMove(ev: MouseEvent) {
+ const delta = ((ev.clientY - startY) / totalH) * 100;
+ const na = Math.max(10, Math.min(a + b - 10, a + delta));
+ setRowSizes((prev) => {
+ const n = [...prev];
+ n[rowIdx] = na;
+ n[rowIdx + 1] = a + b - na;
+ return n;
+ });
+ }
+ function onUp() {
+ endDrag();
+ window.removeEventListener("mousemove", onMove);
+ window.removeEventListener("mouseup", onUp);
+ }
+ window.addEventListener("mousemove", onMove);
+ window.addEventListener("mouseup", onUp);
+ }
+
+ function onRowDividerTouch(e: React.TouchEvent, rowIdx: number) {
+ const container = containerRef.current;
+ if (!container) return;
+ startDrag();
+ const totalH = container.getBoundingClientRect().height;
+ const startY = e.touches[0].clientY;
+ const a = rowSizes[rowIdx];
+ const b = rowSizes[rowIdx + 1];
+ function onMove(ev: TouchEvent) {
+ const delta = ((ev.touches[0].clientY - startY) / totalH) * 100;
+ const na = Math.max(10, Math.min(a + b - 10, a + delta));
+ setRowSizes((prev) => {
+ const n = [...prev];
+ n[rowIdx] = na;
+ n[rowIdx + 1] = a + b - na;
+ return n;
+ });
+ }
+ function onUp() {
+ endDrag();
+ window.removeEventListener("touchmove", onMove);
+ window.removeEventListener("touchend", onUp);
+ }
+ window.addEventListener("touchmove", onMove, { passive: false });
+ window.addEventListener("touchend", onUp);
+ }
+
+ function onColDivider(e: React.MouseEvent, rowIdx: number, colIdx: number) {
+ e.preventDefault();
+ const container = containerRef.current;
+ if (!container) return;
+ startDrag();
+ const totalW = container.getBoundingClientRect().width;
+ const startX = e.clientX;
+ const cols = rowColSizes[rowIdx];
+ const a = cols[colIdx];
+ const b = cols[colIdx + 1];
+ function onMove(ev: MouseEvent) {
+ const delta = ((ev.clientX - startX) / totalW) * 100;
+ const na = Math.max(10, Math.min(a + b - 10, a + delta));
+ setRowColSizes((prev) => {
+ const next = prev.map((r) => [...r]);
+ next[rowIdx][colIdx] = na;
+ next[rowIdx][colIdx + 1] = a + b - na;
+ return next;
+ });
+ }
+ function onUp() {
+ endDrag();
+ window.removeEventListener("mousemove", onMove);
+ window.removeEventListener("mouseup", onUp);
+ }
+ window.addEventListener("mousemove", onMove);
+ window.addEventListener("mouseup", onUp);
+ }
+
+ function onColDividerTouch(
+ e: React.TouchEvent,
+ rowIdx: number,
+ colIdx: number,
+ ) {
+ const container = containerRef.current;
+ if (!container) return;
+ startDrag();
+ const totalW = container.getBoundingClientRect().width;
+ const startX = e.touches[0].clientX;
+ const cols = rowColSizes[rowIdx];
+ const a = cols[colIdx];
+ const b = cols[colIdx + 1];
+ function onMove(ev: TouchEvent) {
+ const delta = ((ev.touches[0].clientX - startX) / totalW) * 100;
+ const na = Math.max(10, Math.min(a + b - 10, a + delta));
+ setRowColSizes((prev) => {
+ const next = prev.map((r) => [...r]);
+ next[rowIdx][colIdx] = na;
+ next[rowIdx][colIdx + 1] = a + b - na;
+ return next;
+ });
+ }
+ function onUp() {
+ endDrag();
+ window.removeEventListener("touchmove", onMove);
+ window.removeEventListener("touchend", onUp);
+ }
+ window.addEventListener("touchmove", onMove, { passive: false });
+ window.addEventListener("touchend", onUp);
+ }
+
+ return {
+ rowSizes,
+ rowColSizes,
+ isDragging,
+ containerRef,
+ reset,
+ onRowDivider,
+ onRowDividerTouch,
+ onColDivider,
+ onColDividerTouch,
+ };
+}
+
+// ─── Dividers ─────────────────────────────────────────────────────────────────
+
+function ColDivider({
+ onMouseDown,
+ onTouchStart,
+}: {
+ onMouseDown: (e: React.MouseEvent) => void;
+ onTouchStart: (e: React.TouchEvent) => void;
+}) {
+ return (
+ <div
+ onMouseDown={onMouseDown}
+ onTouchStart={onTouchStart}
+ className="relative w-3 shrink-0 cursor-col-resize z-10 flex items-center justify-center group"
+ >
+ <div className="w-px h-full bg-border group-hover:bg-accent-brand/60 transition-colors" />
+ </div>
+ );
+}
+
+function RowDivider({
+ onMouseDown,
+ onTouchStart,
+}: {
+ onMouseDown: (e: React.MouseEvent) => void;
+ onTouchStart: (e: React.TouchEvent) => void;
+}) {
+ return (
+ <div
+ onMouseDown={onMouseDown}
+ onTouchStart={onTouchStart}
+ className="relative h-3 w-full shrink-0 cursor-row-resize z-10 flex flex-col items-center justify-center group"
+ >
+ <div className="h-px w-full bg-border group-hover:bg-accent-brand/60 transition-colors" />
+ </div>
+ );
+}
+
+// ─── Pane ─────────────────────────────────────────────────────────────────────
+
+function PaneHeader({
+ tab,
+ paneIndex,
+}: {
+ tab: Tab | null;
+ paneIndex: number;
+}) {
+ return (
+ <div className="flex items-center gap-1.5 px-2.5 h-7 shrink-0 bg-sidebar border-b border-border text-xs font-medium text-muted-foreground select-none">
+ {tab ? (
+ <>
+ <span className="opacity-60">{tabIcon(tab.type)}</span>
+ <span className="truncate text-foreground">
+ {tab.type === "dashboard" ? "Dashboard" : tab.label}
+ </span>
+ </>
+ ) : (
+ <span className="opacity-40">Pane {paneIndex + 1} — empty</span>
+ )}
+ </div>
+ );
+}
+
+function EmptyPane() {
+ return (
+ <div className="flex flex-col items-center justify-center w-full h-full gap-2 text-muted-foreground/30 bg-background">
+ <div className="grid grid-cols-2 gap-1">
+ <div className="size-5 border-2 border-current rounded-sm" />
+ <div className="size-5 border-2 border-current rounded-sm" />
+ <div className="size-5 border-2 border-current rounded-sm" />
+ <div className="size-5 border-2 border-current rounded-sm" />
+ </div>
+ <span className="text-xs">No tab assigned</span>
+ </div>
+ );
+}
+
+function Pane({
+ tab,
+ paneIndex,
+ isDragging,
+ onOpenSingletonTab,
+ onOpenTab,
+}: {
+ tab: Tab | null;
+ paneIndex: number;
+ isDragging: boolean;
+ onOpenSingletonTab: (type: TabType) => void;
+ onOpenTab: (host: Host, type: TabType) => void;
+}) {
+ return (
+ <div className="relative flex flex-col w-full h-full min-w-0 min-h-0 overflow-hidden">
+ <PaneHeader tab={tab} paneIndex={paneIndex} />
+ <div className="flex-1 min-h-0 overflow-hidden">
+ {tab ? (
+ renderTabContent(tab, onOpenSingletonTab, onOpenTab)
+ ) : (
+ <EmptyPane />
+ )}
+ </div>
+ {isDragging && (
+ <div className="absolute inset-0 z-10" style={{ cursor: "inherit" }} />
+ )}
+ </div>
+ );
+}
+
+// ─── SplitView ────────────────────────────────────────────────────────────────
+
+export function SplitView({
+ tabs,
+ paneTabIds,
+ splitMode,
+ onOpenSingletonTab,
+ onOpenTab,
+}: {
+ tabs: Tab[];
+ paneTabIds: (string | null)[];
+ splitMode: SplitMode;
+ onOpenSingletonTab: (type: TabType) => void;
+ onOpenTab: (host: Host, type: TabType) => void;
+}) {
+ const {
+ rowSizes,
+ rowColSizes,
+ isDragging,
+ containerRef,
+ reset,
+ onRowDivider,
+ onRowDividerTouch,
+ onColDivider,
+ onColDividerTouch,
+ } = useSplitSizes(splitMode);
+
+ function pane(idx: number) {
+ const tab =
+ paneTabIds[idx] != null
+ ? (tabs.find((t) => t.id === paneTabIds[idx]) ?? null)
+ : null;
+ return (
+ <Pane
+ tab={tab}
+ paneIndex={idx}
+ isDragging={isDragging}
+ onOpenSingletonTab={onOpenSingletonTab}
+ onOpenTab={onOpenTab}
+ />
+ );
+ }
+
+ function Row({
+ rowIdx,
+ paneIndices,
+ }: {
+ rowIdx: number;
+ paneIndices: number[];
+ }) {
+ const cols = rowColSizes[rowIdx] ?? [];
+ return (
+ <div
+ className="flex min-h-0 w-full"
+ style={{ height: `${rowSizes[rowIdx]}%` }}
+ >
+ {paneIndices.map((pIdx, ci) => (
+ <>
+ <div
+ key={pIdx}
+ className="min-w-0 min-h-0 overflow-hidden"
+ style={{ width: `${cols[ci]}%` }}
+ >
+ {pane(pIdx)}
+ </div>
+ {ci < paneIndices.length - 1 && (
+ <ColDivider
+ key={`cd-${rowIdx}-${ci}`}
+ onMouseDown={(e) => onColDivider(e, rowIdx, ci)}
+ onTouchStart={(e) => onColDividerTouch(e, rowIdx, ci)}
+ />
+ )}
+ </>
+ ))}
+ </div>
+ );
+ }
+
+ return (
+ <div
+ ref={containerRef}
+ className="flex flex-col w-full h-full min-h-0 overflow-hidden relative"
+ >
+ <button
+ onClick={reset}
+ className="absolute top-1 right-1 z-20 text-xs text-muted-foreground hover:text-foreground bg-background/80 border border-border px-1.5 py-0.5 leading-tight"
+ title="Reset to equal split"
+ >
+ Reset
+ </button>
+
+ {splitMode === "2-way" && <Row rowIdx={0} paneIndices={[0, 1]} />}
+
+ {splitMode === "3-way" && (
+ <div className="flex w-full h-full min-h-0">
+ <div
+ className="min-w-0 min-h-0 overflow-hidden"
+ style={{ width: `${rowColSizes[0][0]}%` }}
+ >
+ {pane(0)}
+ </div>
+ <ColDivider
+ onMouseDown={(e) => onColDivider(e, 0, 0)}
+ onTouchStart={(e) => onColDividerTouch(e, 0, 0)}
+ />
+ <div className="flex flex-col flex-1 min-h-0">
+ <div
+ className="min-h-0 overflow-hidden"
+ style={{ height: `${rowSizes[0]}%` }}
+ >
+ {pane(1)}
+ </div>
+ <RowDivider
+ onMouseDown={(e) => onRowDivider(e, 0)}
+ onTouchStart={(e) => onRowDividerTouch(e, 0)}
+ />
+ <div
+ className="min-h-0 overflow-hidden"
+ style={{ height: `${rowSizes[1]}%` }}
+ >
+ {pane(2)}
+ </div>
+ </div>
+ </div>
+ )}
+
+ {splitMode === "4-way" && (
+ <div className="flex flex-col w-full h-full min-h-0">
+ <Row rowIdx={0} paneIndices={[0, 1]} />
+ <RowDivider
+ onMouseDown={(e) => onRowDivider(e, 0)}
+ onTouchStart={(e) => onRowDividerTouch(e, 0)}
+ />
+ <Row rowIdx={1} paneIndices={[2, 3]} />
+ </div>
+ )}
+
+ {splitMode === "5-way" && (
+ <div className="flex flex-col w-full h-full min-h-0">
+ <Row rowIdx={0} paneIndices={[0, 1, 2]} />
+ <RowDivider
+ onMouseDown={(e) => onRowDivider(e, 0)}
+ onTouchStart={(e) => onRowDividerTouch(e, 0)}
+ />
+ <Row rowIdx={1} paneIndices={[3, 4]} />
+ </div>
+ )}
+
+ {splitMode === "6-way" && (
+ <div className="flex flex-col w-full h-full min-h-0">
+ <Row rowIdx={0} paneIndices={[0, 1, 2]} />
+ <RowDivider
+ onMouseDown={(e) => onRowDivider(e, 0)}
+ onTouchStart={(e) => onRowDividerTouch(e, 0)}
+ />
+ <Row rowIdx={1} paneIndices={[3, 4, 5]} />
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/src/ui/desktop/navigation/tabs/Tab.tsx b/src/ui/shell/Tab.tsx
similarity index 99%
rename from src/ui/desktop/navigation/tabs/Tab.tsx
rename to src/ui/shell/Tab.tsx
index 3ccd92d19..ada835d9b 100644
--- a/src/ui/desktop/navigation/tabs/Tab.tsx
+++ b/src/ui/shell/Tab.tsx
@@ -1,7 +1,7 @@
import React from "react";
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import { useTranslation } from "react-i18next";
-import { getHostPassword } from "@/ui/main-axios.ts";
+import { getHostPassword } from "@/main-axios.ts";
import { cn } from "@/lib/utils";
import {
Home,
diff --git a/src/ui/shell/TabBar.tsx b/src/ui/shell/TabBar.tsx
new file mode 100644
index 000000000..215913591
--- /dev/null
+++ b/src/ui/shell/TabBar.tsx
@@ -0,0 +1,336 @@
+import { useRef, useEffect, useState } from "react";
+import { Button } from "@/components/button";
+import { Separator } from "@/components/separator";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@/components/dropdown-menu";
+import { ChevronDown, ChevronUp, X } from "lucide-react";
+import { tabIcon } from "@/shell/tabUtils";
+import type { Tab } from "@/types/ui-types";
+
+export function TabBar({
+ tabs,
+ activeTabId,
+ onSetActiveTab,
+ onCloseTab,
+ onReorderTabs,
+}: {
+ tabs: Tab[];
+ activeTabId: string;
+ onSetActiveTab: (id: string) => void;
+ onCloseTab: (id: string) => void;
+ onReorderTabs: (tabs: Tab[]) => void;
+}) {
+ const [open, setOpen] = useState(true);
+ const [dragTabId, setDragTabId] = useState<string | null>(null);
+ const [dragTargetIndex, setDragTargetIndex] = useState<number | null>(null);
+ const [dragPos, setDragPos] = useState<{ x: number; y: number } | null>(null);
+
+ const tabBarRef = useRef<HTMLDivElement>(null);
+ const tabEls = useRef<Map<string, HTMLDivElement>>(new Map());
+ const dragData = useRef<{
+ id: string;
+ index: number;
+ startX: number;
+ startY: number;
+ offsetX: number;
+ width: number;
+ barTop: number;
+ barHeight: number;
+ x: number;
+ y: number;
+ } | null>(null);
+ const dragTargetRef = useRef<number | null>(null);
+ const didDrag = useRef(false);
+
+ useEffect(() => {
+ const el = tabBarRef.current;
+ if (!el) return;
+ const handleWheel = (e: WheelEvent) => {
+ if (e.deltaY !== 0) {
+ e.preventDefault();
+ el.scrollLeft += e.deltaY;
+ }
+ };
+ el.addEventListener("wheel", handleWheel, { passive: false });
+ return () => el.removeEventListener("wheel", handleWheel);
+ }, []);
+
+ useEffect(() => {
+ if (!dragTabId) return;
+
+ function onPointerMove(e: PointerEvent) {
+ if (!dragData.current || !tabBarRef.current) return;
+ const d = dragData.current;
+ if (Math.abs(e.clientX - d.startX) > 5) didDrag.current = true;
+
+ const barRect = tabBarRef.current.getBoundingClientRect();
+ const x = Math.max(
+ barRect.left,
+ Math.min(barRect.right - d.width, e.clientX - d.offsetX),
+ );
+ const y = d.barTop;
+ setDragPos({ x, y });
+
+ const centerX = e.clientX - d.offsetX + d.width / 2;
+ let newTarget = d.index;
+ tabEls.current.forEach((el, id) => {
+ if (id === d.id) return;
+ const rect = el.getBoundingClientRect();
+ const mid = rect.left + rect.width / 2;
+ const idx = tabs.findIndex((t) => t.id === id);
+ if (idx < d.index && centerX < mid)
+ newTarget = Math.min(newTarget, idx);
+ if (idx > d.index && centerX > mid)
+ newTarget = Math.max(newTarget, idx);
+ });
+
+ if (tabs[0].type === "dashboard") newTarget = Math.max(1, newTarget);
+ dragTargetRef.current = newTarget;
+ setDragTargetIndex(newTarget);
+ }
+
+ function onPointerUp() {
+ if (!dragData.current) return;
+ const { id, index } = dragData.current;
+ const to = dragTargetRef.current ?? index;
+ if (to !== index) {
+ const next = [...tabs];
+ if (next[0].id !== id) next.splice(to, 0, next.splice(index, 1)[0]);
+ onReorderTabs(next);
+ }
+ dragData.current = null;
+ dragTargetRef.current = null;
+ setDragTabId(null);
+ setDragTargetIndex(null);
+ setDragPos(null);
+ setTimeout(() => {
+ didDrag.current = false;
+ }, 0);
+ }
+
+ window.addEventListener("pointermove", onPointerMove);
+ window.addEventListener("pointerup", onPointerUp);
+ return () => {
+ window.removeEventListener("pointermove", onPointerMove);
+ window.removeEventListener("pointerup", onPointerUp);
+ };
+ }, [dragTabId, tabs, onReorderTabs]);
+
+ const dragIdx = tabs.findIndex((t) => t.id === dragTabId);
+ const target = dragTargetIndex ?? dragIdx;
+
+ return (
+ <div className="flex flex-col shrink-0 min-w-0">
+ <div
+ className={`flex items-end bg-sidebar min-w-0 transition-all duration-200 ${open ? "h-12.5 border-b border-border" : "h-0 overflow-hidden"}`}
+ >
+ <div
+ ref={tabBarRef}
+ className="flex h-full flex-1 min-w-0 overflow-x-auto scrollbar-none pl-px"
+ >
+ {tabs.map((tab, index) => {
+ const active = tab.id === activeTabId;
+ const isDragging = dragTabId === tab.id;
+ let translateX = 0;
+ if (
+ dragTabId &&
+ !isDragging &&
+ dragIdx !== -1 &&
+ target !== null &&
+ target !== dragIdx
+ ) {
+ const draggedWidth =
+ tabEls.current.get(dragTabId)?.offsetWidth ?? 0;
+ if (dragIdx < target && index > dragIdx && index <= target)
+ translateX = -draggedWidth;
+ else if (dragIdx > target && index < dragIdx && index >= target)
+ translateX = draggedWidth;
+ }
+ return (
+ <div
+ key={tab.id}
+ ref={(el) => {
+ if (el) tabEls.current.set(tab.id, el);
+ else tabEls.current.delete(tab.id);
+ }}
+ onClick={() =>
+ !dragTabId && !didDrag.current && onSetActiveTab(tab.id)
+ }
+ onMouseDown={(e) => {
+ if (e.button === 1 && tab.type !== "dashboard") {
+ e.preventDefault();
+ onCloseTab(tab.id);
+ }
+ }}
+ onPointerDown={(e) => {
+ if (e.button !== 0 || tab.type === "dashboard") return;
+ e.preventDefault();
+ const el = tabEls.current.get(tab.id);
+ if (!el || !tabBarRef.current) return;
+ const rect = el.getBoundingClientRect();
+ const barRect = tabBarRef.current.getBoundingClientRect();
+ dragData.current = {
+ id: tab.id,
+ index,
+ startX: e.clientX,
+ startY: e.clientY,
+ offsetX: e.clientX - rect.left,
+ width: rect.width,
+ barTop: barRect.top,
+ barHeight: barRect.height,
+ x: rect.left,
+ y: barRect.top,
+ };
+ setDragTabId(tab.id);
+ setDragTargetIndex(index);
+ setDragPos({ x: rect.left, y: barRect.top });
+ (e.currentTarget as HTMLElement).setPointerCapture(
+ e.pointerId,
+ );
+ }}
+ style={{
+ transform: isDragging
+ ? "none"
+ : `translateX(${translateX}px)`,
+ transition:
+ dragTabId && !isDragging ? "transform 200ms ease" : "none",
+ opacity: isDragging ? 0 : 1,
+ cursor:
+ tab.type === "dashboard"
+ ? "pointer"
+ : isDragging
+ ? "grabbing"
+ : "grab",
+ userSelect: "none",
+ }}
+ className={`group/tab flex items-center gap-2 shrink-0 transition-colors border-r border-border text-sm
+ ${index === 0 && tab.type !== "dashboard" ? "border-l border-border" : ""}
+ ${
+ tab.type === "dashboard"
+ ? `px-2.5 md:px-3.5 ${active ? "border-b-2 border-b-accent-brand bg-surface text-foreground" : "text-muted-foreground hover:text-foreground hover:bg-surface"}`
+ : `px-2.5 md:px-4 font-medium ${active ? "border-b-2 border-b-accent-brand bg-surface text-foreground" : "text-muted-foreground hover:text-foreground hover:bg-surface"}`
+ }`}
+ >
+ {tabIcon(tab.type)}
+ {tab.type !== "dashboard" && tab.label}
+ {tab.type !== "dashboard" && (
+ <button
+ onPointerDown={(e) => e.stopPropagation()}
+ onClick={(e) => {
+ e.stopPropagation();
+ onCloseTab(tab.id);
+ }}
+ className={`flex items-center justify-center size-5 md:size-4 rounded-sm transition-opacity text-muted-foreground hover:text-foreground hover:bg-muted ml-1 ${active ? "opacity-100" : "opacity-0 group-hover/tab:opacity-100"}`}
+ >
+ <X className="size-3" />
+ </button>
+ )}
+ </div>
+ );
+ })}
+
+ {dragTabId &&
+ dragPos &&
+ (() => {
+ const tab = tabs.find((t) => t.id === dragTabId)!;
+ const active = tab.id === activeTabId;
+ return (
+ <div
+ style={{
+ position: "fixed",
+ left: dragPos.x,
+ top: dragPos.y,
+ width: tabEls.current.get(dragTabId)?.offsetWidth,
+ height: tabEls.current.get(dragTabId)?.offsetHeight,
+ pointerEvents: "none",
+ zIndex: 9999,
+ opacity: 0.85,
+ }}
+ className={`flex items-center gap-2 shrink-0 border border-border text-sm shadow-lg
+ ${
+ tab.type === "dashboard"
+ ? `px-3.5 ${active ? "border-b-2 border-b-accent-brand bg-surface text-foreground" : "bg-sidebar text-muted-foreground"}`
+ : `px-4 font-medium ${active ? "border-b-2 border-b-accent-brand bg-surface text-foreground" : "bg-sidebar text-muted-foreground"}`
+ }`}
+ >
+ {tabIcon(tab.type)}
+ {tab.type !== "dashboard" && tab.label}
+ </div>
+ );
+ })()}
+ </div>
+
+ <div
+ className={`flex items-center h-full shrink-0 ${open ? "" : "invisible"}`}
+ >
+ <Separator orientation="vertical" />
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="h-full w-12.5 rounded-none text-muted-foreground hover:text-foreground"
+ >
+ <ChevronDown className="size-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ align="end"
+ sideOffset={1}
+ className="w-56 border-t-0 [clip-path:inset(0px_-4px_-4px_-4px)] p-0"
+ >
+ {tabs.map((tab) => (
+ <div
+ key={tab.id}
+ onClick={() => onSetActiveTab(tab.id)}
+ className={`flex items-center justify-between px-2 py-2 text-xs cursor-default hover:bg-accent hover:text-accent-foreground ${tab.id === activeTabId ? "text-foreground" : "text-muted-foreground"}`}
+ >
+ <div className="flex items-center gap-2 flex-1 min-w-0">
+ {tabIcon(tab.type)}
+ <span className="truncate">
+ {tab.type === "dashboard" ? "Dashboard" : tab.label}
+ </span>
+ </div>
+ {tab.type !== "dashboard" && (
+ <button
+ onClick={(e) => {
+ e.stopPropagation();
+ onCloseTab(tab.id);
+ }}
+ className="shrink-0 ml-2 text-muted-foreground hover:text-foreground"
+ >
+ <X className="size-3" />
+ </button>
+ )}
+ </div>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <Separator orientation="vertical" />
+ <Button
+ variant="ghost"
+ size="icon"
+ className="h-full w-12.5 rounded-none text-muted-foreground hover:text-foreground"
+ onClick={() => setOpen((o) => !o)}
+ >
+ <ChevronUp
+ className={`size-4 transition-transform ${open ? "" : "rotate-180"}`}
+ />
+ </Button>
+ </div>
+ </div>
+ {!open && (
+ <button
+ onClick={() => setOpen(true)}
+ className="flex items-center justify-center w-full h-6 bg-sidebar border-b border-border text-muted-foreground hover:text-accent-brand hover:bg-accent-brand/5 transition-colors shrink-0"
+ >
+ <ChevronDown className="size-3.5" />
+ </button>
+ )}
+ </div>
+ );
+}
diff --git a/src/ui/desktop/navigation/tabs/TabContext.tsx b/src/ui/shell/TabContext.tsx
similarity index 95%
rename from src/ui/desktop/navigation/tabs/TabContext.tsx
rename to src/ui/shell/TabContext.tsx
index 33f5f24b2..c6b1e98b5 100644
--- a/src/ui/desktop/navigation/tabs/TabContext.tsx
+++ b/src/ui/shell/TabContext.tsx
@@ -9,7 +9,7 @@ import React, {
type ReactNode,
} from "react";
import { useTranslation } from "react-i18next";
-import type { TabContextTab, TerminalRefHandle } from "../../../types/index.js";
+import type { TabContextTab, TerminalRefHandle } from "@/types/index";
export type Tab = TabContextTab;
@@ -52,6 +52,26 @@ export function useTabs() {
return context;
}
+const NOOP_TABS: TabContextType = {
+ tabs: [],
+ currentTab: null,
+ allSplitScreenTab: [],
+ addTab: () => -1,
+ removeTab: () => {},
+ setCurrentTab: () => {},
+ setSplitScreenTab: () => {},
+ getTab: () => undefined,
+ reorderTabs: () => {},
+ updateHostConfig: () => {},
+ updateTab: () => {},
+ previewTerminalTheme: null,
+ setPreviewTerminalTheme: () => {},
+};
+
+export function useTabsSafe(): TabContextType {
+ return useContext(TabContext) ?? NOOP_TABS;
+}
+
interface TabProviderProps {
children: ReactNode;
}
diff --git a/src/ui/shell/tabUtils.tsx b/src/ui/shell/tabUtils.tsx
new file mode 100644
index 000000000..78790291a
--- /dev/null
+++ b/src/ui/shell/tabUtils.tsx
@@ -0,0 +1,206 @@
+import {
+ Box,
+ FolderSearch,
+ LayoutDashboard,
+ Monitor,
+ Network,
+ Server,
+ Settings,
+ Terminal,
+ User,
+ Activity,
+ TerminalSquare,
+} from "lucide-react";
+import { useTranslation } from "react-i18next";
+import { CommandHistoryProvider } from "@/features/terminal/command-history/CommandHistoryContext";
+import { Terminal as TerminalFeature } from "@/features/terminal/Terminal";
+import { FileManager } from "@/features/file-manager/FileManager";
+import { DockerManager } from "@/features/docker/DockerManager";
+import { ServerStats } from "@/features/server-stats/ServerStats";
+import GuacamoleApp from "@/features/guacamole/GuacamoleApp";
+import { DashboardTab } from "@/dashboard/DashboardTab";
+import { TunnelTab } from "@/features/tunnel/TunnelTab";
+import type { Tab, TabType, Host } from "@/types/ui-types";
+import type { SSHHost } from "@/types";
+
+function hostToSSHHost(h: Host): SSHHost {
+ return {
+ id: parseInt(h.id, 10),
+ name: h.name,
+ ip: h.ip,
+ port: h.port,
+ username: h.username,
+ folder: h.folder ?? "",
+ tags: h.tags ?? [],
+ pin: h.pin ?? false,
+ authType: h.authType,
+ password: h.password,
+ key: h.key,
+ keyPassword: h.keyPassword,
+ keyType: h.keyType,
+ credentialId: h.credentialId ? parseInt(h.credentialId, 10) : undefined,
+ terminalConfig: h.terminalConfig,
+ enableTerminal: h.enableTerminal ?? false,
+ enableTunnel: h.enableTunnel ?? false,
+ enableFileManager: h.enableFileManager ?? false,
+ enableDocker: h.enableDocker ?? false,
+ showTerminalInSidebar: true,
+ showFileManagerInSidebar: true,
+ showTunnelInSidebar: true,
+ showDockerInSidebar: true,
+ showServerStatsInSidebar: true,
+ defaultPath: h.defaultPath ?? "",
+ tunnelConnections: [],
+ connectionType: "ssh",
+ createdAt: "",
+ updatedAt: "",
+ } as SSHHost;
+}
+
+function EmptyState({
+ icon: Icon,
+ messageKey,
+}: {
+ icon: React.ElementType;
+ messageKey: string;
+}) {
+ const { t } = useTranslation();
+ return (
+ <div className="flex flex-col items-center justify-center flex-1 gap-3 p-6 text-center">
+ <div className="size-10 rounded-full bg-muted/40 flex items-center justify-center">
+ <Icon className="size-5 text-muted-foreground/30" />
+ </div>
+ <span className="text-sm font-semibold text-muted-foreground/60">
+ {t(messageKey)}
+ </span>
+ </div>
+ );
+}
+
+export function tabIcon(type: TabType) {
+ switch (type) {
+ case "dashboard":
+ return <LayoutDashboard className="size-3.5" />;
+ case "terminal":
+ return <Terminal className="size-3.5" />;
+ case "rdp":
+ return <Monitor className="size-3.5" />;
+ case "vnc":
+ return <Monitor className="size-3.5" />;
+ case "telnet":
+ return <Terminal className="size-3.5" />;
+ case "stats":
+ return <Server className="size-3.5" />;
+ case "files":
+ return <FolderSearch className="size-3.5" />;
+ case "host-manager":
+ return <Server className="size-3.5" />;
+ case "user-profile":
+ return <User className="size-3.5" />;
+ case "admin-settings":
+ return <Settings className="size-3.5" />;
+ case "docker":
+ return <Box className="size-3.5" />;
+ case "tunnel":
+ return <Network className="size-3.5" />;
+ }
+}
+
+export function renderTabContent(
+ tab: Tab,
+ onOpenSingletonTab?: (type: TabType) => void,
+ onOpenTab?: (host: Host, type: TabType) => void,
+) {
+ const { host, label } = tab;
+
+ switch (tab.type) {
+ case "dashboard":
+ return (
+ <DashboardTab
+ onOpenSingletonTab={onOpenSingletonTab!}
+ onOpenTab={onOpenTab!}
+ />
+ );
+
+ case "terminal":
+ if (!host)
+ return (
+ <EmptyState
+ icon={TerminalSquare}
+ messageKey="terminal.noHostSelected"
+ />
+ );
+ return (
+ <CommandHistoryProvider>
+ <TerminalFeature
+ hostConfig={
+ {
+ ...hostToSSHHost(host),
+ sshPort: host.sshPort ?? host.port,
+ } as any
+ }
+ isVisible={true}
+ title={label}
+ showTitle={false}
+ splitScreen={false}
+ onClose={() => {}}
+ />
+ </CommandHistoryProvider>
+ );
+
+ case "files":
+ if (!host)
+ return (
+ <EmptyState
+ icon={FolderSearch}
+ messageKey="fileManager.noHostSelected"
+ />
+ );
+ return <FileManager initialHost={hostToSSHHost(host)} />;
+
+ case "docker":
+ if (!host)
+ return <EmptyState icon={Box} messageKey="docker.noHostSelected" />;
+ return (
+ <DockerManager
+ hostConfig={hostToSSHHost(host)}
+ title={label}
+ isVisible={true}
+ isTopbarOpen={false}
+ embedded={true}
+ />
+ );
+
+ case "stats":
+ if (!host)
+ return (
+ <EmptyState icon={Activity} messageKey="serverStats.noHostSelected" />
+ );
+ return (
+ <ServerStats
+ hostConfig={hostToSSHHost(host) as any}
+ title={label}
+ isVisible={true}
+ isTopbarOpen={false}
+ embedded={true}
+ />
+ );
+
+ case "tunnel":
+ return <TunnelTab label={label} host={host} />;
+
+ case "rdp":
+ case "vnc":
+ case "telnet":
+ if (!host)
+ return (
+ <EmptyState icon={Monitor} messageKey="guacamole.noHostSelected" />
+ );
+ return <GuacamoleApp hostId={host.id} />;
+
+ case "host-manager":
+ case "user-profile":
+ case "admin-settings":
+ return null;
+ }
+}
diff --git a/src/ui/sidebar/AdminSettingsPanel.tsx b/src/ui/sidebar/AdminSettingsPanel.tsx
new file mode 100644
index 000000000..61e8d96b5
--- /dev/null
+++ b/src/ui/sidebar/AdminSettingsPanel.tsx
@@ -0,0 +1,1110 @@
+import { useState, useEffect } from "react";
+import {
+ getUserList,
+ getSessions,
+ getRoles,
+ getApiKeys,
+ deleteUser,
+ revokeSession,
+ deleteRole,
+ deleteApiKey,
+} from "@/main-axios";
+import type { ApiKey } from "@/main-axios";
+import type React from "react";
+import { Button } from "@/components/button";
+import { Input } from "@/components/input";
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogDescription,
+} from "@/components/dialog";
+import {
+ Activity,
+ AlertCircle,
+ ChevronDown,
+ Database,
+ Eye,
+ KeyRound,
+ Network,
+ Pencil,
+ Plus,
+ RefreshCw,
+ Settings,
+ Share2,
+ Shield,
+ Trash2,
+ User,
+ X,
+} from "lucide-react";
+import { SettingRow } from "@/components/section-card";
+import type { AdminSection } from "@/types/ui-types";
+import type { Role } from "@/main-axios";
+
+function AdminToggle({ on, onToggle }: { on: boolean; onToggle: () => void }) {
+ return (
+ <button
+ onClick={onToggle}
+ className={`relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center border-2 transition-colors ${on ? "bg-accent-brand border-accent-brand" : "bg-muted border-border"}`}
+ >
+ <span
+ className={`pointer-events-none inline-block h-3 w-3 bg-background shadow-sm transition-transform ${on ? "translate-x-4" : "translate-x-0.5"}`}
+ />
+ </button>
+ );
+}
+
+function AccordionSection({
+ label,
+ icon,
+ open,
+ onToggle,
+ children,
+}: {
+ label: string;
+ icon: React.ReactNode;
+ open: boolean;
+ onToggle: () => void;
+ children: React.ReactNode;
+}) {
+ return (
+ <div className="border border-border bg-card overflow-hidden">
+ <button
+ onClick={onToggle}
+ className="flex items-center gap-2 w-full px-3 py-2.5 text-left hover:bg-muted/40 transition-colors"
+ >
+ <span className="text-muted-foreground shrink-0">{icon}</span>
+ <span className="text-xs font-bold uppercase tracking-widest text-foreground flex-1">
+ {label}
+ </span>
+ <ChevronDown
+ className={`size-3.5 text-muted-foreground shrink-0 transition-transform duration-150 ${open ? "rotate-180" : ""}`}
+ />
+ </button>
+ {open && (
+ <div className="border-t border-border px-3 pb-3">{children}</div>
+ )}
+ </div>
+ );
+}
+
+export function AdminSettingsPanel() {
+ const [openSection, setOpenSection] = useState<AdminSection | null>(
+ "general",
+ );
+ const [allowRegistration, setAllowRegistration] = useState(true);
+ const [allowPasswordLogin, setAllowPasswordLogin] = useState(true);
+ const [allowPasswordReset, setAllowPasswordReset] = useState(true);
+ const [sessionTimeout, setSessionTimeout] = useState("24");
+ const [statusInterval, setStatusInterval] = useState("60");
+ const [metricsInterval, setMetricsInterval] = useState("30");
+ const [guacEnabled, setGuacEnabled] = useState(false);
+ const [guacUrl, setGuacUrl] = useState("guacd:4822");
+ const [logLevel, setLogLevel] = useState("info");
+ const [importFile, setImportFile] = useState<string | null>(null);
+ const [showCreateRole, setShowCreateRole] = useState(false);
+ const [showCreateKey, setShowCreateKey] = useState(false);
+ const [createUserOpen, setCreateUserOpen] = useState(false);
+ const [editUserOpen, setEditUserOpen] = useState(false);
+ const [editUserTarget, setEditUserTarget] = useState<any | null>(null);
+ const [linkAccountOpen, setLinkAccountOpen] = useState(false);
+ const [linkAccountTarget, setLinkAccountTarget] = useState<{
+ id: string;
+ username: string;
+ } | null>(null);
+
+ const [users, setUsers] = useState<any[]>([]);
+ const [sessions, setSessions] = useState<any[]>([]);
+ const [roles, setRoles] = useState<Role[]>([]);
+ const [apiKeys, setApiKeys] = useState<ApiKey[]>([]);
+
+ useEffect(() => {
+ getUserList()
+ .then(({ users: u }) => setUsers(u))
+ .catch(() => {});
+ getSessions()
+ .then(({ sessions: s }) => setSessions(s))
+ .catch(() => {});
+ getRoles()
+ .then(({ roles: r }) => setRoles(r))
+ .catch(() => {});
+ getApiKeys()
+ .then(({ apiKeys: k }) => setApiKeys(k))
+ .catch(() => {});
+ }, []);
+
+ function toggle(id: AdminSection) {
+ setOpenSection((prev) => (prev === id ? null : id));
+ }
+
+ return (
+ <div className="flex flex-col gap-2 p-3">
+ {/* General */}
+ <AccordionSection
+ label="General"
+ icon={<Settings className="size-3.5" />}
+ open={openSection === "general"}
+ onToggle={() => toggle("general")}
+ >
+ <div className="flex flex-col gap-0 pt-2">
+ <SettingRow
+ label="Allow User Registration"
+ description="Let new users self-register"
+ >
+ <AdminToggle
+ on={allowRegistration}
+ onToggle={() => setAllowRegistration((o) => !o)}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Allow Password Login"
+ description="Username/password login"
+ >
+ <AdminToggle
+ on={allowPasswordLogin}
+ onToggle={() => setAllowPasswordLogin((o) => !o)}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Allow Password Reset"
+ description="Email-based password reset"
+ >
+ <AdminToggle
+ on={allowPasswordReset}
+ onToggle={() => setAllowPasswordReset((o) => !o)}
+ />
+ </SettingRow>
+
+ <div className="flex flex-col gap-2 border-t border-border pt-3 mt-2">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Session Timeout
+ </span>
+ <div className="flex items-center gap-2">
+ <Input
+ type="number"
+ min={1}
+ max={720}
+ value={sessionTimeout}
+ onChange={(e) => setSessionTimeout(e.target.value)}
+ className="w-20 text-sm"
+ />
+ <span className="text-xs text-muted-foreground">hours</span>
+ </div>
+ <span className="text-[10px] text-muted-foreground">
+ Min 1h · Max 720h
+ </span>
+ </div>
+
+ <div className="flex flex-col gap-2 border-t border-border pt-3 mt-2">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Monitoring Defaults
+ </span>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">
+ Status Check
+ </label>
+ <div className="flex items-center gap-2">
+ <Input
+ type="number"
+ value={statusInterval}
+ onChange={(e) => setStatusInterval(e.target.value)}
+ className="w-20 text-sm"
+ />
+ <span className="text-xs text-muted-foreground">sec</span>
+ </div>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">
+ Metrics
+ </label>
+ <div className="flex items-center gap-2">
+ <Input
+ type="number"
+ value={metricsInterval}
+ onChange={(e) => setMetricsInterval(e.target.value)}
+ className="w-20 text-sm"
+ />
+ <span className="text-xs text-muted-foreground">sec</span>
+ </div>
+ </div>
+ </div>
+
+ <div className="flex flex-col gap-2 border-t border-border pt-3 mt-2">
+ <SettingRow
+ label="Enable Guacamole"
+ description="RDP/VNC remote desktop"
+ >
+ <AdminToggle
+ on={guacEnabled}
+ onToggle={() => setGuacEnabled((o) => !o)}
+ />
+ </SettingRow>
+ {guacEnabled && (
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">
+ guacd URL
+ </label>
+ <Input
+ value={guacUrl}
+ onChange={(e) => setGuacUrl(e.target.value)}
+ placeholder="guacd:4822"
+ className="text-sm"
+ />
+ </div>
+ )}
+ </div>
+
+ <div className="flex flex-col gap-2 border-t border-border pt-3 mt-2">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Log Level
+ </span>
+ <div className="flex gap-1.5 flex-wrap">
+ {["debug", "info", "warn", "error"].map((l) => (
+ <button
+ key={l}
+ onClick={() => setLogLevel(l)}
+ className={`px-2 py-1 text-[10px] font-semibold border capitalize transition-colors ${logLevel === l ? "border-accent-brand/40 bg-accent-brand/10 text-accent-brand" : "border-border text-muted-foreground hover:text-foreground"}`}
+ >
+ {l}
+ </button>
+ ))}
+ </div>
+ </div>
+ </div>
+ </AccordionSection>
+
+ {/* OIDC */}
+ <AccordionSection
+ label="OIDC"
+ icon={<Shield className="size-3.5" />}
+ open={openSection === "oidc"}
+ onToggle={() => toggle("oidc")}
+ >
+ <div className="flex flex-col gap-3 pt-3">
+ <span className="text-[10px] text-muted-foreground">
+ Configure OpenID Connect for SSO. Fields marked{" "}
+ <span className="text-accent-brand">*</span> are required.
+ </span>
+ {(
+ [
+ {
+ label: "Client ID",
+ placeholder: "your-client-id",
+ required: true,
+ },
+ {
+ label: "Client Secret",
+ placeholder: "your-client-secret",
+ type: "password",
+ required: true,
+ },
+ {
+ label: "Authorization URL",
+ placeholder: "https://provider/oauth2/auth",
+ required: true,
+ },
+ {
+ label: "Issuer URL",
+ placeholder: "https://provider",
+ required: true,
+ },
+ {
+ label: "Token URL",
+ placeholder: "https://provider/oauth2/token",
+ required: true,
+ },
+ {
+ label: "User Identifier Path",
+ placeholder: "sub",
+ required: true,
+ },
+ {
+ label: "Display Name Path",
+ placeholder: "name",
+ required: true,
+ },
+ {
+ label: "Scopes",
+ placeholder: "openid email profile",
+ required: true,
+ },
+ {
+ label: "Override Userinfo URL",
+ placeholder: "https://provider/oauth2/userinfo",
+ },
+ ] as {
+ label: string;
+ placeholder: string;
+ type?: string;
+ required?: boolean;
+ }[]
+ ).map((f) => (
+ <div key={f.label} className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">
+ {f.label}
+ {f.required && (
+ <span className="text-accent-brand ml-0.5">*</span>
+ )}
+ </label>
+ <Input
+ type={f.type ?? "text"}
+ placeholder={f.placeholder}
+ className="text-xs"
+ />
+ </div>
+ ))}
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">
+ Allowed Users
+ </label>
+ <span className="text-[10px] text-muted-foreground">
+ One email per line. Leave empty to allow all.
+ </span>
+ <textarea
+ rows={3}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-border text-foreground placeholder:text-muted-foreground resize-none outline-none focus:ring-1 focus:ring-ring font-mono"
+ />
+ </div>
+ <div className="flex gap-2 justify-end">
+ <Button
+ variant="outline"
+ size="sm"
+ className="text-xs border-destructive/40 text-destructive hover:bg-destructive/10 hover:text-destructive"
+ >
+ <Trash2 className="size-3" />
+ Remove
+ </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ className="text-xs border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand"
+ >
+ <RefreshCw className="size-3" />
+ Save
+ </Button>
+ </div>
+ </div>
+ </AccordionSection>
+
+ {/* Users */}
+ <AccordionSection
+ label="Users"
+ icon={<User className="size-3.5" />}
+ open={openSection === "users"}
+ onToggle={() => toggle("users")}
+ >
+ <div className="flex flex-col pt-2">
+ <div className="flex items-center justify-between py-2 border-b border-border">
+ <span className="text-[10px] text-muted-foreground">
+ {users.length} users
+ </span>
+ <div className="flex items-center gap-1">
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-foreground"
+ >
+ <RefreshCw className="size-3" />
+ </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-6 text-[10px] border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand"
+ onClick={() => setCreateUserOpen(true)}
+ >
+ <Plus className="size-3" />
+ Create
+ </Button>
+ </div>
+ </div>
+ {users.map((user) => {
+ const authLabel =
+ user.isOidc && user.passwordHash
+ ? "Dual"
+ : user.isOidc
+ ? "OIDC"
+ : "Local";
+ return (
+ <div
+ key={user.id}
+ className="flex items-center justify-between py-2.5 border-b border-border last:border-0"
+ >
+ <div className="flex items-center gap-2 min-w-0">
+ <div className="size-6 bg-muted border border-border flex items-center justify-center text-[10px] font-bold shrink-0">
+ {user.username[0].toUpperCase()}
+ </div>
+ <div className="flex flex-col gap-0.5 min-w-0">
+ <span className="text-xs font-semibold truncate max-w-[120px]">
+ {user.username}
+ </span>
+ <div className="flex items-center gap-1">
+ {user.isAdmin && (
+ <span className="text-[9px] font-semibold px-1 py-px border border-accent-brand/40 bg-accent-brand/10 text-accent-brand">
+ ADMIN
+ </span>
+ )}
+ <span className="text-[9px] font-semibold px-1 py-px border border-border text-muted-foreground">
+ {authLabel}
+ </span>
+ </div>
+ </div>
+ </div>
+ <div className="flex items-center gap-0.5 shrink-0">
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-foreground"
+ onClick={() => {
+ setEditUserTarget(user);
+ setEditUserOpen(true);
+ }}
+ >
+ <Pencil className="size-3" />
+ </Button>
+ {user.isOidc && !user.passwordHash && (
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-foreground"
+ onClick={() => {
+ setLinkAccountTarget({
+ id: user.id,
+ username: user.username,
+ });
+ setLinkAccountOpen(true);
+ }}
+ >
+ <Share2 className="size-3" />
+ </Button>
+ )}
+ {user.isOidc && user.passwordHash && (
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-accent-brand"
+ >
+ <X className="size-3" />
+ </Button>
+ )}
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-destructive"
+ disabled={user.is_admin}
+ onClick={async () => {
+ try {
+ await deleteUser(user.userId);
+ setUsers((prev) =>
+ prev.filter((u) => u.userId !== user.userId),
+ );
+ } catch {
+ /* ignore */
+ }
+ }}
+ >
+ <Trash2 className="size-3" />
+ </Button>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ </AccordionSection>
+
+ {/* Sessions */}
+ <AccordionSection
+ label="Sessions"
+ icon={<Activity className="size-3.5" />}
+ open={openSection === "sessions"}
+ onToggle={() => toggle("sessions")}
+ >
+ <div className="flex flex-col pt-2">
+ <div className="flex items-center justify-between py-2 border-b border-border">
+ <span className="text-[10px] text-muted-foreground">
+ {sessions.length} active
+ </span>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-foreground"
+ >
+ <RefreshCw className="size-3" />
+ </Button>
+ </div>
+ {sessions.map((session) => (
+ <div
+ key={session.id}
+ className="flex items-start justify-between py-2.5 border-b border-border last:border-0 gap-2"
+ >
+ <div className="flex flex-col gap-0.5 min-w-0 flex-1">
+ <div className="flex items-center gap-1.5 flex-wrap">
+ <span className="text-xs font-semibold">
+ {session.username}
+ </span>
+ {session.isCurrentSession && (
+ <span className="text-[9px] font-semibold px-1 py-px border border-accent-brand/40 bg-accent-brand/10 text-accent-brand">
+ YOU
+ </span>
+ )}
+ </div>
+ <span className="text-[10px] text-muted-foreground truncate">
+ {session.deviceInfo}
+ </span>
+ <span className="text-[10px] text-muted-foreground">
+ Active: {session.lastActiveAt}
+ </span>
+ <span className="text-[10px] text-muted-foreground">
+ Exp: {session.expiresAt}
+ </span>
+ </div>
+ <div className="flex items-center gap-0.5 shrink-0">
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-[10px] text-muted-foreground hover:text-destructive h-6 px-1.5"
+ >
+ All
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-destructive"
+ onClick={async () => {
+ try {
+ await revokeSession(session.id);
+ setSessions((prev) =>
+ prev.filter((s) => s.id !== session.id),
+ );
+ } catch {
+ /* ignore */
+ }
+ }}
+ >
+ <Trash2 className="size-3" />
+ </Button>
+ </div>
+ </div>
+ ))}
+ </div>
+ </AccordionSection>
+
+ {/* Roles */}
+ <AccordionSection
+ label="Roles"
+ icon={<KeyRound className="size-3.5" />}
+ open={openSection === "roles"}
+ onToggle={() => toggle("roles")}
+ >
+ <div className="flex flex-col pt-2">
+ <div className="flex items-center justify-between py-2 border-b border-border">
+ <span className="text-[10px] text-muted-foreground">
+ {roles.length} roles
+ </span>
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-6 text-[10px] border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand"
+ onClick={() => setShowCreateRole((o) => !o)}
+ >
+ <Plus className="size-3" />
+ Create
+ </Button>
+ </div>
+ {showCreateRole && (
+ <div className="flex flex-col gap-2.5 py-3 border-b border-border">
+ <span className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground">
+ New Role
+ </span>
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">
+ Name <span className="text-accent-brand">*</span>
+ </label>
+ <Input placeholder="e.g., developer" className="text-xs" />
+ </div>
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">
+ Display Name <span className="text-accent-brand">*</span>
+ </label>
+ <Input placeholder="e.g., Developer" className="text-xs" />
+ </div>
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">
+ Description
+ </label>
+ <textarea
+ rows={2}
+ placeholder="Optional"
+ className="w-full px-2 py-1.5 text-xs bg-background border border-border text-foreground placeholder:text-muted-foreground resize-none outline-none focus:ring-1 focus:ring-ring"
+ />
+ </div>
+ <div className="flex justify-end gap-2">
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-xs"
+ onClick={() => setShowCreateRole(false)}
+ >
+ Cancel
+ </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ className="text-xs border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand"
+ >
+ Create
+ </Button>
+ </div>
+ </div>
+ )}
+ {roles.map((role) => (
+ <div
+ key={role.id}
+ className="flex items-center justify-between py-2.5 border-b border-border last:border-0"
+ >
+ <div className="flex flex-col gap-0.5 min-w-0">
+ <div className="flex items-center gap-1.5 flex-wrap">
+ <span className="text-xs font-semibold truncate">
+ {role.displayName}
+ </span>
+ {role.isSystem ? (
+ <span className="text-[9px] font-semibold px-1 py-px border border-border text-muted-foreground">
+ SYS
+ </span>
+ ) : (
+ <span className="text-[9px] font-semibold px-1 py-px border border-accent-brand/40 bg-accent-brand/10 text-accent-brand">
+ CUSTOM
+ </span>
+ )}
+ </div>
+ <span className="text-[10px] font-mono text-muted-foreground">
+ {role.name}
+ </span>
+ </div>
+ {!role.isSystem && (
+ <div className="flex items-center gap-0.5 shrink-0">
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-foreground"
+ >
+ <Pencil className="size-3" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-destructive"
+ onClick={async () => {
+ await deleteRole(role.id);
+ setRoles((prev) => prev.filter((r) => r.id !== role.id));
+ }}
+ >
+ <Trash2 className="size-3" />
+ </Button>
+ </div>
+ )}
+ </div>
+ ))}
+ </div>
+ </AccordionSection>
+
+ {/* Database */}
+ <AccordionSection
+ label="Database"
+ icon={<Database className="size-3.5" />}
+ open={openSection === "database"}
+ onToggle={() => toggle("database")}
+ >
+ <div className="flex flex-col gap-3 pt-3">
+ <div className="flex flex-col gap-1.5">
+ <span className="text-xs font-medium">Export Database</span>
+ <span className="text-[10px] text-muted-foreground">
+ Download a backup of all hosts, credentials, and settings
+ </span>
+ <Button
+ variant="outline"
+ size="sm"
+ className="self-start text-xs border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand mt-1"
+ >
+ Export
+ </Button>
+ </div>
+ <div className="flex flex-col gap-1.5 border-t border-border pt-3">
+ <span className="text-xs font-medium">Import Database</span>
+ <span className="text-[10px] text-muted-foreground">
+ {importFile
+ ? `Selected: ${importFile}`
+ : "Restore from a .sqlite backup file"}
+ </span>
+ <div className="flex items-center gap-2 mt-1">
+ <div className="relative">
+ <input
+ type="file"
+ accept=".sqlite,.db"
+ onChange={(e) =>
+ setImportFile(e.target.files?.[0]?.name ?? null)
+ }
+ className="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
+ />
+ <Button
+ variant="outline"
+ size="sm"
+ className="pointer-events-none text-xs"
+ >
+ {importFile ? "Change" : "Select File"}
+ </Button>
+ </div>
+ {importFile && (
+ <Button
+ variant="outline"
+ size="sm"
+ className="text-xs border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand"
+ >
+ Import
+ </Button>
+ )}
+ </div>
+ </div>
+ </div>
+ </AccordionSection>
+
+ {/* API Keys */}
+ <AccordionSection
+ label="API Keys"
+ icon={<Network className="size-3.5" />}
+ open={openSection === "api-keys"}
+ onToggle={() => toggle("api-keys")}
+ >
+ <div className="flex flex-col pt-2">
+ <div className="flex items-center justify-between py-2 border-b border-border">
+ <span className="text-[10px] text-muted-foreground">
+ {apiKeys.length} keys
+ </span>
+ <div className="flex items-center gap-1">
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-foreground"
+ >
+ <RefreshCw className="size-3" />
+ </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-6 text-[10px] border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand"
+ onClick={() => setShowCreateKey((o) => !o)}
+ >
+ <Plus className="size-3" />
+ Create
+ </Button>
+ </div>
+ </div>
+ {showCreateKey && (
+ <div className="flex flex-col gap-2.5 py-3 border-b border-border">
+ <span className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground">
+ New API Key
+ </span>
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">
+ Name <span className="text-accent-brand">*</span>
+ </label>
+ <Input placeholder="e.g., CI Pipeline" className="text-xs" />
+ </div>
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">
+ Scoped User <span className="text-accent-brand">*</span>
+ </label>
+ <Input placeholder="Select a user" className="text-xs" />
+ </div>
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">
+ Expires At
+ </label>
+ <Input type="date" className="text-xs" />
+ </div>
+ <div className="flex justify-end gap-2">
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-xs"
+ onClick={() => setShowCreateKey(false)}
+ >
+ Cancel
+ </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ className="text-xs border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand"
+ >
+ Create Key
+ </Button>
+ </div>
+ </div>
+ )}
+ {apiKeys.map((key) => (
+ <div
+ key={key.id}
+ className="flex items-start justify-between py-2.5 border-b border-border last:border-0 gap-2"
+ >
+ <div className="flex flex-col gap-0.5 min-w-0 flex-1">
+ <div className="flex items-center gap-1.5 flex-wrap">
+ <span className="text-xs font-semibold truncate">
+ {key.name}
+ </span>
+ {!key.isActive && (
+ <span className="text-[9px] font-semibold px-1 py-px border border-destructive/40 bg-destructive/10 text-destructive">
+ REVOKED
+ </span>
+ )}
+ </div>
+ <span className="text-[10px] text-muted-foreground">
+ User: {key.username}
+ </span>
+ <span className="text-[10px] font-mono text-muted-foreground truncate">
+ {key.tokenPrefix}…
+ </span>
+ <span className="text-[10px] text-muted-foreground">
+ {key.createdAt.split("T")[0]} ·{" "}
+ {key.expiresAt ? key.expiresAt.split("T")[0] : "No expiry"}
+ </span>
+ </div>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-destructive shrink-0"
+ onClick={async () => {
+ await deleteApiKey(key.id);
+ setApiKeys((prev) => prev.filter((k) => k.id !== key.id));
+ }}
+ >
+ <Trash2 className="size-3" />
+ </Button>
+ </div>
+ ))}
+ </div>
+ </AccordionSection>
+
+ {/* Dialogs */}
+ <Dialog open={createUserOpen} onOpenChange={setCreateUserOpen}>
+ <DialogContent className="w-[calc(100vw-2rem)] sm:max-w-lg">
+ <DialogHeader>
+ <DialogTitle className="text-lg font-bold">Create User</DialogTitle>
+ <DialogDescription className="text-xs text-muted-foreground">
+ Create a new local account.
+ </DialogDescription>
+ </DialogHeader>
+ <div className="flex flex-col gap-4 mt-1">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-xs font-semibold uppercase tracking-widest text-muted-foreground">
+ Username <span className="text-accent-brand">*</span>
+ </label>
+ <Input placeholder="Enter username" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-xs font-semibold uppercase tracking-widest text-muted-foreground">
+ Password <span className="text-accent-brand">*</span>
+ </label>
+ <div className="relative">
+ <Input
+ type="password"
+ placeholder="Enter password"
+ className="pr-9"
+ />
+ <button className="absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground">
+ <Eye className="size-4" />
+ </button>
+ </div>
+ <span className="text-xs text-muted-foreground">
+ Minimum 6 characters.
+ </span>
+ </div>
+ </div>
+ <div className="flex justify-end gap-2 mt-2">
+ <Button variant="ghost" onClick={() => setCreateUserOpen(false)}>
+ Cancel
+ </Button>
+ <Button
+ variant="outline"
+ className="border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand"
+ >
+ Create User
+ </Button>
+ </div>
+ </DialogContent>
+ </Dialog>
+
+ <Dialog open={editUserOpen} onOpenChange={setEditUserOpen}>
+ <DialogContent className="w-[calc(100vw-2rem)] sm:max-w-lg">
+ <DialogHeader>
+ <DialogTitle className="text-lg font-bold">
+ Manage User: {editUserTarget?.username}
+ </DialogTitle>
+ <DialogDescription className="text-xs text-muted-foreground">
+ Edit roles, admin status, sessions, and account settings.
+ </DialogDescription>
+ </DialogHeader>
+ {editUserTarget && (
+ <div className="flex flex-col gap-0 mt-1 divide-y divide-border">
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-2 py-3">
+ <div className="flex flex-col gap-0.5">
+ <span className="text-xs text-muted-foreground uppercase tracking-widest font-semibold">
+ Username
+ </span>
+ <span className="text-sm font-semibold">
+ {editUserTarget.username}
+ </span>
+ </div>
+ <div className="flex flex-col gap-0.5">
+ <span className="text-xs text-muted-foreground uppercase tracking-widest font-semibold">
+ Auth Type
+ </span>
+ <span className="text-sm font-semibold">
+ {editUserTarget.isOidc && editUserTarget.passwordHash
+ ? "Dual Auth"
+ : editUserTarget.isOidc
+ ? "OIDC"
+ : "Local"}
+ </span>
+ </div>
+ <div className="flex flex-col gap-0.5">
+ <span className="text-xs text-muted-foreground uppercase tracking-widest font-semibold">
+ Admin Status
+ </span>
+ <span className="text-sm font-semibold">
+ {editUserTarget.isAdmin ? "Administrator" : "Regular User"}
+ </span>
+ </div>
+ <div className="flex flex-col gap-0.5">
+ <span className="text-xs text-muted-foreground uppercase tracking-widest font-semibold">
+ User ID
+ </span>
+ <span className="text-xs font-mono text-muted-foreground truncate">
+ {editUserTarget.id}
+ </span>
+ </div>
+ </div>
+ <div className="flex items-center justify-between py-3">
+ <div className="flex flex-col gap-0.5">
+ <span className="text-sm font-medium">Administrator</span>
+ <span className="text-xs text-muted-foreground">
+ Full access to all admin settings
+ </span>
+ </div>
+ <AdminToggle on={editUserTarget.isAdmin} onToggle={() => {}} />
+ </div>
+ <div className="flex flex-col gap-2 py-3">
+ <span className="text-xs font-semibold uppercase tracking-widest text-muted-foreground">
+ Roles
+ </span>
+ <div className="flex flex-wrap gap-1.5">
+ {roles
+ .filter((r) => !r.isSystem)
+ .map((role) => (
+ <div
+ key={role.id}
+ className="flex items-center gap-1 px-2 py-1 border border-border text-xs"
+ >
+ <span>{role.displayName}</span>
+ <button className="text-muted-foreground hover:text-destructive ml-1">
+ <X className="size-3" />
+ </button>
+ </div>
+ ))}
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-7 text-xs border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand"
+ >
+ <Plus className="size-3" />
+ Add Role
+ </Button>
+ </div>
+ </div>
+ <div className="flex items-center justify-between py-3">
+ <div className="flex flex-col gap-0.5">
+ <span className="text-sm font-medium">
+ Revoke All Sessions
+ </span>
+ <span className="text-xs text-muted-foreground">
+ Force re-login on all devices
+ </span>
+ </div>
+ <Button
+ variant="outline"
+ size="sm"
+ className="border-destructive/40 text-destructive hover:bg-destructive/10 hover:text-destructive shrink-0 ml-8"
+ >
+ Revoke
+ </Button>
+ </div>
+ <div className="flex flex-col gap-2 py-3">
+ <div className="flex items-start gap-2.5 border border-destructive/30 bg-destructive/5 px-3 py-2.5">
+ <AlertCircle className="size-4 text-destructive shrink-0 mt-0.5" />
+ <span className="text-xs text-destructive">
+ Deleting this user is permanent.
+ </span>
+ </div>
+ <Button
+ variant="outline"
+ className="w-full border-destructive/40 text-destructive hover:bg-destructive/10 hover:text-destructive"
+ disabled={editUserTarget.isAdmin}
+ >
+ <Trash2 className="size-3.5" />
+ Delete {editUserTarget.username}
+ </Button>
+ </div>
+ </div>
+ )}
+ </DialogContent>
+ </Dialog>
+
+ <Dialog open={linkAccountOpen} onOpenChange={setLinkAccountOpen}>
+ <DialogContent className="w-[calc(100vw-2rem)] sm:max-w-lg">
+ <DialogHeader>
+ <DialogTitle className="text-lg font-bold">
+ Link OIDC to Password Account
+ </DialogTitle>
+ <DialogDescription className="text-xs text-muted-foreground">
+ Merge the OIDC account{" "}
+ <span className="font-semibold text-foreground">
+ {linkAccountTarget?.username}
+ </span>{" "}
+ with an existing local account.
+ </DialogDescription>
+ </DialogHeader>
+ <div className="flex flex-col gap-4 mt-1">
+ <div className="flex items-start gap-2.5 border border-destructive/30 bg-destructive/5 px-3 py-2.5">
+ <AlertCircle className="size-4 text-destructive shrink-0 mt-0.5" />
+ <div className="flex flex-col gap-1 text-xs text-destructive">
+ <span>This will:</span>
+ <ul className="list-disc list-inside space-y-0.5 ml-1">
+ <li>Delete the OIDC-only account</li>
+ <li>Add OIDC login to the target account</li>
+ <li>Allow both OIDC and password login</li>
+ </ul>
+ </div>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-xs font-semibold uppercase tracking-widest text-muted-foreground">
+ Target Username <span className="text-accent-brand">*</span>
+ </label>
+ <Input placeholder="Enter the local account username to link to" />
+ </div>
+ </div>
+ <div className="flex justify-end gap-2 mt-2">
+ <Button variant="ghost" onClick={() => setLinkAccountOpen(false)}>
+ Cancel
+ </Button>
+ <Button
+ variant="outline"
+ className="border-destructive/40 text-destructive hover:bg-destructive/10 hover:text-destructive"
+ >
+ Link Accounts
+ </Button>
+ </div>
+ </DialogContent>
+ </Dialog>
+ </div>
+ );
+}
diff --git a/src/ui/sidebar/AppRail.tsx b/src/ui/sidebar/AppRail.tsx
new file mode 100644
index 000000000..b76ea84ed
--- /dev/null
+++ b/src/ui/sidebar/AppRail.tsx
@@ -0,0 +1,219 @@
+import { useState } from "react";
+import {
+ Clock,
+ Hammer,
+ KeyRound,
+ LayoutPanelLeft,
+ Play,
+ Server,
+ Settings,
+ User,
+ Zap,
+} from "lucide-react";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@/components/dropdown-menu";
+import type { SplitMode, ToolsTab } from "@/types/ui-types";
+
+export type RailView =
+ | "hosts"
+ | "quick-connect"
+ | ToolsTab
+ | "user-profile"
+ | "admin-settings";
+
+type RailItem =
+ | {
+ kind?: undefined;
+ view: RailView;
+ icon: React.ReactNode;
+ title: string;
+ dot?: boolean;
+ }
+ | { kind: "separator" };
+
+function buildRailButtons(splitMode: SplitMode): RailItem[] {
+ return [
+ { view: "hosts", icon: <Server size={16} />, title: "Hosts" },
+ { kind: "separator" },
+ { view: "quick-connect", icon: <Zap size={16} />, title: "Quick Connect" },
+ { kind: "separator" },
+ { view: "ssh-tools", icon: <Hammer size={16} />, title: "SSH Tools" },
+ { kind: "separator" },
+ { view: "snippets", icon: <Play size={16} />, title: "Snippets" },
+ { kind: "separator" },
+ { view: "history", icon: <Clock size={16} />, title: "History" },
+ { kind: "separator" },
+ {
+ view: "split-screen",
+ icon: <LayoutPanelLeft size={16} />,
+ title: "Split Screen",
+ dot: splitMode !== "none",
+ },
+ { kind: "separator" },
+ ];
+}
+
+const btnBase =
+ "relative flex items-center gap-2.5 h-7 rounded shrink-0 transition-colors";
+const btnStyle = { margin: "0 4px", padding: "0 6px" };
+
+export function AppRail({
+ railView,
+ sidebarOpen,
+ splitMode,
+ username,
+ profileDropdownOpen,
+ onProfileDropdownChange,
+ onRailClick,
+ onLogout,
+}: {
+ railView: RailView;
+ sidebarOpen: boolean;
+ splitMode: SplitMode;
+ username: string;
+ profileDropdownOpen: boolean;
+ onProfileDropdownChange: (open: boolean) => void;
+ onRailClick: (view: RailView) => void;
+ onLogout: () => void;
+}) {
+ const [hovered, setHovered] = useState(false);
+ const railExpanded = hovered || profileDropdownOpen;
+ const railButtons = buildRailButtons(splitMode);
+
+ return (
+ <div
+ className="hidden md:flex flex-col items-stretch bg-sidebar border-r border-border shrink-0 overflow-hidden pt-2 gap-1 transition-[width] duration-200"
+ style={{ width: railExpanded ? 160 : 40 }}
+ onMouseEnter={() => setHovered(true)}
+ onMouseLeave={() => setHovered(false)}
+ >
+ <div className="flex flex-col flex-1 gap-1">
+ {railButtons.map((item, i) =>
+ item.kind === "separator" ? (
+ <div
+ key={`sep-${i}`}
+ className="mx-auto h-px bg-border my-0.5 shrink-0 transition-[width] duration-200"
+ style={{ width: railExpanded ? "calc(100% - 16px)" : 20 }}
+ />
+ ) : (
+ <button
+ key={item.view}
+ onClick={() => onRailClick(item.view)}
+ style={btnStyle}
+ className={`${btnBase} ${
+ sidebarOpen && railView === item.view
+ ? "text-accent-brand bg-accent-brand/10"
+ : "text-muted-foreground hover:text-foreground hover:bg-muted/60"
+ }`}
+ >
+ <span
+ className="shrink-0 flex items-center justify-center"
+ style={{ width: 16, height: 16 }}
+ >
+ {item.icon}
+ </span>
+ <span
+ className={`text-xs font-medium whitespace-nowrap overflow-hidden transition-opacity duration-150 ${
+ railExpanded ? "opacity-100 delay-75" : "opacity-0"
+ }`}
+ >
+ {item.title}
+ </span>
+ {item.dot && (
+ <span className="absolute top-0.5 right-0.5 size-1.5 rounded-full bg-accent-brand" />
+ )}
+ </button>
+ ),
+ )}
+ </div>
+
+ <div className="shrink-0 flex flex-col gap-1 border-t border-border pt-1 pb-1">
+ {(
+ [
+ {
+ view: "user-profile" as RailView,
+ icon: <User size={16} />,
+ title: "Profile",
+ },
+ {
+ view: "admin-settings" as RailView,
+ icon: <Settings size={16} />,
+ title: "Admin",
+ },
+ ] as const
+ ).map((item) => (
+ <button
+ key={item.view}
+ onClick={() => onRailClick(item.view)}
+ style={btnStyle}
+ className={`${btnBase} ${
+ sidebarOpen && railView === item.view
+ ? "text-accent-brand bg-accent-brand/10"
+ : "text-muted-foreground hover:text-foreground hover:bg-muted/60"
+ }`}
+ >
+ <span
+ className="shrink-0 flex items-center justify-center"
+ style={{ width: 16, height: 16 }}
+ >
+ {item.icon}
+ </span>
+ <span
+ className={`text-xs font-medium whitespace-nowrap overflow-hidden transition-opacity duration-150 ${railExpanded ? "opacity-100 delay-75" : "opacity-0"}`}
+ >
+ {item.title}
+ </span>
+ </button>
+ ))}
+ </div>
+
+ <div className="shrink-0 border-t border-border">
+ <DropdownMenu
+ open={profileDropdownOpen}
+ onOpenChange={onProfileDropdownChange}
+ >
+ <DropdownMenuTrigger asChild>
+ <button
+ className="flex items-center gap-2.5 w-full h-10 text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors"
+ style={{ padding: "0 6px" }}
+ >
+ <div
+ className="rounded-full bg-accent-brand/20 border border-accent-brand/30 flex items-center justify-center font-bold text-accent-brand shrink-0"
+ style={{ width: 24, height: 24, fontSize: 11 }}
+ >
+ {username.charAt(0).toUpperCase() || "U"}
+ </div>
+ <div
+ className={`flex flex-col items-start overflow-hidden transition-opacity duration-150 ${
+ railExpanded ? "opacity-100 delay-75" : "opacity-0"
+ }`}
+ >
+ <span className="text-xs font-semibold leading-tight whitespace-nowrap">
+ {username || "User"}
+ </span>
+ <span className="text-[10px] text-muted-foreground leading-tight whitespace-nowrap">
+ Administrator
+ </span>
+ </div>
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ side="right"
+ align="end"
+ sideOffset={1}
+ className="!w-auto min-w-max [clip-path:inset(-4px_-4px_-4px_0px)]"
+ >
+ <DropdownMenuItem variant="destructive" onClick={onLogout}>
+ <KeyRound size={14} />
+ Logout
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </div>
+ );
+}
diff --git a/src/ui/sidebar/HistoryPanel.tsx b/src/ui/sidebar/HistoryPanel.tsx
new file mode 100644
index 000000000..57655031d
--- /dev/null
+++ b/src/ui/sidebar/HistoryPanel.tsx
@@ -0,0 +1,133 @@
+import { useState, useEffect } from "react";
+import { useTranslation } from "react-i18next";
+import { Button } from "@/components/button";
+import { Input } from "@/components/input";
+import { Copy, Search, Terminal, Trash2 } from "lucide-react";
+import { getCommandHistory, deleteCommandFromHistory } from "@/main-axios";
+import type { Tab } from "@/types/ui-types";
+
+export function HistoryPanel({
+ activeTabId,
+ terminalTabs,
+}: {
+ activeTabId: string;
+ terminalTabs: Tab[];
+}) {
+ const { t } = useTranslation();
+ const [search, setSearch] = useState("");
+ const [commands, setCommands] = useState<string[]>([]);
+
+ const activeTab = terminalTabs.find((t) => t.id === activeTabId);
+ const activeIsTerminal = !!activeTab;
+ const hostId = activeTab?.host?.id ? parseInt(activeTab.host.id, 10) : null;
+
+ useEffect(() => {
+ if (!hostId) {
+ setCommands([]);
+ return;
+ }
+ getCommandHistory(hostId)
+ .then(setCommands)
+ .catch(() => setCommands([]));
+ }, [hostId]);
+
+ if (!activeIsTerminal) {
+ return (
+ <div className="flex flex-col items-center justify-center flex-1 gap-3 p-6 text-center">
+ <div className="size-10 rounded-full bg-muted/40 flex items-center justify-center">
+ <Terminal className="size-5 text-muted-foreground/30" />
+ </div>
+ <div className="flex flex-col gap-1">
+ <span className="text-sm font-semibold text-muted-foreground/60">
+ {t("newUi.sidebar.history.noTerminalSelected")}
+ </span>
+ <span className="text-xs text-muted-foreground/40">
+ {t("newUi.sidebar.history.noTerminalSelectedHint")}
+ </span>
+ </div>
+ </div>
+ );
+ }
+
+ const filtered = search
+ ? commands.filter((c) => c.toLowerCase().includes(search.toLowerCase()))
+ : commands;
+
+ async function handleDelete(cmd: string) {
+ if (!hostId) return;
+ try {
+ await deleteCommandFromHistory(hostId, cmd);
+ setCommands((prev) => prev.filter((c) => c !== cmd));
+ } catch {
+ /* ignore */
+ }
+ }
+
+ return (
+ <div className="flex flex-col gap-3 p-3">
+ <div className="flex items-center gap-1.5 px-2.5 py-1.5 bg-muted/30 border border-border/60">
+ <Terminal className="size-3 shrink-0 text-accent-brand" />
+ <span className="text-xs font-medium truncate text-foreground">
+ {activeTab.label}
+ </span>
+ </div>
+ <div className="relative">
+ <Search className="absolute left-2.5 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground" />
+ <Input
+ placeholder={t("newUi.sidebar.history.searchPlaceholder")}
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ className="pl-8"
+ />
+ </div>
+ <div className="flex items-center justify-between">
+ <span className="text-xs text-muted-foreground">
+ {filtered.length} command{filtered.length !== 1 ? "s" : ""}
+ </span>
+ <button
+ onClick={() => setCommands([])}
+ className="text-xs text-accent-brand hover:text-accent-brand/70"
+ >
+ {t("newUi.sidebar.history.clearAll")}
+ </button>
+ </div>
+ <div className="flex flex-col gap-1">
+ {filtered.length === 0 && (
+ <span className="text-xs text-muted-foreground/60 text-center py-8">
+ {t("newUi.sidebar.history.noHistoryEntries")}
+ </span>
+ )}
+ {filtered.map((cmd, i) => (
+ <div
+ key={i}
+ className="group flex flex-col gap-1 px-2.5 py-2 border border-border bg-background hover:border-muted-foreground/30 transition-colors"
+ >
+ <div className="flex items-start justify-between gap-2">
+ <span className="text-xs font-mono text-foreground break-all leading-relaxed">
+ {cmd}
+ </span>
+ <div className="flex items-center gap-0.5 shrink-0 md:opacity-0 group-hover:opacity-100 transition-opacity">
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-foreground"
+ onClick={() => navigator.clipboard.writeText(cmd)}
+ >
+ <Copy className="size-3" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-destructive"
+ onClick={() => handleDelete(cmd)}
+ >
+ <Trash2 className="size-3" />
+ </Button>
+ </div>
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+ );
+}
diff --git a/src/ui/desktop/navigation/hosts/Host.tsx b/src/ui/sidebar/Host.tsx
similarity index 96%
rename from src/ui/desktop/navigation/hosts/Host.tsx
rename to src/ui/sidebar/Host.tsx
index 837313bc6..318ba815f 100644
--- a/src/ui/desktop/navigation/hosts/Host.tsx
+++ b/src/ui/sidebar/Host.tsx
@@ -1,7 +1,7 @@
import React, { useEffect, useState, useMemo } from "react";
-import { Status, StatusIndicator } from "@/components/ui/shadcn-io/status";
-import { Button } from "@/components/ui/button";
-import { ButtonGroup } from "@/components/ui/button-group";
+import { Status, StatusIndicator } from "@/components/shadcn-io/status";
+import { Button } from "@/components/button";
+import { ButtonGroup } from "@/components/button-group";
import {
EllipsisVertical,
Terminal,
@@ -20,19 +20,19 @@ import {
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
-} from "@/components/ui/dropdown-menu";
-import { useTabs } from "@/ui/desktop/navigation/tabs/TabContext";
+} from "@/components/dropdown-menu";
+import { useTabs } from "@/shell/TabContext";
import {
getSSHHosts,
getGuacamoleDpi,
getGuacamoleTokenFromHost,
logActivity,
wakeOnLan,
-} from "@/ui/main-axios";
-import type { HostProps } from "../../../../types";
+} from "@/main-axios";
+import type { HostProps } from "@/types";
import { DEFAULT_STATS_CONFIG } from "@/types/stats-widgets";
import { useTranslation } from "react-i18next";
-import { useHostStatus } from "@/ui/contexts/ServerStatusContext";
+import { useHostStatus } from "@/lib/ServerStatusContext";
import { cn } from "@/lib/utils.ts";
import { toast } from "sonner";
diff --git a/src/ui/sidebar/HostManager.tsx b/src/ui/sidebar/HostManager.tsx
new file mode 100644
index 000000000..422b392f8
--- /dev/null
+++ b/src/ui/sidebar/HostManager.tsx
@@ -0,0 +1,3881 @@
+import React, {
+ useState,
+ useEffect,
+ useRef,
+ type MutableRefObject,
+} from "react";
+import { Button } from "@/components/button";
+import { Card } from "@/components/card";
+import { Separator } from "@/components/separator";
+import { Input } from "@/components/input";
+import {
+ Activity,
+ ArrowLeft,
+ Box,
+ Check,
+ ChevronDown,
+ ChevronLeft,
+ ChevronRight,
+ ChevronUp,
+ Copy,
+ Download,
+ Filter,
+ Folder,
+ FolderOpen,
+ FolderSearch,
+ Globe,
+ Info,
+ KeyRound,
+ LayoutDashboard,
+ ListChecks,
+ Lock,
+ MoreHorizontal,
+ Monitor,
+ Network,
+ Palette,
+ Pencil,
+ Pin,
+ Plus,
+ RefreshCw,
+ Search,
+ Server,
+ Settings,
+ Share2,
+ Shield,
+ Tag,
+ Terminal,
+ Trash2,
+ Upload,
+ User,
+ Users,
+ X,
+ Zap,
+} from "lucide-react";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@/components/dropdown-menu";
+import { toast } from "sonner";
+import { SectionCard, SettingRow, FakeSwitch } from "@/components/section-card";
+import { getSSHHosts, getCredentials } from "@/main-axios";
+import type { SSHHostWithStatus } from "@/main-axios";
+
+function sshHostToHost(h: SSHHostWithStatus): Host {
+ return {
+ id: String(h.id),
+ name: h.name,
+ user: h.username,
+ address: h.ip,
+ port: h.port,
+ folder: h.folder ?? "",
+ online: h.status === "online",
+ cpu: 0,
+ ram: 0,
+ lastAccess: "",
+ tags: h.tags ?? [],
+ authType: h.authType,
+ password: h.password,
+ key: typeof h.key === "string" ? h.key : undefined,
+ keyPassword: h.keyPassword,
+ keyType: h.keyType,
+ credentialId: h.credentialId != null ? String(h.credentialId) : undefined,
+ notes: h.notes,
+ pin: h.pin ?? false,
+ macAddress: h.macAddress,
+ enableTerminal: h.enableTerminal ?? true,
+ enableTunnel: h.enableTunnel ?? false,
+ enableFileManager: h.enableFileManager ?? false,
+ enableDocker: h.enableDocker ?? false,
+ enableSsh: h.connectionType === "ssh" || !h.connectionType,
+ enableRdp: h.connectionType === "rdp",
+ enableVnc: h.connectionType === "vnc",
+ enableTelnet: h.connectionType === "telnet",
+ sshPort: h.port,
+ rdpPort: 3389,
+ vncPort: 5900,
+ telnetPort: 23,
+ quickActions: (h.quickActions ?? []).map((a) => ({
+ name: a.name,
+ snippetId: String(a.snippetId),
+ })),
+ serverTunnels: [],
+ defaultPath: h.defaultPath,
+ terminalConfig: h.terminalConfig as Host["terminalConfig"],
+ useSocks5: h.useSocks5,
+ socks5Host: h.socks5Host,
+ socks5Port: h.socks5Port,
+ socks5Username: h.socks5Username,
+ socks5Password: h.socks5Password,
+ };
+}
+import type { Host, Credential } from "@/types/ui-types";
+
+const HOST_TABS = [
+ { id: "general", label: "General", icon: <Settings className="size-3.5" /> },
+ { id: "ssh", label: "SSH", icon: <Terminal className="size-3.5" /> },
+ { id: "tunnels", label: "Tunnels", icon: <Network className="size-3.5" /> },
+ { id: "docker", label: "Docker", icon: <Box className="size-3.5" /> },
+ { id: "files", label: "Files", icon: <FolderSearch className="size-3.5" /> },
+ {
+ id: "stats",
+ label: "Stats & Actions",
+ icon: <Activity className="size-3.5" />,
+ },
+ { id: "rdp", label: "RDP", icon: <Monitor className="size-3.5" /> },
+ { id: "vnc", label: "VNC", icon: <Monitor className="size-3.5" /> },
+ { id: "telnet", label: "Telnet", icon: <Terminal className="size-3.5" /> },
+ { id: "sharing", label: "Sharing", icon: <Share2 className="size-3.5" /> },
+];
+
+const CREDENTIAL_TABS = [
+ { id: "general", label: "General", icon: <Info className="size-3.5" /> },
+ { id: "auth", label: "Authentication", icon: <Lock className="size-3.5" /> },
+];
+
+const SSH_DEP_TABS = new Set(["tunnels", "docker", "files", "stats"]);
+
+function TabStrip({
+ tabs,
+ activeTab,
+ onTabChange,
+}: {
+ tabs: { id: string; label: string; icon: React.ReactNode }[];
+ activeTab: string;
+ onTabChange: (id: string) => void;
+}) {
+ const hasSshGroup = tabs.some((t) => SSH_DEP_TABS.has(t.id));
+
+ const ref = useRef<HTMLDivElement>(null);
+ useEffect(() => {
+ const el = ref.current;
+ if (!el) return;
+ const onWheel = (e: WheelEvent) => {
+ if (e.deltaY === 0) return;
+ e.preventDefault();
+ el.scrollLeft += e.deltaY;
+ };
+ el.addEventListener("wheel", onWheel, { passive: false });
+ return () => el.removeEventListener("wheel", onWheel);
+ }, []);
+
+ // Split tabs into groups for rendering a labeled SSH section
+ const nonSshTabs = tabs.filter((t) => !SSH_DEP_TABS.has(t.id));
+ const sshDepTabs = tabs.filter((t) => SSH_DEP_TABS.has(t.id));
+
+ const renderTab = (tab: (typeof tabs)[0]) => (
+ <button
+ key={tab.id}
+ onClick={() => onTabChange(tab.id)}
+ className={`flex items-center gap-1.5 px-3 py-2 text-xs font-medium whitespace-nowrap border-b-2 transition-colors shrink-0 ${
+ activeTab === tab.id
+ ? "border-accent-brand text-accent-brand"
+ : "border-transparent text-muted-foreground hover:text-foreground"
+ }`}
+ >
+ {tab.icon}
+ {tab.label}
+ </button>
+ );
+
+ return (
+ <div ref={ref} className="overflow-x-auto">
+ <div className="flex min-w-max">
+ {nonSshTabs.map(renderTab)}
+ {hasSshGroup && sshDepTabs.length > 0 && (
+ <div className="flex flex-col border-l border-border/40 ml-0.5">
+ <div className="flex items-center gap-1 px-2 pt-0.5">
+ <Terminal className="size-2.5 text-muted-foreground/30" />
+ <span className="text-[9px] font-bold uppercase tracking-widest text-muted-foreground/30">
+ SSH
+ </span>
+ </div>
+ <div className="flex">{sshDepTabs.map(renderTab)}</div>
+ </div>
+ )}
+ </div>
+ </div>
+ );
+}
+
+function HostRow({
+ host,
+ selectionMode,
+ selected,
+ onToggleSelect,
+ onEdit,
+ onDelete,
+ onDragStart,
+ onDragEnd,
+ depth = 0,
+ stripeIndex = 0,
+}: {
+ host: Host;
+ selectionMode: boolean;
+ selected: boolean;
+ onToggleSelect: () => void;
+ onEdit: () => void;
+ onDelete: () => void;
+ onDragStart?: () => void;
+ onDragEnd?: () => void;
+ depth?: number;
+ stripeIndex?: number;
+}) {
+ const [hovered, setHovered] = useState(false);
+
+ const connTypeColor = "border-border/60 text-muted-foreground/60";
+
+ const hasSsh = host.enableSsh;
+
+ const sshActions: { type: string; icon: typeof Terminal; label: string }[] = [
+ { type: "terminal", icon: Terminal, label: "Terminal" },
+ { type: "files", icon: FolderSearch, label: "Files" },
+ { type: "docker", icon: Box, label: "Docker" },
+ { type: "tunnel", icon: Network, label: "Tunnels" },
+ { type: "stats", icon: Server, label: "Stats" },
+ ];
+
+ const fireOpen = (type: string) => {
+ window.dispatchEvent(
+ new CustomEvent("termix:open-tab", { detail: { hostId: host.id, type } }),
+ );
+ };
+
+ return (
+ <div
+ draggable={!!onDragStart && !selectionMode}
+ onDragStart={onDragStart}
+ onDragEnd={onDragEnd}
+ onMouseEnter={() => setHovered(true)}
+ onMouseLeave={() => setHovered(false)}
+ onClick={selectionMode ? onToggleSelect : undefined}
+ style={{ paddingLeft: depth > 0 ? `${depth * 12 + 8}px` : undefined }}
+ className={`relative flex flex-col border-b border-border/50 last:border-0 transition-colors select-none
+ ${selectionMode ? "cursor-pointer" : ""}
+ ${selected ? "bg-accent-brand/5" : hovered ? "bg-muted/40" : stripeIndex % 2 === 1 ? "bg-muted/20" : ""}
+ ${onDragStart && !selectionMode ? "cursor-grab active:cursor-grabbing" : ""}`}
+ >
+ {/* Main row */}
+ <div className="flex items-center gap-2 px-3 py-2">
+ {selectionMode && (
+ <div
+ className={`size-3.5 border-2 flex items-center justify-center shrink-0 transition-colors ${selected ? "border-accent-brand bg-accent-brand" : "border-border bg-background"}`}
+ >
+ {selected && <Check className="size-2 text-background" />}
+ </div>
+ )}
+
+ {/* Status dot */}
+ <div
+ className={`size-1.5 rounded-full shrink-0 ${host.online ? "bg-accent-brand shadow-[0_0_4px_rgba(251,146,60,0.5)]" : "bg-muted-foreground/25"}`}
+ />
+
+ {/* Name + badges */}
+ <div className="flex items-center gap-1.5 min-w-0 flex-1">
+ <span className="text-[13px] font-semibold truncate leading-none">
+ {host.name}
+ </span>
+ {host.pin && (
+ <Pin className="size-2.5 text-accent-brand/50 shrink-0" />
+ )}
+ <div className="flex items-center gap-0.5 shrink-0">
+ {host.enableSsh && (
+ <span
+ className={`text-[9px] px-1 py-0.5 font-bold border leading-none ${connTypeColor}`}
+ >
+ SSH
+ </span>
+ )}
+ {host.enableRdp && (
+ <span
+ className={`text-[9px] px-1 py-0.5 font-bold border leading-none ${connTypeColor}`}
+ >
+ RDP
+ </span>
+ )}
+ {host.enableVnc && (
+ <span
+ className={`text-[9px] px-1 py-0.5 font-bold border leading-none ${connTypeColor}`}
+ >
+ VNC
+ </span>
+ )}
+ {host.enableTelnet && (
+ <span
+ className={`text-[9px] px-1 py-0.5 font-bold border leading-none ${connTypeColor}`}
+ >
+ TELNET
+ </span>
+ )}
+ </div>
+ </div>
+
+ {/* Right: last access always visible, CPU/RAM on hover */}
+ <div className="flex items-center gap-2 shrink-0">
+ {host.online && hovered && (
+ <div className="flex items-center gap-2">
+ <div className="flex items-center gap-1">
+ <span className="text-[9px] text-muted-foreground/50">CPU</span>
+ <div className="w-10 h-[3px] bg-muted-foreground/15 rounded-full overflow-hidden">
+ <div
+ className={`h-full rounded-full ${host.cpu! > 80 ? "bg-red-400" : host.cpu! > 50 ? "bg-yellow-400" : "bg-accent-brand"}`}
+ style={{ width: `${host.cpu}%` }}
+ />
+ </div>
+ <span className="text-[9px] tabular-nums text-accent-brand font-bold">
+ {host.cpu}%
+ </span>
+ </div>
+ <div className="flex items-center gap-1">
+ <span className="text-[9px] text-muted-foreground/50">RAM</span>
+ <div className="w-10 h-[3px] bg-muted-foreground/15 rounded-full overflow-hidden">
+ <div
+ className={`h-full rounded-full ${host.ram! > 80 ? "bg-red-400" : host.ram! > 60 ? "bg-yellow-400" : "bg-accent-brand/60"}`}
+ style={{ width: `${host.ram}%` }}
+ />
+ </div>
+ <span className="text-[9px] tabular-nums text-accent-brand font-bold">
+ {host.ram}%
+ </span>
+ </div>
+ </div>
+ )}
+ <span className="text-[10px] text-muted-foreground/40 tabular-nums shrink-0">
+ {host.lastAccess}
+ </span>
+ </div>
+ </div>
+
+ {/* Sub-row: address + tags */}
+ <div
+ className="flex items-center gap-2 px-3 pb-1.5 -mt-0.5"
+ style={{
+ paddingLeft:
+ depth > 0 ? `${depth * 12 + 8 + 12 + 8 + 6}px` : undefined,
+ }}
+ >
+ <span className="text-[11px] text-muted-foreground/50 font-mono truncate shrink-0 max-w-[160px]">
+ {host.username}@{host.ip}
+ </span>
+ {host.tags && host.tags.length > 0 && (
+ <div className="flex items-center gap-1 min-w-0 overflow-hidden">
+ {host.tags.slice(0, 4).map((tag) => (
+ <span
+ key={tag}
+ className="text-[9px] px-1 py-px border border-border/50 bg-muted/30 text-muted-foreground/60 lowercase shrink-0 leading-none"
+ >
+ {tag}
+ </span>
+ ))}
+ {host.tags.length > 4 && (
+ <span className="text-[9px] text-muted-foreground/40 shrink-0">
+ +{host.tags.length - 4}
+ </span>
+ )}
+ </div>
+ )}
+ </div>
+
+ {/* Hover action tray */}
+ {hovered && !selectionMode && (
+ <div
+ className="border-t border-border/40"
+ style={{ marginLeft: depth > 0 ? `-${depth * 12 + 8}px` : undefined }}
+ >
+ <div
+ className="flex items-center pt-0.5 pb-1"
+ style={{
+ paddingLeft: depth > 0 ? `${depth * 12 + 8}px` : "8px",
+ paddingRight: "8px",
+ }}
+ >
+ {hasSsh &&
+ sshActions.map(({ type, icon: Icon, label }) => (
+ <button
+ key={type}
+ title={label}
+ onClick={(e) => {
+ e.stopPropagation();
+ fireOpen(type);
+ }}
+ className="flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-muted-foreground/60 hover:text-foreground hover:bg-muted rounded transition-colors"
+ >
+ <Icon className="size-3 shrink-0" />
+ <span>{label}</span>
+ </button>
+ ))}
+ {hasSsh &&
+ (host.enableRdp || host.enableVnc || host.enableTelnet) && (
+ <div className="w-px h-3.5 bg-border/60 mx-0.5 shrink-0" />
+ )}
+ {host.enableRdp && (
+ <button
+ onClick={(e) => {
+ e.stopPropagation();
+ fireOpen("rdp");
+ }}
+ className="flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-muted-foreground/60 hover:text-foreground hover:bg-muted rounded transition-colors"
+ >
+ <Monitor className="size-3 shrink-0" />
+ <span>RDP</span>
+ </button>
+ )}
+ {host.enableVnc && (
+ <button
+ onClick={(e) => {
+ e.stopPropagation();
+ fireOpen("vnc");
+ }}
+ className="flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-muted-foreground/60 hover:text-foreground hover:bg-muted rounded transition-colors"
+ >
+ <Monitor className="size-3 shrink-0" />
+ <span>VNC</span>
+ </button>
+ )}
+ {host.enableTelnet && (
+ <button
+ onClick={(e) => {
+ e.stopPropagation();
+ fireOpen("telnet");
+ }}
+ className="flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-muted-foreground/60 hover:text-foreground hover:bg-muted rounded transition-colors"
+ >
+ <Terminal className="size-3 shrink-0" />
+ <span>Telnet</span>
+ </button>
+ )}
+ <div className="flex-1" />
+ <button
+ title="Edit Host"
+ onClick={(e) => {
+ e.stopPropagation();
+ onEdit();
+ }}
+ className="flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-muted-foreground/60 hover:text-foreground hover:bg-muted rounded transition-colors"
+ >
+ <Pencil className="size-3 shrink-0" />
+ <span>Edit</span>
+ </button>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <button
+ onClick={(e) => e.stopPropagation()}
+ className="flex items-center justify-center size-6 text-muted-foreground/50 hover:text-foreground hover:bg-muted rounded transition-colors"
+ >
+ <MoreHorizontal className="size-3" />
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="text-xs">
+ <DropdownMenuItem onClick={() => toast.success("Host cloned")}>
+ <Copy className="size-3.5 mr-2" />
+ Clone Host
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => {
+ navigator.clipboard.writeText(
+ `${host.username}@${host.ip}`,
+ );
+ toast.success("Copied to clipboard");
+ }}
+ >
+ <Copy className="size-3.5 mr-2" />
+ Copy Address
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ className="text-destructive focus:text-destructive"
+ onClick={onDelete}
+ >
+ <Trash2 className="size-3.5 mr-2" />
+ Delete
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
+
+function HostEditor({
+ host,
+ activeTab,
+ onBack,
+ protocols,
+ onProtocolChange,
+ onTabChange,
+}: {
+ host: Host | null;
+ activeTab: string;
+ onBack: () => void;
+ protocols: {
+ enableSsh: boolean;
+ enableRdp: boolean;
+ enableVnc: boolean;
+ enableTelnet: boolean;
+ };
+ onProtocolChange: (p: Partial<typeof protocols>) => void;
+ onTabChange: (tab: string) => void;
+}) {
+ const [authMethod, setAuthMethod] = useState(host?.authType || "password");
+
+ const handleProtocolToggle = (
+ proto: keyof typeof protocols,
+ value: boolean,
+ ) => {
+ onProtocolChange({ [proto]: value });
+ const tabForProto: Record<string, string> = {
+ enableSsh: "ssh",
+ enableRdp: "rdp",
+ enableVnc: "vnc",
+ enableTelnet: "telnet",
+ };
+ if (!value && activeTab === tabForProto[proto]) onTabChange("general");
+ if (value && tabForProto[proto]) onTabChange(tabForProto[proto]);
+ };
+
+ return (
+ <div className="flex flex-col gap-3">
+ <div className="flex flex-col gap-3">
+ {activeTab === "general" && (
+ <>
+ {/* Protocols — enable/disable each connection type */}
+ <SectionCard
+ title="Protocols"
+ icon={<Globe className="size-3.5" />}
+ >
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-2 py-3">
+ {[
+ {
+ proto: "enableSsh" as const,
+ label: "SSH",
+ desc: "Secure Shell",
+ icon: <Terminal className="size-4" />,
+ port: protocols.enableSsh ? (host?.sshPort ?? 22) : 22,
+ defaultPort: 22,
+ },
+ {
+ proto: "enableRdp" as const,
+ label: "RDP",
+ desc: "Remote Desktop",
+ icon: <Monitor className="size-4" />,
+ port: protocols.enableRdp ? (host?.rdpPort ?? 3389) : 3389,
+ defaultPort: 3389,
+ },
+ {
+ proto: "enableVnc" as const,
+ label: "VNC",
+ desc: "Virtual Network",
+ icon: <Monitor className="size-4" />,
+ port: protocols.enableVnc ? (host?.vncPort ?? 5900) : 5900,
+ defaultPort: 5900,
+ },
+ {
+ proto: "enableTelnet" as const,
+ label: "Telnet",
+ desc: "Unencrypted shell",
+ icon: <Terminal className="size-4" />,
+ port: protocols.enableTelnet
+ ? (host?.telnetPort ?? 23)
+ : 23,
+ defaultPort: 23,
+ },
+ ].map(({ proto, label, desc, icon, port, defaultPort }) => {
+ const enabled = protocols[proto];
+ return (
+ <div
+ key={proto}
+ className={`flex items-center gap-3 p-3 border transition-colors ${enabled ? "border-accent-brand/20 bg-accent-brand/5" : "border-border bg-muted/10"}`}
+ >
+ <div
+ className={`size-8 flex items-center justify-center shrink-0 ${enabled ? "text-accent-brand" : "text-muted-foreground/30"}`}
+ >
+ {icon}
+ </div>
+ <div className="flex flex-col gap-1 flex-1 min-w-0">
+ <span
+ className={`text-xs font-bold ${enabled ? "text-foreground" : "text-muted-foreground/50"}`}
+ >
+ {label}
+ </span>
+ <span className="text-[10px] text-muted-foreground/50">
+ {desc}
+ </span>
+ {enabled && (
+ <div className="flex items-center gap-1.5 mt-0.5">
+ <span className="text-[10px] text-muted-foreground/60">
+ Port
+ </span>
+ <Input
+ type="number"
+ defaultValue={port}
+ className="h-6 w-16 text-[10px] px-2"
+ />
+ </div>
+ )}
+ </div>
+ <FakeSwitch
+ defaultChecked={enabled}
+ onChange={(v: boolean) =>
+ handleProtocolToggle(proto, v)
+ }
+ />
+ </div>
+ );
+ })}
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Connection Details"
+ icon={<Globe className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Address / IP
+ </label>
+ <Input
+ placeholder="10.0.0.1 or example.com"
+ defaultValue={host?.address || ""}
+ />
+ </div>
+
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Friendly Name
+ </label>
+ <Input
+ placeholder="e.g. Web Server Production"
+ defaultValue={host?.name || ""}
+ />
+ </div>
+ {protocols.enableSsh && (
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ MAC Address
+ </label>
+ <Input
+ placeholder="AA:BB:CC:DD:EE:FF"
+ defaultValue={host?.macAddress || ""}
+ />
+ </div>
+ )}
+ </div>
+ </div>
+ </SectionCard>
+
+ {!protocols.enableSsh &&
+ !protocols.enableRdp &&
+ !protocols.enableVnc &&
+ !protocols.enableTelnet && (
+ <div className="flex items-center gap-3 p-3 border border-border bg-muted/20 text-xs text-muted-foreground">
+ <Globe className="size-4 shrink-0 text-muted-foreground/40" />
+ <span>
+ Enable at least one protocol above to configure
+ authentication and connection settings.
+ </span>
+ </div>
+ )}
+
+ <SectionCard
+ title="Proxy & Bastion"
+ icon={<Network className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <SettingRow
+ label="Use SOCKS5 Proxy"
+ description="Route connection through a proxy server"
+ >
+ <FakeSwitch defaultChecked={host?.useSocks5} />
+ </SettingRow>
+ <div className="flex flex-col gap-3 p-3 bg-muted/20 border border-border">
+ <div className="flex items-center justify-between">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Proxy Chain
+ </span>
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-6 text-[10px] px-2 border-accent-brand/40 text-accent-brand"
+ >
+ <Plus className="size-3 mr-1" /> Add Node
+ </Button>
+ </div>
+ <div className="flex flex-col gap-2">
+ <div className="flex items-center gap-2 p-2 bg-background border border-border">
+ <span className="text-[10px] font-bold text-muted-foreground">
+ 1.
+ </span>
+ <Input
+ className="h-7 text-xs flex-1"
+ placeholder="Host"
+ defaultValue="proxy.internal"
+ />
+ <Input
+ className="h-7 text-xs w-20"
+ placeholder="Port"
+ defaultValue="1080"
+ />
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-7 text-destructive"
+ >
+ <Trash2 className="size-3.5" />
+ </Button>
+ </div>
+ </div>
+ </div>
+ <div className="flex flex-col gap-3">
+ <div className="flex items-center justify-between">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Jump Host Chain
+ </span>
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-6 text-[10px] px-2 border-accent-brand/40 text-accent-brand"
+ >
+ <Plus className="size-3 mr-1" /> Add Jump
+ </Button>
+ </div>
+ <div className="flex flex-col gap-2">
+ <div className="flex items-center gap-2 p-2 bg-background border border-border">
+ <span className="text-[10px] font-bold text-muted-foreground">
+ 1.
+ </span>
+ <select className="flex h-7 flex-1 border border-border bg-background px-2 py-0 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option>Select a server...</option>
+ {hosts.map((h) => (
+ <option key={h.id}>{h.name}</option>
+ ))}
+ </select>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-7 text-destructive"
+ >
+ <Trash2 className="size-3.5" />
+ </Button>
+ </div>
+ </div>
+ </div>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Folder & Advanced"
+ icon={<Tag className="size-3.5" />}
+ >
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Folder
+ </label>
+ <Input
+ placeholder="e.g. Production"
+ defaultValue={host?.folder || ""}
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Tags
+ </label>
+ <Input
+ placeholder="space separated"
+ defaultValue={host?.tags?.join(" ") || ""}
+ />
+ </div>
+ <div className="flex flex-col gap-1.5 col-span-2">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Private Notes
+ </label>
+ <textarea
+ rows={3}
+ placeholder="Details about this server..."
+ className="w-full px-3 py-2 text-xs bg-background border border-border text-foreground placeholder:text-muted-foreground resize-none outline-none focus:ring-1 focus:ring-ring"
+ defaultValue={host?.notes || ""}
+ />
+ </div>
+ <SettingRow
+ label="Pin to Top"
+ description="Always show this host at the top of the list"
+ >
+ <FakeSwitch defaultChecked={host?.pin} />
+ </SettingRow>
+ </div>
+ <div className="flex flex-col gap-3 border-t border-border pt-4 pb-2">
+ <div className="flex items-center justify-between">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Port Knocking Sequence
+ </span>
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-6 text-[10px] px-2 border-accent-brand/40 text-accent-brand"
+ >
+ <Plus className="size-3 mr-1" /> Add Knock
+ </Button>
+ </div>
+ <div className="grid grid-cols-3 gap-2">
+ <div className="flex items-center gap-1.5 p-1.5 bg-muted/30 border border-border">
+ <Input className="h-7 text-xs w-16" placeholder="Port" />
+ <select className="h-7 text-[10px] bg-background border border-border">
+ <option>TCP</option>
+ <option>UDP</option>
+ </select>
+ <Input className="h-7 text-xs w-14" placeholder="Delay" />
+ <button className="text-destructive p-1">
+ <X className="size-3" />
+ </button>
+ </div>
+ </div>
+ </div>
+ </SectionCard>
+ </>
+ )}
+
+ {activeTab === "ssh" && (
+ <>
+ <SectionCard
+ title="Authentication"
+ icon={<Shield className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Auth Method
+ </label>
+ <div className="flex flex-wrap gap-2">
+ {["password", "key", "credential", "none", "opkssh"].map(
+ (m) => (
+ <button
+ key={m}
+ onClick={() => setAuthMethod(m as any)}
+ className={`px-3 py-1.5 text-[10px] font-bold uppercase tracking-widest border transition-colors ${authMethod === m ? "border-accent-brand/40 bg-accent-brand/10 text-accent-brand" : "border-border text-muted-foreground hover:text-foreground"}`}
+ >
+ {m}
+ </button>
+ ),
+ )}
+ </div>
+ </div>
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4 border-t border-border pt-4 mt-1">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Username
+ </label>
+ <Input placeholder="root" defaultValue={host?.user || ""} />
+ </div>
+ {authMethod === "password" && (
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Password
+ </label>
+ <Input
+ type="password"
+ placeholder="••••••••"
+ defaultValue={host?.password || ""}
+ />
+ </div>
+ )}
+ {authMethod === "key" && (
+ <>
+ <div className="flex flex-col gap-1.5 col-span-2">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ SSH Private Key
+ </label>
+ <textarea
+ placeholder="-----BEGIN OPENSSH PRIVATE KEY-----"
+ rows={5}
+ defaultValue={host?.key || ""}
+ className="w-full px-3 py-2 text-[10px] bg-background border border-border text-foreground placeholder:text-muted-foreground resize-none outline-none focus:ring-1 focus:ring-ring font-mono"
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Key Passphrase
+ </label>
+ <Input
+ type="password"
+ placeholder="Optional"
+ defaultValue={host?.keyPassword || ""}
+ />
+ </div>
+ </>
+ )}
+ {authMethod === "credential" && (
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Stored Credential
+ </label>
+ <select
+ defaultValue={host?.credentialId || ""}
+ className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring"
+ >
+ <option value="">Select a credential...</option>
+ {credentials.map((c) => (
+ <option key={c.id} value={c.id}>
+ {c.name} ({c.username})
+ </option>
+ ))}
+ </select>
+ </div>
+ )}
+ </div>
+ <SettingRow
+ label="Force Keyboard Interactive"
+ description="Force manual password entry even if keys are present"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Terminal Appearance"
+ icon={<Palette className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="space-y-2">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Theme Preview
+ </label>
+ <div className="w-full bg-[#111210] border border-border font-mono text-xs leading-relaxed overflow-hidden">
+ <div className="px-3 py-2.5 flex flex-col gap-0.5">
+ <div>
+ <span className="text-[#5af78e]">deploy@web-01</span>
+ <span className="text-[#555]">:</span>
+ <span className="text-[#57c7ff]">~</span>
+ <span className="text-[#555]">$</span>
+ <span className="text-[#f1f1f0]"> ls -la</span>
+ </div>
+ <div className="text-[#555]">total 48</div>
+ <div>
+ <span className="text-[#9aedfe]">drwxr-xr-x</span>
+ <span className="text-[#555]">
+ {" "}
+ 5 deploy deploy 4096 May 1 09:12{" "}
+ </span>
+ <span className="text-[#57c7ff]">.</span>
+ </div>
+ <div>
+ <span className="text-[#9aedfe]">drwxr-xr-x</span>
+ <span className="text-[#555]">
+ {" "}
+ 3 root root 4096 Apr 15 18:44{" "}
+ </span>
+ <span className="text-[#57c7ff]">..</span>
+ </div>
+ <div>
+ <span className="text-[#9aedfe]">-rw-r--r--</span>
+ <span className="text-[#555]">
+ {" "}
+ 1 deploy deploy 220 Apr 15 18:44{" "}
+ </span>
+ <span className="text-[#f1f1f0]">.bash_logout</span>
+ </div>
+ <div>
+ <span className="text-[#9aedfe]">-rwxr-xr-x</span>
+ <span className="text-[#555]">
+ {" "}
+ 1 deploy deploy 8192 May 1 08:55{" "}
+ </span>
+ <span className="text-[#5af78e]">deploy.sh</span>
+ </div>
+ <div className="flex items-center gap-0.5 mt-0.5">
+ <span className="text-[#5af78e]">deploy@web-01</span>
+ <span className="text-[#555]">:</span>
+ <span className="text-[#57c7ff]">~</span>
+ <span className="text-[#555]">$</span>
+ <span className="text-[#f1f1f0]"> </span>
+ <span className="inline-block w-1.5 h-3.5 bg-[#f1f1f0] animate-pulse" />
+ </div>
+ </div>
+ </div>
+ </div>
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Color Theme
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option>Termix Dark</option>
+ <option>One Dark</option>
+ <option>Monokai</option>
+ <option>Dracula</option>
+ </select>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Font Family
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring font-mono">
+ <option>JetBrains Mono</option>
+ <option>Fira Code</option>
+ <option>Source Code Pro</option>
+ </select>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Font Size
+ </label>
+ <Input type="number" defaultValue={14} />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Cursor Style
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option>Block</option>
+ <option>Underline</option>
+ <option>Bar</option>
+ </select>
+ </div>
+ </div>
+ <SettingRow
+ label="Cursor Blinking"
+ description="Enable blinking animation for the terminal cursor"
+ >
+ <FakeSwitch defaultChecked={true} />
+ </SettingRow>
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Letter Spacing
+ </label>
+ <Input type="number" step="0.1" defaultValue={0} />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Line Height
+ </label>
+ <Input type="number" step="0.1" defaultValue={1.2} />
+ </div>
+ </div>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Behavior & Advanced"
+ icon={<Zap className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Scrollback Buffer
+ </label>
+ <Input type="number" defaultValue={10000} />
+ <span className="text-[10px] text-muted-foreground">
+ Maximum number of lines kept in history
+ </span>
+ </div>
+ <SettingRow
+ label="SSH Agent Forwarding"
+ description="Pass your local SSH keys to this host"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Enable Auto-Mosh"
+ description="Prefer Mosh over SSH if available"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Enable Auto-Tmux"
+ description="Automatically launch or attach to tmux session"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Sudo Password Auto-fill"
+ description="Automatically provide sudo password when prompted"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <div className="flex flex-col gap-3">
+ <div className="flex items-center justify-between">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Environment Variables
+ </span>
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-6 text-[10px] px-2 border-accent-brand/40 text-accent-brand"
+ >
+ <Plus className="size-3 mr-1" /> Add Variable
+ </Button>
+ </div>
+ <div className="flex flex-col gap-2">
+ <div className="flex items-center gap-2">
+ <Input
+ className="h-7 text-xs flex-1"
+ placeholder="KEY"
+ defaultValue="NODE_ENV"
+ />
+ <Input
+ className="h-7 text-xs flex-1"
+ placeholder="VALUE"
+ defaultValue="production"
+ />
+ <button className="text-destructive">
+ <X className="size-4" />
+ </button>
+ </div>
+ </div>
+ </div>
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4 border-t border-border pt-4">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Keepalive Interval
+ </label>
+ <Input type="number" defaultValue={30} />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Max Keepalive Misses
+ </label>
+ <Input type="number" defaultValue={3} />
+ </div>
+ </div>
+ </div>
+ </SectionCard>
+ </>
+ )}
+
+ {activeTab === "tunnels" && (
+ <>
+ <SectionCard
+ title="Tunnel Settings"
+ icon={<Network className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <SettingRow
+ label="Enable Tunneling"
+ description="Enable SSH tunnel functionality for this host"
+ >
+ <FakeSwitch defaultChecked={host?.enableTunnel ?? true} />
+ </SettingRow>
+ <div className="text-xs text-muted-foreground p-3 bg-muted/30 border border-border space-y-1">
+ <p>
+ <strong>Requirements:</strong> The SSH server must have{" "}
+ <code className="bg-muted px-1">GatewayPorts yes</code>,{" "}
+ <code className="bg-muted px-1">
+ AllowTcpForwarding yes
+ </code>
+ , and{" "}
+ <code className="bg-muted px-1">PermitRootLogin yes</code>{" "}
+ set in{" "}
+ <code className="bg-muted px-1">/etc/ssh/sshd_config</code>.
+ </p>
+ </div>
+ </div>
+ </SectionCard>
+ <SectionCard
+ title="Server Tunnels"
+ icon={<Network className="size-3.5" />}
+ action={
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-6 text-[10px] px-2 border-accent-brand/40 text-accent-brand"
+ >
+ <Plus className="size-3 mr-1" /> Add Tunnel
+ </Button>
+ }
+ >
+ <div className="flex flex-col gap-3 py-3">
+ {[
+ {
+ mode: "remote",
+ endpointHost: "prod-db",
+ endpointPort: 5432,
+ currentHostIp: "0.0.0.0",
+ src: 5432,
+ maxRetries: 3,
+ retryInterval: 10,
+ autoStart: true,
+ },
+ {
+ mode: "local",
+ endpointHost: "web-server",
+ endpointPort: 80,
+ currentHostIp: "127.0.0.1",
+ src: 8080,
+ maxRetries: 3,
+ retryInterval: 10,
+ autoStart: false,
+ },
+ {
+ mode: "dynamic",
+ endpointHost: "",
+ endpointPort: 0,
+ currentHostIp: "127.0.0.1",
+ src: 1080,
+ maxRetries: 3,
+ retryInterval: 10,
+ autoStart: true,
+ },
+ ].map((tun, i) => (
+ <div
+ key={i}
+ className="flex flex-col gap-3 p-3 border border-border bg-muted/20 relative group"
+ >
+ <div className="flex items-center justify-between mb-1">
+ <span className="text-xs font-bold text-muted-foreground">
+ Server Tunnel {i + 1}
+ </span>
+ <div className="flex items-center gap-2">
+ <div className="flex items-center gap-1">
+ <div
+ className={`size-1.5 rounded-full ${tun.autoStart ? "bg-accent-brand" : "bg-muted-foreground/40"}`}
+ />
+ <span
+ className={`text-[10px] font-bold uppercase tracking-widest ${tun.autoStart ? "text-accent-brand" : "text-muted-foreground"}`}
+ >
+ {tun.autoStart ? "Connected" : "Idle"}
+ </span>
+ </div>
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-6 text-[10px] px-2"
+ >
+ Connect
+ </Button>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-6 text-[10px] px-2 text-destructive"
+ onClick={() => toast.success("Tunnel removed")}
+ >
+ Delete
+ </Button>
+ </div>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold text-muted-foreground">
+ Tunnel Type
+ </label>
+ <div className="flex gap-2">
+ {["remote", "local", "dynamic"].map((m) => (
+ <button
+ key={m}
+ className={`px-3 py-1.5 text-[10px] font-bold uppercase tracking-widest border transition-colors ${tun.mode === m ? "border-accent-brand/40 bg-accent-brand/10 text-accent-brand" : "border-border text-muted-foreground hover:text-foreground"}`}
+ >
+ {m}
+ </button>
+ ))}
+ </div>
+ <p className="text-[10px] text-muted-foreground mt-1">
+ {tun.mode === "remote"
+ ? "Remote (R→L): Opens a port on the remote server and forwards traffic to a local service."
+ : tun.mode === "local"
+ ? "Local (L→R): Opens a port locally and forwards traffic through the SSH server to a remote service."
+ : "Dynamic (SOCKS): Creates a local SOCKS proxy that routes traffic through the SSH server."}
+ </p>
+ </div>
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
+ {tun.mode !== "dynamic" && (
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-bold text-muted-foreground">
+ Endpoint SSH Config
+ </label>
+ <select
+ defaultValue={tun.endpointHost || ""}
+ className="h-7 text-xs bg-background border border-border px-2 outline-none focus:ring-1 focus:ring-ring"
+ >
+ <option value="">Select a host...</option>
+ {hosts.map((h) => (
+ <option key={h.id} value={h.name}>
+ {h.name}
+ </option>
+ ))}
+ </select>
+ </div>
+ )}
+ {tun.mode !== "dynamic" && (
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-bold text-muted-foreground">
+ {tun.mode === "remote"
+ ? "Remote Port"
+ : "Endpoint Port"}
+ </label>
+ <Input
+ className="h-7 text-xs"
+ defaultValue={tun.endpointPort}
+ />
+ </div>
+ )}
+ {tun.mode !== "dynamic" && (
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-bold text-muted-foreground">
+ Current Host IP
+ </label>
+ <Input
+ className="h-7 text-xs"
+ placeholder="0.0.0.0 or 127.0.0.1"
+ defaultValue={tun.currentHostIp}
+ />
+ </div>
+ )}
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-bold text-muted-foreground">
+ {tun.mode === "remote" ? "Local Port" : "Source Port"}
+ </label>
+ <Input className="h-7 text-xs" defaultValue={tun.src} />
+ </div>
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-bold text-muted-foreground">
+ Max Retries
+ </label>
+ <Input
+ className="h-7 text-xs"
+ type="number"
+ defaultValue={tun.maxRetries}
+ />
+ </div>
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-bold text-muted-foreground">
+ Retry Interval (s)
+ </label>
+ <Input
+ className="h-7 text-xs"
+ type="number"
+ defaultValue={tun.retryInterval}
+ />
+ </div>
+ </div>
+ <SettingRow
+ label="Auto-start"
+ description="Automatically connect this tunnel when the host is loaded"
+ >
+ <FakeSwitch defaultChecked={tun.autoStart} />
+ </SettingRow>
+ </div>
+ ))}
+ </div>
+ </SectionCard>
+ </>
+ )}
+
+ {activeTab === "docker" && (
+ <SectionCard
+ title="Docker Integration"
+ icon={<Box className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <SettingRow
+ label="Enable Docker"
+ description="Monitor and manage containers on this host via Docker"
+ >
+ <FakeSwitch defaultChecked={host?.enableDocker} />
+ </SettingRow>
+ </div>
+ </SectionCard>
+ )}
+
+ {activeTab === "files" && (
+ <SectionCard
+ title="File Manager"
+ icon={<FolderSearch className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <SettingRow
+ label="Enable File Manager"
+ description="Browse and manage files on this host over SFTP"
+ >
+ <FakeSwitch defaultChecked={host?.enableFileManager ?? true} />
+ </SettingRow>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Default Path
+ </label>
+ <Input
+ placeholder="~"
+ defaultValue={host?.defaultPath || "~"}
+ />
+ <span className="text-[10px] text-muted-foreground">
+ The directory to open when the file manager launches for this
+ host.
+ </span>
+ </div>
+ </div>
+ </SectionCard>
+ )}
+
+ {activeTab === "stats" && (
+ <>
+ <SectionCard
+ title="Status Checks"
+ icon={<Activity className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-0 py-1">
+ <SettingRow
+ label="Enable Status Checks"
+ description="Periodically ping this host to verify availability"
+ >
+ <FakeSwitch
+ defaultChecked={
+ host?.statsConfig?.statusCheckEnabled ?? true
+ }
+ />
+ </SettingRow>
+ <SettingRow
+ label="Use Global Interval"
+ description="Override with the server-wide status check interval"
+ >
+ <FakeSwitch
+ defaultChecked={
+ host?.statsConfig?.useGlobalStatusInterval ?? true
+ }
+ />
+ </SettingRow>
+ <SettingRow
+ label="Check Interval (s)"
+ description="Seconds between each connectivity ping"
+ >
+ <Input
+ type="number"
+ defaultValue={host?.statsConfig?.statusCheckInterval ?? 60}
+ className="w-20 h-7 text-xs text-right"
+ />
+ </SettingRow>
+ </div>
+ </SectionCard>
+ <SectionCard
+ title="Metrics Collection"
+ icon={<Server className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-0 py-1">
+ <SettingRow
+ label="Enable Metrics"
+ description="Collect CPU, RAM, disk, and network usage from this host"
+ >
+ <FakeSwitch
+ defaultChecked={host?.statsConfig?.metricsEnabled ?? true}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Use Global Interval"
+ description="Override with the server-wide metrics interval"
+ >
+ <FakeSwitch
+ defaultChecked={
+ host?.statsConfig?.useGlobalMetricsInterval ?? true
+ }
+ />
+ </SettingRow>
+ <SettingRow
+ label="Metrics Interval (s)"
+ description="Seconds between metric snapshots"
+ >
+ <Input
+ type="number"
+ defaultValue={host?.statsConfig?.metricsInterval ?? 30}
+ className="w-20 h-7 text-xs text-right"
+ />
+ </SettingRow>
+ </div>
+ </SectionCard>
+ <SectionCard
+ title="Visible Widgets"
+ icon={<LayoutDashboard className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-0 py-1">
+ {[
+ {
+ id: "cpu",
+ label: "CPU Usage",
+ desc: "CPU percent, load averages, sparkline graph",
+ },
+ {
+ id: "memory",
+ label: "Memory",
+ desc: "RAM usage, swap, cached",
+ },
+ {
+ id: "disk",
+ label: "Storage",
+ desc: "Disk usage per mount point",
+ },
+ {
+ id: "disk_io",
+ label: "Disk I/O",
+ desc: "Read/write MB/s per device",
+ },
+ {
+ id: "network",
+ label: "Network",
+ desc: "Interface list and bandwidth",
+ },
+ {
+ id: "processes",
+ label: "Top Processes",
+ desc: "PID, CPU%, MEM%, command",
+ },
+ {
+ id: "logins",
+ label: "Recent Logins",
+ desc: "Successful and failed login events",
+ },
+ {
+ id: "ports",
+ label: "Listening Ports",
+ desc: "Open ports with process and state",
+ },
+ {
+ id: "security",
+ label: "Security",
+ desc: "Firewall, AppArmor, SELinux status",
+ },
+ ].map((w) => (
+ <SettingRow key={w.id} label={w.label} description={w.desc}>
+ <FakeSwitch
+ defaultChecked={
+ (host?.statsConfig?.enabledWidgets ?? []).includes(
+ w.id,
+ ) || !host?.statsConfig
+ }
+ />
+ </SettingRow>
+ ))}
+ </div>
+ </SectionCard>
+ <SectionCard
+ title="Quick Actions"
+ icon={<Zap className="size-3.5" />}
+ action={
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-6 text-[10px] px-2 border-accent-brand/40 text-accent-brand"
+ >
+ <Plus className="size-3 mr-1" /> Add Action
+ </Button>
+ }
+ >
+ <div className="flex flex-col gap-3 py-3">
+ <p className="text-xs text-muted-foreground">
+ Quick actions appear as buttons in the Server Stats toolbar
+ for one-click command execution.
+ </p>
+ {[
+ { name: "Restart Nginx", snippet: "System Update" },
+ { name: "Clear Logs", snippet: "Clear Logs" },
+ ].map((a, i) => (
+ <div
+ key={i}
+ className="flex items-center gap-2 p-2 bg-muted/20 border border-border group"
+ >
+ <Input
+ className="h-7 text-xs flex-1"
+ placeholder="Button label"
+ defaultValue={a.name}
+ />
+ <select className="flex h-7 flex-1 border border-border bg-background px-2 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option>System Update</option>
+ <option>Clear Logs</option>
+ <option>Check SSL</option>
+ <option>Disk Usage Report</option>
+ </select>
+ <button className="text-muted-foreground hover:text-destructive opacity-0 group-hover:opacity-100 transition-opacity">
+ <Trash2 className="size-3.5" />
+ </button>
+ </div>
+ ))}
+ {host?.quickActions?.length === 0 && (
+ <div className="flex flex-col items-center justify-center py-4 text-muted-foreground/40 gap-1.5">
+ <Zap className="size-6" />
+ <span className="text-xs">No quick actions yet.</span>
+ </div>
+ )}
+ </div>
+ </SectionCard>
+ </>
+ )}
+
+ {activeTab === "rdp" && (
+ <>
+ <SectionCard
+ title="Authentication"
+ icon={<Shield className="size-3.5" />}
+ >
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Username
+ </label>
+ <Input
+ placeholder="Administrator"
+ defaultValue={host?.rdpUser || ""}
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Password
+ </label>
+ <Input
+ type="password"
+ placeholder="••••••••"
+ defaultValue={host?.rdpPassword || ""}
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Domain
+ </label>
+ <Input
+ placeholder="WORKGROUP"
+ defaultValue={host?.domain || ""}
+ />
+ </div>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Connection Settings"
+ icon={<Shield className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Security Mode
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option value="any">Any</option>
+ <option value="nla">NLA</option>
+ <option value="nla-ext">NLA Extended</option>
+ <option value="tls">TLS</option>
+ <option value="vmconnect">VMConnect</option>
+ <option value="rdp">RDP</option>
+ </select>
+ </div>
+ <SettingRow
+ label="Ignore Certificate"
+ description="Allow connections to hosts with self-signed certificates"
+ >
+ <FakeSwitch defaultChecked={host?.ignoreCert} />
+ </SettingRow>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Display Settings"
+ icon={<Monitor className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Color Depth
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option value="auto">Auto</option>
+ <option value="8">8-bit</option>
+ <option value="16">16-bit</option>
+ <option value="24">24-bit</option>
+ <option value="32">32-bit</option>
+ </select>
+ </div>
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Width
+ </label>
+ <Input type="number" placeholder="Auto" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Height
+ </label>
+ <Input type="number" placeholder="Auto" />
+ </div>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ DPI
+ </label>
+ <Input type="number" placeholder="96" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Resize Method
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option value="auto">Auto</option>
+ <option value="display-update">Display Update</option>
+ <option value="reconnect">Reconnect</option>
+ </select>
+ </div>
+ <SettingRow
+ label="Force Lossless"
+ description="Force lossless image encoding (higher quality, more bandwidth)"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Audio Settings"
+ icon={<Activity className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-0 py-1">
+ <SettingRow
+ label="Disable Audio"
+ description="Mute all audio from the remote session"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Enable Audio Input (Microphone)"
+ description="Forward local microphone to the remote session"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="RDP Performance"
+ icon={<Zap className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-0 py-1">
+ <SettingRow
+ label="Wallpaper"
+ description="Show desktop wallpaper (disabling improves performance)"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Theming"
+ description="Enable visual themes and styles"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Font Smoothing"
+ description="Enable ClearType font rendering"
+ >
+ <FakeSwitch defaultChecked={true} />
+ </SettingRow>
+ <SettingRow
+ label="Full Window Drag"
+ description="Show window contents while dragging"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Desktop Composition"
+ description="Enable Aero glass effects"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Menu Animations"
+ description="Enable menu fade and slide animations"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Disable Bitmap Caching"
+ description="Turn off bitmap cache (may help with glitches)"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Disable Offscreen Caching"
+ description="Turn off offscreen cache"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Disable Glyph Caching"
+ description="Turn off glyph cache"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Enable GFX"
+ description="Use RemoteFX graphics pipeline"
+ >
+ <FakeSwitch defaultChecked={true} />
+ </SettingRow>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Device Redirection"
+ icon={<Settings className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <SettingRow
+ label="Enable Printing"
+ description="Redirect local printers to the remote session"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Enable Drive Redirection"
+ description="Map a local folder as a drive in the remote session"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-3 border-t border-border pt-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Drive Name
+ </label>
+ <Input placeholder="Termix Drive" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Drive Path
+ </label>
+ <Input placeholder="/home/user/shared" />
+ </div>
+ </div>
+ <SettingRow
+ label="Create Drive Path"
+ description="Automatically create the folder if it does not exist"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Disable Download"
+ description="Prevent downloading files from the remote session"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Disable Upload"
+ description="Prevent uploading files to the remote session"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Enable Touch"
+ description="Enable touch input forwarding"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+ </SectionCard>
+
+ <SectionCard title="Session" icon={<Server className="size-3.5" />}>
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Client Name
+ </label>
+ <Input placeholder="Termix" />
+ </div>
+ <SettingRow
+ label="Console Session"
+ description="Connect to the console (session 0) instead of a new session"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Initial Program
+ </label>
+ <Input placeholder="e.g. cmd.exe" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Server Layout
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option value="auto">Auto</option>
+ <option>en-us-qwerty</option>
+ <option>en-gb-qwerty</option>
+ <option>de-de-qwertz</option>
+ <option>fr-fr-azerty</option>
+ <option>it-it-qwerty</option>
+ <option>sv-se-qwerty</option>
+ <option>ja-jp-qwerty</option>
+ <option>pt-br-qwerty</option>
+ <option>es-es-qwerty</option>
+ <option>failsafe</option>
+ </select>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Timezone
+ </label>
+ <Input placeholder="e.g. America/New_York" />
+ </div>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Gateway"
+ icon={<Network className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Gateway Hostname
+ </label>
+ <Input placeholder="gateway.example.com" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Gateway Port
+ </label>
+ <Input type="number" placeholder="443" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Gateway Username
+ </label>
+ <Input placeholder="user" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Gateway Password
+ </label>
+ <Input type="password" placeholder="••••••••" />
+ </div>
+ <div className="flex flex-col gap-1.5 col-span-2">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Gateway Domain
+ </label>
+ <Input placeholder="DOMAIN" />
+ </div>
+ </div>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="RemoteApp"
+ icon={<Monitor className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ RemoteApp Program
+ </label>
+ <Input placeholder="||MyApp" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Working Directory
+ </label>
+ <Input placeholder="C:\Apps\MyApp" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Arguments
+ </label>
+ <Input placeholder="--flag value" />
+ </div>
+ </div>
+ </SectionCard>
+
+ <SectionCard title="Clipboard" icon={<Copy className="size-3.5" />}>
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Normalize Line Endings
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option value="auto">Auto</option>
+ <option value="preserve">Preserve</option>
+ <option value="unix">Unix (LF)</option>
+ <option value="windows">Windows (CRLF)</option>
+ </select>
+ </div>
+ <SettingRow
+ label="Disable Copy"
+ description="Prevent copying text from the remote session"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Disable Paste"
+ description="Prevent pasting text into the remote session"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Session Recording"
+ icon={<Activity className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Recording Path
+ </label>
+ <Input placeholder="/var/lib/termix/recordings" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Recording Name
+ </label>
+ <Input placeholder="${GUAC_USERNAME}-${GUAC_DATE}-${GUAC_TIME}" />
+ </div>
+ <SettingRow
+ label="Create Path if Missing"
+ description="Automatically create the recording directory"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Exclude Output"
+ description="Do not record screen output (metadata only)"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Exclude Mouse"
+ description="Do not record mouse movements"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Include Keystrokes"
+ description="Record raw keystrokes in addition to screen output"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Wake-on-LAN"
+ icon={<Zap className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <SettingRow
+ label="Send WOL Packet"
+ description="Send a magic packet to wake this host before connecting"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ MAC Address
+ </label>
+ <Input
+ placeholder="AA:BB:CC:DD:EE:FF"
+ defaultValue={host?.macAddress || ""}
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Broadcast Address
+ </label>
+ <Input placeholder="255.255.255.255" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ UDP Port
+ </label>
+ <Input type="number" placeholder="9" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Wait Time (s)
+ </label>
+ <Input type="number" placeholder="0" />
+ </div>
+ </div>
+ </div>
+ </SectionCard>
+ </>
+ )}
+
+ {activeTab === "vnc" && (
+ <>
+ <SectionCard
+ title="Authentication"
+ icon={<Shield className="size-3.5" />}
+ >
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ VNC Password
+ </label>
+ <Input
+ type="password"
+ placeholder="••••••••"
+ defaultValue={host?.vncPassword || ""}
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Username (optional)
+ </label>
+ <Input
+ placeholder="Leave blank if not required"
+ defaultValue={host?.vncUser || ""}
+ />
+ </div>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Display Settings"
+ icon={<Monitor className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Color Depth
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option value="auto">Auto</option>
+ <option value="8">8-bit</option>
+ <option value="16">16-bit</option>
+ <option value="24">24-bit</option>
+ <option value="32">32-bit</option>
+ </select>
+ </div>
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Width
+ </label>
+ <Input type="number" placeholder="Auto" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Height
+ </label>
+ <Input type="number" placeholder="Auto" />
+ </div>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Resize Method
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option value="auto">Auto</option>
+ <option value="display-update">Display Update</option>
+ <option value="reconnect">Reconnect</option>
+ </select>
+ </div>
+ <SettingRow
+ label="Force Lossless"
+ description="Force lossless image encoding (higher quality, more bandwidth)"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Audio Settings"
+ icon={<Activity className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-0 py-1">
+ <SettingRow
+ label="Disable Audio"
+ description="Mute all audio from the remote session"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="VNC Settings"
+ icon={<Settings className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Cursor Mode
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option value="auto">Auto</option>
+ <option value="local">Local</option>
+ <option value="remote">Remote</option>
+ </select>
+ </div>
+ <SettingRow
+ label="Swap Red/Blue"
+ description="Swap the red and blue color channels (fixes some colour issues)"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Read-only"
+ description="View the remote screen without sending any input"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+ </SectionCard>
+
+ <SectionCard title="Clipboard" icon={<Copy className="size-3.5" />}>
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Normalize Line Endings
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option value="auto">Auto</option>
+ <option value="preserve">Preserve</option>
+ <option value="unix">Unix (LF)</option>
+ <option value="windows">Windows (CRLF)</option>
+ </select>
+ </div>
+ <SettingRow
+ label="Disable Copy"
+ description="Prevent copying text from the remote session"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Disable Paste"
+ description="Prevent pasting text into the remote session"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Session Recording"
+ icon={<Activity className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Recording Path
+ </label>
+ <Input placeholder="/var/lib/termix/recordings" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Recording Name
+ </label>
+ <Input placeholder="${GUAC_USERNAME}-${GUAC_DATE}-${GUAC_TIME}" />
+ </div>
+ <SettingRow
+ label="Create Path if Missing"
+ description="Automatically create the recording directory"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Exclude Output"
+ description="Do not record screen output (metadata only)"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Exclude Mouse"
+ description="Do not record mouse movements"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Include Keystrokes"
+ description="Record raw keystrokes in addition to screen output"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Wake-on-LAN"
+ icon={<Zap className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <SettingRow
+ label="Send WOL Packet"
+ description="Send a magic packet to wake this host before connecting"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ MAC Address
+ </label>
+ <Input
+ placeholder="AA:BB:CC:DD:EE:FF"
+ defaultValue={host?.macAddress || ""}
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Broadcast Address
+ </label>
+ <Input placeholder="255.255.255.255" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ UDP Port
+ </label>
+ <Input type="number" placeholder="9" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Wait Time (s)
+ </label>
+ <Input type="number" placeholder="0" />
+ </div>
+ </div>
+ </div>
+ </SectionCard>
+ </>
+ )}
+
+ {activeTab === "telnet" && (
+ <>
+ <SectionCard
+ title="Authentication"
+ icon={<Shield className="size-3.5" />}
+ >
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Username
+ </label>
+ <Input
+ placeholder="admin"
+ defaultValue={host?.telnetUser || ""}
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Password
+ </label>
+ <Input
+ type="password"
+ placeholder="••••••••"
+ defaultValue={host?.telnetPassword || ""}
+ />
+ </div>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Display Settings"
+ icon={<Monitor className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Width
+ </label>
+ <Input type="number" placeholder="Auto" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Height
+ </label>
+ <Input type="number" placeholder="Auto" />
+ </div>
+ </div>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Terminal Settings"
+ icon={<Terminal className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Terminal Type
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option value="auto">Auto</option>
+ <option value="xterm">xterm</option>
+ <option value="xterm-256color">xterm-256color</option>
+ <option value="vt100">VT100</option>
+ <option value="vt220">VT220</option>
+ </select>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Font Name
+ </label>
+ <Input placeholder="monospace" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Font Size
+ </label>
+ <Input type="number" defaultValue={12} />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Color Scheme
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option value="auto">Auto</option>
+ <option value="black-white">Black on White</option>
+ <option value="white-black">White on Black</option>
+ <option value="gray-black">Gray on Black</option>
+ <option value="green-black">Green on Black</option>
+ </select>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Backspace Key
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option value="auto">Auto</option>
+ <option value="127">DEL (127)</option>
+ <option value="8">BS (8)</option>
+ </select>
+ </div>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Session Recording"
+ icon={<Activity className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Recording Path
+ </label>
+ <Input placeholder="/var/lib/termix/recordings" />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Recording Name
+ </label>
+ <Input placeholder="${GUAC_USERNAME}-${GUAC_DATE}-${GUAC_TIME}" />
+ </div>
+ <SettingRow
+ label="Create Path if Missing"
+ description="Automatically create the recording directory"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Exclude Output"
+ description="Do not record screen output (metadata only)"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label="Include Keystrokes"
+ description="Record raw keystrokes in addition to screen output"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+ </SectionCard>
+ </>
+ )}
+
+ {activeTab === "sharing" && (
+ <>
+ {host === null && (
+ <div className="flex items-start gap-3 p-3 border border-yellow-500/30 bg-yellow-500/5 text-xs text-yellow-500">
+ <Shield className="size-3.5 shrink-0 mt-0.5" />
+ <div>
+ <strong>Save the host first.</strong> Sharing options are
+ available after the host has been saved.
+ </div>
+ </div>
+ )}
+
+ <SectionCard
+ title="Share Host"
+ icon={<Users className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex gap-2">
+ {["user", "role"].map((t) => (
+ <button
+ key={t}
+ className={`px-3 py-1.5 text-[10px] font-bold uppercase tracking-widest border transition-colors ${t === "user" ? "border-accent-brand/40 bg-accent-brand/10 text-accent-brand" : "border-border text-muted-foreground hover:text-foreground"}`}
+ >
+ {t === "user" ? (
+ <>
+ <User className="size-3 inline mr-1" />
+ Share with User
+ </>
+ ) : (
+ <>
+ <Shield className="size-3 inline mr-1" />
+ Share with Role
+ </>
+ )}
+ </button>
+ ))}
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Select User
+ </label>
+ <select className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring">
+ <option value="">Select a user...</option>
+ <option>alice</option>
+ <option>bob</option>
+ <option>charlie</option>
+ </select>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Permission Level
+ </label>
+ <div className="px-3 py-2 border border-border bg-muted/30 text-xs text-muted-foreground">
+ View only
+ </div>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Expires in (hours)
+ </label>
+ <Input
+ type="number"
+ placeholder="Leave empty for no expiry"
+ />
+ </div>
+ <div className="flex justify-end">
+ <Button
+ variant="outline"
+ className="border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand"
+ onClick={() => toast.success("Host shared successfully")}
+ >
+ <Plus className="size-3.5 mr-1.5" />
+ Share
+ </Button>
+ </div>
+ </div>
+ </SectionCard>
+
+ <SectionCard
+ title="Current Access"
+ icon={<ListChecks className="size-3.5" />}
+ >
+ <div className="py-2">
+ <div className="grid grid-cols-6 gap-2 px-2 py-1.5 text-[10px] font-bold uppercase tracking-widest text-muted-foreground border-b border-border">
+ <span>Type</span>
+ <span>Target</span>
+ <span>Permission</span>
+ <span>Granted By</span>
+ <span>Expires</span>
+ <span></span>
+ </div>
+ {[
+ {
+ type: "User",
+ target: "alice",
+ permission: "View",
+ grantedBy: "admin",
+ expires: "Never",
+ expired: false,
+ },
+ {
+ type: "Role",
+ target: "Developers",
+ permission: "View",
+ grantedBy: "admin",
+ expires: "2026-06-01",
+ expired: false,
+ },
+ {
+ type: "User",
+ target: "bob",
+ permission: "View",
+ grantedBy: "alice",
+ expires: "2026-04-01",
+ expired: true,
+ },
+ ].map((r, i) => (
+ <div
+ key={i}
+ className="grid grid-cols-6 gap-2 px-2 py-2.5 border-b border-border last:border-0 items-center text-xs"
+ >
+ <div className="flex items-center gap-1">
+ {r.type === "User" ? (
+ <User className="size-3 text-muted-foreground" />
+ ) : (
+ <Shield className="size-3 text-muted-foreground" />
+ )}
+ <span className="text-muted-foreground">{r.type}</span>
+ </div>
+ <span className="font-semibold">{r.target}</span>
+ <span>{r.permission}</span>
+ <span className="text-muted-foreground">{r.grantedBy}</span>
+ <span
+ className={
+ r.expired ? "text-destructive" : "text-muted-foreground"
+ }
+ >
+ {r.expired ? (
+ <span className="flex items-center gap-1">
+ <X className="size-3" />
+ Expired
+ </span>
+ ) : (
+ r.expires
+ )}
+ </span>
+ <div className="flex justify-end">
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-6 text-[10px] px-2 text-destructive hover:bg-destructive/10"
+ onClick={() => toast.success("Access revoked")}
+ >
+ Revoke
+ </Button>
+ </div>
+ </div>
+ ))}
+ </div>
+ </SectionCard>
+ </>
+ )}
+ </div>
+
+ <div className="flex justify-end gap-3 mt-3 mb-6">
+ <Button variant="ghost" onClick={onBack}>
+ Cancel
+ </Button>
+ <Button
+ variant="outline"
+ className="border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand px-8"
+ onClick={() => {
+ toast.success("Host configuration saved");
+ onBack();
+ }}
+ >
+ Save Host
+ </Button>
+ </div>
+ </div>
+ );
+}
+
+function CredentialEditorView({
+ credential,
+ activeTab,
+ onBack,
+}: {
+ credential: Credential | null;
+ activeTab: string;
+ onBack: () => void;
+}) {
+ const [type, setType] = useState(credential?.type || "password");
+
+ return (
+ <div className="flex flex-col gap-3">
+ {activeTab === "general" && (
+ <SectionCard
+ title="Basic Information"
+ icon={<Info className="size-3.5" />}
+ >
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Friendly Name
+ </label>
+ <Input
+ placeholder="e.g. Production SSH Key"
+ defaultValue={credential?.name || ""}
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Folder
+ </label>
+ <Input
+ placeholder="e.g. Server Keys"
+ defaultValue={credential?.folder || ""}
+ />
+ </div>
+ <div className="flex flex-col gap-1.5 col-span-2">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Description
+ </label>
+ <Input
+ placeholder="Optional details..."
+ defaultValue={credential?.description || ""}
+ />
+ </div>
+ <div className="flex flex-col gap-1.5 col-span-2">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Tags
+ </label>
+ <Input
+ placeholder="space separated"
+ defaultValue={credential?.tags?.join(" ") || ""}
+ />
+ </div>
+ </div>
+ </SectionCard>
+ )}
+
+ {activeTab === "auth" && (
+ <SectionCard
+ title="Authentication Details"
+ icon={<Lock className="size-3.5" />}
+ >
+ <div className="flex flex-col gap-4 py-3">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Type
+ </label>
+ <div className="flex gap-2">
+ {["password", "key"].map((m) => (
+ <button
+ key={m}
+ onClick={() => setType(m as any)}
+ className={`px-3 py-1.5 text-[10px] font-bold uppercase tracking-widest border transition-colors ${type === m ? "border-accent-brand/40 bg-accent-brand/10 text-accent-brand" : "border-border text-muted-foreground hover:text-foreground"}`}
+ >
+ {m === "key" ? "SSH Private Key" : "Password"}
+ </button>
+ ))}
+ </div>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Username
+ </label>
+ <Input
+ placeholder="e.g. root or deploy"
+ defaultValue={credential?.username || ""}
+ />
+ </div>
+ {type === "password" && (
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Password
+ </label>
+ <Input
+ type="password"
+ placeholder="••••••••"
+ defaultValue={credential?.value || ""}
+ />
+ </div>
+ )}
+ {type === "key" && (
+ <div className="flex flex-col gap-4">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ SSH Private Key
+ </label>
+ <textarea
+ placeholder="-----BEGIN OPENSSH PRIVATE KEY-----"
+ rows={8}
+ defaultValue={credential?.value || ""}
+ className="w-full px-3 py-2 text-[10px] bg-background border border-border text-foreground placeholder:text-muted-foreground resize-none outline-none focus:ring-1 focus:ring-ring font-mono"
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ SSH Public Key (Optional)
+ </label>
+ <textarea
+ placeholder="ssh-rsa AAAAB3Nza..."
+ rows={3}
+ defaultValue={credential?.publicKey || ""}
+ className="w-full px-3 py-2 text-[10px] bg-background border border-border text-foreground placeholder:text-muted-foreground resize-none outline-none focus:ring-1 focus:ring-ring font-mono"
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ Key Passphrase (Optional)
+ </label>
+ <Input
+ type="password"
+ placeholder="••••••••"
+ defaultValue={credential?.passphrase || ""}
+ />
+ </div>
+ </div>
+ )}
+ </div>
+ </SectionCard>
+ )}
+
+ <div className="flex justify-end gap-3 mt-3">
+ <Button variant="ghost" onClick={onBack}>
+ Cancel
+ </Button>
+ <Button
+ variant="outline"
+ className="border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand px-8"
+ onClick={() => {
+ toast.success("Credential saved");
+ onBack();
+ }}
+ >
+ Save Credential
+ </Button>
+ </div>
+ </div>
+ );
+}
+
+export function HostManager({
+ onCollapse,
+ pendingEditId,
+ pendingAction,
+}: {
+ onCollapse?: () => void;
+ pendingEditId?: MutableRefObject<string | null>;
+ pendingAction?: MutableRefObject<"add-host" | "add-credential" | null>;
+} = {}) {
+ const [section, setSection] = useState<"hosts" | "credentials">("hosts");
+ const [editingHost, setEditingHost] = useState<Host | "new" | null>(null);
+ const [editingCredential, setEditingCredential] = useState<
+ Credential | "new" | null
+ >(null);
+ const [activeHostTab, setActiveHostTab] = useState("general");
+ const [activeCredentialTab, setActiveCredentialTab] = useState("general");
+ const [searchQuery, setSearchQuery] = useState("");
+ const [hosts, setHosts] = useState<Host[]>([]);
+ const [credentials, setCredentials] = useState<Credential[]>([]);
+ const [expandedFolders, setExpandedFolders] = useState<Set<string>>(
+ new Set(),
+ );
+ const [selectionMode, setSelectionMode] = useState(false);
+ const [selectedHostIds, setSelectedHostIds] = useState<Set<string>>(
+ new Set(),
+ );
+ const [editingFolderName, setEditingFolderName] = useState<string | null>(
+ null,
+ );
+ const [editingFolderValue, setEditingFolderValue] = useState("");
+ const [draggedHost, setDraggedHost] = useState<Host | null>(null);
+ const [dragOverFolder, setDragOverFolder] = useState<string | null>(null);
+ const [editingProtocols, setEditingProtocols] = useState({
+ enableSsh: true,
+ enableRdp: false,
+ enableVnc: false,
+ enableTelnet: false,
+ });
+ const fileInputRef = useRef<HTMLInputElement>(null);
+ const importOverwriteRef = useRef(false);
+ const [refreshing, setRefreshing] = useState(false);
+
+ useEffect(() => {
+ getSSHHosts()
+ .then((raw) => {
+ const converted = raw.map(sshHostToHost);
+ setHosts(converted);
+ setExpandedFolders(
+ new Set(converted.map((h) => h.folder.split(" / ")[0])),
+ );
+ })
+ .catch(() => {});
+ getCredentials()
+ .then((res: any) => {
+ const arr = Array.isArray(res?.credentials) ? res.credentials : [];
+ setCredentials(
+ arr.map((c: any) => ({
+ id: String(c.id),
+ name: c.name,
+ username: c.username,
+ type: c.authType === "key" ? "key" : "password",
+ description: c.description ?? "",
+ folder: c.folder ?? "",
+ })),
+ );
+ })
+ .catch(() => {});
+ }, []);
+
+ useEffect(() => {
+ if (pendingEditId?.current) {
+ const id = pendingEditId.current;
+ pendingEditId.current = null;
+ const host = hosts.find((h) => h.id === id);
+ if (host) {
+ setSection("hosts");
+ setEditingHost(host);
+ setEditingCredential(null);
+ setActiveHostTab("general");
+ setEditingProtocols({
+ enableSsh: host.enableSsh,
+ enableRdp: host.enableRdp,
+ enableVnc: host.enableVnc,
+ enableTelnet: host.enableTelnet,
+ });
+ }
+ }
+ if (pendingAction?.current) {
+ const action = pendingAction.current;
+ pendingAction.current = null;
+ if (action === "add-host") {
+ setSection("hosts");
+ setEditingHost("new");
+ setEditingCredential(null);
+ setEditingProtocols({
+ enableSsh: true,
+ enableRdp: false,
+ enableVnc: false,
+ enableTelnet: false,
+ });
+ setActiveHostTab("general");
+ } else if (action === "add-credential") {
+ setSection("credentials");
+ setEditingCredential("new");
+ setEditingHost(null);
+ }
+ }
+ }, [pendingEditId, pendingAction]);
+
+ useEffect(() => {
+ const handleAddHost = () => {
+ setSection("hosts");
+ setEditingHost("new");
+ setEditingCredential(null);
+ setEditingProtocols({
+ enableSsh: true,
+ enableRdp: false,
+ enableVnc: false,
+ enableTelnet: false,
+ });
+ setActiveHostTab("general");
+ };
+ const handleAddCredential = () => {
+ setSection("credentials");
+ setEditingCredential("new");
+ setEditingHost(null);
+ };
+ const handleEditHost = (e: Event) => {
+ const id = (e as CustomEvent<string>).detail;
+ const host = hosts.find((h) => h.id === id);
+ if (host) {
+ setSection("hosts");
+ setEditingHost(host);
+ setEditingCredential(null);
+ setActiveHostTab("general");
+ setEditingProtocols({
+ enableSsh: host.enableSsh,
+ enableRdp: host.enableRdp,
+ enableVnc: host.enableVnc,
+ enableTelnet: host.enableTelnet,
+ });
+ }
+ };
+ window.addEventListener("host-manager:add-host", handleAddHost);
+ window.addEventListener("host-manager:add-credential", handleAddCredential);
+ window.addEventListener("host-manager:edit-host", handleEditHost);
+ return () => {
+ window.removeEventListener("host-manager:add-host", handleAddHost);
+ window.removeEventListener(
+ "host-manager:add-credential",
+ handleAddCredential,
+ );
+ window.removeEventListener("host-manager:edit-host", handleEditHost);
+ };
+ }, []);
+
+ const allHosts = hosts;
+ const filteredHosts = allHosts.filter(
+ (h) =>
+ h.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
+ h.ip.toLowerCase().includes(searchQuery.toLowerCase()) ||
+ h.tags?.some((t) => t.toLowerCase().includes(searchQuery.toLowerCase())),
+ );
+ const filteredCredentials = credentials.filter(
+ (c) =>
+ c.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
+ c.username.toLowerCase().includes(searchQuery.toLowerCase()),
+ );
+
+ const folders = Array.from(new Set(allHosts.map((h) => h.folder))).sort();
+ const pinnedHosts = filteredHosts.filter((h) => h.pin);
+ const hostsByFolder = folders.reduce<Record<string, Host[]>>(
+ (acc, folder) => {
+ acc[folder] = filteredHosts.filter((h) => h.folder === folder && !h.pin);
+ return acc;
+ },
+ {},
+ );
+ const credentialFolders = Array.from(
+ new Set(credentials.map((c) => c.folder || "Uncategorized")),
+ ).sort();
+
+ const toggleFolder = (folder: string) => {
+ setExpandedFolders((prev) => {
+ const next = new Set(prev);
+ if (next.has(folder)) next.delete(folder);
+ else next.add(folder);
+ return next;
+ });
+ };
+ const toggleHostSelection = (id: string) => {
+ setSelectedHostIds((prev) => {
+ const next = new Set(prev);
+ if (next.has(id)) next.delete(id);
+ else next.add(id);
+ return next;
+ });
+ };
+ const handleExportHosts = () => {
+ const data = JSON.stringify({ hosts: allHosts }, null, 2);
+ const blob = new Blob([data], { type: "application/json" });
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = "termix-hosts.json";
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+ toast.success("Hosts exported successfully");
+ };
+
+ const handleDownloadSample = () => {
+ const sample = JSON.stringify(
+ {
+ hosts: [
+ {
+ name: "My Server",
+ address: "192.168.1.1",
+ user: "root",
+ port: 22,
+ folder: "Production",
+ enableSsh: true,
+ enableRdp: false,
+ enableVnc: false,
+ enableTelnet: false,
+ sshPort: 22,
+ rdpPort: 3389,
+ vncPort: 5900,
+ telnetPort: 23,
+ },
+ ],
+ },
+ null,
+ 2,
+ );
+ const blob = new Blob([sample], { type: "application/json" });
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = "termix-hosts-sample.json";
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+ toast.success("Sample file downloaded");
+ };
+
+ const handleRefresh = () => {
+ setRefreshing(true);
+ setTimeout(() => {
+ setRefreshing(false);
+ toast.success("Host statuses refreshed");
+ }, 1200);
+ };
+
+ // Build a nested folder tree from flat hosts using "/" as path separator
+ type FolderNode = {
+ name: string;
+ fullPath: string;
+ children: FolderNode[];
+ hosts: Host[];
+ };
+
+ const buildFolderTree = (hostList: Host[]): FolderNode => {
+ const root: FolderNode = {
+ name: "",
+ fullPath: "",
+ children: [],
+ hosts: [],
+ };
+ const nodeMap = new Map<string, FolderNode>();
+ nodeMap.set("", root);
+
+ const ensureNode = (path: string): FolderNode => {
+ if (nodeMap.has(path)) return nodeMap.get(path)!;
+ const parts = path.split(" / ");
+ const parentPath = parts.slice(0, -1).join(" / ");
+ const parent = ensureNode(parentPath);
+ const node: FolderNode = {
+ name: parts[parts.length - 1],
+ fullPath: path,
+ children: [],
+ hosts: [],
+ };
+ parent.children.push(node);
+ nodeMap.set(path, node);
+ return node;
+ };
+
+ for (const host of hostList) {
+ const node = ensureNode(host.folder || "");
+ if (!host.pin) node.hosts.push(host);
+ }
+ return root;
+ };
+
+ const folderTree = buildFolderTree(filteredHosts);
+
+ // Global stripe counter — mutable object so renderFolderNode can increment across recursion
+ const stripeCounter = { value: 0 };
+
+ const renderFolderNode = (
+ node: FolderNode,
+ depth: number = 0,
+ ): React.ReactNode => {
+ const isExpanded = expandedFolders.has(node.fullPath);
+ const isOver = dragOverFolder === node.fullPath;
+ const totalHosts = (() => {
+ const count = (n: FolderNode): number =>
+ n.hosts.length + n.children.reduce((s, c) => s + count(c), 0);
+ return count(node);
+ })();
+ const onlineHosts = (() => {
+ const count = (n: FolderNode): number =>
+ n.hosts.filter((h) => h.online).length +
+ n.children.reduce((s, c) => s + count(c), 0);
+ return count(node);
+ })();
+
+ if (totalHosts === 0 && node.children.length === 0) return null;
+
+ const folderStripe = stripeCounter.value++ % 2 === 1;
+
+ return (
+ <div key={node.fullPath}>
+ <div
+ className={`flex items-center gap-1.5 py-1.5 border-b border-border/40 group/folder transition-colors ${isOver ? "bg-accent-brand/5" : folderStripe ? "bg-muted/20 hover:bg-muted/40" : "hover:bg-muted/30"}`}
+ style={{ paddingLeft: `${depth * 12 + 8}px` }}
+ onDragOver={(e) => {
+ e.preventDefault();
+ setDragOverFolder(node.fullPath);
+ }}
+ onDragLeave={() => setDragOverFolder(null)}
+ onDrop={(e) => {
+ e.preventDefault();
+ setDragOverFolder(null);
+ if (draggedHost) {
+ toast.success(`Moved ${draggedHost.name} to ${node.fullPath}`);
+ setDraggedHost(null);
+ }
+ }}
+ >
+ <button
+ className="flex items-center gap-1.5 flex-1 text-left min-w-0"
+ onClick={() => toggleFolder(node.fullPath)}
+ >
+ <ChevronRight
+ className={`size-3 text-muted-foreground/40 shrink-0 transition-transform ${isExpanded ? "rotate-90" : ""}`}
+ />
+ {isExpanded ? (
+ <FolderOpen className="size-3 text-accent-brand/60 shrink-0" />
+ ) : (
+ <Folder className="size-3 text-muted-foreground/50 shrink-0" />
+ )}
+ {editingFolderName === node.fullPath ? (
+ <input
+ autoFocus
+ value={editingFolderValue}
+ onChange={(e) => setEditingFolderValue(e.target.value)}
+ onBlur={() => {
+ setEditingFolderName(null);
+ toast.success(`Folder renamed`);
+ }}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ setEditingFolderName(null);
+ toast.success(`Folder renamed`);
+ }
+ if (e.key === "Escape") setEditingFolderName(null);
+ }}
+ onClick={(e) => e.stopPropagation()}
+ className="text-[11px] font-semibold bg-background border border-accent-brand/60 px-1 outline-none text-foreground min-w-0 flex-1"
+ />
+ ) : (
+ <span className="text-[11px] font-semibold text-foreground/70 truncate">
+ {node.name}
+ </span>
+ )}
+ <span className="text-[10px] text-muted-foreground/40 shrink-0 ml-0.5 tabular-nums">
+ {onlineHosts > 0 && (
+ <span className="text-accent-brand">{onlineHosts}</span>
+ )}
+ <span>/{totalHosts}</span>
+ </span>
+ </button>
+ <div className="flex items-center gap-0.5 opacity-0 group-hover/folder:opacity-100 transition-opacity pr-2">
+ <button
+ className="size-5 flex items-center justify-center text-muted-foreground/40 hover:text-foreground rounded transition-colors"
+ onClick={(e) => {
+ e.stopPropagation();
+ setEditingFolderName(node.fullPath);
+ setEditingFolderValue(node.name);
+ }}
+ >
+ <Pencil className="size-2.5" />
+ </button>
+ <button
+ className="size-5 flex items-center justify-center text-muted-foreground/40 hover:text-destructive rounded transition-colors"
+ onClick={(e) => {
+ e.stopPropagation();
+ toast.success(`Deleted folder`);
+ }}
+ >
+ <Trash2 className="size-2.5" />
+ </button>
+ </div>
+ </div>
+
+ {isExpanded && (
+ <>
+ {node.children.map((child) => renderFolderNode(child, depth + 1))}
+ {node.hosts.map((host) => {
+ const stripe = stripeCounter.value++ % 2 === 1;
+ return (
+ <HostRow
+ key={host.id}
+ host={host}
+ depth={depth + 1}
+ stripeIndex={stripe ? 1 : 0}
+ selectionMode={selectionMode}
+ selected={selectedHostIds.has(host.id)}
+ onToggleSelect={() => toggleHostSelection(host.id)}
+ onEdit={() => {
+ setEditingHost(host);
+ setActiveHostTab("general");
+ setEditingProtocols({
+ enableSsh: host.enableSsh,
+ enableRdp: host.enableRdp,
+ enableVnc: host.enableVnc,
+ enableTelnet: host.enableTelnet,
+ });
+ }}
+ onDelete={() => toast.success(`Deleted ${host.name}`)}
+ onDragStart={() => setDraggedHost(host)}
+ onDragEnd={() => setDraggedHost(null)}
+ />
+ );
+ })}
+ </>
+ )}
+ </div>
+ );
+ };
+
+ // Editor view: full-width with top tab bar instead of side nav
+ const renderEditorView = () => {
+ const isHost = !!editingHost;
+ const tabs = isHost
+ ? HOST_TABS.filter((t) => {
+ if (t.id === "general" || t.id === "sharing") return true;
+ if (["ssh", "tunnels", "docker", "files", "stats"].includes(t.id))
+ return editingProtocols.enableSsh;
+ if (t.id === "rdp") return editingProtocols.enableRdp;
+ if (t.id === "vnc") return editingProtocols.enableVnc;
+ if (t.id === "telnet") return editingProtocols.enableTelnet;
+ return false;
+ })
+ : CREDENTIAL_TABS;
+ const activeTab = isHost ? activeHostTab : activeCredentialTab;
+ const setActiveTab = isHost ? setActiveHostTab : setActiveCredentialTab;
+
+ return (
+ <div className="flex flex-col flex-1 min-h-0">
+ {/* Back bar + tab strip */}
+ <div className="flex flex-col shrink-0 border-b border-border">
+ <button
+ onClick={() => {
+ if (isHost) {
+ setEditingHost(null);
+ setActiveHostTab("general");
+ } else {
+ setEditingCredential(null);
+ setActiveCredentialTab("general");
+ }
+ }}
+ className="flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/40 transition-colors border-b border-border/50"
+ >
+ <ArrowLeft className="size-3.5 shrink-0" />
+ <span>Back to {isHost ? "Hosts" : "Credentials"}</span>
+ {isHost && editingHost !== "new" && (
+ <span className="ml-auto font-semibold text-foreground truncate max-w-[200px]">
+ {(editingHost as Host).name}
+ </span>
+ )}
+ </button>
+ <TabStrip
+ tabs={tabs}
+ activeTab={activeTab}
+ onTabChange={setActiveTab}
+ />
+ </div>
+ <div className="flex-1 min-h-0 overflow-y-auto px-3 py-3 flex flex-col gap-3">
+ {isHost ? (
+ <HostEditor
+ key={
+ editingHost === "new" ? "new-host" : (editingHost as Host).id
+ }
+ host={editingHost === "new" ? null : (editingHost as Host)}
+ activeTab={activeHostTab}
+ onBack={() => {
+ setEditingHost(null);
+ setActiveHostTab("general");
+ }}
+ protocols={editingProtocols}
+ onProtocolChange={(p) =>
+ setEditingProtocols((prev) => ({ ...prev, ...p }))
+ }
+ onTabChange={setActiveHostTab}
+ />
+ ) : (
+ <CredentialEditorView
+ key={
+ editingCredential === "new"
+ ? "new-cred"
+ : (editingCredential as Credential).id
+ }
+ credential={
+ editingCredential === "new"
+ ? null
+ : (editingCredential as Credential)
+ }
+ activeTab={activeCredentialTab}
+ onBack={() => {
+ setEditingCredential(null);
+ setActiveCredentialTab("general");
+ }}
+ />
+ )}
+ </div>
+ </div>
+ );
+ };
+
+ const isEditing = !!editingHost || !!editingCredential;
+
+ return (
+ <div className="relative flex flex-col flex-1 min-h-0 overflow-hidden">
+ {/* Top bar: section switcher + actions */}
+ {!isEditing && (
+ <div className="flex items-center gap-0 shrink-0 border-b border-border/60">
+ {/* Section tabs */}
+ <button
+ onClick={() => {
+ setSection("hosts");
+ setEditingCredential(null);
+ setSearchQuery("");
+ }}
+ className={`flex items-center gap-1.5 px-3 py-2.5 text-xs font-semibold border-b-2 transition-colors ${section === "hosts" ? "border-accent-brand text-accent-brand" : "border-transparent text-muted-foreground hover:text-foreground"}`}
+ >
+ <Server className="size-3.5" />
+ Hosts
+ <span className="text-[10px] font-bold text-muted-foreground/50 ml-0.5">
+ {allHosts.length}
+ </span>
+ </button>
+ <button
+ onClick={() => {
+ setSection("credentials");
+ setEditingHost(null);
+ setSearchQuery("");
+ }}
+ className={`flex items-center gap-1.5 px-3 py-2.5 text-xs font-semibold border-b-2 transition-colors ${section === "credentials" ? "border-accent-brand text-accent-brand" : "border-transparent text-muted-foreground hover:text-foreground"}`}
+ >
+ <KeyRound className="size-3.5" />
+ Credentials
+ <span className="text-[10px] font-bold text-muted-foreground/50 ml-0.5">
+ {credentials.length}
+ </span>
+ </button>
+
+ <div className="flex-1" />
+
+ {onCollapse && (
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-8 text-muted-foreground hover:text-foreground shrink-0"
+ title="Collapse"
+ onClick={onCollapse}
+ >
+ <ChevronLeft className="size-3.5" />
+ </Button>
+ )}
+
+ {/* Action buttons — icon-only to save space */}
+ {section === "hosts" && (
+ <div className="flex items-center gap-0.5 pr-2">
+ <input
+ ref={fileInputRef}
+ type="file"
+ accept=".json"
+ className="hidden"
+ onChange={(e) => {
+ if (e.target.files?.[0])
+ toast.success(
+ importOverwriteRef.current
+ ? "Hosts imported (overwrite)"
+ : "Hosts imported",
+ );
+ }}
+ />
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-8 text-muted-foreground hover:text-foreground"
+ title="Refresh"
+ onClick={handleRefresh}
+ disabled={refreshing}
+ >
+ <RefreshCw
+ className={`size-3.5 ${refreshing ? "animate-spin" : ""}`}
+ />
+ </Button>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-8 text-muted-foreground hover:text-foreground"
+ title="Import / Export"
+ >
+ <Upload className="size-3.5" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="text-xs">
+ <DropdownMenuItem
+ onClick={() => {
+ importOverwriteRef.current = false;
+ fileInputRef.current?.click();
+ }}
+ >
+ <Upload className="size-3.5 mr-2" />
+ Import (skip existing)
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => {
+ importOverwriteRef.current = true;
+ fileInputRef.current?.click();
+ }}
+ >
+ <Upload className="size-3.5 mr-2" />
+ Import (overwrite)
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={handleExportHosts}
+ disabled={allHosts.length === 0}
+ >
+ <Download className="size-3.5 mr-2" />
+ Export All
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={handleDownloadSample}>
+ <Download className="size-3.5 mr-2" />
+ Download Sample
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <Button
+ variant="ghost"
+ size="icon"
+ className={`size-8 transition-colors ${selectionMode ? "text-accent-brand bg-accent-brand/10" : "text-muted-foreground hover:text-foreground"}`}
+ title={selectionMode ? "Exit selection" : "Select multiple"}
+ onClick={() => {
+ setSelectionMode((s) => !s);
+ setSelectedHostIds(new Set());
+ }}
+ >
+ <ListChecks className="size-3.5" />
+ </Button>
+ <div className="w-px h-4 bg-border mx-1" />
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-7 text-xs px-2.5"
+ onClick={() => {
+ setEditingHost("new");
+ setActiveHostTab("general");
+ setEditingProtocols({
+ enableSsh: true,
+ enableRdp: false,
+ enableVnc: false,
+ enableTelnet: false,
+ });
+ }}
+ >
+ <Plus className="size-3.5 mr-1" />
+ Add Host
+ </Button>
+ </div>
+ )}
+ {section === "credentials" && (
+ <div className="flex items-center gap-0.5 pr-2">
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-7 text-xs px-2.5"
+ onClick={() => {
+ setEditingCredential("new");
+ setActiveCredentialTab("general");
+ }}
+ >
+ <Plus className="size-3.5 mr-1" />
+ Add Credential
+ </Button>
+ </div>
+ )}
+ </div>
+ )}
+
+ {isEditing ? (
+ renderEditorView()
+ ) : (
+ <div className="flex flex-col flex-1 min-h-0 overflow-hidden">
+ {/* Search bar */}
+ <div className="px-2 py-1.5 shrink-0 border-b border-border/40">
+ <div className="flex items-center gap-2 px-2.5 h-7 bg-muted/60 border border-border/60">
+ <Search className="size-3 text-muted-foreground/60 shrink-0" />
+ <input
+ value={searchQuery}
+ onChange={(e) => setSearchQuery(e.target.value)}
+ placeholder={
+ section === "hosts"
+ ? "Search hosts, addresses, tags…"
+ : "Search credentials…"
+ }
+ className="flex-1 text-xs bg-transparent outline-none placeholder:text-muted-foreground/50 text-foreground min-w-0"
+ />
+ {searchQuery && (
+ <button
+ onClick={() => setSearchQuery("")}
+ className="text-muted-foreground/60 hover:text-muted-foreground transition-colors"
+ >
+ <X className="size-3" />
+ </button>
+ )}
+ </div>
+ </div>
+
+ <div className="flex-1 min-h-0 overflow-y-auto">
+ {section === "hosts" && (
+ <div className="flex flex-col">
+ {/* Pinned hosts */}
+ {pinnedHosts.length > 0 && (
+ <div className="flex flex-col">
+ <div className="flex items-center gap-1.5 px-3 py-1.5 border-b border-border/40 bg-accent-brand/5">
+ <Pin className="size-2.5 text-accent-brand" />
+ <span className="text-[10px] font-bold uppercase tracking-widest text-accent-brand">
+ Pinned
+ </span>
+ <span className="text-[10px] text-accent-brand/50 ml-0.5">
+ {pinnedHosts.length}
+ </span>
+ </div>
+ {pinnedHosts.map((host) => (
+ <HostRow
+ key={host.id}
+ host={host}
+ selectionMode={selectionMode}
+ selected={selectedHostIds.has(host.id)}
+ onToggleSelect={() => toggleHostSelection(host.id)}
+ onEdit={() => {
+ setEditingHost(host);
+ setActiveHostTab("general");
+ setEditingProtocols({
+ enableSsh: host.enableSsh,
+ enableRdp: host.enableRdp,
+ enableVnc: host.enableVnc,
+ enableTelnet: host.enableTelnet,
+ });
+ }}
+ onDelete={() => toast.success(`Deleted ${host.name}`)}
+ />
+ ))}
+ </div>
+ )}
+
+ {/* Nested folder tree */}
+ {folderTree.children.map((node) => renderFolderNode(node, 0))}
+ {/* Root-level (no folder) hosts */}
+ {folderTree.hosts.map((host) => (
+ <HostRow
+ key={host.id}
+ host={host}
+ selectionMode={selectionMode}
+ selected={selectedHostIds.has(host.id)}
+ onToggleSelect={() => toggleHostSelection(host.id)}
+ onEdit={() => {
+ setEditingHost(host);
+ setActiveHostTab("general");
+ setEditingProtocols({
+ enableSsh: host.enableSsh,
+ enableRdp: host.enableRdp,
+ enableVnc: host.enableVnc,
+ enableTelnet: host.enableTelnet,
+ });
+ }}
+ onDelete={() => toast.success(`Deleted ${host.name}`)}
+ onDragStart={() => setDraggedHost(host)}
+ onDragEnd={() => setDraggedHost(null)}
+ />
+ ))}
+
+ {filteredHosts.length === 0 && (
+ <div className="flex flex-col items-center justify-center py-12 text-center px-4">
+ <Server className="size-8 text-muted-foreground/20 mb-2" />
+ <span className="text-sm font-semibold text-muted-foreground/60">
+ No hosts found
+ </span>
+ <span className="text-xs text-muted-foreground/40 mt-1">
+ {searchQuery
+ ? "Try a different term"
+ : "Add your first host to get started"}
+ </span>
+ {!searchQuery && (
+ <Button
+ variant="outline"
+ size="sm"
+ className="mt-3 h-7 text-xs border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10"
+ onClick={() => {
+ setEditingHost("new");
+ setActiveHostTab("general");
+ setEditingProtocols({
+ enableSsh: true,
+ enableRdp: false,
+ enableVnc: false,
+ enableTelnet: false,
+ });
+ }}
+ >
+ <Plus className="size-3 mr-1" />
+ Add Host
+ </Button>
+ )}
+ </div>
+ )}
+ </div>
+ )}
+
+ {section === "credentials" && (
+ <div className="flex flex-col">
+ {credentialFolders.map((folder) => {
+ const creds = filteredCredentials.filter(
+ (c) => (c.folder || "Uncategorized") === folder,
+ );
+ if (creds.length === 0) return null;
+ return (
+ <div key={folder}>
+ <div className="flex items-center gap-1.5 px-3 py-1.5 border-b border-border/40 bg-muted/20">
+ <Folder className="size-3 text-muted-foreground/50" />
+ <span className="text-[10px] font-semibold text-muted-foreground/70">
+ {folder}
+ </span>
+ <span className="text-[10px] text-muted-foreground/40">
+ {creds.length}
+ </span>
+ </div>
+ {creds.map((cred) => {
+ const usedByHosts = allHosts.filter(
+ (h) => h.credentialId === cred.id,
+ );
+ return (
+ <div
+ key={cred.id}
+ className="flex items-center justify-between px-3 py-2 border-b border-border/40 last:border-0 hover:bg-muted/30 group"
+ >
+ <div className="flex items-center gap-2.5 min-w-0">
+ <div className="size-7 border border-border/60 bg-muted/30 flex items-center justify-center shrink-0">
+ {cred.type === "key" ? (
+ <Shield className="size-3 text-accent-brand" />
+ ) : (
+ <Lock className="size-3 text-accent-brand" />
+ )}
+ </div>
+ <div className="flex flex-col min-w-0">
+ <div className="flex items-center gap-1.5">
+ <span className="text-xs font-semibold truncate">
+ {cred.name}
+ </span>
+ <span
+ className={`text-[9px] px-1 py-px font-bold border leading-none shrink-0 ${cred.type === "key" ? "border-accent-brand/30 text-accent-brand" : "border-border/60 text-muted-foreground/60"}`}
+ >
+ {cred.type === "key" ? "KEY" : "PWD"}
+ </span>
+ </div>
+ <span className="text-[11px] text-muted-foreground/50 truncate">
+ {cred.username}
+ {usedByHosts.length > 0 && (
+ <span className="text-muted-foreground/30">
+ {" "}
+ · {usedByHosts.length}h
+ </span>
+ )}
+ </span>
+ </div>
+ </div>
+ <div className="flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0">
+ {cred.type === "key" && (
+ <button
+ className="flex items-center gap-1 px-1.5 py-1 text-[10px] text-muted-foreground/60 hover:text-foreground hover:bg-muted rounded transition-colors"
+ onClick={() => {
+ navigator.clipboard.writeText(
+ `ssh-copy-id -i ~/.ssh/id_rsa.pub ${cred.username}@<host>`,
+ );
+ toast.success("Copied");
+ }}
+ >
+ <Copy className="size-3" />
+ </button>
+ )}
+ <button
+ className="size-6 flex items-center justify-center text-muted-foreground/50 hover:text-foreground hover:bg-muted rounded transition-colors"
+ onClick={() => {
+ setEditingCredential(cred);
+ setActiveCredentialTab("general");
+ }}
+ >
+ <Pencil className="size-3" />
+ </button>
+ <button
+ className="size-6 flex items-center justify-center text-muted-foreground/40 hover:text-destructive hover:bg-destructive/10 rounded transition-colors"
+ onClick={() =>
+ toast.success(`Deleted ${cred.name}`)
+ }
+ >
+ <Trash2 className="size-3" />
+ </button>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ );
+ })}
+ {filteredCredentials.length === 0 && (
+ <div className="flex flex-col items-center justify-center py-12 text-center px-4">
+ <KeyRound className="size-8 text-muted-foreground/20 mb-2" />
+ <span className="text-sm font-semibold text-muted-foreground/60">
+ No credentials found
+ </span>
+ <Button
+ variant="outline"
+ size="sm"
+ className="mt-3 h-7 text-xs border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10"
+ onClick={() => {
+ setEditingCredential("new");
+ setActiveCredentialTab("general");
+ }}
+ >
+ <Plus className="size-3 mr-1" />
+ Add Credential
+ </Button>
+ </div>
+ )}
+ </div>
+ )}
+ </div>
+ </div>
+ )}
+
+ {/* Floating selection bar */}
+ {selectionMode && !isEditing && (
+ <div className="absolute bottom-4 inset-x-3 z-50">
+ <div className="bg-popover border border-border shadow-xl px-2.5 py-2 flex items-center gap-1.5 flex-wrap">
+ <span className="text-xs font-semibold tabular-nums shrink-0">
+ {selectedHostIds.size} selected
+ </span>
+ <div className="w-px h-4 bg-border mx-0.5" />
+ <button
+ className="text-[10px] text-muted-foreground hover:text-foreground px-1.5 py-1 hover:bg-muted rounded transition-colors"
+ onClick={() => {
+ if (selectedHostIds.size === allHosts.length)
+ setSelectedHostIds(new Set());
+ else setSelectedHostIds(new Set(allHosts.map((h) => h.id)));
+ }}
+ >
+ {selectedHostIds.size === allHosts.length
+ ? "Deselect All"
+ : "All"}
+ </button>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <button
+ className="text-[10px] text-muted-foreground hover:text-foreground px-1.5 py-1 hover:bg-muted rounded transition-colors flex items-center gap-1"
+ disabled={selectedHostIds.size === 0}
+ >
+ Features <ChevronDown className="size-2.5" />
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="text-xs">
+ <DropdownMenuItem onClick={() => toast.success("Done")}>
+ <Terminal className="size-3.5 mr-2" />
+ Enable Terminal
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={() => toast.success("Done")}>
+ <FolderSearch className="size-3.5 mr-2" />
+ Enable Files
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={() => toast.success("Done")}>
+ <Network className="size-3.5 mr-2" />
+ Enable Tunnels
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={() => toast.success("Done")}>
+ <Box className="size-3.5 mr-2" />
+ Enable Docker
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <button
+ className="text-[10px] text-muted-foreground hover:text-foreground px-1.5 py-1 hover:bg-muted rounded transition-colors flex items-center gap-1"
+ disabled={selectedHostIds.size === 0}
+ >
+ Move <ChevronDown className="size-2.5" />
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="text-xs">
+ {folders.map((f) => (
+ <DropdownMenuItem
+ key={f}
+ onClick={() => toast.success(`Moved to ${f}`)}
+ >
+ <FolderOpen className="size-3.5 mr-2" />
+ {f}
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <button
+ className="text-[10px] text-destructive hover:text-destructive px-1.5 py-1 hover:bg-destructive/10 rounded transition-colors"
+ disabled={selectedHostIds.size === 0}
+ onClick={() => {
+ toast.success(`Deleted ${selectedHostIds.size} hosts`);
+ setSelectedHostIds(new Set());
+ }}
+ >
+ Delete
+ </button>
+ <div className="flex-1" />
+ <button
+ className="text-[10px] text-muted-foreground hover:text-foreground px-1.5 py-1 hover:bg-muted rounded transition-colors"
+ onClick={() => {
+ setSelectionMode(false);
+ setSelectedHostIds(new Set());
+ }}
+ >
+ Cancel
+ </button>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/src/ui/sidebar/HostsPanel.tsx b/src/ui/sidebar/HostsPanel.tsx
new file mode 100644
index 000000000..5a63e5436
--- /dev/null
+++ b/src/ui/sidebar/HostsPanel.tsx
@@ -0,0 +1,78 @@
+import { useState } from "react";
+import { Search, Settings, X } from "lucide-react";
+import { SidebarTree } from "@/sidebar/SidebarTree";
+import { HostManager } from "@/sidebar/HostManager";
+import type { Host, HostFolder, TabType } from "@/types/ui-types";
+import type { MutableRefObject } from "react";
+
+export function HostsPanel({
+ expanded,
+ onExpand,
+ onCollapse,
+ pendingEditId,
+ pendingAction,
+ onOpenTab,
+ onEditHost,
+ hostTree,
+}: {
+ expanded: boolean;
+ onExpand: () => void;
+ onCollapse: () => void;
+ pendingEditId: MutableRefObject<string | null>;
+ pendingAction: MutableRefObject<"add-host" | "add-credential" | null>;
+ onOpenTab: (host: Host, type: TabType) => void;
+ onEditHost: (host: Host) => void;
+ hostTree?: HostFolder;
+}) {
+ const [hostSearch, setHostSearch] = useState("");
+
+ if (expanded) {
+ return (
+ <HostManager
+ onCollapse={onCollapse}
+ pendingEditId={pendingEditId}
+ pendingAction={pendingAction}
+ />
+ );
+ }
+
+ return (
+ <div className="flex flex-col flex-1 min-h-0 overflow-hidden">
+ <div className="flex items-center gap-1.5 px-2 py-1.5 shrink-0 border-b border-border/60">
+ <div className="flex items-center gap-2 px-2.5 h-7 bg-muted/60 border border-border/60 rounded-sm flex-1 min-w-0">
+ <Search className="size-3 text-muted-foreground/60 shrink-0" />
+ <input
+ value={hostSearch}
+ onChange={(e) => setHostSearch(e.target.value)}
+ placeholder="Search hosts..."
+ className="flex-1 text-xs bg-transparent outline-none placeholder:text-muted-foreground/50 text-foreground min-w-0"
+ />
+ {hostSearch && (
+ <button
+ onClick={() => setHostSearch("")}
+ className="text-muted-foreground/60 hover:text-muted-foreground transition-colors"
+ >
+ <X className="size-3" />
+ </button>
+ )}
+ </div>
+ <button
+ onClick={onExpand}
+ title="Manage Hosts"
+ className="flex items-center gap-1 h-7 px-2 text-[10px] font-medium text-muted-foreground hover:text-foreground hover:bg-muted/60 border border-border/60 rounded-sm shrink-0 transition-colors"
+ >
+ <Settings className="size-3 shrink-0" />
+ Manage
+ </button>
+ </div>
+ <div className="flex-1 min-h-0 overflow-y-auto py-1">
+ <SidebarTree
+ children={hostTree?.children ?? []}
+ onOpenTab={onOpenTab}
+ onEditHost={onEditHost}
+ query={hostSearch.trim().toLowerCase()}
+ />
+ </div>
+ </div>
+ );
+}
diff --git a/src/ui/sidebar/QuickConnectPanel.tsx b/src/ui/sidebar/QuickConnectPanel.tsx
new file mode 100644
index 000000000..0d5241336
--- /dev/null
+++ b/src/ui/sidebar/QuickConnectPanel.tsx
@@ -0,0 +1,140 @@
+import { useState } from "react";
+import { useTranslation } from "react-i18next";
+import { Eye, EyeOff, FolderSearch, Terminal } from "lucide-react";
+import { Input } from "@/components/input";
+
+export function QuickConnectPanel() {
+ const { t } = useTranslation();
+ const [host, setHost] = useState("");
+ const [port, setPort] = useState("22");
+ const [username, setUsername] = useState("");
+ const [authType, setAuthType] = useState<"password" | "key" | "credential">(
+ "password",
+ );
+ const [password, setPassword] = useState("");
+ const [showPassword, setShowPassword] = useState(false);
+
+ return (
+ <div className="flex flex-col flex-1 min-h-0 overflow-y-auto">
+ <div className="flex flex-col gap-3 p-3">
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.quickConnect.hostLabel")}
+ </label>
+ <Input
+ placeholder={t("newUi.sidebar.quickConnect.hostPlaceholder")}
+ value={host}
+ onChange={(e) => setHost(e.target.value)}
+ className="h-7 text-xs"
+ />
+ </div>
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.quickConnect.portLabel")}
+ </label>
+ <Input
+ placeholder={t("newUi.sidebar.quickConnect.portPlaceholder")}
+ value={port}
+ onChange={(e) => setPort(e.target.value)}
+ className="h-7 text-xs"
+ />
+ </div>
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.quickConnect.usernameLabel")}
+ </label>
+ <Input
+ placeholder={t("newUi.sidebar.quickConnect.usernamePlaceholder")}
+ value={username}
+ onChange={(e) => setUsername(e.target.value)}
+ className="h-7 text-xs"
+ />
+ </div>
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.quickConnect.authLabel")}
+ </label>
+ <div className="flex gap-1">
+ {(["password", "key", "credential"] as const).map((type) => (
+ <button
+ key={type}
+ onClick={() => setAuthType(type)}
+ className={`flex-1 py-1 text-[10px] font-semibold border transition-colors capitalize ${
+ authType === type
+ ? "border-accent-brand/40 bg-accent-brand/10 text-accent-brand"
+ : "border-border text-muted-foreground hover:text-foreground"
+ }`}
+ >
+ {type}
+ </button>
+ ))}
+ </div>
+ </div>
+ {authType === "password" && (
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.quickConnect.passwordLabel")}
+ </label>
+ <div className="relative">
+ <Input
+ type={showPassword ? "text" : "password"}
+ placeholder={t(
+ "newUi.sidebar.quickConnect.passwordPlaceholder",
+ )}
+ value={password}
+ onChange={(e) => setPassword(e.target.value)}
+ className="h-7 text-xs pr-8"
+ />
+ <button
+ onClick={() => setShowPassword((o) => !o)}
+ className="absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
+ >
+ {showPassword ? (
+ <EyeOff className="size-3.5" />
+ ) : (
+ <Eye className="size-3.5" />
+ )}
+ </button>
+ </div>
+ </div>
+ )}
+ {authType === "key" && (
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.quickConnect.privateKeyLabel")}
+ </label>
+ <textarea
+ placeholder={t(
+ "newUi.sidebar.quickConnect.privateKeyPlaceholder",
+ )}
+ className="w-full h-24 px-2.5 py-2 text-xs bg-background border border-border text-foreground placeholder:text-muted-foreground resize-none outline-none focus:ring-1 focus:ring-ring font-mono"
+ />
+ </div>
+ )}
+ {authType === "credential" && (
+ <div className="flex flex-col gap-1">
+ <label className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.quickConnect.credentialLabel")}
+ </label>
+ <Input
+ placeholder={t(
+ "newUi.sidebar.quickConnect.credentialPlaceholder",
+ )}
+ className="h-7 text-xs"
+ />
+ </div>
+ )}
+ <div className="flex flex-col gap-1.5 pt-1">
+ <button className="flex items-center justify-center gap-1.5 h-7 w-full border border-accent-brand/40 bg-accent-brand/10 text-accent-brand text-xs font-semibold hover:bg-accent-brand/20 transition-colors">
+ <Terminal className="size-3.5" />
+ {t("newUi.sidebar.quickConnect.connectToTerminal")}
+ </button>
+ <button className="flex items-center justify-center gap-1.5 h-7 w-full border border-accent-brand/40 bg-accent-brand/10 text-accent-brand text-xs font-semibold hover:bg-accent-brand/20 transition-colors">
+ <FolderSearch className="size-3.5" />
+ {t("newUi.sidebar.quickConnect.connectToFiles")}
+ </button>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/src/ui/sidebar/SidebarTree.tsx b/src/ui/sidebar/SidebarTree.tsx
new file mode 100644
index 000000000..e76d1ef27
--- /dev/null
+++ b/src/ui/sidebar/SidebarTree.tsx
@@ -0,0 +1,393 @@
+import { useState } from "react";
+import {
+ Box,
+ ChevronRight,
+ Cpu,
+ FolderOpen,
+ FolderSearch,
+ MemoryStick,
+ Monitor,
+ Network,
+ Pencil,
+ Server,
+ Terminal,
+} from "lucide-react";
+import type { Host, HostFolder, TabType } from "@/types/ui-types";
+
+export function isFolder(item: Host | HostFolder): item is HostFolder {
+ return "children" in item;
+}
+
+const SSH_ACTIONS: { type: TabType; icon: typeof Terminal; label: string }[] = [
+ { type: "terminal", icon: Terminal, label: "Terminal" },
+ { type: "stats", icon: Server, label: "Stats" },
+ { type: "files", icon: FolderSearch, label: "Files" },
+ { type: "docker", icon: Box, label: "Docker" },
+ { type: "tunnel", icon: Network, label: "Tunnel" },
+];
+
+function hostMatchesQuery(host: Host, query: string) {
+ return (
+ host.name.toLowerCase().includes(query) ||
+ host.ip.toLowerCase().includes(query) ||
+ host.username.toLowerCase().includes(query) ||
+ host.tags?.some((t) => t.toLowerCase().includes(query))
+ );
+}
+
+function folderHasMatch(folder: HostFolder, query: string): boolean {
+ for (const child of folder.children) {
+ if (isFolder(child)) {
+ if (folderHasMatch(child, query)) return true;
+ } else {
+ if (hostMatchesQuery(child, query)) return true;
+ }
+ }
+ return false;
+}
+
+// Walks the visible tree in render order and pushes every visible row
+// (folder header + hosts) into `out`. This gives us a flat ordered list
+// to assign a single global stripe counter across folders and hosts.
+function collectVisibleRows(
+ children: (Host | HostFolder)[],
+ query: string,
+ openSet: Set<string>,
+ out: (Host | HostFolder)[] = [],
+): (Host | HostFolder)[] {
+ for (const child of children) {
+ if (isFolder(child)) {
+ const visible = query ? folderHasMatch(child, query) : true;
+ if (!visible) continue;
+ out.push(child); // folder header row counts
+ const childOpen = query ? true : openSet.has(child.name);
+ if (childOpen) collectVisibleRows(child.children, query, openSet, out);
+ } else {
+ if (!query || hostMatchesQuery(child, query)) out.push(child);
+ }
+ }
+ return out;
+}
+
+function folderHostCount(folder: HostFolder): {
+ total: number;
+ online: number;
+} {
+ let total = 0,
+ online = 0;
+ for (const child of folder.children) {
+ if (isFolder(child)) {
+ const c = folderHostCount(child);
+ total += c.total;
+ online += c.online;
+ } else {
+ total++;
+ if (child.online) online++;
+ }
+ }
+ return { total, online };
+}
+
+export function HostItem({
+ host,
+ onOpenTab,
+ onEditHost,
+ query = "",
+ stripeIndex = 0,
+}: {
+ host: Host;
+ onOpenTab: (type: TabType) => void;
+ onEditHost?: () => void;
+ query?: string;
+ stripeIndex?: number;
+}) {
+ const [hovered, setHovered] = useState(false);
+
+ if (query && !hostMatchesQuery(host, query)) return null;
+
+ return (
+ <div
+ className={`relative flex items-stretch cursor-pointer select-none transition-colors hover:bg-muted/40 ${stripeIndex % 2 === 1 ? "bg-muted/20" : ""}`}
+ onMouseEnter={() => setHovered(true)}
+ onMouseLeave={() => setHovered(false)}
+ onClick={() => onOpenTab("terminal")}
+ >
+ {/* Status stripe */}
+ <div
+ className={`w-[3px] shrink-0 transition-colors ${host.online ? "bg-accent-brand" : "bg-transparent"}`}
+ />
+
+ <div className="flex flex-col flex-1 min-w-0 px-2.5 pt-2 pb-1.5 gap-1">
+ {/* Name + dot */}
+ <div className="flex items-center gap-1.5 min-w-0">
+ <span
+ className={`size-1.5 rounded-full shrink-0 ${host.online ? "bg-accent-brand" : "bg-muted-foreground/25"}`}
+ />
+ <span className="text-[13px] font-medium truncate text-foreground leading-none">
+ {host.name}
+ </span>
+ </div>
+ {/* Address — only visible on hover */}
+ <span
+ className={`text-[11px] text-muted-foreground/55 truncate leading-none pl-3 transition-opacity duration-100 ${hovered ? "opacity-100" : "opacity-0 h-0 overflow-hidden"}`}
+ >
+ {host.username}@{host.ip}
+ </span>
+
+ {/* Action tray — slides open on hover */}
+ <div
+ className="overflow-hidden transition-all duration-150 ease-out"
+ style={{
+ maxHeight: hovered ? "200px" : "0px",
+ opacity: hovered ? 1 : 0,
+ }}
+ >
+ {host.online &&
+ (host.cpu !== undefined || host.ram !== undefined) && (
+ <div className="flex items-center gap-3 pl-3">
+ {host.cpu !== undefined && (
+ <div className="flex items-center gap-1">
+ <Cpu className="size-2.5 shrink-0 text-muted-foreground/30" />
+ <div className="w-9 h-[3px] bg-muted-foreground/15 rounded-full overflow-hidden">
+ <div
+ className={`h-full rounded-full ${host.cpu > 80 ? "bg-red-400" : host.cpu > 50 ? "bg-yellow-400" : "bg-accent-brand"}`}
+ style={{ width: `${host.cpu}%` }}
+ />
+ </div>
+ <span className="text-[9px] tabular-nums text-muted-foreground/40">
+ {host.cpu}%
+ </span>
+ </div>
+ )}
+ {host.ram !== undefined && (
+ <div className="flex items-center gap-1">
+ <MemoryStick className="size-2.5 shrink-0 text-muted-foreground/30" />
+ <div className="w-9 h-[3px] bg-muted-foreground/15 rounded-full overflow-hidden">
+ <div
+ className={`h-full rounded-full ${host.ram > 80 ? "bg-red-400" : host.ram > 60 ? "bg-yellow-400" : "bg-accent-brand/60"}`}
+ style={{ width: `${host.ram}%` }}
+ />
+ </div>
+ <span className="text-[9px] tabular-nums text-muted-foreground/40">
+ {host.ram}%
+ </span>
+ </div>
+ )}
+ </div>
+ )}
+
+ <div className="flex items-center flex-wrap gap-1 pt-1.5 pl-2 pb-1">
+ {host.enableSsh &&
+ SSH_ACTIONS.map(({ type, icon: Icon, label }) => (
+ <button
+ key={type}
+ title={label}
+ onClick={(e) => {
+ e.stopPropagation();
+ onOpenTab(type);
+ }}
+ className="flex items-center justify-center size-7 rounded text-muted-foreground/50 hover:text-foreground hover:bg-muted-foreground/10 transition-colors"
+ >
+ <Icon className="size-3.5" />
+ </button>
+ ))}
+ {host.enableSsh &&
+ (host.enableRdp || host.enableVnc || host.enableTelnet) && (
+ <div className="w-px h-3.5 bg-border/60 mx-0.5 shrink-0" />
+ )}
+ {host.enableRdp && (
+ <button
+ title="RDP"
+ onClick={(e) => {
+ e.stopPropagation();
+ onOpenTab("rdp");
+ }}
+ className="flex items-center gap-1.5 px-2.5 h-6 rounded text-xs font-medium text-muted-foreground/70 hover:text-foreground hover:bg-muted-foreground/10 transition-colors border border-border/40"
+ >
+ <Monitor className="size-3" />
+ RDP
+ </button>
+ )}
+ {host.enableVnc && (
+ <button
+ title="VNC"
+ onClick={(e) => {
+ e.stopPropagation();
+ onOpenTab("vnc");
+ }}
+ className="flex items-center gap-1.5 px-2.5 h-6 rounded text-xs font-medium text-muted-foreground/70 hover:text-foreground hover:bg-muted-foreground/10 transition-colors border border-border/40"
+ >
+ <Monitor className="size-3" />
+ VNC
+ </button>
+ )}
+ {host.enableTelnet && (
+ <button
+ title="Telnet"
+ onClick={(e) => {
+ e.stopPropagation();
+ onOpenTab("telnet");
+ }}
+ className="flex items-center gap-1.5 px-2.5 h-6 rounded text-xs font-medium text-muted-foreground/70 hover:text-foreground hover:bg-muted-foreground/10 transition-colors border border-border/40"
+ >
+ <Terminal className="size-3" />
+ Telnet
+ </button>
+ )}
+ {onEditHost && (
+ <>
+ <div className="w-px h-3.5 bg-border/60 mx-0.5 shrink-0" />
+ <button
+ title="Edit Host"
+ onClick={(e) => {
+ e.stopPropagation();
+ onEditHost();
+ }}
+ className="flex items-center justify-center size-7 rounded text-muted-foreground/50 hover:text-foreground hover:bg-muted-foreground/10 transition-colors"
+ >
+ <Pencil className="size-3.5" />
+ </button>
+ </>
+ )}
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+export function FolderItem({
+ folder,
+ depth = 0,
+ onOpenTab,
+ onEditHost,
+ query = "",
+ stripeMap,
+ openFolders,
+ onToggleFolder,
+}: {
+ folder: HostFolder;
+ depth?: number;
+ onOpenTab: (host: Host, type: TabType) => void;
+ onEditHost?: (host: Host) => void;
+ query?: string;
+ stripeMap: Map<Host | HostFolder, number>;
+ openFolders: Set<string>;
+ onToggleFolder: (name: string) => void;
+}) {
+ const { total, online } = folderHostCount(folder);
+
+ if (query && !folderHasMatch(folder, query)) return null;
+
+ const isOpen = query ? true : openFolders.has(folder.name);
+ const stripeIndex = stripeMap.get(folder) ?? 0;
+
+ return (
+ <div>
+ <button
+ onClick={() => !query && onToggleFolder(folder.name)}
+ className={`flex items-center gap-2 w-full px-3 py-2 hover:bg-muted/50 transition-colors text-left cursor-pointer ${stripeIndex % 2 === 1 ? "bg-muted/20" : ""}`}
+ >
+ <ChevronRight
+ className={`size-3 shrink-0 text-muted-foreground/50 transition-transform ${isOpen ? "rotate-90" : ""}`}
+ />
+ <FolderOpen
+ className={`size-3.5 shrink-0 ${isOpen ? "text-accent-brand" : "text-muted-foreground/60"}`}
+ />
+ <span className="text-[13px] font-semibold text-foreground/80 truncate flex-1">
+ {folder.name}
+ </span>
+ <span className="text-[10px] tabular-nums shrink-0 ml-1">
+ {online > 0 && (
+ <span className="text-accent-brand font-semibold">{online}</span>
+ )}
+ <span className="text-muted-foreground/40">/{total}</span>
+ </span>
+ </button>
+ {isOpen && (
+ <div className="border-l border-border/40 ml-[30px]">
+ {folder.children.map((child, i) =>
+ isFolder(child) ? (
+ <FolderItem
+ key={i}
+ folder={child}
+ depth={depth + 1}
+ onOpenTab={onOpenTab}
+ onEditHost={onEditHost}
+ query={query}
+ stripeMap={stripeMap}
+ openFolders={openFolders}
+ onToggleFolder={onToggleFolder}
+ />
+ ) : (
+ <HostItem
+ key={i}
+ host={child}
+ onOpenTab={(t) => onOpenTab(child, t)}
+ onEditHost={onEditHost ? () => onEditHost(child) : undefined}
+ query={query}
+ stripeIndex={stripeMap.get(child) ?? 0}
+ />
+ ),
+ )}
+ </div>
+ )}
+ </div>
+ );
+}
+
+// Top-level tree renderer — owns open state and global stripe index.
+export function SidebarTree({
+ children,
+ onOpenTab,
+ onEditHost,
+ query = "",
+}: {
+ children: (Host | HostFolder)[];
+ onOpenTab: (host: Host, type: TabType) => void;
+ onEditHost: (host: Host) => void;
+ query?: string;
+}) {
+ const [openFolders, setOpenFolders] = useState<Set<string>>(new Set());
+
+ function toggleFolder(name: string) {
+ setOpenFolders((prev) => {
+ const next = new Set(prev);
+ next.has(name) ? next.delete(name) : next.add(name);
+ return next;
+ });
+ }
+
+ const visibleRows = collectVisibleRows(children, query, openFolders);
+ const stripeMap = new Map<Host | HostFolder, number>(
+ visibleRows.map((r, i) => [r, i]),
+ );
+
+ return (
+ <>
+ {children.map((child, i) =>
+ isFolder(child) ? (
+ <FolderItem
+ key={i}
+ folder={child}
+ onOpenTab={onOpenTab}
+ onEditHost={onEditHost}
+ query={query}
+ stripeMap={stripeMap}
+ openFolders={openFolders}
+ onToggleFolder={toggleFolder}
+ />
+ ) : (
+ <HostItem
+ key={i}
+ host={child}
+ onOpenTab={(t) => onOpenTab(child, t)}
+ onEditHost={() => onEditHost(child)}
+ query={query}
+ stripeIndex={stripeMap.get(child) ?? 0}
+ />
+ ),
+ )}
+ </>
+ );
+}
diff --git a/src/ui/sidebar/SnippetsPanel.tsx b/src/ui/sidebar/SnippetsPanel.tsx
new file mode 100644
index 000000000..c193471f0
--- /dev/null
+++ b/src/ui/sidebar/SnippetsPanel.tsx
@@ -0,0 +1,660 @@
+import { useState, useEffect } from "react";
+import { useTranslation } from "react-i18next";
+import {
+ getSnippets,
+ createSnippet as apiCreateSnippet,
+ deleteSnippet as apiDeleteSnippet,
+} from "@/main-axios";
+import { Button } from "@/components/button";
+import { Input } from "@/components/input";
+import { Separator } from "@/components/separator";
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogDescription,
+} from "@/components/dialog";
+import {
+ Box,
+ ChevronDown,
+ Copy,
+ Cpu,
+ Database,
+ Folder,
+ Globe,
+ Network,
+ Pencil,
+ Play,
+ Plus,
+ Search,
+ Server,
+ Settings,
+ Share2,
+ Terminal,
+ Trash2,
+} from "lucide-react";
+import { toast } from "sonner";
+import { FOLDER_COLORS } from "@/lib/theme";
+import { FOLDER_ICONS } from "@/types/ui-types";
+import type {
+ Snippet,
+ SnippetFolder,
+ FolderIconId,
+ Tab,
+} from "@/types/ui-types";
+
+function FolderIconEl({
+ icon,
+ className,
+ style,
+}: {
+ icon: FolderIconId;
+ className?: string;
+ style?: React.CSSProperties;
+}) {
+ const props = { className, style };
+ switch (icon) {
+ case "folder":
+ return <Folder {...props} />;
+ case "server":
+ return <Server {...props} />;
+ case "cloud":
+ return (
+ <div {...props}>
+ <svg
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ className={className}
+ style={style}
+ >
+ <path d="M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z" />
+ </svg>
+ </div>
+ );
+ case "database":
+ return <Database {...props} />;
+ case "box":
+ return <Box {...props} />;
+ case "network":
+ return <Network {...props} />;
+ case "copy":
+ return <Copy {...props} />;
+ case "settings":
+ return <Settings {...props} />;
+ case "cpu":
+ return <Cpu {...props} />;
+ case "globe":
+ return <Globe {...props} />;
+ }
+}
+
+function CreateSnippetDialog({
+ open,
+ onOpenChange,
+ folders,
+ onCreate,
+}: {
+ open: boolean;
+ onOpenChange: (v: boolean) => void;
+ folders: SnippetFolder[];
+ onCreate: (s: Omit<Snippet, "id">) => void;
+}) {
+ const { t } = useTranslation();
+ const [name, setName] = useState("");
+ const [description, setDescription] = useState("");
+ const [folderId, setFolderId] = useState<number | null>(null);
+ const [command, setCommand] = useState("");
+
+ function handleCreate() {
+ if (!name.trim() || !command.trim()) return;
+ onCreate({
+ name: name.trim(),
+ description: description.trim() || undefined,
+ command: command.trim(),
+ folderId,
+ });
+ setName("");
+ setDescription("");
+ setFolderId(null);
+ setCommand("");
+ onOpenChange(false);
+ }
+
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent className="sm:max-w-lg">
+ <DialogHeader>
+ <DialogTitle className="text-lg font-bold">
+ {t("newUi.sidebar.snippets.createSnippetTitle")}
+ </DialogTitle>
+ <DialogDescription className="text-xs text-muted-foreground">
+ {t("newUi.sidebar.snippets.createSnippetDescription")}
+ </DialogDescription>
+ </DialogHeader>
+ <div className="flex flex-col gap-4 mt-1">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-xs font-semibold">
+ {t("newUi.sidebar.snippets.nameLabel")}{" "}
+ <span className="text-accent-brand">*</span>
+ </label>
+ <Input
+ placeholder={t("newUi.sidebar.snippets.namePlaceholder")}
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-xs font-semibold text-muted-foreground">
+ {t("newUi.sidebar.snippets.descriptionLabel")}{" "}
+ <span className="font-normal">
+ ({t("newUi.sidebar.snippets.optional")})
+ </span>
+ </label>
+ <Input
+ placeholder={t("newUi.sidebar.snippets.descriptionPlaceholder")}
+ value={description}
+ onChange={(e) => setDescription(e.target.value)}
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="flex items-center gap-2 text-xs font-semibold text-muted-foreground">
+ <Folder className="size-3.5" />
+ {t("newUi.sidebar.snippets.folderLabel")}{" "}
+ <span className="font-normal">
+ ({t("newUi.sidebar.snippets.optional")})
+ </span>
+ </label>
+ <select
+ value={folderId ?? ""}
+ onChange={(e) =>
+ setFolderId(
+ e.target.value === "" ? null : Number(e.target.value),
+ )
+ }
+ className="px-3 py-2 text-sm bg-background border border-border text-foreground outline-none focus:ring-1 focus:ring-ring"
+ >
+ <option value="">{t("newUi.sidebar.snippets.noFolder")}</option>
+ {folders
+ .filter((f) => f.name !== "Uncategorized")
+ .map((f) => (
+ <option key={f.id} value={f.id}>
+ {f.name}
+ </option>
+ ))}
+ </select>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-xs font-semibold">
+ {t("newUi.sidebar.snippets.commandLabel")}{" "}
+ <span className="text-accent-brand">*</span>
+ </label>
+ <textarea
+ placeholder={t("newUi.sidebar.snippets.commandPlaceholder")}
+ value={command}
+ onChange={(e) => setCommand(e.target.value)}
+ className="w-full h-36 px-3 py-2 text-xs bg-background border border-border text-foreground placeholder:text-muted-foreground resize-none outline-none focus:ring-1 focus:ring-ring font-mono"
+ />
+ </div>
+ </div>
+ <div className="flex items-center justify-end gap-2 mt-2">
+ <Button variant="ghost" onClick={() => onOpenChange(false)}>
+ {t("newUi.sidebar.snippets.cancel")}
+ </Button>
+ <Button
+ variant="outline"
+ className="border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand"
+ onClick={handleCreate}
+ >
+ {t("newUi.sidebar.snippets.createSnippetButton")}
+ </Button>
+ </div>
+ </DialogContent>
+ </Dialog>
+ );
+}
+
+function CreateFolderDialog({
+ open,
+ onOpenChange,
+ onCreate,
+}: {
+ open: boolean;
+ onOpenChange: (v: boolean) => void;
+ onCreate: (f: Omit<SnippetFolder, "id" | "open">) => void;
+}) {
+ const { t } = useTranslation();
+ const [name, setName] = useState("");
+ const [color, setColor] = useState(FOLDER_COLORS[0]);
+ const [icon, setIcon] = useState<FolderIconId>("folder");
+
+ function handleCreate() {
+ if (!name.trim()) return;
+ onCreate({ name: name.trim(), color, icon });
+ setName("");
+ setColor(FOLDER_COLORS[0]);
+ setIcon("folder");
+ onOpenChange(false);
+ }
+
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent className="sm:max-w-md">
+ <DialogHeader>
+ <DialogTitle className="text-lg font-bold">
+ {t("newUi.sidebar.snippets.createFolderTitle")}
+ </DialogTitle>
+ <DialogDescription className="text-xs text-muted-foreground">
+ {t("newUi.sidebar.snippets.createFolderDescription")}
+ </DialogDescription>
+ </DialogHeader>
+ <div className="flex flex-col gap-4 mt-1">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-xs font-semibold">
+ {t("newUi.sidebar.snippets.folderNameLabel")}{" "}
+ <span className="text-accent-brand">*</span>
+ </label>
+ <Input
+ placeholder={t("newUi.sidebar.snippets.folderNamePlaceholder")}
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ />
+ </div>
+ <div className="flex flex-col gap-2">
+ <label className="text-xs font-semibold">
+ {t("newUi.sidebar.snippets.folderColorLabel")}
+ </label>
+ <div className="grid grid-cols-4 gap-2">
+ {FOLDER_COLORS.map((c) => (
+ <button
+ key={c}
+ onClick={() => setColor(c)}
+ className={`h-10 transition-all ${color === c ? "ring-2 ring-offset-2 ring-offset-background ring-white/50" : "opacity-75 hover:opacity-100"}`}
+ style={{ backgroundColor: c }}
+ />
+ ))}
+ </div>
+ </div>
+ <div className="flex flex-col gap-2">
+ <label className="text-xs font-semibold">
+ {t("newUi.sidebar.snippets.folderIconLabel")}
+ </label>
+ <div className="grid grid-cols-5 gap-2">
+ {FOLDER_ICONS.map((ic) => (
+ <button
+ key={ic}
+ onClick={() => setIcon(ic)}
+ className={`flex items-center justify-center h-11 border transition-colors ${
+ icon === ic
+ ? "border-accent-brand/40 bg-accent-brand/10 text-accent-brand"
+ : "border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"
+ }`}
+ >
+ <FolderIconEl icon={ic} className="size-5" />
+ </button>
+ ))}
+ </div>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-xs font-semibold">
+ {t("newUi.sidebar.snippets.previewLabel")}
+ </label>
+ <div className="flex items-center gap-2 px-3 py-3 border border-border bg-muted/20">
+ <FolderIconEl
+ icon={icon}
+ className="size-4 shrink-0"
+ style={{ color }}
+ />
+ <span className="text-sm font-semibold">
+ {name || t("newUi.sidebar.snippets.folderNameFallback")}
+ </span>
+ </div>
+ </div>
+ </div>
+ <div className="flex items-center justify-end gap-2 mt-2">
+ <Button variant="ghost" onClick={() => onOpenChange(false)}>
+ {t("newUi.sidebar.snippets.cancel")}
+ </Button>
+ <Button
+ variant="outline"
+ className="border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand"
+ onClick={handleCreate}
+ >
+ {t("newUi.sidebar.snippets.createFolderButton")}
+ </Button>
+ </div>
+ </DialogContent>
+ </Dialog>
+ );
+}
+
+export function SnippetsPanel({
+ terminalTabs,
+ activeTabId,
+}: {
+ terminalTabs: Tab[];
+ activeTabId: string;
+}) {
+ const { t } = useTranslation();
+ const [snippetSearch, setSnippetSearch] = useState("");
+ const [folders, setFolders] = useState<SnippetFolder[]>([]);
+ const [snippets, setSnippets] = useState<Snippet[]>([]);
+
+ useEffect(() => {
+ getSnippets()
+ .then((data) => {
+ const arr = Array.isArray(data) ? data : [];
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ const mapped: Snippet[] = arr.map((s: any) => ({
+ id: s.id,
+ name: s.name,
+ description: s.description,
+ command: s.command,
+ folderId: s.folderId ?? null,
+ }));
+ setSnippets(mapped);
+ })
+ .catch(() => {});
+ }, []);
+ const [createSnippetOpen, setCreateSnippetOpen] = useState(false);
+ const [createFolderOpen, setCreateFolderOpen] = useState(false);
+ const [selectedTabIds, setSelectedTabIds] = useState<Set<string>>(
+ () =>
+ new Set(
+ activeTabId && terminalTabs.some((t) => t.id === activeTabId)
+ ? [activeTabId]
+ : [],
+ ),
+ );
+
+ function toggleTab(id: string) {
+ setSelectedTabIds((prev) => {
+ const next = new Set(prev);
+ next.has(id) ? next.delete(id) : next.add(id);
+ return next;
+ });
+ }
+
+ async function handleCreateSnippet(s: Omit<Snippet, "id">) {
+ try {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ const created = (await apiCreateSnippet(s as any)) as any;
+ setSnippets((prev) => [
+ ...prev,
+ { ...s, id: created.id ?? Math.max(0, ...prev.map((x) => x.id)) + 1 },
+ ]);
+ toast.success("Snippet created successfully");
+ } catch {
+ toast.error("Failed to create snippet");
+ }
+ }
+
+ function handleCreateFolder(f: Omit<SnippetFolder, "id" | "open">) {
+ const id = Math.max(0, ...folders.map((x) => x.id)) + 1;
+ setFolders((prev) => [...prev, { ...f, id, open: true }]);
+ toast.success("Folder created successfully");
+ }
+
+ function toggleFolder(id: number) {
+ setFolders((prev) =>
+ prev.map((f) => (f.id === id ? { ...f, open: !f.open } : f)),
+ );
+ }
+
+ async function deleteSnippet(id: number) {
+ try {
+ await apiDeleteSnippet(id);
+ setSnippets((prev) => prev.filter((s) => s.id !== id));
+ } catch {
+ toast.error("Failed to delete snippet");
+ }
+ }
+
+ const filtered = snippetSearch
+ ? snippets.filter(
+ (s) =>
+ s.name.toLowerCase().includes(snippetSearch.toLowerCase()) ||
+ s.command.toLowerCase().includes(snippetSearch.toLowerCase()),
+ )
+ : snippets;
+
+ const namedFolders = folders.filter((f) => f.name !== "Uncategorized");
+ const uncategorized = folders.find((f) => f.name === "Uncategorized");
+ const allFolders = [
+ ...namedFolders,
+ ...(uncategorized ? [uncategorized] : []),
+ ];
+
+ return (
+ <>
+ <div className="flex flex-col gap-3 p-3">
+ <div className="flex flex-col gap-1.5">
+ <div className="flex items-center justify-between">
+ <span className="text-xs font-semibold">
+ {t("newUi.sidebar.snippets.targetTerminals")}{" "}
+ <span className="text-muted-foreground font-normal">
+ ({t("newUi.sidebar.snippets.optional")})
+ </span>
+ </span>
+ {terminalTabs.length > 0 && (
+ <div className="flex items-center gap-2">
+ <button
+ onClick={() =>
+ setSelectedTabIds(new Set(terminalTabs.map((t) => t.id)))
+ }
+ className="text-[10px] text-accent-brand hover:text-accent-brand/70"
+ >
+ {t("newUi.sidebar.snippets.selectAll")}
+ </button>
+ <button
+ onClick={() => setSelectedTabIds(new Set())}
+ className="text-[10px] text-accent-brand hover:text-accent-brand/70"
+ >
+ {t("newUi.sidebar.snippets.selectNone")}
+ </button>
+ </div>
+ )}
+ </div>
+ {terminalTabs.length === 0 ? (
+ <div className="flex items-center gap-1.5 px-2.5 py-2 border border-dashed border-border/60 text-muted-foreground/40">
+ <Terminal className="size-3 shrink-0" />
+ <span className="text-xs">
+ {t("newUi.sidebar.snippets.noTerminalTabsOpen")}
+ </span>
+ </div>
+ ) : (
+ <div className="flex flex-col gap-1">
+ {terminalTabs.map((tab) => {
+ const selected = selectedTabIds.has(tab.id);
+ return (
+ <button
+ key={tab.id}
+ onClick={() => toggleTab(tab.id)}
+ className={`flex items-center gap-2 px-2.5 py-1.5 border text-left transition-colors ${
+ selected
+ ? "border-accent-brand/40 bg-accent-brand/10 text-accent-brand"
+ : "border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground/40"
+ }`}
+ >
+ <div
+ className={`size-3 border-2 flex items-center justify-center shrink-0 transition-colors ${
+ selected
+ ? "border-accent-brand bg-accent-brand"
+ : "border-border/60"
+ }`}
+ >
+ {selected && <div className="size-1.5 bg-background" />}
+ </div>
+ <Terminal className="size-3 shrink-0 opacity-60" />
+ <span className="text-xs font-medium truncate flex-1">
+ {tab.label}
+ </span>
+ </button>
+ );
+ })}
+ </div>
+ )}
+ </div>
+ <Separator />
+ <div className="relative">
+ <Search className="absolute left-2.5 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground" />
+ <Input
+ placeholder={t("newUi.sidebar.snippets.searchPlaceholder")}
+ value={snippetSearch}
+ onChange={(e) => setSnippetSearch(e.target.value)}
+ className="pl-8"
+ />
+ </div>
+ <div className="flex gap-2 min-w-0">
+ <Button
+ variant="outline"
+ className="flex-1 text-xs min-w-0 overflow-hidden"
+ onClick={() => setCreateSnippetOpen(true)}
+ >
+ <Plus className="size-3.5 shrink-0" />
+ {t("newUi.sidebar.snippets.newSnippet")}
+ </Button>
+ <Button
+ variant="outline"
+ className="flex-1 text-xs min-w-0 overflow-hidden"
+ onClick={() => setCreateFolderOpen(true)}
+ >
+ <Folder className="size-3.5 shrink-0" />
+ {t("newUi.sidebar.snippets.newFolder")}
+ </Button>
+ </div>
+ <div className="flex flex-col gap-4">
+ {allFolders.map((folder) => {
+ const folderSnippets = filtered.filter((s) =>
+ folder.name === "Uncategorized"
+ ? s.folderId === null || s.folderId === folder.id
+ : s.folderId === folder.id,
+ );
+ if (folderSnippets.length === 0 && snippetSearch) return null;
+ return (
+ <div key={folder.id} className="flex flex-col gap-2">
+ <button
+ onClick={() => toggleFolder(folder.id)}
+ className="flex items-center gap-1.5 w-full text-left"
+ >
+ <ChevronDown
+ className={`size-3 text-muted-foreground shrink-0 transition-transform ${folder.open ? "" : "-rotate-90"}`}
+ />
+ <FolderIconEl
+ icon={folder.icon}
+ className="size-3.5 shrink-0"
+ style={{ color: folder.color }}
+ />
+ <span
+ className="text-xs font-semibold flex-1 truncate"
+ style={{
+ color:
+ folder.name === "Uncategorized"
+ ? undefined
+ : folder.color,
+ }}
+ >
+ {folder.name}
+ </span>
+ <span className="text-xs text-muted-foreground shrink-0">
+ {folderSnippets.length}
+ </span>
+ </button>
+ {folder.open && (
+ <div className="flex flex-col gap-2 ml-1">
+ {folderSnippets.map((snippet) => (
+ <div
+ key={snippet.id}
+ className="border border-border bg-background p-2.5 flex flex-col gap-2"
+ >
+ <div className="flex items-start gap-2">
+ <div className="grid grid-cols-2 gap-px mt-0.5 shrink-0 opacity-30">
+ <div className="size-1 bg-muted-foreground rounded-full" />
+ <div className="size-1 bg-muted-foreground rounded-full" />
+ <div className="size-1 bg-muted-foreground rounded-full" />
+ <div className="size-1 bg-muted-foreground rounded-full" />
+ </div>
+ <div className="flex flex-col min-w-0">
+ <span className="text-xs font-semibold">
+ {snippet.name}
+ </span>
+ {snippet.description && (
+ <span className="text-xs text-muted-foreground">
+ {snippet.description}
+ </span>
+ )}
+ </div>
+ </div>
+ <span className="text-xs text-muted-foreground font-mono px-1">
+ {snippet.command}
+ </span>
+ <div className="flex items-center gap-1">
+ <Button
+ variant="outline"
+ size="sm"
+ className="flex-1 text-xs h-7 gap-1.5"
+ >
+ <Play className="size-3" />
+ {t("newUi.sidebar.snippets.run")}
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-7 text-muted-foreground hover:text-foreground shrink-0"
+ >
+ <Copy className="size-3.5" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-7 text-muted-foreground hover:text-foreground shrink-0"
+ >
+ <Pencil className="size-3.5" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-7 text-muted-foreground hover:text-destructive shrink-0"
+ onClick={() => deleteSnippet(snippet.id)}
+ >
+ <Trash2 className="size-3.5" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-7 text-muted-foreground hover:text-foreground shrink-0"
+ >
+ <Share2 className="size-3.5" />
+ </Button>
+ </div>
+ </div>
+ ))}
+ {folderSnippets.length === 0 && (
+ <span className="text-xs text-muted-foreground/60 pl-1">
+ {t("newUi.sidebar.snippets.noSnippetsInFolder")}
+ </span>
+ )}
+ </div>
+ )}
+ </div>
+ );
+ })}
+ </div>
+ </div>
+
+ <CreateSnippetDialog
+ open={createSnippetOpen}
+ onOpenChange={setCreateSnippetOpen}
+ folders={folders}
+ onCreate={handleCreateSnippet}
+ />
+ <CreateFolderDialog
+ open={createFolderOpen}
+ onOpenChange={setCreateFolderOpen}
+ onCreate={handleCreateFolder}
+ />
+ </>
+ );
+}
diff --git a/src/ui/sidebar/SplitScreenPanel.tsx b/src/ui/sidebar/SplitScreenPanel.tsx
new file mode 100644
index 000000000..115f367ca
--- /dev/null
+++ b/src/ui/sidebar/SplitScreenPanel.tsx
@@ -0,0 +1,275 @@
+import { useState } from "react";
+import { useTranslation } from "react-i18next";
+import { Button } from "@/components/button";
+import { Separator } from "@/components/separator";
+import { LayoutPanelLeft, X } from "lucide-react";
+import { PANE_COUNTS, SPLIT_MODES } from "@/lib/theme";
+import { tabIcon } from "@/shell/tabUtils";
+import type { Tab, SplitMode } from "@/types/ui-types";
+
+const LAYOUT_PREVIEWS: Record<SplitMode, React.ReactNode> = {
+ none: <div className="size-full border-2 border-current" />,
+ "2-way": (
+ <div className="flex gap-0.5 size-full">
+ <div className="flex-1 border-2 border-current" />
+ <div className="flex-1 border-2 border-current" />
+ </div>
+ ),
+ "3-way": (
+ <div className="flex gap-0.5 size-full">
+ <div className="flex-1 border-2 border-current" />
+ <div className="flex flex-col flex-1 gap-0.5">
+ <div className="flex-1 border-2 border-current" />
+ <div className="flex-1 border-2 border-current" />
+ </div>
+ </div>
+ ),
+ "4-way": (
+ <div className="grid grid-cols-2 grid-rows-2 gap-0.5 size-full">
+ <div className="border-2 border-current" />
+ <div className="border-2 border-current" />
+ <div className="border-2 border-current" />
+ <div className="border-2 border-current" />
+ </div>
+ ),
+ "5-way": (
+ <div className="flex flex-col gap-0.5 size-full">
+ <div className="flex gap-0.5 flex-1">
+ <div className="flex-1 border-2 border-current" />
+ <div className="flex-1 border-2 border-current" />
+ <div className="flex-1 border-2 border-current" />
+ </div>
+ <div className="flex gap-0.5 flex-1">
+ <div className="flex-1 border-2 border-current" />
+ <div className="flex-[2] border-2 border-current" />
+ </div>
+ </div>
+ ),
+ "6-way": (
+ <div className="grid grid-cols-3 grid-rows-2 gap-0.5 size-full">
+ <div className="border-2 border-current" />
+ <div className="border-2 border-current" />
+ <div className="border-2 border-current" />
+ <div className="border-2 border-current" />
+ <div className="border-2 border-current" />
+ <div className="border-2 border-current" />
+ </div>
+ ),
+};
+
+export function SplitScreenPanel({
+ tabs,
+ splitMode,
+ setSplitMode,
+ paneTabIds,
+ setPaneTabIds,
+}: {
+ tabs: Tab[];
+ splitMode: SplitMode;
+ setSplitMode: (m: SplitMode) => void;
+ paneTabIds: (string | null)[];
+ setPaneTabIds: (ids: (string | null)[]) => void;
+}) {
+ const { t } = useTranslation();
+ const paneCount = PANE_COUNTS[splitMode];
+ const [draggingTabId, setDraggingTabId] = useState<string | null>(null);
+ const [dragOverPane, setDragOverPane] = useState<number | null>(null);
+
+ function handleDrop(paneIndex: number) {
+ if (draggingTabId === null) return;
+ const next = [...paneTabIds];
+ next[paneIndex] = draggingTabId;
+ setPaneTabIds(next);
+ setDraggingTabId(null);
+ setDragOverPane(null);
+ }
+
+ function clearPane(paneIndex: number) {
+ const next = [...paneTabIds];
+ next[paneIndex] = null;
+ setPaneTabIds(next);
+ }
+
+ function resetAll() {
+ setSplitMode("none");
+ setPaneTabIds(Array(6).fill(null));
+ }
+
+ const activeCount = paneTabIds
+ .slice(0, Math.max(paneCount, 0))
+ .filter(Boolean).length;
+
+ return (
+ <div className="flex flex-col gap-3 p-3">
+ <div className="flex flex-col gap-2">
+ <div className="flex items-center justify-between">
+ <span className="text-xs font-bold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.splitScreen.layoutTitle")}
+ </span>
+ {splitMode !== "none" && (
+ <span className="text-xs border border-accent-brand/40 text-accent-brand px-1.5 py-0.5 leading-tight">
+ {splitMode}
+ </span>
+ )}
+ </div>
+ <div className="grid grid-cols-3 gap-2">
+ {SPLIT_MODES.map((mode) => (
+ <button
+ key={mode.id}
+ onClick={() => setSplitMode(mode.id)}
+ className={`flex flex-col items-center gap-1.5 p-2 border transition-colors ${
+ splitMode === mode.id
+ ? "border-accent-brand/40 bg-accent-brand/10 text-accent-brand"
+ : "border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground/50"
+ }`}
+ >
+ <div
+ className={`w-10 h-7 ${splitMode === mode.id ? "text-accent-brand" : "text-muted-foreground/40"}`}
+ >
+ {LAYOUT_PREVIEWS[mode.id]}
+ </div>
+ <span className="text-xs font-semibold">{mode.label}</span>
+ </button>
+ ))}
+ </div>
+ </div>
+
+ {splitMode === "none" ? (
+ <div className="flex flex-col items-center justify-center gap-2 py-6 text-center border border-dashed border-border">
+ <LayoutPanelLeft className="size-8 text-muted-foreground/30" />
+ <span className="text-sm text-muted-foreground">
+ {t("newUi.sidebar.splitScreen.selectLayoutAbove")}
+ </span>
+ <span className="text-xs text-muted-foreground/60">
+ {t("newUi.sidebar.splitScreen.selectLayoutHint")}
+ </span>
+ </div>
+ ) : (
+ <>
+ <Separator />
+ <div className="flex flex-col gap-2">
+ <div className="flex items-center justify-between">
+ <span className="text-xs font-bold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.splitScreen.panesTitle")}
+ </span>
+ <span className="text-xs text-muted-foreground">
+ {activeCount}/{paneCount} assigned
+ </span>
+ </div>
+ <div className="grid grid-cols-2 gap-1.5">
+ {Array.from({ length: paneCount }).map((_, i) => {
+ const assignedId = paneTabIds[i];
+ const assignedTab = assignedId
+ ? tabs.find((t) => t.id === assignedId)
+ : null;
+ const isOver = dragOverPane === i;
+ return (
+ <div
+ key={i}
+ onDragOver={(e) => {
+ e.preventDefault();
+ setDragOverPane(i);
+ }}
+ onDragLeave={() => setDragOverPane(null)}
+ onDrop={() => handleDrop(i)}
+ className={`relative flex flex-col items-center justify-center gap-1 p-2 min-h-[52px] border transition-colors ${
+ isOver
+ ? "border-accent-brand bg-accent-brand/10"
+ : assignedTab
+ ? "border-border bg-muted/20"
+ : "border-dashed border-border/60 bg-muted/5 hover:border-border hover:bg-muted/10"
+ }`}
+ >
+ <span className="absolute top-1 left-1.5 text-[10px] text-muted-foreground/40 font-mono leading-none">
+ {i + 1}
+ </span>
+ {assignedTab ? (
+ <>
+ <div className="flex items-center gap-1 px-1 w-full justify-center">
+ <span className="text-muted-foreground shrink-0">
+ {tabIcon(assignedTab.type)}
+ </span>
+ <span className="text-xs font-semibold truncate max-w-[70px]">
+ {assignedTab.type === "dashboard"
+ ? t("newUi.sidebar.splitScreen.dashboard")
+ : assignedTab.label}
+ </span>
+ </div>
+ <button
+ onClick={() => clearPane(i)}
+ className="absolute top-0.5 right-0.5 size-4 flex items-center justify-center text-muted-foreground hover:text-foreground"
+ >
+ <X className="size-2.5" />
+ </button>
+ </>
+ ) : (
+ <span className="text-xs text-muted-foreground/40">
+ {isOver
+ ? t("newUi.sidebar.splitScreen.dropHere")
+ : t("newUi.sidebar.splitScreen.emptyPane")}
+ </span>
+ )}
+ </div>
+ );
+ })}
+ </div>
+ </div>
+
+ <Separator />
+
+ <div className="flex flex-col gap-2">
+ <span className="text-xs font-bold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.splitScreen.openTabsTitle")}
+ </span>
+ <span className="text-xs text-muted-foreground/60">
+ {t("newUi.sidebar.splitScreen.dragTabsHint")}
+ </span>
+ <div className="flex flex-col gap-1 mt-0.5">
+ {tabs.map((tab) => (
+ <div
+ key={tab.id}
+ draggable
+ onDragStart={() => setDraggingTabId(tab.id)}
+ onDragEnd={() => {
+ setDraggingTabId(null);
+ setDragOverPane(null);
+ }}
+ className={`flex items-center gap-2 px-2.5 py-2 border cursor-grab active:cursor-grabbing select-none transition-colors ${
+ draggingTabId === tab.id
+ ? "border-accent-brand/40 bg-accent-brand/10 text-accent-brand"
+ : "border-border hover:border-muted-foreground/40 hover:bg-muted/30"
+ }`}
+ >
+ <span className="text-muted-foreground shrink-0">
+ {tabIcon(tab.type)}
+ </span>
+ <span className="text-xs font-medium flex-1 truncate">
+ {tab.type === "dashboard"
+ ? t("newUi.sidebar.splitScreen.dashboard")
+ : tab.label}
+ </span>
+ <div className="grid grid-cols-2 gap-px opacity-30 shrink-0">
+ <div className="size-1 bg-muted-foreground rounded-full" />
+ <div className="size-1 bg-muted-foreground rounded-full" />
+ <div className="size-1 bg-muted-foreground rounded-full" />
+ <div className="size-1 bg-muted-foreground rounded-full" />
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+
+ <Button
+ variant="outline"
+ size="sm"
+ className="w-full text-xs text-muted-foreground"
+ onClick={resetAll}
+ >
+ <X className="size-3" />
+ {t("newUi.sidebar.splitScreen.clearSplitScreen")}
+ </Button>
+ </>
+ )}
+ </div>
+ );
+}
diff --git a/src/ui/sidebar/SshToolsPanel.tsx b/src/ui/sidebar/SshToolsPanel.tsx
new file mode 100644
index 000000000..fdb57812b
--- /dev/null
+++ b/src/ui/sidebar/SshToolsPanel.tsx
@@ -0,0 +1,153 @@
+import { useState } from "react";
+import { useTranslation } from "react-i18next";
+import { Button } from "@/components/button";
+import { Separator } from "@/components/separator";
+import { Terminal } from "lucide-react";
+import type { Tab } from "@/types/ui-types";
+
+export function SshToolsPanel({
+ terminalTabs,
+ activeTabId,
+}: {
+ terminalTabs: Tab[];
+ activeTabId: string;
+}) {
+ const { t } = useTranslation();
+ const [keyRecording, setKeyRecording] = useState(false);
+ const [rightClickPaste, setRightClickPaste] = useState(false);
+ const [selectedTabIds, setSelectedTabIds] = useState<Set<string>>(
+ () =>
+ new Set(
+ activeTabId && terminalTabs.some((t) => t.id === activeTabId)
+ ? [activeTabId]
+ : [],
+ ),
+ );
+
+ function toggleTab(id: string) {
+ setSelectedTabIds((prev) => {
+ const next = new Set(prev);
+ next.has(id) ? next.delete(id) : next.add(id);
+ return next;
+ });
+ }
+
+ function selectAll() {
+ setSelectedTabIds(new Set(terminalTabs.map((t) => t.id)));
+ }
+
+ function deselectAll() {
+ setSelectedTabIds(new Set());
+ }
+
+ return (
+ <div className="flex flex-col gap-3 p-3">
+ <div className="flex flex-col gap-2">
+ <span className="text-xs font-bold uppercase tracking-widest">
+ {t("newUi.sidebar.sshTools.keyRecordingTitle")}
+ </span>
+
+ {/* Terminal selector */}
+ <div className="flex flex-col gap-1">
+ <div className="flex items-center justify-between">
+ <span className="text-xs text-muted-foreground">
+ {t("newUi.sidebar.sshTools.recordToTerminals")}
+ </span>
+ <div className="flex items-center gap-2">
+ <button
+ onClick={selectAll}
+ className="text-[10px] text-accent-brand hover:text-accent-brand/70"
+ >
+ {t("newUi.sidebar.sshTools.selectAll")}
+ </button>
+ <button
+ onClick={deselectAll}
+ className="text-[10px] text-accent-brand hover:text-accent-brand/70"
+ >
+ {t("newUi.sidebar.sshTools.selectNone")}
+ </button>
+ </div>
+ </div>
+
+ {terminalTabs.length === 0 ? (
+ <div className="flex items-center gap-1.5 px-2.5 py-2 border border-dashed border-border/60 text-muted-foreground/40">
+ <Terminal className="size-3 shrink-0" />
+ <span className="text-xs">
+ {t("newUi.sidebar.sshTools.noTerminalTabsOpen")}
+ </span>
+ </div>
+ ) : (
+ <div className="flex flex-col gap-1">
+ {terminalTabs.map((tab) => {
+ const selected = selectedTabIds.has(tab.id);
+ return (
+ <button
+ key={tab.id}
+ onClick={() => toggleTab(tab.id)}
+ className={`flex items-center gap-2 px-2.5 py-1.5 border text-left transition-colors ${
+ selected
+ ? "border-accent-brand/40 bg-accent-brand/10 text-accent-brand"
+ : "border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground/40"
+ }`}
+ >
+ <div
+ className={`size-3 border-2 flex items-center justify-center shrink-0 transition-colors ${
+ selected
+ ? "border-accent-brand bg-accent-brand"
+ : "border-border/60"
+ }`}
+ >
+ {selected && <div className="size-1.5 bg-background" />}
+ </div>
+ <Terminal className="size-3 shrink-0 opacity-60" />
+ <span className="text-xs font-medium truncate flex-1">
+ {tab.label}
+ </span>
+ </button>
+ );
+ })}
+ </div>
+ )}
+ </div>
+
+ <Button
+ variant="outline"
+ disabled={selectedTabIds.size === 0}
+ className={`w-full ${keyRecording ? "border-accent-brand/40 text-accent-brand bg-accent-brand/10 hover:bg-accent-brand/20 hover:text-accent-brand" : ""}`}
+ onClick={() => setKeyRecording((o) => !o)}
+ >
+ {keyRecording
+ ? `Stop Recording (${selectedTabIds.size})`
+ : selectedTabIds.size === 0
+ ? t("newUi.sidebar.sshTools.selectTerminalsAbove")
+ : `Start Recording (${selectedTabIds.size})`}
+ </Button>
+ </div>
+
+ <Separator />
+
+ <div className="flex flex-col gap-2">
+ <span className="text-xs font-bold uppercase tracking-widest">
+ {t("newUi.sidebar.sshTools.settingsTitle")}
+ </span>
+ <div className="flex items-center justify-between gap-4">
+ <span className="text-sm text-muted-foreground">
+ {t("newUi.sidebar.sshTools.enableRightClickCopyPaste")}
+ </span>
+ <button
+ onClick={() => setRightClickPaste((o) => !o)}
+ className={`relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center border-2 transition-colors ${
+ rightClickPaste
+ ? "bg-accent-brand border-accent-brand"
+ : "bg-muted border-border"
+ }`}
+ >
+ <span
+ className={`pointer-events-none inline-block h-3 w-3 bg-background shadow-sm transition-transform ${rightClickPaste ? "translate-x-4" : "translate-x-0.5"}`}
+ />
+ </button>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/src/ui/sidebar/UserProfilePanel.tsx b/src/ui/sidebar/UserProfilePanel.tsx
new file mode 100644
index 000000000..9b58649ee
--- /dev/null
+++ b/src/ui/sidebar/UserProfilePanel.tsx
@@ -0,0 +1,1035 @@
+import { useState, useRef, useEffect } from "react";
+import { useTranslation } from "react-i18next";
+import {
+ getUserInfo,
+ getApiKeys,
+ createApiKey,
+ deleteApiKey,
+ changePassword,
+} from "@/main-axios";
+import type React from "react";
+import { isElectron } from "@/lib/electron";
+import { C2STunnelPresetManager } from "@/user/C2STunnelPresetManager";
+import { Button } from "@/components/button";
+import { Input } from "@/components/input";
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogDescription,
+ DialogFooter,
+} from "@/components/dialog";
+import {
+ Activity,
+ AlertCircle,
+ CheckCircle2,
+ ChevronDown,
+ Copy,
+ Eye,
+ EyeOff,
+ KeyRound,
+ Network,
+ Palette,
+ Plus,
+ Shield,
+ ShieldCheck,
+ Trash2,
+ Type,
+ User,
+ X,
+} from "lucide-react";
+import { SettingRow, FakeSwitch } from "@/components/section-card";
+import {
+ ACCENT_PRESET_COLORS,
+ applyAccentColor,
+ applyFontSize,
+ FONT_SIZES,
+} from "@/lib/theme";
+import type { ApiKey } from "@/main-axios";
+import { useTheme } from "@/components/theme-provider";
+import type { FontSizeId, ThemeId } from "@/types/ui-types";
+import { toast } from "sonner";
+
+type UserProfileSection =
+ | "account"
+ | "appearance"
+ | "security"
+ | "api-keys"
+ | "c2s-tunnels";
+
+const SECTIONS: {
+ id: UserProfileSection;
+ label: string;
+ icon: React.ReactNode;
+}[] = [
+ { id: "account", label: "Account", icon: <User className="size-3.5" /> },
+ {
+ id: "appearance",
+ label: "Appearance",
+ icon: <Palette className="size-3.5" />,
+ },
+ { id: "security", label: "Security", icon: <Shield className="size-3.5" /> },
+ { id: "api-keys", label: "API Keys", icon: <Network className="size-3.5" /> },
+];
+
+const THEMES: { id: ThemeId; label: string; preview: string }[] = [
+ { id: "system", label: "System", preview: "auto" },
+ { id: "light", label: "Light", preview: "#ffffff" },
+ { id: "dark", label: "Dark", preview: "#1a1c22" },
+ { id: "dracula", label: "Dracula", preview: "#282a36" },
+ { id: "catppuccin", label: "Catppuccin", preview: "#1e1e2e" },
+ { id: "nord", label: "Nord", preview: "#2e3440" },
+ { id: "solarized", label: "Solarized", preview: "#002b36" },
+ { id: "tokyo-night", label: "Tokyo Night", preview: "#1a1b26" },
+ { id: "one-dark", label: "One Dark", preview: "#282c34" },
+ { id: "gruvbox", label: "Gruvbox", preview: "#282828" },
+];
+
+function AccordionSection({
+ id,
+ label,
+ icon,
+ open,
+ onToggle,
+ children,
+}: {
+ id: string;
+ label: string;
+ icon: React.ReactNode;
+ open: boolean;
+ onToggle: () => void;
+ children: React.ReactNode;
+}) {
+ return (
+ <div className="border border-border bg-card overflow-hidden">
+ <button
+ onClick={onToggle}
+ className="flex items-center gap-2 w-full px-3 py-2.5 text-left hover:bg-muted/40 transition-colors"
+ >
+ <span className="text-muted-foreground shrink-0">{icon}</span>
+ <span className="text-xs font-bold uppercase tracking-widest text-foreground flex-1">
+ {label}
+ </span>
+ <ChevronDown
+ className={`size-3.5 text-muted-foreground shrink-0 transition-transform duration-150 ${open ? "rotate-180" : ""}`}
+ />
+ </button>
+ {open && (
+ <div className="border-t border-border px-3 pb-3">{children}</div>
+ )}
+ </div>
+ );
+}
+
+function NewApiKeyDialog({
+ open,
+ onOpenChange,
+ onAdd,
+ userId,
+}: {
+ open: boolean;
+ onOpenChange: (v: boolean) => void;
+ onAdd: (key: any) => void;
+ userId: string;
+}) {
+ const { t } = useTranslation();
+ const [name, setName] = useState("");
+ const [expiry, setExpiry] = useState("");
+
+ const handleCreate = async () => {
+ if (!name.trim()) {
+ toast.error("API key name is required");
+ return;
+ }
+ try {
+ const created = await createApiKey(
+ name.trim(),
+ userId,
+ expiry ? new Date(expiry).toISOString() : undefined,
+ );
+ onAdd(created);
+ onOpenChange(false);
+ setName("");
+ setExpiry("");
+ toast.success(`API key "${name}" created`);
+ } catch {
+ toast.error("Failed to create API key");
+ }
+ };
+
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent className="sm:max-w-md rounded-none border-border bg-card p-0 gap-0 overflow-hidden">
+ <DialogHeader className="px-5 pt-5 pb-4 border-b border-border">
+ <div className="flex items-center gap-2.5">
+ <div className="size-8 border border-border bg-muted flex items-center justify-center shrink-0">
+ <Network className="size-3.5 text-accent-brand" />
+ </div>
+ <div>
+ <DialogTitle className="text-base font-bold leading-none">
+ {t("newUi.sidebar.userProfile.createApiKeyTitle")}
+ </DialogTitle>
+ <DialogDescription className="text-xs text-muted-foreground mt-0.5">
+ {t("newUi.sidebar.userProfile.createApiKeyDescription")}
+ </DialogDescription>
+ </div>
+ </div>
+ </DialogHeader>
+
+ <div className="flex flex-col gap-4 px-5 py-4">
+ <div className="flex flex-col gap-1.5">
+ <label className="text-xs font-bold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.userProfile.apiKeyNameLabel")}
+ </label>
+ <Input
+ autoFocus
+ placeholder={t("newUi.sidebar.userProfile.apiKeyNamePlaceholder")}
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ className="rounded-none bg-muted/50 border-border text-sm h-9"
+ />
+ </div>
+
+ <div className="flex flex-col gap-1.5">
+ <label className="text-xs font-bold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.userProfile.expiryDateLabel")}{" "}
+ <span className="text-muted-foreground/50 normal-case font-medium">
+ ({t("newUi.sidebar.userProfile.optional")})
+ </span>
+ </label>
+ <Input
+ type="date"
+ value={expiry}
+ onChange={(e) => setExpiry(e.target.value)}
+ className="rounded-none bg-muted/50 border-border text-sm h-9"
+ />
+ </div>
+ </div>
+
+ <DialogFooter className="px-5 py-3 border-t border-border bg-muted/20">
+ <Button
+ variant="ghost"
+ onClick={() => onOpenChange(false)}
+ className="rounded-none text-[10px] font-bold uppercase tracking-widest"
+ >
+ {t("newUi.sidebar.userProfile.cancel")}
+ </Button>
+ <Button
+ variant="outline"
+ className="border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 rounded-none text-[10px] font-bold uppercase tracking-widest gap-1.5"
+ onClick={handleCreate}
+ >
+ <KeyRound className="size-3" />{" "}
+ {t("newUi.sidebar.userProfile.createKey")}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+}
+
+function PasswordChangeSection({
+ showPassword,
+ setShowPassword,
+ onLogout,
+}: {
+ showPassword: boolean;
+ setShowPassword: (v: boolean | ((prev: boolean) => boolean)) => void;
+ onLogout?: () => void;
+}) {
+ const { t } = useTranslation();
+ const [currentPw, setCurrentPw] = useState("");
+ const [newPw, setNewPw] = useState("");
+ const [confirmPw, setConfirmPw] = useState("");
+
+ async function handleUpdate() {
+ if (!currentPw || !newPw) {
+ toast.error("All password fields are required");
+ return;
+ }
+ if (newPw !== confirmPw) {
+ toast.error("Passwords don't match");
+ return;
+ }
+ try {
+ await changePassword(currentPw, newPw);
+ toast.success("Password updated. Please log in again.");
+ setCurrentPw("");
+ setNewPw("");
+ setConfirmPw("");
+ onLogout?.();
+ } catch (e: any) {
+ toast.error(e?.response?.data?.error || "Failed to update password");
+ }
+ }
+
+ return (
+ <div className="flex flex-col gap-3 border-t border-border pt-3">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.userProfile.changePassword")}
+ </span>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">
+ {t("newUi.sidebar.userProfile.currentPasswordLabel")}
+ </label>
+ <div className="relative">
+ <Input
+ type={showPassword ? "text" : "password"}
+ placeholder={t(
+ "newUi.sidebar.userProfile.currentPasswordPlaceholder",
+ )}
+ value={currentPw}
+ onChange={(e) => setCurrentPw(e.target.value)}
+ className="pr-9 text-sm"
+ />
+ <button
+ onClick={() => setShowPassword((o) => !o)}
+ className="absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
+ >
+ {showPassword ? (
+ <EyeOff className="size-4" />
+ ) : (
+ <Eye className="size-4" />
+ )}
+ </button>
+ </div>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">
+ {t("newUi.sidebar.userProfile.newPasswordLabel")}
+ </label>
+ <Input
+ type="password"
+ placeholder={t("newUi.sidebar.userProfile.newPasswordPlaceholder")}
+ value={newPw}
+ onChange={(e) => setNewPw(e.target.value)}
+ className="text-sm"
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">
+ {t("newUi.sidebar.userProfile.confirmPasswordLabel")}
+ </label>
+ <Input
+ type="password"
+ placeholder={t(
+ "newUi.sidebar.userProfile.confirmPasswordPlaceholder",
+ )}
+ value={confirmPw}
+ onChange={(e) => setConfirmPw(e.target.value)}
+ className="text-sm"
+ />
+ </div>
+ <Button
+ variant="outline"
+ size="sm"
+ className="border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand self-end"
+ onClick={handleUpdate}
+ >
+ <KeyRound className="size-3.5" />
+ {t("newUi.sidebar.userProfile.updatePassword")}
+ </Button>
+ </div>
+ );
+}
+
+export function UserProfilePanel({
+ username,
+ onLogout,
+}: {
+ username?: string;
+ onLogout?: () => void;
+}) {
+ const { t } = useTranslation();
+ const [openSection, setOpenSection] = useState<UserProfileSection | null>(
+ "account",
+ );
+ const [showTotpSetup, setShowTotpSetup] = useState(false);
+ const [totpEnabled, setTotpEnabled] = useState(false);
+ const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
+ const [showPassword, setShowPassword] = useState(false);
+ const [accentColor, setAccentColor] = useState<string>(
+ () => localStorage.getItem("termix-accent") ?? "#f59145",
+ );
+ const [customColorInput, setCustomColorInput] = useState<string>(
+ () => localStorage.getItem("termix-accent") ?? "#f59145",
+ );
+ const [fontSize, setFontSize] = useState<FontSizeId>(
+ () => (localStorage.getItem("termix-font-size") as FontSizeId) ?? "md",
+ );
+ const [apiKeys, setApiKeys] = useState<ApiKey[]>([]);
+ const [userId, setUserId] = useState<string>("");
+
+ useEffect(() => {
+ getUserInfo()
+ .then((info) => {
+ setUserId(info.userId);
+ setTotpEnabled(info.totp_enabled);
+ })
+ .catch(() => {});
+ getApiKeys()
+ .then(({ apiKeys: keys }) => setApiKeys(keys))
+ .catch(() => {});
+ }, []);
+
+ const [newKeyOpen, setNewKeyOpen] = useState(false);
+ const colorInputRef = useRef<HTMLInputElement>(null);
+ const { theme, setTheme } = useTheme();
+
+ function handleAccentChange(value: string) {
+ setAccentColor(value);
+ setCustomColorInput(value);
+ localStorage.setItem("termix-accent", value);
+ applyAccentColor(value);
+ }
+
+ function handleFontSizeChange(id: FontSizeId) {
+ setFontSize(id);
+ applyFontSize(id);
+ }
+
+ function toggle(id: UserProfileSection) {
+ setOpenSection((prev) => (prev === id ? null : id));
+ }
+
+ return (
+ <div className="flex flex-col gap-2 p-3">
+ <NewApiKeyDialog
+ open={newKeyOpen}
+ onOpenChange={setNewKeyOpen}
+ onAdd={(key) => setApiKeys((prev) => [key, ...prev])}
+ userId={userId}
+ />
+
+ {/* Account */}
+ <AccordionSection
+ id="account"
+ label={t("newUi.sidebar.userProfile.sectionAccount")}
+ icon={<User className="size-3.5" />}
+ open={openSection === "account"}
+ onToggle={() => toggle("account")}
+ >
+ <div className="flex flex-col gap-0 pt-2">
+ <div className="grid grid-cols-2 gap-x-4 gap-y-0">
+ <div className="flex flex-col py-2">
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold">
+ {t("newUi.sidebar.userProfile.usernameLabel")}
+ </span>
+ <span className="text-sm font-semibold mt-0.5">
+ {username ?? "user"}
+ </span>
+ </div>
+ <div className="flex flex-col py-2">
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold">
+ {t("newUi.sidebar.userProfile.roleLabel")}
+ </span>
+ <span className="inline-flex items-center px-1.5 py-0.5 text-[10px] font-semibold border border-accent-brand/40 bg-accent-brand/10 text-accent-brand mt-0.5 w-fit">
+ {t("newUi.sidebar.userProfile.roleAdministrator")}
+ </span>
+ </div>
+ <div className="flex flex-col py-2">
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold">
+ {t("newUi.sidebar.userProfile.authMethodLabel")}
+ </span>
+ <span className="text-sm font-semibold mt-0.5">
+ {t("newUi.sidebar.userProfile.authMethodLocal")}
+ </span>
+ </div>
+ <div className="flex flex-col py-2">
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold">
+ {t("newUi.sidebar.userProfile.twoFaLabel")}
+ </span>
+ <span className="flex items-center gap-1 mt-0.5">
+ {totpEnabled ? (
+ <>
+ <ShieldCheck className="size-3.5 text-accent-brand" />
+ <span className="text-sm font-semibold text-accent-brand">
+ {t("newUi.sidebar.userProfile.twoFaOn")}
+ </span>
+ </>
+ ) : (
+ <span className="text-sm font-semibold text-muted-foreground">
+ {t("newUi.sidebar.userProfile.twoFaOff")}
+ </span>
+ )}
+ </span>
+ </div>
+ </div>
+
+ <div className="border-t border-border pt-3 mt-1">
+ <span className="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold">
+ {t("newUi.sidebar.userProfile.versionLabel")}
+ </span>
+ <div className="flex items-center justify-between mt-1.5">
+ <span className="text-sm font-bold text-accent-brand">
+ v1.0.0{" "}
+ <span className="text-muted-foreground font-normal text-xs">
+ {t("newUi.sidebar.userProfile.versionStable")}
+ </span>
+ </span>
+ <span className="flex items-center gap-1 text-xs font-semibold text-accent-brand">
+ <CheckCircle2 className="size-3.5" />
+ {t("newUi.sidebar.userProfile.upToDate")}
+ </span>
+ </div>
+ </div>
+
+ <div className="border-t border-border pt-3 mt-3">
+ <div className="flex items-center justify-between">
+ <div className="flex flex-col gap-0.5">
+ <span className="text-xs font-medium text-destructive">
+ {t("newUi.sidebar.userProfile.deleteAccount")}
+ </span>
+ <span className="text-[10px] text-muted-foreground">
+ {t("newUi.sidebar.userProfile.deleteAccountDescription")}
+ </span>
+ </div>
+ <Button
+ variant="outline"
+ size="sm"
+ className="border-destructive/40 text-destructive hover:bg-destructive/10 hover:text-destructive shrink-0 ml-3 text-[10px] h-7"
+ onClick={() => setShowDeleteConfirm(true)}
+ >
+ {t("newUi.sidebar.userProfile.deleteButton")}
+ </Button>
+ </div>
+ </div>
+ </div>
+ </AccordionSection>
+
+ {/* Appearance */}
+ <AccordionSection
+ id="appearance"
+ label={t("newUi.sidebar.userProfile.sectionAppearance")}
+ icon={<Palette className="size-3.5" />}
+ open={openSection === "appearance"}
+ onToggle={() => toggle("appearance")}
+ >
+ <div className="flex flex-col gap-4 pt-3">
+ <div className="flex flex-col gap-1.5">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.userProfile.languageLabel")}
+ </span>
+ <select className="px-2.5 py-1.5 text-xs bg-background border border-border text-foreground outline-none focus:ring-1 focus:ring-ring w-full">
+ <option>English</option>
+ <option>French</option>
+ <option>German</option>
+ <option>Spanish</option>
+ <option>Japanese</option>
+ <option>Chinese (Simplified)</option>
+ </select>
+ </div>
+
+ {/* Theme — dropdown */}
+ <div className="flex flex-col gap-1.5">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.userProfile.themeLabel")}
+ </span>
+ <div className="relative">
+ <select
+ value={theme}
+ onChange={(e) => setTheme(e.target.value as ThemeId)}
+ className="w-full px-2.5 py-1.5 text-xs bg-background border border-border text-foreground outline-none focus:ring-1 focus:ring-ring appearance-none pr-7"
+ >
+ {THEMES.map((t) => (
+ <option key={t.id} value={t.id}>
+ {t.label}
+ </option>
+ ))}
+ </select>
+ <ChevronDown className="absolute right-2 top-1/2 -translate-y-1/2 size-3 text-muted-foreground pointer-events-none" />
+ </div>
+ {/* Live preview strip */}
+ <div className="flex gap-1 mt-0.5">
+ {THEMES.filter((t) => t.id !== "system").map((t) => (
+ <button
+ key={t.id}
+ title={t.label}
+ onClick={() => setTheme(t.id)}
+ className={`h-4 flex-1 border transition-all ${theme === t.id ? "border-accent-brand ring-1 ring-accent-brand" : "border-border/50"}`}
+ style={{ background: t.preview }}
+ />
+ ))}
+ </div>
+ </div>
+
+ {/* Font Size */}
+ <div className="flex flex-col gap-1.5">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground flex items-center gap-1.5">
+ <Type className="size-3" />
+ {t("newUi.sidebar.userProfile.fontSizeLabel")}
+ </span>
+ <div className="flex gap-1">
+ {FONT_SIZES.map((fs) => (
+ <button
+ key={fs.id}
+ onClick={() => handleFontSizeChange(fs.id)}
+ className={`flex-1 py-1.5 border text-[10px] font-bold transition-colors ${
+ fontSize === fs.id
+ ? "border-accent-brand/40 bg-accent-brand/10 text-accent-brand"
+ : "border-border text-muted-foreground hover:text-foreground"
+ }`}
+ >
+ {fs.label}
+ </button>
+ ))}
+ </div>
+ </div>
+
+ {/* Accent Color */}
+ <div className="flex flex-col gap-2">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.userProfile.accentColorLabel")}
+ </span>
+
+ {/* Preset swatches */}
+ <div className="grid grid-cols-6 gap-1">
+ {ACCENT_PRESET_COLORS.map((ac) => (
+ <button
+ key={ac.value}
+ title={ac.label}
+ onClick={() => handleAccentChange(ac.value)}
+ className={`h-6 border-2 transition-all ${
+ accentColor === ac.value
+ ? "border-foreground scale-110"
+ : "border-transparent hover:border-foreground/40"
+ }`}
+ style={{ background: ac.value }}
+ />
+ ))}
+ </div>
+
+ {/* Custom color input */}
+ <div className="flex items-center gap-2 border border-border bg-muted/30 px-2 py-1.5">
+ <button
+ onClick={() => colorInputRef.current?.click()}
+ className="size-5 shrink-0 border border-border/60 cursor-pointer"
+ style={{ background: accentColor }}
+ title="Open color picker"
+ />
+ <input
+ ref={colorInputRef}
+ type="color"
+ value={accentColor.startsWith("#") ? accentColor : "#f97316"}
+ onChange={(e) => handleAccentChange(e.target.value)}
+ className="sr-only"
+ />
+ <Input
+ value={customColorInput}
+ onChange={(e) => setCustomColorInput(e.target.value)}
+ onBlur={() => {
+ const v = customColorInput.trim();
+ if (
+ /^#[0-9a-fA-F]{6}$/.test(v) ||
+ /^#[0-9a-fA-F]{3}$/.test(v)
+ ) {
+ handleAccentChange(v);
+ } else {
+ setCustomColorInput(accentColor);
+ }
+ }}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ const v = customColorInput.trim();
+ if (
+ /^#[0-9a-fA-F]{6}$/.test(v) ||
+ /^#[0-9a-fA-F]{3}$/.test(v)
+ ) {
+ handleAccentChange(v);
+ }
+ }
+ }}
+ placeholder="#f97316"
+ className="h-6 text-[11px] font-mono border-0 bg-transparent p-0 focus-visible:ring-0 flex-1 min-w-0"
+ />
+ <span className="text-[10px] text-muted-foreground shrink-0">
+ hex
+ </span>
+ </div>
+ </div>
+
+ <div className="flex flex-col gap-1 border-t border-border pt-3">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground mb-1">
+ {t("newUi.sidebar.userProfile.settingsFileManager")}
+ </span>
+ <SettingRow
+ label={t("newUi.sidebar.userProfile.fileColorCoding")}
+ description={t("newUi.sidebar.userProfile.fileColorCodingDesc")}
+ >
+ <FakeSwitch defaultChecked={true} />
+ </SettingRow>
+ </div>
+
+ <div className="flex flex-col gap-1 border-t border-border pt-3">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground mb-1">
+ {t("newUi.sidebar.userProfile.settingsTerminal")}
+ </span>
+ <SettingRow
+ label={t("newUi.sidebar.userProfile.commandAutocomplete")}
+ description={t(
+ "newUi.sidebar.userProfile.commandAutocompleteDesc",
+ )}
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label={t("newUi.sidebar.userProfile.historyTracking")}
+ description={t("newUi.sidebar.userProfile.historyTrackingDesc")}
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label={t("newUi.sidebar.userProfile.syntaxHighlighting")}
+ description={t(
+ "newUi.sidebar.userProfile.syntaxHighlightingDesc",
+ )}
+ badge="BETA"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ <SettingRow
+ label={t("newUi.sidebar.userProfile.commandPalette")}
+ description={t("newUi.sidebar.userProfile.commandPaletteDesc")}
+ >
+ <FakeSwitch defaultChecked={true} />
+ </SettingRow>
+ <SettingRow
+ label={t("newUi.sidebar.userProfile.sessionPersistence")}
+ description={t(
+ "newUi.sidebar.userProfile.sessionPersistenceDesc",
+ )}
+ badge="BETA"
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+
+ <div className="flex flex-col gap-1 border-t border-border pt-3">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground mb-1">
+ {t("newUi.sidebar.userProfile.settingsSidebar")}
+ </span>
+ <SettingRow
+ label={t("newUi.sidebar.userProfile.showHostTags")}
+ description={t("newUi.sidebar.userProfile.showHostTagsDesc")}
+ >
+ <FakeSwitch defaultChecked={true} />
+ </SettingRow>
+ </div>
+
+ <div className="flex flex-col gap-1 border-t border-border pt-3">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground mb-1">
+ {t("newUi.sidebar.userProfile.settingsSnippets")}
+ </span>
+ <SettingRow
+ label={t("newUi.sidebar.userProfile.foldersCollapsed")}
+ description={t("newUi.sidebar.userProfile.foldersCollapsedDesc")}
+ >
+ <FakeSwitch defaultChecked={true} />
+ </SettingRow>
+ <SettingRow
+ label={t("newUi.sidebar.userProfile.confirmExecution")}
+ description={t("newUi.sidebar.userProfile.confirmExecutionDesc")}
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+
+ <div className="flex flex-col gap-1 border-t border-border pt-3">
+ <span className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground mb-1">
+ {t("newUi.sidebar.userProfile.settingsUpdates")}
+ </span>
+ <SettingRow
+ label={t("newUi.sidebar.userProfile.disableUpdateChecks")}
+ description={t(
+ "newUi.sidebar.userProfile.disableUpdateChecksDesc",
+ )}
+ >
+ <FakeSwitch />
+ </SettingRow>
+ </div>
+ </div>
+ </AccordionSection>
+
+ {/* Security */}
+ <AccordionSection
+ id="security"
+ label={t("newUi.sidebar.userProfile.sectionSecurity")}
+ icon={<Shield className="size-3.5" />}
+ open={openSection === "security"}
+ onToggle={() => toggle("security")}
+ >
+ <div className="flex flex-col gap-4 pt-3">
+ <div className="flex flex-col gap-2">
+ <div className="flex items-center justify-between">
+ <div className="flex flex-col gap-0.5">
+ <span className="text-xs font-medium">
+ {t("newUi.sidebar.userProfile.totpAuthenticator")}
+ </span>
+ <span className="text-[10px] text-muted-foreground">
+ {totpEnabled
+ ? t("newUi.sidebar.userProfile.totpEnabled")
+ : t("newUi.sidebar.userProfile.totpDisabled")}
+ </span>
+ </div>
+ <Button
+ variant="outline"
+ size="sm"
+ className={`shrink-0 ml-3 text-[10px] h-7 ${totpEnabled ? "border-destructive/40 text-destructive hover:bg-destructive/10 hover:text-destructive" : "border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand"}`}
+ onClick={() => {
+ if (totpEnabled) setTotpEnabled(false);
+ else setShowTotpSetup(true);
+ }}
+ >
+ {totpEnabled
+ ? t("newUi.sidebar.userProfile.disable")
+ : t("newUi.sidebar.userProfile.enable")}
+ </Button>
+ </div>
+
+ {showTotpSetup && !totpEnabled && (
+ <div className="border border-border bg-muted/20 p-3 flex flex-col gap-3">
+ <div className="flex items-center justify-between">
+ <span className="text-[10px] font-semibold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.userProfile.setupTotp")}
+ </span>
+ <button
+ onClick={() => setShowTotpSetup(false)}
+ className="text-muted-foreground hover:text-foreground"
+ >
+ <X className="size-3.5" />
+ </button>
+ </div>
+ <div className="flex items-center justify-center p-3 bg-background border border-border">
+ <div className="size-24 bg-muted flex items-center justify-center text-[10px] text-muted-foreground">
+ {t("newUi.sidebar.userProfile.qrCode")}
+ </div>
+ </div>
+ <div className="flex items-center gap-2 bg-muted/30 border border-border px-2 py-1.5">
+ <span className="text-[10px] font-mono flex-1 tracking-widest select-all truncate">
+ JBSWY3DPEHPK3PXP
+ </span>
+ <button
+ onClick={() => {
+ navigator.clipboard.writeText("JBSWY3DPEHPK3PXP");
+ toast.info("Secret copied");
+ }}
+ className="text-muted-foreground hover:text-accent-brand shrink-0"
+ >
+ <Copy className="size-3.5" />
+ </button>
+ </div>
+ <span className="text-[10px] text-muted-foreground text-center">
+ {t("newUi.sidebar.userProfile.totpInstructions")}
+ </span>
+ <Input
+ placeholder={t(
+ "newUi.sidebar.userProfile.totpCodePlaceholder",
+ )}
+ className="text-center font-mono tracking-widest text-lg h-10"
+ />
+ <div className="flex gap-2">
+ <Button
+ variant="ghost"
+ size="sm"
+ className="flex-1 text-xs"
+ onClick={() => setShowTotpSetup(false)}
+ >
+ {t("newUi.sidebar.userProfile.cancel")}
+ </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ className="flex-1 text-xs border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 hover:text-accent-brand"
+ onClick={() => {
+ setTotpEnabled(true);
+ setShowTotpSetup(false);
+ toast.success("TOTP enabled successfully");
+ }}
+ >
+ <CheckCircle2 className="size-3.5" />
+ {t("newUi.sidebar.userProfile.verify")}
+ </Button>
+ </div>
+ </div>
+ )}
+ </div>
+
+ <PasswordChangeSection
+ showPassword={showPassword}
+ setShowPassword={setShowPassword}
+ onLogout={onLogout}
+ />
+ </div>
+ </AccordionSection>
+
+ {/* API Keys */}
+ <AccordionSection
+ id="api-keys"
+ label={t("newUi.sidebar.userProfile.sectionApiKeys")}
+ icon={<Network className="size-3.5" />}
+ open={openSection === "api-keys"}
+ onToggle={() => toggle("api-keys")}
+ >
+ <div className="flex flex-col gap-2 pt-3">
+ <div className="flex items-center justify-between">
+ <span className="text-[10px] text-muted-foreground">
+ {t("newUi.sidebar.userProfile.apiKeyCount", {
+ count: apiKeys.length,
+ })}
+ </span>
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-6 text-[10px] font-bold uppercase tracking-widest border-accent-brand/40 text-accent-brand hover:bg-accent-brand/10 gap-1"
+ onClick={() => setNewKeyOpen(true)}
+ >
+ <Plus className="size-3" />{" "}
+ {t("newUi.sidebar.userProfile.newKey")}
+ </Button>
+ </div>
+
+ <div className="flex flex-col divide-y divide-border">
+ {apiKeys.length === 0 ? (
+ <div className="py-6 text-center text-muted-foreground text-xs">
+ {t("newUi.sidebar.userProfile.noApiKeys")}
+ </div>
+ ) : (
+ apiKeys.map((key) => (
+ <div
+ key={key.id}
+ className="flex items-start justify-between py-2.5 gap-2"
+ >
+ <div className="flex flex-col gap-0.5 min-w-0 flex-1">
+ <div className="flex items-center gap-1.5 flex-wrap">
+ <span className="text-xs font-semibold truncate">
+ {key.name}
+ </span>
+ {key.isActive && (
+ <span className="text-[9px] font-bold px-1 py-px border border-accent-brand/40 bg-accent-brand/10 text-accent-brand uppercase shrink-0">
+ {t("newUi.sidebar.userProfile.apiKeyActive")}
+ </span>
+ )}
+ </div>
+ <span className="text-[10px] font-mono text-muted-foreground truncate">
+ {key.tokenPrefix}…
+ </span>
+ <span className="text-[10px] text-muted-foreground">
+ User: {key.username}
+ </span>
+ {key.expiresAt && (
+ <span className="text-[10px] text-muted-foreground">
+ Exp: {new Date(key.expiresAt).toLocaleDateString()}
+ </span>
+ )}
+ </div>
+ <div className="flex items-center gap-0.5 shrink-0">
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-accent-brand"
+ onClick={() => {
+ navigator.clipboard.writeText(
+ key.tokenPrefix + "_demo_token",
+ );
+ toast.info("Token prefix copied");
+ }}
+ >
+ <Copy className="size-3" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-6 text-muted-foreground hover:text-destructive"
+ onClick={async () => {
+ try {
+ await deleteApiKey(key.id);
+ setApiKeys((prev) =>
+ prev.filter((k) => k.id !== key.id),
+ );
+ toast.success(`Revoked "${key.name}"`);
+ } catch {
+ toast.error("Failed to revoke key");
+ }
+ }}
+ >
+ <Trash2 className="size-3" />
+ </Button>
+ </div>
+ </div>
+ ))
+ )}
+ </div>
+
+ <div className="border-t border-border pt-2 text-[10px] text-muted-foreground flex flex-col gap-1">
+ <p>
+ {t("newUi.sidebar.userProfile.apiKeyUsageHint")}{" "}
+ <code className="font-mono text-accent-brand bg-accent-brand/10 px-1">
+ Authorization: Bearer
+ </code>{" "}
+ {t("newUi.sidebar.userProfile.apiKeyUsageHintHeader")}
+ </p>
+ <p>{t("newUi.sidebar.userProfile.apiKeyPermissionsHint")}</p>
+ </div>
+ </div>
+ </AccordionSection>
+
+ {isElectron() && (
+ <AccordionSection
+ id="c2s-tunnels"
+ label={t("newUi.sidebar.userProfile.sectionC2sTunnels")}
+ icon={<Activity className="size-3.5" />}
+ open={openSection === "c2s-tunnels"}
+ onToggle={() => toggle("c2s-tunnels")}
+ >
+ <C2STunnelPresetManager />
+ </AccordionSection>
+ )}
+
+ {/* Delete confirm dialog */}
+ <Dialog open={showDeleteConfirm} onOpenChange={setShowDeleteConfirm}>
+ <DialogContent className="sm:max-w-md">
+ <DialogHeader>
+ <DialogTitle className="text-lg font-bold text-destructive">
+ {t("newUi.sidebar.userProfile.deleteAccount")}
+ </DialogTitle>
+ <DialogDescription className="text-xs text-muted-foreground">
+ {t("newUi.sidebar.userProfile.deleteAccountPermanent")}
+ </DialogDescription>
+ </DialogHeader>
+ <div className="flex flex-col gap-3 mt-1">
+ <div className="flex items-start gap-2.5 border border-destructive/30 bg-destructive/5 px-3 py-2.5">
+ <AlertCircle className="size-4 text-destructive shrink-0 mt-0.5" />
+ <span className="text-xs text-destructive">
+ {t("newUi.sidebar.userProfile.deleteAccountWarning")}
+ </span>
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label className="text-xs font-semibold uppercase tracking-widest text-muted-foreground">
+ {t("newUi.sidebar.userProfile.confirmPasswordLabel")}
+ </label>
+ <Input
+ type="password"
+ placeholder={t(
+ "newUi.sidebar.userProfile.confirmPasswordDeletePlaceholder",
+ )}
+ />
+ </div>
+ </div>
+ <div className="flex items-center justify-end gap-2 mt-2">
+ <Button variant="ghost" onClick={() => setShowDeleteConfirm(false)}>
+ {t("newUi.sidebar.userProfile.cancel")}
+ </Button>
+ <Button
+ variant="outline"
+ className="border-destructive/40 text-destructive hover:bg-destructive/10 hover:text-destructive"
+ >
+ <Trash2 className="size-3.5" />
+ {t("newUi.sidebar.userProfile.deleteAccount")}
+ </Button>
+ </div>
+ </DialogContent>
+ </Dialog>
+ </div>
+ );
+}
diff --git a/src/ui/desktop/navigation/connection-log/ConnectionLog.tsx b/src/ui/ssh/connection-log/ConnectionLog.tsx
similarity index 99%
rename from src/ui/desktop/navigation/connection-log/ConnectionLog.tsx
rename to src/ui/ssh/connection-log/ConnectionLog.tsx
index 0a340df44..057841d52 100644
--- a/src/ui/desktop/navigation/connection-log/ConnectionLog.tsx
+++ b/src/ui/ssh/connection-log/ConnectionLog.tsx
@@ -1,7 +1,7 @@
import React, { useEffect, useRef } from "react";
import { useConnectionLog } from "./ConnectionLogContext.tsx";
import { useTranslation } from "react-i18next";
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import {
ChevronDown,
ChevronUp,
diff --git a/src/ui/desktop/navigation/connection-log/ConnectionLogContext.tsx b/src/ui/ssh/connection-log/ConnectionLogContext.tsx
similarity index 100%
rename from src/ui/desktop/navigation/connection-log/ConnectionLogContext.tsx
rename to src/ui/ssh/connection-log/ConnectionLogContext.tsx
diff --git a/src/ui/desktop/navigation/dialogs/HostKeyVerificationDialog.tsx b/src/ui/ssh/dialogs/HostKeyVerificationDialog.tsx
similarity index 98%
rename from src/ui/desktop/navigation/dialogs/HostKeyVerificationDialog.tsx
rename to src/ui/ssh/dialogs/HostKeyVerificationDialog.tsx
index 88fbb13e6..dee46a80c 100644
--- a/src/ui/desktop/navigation/dialogs/HostKeyVerificationDialog.tsx
+++ b/src/ui/ssh/dialogs/HostKeyVerificationDialog.tsx
@@ -5,9 +5,9 @@ import {
CardDescription,
CardHeader,
CardTitle,
-} from "@/components/ui/card.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
+} from "@/components/card.tsx";
+import { Button } from "@/components/button.tsx";
+import { Alert, AlertDescription, AlertTitle } from "@/components/alert.tsx";
import { Shield, AlertTriangle, Copy, Check } from "lucide-react";
import { useTranslation } from "react-i18next";
diff --git a/src/ui/desktop/navigation/dialogs/OPKSSHDialog.tsx b/src/ui/ssh/dialogs/OPKSSHDialog.tsx
similarity index 98%
rename from src/ui/desktop/navigation/dialogs/OPKSSHDialog.tsx
rename to src/ui/ssh/dialogs/OPKSSHDialog.tsx
index 062f2e71d..c7230c5d0 100644
--- a/src/ui/desktop/navigation/dialogs/OPKSSHDialog.tsx
+++ b/src/ui/ssh/dialogs/OPKSSHDialog.tsx
@@ -1,5 +1,5 @@
import React from "react";
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import { Shield, ExternalLink, Loader2, AlertCircle } from "lucide-react";
import { useTranslation } from "react-i18next";
diff --git a/src/ui/desktop/navigation/dialogs/PassphraseDialog.tsx b/src/ui/ssh/dialogs/PassphraseDialog.tsx
similarity index 93%
rename from src/ui/desktop/navigation/dialogs/PassphraseDialog.tsx
rename to src/ui/ssh/dialogs/PassphraseDialog.tsx
index 3475c5443..98e915a62 100644
--- a/src/ui/desktop/navigation/dialogs/PassphraseDialog.tsx
+++ b/src/ui/ssh/dialogs/PassphraseDialog.tsx
@@ -1,7 +1,7 @@
import React from "react";
-import { Button } from "@/components/ui/button.tsx";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
-import { Label } from "@/components/ui/label.tsx";
+import { Button } from "@/components/button.tsx";
+import { PasswordInput } from "@/components/password-input.tsx";
+import { Label } from "@/components/label.tsx";
import { KeyRound } from "lucide-react";
import { useTranslation } from "react-i18next";
diff --git a/src/ui/desktop/navigation/dialogs/SSHAuthDialog.tsx b/src/ui/ssh/dialogs/SSHAuthDialog.tsx
similarity index 97%
rename from src/ui/desktop/navigation/dialogs/SSHAuthDialog.tsx
rename to src/ui/ssh/dialogs/SSHAuthDialog.tsx
index 5b7c18448..be1bf1ca7 100644
--- a/src/ui/desktop/navigation/dialogs/SSHAuthDialog.tsx
+++ b/src/ui/ssh/dialogs/SSHAuthDialog.tsx
@@ -5,17 +5,17 @@ import {
CardDescription,
CardHeader,
CardTitle,
-} from "@/components/ui/card.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
+} from "@/components/card.tsx";
+import { Button } from "@/components/button.tsx";
+import { PasswordInput } from "@/components/password-input.tsx";
+import { Label } from "@/components/label.tsx";
+import { Alert, AlertDescription, AlertTitle } from "@/components/alert.tsx";
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
-} from "@/components/ui/tabs.tsx";
+} from "@/components/tabs.tsx";
import { Shield, AlertCircle, Upload } from "lucide-react";
import { useTranslation } from "react-i18next";
import CodeMirror from "@uiw/react-codemirror";
diff --git a/src/ui/desktop/navigation/dialogs/TOTPDialog.tsx b/src/ui/ssh/dialogs/TOTPDialog.tsx
similarity index 93%
rename from src/ui/desktop/navigation/dialogs/TOTPDialog.tsx
rename to src/ui/ssh/dialogs/TOTPDialog.tsx
index 602b5dcd2..61227c3d1 100644
--- a/src/ui/desktop/navigation/dialogs/TOTPDialog.tsx
+++ b/src/ui/ssh/dialogs/TOTPDialog.tsx
@@ -1,7 +1,7 @@
import React from "react";
-import { Button } from "@/components/ui/button.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Label } from "@/components/ui/label.tsx";
+import { Button } from "@/components/button.tsx";
+import { Input } from "@/components/input.tsx";
+import { Label } from "@/components/label.tsx";
import { Shield } from "lucide-react";
import { useTranslation } from "react-i18next";
diff --git a/src/ui/desktop/navigation/dialogs/TmuxSessionPicker.tsx b/src/ui/ssh/dialogs/TmuxSessionPicker.tsx
similarity index 98%
rename from src/ui/desktop/navigation/dialogs/TmuxSessionPicker.tsx
rename to src/ui/ssh/dialogs/TmuxSessionPicker.tsx
index 5ee7b0650..b522c6431 100644
--- a/src/ui/desktop/navigation/dialogs/TmuxSessionPicker.tsx
+++ b/src/ui/ssh/dialogs/TmuxSessionPicker.tsx
@@ -1,4 +1,4 @@
-import { Button } from "@/components/ui/button.tsx";
+import { Button } from "@/components/button.tsx";
import { Terminal, Monitor, Users, Clock } from "lucide-react";
import { useTranslation } from "react-i18next";
diff --git a/src/ui/desktop/navigation/dialogs/WarpgateDialog.tsx b/src/ui/ssh/dialogs/WarpgateDialog.tsx
similarity index 95%
rename from src/ui/desktop/navigation/dialogs/WarpgateDialog.tsx
rename to src/ui/ssh/dialogs/WarpgateDialog.tsx
index 9189ed7e2..5fe39a3ef 100644
--- a/src/ui/desktop/navigation/dialogs/WarpgateDialog.tsx
+++ b/src/ui/ssh/dialogs/WarpgateDialog.tsx
@@ -1,7 +1,7 @@
import React, { useState } from "react";
-import { Button } from "@/components/ui/button.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Label } from "@/components/ui/label.tsx";
+import { Button } from "@/components/button.tsx";
+import { Input } from "@/components/input.tsx";
+import { Label } from "@/components/label.tsx";
import { Shield, Copy, ExternalLink } from "lucide-react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
diff --git a/src/types/connection-log.ts b/src/ui/types/connection-log.ts
similarity index 100%
rename from src/types/connection-log.ts
rename to src/ui/types/connection-log.ts
diff --git a/src/types/electron.d.ts b/src/ui/types/electron.d.ts
similarity index 100%
rename from src/types/electron.d.ts
rename to src/ui/types/electron.d.ts
diff --git a/src/types/guacamole-common-js.d.ts b/src/ui/types/guacamole-common-js.d.ts
similarity index 100%
rename from src/types/guacamole-common-js.d.ts
rename to src/ui/types/guacamole-common-js.d.ts
diff --git a/src/types/index.ts b/src/ui/types/index.ts
similarity index 96%
rename from src/types/index.ts
rename to src/ui/types/index.ts
index f39913e53..fa48ef88c 100644
--- a/src/types/index.ts
+++ b/src/ui/types/index.ts
@@ -88,6 +88,27 @@ export interface Host {
ignoreCert?: boolean;
guacamoleConfig?: string | Record<string, unknown>;
+ enableSsh?: boolean;
+ enableRdp?: boolean;
+ enableVnc?: boolean;
+ enableTelnet?: boolean;
+ sshPort?: number;
+ rdpPort?: number;
+ vncPort?: number;
+ telnetPort?: number;
+ rdpUser?: string;
+ rdpPassword?: string;
+ rdpDomain?: string;
+ rdpSecurity?: string;
+ rdpIgnoreCert?: boolean;
+ vncPassword?: string;
+ vncUser?: string;
+ telnetUser?: string;
+ telnetPassword?: string;
+ hasRdpPassword?: boolean;
+ hasVncPassword?: boolean;
+ hasTelnetPassword?: boolean;
+
createdAt: string;
updatedAt: string;
@@ -171,6 +192,24 @@ export interface HostData {
ignoreCert?: boolean;
guacamoleConfig?: Record<string, unknown> | null;
dockerConfig?: Record<string, unknown> | null;
+
+ enableSsh?: boolean;
+ enableRdp?: boolean;
+ enableVnc?: boolean;
+ enableTelnet?: boolean;
+ sshPort?: number;
+ rdpPort?: number;
+ vncPort?: number;
+ telnetPort?: number;
+ rdpUser?: string;
+ rdpPassword?: string;
+ rdpDomain?: string;
+ rdpSecurity?: string;
+ rdpIgnoreCert?: boolean;
+ vncPassword?: string;
+ vncUser?: string;
+ telnetUser?: string;
+ telnetPassword?: string;
}
export type SSHHost = Host;
diff --git a/src/types/stats-widgets.ts b/src/ui/types/stats-widgets.ts
similarity index 97%
rename from src/types/stats-widgets.ts
rename to src/ui/types/stats-widgets.ts
index b355a4a84..4ea351dd2 100644
--- a/src/types/stats-widgets.ts
+++ b/src/ui/types/stats-widgets.ts
@@ -69,6 +69,9 @@ export const DEFAULT_STATS_CONFIG: StatsConfig = {
"uptime",
"system",
"login_stats",
+ "processes",
+ "ports",
+ "firewall",
],
statusCheckEnabled: true,
statusCheckInterval: 30,
diff --git a/src/ui/types/ui-types.ts b/src/ui/types/ui-types.ts
new file mode 100644
index 000000000..f8d3cad5b
--- /dev/null
+++ b/src/ui/types/ui-types.ts
@@ -0,0 +1,307 @@
+export type Host = {
+ id: string;
+ name: string;
+ username: string;
+ ip: string;
+ port: number;
+ folder: string;
+ online: boolean;
+ cpu: number;
+ ram: number;
+ lastAccess: string;
+ tags?: string[];
+ authType: "password" | "key" | "credential" | "none" | "opkssh";
+ credentialId?: string;
+ password?: string;
+ key?: string;
+ keyPassword?: string;
+ keyType?: string;
+ notes?: string;
+ macAddress?: string;
+ pin?: boolean;
+
+ enableTerminal: boolean;
+ terminalConfig?: {
+ cursorBlink: boolean;
+ cursorStyle: "block" | "underline" | "bar";
+ fontSize: number;
+ fontFamily: string;
+ letterSpacing: number;
+ lineHeight: number;
+ theme: string;
+ scrollback: number;
+ bellStyle: "none" | "sound" | "visual" | "both";
+ rightClickSelectsWord: boolean;
+ fastScrollModifier: "alt" | "ctrl" | "shift";
+ fastScrollSensitivity: number;
+ minimumContrastRatio: number;
+ backspaceMode: "normal" | "control-h";
+ agentForwarding: boolean;
+ autoMosh: boolean;
+ moshCommand: string;
+ autoTmux: boolean;
+ sudoPasswordAutoFill: boolean;
+ sudoPassword?: string;
+ keepaliveInterval?: number;
+ keepaliveCountMax?: number;
+ environmentVariables: { key: string; value: string }[];
+ };
+
+ useSocks5?: boolean;
+ socks5Host?: string;
+ socks5Port?: number;
+ socks5Username?: string;
+ socks5Password?: string;
+ socks5ProxyChain?: {
+ host: string;
+ port: number;
+ type: 4 | 5 | "http";
+ username?: string;
+ password?: string;
+ }[];
+ jumpHosts?: { hostId: string }[];
+ portKnockSequence?: {
+ port: number;
+ protocol: "tcp" | "udp";
+ delay: number;
+ }[];
+
+ enableTunnel: boolean;
+ serverTunnels: {
+ mode: "local" | "remote" | "dynamic";
+ bindHost?: string;
+ targetHost?: string;
+ sourcePort: number;
+ endpointHost: string;
+ endpointPort: number;
+ maxRetries: number;
+ retryInterval: number;
+ autoStart: boolean;
+ }[];
+
+ enableFileManager: boolean;
+ defaultPath?: string;
+
+ enableDocker: boolean;
+
+ statsConfig?: {
+ statusCheckEnabled: boolean;
+ statusCheckInterval: number;
+ useGlobalStatusInterval: boolean;
+ metricsEnabled: boolean;
+ metricsInterval: number;
+ useGlobalMetricsInterval: boolean;
+ enabledWidgets: string[];
+ };
+ quickActions: { name: string; snippetId: string }[];
+
+ enableSsh: boolean;
+ enableRdp: boolean;
+ enableVnc: boolean;
+ enableTelnet: boolean;
+
+ sshPort: number;
+ rdpPort: number;
+ vncPort: number;
+ telnetPort: number;
+
+ rdpUser?: string;
+ rdpPassword?: string;
+ domain?: string;
+ security?: string;
+ ignoreCert?: boolean;
+
+ vncPassword?: string;
+ vncUser?: string;
+
+ telnetUser?: string;
+ telnetPassword?: string;
+
+ guacamoleConfig?: Record<string, any>;
+};
+
+export type Credential = {
+ id: string;
+ name: string;
+ username: string;
+ type: "password" | "key";
+ value?: string;
+ publicKey?: string;
+ passphrase?: string;
+ description?: string;
+ folder?: string;
+ tags?: string[];
+};
+
+export type HostFolder = {
+ name: string;
+ children: (Host | HostFolder)[];
+};
+
+export type TabType =
+ | "dashboard"
+ | "terminal"
+ | "rdp"
+ | "vnc"
+ | "telnet"
+ | "stats"
+ | "files"
+ | "host-manager"
+ | "user-profile"
+ | "admin-settings"
+ | "docker"
+ | "tunnel";
+
+export type TunnelStatusValue =
+ | "CONNECTED"
+ | "CONNECTING"
+ | "DISCONNECTING"
+ | "DISCONNECTED"
+ | "ERROR"
+ | "WAITING";
+export type TunnelMode = "local" | "remote" | "dynamic";
+
+export type Tunnel = {
+ id: string;
+ hostId: string;
+ sourcePort: number;
+ endpointHost: string;
+ endpointPort: number;
+ status: TunnelStatusValue;
+ mode: TunnelMode;
+ reason?: string;
+ retryCount?: number;
+ maxRetries?: number;
+};
+
+export type Tab = {
+ id: string;
+ type: TabType;
+ label: string;
+ host?: Host;
+};
+
+export type DockerContainerStatus =
+ | "running"
+ | "exited"
+ | "paused"
+ | "created"
+ | "restarting";
+
+export type DockerContainer = {
+ id: string;
+ name: string;
+ image: string;
+ status: DockerContainerStatus;
+ cpu: number;
+ memory: string;
+ ports: string[];
+ created: string;
+};
+
+export type DashboardCardId =
+ | "stats_bar"
+ | "counters_bar"
+ | "quick_actions"
+ | "host_status"
+ | "recent_activity"
+ | "network_graph";
+
+export type DashboardCardConfig = {
+ id: DashboardCardId;
+ label: string;
+ description: string;
+ defaultEnabled: boolean;
+};
+
+export type CardColSpan = "full" | "wide" | "half" | "narrow";
+export type CardRowSize = "short" | "medium" | "tall" | "flex";
+
+export type CardLayoutConfig = {
+ id: DashboardCardId;
+ colSpan: CardColSpan;
+ rowSize: CardRowSize;
+ order: number;
+};
+
+export type LayoutPresetId = "default" | "compact" | "focus" | "wide";
+
+export type LayoutPreset = {
+ id: LayoutPresetId;
+ label: string;
+ description: string;
+ cards: CardLayoutConfig[];
+};
+
+export type UserProfileSection =
+ | "account"
+ | "appearance"
+ | "security"
+ | "api-keys";
+export type AdminSection =
+ | "general"
+ | "oidc"
+ | "users"
+ | "sessions"
+ | "roles"
+ | "database"
+ | "api-keys";
+export type AccentColorId = string;
+export type ThemeId =
+ | "dark"
+ | "light"
+ | "system"
+ | "dracula"
+ | "catppuccin"
+ | "nord"
+ | "solarized"
+ | "tokyo-night"
+ | "one-dark"
+ | "gruvbox";
+export type FontSizeId = "xs" | "sm" | "md" | "lg" | "xl";
+
+export type ToolsTab = "ssh-tools" | "snippets" | "history" | "split-screen";
+export type SplitMode =
+ | "none"
+ | "2-way"
+ | "3-way"
+ | "4-way"
+ | "5-way"
+ | "6-way";
+
+export type Snippet = {
+ id: number;
+ name: string;
+ description?: string;
+ command: string;
+ folderId: number | null;
+};
+
+export const FOLDER_ICONS = [
+ "folder",
+ "server",
+ "cloud",
+ "database",
+ "box",
+ "network",
+ "copy",
+ "settings",
+ "cpu",
+ "globe",
+] as const;
+export type FolderIconId = (typeof FOLDER_ICONS)[number];
+
+export type SnippetFolder = {
+ id: number;
+ name: string;
+ color: string;
+ icon: FolderIconId;
+ open: boolean;
+};
+
+export type HistoryEntry = {
+ id: number;
+ command: string;
+ host: string;
+ time: string;
+};
diff --git a/src/ui/desktop/user/C2STunnelPresetManager.tsx b/src/ui/user/C2STunnelPresetManager.tsx
similarity index 98%
rename from src/ui/desktop/user/C2STunnelPresetManager.tsx
rename to src/ui/user/C2STunnelPresetManager.tsx
index 4f68811af..6ddc138cb 100644
--- a/src/ui/desktop/user/C2STunnelPresetManager.tsx
+++ b/src/ui/user/C2STunnelPresetManager.tsx
@@ -1,29 +1,29 @@
import React from "react";
-import { Button } from "@/components/ui/button.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { Label } from "@/components/ui/label.tsx";
+import { Button } from "@/components/button.tsx";
+import { Input } from "@/components/input.tsx";
+import { Label } from "@/components/label.tsx";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
-} from "@/components/ui/select.tsx";
-import { Switch } from "@/components/ui/switch.tsx";
-import { TunnelInlineControls } from "@/ui/desktop/apps/features/tunnel/TunnelInlineControls.tsx";
-import { TunnelModeSelector } from "@/ui/desktop/apps/features/tunnel/TunnelModeSelector.tsx";
+} from "@/components/select.tsx";
+import { Switch } from "@/components/switch.tsx";
+import { TunnelInlineControls } from "@/features/tunnel/TunnelInlineControls.tsx";
+import { TunnelModeSelector } from "@/features/tunnel/TunnelModeSelector.tsx";
import {
getTunnelModeDescription,
getTunnelPortLabels,
getTunnelTypeForMode,
-} from "@/ui/desktop/apps/features/tunnel/tunnel-form-utils.ts";
+} from "@/features/tunnel/tunnel-form-utils.ts";
import {
createC2STunnelPreset,
deleteC2STunnelPreset,
getC2STunnelPresets,
getSSHHosts,
updateC2STunnelPreset,
-} from "@/ui/main-axios.ts";
+} from "@/main-axios.ts";
import type {
C2STunnelPreset,
SSHHost,
diff --git a/src/ui/desktop/user/ElectronVersionCheck.tsx b/src/ui/user/ElectronVersionCheck.tsx
similarity index 97%
rename from src/ui/desktop/user/ElectronVersionCheck.tsx
rename to src/ui/user/ElectronVersionCheck.tsx
index 947d304a7..57cb78b52 100644
--- a/src/ui/desktop/user/ElectronVersionCheck.tsx
+++ b/src/ui/user/ElectronVersionCheck.tsx
@@ -1,9 +1,9 @@
import React, { useState, useEffect } from "react";
-import { Button } from "@/components/ui/button.tsx";
-import { VersionAlert } from "@/components/ui/version-alert.tsx";
+import { Button } from "@/components/button.tsx";
+import { VersionAlert } from "@/components/version-alert.tsx";
import { useTranslation } from "react-i18next";
import { isElectron } from "@/lib/electron";
-import { checkElectronUpdate } from "@/ui/main-axios.ts";
+import { checkElectronUpdate } from "@/main-axios.ts";
import { useTheme } from "@/components/theme-provider";
interface VersionCheckModalProps {
diff --git a/src/ui/desktop/user/LanguageSwitcher.tsx b/src/ui/user/LanguageSwitcher.tsx
similarity index 98%
rename from src/ui/desktop/user/LanguageSwitcher.tsx
rename to src/ui/user/LanguageSwitcher.tsx
index cad82edc3..4e1d9aed2 100644
--- a/src/ui/desktop/user/LanguageSwitcher.tsx
+++ b/src/ui/user/LanguageSwitcher.tsx
@@ -6,7 +6,7 @@ import {
SelectItem,
SelectTrigger,
SelectValue,
-} from "@/components/ui/select.tsx";
+} from "@/components/select.tsx";
import { Globe } from "lucide-react";
const languages = [
diff --git a/src/ui/desktop/user/PasswordReset.tsx b/src/ui/user/PasswordReset.tsx
similarity index 94%
rename from src/ui/desktop/user/PasswordReset.tsx
rename to src/ui/user/PasswordReset.tsx
index c53e33fe8..3ddfd1bd0 100644
--- a/src/ui/desktop/user/PasswordReset.tsx
+++ b/src/ui/user/PasswordReset.tsx
@@ -4,14 +4,14 @@ import {
CardDescription,
CardHeader,
CardTitle,
-} from "@/components/ui/card.tsx";
+} from "@/components/card.tsx";
import { Key } from "lucide-react";
import React, { useState } from "react";
-import { changePassword } from "@/ui/main-axios.ts";
-import { Label } from "@/components/ui/label.tsx";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
+import { changePassword } from "@/main-axios.ts";
+import { Label } from "@/components/label.tsx";
+import { PasswordInput } from "@/components/password-input.tsx";
+import { Button } from "@/components/button.tsx";
+import { Alert, AlertDescription, AlertTitle } from "@/components/alert.tsx";
import { toast } from "sonner";
import { useTranslation } from "react-i18next";
diff --git a/src/ui/desktop/user/TOTPSetup.tsx b/src/ui/user/TOTPSetup.tsx
similarity index 97%
rename from src/ui/desktop/user/TOTPSetup.tsx
rename to src/ui/user/TOTPSetup.tsx
index 3a65efe22..c67047482 100644
--- a/src/ui/desktop/user/TOTPSetup.tsx
+++ b/src/ui/user/TOTPSetup.tsx
@@ -5,18 +5,18 @@ import {
CardDescription,
CardHeader,
CardTitle,
-} from "@/components/ui/card.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { Input } from "@/components/ui/input.tsx";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
-import { Label } from "@/components/ui/label.tsx";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
+} from "@/components/card.tsx";
+import { Button } from "@/components/button.tsx";
+import { Input } from "@/components/input.tsx";
+import { PasswordInput } from "@/components/password-input.tsx";
+import { Label } from "@/components/label.tsx";
+import { Alert, AlertDescription, AlertTitle } from "@/components/alert.tsx";
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
-} from "@/components/ui/tabs.tsx";
+} from "@/components/tabs.tsx";
import {
Shield,
Copy,
@@ -29,7 +29,7 @@ import {
enableTOTP,
disableTOTP,
generateBackupCodes,
-} from "@/ui/main-axios.ts";
+} from "@/main-axios.ts";
import { toast } from "sonner";
import { useTranslation } from "react-i18next";
diff --git a/src/ui/desktop/user/UserProfile.tsx b/src/ui/user/UserProfile.tsx
similarity index 78%
rename from src/ui/desktop/user/UserProfile.tsx
rename to src/ui/user/UserProfile.tsx
index 66bd4c489..185633c2d 100644
--- a/src/ui/desktop/user/UserProfile.tsx
+++ b/src/ui/user/UserProfile.tsx
@@ -1,23 +1,23 @@
import React, { useState, useEffect } from "react";
-import { Label } from "@/components/ui/label.tsx";
-import { Button } from "@/components/ui/button.tsx";
-import { PasswordInput } from "@/components/ui/password-input.tsx";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
+import { Label } from "@/components/label.tsx";
+import { Button } from "@/components/button.tsx";
+import { PasswordInput } from "@/components/password-input.tsx";
+import { Alert, AlertDescription, AlertTitle } from "@/components/alert.tsx";
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
-} from "@/components/ui/tabs.tsx";
-import { Separator } from "@/components/ui/separator.tsx";
-import { Switch } from "@/components/ui/switch.tsx";
+} from "@/components/tabs.tsx";
+import { Separator } from "@/components/separator.tsx";
+import { Switch } from "@/components/switch.tsx";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
-} from "@/components/ui/select.tsx";
+} from "@/components/select.tsx";
import {
User,
Shield,
@@ -27,9 +27,17 @@ import {
Moon,
Monitor,
Network,
+ Type,
} from "lucide-react";
+import {
+ ACCENT_PRESET_COLORS,
+ applyAccentColor,
+ applyFontSize,
+ FONT_SIZES,
+} from "@/lib/theme";
+import type { FontSizeId, ThemeId } from "@/types/ui-types";
import { useTheme } from "@/components/theme-provider";
-import { TOTPSetup } from "@/ui/desktop/user/TOTPSetup.tsx";
+import { TOTPSetup } from "@/user/TOTPSetup.tsx";
import {
getUserInfo,
getVersionInfo,
@@ -38,14 +46,14 @@ import {
isElectron,
getUserRoles,
type UserRole,
-} from "@/ui/main-axios.ts";
-import { PasswordReset } from "@/ui/desktop/user/PasswordReset.tsx";
+} from "@/main-axios.ts";
+import { PasswordReset } from "@/user/PasswordReset.tsx";
import { useTranslation } from "react-i18next";
-import { LanguageSwitcher } from "@/ui/desktop/user/LanguageSwitcher.tsx";
-import { useSidebar } from "@/components/ui/sidebar.tsx";
+import { LanguageSwitcher } from "@/user/LanguageSwitcher.tsx";
+import { useSidebar } from "@/components/sidebar.tsx";
import { toast } from "sonner";
-import { C2STunnelPresetManager } from "@/ui/desktop/user/C2STunnelPresetManager.tsx";
-import { SimpleLoader } from "@/ui/desktop/navigation/animations/SimpleLoader.tsx";
+import { C2STunnelPresetManager } from "@/user/C2STunnelPresetManager.tsx";
+import { SimpleLoader } from "@/lib/SimpleLoader.tsx";
interface UserProfileProps {
isTopbarOpen?: boolean;
@@ -147,6 +155,14 @@ export function UserProfile({
const saved = localStorage.getItem("commandPaletteShortcutEnabled");
return saved !== null ? saved === "true" : true;
});
+ const [accentColor, setAccentColor] = useState<string>(
+ () => localStorage.getItem("termix-accent") ?? "#f59145",
+ );
+ const [fontSize, setFontSize] = useState<FontSizeId>(
+ () => (localStorage.getItem("termix-font-size") as FontSizeId) ?? "md",
+ );
+ const [customAccentColor, setCustomAccentColor] =
+ useState<string>(accentColor);
const [confirmSnippetExecution, setConfirmSnippetExecution] =
useState<boolean>(() => {
const saved = localStorage.getItem("confirmSnippetExecution");
@@ -527,7 +543,8 @@ export function UserProfile({
<h3 className="text-lg font-semibold mb-4">
{t("profile.appearance")}
</h3>
- <div className="space-y-4">
+ <div className="space-y-6">
+ {/* Theme selector */}
<div className="flex items-center justify-between">
<div>
<Label className="text-foreground-secondary">
@@ -537,85 +554,174 @@ export function UserProfile({
{t("profile.appearanceDesc")}
</p>
</div>
- <Select value={theme} onValueChange={setTheme}>
- <SelectTrigger className="w-[140px]">
+ <Select
+ value={theme}
+ onValueChange={(v) => setTheme(v as ThemeId)}
+ >
+ <SelectTrigger className="w-[160px]">
<SelectValue />
</SelectTrigger>
<SelectContent
onMouseLeave={() => setThemePreview(null)}
>
- <SelectItem
- value="light"
- onMouseEnter={() => setThemePreview("light")}
- >
- <div className="flex items-center gap-2">
- <Sun className="w-4 h-4" />
- {t("profile.themeLight")}
- </div>
- </SelectItem>
- <SelectItem
- value="dark"
- onMouseEnter={() => setThemePreview("dark")}
- >
- <div className="flex items-center gap-2">
- <Moon className="w-4 h-4" />
- {t("profile.themeDark")}
- </div>
- </SelectItem>
- <SelectItem
- value="dracula"
- onMouseEnter={() => setThemePreview("dracula")}
- >
- <div className="flex items-center gap-2">
- <Palette className="w-4 h-4" />
- Dracula
- </div>
- </SelectItem>
- <SelectItem
- value="gentlemansChoice"
- onMouseEnter={() =>
- setThemePreview("gentlemansChoice")
- }
- >
- <div className="flex items-center gap-2">
- <Palette className="w-4 h-4" />
- Gentleman's Choice
- </div>
- </SelectItem>
- <SelectItem
- value="midnightEspresso"
- onMouseEnter={() =>
- setThemePreview("midnightEspresso")
- }
- >
- <div className="flex items-center gap-2">
- <Palette className="w-4 h-4" />
- Midnight Espresso
- </div>
- </SelectItem>
- <SelectItem
- value="catppuccinMocha"
- onMouseEnter={() =>
- setThemePreview("catppuccinMocha")
- }
- >
- <div className="flex items-center gap-2">
- <Palette className="w-4 h-4" />
- Catppuccin Mocha
- </div>
- </SelectItem>
- <SelectItem
- value="system"
- onMouseEnter={() => setThemePreview("system")}
- >
- <div className="flex items-center gap-2">
- <Monitor className="w-4 h-4" />
- {t("profile.themeSystem")}
- </div>
- </SelectItem>
+ {(
+ [
+ {
+ id: "system",
+ label: t("profile.themeSystem"),
+ icon: <Monitor className="w-4 h-4" />,
+ },
+ {
+ id: "light",
+ label: t("profile.themeLight"),
+ icon: <Sun className="w-4 h-4" />,
+ },
+ {
+ id: "dark",
+ label: t("profile.themeDark"),
+ icon: <Moon className="w-4 h-4" />,
+ },
+ {
+ id: "dracula",
+ label: "Dracula",
+ icon: <Palette className="w-4 h-4" />,
+ },
+ {
+ id: "catppuccin",
+ label: "Catppuccin",
+ icon: <Palette className="w-4 h-4" />,
+ },
+ {
+ id: "nord",
+ label: "Nord",
+ icon: <Palette className="w-4 h-4" />,
+ },
+ {
+ id: "solarized",
+ label: "Solarized",
+ icon: <Palette className="w-4 h-4" />,
+ },
+ {
+ id: "tokyo-night",
+ label: "Tokyo Night",
+ icon: <Palette className="w-4 h-4" />,
+ },
+ {
+ id: "one-dark",
+ label: "One Dark",
+ icon: <Palette className="w-4 h-4" />,
+ },
+ {
+ id: "gruvbox",
+ label: "Gruvbox",
+ icon: <Palette className="w-4 h-4" />,
+ },
+ ] as {
+ id: ThemeId;
+ label: string;
+ icon: React.ReactNode;
+ }[]
+ ).map(({ id, label, icon }) => (
+ <SelectItem
+ key={id}
+ value={id}
+ onMouseEnter={() => setThemePreview(id)}
+ >
+ <div className="flex items-center gap-2">
+ {icon}
+ {label}
+ </div>
+ </SelectItem>
+ ))}
</SelectContent>
</Select>
</div>
+
+ {/* Accent color */}
+ <div>
+ <Label className="text-foreground-secondary mb-2 block">
+ {t("profile.accentColor")}
+ </Label>
+ <div className="flex flex-wrap gap-2 mb-3">
+ {ACCENT_PRESET_COLORS.map((c) => (
+ <button
+ key={c.value}
+ title={c.label}
+ onClick={() => {
+ setAccentColor(c.value);
+ setCustomAccentColor(c.value);
+ localStorage.setItem("termix-accent", c.value);
+ applyAccentColor(c.value);
+ }}
+ className="w-7 h-7 rounded-full border-2 transition-transform hover:scale-110"
+ style={{
+ backgroundColor: c.value,
+ borderColor:
+ accentColor === c.value
+ ? "white"
+ : "transparent",
+ boxShadow:
+ accentColor === c.value
+ ? `0 0 0 1px ${c.value}`
+ : undefined,
+ }}
+ />
+ ))}
+ </div>
+ <div className="flex items-center gap-2">
+ <Label className="text-sm text-muted-foreground shrink-0">
+ {t("profile.customColor")}
+ </Label>
+ <input
+ type="color"
+ value={customAccentColor}
+ onChange={(e) => {
+ setCustomAccentColor(e.target.value);
+ }}
+ onBlur={(e) => {
+ const val = e.target.value;
+ setAccentColor(val);
+ localStorage.setItem("termix-accent", val);
+ applyAccentColor(val);
+ }}
+ className="w-8 h-8 rounded cursor-pointer border border-edge bg-transparent"
+ />
+ <span className="text-sm text-muted-foreground font-mono">
+ {customAccentColor}
+ </span>
+ </div>
+ </div>
+
+ {/* Font size */}
+ <div className="flex items-center justify-between">
+ <div>
+ <Label className="text-foreground-secondary flex items-center gap-2">
+ <Type className="w-4 h-4" />
+ {t("profile.fontSize")}
+ </Label>
+ <p className="text-sm text-muted-foreground mt-1">
+ {t("profile.fontSizeDesc")}
+ </p>
+ </div>
+ <div className="flex gap-1">
+ {FONT_SIZES.map((f) => (
+ <button
+ key={f.id}
+ onClick={() => {
+ setFontSize(f.id);
+ applyFontSize(f.id);
+ }}
+ className={`px-2.5 py-1 rounded text-xs border transition-colors ${
+ fontSize === f.id
+ ? "bg-primary text-primary-foreground border-primary"
+ : "border-edge hover:bg-accent"
+ }`}
+ >
+ {f.label}
+ </button>
+ ))}
+ </div>
+ </div>
</div>
</div>
diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts
index 11f02fe2a..95c0cef79 100644
--- a/src/vite-env.d.ts
+++ b/src/vite-env.d.ts
@@ -1 +1,7 @@
/// <reference types="vite/client" />
+
+declare module "*.svg?react" {
+ import type { FC, SVGProps } from "react";
+ const ReactComponent: FC<SVGProps<SVGSVGElement>>;
+ export default ReactComponent;
+}
diff --git a/tsconfig.app.json b/tsconfig.app.json
index 8b558e6a3..2740089b5 100644
--- a/tsconfig.app.json
+++ b/tsconfig.app.json
@@ -28,7 +28,7 @@
"noImplicitOverride": false,
"noEmitOnError": false,
"paths": {
- "@/*": ["./src/*"]
+ "@/*": ["./src/ui/*"]
}
},
"include": ["src"]
diff --git a/tsconfig.json b/tsconfig.json
index fb9cca0af..1263ae5f0 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -13,7 +13,7 @@
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"paths": {
- "@/*": ["./src/*"]
+ "@/*": ["./src/ui/*"]
}
}
}
diff --git a/vite.config.ts b/vite.config.ts
index 5402296ad..b992b6027 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -3,6 +3,7 @@ import fs from "fs";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
+import svgr from "vite-plugin-svgr";
const sslCertPath = path.join(process.cwd(), "ssl/termix.crt");
const sslKeyPath = path.join(process.cwd(), "ssl/termix.key");
@@ -83,7 +84,7 @@ function getManualChunk(id: string): string | undefined {
}
export default defineConfig({
- plugins: [react(), tailwindcss()],
+ plugins: [react(), tailwindcss(), svgr()],
define: {
"import.meta.env.VITE_APP_VERSION": JSON.stringify(
packageJson.version || "0.0.0",
@@ -91,7 +92,7 @@ export default defineConfig({
},
resolve: {
alias: {
- "@": path.resolve(__dirname, "./src"),
+ "@": path.resolve(__dirname, "./src/ui"),
},
},
base: process.env.VITE_BASE_PATH || "./",