Skip to content

The agent that grows with you

refactor(desktop): one sessionBucketId for the filter rule and the overview overlay; shorter resolver header

kshitijk4poor8b9a9f8c234c
diff --git a/apps/desktop/src/app/chat/sidebar/project-filter.ts b/apps/desktop/src/app/chat/sidebar/project-filter.ts
index 7a4d6433e43..33ab9ddd155 100644
--- a/apps/desktop/src/app/chat/sidebar/project-filter.ts
+++ b/apps/desktop/src/app/chat/sidebar/project-filter.ts
@@ -1,19 +1,8 @@
/**
- * Project-filter resolution against the ACTIVE profile's project tree.
- *
- * The sidebar's project filter is a `persistentAtom` whose storage key is
- * shared across profiles. Ids picked in profile B (explicit `p_<hex>` ids or
- * repo-root paths) do not resolve against profile A's per-profile
- * `projects.db`, and both application sites treat the raw filter as a
- * membership whitelist — so one cross-profile switch empties every tier of
- * the sidebar, reading as data loss until the filter is manually cleared
- * (#96246).
- *
- * `resolveLiveProjectFilter` narrows the persisted filter to ids the given
- * tree actually resolves. Ids that resolve nowhere become inert (the filter
- * stops narrowing) instead of fatal (everything filters out). While the tree
- * is still loading (empty), an explicit non-empty filter resolves to an
- * empty live set — fail-open, matching the tree-refresh re-hydration timing.
+ * Narrow the persisted sidebar project filter to ids the ACTIVE tree resolves.
+ * The filter's storage is shared across profiles and outlives project
+ * deletes/rebuilds, so ids that resolve nowhere must be inert, not fatal
+ * (#96246, #97762). Fail-open while the tree is still loading.
*/
export function resolveLiveProjectFilter(
projectFilter: readonly string[],
diff --git a/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.ts b/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.ts
index f84494c27c5..6a6d8aa8d1d 100644
--- a/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.ts
+++ b/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.ts
@@ -428,6 +428,11 @@ export function liveSessionProjectId(session: SessionInfo, explicitProjects: Pro
return repoRoot
}
+/** The lane a row files under: its live project, or Home for detached (cwd-less) rows. */
+export function sessionBucketId(session: SessionInfo, explicitProjects: ProjectInfo[]): null | string {
+ return liveSessionProjectId(session, explicitProjects) ?? (isDetachedSession(session) ? NO_PROJECT_ID : null)
+}
+
/**
* The ONE row-level project-filter rule the flat list and the project lanes
* narrow by. Detached (cwd-less) rows belong to the Home bucket
@@ -443,7 +448,7 @@ export function sessionMatchesProjectFilter(
return true
}
- const id = liveSessionProjectId(session, explicitProjects) ?? (isDetachedSession(session) ? NO_PROJECT_ID : null)
+ const id = sessionBucketId(session, explicitProjects)
return id !== null && filter.includes(id)
}
@@ -802,8 +807,7 @@ export function overlayLivePreviews(
continue
}
- const projectId =
- liveSessionProjectId(session, explicitProjects) ?? (isDetachedSession(session) ? NO_PROJECT_ID : null)
+ const projectId = sessionBucketId(session, explicitProjects)
if (!projectId) {
continue