Skip to content

Commit 6ee3458

Browse files
Saga4claude
andcommitted
feat: language-aware PR descriptions for JS/TS
- TestType.to_name() now accepts language parameter; JS/TS shows only relevant test types (Existing Tests, Generated Tests) instead of Python-specific ones (Replay Tests, Concolic Coverage Tests) - PrComment carries language field through to cf-api for code block syntax and test report formatting - Console syntax highlighting uses typescript for JS/TS instead of hardcoded python Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a46b79b commit 6ee3458

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

codeflash/github/PrComment.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ class PrComment:
2323
benchmark_details: Optional[list[BenchmarkDetail]] = None
2424
original_async_throughput: Optional[int] = None
2525
best_async_throughput: Optional[int] = None
26+
language: str = "python"
2627

2728
def to_json(self) -> dict[str, Union[str, int, dict[str, dict[str, int]], list[BenchmarkDetail], None]]:
2829
report_table: dict[str, dict[str, int]] = {}
2930
for test_type, counts in self.winning_behavior_test_results.get_test_pass_fail_report_by_type().items():
30-
name = test_type.to_name()
31+
name = test_type.to_name(self.language)
3132
if name:
3233
report_table[name] = counts
3334

@@ -42,6 +43,7 @@ def to_json(self) -> dict[str, Union[str, int, dict[str, dict[str, int]], list[B
4243
"loop_count": self.winning_benchmarking_test_results.number_of_loops(),
4344
"report_table": report_table,
4445
"benchmark_details": self.benchmark_details if self.benchmark_details else None,
46+
"language": self.language,
4547
}
4648

4749
if self.original_async_throughput is not None and self.best_async_throughput is not None:

codeflash/models/test_type.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ class TestType(Enum):
99
CONCOLIC_COVERAGE_TEST = 5
1010
INIT_STATE_TEST = 6
1111

12-
def to_name(self) -> str:
12+
def to_name(self, language: str = "python") -> str:
13+
if language in ("javascript", "typescript"):
14+
return _JS_TS_NAME_MAP.get(self, "")
1315
return _TO_NAME_MAP.get(self, "")
1416

1517

@@ -20,3 +22,8 @@ def to_name(self) -> str:
2022
TestType.REPLAY_TEST: "⏪ Replay Tests",
2123
TestType.CONCOLIC_COVERAGE_TEST: "🔎 Concolic Coverage Tests",
2224
}
25+
26+
_JS_TS_NAME_MAP: dict[TestType, str] = {
27+
TestType.EXISTING_UNIT_TEST: "⚙️ Existing Tests",
28+
TestType.GENERATED_REGRESSION: "🌀 Generated Tests",
29+
}

codeflash/optimization/function_optimizer.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,10 +1394,13 @@ def log_successful_optimization(
13941394
)
13951395

13961396
if self.args.no_pr:
1397+
syntax_lang = (
1398+
"typescript" if self.function_to_optimize.language in ("javascript", "typescript") else "python"
1399+
)
13971400
tests_panel = Panel(
13981401
Syntax(
13991402
"\n".join([test.generated_original_test_source for test in generated_tests.generated_tests]),
1400-
"python",
1403+
syntax_lang,
14011404
line_numbers=True,
14021405
),
14031406
title="Validated Tests",
@@ -2227,9 +2230,7 @@ def process_review(
22272230
if "root_dir" not in data:
22282231
data["root_dir"] = git_root_dir(GitRepo(str(self.args.module_root), search_parent_directories=True))
22292232
data["git_remote"] = self.args.git_remote
2230-
# Remove language from data dict as check_create_pr doesn't accept it
2231-
pr_data = {k: v for k, v in data.items() if k != "language"}
2232-
check_create_pr(**pr_data)
2233+
check_create_pr(**data)
22332234
elif staging_review:
22342235
response = create_staging(**data)
22352236
if response.status_code == 200:

0 commit comments

Comments
 (0)