@@ -848,10 +848,14 @@ def handle_successful_candidate(
848848
849849 Returns the BestOptimization and optional benchmark tree.
850850 """
851- with progress_bar ("Running line-by-line profiling" ):
852- line_profile_test_results = self .line_profiler_step (
853- code_context = code_context , original_helper_code = original_helper_code , candidate_index = candidate_index
854- )
851+ # Skip line profiling for JavaScript/TypeScript until implementation is ready
852+ if self .function_to_optimize .language in ("javascript" , "typescript" ):
853+ line_profile_test_results = {"timings" : {}, "unit" : 0 , "str_out" : "" }
854+ else :
855+ with progress_bar ("Running line-by-line profiling" ):
856+ line_profile_test_results = self .line_profiler_step (
857+ code_context = code_context , original_helper_code = original_helper_code , candidate_index = candidate_index
858+ )
855859
856860 eval_ctx .record_line_profiler_result (candidate .optimization_id , line_profile_test_results ["str_out" ])
857861
@@ -1314,13 +1318,15 @@ def repair_optimization(
13141318 optimization_id : str ,
13151319 ai_service_client : AiServiceClient ,
13161320 executor : concurrent .futures .ThreadPoolExecutor ,
1321+ language : str = "python" ,
13171322 ) -> concurrent .futures .Future [OptimizedCandidate | None ]:
13181323 request = AIServiceCodeRepairRequest (
13191324 optimization_id = optimization_id ,
13201325 original_source_code = original_source_code ,
13211326 modified_source_code = modified_source_code ,
13221327 test_diffs = test_diffs ,
13231328 trace_id = trace_id ,
1329+ language = language ,
13241330 )
13251331 return executor .submit (ai_service_client .code_repair , request = request )
13261332
@@ -2016,6 +2022,7 @@ def process_review(
20162022 "coverage_message" : coverage_message ,
20172023 "replay_tests" : replay_tests ,
20182024 "concolic_tests" : concolic_tests ,
2025+ "language" : self .function_to_optimize .language ,
20192026 }
20202027
20212028 raise_pr = not self .args .no_pr
@@ -2058,7 +2065,9 @@ def process_review(
20582065 if "root_dir" not in data :
20592066 data ["root_dir" ] = git_root_dir ()
20602067 data ["git_remote" ] = self .args .git_remote
2061- check_create_pr (** data )
2068+ # Remove language from data dict as check_create_pr doesn't accept it
2069+ pr_data = {k : v for k , v in data .items () if k != "language" }
2070+ check_create_pr (** pr_data )
20622071 elif staging_review :
20632072 response = create_staging (** data )
20642073 if response .status_code == 200 :
@@ -2178,7 +2187,7 @@ def establish_original_code_baseline(
21782187
21792188 # Skip line profiler for JavaScript/TypeScript (not yet supported)
21802189 if self .function_to_optimize .language in ("javascript" , "typescript" ):
2181- line_profile_results = None
2190+ line_profile_results = { "timings" : {}, "unit" : 0 , "str_out" : "" }
21822191 else :
21832192 with progress_bar ("Running line profiler to identify performance bottlenecks..." ):
21842193 line_profile_results = self .line_profiler_step (
@@ -2318,6 +2327,7 @@ def repair_if_possible(
23182327 ai_service_client = ai_service_client ,
23192328 optimization_id = candidate .optimization_id ,
23202329 executor = self .executor ,
2330+ language = self .function_to_optimize .language ,
23212331 )
23222332 )
23232333
@@ -2386,17 +2396,25 @@ def run_optimized_candidate(
23862396
23872397 # Use language-appropriate comparison
23882398 if self .function_to_optimize .language in ("javascript" , "typescript" ):
2389- # JavaScript: Compare using Node.js script (handles Map, Set, Date, etc. natively)
2390- from codeflash .verification .equivalence import compare_javascript_test_results
2391- from codeflash .code_utils .code_utils import get_run_tmp_file
2392-
2399+ # JavaScript: Compare using SQLite results if available, otherwise compare test pass/fail
23932400 original_sqlite = get_run_tmp_file (Path ("test_return_values_0.sqlite" ))
23942401 candidate_sqlite = get_run_tmp_file (Path (f"test_return_values_{ optimization_candidate_index } .sqlite" ))
2395- match , diffs = compare_javascript_test_results (original_sqlite , candidate_sqlite )
23962402
2397- # Cleanup SQLite files after comparison (deferred from parse_test_results)
2398- candidate_sqlite .unlink (missing_ok = True )
2399- # Keep original_sqlite for comparing with other candidates
2403+ if original_sqlite .exists () and candidate_sqlite .exists ():
2404+ # Full comparison using captured return values
2405+ from codeflash .verification .equivalence import compare_javascript_test_results
2406+
2407+ match , diffs = compare_javascript_test_results (original_sqlite , candidate_sqlite )
2408+ # Cleanup SQLite files after comparison
2409+ candidate_sqlite .unlink (missing_ok = True )
2410+ else :
2411+ # Fallback: compare test pass/fail status (tests aren't instrumented yet)
2412+ # If all tests that passed for original also pass for candidate, consider it a match
2413+ if not candidate_sqlite .exists ():
2414+ logger .error (f"Candidate SQLite database not found: { candidate_sqlite } " )
2415+ logger .debug ("No diffs found, skipping repair" )
2416+ # Use Python-style comparison on TestResults as fallback
2417+ match , diffs = compare_test_results (baseline_results .behavior_test_results , candidate_behavior_results )
24002418 else :
24012419 # Python: Compare using Python comparator
24022420 match , diffs = compare_test_results (baseline_results .behavior_test_results , candidate_behavior_results )
@@ -2503,6 +2521,8 @@ def run_and_parse_tests(
25032521 test_env = test_env ,
25042522 pytest_timeout = INDIVIDUAL_TESTCASE_TIMEOUT ,
25052523 enable_coverage = enable_coverage ,
2524+ js_project_root = self .test_cfg .js_project_root ,
2525+ candidate_index = optimization_iteration ,
25062526 )
25072527 elif testing_type == TestingMode .LINE_PROFILE :
25082528 result_file_path , run_result = run_line_profile_tests (
@@ -2527,6 +2547,7 @@ def run_and_parse_tests(
25272547 pytest_min_loops = pytest_min_loops ,
25282548 pytest_max_loops = pytest_max_loops ,
25292549 test_framework = self .test_cfg .test_framework ,
2550+ js_project_root = self .test_cfg .js_project_root ,
25302551 )
25312552 else :
25322553 msg = f"Unexpected testing type: { testing_type } "
0 commit comments