: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(slack-app): share chart links instead of images behind a flag (#119665)
Vojta Bartošf54ed247d2a4
diff --git a/packages/agent/packages/agent-contracts/src/domain-types.ts b/packages/agent/packages/agent-contracts/src/domain-types.tsindex fe80779f6a22..0271a504a55e 100644--- a/packages/agent/packages/agent-contracts/src/domain-types.ts+++ b/packages/agent/packages/agent-contracts/src/domain-types.ts@@ -388,6 +388,7 @@ const taskRunStateFields = {z.enum(["none", "message", "canvas_file"]),),slack_chart_delivery: optionalField(z.boolean()),+ slack_chart_links: optionalField(z.boolean()),slack_notified_pr_url: optionalField(z.string()),slack_thread_url: optionalField(z.string()),snapshot_kind: optionalField(z.string()),diff --git a/packages/agent/packages/agent/src/products/slack/product.test.ts b/packages/agent/packages/agent/src/products/slack/product.test.tsindex 2a27123ebb69..9d91689be685 100644--- a/packages/agent/packages/agent/src/products/slack/product.test.ts+++ b/packages/agent/packages/agent/src/products/slack/product.test.ts@@ -84,6 +84,24 @@ describe("Slack product", () => {expect(deliveryInstructions.includes("Chart images are the one exception"),).toBe(delivery === "message" && charts);+ expect(deliveryInstructions.includes("insights/new#q=")).toBe(false);+ },+ );++ // The backend sends both keys when links are on, and the chart endpoint has to leave the+ // prompt with the link guidance in every delivery mode.+ it.each(["none", "message", "canvas_file"] as const)(+ "tells a %s workspace to share an insight link instead of a chart image when links are on",+ async (delivery) => {+ const { deliveryInstructions = "" } = await configure({+ slack_artifact_delivery: delivery,+ slack_chart_delivery: true,+ slack_chart_links: true,+ });++ expect(deliveryInstructions).toContain("insights/new#q=<query>");+ expect(deliveryInstructions).toContain("the only PostHog link");+ expect(deliveryInstructions).not.toContain("living_artifacts/chart/");},);diff --git a/packages/agent/packages/agent/src/products/slack/product.ts b/packages/agent/packages/agent/src/products/slack/product.tsindex bfc4b92ceb0a..946dc19bab1d 100644--- a/packages/agent/packages/agent/src/products/slack/product.ts+++ b/packages/agent/packages/agent/src/products/slack/product.ts@@ -12,6 +12,7 @@ import { buildPullRequestFooter, defineProduct } from "../../sdk/product";import {buildSlackDeliveryInstructions,buildSlackIdentityInstructions,+ type SlackPromptOptions,} from "./prompt";const SLACK_ORIGIN = "slack";@@ -32,6 +33,7 @@ const slackLaunchOptionsSchema = z.object({// Charts need only the rollout flag, while canvas and file delivery also need Slack// scopes, so a workspace can have charts and nothing else.slack_chart_delivery: z.boolean().catch(false),+ slack_chart_links: z.boolean().catch(false),slack_app_agent_design_enabled: z.boolean().catch(false),slack_thread_url: z.string().nullable().catch(null),slack_notified_pr_url: z.string().nullable().catch(null),@@ -71,9 +73,15 @@ export function slackProduct(): AgentProduct {const { launchOptions } = launch;const slackOrigin = launch.originProduct === SLACK_ORIGIN;const slackReply = slackOrigin || launchOptions.slack_reply_context;- const promptOptions = {+ const promptOptions: SlackPromptOptions = {slackArtifactDelivery: launchOptions.slack_artifact_delivery,- slackChartDelivery: launchOptions.slack_chart_delivery,+ // The backend keeps chart delivery on next to the links key, so an older agent image+ // still posts images while this one prefers the link.+ slackCharts: launchOptions.slack_chart_links+ ? "link"+ : launchOptions.slack_chart_delivery+ ? "image"+ : null,slackProgressChecklist: launchOptions.slack_app_agent_design_enabled,};const threadUrl = launchOptions.slack_thread_url;diff --git a/packages/agent/packages/agent/src/products/slack/prompt.ts b/packages/agent/packages/agent/src/products/slack/prompt.tsindex d36f978e2141..c1984816969e 100644--- a/packages/agent/packages/agent/src/products/slack/prompt.ts+++ b/packages/agent/packages/agent/src/products/slack/prompt.ts@@ -1,11 +1,24 @@export type SlackArtifactDelivery = "none" | "message" | "canvas_file";+export type SlackChartMode = "image" | "link";+export interface SlackPromptOptions {slackArtifactDelivery: SlackArtifactDelivery | null;- slackChartDelivery: boolean;+ slackCharts: SlackChartMode | null;slackProgressChecklist: boolean;}+const CHART_TAKEAWAY = `do not restate the title or announce the chart ("Here's a chart of…"). Spend your answer text on the takeaway instead: the trend, inflection points, spikes, or drops a reader should notice, with numbers where they matter.`;++// An insight link is plain text, so it works in every delivery mode, including a workspace+// with no artifact delivery at all.+const CHART_LINK_BULLETS = `+- When an analytics answer is naturally visual (a trend over time, funnel, breakdown comparison, retention curve), put one PostHog insight link in your reply by default, without waiting for the user to say "chart". Slack unfurls it under your answer as a card with the chart image, so never render, download, or upload a chart image yourself. Skip the link only when the result is a single number, a short list, or the user asked for raw data.+- For a saved insight, use the URL the PostHog tool returned. For an ad hoc query, build \`$POSTHOG_API_URL/project/$POSTHOG_PROJECT_ID/insights/new#q=<query>\` with \`<query>\` the insight query JSON you ran (e.g. \`{"kind": "InsightVizNode", "source": {"kind": "TrendsQuery", ...}}\`), encoded with encodeURIComponent.+- Keep it the only PostHog link in the message: a second one shrinks every card and drops the chart. Links to other sites do not count.+- The card carries the insight title and an "Open in PostHog" button, so ${CHART_TAKEAWAY}+- SQL results cannot be charted this way, because the unfurl renders insight queries only. Link an insight query (e.g. TrendsQuery) when the question can be expressed as one; otherwise summarize the SQL result in your answer text.`;+export function buildSlackDeliveryInstructions(options: SlackPromptOptions,): string {@@ -13,47 +26,53 @@ export function buildSlackDeliveryInstructions(return "";}+ const endpoint = `$POSTHOG_API_URL/api/projects/$POSTHOG_PROJECT_ID/tasks/$POSTHOG_TASK_ID/runs/$POSTHOG_TASK_RUN_ID/living_artifacts/`;+ // A chart image posts as an image block referencing a PostHog-hosted URL, so it works in+ // both artifact modes, but it still goes through the living-artifacts endpoint.+ const chartGuidance =+ options.slackCharts === "link"+ ? CHART_LINK_BULLETS+ : options.slackCharts === "image" &&+ options.slackArtifactDelivery !== "none"+ ? `+- When an analytics answer is naturally visual (a trend over time, funnel, breakdown comparison, retention curve), deliver a chart image by default alongside the summary. Do not wait for the user to say "chart". Skip the image only when the result is a single number, a short list, or the user asked for raw data.+- To show a chart in Slack (a saved insight or an ad-hoc analytics query result), make a single call: POST to \`${endpoint}chart/\` with \`$POSTHOG_PERSONAL_API_KEY\` and body \`{"name": "<chart title>", "query": <query JSON, e.g. {"kind": "InsightVizNode", "source": {"kind": "TrendsQuery", ...}}>}\`, or \`{"name": "<chart title>", "insight_id": <numeric insight id>}\` for a saved insight. It renders the chart server-side and registers it for Slack delivery in one step, blocking until done (typically a few seconds).+- The chart renders directly under your answer text with its name as the title, so ${CHART_TAKEAWAY} Each chart is delivered with an "Open in PostHog" button, so do not paste the response \`url\` into your answer unless the user explicitly asks for a link. Do not download, view, or re-upload the image yourself.+- Report a chart failure rather than retrying blindly: a 400 carries the reason in \`error\`, or in \`detail\` when the request body itself was rejected, and a 429 means the project's chart render limit is saturated, so answer without the chart.+- SQL results cannot be charted yet, because the chart endpoint rejects SQL queries. Chart with an insight query (e.g. TrendsQuery) when the question can be expressed as one; otherwise summarize the SQL result in your answer text.`+ : "";+if (options.slackArtifactDelivery === "none") {return `## Delivering to Slack- You do not have artifact delivery in this workspace: you cannot create or share artifacts (files, canvases, documents) from this run, so do not attempt to. Deliver results as plain text in your reply.-- Do not attach, upload, link to, or expose run artifacts or local working files, including /tmp/workspace paths.`;+- Do not attach, upload, link to, or expose run artifacts or local working files, including /tmp/workspace paths.${chartGuidance}`;}- const endpoint = `$POSTHOG_API_URL/api/projects/$POSTHOG_PROJECT_ID/tasks/$POSTHOG_TASK_ID/runs/$POSTHOG_TASK_RUN_ID/living_artifacts/`;const preamble = `## Delivering to Slack- Local sandbox paths such as /tmp/workspace/... are not visible to Slack users.- Do not say a file, report, PDF, spreadsheet, document, or other artifact is attached, uploaded, or shared unless a tool explicitly confirms that delivery.- Run artifacts that are not your uploaded outputs (plans, context, tree snapshots, user uploads) are internal: never deliver them to Slack or mention them in your reply.`;- // Charts attach to both modes: they post as an image block referencing a PostHog-hosted- // URL, so they work wherever the workspace can post at all.- const chartBullets = options.slackChartDelivery- ? `-- When an analytics answer is naturally visual (a trend over time, funnel, breakdown comparison, retention curve), deliver a chart image by default alongside the summary. Do not wait for the user to say "chart". Skip the image only when the result is a single number, a short list, or the user asked for raw data.-- To show a chart in Slack (a saved insight or an ad-hoc analytics query result), make a single call: POST to \`${endpoint}chart/\` with \`$POSTHOG_PERSONAL_API_KEY\` and body \`{"name": "<chart title>", "query": <query JSON, e.g. {"kind": "InsightVizNode", "source": {"kind": "TrendsQuery", ...}}>}\`, or \`{"name": "<chart title>", "insight_id": <numeric insight id>}\` for a saved insight. It renders the chart server-side and registers it for Slack delivery in one step, blocking until done (typically a few seconds).-- The chart renders directly under your answer text with its name as the title, so do not restate the title or announce the chart ("Here's a chart of…"). Spend your answer text on the takeaway instead: the trend, inflection points, spikes, or drops a reader should notice, with numbers where they matter. Each chart is delivered with an "Open in PostHog" button, so do not paste the response \`url\` into your answer unless the user explicitly asks for a link. Do not download, view, or re-upload the image yourself.-- Report a chart failure rather than retrying blindly: a 400 carries the reason in \`error\`, or in \`detail\` when the request body itself was rejected, and a 429 means the project's chart render limit is saturated, so answer without the chart.-- SQL results cannot be charted yet, because the chart endpoint rejects SQL queries. Chart with an insight query (e.g. TrendsQuery) when the question can be expressed as one; otherwise summarize the SQL result in your answer text.`- : "";-if (options.slackArtifactDelivery === "message") {- const chartException = options.slackChartDelivery- ? " Chart images are the one exception: deliver them through the dedicated chart endpoint below, never through the generic living-artifacts endpoint."- : "";- const unsupportedDeliverable = options.slackChartDelivery- ? "- If a deliverable cannot be expressed as a Slack message or a chart image (for example .xlsx/.pdf/.docx), say that plainly and summarize the result in Slack instead."- : "- If a deliverable cannot be expressed as a Slack message (for example .xlsx/.pdf/.docx), say that plainly and summarize the result in Slack instead.";+ const chartException =+ options.slackCharts === "image"+ ? " Chart images are the one exception: deliver them through the dedicated chart endpoint below, never through the generic living-artifacts endpoint."+ : "";+ const unsupportedDeliverable =+ options.slackCharts === "image"+ ? "- If a deliverable cannot be expressed as a Slack message or a chart image (for example .xlsx/.pdf/.docx), say that plainly and summarize the result in Slack instead."+ : "- If a deliverable cannot be expressed as a Slack message (for example .xlsx/.pdf/.docx), say that plainly and summarize the result in Slack instead.";return `${preamble}- You do not have canvas or file delivery in this workspace: do not use the \`slack_canvas\` or \`slack_file\` adapters, and do not promise a canvas, uploaded spreadsheet, or downloadable file.${chartException}-- For Slack deliverables, create a living artifact before claiming delivery. POST to \`${endpoint}\` with \`$POSTHOG_PERSONAL_API_KEY\` using adapter \`slack_message\`. To update a prior deliverable, GET the returned artifact id or POST new \`content\` to \`${endpoint}<artifact_id>/edit/\`.${chartBullets}+- For Slack deliverables, create a living artifact before claiming delivery. POST to \`${endpoint}\` with \`$POSTHOG_PERSONAL_API_KEY\` using adapter \`slack_message\`. To update a prior deliverable, GET the returned artifact id or POST new \`content\` to \`${endpoint}<artifact_id>/edit/\`.${chartGuidance}${unsupportedDeliverable}`;}return `${preamble}- For Slack deliverables, create a living artifact before claiming delivery. POST to \`${endpoint}\` with \`$POSTHOG_PERSONAL_API_KEY\`; choose adapter \`slack_canvas\`, \`slack_message\`, \`slack_file\`, or \`document_connector\`. Use \`adapter=slack_file\` with \`content_base64\` for binary deliverables such as .xlsx/.pdf/.docx, or \`source_artifact_id\` / \`source_storage_path\` for a file you already uploaded as a \`type=output\` run artifact.-- To update a prior deliverable, GET the returned artifact id or POST new \`content\`, \`content_base64\`, or source artifact fields to \`${endpoint}<artifact_id>/edit/\`.${chartBullets}+- To update a prior deliverable, GET the returned artifact id or POST new \`content\`, \`content_base64\`, or source artifact fields to \`${endpoint}<artifact_id>/edit/\`.${chartGuidance}- Do not paste living-artifact Slack file links or permalinks into your final Slack answer unless the user explicitly asks for the URL. The Slack relay attaches pending files and canvas cards to your final answer automatically after you finish, so mention the artifact by name only if useful.- A pending delivery status only means the artifact waits for your final answer. Do not check it again, and do not tell the user that a link or file has not arrived.- If you created a local file but no upload or delivery tool is available, say that plainly and summarize the result in Slack instead.`;diff --git a/products/slack_app/backend/facade/api.py b/products/slack_app/backend/facade/api.pyindex 36ba376170d0..d8a132442b3a 100644--- a/products/slack_app/backend/facade/api.py+++ b/products/slack_app/backend/facade/api.py@@ -24,6 +24,7 @@ from typing import Anyfrom posthog.models.integration import Integration+from products.slack_app.backend.feature_flags import is_slack_app_chart_links_enabledfrom products.slack_app.backend.logic.progress_phases import (ANSWER_LINE_TITLE,OTHER_WORK,@@ -107,9 +108,14 @@ def slack_channel_is_approved(slack_workspace_id: str, slack_channel_id: str) ->def slack_artifact_delivery_state_updates(integration: Integration) -> dict[str, str | bool]:- """State that tells a task agent which Slack artifact adapters can deliver."""+ """State that tells a task agent which Slack artifact adapters can deliver, and whether to+ share a chart as an insight link rather than render it through the chart endpoint."""mode = "canvas_file" if has_scopes(integration, _SLACK_CANVAS_FILE_ADAPTER_SCOPES) else "message"- return {"slack_artifact_delivery": mode, "slack_chart_delivery": True}+ return {+ "slack_artifact_delivery": mode,+ "slack_chart_delivery": True,+ "slack_chart_links": is_slack_app_chart_links_enabled(integration),+ }def slack_followup_invite_text(integration: Integration | None, *, utm_tags: str, ai_enabled: bool) -> str | None:diff --git a/products/slack_app/backend/feature_flags.py b/products/slack_app/backend/feature_flags.pyindex cdab445df32a..09fa37197b3c 100644--- a/products/slack_app/backend/feature_flags.py+++ b/products/slack_app/backend/feature_flags.py@@ -46,6 +46,7 @@ logger = structlog.get_logger(__name__)SLACK_APP_AGENT_DESIGN_FLAG = "slack-app-agent-design"+SLACK_APP_CHART_LINKS_FLAG = "slack-app-chart-links"SLACK_APP_FORKING_FLAG = "slack-app-forking"SLACK_APP_UNPROMPTED_ANSWERS_FLAG = "slack-app-unprompted-answers"@@ -126,6 +127,17 @@ def is_slack_app_agent_design_enabled(integration: Integration, distinct_id: str)+def is_slack_app_chart_links_enabled(integration: Integration) -> bool:+ """Gate for charts as insight links: a Slack task run shares a PostHog insight link+ instead of rendering a chart image, and the link unfurl draws the chart. Resolved once,+ when the run starts, and stored on the run for the unfurl webhook to read."""+ return _workspace_flag_enabled(+ SLACK_APP_CHART_LINKS_FLAG,+ integration,+ failure_log_key="slack_app_chart_links_feature_flag_check_failed",+ )++def is_slack_app_unprompted_answers_enabled(integration: Integration) -> bool:"""Gate for answering top-level channel messages nobody tagged the app in.diff --git a/products/slack_app/backend/slack_link_unfurl.py b/products/slack_app/backend/slack_link_unfurl.pyindex 79cf0ee17d19..c067b6d6f2d9 100644--- a/products/slack_app/backend/slack_link_unfurl.py+++ b/products/slack_app/backend/slack_link_unfurl.py@@ -63,6 +63,7 @@ from products.slack_app.backend.logic.link_unfurl_charts import (slack_fetchable_image_url,with_chart_images,)+from products.slack_app.backend.models import SlackThreadTaskMappingfrom products.slack_app.backend.services.followup_invite import build_followup_invitefrom products.slack_app.backend.services.slack_messages import UNFURL_OPT_OUT_PARAMfrom products.slack_app.backend.temporal.slack_app_unfurl_charts import (@@ -1315,6 +1316,29 @@ def add_artifact_image_to_unfurl()+def _bot_reply_actor(integration: Integration, event: dict) -> str | None:+ """The Slack user steering the run in this thread, when that run was told to share chart links.++ Slack reports every bot-posted message under one placeholder author, so a thread whose run+ shares links is the signal that a placeholder-authored message is our reply, written for that+ person with their PostHog access. The run state holds the decision, so no flag call here."""+ if not event.get("thread_ts"):+ return None+ actors = (+ SlackThreadTaskMapping.objects.filter(+ integration=integration,+ channel=event["channel"],+ thread_ts=event["thread_ts"],+ task_run__state__slack_chart_links=True,+ )+ .values_list(+ "task_run__state__slack_actor_slack_user_id", "latest_actor_slack_user_id", "mentioning_slack_user_id"+ )+ .first()+ )+ return next((actor for actor in actors or () if actor), None)++def handle_posthog_link_unfurl(event: dict, integration: Integration) -> None:"""Unfurl supported PostHog resource links with metadata.@@ -1335,7 +1359,13 @@ def handle_posthog_link_unfurl(event: dict, integration: Integration) -> None:return# Imported here to avoid circular import with api (api imports this module at load time).- from products.slack_app.backend.api import resolve_slack_user+ from products.slack_app.backend.api import SLACK_PLACEHOLDER_USER_ID, resolve_slack_user++ bot_reply_actor = _bot_reply_actor(integration, event) if slack_user_id == SLACK_PLACEHOLDER_USER_ID else None+ if bot_reply_actor:+ slack_user_id = bot_reply_actor+ # Everything downstream, the chart workflow included, reads the sharer from the event.+ event = {**event, "user": bot_reply_actor}user_context = resolve_slack_user(slack,@@ -1484,4 +1514,5 @@ def handle_posthog_link_unfurl(event: dict, integration: Integration) -> None:followup_invite_shown=invite is not None,charts_queued=charts_queued,artifact_image_queued=artifact_image_queued,+ bot_reply=bot_reply_actor is not None,)diff --git a/products/slack_app/backend/temporal/tests/activities/test_task_creation.py b/products/slack_app/backend/temporal/tests/activities/test_task_creation.pyindex e0c3f0a51ac7..fb6d69cdf36c 100644--- a/products/slack_app/backend/temporal/tests/activities/test_task_creation.py+++ b/products/slack_app/backend/temporal/tests/activities/test_task_creation.py@@ -12,6 +12,7 @@ to wording in the wrapper text show up as a diff in"""import pytest+from unittest.mock import patchfrom posthog.models.integration import Integration@@ -95,12 +96,25 @@ def test_artifact_delivery_mode_offers_only_what_delivery_accepts(granted_scopes# missing one still gets charts while dropping to message mode.integration = Integration(kind="slack", config={"scope": granted_scopes})- assert slack_artifact_delivery_state_updates(integration) == {+ with patch("products.slack_app.backend.facade.api.is_slack_app_chart_links_enabled", return_value=False):+ state = slack_artifact_delivery_state_updates(integration)++ assert state == {"slack_artifact_delivery": expected_mode,"slack_chart_delivery": True,+ "slack_chart_links": False,}+def test_chart_links_ride_on_the_flag():+ integration = Integration(kind="slack", config={"scope": "chat:write"})++ with patch("products.slack_app.backend.facade.api.is_slack_app_chart_links_enabled", return_value=True):+ state = slack_artifact_delivery_state_updates(integration)++ assert state["slack_chart_links"] is True++def test_build_description_renders_labeled_mention_for_each_author():# Add a follow-up message after the mentioner so the placeholder isn't the trailing# entry (the trailing-placeholder pop would otherwise drop the mentioner's row).diff --git a/products/slack_app/backend/tests/test_link_unfurl.py b/products/slack_app/backend/tests/test_link_unfurl.pyindex b9b982040532..b01737128538 100644--- a/products/slack_app/backend/tests/test_link_unfurl.py+++ b/products/slack_app/backend/tests/test_link_unfurl.py@@ -42,7 +42,7 @@ from products.notebooks.backend.models import Notebookfrom products.product_analytics.backend.facade.models import Insightfrom products.signals.backend.models import SignalReportfrom products.slack_app.backend.api import ROUTE_HANDLED_LOCALLY, route_posthog_code_event_to_relevant_region-from products.slack_app.backend.models import SlackChannel+from products.slack_app.backend.models import SlackChannel, SlackThreadTaskMappingfrom products.slack_app.backend.services.slack_auth import write_auth_state_okfrom products.slack_app.backend.services.slack_scopes import REQUIRED_SLACK_SCOPESfrom products.slack_app.backend.slack_link_unfurl import (@@ -564,6 +564,74 @@ class TestHandlePosthogLinkUnfurl(APIBaseTest):mock_client.chat_unfurl.assert_not_called()+ @parameterized.expand(+ [+ # (run told to link, thread has a run, author resolved)+ ("linking_run", True, True, "U_ACTOR"),+ ("run_not_told_to_link", False, True, "U00"),+ ("no_run_in_thread", True, False, "U00"),+ ]+ )+ @patch("products.slack_app.backend.api.resolve_slack_user")+ @patch("products.slack_app.backend.slack_link_unfurl.SlackIntegration")+ def test_bot_reply_link_unfurls_for_the_thread_actor(+ self,+ _name: str,+ run_links: bool,+ has_run: bool,+ expected_resolved: str,+ mock_slack_integration_class: MagicMock,+ mock_resolve: MagicMock,+ ) -> None:+ # Slack reports a bot-posted message under a placeholder author that resolves to no PostHog+ # user, so without this path a chart link in the agent's answer never unfurls. The+ # attribution stays narrow: a thread whose run was told to share links, and the actor is+ # the one the run recorded rather than the mapping's stale column.+ mock_resolve.side_effect = lambda _slack, _integration, uid, *_a, **_k: (+ MagicMock(user=self.user) if uid == "U_ACTOR" else None+ )+ mock_client = MagicMock()+ mock_slack_integration_class.return_value.client = mock_client+ if has_run:+ task = Task.objects.create(+ team=self.team,+ created_by=self.user,+ title="Chart the signups",+ description="",+ origin_product=Task.OriginProduct.USER_CREATED,+ )+ run = TaskRun.objects.create(+ task=task,+ team=self.team,+ state={"slack_chart_links": run_links, "slack_actor_slack_user_id": "U_ACTOR"},+ )+ SlackThreadTaskMapping.objects.create(+ team=self.team,+ integration=self.integration,+ slack_workspace_id=self.integration.integration_id,+ channel="C1",+ thread_ts="100.000",+ task=task,+ task_run=run,+ mentioning_slack_user_id="U_ASKER",+ latest_actor_slack_user_id="U_STALE",+ )+ url = f"http://testserver/project/{self.team.pk}/insights/{self.insight.short_id}"++ handle_posthog_link_unfurl(+ {+ "channel": "C1",+ "message_ts": "123.456",+ "thread_ts": "100.000",+ "user": "U00",+ "links": [{"url": url}],+ },+ self.integration,+ )++ assert mock_resolve.call_args.args[2] == expected_resolved+ assert mock_client.chat_unfurl.called == (expected_resolved == "U_ACTOR")+@patch("products.slack_app.backend.api.resolve_slack_user")@patch("products.slack_app.backend.slack_link_unfurl.SlackIntegration")@override_settings(DEBUG=False, CLOUD_DEPLOYMENT="US")diff --git a/products/tasks/backend/facade/api.py b/products/tasks/backend/facade/api.pyindex 54f6a08cfa82..e8714eb0b0f6 100644--- a/products/tasks/backend/facade/api.py+++ b/products/tasks/backend/facade/api.py@@ -562,6 +562,7 @@ _TASK_RUN_PUBLIC_STATE_KEYS = frozenset("slack_app_agent_design_enabled","slack_artifact_delivery","slack_chart_delivery",+ "slack_chart_links","slack_thread_url",})