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(conversations): add dynamic "me" assignee filter (#73542)

Luke Belton8e64b74c5516
diff --git a/products/conversations/backend/api/tests/test_tickets.py b/products/conversations/backend/api/tests/test_tickets.py
index 0dea1b06c3ee..eb256740e0e8 100644
--- a/products/conversations/backend/api/tests/test_tickets.py
+++ b/products/conversations/backend/api/tests/test_tickets.py
@@ -1076,6 +1076,41 @@ class TestTicketAssignment(APIBaseTest):
returned_ids = {result["id"] for result in response.json()["results"]}
self.assertEqual(returned_ids, {str(tickets[key].id) for key in expected_keys})
+ def test_filter_by_me_resolves_to_requesting_user(self):
+ """The dynamic `me` token filters to whoever is making the request."""
+ TicketAssignment.objects.create(ticket=self.ticket, user=self.user)
+
+ other_user = User.objects.create_and_join(self.organization, "[email protected]", None)
+ other_ticket = Ticket.objects.create_with_number(
+ team=self.team,
+ channel_source=Channel.WIDGET,
+ widget_session_id="other-session",
+ distinct_id="other-user",
+ )
+ TicketAssignment.objects.create(ticket=other_ticket, user=other_user)
+
+ response = self.client.get(f"/api/projects/{self.team.id}/conversations/tickets/?assignee=me")
+
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ self.assertEqual(response.json()["count"], 1)
+ self.assertEqual(response.json()["results"][0]["id"], str(self.ticket.id))
+
+ def test_filter_by_me_combined_with_unassigned(self):
+ """`me` composes with other assignee entries in a match-any list."""
+ TicketAssignment.objects.create(ticket=self.ticket, user=self.user)
+ unassigned_ticket = Ticket.objects.create_with_number(
+ team=self.team,
+ channel_source=Channel.WIDGET,
+ widget_session_id="unassigned-session",
+ distinct_id="unassigned-user",
+ )
+
+ response = self.client.get(f"/api/projects/{self.team.id}/conversations/tickets/?assignee=me,unassigned")
+
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ returned_ids = {result["id"] for result in response.json()["results"]}
+ self.assertEqual(returned_ids, {str(self.ticket.id), str(unassigned_ticket.id)})
+
def test_assignment_logs_activity(self):
"""Test that assignment changes are logged in activity log."""
response = self.client.patch(
diff --git a/products/conversations/backend/api/tickets.py b/products/conversations/backend/api/tickets.py
index 47c9ab026c67..9271f2c46b7a 100644
--- a/products/conversations/backend/api/tickets.py
+++ b/products/conversations/backend/api/tickets.py
@@ -408,6 +408,11 @@ class TicketViewSet(TaggedItemViewSetMixin, TeamAndOrgViewSetMixin, viewsets.Mod
entry = raw_entry.strip()
if entry.lower() == "unassigned":
include_unassigned = True
+ elif entry.lower() == "me":
+ # Dynamic per-viewer token: resolve to the requesting user so a
+ # shared saved view scoped to "me" means each viewer's own tickets.
+ if self.request.user and self.request.user.is_authenticated:
+ user_ids.append(self.request.user.id)
elif entry.startswith("user:"):
try:
user_ids.append(int(entry[5:]))
@@ -708,7 +713,8 @@ class TicketViewSet(TaggedItemViewSetMixin, TeamAndOrgViewSetMixin, viewsets.Mod
description=(
"Filter by assignee. Accepts a single value or a comma-separated list "
"(matches any, max 100 entries). Each entry is `unassigned` (no assignee), "
- "`user:<user_id>`, or `role:<role_uuid>`, e.g. `assignee=unassigned,user:123`."
+ "`me` (the requesting user), `user:<user_id>`, or `role:<role_uuid>`, "
+ "e.g. `assignee=unassigned,user:123`."
),
),
OpenApiParameter(
diff --git a/products/conversations/frontend/components/Assignee/AssigneeMultiSelect.tsx b/products/conversations/frontend/components/Assignee/AssigneeMultiSelect.tsx
index fa6c0f688235..71b312cc6767 100644
--- a/products/conversations/frontend/components/Assignee/AssigneeMultiSelect.tsx
+++ b/products/conversations/frontend/components/Assignee/AssigneeMultiSelect.tsx
@@ -1,7 +1,7 @@
import { useActions, useValues } from 'kea'
import { useEffect, useState } from 'react'
-import { IconPlusSmall } from '@posthog/icons'
+import { IconPerson, IconPlusSmall } from '@posthog/icons'
import { LemonButton, LemonCheckbox, LemonDropdown, LemonInput } from '@posthog/lemon-ui'
import { urls } from 'scenes/urls'
@@ -12,7 +12,8 @@ import { assigneeSelectLogic } from './assigneeSelectLogic'
import { Assignee, AssigneeFilterEntry, MAX_ASSIGNEE_FILTER_ENTRIES } from './types'
function isSameEntry(a: AssigneeFilterEntry, b: AssigneeFilterEntry): boolean {
- if (a === 'unassigned' || b === 'unassigned') {
+ // String tokens ('unassigned', 'me') only match the identical token.
+ if (typeof a === 'string' || typeof b === 'string') {
return a === b
}
return a.type === b.type && String(a.id) === String(b.id)
@@ -25,7 +26,7 @@ export function AssigneeMultiSelect({
value: AssigneeFilterEntry[]
onChange: (value: AssigneeFilterEntry[]) => void
}): JSX.Element {
- const { search, filteredRoles, otherFilteredMembers, currentUserMember, rolesLoading, membersLoading } =
+ const { search, filteredRoles, filteredMembers, currentUserMember, rolesLoading, membersLoading } =
useValues(assigneeSelectLogic)
const { setSearch, ensureAssigneeTypesLoaded } = useActions(assigneeSelectLogic)
const [showPopover, setShowPopover] = useState(false)
@@ -65,6 +66,26 @@ export function AssigneeMultiSelect({
fullWidth
/>
<ul className="deprecated-space-y-2">
+ {currentUserMember && (
+ <li>
+ {/* Dynamic "me" entry — resolves to whoever is signed in, so a
+ saved view scoped to it stays each viewer's own tickets. */}
+ <LemonButton
+ fullWidth
+ role="menuitem"
+ size="small"
+ icon={<LemonCheckbox checked={isSelected('me')} className="pointer-events-none" />}
+ disabledReason={isSelected('me') ? undefined : selectionCapReason}
+ onClick={() => toggleEntry('me')}
+ >
+ <span className="flex items-center gap-1">
+ <MeIcon />
+ Me
+ <span className="text-secondary">(current user)</span>
+ </span>
+ </LemonButton>
+ </li>
+ )}
<li>
<LemonButton
fullWidth
@@ -82,21 +103,6 @@ export function AssigneeMultiSelect({
</span>
</LemonButton>
</li>
- {currentUserMember && (
- <li>
- <AssigneeFilterItem
- item={{
- id: currentUserMember.user.id,
- type: 'user',
- user: currentUserMember.user,
- }}
- isSelected={isSelected}
- onToggle={toggleEntry}
- selectionCapReason={selectionCapReason}
- labelSuffix={<span className="text-secondary">(you)</span>}
- />
- </li>
- )}
<Section
title="Roles"
loading={rolesLoading}
@@ -116,12 +122,15 @@ export function AssigneeMultiSelect({
</LemonButton>
}
/>
- {(!!search || membersLoading || otherFilteredMembers.length > 0) && (
+ {(!!search || membersLoading || filteredMembers.length > 0) && (
<Section
title="Users"
loading={membersLoading}
search={!!search}
- items={otherFilteredMembers.map((member) => ({
+ // Include the current user here too (as their concrete
+ // user:<id>), so they can filter to their own UUID
+ // specifically — distinct from the dynamic "Me" row above.
+ items={filteredMembers.map((member) => ({
id: member.user.id,
type: 'user' as const,
user: member.user,
@@ -163,6 +172,14 @@ function TriggerLabel({ value }: { value: AssigneeFilterEntry[] }): JSX.Element
</span>
)
}
+ if (entry === 'me') {
+ return (
+ <span className="flex items-center gap-1">
+ <MeIcon />
+ Me
+ </span>
+ )
+ }
return (
<AssigneeResolver assignee={entry}>
{({ assignee }) => (
@@ -175,6 +192,12 @@ function TriggerLabel({ value }: { value: AssigneeFilterEntry[] }): JSX.Element
)
}
+// Solid person glyph for the dynamic "me" entry — distinct from the dashed
+// "unassigned" icon and from any specific member's avatar.
+function MeIcon(): JSX.Element {
+ return <IconPerson className="rounded-full bg-accent-highlight text-accent p-0.5 h-4 w-4" />
+}
+
const AssigneeFilterItem = ({
item,
isSelected,
diff --git a/products/conversations/frontend/components/Assignee/types.ts b/products/conversations/frontend/components/Assignee/types.ts
index 37b8a2052855..7ec1dfc6b921 100644
--- a/products/conversations/frontend/components/Assignee/types.ts
+++ b/products/conversations/frontend/components/Assignee/types.ts
@@ -5,7 +5,13 @@ export type TicketAssignee = {
id: string | number
} | null
-export type AssigneeFilterEntry = 'unassigned' | NonNullable<TicketAssignee>
+// `'me'` is a dynamic, per-viewer token: it filters to whoever is currently
+// signed in, resolved server-side against `request.user`. Unlike a concrete
+// `{ type: 'user', id }` entry it stays correct when a saved view is shared, so
+// a "My tickets" view means each teammate's own tickets rather than the
+// creator's. It's a filter-only concept — a ticket's actual assignee is always
+// a concrete user/role, never `'me'`.
+export type AssigneeFilterEntry = 'unassigned' | 'me' | NonNullable<TicketAssignee>
/** Mirrors the entry cap the tickets list endpoint applies to the `assignee` param. */
export const MAX_ASSIGNEE_FILTER_ENTRIES = 100
diff --git a/products/conversations/frontend/components/SavedViews/SavedViewsModal.tsx b/products/conversations/frontend/components/SavedViews/SavedViewsModal.tsx
index 7d32d7539821..148636fcbfd6 100644
--- a/products/conversations/frontend/components/SavedViews/SavedViewsModal.tsx
+++ b/products/conversations/frontend/components/SavedViews/SavedViewsModal.tsx
@@ -42,10 +42,12 @@ function FiltersSummary({ filters }: { filters: TicketViewFilters }): JSX.Elemen
lines.push({
label: 'Assignee',
value: assigneeEntries.map((entry, index) => (
- <span key={entry === 'unassigned' ? 'unassigned' : `${entry.type}:${entry.id}`}>
+ <span key={typeof entry === 'string' ? entry : `${entry.type}:${entry.id}`}>
{index > 0 ? ', ' : ''}
{entry === 'unassigned' ? (
'Unassigned'
+ ) : entry === 'me' ? (
+ 'Me (current user)'
) : (
<AssigneeResolver assignee={entry}>
{({ assignee }) => (
diff --git a/products/conversations/frontend/generated/api.schemas.ts b/products/conversations/frontend/generated/api.schemas.ts
index 8ee101992670..4efd9152b5c6 100644
--- a/products/conversations/frontend/generated/api.schemas.ts
+++ b/products/conversations/frontend/generated/api.schemas.ts
@@ -1193,7 +1193,7 @@ export type ConversationsListParams = {
export type ConversationsTicketsListParams = {
/**
- * Filter by assignee. Accepts a single value or a comma-separated list (matches any, max 100 entries). Each entry is `unassigned` (no assignee), `user:<user_id>`, or `role:<role_uuid>`, e.g. `assignee=unassigned,user:123`.
+ * Filter by assignee. Accepts a single value or a comma-separated list (matches any, max 100 entries). Each entry is `unassigned` (no assignee), `me` (the requesting user), `user:<user_id>`, or `role:<role_uuid>`, e.g. `assignee=unassigned,user:123`.
*/
assignee?: string
/**
diff --git a/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.test.ts b/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.test.ts
index e9f29ad903e0..22f9bf7227a0 100644
--- a/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.test.ts
+++ b/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.test.ts
@@ -37,6 +37,7 @@ describe('supportTicketsSceneLogic', () => {
it.each([
['legacy "all"', 'all', []],
['legacy "unassigned"', 'unassigned', ['unassigned']],
+ ['dynamic "me"', 'me', ['me']],
['legacy single user', { type: 'user', id: 1 }, [{ type: 'user', id: 1 }]],
['undefined', undefined, []],
['null', null, []],
@@ -94,6 +95,21 @@ describe('supportTicketsSceneLogic', () => {
expect(logic.values.assigneeFilterEntries).toEqual(['unassigned'])
expect(lastAssigneeParam).toBe('unassigned')
})
+
+ it('passes the dynamic "me" token through unchanged so the backend resolves the viewer', async () => {
+ await expectLogic(logic, () => {
+ logic.actions.setAssigneeFilter(['me', { type: 'user', id: 1 }])
+ }).toFinishAllListeners()
+ expect(lastAssigneeParam).toBe('me,user:1')
+
+ // A saved view scoped to "me" round-trips as the portable token, not a
+ // concrete user id — so it stays each viewer's own tickets.
+ await expectLogic(logic, () => {
+ logic.actions.applyViewFilters({ assignee: ['me'] })
+ }).toFinishAllListeners()
+ expect(logic.values.assigneeFilterEntries).toEqual(['me'])
+ expect(lastAssigneeParam).toBe('me')
+ })
})
describe('URL sync', () => {
diff --git a/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.ts b/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.ts
index 898bebc8b3dc..a0525bb9c7c8 100644
--- a/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.ts
+++ b/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.ts
@@ -74,7 +74,8 @@ function orderByToSorting(orderBy: string): Sorting {
}
function encodeAssigneeEntry(entry: AssigneeFilterEntry): string {
- return entry === 'unassigned' ? 'unassigned' : `${entry.type}:${entry.id}`
+ // 'unassigned' and 'me' are string tokens; concrete entries encode as type:id.
+ return typeof entry === 'string' ? entry : `${entry.type}:${entry.id}`
}
// kea-router hands back arrays for multi-value params, but a hand-typed single
@@ -91,8 +92,8 @@ function toStringArray(value: unknown): string[] {
function decodeAssignee(value: unknown): AssigneeFilterEntry[] {
const entries = toStringArray(value).map((token): AssigneeFilterEntry | null => {
- if (token === 'unassigned') {
- return 'unassigned'
+ if (token === 'unassigned' || token === 'me') {
+ return token
}
const separator = token.indexOf(':')
const type = token.slice(0, separator)
@@ -696,9 +697,7 @@ export const supportTicketsSceneLogic = kea<supportTicketsSceneLogicType>([
params.sla = values.slaFilter
}
if (values.assigneeFilterEntries.length > 0) {
- params.assignee = values.assigneeFilterEntries
- .map((entry) => (entry === 'unassigned' ? 'unassigned' : `${entry.type}:${entry.id}`))
- .join(',')
+ params.assignee = values.assigneeFilterEntries.map(encodeAssigneeEntry).join(',')
}
if (values.tagsFilter.length > 0) {
params[values.tagsMatch === 'all' ? 'tags_all' : 'tags'] = JSON.stringify(values.tagsFilter)
diff --git a/products/conversations/frontend/types.ts b/products/conversations/frontend/types.ts
index 85e9072c27ef..94d52f4140b6 100644
--- a/products/conversations/frontend/types.ts
+++ b/products/conversations/frontend/types.ts
@@ -28,7 +28,7 @@ export type RestoreFlowState = 'idle' | 'sending' | 'sent' | 'error'
export type AssigneeFilterValue = 'all' | 'unassigned' | TicketAssignee
function isAssigneeFilterEntry(value: unknown): value is AssigneeFilterEntry {
- if (value === 'unassigned') {
+ if (value === 'unassigned' || value === 'me') {
return true
}
if (typeof value !== 'object' || value === null) {
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 2ad70bcfdd1f..fdd9aa2767b1 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -72862,7 +72862,7 @@ export namespace Schemas {
export type ConversationsTicketsListParams = {
/**
- * Filter by assignee. Accepts a single value or a comma-separated list (matches any, max 100 entries). Each entry is `unassigned` (no assignee), `user:<user_id>`, or `role:<role_uuid>`, e.g. `assignee=unassigned,user:123`.
+ * Filter by assignee. Accepts a single value or a comma-separated list (matches any, max 100 entries). Each entry is `unassigned` (no assignee), `me` (the requesting user), `user:<user_id>`, or `role:<role_uuid>`, e.g. `assignee=unassigned,user:123`.
*/
assignee?: string;
/**
diff --git a/services/mcp/src/generated/conversations/api.ts b/services/mcp/src/generated/conversations/api.ts
index 072e6cf9cf49..39fa84069e71 100644
--- a/services/mcp/src/generated/conversations/api.ts
+++ b/services/mcp/src/generated/conversations/api.ts
@@ -24,7 +24,7 @@ export const ConversationsTicketsListQueryParams = /* @__PURE__ */ zod.object({
.string()
.optional()
.describe(
- 'Filter by assignee. Accepts a single value or a comma-separated list (matches any, max 100 entries). Each entry is `unassigned` (no assignee), `user:<user_id>`, or `role:<role_uuid>`, e.g. `assignee=unassigned,user:123`.'
+ 'Filter by assignee. Accepts a single value or a comma-separated list (matches any, max 100 entries). Each entry is `unassigned` (no assignee), `me` (the requesting user), `user:<user_id>`, or `role:<role_uuid>`, e.g. `assignee=unassigned,user:123`.'
),
channel_detail: zod
.enum([
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/conversations-tickets-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/conversations-tickets-list.json
index 17fba8781570..80edfbc4458f 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/conversations-tickets-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/conversations-tickets-list.json
@@ -2,7 +2,7 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"assignee": {
- "description": "Filter by assignee. Accepts a single value or a comma-separated list (matches any, max 100 entries). Each entry is `unassigned` (no assignee), `user:<user_id>`, or `role:<role_uuid>`, e.g. `assignee=unassigned,user:123`.",
+ "description": "Filter by assignee. Accepts a single value or a comma-separated list (matches any, max 100 entries). Each entry is `unassigned` (no assignee), `me` (the requesting user), `user:<user_id>`, or `role:<role_uuid>`, e.g. `assignee=unassigned,user:123`.",
"type": "string"
},
"channel_detail": {