+
{title}
@@ -111,4 +111,4 @@ export function ConfirmDialog({
);
-}
+}
\ No newline at end of file
diff --git a/ui/src/routes/devices.$id.settings.advanced.tsx b/ui/src/routes/devices.$id.settings.advanced.tsx
index 927178e..8f95a57 100644
--- a/ui/src/routes/devices.$id.settings.advanced.tsx
+++ b/ui/src/routes/devices.$id.settings.advanced.tsx
@@ -1,17 +1,16 @@
-
-import { useCallback, useState, useEffect } from "react";
+import { useCallback, useEffect, useState } from "react";
import { GridCard } from "@components/Card";
-import { SettingsPageHeader } from "../components/SettingsPageheader";
-import Checkbox from "../components/Checkbox";
-import { useJsonRpc } from "../hooks/useJsonRpc";
-import notifications from "../notifications";
-import { TextAreaWithLabel } from "../components/TextArea";
-import { isOnDevice } from "../main";
import { Button } from "../components/Button";
+import Checkbox from "../components/Checkbox";
+import { ConfirmDialog } from "../components/ConfirmDialog";
+import { SettingsPageHeader } from "../components/SettingsPageheader";
+import { TextAreaWithLabel } from "../components/TextArea";
import { useSettingsStore } from "../hooks/stores";
-
+import { useJsonRpc } from "../hooks/useJsonRpc";
+import { isOnDevice } from "../main";
+import notifications from "../notifications";
import { SettingsItem } from "./devices.$id.settings";
@@ -22,6 +21,8 @@ export default function SettingsAdvancedRoute() {
const setDeveloperMode = useSettingsStore(state => state.setDeveloperMode);
const [devChannel, setDevChannel] = useState(false);
const [usbEmulationEnabled, setUsbEmulationEnabled] = useState(false);
+ const [showLoopbackWarning, setShowLoopbackWarning] = useState(false);
+ const [localLoopbackOnly, setLocalLoopbackOnly] = useState(false);
const settings = useSettingsStore();
@@ -46,6 +47,11 @@ export default function SettingsAdvancedRoute() {
if ("error" in resp) return;
setDevChannel(resp.result as boolean);
});
+
+ send("getLocalLoopbackOnly", {}, resp => {
+ if ("error" in resp) return;
+ setLocalLoopbackOnly(resp.result as boolean);
+ });
}, [send, setDeveloperMode]);
const getUsbEmulationState = useCallback(() => {
@@ -122,6 +128,42 @@ export default function SettingsAdvancedRoute() {
});
};
+ const handleLoopbackOnlyModeChange = (enabled: boolean) => {
+ // If trying to enable loopback-only mode, show warning first
+ if (enabled) {
+ setShowLoopbackWarning(true);
+ } else {
+ // If disabling, just proceed
+ applyLoopbackOnlyMode(false);
+ }
+ };
+
+ const applyLoopbackOnlyMode = (enabled: boolean) => {
+ send("setLocalLoopbackOnly", { enabled }, resp => {
+ if ("error" in resp) {
+ notifications.error(
+ `Failed to ${enabled ? "enable" : "disable"} loopback-only mode: ${resp.error.data || "Unknown error"}`,
+ );
+ return;
+ }
+ setLocalLoopbackOnly(enabled);
+ if (enabled) {
+ notifications.success(
+ "Loopback-only mode enabled. Restart your device to apply.",
+ );
+ } else {
+ notifications.success(
+ "Loopback-only mode disabled. Restart your device to apply.",
+ );
+ }
+ });
+ };
+
+ const confirmLoopbackModeEnable = () => {
+ applyLoopbackOnlyMode(true);
+ setShowLoopbackWarning(false);
+ };
+
return (
-
+
);
}