Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(soup): query filters not saved and restored, notifications opening in new split (#1494)

dev-rbc11125e89320
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
index 0d83ce476a..cb473ad00f 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
@@ -67,6 +67,7 @@ interface SoupViewContextValues {
setSearchText: (value: string) => void;
isSearchDisabled: Accessor<boolean>;
rows: Accessor<SoupRow[]>;
+ queryFilters: Accessor<SoupItemsQueryFilters>;
setQueryFilters: Setter<SoupItemsQueryFilters>;
}
@@ -417,6 +418,7 @@ export const SoupViewContextProvider: FlowComponent<
searchText,
setSearchText,
isSearchDisabled,
+ queryFilters,
setQueryFilters,
};
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.tsx
index ef20aeb710..a3e3c7ccfe 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
@@ -73,6 +73,7 @@ import { ENABLE_UNIFIED_LIST_AI_INPUT } from '@core/constant/featureFlags';
import { isMobile } from '@core/mobile/isMobile';
import type { SystemSortOption } from '@app/component/next-soup/soup-view/sort-options';
import { usePropertyEditorHotkeys } from '@app/component/property-edit-modal/hooks/usePropertyEditorHotkeys';
+import type { SoupItemsQueryFilters } from '@queries/soup/items';
const DEFAULT_ENTITY_HEIGHT = 40;
@@ -119,6 +120,7 @@ const stateCache = new Map<
soup: {
focus: string | undefined;
filters: string[];
+ queryFilters: SoupItemsQueryFilters;
sort: SystemSortOption[];
};
virtualCache?: CacheSnapshot;
@@ -162,7 +164,8 @@ interface SoupViewListProps {
export const SoupViewList = (props: SoupViewListProps) => {
const panel = useSplitPanelOrThrow();
- const { soup, source, rows, searchText } = useSoupView();
+ const { soup, source, rows, searchText, setQueryFilters, queryFilters } =
+ useSoupView();
const { getSplitCount } = useSplitLayout();
const { isKeypressActive } = useIsKeyPressActive();
@@ -451,6 +454,7 @@ export const SoupViewList = (props: SoupViewListProps) => {
soup: {
focus: soup.focus.id(),
filters: soup.filters.activeIds(),
+ queryFilters: queryFilters(),
sort: soup.sort.active().map((s) => s.id),
},
virtualCache: virtualHandle?.cache,
@@ -458,10 +462,11 @@ export const SoupViewList = (props: SoupViewListProps) => {
});
});
- const registerVirtualizerHandler = (
- handle: VirtualizerHandle | undefined
- ) => {
- setVirtualizerHandle(handle);
+ let restored = false;
+ const restoreState = () => {
+ if (restored) return;
+
+ restored = true;
const cached = stateCache.get(getCacheKey());
@@ -475,12 +480,22 @@ export const SoupViewList = (props: SoupViewListProps) => {
soup.filters.activate(id);
}
+ setQueryFilters(cached.soup.queryFilters);
+
soup.sort.setAll(cached.soup.sort);
- handle?.scrollTo(cached.scrollOffset ?? 0);
+ virtualizerHandle()?.scrollTo(cached.scrollOffset ?? 0);
registerFocusEffects(false);
};
+ const registerVirtualizerHandler = (
+ handle: VirtualizerHandle | undefined
+ ) => {
+ setVirtualizerHandle(handle);
+
+ restoreState();
+ };
+
return (
<div
class="size-full flex bracket-never"
diff --git a/js/app/packages/entity/src/extractors-notification/notification-stacks.tsx b/js/app/packages/entity/src/extractors-notification/notification-stacks.tsx
index 715078e224..fdb24dcd65 100644
--- a/js/app/packages/entity/src/extractors-notification/notification-stacks.tsx
+++ b/js/app/packages/entity/src/extractors-notification/notification-stacks.tsx
@@ -52,7 +52,7 @@ function NotificationStackRow(props: {
if (!splitManager) return;
e.stopPropagation();
- await openNotification(mostRecent, splitManager);
+ await openNotification(mostRecent, splitManager, e.shiftKey);
await notificationSource.markAsRead(mostRecent);
props.onClick?.(e);
};
diff --git a/js/app/packages/notifications/notification-navigation.ts b/js/app/packages/notifications/notification-navigation.ts
index dab4130142..567ed6edea 100644
--- a/js/app/packages/notifications/notification-navigation.ts
+++ b/js/app/packages/notifications/notification-navigation.ts
@@ -21,7 +21,8 @@ const CHANNEL_EVENT_TYPES = [
function openSplitIfNotOpen(
layoutManager: SplitManager,
type: BlockName | BlockAlias | 'component',
- id: string
+ id: string,
+ newSplit: boolean = false
) {
const existing = layoutManager.getSplitByContent(type, id);
if (existing) {
@@ -33,7 +34,7 @@ function openSplitIfNotOpen(
{
activate: true,
referredFrom: null,
- preferNewSplit: true,
+ preferNewSplit: newSplit,
}
);
}
@@ -43,7 +44,8 @@ function openSplitIfNotOpen(
*/
async function openChannelNotification(
notification: UnifiedNotification,
- layoutManager: SplitManager
+ layoutManager: SplitManager,
+ newSplit: boolean = false
) {
const channelId = notification.entity_id;
let messageId: string | undefined;
@@ -60,7 +62,7 @@ async function openChannelNotification(
threadId = notification.notificationMetadata.content.threadId;
}
- openSplitIfNotOpen(layoutManager, 'channel', channelId);
+ openSplitIfNotOpen(layoutManager, 'channel', channelId, newSplit);
const orchestrator = layoutManager.getOrchestrator();
const handle = await orchestrator.getBlockHandle(channelId, 'channel');
@@ -89,52 +91,57 @@ export type OpenNotificationFromIdError = NotSupportedError | NotFoundError;
function getSupportedHandler(
notification: UnifiedNotification
-): ((layoutManager: SplitManager) => Promise<void>) | null {
+): ((layoutManager: SplitManager, newSplit?: boolean) => Promise<void>) | null {
const tag = notification.notificationMetadata.tag;
return match(tag)
.with(
P.union(...CHANNEL_EVENT_TYPES),
- () => (lm: SplitManager) => openChannelNotification(notification, lm)
+ () =>
+ (lm: SplitManager, newSplit: boolean = false) =>
+ openChannelNotification(notification, lm, newSplit)
)
.with('new_email', () => {
const meta = notification.notificationMetadata;
if (meta.tag !== 'new_email') return null;
- return async (lm: SplitManager) => {
- openSplitIfNotOpen(lm, 'email', meta.content.threadId);
+ return async (lm: SplitManager, newSplit: boolean = false) => {
+ openSplitIfNotOpen(lm, 'email', meta.content.threadId, newSplit);
};
})
.with(
'channel_invite',
- () => async (lm: SplitManager) =>
- openSplitIfNotOpen(lm, 'channel', notification.entity_id)
+ () =>
+ async (lm: SplitManager, newSplit: boolean = false) =>
+ openSplitIfNotOpen(lm, 'channel', notification.entity_id, newSplit)
)
.with('document_mention', () => {
const meta = notification.notificationMetadata;
if (meta.tag !== 'document_mention') return null;
- return async (lm: SplitManager) =>
+ return async (lm: SplitManager, newSplit: boolean = false) =>
openSplitIfNotOpen(
lm,
safeFileTypeToBlockName(meta.content.fileType),
- notification.entity_id
+ notification.entity_id,
+ newSplit
);
})
.with('invite_to_team', () => null)
.with('task_assigned', () => {
const meta = notification.notificationMetadata;
if (meta.tag !== 'task_assigned') return null;
- return async (lm: SplitManager) => {
- openSplitIfNotOpen(lm, 'task', meta.content.taskId);
+ return async (lm: SplitManager, newSplit: boolean = false) => {
+ openSplitIfNotOpen(lm, 'task', meta.content.taskId, newSplit);
};
})
.with('mentioned_in_document_comment', () => {
const meta = notification.notificationMetadata;
if (meta.tag !== 'mentioned_in_document_comment') return null;
- return async (lm: SplitManager) =>
+ return async (lm: SplitManager, newSplit: boolean = false) =>
openSplitIfNotOpen(
lm,
safeFileTypeToBlockName(meta.content.fileType),
- notification.entity_id
+ notification.entity_id,
+ newSplit
);
})
.exhaustive();
@@ -146,7 +153,8 @@ function getSupportedHandler(
*/
export function openNotification(
notification: UnifiedNotification,
- layoutManager: SplitManager
+ layoutManager: SplitManager,
+ newSplit: boolean = false
): ResultAsync<void, NotSupportedError> {
const handler = getSupportedHandler(notification);
if (!handler) {
@@ -155,7 +163,7 @@ export function openNotification(
notificationType: notification.notificationMetadata.tag,
});
}
- return ResultAsync.fromSafePromise(handler(layoutManager));
+ return ResultAsync.fromSafePromise(handler(layoutManager, newSplit));
}
export function openNotificationFromId(