The Problem
Traceo’s workspace switcher dropdown rendered correctly. Users could click to select a different workspace. The UI updated the selection indicator. But all data — requirements, diagrams, sessions — remained from the original workspace. Page refresh reverted even the UI selection.The Root Cause
The switcher updatedactiveWorkspaceId in a React context (client-side only). Every API route independently read user.workspaceId from the database. The context state was never persisted anywhere — not to the database, not to a cookie, not to localStorage. The frontend and backend had completely decoupled notions of “active workspace”.
The Fix
Added aPATCH /api/workspaces endpoint that updates user.workspaceId in the database. The frontend now calls this endpoint before updating local state and refreshing. Updated GET /api/workspaces to return all workspaces with an is_active flag so the dropdown populates correctly.