- 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>
4.2 KiB
Session Attachment Bug Fix
Date: 2025-01-22 Issue: Folder selection creates session and navigates to URL, but IDE shows "No sessions yet"
Root Cause
The loadChatView() function in chat-functions.js only checked for URL-based session attachment (PRELOAD_SESSION_ID) when there were no active sessions (activeSessions.length === 0).
When a session was created via folder selection:
- Session created successfully
- Browser navigates to
/claude/ide/session/session-XXX - IDE loads and calls
loadChatView() loadChatView()fetches sessions list- Session exists in active list (because it was just created)
- Code renders the session list but never checks the URL for session attachment
- User sees "No sessions yet" or the session list but isn't attached to the URL-specified session
The Fix
Moved the URL-based session attachment check to execute before checking whether there are active sessions. Now:
- URL check happens first
- If URL contains a session ID, attach to it immediately
- Only render session list if no URL-based session attachment needed
Files Modified
/home/uroma/obsidian-web-interface/public/claude-ide/chat-functions.js
Before: URL check only in else block (when activeSessions.length === 0)
if (activeSessions.length > 0) {
// Render session list
} else {
// Check URL for session ID
let pendingSessionId = window.PRELOAD_SESSION_ID;
// ...
}
After: URL check happens before session list rendering
// URL-BASED SESSION ATTACHMENT (Always check first!)
let pendingSessionId = window.PRELOAD_SESSION_ID;
if (!pendingSessionId) {
pendingSessionId = window.pendingSessionAttach;
}
if (!pendingSessionId) {
const pathname = window.location.pathname;
const sessionMatch = pathname.match(/\/claude\/ide\/session\/([^\/]+)$/);
if (sessionMatch && sessionMatch[1]) {
pendingSessionId = sessionMatch[1];
}
}
if (!pendingSessionId) {
const urlParams = new URLSearchParams(window.location.search);
pendingSessionId = urlParams.get('session');
}
if (pendingSessionId) {
// Attach to session immediately
attachToSession(pendingSessionId);
return;
}
// No URL-based session - render session list normally
if (activeSessions.length > 0) {
// Render session list
} else {
// Show "no sessions" message
}
/home/uroma/obsidian-web-interface/public/claude-ide/index.html
Updated cache buster version:
const EXPECTED_JS_VERSION = '1769079537621'; // Cache bust for URL-based session attachment fix
Testing
Steps to verify:
- Go to https://rommark.dev/claude/
- Click "Start New Session" → "Choose Folder"
- Select any folder
- Click "Select Folder"
- Should navigate to
/claude/ide/session/session-XXX - IDE should show "Loading session..." then attach to the session
- Chat interface should be ready, not "No sessions yet"
Technical Details
Priority order for session detection:
PRELOAD_SESSION_ID- Set by inline script before any JS loadswindow.pendingSessionAttach- Set by ide.js initialization- URL pathname
/claude/ide/session/XXX- Direct route matching - Query parameter
?session=XXX- Legacy support
Why this fix works:
- URL-based navigation is now the PRIMARY way to specify which session to attach to
- Session list rendering is secondary
- Even if 100 sessions exist, navigating to
/claude/ide/session/specific-idwill attach to that specific session - No race condition between session creation and list fetching
Related Code
PRELOAD_SESSION_IDextraction in/public/claude-ide/index.html(lines 11-39)attachToSession()function in/public/claude-ide/chat-functions.js- Folder selection navigation in
/public/claude-ide/components/folder-explorer-modal.js(line 452)
Cache Busting
The fix includes a cache buster update to force browsers to reload the JavaScript:
- Old version:
1769073600000 - New version:
1769079537621
Browsers will detect the version mismatch and automatically reload to get the fixed code.