chore: port CodeRabbit review fixes from upstream PR - #5
Merged
Conversation
Bound cache entries by savedAt so a permanently-gone proxy no longer serves the same stale model list forever. Add readModelCacheSavedAt so callers can throttle background refreshes on still-fresh caches.
Prevents readers from observing a partially-written JSON file when two OpenCode processes refresh the same baseURL concurrently.
Extract a withTimeout helper that clears its setTimeout once the race settles, so a completed discovery doesn't leave a pending timer holding a short-lived process open.
Skip revalidation when the cache's savedAt is within REFRESH_MIN_INTERVAL_MS so a burst of session.created events can't generate repeated health checks and discovery traffic. refreshInFlight still guards concurrent runs.
mergeModels now returns the ids it actually added, and injectedModelIds stores exactly those instead of every provider key (which included user-curated entries). Also use Object.hasOwn so entries that are null, false, or 0 aren't treated as absent.
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.
Ports the CodeRabbit-driven fixes from the upstream PR (yuseferi#19) back to this fork.
Changes
withTimeouthelper) so a completed discovery doesn't leave a pending timer holding a short-lived process open.session.createdevents can't generate repeated health-check/discovery traffic.readModelCacheSavedAtused by the throttle.renameSync) so readers never see a partial JSON file.mergeModelsreturns the ids it actually added;injectedModelIdsstores only those (not every provider key). UsesObject.hasOwnsonull/false/0entries aren't treated as absent.homedir()once incacheDir().The info-log removal from PR #4 is preserved (the cache-load
console.logwas intentionally dropped during the port).Testing
npm run typecheckpasses.