Skip to content

: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.

feat(customer-analytics): search linked feature requests (#87068)

Arthur Moreira de Deus8a9bd5bd8808
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index f0ad21188c05..f25755d81593 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5799,7 +5799,7 @@ snapshots:
scenes-app-customer-analytics-accounts--row-expanded-feature-requests--dark:
hash: v1.k794b7964.3550178b721e91fc806f841754bba3a3fdd2e0fdd2a8674cb2af773fd7ddad49.zXeWz2rgJxGeGlCJpmfj7fgjIGOw3P7UEZsRf7iaoGs
scenes-app-customer-analytics-accounts--row-expanded-feature-requests--light:
- hash: v1.k794b7964.7834a6d05cb251553b3862de12152cb10f46e39ae247f3aea8790c4b8f32390c.ZgnlU9dDtcjD2PYGpqDfxi66rARzxeG18fNFn0_dpys
+ hash: v1.k794b7964.3dacbc6067e557b821633b151997b677019a310783816e533ba94461d2cca19f.v3CvTYMJ73R0QZ_kDc7aX64QokGJmYxBZzlBNaqJhYQ
scenes-app-customer-analytics-accounts--row-expanded-links-disabled--dark:
hash: v1.k794b7964.385a63b277ab9041131f99759cf602d06443de6cc4e41333603d1187d64b6954.sQ8rSdSRp6Hbyvu_itGLdKOfbKjxjMSO_rxHaY4nP_0
scenes-app-customer-analytics-accounts--row-expanded-links-disabled--light:
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
index e9ed2a096546..90aac394876e 100644
--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md
+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
@@ -50,7 +50,7 @@ AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_TABLE_DATA_NODE_KEY, acc
| `accountNotebooksLogic` | Notes/notebooks linked to one account (keyed by `accountId`): server-side pagination (`page`/`notebooksCount`), debounced title+content search (`searchTerm`), sort (`sorting` by created date/author), and `createNote` (creates an internal account notebook and opens it in the side panel). |
| `accountRelatedUsersLogic` | Group members / related users for one account (keyed by `externalId`). US-region orgs come from the org-members endpoint; when it returns no members, the logic falls back to the `eu_org_members` data warehouse view (a materialized pre-join of the EU postgres sync, prod-only, refreshed daily), fetched once per expansion and paginated client-side. A missing view (local dev) degrades to the normal empty state. |
| `accountRelationshipsLogic` | Relationship assignments for one account (keyed by `accountId`): fetches the full timeline once (`include_history=true` on the nested relationships endpoint) — the `displayedRelationships` selector (current assignments first, newest first, optionally narrowed by `definitionFilter`) feeds the (paginated) history tab, the `activeRelationships` selector feeds the sidebar summary. Also owns the tab's mutations: `assignRelationship` (definition picker + `MemberSelect`, POSTs the assign endpoint) and `endRelationship` (per active row, POSTs the end endpoint) — both guarded by a shared `relationshipSaving` flag, reload the timeline, and force-refresh the list's data nodes so relationship columns stay in sync. |
-| `accountFeatureRequestsLogic` | Feature requests for one account (keyed by `accountId`): loads linked requests with server pagination, then searches a bounded server page of accessible, editable active requests for the link picker. The picker exposes load failures with retry guidance and refreshes stale options after optimistic-concurrency conflicts. |
+| `accountFeatureRequestsLogic` | Feature requests for one account (keyed by `accountId`): loads linked requests with server pagination and debounced search, then searches a bounded server page of accessible, editable active requests for the link picker. The picker exposes load failures with retry guidance and refreshes stale options after optimistic-concurrency conflicts. |
| `accountBillingLogic` | Billing data behind the Usage and Spend tabs (keyed by `accountId:kind`); injects the account's org + date range into saved billing insights' SQL variables, preloads each insight result when the account expands, and owns the per-view hidden-series state (`ephemeralHiddenSeriesKeysByShortId`) behind the chart chips. |
| `accountOpportunitiesLogic` | Salesforce opportunities behind the Opportunities tab (keyed by `accountId`): fetches the account's `sfdc_id`, then queries the data-warehouse `salesforce.opportunity` table via HogQL. Degrades to an empty state (not an error) when the table is absent — it's production-only. |
| `accountSummariesLogic` | The Summaries tab (keyed by `accountId`): fetches the account (for its linked `slack_channel_id` and `slack_summary_cadence`) plus the first page of the `accountsSummariesList` endpoint, navigates server pages via `loadSummariesPage` (5 per page, `page` reducer; each page replaces the last), holds per-summary collapse state (`expandedSummaryIds` / `toggleSummaryExpanded`), and owns the cadence opt-in (`setCadence` PATCHes the account through `accountsPartialUpdate`, guarded by a `cadenceSaving` flag). Turning the cadence on with no summaries yet starts `generatingFirstSummary` polling (`startFirstSummaryPolling` / `stopFirstSummaryPolling`, two `cache.disposables` keys) so the backfill the backend kicks off appears without a refresh; the poll deadline lives in a module-level map keyed by account id, because this logic unmounts whenever its row collapses while the backfill keeps running. Distinguishes not-loaded / no-channel-linked / generating / loaded-empty / load-failed; captures unexpected failures. |
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountFeatureRequestsExpansion.tsx b/products/customer_analytics/frontend/components/Accounts/AccountFeatureRequestsExpansion.tsx
index 3fcb8ecaebfe..b9e400ebc1d1 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountFeatureRequestsExpansion.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountFeatureRequestsExpansion.tsx
@@ -1,10 +1,11 @@
import { useActions, useValues } from 'kea'
import { combineUrl } from 'kea-router'
-import { IconPlus } from '@posthog/icons'
+import { IconPlus, IconSearch } from '@posthog/icons'
import {
LemonBanner,
LemonButton,
+ LemonInput,
LemonInputSelect,
LemonModal,
LemonTable,
@@ -25,6 +26,7 @@ export function AccountFeatureRequestsExpansion({ accountId }: { accountId: stri
const {
accountRequests,
accountRequestsPage,
+ accountRequestsSearch,
accountRequestsLoading,
accountRequestsError,
requestPickerOpen,
@@ -41,6 +43,7 @@ export function AccountFeatureRequestsExpansion({ accountId }: { accountId: stri
closeRequestPicker,
setSelectedRequestId,
setAccountRequestsPage,
+ setAccountRequestsSearch,
setRequestSearch,
linkSelectedRequest,
} = useActions(logic)
@@ -92,7 +95,17 @@ export function AccountFeatureRequestsExpansion({ accountId }: { accountId: stri
return (
<div className="flex flex-col gap-3" data-attr="account-feature-requests">
- <div className="flex justify-end">
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <LemonInput
+ type="search"
+ value={accountRequestsSearch}
+ onChange={setAccountRequestsSearch}
+ placeholder="Search linked requests"
+ prefix={<IconSearch />}
+ size="small"
+ className="min-w-64"
+ data-attr="account-feature-requests-search"
+ />
<LemonButton
type="primary"
size="small"
@@ -115,7 +128,11 @@ export function AccountFeatureRequestsExpansion({ accountId }: { accountId: stri
columns={columns}
rowKey="id"
loading={accountRequestsLoading}
- emptyState="No feature requests linked to this account."
+ emptyState={
+ accountRequestsSearch.trim()
+ ? 'No linked feature requests match your search.'
+ : 'No feature requests linked to this account.'
+ }
pagination={{
controlled: true,
pageSize: ACCOUNT_FEATURE_REQUESTS_PAGE_SIZE,
diff --git a/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.test.ts
index 2d594a4f2ba9..14c21747113a 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.test.ts
@@ -7,7 +7,7 @@ import { ApiError } from 'lib/api'
import { initKeaTests } from '~/test/init'
import * as generatedApi from '../../generated/api'
-import type { FeatureRequestApi } from '../../generated/api.schemas'
+import type { FeatureRequestApi, PaginatedFeatureRequestListApi } from '../../generated/api.schemas'
import { accountFeatureRequestsLogic } from './accountFeatureRequestsLogic'
const existingRequest: FeatureRequestApi = {
@@ -78,7 +78,7 @@ describe('accountFeatureRequestsLogic', () => {
logic.unmount()
})
- it('paginates linked requests on the server', async () => {
+ it('paginates linked requests and searches from the first page', async () => {
const requests = Array.from({ length: 21 }, (_, index) => ({
...existingRequest,
id: `request-${index + 1}`,
@@ -107,6 +107,54 @@ describe('accountFeatureRequestsLogic', () => {
String(MOCK_DEFAULT_TEAM.id),
expect.objectContaining({ account_ids: ['account-2'], limit: 20, offset: 20 })
)
+
+ await expectLogic(logic, () => logic.actions.setAccountRequestsSearch('scheduled')).toFinishAllListeners()
+
+ expect(logic.values.accountRequestsPage).toBe(1)
+ expect(listSpy).toHaveBeenLastCalledWith(
+ String(MOCK_DEFAULT_TEAM.id),
+ expect.objectContaining({
+ account_ids: ['account-2'],
+ limit: 20,
+ offset: 0,
+ search: 'scheduled',
+ })
+ )
+ logic.unmount()
+ })
+
+ it('ignores a stale page response after a newer request finishes', async () => {
+ let resolvePageTwo: (response: PaginatedFeatureRequestListApi) => void = () => undefined
+ let resolvePageThree: (response: PaginatedFeatureRequestListApi) => void = () => undefined
+ const pageTwoResponse = new Promise<PaginatedFeatureRequestListApi>((resolve) => {
+ resolvePageTwo = resolve
+ })
+ const pageThreeResponse = new Promise<PaginatedFeatureRequestListApi>((resolve) => {
+ resolvePageThree = resolve
+ })
+ jest.spyOn(generatedApi, 'featureRequestsList')
+ .mockResolvedValueOnce(emptyPage)
+ .mockImplementation(async (_teamId, params) => {
+ if (params?.offset === 20) {
+ return pageTwoResponse
+ }
+ if (params?.offset === 40) {
+ return pageThreeResponse
+ }
+ return emptyPage
+ })
+ const logic = accountFeatureRequestsLogic({ accountId: 'account-2' })
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ logic.actions.setAccountRequestsPage(2)
+ logic.actions.setAccountRequestsPage(3)
+ resolvePageThree({ ...emptyPage, count: 41, results: [{ ...existingRequest, id: 'request-page-3' }] })
+ resolvePageTwo({ ...emptyPage, count: 41, results: [{ ...existingRequest, id: 'request-page-2' }] })
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.accountRequestsPage).toBe(3)
+ expect(logic.values.accountRequests.results.map((request) => request.id)).toEqual(['request-page-3'])
logic.unmount()
})
diff --git a/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.ts
index a7da0315ca08..209b9a017d62 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.ts
@@ -29,6 +29,7 @@ export interface accountFeatureRequestsLogicValues {
accountRequestsError: string | null
accountRequestsLoading: boolean
accountRequestsPage: number
+ accountRequestsSearch: string
availableRequests: FeatureRequestApi[]
availableRequestsError: string | null
availableRequestsLoading: boolean
@@ -50,7 +51,7 @@ export interface accountFeatureRequestsLogicActions {
linkSelectedRequest: () => {
value: true
}
- loadAccountRequests: () => any
+ loadAccountRequests: (_?: any) => any
loadAccountRequestsFailure: (
error: string,
errorObject?: any
@@ -86,6 +87,9 @@ export interface accountFeatureRequestsLogicActions {
setAccountRequestsPage: (page: number) => {
page: number
}
+ setAccountRequestsSearch: (search: string) => {
+ search: string
+ }
setLinkingRequest: (linkingRequest: boolean) => {
linkingRequest: boolean
}
@@ -125,6 +129,7 @@ export const accountFeatureRequestsLogic = kea<accountFeatureRequestsLogicType>(
closeRequestPicker: true,
setSelectedRequestId: (selectedRequestId: string | null) => ({ selectedRequestId }),
setAccountRequestsPage: (page: number) => ({ page }),
+ setAccountRequestsSearch: (search: string) => ({ search }),
setRequestSearch: (search: string) => ({ search }),
linkSelectedRequest: true,
setLinkingRequest: (linkingRequest: boolean) => ({ linkingRequest }),
@@ -133,13 +138,17 @@ export const accountFeatureRequestsLogic = kea<accountFeatureRequestsLogicType>(
accountRequests: [
EMPTY_REQUESTS_RESPONSE,
{
- loadAccountRequests: async () =>
- featureRequestsList(String(values.currentTeam?.id), {
+ loadAccountRequests: async (_ = null, breakpoint) => {
+ const response = await featureRequestsList(String(values.currentTeam?.id), {
account_ids: [props.accountId],
archive_state: 'all',
+ search: values.accountRequestsSearch.trim() || undefined,
limit: ACCOUNT_FEATURE_REQUESTS_PAGE_SIZE,
offset: (values.accountRequestsPage - 1) * ACCOUNT_FEATURE_REQUESTS_PAGE_SIZE,
- }),
+ })
+ breakpoint()
+ return response
+ },
},
],
availableRequests: [
@@ -176,8 +185,10 @@ export const accountFeatureRequestsLogic = kea<accountFeatureRequestsLogicType>(
1,
{
setAccountRequestsPage: (_, { page }) => page,
+ setAccountRequestsSearch: () => 1,
},
],
+ accountRequestsSearch: ['', { setAccountRequestsSearch: (_, { search }) => search }],
requestSearch: [
'',
{
@@ -215,6 +226,10 @@ export const accountFeatureRequestsLogic = kea<accountFeatureRequestsLogicType>(
listeners(({ props, values, actions }) => ({
openRequestPicker: () => actions.loadAvailableRequests(),
setAccountRequestsPage: () => actions.loadAccountRequests(),
+ setAccountRequestsSearch: async (_, breakpoint) => {
+ await breakpoint(300)
+ actions.loadAccountRequests()
+ },
setRequestSearch: async (_, breakpoint) => {
await breakpoint(300)
actions.loadAvailableRequests()