Repository navigation
fix(skills): read installed skills from the connected remote runtime - #6887
Conversation
The "Not installed" badge stayed on in Settings even after a skill was installed against a remote `orca serve`. Skill discovery always ran through the local `skills:discover` IPC, so it scanned the client's home dir while the install (and the skill files) landed on the server. The skills browser had the same blind spot. Route discovery to the runtime that owns it, mirroring git/hooks/terminal: local IPC by default, remote runtime RPC (`skills.discover`) when an Orca runtime environment is active. The discovery cache is now scoped per runtime so local and remote results never collide. Extract the discovery cache/transport into a store-free module (`installed-agent-skill-discovery.ts`) and a shared runtime-target hook, so the React hook stays under `max-lines` and store slices can import the change-notifier without pulling the app store into a circular import. Independent of the terminal selector fix (stablyai#6816); addresses the still-broken install-status half of stablyai#6789.
|
Ready to review this PR? Stage has broken it down into 4 individual chapters for you: Chapters generated by Stage for commit 242ab7c on Jun 30, 2026 10:09am UTC. |
📝 WalkthroughWalkthroughSkill discovery is now runtime-target-aware. A new 🚥 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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/skills/SkillsPage.tsx (1)
217-223: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winError toast still says "local" but discovery can now target a remote runtime.
Since
discoverSkillsForRuntimeTarget(runtimeTarget)routes to a remoteorca servewhen a remote runtime is active, the hardcoded "Could not scan local skills" message is misleading in that path. Consider a runtime-agnostic message (or branch onruntimeTarget.kind).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 0a90c1bc-043c-4970-a94a-9c458c61a664
📒 Files selected for processing (7)
src/renderer/src/components/skills/SkillsPage.tsxsrc/renderer/src/hooks/installed-agent-skill-discovery.tssrc/renderer/src/hooks/use-active-skill-discovery-runtime-target.tssrc/renderer/src/hooks/useInstalledAgentSkills.tssrc/renderer/src/runtime/runtime-skills-client.test.tssrc/renderer/src/runtime/runtime-skills-client.tssrc/renderer/src/store/slices/repos.ts
Address review on stablyai#6887: - The skills-scan error toast said "Could not scan local skills", but discovery can now target a remote runtime; drop "local" (source + locales). - Add short JSDoc to the discovery helpers and skill hooks to clear the docstring-coverage gate.
|
Associating this PR with related issue(s): #6789 |
1 similar comment
|
Associating this PR with related issue(s): #6789 |
…alled-badge-for-skills-in-settings # Conflicts: # src/renderer/src/hooks/useInstalledAgentSkills.ts # src/renderer/src/i18n/locales/es.json
… cache Rebuilt on the repo's standard runtime-client pattern (getActiveRuntimeTarget + callRuntimeRpc) instead of a bespoke transport, and keeps the renderer discovery cache keyed per runtime so a remote result never leaks into the local host's badge after switching environments.
…cycle Reading the active runtime from the app store inside the hook module closed a cycle (store -> repos slice -> hook -> store) that broke module init in three suites. The cache/transport moves to a store-free module the repos slice can import; only the hook itself touches the store.
Reviewer round 1 found the badge could scan a different machine than the Install button writes to: skill install terminals route through getSingleFocusedRuntimeEnvironmentId, which declines to guess an owner while several runtimes are saved, so a two-environment user installed locally while discovery scanned the remote and the badge never flipped. Discovery now resolves through that same resolver, and holds a loading state until settings and the runtime catalog have hydrated instead of flashing 'Not installed'. Also drops the unreachable cwd/worktreeId forwarding (no caller can produce it) and retires three SkillsPage strings that a remote scan makes false.
- SkillsPage had no generation guard, so a slow local scan could land after a newer remote scan and silently redisplay the client's skills. - The round-2 selector took a useShallow object including runtimeEnvironments, whose identity churns on every status refresh; that re-fired every consumer's scan. Select the resolved id instead. - A failed runtime-environment catalog read never set the hydrated flag, so discovery would have spun for the whole session with no retry affordance. An unreadable catalog is settled, which is what terminal routing assumes. - Remote cache keys no longer fragment on a client-side target the remote call discards, which was issuing the same RPC once per target shape. - Cover each hydration conjunct separately; the combined test covered neither. - First tests for SkillsPage, which had none.
Round 3 set runtimeEnvironmentCatalogHydrated on a failed catalog read so skill discovery would stop waiting. That flag also gates fail-closed host routing (worktree-operation-route mayBeLegacyLocal), so flipping it on failure would have routed ownerless legacy worktrees — including removals — to the local host off a stale empty list. Add a separate 'settled' flag for surfaces that only need to stop waiting, and leave 'hydrated' meaning what its doc says. fetchSettings now probes the catalog even when the settings read fails, so a rejected settings.get cannot strand every skill badge on a spinner.
The only hunk in the review no mutation could kill.
|
Thanks for this — the diagnosis was right and the direction you picked (route discovery through the runtime that owns it, and scope the renderer cache per runtime) is the one we kept. I rebased onto latest main and pushed review fixes on top; here is what changed and why. Kept from your PR
Fixed during review
Validated against a real paired
Known gaps, deliberately not in scope here — worth follow-ups:
|
| const revealSkill = async (): Promise<void> => { | ||
| const result = await window.api.shell.openInFileManager(skill.skillFilePath) | ||
| if (!result.ok) { | ||
| toast.error( | ||
| translate('auto.components.skills.SkillsPage.995fde8337', 'Could not reveal skill file') | ||
| ) | ||
| } | ||
| } |
There was a problem hiding this comment.
"Reveal file" silently fails for remote skills
revealSkill always calls window.api.shell.openInFileManager which is a local Electron IPC. When SkillsPage is pointed at a remote runtime (the scenario this PR fixes), skill.skillFilePath is an absolute path on the remote server (e.g., /home/remote-user/.agents/skills/…/SKILL.md). That path does not exist on the client's disk, so the call will fail and show the "Could not reveal skill file" toast on every click. This is a new failure mode created by this PR: before it, SkillsPage only received local paths; now it can receive remote ones.
The simplest fix is to hide or disable the button when the parent page's runtimeTarget.kind === 'environment', or to pass the runtime target as a prop and skip the reveal attempt for remote skills.
Greptile SummaryThis PR fixes skill install-status badges staying on "Not installed" when connected to a remote
Confidence Score: 4/5The routing and caching logic is well-reasoned and well-tested, but the new SkillsPage remote-skill code leaves the "Reveal file" button broken for any skill discovered on a remote runtime. The core discovery-routing change (new runtime-scoped cache key, settled/hydrated flag split, gating on catalog state) is correct and covered by dedicated tests. The one concrete breakage is SkillCard.revealSkill: it always calls the local shell.openInFileManager IPC, which will fail whenever SkillsPage shows skills from a remote runtime — a case that didn't exist before this PR. Every user on a remote orca serve who opens the Skills browser and clicks "Reveal file" will hit the error toast. That's the only issue, and it is scoped to a secondary UI action (not the badge fix itself), but it is a real regression on the new code path. Files Needing Attention: src/renderer/src/components/skills/SkillCard.tsx — the revealSkill handler needs to be aware of whether the current runtime target is remote.
|
| Filename | Overview |
|---|---|
| src/renderer/src/components/skills/SkillCard.tsx | Extracted from SkillsPage; revealSkill always calls local shell.openInFileManager, which will silently fail when the card displays skills discovered on a remote runtime. |
| src/renderer/src/components/skills/SkillsPage.tsx | Refactored to scan through the active runtime target; adds generation guard to prevent stale scan overwrites. SkillCard extracted to its own file. Reveal-file button in SkillCard will fail for remote skill paths. |
| src/renderer/src/runtime/runtime-skills-client.ts | New module: routes skills discovery to local IPC or remote RPC based on the active runtime target; target is intentionally dropped for remote calls to avoid forwarding client-side WSL/project-runtime fields to a Linux server. |
| src/renderer/src/hooks/installed-agent-skill-discovery.ts | Extracted from useInstalledAgentSkills: per-runtime cache/dedup layer. Cache key is now runtime-scoped (remote env keyed by environmentId, local by target shape) to prevent cross-runtime cache collisions. |
| src/renderer/src/hooks/use-active-skill-discovery-runtime-target.ts | New hook: resolves the owning runtime for skill discovery via getSingleFocusedRuntimeEnvironmentId (matching install routing). Returns null while catalog hasn't settled to prevent premature local scans. |
| src/renderer/src/store/slices/runtime-status.ts | Adds runtimeEnvironmentCatalogSettled flag alongside existing Hydrated flag; settled flips on both success and failure of the catalog read, allowing skill discovery to degrade gracefully instead of waiting forever. |
| src/renderer/src/store/slices/settings.ts | hydrateRuntimeEnvironmentStatuses is now called unconditionally (even after a failed settings read) so the runtime catalog always settles and skill discovery is never stranded. |
| src/renderer/src/hooks/useInstalledAgentSkills.ts | Cache/discovery logic extracted to installed-agent-skill-discovery; hook now uses useActiveSkillDiscoveryRuntimeTarget and passes it to discoverInstalledAgentSkills; guards against scanning before runtime is known. |
| src/renderer/src/store/slices/repos.ts | Import of notifyInstalledAgentSkillsChanged moved from useInstalledAgentSkills to installed-agent-skill-discovery to break the circular import chain. |
Sequence Diagram
sequenceDiagram
participant App as App Boot
participant SS as settings.ts
participant RS as runtime-status.ts
participant Hook as useActiveSkillDiscoveryRuntimeTarget
participant Disc as installed-agent-skill-discovery
participant Client as runtime-skills-client
participant Local as Local IPC
participant Remote as Remote RPC
App->>SS: fetchSettings()
SS->>SS: window.api.settings.get() [may fail]
SS->>RS: hydrateRuntimeEnvironmentStatuses() [always runs]
RS->>RS: window.api.runtimeEnvironments.list()
alt list succeeds
RS->>RS: "setRuntimeEnvironments() → catalogSettled=true, catalogHydrated=true"
else list fails
RS->>RS: "set catalogSettled=true (NOT hydrated)"
end
RS-->>Hook: "store update: catalogSettled=true"
Hook->>Hook: getSingleFocusedRuntimeEnvironmentId()
alt single remote env active
Hook-->>Disc: "runtimeTarget = environment"
Disc->>Client: discoverSkillsForRuntimeTarget(remote)
Client->>Remote: "callRuntimeRpc('skills.discover', {})"
Remote-->>Client: SkillDiscoveryResult
else local / ambiguous
Hook-->>Disc: "runtimeTarget = local"
Disc->>Client: discoverSkillsForRuntimeTarget(local, target)
Client->>Local: window.api.skills.discover(target)
Local-->>Client: SkillDiscoveryResult
end
Client-->>Disc: result cached under runtime-scoped key
Disc-->>Hook: SkillDiscoveryResult → badge updated
Reviews (1): Last reviewed commit: "test(skills): pin the settings-failure r..." | Re-trigger Greptile
Scoping the discovery cache key by `settings.activeRuntimeEnvironmentId` is a second feature in a PR about bounding a cache. It is also inert on desktop — src/main/ipc/skills.ts always scans the local machine and never reads the active environment, so the partition only forces a redundant rescan per switch. Only the web client routes skills.discover to the paired runtime, and host-aware discovery belongs to stablyai#6887. Reverts the eight production files it threaded through, and with them the `executionHostId` field on the shared SkillDiscoveryTarget, which reused the `ExecutionHostId` name for a raw environment id. Keeps the cache bound, the generation guard and the rescan fix, and keeps the target-shape and cache-key coverage the scoping work motivated.
…ills-cache stablyai#6887 landed the runtime-scoped discovery module this PR also creates, so the add/add collision is resolved in its favour and the cap layers on top. Kept from stablyai#6887, unchanged: - getRuntimeScopedSkillDiscoveryKey, and it stays THE key producer for both the cache read and the pending map. Keying off getSkillDiscoveryTargetKey would bound every remote under the local 'host' key; pinned by two new tests. - discoverSkillsForRuntimeTarget as the scan, so remote runtimes are still scanned over RPC rather than the client's disk. - notifyInstalledAgentSkillsChanged stays in this store-free module. It must never import @/store or the store -> repos slice -> hook -> store cycle returns; it now invalidates the bounded cache instead of clearing a raw Map. Kept from this PR: - the 256-entry LRU, now keyed by the runtime-scoped key. - the discoveryGeneration guard, so a pre-install scan cannot repopulate. - the render-phase state latch. stablyai#6887 landed with the discoveryTarget object still in refresh's deps, so main now carries the rescan-per-store-write bug: an unreachable runtime host issued one discovery IPC per store write. Verified the 6-vs-1 regression test still fails when the latch is defeated on this tree.
…discovery cache (#7670) Two fixes to installed-skill discovery in the renderer. **Stops one discovery IPC per unrelated store write.** `refresh`'s `useCallback` depended on the `discoveryTarget` *object*, which callers rebuild inside a store-backed `useMemo`. Any unrelated store write handed the hook a fresh identity, recreated `refresh`, and re-fired `useEffect(() => void refresh(false), [refresh])`. On a cache hit that is only extra renders — but on a *rejecting* scan nothing is cached and the pending entry is cleared, so it becomes one discovery IPC per store write, indefinitely. That is the remote-runtime-unreachable and SSH case. Measured 6 scans where 1 was correct. This dep also exists on `main`, so this repairs a pre-existing bug rather than only one introduced here. Fixed with a render-phase `useState` latch keyed on the already-present `discoveryTargetKey` string — deliberately not a `useMemo` (React documents those as discardable, so a discarded one silently restores the regression while the test stays green) and not a ref (react-doctor correctly flags a render-phase ref mutation). **Bounds the discovery cache.** The module-level maps were unbounded, cleared only wholesale by `notifyInstalledAgentSkillsChanged`. Now a 256-entry LRU keyed by `getRuntimeScopedSkillDiscoveryKey`, with a `discoveryGeneration` guard and a read/peek split so only the unforced cache-serving path promotes recency. This matters more after #6887 than before it. Local keys are bounded by project count (~47 KB/entry, ~240 KB for 5 repos), but once remote scans key on `runtime:<environmentId>`, ephemeral VMs mint `orca-${randomUUID()}` per start (`ephemeral-vm-runtime-service.ts` + `ephemeral-vm-recipe-runner.ts`), so every VM start creates a permanently-retained entry — ~18.8 KB each, ~1.8 MB after ~100 starts, and it does not stop. Scoped down during review: an `executionHostId` change touching 8 production files was removed as a second feature (host-awareness landed in #6887 instead), taking this from 17 files to 6. New tests pin that the cap keys off the runtime-scoped key, that two environments never share an entry, and that one environment collapses to a single entry across differing client target shapes. Known gap, not addressed here: cache entries are not evicted when a runtime environment is removed, so a removed environment's skill list is retained until LRU pressure or an install notification clears it. That needs a store subscription to `runtimeEnvironments` removals and is filed separately. Co-authored-by: nwparker <[email protected]>
…tablyai#6887) * fix(skills): read installed skills from the connected remote runtime The "Not installed" badge stayed on in Settings even after a skill was installed against a remote `orca serve`. Skill discovery always ran through the local `skills:discover` IPC, so it scanned the client's home dir while the install (and the skill files) landed on the server. The skills browser had the same blind spot. Route discovery to the runtime that owns it, mirroring git/hooks/terminal: local IPC by default, remote runtime RPC (`skills.discover`) when an Orca runtime environment is active. The discovery cache is now scoped per runtime so local and remote results never collide. Extract the discovery cache/transport into a store-free module (`installed-agent-skill-discovery.ts`) and a shared runtime-target hook, so the React hook stays under `max-lines` and store slices can import the change-notifier without pulling the app store into a circular import. Independent of the terminal selector fix (stablyai#6816); addresses the still-broken install-status half of stablyai#6789. * fix(skills): runtime-agnostic scan-error toast + docstrings Address review on stablyai#6887: - The skills-scan error toast said "Could not scan local skills", but discovery can now target a remote runtime; drop "local" (source + locales). - Add short JSDoc to the discovery helpers and skill hooks to clear the docstring-coverage gate. * fix(skills): route discovery through the active runtime and scope its cache Rebuilt on the repo's standard runtime-client pattern (getActiveRuntimeTarget + callRuntimeRpc) instead of a bespoke transport, and keeps the renderer discovery cache keyed per runtime so a remote result never leaks into the local host's badge after switching environments. * fix(skills): keep the discovery cache store-free to break the import cycle Reading the active runtime from the app store inside the hook module closed a cycle (store -> repos slice -> hook -> store) that broke module init in three suites. The cache/transport moves to a store-free module the repos slice can import; only the hook itself touches the store. * fix(skills): scan the host the install actually lands on Reviewer round 1 found the badge could scan a different machine than the Install button writes to: skill install terminals route through getSingleFocusedRuntimeEnvironmentId, which declines to guess an owner while several runtimes are saved, so a two-environment user installed locally while discovery scanned the remote and the badge never flipped. Discovery now resolves through that same resolver, and holds a loading state until settings and the runtime catalog have hydrated instead of flashing 'Not installed'. Also drops the unreachable cwd/worktreeId forwarding (no caller can produce it) and retires three SkillsPage strings that a remote scan makes false. * fix(skills): close the round-2 review findings - SkillsPage had no generation guard, so a slow local scan could land after a newer remote scan and silently redisplay the client's skills. - The round-2 selector took a useShallow object including runtimeEnvironments, whose identity churns on every status refresh; that re-fired every consumer's scan. Select the resolved id instead. - A failed runtime-environment catalog read never set the hydrated flag, so discovery would have spun for the whole session with no retry affordance. An unreadable catalog is settled, which is what terminal routing assumes. - Remote cache keys no longer fragment on a client-side target the remote call discards, which was issuing the same RPC once per target shape. - Cover each hydration conjunct separately; the combined test covered neither. - First tests for SkillsPage, which had none. * fix(skills): settle the runtime catalog without loosening host routing Round 3 set runtimeEnvironmentCatalogHydrated on a failed catalog read so skill discovery would stop waiting. That flag also gates fail-closed host routing (worktree-operation-route mayBeLegacyLocal), so flipping it on failure would have routed ownerless legacy worktrees — including removals — to the local host off a stale empty list. Add a separate 'settled' flag for surfaces that only need to stop waiting, and leave 'hydrated' meaning what its doc says. fetchSettings now probes the catalog even when the settings read fails, so a rejected settings.get cannot strand every skill badge on a spinner. * test(skills): pin the settings-failure runtime catalog probe The only hunk in the review no mutation could kill. --------- Co-authored-by: vladmesh <[email protected]> Co-authored-by: Brennan Benson <[email protected]>
…discovery cache (stablyai#7670) Two fixes to installed-skill discovery in the renderer. **Stops one discovery IPC per unrelated store write.** `refresh`'s `useCallback` depended on the `discoveryTarget` *object*, which callers rebuild inside a store-backed `useMemo`. Any unrelated store write handed the hook a fresh identity, recreated `refresh`, and re-fired `useEffect(() => void refresh(false), [refresh])`. On a cache hit that is only extra renders — but on a *rejecting* scan nothing is cached and the pending entry is cleared, so it becomes one discovery IPC per store write, indefinitely. That is the remote-runtime-unreachable and SSH case. Measured 6 scans where 1 was correct. This dep also exists on `main`, so this repairs a pre-existing bug rather than only one introduced here. Fixed with a render-phase `useState` latch keyed on the already-present `discoveryTargetKey` string — deliberately not a `useMemo` (React documents those as discardable, so a discarded one silently restores the regression while the test stays green) and not a ref (react-doctor correctly flags a render-phase ref mutation). **Bounds the discovery cache.** The module-level maps were unbounded, cleared only wholesale by `notifyInstalledAgentSkillsChanged`. Now a 256-entry LRU keyed by `getRuntimeScopedSkillDiscoveryKey`, with a `discoveryGeneration` guard and a read/peek split so only the unforced cache-serving path promotes recency. This matters more after stablyai#6887 than before it. Local keys are bounded by project count (~47 KB/entry, ~240 KB for 5 repos), but once remote scans key on `runtime:<environmentId>`, ephemeral VMs mint `orca-${randomUUID()}` per start (`ephemeral-vm-runtime-service.ts` + `ephemeral-vm-recipe-runner.ts`), so every VM start creates a permanently-retained entry — ~18.8 KB each, ~1.8 MB after ~100 starts, and it does not stop. Scoped down during review: an `executionHostId` change touching 8 production files was removed as a second feature (host-awareness landed in stablyai#6887 instead), taking this from 17 files to 6. New tests pin that the cap keys off the runtime-scoped key, that two environments never share an entry, and that one environment collapses to a single entry across differing client target shapes. Known gap, not addressed here: cache entries are not evicted when a runtime environment is removed, so a removed environment's skill list is retained until LRU pressure or an install notification clears it. That needs a store subscription to `runtimeEnvironments` removals and is filed separately. Co-authored-by: nwparker <[email protected]>
Summary
When connected to a remote
orca serve, the Skills setup in Settings stayed on "Not installed" even after a skill was installed on the server. The install runs in a terminal on the remote runtime, so the files land in the server's~/.agents/skills(or~/.claude/skills) — but the status check always ran through the localskills:discoverIPC, which scans the client's home dir. The Skills browser page had the same blind spot.This routes discovery to the runtime that owns it, like git/hooks/terminals already do: local IPC by default (unchanged), and
skills.discoverover runtime RPC when a remote runtime is active, so the scan happens where the files are. The cache is now scoped per runtime so local and remote results don't collide. The cross-runtime cache/transport is extracted into a store-free module (installed-agent-skill-discovery.ts) plus a shareduseActiveSkillDiscoveryRuntimeTargethook, keeping the React hook under max-lines and lettingstore/slices/repos.tsimport the change-notifier without a circular import back into the app store.Independent of #6816 (now merged); addresses the install-status half of #6789 that it didn't touch.
Screenshots
No layout change, but attaching before/after screenshots of the Settings skill badge on a remote
orca serve— "Not installed" before this fix and installed after.Before:

After:
Testing
pnpm lintpnpm typecheckpnpm testpnpm build(Linux AppImage + deb)New
runtime-skills-client.test.tscovers local-vs-remote routing, dropping the local-only target on remote, and forwarding an explicit cwd; existing skill-hook tests still pass.Full suite: 0 new failures. The 4 failing tests (
local-pty-providerWindows-cwd-WSL,pty-connectionmobile-fit,secure-file/runtime-metadatacoarse-ctime) fail identically on clean main — pre-existing/flaky, unrelated to skills.AI Review Report
callRuntimeRpcpath; local IPC is untouched and still the default. Theskills.discoverRPC already exists (it's what the web client uses).Security Audit
No new input handling, command execution, path handling, auth, secrets, or IPC surface. The change only chooses where an existing discovery runs; on remote it uses the existing runtime RPC, whose authorization stays server-side via the device-token registry. The optional
cwdforwarded was already part of theskills.discovercontract. No follow-up needed.Notes
Discovery now follows the active runtime environment (
settings.activeRuntimeEnvironmentId), matching git/hooks/terminal.ELI5
Skills settings said “Not installed” while connected to a remote server because discovery scanned the local home directory. Discovery now uses the remote runtime so server-installed skills show correctly.