fix: legacy sessions (profile=null) leak into all profiles' session lists
Root cause: sessions created before Sprint 22 have no profile tag (profile=None). The client filter was '!s.profile || s.profile === S.activeProfile' -- the '!s.profile' guard made ALL 33 legacy sessions visible under every profile, so switching to Camanji still showed the entire default session history. Fix: - api/models.py all_sessions(): backfill profile='default' on sessions with no profile tag before returning. This is in-memory only (no disk writes) -- legacy sessions just get attributed to the default profile at read time. Applied to both the index-path and the full-scan fallback path. - static/sessions.js: tighten the client filter to s.profile === S.activeProfile (remove the '!s.profile' escape hatch -- now redundant since server fills it). Every session now has an explicit profile, so the filter is precise. Result: switching to Camanji shows only Camanji sessions. Default profile shows legacy + default-tagged sessions. 'All profiles' toggle still shows everything. S.activeProfile defaults to 'default' in the S object so first render is safe. Tests: 426 passed, 0 failed.
This commit is contained in:
@@ -115,7 +115,9 @@ function renderSessionListFromCache(){
|
||||
const titleIds=new Set(titleMatches.map(s=>s.session_id));
|
||||
const allMatched=q?[...titleMatches,..._contentSearchResults.filter(s=>!titleIds.has(s.session_id))]:titleMatches;
|
||||
// Filter by active profile (unless "All profiles" is toggled on)
|
||||
const profileFiltered=_showAllProfiles?allMatched:allMatched.filter(s=>!s.profile||s.profile===S.activeProfile);
|
||||
// Server backfills profile='default' for legacy sessions, so every session has a profile.
|
||||
// Show only sessions tagged to the active profile; 'All profiles' toggle overrides.
|
||||
const profileFiltered=_showAllProfiles?allMatched:allMatched.filter(s=>s.profile===S.activeProfile);
|
||||
// Filter by active project
|
||||
const projectFiltered=_activeProject?profileFiltered.filter(s=>s.project_id===_activeProject):profileFiltered;
|
||||
// Filter archived unless toggle is on
|
||||
|
||||
Reference in New Issue
Block a user