Skip to content

fix(grok): surface ACP slash commands and ignore skills-reload ids#4110

Open
Dishah3241 wants to merge 6 commits into
pingdotgg:mainfrom
Dishah3241:fix/grok-slash-commands-skills-reload
Open

fix(grok): surface ACP slash commands and ignore skills-reload ids#4110
Dishah3241 wants to merge 6 commits into
pingdotgg:mainfrom
Dishah3241:fix/grok-slash-commands-skills-reload

Conversation

@Dishah3241

@Dishah3241 Dishah3241 commented Jul 17, 2026

Copy link
Copy Markdown

Summary

  • Grok slash/skills empty in T3 UI: Grok already advertises commands over ACP (session/updateavailable_commands_update, including user skills). The Grok provider probe only discovered models and never filled ServerProvider.slashCommands, so the composer menu stayed empty (Claude works because it maps SDK init commands).
  • ACP crash on skills-reload: Grok emits non-numeric JSON-RPC ids such as skills-reload. Effect RpcClient does BigInt(requestId) and throws Cannot convert skills-reload to a BigInt, which showed up during checkGrokProviderStatus / startSession.

Changes

  1. packages/effect-acp: Drop Exit/Chunk messages whose requestId is not a valid Effect RPC bigint and not extension-pending, so RpcClient never BigInt-crashes on agent-internal string ids.
  2. GrokProvider: During ACP model discovery, listen for available_commands_update, map via parseAcpAvailableCommands, and publish as slashCommands on the ready snapshot (with a short wait after session/new, since Grok sends commands after the create response).
  3. Tests for the mapper and the non-numeric id path.

Test plan

  • vp run --filter effect-acp test (31 passed)
  • vp run --filter t3 test (includes new parse tests + GrokProvider; 1425 passed)
  • vp run --filter effect-acp --filter t3 typecheck
  • Manual: install Grok CLI with skills under ~/.grok/skills/, open T3 → Grok → confirm / menu lists skills (e.g. factory-planner if present)
  • Manual: no Cannot convert skills-reload to a BigInt in server logs on Grok session start
  • Manual: Claude slash commands still populate

Notes

  • Live mid-session command refresh is still not wired (parseSessionUpdateEvent still ignores available_commands_update for the thread event stream). Provider snapshot fill is enough for the composer menu, matching how Claude exposes commands.
  • Small reliability/interop fix; happy to adjust if you prefer a different collection point.

Note

Medium Risk
Touches ACP wire handling and Grok status probing; incorrect filtering could hide legitimate RPC responses, but changes are scoped to non-numeric ids and provider snapshot enrichment.

Overview
Fixes an empty Grok / composer menu and ACP stream crashes during Grok provider checks.

Grok provider discovery now uses ServerConfig.cwd (not process.cwd()) for ACP session/new, listens for available_commands_update, maps entries via parseAcpAvailableCommands, and publishes slashCommands on the ready provider snapshot. Slash collection is best-effort with a short bounded wait so it does not blow the existing model-discovery timeout.

effect-acp protocol drops JSON-RPC responses whose requestId is not a valid bigint when they are not extension-pending (e.g. Grok’s skills-reload), avoiding BigInt(requestId) crashes that tear down the stream.

Adds unit tests for the mapper, the protocol path, and explicit workspace cwd on checkGrokProviderStatus.

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

Note

Surface ACP slash commands in Grok provider and drop non-numeric JSON-RPC response ids

  • ACP discovery in GrokProvider.ts now registers a session update handler before acp.start() to capture available_commands_update notifications, polls briefly for slash commands, and returns them alongside models in the provider status.
  • Adds parseAcpAvailableCommands.ts to normalize and deduplicate ACP commands into ServerProviderSlashCommand objects before surfacing them.
  • protocol.ts now drops incoming JSON-RPC responses with non-numeric ids that don't correspond to a tracked pending request, preventing BigInt conversion crashes in the Effect RpcClient.
  • checkGrokProviderStatus and discoverGrokModelsViaAcp now accept an explicit cwd parameter passed from ServerConfig, replacing implicit reliance on process.cwd().
  • Behavioral Change: slash command discovery introduces bounded polling (capped by the overall ACP discovery timeout) that may delay provider status responses slightly when commands arrive shortly after session start.

Macroscope summarized 4fde55d.

Summary by CodeRabbit

  • New Features

    • Grok provider discovery now includes available models and ACP slash commands.
    • Slash commands include descriptions and input hints, with duplicate commands handled cleanly.
    • Grok discovery now respects the active workspace directory.
  • Bug Fixes

    • Improved ACP protocol stability by ignoring unsupported response identifiers, preventing connection failures during session updates.
    • Fixed Grok status checks that could fail or hang when ACP startup or discovery encounters errors.

Grok advertises skills via ACP available_commands_update, but the provider
probe never mapped them into ServerProvider.slashCommands, so the T3
composer stayed empty. Collect those commands during ACP discovery (same
shape Claude fills from SDK init).

