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.

chg(properties): use chunk buckets for properties, various type cleanups (#1652)

Seamusba5881ff7932
diff --git a/js/app/packages/app/component/PropertyFilter/FilterValueEntity.tsx b/js/app/packages/app/component/PropertyFilter/FilterValueEntity.tsx
index e1b33b7056..f2bffe4981 100644
--- a/js/app/packages/app/component/PropertyFilter/FilterValueEntity.tsx
+++ b/js/app/packages/app/component/PropertyFilter/FilterValueEntity.tsx
@@ -1,17 +1,18 @@
-import { useChannelsContext } from '@core/context/channels';
import {
type CombinedEntity,
createEntitySearchConfig,
- entityMapper,
+ useQuickAccessEntities,
getEntityName,
getEntitySearchText,
getEntityTimestampedItem,
getEntityType,
isChannelEntity,
threadMapper,
+ quickAccessItemToEntity,
+ userToEntity,
} from '@core/component/Properties/component/modal/shared/entityUtils';
import { usePropertyEntityDisplay } from '@core/component/Properties/hooks/usePropertyEntityDisplay';
-import { useAugmentUserWithDmActivity, useContacts } from '@core/user';
+import { useAugmentUserWithDmActivity } from '@core/user';
import { useEmail } from '@core/context/user';
import { createFreshSearch } from '@core/util/freshSort';
import { createEmailsInfiniteQuery } from '@macro-entity';
@@ -19,7 +20,6 @@ import type { EmailEntity } from '@entity';
import { useSearchSoupQuery } from '@queries/soup/search';
import XIcon from '@phosphor-icons/core/assets/regular/x.svg';
import type { EntityType } from '@service-properties/generated/schemas/entityType';
-import { useHistoryQuery } from '@queries/history/history';
import { debounce } from '@solid-primitives/scheduled';
import type { Component } from 'solid-js';
import {
@@ -85,11 +85,19 @@ export const FilterValueEntity: Component<FilterValueEntityProps> = (props) => {
let containerRef!: HTMLDivElement;
let dropdownRef!: HTMLDivElement;
- // Data sources (same pattern as PropertyEntitySelector)
- const contacts = useContacts();
- const channelsContext = useChannelsContext();
- const channels = channelsContext.channels;
- const historyQuery = useHistoryQuery();
+ const augmentUserWithDmActivity = useAugmentUserWithDmActivity();
+
+ // Get current user domain for same-domain boost in search
+ const currentUserEmail = useEmail();
+ const currentUserDomain = createMemo(() => {
+ const email = currentUserEmail();
+ return email ? email.split('@')[1] : undefined;
+ });
+
+ // Get items from quickAccess based on entity type
+ const { items: quickAccessItems } = useQuickAccessEntities(
+ () => props.specificEntityType
+ );
// Email queries for THREAD type or generic ENTITY (no specific type)
const needsEmailSearch = () =>
@@ -126,65 +134,49 @@ export const FilterValueEntity: Component<FilterValueEntityProps> = (props) => {
.map((entity) => threadMapper(entity as EmailEntity));
});
- // Helper to augment user entities with DM activity timestamps (same as MentionsMenu)
- const augmentUserWithDmActivity = useAugmentUserWithDmActivity();
- const augmentUsersWithDmActivity = (): CombinedEntity[] => {
- return contacts().map((user) =>
- entityMapper('user')(augmentUserWithDmActivity(user))
- );
- };
-
- // Get entities based on specific entity type (same logic as PropertyEntitySelector)
+ // Convert quickAccess items to CombinedEntity format
const entities = createMemo((): CombinedEntity[] => {
- const entityType = props.specificEntityType;
-
- // Generic entity - include all types
- if (!entityType) {
- return [
- ...augmentUsersWithDmActivity(),
- ...(historyQuery.data ?? []).map(entityMapper('item')),
- ...channels().map(entityMapper('channel')),
- ...emails().map(threadMapper),
- ];
- }
+ const specificEntityType = props.specificEntityType;
- if (entityType === 'USER') {
- return augmentUsersWithDmActivity();
- }
-
- if (entityType === 'CHANNEL') {
- return channels().map(entityMapper('channel'));
- }
-
- if (entityType === 'THREAD') {
+ // For THREAD type, use email data (not in quickAccess yet)
+ if (specificEntityType === 'THREAD') {
return emails().map(threadMapper);
}
- // Item-based types: DOCUMENT, PROJECT, CHAT
- const itemTypes: EntityType[] = ['DOCUMENT', 'PROJECT', 'CHAT'];
- if (itemTypes.includes(entityType)) {
- return (historyQuery.data ?? [])
- .filter((item) => item.type.toUpperCase() === entityType)
- .map(entityMapper('item'));
+ // For COMPANY type, return empty (not in quickAccess)
+ if (specificEntityType === 'COMPANY') {
+ return [];
}
- if (entityType === 'TASK') {
- return (historyQuery.data ?? [])
- .filter(
- (item) => item.type === 'document' && item.subType?.type === 'task'
- )
- .map(entityMapper('item'));
+ // Convert quickAccess items to CombinedEntity
+ const items = quickAccessItems();
+ const converted: CombinedEntity[] = [];
+
+ for (const item of items) {
+ // Augment users with DM activity
+ if (item.kind === 'user') {
+ const augmentedUser = augmentUserWithDmActivity(item.data);
+ converted.push(userToEntity(augmentedUser));
+ } else {
+ const entity = quickAccessItemToEntity(item);
+ // Filter by specific entity type if needed
+ if (specificEntityType) {
+ const entityType = getEntityType(entity);
+ if (entityType === specificEntityType) {
+ converted.push(entity);
+ }
+ } else {
+ converted.push(entity);
+ }
+ }
}
- // COMPANY not yet implemented
- return [];
- });
+ // For generic entity type, also include emails
+ if (!specificEntityType) {
+ converted.push(...emails().map(threadMapper));
+ }
- // Get current user domain for same-domain boost
- const currentUserEmail = useEmail();
- const currentUserDomain = createMemo(() => {
- const email = currentUserEmail();
- return email ? email.split('@')[1] : undefined;
+ return converted;
});
// Search function for fuzzy matching (same config as PropertyEntitySelector)
diff --git a/js/app/packages/app/component/command/CommandItem.tsx b/js/app/packages/app/component/command/CommandItem.tsx
index 9136c8790d..ea1926c34a 100644
--- a/js/app/packages/app/component/command/CommandItem.tsx
+++ b/js/app/packages/app/component/command/CommandItem.tsx
@@ -2,24 +2,24 @@ import { Hotkey } from '@core/component/Hotkey';
import { hasValidHotkey } from '@core/hotkey/utils';
import { Match, Show, Switch } from 'solid-js';
import {
- type QuickAccessItem,
- isEntityItem,
isCommandItem,
-} from '@core/context/quickAccess';
+ isEntityItem,
+ type CommandMenuItem,
+} from './useCommandItems';
import { Entity, type EntityData } from '@entity';
import { cn } from '@ui/utils/classname';
import Terminal from '@phosphor-icons/core/regular/terminal.svg?component-solid';
import { Dynamic } from 'solid-js/web';
export interface CommandItemProps {
- item: QuickAccessItem;
+ item: CommandMenuItem;
index: number;
selected: boolean;
- onSelect: (item: QuickAccessItem, openInNewSplit: boolean) => void;
+ onSelect: (item: CommandMenuItem, openInNewSplit: boolean) => void;
onHover: (index: number) => void;
}
-function CommandItemHotkey(props: { item: QuickAccessItem }) {
+function CommandItemHotkey(props: { item: CommandMenuItem }) {
const command = () => (isCommandItem(props.item) ? props.item.data : null);
const token = () => command()?.hotkeyToken;
@@ -47,7 +47,7 @@ function CommandItemHotkey(props: { item: QuickAccessItem }) {
);
}
-function CommandDisplay(props: { item: QuickAccessItem }) {
+function CommandDisplay(props: { item: CommandMenuItem }) {
const command = () => (isCommandItem(props.item) ? props.item.data : null);
const description = () => {
@@ -81,7 +81,7 @@ function EntityDisplay(props: { entity: EntityData }) {
);
}
-function ItemDisplay(props: { item: QuickAccessItem }) {
+function ItemDisplay(props: { item: CommandMenuItem }) {
return (
<Switch>
<Match when={isCommandItem(props.item) && props.item}>
diff --git a/js/app/packages/app/component/command/CommandMenu.tsx b/js/app/packages/app/component/command/CommandMenu.tsx
index a0519765a9..55998cda07 100644
--- a/js/app/packages/app/component/command/CommandMenu.tsx
+++ b/js/app/packages/app/component/command/CommandMenu.tsx
@@ -1,10 +1,10 @@
import { ClippedPanel } from '@core/component/ClippedPanel';
import { DialogWrapper } from '@core/component/DialogWrapper';
import {
- type QuickAccessItem,
- isEntityItem,
isCommandItem,
-} from '@core/context/quickAccess';
+ isEntityItem,
+ type CommandMenuItem,
+} from './useCommandItems';
import { getActiveCommandsFromScope } from '@core/hotkey/getCommands';
import { runCommand } from '@core/hotkey/utils';
import { Dialog } from '@kobalte/core/dialog';
@@ -55,7 +55,7 @@ const MAX_LIST_HEIGHT = VIRTUAL_ITEM_HEIGHT * 8;
const EMPTY_STATE_HEIGHT = VIRTUAL_ITEM_HEIGHT * 1.5;
function getBlockNameForEntity(
- item: QuickAccessItem
+ item: CommandMenuItem
): BlockName | BlockAlias | undefined {
if (isEntityItem(item)) {
return itemToBlockName(item.data);
@@ -135,7 +135,7 @@ function CommandMenuInner(props: {
return items[index];
};
- function handleItemAction(item: QuickAccessItem, openInNewSplit = false) {
+ function handleItemAction(item: CommandMenuItem, openInNewSplit = false) {
if (!item) return;
if (isCommandItem(item)) {
@@ -461,9 +461,9 @@ function EntityActionPreview(props: { entities: EntityData[] }) {
}
function ResultsContainer(props: {
- items: QuickAccessItem[];
+ items: CommandMenuItem[];
selectedIndex: number;
- onSelect: (item: QuickAccessItem, openInNewSplit: boolean) => void;
+ onSelect: (item: CommandMenuItem, openInNewSplit: boolean) => void;
onMouseEnter: (index: number) => void;
}) {
const containerHeight = () => {
@@ -499,9 +499,9 @@ function ResultsContainer(props: {
/** Virtualized command list component */
function VirtualizedCommandList(props: {
- items: QuickAccessItem[];
+ items: CommandMenuItem[];
selectedIndex: number;
- onSelect: (item: QuickAccessItem, openInNewSplit: boolean) => void;
+ onSelect: (item: CommandMenuItem, openInNewSplit: boolean) => void;
onMouseEnter: (index: number) => void;
}) {
let virtualizerHandle: VirtualizerHandle | undefined;
@@ -552,7 +552,7 @@ function HotkeyHint(props: { shortcut: string; label: string }) {
}
function CommandMenuFooter(props: {
- selectedItem: QuickAccessItem | undefined;
+ selectedItem: CommandMenuItem | undefined;
isInCommandScope: boolean;
isEntityActionMode?: boolean;
}) {
diff --git a/js/app/packages/app/component/command/useCommandItems.ts b/js/app/packages/app/component/command/useCommandItems.ts
index b06a51900e..67ef96a9a2 100644
--- a/js/app/packages/app/component/command/useCommandItems.ts
+++ b/js/app/packages/app/component/command/useCommandItems.ts
@@ -2,12 +2,11 @@ import {
useQuickAccess,
type QuickAccessItem,
type Bucket,
- type CommandItem,
- isEntityItem,
- isUserItem,
- isCommandItem,
+ type EntityItem,
+ type UserItem,
exclude,
} from '@core/context/quickAccess';
+import type { HotkeyCommand } from '@core/hotkey/types';
import { createFreshSearch } from '@core/util/freshSort';
import { createMemo } from 'solid-js';
import type { CategoryFilter } from './types';
@@ -19,7 +18,33 @@ import { activeScope } from '@core/hotkey/state';
import { CommandState } from './state';
import { HotkeyTags } from '@core/hotkey/constants';
-function isChannelItem(item: QuickAccessItem): boolean {
+/** Command item type - local to command menu, not part of quickAccess */
+type CommandItem = {
+ id: string;
+ kind: 'command';
+ bucket: 'command';
+ searchText: string;
+ sortTimestamp: number;
+ timestamps: Record<string, never>;
+ data: HotkeyCommand;
+};
+
+/** Combined item type for command menu (quickAccess items + commands) */
+type CommandMenuItem = QuickAccessItem | CommandItem;
+
+function isCommandItem(item: CommandMenuItem): item is CommandItem {
+ return item.kind === 'command';
+}
+
+function isEntityItem(item: CommandMenuItem): item is EntityItem {
+ return item.kind === 'entity';
+}
+
+function isUserItem(item: CommandMenuItem): item is UserItem {
+ return item.kind === 'user';
+}
+
+function isChannelItem(item: CommandMenuItem): boolean {
// only dms get the "channel boost" in command menu
return item.bucket === 'dm';
}
@@ -117,13 +142,13 @@ function useCommandsList(): () => CommandItem[] {
*/
function useQuickAccessBuckets(): Record<
CategoryFilter,
- () => QuickAccessItem[]
+ () => CommandMenuItem[]
> {
const quickAccess = useQuickAccess();
const commandsList = useCommandsList();
const entitiesList = quickAccess.useList(...exclude('person'));
- const allWithCommands = createMemo(() => {
+ const allWithCommands = createMemo((): CommandMenuItem[] => {
const entities = entitiesList();
const commands = commandsList();
return [...entities, ...commands];
@@ -163,7 +188,7 @@ export function useCommandItems(
const search = createMemo(() => {
const q = query();
const hasQuery = q.trim().length > 0;
- return createFreshSearch<QuickAccessItem>(
+ return createFreshSearch<CommandMenuItem>(
createSearchConfig(hasQuery),
(item) => item.searchText,
isChannelItem,
@@ -186,4 +211,4 @@ export function useCommandItems(
}
export { isEntityItem, isUserItem, isCommandItem };
-export type { QuickAccessItem, Bucket };
+export type { QuickAccessItem, CommandMenuItem, CommandItem, Bucket };
diff --git a/js/app/packages/app/component/property-edit-modal/hooks/useEntitiesForProperty.ts b/js/app/packages/app/component/property-edit-modal/hooks/useEntitiesForProperty.ts
index 6f25080c18..ec33ab756d 100644
--- a/js/app/packages/app/component/property-edit-modal/hooks/useEntitiesForProperty.ts
+++ b/js/app/packages/app/component/property-edit-modal/hooks/useEntitiesForProperty.ts
@@ -1,21 +1,22 @@
-import { useChannelsContext } from '@core/context/channels';
import {
type CombinedEntity,
createEntitySearchConfig,
- entityMapper,
+ useQuickAccessEntities,
getEntitySearchText,
getEntityTimestampedItem,
+ getEntityType,
isChannelEntity,
threadMapper,
+ quickAccessItemToEntity,
+ userToEntity,
} from '@core/component/Properties/component/modal/shared/entityUtils';
-import { useAugmentUserWithDmActivity, useContacts } from '@core/user';
+import { useAugmentUserWithDmActivity } from '@core/user';
import { createFreshSearch } from '@core/util/freshSort';
import { useEmail } from '@core/context/user';
import { createEmailsInfiniteQuery } from '@macro-entity';
import type { EmailEntity } from '@entity';
import { useSearchSoupQuery } from '@queries/soup/search';
-import type { EntityType } from '@service-properties/generated/schemas/entityType';
-import { useHistoryQuery } from '@queries/history/history';
+
import { debounce } from '@solid-primitives/scheduled';
import {
createEffect,
@@ -41,15 +42,21 @@ export function useEntitiesForProperty(
);
createEffect(() => debouncedSetSearchTerm(searchQuery()));
- // Data sources
- const contacts = useContacts();
- const channelsContext = useChannelsContext();
- const channels = channelsContext.channels;
- const historyQuery = useHistoryQuery();
- const history = () => historyQuery.data ?? [];
+ const augmentUserWithDmActivity = useAugmentUserWithDmActivity();
+
+ // Get current user domain for same-domain boost in search
+ const currentUserEmail = useEmail();
+ const currentUserDomain = createMemo(() => {
+ const email = currentUserEmail();
+ return email ? email.split('@')[1] : undefined;
+ });
const specificEntityType = () => property()?.specificEntityType;
+ // Get items from quickAccess based on entity type
+ const { items: quickAccessItems } =
+ useQuickAccessEntities(specificEntityType);
+
// Email queries for THREAD type or generic ENTITY (no specific type)
const needsEmailSearch = () =>
specificEntityType() === 'THREAD' || !specificEntityType();
@@ -85,64 +92,49 @@ export function useEntitiesForProperty(
.map((entity) => threadMapper(entity as EmailEntity));
});
- // Helper to augment user entities with DM activity timestamps (same as MentionsMenu)
- const augmentUserWithDmActivity = useAugmentUserWithDmActivity();
- const augmentUsersWithDmActivity = (): CombinedEntity[] => {
- return contacts().map((user) =>
- entityMapper('user')(augmentUserWithDmActivity(user))
- );
- };
-
- // Get entities based on specific entity type
+ // Convert quickAccess items to CombinedEntity format
const entities = createMemo((): CombinedEntity[] => {
const entityType = specificEntityType();
- // Generic entity - include all types
- if (!entityType) {
- return [
- ...augmentUsersWithDmActivity(),
- ...history().map(entityMapper('item')),
- ...channels().map(entityMapper('channel')),
- ...emails().map(threadMapper),
- ];
- }
-
- if (entityType === 'USER') {
- return augmentUsersWithDmActivity();
- }
-
- if (entityType === 'CHANNEL') {
- return channels().map(entityMapper('channel'));
- }
-
+ // For THREAD type, use email data (not in quickAccess yet)
if (entityType === 'THREAD') {
return emails().map(threadMapper);
}
- // Item-based types: DOCUMENT, PROJECT, CHAT
- const itemTypes: EntityType[] = ['DOCUMENT', 'PROJECT', 'CHAT'];
- if (itemTypes.includes(entityType)) {
- return history()
- .filter((item) => item.type.toUpperCase() === entityType)
- .map(entityMapper('item'));
+ // For COMPANY type, return empty (not in quickAccess)
+ if (entityType === 'COMPANY') {
+ return [];
}
- if (entityType === 'TASK') {
- return history()
- .filter(
- (item) => item.type === 'document' && item.subType?.type === 'task'
- )
- .map(entityMapper('item'));
+ // Convert quickAccess items to CombinedEntity
+ const items = quickAccessItems();
+ const converted: CombinedEntity[] = [];
+
+ for (const item of items) {
+ // Augment users with DM activity
+ if (item.kind === 'user') {
+ const augmentedUser = augmentUserWithDmActivity(item.data);
+ converted.push(userToEntity(augmentedUser));
+ } else {
+ const entity = quickAccessItemToEntity(item);
+ // Filter by specific entity type if needed
+ if (entityType) {
+ const type = getEntityType(entity);
+ if (type === entityType) {
+ converted.push(entity);
+ }
+ } else {
+ converted.push(entity);
+ }
+ }
}
- // COMPANY not yet implemented
- return [];
- });
+ // For generic entity type, also include emails
+ if (!entityType) {
+ converted.push(...emails().map(threadMapper));
+ }
- const currentUserEmail = useEmail();
- const currentUserDomain = createMemo(() => {
- const email = currentUserEmail();
- return email ? email.split('@')[1] : undefined;
+ return converted;
});
// search function for fuzzy matching
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx
index f4dad49670..d298181560 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx
@@ -61,9 +61,6 @@ export function MentionsMenuItem(props: {
size="xs"
/>
);
-
- case 'command':
- return null;
}
};
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/entityUtils.ts b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/entityUtils.ts
index ec4aaa3bbc..0d6bf9071a 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/entityUtils.ts
+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/entityUtils.ts
@@ -43,7 +43,5 @@ export function getMentionItemName(item: MentionItem): string {
return item.data.displayText;
case 'entity':
return item.data.name ?? (item.bucket === 'email' ? 'No Subject' : '');
- case 'command':
- return item.searchText ?? '';
}
}
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/mentionHandlers.ts b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/mentionHandlers.ts
index 8677f1fa9e..115c7af167 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/mentionHandlers.ts
+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/mentionHandlers.ts
@@ -114,8 +114,6 @@ export function createItemHandler(dependencies: HandlerDependencies) {
return await handleGroupMentionItem(item.data, dependencies);
case 'entity':
return await handleEntityMention(item, dependencies);
- case 'command':
- return;
}
};
}
diff --git a/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsx b/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsx
index 421743ecd5..21f37061ee 100644
--- a/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsx
+++ b/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsx
@@ -1,49 +1,40 @@
-import { useChannelsContext } from '@core/context/channels';
-import { EntityIcon, getEntityIconType } from '@core/component/EntityIcon';
+import { Entity, type EntityData } from '@entity';
import { UserIcon } from '@core/component/UserIcon';
-import { EntityDataTypeIcon } from '../../../utils/PropertyDataTypeIcon';
-import type { IUser } from '@core/user';
-import {
- idToEmail,
- tryMacroId,
- useAugmentUserWithDmActivity,
- useContacts,
- useDisplayName,
-} from '@core/user';
+import { useAugmentUserWithDmActivity } from '@core/user';
import { createFreshSearch } from '@core/util/freshSort';
import SearchIcon from '@icon/regular/magnifying-glass.svg';
import { createEmailsInfiniteQuery } from '@macro-entity';
import type { EmailEntity } from '@entity';
import { useSearchSoupQuery } from '@queries/soup/search';
-import { useEmail, useUserId } from '@core/context/user';
-import type { EntityType } from '@service-properties/generated/schemas/entityType';
-import { useHistoryQuery } from '@queries/history/history';
+import { useEmail } from '@core/context/user';
import { debounce } from '@solid-primitives/scheduled';
import {
createEffect,
createMemo,
createSignal,
- For,
on,
onCleanup,
onMount,
Show,
} from 'solid-js';
+import { type VirtualizerHandle, VList } from 'virtua/solid';
import { useSearchInputFocus } from '../../../utils';
import {
type CombinedEntity,
createEntitySearchConfig,
- entityMapper,
- getEntityName,
+ useQuickAccessEntities,
getEntitySearchText,
getEntityTimestampedItem,
getEntityType,
isChannelEntity,
threadMapper,
+ quickAccessItemToEntity,
+ userToEntity,
} from './entityUtils';
import { OptionCheckBox } from './OptionCheckBox';
import { useKeyPressed } from '@core/util/useKeyPressed';
import type { EntitySelectorConfig } from './types';
+import type { EntityType } from '@service-properties/generated/schemas/entityType';
type EntityInputProps = {
config: EntitySelectorConfig;
@@ -81,48 +72,30 @@ function getEntityTypePluralLabel(
}
}
-function getEntityIcon(entity: CombinedEntity) {
- switch (entity.kind) {
- case 'user':
- return (
- <UserIcon
- id={entity.data.id}
- size="xs"
- isDeleted={false}
- suppressClick={true}
- />
- );
- case 'channel':
- return (
- <EntityIcon
- targetType={entity.data.channel_type || 'channel'}
- size="xs"
- class="text-ink-muted"
- />
- );
- case 'item':
- return (
- <EntityIcon
- targetType={getEntityIconType(entity.data)}
- size="xs"
- class="text-ink-muted"
- />
- );
- case 'company':
- return (
- <EntityDataTypeIcon property={{ specificEntityType: 'COMPANY' }} />
- );
- case 'thread':
- return <EntityIcon targetType="email" size="xs" class="text-ink-muted" />;
+/** Gets display name for a CombinedEntity */
+function getEntityName(entity: CombinedEntity): string {
+ if (entity.kind === 'user') {
+ const { name, email } = entity.data;
+ if (name === email) return email;
+ return name;
}
+ const data = entity.data;
+ if (data.type === 'email') {
+ return data.name ?? 'No Subject';
+ }
+ return data.name ?? '';
}
+const ITEM_SIZE = 32;
+
export function PropertyEntitySelector(props: EntityInputProps) {
const [inputValue, setInputValue] = createSignal('');
const [searchTerm, setSearchTerm] = createSignal('');
const [selectedIndex, setSelectedIndex] = createSignal(0);
const keyboardMode = useKeyPressed(100);
+ let virtualizerHandle: VirtualizerHandle | undefined;
+
// Debounce search term updates (60ms like MentionsMenu)
const debouncedSetSearchTerm = debounce(
(term: string) => setSearchTerm(term.toLowerCase()),
@@ -136,41 +109,20 @@ export function PropertyEntitySelector(props: EntityInputProps) {
const selfFilterEntityType = () => props.config.selfFilter?.entityType;
const selfFilterBlockId = () => props.config.selfFilter?.blockId;
- const historyQuery = useHistoryQuery();
- const contacts = useContacts();
- const channelsContext = useChannelsContext();
- const channels = channelsContext.channels;
-
- // Get current user info for injection into contacts
- const currentUserId = useUserId();
- const [currentUserDisplayName] = useDisplayName(
- tryMacroId(currentUserId() ?? '')
- );
+ const augmentUserWithDmActivity = useAugmentUserWithDmActivity();
- // Contacts with current user injected at the beginning
- const contactsWithCurrentUser = createMemo((): IUser[] => {
- const userId = currentUserId();
- if (!userId) return contacts();
-
- const existingContacts = contacts();
-
- // Check if current user is already in contacts
- const isCurrentUserInContacts = existingContacts.some(
- (contact) => contact.id === userId
- );
- if (isCurrentUserInContacts) return existingContacts;
-
- // Inject current user at the beginning
- const currentUser: IUser = {
- id: userId,
- email: idToEmail(userId),
- name: currentUserDisplayName(),
- };
- return [currentUser, ...existingContacts];
+ // Get current user domain for same-domain boost in search
+ const currentUserEmail = useEmail();
+ const currentUserDomain = createMemo(() => {
+ const email = currentUserEmail();
+ return email ? email.split('@')[1] : undefined;
});
- // Fetch emails for browsing (only when THREAD type)
- // Email queries for THREAD type or generic ENTITY (no specific type)
+ // Get items from quickAccess based on entity type
+ const { items: quickAccessItems, isLoading: isQuickAccessLoading } =
+ useQuickAccessEntities(() => props.config.specificEntityType);
+
+ // Fetch emails for browsing (only when THREAD type or generic ENTITY)
const needsEmailSearch = () =>
props.config.specificEntityType === 'THREAD' ||
!props.config.specificEntityType;
@@ -208,90 +160,58 @@ export function PropertyEntitySelector(props: EntityInputProps) {
const isLoadingEntities = createMemo(() => {
if (needsEmailSearch()) {
- // Loading if initial emails query is loading OR search is fetching
return (
emailsQuery.isLoading ||
emailsQuery.isPending ||
emailSearchQuery.isFetching
);
}
- return false;
+ return isQuickAccessLoading();
});
- // Helper to augment user entities with DM activity timestamps (same as MentionsMenu)
- const augmentUserWithDmActivity = useAugmentUserWithDmActivity();
- const augmentUsersWithDmActivity = (users: IUser[]): CombinedEntity[] => {
- return users.map((user) =>
- entityMapper('user')(augmentUserWithDmActivity(user))
- );
- };
-
- // Local entities (always available, used for instant results)
- const entities = createMemo(() => {
+ // Convert quickAccess items to CombinedEntity format
+ const entities = createMemo((): CombinedEntity[] => {
const specificEntityType = props.config.specificEntityType;
- if (!specificEntityType) {
- return [
- ...augmentUsersWithDmActivity(contactsWithCurrentUser()),
- ...(historyQuery.data ?? []).map(entityMapper('item')),
- ...channels().map(entityMapper('channel')),
- ...emails().map(threadMapper),
- ];
- }
-
- if (specificEntityType === 'USER') {
- return augmentUsersWithDmActivity(contactsWithCurrentUser());
- }
-
- if (specificEntityType === 'CHANNEL') {
- return channels().map(entityMapper('channel'));
+ // For THREAD type, use email data (not in quickAccess yet)
+ if (specificEntityType === 'THREAD') {
+ return emails().map(threadMapper);
}
+ // For COMPANY type, return empty (not in quickAccess)
if (specificEntityType === 'COMPANY') {
- // TODO: Implement company data source
return [];
}
- if (specificEntityType === 'THREAD') {
- return emails().map(threadMapper);
- }
+ // Convert quickAccess items to CombinedEntity
+ const items = quickAccessItems();
+ const converted: CombinedEntity[] = [];
- if (specificEntityType === 'TASK') {
- return (historyQuery.data ?? [])
- .filter(
- (item) =>
- item.type === 'document' &&
- item.subType !== null &&
- item.subType !== undefined &&
- item.subType.type === 'task'
- )
- .map(entityMapper('item'));
+ for (const item of items) {
+ // Augment users with DM activity
+ if (item.kind === 'user') {
+ const augmentedUser = augmentUserWithDmActivity(item.data);
+ converted.push(userToEntity(augmentedUser));
+ } else {
+ const entity = quickAccessItemToEntity(item);
+ // Filter by specific entity type if needed
+ if (specificEntityType) {
+ const entityType = getEntityType(entity);
+ if (entityType === specificEntityType) {
+ converted.push(entity);
+ }
+ } else {
+ converted.push(entity);
+ }
+ }
}
- const itemTypes: EntityType[] = ['DOCUMENT', 'PROJECT', 'CHAT'];
- if (itemTypes.includes(specificEntityType)) {
- return (historyQuery.data ?? [])
- .filter(
- (item) =>
- item.type.toUpperCase() === specificEntityType &&
- !(
- item.type === 'document' &&
- item.subType !== null &&
- item.subType !== undefined &&
- item.subType.type === 'task'
- )
- )
- .map(entityMapper('item'));
+ // For generic entity type, also include emails
+ if (!specificEntityType) {
+ converted.push(...emails().map(threadMapper));
}
- return [];
- });
-
- // Get current user domain for same-domain boost
- const currentUserEmail = useEmail();
- const currentUserDomain = createMemo(() => {
- const email = currentUserEmail();
- return email ? email.split('@')[1] : undefined;
+ return converted;
});
const entitySearch = createFreshSearch<CombinedEntity>(
@@ -302,13 +222,13 @@ export function PropertyEntitySelector(props: EntityInputProps) {
);
const filteredEntities = createMemo(() => {
- const term = searchTerm(); // Already lowercase from debounce
+ const term = searchTerm();
const allEntities = entities();
const MAX_VISIBLE_ENTITIES_NO_SEARCH = 50;
const MAX_SEARCH_RESULTS = 20;
- // Filter out the current entity when selecting same entity type (e.g., parent task on a task)
+ // Filter out the current entity when selecting same entity type
const blockId = selfFilterBlockId();
const currentEntityType = selfFilterEntityType();
const excludeFilter = blockId
@@ -326,7 +246,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {
.filter(excludeFilter)
.slice(0, MAX_VISIBLE_ENTITIES_NO_SEARCH);
- // For THREAD or generic entity: merge local + server results (local first, server appended, deduped)
+ // For THREAD or generic entity: merge local + server results
if (needsEmailSearch() && term) {
const localIds = new Set(localResults.map((e) => e.id));
const serverResults = serverEmails()
@@ -338,11 +258,10 @@ export function PropertyEntitySelector(props: EntityInputProps) {
return localResults;
});
- // Track searchTerm and filteredEntities, but NOT selectedOptions
- // This keeps list order stable during selection while still reacting to data changes
+ // Sort entities with selected items first when not searching
const sortedEntities = createMemo(
on([searchTerm, filteredEntities], () => {
- const term = searchTerm(); // Already lowercase from debounce
+ const term = searchTerm();
const filteredResults = filteredEntities();
// When there's a search term, return results as-is
@@ -366,7 +285,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {
}
}
- // Add missing selected entities that aren't in the visible results (handles pagination)
+ // Add missing selected entities that aren't in the visible results
const allAvailableEntities = entities();
for (const selectedId of selectedIds) {
if (!entityIdsInResults.has(selectedId)) {
@@ -415,44 +334,37 @@ export function PropertyEntitySelector(props: EntityInputProps) {
// Reset selected index when sortedEntities change
createEffect(() => {
- const entities = sortedEntities();
- if (entities.length === 0) {
+ const entitiesList = sortedEntities();
+ if (entitiesList.length === 0) {
setSelectedIndex(0);
} else {
- setSelectedIndex(Math.min(selectedIndex(), entities.length - 1));
+ setSelectedIndex(Math.min(selectedIndex(), entitiesList.length - 1));
}
});
- const scrollSelectedIntoView = () => {
- const entities = sortedEntities();
- const currentIndex = selectedIndex();
- if (currentIndex >= 0 && currentIndex < entities.length) {
- const element = document.querySelector(
- `[data-entity-index="${currentIndex}"]`
- );
- if (element) {
- element.scrollIntoView({ block: 'nearest' });
- }
+ // Scroll to selected index when it changes
+ createEffect(() => {
+ const index = selectedIndex();
+ if (index >= 0 && virtualizerHandle) {
+ virtualizerHandle.scrollToIndex(index, { align: 'nearest' });
}
- };
+ });
const handleKeyDown = (e: KeyboardEvent) => {
- const entities = sortedEntities();
- if (entities.length === 0) return;
+ const entitiesList = sortedEntities();
+ if (entitiesList.length === 0) return;
if (e.key === 'ArrowDown' || (e.ctrlKey && e.key === 'j')) {
e.preventDefault();
- setSelectedIndex((prev) => (prev + 1) % entities.length);
- scrollSelectedIntoView();
+ setSelectedIndex((prev) => (prev + 1) % entitiesList.length);
} else if (e.key === 'ArrowUp' || (e.ctrlKey && e.key === 'k')) {
e.preventDefault();
setSelectedIndex(
- (prev) => (prev - 1 + entities.length) % entities.length
+ (prev) => (prev - 1 + entitiesList.length) % entitiesList.length
);
- scrollSelectedIntoView();
} else if (e.key === 'Enter') {
e.preventDefault();
- const selectedEntity = entities[selectedIndex()];
+ const selectedEntity = entitiesList[selectedIndex()];
if (selectedEntity) {
toggleEntity(selectedEntity);
}
@@ -496,45 +408,71 @@ export function PropertyEntitySelector(props: EntityInputProps) {
<Show when={sortedEntities().length > 0}>
<div class="p-1">
- <div class="max-h-48 overflow-y-auto overflow-x-hidden scrollbar-hidden">
- <For each={sortedEntities()}>
- {(entity, index) => {
- const isSelected = () => props.selectedOptions().has(entity.id);
- const isKeyboardSelected = () => index() === selectedIndex();
-
- return (
- <div
- data-entity-index={index()}
- class="flex items-center justify-between gap-2 py-1.5 px-2 min-w-0 h-8"
- classList={{
- 'bg-hover': isKeyboardSelected(),
- 'bg-accent/10': isSelected(),
- }}
- onClick={() => toggleEntity(entity)}
- onKeyDown={(e) => e.key === 'Enter' && toggleEntity(entity)}
- onMouseEnter={() => {
- if (!keyboardMode()) {
- setSelectedIndex(index());
- }
- }}
- >
- <div class="flex items-center gap-2 flex-1 min-w-0">
- <div class="flex-shrink-0">{getEntityIcon(entity)}</div>
- <span class="truncate min-w-0">
- {getEntityName(entity)}
- </span>
- </div>
- <div class="flex-shrink-0">
- <OptionCheckBox
- checked={isSelected()}
- multiselect={props.config.isMultiSelect}
- />
+ <VList
+ ref={(handle) => {
+ virtualizerHandle = handle;
+ }}
+ data={sortedEntities()}
+ itemSize={ITEM_SIZE}
+ bufferSize={5 * ITEM_SIZE}
+ style={{ height: '192px', contain: 'content' }}
+ class="overflow-y-auto overflow-x-hidden scrollbar-hidden"
+ >
+ {(entity, index) => {
+ const isSelected = () => props.selectedOptions().has(entity.id);
+ const isKeyboardSelected = () => index() === selectedIndex();
+
+ return (
+ <div
+ data-entity-index={index()}
+ class="flex items-center justify-between gap-2 py-1.5 px-2 min-w-0 h-8"
+ classList={{
+ 'bg-hover': isKeyboardSelected(),
+ 'bg-accent/10': isSelected(),
+ }}
+ onClick={() => toggleEntity(entity)}
+ onKeyDown={(e) => e.key === 'Enter' && toggleEntity(entity)}
+ onMouseEnter={() => {
+ if (!keyboardMode()) {
+ setSelectedIndex(index());
+ }
+ }}
+ >
+ <div class="flex items-center gap-2 flex-1 min-w-0">
+ <div class="size-4 flex-shrink-0">
+ <Show
+ when={entity.kind === 'entity'}
+ fallback={
+ <UserIcon
+ id={entity.id}
+ size="xs"
+ isDeleted={false}
+ suppressClick={true}
+ />
+ }
+ >
+ <Entity.Icon entity={entity.data as EntityData} />
+ </Show>
</div>
+ <span class="truncate min-w-0">
+ <Show
+ when={entity.kind === 'entity'}
+ fallback={getEntityName(entity)}
+ >
+ <Entity.Title entity={entity.data as EntityData} />
+ </Show>
+ </span>
+ </div>
+ <div class="flex-shrink-0">
+ <OptionCheckBox
+ checked={isSelected()}
+ multiselect={props.config.isMultiSelect}
+ />
</div>
- );
- }}
- </For>
- </div>
+ </div>
+ );
+ }}
+ </VList>
</div>
</Show>
diff --git a/js/app/packages/core/component/Properties/component/modal/shared/entityUtils.test.ts b/js/app/packages/core/component/Properties/component/modal/shared/entityUtils.test.ts
index 487b433600..f8a6872054 100644
--- a/js/app/packages/core/component/Properties/component/modal/shared/entityUtils.test.ts
+++ b/js/app/packages/core/component/Properties/component/modal/shared/entityUtils.test.ts
@@ -1,5 +1,23 @@
-import { describe, expect, it } from 'vitest';
+import { describe, expect, it, vi } from 'vitest';
import { createSignal } from 'solid-js';
+
+// Mock @core/context/quickAccess to break the import chain that pulls in
+// LexicalMarkdown plugins -> themeSignals -> window.matchMedia
+vi.mock('@core/context/quickAccess', () => ({
+ useQuickAccess: () => ({
+ useList: () => () => [],
+ isLoading: () => false,
+ refresh: () => {},
+ getById: () => undefined,
+ }),
+ ALL_BUCKETS: [],
+ isEntityItem: () => false,
+ isUserItem: () => false,
+ isEntityOfType: () => false,
+ isFromBucket: () => false,
+ exclude: () => () => true,
+}));
+
import { createEntitySearchConfig } from './entityUtils';
import type { CombinedEntity } from './entityUtils';
import type { IUser } from '@core/user';
@@ -56,12 +74,15 @@ describe('createEntitySearchConfig', () => {
const config = createEntitySearchConfig(domain);
const channelEntity: CombinedEntity = {
- kind: 'channel',
+ kind: 'entity',
id: 'channel-1',
data: {
+ type: 'channel',
id: 'channel-1',
name: 'Test Channel',
- } as any,
+ ownerId: 'owner-1',
+ channelType: 'public',
+ },
};
const boost = config.boostFn!(channelEntity);
diff --git a/js/app/packages/core/component/Properties/component/modal/shared/entityUtils.ts b/js/app/packages/core/component/Properties/component/modal/shared/entityUtils.ts
index 30716981f8..125f9a41b7 100644
--- a/js/app/packages/core/component/Properties/component/modal/shared/entityUtils.ts
+++ b/js/app/packages/core/component/Properties/component/modal/shared/entityUtils.ts
@@ -1,115 +1,166 @@
-import type { ChannelWithParticipants, IUser } from '@core/user';
-import type { EmailEntity } from '@entity';
+import type { IUser } from '@core/user';
+import type { EntityData, EmailEntity } from '@entity';
import type { EntityType } from '@service-properties/generated/schemas/entityType';
import type { Accessor } from 'solid-js';
import type { FreshSortConfig, TimestampedItem } from '@core/util/freshSort';
-import type { HistoryItem as Item } from '@queries/history/history';
+import {
+ useQuickAccess,
+ type QuickAccessItem,
+ type Bucket,
+} from '@core/context/quickAccess';
+
+/**
+ * Maps EntityType to quickAccess buckets
+ */
+export function entityTypeToBuckets(
+ entityType: EntityType | null | undefined
+): Bucket[] | null {
+ if (!entityType) return null; // null means "all"
+ switch (entityType) {
+ case 'USER':
+ return ['person'];
+ case 'CHANNEL':
+ return ['channel', 'dm'];
+ case 'DOCUMENT':
+ return ['document', 'note'];
+ case 'PROJECT':
+ return ['project'];
+ case 'CHAT':
+ return ['chat'];
+ case 'TASK':
+ return ['task'];
+ case 'THREAD':
+ return ['email']; // Note: emails aren't in quickAccess yet, handled separately
+ case 'COMPANY':
+ return []; // Companies aren't in quickAccess
+ default:
+ return null;
+ }
+}
+
+/**
+ * Hook to get QuickAccessItems for a given EntityType.
+ * Returns items from the appropriate buckets based on entity type.
+ */
+export function useQuickAccessEntities(
+ entityType: Accessor<EntityType | null | undefined>
+): { items: Accessor<QuickAccessItem[]>; isLoading: Accessor<boolean> } {
+ const quickAccess = useQuickAccess();
+
+ const buckets = () => entityTypeToBuckets(entityType());
+ const items = (): QuickAccessItem[] => {
+ const b = buckets();
+ if (b === null) {
+ return quickAccess.useList()();
+ }
+ if (b.length === 0) {
+ return [];
+ }
+ return quickAccess.useList(...b)();
+ };
+ return { items, isLoading: quickAccess.isLoading };
+}
/** Combined entity type for unified handling across entity selectors */
export type CombinedEntity =
- | { kind: 'item'; id: string; data: Item }
- | { kind: 'user'; id: string; data: IUser }
- | { kind: 'channel'; id: string; data: ChannelWithParticipants }
- | { kind: 'company'; id: string; data: null }
- | { kind: 'thread'; id: string; data: EmailEntity };
-
-/** Creates a mapper function for a specific entity kind */
-export function entityMapper(kind: 'item' | 'user' | 'channel') {
- return (data: Item | IUser | ChannelWithParticipants): CombinedEntity => {
- return { kind, data, id: data.id } as CombinedEntity;
- };
+ | { kind: 'entity'; id: string; data: EntityData }
+ | { kind: 'user'; id: string; data: IUser };
+
+/** Converts a QuickAccessItem to CombinedEntity */
+export function quickAccessItemToEntity(item: QuickAccessItem): CombinedEntity {
+ if (item.kind === 'user') {
+ return { kind: 'user', id: item.id, data: item.data };
+ }
+ return { kind: 'entity', id: item.id, data: item.data };
+}
+
+/** Maps an EntityData to a CombinedEntity */
+export function entityDataToEntity(data: EntityData): CombinedEntity {
+ return { kind: 'entity', id: data.id, data };
+}
+
+/** Maps an IUser to a CombinedEntity */
+export function userToEntity(user: IUser): CombinedEntity {
+ return { kind: 'user', id: user.id, data: user };
}
-/** Maps an email entity to a CombinedEntity */
+/** Maps an email entity to a CombinedEntity (alias for entityDataToEntity) */
export function threadMapper(email: EmailEntity): CombinedEntity {
- return { kind: 'thread', id: email.id, data: email };
+ return entityDataToEntity(email);
}
/** Gets the display name for an entity */
export function getEntityName(entity: CombinedEntity): string {
- switch (entity.kind) {
- case 'item':
- return entity.data.name;
- case 'user': {
- const { name, email } = entity.data;
- if (name === email) return email;
- return name;
- }
- case 'channel':
- return entity.data.name ?? '';
- case 'company':
- return entity.id;
- case 'thread':
- return entity.data.name ?? 'No Subject';
+ if (entity.kind === 'user') {
+ const { name, email } = entity.data;
+ if (name === email) return email;
+ return name;
}
+
+ const data = entity.data;
+ if (data.type === 'email') {
+ return data.name ?? 'No Subject';
+ }
+ return data.name ?? '';
}
/** Gets searchable text for an entity (used with createFreshSearch) */
export function getEntitySearchText(entity: CombinedEntity): string {
- switch (entity.kind) {
- case 'item':
- return entity.data.name;
- case 'user': {
- const { name, email } = entity.data;
- if (name === email) return `${email} | ${email}`;
- return `${name} | ${email}`;
- }
- case 'channel':
- return entity.data.name ?? '';
- case 'company':
- return entity.id;
- case 'thread':
- return entity.data.name ?? '';
+ if (entity.kind === 'user') {
+ const { name, email } = entity.data;
+ if (name === email) return `${email} | ${email}`;
+ return `${name} | ${email}`;
}
+
+ return entity.data.name ?? '';
}
/** Gets the EntityType string for an entity */
export function getEntityType(entity: CombinedEntity): EntityType {
- switch (entity.kind) {
- case 'user':
- return 'USER';
+ if (entity.kind === 'user') {
+ return 'USER';
+ }
+
+ const data = entity.data;
+ switch (data.type) {
case 'channel':
return 'CHANNEL';
- case 'item':
- if (
- entity.data.type === 'document' &&
- entity.data.subType?.type === 'task'
- ) {
+ case 'document':
+ if (data.subType?.type === 'task') {
return 'TASK';
}
- return entity.data.type.toUpperCase() as EntityType;
- case 'company':
- return 'COMPANY';
- case 'thread':
+ return 'DOCUMENT';
+ case 'chat':
+ return 'CHAT';
+ case 'project':
+ return 'PROJECT';
+ case 'email':
return 'THREAD';
+ default:
+ return (data as EntityData).type.toUpperCase() as EntityType;
}
}
/** Check if entity is a channel */
export function isChannelEntity(item: CombinedEntity): boolean {
- return item.kind === 'channel';
+ return item.kind === 'entity' && item.data.type === 'channel';
}
/** Get timestamped item from combined entity */
export function getEntityTimestampedItem<T extends CombinedEntity>(
item: T
): TimestampedItem {
- switch (item.kind) {
- case 'item':
- return {
- updatedAt: item.data.updatedAt,
- };
- case 'channel':
- return {
- updatedAt: item.data.updated_at,
- };
- case 'user':
- return {
- lastInteraction: item.data.lastInteraction,
- };
- default:
- return {};
+ if (item.kind === 'user') {
+ return {
+ lastInteraction: item.data.lastInteraction,
+ };
}
+
+ const data = item.data;
+ return {
+ updatedAt: data.updatedAt,
+ viewedAt: data.viewedAt,
+ };
}
/**
@@ -123,7 +174,7 @@ export function createEntitySearchConfig<T extends CombinedEntity>(
const userDomain = currentUserDomain();
if (!userDomain) return 0;
- // Check if this looks like a CombinedEntity with user data
+ // Check if this is a user entity with email
if (item.kind === 'user' && item.data.email) {
const email = item.data.email;
const itemDomain = email.split('@')[1];
diff --git a/js/app/packages/core/component/Properties/component/modal/shared/index.ts b/js/app/packages/core/component/Properties/component/modal/shared/index.ts
index 2367c0d1df..52ad23d8e8 100644
--- a/js/app/packages/core/component/Properties/component/modal/shared/index.ts
+++ b/js/app/packages/core/component/Properties/component/modal/shared/index.ts
@@ -3,11 +3,15 @@ export { Dropdown } from './Dropdown';
export {
type CombinedEntity,
createEntitySearchConfig,
- entityMapper,
+ entityTypeToBuckets,
+ useQuickAccessEntities,
getEntityName,
getEntitySearchText,
getEntityType,
threadMapper,
+ quickAccessItemToEntity,
+ entityDataToEntity,
+ userToEntity,
} from './entityUtils';
export { PropertyEntitySelector } from './PropertyEntitySelector';
export { PropertyOptionSelector } from './PropertyOptionSelector';
diff --git a/js/app/packages/core/context/quickAccess/index.ts b/js/app/packages/core/context/quickAccess/index.ts
index b5fa36f2cd..6e11ddeeae 100644
--- a/js/app/packages/core/context/quickAccess/index.ts
+++ b/js/app/packages/core/context/quickAccess/index.ts
@@ -5,7 +5,6 @@ export type {
QuickAccessItem,
EntityItem,
UserItem,
- CommandItem,
SearchOptions,
SearchResult,
SearchWeights,
@@ -19,7 +18,6 @@ export {
ALL_BUCKETS,
isEntityItem,
isUserItem,
- isCommandItem,
isEntityOfType,
isFromBucket,
exclude,
diff --git a/js/app/packages/core/context/quickAccess/types.ts b/js/app/packages/core/context/quickAccess/types.ts
index c60e890265..ac0aae646d 100644
--- a/js/app/packages/core/context/quickAccess/types.ts
+++ b/js/app/packages/core/context/quickAccess/types.ts
@@ -8,7 +8,6 @@ import type {
EmailEntity,
ProjectEntity,
} from '@entity';
-import type { HotkeyCommand } from '@core/hotkey/types';
import type { IUser } from '@core/user/types';
import type { DateValue } from '@core/util/date';
@@ -25,10 +24,9 @@ export type Bucket =
| 'note'
| 'chat'
| 'project'
- | 'email'
- | 'command';
+ | 'email';
-export type EntityBucket = Exclude<Bucket, 'person' | 'command'>;
+export type EntityBucket = Exclude<Bucket, 'person'>;
export const ALL_BUCKETS: Bucket[] = [
'channel',
@@ -40,7 +38,6 @@ export const ALL_BUCKETS: Bucket[] = [
'chat',
'project',
'email',
- 'command',
];
export type BucketCombination = 'all' | 'channels' | 'documents';
@@ -78,13 +75,7 @@ export type UserItem = QuickAccessBase & {
data: IUser;
};
-export type CommandItem = QuickAccessBase & {
- kind: 'command';
- bucket: 'command';
- data: HotkeyCommand;
-};
-
-export type QuickAccessItem = EntityItem | UserItem | CommandItem;
+export type QuickAccessItem = EntityItem | UserItem;
export function isEntityItem(item: QuickAccessItem): item is EntityItem {
return item.kind === 'entity';
@@ -94,10 +85,6 @@ export function isUserItem(item: QuickAccessItem): item is UserItem {
return item.kind === 'user';
}
-export function isCommandItem(item: QuickAccessItem): item is CommandItem {
- return item.kind === 'command';
-}
-
export function isEntityOfType<T extends EntityData['type']>(
item: QuickAccessItem,
entityType: T
@@ -138,7 +125,6 @@ export type BucketItemMap = {
project: EntityItem<ProjectEntity>;
email: EntityItem<EmailEntity>;
person: UserItem;
- command: CommandItem;
};
export type ItemForBucket<B extends Bucket> = BucketItemMap[B];