mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-02-16 13:47:34 +00:00
chore(to-remove): comment todo's
This commit is contained in:
24
src/App.jsx
24
src/App.jsx
@@ -37,20 +37,24 @@ import { api, authenticatedFetch } from './utils/api';
|
|||||||
import { I18nextProvider, useTranslation } from 'react-i18next';
|
import { I18nextProvider, useTranslation } from 'react-i18next';
|
||||||
import i18n from './i18n/config.js';
|
import i18n from './i18n/config.js';
|
||||||
|
|
||||||
|
// TODO: Move to a separate file called AppContent.ts
|
||||||
// ! Move to a separate file called AppContent.ts
|
|
||||||
// Main App component with routing
|
// Main App component with routing
|
||||||
function AppContent() {
|
function AppContent() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate(); // used for navigation on project select
|
||||||
const { sessionId } = useParams();
|
const { sessionId } = useParams();
|
||||||
const { t } = useTranslation('common');
|
const { t } = useTranslation('common');
|
||||||
// * This is a tracker for avoiding excessive re-renders during development
|
// * This is a tracker for avoiding excessive re-renders during development
|
||||||
const renderCountRef = useRef(0);
|
const renderCountRef = useRef(0);
|
||||||
// console.log(`AppContent render count: ${renderCountRef.current++}`);
|
// console.log(`AppContent render count: ${renderCountRef.current++}`);
|
||||||
|
|
||||||
|
// ! ESSENTIAL STATES
|
||||||
const [projects, setProjects] = useState([]);
|
const [projects, setProjects] = useState([]);
|
||||||
|
// debugger;
|
||||||
|
// console.log('Projects state updated:', projects); // Debug log to track projects state changes
|
||||||
const [selectedProject, setSelectedProject] = useState(null);
|
const [selectedProject, setSelectedProject] = useState(null);
|
||||||
const [selectedSession, setSelectedSession] = useState(null);
|
const [selectedSession, setSelectedSession] = useState(null);
|
||||||
|
|
||||||
|
|
||||||
const [activeTab, setActiveTab] = useState('chat'); // 'chat' or 'files'
|
const [activeTab, setActiveTab] = useState('chat'); // 'chat' or 'files'
|
||||||
const { isMobile } = useDeviceSettings({ trackPWA: false });
|
const { isMobile } = useDeviceSettings({ trackPWA: false });
|
||||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||||
@@ -74,7 +78,7 @@ function AppContent() {
|
|||||||
const [externalMessageUpdate, setExternalMessageUpdate] = useState(0);
|
const [externalMessageUpdate, setExternalMessageUpdate] = useState(0);
|
||||||
|
|
||||||
const { ws, sendMessage, latestMessage } = useWebSocket();
|
const { ws, sendMessage, latestMessage } = useWebSocket();
|
||||||
|
console.log('WebSocket latest message:', latestMessage); // Debug log to track WebSocket messages
|
||||||
// Ref to track loading progress timeout for cleanup
|
// Ref to track loading progress timeout for cleanup
|
||||||
const loadingProgressTimeoutRef = useRef(null);
|
const loadingProgressTimeoutRef = useRef(null);
|
||||||
|
|
||||||
@@ -191,6 +195,7 @@ function AppContent() {
|
|||||||
|
|
||||||
// Update projects state with the new data from WebSocket
|
// Update projects state with the new data from WebSocket
|
||||||
const updatedProjects = latestMessage.projects;
|
const updatedProjects = latestMessage.projects;
|
||||||
|
console.log("====> latest message is: ", latestMessage);
|
||||||
setProjects(updatedProjects);
|
setProjects(updatedProjects);
|
||||||
|
|
||||||
// Update selected project if it exists in the updated projects
|
// Update selected project if it exists in the updated projects
|
||||||
@@ -260,6 +265,8 @@ function AppContent() {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("===> Prev projects: ", prevProjects);
|
||||||
|
|
||||||
// Check if the projects data has actually changed
|
// Check if the projects data has actually changed
|
||||||
const hasChanges = data.some((newProject, index) => {
|
const hasChanges = data.some((newProject, index) => {
|
||||||
const prevProject = prevProjects[index];
|
const prevProject = prevProjects[index];
|
||||||
@@ -289,13 +296,13 @@ function AppContent() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Expose fetchProjects globally for component access
|
// Expose fetchProjects globally for component access
|
||||||
window.refreshProjects = fetchProjects;
|
window.refreshProjects = fetchProjects; // ! Exposing it globally is bad so we should use props for stuff like this.
|
||||||
|
|
||||||
// Expose openSettings function globally for component access
|
// Expose openSettings function globally for component access
|
||||||
window.openSettings = useCallback((tab = 'tools') => {
|
window.openSettings = useCallback((tab = 'tools') => {
|
||||||
setSettingsInitialTab(tab);
|
setSettingsInitialTab(tab);
|
||||||
setShowSettings(true);
|
setShowSettings(true);
|
||||||
}, []);
|
}, []); // ! Exposing it globally is bad so we should use props for stuff like this.
|
||||||
|
|
||||||
// Handle URL-based session loading
|
// Handle URL-based session loading
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -332,6 +339,8 @@ function AppContent() {
|
|||||||
}
|
}
|
||||||
}, [sessionId, projects, navigate]);
|
}, [sessionId, projects, navigate]);
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: All this functions should be in separate components
|
||||||
const handleProjectSelect = (project) => {
|
const handleProjectSelect = (project) => {
|
||||||
setSelectedProject(project);
|
setSelectedProject(project);
|
||||||
setSelectedSession(null);
|
setSelectedSession(null);
|
||||||
@@ -643,6 +652,8 @@ function AppContent() {
|
|||||||
<QuickSettingsPanel isMobile={isMobile} />
|
<QuickSettingsPanel isMobile={isMobile} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* // TODO: This should be in its own file. In modals/Settings.tsx */}
|
||||||
|
{/* // TODO: This should be in sidebar as well. */}
|
||||||
{/* Settings Modal */}
|
{/* Settings Modal */}
|
||||||
<Settings
|
<Settings
|
||||||
isOpen={showSettings}
|
isOpen={showSettings}
|
||||||
@@ -666,6 +677,7 @@ function App() {
|
|||||||
<ProtectedRoute>
|
<ProtectedRoute>
|
||||||
<Router basename={window.__ROUTER_BASENAME__ || ''}>
|
<Router basename={window.__ROUTER_BASENAME__ || ''}>
|
||||||
<Routes>
|
<Routes>
|
||||||
|
{/* // TODO: Can this be refactored to just have one route? */}
|
||||||
<Route path="/" element={<AppContent />} />
|
<Route path="/" element={<AppContent />} />
|
||||||
<Route path="/session/:sessionId" element={<AppContent />} />
|
<Route path="/session/:sessionId" element={<AppContent />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
|
|||||||
Reference in New Issue
Block a user