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(tasks): scope assignee pickers to team members (#9497)
dev-rb6b9686fde6ea
diff --git a/.agents/rules/web/architecture.md b/.agents/rules/web/architecture.mdindex ee3c275d4c..f296035ece 100644--- a/.agents/rules/web/architecture.md+++ b/.agents/rules/web/architecture.md@@ -92,6 +92,7 @@ Module layout, layering, and TypeScript conventions.## TypeScript- Represent sets of independently enabled UI features with typed arrays instead of parallel boolean props.+- Declare TypeScript types and interfaces at module scope, outside functions and component bodies.- Name module-level value constants in `SCREAMING_SNAKE_CASE`, except schema definitions; keep functions and local variables in `camelCase`.- For exhaustive matching use `match(...).exhaustive()` from `ts-pattern`, neverdiff --git a/.agents/rules/web/solid.md b/.agents/rules/web/solid.mdindex 322431dde9..e553007e85 100644--- a/.agents/rules/web/solid.md+++ b/.agents/rules/web/solid.md@@ -64,7 +64,7 @@ State ownership, reactivity, and async error handling.expensive. Cheap derivations (() => a() + b()) don't need it regardless ofsubscriber count.- Before rolling your own reactive utility, check solid-primitives first.-- Use keyed reactive collections for mutable maps instead of cloning the whole map into a signal on each write.+- Never store `Set` or `Map` in signals; use arrays for small selections and reactive collections for keyed data.- Never read a solid-query `query.data` unguarded from a component body or aneager `createMemo`. `data` is a resource read: while the query is pending itsuspends the caller's nearest `<Suspense>`, which detaches and re-attachesdiff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex f1e79d6346..2f998fa599 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -1110,6 +1110,18 @@ and Escape return focus to the value through `Property.Root`; tabbing or clickinaway leaves focus where the user put it. The backend-free regression is`bunx playwright test --config src/features/property/editors/inline/browser-test/playwright.config.ts`.+### Assignee people scope++Use only the current team roster and available agents for new Assignee selections.+Keep existing selected outsiders visible and removable, without contact discovery.+Reuse the existing selected-first ordering at opening and keep row positions+stable while selecting. Keep the generic roster hook in `src/lib/queries/team/members.ts`.+Preserve each picker’s existing placeholder, sizing, and row styling.+Preserve filter-only Me/Unassigned choices, company-owner scope, and unrelated+people/contact fields.+Keep the shared filter Assignee picker in `src/features/soup/assignee-picker.tsx`;+import it directly from Tasks and legacy `next-soup` consumers.+### Sidebar tag draggingEmail and Calls sidebar tags can be dragged onto taggable desktop list rows.diff --git a/apps/web/src/components/view-shell/ListDropdowns.test.tsx b/apps/web/src/components/view-shell/ListDropdowns.test.tsxindex c21285c5e2..bc171d4eaa 100644--- a/apps/web/src/components/view-shell/ListDropdowns.test.tsx+++ b/apps/web/src/components/view-shell/ListDropdowns.test.tsx@@ -504,6 +504,12 @@ it('runs a searchable action once and closes without changing the selected optio<Combobox.Trigger>People</Combobox.Trigger></SearchableMultiSelect>));+ fireEvent.input(await screen.findByPlaceholderText('Search...'), {+ target: { value: 'no-match' },+ });+ await waitFor(() =>+ expect(screen.queryByRole('option', { name: 'Alice' })).toBeNull()+ );clickSearchOption(await screen.findByRole('option', { name: 'Connect account' }),truediff --git a/apps/web/src/components/view-shell/ListDropdowns.tsx b/apps/web/src/components/view-shell/ListDropdowns.tsxindex dbc54a4a8c..559a6ea02b 100644--- a/apps/web/src/components/view-shell/ListDropdowns.tsx+++ b/apps/web/src/components/view-shell/ListDropdowns.tsx@@ -209,6 +209,11 @@ export type ListFilterGroup<defaultOptionId?: TOptionId;searchPlaceholder?: string;contentClass?: string;+ /** Keep the source ordering instead of promoting selected options. */+ preserveOrder?: boolean;+ /** Optional content below a searchable group's options. */+ footer?: JSX.Element;+ onOpenChange?: (open: boolean) => void;};export type ListFilterDropdownProps<@@ -424,6 +429,9 @@ export function ListFilterDropdown<activeIds={() => selectedOptionIds(group())}onChange={(ids) => setSelectedOptionIds(group(), ids)}placeholder={group().searchPlaceholder}+ preserveOrder={group().preserveOrder}+ footer={group().footer}+ onOpenChange={group().onOpenChange}/></Show>)}diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/consolidated-filter-chip.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/consolidated-filter-chip.tsxindex c9d26bf1ab..e6739d00fc 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/consolidated-filter-chip.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/consolidated-filter-chip.tsx@@ -56,6 +56,7 @@ export type ConsolidatedFilter = {setPopupOpen?: (v: boolean) => void;/** Keep options in their given order instead of pinning selected first. */preserveOptionOrder?: boolean;+ searchFooter?: JSX.Element;};interface ConsolidatedFilterChipProps {@@ -263,6 +264,7 @@ const SearchableValueSegment = (props: {open={props.filter.isPopupOpen}onOpenChange={(v) => props.filter.setPopupOpen?.(v)}preserveOrder={props.filter.preserveOptionOrder}+ footer={props.filter.searchFooter}><Combobox.Triggerclass={cn(diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/filter-menu.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/filter-menu.tsxindex 2b021347ba..4fa7a27678 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/filter-menu.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/filter-menu.tsx@@ -385,6 +385,7 @@ export const SearchableFilterSubmenu = (props: {onOpenChange?: (v: boolean) => void;/** Keep `options` in their given order instead of pinning selected first. */preserveOrder?: boolean;+ footer?: JSX.Element;}) => {const submenu = createFilterSubmenuHover({open: props.open,@@ -450,6 +451,7 @@ export const SearchableFilterSubmenu = (props: {options={props.options}inputRef={setInputRef}preserveOrder={props.preserveOrder}+ footer={props.footer}/></Dropdown.Group></Dropdown.SubContent>diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsxindex 806165e633..a577a92abb 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx@@ -1,10 +1,7 @@import { MobileFilterDrawer as FilterDrawer } from '@app/components/view-shell/MobileFilterDrawer';import type { ListView } from '@app/constants/list-views';import { isListViewID } from '@app/constants/list-views';-import {- type FilterContext,- NO_ASSIGNEE,-} from '@app/features/next-soup/filters';+import type { FilterContext } from '@app/features/next-soup/filters';import {buildDocumentTypeQuery,getActiveDocumentTypeFilterIds,@@ -21,6 +18,10 @@ import {TASK_SORT_OPTIONS,} from '@app/features/next-soup/soup-view/sort-options';import { useSoupView } from '@app/features/next-soup/soup-view/soup-view-context';+import {+ AssigneePickerStatus,+ useAssigneePicker,+} from '@app/features/soup/assignee-picker';import { useFeatureFlag } from '@app/lib/analytics/posthog';import { t } from '@app/lib/i18n';import { MobileDrawer } from '@components/app/mobile/MobileDrawer';@@ -30,7 +31,7 @@ import { enableMultiInbox } from '@core/constant/featureFlags';import { useUserId } from '@core/context/user';import { useAddInboxFlow } from '@core/email-link';import { fireAndForget } from '@core/util/fireAndForget';-import CircleDashedIcon from '@icon/system/regular/circle-dashed.svg';+import { useSelectedFirst } from '@core/util/useSelectedFirst';import SearchIcon from '@icon/system/regular/magnifying-glass.svg';import PlusIcon from '@icon/system/regular/plus.svg';import { Accordion } from '@kobalte/core/accordion';@@ -73,6 +74,10 @@ export const MobileFilterDrawer = (props: {return undefined;return content.id;});+ const assigneePicker = useAssigneePicker(+ assigneeFilter,+ () => currentView() === 'tasks'+ );const categories = createMemo(() => {const view = currentView();@@ -204,47 +209,12 @@ export const MobileFilterDrawer = (props: {);};- const assigneeOptions = createMemo(() => {- const currentUserId = userId();- const noAssigneeOption = {- id: NO_ASSIGNEE,- label: t('viewMenus.unassigned'),- icon: () => <CircleDashedIcon class="size-3.5 text-ink-muted" />,- };- let meOption: typeof noAssigneeOption | undefined;- const otherContactOptions: (typeof noAssigneeOption)[] = [];- for (const contact of contacts()) {- const opt = {- id: contact.id,- label: buildContactLabel(contact, currentUserId),- icon: () => (- <UserIcon- id={contact.id}- size="sm"- suppressClick- showTooltip={false}- />- ),- };- if (contact.id === currentUserId) {- meOption = opt;- } else {- otherContactOptions.push(opt);- }- }- return [- ...(meOption ? [meOption] : []),- noAssigneeOption,- ...otherContactOptions,- ];- });-const filteredAssigneeOptions = createMemo(() => {const query = assigneeSearch().toLowerCase();- if (!query) return assigneeOptions();- return assigneeOptions().filter((o) =>- o.label.toLowerCase().includes(query)- );+ if (!query) return assigneePicker.options();+ return assigneePicker+ .options()+ .filter((o) => o.label.toLowerCase().includes(query));});const createdByOptions = createMemo(() => {@@ -291,12 +261,28 @@ export const MobileFilterDrawer = (props: {};const activeCount = () => consolidatedFiltersList().length;+ const [expandedSections, setExpandedSections] = createSignal([+ categories()[0]?.id ?? 'assignee',+ ]);+ const orderedAssigneeOptions = useSelectedFirst({+ items: filteredAssigneeOptions,+ selectedIds: assigneePicker.selectedIdsAtViewEntry,+ searchQuery: assigneeSearch,+ getId: (option) => option.id,+ sortDeps: [assigneePicker.selectedIdsAtViewEntry],+ });return (<Show when={hasFiltersOrCategories()}><FilterDrawerclass={props.class}activeCount={activeCount()}+ onOpenChange={(open) => {+ assigneePicker.onOpenChange(open);+ if (!open) {+ setAssigneeSearch('');+ }+ }}onClear={resetToTabDefaults}footer={<For each={consolidatedFiltersList()}>@@ -340,7 +326,16 @@ export const MobileFilterDrawer = (props: {<Accordionmultiplecollapsible- defaultValue={[categories()[0]?.id ?? 'assignee']}+ value={expandedSections()}+ onChange={(value) => {+ const wasOpen = expandedSections().includes('assignee');+ const isOpen = value.includes('assignee');+ if (wasOpen !== isOpen) {+ assigneePicker.onOpenChange(isOpen);+ if (!isOpen) setAssigneeSearch('');+ }+ setExpandedSections(value);+ }}>{/* Filter section */}<Show@@ -464,22 +459,22 @@ export const MobileFilterDrawer = (props: {<SearchIcon class="size-3.5 text-ink-muted shrink-0" /><inputtype="text"- aria-label={t('viewMenus.searchAssigneesLabel')}+ aria-label={assigneePicker.placeholder()}value={assigneeSearch()}onInput={(e) => setAssigneeSearch(e.currentTarget.value)}- placeholder={t('viewMenus.searchAssignees')}+ placeholder={assigneePicker.placeholder()}class="min-w-0 flex-1 bg-transparent text-base outline-none placeholder:text-ink-placeholder"/></div><div class="max-h-[calc(50*var(--dvh))] overflow-y-auto scrollbar-hidden">- <For each={filteredAssigneeOptions()}>+ <For each={orderedAssigneeOptions()}>{(option) => {const active = () => assigneeFilter().includes(option.id);return (<FilterDrawer.Optionchecked={active()}onChange={() => toggleAssignee(option.id)}- icon={option.icon()}+ icon={option.icon?.()}>{option.label}</FilterDrawer.Option>@@ -487,12 +482,12 @@ export const MobileFilterDrawer = (props: {}}</For></div>-<Show when={filteredAssigneeOptions().length === 0}><div class="px-4 py-2 text-sm text-ink-muted">{t('viewMenus.noResults')}</div></Show>+ <AssigneePickerStatus picker={assigneePicker} /></FilterDrawer.Section></Show>diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/search/mobile-search-filter-drawer.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/search/mobile-search-filter-drawer.tsxindex ab29c9cecc..c90f9c1c36 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/search/mobile-search-filter-drawer.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/search/mobile-search-filter-drawer.tsx@@ -4,7 +4,19 @@ import ChevronDownIcon from '@icon/system/regular/caret-down.svg';import SearchIcon from '@icon/system/regular/magnifying-glass.svg';import { Accordion } from '@kobalte/core/accordion';import { cn } from '@ui';-import { createMemo, createSignal, For, Match, Show, Switch } from 'solid-js';+import {+ type Accessor,+ createMemo,+ createSignal,+ For,+ Match,+ onCleanup,+ onMount,+ Show,+ Switch,+} from 'solid-js';+import { createStore } from 'solid-js/store';+import type { SearchableOption } from '../searchable-multi-select';import { type SearchFacetVM, useSearchFacets } from './search-facets';import { createSearchFiltersController } from './search-filters-state';@@ -34,8 +46,18 @@ function SingleFacetContent(props: { facet: SingleFacet }) {);}-function MultiFacetContent(props: { facet: MultiFacet }) {- const [query, setQuery] = createSignal('');+function MultiFacetContent(props: {+ facet: MultiFacet;+ query?: string;+ onQueryChange?: (query: string) => void;+}) {+ const [localQuery, setLocalQuery] = createSignal('');+ const query = () => props.query ?? localQuery();+ onMount(() => props.facet.onPickerOpenChange?.(true));+ onCleanup(() => {+ props.onQueryChange?.('');+ props.facet.onPickerOpenChange?.(false);+ });const filteredOptions = createMemo(() => {const q = query().toLowerCase();@@ -53,6 +75,53 @@ function MultiFacetContent(props: { facet: MultiFacet }) {);};+ const renderOptions = (options: Accessor<SearchableOption[]>) => (+ <>+ <div class="max-h-[calc(50*var(--dvh))] overflow-y-auto scrollbar-hidden">+ <For each={options()}>+ {(option) => {+ const active = () => props.facet.activeIds().includes(option.id);+ const isSole = () => {+ const ids = props.facet.activeIds();+ return ids.length === 1 && ids[0] === option.id;+ };+ return (+ <div class="w-full flex items-stretch gap-1">+ <MobileFilterDrawer.Option+ class="min-w-0 flex-1"+ checked={active()}+ onChange={() => toggle(option.id)}+ icon={option.icon?.()}+ >+ {option.label}+ </MobileFilterDrawer.Option>+ <Show+ when={props.facet.onOnly && props.facet.options().length > 1}+ >+ <button+ type="button"+ class="shrink-0 rounded-xl px-3 text-xs text-ink-muted hover:text-ink hover:bg-ink/6 transition-colors"+ aria-label={+ isSole()+ ? `Show all ${props.facet.label.toLowerCase()}`+ : `Show only ${option.label}`+ }+ onClick={() => props.facet.onOnly?.(option.id)}+ >+ {isSole() ? 'All' : 'Only'}+ </button>+ </Show>+ </div>+ );+ }}+ </For>+ <Show when={options().length === 0}>+ <div class="px-4 py-2 text-sm text-ink-muted">No results</div>+ </Show>+ </div>+ {props.facet.footer?.()}+ </>+ );return (<>{/* Any-of/all-of segment (e.g. tags), mirroring the desktop chip. */}@@ -89,67 +158,37 @@ function MultiFacetContent(props: { facet: MultiFacet }) {</div></Show>- <Show when={props.facet.options().length > SEARCHABLE_OPTION_COUNT}>+ <Show+ when={+ props.facet.id === 'task-assignee' ||+ props.facet.options().length > SEARCHABLE_OPTION_COUNT+ }+ ><div class="flex min-h-11 items-center gap-2 rounded-[20px] px-3 py-2 bg-ink/5 mb-1"><SearchIcon class="size-3.5 text-ink-muted shrink-0" /><inputtype="text"aria-label={props.facet.placeholder}value={query()}- onInput={(e) => setQuery(e.currentTarget.value)}+ onInput={(e) =>+ (props.onQueryChange ?? setLocalQuery)(e.currentTarget.value)+ }placeholder={props.facet.placeholder}class="min-w-0 flex-1 bg-transparent text-base outline-none placeholder:text-ink-placeholder"/></div></Show>- <div class="max-h-[calc(50*var(--dvh))] overflow-y-auto scrollbar-hidden">- <For each={filteredOptions()}>- {(option) => {- const active = () => props.facet.activeIds().includes(option.id);- const isSole = () => {- const ids = props.facet.activeIds();- return ids.length === 1 && ids[0] === option.id;- };- return (- <div class="w-full flex items-stretch gap-1">- <MobileFilterDrawer.Option- class="min-w-0 flex-1"- checked={active()}- onChange={() => toggle(option.id)}- icon={option.icon?.()}- >- {option.label}- </MobileFilterDrawer.Option>- <Show- when={props.facet.onOnly && props.facet.options().length > 1}- >- <button- type="button"- class="shrink-0 rounded-xl px-3 text-xs text-ink-muted hover:text-ink hover:bg-ink/6 transition-colors"- aria-label={- isSole()- ? `Show all ${props.facet.label.toLowerCase()}`- : `Show only ${option.label}`- }- onClick={() => props.facet.onOnly?.(option.id)}- >- {isSole() ? 'All' : 'Only'}- </button>- </Show>- </div>- );- }}- </For>- <Show when={filteredOptions().length === 0}>- <div class="px-4 py-2 text-sm text-ink-muted">No results</div>- </Show>- </div>+ {renderOptions(filteredOptions)}</>);}-function FacetSection(props: { facet: SearchFacetVM }) {+function FacetSection(props: {+ facet: SearchFacetVM;+ query?: string;+ onQueryChange?: (query: string) => void;+}) {return (<MobileDrawer.Sectionas={Accordion.Item}@@ -189,7 +228,13 @@ function FacetSection(props: { facet: SearchFacetVM }) {{(facet) => <SingleFacetContent facet={facet()} />}</Match><Match when={props.facet.kind === 'multi' && props.facet}>- {(facet) => <MultiFacetContent facet={facet()} />}+ {(facet) => (+ <MultiFacetContent+ facet={facet()}+ query={props.query}+ onQueryChange={props.onQueryChange}+ />+ )}</Match></Switch></Accordion.Content>@@ -208,6 +253,8 @@ function FacetSection(props: { facet: SearchFacetVM }) {export const MobileSearchFilterDrawer = (props: { class?: string }) => {const controller = createSearchFiltersController();const facets = useSearchFacets(controller);+ const [queries, setQueries] = createStore<Record<string, string>>({});+ const [expandedSections, setExpandedSections] = createSignal(['type']);const activeCount = createMemo(() => facets().filter((facet) => !facet.isDefault()).length@@ -223,9 +270,50 @@ export const MobileSearchFilterDrawer = (props: { class?: string }) => {label="Search filters"activeCount={activeCount()}onClear={resetAll}+ onOpenChange={(open) => {+ for (const facet of facets()) {+ if (facet.kind !== 'multi' || !facet.onPickerOpenChange) continue;+ facet.onPickerOpenChange(+ open && expandedSections().includes(facet.id)+ );+ if (!open) setQueries(facet.id, '');+ }+ }}>- <Accordion multiple collapsible defaultValue={['type']}>- <For each={facets()}>{(facet) => <FacetSection facet={facet} />}</For>+ <Accordion+ multiple+ collapsible+ value={expandedSections()}+ onChange={(value) => {+ for (const facet of facets()) {+ if (facet.kind !== 'multi' || !facet.onPickerOpenChange) continue;+ const wasOpen = expandedSections().includes(facet.id);+ const isOpen = value.includes(facet.id);+ if (wasOpen !== isOpen) {+ facet.onPickerOpenChange(isOpen);+ if (!isOpen) setQueries(facet.id, '');+ }+ }+ setExpandedSections(value);+ }}+ >+ <For each={facets()}>+ {(facet) => (+ <FacetSection+ facet={facet}+ query={+ facet.kind === 'multi' && facet.onPickerOpenChange+ ? (queries[facet.id] ?? '')+ : undefined+ }+ onQueryChange={+ facet.kind === 'multi' && facet.onPickerOpenChange+ ? (query) => setQueries(facet.id, query)+ : undefined+ }+ />+ )}+ </For></Accordion></MobileFilterDrawer>);diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-facet-chip.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-facet-chip.tsxindex 4f793b8822..05cce63209 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-facet-chip.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-facet-chip.tsx@@ -8,6 +8,7 @@ import {createSignal,For,Match,+ onCleanup,Show,Switch,} from 'solid-js';@@ -123,6 +124,7 @@ const MultiValueSegment = (props: {}) => {const panel = useSplitPanel();const [open, setOpen] = createSignal(false);+ onCleanup(() => props.facet.onPickerOpenChange?.(false));return (<SearchableMultiSelect@@ -133,9 +135,11 @@ const MultiValueSegment = (props: {onOnly={props.facet.onOnly}placeholder={props.facet.placeholder}preserveOrder={props.facet.preserveOrder}+ footer={props.facet.footer?.()}placement="bottom-start"open={open}onOpenChange={(v) => {+ props.facet.onPickerOpenChange?.(v);setOpen(v);if (!v) {queueMicrotask(() =>diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-facets.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-facets.tsxindex ff3ee9b62b..9aee20be93 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-facets.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/search/search-facets.tsx@@ -1,9 +1,14 @@import { useCalendarSearchUiFlag } from '@app/features/calendar/hooks/use-calendar-ui-flag';+import { NO_ASSIGNEE } from '@app/features/next-soup/filters';import type {CallStatus,PropertyFilter,TagFilterMode,} from '@app/features/next-soup/filters/filter-store/types';+import {+ AssigneePickerStatus,+ useAssigneePicker,+} from '@app/features/soup/assignee-picker';import { usePosthog } from '@app/lib/analytics/posthog';import { EntityIcon } from '@core/component/EntityIcon';import { UserIcon } from '@core/component/UserIcon';@@ -134,6 +139,8 @@ export type SearchFacetVM = FacetBase &preserveOrder?: boolean;onOnly?: (id: string) => void;mode?: FacetModeVM;+ footer?: () => JSX.Element;+ onPickerOpenChange?: (open: boolean) => void;});@@ -260,6 +267,10 @@ export function useSearchFacets(): Accessor<SearchFacetVM[]> {const channelOptions = useChannelPicker();const personOptions = usePersonPicker();+ const assigneePicker = useAssigneePicker(+ controller.taskAssignees,+ () => controller.type() === 'task'+ );const inboxPicker = useInboxPicker({selectedIds: controller.emailInbox,setSelectedIds: controller.setEmailInbox,@@ -432,15 +443,24 @@ export function useSearchFacets(onChange: controller.setTaskPriority,});- const taskAssignee = multiFacet({- id: 'task-assignee',- label: 'Assignee',- neutralLabel: 'Anyone',- placeholder: 'Search assignees...',- options: personOptions,- activeIds: controller.taskAssignees,- onChange: controller.setTaskAssignees,- });+ const taskAssignee: SearchFacetVM = {+ ...multiFacet({+ id: 'task-assignee',+ label: 'Assignee',+ neutralLabel: 'Anyone',+ placeholder: 'Search assignees...',+ options: () =>+ assigneePicker.options().filter((option) => option.id !== NO_ASSIGNEE),+ activeIds: controller.taskAssignees,+ onChange: controller.setTaskAssignees,+ }),+ options: () =>+ assigneePicker.options().filter((option) => option.id !== NO_ASSIGNEE),+ get placeholder() {+ return assigneePicker.placeholder();+ },+ footer: () => <AssigneePickerStatus picker={assigneePicker} />,+ };const taskCreatedBy = multiFacet({id: 'task-created-by',diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/searchable-multi-select.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/searchable-multi-select.tsxindex 7d02f01fa9..2cd287a926 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/searchable-multi-select.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/searchable-multi-select.tsx@@ -69,12 +69,28 @@ type SearchableMultiSelectProps = {open?: Accessor<boolean>;onOpenChange?: (open: boolean) => void;children: JSX.Element;+ footer?: JSX.Element;};// Options use virtual focus. A native pointer focus would land on the enclosing// dialog, dismissing the combobox before its pointer-up selection handler runs.const keepComboboxFocus = (event: Event) => event.preventDefault();+function PickerSearchInput(props: {+ placeholder?: string;+ onKeyDown?: (event: KeyboardEvent) => void;+ onReady?: (input: HTMLInputElement) => void;+}) {+ return (+ <Combobox.Input+ ref={props.onReady}+ onKeyDown={props.onKeyDown}+ class="flex-1 min-w-0 text-sm bg-transparent outline-none caret-accent placeholder:text-ink-placeholder"+ placeholder={props.placeholder ?? 'Search...'}+ />+ );+}+const SearchableMultiSelectItem = (itemProps: {item: CollectionNode<SearchableOption>;onOnly?: (id: string) => void;@@ -233,12 +249,13 @@ const VirtualizedListbox = (props: {>{(items) => {visibleItems = items;+ const rows = createMemo(() => [...items()]);return (<Virtualizerref={(h) => {handle = h;}}- data={[...items()]}+ data={rows()}itemSize={ITEM_HEIGHT}>{(item) => (@@ -288,12 +305,15 @@ const useActiveOptions = (const getOptionId = (opt: SearchableOption) => opt.id;+const filterWithAction = (option: SearchableOption, query: string) =>+ option.id === ACTION_ID ||+ option.label.toLowerCase().includes(query.toLowerCase());+export const SearchableMultiSelect = (props: SearchableMultiSelectProps) => {const [portalAnchor, setPortalAnchor] = createSignal<HTMLDivElement>();const selectionIntent = createMultiSelectIntent();const [internalOpen, setInternalOpen] = createSignal(false);const [searchQuery, setSearchQuery] = createSignal('');-const isOpen = () => props.open?.() ?? internalOpen();const setIsOpen = (v: boolean) => {if (props.onOpenChange) props.onOpenChange(v);@@ -315,10 +335,15 @@ export const SearchableMultiSelect = (props: SearchableMultiSelectProps) => {if (!action) return sortedOptions();return [...sortedOptions(),- { id: ACTION_ID, label: action.label, icon: action.icon },+ {+ id: ACTION_ID,+ label: action.label,+ icon: action.icon,+ },];});- const hasMatches = useHasMatches(displayOptions, searchQuery);+ const matches = useHasMatches(displayOptions, searchQuery);+ const hasMatches = () => !!props.action || matches();const handleOpenChange = (open: boolean) => {setIsOpen(open);@@ -326,9 +351,10 @@ export const SearchableMultiSelect = (props: SearchableMultiSelectProps) => {};const handleChange = (selected: SearchableOption[]) => {- if (props.action && selected.some((o) => o.id === ACTION_ID)) {+ const action = props.action;+ if (action && selected.some((o) => o.id === ACTION_ID)) {handleOpenChange(false);- props.action.onSelect();+ action.onSelect();return;}const id =@@ -375,6 +401,7 @@ export const SearchableMultiSelect = (props: SearchableMultiSelectProps) => {optionValue="id"optionTextValue="label"optionLabel="label"+ defaultFilter={props.action ? filterWithAction : undefined}optionDisabled="disabled"allowsEmptyCollectionvirtualized@@ -406,10 +433,7 @@ export const SearchableMultiSelect = (props: SearchableMultiSelectProps) => {><div class="flex items-center gap-2 px-3 py-2 border-b border-edge-muted"><SearchIcon class="size-3.5 text-ink-muted shrink-0" />- <Combobox.Input- class="flex-1 min-w-0 text-sm bg-transparent outline-none caret-accent placeholder:text-ink-placeholder"- placeholder={props.placeholder ?? 'Search...'}- />+ <PickerSearchInput placeholder={props.placeholder} /></div><div class="p-1"><Show@@ -430,6 +454,7 @@ export const SearchableMultiSelect = (props: SearchableMultiSelectProps) => {/></Show></div>+ {props.footer}</Combobox.Content></Layer></Combobox.Portal>@@ -448,6 +473,7 @@ type SearchableMultiSelectInlineProps = {listboxClass?: string;/** Keep `options` in their given order instead of pinning selected first. */preserveOrder?: boolean;+ footer?: JSX.Element;};/**@@ -461,9 +487,9 @@ export const SearchableMultiSelectInline = () => {const selectionIntent = createMultiSelectIntent();const [searchQuery, setSearchQuery] = createSignal('');-const activeOptions = useActiveOptions(props.options, props.activeIds);- const hasMatches = useHasMatches(props.options, searchQuery);+ const matches = useHasMatches(props.options, searchQuery);+ const hasMatches = matches;// Inline variant is freshly mounted each time the parent submenu opens,// so we don't need an explicit "menu opened" trigger — the memo's first// run captures the current selection ordering.@@ -475,6 +501,7 @@ export const SearchableMultiSelectInline = (});const sortedOptions = () =>props.preserveOrder ? props.options() : selectedFirstOptions();+ const displayOptions = sortedOptions;const handleChange = (selected: SearchableOption[]) => {const id =@@ -532,7 +559,7 @@ export const SearchableMultiSelectInline = (selectionBehavior="toggle"closeOnSelection={false}open- options={sortedOptions()}+ options={displayOptions()}value={activeOptions()}onChange={handleChange}onInputChange={setSearchQuery}@@ -549,11 +576,12 @@ export const SearchableMultiSelectInline = (class="flex items-center gap-2 px-3 py-2 border-b border-edge-muted"><SearchIcon class="size-3.5 text-ink-muted shrink-0" />- <Combobox.Input- ref={props.inputRef}+ <PickerSearchInput+ onReady={(element) => {+ props.inputRef?.(element);+ }}onKeyDown={handleInputKeyDown}- class="flex-1 min-w-0 text-sm bg-transparent outline-none caret-accent placeholder:text-ink-placeholder"- placeholder={props.placeholder ?? 'Search...'}+ placeholder={props.placeholder}/></div><div ref={selectionIntent.track} class="p-1">@@ -572,6 +600,7 @@ export const SearchableMultiSelectInline = (/></Show></div>+ {props.footer}</Combobox>);};diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.test.ts b/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.test.tsindex cc7d278f6c..a00e00d5f5 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.test.ts+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.test.ts@@ -1,9 +1,43 @@-import { describe, expect, it } from 'vitest';+import { useAssigneePicker } from '@app/features/soup/assignee-picker';+import { useSelectedFirst } from '@core/util/useSelectedFirst';+import { createRoot, createSignal } from 'solid-js';+import { describe, expect, it, vi } from 'vitest';import {type FilterCategory,filterInboxGithubPrOption,} from './filter-categories';+vi.mock('@core/context/user', () => ({+ useUserId: () => () => 'macro|[email protected]',+}));+vi.mock('@core/component/UserIcon', () => ({ UserIcon: () => null }));+vi.mock('@queries/team/members', () => ({+ useTeamMembers: () => ({+ users: () => [+ {+ id: 'macro|[email protected]',+ email: '[email protected]',+ name: 'Alice',+ },+ {+ id: 'macro|[email protected]',+ email: '[email protected]',+ name: 'Teammate',+ },+ ],+ isLoading: () => false,+ isError: () => false,+ }),+}));+vi.mock('@property/queries/agent-assignees', () => ({+ useAgentAssignees: () => () => [+ {+ id: 'bot|00000000-0000-0000-0000-000000000123',+ email: '',+ name: 'Agent',+ },+ ],+}));const categories: FilterCategory[] = [{id: 'type',@@ -39,3 +73,49 @@ describe('filterInboxGithubPrOption', () => {expect(filterInboxGithubPrOption(categories, false)[1]).toBe(categories[1]);});});++describe('Assignee filter ordering', () => {+ it('keeps team rows stable during selection and reorders on reopening', () => {+ createRoot((dispose) => {+ const [ids, setIds] = createSignal(['macro|[email protected]']);+ const picker = useAssigneePicker(ids, () => true);+ const ordered = useSelectedFirst({+ items: picker.options,+ selectedIds: picker.selectedIdsAtViewEntry,+ searchQuery: () => '',+ getId: (option) => option.id,+ sortDeps: [picker.selectedIdsAtViewEntry],+ });+ picker.onOpenChange(true);+ const initial = ordered().map((option) => option.id);+ setIds(['macro|[email protected]', 'macro|[email protected]']);+ expect(ordered().map((option) => option.id)).toEqual(initial);+ setIds(['macro|[email protected]']);+ expect(ordered().map((option) => option.id)).toEqual(initial);+ picker.onOpenChange(false);+ picker.onOpenChange(true);+ expect(ordered()[0].id).toBe('macro|[email protected]');+ expect(ordered()[1].id).toBe('bot|00000000-0000-0000-0000-000000000123');+ dispose();+ });+ });++ it('retains selected outsiders without offering unrelated contacts', () => {+ createRoot((dispose) => {+ const [ids, setIds] = createSignal(['macro|[email protected]']);+ const picker = useAssigneePicker(ids, () => true);+ picker.onOpenChange(true);+ expect(picker.selectedIdsAtViewEntry()).toEqual([+ 'macro|[email protected]',+ ]);+ expect(picker.options().at(-1)?.id).toBe('macro|[email protected]');+ setIds([]);+ expect(+ picker+ .options()+ .some((option) => option.id === 'macro|[email protected]')+ ).toBe(false);+ dispose();+ });+ });+});diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsxindex 4410e95ed2..fc257fa043 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx@@ -20,6 +20,11 @@ import {type ReadFilter,useSoupView,} from '@app/features/next-soup/soup-view/soup-view-context';+import {+ AssigneePickerStatus,+ buildContactLabel,+ useAssigneePicker,+} from '@app/features/soup/assignee-picker';import { t } from '@app/lib/i18n';import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';import { EntityIcon } from '@core/component/EntityIcon';@@ -27,7 +32,6 @@ import { UserIcon } from '@core/component/UserIcon';import { useUserId } from '@core/context/user';import { registerHotkey } from '@core/hotkey/hotkeys';import { TOKENS } from '@core/hotkey/tokens';-import CircleDashedIcon from '@icon/system/regular/circle-dashed.svg';import FilterIcon from '@icon/system/regular/funnel-simple.svg';import { PropertyValueIcon } from '@property/component/propertyValue/PropertyValueIcon';import { PROPERTY_OPTION_IDS, SYSTEM_PROPERTY_IDS } from '@property/constants';@@ -63,6 +67,8 @@ import {} from './filter-menu';import type { SearchableOption } from './searchable-multi-select';+export { buildContactLabel } from '@app/features/soup/assignee-picker';+import { useTagFilter } from './tag-filter';export type { FilterCategory, FilterOption } from './filter-categories';@@ -471,18 +477,6 @@ const DOCUMENTS_FILTER_CATEGORIES: FilterCategory[] = [},];-export function buildContactLabel(- contact: { id: string; name?: string | null },- currentUserId: string | undefined-): string {- if (contact.id === currentUserId) {- return contact.name- ? t('viewMenus.contactMe', { name: contact.name })- : t('viewMenus.me');- }- return contact.name || contact.id;-}-export const VIEW_FILTER_CATEGORIES: Record<ListView, FilterCategory[]> = {home: HOME_FILTER_CATEGORIES,// No refinements yet: the touched-by-me query rejects channel/email@@ -666,41 +660,10 @@ export const UnifiedFilterDropdown = (}};- // Assignee options for tasks view- const assigneeOptions = createMemo((): SearchableOption[] => {- const currentUserId = userId();- const noAssigneeOption: SearchableOption = {- id: NO_ASSIGNEE,- label: t('viewMenus.unassigned'),- icon: () => <CircleDashedIcon class="size-3.5 text-ink-muted" />,- };- let meOption: SearchableOption | undefined;- const otherContactOptions: SearchableOption[] = [];- for (const contact of contacts()) {- const opt: SearchableOption = {- id: contact.id,- label: buildContactLabel(contact, currentUserId),- icon: () => (- <UserIcon- id={contact.id}- size="sm"- suppressClick- showTooltip={false}- />- ),- };- if (contact.id === currentUserId) {- meOption = opt;- } else {- otherContactOptions.push(opt);- }- }- return [- ...(meOption ? [meOption] : []),- noAssigneeOption,- ...otherContactOptions,- ];- });+ const assigneePicker = useAssigneePicker(+ assigneeFilter,+ () => currentView() === 'tasks'+ );const handleAssigneeChange = (ids: string[]) => {const current = assigneeFilter();@@ -932,10 +895,11 @@ export const UnifiedFilterDropdown = (<SearchableFilterSubmenuonSelectionComplete={() => setOpen(false)}label={t('viewMenus.assignee')}- options={assigneeOptions}+ options={assigneePicker.options}activeIds={assigneeFilter}onChange={handleAssigneeChange}- placeholder={t('viewMenus.searchAssignees')}+ placeholder={assigneePicker.placeholder()}+ footer={<AssigneePickerStatus picker={assigneePicker} />}/></Show>diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/use-filter-refinements.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/use-filter-refinements.tsxindex e6edd76f5b..876c82cb74 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/use-filter-refinements.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/use-filter-refinements.tsx@@ -21,6 +21,10 @@ import {VIEW_TAB_PRESETS,} from '@app/features/next-soup/sidebar/soup-filter-presets';import { useSoupView } from '@app/features/next-soup/soup-view/soup-view-context';+import {+ AssigneePickerStatus,+ useAssigneePicker,+} from '@app/features/soup/assignee-picker';import { t } from '@app/lib/i18n';import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';import { UserIcon } from '@core/component/UserIcon';@@ -146,13 +150,17 @@ export function useFilterRefinements() {return hasClientFilterDiff || hasQueryFilterDiff || hasSubFilters;});+ const assigneePicker = useAssigneePicker(+ assigneeFilter,+ () => currentView() === 'tasks'+ );+/*** Human-readable options for the assignee sub-filter, keyed by assignee ID.- * Mirrors the same logic used in UnifiedFilterDropdown's assigneeOptions.+ * Uses the same team and selected-outsider options as the pickers.*/const assigneeOptionsMap = createMemo((): Map<string, { label: string; icon?: () => JSX.Element }> => {- const uid = currentUserId();const map = new Map<string,{ label: string; icon?: () => JSX.Element }@@ -161,61 +169,13 @@ export function useFilterRefinements() {label: t('viewMenus.unassigned'),icon: () => <CircleDashedIcon class="size-3 text-ink-muted" />,});- for (const contact of contacts()) {- map.set(contact.id, {- label: buildContactLabel(contact, uid),- icon: () => (- <UserIcon- id={contact.id}- size="sm"- suppressClick- showTooltip={false}- />- ),- });+ for (const option of assigneePicker.options()) {+ map.set(option.id, { label: option.label, icon: option.icon });}return map;});- /**- * Searchable options for the assignee filter (for use in searchable multi-select).- */- const assigneeSearchableOptions = createMemo((): SearchableOption[] => {- const uid = currentUserId();- const noAssigneeOption: SearchableOption = {- id: NO_ASSIGNEE,- label: t('viewMenus.unassigned'),- icon: () => <CircleDashedIcon class="size-3.5 text-ink-muted" />,- };- let meOption: SearchableOption | undefined;- const otherContactOptions: SearchableOption[] = [];- for (const contact of contacts()) {- const opt: SearchableOption = {- id: contact.id,- label: buildContactLabel(contact, uid),- icon: () => (- <UserIcon- id={contact.id}- size="sm"- suppressClick- showTooltip={false}- />- ),- };- if (contact.id === uid) {- meOption = opt;- } else {- otherContactOptions.push(opt);- }- }- return [- ...(meOption ? [meOption] : []),- noAssigneeOption,- ...otherContactOptions,- ];- });-/** Creator options for the Tasks and Files Created by filter. */const createdByOptionsMap = createMemo((): Map<string, { label: string; icon?: () => JSX.Element }> => {@@ -645,11 +605,14 @@ export function useFilterRefinements() {return t('viewMenus.assignee');},values: getValues,- searchableOptions: assigneeSearchableOptions,+ searchableOptions: assigneePicker.options,+ get searchFooter() {+ return <AssigneePickerStatus picker={assigneePicker} />;+ },activeSearchableIds: assigneeFilter,onSearchableChange: handleAssigneeChange,get searchPlaceholder() {- return t('viewMenus.searchAssignees');+ return assigneePicker.placeholder();},isPopupOpen,setPopupOpen,diff --git a/apps/web/src/features/property/README.md b/apps/web/src/features/property/README.mdindex d8a36686bd..aaa44258bb 100644--- a/apps/web/src/features/property/README.md+++ b/apps/web/src/features/property/README.md@@ -90,6 +90,27 @@ height on touch instead of adopting the shared button touch minimum. Onlythe task-detail title-row tags selector uses the 36px touch target; documenttitle-row tags retain their compact height.+## Assignee selection++The system Assignees property uses the existing selected-first ordering at opening+with available agents and the current team roster. Row positions stay stable while+selecting. Search uses these options without contact discovery; preserve the+existing Add/Change property and command-menu search placeholders.+Existing selected outsiders remain visible and removable, including references+absent from contacts. Removing an outsider removes that row immediately; the+picker cannot add that person again unless they join the team.++This applies to task/project composers, property pills, side panels, bulk+editors, and touch picker sheets. References remain `USER` values. Company owner+stays strictly team-only, and custom people properties keep their existing pool.+`src/lib/queries/team/members.ts` owns the shared non-suspending roster hook.+The property-aware wrapper in `editors/popover/EntityEditor.tsx` owns roster+scope, outsider retention, and roster-status UI. Keep that policy out of+`PropertyEntitySelector`; its empty-state content remains generic. Reuse existing+picker ordering rather than adding Assignee-specific priority APIs. The command-menu+composer/bulk editor lives in `editor/entity-property-editor.tsx`; both editor compositions share+`editors/selectors/scoped-user-options.ts`.+## Side-panel collectionsProperty rows use a 4px vertical gap, including inline Tags and the boundarydiff --git a/apps/web/src/features/property/editor/PropertyEditorModal.tsx b/apps/web/src/features/property/editor/PropertyEditorModal.tsxindex 894afcca1d..e680ccfa7b 100644--- a/apps/web/src/features/property/editor/PropertyEditorModal.tsx+++ b/apps/web/src/features/property/editor/PropertyEditorModal.tsx@@ -1,7 +1,5 @@import { toast } from '@core/component/Toast/Toast';import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';-import type { IUser } from '@core/user';-import { idToDisplayName, idToEmail } from '@core/user/util';import { createControlledOpenSignal } from '@core/util/createControlledOpenSignal';import { useDateSearch } from '@core/util/dateSearch/useDateSearch';import { fireAndForget } from '@core/util/fireAndForget';@@ -15,13 +13,10 @@ import CircleDashedEmpty from '@icon/system/regular/circle-dashed.svg';import PencilIcon from '@icon/system/regular/pencil-simple.svg';import PropertiesIcon from '@icon/system/regular/sliders-horizontal.svg';import TagIcon from '@icon/system/regular/tag-simple.svg';-import { type CombinedEntity, getEntityName, getEntityType } from '@property';import { CreatePropertyModal } from '@property/component/modal/CreatePropertyModal';import { PropertyValueIcon } from '@property/component/propertyValue';-import { SYSTEM_PROPERTY_IDS } from '@property/constants';import { OptionCheckBox } from '@property/editors/selectors/OptionCheckBox';import { usePropertySelection } from '@property/hooks';-import { usePropertyEntityDisplay } from '@property/hooks/usePropertyEntityDisplay';import { canTagEntity, useDocTags } from '@property/tags';import { TagDot } from '@property/tags/TagDot';import {@@ -78,8 +73,8 @@ import {Show,Switch,} from 'solid-js';+import { EntityPropertyEditor } from './entity-property-editor';import { useAllProperties } from './hooks/useAllProperties';-import { useEntitiesForProperty } from './hooks/useEntitiesForProperty';import { useSavePropertyForMultiEntitites } from './hooks/useSaveProperties';import {closePropertyEditor,@@ -192,13 +187,6 @@ function selectedOptionIds(return new Set(property.value ?? []);}-function selectedEntityRefs(- property: Property | PropertyDefinitionDomain-): EntityReference[] {- if (!('value' in property) || property.valueType !== 'ENTITY') return [];- return property.value ?? [];-}-function propertyEditorEntityType(entity: PropertyEditorEntity): EntityType {if ('entityType' in entity) return entity.entityType;if (isTaskEntity(entity)) return 'TASK';@@ -1394,7 +1382,6 @@ function PropertyValueEditor(props: {<EntityPropertyEditorproperty={resolvedProperty()}searchValue={props.searchValue}- setSearchValue={props.setSearchValue}selectedIndex={props.selectedIndex}setSelectedIndex={props.setSelectedIndex}onSubmit={handleSubmit}@@ -1713,332 +1700,6 @@ function SelectPropertyEditor(props: {);}-function EntityPropertyEditor(props: {- property?: Property | PropertyDefinitionDomain;- searchValue: Accessor<string>;- setSearchValue: Setter<string>;- selectedIndex: Accessor<number>;- setSelectedIndex: Setter<number>;- onSubmit: (value: EntityReference) => void;- onSave: (- apiValues: PropertyApiValues,- event?: KeyboardEvent | MouseEvent- ) => void;- setKeybindings: (binding: ListNavActions) => void;- setPlaceholder: Setter<string>;- selectedEntityCount: number;-}) {- // Company owners are always teammates, so the owner picker offers the- // team roster instead of the default quick-access people pool (same as- // the row-cell owner editor in EntityEditor).- const isCompanyOwner = () => {- const property = props.property;- if (!property) return false;- const definitionId =- 'propertyDefinitionId' in property- ? property.propertyDefinitionId- : property.id;- return definitionId === SYSTEM_PROPERTY_IDS.COMPANY_OWNER;- };- const teamQuery = useCurrentTeamQuery();- const teamMembers = (): IUser[] =>- (teamQuery.data?.members ?? []).map((member) => ({- id: member.user_id,- email: idToEmail(member.user_id),- name: idToDisplayName(member.user_id),- }));-- const { entities } = useEntitiesForProperty(- () => props.property,- props.searchValue,- { users: () => (isCompanyOwner() ? teamMembers() : undefined) }- );- const [localSelectedRefs, setLocalSelectedRefs] = createSignal(- props.property ? selectedEntityRefs(props.property) : []- );- const [orderedSelectedIds, setOrderedSelectedIds] = createSignal(- new Set(- props.property- ? selectedEntityRefs(props.property).map((ref) => ref.entity_id)- : []- )- );- let syncedPropertyId = props.property ? propertyIdentity(props.property) : '';- let syncedSelectionKey = props.property- ? selectedEntityRefs(props.property)- .map((ref) => ref.entity_id)- .sort()- .join('\0')- : '';- const [openOrderFrozen, setOpenOrderFrozen] = createSignal(false);-- createEffect(() => {- const propertyId = props.property ? propertyIdentity(props.property) : '';- const refs = props.property ? selectedEntityRefs(props.property) : [];- const nextSelectionKey = refs- .map((ref) => ref.entity_id)- .sort()- .join('\0');-- if (propertyId !== syncedPropertyId) {- syncedPropertyId = propertyId;- syncedSelectionKey = nextSelectionKey;- setOpenOrderFrozen(false);- setLocalSelectedRefs(refs);- setOrderedSelectedIds(new Set(refs.map((ref) => ref.entity_id)));- return;- }-- if (openOrderFrozen() || nextSelectionKey === syncedSelectionKey) return;-- syncedSelectionKey = nextSelectionKey;- setLocalSelectedRefs(refs);- setOrderedSelectedIds(new Set(refs.map((ref) => ref.entity_id)));- });-- createEffect(() => {- const entityTypeLabel =- props.property?.specificEntityType?.toLowerCase() || 'entity';- props.setPlaceholder(`Search for ${entityTypeLabel}...`);- });-- createEffect(() => {- props.searchValue();- props.setSelectedIndex(0);- });-- const selectEntity = (entity: CombinedEntity) => {- const entityType = getEntityType(entity);- if (!entityType) return;- const entityRef: EntityReference = {- entity_id: entity.id,- entity_type: entityType,- };- props.onSubmit(entityRef);- };-- const canGroupMultiValues = () =>- Boolean(- props.property?.isMultiSelect &&- props.selectedEntityCount === 1 &&- props.property &&- 'value' in props.property- );-- const localSelectedIds = createMemo(- () => new Set(localSelectedRefs().map((ref) => ref.entity_id))- );-- const orderedEntities = createMemo(() => {- if (!canGroupMultiValues()) return entities();-- const selectedAtOpen = orderedSelectedIds();- const selected = entities().filter((entity) =>- selectedAtOpen.has(entity.id)- );- const remaining = entities().filter(- (entity) => !selectedAtOpen.has(entity.id)- );-- return [...selected, ...remaining];- });-- const selectedGroupSize = createMemo(() =>- canGroupMultiValues()- ? orderedEntities().filter((entity) =>- orderedSelectedIds().has(entity.id)- ).length- : 0- );-- const searchQuery = () => props.searchValue().trim();- const showClearAllRow = () =>- canGroupMultiValues() && orderedSelectedIds().size > 0;- const showClearAllAtTop = () => showClearAllRow() && !searchQuery();- const showClearAllAtBottom = () => showClearAllRow() && !!searchQuery();-- type EntityPropertyRow =- | { type: 'clear'; separatorBefore: boolean }- | {- type: 'entity';- entity: CombinedEntity;- separatorBefore: boolean;- };-- const rows = createMemo(() => {- const nextRows: EntityPropertyRow[] = [];-- if (showClearAllAtTop()) {- nextRows.push({ type: 'clear', separatorBefore: false });- }-- for (const [index, entity] of orderedEntities().entries()) {- nextRows.push({- type: 'entity',- entity,- separatorBefore:- canGroupMultiValues() && index === selectedGroupSize() && index > 0,- });- }-- if (showClearAllAtBottom()) {- nextRows.push({- type: 'clear',- separatorBefore: orderedEntities().length > 0,- });- }-- return nextRows;- });-- const toggleEntity = (- entity: CombinedEntity,- event?: KeyboardEvent | MouseEvent- ) => {- if (!canGroupMultiValues()) {- selectEntity(entity);- return;- }-- const entityType = getEntityType(entity);- if (!entityType) return;- const selectedIds = localSelectedIds();- setOpenOrderFrozen(true);- const nextRefs = selectedIds.has(entity.id)- ? localSelectedRefs().filter((ref) => ref.entity_id !== entity.id)- : [- ...localSelectedRefs(),- {- entity_id: entity.id,- entity_type: entityType,- },- ];-- setLocalSelectedRefs(nextRefs);- props.onSave(- {- valueType: 'ENTITY',- refs: nextRefs.length > 0 ? nextRefs : null,- },- event- );- };-- const clearAllEntities = (event?: KeyboardEvent | MouseEvent) => {- if (!showClearAllRow()) return;-- setOpenOrderFrozen(true);- setLocalSelectedRefs([]);- props.onSave({ valueType: 'ENTITY', refs: null }, event);- };-- const selectRow = (- row: EntityPropertyRow,- event?: KeyboardEvent | MouseEvent- ) => {- if (row.type === 'clear') {- clearAllEntities(event);- return;- }-- toggleEntity(row.entity, event);- };-- const listController = createCommandListController({- items: rows,- selectedIndex: props.selectedIndex,- setSelectedIndex: props.setSelectedIndex,- });-- props.setKeybindings({- select: (event) => {- const row = rows()[props.selectedIndex()];- if (row) selectRow(row, event);- },- next: () => {- listController.selectNext();- },- previous: () => {- listController.selectPrevious();- },- });-- return (- <Show- when={rows().length > 0}- fallback={- <CommandMenuEmptyState>- {props.searchValue().trim()- ? 'No matching entities found'- : 'No entities available'}- </CommandMenuEmptyState>- }- >- <CommandMenuList- items={rows()}- selectedIndex={props.selectedIndex()}- scrollSelectedIntoView={listController.shouldScrollSelectedIntoView()}- itemId={(_, index) => `entity-option-${index}`}- beforeItem={(row) =>- row.separatorBefore ? (- <div class="mx-2 my-1 h-px bg-edge-muted/50" />- ) : null- }- onSelect={(row, _, event) => selectRow(row, event)}- onItemMouseMove={(index) =>- listController.setSelectedIndexFromPointer(index)- }- >- {(row) => (- <Switch>- <Match when={row.type === 'clear'}>- <CircleDashedEmpty class="size-4 text-ink-muted opacity-50" />- <span class="min-w-0 flex-1 truncate text-ink-muted">- Clear all{' '}- {props.property?.displayName.toLowerCase() ?? 'entities'}- </span>- </Match>- <Match when={row.type === 'entity' && row.entity}>- {(entity) => (- <EntityRowContent- entity={entity()}- multiselect={canGroupMultiValues()}- selected={localSelectedIds().has(entity().id)}- />- )}- </Match>- </Switch>- )}- </CommandMenuList>- </Show>- );-}--function EntityRowContent(props: {- entity: CombinedEntity;- multiselect?: boolean;- selected?: boolean;-}) {- const { icon } = usePropertyEntityDisplay(- () => props.entity.id,- () => getEntityType(props.entity)- );-- return (- <>- <Show when={props.multiselect}>- <OptionCheckBox checked={Boolean(props.selected)} multiselect />- </Show>- <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>;diff --git a/apps/web/src/features/property/editor/entity-property-editor.tsx b/apps/web/src/features/property/editor/entity-property-editor.tsxnew file mode 100644index 0000000000..0bbb809119--- /dev/null+++ b/apps/web/src/features/property/editor/entity-property-editor.tsx@@ -0,0 +1,391 @@+import { t } from '@app/lib/i18n';+import type { ListNavActions } from '@core/util/useListKeyBindings';+import CircleDashedEmpty from '@icon/system/regular/circle-dashed.svg';+import { useTeamMembers } from '@queries/team/members';+import type { EntityReference } from '@service-properties/generated/schemas/entityReference';+import {+ CommandMenuEmptyState,+ CommandMenuList,+ createCommandListController,+} from '@ui';+import {+ type Accessor,+ createEffect,+ createMemo,+ createSignal,+ createUniqueId,+ Match,+ type Setter,+ Show,+ Switch,+} from 'solid-js';+import { SYSTEM_PROPERTY_IDS } from '../constants';+import {+ type CombinedEntity,+ getEntityName,+ getEntityType,+ useQuickAccessEntities,+} from '../editors/selectors/entityUtils';+import { OptionCheckBox } from '../editors/selectors/OptionCheckBox';+import { scopedUserOptions } from '../editors/selectors/scoped-user-options';+import { usePropertyEntityDisplay } from '../hooks/usePropertyEntityDisplay';+import { useAgentAssignees } from '../queries/agent-assignees';+import type {+ Property,+ PropertyApiValues,+ PropertyDefinitionDomain,+} from '../types';+import { useEntitiesForProperty } from './hooks/useEntitiesForProperty';++type EntityPropertyRow =+ | { type: 'clear'; separatorBefore: boolean }+ | {+ type: 'entity';+ entity: CombinedEntity;+ separatorBefore: boolean;+ };++function selectedEntityRefs(+ property: Property | PropertyDefinitionDomain+): EntityReference[] {+ if (!('value' in property) || property.valueType !== 'ENTITY') return [];+ return property.value ?? [];+}++export function EntityPropertyEditor(props: {+ property?: Property | PropertyDefinitionDomain;+ searchValue: Accessor<string>;+ selectedIndex: Accessor<number>;+ setSelectedIndex: Setter<number>;+ onSubmit: (value: EntityReference) => void;+ onSave: (+ apiValues: PropertyApiValues,+ event?: KeyboardEvent | MouseEvent+ ) => void;+ setKeybindings: (binding: ListNavActions) => void;+ setPlaceholder: Setter<string>;+ selectedEntityCount: number;+}) {+ const definitionId = () => {+ const property = props.property;+ if (!property) return '';+ if ('propertyDefinitionId' in property) {+ return property.propertyDefinitionId;+ }++ return property.id;+ };+ const isCompanyOwner = () =>+ definitionId() === SYSTEM_PROPERTY_IDS.COMPANY_OWNER;+ const isAssignees = () => definitionId() === SYSTEM_PROPERTY_IDS.ASSIGNEES;+ const agents = useAgentAssignees(isAssignees);+ const team = useTeamMembers(() => isCompanyOwner() || isAssignees());+ const [localSelectedRefs, setLocalSelectedRefs] = createSignal(+ props.property ? selectedEntityRefs(props.property) : []+ );+ const [orderedSelectedIds, setOrderedSelectedIds] = createSignal(+ localSelectedRefs().map((ref) => ref.entity_id)+ );+ let syncedPropertyId = definitionId();+ let syncedSelectionKey = props.property+ ? selectedEntityRefs(props.property)+ .map((ref) => ref.entity_id)+ .sort()+ .join('\0')+ : '';+ const [openOrderFrozen, setOpenOrderFrozen] = createSignal(false);++ createEffect(() => {+ const propertyId = definitionId();+ const refs = props.property ? selectedEntityRefs(props.property) : [];+ const nextSelectionKey = refs+ .map((ref) => ref.entity_id)+ .sort()+ .join('\0');++ if (propertyId !== syncedPropertyId) {+ syncedPropertyId = propertyId;+ syncedSelectionKey = nextSelectionKey;+ setOpenOrderFrozen(false);+ setLocalSelectedRefs(refs);+ setOrderedSelectedIds(refs.map((ref) => ref.entity_id));+ return;+ }++ if (openOrderFrozen() || nextSelectionKey === syncedSelectionKey) return;++ syncedSelectionKey = nextSelectionKey;+ setLocalSelectedRefs(refs);+ setOrderedSelectedIds(refs.map((ref) => ref.entity_id));+ });++ createEffect(() => {+ const entityTypeLabel =+ props.property?.specificEntityType?.toLowerCase() || 'entity';+ props.setPlaceholder(`Search for ${entityTypeLabel}...`);+ });++ createEffect(() => {+ props.searchValue();+ props.setSelectedIndex(0);+ });++ const selectEntity = (entity: CombinedEntity) => {+ const entityType = getEntityType(entity);+ if (!entityType) return;+ const entityRef: EntityReference = {+ entity_id: entity.id,+ entity_type: entityType,+ };+ props.onSubmit(entityRef);+ };++ const canGroupMultiValues = () => {+ if (!props.property?.isMultiSelect) return false;+ if (props.selectedEntityCount !== 1) return false;++ return 'value' in props.property;+ };++ const localSelectedIds = createMemo(() =>+ localSelectedRefs().map((ref) => ref.entity_id)+ );+ const { items: people } = useQuickAccessEntities(() => 'USER');+ const users = createMemo(() => {+ if (!isCompanyOwner() && !isAssignees()) return undefined;+ const pool = [...agents(), ...team.users()];+ if (!isAssignees()) return pool;+ return scopedUserOptions(+ pool,+ people().map((item) => item.data),+ localSelectedIds()+ );+ });+ const { entities } = useEntitiesForProperty(+ () => props.property,+ props.searchValue,+ {+ users,+ selectedIds: () => {+ if (!isAssignees()) return undefined;++ return localSelectedIds();+ },+ }+ );++ const orderedEntities = createMemo(() => {+ if (!canGroupMultiValues()) return entities();++ const selectedAtOpen = orderedSelectedIds();+ const selected = entities().filter((entity) =>+ selectedAtOpen.includes(entity.id)+ );+ const remaining = entities().filter(+ (entity) => !selectedAtOpen.includes(entity.id)+ );++ return [...selected, ...remaining];+ });++ const searchQuery = () => props.searchValue().trim();+ const showClearAllRow = () =>+ canGroupMultiValues() && orderedSelectedIds().length > 0;+ const showClearAllAtTop = () => showClearAllRow() && !searchQuery();+ const showClearAllAtBottom = () => showClearAllRow() && !!searchQuery();++ const rows = createMemo(() => {+ const nextRows: EntityPropertyRow[] = [];++ if (showClearAllAtTop()) {+ nextRows.push({ type: 'clear', separatorBefore: false });+ }++ for (const [index, entity] of orderedEntities().entries()) {+ let separatorBefore = false;+ if (canGroupMultiValues() && index > 0) {+ const previous = orderedEntities()[index - 1];+ const selectedAtOpen = orderedSelectedIds();+ separatorBefore =+ selectedAtOpen.includes(previous.id) &&+ !selectedAtOpen.includes(entity.id);+ }++ nextRows.push({ type: 'entity', entity, separatorBefore });+ }++ if (showClearAllAtBottom()) {+ nextRows.push({+ type: 'clear',+ separatorBefore: orderedEntities().length > 0,+ });+ }++ return nextRows;+ });++ const toggleEntity = (+ entity: CombinedEntity,+ event?: KeyboardEvent | MouseEvent+ ) => {+ if (!canGroupMultiValues()) {+ selectEntity(entity);+ return;+ }++ const entityType = getEntityType(entity);+ if (!entityType) return;+ const selectedIds = localSelectedIds();+ setOpenOrderFrozen(true);+ const nextRefs = localSelectedRefs().filter(+ (ref) => ref.entity_id !== entity.id+ );+ if (!selectedIds.includes(entity.id)) {+ nextRefs.push({ entity_id: entity.id, entity_type: entityType });+ }++ setLocalSelectedRefs(nextRefs);+ props.onSave(+ {+ valueType: 'ENTITY',+ refs: nextRefs.length > 0 ? nextRefs : null,+ },+ event+ );+ };++ const clearAllEntities = (event?: KeyboardEvent | MouseEvent) => {+ if (!showClearAllRow()) return;++ setOpenOrderFrozen(true);+ setLocalSelectedRefs([]);+ props.onSave({ valueType: 'ENTITY', refs: null }, event);+ };++ const selectRow = (+ row: EntityPropertyRow,+ event?: KeyboardEvent | MouseEvent+ ) => {+ if (row.type === 'clear') {+ clearAllEntities(event);+ return;+ }++ toggleEntity(row.entity, event);+ };++ const listController = createCommandListController({+ items: rows,+ selectedIndex: props.selectedIndex,+ setSelectedIndex: props.setSelectedIndex,+ });++ props.setKeybindings({+ select: (event) => {+ const row = rows()[props.selectedIndex()];+ if (row) selectRow(row, event);+ },+ next: () => {+ listController.selectNext();+ },+ previous: () => {+ listController.selectPrevious();+ },+ });++ const listId = createUniqueId();+ return (+ <div>+ <Show+ when={rows().length > 0}+ fallback={+ <CommandMenuEmptyState>+ <Switch+ fallback={+ props.searchValue().trim()+ ? 'No matching entities found'+ : 'No entities available'+ }+ >+ <Match when={isAssignees() && team.isLoading()}>+ {t('viewMenus.loadingTeamMembers')}+ </Match>+ <Match when={isAssignees() && team.isError()}>+ {t('viewMenus.teamMembersUnavailable')}+ </Match>+ </Switch>+ </CommandMenuEmptyState>+ }+ >+ <Show when={isAssignees() && (team.isLoading() || team.isError())}>+ <div role="status" class="px-3 py-2 text-sm text-ink-muted">+ {team.isLoading()+ ? t('viewMenus.loadingTeamMembers')+ : t('viewMenus.teamMembersUnavailable')}+ </div>+ </Show>+ <CommandMenuList+ items={rows()}+ selectedIndex={props.selectedIndex()}+ scrollSelectedIntoView={listController.shouldScrollSelectedIntoView()}+ itemId={(_, index) => `${listId}-entity-option-${index}`}+ beforeItem={(row) =>+ row.separatorBefore ? (+ <div class="mx-2 my-1 h-px bg-edge-muted/50" />+ ) : null+ }+ onSelect={(row, _, event) => selectRow(row, event)}+ onItemMouseMove={(index) =>+ listController.setSelectedIndexFromPointer(index)+ }+ >+ {(row) => (+ <Switch>+ <Match when={row.type === 'clear'}>+ <CircleDashedEmpty class="size-4 text-ink-muted opacity-50" />+ <span class="min-w-0 flex-1 truncate text-ink-muted">+ Clear all{' '}+ {props.property?.displayName.toLowerCase() ?? 'entities'}+ </span>+ </Match>+ <Match when={row.type === 'entity' && row.entity}>+ {(entity) => (+ <EntityRowContent+ entity={entity()}+ multiselect={canGroupMultiValues()}+ selected={localSelectedIds().includes(entity().id)}+ />+ )}+ </Match>+ </Switch>+ )}+ </CommandMenuList>+ </Show>+ </div>+ );+}++function EntityRowContent(props: {+ entity: CombinedEntity;+ multiselect?: boolean;+ selected?: boolean;+}) {+ const { icon } = usePropertyEntityDisplay(+ () => props.entity.id,+ () => getEntityType(props.entity)+ );++ return (+ <>+ <Show when={props.multiselect}>+ <OptionCheckBox checked={Boolean(props.selected)} multiselect />+ </Show>+ <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>+ </>+ );+}diff --git a/apps/web/src/features/property/editor/hooks/useEntitiesForProperty.ts b/apps/web/src/features/property/editor/hooks/useEntitiesForProperty.tsindex 511b79176b..c4868d2cdb 100644--- a/apps/web/src/features/property/editor/hooks/useEntitiesForProperty.ts+++ b/apps/web/src/features/property/editor/hooks/useEntitiesForProperty.ts@@ -3,6 +3,14 @@ import { type IUser, useAugmentUserWithDmActivity } from '@core/user';import { createFreshSearch } from '@core/util/freshSort';import type { EmailEntity } from '@entity';import { createEmailsInfiniteQuery } from '@entity';+import { useSearchSoupQuery } from '@queries/soup/search';+import { debounce } from '@solid-primitives/scheduled';+import {+ type Accessor,+ createEffect,+ createMemo,+ createSignal,+} from 'solid-js';import {type CombinedEntity,createEntitySearchConfig,@@ -15,25 +23,20 @@ import {threadMapper,useQuickAccessEntities,userToEntity,-} from '@property';-import type { Property, PropertyDefinitionDomain } from '@property/types';-import { useSearchSoupQuery } from '@queries/soup/search';-import { debounce } from '@solid-primitives/scheduled';-import {- type Accessor,- createEffect,- createMemo,- createSignal,-} from 'solid-js';+} from '../../editors/selectors/entityUtils';+import type { Property, PropertyDefinitionDomain } from '../../types';++type EntityPropertyOptions = {+ /** Explicit USER pool replacing Quick Access people. */+ users?: Accessor<IUser[] | undefined>;+ /** Keep selected entities available beyond the initial result limit. */+ selectedIds?: Accessor<string[] | undefined>;+};export function useEntitiesForProperty(property: Accessor<Property | PropertyDefinitionDomain | undefined>,searchQuery: Accessor<string>,- options?: {- /** Explicit pool for USER pickers (e.g. company owner → team members);- * when it returns a list, it replaces the quick-access people list. */- users?: Accessor<IUser[] | undefined>;- }+ options?: EntityPropertyOptions) {const [searchTerm, setSearchTerm] = createSignal('');@@ -158,7 +161,20 @@ export function useEntitiesForProperty(// When no search query, sort self to top BEFORE slicingif (!query) {- return sortEntitiesWithSelfFirst(available, userId).slice(0, MAX_RESULTS);+ const visible = sortEntitiesWithSelfFirst(available, userId).slice(+ 0,+ MAX_RESULTS+ );+ const selectedIds = options?.selectedIds?.();+ if (selectedIds) {+ for (const entity of available) {+ if (!selectedIds.includes(entity.id)) continue;+ if (visible.some((item) => item.id === entity.id)) continue;++ visible.push(entity);+ }+ }+ return visible;}const localResults = entitySearch(available, query)diff --git a/apps/web/src/features/property/editors/popover/EntityEditor.test.tsx b/apps/web/src/features/property/editors/popover/EntityEditor.test.tsxindex 81fe6e19e9..ffa11b4b0c 100644--- a/apps/web/src/features/property/editors/popover/EntityEditor.test.tsx+++ b/apps/web/src/features/property/editors/popover/EntityEditor.test.tsx@@ -28,8 +28,12 @@ vi.mock('@core/user', () => ({useAugmentUserWithDmActivity: () => (user: unknown) => user,}));vi.mock('@core/user/util', () => ({- idToEmail: (id: string) => id,- idToDisplayName: (id: string) => id,+ idToEmail: (id: string) => id.replace('macro|', ''),+ idToDisplayName: (id: string) => {+ if (id === 'macro|[email protected]') return 'Alice';+ if (id === 'macro|[email protected]') return 'Teammate';+ return id.replace('macro|', '');+ },}));vi.mock('@core/component/UserIcon', () => ({ UserIcon: () => <span /> }));vi.mock('@core/context/quickAccess', () => ({@@ -59,6 +63,15 @@ vi.mock('@core/context/quickAccess', () => ({email: '[email protected]',},},+ {+ kind: 'user',+ id: 'macro|[email protected]',+ data: {+ id: 'macro|[email protected]',+ name: 'Outside',+ email: '[email protected]',+ },+ },],}),}),@@ -81,7 +94,16 @@ vi.mock('@queries/soup/search', () => ({useSearchSoupQuery: () => ({ status: 'pending', isFetching: false }),}));vi.mock('@queries/team/teams', () => ({- useCurrentTeamQuery: () => ({ data: null }),+ useCurrentTeamQuery: () => ({+ isPending: false,+ isError: false,+ data: {+ members: [+ { user_id: 'macro|[email protected]' },+ { user_id: 'macro|[email protected]' },+ ],+ },+ }),}));vi.mock('../../queries/agent-assignees', () => ({useAgentAssignees: (enabled: () => boolean) => () =>@@ -168,9 +190,50 @@ beforeAll(() => {Element.prototype.scrollIntoView = vi.fn();});-afterEach(cleanup);+afterEach(() => {+ cleanup();+});describe('assigning an agent through task and project properties', () => {+ it.each([+ { Editor: EntityEditor, search: false },+ { Editor: EntitySheetEditor, search: false },+ { Editor: EntityEditor, search: true },+ { Editor: EntitySheetEditor, search: true },+ ])(+ 'supports keyboard agent assignment (search: $search)',+ async ({ Editor, search }) => {+ const onSave = setup(undefined, property, Editor);+ if (search) {+ const input = screen.getByRole('textbox');+ fireEvent.input(input, { target: { value: 'research' } });+ await waitFor(() => expect(screen.queryByText('Alice')).toBeNull());+ await screen.findByText('Research assistant');+ }+ fireEvent.keyDown(screen.getByRole('textbox'), {+ key: 'ArrowDown',+ });+ fireEvent.keyDown(screen.getByRole('textbox'), {+ key: 'Enter',+ });+ fireEvent.click(+ screen.getByText(Editor === EntitySheetEditor ? 'Done' : 'Dismiss')+ );+ await waitFor(() =>+ expect(onSave).toHaveBeenCalledExactlyOnceWith(+ property,+ {+ valueType: 'ENTITY',+ refs: [+ { entity_id: userId, entity_type: 'USER' },+ { entity_id: agentId, entity_type: 'USER' },+ ],+ },+ new Map([[agentId, 'Research assistant']])+ )+ );+ }+ );it.each([{ name: 'new task', selfFilter: undefined },{@@ -193,7 +256,7 @@ describe('assigning an agent through task and project properties', () => {'Agents assigned to this project automatically take on tasks created in or moved into it. Use a shared team agent for tasks added by teammates.') !== null).toBe(selfFilter?.entityType === 'INITIATIVE');- fireEvent.input(screen.getByPlaceholderText('Add assignees...'), {+ fireEvent.input(screen.getByRole('textbox'), {target: { value: 'research' },});await waitFor(() => expect(screen.queryByText('Alice')).toBeNull());@@ -258,11 +321,111 @@ describe('assigning an agent through task and project properties', () => {});});+describe('team-first assignees', () => {+ it.each([EntityEditor, EntitySheetEditor])(+ 'keeps selected rows in place until the picker reopens',+ async (Editor) => {+ const onSave = setup(undefined, property, Editor);+ const teammateRow = screen+ .getByText('Teammate')+ .closest('[data-entity-index]')!;+ const originalIndex = teammateRow.getAttribute('data-entity-index');+ fireEvent.click(screen.getByText('Teammate'));+ const selectedRow = screen+ .getByText('Teammate')+ .closest('[data-entity-index]')!;+ expect(selectedRow.getAttribute('data-entity-index')).toBe(originalIndex);+ expect(selectedRow.querySelector('input')?.checked).toBe(true);+ fireEvent.click(+ screen.getByText(Editor === EntitySheetEditor ? 'Done' : 'Dismiss')+ );+ const selected: EntityProperty = {+ ...property,+ value: [+ { entity_id: userId, entity_type: 'USER' },+ { entity_id: 'macro|[email protected]', entity_type: 'USER' },+ ],+ };+ await waitFor(() =>+ expect(onSave).toHaveBeenCalledWith(+ property,+ { valueType: 'ENTITY', refs: selected.value },+ new Map([['macro|[email protected]', 'Teammate']])+ )+ );+ cleanup();+ setup(undefined, selected, Editor);+ expect(+ Number(+ screen+ .getByText('Teammate')+ .closest('[data-entity-index]')!+ .getAttribute('data-entity-index')+ )+ ).toBeLessThan(+ Number(+ screen+ .getByText('Research assistant')+ .closest('[data-entity-index]')!+ .getAttribute('data-entity-index')+ )+ );+ }+ );+ it.each([EntityEditor, EntitySheetEditor])(+ 'does not assign a non-team contact through search or Enter',+ async (Editor) => {+ const onSave = setup(undefined, property, Editor);+ const input = screen.getByRole('textbox');+ expect(screen.getByText('Teammate')).toBeTruthy();+ expect(screen.queryByText('Outside')).toBeNull();+ fireEvent.input(input, { target: { value: 'outside' } });+ await waitFor(() => expect(screen.queryByText('Teammate')).toBeNull());+ expect(screen.queryByText('Outside')).toBeNull();+ fireEvent.keyDown(input, { key: 'Enter' });+ fireEvent.click(+ screen.getByText(Editor === EntitySheetEditor ? 'Done' : 'Dismiss')+ );+ expect(onSave).not.toHaveBeenCalled();+ }+ );++ it('removes a selected outsider missing from contacts', async () => {+ const assigned: EntityProperty = {+ ...property,+ value: [{ entity_id: 'macro|[email protected]', entity_type: 'USER' }],+ };+ const onSave = setup(undefined, assigned);+ fireEvent.click(screen.getByText('[email protected]'));+ expect(screen.queryByText('[email protected]')).toBeNull();+ fireEvent.click(screen.getByText('Dismiss'));+ await waitFor(() =>+ expect(onSave).toHaveBeenCalledWith(+ assigned,+ { valueType: 'ENTITY', refs: null },+ new Map([['macro|[email protected]', '[email protected]']])+ )+ );+ });++ it('keeps custom people fields broad and company owners strictly team-only', () => {+ setup(undefined, { ...property, propertyDefinitionId: 'custom-people' });+ expect(screen.getByText('Outside')).toBeTruthy();+ cleanup();+ setup(undefined, {+ ...property,+ propertyDefinitionId: SYSTEM_PROPERTY_IDS.COMPANY_OWNER,+ });+ expect(screen.getByText('Teammate')).toBeTruthy();+ expect(screen.queryByText('Outside')).toBeNull();+ expect(screen.queryByRole('button', { name: 'Find contacts' })).toBeNull();+ });+});describe('people in a picker sheet', () => {it('drops the picks on Escape and saves them on Done', async () => {const dropped = setup(undefined, property, EntitySheetEditor);fireEvent.click(screen.getByText('Research assistant'));- fireEvent.keyDown(screen.getByPlaceholderText('Add assignees...'), {+ fireEvent.keyDown(screen.getByRole('textbox'), {key: 'Escape',});expect(screen.queryByRole('dialog')).toBeNull();diff --git a/apps/web/src/features/property/editors/popover/EntityEditor.tsx b/apps/web/src/features/property/editors/popover/EntityEditor.tsxindex f0fb614d91..3314be7f1c 100644--- a/apps/web/src/features/property/editors/popover/EntityEditor.tsx+++ b/apps/web/src/features/property/editors/popover/EntityEditor.tsx@@ -1,21 +1,22 @@+import { t } from '@app/lib/i18n';import { PickerSheet } from '@components/app/mobile/PickerSheet';-import type { IUser } from '@core/user';-import { idToDisplayName, idToEmail } from '@core/user/util';import { fireAndForget } from '@core/util/fireAndForget';import { SYSTEM_PROPERTY_IDS } from '@property/constants';import {entityReferencesToIdSet,updateEntityReferences,} from '@property/utils/entityConversion';-import { useCurrentTeamQuery } from '@queries/team/teams';+import { useTeamMembers } from '@queries/team/members';import type { EntityReference } from '@service-properties/generated/schemas/entityReference';import type { EntityType } from '@service-properties/generated/schemas/entityType';-import { createSignal, Show, Suspense } from 'solid-js';+import { createMemo, createSignal, Show, Suspense } from 'solid-js';import { useProperty } from '../../core/context';import { useAgentAssignees } from '../../queries/agent-assignees';import type { EntityProperty, PropertyApiValues } from '../../types';import { isEntityProperty } from '../../utils';+import { useQuickAccessEntities } from '../selectors/entityUtils';import { PropertyEntitySelector } from '../selectors/PropertyEntitySelector';+import { scopedUserOptions } from '../selectors/scoped-user-options';import type { EntityPickerOptions } from '../selectors/types';import { EditorPopover } from './EditorPopover';@@ -116,20 +117,26 @@ function EntityEditorSelector() {const property = props.draft.property;- // Company owners are always teammates, so the owner picker offers the- // team roster instead of the default quick-access people pool.const isCompanyOwner =property.propertyDefinitionId === SYSTEM_PROPERTY_IDS.COMPANY_OWNER;- const agents = useAgentAssignees(- () => property.propertyDefinitionId === SYSTEM_PROPERTY_IDS.ASSIGNEES- );- const teamQuery = useCurrentTeamQuery();- const teamMembers = (): IUser[] =>- (teamQuery.data?.members ?? []).map((member) => ({- id: member.user_id,- email: idToEmail(member.user_id),- name: idToDisplayName(member.user_id),- }));+ const isAssignees =+ property.propertyDefinitionId === SYSTEM_PROPERTY_IDS.ASSIGNEES;+ const agents = useAgentAssignees(() => isAssignees);+ const team = useTeamMembers(() => isCompanyOwner || isAssignees);+ const { items: people } = useQuickAccessEntities(() => 'USER');+ const users = createMemo(() => {+ if (!isAssignees) return team.users();+ return scopedUserOptions(+ [...agents(), ...team.users()],+ people().map((item) => item.data),+ props.draft.selectedRefs().map((ref) => ref.entity_id)+ );+ });+ const showRosterStatus = () => {+ if (!isCompanyOwner && !isAssignees) return false;++ return team.isLoading() || team.isError();+ };return (<>@@ -148,10 +155,10 @@ function EntityEditorSelector(specificEntityType:props.entityPicker?.entityTypes ?? property.specificEntityType,selfFilter: props.selfFilter,- users: isCompanyOwner ? teamMembers : undefined,- additionalUsers: agents,+ users: isCompanyOwner || isAssignees ? users : undefined,fillHeight: props.fillHeight,}}+ emptyState={showRosterStatus() ? null : undefined}selectedOptions={() =>entityReferencesToIdSet(props.draft.selectedRefs())}@@ -169,6 +176,13 @@ function EntityEditorSelector(onCancel={props.onCancel}/></Suspense>+ <Show when={showRosterStatus()}>+ <div role="status" class="shrink-0 px-3 py-2 text-sm text-ink-muted">+ {team.isLoading()+ ? t('viewMenus.loadingTeamMembers')+ : t('viewMenus.teamMembersUnavailable')}+ </div>+ </Show><Showwhen={props.selfFilter?.entityType === 'INITIATIVE' &&diff --git a/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsx b/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsxindex 5461ef0621..6317bd045b 100644--- a/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsx+++ b/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsx@@ -25,6 +25,7 @@ import {createMemo,createSignal,For,+ type JSX,onCleanup,onMount,Show,@@ -55,6 +56,8 @@ type EntityInputProps = {onClose?: () => void;/** Escape in the search; `onClose` when absent, as a popover saves on close. */onCancel?: () => void;+ /** Override empty-result content; null hides the default message. */+ emptyState?: JSX.Element;};function getEntityTypePluralLabel(@@ -117,6 +120,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {const [inputValue, setInputValue] = createSignal('');const [searchTerm, setSearchTerm] = createSignal('');const [selectedIndex, setSelectedIndex] = createSignal(0);+ const openedSelectedIds = [...props.selectedOptions()];const keyboardMode = useKeyPressed(100);let scrollContainerRef: HTMLDivElement | undefined;@@ -185,6 +189,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {});const isLoadingEntities = createMemo(() => {+ if (props.config.users) return false;if (needsEmailSearch()) {return (emailsQuery.isLoading ||@@ -195,17 +200,23 @@ export function PropertyEntitySelector(props: EntityInputProps) {return isQuickAccessLoading();});- // Convert quickAccess items to CombinedEntity format+ // An explicit user pool replaces Quick Access options.+ const scopedUserEntities = createMemo(() => {+ if (props.config.specificEntityType !== 'USER' || !props.config.users) {+ return undefined;+ }+ return [+ ...props.config.users(),+ ...(props.config.additionalUsers?.() ?? []),+ ].map((user) => userToEntity(augmentUserWithDmActivity(user)));+ });++ // Convert quickAccess items to CombinedEntity format.const entities = createMemo((): CombinedEntity[] => {+ const scoped = scopedUserEntities();+ if (scoped) return scoped;const specificEntityType = props.config.specificEntityType;- // An explicit user pool replaces the quick-access people list.- if (specificEntityType === 'USER' && props.config.users) {- return props.config- .users()- .map((user) => userToEntity(augmentUserWithDmActivity(user)));- }-// For THREAD type, use email data (not in quickAccess yet)if (specificEntityType === 'THREAD') {return emails().map(threadMapper);@@ -294,17 +305,18 @@ export function PropertyEntitySelector(props: EntityInputProps) {!(getEntityType(e) === currentEntityType && e.id === blockId): () => true;- // Get visible entities based on search- // Sort self to top BEFORE slicing to ensure self appears even if not in top 50 by default- const localResults = term- ? entitySearch(allEntities, term)- .slice(0, MAX_SEARCH_RESULTS)- .map((result) => result.item)- .filter(excludeFilter)- : sortEntitiesWithSelfFirst(- allEntities.filter(excludeFilter),- userId- ).slice(0, MAX_VISIBLE_ENTITIES_NO_SEARCH);+ let localResults: CombinedEntity[];+ if (term) {+ localResults = entitySearch(allEntities, term)+ .slice(0, MAX_SEARCH_RESULTS)+ .map((result) => result.item)+ .filter(excludeFilter);+ } else {+ localResults = sortEntitiesWithSelfFirst(+ allEntities.filter(excludeFilter),+ userId+ ).slice(0, MAX_VISIBLE_ENTITIES_NO_SEARCH);+ }// For THREAD or generic entity: merge local + server resultsif (needsEmailSearch() && term) {@@ -325,22 +337,11 @@ export function PropertyEntitySelector(props: EntityInputProps) {const sortedEntities = useSelectedFirst({items: filteredEntities,allItems: entities,- selectedIds: props.selectedOptions,+ selectedIds: () => openedSelectedIds,searchQuery: searchTerm,getId: (e: CombinedEntity) => e.id,});- const openedSelectedIds = new Set(props.selectedOptions());- const selectedEntityCountAtOpen = createMemo(() => {- if (!props.config.isMultiSelect || searchTerm()) return 0;- return sortedEntities().filter((entity) => openedSelectedIds.has(entity.id))- .length;- });- const shouldShowSelectedDivider = (index: number) =>- selectedEntityCountAtOpen() > 0 &&- selectedEntityCountAtOpen() < sortedEntities().length &&- index === selectedEntityCountAtOpen();-const toggleEntity = (entity: CombinedEntity) => {const entityType = getEntityType(entity);if (!entityType) return;@@ -375,12 +376,12 @@ export function PropertyEntitySelector(props: EntityInputProps) {}};- const totalCount = () => sortedEntities().length + (customEmail() ? 1 : 0);+ const resultCount = () => sortedEntities().length + (customEmail() ? 1 : 0);// Reset selected index to top when search term or list changescreateEffect(() => {searchTerm(); // track search term changes- totalCount(); // track list size changes+ resultCount(); // track list size changessetSelectedIndex(0);});@@ -395,6 +396,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {});const handleKeyDown = (e: KeyboardEvent) => {+ if (e.target instanceof HTMLElement && e.target.closest('button')) return;// Another field on the page keeps its own keys.if (e.target !== searchInputRef &&@@ -402,8 +404,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {isEditableInput(e.target))return;-- const total = totalCount();+ const total = resultCount();if (total === 0) return;if (e.key === 'ArrowDown' || (e.ctrlKey && e.key === 'j')) {@@ -438,6 +439,21 @@ export function PropertyEntitySelector(props: EntityInputProps) {const fills = () => props.config.fillHeight === true;const keepSearchFocus = (event: Event) => event.preventDefault();+ const selectedEntityCountAtOpen = createMemo(() => {+ if (!props.config.isMultiSelect || searchTerm()) return 0;++ return sortedEntities().filter((entity) =>+ openedSelectedIds.includes(entity.id)+ ).length;+ });+ const shouldShowSelectedDivider = (index: number) => {+ const selectedCount = selectedEntityCountAtOpen();+ if (selectedCount === 0) return false;+ if (selectedCount === sortedEntities().length) return false;++ return index === selectedCount;+ };+return (<div class={cn(fills() && 'flex min-h-0 flex-1 flex-col')}><div class="relative shrink-0">@@ -460,11 +476,10 @@ export function PropertyEntitySelector(props: EntityInputProps) {/></div></div>-- <Show when={totalCount() > 0}>+ <Show when={resultCount() > 0}>{/* Picking a row keeps focus in the search field: a tap that moved- it would drop the phone keyboard until the refocus below. iOS- devices still send mousedown after a cancelled pointerdown. */}+ it would drop the phone keyboard until the refocus below. iOS+ devices still send mousedown after a cancelled pointerdown. */}<divclass={cn('p-1.5', fills() && 'flex min-h-0 flex-1 flex-col')}onPointerDown={keepSearchFocus}@@ -625,13 +640,20 @@ export function PropertyEntitySelector(props: EntityInputProps) {</div></Show>- <Show when={totalCount() === 0}>- <div class="text-center py-4 text-ink-muted text-sm">- <Show when={!isLoadingEntities()} fallback={<span>Loading...</span>}>- {props.config.emptyMessage ??- `No ${getEntityTypePluralLabel(props.config.specificEntityType)} found`}- </Show>- </div>+ <Show when={resultCount() === 0}>+ {props.emptyState !== undefined ? (+ props.emptyState+ ) : (+ <div class="text-center py-4 text-ink-muted text-sm">+ <Show+ when={!isLoadingEntities()}+ fallback={<span>Loading...</span>}+ >+ {props.config.emptyMessage ??+ `No ${getEntityTypePluralLabel(props.config.specificEntityType)} found`}+ </Show>+ </div>+ )}</Show></div>);diff --git a/apps/web/src/features/property/editors/selectors/scoped-user-options.ts b/apps/web/src/features/property/editors/selectors/scoped-user-options.tsnew file mode 100644index 0000000000..ff7f0e5068--- /dev/null+++ b/apps/web/src/features/property/editors/selectors/scoped-user-options.ts@@ -0,0 +1,32 @@+import { isBotPrincipalId } from '@core/constant/macroAgent';+import type { IUser } from '@core/user';+import { idToDisplayName, idToEmail } from '@core/user/util';++/** Keep selected users available without adding other non-team people. */+export function scopedUserOptions(+ users: IUser[],+ otherUsers: IUser[],+ selectedIds: readonly string[]+): IUser[] {+ const options = [...users];++ for (const id of selectedIds) {+ const contact = otherUsers.find((user) => user.id === id);+ const member = users.find((user) => user.id === id);+ const user = contact ??+ member ?? {+ id,+ email: isBotPrincipalId(id) ? '' : idToEmail(id),+ name: isBotPrincipalId(id) ? 'Agent' : idToDisplayName(id),+ };+ const index = options.findIndex((option) => option.id === id);++ if (index === -1) {+ options.push(user);+ } else {+ options[index] = user;+ }+ }++ return options;+}diff --git a/apps/web/src/features/soup/assignee-picker.tsx b/apps/web/src/features/soup/assignee-picker.tsxnew file mode 100644index 0000000000..43162f6fd0--- /dev/null+++ b/apps/web/src/features/soup/assignee-picker.tsx@@ -0,0 +1,113 @@+import { NO_ASSIGNEE } from '@app/features/next-soup/filters';+import type { SearchableOption } from '@app/features/next-soup/soup-view/filters-bar/searchable-multi-select';+import { t } from '@app/lib/i18n';+import { UserIcon } from '@core/component/UserIcon';+import { useUserId } from '@core/context/user';+import CircleDashedIcon from '@icon/system/regular/circle-dashed.svg';+import { useAgentAssignees } from '@property/queries/agent-assignees';+import { useTeamMembers } from '@queries/team/members';+import { type Accessor, createMemo, createSignal, Show } from 'solid-js';++export function buildContactLabel(+ contact: { id: string; name?: string | null },+ currentUserId: string | undefined+): string {+ if (contact.id === currentUserId) {+ return contact.name+ ? t('viewMenus.contactMe', { name: contact.name })+ : t('viewMenus.me');+ }+ return contact.name || contact.id;+}++/** A team roster with selected outsiders retained until explicitly removed. */+export function useAssigneePicker(+ activeIds: Accessor<string[]>,+ enabled: Accessor<boolean>+) {+ const team = useTeamMembers(enabled);+ const agents = useAgentAssignees(enabled);+ const userId = useUserId();+ const [selectedIdsAtViewEntry, setSelectedIdsAtViewEntry] = createSignal([+ ...activeIds(),+ ]);+ const onOpenChange = (open: boolean) => {+ if (open) setSelectedIdsAtViewEntry([...activeIds()]);+ };++ const options = createMemo(+ () => {+ const uid = userId();+ const members = team.users();+ const agentUsers = agents();+ const people = [...agentUsers, ...members];+ const result: SearchableOption[] = [];+ const add = (id: string) => {+ if (result.some((option) => option.id === id)) return;++ const person = people.find((user) => user.id === id);+ result.push({+ id,+ label: buildContactLabel(person ?? { id }, uid),+ icon: () => (+ <UserIcon id={id} size="sm" suppressClick showTooltip={false} />+ ),+ });+ };++ for (const agent of agentUsers) add(agent.id);+ if (uid) add(uid);+ result.push({+ id: NO_ASSIGNEE,+ label: t('viewMenus.unassigned'),+ icon: () => <CircleDashedIcon class="size-3.5 text-ink-muted" />,+ });+ for (const member of members) add(member.id);+ for (const id of activeIds()) {+ if (id !== NO_ASSIGNEE) add(id);+ }+ return result;+ },+ undefined,+ {+ // Selecting a roster member does not change the rows or their order.+ equals: (previous, next) => {+ if (previous.length !== next.length) return false;++ return previous.every((option, index) => {+ const nextOption = next[index];+ return (+ option.id === nextOption.id && option.label === nextOption.label+ );+ });+ },+ }+ );+ return {+ options,+ onOpenChange,+ selectedIdsAtViewEntry,+ placeholder: () => t('viewMenus.searchAssignees'),+ isLoading: team.isLoading,+ isError: team.isError,+ };+}++export type AssigneePicker = ReturnType<typeof useAssigneePicker>;++export function AssigneePickerStatus(props: { picker: AssigneePicker }) {+ return (+ <>+ <Show when={props.picker.isLoading()}>+ <div class="px-2 py-1 text-xs text-ink-muted">+ {t('viewMenus.loadingTeamMembers')}+ </div>+ </Show>+ <Show when={props.picker.isError()}>+ <div class="px-2 py-1 text-xs text-ink-muted">+ {t('viewMenus.teamMembersUnavailable')}+ </div>+ </Show>+ </>+ );+}diff --git a/apps/web/src/features/tasks-view/AGENTS.md b/apps/web/src/features/tasks-view/AGENTS.mdindex 52d47efb58..85921cdb8a 100644--- a/apps/web/src/features/tasks-view/AGENTS.md+++ b/apps/web/src/features/tasks-view/AGENTS.md@@ -46,6 +46,7 @@ Main Tasks and reusable task-list hosts. Projects and CRM embed `TasksViewProvid- Save filters, relative due dates or valid calendar bounds, selected layout, grouping, and ordered sort directions; keep text search and scroll state local, and capture implicit person conditions as normal OR-valued facets.- Preserve stable tag/property bindings when labels disappear; skip unsupported or malformed conditions without discarding supported filters.- Label the semantic viewer token Me, explain it with “Matches whoever opens this saved view,” and resolve it only when executing a filter; a selected fixed user stays fixed.+- Limit new Assignee choices to team members and available agents without contact discovery; reuse existing selected-first ordering at opening and keep rows stable while selecting; preserve selected outsiders, the semantic Me token, Unassigned, and broad Created by options.- Keep saved views on All Tasks with every restriction in editable facets; accept only the final v1 person-filter format, without a separate Scope control.- Do not persist temporary saved-view filters, including due-date predicates, in entry snapshots; detail navigation discards those edits but retains the saved-view ID.- Pass saved-view state through the existing Tasks search codec; split URLs namespace it as `s0.tasks.savedView`.diff --git a/apps/web/src/features/tasks-view/components/TasksFilterDrawer.tsx b/apps/web/src/features/tasks-view/components/TasksFilterDrawer.tsxindex 693fcbfced..40a0a0165e 100644--- a/apps/web/src/features/tasks-view/components/TasksFilterDrawer.tsx+++ b/apps/web/src/features/tasks-view/components/TasksFilterDrawer.tsx@@ -1,9 +1,13 @@+import type { ListControlOption } from '@app/components/view-shell/ListDropdowns';import { MobileFilterDrawer } from '@app/components/view-shell/MobileFilterDrawer';import { MobileDrawer } from '@components/app/mobile/MobileDrawer';import { fireAndForget } from '@core/util/fireAndForget';+import { useSelectedFirst } from '@core/util/useSelectedFirst';import { Accordion } from '@kobalte/core/accordion';-import type { DialogHandle } from '@ui';+import { Key } from '@solid-primitives/keyed';+import { type DialogHandle, Input } from '@ui';import {+ type Accessor,createMemo,createSignal,For,@@ -20,19 +24,37 @@ import {} from '../views/task-saved-views';import { TaskDueDateRangeDialog } from './task-due-date-range-dialog';+type SavedViewScope = ReturnType<+ ReturnType<typeof useTasksView>['savedViewScope']+>;++type PendingSavedViewAction = {+ create: () => DialogHandle | undefined;+ scope: SavedViewScope;+};+export function TasksFilterDrawer() {const { state, setPrimarySort, setState, savedViews, savedViewScope } =useTasksView();const filters = useTaskFilters();- const [open, setOpen] = createSignal(false);+ const [open, setDrawerOpen] = createSignal(false);+ const [assigneeSearch, setAssigneeSearch] = createSignal('');+ const [expandedSections, setExpandedSections] = createSignal<string[]>([+ filters.groups()[0]?.id ?? 'status',+ ]);+ const setOpen = (value: boolean) => {+ filters+ .groups()+ .find((group) => group.id === 'assignees')+ ?.onOpenChange?.(value);+ if (!value) {+ setAssigneeSearch('');+ }+ setDrawerOpen(value);+ };const owner = getOwner();let disposed = false;- let pending:- | {- create: () => DialogHandle | undefined;- scope: ReturnType<typeof savedViewScope>;- }- | undefined;+ let pending: PendingSavedViewAction | undefined;onCleanup(() => {disposed = true;pending = undefined;@@ -41,10 +63,7 @@ export function TasksFilterDrawer() {pending = { create, scope: savedViewScope() };setOpen(false);};- const reopen = async (- dialog: DialogHandle,- scope: ReturnType<typeof savedViewScope>- ) => {+ const reopen = async (dialog: DialogHandle, scope: SavedViewScope) => {await dialog.closed;if (!disposed && scope === savedViewScope()) setOpen(true);};@@ -148,33 +167,64 @@ export function TasksFilterDrawer() {<Accordionmultiplecollapsible- defaultValue={[filters.groups()[0]?.id ?? 'status']}+ value={expandedSections()}+ onChange={(value) => {+ const wasOpen = expandedSections().includes('assignees');+ const isOpen = value.includes('assignees');+ if (wasOpen !== isOpen) {+ filters+ .groups()+ .find((group) => group.id === 'assignees')+ ?.onOpenChange?.(isOpen);+ if (!isOpen) setAssigneeSearch('');+ }+ setExpandedSections(value);+ }}><div class="flex flex-col gap-3">- <For each={filters.groups()}>+ <Key each={filters.groups()} by="id">{(group) => {- const activeCount = createMemo(- () =>- group.options.filter(- (option) =>- option.id !== group.defaultOptionId &&- filters.isSelected(group.id, option.id)- ).length- );+ const activeCount = createMemo(() => {+ if (group().id === 'assignees')+ return filters.selectedIds('assignees').length;+ return group().options.filter(+ (option) =>+ option.id !== group().defaultOptionId &&+ filters.isSelected(group().id, option.id)+ ).length;+ });+ const visibleOptions = () => {+ const options = group().options;+ if (group().id !== 'assignees') return options;- return (- <MobileFilterDrawer.Section- value={group.id}- label={group.label}- activeCount={activeCount()}- >- <For each={group.options}>+ const search = assigneeSearch().toLowerCase();+ if (!search) return options;++ return options.filter((option) =>+ option.label.toLowerCase().includes(search)+ );+ };+ let orderedOptions = visibleOptions;+ if (group().id === 'assignees') {+ orderedOptions = useSelectedFirst({+ items: visibleOptions,+ selectedIds: filters.selectedAssigneesAtViewEntry,+ searchQuery: assigneeSearch,+ getId: (option) => option.id,+ sortDeps: [filters.selectedAssigneesAtViewEntry],+ });+ }+ const renderOptions = (+ options: Accessor<ListControlOption<string>[]>+ ) => (+ <>+ <For each={options()}>{(option) => (<MobileFilterDrawer.Option- selectionMode={group.selectionMode ?? 'multiple'}- checked={filters.isSelected(group.id, option.id)}+ selectionMode={group().selectionMode ?? 'multiple'}+ checked={filters.isSelected(group().id, option.id)}onChange={(checked) =>- filters.setSelected(group.id, option.id, checked)+ filters.setSelected(group().id, option.id, checked)}icon={option.icon?.()}>@@ -182,10 +232,34 @@ export function TasksFilterDrawer() {</MobileFilterDrawer.Option>)}</For>+ {group().footer}+ </>+ );++ return (+ <MobileFilterDrawer.Section+ value={group().id}+ label={group().label}+ activeCount={activeCount()}+ >+ <Show when={group().id === 'assignees'}>+ <div class="flex items-center gap-2 px-3 pb-2">+ <Input+ class="min-w-0 flex-1"+ aria-label={group().searchPlaceholder}+ placeholder={group().searchPlaceholder}+ value={assigneeSearch()}+ onInput={(event) =>+ setAssigneeSearch(event.currentTarget.value)+ }+ />+ </div>+ </Show>+ {renderOptions(orderedOptions)}</MobileFilterDrawer.Section>);}}- </For>+ </Key></div></Accordion></MobileFilterDrawer>diff --git a/apps/web/src/features/tasks-view/filters/use-task-filters.tsx b/apps/web/src/features/tasks-view/filters/use-task-filters.tsxindex ffaf23f2a4..571bbcec7a 100644--- a/apps/web/src/features/tasks-view/filters/use-task-filters.tsx+++ b/apps/web/src/features/tasks-view/filters/use-task-filters.tsx@@ -2,6 +2,11 @@ import type {AiFilterOutcome,ListFilterGroup,} from '@app/components/view-shell';+import { NO_ASSIGNEE } from '@app/features/next-soup/filters';+import {+ AssigneePickerStatus,+ useAssigneePicker,+} from '@app/features/soup/assignee-picker';import { addUnique, removeValue } from '@app/lib/signals/store-array-updaters';import { UserIcon } from '@core/component/UserIcon';import { useUserId } from '@core/context/user';@@ -10,7 +15,7 @@ import { PropertyValueIcon } from '@property/component/propertyValue';import { useTagFilterGroup } from '@property/tags/use-tag-filter-group';import { useContacts } from '@queries/contacts/contacts';import { Tooltip } from '@ui';-import { batch, createMemo, createSignal } from 'solid-js';+import { batch, createMemo, createSignal, on } from 'solid-js';import { match } from 'ts-pattern';import type { TaskDateRangeDraft } from '../components/task-due-date-range-dialog';import {@@ -47,6 +52,15 @@ export function useTaskFilters() {const currentUserId = useUserId();const tagGroup = useTagFilterGroup();const [customRange, setCustomRange] = createSignal<TaskDateRangeDraft>();+ const assigneePicker = useAssigneePicker(+ () => (state.facets.assignees ?? []).filter((id) => id !== TASK_VIEWER),+ () => true+ );+ const selectedAssigneesAtViewEntry = createMemo(+ on(assigneePicker.selectedIdsAtViewEntry, () => [+ ...(state.facets.assignees ?? []),+ ])+ );const peopleOptions = createMemo(() => {const me = currentUserId();@@ -100,6 +114,11 @@ export function useTaskFilters() {: options;});+ const assigneeOptions = createMemo(() => [+ ...peopleOptions().filter((option) => option.id === TASK_VIEWER),+ ...assigneePicker.options().filter((option) => option.id !== NO_ASSIGNEE),+ ]);+const withUnavailable = (id: TaskFilterGroupId,options: ListFilterGroup<TaskFilterGroupId, string>['options']@@ -168,8 +187,10 @@ export function useTaskFilters() {{id: 'assignees',label: 'Assignee',- searchPlaceholder: 'Search assignees...',- options: withUnavailable('assignees', peopleOptions()),+ searchPlaceholder: assigneePicker.placeholder(),+ options: assigneeOptions(),+ footer: <AssigneePickerStatus picker={assigneePicker} />,+ onOpenChange: assigneePicker.onOpenChange,},{id: 'created-by',@@ -281,6 +302,7 @@ export function useTaskFilters() {setCustomRange(undefined);},groups,+ selectedAssigneesAtViewEntry,isSelected,selectedIds: (groupId: TaskFilterGroupId) => state.facets[groupId] ?? [],setSelected,diff --git a/apps/web/src/lib/i18n/locales/en/view-menus.ts b/apps/web/src/lib/i18n/locales/en/view-menus.tsindex abbf6ee078..7a0e4bc3f3 100644--- a/apps/web/src/lib/i18n/locales/en/view-menus.ts+++ b/apps/web/src/lib/i18n/locales/en/view-menus.ts@@ -123,6 +123,8 @@ export default {filterByTag: 'Filter by tag...',searchAssignees: 'Search assignees...',searchAssigneesLabel: 'Search assignees',+ loadingTeamMembers: 'Loading team members…',+ teamMembersUnavailable: 'Team members could not be loaded.',createdBy: 'Created by',searchCreators: 'Search creators...',searchCreatorsLabel: 'Search creators',diff --git a/apps/web/src/lib/queries/team/members.ts b/apps/web/src/lib/queries/team/members.tsindex 70cb0817dc..8797016082 100644--- a/apps/web/src/lib/queries/team/members.ts+++ b/apps/web/src/lib/queries/team/members.ts@@ -1,18 +1,22 @@import { toast } from '@core/component/Toast/Toast';+import type { IUser } from '@core/user';+import { idToDisplayName, idToEmail } from '@core/user/util';import { fireAndForget } from '@core/util/fireAndForget';import { throwOnErr } from '@core/util/result';import type { PaidPlan } from '@service-auth/ai-billing-types';import { authServiceClient } from '@service-auth/client';import type { TeamWithMembers } from '@service-auth/generated/schemas/teamWithMembers';import { useMutation } from '@tanstack/solid-query';+import { type Accessor, createMemo } from 'solid-js';import {invalidateAiBillingSummary,invalidateSubscriptionStatus,} from '../auth';import { queryClient } from '../client';+import { queryReadyGate } from '../gate';import { type MutationCallbacks, withCallbacks } from '../utils';import { teamKeys } from './keys';-import { invalidateTeam } from './teams';+import { invalidateTeam, useCurrentTeamQuery } from './teams';type RemoveUserFromTeamArgs = { teamId: string; userId: string };type RemoveUserFromTeamContext = { previousTeam: TeamWithMembers | undefined };@@ -23,6 +27,27 @@ type RemoveUserFromTeamCallbacks = MutationCallbacks<RemoveUserFromTeamContext>;+/** The cached current team roster, independent of the viewer's contacts. */+export function useTeamMembers(enabled: Accessor<boolean>) {+ const query = useCurrentTeamQuery(enabled);+ const users = createMemo((): IUser[] => {+ if (!enabled()) return [];+ if (!queryReadyGate(query)) return [];++ return (query.data?.members ?? []).map(({ user_id }) => ({+ id: user_id,+ email: idToEmail(user_id),+ name: idToDisplayName(user_id),+ }));+ });++ return {+ users,+ isLoading: () => enabled() && query.isPending,+ isError: () => enabled() && query.isError,+ };+}+export function useRemoveUserFromTeamMutation(callbacks?: RemoveUserFromTeamCallbacks) {diff --git a/docs/agent-guide/search.md b/docs/agent-guide/search.mdindex 29bebdadf3..73249086c4 100644--- a/docs/agent-guide/search.md+++ b/docs/agent-guide/search.md@@ -76,6 +76,12 @@ live search. Closing Search clears the input and its unsent suggested form.For Search intent, extraction selects a search type before extracting only thattype's supported filters. Task status/priority/assignee/creator filters and channelIn/From filters use the same controls and resolution as desktop Command K.+The task Assignee facet reuses selected-first ordering when opening the picker,+with available agents, team members, and the **Search assignees...** placeholder.+Rows stay in place while selecting or deselecting. Existing selected outsiders+remain removable, but contact discovery is not available. Desktop chips and the+mobile filter drawer share this behavior.+Created by, channel senders, and call speakers retain their existing people pools.The shared global-search filters and results update live above the bar. Open afiltered result directly; there is no separate Search submit action.Opening a result hides search chrome whilediff --git a/docs/agent-guide/tasks.md b/docs/agent-guide/tasks.mdindex c16995a62c..81d491ef6d 100644--- a/docs/agent-guide/tasks.md+++ b/docs/agent-guide/tasks.md@@ -1191,6 +1191,21 @@ with the PR's status, title, `owner/repo#N`, and line changes. Clicking it opensMacro in a new split (in place on touch devices); a PR Macro has not synced yet opens onGitHub instead.+Assignees lists and searches current team members and available agents, keeping+each surface's existing search placeholder, styling, and selected-first ordering+when opening the picker. Rows stay in place while selecting or deselecting.+Existing selected outsiders remain visible and removable,+including references absent from contacts. The picker has no contact discovery;+a removed outsider cannot be added again unless they join the team.++The same scope applies to task/project creation and editing, bulk Set assignee,+and desktop/mobile Assignee filters. Existing **Me** and **Unassigned** choices+keep their semantics; Created by and custom people fields keep their contact lists.+Check that a teammate absent from contacts appears and can be selected, that+searching by email cannot select an unassigned outsider, and that an existing+outsider can be removed. Repeat with keyboard navigation and a touch picker+sheet; Cancel still discards drafts and Done still applies them.+The Assignees picker offers people and available agents together. Agent rows showtheir name and an `Agent` label; saved agents also show their `@handle`. Search byname or handle to find one. Built-in session agents follow the same availability