feat: add 'keep chat images' toggle to preserve chat images across restarts (#563) - #828
feat: add 'keep chat images' toggle to preserve chat images across restarts (#563)#828ghshhf wants to merge 1 commit into
Conversation
…starts (AAswordman#563) Implement upstream issue AAswordman#563: a user setting that, when enabled, stops ImagePoolManager from clearing the on-disk image cache on startup and from deleting disk files when the in-memory LRU pool evicts entries. Plumbing: new KEEP_CHAT_IMAGES DataStore preference, injected into ImagePoolManager at Application startup. UI: a Switch added to ChatHistorySettingsScreen with en/base string resources. Also adds JsCalculator JVM regression tests under core/tools.
Review CommentThanks for the contribution — the feature direction is correct and the implementation is clean for what it covers. However, I'd like to request a few changes before this can be merged. Blocking issues1. Merge conflicts — GitHub currently reports this PR as conflicting with 2. Toggle does not take effect without app restart Currently the preference is read once in // OperitApplication.kt — startup only
val keepChatImages = runBlocking { ... .keepChatImages.first() }
ImagePoolManager.keepChatImages = keepChatImagesThe settings screen only calls // ChatHistorySettingsScreen.kt — only persists, no runtime sync
userPreferencesManager.setKeepChatImages(enabled)This means:
There's no UI hint about needing a restart, so users will assume the switch is broken. Suggested fix: Either have 3. CI: JVM checks failing The PR Check workflow fails at Step 31 "Run Android JVM checks" (not at a secrets/config step — the build and dependency steps all succeed). This is the JVM unit test stage, so it's likely that either the new Non-blocking but should address4. Unrelated calculator tests should be split out The 94-line 5. No tests for the image retention feature itself The PR adds tests for the calculator but none for the
Note on
|
| Item | Status |
|---|---|
| Merge conflict | ❌ Must resolve |
| Toggle not live-updating | ❌ Must fix |
| CI JVM checks failing | ❌ Must investigate |
| Unrelated calculator tests | |
| Missing feature tests | |
removeImagesFromLastUserMessage |
✅ No change needed |
Verdict: Request changes. The core logic is sound, but the runtime-sync gap and CI failure need to be addressed first.
AAswordman
left a comment
There was a problem hiding this comment.
Request changes.\n\nP1: The PR is currently conflicting with main and Candidate checks fail during Android JVM tests; both must be resolved on an updated branch.\n\nP1: keepChatImages is read once at application startup, while the settings switch only persists DataStore. Toggling it during a running session therefore does not change ImagePoolManager behavior, although the UI gives no restart requirement. Wire the setting change to the runtime manager.\n\nP2: JsCalculatorRegressionTest is unrelated to chat-image retention and should be split from this feature. The image-retention behavior itself also needs focused coverage for startup cleanup and LRU eviction.
Summary
Implements upstream issue #563: a user setting "Keep chat images" that, when enabled, prevents
ImagePoolManagerfrom clearing the on-disk image cache on app startup and from deleting disk files when the in-memory LRU pool evicts entries. Chat images are therefore preserved across restarts and cache eviction.Changes
ImagePoolManager: addedkeepChatImagesflag; skipclearDiskCache()at startup and skipdeleteFromDisk()on LRU eviction when enabled.UserPreferencesManager: newKEEP_CHAT_IMAGESDataStore preference with Flow + setter.OperitApplication: read the preference before initializing the image pool, so startup does not wipe the disk cache.ChatHistorySettingsScreen: new Switch (with description) bound to the preference.values/strings.xml+values-en/strings.xml: new strings (zh + en).JsCalculatorRegressionTest: added pure-JVM regression tests undercore/tools/calculator(no Android dependency).Testing
Closes #563