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
feat(properties): soup property editor modal (v0 - tasks only) (#1140)
Seamus561fe5278477
diff --git a/js/app/packages/app/component/Layout.tsx b/js/app/packages/app/component/Layout.tsxindex 0f8bcdbefe..40d64f21c2 100644--- a/js/app/packages/app/component/Layout.tsx+++ b/js/app/packages/app/component/Layout.tsx@@ -13,6 +13,7 @@ import { updateCookie } from '@core/util/cookies';import Banner from './banner/Banner';import { GlobalBulkEditEntityModal } from './bulk-edit-entity/BulkEditEntityModal';import { KommandMenu } from './command/Konsole';+import { PropertyEditorModal } from './property-edit-modal/PropertyEditorModal';import GlobalShortcuts from './GlobalHotkeys';import { ItemDndProvider } from './ItemDragAndDrop';import { createMenuOpen, Launcher, setCreateMenuOpen } from './Launcher';@@ -103,6 +104,9 @@ export function Layout(props: RouteSectionProps) {<Suspense><KommandMenu /></Suspense>+ <Suspense>+ <PropertyEditorModal />+ </Suspense><GlobalBulkEditEntityModal /><ShortcutsHelper /></Show>diff --git a/js/app/packages/app/component/PropertyFilter/FilterValueEntity.tsx b/js/app/packages/app/component/PropertyFilter/FilterValueEntity.tsxindex e35cd717b7..434f353bc3 100644--- a/js/app/packages/app/component/PropertyFilter/FilterValueEntity.tsx+++ b/js/app/packages/app/component/PropertyFilter/FilterValueEntity.tsx@@ -1,7 +1,10 @@-import { useChannelsContext } from '@core/context/channels';+import {+ useChannelsContext,+ useDmActivityByUserId,+} from '@core/context/channels';import {type CombinedEntity,- ENTITY_SEARCH_CONFIG,+ createEntitySearchConfig,entityMapper,getEntityName,getEntitySearchText,@@ -10,6 +13,7 @@ import {} from '@core/component/Properties/component/modal/shared/entityUtils';import { usePropertyEntityDisplay } from '@core/component/Properties/hooks/usePropertyEntityDisplay';import { useContacts } from '@core/user';+import { useEmail } from '@core/context/user';import { createFreshSearch } from '@core/util/freshSort';import {createEmailsInfiniteQuery,@@ -88,6 +92,7 @@ export const FilterValueEntity: Component<FilterValueEntityProps> = (props) => {const contacts = useContacts();const channelsContext = useChannelsContext();const channels = channelsContext.channels;+ const dmActivityByUserId = useDmActivityByUserId();const historyQuery = useHistoryQuery();// Email queries for THREAD type or generic ENTITY (no specific type)@@ -125,6 +130,23 @@ 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 augmentUsersWithDmActivity = () => {+ const dmActivity = dmActivityByUserId();+ return contacts()+ .map(entityMapper('user'))+ .map((entity) => {+ const dmTimestamp = dmActivity.get(entity.id);+ if (dmTimestamp) {+ return {+ ...entity,+ lastInteraction: dmTimestamp,+ };+ }+ return entity;+ });+ };+// Get entities based on specific entity type (same logic as PropertyEntitySelector)const entities = createMemo((): CombinedEntity[] => {const entityType = props.specificEntityType;@@ -132,7 +154,7 @@ export const FilterValueEntity: Component<FilterValueEntityProps> = (props) => {// Generic entity - include all typesif (!entityType) {return [- ...contacts().map(entityMapper('user')),+ ...augmentUsersWithDmActivity(),...(historyQuery.data ?? []).map(entityMapper('item')),...channels().map(entityMapper('channel')),...emails().map(threadMapper),@@ -140,7 +162,7 @@ export const FilterValueEntity: Component<FilterValueEntityProps> = (props) => {}if (entityType === 'USER') {- return contacts().map(entityMapper('user'));+ return augmentUsersWithDmActivity();}if (entityType === 'CHANNEL') {@@ -171,9 +193,16 @@ export const FilterValueEntity: Component<FilterValueEntityProps> = (props) => {return [];});+ // Get current user domain for same-domain boost+ const currentUserEmail = useEmail();+ const currentUserDomain = createMemo(() => {+ const email = currentUserEmail();+ return email ? email.split('@')[1] : undefined;+ });+// Search function for fuzzy matching (same config as PropertyEntitySelector)const entitySearch = createFreshSearch<CombinedEntity>(- ENTITY_SEARCH_CONFIG,+ createEntitySearchConfig(currentUserDomain),getEntitySearchText);diff --git a/js/app/packages/app/component/UnifiedListView.tsx b/js/app/packages/app/component/UnifiedListView.tsxindex 29a2cb1b24..0f95604a14 100644--- a/js/app/packages/app/component/UnifiedListView.tsx+++ b/js/app/packages/app/component/UnifiedListView.tsx@@ -67,6 +67,7 @@ import {type WithNotification,type WithSearch,} from '@macro-entity';+import { usePropertyEditorHotkeys } from '../component/property-edit-modal/hooks/usePropertyEditorHotkeys';import {isChannelMention,isChannelMessageReply,@@ -1345,6 +1346,16 @@ export function UnifiedListView(props: UnifiedListViewProps) {(a: string, b: EntityData[]) => b.find((e) => e.id === a) !== undefined);+ // Add property editor hotkeys+ usePropertyEditorHotkeys({+ scopeId: splitContext.splitHotkeyScope,+ getSelectedEntities: () => {+ const multi = view().multiSelectEntities;+ if (multi.length > 0) return multi;+ return selectedEntity() ? [selectedEntity()!] : [];+ },+ });+const saveViewMutation = useUpsertSavedViewMutation();const isViewConfigChanged = createMemo(() => {diff --git a/js/app/packages/app/component/property-edit-modal/PropertyEditorModal.tsx b/js/app/packages/app/component/property-edit-modal/PropertyEditorModal.tsxnew file mode 100644index 0000000000..2e0d55acf1--- /dev/null+++ b/js/app/packages/app/component/property-edit-modal/PropertyEditorModal.tsx@@ -0,0 +1,900 @@+import { DialogWrapper } from '@core/component/DialogWrapper';+import { ClippedPanel } from '@core/component/ClippedPanel';+import { Dialog } from '@kobalte/core/dialog';+import { registerHotkey, useHotkeyDOMScope } from 'core/hotkey/hotkeys';+import {+ type Accessor,+ createEffect,+ createMemo,+ createSelector,+ createSignal,+ For,+ type JSX,+ Match,+ on,+ onCleanup,+ onMount,+ type Setter,+ Show,+ Switch,+} from 'solid-js';+import {+ closePropertyEditor,+ propertyEditorOpen,+ propertyEditorState,+ setPropertyEditorMode,+ setPropertyEditorTarget,+ togglePropertyEditor,+} from './state/propertyEditor';+import { beveledCorners } from '../../../block-theme/signals/themeSignals';+import { useAllProperties } from './hooks/useAllProperties';+import { usePropertySelection } from '@core/component/Properties/hooks';+import { cn } from '@ui/utils/classname';+import type { EntityData } from '@macro-entity';+import { InlineEntity } from '../../../macro-entity/src/components/InlineEntity';+import { useIsKeyPressActive } from '@core/util/useIsKeyPressActive';+import type {+ Property,+ PropertyDefinitionDomain,+} from '@core/component/Properties/types';+import type { EntityReference } from '@service-properties/generated/schemas/entityReference';+import { PropertyValueIcon } from '@core/component/Properties/component/propertyValue';+import { Hotkey } from '@core/component/Hotkey';++import { fuzzyFilter } from '@core/util/fuzzy';+import { mergeRefs } from '@solid-primitives/refs';+import {+ macroEntityToPropertyEntityType,+ PropertyDataTypeIcon,+ toPropertyApiValue,+} from '@core/component/Properties/utils';+import { useDateSearch } from '@core/util/dateSearch/useDateSearch';++import { useEntitiesForProperty } from './hooks/useEntitiesForProperty';+import {+ useListKeyBindings,+ type ListNavActions,+} from './hooks/useListKeyBindings';+import {+ getEntityName,+ getEntityType,+ type CombinedEntity,+} from '@core/component/Properties/component/modal/shared/entityUtils';+import { usePropertyEntityDisplay } from '@core/component/Properties/hooks/usePropertyEntityDisplay';+import type { PropertyApiValues } from '@core/component/Properties/types';+import { toast } from '@core/component/Toast/Toast';+import { useSavePropertyForMultiEntitites } from './hooks/useSaveProperties';+import { useEntityPropertiesQuery } from '@queries/properties/entity';++/* Styled wrapper for list items in each menu. */+function ListItem(props: {+ id: string;+ isSelected: boolean;+ disabled?: boolean;+ onClick: () => void;+ onMouseEnter: () => void;+ children: JSX.Element;+}) {+ return (+ <button+ type="button"+ id={props.id}+ disabled={props.disabled}+ class={cn(+ 'flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2 scroll-my-1',+ {+ 'bg-hover bracket': props.isSelected && !props.disabled,+ 'opacity-50 cursor-not-allowed': props.disabled,+ }+ )}+ onClick={props.onClick}+ onMouseEnter={props.onMouseEnter}+ >+ {props.children}+ </button>+ );+}++export function PropertyEditorModal() {+ const [dialogRef, setDialogRef] = createSignal<HTMLElement | undefined>();+ const [attach, hotkeyScope] = useHotkeyDOMScope('property-editor');+ const [searchValue, setSearchValue] = createSignal('');+ const [selectedIndex, setSelectedIndex] = createSignal(0);+ const [inputType, setInputType] = createSignal<'text' | 'number'>('text');++ const defaultPlaceholder = 'Choose a property...';+ const [placeholder, setPlaceholder] = createSignal('');++ const saveProperties = useSavePropertyForMultiEntitites();++ const handlePropertySave = (value: PropertyApiValues) => {+ const { selectedEntities, targetProperty } = propertyEditorState;+ if (!selectedEntities.length || !targetProperty) return;+ saveProperties(selectedEntities, targetProperty, value).then((success) => {+ if (success) {+ const count = selectedEntities.length;+ const message = `Set ${targetProperty.displayName} for ${count === 1 ? selectedEntities[0].name : count + ' entities'}`;+ toast.success(message);+ }+ // failure toast handled by mutation+ closePropertyEditor();+ });+ };++ const { dispose: disposeHotkey } = registerHotkey({+ hotkey: ['escape'],+ description: 'Close property editor',+ keyDownHandler: () => {+ closePropertyEditor();+ return true;+ },+ scopeId: hotkeyScope,+ });+ onCleanup(disposeHotkey);++ createEffect(+ on([() => propertyEditorState.mode, propertyEditorOpen], () => {+ setSelectedIndex(0);+ setSearchValue('');+ setPlaceholder('');+ setInputType('text');+ })+ );++ const { isKeypressActive } = useIsKeyPressActive();+ const setSelectedIndexFromMouse = (index: number) => {+ if (isKeypressActive()) return;+ setSelectedIndex(index);+ };++ const keybindings = useListKeyBindings(() => dialogRef());++ return (+ <Dialog open={propertyEditorOpen()} onOpenChange={togglePropertyEditor}>+ <Dialog.Portal>+ <DialogWrapper>+ <div ref={mergeRefs(attach, setDialogRef)}>+ <Dialog.Content>+ <ClippedPanel tl={!beveledCorners()} active>+ <div class="flex flex-col max-h-108 overflow-hidden bracket-never text-sm">+ <div class="flex items-center gap-2 bg-panel px-2 h-[40px] border-b border-edge-muted shrink-0">+ <span class="pl-2 pointer-events-none">❯</span>+ <SearchInput+ placeHolder={placeholder() || defaultPlaceholder}+ value={searchValue}+ setValue={setSearchValue}+ focusedIndex={selectedIndex}+ setFocusedIndex={setSelectedIndex}+ inputType={inputType()}+ />+ </div>+ <div class="p-2 border-b border-edge-muted">+ <EditingEntityPreview+ entities={propertyEditorState.selectedEntities}+ />+ </div>+ <Switch>+ <Match when={propertyEditorState.mode === 'selector'}>+ <div class="overflow-scroll scrollbar-hidden">+ <PropertyList+ searchTerm={searchValue()}+ focusedIndex={selectedIndex}+ setFocusedIndex={setSelectedIndex}+ setFocusedIndexFromMouse={setSelectedIndexFromMouse}+ setKeybindings={keybindings}+ />+ </div>+ </Match>+ <Match when={propertyEditorState.mode === 'direct'}>+ <PropertyValueEditor+ property={propertyEditorState.targetProperty}+ searchValue={searchValue}+ setSearchValue={setSearchValue}+ selectedIndex={selectedIndex}+ setSelectedIndex={setSelectedIndex}+ setSelectedIndexFromMouse={setSelectedIndexFromMouse}+ setKeybindings={keybindings}+ setPlaceholder={setPlaceholder}+ setInputType={setInputType}+ onSave={handlePropertySave}+ />+ </Match>+ </Switch>+ </div>+ </ClippedPanel>+ </Dialog.Content>+ </div>+ </DialogWrapper>+ </Dialog.Portal>+ </Dialog>+ );+}++function SearchInput(props: {+ placeHolder: string;+ setValue: Setter<string>;+ value: Accessor<string>;+ focusedIndex: Accessor<number>;+ setFocusedIndex: Setter<number>;+ onKeyDown?: (e: KeyboardEvent) => void;+ inputType?: 'text' | 'number';+}) {+ let inputRef: HTMLInputElement | undefined;++ onMount(() => {+ inputRef?.focus();+ });++ return (+ <input+ ref={inputRef}+ type={props.inputType ?? 'text'}+ class="flex-1 text-base border-0 outline-none! focus:outline-none ring-0! focus:ring-0"+ placeholder={props.placeHolder}+ value={props.value()}+ onInput={(e) => props.setValue(e.target.value)}+ onKeyDown={(e) => {+ if (props.onKeyDown) {+ props.onKeyDown(e);+ }+ }}+ autofocus+ />+ );+}++function PropertyList(props: {+ searchTerm: string;+ focusedIndex: Accessor<number>;+ setFocusedIndex: Setter<number>;+ setFocusedIndexFromMouse: (index: number) => void;+ setKeybindings: (navAction: ListNavActions) => void;+}) {+ const properties = useAllProperties();+ let containerRef: HTMLDivElement | undefined;++ const { filteredProperties } = usePropertySelection(+ () => [],+ properties,+ () => props.searchTerm+ );++ createEffect(() => {+ props.searchTerm;+ props.setFocusedIndex(0);+ });++ props.setKeybindings({+ next: () => {+ const len = filteredProperties().length;+ props.setFocusedIndex((prev) => (prev + 1) % len);+ },+ previous: () => {+ const len = filteredProperties().length;+ props.setFocusedIndex((prev) => (prev - 1 + len) % len);+ },+ select: () => {+ const focusedProperty = filteredProperties()[props.focusedIndex()];+ if (focusedProperty) {+ setProperty(focusedProperty);+ }+ },+ });++ createEffect(() => {+ const index = props.focusedIndex();+ const elem = document.getElementById(`property-editor-option-${index}`);+ if (elem) {+ elem.scrollIntoView({ block: 'nearest' });+ }+ });++ const setProperty = (property: Property | PropertyDefinitionDomain) => {+ setPropertyEditorMode('direct');+ setPropertyEditorTarget(property);+ };++ const selector = createSelector(props.focusedIndex);++ return (+ <Show+ when={filteredProperties().length > 0}+ fallback={+ <div class="text-center py-4 text-ink-muted text-sm">+ No matching properties found+ </div>+ }+ >+ <div+ ref={containerRef}+ class="max-h-[200px] overflow-y-auto overflow-x-hidden scrollbar-hidden p-1"+ >+ <For each={filteredProperties()}>+ {(property, index) => (+ <ListItem+ id={`property-editor-option-${index()}`}+ isSelected={selector(index())}+ onClick={() => setProperty(property)}+ onMouseEnter={() => props.setFocusedIndexFromMouse(index())}+ >+ <PropertyDataTypeIcon property={property} class="opacity-50" />+ <div class="flex-1 text-left flex">+ <p class="text-sm font-medium">{property.displayName}</p>+ </div>+ </ListItem>+ )}+ </For>+ </div>+ </Show>+ );+}++function EditingEntityPreview(props: { entities: EntityData[] }) {+ const displayEntities = () => props.entities.slice(0, 2);+ const remainingCount = () => Math.max(0, props.entities.length - 2);+ return (+ <div class="flex items-center gap-2">+ <For each={displayEntities()}>+ {(entity) => {+ return (+ <div+ class={cn('bg-edge/20 px-2 py-1 truncate', {+ 'max-w-[50%]': props.entities.length === 2,+ })}+ >+ <InlineEntity entity={entity} />+ </div>+ );+ }}+ </For>+ <Show when={remainingCount() > 0}>+ <div class="text-muted-foreground px-2 py-1">+ +{remainingCount()} more+ </div>+ </Show>+ </div>+ );+}++function PropertyValueEditor(props: {+ property?: Property | PropertyDefinitionDomain;+ searchValue: Accessor<string>;+ setSearchValue: Setter<string>;+ selectedIndex: Accessor<number>;+ setSelectedIndex: Setter<number>;+ setSelectedIndexFromMouse: (index: number) => void;+ setKeybindings: (binding: ListNavActions) => void;+ setPlaceholder: Setter<string>;+ setInputType: Setter<'text' | 'number'>;+ onSave: (apiValues: PropertyApiValues) => void;+}) {+ const propertyType = () => props.property?.valueType;++ const handleSubmit = (+ value: string | number | boolean | Date | EntityReference+ ) => {+ const type = propertyType();+ if (!type) return;+ let apiValues = toPropertyApiValue({ valueType: type }, value);+ if (!apiValues) return;+ props.onSave(apiValues);+ };++ return (+ <Switch>+ <Match+ when={+ propertyType() === 'SELECT_STRING' ||+ propertyType() === 'SELECT_NUMBER'+ }+ >+ <SelectPropertyEditor+ property={props.property!}+ searchValue={props.searchValue}+ selectedIndex={props.selectedIndex}+ setSelectedIndex={props.setSelectedIndex}+ setSelectedIndexFromMouse={props.setSelectedIndexFromMouse}+ onSubmit={handleSubmit}+ setKeybindings={props.setKeybindings}+ setPlaceholder={props.setPlaceholder}+ />+ </Match>+ <Match when={propertyType() === 'ENTITY'}>+ <EntityPropertyEditor+ property={props.property}+ searchValue={props.searchValue}+ setSearchValue={props.setSearchValue}+ selectedIndex={props.selectedIndex}+ setSelectedIndex={props.setSelectedIndex}+ setSelectedIndexFromMouse={props.setSelectedIndexFromMouse}+ onSubmit={handleSubmit}+ setKeybindings={props.setKeybindings}+ setPlaceholder={props.setPlaceholder}+ />+ </Match>+ <Match+ when={+ propertyType() === 'STRING' ||+ propertyType() === 'NUMBER' ||+ propertyType() === 'DATE' ||+ propertyType() === 'BOOLEAN'+ }+ >+ <DirectEditPropertyEditor+ property={props.property}+ searchValue={props.searchValue}+ setSearchValue={props.setSearchValue}+ selectedIndex={props.selectedIndex}+ setSelectedIndex={props.setSelectedIndex}+ setSelectedIndexFromMouse={props.setSelectedIndexFromMouse}+ onSubmit={handleSubmit}+ setKeybindings={props.setKeybindings}+ setPlaceholder={props.setPlaceholder}+ setInputType={props.setInputType}+ />+ </Match>+ <Match when={propertyType() === 'LINK'}>+ <div class="p-4 text-center text-muted-foreground">+ Link editing not yet implemented+ </div>+ </Match>+ </Switch>+ );+}++function SelectPropertyEditor(props: {+ property: Property | PropertyDefinitionDomain;+ searchValue: Accessor<string>;+ selectedIndex: Accessor<number>;+ setSelectedIndex: Setter<number>;+ setSelectedIndexFromMouse: (index: number) => void;+ onSubmit: (value: string) => void;+ setKeybindings: (binding: ListNavActions) => void;+ setPlaceholder: Setter<string>;+}) {+ createEffect(() => {+ if (props.property.isMultiSelect) {+ props.setPlaceholder(+ `Add ${props.property.displayName.toLowerCase()}...`+ );+ return;+ }+ props.setPlaceholder(`Set ${props.property.displayName.toLowerCase()}...`);+ });++ const filteredOptions = createMemo(() => {+ const options = props.property?.options || [];+ const search = props.searchValue().trim();+ if (!search) return options;+ return fuzzyFilter(search, options, (opt) => String(opt.value.value));+ });++ const shouldShowHotkeys = createMemo(() => {+ return !props.searchValue().trim() && filteredOptions().length <= 9;+ });++ props.setKeybindings({+ select: () => {+ const selected = filteredOptions()[props.selectedIndex()];+ props.onSubmit(selected.id);+ },+ next: () => {+ const len = filteredOptions().length;+ props.setSelectedIndex((prev) => (prev + 1) % len);+ },+ previous: () => {+ const len = filteredOptions().length;+ props.setSelectedIndex((prev) => (prev - 1 + len) % len);+ },+ });++ const selector = createSelector(props.selectedIndex);++ return (+ <div class="p-1 max-h-[200px] overflow-y-auto overflow-x-hidden scrollbar-hidden">+ <Show+ when={filteredOptions().length > 0}+ fallback={+ <div class="text-center py-4 text-ink-muted text-sm">+ No matching options found+ </div>+ }+ >+ <For each={filteredOptions()}>+ {(option, index) => (+ <ListItem+ id={`property-value-option-${index()}`}+ isSelected={selector(index())}+ onClick={() => props.onSubmit(option.id)}+ onMouseEnter={() => props.setSelectedIndexFromMouse(index())}+ >+ <PropertyValueIcon optionId={option.id} />+ <div class="flex-1 text-left">+ <p class="text-sm font-medium">{String(option.value.value)}</p>+ </div>+ <Show when={shouldShowHotkeys() && index() < 9}>+ <div class="text-[0.625rem] px-1.5 py-0.5 border border-edge-muted text-ink-muted font-mono rounded-xs">+ <Hotkey shortcut={`${index() + 1}`} />+ </div>+ </Show>+ </ListItem>+ )}+ </For>+ </Show>+ </div>+ );+}++function EntityPropertyEditor(props: {+ property?: Property | PropertyDefinitionDomain;+ searchValue: Accessor<string>;+ setSearchValue: Setter<string>;+ selectedIndex: Accessor<number>;+ setSelectedIndex: Setter<number>;+ setSelectedIndexFromMouse: (index: number) => void;+ onSubmit: (value: EntityReference) => void;+ setKeybindings: (binding: ListNavActions) => void;+ setPlaceholder: Setter<string>;+}) {+ const { entities } = useEntitiesForProperty(+ () => props.property,+ props.searchValue+ );++ createEffect(() => {+ const entityTypeLabel =+ props.property?.specificEntityType?.toLowerCase() || 'entity';+ props.setPlaceholder(`Search for ${entityTypeLabel}...`);+ });++ createEffect(() => {+ props.searchValue();+ props.setSelectedIndex(0);+ });++ props.setKeybindings({+ select: () => {+ const selected = entities()[props.selectedIndex()];+ if (selected) {+ const entityRef: EntityReference = {+ entity_id: selected.id,+ entity_type: getEntityType(selected),+ };+ props.onSubmit(entityRef);+ }+ },+ next: () => {+ const len = entities().length;+ props.setSelectedIndex((prev) => (prev + 1) % len);+ },+ previous: () => {+ const len = entities().length;+ props.setSelectedIndex((prev) => (prev - 1 + len) % len);+ },+ });++ createEffect(() => {+ const index = props.selectedIndex();+ const elem = document.getElementById(`entity-option-${index}`);+ if (elem) {+ elem.scrollIntoView({ block: 'nearest' });+ }+ });++ const selector = createSelector(props.selectedIndex);++ return (+ <div class="p-1 max-h-[200px] overflow-y-auto overflow-x-hidden scrollbar-hidden">+ <Show+ when={entities().length > 0}+ fallback={+ <div class="text-center py-4 text-ink-muted text-sm">+ {props.searchValue().trim()+ ? 'No matching entities found'+ : 'No entities available'}+ </div>+ }+ >+ <For each={entities()}>+ {(entity, index) => (+ <ListItem+ id={`entity-option-${index()}`}+ isSelected={selector(index())}+ onClick={() => {+ const entityRef: EntityReference = {+ entity_id: entity.id,+ entity_type: getEntityType(entity),+ };+ props.onSubmit(entityRef);+ }}+ onMouseEnter={() => props.setSelectedIndexFromMouse(index())}+ >+ <EntityRowContent entity={entity} />+ </ListItem>+ )}+ </For>+ </Show>+ </div>+ );+}++function EntityRowContent(props: { entity: CombinedEntity }) {+ const { icon } = usePropertyEntityDisplay(+ () => props.entity.id,+ () => getEntityType(props.entity)+ );++ return (+ <>+ <span class="size-4 flex items-center justify-center shrink-0">+ {icon()}+ </span>+ <div class="flex-1 text-left">+ <p class="text-sm font-medium">{getEntityName(props.entity)}</p>+ </div>+ </>+ );+}++function DirectEditPropertyEditor(props: {+ property?: Property | PropertyDefinitionDomain;+ searchValue: Accessor<string>;+ setSearchValue: Setter<string>;+ selectedIndex: Accessor<number>;+ setSelectedIndex: Setter<number>;+ setSelectedIndexFromMouse: (index: number) => void;+ onSubmit: (value: string | number | boolean | Date) => void;+ setKeybindings: (binding: ListNavActions) => void;+ setPlaceholder: Setter<string>;+ setInputType: Setter<'text' | 'number'>;+}) {+ // Show date picker for DATE type properties+ if (props.property?.valueType === 'DATE') {+ return (+ <DatePropertyEditor+ property={props.property}+ searchValue={props.searchValue}+ selectedIndex={props.selectedIndex}+ setSelectedIndex={props.setSelectedIndex}+ setSelectedIndexFromMouse={props.setSelectedIndexFromMouse}+ onSubmit={props.onSubmit as (value: Date) => void}+ setKeybindings={props.setKeybindings}+ setPlaceholder={props.setPlaceholder}+ />+ );+ }++ // Fetch existing property value for single entity+ const singleEntity = () => {+ const entities = propertyEditorState.selectedEntities;+ return entities.length === 1 ? entities[0] : null;+ };++ const entityPropertiesQuery = useEntityPropertiesQuery(+ () => {+ const entity = singleEntity();+ return entity ? macroEntityToPropertyEntityType(entity) : 'DOCUMENT';+ },+ () => singleEntity()?.id ?? '',+ false+ );++ const existingValue = createMemo(() => {+ const entity = singleEntity();+ if (!entity || !props.property) return null;++ const propertyDefId =+ 'propertyDefinitionId' in props.property+ ? props.property.propertyDefinitionId+ : props.property.id;++ const entityProperties = entityPropertiesQuery.data;+ if (!entityProperties) return null;++ const prop = entityProperties.find(+ (p) => p.propertyDefinitionId === propertyDefId+ );+ if (!prop) return null;++ if (prop.valueType === 'STRING' || prop.valueType === 'NUMBER') {+ return prop.value;+ }+ return null;+ });++ const handleSubmit = () => {+ const value = props.searchValue();+ const type = props.property?.valueType;++ if (type === 'NUMBER') {+ const numValue = parseFloat(value);+ if (!isNaN(numValue)) {+ props.onSubmit(numValue);+ }+ } else if (type === 'BOOLEAN') {+ props.onSubmit(value.toLowerCase() === 'true');+ } else {+ props.onSubmit(value);+ }+ };++ // Set input type and initial value based on property type+ createEffect(() => {+ const type = props.property?.valueType;+ props.setInputType(type === 'NUMBER' ? 'number' : 'text');+ });++ // Set initial value to existing value when available+ createEffect(() => {+ const existing = existingValue();+ if (existing !== null && existing !== undefined) {+ props.setSearchValue(String(existing));+ }+ });++ createEffect(() => {+ const name = props.property?.displayName || 'value';+ const type = props.property?.valueType;+ const existing = existingValue();++ let placeholderText: string;+ if (existing !== null && existing !== undefined) {+ placeholderText = `${String(existing)}...`;+ } else if (type === 'BOOLEAN') {+ placeholderText = `Enter true or false for ${name}`;+ } else if (type === 'NUMBER') {+ placeholderText = `Enter number for ${name}`;+ } else {+ placeholderText = `Enter ${name}`;+ }++ props.setPlaceholder(placeholderText);+ });++ props.setKeybindings({+ select: () => {+ handleSubmit();+ },+ next: () => {},+ previous: () => {},+ });++ const displayValue = () => {+ const value = props.searchValue().trim();+ return value || null;+ };++ const isValidInput = () => {+ const value = props.searchValue().trim();+ if (!value) return false;+ if (props.property?.valueType === 'NUMBER') {+ return !isNaN(parseFloat(value));+ }+ return true;+ };++ return (+ <div class="max-h-[200px] overflow-y-auto overflow-x-hidden scrollbar-hidden p-1">+ <ListItem+ id="property-value-option-0"+ isSelected={true}+ disabled={!isValidInput()}+ onClick={handleSubmit}+ onMouseEnter={() => {}}+ >+ <PropertyDataTypeIcon property={props.property!} class="opacity-50" />+ <div class="flex-1 text-left">+ <p class="text-sm font-medium">+ Set {props.property?.displayName}+ <Show when={displayValue()}>+ {' '}+ to <span class="text-ink-muted">{displayValue()}</span>+ </Show>+ </p>+ </div>+ </ListItem>+ </div>+ );+}++function DatePropertyEditor(props: {+ property: Property | PropertyDefinitionDomain;+ searchValue: Accessor<string>;+ selectedIndex: Accessor<number>;+ setSelectedIndex: Setter<number>;+ setSelectedIndexFromMouse: (index: number) => void;+ onSubmit: (value: Date) => void;+ setKeybindings: (binding: ListNavActions) => void;+ setPlaceholder: Setter<string>;+}) {+ createEffect(() => {+ props.setPlaceholder(`Set ${props.property.displayName.toLowerCase()}...`);+ });++ const dateOptions = useDateSearch({+ query: props.searchValue,+ });++ createEffect(+ on(dateOptions, (options) => {+ if (options.length === 0) {+ props.setSelectedIndex(0);+ } else {+ props.setSelectedIndex(+ Math.min(props.selectedIndex(), options.length - 1)+ );+ }+ })+ );++ props.setKeybindings({+ select: () => {+ const selected = dateOptions()[props.selectedIndex()];+ if (selected) {+ props.onSubmit(selected.date);+ }+ },+ next: () => {+ const len = dateOptions().length;+ props.setSelectedIndex((prev) => (prev + 1) % len);+ },+ previous: () => {+ const len = dateOptions().length;+ props.setSelectedIndex((prev) => (prev - 1 + len) % len);+ },+ });++ const selector = createSelector(props.selectedIndex);++ return (+ <>+ <div class="p-1 max-h-[200px] overflow-y-auto overflow-x-hidden scrollbar-hidden">+ <Show+ when={dateOptions().length > 0}+ fallback={+ <Show+ when={props.searchValue().trim()}+ fallback={+ <div class="text-center py-4 text-ink-muted text-sm">+ Enter a date or duration+ </div>+ }+ >+ <div class="text-center py-4 text-ink-muted text-sm">+ No dates match "{props.searchValue()}"+ </div>+ </Show>+ }+ >+ <For each={dateOptions()}>+ {(option, index) => (+ <ListItem+ id={`date-option-${index()}`}+ isSelected={selector(index())}+ onClick={() => props.onSubmit(option.date)}+ onMouseEnter={() => props.setSelectedIndexFromMouse(index())}+ >+ <div class="flex-1 text-left">+ <p class="text-sm font-medium">{option.displayText}</p>+ </div>+ <span class="text-xs text-ink-muted">+ {option.secondaryText}+ </span>+ </ListItem>+ )}+ </For>+ </Show>+ </div>++ <div class="px-2 py-1.5 border-t border-edge-muted">+ <div class="text-xs text-ink-muted">+ <span>Use queries like </span>+ <code class="bg-active px-1">3d</code>,{' '}+ <code class="bg-active px-1">1w</code>,{' '}+ <code class="bg-active px-1">feb 17</code>, or{' '}+ <code class="bg-active px-1">tomorrow</code>+ </div>+ </div>+ </>+ );+}diff --git a/js/app/packages/app/component/property-edit-modal/hooks/useAllProperties.ts b/js/app/packages/app/component/property-edit-modal/hooks/useAllProperties.tsnew file mode 100644index 0000000000..a065ffb1b0--- /dev/null+++ b/js/app/packages/app/component/property-edit-modal/hooks/useAllProperties.ts@@ -0,0 +1,30 @@+import type { PropertyDefinitionDomain } from '@core/component/Properties/types';+import { toPropertyDefinitionDomain } from '@core/component/Properties/utils';+import { useListPropertiesQuery } from '@queries/properties/definitions';+import { createMemo } from 'solid-js';++export function useAllProperties() {+ const query = useListPropertiesQuery(() => ({+ scope: 'all',+ includeOptions: true,+ }));++ return createMemo<PropertyDefinitionDomain[]>(() => {+ if (query.isLoading || query.isError || !query.data) {+ return [];+ }++ const data = query.data;++ const properties = Array.isArray(data) ? data : [];+ return properties.map((item) => {+ if ('definition' in item) {+ return toPropertyDefinitionDomain(+ item.definition,+ item.property_options || []+ );+ }+ return toPropertyDefinitionDomain(item);+ });+ });+}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.tsnew file mode 100644index 0000000000..98cf66683a--- /dev/null+++ b/js/app/packages/app/component/property-edit-modal/hooks/useEntitiesForProperty.ts@@ -0,0 +1,190 @@+import {+ useChannelsContext,+ useDmActivityByUserId,+} from '@core/context/channels';+import {+ type CombinedEntity,+ createEntitySearchConfig,+ entityMapper,+ getEntitySearchText,+ threadMapper,+} from '@core/component/Properties/component/modal/shared/entityUtils';+import { useContacts } from '@core/user';+import { createFreshSearch } from '@core/util/freshSort';+import { useEmail } from '@core/context/user';+import {+ createEmailsInfiniteQuery,+ createUnifiedSearchInfiniteQuery,+ type EmailEntity,+} from '@macro-entity';+import type { EntityType } from '@service-properties/generated/schemas/entityType';+import { useHistoryQuery } from '@queries/history/history';+import { debounce } from '@solid-primitives/scheduled';+import {+ createEffect,+ createMemo,+ createSignal,+ type Accessor,+} from 'solid-js';+import type {+ Property,+ PropertyDefinitionDomain,+} from '@core/component/Properties/types';++export function useEntitiesForProperty(+ property: Accessor<Property | PropertyDefinitionDomain | undefined>,+ searchQuery: Accessor<string>+) {+ const [searchTerm, setSearchTerm] = createSignal('');++ // Debounce search term updates+ const debouncedSetSearchTerm = debounce(+ (term: string) => setSearchTerm(term.toLowerCase()),+ 60+ );+ createEffect(() => debouncedSetSearchTerm(searchQuery()));++ // Data sources+ const contacts = useContacts();+ const channelsContext = useChannelsContext();+ const channels = channelsContext.channels;+ const dmActivityByUserId = useDmActivityByUserId();+ const historyQuery = useHistoryQuery();+ const history = () => historyQuery.data ?? [];++ const specificEntityType = () => property()?.specificEntityType;++ // Email queries for THREAD type or generic ENTITY (no specific type)+ const needsEmailSearch = () =>+ specificEntityType() === 'THREAD' || !specificEntityType();++ const emailsQuery = createEmailsInfiniteQuery(() => ({ view: 'all' }), {+ disabled: () => !needsEmailSearch(),+ });+ const emails = () => emailsQuery.data ?? [];++ // Server-side email search+ const emailSearchQuery = createUnifiedSearchInfiniteQuery(+ () => ({+ params: { page: 0, page_size: 20 },+ request: {+ query: searchTerm(),+ match_type: 'partial' as const,+ include: ['emails' as const],+ search_on: 'name' as const,+ },+ }),+ {+ disabled: () => !needsEmailSearch() || !searchTerm(),+ }+ );++ // Server search results mapped to our format+ const serverEmails = createMemo((): CombinedEntity[] => {+ if (emailSearchQuery.status !== 'success' || !emailSearchQuery.data) {+ return [];+ }+ return emailSearchQuery.data+ .filter((entity) => entity.type === 'email')+ .map((entity) => threadMapper(entity as EmailEntity));+ });++ // Helper to augment user entities with DM activity timestamps (same as MentionsMenu)+ const augmentUsersWithDmActivity = () => {+ const dmActivity = dmActivityByUserId();+ return contacts()+ .map(entityMapper('user'))+ .map((entity) => {+ const dmTimestamp = dmActivity.get(entity.id);+ if (dmTimestamp) {+ return {+ ...entity,+ lastInteraction: dmTimestamp,+ };+ }+ return entity;+ });+ };++ // Get entities based on specific entity type+ 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'));+ }++ 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'));+ }++ if (entityType === 'TASK') {+ return history()+ .filter(+ (item) => item.type === 'document' && item.subType?.type === 'task'+ )+ .map(entityMapper('item'));+ }++ // COMPANY not yet implemented+ return [];+ });++ const currentUserEmail = useEmail();+ const currentUserDomain = createMemo(() => {+ const email = currentUserEmail();+ return email ? email.split('@')[1] : undefined;+ });++ // search function for fuzzy matching+ const entitySearch = createFreshSearch<CombinedEntity>(+ createEntitySearchConfig(currentUserDomain),+ getEntitySearchText+ );++ // get filtered entities based on search query+ const filteredEntities = createMemo(() => {+ const query = searchTerm();+ const available = entities();++ const MAX_RESULTS = 50;++ const localResults = entitySearch(available, query)+ .slice(0, MAX_RESULTS)+ .map((result) => result.item);++ if (needsEmailSearch() && query) {+ const localIds = new Set(localResults.map((e) => e.id));+ const serverResults = serverEmails().filter((e) => !localIds.has(e.id));+ return [...localResults, ...serverResults].slice(0, MAX_RESULTS);+ }++ return localResults;+ });++ return {+ entities: filteredEntities,+ };+}diff --git a/js/app/packages/app/component/property-edit-modal/hooks/useListKeyBindings.ts b/js/app/packages/app/component/property-edit-modal/hooks/useListKeyBindings.tsnew file mode 100644index 0000000000..407b34e455--- /dev/null+++ b/js/app/packages/app/component/property-edit-modal/hooks/useListKeyBindings.ts@@ -0,0 +1,40 @@+import { type Accessor, createEffect, on, onCleanup } from 'solid-js';++export type ListNavActions = {+ next: VoidFunction;+ previous: VoidFunction;+ select: VoidFunction;+};++export function useListKeyBindings(elem: Accessor<HTMLElement | undefined>) {+ let actions: ListNavActions | undefined;+ let unbind: VoidFunction | undefined;++ const onKeyDown = (e: KeyboardEvent) => {+ if (e.key === 'ArrowDown' || (e.key === 'j' && e.ctrlKey)) {+ e.preventDefault();+ actions?.next();+ } else if (e.key === 'ArrowUp' || (e.key === 'k' && e.ctrlKey)) {+ e.preventDefault();+ actions?.previous();+ } else if (e.key === 'Enter') {+ e.preventDefault();+ actions?.select();+ }+ };++ createEffect(+ on(elem, (el) => {+ unbind?.();+ if (!el) return;+ el.addEventListener('keydown', onKeyDown);+ unbind = () => el.removeEventListener('keydown', onKeyDown);+ })+ );++ onCleanup(() => unbind?.());++ return (nextActions: ListNavActions | undefined) => {+ actions = nextActions;+ };+}diff --git a/js/app/packages/app/component/property-edit-modal/hooks/usePropertyEditorHotkeys.ts b/js/app/packages/app/component/property-edit-modal/hooks/usePropertyEditorHotkeys.tsnew file mode 100644index 0000000000..fa5727f7a7--- /dev/null+++ b/js/app/packages/app/component/property-edit-modal/hooks/usePropertyEditorHotkeys.ts@@ -0,0 +1,131 @@+import { registerHotkey } from 'core/hotkey/hotkeys';+import { onCleanup, onMount, type Accessor } from 'solid-js';+import { openPropertyEditor } from '../state/propertyEditor';+import type {+ Property,+ PropertyDefinitionDomain,+} from '@core/component/Properties/types';+import { isTaskEntity, type EntityData } from '@macro-entity';+import { TOKENS } from '@core/hotkey/tokens';+import { HotkeyTags } from '@core/hotkey/constants';+import { useAllProperties } from './useAllProperties';+import { SYSTEM_PROPERTY_IDS } from '@core/component/Properties/constants';++interface PropertyEditorHotkeyOptions {+ scopeId: string;+ getSelectedEntities: () => EntityData[];+ enabled?: Accessor<boolean>;+}++/**+ * Hook that registers hotkeys for the property editor+ * - `cmd-shift-o`: Opens property selector+ * - `cmd-shift-s`: Direct edit status property+ * - `cmd-shift-p`: Direct edit priority property+ * - `cmd-shift-a`: Direct edit assigness property+ */+export function usePropertyEditorHotkeys(options: PropertyEditorHotkeyOptions) {+ const { scopeId, getSelectedEntities, enabled = () => true } = options;+ const allProperties = useAllProperties();++ const propertyById = (propertyId: string) => {+ return allProperties().find(({ id }) => {+ return id === propertyId;+ });+ };+ const status = () => propertyById(SYSTEM_PROPERTY_IDS.STATUS);+ const priority = () => propertyById(SYSTEM_PROPERTY_IDS.PRIORITY);+ const assignees = () => propertyById(SYSTEM_PROPERTY_IDS.ASSIGNEES);++ // Helper to open property editor if entities are selected+ const openIfSelected = (+ mode: 'selector' | 'direct' = 'selector',+ property?: Property | PropertyDefinitionDomain+ ) => {+ if (!enabled()) {+ console.log('[PropertyEditor] Hotkey disabled');+ return;+ }+ const entities = getSelectedEntities();+ if (entities && entities.length > 0) {+ openPropertyEditor(entities, mode, property);+ } else {+ console.warn('[PropertyEditor] No entities selected for property editor');+ }+ };++ onMount(() => {+ const disposers: Array<{ dispose: () => void }> = [];+ disposers.push(+ registerHotkey({+ hotkey: ['shift+cmd+o'],+ hotkeyToken: TOKENS.entity.action.properties,+ tags: [HotkeyTags.SelectionModification],+ displayPriority: 10,+ description: 'Open property editor',+ keyDownHandler: () => {+ const entities = getSelectedEntities();+ if (!entities.every(isTaskEntity)) return true;+ openIfSelected('selector');+ return true;+ },+ scopeId,+ }),+ registerHotkey({+ hotkey: ['shift+cmd+p'],+ hotkeyToken: TOKENS.entity.action.priority,+ tags: [HotkeyTags.SelectionModification],+ displayPriority: 10,+ description: 'Set priority',+ keyDownHandler: () => {+ const property = priority();+ const entities = getSelectedEntities();+ if (!entities.every(isTaskEntity) || !property) return true;+ openIfSelected('direct', property);+ return true;+ },+ condition: () => Boolean(priority()),+ scopeId,+ }),+ registerHotkey({+ hotkey: ['shift+cmd+a'],+ hotkeyToken: TOKENS.entity.action.assignee,+ tags: [HotkeyTags.SelectionModification],+ displayPriority: 10,+ description: 'Set assignee',+ keyDownHandler: () => {+ const property = assignees();+ const entities = getSelectedEntities();+ if (!entities.every(isTaskEntity) || !property) return true;+ openIfSelected('direct', property);+ return true;+ },+ condition: () => Boolean(assignees()),+ scopeId,+ }),+ registerHotkey({+ hotkey: ['shift+cmd+s'],+ hotkeyToken: TOKENS.entity.action.status,+ tags: [HotkeyTags.SelectionModification],+ displayPriority: 10,+ description: 'Set status',+ keyDownHandler: () => {+ const property = status();+ const entities = getSelectedEntities();+ if (!entities.every(isTaskEntity) || !property) return true;+ openIfSelected('direct', property);+ return true;+ },+ condition: () => Boolean(status()),+ scopeId,+ })+ );+ onCleanup(() => {+ disposers.forEach((disposer) => disposer.dispose());+ });+ });++ return {+ openPropertyEditor: openIfSelected,+ };+}diff --git a/js/app/packages/app/component/property-edit-modal/hooks/useSaveProperties.ts b/js/app/packages/app/component/property-edit-modal/hooks/useSaveProperties.tsnew file mode 100644index 0000000000..1391b26de4--- /dev/null+++ b/js/app/packages/app/component/property-edit-modal/hooks/useSaveProperties.ts@@ -0,0 +1,42 @@+import type {+ Property,+ PropertyApiValues,+ PropertyDefinitionDomain,+} from '@core/component/Properties/types';+import {+ isInstantiatedProperty,+ macroEntityToPropertyEntityType,+} from '@core/component/Properties/utils';+import type { EntityData } from '@macro-entity';+import { useBulkSaveEntityPropertiesMutation } from '@queries/properties/entity';++export function useSavePropertyForMultiEntitites() {+ const mutation = useBulkSaveEntityPropertiesMutation();+ return async (+ entities: EntityData[],+ property: Property | PropertyDefinitionDomain,+ value: PropertyApiValues+ ) => {+ if (entities.length === 0) {+ console.error('saveProperties Error: no selected entities');+ }++ const definitionId = isInstantiatedProperty(property)+ ? property.propertyDefinitionId+ : property.id;++ const propList = entities.map((e) => ({+ entityId: e.id,+ entityType: macroEntityToPropertyEntityType(e),+ property: { id: definitionId, isMultiSelect: property.isMultiSelect },+ apiValues: value,+ }));++ try {+ await mutation.mutateAsync({ properties: propList });+ return true;+ } catch {+ return false;+ }+ };+}diff --git a/js/app/packages/app/component/property-edit-modal/state/propertyEditor.ts b/js/app/packages/app/component/property-edit-modal/state/propertyEditor.tsnew file mode 100644index 0000000000..e265083ee3--- /dev/null+++ b/js/app/packages/app/component/property-edit-modal/state/propertyEditor.ts@@ -0,0 +1,71 @@+import type { EntityData } from '@macro-entity';+import type {+ Property,+ PropertyDefinitionDomain,+} from '@core/component/Properties/types';+import { createStore, reconcile } from 'solid-js/store';+import { createControlledOpenSignal } from '@core/util/createControlledOpenSignal';++export type PropertyEditorMode = 'selector' | 'direct';++export const [propertyEditorOpen, setPropertyEditorOpen] =+ createControlledOpenSignal();++interface PropertyEditorState {+ mode: PropertyEditorMode;+ selectedEntities: EntityData[];+ targetProperty?: Property | PropertyDefinitionDomain;+}++const [state, setState] = createStore<PropertyEditorState>({+ mode: 'selector',+ selectedEntities: [],+ targetProperty: undefined,+});++export function openPropertyEditor(+ entities: EntityData[],+ mode: PropertyEditorMode = 'selector',+ targetProperty?: Property | PropertyDefinitionDomain+) {+ if (!entities || entities.length === 0) {+ console.warn('Cannot open property editor without entities');+ return;+ }+ setPropertyEditorOpen(true);+ setState(+ reconcile({+ mode,+ selectedEntities: entities,+ targetProperty,+ })+ );+}++export function closePropertyEditor() {+ setPropertyEditorOpen(false);+ setState(+ reconcile({+ mode: 'selector',+ selectedEntities: [],+ targetProperty: undefined,+ targetPropertyDefinition: undefined,+ })+ );+}++export function togglePropertyEditor(force?: boolean) {+ setPropertyEditorOpen(force ?? !propertyEditorOpen());+}++export function setPropertyEditorMode(mode: PropertyEditorMode) {+ setState('mode', mode);+}++export function setPropertyEditorTarget(+ property: Property | PropertyDefinitionDomain+) {+ setState('targetProperty', property);+}++export const propertyEditorState = state;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.tsxindex 7b59cf98b8..6f946fcccf 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,5 +1,8 @@import { useMaybeBlockId } from '@core/block';-import { useChannelsContext } from '@core/context/channels';+import {+ useChannelsContext,+ useDmActivityByUserId,+} from '@core/context/channels';import { EntityIcon } from '@core/component/EntityIcon';import { UserIcon } from '@core/component/UserIcon';import { fileTypeToBlockName } from '@core/constant/allBlocks';@@ -19,7 +22,7 @@ import {createUnifiedSearchInfiniteQuery,type EmailEntity,} from '@macro-entity';-import { useUserId } from '@core/context/user';+import { useEmail, useUserId } from '@core/context/user';import type { EntityType } from '@service-properties/generated/schemas/entityType';import { useHistoryQuery } from '@queries/history/history';import { debounce } from '@solid-primitives/scheduled';@@ -38,7 +41,7 @@ import type { Property } from '../../../types';import { useSearchInputFocus } from '../../../utils';import {type CombinedEntity,- ENTITY_SEARCH_CONFIG,+ createEntitySearchConfig,entityMapper,getEntityName,getEntitySearchText,@@ -156,6 +159,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {const contacts = useContacts();const channelsContext = useChannelsContext();const channels = channelsContext.channels;+ const dmActivityByUserId = useDmActivityByUserId();// Get current user info for injection into contactsconst currentUserId = useUserId();@@ -234,13 +238,28 @@ export function PropertyEntitySelector(props: EntityInputProps) {return false;});+ // Helper to augment user entities with DM activity timestamps (same as MentionsMenu)+ const augmentUsersWithDmActivity = (users: IUser[]) => {+ const dmActivity = dmActivityByUserId();+ return users.map(entityMapper('user')).map((entity) => {+ const dmTimestamp = dmActivity.get(entity.id);+ if (dmTimestamp) {+ return {+ ...entity,+ lastInteraction: dmTimestamp,+ };+ }+ return entity;+ });+ };+// Local entities (always available, used for instant results)const entities = createMemo(() => {const { specificEntityType } = props.property;if (!specificEntityType) {return [- ...contactsWithCurrentUser().map(entityMapper('user')),+ ...augmentUsersWithDmActivity(contactsWithCurrentUser()),...(historyQuery.data ?? []).map(entityMapper('item')),...channels().map(entityMapper('channel')),...emails().map(threadMapper),@@ -248,7 +267,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {}if (specificEntityType === 'USER') {- return contactsWithCurrentUser().map(entityMapper('user'));+ return augmentUsersWithDmActivity(contactsWithCurrentUser());}if (specificEntityType === 'CHANNEL') {@@ -295,8 +314,15 @@ export function PropertyEntitySelector(props: EntityInputProps) {return [];});+ // Get current user domain for same-domain boost+ const currentUserEmail = useEmail();+ const currentUserDomain = createMemo(() => {+ const email = currentUserEmail();+ return email ? email.split('@')[1] : undefined;+ });+const entitySearch = createFreshSearch<CombinedEntity>(- ENTITY_SEARCH_CONFIG,+ createEntitySearchConfig(currentUserDomain),getEntitySearchText);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.tsnew file mode 100644index 0000000000..487b433600--- /dev/null+++ b/js/app/packages/core/component/Properties/component/modal/shared/entityUtils.test.ts@@ -0,0 +1,90 @@+import { describe, expect, it } from 'vitest';+import { createSignal } from 'solid-js';+import { createEntitySearchConfig } from './entityUtils';+import type { CombinedEntity } from './entityUtils';+import type { IUser } from '@core/user';++describe('createEntitySearchConfig', () => {+ it('should return correct search config with same weights as MentionsMenu', () => {+ const [domain] = createSignal('example.com');+ const config = createEntitySearchConfig(domain);++ expect(config.fuzzyWeight).toBe(0.5);+ expect(config.timeWeight).toBe(0.4);+ expect(config.brevityWeight).toBe(0.1);+ expect(config.boostFn).toBeDefined();+ });++ it('should boost users with same domain', () => {+ const [domain] = createSignal('example.com');+ const config = createEntitySearchConfig(domain);++ const userEntity: CombinedEntity = {+ kind: 'user',+ id: 'user-1',+ data: {+ id: 'user-1',+ email: '[email protected]',+ name: 'Test User',+ } as IUser,+ };++ const boost = config.boostFn!(userEntity);+ expect(boost).toBe(0.5);+ });++ it('should not boost users with different domain', () => {+ const [domain] = createSignal('example.com');+ const config = createEntitySearchConfig(domain);++ const userEntity: CombinedEntity = {+ kind: 'user',+ id: 'user-1',+ data: {+ id: 'user-1',+ email: '[email protected]',+ name: 'Test User',+ } as IUser,+ };++ const boost = config.boostFn!(userEntity);+ expect(boost).toBe(0);+ });++ it('should not boost non-user entities', () => {+ const [domain] = createSignal('example.com');+ const config = createEntitySearchConfig(domain);++ const channelEntity: CombinedEntity = {+ kind: 'channel',+ id: 'channel-1',+ data: {+ id: 'channel-1',+ name: 'Test Channel',+ } as any,+ };++ const boost = config.boostFn!(channelEntity);+ expect(boost).toBe(0);+ });++ it('should be reactive to domain changes', () => {+ const [domain, setDomain] = createSignal('example.com');+ const config = createEntitySearchConfig(domain);++ const userEntity: CombinedEntity = {+ kind: 'user',+ id: 'user-1',+ data: {+ id: 'user-1',+ email: '[email protected]',+ name: 'Test User',+ } as IUser,+ };++ expect(config.boostFn!(userEntity)).toBe(0.5);++ setDomain('other.com');+ expect(config.boostFn!(userEntity)).toBe(0);+ });+});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.tsindex 6c1944c1f8..762dcc2f56 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@@ -2,6 +2,8 @@ import type { ChannelWithParticipants, IUser } from '@core/user';import type { EmailEntity } from '@macro-entity';import type { EntityType } from '@service-properties/generated/schemas/entityType';import type { Item } from '@service-storage/generated/schemas/item';+import type { Accessor } from 'solid-js';+import type { FreshSortConfig, TimestampedItem } from '@core/util/freshSort';/** Combined entity type for unified handling across entity selectors */export type CombinedEntity =@@ -83,8 +85,31 @@ export function getEntityType(entity: CombinedEntity): EntityType {}}-/** Search config for createFreshSearch (consistent across entity selectors) */-export const ENTITY_SEARCH_CONFIG = {- timeWeight: 0.1,- brevityWeight: 0.3,-} as const;+/**+ * Creates search config for entity searches with same-domain boost.+ * Uses the same preset as MentionsMenu and RecipientSelector for consistency.+ */+export function createEntitySearchConfig(+ currentUserDomain: Accessor<string | undefined>+): FreshSortConfig {+ const boostFn = <T extends TimestampedItem>(item: T): number => {+ const userDomain = currentUserDomain();+ if (!userDomain) return 0;++ // Check if this looks like a CombinedEntity with user data+ if (item?.kind === 'user' && item?.data?.email) {+ const email = item.data.email as string;+ const itemDomain = email.split('@')[1];+ return itemDomain === userDomain ? 0.5 : 0;+ }++ return 0;+ };++ return {+ fuzzyWeight: 0.5,+ timeWeight: 0.4,+ brevityWeight: 0.1,+ boostFn,+ };+}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.tsindex 8f38f6da84..2367c0d1df 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@@ -2,7 +2,7 @@ export type { DropdownOption } from './Dropdown';export { Dropdown } from './Dropdown';export {type CombinedEntity,- ENTITY_SEARCH_CONFIG,+ createEntitySearchConfig,entityMapper,getEntityName,getEntitySearchText,diff --git a/js/app/packages/core/component/Properties/component/propertyValue/BooleanValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/BooleanValue.tsxindex ccc2a54196..847ccd828c 100644--- a/js/app/packages/core/component/Properties/component/propertyValue/BooleanValue.tsx+++ b/js/app/packages/core/component/Properties/component/propertyValue/BooleanValue.tsx@@ -3,15 +3,18 @@ import type { Component } from 'solid-js';import { Show } from 'solid-js';import { useBooleanEditor } from '../../hooks';import type { Property } from '../../types';-import type { PropertyValueProps } from './ValueComponents';+import { stubSaveHandler, type PropertyValueProps } from './ValueComponents';/*** Display component for boolean properties with instant toggle* Treats null as false (unchecked)*/export const BooleanValue: Component<PropertyValueProps> = (props) => {+ const saveHandler = () => props.saveHandler ?? stubSaveHandler;+const { value, isSaving, toggle } = useBooleanEditor(props.property as Property & { valueType: 'BOOLEAN' },+ saveHandler(),props.onRefresh);diff --git a/js/app/packages/core/component/Properties/component/propertyValue/CondensedPropertyValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/CondensedPropertyValue.tsxindex 018d02337d..e9a3990c51 100644--- a/js/app/packages/core/component/Properties/component/propertyValue/CondensedPropertyValue.tsx+++ b/js/app/packages/core/component/Properties/component/propertyValue/CondensedPropertyValue.tsx@@ -1,15 +1,23 @@import { getSelectValues } from '@core/component/Properties/utils';import { PropertyValueIcon } from './PropertyValueIcon';import { Tooltip } from '@core/component/Tooltip';-import { usePropertiesContext } from '../../context/PropertiesContext';-import type { Component } from 'solid-js';+import type { Component, JSX } from 'solid-js';import { Show } from 'solid-js';import type { Property } from '../../types';import {hasValue,isSelectProperty,isEntityProperty,+ isDateProperty,+ isStringProperty,+ isNumberProperty,+ isBooleanProperty,} from '../../utils/typeGuards';+import {+ formatDate,+ formatNumber,+ formatBoolean,+} from '../../utils/formatting';import { PropertyTooltip } from './PropertyTooltip';import CircleDashedEmpty from '@icon/regular/circle-dashed.svg';import { UserGroup } from './UserGroup';@@ -17,6 +25,8 @@ import { cn } from '@ui/utils/classname';type CondensedPropertyValueProps = {property: Property;+ canEdit: boolean;+ onEdit?: (property: Property, anchor?: HTMLElement) => void;};/**@@ -26,16 +36,14 @@ type CondensedPropertyValueProps = {export const CondensedPropertyValue: Component<CondensedPropertyValueProps> = (props) => {- const { canEdit, openPropertyEditor } = usePropertiesContext();-const validValue = () => hasValue(props.property);const handleClick = (e: MouseEvent) => {- if (!canEdit) return;+ if (!props.canEdit) return;e.preventDefault();e.stopPropagation();const target = e.currentTarget as HTMLElement;- openPropertyEditor(props.property, target);+ props.onEdit?.(props.property, target);};return (@@ -48,13 +56,14 @@ export const CondensedPropertyValue: Component<CondensedPropertyValueProps> = (class={cn('inline-flex items-center text-xs leading-none text-ink-muted shrink-0 py-1.5 h-6.5 transition-colors border border-edge-muted/50 px-1.5',{- 'cursor-pointer hover:border-edge-muted hover:bg-hover/50': canEdit,+ 'cursor-pointer hover:border-edge-muted hover:bg-hover/50':+ props.canEdit,'opacity-50': !validValue(),})}onClick={handleClick}- role={canEdit ? 'button' : undefined}- tabIndex={canEdit ? 0 : undefined}+ role={props.canEdit ? 'button' : undefined}+ tabIndex={props.canEdit ? 0 : undefined}><CondensedIcon property={props.property} /></div>@@ -62,16 +71,28 @@ export const CondensedPropertyValue: Component<CondensedPropertyValueProps> = ();};-const CondensedIcon = (props: { property: Property }) => {- const internal = () => {+const CondensedIcon = (props: { property: Property }): JSX.Element => {+ const internal = (): JSX.Element | null => {if (!hasValue(props.property)) return null;+ // Entity properties - show user group or fallbackif (isEntityProperty(props.property)) {if (props.property.specificEntityType === 'USER') {return <UserGroup entities={props.property.value ?? []} maxUsers={2} />;}+ // For non-user entities, show count if multiple+ const count = props.property.value?.length ?? 0;+ if (count > 0) {+ return (+ <span class="truncate max-w-[100px]">+ {count === 1 ? '1 item' : `${count} items`}+ </span>+ );+ }+ return null;}+ // Select properties - show icon for first selected optionif (isSelectProperty(props.property)) {const values = getSelectValues(props.property);if (values.length > 0) {@@ -79,6 +100,48 @@ const CondensedIcon = (props: { property: Property }) => {}return null;}++ // Date properties - show formatted date+ if (isDateProperty(props.property)) {+ const value = props.property.value;+ if (value) {+ return <span class="truncate max-w-[100px]">{formatDate(value)}</span>;+ }+ return null;+ }++ // String properties - show truncated value+ if (isStringProperty(props.property)) {+ const value = props.property.value;+ if (value) {+ return <span class="truncate max-w-[100px]">{value}</span>;+ }+ return null;+ }++ // Number properties - show formatted number+ if (isNumberProperty(props.property)) {+ const value = props.property.value;+ if (value !== null) {+ return (+ <span class="truncate max-w-[100px]">{formatNumber(value)}</span>+ );+ }+ return null;+ }++ // Boolean properties - show True/False+ if (isBooleanProperty(props.property)) {+ const value = props.property.value;+ if (value !== null) {+ return (+ <span class="truncate max-w-[100px]">{formatBoolean(value)}</span>+ );+ }+ return null;+ }++ return null;};return (@@ -86,7 +149,7 @@ const CondensedIcon = (props: { property: Property }) => {when={internal()}fallback={<CircleDashedEmpty class="size-3 shrink-0" />}>- {(Icon) => Icon()}+ {(content) => content()}</Show>);};diff --git a/js/app/packages/core/component/Properties/component/propertyValue/DateValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/DateValue.tsxindex 71017ac901..c764271c9c 100644--- a/js/app/packages/core/component/Properties/component/propertyValue/DateValue.tsx+++ b/js/app/packages/core/component/Properties/component/propertyValue/DateValue.tsx@@ -1,10 +1,10 @@import type { Component } from 'solid-js';import { createSignal, Show } from 'solid-js';-import { usePropertiesContext } from '../../context/PropertiesContext';import { formatDate } from '../../utils';import {EmptyValue,PropertyValueDeleteButton,+ stubSaveHandler,type PropertyValueProps,} from './ValueComponents';import { cn } from '@ui/utils/classname';@@ -14,7 +14,7 @@ import { cn } from '@ui/utils/classname';* Opens date picker modal on click*/export const DateValue: Component<PropertyValueProps> = (props) => {- const { saveHandler } = usePropertiesContext();+ const saveHandler = () => props.saveHandler ?? stubSaveHandler;const [isHovered, setIsHovered] = createSignal(false);const [isSaving, setIsSaving] = createSignal(false);@@ -30,7 +30,7 @@ export const DateValue: Component<PropertyValueProps> = (props) => {setIsSaving(true);try {- await saveHandler.saveProperty(props.property, {+ await saveHandler().saveProperty(props.property, {valueType: 'DATE',value: null,});diff --git a/js/app/packages/core/component/Properties/component/propertyValue/EntityValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/EntityValue.tsxindex b8cf9f384f..229ac18014 100644--- a/js/app/packages/core/component/Properties/component/propertyValue/EntityValue.tsx+++ b/js/app/packages/core/component/Properties/component/propertyValue/EntityValue.tsx@@ -1,12 +1,12 @@import type { EntityReference } from '@service-properties/generated/schemas/entityReference';import type { Component } from 'solid-js';import { createSignal, For, Show } from 'solid-js';-import { usePropertiesContext } from '../../context/PropertiesContext';import { getEntityValues } from '../../utils';import { EntityIcon } from './EntityIcon';import {AddPropertyValueButton,EmptyValue,+ stubSaveHandler,type PropertyValueProps,} from './ValueComponents';@@ -15,7 +15,7 @@ import {* Shows entity badges and opens modal on click*/export const EntityValue: Component<PropertyValueProps> = (props) => {- const { saveHandler } = usePropertiesContext();+ const saveHandler = () => props.saveHandler ?? stubSaveHandler;const [isSaving, setIsSaving] = createSignal(false);const handleEditClick = (e: MouseEvent) => {@@ -43,7 +43,7 @@ export const EntityValue: Component<PropertyValueProps> = (props) => {entity.entity_type !== entityToRemove.entity_type);- await saveHandler.saveProperty(props.property, {+ await saveHandler().saveProperty(props.property, {valueType: 'ENTITY',refs: newValues.length > 0 ? newValues : null,});diff --git a/js/app/packages/core/component/Properties/component/propertyValue/LinkValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/LinkValue.tsxindex 731324c941..fe5303428a 100644--- a/js/app/packages/core/component/Properties/component/propertyValue/LinkValue.tsx+++ b/js/app/packages/core/component/Properties/component/propertyValue/LinkValue.tsx@@ -4,7 +4,6 @@ import { proxyResource } from '@service-unfurl/client';import type { Component } from 'solid-js';import { createSignal, For, Show } from 'solid-js';import { createStore } from 'solid-js/store';-import { usePropertiesContext } from '../../context/PropertiesContext';import {extractDomain,getLinkValues,@@ -15,11 +14,12 @@ import {AddPropertyValueButton,EmptyValue,PropertyValueDeleteButton,+ stubSaveHandler,type PropertyValueProps,} from './ValueComponents';export const LinkValue: Component<PropertyValueProps> = (props) => {- const { saveHandler } = usePropertiesContext();+ const saveHandler = () => props.saveHandler ?? stubSaveHandler;const [isAdding, setIsAdding] = createSignal(false);const [inputValue, setInputValue] = createSignal('');const [error, setError] = createSignal<string | null>(null);@@ -72,7 +72,7 @@ export const LinkValue: Component<PropertyValueProps> = (props) => {newValues = [normalized];}- await saveHandler.saveProperty(props.property, {+ await saveHandler().saveProperty(props.property, {valueType: 'LINK',values: newValues,});@@ -93,7 +93,7 @@ export const LinkValue: Component<PropertyValueProps> = (props) => {try {const newValues = linkValues.filter((link: string) => link !== url);- await saveHandler.saveProperty(props.property, {+ await saveHandler().saveProperty(props.property, {valueType: 'LINK',values: newValues.length > 0 ? newValues : null,});diff --git a/js/app/packages/core/component/Properties/component/propertyValue/NumberValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/NumberValue.tsxindex f22598b641..518cebe092 100644--- a/js/app/packages/core/component/Properties/component/propertyValue/NumberValue.tsx+++ b/js/app/packages/core/component/Properties/component/propertyValue/NumberValue.tsx@@ -2,14 +2,23 @@ import type { Component } from 'solid-js';import { Show } from 'solid-js';import { useInlineEditor } from '../../hooks';import { formatNumber } from '../../utils';-import { EmptyValue, type PropertyValueProps } from './ValueComponents';+import {+ EmptyValue,+ stubSaveHandler,+ type PropertyValueProps,+} from './ValueComponents';/*** Display component for number properties with inline editing* Numbers are formatted to 4 decimal places*/export const NumberValue: Component<PropertyValueProps> = (props) => {- const editor = useInlineEditor(props.property, props.onRefresh);+ const saveHandler = () => props.saveHandler ?? stubSaveHandler;+ const editor = useInlineEditor(+ props.property,+ saveHandler(),+ props.onRefresh+ );const supportsInline = () =>props.canEdit &&diff --git a/js/app/packages/core/component/Properties/component/propertyValue/PropertyValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/PropertyValue.tsxindex 6b9bbb3151..3f43f2a06c 100644--- a/js/app/packages/core/component/Properties/component/propertyValue/PropertyValue.tsx+++ b/js/app/packages/core/component/Properties/component/propertyValue/PropertyValue.tsx@@ -1,7 +1,11 @@+import type { EntityType } from '@service-properties/generated/schemas/entityType';import type { Component } from 'solid-js';import { Dynamic, Show } from 'solid-js/web';import { match } from 'ts-pattern';-import { usePropertiesContext } from '../../context/PropertiesContext';+import {+ usePropertiesContext,+ type PropertySaveHandler,+} from '../../context/PropertiesContext';import type { Property } from '../../types';import { BooleanValue } from './BooleanValue';import { CondensedPropertyValue } from './CondensedPropertyValue';@@ -11,6 +15,30 @@ import { LinkValue } from './LinkValue';import { NumberValue } from './NumberValue';import { SelectValue } from './SelectValue';import { TextValue } from './TextValue';+import { stubSaveHandler } from './ValueComponents';++/**+ * Attempts to use PropertiesContext, returning stub values if not within a provider+ */+function tryUsePropertiesContext(): {+ entityType?: EntityType;+ canEdit: boolean;+ onRefresh: () => void;+ saveHandler: PropertySaveHandler;+ openPropertyEditor: (property: Property, anchor?: HTMLElement) => void;+} {+ try {+ return usePropertiesContext();+ } catch {+ return {+ entityType: undefined,+ canEdit: false,+ onRefresh: () => {},+ saveHandler: stubSaveHandler,+ openPropertyEditor: () => {},+ };+ }+}/*** Router component that delegates to type-specific display components@@ -20,7 +48,7 @@ export const PropertyValue: Component<{onEdit?: (property: Property, anchor?: HTMLElement) => void;condensed?: boolean;}> = (props) => {- const { entityType, canEdit, onRefresh } = usePropertiesContext();+ const context = tryUsePropertiesContext();const expanded = () => !props.condensed;const valueComponent = () =>@@ -38,15 +66,22 @@ export const PropertyValue: Component<{return (<Showwhen={expanded()}- fallback={<CondensedPropertyValue property={props.property} />}+ fallback={+ <CondensedPropertyValue+ property={props.property}+ canEdit={context.canEdit}+ onEdit={props.onEdit ?? context.openPropertyEditor}+ />+ }><Dynamiccomponent={valueComponent()}property={props.property}- canEdit={canEdit}- entityType={entityType}+ canEdit={context.canEdit}+ entityType={context.entityType}onEdit={props.onEdit}- onRefresh={onRefresh}+ onRefresh={context.onRefresh}+ saveHandler={context.saveHandler}/></Show>);diff --git a/js/app/packages/core/component/Properties/component/propertyValue/SelectValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/SelectValue.tsxindex be0e208c26..c667273de4 100644--- a/js/app/packages/core/component/Properties/component/propertyValue/SelectValue.tsx+++ b/js/app/packages/core/component/Properties/component/propertyValue/SelectValue.tsx@@ -1,6 +1,5 @@import type { Component } from 'solid-js';import { createSignal, For, Show } from 'solid-js';-import { usePropertiesContext } from '../../context/PropertiesContext';import { PROPERTY_STYLES } from '../../styles/styles';import { formatPropertyValue, getSelectValues } from '../../utils';import { PropertyValueIcon } from './PropertyValueIcon';@@ -8,6 +7,7 @@ import {AddPropertyValueButton,EmptyValue,PropertyValueDeleteButton,+ stubSaveHandler,type PropertyValueProps,} from './ValueComponents';@@ -16,7 +16,7 @@ import {* Opens options modal on click*/export const SelectValue: Component<PropertyValueProps> = (props) => {- const { saveHandler } = usePropertiesContext();+ const saveHandler = () => props.saveHandler ?? stubSaveHandler;const [hoveredValue, setHoveredValue] = createSignal<string | null>(null);const [isSaving, setIsSaving] = createSignal(false);@@ -40,7 +40,7 @@ export const SelectValue: Component<PropertyValueProps> = (props) => {return;}- await saveHandler.saveProperty(props.property, {+ await saveHandler().saveProperty(props.property, {valueType,values: newValues.length > 0 ? newValues : null,});diff --git a/js/app/packages/core/component/Properties/component/propertyValue/TextValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/TextValue.tsxindex 054221a95d..184f82f3da 100644--- a/js/app/packages/core/component/Properties/component/propertyValue/TextValue.tsx+++ b/js/app/packages/core/component/Properties/component/propertyValue/TextValue.tsx@@ -2,13 +2,22 @@ import type { Component } from 'solid-js';import { Show } from 'solid-js';import { useInlineEditor } from '../../hooks';import { formatPropertyValue } from '../../utils';-import { EmptyValue, type PropertyValueProps } from './ValueComponents';+import {+ EmptyValue,+ type PropertyValueProps,+ stubSaveHandler,+} from './ValueComponents';/*** Display component for string properties with inline editing*/export const TextValue: Component<PropertyValueProps> = (props) => {- const editor = useInlineEditor(props.property, props.onRefresh);+ const saveHandler = () => props.saveHandler ?? stubSaveHandler;+ const editor = useInlineEditor(+ props.property,+ saveHandler(),+ props.onRefresh+ );const supportsInline = () =>props.canEdit &&@@ -66,6 +75,7 @@ export const TextValue: Component<PropertyValueProps> = (props) => {el.setSelectionRange(el.value.length, el.value.length);}, 0);}}+ placeholder={`Set ${props.property.displayName}...`}value={editor.inputValue()}onInput={(e) => editor.setInputValue(e.currentTarget.value)}onBlur={editor.save}diff --git a/js/app/packages/core/component/Properties/component/propertyValue/ValueComponents.tsx b/js/app/packages/core/component/Properties/component/propertyValue/ValueComponents.tsxindex b1688241da..838941900e 100644--- a/js/app/packages/core/component/Properties/component/propertyValue/ValueComponents.tsx+++ b/js/app/packages/core/component/Properties/component/propertyValue/ValueComponents.tsx@@ -4,17 +4,27 @@ import type { EntityType } from '@service-properties/generated/schemas/entityTypimport { Button } from '@ui/components/Button';import type { Component, JSX } from 'solid-js';import { twMerge } from 'tailwind-merge';+import type { PropertySaveHandler } from '../../context/PropertiesContext';import type { Property } from '../../types';+/**+ * Stub save handler for read-only contexts.+ */+export const stubSaveHandler: PropertySaveHandler = {+ saveProperty: async () => {},+ saveDate: async () => {},+};+/*** Shared props type for all property value display components*/export type PropertyValueProps = {property: Property;canEdit: boolean;- entityType: EntityType;+ entityType?: EntityType;onEdit?: (property: Property, anchor?: HTMLElement) => void;onRefresh?: () => void;+ saveHandler?: PropertySaveHandler;};/**diff --git a/js/app/packages/core/component/Properties/hooks/useBooleanEditor.ts b/js/app/packages/core/component/Properties/hooks/useBooleanEditor.tsindex ad3c82c81b..38557cd9ac 100644--- a/js/app/packages/core/component/Properties/hooks/useBooleanEditor.ts+++ b/js/app/packages/core/component/Properties/hooks/useBooleanEditor.ts@@ -1,5 +1,5 @@import { type Accessor, createMemo, createSignal } from 'solid-js';-import { usePropertiesContext } from '../context/PropertiesContext';+import type { PropertySaveHandler } from '../context/PropertiesContext';import type { Property } from '../types';/**@@ -11,13 +11,13 @@ import type { Property } from '../types';*/export function useBooleanEditor(property: Property & { valueType: 'BOOLEAN' },+ saveHandler: PropertySaveHandler,onSaved?: () => void): {value: Accessor<boolean | null>;isSaving: Accessor<boolean>;toggle: () => Promise<void>;} {- const { saveHandler } = usePropertiesContext();const [isSaving, setIsSaving] = createSignal(false);const currentValue = createMemo(() => {diff --git a/js/app/packages/core/component/Properties/hooks/useInlineEditor.ts b/js/app/packages/core/component/Properties/hooks/useInlineEditor.tsindex 3c3ea23cf6..98c168e6e1 100644--- a/js/app/packages/core/component/Properties/hooks/useInlineEditor.ts+++ b/js/app/packages/core/component/Properties/hooks/useInlineEditor.ts@@ -1,6 +1,6 @@import { type Accessor, createSignal, type Setter } from 'solid-js';import { NUMBER_DECIMAL_PLACES } from '../constants';-import { usePropertiesContext } from '../context/PropertiesContext';+import type { PropertySaveHandler } from '../context/PropertiesContext';import type { Property, PropertyApiValues } from '../types';import { formatPropertyValue } from '../utils';@@ -13,6 +13,7 @@ import { formatPropertyValue } from '../utils';*/export function useInlineEditor(property: Property,+ saveHandler: PropertySaveHandler,onSaved?: () => void): {isEditing: Accessor<boolean>;@@ -23,7 +24,6 @@ export function useInlineEditor(cancelEdit: () => void;save: () => Promise<void>;} {- const { saveHandler } = usePropertiesContext();const [isEditing, setIsEditing] = createSignal(false);const [inputValue, setInputValue] = createSignal('');const [isSaving, setIsSaving] = createSignal(false);diff --git a/js/app/packages/core/component/Properties/utils/entityConversion.ts b/js/app/packages/core/component/Properties/utils/entityConversion.tsindex 4054a59df7..5217214eec 100644--- a/js/app/packages/core/component/Properties/utils/entityConversion.ts+++ b/js/app/packages/core/component/Properties/utils/entityConversion.ts@@ -1,5 +1,6 @@+import { type EntityData, isTaskEntity } from '@macro-entity';import type { EntityReference } from '@service-properties/generated/schemas/entityReference';-import type { EntityType } from '@service-properties/generated/schemas/entityType';+import { EntityType } from '@service-properties/generated/schemas/entityType';import type { ItemType } from '@service-storage/client';import { match } from 'ts-pattern';@@ -59,3 +60,16 @@ export function entityTypeToItemType(type: EntityType): ItemType | undefined {.with('THREAD', () => 'email' as ItemType).exhaustive();}++export function macroEntityToPropertyEntityType(+ entity: EntityData+): EntityType {+ return match(entity)+ .when(isTaskEntity, () => EntityType.TASK)+ .with({ type: 'channel' }, () => EntityType.CHANNEL)+ .with({ type: 'chat' }, () => EntityType.CHAT)+ .with({ type: 'project' }, () => EntityType.PROJECT)+ .with({ type: 'email' }, () => EntityType.THREAD)+ .with({ type: 'document' }, () => EntityType.DOCUMENT)+ .exhaustive();+}diff --git a/js/app/packages/core/component/Properties/utils/transforms.ts b/js/app/packages/core/component/Properties/utils/transforms.tsindex 4b59e9dbb7..ee8f4de858 100644--- a/js/app/packages/core/component/Properties/utils/transforms.ts+++ b/js/app/packages/core/component/Properties/utils/transforms.ts@@ -1,6 +1,7 @@import type { PropertyDefinition } from '@service-properties/generated/schemas/propertyDefinition';import type { PropertyOption } from '@service-properties/generated/schemas/propertyOption';-import type { PropertyDefinitionDomain, ValueType } from '../types';+import type { Property, PropertyDefinitionDomain, ValueType } from '../types';+import { nanoid } from 'nanoid';/*** Transforms a backend PropertyDefinition (snake_case) to the frontend@@ -30,3 +31,23 @@ export function toPropertyDefinitionDomain(updatedAt: definition.updated_at,};}++export function propertyDefinitionDomainToProperty(+ propertyDefinition: PropertyDefinitionDomain+): Property {+ return {+ propertyId: nanoid(8),+ propertyDefinitionId: propertyDefinition.id,+ displayName: propertyDefinition.displayName,+ isMultiSelect: propertyDefinition.isMultiSelect,+ isMetadata: propertyDefinition.isMetadata,+ isSystemProperty: propertyDefinition.isSystem,+ options: propertyDefinition.options,+ owner: propertyDefinition.owner,+ specificEntityType: propertyDefinition.specificEntityType,+ createdAt: propertyDefinition.createdAt,+ updatedAt: propertyDefinition.updatedAt,+ valueType: propertyDefinition.valueType,+ value: null,+ };+}diff --git a/js/app/packages/core/component/Properties/utils/typeGuards.ts b/js/app/packages/core/component/Properties/utils/typeGuards.tsindex 4e374bc9dd..acdc300583 100644--- a/js/app/packages/core/component/Properties/utils/typeGuards.ts+++ b/js/app/packages/core/component/Properties/utils/typeGuards.ts@@ -1,3 +1,4 @@+import { match } from 'ts-pattern';import type { EntityReference } from '@service-properties/generated/schemas/entityReference';import type { PropertyDefinition } from '@service-properties/generated/schemas/propertyDefinition';import type { PropertyDefinitionResponse } from '@service-properties/generated/schemas/propertyDefinitionResponse';@@ -9,6 +10,8 @@ import type {MultiValueProperty,NumberProperty,Property,+ PropertyApiValues,+ PropertyDefinitionDomain,SelectNumberProperty,SelectProperty,SelectStringProperty,@@ -192,6 +195,12 @@ export function isPropertyDefinition(return !('definition' in p);}+export function isInstantiatedProperty(+ p: Property | PropertyDefinitionDomain+): p is Property {+ return 'propertyDefinitionId' in p;+}+export const hasValue = (property: Property): boolean => {if (property.value === null) {return false;@@ -211,3 +220,130 @@ export const hasSingleValue = (property: MultiValueProperty): boolean => {export const hasMultiValue = (property: MultiValueProperty): boolean => {return property.value !== null && property.value.length > 1;};++/**+ * Raw input value types that can be converted to PropertyApiValues+ */+type RawPropertyValue =+ | string+ | number+ | boolean+ | Date+ | string[]+ | EntityReference+ | EntityReference[]+ | null;++/**+ * Type guard to check if a value is a single EntityReference+ */+function isSingleEntityReference(value: unknown): value is EntityReference {+ return (+ value !== null &&+ typeof value === 'object' &&+ !Array.isArray(value) &&+ 'entity_id' in value &&+ 'entity_type' in value+ );+}++/**+ * Creates a null-valued PropertyApiValues for the given valueType+ */+function createNullApiValue(+ valueType: Property['valueType']+): PropertyApiValues {+ return match(valueType)+ .with('STRING', () => ({ valueType: 'STRING' as const, value: null }))+ .with('NUMBER', () => ({ valueType: 'NUMBER' as const, value: null }))+ .with('BOOLEAN', () => ({ valueType: 'BOOLEAN' as const, value: null }))+ .with('DATE', () => ({ valueType: 'DATE' as const, value: null }))+ .with('SELECT_STRING', () => ({+ valueType: 'SELECT_STRING' as const,+ values: null,+ }))+ .with('SELECT_NUMBER', () => ({+ valueType: 'SELECT_NUMBER' as const,+ values: null,+ }))+ .with('ENTITY', () => ({ valueType: 'ENTITY' as const, refs: null }))+ .with('LINK', () => ({ valueType: 'LINK' as const, values: null }))+ .exhaustive();+}++/**+ * Validates and converts a raw value to the appropriate PropertyApiValues format+ * based on the property's valueType.+ * @param property - The property definition (used to determine valueType)+ * @param value - The raw value to convert+ * @returns A valid PropertyApiValues object, or null if the value type is incompatible+ */+export function toPropertyApiValue(+ property: Pick<Property, 'valueType'>,+ value: RawPropertyValue+): PropertyApiValues | null {+ const { valueType } = property;++ if (value === null) {+ return createNullApiValue(valueType);+ }++ return match(valueType)+ .with('STRING', () =>+ typeof value === 'string' ? { valueType: 'STRING' as const, value } : null+ )+ .with('NUMBER', () =>+ typeof value === 'number' ? { valueType: 'NUMBER' as const, value } : null+ )+ .with('BOOLEAN', () =>+ typeof value === 'boolean'+ ? { valueType: 'BOOLEAN' as const, value }+ : null+ )+ .with('DATE', () => {+ if (typeof value === 'string') {+ return { valueType: 'DATE' as const, value };+ }+ if (value instanceof Date) {+ return { valueType: 'DATE' as const, value: value.toISOString() };+ }+ return null;+ })+ .with('SELECT_STRING', () => {+ if (typeof value === 'string') {+ return { valueType: 'SELECT_STRING' as const, values: [value] };+ }+ if (isStringArray(value)) {+ return { valueType: 'SELECT_STRING' as const, values: value };+ }+ return null;+ })+ .with('SELECT_NUMBER', () => {+ if (typeof value === 'string') {+ return { valueType: 'SELECT_NUMBER' as const, values: [value] };+ }+ if (isStringArray(value)) {+ return { valueType: 'SELECT_NUMBER' as const, values: value };+ }+ return null;+ })+ .with('ENTITY', () => {+ if (isEntityReferenceArray(value)) {+ return { valueType: 'ENTITY' as const, refs: value };+ }+ if (isSingleEntityReference(value)) {+ return { valueType: 'ENTITY' as const, refs: [value] };+ }+ return null;+ })+ .with('LINK', () => {+ if (typeof value === 'string') {+ return { valueType: 'LINK' as const, values: [value] };+ }+ if (isStringArray(value)) {+ return { valueType: 'LINK' as const, values: value };+ }+ return null;+ })+ .exhaustive();+}diff --git a/js/app/packages/core/hotkey/tokens.ts b/js/app/packages/core/hotkey/tokens.tsindex 6f304a953b..0c22337b9e 100644--- a/js/app/packages/core/hotkey/tokens.ts+++ b/js/app/packages/core/hotkey/tokens.ts@@ -46,6 +46,10 @@ export const TOKENS = {rename: 'entity.action.rename',moveToFolder: 'entity.action.moveToFolder',copy: 'entity.action.copy',+ properties: 'entity.action.properties',+ priority: 'entity.action.priority',+ status: 'entity.action.status',+ assignee: 'entity.action.assignee',},},diff --git a/js/app/packages/macro-entity/src/components/InlineEntity.tsx b/js/app/packages/macro-entity/src/components/InlineEntity.tsxnew file mode 100644index 0000000000..a116731a8d--- /dev/null+++ b/js/app/packages/macro-entity/src/components/InlineEntity.tsx@@ -0,0 +1,35 @@+import { createMemo } from 'solid-js';+import type { EntityData } from '../types/entity';+import { getIconConfig } from '@core/component/EntityIcon';+import { cn } from '@ui/utils/classname';+import { Dynamic } from 'solid-js/web';+import { match } from 'ts-pattern';++export function InlineEntity(props: { entity: EntityData }) {+ const iconConfig = createMemo<ReturnType<typeof getIconConfig>>(() => {+ return match(props.entity)+ .with({ type: 'channel', channelType: 'direct_message' }, () =>+ getIconConfig('directMessage')+ )+ .with({ type: 'channel', channelType: 'organization' }, () =>+ getIconConfig('company')+ )+ .with({ type: 'channel' }, () => getIconConfig('channel'))+ .with({ type: 'document' }, (entity) =>+ getIconConfig(entity.subType?.type ?? entity.fileType ?? 'default')+ )+ .with({ type: 'email', isRead: true }, () => getIconConfig('emailRead'))+ .with({ type: 'email' }, () => getIconConfig('email'))+ .otherwise((entity) => getIconConfig(entity.type));+ });++ return (+ <div class="flex items-center gap-2 min-w-0">+ <Dynamic+ component={iconConfig().icon}+ class={cn('flex shrink-0 size-[1em]', iconConfig().foreground)}+ />+ <span class="truncate">{props.entity.name}</span>+ </div>+ );+}diff --git a/js/app/packages/queries/properties/entity.ts b/js/app/packages/queries/properties/entity.tsindex fd521ca74a..3c652a1db7 100644--- a/js/app/packages/queries/properties/entity.ts+++ b/js/app/packages/queries/properties/entity.ts@@ -441,3 +441,73 @@ export function useSetPropertyStatusCompleteMutation(: {}),}));}++export type BulkSaveEntityPropertiesParams = {+ properties: Array<{+ entityId: string;+ entityType: EntityType;+ property: { id: string; isMultiSelect: boolean };+ apiValues: PropertyApiValues;+ }>;+};++/** Saves multiple entity properties in bulk using parallel requests */+export function useBulkSaveEntityPropertiesMutation(+ callbacks?: MutationCallbacks<void, Error, BulkSaveEntityPropertiesParams>+) {+ return useMutation(() => ({+ mutationFn: async (vars: BulkSaveEntityPropertiesParams) => {+ await Promise.all(+ vars.properties.map((item) => {+ const propertyValue = propertyValueToApi(+ item.apiValues,+ item.property.isMultiSelect+ );++ return throwOnErr(+ async () =>+ await propertiesServiceClient.setEntityProperty({+ entity_type: item.entityType,+ entity_id: item.entityId,+ property_id: item.property.id,+ body: {+ value: propertyValue,+ },+ })+ );+ })+ );+ },+ ...withCallbacks<void, Error, BulkSaveEntityPropertiesParams>(+ {+ onError(error) {+ console.error('Failed to bulk save properties', error);+ toast.failure('Failed to save properties');+ },+ onSettled: (_data, error, variables) => {+ if (error) {+ console.error('Failed bulk save properties', variables, error);+ toast.failure('Failed to save properties');+ }++ // Invalidate queries for all affected entities+ const entityGroups = new Map<EntityType, Set<string>>();++ variables.properties.forEach((p) => {+ if (!entityGroups.has(p.entityType)) {+ entityGroups.set(p.entityType, new Set());+ }+ entityGroups.get(p.entityType)!.add(p.entityId);+ });++ entityGroups.forEach((entityIds, entityType) => {+ entityIds.forEach((entityId) => {+ invalidatePropertiesForEntity(entityType, entityId);+ });+ });+ },+ },+ callbacks+ ),+ }));+}