-
-
Notifications
You must be signed in to change notification settings - Fork 261
feat(ramps-controller): add request caching with TTL, deduplication, and abort support #7536
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
Merged
+925
−12
Conversation
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
Contributor
Author
|
cursor review |
Contributor
Author
|
cursor review. |
abb2793 to
a7497e4
Compare
Contributor
Author
|
cursor review |
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.
✅ Bugbot reviewed your changes and found no bugs!
wachunei
approved these changes
Dec 18, 2025
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.
Explanation
Current state: The RampsController has a simple
updateGeolocationmethod that fetches geolocation from the RampsService and stores it in state. There's no caching, deduplication, or request lifecycle management. When multiple UI components need the same data, each triggers a separate API call, leading to redundant network requests and inconsistent loading states across the app.Solution: This PR introduces a request caching infrastructure to RampsController that:
The
updateGeolocationmethod now uses this infrastructure, serving as the first implementation and a pattern for future controller methods.Non-obvious details:
requestsstate field is markedpersist: falsesince request cache should not survive app restarts.RequestState.statususes a template literal type (`${RequestStatus}`) rather than the enum directly to satisfy the controller'sStateConstraintJSON compatibility requirement.#updateRequestStateto work around immer'sDrafttype causing deep instantiation errors—this pattern exists elsewhere in the codebase.References
Checklist
Note
Introduces a request caching system with TTL, deduplication, aborting, and eviction, and updates RampsController (incl. updateGeolocation) to use it with new state and APIs.
requestscache to state (non-persisted) and metadata; reset on init.requestCacheTTL,requestCacheMaxSize.executeRequest(cached/deduped with TTL, error handling),abortRequest,getRequestState.timestampwhen exceedingrequestCacheMaxSize.updateGeolocationto use caching viacreateCacheKeyand returnstring.src/RequestCache.ts):RequestStatus,RequestState, cache utils (createCacheKey,isCacheExpired,createLoadingState,createSuccessState,createErrorState), defaults (DEFAULT_REQUEST_CACHE_TTL,DEFAULT_REQUEST_CACHE_MAX_SIZE).src/index.ts):Written by Cursor Bugbot for commit a7497e4. This will update automatically on new commits. Configure here.