AI Engineering Workspace
PartialChat, files, terminal and preview in one place. Chat sessions run on a durable Postgres-backed queue (chat only: no tools or shell). Live models need an API key; the terminal is unavailable.
Project files
read-only- ..
- ai.ts
- apps.ts
- audit.ts
- auth.ts
- central-core.d.mts
- central-core.mjs
- central.ts
- cloud.ts
- config.ts
- crypto.ts
- db.ts
- design.ts
- engines.ts
- files.ts
- gates.ts
- gateway.ts
- marketplace-core.d.mts
- marketplace-core.mjs
- metrics.ts
- modules.ts
- motion.ts
- nexus-core.d.mts
- nexus-core.mjs
- oidc-core.d.mts
- oidc-core.mjs
- oidc.ts
- providers.ts
- proxy-core.d.mts
- proxy-core.mjs
- pwauth-core.d.mts
- pwauth-core.mjs
- requirements.ts
- rls.sql.d.mts
- rls.sql.mjs
- services-content.ts
- ssrf.ts
- status.ts
- tenant.ts
- tlsgate.ts
- workspace.ts
app/src/components/motion/provider.tsx
1"use client";2// Motion context: resolves the level once from OS preference + device + user choice, mirrors it to <html data-motion> for CSS gating,3// and tracks page visibility so CSS animations pause in background tabs.4import { createContext, useCallback, useContext, useEffect, useRef, useState, type ReactNode, type RefObject } from "react";5import { MOTION_GLOBAL, PRESETS, isPref, resolveLevel, type Level, type Pref, type Preset } from "@/lib/motion";6type Ctx = { level: Level; pref: Pref; setPref: (p: Pref) => void; reduced: boolean; ready: boolean };7const C = createContext<Ctx>({ level: "off", pref: "auto", setPref: () => {}, reduced: false, ready: false });8export const useMotion = () => useContext(C);9const read = (): Pref => { try { const v = localStorage.getItem(MOTION_GLOBAL.storageKey); return isPref(v) ? v : "auto"; } catch { return "auto"; } };10export function MotionProvider({ children }: { children: ReactNode }) {11 const [pref, setPrefState] = useState<Pref>("auto"); const [level, setLevel] = useState<Level>("off"); const [reduced, setReduced] = useState(false); const [ready, setReady] = useState(false);12 const compute = useCallback((p: Pref) => {13 const mq = matchMedia("(prefers-reduced-motion: reduce)"); const nav = navigator as Navigator & { deviceMemory?: number; connection?: { saveData?: boolean } };14 const l = resolveLevel(p, { reduced: mq.matches, saveData: !!nav.connection?.saveData, cores: nav.hardwareConcurrency || 8, memoryGb: nav.deviceMemory ?? 8, coarse: matchMedia("(pointer: coarse)").matches });15 setReduced(mq.matches); setLevel(l); document.documentElement.dataset.motion = l;16 }, []);17 useEffect(() => {18 const p = read(); setPrefState(p); compute(p); setReady(true);19 const mq = matchMedia("(prefers-reduced-motion: reduce)"); const onMq = () => compute(read()); mq.addEventListener("change", onMq);20 // continuous (looping) motion is armed only after the page has settled: keeps hydration/TTI free of animation work21 let t = 0; const arm = () => { t = window.setTimeout(() => { document.documentElement.dataset.live = "1"; }, 1500); };22 if (document.readyState === "complete") arm(); else window.addEventListener("load", arm, { once: true });23 const vis = () => { document.documentElement.dataset.hidden = document.hidden ? "1" : "0"; }; vis(); document.addEventListener("visibilitychange", vis);24 return () => { clearTimeout(t); window.removeEventListener("load", arm); mq.removeEventListener("change", onMq); document.removeEventListener("visibilitychange", vis); };25 }, [compute]);26 const setPref = useCallback((p: Pref) => { setPrefState(p); try { localStorage.setItem(MOTION_GLOBAL.storageKey, p); } catch {} compute(p); }, [compute]);27 return <C.Provider value={{ level, pref, setPref, reduced, ready }}>{children}</C.Provider>;28}29/** True while the element intersects the viewport. `initial` is the value before the first observer callback (use false for work that must not start off-screen). */30export function useInView<T extends Element>(ref: RefObject<T | null>, margin = "80px", initial = true): boolean {31 const [v, setV] = useState(initial);32 useEffect(() => { const el = ref.current; if (!el || typeof IntersectionObserver === "undefined") return; const io = new IntersectionObserver(([e]) => setV(e.isIntersecting), { rootMargin: margin }); io.observe(el); return () => io.disconnect(); }, [ref, margin]);33 return v;34}35/** Fires a Web Animations API preset once when the element first scrolls into view. Content is fully visible without JS or when motion is off. */36export function Reveal({ children, preset = "reveal", delay = 0, className, as: Tag = "div", ...rest }: { children: ReactNode; preset?: Preset; delay?: number; className?: string; as?: any; onPointerMove?: (e: React.PointerEvent<HTMLElement>) => void }) {37 const ref = useRef<HTMLElement>(null); const { level, ready } = useMotion();38 useEffect(() => {39 const el = ref.current; if (!el || !ready || level === "off" || typeof IntersectionObserver === "undefined" || !el.animate) return;40 // No layout reads: the observer's first callback says whether the element is already on screen. Visible content is never hidden;41 // below-fold content is primed (hidden + paused animation) and revealed when it scrolls in.42 let a: Animation | null = null, primed = false;43 const io = new IntersectionObserver(([e]) => {44 if (!primed) { primed = true; if (e.isIntersecting) { io.disconnect(); return; } const p = PRESETS[preset]; a = el.animate([...p.keyframes] as Keyframe[], { ...p.options, delay, fill: "both" }); a.pause(); a.currentTime = 0; el.style.opacity = "0"; return; }45 if (e.isIntersecting && a) { el.style.opacity = ""; a.play(); a.onfinish = () => a?.cancel(); io.disconnect(); }46 }, { rootMargin: "0px 0px -8% 0px" }); io.observe(el);47 return () => { io.disconnect(); a?.cancel(); el.style.opacity = ""; };48 }, [level, ready, preset, delay]);49 return <Tag ref={ref} className={className} {...rest}>{children}</Tag>;50}51export function MotionToggle({ showLabel = false, className = "" }: { showLabel?: boolean; className?: string }) {52 const { pref, level, setPref, reduced } = useMotion(); const on = level !== "off";53 return <button className={`btn btn-sm ${className}`} aria-pressed={on} aria-label={reduced ? "Motion is off (system reduced-motion setting)" : on ? "Turn animations off" : "Turn animations on"} title={reduced ? "Reduced motion is set in your system" : on ? "Animations: on" : "Animations: off"} disabled={reduced}54 onClick={() => setPref(on ? "off" : "auto")}><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden>{on ? <path d="M12 3l1.8 4.6L18.5 9l-4.7 1.4L12 15l-1.8-4.6L5.5 9l4.7-1.4zM19 15l.8 2.2L22 18l-2.2.8L19 21l-.8-2.2L16 18l2.2-.8z" /> : <><path d="M6 4h4v16H6zM14 4h4v16h-4z" /></>}</svg>{showLabel && <span className="ml-1.5">{reduced ? "Animations off (system)" : on ? "Animations: on" : "Animations: off"}</span>}</button>;55}56
Conversation
PartialSign in to start AI sessions.
Task checklist
- Application shell deployed
- Persistent projects
- Agent runtime
- Sandboxed terminal
Execution activity
No agent sessions. Git HEAD fb22adb on master.
Approval requests
None pending.