Skip to content
Merged
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
30 changes: 0 additions & 30 deletions ui/desktop/src/components/settings/app/AppSettingsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ interface AppSettingsSectionProps {
export default function AppSettingsSection({ scrollToSection }: AppSettingsSectionProps) {
const [menuBarIconEnabled, setMenuBarIconEnabled] = useState(true);
const [dockIconEnabled, setDockIconEnabled] = useState(true);
const [quitConfirmationEnabled, setQuitConfirmationEnabled] = useState(true);
const [wakelockEnabled, setWakelockEnabled] = useState(true);
const [isMacOS, setIsMacOS] = useState(false);
const [isDockSwitchDisabled, setIsDockSwitchDisabled] = useState(false);
Expand Down Expand Up @@ -144,10 +143,6 @@ export default function AppSettingsSection({ scrollToSection }: AppSettingsSecti
setMenuBarIconEnabled(enabled);
});

window.electron.getQuitConfirmationState().then((enabled) => {
setQuitConfirmationEnabled(enabled);
});

window.electron.getWakelockState().then((enabled) => {
setWakelockEnabled(enabled);
});
Expand Down Expand Up @@ -199,14 +194,6 @@ export default function AppSettingsSection({ scrollToSection }: AppSettingsSecti
}
};

const handleQuitConfirmationToggle = async () => {
const newState = !quitConfirmationEnabled;
const success = await window.electron.setQuitConfirmation(newState);
if (success) {
setQuitConfirmationEnabled(newState);
}
};

const handleWakelockToggle = async () => {
const newState = !wakelockEnabled;
const success = await window.electron.setWakelock(newState);
Expand Down Expand Up @@ -295,23 +282,6 @@ export default function AppSettingsSection({ scrollToSection }: AppSettingsSecti
</div>
)}

{/* Quit Confirmation */}
<div className="flex items-center justify-between">
<div>
<h3 className="text-text-default text-xs">Quit confirmation</h3>
<p className="text-xs text-text-muted max-w-md mt-[2px]">
Show confirmation dialog when quitting the app
</p>
</div>
<div className="flex items-center">
<Switch
checked={quitConfirmationEnabled}
onCheckedChange={handleQuitConfirmationToggle}
variant="mono"
/>
</div>
</div>

{/* Prevent Sleep */}
<div className="flex items-center justify-between">
<div>
Expand Down
65 changes: 0 additions & 65 deletions ui/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1267,29 +1267,6 @@ ipcMain.handle('open-notifications-settings', async () => {
}
});

// Handle quit confirmation setting
ipcMain.handle('set-quit-confirmation', async (_event, show: boolean) => {
try {
const settings = loadSettings();
settings.showQuitConfirmation = show;
saveSettings(settings);
return true;
} catch (error) {
console.error('Error setting quit confirmation:', error);
return false;
}
});

ipcMain.handle('get-quit-confirmation-state', () => {
try {
const settings = loadSettings();
return settings.showQuitConfirmation ?? true;
} catch (error) {
console.error('Error getting quit confirmation state:', error);
return true;
}
});

// Handle wakelock setting
ipcMain.handle('set-wakelock', async (_event, enable: boolean) => {
try {
Expand Down Expand Up @@ -2317,48 +2294,6 @@ app.on('will-quit', async () => {
}
});

// Quit when all windows are closed, except on macOS or if we have a tray icon.
// Add confirmation dialog when quitting with Cmd+Q (skip in dev mode)
app.on('before-quit', async (event) => {
// Skip confirmation dialog in development mode
if (MAIN_WINDOW_VITE_DEV_SERVER_URL) {
return; // Allow normal quit behavior in dev mode
}

// Check if quit confirmation is enabled in settings
const settings = loadSettings();
if (!settings.showQuitConfirmation) {
return; // Allow normal quit behavior if confirmation is disabled
}

// Prevent the default quit behavior
event.preventDefault();

// Show confirmation dialog
try {
const result = (await dialog.showMessageBox({
type: 'question',
buttons: ['Quit', 'Cancel'],
defaultId: 1, // Default to Cancel
title: 'Confirm Quit',
message: 'Are you sure you want to quit Goose?',
detail: 'Any unsaved changes may be lost.',
})) as unknown as { response: number };

if (result.response === 0) {
// User clicked "Quit"
// Set a flag to avoid showing the dialog again
app.removeAllListeners('before-quit');
// Force quit the app
process.nextTick(() => {
app.exit(0);
});
}
} catch (error) {
console.error('Error showing quit dialog:', error);
}
});

app.on('window-all-closed', () => {
// Only quit if we're not on macOS or don't have a tray icon
if (process.platform !== 'darwin' || !tray) {
Expand Down
4 changes: 0 additions & 4 deletions ui/desktop/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ type ElectronAPI = {
getSettings: () => Promise<unknown | null>;
getSecretKey: () => Promise<string>;
setSchedulingEngine: (engine: string) => Promise<boolean>;
setQuitConfirmation: (show: boolean) => Promise<boolean>;
getQuitConfirmationState: () => Promise<boolean>;
setWakelock: (enable: boolean) => Promise<boolean>;
getWakelockState: () => Promise<boolean>;
openNotificationsSettings: () => Promise<boolean>;
Expand Down Expand Up @@ -177,8 +175,6 @@ const electronAPI: ElectronAPI = {
getSettings: () => ipcRenderer.invoke('get-settings'),
getSecretKey: () => ipcRenderer.invoke('get-secret-key'),
setSchedulingEngine: (engine: string) => ipcRenderer.invoke('set-scheduling-engine', engine),
setQuitConfirmation: (show: boolean) => ipcRenderer.invoke('set-quit-confirmation', show),
getQuitConfirmationState: () => ipcRenderer.invoke('get-quit-confirmation-state'),
setWakelock: (enable: boolean) => ipcRenderer.invoke('set-wakelock', enable),
getWakelockState: () => ipcRenderer.invoke('get-wakelock-state'),
openNotificationsSettings: () => ipcRenderer.invoke('open-notifications-settings'),
Expand Down
2 changes: 0 additions & 2 deletions ui/desktop/src/utils/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export interface Settings {
showMenuBarIcon: boolean;
showDockIcon: boolean;
schedulingEngine: SchedulingEngine;
showQuitConfirmation: boolean;
enableWakelock: boolean;
}

Expand All @@ -30,7 +29,6 @@ const defaultSettings: Settings = {
showMenuBarIcon: true,
showDockIcon: true,
schedulingEngine: 'builtin-cron',
showQuitConfirmation: true,
enableWakelock: false,
};

Expand Down
Loading