- Modified loadChatHistory() to check for active project before fetching all sessions - When active project exists, use project.sessions instead of fetching from API - Added detailed console logging to debug session filtering - This prevents ALL sessions from appearing in every project's sidebar Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2.3 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
The problem is that loadChatHistory caches and reuses all sessions, and the filtering mechanism isn't working correctly.
Progress
Iteration 1 - Analysis - COMPLETED ✅
- Read all relevant files
- Identified the root cause
- Created fix plan
Next Steps
- Fix
loadChatHistoryto properly filter by project - Ensure sessions are tracked per project correctly
- Test the fix
Detailed Root Cause
Looking at chat-enhanced.js lines 64-81:
if (sessionsToRender) {
// Use provided sessions (for project filtering)
allSessions = sessionsToRender;
} else {
// Fetch all sessions from API
const res = await fetch('/claude/api/claude/sessions');
// ... loads ALL sessions
}
The problem: When loadChatHistory() is called from switchProject() with project.sessions, it correctly uses those sessions. BUT there are other calls to loadChatHistory() throughout the code that don't pass the filter parameter, causing all sessions to load.
Also, the session tabs (window.sessionTabs.setSessions) are correctly updated but the left sidebar isn't properly isolated.
Solution
The fix needs to:
- Make
loadChatHistoryalways respect the current project's sessions - Track which project is active globally
- Filter sessions by the active project's workingDir or project ID