From 4eda639cca499c92abf393b7e80e4816440e0c12 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2026 16:58:17 +0000 Subject: [PATCH] ref(agent-handoff): Remove unused flow previews The public guide preview mode was removed in #131499, so nothing calls Flow.preview() anymore. Drop it from every flow and inline the render helpers that only existed to share a template between render and preview. Co-Authored-By: Evan Purkhiser <1421724+evanpurkhiser@users.noreply.github.com> --- src/sentry/agent_handoff/flows/add_feature.py | 16 ++-------- src/sentry/agent_handoff/flows/base.py | 4 --- .../agent_handoff/flows/create_project.py | 13 ++------ .../agent_handoff/flows/guided_next_steps.py | 3 -- src/sentry/agent_handoff/flows/onboarding.py | 13 ++------ tests/sentry/agent_handoff/test_runbook.py | 31 ++++++------------- 6 files changed, 18 insertions(+), 62 deletions(-) diff --git a/src/sentry/agent_handoff/flows/add_feature.py b/src/sentry/agent_handoff/flows/add_feature.py index 73df8e67a93f..be9309c1de85 100644 --- a/src/sentry/agent_handoff/flows/add_feature.py +++ b/src/sentry/agent_handoff/flows/add_feature.py @@ -67,17 +67,7 @@ def render(self, context: object, *, user_id: int, organization_id: int) -> str: ) if project is None: raise InvalidHandoffContext("Project is unavailable") - return render_add_feature_runbook(product=parsed.product, project_slug=project.slug) - - def preview(self) -> str: - return render_add_feature_runbook( - product=AddFeatureProduct.TRACING, - project_slug="example-project", + return MARKDOWN_JINJA_ENV.get_template("sentry/agent_handoff/add_feature.md").render( + product=parsed.product, + project_slug=escape_label(project.slug), ) - - -def render_add_feature_runbook(*, product: AddFeatureProduct, project_slug: str) -> str: - return MARKDOWN_JINJA_ENV.get_template("sentry/agent_handoff/add_feature.md").render( - product=product, - project_slug=escape_label(project_slug), - ) diff --git a/src/sentry/agent_handoff/flows/base.py b/src/sentry/agent_handoff/flows/base.py index 1ac40f0f6ad1..90c0ee1c5473 100644 --- a/src/sentry/agent_handoff/flows/base.py +++ b/src/sentry/agent_handoff/flows/base.py @@ -18,7 +18,3 @@ def get_context_serializer(self) -> type[BaseSerializer[Context]] | None: @abstractmethod def render(self, context: object, *, user_id: int, organization_id: int) -> str: pass - - @abstractmethod - def preview(self) -> str: - pass diff --git a/src/sentry/agent_handoff/flows/create_project.py b/src/sentry/agent_handoff/flows/create_project.py index 8fc8153d1742..829287e3cd94 100644 --- a/src/sentry/agent_handoff/flows/create_project.py +++ b/src/sentry/agent_handoff/flows/create_project.py @@ -17,13 +17,6 @@ def render(self, context: object, *, user_id: int, organization_id: int) -> str: if issued is None: raise InvalidHandoffContext("Project setup run is unavailable") - return render_create_project_runbook(run_code=issued.code) - - def preview(self) -> str: - return render_create_project_runbook(run_code="") - - -def render_create_project_runbook(*, run_code: str) -> str: - return MARKDOWN_JINJA_ENV.get_template("sentry/agent_handoff/create_project.md").render( - run_code=run_code - ) + return MARKDOWN_JINJA_ENV.get_template("sentry/agent_handoff/create_project.md").render( + run_code=issued.code + ) diff --git a/src/sentry/agent_handoff/flows/guided_next_steps.py b/src/sentry/agent_handoff/flows/guided_next_steps.py index 251c1522bf5f..db2e0c4b86dd 100644 --- a/src/sentry/agent_handoff/flows/guided_next_steps.py +++ b/src/sentry/agent_handoff/flows/guided_next_steps.py @@ -3,7 +3,4 @@ class GuidedNextStepsFlow(Flow[None]): def render(self, context: object, *, user_id: int, organization_id: int) -> str: - return self.preview() - - def preview(self) -> str: return "Now ask the user what they would like to do next." diff --git a/src/sentry/agent_handoff/flows/onboarding.py b/src/sentry/agent_handoff/flows/onboarding.py index 452ab4c9dfee..0af9943c9977 100644 --- a/src/sentry/agent_handoff/flows/onboarding.py +++ b/src/sentry/agent_handoff/flows/onboarding.py @@ -17,13 +17,6 @@ def render(self, context: object, *, user_id: int, organization_id: int) -> str: if issued is None: raise InvalidHandoffContext("Onboarding run is unavailable") - return render_onboarding_runbook(run_code=issued.code) - - def preview(self) -> str: - return render_onboarding_runbook(run_code="") - - -def render_onboarding_runbook(*, run_code: str) -> str: - return MARKDOWN_JINJA_ENV.get_template("sentry/agent_handoff/onboarding.md").render( - run_code=run_code - ) + return MARKDOWN_JINJA_ENV.get_template("sentry/agent_handoff/onboarding.md").render( + run_code=issued.code + ) diff --git a/tests/sentry/agent_handoff/test_runbook.py b/tests/sentry/agent_handoff/test_runbook.py index e15032018482..a769a2a7ecce 100644 --- a/tests/sentry/agent_handoff/test_runbook.py +++ b/tests/sentry/agent_handoff/test_runbook.py @@ -93,15 +93,6 @@ def test_create_project_claim_rejects_unavailable_run() -> None: ) -def test_onboarding_preview_does_not_issue_reporting_code() -> None: - with patch( - "sentry.agent_handoff.flows.onboarding.organization_service.issue_onboarding_reporting_code" - ) as issue: - guide = get_flow(HandoffFlow.ONBOARDING).preview() - assert "" in guide - issue.assert_not_called() - - def test_onboarding_claim_rejects_unavailable_run() -> None: with ( patch( @@ -125,7 +116,10 @@ def test_onboarding_claim_requires_run_context() -> None: def test_guided_next_steps_claim() -> None: flow = get_flow(HandoffFlow.GUIDED_NEXT_STEPS) assert flow.get_context_serializer() is None - assert flow.render(None, user_id=1, organization_id=2) == flow.preview() + assert ( + flow.render(None, user_id=1, organization_id=2) + == "Now ask the user what they would like to do next." + ) def test_onboarding_context_serializer_validates_run_without_issuing_code() -> None: @@ -150,15 +144,6 @@ def test_onboarding_context_serializer_validates_run_without_issuing_code() -> N issue.assert_not_called() -def test_add_feature_preview_uses_instrument_guide() -> None: - guide = get_flow(HandoffFlow.ADD_FEATURE).preview() - assert "add tracing to a project" in guide - assert "Project slug: example\\-project" in guide - assert "https://docs.sentry.io/index.md" in guide - assert "(https://docs.sentry.io/ai/agent-setup/instrument.md), both with `curl -sS`" in guide - assert "add only tracing" in guide - - def test_add_feature_claim_renders_product_and_project() -> None: context = AddFeatureContext(product=AddFeatureProduct.TRACING, project_id=99) with patch( @@ -166,9 +151,11 @@ def test_add_feature_claim_renders_product_and_project() -> None: return_value=RpcProject(id=99, slug="checkout-web", organization_id=2), ): guide = get_flow(HandoffFlow.ADD_FEATURE).render(context, user_id=1, organization_id=2) - assert "instrument.md" in guide - assert "checkout\\-web" in guide - assert "tracing" in guide + assert "add tracing to a project" in guide + assert "Project slug: checkout\\-web" in guide + assert "https://docs.sentry.io/index.md" in guide + assert "(https://docs.sentry.io/ai/agent-setup/instrument.md), both with `curl -sS`" in guide + assert "add only tracing" in guide assert "run code" not in guide