Root cause: loadManuallyCreatedProjects() was restoring projects with stale session arrays from localStorage. When loadProjects() tried to merge with fresh API data, the stale sessions would override. Fix 1: In loadManuallyCreatedProjects(), reset the sessions array to empty for each loaded project. This ensures sessions always come from the API (authoritative source) rather than localStorage. Fix 2: In createSessionInFolder(), remove the redundant initialize() call after loadProjects(). initialize() would reload stale localStorage data, undoing the fresh data fetched by loadProjects(). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2.1 KiB
2.1 KiB
Task: CRITICAL BUG: Project isolation completely broken.
Current Behavior
User creates new project (e.g., 'roman') and clicks 'Start new session' → ALL sessions from other projects appear in this project's left sidebar.
Previous Failed Attempts
- Virtual workingDir approach - didn't work
- Skipping virtual sessions in loadProjects() - didn't work
- Smart merging logic - still doesn't work
Requirements
- Each manually created project should have ONLY its own sessions
- Auto-generated projects (from real workingDirs) should still work
- Projects must persist across page refreshes
- Switching between projects should show only that project's sessions
Files to Analyze
- /home/uroma/obsidian-web-interface/public/claude-ide/project-manager.js (main logic)
- /home/uroma/obsidian-web-interface/public/claude-ide/chat-enhanced.js (left sidebar)
- /home/uroma/obsidian-web-interface/routes/sessions-routes.js (backend API)
Progress
Iteration 1 - Fixed loadChatHistory to respect active project ✅
Modified loadChatHistory() in chat-enhanced.js to check for active project before fetching all sessions from API. When active project exists, it uses activeProject.sessions instead.
Commit: 55aafba
Iteration 2 - Fixed virtual workingDir handling ✅
Modified addSessionToProject() in project-manager.js to correctly extract projectKey from virtual workingDirs (/virtual/projects/{key}) instead of converting slashes to dashes.
Commit: ec790a2
Iteration 3 - Added debugging logging ✅
Added extensive console logging to track session assignment and project isolation.
Commit: 9107b3d
Status
ALL FIXES IMPLEMENTED - Ready for browser testing. The fixes address:
- loadChatHistory now respects active project filter
- Virtual workingDirs are correctly handled when assigning sessions to projects
- Detailed logging helps identify any remaining issues
Success Criteria
The task is complete when:
- All requirements are implemented
- Tests pass
- Code is documented