Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a984bd0
feat: initial addition of tray icon
nmggithub Mar 12, 2026
64538f2
fix: fix formatting issues
nmggithub Mar 12, 2026
f9112f0
refactor: move entire tray implementation `tray.ts`
nmggithub Mar 12, 2026
beb08f3
fix: fix inverted boolean logic
nmggithub Mar 12, 2026
9549570
fix: don't duplicate tray configuration work
nmggithub Mar 12, 2026
fcd4f00
fix: use consistent export syntax in `tray.ts`
nmggithub Mar 12, 2026
3441ef1
feat: set up tray enablement ipc
nmggithub Mar 12, 2026
82bce0e
feat: add setting to toggle tray icon
nmggithub Mar 12, 2026
1a4f31c
feat: add thread menu items
nmggithub Mar 12, 2026
6169a61
fix: format files
nmggithub Mar 12, 2026
867d8f8
refactor: rename `useTray` hook to `useTrayEnabled`
nmggithub Mar 13, 2026
2d63b25
refactor: make tray state setter hook and move from update pattern to…
nmggithub Mar 13, 2026
14786ba
fix: remove leftover `console.log`
nmggithub Mar 13, 2026
0c2ca96
fix: format files as needed
nmggithub Mar 13, 2026
b6de8bd
fix: use `toSorted` instead of `sorted`
nmggithub Mar 15, 2026
e5d7fd3
fix: increase thread name truncation length in tray menu
nmggithub Mar 15, 2026
01156de
fix: remove old todo
nmggithub Mar 15, 2026
a5f2731
fix: address linter concerns
nmggithub Mar 15, 2026
7fa0ec2
fix: address additional linter concerns
nmggithub Mar 15, 2026
a0c944d
fix: actually fail early on non-macOS platforms
nmggithub Mar 15, 2026
10a9876
fix: create main window from tray if it doesn't exist
nmggithub Mar 15, 2026
9d0d67f
fix: don't rely on old thread state
nmggithub Mar 15, 2026
053e7f6
fix: add state updater to `useTrayState`
nmggithub Mar 15, 2026
8c1cd5b
fix: actually create main window on thread click from tray
nmggithub Mar 15, 2026
4ab4f1b
feat: allow for tray menu to re-open main window
nmggithub Mar 15, 2026
a1bc2ed
style: re-order hooks
nmggithub Mar 15, 2026
f388328
feat: add new thread in project action from tray
nmggithub Mar 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"dependencies": {
"effect": "catalog:",
"electron": "40.6.0",
"electron-updater": "^6.6.2"
"electron-updater": "^6.6.2",
"sharp": "^0.34.5"
},
"devDependencies": {
"@t3tools/contracts": "workspace:*",
Expand Down
12 changes: 12 additions & 0 deletions apps/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
reduceDesktopUpdateStateOnUpdateAvailable,
} from "./updateMachine";
import { isArm64HostRunningIntelBuild, resolveDesktopRuntimeInfo } from "./runtimeArch";
import { setupTrayIpcHandlers, setTrayEnabled, setReadyToHandleTrayMessages } from "./tray";

fixPath();

Expand Down Expand Up @@ -1330,13 +1331,16 @@ async function bootstrap(): Promise<void> {
writeDesktopLogHeader("bootstrap backend start requested");
mainWindow = createWindow();
writeDesktopLogHeader("bootstrap main window created");
setupTrayIpcHandlers();
writeDesktopLogHeader("bootstrap tray ipc handlers registered");
}

app.on("before-quit", () => {
isQuitting = true;
writeDesktopLogHeader("before-quit received");
clearUpdatePollTimer();
stopBackend();
setTrayEnabled(false);
restoreStdIoCapture?.();
});

Expand Down Expand Up @@ -1366,6 +1370,7 @@ app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
setReadyToHandleTrayMessages(false);
});

if (process.platform !== "win32") {
Expand All @@ -1389,3 +1394,10 @@ if (process.platform !== "win32") {
app.quit();
});
}

export function getMainWindow(createIfNeeded: boolean = false): BrowserWindow | null {
if (createIfNeeded && mainWindow === null) {
mainWindow = createWindow();
}
return mainWindow;
}
23 changes: 22 additions & 1 deletion apps/desktop/src/preload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { contextBridge, ipcRenderer } from "electron";
import type { DesktopBridge } from "@t3tools/contracts";
import type { DesktopBridge, DesktopTrayState } from "@t3tools/contracts";

const PICK_FOLDER_CHANNEL = "desktop:pick-folder";
const CONFIRM_CHANNEL = "desktop:confirm";
Expand All @@ -11,6 +11,11 @@ const UPDATE_STATE_CHANNEL = "desktop:update-state";
const UPDATE_GET_STATE_CHANNEL = "desktop:update-get-state";
const UPDATE_DOWNLOAD_CHANNEL = "desktop:update-download";
const UPDATE_INSTALL_CHANNEL = "desktop:update-install";
const SET_TRAY_ENABLED_CHANNEL = "desktop:set-tray-enabled";
const GET_TRAY_STATE_CHANNEL = "desktop:get-tray-state";
const SET_TRAY_STATE_CHANNEL = "desktop:set-tray-state";
const SET_READY_TO_HANDLE_TRAY_MESSAGES_CHANNEL = "desktop:set-ready-to-handle-tray-messages";
const TRAY_MESSAGE_CHANNEL = "desktop:tray-message";
const wsUrl = process.env.T3CODE_DESKTOP_WS_URL ?? null;

contextBridge.exposeInMainWorld("desktopBridge", {
Expand Down Expand Up @@ -45,4 +50,20 @@ contextBridge.exposeInMainWorld("desktopBridge", {
ipcRenderer.removeListener(UPDATE_STATE_CHANNEL, wrappedListener);
};
},
setTrayEnabled: (enabled: boolean) => ipcRenderer.invoke(SET_TRAY_ENABLED_CHANNEL, enabled),
getTrayState: () => ipcRenderer.invoke(GET_TRAY_STATE_CHANNEL),
setTrayState: (state: DesktopTrayState) => ipcRenderer.invoke(SET_TRAY_STATE_CHANNEL, state),
setReadyToHandleTrayMessages: (ready: boolean) =>
ipcRenderer.invoke(SET_READY_TO_HANDLE_TRAY_MESSAGES_CHANNEL, ready),
onTrayMessage: (listener) => {
const wrappedListener = (_event: Electron.IpcRendererEvent, message: unknown) => {
if (typeof message !== "object" || message === null) return;
listener(message as Parameters<typeof listener>[0]);
};

ipcRenderer.on(TRAY_MESSAGE_CHANNEL, wrappedListener);
return () => {
ipcRenderer.removeListener(TRAY_MESSAGE_CHANNEL, wrappedListener);
};
},
} satisfies DesktopBridge);
Loading