Fix: Add project parameter parsing to enable chat in project context

When accessing the IDE with ?project= URL parameter, the project context
was not being initialized, causing auto-session creation to fail and
chat to show "Please start or attach to a session first" error.

Changes:
- Added currentProjectName global variable
- Parse project parameter from URL on page load
- Set window.currentProjectDir for chat-functions.js auto-session logic
- Extract project name from path for display

Fixes chat not responding when navigating from landing page or projects view.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
uroma
2026-01-20 19:57:24 +00:00
Unverified
parent d774621200
commit ed622ecbe2

View File

@@ -1,5 +1,6 @@
// Claude Code IDE JavaScript // Claude Code IDE JavaScript
let currentSession = null; let currentSession = null;
let currentProjectName = null;
let ws = null; let ws = null;
// Make ws globally accessible for other scripts // Make ws globally accessible for other scripts
@@ -15,10 +16,18 @@ document.addEventListener('DOMContentLoaded', () => {
initNavigation(); initNavigation();
connectWebSocket(); connectWebSocket();
// Check URL params for session and prompt // Check URL params for session, prompt, and project
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
const sessionId = urlParams.get('session'); const sessionId = urlParams.get('session');
const prompt = urlParams.get('prompt'); const prompt = urlParams.get('prompt');
const project = urlParams.get('project');
// Parse project parameter if present
if (project) {
window.currentProjectDir = decodeURIComponent(project);
currentProjectName = project.split('/').filter(Boolean).pop() || 'Project';
console.log('[Init] Project context loaded:', currentProjectName, window.currentProjectDir);
}
if (sessionId || prompt) { if (sessionId || prompt) {
// Switch to chat view first // Switch to chat view first