: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): sync Task model to desktop file system via mixin (#62791)
Raquel Smith9517f54e1866
diff --git a/posthog/api/file_system/file_system.py b/posthog/api/file_system/file_system.pyindex 5e83e7e9f5c2..5a2937a77a57 100644--- a/posthog/api/file_system/file_system.py+++ b/posthog/api/file_system/file_system.py@@ -186,7 +186,15 @@ class FileSystemViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):# GET /instructions/ and /instructions/versions/ are reads; PUT/PATCH/DELETE on# /instructions/ resolve to `publish_instructions` / `delete_instructions` via DRF's# method mapping, so they go in the write bucket.- scope_object_read_actions = ["list", "retrieve", "instructions", "instructions_versions"]+ scope_object_read_actions = [+ "list",+ "retrieve",+ "instructions",+ "instructions_versions",+ "unfiled",+ "count",+ "count_by_path",+ ]scope_object_write_actions = ["create","update",@@ -195,6 +203,10 @@ class FileSystemViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):"destroy","publish_instructions","delete_instructions",+ "move",+ "link",+ "log_view",+ "undo_delete",]def _basename_regex(self, value: str) -> str:diff --git a/posthog/models/file_system/unfiled_file_saver.py b/posthog/models/file_system/unfiled_file_saver.pyindex a0fcb376c35a..6f1c0173182f 100644--- a/posthog/models/file_system/unfiled_file_saver.py+++ b/posthog/models/file_system/unfiled_file_saver.py@@ -4,7 +4,7 @@ from typing import Optionalfrom django.utils import timezone-from posthog.models.file_system.constants import DEFAULT_SURFACE+from posthog.models.file_system.constants import DEFAULT_SURFACE, DESKTOP_SURFACEfrom posthog.models.file_system.file_system import FileSystem, escape_path, split_pathfrom posthog.models.file_system.file_system_mixin import FileSystemSyncMixinfrom posthog.models.team import Team@@ -22,6 +22,7 @@ from products.links.backend.models import Linkfrom products.notebooks.backend.models import Notebookfrom products.product_analytics.backend.models.insight import Insightfrom products.surveys.backend.models import Survey+from products.tasks.backend.models import TaskMIXIN_MODELS: dict[str, type[FileSystemSyncMixin]] = {"action": Action,@@ -38,10 +39,15 @@ MIXIN_MODELS: dict[str, type[FileSystemSyncMixin]] = {"survey": Survey,}+DESKTOP_MIXIN_MODELS: dict[str, type[FileSystemSyncMixin]] = {+ "task": Task,+}+# Which models feed each surface's tree. New product surfaces register their own models here so# they are never swept into the default ("web") tree, and vice versa.MIXIN_MODELS_BY_SURFACE: dict[str, dict[str, type[FileSystemSyncMixin]]] = {DEFAULT_SURFACE: MIXIN_MODELS,+ DESKTOP_SURFACE: DESKTOP_MIXIN_MODELS,}diff --git a/products/tasks/backend/api.py b/products/tasks/backend/api.pyindex 4b3b1f0aedaa..c203e0dcb920 100644--- a/products/tasks/backend/api.py+++ b/products/tasks/backend/api.py@@ -35,8 +35,6 @@ from posthog.api.routing import TeamAndOrgViewSetMixinfrom posthog.api.utils import ServerTimingsGatheredfrom posthog.auth import OAuthAccessTokenAuthentication, PersonalAPIKeyAuthenticationfrom posthog.event_usage import groups-from posthog.models.file_system.constants import DESKTOP_SURFACE-from posthog.models.file_system.file_system import FileSystem, create_or_update_file, delete_file, surface_qfrom posthog.models.integration import Integrationfrom posthog.models.user_push_token import UserPushTokenfrom posthog.permissions import APIScopePermission@@ -86,8 +84,6 @@ from .serializers import (SlackThreadContextQuerySerializer,SlackThreadContextResponseSerializer,TaskAutomationSerializer,- TaskFileRequestSerializer,- TaskFileResponseSerializer,TaskListQuerySerializer,TaskPresenceBeaconRequestSerializer,TaskRepositoriesResponseSerializer,@@ -907,56 +903,6 @@ class TaskViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):)return Response(serializer.data)- @validated_request(- request_serializer=TaskFileRequestSerializer,- responses={- 200: OpenApiResponse(- response=TaskFileResponseSerializer, description="Task filed into the desktop project tree"- ),- 404: OpenApiResponse(description="Task not found"),- },- summary="File a task into the project tree",- description=(- "Add this task to the desktop project tree so it can be organized into folders. "- "Optionally pass a destination folder path. Idempotent — re-filing updates the existing entry."- ),- )- @action(detail=True, methods=["post"], url_path="file", required_scopes=["task:write"])- def file(self, request, pk=None, **kwargs):- task = cast(Task, self.get_object())- folder = (request.validated_data.get("folder") or "").strip() or "Tasks"- fs = task.get_file_system_representation(folder=folder)- create_or_update_file(- team=task.team,- base_folder=fs.base_folder,- name=fs.name,- file_type=fs.type,- ref=fs.ref,- href=fs.href,- meta=fs.meta,- created_at=task.created_at,- created_by_id=task.created_by_id,- surface=DESKTOP_SURFACE,- )- entry = (- FileSystem.objects.filter(surface_q(DESKTOP_SURFACE), team=task.team, type="task", ref=str(task.id))- .exclude(shortcut=True)- .first()- )- return Response(TaskFileResponseSerializer(entry).data)-- @extend_schema(- request=None,- responses={204: OpenApiResponse(description="Task removed from the project tree")},- summary="Remove a task from the project tree",- description="Remove this task's entry from the desktop project tree. The task itself is not deleted.",- )- @action(detail=True, methods=["post"], url_path="unfile", required_scopes=["task:write"])- def unfile(self, request, pk=None, **kwargs):- task = cast(Task, self.get_object())- delete_file(team=task.team, file_type="task", ref=str(task.id), surface=DESKTOP_SURFACE)- return Response(status=status.HTTP_204_NO_CONTENT)-def perform_update(self, serializer):task = cast(Task, serializer.instance)logger.info(f"perform_update called for task {task.id} with validated_data: {serializer.validated_data}")diff --git a/products/tasks/backend/models.py b/products/tasks/backend/models.pyindex f03a387b8750..1146351adb85 100644--- a/products/tasks/backend/models.py+++ b/products/tasks/backend/models.py@@ -8,7 +8,7 @@ from collections.abc import Callable, Iterablefrom datetime import datetimefrom typing import TYPE_CHECKING, Any, Literal, Optional-from django.db.models.signals import post_delete, post_save+from django.db.models.signals import post_savefrom django.dispatch import receiverfrom pydantic import BaseModel@@ -28,8 +28,8 @@ import posthoganalyticsfrom posthog.event_usage import groupsfrom posthog.helpers.encrypted_fields import EncryptedJSONStringField-from posthog.models.file_system.constants import DESKTOP_SURFACE-from posthog.models.file_system.file_system import delete_file+from posthog.models.file_system.constants import DEFAULT_SURFACE, DESKTOP_SURFACE+from posthog.models.file_system.file_system_mixin import FileSystemSyncMixinfrom posthog.models.file_system.file_system_representation import FileSystemRepresentationfrom posthog.models.integration import Integrationfrom posthog.models.scoping.root_mixin import TeamScopedRootMixin@@ -55,7 +55,7 @@ def resolve_schema(schema: type[BaseModel] | dict) -> dict:return schema.model_json_schema()-class Task(DeletedMetaFields, models.Model):+class Task(FileSystemSyncMixin, DeletedMetaFields, models.Model):class OriginProduct(models.TextChoices):ERROR_TRACKING = "error_tracking", "Error Tracking"EVAL_CLUSTERS = "eval_clusters", "Eval Clusters"@@ -174,11 +174,20 @@ class Task(DeletedMetaFields, models.Model):if is_new:self._track_task_created()- def get_file_system_representation(self, folder: str = "Tasks") -> FileSystemRepresentation:- # Tasks are filed into the tree only on explicit request; this describes where a filed task- # lives. Tasks live only on the desktop surface, never the web app tree.+ @classmethod+ def get_file_system_unfiled(cls, team: "Team", surface: str = DEFAULT_SURFACE) -> models.QuerySet["Task"]:+ # Tasks live only on the desktop surface, never the web app tree.+ if surface != DESKTOP_SURFACE:+ return cls.objects.none()+ base_qs = cls.objects.filter(team=team, deleted=False)+ return cls._filter_unfiled_queryset(base_qs, team, type="task", ref_field="id", surface=surface)++ def get_file_system_representation(self, folder: str | None = None) -> FileSystemRepresentation:+ # Tasks live only on the desktop surface, never the web app tree. They land in+ # Unfiled/Tasks/<title> on first save (via FileSystemSyncMixin) and stay there+ # unless filed into another folder — e.g. a canvas channel.return FileSystemRepresentation(- base_folder=folder,+ base_folder=folder or self._get_assigned_folder("Unfiled/Tasks"),type="task",ref=str(self.id),name=self.title or "Untitled",@@ -1533,23 +1542,3 @@ def track_task_run_completion(sender, instance: TaskRun, created: bool, **kwargstask_run_id=str(instance.id),error=str(e),)---# Tasks are filed into the project tree only on explicit request (see TaskViewSet.file). These-# receivers never create an entry — they only remove a filed task's entry when the task is deleted,-# so the tree can't surface a dead reference. delete_file is a no-op when no entry exists.-@receiver(post_save, sender=Task)-def _unfile_task_on_soft_delete(sender, instance: Task, **kwargs):- update_fields = kwargs.get("update_fields")- if update_fields is not None and "deleted" not in update_fields:- return- if instance.deleted:- delete_file(team=instance.team, file_type="task", ref=str(instance.id), surface=DESKTOP_SURFACE)---@receiver(post_delete, sender=Task)-def _unfile_task_on_hard_delete(sender, instance: Task, **kwargs):- try:- delete_file(team=instance.team, file_type="task", ref=str(instance.id), surface=DESKTOP_SURFACE)- except Team.DoesNotExist:- passdiff --git a/products/tasks/backend/serializers.py b/products/tasks/backend/serializers.pyindex 31f4dccf8315..60c6330ebe72 100644--- a/products/tasks/backend/serializers.py+++ b/products/tasks/backend/serializers.py@@ -81,22 +81,6 @@ def build_task_run_artifact_size_error(return f"{artifact_name or 'Artifact'} exceeds the {max_mb}MB attachment limit"-class TaskFileRequestSerializer(serializers.Serializer):- folder = serializers.CharField(- required=False,- allow_blank=True,- help_text="Destination folder path in the project tree (e.g. 'Tasks/Bugs'). Defaults to 'Tasks'.",- )---class TaskFileResponseSerializer(serializers.Serializer):- id = serializers.UUIDField(help_text="Identifier of the project-tree entry for this task.")- path = serializers.CharField(help_text="Full slash-separated path of the filed task in the project tree.")- type = serializers.CharField(help_text="File system entry type. Always 'task'.")- ref = serializers.CharField(help_text="Identifier of the task this entry points to.")- href = serializers.CharField(help_text="In-app link to the task.")--class TaskSerializer(serializers.ModelSerializer):repository = serializers.CharField(max_length=255,diff --git a/products/tasks/backend/tests/test_file_system.py b/products/tasks/backend/tests/test_file_system.pyindex 7f6c2ef5cfcd..955f1fcb92cf 100644--- a/products/tasks/backend/tests/test_file_system.py+++ b/products/tasks/backend/tests/test_file_system.py@@ -9,92 +9,109 @@ class TestTaskFileSystem(BaseTaskAPITest):def _task_rows(self, task: Task):return FileSystem.objects.filter(team=self.team, type="task", ref=str(task.id)).exclude(shortcut=True)- def test_creating_a_task_does_not_file_it(self):+ def test_creating_a_task_auto_files_it_in_unfiled(self):task = self.create_task(title="My Task")- self.assertFalse(FileSystem.objects.filter(team=self.team, type="task", ref=str(task.id)).exists())-- def test_file_action_files_task_on_desktop_surface(self):- task = self.create_task(title="My Task")-- response = self.client.post(f"/api/projects/@current/tasks/{task.id}/file/")- self.assertEqual(response.status_code, 200, response.content)-entry = self._task_rows(task).get()- self.assertEqual(entry.path, "Tasks/My Task")- self.assertEqual(entry.href, f"/tasks/{task.id}")+ self.assertEqual(entry.path, "Unfiled/Tasks/My Task")self.assertEqual(entry.surface, DESKTOP_SURFACE)- self.assertEqual(response.json()["path"], "Tasks/My Task")+ self.assertEqual(entry.href, f"/tasks/{task.id}")- # Never leaks into the web app tree.+ def test_task_rows_never_leak_to_web_surface(self):+ task = self.create_task(title="My Task")self.assertFalse(FileSystem.objects.filter(surface_q("web"), team=self.team, type="task", ref=str(task.id)).exists())- def test_file_action_into_custom_folder(self):+ def test_renaming_task_renames_all_filed_rows(self):task = self.create_task(title="My Task")-- response = self.client.post(- f"/api/projects/@current/tasks/{task.id}/file/",- {"folder": "Tasks/Bugs"},- format="json",+ # Simulate filing to a channel by creating a second row directly under a channel folder.+ FileSystem.objects.create(+ team=self.team,+ path="Channels/Engineering/My Task",+ depth=3,+ type="task",+ ref=str(task.id),+ href=f"/tasks/{task.id}",+ meta={},+ shortcut=False,+ surface=DESKTOP_SURFACE,+ created_by=self.user,)- self.assertEqual(response.status_code, 200, response.content)- self.assertEqual(self._task_rows(task).get().path, "Tasks/Bugs/My Task")-- def test_file_action_is_idempotent(self):- task = self.create_task(title="My Task")-- self.client.post(f"/api/projects/@current/tasks/{task.id}/file/")- self.client.post(f"/api/projects/@current/tasks/{task.id}/file/")-- self.assertEqual(self._task_rows(task).count(), 1)-- def test_unfile_action_removes_entry_but_keeps_task(self):- task = self.create_task(title="My Task")- self.client.post(f"/api/projects/@current/tasks/{task.id}/file/")- self.assertEqual(self._task_rows(task).count(), 1)-- response = self.client.post(f"/api/projects/@current/tasks/{task.id}/unfile/")- self.assertEqual(response.status_code, 204, response.content)+ task.title = "Renamed"+ task.save()- self.assertFalse(self._task_rows(task).exists())- task.refresh_from_db()- self.assertFalse(task.deleted)+ paths = sorted(self._task_rows(task).values_list("path", flat=True))+ self.assertEqual(paths, ["Channels/Engineering/Renamed", "Unfiled/Tasks/Renamed"])- def test_soft_deleting_a_filed_task_removes_entry(self):+ def test_soft_delete_removes_all_rows(self):task = self.create_task(title="My Task")- self.client.post(f"/api/projects/@current/tasks/{task.id}/file/")- self.assertEqual(self._task_rows(task).count(), 1)+ FileSystem.objects.create(+ team=self.team,+ path="Channels/Engineering/My Task",+ depth=3,+ type="task",+ ref=str(task.id),+ href=f"/tasks/{task.id}",+ meta={},+ shortcut=False,+ surface=DESKTOP_SURFACE,+ created_by=self.user,+ )+ self.assertEqual(self._task_rows(task).count(), 2)task.deleted = Truetask.save()self.assertFalse(self._task_rows(task).exists())- def test_hard_deleting_a_filed_task_removes_entry(self):+ def test_hard_delete_removes_all_rows(self):task = self.create_task(title="My Task")- self.client.post(f"/api/projects/@current/tasks/{task.id}/file/")task_id = task.id- self.assertEqual(FileSystem.objects.filter(team=self.team, type="task", ref=str(task_id)).count(), 1)+ self.assertEqual(self._task_rows(task).count(), 1)- # Task.delete() is blocked; queryset.delete() bypasses the override and fires post_delete.Task.objects.filter(pk=task_id).delete()self.assertFalse(FileSystem.objects.filter(team=self.team, type="task", ref=str(task_id)).exists())- def test_unfiled_sweep_does_not_file_tasks(self):- self.create_task(title="My Task")+ def test_unfiled_sweep_files_existing_tasks(self):+ # Older tasks created before the home row existed can be backfilled via the unfiled sweep.+ task = self.create_task(title="My Task")+ self._task_rows(task).delete()+ self.assertFalse(self._task_rows(task).exists())response = self.client.get(f"/api/projects/{self.team.id}/desktop_file_system/unfiled/?type=task")self.assertEqual(response.status_code, 200, response.content)- self.assertFalse(FileSystem.objects.filter(team=self.team, type="task").exists())- def test_tree_delete_and_restore(self):+ entry = self._task_rows(task).get()+ self.assertEqual(entry.path, "Unfiled/Tasks/My Task")++ def test_deleting_one_of_many_rows_preserves_task(self):+ task = self.create_task(title="My Task")+ channel_row = FileSystem.objects.create(+ team=self.team,+ path="Channels/Engineering/My Task",+ depth=3,+ type="task",+ ref=str(task.id),+ href=f"/tasks/{task.id}",+ meta={},+ shortcut=False,+ surface=DESKTOP_SURFACE,+ created_by=self.user,+ )++ # Removing one row (e.g. unfiling from a channel) leaves the task and the home row alone.+ response = self.client.delete(f"/api/projects/{self.team.id}/desktop_file_system/{channel_row.id}/")+ self.assertEqual(response.status_code, 204, response.content)+ task.refresh_from_db()+ self.assertFalse(task.deleted)+ self.assertEqual(self._task_rows(task).get().path, "Unfiled/Tasks/My Task")++ def test_deleting_last_row_soft_deletes_task(self):task = self.create_task(title="My Task")- self.client.post(f"/api/projects/@current/tasks/{task.id}/file/")entry = self._task_rows(task).get()- # Deleting the tree entry soft-deletes the task and removes the row.+ # Removing the last remaining row treats the file-system action as a delete of the task itself.delete_response = self.client.delete(f"/api/projects/{self.team.id}/desktop_file_system/{entry.id}/")self.assertEqual(delete_response.status_code, 200, delete_response.content)task.refresh_from_db()@@ -110,18 +127,15 @@ class TestTaskFileSystem(BaseTaskAPITest):self.assertEqual(undo_response.status_code, 200, undo_response.content)task.refresh_from_db()self.assertFalse(task.deleted)- self.assertEqual(self._task_rows(task).get().path, "Tasks/My Task")+ self.assertEqual(self._task_rows(task).get().path, "Unfiled/Tasks/My Task")def test_tree_delete_blocked_for_other_users_task(self):- # A teammate filed a task they own. The current user (admin or not) must not be able to- # delete it via the generic file system endpoint, since that would soft-delete the task.+ # A teammate owns a task. The current user must not be able to delete it via the+ # generic file system endpoint, since the last-row delete would soft-delete the task.other_user = self.create_organization_user("victim")task = self.create_task(title="Their Task", created_by=other_user)- self.client.force_authenticate(other_user)- self.client.post(f"/api/projects/@current/tasks/{task.id}/file/")entry = self._task_rows(task).get()- self.client.force_authenticate(self.user)response = self.client.delete(f"/api/projects/{self.team.id}/desktop_file_system/{entry.id}/")self.assertEqual(response.status_code, 403, response.content)@@ -132,14 +146,11 @@ class TestTaskFileSystem(BaseTaskAPITest):def test_tree_undo_blocked_for_other_users_task(self):other_user = self.create_organization_user("victim")task = self.create_task(title="Their Task", created_by=other_user)- self.client.force_authenticate(other_user)- self.client.post(f"/api/projects/@current/tasks/{task.id}/file/")entry = self._task_rows(task).get()# Soft-delete the task as the owner so undo has something to restore.task.deleted = Truetask.save()- self.client.force_authenticate(self.user)undo_response = self.client.post(f"/api/projects/{self.team.id}/desktop_file_system/undo_delete/",{"items": [{"type": "task", "ref": str(task.id), "path": entry.path}]},diff --git a/products/tasks/frontend/generated/api.schemas.ts b/products/tasks/frontend/generated/api.schemas.tsindex 66fdfe23257b..3a6c8b314331 100644--- a/products/tasks/frontend/generated/api.schemas.ts+++ b/products/tasks/frontend/generated/api.schemas.ts@@ -477,24 +477,6 @@ export interface PatchedTaskApi {ci_prompt?: string | null}-export interface TaskFileRequestApi {- /** Destination folder path in the project tree (e.g. 'Tasks/Bugs'). Defaults to 'Tasks'. */- folder?: string-}--export interface TaskFileResponseApi {- /** Identifier of the project-tree entry for this task. */- id: string- /** Full slash-separated path of the filed task in the project tree. */- path: string- /** File system entry type. Always 'task'. */- type: string- /** Identifier of the task this entry points to. */- ref: string- /** In-app link to the task. */- href: string-}-/*** Request body for the presence beacon and beacon-leave endpoints.*diff --git a/products/tasks/frontend/generated/api.ts b/products/tasks/frontend/generated/api.tsindex fc99f2c1dd59..59a86ed8c480 100644--- a/products/tasks/frontend/generated/api.ts+++ b/products/tasks/frontend/generated/api.ts@@ -28,8 +28,6 @@ import type {TaskApi,TaskAutomationApi,TaskAutomationsListParams,- TaskFileRequestApi,- TaskFileResponseApi,TaskPresenceBeaconRequestApi,TaskRepositoriesResponseApi,TaskRunAppendLogRequestApi,@@ -462,28 +460,6 @@ export const tasksDestroy = async (projectId: string, id: string, options?: Requ})}-export const getTasksFileCreateUrl = (projectId: string, id: string) => {- return `/api/projects/${projectId}/tasks/${id}/file/`-}--/**- * Add this task to the desktop project tree so it can be organized into folders. Optionally pass a destination folder path. Idempotent — re-filing updates the existing entry.- * @summary File a task into the project tree- */-export const tasksFileCreate = async (- projectId: string,- id: string,- taskFileRequestApi?: TaskFileRequestApi,- options?: RequestInit-): Promise<TaskFileResponseApi> => {- return apiMutator<TaskFileResponseApi>(getTasksFileCreateUrl(projectId, id), {- ...options,- method: 'POST',- headers: { 'Content-Type': 'application/json', ...options?.headers },- body: JSON.stringify(taskFileRequestApi),- })-}-export const getTasksPresenceCreateUrl = (projectId: string, id: string) => {return `/api/projects/${projectId}/tasks/${id}/presence/`}@@ -593,21 +569,6 @@ export const tasksStagedArtifactsPrepareUploadCreate = async ()}-export const getTasksUnfileCreateUrl = (projectId: string, id: string) => {- return `/api/projects/${projectId}/tasks/${id}/unfile/`-}--/**- * Remove this task's entry from the desktop project tree. The task itself is not deleted.- * @summary Remove a task from the project tree- */-export const tasksUnfileCreate = async (projectId: string, id: string, options?: RequestInit): Promise<void> => {- return apiMutator<void>(getTasksUnfileCreateUrl(projectId, id), {- ...options,- method: 'POST',- })-}-export const getTasksRunsListUrl = (projectId: string, taskId: string, params?: TasksRunsListParams) => {const normalizedParams = new URLSearchParams()diff --git a/products/tasks/frontend/generated/api.zod.ts b/products/tasks/frontend/generated/api.zod.tsindex 86ee567f04cf..a6eaf83b1674 100644--- a/products/tasks/frontend/generated/api.zod.ts+++ b/products/tasks/frontend/generated/api.zod.ts@@ -384,17 +384,6 @@ export const TasksPartialUpdateBody = /* @__PURE__ */ zod.object({ci_prompt: zod.string().nullish().describe('Custom prompt for CI fixes. If blank, a default prompt will be used.'),})-/**- * Add this task to the desktop project tree so it can be organized into folders. Optionally pass a destination folder path. Idempotent — re-filing updates the existing entry.- * @summary File a task into the project tree- */-export const TasksFileCreateBody = /* @__PURE__ */ zod.object({- folder: zod- .string()- .optional()- .describe("Destination folder path in the project tree (e.g. 'Tasks\/Bugs'). Defaults to 'Tasks'."),-})-/*** Idempotent upsert: marks the calling user + `device_id` as actively watching this task for the next ~60 seconds. While at least one device for the user has a non-expired presence row for this task, the push fanout will skip ALL of that user's other registered devices for task notifications — the contract is 'if any device is demonstrably watching, suppress the others'. Clients call this every ~30s while the task screen is foregrounded. `device_id` is the UUID of the caller's UserPushToken row.* @summary Beacon presence for a device watching this taskdiff --git a/products/tasks/mcp/tools.yaml b/products/tasks/mcp/tools.yamlindex 8763d2ae8afd..7a709c1e7d6a 100644--- a/products/tasks/mcp/tools.yaml+++ b/products/tasks/mcp/tools.yaml@@ -57,20 +57,6 @@ tools:tasks-destroy:operation: tasks_destroyenabled: false- tasks-file-create:- operation: tasks_file_create- enabled: true- scopes:- - task:write- annotations:- readOnly: false- destructive: false- idempotent: true- title: File a task into the project tree- description: >- Add a task to the desktop project tree so it can be organized into folders. Optionally pass a destination- `folder` path (defaults to `Tasks`). Idempotent — re-filing updates the existing entry.- feature_flag: taskstasks-list:operation: tasks_listenabled: true@@ -266,19 +252,6 @@ tools:tasks-summaries-create:operation: tasks_summaries_createenabled: false- tasks-unfile-create:- operation: tasks_unfile_create- enabled: true- scopes:- - task:write- annotations:- readOnly: false- destructive: false- idempotent: true- title: Remove a task from the project tree- description: |- Remove a task's entry from the desktop project tree. The task itself is not deleted.- feature_flag: taskstasks-update:operation: tasks_updateenabled: falsediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 45ae0c4f1c5d..dc965a1a69c2 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -5570,21 +5570,6 @@"readOnlyHint": true}},- "tasks-file-create": {- "description": "Add a task to the desktop project tree so it can be organized into folders. Optionally pass a destination `folder` path (defaults to `Tasks`). Idempotent — re-filing updates the existing entry.",- "category": "Tasks",- "feature": "tasks",- "summary": "File a task into the project tree",- "title": "File a task into the project tree",- "required_scopes": ["task:write"],- "annotations": {- "destructiveHint": false,- "idempotentHint": true,- "openWorldHint": true,- "readOnlyHint": false- },- "feature_flag": "tasks"- },"tasks-list": {"description": "List agent tasks in the current project. Supports filtering by `origin_product`, `stage`, `organization`, `repository`, `created_by`, and `internal`. Returns lightweight task metadata only — call tasks-retrieve for the full task including its latest run, or tasks-runs-list for run history. Requires the calling token's organization to have Tasks access enabled.","category": "Tasks",@@ -5660,21 +5645,6 @@},"feature_flag": "tasks"},- "tasks-unfile-create": {- "description": "Remove a task's entry from the desktop project tree. The task itself is not deleted.",- "category": "Tasks",- "feature": "tasks",- "summary": "Remove a task from the project tree",- "title": "Remove a task from the project tree",- "required_scopes": ["task:write"],- "annotations": {- "destructiveHint": false,- "idempotentHint": true,- "openWorldHint": true,- "readOnlyHint": false- },- "feature_flag": "tasks"- },"update-feature-flag": {"description": "Update a feature flag by ID in the current project.","category": "Feature flags",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 90aac4cedeac..a35791c48897 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -5939,21 +5939,6 @@"readOnlyHint": false}},- "tasks-file-create": {- "description": "Add a task to the desktop project tree so it can be organized into folders. Optionally pass a destination `folder` path (defaults to `Tasks`). Idempotent — re-filing updates the existing entry.",- "category": "Tasks",- "feature": "tasks",- "summary": "File a task into the project tree",- "title": "File a task into the project tree",- "required_scopes": ["task:write"],- "annotations": {- "destructiveHint": false,- "idempotentHint": true,- "openWorldHint": true,- "readOnlyHint": false- },- "feature_flag": "tasks"- },"tasks-list": {"description": "List agent tasks in the current project. Supports filtering by `origin_product`, `stage`, `organization`, `repository`, `created_by`, and `internal`. Returns lightweight task metadata only — call tasks-retrieve for the full task including its latest run, or tasks-runs-list for run history. Requires the calling token's organization to have Tasks access enabled.","category": "Tasks",@@ -6029,21 +6014,6 @@},"feature_flag": "tasks"},- "tasks-unfile-create": {- "description": "Remove a task's entry from the desktop project tree. The task itself is not deleted.",- "category": "Tasks",- "feature": "tasks",- "summary": "Remove a task from the project tree",- "title": "Remove a task from the project tree",- "required_scopes": ["task:write"],- "annotations": {- "destructiveHint": false,- "idempotentHint": true,- "openWorldHint": true,- "readOnlyHint": false- },- "feature_flag": "tasks"- },"update-feature-flag": {"description": "Update a feature flag by ID in the current project.","category": "Feature flags",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 8c24eaa9fb7e..186d739f676c 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -40790,24 +40790,6 @@ export namespace Schemas {deleted?: boolean;}- export interface TaskFileRequest {- /** Destination folder path in the project tree (e.g. 'Tasks/Bugs'). Defaults to 'Tasks'. */- folder?: string;- }-- export interface TaskFileResponse {- /** Identifier of the project-tree entry for this task. */- id: string;- /** Full slash-separated path of the filed task in the project tree. */- path: string;- /** File system entry type. Always 'task'. */- type: string;- /** Identifier of the task this entry points to. */- ref: string;- /** In-app link to the task. */- href: string;- }-/*** Request body for the presence beacon and beacon-leave endpoints.*diff --git a/services/mcp/src/generated/tasks/api.ts b/services/mcp/src/generated/tasks/api.tsindex 89009a317abf..13f2b945af57 100644--- a/services/mcp/src/generated/tasks/api.ts+++ b/services/mcp/src/generated/tasks/api.ts@@ -3,7 +3,7 @@* MCP service uses these Zod schemas for generated tool handlers.* To regenerate: hogli build:openapi*- * PostHog API - MCP 7 enabled ops+ * PostHog API - MCP 5 enabled ops* OpenAPI spec version: 1.0.0*/import * as zod from 'zod'@@ -81,39 +81,6 @@ export const TasksRetrieveParams = /* @__PURE__ */ zod.object({),})-/**- * Add this task to the desktop project tree so it can be organized into folders. Optionally pass a destination folder path. Idempotent — re-filing updates the existing entry.- * @summary File a task into the project tree- */-export const TasksFileCreateParams = /* @__PURE__ */ zod.object({- id: zod.string().describe('A UUID string identifying this task.'),- project_id: zod- .string()- .describe(- "Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/."- ),-})--export const TasksFileCreateBody = /* @__PURE__ */ zod.object({- folder: zod- .string()- .optional()- .describe("Destination folder path in the project tree (e.g. 'Tasks/Bugs'). Defaults to 'Tasks'."),-})--/**- * Remove this task's entry from the desktop project tree. The task itself is not deleted.- * @summary Remove a task from the project tree- */-export const TasksUnfileCreateParams = /* @__PURE__ */ zod.object({- id: zod.string().describe('A UUID string identifying this task.'),- project_id: zod- .string()- .describe(- "Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/."- ),-})-/*** Get a list of runs for a specific task.* @summary List task runsdiff --git a/services/mcp/src/tools/generated/tasks.ts b/services/mcp/src/tools/generated/tasks.tsindex f8b1597de804..095335686bfa 100644--- a/services/mcp/src/tools/generated/tasks.ts+++ b/services/mcp/src/tools/generated/tasks.ts@@ -3,8 +3,6 @@ import { z } from 'zod'import type { Schemas } from '@/api/generated'import {- TasksFileCreateBody,- TasksFileCreateParams,TasksListQueryParams,TasksRetrieveParams,TasksRunsListParams,@@ -12,31 +10,10 @@ import {TasksRunsRetrieveParams,TasksRunsSessionLogsRetrieveParams,TasksRunsSessionLogsRetrieveQueryParams,- TasksUnfileCreateParams,} from '@/generated/tasks/api'import { withPostHogUrl, pickResponseFields, omitResponseFields, type WithPostHogUrl } from '@/tools/tool-utils'import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'-const TasksFileCreateSchema = TasksFileCreateParams.omit({ project_id: true }).extend(TasksFileCreateBody.shape)--const tasksFileCreate = (): ToolBase<typeof TasksFileCreateSchema, Schemas.TaskFileResponse> => ({- name: 'tasks-file-create',- schema: TasksFileCreateSchema,- handler: async (context: Context, params: z.infer<typeof TasksFileCreateSchema>) => {- const projectId = await context.stateManager.getProjectId()- const body: Record<string, unknown> = {}- if (params.folder !== undefined) {- body['folder'] = params.folder- }- const result = await context.api.request<Schemas.TaskFileResponse>({- method: 'POST',- path: `/api/projects/${encodeURIComponent(String(projectId))}/tasks/${encodeURIComponent(String(params.id))}/file/`,- body,- })- return result- },-})-const TasksListSchema = TasksListQueryParamsconst tasksList = (): ToolBase<typeof TasksListSchema, WithPostHogUrl<Schemas.PaginatedTaskList>> => ({@@ -196,27 +173,10 @@ const tasksRunsSessionLogsRetrieve = (): ToolBase<typeof TasksRunsSessionLogsRet},})-const TasksUnfileCreateSchema = TasksUnfileCreateParams.omit({ project_id: true })--const tasksUnfileCreate = (): ToolBase<typeof TasksUnfileCreateSchema, unknown> => ({- name: 'tasks-unfile-create',- schema: TasksUnfileCreateSchema,- handler: async (context: Context, params: z.infer<typeof TasksUnfileCreateSchema>) => {- const projectId = await context.stateManager.getProjectId()- const result = await context.api.request<unknown>({- method: 'POST',- path: `/api/projects/${encodeURIComponent(String(projectId))}/tasks/${encodeURIComponent(String(params.id))}/unfile/`,- })- return result- },-})-export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {- 'tasks-file-create': tasksFileCreate,'tasks-list': tasksList,'tasks-retrieve': tasksRetrieve,'tasks-runs-list': tasksRunsList,'tasks-runs-retrieve': tasksRunsRetrieve,'tasks-runs-session-logs-retrieve': tasksRunsSessionLogsRetrieve,- 'tasks-unfile-create': tasksUnfileCreate,}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-file-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-file-create.jsondeleted file mode 100644index 37c839b30143..000000000000--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-file-create.json+++ /dev/null@@ -1,15 +0,0 @@-{- "$schema": "https://json-schema.org/draft/2020-12/schema",- "properties": {- "folder": {- "description": "Destination folder path in the project tree (e.g. 'Tasks/Bugs'). Defaults to 'Tasks'.",- "type": "string"- },- "id": {- "description": "A UUID string identifying this task.",- "type": "string"- }- },- "required": ["id"],- "type": "object"-}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-unfile-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-unfile-create.jsondeleted file mode 100644index f0289641c9e3..000000000000--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-unfile-create.json+++ /dev/null@@ -1,11 +0,0 @@-{- "$schema": "https://json-schema.org/draft/2020-12/schema",- "properties": {- "id": {- "description": "A UUID string identifying this task.",- "type": "string"- }- },- "required": ["id"],- "type": "object"-}