fix(server): resume OpenCode sessions from resumeCursor#2302
fix(server): resume OpenCode sessions from resumeCursor#2302Pedro-Revez-Silva wants to merge 4 commits intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
ApprovabilityVerdict: Needs human review This PR introduces new session resume functionality for OpenCode, changing how sessions are created versus resumed and adding new provider capabilities for cursor invalidation. The behavioral changes to session lifecycle management and an unresolved reviewer concern about provider compatibility warrant human review. You can customize Macroscope's approvability policy. Learn more. |
9ce0606 to
a52ce4a
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c3e0f9e. Configure here.

What Changed
OpenCodeAdapter.startSessionto resume an existing OpenCode session from a persistedresumeCursorinstead of always creating a new native sessionresumeCursorInvalidationReasonsso restart cursor handling is capability-driven rather than hard-coded in the orchestration layerWhy
T3 already persists provider resume state, but the OpenCode adapter ignored that state and always started a fresh OpenCode session. That broke continuity when T3 knew the OpenCode
sessionIDand needed to reconnect to it.The first fix made OpenCode reuse
resumeCursor, but review correctly pointed out that some restarts make an OpenCode cursor unsafe: resuming after a permission-mode change can keep the old permission behavior, and resuming after a cwd change can keep the old workspace.This update keeps the fix provider-compatible by moving that decision into provider capabilities. OpenCode opts into clearing cursors for runtime-mode and cwd changes. Other providers keep the previous restart behavior unless they explicitly declare additional invalidation reasons.
UI Changes
None.
Verification
bun fmtbun lintbun typecheckbun run testChecklist
Note
Medium Risk
Changes provider session startup and restart behavior around
resumeCursor, which can affect session continuity and remote OpenCode session lifecycle on restarts. Risk is moderate due to cross-cutting impact on orchestration restart logic and provider adapter behavior.Overview
OpenCode sessions can now be resumed using an existing
resumeCursor.OpenCodeAdapter.startSessionparses aresumeCursorwith asessionIDand, when present, callssession.getinstead of always creating a new OpenCode session; the returnedProviderSessionpersists the resolved directory back into theresumeCursorand uses it forcwd.Session restart behavior now respects provider-declared cursor invalidation.
ProviderAdapterCapabilitiesaddsresumeCursorInvalidationReasons,OpenCodeAdapterdeclares it, andProviderCommandReactorclears vs forwardsresumeCursoron restarts based on runtime-mode, workspace (cwd), or unsupported model-change triggers; tests were added to cover cursor dropping on workspace/runtime-mode restarts and OpenCode resume behavior.Reviewed by Cursor Bugbot for commit f4b5b36. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Resume OpenCode sessions from a resume cursor in
startSessionOpenCodeAdapter.startSessionnow callsclient.session.getinstead ofclient.session.createwhen a validresumeCursoris provided, derivingcwdfrom the resumed session payload.ProviderResumeCursorInvalidationReasontype and an optionalresumeCursorInvalidationReasonsfield toProviderAdapterCapabilities; OpenCode exposes["runtime-mode-change", "cwd-change"].ProviderCommandReactorclearsresumeCursorbefore restarting a session when the provider's capabilities indicate invalidation for the relevant change (runtime mode, cwd, or unsupported model change).startSessionskipssession.abortwhen the session being cleaned up was a resumed session.resumeCursoris present.Macroscope summarized f4b5b36.