Skip to content

Fix workspace-scoped Codex skill discovery#3059

Open
Quicksaver wants to merge 32 commits into
pingdotgg:mainfrom
Quicksaver:fix/codex-skills
Open

Fix workspace-scoped Codex skill discovery#3059
Quicksaver wants to merge 32 commits into
pingdotgg:mainfrom
Quicksaver:fix/codex-skills

Conversation

@Quicksaver

@Quicksaver Quicksaver commented Jun 12, 2026

Copy link
Copy Markdown

Summary

Fix Codex repo-local skill discovery by resolving skills for the active project/worktree cwd instead of relying on the provider status snapshot.

Codex discovers local skills relative to the cwd used for skills/list, while provider status is global to the provider instance. This PR adds a workspace-scoped provider-skills RPC, uses it in the composer and message timeline, and keeps provider probes explicit about their configured cwd so behavior does not depend on the backend process cwd.

What Changed

  • Add server.listProviderSkills contracts, client-runtime query wiring, local API support, and WebSocket handler coverage.
  • Add ProviderSkillsLister to serve snapshot skills for non-Codex or disabled-Codex providers while using workspace-aware Codex skills/list for enabled Codex providers.
  • Start short-lived Codex app-server processes for workspace skill listing with cwd validation, Codex home preparation, timeout handling, request coalescing, TTL caching, and bounded concurrency.
  • Add stable structured error handling for provider skill-list failures, including bounded details for invalid workspace roots and Codex home-preparation failures.
  • Pass explicit serverConfig.cwd values into Codex, Cursor, and Grok provider status probes and ACP discovery.
  • Load workspace skills lazily for the active composer workspace when the $ menu is open or the prompt already contains complete $skill references.
  • Reuse the same workspace-scoped skill data for inline composer chips, pending user-input custom answers, and submitted user-message skill chips in the chat timeline.
  • Key workspace skill state by environment, provider instance, and cwd; preserve same-workspace skills during pending refreshes; fall back to snapshot skills after settled empty/error lookups; and avoid carrying stale skills across workspace/provider changes.
  • Surface workspace skill-listing errors in the $ menu instead of silently presenting an empty skill set.
  • Add tests for provider skill-listing branches, Codex app-server cwd/timeout/termination behavior, request-cache coalescing/concurrency, provider probe cwd propagation, query-key isolation, stale pending workspace-skill state, composer skill references, and timeline skill chips.

Why

Fixes #3040.

The cwd fix is necessary but not sufficient on its own. Provider startup and status probes should use the configured server cwd, but the composer needs a workspace-specific skill query because repo-local Codex skills depend on the active project/worktree cwd.

The client state is keyed by environment/provider/cwd so skill suggestions and chips can refresh through the shared query runtime, keep useful same-workspace data visible during refreshes, and avoid showing skills from a previous workspace while a new workspace query is pending.

Validation

  • pnpm exec vp check
  • pnpm exec vp run typecheck
  • pnpm exec vp test apps/server/src/provider/ProviderSkillsLister.test.ts
  • pnpm exec vp test apps/server/src/server.test.ts -t "server.listProviderSkills"
  • pnpm exec vp test apps/server/src/provider/Layers/CodexProvider.test.ts apps/server/src/provider/Layers/CursorProvider.test.ts apps/server/src/provider/Layers/GrokProvider.test.ts
  • pnpm exec vp test apps/web/src/lib/providerWorkspaceSkillsState.test.ts apps/web/src/composer-editor-mentions.test.ts
  • pnpm exec vp test apps/web/src/components/chat/MessagesTimeline.test.tsx

Proof

  • No external proof artifacts; validation is covered by the automated checks above.

Note

Medium Risk
Spawns Codex app-server child processes per workspace skill request (mitigated by timeout, caching, and concurrency limits); provider probe cwd changes affect model/skill discovery behavior across workspaces.

Overview
Fixes repo-local Codex skill discovery by listing skills for the active workspace cwd instead of the global provider snapshot or the server process cwd.

Adds server.listProviderSkills (contracts, WebSocket RPC, client query) backed by ProviderSkillsLister: non-Codex or disabled Codex instances return snapshot skills; enabled Codex runs a short-lived codex app-server skills/list for the requested cwd with home prep, 15s timeout, TTL cache, coalescing, and structured ServerProviderSkillsListError payloads (via sanitizeErrorCause).

Codex, Cursor, and Grok status probes and ACP discovery now take an explicit serverConfig.cwd instead of process.cwd().

The web client loads skills through useProviderWorkspaceSkills (keyed by environment, instance, cwd) in the composer and timeline—lazy when the $ menu is open or the prompt has complete $skill tokens—with stale-workspace clearing, snapshot fallback on errors, and menu-visible failures. promptHasComposerSkillReference avoids unnecessary fetches.

Reviewed by Cursor Bugbot for commit c748279. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix workspace-scoped Codex skill discovery by passing cwd through provider status checks and skill listing

  • Adds a listCodexProviderSkills effect in CodexProvider.ts that spawns a Codex app-server child process scoped to a caller-supplied cwd, initializes it, and requests skills/list with a 15s timeout.
  • Propagates serverConfig.cwd through checkCodexProviderStatus, checkCursorProviderStatus, and checkGrokProviderStatus so provider probes run in the workspace directory instead of process.cwd().
  • Introduces makeProviderSkillsLister in ProviderSkillsLister.ts — a TTL-cached (1s, cap 64), concurrency-limited (4 permits) service that validates cwd, prepares Codex shadow home, and maps failures to structured ServerProviderSkillsListError values.
  • Exposes a new server.listProviderSkills WebSocket RPC (requiring AuthOrchestrationReadScope) wired to makeProviderSkillsLister in ws.ts.
  • Adds a useProviderWorkspaceSkills React hook in providerWorkspaceSkillsState.ts and wires it into ChatView and ChatComposer so the skill list and composer menu reflect the active workspace rather than the global provider snapshot.

Macroscope summarized c748279.

- Propagate cwd through provider status probes
- Add server RPC for workspace skill discovery
- Load workspace skills in the composer UI
- Clarify bogus skill as a durable discovery test fixture

- Stabilize composer fallback skill array identity
- Skip Codex skill spawning for disabled instances

- Move bogus skill fixture out of workspace discovery
- Refresh workspace skill cache on provider and connection changes

- Validate Codex skill cwd before spawning the app server

- Cover server.listProviderSkills RPC branches
- Track the active workspace key in provider skill state

- Reset pending skills when switching workspace targets
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 28005d40-0d16-4205-b150-0d71f4cd6be4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jun 12, 2026
Comment thread apps/web/src/lib/providerWorkspaceSkillsState.ts Outdated
Comment thread apps/web/src/components/chat/ChatComposer.tsx
Comment thread apps/server/src/ws.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces a new feature for workspace-scoped Codex skill discovery, including a new RPC endpoint, server-side child process spawning, and frontend state management. Despite extensive test coverage, the new capability and runtime behavior changes warrant human review.

You can customize Macroscope's approvability policy. Learn more.

- Keep pending skill lookups scoped to the active workspace key
- Surface Codex skill-list timeout errors in the composer
- Add regression coverage for stale pending skills
@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Jun 12, 2026
# Conflicts:
#	apps/server/src/provider/Layers/CursorProvider.ts
#	apps/web/src/components/chat/ChatComposer.tsx
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:XL 500-999 changed lines (additions + deletions). labels Jun 19, 2026
Quicksaver and others added 2 commits June 19, 2026 14:07
# Conflicts:
#	apps/web/src/environments/runtime/connection.test.ts
#	apps/web/src/environments/runtime/service.savedEnvironments.test.ts
#	apps/web/src/environments/runtime/service.threadSubscriptions.test.ts
#	apps/web/src/localApi.ts
#	packages/client-runtime/src/wsRpcClient.ts
Co-authored-by: codex <codex@users.noreply.github.com>
Comment thread apps/web/src/lib/providerWorkspaceSkillsState.ts
- Keep prior workspace skills visible while refreshes are pending
- Add tests for loaded, pending, workspace-switch, and empty states
- Preserve and clear cached workspace skills by query state

- Cover pending data, empty data, and workspace switches
@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Jun 19, 2026

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

Effect service review found one convention issue in the changed scope. See the inline comment.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/backend/DesktopBackendManager.ts Outdated
Comment thread apps/vscode-extension/src/extension.ts Outdated
Comment thread CUSTOMIZED.md Outdated
Comment thread apps/desktop/src/backend/DesktopBackendManager.ts Outdated

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

Two new ServerProviderSkillsListError constructions derive the caller-visible message from the underlying cause. Since this error flows through the server.listProviderSkills RPC error channel and into the $ menu UI, the raw underlying text leaks across a caller-visible boundary. The underlying failure is already preserved structurally via cause, so the message should be derived only from stable structural attributes.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/src/provider/ProviderSkillsLister.ts Outdated
Comment thread apps/server/src/provider/ProviderSkillsLister.ts Outdated
Comment thread apps/server/src/provider/ProviderSkillsLister.ts
Comment thread apps/desktop/src/backend/DesktopBackendManager.ts Outdated
Comment thread apps/web/src/components/chat/ChatComposer.tsx
Comment thread apps/web/src/components/chat/ChatComposer.tsx
Comment thread apps/web/src/components/chat/ChatComposer.tsx
Comment thread apps/web/src/components/chat/ChatComposer.tsx
Comment thread apps/web/src/lib/providerWorkspaceSkillsState.ts Outdated
Comment thread apps/web/src/lib/providerWorkspaceSkillsState.ts Outdated
@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). and removed size:XXL 1,000+ changed lines (additions + deletions). labels Jun 26, 2026
Comment thread apps/server/src/provider/ProviderSkillsLister.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Repo-local Codex skills do not appear in T3 Code $ skill picker

2 participants