fix(opencode): keep slash commands when the workspace command probe times out #13264
main fromrefs/pull/13264/head·opened View on GitHubWhat Changed#
In OpenCodeDriver, the per-project command probe now times out after falling back on SDK errors, instead of before:
commands: loadOpenCodeCommands(client).pipe(
- Effect.timeout("10 seconds"),
Effect.orElseSucceed(() => []),
+ Effect.timeout("10 seconds"),
),
An OpenCode server that returns an error still gives an empty list, as before. A probe that takes longer than 10 seconds now fails instead of reporting that the project has no commands.
Fixes #13071.
Why#
OpenCode's command.list waits for the project's MCP servers to start. On a cold start with slow MCP servers it can take longer than 10 seconds. The old order turned that timeout into [], and ProviderRegistry.refreshWorkspaceSnapshot cached it as the project's workspace snapshot. The registry never probes a cwd again once it has a snapshot, so every OpenCode command vanished from the / menu, and only /model and /usage-limits remained until the server restarted. This matches the reporter's screenshot and their note that the commands show right after startup and disappear a few seconds later.
With the swap, the timeout fails the probe, recoverRefreshFailure keeps the cached providers, and nothing is cached for the project. The composer keeps showing the machine-level commands and retries after its cooldown, and the post-session-start refresh in ProviderCommandReactor retries too. Once OpenCode has finished starting, the retry returns the full list. Each timed-out attempt logs one "provider registry refresh failed" error while the MCP servers start.
I reproduced this in an isolated dev server with OpenCode 1.18.32 and a project that has a custom command plus an MCP server that takes 15 seconds to start:
main: the probe times out, the workspace snapshot is stored with no commands, a later retry is skipped, and the menu shows only/model /usage-limits.- This branch: the first probe fails and is not cached, the next retry succeeds in 8ms, and the menu shows
/model /init /review /hello /usage-limits.
The new OpenCodeDriver.test.ts hangs command.list and checks that snapshotForCwd fails. It fails on main.
Checklist#
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes (no UI change)
- I included a video for animation/interaction changes
Implemented with Claude Opus 5.5 in Claude Code, reviewed with Claude Fable 5.1.
Summary by CodeRabbit#
- Bug Fixes
- Workspace inventory now continues with an empty command list when loading commands returns an error.
- Probes still report a failure if command loading does not respond within 10 seconds.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
11b84f7Macroscope's review found this PR approvable — This is a small, targeted OpenCode bug fix with a regression test. It preserves existing successful and ordinary-error behavior while preventing timed-out command probes from caching an empty workspace command list.
Notes:
- Diff unchanged. Approvability was decided on eligibility alone.
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
faf71cfc-02ef-4360-a5f4-a652cf8bb801📥 Commits
Reviewing files that changed from the base of the PR and between f5ef0ddb90a8c36584e181b1913e7b8a5df30ffc and 11b84f74f687405d8673711bcc3551ba70e18c5a.
📒 Files selected for processing (2)
apps/server/src/provider/Drivers/OpenCodeDriver.test.tsapps/server/src/provider/Drivers/OpenCodeDriver.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
📝 Walkthrough
Walkthrough#
The OpenCode commands effect pipeline now applies its fallback before its timeout. A new test checks the workspace probe failure when command listing does not resolve within 10 seconds.
Changes#
OpenCode command timeout handling
Layer / File(s) Summary Commands pipeline and timeout test
apps/server/src/provider/Drivers/OpenCodeDriver.ts,apps/server/src/provider/Drivers/OpenCodeDriver.test.tsThe commands effect applies Effect.orElseSucceedbeforeEffect.timeout. The test uses a command-list promise that does not resolve, advances the test clock by 10 seconds, and checks for a failure detail containing “Failed to probe OpenCode commands”.Estimated code review effort: 2 (Simple) | ~10 minutes
Suggested reviewers:
maria-rcksMerge Risk: ⚪ Minimal · up to
11b84A timed-out OpenCode command probe can be retried rather than saving a fallback command list. No merge-blocking issue was established.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation Description check ✅ Passed The description clearly explains the change, the problem, the rationale, testing, linked issue, and checklist status. It is mostly complete; the UI screenshot item is correctly marked not applicable b… Title check ✅ Passed The title is concise and accurately describes the OpenCode timeout fix that preserves slash commands. Linked Issues check ✅ Passed Issue [ #13071] requires OpenCode custom commands to remain available for slash-command suggestions. The PR preserves successful command loading and changesloadWorkspaceInventoryso the 10-second ti…Out of Scope Changes check ✅ Passed The PR changes only the OpenCode command-loading error and timeout order and adds a focused regression test for the workspace probe. Both changes directly support issue [ #13071]. No unrelated change i…Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2… ✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create a new PR
Comment `@coderabbitai help` to get the list of available commands.juliusmarminge added labelsmacroscope-review
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Thanks for working on this. We merged the orchestrator V2 rewrite in #2829, and we are closing this PR as part of that transition.
The patch conflicts with the rewrite in apps/server/src/provider/Drivers/OpenCodeDriver.ts. Even where the conflict is small enough to rebase, we are asking for fresh PRs against the new base so we can review and verify the behavior in V2.
Sorry for the extra work this creates. If the change is still needed on V2, please rebuild it on current main, verify it there, and open a new PR linking back here. We're closing the current implementation without assuming the underlying request is resolved.
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed