Skip to content

feat(photo-loader): progress bar for batch scheduling (CLI + web item-count)#1194

Merged
axisrow merged 3 commits into
mainfrom
ao/tg_content_factory_5863f66be3-6/issue-1152-progress
Jun 29, 2026
Merged

feat(photo-loader): progress bar for batch scheduling (CLI + web item-count)#1194
axisrow merged 3 commits into
mainfrom
ao/tg_content_factory_5863f66be3-6/issue-1152-progress

Conversation

@axisrow

@axisrow axisrow commented Jun 28, 2026

Copy link
Copy Markdown
Owner

What

Adds live progress feedback for long-running photo batch operations (#1152) — previously run-due could run silently for 30+ minutes.

Closes #1152

CLI (plain, no new deps)

  • Optional on_progress: Callable[[int, int], None] | None = None in PhotoTaskService.run_due and PhotoAutoUploadService.run_due. Without a callback behaviour is unchanged (existing test fakes keep working).
  • run_due_impl prints [done/total] ... (~Xm left) per item + a final summary, via _make_progress_printer/_format_eta/_print_progress_summary. Extends the existing print(f"[N]...") pattern — no rich/tqdm dependency added (owner decision).

Web (item-count parity)

  • New repo count method (completed/total items per batch) in repositories/photo_loader.py.
  • jobs_read_model surfaces completed_items/total_items.
  • New HTMX fragment photo_loader_batch_row.html with hx-get="/dialogs/photos/fragments/batches/{id}" + hx-trigger="every 5s" polling on RUNNING batches (server-driven swap per the HTMX policy — not fetch/SSE), shows N/M items.

Tests

CLI progress callback, repo counts, jobs_read_model fields, route fragment, photo task lifecycle. 99 passed isolated (-n 0); ruff clean. No new CLI leaf (callback on existing run-due) → no manifest change needed.

Note: authored by a worker session that stalled on a network reconnect after validation; orchestrator validated (99 passed isolated, ruff clean), staged the un-added HTMX fragment, and committed/pushed the completed work.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TShpckA1DoLNezbD3txTL1

axisrow and others added 2 commits June 29, 2026 02:28
…-count)

CLI: optional on_progress callback in PhotoTaskService.run_due and
PhotoAutoUploadService.run_due; run_due_impl prints plain "[done/total] ...
(~Xm left)" per item plus a final summary. No new dependencies (extends the
existing print(f"[N]...") pattern). Without a callback (None) behaviour is
unchanged — existing test fakes keep working.

Web (item-count parity): new repo count method (completed/total items per
batch), surfaced via jobs_read_model; new HTMX fragment
photo_loader_batch_row.html with hx-get/hx-trigger="every 5s" polling on
RUNNING batches (server-driven swap, per the HTMX policy — not fetch/SSE).

Tests: CLI progress callback, repo counts, jobs_read_model fields, route
fragment, photo task lifecycle. 99 passed isolated; ruff clean.

Closes #1152

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TShpckA1DoLNezbD3txTL1
- Stub bundle.count_due_items in TestPhotoTaskServiceRunDue (4 tests) — run_due
  now calls it unconditionally; bare MagicMock bundles raised
  "MagicMock can't be used in 'await'" (signature-change-breaks-fakes, #1117).
- run_due item_id path: on_progress(1, max(due_total, 1)) avoids "[1/0]" when an
  item is claimed by id before its schedule_at; loop path caps total at
  processed so progress never exceeds the snapshot total.
- Merge resolution kept the #1190 HELD Publish button: photo_loader_batch_row.html
  now carries the publish-form column (HELD batches stay web-publishable) and the
  table header has the Прогресс + publish columns.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TShpckA1DoLNezbD3txTL1
@axisrow axisrow force-pushed the ao/tg_content_factory_5863f66be3-6/issue-1152-progress branch from 6284efa to dbc5143 Compare June 28, 2026 18:33
count_due_items / count_items_by_batch_status are consumed by
PhotoTaskService / JobsReadModel (which hold a PhotoLoaderBundle, not
db.repos), so the progress-count reads must live on the bundle surface.
Legitimate +2 growth — raise the ratchet cap accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TShpckA1DoLNezbD3txTL1
@axisrow axisrow merged commit 17f7411 into main Jun 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add progress bar for batch photo scheduling

1 participant