Spaces:
Runtime error
Runtime error
nz-nz Claude Opus 4.8 commited on
[NAH-30] loading spinners on every model call + button locking (#12)
Browse filesWrap deck-generation, grading, and next/recap in show_progress="full" so
a slow model call always shows a spinner — never a dead screen. Each button
is disabled and relabelled (Generating…/Grading…) while its handler runs,
then restored, preventing double-submits. Empty/error states from NAH-23
already surface friendly messages on the upload screen.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -145,18 +145,34 @@ with gr.Blocks(title="Recall — your AI study partner", theme=gr.themes.Soft())
|
|
| 145 |
with gr.Accordion("🔍 Debug: extraction & chunks", open=False, visible=False) as debug_accordion:
|
| 146 |
debug_data = gr.JSON(label="Content pipeline output")
|
| 147 |
|
|
|
|
|
|
|
|
|
|
| 148 |
start_btn.click(
|
|
|
|
|
|
|
| 149 |
start_session, [file_in, text_in],
|
| 150 |
[session, upload_view, study_view, upload_msg, progress, question,
|
| 151 |
debug_accordion, debug_data],
|
|
|
|
|
|
|
|
|
|
| 152 |
)
|
|
|
|
| 153 |
submit_btn.click(
|
|
|
|
|
|
|
| 154 |
submit_answer, [session, answer_in],
|
| 155 |
[session, verdict, followup, progress, next_btn],
|
|
|
|
|
|
|
|
|
|
| 156 |
)
|
|
|
|
| 157 |
next_btn.click(
|
| 158 |
show_next, [session],
|
| 159 |
[session, question, study_view, recap_view, recap_md],
|
|
|
|
| 160 |
).then(lambda: ("", "", ""), None, [answer_in, verdict, followup])
|
| 161 |
|
| 162 |
|
|
|
|
| 145 |
with gr.Accordion("🔍 Debug: extraction & chunks", open=False, visible=False) as debug_accordion:
|
| 146 |
debug_data = gr.JSON(label="Content pipeline output")
|
| 147 |
|
| 148 |
+
# Every handler that can hit the model shows a spinner (show_progress="full")
|
| 149 |
+
# and disables its button while working, so a slow call never reads as a dead
|
| 150 |
+
# or double-clickable screen.
|
| 151 |
start_btn.click(
|
| 152 |
+
lambda: gr.update(value="⏳ Generating deck…", interactive=False), None, start_btn,
|
| 153 |
+
).then(
|
| 154 |
start_session, [file_in, text_in],
|
| 155 |
[session, upload_view, study_view, upload_msg, progress, question,
|
| 156 |
debug_accordion, debug_data],
|
| 157 |
+
show_progress="full",
|
| 158 |
+
).then(
|
| 159 |
+
lambda: gr.update(value="Generate deck & start", interactive=True), None, start_btn,
|
| 160 |
)
|
| 161 |
+
|
| 162 |
submit_btn.click(
|
| 163 |
+
lambda: gr.update(value="⏳ Grading…", interactive=False), None, submit_btn,
|
| 164 |
+
).then(
|
| 165 |
submit_answer, [session, answer_in],
|
| 166 |
[session, verdict, followup, progress, next_btn],
|
| 167 |
+
show_progress="full",
|
| 168 |
+
).then(
|
| 169 |
+
lambda: gr.update(value="Submit", interactive=True), None, submit_btn,
|
| 170 |
)
|
| 171 |
+
|
| 172 |
next_btn.click(
|
| 173 |
show_next, [session],
|
| 174 |
[session, question, study_view, recap_view, recap_md],
|
| 175 |
+
show_progress="full",
|
| 176 |
).then(lambda: ("", "", ""), None, [answer_in, verdict, followup])
|
| 177 |
|
| 178 |
|