Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

feat(desktop): Linux shows the Open/Quit tray icon; the window still never hides into it (#7007)

Kanzal Qalandrifcd2fd68bc61
diff --git a/electron/main.mjs b/electron/main.mjs
index 74d3a376a4..ed2a0019a3 100644
--- a/electron/main.mjs
+++ b/electron/main.mjs
@@ -42,6 +42,8 @@ import { missingPermissions } from "./lent-screen-failures.mjs";
import { createScreenControl } from "./screen-control.mjs"; import { createAskPrompt } from "./ask-prompt.mjs";
let startupScreen = null;
let desktopTray = null;
+// Linux: an icon in the top bar to open or quit. The window never hides into it: not every desktop shows the icon.
+let linuxTray = null;
import { collisionFreeDownloadPath, defaultSaveName, openFolder, openHtmlCopy, openLogsFolder, revealDownloadWhenDone, revealInFolder, withSavableFile } from "./save-file.mjs";
import { desktopViewerPermissionAllowed } from "./desktop-viewer-permissions.mjs";
import { appPermissionHandlers, externalLinkUrl } from "./app-permissions.mjs";
@@ -1528,7 +1530,7 @@ function persistEnvironments(next) {
try { railChanged(); } catch {}
}
-function applyNativeLanguage() { relabelDesktop({ menu: refreshApplicationMenu, trays: [desktopTray, lendingTray], window: mainWindow, title: mainWindowTitle, badge: applyUnreadBadge }); }
+function applyNativeLanguage() { relabelDesktop({ menu: refreshApplicationMenu, trays: [desktopTray, linuxTray, lendingTray], window: mainWindow, title: mainWindowTitle, badge: applyUnreadBadge }); }
async function workspaceMenuAction(action) {
try { await action(); } catch (error) {
@@ -2791,13 +2793,14 @@ app.whenReady().then(async () => { launchRecord.mark("ready");
clearCache: () => session.defaultSession.clearCache(),
log: slog,
});
- if (process.platform === "win32") {
+ if (process.platform === "win32" || process.platform === "linux") {
try {
- desktopTray = createSystemTray({
+ const tray = createSystemTray({
Tray, Menu, nativeImage, iconPath: APP_ICON, t: nativeT,
getWindow: () => startupScreen?.window ?? mainWindow ?? (openWindowForLink?.(), mainWindow),
onQuit: () => app.quit(),
});
+ if (process.platform === "win32") desktopTray = tray; else linuxTray = tray;
} catch (error) {
slog(`system tray unavailable: ${error?.message ?? error}`);
}
@@ -3120,5 +3123,5 @@ function releaseDesktopDataDirLease() {
// before-quit is too early (this app defers it); will-quit is Electron's last boundary, and the process hook covers app.exit().
app.on("will-quit", releaseDesktopDataDirLease);
-app.on("will-quit", () => { desktopTray?.destroy(); void tailnetShare.stop(); });
+app.on("will-quit", () => { desktopTray?.destroy(); linuxTray?.destroy(); void tailnetShare.stop(); });
process.once("exit", releaseDesktopDataDirLease);
diff --git a/electron/native-language.node-test.mjs b/electron/native-language.node-test.mjs
index dd9ca8ba89..326fb61985 100644
--- a/electron/native-language.node-test.mjs
+++ b/electron/native-language.node-test.mjs
@@ -82,7 +82,7 @@ test("a new language redraws main's menu, both trays, the window title and the b
lendingTray.update({ clouds: ["My Cloud"], using: [], paused: false });
const office = { id: "o", kind: "remote", name: "Office", origin: "https://office.example.test" };
const context = vm.createContext({
- desktopTray, lendingTray, nativeT: text.t, relabelDesktop,
+ desktopTray, linuxTray: null, lendingTray, nativeT: text.t, relabelDesktop,
refreshApplicationMenu: () => calls.push(["menu", text.t("native.menu.server")]),
applyUnreadBadge: () => calls.push(["badge", text.t("native.badge.none")]),
mainWindow: { isDestroyed: () => false, setTitle: (title) => calls.push(["title", title]) },