-
Notifications
You must be signed in to change notification settings - Fork 73
feat: add AssetBatchSize and client persist options #567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add AssetBatchSize and client persist options #567
Conversation
- Add AssetBatchSize config to control batch size for asset loading (default: 25) - Add ClientPersistAssetQueue to persist current and upcoming assets in localStorage - Add ClientPersistAssetHistory to persist asset history in localStorage - Extract showAssets() function to centralize asset display logic - Update documentation with new config options and stale asset warnings Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add AssetBatchSize, ClientPersistAssetQueue, and ClientPersistAssetHistory defaults to the ServerSettingsV1Adapter for backwards compatibility. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdd three new general settings (AssetBatchSize, ClientPersistAssetQueue, ClientPersistAssetHistory); propagate them through backend models, DTOs, and API types; make GetAssets use AssetBatchSize; add frontend persisted stores and restoration/persistence logic for asset backlog, displaying assets, and history. Changes
Sequence DiagramsequenceDiagram
participant Browser as Client (Browser)
participant API as Server (API)
participant LS as LocalStorage
participant Pool as Asset Pool
Browser->>API: GET /client-settings
API-->>Browser: ClientSettings (assetBatchSize, persist flags)
alt clientPersistAssetQueue or clientPersistAssetHistory enabled
Browser->>LS: load `assetBacklog`, `displayingAssets`, `assetHistory`
alt persisted data found
LS-->>Browser: return persisted arrays
Browser->>Pool: render persisted displayingAssets
Browser->>Browser: restore image promises
else no persisted data
Browser->>API: Fetch assets (include clientIdentifier, batchSize)
API-->>Browser: return asset batch
Browser->>Pool: render fetched assets
Browser->>LS: persist backlog & displaying
end
else persistence disabled
Browser->>LS: clear persisted keys
Browser->>API: Fetch assets (include clientIdentifier, batchSize)
API-->>Browser: return asset batch
Browser->>Pool: render fetched assets
end
loop user navigates (next/previous)
Browser->>Browser: compute next/previous sets
Browser->>LS: persist backlog & history
Browser->>Pool: render updated displayingAssets
end
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
immichFrame.Web/src/lib/components/home-page/home-page.svelte (1)
344-387: Fix persistence key scoping to prevent cross-client data leakage.Persistence keys (
assetBacklog,assetHistory,displayingAssets) are hardcoded without client identifier. Switching?client=will restore the previous client's queue and history. Include the client identifier in the persistence keys or clear these stores when the client parameter changes.
🤖 Fix all issues with AI agents
In `@ImmichFrame.WebApi/Models/ServerSettings.cs`:
- Around line 73-75: ServerSettings.AssetBatchSize can be zero/negative and must
be validated in ServerSettings.Validate(); update Validate() to clamp or enforce
a minimum (e.g., if AssetBatchSize < 1 then set AssetBatchSize = 1 or throw) so
downstream logic never sees non-positive batch sizes—locate the ServerSettings
class and its Validate() method and add this check (use Math.Max(1,
AssetBatchSize) or equivalent).
🧹 Nitpick comments (1)
ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs (1)
129-131: Avoid default drift between V1 adapter and GeneralSettings.These hard-coded defaults can diverge from
GeneralSettingsover time. Consider referencing a shared constant/default source to keep them in sync.
Ensure AssetBatchSize is at least 1 to prevent issues with zero or negative batch sizes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Add
AssetBatchSizeconfig option to control how many assets are fetched per batch (default: 25)Rationale: Currently this is hardcoded to 25 but that means after 25 images you get a new batch of random assets where there could be collisions, making this configurable allows the user to determine how long they want to go before possible seeing duplicate assets.
Add
ClientPersistAssetQueueto persist current and upcoming assets in localStorage across browser restartsAdd
ClientPersistAssetHistoryto persist asset history in localStorage for back button functionality after refreshRationale: Currently if the client restarts (e.g. due to a power cycle on the TV or the app gets unintentionally closed, all viewed items and the current queue gets reset. This means
This makes it configurable to choose for all clients to persist the history and queue so you don't loose your place just because the app got closed.
Open questions/considerations
Summary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.