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
opts: itemSize, lead queries, contacts (#5012)
teo35c265618780
diff --git a/apps/web/src/features/auth/mobile-onboarding/OnboardingInbox.tsx b/apps/web/src/features/auth/mobile-onboarding/OnboardingInbox.tsxindex 204112ea02..1863548601 100644--- a/apps/web/src/features/auth/mobile-onboarding/OnboardingInbox.tsx+++ b/apps/web/src/features/auth/mobile-onboarding/OnboardingInbox.tsx@@ -5,6 +5,7 @@ import {type EmailEntity,InlineEntity,ListEntity,+ ListEntityNoopMetadataProvider,ListLayoutProvider,} from '@entity';import CheckIcon from '@phosphor/check.svg';@@ -129,47 +130,51 @@ export function OnboardingInbox() {Swipe an email left to mark it done, or press and hold for more actions.</p>- <ListLayoutProvider ref={listRef}>- <SwipableRowProvider- container={listRef}- canSwipeLeft={() => true}- onSwipeLeft={(entityId) => markDone(entityId)}- >- <div ref={setListRef} class="overflow-hidden border-t border-edge">- <For- each={emails()}- fallback={- <div class="flex flex-col items-center justify-center gap-1 py-12 text-center">- <p class="text-sm font-medium text-ink">Inbox zero 🎉</p>- <p class="text-sm text-ink/60">You've cleared every email.</p>- </div>- }- >- {(email) => (- <div- ref={(el) =>- touchHandler(el, () => ({- onLongPress: () => setDrawerEmail(email),- }))- }- >- <ListEntity- entity={email}- timestamp={email.updatedAt}- hideCheckbox- entityRowConfig={{- swipeLeftColor: 'bg-success',- swipeLeftRevealedComponent: (- <CheckIcon class="size-8 text-panel" />- ),- }}- />- </div>- )}- </For>- </div>- </SwipableRowProvider>- </ListLayoutProvider>+ <ListEntityNoopMetadataProvider>+ <ListLayoutProvider ref={listRef}>+ <SwipableRowProvider+ container={listRef}+ canSwipeLeft={() => true}+ onSwipeLeft={(entityId) => markDone(entityId)}+ >+ <div ref={setListRef} class="overflow-hidden border-t border-edge">+ <For+ each={emails()}+ fallback={+ <div class="flex flex-col items-center justify-center gap-1 py-12 text-center">+ <p class="text-sm font-medium text-ink">Inbox zero 🎉</p>+ <p class="text-sm text-ink/60">+ You've cleared every email.+ </p>+ </div>+ }+ >+ {(email) => (+ <div+ ref={(el) =>+ touchHandler(el, () => ({+ onLongPress: () => setDrawerEmail(email),+ }))+ }+ >+ <ListEntity+ entity={email}+ timestamp={email.updatedAt}+ hideCheckbox+ entityRowConfig={{+ swipeLeftColor: 'bg-success',+ swipeLeftRevealedComponent: (+ <CheckIcon class="size-8 text-panel" />+ ),+ }}+ />+ </div>+ )}+ </For>+ </div>+ </SwipableRowProvider>+ </ListLayoutProvider>+ </ListEntityNoopMetadataProvider>{/* Long-press action drawer (markup modeled on SoupEntityActionDrawer). */}<MobileDrawerdiff --git a/apps/web/src/features/block-md/component/TaskDuplicateList.tsx b/apps/web/src/features/block-md/component/TaskDuplicateList.tsxindex 879c4a7e8f..6dd502d95d 100644--- a/apps/web/src/features/block-md/component/TaskDuplicateList.tsx+++ b/apps/web/src/features/block-md/component/TaskDuplicateList.tsx@@ -8,6 +8,7 @@ import {import { ListLayoutProvider } from '@entity';import CaretRightIcon from '@phosphor/caret-right.svg';import CopyIcon from '@phosphor/copy.svg';+import { TagSetsQueryProvider } from '@property/tags/tag-sets-context';import { useSoupItemsQuery } from '@queries/soup/items';import { useTaskSimilaritySearchQuery } from '@queries/storage/task-duplicates';import type { TaskSimilarityResult } from '@service-storage/client';@@ -93,25 +94,27 @@ function SimilarTasksInner(props: {<span>Similar Tasks</span></button><Show when={expanded()}>- <ListLayoutProvider ref={listRef}>- {/* Named `u-list` container so the task rows pick up the narrow- (<=840px) container queries and collapse status/priority/- assignee pills to icons, leaving the width for task names. */}- <div- ref={setListRef}- class="@container/u-list flex max-h-48 flex-col overflow-y-auto scrollbar-hidden"- >- <For each={entities()}>- {(entity) => (- <TaskListEntity- entity={entity}- hideCheckbox- onClick={() => props.onOpenTask(entity.id)}- />- )}- </For>- </div>- </ListLayoutProvider>+ <TagSetsQueryProvider>+ <ListLayoutProvider ref={listRef}>+ {/* Named `u-list` container so the task rows pick up the narrow+ (<=840px) container queries and collapse status/priority/+ assignee pills to icons, leaving the width for task names. */}+ <div+ ref={setListRef}+ class="@container/u-list flex max-h-48 flex-col overflow-y-auto scrollbar-hidden"+ >+ <For each={entities()}>+ {(entity) => (+ <TaskListEntity+ entity={entity}+ hideCheckbox+ onClick={() => props.onOpenTask(entity.id)}+ />+ )}+ </For>+ </div>+ </ListLayoutProvider>+ </TagSetsQueryProvider></Show></div></Show>diff --git a/apps/web/src/features/companies/Company/CompanyEmailsSection.tsx b/apps/web/src/features/companies/Company/CompanyEmailsSection.tsxindex 7f06d5a3ff..c6ac99c836 100644--- a/apps/web/src/features/companies/Company/CompanyEmailsSection.tsx+++ b/apps/web/src/features/companies/Company/CompanyEmailsSection.tsx@@ -1,6 +1,11 @@import { openEntityInSplitFromUnifiedList } from '@app/features/next-soup/utils';import { TabsInset } from '@core/component/TabsInset';-import { type CrmCompanyEntity, ListEntity, ListLayoutProvider } from '@entity';+import {+ type CrmCompanyEntity,+ ListEntity,+ ListEntityMetadataQueryProvider,+ ListLayoutProvider,+} from '@entity';import { createMemo, createSignal, For, Show } from 'solid-js';import {type EmailSignalView,@@ -75,21 +80,23 @@ export function CompanyEmailsSection(props: { company?: CrmCompanyEntity }) {}><div class="max-h-96 overflow-y-auto">- <ListLayoutProvider ref={listRef}>- <div ref={setListRef} class="flex flex-col">- <For each={emails()}>- {(entity) => (- <ListEntity- entity={entity}- timestamp={entity.updatedAt}- onClick={() =>- openEntityInSplitFromUnifiedList(entity, {})- }- />- )}- </For>- </div>- </ListLayoutProvider>+ <ListEntityMetadataQueryProvider>+ <ListLayoutProvider ref={listRef}>+ <div ref={setListRef} class="flex flex-col">+ <For each={emails()}>+ {(entity) => (+ <ListEntity+ entity={entity}+ timestamp={entity.updatedAt}+ onClick={() =>+ openEntityInSplitFromUnifiedList(entity, {})+ }+ />+ )}+ </For>+ </div>+ </ListLayoutProvider>+ </ListEntityMetadataQueryProvider><Show when={emailsQuery.hasNextPage}><div ref={setSentinelRef} class="h-px" /></Show>diff --git a/apps/web/src/features/contacts/Contact/ContactEmailsSection.tsx b/apps/web/src/features/contacts/Contact/ContactEmailsSection.tsxindex 705656db5c..cff613ad24 100644--- a/apps/web/src/features/contacts/Contact/ContactEmailsSection.tsx+++ b/apps/web/src/features/contacts/Contact/ContactEmailsSection.tsx@@ -1,7 +1,11 @@import { openEntityInSplitFromUnifiedList } from '@app/features/next-soup/utils';import { useInfiniteScrollSentinel } from '@companies/Company/use-infinite-scroll-sentinel';import { TabsInset } from '@core/component/TabsInset';-import { ListEntity, ListLayoutProvider } from '@entity';+import {+ ListEntity,+ ListEntityMetadataQueryProvider,+ ListLayoutProvider,+} from '@entity';import type { CrmContactResponse } from '@service-storage/generated/schemas/crmContactResponse';import { createSignal, For, Show } from 'solid-js';import {@@ -65,21 +69,23 @@ export function ContactEmailsSection(props: { contact?: CrmContactResponse }) {}><div class="max-h-96 overflow-y-auto">- <ListLayoutProvider ref={listRef}>- <div ref={setListRef} class="flex flex-col">- <For each={emails()}>- {(entity) => (- <ListEntity- entity={entity}- timestamp={entity.updatedAt}- onClick={() =>- openEntityInSplitFromUnifiedList(entity, {})- }- />- )}- </For>- </div>- </ListLayoutProvider>+ <ListEntityMetadataQueryProvider>+ <ListLayoutProvider ref={listRef}>+ <div ref={setListRef} class="flex flex-col">+ <For each={emails()}>+ {(entity) => (+ <ListEntity+ entity={entity}+ timestamp={entity.updatedAt}+ onClick={() =>+ openEntityInSplitFromUnifiedList(entity, {})+ }+ />+ )}+ </For>+ </div>+ </ListLayoutProvider>+ </ListEntityMetadataQueryProvider><Show when={emailsQuery.hasNextPage}><div ref={setSentinelRef} class="h-px" /></Show>diff --git a/apps/web/src/features/dynamic-ui/widgets/List.tsx b/apps/web/src/features/dynamic-ui/widgets/List.tsxindex 30b1dc1491..1781c9f881 100644--- a/apps/web/src/features/dynamic-ui/widgets/List.tsx+++ b/apps/web/src/features/dynamic-ui/widgets/List.tsx@@ -5,6 +5,7 @@ import {queryStateFrom,} from '@app/features/next-soup/filters/filter-store';import type { FieldFilters } from '@app/features/next-soup/filters/filter-store/types';+import { ListEntityMetadataQueryProvider } from '@entity';import { CollapsibleList } from '@entity/components/CollapsibleList';import { ListEntity, ListLayoutProvider } from '@entity/composed/ListEntity';import type { EntityData } from '@entity/types/entity';@@ -32,10 +33,9 @@ import { SURFACE, TEXT } from '../tokens';* task pills read `entity.properties`. Both come from the soup item query: we* compile the widget's source into a soup AST and let `useSoupAstItemsQuery`* return ready-to-render `EntityData[]` (properties pre-attached). The only- * provider `ListEntity` needs for the wide layout is `ListLayoutProvider`- * (width detection); `Entity.Properties` brings its own `PropertiesProvider`,- * and the split-panel / soup-view contexts are read optionally so they degrade- * gracefully when absent. We render inside the gallery's split-panel anyway.+ * composition root supplies responsive layout and shared row metadata; leaf+ * rows remain query-free. `Entity.Properties` brings its own+ * `PropertiesProvider`, and the split-panel / soup-view contexts are optional.** - `items` mode: resolve the supplied refs → EntityData via an id-filtered AST.* - `query` mode: drive the same query straight from `source.query`.@@ -155,51 +155,53 @@ function Rows(props: {export function List(props: ListProps) {return (- <ListLayoutProvider ref={() => undefined}>- <div class="flex w-full min-w-0 flex-col gap-2">- {/* Group header, soup-style: bold title above the card. */}- <Show when={props.title}>- {(title) => (- <div- class={cn(- 'flex items-center gap-2 px-1 text-sm font-semibold',- TEXT.primary- )}- >- {title()}- </div>- )}- </Show>-- {/*- * Flush row container (mirrors SoupView's unified list): no- * per-row dividers/borders. Each `ListEntity` brings its own- * rounded inset highlight pill (`mx-1`), so the card just needs a- * hair of vertical padding for the pills to breathe — adding- * `divide-y`/per-row borders here would box those highlights in.- */}- <div- class={cn(- 'overflow-hidden rounded-lg border py-1',- SURFACE.borderMuted- )}- >- {/* Soup fetches suspend; guard so it can't blank the surrounding view. */}- <Suspense- fallback={- <div class={cn('px-3 py-6 text-center text-sm', TEXT.tertiary)}>- Loading…+ <ListEntityMetadataQueryProvider>+ <ListLayoutProvider ref={() => undefined}>+ <div class="flex w-full min-w-0 flex-col gap-2">+ {/* Group header, soup-style: bold title above the card. */}+ <Show when={props.title}>+ {(title) => (+ <div+ class={cn(+ 'flex items-center gap-2 px-1 text-sm font-semibold',+ TEXT.primary+ )}+ >+ {title()}</div>- }+ )}+ </Show>++ {/*+ * Flush row container (mirrors SoupView's unified list): no+ * per-row dividers/borders. Each `ListEntity` brings its own+ * rounded inset highlight pill (`mx-1`), so the card just needs a+ * hair of vertical padding for the pills to breathe — adding+ * `divide-y`/per-row borders here would box those highlights in.+ */}+ <div+ class={cn(+ 'overflow-hidden rounded-lg border py-1',+ SURFACE.borderMuted+ )}>- <Rows- source={props.source}- limit={props.limit}- groupBy={props.groupBy}- />- </Suspense>+ {/* Soup fetches suspend; guard so it can't blank the surrounding view. */}+ <Suspense+ fallback={+ <div class={cn('px-3 py-6 text-center text-sm', TEXT.tertiary)}>+ Loading…+ </div>+ }+ >+ <Rows+ source={props.source}+ limit={props.limit}+ groupBy={props.groupBy}+ />+ </Suspense>+ </div></div>- </div>- </ListLayoutProvider>+ </ListLayoutProvider>+ </ListEntityMetadataQueryProvider>);}diff --git a/apps/web/src/features/entity/composed/list-entity/email-links-context.test.tsx b/apps/web/src/features/entity/composed/list-entity/email-links-context.test.tsxnew file mode 100644index 0000000000..152d8e7094--- /dev/null+++ b/apps/web/src/features/entity/composed/list-entity/email-links-context.test.tsx@@ -0,0 +1,104 @@+/**+ * @vitest-environment jsdom+ */++import type { Link } from '@service-email/generated/schemas';+import { fireEvent, render, screen } from '@solidjs/testing-library';+import { createSignal, Show } from 'solid-js';+import { describe, expect, it, vi } from 'vitest';+import type { EmailEntity, EntityData } from '../../types/entity';+import { EmailInboxChip, useOwningInboxForEntity } from './email';+import { EmailLinksProvider } from './email-links-context';++vi.mock('@core/component/UserIcon', () => ({+ UserIcon: () => <span data-testid="inbox-icon" />,+}));++vi.mock('../../entity', () => ({ Entity: {} }));+vi.mock('../../components/Badges', () => ({ DraftBadge: () => null }));+vi.mock('../../extractors-search/HitSnippet', () => ({+ HitSnippet: () => null,+}));+vi.mock('../../extractors-search/snippet-entity', () => ({+ getSnippetHit: () => undefined,+}));++function RecycledRowInboxConsumer() {+ const [entity, setEntity] = createSignal<EntityData>({+ id: 'document-1',+ name: 'Document',+ ownerId: 'user-1',+ type: 'document',+ });+ const inbox = useOwningInboxForEntity(entity);++ return (+ <>+ <Show when={inbox()}>+ {(link) => <span>{link().email_address}</span>}+ </Show>+ <button+ type="button"+ onClick={() =>+ setEntity({+ id: 'thread-1',+ name: 'Email',+ ownerId: 'user-1',+ type: 'email',+ isRead: true,+ isDraft: false,+ isImportant: false,+ done: false,+ linkId: 'secondary-inbox',+ })+ }+ >+ Recycle row+ </button>+ </>+ );+}++describe('EmailLinksContext', () => {+ it('supports the real email-row consumer', () => {+ const links = (): Link[] => [+ { id: 'primary-inbox' } as Link,+ {+ id: 'secondary-inbox',+ email_address: '[email protected]',+ } as Link,+ ];+ const entity = {+ type: 'email',+ linkId: 'secondary-inbox',+ } as EmailEntity;++ render(() => (+ <EmailLinksProvider links={links}>+ <EmailInboxChip entity={entity} />+ </EmailLinksProvider>+ ));++ expect(screen.getByTitle('[email protected]')).toBeTruthy();+ });++ it('updates inbox attribution when a mounted row changes entity type', async () => {+ const links = (): Link[] => [+ { id: 'primary-inbox' } as Link,+ {+ id: 'secondary-inbox',+ email_address: '[email protected]',+ } as Link,+ ];++ render(() => (+ <EmailLinksProvider links={links}>+ <RecycledRowInboxConsumer />+ </EmailLinksProvider>+ ));++ expect(screen.queryByText('[email protected]')).toBeNull();+ await fireEvent.click(screen.getByRole('button', { name: 'Recycle row' }));+ expect(screen.getByText('[email protected]')).toBeTruthy();+ });+});diff --git a/apps/web/src/features/entity/composed/list-entity/email-links-context.tsx b/apps/web/src/features/entity/composed/list-entity/email-links-context.tsxnew file mode 100644index 0000000000..4b04aa9ee2--- /dev/null+++ b/apps/web/src/features/entity/composed/list-entity/email-links-context.tsx@@ -0,0 +1,43 @@+import { useEmailLinksQuery } from '@queries/email/link';+import type { Link } from '@service-email/generated/schemas';+import {+ type Accessor,+ createContext,+ type FlowComponent,+ useContext,+} from 'solid-js';++type EmailLinks = Accessor<Link[]>;++const EmailLinksContext = createContext<EmailLinks>();++/** Provides already-loaded email links to an entity-list subtree. */+export const EmailLinksProvider: FlowComponent<{ links: EmailLinks }> = (+ props+) => (+ <EmailLinksContext.Provider value={props.links}>+ {props.children}+ </EmailLinksContext.Provider>+);++/** Explicit query-owning adapter for standalone entity lists. */+export const EmailLinksQueryProvider: FlowComponent = (props) => {+ const linksQuery = useEmailLinksQuery();+ const links = (): Link[] => linksQuery.data?.links ?? [];++ return (+ <EmailLinksProvider links={links}>{props.children}</EmailLinksProvider>+ );+};++/** Returns links from the nearest entity-list metadata provider. */+export function useEmailLinks(): EmailLinks {+ const links = useContext(EmailLinksContext);+ if (!links) {+ throw new Error(+ 'useEmailLinks can only be used under an EmailLinksProvider'+ );+ }++ return links;+}diff --git a/apps/web/src/features/entity/composed/list-entity/email.tsx b/apps/web/src/features/entity/composed/list-entity/email.tsxindex 9918323c07..9c470bee6c 100644--- a/apps/web/src/features/entity/composed/list-entity/email.tsx+++ b/apps/web/src/features/entity/composed/list-entity/email.tsx@@ -1,13 +1,17 @@import { inboxIconProps } from '@core/component/inboxIcon';import { UserIcon } from '@core/component/UserIcon';-import { useEmailLinksQuery } from '@queries/email/link';import { cn } from '@ui';import { type Accessor, createMemo, Show } from 'solid-js';import { DraftBadge } from '../../components/Badges';import { Entity } from '../../entity';import { HitSnippet } from '../../extractors-search/HitSnippet';import { getSnippetHit } from '../../extractors-search/snippet-entity';-import type { EmailEntity } from '../../types/entity';+import {+ type EmailEntity,+ type EntityData,+ isEmailEntity,+} from '../../types/entity';+import { useEmailLinks } from './email-links-context';/*** Resolves the linked inbox a thread belongs to, but only when the user has@@ -16,13 +20,21 @@ import type { EmailEntity } from '../../types/entity';* thread shared with the user that isn't one of their own/delegated inboxes.*/export function useOwningInbox(entity: Accessor<EmailEntity | undefined>) {- const linksQuery = useEmailLinksQuery();+ const links = useEmailLinks();return createMemo(() => {const linkId = entity()?.linkId;if (!linkId) return undefined;- const links = linksQuery.data?.links ?? [];- if (links.length <= 1) return undefined;- return links.find((l) => l.id === linkId);+ const availableLinks = links();+ if (availableLinks.length <= 1) return undefined;+ return availableLinks.find((link) => link.id === linkId);+ });+}++/** Keeps inbox attribution reactive when a recycled list row changes entity. */+export function useOwningInboxForEntity(entity: Accessor<EntityData>) {+ return useOwningInbox(() => {+ const current = entity();+ return isEmailEntity(current) ? current : undefined;});}diff --git a/apps/web/src/features/entity/composed/list-entity/list-entity-metadata-provider.test.tsx b/apps/web/src/features/entity/composed/list-entity/list-entity-metadata-provider.test.tsxnew file mode 100644index 0000000000..06572d0bfe--- /dev/null+++ b/apps/web/src/features/entity/composed/list-entity/list-entity-metadata-provider.test.tsx@@ -0,0 +1,74 @@+/**+ * @vitest-environment jsdom+ */++import { useTagSets } from '@property/tags/tag-sets-context';+import { render, screen } from '@solidjs/testing-library';+import { beforeEach, describe, expect, it, vi } from 'vitest';+import { useEmailLinks } from './email-links-context';+import {+ ListEntityMetadataQueryProvider,+ ListEntityNoopMetadataProvider,+} from './list-entity-metadata-provider';++const mocks = vi.hoisted(() => ({+ useEmailLinksQuery: vi.fn(),+ useTagsQuery: vi.fn(),+}));++vi.mock('@queries/email/link', () => ({+ useEmailLinksQuery: mocks.useEmailLinksQuery,+}));++vi.mock('@queries/properties/tags', () => ({+ useTagsQuery: mocks.useTagsQuery,+}));++function MetadataConsumer(props: { label: string }) {+ const emailLinks = useEmailLinks();+ const tagSets = useTagSets();+ return (+ <span>+ {props.label}:{emailLinks().length}:{tagSets().length}+ </span>+ );+}++beforeEach(() => {+ mocks.useEmailLinksQuery.mockReset();+ mocks.useTagsQuery.mockReset();+ mocks.useEmailLinksQuery.mockReturnValue({+ data: { links: [{ id: 'inbox-1' }] },+ });+ mocks.useTagsQuery.mockReturnValue({+ data: [{ scope: 'user', options: [] }],+ });+});++describe('ListEntityMetadataProvider', () => {+ it('shares one query observer of each kind across a collection', () => {+ render(() => (+ <ListEntityMetadataQueryProvider>+ <MetadataConsumer label="first" />+ <MetadataConsumer label="second" />+ </ListEntityMetadataQueryProvider>+ ));++ expect(screen.getByText('first:1:1')).toBeTruthy();+ expect(screen.getByText('second:1:1')).toBeTruthy();+ expect(mocks.useEmailLinksQuery).toHaveBeenCalledOnce();+ expect(mocks.useTagsQuery).toHaveBeenCalledOnce();+ });++ it('provides explicit empty metadata without creating queries', () => {+ render(() => (+ <ListEntityNoopMetadataProvider>+ <MetadataConsumer label="noop" />+ </ListEntityNoopMetadataProvider>+ ));++ expect(screen.getByText('noop:0:0')).toBeTruthy();+ expect(mocks.useEmailLinksQuery).not.toHaveBeenCalled();+ expect(mocks.useTagsQuery).not.toHaveBeenCalled();+ });+});diff --git a/apps/web/src/features/entity/composed/list-entity/list-entity-metadata-provider.tsx b/apps/web/src/features/entity/composed/list-entity/list-entity-metadata-provider.tsxnew file mode 100644index 0000000000..0b03ae435e--- /dev/null+++ b/apps/web/src/features/entity/composed/list-entity/list-entity-metadata-provider.tsx@@ -0,0 +1,47 @@+import {+ TagSetsProvider,+ TagSetsQueryProvider,+} from '@property/tags/tag-sets-context';+import type { Link } from '@service-email/generated/schemas';+import type { TagSetResponse } from '@service-properties/generated/schemas/tagSetResponse';+import type { Accessor, FlowComponent } from 'solid-js';+import {+ EmailLinksProvider,+ EmailLinksQueryProvider,+} from './email-links-context';++const EMPTY_EMAIL_LINKS: Link[] = [];+const EMPTY_TAG_SETS: TagSetResponse[] = [];++/** Provides caller-owned metadata to a ListEntity collection without queries. */+export const ListEntityMetadataProvider: FlowComponent<{+ emailLinks: Accessor<Link[]>;+ tagSets: Accessor<TagSetResponse[]>;+}> = (props) => (+ <EmailLinksProvider links={props.emailLinks}>+ <TagSetsProvider tagSets={props.tagSets}>{props.children}</TagSetsProvider>+ </EmailLinksProvider>+);++/**+ * Satisfies ListEntity's metadata contract without loading or displaying+ * optional metadata. Use for intentionally local or static collections.+ */+export const ListEntityNoopMetadataProvider: FlowComponent = (props) => (+ <ListEntityMetadataProvider+ emailLinks={() => EMPTY_EMAIL_LINKS}+ tagSets={() => EMPTY_TAG_SETS}+ >+ {props.children}+ </ListEntityMetadataProvider>+);++/**+ * Owns the shared metadata queries required by a standalone ListEntity+ * collection. Soup lists use their soup-specific metadata provider instead.+ */+export const ListEntityMetadataQueryProvider: FlowComponent = (props) => (+ <EmailLinksQueryProvider>+ <TagSetsQueryProvider>{props.children}</TagSetsQueryProvider>+ </EmailLinksQueryProvider>+);diff --git a/apps/web/src/features/entity/composed/list-entity/wide-layout.tsx b/apps/web/src/features/entity/composed/list-entity/wide-layout.tsxindex 5a740a9c81..d927009267 100644--- a/apps/web/src/features/entity/composed/list-entity/wide-layout.tsx+++ b/apps/web/src/features/entity/composed/list-entity/wide-layout.tsx@@ -1,5 +1,4 @@import { useRowTagsVisible } from '@app/features/next-soup/soup-view/filters-bar/search/search-tags-flag';-import { useRowTagFilter } from '@app/features/next-soup/soup-view/filters-bar/use-row-tag-filter';import { useMaybeSoupView } from '@app/features/next-soup/soup-view/soup-view-context';import { formatCallDuration } from '@block-call/utils';import { EntityRowTags } from '@property/tags';@@ -33,7 +32,7 @@ import { isSearchEntity } from '../../types/search';import { AutomationWideContent } from './automation';import { CallParticipants, CallWideContent } from './call';import { ChannelMessageWideContent, ChannelWideContent } from './channel';-import { EmailWideContent, useOwningInbox } from './email';+import { EmailWideContent, useOwningInboxForEntity } from './email';import {GithubPullRequestChecksIndicator,GithubPullRequestPills,@@ -44,14 +43,14 @@ function RowTags(props: {entityId: string;entityType: EntityType;properties: SoupProperty[] | undefined;+ onFilterByTag?: (optionId: string) => void;}) {- const filterByTag = useRowTagFilter();return (<EntityRowTagsentityId={props.entityId}entityType={props.entityType}properties={props.properties}- onFilterByTag={filterByTag}+ onFilterByTag={props.onFilterByTag}/>);}@@ -61,9 +60,7 @@ export function WideLayout(props: LayoutProps) {const rowTagsVisible = useRowTagsVisible();// When a thread resolves to one of the user's inboxes the inbox chip already// conveys ownership, so the generic "shared" badge would be redundant.- const owningInbox = useOwningInbox(() =>- isEmailEntity(props.entity) ? props.entity : undefined- );+ const owningInbox = useOwningInboxForEntity(() => props.entity);return (<Entity.Layout@@ -170,6 +167,7 @@ export function WideLayout(props: LayoutProps) {entityId={entity().id}entityType={EntityType.PROJECT}properties={entity().properties}+ onFilterByTag={soupView?.filterByTag}/>)}</Show>@@ -190,6 +188,7 @@ export function WideLayout(props: LayoutProps) {isTaskEntity(entity()) ? EntityType.TASK : EntityType.DOCUMENT}properties={properties()}+ onFilterByTag={soupView?.filterByTag}/>);}}@@ -215,6 +214,7 @@ export function WideLayout(props: LayoutProps) {entityId={entity().id}entityType={EntityType.CHAT}properties={entity().properties}+ onFilterByTag={soupView?.filterByTag}/>)}</Show>@@ -226,6 +226,7 @@ export function WideLayout(props: LayoutProps) {entityId={entity().id}entityType={EntityType.CALL_RECORD}properties={entity().properties}+ onFilterByTag={soupView?.filterByTag}/>)}</Show>diff --git a/apps/web/src/features/entity/debug/DebugEntityView.tsx b/apps/web/src/features/entity/debug/DebugEntityView.tsxindex 8564d6620a..e5ce328d3e 100644--- a/apps/web/src/features/entity/debug/DebugEntityView.tsx+++ b/apps/web/src/features/entity/debug/DebugEntityView.tsx@@ -3,6 +3,7 @@ import { StaticSplitLabel } from '@components/app/split-layout/components/SplitLimport { seedMockDisplayNames } from '@core/user';import { createSignal, For } from 'solid-js';import { ListEntity } from '../composed/ListEntity';+import { ListEntityNoopMetadataProvider } from '../composed/list-entity/list-entity-metadata-provider';import {ALL_MOCK_ENTITIES,createEntityWithNotifications,@@ -66,21 +67,23 @@ export default function DebugEntityView() {<StaticSplitLabel label="Enity Component Demo (mock data)" />jk</SplitHeaderLeft>- <div class="size-full overflow-auto">- <For each={entitiesWithNotifications}>- {(entity, index) => (- <ListEntity- entity={entity}- onClick={() => handleEntityClick(entity, index())}- checked={selectedIds().has(entity.id)}- onChecked={(checked, shiftKey) =>- handleEntityChecked(entity, index(), checked, shiftKey)- }- showUnrollNotifications={true}- />- )}- </For>- </div>+ <ListEntityNoopMetadataProvider>+ <div class="size-full overflow-auto">+ <For each={entitiesWithNotifications}>+ {(entity, index) => (+ <ListEntity+ entity={entity}+ onClick={() => handleEntityClick(entity, index())}+ checked={selectedIds().has(entity.id)}+ onChecked={(checked, shiftKey) =>+ handleEntityChecked(entity, index(), checked, shiftKey)+ }+ showUnrollNotifications={true}+ />+ )}+ </For>+ </div>+ </ListEntityNoopMetadataProvider></>);}diff --git a/apps/web/src/features/entity/index.ts b/apps/web/src/features/entity/index.tsindex 0c396f800f..688f974336 100644--- a/apps/web/src/features/entity/index.ts+++ b/apps/web/src/features/entity/index.ts@@ -8,6 +8,11 @@ export {ListLayoutProvider,MaybeEntityRow,} from './composed/ListEntity';+export {+ ListEntityMetadataProvider,+ ListEntityMetadataQueryProvider,+ ListEntityNoopMetadataProvider,+} from './composed/list-entity/list-entity-metadata-provider';export { Entity } from './entity';export { EntityIcon as EntityRowIcon } from './extractors/entity-icon';export { EntityTitle as EntityRowTitle } from './extractors/entity-title';diff --git a/apps/web/src/features/next-soup/debug/DocumentWherePlayground.tsx b/apps/web/src/features/next-soup/debug/DocumentWherePlayground.tsxindex 0a8e2b07c8..1689a22d0f 100644--- a/apps/web/src/features/next-soup/debug/DocumentWherePlayground.tsx+++ b/apps/web/src/features/next-soup/debug/DocumentWherePlayground.tsx@@ -6,7 +6,11 @@ import {queryStateFrom,} from '@app/features/next-soup/filters/filter-store';import { throwOnErr } from '@core/util/result';-import { ListEntity, ListLayoutProvider } from '@entity';+import {+ ListEntity,+ ListEntityMetadataQueryProvider,+ ListLayoutProvider,+} from '@entity';import {isDisplayableSoupItem,mapApiSoupItemToEntity,@@ -666,19 +670,21 @@ export default function DocumentWherePlayground() {</div></Show>- <ListLayoutProvider ref={resultsRef}>- <div class="space-y-1">- <For each={entities()}>- {(entity) => (- <ListEntity- entity={entity}- hideCheckbox- onClick={() => console.log('Soup entity:', entity)}- />- )}- </For>- </div>- </ListLayoutProvider>+ <ListEntityMetadataQueryProvider>+ <ListLayoutProvider ref={resultsRef}>+ <div class="space-y-1">+ <For each={entities()}>+ {(entity) => (+ <ListEntity+ entity={entity}+ hideCheckbox+ onClick={() => console.log('Soup entity:', entity)}+ />+ )}+ </For>+ </div>+ </ListLayoutProvider>+ </ListEntityMetadataQueryProvider></section></main></div>diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/tag-filter-state.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/tag-filter-state.tsxnew file mode 100644index 0000000000..7188c430cb--- /dev/null+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/tag-filter-state.tsx@@ -0,0 +1,95 @@+import type { PropertyFilter } from '@app/features/next-soup/filters/filter-store';+import type { QueryStore } from '@app/features/next-soup/filters/filter-store/query-store';+import { useFeatureFlag } from '@app/lib/analytics/posthog';+import {+ ENABLE_TAGS_FE_FLAG,+ ENABLE_TAGS_FE_OVERRIDE,+} from '@core/constant/featureFlags';+import { TagDot } from '@property/tags/TagDot';+import { useTagsQuery } from '@queries/properties/tags';+import type { TagSetResponse } from '@service-properties/generated/schemas/tagSetResponse';+import { batch, createMemo } from 'solid-js';+import type { SearchableOption } from './searchable-multi-select';++/**+ * Creates the tag resources shared by every surface in one soup view. Keeping+ * this at the provider boundary prevents each filter surface and virtual row+ * from attaching another observer to the same TanStack query.+ */+export function createTagFilter(queryFilters: QueryStore) {+ const tagsFlag = useFeatureFlag(ENABLE_TAGS_FE_FLAG, {+ enabledOverride: ENABLE_TAGS_FE_OVERRIDE,+ });+ const tagsQuery = useTagsQuery();++ const tagSets = (): TagSetResponse[] => tagsQuery.data ?? [];++ const defByOption = createMemo(() => {+ const map = new Map<string, string>();+ for (const set of tagSets()) {+ for (const option of set.options) {+ map.set(option.id, option.propertyDefinitionId);+ }+ }+ return map;+ });++ const options = createMemo<SearchableOption[]>(() =>+ tagSets().flatMap((set) =>+ set.options.map((option) => ({+ id: option.id,+ label: option.value.type === 'string' ? option.value.value : option.id,+ icon: () => <TagDot color={option.color ?? undefined} />,+ }))+ )+ );++ const optionsById = createMemo(() => {+ const map = new Map<string, SearchableOption>();+ for (const option of options()) map.set(option.id, option);+ return map;+ });++ const activeIds = createMemo(() =>+ (queryFilters.state.include.tagFilters ?? []).map((tag) => tag.value)+ );++ const onChange = (ids: string[]) => {+ const byOption = defByOption();+ const current = activeIds();+ const currentFilters = queryFilters.state.include.tagFilters ?? [];+ const addProps = ids.reduce<PropertyFilter[]>((acc, id) => {+ if (current.includes(id)) return acc;+ const propertyId = byOption.get(id);+ if (propertyId) acc.push({ propertyId, type: 'select', value: id });+ return acc;+ }, []);+ // Remove from the stored filters, not from freshly-derived ones: the stored+ // entry keeps its definition id even if the tag was deleted or the tag list+ // has not loaded, so deselecting always clears the filter.+ const removeProps = currentFilters.filter(+ (filter) => !ids.includes(filter.value)+ );+ batch(() => {+ if (removeProps.length) {+ queryFilters.remove({ include: { tagFilters: removeProps } });+ }+ if (addProps.length) {+ queryFilters.add({ include: { tagFilters: addProps } });+ }+ });+ };++ return {+ enabled: () => tagsFlag().enabled,+ hasTags: () => options().length > 0,+ tagSets,+ options,+ optionsById,+ defByOption,+ activeIds,+ onChange,+ };+}++export type TagFilter = ReturnType<typeof createTagFilter>;diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/tag-filter.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/tag-filter.tsxindex ef20de5e96..19711240e6 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/tag-filter.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/tag-filter.tsx@@ -1,14 +1,4 @@-import type { PropertyFilter } from '@app/features/next-soup/filters/filter-store';import { useSoupView } from '@app/features/next-soup/soup-view/soup-view-context';-import { useFeatureFlag } from '@app/lib/analytics/posthog';-import {- ENABLE_TAGS_FE_FLAG,- ENABLE_TAGS_FE_OVERRIDE,-} from '@core/constant/featureFlags';-import { TagDot } from '@property/tags/TagDot';-import { useTagsQuery } from '@queries/properties/tags';-import { batch, createMemo } from 'solid-js';-import type { SearchableOption } from './searchable-multi-select';/*** The caller's tags as pickable options, plus the flag/availability gating.@@ -16,41 +6,7 @@ import type { SearchableOption } from './searchable-multi-select';* so option labels, colors, and the owning-definition mapping stay in sync.*/export function useTagOptions() {- const tagsFlag = useFeatureFlag(ENABLE_TAGS_FE_FLAG, {- enabledOverride: ENABLE_TAGS_FE_OVERRIDE,- });- const tagsQuery = useTagsQuery();-- const defByOption = createMemo(() => {- const map = new Map<string, string>();- for (const set of tagsQuery.data ?? []) {- for (const option of set.options) {- map.set(option.id, option.propertyDefinitionId);- }- }- return map;- });-- const options = createMemo<SearchableOption[]>(() =>- (tagsQuery.data ?? []).flatMap((set) =>- set.options.map((option) => ({- id: option.id,- label: option.value.type === 'string' ? option.value.value : option.id,- icon: () => <TagDot color={option.color ?? undefined} />,- }))- )- );-- const optionsById = createMemo(() => {- const map = new Map<string, SearchableOption>();- for (const option of options()) map.set(option.id, option);- return map;- });-- const enabled = () => tagsFlag().enabled;- const hasTags = () => options().length > 0;-- return { enabled, hasTags, options, optionsById, defByOption };+ return useSoupView().tagFilter;}/**@@ -61,41 +17,5 @@ export function useTagOptions() {* together across definitions.*/export function useTagFilter() {- const { queryFilters } = useSoupView();- const tags = useTagOptions();-- const activeIds = createMemo(() =>- (queryFilters.state.include.tagFilters ?? []).map((t) => t.value)- );-- const onChange = (ids: string[]) => {- const byOption = tags.defByOption();- const current = activeIds();- const currentFilters = queryFilters.state.include.tagFilters ?? [];- const addProps = ids.reduce<PropertyFilter[]>((acc, id) => {- if (current.includes(id)) return acc;- const propertyId = byOption.get(id);- if (propertyId) acc.push({ propertyId, type: 'select', value: id });- return acc;- }, []);- // Remove from the stored filters, not from freshly-derived ones: the stored- // entry keeps its definition id even if the tag was deleted or the tag list- // has not loaded, so deselecting always clears the filter.- const removeProps = currentFilters.filter((f) => !ids.includes(f.value));- batch(() => {- if (removeProps.length)- queryFilters.remove({ include: { tagFilters: removeProps } });- if (addProps.length)- queryFilters.add({ include: { tagFilters: addProps } });- });- };-- return {- enabled: tags.enabled,- hasTags: tags.hasTags,- options: tags.options,- optionsById: tags.optionsById,- activeIds,- onChange,- };+ return useSoupView().tagFilter;}diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/use-row-tag-filter.ts b/apps/web/src/features/next-soup/soup-view/filters-bar/use-row-tag-filter.tsdeleted file mode 100644index 1cf36dfaff..0000000000--- a/apps/web/src/features/next-soup/soup-view/filters-bar/use-row-tag-filter.ts+++ /dev/null@@ -1,17 +0,0 @@-import { useTagFilter } from '@app/features/next-soup/soup-view/filters-bar/tag-filter';-import { useMaybeSoupView } from '@app/features/next-soup/soup-view/soup-view-context';--/**- * Row-tag click handler: filter the current list to a single tag. Applied on- * top of the active tab and any other filters — only the tag filter itself is- * replaced, so it is always exactly the one clicked tag. Returns undefined- * outside a soup view (e.g. document embeds), where there is nothing to filter.- */-export function useRowTagFilter(): ((optionId: string) => void) | undefined {- const soupView = useMaybeSoupView();- if (!soupView) return undefined;- const tagFilter = useTagFilter();- return (optionId: string) => {- tagFilter.onChange([optionId]);- };-}diff --git a/apps/web/src/features/next-soup/soup-view/soup-row-metadata-provider.tsx b/apps/web/src/features/next-soup/soup-view/soup-row-metadata-provider.tsxnew file mode 100644index 0000000000..929369058a--- /dev/null+++ b/apps/web/src/features/next-soup/soup-view/soup-row-metadata-provider.tsx@@ -0,0 +1,20 @@+import { EmailLinksQueryProvider } from '@entity/composed/list-entity/email-links-context';+import { TagSetsProvider } from '@property/tags/tag-sets-context';+import type { FlowComponent } from 'solid-js';+import { useSoupView } from './soup-view-context';++/**+ * Owns non-soup queries used to enrich virtualized entity rows and adapts+ * soup-owned metadata into the domain contexts consumed by row components.+ */+export const SoupRowMetadataProvider: FlowComponent = (props) => {+ const { tagFilter } = useSoupView();++ return (+ <EmailLinksQueryProvider>+ <TagSetsProvider tagSets={tagFilter.tagSets}>+ {props.children}+ </TagSetsProvider>+ </EmailLinksQueryProvider>+ );+};diff --git a/apps/web/src/features/next-soup/soup-view/soup-view-context.tsx b/apps/web/src/features/next-soup/soup-view/soup-view-context.tsxindex 2496da8060..b009e2748f 100644--- a/apps/web/src/features/next-soup/soup-view/soup-view-context.tsx+++ b/apps/web/src/features/next-soup/soup-view/soup-view-context.tsx@@ -26,6 +26,10 @@ import {} from '@app/features/next-soup/filters/filter-store/query-store';import { createGroupedSoupQueries } from '@app/features/next-soup/soup-view/create-grouped-soup-queries';import { createSearchState } from '@app/features/next-soup/soup-view/create-search-state';+import {+ createTagFilter,+ type TagFilter,+} from '@app/features/next-soup/soup-view/filters-bar/tag-filter-state';import { dateBucket } from '@app/features/next-soup/soup-view/group-by-date';import {INBOX_FILTER_ENTRY_KEY,@@ -140,6 +144,8 @@ interface SoupViewContextValues {isSearchServiceLoading: Accessor<boolean>;isLocalSearchSettling: Accessor<boolean>;queryFilters: QueryStore;+ tagFilter: TagFilter;+ filterByTag: (optionId: string) => void;assigneeFilter: Accessor<string[]>;setAssigneeFilter: Setter<string[]>;ownerFilter: Accessor<string[]>;@@ -313,6 +319,8 @@ export const SoupViewContextProvider: FlowComponent<store.remove(query);},};+ const tagFilter = createTagFilter(queryFilters);+ const filterByTag = (optionId: string) => tagFilter.onChange([optionId]);const [searchPaused, setSearchPaused] = createSignal(false);const sourceSearchPaused = createMemo(() => searchPaused() || !enabled());@@ -1171,6 +1179,8 @@ export const SoupViewContextProvider: FlowComponent<isSearchServiceLoading: search.isSearchServiceLoading,isLocalSearchSettling: search.isLocalSearchSettling,queryFilters,+ tagFilter,+ filterByTag,assigneeFilter,setAssigneeFilter,ownerFilter,diff --git a/apps/web/src/features/next-soup/soup-view/soup-view.tsx b/apps/web/src/features/next-soup/soup-view/soup-view.tsxindex c8315f42b7..f62f6f42f4 100644--- a/apps/web/src/features/next-soup/soup-view/soup-view.tsx+++ b/apps/web/src/features/next-soup/soup-view/soup-view.tsx@@ -28,6 +28,7 @@ import {persistSoupNavigationTouchHighlight,soupNavigationTouchHighlight,} from '@app/features/next-soup/soup-view/soup-navigation-touch-highlight';+import { SoupRowMetadataProvider } from '@app/features/next-soup/soup-view/soup-row-metadata-provider';import { useSoupView } from '@app/features/next-soup/soup-view/soup-view-context';import { SoupViewCreateButton } from '@app/features/next-soup/soup-view/soup-view-create-button';import { SoupViewFileDropzone } from '@app/features/next-soup/soup-view/soup-view-file-dropzone';@@ -817,7 +818,20 @@ interface SoupViewListProps {scopeId?: string;}-export const SoupViewList = (props: SoupViewListProps) => {+/**+ * Complete soup-list composition boundary. Exported consumers receive the+ * shared metadata contexts required by every row and row-owned overlay.+ */+export const SoupViewList = (props: SoupViewListProps) => (+ <SoupRowMetadataProvider>+ <SoupViewListContent+ customScrollbarHidden={props.customScrollbarHidden}+ scopeId={props.scopeId}+ />+ </SoupRowMetadataProvider>+);++const SoupViewListContent = (props: SoupViewListProps) => {const panel = useSplitPanelOrThrow();const {soup,@@ -1696,8 +1710,8 @@ export const SoupViewList = (props: SoupViewListProps) => {);};-const DEFAULT_ITEM_SIZE = 10;const DEFAULT_OVERSCAN = 5;+const DEFAULT_ITEM_SIZE_ESTIMATE = 40;interface SoupListProps {ref?: (el: HTMLDivElement) => void;@@ -1720,7 +1734,6 @@ const SoupList = (props: SoupListProps) => {const [virtualizerHandle, setVirtualizerHandle] =createSignal<VirtualizerHandle>();- const itemSize = createMemo(() => props.itemSize ?? DEFAULT_ITEM_SIZE);const overscan = createMemo(() => props.overscan ?? DEFAULT_OVERSCAN);const [topSpacerRef, setTopSpacerRef] = createSignal<HTMLDivElement>();const topSpacerSize = createElementSize(topSpacerRef);@@ -1791,8 +1804,12 @@ const SoupList = (props: SoupListProps) => {ref={registerVirtualizerHandler}startMargin={topInset()}data={props.rows}- itemSize={itemSize()}- bufferSize={overscan() * itemSize()}+ // Leave itemSize unset for heterogeneous lists so Virtua measures+ // larger rows; 40px is only the default overscan estimate.+ itemSize={props.itemSize}+ bufferSize={+ overscan() * (props.itemSize ?? DEFAULT_ITEM_SIZE_ESTIMATE)+ }onScroll={handleScroll}>{(row, i) => props.children(row, i)}diff --git a/apps/web/src/features/next-soup/soup-view/views/tasks/task-grid-layout.tsx b/apps/web/src/features/next-soup/soup-view/views/tasks/task-grid-layout.tsxindex e37bfa9af3..711bf04325 100644--- a/apps/web/src/features/next-soup/soup-view/views/tasks/task-grid-layout.tsx+++ b/apps/web/src/features/next-soup/soup-view/views/tasks/task-grid-layout.tsx@@ -1,4 +1,4 @@-import { useRowTagFilter } from '@app/features/next-soup/soup-view/filters-bar/use-row-tag-filter';+import { useMaybeSoupView } from '@app/features/next-soup/soup-view/soup-view-context';import { UserIcon } from '@core/component/UserIcon';import { tryMacroId, useDisplayNameParts } from '@core/user';import {@@ -65,8 +65,8 @@ function buildStubProperty(col: TaskGridColumn): Property {}export function TaskGridLayout(props: LayoutProps) {+ const soupView = useMaybeSoupView();const currentId = useUserId();- const filterByTag = useRowTagFilter();const entity = () => props.entity as EntityWithProperties<EntityData>;const isShared = () => props.entity.ownerId !== currentId();@@ -194,7 +194,7 @@ export function TaskGridLayout(props: LayoutProps) {entityId={props.entity.id}entityType={EntityType.TASK}properties={entity().properties}- onFilterByTag={filterByTag}+ onFilterByTag={soupView?.filterByTag}class="ml-auto"/></Entity.Slot>diff --git a/apps/web/src/features/property/tags/EntityRowTags.tsx b/apps/web/src/features/property/tags/EntityRowTags.tsxindex 03f2f59a50..d9f5678fa4 100644--- a/apps/web/src/features/property/tags/EntityRowTags.tsx+++ b/apps/web/src/features/property/tags/EntityRowTags.tsx@@ -7,15 +7,13 @@ import type { SoupProperty } from '@service-storage/generated/schemas/soupProperimport { cn, HoverCard, Layer } from '@ui';import { createSignal, For, Match, Show, Switch } from 'solid-js';import { TagDot } from './TagDot';-import {- type EditableTag,- TagEditorDialog,- type TagEditorDialogMode,-} from './TagEditorDialog';+import { type EditableTag, TagEditorDialog } from './TagEditorDialog';import { TagPicker } from './TagPicker';-import { type ResolvedTag, useDocTags, useSoupDocTags } from './useDocTags';+import { useDocTags, useSoupDocTags } from './useDocTags';+import { type ResolvedTag, useSoupResolvedTags } from './useSoupResolvedTags';type DocTags = ReturnType<typeof useSoupDocTags>;+type CreateDocTags = () => DocTags;const DEFAULT_MAX_VISIBLE = 3;const MAX_OVERFLOW_DOTS = 3;@@ -131,9 +129,35 @@ function editableTagFromResolved(};}+function RowTagEditorOwner(props: {+ tag: ResolvedTag;+ createDocTags: CreateDocTags;+ onClose: () => void;+}) {+ // Editing is an interaction boundary: initialize query/mutation-backed tag+ // state only after the user asks to edit this row's tag.+ const docTags = props.createDocTags();+ const editable = () => editableTagFromResolved(docTags, props.tag);++ return (+ <Show when={editable()}>+ {(tag) => (+ <TagEditorDialog+ open+ mode={{ type: 'edit', tag: tag() }}+ teamAvailable={Boolean(+ docTags.tagSets().some((set) => set.scope === 'team')+ )}+ onClose={props.onClose}+ />+ )}+ </Show>+ );+}+function TagChip(props: {tag: ResolvedTag;- docTags: DocTags;+ createDocTags: CreateDocTags;onFilterByTag?: (id: string) => void;onEdit: (tag: ResolvedTag) => void;}) {@@ -152,7 +176,7 @@ function TagChip(props: {}><TagPicker- docTags={props.docTags}+ createDocTags={props.createDocTags}triggerClass={chipClass}triggerLabel={`Change or select tag ${props.tag.label}`}onOpenChange={setPickerOpen}@@ -167,7 +191,7 @@ function TagChip(props: {function TagOverflow(props: {tags: ResolvedTag[];- docTags: DocTags;+ createDocTags: CreateDocTags;onFilterByTag?: (id: string) => void;onEdit: (tag: ResolvedTag) => void;}) {@@ -196,7 +220,7 @@ function TagOverflow(props: {}><TagPicker- docTags={props.docTags}+ createDocTags={props.createDocTags}triggerClass={cn(chipClass, 'gap-1.5')}triggerLabel="Edit tags"onOpenChange={setPickerOpen}@@ -233,26 +257,16 @@ export function EntityRowTags(props: {class?: string;onFilterByTag?: (optionId: string) => void;}) {- const docTags = useSoupDocTags(- props.entityId,- props.entityType,- () => props.properties- );+ const appliedTags = useSoupResolvedTags(() => props.properties);+ const createDocTags = () =>+ useSoupDocTags(props.entityId, props.entityType, () => props.properties);const maxVisible = () => props.maxVisible ?? DEFAULT_MAX_VISIBLE;- const visible = () => docTags.appliedTags().slice(0, maxVisible());- const hidden = () => docTags.appliedTags().slice(maxVisible());- const [editorMode, setEditorMode] = createSignal<TagEditorDialogMode | null>(- null- );-- const openEdit = (tag: ResolvedTag) => {- const editable = editableTagFromResolved(docTags, tag);- if (!editable) return;- setEditorMode({ type: 'edit', tag: editable });- };+ const visible = () => appliedTags().slice(0, maxVisible());+ const hidden = () => appliedTags().slice(maxVisible());+ const [editingTag, setEditingTag] = createSignal<ResolvedTag>();return (- <Show when={docTags.appliedTags().length > 0}>+ <Show when={appliedTags().length > 0}><divclass={cn('flex items-center gap-1', props.class)}onClick={(event) => event.stopPropagation()}@@ -261,28 +275,29 @@ export function EntityRowTags(props: {{(tag) => (<TagChiptag={tag}- docTags={docTags}+ createDocTags={createDocTags}onFilterByTag={props.onFilterByTag}- onEdit={openEdit}+ onEdit={setEditingTag}/>)}</For><Show when={hidden().length > 0}><TagOverflowtags={hidden()}- docTags={docTags}+ createDocTags={createDocTags}onFilterByTag={props.onFilterByTag}- onEdit={openEdit}+ onEdit={setEditingTag}/></Show>- <TagEditorDialog- open={editorMode() !== null}- mode={editorMode()}- teamAvailable={Boolean(- docTags.tagSets().some((set) => set.scope === 'team')+ <Show when={editingTag()}>+ {(tag) => (+ <RowTagEditorOwner+ tag={tag()}+ createDocTags={createDocTags}+ onClose={() => setEditingTag(undefined)}+ />)}- onClose={() => setEditorMode(null)}- />+ </Show></div></Show>);diff --git a/apps/web/src/features/property/tags/TagPicker.tsx b/apps/web/src/features/property/tags/TagPicker.tsxindex f4f9d5e5d0..3800bd4c97 100644--- a/apps/web/src/features/property/tags/TagPicker.tsx+++ b/apps/web/src/features/property/tags/TagPicker.tsx@@ -62,21 +62,24 @@ function nextDisplayOrder(options: PropertyOptionResponse[]): number {const MAX_LIST_HEIGHT = 192;-export function TagPicker(props: {- docTags: DocTags;+type TagPickerProps = {replaceTag?: ResolvedTag;triggerClass?: string;triggerLabel: string;children: JSX.Element;onOpenChange?: (open: boolean) => void;-}) {+} & (+ | { docTags: DocTags; createDocTags?: never }+ | { docTags?: never; createDocTags: () => DocTags }+);++export function TagPicker(props: TagPickerProps) {const [open, setOpen] = createSignal(false);const [editorMode, setEditorMode] = createSignal<TagEditorDialogMode | null>(null);const [createSuccessHandler, setCreateSuccessHandler] =createSignal<CreateTagSuccessHandler>();- const currentTeamQuery = useCurrentTeamQuery();let saveAndClose: (() => Promise<void>) | undefined;const setOpenState = (value: boolean) => {@@ -98,52 +101,95 @@ export function TagPicker(props: {};return (- <>- <Popover- open={open()}- onOpenChange={handleOpenChange}- placement="bottom-start"- gutter={4}+ <Popover+ open={open()}+ onOpenChange={handleOpenChange}+ placement="bottom-start"+ gutter={4}+ >+ <Popover.Trigger+ type="button"+ class={props.triggerClass}+ aria-label={props.triggerLabel}>- <Popover.Trigger- type="button"- class={props.triggerClass}- aria-label={props.triggerLabel}- >- {props.children}- </Popover.Trigger>- <Show when={open()}>- <TagPickerBody- docTags={props.docTags}- onClose={() => setOpenState(false)}- onOpenCreateEditor={(mode, onCreateSuccess) => {- setCreateSuccessHandler(() => onCreateSuccess);- setEditorMode(mode);- setOpenState(false);- }}- onOpenEditEditor={(mode) => {- setEditorMode(mode);- setOpenState(false);- }}- registerSave={(handler) => {- saveAndClose = handler;- }}- suppressInitialOutsideEvents={false}- />- </Show>- </Popover>- <TagEditorDialog- open={editorMode() !== null}- mode={editorMode()}- teamAvailable={Boolean(currentTeamQuery.data?.team)}- onCreateSuccess={async (result) => {- await createSuccessHandler()?.(result);- }}- onClose={() => {- setEditorMode(null);- setCreateSuccessHandler(undefined);- }}- />+ {props.children}+ </Popover.Trigger>+ <Show when={open() || editorMode() !== null}>+ <TagPickerBodyOwner+ docTags={props.docTags}+ createDocTags={props.createDocTags}+ open={open}+ editorMode={editorMode}+ onClose={() => setOpenState(false)}+ onOpenCreateEditor={(mode, onCreateSuccess) => {+ setCreateSuccessHandler(() => onCreateSuccess);+ setEditorMode(mode);+ setOpenState(false);+ }}+ onOpenEditEditor={(mode) => {+ setEditorMode(mode);+ setOpenState(false);+ }}+ registerSave={(handler) => {+ saveAndClose = handler;+ }}+ createSuccessHandler={createSuccessHandler}+ onEditorClose={() => {+ setEditorMode(null);+ setCreateSuccessHandler(undefined);+ }}+ />+ </Show>+ </Popover>+ );+}++function TagPickerBodyOwner(props: {+ docTags?: DocTags;+ createDocTags?: () => DocTags;+ open: () => boolean;+ editorMode: () => TagEditorDialogMode | null;+ onClose: () => void;+ onOpenCreateEditor: (+ mode: Extract<TagEditorDialogMode, { type: 'create' }>,+ onCreateSuccess?: CreateTagSuccessHandler+ ) => void;+ onOpenEditEditor: (+ mode: Extract<TagEditorDialogMode, { type: 'edit' }>+ ) => void;+ registerSave: (handler: (() => Promise<void>) | undefined) => void;+ createSuccessHandler: () => CreateTagSuccessHandler | undefined;+ onEditorClose: () => void;+}) {+ // The factory is invoked under this conditionally-mounted component owner,+ // so row-level query/mutation hooks do not exist until the picker opens.+ const docTags = props.docTags ?? props.createDocTags?.();+ if (!docTags) throw new Error('TagPicker requires a doc-tags source');+ const currentTeamQuery = useCurrentTeamQuery();++ return (+ <>+ <Show when={props.open()}>+ <TagPickerBody+ docTags={docTags}+ onClose={props.onClose}+ onOpenCreateEditor={props.onOpenCreateEditor}+ onOpenEditEditor={props.onOpenEditEditor}+ registerSave={props.registerSave}+ suppressInitialOutsideEvents={false}+ />+ </Show>+ <Show when={props.editorMode()}>+ <TagEditorDialog+ open+ mode={props.editorMode()}+ teamAvailable={Boolean(currentTeamQuery.data?.team)}+ onCreateSuccess={async (result) => {+ await props.createSuccessHandler()?.(result);+ }}+ onClose={props.onEditorClose}+ />+ </Show></>);}diff --git a/apps/web/src/features/property/tags/tag-sets-context.test.tsx b/apps/web/src/features/property/tags/tag-sets-context.test.tsxnew file mode 100644index 0000000000..7002316bea--- /dev/null+++ b/apps/web/src/features/property/tags/tag-sets-context.test.tsx@@ -0,0 +1,90 @@+/**+ * @vitest-environment jsdom+ */++import { EntityType } from '@service-properties/generated/schemas/entityType';+import type { TagSetResponse } from '@service-properties/generated/schemas/tagSetResponse';+import type { SoupProperty } from '@service-storage/generated/schemas/soupProperty';+import { fireEvent, render, screen } from '@solidjs/testing-library';+import type { JSX } from 'solid-js';+import { beforeEach, describe, expect, it, vi } from 'vitest';+import { EntityRowTags } from './EntityRowTags';+import { TagSetsProvider } from './tag-sets-context';++const mocks = vi.hoisted(() => ({+ useDocTags: vi.fn(),+ useSoupDocTags: vi.fn(),+}));++vi.mock('./TagPicker', () => ({+ TagPicker: (props: {+ children: JSX.Element;+ createDocTags?: () => unknown;+ }) => (+ <button type="button" onClick={() => props.createDocTags?.()}>+ {props.children}+ </button>+ ),+}));++vi.mock('./TagDot', () => ({+ TagDot: () => <span data-testid="tag-dot" />,+}));++vi.mock('./useDocTags', () => ({+ useDocTags: mocks.useDocTags,+ useSoupDocTags: mocks.useSoupDocTags,+}));++beforeEach(() => {+ mocks.useDocTags.mockReset();+ mocks.useSoupDocTags.mockReset();+});++describe('TagSetsContext', () => {+ it('uses the real row resolver and initializes editing only on interaction', async () => {+ const tagSets = (): TagSetResponse[] => [+ {+ definition: { id: 'tag-definition' },+ scope: 'user',+ options: [+ {+ id: 'urgent-tag',+ propertyDefinitionId: 'tag-definition',+ displayOrder: 0,+ value: { type: 'string', value: 'Urgent' },+ },+ ],+ } as TagSetResponse,+ ];+ const properties = [+ {+ id: 'property-assignment',+ definition: { id: 'tag-definition' },+ value: { type: 'SelectOption', value: ['urgent-tag'] },+ } as SoupProperty,+ ];++ render(() => (+ <TagSetsProvider tagSets={tagSets}>+ <EntityRowTags+ entityId="document-1"+ entityType={EntityType.DOCUMENT}+ properties={properties}+ />+ </TagSetsProvider>+ ));++ expect(screen.getByText('Urgent')).toBeTruthy();+ expect(mocks.useSoupDocTags).not.toHaveBeenCalled();++ await fireEvent.click(screen.getByRole('button'));++ expect(mocks.useSoupDocTags).toHaveBeenCalledOnce();+ expect(mocks.useSoupDocTags).toHaveBeenCalledWith(+ 'document-1',+ EntityType.DOCUMENT,+ expect.any(Function)+ );+ });+});diff --git a/apps/web/src/features/property/tags/tag-sets-context.tsx b/apps/web/src/features/property/tags/tag-sets-context.tsxnew file mode 100644index 0000000000..ed002ddc39--- /dev/null+++ b/apps/web/src/features/property/tags/tag-sets-context.tsx@@ -0,0 +1,66 @@+import { useTagsQuery } from '@queries/properties/tags';+import type { PropertyOptionResponse } from '@service-properties/generated/schemas/propertyOptionResponse';+import type { TagScope } from '@service-properties/generated/schemas/tagScope';+import type { TagSetResponse } from '@service-properties/generated/schemas/tagSetResponse';+import {+ type Accessor,+ createContext,+ createMemo,+ type FlowComponent,+ useContext,+} from 'solid-js';++type TagSets = Accessor<TagSetResponse[]>;+type TagOption = { option: PropertyOptionResponse; scope: TagScope };+type TagSetsContextValue = {+ tagSets: TagSets;+ optionById: Accessor<ReadonlyMap<string, TagOption>>;+};++const TagSetsContext = createContext<TagSetsContextValue>();++/** Shares loaded tag definitions with a feature subtree. */+export const TagSetsProvider: FlowComponent<{ tagSets: TagSets }> = (props) => {+ const optionById = createMemo(() => {+ const options = new Map<string, TagOption>();+ for (const set of props.tagSets()) {+ for (const option of set.options) {+ options.set(option.id, { option, scope: set.scope });+ }+ }+ return options;+ });++ return (+ <TagSetsContext.Provider value={{ tagSets: props.tagSets, optionById }}>+ {props.children}+ </TagSetsContext.Provider>+ );+};++/** Explicit query-owning adapter for standalone tag-aware lists. */+export const TagSetsQueryProvider: FlowComponent = (props) => {+ const tagsQuery = useTagsQuery();+ const tagSets = (): TagSetResponse[] => tagsQuery.data ?? [];++ return <TagSetsProvider tagSets={tagSets}>{props.children}</TagSetsProvider>;+};++function useTagSetsContext(): TagSetsContextValue {+ const context = useContext(TagSetsContext);+ if (!context) {+ throw new Error('useTagSets can only be used under a TagSetsProvider');+ }++ return context;+}++/** Returns tag definitions from the nearest metadata provider. */+export function useTagSets(): TagSets {+ return useTagSetsContext().tagSets;+}++/** Returns the provider-owned tag-option index shared by every list row. */+export function useTagOptionById() {+ return useTagSetsContext().optionById;+}diff --git a/apps/web/src/features/property/tags/useDocTags.ts b/apps/web/src/features/property/tags/useDocTags.tsindex 6d177f5c1f..8f939fcc62 100644--- a/apps/web/src/features/property/tags/useDocTags.ts+++ b/apps/web/src/features/property/tags/useDocTags.ts@@ -22,14 +22,10 @@ import {} from 'solid-js';import { useEntityProperties } from '../hooks';import type { PropertyDefinitionDomain } from '../types';+import { useTagSets } from './tag-sets-context';+import type { ResolvedTag } from './useSoupResolvedTags';-export type ResolvedTag = {- optionId: string;- propertyDefinitionId: string;- scope: TagScope;- label: string;- color?: string;-};+export type { ResolvedTag } from './useSoupResolvedTags';function optionLabel(option: PropertyOptionResponse): string {return option.value.type === 'string' ? option.value.value : '';@@ -93,9 +89,9 @@ function usePersistTagSelection(function createDocTags(appliedOptionIdsForDefinition: (definitionId: string) => string[],- persistTagSelection: PersistTagSelection+ persistTagSelection: PersistTagSelection,+ tagSets: Accessor<TagSetResponse[]>) {- const tagsQuery = useTagsQuery();const ensureTagSet = useEnsureTagSetMutation();const [pendingOptionIdsByDefinition, setPendingOptionIdsByDefinition] =createSignal<Map<string, string[]>>(new Map());@@ -103,8 +99,6 @@ function createDocTags([]);- const tagSets = (): TagSetResponse[] => tagsQuery.data ?? [];-const definitionByScope = createMemo(() => {const map = new Map<TagScope, PropertyDefinitionDetailResponse>();for (const set of tagSets()) {@@ -322,7 +316,6 @@ function createDocTags(};return {- tagsQuery,tagSets,appliedTags,optionById,@@ -347,8 +340,14 @@ export function useDocTags(entityId: string, entityType: EntityType) {: [];};const persistTagSelection = usePersistTagSelection(entityId, entityType);+ const tagsQuery = useTagsQuery();+ const tagSets = (): TagSetResponse[] => tagsQuery.data ?? [];- return createDocTags(appliedOptionIdsForDefinition, persistTagSelection);+ return createDocTags(+ appliedOptionIdsForDefinition,+ persistTagSelection,+ tagSets+ );}/**@@ -369,19 +368,31 @@ export function useSoupDocTags(return value?.type === 'SelectOption' ? value.value : [];};const persistTagSelection = usePersistTagSelection(entityId, entityType);+ const tagSets = useTagSets();- return createDocTags(appliedOptionIdsForDefinition, persistTagSelection);+ return createDocTags(+ appliedOptionIdsForDefinition,+ persistTagSelection,+ tagSets+ );}export function useLocalDocTags(appliedOptionIdsForDefinition: (definitionId: string) => string[],setTagOptionIdsForDefinition: SetTagOptionIdsForDefinition) {- return createDocTags(appliedOptionIdsForDefinition, async (updates) => {- await Promise.all(- updates.map((update) =>- setTagOptionIdsForDefinition(update.definition, update.nextOptionIds)- )- );- });+ const tagsQuery = useTagsQuery();+ const tagSets = (): TagSetResponse[] => tagsQuery.data ?? [];++ return createDocTags(+ appliedOptionIdsForDefinition,+ async (updates) => {+ await Promise.all(+ updates.map((update) =>+ setTagOptionIdsForDefinition(update.definition, update.nextOptionIds)+ )+ );+ },+ tagSets+ );}diff --git a/apps/web/src/features/property/tags/useSoupResolvedTags.ts b/apps/web/src/features/property/tags/useSoupResolvedTags.tsnew file mode 100644index 0000000000..3302449961--- /dev/null+++ b/apps/web/src/features/property/tags/useSoupResolvedTags.ts@@ -0,0 +1,59 @@+import type { PropertyOptionResponse } from '@service-properties/generated/schemas/propertyOptionResponse';+import type { TagScope } from '@service-properties/generated/schemas/tagScope';+import type { SoupProperty } from '@service-storage/generated/schemas/soupProperty';+import { type Accessor, createMemo } from 'solid-js';+import { useTagOptionById, useTagSets } from './tag-sets-context';++export type ResolvedTag = {+ optionId: string;+ propertyDefinitionId: string;+ scope: TagScope;+ label: string;+ color?: string;+};++function optionLabel(option: PropertyOptionResponse): string {+ return option.value.type === 'string' ? option.value.value : '';+}++/**+ * Resolves the tags already present in soup properties without initializing+ * any edit mutations. Virtual rows use this read-only model until a picker is+ * actually opened.+ */+export function useSoupResolvedTags(+ properties: Accessor<SoupProperty[] | undefined>+): Accessor<ResolvedTag[]> {+ const tagSets = useTagSets();+ const tagOptionById = useTagOptionById();++ return createMemo(() => {+ const resolved: ResolvedTag[] = [];+ const options = tagOptionById();+ const soupProperties = properties();++ for (const set of tagSets()) {+ const definitionId = set.definition?.id;+ if (!definitionId) continue;+ const property = soupProperties?.find(+ (candidate) => candidate.definition.id === definitionId+ );+ const value = property?.value;+ if (value?.type !== 'SelectOption') continue;++ for (const optionId of value.value) {+ const tagOption = options.get(optionId);+ if (!tagOption) continue;+ resolved.push({+ optionId,+ propertyDefinitionId: tagOption.option.propertyDefinitionId,+ scope: tagOption.scope,+ label: optionLabel(tagOption.option),+ color: tagOption.option.color ?? undefined,+ });+ }+ }++ return resolved;+ });+}diff --git a/apps/web/src/lib/queries/contacts/contacts.ts b/apps/web/src/lib/queries/contacts/contacts.tsindex 29ccac8f93..c067d9fe36 100644--- a/apps/web/src/lib/queries/contacts/contacts.ts+++ b/apps/web/src/lib/queries/contacts/contacts.ts@@ -4,7 +4,7 @@ import { throwOnErr } from '@core/util/result';import { queryClient } from '@queries/client';import { contactsClient } from '@service-contacts/client';import { useQuery } from '@tanstack/solid-query';-import type { Accessor } from 'solid-js';+import { type Accessor, createMemo } from 'solid-js';import { contactsKeys } from './keys';function contactsQueryOptions() {@@ -24,7 +24,7 @@ function useContactsQuery() {*/export function useContacts(): Accessor<IUser[]> {const query = useContactsQuery();- return () => {+ return createMemo(() => {if (!query.isSuccess) return [];const contacts = query.data.contacts;return contacts.map((c) => ({@@ -32,7 +32,7 @@ export function useContacts(): Accessor<IUser[]> {email: idToEmail(c),name: idToDisplayName(c),}));- };+ });}export function invalidateContacts() {