Spaces:
Sleeping
Sleeping
Refine workflow UI readability and scoring
Browse files- app.py +335 -77
- tests/test_app_ui.py +66 -8
app.py
CHANGED
|
@@ -54,16 +54,54 @@ from course_slide_factory.models import ArtifactStatus, IssueSeverity, IssueStat
|
|
| 54 |
|
| 55 |
|
| 56 |
CSS = """
|
|
|
|
|
|
|
|
|
|
| 57 |
body,
|
| 58 |
.gradio-container {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
background: #f7f8fa !important;
|
| 60 |
color: #111827 !important;
|
| 61 |
}
|
| 62 |
.gradio-container { max-width: 1540px !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
.gradio-container label,
|
| 64 |
.gradio-container span,
|
| 65 |
-
.gradio-container p
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
}
|
| 68 |
.gradio-container input,
|
| 69 |
.gradio-container textarea,
|
|
@@ -73,20 +111,65 @@ body,
|
|
| 73 |
color: #111827 !important;
|
| 74 |
}
|
| 75 |
textarea, .cm-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
.compact-panel table { font-size: 12px; }
|
| 77 |
.compact-panel table,
|
| 78 |
.compact-panel thead,
|
| 79 |
.compact-panel tbody,
|
| 80 |
.compact-panel tr,
|
| 81 |
.compact-panel th,
|
| 82 |
-
.compact-panel td
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
background: #ffffff !important;
|
| 84 |
color: #111827 !important;
|
|
|
|
| 85 |
}
|
| 86 |
-
.compact-panel th
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
color: #374151 !important;
|
| 88 |
font-weight: 700 !important;
|
| 89 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
.workflow-topbar {
|
| 91 |
position: sticky;
|
| 92 |
top: 0;
|
|
@@ -230,6 +313,30 @@ textarea, .cm-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco,
|
|
| 230 |
min-height: 42px;
|
| 231 |
white-space: normal !important;
|
| 232 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
.screen-card {
|
| 234 |
border: 1px solid #d9dee7;
|
| 235 |
border-radius: 8px;
|
|
@@ -347,6 +454,21 @@ textarea, .cm-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco,
|
|
| 347 |
.stage-result-panel {
|
| 348 |
margin-top: 14px;
|
| 349 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 350 |
.stage-result-card {
|
| 351 |
border: 1px solid #d9dee7;
|
| 352 |
border-left: 5px solid #64748b;
|
|
@@ -380,6 +502,28 @@ textarea, .cm-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco,
|
|
| 380 |
line-height: 1;
|
| 381 |
margin-top: 8px;
|
| 382 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
@media (max-width: 900px) {
|
| 384 |
.workflow-title-row,
|
| 385 |
.workflow-metrics {
|
|
@@ -524,10 +668,10 @@ def render_activity_message(message: str, status: str = "complete") -> str:
|
|
| 524 |
)
|
| 525 |
|
| 526 |
|
| 527 |
-
def
|
| 528 |
if not message:
|
| 529 |
-
return gr.update(
|
| 530 |
-
return gr.update(
|
| 531 |
|
| 532 |
|
| 533 |
def _activity_status_for_message(message: str) -> str:
|
|
@@ -543,18 +687,31 @@ def pending_activity_message(message: str) -> str:
|
|
| 543 |
return render_activity_message(message, "pending")
|
| 544 |
|
| 545 |
|
| 546 |
-
def
|
| 547 |
-
return
|
| 548 |
|
| 549 |
|
| 550 |
-
|
| 551 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 552 |
score = stage.score
|
|
|
|
| 553 |
if score is None:
|
| 554 |
-
return """
|
| 555 |
<div class="stage-result-card">
|
| 556 |
-
<h4>
|
| 557 |
-
<p>Run
|
| 558 |
<div class="stage-result-score">Pending</div>
|
| 559 |
</div>
|
| 560 |
"""
|
|
@@ -562,13 +719,17 @@ def render_setup_score_panel(state) -> str:
|
|
| 562 |
result_text = "Ready to continue" if score >= PASSING_STAGE_SCORE else "Needs review before continuing"
|
| 563 |
return f"""
|
| 564 |
<div class="stage-result-card {result_class}">
|
| 565 |
-
<h4>
|
| 566 |
<p>{_escape(result_text)}</p>
|
| 567 |
<div class="stage-result-score">{score}/100</div>
|
| 568 |
</div>
|
| 569 |
"""
|
| 570 |
|
| 571 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 572 |
def _human_label(value: object) -> str:
|
| 573 |
return str(value).replace("_", " ").strip().capitalize()
|
| 574 |
|
|
@@ -584,15 +745,15 @@ def _human_scalar(value: object) -> str:
|
|
| 584 |
def _artifact_header(state, stage_id: str) -> list[str]:
|
| 585 |
artifact = get_current_stage_artifact(stage_id, state)
|
| 586 |
if artifact is None:
|
| 587 |
-
return [f"{STAGE_LABELS[stage_id]} output", "", "No candidate has been created for this stage yet."]
|
| 588 |
score = state.stages[stage_id].score
|
| 589 |
score_text = "Not scored yet" if score is None else f"{score}/100"
|
| 590 |
return [
|
| 591 |
-
f"{STAGE_LABELS[stage_id]} output",
|
| 592 |
"",
|
| 593 |
-
f"Artifact: {artifact.artifact_version_id}",
|
| 594 |
-
f"Status: {_human_label(artifact.status.value)}",
|
| 595 |
-
f"Score: {score_text}",
|
| 596 |
]
|
| 597 |
|
| 598 |
|
|
@@ -676,7 +837,7 @@ def _format_generic_value(value: Any, indent: int = 0) -> list[str]:
|
|
| 676 |
return [f"{prefix}{_human_scalar(value)}"]
|
| 677 |
|
| 678 |
|
| 679 |
-
def
|
| 680 |
stage_id = _safe_stage_id(stage_id)
|
| 681 |
artifact = get_current_stage_artifact(stage_id, state)
|
| 682 |
lines = _artifact_header(state, stage_id)
|
|
@@ -737,6 +898,21 @@ def readable_current_artifact_text(state, stage_id: str) -> str:
|
|
| 737 |
return "\n".join(lines)
|
| 738 |
|
| 739 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 740 |
def _is_unresolved_issue(issue) -> bool:
|
| 741 |
return issue.status not in RESOLVED_ISSUE_STATUSES and not issue.resolved
|
| 742 |
|
|
@@ -902,7 +1078,7 @@ def _render_chrome_outputs(state, active_stage_id: str):
|
|
| 902 |
return (
|
| 903 |
render_workflow_header(state, active_stage_id),
|
| 904 |
render_stage_score_strip(state, active_stage_id),
|
| 905 |
-
|
| 906 |
*stage_visibility_updates(active_stage_id),
|
| 907 |
*workspace_visibility_updates(active_stage_id),
|
| 908 |
*stage_step_button_updates(active_stage_id),
|
|
@@ -1065,8 +1241,9 @@ def _render_outputs(
|
|
| 1065 |
state_json = json.dumps(state_to_dict(state), indent=2, sort_keys=True)
|
| 1066 |
return (
|
| 1067 |
state_to_dict(state),
|
| 1068 |
-
|
| 1069 |
-
|
|
|
|
| 1070 |
current_artifact_diff(state, stage_id),
|
| 1071 |
lock_reasons,
|
| 1072 |
deck_health_table(state),
|
|
@@ -1546,7 +1723,8 @@ def build_app() -> gr.Blocks:
|
|
| 1546 |
|
| 1547 |
with gr.Row():
|
| 1548 |
with gr.Column(scale=2):
|
| 1549 |
-
|
|
|
|
| 1550 |
with gr.Column(scale=1, min_width=240):
|
| 1551 |
reviewer_name = gr.Textbox(label="Reviewer", value="human_reviewer")
|
| 1552 |
|
|
@@ -1607,21 +1785,25 @@ def build_app() -> gr.Blocks:
|
|
| 1607 |
value="",
|
| 1608 |
)
|
| 1609 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1610 |
-
update_setup = gr.Button("Save Setup",
|
| 1611 |
-
|
| 1612 |
-
|
| 1613 |
-
|
| 1614 |
-
|
| 1615 |
-
|
| 1616 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1617 |
stage_screens.append(setup_screen)
|
| 1618 |
|
| 1619 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as source_screen:
|
| 1620 |
gr.Markdown("### Source Extraction / Objective Mapping\nExtract source chunks and map them to learning objectives.")
|
| 1621 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1622 |
-
source_generate = gr.Button("Generate Mapping", variant="primary")
|
| 1623 |
-
|
| 1624 |
-
source_approve = gr.Button("Approve Mapping", variant="primary")
|
| 1625 |
objective_matrix = gr.Dataframe(
|
| 1626 |
headers=[
|
| 1627 |
"Objective ID",
|
|
@@ -1635,14 +1817,23 @@ def build_app() -> gr.Blocks:
|
|
| 1635 |
interactive=False,
|
| 1636 |
elem_classes=["compact-panel"],
|
| 1637 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1638 |
stage_screens.append(source_screen)
|
| 1639 |
|
| 1640 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as outline_screen:
|
| 1641 |
gr.Markdown("### Slide Outline & Order\nCreate the slide sequence, inspect slide roles, and check coverage.")
|
| 1642 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1643 |
-
outline_generate = gr.Button("Build Outline", variant="primary")
|
| 1644 |
-
|
| 1645 |
-
outline_approve = gr.Button("Approve Outline", variant="primary")
|
| 1646 |
slide_inventory = gr.Dataframe(
|
| 1647 |
headers=[
|
| 1648 |
"Slide #",
|
|
@@ -1662,34 +1853,71 @@ def build_app() -> gr.Blocks:
|
|
| 1662 |
interactive=False,
|
| 1663 |
elem_classes=["compact-panel"],
|
| 1664 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1665 |
stage_screens.append(outline_screen)
|
| 1666 |
|
| 1667 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as title_screen:
|
| 1668 |
gr.Markdown("### Title Generation\nDraft, review, edit, and approve slide titles.")
|
| 1669 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1670 |
-
title_generate = gr.Button("Generate Titles", variant="primary")
|
| 1671 |
-
|
| 1672 |
-
|
| 1673 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1674 |
stage_screens.append(title_screen)
|
| 1675 |
|
| 1676 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as text_screen:
|
| 1677 |
gr.Markdown("### Text Generation\nDraft visible slide text and speaker notes, then improve or approve the result.")
|
| 1678 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1679 |
-
text_generate = gr.Button("Generate Slide Text", variant="primary")
|
| 1680 |
-
text_improve = gr.Button("Improve Text with AI")
|
| 1681 |
-
text_save_edits = gr.Button("Save Text Edits")
|
| 1682 |
-
|
| 1683 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1684 |
stage_screens.append(text_screen)
|
| 1685 |
|
| 1686 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as image_screen:
|
| 1687 |
gr.Markdown("### Image / Visual Asset Generation\nGenerate visual asset plans, alt text, and asset readiness metadata.")
|
| 1688 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1689 |
-
image_generate = gr.Button("Generate Visuals", variant="primary")
|
| 1690 |
-
image_improve = gr.Button("Improve Visual Plan")
|
| 1691 |
-
|
| 1692 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1693 |
stage_screens.append(image_screen)
|
| 1694 |
|
| 1695 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as layout_screen:
|
|
@@ -1698,61 +1926,80 @@ def build_app() -> gr.Blocks:
|
|
| 1698 |
"Assign layouts, inspect composition, and compare the latest candidate versions."
|
| 1699 |
)
|
| 1700 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1701 |
-
layout_generate = gr.Button("Compose Layout", variant="primary")
|
| 1702 |
-
layout_improve = gr.Button("Improve Composition")
|
| 1703 |
-
layout_compare = gr.Button("Compare Layout Versions")
|
| 1704 |
-
|
| 1705 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1706 |
stage_screens.append(layout_screen)
|
| 1707 |
|
| 1708 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as technical_screen:
|
| 1709 |
gr.Markdown("### Technical Review\nFocus on technical accuracy, terminology, unsupported claims, and blocking issues.")
|
| 1710 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1711 |
-
technical_refresh = gr.Button("Refresh Technical Queue",
|
| 1712 |
-
technical_fix = gr.Button("Generate Technical Fix")
|
| 1713 |
-
technical_approve = gr.Button("Approve Technical Review", variant="primary")
|
| 1714 |
stage_screens.append(technical_screen)
|
| 1715 |
|
| 1716 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as pedagogical_screen:
|
| 1717 |
gr.Markdown("### Pedagogical Review\nFocus on objective coverage, teaching flow, examples, and speaker notes.")
|
| 1718 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1719 |
-
pedagogical_refresh = gr.Button("Refresh Pedagogy Queue",
|
| 1720 |
-
pedagogical_fix = gr.Button("Generate Pedagogy Fix")
|
| 1721 |
-
pedagogical_approve = gr.Button("Approve Pedagogical Review", variant="primary")
|
| 1722 |
stage_screens.append(pedagogical_screen)
|
| 1723 |
|
| 1724 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as aesthetic_screen:
|
| 1725 |
gr.Markdown("### Aesthetic Review\nFocus on readability, accessibility, brand/template compliance, and layout consistency.")
|
| 1726 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1727 |
-
aesthetic_refresh = gr.Button("Refresh Aesthetic Queue",
|
| 1728 |
-
aesthetic_fix = gr.Button("Generate Aesthetic Fix")
|
| 1729 |
-
aesthetic_approve = gr.Button("Approve Aesthetic Review", variant="primary")
|
| 1730 |
stage_screens.append(aesthetic_screen)
|
| 1731 |
|
| 1732 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as final_screen:
|
| 1733 |
gr.Markdown("### Final Render & Export\nRun the final readiness checks and export the completed deck.")
|
| 1734 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1735 |
-
final_preflight = gr.Button("Run Export Preflight",
|
| 1736 |
-
export = gr.Button("Final Render & Export", variant="
|
| 1737 |
stage_screens.append(final_screen)
|
| 1738 |
|
| 1739 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as audit_screen:
|
| 1740 |
gr.Markdown("### Audit Log / Version History\nInspect prompt runs, state, semantic diffs, and candidate versions.")
|
| 1741 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1742 |
-
audit_compare = gr.Button("Compare Latest Versions",
|
| 1743 |
-
restore_candidate = gr.Button("Restore Candidate")
|
| 1744 |
stage_screens.append(audit_screen)
|
| 1745 |
|
| 1746 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as artifact_workspace:
|
| 1747 |
gr.Markdown("### Current Stage Output")
|
| 1748 |
with gr.Row():
|
| 1749 |
with gr.Column(scale=2):
|
| 1750 |
-
|
|
|
|
|
|
|
|
|
|
| 1751 |
artifact_diff = gr.Textbox(label="Latest version changes", lines=10, interactive=False)
|
| 1752 |
with gr.Column(scale=1, min_width=320):
|
| 1753 |
lock_reasons = gr.Textbox(label="Lock reasons", lines=5, interactive=False)
|
| 1754 |
-
|
| 1755 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1756 |
with gr.Accordion("AI revision controls", open=False):
|
| 1757 |
with gr.Row():
|
| 1758 |
preserve_slide_order = gr.Checkbox(label="Preserve slide order", value=True)
|
|
@@ -1917,10 +2164,21 @@ def build_app() -> gr.Blocks:
|
|
| 1917 |
prompt_run_id = gr.Textbox(label="Prompt run ID")
|
| 1918 |
prompt_detail = gr.Textbox(label="Prompt run detail", lines=8, interactive=False)
|
| 1919 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1920 |
outputs = [
|
| 1921 |
state_store,
|
|
|
|
| 1922 |
status,
|
| 1923 |
-
|
|
|
|
| 1924 |
artifact_diff,
|
| 1925 |
lock_reasons,
|
| 1926 |
deck_health,
|
|
@@ -1943,7 +2201,7 @@ def build_app() -> gr.Blocks:
|
|
| 1943 |
reviewer_metrics,
|
| 1944 |
workflow_header,
|
| 1945 |
stage_score_strip,
|
| 1946 |
-
|
| 1947 |
*stage_screens,
|
| 1948 |
artifact_workspace,
|
| 1949 |
review_workspace,
|
|
@@ -2035,7 +2293,7 @@ def build_app() -> gr.Blocks:
|
|
| 2035 |
|
| 2036 |
def _pending_handler(message):
|
| 2037 |
def _handle():
|
| 2038 |
-
return
|
| 2039 |
|
| 2040 |
return _handle
|
| 2041 |
|
|
@@ -2043,7 +2301,7 @@ def build_app() -> gr.Blocks:
|
|
| 2043 |
button.click(
|
| 2044 |
_pending_handler(pending_message),
|
| 2045 |
inputs=[],
|
| 2046 |
-
outputs=[status],
|
| 2047 |
show_progress="hidden",
|
| 2048 |
queue=False,
|
| 2049 |
).then(
|
|
@@ -2094,7 +2352,7 @@ def build_app() -> gr.Blocks:
|
|
| 2094 |
for button in [title_save_edits, text_save_edits]:
|
| 2095 |
button.click(
|
| 2096 |
handle_save_edits,
|
| 2097 |
-
inputs=[state_store, stage_id,
|
| 2098 |
outputs=outputs,
|
| 2099 |
)
|
| 2100 |
final_preflight.click(handle_preflight, inputs=[state_store, stage_id], outputs=outputs)
|
|
|
|
| 54 |
|
| 55 |
|
| 56 |
CSS = """
|
| 57 |
+
:root {
|
| 58 |
+
color-scheme: light;
|
| 59 |
+
}
|
| 60 |
body,
|
| 61 |
.gradio-container {
|
| 62 |
+
--body-background-fill: #f7f8fa;
|
| 63 |
+
--body-text-color: #111827;
|
| 64 |
+
--background-fill-primary: #ffffff;
|
| 65 |
+
--background-fill-secondary: #f8fafc;
|
| 66 |
+
--block-background-fill: #ffffff;
|
| 67 |
+
--block-border-color: #d9dee7;
|
| 68 |
+
--block-label-text-color: #111827;
|
| 69 |
+
--input-background-fill: #ffffff;
|
| 70 |
+
--input-border-color: #cbd5e1;
|
| 71 |
+
--input-placeholder-color: #6b7280;
|
| 72 |
+
--button-primary-background-fill: #f97316;
|
| 73 |
+
--button-primary-background-fill-hover: #ea580c;
|
| 74 |
+
--button-primary-text-color: #ffffff;
|
| 75 |
+
--table-border-color: #d9dee7;
|
| 76 |
+
--table-row-focus: #eff6ff;
|
| 77 |
background: #f7f8fa !important;
|
| 78 |
color: #111827 !important;
|
| 79 |
}
|
| 80 |
.gradio-container { max-width: 1540px !important; }
|
| 81 |
+
.gradio-container .block,
|
| 82 |
+
.gradio-container .form,
|
| 83 |
+
.gradio-container .wrap,
|
| 84 |
+
.gradio-container .contain,
|
| 85 |
+
.gradio-container .panel,
|
| 86 |
+
.gradio-container .input-container,
|
| 87 |
+
.gradio-container .file-preview,
|
| 88 |
+
.gradio-container [data-testid="block-info"],
|
| 89 |
+
.gradio-container [data-testid="file"],
|
| 90 |
+
.gradio-container [data-testid="textbox"] {
|
| 91 |
+
background: #ffffff !important;
|
| 92 |
+
color: #111827 !important;
|
| 93 |
+
border-color: #d9dee7 !important;
|
| 94 |
+
}
|
| 95 |
.gradio-container label,
|
| 96 |
.gradio-container span,
|
| 97 |
+
.gradio-container p,
|
| 98 |
+
.gradio-container h1,
|
| 99 |
+
.gradio-container h2,
|
| 100 |
+
.gradio-container h3,
|
| 101 |
+
.gradio-container h4,
|
| 102 |
+
.gradio-container h5,
|
| 103 |
+
.gradio-container h6 {
|
| 104 |
+
color: #111827 !important;
|
| 105 |
}
|
| 106 |
.gradio-container input,
|
| 107 |
.gradio-container textarea,
|
|
|
|
| 111 |
color: #111827 !important;
|
| 112 |
}
|
| 113 |
textarea, .cm-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
|
| 114 |
+
.cm-editor,
|
| 115 |
+
.cm-scroller,
|
| 116 |
+
.cm-gutters {
|
| 117 |
+
background: #ffffff !important;
|
| 118 |
+
color: #111827 !important;
|
| 119 |
+
}
|
| 120 |
+
.compact-panel {
|
| 121 |
+
overflow-x: auto;
|
| 122 |
+
}
|
| 123 |
.compact-panel table { font-size: 12px; }
|
| 124 |
.compact-panel table,
|
| 125 |
.compact-panel thead,
|
| 126 |
.compact-panel tbody,
|
| 127 |
.compact-panel tr,
|
| 128 |
.compact-panel th,
|
| 129 |
+
.compact-panel td,
|
| 130 |
+
.compact-panel [role="grid"],
|
| 131 |
+
.compact-panel [role="row"],
|
| 132 |
+
.compact-panel [role="columnheader"],
|
| 133 |
+
.compact-panel [role="gridcell"],
|
| 134 |
+
.compact-panel .ag-root-wrapper,
|
| 135 |
+
.compact-panel .ag-root,
|
| 136 |
+
.compact-panel .ag-header,
|
| 137 |
+
.compact-panel .ag-header-row,
|
| 138 |
+
.compact-panel .ag-center-cols-container,
|
| 139 |
+
.compact-panel .ag-center-cols-viewport,
|
| 140 |
+
.compact-panel .ag-body,
|
| 141 |
+
.compact-panel .ag-body-viewport,
|
| 142 |
+
.compact-panel .ag-row,
|
| 143 |
+
.compact-panel .ag-cell {
|
| 144 |
background: #ffffff !important;
|
| 145 |
color: #111827 !important;
|
| 146 |
+
border-color: #d9dee7 !important;
|
| 147 |
}
|
| 148 |
+
.compact-panel th,
|
| 149 |
+
.compact-panel [role="columnheader"],
|
| 150 |
+
.compact-panel .ag-header,
|
| 151 |
+
.compact-panel .ag-header-cell {
|
| 152 |
+
background: #f8fafc !important;
|
| 153 |
color: #374151 !important;
|
| 154 |
font-weight: 700 !important;
|
| 155 |
}
|
| 156 |
+
.compact-panel tbody tr:nth-child(even),
|
| 157 |
+
.compact-panel .ag-row-even {
|
| 158 |
+
background: #f8fafc !important;
|
| 159 |
+
}
|
| 160 |
+
.compact-panel tbody tr:nth-child(even) td,
|
| 161 |
+
.compact-panel .ag-row-even .ag-cell {
|
| 162 |
+
background: #f8fafc !important;
|
| 163 |
+
}
|
| 164 |
+
.compact-panel .ag-row-selected,
|
| 165 |
+
.compact-panel .ag-row-selected .ag-cell {
|
| 166 |
+
background: #eff6ff !important;
|
| 167 |
+
color: #111827 !important;
|
| 168 |
+
}
|
| 169 |
+
.compact-panel button,
|
| 170 |
+
.compact-panel svg {
|
| 171 |
+
color: #374151 !important;
|
| 172 |
+
}
|
| 173 |
.workflow-topbar {
|
| 174 |
position: sticky;
|
| 175 |
top: 0;
|
|
|
|
| 313 |
min-height: 42px;
|
| 314 |
white-space: normal !important;
|
| 315 |
}
|
| 316 |
+
.production-action,
|
| 317 |
+
.production-action button {
|
| 318 |
+
background: #f97316 !important;
|
| 319 |
+
border-color: #f97316 !important;
|
| 320 |
+
color: #ffffff !important;
|
| 321 |
+
}
|
| 322 |
+
.approval-action,
|
| 323 |
+
.approval-action button {
|
| 324 |
+
background: #059669 !important;
|
| 325 |
+
border-color: #059669 !important;
|
| 326 |
+
color: #ffffff !important;
|
| 327 |
+
}
|
| 328 |
+
.score-action,
|
| 329 |
+
.score-action button {
|
| 330 |
+
background: #ffffff !important;
|
| 331 |
+
border-color: #cbd5e1 !important;
|
| 332 |
+
color: #111827 !important;
|
| 333 |
+
}
|
| 334 |
+
.secondary-action,
|
| 335 |
+
.secondary-action button {
|
| 336 |
+
background: #f8fafc !important;
|
| 337 |
+
border-color: #cbd5e1 !important;
|
| 338 |
+
color: #111827 !important;
|
| 339 |
+
}
|
| 340 |
.screen-card {
|
| 341 |
border: 1px solid #d9dee7;
|
| 342 |
border-radius: 8px;
|
|
|
|
| 454 |
.stage-result-panel {
|
| 455 |
margin-top: 14px;
|
| 456 |
}
|
| 457 |
+
.score-gate {
|
| 458 |
+
border: 1px solid #d9dee7;
|
| 459 |
+
border-radius: 8px;
|
| 460 |
+
background: #f8fafc;
|
| 461 |
+
margin-top: 14px;
|
| 462 |
+
padding: 12px;
|
| 463 |
+
}
|
| 464 |
+
.score-gate h4 {
|
| 465 |
+
color: #111827;
|
| 466 |
+
font-size: 14px;
|
| 467 |
+
margin: 0 0 8px;
|
| 468 |
+
}
|
| 469 |
+
.score-gate-row {
|
| 470 |
+
align-items: stretch;
|
| 471 |
+
}
|
| 472 |
.stage-result-card {
|
| 473 |
border: 1px solid #d9dee7;
|
| 474 |
border-left: 5px solid #64748b;
|
|
|
|
| 502 |
line-height: 1;
|
| 503 |
margin-top: 8px;
|
| 504 |
}
|
| 505 |
+
.output-panel {
|
| 506 |
+
border: 1px solid #d9dee7;
|
| 507 |
+
border-radius: 8px;
|
| 508 |
+
background: #ffffff;
|
| 509 |
+
padding: 14px;
|
| 510 |
+
}
|
| 511 |
+
.output-panel,
|
| 512 |
+
.output-panel p,
|
| 513 |
+
.output-panel li,
|
| 514 |
+
.output-panel strong {
|
| 515 |
+
color: #111827 !important;
|
| 516 |
+
}
|
| 517 |
+
.output-panel h3 {
|
| 518 |
+
color: #111827 !important;
|
| 519 |
+
font-size: 16px;
|
| 520 |
+
margin: 0 0 8px;
|
| 521 |
+
}
|
| 522 |
+
.output-panel code,
|
| 523 |
+
.output-panel pre {
|
| 524 |
+
background: #f8fafc !important;
|
| 525 |
+
color: #111827 !important;
|
| 526 |
+
}
|
| 527 |
@media (max-width: 900px) {
|
| 528 |
.workflow-title-row,
|
| 529 |
.workflow-metrics {
|
|
|
|
| 668 |
)
|
| 669 |
|
| 670 |
|
| 671 |
+
def render_activity_updates(message: str, status: str | None = None):
|
| 672 |
if not message:
|
| 673 |
+
return gr.update(visible=False), ""
|
| 674 |
+
return gr.update(visible=True), render_activity_message(message, status or _activity_status_for_message(message))
|
| 675 |
|
| 676 |
|
| 677 |
def _activity_status_for_message(message: str) -> str:
|
|
|
|
| 687 |
return render_activity_message(message, "pending")
|
| 688 |
|
| 689 |
|
| 690 |
+
def pending_activity_updates(message: str):
|
| 691 |
+
return render_activity_updates(message, "pending")
|
| 692 |
|
| 693 |
|
| 694 |
+
SCORE_GATE_STAGE_IDS = (
|
| 695 |
+
"setup_inputs",
|
| 696 |
+
"source_extraction_objective_mapping",
|
| 697 |
+
"slide_outline_order",
|
| 698 |
+
"title_generation",
|
| 699 |
+
"text_generation",
|
| 700 |
+
"image_visual_asset_generation",
|
| 701 |
+
"aesthetic_ordering_visual_composition",
|
| 702 |
+
)
|
| 703 |
+
|
| 704 |
+
|
| 705 |
+
def render_stage_score_gate_panel(state, stage_id: str) -> str:
|
| 706 |
+
stage_id = _safe_stage_id(stage_id)
|
| 707 |
+
stage = state.stages[stage_id]
|
| 708 |
score = stage.score
|
| 709 |
+
label = STAGE_LABELS[stage_id]
|
| 710 |
if score is None:
|
| 711 |
+
return f"""
|
| 712 |
<div class="stage-result-card">
|
| 713 |
+
<h4>{_escape(label)} score</h4>
|
| 714 |
+
<p>Run the stage score check after creating a candidate.</p>
|
| 715 |
<div class="stage-result-score">Pending</div>
|
| 716 |
</div>
|
| 717 |
"""
|
|
|
|
| 719 |
result_text = "Ready to continue" if score >= PASSING_STAGE_SCORE else "Needs review before continuing"
|
| 720 |
return f"""
|
| 721 |
<div class="stage-result-card {result_class}">
|
| 722 |
+
<h4>{_escape(label)} score</h4>
|
| 723 |
<p>{_escape(result_text)}</p>
|
| 724 |
<div class="stage-result-score">{score}/100</div>
|
| 725 |
</div>
|
| 726 |
"""
|
| 727 |
|
| 728 |
|
| 729 |
+
def render_setup_score_panel(state) -> str:
|
| 730 |
+
return render_stage_score_gate_panel(state, "setup_inputs")
|
| 731 |
+
|
| 732 |
+
|
| 733 |
def _human_label(value: object) -> str:
|
| 734 |
return str(value).replace("_", " ").strip().capitalize()
|
| 735 |
|
|
|
|
| 745 |
def _artifact_header(state, stage_id: str) -> list[str]:
|
| 746 |
artifact = get_current_stage_artifact(stage_id, state)
|
| 747 |
if artifact is None:
|
| 748 |
+
return [f"### {STAGE_LABELS[stage_id]} output", "", "No candidate has been created for this stage yet."]
|
| 749 |
score = state.stages[stage_id].score
|
| 750 |
score_text = "Not scored yet" if score is None else f"{score}/100"
|
| 751 |
return [
|
| 752 |
+
f"### {STAGE_LABELS[stage_id]} output",
|
| 753 |
"",
|
| 754 |
+
f"**Artifact:** {artifact.artifact_version_id}",
|
| 755 |
+
f"**Status:** {_human_label(artifact.status.value)}",
|
| 756 |
+
f"**Score:** {score_text}",
|
| 757 |
]
|
| 758 |
|
| 759 |
|
|
|
|
| 837 |
return [f"{prefix}{_human_scalar(value)}"]
|
| 838 |
|
| 839 |
|
| 840 |
+
def readable_current_artifact_markdown(state, stage_id: str) -> str:
|
| 841 |
stage_id = _safe_stage_id(stage_id)
|
| 842 |
artifact = get_current_stage_artifact(stage_id, state)
|
| 843 |
lines = _artifact_header(state, stage_id)
|
|
|
|
| 898 |
return "\n".join(lines)
|
| 899 |
|
| 900 |
|
| 901 |
+
def readable_current_artifact_text(state, stage_id: str) -> str:
|
| 902 |
+
return readable_current_artifact_markdown(state, stage_id)
|
| 903 |
+
|
| 904 |
+
|
| 905 |
+
def advanced_human_edit_text(state, stage_id: str) -> str:
|
| 906 |
+
stage_id = _safe_stage_id(stage_id)
|
| 907 |
+
artifact = get_current_stage_artifact(stage_id, state)
|
| 908 |
+
if artifact is None:
|
| 909 |
+
return ""
|
| 910 |
+
content = artifact.metadata.get("content", {})
|
| 911 |
+
if isinstance(content, dict) and "human_edit" in content:
|
| 912 |
+
return _human_scalar(content.get("human_edit"))
|
| 913 |
+
return readable_current_artifact_markdown(state, stage_id)
|
| 914 |
+
|
| 915 |
+
|
| 916 |
def _is_unresolved_issue(issue) -> bool:
|
| 917 |
return issue.status not in RESOLVED_ISSUE_STATUSES and not issue.resolved
|
| 918 |
|
|
|
|
| 1078 |
return (
|
| 1079 |
render_workflow_header(state, active_stage_id),
|
| 1080 |
render_stage_score_strip(state, active_stage_id),
|
| 1081 |
+
*(render_stage_score_gate_panel(state, stage_id) for stage_id in SCORE_GATE_STAGE_IDS),
|
| 1082 |
*stage_visibility_updates(active_stage_id),
|
| 1083 |
*workspace_visibility_updates(active_stage_id),
|
| 1084 |
*stage_step_button_updates(active_stage_id),
|
|
|
|
| 1241 |
state_json = json.dumps(state_to_dict(state), indent=2, sort_keys=True)
|
| 1242 |
return (
|
| 1243 |
state_to_dict(state),
|
| 1244 |
+
*render_activity_updates(message),
|
| 1245 |
+
readable_current_artifact_markdown(state, stage_id),
|
| 1246 |
+
advanced_human_edit_text(state, stage_id),
|
| 1247 |
current_artifact_diff(state, stage_id),
|
| 1248 |
lock_reasons,
|
| 1249 |
deck_health_table(state),
|
|
|
|
| 1723 |
|
| 1724 |
with gr.Row():
|
| 1725 |
with gr.Column(scale=2):
|
| 1726 |
+
with gr.Group(visible=False, elem_classes=["status-region"]) as status_region:
|
| 1727 |
+
status = gr.Markdown(elem_classes=["activity-panel"])
|
| 1728 |
with gr.Column(scale=1, min_width=240):
|
| 1729 |
reviewer_name = gr.Textbox(label="Reviewer", value="human_reviewer")
|
| 1730 |
|
|
|
|
| 1785 |
value="",
|
| 1786 |
)
|
| 1787 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1788 |
+
update_setup = gr.Button("Save Setup", elem_classes=["secondary-action"])
|
| 1789 |
+
setup_generate = gr.Button("Create Setup Candidate", variant="primary", elem_classes=["production-action"])
|
| 1790 |
+
with gr.Group(elem_classes=["score-gate"]):
|
| 1791 |
+
gr.Markdown("#### Setup Score & Gate")
|
| 1792 |
+
with gr.Row(elem_classes=["score-gate-row"]):
|
| 1793 |
+
with gr.Column(scale=1, min_width=220):
|
| 1794 |
+
setup_grade = gr.Button("Check Setup Score", elem_classes=["score-action"])
|
| 1795 |
+
with gr.Column(scale=3, min_width=320):
|
| 1796 |
+
setup_score_panel = gr.Markdown(
|
| 1797 |
+
render_setup_score_panel(initial_state),
|
| 1798 |
+
elem_classes=["stage-result-panel"],
|
| 1799 |
+
)
|
| 1800 |
stage_screens.append(setup_screen)
|
| 1801 |
|
| 1802 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as source_screen:
|
| 1803 |
gr.Markdown("### Source Extraction / Objective Mapping\nExtract source chunks and map them to learning objectives.")
|
| 1804 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1805 |
+
source_generate = gr.Button("Generate Mapping", variant="primary", elem_classes=["production-action"])
|
| 1806 |
+
source_approve = gr.Button("Approve Mapping", variant="primary", elem_classes=["approval-action"])
|
|
|
|
| 1807 |
objective_matrix = gr.Dataframe(
|
| 1808 |
headers=[
|
| 1809 |
"Objective ID",
|
|
|
|
| 1817 |
interactive=False,
|
| 1818 |
elem_classes=["compact-panel"],
|
| 1819 |
)
|
| 1820 |
+
with gr.Group(elem_classes=["score-gate"]):
|
| 1821 |
+
gr.Markdown("#### Mapping Score & Gate")
|
| 1822 |
+
with gr.Row(elem_classes=["score-gate-row"]):
|
| 1823 |
+
with gr.Column(scale=1, min_width=220):
|
| 1824 |
+
source_grade = gr.Button("Grade Mapping", elem_classes=["score-action"])
|
| 1825 |
+
with gr.Column(scale=3, min_width=320):
|
| 1826 |
+
source_score_panel = gr.Markdown(
|
| 1827 |
+
render_stage_score_gate_panel(initial_state, "source_extraction_objective_mapping"),
|
| 1828 |
+
elem_classes=["stage-result-panel"],
|
| 1829 |
+
)
|
| 1830 |
stage_screens.append(source_screen)
|
| 1831 |
|
| 1832 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as outline_screen:
|
| 1833 |
gr.Markdown("### Slide Outline & Order\nCreate the slide sequence, inspect slide roles, and check coverage.")
|
| 1834 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1835 |
+
outline_generate = gr.Button("Build Outline", variant="primary", elem_classes=["production-action"])
|
| 1836 |
+
outline_approve = gr.Button("Approve Outline", variant="primary", elem_classes=["approval-action"])
|
|
|
|
| 1837 |
slide_inventory = gr.Dataframe(
|
| 1838 |
headers=[
|
| 1839 |
"Slide #",
|
|
|
|
| 1853 |
interactive=False,
|
| 1854 |
elem_classes=["compact-panel"],
|
| 1855 |
)
|
| 1856 |
+
with gr.Group(elem_classes=["score-gate"]):
|
| 1857 |
+
gr.Markdown("#### Outline Score & Gate")
|
| 1858 |
+
with gr.Row(elem_classes=["score-gate-row"]):
|
| 1859 |
+
with gr.Column(scale=1, min_width=220):
|
| 1860 |
+
outline_grade = gr.Button("Grade Outline", elem_classes=["score-action"])
|
| 1861 |
+
with gr.Column(scale=3, min_width=320):
|
| 1862 |
+
outline_score_panel = gr.Markdown(
|
| 1863 |
+
render_stage_score_gate_panel(initial_state, "slide_outline_order"),
|
| 1864 |
+
elem_classes=["stage-result-panel"],
|
| 1865 |
+
)
|
| 1866 |
stage_screens.append(outline_screen)
|
| 1867 |
|
| 1868 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as title_screen:
|
| 1869 |
gr.Markdown("### Title Generation\nDraft, review, edit, and approve slide titles.")
|
| 1870 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1871 |
+
title_generate = gr.Button("Generate Titles", variant="primary", elem_classes=["production-action"])
|
| 1872 |
+
title_save_edits = gr.Button("Save Title Edits", elem_classes=["secondary-action"])
|
| 1873 |
+
title_approve = gr.Button("Approve Titles", variant="primary", elem_classes=["approval-action"])
|
| 1874 |
+
with gr.Group(elem_classes=["score-gate"]):
|
| 1875 |
+
gr.Markdown("#### Titles Score & Gate")
|
| 1876 |
+
with gr.Row(elem_classes=["score-gate-row"]):
|
| 1877 |
+
with gr.Column(scale=1, min_width=220):
|
| 1878 |
+
title_grade = gr.Button("Grade Titles", elem_classes=["score-action"])
|
| 1879 |
+
with gr.Column(scale=3, min_width=320):
|
| 1880 |
+
title_score_panel = gr.Markdown(
|
| 1881 |
+
render_stage_score_gate_panel(initial_state, "title_generation"),
|
| 1882 |
+
elem_classes=["stage-result-panel"],
|
| 1883 |
+
)
|
| 1884 |
stage_screens.append(title_screen)
|
| 1885 |
|
| 1886 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as text_screen:
|
| 1887 |
gr.Markdown("### Text Generation\nDraft visible slide text and speaker notes, then improve or approve the result.")
|
| 1888 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1889 |
+
text_generate = gr.Button("Generate Slide Text", variant="primary", elem_classes=["production-action"])
|
| 1890 |
+
text_improve = gr.Button("Improve Text with AI", elem_classes=["secondary-action"])
|
| 1891 |
+
text_save_edits = gr.Button("Save Text Edits", elem_classes=["secondary-action"])
|
| 1892 |
+
text_approve = gr.Button("Approve Text", variant="primary", elem_classes=["approval-action"])
|
| 1893 |
+
with gr.Group(elem_classes=["score-gate"]):
|
| 1894 |
+
gr.Markdown("#### Text Score & Gate")
|
| 1895 |
+
with gr.Row(elem_classes=["score-gate-row"]):
|
| 1896 |
+
with gr.Column(scale=1, min_width=220):
|
| 1897 |
+
text_grade = gr.Button("Grade Text", elem_classes=["score-action"])
|
| 1898 |
+
with gr.Column(scale=3, min_width=320):
|
| 1899 |
+
text_score_panel = gr.Markdown(
|
| 1900 |
+
render_stage_score_gate_panel(initial_state, "text_generation"),
|
| 1901 |
+
elem_classes=["stage-result-panel"],
|
| 1902 |
+
)
|
| 1903 |
stage_screens.append(text_screen)
|
| 1904 |
|
| 1905 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as image_screen:
|
| 1906 |
gr.Markdown("### Image / Visual Asset Generation\nGenerate visual asset plans, alt text, and asset readiness metadata.")
|
| 1907 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1908 |
+
image_generate = gr.Button("Generate Visuals", variant="primary", elem_classes=["production-action"])
|
| 1909 |
+
image_improve = gr.Button("Improve Visual Plan", elem_classes=["secondary-action"])
|
| 1910 |
+
image_approve = gr.Button("Approve Visuals", variant="primary", elem_classes=["approval-action"])
|
| 1911 |
+
with gr.Group(elem_classes=["score-gate"]):
|
| 1912 |
+
gr.Markdown("#### Visuals Score & Gate")
|
| 1913 |
+
with gr.Row(elem_classes=["score-gate-row"]):
|
| 1914 |
+
with gr.Column(scale=1, min_width=220):
|
| 1915 |
+
image_grade = gr.Button("Grade Visuals", elem_classes=["score-action"])
|
| 1916 |
+
with gr.Column(scale=3, min_width=320):
|
| 1917 |
+
image_score_panel = gr.Markdown(
|
| 1918 |
+
render_stage_score_gate_panel(initial_state, "image_visual_asset_generation"),
|
| 1919 |
+
elem_classes=["stage-result-panel"],
|
| 1920 |
+
)
|
| 1921 |
stage_screens.append(image_screen)
|
| 1922 |
|
| 1923 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as layout_screen:
|
|
|
|
| 1926 |
"Assign layouts, inspect composition, and compare the latest candidate versions."
|
| 1927 |
)
|
| 1928 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1929 |
+
layout_generate = gr.Button("Compose Layout", variant="primary", elem_classes=["production-action"])
|
| 1930 |
+
layout_improve = gr.Button("Improve Composition", elem_classes=["secondary-action"])
|
| 1931 |
+
layout_compare = gr.Button("Compare Layout Versions", elem_classes=["secondary-action"])
|
| 1932 |
+
layout_approve = gr.Button("Approve Layout", variant="primary", elem_classes=["approval-action"])
|
| 1933 |
+
with gr.Group(elem_classes=["score-gate"]):
|
| 1934 |
+
gr.Markdown("#### Layout Score & Gate")
|
| 1935 |
+
with gr.Row(elem_classes=["score-gate-row"]):
|
| 1936 |
+
with gr.Column(scale=1, min_width=220):
|
| 1937 |
+
layout_grade = gr.Button("Grade Layout", elem_classes=["score-action"])
|
| 1938 |
+
with gr.Column(scale=3, min_width=320):
|
| 1939 |
+
layout_score_panel = gr.Markdown(
|
| 1940 |
+
render_stage_score_gate_panel(initial_state, "aesthetic_ordering_visual_composition"),
|
| 1941 |
+
elem_classes=["stage-result-panel"],
|
| 1942 |
+
)
|
| 1943 |
stage_screens.append(layout_screen)
|
| 1944 |
|
| 1945 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as technical_screen:
|
| 1946 |
gr.Markdown("### Technical Review\nFocus on technical accuracy, terminology, unsupported claims, and blocking issues.")
|
| 1947 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1948 |
+
technical_refresh = gr.Button("Refresh Technical Queue", elem_classes=["secondary-action"])
|
| 1949 |
+
technical_fix = gr.Button("Generate Technical Fix", variant="primary", elem_classes=["production-action"])
|
| 1950 |
+
technical_approve = gr.Button("Approve Technical Review", variant="primary", elem_classes=["approval-action"])
|
| 1951 |
stage_screens.append(technical_screen)
|
| 1952 |
|
| 1953 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as pedagogical_screen:
|
| 1954 |
gr.Markdown("### Pedagogical Review\nFocus on objective coverage, teaching flow, examples, and speaker notes.")
|
| 1955 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1956 |
+
pedagogical_refresh = gr.Button("Refresh Pedagogy Queue", elem_classes=["secondary-action"])
|
| 1957 |
+
pedagogical_fix = gr.Button("Generate Pedagogy Fix", variant="primary", elem_classes=["production-action"])
|
| 1958 |
+
pedagogical_approve = gr.Button("Approve Pedagogical Review", variant="primary", elem_classes=["approval-action"])
|
| 1959 |
stage_screens.append(pedagogical_screen)
|
| 1960 |
|
| 1961 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as aesthetic_screen:
|
| 1962 |
gr.Markdown("### Aesthetic Review\nFocus on readability, accessibility, brand/template compliance, and layout consistency.")
|
| 1963 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1964 |
+
aesthetic_refresh = gr.Button("Refresh Aesthetic Queue", elem_classes=["secondary-action"])
|
| 1965 |
+
aesthetic_fix = gr.Button("Generate Aesthetic Fix", variant="primary", elem_classes=["production-action"])
|
| 1966 |
+
aesthetic_approve = gr.Button("Approve Aesthetic Review", variant="primary", elem_classes=["approval-action"])
|
| 1967 |
stage_screens.append(aesthetic_screen)
|
| 1968 |
|
| 1969 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as final_screen:
|
| 1970 |
gr.Markdown("### Final Render & Export\nRun the final readiness checks and export the completed deck.")
|
| 1971 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1972 |
+
final_preflight = gr.Button("Run Export Preflight", elem_classes=["secondary-action"])
|
| 1973 |
+
export = gr.Button("Final Render & Export", variant="primary", elem_classes=["production-action"])
|
| 1974 |
stage_screens.append(final_screen)
|
| 1975 |
|
| 1976 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as audit_screen:
|
| 1977 |
gr.Markdown("### Audit Log / Version History\nInspect prompt runs, state, semantic diffs, and candidate versions.")
|
| 1978 |
with gr.Row(elem_classes=["action-strip"]):
|
| 1979 |
+
audit_compare = gr.Button("Compare Latest Versions", elem_classes=["secondary-action"])
|
| 1980 |
+
restore_candidate = gr.Button("Restore Candidate", elem_classes=["secondary-action"])
|
| 1981 |
stage_screens.append(audit_screen)
|
| 1982 |
|
| 1983 |
with gr.Group(visible=False, elem_classes=["screen-card"]) as artifact_workspace:
|
| 1984 |
gr.Markdown("### Current Stage Output")
|
| 1985 |
with gr.Row():
|
| 1986 |
with gr.Column(scale=2):
|
| 1987 |
+
artifact_output = gr.Markdown(
|
| 1988 |
+
readable_current_artifact_markdown(initial_state, STAGE_IDS[0]),
|
| 1989 |
+
elem_classes=["output-panel"],
|
| 1990 |
+
)
|
| 1991 |
artifact_diff = gr.Textbox(label="Latest version changes", lines=10, interactive=False)
|
| 1992 |
with gr.Column(scale=1, min_width=320):
|
| 1993 |
lock_reasons = gr.Textbox(label="Lock reasons", lines=5, interactive=False)
|
| 1994 |
+
with gr.Accordion("Advanced human edit", open=False):
|
| 1995 |
+
human_edit_text = gr.Textbox(
|
| 1996 |
+
label="Human edit text",
|
| 1997 |
+
value=advanced_human_edit_text(initial_state, STAGE_IDS[0]),
|
| 1998 |
+
lines=10,
|
| 1999 |
+
interactive=True,
|
| 2000 |
+
)
|
| 2001 |
+
reviewer_summary = gr.Textbox(label="Reviewer summary")
|
| 2002 |
+
requested_changes_json = gr.Textbox(label="Requested changes JSON", lines=6, value="[]")
|
| 2003 |
with gr.Accordion("AI revision controls", open=False):
|
| 2004 |
with gr.Row():
|
| 2005 |
preserve_slide_order = gr.Checkbox(label="Preserve slide order", value=True)
|
|
|
|
| 2164 |
prompt_run_id = gr.Textbox(label="Prompt run ID")
|
| 2165 |
prompt_detail = gr.Textbox(label="Prompt run detail", lines=8, interactive=False)
|
| 2166 |
|
| 2167 |
+
stage_score_gate_panels = [
|
| 2168 |
+
setup_score_panel,
|
| 2169 |
+
source_score_panel,
|
| 2170 |
+
outline_score_panel,
|
| 2171 |
+
title_score_panel,
|
| 2172 |
+
text_score_panel,
|
| 2173 |
+
image_score_panel,
|
| 2174 |
+
layout_score_panel,
|
| 2175 |
+
]
|
| 2176 |
outputs = [
|
| 2177 |
state_store,
|
| 2178 |
+
status_region,
|
| 2179 |
status,
|
| 2180 |
+
artifact_output,
|
| 2181 |
+
human_edit_text,
|
| 2182 |
artifact_diff,
|
| 2183 |
lock_reasons,
|
| 2184 |
deck_health,
|
|
|
|
| 2201 |
reviewer_metrics,
|
| 2202 |
workflow_header,
|
| 2203 |
stage_score_strip,
|
| 2204 |
+
*stage_score_gate_panels,
|
| 2205 |
*stage_screens,
|
| 2206 |
artifact_workspace,
|
| 2207 |
review_workspace,
|
|
|
|
| 2293 |
|
| 2294 |
def _pending_handler(message):
|
| 2295 |
def _handle():
|
| 2296 |
+
return pending_activity_updates(message)
|
| 2297 |
|
| 2298 |
return _handle
|
| 2299 |
|
|
|
|
| 2301 |
button.click(
|
| 2302 |
_pending_handler(pending_message),
|
| 2303 |
inputs=[],
|
| 2304 |
+
outputs=[status_region, status],
|
| 2305 |
show_progress="hidden",
|
| 2306 |
queue=False,
|
| 2307 |
).then(
|
|
|
|
| 2352 |
for button in [title_save_edits, text_save_edits]:
|
| 2353 |
button.click(
|
| 2354 |
handle_save_edits,
|
| 2355 |
+
inputs=[state_store, stage_id, human_edit_text, reviewer_name, reviewer_summary, requested_changes_json],
|
| 2356 |
outputs=outputs,
|
| 2357 |
)
|
| 2358 |
final_preflight.click(handle_preflight, inputs=[state_store, stage_id], outputs=outputs)
|
tests/test_app_ui.py
CHANGED
|
@@ -1,11 +1,14 @@
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
from app import (
|
|
|
|
| 4 |
handle_stage_nav,
|
| 5 |
handle_generate,
|
| 6 |
handle_grade,
|
| 7 |
pending_activity_message,
|
|
|
|
| 8 |
render_activity_message,
|
|
|
|
| 9 |
render_stage_score_strip,
|
| 10 |
stage_score_rows,
|
| 11 |
workflow_progress_summary,
|
|
@@ -14,13 +17,17 @@ from app import (
|
|
| 14 |
from course_slide_factory.constants import STAGE_IDS
|
| 15 |
from course_slide_factory.models import IssueSeverity, IssueType
|
| 16 |
from course_slide_factory.quality import approve_current_artifact, upsert_issue
|
| 17 |
-
from course_slide_factory.workflow import build_empty_state, generate_stage
|
| 18 |
|
| 19 |
|
| 20 |
def _activity_value(update):
|
| 21 |
return update["value"] if isinstance(update, dict) else update
|
| 22 |
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
def test_workflow_progress_summary_starts_empty():
|
| 25 |
state = build_empty_state(deck_title="UI Test", source_url="mock://source")
|
| 26 |
|
|
@@ -87,6 +94,29 @@ def test_activity_messages_render_distinct_pending_and_complete_states():
|
|
| 87 |
assert "Done" in complete
|
| 88 |
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
def test_setup_candidate_button_returns_visible_snapshot_feedback(tmp_path):
|
| 91 |
instructions = tmp_path / "instructions.txt"
|
| 92 |
instructions.write_text("Course plan\n- Explain the core course concept.", encoding="utf-8")
|
|
@@ -109,16 +139,44 @@ def test_setup_candidate_button_returns_visible_snapshot_feedback(tmp_path):
|
|
| 109 |
"setup_inputs",
|
| 110 |
)
|
| 111 |
|
| 112 |
-
|
|
|
|
| 113 |
assert "activity-card complete" in message
|
| 114 |
assert "Done" in message
|
| 115 |
assert "Setup candidate created as setup_inputs_v1." in message
|
| 116 |
assert "1 parsed upload(s)" in message
|
| 117 |
assert "Check Setup Score" in message
|
| 118 |
-
assert "
|
| 119 |
-
assert "
|
| 120 |
-
assert "
|
| 121 |
-
assert
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
|
| 124 |
def test_stage_navigation_clears_activity_message():
|
|
@@ -143,7 +201,7 @@ def test_stage_navigation_clears_activity_message():
|
|
| 143 |
navigated = handle_stage_nav(generated[0], "source_extraction_objective_mapping")
|
| 144 |
|
| 145 |
assert navigated[4]["visible"] is False
|
| 146 |
-
assert navigated[
|
| 147 |
|
| 148 |
|
| 149 |
def test_setup_grade_button_path_returns_score_feedback():
|
|
@@ -167,6 +225,6 @@ def test_setup_grade_button_path_returns_score_feedback():
|
|
| 167 |
|
| 168 |
graded = handle_grade(generated[0], "setup_inputs")
|
| 169 |
|
| 170 |
-
message = _activity_value(graded[
|
| 171 |
assert "activity-card complete" in message
|
| 172 |
assert "Grade for Setup & Inputs:" in message
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
from app import (
|
| 4 |
+
CSS,
|
| 5 |
handle_stage_nav,
|
| 6 |
handle_generate,
|
| 7 |
handle_grade,
|
| 8 |
pending_activity_message,
|
| 9 |
+
readable_current_artifact_markdown,
|
| 10 |
render_activity_message,
|
| 11 |
+
render_stage_score_gate_panel,
|
| 12 |
render_stage_score_strip,
|
| 13 |
stage_score_rows,
|
| 14 |
workflow_progress_summary,
|
|
|
|
| 17 |
from course_slide_factory.constants import STAGE_IDS
|
| 18 |
from course_slide_factory.models import IssueSeverity, IssueType
|
| 19 |
from course_slide_factory.quality import approve_current_artifact, upsert_issue
|
| 20 |
+
from course_slide_factory.workflow import build_empty_state, generate_stage, update_setup_from_inputs
|
| 21 |
|
| 22 |
|
| 23 |
def _activity_value(update):
|
| 24 |
return update["value"] if isinstance(update, dict) else update
|
| 25 |
|
| 26 |
|
| 27 |
+
def _update_visible(update):
|
| 28 |
+
return update["visible"] if isinstance(update, dict) else None
|
| 29 |
+
|
| 30 |
+
|
| 31 |
def test_workflow_progress_summary_starts_empty():
|
| 32 |
state = build_empty_state(deck_title="UI Test", source_url="mock://source")
|
| 33 |
|
|
|
|
| 94 |
assert "Done" in complete
|
| 95 |
|
| 96 |
|
| 97 |
+
def test_light_theme_css_covers_gradio_dataframes_and_action_hierarchy():
|
| 98 |
+
assert ":root" in CSS
|
| 99 |
+
assert "color-scheme: light" in CSS
|
| 100 |
+
assert ".compact-panel .ag-header" in CSS
|
| 101 |
+
assert '.compact-panel [role="gridcell"]' in CSS
|
| 102 |
+
assert ".production-action" in CSS
|
| 103 |
+
assert ".approval-action" in CSS
|
| 104 |
+
assert ".score-gate" in CSS
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def test_stage_score_gate_panel_renders_pending_and_scored_states():
|
| 108 |
+
state = build_empty_state(deck_title="UI Test", source_url="mock://source")
|
| 109 |
+
|
| 110 |
+
pending = render_stage_score_gate_panel(state, "setup_inputs")
|
| 111 |
+
state.stages["setup_inputs"].score = 91
|
| 112 |
+
scored = render_stage_score_gate_panel(state, "setup_inputs")
|
| 113 |
+
|
| 114 |
+
assert "Setup & Inputs score" in pending
|
| 115 |
+
assert "Pending" in pending
|
| 116 |
+
assert "stage-result-card scored" in scored
|
| 117 |
+
assert "91/100" in scored
|
| 118 |
+
|
| 119 |
+
|
| 120 |
def test_setup_candidate_button_returns_visible_snapshot_feedback(tmp_path):
|
| 121 |
instructions = tmp_path / "instructions.txt"
|
| 122 |
instructions.write_text("Course plan\n- Explain the core course concept.", encoding="utf-8")
|
|
|
|
| 139 |
"setup_inputs",
|
| 140 |
)
|
| 141 |
|
| 142 |
+
assert _update_visible(generated[1]) is True
|
| 143 |
+
message = _activity_value(generated[2])
|
| 144 |
assert "activity-card complete" in message
|
| 145 |
assert "Done" in message
|
| 146 |
assert "Setup candidate created as setup_inputs_v1." in message
|
| 147 |
assert "1 parsed upload(s)" in message
|
| 148 |
assert "Check Setup Score" in message
|
| 149 |
+
assert "### Setup & Inputs output" in generated[3]
|
| 150 |
+
assert "Input summary" in generated[3]
|
| 151 |
+
assert "Parsed uploads: 1" in generated[3]
|
| 152 |
+
assert "instructions.txt" in generated[3]
|
| 153 |
+
assert '"input_summary"' not in generated[3]
|
| 154 |
+
assert generated[4] == generated[3]
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
def test_readable_artifact_markdown_uses_human_summary_not_json(tmp_path):
|
| 158 |
+
instructions = tmp_path / "instructions.txt"
|
| 159 |
+
instructions.write_text("Course plan\n- Explain the core course concept.", encoding="utf-8")
|
| 160 |
+
state = build_empty_state(deck_title="Course Slide Deck", source_url="")
|
| 161 |
+
update_setup_from_inputs(
|
| 162 |
+
state,
|
| 163 |
+
deck_title="Course Slide Deck",
|
| 164 |
+
source_url="",
|
| 165 |
+
template_url="mock://template/course",
|
| 166 |
+
output_folder_id="",
|
| 167 |
+
dry_run=True,
|
| 168 |
+
objectives_text="obj_1: Explain the core course concept.",
|
| 169 |
+
material_files=[str(instructions)],
|
| 170 |
+
start_mode="instructions_file",
|
| 171 |
+
)
|
| 172 |
+
state, _message = generate_stage(state, "setup_inputs")
|
| 173 |
+
|
| 174 |
+
output = readable_current_artifact_markdown(state, "setup_inputs")
|
| 175 |
+
|
| 176 |
+
assert output.startswith("### Setup & Inputs output")
|
| 177 |
+
assert "Input summary" in output
|
| 178 |
+
assert "Uploaded materials" in output
|
| 179 |
+
assert '"uploaded_materials"' not in output
|
| 180 |
|
| 181 |
|
| 182 |
def test_stage_navigation_clears_activity_message():
|
|
|
|
| 201 |
navigated = handle_stage_nav(generated[0], "source_extraction_objective_mapping")
|
| 202 |
|
| 203 |
assert navigated[4]["visible"] is False
|
| 204 |
+
assert navigated[5] == ""
|
| 205 |
|
| 206 |
|
| 207 |
def test_setup_grade_button_path_returns_score_feedback():
|
|
|
|
| 225 |
|
| 226 |
graded = handle_grade(generated[0], "setup_inputs")
|
| 227 |
|
| 228 |
+
message = _activity_value(graded[2])
|
| 229 |
assert "activity-card complete" in message
|
| 230 |
assert "Grade for Setup & Inputs:" in message
|