Skip to content

[codex] Fix Codex workspace skill discovery#2953

Closed
PabloSzx wants to merge 1 commit into
pingdotgg:mainfrom
PabloSzx:codex/workspace-scoped-skills
Closed

[codex] Fix Codex workspace skill discovery#2953
PabloSzx wants to merge 1 commit into
pingdotgg:mainfrom
PabloSzx:codex/workspace-scoped-skills

Conversation

@PabloSzx

@PabloSzx PabloSzx commented Jun 4, 2026

Copy link
Copy Markdown

Summary

Fix Codex workspace skill discovery and provider skill suggestions in the composer.

Root cause

Codex provider status was probed from the server process cwd, so codex app-server skills/list did not receive the active project or worktree cwd. Project-local .agents/skills entries could be parsed by Codex, but T3 Code's provider snapshot did not include them for the active workspace. The / composer menu also only surfaced slash commands, so provider skills were not discoverable there even when present in provider status.

Changes

  • Thread optional cwd context through server.refreshProviders, the WebSocket contract, provider registry refreshes, and managed provider snapshots.
  • Make managed providers remember an explicit refresh context so later background refreshes keep using the active workspace cwd.
  • Probe Codex provider status with the active project/worktree cwd, falling back to the configured server cwd.
  • Refresh the active Codex provider when the active workspace root changes.
  • Show provider skills in the / composer menu under a Skills group, with selection inserting the $skill-name invocation.
  • Add regression coverage for Codex cwd forwarding, registry refresh context, managed-provider context reuse, local API forwarding, and slash-menu skill grouping.

Related

Related to #2637, but this PR should not automatically close it.

Related to #2048, but this PR only wires the cwd consumer for Codex; Claude project skill discovery remains separate.
Builds on the closed stale approach from #2330, with the cwd coming from the active workspace rather than only the server config cwd.
Includes the slash-menu provider skill surfacing from the open #2650 approach as part of the same end-to-end fix.

Validation

  • mise exec -- pnpm exec vp check
  • mise exec -- pnpm exec vp run typecheck
  • mise exec -- pnpm exec vp test run apps/server/src/provider/makeManagedServerProvider.test.ts apps/server/src/provider/Layers/ProviderRegistry.test.ts apps/web/src/localApi.test.ts apps/web/src/components/chat/ComposerCommandMenu.test.ts apps/web/src/components/chat/composerSlashCommandSearch.test.ts

Note

Medium Risk
Changes provider refresh RPC shape and Codex probe behavior; scope is bounded with tests but affects live provider snapshots and WS clients.

Overview
Fixes Codex workspace skill discovery by probing provider status against the active project/worktree instead of only the server process cwd.

Server: Adds optional cwd on server.refreshProviders (IPC/WS contracts) and threads ProviderSnapshotRefreshInput through the provider registry, managed snapshots, and Codex’s app-server probe (skills/list uses the supplied cwd). Managed providers remember the last explicit refresh cwd so periodic background checks keep the same workspace context. Web: When the active workspace root changes, Codex triggers a targeted provider refresh with that cwd. The / composer menu now includes provider skills (with a Skills group) alongside slash commands.

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

@coderabbitai

coderabbitai Bot commented Jun 4, 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: 5925c4a8-1405-448c-b219-2a186dcabe36

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 and usage tips.

@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 4, 2026
@PabloSzx PabloSzx marked this pull request as ready for review June 4, 2026 18:37

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 51e474a. Configure here.

})
.catch((error: unknown) => {
console.warn("Failed to refresh Codex provider for active workspace", error);
});

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.

Failed workspace refresh not retried

Medium Severity

The Codex workspace refresh effect records its dedupe key before refreshProviders completes. If the RPC fails, the key still matches the active workspace, so the effect skips further attempts and project-local skills can stay wrong until the user changes workspace or another refresh path runs.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 51e474a. Configure here.

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.

🟢 Low

const checkProvider = checkOpenCodeProviderStatus(

The checkProvider function at line 152 ignores the input parameter, so any cwd override passed during refresh is discarded. The interface expects checkProvider: (input?: ProviderSnapshotRefreshInput) => Effect.Effect<...> where input?.cwd can override the working directory, but the current implementation captures serverConfig.cwd at instance creation time and discards runtime cwd values. This breaks the refresh contract when a different working directory is requested.

🤖 Copy this AI Prompt to have your agent fix this:
In file apps/server/src/provider/Drivers/OpenCodeDriver.ts around line 139:

The `checkProvider` function at line 152 ignores the `input` parameter, so any `cwd` override passed during refresh is discarded. The interface expects `checkProvider: (input?: ProviderSnapshotRefreshInput) => Effect.Effect<...>` where `input?.cwd` can override the working directory, but the current implementation captures `serverConfig.cwd` at instance creation time and discards runtime `cwd` values. This breaks the refresh contract when a different working directory is requested.

Evidence trail:
- OpenCodeDriver.ts:139-143 — `checkProvider` created with `serverConfig.cwd` baked in
- OpenCodeDriver.ts:152 — `checkProvider: () => checkProvider` ignores input parameter
- makeManagedServerProvider.ts:31-33 — interface expects `(input?: ProviderSnapshotRefreshInput) => Effect.Effect<...>`
- makeManagedServerProvider.ts:130-131 — `resolveRefreshInput` result passed to `input.checkProvider(refreshInput)`
- ServerProvider.ts:6-8 — `ProviderSnapshotRefreshInput` has `readonly cwd?: string | undefined`
- CodexDriver.ts:163-168 — peer driver properly handles cwd override: `refreshInput?.cwd ?? serverConfig.cwd`
- OpenCodeProvider.ts:301-303 — `checkOpenCodeProviderStatus` accepts a `cwd` parameter, confirming relevance

@macroscopeapp

macroscopeapp Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR enables workspace-scoped skill discovery for Codex by propagating a new cwd parameter through the provider refresh flow, changing interface signatures and adding frontend auto-refresh behavior. Additionally, unresolved review comments identify bugs in error handling and OpenCodeDriver's input handling.

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

@PabloSzx

PabloSzx commented Jun 4, 2026

Copy link
Copy Markdown
Author

Superseded by #2954, which narrows the scope to Codex skill autocomplete only and removes the suggestion changes.

@PabloSzx PabloSzx closed this Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 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.

1 participant