controller: Desktop start/stop toggle; rename hotspot/bluetooth actions to what they do

Add a Desktop toggle to the Controller (both UIs) that starts/stops
display-manager.service. Fail open: the unit is never enabled/disabled,
so the desktop always returns on reboot; users who want it disabled
across reboots can set the default target themselves.

Rename the hotspot and bluetooth actions to reflect their real behavior:
- enable/disable_hotspot -> start/stop_hotspot (/api/hotspot/start|stop)
- enable/disable_bluetooth -> unblock/block_bluetooth (rfkill semantics,
  /api/bluetooth/unblock|block)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-07-29 14:57:28 -06:00 • committed by lrnselfreliance
parent a4eeba14ee
commit 3e559e1bf8
14 changed files with 712 additions and 132 deletions

View file

@ -43,10 +43,12 @@ import {
updateDomain,
} from "../api";
import {
enableBluetooth,
disableBluetooth,
enableHotspot,
disableHotspot,
unblockBluetooth,
blockBluetooth,
startHotspot,
stopHotspot,
startDesktop,
stopDesktop,
enableThrottle,
disableThrottle,
getControllerStats,
@ -1049,9 +1051,9 @@ export const useHotspot = () => {
setOn(null);
try {
if (enable) {
await enableHotspot();
await startHotspot();
} else {
await disableHotspot();
await stopHotspot();
}
} catch (e) {
console.error('Hotspot error:', e);
@ -1191,9 +1193,9 @@ export const useBluetooth = () => {
setOn(null);
try {
if (enable) {
await enableBluetooth();
await unblockBluetooth();
} else {
await disableBluetooth();
await blockBluetooth();
}
} catch (e) {
console.error('Bluetooth error:', e);
@ -1209,6 +1211,43 @@ export const useBluetooth = () => {
return {on, setBluetooth: localSetBluetooth};
}
export const useDesktop = () => {
const [on, setOn] = useState(null);
const {status} = useContext(StatusContext);
useEffect(() => {
const desktopStatus = status?.desktop_status;
if (desktopStatus === 'on') {
setOn(true);
} else if (desktopStatus === 'off') {
setOn(false);
} else {
setOn(null);
}
}, [status?.desktop_status]);
const localSetDesktop = async (running) => {
setOn(null);
try {
if (running) {
await startDesktop();
} else {
await stopDesktop();
}
} catch (e) {
console.error('Desktop error:', e);
toast({
type: 'error',
title: 'Desktop Error',
description: e.message || 'Could not start/stop the desktop. See server logs.',
time: 5000,
});
}
}
return {on, setDesktop: localSetDesktop};
}
export const useSearchDirectories = (value) => {
const [directoryName, setDirectoryName] = useState(value ?? '');
const [directories, setDirectories] = useState(null);