mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-08-29 18:31:33 +00:00
+7






![dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)


Luke Gustafson
emreumar
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
ZacharyZcR
Russell Poovey
russell
Subedi Bibek
Claude Fable 5
Alexander Elsner
SankeerthNara
Stephan Groth
DivByZero
devdanetra
Aleksandr Fominykh
sash
lhojun
Yunus Emre Umar
ddbdd5c437
* chore(deps): bump node from 24-slim to 26-slim in /docker in the docker-major-updates group (#1021) * chore: fix release workflow to merge docs branch * fix: svg donation generator push fail * fix: svg donation generator push fail * Update termix.rb * fix: svg donation generator push fail * chore: move donation badge to badges branch to avoid ruleset conflicts * chore: remove unneeded token from donation badge workflow * chore: debug donation badge commit step * fix: escape < character in donation SVG * fix: point donation badge to badges branch * chore: remove unused donation badge svg from main * Add Rack Genius logo to README Added Rack Genius logo to the README. * chore: improve donation goal svg generator to include stablecoins * chore: donation goal generator syntax error * chore: donation goal generator incorrect docs url usage * chore(deps): bump node in /docker in the docker-major-updates group Bumps the docker-major-updates group in /docker with 1 update: node. Updates `node` from 24-slim to 26-slim --- updated-dependencies: - dependency-name: node dependency-version: 26-slim dependency-type: direct:production dependency-group: docker-major-updates ... Signed-off-by: dependabot[bot] <support@github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: LukeGus <bugattiguy527@gmail.com> Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump the dev-patch-updates group with 24 updates (#1023) * chore: fix release workflow to merge docs branch * fix: svg donation generator push fail * fix: svg donation generator push fail * Update termix.rb * fix: svg donation generator push fail * chore: move donation badge to badges branch to avoid ruleset conflicts * chore: remove unneeded token from donation badge workflow * chore: debug donation badge commit step * fix: escape < character in donation SVG * fix: point donation badge to badges branch * chore: remove unused donation badge svg from main * Add Rack Genius logo to README Added Rack Genius logo to the README. * chore: improve donation goal svg generator to include stablecoins * chore: donation goal generator syntax error * chore: donation goal generator incorrect docs url usage * chore(deps-dev): bump the dev-patch-updates group with 24 updates Bumps the dev-patch-updates group with 24 updates: | Package | From | To | | --- | --- | --- | | [@biomejs/biome](https://github.com/biomejs/biome/tree/HEAD/packages/@biomejs/biome) | `2.5.1` | `2.5.2` | | [@codemirror/commands](https://github.com/codemirror/commands) | `6.10.3` | `6.10.4` | | [@codemirror/view](https://github.com/codemirror/view) | `6.43.1` | `6.43.5` | | [@radix-ui/react-accordion](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/accordion) | `1.2.14` | `1.2.15` | | [@radix-ui/react-alert-dialog](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/alert-dialog) | `1.1.17` | `1.1.18` | | [@radix-ui/react-checkbox](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/checkbox) | `1.3.5` | `1.3.6` | | [@radix-ui/react-dialog](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/dialog) | `1.1.17` | `1.1.18` | | [@radix-ui/react-dropdown-menu](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/dropdown-menu) | `2.1.18` | `2.1.19` | | [@radix-ui/react-label](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/label) | `2.1.10` | `2.1.11` | | [@radix-ui/react-popover](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/popover) | `1.1.17` | `1.1.18` | | [@radix-ui/react-progress](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/progress) | `1.1.10` | `1.1.11` | | [@radix-ui/react-scroll-area](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/scroll-area) | `1.2.12` | `1.2.13` | | [@radix-ui/react-select](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/select) | `2.3.1` | `2.3.2` | | [@radix-ui/react-separator](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/separator) | `1.1.10` | `1.1.11` | | [@radix-ui/react-slider](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/slider) | `1.4.1` | `1.4.2` | | [@radix-ui/react-switch](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/switch) | `1.3.1` | `1.3.2` | | [@radix-ui/react-tabs](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/tabs) | `1.1.15` | `1.1.16` | | [@radix-ui/react-tooltip](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/tooltip) | `1.2.10` | `1.2.11` | | [@tailwindcss/vite](https://github.com/tailwindlabs/tailwindcss/tree/HEAD/packages/@tailwindcss-vite) | `4.3.1` | `4.3.2` | | [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react) | `6.0.2` | `6.0.3` | | [i18next](https://github.com/i18next/i18next) | `26.3.1` | `26.3.4` | | [radix-ui](https://github.com/radix-ui/primitives/tree/HEAD/packages/react/radix-ui) | `1.6.0` | `1.6.1` | | [sharp](https://github.com/lovell/sharp) | `0.35.2` | `0.35.3` | | [tailwindcss](https://github.com/tailwindlabs/tailwindcss/tree/HEAD/packages/tailwindcss) | `4.3.1` | `4.3.2` | Updates `@biomejs/biome` from 2.5.1 to 2.5.2 - [Release notes](https://github.com/biomejs/biome/releases) - [Changelog](https://github.com/biomejs/biome/blob/main/packages/@biomejs/biome/CHANGELOG.md) - [Commits](https://github.com/biomejs/biome/commits/@biomejs/biome@2.5.2/packages/@biomejs/biome) Updates `@codemirror/commands` from 6.10.3 to 6.10.4 - [Changelog](https://github.com/codemirror/commands/blob/main/CHANGELOG.md) - [Commits](https://github.com/codemirror/commands/commits) Updates `@codemirror/view` from 6.43.1 to 6.43.5 - [Changelog](https://github.com/codemirror/view/blob/main/CHANGELOG.md) - [Commits](https://github.com/codemirror/view/commits) Updates `@radix-ui/react-accordion` from 1.2.14 to 1.2.15 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/accordion/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/accordion) Updates `@radix-ui/react-alert-dialog` from 1.1.17 to 1.1.18 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/alert-dialog/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/alert-dialog) Updates `@radix-ui/react-checkbox` from 1.3.5 to 1.3.6 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/checkbox/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/checkbox) Updates `@radix-ui/react-dialog` from 1.1.17 to 1.1.18 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/dialog/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/dialog) Updates `@radix-ui/react-dropdown-menu` from 2.1.18 to 2.1.19 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/dropdown-menu/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/dropdown-menu) Updates `@radix-ui/react-label` from 2.1.10 to 2.1.11 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/label/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/label) Updates `@radix-ui/react-popover` from 1.1.17 to 1.1.18 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/popover/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/popover) Updates `@radix-ui/react-progress` from 1.1.10 to 1.1.11 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/progress/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/progress) Updates `@radix-ui/react-scroll-area` from 1.2.12 to 1.2.13 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/scroll-area/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/scroll-area) Updates `@radix-ui/react-select` from 2.3.1 to 2.3.2 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/select/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/select) Updates `@radix-ui/react-separator` from 1.1.10 to 1.1.11 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/separator/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/separator) Updates `@radix-ui/react-slider` from 1.4.1 to 1.4.2 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/slider/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/slider) Updates `@radix-ui/react-switch` from 1.3.1 to 1.3.2 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/switch/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/switch) Updates `@radix-ui/react-tabs` from 1.1.15 to 1.1.16 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/tabs/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/tabs) Updates `@radix-ui/react-tooltip` from 1.2.10 to 1.2.11 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/tooltip/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/tooltip) Updates `@tailwindcss/vite` from 4.3.1 to 4.3.2 - [Release notes](https://github.com/tailwindlabs/tailwindcss/releases) - [Changelog](https://github.com/tailwindlabs/tailwindcss/blob/main/CHANGELOG.md) - [Commits](https://github.com/tailwindlabs/tailwindcss/commits/v4.3.2/packages/@tailwindcss-vite) Updates `@vitejs/plugin-react` from 6.0.2 to 6.0.3 - [Release notes](https://github.com/vitejs/vite-plugin-react/releases) - [Changelog](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite-plugin-react/commits/plugin-react@6.0.3/packages/plugin-react) Updates `i18next` from 26.3.1 to 26.3.4 - [Release notes](https://github.com/i18next/i18next/releases) - [Changelog](https://github.com/i18next/i18next/blob/master/CHANGELOG.md) - [Commits](https://github.com/i18next/i18next/compare/v26.3.1...v26.3.4) Updates `radix-ui` from 1.6.0 to 1.6.1 - [Changelog](https://github.com/radix-ui/primitives/blob/main/packages/react/radix-ui/CHANGELOG.md) - [Commits](https://github.com/radix-ui/primitives/commits/HEAD/packages/react/radix-ui) Updates `sharp` from 0.35.2 to 0.35.3 - [Release notes](https://github.com/lovell/sharp/releases) - [Commits](https://github.com/lovell/sharp/compare/v0.35.2...v0.35.3) Updates `tailwindcss` from 4.3.1 to 4.3.2 - [Release notes](https://github.com/tailwindlabs/tailwindcss/releases) - [Changelog](https://github.com/tailwindlabs/tailwindcss/blob/main/CHANGELOG.md) - [Commits](https://github.com/tailwindlabs/tailwindcss/commits/v4.3.2/packages/tailwindcss) --- updated-dependencies: - dependency-name: "@biomejs/biome" dependency-version: 2.5.2 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@codemirror/commands" dependency-version: 6.10.4 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@codemirror/view" dependency-version: 6.43.5 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-accordion" dependency-version: 1.2.15 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-alert-dialog" dependency-version: 1.1.18 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-checkbox" dependency-version: 1.3.6 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-dialog" dependency-version: 1.1.18 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-dropdown-menu" dependency-version: 2.1.19 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-label" dependency-version: 2.1.11 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-popover" dependency-version: 1.1.18 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-progress" dependency-version: 1.1.11 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-scroll-area" dependency-version: 1.2.13 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-select" dependency-version: 2.3.2 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-separator" dependency-version: 1.1.11 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-slider" dependency-version: 1.4.2 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-switch" dependency-version: 1.3.2 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-tabs" dependency-version: 1.1.16 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@radix-ui/react-tooltip" dependency-version: 1.2.11 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@tailwindcss/vite" dependency-version: 4.3.2 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@vitejs/plugin-react" dependency-version: 6.0.3 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: i18next dependency-version: 26.3.4 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: radix-ui dependency-version: 1.6.1 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: sharp dependency-version: 0.35.3 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: tailwindcss dependency-version: 4.3.2 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates ... Signed-off-by: dependabot[bot] <support@github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: LukeGus <bugattiguy527@gmail.com> Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump the prod-patch-updates group with 2 updates (#1025) * chore: fix release workflow to merge docs branch * fix: svg donation generator push fail * fix: svg donation generator push fail * Update termix.rb * fix: svg donation generator push fail * chore: move donation badge to badges branch to avoid ruleset conflicts * chore: remove unneeded token from donation badge workflow * chore: debug donation badge commit step * fix: escape < character in donation SVG * fix: point donation badge to badges branch * chore: remove unused donation badge svg from main * Add Rack Genius logo to README Added Rack Genius logo to the README. * chore: improve donation goal svg generator to include stablecoins * chore: donation goal generator syntax error * chore: donation goal generator incorrect docs url usage * chore(deps): bump the prod-patch-updates group with 2 updates Bumps the prod-patch-updates group with 2 updates: [axios](https://github.com/axios/axios) and [nanoid](https://github.com/ai/nanoid). Updates `axios` from 1.18.0 to 1.18.1 - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md) - [Commits](https://github.com/axios/axios/compare/v1.18.0...v1.18.1) Updates `nanoid` from 5.1.15 to 5.1.16 - [Release notes](https://github.com/ai/nanoid/releases) - [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md) - [Commits](https://github.com/ai/nanoid/compare/5.1.15...5.1.16) --- updated-dependencies: - dependency-name: axios dependency-version: 1.18.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: prod-patch-updates - dependency-name: nanoid dependency-version: 5.1.16 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: prod-patch-updates ... Signed-off-by: dependabot[bot] <support@github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: LukeGus <bugattiguy527@gmail.com> Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump the prod-minor-updates group with 3 updates (#1026) * chore: fix release workflow to merge docs branch * fix: svg donation generator push fail * fix: svg donation generator push fail * Update termix.rb * fix: svg donation generator push fail * chore: move donation badge to badges branch to avoid ruleset conflicts * chore: remove unneeded token from donation badge workflow * chore: debug donation badge commit step * fix: escape < character in donation SVG * fix: point donation badge to badges branch * chore: remove unused donation badge svg from main * Add Rack Genius logo to README Added Rack Genius logo to the README. * chore: improve donation goal svg generator to include stablecoins * chore: donation goal generator syntax error * chore: donation goal generator incorrect docs url usage * chore(deps): bump the prod-minor-updates group with 3 updates Bumps the prod-minor-updates group with 3 updates: [js-yaml](https://github.com/nodeca/js-yaml), [motion](https://github.com/motiondivision/motion) and [undici](https://github.com/nodejs/undici). Updates `js-yaml` from 5.0.0 to 5.2.1 - [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md) - [Commits](https://github.com/nodeca/js-yaml/compare/5.0.0...5.2.1) Updates `motion` from 12.40.0 to 12.42.2 - [Changelog](https://github.com/motiondivision/motion/blob/main/CHANGELOG.md) - [Commits](https://github.com/motiondivision/motion/compare/v12.40.0...v12.42.2) Updates `undici` from 8.5.0 to 8.7.0 - [Release notes](https://github.com/nodejs/undici/releases) - [Commits](https://github.com/nodejs/undici/compare/v8.5.0...v8.7.0) --- updated-dependencies: - dependency-name: js-yaml dependency-version: 5.2.1 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: prod-minor-updates - dependency-name: motion dependency-version: 12.42.2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: prod-minor-updates - dependency-name: undici dependency-version: 8.7.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: prod-minor-updates ... Signed-off-by: dependabot[bot] <support@github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: LukeGus <bugattiguy527@gmail.com> Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump electron from 42.4.1 to 43.0.0 in the major-updates group (#1027) * chore: fix release workflow to merge docs branch * fix: svg donation generator push fail * fix: svg donation generator push fail * Update termix.rb * fix: svg donation generator push fail * chore: move donation badge to badges branch to avoid ruleset conflicts * chore: remove unneeded token from donation badge workflow * chore: debug donation badge commit step * fix: escape < character in donation SVG * fix: point donation badge to badges branch * chore: remove unused donation badge svg from main * Add Rack Genius logo to README Added Rack Genius logo to the README. * chore: improve donation goal svg generator to include stablecoins * chore: donation goal generator syntax error * chore: donation goal generator incorrect docs url usage * chore(deps-dev): bump electron in the major-updates group Bumps the major-updates group with 1 update: [electron](https://github.com/electron/electron). Updates `electron` from 42.4.1 to 43.0.0 - [Release notes](https://github.com/electron/electron/releases) - [Commits](https://github.com/electron/electron/compare/v42.4.1...v43.0.0) --- updated-dependencies: - dependency-name: electron dependency-version: 43.0.0 dependency-type: direct:development update-type: version-update:semver-major dependency-group: major-updates ... Signed-off-by: dependabot[bot] <support@github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: LukeGus <bugattiguy527@gmail.com> Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix MC syntax highlighting artifacts (#996) * Filter dashboard status hosts (#997) * Persist dashboard service link changes (#999) * Fix snippet text overflow (#1000) * Persist remote desktop credential auth (#1001) * Guard language switching failures (#1002) * Resolve tunnel source credentials (#1003) * Support Vault auth for monitors (#1004) * Fix Windows file delete command (#1005) * Fix release artifact checkout ref (#1006) * Fix command palette escape in fullscreen (#1008) * Fix alerts and audit log data normalization (#1010) * Fix macOS VNC protocol negotiation (#1012) * Fix port knocking before SSH connect (#1013) * Allow Escape to close link confirmation (#1014) * Prevent Electron modifier wheel zoom (#1016) * Fix credential auth optional password (#1009) * Retry transient terminal DNS lookups (#1011) * Retry transient terminal DNS lookups * Apply DNS retry to SSH entry points * Fix OIDC redirect forwarded port handling (#1007) * Preserve recent open tabs on startup (#1015) * Fix fish prompt OSC highlighting (#998) * Fix terminal font selection (#1018) * fix: font legibility (#1019) * chore: fix release workflow to merge docs branch * fix: svg donation generator push fail * fix: svg donation generator push fail * Update termix.rb * fix: svg donation generator push fail * chore: move donation badge to badges branch to avoid ruleset conflicts * chore: remove unneeded token from donation badge workflow * chore: debug donation badge commit step * fix: escape < character in donation SVG * fix: point donation badge to badges branch * chore: remove unused donation badge svg from main * Add Rack Genius logo to README Added Rack Genius logo to the README. * chore: improve donation goal svg generator to include stablecoins * chore: donation goal generator syntax error * chore: donation goal generator incorrect docs url usage * fix: font legibility Text was entirely unreadable in places for me. Especially with themes like Catppuccin. The muted-foreground text and the tags too similiar to the background. --------- Co-authored-by: LukeGus <bugattiguy527@gmail.com> Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> Co-authored-by: russell <git@0896c69e.com> * fix(file-manager): chunked uploads fail with 'Expected multipart/form-data request' (#1020) * chore: fix release workflow to merge docs branch * fix: svg donation generator push fail * fix: svg donation generator push fail * Update termix.rb * fix: svg donation generator push fail * chore: move donation badge to badges branch to avoid ruleset conflicts * chore: remove unneeded token from donation badge workflow * chore: debug donation badge commit step * fix: escape < character in donation SVG * fix: point donation badge to badges branch * chore: remove unused donation badge svg from main * Add Rack Genius logo to README Added Rack Genius logo to the README. * chore: improve donation goal svg generator to include stablecoins * chore: donation goal generator syntax error * chore: donation goal generator incorrect docs url usage * fix(file-manager): use postForm for chunked uploads so multipart content-type is sent The fileManagerApi axios instance defaults to Content-Type: application/json. Axios 1.x's default transformRequest converts a FormData body to JSON whenever the request content type is application/json, so every chunk POSTed to /ssh/uploadFileChunk arrived as a JSON body like {"chunk":{}} and the backend rejected it with 400 'Expected multipart/form-data request'. This breaks all uploads of files larger than the 1.5 GiB chunking threshold. The non-chunked path already uses postForm for /ssh/uploadFileStream; use it for the chunk path too so axios keeps the FormData intact and the browser sets the multipart boundary. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: LukeGus <bugattiguy527@gmail.com> Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> * feat: implement OIDC back-channel logout support with session management (#1028) * feat: implement OIDC back-channel logout support with session management * Fix OIDC back-channel logout handling * Require logout token replay identifiers --------- Co-authored-by: ZacharyZcR <zacharyzcr1984@gmail.com> * Add API key host enrollment endpoint (#1029) * Fix tmux detection for non-POSIX shells (#1030) * Fix OPKSSH js-yaml ESM import (#1031) * Fix Android Vietnamese IME input (#1032) * Fix Firefox RDP clipboard paste (#1033) * Fix Proxmox discovery over HTTPS (#1041) * Fix external editor actions in file preview (#1042) * Allow pinned hosts with name sorting (#1043) * Fix Firefox desktop OIDC callback (#1044) * feat(session): add recording and replay (#1049) * Fix status checks through jump hosts (#1045) * Add terminal font size shortcuts (#1047) * feat: add Open File Manager to tab right-click menu (#1051) Co-authored-by: SankeerthNara <sankeerthnara@gmail.com> * perf: frontend request cache, poll pause, and code-split shell (#1052) Host/status caching, shell code-split, SSH pool waits, host-metrics concurrency, background-tab idle, per-host status subscriptions, homepage poll quieting, and virtualized host sidebar + file manager lists. * Merge commit from fork * Merge commit from fork * Merge commit from fork * Merge commit from fork * Merge commit from fork * Merge commit from fork * Merge commit from fork * Merge commit from fork * Merge commit from fork * Merge commit from fork * Merge commit from fork * Merge commit from fork * feat: save quick connect sessions as hosts (#1055) * fix: restore sudo password autofill settings (#1056) * fix: preserve file editor position on save (#1057) * fix: sync cloud preference storage mode (#1058) * fix: render RDP sessions at native pixel density (#1059) * fix: restore database import in embedded desktop mode (#1060) * Update Auto-complete.tsx (#1061) * chore: fix release workflow to merge docs branch * fix: svg donation generator push fail * fix: svg donation generator push fail * Update termix.rb * fix: svg donation generator push fail * chore: move donation badge to badges branch to avoid ruleset conflicts * chore: remove unneeded token from donation badge workflow * chore: debug donation badge commit step * fix: escape < character in donation SVG * fix: point donation badge to badges branch * chore: remove unused donation badge svg from main * Add Rack Genius logo to README Added Rack Genius logo to the README. * chore: improve donation goal svg generator to include stablecoins * chore: donation goal generator syntax error * chore: donation goal generator incorrect docs url usage * chore: donation bar reporting wrong result * feat: add Open File Manager to tab right-click menu (#1046) * Revert "feat: add Open File Manager to tab right-click menu (#1046)" (#1050) This reverts commit0712fdd731. * Remove donation badge from README Removed donation badge from README. * Delete .github/workflows/donation-goal.yml * Update Auto-complete.tsx --------- Co-authored-by: LukeGus <bugattiguy527@gmail.com> Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> Co-authored-by: ZacharyZcR <zacharyzcr1984@gmail.com> * feat(auth): opt-in OIDC DEK unlock for API-key requests (ALLOW_APIKEY_DATA_UNLOCK) (#1064) * chore: fix release workflow to merge docs branch * fix: svg donation generator push fail * fix: svg donation generator push fail * Update termix.rb * fix: svg donation generator push fail * chore: move donation badge to badges branch to avoid ruleset conflicts * chore: remove unneeded token from donation badge workflow * chore: debug donation badge commit step * fix: escape < character in donation SVG * fix: point donation badge to badges branch * chore: remove unused donation badge svg from main * Add Rack Genius logo to README Added Rack Genius logo to the README. * chore: improve donation goal svg generator to include stablecoins * chore: donation goal generator syntax error * chore: donation goal generator incorrect docs url usage * chore: donation bar reporting wrong result * feat: add Open File Manager to tab right-click menu (#1046) * Revert "feat: add Open File Manager to tab right-click menu (#1046)" (#1050) This reverts commit0712fdd731. * Remove donation badge from README Removed donation badge from README. * Delete .github/workflows/donation-goal.yml * feat(auth): opt-in OIDC DEK unlock for API-key requests API keys authenticate but cannot touch the encrypted credential/host store ('User data not unlocked') unless the user has a live interactive session, making them unusable for headless automation. For OIDC users the DEK is server-derivable (deriveOIDCSystemKey), so handleApiKeyAuth can unlock it without a password. Gated behind ALLOW_APIKEY_DATA_UNLOCK (default off) because enabling it widens the blast radius of a leaked API key. OIDC-only; password users are untouched. Refs #1063 --------- Co-authored-by: LukeGus <bugattiguy527@gmail.com> Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> Co-authored-by: Sankeerth Nara <sankeerthnara@gmail.com> Co-authored-by: ZacharyZcR <zacharyzcr1984@gmail.com> * chore: package lock sync * Add Proxmox guest auto sync (#1053) * draft: database layer refactor (#1054) * feat(sshid) - sshid.io equivalent for termix (#919) * feat(ssh-id): database schema, migrations and field encryption Adds ssh_identities, ssh_identity_keys and ssh_identity_ca tables (public keys stored plaintext for the unauthenticated resolver; CA private key registered for per-user field encryption), with UNIQUE(user_id), an index on ssh_identity_keys(identity_id), and idempotent CREATE TABLE migrations. * feat(ssh-id): backend API — resolver, key management, CA and certificates Mounts /sshid (nginx route added). Public text/plain authorized_keys resolver (+ exact /:algo filter, HTML viewer) and CA public-key endpoint; no-store + noindex headers on every resolver response including early 404s. Authenticated management: claim/rename/delete handle, add/import/generate/enable/delete keys, and a per-user CA (create/rotate/delete) with pure-Node OpenSSH certificate issuance. Audit logging on all mutations; UNIQUE races map to a precise 409. Unit tests for key parsing and certificate signing (ssh-keygen-validated). * feat(ssh-id): frontend panel, API client and i18n SSH ID panel wired into the app rail and AppShell: claim handle, resolver URL + curl one-liner, key list, generate, paste/import, CA enable/rotate/remove with server trust command, and per-key certificate issuance. API client re-exported through main-axios.ts; all strings i18n'd. * style(ssh-id): align panel and resolver page with Termix theme - Rebuild the SSH ID sidebar panel with the theme's square components (SectionCard / SettingRow / FakeSwitch) instead of rounded ad-hoc cards; use accent-brand and destructive tokens rather than raw red/green. - Fix panel scrolling: move overflow to a block scroll container so the cards keep their natural height instead of being clipped. - Restyle the public resolver HTML page (/sshid/u/:handle) to the Termix dark theme: square corners, #18181b/#303032 palette, #f59145 accent, uppercase section labels. - Tidy copy: 'Save To Credentials' label, drop the redundant generate intro, and correct the generate tooltip (the key is stored when saving to vault). * feat: rename to Termix ID, improve UI, backend inconsistencies, and general bug fixes --------- Co-authored-by: LukeGus <bugattiguy527@gmail.com> * ci(deps): bump actions/checkout from 6 to 7 in the github-actions group (#922) Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 6 to 7 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v6...v7) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump the dev-patch-updates group with 11 updates (#923) Bumps the dev-patch-updates group with 11 updates: | Package | From | To | | --- | --- | --- | | [@codemirror/search](https://github.com/codemirror/search) | `6.7.0` | `6.7.1` | | [@codemirror/view](https://github.com/codemirror/view) | `6.43.0` | `6.43.1` | | [@tailwindcss/vite](https://github.com/tailwindlabs/tailwindcss/tree/HEAD/packages/@tailwindcss-vite) | `4.3.0` | `4.3.1` | | [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8) | `4.1.8` | `4.1.9` | | [@vitest/ui](https://github.com/vitest-dev/vitest/tree/HEAD/packages/ui) | `4.1.8` | `4.1.9` | | [eslint-plugin-react-refresh](https://github.com/ArnaudBarre/eslint-plugin-react-refresh) | `0.5.2` | `0.5.3` | | [lint-staged](https://github.com/lint-staged/lint-staged) | `17.0.7` | `17.0.8` | | [prettier](https://github.com/prettier/prettier) | `3.8.3` | `3.8.4` | | [sharp](https://github.com/lovell/sharp) | `0.35.1` | `0.35.2` | | [tailwindcss](https://github.com/tailwindlabs/tailwindcss/tree/HEAD/packages/tailwindcss) | `4.3.0` | `4.3.1` | | [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) | `4.1.8` | `4.1.9` | Updates `@codemirror/search` from 6.7.0 to 6.7.1 - [Changelog](https://github.com/codemirror/search/blob/main/CHANGELOG.md) - [Commits](https://github.com/codemirror/search/commits) Updates `@codemirror/view` from 6.43.0 to 6.43.1 - [Changelog](https://github.com/codemirror/view/blob/main/CHANGELOG.md) - [Commits](https://github.com/codemirror/view/commits) Updates `@tailwindcss/vite` from 4.3.0 to 4.3.1 - [Release notes](https://github.com/tailwindlabs/tailwindcss/releases) - [Changelog](https://github.com/tailwindlabs/tailwindcss/blob/main/CHANGELOG.md) - [Commits](https://github.com/tailwindlabs/tailwindcss/commits/v4.3.1/packages/@tailwindcss-vite) Updates `@vitest/coverage-v8` from 4.1.8 to 4.1.9 - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md) - [Commits](https://github.com/vitest-dev/vitest/commits/v4.1.9/packages/coverage-v8) Updates `@vitest/ui` from 4.1.8 to 4.1.9 - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md) - [Commits](https://github.com/vitest-dev/vitest/commits/v4.1.9/packages/ui) Updates `eslint-plugin-react-refresh` from 0.5.2 to 0.5.3 - [Release notes](https://github.com/ArnaudBarre/eslint-plugin-react-refresh/releases) - [Changelog](https://github.com/ArnaudBarre/eslint-plugin-react-refresh/blob/main/CHANGELOG.md) - [Commits](https://github.com/ArnaudBarre/eslint-plugin-react-refresh/compare/v0.5.2...v0.5.3) Updates `lint-staged` from 17.0.7 to 17.0.8 - [Release notes](https://github.com/lint-staged/lint-staged/releases) - [Changelog](https://github.com/lint-staged/lint-staged/blob/main/CHANGELOG.md) - [Commits](https://github.com/lint-staged/lint-staged/compare/v17.0.7...v17.0.8) Updates `prettier` from 3.8.3 to 3.8.4 - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/3.8.3...3.8.4) Updates `sharp` from 0.35.1 to 0.35.2 - [Release notes](https://github.com/lovell/sharp/releases) - [Commits](https://github.com/lovell/sharp/compare/v0.35.1...v0.35.2) Updates `tailwindcss` from 4.3.0 to 4.3.1 - [Release notes](https://github.com/tailwindlabs/tailwindcss/releases) - [Changelog](https://github.com/tailwindlabs/tailwindcss/blob/main/CHANGELOG.md) - [Commits](https://github.com/tailwindlabs/tailwindcss/commits/v4.3.1/packages/tailwindcss) Updates `vitest` from 4.1.8 to 4.1.9 - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md) - [Commits](https://github.com/vitest-dev/vitest/commits/v4.1.9/packages/vitest) --- updated-dependencies: - dependency-name: "@codemirror/search" dependency-version: 6.7.1 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@codemirror/view" dependency-version: 6.43.1 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@tailwindcss/vite" dependency-version: 4.3.1 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@vitest/coverage-v8" dependency-version: 4.1.9 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: "@vitest/ui" dependency-version: 4.1.9 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: eslint-plugin-react-refresh dependency-version: 0.5.3 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: lint-staged dependency-version: 17.0.8 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: prettier dependency-version: 3.8.4 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: sharp dependency-version: 0.35.2 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: tailwindcss dependency-version: 4.3.1 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates - dependency-name: vitest dependency-version: 4.1.9 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-patch-updates ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump nanoid in the prod-patch-updates group (#925) Bumps the prod-patch-updates group with 1 update: [nanoid](https://github.com/ai/nanoid). Updates `nanoid` from 5.1.11 to 5.1.15 - [Release notes](https://github.com/ai/nanoid/releases) - [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md) - [Commits](https://github.com/ai/nanoid/compare/5.1.11...5.1.15) --- updated-dependencies: - dependency-name: nanoid dependency-version: 5.1.15 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: prod-patch-updates ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump the major-updates group with 5 updates (#926) Bumps the major-updates group with 5 updates: | Package | From | To | | --- | --- | --- | | [js-yaml](https://github.com/nodeca/js-yaml) | `4.2.0` | `5.0.0` | | [@eslint/js](https://github.com/eslint/eslint/tree/HEAD/packages/js) | `9.39.4` | `10.0.1` | | [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) | `25.9.2` | `26.0.0` | | [concurrently](https://github.com/open-cli-tools/concurrently) | `9.2.1` | `10.0.3` | | [eslint](https://github.com/eslint/eslint) | `9.39.4` | `10.5.0` | Updates `js-yaml` from 4.2.0 to 5.0.0 - [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md) - [Commits](https://github.com/nodeca/js-yaml/compare/4.2.0...5.0.0) Updates `@eslint/js` from 9.39.4 to 10.0.1 - [Release notes](https://github.com/eslint/eslint/releases) - [Commits](https://github.com/eslint/eslint/commits/v10.0.1/packages/js) Updates `@types/node` from 25.9.2 to 26.0.0 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Updates `concurrently` from 9.2.1 to 10.0.3 - [Release notes](https://github.com/open-cli-tools/concurrently/releases) - [Commits](https://github.com/open-cli-tools/concurrently/compare/v9.2.1...v10.0.3) Updates `eslint` from 9.39.4 to 10.5.0 - [Release notes](https://github.com/eslint/eslint/releases) - [Commits](https://github.com/eslint/eslint/compare/v9.39.4...v10.5.0) --- updated-dependencies: - dependency-name: js-yaml dependency-version: 5.0.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: major-updates - dependency-name: "@eslint/js" dependency-version: 10.0.1 dependency-type: direct:development update-type: version-update:semver-major dependency-group: major-updates - dependency-name: "@types/node" dependency-version: 26.0.0 dependency-type: direct:development update-type: version-update:semver-major dependency-group: major-updates - dependency-name: concurrently dependency-version: 10.0.3 dependency-type: direct:development update-type: version-update:semver-major dependency-group: major-updates - dependency-name: eslint dependency-version: 10.5.0 dependency-type: direct:development update-type: version-update:semver-major dependency-group: major-updates ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat(ssh): add HashiCorp Vault SSH signer authentication * fix: small fixes to vault feature to align with Termix codebase * chore: add view docs links for vault/termix id * fix: file upload fails with 400 and missing schema migrations on upgrade (#929) Two bugs introduced in v2.4.1: 1. uploadFileStream uses fileManagerApi.post() which triggers axios's transformRequest to JSON-serialize the FormData because the instance default Content-Type is application/json. Change to postForm() which sets Content-Type: multipart/form-data so the browser XHR sends the correct multipart body with boundary. 2. Two schema items added to schema.ts were not included in migrateSchema() in db/index.ts, causing 500 errors on existing installations upgrading from v2.4.0: - user_preferences.status_color_scheme (no such column) - dashboard_service_links table (no such table) Fixes #928 Co-authored-by: sash <sash@fominykh.io> * fix: support PuTTY PPK ssh keys (#930) * fix: chunk large file manager uploads (#932) * fix: route dashboard hosts by protocol (#934) * fix: resolve tunnel endpoints reliably (#935) * Fix Electron OIDC browser auth failures (#936) * Allow RDP connections without stored credentials (#937) * Sync role credential shares for OIDC users (#938) * Fix terminal link dialog layering (#940) * Confirm large files before opening editor (#942) * Confirm closing active host connections (#943) * Preserve file path case in file manager UI (#941) * fix: preserve unicode guacamole tokens (#933) * Persist VNC authentication settings (#944) * Fix Guacamole websocket base path (#946) * Promote file manager terminals to tabs (#939) * Guard Guacamole disconnect during startup (#945) * chore: increment ver * feat: bitwarden ssh agent integration * feat: serial connections support * fix: various small bug fixes * feat: open all sessions in a folder and terminal custom theme color support * feat: cross host file manager clipboard and several small bug fixes * feat: tailscale/wireguard support and added a new status state for when backend is checking status * feat: grafana like server stats history, new alert system, ntfy/webhook support * feat: new grid and widget based homepage function * feat: new donate button in dashboard * fix: alert ui incorrectly using termix css and fixed issue with alert system not loading * chore: start database layer refactor * docs: plan database layer refactor * docs: audit database layer refactor phase zero * chore: add database runtime adapter skeleton * chore: add settings repository skeleton * chore: add user session repository skeleton * chore: add host credential repository skeleton * chore: add field encryption boundary * chore: migrate settings route slice * chore: migrate user settings routes * chore: migrate host metrics settings routes * chore: migrate acme settings route * chore: migrate terminal settings route * chore: migrate tailscale settings read * chore: migrate guacamole settings reads * chore: migrate session timeout settings reads * chore: migrate auth route settings reads * chore: migrate host metrics settings reads * chore: migrate startup settings reads * chore: migrate user settings cleanup * chore: migrate password reset settings * chore: migrate oidc legacy settings read * chore: migrate user route settings slice * chore: migrate oidc state settings * chore: migrate user login settings reads * chore: migrate user crypto settings * chore: consolidate startup settings defaults * chore: consolidate database settings import export * chore: migrate core session auth paths * chore: migrate remaining session auth paths * chore: migrate admin user routes * chore: migrate user route admin checks * chore: migrate user lifecycle routes * chore: migrate auth user lookups * chore: migrate oidc user routes * chore: migrate api key repository paths * docs: add database gray rollout guide * chore: migrate trusted device paths * chore: migrate user session route user lookups * chore: add database repository rollout guard * chore: expose repository rollout status * chore: warn on repository rollout misconfiguration * chore: migrate remaining user lookup helpers * chore: migrate ssh user lookups * chore: migrate user settings admin lookups * chore: migrate acme ssl user lookups * chore: migrate audit log admin checks * chore: migrate oidc account user updates * chore: migrate password reset user updates * chore: migrate user deletion core records * chore: migrate snippet audit user lookups * chore: migrate ldap user sync paths * chore: migrate totp user updates * chore: migrate rbac user checks * chore: migrate rbac role paths * chore: migrate permission role lookups * chore: migrate rbac access list reads * chore: migrate shared rbac reads * chore: migrate rbac access writes * chore: migrate permission host access * chore: migrate role host access lookup * chore: migrate snippet access lookup * chore: migrate shared credential access lookups * chore: migrate host access cleanup writes * chore: migrate host list access checks * chore: migrate host access cleanup routes * chore: migrate shared credential role lookups * chore: migrate user role cleanup * chore: migrate admin role sync * chore: migrate ldap role sync * chore: migrate user role assignment * chore: migrate sso provider access * chore: migrate audit log access * chore: migrate user preference access * chore: migrate open tab access * chore: migrate dismissed alert access * chore: migrate homepage layout access * chore: migrate network topology access * chore: migrate dashboard service link access * chore: migrate command history access * chore: migrate recent activity cleanup * chore: migrate ssh credential usage access * chore: migrate transfer recent access * chore: migrate file manager bookmark access * chore: migrate c2s tunnel preset access * chore: migrate homepage item access * chore: migrate session recording access * chore: migrate tmux session tag access * chore: migrate opkssh token access * chore: migrate vault token access * chore: migrate vault profile access * chore: migrate host metrics preference access * chore: migrate host health access * chore: migrate host metrics history access * chore: migrate alert persistence access * chore: route alert host lookup through repository * chore: migrate user data export reads * chore: route host metrics stats sync through repository * chore: migrate host folder persistence * chore: migrate host resolution reads * chore: route jump host resolution reads * chore: route docker console jump host reads * chore: route docker ssh resolution reads * chore: route proxmox discovery resolution reads * chore: route file manager activity host reads * chore: route host metrics resolution reads * chore: route ssh auth credential reads * chore: route tunnel endpoint credential reads * chore: route credential deployment resolution reads * chore: route command history host flag reads * chore: route snippet execution resolution reads * chore: route terminal host resolution reads * chore: route vault oidc host resolution reads * chore: route wake on lan host reads * chore: route internal host list reads * chore: route host key verification persistence * chore: route credential read paths * chore: route credential host usage reads * chore: route credential folder rename * chore: route host owner access checks * chore: route shared credential source reads * chore: route user host credential cleanup * chore: route credential delete reads * chore: route credential update reads * chore: route host credential reads * chore: route host read paths * chore: route host projection reads * chore: route host list reads * chore: route snippet read paths * chore: route snippet folder writes * chore: route snippet crud paths * chore: route snippet bulk import * chore: route rbac ownership reads * chore: route user count reads * chore: route cleanup snippets folders * chore: route shared credential persistence * chore: route dashboard activity * chore: route guacamole host reads * chore: route host bulk lookups * chore: remove unlock-only simple db ops * chore: route host autostart persistence * chore: route ldap provisioning through users * chore: route credential encrypted writes * chore: route host encrypted writes * chore: route bulk host encrypted writes * chore: route termix id credentials * chore: route termix id ca persistence * chore: route termix identity persistence * chore: route credential system migration * chore: isolate user encryption migration storage * chore: remove legacy simple db ops * chore: isolate legacy sqlite migration copy * chore: route database settings import export * chore: route database host credential export * chore: route database host credential import * chore: route database file-manager import export * chore: route database alert usage import export * chore: route database user checks * chore: isolate auth lazy migration storage * chore: route explicit database saves * chore: initialize database save boundary * chore: route migration snapshot saves * chore: isolate sqlite import constraints * chore: route import sqlite boundary * chore: route user encryption migration store * chore: centralize current repository runtime * chore: route more current repositories * chore: route activity repository runtimes * chore: route token repository runtimes * chore: route health repository runtimes * chore: route identity repository runtimes * chore: route rbac repository runtime * chore: centralize current sqlite runtime access * chore: route user deletion key cleanup * chore: route user deletion vault cleanup * chore: route user deletion homepage cleanup * chore: route user deletion health cleanup * chore: route user deletion alert cleanup * chore: route user deletion identity cleanup * chore: add database layer preupgrade backup * Fix database repository type errors * fix: complete post-merge compile fixes for database refactor Restore missing DatabaseSaveTrigger/getDb imports, session log format fallback, OIDC provider resolution, guacamole recording insert, and passwordFallbackOnly typing after merging current dev. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: DivByZero <mr.oplus@yahoo.fr> Co-authored-by: LukeGus <bugattiguy527@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: devdanetra <46488477+devdanetra@users.noreply.github.com> Co-authored-by: Aleksandr Fominykh <neoformalex@users.noreply.github.com> Co-authored-by: sash <sash@fominykh.io> * refactor(db): collapse repository rollout scaffolding into single factory Repositories are now the only data path. Replaces the 41 current-*-repository wrapper files, the DATABASE_LAYER_REPOSITORY_ROLLOUT flag/alias map and the unused database/runtime adapter with repositories/factory.ts, a plain DatabaseContext type and an in-memory TestSqliteDatabase test harness. * refactor(db): route remaining raw DB access through repositories proxmox, session-log, oidc-utils, webauthn and guacamole recording now use repositories (new WebauthnCredentialRepository; SsoProviderRepository listEnabled; HostRepository findDecryptedByIdAs/listProxmoxEnabled). Remaining raw access: db boot code, simple-db-ops and docker.ts, which are removed/restructured in later phases. * feat(crypto): add UserKeyManager with system-wrapped per-user DEKs New utils/user-keys.ts: one random 32-byte DEK per user, wrapped AES-256-GCM under an HKDF key derived from the system ENCRYPTION_KEY (per-user info string + AAD binding, versioned v3 wrap format stored in settings). Synchronous unwrap-on-demand with a 15-minute cache so the existing DataCrypto facade keeps its sync call sites. Not wired up yet. * feat(crypto): boot-time DEK migration to system-wrapped v3 format utils/crypto-migration/dek-migration.ts carries the legacy unwrap paths (PBKDF2 password KEK, OIDC/WebAuthn system keys, hardcoded-default fallback) and migrates every server-unwrappable DEK to the v3 wrap at startup. Password-wrapped DEKs migrate at next login or from a live session via adoptRecoveredDEK. Legacy rows are kept for now; cleanup flips on once the new path is authoritative. * refactor(crypto): make system-wrapped DEKs the authoritative key path DataCrypto and AuthManager now read keys through UserKeyManager: DEKs are always unwrappable server-side, so the in-memory unlock session, DEK-in-JWT wrapping, session-expiry data locks and ALLOW_APIKEY_DATA_UNLOCK are gone. utils/user-crypto.ts is deleted; boot migration now cleans legacy wraps. A one-release shim adopts DEKs from legacy dataKeyWrap tokens so active password users migrate without re-login. Password login migrates legacy password-wrapped DEKs via migratePasswordUserAtLogin. * refactor(crypto): remove pending share queue and credential sharing key With server-unwrappable DEKs both sides of a share are always available, so the needsReEncryption queue, CREDENTIAL_SHARING_KEY and the system_* shadow columns on ssh_credentials are gone. A one-time boot cleanup re-creates legacy pending share copies where possible (dropping unresolvable ones with a warning) and drops the legacy columns. * feat(auth): non-destructive password resets and admin reset endpoint Password resets no longer destroy user data: the DEK is system-wrapped, so forgot-password and admin resets are just a hash update plus session revoke. The wipe branch survives only for accounts that never logged in since the encryption upgrade and now requires explicit confirmDataWipe (surfaced as a 409 DATA_WIPE_REQUIRED; the reset UI asks for confirmation). Adds POST /users/admin/reset-password and removes the dead re-encryption paths. * refactor(ssh): consolidate four jump-host chain copies into one module terminal, host-metrics and docker now use ssh/jump-host-chain.ts (already shared by file-manager, tmux-monitor and docker-console); docker's inline copy also drops its raw SimpleDBOps host/credential lookups in favor of repositories. * refactor(ssh): single shared createConnectionLog helper file-manager-log.ts becomes ssh/connection-log.ts; the copies in docker.ts and host-metrics-helpers.ts are gone. * refactor(ssh): split docker module into layered directory ssh/docker/{index,routes,session-manager,container-routes,console}.ts: server boot and wiring in index, HTTP handlers in routes, SSH session registry and command execution in session-manager. Code motion only; port 30007/30009 and endpoints unchanged. Swagger now scans ssh subdirectories. * refactor(ssh): split tunnel module into layered directory ssh/tunnel/{index,routes,manager}.ts: server boot in index, HTTP handlers in routes, tunnel state and engine (connect/retry/autostart) in manager. Code motion only; port 30003 and endpoints unchanged. * refactor(backend): reorganize top-level layout - ssh/ renamed to hosts/ (it covers SSH, RDP, VNC, Telnet, Docker, metrics) - serial/serial.ts and guacamole/ moved inside hosts/ - dashboard.ts and homepage.ts moved to services/ - swagger.ts moved to utils/ with adjusted scan globs Import paths and the generate:openapi script updated; ports and endpoints unchanged. * refactor(tests): move backend tests into src/backend/tests mirror tree Backend *.test.ts files (and the test-support harness) no longer sit next to source files; they live under src/backend/tests/ mirroring the source layout. Imports rewritten accordingly; CLAUDE.md convention updated. * refactor(hosts): group host modules into per-feature directories file-manager/, metrics/ (incl. widgets, managers, alert-engine), terminal/, tmux/ and tunnel/ each own their files; docker/ gains container-runtime. Genuinely shared helpers (jump-host chain, host resolver, connection pool, opkssh, vault, serial) stay at hosts/ root. Pure file moves with import path updates; mirrored test paths follow. * refactor(backend): final cleanup pass - re-register WebAuthn passkey routes (registration was dropped in the #1054 merge, breaking passkey login) and document all six endpoints - delete utils/simple-db-ops.ts (last caller migrated to DataCrypto) - starter: use the typed serverReady export, collapse the four-way version lookup to env then package.json candidates - add OpenAPI JSDoc to c2s-tunnel-presets endpoints - strip block-divider comment banners * feat: remove legacy "data_unlocked" field * feat: refactor rbac/sharing to support new permissions and auth types * feat: refactor rbac/sharing to support new permissions and auth types * feat: add "id" to user profile hide list * chore: root cleanup * feat: add more donation references and a 30-day donation reminder * chore: update readme * feat: automate beta tests * feat: add links to milestones * fix: hoist github/google SSO defaults to module scope (#1065) * fix(ssh-tools): allow clipboard paste in key recording field (#1066) The broadcast key-recording input was marked readOnly, which makes browsers block paste entirely (no context-menu Paste, Ctrl+V does nothing). handleKeyDown also called preventDefault() unconditionally, swallowing the Ctrl+V shortcut before a paste event could even fire. Let Ctrl/Cmd+V pass through in handleKeyDown, drop readOnly, and add an onPaste handler that reads the clipboard text and broadcasts it to the selected terminals like any other captured keystroke. Signed-off-by: emreumar <emreumar@users.noreply.github.com> Co-authored-by: emreumar <emreumar@users.noreply.github.com> * chore: write release notes * chore: update release notes * chore: update readmes * chore: add crypto only reminder in en.json * fix: macOS and cask errors on release workflow * chore: sync Crowdin translations for 2.5.1 --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: emreumar <emreumar@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: ZacharyZcR <zacharyzcr1984@gmail.com> Co-authored-by: Russell Poovey <09.our_seekers@icloud.com> Co-authored-by: russell <git@0896c69e.com> Co-authored-by: Subedi Bibek <77529535+questbibek@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: Alexander Elsner <101340634+Bensonheimer992@users.noreply.github.com> Co-authored-by: SankeerthNara <sankeerthnara@gmail.com> Co-authored-by: Stephan Groth <96803994+Kalvalax@users.noreply.github.com> Co-authored-by: DivByZero <mr.oplus@yahoo.fr> Co-authored-by: devdanetra <46488477+devdanetra@users.noreply.github.com> Co-authored-by: Aleksandr Fominykh <neoformalex@users.noreply.github.com> Co-authored-by: sash <sash@fominykh.io> Co-authored-by: lhojun <ldgs3324@gmail.com> Co-authored-by: Yunus Emre Umar <77045015+emre155@users.noreply.github.com> Co-authored-by: emreumar <emreumar@users.noreply.github.com>
3201 lines
106 KiB
TypeScript
3201 lines
106 KiB
TypeScript
/* eslint-disable react-hooks/exhaustive-deps */
|
|
import {
|
|
useEffect,
|
|
useRef,
|
|
useState,
|
|
useImperativeHandle,
|
|
forwardRef,
|
|
useCallback,
|
|
} from "react";
|
|
import { createPortal } from "react-dom";
|
|
import { useXTerm } from "react-xtermjs";
|
|
import { FitAddon } from "@xterm/addon-fit";
|
|
import { ClipboardAddon } from "@xterm/addon-clipboard";
|
|
import { RobustClipboardProvider } from "@/lib/clipboard-provider";
|
|
import { copyToClipboard } from "@/lib/clipboard";
|
|
import { Unicode11Addon } from "@xterm/addon-unicode11";
|
|
import { WebLinksAddon } from "@xterm/addon-web-links";
|
|
import { useTranslation } from "react-i18next";
|
|
import { getBasePath } from "@/lib/base-path";
|
|
import {
|
|
getCookie,
|
|
isElectron,
|
|
isEmbeddedMode,
|
|
logActivity,
|
|
getSnippets,
|
|
deleteCommandFromHistory,
|
|
getCommandHistory,
|
|
getHostPassword,
|
|
getServerConfig,
|
|
} 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 {
|
|
DEFAULT_TERMINAL_CONFIG,
|
|
TERMINAL_FONTS,
|
|
} from "@/lib/terminal-themes.ts";
|
|
import "./terminal-global-styles.ts";
|
|
import { useTheme } from "@/components/theme-provider.tsx";
|
|
import { globalShortcutHandler } from "@/lib/global-shortcut-handler";
|
|
import { useCommandTracker } from "@/features/terminal/command-history/useCommandTracker.ts";
|
|
import { highlightTerminalOutput } from "@/lib/terminal-syntax-highlighter.ts";
|
|
import { useCommandHistory } from "@/features/terminal/command-history/CommandHistoryContext.tsx";
|
|
import { CommandAutocomplete } from "./command-history/CommandAutocomplete.tsx";
|
|
import { SimpleLoader } from "@/lib/SimpleLoader.tsx";
|
|
import { useConfirmation } from "@/hooks/use-confirmation.ts";
|
|
import {
|
|
ConnectionLogProvider,
|
|
useConnectionLog,
|
|
} from "@/ssh/connection-log/ConnectionLogContext.tsx";
|
|
import { ConnectionLog } from "@/ssh/connection-log/ConnectionLog.tsx";
|
|
import { toast } from "sonner";
|
|
import { Button } from "@/components/button";
|
|
import { Save } from "lucide-react";
|
|
import { resolveTermixThemeColors } from "./terminal-theme.ts";
|
|
import type { TerminalHandle, TerminalHostConfig } from "./terminal-types.ts";
|
|
import {
|
|
getNextTerminalFontSize,
|
|
getTerminalFontZoomDirection,
|
|
} from "./terminal-font-zoom.ts";
|
|
export type { TerminalHandle, TerminalHostConfig } from "./terminal-types.ts";
|
|
|
|
type HostKeyVerificationData = Omit<
|
|
React.ComponentProps<typeof HostKeyVerificationDialog>,
|
|
"isOpen" | "scenario" | "onAccept" | "onReject" | "backgroundColor"
|
|
>;
|
|
|
|
interface SSHTerminalProps {
|
|
hostConfig: TerminalHostConfig;
|
|
isVisible: boolean;
|
|
title?: string;
|
|
showTitle?: boolean;
|
|
splitScreen?: boolean;
|
|
onClose?: () => void;
|
|
onTitleChange?: (title: string) => void;
|
|
initialPath?: string;
|
|
executeCommand?: string;
|
|
/** Attach to this tmux session right after connecting (tmux monitor). */
|
|
tmuxAttachSession?: string;
|
|
onOpenFileManager?: (path?: string) => void;
|
|
onOpenFileInEditor?: (filePath: string) => void;
|
|
previewTheme?: string | null;
|
|
/** When true, suppress automatic focus on connect/visibility change. */
|
|
disableAutoFocus?: boolean;
|
|
isQuickConnect?: boolean;
|
|
onSaveQuickConnect?: () => Promise<void>;
|
|
}
|
|
|
|
const ALTERNATE_SCREEN_SEQUENCE = /\x1b\[\?(47|1047|1049)([hl])/g;
|
|
|
|
function updateAlternateScreenMode(output: string, currentMode: boolean) {
|
|
ALTERNATE_SCREEN_SEQUENCE.lastIndex = 0;
|
|
let isActive = currentMode;
|
|
let sawSequence = false;
|
|
let match: RegExpExecArray | null;
|
|
|
|
while ((match = ALTERNATE_SCREEN_SEQUENCE.exec(output)) !== null) {
|
|
sawSequence = true;
|
|
isActive = match[2] === "h";
|
|
}
|
|
|
|
return { isActive, sawSequence };
|
|
}
|
|
|
|
const TerminalInner = forwardRef<TerminalHandle, SSHTerminalProps>(
|
|
function SSHTerminal(
|
|
{
|
|
hostConfig,
|
|
isVisible,
|
|
splitScreen = false,
|
|
onClose,
|
|
onTitleChange,
|
|
initialPath,
|
|
executeCommand,
|
|
tmuxAttachSession,
|
|
onOpenFileManager,
|
|
onOpenFileInEditor,
|
|
previewTheme,
|
|
disableAutoFocus = false,
|
|
isQuickConnect = false,
|
|
onSaveQuickConnect,
|
|
},
|
|
ref,
|
|
) {
|
|
const { t } = useTranslation();
|
|
const { instance: terminal, ref: xtermRef } = useXTerm();
|
|
const commandHistoryContext = useCommandHistory();
|
|
const { confirmWithToast } = useConfirmation();
|
|
const { theme: appTheme } = useTheme();
|
|
const { addLog, isExpanded: isConnectionLogExpanded } = useConnectionLog();
|
|
|
|
const savedTheme = localStorage.getItem(
|
|
`terminal_theme_host_${hostConfig.id}`,
|
|
);
|
|
const config = {
|
|
...DEFAULT_TERMINAL_CONFIG,
|
|
...hostConfig.terminalConfig,
|
|
theme:
|
|
savedTheme ||
|
|
hostConfig.terminalConfig?.theme ||
|
|
DEFAULT_TERMINAL_CONFIG.theme,
|
|
};
|
|
|
|
const activeTheme = previewTheme || config.theme;
|
|
const themeColors = resolveTermixThemeColors(
|
|
activeTheme,
|
|
appTheme,
|
|
config.customThemeColors,
|
|
);
|
|
const backgroundImage = config.backgroundImage || "";
|
|
const backgroundImageOpacity = config.backgroundImageOpacity ?? 0.15;
|
|
const backgroundColor = backgroundImage
|
|
? "transparent"
|
|
: 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 pongReceivedRef = useRef(true);
|
|
const pongTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
const [isConnected, setIsConnected] = useState(false);
|
|
const [isSavingQuickConnect, setIsSavingQuickConnect] = useState(false);
|
|
const [isQuickConnectSaved, setIsQuickConnectSaved] = useState(false);
|
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
const [isFitted, setIsFitted] = useState(false);
|
|
const [connectionError, setConnectionError] = useState<string | null>(null);
|
|
const connectionErrorRef = useRef<string | null>(null);
|
|
const [showDisconnectedOverlay, setShowDisconnectedOverlay] =
|
|
useState(false);
|
|
|
|
const updateConnectionError = useCallback((error: string | null) => {
|
|
connectionErrorRef.current = error;
|
|
setConnectionError(error);
|
|
}, []);
|
|
|
|
const [, 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 [, setKeyboardInteractiveDetected] = useState(false);
|
|
const [warpgateAuthRequired, setWarpgateAuthRequired] = useState(false);
|
|
const [warpgateAuthUrl, setWarpgateAuthUrl] = useState<string>("");
|
|
const [warpgateSecurityKey, setWarpgateSecurityKey] = useState<string>("");
|
|
const warpgateTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
|
|
const [opksshDialog, setOpksshDialog] = useState<{
|
|
isOpen: boolean;
|
|
authUrl: string;
|
|
requestId: string;
|
|
stage: "chooser" | "waiting" | "authenticating" | "completed" | "error";
|
|
error?: string;
|
|
providers?: Array<{ alias: string; issuer: string }>;
|
|
} | null>(null);
|
|
const opksshTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
|
|
const opksshFailedRef = useRef(false);
|
|
const currentHostIdRef = useRef<number | null>(null);
|
|
const currentHostConfigRef = useRef<TerminalHostConfig | null>(null);
|
|
|
|
// Vault SSH signer interactive OIDC flow
|
|
const [vaultDialog, setVaultDialog] = useState<{
|
|
stage: "waiting" | "error";
|
|
error?: string;
|
|
} | null>(null);
|
|
const vaultFailedRef = useRef(false);
|
|
const vaultPopupRef = useRef<Window | null>(null);
|
|
const vaultTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
|
|
const [hostKeyVerification, setHostKeyVerification] = useState<{
|
|
isOpen: boolean;
|
|
scenario: "new" | "changed";
|
|
data: HostKeyVerificationData;
|
|
} | null>(null);
|
|
|
|
const sessionIdRef = useRef<string | null>(null);
|
|
const isAttachingSessionRef = useRef<boolean>(false);
|
|
// Consumed on first connectToHost call so retries don't re-attempt a stale session
|
|
const pendingRestoredSessionIdRef = useRef<string | null>(
|
|
hostConfig.restoredSessionId ?? null,
|
|
);
|
|
const [linkClickDialog, setLinkClickDialog] = useState<{
|
|
url: string;
|
|
} | null>(null);
|
|
|
|
useEffect(() => {
|
|
if (!linkClickDialog) return;
|
|
|
|
const handleKeyDown = (event: KeyboardEvent) => {
|
|
if (event.key !== "Escape") return;
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
setLinkClickDialog(null);
|
|
};
|
|
|
|
window.addEventListener("keydown", handleKeyDown, true);
|
|
return () => window.removeEventListener("keydown", handleKeyDown, true);
|
|
}, [linkClickDialog]);
|
|
|
|
const [tmuxSessionPicker, setTmuxSessionPicker] = useState<{
|
|
sessions: Array<{
|
|
name: string;
|
|
created: number;
|
|
lastActivity: number;
|
|
windows: number;
|
|
attachedClients: number;
|
|
}>;
|
|
} | null>(null);
|
|
const tmuxSessionNameRef = useRef<string | null>(null);
|
|
const [isTmuxAttached, setIsTmuxAttached] = useState(false);
|
|
const tmuxCopyModeHintShownRef = useRef(false);
|
|
|
|
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 wasConnectedRef = useRef(false);
|
|
const wasSessionExpiredRef = useRef(false);
|
|
|
|
useEffect(() => {
|
|
isUnmountingRef.current = false;
|
|
shouldNotReconnectRef.current = false;
|
|
isReconnectingRef.current = false;
|
|
isConnectingRef.current = false;
|
|
reconnectAttempts.current = 0;
|
|
wasConnectedRef.current = false;
|
|
isAttachingSessionRef.current = false;
|
|
|
|
return () => {};
|
|
}, [hostConfig.id]);
|
|
const connectionAttemptIdRef = useRef(0);
|
|
const totpTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
const connectionTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
const activityLoggedRef = useRef(false);
|
|
const commandHistoryTrackingEnabled =
|
|
hostConfig.enableCommandHistory !== false;
|
|
|
|
const { trackInput, getCurrentCommand, updateCurrentCommand } =
|
|
useCommandTracker({
|
|
hostId: hostConfig.id,
|
|
enabled: commandHistoryTrackingEnabled,
|
|
onCommandExecuted: (command) => {
|
|
if (!autocompleteHistory.current.includes(command)) {
|
|
autocompleteHistory.current = [
|
|
command,
|
|
...autocompleteHistory.current,
|
|
];
|
|
}
|
|
},
|
|
});
|
|
|
|
const getCurrentCommandRef = useRef(getCurrentCommand);
|
|
const updateCurrentCommandRef = useRef(updateCurrentCommand);
|
|
|
|
useEffect(() => {
|
|
getCurrentCommandRef.current = getCurrentCommand;
|
|
updateCurrentCommandRef.current = updateCurrentCommand;
|
|
}, [getCurrentCommand, updateCurrentCommand]);
|
|
|
|
const [showAutocomplete, setShowAutocomplete] = useState(false);
|
|
const [autocompleteSuggestions, setAutocompleteSuggestions] = useState<
|
|
string[]
|
|
>([]);
|
|
const [autocompleteSelectedIndex, setAutocompleteSelectedIndex] =
|
|
useState(0);
|
|
const [autocompletePosition, setAutocompletePosition] = useState({
|
|
top: 0,
|
|
left: 0,
|
|
});
|
|
const autocompleteHistory = useRef<string[]>([]);
|
|
const currentAutocompleteCommand = useRef<string>("");
|
|
|
|
const showAutocompleteRef = useRef(false);
|
|
const autocompleteSuggestionsRef = useRef<string[]>([]);
|
|
const autocompleteSelectedIndexRef = useRef(0);
|
|
|
|
const [showHistoryDialog] = useState(false);
|
|
const [, setCommandHistory] = useState<string[]>([]);
|
|
const [, setIsLoadingHistory] = useState(false);
|
|
|
|
const setIsLoadingRef = useRef(commandHistoryContext.setIsLoading);
|
|
const setCommandHistoryContextRef = useRef(
|
|
commandHistoryContext.setCommandHistory,
|
|
);
|
|
|
|
useEffect(() => {
|
|
setIsLoadingRef.current = commandHistoryContext.setIsLoading;
|
|
setCommandHistoryContextRef.current =
|
|
commandHistoryContext.setCommandHistory;
|
|
}, [
|
|
commandHistoryContext.setIsLoading,
|
|
commandHistoryContext.setCommandHistory,
|
|
]);
|
|
|
|
useEffect(() => {
|
|
if (showHistoryDialog && hostConfig.id) {
|
|
setIsLoadingHistory(true);
|
|
setIsLoadingRef.current(true);
|
|
getCommandHistory(hostConfig.id!)
|
|
.then((history) => {
|
|
setCommandHistory(history);
|
|
setCommandHistoryContextRef.current(history);
|
|
})
|
|
.catch((error) => {
|
|
console.error("Failed to load command history:", error);
|
|
setCommandHistory([]);
|
|
setCommandHistoryContextRef.current([]);
|
|
})
|
|
.finally(() => {
|
|
setIsLoadingHistory(false);
|
|
setIsLoadingRef.current(false);
|
|
});
|
|
}
|
|
}, [showHistoryDialog, hostConfig.id]);
|
|
|
|
useEffect(() => {
|
|
const autocompleteEnabled =
|
|
localStorage.getItem("commandAutocomplete") === "true";
|
|
|
|
if (hostConfig.id && autocompleteEnabled) {
|
|
getCommandHistory(hostConfig.id!)
|
|
.then((history) => {
|
|
autocompleteHistory.current = history;
|
|
})
|
|
.catch((error) => {
|
|
console.error("Failed to load autocomplete history:", error);
|
|
autocompleteHistory.current = [];
|
|
});
|
|
} else {
|
|
autocompleteHistory.current = [];
|
|
}
|
|
}, [hostConfig.id]);
|
|
|
|
useEffect(() => {
|
|
showAutocompleteRef.current = showAutocomplete;
|
|
}, [showAutocomplete]);
|
|
|
|
useEffect(() => {
|
|
autocompleteSuggestionsRef.current = autocompleteSuggestions;
|
|
}, [autocompleteSuggestions]);
|
|
|
|
useEffect(() => {
|
|
autocompleteSelectedIndexRef.current = autocompleteSelectedIndex;
|
|
}, [autocompleteSelectedIndex]);
|
|
|
|
const activityLoggingRef = useRef(false);
|
|
const passwordPromptShownRef = useRef(false);
|
|
const alternateScreenModeRef = useRef(false);
|
|
|
|
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 lastFittedSizeRef = useRef<{ cols: number; rows: number } | null>(
|
|
null,
|
|
);
|
|
const terminalFontSizeRef = useRef(config.fontSize);
|
|
const DEBOUNCE_MS = 140;
|
|
|
|
const logTerminalActivity = async () => {
|
|
if (
|
|
!hostConfig.id ||
|
|
activityLoggedRef.current ||
|
|
activityLoggingRef.current
|
|
) {
|
|
return;
|
|
}
|
|
|
|
activityLoggingRef.current = true;
|
|
activityLoggedRef.current = true;
|
|
|
|
try {
|
|
const hostName =
|
|
hostConfig.name || `${hostConfig.username}@${hostConfig.ip}`;
|
|
await logActivity("terminal", hostConfig.id, hostName);
|
|
} catch (err) {
|
|
console.warn("Failed to log terminal activity:", err);
|
|
activityLoggedRef.current = false;
|
|
} finally {
|
|
activityLoggingRef.current = false;
|
|
}
|
|
};
|
|
|
|
useEffect(() => {
|
|
isVisibleRef.current = isVisible;
|
|
}, [isVisible]);
|
|
|
|
useEffect(() => {
|
|
// One-shot: historical code polled every 5s but only ever flipped false→true.
|
|
setIsAuthenticated(true);
|
|
}, []);
|
|
|
|
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 ||
|
|
!isVisible ||
|
|
isFittingRef.current
|
|
) {
|
|
return;
|
|
}
|
|
|
|
isFittingRef.current = true;
|
|
|
|
try {
|
|
fitAddonRef.current.fit();
|
|
if (terminal && terminal.cols > 0 && terminal.rows > 0) {
|
|
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 {
|
|
isFittingRef.current = false;
|
|
}
|
|
}
|
|
|
|
function changeTerminalFontSize(direction: -1 | 1) {
|
|
const currentFontSize =
|
|
terminal.options.fontSize ??
|
|
terminalFontSizeRef.current ??
|
|
DEFAULT_TERMINAL_CONFIG.fontSize;
|
|
const nextFontSize = getNextTerminalFontSize(currentFontSize, direction);
|
|
|
|
if (nextFontSize === currentFontSize) {
|
|
return;
|
|
}
|
|
|
|
terminalFontSizeRef.current = nextFontSize;
|
|
terminal.options.fontSize = nextFontSize;
|
|
performFit();
|
|
hardRefresh();
|
|
}
|
|
|
|
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("");
|
|
if (onClose) onClose();
|
|
}
|
|
|
|
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("");
|
|
if (onClose) onClose();
|
|
}
|
|
|
|
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);
|
|
if (onClose) onClose();
|
|
}
|
|
|
|
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);
|
|
if (onClose) onClose();
|
|
}
|
|
|
|
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 formatTerminalOutput(output: string): string {
|
|
const alternateScreen = updateAlternateScreenMode(
|
|
output,
|
|
alternateScreenModeRef.current,
|
|
);
|
|
alternateScreenModeRef.current = alternateScreen.isActive;
|
|
|
|
const syntaxHighlightingEnabled =
|
|
hostConfig.terminalConfig?.syntaxHighlighting !== false;
|
|
if (
|
|
!syntaxHighlightingEnabled ||
|
|
alternateScreen.sawSequence ||
|
|
alternateScreen.isActive
|
|
) {
|
|
return output;
|
|
}
|
|
|
|
return highlightTerminalOutput(
|
|
output,
|
|
hostConfig.terminalConfig?.syntaxHighlightingOptions,
|
|
);
|
|
}
|
|
|
|
async function resolvePasswordForPrompt(isSudoPrompt: boolean) {
|
|
let passwordToFill = isSudoPrompt
|
|
? hostConfig.terminalConfig?.sudoPassword || hostConfig.password
|
|
: hostConfig.password || hostConfig.terminalConfig?.sudoPassword;
|
|
|
|
if (!passwordToFill && hostConfig.id) {
|
|
passwordToFill = isSudoPrompt
|
|
? (await getHostPassword(hostConfig.id, "sudoPassword")) ||
|
|
(await getHostPassword(hostConfig.id, "password")) ||
|
|
undefined
|
|
: (await getHostPassword(hostConfig.id, "password")) ||
|
|
(await getHostPassword(hostConfig.id, "sudoPassword")) ||
|
|
undefined;
|
|
}
|
|
|
|
return passwordToFill;
|
|
}
|
|
|
|
function maybeOfferPasswordFill(strippedData: string) {
|
|
const passwordPromptPattern =
|
|
/(?:\[sudo\][^\n\r]*:\s*$|sudo:[^\n\r]*password[^\n\r]*required|password for [^\n\r]*:\s*$|Password:\s*$|password:\s*$)/im;
|
|
if (!passwordPromptPattern.test(strippedData)) return;
|
|
|
|
const hasStoredPassword =
|
|
hostConfig.terminalConfig?.sudoPassword ||
|
|
hostConfig.password ||
|
|
hostConfig.hasSudoPassword ||
|
|
hostConfig.hasPassword;
|
|
if (!hasStoredPassword || passwordPromptShownRef.current) return;
|
|
|
|
passwordPromptShownRef.current = true;
|
|
const isSudoPrompt = /(?:\[sudo\]|sudo:)/i.test(strippedData);
|
|
|
|
confirmWithToast(
|
|
t("terminal.passwordPromptFillTitle"),
|
|
async () => {
|
|
const passwordToFill = await resolvePasswordForPrompt(isSudoPrompt);
|
|
if (
|
|
passwordToFill &&
|
|
webSocketRef.current &&
|
|
webSocketRef.current.readyState === WebSocket.OPEN
|
|
) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({
|
|
type: "input",
|
|
data: passwordToFill + "\n",
|
|
}),
|
|
);
|
|
}
|
|
setTimeout(() => {
|
|
passwordPromptShownRef.current = false;
|
|
}, 3000);
|
|
},
|
|
t("common.confirm"),
|
|
t("common.cancel"),
|
|
{ confirmOnEnter: true },
|
|
);
|
|
setTimeout(() => {
|
|
passwordPromptShownRef.current = false;
|
|
}, 15000);
|
|
}
|
|
|
|
useImperativeHandle(
|
|
ref,
|
|
() => ({
|
|
disconnect: () => {
|
|
isUnmountingRef.current = true;
|
|
shouldNotReconnectRef.current = true;
|
|
isReconnectingRef.current = false;
|
|
if (pingIntervalRef.current) {
|
|
clearInterval(pingIntervalRef.current);
|
|
pingIntervalRef.current = null;
|
|
}
|
|
if (pongTimeoutRef.current) {
|
|
clearTimeout(pongTimeoutRef.current);
|
|
pongTimeoutRef.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;
|
|
}
|
|
if (webSocketRef.current?.readyState === WebSocket.OPEN) {
|
|
webSocketRef.current.send(JSON.stringify({ type: "disconnect" }));
|
|
}
|
|
sessionIdRef.current = null;
|
|
webSocketRef.current?.close();
|
|
setIsConnected(false);
|
|
setIsConnecting(false);
|
|
},
|
|
reconnect: () => {
|
|
isUnmountingRef.current = false;
|
|
shouldNotReconnectRef.current = false;
|
|
isReconnectingRef.current = false;
|
|
isConnectingRef.current = false;
|
|
reconnectAttempts.current = 0;
|
|
wasDisconnectedBySSH.current = false;
|
|
wasConnectedRef.current = false;
|
|
updateConnectionError(null);
|
|
setShowDisconnectedOverlay(false);
|
|
if (terminal) {
|
|
terminal.clear();
|
|
const cols = terminal.cols;
|
|
const rows = terminal.rows;
|
|
connectToHost(cols, rows);
|
|
}
|
|
},
|
|
isConnected: () => isConnected,
|
|
fit: () => {
|
|
if (!fitAddonRef.current || !terminal || isFittingRef.current) return;
|
|
isFittingRef.current = true;
|
|
try {
|
|
fitAddonRef.current.fit();
|
|
if (terminal.cols > 0 && terminal.rows > 0) {
|
|
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 {
|
|
isFittingRef.current = false;
|
|
}
|
|
},
|
|
focus: () => terminal?.focus(),
|
|
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(),
|
|
getApplicationCursorKeysMode: () =>
|
|
terminal?.modes?.applicationCursorKeysMode ?? false,
|
|
openFileManager: () => {
|
|
if (webSocketRef.current?.readyState === WebSocket.OPEN) {
|
|
webSocketRef.current.send(JSON.stringify({ type: "get_cwd" }));
|
|
} else {
|
|
onOpenFileManager?.("/");
|
|
}
|
|
},
|
|
}),
|
|
[isConnected, terminal],
|
|
);
|
|
|
|
function getUseRightClickCopyPaste() {
|
|
return getCookie("rightClickCopyPaste") !== "false";
|
|
}
|
|
|
|
function attemptReconnection() {
|
|
if (
|
|
isUnmountingRef.current ||
|
|
shouldNotReconnectRef.current ||
|
|
isReconnectingRef.current ||
|
|
isConnectingRef.current ||
|
|
wasDisconnectedBySSH.current ||
|
|
reconnectTimeoutRef.current !== null
|
|
) {
|
|
return;
|
|
}
|
|
|
|
if (reconnectAttempts.current >= maxReconnectAttempts) {
|
|
setIsConnecting(false);
|
|
shouldNotReconnectRef.current = true;
|
|
setShowDisconnectedOverlay(true);
|
|
addLog({
|
|
type: "error",
|
|
stage: "connection",
|
|
message: t("terminal.maxReconnectAttemptsReached"),
|
|
});
|
|
return;
|
|
}
|
|
|
|
isReconnectingRef.current = true;
|
|
|
|
if (terminal && !isAttachingSessionRef.current) {
|
|
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) {
|
|
if (!isAttachingSessionRef.current) {
|
|
terminal.clear();
|
|
}
|
|
const cols = terminal.cols;
|
|
const rows = terminal.rows;
|
|
connectToHost(cols, rows);
|
|
}
|
|
|
|
isReconnectingRef.current = false;
|
|
}, delay);
|
|
}
|
|
|
|
async function connectToHost(cols: number, rows: number) {
|
|
if (isConnectingRef.current) {
|
|
return;
|
|
}
|
|
|
|
isConnectingRef.current = true;
|
|
connectionAttemptIdRef.current++;
|
|
wasConnectedRef.current = false;
|
|
|
|
if (!isReconnectingRef.current) {
|
|
reconnectAttempts.current = 0;
|
|
shouldNotReconnectRef.current = false;
|
|
}
|
|
|
|
const isDev =
|
|
!isElectron() &&
|
|
process.env.NODE_ENV === "development" &&
|
|
(window.location.port === "3000" ||
|
|
window.location.port === "5173" ||
|
|
window.location.port === "");
|
|
|
|
let baseWsUrl: string;
|
|
|
|
if (isDev) {
|
|
baseWsUrl = `${window.location.protocol === "https:" ? "wss" : "ws"}://localhost:30002`;
|
|
} else if (isElectron()) {
|
|
let configuredUrl = (window as { configuredServerUrl?: string | null })
|
|
.configuredServerUrl;
|
|
|
|
if (!configuredUrl && !isEmbeddedMode()) {
|
|
try {
|
|
const serverConfig = await getServerConfig();
|
|
configuredUrl = serverConfig?.serverUrl || null;
|
|
if (configuredUrl) {
|
|
(
|
|
window as Window &
|
|
typeof globalThis & {
|
|
configuredServerUrl?: string | null;
|
|
}
|
|
).configuredServerUrl = configuredUrl;
|
|
}
|
|
} catch (error) {
|
|
console.error("Failed to resolve Electron server URL:", error);
|
|
}
|
|
}
|
|
|
|
if (isEmbeddedMode()) {
|
|
baseWsUrl = "ws://127.0.0.1:30002";
|
|
const storedJwt = localStorage.getItem("jwt");
|
|
if (storedJwt) {
|
|
baseWsUrl += `?token=${encodeURIComponent(storedJwt)}`;
|
|
}
|
|
} else if (!configuredUrl) {
|
|
console.error("No configured server URL available for Electron SSH");
|
|
setIsConnected(false);
|
|
setIsConnecting(false);
|
|
updateConnectionError(t("errors.failedToLoadServer"));
|
|
isConnectingRef.current = false;
|
|
return;
|
|
} else {
|
|
const wsProtocol = configuredUrl.startsWith("https://")
|
|
? "wss://"
|
|
: "ws://";
|
|
const wsHost = configuredUrl
|
|
.replace(/^https?:\/\//, "")
|
|
.replace(/\/$/, "");
|
|
baseWsUrl = `${wsProtocol}${wsHost}/ssh/websocket/`;
|
|
const storedJwt = localStorage.getItem("jwt");
|
|
if (storedJwt) {
|
|
baseWsUrl += `?token=${encodeURIComponent(storedJwt)}`;
|
|
}
|
|
}
|
|
} else {
|
|
baseWsUrl = `${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", () => {
|
|
alternateScreenModeRef.current = false;
|
|
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);
|
|
|
|
currentHostIdRef.current = hostConfig.id;
|
|
currentHostConfigRef.current = hostConfig;
|
|
|
|
// Consume the pending restored session ID once; retries get null so they create fresh connections
|
|
const restoredSessionId = pendingRestoredSessionIdRef.current;
|
|
pendingRestoredSessionIdRef.current = null;
|
|
|
|
if (restoredSessionId) {
|
|
sessionIdRef.current = restoredSessionId;
|
|
isAttachingSessionRef.current = true;
|
|
|
|
ws.send(
|
|
JSON.stringify({
|
|
type: "attachSession",
|
|
data: {
|
|
sessionId: restoredSessionId,
|
|
cols,
|
|
rows,
|
|
tabInstanceId: hostConfig.instanceId,
|
|
},
|
|
}),
|
|
);
|
|
} else {
|
|
isAttachingSessionRef.current = false;
|
|
ws.send(
|
|
JSON.stringify({
|
|
type: "connectToHost",
|
|
data: {
|
|
cols,
|
|
rows,
|
|
hostConfig,
|
|
initialPath,
|
|
executeCommand,
|
|
tmuxAttachSession,
|
|
},
|
|
}),
|
|
);
|
|
}
|
|
terminal.onData((data) => {
|
|
if (data === "\r" || data === "\n") {
|
|
const currentCmd = getCurrentCommand().trim();
|
|
const termixMatch = currentCmd.match(/^termix\s+(.+)$/);
|
|
if (termixMatch && onOpenFileInEditor) {
|
|
const filePath = termixMatch[1].trim();
|
|
trackInput(data);
|
|
terminal.write("\r\n");
|
|
if (ws.readyState === WebSocket.OPEN) {
|
|
ws.send(
|
|
JSON.stringify({
|
|
type: "open_file_in_editor",
|
|
path: filePath,
|
|
}),
|
|
);
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
trackInput(data);
|
|
ws.send(JSON.stringify({ type: "input", data }));
|
|
});
|
|
|
|
pongReceivedRef.current = true;
|
|
pingIntervalRef.current = setInterval(() => {
|
|
if (ws.readyState === WebSocket.OPEN) {
|
|
if (!pongReceivedRef.current) {
|
|
console.warn(
|
|
"[WebSocket] Pong timeout - connection appears dead, closing",
|
|
);
|
|
ws.close();
|
|
return;
|
|
}
|
|
pongReceivedRef.current = false;
|
|
ws.send(JSON.stringify({ type: "ping" }));
|
|
}
|
|
}, 30000);
|
|
});
|
|
|
|
ws.addEventListener("message", (event) => {
|
|
try {
|
|
const msg = JSON.parse(event.data);
|
|
if (msg.type === "pong") {
|
|
pongReceivedRef.current = true;
|
|
return;
|
|
}
|
|
if (msg.type === "data") {
|
|
if (typeof msg.data === "string") {
|
|
if (showAutocompleteRef.current) {
|
|
showAutocompleteRef.current = false;
|
|
setShowAutocomplete(false);
|
|
setAutocompleteSuggestions([]);
|
|
currentAutocompleteCommand.current = "";
|
|
}
|
|
|
|
terminal.write(formatTerminalOutput(msg.data));
|
|
// Strip ANSI escape codes before testing — newer sudo versions (Ubuntu 26.04+)
|
|
// emit colored prompts with embedded escape sequences that break the regex.
|
|
const strippedData = msg.data.replace(
|
|
/\x1b(?:[@-Z\\-_]|\[[0-9;?>=!]*[@-~])/g,
|
|
"",
|
|
);
|
|
maybeOfferPasswordFill(strippedData);
|
|
} else {
|
|
const stringData = String(msg.data);
|
|
terminal.write(formatTerminalOutput(stringData));
|
|
}
|
|
} 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") {
|
|
opksshFailedRef.current = false;
|
|
vaultFailedRef.current = false;
|
|
wasConnectedRef.current = true;
|
|
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;
|
|
|
|
logTerminalActivity();
|
|
|
|
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 + "\n",
|
|
}),
|
|
);
|
|
}
|
|
} 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;
|
|
setIsConnected(false);
|
|
setIsConnecting(false);
|
|
shouldNotReconnectRef.current = true;
|
|
if (onClose) {
|
|
onClose();
|
|
}
|
|
} else if (msg.type === "disconnected") {
|
|
wasDisconnectedBySSH.current = true;
|
|
shouldNotReconnectRef.current = true;
|
|
setIsConnected(false);
|
|
setIsConnecting(false);
|
|
if (msg.graceful) {
|
|
wasConnectedRef.current = false;
|
|
if (onClose) onClose();
|
|
} else if (wasConnectedRef.current) {
|
|
wasConnectedRef.current = false;
|
|
setShowDisconnectedOverlay(true);
|
|
} else if (!connectionErrorRef.current) {
|
|
updateConnectionError(
|
|
msg.message || t("terminal.connectionRejected"),
|
|
);
|
|
}
|
|
} 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 === "totp_retry") {
|
|
// Existing prompt remains visible while the backend asks for another code.
|
|
} 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 === "opkssh_auth_required") {
|
|
if (connectionTimeoutRef.current) {
|
|
clearTimeout(connectionTimeoutRef.current);
|
|
connectionTimeoutRef.current = null;
|
|
}
|
|
if (opksshFailedRef.current) {
|
|
setOpksshDialog(null);
|
|
if (opksshTimeoutRef.current) {
|
|
clearTimeout(opksshTimeoutRef.current);
|
|
opksshTimeoutRef.current = null;
|
|
}
|
|
updateConnectionError(t("terminal.opksshAuthFailed"));
|
|
addLog({
|
|
type: "error",
|
|
stage: "auth",
|
|
message: t("terminal.opksshAuthFailed"),
|
|
});
|
|
} else {
|
|
opksshFailedRef.current = true;
|
|
if (webSocketRef.current) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({
|
|
type: "opkssh_start_auth",
|
|
data: { hostId: msg.hostId },
|
|
}),
|
|
);
|
|
}
|
|
}
|
|
} else if (msg.type === "vault_auth_required") {
|
|
if (connectionTimeoutRef.current) {
|
|
clearTimeout(connectionTimeoutRef.current);
|
|
connectionTimeoutRef.current = null;
|
|
}
|
|
if (vaultFailedRef.current) {
|
|
setVaultDialog({
|
|
stage: "error",
|
|
error: t("terminal.vaultAuthFailed"),
|
|
});
|
|
updateConnectionError(t("terminal.vaultAuthFailed"));
|
|
addLog({
|
|
type: "error",
|
|
stage: "auth",
|
|
message: t("terminal.vaultAuthFailed"),
|
|
});
|
|
} else {
|
|
vaultFailedRef.current = true;
|
|
webSocketRef.current?.send(
|
|
JSON.stringify({
|
|
type: "vault_start_auth",
|
|
data: { hostId: msg.hostId },
|
|
}),
|
|
);
|
|
}
|
|
} else if (msg.type === "vault_auth_url") {
|
|
if (connectionErrorRef.current) return;
|
|
try {
|
|
vaultPopupRef.current = window.open(
|
|
msg.url,
|
|
"termix-vault-oidc",
|
|
"width=540,height=720",
|
|
);
|
|
} catch {
|
|
vaultPopupRef.current = null;
|
|
}
|
|
setVaultDialog({ stage: "waiting" });
|
|
if (vaultTimeoutRef.current) clearTimeout(vaultTimeoutRef.current);
|
|
vaultTimeoutRef.current = setTimeout(() => {
|
|
setVaultDialog(null);
|
|
webSocketRef.current?.close();
|
|
}, 300000);
|
|
} else if (msg.type === "vault_completed") {
|
|
if (vaultTimeoutRef.current) {
|
|
clearTimeout(vaultTimeoutRef.current);
|
|
vaultTimeoutRef.current = null;
|
|
}
|
|
try {
|
|
vaultPopupRef.current?.close();
|
|
} catch {
|
|
// popup may already be closed
|
|
}
|
|
setVaultDialog(null);
|
|
if (webSocketRef.current && terminal) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({
|
|
type: "vault_auth_completed",
|
|
data: {
|
|
hostId: currentHostIdRef.current,
|
|
cols: terminal.cols || 80,
|
|
rows: terminal.rows || 24,
|
|
hostConfig: currentHostConfigRef.current,
|
|
},
|
|
}),
|
|
);
|
|
}
|
|
} else if (msg.type === "vault_error") {
|
|
if (connectionErrorRef.current) return;
|
|
vaultFailedRef.current = true;
|
|
if (vaultTimeoutRef.current) {
|
|
clearTimeout(vaultTimeoutRef.current);
|
|
vaultTimeoutRef.current = null;
|
|
}
|
|
try {
|
|
vaultPopupRef.current?.close();
|
|
} catch {
|
|
// popup may already be closed
|
|
}
|
|
setVaultDialog({ stage: "error", error: msg.error });
|
|
setIsConnecting(false);
|
|
} else if (msg.type === "opkssh_status") {
|
|
if (connectionErrorRef.current) return;
|
|
if (msg.stage === "chooser") {
|
|
setOpksshDialog({
|
|
isOpen: true,
|
|
authUrl: msg.url || "",
|
|
requestId: msg.requestId || "",
|
|
stage: "chooser",
|
|
providers: msg.providers,
|
|
});
|
|
if (opksshTimeoutRef.current) {
|
|
clearTimeout(opksshTimeoutRef.current);
|
|
}
|
|
opksshTimeoutRef.current = setTimeout(() => {
|
|
setOpksshDialog(null);
|
|
if (webSocketRef.current) {
|
|
webSocketRef.current.close();
|
|
}
|
|
}, 300000);
|
|
} else {
|
|
setOpksshDialog((prev) =>
|
|
prev ? { ...prev, stage: msg.stage } : null,
|
|
);
|
|
}
|
|
} else if (msg.type === "opkssh_completed") {
|
|
if (opksshTimeoutRef.current) {
|
|
clearTimeout(opksshTimeoutRef.current);
|
|
opksshTimeoutRef.current = null;
|
|
}
|
|
setOpksshDialog(null);
|
|
if (webSocketRef.current && terminal) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({
|
|
type: "opkssh_auth_completed",
|
|
data: {
|
|
hostId: currentHostIdRef.current,
|
|
cols: terminal.cols || 80,
|
|
rows: terminal.rows || 24,
|
|
hostConfig: currentHostConfigRef.current,
|
|
},
|
|
}),
|
|
);
|
|
}
|
|
} else if (msg.type === "opkssh_error") {
|
|
if (connectionErrorRef.current) return;
|
|
opksshFailedRef.current = true;
|
|
if (opksshDialog) {
|
|
setOpksshDialog((prev) =>
|
|
prev ? { ...prev, stage: "error", error: msg.error } : null,
|
|
);
|
|
} else {
|
|
setOpksshDialog({
|
|
isOpen: true,
|
|
authUrl: "",
|
|
requestId: msg.requestId || "",
|
|
stage: "error",
|
|
error: msg.error,
|
|
});
|
|
}
|
|
setIsConnecting(false);
|
|
} else if (msg.type === "opkssh_timeout") {
|
|
if (connectionErrorRef.current) return;
|
|
opksshFailedRef.current = true;
|
|
if (opksshDialog) {
|
|
setOpksshDialog((prev) =>
|
|
prev
|
|
? {
|
|
...prev,
|
|
stage: "error",
|
|
error: t("terminal.opksshTimeout"),
|
|
}
|
|
: null,
|
|
);
|
|
} else {
|
|
setOpksshDialog({
|
|
isOpen: true,
|
|
authUrl: "",
|
|
requestId: msg.requestId || "",
|
|
stage: "error",
|
|
error: t("terminal.opksshTimeout"),
|
|
});
|
|
}
|
|
setIsConnecting(false);
|
|
} else if (msg.type === "opkssh_config_error") {
|
|
setOpksshDialog({
|
|
isOpen: true,
|
|
authUrl: "",
|
|
requestId: msg.requestId || "",
|
|
stage: "error",
|
|
error: msg.instructions || msg.error,
|
|
});
|
|
} else if (msg.type === "keyboard_interactive_available") {
|
|
setKeyboardInteractiveDetected(true);
|
|
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 === "cwd") {
|
|
onOpenFileManager?.(msg.path as string);
|
|
} else if (msg.type === "open_file_in_editor") {
|
|
onOpenFileInEditor?.(msg.path as string);
|
|
} else if (msg.type === "passphrase_required") {
|
|
setShowPassphraseDialog(true);
|
|
setIsConnecting(false);
|
|
if (connectionTimeoutRef.current) {
|
|
clearTimeout(connectionTimeoutRef.current);
|
|
connectionTimeoutRef.current = null;
|
|
}
|
|
} else if (msg.type === "host_key_verification_required") {
|
|
setHostKeyVerification({
|
|
isOpen: true,
|
|
scenario: "new",
|
|
data: msg.data,
|
|
});
|
|
if (connectionTimeoutRef.current) {
|
|
clearTimeout(connectionTimeoutRef.current);
|
|
connectionTimeoutRef.current = null;
|
|
}
|
|
} else if (msg.type === "host_key_changed") {
|
|
setHostKeyVerification({
|
|
isOpen: true,
|
|
scenario: "changed",
|
|
data: msg.data,
|
|
});
|
|
if (connectionTimeoutRef.current) {
|
|
clearTimeout(connectionTimeoutRef.current);
|
|
connectionTimeoutRef.current = null;
|
|
}
|
|
} else if (msg.type === "sessionCreated") {
|
|
sessionIdRef.current = msg.sessionId;
|
|
if (hostConfig.instanceId) {
|
|
import("@/main-axios").then(({ patchOpenTab }) => {
|
|
patchOpenTab(hostConfig.instanceId!, {
|
|
backendSessionId: msg.sessionId,
|
|
}).catch(() => {});
|
|
});
|
|
}
|
|
} else if (msg.type === "sessionAttached") {
|
|
isAttachingSessionRef.current = false;
|
|
opksshFailedRef.current = false;
|
|
vaultFailedRef.current = false;
|
|
wasConnectedRef.current = true;
|
|
setIsConnected(true);
|
|
setIsConnecting(false);
|
|
isConnectingRef.current = false;
|
|
shouldNotReconnectRef.current = false;
|
|
updateConnectionError(null);
|
|
if (connectionTimeoutRef.current) {
|
|
clearTimeout(connectionTimeoutRef.current);
|
|
connectionTimeoutRef.current = null;
|
|
}
|
|
if (reconnectTimeoutRef.current) {
|
|
clearTimeout(reconnectTimeoutRef.current);
|
|
reconnectTimeoutRef.current = null;
|
|
}
|
|
reconnectAttempts.current = 0;
|
|
isReconnectingRef.current = false;
|
|
|
|
logTerminalActivity();
|
|
|
|
addLog({
|
|
type: "success",
|
|
stage: "connection",
|
|
message: t("terminal.reconnected"),
|
|
});
|
|
} else if (msg.type === "sessionExpired") {
|
|
isAttachingSessionRef.current = false;
|
|
sessionIdRef.current = null;
|
|
wasSessionExpiredRef.current = true;
|
|
if (hostConfig.instanceId) {
|
|
import("@/main-axios").then(({ patchOpenTab }) => {
|
|
patchOpenTab(hostConfig.instanceId!, {
|
|
backendSessionId: null,
|
|
}).catch(() => {});
|
|
});
|
|
}
|
|
if (webSocketRef.current) {
|
|
webSocketRef.current.close();
|
|
}
|
|
} else if (msg.type === "sessionTakenOver") {
|
|
sessionIdRef.current = null;
|
|
|
|
if (terminal) {
|
|
terminal.clear();
|
|
}
|
|
setIsConnected(false);
|
|
setIsConnecting(true);
|
|
|
|
addLog({
|
|
type: "warning",
|
|
stage: "connection",
|
|
message: t("terminal.sessionTakenOver"),
|
|
});
|
|
|
|
const cols = terminal?.cols || 80;
|
|
const rows = terminal?.rows || 24;
|
|
connectToHost(cols, rows);
|
|
} else if (msg.type === "tmux_sessions_available") {
|
|
setTmuxSessionPicker({
|
|
sessions: msg.sessions,
|
|
});
|
|
} else if (
|
|
msg.type === "tmux_session_created" ||
|
|
msg.type === "tmux_session_attached"
|
|
) {
|
|
const sessionName =
|
|
typeof msg.sessionName === "string" ? msg.sessionName : "";
|
|
tmuxSessionNameRef.current = sessionName || "(active)";
|
|
setIsTmuxAttached(true);
|
|
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 === "tmux_detached") {
|
|
tmuxSessionNameRef.current = null;
|
|
setIsTmuxAttached(false);
|
|
toast.info(t("terminal.tmuxDetached"), { duration: 3000 });
|
|
} 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("WebSocket message handler error:", error);
|
|
}
|
|
});
|
|
|
|
const currentAttemptId = connectionAttemptIdRef.current;
|
|
|
|
ws.addEventListener("close", (event) => {
|
|
if (currentAttemptId !== connectionAttemptIdRef.current) {
|
|
return;
|
|
}
|
|
|
|
setIsConnected(false);
|
|
isConnectingRef.current = false;
|
|
|
|
if (pingIntervalRef.current) {
|
|
clearInterval(pingIntervalRef.current);
|
|
pingIntervalRef.current = null;
|
|
}
|
|
|
|
if (pongTimeoutRef.current) {
|
|
clearTimeout(pongTimeoutRef.current);
|
|
pongTimeoutRef.current = null;
|
|
}
|
|
|
|
if (totpTimeoutRef.current) {
|
|
clearTimeout(totpTimeoutRef.current);
|
|
totpTimeoutRef.current = null;
|
|
}
|
|
|
|
if (wasSessionExpiredRef.current) {
|
|
wasSessionExpiredRef.current = false;
|
|
const cols = terminal?.cols || 80;
|
|
const rows = terminal?.rows || 24;
|
|
connectToHost(cols, rows);
|
|
return;
|
|
}
|
|
|
|
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 (
|
|
!wasConnectedRef.current &&
|
|
!isAttachingSessionRef.current &&
|
|
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 (pingIntervalRef.current) {
|
|
clearInterval(pingIntervalRef.current);
|
|
pingIntervalRef.current = null;
|
|
}
|
|
|
|
if (totpTimeoutRef.current) {
|
|
clearTimeout(totpTimeoutRef.current);
|
|
totpTimeoutRef.current = null;
|
|
}
|
|
});
|
|
}
|
|
|
|
async function writeTextToClipboard(text: string): Promise<boolean> {
|
|
const ok = await copyToClipboard(text);
|
|
if (!ok) toast.error(t("terminal.clipboardWriteFailed"));
|
|
return ok;
|
|
}
|
|
|
|
async function readTextFromClipboard(): Promise<string> {
|
|
try {
|
|
if (window.electronClipboard) {
|
|
return window.electronClipboard.readText();
|
|
}
|
|
if (navigator.clipboard && navigator.clipboard.readText) {
|
|
return await navigator.clipboard.readText();
|
|
}
|
|
} catch {
|
|
// fall through
|
|
}
|
|
if (window.location.protocol !== "https:" && !isElectron()) {
|
|
toast.error(t("terminal.clipboardHttpWarning"));
|
|
}
|
|
return "";
|
|
}
|
|
|
|
const handleSelectCommand = useCallback(
|
|
(command: string) => {
|
|
if (!terminal || !webSocketRef.current) return;
|
|
|
|
for (const char of command) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({ type: "input", data: char }),
|
|
);
|
|
}
|
|
|
|
setTimeout(() => {
|
|
terminal.focus();
|
|
}, 100);
|
|
},
|
|
[terminal],
|
|
);
|
|
|
|
useEffect(() => {
|
|
commandHistoryContext.setOnSelectCommand(handleSelectCommand);
|
|
}, [handleSelectCommand]);
|
|
|
|
const handleAutocompleteSelect = useCallback(
|
|
(selectedCommand: string) => {
|
|
if (!webSocketRef.current) return;
|
|
|
|
const currentCmd = currentAutocompleteCommand.current;
|
|
const completion = selectedCommand.substring(currentCmd.length);
|
|
|
|
for (const char of completion) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({ type: "input", data: char }),
|
|
);
|
|
}
|
|
|
|
updateCurrentCommand(selectedCommand);
|
|
|
|
setShowAutocomplete(false);
|
|
setAutocompleteSuggestions([]);
|
|
currentAutocompleteCommand.current = "";
|
|
|
|
setTimeout(() => {
|
|
terminal?.focus();
|
|
}, 50);
|
|
},
|
|
[terminal, updateCurrentCommand],
|
|
);
|
|
|
|
const handleDeleteCommand = useCallback(
|
|
async (command: string) => {
|
|
if (!hostConfig.id) return;
|
|
|
|
try {
|
|
await deleteCommandFromHistory(hostConfig.id, command);
|
|
|
|
setCommandHistory((prev) => {
|
|
const newHistory = prev.filter((cmd) => cmd !== command);
|
|
setCommandHistoryContextRef.current(newHistory);
|
|
return newHistory;
|
|
});
|
|
|
|
autocompleteHistory.current = autocompleteHistory.current.filter(
|
|
(cmd) => cmd !== command,
|
|
);
|
|
} catch (error) {
|
|
console.error("Failed to delete command from history:", error);
|
|
}
|
|
},
|
|
[hostConfig.id],
|
|
);
|
|
|
|
useEffect(() => {
|
|
commandHistoryContext.setOnDeleteCommand(handleDeleteCommand);
|
|
}, [handleDeleteCommand]);
|
|
|
|
// Separate theme and options updates to avoid terminal re-initialization flashes
|
|
useEffect(() => {
|
|
if (!terminal) return;
|
|
|
|
const config = {
|
|
...DEFAULT_TERMINAL_CONFIG,
|
|
...hostConfig.terminalConfig,
|
|
};
|
|
|
|
const activeTheme = previewTheme || config.theme;
|
|
const themeColors = resolveTermixThemeColors(
|
|
activeTheme,
|
|
appTheme,
|
|
config.customThemeColors,
|
|
);
|
|
|
|
const fontConfig = TERMINAL_FONTS.find(
|
|
(f) => f.value === config.fontFamily,
|
|
);
|
|
const fontFamily = fontConfig?.fallback || TERMINAL_FONTS[0].fallback;
|
|
|
|
// Update terminal options individually to avoid re-initialization flashes
|
|
terminal.options.cursorBlink = config.cursorBlink;
|
|
terminal.options.cursorStyle = config.cursorStyle;
|
|
terminal.options.scrollback = config.scrollback;
|
|
terminal.options.fontSize = config.fontSize;
|
|
terminalFontSizeRef.current = config.fontSize;
|
|
terminal.options.fontFamily = fontFamily;
|
|
terminal.options.rightClickSelectsWord = config.rightClickSelectsWord;
|
|
terminal.options.fastScrollSensitivity = config.fastScrollSensitivity;
|
|
terminal.options.minimumContrastRatio = config.minimumContrastRatio;
|
|
terminal.options.letterSpacing = config.letterSpacing;
|
|
terminal.options.lineHeight = config.lineHeight;
|
|
terminal.options.bellStyle = config.bellStyle as
|
|
| "none"
|
|
| "sound"
|
|
| "visual"
|
|
| "both";
|
|
|
|
terminal.options.theme = {
|
|
background: config.backgroundImage
|
|
? "transparent"
|
|
: 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,
|
|
};
|
|
|
|
// Ensure terminal is correctly fitted if font-related options change
|
|
if (fitAddonRef.current && isFitted) {
|
|
performFit();
|
|
}
|
|
|
|
// Refresh terminal to apply new theme colors to existing buffer content
|
|
hardRefresh();
|
|
}, [terminal, hostConfig.terminalConfig, previewTheme, appTheme, isFitted]);
|
|
|
|
useEffect(() => {
|
|
if (!terminal || !xtermRef.current) return;
|
|
|
|
const config = {
|
|
...DEFAULT_TERMINAL_CONFIG,
|
|
...hostConfig.terminalConfig,
|
|
};
|
|
|
|
const fontConfig = TERMINAL_FONTS.find(
|
|
(f) => f.value === config.fontFamily,
|
|
);
|
|
const fontFamily = fontConfig?.fallback || TERMINAL_FONTS[0].fallback;
|
|
|
|
const activeTheme = previewTheme || config.theme;
|
|
const themeColors = resolveTermixThemeColors(
|
|
activeTheme,
|
|
appTheme,
|
|
config.customThemeColors,
|
|
);
|
|
|
|
// Set initial options before opening the terminal
|
|
terminal.options = {
|
|
cursorBlink: config.cursorBlink,
|
|
cursorStyle: config.cursorStyle,
|
|
scrollback: config.scrollback,
|
|
fontSize: config.fontSize,
|
|
fontFamily,
|
|
allowTransparency: true, // MUST be set before open()
|
|
convertEol: false,
|
|
macOptionIsMeta: true,
|
|
macOptionClickForcesSelection: false,
|
|
rightClickSelectsWord: config.rightClickSelectsWord,
|
|
fastScrollSensitivity: config.fastScrollSensitivity,
|
|
allowProposedApi: true,
|
|
minimumContrastRatio: config.minimumContrastRatio,
|
|
letterSpacing: config.letterSpacing,
|
|
lineHeight: config.lineHeight,
|
|
bellStyle: config.bellStyle as "none" | "sound" | "visual" | "both",
|
|
theme: {
|
|
background: config.backgroundImage
|
|
? "transparent"
|
|
: 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((_event, uri) => {
|
|
const url =
|
|
uri.startsWith("http://") || uri.startsWith("https://")
|
|
? uri
|
|
: `https://${uri}`;
|
|
|
|
const hostBehavior = hostConfig.terminalConfig?.linkClickBehavior;
|
|
const globalBehavior =
|
|
localStorage.getItem("terminalLinkClickBehavior") ?? "confirm";
|
|
const behavior = hostBehavior ?? globalBehavior;
|
|
|
|
if (behavior === "direct") {
|
|
window.open(url, "_blank");
|
|
} else {
|
|
setLinkClickDialog({ url });
|
|
}
|
|
});
|
|
|
|
fitAddonRef.current = fitAddon;
|
|
terminal.loadAddon(fitAddon);
|
|
terminal.loadAddon(clipboardAddon);
|
|
terminal.loadAddon(unicode11Addon);
|
|
terminal.loadAddon(webLinksAddon);
|
|
|
|
terminal.unicode.activeVersion = "11";
|
|
|
|
terminal.open(xtermRef.current);
|
|
|
|
const xtermTextarea = xtermRef.current.querySelector("textarea");
|
|
if (xtermTextarea) {
|
|
xtermTextarea.setAttribute("autocomplete", "off");
|
|
xtermTextarea.setAttribute("autocorrect", "off");
|
|
xtermTextarea.setAttribute("autocapitalize", "none");
|
|
xtermTextarea.setAttribute("spellcheck", "false");
|
|
xtermTextarea.setAttribute("data-gramm", "false");
|
|
xtermTextarea.setAttribute("data-gramm_editor", "false");
|
|
xtermTextarea.setAttribute("data-enable-grammarly", "false");
|
|
}
|
|
|
|
terminal.onTitleChange((title) => {
|
|
if (title) onTitleChange?.(title);
|
|
});
|
|
document.fonts.ready.then(() => {
|
|
terminal.refresh(0, terminal.rows - 1);
|
|
fitAddon.fit();
|
|
});
|
|
|
|
terminal.attachCustomWheelEventHandler((ev) => {
|
|
if (ev.ctrlKey || ev.metaKey) {
|
|
changeTerminalFontSize(ev.deltaY < 0 ? 1 : -1);
|
|
return false;
|
|
}
|
|
|
|
const cfg = {
|
|
...DEFAULT_TERMINAL_CONFIG,
|
|
...hostConfig.terminalConfig,
|
|
};
|
|
const mod = cfg.fastScrollModifier;
|
|
const modHeld =
|
|
(mod === "alt" && ev.altKey) ||
|
|
(mod === "ctrl" && ev.ctrlKey) ||
|
|
(mod === "shift" && ev.shiftKey);
|
|
if (modHeld) {
|
|
const lines = Math.round(
|
|
(Math.abs(ev.deltaY) / 100) * (cfg.fastScrollSensitivity ?? 5),
|
|
);
|
|
terminal.scrollLines(ev.deltaY > 0 ? lines : -lines);
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
|
|
fitAddonRef.current?.fit();
|
|
// Double-rAF ensures layout is fully settled (fonts, flexbox, etc.) before
|
|
// committing the fitted size, preventing the "terminal too short" glitch.
|
|
requestAnimationFrame(() => {
|
|
requestAnimationFrame(() => {
|
|
fitAddonRef.current?.fit();
|
|
setIsFitted(true);
|
|
});
|
|
});
|
|
|
|
const element = xtermRef.current;
|
|
const handleContextMenu = (e: MouseEvent) => {
|
|
if (e.ctrlKey && onOpenFileManager) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
onOpenFileManager();
|
|
return;
|
|
}
|
|
|
|
if (getUseRightClickCopyPaste()) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
if (terminal.hasSelection()) {
|
|
const text = terminal.getSelection();
|
|
writeTextToClipboard(text).then(() => terminal.clearSelection());
|
|
} else {
|
|
readTextFromClipboard().then((text) => {
|
|
if (text) terminal.paste(text);
|
|
});
|
|
}
|
|
return;
|
|
}
|
|
};
|
|
element?.addEventListener("contextmenu", handleContextMenu);
|
|
|
|
const handlePaste = (e: ClipboardEvent) => {
|
|
const text = e.clipboardData?.getData("text");
|
|
if (text) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
terminal.paste(text);
|
|
}
|
|
};
|
|
element?.addEventListener("paste", handlePaste);
|
|
|
|
let tmuxDragTracking = false;
|
|
const handleTmuxDragStart = (e: MouseEvent) => {
|
|
if (e.button !== 0) return;
|
|
if (!tmuxSessionNameRef.current) return;
|
|
tmuxDragTracking = true;
|
|
};
|
|
const handleTmuxDragMove = () => {
|
|
if (!tmuxDragTracking) return;
|
|
tmuxDragTracking = false;
|
|
if (tmuxCopyModeHintShownRef.current) return;
|
|
tmuxCopyModeHintShownRef.current = true;
|
|
toast.info(t("terminal.tmuxCopyHint"), { duration: 5000 });
|
|
};
|
|
const handleTmuxDragEnd = () => {
|
|
tmuxDragTracking = false;
|
|
};
|
|
element?.addEventListener("mousedown", handleTmuxDragStart);
|
|
element?.addEventListener("mousemove", handleTmuxDragMove);
|
|
element?.addEventListener("mouseup", handleTmuxDragEnd);
|
|
|
|
const handleBackspaceMode = (e: KeyboardEvent) => {
|
|
if (e.key !== "Backspace") return;
|
|
if (e.ctrlKey || e.metaKey || e.altKey) return;
|
|
|
|
const config = {
|
|
...DEFAULT_TERMINAL_CONFIG,
|
|
...hostConfig.terminalConfig,
|
|
};
|
|
if (config.backspaceMode !== "control-h") return;
|
|
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
|
|
if (webSocketRef.current?.readyState === 1) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({ type: "input", data: "\x08" }),
|
|
);
|
|
}
|
|
return false;
|
|
};
|
|
|
|
// On macOS Electron, Tab key events can be swallowed by Chromium's focus
|
|
// traversal system before xterm.js sees them. Calling preventDefault() in
|
|
// the capture phase blocks that traversal while still allowing the event to
|
|
// reach xterm.js's internal handler (which fires our attachCustomKeyEventHandler).
|
|
const handleTabCapture = (e: KeyboardEvent) => {
|
|
if (e.key === "Tab") {
|
|
e.preventDefault();
|
|
}
|
|
};
|
|
|
|
element?.addEventListener("keydown", handleBackspaceMode, true);
|
|
element?.addEventListener("keydown", handleTabCapture, true);
|
|
|
|
const resizeObserver = new ResizeObserver(() => {
|
|
// Background keep-alive tabs still observe layout; skip fit work.
|
|
if (!isVisibleRef.current) return;
|
|
if (resizeTimeout.current) clearTimeout(resizeTimeout.current);
|
|
resizeTimeout.current = setTimeout(() => {
|
|
if (isVisibleRef.current) {
|
|
performFit();
|
|
}
|
|
}, 50);
|
|
});
|
|
|
|
const observeTarget = xtermRef.current.parentElement ?? xtermRef.current;
|
|
resizeObserver.observe(observeTarget);
|
|
|
|
return () => {
|
|
isFittingRef.current = false;
|
|
resizeObserver.disconnect();
|
|
clipboardProvider.dispose();
|
|
element?.removeEventListener("contextmenu", handleContextMenu);
|
|
element?.removeEventListener("paste", handlePaste);
|
|
element?.removeEventListener("mousedown", handleTmuxDragStart);
|
|
element?.removeEventListener("mousemove", handleTmuxDragMove);
|
|
element?.removeEventListener("mouseup", handleTmuxDragEnd);
|
|
element?.removeEventListener("keydown", handleBackspaceMode, true);
|
|
element?.removeEventListener("keydown", handleTabCapture, true);
|
|
if (notifyTimerRef.current) clearTimeout(notifyTimerRef.current);
|
|
if (resizeTimeout.current) clearTimeout(resizeTimeout.current);
|
|
};
|
|
}, [xtermRef, terminal]);
|
|
|
|
const isMountedRef = useRef(false);
|
|
|
|
useEffect(() => {
|
|
isMountedRef.current = true;
|
|
|
|
const currentHostId = hostConfig.id;
|
|
return () => {
|
|
if (!isMountedRef.current) {
|
|
return;
|
|
}
|
|
|
|
if (
|
|
currentHostIdRef.current !== currentHostId &&
|
|
currentHostIdRef.current !== null
|
|
) {
|
|
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 (pingIntervalRef.current) {
|
|
clearInterval(pingIntervalRef.current);
|
|
pingIntervalRef.current = null;
|
|
}
|
|
if (pongTimeoutRef.current) {
|
|
clearTimeout(pongTimeoutRef.current);
|
|
pongTimeoutRef.current = null;
|
|
}
|
|
|
|
if (webSocketRef.current) {
|
|
webSocketRef.current.close();
|
|
}
|
|
|
|
isMountedRef.current = false;
|
|
}
|
|
};
|
|
}, [hostConfig.id, hostConfig.instanceId]);
|
|
|
|
useEffect(() => {
|
|
if (!terminal) return;
|
|
|
|
const handleCustomKey = (e: KeyboardEvent): boolean => {
|
|
if (e.type !== "keydown") {
|
|
return true;
|
|
}
|
|
|
|
// Forward global app shortcuts to AppShell directly — xterm swallows
|
|
// all keydown events and synthetic re-dispatch is unreliable.
|
|
// stopPropagation prevents the same event from also firing the window listener.
|
|
if (e.ctrlKey && e.shiftKey && !e.altKey && !e.metaKey) {
|
|
const globalCodes = [
|
|
"BracketRight",
|
|
"BracketLeft",
|
|
"Backslash",
|
|
"Minus",
|
|
];
|
|
if (globalCodes.includes(e.code)) {
|
|
e.stopPropagation();
|
|
globalShortcutHandler.current?.(e);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (e.altKey && !e.ctrlKey && !e.shiftKey && !e.metaKey) {
|
|
const arrowCodes = [
|
|
"ArrowLeft",
|
|
"ArrowRight",
|
|
"ArrowUp",
|
|
"ArrowDown",
|
|
];
|
|
if (arrowCodes.includes(e.code)) {
|
|
e.stopPropagation();
|
|
globalShortcutHandler.current?.(e);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
const fontZoomDirection = getTerminalFontZoomDirection(e);
|
|
if (fontZoomDirection !== 0) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
changeTerminalFontSize(fontZoomDirection);
|
|
return false;
|
|
}
|
|
|
|
if (
|
|
e.ctrlKey &&
|
|
!e.shiftKey &&
|
|
!e.altKey &&
|
|
!e.metaKey &&
|
|
e.key.toLowerCase() === "c" &&
|
|
terminal.hasSelection()
|
|
) {
|
|
const selection = terminal.getSelection();
|
|
if (selection) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
writeTextToClipboard(selection);
|
|
terminal.clearSelection();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (
|
|
((e.metaKey && !e.shiftKey && !e.ctrlKey && !e.altKey) ||
|
|
(e.ctrlKey &&
|
|
!e.shiftKey &&
|
|
!e.altKey &&
|
|
!e.metaKey &&
|
|
e.key === "Insert")) &&
|
|
(e.key.toLowerCase() === "c" || e.key === "Insert")
|
|
) {
|
|
const selection = terminal.getSelection();
|
|
if (selection) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
writeTextToClipboard(selection);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (
|
|
e.ctrlKey &&
|
|
e.shiftKey &&
|
|
!e.altKey &&
|
|
!e.metaKey &&
|
|
e.key.toLowerCase() === "c"
|
|
) {
|
|
const selection = terminal.getSelection();
|
|
if (selection) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
writeTextToClipboard(selection);
|
|
terminal.clearSelection();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (
|
|
e.ctrlKey &&
|
|
e.shiftKey &&
|
|
!e.altKey &&
|
|
!e.metaKey &&
|
|
e.key.toLowerCase() === "v"
|
|
) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
readTextFromClipboard().then((text) => {
|
|
if (text) terminal.paste(text);
|
|
});
|
|
return false;
|
|
}
|
|
|
|
if (
|
|
e.ctrlKey &&
|
|
!e.shiftKey &&
|
|
!e.altKey &&
|
|
!e.metaKey &&
|
|
e.key.toLowerCase() === "v"
|
|
) {
|
|
// Let the browser handle Ctrl+V natively, the paste event
|
|
// listener will intercept the result without triggering the
|
|
// clipboard permission popup
|
|
return false;
|
|
}
|
|
|
|
if (e.ctrlKey && e.altKey && !e.metaKey && !e.shiftKey) {
|
|
const key = e.key.toLowerCase();
|
|
const blockedKeys = ["w", "t", "n", "q"];
|
|
if (blockedKeys.includes(key)) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
const ctrlCode = key.charCodeAt(0) - 96;
|
|
if (webSocketRef.current?.readyState === 1) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({
|
|
type: "input",
|
|
data: String.fromCharCode(ctrlCode),
|
|
}),
|
|
);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (showAutocompleteRef.current) {
|
|
if (e.key === "Escape") {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
setShowAutocomplete(false);
|
|
setAutocompleteSuggestions([]);
|
|
currentAutocompleteCommand.current = "";
|
|
return false;
|
|
}
|
|
|
|
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
|
|
const currentIndex = autocompleteSelectedIndexRef.current;
|
|
const suggestionsLength = autocompleteSuggestionsRef.current.length;
|
|
|
|
if (e.key === "ArrowDown") {
|
|
const newIndex =
|
|
currentIndex < suggestionsLength - 1 ? currentIndex + 1 : 0;
|
|
setAutocompleteSelectedIndex(newIndex);
|
|
} else if (e.key === "ArrowUp") {
|
|
const newIndex =
|
|
currentIndex > 0 ? currentIndex - 1 : suggestionsLength - 1;
|
|
setAutocompleteSelectedIndex(newIndex);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
if (
|
|
e.key === "Enter" &&
|
|
autocompleteSuggestionsRef.current.length > 0
|
|
) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
|
|
const selectedCommand =
|
|
autocompleteSuggestionsRef.current[
|
|
autocompleteSelectedIndexRef.current
|
|
];
|
|
const currentCmd = currentAutocompleteCommand.current;
|
|
const completion = selectedCommand.substring(currentCmd.length);
|
|
|
|
if (webSocketRef.current?.readyState === 1) {
|
|
for (const char of completion) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({ type: "input", data: char }),
|
|
);
|
|
}
|
|
}
|
|
|
|
updateCurrentCommandRef.current(selectedCommand);
|
|
|
|
setShowAutocomplete(false);
|
|
setAutocompleteSuggestions([]);
|
|
currentAutocompleteCommand.current = "";
|
|
|
|
return false;
|
|
}
|
|
|
|
if (
|
|
e.key === "Tab" &&
|
|
!e.ctrlKey &&
|
|
!e.altKey &&
|
|
!e.metaKey &&
|
|
!e.shiftKey
|
|
) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
const currentIndex = autocompleteSelectedIndexRef.current;
|
|
const suggestionsLength = autocompleteSuggestionsRef.current.length;
|
|
const newIndex =
|
|
currentIndex < suggestionsLength - 1 ? currentIndex + 1 : 0;
|
|
setAutocompleteSelectedIndex(newIndex);
|
|
return false;
|
|
}
|
|
|
|
setShowAutocomplete(false);
|
|
setAutocompleteSuggestions([]);
|
|
currentAutocompleteCommand.current = "";
|
|
return true;
|
|
}
|
|
|
|
if (
|
|
e.key === "Tab" &&
|
|
e.shiftKey &&
|
|
!e.ctrlKey &&
|
|
!e.altKey &&
|
|
!e.metaKey
|
|
) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
if (webSocketRef.current?.readyState === 1) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({ type: "input", data: "\x1b[Z" }),
|
|
);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
if (
|
|
e.key === "Tab" &&
|
|
!e.ctrlKey &&
|
|
!e.altKey &&
|
|
!e.metaKey &&
|
|
!e.shiftKey
|
|
) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
|
|
const sendTabToShell = () => {
|
|
if (webSocketRef.current?.readyState === 1) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({ type: "input", data: "\t" }),
|
|
);
|
|
}
|
|
};
|
|
|
|
const autocompleteEnabled =
|
|
localStorage.getItem("commandAutocomplete") === "true";
|
|
|
|
if (!autocompleteEnabled) {
|
|
sendTabToShell();
|
|
return false;
|
|
}
|
|
|
|
const currentCmd = getCurrentCommandRef.current().trim();
|
|
if (currentCmd.length === 0) {
|
|
sendTabToShell();
|
|
return false;
|
|
}
|
|
|
|
if (webSocketRef.current?.readyState === 1) {
|
|
const matches = autocompleteHistory.current
|
|
.filter(
|
|
(cmd) =>
|
|
cmd.startsWith(currentCmd) &&
|
|
cmd !== currentCmd &&
|
|
cmd.length > currentCmd.length,
|
|
)
|
|
.slice(0, 5);
|
|
|
|
if (matches.length === 1) {
|
|
const completedCommand = matches[0];
|
|
const completion = completedCommand.substring(currentCmd.length);
|
|
|
|
for (const char of completion) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({ type: "input", data: char }),
|
|
);
|
|
}
|
|
|
|
updateCurrentCommandRef.current(completedCommand);
|
|
} else if (matches.length > 1) {
|
|
currentAutocompleteCommand.current = currentCmd;
|
|
setAutocompleteSuggestions(matches);
|
|
setAutocompleteSelectedIndex(0);
|
|
|
|
const cursorY = terminal.buffer.active.cursorY;
|
|
const cursorX = terminal.buffer.active.cursorX;
|
|
const rect = xtermRef.current?.getBoundingClientRect();
|
|
|
|
if (rect) {
|
|
const cellHeight =
|
|
terminal.rows > 0 ? rect.height / terminal.rows : 20;
|
|
const cellWidth =
|
|
terminal.cols > 0 ? rect.width / terminal.cols : 10;
|
|
|
|
const itemHeight = 32;
|
|
const footerHeight = 32;
|
|
const maxMenuHeight = 240;
|
|
const estimatedMenuHeight = Math.min(
|
|
matches.length * itemHeight + footerHeight,
|
|
maxMenuHeight,
|
|
);
|
|
const cursorBottomY = rect.top + (cursorY + 1) * cellHeight;
|
|
const cursorTopY = rect.top + cursorY * cellHeight;
|
|
const spaceBelow = window.innerHeight - cursorBottomY;
|
|
const spaceAbove = cursorTopY;
|
|
|
|
const showAbove =
|
|
spaceBelow < estimatedMenuHeight && spaceAbove > spaceBelow;
|
|
|
|
setAutocompletePosition({
|
|
top: showAbove
|
|
? Math.max(0, cursorTopY - estimatedMenuHeight)
|
|
: cursorBottomY,
|
|
left: Math.max(0, rect.left + cursorX * cellWidth),
|
|
});
|
|
}
|
|
|
|
setShowAutocomplete(true);
|
|
} else {
|
|
sendTabToShell();
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
terminal.attachCustomKeyEventHandler(handleCustomKey);
|
|
}, [terminal]);
|
|
|
|
useEffect(() => {
|
|
if (!terminal || !hostConfig || !isVisible) return;
|
|
if (isConnected || isConnecting) return;
|
|
|
|
if (isReconnectingRef.current || reconnectTimeoutRef.current !== null) {
|
|
return;
|
|
}
|
|
|
|
if (shouldNotReconnectRef.current) {
|
|
return;
|
|
}
|
|
|
|
if (
|
|
webSocketRef.current &&
|
|
(webSocketRef.current.readyState === WebSocket.OPEN ||
|
|
webSocketRef.current.readyState === WebSocket.CONNECTING)
|
|
) {
|
|
return;
|
|
}
|
|
|
|
setIsConnecting(true);
|
|
fitAddonRef.current?.fit();
|
|
requestAnimationFrame(() => {
|
|
requestAnimationFrame(() => {
|
|
fitAddonRef.current?.fit();
|
|
if (terminal.cols > 0 && terminal.rows > 0) {
|
|
scheduleNotify(terminal.cols, terminal.rows);
|
|
connectToHost(terminal.cols, terminal.rows);
|
|
}
|
|
});
|
|
});
|
|
}, [terminal, hostConfig.id, isVisible, isConnected, isConnecting]);
|
|
|
|
useEffect(() => {
|
|
if (!terminal || !fitAddonRef.current) return;
|
|
|
|
if (!isVisible) {
|
|
lastFittedSizeRef.current = null;
|
|
lastSentSizeRef.current = null;
|
|
return;
|
|
}
|
|
|
|
const fitTimeoutId = setTimeout(() => {
|
|
if (!isFittingRef.current && terminal.cols > 0 && terminal.rows > 0) {
|
|
performFit();
|
|
if (!splitScreen && !isConnecting && !disableAutoFocus) {
|
|
requestAnimationFrame(() => terminal.focus());
|
|
}
|
|
}
|
|
}, 50);
|
|
|
|
return () => clearTimeout(fitTimeoutId);
|
|
}, [terminal, isVisible, splitScreen, isConnecting]);
|
|
|
|
const hasConnectionError = !!connectionError;
|
|
|
|
return (
|
|
<div
|
|
className="h-full w-full relative"
|
|
style={{
|
|
backgroundColor: backgroundImage ? "transparent" : backgroundColor,
|
|
...(backgroundImage && {
|
|
backgroundImage: `url(${backgroundImage})`,
|
|
backgroundSize: "cover",
|
|
backgroundPosition: "center",
|
|
backgroundRepeat: "no-repeat",
|
|
}),
|
|
}}
|
|
>
|
|
{backgroundImage && (
|
|
<div
|
|
className="absolute inset-0 pointer-events-none"
|
|
style={{
|
|
backgroundColor: themeColors.background,
|
|
opacity: 1 - backgroundImageOpacity,
|
|
}}
|
|
/>
|
|
)}
|
|
<div
|
|
ref={xtermRef}
|
|
className="h-full w-full relative"
|
|
style={{
|
|
pointerEvents: isVisible ? "auto" : "none",
|
|
visibility:
|
|
isConnected && isFitted && !connectionError
|
|
? "visible"
|
|
: "hidden",
|
|
}}
|
|
onClick={() => {
|
|
if (terminal && !splitScreen) {
|
|
terminal.focus();
|
|
}
|
|
}}
|
|
/>
|
|
|
|
{isTmuxAttached && isConnected && (
|
|
<button
|
|
onClick={() => {
|
|
if (webSocketRef.current?.readyState === WebSocket.OPEN) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({ type: "tmux_detach" }),
|
|
);
|
|
}
|
|
}}
|
|
title={t("terminal.tmuxDetach")}
|
|
className="absolute top-2 right-2 z-[110] px-2 py-1 text-xs rounded bg-black/60 text-white/70 hover:text-white hover:bg-black/80 transition-colors"
|
|
>
|
|
tmux:detach
|
|
</button>
|
|
)}
|
|
|
|
{isQuickConnect &&
|
|
isConnected &&
|
|
!isQuickConnectSaved &&
|
|
onSaveQuickConnect && (
|
|
<Button
|
|
size="sm"
|
|
variant="secondary"
|
|
disabled={isSavingQuickConnect}
|
|
onClick={async () => {
|
|
setIsSavingQuickConnect(true);
|
|
try {
|
|
await onSaveQuickConnect();
|
|
setIsQuickConnectSaved(true);
|
|
} catch {
|
|
// The shell reports the failure with a toast.
|
|
} finally {
|
|
setIsSavingQuickConnect(false);
|
|
}
|
|
}}
|
|
className="absolute top-2 left-2 z-[110] h-7 gap-1.5 bg-black/60 text-white/80 hover:bg-black/80 hover:text-white"
|
|
>
|
|
<Save className="size-3.5" />
|
|
{t("hosts.addHost")}
|
|
</Button>
|
|
)}
|
|
|
|
<SimpleLoader
|
|
visible={isConnecting && !isConnectionLogExpanded}
|
|
message={t("terminal.connecting")}
|
|
backgroundColor={backgroundColor}
|
|
/>
|
|
|
|
{showDisconnectedOverlay && !isConnecting && (
|
|
<div
|
|
className="absolute inset-0 flex flex-col items-center justify-center gap-3 z-[120]"
|
|
style={{ backgroundColor }}
|
|
>
|
|
<p className="text-sm text-muted-foreground">
|
|
{t("terminal.connectionLost")}
|
|
</p>
|
|
<div className="flex gap-2">
|
|
<Button
|
|
onClick={() => {
|
|
setShowDisconnectedOverlay(false);
|
|
isUnmountingRef.current = false;
|
|
shouldNotReconnectRef.current = false;
|
|
isReconnectingRef.current = false;
|
|
isConnectingRef.current = false;
|
|
reconnectAttempts.current = 0;
|
|
wasDisconnectedBySSH.current = false;
|
|
wasConnectedRef.current = false;
|
|
updateConnectionError(null);
|
|
if (terminal) {
|
|
terminal.clear();
|
|
connectToHost(terminal.cols, terminal.rows);
|
|
}
|
|
}}
|
|
>
|
|
{t("terminal.reconnect")}
|
|
</Button>
|
|
{onClose && (
|
|
<Button variant="outline" onClick={onClose}>
|
|
{t("terminal.closeTab")}
|
|
</Button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
<ConnectionLog
|
|
isConnecting={isConnecting}
|
|
isConnected={isConnected}
|
|
hasConnectionError={hasConnectionError && !showDisconnectedOverlay}
|
|
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}
|
|
/>
|
|
|
|
{opksshDialog?.isOpen && (
|
|
<OPKSSHDialog
|
|
isOpen={opksshDialog.isOpen}
|
|
authUrl={opksshDialog.authUrl}
|
|
requestId={opksshDialog.requestId}
|
|
stage={opksshDialog.stage}
|
|
error={opksshDialog.error}
|
|
providers={opksshDialog.providers}
|
|
onCancel={() => {
|
|
if (webSocketRef.current) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({
|
|
type: "opkssh_cancel",
|
|
data: { requestId: opksshDialog.requestId },
|
|
}),
|
|
);
|
|
}
|
|
setOpksshDialog(null);
|
|
if (opksshTimeoutRef.current) {
|
|
clearTimeout(opksshTimeoutRef.current);
|
|
opksshTimeoutRef.current = null;
|
|
}
|
|
}}
|
|
onOpenUrl={() => {
|
|
window.open(opksshDialog.authUrl, "_blank");
|
|
if (webSocketRef.current) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({
|
|
type: "opkssh_browser_opened",
|
|
data: { requestId: opksshDialog.requestId },
|
|
}),
|
|
);
|
|
}
|
|
}}
|
|
onSelectProvider={(alias) => {
|
|
if (!opksshDialog.authUrl) return;
|
|
const selectUrl = `${opksshDialog.authUrl}/select?op=${encodeURIComponent(alias)}`;
|
|
window.open(selectUrl, "_blank");
|
|
if (webSocketRef.current) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({
|
|
type: "opkssh_browser_opened",
|
|
data: { requestId: opksshDialog.requestId },
|
|
}),
|
|
);
|
|
}
|
|
setOpksshDialog((prev) =>
|
|
prev ? { ...prev, stage: "waiting" } : null,
|
|
);
|
|
}}
|
|
backgroundColor={backgroundColor}
|
|
/>
|
|
)}
|
|
|
|
{vaultDialog && (
|
|
<div className="absolute inset-0 z-50 flex items-center justify-center bg-black/60">
|
|
<div className="w-[420px] max-w-[90%] border border-border bg-background p-5 shadow-lg">
|
|
<h3 className="text-sm font-bold mb-2 text-foreground">
|
|
{vaultDialog.stage === "error"
|
|
? t("terminal.vaultAuthFailed")
|
|
: t("terminal.vaultAuthTitle")}
|
|
</h3>
|
|
{vaultDialog.stage === "error" ? (
|
|
<p className="text-xs text-destructive mb-4 break-words">
|
|
{vaultDialog.error || t("terminal.vaultAuthFailed")}
|
|
</p>
|
|
) : (
|
|
<p className="text-xs text-muted-foreground mb-4">
|
|
{t("terminal.vaultAuthDescription")}
|
|
</p>
|
|
)}
|
|
<div className="flex justify-end gap-2">
|
|
{vaultDialog.stage === "waiting" && (
|
|
<Button
|
|
variant="outline"
|
|
size="sm"
|
|
onClick={() => {
|
|
try {
|
|
vaultPopupRef.current?.focus();
|
|
} catch {
|
|
// popup may be gone
|
|
}
|
|
}}
|
|
>
|
|
{t("terminal.vaultReopen")}
|
|
</Button>
|
|
)}
|
|
<Button
|
|
variant="ghost"
|
|
size="sm"
|
|
onClick={() => {
|
|
if (vaultTimeoutRef.current) {
|
|
clearTimeout(vaultTimeoutRef.current);
|
|
vaultTimeoutRef.current = null;
|
|
}
|
|
try {
|
|
vaultPopupRef.current?.close();
|
|
} catch {
|
|
// popup may already be closed
|
|
}
|
|
webSocketRef.current?.send(
|
|
JSON.stringify({
|
|
type: "vault_cancel",
|
|
data: { hostId: currentHostIdRef.current },
|
|
}),
|
|
);
|
|
setVaultDialog(null);
|
|
}}
|
|
>
|
|
{vaultDialog.stage === "error"
|
|
? t("common.close")
|
|
: t("hosts.cancelBtn")}
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{hostKeyVerification?.isOpen && (
|
|
<HostKeyVerificationDialog
|
|
isOpen={true}
|
|
scenario={hostKeyVerification.scenario}
|
|
{...hostKeyVerification.data}
|
|
onAccept={() => {
|
|
if (webSocketRef.current) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({
|
|
type: "host_key_verification_response",
|
|
data: { action: "accept" },
|
|
}),
|
|
);
|
|
}
|
|
setHostKeyVerification(null);
|
|
}}
|
|
onReject={() => {
|
|
if (webSocketRef.current) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({
|
|
type: "host_key_verification_response",
|
|
data: { action: "reject" },
|
|
}),
|
|
);
|
|
}
|
|
setHostKeyVerification(null);
|
|
setIsConnecting(false);
|
|
updateConnectionError(t("terminal.hostKeyRejected"));
|
|
}}
|
|
backgroundColor={backgroundColor}
|
|
/>
|
|
)}
|
|
|
|
{tmuxSessionPicker && (
|
|
<TmuxSessionPicker
|
|
isOpen={true}
|
|
sessions={tmuxSessionPicker.sessions}
|
|
onSelect={(sessionName) => {
|
|
setTmuxSessionPicker(null);
|
|
if (webSocketRef.current?.readyState === WebSocket.OPEN) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({
|
|
type: "tmux_attach",
|
|
data: { sessionName },
|
|
}),
|
|
);
|
|
}
|
|
setTimeout(() => terminal?.focus(), 50);
|
|
}}
|
|
onCreateNew={() => {
|
|
setTmuxSessionPicker(null);
|
|
if (webSocketRef.current?.readyState === WebSocket.OPEN) {
|
|
webSocketRef.current.send(
|
|
JSON.stringify({
|
|
type: "tmux_attach",
|
|
data: { sessionName: "" },
|
|
}),
|
|
);
|
|
}
|
|
setTimeout(() => terminal?.focus(), 50);
|
|
}}
|
|
onCancel={() => setTmuxSessionPicker(null)}
|
|
backgroundColor={backgroundColor}
|
|
/>
|
|
)}
|
|
|
|
<CommandAutocomplete
|
|
visible={showAutocomplete}
|
|
suggestions={autocompleteSuggestions}
|
|
selectedIndex={autocompleteSelectedIndex}
|
|
position={autocompletePosition}
|
|
onSelect={handleAutocompleteSelect}
|
|
/>
|
|
|
|
{linkClickDialog &&
|
|
createPortal(
|
|
<div
|
|
className="fixed inset-0 flex items-center justify-center z-[10000]"
|
|
style={{ backgroundColor: "rgba(0,0,0,0.5)" }}
|
|
onClick={() => setLinkClickDialog(null)}
|
|
>
|
|
<div
|
|
className="flex flex-col gap-3 p-4 rounded shadow-lg max-w-sm w-full mx-4"
|
|
style={{ backgroundColor }}
|
|
onClick={(event) => event.stopPropagation()}
|
|
>
|
|
<p className="text-xs font-bold uppercase tracking-widest text-muted-foreground">
|
|
{t("terminal.linkDialogTitle")}
|
|
</p>
|
|
<p className="text-sm break-all text-foreground select-all">
|
|
{linkClickDialog.url}
|
|
</p>
|
|
<div className="flex gap-2 justify-end">
|
|
<Button
|
|
variant="outline"
|
|
size="sm"
|
|
onClick={() => {
|
|
writeTextToClipboard(linkClickDialog.url);
|
|
setLinkClickDialog(null);
|
|
}}
|
|
>
|
|
{t("terminal.linkDialogCopy")}
|
|
</Button>
|
|
<Button
|
|
size="sm"
|
|
onClick={() => {
|
|
window.open(
|
|
linkClickDialog.url,
|
|
"_blank",
|
|
"noopener,noreferrer",
|
|
);
|
|
setLinkClickDialog(null);
|
|
}}
|
|
>
|
|
{t("terminal.linkDialogOpen")}
|
|
</Button>
|
|
<Button
|
|
variant="outline"
|
|
size="sm"
|
|
onClick={() => setLinkClickDialog(null)}
|
|
>
|
|
{t("common.cancel")}
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</div>,
|
|
document.body,
|
|
)}
|
|
</div>
|
|
);
|
|
},
|
|
);
|
|
|
|
export const Terminal = forwardRef<TerminalHandle, SSHTerminalProps>(
|
|
function Terminal(props, ref) {
|
|
return (
|
|
<ConnectionLogProvider>
|
|
<TerminalInner {...props} ref={ref} />
|
|
</ConnectionLogProvider>
|
|
);
|
|
},
|
|
);
|