Skip to content

Commit 5aab507

Browse files
committed
fix(desktop): improve onboarding drag handling and permission prompts
Made-with: Cursor
1 parent b4f7b4f commit 5aab507

1 file changed

Lines changed: 37 additions & 18 deletions

File tree

apps/desktop/src/routes/(window-chrome)/onboarding.tsx

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ export default function OnboardingPage() {
365365
await generalSettingsStore.set({ hasCompletedOnboarding: true });
366366
}
367367
await commands.showWindow({ Main: { init_target_mode: null } });
368-
getCurrentWindow().close();
368+
await getCurrentWindow().close();
369369
};
370370

371371
const handleStartupDone = async () => {
@@ -484,7 +484,10 @@ export default function OnboardingPage() {
484484
}
485485
`}
486486
</style>
487-
<div class="flex flex-col flex-1 min-h-0 overflow-hidden relative">
487+
<div
488+
data-tauri-drag-region="none"
489+
class="flex flex-col flex-1 min-h-0 overflow-hidden relative"
490+
>
488491
<OnboardingAmbientBackdrop />
489492
<div class="relative flex-1 min-h-0 z-10">
490493
<Show when={isMacOS()}>
@@ -567,11 +570,15 @@ function StepNavigation(props: {
567570
onSkip?: () => void;
568571
}) {
569572
return (
570-
<div class="flex flex-col items-center gap-2 px-8 pb-5 pt-2 shrink-0 relative z-40">
573+
<div
574+
data-tauri-drag-region="none"
575+
class="flex flex-col items-center gap-2 px-8 pb-5 pt-2 shrink-0 relative z-40"
576+
>
571577
<div class="flex items-center justify-between w-full">
572578
<div class="flex-1">
573579
<Show when={props.showBack}>
574580
<button
581+
data-tauri-drag-region="none"
575582
type="button"
576583
onClick={props.onBack}
577584
class="flex items-center gap-1.5 text-[13px] text-gray-10 hover:text-gray-12 transition-colors duration-200"
@@ -600,6 +607,7 @@ function StepNavigation(props: {
600607
<div class="flex-1 flex justify-end">
601608
<div class="flex flex-col items-center gap-1.5">
602609
<Button
610+
data-tauri-drag-region="none"
603611
onClick={props.onNext}
604612
variant="primary"
605613
size="md"
@@ -616,6 +624,7 @@ function StepNavigation(props: {
616624
</Button>
617625
<Show when={props.showSkipOnboarding}>
618626
<button
627+
data-tauri-drag-region="none"
619628
type="button"
620629
onClick={() => props.onSkip?.()}
621630
class="text-[11px] text-gray-9 hover:text-gray-11 transition-colors duration-200 py-0.5"
@@ -649,7 +658,9 @@ function StepPanel(props: {
649658
? "translateX(-40px)"
650659
: "translateX(40px)",
651660
opacity: props.active ? 1 : 0,
661+
visibility: props.active ? "visible" : "hidden",
652662
"pointer-events": props.active ? "auto" : "none",
663+
"z-index": props.active ? 1 : 0,
653664
transition:
654665
"transform 400ms cubic-bezier(0.4, 0, 0.2, 1), opacity 300ms ease",
655666
}}
@@ -1980,16 +1991,17 @@ function PermissionsStep(props: {
19801991
);
19811992
});
19821993

1983-
const maybePromptRestartForScreenRecording = async () => {
1984-
const shouldRestart = await ask(
1985-
"After adding Cap in System Settings, you'll need to restart the app for the permission to take effect.",
1986-
{
1987-
title: "Restart Required",
1988-
kind: "info",
1989-
okLabel: "Restart, I've granted permission",
1990-
cancelLabel: "No, I still need to add it",
1991-
},
1992-
);
1994+
const maybePromptRestartForPermission = async (permission: OSPermission) => {
1995+
const message =
1996+
permission === "accessibility"
1997+
? "After enabling Accessibility for Cap in System Settings, macOS may keep showing it as denied until you restart the app."
1998+
: "After adding Cap in System Settings, you'll need to restart the app for the permission to take effect.";
1999+
const shouldRestart = await ask(message, {
2000+
title: "Restart Required",
2001+
kind: "info",
2002+
okLabel: "Restart, I've granted permission",
2003+
cancelLabel: "No, I still need to add it",
2004+
});
19932005
if (shouldRestart) {
19942006
await relaunch();
19952007
}
@@ -2009,8 +2021,11 @@ function PermissionsStep(props: {
20092021
status,
20102022
);
20112023
setCheck(result.check as unknown as Record<string, OSPermissionStatus>);
2012-
if (result.openedSettings && permission === "screenRecording") {
2013-
await maybePromptRestartForScreenRecording();
2024+
if (
2025+
result.openedSettings &&
2026+
(permission === "screenRecording" || permission === "accessibility")
2027+
) {
2028+
await maybePromptRestartForPermission(permission);
20142029
}
20152030
} catch (err) {
20162031
console.error(`Error requesting permission: ${err}`);
@@ -2025,8 +2040,8 @@ function PermissionsStep(props: {
20252040
setRequestingPermission(true);
20262041
try {
20272042
await commands.openPermissionSettings(permission);
2028-
if (permission === "screenRecording") {
2029-
await maybePromptRestartForScreenRecording();
2043+
if (permission === "screenRecording" || permission === "accessibility") {
2044+
await maybePromptRestartForPermission(permission);
20302045
}
20312046
setInitialCheck(false);
20322047
fetchPermissions();
@@ -2038,7 +2053,10 @@ function PermissionsStep(props: {
20382053
};
20392054

20402055
return (
2041-
<div class="flex flex-col items-center justify-center min-h-full px-12 gap-6">
2056+
<div
2057+
data-tauri-drag-region="none"
2058+
class="flex flex-col items-center justify-center min-h-full px-12 gap-6"
2059+
>
20422060
<div
20432061
class={cx(
20442062
"flex flex-col items-center gap-3 text-center max-w-[440px] transition-all duration-500",
@@ -2102,6 +2120,7 @@ function PermissionsStep(props: {
21022120
}
21032121
>
21042122
<Button
2123+
data-tauri-drag-region="none"
21052124
size="sm"
21062125
variant="gray"
21072126
class="shrink-0"

0 commit comments

Comments
 (0)