Skip to content

The agent that grows with you

refactor(desktop): one live-filter resolver; keep the Home row rule from #102465

kshitijk4poor88d0a740c921
diff --git a/apps/desktop/src/app/chat/sidebar/index.tsx b/apps/desktop/src/app/chat/sidebar/index.tsx
index 2f0a54efcd3..b9e12912b6e 100644
--- a/apps/desktop/src/app/chat/sidebar/index.tsx
+++ b/apps/desktop/src/app/chat/sidebar/index.tsx
@@ -166,7 +166,6 @@ import {
ProjectMenu,
projectTreeCwd,
reconcileEnteredProjectSessions,
- sanitizeProjectFilter,
sessionMatchesProjectFilter,
sessionRecency as sessionTime,
type SidebarProjectTree,
@@ -524,15 +523,8 @@ export function ChatSidebar({
// One predicate for the status/project filters, so the flat list and the
// project lanes narrow by the same rule. A project lane holds rows the loaded
// page may not, so it has to be answerable per session rather than by
- // membership in the filtered set.
- // The project filter is sanitized against the live tree: persisted ids go
- // stale across updates/deletes and must be inert, never a blank sidebar
- // (#97762). Detached rows file under the Home bucket id (same rule as the
- // overview overlay), so filtering to Home keeps Home's rows.
- const effectiveProjectFilter = useMemo(
- () => sanitizeProjectFilter(projectFilter, projectTree),
- [projectFilter, projectTree]
- )
+ // membership in the filtered set. Detached rows file under the Home bucket id
+ // (same rule as the overview overlay), so filtering to Home keeps Home's rows.
const sessionMatchesFilters = useCallback(
(session: SessionInfo) => {
if (statusFilter.length && !statusFilter.includes(sessionStatusBucket(dotStates[session.id]))) {
@@ -555,14 +547,14 @@ export function ChatSidebar({
// Same membership the sidebar groups and colors by, so a filtered row
// lands in the lane the user picked it from.
- return sessionMatchesProjectFilter(session, effectiveProjectFilter, projects)
+ return sessionMatchesProjectFilter(session, projectFilter, projects)
},
- [statusFilter, effectiveProjectFilter, profileFilter, showAllProfiles, prFilter, pullRequests, projects, dotStates]
+ [statusFilter, projectFilter, profileFilter, showAllProfiles, prFilter, pullRequests, projects, dotStates]
)
const filtersNarrow =
statusFilter.length > 0 ||
- effectiveProjectFilter.length > 0 ||
+ projectFilter.length > 0 ||
prFilter.length > 0 ||
(showAllProfiles && profileFilter.length > 0)
@@ -941,7 +933,7 @@ export function ChatSidebar({
filterVisibleProjects(projectTree, dismissedAutoProjects)
// A filtered-out project drops its whole lane, header included — hiding
// only its rows would leave a row of empty folders behind.
- .filter(project => !effectiveProjectFilter.length || effectiveProjectFilter.includes(project.id))
+ .filter(project => !projectFilter.length || projectFilter.includes(project.id))
.map(project =>
excludeProjectSessions(
{
@@ -966,7 +958,7 @@ export function ChatSidebar({
dismissedAutoProjects,
orderRepos,
activeProjectId,
- effectiveProjectFilter,
+ projectFilter,
projectOrderIds,
isHiddenFromProjects,
s
diff --git a/apps/desktop/src/app/chat/sidebar/projects/index.ts b/apps/desktop/src/app/chat/sidebar/projects/index.ts
index 7ab28645782..501ba79cd95 100644
--- a/apps/desktop/src/app/chat/sidebar/projects/index.ts
+++ b/apps/desktop/src/app/chat/sidebar/projects/index.ts
@@ -16,7 +16,6 @@ export {
overlayLiveLanes,
overlayLivePreviews,
reconcileEnteredProjectSessions,
- sanitizeProjectFilter,
sessionMatchesProjectFilter,
sessionRecency,
type SidebarProjectTree,
diff --git a/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.test.ts b/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.test.ts
index 3b6b13a7107..a1b0c75aa76 100644
--- a/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.test.ts
+++ b/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.test.ts
@@ -14,7 +14,6 @@ import {
overlayLiveLanes,
overlayLivePreviews,
reconcileEnteredProjectSessions,
- sanitizeProjectFilter,
sessionMatchesProjectFilter,
sessionProjectColor,
type SidebarProjectTree,
@@ -1234,19 +1233,16 @@ describe('excludeProjectSessions', () => {
})
})
-describe('project filter fail-open (#97762)', () => {
- const tree = [{ id: 'p_app' }, { id: NO_PROJECT_ID }]
+describe('project filter row rule (#97762)', () => {
const projects = [makeProject('p_app', ['/www/app'])]
const appRow = makeCwdSession('/www/app/src', { git_repo_root: '/www/app' })
const homeRow = makeCwdSession(null)
- it('stale persisted ids are inert instead of blanking the sidebar', () => {
- expect(sanitizeProjectFilter(['p_dead'], tree)).toEqual([])
- expect(sessionMatchesProjectFilter(appRow, sanitizeProjectFilter(['p_dead'], tree), projects)).toBe(true)
- })
+
it('filtering to Home keeps the detached Home rows', () => {
expect(sessionMatchesProjectFilter(homeRow, [NO_PROJECT_ID], projects)).toBe(true)
expect(sessionMatchesProjectFilter(appRow, [NO_PROJECT_ID], projects)).toBe(false)
})
+
it('a live id still narrows', () => {
expect(sessionMatchesProjectFilter(appRow, ['p_app'], projects)).toBe(true)
expect(sessionMatchesProjectFilter(homeRow, ['p_app'], projects)).toBe(false)
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 a9b6739a987..f84494c27c5 100644
--- a/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.ts
+++ b/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.ts
@@ -428,28 +428,6 @@ export function liveSessionProjectId(session: SessionInfo, explicitProjects: Pro
return repoRoot
}
-/**
- * Fail-open project filter (#97762, #96246): the persisted filter names tree
- * node ids, which go stale when a project is deleted/recreated or an update
- * rebuilds the tree — and each stale id then blanks the flat list AND the
- * overview (headers, zero rows) until Local Storage is wiped. Ids the live
- * tree no longer names are inert. Memo-only, never written back: the tree
- * loads async, so persisting the boot-time (empty-tree) result would destroy
- * a valid filter.
- */
-export function sanitizeProjectFilter(
- filter: readonly string[],
- tree: readonly Pick<SidebarProjectTree, 'id'>[]
-): string[] {
- if (!filter.length) {
- return []
- }
-
- const known = new Set(tree.map(project => project.id))
-
- return filter.filter(id => known.has(id))
-}
-
/**
* 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