Kaynağa Gözat

Remove reboot after WiFi connect (nmcli switches live)

- Remove _schedule_reboot and reboot logic from connect_to_network
- Remove rebooting screen from frontend
- After connecting, refresh status/saved/networks in-place
- Update help text to remove reboot mention

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tuanchris 4 ay önce
ebeveyn
işleme
bdd93c572f
2 değiştirilmiş dosya ile 10 ekleme ve 47 silme
  1. 7 30
      frontend/src/pages/WiFiSetupPage.tsx
  2. 3 17
      modules/wifi/manager.py

+ 7 - 30
frontend/src/pages/WiFiSetupPage.tsx

@@ -56,7 +56,6 @@ export function WiFiSetupPage() {
   const [isScanning, setIsScanning] = useState(false)
   const [isScanning, setIsScanning] = useState(false)
   const [isConnecting, setIsConnecting] = useState(false)
   const [isConnecting, setIsConnecting] = useState(false)
   const [isSaving, setIsSaving] = useState(false)
   const [isSaving, setIsSaving] = useState(false)
-  const [isRebooting, setIsRebooting] = useState(false)
   const [isManualEntry, setIsManualEntry] = useState(false)
   const [isManualEntry, setIsManualEntry] = useState(false)
   const [manualSsid, setManualSsid] = useState('')
   const [manualSsid, setManualSsid] = useState('')
   const [forgetSsid, setForgetSsid] = useState<string | null>(null)
   const [forgetSsid, setForgetSsid] = useState<string | null>(null)
@@ -128,8 +127,11 @@ export function WiFiSetupPage() {
       })
       })
 
 
       if (result.success) {
       if (result.success) {
-        setIsRebooting(true)
         toast.success(result.message)
         toast.success(result.message)
+        closeDialog()
+        fetchStatus()
+        fetchSaved()
+        scanNetworks()
       }
       }
     } catch (err) {
     } catch (err) {
       const message = err instanceof Error ? err.message : 'Connection failed'
       const message = err instanceof Error ? err.message : 'Connection failed'
@@ -224,30 +226,6 @@ export function WiFiSetupPage() {
 
 
   const isHotspotMode = status?.mode === 'hotspot'
   const isHotspotMode = status?.mode === 'hotspot'
 
 
-  if (isRebooting) {
-    return (
-      <div className="container max-w-lg mx-auto px-4 py-8">
-        <Card>
-          <CardContent className="pt-6">
-            <div className="text-center space-y-4">
-              <span className="material-icons text-5xl text-blue-500 animate-spin">refresh</span>
-              <h2 className="text-xl font-semibold">Rebooting...</h2>
-              <p className="text-muted-foreground">
-                The system is rebooting to connect to <strong>{isManualEntry ? manualSsid : selectedNetwork?.ssid}</strong>.
-              </p>
-              <p className="text-sm text-muted-foreground">
-                Once connected, access Dune Weaver on your home network at:
-              </p>
-              <code className="text-sm bg-muted px-2 py-1 rounded">
-                http://{status?.hostname || 'duneweaver'}.local
-              </code>
-            </div>
-          </CardContent>
-        </Card>
-      </div>
-    )
-  }
-
   return (
   return (
     <div className="container max-w-lg mx-auto px-3 py-4 space-y-3">
     <div className="container max-w-lg mx-auto px-3 py-4 space-y-3">
       {/* Hotspot Welcome Banner */}
       {/* Hotspot Welcome Banner */}
@@ -403,8 +381,7 @@ export function WiFiSetupPage() {
         <>
         <>
           <Separator />
           <Separator />
           <div className="text-center text-sm text-muted-foreground space-y-1">
           <div className="text-center text-sm text-muted-foreground space-y-1">
-            <p>After connecting, the system will reboot.</p>
-            <p>Reconnect to your home WiFi and access Dune Weaver at:</p>
+            <p>After connecting, access Dune Weaver at:</p>
             <code className="text-xs bg-muted px-2 py-1 rounded">
             <code className="text-xs bg-muted px-2 py-1 rounded">
               http://{status?.hostname || 'duneweaver'}.local
               http://{status?.hostname || 'duneweaver'}.local
             </code>
             </code>
@@ -621,7 +598,7 @@ export function WiFiSetupPage() {
                   ) : (
                   ) : (
                     <>
                     <>
                       <span className="material-icons text-sm mr-2">wifi</span>
                       <span className="material-icons text-sm mr-2">wifi</span>
-                      Connect{isHotspotMode ? ' & Reboot' : ''}
+                      Connect
                     </>
                     </>
                   )}
                   )}
                 </Button>
                 </Button>
@@ -640,7 +617,7 @@ export function WiFiSetupPage() {
                 ) : (
                 ) : (
                   <>
                   <>
                     <span className="material-icons text-sm mr-2">wifi</span>
                     <span className="material-icons text-sm mr-2">wifi</span>
-                    Connect{isHotspotMode ? ' & Reboot' : ''}
+                    Connect
                   </>
                   </>
                 )}
                 )}
               </Button>
               </Button>

+ 3 - 17
modules/wifi/manager.py

@@ -243,7 +243,7 @@ def get_saved_connections() -> list[dict]:
 
 
 
 
 async def connect_to_network(ssid: str, password: str) -> dict:
 async def connect_to_network(ssid: str, password: str) -> dict:
-    """Connect to a WiFi network and schedule reboot.
+    """Connect to a WiFi network.
 
 
     Uses explicit connection profile creation (nmcli con add) instead of
     Uses explicit connection profile creation (nmcli con add) instead of
     'nmcli dev wifi connect' because the latter fails on Pi Trixie with
     'nmcli dev wifi connect' because the latter fails on Pi Trixie with
@@ -293,14 +293,11 @@ async def connect_to_network(ssid: str, password: str) -> dict:
             run_nmcli_check("con", "delete", ssid, timeout=10)
             run_nmcli_check("con", "delete", ssid, timeout=10)
             return {"success": False, "message": error_msg}
             return {"success": False, "message": error_msg}
 
 
-        logger.info(f"WiFi connection to '{ssid}' successful, scheduling reboot...")
-
-        # Schedule reboot so the response can be sent first
-        asyncio.get_event_loop().call_later(3, _schedule_reboot)
+        logger.info(f"WiFi connection to '{ssid}' successful")
 
 
         return {
         return {
             "success": True,
             "success": True,
-            "message": f"Connected to '{ssid}'. Rebooting in 3 seconds...",
+            "message": f"Connected to '{ssid}'.",
         }
         }
 
 
     except subprocess.TimeoutExpired:
     except subprocess.TimeoutExpired:
@@ -358,17 +355,6 @@ def save_network(ssid: str, password: str) -> dict:
         return {"success": False, "message": str(e)}
         return {"success": False, "message": str(e)}
 
 
 
 
-def _schedule_reboot():
-    """Trigger a system reboot via systemctl (communicates over D-Bus)."""
-    try:
-        logger.info("Rebooting system for WiFi mode change...")
-        subprocess.run(["systemctl", "reboot"], check=True)
-    except FileNotFoundError:
-        logger.error("systemctl not found — ensure systemd is installed in container")
-    except Exception as e:
-        logger.error(f"Reboot failed: {e}")
-
-
 def forget_network(ssid: str) -> dict:
 def forget_network(ssid: str) -> dict:
     """Delete a saved WiFi connection by SSID.
     """Delete a saved WiFi connection by SSID.