fix(claude): show commands that Claude Code mods register in the / menu #17432
Closedsergical(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/17432/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
- apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts line 7452OutdatedResolvedby sergical(GitHub profile, opens in a new tab)@@ -7414,2 +7432,21 @@74147432 };74157433 yield* Ref.set(queryContext, context);7434+ const reportSessionCommands = adapterOptions.onSessionCommands;7435+ const sessionCwd = turnInput.runtimePolicy.cwd;7436+ // Best effort and off the message loop: a slow or failing command7437+ // lookup must not hold up or fail the turn.7438+ const forkSessionCommandsReport = (7439+ commands: Effect.Effect<ReadonlyArray<SlashCommand>, ClaudeAgentSdkQueryRunnerError>,7440+ ) =>7441+ reportSessionCommands === undefined || sessionCwd === null7442+ ? Effect.void7443+ : commands.pipe(7444+ Effect.flatMap((list) =>7445+ reportSessionCommands({ cwd: sessionCwd, commands: list }),7446+ ),7447+ Effect.catchCause((cause) =>7448+ Effect.logDebug("orchestration-v2.claude-session-commands-report-failed", {7449+ cause,7450+ }),7451+ ),7452+ Effect.forkIn(sessionScope),
coderabbitai[bot](GitHub profile, opens in a new tab) requested changes
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts line 7468OutdatedResolvedby sergical(GitHub profile, opens in a new tab)@@ -7422,4 +7461,8 @@74227461 ) {74237462 context.permissionMode = message.permissionMode;74247463 }7425- return handleSdkMessage({ query: querySession, message });7464+ const sessionCommandsReport =7465+ message.type !== "system"7466+ ? Effect.void7467+ : message.subtype === "init"7468+ ? forkSessionCommandsReport(querySession.supportedCommands)apps/server/src/provider/Drivers/ClaudeDriver.ts line 377OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -344,4 +373,5 @@344373 accentColor,345374 enabled,346375 snapshot,347- invalidateCaches: Cache.invalidateAll(capabilitiesProbeCache),376+ invalidateCaches: Cache.invalidateAll(capabilitiesProbeCache).pipe(377+ Effect.andThen(Ref.set(sessionSlashCommandsByCwd, new Map())),apps/server/src/provider/ProviderRegistry.ts line 226OutdatedResolvedby sergical(GitHub profile, opens in a new tab)@@ -208,3 +209,18 @@208209 };209210 }210211212+/**213+ * Adds slash commands a live session reported to a cwd that already has a214+ * workspace snapshot. Existing entries win; without a snapshot the next scan215+ * of that cwd picks the commands up from the driver.216+ */217+export function addSessionSlashCommands(218+ provider: ServerProvider,219+ cwd: string,220+ slashCommands: ReadonlyArray<ServerProviderSlashCommand>,221+): ServerProvider {222+ const workspaceSnapshots = provider.workspaceSnapshots;223+ const snapshot = workspaceSnapshots?.find((candidate) => candidate.cwd === cwd);224+ if (workspaceSnapshots === undefined || snapshot === undefined) return provider;225+ const known = new Set(snapshot.slashCommands.map((command) => command.name.toLowerCase()));226+ const added = slashCommands.filter((command) => !known.has(command.name.toLowerCase()));coderabbitai[bot](GitHub profile, opens in a new tab) approved these changes
coderabbitai[bot](GitHub profile, opens in a new tab) requested changes
apps/server/src/provider/Drivers/ClaudeDriver.ts lines 400 to 408Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -348,8 +381,13 @@348381 enabled,349382 snapshot,350383 invalidateCaches: Cache.invalidateAll(capabilitiesProbeCache),384+ sessionSlashCommands: Stream.fromPubSub(sessionSlashCommandUpdates),351385 snapshotForCwd: (cwd: string) =>352386 snapshot.getSnapshot.pipe(353387 Effect.flatMap((machineSnapshot) =>354388 probeClaudeWorkspaceSnapshot(effectiveConfig, machineSnapshot, cwd, processEnv),355389 ),390+ Effect.flatMap((scanned) =>391+ Ref.modify(slashCommandsByCwd, (byCwd) =>392+ recordClaudeProbedSlashCommands(byCwd, cwd, scanned.slashCommands),393+ ).pipe(Effect.map((slashCommands) => ({ ...scanned, slashCommands }))),coderabbitai[bot](GitHub profile, opens in a new tab) approved these changes
maria-rcks closed this
Sign in to join this conversation.



macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed