Fix virtual workingDir handling in addSessionToProject

- 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>
This commit is contained in:
uroma
2026-01-22 14:44:08 +00:00
Unverified
parent 55aafbae9a
commit ec790a2de6
3 changed files with 62 additions and 39 deletions

View File

@@ -572,10 +572,22 @@ class ProjectManager {
/**
* Add a session to its project
* CRITICAL FIX: Handle virtual working directories correctly
*/
addSessionToProject(session) {
const dir = session.workingDir || 'default';
const projectKey = dir.replace(/\//g, '-').replace(/^-/, '') || 'default';
let projectKey;
// CRITICAL FIX: Handle virtual working directories specially
// Virtual workingDir format: /virtual/projects/{projectKey}
if (dir.startsWith('/virtual/projects/')) {
// Extract the projectKey from the virtual workingDir
projectKey = dir.replace('/virtual/projects/', '');
console.log('[ProjectManager] Session has virtual workingDir, extracted projectKey:', projectKey, 'from', dir);
} else {
// Standard workingDir - convert path to projectKey
projectKey = dir.replace(/\//g, '-').replace(/^-/, '') || 'default';
}
if (!this.projects.has(projectKey)) {
const projectName = dir.split('/').pop() || 'Default';
@@ -593,6 +605,8 @@ class ProjectManager {
project.sessions.unshift(session); // Add to beginning
project.activeSessionId = session.id;
console.log('[ProjectManager] Added session', session.id.substring(0, 8), 'to project:', project.name, 'key:', projectKey, 'total sessions:', project.sessions.length);
// Re-render if this is the active project
if (this.activeProjectId === project.id) {
this.renderProjectTabs();