Merge pull request 'fix(desktop): without a tray, the first-close dialog defaults to Quit (cinny-desktop #37)' (#416) from fix/close-no-tray into lotus
CI / Build & Quality Checks (push) Canceled after 0s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Secret scan (gitleaks) (push) Canceled after 0s
CI / Docker image build & smoke test (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s

This commit was merged in pull request #416.
This commit is contained in:
2026-10-18 08:18:30 -04:00
+56 -10
View File
@@ -26,6 +26,10 @@ import { useModalStyle } from '../hooks/useModalStyle';
export function CloseBehaviorPrompt() { export function CloseBehaviorPrompt() {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [launchOnLogin, setLaunchOnLogin] = useState(false); const [launchOnLogin, setLaunchOnLogin] = useState(false);
// [cinny-desktop #37] Stock GNOME has no tray host: "keep running in the
// tray" would hide the window with no icon to bring it back. Older desktop
// builds lack the command; assume a tray then (the old behaviour).
const [hasTray, setHasTray] = useState(true);
const modalStyle = useModalStyle(420); const modalStyle = useModalStyle(420);
// Tells the native side we're listening (see get_close_behavior). // Tells the native side we're listening (see get_close_behavior).
@@ -34,7 +38,17 @@ export function CloseBehaviorPrompt() {
tauriInvoke()?.('get_close_behavior').catch(() => undefined); tauriInvoke()?.('get_close_behavior').catch(() => undefined);
}, []); }, []);
useTauriEvent('lotus-close-requested', () => setOpen(true)); useTauriEvent('lotus-close-requested', () => {
const ask = tauriInvoke()?.('has_tray_host');
if (!ask) {
setOpen(true);
return;
}
ask
.then((v) => setHasTray(v !== false))
.catch(() => setHasTray(true))
.finally(() => setOpen(true));
});
const choose = useCallback( const choose = useCallback(
(value: 'tray' | 'quit') => { (value: 'tray' | 'quit') => {
@@ -51,7 +65,7 @@ export function CloseBehaviorPrompt() {
<OverlayCenter> <OverlayCenter>
<FocusTrap <FocusTrap
focusTrapOptions={{ focusTrapOptions={{
initialFocus: '#close-behavior-keep', initialFocus: hasTray ? '#close-behavior-keep' : '#close-behavior-quit',
// Dismissing without choosing keeps the window open; the next close // Dismissing without choosing keeps the window open; the next close
// asks again. // asks again.
onDeactivate: () => setOpen(false), onDeactivate: () => setOpen(false),
@@ -80,8 +94,9 @@ export function CloseBehaviorPrompt() {
</Header> </Header>
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400"> <Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
<Text priority="400" id="close-behavior-body"> <Text priority="400" id="close-behavior-body">
Lotus Chat can keep running in the system tray when you close this window, so {hasTray
messages, notifications and calls still reach you. Open it again from the tray icon. ? 'Lotus Chat can keep running in the system tray when you close this window, so messages, notifications and calls still reach you. Open it again from the tray icon.'
: "Your desktop doesn't show tray icons, so if Lotus Chat keeps running after you close this window, the only way back is to launch it again."}
</Text> </Text>
<Box as="label" alignItems="Center" gap="200" style={{ cursor: 'pointer' }}> <Box as="label" alignItems="Center" gap="200" style={{ cursor: 'pointer' }}>
<Checkbox <Checkbox
@@ -95,12 +110,43 @@ export function CloseBehaviorPrompt() {
<Text size="T300">Start Lotus Chat when I sign in to my computer</Text> <Text size="T300">Start Lotus Chat when I sign in to my computer</Text>
</Box> </Box>
<Box direction="Column" gap="200"> <Box direction="Column" gap="200">
<Button id="close-behavior-keep" variant="Primary" onClick={() => choose('tray')}> {hasTray ? (
<Text size="B400">Keep running in the tray</Text> <>
</Button> <Button
<Button variant="Secondary" fill="Soft" onClick={() => choose('quit')}> id="close-behavior-keep"
<Text size="B400">Quit when I close the window</Text> variant="Primary"
</Button> onClick={() => choose('tray')}
>
<Text size="B400">Keep running in the tray</Text>
</Button>
<Button
id="close-behavior-quit"
variant="Secondary"
fill="Soft"
onClick={() => choose('quit')}
>
<Text size="B400">Quit when I close the window</Text>
</Button>
</>
) : (
<>
<Button
id="close-behavior-quit"
variant="Primary"
onClick={() => choose('quit')}
>
<Text size="B400">Quit when I close the window</Text>
</Button>
<Button
id="close-behavior-keep"
variant="Secondary"
fill="Soft"
onClick={() => choose('tray')}
>
<Text size="B400">Keep running in the background</Text>
</Button>
</>
)}
</Box> </Box>
<Text size="T200" priority="300"> <Text size="T200" priority="300">
You can change this in Settings → General. You can change this in Settings → General.