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

Function handleProjectClick

frontend/src/components/ProjectTreeView.tsx:209–235  ·  view source on GitHub ↗
(project: Project)

Source from the content-addressed store, hash-verified

207 };
208
209 const handleProjectClick = async (project: Project) => {
210 // Check if we should show the warning
211 const warningKey = `mainBranchWarning_${project.id}`;
212 const hasShownWarning = localStorage.getItem(warningKey);
213
214 if (!hasShownWarning) {
215 // Fetch the current branch before showing warning
216 try {
217 const response = await window.electronAPI.git.detectBranch(project.path);
218 if (response.success && response.data) {
219 setDetectedMainBranch(response.data);
220 } else {
221 setDetectedMainBranch('main');
222 }
223 } catch (error) {
224 console.error('Failed to detect branch:', error);
225 setDetectedMainBranch('main');
226 }
227
228 // Show warning dialog
229 setPendingMainBranchProject(project);
230 setShowMainBranchWarning(true);
231 } else {
232 // Proceed directly
233 await openMainRepoSession(project);
234 }
235 };
236
237 const openMainRepoSession = async (project: Project) => {
238 try {

Callers 1

ProjectTreeViewFunction · 0.70

Calls 3

openMainRepoSessionFunction · 0.85
detectBranchMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected