Skip to content

fix(skills): read installed skills from the connected remote runtime - #6887

Merged
brennanb2025 merged 9 commits into
stablyai:mainfrom
vladmesh:vladmesh/fix-not-installed-badge-for-skills-in-settings
Jul 29, 2026
Merged

brennanb2025 merged 9 commits into
stablyai:mainfrom
vladmesh:vladmesh/fix-not-installed-badge-for-skills-in-settings

Conversation

@vladmesh

@vladmesh vladmesh commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

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 local skills:discover IPC, 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.discover over 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 shared useActiveSkillDiscoveryRuntimeTarget hook, keeping the React hook under max-lines and letting store/slices/repos.ts import 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: Screenshot from 2026-06-30 11-53-34
After: Screenshot from 2026-06-30 11-33-56

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build (Linux AppImage + deb)
  • Added regression tests

New runtime-skills-client.test.ts covers 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-provider Windows-cwd-WSL, pty-connection mobile-fit, secure-file/runtime-metadata coarse-ctime) fail identically on clean main — pre-existing/flaky, unrelated to skills.

AI Review Report

  • Cross-platform (macOS/Linux/Windows): no platform-dependent code — no shortcuts, labels, paths, shells, or Electron specifics; underlying path handling unchanged.
  • SSH/remote/local: this is the fix. Remote uses the existing callRuntimeRpc path; local IPC is untouched and still the default. The skills.discover RPC already exists (it's what the web client uses).
  • Agent/integration/git-provider: skills discovery is neutral; no provider-specific assumptions added.
  • Performance: discovery stays cached (now keyed per runtime); the remote path reuses the same cached compatibility check the other runtime clients use.
  • UI: no visual change.

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 cwd forwarded was already part of the skills.discover contract. No follow-up needed.

Notes

Discovery now follows the active runtime environment (settings.activeRuntimeEnvironmentId), matching git/hooks/terminal.


Open in Stage

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.

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.
@ghost

ghost commented Jun 30, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 4 individual chapters for you:

Title
1 Implement runtime-aware skill discovery client
2 Extract skill discovery logic and caching
3 Refactor useInstalledAgentSkills to support remote runtimes
4 Update SkillsPage and localization for remote discovery
Open in Stage

Chapters generated by Stage for commit 242ab7c on Jun 30, 2026 10:09am UTC.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Skill discovery is now runtime-target-aware. A new runtime-skills-client module routes local targets to window.api.skills.discover and remote targets through callRuntimeRpc with a 15-second timeout. Discovery caching, in-flight de-duplication, force-refresh logic, and cache-key generation for host, WSL, project, and environment scopes move into installed-agent-skill-discovery. A new useActiveSkillDiscoveryRuntimeTarget hook reads the active runtime target from the app store. useInstalledAgentSkills, SkillsPage, the repos store slice, and localized scan-failure strings are updated to use the new flow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.94% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: routing skills discovery to the connected remote runtime.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description follows the required template and includes all major sections with sufficient detail, including screenshots, testing, review, security, and notes.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Error toast still says "local" but discovery can now target a remote runtime.

Since discoverSkillsForRuntimeTarget(runtimeTarget) routes to a remote orca serve when 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 on runtimeTarget.kind).


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0a90c1bc-043c-4970-a94a-9c458c61a664

📥 Commits

Reviewing files that changed from the base of the PR and between 677fc43 and 4fac3b0.

📒 Files selected for processing (7)
  • src/renderer/src/components/skills/SkillsPage.tsx
  • src/renderer/src/hooks/installed-agent-skill-discovery.ts
  • src/renderer/src/hooks/use-active-skill-discovery-runtime-target.ts
  • src/renderer/src/hooks/useInstalledAgentSkills.ts
  • src/renderer/src/runtime/runtime-skills-client.test.ts
  • src/renderer/src/runtime/runtime-skills-client.ts
  • src/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.
@AmethystLiang
AmethystLiang requested a review from Jinwoo-H June 30, 2026 18:34
@AmethystLiang AmethystLiang assigned OrcaWin and unassigned Jinwoo-H Jul 20, 2026
@AmethystLiang
AmethystLiang requested review from OrcaWin and removed request for Jinwoo-H July 20, 2026 18:42
@AmethystLiang AmethystLiang added the orca-remote-server Remote Orca Server / orca serve / paired remote runtime label Jul 22, 2026
@AmethystLiang

Copy link
Copy Markdown
Contributor

Associating this PR with related issue(s): #6789

1 similar comment
@AmethystLiang

Copy link
Copy Markdown
Contributor

Associating this PR with related issue(s): #6789

@nwparker nwparker added the bug Something isn't working label Jul 27, 2026
…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.
@brennanb2025

