MCPcopy
hub / github.com/stravu/crystal / loadProjectsWithSessions

Function loadProjectsWithSessions

frontend/src/components/ProjectTreeView.tsx:165–195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

163 }, [storesSessions]);
164
165 const loadProjectsWithSessions = async () => {
166 try {
167 setIsLoading(true);
168 const response = await API.sessions.getAllWithProjects();
169 if (response.success && response.data) {
170 setProjectsWithSessions(response.data);
171
172 // Auto-expand projects that have sessions
173 const projectsToExpand = new Set<number>();
174 response.data.forEach((project: ProjectWithSessions) => {
175 if (project.sessions.length > 0) {
176 projectsToExpand.add(project.id);
177 }
178 });
179 setExpandedProjects(projectsToExpand);
180
181 // Also expand the project containing the active session
182 if (activeSessionId) {
183 response.data.forEach((project: ProjectWithSessions) => {
184 if (project.sessions.some(s => s.id === activeSessionId)) {
185 projectsToExpand.add(project.id);
186 }
187 });
188 }
189 }
190 } catch (error) {
191 console.error('Failed to load projects with sessions:', error);
192 } finally {
193 setIsLoading(false);
194 }
195 };
196
197 const toggleProject = (projectId: number) => {
198 setExpandedProjects(prev => {

Callers 2

ProjectTreeViewFunction · 0.70
handleCreateProjectFunction · 0.70

Calls 3

getAllWithProjectsMethod · 0.80
errorMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected