Files
paseo/packages/app/src/components/quitting-overlay.tsx
T
Mohamed Boudra 88f382cad3 Fix Cmd+Q on macOS leaving the desktop app alive
The before-quit handler preventDefaulted on every quit and re-fired
app.quit() from .finally. That re-entered Electron through the
window-all-closed gate, which on macOS is a no-op listener that
vetoes the quit — so the window closed but the process stayed up.

Use app.exit(0) to bypass the close → window-all-closed → will-quit
chain entirely. Also drop the daemon-stop NSAlert: with no parent
window it ran app-modal and stalled the child-process pipes for
'paseo daemon stop', so daemon shutdown waited on the user dismissing
the dialog. Replace it with an in-app overlay rendered in the renderer
via a paseo:event:quitting IPC event. Stop opening DevTools on dev boot.
2026-04-27 15:22:16 +07:00

68 lines
1.6 KiB
TypeScript

import { useEffect, useState } from "react";
import { Text, View } from "react-native";
import { StyleSheet, useUnistyles } from "react-native-unistyles";
import { LoadingSpinner } from "@/components/ui/loading-spinner";
import { getIsElectronRuntime } from "@/constants/layout";
import { listenToDesktopEvent } from "@/desktop/electron/events";
export function QuittingOverlay() {
const { theme } = useUnistyles();
const [quitting, setQuitting] = useState(false);
useEffect(() => {
if (!getIsElectronRuntime()) return;
let cancelled = false;
let unlisten: (() => void) | null = null;
void listenToDesktopEvent("quitting", () => {
if (!cancelled) setQuitting(true);
}).then((fn) => {
if (cancelled) {
fn();
} else {
unlisten = fn;
}
return undefined;
});
return () => {
cancelled = true;
unlisten?.();
};
}, []);
if (!quitting) return null;
return (
<View style={styles.overlay}>
<LoadingSpinner size="large" color={theme.colors.foregroundMuted} />
<Text style={styles.title}>Quitting Paseo…</Text>
<Text style={styles.detail}>Stopping the local daemon.</Text>
</View>
);
}
const styles = StyleSheet.create((theme) => ({
overlay: {
position: "absolute",
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: theme.colors.surface1,
alignItems: "center",
justifyContent: "center",
gap: theme.spacing[3],
zIndex: 9999,
},
title: {
color: theme.colors.foreground,
fontSize: theme.fontSize.base,
},
detail: {
color: theme.colors.foregroundMuted,
fontSize: theme.fontSize.sm,
},
}));