Skip to content

Conversation

@Zaida-3dO
Copy link

@Zaida-3dO Zaida-3dO commented Jan 18, 2026

Problem: The original splitview logic only paired horizontal images if they were adjacent (positions 0 and 1). If a vertical image was between two horizontal ones, the first horizontal would display alone, looking awkward.

Summary

  • Smarter horizontal image pairing in splitview layout - looks ahead at 3 candidates instead of 2
  • Skips vertical images to pair horizontal images that aren't adjacent in the queue
  • Avoids showing lone horizontal images that look awkward in splitview

Drive by fix

  • Passes clientIdentifier on asset requests to improve logs
  • The original isHorizontal() function actually checked if height > width (portrait orientation). Renamed to isPortrait() for clarity.

Details

Solution: New selectAssetsForDisplay() function with smarter logic:

  • If first image is vertical → show it alone
  • If first and second are both horizontal → pair them [0, 1]
  • If first is horizontal, second is vertical, third is horizontal → pair [0, 2], skipping the vertical
  • If first is horizontal with no horizontal partner → skip it and show the vertical instead

This improves the visual experience by maximizing horizontal pairings and avoiding lone horizontal images in splitview.

Open question/discussion

I was thinking about making this configurable for back compat reasons, by adding a "splitview-forced" option for layout, but that felt like overkill and I struggle to think of a valid use case for wanting to keep the "sometimes splitview shows a lone portrait item" behaviour. So opted to just change the default behavior for all "splitview"

Summary by CodeRabbit

Summary by CodeRabbit

  • Refactor
    • Improved asset selection and navigation when browsing your photo library, with smarter candidate-based selection and better handling of portrait/landscape orientations (improves pairing and layout display).
    • Asset requests now consistently include client identifier for image loading.

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

- Pass clientIdentifier to getAsset() for better logging/tracking
- Add selectAssetsForDisplay() to look ahead 3 images when pairing
- Skip lone horizontal images by checking if 2nd or 3rd can pair
- Extract removeAtIndices() helper for cleaner array manipulation
@coderabbitai
Copy link

coderabbitai bot commented Jan 18, 2026

📝 Walkthrough

Walkthrough

Home page asset loading now includes a clientIdentifier and replaces backlog/history batching with candidate-based selection and orientation-aware display logic via new helpers that pick and remove asset indices and update portrait detection.

Changes

Cohort / File(s) Summary
Asset Selection Refactor
immichFrame.Web/src/lib/components/home-page/home-page.svelte
Asset requests now pass clientIdentifier. Removed previous backlog/history batching logic and introduced candidate-based selection: getNextAssets takes up to 3 candidates from the front of assetBacklog, getPreviousAssets takes up to 3 from the end of assetHistory (reversed for selection). Added selectAssetsForDisplay(layout, candidates) to choose which candidate indices to display (prioritizes portrait pairings in splitview), and removeAtIndices(arr, indicesToRemove) to remove elements by index. Renamed isHorizontalisPortrait and updated orientation logic to handle flipped dimensions. Comments and flow updated accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble through the asset stack with glee,
Picking three candidates for screens to see,
Portraits pair where splitviews play,
Indices hop off, then fade away,
The homepage shuffles — neat as can be!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely summarizes the main change: improving splitview horizontal image pairing logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@immichFrame.Web/src/lib/components/home-page/home-page.svelte`:
- Around line 217-251: The pairing logic is inverted because isHorizontal()
currently returns imageHeight > imageWidth (true for portrait), causing
selectAssetsForDisplay() (variables h0, h1, h2 and checks like if (!h0), if
(h1), etc.) to treat portrait images as "horizontal"; fix by changing
isHorizontal() to return imageWidth > imageHeight so its boolean matches its
name and the intended pairing logic, then run/adjust any comments or tests
referencing isHorizontal() behavior to reflect the corrected orientation
semantics.

Zaida-3dO and others added 2 commits January 18, 2026 21:39
The function was incorrectly named - it checks if height > width,
which means portrait orientation, not horizontal/landscape.
Renamed to isPortrait and updated variable names and comments
to accurately reflect the behavior.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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