Repository navigation
fix(skills): evict removed runtime discovery cache - #11489
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughRuntime environment removal and re-pairing now evict installed-agent skill discovery cache entries. Pending discoveries for evicted environments are invalidated, so stale results cannot repopulate the cache. Runtime target changes reset hook state and trigger fresh discovery. Tests cover selective rescans, preserved scans, re-pairing, suspended renders, and in-flight discovery behavior. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Re-pairing no longer allows a retired runtime’s skill results to appear for the replacement runtime. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
Greptile SummaryThis PR fixes a bug where skill-discovery cache entries for a removed or re-paired runtime environment would persist in renderer memory, causing stale skills to be served for that environment's next connection. It also prevents any in-flight discovery scan from repopulating the cache after its owning environment has been retired.
Confidence Score: 5/5Safe to merge — the change is scoped entirely to renderer-memory bookkeeping, with no IPC, network, or persistence surface touched. All four changed files are straightforward: a new per-key delete helper, a WeakSet-based invalidation guard on in-flight promises, one call-site wired into an existing retirement boundary, and three targeted regression tests. The self-referential closure on Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/src/hooks/installed-agent-skill-discovery-cache.ts | Adds deleteInstalledAgentSkillDiscoveryCache(key) to enable per-key eviction without clearing the entire LRU map; minimal and correct. |
| src/renderer/src/hooks/installed-agent-skill-discovery.ts | Introduces invalidatedPendingDiscoveries WeakSet and evictInstalledAgentSkillDiscoveryForRuntimeEnvironments; the self-referential closure on discovery in the .then() guard is a valid JS pattern and correctly prevents stale in-flight scans from writing to cache. |
| src/renderer/src/store/slices/runtime-status.ts | Calls evictInstalledAgentSkillDiscoveryForRuntimeEnvironments at the correct setRuntimeEnvironments boundary for both removed and re-paired environments, before other retired-state teardown. |
| src/renderer/src/store/slices/runtime-status-skill-cache-eviction.test.ts | Three regression tests covering targeted removal, re-pair eviction without churning unchanged runtimes, and in-flight scan suppression; all three cases are red/green validated per PR notes. |
Reviews (2): Last reviewed commit: "fix(skills): evict removed runtime disco..." | Re-trigger Greptile
38d51a7 to
aa2255c
Compare
aa2255c to
5d44ad7
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Contributor hygiene: rebased onto current Still needs a maintainer to Approve and run workflows for full CI. |
… same id - Fold the pairing revision into useActiveSkillDiscoveryRuntimeTarget's selector so a same-id re-pair yields a new runtime target and every mounted useInstalledAgentSkillNames effect re-runs instead of holding the retired peer's installed list after the module cache is evicted. - Reset hook-local result/loading state on runtime target identity change, which also bumps the refresh generation so an in-flight scan issued to the retired peer can no longer commit its result into React state. - Add mounted-hook regression tests covering the re-pair rescan and the in-flight stale-scan fence.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 0a55ab92-5122-490c-a908-f5cfcb10296f
📒 Files selected for processing (3)
src/renderer/src/hooks/use-active-skill-discovery-runtime-target.tssrc/renderer/src/hooks/useInstalledAgentSkills.react.test.tsxsrc/renderer/src/hooks/useInstalledAgentSkills.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
| stateResetInputRef.current.discoveryTargetKey !== discoveryTargetKey || | ||
| stateResetInputRef.current.enabled !== enabled | ||
| stateResetInputRef.current.enabled !== enabled || | ||
| stateResetInputRef.current.runtimeTarget !== runtimeTarget |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Fence retired scans by runtime target identity.
React can run the retired request’s promise continuation after the re-pair render but before the replacement passive effect increments refreshGenerationRef. The unchanged discoveryTargetKey and generation then let the retired request queue a stale setResult update. If the replacement scan fails, its catch path does not clear that result. The current test resolves the retired scan after act flushes passive effects, so it does not cover this ordering.
Capture and compare the request’s runtimeTarget, and add a regression test that settles the retired request before passive effects run.
Proposed stale-result guard
const refresh = useCallback(
async (force = true, showLoading = true): Promise<boolean> => {
const requestDiscoveryTargetKey = discoveryTargetKey
+ const requestRuntimeTarget = runtimeTarget
const requestGeneration = ++refreshGenerationRef.current
const writeIfCurrent = (write: () => void): void => {
if (
mountedRef.current &&
requestGeneration === refreshGenerationRef.current &&
currentDiscoveryTargetKeyRef.current === requestDiscoveryTargetKey &&
+ stateResetInputRef.current.runtimeTarget === requestRuntimeTarget
) {
write()
}…ef write React Doctor flagged the render-phase write to stateResetInputRef. React can discard a render after the write, in which case the next render sees "already reset" and keeps painting the previous target's skill list until a rescan. Track the reset inputs in useState and adjust it during render instead, which React replays safely. Also drop the `as never` / `as GlobalSettings` casts from the tests this PR added, since main now enforces consistent-type-assertions on changed lines.
ELI5
When you remove or re-pair a server, Orca now forgets its old cached skill list and prevents a late scan from restoring it. Other servers and local skill lists keep their caches.
Details
Removed and re-paired runtime environments left their skill-discovery results in the renderer cache. Retired entries could also displace useful local/WSL entries from its 256-target capacity, and a late scan could restore a removed entry.
The existing catalog removal/re-pair boundary now evicts the exact runtime-scoped cache entry and detaches its pending scan. Completion writes use the existing current-promise identity check, so a retired scan cannot restore the cache or overwrite its replacement. This needs no additional invalidation collection. Surviving runtimes, local/WSL targets, scan coalescing, forced refresh behavior, and the 15-second freshness policy are preserved; unchanged catalog updates do not trigger scans.
Validation against main
fa3d29fa11e3, withORCA_BACKGROUND_LAUNCH=1:Original contributor history is preserved. These are local unit/component checks on macOS; no live Electron or remote-host run is claimed. No layout, wire, filesystem, or provider API changed.
Fixes #11429.