Spaces:
Sleeping
Sleeping
feat(ui): streaming progress updates per pipeline stage in Gradio
Browse files- gradio_app/app.py +36 -21
gradio_app/app.py
CHANGED
|
@@ -625,32 +625,48 @@ async def _run_pipeline(github_url: str):
|
|
| 625 |
|
| 626 |
|
| 627 |
def run_analysis(github_url: str):
|
| 628 |
-
""
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
1 bugs_html
|
| 632 |
-
2 review_html
|
| 633 |
-
3 tests_code
|
| 634 |
-
4 report_md
|
| 635 |
-
5 status_text
|
| 636 |
-
6 score_html
|
| 637 |
-
7 stats_html
|
| 638 |
-
8 refactor_html
|
| 639 |
-
"""
|
| 640 |
if not github_url.strip():
|
| 641 |
-
|
| 642 |
-
return
|
| 643 |
|
| 644 |
url = github_url.strip()
|
| 645 |
if not url.startswith("https://github.com/"):
|
| 646 |
err = _empty_state("β URL must start with https://github.com/")
|
| 647 |
-
|
|
|
|
| 648 |
|
|
|
|
| 649 |
try:
|
| 650 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 651 |
except Exception as e:
|
| 652 |
-
err = _empty_state(f"β
|
| 653 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 654 |
|
| 655 |
m = report.repository
|
| 656 |
i = report.issues
|
|
@@ -796,7 +812,6 @@ def run_analysis(github_url: str):
|
|
| 796 |
</div>
|
| 797 |
"""
|
| 798 |
|
| 799 |
-
# ββ Refactor tab ββ
|
| 800 |
refactor_html = f"""
|
| 801 |
<div class="section-header">Refactor Suggestions</div>
|
| 802 |
{_list_items(rv.refactor_suggestions)}
|
|
@@ -804,7 +819,7 @@ def run_analysis(github_url: str):
|
|
| 804 |
|
| 805 |
status_text = f"β Analysis complete β {m.name} Β· {m.language} Β· score {score}/10"
|
| 806 |
|
| 807 |
-
|
| 808 |
overview_html,
|
| 809 |
bugs_html,
|
| 810 |
review_html,
|
|
@@ -924,7 +939,7 @@ with gr.Blocks(css=CSS, title="AI Code Review Agent", theme=gr.themes.Base()) as
|
|
| 924 |
stats_state,
|
| 925 |
refactor_out,
|
| 926 |
],
|
| 927 |
-
show_progress="
|
| 928 |
)
|
| 929 |
|
| 930 |
if __name__ == "__main__":
|
|
|
|
| 625 |
|
| 626 |
|
| 627 |
def run_analysis(github_url: str):
|
| 628 |
+
empty = _empty_state("Run analysis to see results.")
|
| 629 |
+
empty_defaults = (empty, empty, empty, "", "# No report yet.", "", empty, "", "")
|
| 630 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 631 |
if not github_url.strip():
|
| 632 |
+
yield (_empty_state("Enter a GitHub URL above to get started."),) + empty_defaults[1:]
|
| 633 |
+
return
|
| 634 |
|
| 635 |
url = github_url.strip()
|
| 636 |
if not url.startswith("https://github.com/"):
|
| 637 |
err = _empty_state("β URL must start with https://github.com/")
|
| 638 |
+
yield (err, err, err, "", "# Invalid URL", "β Invalid GitHub URL.", "", "", err)
|
| 639 |
+
return
|
| 640 |
|
| 641 |
+
local_path = None
|
| 642 |
try:
|
| 643 |
+
# Step 1 β clone
|
| 644 |
+
yield empty_defaults[:5] + ("β³ [1/5] Cloning repository...",) + empty_defaults[6:]
|
| 645 |
+
local_path = clone_repository(url)
|
| 646 |
+
|
| 647 |
+
# Step 2 β repo analysis
|
| 648 |
+
yield empty_defaults[:5] + ("β³ [2/5] Analysing repository structure...",) + empty_defaults[6:]
|
| 649 |
+
metadata = asyncio.run(repo_analysis_agent.run(url, local_path))
|
| 650 |
+
|
| 651 |
+
# Step 3 β parallel agents
|
| 652 |
+
yield empty_defaults[:5] + ("β³ [3/5] Running bug detection, test generation and code review in parallel...",) + empty_defaults[6:]
|
| 653 |
+
issues, tests, review = asyncio.run(asyncio.gather(
|
| 654 |
+
bug_detection_agent.run(local_path),
|
| 655 |
+
test_generation_agent.run(local_path),
|
| 656 |
+
code_review_agent.run(local_path, metadata),
|
| 657 |
+
))
|
| 658 |
+
|
| 659 |
+
# Step 4 β report
|
| 660 |
+
yield empty_defaults[:5] + ("β³ [4/5] Generating engineering report...",) + empty_defaults[6:]
|
| 661 |
+
report = asyncio.run(report_generator_agent.run(metadata, issues, tests, review))
|
| 662 |
+
|
| 663 |
except Exception as e:
|
| 664 |
+
err = _empty_state(f"β {e}")
|
| 665 |
+
yield (err, err, err, "", f"# Error\n\n```\n{e}\n```", f"β {e}", "", "", err)
|
| 666 |
+
return
|
| 667 |
+
finally:
|
| 668 |
+
if local_path:
|
| 669 |
+
delete_repository(local_path)
|
| 670 |
|
| 671 |
m = report.repository
|
| 672 |
i = report.issues
|
|
|
|
| 812 |
</div>
|
| 813 |
"""
|
| 814 |
|
|
|
|
| 815 |
refactor_html = f"""
|
| 816 |
<div class="section-header">Refactor Suggestions</div>
|
| 817 |
{_list_items(rv.refactor_suggestions)}
|
|
|
|
| 819 |
|
| 820 |
status_text = f"β Analysis complete β {m.name} Β· {m.language} Β· score {score}/10"
|
| 821 |
|
| 822 |
+
yield (
|
| 823 |
overview_html,
|
| 824 |
bugs_html,
|
| 825 |
review_html,
|
|
|
|
| 939 |
stats_state,
|
| 940 |
refactor_out,
|
| 941 |
],
|
| 942 |
+
show_progress="hidden",
|
| 943 |
)
|
| 944 |
|
| 945 |
if __name__ == "__main__":
|