:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(signals): reuse member picker for inbox scope and scout owners (#105777)
Paul D'Ambrab8e87eded37d
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex f0c3e888faa6..d5a453d08ffd 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -9289,13 +9289,13 @@ snapshots:scenes-app-inbox-report-metrics--wide--light:hash: v1.k794b7964.3465b8cd1a9bf286b7ae698d78dba847138201548b8a3c56978fae74b431da53.2bz4A6FW49b2OIDhumSwnnmW8eVEaLSHMmBLZx_eFOgscenes-app-inbox-scene--empty--dark:- hash: v1.k794b7964.7d08781760f326f7746ad15883a7ad1a12af173a118c112947ec8ad2637cb1e1.9lq59SDcw12Zz9wZmdfDUnV8V-8vVzWL4NZ0QbTOMgU+ hash: v1.k794b7964.d1f94cecb2a36f2308212dc28ef1e83d8153b45578c4f390c4596dc308d5eb93.Cxai09kW1P5oCqveaca9r04fxOsysv7d9ggUQDV7hB4scenes-app-inbox-scene--empty--light:- hash: v1.k794b7964.70d46b83d374799f0fa32a86442a324f89b4dc5891114b47fd18b6f4beeb5a72.bY2Vjl09QImFY6oHwS8QTTZzb_zMPQJcg4eZkZLeCDs+ hash: v1.k794b7964.5832796d3a31b54adb1e443563c554438ec16af1997eb0b2f691a379ba146e35.0jCKXn2XHX0vvkDvYjbfVmf8CpQ90ItPuRPT25cRt1wscenes-app-inbox-scene--empty-control--dark:- hash: v1.k794b7964.c3b310e693423d075fbc89cdf980da883e83c2dcb875de9e81fe2f58f65eb69a.bWCTpI3O_lPdfX3K-LYQvQuAxAYonfQER2mBaUh5eEM+ hash: v1.k794b7964.04e977d96b4d52ef741ab77062d8752f962981d44b5c218d6c6ee3a49d018792.W1bmigHUOt4DxTyAH6et4R_7BxAXWI7q6It7SGjoF7gscenes-app-inbox-scene--empty-control--light:- hash: v1.k794b7964.40a8eaced770971fbe50173245db2b8f173948320a09b1f0a138ca90819e0c1a.FTwYK7wfCfCxR-YFKOLhK5ejxXe4qYDEjxWf2tG3vQo+ hash: v1.k794b7964.e37ef776409743604f11012a968f1696207b2af7da12126e874cb5f46c651b73.EFqoZnsQSFgGEpIdKcCHV6WYkbhONief7_oKj5Z9Eskscenes-app-inbox-scene--empty-with-many-scouts--dark:hash: v1.k794b7964.912f58c1595c14260c58e5edfd74fe6429a05960ed05c3a93c38668f715f98b3.pCfUAofhEjo2TKaWOCbUnXghdlQqVcfHujJgROUT54wscenes-app-inbox-scene--empty-with-many-scouts--light:@@ -9305,7 +9305,7 @@ snapshots:scenes-app-inbox-scene--inbox--light:hash: v1.k794b7964.1472c24e826857d56e99bf9b698032a20a04679e083e6c14f1b805596b73719b.6Ah4ycjYBbRUjcO8HIm1iBVbKpB8AmGntfKX6pIpGvMscenes-app-inbox-scene--installing-self-driving--dark:- hash: v1.k794b7964.9b4caff813eafd13634c23944b6864b2e5e780612b7c7582853b1641fd6069d6.BpcSU8wtvBqJ6wuJ1eDHKkzYRHbGFpA2FkvwTu64kkY+ hash: v1.k794b7964.8ae6815920bb480008e7e911ff1dcab389f7efdccca7c17cfbfab02cbd564b4c.oiyVoRTrtyGJiszfAkRBVt6NtR9_L8aqcMTDnzUy-Vsscenes-app-inbox-scene--installing-self-driving--light:hash: v1.k794b7964.fc1d6c0f35936c2a9a59fe89dbc9fdd8bae321ef4a4cba09af26626522d606eb.Ben1AjqSzgVvRph3ykOT3OusF-gZBfMIiFyONV4k6hAscenes-app-inbox-scene--legacy--dark:diff --git a/frontend/src/lib/components/MemberSelect.test.tsx b/frontend/src/lib/components/MemberSelect.test.tsxindex b42280690e2f..88cd2cf1b520 100644--- a/frontend/src/lib/components/MemberSelect.test.tsx+++ b/frontend/src/lib/components/MemberSelect.test.tsx@@ -52,7 +52,10 @@ describe('MemberSelect', () => {function renderSelect(props: Partial<Parameters<typeof MemberSelect>[0]> = {}): void {render(<Provider>- <MemberSelect value={null} onChange={onChange} {...props} />+ <>+ <MemberSelect value={null} onChange={onChange} {...props} />+ <button type="button">Outside</button>+ </></Provider>)}@@ -110,4 +113,51 @@ describe('MemberSelect', () => {expect(await screen.findByPlaceholderText('Search')).toHaveValue('')})++ it('focuses search and picks a custom option from an external roster', async () => {+ const onSelectOption = jest.fn()+ const onSearch = jest.fn()+ const onForYou = jest.fn()+ renderSelect({+ defaultLabel: 'Entire project',+ extraOptions: [{ label: 'For you', onClick: onForYou }],+ options: [+ { uuid: 'reviewer-1', name: 'Alex', email: '[email protected]' },+ {+ uuid: MOCK_DEFAULT_BASIC_USER.uuid,+ name: MOCK_DEFAULT_BASIC_USER.first_name,+ email: MOCK_DEFAULT_BASIC_USER.email,+ },+ ],+ onSearch,+ onSelectOption,+ })++ await userEvent.click(screen.getByText('Entire project'))+ expect(screen.getByPlaceholderText('Search')).toHaveFocus()+ expect(+ screen.getByText(MOCK_DEFAULT_BASIC_USER.first_name).compareDocumentPosition(screen.getByText('Alex')) &+ Node.DOCUMENT_POSITION_FOLLOWING+ ).toBeTruthy()+ expect(screen.queryByText(MOCK_SECOND_BASIC_USER.first_name)).not.toBeInTheDocument()+ await userEvent.type(screen.getByPlaceholderText('Search'), 'Alex')+ expect(onSearch).toHaveBeenLastCalledWith('Alex')+ await userEvent.click(screen.getByText('Outside'))+ await waitFor(() => expect(screen.queryByPlaceholderText('Search')).not.toBeInTheDocument())+ await userEvent.click(screen.getByText('Entire project'))+ expect(screen.getByPlaceholderText('Search')).toHaveValue('Alex')+ expect(onSearch).toHaveBeenLastCalledWith('Alex')+ await userEvent.click(screen.getByText('Alex'))+ expect(onSelectOption).toHaveBeenCalledWith('reviewer-1', 'Alex')+ expect(onSearch).toHaveBeenLastCalledWith('')++ await userEvent.click(screen.getByText('Entire project'))+ expect(screen.getByPlaceholderText('Search')).toHaveValue('')+ await userEvent.click(screen.getAllByText('Entire project')[1])+ expect(onChange).toHaveBeenCalledWith(null)++ await userEvent.click(screen.getByText('Entire project'))+ await userEvent.click(screen.getByText('For you'))+ expect(onForYou).toHaveBeenCalledTimes(1)+ })})diff --git a/frontend/src/lib/components/MemberSelect.tsx b/frontend/src/lib/components/MemberSelect.tsxindex 8d06d0ec726d..ae7241acbefc 100644--- a/frontend/src/lib/components/MemberSelect.tsx+++ b/frontend/src/lib/components/MemberSelect.tsx@@ -8,11 +8,16 @@ import { membersLogic } from 'scenes/organization/membersLogic'import { UserBasicType } from '~/types'-import { MemberSelectRow } from './MemberSelectRow'+import { MemberSelectOptions } from './MemberSelectOptions'export type MemberSelectProps = {defaultLabel?: stringallowNone?: boolean+ extraOptions?: { label: string; onClick: () => void }[]+ options?: { uuid: string; name: string; email: string; trailing?: string | number }[]+ optionsLoading?: boolean+ onSearch?: (query: string) => void+ onSelectOption?: (uuid: string, name: string) => void// NOTE: Trying to cover a lot of different cases - if string we assume uuid, if number we assume idvalue: string | number | nullexcludedMembers?: (string | number)[]@@ -23,6 +28,11 @@ export type MemberSelectProps = {export function MemberSelect({defaultLabel = 'Any user',allowNone = true,+ extraOptions = [],+ options,+ optionsLoading,+ onSearch,+ onSelectOption,value,excludedMembers = [],onChange,@@ -32,6 +42,17 @@ export function MemberSelect({const { me, selectableMembers, meFirstMembers, search, membersLoading } = useValues(membersLogic)const { ensureAllMembersLoaded, setSearch } = useActions(membersLogic)const [showPopover, setShowPopover] = useState(false)+ const [optionSearch, setOptionSearch] = useState('')+ const searchValue = options ? optionSearch : search++ const changeSearch = (query: string): void => {+ if (options) {+ setOptionSearch(query)+ onSearch?.(query)+ } else {+ setSearch(query)+ }+ }const propToCompare = typeof value === 'string' ? 'uuid' : 'id'@@ -44,21 +65,27 @@ export function MemberSelect({const handleVisibilityChange = (visible: boolean): void => {setShowPopover(visible)- if (search) {- setSearch('')+ if (searchValue && !options) {+ changeSearch('')}- if (visible) {+ if (visible && !options) {ensureAllMembersLoaded()}}- const _onChange = (value: UserBasicType | null): void => {+ const closeAfterSelection = (): void => {+ if (options && searchValue) {+ changeSearch('')+ }handleVisibilityChange(false)- onChange(value)}- const members = showPopover ? selectableMembers(excludedMembers, propToCompare) : []+ const _onChange = (value: UserBasicType | null): void => {+ closeAfterSelection()+ onChange(value)+ }+ const members = showPopover && !options ? selectableMembers(excludedMembers, propToCompare) : []return (<LemonDropdowncloseOnClickInside={false}@@ -74,36 +101,24 @@ export function MemberSelect({type="search"placeholder="Search"autoFocus- value={search}- onChange={setSearch}+ value={searchValue}+ onChange={changeSearch}fullWidth/>- <ul className="deprecated-space-y-px">- {allowNone && (- <li>- <LemonButton fullWidth role="menuitem" size="small" onClick={() => _onChange(null)}>- {defaultLabel}- </LemonButton>- </li>- )}-- {members.map((member) => (- <MemberSelectRow- key={member.user.uuid}- member={member}- isYou={member.user.uuid === me?.user.uuid}- onClick={() => _onChange(member.user)}- />- ))}-- {membersLoading ? (- <div className="p-2 text-secondary italic truncate border-t">Loading...</div>- ) : members.length === 0 ? (- <div className="p-2 text-secondary italic truncate border-t">- {search ? <span>No matches</span> : <span>No users</span>}- </div>- ) : null}- </ul>+ <MemberSelectOptions+ extraOptions={extraOptions}+ allowNone={allowNone}+ defaultLabel={defaultLabel}+ members={members}+ currentUserUuid={me?.user.uuid}+ options={options}+ optionsLoading={optionsLoading}+ membersLoading={membersLoading}+ searchValue={searchValue}+ onChange={_onChange}+ onSelectOption={onSelectOption}+ onClose={closeAfterSelection}+ /></div>) : null}diff --git a/frontend/src/lib/components/MemberSelectOptions.tsx b/frontend/src/lib/components/MemberSelectOptions.tsxnew file mode 100644index 000000000000..0dd681ff830f--- /dev/null+++ b/frontend/src/lib/components/MemberSelectOptions.tsx@@ -0,0 +1,109 @@+import { LemonButton } from '@posthog/lemon-ui'++import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture/ProfilePicture'++import type { OrganizationMemberType } from '~/types'++import type { MemberSelectProps } from './MemberSelect'+import { MemberSelectRow } from './MemberSelectRow'++type MemberSelectOptionsProps = {+ extraOptions: NonNullable<MemberSelectProps['extraOptions']>+ allowNone: boolean+ defaultLabel: string+ members: OrganizationMemberType[]+ currentUserUuid?: string+ options: MemberSelectProps['options']+ optionsLoading: MemberSelectProps['optionsLoading']+ membersLoading: boolean+ searchValue: string+ onChange: MemberSelectProps['onChange']+ onSelectOption: MemberSelectProps['onSelectOption']+ onClose: () => void+}++export function MemberSelectOptions({+ extraOptions,+ allowNone,+ defaultLabel,+ members,+ currentUserUuid,+ options,+ optionsLoading,+ membersLoading,+ searchValue,+ onChange,+ onSelectOption,+ onClose,+}: MemberSelectOptionsProps): JSX.Element {+ const displayedOptions =+ options && !searchValue && currentUserUuid+ ? [...options].sort(+ (first, second) => Number(second.uuid === currentUserUuid) - Number(first.uuid === currentUserUuid)+ )+ : options++ return (+ <ul className="deprecated-space-y-px">+ {extraOptions.map((option) => (+ <li key={option.label}>+ <LemonButton+ fullWidth+ role="menuitem"+ size="small"+ onClick={() => {+ onClose()+ option.onClick()+ }}+ >+ {option.label}+ </LemonButton>+ </li>+ ))}+ {allowNone && (+ <li>+ <LemonButton fullWidth role="menuitem" size="small" onClick={() => onChange(null)}>+ {defaultLabel}+ </LemonButton>+ </li>+ )}++ {members.map((member) => (+ <MemberSelectRow+ key={member.user.uuid}+ member={member}+ isYou={member.user.uuid === currentUserUuid}+ onClick={() => onChange(member.user)}+ />+ ))}++ {displayedOptions?.map((option) => (+ <li key={option.uuid}>+ <LemonButton+ fullWidth+ role="menuitem"+ size="small"+ icon={<ProfilePicture size="md" user={{ first_name: option.name, email: option.email }} />}+ onClick={() => {+ onClose()+ onSelectOption?.(option.uuid, option.name || option.email)+ }}+ >+ <span className="flex min-w-0 flex-1 items-center justify-between gap-2">+ <span className="min-w-0 flex-1 truncate">{option.name || option.email}</span>+ <span className="shrink-0 text-secondary">{option.trailing}</span>+ </span>+ </LemonButton>+ </li>+ ))}++ {(options ? optionsLoading : membersLoading) ? (+ <div className="p-2 text-secondary italic truncate border-t">Loading...</div>+ ) : (options ?? members).length === 0 ? (+ <div className="p-2 text-secondary italic truncate border-t">+ {searchValue ? <span>No matches</span> : <span>No users</span>}+ </div>+ ) : null}+ </ul>+ )+}diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutOwnerFilter.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutOwnerFilter.tsxindex 22ee013b4cd1..edba6eb7c9f7 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutOwnerFilter.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutOwnerFilter.tsx@@ -1,13 +1,12 @@import { useValues } from 'kea'import { useState } from 'react'-import { IconChevronDown } from '@posthog/icons'import { LemonButton } from '@posthog/lemon-ui'+import { MemberSelect } from 'lib/components/MemberSelect'import { userLogic } from 'scenes/userLogic'import type { ScoutOwnerOption } from '../../../utils/scoutOwners'-import { InboxPeoplePicker } from '../../shell/InboxPeoplePicker'/*** Whose scouts the roster shows: the same people picker as the reports scope control, behind a@@ -27,9 +26,7 @@ export function ScoutOwnerFilter({size?: 'xsmall' | 'small'}): JSX.Element {const { user } = useValues(userLogic)- const [open, setOpen] = useState(false)const [search, setSearch] = useState('')- const [referenceEl, setReferenceEl] = useState<HTMLDivElement | null>(null)// Your own scouts are the ones you came here to find, so the list says which are yours.const nameOf = (option: ScoutOwnerOption): string =>@@ -43,40 +40,27 @@ export function ScoutOwnerFilter({).map((option) => ({ uuid: option.uuid, name: nameOf(option), email: option.email, trailing: option.count }))- const pick = (owner: string | null): void => {- onChange(owner)- setOpen(false)- setSearch('')- }-return (- <>- <div ref={setReferenceEl} className="inline-flex">+ <MemberSelect+ value={selected}+ defaultLabel="Any owner"+ options={people}+ onSearch={setSearch}+ onChange={() => onChange(null)}+ onSelectOption={(uuid) => onChange(uuid)}+ >+ {() => (<LemonButtontype="secondary"size={size}- active={open}- onClick={() => setOpen((value) => !value)}aria-label="Filter scouts by owner"data-attr="inbox-scout-filter-owner"- sideIcon={<IconChevronDown />}><span className="max-w-[160px] truncate">{selectedOption ? nameOf(selectedOption) : 'Any owner'}</span></LemonButton>- </div>- <InboxPeoplePicker- visible={open}- referenceElement={referenceEl}- onClose={() => setOpen(false)}- search={search}- onSearch={setSearch}- people={people}- selectedUuid={selected}- everyoneLabel="Any owner"- onPick={(person) => pick(person?.uuid ?? null)}- />- </>+ )}+ </MemberSelect>)}diff --git a/products/signals/frontend/inbox/components/shell/InboxPeoplePicker.tsx b/products/signals/frontend/inbox/components/shell/InboxPeoplePicker.tsxdeleted file mode 100644index 0b6198d56607..000000000000--- a/products/signals/frontend/inbox/components/shell/InboxPeoplePicker.tsx+++ /dev/null@@ -1,151 +0,0 @@-import clsx from 'clsx'--import { IconAsterisk, IconCheck, IconPerson } from '@posthog/icons'-import { LemonInput, Spinner } from '@posthog/lemon-ui'--import { Popover } from 'lib/lemon-ui/Popover'-import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture/ProfilePicture'--export interface InboxPerson {- uuid: string- name: string- email: string- /** Shown after the name in muted text. */- trailing?: string | number-}--/**- * The searchable people popover the inbox uses wherever a filter names one person: a search box,- * an "everyone" row, then a row per person with an avatar. The caller owns the trigger, the open- * state, and the search query, so the same picker sits behind a segmented control on the reports- * page and a plain button on the scouts roster, and searches a server or a local list.- */-export function InboxPeoplePicker({- visible,- referenceElement,- onClose,- search,- onSearch,- people,- loading = false,- selectedUuid,- forYou,- everyoneLabel,- onPick,-}: {- visible: boolean- referenceElement: HTMLElement | null- onClose: () => void- search: string- onSearch: (query: string) => void- people: InboxPerson[]- loading?: boolean- /** `null` marks the everyone row; `undefined` marks no row at all. */- selectedUuid: string | null | undefined- /** Adds a pinned "For you" row above the everyone row (the reports scope filter uses it). */- forYou?: { active: boolean; onPick: () => void }- everyoneLabel: string- onPick: (person: InboxPerson | null) => void-}): JSX.Element {- return (- <Popover- visible={visible}- onClickOutside={onClose}- referenceElement={referenceElement}- placement="bottom-end"- overlay={- <div className="w-[240px] p-1">- <LemonInput- type="search"- size="small"- placeholder="Search people…"- value={search}- onChange={onSearch}- autoFocus- className="mb-1"- />- <div className="max-h-[16rem] overflow-y-auto space-y-px">- {forYou && (- <PersonRow- active={forYou.active}- onClick={forYou.onPick}- avatar={- <span- className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-secondary text-tertiary"- aria-hidden- >- <IconPerson className="text-xs" />- </span>- }- label="For you"- />- )}- <PersonRow- active={selectedUuid === null}- onClick={() => onPick(null)}- avatar={- <span- className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-dashed border-secondary text-tertiary"- aria-hidden- >- <IconAsterisk className="text-xs" />- </span>- }- label={everyoneLabel}- />- {people.map((person) => (- <PersonRow- key={person.uuid}- active={selectedUuid === person.uuid}- onClick={() => onPick(person)}- avatar={- <ProfilePicture user={{ first_name: person.name, email: person.email }} size="sm" />- }- label={person.name || person.email}- trailing={person.trailing}- />- ))}- {loading ? (- <div className="flex items-center gap-2 px-2 py-1.5 text-xs text-tertiary">- <Spinner className="size-3" />- Searching…- </div>- ) : people.length === 0 ? (- <div className="px-2 py-1.5 text-xs text-tertiary">No matching people.</div>- ) : null}- </div>- </div>- }- />- )-}--function PersonRow({- active,- onClick,- avatar,- label,- trailing,-}: {- active: boolean- onClick: () => void- avatar: JSX.Element- label: string- trailing?: string | number-}): JSX.Element {- return (- <button- type="button"- onClick={onClick}- className={clsx(- 'flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm transition-colors',- active ? 'bg-surface-secondary font-medium' : 'hover:bg-surface-secondary'- )}- >- {avatar}- <span className="min-w-0 flex-1 truncate">{label}</span>- {trailing !== undefined && <span className="shrink-0 text-xs text-muted tabular-nums">{trailing}</span>}- {active && <IconCheck className="shrink-0 text-sm text-default" />}- </button>- )-}diff --git a/products/signals/frontend/inbox/components/shell/InboxScopeFilter.test.tsx b/products/signals/frontend/inbox/components/shell/InboxScopeFilter.test.tsxindex 9b6c90199c75..250bf7e2f81a 100644--- a/products/signals/frontend/inbox/components/shell/InboxScopeFilter.test.tsx+++ b/products/signals/frontend/inbox/components/shell/InboxScopeFilter.test.tsx@@ -9,21 +9,27 @@ import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'import { inboxFiltersLogic } from '../../logics/inboxFiltersLogic'-import type { InboxPerson } from './InboxPeoplePicker'import { InboxScopeFilter } from './InboxScopeFilter'jest.mock('posthog-js')-// The real picker pulls in a popover and avatars. This stand-in lists the roster rows as plain text,-// which is all these tests read from it.-jest.mock('./InboxPeoplePicker', () => ({- InboxPeoplePicker: ({ people }: { people: InboxPerson[] }) => (- <ul>- {people.map((person) => (- <li key={person.uuid}>- {person.name} {person.trailing}- </li>- ))}- </ul>+jest.mock('lib/components/MemberSelect', () => ({+ MemberSelect: ({+ options,+ children,+ }: {+ options: { uuid: string; name: string; trailing?: string }[]+ children: () => JSX.Element+ }) => (+ <>+ {children()}+ <ul>+ {options.map((person) => (+ <li key={person.uuid}>+ {person.name} {person.trailing}+ </li>+ ))}+ </ul>+ </>),}))@@ -63,6 +69,9 @@ describe('InboxScopeFilter', () => {inboxFiltersLogic.actions.setScope('teammate:uuid-ada')await waitFor(() => expect(screen.getByLabelText('Report scope: Ada')).toBeInTheDocument())+ inboxFiltersLogic.actions.loadAvailableReviewersSuccess([])+ expect(screen.getByLabelText('Report scope: Ada')).toBeInTheDocument()+inboxFiltersLogic.actions.setScope('teammate:uuid-off-roster')await waitFor(() => expect(screen.getByLabelText('Report scope: Teammate')).toBeInTheDocument())expect(screen.queryByLabelText('Report scope: Ada')).toBeNull()diff --git a/products/signals/frontend/inbox/components/shell/InboxScopeFilter.tsx b/products/signals/frontend/inbox/components/shell/InboxScopeFilter.tsxindex 2876fa68a5a5..937eab203028 100644--- a/products/signals/frontend/inbox/components/shell/InboxScopeFilter.tsx+++ b/products/signals/frontend/inbox/components/shell/InboxScopeFilter.tsx@@ -1,15 +1,13 @@import { useActions, useValues } from 'kea'-import { useEffect, useState } from 'react'-import { IconChevronDown } from '@posthog/icons'import { LemonButton } from '@posthog/lemon-ui'+import { MemberSelect } from 'lib/components/MemberSelect'import { userLogic } from 'scenes/userLogic'-import { isTeammateInboxScope, parseTeammateInboxScope, teammateInboxScope } from '../../inboxMembership'+import { parseTeammateInboxScope, teammateInboxScope } from '../../inboxMembership'import { inboxFiltersLogic } from '../../logics/inboxFiltersLogic'import { INBOX_SCOPE_ENTIRE_PROJECT, INBOX_SCOPE_FOR_YOU, InboxScope } from '../../types'-import { InboxPeoplePicker } from './InboxPeoplePicker'/*** Single-dropdown reviewer scope for the flat Reports list: one trigger that names the current@@ -20,30 +18,20 @@ import { InboxPeoplePicker } from './InboxPeoplePicker'* `inboxFiltersLogic`; teammates come from its shared `availableReviewers` loader.*/export function InboxScopeFilter(): JSX.Element {- const { scope, availableReviewers: reviewers, availableReviewersLoading } = useValues(inboxFiltersLogic)- const { setScope, searchAvailableReviewers } = useActions(inboxFiltersLogic)+ const {+ scope,+ availableReviewers: reviewers,+ availableReviewersLoading,+ knownTeammate,+ } = useValues(inboxFiltersLogic)+ const { setScope, searchAvailableReviewers, setKnownTeammate } = useActions(inboxFiltersLogic)const { user } = useValues(userLogic)- const [open, setOpen] = useState(false)- const [search, setSearch] = useState('')- // External reference (callback ref → state so the Popover re-anchors once mounted).- const [referenceEl, setReferenceEl] = useState<HTMLDivElement | null>(null)- // Remember the selected teammate's label so the trigger stays correct even while a search- // query has filtered them out of the server-returned `reviewers` list. Keep the uuid alongside- // it: a scope change to a different teammate the roster hasn't loaded (search-filtered, or past- // the 100-row cap) must not fall back to the previous teammate's name.- const [knownTeammate, setKnownTeammate] = useState<{ uuid: string; label: string } | null>(null)const isForYou = scope === INBOX_SCOPE_FOR_YOU- const selectedTeammateUuid = isTeammateInboxScope(scope) ? parseTeammateInboxScope(scope) : null+ const selectedTeammateUuid = parseTeammateInboxScope(scope)const selectedTeammate = reviewers.find((r) => r.user_uuid === selectedTeammateUuid)const selectedTeammateLabel = selectedTeammate ? selectedTeammate.name || selectedTeammate.email : null- useEffect(() => {- if (selectedTeammateUuid && selectedTeammateLabel) {- setKnownTeammate({ uuid: selectedTeammateUuid, label: selectedTeammateLabel })- }- }, [selectedTeammateUuid, selectedTeammateLabel])-// Only reuse the cached label when it names the currently-scoped teammate.const cachedTeammateLabel =knownTeammate && knownTeammate.uuid === selectedTeammateUuid ? knownTeammate.label : null@@ -57,22 +45,32 @@ export function InboxScopeFilter(): JSX.Element {const pick = (next: InboxScope, label?: string): void => {const nextUuid = parseTeammateInboxScope(next)if (label && nextUuid) {- setKnownTeammate({ uuid: nextUuid, label })+ setKnownTeammate(nextUuid, label)}setScope(next)- setOpen(false)- setSearch('')searchAvailableReviewers('')}return (- <>- <div ref={setReferenceEl} className="inline-flex">+ <MemberSelect+ value={selectedTeammateUuid}+ defaultLabel="Entire project"+ extraOptions={[{ label: 'For you', onClick: () => pick(INBOX_SCOPE_FOR_YOU) }]}+ options={reviewers.map((reviewer) => ({+ uuid: reviewer.user_uuid,+ name: reviewer.name,+ email: reviewer.email,+ trailing: reviewer.user_uuid === user?.uuid ? '(you)' : undefined,+ }))}+ optionsLoading={availableReviewersLoading}+ onSearch={searchAvailableReviewers}+ onChange={() => pick(INBOX_SCOPE_ENTIRE_PROJECT)}+ onSelectOption={(uuid, label) => pick(teammateInboxScope(uuid), label)}+ >+ {() => (<LemonButtonsize="small"type="secondary"- onClick={() => setOpen((v) => !v)}- sideIcon={<IconChevronDown className="text-tertiary" />}tooltip="See the reports suggested to you, every report in the project, or a teammate's"// Name the active scope for assistive tech. Without this, LemonButton copies the// string tooltip into aria-label, so a screen reader hears the help text and never@@ -82,36 +80,7 @@ export function InboxScopeFilter(): JSX.Element {><span className="max-w-[160px] truncate">{triggerLabel}</span></LemonButton>- </div>- <InboxPeoplePicker- visible={open}- referenceElement={referenceEl}- onClose={() => setOpen(false)}- search={search}- onSearch={(value) => {- setSearch(value)- searchAvailableReviewers(value)- }}- // The signed-in user keeps their own roster row next to the pinned "For you" row. Both- // show the same reports, but only the roster row writes `scope=teammate:<uuid>` to the- // URL. "For you" is the default, so it leaves the URL bare and resolves to whoever opens- // the link. The roster row is the only way to share a link that opens to your reports.- people={reviewers.map((reviewer) => ({- uuid: reviewer.user_uuid,- name: reviewer.name,- email: reviewer.email,- trailing: reviewer.user_uuid === user?.uuid ? '(you)' : undefined,- }))}- loading={availableReviewersLoading}- selectedUuid={scope === INBOX_SCOPE_ENTIRE_PROJECT ? null : (selectedTeammateUuid ?? undefined)}- forYou={{ active: isForYou, onPick: () => pick(INBOX_SCOPE_FOR_YOU) }}- everyoneLabel="Entire project"- onPick={(person) =>- person- ? pick(teammateInboxScope(person.uuid), person.name || person.email)- : pick(INBOX_SCOPE_ENTIRE_PROJECT)- }- />- </>+ )}+ </MemberSelect>)}diff --git a/products/signals/frontend/inbox/components/shell/InboxScopeSelect.tsx b/products/signals/frontend/inbox/components/shell/InboxScopeSelect.tsxindex 17fa4f814bd7..1efae5be87d8 100644--- a/products/signals/frontend/inbox/components/shell/InboxScopeSelect.tsx+++ b/products/signals/frontend/inbox/components/shell/InboxScopeSelect.tsx@@ -1,119 +1,76 @@import { useActions, useValues } from 'kea'-import { useEffect, useState } from 'react'import { IconChevronDown } from '@posthog/icons'-import { LemonSegmentedButton } from '@posthog/lemon-ui'+import { LemonButton } from '@posthog/lemon-ui'-import { isTeammateInboxScope, parseTeammateInboxScope, teammateInboxScope } from '../../inboxMembership'+import { MemberSelect } from 'lib/components/MemberSelect'++import { parseTeammateInboxScope, teammateInboxScope } from '../../inboxMembership'import { inboxFiltersLogic } from '../../logics/inboxFiltersLogic'import { INBOX_SCOPE_ENTIRE_PROJECT, INBOX_SCOPE_FOR_YOU, InboxScope } from '../../types'-import { InboxPeoplePicker } from './InboxPeoplePicker'-/**- * Two-segment scope toggle built on `LemonSegmentedButton`. Left segment is- * "For you"; the right segment shows "Entire project" or the selected teammate's- * name and opens the shared people picker ("Entire project" + each teammate).- * One-to-one port of desktop `InboxScopeSelect` (segmented control + combobox),- * in LemonUI. Scope is persisted via `inboxFiltersLogic`; teammates come from- * its shared `availableReviewers` loader.- */export function InboxScopeSelect(): JSX.Element {- const { scope, availableReviewers: reviewers, availableReviewersLoading } = useValues(inboxFiltersLogic)- const { setScope, searchAvailableReviewers } = useActions(inboxFiltersLogic)- const [open, setOpen] = useState(false)- const [search, setSearch] = useState('')- // External reference (callback ref → state so the Popover re-anchors once mounted).- // Anchoring via `referenceElement` keeps the segment buttons OUT of the popover-reference- // context, so LemonButton doesn't auto-add its own dropdown chevron to each segment.- const [referenceEl, setReferenceEl] = useState<HTMLDivElement | null>(null)- // Remember the selected teammate's label so the trigger stays correct even while a search- // query has filtered them out of the server-returned `reviewers` list.- const [knownTeammateLabel, setKnownTeammateLabel] = useState<string | null>(null)-- const isForYou = scope === INBOX_SCOPE_FOR_YOU- const selectedTeammateUuid = isTeammateInboxScope(scope) ? parseTeammateInboxScope(scope) : null- const selectedTeammate = reviewers.find((r) => r.user_uuid === selectedTeammateUuid)- const selectedTeammateLabel = selectedTeammate ? selectedTeammate.name || selectedTeammate.email : null+ const {+ scope,+ availableReviewers: reviewers,+ availableReviewersLoading,+ knownTeammate,+ } = useValues(inboxFiltersLogic)+ const { setScope, searchAvailableReviewers, setKnownTeammate } = useActions(inboxFiltersLogic)- useEffect(() => {- if (selectedTeammateUuid && selectedTeammateLabel) {- setKnownTeammateLabel(selectedTeammateLabel)- }- }, [selectedTeammateUuid, selectedTeammateLabel])+ const selectedUuid = parseTeammateInboxScope(scope)+ const selectedTeammate = reviewers.find((reviewer) => reviewer.user_uuid === selectedUuid)+ const selectedLabel = selectedTeammate ? selectedTeammate.name || selectedTeammate.email : null- const rightLabel = selectedTeammateUuid- ? (selectedTeammateLabel ?? knownTeammateLabel ?? 'Teammate')+ const rightLabel = selectedUuid+ ? (selectedLabel ?? (knownTeammate?.uuid === selectedUuid ? knownTeammate.label : null) ?? 'Teammate'): 'Entire project'const pick = (next: InboxScope, label?: string): void => {- if (label) {- setKnownTeammateLabel(label)+ const nextUuid = parseTeammateInboxScope(next)+ if (nextUuid && label) {+ setKnownTeammate(nextUuid, label)}setScope(next)- setOpen(false)- setSearch('')searchAvailableReviewers('')}return (- <>- <div ref={setReferenceEl} className="inline-flex">- <LemonSegmentedButton- size="small"- value={isForYou ? 'for-you' : 'other'}- onChange={(value) => {- if (value === 'for-you') {- // Left segment selects the For-you scope and closes the picker.- setScope(INBOX_SCOPE_FOR_YOU)- setOpen(false)- } else {- // Right segment opens the people picker; the scope only changes- // once a row (Entire project / teammate) is picked.- setOpen((v) => !v)- }- }}- options={[- {- value: 'for-you',- label: 'For you',- tooltip: 'Only reports where agents suggested you as a reviewer',- },- {- value: 'other',- label: (- <span className="inline-flex items-center gap-1">- <span className="max-w-[160px] truncate">{rightLabel}</span>- <IconChevronDown className="text-tertiary" />- </span>- ),- tooltip: "See every report in the project, or a specific teammate's",- },- ]}- />- </div>- <InboxPeoplePicker- visible={open}- referenceElement={referenceEl}- onClose={() => setOpen(false)}- search={search}- onSearch={(value) => {- setSearch(value)- searchAvailableReviewers(value)- }}- people={reviewers.map((reviewer) => ({+ <div className="inline-flex">+ <LemonButton+ size="small"+ type="secondary"+ active={scope === INBOX_SCOPE_FOR_YOU}+ onClick={() => pick(INBOX_SCOPE_FOR_YOU)}+ tooltip="Only reports where agents suggested you as a reviewer"+ >+ For you+ </LemonButton>+ <MemberSelect+ value={selectedUuid}+ defaultLabel="Entire project"+ options={reviewers.map((reviewer) => ({uuid: reviewer.user_uuid,name: reviewer.name,email: reviewer.email,}))}- loading={availableReviewersLoading}- selectedUuid={scope === INBOX_SCOPE_ENTIRE_PROJECT ? null : (selectedTeammateUuid ?? undefined)}- everyoneLabel="Entire project"- onPick={(person) =>- person- ? pick(teammateInboxScope(person.uuid), person.name || person.email)- : pick(INBOX_SCOPE_ENTIRE_PROJECT)- }- />- </>+ optionsLoading={availableReviewersLoading}+ onSearch={searchAvailableReviewers}+ onChange={() => pick(INBOX_SCOPE_ENTIRE_PROJECT)}+ onSelectOption={(uuid, label) => pick(teammateInboxScope(uuid), label)}+ >+ {() => (+ <LemonButton+ size="small"+ type="secondary"+ active={scope !== INBOX_SCOPE_FOR_YOU}+ tooltip="See every report in the project, or a specific teammate's"+ sideIcon={<IconChevronDown className="text-tertiary" />}+ >+ <span className="max-w-[160px] truncate">{rightLabel}</span>+ </LemonButton>+ )}+ </MemberSelect>+ </div>)}diff --git a/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts b/products/signals/frontend/inbox/logics/inboxFiltersLogic.tsindex 1394a72d3298..9769513c1b84 100644--- a/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts+++ b/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts@@ -13,6 +13,7 @@ import type { UserType } from '~/types'import { INBOX_PRIORITY_OPTIONS, INBOX_SORT_OPTIONS, INBOX_SOURCE_OPTIONS } from '../filterOptions'import { captureInboxQueryChanged, InboxQueryChange } from '../inboxAnalytics'+import { parseTeammateInboxScope } from '../inboxMembership'import {INBOX_LEGACY_TAB_KEYS,INBOX_REPORT_SECTION_KEYS,@@ -241,6 +242,10 @@ export interface inboxFiltersLogicValues {hasActiveFilters: booleanhasUserChosenScope: booleanisRedesign: boolean+ knownTeammate: {+ label: string+ uuid: string+ } | nullpriorityFilter: SignalReportPriority[]scope: InboxScopescoutFilter: string[]@@ -298,6 +303,13 @@ export interface inboxFiltersLogicActions {setFilters: (filters: InboxFilterState) => {filters: InboxFilterState}+ setKnownTeammate: (+ uuid: string,+ label: string+ ) => {+ label: string+ uuid: string+ }setPriorityFilter: (priorities: SignalReportPriority[]) => {priorities: SignalReportPriority[]}@@ -376,6 +388,7 @@ export const inboxFiltersLogic = kea<inboxFiltersLogicType>([actions({setScope: (scope: InboxScope) => ({ scope }),+ setKnownTeammate: (uuid: string, label: string) => ({ uuid, label }),// Auto-select a default scope (e.g. Entire project when the user has no assigned reports)// without marking it as an explicit user choice, so a later real choice still wins and persists.applyDefaultScope: (scope: InboxScope) => ({ scope }),@@ -435,14 +448,26 @@ export const inboxFiltersLogic = kea<inboxFiltersLogicType>([hasActiveFilters: values.hasActiveFilters,})+ const rememberSelectedTeammate = (): void => {+ const uuid = parseTeammateInboxScope(values.scope)+ const reviewer = values.availableReviewers.find((reviewer) => reviewer.user_uuid === uuid)+ if (uuid && reviewer) {+ actions.setKnownTeammate(uuid, reviewer.name || reviewer.email)+ }+ }+return {+ loadAvailableReviewersSuccess: rememberSelectedTeammate,searchAvailableReviewers: async ({ query }, breakpoint) => {await breakpoint(300)actions.loadAvailableReviewers({ query: query.trim() || undefined })},// `applyDefaultScope` is deliberately absent — it's the empty-inbox auto-default, not a// user choice, and counting it as engagement is exactly the inflation we're trying to avoid.- setScope: () => captureQueryChange('scope'),+ setScope: () => {+ rememberSelectedTeammate()+ captureQueryChange('scope')+ },setSort: () => captureQueryChange('sort'),toggleSourceProduct: () => captureQueryChange('source_product'),toggleScout: () => captureQueryChange('scout'),@@ -451,7 +476,10 @@ export const inboxFiltersLogic = kea<inboxFiltersLogicType>([setPriorityFilter: () => captureQueryChange('priority'),toggleState: () => captureQueryChange('state'),clearFilters: () => captureQueryChange('clear'),- setFilters: () => captureQueryChange('url'),+ setFilters: () => {+ rememberSelectedTeammate()+ captureQueryChange('url')+ },// The search box fires per keystroke; settle first so a typed phrase is one event.setSearchQuery: async (_, breakpoint) => {await breakpoint(600)@@ -461,6 +489,11 @@ export const inboxFiltersLogic = kea<inboxFiltersLogicType>([}),reducers({+ // Keep the selected label when a search removes its row from the returned roster.+ knownTeammate: [+ null as { uuid: string; label: string } | null,+ { setKnownTeammate: (_, { uuid, label }) => ({ uuid, label }) },+ ],scope: [INBOX_SCOPE_FOR_YOU as InboxScope,{ persist: true },