Separately, Grok emits non-numeric JSON-RPC ids such as skills-reload.
Effect RpcClient BigInt-coerces request ids and threw, tearing the ACP
stream. Drop non-numeric response ids that are not extension-pending
before they reach RpcClient.
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Grok ACP discovery now receives the workspace directory, discovers slash commands alongside models, and includes them in provider snapshots. ACP transport filtering ignores non-numeric response IDs, with regression coverage for continued session-update decoding.

Changes

Grok ACP discovery

Layer / File(s) Summary
ACP command mapping
apps/server/src/provider/acp/parseAcpAvailableCommands.ts, apps/server/src/provider/acp/parseAcpAvailableCommands.test.ts
ACP commands are mapped to deduplicated provider slash commands, including optional descriptions and input hints.
Workspace-aware discovery
apps/server/src/provider/Layers/GrokProvider.ts
Grok ACP discovery accepts cwd, captures command updates, waits briefly for commands, and returns models with slash commands.
Provider snapshot wiring
apps/server/src/provider/Drivers/GrokDriver.ts, apps/server/src/provider/Layers/GrokProvider.ts, apps/server/src/provider/Layers/GrokProvider.test.ts
Provider creation passes the configured workspace directory, and tests cover ACP startup failure without hanging probes.

ACP transport filtering

Layer / File(s) Summary
Numeric request ID forwarding
packages/effect-acp/src/protocol.ts
Unmatched exit and streaming chunk messages are forwarded only when their request IDs are numeric.
Transport regression coverage
packages/effect-acp/src/protocol.test.ts
A protocol test verifies that non-numeric response IDs do not terminate processing before a valid session update is decoded.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: juliusmarminge

Poem

I’m a rabbit with commands in my hat,
Grok finds models—imagine that!
Workspace paths guide the ACP trail,
Odd IDs now quietly fail.
Sessions hop onward, safe and bright—
Thump-thump, the tests all pass tonight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main fixes: Grok ACP slash-command surfacing and filtering non-numeric IDs.
Description check ✅ Passed The description explains what changed, why, and testing; it is mostly complete despite not following the template headings exactly.
✨ 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 Jul 17, 2026
Comment thread apps/server/src/provider/Layers/GrokProvider.ts
@macroscopeapp

macroscopeapp Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces new slash command discovery capability with non-trivial async polling logic, timeout budgeting, and state management. Despite the 'fix' framing, this is a feature addition that changes what gets surfaced to users and warrants human review.

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

The ACP discovery session used process.cwd(), so project-local skills
could differ from live Grok threads that open under ServerConfig.cwd.
Pass the workspace cwd from GrokDriver into checkGrokProviderStatus /
session/new, matching Claude's probe pattern.
@Dishah3241

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/server/src/provider/Layers/GrokProvider.ts`:
- Around line 145-201: Use an Option-wrapped state for slash commands so
waitForGrokSlashCommands can distinguish no available_commands_update
notification from an explicitly empty parsed command list. Initialize the Ref as
None, set it to Some(parseAcpAvailableCommands(...)) in the
acp.handleSessionUpdate callback, and have the polling loop return the contained
list whenever the Option is Some, including an empty list; preserve the timeout
fallback and update the discovery flow in discoverGrokModelsViaAcp accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: de9b0895-a293-462f-b63a-9b187d0c101c

📥 Commits

Reviewing files that changed from the base of the PR and between 5ca3266 and 208ee44.

📒 Files selected for processing (7)
  • apps/server/src/provider/Drivers/GrokDriver.ts
  • apps/server/src/provider/Layers/GrokProvider.test.ts
  • apps/server/src/provider/Layers/GrokProvider.ts
  • apps/server/src/provider/acp/parseAcpAvailableCommands.test.ts
  • apps/server/src/provider/acp/parseAcpAvailableCommands.ts
  • packages/effect-acp/src/protocol.test.ts
  • packages/effect-acp/src/protocol.ts

Comment thread apps/server/src/provider/Layers/GrokProvider.ts
Use Option on the slash-command probe ref so waitForGrokSlashCommands
returns immediately on an explicit empty command list instead of
polling until timeout when no non-empty update arrives.
Comment thread apps/server/src/provider/Layers/GrokProvider.ts Outdated
CodeRabbit: track probe command state with Option (pending vs seen).
Cursor: do not return early on Some([]); ACP may send empty then a
later non-empty "changed" update. Return non-empty immediately; on
timeout use the latest seen list (or []).

@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 1d7fa62. Configure here.

Comment thread apps/server/src/provider/Layers/GrokProvider.ts Outdated
An empty available_commands_update no longer burns the full slash-command
wait budget, which could push ACP discovery past the 15s outer timeout.
Wait up to 250ms after empty for a non-empty follow-up, else accept [].
Still wait up to 2s when no notification has arrived yet.
Comment thread apps/server/src/provider/Layers/GrokProvider.ts Outdated
After acp.start(), slash wait no longer always allocates a fresh 2s
window. Cap it by time left under the 15s discovery timeout (minus a
small reserve) so a slow session setup cannot discard already-discovered
models. maxWaitMs <= 0 returns current commands immediately.
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