: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(tasks): add description_preview to the basic task list (#97999)
Paul D'Ambrad57e9844d503
diff --git a/products/tasks/backend/presentation/serializers.py b/products/tasks/backend/presentation/serializers.pyindex a5da5398ed33..7758e2524ff2 100644--- a/products/tasks/backend/presentation/serializers.py+++ b/products/tasks/backend/presentation/serializers.py@@ -608,18 +608,42 @@ class TaskSerializer(DataclassSerializer):]+TASK_DESCRIPTION_PREVIEW_LENGTH = 1000+TASK_DESCRIPTION_PREVIEW_HELP_TEXT = (+ f"First {TASK_DESCRIPTION_PREVIEW_LENGTH} characters of the description, so a summary "+ "surface can show a prompt snippet without the full body. Open the task for the complete text."+)+++@extend_schema_serializer(component_name="TaskBasic")class TaskBasicSerializer(TaskSerializer):"""Basic list response for a task, returned when the list is asked for ``basic=true``.A surface that renders only a summary of each task asks for the basic payload and gets this- smaller shape. It currently drops ``description``, which dominates the list payload; more- heavy fields may follow. The default list response keeps every field, and ``retrieve``- always returns the description. A client uses the ``search`` query parameter to match- description text server-side.+ smaller shape. It drops the full ``description`` body, which dominates the list payload, and+ replaces it with ``description_preview`` (the first characters) so a feed can still show a+ prompt snippet. The default list response keeps the full ``description``, and ``retrieve``+ always returns it. A client uses the ``search`` query parameter to match description text+ server-side."""+ description_preview = serializers.SerializerMethodField(+ help_text=TASK_DESCRIPTION_PREVIEW_HELP_TEXT,+ )+class Meta(TaskSerializer.Meta):- fields = [field for field in TaskSerializer.Meta.fields if field != "description"]+ fields = [field for field in TaskSerializer.Meta.fields if field != "description"] + ["description_preview"]++ @extend_schema_field(serializers.CharField(help_text=TASK_DESCRIPTION_PREVIEW_HELP_TEXT))+ def get_description_preview(self, obj: TaskDetailDTO) -> str:+ return (obj.description or "")[:TASK_DESCRIPTION_PREVIEW_LENGTH]+++TaskListItemSerializer = PolymorphicProxySerializer(+ component_name="TaskListItem",+ serializers=[TaskSerializer, TaskBasicSerializer],+ resource_type_field_name=None,+)class TaskWriteSerializer(serializers.Serializer):@@ -2029,9 +2053,9 @@ class TaskListQuerySerializer(serializers.Serializer):required=False,default=False,help_text=(- "Return a basic payload with heavy fields dropped, for surfaces that render only a summary "- "of each task. Defaults to false. Currently this omits the description body, which dominates "- "the list payload; the search parameter still matches description text server-side."+ "With true, return basic list rows for summary surfaces: each row omits the full description "+ "and includes description_preview, its first 1000 characters. Defaults to false, which returns "+ "full task rows with description. The search parameter still matches description text server-side."),)search = serializers.CharField(diff --git a/products/tasks/backend/presentation/views/api.py b/products/tasks/backend/presentation/views/api.pyindex 48ba367388c6..847f9595072f 100644--- a/products/tasks/backend/presentation/views/api.py+++ b/products/tasks/backend/presentation/views/api.py@@ -133,6 +133,7 @@ from products.tasks.backend.presentation.serializers import (TaskCommentsResponseSerializer,TaskCreateSerializer,TaskHandoffRequestSerializer,+ TaskListItemSerializer,TaskListQuerySerializer,TaskPinRequestSerializer,TaskPinResponseSerializer,@@ -461,10 +462,13 @@ class TaskViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):@validated_request(query_serializer=TaskListQuerySerializer,responses={- 200: OpenApiResponse(response=TaskSerializer, description="List of tasks"),+ 200: OpenApiResponse(+ response=TaskListItemSerializer,+ description="List of full task rows by default, or basic rows with description_preview when basic=true.",+ ),},summary="List tasks",- description="Get a list of tasks for the current project, with optional filtering by origin product, stage, organization, repository, created_by, and the workflow (hog_flow_id) that created the task. Pass basic=true for a summary payload that drops the description body from each row; use the search parameter to match description text server-side.",+ description="Get a list of tasks for the current project, with optional filtering by origin product, stage, organization, repository, created_by, and the workflow (hog_flow_id) that created the task. By default, each row includes description. Pass basic=true for a summary row that omits description and includes description_preview, its first 1000 characters. Use the search parameter to match description text server-side.",)def list(self, request, *args, **kwargs):filters = {key: request.query_params.get(key) for key in request.query_params}diff --git a/products/tasks/backend/tests/test_api.py b/products/tasks/backend/tests/test_api.pyindex 144d40f8f21c..fcd8f5cd7eff 100644--- a/products/tasks/backend/tests/test_api.py+++ b/products/tasks/backend/tests/test_api.py@@ -239,12 +239,13 @@ class BaseTaskAPITest(TestCase):title: str = "Test Task",created_by: User | None = None,runtime: Task.Runtime = Task.Runtime.ACP,+ description: str = "Test Description",) -> Task:return Task.objects.create(team=self.team,created_by=created_by or self.user,title=title,- description="Test Description",+ description=description,origin_product=Task.OriginProduct.USER_CREATED,runtime=runtime,)@@ -1235,8 +1236,20 @@ class TestTaskAPI(BaseTaskAPITest):row = response.json()["results"][0]if expect_description:self.assertEqual(row["description"], "Test Description")+ self.assertNotIn("description_preview", row)else:self.assertNotIn("description", row)+ self.assertEqual(row["description_preview"], "Test Description")++ def test_basic_description_preview_is_truncated(self):+ self.create_task("Long", description="x" * 1500)++ response = self.client.get("/api/projects/@current/tasks/?basic=true")+ self.assertEqual(response.status_code, status.HTTP_200_OK)++ row = response.json()["results"][0]+ self.assertNotIn("description", row)+ self.assertEqual(row["description_preview"], "x" * 1000)def test_list_tasks_includes_latest_run(self):task1 = self.create_task("Task 1")diff --git a/products/tasks/frontend/generated/api.schemas.ts b/products/tasks/frontend/generated/api.schemas.tsindex 63704163d9be..b76a4f74538b 100644--- a/products/tasks/frontend/generated/api.schemas.ts+++ b/products/tasks/frontend/generated/api.schemas.ts@@ -1779,13 +1779,81 @@ export interface TaskDetailDTOApi {origin_key?: string | null}-export interface PaginatedTaskDetailDTOListApi {+/**+ * @nullable+ */+export type TaskBasicApiJsonSchema = { [key: string]: unknown } | null++/**+ * Basic list response for a task, returned when the list is asked for ``basic=true``.+ *+ * A surface that renders only a summary of each task asks for the basic payload and gets this+ * smaller shape. It drops the full ``description`` body, which dominates the list payload, and+ * replaces it with ``description_preview`` (the first characters) so a feed can still show a+ * prompt snippet. The default list response keeps the full ``description``, and ``retrieve``+ * always returns it. A client uses the ``search`` query parameter to match description text+ * server-side.+ */+export interface TaskBasicApi {+ id: string+ /** @nullable */+ task_number: number | null+ slug: string+ title: string+ title_manually_set: boolean+ origin_product: string+ /** Agent protocol and harness used for this task's runs.+ *+ * * `acp` - ACP+ * * `pi` - Pi */+ runtime: TaskRuntimeEnumApi+ /** @nullable */+ repository: string | null+ repositories: string[]+ /** @nullable */+ github_integration: number | null+ /** @nullable */+ github_user_integration: string | null+ /** @nullable */+ signal_report: string | null+ /** @nullable */+ json_schema: TaskBasicApiJsonSchema+ internal: boolean+ archived: boolean+ /** @nullable */+ archived_at: string | null+ /** Latest run details for this task */+ latest_run?: TaskRunDetailDTOApi | null+ /** @nullable */+ created_at?: string | null+ /** @nullable */+ updated_at?: string | null+ /** @nullable */+ last_activity_at?: string | null+ created_by?: TaskUserBasicInfoApi | null+ /** @nullable */+ ci_prompt: string | null+ /** @nullable */+ channel?: string | null+ readonly slack_thread_references: readonly SlackThreadReferenceDTOApi[]+ /**+ * Stable key of the server-side flow that created this task, e.g. `desktop_onboarding_session:<user_id>`. Null for tasks people create themselves.+ * @nullable+ */+ origin_key?: string | null+ /** First 1000 characters of the description, so a summary surface can show a prompt snippet without the full body. Open the task for the complete text. */+ readonly description_preview: string+}++export type TaskListItemApi = TaskDetailDTOApi | TaskBasicApi++export interface PaginatedTaskListItemListApi {count: number/** @nullable */next?: string | null/** @nullable */previous?: string | null- results: TaskDetailDTOApi[]+ results: TaskListItemApi[]}/**@@ -5171,7 +5239,7 @@ export type TasksListParams = {*/archived?: TasksListArchived/**- * Return a basic payload with heavy fields dropped, for surfaces that render only a summary of each task. Defaults to false. Currently this omits the description body, which dominates the list payload; the search parameter still matches description text server-side.+ * With true, return basic list rows for summary surfaces: each row omits the full description and includes description_preview, its first 1000 characters. Defaults to false, which returns full task rows with description. The search parameter still matches description text server-side.*/basic?: boolean/**diff --git a/products/tasks/frontend/generated/api.ts b/products/tasks/frontend/generated/api.tsindex 1f1388e8638c..7e8b4f7b421a 100644--- a/products/tasks/frontend/generated/api.ts+++ b/products/tasks/frontend/generated/api.ts@@ -44,7 +44,7 @@ import type {PaginatedLoopDTOListApi,PaginatedSandboxCustomImageDTOListApi,PaginatedSandboxEnvironmentDTOListApi,- PaginatedTaskDetailDTOListApi,+ PaginatedTaskListItemListApi,PaginatedTaskMentionDTOListApi,PaginatedTaskRunDetailDTOListApi,PaginatedTaskSummaryDTOListApi,@@ -1279,15 +1279,15 @@ export const getTasksListUrl = (projectId: string, params?: TasksListParams) =>}/**- * Get a list of tasks for the current project, with optional filtering by origin product, stage, organization, repository, created_by, and the workflow (hog_flow_id) that created the task. Pass basic=true for a summary payload that drops the description body from each row; use the search parameter to match description text server-side.+ * Get a list of tasks for the current project, with optional filtering by origin product, stage, organization, repository, created_by, and the workflow (hog_flow_id) that created the task. By default, each row includes description. Pass basic=true for a summary row that omits description and includes description_preview, its first 1000 characters. Use the search parameter to match description text server-side.* @summary List tasks*/export const tasksList = async (projectId: string,params?: TasksListParams,options?: RequestInit-): Promise<PaginatedTaskDetailDTOListApi> => {- return apiMutator<PaginatedTaskDetailDTOListApi>(getTasksListUrl(projectId, params), {+): Promise<PaginatedTaskListItemListApi> => {+ return apiMutator<PaginatedTaskListItemListApi>(getTasksListUrl(projectId, params), {...options,method: 'GET',})diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 9e5f235a7d96..c9ba441347d4 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -60219,13 +60219,81 @@ export namespace Schemas {origin_key?: string | null;}- export interface PaginatedTaskDetailDTOList {+ /**+ * @nullable+ */+ export type TaskBasicJsonSchema = { [key: string]: unknown } | null;++ /**+ * Basic list response for a task, returned when the list is asked for ``basic=true``.+ *+ * A surface that renders only a summary of each task asks for the basic payload and gets this+ * smaller shape. It drops the full ``description`` body, which dominates the list payload, and+ * replaces it with ``description_preview`` (the first characters) so a feed can still show a+ * prompt snippet. The default list response keeps the full ``description``, and ``retrieve``+ * always returns it. A client uses the ``search`` query parameter to match description text+ * server-side.+ */+ export interface TaskBasic {+ id: string;+ /** @nullable */+ task_number: number | null;+ slug: string;+ title: string;+ title_manually_set: boolean;+ origin_product: string;+ /** Agent protocol and harness used for this task's runs.+ *+ * * `acp` - ACP+ * * `pi` - Pi */+ runtime: TaskRuntimeEnum;+ /** @nullable */+ repository: string | null;+ repositories: string[];+ /** @nullable */+ github_integration: number | null;+ /** @nullable */+ github_user_integration: string | null;+ /** @nullable */+ signal_report: string | null;+ /** @nullable */+ json_schema: TaskBasicJsonSchema;+ internal: boolean;+ archived: boolean;+ /** @nullable */+ archived_at: string | null;+ /** Latest run details for this task */+ latest_run?: TaskRunDetailDTO | null;+ /** @nullable */+ created_at?: string | null;+ /** @nullable */+ updated_at?: string | null;+ /** @nullable */+ last_activity_at?: string | null;+ created_by?: TaskUserBasicInfo | null;+ /** @nullable */+ ci_prompt: string | null;+ /** @nullable */+ channel?: string | null;+ readonly slack_thread_references: readonly SlackThreadReferenceDTO[];+ /**+ * Stable key of the server-side flow that created this task, e.g. `desktop_onboarding_session:<user_id>`. Null for tasks people create themselves.+ * @nullable+ */+ origin_key?: string | null;+ /** First 1000 characters of the description, so a summary surface can show a prompt snippet without the full body. Open the task for the complete text. */+ readonly description_preview: string;+ }++ export type TaskListItem = TaskDetailDTO | TaskBasic;++ export interface PaginatedTaskListItemList {count: number;/** @nullable */next?: string | null;/** @nullable */previous?: string | null;- results: TaskDetailDTO[];+ results: TaskListItem[];}/**@@ -102313,7 +102381,7 @@ export namespace Schemas {*/archived?: TasksListArchived;/**- * Return a basic payload with heavy fields dropped, for surfaces that render only a summary of each task. Defaults to false. Currently this omits the description body, which dominates the list payload; the search parameter still matches description text server-side.+ * With true, return basic list rows for summary surfaces: each row omits the full description and includes description_preview, its first 1000 characters. Defaults to false, which returns full task rows with description. The search parameter still matches description text server-side.*/basic?: boolean;/**diff --git a/services/mcp/src/generated/tasks/api.ts b/services/mcp/src/generated/tasks/api.tsindex 2a0068f6768a..f7cc9f3d13de 100644--- a/services/mcp/src/generated/tasks/api.ts+++ b/services/mcp/src/generated/tasks/api.ts@@ -854,7 +854,7 @@ export const TaskChannelsInstructionsUpdateBody = () => zod.describe('Request body for publishing a new instructions version.')/**- * Get a list of tasks for the current project, with optional filtering by origin product, stage, organization, repository, created_by, and the workflow (hog_flow_id) that created the task. Pass basic=true for a summary payload that drops the description body from each row; use the search parameter to match description text server-side.+ * Get a list of tasks for the current project, with optional filtering by origin product, stage, organization, repository, created_by, and the workflow (hog_flow_id) that created the task. By default, each row includes description. Pass basic=true for a summary row that omits description and includes description_preview, its first 1000 characters. Use the search parameter to match description text server-side.* @summary List tasks*/export const TasksListParams = () => zod.object({@@ -890,7 +890,7 @@ export const TasksListQueryParams = () => zod.object({.boolean().default(tasksListQueryBasicDefault).describe(- 'Return a basic payload with heavy fields dropped, for surfaces that render only a summary of each task. Defaults to false. Currently this omits the description body, which dominates the list payload; the search parameter still matches description text server-side.'+ 'With true, return basic list rows for summary surfaces: each row omits the full description and includes description_preview, its first 1000 characters. Defaults to false, which returns full task rows with description. The search parameter still matches description text server-side.'),channel: zod.string().optional().describe("Filter tasks to a channel's feed."),ci_status: zoddiff --git a/services/mcp/src/tools/generated/tasks.ts b/services/mcp/src/tools/generated/tasks.tsindex 4a85cb865c08..359008d69e9c 100644--- a/services/mcp/src/tools/generated/tasks.ts+++ b/services/mcp/src/tools/generated/tasks.ts@@ -660,13 +660,13 @@ const TasksListSchema = () => {const tasksList = (): ToolBase<ReturnType<typeof TasksListSchema>,- WithPostHogUrl<Schemas.PaginatedTaskDetailDTOList>+ WithPostHogUrl<Schemas.PaginatedTaskListItemList>> => ({name: 'tasks-list',schema: TasksListSchema(),handler: async (context: Context, params: z.infer<ReturnType<typeof TasksListSchema>>) => {const projectId = await context.stateManager.getProjectId()- const result = await context.api.request<Schemas.PaginatedTaskDetailDTOList>({+ const result = await context.api.request<Schemas.PaginatedTaskListItemList>({method: 'GET',path: `/api/projects/${encodeURIComponent(String(projectId))}/tasks/`,query: {diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-list.jsonindex d96d7b65d754..2b8c6b6de61f 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-list.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-list.json@@ -13,7 +13,7 @@},"basic": {"default": false,- "description": "Return a basic payload with heavy fields dropped, for surfaces that render only a summary of each task. Defaults to false. Currently this omits the description body, which dominates the list payload; the search parameter still matches description text server-side.",+ "description": "With true, return basic list rows for summary surfaces: each row omits the full description and includes description_preview, its first 1000 characters. Defaults to false, which returns full task rows with description. The search parameter still matches description text server-side.","type": "boolean"},"channel": {