Skip to content

Configurable asset fetch batch size#662

Closed
Zaida-3dO wants to merge 2 commits into
immichFrame:mainfrom
Zaida-3dO:feature/configurable-asset-batch-size
Closed

Configurable asset fetch batch size#662
Zaida-3dO wants to merge 2 commits into
immichFrame:mainfrom
Zaida-3dO:feature/configurable-asset-batch-size

Conversation

@Zaida-3dO

@Zaida-3dO Zaida-3dO commented Jul 3, 2026

Copy link
Copy Markdown

Assets are served from Immich via a stateless random search (SearchRandomAsync). Each batch returns 25 distinct assets, but there is no cross-batch "already shown" tracking — so once the frontend exhausts a batch and refetches, the next random draw can repeat images the viewer just saw. This means that currently, though I have hundreds of images in my album, I still get repetitions every 2 weeks or so.

Change summary

Makes the number of assets fetched per request configurable via a new AssetBatchSize general setting (default 25, clamped to 1–1000), replacing the hardcoded 25 in PooledImmichFrameLogic.GetAssets().

Summary by CodeRabbit

  • New Features
    • Added General.AssetBatchSize setting to control how many assets are fetched per request (default: 25), with matching updates to example Docker settings.
  • Bug Fixes
    • Enforced safe batch-size limits by clamping the configured value to Immich’s supported range (1–1000).
  • Documentation
    • Updated configuration reference and setup examples to include General.AssetBatchSize.
  • Tests
    • Extended V1/V2 test configuration resources to cover the new setting.
  • Chores
    • Updated version control ignore rules for additional generated/tool-local files.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 96aba698-ae97-4c1f-bb92-5a74301509d8

📥 Commits

Reviewing files that changed from the base of the PR and between a48f13a and d1f0ce3.

📒 Files selected for processing (10)
  • ImmichFrame.Core/Interfaces/IServerSettings.cs
  • ImmichFrame.Core/Logic/PooledImmichFrameLogic.cs
  • ImmichFrame.WebApi.Tests/Resources/TestV1.json
  • ImmichFrame.WebApi.Tests/Resources/TestV2.json
  • ImmichFrame.WebApi.Tests/Resources/TestV2.yml
  • ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs
  • ImmichFrame.WebApi/Models/ServerSettings.cs
  • docker/Settings.example.json
  • docker/Settings.example.yml
  • docs/docs/getting-started/configuration.md
✅ Files skipped from review due to trivial changes (4)
  • ImmichFrame.WebApi.Tests/Resources/TestV1.json
  • docs/docs/getting-started/configuration.md
  • ImmichFrame.WebApi.Tests/Resources/TestV2.json
  • ImmichFrame.WebApi.Tests/Resources/TestV2.yml
🚧 Files skipped from review as they are similar to previous changes (5)
  • docker/Settings.example.json
  • ImmichFrame.Core/Logic/PooledImmichFrameLogic.cs
  • ImmichFrame.Core/Interfaces/IServerSettings.cs
  • ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs
  • docker/Settings.example.yml

📝 Walkthrough

Walkthrough

Adds a new AssetBatchSize configuration setting, wires it through settings interfaces and adapters, uses it in asset fetching, and updates example configs, test resources, docs, and ignore rules.

Changes

AssetBatchSize configuration and usage

