From 6c79e465fad1119e15e2d4b31691d541e94209e3 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 1 Jul 2026 10:03:37 +0000 Subject: [PATCH 1/4] test(emitters): cover domain guidance branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mehmet Özel --- tests/test_emitters_utils.py | 71 +++++++++++++++++++++++++++++++++++ tests/test_expanded_prompt.py | 12 ++++++ 2 files changed, 83 insertions(+) diff --git a/tests/test_emitters_utils.py b/tests/test_emitters_utils.py index c7765412..c583a06c 100644 --- a/tests/test_emitters_utils.py +++ b/tests/test_emitters_utils.py @@ -6,11 +6,15 @@ from __future__ import annotations +from types import SimpleNamespace + from app.emitters import ( _clean_domain_suggestion_text, _contains_any_marker, _is_trivial_input, _minimal_greeting_prompt, + _relevant_followups, + _scenario_considerations, ) @@ -133,3 +137,70 @@ def test_whitespace_normalized(self) -> None: def test_ok_prefix_stripped_before_use(self) -> None: assert _clean_domain_suggestion_text("Ok: Use type hints") == "Use type hints" + + +class TestScenarioConsiderations: + """Route conservative scenario guidance only when the right signals appear.""" + + def test_browser_download_requires_browser_and_download_signals(self) -> None: + ir = SimpleNamespace( + goals=["Make Safari download a CSV export instead of opening it inline"], + tasks=[], + ) + + considerations = _scenario_considerations(ir) + + assert len(considerations) == 2 + assert "Blob + an link" in considerations[0] + assert "File System Access API is unsupported in Safari" in considerations[1] + + def test_browser_download_does_not_trigger_without_browser_signal(self) -> None: + ir = SimpleNamespace( + goals=["Add a CSV export so users can download monthly reports"], + tasks=[], + ) + + assert _scenario_considerations(ir) == [] + + def test_react_perf_requires_react_and_perf_markers(self) -> None: + ir = SimpleNamespace( + goals=["My React list is slow and re-renders too much when filters change"], + tasks=[], + ) + + considerations = _scenario_considerations(ir) + + assert len(considerations) == 2 + assert "React DevTools Profiler" in considerations[0] + assert "virtualize long lists" in considerations[1] + + +class TestRelevantFollowups: + """Choose the most useful follow-up question set for the prompt context.""" + + def test_react_perf_prompt_prefers_perf_followups_over_browser_keywords(self) -> None: + ir = SimpleNamespace( + goals=["My React button re-renders constantly and the page feels slow"], + tasks=[], + intents=[], + domain="software", + ) + + followups = _relevant_followups(ir) + + assert len(followups) == 3 + assert "React DevTools Profiler" in followups[0] + assert "Which browser and version is affected" not in "\n".join(followups) + + def test_browser_bug_prompt_gets_browser_followups(self) -> None: + ir = SimpleNamespace( + goals=["This Chrome button renders in the wrong place after click"], + tasks=[], + intents=[], + domain="software", + ) + + followups = _relevant_followups(ir) + + assert len(followups) == 3 + assert followups[0].startswith("Which browser and version is affected") diff --git a/tests/test_expanded_prompt.py b/tests/test_expanded_prompt.py index f3f206b7..3398c661 100644 --- a/tests/test_expanded_prompt.py +++ b/tests/test_expanded_prompt.py @@ -13,6 +13,18 @@ def test_expanded_prompt_contains_input_and_example(): assert ("Örnek çıktı formatı" in ep) or ("Example output format" in ep) +def test_expanded_prompt_surfaces_react_perf_domain_guidance(): + ir = compile_text("My React table re-renders too much and feels slow with large lists") + + ep = emit_expanded_prompt(ir) + + assert "Key considerations:" in ep + assert "React DevTools Profiler" in ep + assert "virtualize long lists" in ep + assert "Follow-up Questions:" in ep + assert "Have you profiled it" in ep + + def test_expanded_prompt_v2_surfaces_clarification_questions_without_diagnostics(monkeypatch): monkeypatch.setenv("PROMPT_COMPILER_MODE", "conservative") ir2 = compile_text_v2("Optimize this API and make it better", offline_only=True) From 759558725a267590a2288601b288597613c04ba9 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 1 Jul 2026 10:04:40 +0000 Subject: [PATCH 2/4] test(expanded-prompt): target v2 domain guidance path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mehmet Özel --- tests/test_expanded_prompt.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_expanded_prompt.py b/tests/test_expanded_prompt.py index 3398c661..b5d2f0ec 100644 --- a/tests/test_expanded_prompt.py +++ b/tests/test_expanded_prompt.py @@ -13,10 +13,13 @@ def test_expanded_prompt_contains_input_and_example(): assert ("Örnek çıktı formatı" in ep) or ("Example output format" in ep) -def test_expanded_prompt_surfaces_react_perf_domain_guidance(): - ir = compile_text("My React table re-renders too much and feels slow with large lists") +def test_expanded_prompt_v2_surfaces_react_perf_domain_guidance(): + ir = compile_text_v2( + "My React table re-renders too much and feels slow with large lists", + offline_only=True, + ) - ep = emit_expanded_prompt(ir) + ep = emit_expanded_prompt_v2(ir, diagnostics=False) assert "Key considerations:" in ep assert "React DevTools Profiler" in ep From 41fd3dfd1ae87ec589af9ba8dc62136f4c6d0c96 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 1 Jul 2026 10:08:07 +0000 Subject: [PATCH 3/4] fix(emitters): avoid generic optimize perf followups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mehmet Özel --- app/emitters.py | 1 - tests/test_emitters_utils.py | 14 ++++++++++++++ tests/test_expanded_prompt.py | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/emitters.py b/app/emitters.py index f5053f5e..e0da71ea 100644 --- a/app/emitters.py +++ b/app/emitters.py @@ -172,7 +172,6 @@ def _relevant_followups(ir) -> list[str]: "performance", "perf", "memo", - "optimi", "latency", "fps", "profil", diff --git a/tests/test_emitters_utils.py b/tests/test_emitters_utils.py index c583a06c..4604a70e 100644 --- a/tests/test_emitters_utils.py +++ b/tests/test_emitters_utils.py @@ -204,3 +204,17 @@ def test_browser_bug_prompt_gets_browser_followups(self) -> None: assert len(followups) == 3 assert followups[0].startswith("Which browser and version is affected") + + def test_generic_api_optimization_prompt_falls_back_to_software_followups(self) -> None: + ir = SimpleNamespace( + goals=["Optimize this API and make it better"], + tasks=[], + intents=[], + domain="software", + ) + + followups = _relevant_followups(ir) + + assert len(followups) == 3 + assert followups[0] == "Which language, framework, and version are targeted?" + assert "React DevTools Profiler" not in "\n".join(followups) diff --git a/tests/test_expanded_prompt.py b/tests/test_expanded_prompt.py index b5d2f0ec..cb87d508 100644 --- a/tests/test_expanded_prompt.py +++ b/tests/test_expanded_prompt.py @@ -37,6 +37,8 @@ def test_expanded_prompt_v2_surfaces_clarification_questions_without_diagnostics assert "Clarification Questions:" in ep assert "Which metric or aspect should be optimized?" in ep assert "Better in what sense" in ep + assert "Have you profiled it (e.g. React DevTools Profiler)" not in ep + assert "Which language, framework, and version are targeted?" in ep def test_inferred_coding_best_practices_are_optional_not_constraints(monkeypatch): From 4b7b18f12f57b0fe33b3dabc296dfc636b6d100d Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 1 Jul 2026 15:16:49 +0000 Subject: [PATCH 4/4] test(emitters): update browser download tests for new heuristic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adapt scenario consideration tests to match the stricter detect_frontend_download_feature logic from #912. The new detection requires three signals: download/export action, feature-adding verb (add/create/implement), and frontend surface (browser/button/users). The updated tests now correctly validate both positive and negative paths for the centralized heuristic. Co-authored-by: Mehmet Özel --- tests/test_emitters_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_emitters_utils.py b/tests/test_emitters_utils.py index 4604a70e..4abdadea 100644 --- a/tests/test_emitters_utils.py +++ b/tests/test_emitters_utils.py @@ -142,9 +142,9 @@ def test_ok_prefix_stripped_before_use(self) -> None: class TestScenarioConsiderations: """Route conservative scenario guidance only when the right signals appear.""" - def test_browser_download_requires_browser_and_download_signals(self) -> None: + def test_browser_download_requires_all_three_signals(self) -> None: ir = SimpleNamespace( - goals=["Make Safari download a CSV export instead of opening it inline"], + goals=["Add a button so users can download CSV exports from the dashboard"], tasks=[], ) @@ -154,9 +154,9 @@ def test_browser_download_requires_browser_and_download_signals(self) -> None: assert "Blob + an link" in considerations[0] assert "File System Access API is unsupported in Safari" in considerations[1] - def test_browser_download_does_not_trigger_without_browser_signal(self) -> None: + def test_browser_download_does_not_trigger_without_feature_adding_verb(self) -> None: ir = SimpleNamespace( - goals=["Add a CSV export so users can download monthly reports"], + goals=["Fix the Safari CSV download that opens inline instead of saving"], tasks=[], )