fix(ingestion,frontend): show live counter immediately on run start

Two issues with the initial implementation:
- Counter only appeared after the first SSE event arrived (scholarProgress null
  kept the v-else static template showing until a scholar completed)
- First events were often dropped because the EventSource hadn't subscribed yet

Fix:
- Backend: emit an initial scholar_progress kickoff event (0/0/N) at the
  start of run_scholar_iteration so the frontend receives total early
- Frontend: gate on isLikelyRunning alone (not scholarProgress); use optional
  chaining with fallbacks so "0 / … visited · 0 finished" shows immediately
  when a run starts, before any SSE events arrive

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Justin Visser 2026-03-03 18:37:53 +01:00
parent 4620978dce
commit 2c591a0ca3
2 changed files with 4 additions and 3 deletions

View file

@ -420,6 +420,7 @@ async def run_scholar_iteration(
{"visited": visited, "finished": finished, "total": total}, {"visited": visited, "finished": finished, "total": total},
) )
await _emit()
first_pass_cstarts = await _run_first_pass( first_pass_cstarts = await _run_first_pass(
db_session, db_session,
scholars=scholars, scholars=scholars,

View file

@ -487,9 +487,9 @@ watch(
</div> </div>
<p class="mt-2 text-sm text-secondary"> <p class="mt-2 text-sm text-secondary">
Started {{ formatDate(displayedLatestRun.start_dt) }}. Started {{ formatDate(displayedLatestRun.start_dt) }}.
<template v-if="runStatus.isLikelyRunning && runStatus.scholarProgress"> <template v-if="runStatus.isLikelyRunning">
{{ runStatus.scholarProgress.visited }} / {{ runStatus.scholarProgress.total }} visited {{ runStatus.scholarProgress?.visited ?? 0 }} / {{ runStatus.scholarProgress?.total ?? '…' }} visited
· {{ runStatus.scholarProgress.finished }} finished · {{ runStatus.scholarProgress?.finished ?? 0 }} finished
· {{ displayedLatestRun.new_publication_count }} new publications. · {{ displayedLatestRun.new_publication_count }} new publications.
</template> </template>
<template v-else> <template v-else>