Skip to content

Fix workspace-scoped Codex skill discovery#3059

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

Fix workspace-scoped Codex skill discovery#3059
Quicksaver wants to merge 72 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 or worktree cwd instead of relying on the provider-wide status snapshot.

The implementation adds a workspace-scoped provider-skills RPC and a shared web/mobile resolution policy so composer suggestions and rendered skill chips refresh for the correct workspace without leaking stale skills across workspace, environment, or provider changes.

What Changed

  • Add server.listProviderSkills contracts, WebSocket and local API handlers, and environment-query wiring keyed by environment, provider instance, and cwd.
  • Add ProviderSkillsLister to return snapshot skills for non-Codex or disabled Codex providers and run Codex skills/list in the validated workspace cwd for enabled Codex providers.
  • Prepare the configured Codex home and forward configured launch arguments before each probe, and return bounded structured errors for provider lookup, settings, cwd, home-preparation, timeout, and app-server failures.
  • Coalesce identical requests with a short TTL cache, bound cache capacity and concurrent probes, and terminate short-lived Codex app-server processes when requests finish or time out.
  • Run Codex provider status probes with the configured server cwd instead of the backend process cwd.
  • Share the workspace-skill state policy across web and mobile: preserve settled skills during a same-workspace refresh, clear them while switching targets or after a failed refresh, and fall back to provider snapshot skills after empty or failed lookups while keeping errors visible, without refreshing workspace probes when only client-side fallback skills change.
  • Load composer workspace skills only when needed for the $ menu or existing complete $skill references, and load timeline skills only when a sent user prompt contains a complete skill reference, including one at the end of the message; web and mobile new-worktree drafts deliberately use snapshot fallback until their cwd exists and never probe the base checkout for repo-local skills.
  • Reuse workspace-scoped skills for web and mobile composer suggestions, inline editor chips, pending answers, and submitted user-message skill chips, with shared token-boundary handling across web and mobile rendering.
  • Add focused coverage for RPC handling, workspace validation, Codex app-server cwd and lifecycle behavior, timeout and request coalescing, query-key isolation, stale-state prevention, lazy skill references, fallback/error rendering, search ranking, and timeline chips.

Why

Fixes #3040.

Codex discovers repo-local skills relative to the cwd supplied to skills/list, but a provider status snapshot is global to the provider instance. A workspace-scoped query is therefore required to show the correct skills for each project and worktree, especially while switching between workspaces or refreshing under failure.

Validation

  • pnpm exec vp test --maxWorkers=1 apps/server/src/provider/ProviderSkillsLister.test.ts apps/server/src/provider/Layers/CodexProvider.test.ts packages/client-runtime/src/state/providerWorkspaceSkills.test.ts packages/client-runtime/src/state/runtime.test.ts apps/web/src/lib/providerWorkspaceSkillsState.test.ts apps/web/src/composer-editor-mentions.test.ts apps/web/src/components/chat/ComposerCommandMenu.test.tsx apps/web/src/components/chat/MessagesTimeline.test.tsx apps/mobile/src/features/threads/new-task-provider-skills.test.ts apps/mobile/src/features/threads/thread-composer-skill-items.test.ts (10 files, 92 tests passed)
  • pnpm exec vp test --maxWorkers=1 apps/server/src/server.test.ts -t "server.listProviderSkills" (5 tests passed)
  • pnpm exec vp test run --passWithNoTests apps/mobile/src/lib/nativeMarkdownText.test.ts packages/shared/src/skillInlineTokens.test.ts (native and shared inline-token coverage passed as part of the focused 4-file run)
  • pnpm exec vp check apps/server/src/provider/Layers/CodexProvider.ts apps/server/src/provider/Layers/CodexProvider.test.ts apps/server/src/provider/ProviderSkillsLister.ts apps/server/scripts/codex-skills-mock-app-server.ts packages/client-runtime/src/state/providerWorkspaceSkills.ts packages/client-runtime/src/state/providerWorkspaceSkills.test.ts apps/web/src/lib/providerWorkspaceSkillsState.ts apps/web/src/lib/providerWorkspaceSkillsState.test.ts apps/mobile/src/state/providerWorkspaceSkillsState.ts (9 files passed formatting and lint/type-aware checks)
  • pnpm exec vp check (0 errors; 9 existing React warnings)
  • pnpm exec vp run typecheck (15 tasks passed)
  • pnpm exec vp run lint:mobile (passed; SwiftLint, ktlint, and detekt were unavailable)
  • Playwright smoke against web 5735 and server 13775: paired the isolated app, added the codex-skills worktree, and verified that typing $ opened the skill picker with repo-scoped entries such as iOS Debugger Agent alongside system skills.
  • pnpm exec vp test run --passWithNoTests --project unit src/components/ChatView.logic.test.ts src/components/chat/ComposerCommandMenu.test.tsx src/lib/providerWorkspaceSkillsState.test.ts from apps/web (3 files, 47 tests passed after the future-worktree review fix)
  • pnpm exec vp check src/components/ChatView.logic.ts src/components/ChatView.logic.test.ts src/components/ChatView.tsx src/components/chat/ChatComposer.tsx from apps/web (4 files passed formatting and lint/type-aware checks)
  • Playwright follow-up against web 5735 and server 13775: with $ open, a future-worktree draft sent 0 server.listProviderSkills frames; switching the same draft to the current checkout sent 1 request with the assigned worktree cwd.

