feat: persist PR cache to UserDefaults for instant startup display#15
Merged
Conversation
On launch, restores the previous session's PR list immediately so the menu bar shows real data while the first GitHub fetch is in flight, eliminating the blank-list flash on startup. - PullRequest (and nested types) gains Codable conformance - New PRCacheService saves/restores main and Other PR lists as JSON; uses an in-session Data.hashValue guard to skip redundant writes - PRMonitorViewModel restores from cache before first poll, then saves after each successful refresh Co-authored-by: Buqian Zheng <zhengbuqian@users.noreply.github.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add PRCacheServiceTests (7 tests) covering round-trip, field fidelity, overwrite, empty-list clearing, and hash-guard correctness - Fix restoreFromCache() to re-apply WatchlistService truth over cached isWatched values, eliminating the stale-state window on startup - Extract private load<T>(forKey:) helper in PRCacheService to remove the loadMainPRs/loadOtherPRs duplication Co-Authored-By: zhengbuqian <zhengbuqian@users.noreply.github.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PullRequest(and its nestedRepositoryInfo,Author,Labeltypes) gainsCodableconformancePRCacheServicesaves/restores main and Other PR lists as JSON in UserDefaults; uses an in-sessionData.hashValueguard to skip redundant writesPRMonitorViewModelrestores from cache before the first poll so the menu bar shows real data immediately on launch, then saves after each successful refreshReview fixes (follow-up commit)
restoreFromCache()now re-appliesWatchlistServicetruth over cachedisWatchedvalues, eliminating a stale-state window on startupprivate load<T>(forKey:)helper inPRCacheServiceto removeloadMainPRs/loadOtherPRsduplicationPRCacheServiceTests(7 tests) covering round-trip, field fidelity, overwrite, empty-list clearing, and hash-guard correctnessUser-facing impact
Eliminates the blank PR list on startup. The previous session's data appears instantly; the list refreshes in place once the first GitHub fetch completes.
Credit
Feature originally implemented by @zhengbuqian in #8. Cherry-picked and adapted for the main branch.
Test plan
PRCacheServiceTests(7 tests, all passing)🤖 Generated with Claude Code