Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(properties): show a picked entity's name instead of "Loading…" (#9195)
gbirman0c71f524af61
diff --git a/apps/web/src/features/block-md/component/InlineTaskProperties.test.tsx b/apps/web/src/features/block-md/component/InlineTaskProperties.test.tsxindex b8cb4f8d8f..5ef41e834a 100644--- a/apps/web/src/features/block-md/component/InlineTaskProperties.test.tsx+++ b/apps/web/src/features/block-md/component/InlineTaskProperties.test.tsx@@ -401,6 +401,29 @@ it('updates task title chips in place when the properties emit new objects', asy);});+it('keeps the Project chip mounted when saving assigns its placeholder an ID', async () => {+ mocks.kind = 'task';+ mocks.projectsEnabled = true;+ setup(taskProperties);+ const project = await screen.findByRole('button', { name: 'Unpin Project' });++ mocks.setProperties?.([+ ...taskProperties,+ {+ ...property,+ propertyId: 'project-assignment',+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.PROJECT,+ displayName: 'Project saved',+ },+ ]);++ await waitFor(() =>+ expect(screen.getByRole('button', { name: 'Unpin Project saved' })).toBe(+ project+ )+ );+});+it('keeps all task title pins cleared after serialization and reopening', async () => {mocks.kind = 'task';const editor = setup(taskProperties);diff --git a/apps/web/src/features/block-md/component/InlineTaskProperties.tsx b/apps/web/src/features/block-md/component/InlineTaskProperties.tsxindex c3c0aa0f6d..0e6557ca1b 100644--- a/apps/web/src/features/block-md/component/InlineTaskProperties.tsx+++ b/apps/web/src/features/block-md/component/InlineTaskProperties.tsx@@ -181,7 +181,8 @@ export function InlineTaskProperties() {size="xs"showAddButton={documentKind === 'document' && canEdit()}/>- <Key each={inlineProperties()} by="propertyId">+ {/* A placeholder keeps its chip, and a pick in it, when saving assigns its ID. */}+ <Key each={inlineProperties()} by="propertyDefinitionId">{(property) => (<InlinePropertyValueproperty={property()}diff --git a/apps/web/src/features/property/README.md b/apps/web/src/features/property/README.mdindex 2fd311edaf..cdd9d24e03 100644--- a/apps/web/src/features/property/README.md+++ b/apps/web/src/features/property/README.md@@ -11,7 +11,12 @@ Debug page: `/props-debug` (LOCAL_ONLY).`Property.Root` shows a pick from the moment an editor saves it until the savesettles and the source emits a newer property, and drops it if the save fails.-Pass its children as a function (`{(property) => ...}`) and render from that+The entity editor also passes the names its picker showed, and `Property.Text`+and `ProjectLinkPill` show them while the picked entity's own read loads, so a+pick never reads "Loading…". This holds only while the Root stays mounted: key rows by+definition ID, not property ID or object identity, so a property's first save+(which assigns its ID) and later emissions keep the same Root. Pass its+children as a function (`{(property) => ...}`) and render from thatproperty, not the prop you passed in. Save handlers keep their own cachescurrent, so `Property.Root` editors never refetch properties after a save;side-panel collections own their refresh (below).diff --git a/apps/web/src/features/property/component/ProjectLinkPill.test.tsx b/apps/web/src/features/property/component/ProjectLinkPill.test.tsxindex adf9e52348..9f4b40a1e6 100644--- a/apps/web/src/features/property/component/ProjectLinkPill.test.tsx+++ b/apps/web/src/features/property/component/ProjectLinkPill.test.tsx@@ -1,3 +1,4 @@+import { fireAndForget } from '@core/util/fireAndForget';import {cleanup,fireEvent,@@ -25,8 +26,12 @@ vi.mock('@components/app/split-layout/layout', () => ({useSplitLayout: () => 'layout',}));vi.mock('../hooks', () => ({- usePropertyEntityDisplay: () => ({- name: () => 'Launch',+ usePropertyEntityDisplay: (+ _id: () => string,+ _type: () => string,+ options?: { loadingName?: () => string | undefined }+ ) => ({+ name: () => (mocks.isLoading() && options?.loadingName?.()) || 'Launch',nativeProjectId: () => mocks.nativeProjectId(),isLoading: () => mocks.isLoading(),}),@@ -171,3 +176,49 @@ it('keeps the caret mounted while a picked project loads', () => {fireEvent.click(screen.getByRole('button', { name: 'Open project Launch' }));expect(mocks.openProject).toHaveBeenCalledOnce();});++it('names a picked project from its picker while its own read loads', () => {+ mocks.nativeProjectId = () => undefined;+ mocks.isLoading = () => true;+ function PickProject() {+ const ctx = useProperty();+ const pick = async () => {+ await ctx.onSave?.(+ ctx.property(),+ {+ valueType: 'ENTITY',+ refs: [{ entity_id: 'redesign', entity_type: 'INITIATIVE' }],+ },+ new Map([['redesign', 'Website redesign']])+ );+ };+ return (+ <button onClick={() => fireAndForget(pick(), 'project-link-pill-test')}>+ Pick redesign+ </button>+ );+ }+ render(() => (+ <Root+ property={project}+ canEdit+ onSave={() => Promise.withResolvers<void>().promise}+ >+ {(shown) => (+ <>+ <ProjectLinkPill+ property={shown()}+ fallback={<span>Plain pill</span>}+ />+ <PickProject />+ </>+ )}+ </Root>+ ));++ fireEvent.click(screen.getByText('Pick redesign'));++ expect(+ screen.getByRole('button', { name: 'Open project Website redesign' })+ ).toBeTruthy();+});diff --git a/apps/web/src/features/property/component/ProjectLinkPill.tsx b/apps/web/src/features/property/component/ProjectLinkPill.tsxindex 10c551afe1..4a89f753c3 100644--- a/apps/web/src/features/property/component/ProjectLinkPill.tsx+++ b/apps/web/src/features/property/component/ProjectLinkPill.tsx@@ -30,7 +30,8 @@ export function ProjectLinkPill(props: {const reference = () => getEntityValues(props.property)[0];const { name, nativeProjectId, isLoading } = usePropertyEntityDisplay(() => reference()?.entity_id ?? '',- () => 'INITIATIVE'+ () => 'INITIATIVE',+ { loadingName: () => ctx.pickedEntityName(reference()?.entity_id ?? '') });const open = (event: MouseEvent) => {event.stopPropagation();diff --git a/apps/web/src/features/property/core/Root.test.tsx b/apps/web/src/features/property/core/Root.test.tsxindex 20508b7466..de2e68b27b 100644--- a/apps/web/src/features/property/core/Root.test.tsx+++ b/apps/web/src/features/property/core/Root.test.tsx@@ -2,7 +2,7 @@ import { fireAndForget } from '@core/util/fireAndForget';import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';import { createSignal } from 'solid-js';import { afterEach, expect, it, vi } from 'vitest';-import type { SelectProperty } from '../types';+import type { EntityProperty, SelectProperty } from '../types';import { getSelectValues } from '../utils/typeGuards';import { useProperty } from './context';import { Root } from './Root';@@ -123,6 +123,100 @@ it('keeps a saving pick through ID assignment but not on another property', () =expect(shown()).toBe('todo');});+const project: EntityProperty = {+ propertyId: 'project-assignment',+ propertyDefinitionId: 'project-definition',+ displayName: 'Project',+ isMultiSelect: false,+ owner: { scope: 'system' },+ createdAt: new Date(0),+ updatedAt: new Date(0),+ valueType: 'ENTITY',+ specificEntityType: 'INITIATIVE',+ value: [{ entity_id: 'launch', entity_type: 'INITIATIVE' }],+};++function PickProject() {+ const ctx = useProperty();+ const pick = async () => {+ try {+ await ctx.onSave?.(+ ctx.property(),+ {+ valueType: 'ENTITY',+ refs: [{ entity_id: 'redesign', entity_type: 'INITIATIVE' }],+ },+ new Map([['redesign', 'Website redesign']])+ );+ } catch {+ // Each test settles its saves.+ }+ };+ return (+ <>+ <output>{ctx.pickedEntityName('redesign')}</output>+ <button onClick={() => fireAndForget(pick(), 'property-root-test')}>+ Pick redesign+ </button>+ </>+ );+}++it('names a picked entity until its own read can answer, on its property only', async () => {+ const [source, setSource] = createSignal<EntityProperty>(project);+ const saves: PromiseWithResolvers<void>[] = [];+ const onSave = vi.fn(() => {+ const save = Promise.withResolvers<void>();+ saves.push(save);+ return save.promise;+ });+ render(() => (+ <Root property={source()} canEdit onSave={onSave}>+ <PickProject />+ </Root>+ ));+ const pickedName = () => screen.getByRole('status').textContent;++ fireEvent.click(screen.getByText('Pick redesign'));+ expect(pickedName()).toBe('Website redesign');+ expect(onSave).toHaveBeenCalledExactlyOnceWith(project, {+ valueType: 'ENTITY',+ refs: [{ entity_id: 'redesign', entity_type: 'INITIATIVE' }],+ });++ saves[0].resolve();+ await saves[0].promise;+ // The source can show the pick before the chip's own read answers.+ setSource({+ ...project,+ value: [{ entity_id: 'redesign', entity_type: 'INITIATIVE' }],+ });+ expect(pickedName()).toBe('Website redesign');++ setSource({+ ...project,+ propertyId: 'status-assignment',+ propertyDefinitionId: 'status-definition',+ });+ expect(pickedName()).toBe('');+});++it('drops the picked names when their save fails', async () => {+ const save = Promise.withResolvers<void>();+ render(() => (+ <Root property={project} canEdit onSave={() => save.promise}>+ <PickProject />+ </Root>+ ));++ fireEvent.click(screen.getByText('Pick redesign'));+ expect(screen.getByRole('status').textContent).toBe('Website redesign');++ save.reject(new Error('rejected'));+ await expect(save.promise).rejects.toThrow('rejected');+ expect(screen.getByRole('status').textContent).toBe('');+});+function EditorToggle() {const ctx = useProperty();return (diff --git a/apps/web/src/features/property/core/Root.tsx b/apps/web/src/features/property/core/Root.tsxindex 4703c742b3..618497b9f2 100644--- a/apps/web/src/features/property/core/Root.tsx+++ b/apps/web/src/features/property/core/Root.tsx@@ -13,6 +13,7 @@ import type { Property, PropertyApiValues } from '../types';import { withApiValues } from '../utils/transforms';import {type PropertyEditFn,+ type PropertyPickFn,PropertyRootContext,type PropertyRootContextValue,type PropertySaveFn,@@ -43,6 +44,16 @@ type PendingValue = {base?: Property;};+/**+ * The names the last pick's picker showed, by entity ID. They outlive the+ * pending value: a chip's own read can answer after the source shows the pick,+ * and chips use these names only while that read loads.+ */+type PickedNames = {+ names: ReadonlyMap<string, string>;+ propertyDefinitionId: string;+};+export function Root(props: PropertyRootProps) {const [local, rest] = splitProps(props, ['property',@@ -71,8 +82,9 @@ export function Root(props: PropertyRootProps) {? withApiValues(local.property, current.value): local.property;});+ const [picked, setPicked] = createSignal<PickedNames>();- const save: PropertySaveFn = async (saved, value) => {+ const save: PropertyPickFn = async (saved, value, entityNames) => {const onSave = local.onSave;if (!onSave) return;const entry: PendingValue = {@@ -80,11 +92,20 @@ export function Root(props: PropertyRootProps) {propertyDefinitionId: saved.propertyDefinitionId,};setPending(entry);+ setPicked(+ entityNames && {+ names: entityNames,+ propertyDefinitionId: saved.propertyDefinitionId,+ }+ );try {await onSave(saved, value);if (pending() === entry) setPending({ ...entry, base: local.property });} catch (error) {- if (pending() === entry) setPending(undefined);+ if (pending() === entry) {+ setPending(undefined);+ setPicked(undefined);+ }throw error;}};@@ -131,6 +152,13 @@ export function Root(props: PropertyRootProps) {const value: PropertyRootContextValue = {property,+ pickedEntityName: (entityId) => {+ const current = picked();+ return current?.propertyDefinitionId ===+ local.property.propertyDefinitionId+ ? current.names.get(entityId)+ : undefined;+ },canEdit: () => local.canEdit ?? false,get onSave() {return local.onSave && save;diff --git a/apps/web/src/features/property/core/context.ts b/apps/web/src/features/property/core/context.tsindex 7ae5068b8e..52d1c67807 100644--- a/apps/web/src/features/property/core/context.ts+++ b/apps/web/src/features/property/core/context.ts@@ -6,14 +6,26 @@ export type PropertySaveFn = (value: PropertyApiValues) => Promise<void>;+/**+ * Saves a pick. An entity editor also passes the names its picker showed, by+ * entity ID, so the pick can be named before the entity's own read loads.+ */+export type PropertyPickFn = (+ property: Property,+ value: PropertyApiValues,+ entityNames?: ReadonlyMap<string, string>+) => Promise<void>;+export type PropertyEditFn = (property: Property, anchor?: HTMLElement) => void;export interface PropertyRootContextValue {/** The property as shown: a pick still saving replaces the source value. */property: () => Property;+ /** The name the picker showed for an entity in the pick being shown. */+ pickedEntityName: (entityId: string) => string | undefined;canEdit: () => boolean;/** Saves through the consumer's handler and shows the pick until then. */- onSave?: PropertySaveFn;+ onSave?: PropertyPickFn;onEdit?: PropertyEditFn;// Local editor open state. Populated by EditTrigger when the consumer hasn'tdiff --git a/apps/web/src/features/property/editors/popover/EntityEditor.test.tsx b/apps/web/src/features/property/editors/popover/EntityEditor.test.tsxindex 9b6e5a2940..81fe6e19e9 100644--- a/apps/web/src/features/property/editors/popover/EntityEditor.test.tsx+++ b/apps/web/src/features/property/editors/popover/EntityEditor.test.tsx@@ -148,6 +148,7 @@ function setup(const [editorOpen, setEditorOpen] = createSignal(true);const context: PropertyRootContextValue = {property: () => value,+ pickedEntityName: () => undefined,canEdit: () => true,editorOpen,openEditor: () => setEditorOpen(true),@@ -200,13 +201,17 @@ describe('assigning an agent through task and project properties', () => {expect(onSave).not.toHaveBeenCalled();fireEvent.click(screen.getByText('Dismiss'));await waitFor(() =>- expect(onSave).toHaveBeenCalledExactlyOnceWith(property, {- valueType: 'ENTITY',- refs: [- { entity_id: userId, entity_type: 'USER' },- { entity_id: agentId, entity_type: 'USER' },- ],- })+ expect(onSave).toHaveBeenCalledExactlyOnceWith(+ property,+ {+ valueType: 'ENTITY',+ refs: [+ { entity_id: userId, entity_type: 'USER' },+ { entity_id: agentId, entity_type: 'USER' },+ ],+ },+ new Map([[agentId, 'Research assistant']])+ ));});@@ -226,10 +231,11 @@ describe('assigning an agent through task and project properties', () => {fireEvent.click(screen.getByText('Research assistant'));fireEvent.click(screen.getByText('Dismiss'));await waitFor(() =>- expect(onSave).toHaveBeenCalledExactlyOnceWith(assigned, {- valueType: 'ENTITY',- refs: null,- })+ expect(onSave).toHaveBeenCalledExactlyOnceWith(+ assigned,+ { valueType: 'ENTITY', refs: null },+ new Map([[agentId, 'Research assistant']])+ ));});@@ -267,35 +273,60 @@ describe('people in a picker sheet', () => {fireEvent.click(screen.getByText('Research assistant'));fireEvent.click(screen.getByText('Done'));await waitFor(() =>- expect(onSave).toHaveBeenCalledExactlyOnceWith(property, {- valueType: 'ENTITY',- refs: [- { entity_id: userId, entity_type: 'USER' },- { entity_id: agentId, entity_type: 'USER' },- ],- })+ expect(onSave).toHaveBeenCalledExactlyOnceWith(+ property,+ {+ valueType: 'ENTITY',+ refs: [+ { entity_id: userId, entity_type: 'USER' },+ { entity_id: agentId, entity_type: 'USER' },+ ],+ },+ new Map([[agentId, 'Research assistant']])+ ));});});describe('the Project property', () => {+ const project: EntityProperty = {+ ...property,+ propertyId: 'project-property',+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.PROJECT,+ displayName: 'Project',+ isMultiSelect: false,+ specificEntityType: 'INITIATIVE',+ value: [{ entity_id: 'project-launch', entity_type: 'INITIATIVE' }],+ };++ it('saves a picked project with the name the picker showed', async () => {+ const unassigned: EntityProperty = { ...project, value: [] };+ const onSave = setup(+ { entityType: 'TASK', blockId: 'task-id' },+ unassigned+ );+ fireEvent.click(screen.getByText('Launch'));+ await waitFor(() =>+ expect(onSave).toHaveBeenCalledExactlyOnceWith(+ unassigned,+ {+ valueType: 'ENTITY',+ refs: [{ entity_id: 'project-launch', entity_type: 'INITIATIVE' }],+ },+ new Map([['project-launch', 'Launch']])+ )+ );+ });+it('clears the project when the selected project is clicked again', async () => {- const project: EntityProperty = {- ...property,- propertyId: 'project-property',- propertyDefinitionId: SYSTEM_PROPERTY_IDS.PROJECT,- displayName: 'Project',- isMultiSelect: false,- specificEntityType: 'INITIATIVE',- value: [{ entity_id: 'project-launch', entity_type: 'INITIATIVE' }],- };const onSave = setup({ entityType: 'TASK', blockId: 'task-id' }, project);fireEvent.click(screen.getByText('Launch'));await waitFor(() =>- expect(onSave).toHaveBeenCalledExactlyOnceWith(project, {- valueType: 'ENTITY',- refs: null,- })+ expect(onSave).toHaveBeenCalledExactlyOnceWith(+ project,+ { valueType: 'ENTITY', refs: null },+ new Map([['project-launch', 'Launch']])+ ));});});diff --git a/apps/web/src/features/property/editors/popover/EntityEditor.tsx b/apps/web/src/features/property/editors/popover/EntityEditor.tsxindex d3273d196d..beb066a50b 100644--- a/apps/web/src/features/property/editors/popover/EntityEditor.tsx+++ b/apps/web/src/features/property/editors/popover/EntityEditor.tsx@@ -52,6 +52,7 @@ function createEntityEditorDraft() {const [selectedRefs, setSelectedRefs] =createSignal<EntityReference[]>(initialRefs);const [dirty, setDirty] = createSignal(false);+ const pickedNames = new Map<string, string>();const refsEqual = (a: EntityReference[], b: EntityReference[]) => {if (a.length !== b.length) return false;@@ -72,7 +73,7 @@ function createEntityEditorDraft() {refs: refs.length > 0 ? refs : null,};try {- await ctx.onSave?.(property, apiValues);+ await ctx.onSave?.(property, apiValues, pickedNames);} catch {// mutation onError owns toast}@@ -83,7 +84,11 @@ function createEntityEditorDraft() {return {property,selectedRefs,- select: (refs: EntityReference[]) => {+ select: (+ refs: EntityReference[],+ picked: readonly { id: string; name: string }[] = []+ ) => {+ for (const { id, name } of picked) pickedNames.set(id, name);setSelectedRefs(refs);setDirty(true);},@@ -146,7 +151,8 @@ function EntityEditorSelector(props.draft.selectedRefs(),newOptions,entityInfo- )+ ),+ entityInfo);}}onClose={props.draft.closeAndSave}diff --git a/apps/web/src/features/property/editors/popover/SelectEditor.test.tsx b/apps/web/src/features/property/editors/popover/SelectEditor.test.tsxindex 7c6285eb59..f2fc359c01 100644--- a/apps/web/src/features/property/editors/popover/SelectEditor.test.tsx+++ b/apps/web/src/features/property/editors/popover/SelectEditor.test.tsx@@ -93,6 +93,7 @@ function setup(value = property) {const [editorOpen, setEditorOpen] = createSignal(true);const context: PropertyRootContextValue = {property: () => value,+ pickedEntityName: () => undefined,canEdit: () => true,editorOpen,openEditor: () => setEditorOpen(true),diff --git a/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsx b/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsxindex 838e6e0345..7e6e7fba7b 100644--- a/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsx+++ b/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsx@@ -49,7 +49,7 @@ type EntityInputProps = {selectedOptions: () => Set<string>;setSelectedOptions: (options: Set<string>,- entityInfo?: { id: string; entity_type: EntityType }[]+ entityInfo?: { id: string; entity_type: EntityType; name: string }[]) => void;onClose?: () => void;/** Escape in the search; `onClose` when absent, as a popover saves on close. */@@ -369,6 +369,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {{id: entity.id,entity_type: entityType,+ name: getEntityName(entity),},]);diff --git a/apps/web/src/features/property/extractors/PropertyPill.test.tsx b/apps/web/src/features/property/extractors/PropertyPill.test.tsxindex 960ba380ea..048a48eaa1 100644--- a/apps/web/src/features/property/extractors/PropertyPill.test.tsx+++ b/apps/web/src/features/property/extractors/PropertyPill.test.tsx@@ -36,6 +36,7 @@ function context(): PropertyRootContextValue {return {property: () => value,+ pickedEntityName: () => undefined,canEdit: () => canEdit,onEdit,editorOpen: () => false,diff --git a/apps/web/src/features/property/extractors/PropertyText.tsx b/apps/web/src/features/property/extractors/PropertyText.tsxindex 86b618d284..e34881408e 100644--- a/apps/web/src/features/property/extractors/PropertyText.tsx+++ b/apps/web/src/features/property/extractors/PropertyText.tsx@@ -1,7 +1,8 @@import { isBotPrincipalId } from '@core/constant/macroAgent';import type { EntityReference } from '@service-properties/generated/schemas/entityReference';import { cn } from '@ui';-import { type JSX, Show } from 'solid-js';+import { type JSX, Show, useContext } from 'solid-js';+import { PropertyRootContext } from '../core/context';import { usePropertyEntityDisplay } from '../hooks/usePropertyEntityDisplay';import { usePropertyUserDisplay } from '../hooks/usePropertyUserDisplay';import type { Property } from '../types';@@ -95,9 +96,11 @@ function EntityPropertyText(props: {entityType: EntityReference['entity_type'] | undefined;class?: string;}) {+ const root = useContext(PropertyRootContext);const { name, icon } = usePropertyEntityDisplay(() => props.entityId,- () => props.entityType+ () => props.entityType,+ { loadingName: () => root?.pickedEntityName(props.entityId) });return (<span class={cn('inline-flex min-w-0 items-center gap-1.5', props.class)}>diff --git a/apps/web/src/features/property/hooks/usePropertyEntityDisplay.test.tsx b/apps/web/src/features/property/hooks/usePropertyEntityDisplay.test.tsxindex c307f8b619..015c025870 100644--- a/apps/web/src/features/property/hooks/usePropertyEntityDisplay.test.tsx+++ b/apps/web/src/features/property/hooks/usePropertyEntityDisplay.test.tsx@@ -10,6 +10,7 @@ const fixture = vi.hoisted(() => ({previewDisposals: 0,channelMounts: 0,projectsEnabled: undefined as (() => boolean | undefined) | undefined,+ projectPending: undefined as (() => boolean) | undefined,projectMounts: 0,projectDisposals: 0,projectIdReads: 0,@@ -40,8 +41,14 @@ vi.mock('../../projects/queries/project-identity', () => ({});return {isError: false,- isPending: false,- data: { id: 'entity-1', name: 'Launch' },+ get isPending() {+ return fixture.projectPending?.() === true;+ },+ get data() {+ return fixture.projectPending?.()+ ? undefined+ : { id: 'entity-1', name: 'Launch' };+ },};},}));@@ -96,6 +103,7 @@ afterEach(() => {fixture.previewDisposals = 0;fixture.channelMounts = 0;fixture.projectsEnabled = undefined;+ fixture.projectPending = undefined;fixture.projectMounts = 0;fixture.projectDisposals = 0;fixture.projectIdReads = 0;@@ -178,6 +186,30 @@ describe('usePropertyEntityDisplay subscription ownership', () => {expect(display.name()).toBe('Launch');});+ it.each(['INITIATIVE', 'DOCUMENT'] as const)(+ 'names a %s from the loading name until its own read answers',+ (type) => {+ const [pending, setPending] = createSignal(true);+ fixture.projectsEnabled = () => true;+ fixture.projectPending = pending;+ fixture.preview = () =>+ pending()+ ? { loading: true }+ : { loading: false, access: 'access', name: 'Launch' };+ const display = createRoot((dispose) => {+ disposals.push(dispose);+ return usePropertyEntityDisplay(+ () => 'entity-1',+ () => type,+ { loadingName: () => 'Picked launch' }+ );+ });+ expect(display.name()).toBe('Picked launch');+ setPending(false);+ expect(display.name()).toBe('Launch');+ }+ );+it('keeps the generic project label, without fetching, until the rollout enables it', () => {const [enabled, setEnabled] = createSignal<boolean | undefined>();fixture.projectsEnabled = enabled;diff --git a/apps/web/src/features/property/hooks/usePropertyEntityDisplay.tsx b/apps/web/src/features/property/hooks/usePropertyEntityDisplay.tsxindex 30bef8be86..c2bba82a97 100644--- a/apps/web/src/features/property/hooks/usePropertyEntityDisplay.tsx+++ b/apps/web/src/features/property/hooks/usePropertyEntityDisplay.tsx@@ -70,6 +70,8 @@ export function usePropertyEntityDisplay(fallbackIcon?: JSX.Element | null;/** Specific message ID for THREAD/CHANNEL/CHAT entities */specificMessageId?: Accessor<string | null | undefined>;+ /** Name to show while the entity's own read loads, such as a picker's label. */+ loadingName?: Accessor<string | undefined>;}): PropertyEntityDisplayResult {// Callers usually read these from a property value, which every properties@@ -134,19 +136,21 @@ export function usePropertyEntityDisplay(return !previewItem || previewItem.loading;});+ const loadingName = () => options?.loadingName?.() || 'Loading...';+const name = createMemo(() =>match(entityType()).with('INITIATIVE', () => {const source = projectSource();if (!source) return 'Project';- if (source.isPending) return 'Loading...';+ if (source.isPending) return loadingName();return (!source.isError && source.data?.name) || 'Project unavailable';}).with('USER', () => user.name()).with('CHANNEL', () => channelName() || 'Channel').otherwise(() => {const item = preview();- if (!item || item.loading) return 'Loading...';+ if (!item || item.loading) return loadingName();if (isAccessiblePreviewItem(item)) {return item.name;}