Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 20 additions & 12 deletions emain/emain-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,18 +299,14 @@ export class WaveBrowserWindow extends BaseWindow {
const fullConfig = await RpcApi.GetFullConfigCommand(ElectronWshClient);
if (numWindows > 1 || !fullConfig.settings["window:savelastwindow"]) {
if (fullConfig.settings["window:confirmclose"]) {
const workspace = await WorkspaceService.GetWorkspace(this.workspaceId);
if (isNonEmptyUnsavedWorkspace(workspace)) {
const choice = dialog.showMessageBoxSync(this, {
type: "question",
buttons: ["Cancel", "Close Window"],
title: "Confirm",
message:
"Window has unsaved tabs, closing window will delete existing tabs.\n\nContinue?",
});
if (choice === 0) {
return;
}
const choice = dialog.showMessageBoxSync(this, {
type: "question",
buttons: ["Cancel", "Close Window"],
title: "Confirm",
message: "Close this window?",
});
if (choice === 0) {
return;
}
}
this.deleteAllowed = true;
Expand Down Expand Up @@ -550,6 +546,18 @@ export class WaveBrowserWindow extends BaseWindow {
break;
case "closetab":
tabId = entry.tabId;
const closeTabConfig = await RpcApi.GetFullConfigCommand(ElectronWshClient);
if (closeTabConfig.settings["tab:confirmclose"]) {
const choice = dialog.showMessageBoxSync(this, {
type: "question",
buttons: ["Cancel", "Close Tab"],
title: "Confirm",
message: "Close this tab?",
});
if (choice === 0) {
return;
}
}
const rtn = await WorkspaceService.CloseTab(this.workspaceId, tabId, true);
if (rtn == null) {
console.log(
Expand Down
86 changes: 58 additions & 28 deletions emain/emain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
getActivityState,
getAndClearTermCommandsRun,
getForceQuit,
getGlobalIsQuitting,
getGlobalIsRelaunching,
setForceQuit,
setGlobalIsQuitting,
Expand Down Expand Up @@ -242,38 +243,67 @@ electronApp.on("window-all-closed", () => {
}
});
electronApp.on("before-quit", (e) => {
setGlobalIsQuitting(true);
updater?.stop();
if (unamePlatform == "win32") {
// win32 doesn't have a SIGINT, so we just let electron die, which
// ends up killing wavesrv via closing it's stdin.
return;
}
getWaveSrvProc()?.kill("SIGINT");
shutdownWshrpc();
if (getForceQuit()) {
// If already confirmed and in quit process, run shutdown logic
if (getGlobalIsQuitting()) {
updater?.stop();
if (unamePlatform == "win32") {
// win32 doesn't have a SIGINT, so we just let electron die, which
// ends up killing wavesrv via closing it's stdin.
return;
}
getWaveSrvProc()?.kill("SIGINT");
shutdownWshrpc();
if (getForceQuit()) {
return;
}
e.preventDefault();
const allWindows = getAllWaveWindows();
for (const window of allWindows) {
hideWindowWithCatch(window);
}
const allBuilders = getAllBuilderWindows();
for (const builder of allBuilders) {
builder.hide();
}
if (getIsWaveSrvDead()) {
console.log("wavesrv is dead, quitting immediately");
setForceQuit(true);
electronApp.quit();
return;
}
setTimeout(() => {
console.log("waiting for wavesrv to exit...");
setForceQuit(true);
electronApp.quit();
}, 3000);
return;
}

// First time through - check if confirmation needed
e.preventDefault();
const allWindows = getAllWaveWindows();
for (const window of allWindows) {
hideWindowWithCatch(window);
}
const allBuilders = getAllBuilderWindows();
for (const builder of allBuilders) {
builder.hide();
}
if (getIsWaveSrvDead()) {
console.log("wavesrv is dead, quitting immediately");
setForceQuit(true);
electronApp.quit();
return;
}
setTimeout(() => {
console.log("waiting for wavesrv to exit...");
setForceQuit(true);
fireAndForget(async () => {
// Skip confirmation if RPC client not ready (early quit before app fully started)
if (ElectronWshClient == null) {
setGlobalIsQuitting(true);
electronApp.quit();
return;
}
const fullConfig = await RpcApi.GetFullConfigCommand(ElectronWshClient);
if (fullConfig.settings["app:confirmquit"]) {
const choice = electron.dialog.showMessageBoxSync({
type: "question",
buttons: ["Cancel", "Quit"],
title: "Confirm",
message: "Quit Wave Terminal?",
});
if (choice === 0) {
return; // User cancelled
}
}
// User confirmed or setting disabled - proceed with quit
setGlobalIsQuitting(true);
electronApp.quit();
}, 3000);
});
});
process.on("SIGINT", () => {
console.log("Caught SIGINT, shutting down");
Expand Down
2 changes: 2 additions & 0 deletions pkg/wconfig/defaultconfig/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"window:magnifiedblockblurprimarypx": 10,
"window:fullscreenonlaunch": false,
"window:magnifiedblockblursecondarypx": 2,
"app:confirmquit": false,
"tab:confirmclose": false,
"window:confirmclose": true,
"window:savelastwindow": true,
"telemetry:enabled": true,
Expand Down
4 changes: 3 additions & 1 deletion pkg/wconfig/settingsconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type SettingsType struct {
AppDefaultNewBlock string `json:"app:defaultnewblock,omitempty"`
AppShowOverlayBlockNums *bool `json:"app:showoverlayblocknums,omitempty"`
AppCtrlVPaste *bool `json:"app:ctrlvpaste,omitempty"`
AppConfirmQuit bool `json:"app:confirmquit,omitempty"`

FeatureWaveAppBuilder bool `json:"feature:waveappbuilder,omitempty"`

Expand Down Expand Up @@ -120,7 +121,8 @@ type SettingsType struct {

PreviewShowHiddenFiles *bool `json:"preview:showhiddenfiles,omitempty"`

TabPreset string `json:"tab:preset,omitempty"`
TabPreset string `json:"tab:preset,omitempty"`
TabConfirmClose bool `json:"tab:confirmclose,omitempty"`

WidgetClear bool `json:"widget:*,omitempty"`
WidgetShowHelp *bool `json:"widget:showhelp,omitempty"`
Expand Down
6 changes: 6 additions & 0 deletions schema/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"app:ctrlvpaste": {
"type": "boolean"
},
"app:confirmquit": {
"type": "boolean"
},
"feature:waveappbuilder": {
"type": "boolean"
},
Expand Down Expand Up @@ -179,6 +182,9 @@
"tab:preset": {
"type": "string"
},
"tab:confirmclose": {
"type": "boolean"
},
"widget:*": {
"type": "boolean"
},
Expand Down