Layer / File(s) Summary
Interface contract and batch fetching logic
ImmichFrame.Core/Interfaces/IServerSettings.cs, ImmichFrame.Core/Logic/PooledImmichFrameLogic.cs
IGeneralSettings gains an AssetBatchSize int property; GetAssets() reads it, clamps it to 1..1000, and passes the result to _pool.GetAssets().
Settings model and V1 adapter
ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs, ImmichFrame.WebApi/Models/ServerSettings.cs
ServerSettingsV1, GeneralSettings, and the V1 adapter expose AssetBatchSize with a default value of 25.
Example configs, test resources, docs, and ignore rules
docker/Settings.example.json, docker/Settings.example.yml, docs/docs/getting-started/configuration.md, ImmichFrame.WebApi.Tests/Resources/TestV1.json, ImmichFrame.WebApi.Tests/Resources/TestV2.json, ImmichFrame.WebApi.Tests/Resources/TestV2.yml, .gitignore
Example and test configs add AssetBatchSize, docs describe the setting and clamping behavior, and .gitignore ignores additional local/generated files.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: JW-CH

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: making the asset fetch batch size configurable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs`:
- Around line 139-141: GeneralSettingsV1Adapter.Validate() is currently empty,
so legacy V1 configs can bypass the AssetBatchSize 1–1000 bounds and pass
invalid values through the adapter. Update the Validate method in
GeneralSettingsV1Adapter to apply the same clamping logic used by
GeneralSettings for AssetBatchSize, or refactor the shared validation into a
common helper that both paths call.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7bf6efc7-f749-4ef2-97d2-c3c1819cbffb

📥 Commits

Reviewing files that changed from the base of the PR and between 682fdc4 and a48f13a.

📒 Files selected for processing (11)
  • .gitignore
  • ImmichFrame.Core/Interfaces/IServerSettings.cs
  • ImmichFrame.Core/Logic/PooledImmichFrameLogic.cs
  • ImmichFrame.WebApi.Tests/Resources/TestV1.json
  • ImmichFrame.WebApi.Tests/Resources/TestV2.json
  • ImmichFrame.WebApi.Tests/Resources/TestV2.yml
  • ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs
  • ImmichFrame.WebApi/Models/ServerSettings.cs
  • docker/Settings.example.json
  • docker/Settings.example.yml
  • docs/docs/getting-started/configuration.md

Comment on lines +139 to 141
public int AssetBatchSize => _delegate.AssetBatchSize;

public void Validate() { }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the relevant files and inspect the surrounding code.
git ls-files | rg 'ImmichFrame\.WebApi/(Helpers/Config/ServerSettingsV1\.cs|Models/ServerSettings\.cs|.*PooledImmichFrameLogic.*|.*Settings.*)'
printf '\n--- ServerSettingsV1.cs ---\n'
wc -l ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs
cat -n ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs | sed -n '1,220p'

printf '\n--- ServerSettings.cs ---\n'
wc -l ImmichFrame.WebApi/Models/ServerSettings.cs
cat -n ImmichFrame.WebApi/Models/ServerSettings.cs | sed -n '1,260p'

printf '\n--- Search for AssetBatchSize and Validate usages ---\n'
rg -n "AssetBatchSize|Validate\(\)|GetAssets\(" ImmichFrame.WebApi -g '!**/bin/**' -g '!**/obj/**'

Repository: immichFrame/ImmichFrame

Length of output: 15652


Clamp AssetBatchSize in the V1 adapter

GeneralSettingsV1Adapter.Validate() is still empty, so legacy V1 configs bypass the 1–1000 clamp and can send invalid sizes to Immich’s /search/random. Add the same clamp here, or share the validation with GeneralSettings.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs` around lines 139 -
141, GeneralSettingsV1Adapter.Validate() is currently empty, so legacy V1
configs can bypass the AssetBatchSize 1–1000 bounds and pass invalid values
through the adapter. Update the Validate method in GeneralSettingsV1Adapter to
apply the same clamping logic used by GeneralSettings for AssetBatchSize, or
refactor the shared validation into a common helper that both paths call.

Replace the hardcoded batch size of 25 in PooledImmichFrameLogic.GetAssets()
with a configurable AssetBatchSize general setting (default 25).

- Add AssetBatchSize to IGeneralSettings and GeneralSettings (V2 config) and the
  legacy V1 flat config (ServerSettingsV1 + adapter)
- Clamp to Immich's random-search range of 1-1000 at the point of use in
  GetAssets(), so every config source (V1 and V2) stays within bounds
- Document in configuration.md and the docker example settings files
- Update config-loader test resources for the new property
@Zaida-3dO Zaida-3dO force-pushed the feature/configurable-asset-batch-size branch from a48f13a to d1f0ce3 Compare July 3, 2026 12:34
@Zaida-3dO Zaida-3dO marked this pull request as draft July 3, 2026 12:59
@Zaida-3dO

Copy link
Copy Markdown
Author

I just realized that this assumption is false if you use filters

Each batch returns 25 distinct assets,

@Zaida-3dO Zaida-3dO closed this Jul 3, 2026
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