- 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.5 KiB
Session Attachment Bug - COMPLETE FIX
Date: 2025-01-22 Status: ✅ Root cause found and fixed Server PID: 1723610
The Bug
User flow: https://rommark.dev/claude/ > select folder > navigates to session URL > shows "No sessions yet"
Root Cause Found
Race Condition: Two components both initializing on DOMContentLoaded:
- ide.js - Extracts sessionId from URL, sets
window.pendingSessionAttach, switches to chat view, callsattachToSession() - session-picker.js - Initializes and shows modal with "No sessions yet"
The problem: session-picker was showing its modal BEFORE ide.js could switch to the chat view.
The session-picker only checked for ?session=XXX query parameter, NOT the route-based URL path /claude/ide/session/session-XXX.
The Fix
File: /home/uroma/obsidian-web-interface/public/claude-ide/components/session-picker.js
Before:
async initialize() {
// Only checked query params
const urlParams = new URLSearchParams(window.location.search);
const sessionId = urlParams.get('session');
// ...
}
After:
async initialize() {
// FIRST: Check URL path for session ID (route-based: /claude/ide/session/XXX)
const pathname = window.location.pathname;
const pathMatch = pathname.match(/\/claude\/ide\/session\/([^\/]+)$/);
if (pathMatch && pathMatch[1]) {
const sessionId = pathMatch[1];
console.log('[SessionPicker] Session ID in URL path, NOT showing picker:', sessionId);
console.log('[SessionPicker] ide.js will handle attachment');
this.initialized = true;
return; // Don't show picker, let ide.js handle it
}
// SECOND: Check URL params (legacy format: ?session=XXX)
// ...
}
All Files Modified
-
/home/uroma/obsidian-web-interface/public/claude-ide/components/session-picker.js- Added URL path check BEFORE showing modal
- If session ID in URL path, don't show picker, let ide.js handle it
-
/home/uroma/obsidian-web-interface/public/claude-ide/chat-functions.js- Moved URL-based session attachment check to execute FIRST
- Before rendering session list
-
/home/uroma/obsidian-web-interface/public/claude-ide/index.html- Re-added
ide.jsscript tag - Updated all script versions to
v1769079800000 - Updated cache buster version to
1769079800000
- Re-added
How It Works Now
User flow:
- User clicks "Select Folder" on landing page
- Folder selected, session created via POST
/claude/api/claude/sessions - Response:
{ id: "session-1769079417244-0ynpja8dc" } - Browser navigates to:
/claude/ide/session/session-1769079417244-0ynpja8dc - Page loads:
- PRELOAD script extracts session ID →
window.PRELOAD_SESSION_ID - Cache-bust script runs (version matches, no reload)
- ide.js initializes → sees sessionId → switches to chat view → calls attachToSession
- session-picker.js initializes → sees sessionId in URL path → DOESN'T show modal
- chat-functions.js loads → loadChatView() → attaches to session
- PRELOAD script extracts session ID →
- Result: Chat interface shows with session attached ✅
Testing
To verify the fix:
- Hard refresh browser (Ctrl+Shift+R or Cmd+Shift+R)
- Go to https://rommark.dev/claude/
- Click "Start New Session" → "Choose Folder"
- Select any folder
- Click "Select Folder"
- Should navigate to session URL and show chat interface (not "No sessions yet")
Browser Console Logs
When it works, you should see:
[PRELOAD] Session ID extracted from URL: session-XXX
[Cache-Bust] Fresh load confirmed
[Init] Using PRELOAD_SESSION_ID: session-XXX
[Init] Set pendingSessionAttach: session-XXX
[SessionPicker] Session ID in URL path, NOT showing picker: session-XXX
[SessionPicker] ide.js will handle attachment
[loadChatView] Pending session attachment detected: session-XXX
[loadChatView] Attaching IMMEDIATELY (no delay)
[attachToSession] Attaching to session: session-XXX
Server Status
- PID: 1723610
- Status: Running
- Port: 3010
- Working Directory:
/home/uroma/obsidian-web-interface
Version Information
- Cache Buster: 1769079800000
- Script Versions: v1769079800000
- Fix Date: 2025-01-22 11:07 UTC
Related Files
- Ralph wrapper:
/home/uroma/obsidian-web-interface/bin/ralphloop - /ralph alias:
/home/uroma/.claude/skills/ralph/SKILL.md - Ralph integration:
/home/uroma/.claude/skills/brainstorming/ralph-integration.py