Copy link
Copy Markdown
Contributor

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

  • Discovery routed through getActiveRuntimeTarget + callRuntimeRpc, matching how git/hooks/Linear clients already reach a runtime. This also inherits the protocol-compat gate and pairing-revision pinning for free.
  • The runtime-scoped discovery cache. This turned out to be load-bearing: without it, switching environments replays the other host's skill list.
  • Extracting the cache into a store-free module. A reviewer round proved this is required rather than cosmetic — the hook now reads the app store, so leaving the cache in useInstalledAgentSkills.ts closes a store -> repos slice -> hook -> store import cycle that broke three suites.

Fixed during review

  • Scan and install could name different hosts. Skill install terminals route through getSingleFocusedRuntimeEnvironmentId, which deliberately declines to guess an owner while several runtimes are saved. Discovery was reading raw activeRuntimeEnvironmentId, so a user with two saved runtimes installed locally while the badge scanned the remote — the same stuck "Not installed", just inverted. Discovery now resolves through that same resolver, so the two can never disagree.
  • First paint flashed "Not installed" for remote users, briefly latching onboarding prompts. Discovery now holds a loading state until the runtime catalog settles.
  • A failed catalog read used to leave that wait pending for the whole session. Added a distinct runtimeEnvironmentCatalogSettled flag for surfaces that only need to stop waiting; runtimeEnvironmentCatalogHydrated keeps its stricter meaning because it also gates fail-closed host routing for worktree operations, including removals.
  • SkillsPage had no generation guard, so a slow local scan could land after a newer remote one and silently redisplay the client's skills.
  • Remote cache keys no longer fragment on a client-side target that the remote call discards.
  • Retired three strings the fix makes false: the installed badge said Local, and the empty state said No local skills found / Checked local home, .... Same five locales as your toast change.
  • Dropped the cwd/worktreeId forwarding — no caller can currently produce those fields, so it was unreachable code with tests asserting it.

Validated against a real paired orca serve (isolated HOME, so the server's skill set is provably disjoint from the client's):

  • Skills page, local: 52 skills from 6 sources, client paths.
  • Same page, remote active: 7 skills from 2 sources, all paths under the server's home, including a probe skill that exists only there.
  • Switching back to local returns the client's 52 — no cross-runtime bleed either way.
  • Settings badge, remote active: Orchestration read Not installed while the client had it installed locally, then flipped to Up to date when the skill was added to the server, and back again when removed. That is exactly selector_not_found error when installing skills via IDE on remote server connection #6789.

pnpm typecheck, pnpm lint, and the renderer suite are clean; the only failures are pre-existing Node 26 localStorage breakages that reproduce identically on main.

Known gaps, deliberately not in scope here — worth follow-ups:

  • With two or more saved runtime environments, discovery still scans the client, matching install routing. selector_not_found error when installing skills via IDE on remote server connection #6789 is fixed for a single saved runtime.
  • Skill freshness/update still scans the local host, so the "update available" pill can describe the client next to a remote installed verdict.
  • Reveal-file on the Skills page points at server paths when a runtime is active.
  • No fallback when the paired server predates skills.discover.
  • SSH-connected repo hosts are a different axis and remain undiscoverable.

Comment on lines +29 to +36
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')
)
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 "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-apps

greptile-apps Bot commented Jul 29, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes skill install-status badges staying on "Not installed" when connected to a remote orca serve by routing skills.discover through the active runtime RPC instead of always using the local IPC. Discovery is gated on runtimeEnvironmentCatalogSettled (a new flag that fires on both success and failure of the catalog read) so badges never hang indefinitely, and a per-runtime cache key prevents local and remote results from colliding.

  • New runtime-skills-client.ts dispatches discovery to local IPC or remote RPC based on the active RuntimeClientTarget; client-side WSL/project-runtime fields are intentionally dropped for remote calls since they describe the client host, not the server.
  • installed-agent-skill-discovery.ts extracts the cache/dedup layer from useInstalledAgentSkills and scopes cache keys per runtime (runtime:<environmentId> for remote, target-shape key for local), eliminating the circular import through repos.ts.
  • useActiveSkillDiscoveryRuntimeTarget resolves the owner via getSingleFocusedRuntimeEnvironmentId (matching install routing) and returns null until the catalog settles, preventing a premature local scan that would cache client skills under the local key before a remote runtime is known.
  • runtimeEnvironmentCatalogSettled is a new store flag (distinct from Hydrated) that flips on both a successful and a failed catalog read, ensuring skill discovery degrades to the local host rather than waiting forever on a spinner.

Confidence Score: 4/5

The 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.

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "test(skills): pin the settings-failure r..." | Re-trigger Greptile

brennanb2025 added a commit to nwparker/orca that referenced this pull request Jul 29, 2026
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.
@brennanb2025
brennanb2025 merged commit 8f36cd9 into stablyai:main Jul 29, 2026
25 checks passed
brennanb2025 added a commit to nwparker/orca that referenced this pull request Jul 29, 2026
…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.
brennanb2025 pushed a commit that referenced this pull request Jul 29, 2026
…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]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working orca-remote-server Remote Orca Server / orca serve / paired remote runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants