feat(desktop): Electron all-in-one desktop shell (Mac/Windows) embedding the server

Add a `desktop/` Electron app that embeds the existing Node server + node-pty
(all-in-one): the window loads http://127.0.0.1:<port>/ and reuses the frontend
unchanged; other LAN devices can still connect. The server needs zero changes —
startServer(cfg)/loadConfig already support programmatic embedding.

- Pure, unit-tested modules: port, shell, server-config, deep-link, notify-policy,
  notifications, live-poll, prefs, settings-store (94 tests; desktop/src ~97% cov)
- Electron glue: main/window/tray/menu/preload/embedded-server/logger
  (hardened: contextIsolation, sandbox, deny foreign-origin navigation)
- Native value: OS notifications driven by /live-sessions status, tray, deep links
- Packaging (electron-builder -> arm64 .dmg): ships dist/ + public/ + node_modules
  on-disk under Resources so the server resolves its deps from /Applications;
  node-pty rebuilt for the Electron ABI
- Docs: docs/DESKTOP_PLAN.md; PROGRESS_LOG updated

Verified: desktop tsc clean; 1401 tests pass; coverage >=80% (desktop/src 97/95/100/97);
.dmg built and launch-tested on arm64 (server boots, UI serves 200, node-pty loads).
This commit is contained in:
Yaojia Wang
2026-07-02 06:13:17 +02:00
parent 2af57e6686
commit cf8cfccab4
39 changed files with 7781 additions and 0 deletions

33
desktop/package.json Normal file
View File

@@ -0,0 +1,33 @@
{
"name": "web-terminal-desktop",
"version": "0.1.0",
"private": true,
"type": "module",
"author": "Yaojia Wang",
"description": "Electron desktop shell (Mac + Windows) that embeds the web-terminal server + node-pty. All-in-one: a native terminal that is also the LAN server.",
"main": "build/main.cjs",
"engines": {
"node": ">=18"
},
"scripts": {
"typecheck": "tsc -p tsconfig.json --noEmit",
"build": "node build.mjs",
"build:server": "cd .. && npm run build && npm run build:web",
"build:all": "npm run build:server && npm run build",
"start": "npm run build:all && electron .",
"dist:mac": "npm run build:all && electron-builder --mac",
"dist:win": "npm run build:all && electron-builder --win"
},
"dependencies": {
"express": "^5.2.1",
"node-pty": "^1.1.0",
"web-push": "3.6.7",
"ws": "^8.21.0"
},
"devDependencies": {
"electron": "^43.0.0",
"electron-builder": "^26.15.3",
"esbuild": "^0.28.1",
"typescript": "^6.0.3"
}
}