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: persistent tab state bug (#2232)
Peter Chinmandb8b4698a100
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 25c63c2c36..d209684188 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@@ -61,6 +61,7 @@ import {Match,on,onCleanup,+ onMount,Show,Suspense,Switch,@@ -636,22 +637,29 @@ export const SoupViewList = (props: SoupViewListProps) => {const cacheKey = `soup-view-${panel.handle.id}-${contentId}${previewPanel ? '-preview' : ''}`;+ // Restore previewEntity synchronously so the first-render effect sees the+ // correct value and avoids a transient window where previewEntity is undefined.+ const initialPersistedState = !persistenceDisabled+ ? untrack(persistedState)+ : null;+ soup.setPreviewEntity(initialPersistedState?.previewEntity);+// Set initial state- const initial = !persistenceDisabled ? untrack(persistedState) : null;- if (initial) {- batch(() => {- soup.filters.set(initial.filters ?? { and: [], or: [] });- setQueryFilters(initial.queryFilters ?? {});- soup.sort.setAll(initial.sort ?? []);- setActiveTab(initial.activeTab);- setAssigneeFilter(initial.assigneeFilter ?? []);- if (initial.previewEntity) {- soup.setPreviewEntity(initial.previewEntity);+ onMount(() => {+ if (initialPersistedState) {+ batch(() => {+ soup.filters.set(initialPersistedState.filters ?? { and: [], or: [] });+ setQueryFilters(initialPersistedState.queryFilters ?? {});+ soup.sort.setAll(initialPersistedState.sort ?? []);+ setActiveTab(initialPersistedState.activeTab);+ setAssigneeFilter(initialPersistedState.assigneeFilter ?? []);+ });+ } else {+ if (props.initialClientFilters) {+ soup.filters.set(props.initialClientFilters);}- });- } else if (props.initialClientFilters) {- soup.filters.set(props.initialClientFilters);- }+ }+ });createEffect(on(diff --git a/js/app/packages/core/hotkey/hotkeys.ts b/js/app/packages/core/hotkey/hotkeys.tsindex 2d5abcc614..643319bc8a 100644--- a/js/app/packages/core/hotkey/hotkeys.ts+++ b/js/app/packages/core/hotkey/hotkeys.ts@@ -455,6 +455,10 @@ export function useHotkeyDOMScope(};const attachFn = (el: Element) => {+ if (!el)+ return console.error(+ 'Trying to attach hotkeys to an element that does exist.'+ );const DOMScope = hotkeyScopeTree.get(scopeId);// Attach this scope to the closest parent scope.// Note: this only works in "ideal" circumstances, where children are attached sequentially after parents. This is not always the case.diff --git a/js/app/packages/core/hotkey/utils.ts b/js/app/packages/core/hotkey/utils.tsindex 60878e6f04..74eb580181 100644--- a/js/app/packages/core/hotkey/utils.ts+++ b/js/app/packages/core/hotkey/utils.ts@@ -571,7 +571,8 @@ export function getScopeElement(scopeId: string): Element | null {}// Returns the id of the closest parent scope, or 'global' if no parent scope is found.-export function findClosestParentScopeId(element: Element) {+export function findClosestParentScopeId(element: Element | null | undefined) {+ if (!element) return 'global';const parentElement = element.parentElement;if (!parentElement) return 'global';const closestParent = parentElement.closest('[data-hotkey-scope]');