8000 Add thumbnail priority queue for viewport-based generation by tamzrod · Pull Request #84 · tamzrod/Librarian · GitHub
[go: up one dir, main page]

Skip to content

Add thumbnail priority queue for viewport-based generation - #84

Merged
tamzrod merged 1 commit into
mainfrom
feature/thumbnail-priority-queue
Jul 2, 2026
Merged

tamzrod merged 1 commit into
mainfrom
feature/thumbnail-priority-queue

Conversation

@tamzrod
@tamzrod tamzrod commented Jul 2, 2026
Copy link
Copy Markdown
Owner

Summary

Implements a priority-based thumbnail generation system so that images visible in the current Explorer viewport are generated first, rather than using FIFO queue order.

Problem

  • Explorer showed placeholders for images whose thumbnail jobs were pending
  • Workers processed jobs in FIFO order, ignoring viewport visibility
  • Users saw blank placeholders while workers generated thumbnails for images outside the viewport

Solution

  • Added priority-based scheduling with three levels:
    • Priority 100: Thumbnails visible in current Explorer viewport
    • Priority 50: Thumbnails in currently open folder
    • Priority 10: Background generation for remaining library

Changes

Backend (storage/postgres_backend.py)

  • update_job_priority() - Update priority of a queued job
  • prioritize_thumbnail_jobs() - Batch update priorities for multiple documents
  • create_or_update_thumbnail_job() - Create or update with deduplication

API (api/routes/operations.py)

  • Added POST /api/v1/operations/thumbnails/prioritize endpoint

Frontend (dashboard/src/)

  • ArtifactExplorer.tsx - Added Intersection Observer to track visible items
  • api.ts - Added prioritizeThumbnails() method

Map Fix (bonus)

  • Fixed Trace View map rendering regression
  • TraceView.css and MapCanvas.css - Added height: 100% to ensure proper flexbox height propagation

Success Criteria

  • Frontend reports visible document IDs
  • Existing generate_thumbnail jobs are reprioritized
  • Workers process higher priority jobs first (uses existing ORDER BY priority DESC)
  • No duplicate jobs created
  • Map visible in Trace view
  • Event stream remains docked at bottom

Testing

Build succeeded with no TypeScript errors.

@tamzrod can click here to continue refining the PR

- Backend: Added prioritize_thumbnail_jobs and create_or_update_thumbnail_job methods
- API: Added POST /api/v1/operations/thumbnails/prioritize endpoint
- Frontend: Added Intersection Observer to report visible documents
- Priority levels: 100 (viewport), 50 (folder), 10 (background)
- Includes map regression fix in TraceView and MapCanvas
@tamzrod
tamzrod marked this pull request as ready for review July 2, 2026 09:00
@tamzrod
tamzrod merged commit 937d202 into main Jul 2, 2026
3 of 7 checks passed
@tamzrod
tamzrod deleted the feature/thumbnail-priority-queue branch July 6, 2026 03:53
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.

2 participants

0