fix(provider): resolve skills and slash commands against the workspace root #7882
ClosedCurlyPeter(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/7882/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -6661,3 +6694,4 @@66616694 interactionMode={interactionMode}66626695 lockedProvider={lockedProvider}66636696 providerStatuses={providerStatuses as ServerProvider[]}6697+ workspaceSkills={activeSkills}
- @@ -1936,0 +1944,21 @@1944+ // and that is exactly when the skill picker matters most.1945+ const project = yield* projectionSnapshotQuery1946+ .getProjectShellById(input.projectId)1947+ .pipe(1948+ Effect.mapError(1949+ (cause) =>1950+ new OrchestrationGetSnapshotError({1951+ message: "Failed to load project for skill discovery",1952+ cause,1953+ }),1954+ ),1955+ );1956+ if (Option.isNone(project)) {1957+ return yield* new OrchestrationGetSnapshotError({1958+ message: `Unknown project ${input.projectId}`,1959+ });1960+ }1961+ // An unknown thread id is not an error: a draft thread has no row.1962+ const worktreePath = input.threadId1963+ ? yield* projectionSnapshotQuery.getThreadShellById(input.threadId).pipe(1964+ Effect.map((thread) =>@@ -1936,0 +1947,21 @@1947+ .pipe(1948+ Effect.mapError(1949+ (cause) =>1950+ new OrchestrationGetSnapshotError({1951+ message: "Failed to load project for skill discovery",1952+ cause,1953+ }),1954+ ),1955+ );1956+ if (Option.isNone(project)) {1957+ return yield* new OrchestrationGetSnapshotError({1958+ message: `Unknown project ${input.projectId}`,1959+ });1960+ }1961+ // An unknown thread id is not an error: a draft thread has no row.1962+ const worktreePath = input.threadId1963+ ? yield* projectionSnapshotQuery.getThreadShellById(input.threadId).pipe(1964+ Effect.map((thread) =>1965+ Option.isSome(thread) ? thread.value.worktreePath : null,1966+ ),1967+ Effect.orElseSucceed(() => null),@@ -1113,9 +1139,14 @@1113- type: "provider-slash-command" as const,1114- provider: selectedProvider,1115- command,1116- label: `/${command.name}`,1117- description: command.description ?? command.input?.hint ?? "Run provider command",1118- }),1119- );1139+ const providerSlashCommandItems = (1140+ workspaceSlashCommands ??1141+ selectedProviderStatus?.slashCommands ??1142+ EMPTY_COMPOSER_SLASH_COMMANDS1143+ ).map((command) => ({1144+ id: `provider-slash-command:${selectedProvider}:${command.name}`,1145+ type: "provider-slash-command" as const,1146+ provider: selectedProvider,1147+ command,1148+ label: `/${command.name}`,1149+ description: command.description ?? command.input?.hint ?? "Run provider command",1150+ }));11201151 const query = composerTrigger.query.trim().toLowerCase();11211152 const skillItems = (selectedProviderStatus?.skills ?? [])
- @@ -54,4 +54,4 @@5454 makeProviderSnapshotSettingsSource,5555 type ProviderSnapshotSettings,5656 } from "../providerUpdateSettings.ts";57-import { makeClaudeCapabilitiesCacheKey, makeClaudeContinuationGroupKey } from "./ClaudeHome.ts";57+import { makeClaudeContinuationGroupKey } from "./ClaudeHome.ts";@@ -1934,3 +1934,4 @@19341934 ),19351935 { "rpc.aggregate": "workspace" },19361936 ),1937+ [WS_METHODS.providersWorkspaceSkills]: (input) =>
- @@ -1139,16 +1170,3 @@11391170 return searchSlashCommandItems(slashCommandItems, query);11401171 }11411172 if (composerTrigger.kind === "skill") {1142- return searchProviderSkills(selectedProviderStatus?.skills ?? [], composerTrigger.query).map(1143- (skill) => ({1144- id: `skill:${selectedProvider}:${skill.name}`,1145- type: "skill" as const,1146- provider: selectedProvider,1147- skill,1148- label: formatProviderSkillDisplayName(skill),1149- description:1150- skill.shortDescription ??1151- skill.description ??1152- (skill.scope ? `${skill.scope} skill` : "Run provider skill"),1153- }),1154- );@@ -2722,0 +2727,21 @@2727+ // sets to the user's home directory, so it reports user-scope skills only and2728+ // is empty on a machine that keeps none there. Falling back to it keeps the2729+ // picker working against a server that predates this RPC.2730+ const workspaceCapabilitiesQuery = useEnvironmentQuery(2731+ activeThread && activeProject && activeProviderInstanceId2732+ ? providerSkillsEnvironment.workspaceSkills({2733+ environmentId: activeThread.environmentId,2734+ input: {2735+ projectId: activeProject.id,2736+ instanceId: activeProviderInstanceId,2737+ // Only a persisted thread has a server-side row; a draft has none,2738+ // and the project root is the right answer for it anyway.2739+ ...(activeServerThread ? { threadId: activeServerThread.id } : {}),2740+ },2741+ })2742+ : null,2743+ );2744+ const activeSkills =2745+ workspaceCapabilitiesQuery.data?.skills ??2746+ activeProviderStatus?.skills ??2747+ EMPTY_PROVIDER_SKILLS;@@ -2720,3 +2721,21 @@27202721 const defaultInstanceId = defaultInstanceIdForDriver(selectedProvider);27212722 return providerStatuses.find((status) => status.instanceId === defaultInstanceId) ?? null;27222723 }, [activeProviderInstanceId, providerStatuses, selectedProvider]);2724+ // Skills for the `$` picker, resolved against this thread's workspace root.2725+ // `activeProviderStatus.skills` is machine-scoped: the server scans it once2726+ // per provider instance against its own cwd, which a packaged desktop build2727+ // sets to the user's home directory, so it reports user-scope skills only and2728+ // is empty on a machine that keeps none there. Falling back to it keeps the2729+ // picker working against a server that predates this RPC.2730+ const workspaceCapabilitiesQuery = useEnvironmentQuery(2731+ activeThread && activeProject && activeProviderInstanceId2732+ ? providerSkillsEnvironment.workspaceSkills({2733+ environmentId: activeThread.environmentId,2734+ input: {2735+ projectId: activeProject.id,2736+ instanceId: activeProviderInstanceId,2737+ // Only a persisted thread has a server-side row; a draft has none,2738+ // and the project root is the right answer for it anyway.2739+ ...(activeServerThread ? { threadId: activeServerThread.id } : {}),2740+ },2741+ })
juliusmarminge closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
cff0cc3d-bb17-4c6e-b8e3-4196638855a0You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
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