Add wakelock feature to prevent system sleep while Goose is working (#3321)

Signed-off-by: Simon Sickle <51972200+simonsickle@users.noreply.github.com>
This commit is contained in:
Simon Sickle
2025-07-17 04:09:08 -04:00
committed by GitHub
parent 9351027d1b
commit 759cbc7acb
4 changed files with 71 additions and 7 deletions
@@ -19,6 +19,7 @@ export default function AppSettingsSection({ scrollToSection }: AppSettingsSecti
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);
const [showNotificationModal, setShowNotificationModal] = useState(false);
@@ -147,6 +148,10 @@ export default function AppSettingsSection({ scrollToSection }: AppSettingsSecti
setQuitConfirmationEnabled(enabled);
});
window.electron.getWakelockState().then((enabled) => {
setWakelockEnabled(enabled);
});
if (isMacOS) {
window.electron.getDockIconState().then((enabled) => {
setDockIconEnabled(enabled);
@@ -202,6 +207,14 @@ export default function AppSettingsSection({ scrollToSection }: AppSettingsSecti
}
};
const handleWakelockToggle = async () => {
const newState = !wakelockEnabled;
const success = await window.electron.setWakelock(newState);
if (success) {
setWakelockEnabled(newState);
}
};
const handleShowPricingToggle = (checked: boolean) => {
setShowPricing(checked);
localStorage.setItem('show_pricing', String(checked));
@@ -299,6 +312,23 @@ export default function AppSettingsSection({ scrollToSection }: AppSettingsSecti
</div>
</div>
{/* Prevent Sleep */}
<div className="flex items-center justify-between">
<div>
<h3 className="text-text-default text-xs">Prevent Sleep</h3>
<p className="text-xs text-text-muted max-w-md mt-[2px]">
Keep your computer awake while Goose is running a task (screen can still lock)
</p>
</div>
<div className="flex items-center">
<Switch
checked={wakelockEnabled}
onCheckedChange={handleWakelockToggle}
variant="mono"
/>
</div>
</div>
{/* Cost Tracking */}
{COST_TRACKING_ENABLED && (
<div className="flex items-center justify-between mb-4">