- Modified addSessionToProject to correctly extract projectKey from virtual workingDirs
- Virtual workingDir format: /virtual/projects/{projectKey}
- Previously was converting slashes to dashes, causing mismatch
- Added console logging to track session-to-project assignment
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2.7 KiB
2.7 KiB
Project Isolation Bug - Scratchpad
Task Overview
Fix project isolation bug where ALL sessions appear in every project's left sidebar instead of only that project's sessions.
Files to Modify
- /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)
Root Cause Analysis
After analyzing the code:
- project-manager.js line 365:
switchProject()callsloadChatHistory(project.sessions)- this passes the correct sessions - chat-enhanced.js line 52:
loadChatHistory()acceptssessionsToRenderparameter - BUT - When
loadChatHistory()is called without parameters (initial load), it fetches ALL sessions from API
The issue: The left sidebar loadChatHistory function is being called in multiple places:
- Initial page load (no filter) - loads ALL sessions
- When switching projects (with filter) - should load only project sessions
- When sessions are created/updated
- After archiving/unarchiving sessions
- After resuming sessions
The problem is that loadChatHistory caches and reuses all sessions, and the filtering mechanism wasn't working correctly.
Progress
Iteration 1 - Analysis & Initial Fix - COMPLETED ✅
Changes Made:
-
Modified
loadChatHistory()in chat-enhanced.js (lines 71-100):- Added check for
window.projectManager.activeProjectId - If active project exists, use
activeProject.sessionsinstead of fetching from API - This ensures that even when
loadChatHistory()is called without parameters, it respects the active project
- Added check for
-
Added detailed console logging (lines 107-115):
- Logs which sessions are being rendered
- Shows workingDir, project metadata, and status for each session
- Helps debug any remaining issues
Commit: 55aafba - "Fix project isolation: Make loadChatHistory respect active project sessions"
Testing Required
- Create a new project (e.g., 'roman')
- Add a session to 'roman' project
- Check if only 'roman' sessions appear in left sidebar
- Switch to another project
- Verify only that project's sessions appear
Potential Issues to Watch
- Initial page load: If project manager hasn't initialized yet, we might load all sessions briefly
- Session creation: New sessions might not appear until project manager refreshes
- Project switching timing: Race conditions between loadChatHistory calls
Next Steps
- Test the current fix in browser
- If issues remain, may need to:
- Add loading state to prevent showing wrong sessions during initialization
- Ensure project manager initializes before loadChatHistory runs
- Add event-based updates instead of polling