Skip to content

Commit 480e0c7

Browse files
committed
feat: support Windows right-click context menu to open directory in Wave Terminal
Pass workingDirectory from Electron second-instance event through createNewWaveWindow > createBrowserWindow, and set cmd:cwd metadata on new workspaces so shells spawn in the right-clicked directory. Also add .reg files for installing/removing the context menu entry.
1 parent 2e25ea1 commit 480e0c7

4 files changed

Lines changed: 52 additions & 3 deletions

File tree

emain/emain-window.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export type WindowOpts = {
2929
unamePlatform: NodeJS.Platform;
3030
isPrimaryStartupWindow?: boolean;
3131
foregroundWindow?: boolean;
32+
cwd?: string;
3233
};
3334

3435
export const MinWindowWidth = 800;
@@ -724,6 +725,9 @@ export async function createBrowserWindow(
724725
if (!waveWindow) {
725726
console.log("createBrowserWindow: no waveWindow");
726727
waveWindow = await WindowService.CreateWindow(null, "");
728+
if (opts.cwd && waveWindow?.workspaceid) {
729+
await ObjectService.UpdateObjectMeta(`workspace:${waveWindow.workspaceid}`, { "cmd:cwd": opts.cwd } as MetaType);
730+
}
727731
}
728732
let workspace = await WorkspaceService.GetWorkspace(waveWindow.workspaceid);
729733
if (!workspace) {
@@ -847,8 +851,8 @@ ipcMain.on("delete-workspace", (event, workspaceId) => {
847851
});
848852
});
849853

850-
export async function createNewWaveWindow() {
851-
log("createNewWaveWindow");
854+
export async function createNewWaveWindow(cwd?: string) {
855+
log("createNewWaveWindow" + (cwd ? ` cwd=${cwd}` : ""));
852856
const clientData = await ClientService.GetClientData();
853857
const fullConfig = await RpcApi.GetFullConfigCommand(ElectronWshClient);
854858
let recreatedWindow = false;
@@ -862,6 +866,7 @@ export async function createNewWaveWindow() {
862866
const win = await createBrowserWindow(existingWindowData, fullConfig, {
863867
unamePlatform,
864868
isPrimaryStartupWindow: false,
869+
cwd,
865870
});
866871
if (quakeWindow == null) {
867872
quakeWindow = win;
@@ -878,6 +883,7 @@ export async function createNewWaveWindow() {
878883
const newBrowserWindow = await createBrowserWindow(null, fullConfig, {
879884
unamePlatform,
880885
isPrimaryStartupWindow: false,
886+
cwd,
881887
});
882888
if (quakeWindow == null) {
883889
quakeWindow = newBrowserWindow;

emain/emain.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ async function appMain() {
388388
}
389389
electronApp.on("second-instance", (_event, argv, workingDirectory) => {
390390
console.log("second-instance event, argv:", argv, "workingDirectory:", workingDirectory);
391-
fireAndForget(createNewWaveWindow);
391+
const cwd = workingDirectory || undefined;
392+
fireAndForget(() => createNewWaveWindow(cwd));
392393
});
393394
try {
394395
await runWaveSrv(handleWSEvent);

wave-context-menu-remove.reg

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Windows Registry Editor Version 5.00
2+
3+
; ============================================================
4+
; Remove Wave Terminal Context Menu
5+
; ============================================================
6+
7+
[-HKEY_CLASSES_ROOT\Directory\Background\shell\WaveTerminal]
8+
[-HKEY_CLASSES_ROOT\Directory\shell\WaveTerminal]
9+
[-HKEY_CLASSES_ROOT\Drive\shell\WaveTerminal]

wave-context-menu.reg

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Windows Registry Editor Version 5.00
2+
3+
; ============================================================
4+
; Wave Terminal - Windows Right-Click Context Menu
5+
; ============================================================
6+
; Adds "Open in Wave Terminal" to:
7+
; 1. Right-click on empty space in a folder (Directory\Background)
8+
; 2. Right-click on a folder itself (Directory)
9+
; ============================================================
10+
11+
; --- Folder background (right-click empty space) ---
12+
[HKEY_CLASSES_ROOT\Directory\Background\shell\WaveTerminal]
13+
@="Open in Wave Terminal"
14+
"Icon"="C:\\Users\\azurr\\AppData\\Local\\Programs\\waveterm\\Wave.exe"
15+
16+
[HKEY_CLASSES_ROOT\Directory\Background\shell\WaveTerminal\command]
17+
@="\"C:\\Users\\azurr\\AppData\\Local\\Programs\\waveterm\\Wave.exe\" \"%V\""
18+
19+
; --- Folder itself (right-click on folder) ---
20+
[HKEY_CLASSES_ROOT\Directory\shell\WaveTerminal]
21+
@="Open in Wave Terminal"
22+
"Icon"="C:\\Users\\azurr\\AppData\\Local\\Programs\\waveterm\\Wave.exe"
23+
24+
[HKEY_CLASSES_ROOT\Directory\shell\WaveTerminal\command]
25+
@="\"C:\\Users\\azurr\\AppData\\Local\\Programs\\waveterm\\Wave.exe\" \"%1\""
26+
27+
; --- Drive root (right-click on drive in This PC) ---
28+
[HKEY_CLASSES_ROOT\Drive\shell\WaveTerminal]
29+
@="Open in Wave Terminal"
30+
"Icon"="C:\\Users\\azurr\\AppData\\Local\\Programs\\waveterm\\Wave.exe"
31+
32+
[HKEY_CLASSES_ROOT\Drive\shell\WaveTerminal\command]
33+
@="\"C:\\Users\\azurr\\AppData\\Local\\Programs\\waveterm\\Wave.exe\" \"%1\""

0 commit comments

Comments
 (0)