mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 20:03:37 +00:00
- Changed SameSite attribute for session cookies from 'strict' to 'lax' to allow cross-origin fetches, improving compatibility with various client requests. - Updated cookie clearing logic in the authentication route to use `res.cookie()` for better reliability in cross-origin environments. - Refactored the login view to implement a state machine for managing authentication phases, enhancing clarity and maintainability. - Introduced a new logged-out view to inform users of session expiration and provide options to log in or retry. - Added account and security sections to the settings view, allowing users to manage their account and security preferences more effectively.
61 lines
2.1 KiB
TypeScript
61 lines
2.1 KiB
TypeScript
import { useState, useCallback, useEffect } from 'react';
|
|
import { RouterProvider } from '@tanstack/react-router';
|
|
import { createLogger } from '@automaker/utils/logger';
|
|
import { router } from './utils/router';
|
|
import { SplashScreen } from './components/splash-screen';
|
|
import { LoadingState } from './components/ui/loading-state';
|
|
import { useSettingsSync } from './hooks/use-settings-sync';
|
|
import { useCursorStatusInit } from './hooks/use-cursor-status-init';
|
|
import './styles/global.css';
|
|
import './styles/theme-imports';
|
|
|
|
const logger = createLogger('App');
|
|
|
|
export default function App() {
|
|
const [showSplash, setShowSplash] = useState(() => {
|
|
// Only show splash once per session
|
|
if (sessionStorage.getItem('automaker-splash-shown')) {
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
|
|
// Clear accumulated PerformanceMeasure entries to prevent memory leak in dev mode
|
|
// React's internal scheduler creates performance marks/measures that accumulate without cleanup
|
|
useEffect(() => {
|
|
if (import.meta.env.DEV) {
|
|
const clearPerfEntries = () => {
|
|
performance.clearMarks();
|
|
performance.clearMeasures();
|
|
};
|
|
const interval = setInterval(clearPerfEntries, 5000);
|
|
return () => clearInterval(interval);
|
|
}
|
|
}, []);
|
|
|
|
// Settings are now loaded in __root.tsx after successful session verification
|
|
// This ensures a unified flow: verify session → load settings → redirect
|
|
// We no longer block router rendering here - settings loading happens in __root.tsx
|
|
|
|
// Sync settings changes back to server (API-first persistence)
|
|
const settingsSyncState = useSettingsSync();
|
|
if (settingsSyncState.error) {
|
|
logger.error('Settings sync error:', settingsSyncState.error);
|
|
}
|
|
|
|
// Initialize Cursor CLI status at startup
|
|
useCursorStatusInit();
|
|
|
|
const handleSplashComplete = useCallback(() => {
|
|
sessionStorage.setItem('automaker-splash-shown', 'true');
|
|
setShowSplash(false);
|
|
}, []);
|
|
|
|
return (
|
|
<>
|
|
<RouterProvider router={router} />
|
|
{showSplash && <SplashScreen onComplete={handleSplashComplete} />}
|
|
</>
|
|
);
|
|
}
|