Lara Monteagudo Tubau commited on
Commit Β·
3dc5e3c
1
Parent(s): 014b03e
Improve UX: inline validation, better error handling, and progress reporting
Browse files- Replace pop-up alerts with red-boxed inline error messages for missing fields
- Add success card showing parse results (turns, speakers, processing time)
- Better visual hierarchy in error display with emoji icons
- Process status cards instead of overwhelming all-in-one view
- More transparent feedback when operations complete
1202 unmodified lines12031204120512061207120812091210121112121213121412151216121712181219122012211222122317 unmodified lines124112421243124412451246986 unmodified lines223322342235223622372238223922401202 unmodified linesraise gr.Error("Confirm sections first.")session_overview = state.get("_agent0_overview", "")n = len(sections)# Initial yield β tell the UI we've startedyield (state,f"β³ Running Agent 1a on {n} section{'s' if n>1 else ''} in parallel "f"(max {min(n, 3)} concurrent workers)β¦","",gr.update(visible=False),gr.update(visible=False),"","",)collected_results: dict[str, dict] = {}pipeline_stats_html = ""# Initialise pstats before the loop so references after the try block are# always safe even if run_boundaries_parallel raises before its first yield.17 unmodified lines# Build live progress tabledone = len(collected_results)pending = [s for s in sections if s["section_id"] not in collected_results andnot any(not x.success and x.section_id == s["section_id"]for x in pstats.results)]prog_lines = []986 unmodified linesparse_btn.click(fn=fn_parse,inputs=[transcript_file, session_id_box, researcher_id_box, state],outputs=[state, pipeline_html, parse_status, col_agent0, sidebar_log],).then(fn=lambda: gr.update(visible=True), outputs=[parse_status])# Update info sidebar to sections step after parseparse_btn.click(1202 unmodified lines120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127217 unmodified lines12901291129212931294129512961297129812991300130113021303130413051306130713081309986 unmodified lines229622972298229923002301230223031202 unmodified linesraise gr.Error("Confirm sections first.")session_overview = state.get("_agent0_overview", "")# Validation without pop-ups β return error state for inline displayerrors = []if file_obj is None:errors.append("π Upload a transcript file first.")if not session_id.strip():errors.append("π Enter a Session ID (e.g. dyad_01).")if not researcher_id.strip():errors.append("π€ Enter your Researcher ID (e.g. R1).")if errors:error_html = (f'<div style="background:#fef2f2;border:2px solid #fca5a5;'f'border-radius:8px;padding:16px;margin:12px 0">'f'<div style="color:#991b1b;font-weight:700;margin-bottom:8px">β Please complete required fields:</div>'+ "".join(f'<div style="color:#7f1d1d;font-size:0.93em;margin:4px 0">β’ {e}</div>' for e in errors) +f'</div>')return (state,_pipeline_html("upload"),error_html, # Show inline instead of pop-upgr.update(visible=False),)# Processing started β show progressstatus_html = (f'<div style="background:#eff6ff;border:1px solid #93c5fd;'f'border-radius:8px;padding:12px 16px;margin:12px 0;font-size:0.88em;'f'color:#1e40af">β³ Parsing transcript...</div>')f"(max {min(n, 3)} concurrent workers)β¦","",gr.update(visible=False),gr.update(visible=False),"",error_html = (f'<div style="background:#fef2f2;border:2px solid #fca5a5;'f'border-radius:8px;padding:16px;margin:12px 0">'f'<div style="color:#991b1b;font-weight:700;margin-bottom:8px">β Parse Error</div>'f'<div style="color:#7f1d1d;font-size:0.88em;font-family:monospace">{_h(str(e))}</div>'f'</div>')return (state,_pipeline_html("upload"),error_html,gr.update(visible=False),))error_html = (f'<div style="background:#fef2f2;border:2px solid #fca5a5;'f'border-radius:8px;padding:16px;margin:12px 0">'f'<div style="color:#991b1b;font-weight:700;margin-bottom:8px">β Insufficient Data</div>'f'<div style="color:#7f1d1d;font-size:0.88em">Only {len(turns)} turns found. 'f'Please check the transcript format β at least 5 turns needed.</div>'f'</div>')return (state,_pipeline_html("upload"),error_html,gr.update(visible=False),)pipeline_stats_html = ""# Initialise pstats before the loop so references after the try block are# always safe even if run_boundaries_parallel raises before its first yield.17 unmodified lines# Build live progress tabledone = len(collected_results)pending = [s for s in sections if s["section_id"] not in collected_results and# Success report cardsuccess_html = (f'<div style="background:#f0fdf4;border:2px solid #86efac;'f'border-radius:8px;padding:16px;margin:12px 0">'f'<div style="color:#065f46;font-weight:700;margin-bottom:8px">β Transcript Parsed</div>'f'<div style="display:grid;grid-template-columns:1fr 1fr;gap:12px;font-size:0.88em;color:#14532d">'f'<div><strong>{len(turns)}</strong> turns</div>'f'<div><strong>{len(speakers)}</strong> speakers</div>'f'<div><strong>{rt}s</strong> processing time</div>'f'<div>Session: <code style="background:#dcfce7;padding:2px 4px;border-radius:3px">{_h(session_id.strip())}</code></div>'f'</div>'f'<p style="margin:12px 0 0;font-size:0.85em;color:#14532d">Ready for section detection. Click "<strong>Detect Sections</strong>" below.</p>'f'</div>')not any(not x.success and x.section_id == s["section_id"]for x in pstats.results)]prog_lines = []986 unmodified linesparse_btn.click(fn=fn_parse,inputs=[transcript_file, session_id_box, researcher_id_box, state],outputs=[state, pipeline_html, parse_status, col_agent0],)# Update info sidebar to sections step after parseparse_btn.click(
app.py+72-9