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.

Seanaye/perf/more laziness (#5832)

Sean Ayeec2238eb35b5
diff --git a/apps/web/src/features/channel/Message/ActionMenu.tsx b/apps/web/src/features/channel/Message/ActionMenu.tsx
index e8cd980c5f..fc8dde35b2 100644
--- a/apps/web/src/features/channel/Message/ActionMenu.tsx
+++ b/apps/web/src/features/channel/Message/ActionMenu.tsx
@@ -1,4 +1,5 @@
import { recordEmojiUsage } from '@core/component/Emoji/emojiUsage';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
import StarIcon from '@icon/wide-star.svg';
import TaskIcon from '@icon/wide-task.svg';
import ReplyIcon from '@phosphor/arrow-bend-up-left.svg';
@@ -8,8 +9,19 @@ import EditIcon from '@phosphor/pencil-simple.svg';
import AddEmojiIcon from '@phosphor/smiley.svg';
import TrashIcon from '@phosphor/trash.svg';
import { Button, cn, Layer } from '@ui';
-import { type Component, createSignal, For, type JSX, Show } from 'solid-js';
-import { useMessage, useMessageActions } from './context';
+import {
+ type Component,
+ createSignal,
+ For,
+ type JSX,
+ onCleanup,
+ Show,
+} from 'solid-js';
+import {
+ useMessage,
+ useMessageActionMenuVisibility,
+ useMessageActions,
+} from './context';
import { EmojiReactionPopover } from './EmojiReactionPopover';
import { HoverActions } from './HoverActions';
import { renderIcon } from './render-icon';
@@ -62,11 +74,19 @@ function ActionButton(props: {
);
}
-export function ActionMenu(props: ActionMenuProps) {
+function ActionMenuContent(props: ActionMenuProps) {
const message = useMessage();
const actions = useMessageActions();
+ const actionMenuVisibility = useMessageActionMenuVisibility();
const [emojiMenuOpen, setEmojiMenuOpen] = createSignal(false);
+ const handleEmojiMenuOpenChange = (isOpen: boolean) => {
+ setEmojiMenuOpen(isOpen);
+ actionMenuVisibility.setPersistent(isOpen);
+ };
+
+ onCleanup(() => actionMenuVisibility.setPersistent(false));
+
const handleReaction = (emoji: string, event?: MessageActionEvent) => {
void actions?.onReact?.({
message: message(),
@@ -166,7 +186,7 @@ export function ActionMenu(props: ActionMenuProps) {
<EmojiReactionPopover
placement="left"
open={emojiMenuOpen()}
- onOpenChange={setEmojiMenuOpen}
+ onOpenChange={handleEmojiMenuOpenChange}
onEmojiSelect={(emoji) => {
handleReaction(emoji);
}}
@@ -213,3 +233,13 @@ export function ActionMenu(props: ActionMenuProps) {
</Show>
);
}
+
+export function ActionMenu(props: ActionMenuProps) {
+ const actionMenuVisibility = useMessageActionMenuVisibility();
+
+ return (
+ <Show when={actionMenuVisibility.visible() && !isTouchDevice()}>
+ <ActionMenuContent {...props} />
+ </Show>
+ );
+}
diff --git a/apps/web/src/features/channel/Message/HoverActions.tsx b/apps/web/src/features/channel/Message/HoverActions.tsx
index aac811a5cf..e13b979624 100644
--- a/apps/web/src/features/channel/Message/HoverActions.tsx
+++ b/apps/web/src/features/channel/Message/HoverActions.tsx
@@ -13,7 +13,9 @@ export function HoverActions(props: HoverActionsProps) {
<div
class={cn(
'absolute right-4 top-0 -translate-y-1/2 z-10',
- props.persistentVisible ? '' : 'hidden group-hover/message:block',
+ props.persistentVisible
+ ? ''
+ : 'hidden group-hover/message:block group-focus-within/message:block',
isTouchDevice() && 'hidden',
props.class
)}
diff --git a/apps/web/src/features/channel/Message/Root.tsx b/apps/web/src/features/channel/Message/Root.tsx
index c4907c2b80..f690f9fcf8 100644
--- a/apps/web/src/features/channel/Message/Root.tsx
+++ b/apps/web/src/features/channel/Message/Root.tsx
@@ -1,7 +1,11 @@
import { stickyGate } from '@core/util/debounce';
import { cn } from '@ui';
-import { type JSX, splitProps } from 'solid-js';
-import { MessageActionsProvider, MessageProvider } from './context';
+import { createSignal, type JSX, splitProps } from 'solid-js';
+import {
+ MessageActionMenuVisibilityProvider,
+ MessageActionsProvider,
+ MessageProvider,
+} from './context';
import type { MessageActions, MessageData } from './types';
/**
@@ -10,6 +14,9 @@ import type { MessageActions, MessageData } from './types';
* duration in index.css.
*/
const TARGETED_FADE_OUT_MS = 500;
+const ACTION_MENU_POINTER_VISIBLE = 1;
+const ACTION_MENU_FOCUS_VISIBLE = 2;
+const ACTION_MENU_PERSISTENT = 4;
type RootProps = JSX.HTMLAttributes<HTMLDivElement> & {
message: MessageData;
@@ -23,6 +30,17 @@ type RootProps = JSX.HTMLAttributes<HTMLDivElement> & {
targeted?: boolean;
};
+function callEventHandler<E extends Event>(
+ event: E & { currentTarget: HTMLDivElement; target: Element },
+ handler: JSX.EventHandlerUnion<HTMLDivElement, E> | undefined
+) {
+ if (typeof handler === 'function') {
+ handler(event);
+ } else if (handler) {
+ handler[0](handler[1], event);
+ }
+}
+
export function Root(props: RootProps) {
const [local, rest] = splitProps(props, [
'children',
@@ -31,8 +49,25 @@ export function Root(props: RootProps) {
'actions',
'selected',
'targeted',
+ 'onPointerEnter',
+ 'onPointerLeave',
+ 'onFocusIn',
+ 'onFocusOut',
]);
+ const [actionMenuVisibilityFlags, setActionMenuVisibilityFlags] =
+ createSignal(0);
+ const setActionMenuVisibilityFlag = (flag: number, visible: boolean) => {
+ setActionMenuVisibilityFlags((current) =>
+ visible ? current | flag : current & ~flag
+ );
+ };
+ const actionMenuVisibility = {
+ visible: () => actionMenuVisibilityFlags() !== 0,
+ setPersistent: (persistent: boolean) =>
+ setActionMenuVisibilityFlag(ACTION_MENU_PERSISTENT, persistent),
+ };
+
// When the message stops being targeted, the accent fades out instead of
// cutting off: the sticky gate holds for the fade window after `targeted`
// falls, so the fading flag is true exactly during that window.
@@ -51,12 +86,38 @@ export function Root(props: RootProps) {
data-selected={local.selected ? '' : undefined}
data-targeted={local.targeted ? '' : undefined}
data-targeted-fading={targetFading() ? '' : undefined}
+ onPointerEnter={(event) => {
+ setActionMenuVisibilityFlag(ACTION_MENU_POINTER_VISIBLE, true);
+ callEventHandler(event, local.onPointerEnter);
+ }}
+ onPointerLeave={(event) => {
+ setActionMenuVisibilityFlag(ACTION_MENU_POINTER_VISIBLE, false);
+ callEventHandler(event, local.onPointerLeave);
+ }}
+ onFocusIn={(event) => {
+ setActionMenuVisibilityFlag(ACTION_MENU_FOCUS_VISIBLE, true);
+ callEventHandler(event, local.onFocusIn);
+ }}
+ onFocusOut={(event) => {
+ const nextTarget = event.relatedTarget;
+ if (
+ !(
+ nextTarget instanceof Node &&
+ event.currentTarget.contains(nextTarget)
+ )
+ ) {
+ setActionMenuVisibilityFlag(ACTION_MENU_FOCUS_VISIBLE, false);
+ }
+ callEventHandler(event, local.onFocusOut);
+ }}
{...rest}
>
<div class="absolute h-full w-1 left-0 top-0 bg-accent opacity-0 message-accent-bar" />
<MessageProvider value={() => local.message}>
<MessageActionsProvider value={local.actions}>
- {props.children}
+ <MessageActionMenuVisibilityProvider value={actionMenuVisibility}>
+ {props.children}
+ </MessageActionMenuVisibilityProvider>
</MessageActionsProvider>
</MessageProvider>
</div>
diff --git a/apps/web/src/features/channel/Message/context.ts b/apps/web/src/features/channel/Message/context.ts
index f1ff8f63c1..d78643a07c 100644
--- a/apps/web/src/features/channel/Message/context.ts
+++ b/apps/web/src/features/channel/Message/context.ts
@@ -4,6 +4,14 @@ import type { MessageActions, MessageData } from './types';
const MessageContext = createContext<Accessor<MessageData>>();
const MessageActionsContext = createContext<MessageActions>();
+type MessageActionMenuVisibility = {
+ visible: Accessor<boolean>;
+ setPersistent: (persistent: boolean) => void;
+};
+
+const MessageActionMenuVisibilityContext =
+ createContext<MessageActionMenuVisibility>();
+
export type SearchHighlightTermsLookup = (
messageId: string
) => readonly string[] | undefined;
@@ -12,6 +20,8 @@ const SearchHighlightTermsContext = createContext<SearchHighlightTermsLookup>();
export const MessageProvider = MessageContext.Provider;
export const MessageActionsProvider = MessageActionsContext.Provider;
+export const MessageActionMenuVisibilityProvider =
+ MessageActionMenuVisibilityContext.Provider;
export const SearchHighlightTermsProvider =
SearchHighlightTermsContext.Provider;
@@ -31,6 +41,16 @@ export function useMessageActions(): MessageActions | undefined {
return useContext(MessageActionsContext);
}
+export function useMessageActionMenuVisibility(): MessageActionMenuVisibility {
+ const ctx = useContext(MessageActionMenuVisibilityContext);
+ if (!ctx) {
+ throw new Error(
+ 'useMessageActionMenuVisibility must be used within <Message.Root>'
+ );
+ }
+ return ctx;
+}
+
export type MessageActionDrawerState = {
isOpen: Accessor<boolean>;
message: Accessor<MessageData | undefined>;
diff --git a/apps/web/src/features/channel/Message/tests/action-menu.test.tsx b/apps/web/src/features/channel/Message/tests/action-menu.test.tsx
new file mode 100644
index 0000000000..cf3d294251
--- /dev/null
+++ b/apps/web/src/features/channel/Message/tests/action-menu.test.tsx
@@ -0,0 +1,96 @@
+/**
+ * @vitest-environment jsdom
+ */
+
+import { fireEvent, render } from '@solidjs/testing-library';
+import { describe, expect, it, vi } from 'vitest';
+import { ActionMenu } from '../ActionMenu';
+import { Root } from '../Root';
+import type { MessageData } from '../types';
+
+const message: MessageData = {
+ id: 'message-1',
+ content: 'hello',
+ sender_id: 'user-2',
+ created_at: '2026-02-25T00:00:00.000Z',
+ updated_at: '2026-02-25T00:00:00.000Z',
+ attachments: [],
+ reactions: [],
+};
+
+describe('ActionMenu', () => {
+ it('mounts only while its message is hovered', () => {
+ const onPointerEnter = vi.fn();
+ const { container } = render(() => (
+ <Root
+ message={message}
+ actions={{ onReact: () => undefined }}
+ onPointerEnter={onPointerEnter}
+ >
+ <ActionMenu />
+ </Root>
+ ));
+ const root = container.querySelector<HTMLElement>('[data-message]');
+
+ expect(root).not.toBeNull();
+ expect(container.querySelector('[data-message-hover-actions]')).toBeNull();
+
+ fireEvent.pointerEnter(root!);
+
+ expect(onPointerEnter).toHaveBeenCalledTimes(1);
+ expect(
+ container.querySelector('[data-message-hover-actions]')
+ ).not.toBeNull();
+
+ fireEvent.pointerLeave(root!);
+
+ expect(container.querySelector('[data-message-hover-actions]')).toBeNull();
+ });
+
+ it('stays mounted while its emoji popover is open', () => {
+ const { container } = render(() => (
+ <Root message={message} actions={{ onReact: () => undefined }}>
+ <ActionMenu />
+ </Root>
+ ));
+ const root = container.querySelector<HTMLElement>('[data-message]');
+
+ fireEvent.pointerEnter(root!);
+ const emojiMenuTrigger = container.querySelector<HTMLButtonElement>(
+ '[aria-label="More reactions"]'
+ );
+ expect(emojiMenuTrigger).not.toBeNull();
+
+ fireEvent.click(emojiMenuTrigger!);
+ fireEvent.pointerLeave(root!);
+
+ expect(
+ container.querySelector('[data-message-hover-actions]')
+ ).not.toBeNull();
+ });
+
+ it('mounts while focus is within the message', () => {
+ const { container } = render(() => (
+ <Root message={message} actions={{ onReact: () => undefined }}>
+ <button type="button">Message control</button>
+ <ActionMenu />
+ </Root>
+ ));
+ const root = container.querySelector<HTMLElement>('[data-message]');
+ const control = container.querySelector<HTMLButtonElement>('button');
+
+ expect(root).not.toBeNull();
+ expect(control).not.toBeNull();
+ expect(container.querySelector('[data-message-hover-actions]')).toBeNull();
+
+ fireEvent.focusIn(control!);
+
+ expect(
+ container.querySelector('[data-message-hover-actions]')
+ ).not.toBeNull();
+
+ fireEvent.focusOut(control!, { relatedTarget: document.body });
+
+ expect(container.querySelector('[data-message-hover-actions]')).toBeNull();
+ });
+});
diff --git a/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsx b/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsx
index 24f183b94d..b2a71f9422 100644
--- a/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsx
+++ b/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsx
@@ -1,8 +1,10 @@
import { itemToSafeName } from '@core/constant/allBlocks';
-import { useChannelsContext } from '@core/context/channels';
+import {
+ useChannelsContext,
+ useDmActivityByUserId,
+} from '@core/context/channels';
import {
type IUser,
- useAugmentUserWithDmActivity,
useContacts,
useIsConnectedSecondaryInbox,
} from '@core/user';
@@ -26,7 +28,7 @@ import { getGraphqlSoupCacheHost } from '@service-storage/graphql-soup';
import { formatDocumentName } from '@service-storage/util/filename';
import { createLazyMemo } from '@solid-primitives/memo';
import { toDate } from 'date-fns';
-import { createEffect, createSignal, onCleanup } from 'solid-js';
+import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js';
import { searchQuickAccessItems } from './entity-search';
import type {
Bucket,
@@ -162,6 +164,18 @@ function toTimestamp(value: DateValue | null | undefined): number {
return toDate(value).getTime();
}
+function equalActivityMaps(
+ previous: Map<string, DateValue>,
+ next: Map<string, DateValue>
+): boolean {
+ if (previous.size !== next.size) return false;
+ for (const [id, value] of previous) {
+ if (!next.has(id)) return false;
+ if (toTimestamp(value) !== toTimestamp(next.get(id))) return false;
+ }
+ return true;
+}
+
function getHistoryItemVersion(item: HistoryItem, viewedAt?: string): string {
return `${item.name}|${item.updatedAt}|${viewedAt}|${item.deletedAt}`;
}
@@ -173,8 +187,11 @@ function getChannelVersion(
return `${channel.name}|${channel.updated_at}|${viewedAt}`;
}
-function getUserVersion(user: IUser): string {
- return `${user.name}|${user.email}|${user.lastInteraction}`;
+function getUserVersion(
+ user: IUser,
+ lastInteraction: DateValue | undefined
+): string {
+ return `${user.name}|${user.email}|${lastInteraction}`;
}
function getCrmCompanySearchText(company: CrmCompanyEntity): string {
@@ -237,13 +254,21 @@ function mergeMultipleSortedIndices(arrays: IndexEntry[][]): IndexEntry[] {
return arrays.reduce((acc, arr) => mergeSortedIndices(acc, arr));
}
+function sortIndexEntries(entries: IndexEntry[]): IndexEntry[] {
+ entries.sort((a, b) => b.sortTimestamp - a.sortTimestamp);
+ return entries;
+}
+
/** Builds Quick Access from history and its supporting entity sources. */
export function createQuickAccessValue(): QuickAccessContextValue {
// queries
const historyQuery = useHistoryQuery();
const { channels, isLoading: channelsLoading } = useChannelsContext();
const contacts = useContacts();
- const augmentUserWithDmActivity = useAugmentUserWithDmActivity();
+ const rawDmActivityByUserId = useDmActivityByUserId();
+ const dmActivityByUserId = createMemo(rawDmActivityByUserId, undefined, {
+ equals: equalActivityMaps,
+ });
const isConnectedSecondaryInbox = useIsConnectedSecondaryInbox();
const cacheHost = getGraphqlSoupCacheHost();
const [cacheRevision, setCacheRevision] = createSignal(0);
@@ -294,18 +319,11 @@ export function createQuickAccessValue(): QuickAccessContextValue {
return map;
});
- const processedData = createLazyMemo(() => {
+ const historyEntries = createLazyMemo(() => {
const viewedAtMap = soupViewedAtMap();
const seenIds = new Set<string>();
const allEntries: IndexEntry[] = [];
- const transformedItems: Array<{
- id: string;
- name: string;
- type: string;
- reason: string;
- }> = [];
-
// Process history items
const historyData = historyQuery.data ?? [];
const hidden = hiddenIds();
@@ -320,15 +338,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {
const cached = itemCache.get(item.id);
if (!cached || cached.version !== version) {
- const reason = !cached
- ? 'new'
- : `changed (${cached.version} -> ${version})`;
- transformedItems.push({
- id: item.id,
- name: item.name,
- type: `history:${item.type}`,
- reason,
- });
const bucket = getBucketForHistoryItem(item);
const entity = {
...historyItemToEntity(item),
@@ -363,11 +372,19 @@ export function createQuickAccessValue(): QuickAccessContextValue {
}
}
+ return {
+ entries: sortIndexEntries(allEntries),
+ ids: seenIds,
+ };
+ });
+
+ const channelEntries = createLazyMemo(() => {
+ const viewedAtMap = soupViewedAtMap();
+ const allEntries: IndexEntry[] = [];
+
// Process channels
const channelData = channels();
for (const channel of channelData) {
- seenIds.add(channel.id);
-
const viewedAt =
viewedAtMap.get(channel.id) ?? channel.viewed_at ?? undefined;
@@ -375,15 +392,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {
const cached = itemCache.get(channel.id);
if (!cached || cached.version !== version) {
- const reason = !cached
- ? 'new'
- : `changed (${cached.version} -> ${version})`;
- transformedItems.push({
- id: channel.id,
- name: channel.name ?? '',
- type: `channel:${channel.channel_type}`,
- reason,
- });
const isDm = channel.channel_type === 'direct_message';
const bucket: Bucket = isDm ? 'dm' : 'channel';
const entity = {
@@ -419,27 +427,25 @@ export function createQuickAccessValue(): QuickAccessContextValue {
}
}
+ return sortIndexEntries(allEntries);
+ });
+
+ const contactEntries = createLazyMemo(() => {
+ const activityByUserId = dmActivityByUserId();
+ const allEntries: IndexEntry[] = [];
+
// Process contacts (users)
const contactData = contacts();
for (const contact of contactData) {
if (isConnectedSecondaryInbox(contact.id)) continue;
- const augmentedUser = augmentUserWithDmActivity(contact);
- seenIds.add(augmentedUser.id);
+ const lastInteraction = activityByUserId.get(contact.id);
- const version = getUserVersion(augmentedUser);
- const cached = itemCache.get(augmentedUser.id);
+ const version = getUserVersion(contact, lastInteraction);
+ const cached = itemCache.get(contact.id);
if (!cached || cached.version !== version) {
- const reason = !cached
- ? 'new'
- : `changed (${cached.version} -> ${version})`;
- transformedItems.push({
- id: augmentedUser.id,
- name: augmentedUser.name,
- type: 'user',
- reason,
- });
- const sortTimestamp = toTimestamp(augmentedUser.lastInteraction);
+ const augmentedUser = { ...contact, lastInteraction };
+ const sortTimestamp = toTimestamp(lastInteraction);
const quickAccessItem: QuickAccessItem = {
kind: 'user',
@@ -461,13 +467,21 @@ export function createQuickAccessValue(): QuickAccessContextValue {
});
} else {
allEntries.push({
- id: augmentedUser.id,
+ id: contact.id,
bucket: cached.item.bucket,
sortTimestamp: cached.item.sortTimestamp,
});
}
}
+ return sortIndexEntries(allEntries);
+ });
+
+ const crmCompanyEntries = createLazyMemo(() => {
+ const viewedAtMap = soupViewedAtMap();
+ const allEntries: IndexEntry[] = [];
+ const hidden = hiddenIds();
+
// Process CRM companies (live soup list, complements the
// recently-viewed feed which only has companies the user has
// opened). Sort timestamp prefers viewed_at; falls back to
@@ -475,7 +489,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {
const crmCompanyData = crmCompaniesAccessor();
for (const company of crmCompanyData) {
if (hidden.has(company.id)) continue;
- seenIds.add(company.id);
const viewedAt =
viewedAtMap.get(company.id) ?? company.viewedAt ?? undefined;
@@ -487,15 +500,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {
const cached = itemCache.get(company.id);
if (!cached || cached.version !== version) {
- const reason = !cached
- ? 'new'
- : `changed (${cached.version} -> ${version})`;
- transformedItems.push({
- id: company.id,
- name: company.name,
- type: 'crm_company',
- reason,
- });
const entity: CrmCompanyEntity = {
...company,
viewedAt: (viewedAt ?? company.viewedAt) as DateValue | null,
@@ -533,6 +537,15 @@ export function createQuickAccessValue(): QuickAccessContextValue {
}
}
+ return sortIndexEntries(allEntries);
+ });
+
+ const snippetEntries = createLazyMemo(() => {
+ const viewedAtMap = soupViewedAtMap();
+ const seenIds = new Set(historyEntries().ids);
+ const allEntries: IndexEntry[] = [];
+ const hidden = hiddenIds();
+
// Process snippets (live soup list, complements the history feed
// which only has snippets the user has opened). Widens the pool to
// team-shared snippets so the `;` menu lists snippets the user has
@@ -554,15 +567,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {
const cached = itemCache.get(snippet.id);
if (!cached || cached.version !== version) {
- const reason = !cached
- ? 'new'
- : `changed (${cached.version} -> ${version})`;
- transformedItems.push({
- id: snippet.id,
- name: snippet.name,
- type: 'snippet',
- reason,
- });
const entity: SnippetEntity = {
...snippet,
viewedAt: (viewedAt ?? snippet.viewedAt) as DateValue | null,
@@ -600,6 +604,15 @@ export function createQuickAccessValue(): QuickAccessContextValue {
}
}
+ return sortIndexEntries(allEntries);
+ });
+
+ const skillEntries = createLazyMemo(() => {
+ const viewedAtMap = soupViewedAtMap();
+ const seenIds = new Set(historyEntries().ids);
+ const allEntries: IndexEntry[] = [];
+ const hidden = hiddenIds();
+
// Process skills (live soup list, complements the history feed which
// only has skills the user has opened). Widens the pool to shared
// skills so the `/` menu lists skills the user has never opened.
@@ -616,15 +629,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {
const cached = itemCache.get(skill.id);
if (!cached || cached.version !== version) {
- const reason = !cached
- ? 'new'
- : `changed (${cached.version} -> ${version})`;
- transformedItems.push({
- id: skill.id,
- name: skill.name,
- type: 'skill',
- reason,
- });
const entity: SkillEntity = {
...skill,
viewedAt: (viewedAt ?? skill.viewedAt) as DateValue | null,
@@ -662,6 +666,20 @@ export function createQuickAccessValue(): QuickAccessContextValue {
}
}
+ return sortIndexEntries(allEntries);
+ });
+
+ const processedData = createLazyMemo(() => {
+ const allEntries = mergeMultipleSortedIndices([
+ historyEntries().entries,
+ channelEntries(),
+ contactEntries(),
+ crmCompanyEntries(),
+ snippetEntries(),
+ skillEntries(),
+ ]);
+ const seenIds = new Set(allEntries.map((entry) => entry.id));
+
// Clean up stale cache entries (items that no longer exist)
for (const id of itemCache.keys()) {
if (!seenIds.has(id)) {
@@ -669,9 +687,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {
}
}
- // Sort all entries by timestamp descending
- allEntries.sort((a, b) => b.sortTimestamp - a.sortTimestamp);
-
// Deduplicate by id - keep the first occurrence (most recent timestamp)
const deduplicatedEntries: IndexEntry[] = [];
const dedupeSet = new Set<string>();