Skip to content

perf: bandwidth optimization#20

Merged
Simplereally merged 4 commits intomainfrom
chore/bandwidth-optimization
Jan 17, 2026
Merged

perf: bandwidth optimization#20
Simplereally merged 4 commits intomainfrom
chore/bandwidth-optimization

Conversation

@Simplereally
Copy link
Copy Markdown
Owner

@Simplereally Simplereally commented Jan 17, 2026

Summary by CodeRabbit

  • Performance Improvements

    • Faster favorite status loading in galleries via batched checks
    • Improved following feed retrieval and reduced batch-list payloads for snappier lists
  • UX / Layout

    • Gallery scroll container and overflow handling improved for more consistent scrolling
  • Behavior

    • More consistent favorite heart display with optimistic updates and prefetched statuses
  • Tests

    • Expanded gallery, image-card, and aspect-ratio test coverage
  • Documentation

    • Added bandwidth & performance audit and guidance document

✏️ Tip: You can customize this high-level summary in your review settings.

- Item #1: Create toBatchJobSummary helper to strip generationParams (10-50KB)
  from getUserBatchJobs and getUserActiveBatches list views

- Item #2: Fix ImageCard N+1 subscriptions by batch-fetching favorites
  in PaginatedImageGrid, reducing 50+ useQuery calls to 1

- Item #3: Optimize getFollowingFeed to use per-user indexed queries
  instead of scanning all public images (O(n*k) vs O(total_public))

- Items #4-5: Document enrichImages full-doc limitation and
  generationParams v.any() size concerns in schema comments
…lleries by adding `min-h-0` and `overflow-hidden` to the scroll container and introducing new tests.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jan 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
bloomstudio Ready Ready Preview, Comment Jan 17, 2026 3:17pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

Batch-fetch favorite statuses in the gallery, add an optional isFavorited prop to ImageCard to avoid per-item subscriptions, reduce batch job payloads with a summarized type, rework following feed to per-user indexed queries, add layout/tests and bandwidth-audit docs.

Changes

Cohort / File(s) Summary
Batch Favorite Status Optimization
components/gallery/paginated-image-grid.tsx, components/ui/image-card.tsx, components/ui/image-card.test.tsx
Parent now computes imageIds and calls api.favorites.batchIsFavorited once; ImageCard gains optional isFavorited?: boolean prop and conditionally skips its own useQuery when prop is present or user is signed out. Tests added to validate skip and UI state.
Gallery Layout & Scroll Tests
components/studio/gallery/image-gallery.tsx, components/studio/gallery/image-gallery.test.tsx
Added min-h-0 and overflow-hidden to the ScrollArea container; expanded tests covering scroll container rendering, flex/min-height classes, overflow behavior, and scrollability thresholds across image counts.
Convex Batch Job Summary / Schema Note
convex/batchGeneration.ts, convex/schema.ts
Introduced BatchJobSummary and converter to trim heavy fields from list endpoints; updated list queries to return summaries. Added documentation comment warning about generationParams size.
Following Feed Optimization
convex/generatedImages.ts
Replaced public all-image scan with per-followed-user indexed queries (by_owner_visibility), fetching N recent images per user, merging, sorting, and paginating the combined results.
Bandwidth Audit Documentation
todo/bandwidth-optimization.md, todo/convex-bandwidth-audit.md
Added two audit documents detailing bandwidth drivers, prioritized recommendations, and action plans for Convex optimizations.
Aspect Ratio & Tiered Dimensions
hooks/use-aspect-ratio-dimensions.ts, hooks/use-aspect-ratio-dimensions.test.ts
Added logic to prefer standard HD dimensions for matching model bases, fallback scaling from custom bases with rounded outputs; tests added for SD/HD tier behavior and dimension options.

Sequence Diagram(s)

sequenceDiagram
    participant Parent as PaginatedImageGrid
    participant Convex as Convex API
    participant Child as ImageCard
    participant Auth as Auth (useUser)

    Parent->>Auth: check isSignedIn
    Parent->>Parent: compute imageIds (useMemo)
    Parent->>Convex: useQuery(api.favorites.batchIsFavorited, {imageIds})
    Convex-->>Parent: favoriteStatuses {id: boolean}

    rect rgba(100,200,100,0.5)
    Parent->>Child: render with isFavorited={favoriteStatuses[id]}
    end

    rect rgba(200,100,100,0.5)
    Child->>Auth: check isSignedIn (if needed)
    alt isFavorited prop provided or not signed in
        Child-->>Child: skip per-item useQuery
    else
        Child->>Convex: useQuery(api.favorites.isFavorited, {imageId})
        Convex-->>Child: isFavoritedQuery
    end
    Child-->>Child: displayFavorited = optimistic > prop > query > false
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

Poem

🐰 I hop through code with cheer,
Batching hearts so queries clear,
Feeds per-user, payloads slim,
Tests and notes — a tidy brim.
Hooray! The gallery leaps light and near.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'perf: bandwidth optimization' directly relates to the main objectives of the changeset: batch favorite status retrieval, optimized batch job summaries, and feed pagination improvements to reduce bandwidth.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…standard resolution lookups and custom base scaling, adding tests for video models.
@Simplereally Simplereally merged commit 4b9dadb into main Jan 17, 2026
4 checks passed
@Simplereally Simplereally deleted the chore/bandwidth-optimization branch January 17, 2026 15:19
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.

1 participant