Proof

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

Note

Medium Risk
Spawns external Codex app-server processes per workspace lookup (bounded and cached); incorrect cwd or stale-skill policy could affect composer/timeline UX but not auth or data persistence.

Overview
Fixes repo-local Codex skills showing up in the wrong workspace by listing skills for the active project/worktree cwd instead of the global provider status snapshot.

Server: New server.listProviderSkills RPC. Codex runs a short-lived app-server probe with skills/list for the requested cwd (15s timeout, process kill on hang). ProviderSkillsLister coalesces identical provider+cwd requests, caps concurrency, and uses a 1s TTL cache. Non-Codex or disabled Codex still return snapshot skills. Failures use structured ServerProviderSkillsListError with sanitized causes.

Clients (web + mobile): Shared useProviderWorkspaceSkills policy keyed by environment, instance, and cwd—lazy fetch when the $ menu is open or the prompt/timeline has a complete $skill token; preserve skills on same-workspace refresh; clear on workspace switch or failed refresh; fall back to provider snapshot on empty/error while surfacing errors in the skill picker. Future worktree drafts skip cwd probes until a directory exists.

Tokens: Shared parseInlineSkillTokens / hasInlineSkillToken tighten boundaries (e.g. sentence punctuation vs $HOME / $value).

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

Note

Fix workspace-scoped Codex skill discovery in composer and timeline

  • Adds a server.listProviderSkills WebSocket RPC endpoint that spawns the Codex app-server for a given cwd and returns workspace-scoped skills, with a bounded request cache and semaphore to limit concurrency.
  • Introduces useProviderWorkspaceSkills hooks (web and mobile) that query workspace skills, snapshot prior results, fall back to provider-snapshot skills on error, and expose loading/error state.
  • ChatComposer, ThreadComposer, and ChatView now consume workspace skills instead of the static provider snapshot; skill fetching is triggered when the prompt or timeline contains a complete $skill token.
  • Composer command menus (ComposerCommandMenu, ComposerCommandPopover) surface skill fetch errors as inline alerts and show a loading state while skills are pending.
  • Adds shared parseInlineSkillTokens / hasInlineSkillToken utilities in @t3tools/shared with sentence-boundary rules that exclude code-like tokens ($HOME/.codex, $value;).
  • Risk: skill discovery now spawns a child process (Codex app-server) per workspace lookup; heavy concurrent use could impact server load despite the semaphore cap.

Macroscope summarized a9b4a6a.

- 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: 2487e575-cb6d-43bb-be84-6419f64ba938

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 workspace-scoped Codex skill discovery as a new feature with a new server RPC endpoint, bounded caching infrastructure, new error handling, and cross-platform client state management. Despite the 'fix' framing, it adds significant new capability and user-facing behavior that warrants 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
Comment thread apps/web/src/components/chat/ChatComposer.tsx
- Show lookup failures even when provider snapshot skills remain
- Cover the web command menu fallback-and-error rendering path
- Document expected workspace-aware skill behavior
- Record primary files, focused tests, and development ports
- Avoid workspace skill probes for empty drafts and unrelated messages
- Add focused coverage for complete user skill tokens
- Refresh branch details after merging upstream main
- Share sent-message skill parsing with timeline rendering
- Cover skill references at the end of sent prompts
- Recognize skill tokens followed by punctuation
- Cache sent-message matches and avoid token-array allocation
- Remove stale branch snapshot metadata
- Share punctuation-aware parsing across web and mobile
- Reject path and statement continuations when gating skill loading
- Cover sentence boundaries and code-variable continuations
- Add the shared workspace package to peer dependencies
- Refresh the mobile markdown package snapshot hash
Comment thread apps/web/src/lib/providerWorkspaceSkillsState.ts Outdated
Comment thread apps/web/src/lib/providerWorkspaceSkillsState.ts Outdated
- Update Effect Vitest peer dependency wiring for the patched beta release
- Refresh lockfile metadata and Alchemy dependency resolution
# Conflicts:
#	apps/server/src/provider/Layers/CodexProvider.ts
- Remove fallback-driven workspace query refreshes on web and mobile
- Drop the unused no-op web invalidation helper
- Document the corrected workspace query behavior
Comment thread apps/server/src/provider/Layers/CodexProvider.ts
Comment thread packages/client-runtime/src/state/providerWorkspaceSkills.ts
@jakeleventhal

Copy link
Copy Markdown
Contributor

My PR #3982 solves for both codex and Grok

- Forward configured launch arguments to workspace skill probes
- Clear retained workspace skills after failed refreshes
- Add focused probe and snapshot regressions
@Quicksaver

Copy link
Copy Markdown
Author

@jakeleventhal Thanks for the pointer. I confirmed #3982 carries the provider-neutral Codex/Grok approach and explicitly supersedes #3901. This branch still includes additional mobile composer/feed coverage, timeline skill decoration, shared web/mobile refresh/error policy, and bounded structured failure handling, so I’ll leave the overlap visible for maintainers to decide what to merge or port.

Comment thread packages/client-runtime/src/state/providerWorkspaceSkills.ts

@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 using high effort 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 a973e27. Configure here.

Comment thread apps/web/src/components/ChatView.tsx
- Pass a null skill cwd until a draft worktree materializes
- Keep local checkout skill queries and path searches unchanged
- Cover local, materialized, and future worktree resolution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ 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

3 participants