: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(ai): filter chat history by origin (#100554)
Chris Volzer892aca269dbf
diff --git a/docs/published/handbook/engineering/ai/sandboxed-agents.md b/docs/published/handbook/engineering/ai/sandboxed-agents.mdindex 0c097d779668..8239a043fc3b 100644--- a/docs/published/handbook/engineering/ai/sandboxed-agents.md+++ b/docs/published/handbook/engineering/ai/sandboxed-agents.md@@ -36,6 +36,10 @@ Follow-up messages collect in "Up next" and send after the first response finishOnce the agent starts, Steer can send them before the current turn ends.The thread hides empty and whitespace-only assistant messages during streaming and history replay.+The chat history filters for PostHog AI, Slack, and Desktop show tasks created by the current user.+These requests wait until the current user's ID is available, including filter changes, searches, and refreshes.+When the user loads, the pending request uses the active filter and search term.+```textYour product code│diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 6ebb689fd582..d25c4c864834 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -5928,6 +5928,14 @@ snapshots:hash: v1.k794b7964.6d96696bb96a440ce1fa7b776edc81f103b6812009d0a850bcda00634acf485f.dm_X4B9rkIjkeWEqyEbies8fE9rJzn6jP1Rwjfl1Txsproducts-posthog-ai-startup-chat--sidebar--light:hash: v1.k794b7964.21eaee49f9429125b726ca537df2609832e2d31297b0e98d8264964866f293cb.u5AJc9X9898pYhh_P0fqkrmxDZRscEkFWYiCq68frv4+ products-posthog-ai-taskassigneefiltermenu--non-staff--dark:+ hash: v1.k794b7964.4035ea833c33e4ee5a2170621229dd92f1d100cf62a6e31a76e87f9b7208929d.A-PKKpUmtDu7WAcdTGXByPOQIfE5-GNHqOQ6uIa5Dfg+ products-posthog-ai-taskassigneefiltermenu--non-staff--light:+ hash: v1.k794b7964.068f6f8c005f286387bdaf6bfa91856bb0b3eed287c94d80983a74ea5663363a.1HycZE07eRlacyWMXxpLE6iI1aalIj2fNub2NQHSmoA+ products-posthog-ai-taskassigneefiltermenu--staff--dark:+ hash: v1.k794b7964.4035ea833c33e4ee5a2170621229dd92f1d100cf62a6e31a76e87f9b7208929d.psrRGt1S88jvdKLhtV2jSQ7BA1aRSlMwqM4giZf51uk+ products-posthog-ai-taskassigneefiltermenu--staff--light:+ hash: v1.k794b7964.068f6f8c005f286387bdaf6bfa91856bb0b3eed287c94d80983a74ea5663363a.xsldW73f4YSK9PPTcqbUdzQvps4iPX5EcQdQKZa5-04products-posthog-ai-threadactivitygroup--long-history--dark:hash: v1.k794b7964.8b34d1e1c80e586075052512fbf6342204ac90e7e990b4b0a2216794daffe677.RbS0dZBWhHvm3zRt-7dgogNZVBloP_Oonxbo8qrZIoAproducts-posthog-ai-threadactivitygroup--long-history--light:@@ -10691,7 +10699,7 @@ snapshots:scenes-other-onboarding-shared-wizard-cloud-run--run-it-yourself--dark:hash: v1.k794b7964.5a35f0677ffb11febcba8084a0ccb558ecff39d861a8cd8c6501671f47a1fac2.Of5i_K-cfe3g96_a6dHtRI0PeaDjaJ0rdWZMi6O4aG0scenes-other-onboarding-shared-wizard-cloud-run--run-it-yourself--light:- hash: v1.k794b7964.8cff144ac77c6006b48a62a014070b994affcef9058056e2a95b8f4e22084c76.hP6I6QLsGi3k_TebVwrWapvf_CjCVBsmTFQ81_8HVfo+ hash: v1.k794b7964.acc28e25e011b28ef72f89cc2e2494c5b20d4df504f501b3841777f33caecc2f.yvS9TBOTcaphHhW5g2EW9hNjWcKf7TidUb2f2Tp2ROkscenes-other-onboarding-shared-wizard-handoff-dialog--opened--dark:hash: v1.k794b7964.810fb1774d7f9ebf7b63cab5e3b5a45606bb9f498c3aff4ee6ee4d45bbb33123.jD9rqBcIaYTHx4mQTQs73wzG3zM_WtCv8UutSWtnny0scenes-other-onboarding-shared-wizard-handoff-dialog--opened--light:diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavTabChat.test.ts b/frontend/src/layout/panel-layout/navbar/tabs/NavTabChat.test.tsindex a51ec28f81a8..8bdc26699fe6 100644--- a/frontend/src/layout/panel-layout/navbar/tabs/NavTabChat.test.ts+++ b/frontend/src/layout/panel-layout/navbar/tabs/NavTabChat.test.ts@@ -2,7 +2,7 @@ import { MOCK_DEFAULT_BASIC_USER } from 'lib/api.mock'import { Conversation, ConversationStatus, ConversationType } from '~/types'-import type { Task } from 'products/posthog_ai/frontend/api/types'+import type { Task, TaskAssigneeFilter } from 'products/posthog_ai/frontend/api/types'import { groupAiHistory, groupConversations } from './NavTabChat'@@ -48,6 +48,21 @@ const baseTask: Task = {}describe('groupAiHistory', () => {+ it.each<[TaskAssigneeFilter, boolean]>([+ ['for_you', true],+ ['posthog_ai', true],+ ['slack', false],+ ['desktop', false],+ ['my_scouts', false],+ ['team_scouts', false],+ ['all_team', true],+ ])('includes chat history only when it matches %s', (filter, includesChats) => {+ const items = groupAiHistory([conversation], [baseTask], filter).flatMap((group) => group.items)++ expect(items.some((item) => item.kind === 'conversation')).toBe(includesChats)+ expect(items.filter((item) => item.kind === 'task')).toHaveLength(1)+ })+it('combines chats and tasks in updated order', () => {const olderConversation = {...conversation,diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavTabChat.tsx b/frontend/src/layout/panel-layout/navbar/tabs/NavTabChat.tsxindex 8c6c657f59ba..4f1483c36133 100644--- a/frontend/src/layout/panel-layout/navbar/tabs/NavTabChat.tsx+++ b/frontend/src/layout/panel-layout/navbar/tabs/NavTabChat.tsx@@ -22,7 +22,7 @@ import type { Conversation } from '~/types'import { tasksLogic } from 'products/posthog_ai/frontend/api/logics'import { TaskAssigneeFilterMenu, TaskListItem } from 'products/posthog_ai/frontend/api/primitives'-import type { Task } from 'products/posthog_ai/frontend/api/types'+import type { Task, TaskAssigneeFilter } from 'products/posthog_ai/frontend/api/types'const DATE_GROUP_ORDER = ['Today', 'Yesterday', 'Last 7 days', 'Last 30 days', 'Older'] as const@@ -76,10 +76,15 @@ export interface AiHistoryGroup {items: AiHistoryItem[]}-export function groupAiHistory(conversationHistory: Conversation[], tasks: Task[]): AiHistoryGroup[] {+export function groupAiHistory(+ conversationHistory: Conversation[],+ tasks: Task[],+ filter: TaskAssigneeFilter = 'for_you'+): AiHistoryGroup[] {const items: AiHistoryItem[] = []- for (const conversation of conversationHistory) {+ const showConversations = filter === 'for_you' || filter === 'posthog_ai' || filter === 'all_team'+ for (const conversation of showConversations ? conversationHistory : []) {if (!conversation) {continue}@@ -274,6 +279,7 @@ export function NavTabChat({tasksSearchPending,searchQuery,taskListParams,+ assigneeFilter,} = useValues(tasksLogic)const { loadTasks, loadMoreTasks, setSearchQuery } = useActions(tasksLogic)const { location, searchParams } = useValues(router)@@ -286,8 +292,8 @@ export function NavTabChat({: (location.pathname.match(/\/tasks\/([^/]+)/)?.[1] ?? null)const historyGroups = useMemo(- () => groupAiHistory(conversationHistory, tasksEnabled ? tasks : []),- [conversationHistory, tasks, tasksEnabled]+ () => groupAiHistory(conversationHistory, tasksEnabled ? tasks : [], tasksEnabled ? assigneeFilter : 'for_you'),+ [conversationHistory, tasks, tasksEnabled, assigneeFilter])const initialLoading = historyGroups.length === 0 && (conversationHistoryLoading || (tasksEnabled && tasksLoading))// Typing moves the client-side filter at once, but the matching tasks are a debounce plus a rounddiff --git a/products/posthog_ai/frontend/components/navigation/TaskAssigneeFilterMenu.stories.tsx b/products/posthog_ai/frontend/components/navigation/TaskAssigneeFilterMenu.stories.tsxnew file mode 100644index 000000000000..6453f249768d--- /dev/null+++ b/products/posthog_ai/frontend/components/navigation/TaskAssigneeFilterMenu.stories.tsx@@ -0,0 +1,34 @@+import { MOCK_DEFAULT_USER } from 'lib/api.mock'++import type { Meta, StoryObj } from '@storybook/react'++import { mswDecorator } from '~/mocks/browser'++import { TaskAssigneeFilterMenu } from './TaskAssigneeFilterMenu'++const meta: Meta<typeof TaskAssigneeFilterMenu> = {+ title: 'Products/PostHog AI/TaskAssigneeFilterMenu',+ component: TaskAssigneeFilterMenu,+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:team_id/tasks/': { results: [], count: 0 },+ },+ }),+ ],+}+export default meta++type Story = StoryObj<typeof TaskAssigneeFilterMenu>++export const Staff: Story = {}++export const NonStaff: Story = {+ decorators: [+ mswDecorator({+ get: {+ '/api/users/@me/': { ...MOCK_DEFAULT_USER, is_staff: false },+ },+ }),+ ],+}diff --git a/products/posthog_ai/frontend/components/navigation/TaskAssigneeFilterMenu.tsx b/products/posthog_ai/frontend/components/navigation/TaskAssigneeFilterMenu.tsxindex cbca8a3e3031..3d99e0adfc55 100644--- a/products/posthog_ai/frontend/components/navigation/TaskAssigneeFilterMenu.tsx+++ b/products/posthog_ai/frontend/components/navigation/TaskAssigneeFilterMenu.tsx@@ -28,12 +28,15 @@ export function TaskAssigneeFilterMenu(): JSX.Element {}/><DropdownMenuContent align="start" side="bottom" sideOffset={6} className="min-w-fit">- <MenuLabel>Show tasks</MenuLabel>+ <MenuLabel>Show chats</MenuLabel><DropdownMenuRadioGroupvalue={assigneeFilter}onValueChange={(value) => setAssigneeFilter(value as TaskAssigneeFilter)}><DropdownMenuRadioItem value="for_you">For you</DropdownMenuRadioItem>+ <DropdownMenuRadioItem value="posthog_ai">PostHog AI</DropdownMenuRadioItem>+ <DropdownMenuRadioItem value="slack">Slack</DropdownMenuRadioItem>+ <DropdownMenuRadioItem value="desktop">Desktop</DropdownMenuRadioItem><DropdownMenuRadioItem value="my_scouts">My scouts</DropdownMenuRadioItem><DropdownMenuRadioItem value="team_scouts">Team scouts</DropdownMenuRadioItem>{isStaffUser && (diff --git a/products/posthog_ai/frontend/logics/tasksLogic.test.ts b/products/posthog_ai/frontend/logics/tasksLogic.test.tsindex 9e75be468cf2..6e8b421a8c14 100644--- a/products/posthog_ai/frontend/logics/tasksLogic.test.ts+++ b/products/posthog_ai/frontend/logics/tasksLogic.test.ts@@ -105,6 +105,9 @@ describe('tasksLogic', () => {],['my_scouts' as const, { created_by: MOCK_DEFAULT_USER.id, origin_product: OriginProduct.SIGNALS_SCOUT }],['team_scouts' as const, { origin_product: OriginProduct.SIGNALS_SCOUT }],+ ['posthog_ai' as const, { created_by: MOCK_DEFAULT_USER.id, origin_product: OriginProduct.POSTHOG_AI }],+ ['slack' as const, { created_by: MOCK_DEFAULT_USER.id, origin_product: OriginProduct.SLACK }],+ ['desktop' as const, { created_by: MOCK_DEFAULT_USER.id, client_provenance: 'posthog_desktop' }],])('maps the %s filter to its query params', (assigneeFilter, expected) => {logic.actions.setAssigneeFilter(assigneeFilter)@@ -159,6 +162,66 @@ describe('tasksLogic', () => {expect(listRequestUrls).toHaveLength(1)})+ // Regression coverage: `created_by` is the current user's id, and a filter picked before the+ // user had loaded sent the request without it. The server then answered with every task the+ // caller can read, so an origin filter showed other people's shared tasks.+ it.each([+ ['posthog_ai', 'checkout bug'],+ ['slack', ''],+ ['desktop', 'checkout bug'],+ ] as const)(+ 'holds the %s filter and search until the user has loaded after a team request',+ async (filter, search) => {+ userLogic.actions.loadUserSuccess(null)+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.TASKS], { [FEATURE_FLAGS.TASKS]: true })++ logic.actions.setAssigneeFilter('team_scouts')+ await expectLogic(logic).toFinishAllListeners()+ expect(listRequestUrls).toHaveLength(1)+ listRequestUrls = []++ logic.actions.setAssigneeFilter(filter)+ if (search) {+ logic.actions.setSearchQuery(search)+ }+ await expectLogic(logic).toFinishAllListeners()++ expect(listRequestUrls).toHaveLength(0)++ userLogic.actions.loadUserSuccess(MOCK_DEFAULT_USER)+ await expectLogic(logic).toFinishAllListeners()++ expect(listRequestUrls).toHaveLength(1)+ expect(+ listRequestUrls[0].searchParams.get(filter === 'desktop' ? 'client_provenance' : 'origin_product')+ ).toBe(filter === 'desktop' ? 'posthog_desktop' : filter)+ expect(listRequestUrls[0].searchParams.get('created_by')).toBe(String(MOCK_DEFAULT_USER.id))+ expect(listRequestUrls[0].searchParams.get('search')).toBe(search || null)+ }+ )++ it('holds the initial load and a direct refresh until the user has loaded', async () => {+ logic.unmount()+ userLogic.actions.loadUserSuccess(null)+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.TASKS], { [FEATURE_FLAGS.TASKS]: true })+ logic = tasksLogic()+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()++ expect(listRequestUrls).toHaveLength(0)++ logic.actions.loadTasks(logic.values.taskListParams)+ await expectLogic(logic).toFinishAllListeners()++ expect(listRequestUrls).toHaveLength(0)++ userLogic.actions.loadUserSuccess(MOCK_DEFAULT_USER)+ await expectLogic(logic).toFinishAllListeners()++ expect(listRequestUrls).toHaveLength(1)+ expect(listRequestUrls[0].searchParams.get('created_by')).toBe(String(MOCK_DEFAULT_USER.id))+ })+// Regression coverage: the loader reached `breakpoint` only after a resolved response, so a// superseded request that rejected still dispatched `loadTasksFailure`. `tasksError` only// clears on a new `loadTasks`, so the nav kept its error banner above the newer run'sdiff --git a/products/posthog_ai/frontend/logics/tasksLogic.ts b/products/posthog_ai/frontend/logics/tasksLogic.tsindex 5d13b1344147..45e03d3e2686 100644--- a/products/posthog_ai/frontend/logics/tasksLogic.ts+++ b/products/posthog_ai/frontend/logics/tasksLogic.ts@@ -36,6 +36,7 @@ export interface tasksLogicValues {repositoriesLoading: booleansearchQuery: stringtaskListParams: TaskListParams+ taskListParamsReady: booleantasks: Task[]tasksError: string | nulltasksLoading: boolean@@ -53,6 +54,19 @@ export interface tasksLogicActions {flags: string[]variants: Record<string, boolean | string>} // featureFlagLogic+ loadUserSuccess: (+ user: UserType | null,+ payload?:+ | {+ resetOnFailure: boolean | undefined+ }+ | undefined+ ) => {+ payload?: {+ resetOnFailure: boolean | undefined+ }+ user: UserType | null+ } // userLogiccreateTask: ({ data }: { data: TaskUpsertProps }) => {data: TaskUpsertProps}@@ -167,6 +181,7 @@ export interface tasksLogicMeta {assigneeFilter: TaskAssigneeFilter,user: UserType | null) => TaskListParams+ taskListParamsReady: (assigneeFilter: TaskAssigneeFilter, user: UserType | null) => boolean}}@@ -177,7 +192,7 @@ export const tasksLogic = kea<tasksLogicType>([connect(() => ({values: [userLogic, ['user'], featureFlagLogic, ['featureFlags']],- actions: [featureFlagLogic, ['setFeatureFlags']],+ actions: [featureFlagLogic, ['setFeatureFlags'], userLogic, ['loadUserSuccess']],})),actions({@@ -188,7 +203,7 @@ export const tasksLogic = kea<tasksLogicType>([setTasksNext: (next: string | null) => ({ next }),}),- loaders(({ actions, values }) => ({+ loaders(({ actions, values, cache }) => ({tasks: [[] as Task[],{@@ -199,6 +214,10 @@ export const tasksLogic = kea<tasksLogicType>([// it is showing, and `{}` there would swap the active filter for the whole visible set.// The default is evaluated per call, so it picks up the filter active at refresh time.loadTasks: async (params: TaskListParams = values.taskListParams, breakpoint) => {+ cache.tasksLoadPending = !values.taskListParamsReady+ if (cache.tasksLoadPending) {+ return values.tasks+ }let response: PaginatedResponse<Task>try {response = await api.tasks.list(params)@@ -379,48 +398,79 @@ export const tasksLogic = kea<tasksLogicType>([if (assigneeFilter === 'my_scouts') {return { ...base, origin_product: OriginProduct.SIGNALS_SCOUT, created_by: user?.id }}+ if (assigneeFilter === 'posthog_ai' || assigneeFilter === 'slack') {+ return { ...base, origin_product: assigneeFilter, created_by: user?.id }+ }+ if (assigneeFilter === 'desktop') {+ return { ...base, client_provenance: 'posthog_desktop', created_by: user?.id }+ }return { ...base, created_by: user?.id, exclude_origin_product: OriginProduct.SIGNALS_SCOUT }},],+ // Every filter except "team scouts" reads the user: `created_by` pins the list to them, and+ // "all team" is staff-gated. A request sent before the user lands carries no pin, so the+ // server answers with every task the caller can read, shared ones from other people+ // included. Hold the request until then; `loadUserSuccess` sends it.+ taskListParamsReady: [+ (s) => [s.assigneeFilter, s.user],+ (assigneeFilter: TaskAssigneeFilter, user: null | import('~/types').UserType): boolean =>+ assigneeFilter === 'team_scouts' || !!user?.id,+ ],}),- listeners(({ actions, values }) => ({- openTask: ({ taskId }) => {- router.actions.push(`/tasks/${taskId}`)- },- // Debounce typing before hitting the server; the loader's own `breakpoint` then drops any- // response that a newer query has already superseded.- setSearchQuery: async (_, breakpoint) => {- await breakpoint(300)- actions.loadTasks(values.taskListParams)- },- setAssigneeFilter: () => {- actions.loadTasks(values.taskListParams)- },- loadMoreTasksFailure: ({ error, errorObject }) => {- lemonToast.error(`Couldn't load more tasks: ${loadErrorMessage(error, errorObject)}`)- },- // Every surface that archives goes through this loader, so sync the independent panel- // history here instead of asking each one to remember. Only when it's already mounted:- // building it would fetch a list nobody is showing, and a later mount loads it fresh.- deleteTaskSuccess: ({ payload }) => {- if (payload) {- taskHistoryLogic.findMounted()?.actions.taskArchived(payload.taskId)+ listeners(({ actions, values, cache }) => {+ const loadTasksWhenReady = (): void => {+ cache.tasksLoadPending = !values.taskListParamsReady+ if (!cache.tasksLoadPending) {+ actions.loadTasks(values.taskListParams)}- },+ }// The app renders once the feature-flag request times out (3s), so this logic can mount// before the flags land — and it's an unkeyed singleton, so `afterMount` never runs again.// Without this the nav would sit on an empty list, showing "no tasks" rather than loading.- setFeatureFlags: () => {- if (!values.hasRequestedTasks && hasTasksFlag(values.featureFlags)) {+ // The user can land late as well (see `taskListParamsReady`), in either order with the+ // flags, so the first request goes out from whichever arrives last.+ const loadInitialTasks = (): void => {+ if (!values.hasRequestedTasks && hasTasksFlag(values.featureFlags) && values.taskListParamsReady) {actions.loadTasks(values.taskListParams)}- },- })),+ }+ return {+ openTask: ({ taskId }) => {+ router.actions.push(`/tasks/${taskId}`)+ },+ // Debounce typing before hitting the server; the loader's own `breakpoint` then drops any+ // response that a newer query has already superseded.+ setSearchQuery: async (_, breakpoint) => {+ await breakpoint(300)+ loadTasksWhenReady()+ },+ setAssigneeFilter: loadTasksWhenReady,+ loadMoreTasksFailure: ({ error, errorObject }) => {+ lemonToast.error(`Couldn't load more tasks: ${loadErrorMessage(error, errorObject)}`)+ },+ // Every surface that archives goes through this loader, so sync the independent panel+ // history here instead of asking each one to remember. Only when it's already mounted:+ // building it would fetch a list nobody is showing, and a later mount loads it fresh.+ deleteTaskSuccess: ({ payload }) => {+ if (payload) {+ taskHistoryLogic.findMounted()?.actions.taskArchived(payload.taskId)+ }+ },+ setFeatureFlags: loadInitialTasks,+ loadUserSuccess: () => {+ if (cache.tasksLoadPending) {+ loadTasksWhenReady()+ } else {+ loadInitialTasks()+ }+ },+ }+ }),events(({ actions, values }) => ({afterMount: () => {- if (hasTasksFlag(values.featureFlags)) {+ if (hasTasksFlag(values.featureFlags) && values.taskListParamsReady) {actions.loadTasks(values.taskListParams)}},diff --git a/products/posthog_ai/frontend/types/taskTypes.ts b/products/posthog_ai/frontend/types/taskTypes.tsindex 3e4d061aec9a..bd7105c709a3 100644--- a/products/posthog_ai/frontend/types/taskTypes.ts+++ b/products/posthog_ai/frontend/types/taskTypes.ts@@ -3,6 +3,7 @@ import { Optional } from 'lib/utils/types'import {type TaskRunDetailDTOApi,TaskRuntimeEnumApi,+ type TasksListClientProvenance,type TasksListOrdering,} from 'products/tasks/frontend/generated/api.schemas'@@ -30,15 +31,22 @@ export enum OriginProduct {// Tasks created autonomously by the headless Signals Scout — team-scoped, visible to everyone.SIGNALS_SCOUT = 'signals_scout',POSTHOG_AI = 'posthog_ai',+ SLACK = 'slack',// "Create fix task" on the MCP analytics tool-quality failure drill-down.MCP_ANALYTICS = 'mcp_analytics',}/**- * TaskTracker list filter: the current user's own non-scout tasks, their own scout tasks, every- * team scout task, or — staff only — every task on the team.+ * Origin filters stay scoped to the current user, like "for you".*/-export type TaskAssigneeFilter = 'for_you' | 'my_scouts' | 'team_scouts' | 'all_team'+export type TaskAssigneeFilter =+ | 'for_you'+ | 'posthog_ai'+ | 'slack'+ | 'desktop'+ | 'my_scouts'+ | 'team_scouts'+ | 'all_team'export enum TaskRunStatus {NOT_STARTED = 'not_started',@@ -102,6 +110,7 @@ export interface TaskListParams {organization?: stringstage?: stringorigin_product?: string+ client_provenance?: TasksListClientProvenanceexclude_origin_product?: string/** `all` includes internal tasks (shown-by-default flag, not an access gate); `true` narrows to only-internal tasks. */internal?: 'true' | 'false' | 'all'diff --git a/products/tasks/backend/facade/api.py b/products/tasks/backend/facade/api.pyindex 35500c97a2ab..7a6dce29343d 100644--- a/products/tasks/backend/facade/api.py+++ b/products/tasks/backend/facade/api.py@@ -5490,6 +5490,10 @@ def _list_tasks_queryset(if origin_product:qs = qs.filter(origin_product=origin_product)+ client_provenance = filters.get("client_provenance")+ if client_provenance:+ qs = qs.filter(client_provenance=client_provenance)+exclude_origin_product = filters.get("exclude_origin_product")if exclude_origin_product:qs = qs.exclude(origin_product=exclude_origin_product)diff --git a/products/tasks/backend/presentation/serializers.py b/products/tasks/backend/presentation/serializers.pyindex 046cdaca8793..936d1e7a1fbb 100644--- a/products/tasks/backend/presentation/serializers.py+++ b/products/tasks/backend/presentation/serializers.py@@ -2038,6 +2038,11 @@ class TaskListQuerySerializer(serializers.Serializer):"""Query parameters for listing tasks"""origin_product = serializers.CharField(required=False, help_text="Filter by origin product")+ client_provenance = serializers.ChoiceField(+ required=False,+ choices=tasks_facade.TaskClientProvenance.choices,+ help_text="Filter by the client that created the task",+ )exclude_origin_product = serializers.ChoiceField(required=False,choices=tasks_facade.TaskOriginProduct.choices,diff --git a/products/tasks/backend/tests/test_filter_matrix.py b/products/tasks/backend/tests/test_filter_matrix.pyindex 50f9fa20cfda..2e2350443efc 100644--- a/products/tasks/backend/tests/test_filter_matrix.py+++ b/products/tasks/backend/tests/test_filter_matrix.py@@ -207,6 +207,20 @@ class TestTaskListFilterMatrix(TestCase):assert self._list(origin_product="signals_scout") == self._ids("scout_in_channel")assert self._list(origin_product="slack") == self._ids("peter_slack_mention_me")+ def test_client_provenance(self) -> None:+ desktop_task = self.tasks["peter_plain"]+ desktop_task.client_provenance = "posthog_desktop"+ desktop_task.save(update_fields=["client_provenance"])++ assert self._list(client_provenance="posthog_desktop") == self._ids("peter_plain")+ assert self._list(client_provenance="posthog_desktop", created_by=self.me.id) == set()+ assert self._list(client_provenance="posthog_desktop", search="billing") == self._ids("peter_plain")+ assert self._list(client_provenance="posthog_desktop", search="missing") == set()++ def test_client_provenance_rejects_unknown_values(self) -> None:+ response = self.client.get("/api/projects/@current/tasks/", {"client_provenance": "unknown"})+ assert response.status_code == http_status.HTTP_400_BAD_REQUEST+def test_exclude_origin_product(self):assert self._list(exclude_origin_product="signals_scout") == self.all_except("scout_in_channel")assert self._list(created_by=self.peter.id, exclude_origin_product="slack") == self._ids(diff --git a/products/tasks/frontend/generated/api.schemas.ts b/products/tasks/frontend/generated/api.schemas.tsindex b76a4f74538b..083472dd753c 100644--- a/products/tasks/frontend/generated/api.schemas.ts+++ b/products/tasks/frontend/generated/api.schemas.ts@@ -5256,6 +5256,13 @@ export type TasksListParams = {* @minLength 1*/ci_status?: TasksListCiStatus+ /**+ * Filter by the client that created the task+ *+ * * `posthog_desktop` - PostHog Desktop+ * @minLength 1+ */+ client_provenance?: TasksListClientProvenance/*** Filter to tasks carrying a thread comment written by this user ID.*/@@ -5396,6 +5403,12 @@ export const TasksListCiStatus = {None: 'none',} as const+export type TasksListClientProvenance = (typeof TasksListClientProvenance)[keyof typeof TasksListClientProvenance]++export const TasksListClientProvenance = {+ PosthogDesktop: 'posthog_desktop',+} as const+export type TasksListExcludeOriginProduct =(typeof TasksListExcludeOriginProduct)[keyof typeof TasksListExcludeOriginProduct]diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex a27962ac193e..ed288eb13eed 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -105815,6 +105815,13 @@ export namespace Schemas {* @minLength 1*/ci_status?: TasksListCiStatus;+ /**+ * Filter by the client that created the task+ *+ * * `posthog_desktop` - PostHog Desktop+ * @minLength 1+ */+ client_provenance?: TasksListClientProvenance;/*** Filter to tasks carrying a thread comment written by this user ID.*/@@ -105957,6 +105964,13 @@ export namespace Schemas {None: 'none',} as const;+ export type TasksListClientProvenance = typeof TasksListClientProvenance[keyof typeof TasksListClientProvenance];+++ export const TasksListClientProvenance = {+ PosthogDesktop: 'posthog_desktop',+ } as const;+export type TasksListExcludeOriginProduct = typeof TasksListExcludeOriginProduct[keyof typeof TasksListExcludeOriginProduct];diff --git a/services/mcp/src/generated/tasks/api.ts b/services/mcp/src/generated/tasks/api.tsindex f7cc9f3d13de..0dc5fa62285a 100644--- a/services/mcp/src/generated/tasks/api.ts+++ b/services/mcp/src/generated/tasks/api.ts@@ -899,6 +899,10 @@ export const TasksListQueryParams = () => zod.object({.describe("Filter tasks by the CI check rollup on their most recent run's pull request, as last observed from GitHub. 'none' means the PR has no checks.\n\n\* `passing` - passing\n\* `failing` - failing\n\* `pending` - pending\n\* `none` - none"),+ client_provenance: zod+ .enum(['posthog_desktop'])+ .optional()+ .describe('Filter by the client that created the task\n\n\* `posthog_desktop` - PostHog Desktop'),commented_by: zod.number().optional()diff --git a/services/mcp/src/tools/generated/tasks.ts b/services/mcp/src/tools/generated/tasks.tsindex 359008d69e9c..6c2e99b39b44 100644--- a/services/mcp/src/tools/generated/tasks.ts+++ b/services/mcp/src/tools/generated/tasks.ts@@ -675,6 +675,7 @@ const tasksList = (): ToolBase<basic: params.basic,channel: params.channel,ci_status: params.ci_status,+ client_provenance: params.client_provenance,commented_by: params.commented_by,created_by: params.created_by,exclude_origin_product: params.exclude_origin_product,diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-list.jsonindex 2b8c6b6de61f..435a4f523548 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-list.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-list.json@@ -25,6 +25,11 @@"enum": ["passing", "failing", "pending", "none"],"type": "string"},+ "client_provenance": {+ "description": "Filter by the client that created the task\n\n* `posthog_desktop` - PostHog Desktop",+ "enum": ["posthog_desktop"],+ "type": "string"+ },"commented_by": {"description": "Filter to tasks carrying a thread comment written by this user ID.","type": "number"