: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(canvas): drop the unused author context field (#96741)
Peter Kirkhamde82d7235000
diff --git a/products/canvas/backend/migrations/0018_remove_canvas_context.py b/products/canvas/backend/migrations/0018_remove_canvas_context.pynew file mode 100644index 000000000000..98cd8fa9ebbb--- /dev/null+++ b/products/canvas/backend/migrations/0018_remove_canvas_context.py@@ -0,0 +1,28 @@+from django.db import migrations+++class Migration(migrations.Migration):+ dependencies = [+ ("canvas", "0017_squash_2026_09_07_finalize_fks"),+ ]++ # State-only removal: the column stays in place until a follow-up migration+ # drops it after a full deploy cycle (see safe-django-migrations.md). The+ # column is NOT NULL with no database default, so it gets one here; without+ # it every insert that no longer names the column fails.+ operations = [+ migrations.SeparateDatabaseAndState(+ state_operations=[+ migrations.RemoveField(+ model_name="canvas",+ name="context",+ ),+ ],+ database_operations=[+ migrations.RunSQL(+ sql="ALTER TABLE posthog_canvas ALTER COLUMN context SET DEFAULT '';",+ reverse_sql="ALTER TABLE posthog_canvas ALTER COLUMN context DROP DEFAULT;",+ ),+ ],+ ),+ ]diff --git a/products/canvas/backend/migrations/max_migration.txt b/products/canvas/backend/migrations/max_migration.txtindex 6a7a268df071..c7d5a931c758 100644--- a/products/canvas/backend/migrations/max_migration.txt+++ b/products/canvas/backend/migrations/max_migration.txt@@ -1 +1 @@-0017_squash_2026_09_07_finalize_fks+0018_remove_canvas_contextdiff --git a/products/canvas/backend/models.py b/products/canvas/backend/models.pyindex d37c8bc27dbc..05a7c9f8b0e2 100644--- a/products/canvas/backend/models.py+++ b/products/canvas/backend/models.py@@ -51,8 +51,6 @@ class Canvas(TeamScopedRootMixin, UUIDModel):# widget shows and what its config controls.description = models.TextField(blank=True, default="")template_id = models.CharField(max_length=64, default="freeform")- # Author-written markdown handed to generation tasks as background context.- context = models.TextField(blank=True, default="")# The task currently generating/editing this canvas. A plain UUID rather# than a FK: Task lives in the tasks app and a schema-level FK would chain# the two products' migrations together for a soft pointer.diff --git a/products/canvas/backend/notebook_integration.py b/products/canvas/backend/notebook_integration.pyindex 0e0e0aa302dc..a2662037f0a2 100644--- a/products/canvas/backend/notebook_integration.py+++ b/products/canvas/backend/notebook_integration.py@@ -62,7 +62,7 @@ class NotebookCanvasSourceInvalidError(NotebookCanvasError):pass-def create_notebook_canvas(*, team_id: int, user_id: int, channel_id: UUID, name: str, context: str) -> UUID:+def create_notebook_canvas(*, team_id: int, user_id: int, channel_id: UUID, name: str) -> UUID:if not tasks_facade.channel_exists(team_id, channel_id, user_id):raise NotebookCanvasNotFoundErrorreturn (@@ -71,7 +71,6 @@ def create_notebook_canvas(*, team_id: int, user_id: int, channel_id: UUID, nameteam_id=team_id,channel_id=channel_id,name=name,- context=context,created_by_id=user_id,source_policy=Canvas.SOURCE_POLICY_NOTEBOOK_WIDGET,)diff --git a/products/canvas/backend/presentation/serializers.py b/products/canvas/backend/presentation/serializers.pyindex acfe137fde59..7beec9f3892a 100644--- a/products/canvas/backend/presentation/serializers.py+++ b/products/canvas/backend/presentation/serializers.py@@ -130,7 +130,6 @@ class CanvasSerializer(serializers.ModelSerializer):"description","channel","template_id",- "context","generation_task_id","pinned","pinned_at",@@ -207,11 +206,6 @@ class CanvasUpdateSerializer(serializers.Serializer):max_length=400,help_text="Updated display name.",)- # The field name shadows BaseSerializer.context; the metaclass moves declared fields into- # _declared_fields, so self.context still resolves to the serializer context at runtime.- context = serializers.CharField( # type: ignore[assignment]- required=False, allow_blank=True, trim_whitespace=False, help_text="Updated author context markdown."- )description = serializers.CharField(required=False,allow_blank=True,diff --git a/products/canvas/backend/presentation/views.py b/products/canvas/backend/presentation/views.pyindex e544bec45a1a..197be6efd574 100644--- a/products/canvas/backend/presentation/views.py+++ b/products/canvas/backend/presentation/views.py@@ -363,7 +363,7 @@ class CanvasViewSet(CanvasAccessMixin, viewsets.ModelViewSet):# publish a new version of it; a canvas in a personal space is only visible# to its owner, so the creator rule is implied there. partial_update is in# this set because a member must record their own generation task on the- # canvas; the other metadata fields stay creator-only (see partial_update).+ # canvas; every other metadata field stays creator-only (see partial_update)._EDITOR_ACTIONS = {"partial_update","publish",@@ -377,7 +377,7 @@ class CanvasViewSet(CanvasAccessMixin, viewsets.ModelViewSet):"patch_layout",}_CREATOR_ONLY_ACTIONS = {"destroy"}- _NON_CREATOR_UPDATE_FIELDS = {"generation_task_id", "context"}+ _NON_CREATOR_UPDATE_FIELDS = {"generation_task_id"}@extend_schema(parameters=[@@ -512,13 +512,6 @@ class CanvasViewSet(CanvasAccessMixin, viewsets.ModelViewSet):record("name", canvas.name, data["name"])canvas.name = data["name"]update_fields.append("name")- if "context" in data:- # The author-context markdown is content, not configuration — record- # that it changed without copying it into the audit trail.- if data["context"] != canvas.context:- record("context")- canvas.context = data["context"]- update_fields.append("context")if "description" in data:if data["description"] != canvas.description:record("description", canvas.description, data["description"])diff --git a/products/canvas/backend/teaching.py b/products/canvas/backend/teaching.pyindex 9174ad0aec88..b710ef1bdc55 100644--- a/products/canvas/backend/teaching.py+++ b/products/canvas/backend/teaching.py@@ -31,12 +31,6 @@ TEACHING_CANVAS_DESCRIPTION = ("A short tour of PostHog Desktop for new users: spaces, the agent, space context, Self-driving, and canvases.")-TEACHING_CANVAS_CONTEXT = (- "This canvas is an onboarding tour for new PostHog Desktop users. It explains spaces, "- "the agent, space context, Self-driving, and canvases, and shows a live unique-users "- "chart. If you edit it, keep it short and plain."-)-TEACHING_CANVAS_CODE = """\import { useEffect, useState } from "react";import {@@ -546,7 +540,6 @@ def seed_teaching_canvas(*, team_id: int, channel_id: UUID, user: User, refresh:kind=Canvas.KIND_FREEFORM,template_id=TEACHING_CANVAS_TEMPLATE_ID,description=TEACHING_CANVAS_DESCRIPTION,- context=TEACHING_CANVAS_CONTEXT,pinned_at=timezone.now(),created_by=user,)diff --git a/products/canvas/backend/tests/test_canvas_api.py b/products/canvas/backend/tests/test_canvas_api.pyindex 6c96b912ebd7..bc5aac84b6aa 100644--- a/products/canvas/backend/tests/test_canvas_api.py+++ b/products/canvas/backend/tests/test_canvas_api.py@@ -648,7 +648,7 @@ class TestCanvasCrud(CanvasAPIBaseTest):assert response.status_code == status.HTTP_200_OK, response.json()body = response.json()assert body["name"] == "Renamed"- assert body["context"] == "notes"+ assert "context" not in bodyassert body["pinned"] is Trueresponse = self.client.patch(diff --git a/products/canvas/backend/tests/test_notebook_integration.py b/products/canvas/backend/tests/test_notebook_integration.pyindex 0cae78fbcd05..6880fd1f6286 100644--- a/products/canvas/backend/tests/test_notebook_integration.py+++ b/products/canvas/backend/tests/test_notebook_integration.py@@ -52,7 +52,6 @@ class TestNotebookCanvasCreation(APIBaseTest):user_id=self.user.id,channel_id=channel.id,name="Widget",- context="Context",)self.assertFalse(Canvas.objects.unscoped().filter(channel_id=channel.id).exists())@@ -68,7 +67,6 @@ class TestNotebookCanvasCreation(APIBaseTest):user_id=self.user.id,channel_id=channel.id,name="Widget",- context="Context",)self.assertFalse(Canvas.objects.unscoped().filter(channel_id=channel.id).exists())diff --git a/products/canvas/frontend/generated/api.schemas.ts b/products/canvas/frontend/generated/api.schemas.tsindex 67b1d51e0e60..896bcda85f8d 100644--- a/products/canvas/frontend/generated/api.schemas.ts+++ b/products/canvas/frontend/generated/api.schemas.ts@@ -150,7 +150,6 @@ export interface CanvasApi {readonly description: stringreadonly channel: stringreadonly template_id: string- readonly context: string/** @nullable */readonly generation_task_id: string | null/** Whether the canvas is pinned to its channel. */@@ -220,8 +219,6 @@ export interface PatchedCanvasUpdateApi {* @maxLength 400*/name?: string- /** Updated author context markdown. */- context?: string/** Updated canvas description (for components, the store-search text). */description?: string/** Id of the space the canvas belongs to. */diff --git a/products/canvas/frontend/generated/api.zod.ts b/products/canvas/frontend/generated/api.zod.tsindex dff93ca8b0cd..f48a379d1e0b 100644--- a/products/canvas/frontend/generated/api.zod.ts+++ b/products/canvas/frontend/generated/api.zod.ts@@ -52,7 +52,6 @@ export const canvasesPartialUpdateBodyNameMax = 400export const CanvasesPartialUpdateBody = /* @__PURE__ */ zod.object({name: zod.string().max(canvasesPartialUpdateBodyNameMax).optional().describe('Updated display name.'),- context: zod.string().optional().describe('Updated author context markdown.'),description: zod.string().optional()diff --git a/products/notebooks/backend/widgets.py b/products/notebooks/backend/widgets.pyindex 22b2c504ba63..d40f01dad48d 100644--- a/products/notebooks/backend/widgets.py+++ b/products/notebooks/backend/widgets.py@@ -511,7 +511,6 @@ def _ensure_widget_instance(*, notebook: Notebook, node_id: str, prompt: str, ususer_id=user_id,channel_id=channel_id,name=_display_name(prompt),- context=prompt,)widget = GeneratedWidget.objects.for_team(notebook.team_id).create(team_id=notebook.team_id,diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex bbc3ef1f822d..d19f2baf9dc1 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -15803,7 +15803,6 @@ export namespace Schemas {readonly description: string;readonly channel: string;readonly template_id: string;- readonly context: string;/** @nullable */readonly generation_task_id: string | null;/** Whether the canvas is pinned to its channel. */@@ -62584,8 +62583,6 @@ export namespace Schemas {* @maxLength 400*/name?: string;- /** Updated author context markdown. */- context?: string;/** Updated canvas description (for components, the store-search text). */description?: string;/** Id of the space the canvas belongs to. */diff --git a/services/mcp/src/generated/canvas/api.ts b/services/mcp/src/generated/canvas/api.tsindex ded91b2f79c7..871b5d6239c7 100644--- a/services/mcp/src/generated/canvas/api.ts+++ b/services/mcp/src/generated/canvas/api.ts@@ -96,7 +96,6 @@ export const canvasesPartialUpdateBodyNameMax = 400export const CanvasesPartialUpdateBody = () => zod.object({name: zod.string().max(canvasesPartialUpdateBodyNameMax).optional().describe('Updated display name.'),- context: zod.string().optional().describe('Updated author context markdown.'),description: zod.string().optional()diff --git a/services/mcp/src/tools/generated/canvas.ts b/services/mcp/src/tools/generated/canvas.tsindex 1f7079456474..02a4f59243c3 100644--- a/services/mcp/src/tools/generated/canvas.ts+++ b/services/mcp/src/tools/generated/canvas.ts@@ -340,13 +340,8 @@ const CanvasMoveSchema = () => {const CanvasesPartialUpdateParams = orvalSchemas.CanvasesPartialUpdateParams()return CanvasesPartialUpdateParams.omit({ project_id: true }).extend(- CanvasesPartialUpdateBody.omit({- name: true,- context: true,- description: true,- pinned: true,- generation_task_id: true,- }).shape+ CanvasesPartialUpdateBody.omit({ name: true, description: true, pinned: true, generation_task_id: true })+ .shape).extend({id: CanvasesPartialUpdateParams.shape['id'].describe('ID of the canvas to move.'),