Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(tasks): link "View agent logs" to cloud task page (#66225)

Andrew Maguire55a7e7cfc55f
diff --git a/products/slack_app/backend/tests/test_slack_thread.py b/products/slack_app/backend/tests/test_slack_thread.py
index 773fef8ffb62..a2697893cb5c 100644
--- a/products/slack_app/backend/tests/test_slack_thread.py
+++ b/products/slack_app/backend/tests/test_slack_thread.py
@@ -42,7 +42,9 @@ class TestSlackThreadHandler(TestCase):
)
handler = SlackThreadHandler(context)
- handler.post_or_update_progress("In progress...", task_url="posthog-code://task/abc/run/xyz")
+ handler.post_or_update_progress(
+ "In progress...", task_url="https://us.posthog.com/project/1/tasks/abc?runId=xyz"
+ )
mock_client.chat_postMessage.assert_called_once()
blocks = mock_client.chat_postMessage.call_args.kwargs["blocks"]
@@ -50,6 +52,7 @@ class TestSlackThreadHandler(TestCase):
assert len(actions) == 1
assert actions[0]["text"]["text"] == "View agent logs"
+ assert actions[0]["url"] == "https://us.posthog.com/project/1/tasks/abc?runId=xyz"
@patch.object(SlackThreadHandler, "_find_progress_message_ts", return_value="1234.9999")
@patch.object(SlackThreadHandler, "_get_client")
diff --git a/products/tasks/backend/temporal/process_task/activities/post_slack_update.py b/products/tasks/backend/temporal/process_task/activities/post_slack_update.py
index 22ee6b06d0d6..29b3202b44b1 100644
--- a/products/tasks/backend/temporal/process_task/activities/post_slack_update.py
+++ b/products/tasks/backend/temporal/process_task/activities/post_slack_update.py
@@ -60,9 +60,6 @@ def post_slack_update(input: PostSlackUpdateInput) -> None:
if creator_has_access
else None
)
- logs_deeplink: str | None = (
- f"posthog-code://task/{task_run.task_id}/run/{task_run.id}" if creator_has_access else None
- )
pr_url = (task_run.output or {}).get("pr_url")
if input.sandbox_cleaned:
@@ -105,7 +102,7 @@ def post_slack_update(input: PostSlackUpdateInput) -> None:
handler.delete_progress()
return
stage = _get_stage_from_status(task_run.status, task_run.stage)
- handler.post_or_update_progress(stage, logs_deeplink)
+ handler.post_or_update_progress(stage, task_url)
except Exception:
logger.exception("post_slack_update_failed", run_id=input.run_id)
diff --git a/products/tasks/backend/tests/test_post_slack_update.py b/products/tasks/backend/tests/test_post_slack_update.py
index 703516f1e09a..b569619e6927 100644
--- a/products/tasks/backend/tests/test_post_slack_update.py
+++ b/products/tasks/backend/tests/test_post_slack_update.py
@@ -116,6 +116,9 @@ class TestPostSlackUpdate(TestCase):
mock_post_progress.assert_called_once()
assert mock_post_progress.call_args[0][0] == "Cloning repository"
+ # The "View agent logs" button links to the cloud task page (works on
+ # mobile) rather than a desktop-only ``posthog-code://`` deep link.
+ assert mock_post_progress.call_args[0][1] == "http://localhost:8000/project/1/tasks/10?runId=run-1"
@patch.object(SlackThreadHandler, "delete_progress")
@patch.object(SlackThreadHandler, "update_reaction")
@@ -383,8 +386,8 @@ class TestPostSlackUpdate(TestCase):
mock_post_completion,
):
# When the task creator is not a PostHog Code user, every handler call
- # receives ``task_url=None`` (and the progress handler receives
- # ``logs_deeplink=None``) so the deep-link / web buttons are skipped.
+ # (including the progress handler) receives ``task_url=None`` so the
+ # web buttons are skipped.
self._access_patcher.stop()
deny_patcher = patch(
"products.tasks.backend.temporal.process_task.activities.post_slack_update.has_tasks_access",