UMBRA/frontend/src/main.tsx
Kyle Pope 89519a6dd3 Fix lock screen bypass, theme flicker, skeleton flash, and sidebar click target
Critical: Lock state was purely React useState — refreshing the page reset it.
Now persisted server-side via is_locked/locked_at columns on user_sessions.
POST /auth/lock sets the flag, /auth/verify-password clears it, and
GET /auth/status returns is_locked so the frontend initializes correctly.

UI: Cache accent color in localStorage and apply via inline script in
index.html before React hydrates to eliminate the cyan flash on load.

UI: Increase TanStack Query gcTime from 5min to 30min so page data
survives component unmount/remount across tab switches without skeleton.

UI: Move Projects nav onClick from the icon element to the full-width
container div so the entire row is clickable when the sidebar is collapsed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 19:00:55 +08:00

43 lines
1.3 KiB
TypeScript

import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { Toaster } from 'sonner';
import App from './App';
import './index.css';
// Mark forms as submitted so CSS validation outlines only appear after a submit attempt.
// The attribute is cleared naturally when Sheet/Dialog forms unmount and remount.
document.addEventListener('submit', (e) => {
if (e.target instanceof HTMLFormElement) {
e.target.setAttribute('data-submitted', '');
}
}, true);
const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
retry: 1,
staleTime: 5 * 60 * 1000,
gcTime: 30 * 60 * 1000, // keep cache 30 min to avoid skeleton flash on tab switch
},
},
});
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<BrowserRouter>
<App />
<Toaster
position="top-right"
theme="dark"
style={{ pointerEvents: 'none' }}
toastOptions={{ style: { pointerEvents: 'auto' } }}
/>
</BrowserRouter>
</QueryClientProvider>
</React.StrictMode>
);