Download web/src/components/shell/simpleMode.ts from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 923 Bytes
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/components/shell/simpleMode.ts
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/web/src/components/shell/simpleMode.ts
-
curl -L -o simpleMode.ts https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/components/shell/simpleMode.ts
923 Bytes
| import { useEffect, useState } from 'react'; | |
| /* Simple mode: the test run page as one guided column (the current step only, the rest folded away), for people new | |
| to the app. Each person switches it in the account menu; the choice stays in this browser. */ | |
| const KEY = 'pw.simple'; | |
| const EVT = 'pw-simple'; | |
| export const simpleModeOn = () => { try { return window.localStorage.getItem(KEY) === 'on'; } catch { return false; } }; | |
| export function setSimpleMode(on: boolean) { | |
| try { window.localStorage.setItem(KEY, on ? 'on' : 'off'); } catch { /* storage blocked: the choice lasts this page */ } | |
| window.dispatchEvent(new Event(EVT)); | |
| } | |
| export function useSimpleMode() { | |
| const [on, setOn] = useState(simpleModeOn); | |
| useEffect(() => { | |
| const f = () => setOn(simpleModeOn()); | |
| window.addEventListener(EVT, f); | |
| return () => window.removeEventListener(EVT, f); | |
| }, []); | |
| return on; | |
| } | |