mcp-ssh-manager 4.3.5 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -0
- package/Formula/ssh-manager.rb +2 -2
- package/README.md +14 -6
- package/cli/vault.js +5 -2
- package/desktop/electron/electron-builder.yml +1 -0
- package/desktop/electron/main.js +21 -14
- package/desktop/electron/package-lock.json +2 -2
- package/desktop/electron/package.json +1 -1
- package/desktop/electron/window-close.mjs +35 -0
- package/dist/ui/app.css +1 -1
- package/dist/ui/app.js +123 -123
- package/docs/MIGRATION.md +20 -2
- package/package.json +4 -2
- package/server.json +2 -2
- package/src/config-paths.js +83 -12
- package/src/index.js +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,74 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [4.4.0] - 2026-11-26
|
|
11
|
+
|
|
12
|
+
**A feature release with two interface fixes.** Nothing changes unless you turn the new
|
|
13
|
+
switch on; the interface fixes only affect the desktop app and the browser interface.
|
|
14
|
+
Contributed by @AnA-0823 (the tray switch, the dropdown colours) and @congzhou09 (the
|
|
15
|
+
terminal fix). The Windows installer is still **not Authenticode-signed**, for the same
|
|
16
|
+
reason as 4.0.0: Windows shows *"Windows protected your PC"*, *More info → Run anyway*,
|
|
17
|
+
and `ssh-manager app` checks the installer against the SHA-256 in
|
|
18
|
+
`release-manifest-win32.json`. macOS builds are signed and notarized.
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- **Keep the desktop application running when its window is closed** (*Options → Appearance*, inside the desktop application). On Windows and Linux, turning this on leaves SSH Manager in the system tray so approval notifications still arrive after closing the window; each platform's default behaviour (staying in the menu bar on macOS, quitting on Windows and Linux) is unchanged.
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- **Native `<select>` menus were light text on a white background in dark mode on Windows and Linux.** Transparent backgrounds on `<select>` and `<option>` exposed Chromium's white popup surface while inheriting dark-mode text colour; all five dropdowns now carry opaque theme colours.
|
|
27
|
+
- **`vim` froze the terminal of the interface on its first screen** (#175, @congzhou09). vim asks the terminal for one of its modes as soon as it has drawn; xterm answered with code that the interface's build target made esbuild lower into an assignment to an undeclared variable, so the answer threw and nothing after it was drawn. The interface is now built for ES2021, which keeps the code as written; a test sends that query and expects the answer.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- **Interface dependency:** `i18next` 25 to 27 (#168). The interface's languages and the language tool are unchanged.
|
|
32
|
+
|
|
33
|
+
## [4.3.6] - 2026-11-25
|
|
34
|
+
|
|
35
|
+
**A security release: upgrade if an agent runs in a project folder you did not write.**
|
|
36
|
+
The `.env` of the folder an MCP client was started in could define a server whose
|
|
37
|
+
`PROXYCOMMAND` runs a command on your machine when a tool connects to it
|
|
38
|
+
([GHSA-wxcj-q5hp-wjrw](https://github.com/bvisible/mcp-ssh-manager/security/advisories/GHSA-wxcj-q5hp-wjrw),
|
|
39
|
+
high). Every release from 3.3.0, where `PROXYCOMMAND` was added, is affected.
|
|
40
|
+
**One thing behaves differently on purpose:** that `.env` is no longer read unless you
|
|
41
|
+
placed it or set `SSH_MANAGER_TRUST_PROJECT_ENV=1` (details below). Servers in
|
|
42
|
+
`~/.ssh-manager/.env`, in a file named by `SSH_ENV_PATH` or `SSH_MANAGER_ENV`, in the
|
|
43
|
+
vault or in the process environment are not affected. Nothing else changes (the release
|
|
44
|
+
pipeline upgrades 3.8.5, 3.8.6, 3.8.7, every 4.0.x, 4.1.0, 4.2.0, 4.3.0, 4.3.1, 4.3.2, 4.3.3,
|
|
45
|
+
4.3.4 and 4.3.5 from the registry to this version and back).
|
|
46
|
+
|
|
47
|
+
The Windows installer is still **not Authenticode-signed**, for the same reason
|
|
48
|
+
as 4.0.0: Windows shows *"Windows protected your PC"*, *More info → Run anyway*,
|
|
49
|
+
and `ssh-manager app` checks the installer against the SHA-256 in
|
|
50
|
+
`release-manifest-win32.json`. macOS builds are signed and notarized.
|
|
51
|
+
|
|
52
|
+
### Security
|
|
53
|
+
|
|
54
|
+
- **A project's `.env` could run a command on this machine**
|
|
55
|
+
([GHSA-wxcj-q5hp-wjrw](https://github.com/bvisible/mcp-ssh-manager/security/advisories/GHSA-wxcj-q5hp-wjrw),
|
|
56
|
+
reported by Pythame). The engine read the `.env` of its working directory, which is
|
|
57
|
+
whatever project the MCP client was started in, when `~/.ssh-manager/.env` did not
|
|
58
|
+
exist. That file can define a server with `SSH_SERVER_<NAME>_PROXYCOMMAND`, or point
|
|
59
|
+
`SSH_CONFIG_PATH` at a TOML with a `proxy_command`, and the engine runs that command
|
|
60
|
+
through the shell when a tool connects to the server: before any SSH banner, whatever
|
|
61
|
+
the server's mode or approval, and even when the connection then fails. A repository
|
|
62
|
+
with such a file was enough. Every release from 3.3.0, where `PROXYCOMMAND` was
|
|
63
|
+
added, is affected.
|
|
64
|
+
**One thing behaves differently on purpose:** the `.env` of the working directory is
|
|
65
|
+
no longer read, unless it is also a file you placed (`~/.ssh-manager/.env`, your
|
|
66
|
+
home's `.env`, or the install directory's, which is what a run from a checkout
|
|
67
|
+
reads) or the environment of the MCP server says `SSH_MANAGER_TRUST_PROJECT_ENV=1`.
|
|
68
|
+
A project file cannot grant that itself, and a file it names through
|
|
69
|
+
`SSH_CONFIG_PATH` is not read either. When a project `.env` that defines servers is
|
|
70
|
+
left unread, the engine says so at startup, in `ssh_list_servers` and in "server not
|
|
71
|
+
found", with the three ways to have it read: move it to `~/.ssh-manager/.env`, name
|
|
72
|
+
it with `SSH_ENV_PATH`, or set the variable (in the `env` block of the MCP client's
|
|
73
|
+
configuration, where the client's own approval of a project server applies). With a
|
|
74
|
+
file in `~/.ssh-manager/.env`, `SSH_ENV_PATH` or `SSH_MANAGER_ENV`, nothing changes.
|
|
75
|
+
Two details that come with it: a project `.env` no longer hides your home `.env`, and
|
|
76
|
+
a `.env` written into the project while the engine runs is not picked up.
|
|
77
|
+
|
|
10
78
|
## [4.3.5] - 2026-11-25
|
|
11
79
|
|
|
12
80
|
**A security release: upgrade if a server uses `restricted` or `readonly` mode.** A
|
package/Formula/ssh-manager.rb
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
class SshManager < Formula
|
|
14
14
|
desc "SSH server management for AI agents, with approval and audit"
|
|
15
15
|
homepage "https://github.com/bvisible/mcp-ssh-manager"
|
|
16
|
-
url "https://registry.npmjs.org/mcp-ssh-manager/-/mcp-ssh-manager-4.3.
|
|
17
|
-
sha256 "
|
|
16
|
+
url "https://registry.npmjs.org/mcp-ssh-manager/-/mcp-ssh-manager-4.3.6.tgz"
|
|
17
|
+
sha256 "2ab2076b2c06fbdccfdeba4f4fc9737ecd7a7838d6fd281687ee979fda2122d2"
|
|
18
18
|
license "MIT"
|
|
19
19
|
|
|
20
20
|
depends_on "node"
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
[](https://github.com/bvisible/mcp-ssh-manager/releases/latest)
|
|
26
26
|
[](https://github.com/bvisible/mcp-ssh-manager/stargazers)
|
|
27
27
|
[](https://mcptoplist.com/server/io.github.bvisible%2Fmcp-ssh-manager)
|
|
28
|
-
[](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.4.0)
|
|
29
29
|
[](https://claude.ai/code)
|
|
30
30
|
[](https://openai.com/codex)
|
|
31
31
|
[](https://modelcontextprotocol.io)
|
|
@@ -58,9 +58,9 @@ An MCP SSH server is the most dangerous tool you can hand an agent: a shell on m
|
|
|
58
58
|
|
|
59
59
|
## Choose your workspace
|
|
60
60
|
|
|
61
|
-
**Desktop application (`4.
|
|
61
|
+
**Desktop application (`4.4.0`):** one installation with its own runtime,
|
|
62
62
|
terminal, file browser and server settings. No separate Node.js or npm
|
|
63
|
-
installation. [Download it](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.
|
|
63
|
+
installation. [Download it](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.4.0):
|
|
64
64
|
|
|
65
65
|
| Platform | File | Signature |
|
|
66
66
|
|---|---|---|
|
|
@@ -68,7 +68,7 @@ installation. [Download it](https://github.com/bvisible/mcp-ssh-manager/releases
|
|
|
68
68
|
| Windows x64 / arm64 | `…-setup.exe` | **Not code-signed yet.** Windows shows *"Windows protected your PC"*: *More info → Run anyway*. Check the file against the SHA-256 in `release-manifest-win32.json` on the release (`ssh-manager app` does it for you). Signing comes in a later release. |
|
|
69
69
|
| Linux x64 | `.deb`, `.AppImage` | Unsigned, as Linux packages usually are |
|
|
70
70
|
|
|
71
|
-
**Already using npm / the CLI?** `npm update -g mcp-ssh-manager` brings 4.
|
|
71
|
+
**Already using npm / the CLI?** `npm update -g mcp-ssh-manager` brings 4.4.0,
|
|
72
72
|
and the V4 engine runs without an interface, from your existing `.env`, TOML or
|
|
73
73
|
process variables — no automatic import, no forced wizard, no approval prompt
|
|
74
74
|
unless you enable one per server. The one behaviour that tightens is **SSH
|
|
@@ -203,7 +203,7 @@ files and one command (`npm run lang -- add <code>`): see [Adding a language](ui
|
|
|
203
203
|
|
|
204
204
|
The desktop build adds the two things a browser tab cannot do:
|
|
205
205
|
|
|
206
|
-
- **It lives in the menu bar.** The icon carries a count when something is waiting, and its menu lists what is blocked on you, which shells and commands are open right now, and your servers — so "is anything waiting on me?" costs a glance instead of a window switch.
|
|
206
|
+
- **It lives in the menu bar.** The icon carries a count when something is waiting, and its menu lists what is blocked on you, which shells and commands are open right now, and your servers — so "is anything waiting on me?" costs a glance instead of a window switch. On macOS, closing the window leaves it there by default; on Windows and Linux you can turn that on under *Options → Appearance*.
|
|
207
207
|
- **It posts real system notifications**, with the application's own identity, so macOS and Windows show and route them properly. Destructive requests stay on screen instead of fading after four seconds. macOS asks your permission the first time it needs to.
|
|
208
208
|
|
|
209
209
|
<p align="center">
|
|
@@ -526,6 +526,8 @@ file people email each other and commit by accident.
|
|
|
526
526
|
|
|
527
527
|
Two interchangeable formats, read by the same loader: `.env` is the usual choice with Claude Code, TOML with Codex (from `SSH_CONFIG_PATH`, or `~/.codex/ssh-config.toml`). Both can coexist — the loader merges them.
|
|
528
528
|
|
|
529
|
+
The `.env` is `~/.ssh-manager/.env`, or the file `SSH_ENV_PATH` names. One that only sits in the project folder your agent was started in is **not** read (a server entry can run a command on your machine): move it, name it, or set `SSH_MANAGER_TRUST_PROJECT_ENV=1` — see [docs/MIGRATION.md](docs/MIGRATION.md#which-env-is-read).
|
|
530
|
+
|
|
529
531
|
```env
|
|
530
532
|
SSH_SERVER_[NAME]_HOST=hostname_or_ip
|
|
531
533
|
SSH_SERVER_[NAME]_USER=username
|
|
@@ -720,7 +722,13 @@ The hero animation ships twice, light and dark, swapped by `<picture>` on `prefe
|
|
|
720
722
|
|
|
721
723
|
## What's new
|
|
722
724
|
|
|
723
|
-
**[4.
|
|
725
|
+
**[4.4.0](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.4.0) — keep the desktop app running when you close its window, readable dropdowns in dark mode, and `vim` works in the terminal.** *Options → Appearance* has a new, opt-in switch: with it on, closing the window leaves SSH Manager in the system tray (Windows, Linux) or the menu bar (macOS), so approval requests still reach you; nothing changes until you turn it on. Native `<select>` menus are no longer light text on a white menu in dark mode on Windows and Linux, and vim no longer freezes the interface's terminal on its first screen. From @AnA-0823 (#173, #174) and @congzhou09 (#175). See the [CHANGELOG](CHANGELOG.md#440---2026-11-26).
|
|
726
|
+
|
|
727
|
+
**[4.3.6](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.3.6) — a security fix: a project folder's `.env` could run a command on your machine.** The `.env` of the folder an MCP client was started in could define a server whose `PROXYCOMMAND` ran when a tool connected to it, before any SSH login and whatever the server's mode. That `.env` is no longer read unless you placed it (`~/.ssh-manager/.env`, your home's, the install folder's) or set `SSH_MANAGER_TRUST_PROJECT_ENV=1` in the environment of the engine; the engine says which file it left unread. If your servers were in a `.env` next to the project, move it to `~/.ssh-manager/.env` or name it with `SSH_ENV_PATH`. Reported by @Pythame (GHSA-wxcj-q5hp-wjrw). See the [CHANGELOG](CHANGELOG.md#436---2026-11-25).
|
|
728
|
+
|
|
729
|
+
**[4.3.5](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.3.5) — a security fix: `restricted` and `readonly` modes could be made to run a command their patterns deny.** A shell rewrites a word before it runs it (`r""m`, `r\m` and `r${x}m` are all `rm`), and the patterns were tested on the text as typed, so a denied command could ride behind an allowed launcher such as `find -exec` or `xargs`. Every command is now also tested as the shell reads it. If you use `restricted` or `readonly` mode, upgrade. Reported by @Pythame (GHSA-4fp4-fggm-cf5c). See the [CHANGELOG](CHANGELOG.md#435---2026-11-25).
|
|
730
|
+
|
|
731
|
+
**[4.3.4](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.3.4) — a security fix: `ssh_download` could write any file on your machine, even from a `readonly` server.** An agent that could not run a command on a `readonly` or `restricted` server could still have a file it had put on the server downloaded over `~/.zshrc` or into `~/.ssh/authorized_keys`. The local side of a transfer now has a transfer root: `readonly` and `restricted` servers download into `~/.ssh-manager/transfers`, and any server can name its own folder with `TRANSFER_ROOT`. If you download from such a server to a folder of your own, set `TRANSFER_ROOT` to it. (GHSA-2v9g-gm8g-mxgj) See the [CHANGELOG](CHANGELOG.md#434---2026-11-23).
|
|
724
732
|
|
|
725
733
|
**[4.3.3](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.3.3) — a security fix: `restricted` mode could be made to run a command its allowlist never saw.** A comment, a here-document, an ANSI-C quote (`$'…'`) or a parenthesis could hide a command from the check while the shell ran it. The allowlist now reads comments as comments and refuses those constructs, with a reason. Servers in `readonly` mode and servers without a mode are unaffected; if you use `restricted` mode, upgrade. Reported by @Fastyyy123 (GHSA-86xm-rv3h-r4f2). See the [CHANGELOG](CHANGELOG.md#433---2026-11-21).
|
|
726
734
|
|
package/cli/vault.js
CHANGED
|
@@ -19,7 +19,7 @@ import { writeRecoveryFile, readRecoveryFile, describeRecoveryFile } from '../sr
|
|
|
19
19
|
import { SecretStore, defaultVaultPath, SECRET_FIELDS } from '../src/secret-store.js';
|
|
20
20
|
import { defaultSocketPath, isControlPlaneListening, VALID_APPROVAL_MODES } from '../src/approval.js';
|
|
21
21
|
import { ConfigLoader } from '../src/config-loader.js';
|
|
22
|
-
import {
|
|
22
|
+
import { envFileChoice } from '../src/config-paths.js';
|
|
23
23
|
import { GREEN, YELLOW, RED, DIM, RESET } from './style.js';
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -282,7 +282,8 @@ async function cmdRemove(store, name) {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
async function cmdImport(store, fromPath) {
|
|
285
|
-
const
|
|
285
|
+
const choice = fromPath ? null : envFileChoice();
|
|
286
|
+
const envPath = fromPath || choice.path;
|
|
286
287
|
if (fromPath && !fs.existsSync(fromPath)) {
|
|
287
288
|
console.error(`${RED}No configuration found at ${fromPath}${RESET}`);
|
|
288
289
|
process.exit(1);
|
|
@@ -298,6 +299,8 @@ async function cmdImport(store, fromPath) {
|
|
|
298
299
|
|
|
299
300
|
if (servers.size === 0) {
|
|
300
301
|
console.log(`${YELLOW}No servers found in the configuration.${RESET}`);
|
|
302
|
+
// A .env in this folder is read only when named: a project file is not trusted by default.
|
|
303
|
+
if (choice?.skippedProject) console.log(`${YELLOW}${choice.skippedProject} was not read; to import it, name it.${RESET}`);
|
|
301
304
|
console.log(`${DIM}Point at a file with: ssh-manager vault import --from /path/to/.env (or .toml)${RESET}`);
|
|
302
305
|
return;
|
|
303
306
|
}
|
|
@@ -16,6 +16,7 @@ files:
|
|
|
16
16
|
# One file per language, found by locale.mjs at start: a new language needs no change here.
|
|
17
17
|
- native.*.json
|
|
18
18
|
- local-shell.mjs
|
|
19
|
+
- window-close.mjs
|
|
19
20
|
- smoke-test.mjs
|
|
20
21
|
- package.json
|
|
21
22
|
# The menu-bar glyph is loaded at runtime from __dirname/resources, so it has
|
package/desktop/electron/main.js
CHANGED
|
@@ -32,6 +32,7 @@ import { fileURLToPath, pathToFileURL } from 'url';
|
|
|
32
32
|
import { localShellLaunch, localShellName } from './local-shell.mjs';
|
|
33
33
|
import { nativeLanguage, nativeText } from './locale.mjs';
|
|
34
34
|
import { applicationMenuTemplate } from './native-menu.mjs';
|
|
35
|
+
import { shouldQuitOnWindowAllClosed } from './window-close.mjs';
|
|
35
36
|
|
|
36
37
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
37
38
|
|
|
@@ -646,8 +647,13 @@ function createTray() {
|
|
|
646
647
|
// to raise the window, and the menu is on right-click.
|
|
647
648
|
if (process.platform !== 'darwin') {
|
|
648
649
|
tray.on('click', () => {
|
|
649
|
-
if (mainWindow)
|
|
650
|
-
|
|
650
|
+
if (mainWindow) {
|
|
651
|
+
if (mainWindow.isMinimized()) mainWindow.restore();
|
|
652
|
+
mainWindow.show();
|
|
653
|
+
mainWindow.focus();
|
|
654
|
+
} else if (plane) {
|
|
655
|
+
createWindow(plane.url);
|
|
656
|
+
}
|
|
651
657
|
});
|
|
652
658
|
}
|
|
653
659
|
refreshTray();
|
|
@@ -766,20 +772,21 @@ app.whenReady().then(async () => {
|
|
|
766
772
|
});
|
|
767
773
|
});
|
|
768
774
|
|
|
769
|
-
// On macOS, closing the window leaves the app in the menu bar
|
|
770
|
-
// it quits
|
|
771
|
-
//
|
|
772
|
-
// This used to quit on every platform, and the reason was sound at the time:
|
|
773
|
-
// leaving the control plane running with no window means a process holding SSH
|
|
774
|
-
// connections that nobody can see — and worse, holding the approval socket, so
|
|
775
|
-
// agents block on an interface that is not on screen.
|
|
775
|
+
// On macOS, closing the window leaves the app in the menu bar by default;
|
|
776
|
+
// everywhere else it quits unless the user asked to keep it in the tray under
|
|
777
|
+
// Options → Appearance.
|
|
776
778
|
//
|
|
777
|
-
//
|
|
778
|
-
//
|
|
779
|
-
//
|
|
780
|
-
//
|
|
779
|
+
// This used to quit unconditionally, and the reason was sound before the tray
|
|
780
|
+
// and native notifications existed: leaving the control plane running with no
|
|
781
|
+
// window meant holding SSH connections and the approval socket with nothing on
|
|
782
|
+
// screen to tell you an agent was waiting. With the tray and notifications in
|
|
783
|
+
// place on every platform, keeping it running is safe wherever a tray icon
|
|
784
|
+
// actually came up.
|
|
781
785
|
app.on('window-all-closed', () => {
|
|
782
|
-
|
|
786
|
+
const home = plane ? path.dirname(plane.store.vaultPath) : undefined;
|
|
787
|
+
if (shouldQuitOnWindowAllClosed({ platform: process.platform, home, hasTray: Boolean(tray) })) {
|
|
788
|
+
app.quit();
|
|
789
|
+
}
|
|
783
790
|
});
|
|
784
791
|
|
|
785
792
|
app.on('before-quit', async event => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssh-manager-desktop",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "ssh-manager-desktop",
|
|
9
|
-
"version": "4.
|
|
9
|
+
"version": "4.4.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"electron-updater": "^6.8.9",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
export const CLOSE_TO_TRAY_KEY = 'ssh-manager.close-to-tray';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Whether closing the last window should quit the application.
|
|
9
|
+
*
|
|
10
|
+
* Without a saved preference, each platform keeps its own convention: macOS
|
|
11
|
+
* stays in the menu bar and Dock; Windows and Linux quit. When the user sets
|
|
12
|
+
* the preference in Options, that choice wins — except on Windows and Linux
|
|
13
|
+
* when no tray icon could be created, where staying alive with neither window
|
|
14
|
+
* nor tray would leave an unreachable process holding the approval socket.
|
|
15
|
+
*
|
|
16
|
+
* @param {{ platform?: string, home?: string, hasTray?: boolean }} [options]
|
|
17
|
+
* @returns {boolean}
|
|
18
|
+
*/
|
|
19
|
+
export function shouldQuitOnWindowAllClosed({
|
|
20
|
+
platform = process.platform,
|
|
21
|
+
home = process.env.SSH_MANAGER_HOME || path.join(os.homedir(), '.ssh-manager'),
|
|
22
|
+
hasTray = true,
|
|
23
|
+
} = {}) {
|
|
24
|
+
let keepInTray = platform === 'darwin';
|
|
25
|
+
try {
|
|
26
|
+
const preferences = JSON.parse(fs.readFileSync(path.join(home, 'preferences.json'), 'utf8'));
|
|
27
|
+
const saved = preferences?.[CLOSE_TO_TRAY_KEY];
|
|
28
|
+
if (saved === 'true' || saved === true) keepInTray = true;
|
|
29
|
+
else if (saved === 'false' || saved === false) keepInTray = false;
|
|
30
|
+
} catch {
|
|
31
|
+
// Absent or unreadable preferences fall back to the platform default.
|
|
32
|
+
}
|
|
33
|
+
if (platform !== 'darwin' && !hasTray) return true;
|
|
34
|
+
return !keepInTray;
|
|
35
|
+
}
|