Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(search): scope channel filter cache (#2505)
gbirman4af78394817b
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsxindex 0db1ce0ee9..22cd07d0ef 100644--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsx@@ -6,7 +6,10 @@ import { useQuickAccess } from '@core/context/quickAccess';import { useUserId } from '@core/context/user';import { QUERY_FILTERS } from '@app/component/next-soup/filters/query-filters';import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';-import { soupViewCacheKey } from '@app/component/next-soup/soup-view/soup-view-cache-key';+import {+ soupViewCacheKey,+ activeSoupViewCounts,+} from '@app/component/next-soup/soup-view/soup-view-cache-key';import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';import type { SoupBody } from '@queries/soup/items';import { batch, createEffect, createMemo, Show } from 'solid-js';@@ -17,6 +20,7 @@ import type { ChannelFilters } from '@service-storage/generated/schemas';type ChannelSubFilters = Pick<ChannelFilters, 'channel_ids' | 'sender_ids'>;function getCachedChannelSubFilters(contentId: string): ChannelSubFilters {+ if ((activeSoupViewCounts.get(contentId) ?? 0) > 1) return {};try {const raw = localStorage.getItem(soupViewCacheKey(contentId, 'channel-sub-filters')@@ -28,10 +32,15 @@ function getCachedChannelSubFilters(contentId: string): ChannelSubFilters {}function cacheChannelSubFilters(contentId: string, filters: ChannelSubFilters) {- localStorage.setItem(- soupViewCacheKey(contentId, 'channel-sub-filters'),- JSON.stringify(filters)- );+ if ((activeSoupViewCounts.get(contentId) ?? 0) > 1) return;+ try {+ localStorage.setItem(+ soupViewCacheKey(contentId, 'channel-sub-filters'),+ JSON.stringify(filters)+ );+ } catch {+ // best-effort: quota or security errors should not break filter flow+ }}export const INDEX_OPTIONS: (Option & { queryFilters: SoupBody })[] = [diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-cache-key.ts b/js/app/packages/app/component/next-soup/soup-view/soup-view-cache-key.tsindex 1cd3953012..10380bd15f 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-cache-key.ts+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-cache-key.ts@@ -2,3 +2,7 @@ export function soupViewCacheKey(contentId: string, suffix?: string): string {const base = `macro:soup-view:${contentId}`;return suffix ? `${base}:${suffix}` : base;}++// Tracks how many SoupViewList instances are mounted per contentId.+// Used to detect duplicate splits showing the same view.+export const activeSoupViewCounts = new Map<string, number>();diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsxindex d137889e89..7a5f0b7fbc 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx@@ -17,7 +17,10 @@ import {SoupViewContextProvider,useSoupView,} from '@app/component/next-soup/soup-view/soup-view-context';-import { soupViewCacheKey } from '@app/component/next-soup/soup-view/soup-view-cache-key';+import {+ soupViewCacheKey,+ activeSoupViewCounts,+} from '@app/component/next-soup/soup-view/soup-view-cache-key';import { useSoupNavigationHotkeys } from './use-soup-navigation-hotkeys';import { useSoupViewHotkeys } from './use-soup-view-hotkeys';import { useSplitLayout } from '@app/component/split-layout/layout';@@ -172,10 +175,6 @@ type PersistedSoupViewState = {const PERSISTED_STATE_VERSION = 2;-// Tracks how many SoupViewList instances are mounted per contentId.-// Used to detect duplicate splits showing the same view.-const activeSoupViewCounts = new Map<string, number>();-const listStateCache = new Map<string,{