YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(settings): keep power mode selector visible when engine /power is down
Louis Beaumont856b662062ec
diff --git a/apps/screenpipe-app-tauri/components/settings/battery-saver-section.tsx b/apps/screenpipe-app-tauri/components/settings/battery-saver-section.tsxindex 7836af498..eb78bb38a 100644--- a/apps/screenpipe-app-tauri/components/settings/battery-saver-section.tsx+++ b/apps/screenpipe-app-tauri/components/settings/battery-saver-section.tsx@@ -67,9 +67,8 @@ const UNKNOWN_PROFILE_INFO = {} as const;export function BatterySaverSection() {- const { updateSettings } = useSettings();+ const { settings, updateSettings } = useSettings();const [status, setStatus] = useState<PowerStatus | null>(null);- const [loading, setLoading] = useState(true);const [updating, setUpdating] = useState(false);const fetchStatus = useCallback(async () => {@@ -80,9 +79,7 @@ export function BatterySaverSection() {setStatus(data);}} catch {- // Server may not be running yet- } finally {- setLoading(false);+ // Server may not be running yet — keep last-known status if any}}, []);@@ -95,6 +92,9 @@ export function BatterySaverSection() {const setMode = async (mode: PowerMode) => {if (updating) return;setUpdating(true);+ // Always persist preference — backend will pick it up on next start+ // even if the live POST fails because the engine isn't up yet.+ await updateSettings({ powerMode: mode });try {const res = await localFetch("/power", {method: "POST",@@ -104,32 +104,22 @@ export function BatterySaverSection() {if (res.ok) {const data: PowerStatus = await res.json();setStatus(data);- // Persist to settings store so it survives app restarts- await updateSettings({ powerMode: mode });}} catch {- // ignore+ // ignore — preference is already saved} finally {setUpdating(false);}};- if (loading) {- return (- <div className="space-y-3">- <h3 className="text-sm font-medium text-foreground">power mode</h3>- <div className="text-xs text-muted-foreground">loading...</div>- </div>- );- }-- if (!status) {- return null; // Server doesn't support power API yet- }-- const { state, active_profile, user_pref } = status;- const profileInfo = PROFILE_INFO[active_profile] ?? UNKNOWN_PROFILE_INFO;- const ProfileIcon = profileInfo.icon;+ // Live state from the engine — may be null if the server isn't responding.+ const state = status?.state ?? null;+ const active_profile = status?.active_profile ?? null;+ const user_pref: PowerMode = status?.user_pref ?? settings.powerMode ?? "auto";+ const profileInfo = active_profile+ ? (PROFILE_INFO[active_profile] ?? UNKNOWN_PROFILE_INFO)+ : null;+ const ProfileIcon = profileInfo?.icon;const modes: { value: PowerMode; label: string; description: string }[] = [{@@ -159,28 +149,32 @@ export function BatterySaverSection() {</p></div>- {/* Battery status badge */}- <div className="flex items-center gap-1.5 text-xs text-muted-foreground">- {state.on_ac ? (- <BatteryCharging className="h-3.5 w-3.5" />- ) : state.battery_pct !== null && state.battery_pct <= 20 ? (- <BatteryLow className="h-3.5 w-3.5" />- ) : (- <Battery className="h-3.5 w-3.5" />- )}- <span>- {state.battery_pct !== null ? `${state.battery_pct}%` : "AC"}- {state.on_ac ? " (charging)" : ""}- </span>- </div>+ {/* Battery status badge — only when engine is reachable */}+ {state && (+ <div className="flex items-center gap-1.5 text-xs text-muted-foreground">+ {state.on_ac ? (+ <BatteryCharging className="h-3.5 w-3.5" />+ ) : state.battery_pct !== null && state.battery_pct <= 20 ? (+ <BatteryLow className="h-3.5 w-3.5" />+ ) : (+ <Battery className="h-3.5 w-3.5" />+ )}+ <span>+ {state.battery_pct !== null ? `${state.battery_pct}%` : "AC"}+ {state.on_ac ? " (charging)" : ""}+ </span>+ </div>+ )}</div>- {/* Active profile indicator */}- <div className="flex items-center gap-2 px-3 py-2 border border-border bg-card rounded text-xs">- <ProfileIcon className="h-3.5 w-3.5" />- <span className="font-medium text-foreground">{profileInfo.label}</span>- <span className="text-muted-foreground">— {profileInfo.description}</span>- </div>+ {/* Active profile indicator — only when engine is reachable */}+ {profileInfo && ProfileIcon && (+ <div className="flex items-center gap-2 px-3 py-2 border border-border bg-card rounded text-xs">+ <ProfileIcon className="h-3.5 w-3.5" />+ <span className="font-medium text-foreground">{profileInfo.label}</span>+ <span className="text-muted-foreground">— {profileInfo.description}</span>+ </div>+ )}{/* Mode selector */}<div className="grid grid-cols-3 gap-2">@@ -208,7 +202,7 @@ export function BatterySaverSection() {</div>{/* Thermal warning */}- {(state.thermal_state === "serious" || state.thermal_state === "critical") && (+ {state && (state.thermal_state === "serious" || state.thermal_state === "critical") && (<div className="flex items-center gap-2 px-3 py-2 border border-border bg-card rounded text-xs text-muted-foreground"><span>System is thermally throttled — battery saver active regardless of preference